solve-engine 2.15.0 → 2.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/{PackageCompatibility-C2IQZ_w3.d.cts → PackageCompatibility-BET0iFb9.d.cts} +1 -1
  2. package/dist/{PackageCompatibility-Cl7GF_Iu.d.ts → PackageCompatibility-CHQ4kDT8.d.ts} +1 -1
  3. package/dist/{PackageRegistry-CZO1IbS-.d.cts → PackageRegistry-DzmG-Rvu.d.cts} +29 -0
  4. package/dist/{PackageRegistry-CK_JoX50.d.ts → PackageRegistry-YmfowYr1.d.ts} +29 -0
  5. package/dist/chunk-35RNQ2OQ.js +5 -0
  6. package/dist/chunk-35RNQ2OQ.js.map +1 -0
  7. package/dist/{chunk-Q7HPPLMG.js → chunk-55B4PSPM.js} +2 -2
  8. package/dist/{chunk-Q7HPPLMG.js.map → chunk-55B4PSPM.js.map} +1 -1
  9. package/dist/{chunk-YFX53MZF.js → chunk-5CWVWMIY.js} +2 -2
  10. package/dist/chunk-5CWVWMIY.js.map +1 -0
  11. package/dist/{chunk-3PDDKWTJ.js → chunk-5EX2FCM3.js} +3 -3
  12. package/dist/{chunk-3PDDKWTJ.js.map → chunk-5EX2FCM3.js.map} +1 -1
  13. package/dist/chunk-7EMZOBGW.cjs +3 -0
  14. package/dist/chunk-7EMZOBGW.cjs.map +1 -0
  15. package/dist/chunk-ERMNQ5QJ.js +2 -0
  16. package/dist/chunk-ERMNQ5QJ.js.map +1 -0
  17. package/dist/{chunk-RC4M6HBX.cjs → chunk-LZSSAH5D.cjs} +2 -2
  18. package/dist/chunk-LZSSAH5D.cjs.map +1 -0
  19. package/dist/chunk-SPOECHDG.cjs +5 -0
  20. package/dist/chunk-SPOECHDG.cjs.map +1 -0
  21. package/dist/{chunk-3Y56PSQD.cjs → chunk-VOTTSM4L.cjs} +3 -3
  22. package/dist/{chunk-3Y56PSQD.cjs.map → chunk-VOTTSM4L.cjs.map} +1 -1
  23. package/dist/chunk-W64AWQCX.js +3 -0
  24. package/dist/chunk-W64AWQCX.js.map +1 -0
  25. package/dist/{chunk-EEUA3OJ6.cjs → chunk-XZYZS4BP.cjs} +2 -2
  26. package/dist/{chunk-EEUA3OJ6.cjs.map → chunk-XZYZS4BP.cjs.map} +1 -1
  27. package/dist/chunk-Z4BXU65Y.cjs +2 -0
  28. package/dist/chunk-Z4BXU65Y.cjs.map +1 -0
  29. package/dist/constants.cjs +1 -1
  30. package/dist/constants.js +1 -1
  31. package/dist/engine.cjs +1 -1
  32. package/dist/engine.d.cts +2 -2
  33. package/dist/engine.d.ts +2 -2
  34. package/dist/engine.js +1 -1
  35. package/dist/index.cjs +1 -1
  36. package/dist/index.d.cts +3 -3
  37. package/dist/index.d.ts +3 -3
  38. package/dist/index.js +1 -1
  39. package/dist/language.d.cts +2 -2
  40. package/dist/language.d.ts +2 -2
  41. package/dist/normalizer.cjs +1 -1
  42. package/dist/normalizer.js +1 -1
  43. package/dist/packages.cjs +1 -1
  44. package/dist/packages.d.cts +1 -1
  45. package/dist/packages.d.ts +1 -1
  46. package/dist/packages.js +1 -1
  47. package/dist/testing.cjs +2 -2
  48. package/dist/testing.d.cts +2 -2
  49. package/dist/testing.d.ts +2 -2
  50. package/dist/testing.js +1 -1
  51. package/dist/worker.cjs +2 -2
  52. package/dist/worker.d.cts +1 -1
  53. package/dist/worker.d.ts +1 -1
  54. package/dist/worker.js +1 -1
  55. package/package.json +1 -1
  56. package/dist/chunk-4IIFFJTJ.js +0 -5
  57. package/dist/chunk-4IIFFJTJ.js.map +0 -1
  58. package/dist/chunk-5SDSIRPL.js +0 -2
  59. package/dist/chunk-5SDSIRPL.js.map +0 -1
  60. package/dist/chunk-AYTEPHRO.js +0 -3
  61. package/dist/chunk-AYTEPHRO.js.map +0 -1
  62. package/dist/chunk-FPGYRFJY.cjs +0 -5
  63. package/dist/chunk-FPGYRFJY.cjs.map +0 -1
  64. package/dist/chunk-HDGARCI2.cjs +0 -2
  65. package/dist/chunk-HDGARCI2.cjs.map +0 -1
  66. package/dist/chunk-KKMLFYVW.cjs +0 -3
  67. package/dist/chunk-KKMLFYVW.cjs.map +0 -1
  68. package/dist/chunk-RC4M6HBX.cjs.map +0 -1
  69. package/dist/chunk-YFX53MZF.js.map +0 -1
@@ -1,3 +0,0 @@
1
- 'use strict';var chunkW5ELYJ4Z_cjs=require('./chunk-W5ELYJ4Z.cjs'),chunkHDGARCI2_cjs=require('./chunk-HDGARCI2.cjs'),chunkFVQWN5HZ_cjs=require('./chunk-FVQWN5HZ.cjs'),chunkRC4M6HBX_cjs=require('./chunk-RC4M6HBX.cjs'),chunkUURM7P3P_cjs=require('./chunk-UURM7P3P.cjs'),chunkZLRJ7TDP_cjs=require('./chunk-ZLRJ7TDP.cjs'),chunkEEVUKZ5B_cjs=require('./chunk-EEVUKZ5B.cjs'),chunkGWCBPITD_cjs=require('./chunk-GWCBPITD.cjs'),chunkTLG7VZRX_cjs=require('./chunk-TLG7VZRX.cjs'),chunk5TVI2UPZ_cjs=require('./chunk-5TVI2UPZ.cjs'),chunk2XZCLDHJ_cjs=require('./chunk-2XZCLDHJ.cjs'),chunk6U66HQKQ_cjs=require('./chunk-6U66HQKQ.cjs'),chunkBKSKZA4W_cjs=require('./chunk-BKSKZA4W.cjs'),chunkFAGFPVYK_cjs=require('./chunk-FAGFPVYK.cjs'),chunk5IJD5L3O_cjs=require('./chunk-5IJD5L3O.cjs'),chunkS3DFU33X_cjs=require('./chunk-S3DFU33X.cjs'),chunkWEAKI5V5_cjs=require('./chunk-WEAKI5V5.cjs'),chunk6QRHN3I6_cjs=require('./chunk-6QRHN3I6.cjs'),chunkNAZ6PGLS_cjs=require('./chunk-NAZ6PGLS.cjs');var Fu=/^\d{1,3}(\.\d{3}){2,}$/,Hu=/^\d*\.\d*$/,xr=class{constructor(){this.category="Arithmetic";}parse(e,o,t){let n,i=null,a=o.value;if(a.startsWith("0x")||a.startsWith("0X")){if(n=parseInt(a,16),Number.isNaN(n))throw chunkNAZ6PGLS_cjs.c.parsing("INVALID_NUMBER_LITERAL",`Invalid hex literal: "${a}"`,{raw:a})}else if(a.startsWith("0b")||a.startsWith("0B")){if(n=parseInt(a.slice(2),2),Number.isNaN(n))throw chunkNAZ6PGLS_cjs.c.parsing("INVALID_NUMBER_LITERAL",`Invalid binary literal: "${a}"`,{raw:a})}else if(a.startsWith("0o")||a.startsWith("0O")){if(n=parseInt(a.slice(2),8),Number.isNaN(n))throw chunkNAZ6PGLS_cjs.c.parsing("INVALID_NUMBER_LITERAL",`Invalid octal literal: "${a}"`,{raw:a})}else if(Fu.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),Hu.test(c)&&(i=c);}if(i!==null){t.emitOpcode(16),t.emitString(i);return}t.emitOpcode(10),t.emitNumber(n);}};var Ce=class{constructor(e){this.opcode=e;this.category="Arithmetic";}parse(e,o,t){e.parseExpression(60,t),t.emitOpcode(this.opcode);}};var k=class{constructor(e,o,t=false){this.opcode=o;this.category="Arithmetic";this.bindingPower=e,this.rightBindingPower=t?e-1:e;}parse(e,o,t,n){e.parseExpression(this.rightBindingPower,n),n.emitOpcode(this.opcode);}};var Rr=class{constructor(){this.category="Arithmetic";}parse(e,o,t){e.parseExpression(0,t);let n=1;for(;e.match("COMMA");)e.parseExpression(0,t),n++;e.consume("RPAREN"),n>1&&(t.emitOpcode(152),t.emitIndex(1),t.emitIndex(n));}};var $e=class{constructor(){this.category="Arithmetic";}parse(e,o,t){let n=o.type==="PI"?Math.PI:Math.E;t.emitOpcode(10),t.emitNumber(n);}};var zu={k:3,M:6,G:9,B:9,T:12},Gu={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 $u(r,e){let o=r.indexOf("."),t=o===-1?r:r.slice(0,o),n=o===-1?"":r.slice(o+1);n.length<e&&(n=n.padEnd(e,"0"));let i=t+n.slice(0,e),a=n.slice(e);return a?`${i}.${a}`:i}function fa(r=65){return {name:"arithmetic:large-number-suffix",priority:r,match(e,o){let t=e[o];if(t.type!=="NUMBER"||!Ku.test(t.text))return null;let n=e[o+1];if(!n||n.type!=="IDENT"&&n.type!=="UNIT")return null;let i=t.offset+t.text.length===n.offset,a=n.type==="UNIT"?void 0:Gu[n.value.toLowerCase()],s=i?zu[n.value]??a:a;if(s===void 0)return null;let l=$u(t.text,s);return {consumed:2,replacement:[chunkRC4M6HBX_cjs.b("NUMBER",l,e.slice(o,o+2))],ruleName:"arithmetic:large-number-suffix"}}}}var Ko={name:"solve-arithmetic",prefixParselets:{NUMBER:new xr,LPAREN:new Rr,PI:new $e,E:new $e,PLUS:new Ce(27),MINUS:new Ce(26),BIT_NOT:new Ce(36)},infixParselets:{PLUS:new k(chunkFVQWN5HZ_cjs.a.Sum,20),AND_CONJ:new k(chunkFVQWN5HZ_cjs.a.Conjunction,20),MINUS:new k(chunkFVQWN5HZ_cjs.a.Sum,21),STAR:new k(chunkFVQWN5HZ_cjs.a.Product,22),SLASH:new k(chunkFVQWN5HZ_cjs.a.Product,23),MOD:new k(chunkFVQWN5HZ_cjs.a.Product,24),CARET:new k(chunkFVQWN5HZ_cjs.a.Exponent,25,true),TIMES_BY:new k(chunkFVQWN5HZ_cjs.a.Product,22),MULTIPLY_BY:new k(chunkFVQWN5HZ_cjs.a.Product,22),DIVIDE_BY:new k(chunkFVQWN5HZ_cjs.a.Product,23),LSHIFT:new k(chunkFVQWN5HZ_cjs.a.Shift,30),RSHIFT:new k(chunkFVQWN5HZ_cjs.a.Shift,31),URSHIFT:new k(chunkFVQWN5HZ_cjs.a.Shift,32),BIT_AND:new k(chunkFVQWN5HZ_cjs.a.BitwiseAnd,33),BIT_OR:new k(chunkFVQWN5HZ_cjs.a.BitwiseOr,34),BIT_XOR:new k(chunkFVQWN5HZ_cjs.a.BitwiseXor,35)},normalizerRules:[fa()]};var Or=class{constructor(){this.category="Percentage";this.bindingPower=chunkFVQWN5HZ_cjs.a.Prefix;}parse(e,o,t,n){n.emitOpcode(10),n.emitNumber(100),n.emitOpcode(23),n.emitOpcode(74);}};var Cr=class{constructor(){this.category="Percentage";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,t,n){if(Ta(e,"what")){e.consume(),this.parseWhatRate(e,n);return}this.parseWhatBase(e,n);}parseWhatRate(e,o){if(!e.match("PERCENT"))throw chunkNAZ6PGLS_cjs.c.parsing("IS_WHAT_EXPECTED_PERCENT",'Expected "%" after "is what", as in "20 is what % of 200"');let t=Wu(e);if(t===null){o.emitOpcode(74);return}e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,o),o.emitOpcode(23),t==="off"?(o.emitOpcode(10),o.emitNumber(1),o.emitOpcode(2),o.emitOpcode(21)):t==="on"&&(o.emitOpcode(10),o.emitNumber(1),o.emitOpcode(21)),o.emitOpcode(74);}parseWhatBase(e,o){if(e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,o),e.match("TO")){Ea(e,"what",'"81 is 9 to what power"'),Ea(e,"power",'"81 is 9 to what power"'),o.emitOpcode(51),o.emitIndex(da),o.emitIndex(1),o.emitOpcode(2),o.emitOpcode(51),o.emitIndex(da),o.emitIndex(1),o.emitOpcode(2),o.emitOpcode(23);return}let t=e.match("OF_WHAT")?"of":e.match("OFF_WHAT")?"off":e.match("ON_WHAT")?"on":null;if(t===null)throw chunkNAZ6PGLS_cjs.c.parsing("IS_WHAT_EXPECTED_PREPOSITION",'Expected "of what", "off what" or "on what", as in "20 is 10% of what"');if(t==="of"){o.emitOpcode(23);return}o.emitOpcode(10),o.emitNumber(1),t==="off"?(o.emitOpcode(2),o.emitOpcode(21)):o.emitOpcode(20),o.emitOpcode(23);}},da=5;function Ta(r,e){return (r.peek()?.text??"").toLowerCase()===e}function Ea(r,e,o){if(!Ta(r,e))throw chunkNAZ6PGLS_cjs.c.parsing("IS_WHAT_EXPECTED_WORD",`Expected "${e}" here, as in ${o}`);r.consume();}function Wu(r){if(r.match("OF"))return "of";let e=(r.peek()?.text??"").toLowerCase();return e==="off"||e==="on"?(r.consume(),e):null}var We=class{constructor(e){this.sign=e;this.category="Percentage";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,t,n){e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,n),n.emitOpcode(2),n.emitOpcode(10),n.emitNumber(1),this.sign===1?n.emitOpcode(20):(n.emitOpcode(2),n.emitOpcode(21)),n.emitOpcode(22);}};function Na(r=68){return {name:"percentage:on-off",priority:r,match(e,o){if(e[o]?.type!=="PERCENT")return null;let t=e[o+1];if(t?.type!=="IDENT")return null;let n=(t.text??t.value??"").toLowerCase();return n!=="on"&&n!=="off"||(e[o+2]?.text??"").toLowerCase()==="what"?null:{consumed:2,replacement:[e[o],chunkRC4M6HBX_cjs.b(n==="on"?"PCT_ON":"PCT_OFF",n,[t])],ruleName:"percentage:on-off"}}}}var Ir=class{constructor(){this.category="Percentage";this.bindingPower=chunkFVQWN5HZ_cjs.a.Product;}parse(e,o,t,n){e.parseExpression(this.bindingPower,n),n.emitOpcode(22);}};var hr=class{constructor(){this.category="Percentage";this.bindingPower=chunkFVQWN5HZ_cjs.a.Product;}parse(e,o,t,n){e.parseExpression(this.bindingPower,n),n.emitOpcode(2),n.emitOpcode(23);}};var Ye=class{constructor(e){this.sign=e;this.category="Percentage";this.bindingPower=chunkFVQWN5HZ_cjs.a.Product;}parse(e,o,t,n){n.emitOpcode(10),n.emitNumber(1),this.sign===1?n.emitOpcode(20):(n.emitOpcode(2),n.emitOpcode(21)),e.parseExpression(this.bindingPower,n),n.emitOpcode(2),n.emitOpcode(23);}};var je=class{constructor(e){this.multiplier=e;this.category="Percentage";}parse(e,o,t){e.parseExpression(0,t);let n=e.peek();n&&(n.type==="IDENT"||n.type==="BY")&&e.consume(),t.emitOpcode(10),t.emitNumber(1),e.parseExpression(0,t),e.peek()?.type==="PERCENT"&&e.consume(),t.emitOpcode(this.multiplier>0?20:21),t.emitOpcode(22);}};var Xe=class{constructor(e){this.multiplier=e;this.category="Percentage";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,t,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 Sr=class{constructor(){this.category="Percentage";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,t,n){if(o.type==="UNIT")return;let i=e.peek();if(i&&((i.type==="UNIT"||i.type==="IDENT")&&chunkWEAKI5V5_cjs.b(i.value)||i.type==="IN")){e.consume(),n.emitOpcode(13),n.emitString(i.value),n.emitOpcode(84);return}e.parseExpression(this.bindingPower,n),n.emitOpcode(2),n.emitOpcode(23),n.emitOpcode(10),n.emitNumber(1),n.emitOpcode(21),n.emitOpcode(74);}};var Yu={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 ju(r){if(r.type==="NUMBER"){let e=Number(r.value);return Number.isInteger(e)&&e>=0?e:null}return r.type==="IDENT"?Yu[r.value.toLowerCase()]??null:null}var Qe=class{constructor(e){this.sign=e;this.category="Percentage";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,t,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(),t=e.peekAt(1);if(!o||!t||t.type!=="STAR"||t.value.toLowerCase()!=="times")return null;let n=ju(o);return n===null?null:(e.consume(),e.consume(),n)}consumeChainThen(e){if(e.peek()?.type!=="THEN")return;let o=e.peekAt(1)?.type;(o==="PCT_UP"||o==="PCT_DOWN")&&e.consume();}};function ya(r,e){let o=r[e];if(o?.type!=="IDENT")return null;let t=(o.text??o.value??"").toLowerCase();return t!=="up"&&t!=="down"||r[e+1]?.type!=="NUMBER"||r[e+2]?.type!=="PERCENT"?null:chunkRC4M6HBX_cjs.b(t==="up"?"PCT_UP":"PCT_DOWN",t,[o])}function ga(r=68){return {name:"percentage:up-down",priority:r,match(e,o){let t=e[o];if(t&&(t.type==="NUMBER"||t.type==="RPAREN")){let i=ya(e,o+1);if(i)return {consumed:2,replacement:[t,i],ruleName:"percentage:up-down"}}let n=ya(e,o);return n?{consumed:1,replacement:[n],ruleName:"percentage:up-down"}:null}}}var $o={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 Or,IS:new Cr,PCT_ON:new We(1),PCT_OFF:new We(-1),OF:new Ir,OF_WHAT_IS:new hr,ON_WHAT_IS:new Ye(1),OFF_WHAT_IS:new Ye(-1),TO:new Sr,INCREASE_BY:new Xe(1),DECREASE_BY:new Xe(-1),PCT_UP:new Qe(1),PCT_DOWN:new Qe(-1)},prefixParselets:{INCREASE:new je(1),DECREASE:new je(-1)},normalizerRules:[Na(),ga()]};var Wo={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},Lr=class{constructor(){this.category="Function";}parse(e,o,t){let n=o.value.toLowerCase(),i=Wo[n];if(i===void 0)throw chunkNAZ6PGLS_cjs.c.execution("UNKNOWN_FUNCTION",`Unknown function: ${n}`,{functionName:n});e.consume("LPAREN");let a=0;if(e.peek()?.type!=="RPAREN")for(e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,t),a++;e.match("COMMA");)e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,t),a++;e.consume("RPAREN"),t.emitOpcode(51),t.emitIndex(i),t.emitIndex(a);}};var Yo={name:"solve-function",prefixParselets:{FUNC:new Lr}};var pe=class{constructor(e=0){this.category="Date/Time";this.dayOffset=e;}parse(e,o,t){t.emitOpcode(90),this.dayOffset!==0&&(t.emitOpcode(10),t.emitNumber(this.dayOffset),t.emitOpcode(13),t.emitString("days"),t.emitOpcode(80),t.emitOpcode(20));}};var Xu={SUNDAY:0,MONDAY:1,TUESDAY:2,WEDNESDAY:3,THURSDAY:4,FRIDAY:5,SATURDAY:6},qe=class{constructor(e){this.direction=e;this.category="Date/Time";}parse(e,o,t){let n=e.peek(),i=n?Xu[n.type]:void 0;if(i===void 0)throw chunkNAZ6PGLS_cjs.c.parsing("MISSING_WEEKDAY",`"${o.value}" must be followed by a day of the week (e.g. "${o.value} Saturday")`,{keyword:o.value,actualType:n?.type,actualValue:n?.value});e.consume(),t.emitOpcode(90),t.emitOpcode(10),t.emitNumber(i),t.emitOpcode(this.direction==="next"?93:94);}};var Ze=class{constructor(e){this.direction=e;this.category="Date/Time";}parse(e,o,t){let n=o.value;this.direction==="until"?(e.parseExpression(0,t),t.emitOpcode(90)):(t.emitOpcode(90),e.parseExpression(0,t)),t.emitOpcode(21),t.emitOpcode(13),t.emitString(n),t.emitOpcode(84);}};var vr=class{constructor(){this.category="Date/Time";}parse(e,o,t){e.parseExpression(0,t),t.emitPluginCall("workdaysInDuration",1);}};var Je=class{constructor(e){this.direction=e;this.category="Date/Time";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,t,n){e.parseExpression(chunkFVQWN5HZ_cjs.a.Sum,n),n.emitOpcode(96),n.emitByte(this.direction==="backward"?1:0);}};var wr=class{constructor(){this.category="Date/Time";}parse(e,o,t){e.parseExpression(chunkFVQWN5HZ_cjs.a.Product,t),e.consume("AND_CONJ"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,t),t.emitOpcode(97);}};var J=class{constructor(e,o){this.functionName=e;this.mode=o;this.category="Date/Time";}parse(e,o,t){this.mode==="in"?(t.emitOpcode(90),e.parseExpression(0,t),t.emitOpcode(20)):e.peek()?e.parseExpression(0,t):t.emitOpcode(90),t.emitPluginCall(this.functionName,1);}};var kr=class{constructor(){this.category="Date/Time";}parse(e,o,t){let n=o.value;e.parseExpression(chunkFVQWN5HZ_cjs.a.Product,t),e.consume("AND_CONJ"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,t),t.emitPluginCall("spanBetweenDates",2),t.emitOpcode(13),t.emitString(n),t.emitOpcode(84);}};var er=class{constructor(e){this.functionName=e;this.category="Date/Time";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,t,n){n.emitPluginCall(this.functionName,1);}};var Mr=class{constructor(){this.category="Date/Time";}parse(e,o,t){t.emitOpcode(90),t.emitPluginCall("toTimestampFromAny",1);}};var Br=class{constructor(){this.category="Date/Time";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,t,n){n.emitPluginCall("toDateFromAny",1);}};var Ur=class{constructor(){this.category="Date/Time";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,t,n){n.emitPluginCall("toTimestampFromAny",1);}};var Dr=class{constructor(){this.category="Date/Time";}parse(e,o,t){t.emitOpcode(95),t.emitNumber(Number(o.value));}};var br=class{constructor(){this.category="Date/Time";}parse(e,o,t){e.consume("OF"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Postfix,t),t.emitOpcode(13),t.emitString(o.value),t.emitPluginCall("nthWeekdayOfMonth",2);}};var Ie=class{constructor(e){this.offsetMonths=e;this.category="Date/Time";}parse(e,o,t){t.emitOpcode(90),t.emitOpcode(10),t.emitNumber(this.offsetMonths),t.emitPluginCall("monthAnchorShift",2);}};var Qu=new Set(["year","years","month","months","day","days"]),Vr=class{constructor(){this.category="Date/Time";}parse(e,o,t){e.parseExpression(chunkFVQWN5HZ_cjs.a.Postfix,t),this.wordIs(e.peek(),"on")?(e.consume(),e.parseExpression(chunkFVQWN5HZ_cjs.a.Postfix,t)):t.emitOpcode(90);let n=this.consumeBreakdown(e)?"ymd":"years";t.emitOpcode(13),t.emitString(n),t.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 t=e.peek();if(!t)break;let n=String(t.value??t.text??"").toLowerCase();if(t.type==="UNIT"&&Qu.has(n))o=true,e.consume();else if(t.type==="COMMA"||t.type==="AND_CONJ"||n==="and")e.consume();else break}return o}};function qu(r){let e=r[0],o;if(e.type===6&&e.unit){if(chunkBKSKZA4W_cjs.c(e.unit)!=="time")return chunk6U66HQKQ_cjs.P("WORKDAYS_IN_EXPECTED_DURATION",`"workdays in" expects a time duration, got unit "${e.unit}"`);o=chunkBKSKZA4W_cjs.e(e.toNumber(),e.unit,"day");}else o=e.toNumber();let t=o<0?-1:1,n=Math.abs(o),i=Math.floor(n/7),a=n-i*7,s=t*(i*5+Math.min(a,5));return chunk6U66HQKQ_cjs.n(s)}var Zu=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function rr(r,e){return r.type===4?r.toNumber():chunk6U66HQKQ_cjs.P("DATE_FIELD_EXPECTED_DATE",`"${e}" expects a date, got ${chunk6U66HQKQ_cjs.g[r.type]??"an unsupported value"}`)}function Ju(r){let e=rr(r[0],"weekday");return typeof e!="number"?e:chunk6U66HQKQ_cjs.t(Zu[new Date(e).getDay()])}var ec=["January","February","March","April","May","June","July","August","September","October","November","December"];function rc(r){let e=rr(r[0],"month");return typeof e!="number"?e:chunk6U66HQKQ_cjs.t(ec[new Date(e).getMonth()])}function tc(r){let e=rr(r[0],"week");if(typeof e!="number")return e;let o=new Date(e),t=new Date(Date.UTC(o.getFullYear(),o.getMonth(),o.getDate())),n=t.getUTCDay()===0?7:t.getUTCDay();t.setUTCDate(t.getUTCDate()+4-n);let i=Date.UTC(t.getUTCFullYear(),0,1),a=Math.floor((t.getTime()-i)/864e5);return chunk6U66HQKQ_cjs.n(Math.floor(a/7)+1)}function Pa(r){let e=new Date(r).getDay();return e===0||e===6}function oc(r){let e=rr(r[0],"is a weekend");return typeof e!="number"?e:chunk6U66HQKQ_cjs.L(Pa(e))}function nc(r){let e=rr(r[0],"is a workday");return typeof e!="number"?e:chunk6U66HQKQ_cjs.L(!Pa(e))}function ic(r){return chunk6U66HQKQ_cjs.u(Math.abs(r[0].toNumber()-r[1].toNumber()),"ms")}function ac(r){let e=r[0];if(e.type===4)return e;if(e.type===3){let o=chunkHDGARCI2_cjs.c(e.value);return o===null?chunk6U66HQKQ_cjs.P("INVALID_ISO8601_STRING",`"${e.value}" is not a recognizable ISO8601 date/time string`):chunk6U66HQKQ_cjs.M(o)}return chunk6U66HQKQ_cjs.M(chunkHDGARCI2_cjs.e(e.toNumber()))}function sc(r){let e=r[0];if(e.type===3){let o=chunkHDGARCI2_cjs.c(e.value);return o===null?chunk6U66HQKQ_cjs.P("INVALID_ISO8601_STRING",`"${e.value}" is not a recognizable ISO8601 date/time string`):chunk6U66HQKQ_cjs.n(Math.floor(o/1e3))}return chunk6U66HQKQ_cjs.n(Math.floor(e.toNumber()/1e3))}var _a=qu,jo=Ju,Xo=rc,Qo=tc,Aa=oc,xa=nc,Ra=ic,Oa=ac,Ca=sc;function qo(r,e){return new Date(r,e+1,0).getDate()}function Sa(r,e,o,t){let n=new Date(r,e,1).getDay(),a=1+(o-n+7)%7+(t-1)*7;return a<1||a>qo(r,e)?null:new Date(r,e,a).getTime()}function La(r,e,o){let t=qo(r,e),i=(new Date(r,e,t).getDay()-o+7)%7;return new Date(r,e,t-i).getTime()}function va(r,e){let o=new Date(r),t=new Date(e),n=t.getFullYear()-o.getFullYear();return (t.getMonth()<o.getMonth()||t.getMonth()===o.getMonth()&&t.getDate()<o.getDate())&&n--,n}function Ia(r,e){let o=r.getFullYear(),t=r.getMonth()+e,n=o+Math.floor(t/12),i=(t%12+12)%12,a=Math.min(r.getDate(),qo(n,i));return new Date(n,i,a)}function ha(r){return Math.floor(Date.UTC(r.getFullYear(),r.getMonth(),r.getDate())/864e5)}function wa(r,e){let o=new Date(r),t=new Date(e),n=(t.getFullYear()-o.getFullYear())*12+(t.getMonth()-o.getMonth());Ia(o,n)>t&&n--;let i=Ia(o,n),a=ha(t)-ha(i);return {years:Math.floor(n/12),months:n%12,days:a}}function ka(r,e){let o=new Date(r);return new Date(o.getFullYear(),o.getMonth()+e,1).getTime()}function Hr(r,e){return r.type===4?r.toNumber():chunk6U66HQKQ_cjs.P("DATE_EXPECTED",`"${e}" expects a date, got ${chunk6U66HQKQ_cjs.g[r.type]??"an unsupported value"}`)}function mc(r){let e=Hr(r[0],"nth weekday of month");if(typeof e!="number")return e;let o=String(r[1].value??""),[t,n]=o.split(":"),i=Number(n),a=new Date(e),s=a.getFullYear(),l=a.getMonth();if(t==="last")return chunk6U66HQKQ_cjs.M(La(s,l,i));let u=Number(t),c=Sa(s,l,i,u);return c===null?chunk6U66HQKQ_cjs.P("NTH_WEEKDAY_OUT_OF_RANGE",`there is no ${t}${lc(u)} occurrence of that weekday in the month`):chunk6U66HQKQ_cjs.M(c)}function lc(r){let e=r%100;if(e>=11&&e<=13)return "th";switch(r%10){case 1:return "st";case 2:return "nd";case 3:return "rd";default:return "th"}}function uc(r){let e=Hr(r[0],"month anchor");if(typeof e!="number")return e;let o=r[1].toNumber();return chunk6U66HQKQ_cjs.M(ka(e,o))}var cc="ymd";function pc(r){let e=Hr(r[0],"age of");if(typeof e!="number")return e;let o=Hr(r[1],"age of");return typeof o!="number"?o:String(r[2].value??"years")===cc?chunk6U66HQKQ_cjs.t(fc(wa(e,o))):chunk6U66HQKQ_cjs.u(va(e,o),"years")}function fc(r){let e=[];return r.years!==0&&e.push(Fr(r.years,"year")),r.months!==0&&e.push(Fr(r.months,"month")),r.days!==0&&e.push(Fr(r.days,"day")),e.length===0?Fr(0,"day"):e.join(", ")}function Fr(r,e){return `${r} ${e}${Math.abs(r)===1?"":"s"}`}var Ma=mc,Ba=uc,Ua=pc;var dc={SUNDAY:0,MONDAY:1,TUESDAY:2,WEDNESDAY:3,THURSDAY:4,FRIDAY:5,SATURDAY:6},Da="NTH_WEEKDAY",Ec=chunk5IJD5L3O_cjs.c(Da),Tc=/^(\d+)(st|nd|rd|th)$/i;function ba(r=66){let e="datetime:nth-weekday";return {name:e,priority:r,match(o,t){let n=o[t];if(!n)return null;let i=null,a=0;if(n.type==="LAST")i="last",a=1;else {let f=o[t+1];if(!f||(n.sourceEnd??n.offset+(n.text?.length??0))!==f.offset)return null;let N=(n.text??"")+(f.text??""),E=Tc.exec(N);if(!E)return null;i=String(Number(E[1])),a=2;}let s=o[t+a],l=s?dc[s.type]:void 0;if(l===void 0||o[t+a+1]?.type!=="OF")return null;let u=`${i}:${l}`,c=new chunkFAGFPVYK_cjs.a(Da,Ec,u,u,n.offset,0,n.line,n.col);return {consumed:a+1,replacement:[c],ruleName:e}}}}function Va(r=60){return {name:"datetime:until-since",priority:r,match(e,o){if(o+1>=e.length)return null;let t=e[o],n=e[o+1];if(t.type!=="UNIT"||n.type!=="UNTIL"&&n.type!=="SINCE")return null;let i=n.type==="UNTIL"?"UNTIL_UNIT":"SINCE_UNIT";return {consumed:2,replacement:[chunkRC4M6HBX_cjs.b(i,t.value,[t,n])],ruleName:`datetime:${n.type.toLowerCase()}`}}}}function Fa(r=60){return {name:"datetime:between-unit",priority:r,match(e,o){let t=o,n=0;e[o]?.value?.toLowerCase()==="how"&&e[o+1]?.value?.toLowerCase()==="many"&&(t=o+2,n=2);let i=e[t],a=e[t+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,t+2);return l?{consumed:n+2,replacement:[i,a],ruleName:"datetime:how-many"}:{consumed:n+2,replacement:[chunkRC4M6HBX_cjs.b("BETWEEN_UNIT",i.value,u)],ruleName:"datetime:between"}}}}function Ha(r=70){return {name:"datetime:workday-rate-denominator",priority:r,match(e,o){let t=e[o];if(t.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:[t,i,n],ruleName:"datetime:workday-rate-denominator"}}}}var Nc={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 za(r){return r===void 0||r.type!=="IDENT"&&r.type!=="UNIT"?0:Nc[(r.text??r.value??"").toLowerCase()]??0}var tr=/^\d+$/;function zr(r){return r.length===4}function Ga(r=64){return {name:"datetime:month-name-date",priority:r,match(e,o){let t="datetime:month-name-date",n=e[o];if(n?.type==="NUMBER"&&tr.test(n.text??"")){let c=za(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"&&tr.test(T.text??"")&&zr(T.text??"")?chunkHDGARCI2_cjs.g(f,c,Number(T.text),e.slice(o,o+3),t):chunkHDGARCI2_cjs.g(f,c,new Date().getFullYear(),e.slice(o,o+2),t)}let i=za(n);if(i===0)return null;let a=e[o+1];if(a?.type!=="NUMBER"||!tr.test(a.text??""))return null;if(zr(a.text??""))return chunkHDGARCI2_cjs.g(1,i,Number(a.text),e.slice(o,o+2),t);let s=Number(a.text),l=e[o+2],u=e[o+3];return l?.type==="COMMA"&&u?.type==="NUMBER"&&tr.test(u.text??"")&&zr(u.text??"")?chunkHDGARCI2_cjs.g(s,i,Number(u.text),e.slice(o,o+4),t):l?.type==="NUMBER"&&tr.test(l.text??"")&&zr(l.text??"")?chunkHDGARCI2_cjs.g(s,i,Number(l.text),e.slice(o,o+3),t):chunkHDGARCI2_cjs.g(s,i,new Date().getFullYear(),e.slice(o,o+2),t)}}}var yc=93,gc={q1:[1,3],q2:[4,6],q3:[7,9],q4:[10,12]};function Zo(r,e){return new Date(r,e,0).getDate()}function Pc(r){return Zo(r,2)===29?366:365}var Gr=class{constructor(){this.category="Datetime";}parse(e,o,t){let n=this.readPeriodDays(e);t.emitOpcode(10),t.emitNumber(n),t.emitOpcode(51),t.emitIndex(yc),t.emitIndex(1);}readPeriodDays(e){let o=e.peek(),t=(o?.text??o?.value??"").toLowerCase(),n=gc[t];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+=Zo(a,l);return s}if(o?.type==="DATETIME_LITERAL"){e.consume();let a=new Date(Number(o.value));return Zo(a.getFullYear(),a.getMonth()+1)}let i=this.readOptionalYear(e);if(i!==null)return Pc(i);throw chunkNAZ6PGLS_cjs.c.parsing("DAYS_IN_EXPECTED_PERIOD",'Expected a month, quarter or year, as in "days in February 2020" or "days in Q3"')}readOptionalYear(e){let o=e.peek();if(o?.type!=="NUMBER")return null;let t=o.text??o.value??"";return /^\d{4}$/.test(t)?(e.consume(),Number(t)):null}};var _c=new Set(["q1","q2","q3","q4"]),Ac=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 xc(r){if(r===void 0)return false;if(r.type==="DATETIME_LITERAL")return true;let e=(r.text??r.value??"").toLowerCase();return r.type==="IDENT"||r.type==="UNIT"?_c.has(e)||Ac.has(e):r.type==="NUMBER"&&/^\d{4}$/.test(r.text??"")}function Ka(r=60){return {name:"datetime:days-in-period",priority:r,match(e,o){let t=e[o];return t===void 0||(t.text??t.value??"").toLowerCase()!=="days"||t.type!=="UNIT"&&t.type!=="IDENT"||e[o+1]?.type!=="IN"||!xc(e[o+2])?null:{consumed:2,replacement:[chunkRC4M6HBX_cjs.b("DAYS_IN_PERIOD","days in",[t,e[o+1]])],ruleName:"datetime:days-in-period"}}}}function $a(){return {name:"datetime:daily-note-link",priority:80,match(r,e){return r[e]?.type!=="LBRACKET"||r[e+1]?.type!=="LBRACKET"||r[e+2]?.type!==chunkHDGARCI2_cjs.f||r[e+3]?.type!=="RBRACKET"||r[e+4]?.type!=="RBRACKET"?null:{consumed:5,replacement:[r[e+2]],ruleName:"datetime:daily-note-link"}}}}var Jo={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 Gr,NOW:new pe(0),TODAY:new pe(0),TOMORROW:new pe(1),YESTERDAY:new pe(-1),NEXT:new qe("next"),LAST:new qe("last"),UNTIL_UNIT:new Ze("until"),SINCE_UNIT:new Ze("since"),WORKDAYS_IN:new vr,WORKDAYS_BETWEEN:new wr,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 kr,CURRENT_TIMESTAMP:new Mr,DATETIME_LITERAL:new Dr,NTH_WEEKDAY:new br,AGE_OF:new Vr,MONTH_ANCHOR_NEXT:new Ie(1),MONTH_ANCHOR_THIS:new Ie(0),MONTH_ANCHOR_LAST:new Ie(-1)},infixParselets:{WORKDAYS_AFTER:new Je("forward"),WORKDAYS_BEFORE:new Je("backward"),TO_DATE:new Br,TO_TIMESTAMP:new Ur,IS_WEEKEND:new er("isWeekendOnDate"),IS_WORKDAY:new er("isWorkdayOnDate")},normalizerRules:[Va(),Fa(),Ha(),Ga(),ba(),Ka(),$a()],pluginFunctions:{workdaysInDuration:_a,weekdayOnDate:jo,toDateFromAny:Oa,toTimestampFromAny:Ca,monthOnDate:Xo,weekOnDate:Qo,isWeekendOnDate:Aa,isWorkdayOnDate:xa,spanBetweenDates:Ra,nthWeekdayOfMonth:Ma,monthAnchorShift:Ba,ageBetween:Ua},asConverters:{iso8601:r=>chunk6U66HQKQ_cjs.t(chunkHDGARCI2_cjs.d(r.toNumber())),weekday:r=>jo([r]),month:r=>Xo([r]),week:r=>Qo([r])},tokenCategories:{NTH_WEEKDAY:"datetime",MONTH_ANCHOR_NEXT:"datetime",MONTH_ANCHOR_THIS:"datetime",MONTH_ANCHOR_LAST:"datetime",AGE_OF:"keyword"}};var Rc={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"},en={"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"},Oc={pst:"America/Los_Angeles",pdt:"America/Los_Angeles",est:"America/New_York",edt:"America/New_York",cst:"America/Chicago",cdt:"America/Chicago",mst:"America/Denver",mdt:"America/Denver",hst:"Pacific/Honolulu",bst:"Europe/London",cet:"Europe/Paris",cest:"Europe/Paris",jst:"Asia/Tokyo",ist:"Asia/Kolkata",aest:"Australia/Sydney",aedt:"Australia/Sydney"},Wa={...Rc,...en,...Oc};var rn="UTCOFFSET:";function tn(r){return `${rn}${r}`}function or(r){return r.startsWith(rn)}function nr(r){return parseInt(r.slice(rn.length),10)}function Kr(r,e){if(or(r))return nr(r);let o=new Intl.DateTimeFormat("en-US",{timeZone:r,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),t={};for(let i of o.formatToParts(new Date(e)))t[i.type]=i.value;let n=Date.UTC(+t.year,+t.month-1,+t.day,+t.hour,+t.minute,+t.second);return Math.round((n-e)/6e4)}function ja(r,e,o,t,n,i){let a=Date.UTC(r,e,o,t,n,0),s=Kr(i,a);return a-s*6e4}function on(r,e){if(or(e)){let t=nr(e)*6e4;return Cc(new Date(r+t))}return new Intl.DateTimeFormat("en-US",{timeZone:e,hour:"numeric",minute:"2-digit",hour12:true}).format(new Date(r))}function Xa(r,e){if(or(e)){let t=nr(e)*6e4;return Ic(new Date(r+t))}return new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"long",day:"numeric"}).format(new Date(r))}function Ya(r,e){if(or(e)){let n=new Date(r+nr(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"}),t={};for(let n of o.formatToParts(new Date(r)))t[n.type]=n.value;return {year:+t.year,month0:+t.month-1,day:+t.day}}function Qa(r,e,o){let t=Ya(r,e),n=Ya(r,o),i=Date.UTC(t.year,t.month0,t.day),a=Date.UTC(n.year,n.month0,n.day);return Math.round((i-a)/864e5)}function Cc(r){return new Intl.DateTimeFormat("en-US",{timeZone:"UTC",hour:"numeric",minute:"2-digit",hour12:true}).format(r)}function Ic(r){return new Intl.DateTimeFormat("en-US",{timeZone:"UTC",year:"numeric",month:"long",day:"numeric"}).format(r)}function nn(r){if(or(r)){let o=nr(r),t=o>=0?"+":"-",n=Math.abs(o),i=Math.floor(n/60),a=n%60;return a===0?`UTC${t}${i}`:`UTC${t}${i}:${String(a).padStart(2,"0")}`}return (r.split("/").pop()??r).replace(/_/g," ")}function ne(r){let e=r.peek();if(!e)return null;let o=e.value,t=o.toLowerCase();if(t==="gmt"||t==="utc"){r.consume();let i=r.peek();if(i?.type==="PLUS"||i?.type==="MINUS"){let s=i.type==="MINUS";r.consume();let l=r.peek(),u;if(l?.type==="CLOCK_TIME")r.consume(),u=parseInt(l.value,10);else {let f=r.consume("NUMBER");if(u=parseInt(f.value,10)*60,r.peek()?.type==="COLON"){r.consume();let T=r.consume("NUMBER");u+=parseInt(T.value,10);}}let c=tn(s?-u:u);return {zoneRef:c,displayName:nn(c)}}let a=tn(0);return {zoneRef:a,displayName:nn(a)}}let n=Wa[t];if(n){r.consume();let i=o.replace(/\b\w/g,a=>a.toUpperCase());return {zoneRef:n,displayName:i}}return null}var $r="zoneConvert",an="timeInZone",sn="dateInZone",Wr="timeDifference";function qa(r){let e=r[0].toNumber(),o=r[1].value,t=r[2].value,n=new Date,i=ja(n.getFullYear(),n.getMonth(),n.getDate(),Math.floor(e/60),e%60,o),a=on(i,t),s=Qa(i,t,o);if(s===0)return chunk6U66HQKQ_cjs.t(a);let l=s>0?"+":"";return chunk6U66HQKQ_cjs.t(`${a} (${l}${s} day${Math.abs(s)===1?"":"s"})`)}function Za(r){let e=r[0].value;return chunk6U66HQKQ_cjs.t(on(Date.now(),e))}function Ja(r){let e=r[0].value;return chunk6U66HQKQ_cjs.t(Xa(Date.now(),e))}function es(r){let e=r[0].value,o=r[1].value,t=r[2].value,n=r[3].value,i=Date.now(),a=Kr(e,i),l=Kr(o,i)-a;if(l===0)return chunk6U66HQKQ_cjs.t(`${n} and ${t} currently share the same UTC offset`);let u=l>0?n:t,c=l>0?t:n,f=Math.abs(l),T=Math.floor(f/60),N=f%60,E=[];return T>0&&E.push(`${T} hour${T===1?"":"s"}`),N>0&&E.push(`${N} minute${N===1?"":"s"}`),chunk6U66HQKQ_cjs.t(`${u} is ${E.join(" ")} ahead of ${c}`)}var Yr=class{constructor(){this.category="Time";}parse(e,o,t){let n=parseInt(o.value,10),i=ne(e);if(i!==null){if(e.peek()?.type!=="IN")throw chunkNAZ6PGLS_cjs.c.parsing("TIME_ZONE_EXPECTED_IN",`Expected "in <city>" after the zone name (e.g. "6pm Sydney in Chicago") but got ${e.peek()?`"${e.peek().value}"`:"end of input"}`);e.consume();let a=ne(e);if(a===null)throw chunkNAZ6PGLS_cjs.c.parsing("TIME_ZONE_EXPECTED_TARGET",'Expected a city or zone name after "in" (e.g. "6pm Sydney in Chicago")');t.emitOpcode(10),t.emitNumber(n),t.emitOpcode(13),t.emitString(i.zoneRef),t.emitOpcode(13),t.emitString(a.zoneRef),t.emitPluginCall($r,3);return}t.emitOpcode(10),t.emitNumber(n),t.emitOpcode(120);}};var jr=class{constructor(){this.category="Time";}parse(e,o,t){let[n,i]=o.value.split(":"),a=parseInt(n,10),s=parseInt(i,10),l=s>=a?s-a:1440-a+s;t.emitOpcode(10),t.emitNumber(l),t.emitOpcode(13),t.emitString("minutes"),t.emitOpcode(80);}};var Xr=class{constructor(){this.category="Time";}parse(e,o,t){t.emitOpcode(10),t.emitNumber(parseFloat(o.value)),t.emitOpcode(13),t.emitString("frames/s"),t.emitOpcode(80);}};var Qr=class{constructor(){this.category="Time";}parse(e,o,t){t.emitOpcode(10),t.emitNumber(parseFloat(o.value)),t.emitOpcode(13),t.emitString("s"),t.emitOpcode(80);}};function mn(r){return {category:"Time",parse(e,o,t){let n=ne(e);if(n===null)throw chunkNAZ6PGLS_cjs.c.parsing("TIME_ZONE_EXPECTED_CITY",`Expected a city or zone name after "${o.value}" (e.g. "time in Paris")`);t.emitOpcode(13),t.emitString(n.zoneRef),t.emitPluginCall(r,1);}}}var qr=class{constructor(){this.category="Time";}parse(e,o,t){let n=ne(e);if(n===null)throw chunkNAZ6PGLS_cjs.c.parsing("TIME_DIFFERENCE_EXPECTED_CITY",'Expected a city or zone name after "time difference between" (e.g. "time difference between Seattle and Moscow")');e.consume("AND_CONJ");let i=ne(e);if(i===null)throw chunkNAZ6PGLS_cjs.c.parsing("TIME_DIFFERENCE_EXPECTED_SECOND_CITY",'Expected a second city or zone name after "and" (e.g. "time difference between Seattle and Moscow")');t.emitOpcode(13),t.emitString(n.zoneRef),t.emitOpcode(13),t.emitString(i.zoneRef),t.emitOpcode(13),t.emitString(n.displayName),t.emitOpcode(13),t.emitString(i.displayName),t.emitPluginCall(Wr,4);}};var Zr=class{constructor(){this.category="Time";}parse(e,o,t){let[n,i,a,s]=o.value.split(",").map(Number),l=e.peek();if(!l||l.type!=="RATE_AT"&&l.type!=="AT")throw chunkNAZ6PGLS_cjs.c.parsing("TIMECODE_EXPECTED_FPS",`A video timecode must specify a frame rate, e.g. "${o.value.split(",").join(":")} at 30 fps" or "... @ 30 fps"`);e.consume();let u=e.peek();if(!u||u.type!=="FPS_RATE")throw chunkNAZ6PGLS_cjs.c.parsing("TIMECODE_EXPECTED_FPS",`Expected "<number> fps" after "${l.value}" (e.g. "at 30 fps")`);e.consume();let c=parseFloat(u.value),f=Math.round(c);if(s>=f)throw chunkNAZ6PGLS_cjs.c.parsing("TIMECODE_FRAME_OUT_OF_RANGE",`Frame number ${s} is out of range for ${c} fps (must be 0-${f-1})`);let T=(n*3600+i*60+a)*f+s,N=chunk6U66HQKQ_cjs.z(c);if(e.peek()?.type==="IN"){e.consume();let E=e.peek();if(!E||E.type!=="IDENT"||E.value.toLowerCase()!=="frames")throw chunkNAZ6PGLS_cjs.c.parsing("TIMECODE_EXPECTED_FRAMES",`Expected "frames" after "in" (e.g. "... in frames") but got ${E?`"${E.value}"`:"end of input"}`);e.consume(),N="frames";}t.emitOpcode(10),t.emitNumber(T),t.emitOpcode(13),t.emitString(N),t.emitOpcode(80);}};function rs(r,e){let o=Math.max(1,Math.round(e)),t=c=>String(c).padStart(2,"0"),n=Math.trunc(r),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 `${t(s)}:${t(l)}:${t(u)}:${t(i)}`}var Jr=class{constructor(){this.category="Time";}parse(e,o,t){let n=parseFloat(o.value),i=e.peek();if(i&&(i.type==="RATE_AT"||i.type==="AT")){e.consume();let a=e.peek();if(!a||a.type!=="FPS_RATE")throw chunkNAZ6PGLS_cjs.c.parsing("TIMECODE_EXPECTED_FPS",`Expected "<number> fps" after "${i.value}" (e.g. "@ 30 fps")`);e.consume();let s=parseFloat(a.value);t.emitOpcode(13),t.emitString(rs(n,s));return}t.emitOpcode(10),t.emitNumber(n),t.emitOpcode(13),t.emitString("frames"),t.emitOpcode(80);}};function ts(r,e,o){if(e<0||e>59)return null;if(o){if(r<1||r>12)return null;let t=o.toLowerCase()==="pm";return (r%12+(t?12:0))*60+e}return r<0||r>23?null:r*60+e}function os(r){return !!r&&r.type==="IDENT"&&/^(am|pm)$/i.test(r.value)}function ns(r=65){return {name:"time:clock-time",priority:r,match(e,o){if(chunkRC4M6HBX_cjs.e(e,o))return null;let t=e[o];if(t.type!=="NUMBER")return null;let n=parseInt(t.value,10);if(isNaN(n)||n<0||n>23)return null;let i=e[o+1],a=e[o+2];if(i?.type==="COLON"&&a?.type==="NUMBER"){let l=parseInt(a.value,10),u=e[o+3],c=os(u),f=ts(n,l,c?u.value:void 0);if(f===null)return null;let T=c?4:3;return {consumed:T,replacement:[chunkRC4M6HBX_cjs.b("CLOCK_TIME",String(f),e.slice(o,o+T))],ruleName:"time:clock-time"}}let s=e[o+1];if(os(s)){let l=ts(n,0,s.value);return l===null?null:{consumed:2,replacement:[chunkRC4M6HBX_cjs.b("CLOCK_TIME",String(l),e.slice(o,o+2))],ruleName:"time:clock-time"}}return null}}}function is(r=66){return {name:"time:clock-time-interval",priority:r,match(e,o){let t=e[o],n=e[o+1],i=e[o+2];return t.type!=="CLOCK_TIME"||n?.type!=="TO"||i?.type!=="CLOCK_TIME"?null:{consumed:3,replacement:[chunkRC4M6HBX_cjs.b("CLOCK_TIME_INTERVAL",`${t.value}:${i.value}`,e.slice(o,o+3))],ruleName:"time:clock-time-interval"}}}}function as(r=65){return {name:"time:fps-rate",priority:r,match(e,o){let t=e[o],n=e[o+1];return t.type!=="NUMBER"||n?.type!=="IDENT"||n.value.toLowerCase()!=="fps"?null:{consumed:2,replacement:[chunkRC4M6HBX_cjs.b("FPS_RATE",t.value,e.slice(o,o+2))],ruleName:"time:fps-rate"}}}}function ss(r=70){return {name:"time:laptime",priority:r,match(e,o){if(chunkRC4M6HBX_cjs.e(e,o))return null;let t=e[o],n=e[o+1],i=e[o+2],a=e[o+3],s=e[o+4];if(t.type!=="NUMBER"||n?.type!=="COLON"||i?.type!=="NUMBER"||a?.type!=="COLON"||s?.type!=="NUMBER")return null;let l=parseInt(t.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:[chunkRC4M6HBX_cjs.b("LAPTIME",String(f),e.slice(o,o+5))],ruleName:"time:laptime"}}}}function ms(r=75){return {name:"time:video-timecode",priority:r,match(e,o){if(chunkRC4M6HBX_cjs.e(e,o))return null;let t=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(t?.type!=="NUMBER"||n?.type!=="COLON"||i?.type!=="NUMBER"||a?.type!=="COLON"||s?.type!=="NUMBER"||l?.type!=="COLON"||u?.type!=="NUMBER")return null;let c=parseInt(t.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:[chunkRC4M6HBX_cjs.b("VIDEO_TIMECODE",`${c},${f},${T},${N}`,e.slice(o,o+7))],ruleName:"time:video-timecode"}}}}function ls(r=65){return {name:"time:frame-count",priority:r,match(e,o){let t=e[o],n=e[o+1];return t.type!=="NUMBER"||n?.type!=="IDENT"||n.value.toLowerCase()!=="frames"?null:{consumed:2,replacement:[chunkRC4M6HBX_cjs.b("FRAME_COUNT",t.value,e.slice(o,o+2))],ruleName:"time:frame-count"}}}}var hc=14,Sc=[["week","weeks",604800],["day","days",86400],["hour","hours",3600],["minute","minutes",60],["second","seconds",1]];function us(r){if(r.type===0)return r.toNumber();if(r.type!==6||r.unit===void 0)return null;let e=chunk6QRHN3I6_cjs.a[r.unit.toLowerCase()];return e===void 0||e[0]!==hc?null:r.toNumber()*e[1]}function cs(r){let e=us(r);if(e===null)return chunk6U66HQKQ_cjs.t(`"as timespan" needs a duration, got ${r.unit??"a non-duration"}`);let o=e<0,t=Math.abs(e),n=[];for(let[a,s,l]of Sc){if(l===1)break;let u=Math.floor(t/l);u>0&&(n.push(`${u} ${u===1?a:s}`),t-=u*l);}let i=Math.round(t*1e3)/1e3;return (i>0||n.length===0)&&n.push(`${i} ${i===1?"second":"seconds"}`),chunk6U66HQKQ_cjs.t((o?"-":"")+n.join(" "))}function un(r){let e=us(r);if(e===null)return chunk6U66HQKQ_cjs.t(`"as laptime" needs a duration, got ${r.unit??"a non-duration"}`);let o=e<0,t=Math.round(Math.abs(e)*1e3)/1e3,n=Math.floor(t/3600),i=Math.floor(t%3600/60),a=t%60,s=Math.floor(a),l=Math.round((a-s)*1e3),u=`${ln(n)}:${ln(i)}:${ln(s)}`;return chunk6U66HQKQ_cjs.t((o?"-":"")+(l>0?`${u}.${String(l).padStart(3,"0")}`:u))}function ln(r){return r<10?`0${r}`:String(r)}var cn={name:"solve-time",asConverters:{timespan:cs,laptime:un,lap:un},phrases:{"time in":"TIME_IN","date in":"DATE_IN","time difference between":"TIME_DIFFERENCE_BETWEEN",...Object.fromEntries(Object.keys(en).map(r=>[r,"CITY_NAME"]))},prefixParselets:{CLOCK_TIME:new Yr,CLOCK_TIME_INTERVAL:new jr,FPS_RATE:new Xr,LAPTIME:new Qr,TIME_IN:mn(an),DATE_IN:mn(sn),TIME_DIFFERENCE_BETWEEN:new qr,VIDEO_TIMECODE:new Zr,FRAME_COUNT:new Jr},normalizerRules:[ns(),is(),as(),ss(),ms(),ls()],pluginFunctions:{[$r]:qa,[an]:Za,[sn]:Ja,[Wr]:es}};function et(r){for(let e of r.alternatives){let o=e.slots[0];if(!o||o.kind!=="keyword")throw chunkNAZ6PGLS_cjs.c.config("INVALID_PHRASE_PATTERN","Every PhraseAlternative's first slot must be a `keyword` slot \u2014 alternatives are chosen by peeking the next token, which only works if the choice is decidable from one leading keyword.",{category:r.category})}return {category:r.category,parse(e,o,t){let n=e.peek(),i=r.alternatives.find(s=>{let l=s.slots[0];return n!==void 0&&l.tokenTypes.includes(n.type)});if(!i){let s=r.alternatives.map(l=>l.slots[0].tokenTypes.join("|")).join(", ");throw chunkNAZ6PGLS_cjs.c.parsing("NO_MATCHING_PHRASE_ALTERNATIVE",`Expected one of [${s}] but got "${n?.type??"end of input"}" ("${n?.value??""}")`,{category:r.category,expected:s,actualType:n?.type,actualValue:n?.value})}let a=[];for(let s of i.slots)if(s.kind==="keyword"){let l=e.peek();if(!l||!s.tokenTypes.includes(l.type))throw chunkNAZ6PGLS_cjs.c.parsing("PHRASE_KEYWORD_MISMATCH",`Expected one of [${s.tokenTypes.join("|")}] but got "${l?.type??"end of input"}" ("${l?.value??""}")`,{category:r.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,t);i.emit(t,a);}}}var Lc=37;function rt(r){r.emitOpcode(51),r.emitIndex(Lc),r.emitIndex(2);}var vc=et({category:"Dice",alternatives:[{slots:[{kind:"keyword",tokenTypes:["BETWEEN"]},{kind:"expr",bindingPower:chunkFVQWN5HZ_cjs.a.Product},{kind:"keyword",tokenTypes:["AND_CONJ"]},{kind:"expr"}],emit:rt},{slots:[{kind:"keyword",tokenTypes:["FROM"]},{kind:"expr",bindingPower:chunkFVQWN5HZ_cjs.a.Product},{kind:"keyword",tokenTypes:["TO"]},{kind:"expr"}],emit:rt},{slots:[{kind:"keyword",tokenTypes:["LPAREN"]},{kind:"expr"},{kind:"keyword",tokenTypes:["COMMA"]},{kind:"expr"},{kind:"keyword",tokenTypes:["RPAREN"]}],emit:rt}]}),tt=class{constructor(){this.category="Dice";}parse(e,o,t){let n=e.peek();if(n&&n.type==="NUMBER"){let i=e.consume();t.emitOpcode(10),t.emitNumber(parseFloat(i.value)),e.consume("MINUS");let a=e.consume();t.emitOpcode(10),t.emitNumber(parseFloat(a.value)),rt(t);return}vc.parse(e,o,t);}};var pn={name:"solve-dice",prefixParselets:{ROLL:new tt}};var ot=class{constructor(){this.category="Variable";}parse(e,o,t){let n=e.consume();if(n.type!=="IDENT"&&n.type!=="UNIT")throw chunkNAZ6PGLS_cjs.c.parsing("EXPECTED_IDENTIFIER",`Expected identifier or unit after colon, got ${n.type}`,{tokenType:n.type});let i=n.value;e.peek()?.type==="EQUALS"?(e.consume("EQUALS"),e.parseExpression(0,t),t.emitOpcode(61),t.emitString(i)):(t.emitOpcode(60),t.emitString(i));}};var ir=class{constructor(){this.category="Variable";}parse(e,o,t){t.emitOpcode(60),t.emitString(o.value);}};var nt=class{constructor(){this.category="Variable";}parse(e,o,t){e.consume("COLON");let n=e.consume();if(n.type!=="IDENT"&&n.type!=="UNIT")throw chunkNAZ6PGLS_cjs.c.parsing("EXPECTED_IDENTIFIER",`Expected identifier after 'global :', got ${n.type}`,{tokenType:n.type});let i=n.value;e.peek()?.type==="EQUALS"?(e.consume("EQUALS"),e.parseExpression(0,t),t.emitOpcode(63),t.emitString(i)):(t.emitOpcode(62),t.emitString(i));}};var it=class{constructor(){this.namespace="global-variables";this.pending=new Map;}preflight(e,o,t,n,i){let{opcodes:a,strings:s}=o,l=a.length,u=0;for(;u<l;){if(a[u]===62){let f=s[a[u+1]];if(!chunkEEVUKZ5B_cjs.J.has(f))return this.pendingResultFor(f,t,n)}u=chunkW5ELYJ4Z_cjs.a(a,u);}return null}pendingResultFor(e,o,t){let n=this.pending.get(e);return n||(n=new Promise(i=>{let a=chunkEEVUKZ5B_cjs.J.subscribe((s,l)=>{s===e&&(a(),this.pending.delete(e),i(l));});}),this.pending.set(e,n)),{queryKey:`global:${e}`,resolver:n,packageId:o,signal:t,metadata:{varName:e}}}destroy(){this.pending.clear();}};var fn={name:"solve-variables",asyncResolvers:[new it],prefixParselets:{COLON:new ot,IDENT:new ir,UNIT:new ir,GLOBAL:new nt}};var fs="currency-historical",fe="historicalCurrency",wc=`solve-currency:${fe}`,at={NOT_CONFIGURED:"HISTORICAL_RATES_NOT_CONFIGURED",QUERY_FAILED:"HISTORICAL_RATE_QUERY_FAILED",NOT_PREFLIGHTED:"HISTORICAL_RATE_NOT_PREFLIGHTED",INVALID_OPERAND:"HISTORICAL_CURRENCY_INVALID_OPERAND"},kc=3e4,ds=1/0,Mc=1e4;function dn(r,e,o){return [fs,`${r.toUpperCase()}:${e.toUpperCase()}:${o}`]}function ps(r){return r<10?`0${r}`:String(r)}function st(r,e,o){if(!chunkGWCBPITD_cjs.c.isCurrency(e)||o!==void 0&&!chunkGWCBPITD_cjs.c.isCurrency(o))return null;let t=r.peek();if(!t||t.type!=="IDENT"||t.value.toLowerCase()!=="on")return null;let n=r.peekAt(1);if(!n||n.type!=="DATETIME_LITERAL")return null;r.consume(),r.consume();let i=new Date(Number(n.value));return `${i.getFullYear()}-${ps(i.getMonth()+1)}-${ps(i.getDate())}`}async function Es(r,e,o,t,n,i){let a=e.toUpperCase(),s=o.toUpperCase();if(!r)return chunk6U66HQKQ_cjs.P(at.NOT_CONFIGURED,`Historical exchange rates are not configured. Supply historicalRateProvider via createCurrencyPackage({ ... }) to convert ${a} to ${s} on ${t}.`);let{signal:l,cleanup:u}=chunkTLG7VZRX_cjs.a(n,Mc,"Historical currency rate fetch");try{let c=await r(a,s,t,l);return chunk6U66HQKQ_cjs.n(c)}catch(c){let f=chunk6U66HQKQ_cjs.P(at.QUERY_FAILED,`Failed to resolve the historical rate for ${a} to ${s} on ${t}: ${c instanceof Error?c.message:String(c)}`),T=dn(e,o,t);return setTimeout(()=>{i.getQueryData(T)===f&&i.removeQueries({queryKey:T,exact:true});},kc).unref?.(),f}finally{u();}}function En(r){return e=>{let o=e[0],t=e[1],n=e[2],i=chunk6U66HQKQ_cjs.Q(o);if(i)return i;if(o.type!==6||o.unit===void 0||!chunkGWCBPITD_cjs.c.isCurrency(o.unit))return chunk6U66HQKQ_cjs.P(at.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(t.value),l=String(n.value);if(a.toUpperCase()===s.toUpperCase())return chunk6U66HQKQ_cjs.u(o.toNumber(),s);let u=chunkZLRJ7TDP_cjs.b(),c=dn(a,s,l),f=u?.getQueryData(c);if(f===void 0)return u?u.fetchQuery({queryKey:c,queryFn:({signal:N})=>Es(r,a,s,l,N,u),staleTime:ds}):chunk6U66HQKQ_cjs.P(at.NOT_PREFLIGHTED,`No historical rate resolved for ${a.toUpperCase()} to ${s.toUpperCase()} on ${l}.`);if(f.type===13)return f;let T=f.value;return chunk6U66HQKQ_cjs.u(o.toNumber()*T,s)}}function Ts(r){return {namespace:fs,preflight(e,o,t,n,i){let{opcodes:a,strings:s}=o,l=a.length,u=chunkEEVUKZ5B_cjs.F(wc),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]],R=s[f[f.length-2]],O=new Set;for(let g=0;g<f.length-2;g++){let P=s[f[g]];chunkGWCBPITD_cjs.c.isCurrency(P)&&O.add(P.toUpperCase());}if(O.size===1){let g=O.values().next().value;if(g!==R.toUpperCase()){let P=dn(g,R,_);if(i.getQueryData(P)===void 0){let S=i.fetchQuery({queryKey:P,queryFn:({signal:v})=>Es(r,g,R,_,v,i),staleTime:ds});return {queryKey:P.join(":"),resolver:S,packageId:t,signal:n,metadata:{from:g,to:R,isoDate:_}}}}}}f=[];}c=chunkW5ELYJ4Z_cjs.a(a,c);}return null},destroy(){}}}function Ns(r){return chunk2XZCLDHJ_cjs.ta(r)??r}var mt=class{constructor(){this.category="UoM";this.bindingPower=chunkFVQWN5HZ_cjs.a.Postfix;}parse(e,o,t,n){let i=Ns(t.value);if(n.emitOpcode(13),n.emitString(i),!(e.infixMinBindingPower>=chunkFVQWN5HZ_cjs.a.Product)&&(e.peek()?.type==="TO"||e.peek()?.type==="IN")){e.consume();let s=e.peek();if(s?.type==="UNIT"||s?.type==="IN"){e.consume();let l=Ns(s.value),u=st(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 Tn(r){return chunk2XZCLDHJ_cjs.ta(r)??r}var lt=class{constructor(){this.category="UoM";}parse(e,o,t){e.parseExpression(chunkFVQWN5HZ_cjs.a.Postfix,t);let n=e.peek();if(n&&n.type==="UNIT"){if(e.consume(),t.emitOpcode(13),t.emitString(Tn(n.value)),e.peek()?.type==="TO"){e.consume("TO");let i=e.consume();i?.type==="UNIT"?(t.emitOpcode(13),t.emitString(Tn(i.value)),t.emitOpcode(81)):i?.type==="BEST"&&t.emitOpcode(83);}else t.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(),t.emitOpcode(13),t.emitString(Tn(i.value)),t.emitOpcode(84)):i?.type==="BEST"&&(e.consume(),t.emitOpcode(83));return}}};var ut=class{constructor(){this.category="UoM";}parse(e,o,t){t.emitOpcode(13),t.emitString(o.value),t.emitOpcode(85);}};function ys(r=60){return {name:"uom:possibilities",priority:r,match(e,o){if(o+2>=e.length)return null;let t=e[o],n=e[o+1],i=e[o+2];return t.type!=="UNIT"||n.type!=="TO"||i.type!=="QUESTION"?null:{consumed:3,replacement:[chunkRC4M6HBX_cjs.b("UOM_POSSIBILITIES_QUERY",t.value,[t,n,i])],ruleName:"uom:possibilities"}}}}var gs=14;function Ps(r,e){if(r===void 0||r.type!=="UNIT")return;let o=(r.value??"").toLowerCase();if(o==="m"&&e===gs)return {kind:gs,ratio:60,spelling:"minutes"};let t=chunk6QRHN3I6_cjs.a[o];return t===void 0?void 0:{kind:t[0],ratio:t[1],spelling:o}}var _s=/^\d+(\.\d+)?$/;function As(r=63){return {name:"uom:compound-quantity",priority:r,match(e,o){let t=e[o];if(t?.type!=="NUMBER"||!_s.test(t.text??""))return null;let n=Ps(e[o+1]);if(n===void 0)return null;let i=n.kind,a=n.ratio,s=Number(t.text)*a,l=n.spelling,u=e[o+1],c=2;for(;;){let N=e[o+c];if(N?.type!=="NUMBER"||!_s.test(N.text??""))break;let E=Ps(e[o+c+1],i);if(E===void 0||E.kind!==i||E.ratio>=a)break;s+=Number(N.text)*E.ratio,a=E.ratio,l=E.spelling,u=e[o+c+1],c+=2;}if(c===2)return null;let f=e.slice(o,o+c),T=s/a;return {consumed:c,replacement:[chunkRC4M6HBX_cjs.b("NUMBER",String(T),f),chunkRC4M6HBX_cjs.b("UNIT",l,[u])],ruleName:"uom:compound-quantity"}}}}function xs(r){return r===void 0||r.type!=="UNIT"?false:chunk6QRHN3I6_cjs.a[(r.value??"").toLowerCase()]!==void 0}function Rs(r=59){return {name:"uom:two-unit-conversion",priority:r,match(e,o){let t=e[o];if(t?.type!=="IN"&&t?.type!=="TO"||!xs(e[o+1])||e[o+2]?.type!=="AND_CONJ"||!xs(e[o+3]))return null;let n=e[o+1].value,i=e[o+3].value;return {consumed:4,replacement:[chunkRC4M6HBX_cjs.b("IN_TWO_UNITS",`${n} ${i}`,e.slice(o,o+4))],ruleName:"uom:two-unit-conversion"}}}}function Os(r=74){return {name:"uom:degree-symbol",priority:r,match(e,o){let t=e[o];if(t?.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:[t,chunkRC4M6HBX_cjs.b("UNIT","degrees",[n])],ruleName:"uom:degree-symbol"}}}}var ct=class{constructor(e){this.builtinIndex=e;this.category="Uom";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,t,n){let[i,a]=String(t.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 Cs(r){return r===void 0||r.type!=="UNIT"?false:chunk6QRHN3I6_cjs.a[(r.value??"").toLowerCase()]!==void 0}var Nn=new Set(["per","a","an","each","every"]);function Bc(r){if(r===void 0||r.type!=="IDENT")return false;let e=(r.text??r.value??"").toLowerCase();return Nn.has(e)?false:/^[a-z][a-z_]{2,}$/.test(e)&&chunk6QRHN3I6_cjs.a[e]===void 0}function Is(r=75){return {name:"uom:bare-rate-denominator",priority:r,match(e,o){let t=e[o];if(t===void 0)return null;if(t.type==="NUMBER"&&Bc(e[o+1])){let l=e[o+1],u=e[o+2];if((u?.type==="SLASH"||u?.type==="IDENT"&&Nn.has((u.text??u.value??"").toLowerCase()))&&Cs(e[o+3]))return {consumed:2,replacement:[t,chunkRC4M6HBX_cjs.b("UNIT",l.value,[l])],ruleName:"uom:bare-rate-denominator"}}if(!Cs(e[o+1]))return null;let n=t.type==="SLASH",i=(t.text??t.value??"").toLowerCase(),a=t.type==="IDENT"&&Nn.has(i);if(!n&&!a)return null;let s=e[o+1];return {consumed:2,replacement:[chunkRC4M6HBX_cjs.b("PER_UNIT",s.value,[t,s])],ruleName:"uom:bare-rate-denominator"}}}}var pt=class{constructor(e){this.builtinIndex=e;this.category="Uom";this.bindingPower=chunkFVQWN5HZ_cjs.a.Product;}parse(e,o,t,n){n.emitOpcode(13),n.emitString(String(t.value)),n.emitOpcode(51),n.emitIndex(this.builtinIndex),n.emitIndex(2);}};var ft=class{constructor(e){this.builtinIndex=e;this.category="Uom";this.bindingPower=chunkFVQWN5HZ_cjs.a.Product;}parse(e,o,t,n){e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,n),n.emitOpcode(51),n.emitIndex(this.builtinIndex),n.emitIndex(2);}};function Uc(r){return r===void 0||r.type!=="UNIT"?false:chunk6QRHN3I6_cjs.a[(r.value??"").toLowerCase()]!==void 0}var Dc=new Set(["per","a","an","each","every"]);function bc(r,e){for(let o=e;o<r.length&&o<e+5;o++){let t=r[o];if(t.type==="PER_UNIT")return true;if(t.type==="EOF"||t.type==="COMMA"||t.type==="RATE_AT")return false;let n=(t.text??t.value??"").toLowerCase();if((t.type==="SLASH"||t.type==="IDENT"&&Dc.has(n))&&Uc(r[o+1]))return true}return false}function hs(r=73){return {name:"uom:at-rate",priority:r,match(e,o){return e[o]?.type!=="RATE_AT"||!bc(e,o+1)?null:{consumed:1,replacement:[chunkRC4M6HBX_cjs.b("AT_RATE","at",[e[o]])],ruleName:"uom:at-rate"}}}}function Vc(r){return r===void 0||r.type!=="UNIT"?false:chunk6QRHN3I6_cjs.a[(r.value??"").toLowerCase()]!==void 0}var Fc=new Set(["a","an"]);function Ss(r=76){return {name:"uom:for-duration",priority:r,match(e,o){let t=e[o];if(t?.type!=="FOR_DURATION")return null;let n=e[o+1];return n?.type!=="IDENT"||!Fc.has((n.text??n.value??"").toLowerCase())||!Vc(e[o+2])?null:{consumed:3,replacement:[chunkRC4M6HBX_cjs.b("STAR","*",[t]),chunkRC4M6HBX_cjs.b("NUMBER","1",[n]),e[o+2]],ruleName:"uom:for-duration"}}}}function yn(r){return r===void 0||r.type!=="UNIT"?false:chunk6QRHN3I6_cjs.a[(r.value??"").toLowerCase()]!==void 0}var Hc=new Set(["a","an"]);function Ls(r=61){return {name:"uom:reversed-conversion",priority:r,match(e,o){if(o!==0||!yn(e[o])||e[o+1]?.type!=="IN")return null;let t=e[o],n=e[o+2];if(n===void 0)return null;if(n.type==="NUMBER"&&yn(e[o+3]))return {consumed:4,replacement:[n,e[o+3],e[o+1],t],ruleName:"uom:reversed-conversion"};let i=(n.text??n.value??"").toLowerCase();return n.type==="IDENT"&&Hc.has(i)&&yn(e[o+3])?{consumed:4,replacement:[chunkRC4M6HBX_cjs.b("NUMBER","1",[n]),e[o+3],e[o+1],t],ruleName:"uom:reversed-conversion"}:null}}}var zc={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},vs=2;function ws(r){return zc[r.toLowerCase().trim()]}var dt="cookingConvert";function ks(r){let e=r[0],o=r[1].value,t=r[2].value;if(e.type!==6||!e.unit)return chunk6U66HQKQ_cjs.P("COOKING_CONVERSION_REQUIRES_UNIT",'Expected a value with a mass or volume unit (e.g. "300g", "10 cups"), got a plain number');let n=e.unit,i=e.toNumber(),a=chunkBKSKZA4W_cjs.c(n),s=chunkBKSKZA4W_cjs.c(t),l=N=>N==="mass"||N==="volume";if(!l(a))return chunk6U66HQKQ_cjs.P("COOKING_CONVERSION_UNSUPPORTED_UNIT",`"${n}" is not a recognized mass or volume unit`);if(!l(s))return chunk6U66HQKQ_cjs.P("COOKING_CONVERSION_UNSUPPORTED_UNIT",`"${t}" is not a recognized mass or volume unit`);if(a===s)return chunk6U66HQKQ_cjs.u(chunkBKSKZA4W_cjs.e(i,n,t),t);let u=ws(o);if(u===void 0)return chunk6U66HQKQ_cjs.P("COOKING_UNKNOWN_INGREDIENT",`No density data for "${o}" \u2014 cannot convert between mass and volume for this ingredient`);if(a==="mass"){let E=chunkBKSKZA4W_cjs.e(i,n,"g")/u,_=chunkBKSKZA4W_cjs.e(E,"ml",t);return chunk6U66HQKQ_cjs.u(_,t)}let f=chunkBKSKZA4W_cjs.e(i,n,"ml")*u,T=chunkBKSKZA4W_cjs.e(f,"g",t);return chunk6U66HQKQ_cjs.u(T,t)}var Et=class{constructor(){this.category="UoM";this.bindingPower=35;}parse(e,o,t,n){let i=t.value;e.consume("IN");let a=e.consume();n.emitOpcode(13),n.emitString(i),n.emitOpcode(13),n.emitString(a.value),n.emitPluginCall(dt,3);}};function Ms(r=68){return {name:"uom-cooking:ingredient-name",priority:r,match(e,o){let t=e[o-1];if(!t||t.type!=="UNIT")return null;for(let n=vs;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:[chunkRC4M6HBX_cjs.b("INGREDIENT_NAME",u,i)],ruleName:"uom-cooking:ingredient-name"}}return null}}}function Bs(r=78){return {name:"uom:multi-word-unit",priority:r,match(e,o){let t=e[o],n=e[o+1];if(t?.type!=="UNIT"||n?.type!=="UNIT"||t.offset+t.text.length+1!==n.offset)return null;let i=`${t.value} ${n.value}`;return chunk6QRHN3I6_cjs.a[i]===void 0?null:{consumed:2,replacement:[chunkRC4M6HBX_cjs.b("UNIT",i,e.slice(o,o+2))],ruleName:"uom:multi-word-unit"}}}}function Us(r=77){return {name:"uom:compound-unit",priority:r,match(e,o){let t=e[o],n=e[o+1],i=e[o+2];if(t?.type!=="UNIT"||n?.type!=="SLASH"||i?.type!=="UNIT")return null;let a=`${t.value}/${i.value}`;return {consumed:3,replacement:[chunkRC4M6HBX_cjs.b("UNIT",a,[t,n,i])],ruleName:"uom:compound-unit"}}}}var gn={name:"solve-uom",prefixParselets:{CONVERT:new lt,UOM_POSSIBILITIES_QUERY:new ut},infixParselets:{IN_TWO_UNITS:new ct(94),PER_UNIT:new pt(95),AT_RATE:new ft(96),UNIT:new mt,INGREDIENT_NAME:new Et},normalizerRules:[Bs(),Us(),ys(),As(),Rs(),Os(),hs(),Ss(),Is(),Ls(),Ms()],pluginFunctions:{[dt]:ks}};var Q=class{constructor(){this.category="UoM";}parse(e,o,t){let n=chunk2XZCLDHJ_cjs.ta(o.value)??o.value.toUpperCase();e.parseExpression(chunkFVQWN5HZ_cjs.a.Prefix,t),e.peek()?.type==="UNIT"&&e.consume(),t.emitOpcode(13),t.emitString(n),t.emitOpcode(80);}};var Tt=class{constructor(){this.category="UoM";this.bindingPower=35;}parse(e,o,t,n){let i=e.peek();if(i?.type==="IP_CIDR"){e.parseExpression(chunkFVQWN5HZ_cjs.a.Prefix,n),n.emitPluginCall("ipInCidr",2);return}if(i&&(i.type==="UNIT"||i.type==="DOLLAR"||i.type==="POUND"||i.type==="EURO"||i.type==="YEN"||i.type==="RUBLE"||i.type==="WON"||i.type==="CURRENCY_SYMBOL"||i.type==="IDENT"||i.type==="IN")){e.consume();let a=chunk2XZCLDHJ_cjs.ta(i.value)??i.value,s=st(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 Pn(r={}){return {name:"solve-currency",asyncResolvers:[new chunkW5ELYJ4Z_cjs.b,Ts(r.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 Tt},pluginFunctions:{[fe]:En(r.historicalRateProvider)}}}var _n=Pn();var he=class{constructor(e=0){this.category="Vector";this.dimension=e;}parse(e,o,t){e.consume("LPAREN");let n=0;if(e.peek()?.type!=="RPAREN")for(e.parseExpression(0,t),n++;e.match("COMMA");)e.parseExpression(0,t),n++;e.consume("RPAREN"),t.emitOpcode(152),t.emitIndex(1),t.emitIndex(this.dimension>0?this.dimension:n);}};var Nt=class{constructor(){this.category="Float";}parse(e,o,t){e.consume("LPAREN"),e.parseExpression(0,t),e.consume("RPAREN"),t.emitOpcode(152),t.emitIndex(1),t.emitIndex(1);}};var An={name:"solve-vector",prefixParselets:{VEC2:new he(2),VEC3:new he(3),VEC4:new he(4),FLOAT:new Nt}};var yt=class{constructor(){this.category="Matrix";}parse(e,o,t){let n=0,i=-1;if(e.peek()?.type==="RBRACKET")throw chunkNAZ6PGLS_cjs.c.parsing("EMPTY_MATRIX_LITERAL","A matrix literal cannot be empty \u2014 `[]` has no valid shape.",{});for(;;){let a=0;for(e.parseExpression(0,t),a++;e.match("COMMA");)e.parseExpression(0,t),a++;if(i===-1)i=a;else if(a!==i)throw chunkNAZ6PGLS_cjs.c.parsing("RAGGED_MATRIX_LITERAL",`Matrix literal rows must all have the same number of columns \u2014 row ${n+1} has ${a}, but a previous row has ${i}.`,{expectedCols:i,actualCols:a,row:n+1});if(n++,!e.match("SEMICOLON"))break}e.consume("RBRACKET"),t.emitOpcode(152),t.emitIndex(n),t.emitIndex(i);}};var gt=class{constructor(){this.category="Matrix";this.bindingPower=chunkFVQWN5HZ_cjs.a.Postfix;}parse(e,o,t,n){let i=this.hasTopLevelColon(e);this.parseIndexArg(e,n,i);let a=1;if(e.match("COMMA")&&(this.parseIndexArg(e,n,i),a=2),e.consume("RBRACKET"),!i){a===1?n.emitOpcode(153):n.emitOpcode(154);return}if(a!==2)throw chunkNAZ6PGLS_cjs.c.parsing("INVALID_MATRIX_SLICE_ARITY",`Range-based matrix slicing needs exactly 2 arguments ("a[rowRange, colRange]"), got ${a}.`,{argCount:a});n.emitOpcode(155);}hasTopLevelColon(e){let o=0;for(let t=0;;t++){let n=e.peekAt(t);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,t){e.parseExpression(0,o);let n=false;e.match("COLON")&&(e.parseExpression(0,o),n=true),t&&(n||o.emitOpcode(3),o.emitOpcode(156));}};var xn={name:"solve-matrix",prefixParselets:{LBRACKET:new yt},infixParselets:{LBRACKET:new gt}};function Pt(r,e){let o=r.peek(),t=r.peekAt(1);if(o&&(o.type==="IDENT"||o.type==="UNIT"||o.type==="FUNC")&&t?.type==="COMMA"){r.consume();let a=o.value,s=Wo[a.toLowerCase()];return s!==void 0?{kind:1,builtinIdx:s}:{kind:2,name:a}}let n=new chunkFVQWN5HZ_cjs.d(e.pluginIndexMap);r.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,n),r.setBuilder(e);let i=n.build();if(i.hasAsync)throw chunkNAZ6PGLS_cjs.c.parsing("MAP_REDUCE_TRANSFORM_MUST_BE_SYNCHRONOUS","map/reduce transform expressions must be synchronous (no weather/stocks/currency calls).");return {kind:0,program:i}}function Ds(r){let e=r.peek(),o=r.peekAt(1);return !!e&&(e.type==="IDENT"||e.type==="UNIT")&&o?.type==="EQUALS"}function bs(r){let e=r.peek();if(e&&(e.type==="IDENT"||e.type==="UNIT"))return r.consume(),e.value;throw chunkNAZ6PGLS_cjs.c.parsing("MAP_REDUCE_EXPECTED_COLLECTION_NAME",`Expected a collection name (e.g. "x" in "x=[1,2,3]") but got ${e?`"${e.value}"`:"end of input"}.`)}function ee(r,e){r.parseExpression(0,e),r.match("COLON")&&(r.parseExpression(0,e),e.emitOpcode(156));}function ie(r,e,o,t,n){if(r.emitOpcode(e),r.emitIndex(o.kind),o.kind===0){let i=r.emitAnonymousBody(t,o.program);r.emitIndex(i);}else o.kind===1?r.emitIndex(o.builtinIdx):r.emitString(o.name);r.emitIndex(n);}var _t=class{constructor(){this.category="MapReduce";}parse(e,o,t){e.consume("LPAREN");let n=Pt(e,t);e.consume("COMMA");let i=[];if(Ds(e))do{let a=bs(e);e.consume("EQUALS"),ee(e,t),i.push(a);}while(e.match("COMMA"));else ee(e,t),i.push("x");e.consume("RPAREN"),ie(t,157,n,i,i.length);}};var At=class{constructor(){this.category="MapReduce";}parse(e,o,t){e.consume("LPAREN");let n=Pt(e,t);e.consume("COMMA"),ee(e,t);let i=0;e.match("COMMA")&&(e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,t),i=1),e.consume("RPAREN"),ie(t,158,n,["acc","x"],i);}};var xt=class{constructor(){this.category="MapReduce";}parse(e,o,t){e.consume("LPAREN");let n=new chunkFVQWN5HZ_cjs.d(t.pluginIndexMap);n.emitOpcode(60),n.emitString("acc"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,n),e.setBuilder(t),n.emitOpcode(20);let i=n.build();if(i.hasAsync)throw chunkNAZ6PGLS_cjs.c.parsing("MAP_REDUCE_TRANSFORM_MUST_BE_SYNCHRONOUS","sum's element expression must be synchronous (no weather/stocks/currency calls).");e.consume("COMMA"),ee(e,t),e.consume("RPAREN"),t.emitOpcode(10),t.emitNumber(0),ie(t,158,{kind:0,program:i},["acc","x"],1);}};var Rt=class{constructor(){this.category="MapReduce";}parse(e,o,t){e.consume("LPAREN");let n=new chunkFVQWN5HZ_cjs.d(t.pluginIndexMap);n.emitOpcode(60),n.emitString("acc"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,n),e.setBuilder(t),n.emitOpcode(22);let i=n.build();if(i.hasAsync)throw chunkNAZ6PGLS_cjs.c.parsing("MAP_REDUCE_TRANSFORM_MUST_BE_SYNCHRONOUS","prod's element expression must be synchronous (no weather/stocks/currency calls).");e.consume("COMMA"),ee(e,t),e.consume("RPAREN"),t.emitOpcode(10),t.emitNumber(1),ie(t,158,{kind:0,program:i},["acc","x"],1);}};var Gc={map:"MAP",reduce:"REDUCE",sum:"SUM_FN",prod:"PROD_FN"};function Kc(r,e){return r?!!(r.type==="LINE_REF"||r.type==="IDENT"&&(/^line\d+$/i.test(r.value)||/^line$/i.test(r.value)&&e?.type==="NUMBER"&&/^\d+$/.test(e.value))):false}function Vs(r=80){return {name:"mapreduce:call",priority:r,startTokenTypes:["IDENT"],match(e,o){let t=e[o];if(!t||t.type!=="IDENT")return null;let n=t.value.toLowerCase(),i=Gc[n];return !i||e[o+1]?.type!=="LPAREN"||n==="sum"&&Kc(e[o+2],e[o+3])?null:{consumed:1,replacement:[new chunkFAGFPVYK_cjs.a(i,chunk5IJD5L3O_cjs.c(i),t.value,t.value,t.offset,0,t.line,t.col)],ruleName:"mapreduce:call"}}}}var Rn={name:"solve-mapreduce",normalizerRules:[Vs()],prefixParselets:{MAP:new _t,REDUCE:new At,SUM_FN:new xt,PROD_FN:new Rt}};var Ot=class{constructor(){this.category="BigInt";}parse(e,o,t){t.emitOpcode(11),t.emitString(chunkFVQWN5HZ_cjs.e(o.value,e.getLocaleCode()));}};var On={name:"solve-bigint",prefixParselets:{BIGINT:new Ot}};var re=class{constructor(e){this.opcode=e;this.category="Conditionals";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,t,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,t,n){e.parseExpression(this.bindingPower,n),n.emitOpcode(this.opcode);}};var ar=class{constructor(e){this.value=e;this.category="Conditionals";}parse(e,o,t){t.emitOpcode(14),t.emitByte(this.value?1:0);}};var Ct=class{constructor(){this.category="Conditionals";}parse(e,o,t){e.parseExpression(0,t),e.consume("THEN"),e.parseExpression(0,t),e.consume("ELSE"),e.parseExpression(0,t),t.emitOpcode(132);}};var Cn={name:"solve-conditionals",prefixParselets:{TRUE:new ar(true),FALSE:new ar(false),IF:new Ct},infixParselets:{EQUALITY:new re(40),NEQ:new re(41),LT:new re(42),GT:new re(44),LTE:new re(43),GTE:new re(45),OR:new Se(131,chunkFVQWN5HZ_cjs.a.LogicalOr),LOGICAL_AND:new Se(130,chunkFVQWN5HZ_cjs.a.LogicalAnd),LOGICAL_OR:new Se(131,chunkFVQWN5HZ_cjs.a.LogicalOr)}};var $c={percent:74,percentage:74,decimal:70,dec:70,number:70,hex:71,fraction:140,multiplier:141,x:141,sci:142,scientific:142,binary:143,bin:143,octal:144,oct:144},Fs={2:143,8:144,16:71},It=class{constructor(){this.category="Converters";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,t,n){let i=e.peek();if(i?.type==="PERCENT"){e.consume(),n.emitOpcode(74);return}if(!i||i.type!=="CONVERTER_NAME"&&i.type!=="IDENT"&&i.type!=="FUNC"&&i.type!=="UNIT")throw chunkNAZ6PGLS_cjs.c.parsing("AS_CONVERTER_EXPECTED_NAME",`Expected a converter name after "as" (e.g. "as hex", "as decimal") but got ${i?`"${i.value}"`:"end of input"}`);e.consume();let a=i.value.toLowerCase();if(a==="base"){let l=e.peek(),u=l?.type==="NUMBER"?Number(l.value):NaN,c=Fs[u];if(c===void 0)throw chunkNAZ6PGLS_cjs.c.parsing("AS_CONVERTER_UNSUPPORTED_BASE",`"as base ${l?.value??"?"}": only bases ${Object.keys(Fs).join(", ")} can be written out`);e.consume(),n.emitOpcode(c);return}let s=$c[a];if(s!==void 0){s===141&&e.match("OF")&&(e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,n),n.emitOpcode(23)),n.emitOpcode(s);return}n.emitOpcode(13),n.emitString(a),n.emitOpcode(145);}};var Hs={ten:10,hundred:100,thousand:1e3,million:1e6,billion:1e9};function zs(r,e,o){r.emitOpcode(10),r.emitNumber(e),r.emitOpcode(23),Gs(r,o),r.emitOpcode(10),r.emitNumber(e),r.emitOpcode(22);}function Gs(r,e){let o=e==="up"?Yc:e==="down"?jc:Wc;r.emitOpcode(51),r.emitIndex(o),r.emitIndex(1);}var Wc=8,Yc=6,jc=7,Xc=97;function Qc(r){let o=(r.peek()?.text??"").toLowerCase();return o==="up"?(r.consume(),"up"):o==="down"?(r.consume(),"down"):"nearest"}var ht=class{constructor(){this.category="Converters";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,t,n){let i=Qc(e);if(e.match("TO_NEAREST")){zs(n,Ks(e),i);return}Gs(n,i);}},St=class{constructor(){this.category="Converters";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,t,n){zs(n,Ks(e),"nearest");}};function Ks(r){let e=r.peek(),o=(e?.text??"").toLowerCase(),t=Hs[o];if(t!==void 0)return r.consume(),t;if(e?.type==="NUMBER"){r.consume();let n=Number(e.value);if(Number.isFinite(n)&&n>0)return n}throw chunkNAZ6PGLS_cjs.c.parsing("INVALID_ROUNDING_INCREMENT",`"to nearest ${e?.value??"?"}": expected a positive number or one of ${Object.keys(Hs).join(", ")}`)}var Lt=class{constructor(){this.category="Converters";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,t,n){let i=Number(t.value);if(!Number.isFinite(i)||i<0||i>100)throw chunkNAZ6PGLS_cjs.c.parsing("INVALID_DECIMAL_PLACES",`"to ${t.value} dp": expected a place count between 0 and 100`);n.emitOpcode(10),n.emitNumber(i),n.emitOpcode(51),n.emitIndex(Xc),n.emitIndex(2);}};var qc=new Set(["dp","dps","decimals","digits","digit"]),Zc=new Set(["decimal"]);function $s(r=66){return {name:"converters:decimal-places",priority:r,match(e,o){if(e[o]?.type!=="TO")return null;let t=e[o+1];if(t?.type!=="NUMBER")return null;let n=e[o+2];if(!n)return null;let i=(n.text??n.value??"").toLowerCase(),a=3;if(Zc.has(i)){let l=(e[o+3]?.text??"").toLowerCase();if(l!=="place"&&l!=="places")return null;a=4;}else if(!qc.has(i))return null;return {consumed:a,replacement:[chunkRC4M6HBX_cjs.b("DECIMAL_PLACES",t.value,e.slice(o,o+a))],ruleName:"converters:decimal-places"}}}}var Jc=new Set(["hex","bin"]);function Ws(r=67){return {name:"converters:preposition",priority:r,match(e,o){let t=e[o];if(t?.type!=="IN"&&t?.type!=="TO")return null;let n=e[o+1];return n?.type==="CONVERTER_NAME"||n?.type==="FUNC"&&Jc.has(n.value.toLowerCase())?{consumed:1,replacement:[chunkRC4M6HBX_cjs.b("AS","as",[t])],ruleName:"converters:preposition"}:null}}}var In={name:"solve-converters",phrases:{"to nearest":"TO_NEAREST","to the nearest":"TO_NEAREST"},infixParselets:{AS:new It,ROUNDED:new ht,TO_NEAREST:new St,DECIMAL_PLACES:new Lt},normalizerRules:[$s(),Ws()]};var H=class{constructor(e){this.builtinIndex=e;this.category="MathPhrases";}parse(e,o,t){let n=0;for(e.parseExpression(chunkFVQWN5HZ_cjs.a.Conjunction,t),n++;e.match("COMMA")||e.match("AND_CONJ");)e.parseExpression(chunkFVQWN5HZ_cjs.a.Conjunction,t),n++;t.emitOpcode(51),t.emitIndex(this.builtinIndex),t.emitIndex(n);}};var vt=class{constructor(e){this.builtinIndex=e;this.category="MathPhrases";}parse(e,o,t){let n=0;do{if(e.parseExpression(chunkFVQWN5HZ_cjs.a.Conjunction,t),n++,!e.match("RATE_AT")&&!e.match("AT")){let i=e.peek();throw chunkNAZ6PGLS_cjs.c.parsing("WEIGHTED_AVERAGE_MISSING_WEIGHT",'weighted average: each value needs a weight, as in "72 at 30%"',{actualType:i?.type,actualValue:i?.value})}e.parseExpression(chunkFVQWN5HZ_cjs.a.Product,t),n++,this.skipWeightLabel(e);}while(e.match("COMMA")||e.match("AND_CONJ"));t.emitOpcode(51),t.emitIndex(this.builtinIndex),t.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 hn(r){return {category:"MathPhrases",parse(e,o,t){e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,t),t.emitOpcode(51),t.emitIndex(r),t.emitIndex(1);}}}var js={category:"MathPhrases",parse(r,e,o){if(r.parseExpression(chunkFVQWN5HZ_cjs.a.Product,o),!r.match("DIVIDE_BY")&&!r.match("SLASH"))throw chunkNAZ6PGLS_cjs.c.parsing("REMAINDER_EXPECTED_DIVIDED_BY",'Expected "divided by" or "/", as in "remainder of 21 divided by 5"');r.parseExpression(chunkFVQWN5HZ_cjs.a.Product,o),o.emitOpcode(24);}},Xs={category:"MathPhrases",parse(r,e,o){if(r.parseExpression(chunkFVQWN5HZ_cjs.a.Product,o),!r.match("OF"))throw chunkNAZ6PGLS_cjs.c.parsing("ROOT_EXPECTED_OF",'Expected "of", as in "root 5 of 100"');r.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,o),o.emitOpcode(2),o.emitOpcode(10),o.emitNumber(1),o.emitOpcode(2),o.emitOpcode(23),o.emitOpcode(25);}},Qs={category:"MathPhrases",parse(r,e,o){if(r.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,o),Ys(o),!r.match("LOG_BASE"))throw chunkNAZ6PGLS_cjs.c.parsing("LOG_EXPECTED_BASE",'Expected "base", as in "log 20 base 4"');r.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,o),Ys(o),o.emitOpcode(23);}},ep=5;function Ys(r){r.emitOpcode(51),r.emitIndex(ep),r.emitIndex(1);}function qs(r=69){return {name:"mathphrases:function-phrase",priority:r,match(e,o){let t=e[o];if(t?.type!=="FUNC")return null;let n=(t.value??"").toLowerCase();if(n!=="root"&&n!=="log"||e[o+1]?.type==="LPAREN")return null;if(n==="root")return {consumed:1,replacement:[chunkRC4M6HBX_cjs.b("NTH_ROOT","root",[t])],ruleName:"mathphrases:function-phrase"};let i=rp(e,o+1);if(i===-1)return null;let a=e.slice(o,i+1).map((s,l)=>l===0?chunkRC4M6HBX_cjs.b("LOG_PHRASE","log",[s]):l===i-o?chunkRC4M6HBX_cjs.b("LOG_BASE","base",[s]):s);return {consumed:i-o+1,replacement:a,ruleName:"mathphrases:function-phrase"}}}}function rp(r,e){for(let o=e;o<r.length&&o<e+8;o++){let t=r[o];if(t.type==="EOF"||t.type==="COMMA"||t.type==="RPAREN")return -1;if((t.text??t.value??"").toLowerCase()==="base")return o}return -1}function sr(r){return {category:"MathPhrases",parse(e,o,t){e.parseExpression(chunkFVQWN5HZ_cjs.a.Conjunction,t),e.consume("AND_CONJ"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,t),t.emitOpcode(51),t.emitIndex(r),t.emitIndex(2);}}}var Zs={category:"MathPhrases",parse(r,e,o){r.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,o),o.emitOpcode(10),o.emitNumber(2),o.emitOpcode(23);}};var Js={category:"MathPhrases",parse(r,e,o){r.parseExpression(chunkFVQWN5HZ_cjs.a.Conjunction,o),r.consume("AND_CONJ"),r.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,o),o.emitOpcode(20),o.emitOpcode(10),o.emitNumber(2),o.emitOpcode(23);}};var em=et({category:"MathPhrases",alternatives:[{slots:[{kind:"keyword",tokenTypes:["BETWEEN"]},{kind:"expr",bindingPower:chunkFVQWN5HZ_cjs.a.Product},{kind:"keyword",tokenTypes:["AND_CONJ"]},{kind:"expr"}],emit:r=>{r.emitOpcode(51),r.emitIndex(37),r.emitIndex(2);}}]});var tp=47,wt=class{constructor(){this.category="MathPhrases";}parse(e,o,t){e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,t);let n=e.peek();if(n?.type==="BETWEEN")e.consume(),e.parseExpression(chunkFVQWN5HZ_cjs.a.Product,t),e.consume("AND_CONJ"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,t);else if(n?.type==="FROM")e.consume(),e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,t),e.consume("TO"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,t);else throw chunkNAZ6PGLS_cjs.c.parsing("CLAMP_EXPECTED_BETWEEN_OR_FROM",`Expected "between" or "from" after "clamp <value>" but got ${n?`"${n.value}"`:"end of input"}`);t.emitOpcode(51),t.emitIndex(tp),t.emitIndex(3);}};var op=46,kt=class{constructor(){this.category="MathPhrases";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,t,n){e.parseExpression(this.bindingPower,n),e.consume("AS"),e.parseExpression(this.bindingPower,n),e.consume("IS_TO");let i=e.consume();if(!i||i.value.toLowerCase()!=="what")throw chunkNAZ6PGLS_cjs.c.parsing("PROPORTION_EXPECTED_WHAT",`Expected "what" but got ${i?`"${i.value}"`:"end of input"}`);n.emitOpcode(51),n.emitIndex(op),n.emitIndex(3);}};var np=42,ip=43,ap=44,sp=45,mp=9,lp=10,up=101,cp=102,pp=103,fp=104,dp=105,Ep=106,Tp=107,Np=38,yp=39,gp=0,Pp=21,Sn={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(np),MEDIAN_OF:new H(ip),TOTAL_OF:new H(ap),COUNT_OF:new H(sp),LARGER_OF:sr(lp),SMALLER_OF:sr(mp),HALF_OF:Zs,MIDPOINT_BETWEEN:Js,RANDOM_NUMBER:em,REMAINDER_OF:js,NTH_ROOT:Xs,LOG_PHRASE:Qs,GCD_OF:sr(Np),LCM_OF:sr(yp),SQUARE_ROOT_OF:hn(gp),CUBE_ROOT_OF:hn(Pp),CLAMP:new wt,STANDARD_DEVIATION_OF:new H(up),SAMPLE_STANDARD_DEVIATION_OF:new H(cp),VARIANCE_OF:new H(pp),SAMPLE_VARIANCE_OF:new H(fp),SPREAD_OF:new H(dp),MODE_OF:new H(Ep),WEIGHTED_AVERAGE_OF:new vt(Tp)},infixParselets:{IS_TO:new kt},normalizerRules:[qs()]};var rm={annually:1,yearly:1,"semi-annually":2,quarterly:4,monthly:12,fortnightly:26,weekly:52,daily:365};function Ln(r){if(!r.match("COMPOUNDING"))return 1;let e=r.peek(),o=(e?.text??e?.value??"").toLowerCase(),t=rm[o];if(t===void 0)throw chunkNAZ6PGLS_cjs.c.parsing("UNKNOWN_COMPOUNDING_INTERVAL",`compounding ${o||"?"}: expected one of ${Object.keys(rm).join(", ")}`);return r.consume(),t}var mr=class{constructor(e,o){this.annualIndex=e;this.intervalIndex=o;this.category="Finance";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,t,n){e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,n),e.match("RATE_AT")||e.consume("AT"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,n);let i=Ln(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);}},Mt=class{constructor(e){this.builtinIndex=e;this.category="Finance";}parse(e,o,t){e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,t),!e.match("AFTER")&&!e.match("OVER")&&!e.match("IN")&&e.consume("AFTER"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,t),e.match("RATE_AT")||e.consume("AT"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,t),t.emitOpcode(2),t.emitOpcode(51),t.emitIndex(this.builtinIndex),t.emitIndex(3);}},Bt=class{constructor(e){this.builtinIndex=e;this.category="Finance";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,t,n){e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,n),e.consume("RETURNED"),n.emitOpcode(51),n.emitIndex(this.builtinIndex),n.emitIndex(2);}},Ut=class{constructor(e){this.builtinIndex=e;this.category="Finance";}parse(e,o,t){e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,t),e.consume("INVESTED"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,t),e.consume("RETURNED"),!e.match("AFTER")&&!e.match("OVER")&&!e.match("IN")&&e.consume("AFTER"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,t),t.emitOpcode(51),t.emitIndex(this.builtinIndex),t.emitIndex(3);}};function Dt(r,e,o){return om(r,o)?(r.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,e),tm(r),r.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,e),{swap:true}):(tm(r),r.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,e),_p(r,o),r.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,e),{swap:false})}function om(r,e){for(let o of e)if(r.match(o))return true;return false}function _p(r,e){om(r,e)||r.consume(e[0]);}function tm(r){r.match("RATE_AT")||r.consume("AT");}var lr=class{constructor(e,o){this.builtinIndex=e;this.intervalIndex=o;this.category="Finance";}parse(e,o,t){e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,t);let{swap:n}=Dt(e,t,["AFTER","FOR_DURATION","OVER"]),i=Ln(e);if(n&&t.emitOpcode(2),i===1){t.emitOpcode(51),t.emitIndex(this.builtinIndex),t.emitIndex(3);return}t.emitOpcode(10),t.emitNumber(i),t.emitOpcode(51),t.emitIndex(this.intervalIndex),t.emitIndex(4);}};var W=class{constructor(e,o){this.builtinIndex=e;this.periodsPerYear=o;this.category="Finance";}parse(e,o,t){e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,t);let{swap:n}=Dt(e,t,["OVER"]);n&&t.emitOpcode(2),t.emitOpcode(10),t.emitNumber(this.periodsPerYear),t.emitOpcode(51),t.emitIndex(this.builtinIndex),t.emitIndex(4);}};var bt=class{constructor(e){this.builtinIndex=e;this.category="Finance";}parse(e,o,t){e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,t),e.consume("BETWEEN"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,t),e.match("PEOPLE"),t.emitOpcode(51),t.emitIndex(this.builtinIndex),t.emitIndex(2);}},Vt=class{constructor(e){this.builtinIndex=e;this.category="Finance";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,t,n){e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,n),e.consume("WAYS"),n.emitOpcode(51),n.emitIndex(this.builtinIndex),n.emitIndex(2);}};var nm={daily:{perYear:365,unit:"days"},weekly:{perYear:52,unit:"weeks"},monthly:{perYear:12,unit:"months"},yearly:{perYear:1,unit:"years"},annually:{perYear:1,unit:"years"}};function Ap(r){let e=r.peek(),o=(e?.text??e?.value??"").toLowerCase(),t=nm[o];if(t===void 0)throw chunkNAZ6PGLS_cjs.c.parsing("UNKNOWN_SAVINGS_PERIOD",`savings goal: expected a contribution period, one of ${Object.keys(nm).join(", ")}, not "${o||"?"}".`);return r.consume(),t}var Ft=class{constructor(e){this.builtinIndex=e;this.category="Finance";}parse(e,o,t){e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,t),e.match("RATE_AT")||e.consume("AT"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Product,t),e.match("STAR");let n=Ap(e);t.emitOpcode(10),t.emitNumber(n.perYear),e.match("RATE_AT")||e.match("AT")?e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,t):(t.emitOpcode(10),t.emitNumber(0)),t.emitOpcode(13),t.emitString(n.unit),t.emitOpcode(51),t.emitIndex(this.builtinIndex),t.emitIndex(5);}},Ht=class{constructor(e){this.builtinIndex=e;this.category="Finance";}parse(e,o,t){e.parseExpression(chunkFVQWN5HZ_cjs.a.Product,t),e.consume("IN"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,t),e.match("RATE_AT")||e.match("AT")?e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,t):(t.emitOpcode(10),t.emitNumber(0)),t.emitOpcode(51),t.emitIndex(this.builtinIndex),t.emitIndex(3);}};var Le=class{constructor(e){this.builtinIndex=e;this.category="Finance";}parse(e,o,t){e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,t),e.consume("RATE_AT"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,t),t.emitOpcode(51),t.emitIndex(this.builtinIndex),t.emitIndex(2);}};var xp=60;function Rp(r){for(let e=0;;e++){let o=r.peekAt(e);if(!o)return false;if(o.type==="FROM"||o.type==="WORTH_IN")return true}}var ur=class{constructor(e){this.variant=e;this.category="Finance";}parse(e,o,t){if(!Rp(e)){e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,t);return}if(e.parseExpression(chunkFVQWN5HZ_cjs.a.Product,t),this.variant==="what-was"){e.consume("WORTH_IN"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,t),t.emitPluginCall("inflationToYearFromPresent",2);return}let n=e.peek();if(n?.type==="FROM"){e.consume(),e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,t),t.emitPluginCall("inflationFromYearToPresent",2);return}if(n?.type==="IN"){e.consume(),e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,t),e.consume("WORTH_IN"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,t),t.emitOpcode(51),t.emitIndex(xp),t.emitIndex(3);return}let i=n?n.type:"end of input";throw chunkNAZ6PGLS_cjs.c.parsing("INFLATION_EXPECTED_FROM_OR_IN",`Expected "from <year>" or "in <year> worth in <year>" after "what is <amount>", got ${i}`)}};var zt=class{constructor(){this.category="Finance";}parse(e,o,t){e.parseExpression(chunkFVQWN5HZ_cjs.a.Product,t),e.consume("IN"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,t),e.consume("ASSUMING"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,t);let n=e.peek();if((n&&n.type==="IDENT"?n.value.toLowerCase():void 0)!=="inflation"){let a=n?n.value:"end of input";throw chunkNAZ6PGLS_cjs.c.parsing("INFLATION_EXPECTED_INFLATION_WORD",`Expected the word "inflation" after "assuming <rate>%", got "${a}"`)}e.consume(),t.emitPluginCall("inflationFutureValue",3);}};var Gt=class{constructor(){this.category="Finance";this.bindingPower=35;}parse(e,o,t,n){let i=Number(t.value);n.emitOpcode(10),n.emitNumber(i),n.emitPluginCall("inflationToYearFromPresent",2);}};function im(r,e){return chunk6U66HQKQ_cjs.P(r,`Year ${e} is outside the bundled CPI table's range (${chunkEEVUKZ5B_cjs.z}-${chunkEEVUKZ5B_cjs.A})`)}function am(r){let e=r[0],o=r[1].toNumber(),t=new Date().getFullYear(),n=chunkEEVUKZ5B_cjs.B(e.toNumber(),o,t);return n===void 0?im("INFLATION_YEAR_OUT_OF_RANGE",o):e.type===6?chunk6U66HQKQ_cjs.u(n,e.unit):chunk6U66HQKQ_cjs.n(n)}function sm(r){let e=r[0],o=new Date().getFullYear(),t=r[1].toNumber(),n=chunkEEVUKZ5B_cjs.B(e.toNumber(),o,t);return n===void 0?im("INFLATION_YEAR_OUT_OF_RANGE",t):e.type===6?chunk6U66HQKQ_cjs.u(n,e.unit):chunk6U66HQKQ_cjs.n(n)}function mm(r){let e=r[0],o=r[1].toNumber(),t=r[2].toNumber(),n=o-new Date().getFullYear();if(1+t<=0)return chunk6U66HQKQ_cjs.P("INVALID_RATE",`inflationFutureValue: rate ${t} makes (1 + rate) non-positive`);let a=e.toNumber()/Math.pow(1+t,n);return e.type===6?chunk6U66HQKQ_cjs.u(a,e.unit):chunk6U66HQKQ_cjs.n(a)}function lm(r=70){return {name:"finance:in-year-dollars",priority:r,match(e,o){let t=e[o],n=e[o+1],i=e[o+2];if(t.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:[chunkRC4M6HBX_cjs.b("IN_YEAR_DOLLARS",n.value,e.slice(o,o+3))],ruleName:"finance:in-year-dollars"}}}}var Op={RECURRING_INTERVAL_NOT_POSITIVE:"RECURRING_INTERVAL_NOT_POSITIVE"},Cp={daily:365,weekly:52,monthly:12,yearly:1,annually:1},Ip={day:365,days:365,week:52,weeks:52,month:12,months:12,year:1,years:1},hp=new Set(["a","an"]),Sp=new Set(["NUMBER","FLOAT","HEX","BIGINT","RPAREN","RBRACKET","IDENT","PERCENT","STRING"]);function cr(r){return r===void 0?"":(r.text??r.value??"").toLowerCase()}function um(r){if(!(r===void 0||r.type!=="UNIT"))return Ip[cr(r)]}function Lp(r,e){let o=r[e];if(o===void 0)return null;if(o.type==="IDENT"){let t=Cp[cr(o)];if(t!==void 0)return {perYear:t,consumed:1};if(cr(o)==="every"){let n=r[e+1];if(n?.type!=="NUMBER")return null;let i=um(r[e+2]);if(i===void 0)return null;let a=Number((n.value??"").replace(/,/g,""));if(!(a>0))throw chunkNAZ6PGLS_cjs.c.parsing({code:Op.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} ${cr(r[e+2])}`});return {perYear:i/a,consumed:3}}}return null}function vp(r,e){let o=r[e];if(o===void 0)return null;let t,n;if(o.type==="NUMBER")t=Number((o.value??"").replace(/,/g,"")),n=e+1;else if(o.type==="IDENT"&&hp.has(cr(o)))t=1,n=e+1;else return null;let i=um(r[n]);return i===void 0||!Number.isFinite(t)||t<0?null:{years:t/i,consumed:n-e+1}}function wp(r,e){let o=r*e,t=Math.round(o);return Math.abs(o-t)<1e-9?t:Math.floor(o)}function cm(r=78){return {name:"finance:recurring-schedule",priority:r,match(e,o){let t=e[o];if(t===void 0||!Sp.has(t.type))return null;let n=Lp(e,o+1);if(n===null)return null;let i=o+1+n.consumed;if(e[i]?.type!=="FOR_DURATION")return null;let a=vp(e,i+1);if(a===null)return null;let s=wp(n.perYear,a.years),l=i+1+a.consumed-o,u=e.slice(o,o+l);return {replacement:[t,chunkRC4M6HBX_cjs.b("STAR","*",u),chunkRC4M6HBX_cjs.b("NUMBER",String(s),u)],consumed:l,ruleName:"finance:recurring-schedule"}}}}function Kt(r){return r===void 0?"":(r.text??r.value??"").toLowerCase()}var pm=new Set(["NUMBER","FLOAT","HEX","BIGINT","RPAREN","RBRACKET","IDENT","PERCENT","STRING"]),fm=new Set(["NUMBER","FLOAT"]);function dm(r=77){return {name:"finance:bill-split",priority:r,match(e,o){let t=e[o];if(t===void 0)return null;if(pm.has(t.type)){let f=e[o+1],T=e[o+2],N=e[o+3];if(f?.type==="IDENT"&&Kt(f)==="split"&&T!==void 0&&fm.has(T.type)&&N?.type==="IDENT"&&Kt(N)==="ways")return {consumed:4,replacement:[t,chunkRC4M6HBX_cjs.b("SPLIT_WAYS","split",[f]),T,chunkRC4M6HBX_cjs.b("WAYS","ways",[N])],ruleName:"finance:bill-split"}}if(t.type!=="IDENT"||Kt(t)!=="split")return null;let n=e[o-1];if(n!==void 0&&pm.has(n.type))return null;let i=-1;for(let f=o+1;f<e.length;f++)if(e[f].type==="BETWEEN"){i=f;break}if(i===-1)return null;let a=e[i+1];if(a===void 0||!fm.has(a.type))return null;let s=i+2,l=e[s]?.type==="IDENT"&&Kt(e[s])==="people",u=l?s:i+1,c=[chunkRC4M6HBX_cjs.b("SPLIT","split",[t]),...e.slice(o+1,i+2)];return l&&c.push(chunkRC4M6HBX_cjs.b("PEOPLE","people",[e[s]])),{consumed:u-o+1,replacement:c,ruleName:"finance:bill-split"}}}}var vn=51,kp=52,$t=55,Wt=56,wn=80,Mp=81,Bp=82,Up=83,Dp=84,bp=59,Vp=85,Fp=86,Em=98,Hp=99,zp=100,kn={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 Mt(Bp),ANNUAL_RETURN_ON:new Ut(Dp),COMPOUND_INTEREST_ON:new lr(vn,wn),INTEREST_ON:new lr(kp,Mp),DAILY_REPAYMENT_ON:new W($t,365),MONTHLY_REPAYMENT_ON:new W($t,12),ANNUAL_REPAYMENT_ON:new W($t,1),TOTAL_REPAYMENT_ON:new W($t,0),DAILY_LOAN_INTEREST_ON:new W(Wt,365),MONTHLY_LOAN_INTEREST_ON:new W(Wt,12),ANNUAL_LOAN_INTEREST_ON:new W(Wt,1),TOTAL_LOAN_INTEREST_ON:new W(Wt,0),TAX_ON:new Le(Fp),TAX_OFF:new Le(bp),TAX_IN_PHRASE:new Le(Vp),SPLIT:new bt(Em),WHAT_IS:new ur("what-is"),WHAT_WAS:new ur("what-was"),VALUE_OF:new zt,SAVINGS_HOW_LONG:new Ft(zp),SAVINGS_HOW_MUCH:new Ht(Hp)},infixParselets:{AFTER:new mr(vn,wn),FOR_DURATION:new mr(vn,wn),INVESTED:new Bt(Up),IN_YEAR_DOLLARS:new Gt,SPLIT_WAYS:new Vt(Em)},normalizerRules:[lm(),cm(),dm()],pluginFunctions:{inflationFromYearToPresent:am,inflationToYearFromPresent:sm,inflationFutureValue:mm}};function Gp(r){return (e,o)=>chunk6U66HQKQ_cjs.P(`${r.toUpperCase()}_QUERY_FAILED`,`Failed to resolve "${e}": ${o instanceof Error?o.message:String(o)}`)}function de(r){let e=r.staleTimeMs??3e5,o=r.timeoutMs??1e4,t=r.failureCooldownMs??3e4,n=r.onError??Gp(r.namespace),i=u=>[r.namespace,u];async function a(u,c,f){let{signal:T,cleanup:N}=chunkTLG7VZRX_cjs.a(c,o,`${r.namespace} query`);try{return await r.fetchQuery(u,T)}catch(E){let _=n(u,E);return setTimeout(()=>{f.getQueryData(i(u))===_&&f.removeQueries({queryKey:i(u),exact:true});},t).unref?.(),_}finally{N();}}return {resolver:{namespace:r.namespace,preflight(u,c,f,T,N){let{opcodes:E,strings:_}=c,R=E.length,O=0;for(;O<R;){if(E[O]===50&&O+2<R){let P=E[O+1],S=E[O+2];if(P===r.pluginFunctionIndex&&S>=1&&O>=2&&E[O-2]===13){let v=_[E[O-1]],j=i(v);if(N.getQueryData(j)===void 0){let ze=N.fetchQuery({queryKey:j,queryFn:({signal:Uo})=>a(v,Uo,N),staleTime:e}),me={queryKey:j.join(":"),resolver:ze,packageId:f,signal:T,metadata:{query:v}};return r.refetchIntervalMs!==void 0&&(me.refetchIntervalMs=r.refetchIntervalMs,me.refetch=()=>N.fetchQuery({queryKey:j,queryFn:({signal:Uo})=>a(v,Uo,N),staleTime:0})),me}}O+=3;continue}O=chunkW5ELYJ4Z_cjs.a(E,O);}return null},destroy(){}},pluginFunction:u=>{let c=u[0]?.value,f=chunkZLRJ7TDP_cjs.b()?.getQueryData(i(c));return f!==void 0?f:chunk6U66HQKQ_cjs.P(`${r.namespace.toUpperCase()}_NOT_PREFLIGHTED`,`No cached result for "${c}"`)}}}function Kp(r,e){let o=[];for(;r.peek()?.type==="IDENT";)o.push(r.consume().value);if(o.length===0)throw chunkNAZ6PGLS_cjs.c.parsing("WEATHER_EXPECTED_CITY",`Expected a city name after "${e}" (e.g. "${e} London")`);return o.join(" ")}function ve(r,e){return {category:"Weather",parse(o,t,n){let i=Kp(o,t.value);n.emitOpcode(13),n.emitString(`${r}:${i}`),n.emitPluginCall(e,1);}}}var $p={0:"clear sky",1:"mainly clear",2:"partly cloudy",3:"overcast",45:"fog",48:"depositing rime fog",51:"light drizzle",53:"moderate drizzle",55:"dense drizzle",56:"light freezing drizzle",57:"dense freezing drizzle",61:"slight rain",63:"moderate rain",65:"heavy rain",66:"light freezing rain",67:"heavy freezing rain",71:"slight snow fall",73:"moderate snow fall",75:"heavy snow fall",77:"snow grains",80:"slight rain showers",81:"moderate rain showers",82:"violent rain showers",85:"slight snow showers",86:"heavy snow showers",95:"thunderstorm",96:"thunderstorm with slight hail",99:"thunderstorm with heavy hail"};function Tm(r){return $p[r]??`weather code ${r}`}var we={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"},Wp="https://geocoding-api.open-meteo.com/v1/search",Yp="https://api.open-meteo.com/v1/forecast",jp=1e4;async function Xp(r,e){let o=`${Wp}?name=${encodeURIComponent(r)}&count=1&language=en&format=json`,t=await fetch(o,{signal:e});if(!t.ok)throw chunkNAZ6PGLS_cjs.c.external(we.GEOCODING_API_ERROR,`Open-Meteo geocoding API returned ${t.status} for "${r}"`,{city:r,status:t.status});let i=(await t.json())?.results?.[0];if(!i)throw chunkNAZ6PGLS_cjs.c.validation(we.CITY_NOT_FOUND,`No location found for "${r}"`,{city:r});return {latitude:i.latitude,longitude:i.longitude,name:i.name}}async function Qp(r,e,o){let t=new URLSearchParams({latitude:String(r),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(`${Yp}?${t.toString()}`,{signal:o});if(!n.ok)throw chunkNAZ6PGLS_cjs.c.external(we.FORECAST_API_ERROR,`Open-Meteo forecast API returned ${n.status}`,{status:n.status});let i=await n.json(),a=i?.current,s=i?.daily;if(!a||!s)throw chunkNAZ6PGLS_cjs.c.external(we.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 Yt=new Map,qp=6e4;function Nm(r,e){let o=r.trim().toLowerCase(),t=Date.now(),n=Yt.get(o);if(n&&n.expiresAt>t)return n.promise;let{signal:i,cleanup:a}=chunkTLG7VZRX_cjs.a(e,jp,"Open-Meteo weather query"),s=(async()=>{try{let l=await Xp(r,i),u=await Qp(l.latitude,l.longitude,i);return {resolvedName:l.name,weatherCode:u.weatherCode,description:Tm(u.weatherCode),temperature:u.temperature,apparentTemperature:u.apparentTemperature,high:u.high,low:u.low}}finally{a();}})();return Yt.set(o,{promise:s,expiresAt:t+qp}),s.catch(()=>{Yt.get(o)?.promise===s&&Yt.delete(o);}),s}var ym="solve-weather",Ee="weather",Zp=chunkEEVUKZ5B_cjs.F(`${ym}:${Ee}`),{resolver:Jp,pluginFunction:ef}=de({namespace:"weather",pluginFunctionIndex:Zp,staleTimeMs:600*1e3,fetchQuery:async(r,e)=>{let o=r.indexOf(":"),t=o===-1?r:r.slice(0,o),n=o===-1?"":r.slice(o+1),i=await Nm(n,e);switch(t){case "current":return chunk6U66HQKQ_cjs.t(`${Math.round(i.temperature)}\xB0C, ${i.description}`);case "temperature":return chunk6U66HQKQ_cjs.u(i.temperature,"C");case "feelslike":return chunk6U66HQKQ_cjs.u(i.apparentTemperature,"C");case "high":return chunk6U66HQKQ_cjs.u(i.high,"C");case "low":return chunk6U66HQKQ_cjs.u(i.low,"C");default:throw chunkNAZ6PGLS_cjs.c.internal(we.UNKNOWN_QUERY_KIND,`Unknown weather query kind "${t}"`,{kind:t})}}}),Mn={name:ym,phrases:{"weather in":"WEATHER_IN","temperature in":"TEMPERATURE_IN","feels like in":"FEELS_LIKE_IN","high in":"HIGH_IN","low in":"LOW_IN"},prefixParselets:{WEATHER_IN:ve("current",Ee),TEMPERATURE_IN:ve("temperature",Ee),FEELS_LIKE_IN:ve("feelslike",Ee),HIGH_IN:ve("high",Ee),LOW_IN:ve("low",Ee)},pluginFunctions:{[Ee]:ef},asyncResolvers:[Jp]};var jt={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 Qt(r){return r<10?`0${r}`:String(r)}function pr(r,e,o,t){let n=new Date(r,e,o);if(n.getFullYear()!==r||n.getMonth()!==e||n.getDate()!==o)throw chunkNAZ6PGLS_cjs.c.parsing("STOCKS_INVALID_DATE",`"${t}" is not a valid calendar date`);return {isoDate:`${r}-${Qt(e+1)}-${Qt(o)}`,raw:t}}function Xt(r,e){if(!/^\d{4}$/.test(r))throw chunkNAZ6PGLS_cjs.c.parsing("STOCKS_INVALID_DATE",`Expected a 4-digit year in "${e}", got "${r}"`);return parseInt(r,10)}function gm(r){let e=r.peek();if(!e)return null;if(e.type==="DATETIME_LITERAL"){r.consume();let o=new Date(Number(e.value));return Number.isNaN(o.getTime())?null:{isoDate:`${o.getFullYear()}-${Qt(o.getMonth()+1)}-${Qt(o.getDate())}`,raw:e.text??e.value}}if(e.type==="NUMBER"){let o=r.consume(),t=r.peek();if(t&&(t.type==="SLASH"||t.type==="MINUS")){let i=t.type;r.consume();let a=r.consume("NUMBER");r.consume(i);let s=r.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=Xt(s.value,l);return pr(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 pr(T,N-1,E,l)}let u=parseInt(o.value,10),c=parseInt(a.value,10),f=Xt(s.value,l);return pr(f,u-1,c,l)}}let n=r.peek();if(n&&n.type==="IDENT"&&jt[n.value.toLowerCase()]!==void 0){let i=jt[n.value.toLowerCase()];r.consume(),r.peek()?.type==="COMMA"&&r.consume();let a=r.consume("NUMBER"),s=`${o.value} ${n.value} ${a.value}`,l=Xt(a.value,s);return pr(l,i,parseInt(o.value,10),s)}throw chunkNAZ6PGLS_cjs.c.parsing("STOCKS_INVALID_DATE",`Expected a date after "on" (e.g. "April 12, 2005" or "4/12/2005"), got "${o.value}"`)}if(e.type==="IDENT"&&jt[e.value.toLowerCase()]!==void 0){let o=jt[e.value.toLowerCase()];r.consume();let t=r.consume("NUMBER");r.peek()?.type==="COMMA"&&r.consume();let n=r.consume("NUMBER"),i=`${e.value} ${t.value}, ${n.value}`,a=Xt(n.value,i);return pr(a,o,parseInt(t.value,10),i)}return null}var Pm=new Set(["AAPL","MSFT","GOOGL","GOOG","AMZN","META","NVDA","TSLA","NFLX","ADBE","CRM","ORCL","IBM","INTC","AMD","CSCO","PYPL","UBER","ABNB","SPOT","SHOP","SQ","COIN","PLTR","SNOW","ZM","JPM","V","MA","BAC","WFC","GS","MS","AXP","WMT","COST","HD","NKE","SBUX","MCD","KO","PEP","DIS","TGT","BA","GE","F","GM","XOM","CVX","PFE","JNJ","UNH","MRNA","TSM","ASML","BABA"]);var ke="STOCK_TICKER",rf=chunk5IJD5L3O_cjs.c(ke);function _m(){return {name:"stocks:bare-ticker",priority:20,startTokenTypes:["IDENT"],match(r,e){let o=r[e];return !o||o.type!=="IDENT"||!Pm.has(o.value)||e>0&&r[e-1].type==="COLON"?null:{consumed:1,replacement:[new chunkFAGFPVYK_cjs.a(ke,rf,o.value,o.value,o.offset,0,o.line,o.col)],ruleName:"stocks:bare-ticker"}}}}function tf(r){let e=r.peek();if(!e||e.type!=="IDENT")return null;let o=e.value.toLowerCase(),t="close";if(o==="close"||o==="volume"){t=o,r.consume();let i=r.peek();if(!i||i.type!=="IDENT"||i.value.toLowerCase()!=="on")throw chunkNAZ6PGLS_cjs.c.parsing("STOCKS_EXPECTED_ON",`Expected "on <date>" after "${o}" (e.g. "AAPL ${o} on April 12, 2005")`);r.consume();}else if(o==="on")r.consume();else return null;let n=gm(r);if(!n)throw chunkNAZ6PGLS_cjs.c.parsing("STOCKS_EXPECTED_DATE",'Expected a date after "on" (e.g. "April 12, 2005" or "4/12/2005")');return {field:t,date:n}}function Am(r,e,o,t,n){r.emitOpcode(13),o?(r.emitString(`${o.field}:${e}:${o.date.isoDate}`),r.emitPluginCall(n,1)):(r.emitString(e),r.emitPluginCall(t,1));}function xm(r,e,o,t,n){let i=false;r.peek()?.type==="STAR"&&(r.consume(),i=true);let a=tf(r);if(i&&!a){Am(e,o,null,t,n),r.parseExpression(chunkFVQWN5HZ_cjs.a.Product,e),e.emitOpcode(22);return}Am(e,o,a,t,n);}function Rm(r,e){return {category:"Stocks",parse(o,t,n){o.consume("LPAREN");let i=o.consume(),a;if(i.type==="STRING")a=chunkUURM7P3P_cjs.a(i.value).toUpperCase();else if(i.type==="IDENT"||i.type===ke)a=i.value.toUpperCase();else throw chunkNAZ6PGLS_cjs.c.parsing("STOCKS_INVALID_TICKER",`Expected a ticker symbol inside stock(...), got "${i.value}" (${i.type})`);o.consume("RPAREN"),xm(o,n,a,r,e);}}}function Om(r,e){return {category:"Stocks",parse(o,t,n){let i=t.value.toUpperCase();xm(o,n,i,r,e);}}}var Bn="solve-stocks",qt="stock",Zt="stockhistorical";function Cm(r={}){function e(s){return chunk6U66HQKQ_cjs.P("STOCKS_NOT_CONFIGURED",`Stock data provider not configured. Supply ${s} via createStocksPackage({ ... }); see the StocksPackage doc comment.`)}let{resolver:o,pluginFunction:t}=de({namespace:"stocks-current",pluginFunctionIndex:chunkEEVUKZ5B_cjs.F(`${Bn}:${qt}`),staleTimeMs:r.staleTimeMs??6e4,refetchIntervalMs:r.refetchIntervalMs,fetchQuery:async(s,l)=>{if(!r.fetchQuote)return e("fetchQuote");let u=await r.fetchQuote(s,l);return chunk6U66HQKQ_cjs.u(u.price,u.currency??"USD")}}),{resolver:n,pluginFunction:i}=de({namespace:"stocks-historical",pluginFunctionIndex:chunkEEVUKZ5B_cjs.F(`${Bn}:${Zt}`),staleTimeMs:r.historicalStaleTimeMs??720*60*60*1e3,fetchQuery:async(s,l)=>{let[u,c,f]=s.split(":");if(!r.fetchHistoricalQuote)return e("fetchHistoricalQuote");let T=await r.fetchHistoricalQuote(c,f,l);return u==="volume"?chunk6U66HQKQ_cjs.n(T.volume??0):chunk6U66HQKQ_cjs.u(T.close,T.currency??"USD")}});return {name:Bn,lexerVocabulary:{keywords:{stock:"STOCK_FN"}},prefixParselets:{STOCK_FN:Rm(qt,Zt),...r.enableBareTickerRecognition?{[ke]:Om(qt,Zt)}:{}},normalizerRules:r.enableBareTickerRecognition?[_m()]:[],pluginFunctions:{[qt]:t,[Zt]:i},asyncResolvers:[o,n]}}function Im(r){return {category:"Knowledge",parse(e,o,t){t.emitOpcode(13),t.emitString(o.value),t.emitPluginCall(r,1);}}}function hm(r={}){let e="solve-knowledge",o="knowledge",t=chunkEEVUKZ5B_cjs.F(`${e}:${o}`),{resolver:n,pluginFunction:i}=de({namespace:"knowledge",pluginFunctionIndex:t,staleTimeMs:r.staleTimeMs??300*1e3,fetchQuery:async(a,s)=>{if(!r.answerQuery)return chunk6U66HQKQ_cjs.P("KNOWLEDGE_NOT_CONFIGURED","Knowledge answer provider not configured. Supply answerQuery via createKnowledgePackage({ ... }); see the KnowledgePackage doc comment.");let l=await r.answerQuery(a,s);return chunk6U66HQKQ_cjs.t(l)}});return {name:e,lexerVocabulary:{rawLinePatterns:[{pattern:/^(?:search|ask|google)\s*:\s*(.+)$/i,tokenType:"KNOWLEDGE_QUERY"},{pattern:/^(.+?)=\s*\?\s*$/,tokenType:"KNOWLEDGE_QUERY"}]},prefixParselets:{KNOWLEDGE_QUERY:Im(o)},pluginFunctions:{[o]:i},asyncResolvers:[n]}}var Jt=class{constructor(){this.category="Lines";}parse(e,o,t){t.emitPluginCall("prev",0);}};var eo=class{constructor(){this.category="Lines";}parse(e,o,t){let n=parseInt(o.value,10);t.emitOpcode(10),t.emitNumber(n),t.emitPluginCall("lineRef",1);}};var fr=class{constructor(e){this.isAverage=e;this.category="Lines";}parse(e,o,t){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);t.emitOpcode(10),t.emitNumber(a),t.emitOpcode(10),t.emitNumber(s),t.emitPluginCall(this.isAverage?"averageRange":"sumRange",2);}};var Me=class{constructor(e){this.isAverage=e;this.category="Lines";}parse(e,o,t){t.emitPluginCall(this.isAverage?"averageAbove":"totalAbove",0);}};var of=chunk5IJD5L3O_cjs.c("LINE_REF"),nf=chunk5IJD5L3O_cjs.c("SUM_RANGE_CALL"),af=chunk5IJD5L3O_cjs.c("AVERAGE_RANGE_CALL");function Lm(){return {name:"lines:line-ref",priority:80,match(r,e){if(e>0&&r[e-1].type==="COLON"&&!(e>1&&r[e-2].type==="LINE_REF"))return null;let o=r[e];if(!o)return null;if(o.type==="IDENT"){let t=/^line(\d+)$/i.exec(o.value);if(t)return {consumed:1,replacement:[Sm(t[1],o)],ruleName:"lines:line-ref"}}if(o.type==="IDENT"&&/^line$/i.test(o.value)){let t=r[e+1];if(t&&t.type==="NUMBER"&&/^\d+$/.test(t.value))return {consumed:2,replacement:[Sm(t.value,o)],ruleName:"lines:line-ref"}}return null}}}function Sm(r,e){return new chunkFAGFPVYK_cjs.a("LINE_REF",of,r,r,e.offset,0,e.line,e.col)}function vm(){return {name:"lines:range-call",priority:80,match(r,e){let o=r[e];if(!o||o.type!=="IDENT")return null;let t=o.value.toLowerCase();if(t!=="sum"&&t!=="total"&&t!=="average"||r[e+1]?.type!=="LPAREN")return null;let n=t==="average"?"AVERAGE_RANGE_CALL":"SUM_RANGE_CALL",i=t==="average"?af:nf;return {consumed:1,replacement:[new chunkFAGFPVYK_cjs.a(n,i,o.value,o.value,o.offset,0,o.line,o.col)],ruleName:"lines:range-call"}}}}function ro(r,e){return r===void 0?chunk6U66HQKQ_cjs.P("LINE_NOT_YET_EVALUATED",`Line ${e} has not been evaluated yet (forward reference, or out of range)`):r.type===12?chunk6U66HQKQ_cjs.P("LINE_RESULT_PENDING",`Line ${e}'s result is still resolving`):r.type===13?chunk6U66HQKQ_cjs.P("LINE_RESULT_ERROR",`Line ${e} has an error`):null}function Be(r){return r?.getLineResult?null:chunk6U66HQKQ_cjs.P("LINE_REF_NO_DOCUMENT","Cross-line references require a real document \u2014 not available outside one (e.g. evaluateExpression()'s single-expression path)")}function wm(r,e){let o=Be(e);if(o)return o;let t=e.lineIndex-1,n=e.getLineResult(t);return ro(n,t)??n}function km(r,e){let o=Be(e);if(o)return o;let t=r[0].toNumber(),n=e.getLineResult(t);return ro(n,t)??n}function Mm(r,e,o,t){let n=0,i=0,a,s=false,l=r<=e?1:-1;for(let c=r;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 chunk6U66HQKQ_cjs.P("LINE_RANGE_NON_NUMERIC",`Line ${c} is not a plain number or unit value \u2014 cannot include it in a sum/total/average range`);if(f.type===6){if(s=true,a===void 0)a=f.unit;else if(f.unit!==a)return chunk6U66HQKQ_cjs.P("LINE_RANGE_MIXED_UNITS",`Line ${c}'s unit (${f.unit}) doesn't match the range's first unit (${a}) \u2014 aggregating mixed units would silently misrepresent the result`)}n+=f.toNumber(),i++;}let u=t?n/i:n;return s?chunk6U66HQKQ_cjs.u(u,a):chunk6U66HQKQ_cjs.n(u)}function Bm(r,e){let o=Be(e);return o||Mm(r[0].toNumber(),r[1].toNumber(),e,false)}function Um(r,e){let o=Be(e);return o||Mm(r[0].toNumber(),r[1].toNumber(),e,true)}function Dm(r,e){let o=r.isLineBoundary;if(!o)return chunk6U66HQKQ_cjs.P("LINE_REF_NO_DOCUMENT",'"above" aggregation requires a real document');let t=0,n=0,i,a=false;for(let l=r.lineIndex-1;l>=1&&!o(l);l--){let u=r.getLineResult(l),c=ro(u,l);if(c)return c;if(u.type!==0&&u.type!==6)return chunk6U66HQKQ_cjs.P("LINE_RANGE_NON_NUMERIC",`Line ${l} is not a plain number or unit value \u2014 cannot include it in "above" aggregation`);if(u.type===6){if(a=true,i===void 0)i=u.unit;else if(u.unit!==i)return chunk6U66HQKQ_cjs.P("LINE_RANGE_MIXED_UNITS",`Line ${l}'s unit (${u.unit}) doesn't match the range's unit (${i})`)}t+=u.toNumber(),n++;}if(n===0)return chunk6U66HQKQ_cjs.P("LINE_RANGE_EMPTY","No lines above to aggregate (hit the top of the document, a blank line, or a heading immediately)");let s=e?t/n:t;return a?chunk6U66HQKQ_cjs.u(s,i):chunk6U66HQKQ_cjs.n(s)}function bm(r,e){let o=Be(e);return o||Dm(e,false)}function Vm(r,e){let o=Be(e);return o||Dm(e,true)}var Un={name:"solve-lines",lexerVocabulary:{keywords:{prev:"PREV"}},phrases:{"total above":"TOTAL_ABOVE","sum above":"SUM_ABOVE","average above":"AVERAGE_ABOVE"},normalizerRules:[Lm(),vm()],prefixParselets:{PREV:new Jt,LINE_REF:new eo,SUM_RANGE_CALL:new fr(false),AVERAGE_RANGE_CALL:new fr(true),TOTAL_ABOVE:new Me(false),SUM_ABOVE:new Me(false),AVERAGE_ABOVE:new Me(true)},pluginFunctions:{prev:wm,lineRef:km,sumRange:Bm,averageRange:Um,totalAbove:bm,averageAbove:Vm}};var b=class{constructor(e){this.pluginFnName=e;this.category="Tables";}parse(e,o,t){let n=e.peek();if(!n||n.type!=="STRING")throw chunkNAZ6PGLS_cjs.c.parsing("TABLE_COLUMN_NAME_EXPECTED",`Expected a quoted column name after "... of column" but got ${n?`"${n.value}"`:"end of input"}`);let i=e.consume("STRING");for(;;){let a=e.peek();if(!a)break;if(a.type==="IN"){e.consume();continue}if(a.type==="IDENT"&&sf.has(a.value.toLowerCase())){e.consume();continue}break}t.emitOpcode(13),t.emitString(i.value),t.emitPluginCall(this.pluginFnName,1);}},sf=new Set(["the","table","above"]);function Fm(r){return r.trimStart().startsWith("|")}function mf(r){let e=r.trim();return e.length===0||!e.includes("-")||!e.includes("|")?false:/^[|\s:-]+$/.test(e)}function Hm(r){let e=r.trim();e.startsWith("|")&&(e=e.slice(1)),e.endsWith("|")&&!e.endsWith("\\|")&&(e=e.slice(0,-1));let o=[],t="";for(let n=0;n<e.length;n++){let i=e[n];if(i==="\\"&&n+1<e.length&&e[n+1]==="|"){t+="|",n++;continue}if(i==="|"){o.push(t.trim()),t="";continue}t+=i;}return o.push(t.trim()),o}function lf(r){if(r===void 0)return null;let e=r.trim();if(e.length===0)return null;let o=e.replace(/,/g,"");if(!/^[+-]?(\d+(\.\d+)?|\.\d+)$/.test(o))return null;let t=Number.parseFloat(o);return Number.isFinite(t)?t:null}function zm(r,e){let o=-1;for(let s=e-1;s>=1;s--){let l=r(s);if(l===void 0)break;if(Fm(l)){o=s;break}}if(o===-1)return null;let t=o;for(;t-1>=1;){let s=r(t-1);if(s===void 0||!Fm(s))break;t--;}let n=-1;for(let s=t;s<=o;s++)if(mf(r(s))){n=s;break}if(n===-1||n===t)return null;let i=Hm(r(n-1)),a=[];for(let s=n+1;s<=o;s++)a.push(Hm(r(s)));return {header:i,rows:a}}function Gm(r,e){let o=e.trim().toLowerCase();for(let t=0;t<r.length;t++)if(r[t].trim().toLowerCase()===o)return t;return -1}function Km(r,e){let o=[];for(let t of r.rows){let n=lf(t[e]);n!==null&&o.push(n);}return o}var to={TABLE_NO_DOCUMENT:"TABLE_NO_DOCUMENT",TABLE_NOT_FOUND:"TABLE_NOT_FOUND",TABLE_COLUMN_NOT_FOUND:"TABLE_COLUMN_NOT_FOUND",TABLE_COLUMN_NO_NUMERIC_CELLS:"TABLE_COLUMN_NO_NUMERIC_CELLS"};function oo(r,e){let o=r.length;if(o===0)return 0;let t=e?o-1:o;if(t<=0)return 0;let n=r.reduce((i,a)=>i+a,0)/o;return r.reduce((i,a)=>i+(a-n)*(a-n),0)/t}function uf(r,e){switch(r){case "sum":return e.reduce((o,t)=>o+t,0);case "average":return e.reduce((o,t)=>o+t,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),t=Math.floor(o.length/2);return o.length%2===0?(o[t-1]+o[t])/2:o[t]}case "stdev":return Math.sqrt(oo(e,false));case "sampleStdev":return Math.sqrt(oo(e,true));case "variance":return oo(e,false);case "sampleVariance":return oo(e,true);case "spread":return Math.max(...e)-Math.min(...e);case "mode":{let o=new Map,t=e[0],n=0;for(let i of e){let a=(o.get(i)??0)+1;o.set(i,a),a>n&&(n=a,t=i);}return t}}}function G(r,e,o){let t=o?.getLineText;if(!t||o.lineIndex<1)return chunk6U66HQKQ_cjs.P(to.TABLE_NO_DOCUMENT,"Reading a table column needs a real document, which the single-expression path (evaluateExpression) does not have");let n=zm(t,o.lineIndex);if(!n)return chunk6U66HQKQ_cjs.P(to.TABLE_NOT_FOUND,'No markdown table found above this line (a table row starts with "|", and needs a "|---|" separator under its header)');let i=Gm(n.header,e);if(i===-1){let s=n.header.map(l=>`"${l}"`).join(", ");return chunk6U66HQKQ_cjs.P(to.TABLE_COLUMN_NOT_FOUND,`The table above has no column named "${e}". Its columns are: ${s}`)}let a=Km(n,i);return r==="count"?chunk6U66HQKQ_cjs.n(a.length):a.length===0?chunk6U66HQKQ_cjs.P(to.TABLE_COLUMN_NO_NUMERIC_CELLS,`Column "${e}" has no plain-number cells to aggregate (currency and unit cells are not read yet)`):chunk6U66HQKQ_cjs.n(uf(r,a))}function K(r){let e=r[0];return e&&e.type===3&&typeof e.value=="string"?e.value:String(e?.value??"")}function $m(r,e){return G("sum",K(r),e)}function Wm(r,e){return G("average",K(r),e)}function Ym(r,e){return G("min",K(r),e)}function jm(r,e){return G("max",K(r),e)}function Xm(r,e){return G("count",K(r),e)}function Qm(r,e){return G("median",K(r),e)}function qm(r,e){return G("stdev",K(r),e)}function Zm(r,e){return G("sampleStdev",K(r),e)}function Jm(r,e){return G("variance",K(r),e)}function el(r,e){return G("sampleVariance",K(r),e)}function rl(r,e){return G("spread",K(r),e)}function tl(r,e){return G("mode",K(r),e)}var Dn={name:"solve-tables",phrases:{"sum of column":"TABLE_COLUMN_SUM","total of column":"TABLE_COLUMN_SUM","average of column":"TABLE_COLUMN_AVERAGE","mean of column":"TABLE_COLUMN_AVERAGE","min of column":"TABLE_COLUMN_MIN","minimum of column":"TABLE_COLUMN_MIN","max of column":"TABLE_COLUMN_MAX","maximum of column":"TABLE_COLUMN_MAX","count of column":"TABLE_COLUMN_COUNT","median of column":"TABLE_COLUMN_MEDIAN","standard deviation of column":"TABLE_COLUMN_STDEV","stdev of column":"TABLE_COLUMN_STDEV","sample standard deviation of column":"TABLE_COLUMN_SAMPLE_STDEV","variance of column":"TABLE_COLUMN_VARIANCE","sample variance of column":"TABLE_COLUMN_SAMPLE_VARIANCE","spread of column":"TABLE_COLUMN_SPREAD","mode of column":"TABLE_COLUMN_MODE"},prefixParselets:{TABLE_COLUMN_SUM:new b("TABLE_COLUMN_SUM"),TABLE_COLUMN_AVERAGE:new b("TABLE_COLUMN_AVERAGE"),TABLE_COLUMN_MIN:new b("TABLE_COLUMN_MIN"),TABLE_COLUMN_MAX:new b("TABLE_COLUMN_MAX"),TABLE_COLUMN_COUNT:new b("TABLE_COLUMN_COUNT"),TABLE_COLUMN_MEDIAN:new b("TABLE_COLUMN_MEDIAN"),TABLE_COLUMN_STDEV:new b("TABLE_COLUMN_STDEV"),TABLE_COLUMN_SAMPLE_STDEV:new b("TABLE_COLUMN_SAMPLE_STDEV"),TABLE_COLUMN_VARIANCE:new b("TABLE_COLUMN_VARIANCE"),TABLE_COLUMN_SAMPLE_VARIANCE:new b("TABLE_COLUMN_SAMPLE_VARIANCE"),TABLE_COLUMN_SPREAD:new b("TABLE_COLUMN_SPREAD"),TABLE_COLUMN_MODE:new b("TABLE_COLUMN_MODE")},pluginFunctions:{TABLE_COLUMN_SUM:$m,TABLE_COLUMN_AVERAGE:Wm,TABLE_COLUMN_MIN:Ym,TABLE_COLUMN_MAX:jm,TABLE_COLUMN_COUNT:Xm,TABLE_COLUMN_MEDIAN:Qm,TABLE_COLUMN_STDEV:qm,TABLE_COLUMN_SAMPLE_STDEV:Zm,TABLE_COLUMN_VARIANCE:Jm,TABLE_COLUMN_SAMPLE_VARIANCE:el,TABLE_COLUMN_SPREAD:rl,TABLE_COLUMN_MODE:tl}};var Ue=class{constructor(e){this.pluginFnName=e;this.category="Tags";}parse(e,o,t){t.emitOpcode(13),t.emitString(o.value),t.emitPluginCall(this.pluginFnName,1);}};function no(r){return r===void 0?"":(r.text??r.value??"").toLowerCase()}var ol={TOTAL_OF:"TAG_SUM",COUNT_OF:"TAG_COUNT",AVERAGE_OF:"TAG_AVERAGE"},cf=new Set(["total","sum","count","average"]);function nl(r=80){return {name:"tags:aggregate",priority:r,match(e,o){let t=e[o];if(t===void 0)return null;let n=ol[t.type];if(n!==void 0){let i=e[o+1];return i?.type!=="TAG"?null:{consumed:2,replacement:[chunkRC4M6HBX_cjs.b(n,i.value??"",[t,i])],ruleName:"tags:aggregate"}}if(t.type==="IDENT"&&no(t)==="sum"){let i=e[o+1],a=e[o+2];return no(i)!=="of"||a?.type!=="TAG"?null:{consumed:3,replacement:[chunkRC4M6HBX_cjs.b("TAG_SUM",a.value??"",[t,i,a])],ruleName:"tags:aggregate"}}return null}}}function il(r=40){return {name:"tags:strip",priority:r,match(e,o){if(e[o]?.type!=="TAG")return null;let t=e[o-1];return t!==void 0&&(ol[t.type]!==void 0||no(t)==="of"&&cf.has(no(e[o-2])))?null:{consumed:1,replacement:[],ruleName:"tags:strip"}}}}function pf(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function al(r,e){if(e==="")return false;let t=new RegExp(`(?:^|[^0-9A-Za-z_])#${pf(e)}(?![0-9A-Za-z_-])`,"i").exec(r);if(t===null)return false;let n=t.index+t[0].indexOf("#");return r.slice(0,n).trim().length>0}function ff(r,e){return r===void 0?chunk6U66HQKQ_cjs.P("LINE_NOT_YET_EVALUATED",`Line ${e} has not been evaluated yet`):r.type===12?chunk6U66HQKQ_cjs.P("LINE_RESULT_PENDING",`Line ${e}'s result is still resolving`):r.type===13?chunk6U66HQKQ_cjs.P("LINE_RESULT_ERROR",`Line ${e} has an error`):null}function bn(r){return !r?.getLineResult||!r.getLineText?chunk6U66HQKQ_cjs.P("TAG_NO_DOCUMENT","Category tag sums require a real document, not available outside one (e.g. evaluateExpression()'s single-expression path)"):null}function Vn(r,e,o){let t=r.getLineText,n=r.getLineResult,i=r.isLineBoundary,a=e.toLowerCase(),s=0,l=0,u,c=false;for(let T=1;;T++){let N=t(T);if(N===void 0)break;if(T===r.lineIndex||i&&i(T)||!al(N,a))continue;let E=n(T),_=ff(E,T);if(_)return _;if(o!=="count"){if(E.type!==0&&E.type!==6)return chunk6U66HQKQ_cjs.P("TAG_NON_NUMERIC",`Line ${T}, tagged #${e}, is not a plain number or unit value.`);if(E.type===6){if(c=true,u===void 0)u=E.unit;else if(E.unit!==u)return chunk6U66HQKQ_cjs.P("TAG_MIXED_UNITS",`Line ${T}'s unit (${E.unit}) doesn't match #${e}'s first unit (${u}), aggregating mixed units would misrepresent the result.`)}s+=E.toNumber();}l++;}if(o==="count")return chunk6U66HQKQ_cjs.n(l);if(l===0)return chunk6U66HQKQ_cjs.P("TAG_EMPTY",`No lines are tagged #${e}.`);let f=o==="average"?s/l:s;return c?chunk6U66HQKQ_cjs.u(f,u):chunk6U66HQKQ_cjs.n(f)}function sl(r,e){let o=bn(e);return o||Vn(e,String(r[0].value),"sum")}function ml(r,e){let o=bn(e);return o||Vn(e,String(r[0].value),"average")}function ll(r,e){let o=bn(e);return o||Vn(e,String(r[0].value),"count")}var Fn={name:"solve-tags",normalizerRules:[nl(),il()],prefixParselets:{TAG_SUM:new Ue("sum"),TAG_AVERAGE:new Ue("average"),TAG_COUNT:new Ue("count")},pluginFunctions:{sum:sl,average:ml,count:ll}};var io=class{constructor(){this.category="operator";this.bindingPower=chunkFVQWN5HZ_cjs.a.Uncertainty;}parse(e,o,t,n){e.parseExpression(this.bindingPower,n),n.emitOpcode(28);}};function ul(r=90){return {name:"uncertainty:ascii-plus-minus",priority:r,match(e,o){let t=e[o];if(t?.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:[chunkRC4M6HBX_cjs.b("PLUS_MINUS","\xB1",[t,n,i])],ruleName:"uncertainty:ascii-plus-minus"}}}}var Hn={name:"solve-uncertainty",infixParselets:{PLUS_MINUS:new io},normalizerRules:[ul()]};var cl=1e-9,pl=1e9,df=100,Ef=1e-9,Tf=1e-9,Nf=1e-12,yf=1e-9,ao="goalseek";function fl(r,e){let o=e?.evaluateLineWithBinding,t=e?.getLineReads;if(!o||!t)return chunk6U66HQKQ_cjs.P("GOAL_SEEK_NO_DOCUMENT","Goal seek only works inside a document, since it re-runs another line. The single-expression entry point has no document to solve against.");let n=r[0].toNumber(),i=typeof r[1].value=="string"?r[1].value:String(r[1].value),a=r[2];if(a.type!==0&&a.type!==6)return chunk6U66HQKQ_cjs.P("GOAL_SEEK_TARGET_NOT_NUMERIC",`Goal seek's target must be a number, as in "solve line ${n} for ${i} = 900".`);let s=a.toNumber();if(!Number.isFinite(s))return chunk6U66HQKQ_cjs.P("GOAL_SEEK_TARGET_NOT_NUMERIC","Goal seek's target is not a finite number.");let l=t(n);if(l===void 0)return chunk6U66HQKQ_cjs.P("GOAL_SEEK_LINE_NOT_READY",`Line ${n} has no evaluated expression to solve (forward reference, out of range, or not an expression).`);if(!l.includes(i))return chunk6U66HQKQ_cjs.P("GOAL_SEEK_VARIABLE_NOT_USED",`Line ${n} does not use ${i}, so changing ${i} cannot move its result toward ${s}.`);let u=o(n,i,chunk6U66HQKQ_cjs.K(chunk2XZCLDHJ_cjs.q(i)),true);if(u.type===9){let f=gf(u.value,s,i);if(f!==null)return chunk6U66HQKQ_cjs.n(f)}let c=e.goalSeekMaxIterations??df;return Pf(o,n,i,s,c)}function gf(r,e,o){let t=chunk2XZCLDHJ_cjs.p(chunk2XZCLDHJ_cjs.d(e)),n;try{n=chunkEEVUKZ5B_cjs.d(r,t,o);}catch{return null}if(n.kind!=="roots")return null;let i=[];for(let l of n.exact){let u=chunk2XZCLDHJ_cjs.Q(l);if(u.kind==="const"){let c=chunk2XZCLDHJ_cjs.e(u.value);Number.isFinite(c)&&i.push(c);}}for(let l of n.approximate)Math.abs(l.im)<=yf&&Number.isFinite(l.re)&&i.push(l.re);if(i.length===0)return null;let a=i.filter(l=>l>=cl&&l<=pl),s=a.length>0?a:i;return s.sort((l,u)=>Math.abs(l)-Math.abs(u)),s[0]}function Pf(r,e,o,t,n){let i=N=>{let E=r(e,o,chunk6U66HQKQ_cjs.n(N),false);if(E.type===13)return {error:E};if(E.type!==0&&E.type!==6)return {error:chunk6U66HQKQ_cjs.P("GOAL_SEEK_TARGET_NOT_NUMERIC",`Line ${e} did not produce a number when ${o} was set to ${N}, so goal seek cannot compare it to the target.`)};let _=E.toNumber();return Number.isFinite(_)?{value:_}:{error:chunk6U66HQKQ_cjs.P("GOAL_SEEK_NON_FINITE",`Line ${e}'s result is not finite when ${o} is ${N}.`)}},a=cl,s=pl,l=i(a);if("error"in l)return l.error;let u=i(s);if("error"in u)return u.error;let c=Math.max(Ef,Math.abs(t)*Tf),f=l.value-t,T=u.value-t;if(Math.abs(f)<=c)return chunk6U66HQKQ_cjs.n(a);if(Math.abs(T)<=c)return chunk6U66HQKQ_cjs.n(s);if(Math.sign(f)===Math.sign(T))return chunk6U66HQKQ_cjs.P("GOAL_SEEK_NO_SOLUTION",`No value of ${o} between ${a} and ${s} makes line ${e} equal ${t}: 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 R=_.value-t;if(Math.abs(R)<=c)return chunk6U66HQKQ_cjs.n(E);if(s-a<=Nf)return chunk6U66HQKQ_cjs.P("GOAL_SEEK_DID_NOT_CONVERGE",`Goal seek narrowed ${o} to a single point near ${E} without line ${e} reaching ${t}: the relationship jumps across the target rather than passing through it.`);Math.sign(R)===Math.sign(f)?(a=E,f=R):s=E;}return chunk6U66HQKQ_cjs.P("GOAL_SEEK_DID_NOT_CONVERGE",`Goal seek did not bring line ${e} within tolerance of ${t} by varying ${o} in ${n} steps.`)}var so=class{constructor(){this.category="GoalSeek";}parse(e,o,t){let n=e.peek();if(!n||n.type!=="LINE_REF")throw chunkNAZ6PGLS_cjs.c.parsing("GOAL_SEEK_SYNTAX",'Goal seek reads "solve line N for <var> = <target>", for example "solve line 4 for rate = 900".',{found:n?.type??"end of input"});e.consume();let i=parseInt(n.value,10),a=e.peek();if(!(!!a&&(a.type==="FOR_DURATION"||a.type==="IDENT"&&a.value.toLowerCase()==="for")))throw chunkNAZ6PGLS_cjs.c.parsing("GOAL_SEEK_SYNTAX",'Goal seek reads "solve line N for <var> = <target>". Expected "for" after the line reference.',{found:a?.type??"end of input"});e.consume();let l=e.peek();if(!l||l.type!=="IDENT"&&l.type!=="UNIT")throw chunkNAZ6PGLS_cjs.c.parsing("GOAL_SEEK_REQUIRES_VARIABLE_NAME",'Goal seek needs the name of the variable to vary here, as in "solve line 4 for rate = 900".',{found:l?.type??"end of input"});e.consume(),e.consume("EQUALS"),t.emitOpcode(10),t.emitNumber(i),t.emitOpcode(13),t.emitString(l.value),e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,t),t.emitPluginCall(ao,3);}};var _f=chunk5IJD5L3O_cjs.c("GOAL_SEEK");function dl(r=75){return {name:"goalseek:solve-line",priority:r,startTokenTypes:["IDENT"],match(e,o){if(o>0&&e[o-1].type==="COLON")return null;let t=e[o];return !t||t.type!=="IDENT"||t.value.toLowerCase()!=="solve"||e[o+1]?.type!=="LINE_REF"?null:{consumed:1,replacement:[new chunkFAGFPVYK_cjs.a("GOAL_SEEK",_f,t.value,t.value,t.offset,0,t.line,t.col)],ruleName:"goalseek:solve-line"}}}}var zn={name:"solve-goalseek",normalizerRules:[dl()],prefixParselets:{GOAL_SEEK:new so},pluginFunctions:{[ao]:fl}};var mo=class{constructor(){this.category="Colour";}parse(e,o,t){t.emitOpcode(13),t.emitString(o.value),t.emitPluginCall("colour",1);}};var Te={COLOUR_INVALID:"COLOUR_INVALID",COLOUR_EXPECTED_COLOUR:"COLOUR_EXPECTED_COLOUR",COLOUR_BAD_ARGUMENTS:"COLOUR_BAD_ARGUMENTS"};function M(r){return r&&r.type===14?r.value:null}function U(r){if(!r)return 0;let e=r.toNumber();return r.type===5?e:e>1?e/100:e}function q(r,e){return chunk6U66HQKQ_cjs.P(Te.COLOUR_BAD_ARGUMENTS,`${r}(...) expects ${e}`)}function Y(r){return chunk6U66HQKQ_cjs.P(Te.COLOUR_EXPECTED_COLOUR,`${r}(...) expects a colour as its first argument`)}function El(r){let e=r[0];if(!e||e.type!==3||typeof e.value!="string")return q("color",'a string, e.g. color("#ff0000") or color("red")');let o=chunk5TVI2UPZ_cjs.c(e.value);return o?chunk6U66HQKQ_cjs.G(o):chunk6U66HQKQ_cjs.P(Te.COLOUR_INVALID,`"${e.value}" is not a hex colour (#rgb, #rgba, #rrggbb, #rrggbbaa) or a CSS colour name`)}function Af(r){return r.length!==3?q("rgb","three numbers: rgb(red, green, blue)"):chunk6U66HQKQ_cjs.G({r:chunk5TVI2UPZ_cjs.a(r[0].toNumber()),g:chunk5TVI2UPZ_cjs.a(r[1].toNumber()),b:chunk5TVI2UPZ_cjs.a(r[2].toNumber()),a:1,format:"rgb"})}function xf(r){return r.length!==4?q("rgba","four numbers: rgba(red, green, blue, alpha)"):chunk6U66HQKQ_cjs.G({r:chunk5TVI2UPZ_cjs.a(r[0].toNumber()),g:chunk5TVI2UPZ_cjs.a(r[1].toNumber()),b:chunk5TVI2UPZ_cjs.a(r[2].toNumber()),a:chunk5TVI2UPZ_cjs.b(U(r[3])),format:"rgba"})}function Rf(r){if(r.length!==3)return q("hsl","three values: hsl(hue, saturation%, lightness%)");let{r:e,g:o,b:t}=chunk5TVI2UPZ_cjs.e(r[0].toNumber(),U(r[1]),U(r[2]));return chunk6U66HQKQ_cjs.G({r:e,g:o,b:t,a:1,format:"hsl"})}function Of(r){if(r.length!==4)return q("hsla","four values: hsla(hue, saturation%, lightness%, alpha)");let{r:e,g:o,b:t}=chunk5TVI2UPZ_cjs.e(r[0].toNumber(),U(r[1]),U(r[2]));return chunk6U66HQKQ_cjs.G({r:e,g:o,b:t,a:chunk5TVI2UPZ_cjs.b(U(r[3])),format:"hsla"})}function Ne(r,e){return o=>{let t=M(o[0]);return t?o.length<2?q(r,`a colour and an amount, e.g. ${r}(#3366cc, 20%)`):chunk6U66HQKQ_cjs.G(e(t,U(o[1]))):Y(r)}}var Cf=Ne("lighten",chunk5TVI2UPZ_cjs.j),If=Ne("darken",chunk5TVI2UPZ_cjs.k),hf=Ne("saturate",chunk5TVI2UPZ_cjs.l),Tl=Ne("desaturate",chunk5TVI2UPZ_cjs.m);function Gn(r){let e=M(r[0]);return e?r.length<2?q("rotate","a colour and a hue angle in degrees, e.g. rotate(#ff0000, 90)"):chunk6U66HQKQ_cjs.G(chunk5TVI2UPZ_cjs.n(e,r[1].toNumber())):Y("rotate")}function Sf(r){let e=M(r[0]);return e?chunk6U66HQKQ_cjs.G(chunk5TVI2UPZ_cjs.o(e)):Y("complement")}function Nl(r){let e=M(r[0]);return e?chunk6U66HQKQ_cjs.G(chunk5TVI2UPZ_cjs.p(e)):Y("grayscale")}function yl(r){let e=M(r[0]);return e?chunk6U66HQKQ_cjs.G(chunk5TVI2UPZ_cjs.q(e,r.length>1?U(r[1]):1)):Y("invert")}function Lf(r){let e=M(r[0]),o=M(r[1]);return !e||!o?chunk6U66HQKQ_cjs.P(Te.COLOUR_EXPECTED_COLOUR,"mix(...) expects two colours to blend"):chunk6U66HQKQ_cjs.G(chunk5TVI2UPZ_cjs.r(e,o,r.length>2?U(r[2]):.5))}function Kn(r){let e=M(r[0]);return e?r.length<2?chunk6U66HQKQ_cjs.n(e.a):chunk6U66HQKQ_cjs.G(chunk5TVI2UPZ_cjs.s(e,U(r[1]))):Y("alpha")}function vf(r){let e=M(r[0]),o=M(r[1]);return !e||!o?chunk6U66HQKQ_cjs.P(Te.COLOUR_EXPECTED_COLOUR,"contrast(...) expects two colours"):chunk6U66HQKQ_cjs.n(chunk5TVI2UPZ_cjs.i(e,o))}function wf(r){let e=M(r[0]);return e?chunk6U66HQKQ_cjs.n(chunk5TVI2UPZ_cjs.h(e)):Y("luminance")}function De(r,e){return o=>{let t=M(o[0]);return t?chunk6U66HQKQ_cjs.n(e(t)):Y(r)}}var kf=De("red",r=>r.r),Mf=De("green",r=>r.g),Bf=De("blue",r=>r.b),Uf=De("hue",r=>chunk5TVI2UPZ_cjs.d(r.r,r.g,r.b).h),Df=De("saturation",r=>chunk5TVI2UPZ_cjs.d(r.r,r.g,r.b).s*100),bf=De("lightness",r=>chunk5TVI2UPZ_cjs.d(r.r,r.g,r.b).l*100);function gl(r){if(r.length!==3)return q("hsv","three values: hsv(hue, saturation%, value%)");let{r:e,g:o,b:t}=chunk5TVI2UPZ_cjs.t(r[0].toNumber(),U(r[1]),U(r[2]));return chunk6U66HQKQ_cjs.G({r:e,g:o,b:t,a:1,format:"hex"})}function Vf(r){if(r.length!==4)return q("hsva","four values: hsva(hue, saturation%, value%, alpha)");let{r:e,g:o,b:t}=chunk5TVI2UPZ_cjs.t(r[0].toNumber(),U(r[1]),U(r[2]));return chunk6U66HQKQ_cjs.G({r:e,g:o,b:t,a:chunk5TVI2UPZ_cjs.b(U(r[3])),format:"hex"})}function Ff(r){if(r.length!==3)return q("hwb","three values: hwb(hue, whiteness%, blackness%)");let{r:e,g:o,b:t}=chunk5TVI2UPZ_cjs.u(r[0].toNumber(),U(r[1]),U(r[2]));return chunk6U66HQKQ_cjs.G({r:e,g:o,b:t,a:1,format:"hex"})}var Hf=Ne("tint",chunk5TVI2UPZ_cjs.v),zf=Ne("shade",chunk5TVI2UPZ_cjs.w),Gf=Ne("tone",chunk5TVI2UPZ_cjs.x);function Kf(r){let e=M(r[0]);return e?chunk6U66HQKQ_cjs.L(chunk5TVI2UPZ_cjs.y(e)):Y("isdark")}function $f(r){let e=M(r[0]);return e?chunk6U66HQKQ_cjs.L(!chunk5TVI2UPZ_cjs.y(e)):Y("islight")}function $n(r){let e=M(r[0]);return e?chunk6U66HQKQ_cjs.G(chunk5TVI2UPZ_cjs.z(e)):Y("readable")}function Wf(r){if(!r)return chunk5TVI2UPZ_cjs.A.aa;if(r.type===0)return r.toNumber();if(r.type===3){let e=r.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 Yf(r){let e=M(r[0]),o=M(r[1]);return !e||!o?chunk6U66HQKQ_cjs.P(Te.COLOUR_EXPECTED_COLOUR,"iscontrastcompliant(...) expects two colours"):chunk6U66HQKQ_cjs.L(chunk5TVI2UPZ_cjs.i(e,o)>=Wf(r[2]))}function Pl(r){let e=M(r[0]),o=M(r[1]);return !e||!o?chunk6U66HQKQ_cjs.P(Te.COLOUR_EXPECTED_COLOUR,"wcaglevel(...) expects two colours"):chunk6U66HQKQ_cjs.t(chunk5TVI2UPZ_cjs.B(e,o))}var ye={color:El,colour:El,rgb:Af,rgba:xf,hsl:Rf,hsla:Of,lighten:Cf,darken:If,saturate:hf,desaturate:Tl,desat:Tl,rotate:Gn,spin:Gn,adjusthue:Gn,complement:Sf,grayscale:Nl,greyscale:Nl,invert:yl,mix:Lf,alpha:Kn,opacity:Kn,fade:Kn,contrast:vf,luminance:wf,red:kf,green:Mf,blue:Bf,hue:Uf,saturation:Df,lightness:bf,hsv:gl,hsb:gl,hsva:Vf,hwb:Ff,tint:Hf,shade:zf,tone:Gf,negate:yl,isdark:Kf,islight:$f,readable:$n,contrastcolor:$n,contrastcolour:$n,iscontrastcompliant:Yf,wcaglevel:Pl,wcag:Pl};var lo=class{constructor(){this.category="Colour";}parse(e,o,t){let n=o.value.toLowerCase();if(ye[n]===void 0)throw chunkNAZ6PGLS_cjs.c.execution("UNKNOWN_COLOUR_FUNCTION",`Unknown colour function: ${n}`,{functionName:n});e.consume("LPAREN");let i=0;if(e.peek()?.type!=="RPAREN")for(e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,t),i++;e.match("COMMA");)e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,t),i++;e.consume("RPAREN"),t.emitPluginCall(n,i);}};var jf=new Set(Object.keys(ye));function _l(r=80){return {name:"colour:call",priority:r,startTokenTypes:["IDENT"],match(e,o){let t=e[o];if(!t||t.type!=="IDENT")return null;let n=t.value.toLowerCase();return !jf.has(n)||e[o+1]?.type!=="LPAREN"?null:{consumed:1,replacement:[new chunkFAGFPVYK_cjs.a("COLOUR_CALL",chunk5IJD5L3O_cjs.c("COLOUR_CALL"),t.value,t.value,t.offset,0,t.line,t.col)],ruleName:"colour:call"}}}}var uo=r=>e=>{if(e.type!==14)return e;let o=e.value;return chunk6U66HQKQ_cjs.G({r:o.r,g:o.g,b:o.b,a:o.a,format:r})},Xf=Object.keys(ye).map(r=>({label:r,category:"function",detail:"colour"})),Wn={name:"solve-colour",prefixParselets:{HEX_COLOUR:new mo,COLOUR_CALL:new lo},normalizerRules:[_l()],pluginFunctions:ye,asConverters:{rgb:uo("rgb"),rgba:uo("rgba"),hsl:uo("hsl"),hsla:uo("hsla")},completionItems:Xf};var Yn=32;function Qf(r){if(r.hasSymbolic||r.rows!==1&&r.cols!==1)return null;let e=[];for(let o of r.data){if(typeof o!="number"||!Number.isFinite(o))return null;e.push(o);}return e}function qf(r){let e=r.max-r.min+1,o=Math.min(e,Yn),t=[];for(let n=0;n<o;n++)t.push(r.min+Math.round(n*(e-1)/(o-1)));return t}function Zf(r,e){if(r.length<=e)return [...r];let o=[];for(let t=0;t<e;t++)o.push(r[Math.round(t*(r.length-1)/(e-1))]);return o}function Al(r){let e=null;if(r.type===7)e=Qf(r.value);else if(r.type===8){let a=r.value;e=a.max-a.min+1>=2?qf(a):null;}if(!e||e.length<2)return null;let o=Zf(e,Yn),t=Math.min(...e),n=Math.max(...e),i=e.length<=Yn?`[${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:[t,n]}}var co=class{constructor(){this.category="Plot";}parse(e,o,t){let n=Jf(e),i=new chunkFVQWN5HZ_cjs.d(t.pluginIndexMap);e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,i),e.setBuilder(t);let a=i.build();if(a.hasAsync)throw chunkNAZ6PGLS_cjs.c.parsing("PLOT_EXPR_MUST_BE_SYNCHRONOUS","a plot expression must be synchronous (no weather, stocks or currency calls).");e.consume("FROM"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,t),e.consume("TO"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,t);let s=t.emitAnonymousBody(["x"],a);t.emitOpcode(160),t.emitIndex(s),t.emitString(n);}};function Jf(r){let e=[];for(let n=0;;n++){let i=r.peekAt(n);if(!i||i.type==="FROM")break;e.push(i);}if(e.length===0)return "";let o=e[0].offset,t="";for(let n of e){let i=n.offset-o;for(;t.length<i;)t+=" ";t+=n.text??n.value??"";}return t.trim()}var xl="PLOT",ed=chunk5IJD5L3O_cjs.c(xl),rd=new Set(["NUMBER","IDENT","FUNC","UNIT","LPAREN","PI","E"]);function Rl(r=80){let e="plot:plot-clause";return {name:e,priority:r,startTokenTypes:["IDENT"],match(o,t){let n=o[t];if(!n||n.type!=="IDENT"||(n.value??"").toLowerCase()!=="plot"||o[t-1]?.type==="COLON")return null;let i=o[t+1];return !i||!rd.has(i.type)?null:{consumed:1,replacement:[new chunkFAGFPVYK_cjs.a(xl,ed,n.value,n.value,n.offset,0,n.line,n.col)],ruleName:e}}}}var jn={name:"solve-chart",asConverters:{sparkline:r=>{let e=Al(r);return e?chunk6U66HQKQ_cjs.I(e):chunk6U66HQKQ_cjs.P("SPARKLINE_NOT_A_SERIES",'"as sparkline" expects a numeric vector or a range, with at least two values')}},prefixParselets:{PLOT:new co},normalizerRules:[Rl()],tokenCategories:{PLOT:"keyword"}};var dr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function Xn(r){let e=new TextEncoder().encode(r),o="";for(let t=0;t<e.length;t+=3){let n=e[t],i=t+1<e.length?e[t+1]:0,a=t+2<e.length?e[t+2]:0;o+=dr[n>>2],o+=dr[(n&3)<<4|i>>4],o+=t+1<e.length?dr[(i&15)<<2|a>>6]:"=",o+=t+2<e.length?dr[a&63]:"=";}return o}function Ol(r){let e=r.replace(/\s+/g,"");if(!/^[A-Za-z0-9+/]*={0,2}$/.test(e))return null;let o=e.replace(/=+$/,""),t=[],n=0,i=0;for(let a of o){let s=dr.indexOf(a);if(s<0)return null;i=i<<6|s,n+=6,n>=8&&(n-=8,t.push(i>>n&255));}try{return new TextDecoder("utf-8",{fatal:!0}).decode(new Uint8Array(t))}catch{return null}}function Cl(r){return encodeURIComponent(r)}function Il(r){try{return decodeURIComponent(r)}catch{return null}}function hl(r){return Array.from(new TextEncoder().encode(r)).map(e=>e.toString(16).padStart(2,"0")).join(" ")}function Qn(r){let e=r.trim().split(/[\s,]+/).filter(t=>t.length>0),o=[];for(let t of e){if(!/^[0-9a-fA-F]{1,2}$/.test(t))return null;o.push(parseInt(t,16));}try{return new TextDecoder("utf-8",{fatal:!0}).decode(new Uint8Array(o))}catch{return null}}var po=class{constructor(){this.category="Encoding";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,t,n){let i=(t.value??"").replace(/^from\s+/i,"").toLowerCase();n.emitOpcode(13),n.emitString(i),n.emitPluginCall("fromEncoding",2);}};var fo=class{constructor(e){this.fn=e;this.category="Encoding";}parse(e,o,t){e.consume("LPAREN"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,t),e.consume("RPAREN"),t.emitPluginCall(this.fn,1);}};var Sl="BASE64_FN",td=chunk5IJD5L3O_cjs.c(Sl);function Ll(r=80){let e="encoding:base64-call";return {name:e,priority:r,startTokenTypes:["IDENT"],match(o,t){let n=o[t];return !n||n.type!=="IDENT"||(n.value??"").toLowerCase()!=="base64"||o[t+1]?.type!=="LPAREN"||o[t-1]?.type==="COLON"?null:{consumed:1,replacement:[new chunkFAGFPVYK_cjs.a(Sl,td,n.value,n.value,n.offset,0,n.line,n.col)],ruleName:e}}}}function vl(r){return r.type===3?r.value:null}function Eo(r,e){return o=>{let t=vl(o);return t===null?chunk6U66HQKQ_cjs.P("ENCODING_EXPECTED_TEXT",`"as ${r}" expects text (a "quoted string")`):chunk6U66HQKQ_cjs.t(e(t))}}var od={base64:Ol,url:Il,"hex bytes":Qn,hexbytes:Qn},qn={name:"solve-encoding",phrases:{"hex bytes":"CONVERTER_NAME","from base64":"FROM_ENCODING","from url":"FROM_ENCODING","from hex bytes":"FROM_ENCODING"},asConverters:{base64:Eo("base64",Xn),url:Eo("url",Cl),"hex bytes":Eo("hex bytes",hl)},infixParselets:{FROM_ENCODING:new po},prefixParselets:{BASE64_FN:new fo("base64")},normalizerRules:[Ll()],pluginFunctions:{base64:r=>Eo("base64",Xn)(r[0]),fromEncoding:r=>{let e=vl(r[0]),o=String(r[1].value??"");if(e===null)return chunk6U66HQKQ_cjs.P("ENCODING_EXPECTED_TEXT",`"from ${o}" expects text (a "quoted string")`);let t=od[o];if(!t)return chunk6U66HQKQ_cjs.P("UNKNOWN_ENCODING",`"from ${o}" is not a known encoding (try base64, url or hex bytes)`);let n=t(e);return n===null?chunk6U66HQKQ_cjs.P("ENCODING_DECODE_FAILED",`"from ${o}": the input is not valid ${o}`):chunk6U66HQKQ_cjs.t(n)}},tokenCategories:{BASE64_FN:"function"}};var To=class{constructor(){this.category="IP";}parse(e,o,t){t.emitOpcode(13),t.emitString(o.value),t.emitPluginCall("ipLiteral",1);}};var be=class{constructor(e){this.pluginFn=e;this.category="IP";}parse(e,o,t){let n=e.peek(),i=e.peekAt(1);n?.type==="SLASH"&&i?.type==="NUMBER"?(e.consume(),e.consume(),t.emitOpcode(13),t.emitString(`|${i.value}`),t.emitPluginCall("ipLiteral",1)):e.parseExpression(chunkFVQWN5HZ_cjs.a.Prefix,t),t.emitPluginCall(this.pluginFn,1);}};var wl="IP_CIDR",nd=chunk5IJD5L3O_cjs.c(wl),id=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(?:\/\d{1,2})?/,ad=8;function kl(r=72){let e="ip:ip-cidr-literal";return {name:e,priority:r,match(o,t){let n=o[t];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=t+1;E<o.length&&s.length<ad;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=id.exec(i);if(l===null)return null;let u=chunk5TVI2UPZ_cjs.C(l[0]);if(u===null||u.addr===void 0)return null;let c=0,f=0;for(let E of s)if(f+=E.text?.length??0,c++,f>=l[0].length)break;if(f!==l[0].length)return null;let T=`${u.addr}|${u.prefix??""}`,N=new chunkFAGFPVYK_cjs.a(wl,nd,T,l[0],n.offset,0,n.line,n.col,n.offset+l[0].length);return {consumed:c,replacement:[N],ruleName:e}}}}function Er(r,e){return r.type===17?r.value:chunk6U66HQKQ_cjs.P("IP_EXPECTED",`"${e}" expects an IP address or subnet (e.g. 192.168.1.0/24)`)}function Ml(r){let[e,o]=String(r[0].value??"").split("|"),t={...e!==""?{addr:Number(e)}:{},...o!==""?{prefix:Number(o)}:{}};return chunk6U66HQKQ_cjs.J(t)}function Bl(r){let e=Er(r[0],"hosts in");return e instanceof chunk6U66HQKQ_cjs.m?e:e.prefix===void 0?chunk6U66HQKQ_cjs.P("IP_NO_PREFIX",'"hosts in" needs a subnet with a prefix, e.g. 192.168.1.0/24'):chunk6U66HQKQ_cjs.n(chunk5TVI2UPZ_cjs.F(e.prefix))}function Ul(r){let e=Er(r[0],"netmask of");return e instanceof chunk6U66HQKQ_cjs.m?e:e.prefix===void 0?chunk6U66HQKQ_cjs.P("IP_NO_PREFIX",'"netmask of" needs a prefix, e.g. /24 or 192.168.1.0/24'):chunk6U66HQKQ_cjs.J({addr:chunk5TVI2UPZ_cjs.E(e.prefix)})}function Dl(r){let e=Er(r[0],"broadcast of");return e instanceof chunk6U66HQKQ_cjs.m?e:e.addr===void 0||e.prefix===void 0?chunk6U66HQKQ_cjs.P("IP_NEEDS_ADDRESS_AND_PREFIX",'"broadcast of" needs an address and a prefix, e.g. 192.168.1.0/24'):chunk6U66HQKQ_cjs.J({addr:chunk5TVI2UPZ_cjs.G(e.addr,e.prefix)})}function bl(r){let e=Er(r[0],"in");if(e instanceof chunk6U66HQKQ_cjs.m)return e;let o=Er(r[1],"in");return o instanceof chunk6U66HQKQ_cjs.m?o:e.addr===void 0?chunk6U66HQKQ_cjs.P("IP_EXPECTED_ADDRESS",'"in" expects an address on the left'):o.addr===void 0||o.prefix===void 0?chunk6U66HQKQ_cjs.P("IP_EXPECTED_BLOCK",'"in" expects a subnet on the right, e.g. 10.0.0.0/8'):chunk6U66HQKQ_cjs.L(chunk5TVI2UPZ_cjs.H(e.addr,o.addr,o.prefix))}function Vl(r){if(r.type===17){let e=r.value;return chunk6U66HQKQ_cjs.n(e.addr??0)}return chunk6U66HQKQ_cjs.n(Math.trunc(r.toNumber()))}var Zn={name:"solve-ip",phrases:{"hosts in":"HOSTS_IN","netmask of":"NETMASK_OF","broadcast of":"BROADCAST_OF"},prefixParselets:{IP_CIDR:new To,HOSTS_IN:new be("hostsIn"),NETMASK_OF:new be("netmaskOf"),BROADCAST_OF:new be("broadcastOf")},normalizerRules:[kl()],pluginFunctions:{ipLiteral:Ml,hostsIn:Bl,netmaskOf:Ul,broadcastOf:Dl,ipInCidr:bl},asConverters:{int:Vl},tokenCategories:{IP_CIDR:"number",HOSTS_IN:"keyword",NETMASK_OF:"keyword",BROADCAST_OF:"keyword"}};var sd=chunk5IJD5L3O_cjs.c("UNIT");function Fl(r=82){let e="fuel:l-per-100km";return {name:e,priority:r,match(o,t){let n=o[t],i=o[t+1],a=o[t+2],s=o[t+3];return !n||n.type!=="UNIT"&&n.type!=="IDENT"||(n.value??"").toLowerCase()!=="l"||i?.type!=="SLASH"||a?.type!=="NUMBER"||a.value!=="100"||s?.type!=="UNIT"||(s.value??"").toLowerCase()!=="km"?null:{consumed:4,replacement:[new chunkFAGFPVYK_cjs.a("UNIT",sd,"l100km","l/100km",n.offset,0,n.line,n.col)],ruleName:e}}}}var Jn={name:"solve-fuel",normalizerRules:[Fl()]};var md=chunk5IJD5L3O_cjs.c("UNIT");function Hl(r=82){let e="derived:acceleration";return {name:e,priority:r,match(o,t){let n=o[t],i=o[t+1],a=o[t+2],s=o[t+3],l=o[t+4];return !n||n.type!=="UNIT"||(n.value??"")!=="m"||i?.type!=="SLASH"||a?.type!=="UNIT"||(a.value??"")!=="s"||s?.type!=="CARET"||l?.type!=="NUMBER"||l.value!=="2"?null:{consumed:5,replacement:[new chunkFAGFPVYK_cjs.a("UNIT",md,"mps2","m/s^2",n.offset,0,n.line,n.col)],ruleName:e}}}}function D(r){return e=>e.type!==6||!e.unit?chunk6U66HQKQ_cjs.P("AS_UNIT_EXPECTED_QUANTITY",`"as ${r}" expects a quantity with a unit`):e.unit===r?e:chunkBKSKZA4W_cjs.d(e.unit,r)?chunk6U66HQKQ_cjs.u(chunkBKSKZA4W_cjs.e(e.toNumber(),e.unit,r),r):chunk6U66HQKQ_cjs.P("AS_UNIT_INCOMPATIBLE",`${e.unit} cannot be expressed as ${r}: they do not measure the same thing`)}var ei={name:"solve-derived-units",normalizerRules:[Hl()],asConverters:{n:D("N"),kn:D("kN"),j:D("J"),kj:D("kJ"),mj:D("MJ"),wh:D("Wh"),kwh:D("kWh"),w:D("W"),kw:D("kW"),mw:D("MW"),pa:D("Pa"),kpa:D("kPa"),mpa:D("MPa"),v:D("V"),mv:D("mV"),kv:D("kV")}};function ri(r){return [...r].length}function zl(r){return r.trim()}function Gl(r){return [...r].reverse().join("")}function Kl(r,e){return r.includes(e)}function $l(r,e){return r.startsWith(e)}function Wl(r,e){return r.endsWith(e)}function Yl(r,e,o){return e===""?r:r.split(e).join(o)}function jl(r,e){let o=Math.trunc(e);return o<=0?"":r.repeat(o)}function No(r){return r.toUpperCase()}function yo(r){return r.toLowerCase()}function go(r){return r.replace(/\S+/g,e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase())}function Po(r){return r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Xl(r){let e=r.trim();return e===""?0:e.split(/\s+/).length}function Ql(r){return r===""?0:r.split(/\r\n|\r|\n/).length}function ae(r){return r?.type===3?r.value:null}function Tr(r){return chunk6U66HQKQ_cjs.P("TEXT_EXPECTED",`${r} expects text (a "quoted string")`)}function _o(r,e){return o=>{let t=ae(o[0]);return t===null?Tr(r):chunk6U66HQKQ_cjs.n(e(t))}}function Ve(r,e){return o=>{let t=ae(o[0]);return t===null?Tr(r):chunk6U66HQKQ_cjs.t(e(t))}}function ti(r,e){return o=>{let t=ae(o[0]),n=ae(o[1]);return t===null||n===null?Tr(r):chunk6U66HQKQ_cjs.L(e(t,n))}}var ql={textLength:_o("length",ri),textWordCount:_o("words in",Xl),textCharCount:_o("characters in",ri),textLineCount:_o("lines in",Ql),textTrim:Ve("trim",zl),textReverse:Ve("reverse",Gl),textUpper:Ve('"as upper"',No),textLower:Ve('"as lower"',yo),textTitle:Ve('"as title"',go),textSlug:Ve('"as slug"',Po),textContains:ti("contains",Kl),textStartsWith:ti("starts with",$l),textEndsWith:ti("ends with",Wl),textReplace:r=>{let e=ae(r[0]),o=ae(r[1]),t=ae(r[2]);return e===null||o===null||t===null?Tr("replace"):chunk6U66HQKQ_cjs.t(Yl(e,o,t))},textRepeat:r=>{let e=ae(r[0]);if(e===null)return Tr("repeat");let o=r[1];return o?.type!==0?chunk6U66HQKQ_cjs.P("TEXT_EXPECTED","repeat expects a count (a number)"):chunk6U66HQKQ_cjs.t(jl(e,o.value))}};function ge(r,e){return {category:"Text",parse(o,t,n){o.parseExpression(e,n),n.emitPluginCall(r,1);}}}function Ao(r){return {category:"Text",bindingPower:chunkFVQWN5HZ_cjs.a.Conditional,parse(e,o,t,n){e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,n),n.emitPluginCall(r,2);}}}var Zl={category:"Text",bindingPower:chunkFVQWN5HZ_cjs.a.Conditional,parse(r,e,o,t){r.parseExpression(chunkFVQWN5HZ_cjs.a.Prefix,t);let n=r.peek();n?.type==="STAR"&&(n.value??"").toLowerCase()==="times"&&r.consume(),t.emitPluginCall("textRepeat",2);}};var xo={length:"textLength",upper:"textUpper",uppercase:"textUpper",lower:"textLower",lowercase:"textLower",title:"textTitle",titlecase:"textTitle",slug:"textSlug",slugify:"textSlug",replace:"textReplace",repeat:"textRepeat",words:"textWordCount",wordcount:"textWordCount",characters:"textCharCount",charcount:"textCharCount",lines:"textLineCount",linecount:"textLineCount"};var Ro=class{constructor(){this.category="Text";}parse(e,o,t){let n=xo[o.value];if(n===void 0)throw chunkNAZ6PGLS_cjs.c.execution("UNKNOWN_FUNCTION",`Unknown text function: ${o.value}`,{functionName:o.value});e.consume("LPAREN");let i=0;if(e.peek()?.type!=="RPAREN")for(e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,t),i++;e.match("COMMA");)e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,t),i++;e.consume("RPAREN"),t.emitPluginCall(n,i);}};var Jl="TEXT_CALL",ld=chunk5IJD5L3O_cjs.c(Jl);function eu(r=80){let e="text:call";return {name:e,priority:r,startTokenTypes:["IDENT"],match(o,t){let n=o[t];if(!n||n.type!=="IDENT")return null;let i=(n.value??"").toLowerCase();return !(i in xo)||o[t+1]?.type!=="LPAREN"||o[t-1]?.type==="COLON"?null:{consumed:1,replacement:[new chunkFAGFPVYK_cjs.a(Jl,ld,i,n.value,n.offset,0,n.line,n.col)],ruleName:e}}}}function Oo(r,e){return o=>o.type!==3?chunk6U66HQKQ_cjs.P("TEXT_EXPECTED",`"as ${r}" expects text (a "quoted string")`):chunk6U66HQKQ_cjs.t(e(o.value))}var oi={name:"solve-text",phrases:{"length of":"LENGTH_OF","words in":"WORDS_IN","characters in":"CHARACTERS_IN","lines in":"LINES_IN","starts with":"STARTS_WITH","ends with":"ENDS_WITH"},lexerVocabulary:{keywords:{trim:"TRIM",reverse:"REVERSE",contains:"CONTAINS",repeated:"REPEATED"}},prefixParselets:{LENGTH_OF:ge("textLength",chunkFVQWN5HZ_cjs.a.Lowest),WORDS_IN:ge("textWordCount",chunkFVQWN5HZ_cjs.a.Lowest),CHARACTERS_IN:ge("textCharCount",chunkFVQWN5HZ_cjs.a.Lowest),LINES_IN:ge("textLineCount",chunkFVQWN5HZ_cjs.a.Lowest),TRIM:ge("textTrim",chunkFVQWN5HZ_cjs.a.Prefix),REVERSE:ge("textReverse",chunkFVQWN5HZ_cjs.a.Prefix),TEXT_CALL:new Ro},infixParselets:{CONTAINS:Ao("textContains"),STARTS_WITH:Ao("textStartsWith"),ENDS_WITH:Ao("textEndsWith"),REPEATED:Zl},asConverters:{upper:Oo("upper",No),lower:Oo("lower",yo),title:Oo("title",go),slug:Oo("slug",Po)},normalizerRules:[eu()],pluginFunctions:ql,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 Nr(r){return new TextEncoder().encode(r)}function ni(r){let e="";for(let o of r)e+=o.toString(16).padStart(2,"0");return e}var ud=(()=>{let r=new Uint32Array(256);for(let e=0;e<256;e++){let o=e;for(let t=0;t<8;t++)o=o&1?3988292384^o>>>1:o>>>1;r[e]=o>>>0;}return r})();function ru(r){let e=Nr(r),o=4294967295;for(let t of e)o=ud[(o^t)&255]^o>>>8;return o=(o^4294967295)>>>0,o.toString(16).padStart(8,"0")}function cd(r){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 t=r.length*8,n=new Uint8Array(((r.length+8>>6)+1)*64);n.set(r),n[r.length]=128;let i=new DataView(n.buffer);i.setUint32(n.length-8,t>>>0,true),i.setUint32(n.length-4,Math.floor(t/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,R=s,O=l,g=u;for(let P=0;P<64;P++){let S,v;P<16?(S=R&O|~R&g,v=P):P<32?(S=g&R|~g&O,v=(5*P+1)%16):P<48?(S=R^O^g,v=(3*P+5)%16):(S=O^(R|~g),v=7*P%16),S=S+_+o[P]+E[v]|0,_=g,g=O,O=R,R=R+c(S,e[P])|0;}a=a+_|0,s=s+R|0,l=l+O|0,u=u+g|0;}let f=new Uint8Array(16),T=new DataView(f.buffer);return T.setUint32(0,a>>>0,true),T.setUint32(4,s>>>0,true),T.setUint32(8,l>>>0,true),T.setUint32(12,u>>>0,true),f}function tu(r){return ni(cd(Nr(r)))}function pd(r){let e=r.length*8,o=new Uint8Array(((r.length+8>>6)+1)*64);o.set(r),o[r.length]=128;let t=new DataView(o.buffer);t.setUint32(o.length-8,Math.floor(e/4294967296)>>>0),t.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]=t.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,R=a,O=s,g=l;for(let P=0;P<80;P++){let S,v;P<20?(S=_&R|~_&O,v=1518500249):P<40?(S=_^R^O,v=1859775393):P<60?(S=_&R|_&O|R&O,v=2400959708):(S=_^R^O,v=3395469782);let j=u(E,5)+S+g+v+c[P]|0;g=O,O=R,R=u(_,30),_=E,E=j;}n=n+E|0,i=i+_|0,a=a+R|0,s=s+O|0,l=l+g|0;}let f=new Uint8Array(20),T=new DataView(f.buffer);return [n,i,a,s,l].forEach((N,E)=>T.setUint32(E*4,N>>>0)),f}function ou(r){return ni(pd(Nr(r)))}var fd=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 dd(r){let e=r.length*8,o=new Uint8Array(((r.length+8>>6)+1)*64);o.set(r),o[r.length]=128;let t=new DataView(o.buffer);t.setUint32(o.length-8,Math.floor(e/4294967296)>>>0),t.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]=t.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,S=i(a[g-2],17)^i(a[g-2],19)^a[g-2]>>>10;a[g]=a[g-16]+P+a[g-7]+S|0;}let[c,f,T,N,E,_,R,O]=n;for(let g=0;g<64;g++){let P=i(E,6)^i(E,11)^i(E,25),S=E&_^~E&R,v=O+P+S+fd[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;O=R,R=_,_=E,E=N+v|0,N=T,T=f,f=c,c=v+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]+R|0,n[7]=n[7]+O|0;}let s=new Uint8Array(32),l=new DataView(s.buffer);for(let u=0;u<8;u++)l.setUint32(u*4,n[u]>>>0);return s}function nu(r){return ni(dd(Nr(r)))}var V=(1n<<64n)-1n,Ed=[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 iu(r){let e=Nr(r),o=((e.length+16>>7)+1)*128,t=new Uint8Array(o);t.set(e),t[e.length]=128;let n=BigInt(e.length)*8n,i=new DataView(t.buffer);i.setUint32(t.length-4,Number(n&0xffffffffn)),i.setUint32(t.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<t.length;u+=128){for(let g=0;g<16;g++){let P=BigInt(i.getUint32(u+g*8)),S=BigInt(i.getUint32(u+g*8+4));l[g]=P<<32n|S;}for(let g=16;g<80;g++){let P=s(l[g-15],1n)^s(l[g-15],8n)^l[g-15]>>7n,S=s(l[g-2],19n)^s(l[g-2],61n)^l[g-2]>>6n;l[g]=l[g-16]+P+l[g-7]+S&V;}let[c,f,T,N,E,_,R,O]=a;for(let g=0;g<80;g++){let P=s(E,14n)^s(E,18n)^s(E,41n),S=E&_^~E&V&R,v=O+P+S+Ed[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;O=R,R=_,_=E,E=N+v&V,N=T,T=f,f=c,c=v+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]+R&V,a[7]=a[7]+O&V;}return a.map(u=>u.toString(16).padStart(16,"0")).join("")}var Co={md5:"hashMd5",sha1:"hashSha1",sha256:"hashSha256",sha512:"hashSha512",crc32:"hashCrc32"};function yr(r,e){return o=>{let t=o[0];return t?.type!==3?chunk6U66HQKQ_cjs.P("HASH_EXPECTED_TEXT",`${r}(...) expects text (a "quoted string")`):chunk6U66HQKQ_cjs.t(e(t.value))}}var au={hashMd5:yr("md5",tu),hashSha1:yr("sha1",ou),hashSha256:yr("sha256",nu),hashSha512:yr("sha512",iu),hashCrc32:yr("crc32",ru)};var Io=class{constructor(){this.category="Hash";}parse(e,o,t){let n=Co[o.value];if(n===void 0)throw chunkNAZ6PGLS_cjs.c.execution("UNKNOWN_FUNCTION",`Unknown hash function: ${o.value}`,{functionName:o.value});e.consume("LPAREN");let i=0;if(e.peek()?.type!=="RPAREN")for(e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,t),i++;e.match("COMMA");)e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,t),i++;e.consume("RPAREN"),t.emitPluginCall(n,i);}};var su="HASH_CALL",Td=chunk5IJD5L3O_cjs.c(su);function mu(r=80){let e="hash:call";return {name:e,priority:r,startTokenTypes:["IDENT"],match(o,t){let n=o[t];if(!n||n.type!=="IDENT")return null;let i=(n.value??"").toLowerCase();return !(i in Co)||o[t+1]?.type!=="LPAREN"||o[t-1]?.type==="COLON"?null:{consumed:1,replacement:[new chunkFAGFPVYK_cjs.a(su,Td,i,n.value,n.offset,0,n.line,n.col)],ruleName:e}}}}var ii={name:"solve-hash",prefixParselets:{HASH_CALL:new Io},normalizerRules:[mu()],pluginFunctions:au,tokenCategories:{HASH_CALL:"function"}};var lu="0123456789abcdef";function uu(){return lu[Math.floor(Math.random()*16)]}function Nd(){let r="";for(let e=0;e<36;e++)e===8||e===13||e===18||e===23?r+="-":e===14?r+="4":e===19?r+=lu[Math.floor(Math.random()*16)&3|8]:r+=uu();return r}function yd(r){let e="";for(let o=0;o<r;o++)e+=uu();return e}var cu={randomUuid:()=>chunk6U66HQKQ_cjs.t(Nd()),randomCoin:()=>chunk6U66HQKQ_cjs.t(Math.random()<.5?"heads":"tails"),randomHex:r=>{let e=r[0];if(e?.type!==0)return chunk6U66HQKQ_cjs.P("RANDOM_EXPECTED_COUNT","random hex expects a number of digits");let o=Math.trunc(e.value);return o<0?chunk6U66HQKQ_cjs.P("RANDOM_EXPECTED_COUNT","random hex needs a count of 0 or more"):chunk6U66HQKQ_cjs.t(yd(o))},randomPick:r=>r.length===0?chunk6U66HQKQ_cjs.P("RANDOM_PICK_EMPTY","pick needs at least one option"):r[Math.floor(Math.random()*r.length)],randomShuffle:r=>{let e=r[0];if(e?.type!==7)return chunk6U66HQKQ_cjs.P("RANDOM_SHUFFLE_EXPECTED_LIST","shuffle expects a list, e.g. shuffle [1, 2, 3]");let o=e.value;if(o.rows!==1&&o.cols!==1)return chunk6U66HQKQ_cjs.P("RANDOM_SHUFFLE_EXPECTED_LIST","shuffle expects a single row or column, not a full matrix");let t=o.data.slice();for(let n=t.length-1;n>0;n--){let i=Math.floor(Math.random()*(n+1));[t[n],t[i]]=[t[i],t[n]];}return chunk6U66HQKQ_cjs.C(o.rows,o.cols,t)}};function ai(r){return {category:"Random",parse(e,o,t){t.emitPluginCall(r,0);}}}function si(r){return {category:"Random",parse(e,o,t){e.parseExpression(chunkFVQWN5HZ_cjs.a.Prefix,t),t.emitPluginCall(r,1);}}}var pu={category:"Random",parse(r,e,o){r.consume("LPAREN");let t=0;if(r.peek()?.type!=="RPAREN")for(r.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,o),t++;r.match("COMMA");)r.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,o),t++;r.consume("RPAREN"),o.emitPluginCall("randomPick",t);}};var fu="PICK_CALL",gd=chunk5IJD5L3O_cjs.c(fu);function du(r=80){let e="random:pick-call";return {name:e,priority:r,startTokenTypes:["IDENT"],match(o,t){let n=o[t];return !n||n.type!=="IDENT"||(n.value??"").toLowerCase()!=="pick"||o[t+1]?.type!=="LPAREN"||o[t-1]?.type==="COLON"?null:{consumed:1,replacement:[new chunkFAGFPVYK_cjs.a(fu,gd,n.value,n.value,n.offset,0,n.line,n.col)],ruleName:e}}}}var mi={name:"solve-random",phrases:{"random hex":"RANDOM_HEX"},lexerVocabulary:{keywords:{uuid:"UUID",coin:"COIN",shuffle:"SHUFFLE"}},prefixParselets:{UUID:ai("randomUuid"),COIN:ai("randomCoin"),RANDOM_HEX:si("randomHex"),SHUFFLE:si("randomShuffle"),PICK_CALL:pu},normalizerRules:[du()],pluginFunctions:cu,tokenCategories:{UUID:"function",COIN:"function",RANDOM_HEX:"function",SHUFFLE:"function",PICK_CALL:"function"}};function se(r){return r.reduce((e,o)=>e+o,0)/r.length}function Pd(r){let e=se(r);return r.reduce((o,t)=>o+(t-e)*(t-e),0)/r.length}function _d(r){return Math.sqrt(Pd(r))}function li(r,e){let o=se(r),t=se(e),n=0,i=0,a=0;for(let l=0;l<r.length;l++){let u=r[l]-o,c=e[l]-t;n+=u*c,i+=u*u,a+=c*c;}let s=Math.sqrt(i*a);return s===0?NaN:n/s}function ui(r,e){let o=se(r),t=se(e),n=0,i=0;for(let a=0;a<r.length;a++){let s=r[a]-o;n+=s*(e[a]-t),i+=s*s;}return i===0?NaN:n/i}function Eu(r,e){return se(e)-ui(r,e)*se(r)}function Tu(r,e){let o=li(r,e);return o*o}function Nu(r,e){let o=[...r].sort((a,s)=>a-s);if(o.length===1)return o[0];let t=e/100*(o.length-1),n=Math.floor(t),i=Math.ceil(t);return n===i?o[n]:o[n]+(t-n)*(o[i]-o[n])}function yu(r,e){let o=_d(e);return o===0?NaN:(r-se(e))/o}function Ad(r){let e=r<0?-1:1,o=1/(1+.3275911*Math.abs(r)),t=1-((((1.061405429*o-1.453152027)*o+1.421413741)*o-.284496736)*o+.254829592)*o*Math.exp(-r*r);return e*t}function gu(r){return .5*(1+Ad(r/Math.SQRT2))}function Pu(r){return Math.exp(-0.5*r*r)/Math.sqrt(2*Math.PI)}function So(r){if(!r)return null;if(r.type===7){let e=r.value;return e.hasSymbolic||e.rows!==1&&e.cols!==1?null:e.data.slice()}if(r.type===8){let e=r.value,o=[];for(let t=Math.ceil(e.min);t<=e.max;t++)o.push(t);return o}return r.type===0?[r.value]:null}function ho(r,e){return o=>{let t=So(o[0]),n=So(o[1]);return t===null||n===null?chunk6U66HQKQ_cjs.P("STAT_EXPECTED_LISTS",`${r} expects two lists, e.g. ${r} of [1, 2, 3] and [2, 4, 6]`):t.length!==n.length?chunk6U66HQKQ_cjs.P("STAT_LENGTH_MISMATCH",`${r}: the two lists must be the same length (got ${t.length} and ${n.length})`):t.length<2?chunk6U66HQKQ_cjs.P("STAT_TOO_FEW",`${r} needs at least two paired points`):chunk6U66HQKQ_cjs.n(e(t,n))}}var _u={statCorrelation:ho("correlation",li),statSlope:ho("slope",ui),statIntercept:ho("intercept",Eu),statRSquared:ho("r squared",Tu),statPercentile:r=>{let e=So(r[0]),o=r[1];if(e===null)return chunk6U66HQKQ_cjs.P("STAT_EXPECTED_LIST","percentile expects a list, e.g. percentile([1, 2, 3], 90)");if(e.length===0)return chunk6U66HQKQ_cjs.P("STAT_EMPTY","percentile needs at least one value");if(o?.type!==0)return chunk6U66HQKQ_cjs.P("STAT_EXPECTED_PERCENT","percentile needs a percentage, e.g. percentile([...], 90)");let t=o.value;return t<0||t>100?chunk6U66HQKQ_cjs.P("STAT_PERCENT_RANGE","a percentile is between 0 and 100"):chunk6U66HQKQ_cjs.n(Nu(e,t))},statZScore:r=>{let e=r[0],o=So(r[1]);return e?.type!==0?chunk6U66HQKQ_cjs.P("STAT_EXPECTED_VALUE","zscore expects a value first, e.g. zscore(5, [1, 2, 3])"):o===null||o.length<2?chunk6U66HQKQ_cjs.P("STAT_EXPECTED_LIST","zscore expects a list of at least two values"):chunk6U66HQKQ_cjs.n(yu(e.value,o))},statNormalCdf:r=>{let e=r[0];return e?.type!==0?chunk6U66HQKQ_cjs.P("STAT_EXPECTED_VALUE","normalcdf expects a number"):chunk6U66HQKQ_cjs.n(gu(e.value))},statNormalPdf:r=>{let e=r[0];return e?.type!==0?chunk6U66HQKQ_cjs.P("STAT_EXPECTED_VALUE","normalpdf expects a number"):chunk6U66HQKQ_cjs.n(Pu(e.value))}};function Lo(r){return {category:"Statistics",parse(e,o,t){e.parseExpression(chunkFVQWN5HZ_cjs.a.Conjunction,t),e.consume("AND_CONJ"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Conjunction,t),t.emitPluginCall(r,2);}}}var vo={correlation:"statCorrelation",slope:"statSlope",intercept:"statIntercept",rsquared:"statRSquared",percentile:"statPercentile",zscore:"statZScore",normalcdf:"statNormalCdf",normalpdf:"statNormalPdf"};var wo=class{constructor(){this.category="Statistics";}parse(e,o,t){let n=vo[o.value];if(n===void 0)throw chunkNAZ6PGLS_cjs.c.execution("UNKNOWN_FUNCTION",`Unknown statistics function: ${o.value}`,{functionName:o.value});e.consume("LPAREN");let i=0;if(e.peek()?.type!=="RPAREN")for(e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,t),i++;e.match("COMMA");)e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,t),i++;e.consume("RPAREN"),t.emitPluginCall(n,i);}};var Au="STAT_CALL",xd=chunk5IJD5L3O_cjs.c(Au);function xu(r=80){let e="statistics:call";return {name:e,priority:r,startTokenTypes:["IDENT"],match(o,t){let n=o[t];if(!n||n.type!=="IDENT")return null;let i=(n.value??"").toLowerCase();return !(i in vo)||o[t+1]?.type!=="LPAREN"||o[t-1]?.type==="COLON"?null:{consumed:1,replacement:[new chunkFAGFPVYK_cjs.a(Au,xd,i,n.value,n.offset,0,n.line,n.col)],ruleName:e}}}}var ci={name:"solve-statistics",phrases:{"correlation of":"CORRELATION_OF","slope of":"SLOPE_OF","intercept of":"INTERCEPT_OF"},prefixParselets:{CORRELATION_OF:Lo("statCorrelation"),SLOPE_OF:Lo("statSlope"),INTERCEPT_OF:Lo("statIntercept"),STAT_CALL:new wo},normalizerRules:[xu()],pluginFunctions:_u,tokenCategories:{CORRELATION_OF:"function",SLOPE_OF:"function",INTERCEPT_OF:"function",STAT_CALL:"function"}};var Rd=[[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"]],Ru={I:1,V:5,X:10,L:50,C:100,D:500,M:1e3};function pi(r){if(!Number.isInteger(r)||r<1||r>3999)return null;let e="",o=r;for(let[t,n]of Rd)for(;o>=t;)e+=n,o-=t;return e}function Ou(r){let e=r.trim().toUpperCase();if(e===""||!/^[MDCLXVI]+$/.test(e))return null;let o=0;for(let t=0;t<e.length;t++){let n=Ru[e[t]],i=t+1<e.length?Ru[e[t+1]]:0;o+=n<i?-n:n;}return pi(o)===e?o:null}function Cu(r){if(!Number.isInteger(r))return null;let e=Math.abs(r),o=e%100,t=e%10,n="th";return (o<11||o>13)&&(t===1?n="st":t===2?n="nd":t===3&&(n="rd")),`${r}${n}`}var ko=["zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],Od=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"],Cd=["","thousand","million","billion","trillion","quadrillion"];function Id(r){if(r<20)return ko[r];let e=Math.floor(r/10),o=r%10;return Od[e]+(o?`-${ko[o]}`:"")}function hd(r){let e=Math.floor(r/100),o=r%100,t=[];return e&&t.push(`${ko[e]} hundred`),o&&(e&&t.push("and"),t.push(Id(o))),t.join(" ")}function Sd(r){if(r===0)return "zero";let e=[],o=r;for(;o>0;)e.push(o%1e3),o=Math.floor(o/1e3);let t=[];for(let i=e.length-1;i>=0;i--){if(e[i]===0)continue;let a=hd(e[i]);i>0&&(a+=` ${Cd[i]}`),t.push({scale:i,group:e[i],words:a});}let n="";for(let i=0;i<t.length;i++){if(i>0){let a=i===t.length-1;n+=a&&t[i].scale===0&&t[i].group<100?" and ":" ";}n+=t[i].words;}return n}function Iu(r){if(!Number.isFinite(r))return null;let e=Math.abs(r).toString();if(e.includes("e")||e.includes("E"))return null;let[o,t]=e.split("."),n=Sd(parseInt(o,10));return t&&(n+=" point "+[...t].map(i=>ko[Number(i)]).join(" ")),(r<0?"minus ":"")+n}var Mo=class{constructor(){this.category="Numerals";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,t,n){n.emitPluginCall("romanFromString",1);}};function fi(r,e){return o=>{if(o.type!==0)return chunk6U66HQKQ_cjs.P("NUMERAL_EXPECTED_NUMBER",`"as ${r}" expects a number`);let t=e(o.value);return t===null?chunk6U66HQKQ_cjs.P("NUMERAL_OUT_OF_RANGE",`${o.value} cannot be written as ${r}`):chunk6U66HQKQ_cjs.t(t)}}var di={name:"solve-numerals",phrases:{"from roman":"FROM_ROMAN"},asConverters:{roman:fi("roman",pi),ordinal:fi("ordinal",Cu),words:fi("words",Iu)},infixParselets:{FROM_ROMAN:new Mo},pluginFunctions:{romanFromString:r=>{let e=r[0];if(e?.type!==3)return chunk6U66HQKQ_cjs.P("NUMERAL_EXPECTED_TEXT",'"from roman" expects text, e.g. "MMXXIV" from roman');let o=Ou(e.value);return o===null?chunk6U66HQKQ_cjs.P("NUMERAL_INVALID_ROMAN",`"${e.value}" is not a valid Roman numeral`):chunk6U66HQKQ_cjs.n(o)}},tokenCategories:{FROM_ROMAN:"operator"}};function Ld(r,e){for(r=Math.abs(r),e=Math.abs(e);e;)[r,e]=[e,r%e];return r}function hu(r){if(r.length<2||r.some(o=>!Number.isInteger(o)||o<=0))return null;let e=r.reduce((o,t)=>Ld(o,t),0)||1;return r.map(o=>o/e).join(":")}var Su={category:"Ratio",parse(r,e,o){r.consume("LPAREN");let t=0;if(r.peek()?.type!=="RPAREN")for(r.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,o),t++;r.match("COMMA");)r.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,o),t++;r.consume("RPAREN"),o.emitPluginCall("ratioReduce",t);}};var Lu="RATIO_CALL",vd=chunk5IJD5L3O_cjs.c(Lu);function vu(r=80){let e="ratio:call";return {name:e,priority:r,startTokenTypes:["IDENT"],match(o,t){let n=o[t];return !n||n.type!=="IDENT"||(n.value??"").toLowerCase()!=="ratio"||o[t+1]?.type!=="LPAREN"||o[t-1]?.type==="COLON"?null:{consumed:1,replacement:[new chunkFAGFPVYK_cjs.a(Lu,vd,n.value,n.value,n.offset,0,n.line,n.col)],ruleName:e}}}}var Ei={name:"solve-ratio",prefixParselets:{RATIO_CALL:Su},normalizerRules:[vu()],pluginFunctions:{ratioReduce:r=>{let e=[];for(let t of r){if(t.type!==0)return chunk6U66HQKQ_cjs.P("RATIO_EXPECTED_NUMBERS","ratio expects whole numbers, e.g. ratio(16, 9)");e.push(t.value);}let o=hu(e);return o===null?chunk6U66HQKQ_cjs.P("RATIO_INVALID","ratio needs at least two whole positive numbers"):chunk6U66HQKQ_cjs.t(o)}},tokenCategories:{RATIO_CALL:"function"}};var Pe=Math.PI;function F(r,e){let o=[];for(let t of e){if(!(t in r))return null;o.push(r[t]);}return o}var Ti=["circle","square","rectangle","triangle","sphere","cube","cylinder","cone"],wu=["radius","side","width","height","base","length"];function ku(r,e,o){let t=i=>({error:`the ${r} of a ${e} needs its ${i}`}),n={error:`the ${r} of a ${e} is not one of the shapes this supports`};switch(`${r}:${e}`){case "area:circle":{let i=F(o,["radius"]);return i?{value:Pe*i[0]**2}:t("radius")}case "perimeter:circle":case "circumference:circle":{let i=F(o,["radius"]);return i?{value:2*Pe*i[0]}:t("radius")}case "area:square":{let i=F(o,["side"]);return i?{value:i[0]**2}:t("side")}case "perimeter:square":{let i=F(o,["side"]);return i?{value:4*i[0]}:t("side")}case "area:rectangle":{let i=F(o,["width","height"]);return i?{value:i[0]*i[1]}:t("width and height")}case "perimeter:rectangle":{let i=F(o,["width","height"]);return i?{value:2*(i[0]+i[1])}:t("width and height")}case "area:triangle":{let i=F(o,["base","height"]);return i?{value:.5*i[0]*i[1]}:t("base and height")}case "volume:sphere":{let i=F(o,["radius"]);return i?{value:4/3*Pe*i[0]**3}:t("radius")}case "surface:sphere":{let i=F(o,["radius"]);return i?{value:4*Pe*i[0]**2}:t("radius")}case "volume:cube":{let i=F(o,["side"]);return i?{value:i[0]**3}:t("side")}case "surface:cube":{let i=F(o,["side"]);return i?{value:6*i[0]**2}:t("side")}case "volume:cylinder":{let i=F(o,["radius","height"]);return i?{value:Pe*i[0]**2*i[1]}:t("radius and height")}case "surface:cylinder":{let i=F(o,["radius","height"]);return i?{value:2*Pe*i[0]*(i[0]+i[1])}:t("radius and height")}case "volume:cone":{let i=F(o,["radius","height"]);return i?{value:1/3*Pe*i[0]**2*i[1]}:t("radius and height")}default:return n}}var wd=new Set(Ti),kd=new Set(wu);function Fe(r){return {category:"Geometry",parse(e,o,t){let n=e.peek(),i=(n?.value??"").toLowerCase();if(!n||n.type!=="IDENT"||!wd.has(i))throw chunkNAZ6PGLS_cjs.c.parsing("GEOMETRY_EXPECTED_SHAPE",`Expected a shape (${Ti.join(", ")}) after "${r} of" but got ${n?`"${n.value}"`:"end of input"}`);e.consume(),t.emitOpcode(13),t.emitString(r),t.emitOpcode(13),t.emitString(i);let a=2;for(;;){let s=e.peek(),l=(s?.value??"").toLowerCase();if(!s||s.type!=="IDENT"||!kd.has(l))break;e.consume(),t.emitOpcode(13),t.emitString(l),a++,e.parseExpression(chunkFVQWN5HZ_cjs.a.Call,t),a++,e.peek()?.type==="COMMA"&&e.consume();}t.emitPluginCall("geometryCompute",a);}}}var Ni={name:"solve-geometry",phrases:{"area of":"AREA_OF","perimeter of":"PERIMETER_OF","circumference of":"CIRCUMFERENCE_OF","volume of":"VOLUME_OF","surface area of":"SURFACE_AREA_OF"},prefixParselets:{AREA_OF:Fe("area"),PERIMETER_OF:Fe("perimeter"),CIRCUMFERENCE_OF:Fe("circumference"),VOLUME_OF:Fe("volume"),SURFACE_AREA_OF:Fe("surface")},pluginFunctions:{geometryCompute:r=>{let e=String(r[0]?.value??""),o=String(r[1]?.value??""),t={};for(let i=2;i+1<r.length;i+=2){let a=String(r[i]?.value??""),s=r[i+1];if(s?.type===13)return s;t[a]=s?.toNumber()??NaN;}let n=ku(e,o,t);return n.error!==void 0?chunk6U66HQKQ_cjs.P("GEOMETRY_ERROR",n.error):chunk6U66HQKQ_cjs.n(n.value)}},tokenCategories:{AREA_OF:"function",PERIMETER_OF:"function",CIRCUMFERENCE_OF:"function",VOLUME_OF:"function",SURFACE_AREA_OF:"function"}};var Md={"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 Mu(r){return Md[r.toLowerCase()]??null}function z(r){return {category:"Constants",parse(e,o,t){t.emitOpcode(13),t.emitString(r),t.emitPluginCall("constantValue",1);}}}var yi={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:z("speed of light"),ELECTRON_MASS:z("electron mass"),PROTON_MASS:z("proton mass"),ELEMENTARY_CHARGE:z("elementary charge"),GAS_CONSTANT:z("gas constant"),GOLDEN_RATIO:z("golden ratio"),GRAVITY:z("gravity"),AVOGADRO:z("avogadro"),PLANCK:z("planck"),BOLTZMANN:z("boltzmann"),TAU:z("tau"),PHI:z("phi")},pluginFunctions:{constantValue:r=>{let e=r[0]?.type===3?r[0].value:"",o=Mu(e);return o===null?chunk6U66HQKQ_cjs.P("UNKNOWN_CONSTANT",`"${e}" is not a known constant`):o.unit?chunk6U66HQKQ_cjs.u(o.value,o.unit):chunk6U66HQKQ_cjs.n(o.value)}},tokenCategories:{SPEED_OF_LIGHT:"keyword",ELECTRON_MASS:"keyword",PROTON_MASS:"keyword",ELEMENTARY_CHARGE:"keyword",GAS_CONSTANT:"keyword",GOLDEN_RATIO:"keyword",GRAVITY:"keyword",AVOGADRO:"keyword",PLANCK:"keyword",BOLTZMANN:"keyword",TAU:"keyword",PHI:"keyword"}};function Bu(r,e){return r/(e*e)}function Uu(r,e){return r*60/e}function Du(r,e){let o=e/r,t=Math.floor(o),n=Math.round((o-t)*60);return n===60&&(t+=1,n=0),`${t}:${n.toString().padStart(2,"0")}`}var gi={bmi:"healthBmi",pace:"healthPace",speed:"healthSpeed"},bu="HEALTH_CALL",Bd=chunk5IJD5L3O_cjs.c(bu);function Vu(r=80){let e="health:call";return {name:e,priority:r,startTokenTypes:["IDENT"],match(o,t){let n=o[t];if(!n||n.type!=="IDENT")return null;let i=(n.value??"").toLowerCase();return !(i in gi)||o[t+1]?.type!=="LPAREN"||o[t-1]?.type==="COLON"?null:{consumed:1,replacement:[new chunkFAGFPVYK_cjs.a(bu,Bd,i,n.value,n.offset,0,n.line,n.col)],ruleName:e}}}}var Bo=class{constructor(){this.category="Health";}parse(e,o,t){let n=gi[o.value];if(n===void 0)throw chunkNAZ6PGLS_cjs.c.execution("UNKNOWN_FUNCTION",`Unknown health function: ${o.value}`,{functionName:o.value});e.consume("LPAREN");let i=0;if(e.peek()?.type!=="RPAREN")for(e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,t),i++;e.match("COMMA");)e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,t),i++;e.consume("RPAREN"),t.emitPluginCall(n,i);}};function He(r){return r?.type===0?r.value:r?.type===6?r.toNumber():null}var Pi={name:"solve-health",prefixParselets:{HEALTH_CALL:new Bo},normalizerRules:[Vu()],pluginFunctions:{healthBmi:r=>{let e=He(r[0]),o=He(r[1]);return e===null||o===null||o===0?chunk6U66HQKQ_cjs.P("HEALTH_BAD_INPUT","bmi(weight in kg, height in m), e.g. bmi(70, 1.75)"):chunk6U66HQKQ_cjs.n(Bu(e,o))},healthPace:r=>{let e=He(r[0]),o=He(r[1]);return e===null||o===null||e===0?chunk6U66HQKQ_cjs.P("HEALTH_BAD_INPUT","pace(distance in km, time in min), e.g. pace(10, 50)"):chunk6U66HQKQ_cjs.t(`${Du(e,o)} /km`)},healthSpeed:r=>{let e=He(r[0]),o=He(r[1]);return e===null||o===null||o===0?chunk6U66HQKQ_cjs.P("HEALTH_BAD_INPUT","speed(distance in km, time in min), e.g. speed(10, 50)"):chunk6U66HQKQ_cjs.u(Uu(e,o),"km/h")}},tokenCategories:{HEALTH_CALL:"function"}};var y0=[Ko,$o,Yo,Jo,cn,pn,fn,gn,_n,An,xn,Rn,chunkHDGARCI2_cjs.a,On,Cn,In,Sn,kn,Hn,Mn,Un,zn,Dn,Wn,jn,qn,Zn,Jn,ei,Fn,oi,ii,mi,ci,di,Ei,Ni,yi,Pi];
2
- exports.a=Ko;exports.b=$o;exports.c=Yo;exports.d=Jo;exports.e=cn;exports.f=pn;exports.g=fn;exports.h=gn;exports.i=Pn;exports.j=_n;exports.k=An;exports.l=xn;exports.m=Rn;exports.n=On;exports.o=Cn;exports.p=In;exports.q=Sn;exports.r=kn;exports.s=Mn;exports.t=Cm;exports.u=hm;exports.v=Un;exports.w=Dn;exports.x=Fn;exports.y=y0;//# sourceMappingURL=chunk-KKMLFYVW.cjs.map
3
- //# sourceMappingURL=chunk-KKMLFYVW.cjs.map