@malloy-publisher/app 0.0.228 → 0.0.230

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 (28) hide show
  1. package/dist/api-doc.yaml +102 -10
  2. package/dist/assets/EnvironmentPage-wa_EPkwK.js +1 -0
  3. package/dist/assets/{HomePage-Bkwc9Woc.js → HomePage-jnCrupQp.js} +1 -1
  4. package/dist/assets/{LightMode-Bum_KBpN.js → LightMode-DYbwNULZ.js} +1 -1
  5. package/dist/assets/MainPage-CuJLrPNI.js +2 -0
  6. package/dist/assets/MaterializationsPage-D_67x2ee.js +1 -0
  7. package/dist/assets/ModelPage-D5JtAWqR.js +1 -0
  8. package/dist/assets/PackagePage-BRwtqUSG.js +1 -0
  9. package/dist/assets/{RouteError-DmJLpLXm.js → RouteError-CBNNrnSD.js} +1 -1
  10. package/dist/assets/ThemeEditorPage-CTCeBneA.js +1 -0
  11. package/dist/assets/WorkbookPage-SN6f1RBm.js +1 -0
  12. package/dist/assets/{core-CEDZMHV1.es-_yGzNgNH.js → core-Dp3q5Ieu.es-CD5FvM2s.js} +10 -10
  13. package/dist/assets/{index-CdmFub34.js → index-B3Nn8Vm2.js} +459 -446
  14. package/dist/assets/index-BLCx1EdC.js +18 -0
  15. package/dist/assets/index-C_tJstcx.js +529 -0
  16. package/dist/assets/{index-CE9xhdra.js → index-CfmBVB6M.js} +1 -1
  17. package/dist/assets/{index-OEjKNSYb.js → index-DU4r7GdU.js} +573 -413
  18. package/dist/index.html +1 -1
  19. package/package.json +2 -2
  20. package/dist/assets/EnvironmentPage-EW2lbGvb.js +0 -1
  21. package/dist/assets/MainPage-oiEy7TNM.js +0 -2
  22. package/dist/assets/MaterializationsPage-C_VJsTgU.js +0 -1
  23. package/dist/assets/ModelPage-z8REqAmk.js +0 -1
  24. package/dist/assets/PackagePage-C2Vtt1Ln.js +0 -1
  25. package/dist/assets/ThemeEditorPage-BywFjC7A.js +0 -1
  26. package/dist/assets/WorkbookPage-DCMizDMR.js +0 -1
  27. package/dist/assets/index-DDMrjIT3.js +0 -18
  28. package/dist/assets/index-EqslXZ44.js +0 -527
@@ -0,0 +1,18 @@
1
+ import{aJ as mi}from"./index-C_tJstcx.js";import{r as gi}from"./index-w_0OQJgZ.js";function yi(f,ie){for(var W=0;W<ie.length;W++){const P=ie[W];if(typeof P!="string"&&!Array.isArray(P)){for(const k in P)if(k!=="default"&&!(k in f)){const $=Object.getOwnPropertyDescriptor(P,k);$&&Object.defineProperty(f,k,$.get?$:{enumerable:!0,get:()=>P[k]})}}}return Object.freeze(Object.defineProperty(f,Symbol.toStringTag,{value:"Module"}))}var Et={},dt={},Vr;function Ct(){if(Vr)return dt;Vr=1,Object.defineProperty(dt,"__esModule",{value:!0}),dt.isChainOp=f,dt.isStringCondition=ie,dt.isStringFilter=W,dt.isBooleanFilter=P,dt.isNumberFilter=k,dt.isTemporalFilter=$,dt.isFilterExpression=w,dt.isFilterable=y;function f(o){return["and","or",","].includes(o)}function ie(o){return["starts","ends","contains","="].includes(o.operator)}function W(o){return typeof o=="object"&&o!==null&&"operator"in o&&typeof o.operator=="string"&&["starts","ends","contains","=","~","null","none","empty","and","or",",","()"].includes(o.operator)}function P(o){return typeof o=="object"&&o!==null&&"operator"in o&&typeof o.operator=="string"&&["null","none","true","false","=false","=true"].includes(o.operator)}function k(o){return typeof o=="object"&&o!==null&&"operator"in o&&typeof o.operator=="string"&&["range","<=",">=","!=","=",">","<","and","or","()","null","none"].includes(o.operator)}function $(o){return typeof o=="object"&&o!==null&&"operator"in o&&typeof o.operator=="string"&&["literal","before","after","to","for","in","and","or","in_last","this","last","next","()","null","none"].includes(o.operator)}function w(o){return typeof o=="object"&&o!==null&&"operator"in o}function y(o){return["string","number","boolean","timestamp","timestamptz","date"].includes(o)}return dt}var Mt={},Lr;function vi(){return Lr||(Lr=1,Object.defineProperty(Mt,"__esModule",{value:!0}),Mt.BooleanFilterExpression=void 0,Mt.BooleanFilterExpression={parse(f){var ie;if(f.match(/^\s*$/))return{parsed:null,log:[]};const W={parsed:null,log:[]};let P=f.toLowerCase().trim().replace(/\s\s+/," "),k=!1;if(P.startsWith("not ")&&(k=!0,P=P.slice(4)),P==="true")W.parsed={operator:"true"};else if(P==="=true")W.parsed={operator:"=true"};else if(P==="false")W.parsed={operator:"false"};else if(P==="=false")W.parsed={operator:"=false"};else if(P==="null")W.parsed={operator:"null"};else if(P==="none")W.parsed={operator:"none"};else{const $=f.match(/[^\s]/),w=$&&(ie=$.index)!==null&&ie!==void 0?ie:0;W.log=[{message:`Illegal boolean filter '${P}'. Must be one of true,=true,false,=false,null,none`,severity:"error",startIndex:w,endIndex:w+f.length-1}]}return k&&W.parsed&&(W.parsed.not=!0),W},unparse(f){return f===null?"":(f.not?"not ":"")+f.operator}}),Mt}var yr={},ze={},Ir;function Xt(){if(Ir)return ze;Ir=1,Object.defineProperty(ze,"__esModule",{value:!0}),ze.maybeNot=ie,ze.unescape=W,ze.escape=P,ze.matchOp=$,ze.conjoin=y,ze.joinNumbers=o,ze.mkRange=d,ze.mkValues=e,ze.numNot=C,ze.temporalNot=N,ze.joinTemporal=Z,ze.timeLiteral=ne,ze.mkUnits=pe;const f=Ct();function ie(O){const[A,F]=O;return A&&F&&(0,f.isStringFilter)(F)?{...F,not:!0}:F}function W(O){return O.replace(/\\(.)/g,"$1")}function P(O){const A=O.toLowerCase();return A==="null"||A==="empty"||A==="none"?"\\"+O:O.replace(/([,; |()\\%_-])/g,"\\$1")}function k(O){let A=!1,F=!1,G=0,he=!1;const Fe=O.length;for(let we=0;we<Fe;we+=1){const He=O[we];if(He===" "||He===" "){G+=1;continue}G=0,He==="%"?(he=!0,we===0&&(A=!0),F=!0):(F=!1,He==="\\"?we+=1:He==="_"&&(he=!0))}return{hasLike:he,percentEnd:F&&Fe>1,percentStart:A&&Fe>1,endSpace:G}}function $(O){let A=O.trimStart();const{hasLike:F,percentEnd:G,percentStart:he,endSpace:Fe}=k(A);if(Fe>0&&(A=A.slice(0,-Fe)),F){if(he&&G){const we=A.slice(1,-1);if(!k(we).hasLike&&we.length>0)return{operator:"contains",values:[W(we)]}}else if(G){const we=A.slice(0,-1);if(!k(we).hasLike)return{operator:"starts",values:[W(we)]}}else if(he){const we=A.slice(1);if(!k(we).hasLike)return{operator:"ends",values:[W(we)]}}return{operator:"~",escaped_values:[A]}}return A.toLowerCase()==="null"?{operator:"null"}:A.toLowerCase()==="empty"?{operator:"empty"}:A.toLowerCase()==="none"?{operator:"none"}:{operator:"=",values:[W(A)]}}function w(O,A){var F,G;return O.operator===A.operator&&((F=O.not)!==null&&F!==void 0?F:!1)===((G=A.not)!==null&&G!==void 0?G:!1)}function y(O,A,F){if(A=A.toLowerCase(),(0,f.isStringFilter)(O)&&(0,f.isStringFilter)(F)){if(A===","){if(O.operator==="~"&&w(O,F))return{...O,escaped_values:[...O.escaped_values,...F.escaped_values]};if((0,f.isStringCondition)(O)&&w(O,F))return{...O,values:[...O.values,...F.values]}}const G=A===","?",":A==="|"?"or":A===";"?"and":void 0;if(G)return O.operator===G?{...O,members:[...O.members,F]}:{operator:G,members:[O,F]}}return null}function o(O,A,F){if(A=A.toLowerCase(),(0,f.isNumberFilter)(O)&&(0,f.isNumberFilter)(F)){if(A==="or"&&O.operator==="="&&w(O,F)){const G={operator:"=",values:[...O.values,...F.values]};return O.not&&(G.not=!0),G}if(A==="and"||A==="or")return O.operator===A?{...O,members:[...O.members,F]}:{operator:A,members:[O,F]}}return null}function d(O,A,F,G){return{operator:"range",startValue:A,startOperator:O==="("?">":">=",endValue:F,endOperator:G===")"?"<":"<="}}function e(O,A){return{values:[O,...A]}}function C(O,A){return(0,f.isNumberFilter)(O)&&A?O.operator==="="?{operator:"!=",values:O.values}:O.operator==="!="?{operator:"=",values:O.values}:{...O,not:!0}:O}function N(O,A){if((0,f.isTemporalFilter)(O)&&A){if("not"in O){const F={...O};return O.not?delete F.not:F.not=!0,F}return{...O,not:!0}}return O}function Z(O,A,F){return A=A.toLowerCase(),(0,f.isTemporalFilter)(O)&&(0,f.isTemporalFilter)(F)&&(A==="and"||A==="or")?O.operator===A?{...O,members:[...O.members,F]}:{operator:A,members:[O,F]}:null}function ne(O,A){const F={moment:"literal",literal:O};return A&&(F.units=A),F}function pe(O){switch(O.toLowerCase()){case"second":case"seconds":return"second";case"minute":case"minutes":return"minute";case"hour":case"hours":return"hour";case"day":case"days":return"day";case"week":case"weeks":return"week";case"month":case"months":return"month";case"quarter":case"quarters":return"quarter";case"year":case"years":return"year"}}return ze}var vr,Cr;function wi(){if(Cr)return vr;Cr=1;const{numNot:f,mkRange:ie,joinNumbers:W,mkValues:P}=Xt();function k(o,d){function e(){this.constructor=o}e.prototype=d.prototype,o.prototype=new e}function $(o,d,e,C){var N=Error.call(this,o);return Object.setPrototypeOf&&Object.setPrototypeOf(N,$.prototype),N.expected=d,N.found=e,N.location=C,N.name="SyntaxError",N}k($,Error);function w(o,d,e){return e=e||" ",o.length>d?o:(d-=o.length,e+=e.repeat(d),o+e.slice(0,d))}$.prototype.format=function(o){var d="Error: "+this.message;if(this.location){var e=null,C;for(C=0;C<o.length;C++)if(o[C].source===this.location.source){e=o[C].text.split(/\r\n|\n|\r/g);break}var N=this.location.start,Z=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(N):N,ne=this.location.source+":"+Z.line+":"+Z.column;if(e){var pe=this.location.end,O=w("",Z.line.toString().length," "),A=e[N.line-1],F=N.line===pe.line?pe.column:A.length+1,G=F-N.column||1;d+=`
2
+ --> `+ne+`
3
+ `+O+` |
4
+ `+Z.line+" | "+A+`
5
+ `+O+" | "+w("",N.column-1," ")+w("",G,"^")}else d+=`
6
+ at `+ne}return d},$.buildMessage=function(o,d){var e={literal:function(A){return'"'+N(A.text)+'"'},class:function(A){var F=A.parts.map(function(G){return Array.isArray(G)?Z(G[0])+"-"+Z(G[1]):Z(G)});return"["+(A.inverted?"^":"")+F.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(A){return A.description}};function C(A){return A.charCodeAt(0).toString(16).toUpperCase()}function N(A){return A.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(F){return"\\x0"+C(F)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(F){return"\\x"+C(F)})}function Z(A){return A.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(F){return"\\x0"+C(F)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(F){return"\\x"+C(F)})}function ne(A){return e[A.type](A)}function pe(A){var F=A.map(ne),G,he;if(F.sort(),F.length>0){for(G=1,he=1;G<F.length;G++)F[G-1]!==F[G]&&(F[he]=F[G],he++);F.length=he}switch(F.length){case 1:return F[0];case 2:return F[0]+" or "+F[1];default:return F.slice(0,-1).join(", ")+", or "+F[F.length-1]}}function O(A){return A?'"'+N(A)+'"':"end of input"}return"Expected "+pe(o)+" but "+O(d)+" found."};function y(o,d){d=d!==void 0?d:{};var e={},C=d.grammarSource,N={numberFilter:Dt},Z=Dt,ne="(",pe=")",O="!=",A=",",F="=",G="<=",he=">=",Fe="[",we="]",He="-",Te=".",me="not",Qe="null",nt="none",Re="and",je="or",at="to",st=/^[<>]/,ke=/^[0-9]/,Ce=/^[Ee]/,De=/^[+\-]/,lt=/^[a-zA-Z]/,Me=/^[ \t]/,Oe=xe("(",!1),Ee=xe(")",!1),Ze=xe("!=",!1),Ne=xe(",",!1),Ke=xe("=",!1),Ye=xe("<=",!1),q=xe(">=",!1),m=wt(["<",">"],!1,!1),S=xe("[",!1),V=xe("]",!1),E=xe("-",!1),B=wt([["0","9"]],!1,!1),z=xe(".",!1),_e=wt(["E","e"],!1,!1),Be=wt(["+","-"],!1,!1),it=xe("not",!0),Je=xe("null",!0),x=xe("none",!0),Xe=xe("and",!0),Ae=xe("or",!0),et=xe("to",!0),mt=wt([["a","z"],["A","Z"]],!1,!1),vt=tr("whitespace"),We=wt([" "," "],!1,!1),ft=function(h,v){return v.reduce((R,[,D,,ee])=>W(R,D,ee),h)},qe=function(h,v){return f(v,h)},Ge=function(h){return h},I=function(){return{operator:"null"}},_=function(){return{operator:"none"}},se=function(h){return{operator:"()",expr:h}},Y=function(h,v,R,D){return ie(h,v,R,D)},de=function(h,v){return{operator:"!=",...P(h,v.map(R=>R[3]))}},be=function(h,v){return{operator:"=",...P(h,v.map(R=>R[3]))}},ut=function(h,v){return{operator:h,values:[v]}},tt=function(h,v){return{operator:"=",...P(h,v.map(R=>R[3]))}},St=function(){return"["},g=function(){return"("},t=function(){return"]"},a=function(){return")"},l=function(h){return h},b=function(){return"or"},L=function(){return"and"},K=function(){return"not"},u=d.peg$currPos|0,X=[{line:1,column:1}],ue=u,ot=d.peg$maxFailExpected||[],J=d.peg$silentFails|0,bt;if(d.startRule){if(!(d.startRule in N))throw new Error(`Can't start parsing from rule "`+d.startRule+'".');Z=N[d.startRule]}function xe(h,v){return{type:"literal",text:h,ignoreCase:v}}function wt(h,v,R){return{type:"class",parts:h,inverted:v,ignoreCase:R}}function er(){return{type:"end"}}function tr(h){return{type:"other",description:h}}function jt(h){var v=X[h],R;if(v)return v;if(h>=X.length)R=X.length-1;else for(R=h;!X[--R];);for(v=X[R],v={line:v.line,column:v.column};R<h;)o.charCodeAt(R)===10?(v.line++,v.column=1):v.column++,R++;return X[h]=v,v}function Wt(h,v,R){var D=jt(h),ee=jt(v),Q={source:C,start:{offset:h,line:D.line,column:D.column},end:{offset:v,line:ee.line,column:ee.column}};return Q}function te(h){u<ue||(u>ue&&(ue=u,ot=[]),ot.push(h))}function rr(h,v,R){return new $($.buildMessage(h,v),h,v,R)}function Dt(){var h,v,R,D,ee,Q,U,H;if(h=u,v=Nt(),v!==e){for(R=[],D=u,ee=ge(),Q=Yt(),Q!==e?(U=ge(),H=Nt(),H!==e?(ee=[ee,Q,U,H],D=ee):(u=D,D=e)):(u=D,D=e);D!==e;)R.push(D),D=u,ee=ge(),Q=Yt(),Q!==e?(U=ge(),H=Nt(),H!==e?(ee=[ee,Q,U,H],D=ee):(u=D,D=e)):(u=D,D=e);h=ft(v,R)}else u=h,h=e;return h}function Nt(){var h,v,R;return h=u,v=ar(),v!==e?(ge(),R=zt(),R!==e?h=qe(v,R):(u=h,h=e)):(u=h,h=e),h===e&&(h=u,v=zt(),v!==e&&(v=Ge(v)),h=v),h}function zt(){var h,v,R,D,ee,Q,U,H,ce,ve;if(h=u,v=sr(),v!==e&&(v=I()),h=v,h===e&&(h=u,v=or(),v!==e&&(v=_()),h=v,h===e&&(h=u,o.charCodeAt(u)===40?(v=ne,u++):(v=e,J===0&&te(Oe)),v!==e?(R=ge(),D=Dt(),D!==e?(ee=ge(),o.charCodeAt(u)===41?(Q=pe,u++):(Q=e,J===0&&te(Ee)),Q!==e?h=se(D):(u=h,h=e)):(u=h,h=e)):(u=h,h=e),h===e&&(h=u,v=nr(),v!==e?(R=ge(),D=rt(),D!==e?(ee=ge(),Q=ur(),Q!==e?(U=ge(),H=rt(),H!==e?(ce=ge(),ve=ir(),ve!==e?h=Y(v,D,H,ve):(u=h,h=e)):(u=h,h=e)):(u=h,h=e)):(u=h,h=e)):(u=h,h=e),h===e)))){if(h=u,o.substr(u,2)===O?(v=O,u+=2):(v=e,J===0&&te(Ze)),v!==e)if(R=ge(),D=rt(),D!==e){for(ee=[],Q=u,U=ge(),o.charCodeAt(u)===44?(H=A,u++):(H=e,J===0&&te(Ne)),H!==e?(ce=ge(),ve=rt(),ve!==e?(U=[U,H,ce,ve],Q=U):(u=Q,Q=e)):(u=Q,Q=e);Q!==e;)ee.push(Q),Q=u,U=ge(),o.charCodeAt(u)===44?(H=A,u++):(H=e,J===0&&te(Ne)),H!==e?(ce=ge(),ve=rt(),ve!==e?(U=[U,H,ce,ve],Q=U):(u=Q,Q=e)):(u=Q,Q=e);h=de(D,ee)}else u=h,h=e;else u=h,h=e;if(h===e){if(h=u,o.charCodeAt(u)===61?(v=F,u++):(v=e,J===0&&te(Ke)),v!==e)if(R=ge(),D=rt(),D!==e){for(ee=[],Q=u,U=ge(),o.charCodeAt(u)===44?(H=A,u++):(H=e,J===0&&te(Ne)),H!==e?(ce=ge(),ve=rt(),ve!==e?(U=[U,H,ce,ve],Q=U):(u=Q,Q=e)):(u=Q,Q=e);Q!==e;)ee.push(Q),Q=u,U=ge(),o.charCodeAt(u)===44?(H=A,u++):(H=e,J===0&&te(Ne)),H!==e?(ce=ge(),ve=rt(),ve!==e?(U=[U,H,ce,ve],Q=U):(u=Q,Q=e)):(u=Q,Q=e);h=be(D,ee)}else u=h,h=e;else u=h,h=e;if(h===e&&(h=u,v=u,o.substr(u,2)===G?(R=G,u+=2):(R=e,J===0&&te(Ye)),R===e&&(o.substr(u,2)===he?(R=he,u+=2):(R=e,J===0&&te(q)),R===e&&(R=o.charAt(u),st.test(R)?u++:(R=e,J===0&&te(m)))),R!==e?v=o.substring(v,u):v=R,v!==e?(R=ge(),D=rt(),D!==e?h=ut(v,D):(u=h,h=e)):(u=h,h=e),h===e))if(h=u,v=rt(),v!==e){for(R=[],D=u,ee=ge(),o.charCodeAt(u)===44?(Q=A,u++):(Q=e,J===0&&te(Ne)),Q!==e?(U=ge(),H=rt(),H!==e?(ee=[ee,Q,U,H],D=ee):(u=D,D=e)):(u=D,D=e);D!==e;)R.push(D),D=u,ee=ge(),o.charCodeAt(u)===44?(Q=A,u++):(Q=e,J===0&&te(Ne)),Q!==e?(U=ge(),H=rt(),H!==e?(ee=[ee,Q,U,H],D=ee):(u=D,D=e)):(u=D,D=e);h=tt(v,R)}else u=h,h=e}}return h}function nr(){var h,v;return h=u,o.charCodeAt(u)===91?(v=Fe,u++):(v=e,J===0&&te(S)),v!==e&&(v=St()),h=v,h===e&&(h=u,o.charCodeAt(u)===40?(v=ne,u++):(v=e,J===0&&te(Oe)),v!==e&&(v=g()),h=v),h}function ir(){var h,v;return h=u,o.charCodeAt(u)===93?(v=we,u++):(v=e,J===0&&te(V)),v!==e&&(v=t()),h=v,h===e&&(h=u,o.charCodeAt(u)===41?(v=pe,u++):(v=e,J===0&&te(Ee)),v!==e&&(v=a()),h=v),h}function rt(){var h,v,R,D,ee,Q,U,H,ce,ve;if(h=u,v=u,R=u,o.charCodeAt(u)===45?(D=He,u++):(D=e,J===0&&te(E)),D===e&&(D=null),ee=u,Q=[],U=o.charAt(u),ke.test(U)?u++:(U=e,J===0&&te(B)),U!==e)for(;U!==e;)Q.push(U),U=o.charAt(u),ke.test(U)?u++:(U=e,J===0&&te(B));else Q=e;if(Q!==e){for(o.charCodeAt(u)===46?(U=Te,u++):(U=e,J===0&&te(z)),U===e&&(U=null),H=[],ce=o.charAt(u),ke.test(ce)?u++:(ce=e,J===0&&te(B));ce!==e;)H.push(ce),ce=o.charAt(u),ke.test(ce)?u++:(ce=e,J===0&&te(B));Q=[Q,U,H],ee=Q}else u=ee,ee=e;if(ee===e){for(ee=u,Q=[],U=o.charAt(u),ke.test(U)?u++:(U=e,J===0&&te(B));U!==e;)Q.push(U),U=o.charAt(u),ke.test(U)?u++:(U=e,J===0&&te(B));if(o.charCodeAt(u)===46?(U=Te,u++):(U=e,J===0&&te(z)),U!==e){if(H=[],ce=o.charAt(u),ke.test(ce)?u++:(ce=e,J===0&&te(B)),ce!==e)for(;ce!==e;)H.push(ce),ce=o.charAt(u),ke.test(ce)?u++:(ce=e,J===0&&te(B));else H=e;H!==e?(Q=[Q,U,H],ee=Q):(u=ee,ee=e)}else u=ee,ee=e}if(ee!==e){if(Q=u,U=o.charAt(u),Ce.test(U)?u++:(U=e,J===0&&te(_e)),U!==e){if(H=o.charAt(u),De.test(H)?u++:(H=e,J===0&&te(Be)),H===e&&(H=null),ce=[],ve=o.charAt(u),ke.test(ve)?u++:(ve=e,J===0&&te(B)),ve!==e)for(;ve!==e;)ce.push(ve),ve=o.charAt(u),ke.test(ve)?u++:(ve=e,J===0&&te(B));else ce=e;ce!==e?(U=[U,H,ce],Q=U):(u=Q,Q=e)}else u=Q,Q=e;Q===e&&(Q=null),D=[D,ee,Q],R=D}else u=R,R=e;return R!==e?v=o.substring(v,u):v=R,v!==e&&(v=l(v)),h=v,h}function Yt(){var h,v;return h=u,v=fr(),v!==e&&(v=b()),h=v,h===e&&(h=u,v=lr(),v!==e&&(v=L()),h=v),h}function ar(){var h,v,R,D;return h=u,v=o.substr(u,3),v.toLowerCase()===me?u+=3:(v=e,J===0&&te(it)),v!==e?(R=u,J++,D=_t(),J--,D===e?R=void 0:(u=R,R=e),R!==e?h=K():(u=h,h=e)):(u=h,h=e),h}function sr(){var h,v,R,D;return h=u,v=o.substr(u,4),v.toLowerCase()===Qe?u+=4:(v=e,J===0&&te(Je)),v!==e?(R=u,J++,D=_t(),J--,D===e?R=void 0:(u=R,R=e),R!==e?(v=[v,R],h=v):(u=h,h=e)):(u=h,h=e),h}function or(){var h,v,R,D;return h=u,v=o.substr(u,4),v.toLowerCase()===nt?u+=4:(v=e,J===0&&te(x)),v!==e?(R=u,J++,D=_t(),J--,D===e?R=void 0:(u=R,R=e),R!==e?(v=[v,R],h=v):(u=h,h=e)):(u=h,h=e),h}function lr(){var h,v,R,D;return h=u,v=o.substr(u,3),v.toLowerCase()===Re?u+=3:(v=e,J===0&&te(Xe)),v!==e?(R=u,J++,D=_t(),J--,D===e?R=void 0:(u=R,R=e),R!==e?(v=[v,R],h=v):(u=h,h=e)):(u=h,h=e),h}function fr(){var h,v,R,D;return h=u,v=o.substr(u,2),v.toLowerCase()===je?u+=2:(v=e,J===0&&te(Ae)),v!==e?(R=u,J++,D=_t(),J--,D===e?R=void 0:(u=R,R=e),R!==e?(v=[v,R],h=v):(u=h,h=e)):(u=h,h=e),h}function ur(){var h,v,R,D;return h=u,v=o.substr(u,2),v.toLowerCase()===at?u+=2:(v=e,J===0&&te(et)),v!==e?(R=u,J++,D=_t(),J--,D===e?R=void 0:(u=R,R=e),R!==e?(v=[v,R],h=v):(u=h,h=e)):(u=h,h=e),h}function _t(){var h;return h=o.charAt(u),lt.test(h)?u++:(h=e,J===0&&te(mt)),h}function ge(){var h,v;for(J++,h=[],v=o.charAt(u),Me.test(v)?u++:(v=e,J===0&&te(We));v!==e;)h.push(v),v=o.charAt(u),Me.test(v)?u++:(v=e,J===0&&te(We));return J--,v=e,J===0&&te(vt),h}if(bt=Z(),d.peg$library)return{peg$result:bt,peg$currPos:u,peg$FAILED:e,peg$maxFailExpected:ot,peg$maxFailPos:ue};if(bt!==e&&u===o.length)return bt;throw bt!==e&&u<o.length&&te(er()),rr(ot,ue<o.length?o.charAt(ue):null,ue<o.length?Wt(ue,ue+1):Wt(ue,ue))}return vr={StartRules:["numberFilter"],SyntaxError:$,parse:y},vr}var Zt={},Dr;function $r(){if(Dr)return Zt;Dr=1,Object.defineProperty(Zt,"__esModule",{value:!0}),Zt.run_parser=W;const f=Ct();function ie(P){return P instanceof Error&&"location"in P}function W(P,k){try{const $=k(P);return(0,f.isFilterExpression)($)?{parsed:$,log:[]}:{parsed:null,log:[]}}catch($){if(ie($)){const w=$.location,y=w?w.start.offset:0,o=w?w.end.offset-1:P.length-1;return{parsed:null,log:[{message:$.message,startIndex:y,endIndex:Math.max(y,o),severity:"error"}]}}throw $}}return Zt}var Nr;function _i(){return Nr||(Nr=1,(function(f){Object.defineProperty(f,"__esModule",{value:!0}),f.NumberFilterExpression=void 0;const ie=Ct(),W=wi(),P=$r();f.NumberFilterExpression={parse(k){if(k.match(/^\s*$/))return{parsed:null,log:[]};const $=(0,P.run_parser)(k,W.parse);return $.parsed&&(0,ie.isNumberFilter)($.parsed)?{parsed:$.parsed,log:[]}:{parsed:null,log:$.log}},unparse(k){if(k===null)return"";switch(k.operator){case"=":return k.values.join(", ");case"!=":return"!= "+k.values.join(", ");case">":case"<":case"<=":case">=":return k.not?k.values.map($=>k.operator==="="?`not ${$}`:`not ${k.operator} ${$}`).join(", "):k.values.map($=>`${k.operator} ${$}`).join(", ");case"range":{const $=k.startOperator===">"?"(":"[",w=k.endOperator==="<"?")":"]",y=`${$}${k.startValue} to ${k.endValue}${w}`;return k.not?`not ${y}`:y}case"null":return k.not?"not null":"null";case"none":return k.not?"not none":"none";case"and":case"or":return k.members.map($=>f.NumberFilterExpression.unparse($)).join(` ${k.operator} `);case"()":{const $="("+f.NumberFilterExpression.unparse(k.expr)+")";return k.not?"not "+$:$}}return`no unparse for ${JSON.stringify(k)}`}}})(yr)),yr}var wr={},_r,xr;function Ai(){if(xr)return _r;xr=1;const{conjoin:f,maybeNot:ie,matchOp:W}=Xt();function P(y,o){function d(){this.constructor=y}d.prototype=o.prototype,y.prototype=new d}function k(y,o,d,e){var C=Error.call(this,y);return Object.setPrototypeOf&&Object.setPrototypeOf(C,k.prototype),C.expected=o,C.found=d,C.location=e,C.name="SyntaxError",C}P(k,Error);function $(y,o,d){return d=d||" ",y.length>o?y:(o-=y.length,d+=d.repeat(o),y+d.slice(0,o))}k.prototype.format=function(y){var o="Error: "+this.message;if(this.location){var d=null,e;for(e=0;e<y.length;e++)if(y[e].source===this.location.source){d=y[e].text.split(/\r\n|\n|\r/g);break}var C=this.location.start,N=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(C):C,Z=this.location.source+":"+N.line+":"+N.column;if(d){var ne=this.location.end,pe=$("",N.line.toString().length," "),O=d[C.line-1],A=C.line===ne.line?ne.column:O.length+1,F=A-C.column||1;o+=`
7
+ --> `+Z+`
8
+ `+pe+` |
9
+ `+N.line+" | "+O+`
10
+ `+pe+" | "+$("",C.column-1," ")+$("",F,"^")}else o+=`
11
+ at `+Z}return o},k.buildMessage=function(y,o){var d={literal:function(O){return'"'+C(O.text)+'"'},class:function(O){var A=O.parts.map(function(F){return Array.isArray(F)?N(F[0])+"-"+N(F[1]):N(F)});return"["+(O.inverted?"^":"")+A.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(O){return O.description}};function e(O){return O.charCodeAt(0).toString(16).toUpperCase()}function C(O){return O.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(A){return"\\x0"+e(A)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(A){return"\\x"+e(A)})}function N(O){return O.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(A){return"\\x0"+e(A)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(A){return"\\x"+e(A)})}function Z(O){return d[O.type](O)}function ne(O){var A=O.map(Z),F,G;if(A.sort(),A.length>0){for(F=1,G=1;F<A.length;F++)A[F-1]!==A[F]&&(A[G]=A[F],G++);A.length=G}switch(A.length){case 1:return A[0];case 2:return A[0]+" or "+A[1];default:return A.slice(0,-1).join(", ")+", or "+A[A.length-1]}}function pe(O){return O?'"'+C(O)+'"':"end of input"}return"Expected "+ne(y)+" but "+pe(o)+" found."};function w(y,o){o=o!==void 0?o:{};var d={},e=o.grammarSource,C={stringFilter:mt},N=mt,Z="-",ne="(",pe=")",O="\\",A=",",F=";",G="|",he=/^[^\n,;()|]/,Fe=/^[ \t]/,we=z("-",!1),He=z("(",!1),Te=z(")",!1),me=Je("match string"),Qe=z("\\",!1),nt=Be(),Re=_e([`
12
+ `,",",";","(",")","|"],!0,!1),je=z(",",!1),at=z(";",!1),st=z("|",!1),ke=Je("whitespace"),Ce=_e([" "," "],!1,!1),De=function(I,_){return _.reduce((se,[,Y,,de])=>f(se,Y,de),I)},lt=function(I){return ie([!0,I])},Me=function(I){return I},Oe=function(I){return{operator:"()",expr:I}},Ee=function(I){return W(I)},Ze=function(I){return I},Ne=function(){return","},Ke=function(){return";"},Ye=function(){return"|"},q=o.peg$currPos|0,m=[{line:1,column:1}],S=q,V=o.peg$maxFailExpected||[],E=o.peg$silentFails|0,B;if(o.startRule){if(!(o.startRule in C))throw new Error(`Can't start parsing from rule "`+o.startRule+'".');N=C[o.startRule]}function z(I,_){return{type:"literal",text:I,ignoreCase:_}}function _e(I,_,se){return{type:"class",parts:I,inverted:_,ignoreCase:se}}function Be(){return{type:"any"}}function it(){return{type:"end"}}function Je(I){return{type:"other",description:I}}function x(I){var _=m[I],se;if(_)return _;if(I>=m.length)se=m.length-1;else for(se=I;!m[--se];);for(_=m[se],_={line:_.line,column:_.column};se<I;)y.charCodeAt(se)===10?(_.line++,_.column=1):_.column++,se++;return m[I]=_,_}function Xe(I,_,se){var Y=x(I),de=x(_),be={source:e,start:{offset:I,line:Y.line,column:Y.column},end:{offset:_,line:de.line,column:de.column}};return be}function Ae(I){q<S||(q>S&&(S=q,V=[]),V.push(I))}function et(I,_,se){return new k(k.buildMessage(I,_),I,_,se)}function mt(){var I,_,se,Y,de,be,ut,tt;if(I=q,Ge(),_=vt(),_!==d){for(se=[],Y=q,de=Ge(),be=qe(),be!==d?(ut=Ge(),tt=vt(),tt!==d?(de=[de,be,ut,tt],Y=de):(q=Y,Y=d)):(q=Y,Y=d);Y!==d;)se.push(Y),Y=q,de=Ge(),be=qe(),be!==d?(ut=Ge(),tt=vt(),tt!==d?(de=[de,be,ut,tt],Y=de):(q=Y,Y=d)):(q=Y,Y=d);I=De(_,se)}else q=I,I=d;return I}function vt(){var I,_,se;return I=q,y.charCodeAt(q)===45?(_=Z,q++):(_=d,E===0&&Ae(we)),_!==d?(Ge(),se=We(),se!==d?I=lt(se):(q=I,I=d)):(q=I,I=d),I===d&&(I=q,_=We(),_!==d&&(_=Me(_)),I=_),I}function We(){var I,_,se,Y;return I=q,y.charCodeAt(q)===40?(_=ne,q++):(_=d,E===0&&Ae(He)),_!==d?(Ge(),se=mt(),se!==d?(Ge(),y.charCodeAt(q)===41?(Y=pe,q++):(Y=d,E===0&&Ae(Te)),Y!==d?I=Oe(se):(q=I,I=d)):(q=I,I=d)):(q=I,I=d),I===d&&(I=q,_=ft(),_!==d&&(_=Ee(_)),I=_),I}function ft(){var I,_,se,Y,de,be;if(E++,I=q,_=q,se=[],Y=q,y.charCodeAt(q)===92?(de=O,q++):(de=d,E===0&&Ae(Qe)),de!==d?(y.length>q?(be=y.charAt(q),q++):(be=d,E===0&&Ae(nt)),be!==d?(de=[de,be],Y=de):(q=Y,Y=d)):(q=Y,Y=d),Y===d&&(Y=y.charAt(q),he.test(Y)?q++:(Y=d,E===0&&Ae(Re))),Y!==d)for(;Y!==d;)se.push(Y),Y=q,y.charCodeAt(q)===92?(de=O,q++):(de=d,E===0&&Ae(Qe)),de!==d?(y.length>q?(be=y.charAt(q),q++):(be=d,E===0&&Ae(nt)),be!==d?(de=[de,be],Y=de):(q=Y,Y=d)):(q=Y,Y=d),Y===d&&(Y=y.charAt(q),he.test(Y)?q++:(Y=d,E===0&&Ae(Re)));else se=d;return se!==d?_=y.substring(_,q):_=se,_!==d&&(_=Ze(_)),I=_,E--,I===d&&(_=d,E===0&&Ae(me)),I}function qe(){var I,_;return I=q,y.charCodeAt(q)===44?(_=A,q++):(_=d,E===0&&Ae(je)),_!==d&&(_=Ne()),I=_,I===d&&(I=q,y.charCodeAt(q)===59?(_=F,q++):(_=d,E===0&&Ae(at)),_!==d&&(_=Ke()),I=_,I===d&&(I=q,y.charCodeAt(q)===124?(_=G,q++):(_=d,E===0&&Ae(st)),_!==d&&(_=Ye()),I=_)),I}function Ge(){var I,_;for(E++,I=[],_=y.charAt(q),Fe.test(_)?q++:(_=d,E===0&&Ae(Ce));_!==d;)I.push(_),_=y.charAt(q),Fe.test(_)?q++:(_=d,E===0&&Ae(Ce));return E--,_=d,E===0&&Ae(ke),I}if(B=N(),o.peg$library)return{peg$result:B,peg$currPos:q,peg$FAILED:d,peg$maxFailExpected:V,peg$maxFailPos:S};if(B!==d&&q===y.length)return B;throw B!==d&&q<y.length&&Ae(it()),et(V,S<y.length?y.charAt(S):null,S<y.length?Xe(S,S+1):Xe(S,S))}return _r={StartRules:["stringFilter"],SyntaxError:k,parse:w},_r}var Pr;function Ti(){return Pr||(Pr=1,(function(f){Object.defineProperty(f,"__esModule",{value:!0}),f.StringFilterExpression=void 0;const ie=Ct(),W=Ai(),P=Xt(),k=$r();f.StringFilterExpression={parse($){if($.match(/^\s*$/))return{parsed:null,log:[]};const w=(0,k.run_parser)($,W.parse);return w.parsed&&(0,ie.isStringFilter)(w.parsed)?{parsed:w.parsed,log:[]}:{parsed:null,log:w.log}},unparse($){if($===null)return"";switch($.operator){case"=":return $.not?$.values.map(w=>"-"+(0,P.escape)(w)).join(", "):$.values.map(w=>(0,P.escape)(w)).join(", ");case"~":return $.not?$.escaped_values.map(w=>"-"+w).join(", "):$.escaped_values.join(", ");case"starts":return $.not?$.values.map(w=>"-"+(0,P.escape)(w)+"%").join(", "):$.values.map(w=>(0,P.escape)(w)+"%").join(", ");case"ends":return $.not?$.values.map(w=>"-%"+(0,P.escape)(w)).join(", "):$.values.map(w=>"%"+(0,P.escape)(w)).join(", ");case"contains":return $.not?$.values.map(w=>"-%"+(0,P.escape)(w)+"%").join(", "):$.values.map(w=>"%"+(0,P.escape)(w)+"%").join(", ");case"or":return $.members.map(w=>f.StringFilterExpression.unparse(w)).join(" | ");case"and":return $.members.map(w=>f.StringFilterExpression.unparse(w)).join("; ");case",":return $.members.map(w=>f.StringFilterExpression.unparse(w)).join(", ");case"()":{const w="("+f.StringFilterExpression.unparse($.expr)+")";return $.not?"-"+w:w}case"null":return $.not?"-null":"null";case"empty":return $.not?"-empty":"empty";case"none":return $.not?"-none":"none"}}}})(wr)),wr}var Ar={},Tr,qr;function $i(){if(qr)return Tr;qr=1;const{temporalNot:f,joinTemporal:ie,timeLiteral:W,mkUnits:P}=Xt();function k(o,d){function e(){this.constructor=o}e.prototype=d.prototype,o.prototype=new e}function $(o,d,e,C){var N=Error.call(this,o);return Object.setPrototypeOf&&Object.setPrototypeOf(N,$.prototype),N.expected=d,N.found=e,N.location=C,N.name="SyntaxError",N}k($,Error);function w(o,d,e){return e=e||" ",o.length>d?o:(d-=o.length,e+=e.repeat(d),o+e.slice(0,d))}$.prototype.format=function(o){var d="Error: "+this.message;if(this.location){var e=null,C;for(C=0;C<o.length;C++)if(o[C].source===this.location.source){e=o[C].text.split(/\r\n|\n|\r/g);break}var N=this.location.start,Z=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(N):N,ne=this.location.source+":"+Z.line+":"+Z.column;if(e){var pe=this.location.end,O=w("",Z.line.toString().length," "),A=e[N.line-1],F=N.line===pe.line?pe.column:A.length+1,G=F-N.column||1;d+=`
13
+ --> `+ne+`
14
+ `+O+` |
15
+ `+Z.line+" | "+A+`
16
+ `+O+" | "+w("",N.column-1," ")+w("",G,"^")}else d+=`
17
+ at `+ne}return d},$.buildMessage=function(o,d){var e={literal:function(A){return'"'+N(A.text)+'"'},class:function(A){var F=A.parts.map(function(G){return Array.isArray(G)?Z(G[0])+"-"+Z(G[1]):Z(G)});return"["+(A.inverted?"^":"")+F.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(A){return A.description}};function C(A){return A.charCodeAt(0).toString(16).toUpperCase()}function N(A){return A.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(F){return"\\x0"+C(F)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(F){return"\\x"+C(F)})}function Z(A){return A.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(F){return"\\x0"+C(F)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(F){return"\\x"+C(F)})}function ne(A){return e[A.type](A)}function pe(A){var F=A.map(ne),G,he;if(F.sort(),F.length>0){for(G=1,he=1;G<F.length;G++)F[G-1]!==F[G]&&(F[he]=F[G],he++);F.length=he}switch(F.length){case 1:return F[0];case 2:return F[0]+" or "+F[1];default:return F.slice(0,-1).join(", ")+", or "+F[F.length-1]}}function O(A){return A?'"'+N(A)+'"':"end of input"}return"Expected "+pe(o)+" but "+O(d)+" found."};function y(o,d){d=d!==void 0?d:{};var e={},C=d.grammarSource,N={temporalFilter:cr},Z=cr,ne="(",pe=")",O="second",A="minute",F="hour",G="day",he="week",Fe="month",we="quarter",He="year",Te="s",me="-",Qe=":",nt="not",Re="null",je="none",at="to",st="now",ke="last",Ce="this",De="next",lt="ago",Me="from",Oe="before",Ee="after",Ze="through",Ne="starting",Ke="for",Ye="today",q="yesterday",m="tomorrow",S="and",V="or",E="monday",B="tuesday",z="wednesday",_e="thursday",Be="friday",it="saturday",Je="sunday",x=/^[0-9]/,Xe=/^[ Tt]/,Ae=/^[.,]/,et=/^[Ww]/,mt=/^[Kk]/,vt=/^[Qq]/,We=/^[1234]/,ft=/^[a-zA-Z]/,qe=/^[ \t]/,Ge=ae("(",!1),I=ae(")",!1),_=gt([["0","9"]],!1,!1),se=ae("second",!0),Y=ae("minute",!0),de=ae("hour",!0),be=ae("day",!0),ut=ae("week",!0),tt=ae("month",!0),St=ae("quarter",!0),g=ae("year",!0),t=ae("s",!0),a=ae("-",!1),l=gt([" ","T","t"],!1,!1),b=ae(":",!1),L=gt([".",","],!1,!1),K=gt(["W","w"],!1,!1),u=gt(["K","k"],!1,!1),X=gt(["Q","q"],!1,!1),ue=gt(["1","2","3","4"],!1,!1),ot=ae("not",!0),J=ae("null",!0),bt=ae("none",!0),xe=ae("to",!0),wt=ae("now",!0),er=ae("last",!0),tr=ae("this",!0),jt=ae("next",!0),Wt=ae("ago",!0),te=ae("from",!0),rr=ae("before",!0),Dt=ae("after",!0),Nt=ae("through",!0),zt=ae("starting",!0),nr=ae("for",!0),ir=ae("today",!0),rt=ae("yesterday",!0),Yt=ae("tomorrow",!0),ar=ae("and",!0),sr=ae("or",!0),or=ae("monday",!0),lr=ae("tuesday",!0),fr=ae("wednesday",!0),ur=ae("thursday",!0),_t=ae("friday",!0),ge=ae("saturday",!0),h=ae("sunday",!0),v=gt([["a","z"],["A","Z"]],!1,!1),R=Sr("optional whitespace"),D=gt([" "," "],!1,!1),ee=Sr("whitespace"),Q=function(n,s){return s.reduce((i,[,c,,M])=>ie(i,c,M),n)},U=function(n){return f(n,!0)},H=function(n){return n},ce=function(){return{operator:"null"}},ve=function(){return{operator:"none"}},Kr=function(n){return{operator:"()",expr:n}},Xr=function(n){return{operator:"before",before:n}},en=function(n){return{operator:"before",before:n,not:!0}},tn=function(n){return{operator:"after",after:n}},rn=function(n){return{operator:"after",after:n,not:!0}},nn=function(n,s){return{operator:n,...s}},an=function(n,s){return{operator:"to",fromMoment:n,toMoment:s}},sn=function(n,s){return{...s,operator:"for",begin:n}},on=function(n){return{operator:"in",in:n}},ln=function(n){return{operator:"in_last",...n}},fn=function(){return"last"},un=function(){return"next"},cn=function(n,s){return{units:s,n}},dn=function(n){return n},pn=function(n){return P(n)},hn=function(){return{moment:"now"}},mn=function(){return{moment:"today"}},gn=function(){return{moment:"yesterday"}},yn=function(){return{moment:"tomorrow"}},vn=function(n){return{moment:"ago",...n}},wn=function(n){return{moment:"from_now",...n}},_n=function(n){return{moment:n.toLowerCase(),which:"next"}},An=function(n){return{moment:n.toLowerCase(),which:"last"}},Tn=function(n,s){return{moment:n,units:s}},$n=function(n){return{moment:n.toLowerCase(),which:"last"}},Sn=function(n){return n},bn=function(){return"this"},Fn=function(){return"next"},On=function(){return"last"},En=function(n){return W(n)},kn=function(n){return W(n,"week")},Rn=function(n){return W(n,"quarter")},Vn=function(n){return W(n,"minute")},Ln=function(n){return W(n,"hour")},In=function(n){return W(n,"day")},Cn=function(n){return W(n,"month")},Dn=function(n){return W(n,"year")},Nn=function(n){return n},xn=function(){return"or"},Pn=function(){return"and"},r=d.peg$currPos|0,Lt=[{line:1,column:1}],ct=r,Jt=d.peg$maxFailExpected||[],p=d.peg$silentFails|0,xt;if(d.startRule){if(!(d.startRule in N))throw new Error(`Can't start parsing from rule "`+d.startRule+'".');Z=N[d.startRule]}function ae(n,s){return{type:"literal",text:n,ignoreCase:s}}function gt(n,s,i){return{type:"class",parts:n,inverted:s,ignoreCase:i}}function qn(){return{type:"end"}}function Sr(n){return{type:"other",description:n}}function br(n){var s=Lt[n],i;if(s)return s;if(n>=Lt.length)i=Lt.length-1;else for(i=n;!Lt[--i];);for(s=Lt[i],s={line:s.line,column:s.column};i<n;)o.charCodeAt(i)===10?(s.line++,s.column=1):s.column++,i++;return Lt[n]=s,s}function Fr(n,s,i){var c=br(n),M=br(s),j={source:C,start:{offset:n,line:c.line,column:c.column},end:{offset:s,line:M.line,column:M.column}};return j}function T(n){r<ct||(r>ct&&(ct=r,Jt=[]),Jt.push(n))}function Qn(n,s,i){return new $($.buildMessage(n,s),n,s,i)}function cr(){var n,s,i,c,M,j,re,oe;if(n=r,s=dr(),s!==e){for(i=[],c=r,M=It(),j=kr(),j!==e?(re=It(),oe=dr(),oe!==e?(M=[M,j,re,oe],c=M):(r=c,c=e)):(r=c,c=e);c!==e;)i.push(c),c=r,M=It(),j=kr(),j!==e?(re=It(),oe=dr(),oe!==e?(M=[M,j,re,oe],c=M):(r=c,c=e)):(r=c,c=e);n=Q(s,i)}else r=n,n=e;return n}function dr(){var n,s,i,c;return n=r,s=jn(),s!==e?(i=Ue(),i!==e?(c=Or(),c!==e?n=U(c):(r=n,n=e)):(r=n,n=e)):(r=n,n=e),n===e&&(n=r,s=Or(),s!==e&&(s=H(s)),n=s),n}function Or(){var n,s,i,c,M,j;return n=r,s=Wn(),s!==e&&(s=ce()),n=s,n===e&&(n=r,s=zn(),s!==e&&(s=ve()),n=s,n===e&&(n=r,o.charCodeAt(r)===40?(s=ne,r++):(s=e,p===0&&T(Ge)),s!==e?(i=It(),c=cr(),c!==e?(M=It(),o.charCodeAt(r)===41?(j=pe,r++):(j=e,p===0&&T(I)),j!==e?n=Kr(c):(r=n,n=e)):(r=n,n=e)):(r=n,n=e),n===e&&(n=r,s=Kn(),s!==e?(i=Ue(),i!==e?(c=At(),c!==e?n=Xr(c):(r=n,n=e)):(r=n,n=e)):(r=n,n=e),n===e&&(n=r,s=ti(),s!==e?(i=Ue(),i!==e?(c=At(),c!==e?n=en(c):(r=n,n=e)):(r=n,n=e)):(r=n,n=e),n===e&&(n=r,s=Xn(),s!==e?(i=Ue(),i!==e?(c=At(),c!==e?n=tn(c):(r=n,n=e)):(r=n,n=e)):(r=n,n=e),n===e&&(n=r,s=ei(),s!==e?(i=Ue(),i!==e?(c=At(),c!==e?n=rn(c):(r=n,n=e)):(r=n,n=e)):(r=n,n=e),n===e&&(n=r,s=Mn(),s!==e?(i=Ue(),i!==e?(c=Pt(),c!==e?n=nn(s,c):(r=n,n=e)):(r=n,n=e)):(r=n,n=e),n===e&&(n=r,s=At(),s!==e?(i=Ue(),i!==e?(c=Yn(),c!==e?(M=Ue(),M!==e?(j=At(),j!==e?n=an(s,j):(r=n,n=e)):(r=n,n=e)):(r=n,n=e)):(r=n,n=e)):(r=n,n=e),n===e&&(n=r,s=At(),s!==e?(i=Ue(),i!==e?(c=ri(),c!==e?(M=Ue(),M!==e?(j=Pt(),j!==e?n=sn(s,j):(r=n,n=e)):(r=n,n=e)):(r=n,n=e)):(r=n,n=e)):(r=n,n=e),n===e&&(n=r,s=At(),s!==e&&(s=on(s)),n=s,n===e&&(n=r,s=Pt(),s!==e&&(s=ln(s)),n=s))))))))))),n}function Mn(){var n,s;return n=r,s=hr(),s!==e&&(s=fn()),n=s,n===e&&(n=r,s=mr(),s!==e&&(s=un()),n=s),n}function Pt(){var n,s,i,c;return n=r,s=Bn(),s!==e?(i=Ue(),i!==e?(c=Er(),c!==e?n=cn(s,c):(r=n,n=e)):(r=n,n=e)):(r=n,n=e),n}function Bn(){var n,s,i,c;if(n=r,s=r,i=[],c=o.charAt(r),x.test(c)?r++:(c=e,p===0&&T(_)),c!==e)for(;c!==e;)i.push(c),c=o.charAt(r),x.test(c)?r++:(c=e,p===0&&T(_));else i=e;return i!==e?s=o.substring(s,r):s=i,s!==e&&(s=dn(s)),n=s,n}function Er(){var n,s,i,c,M;return n=r,s=r,i=o.substr(r,6),i.toLowerCase()===O?r+=6:(i=e,p===0&&T(se)),i===e&&(i=o.substr(r,6),i.toLowerCase()===A?r+=6:(i=e,p===0&&T(Y)),i===e&&(i=o.substr(r,4),i.toLowerCase()===F?r+=4:(i=e,p===0&&T(de)),i===e&&(i=o.substr(r,3),i.toLowerCase()===G?r+=3:(i=e,p===0&&T(be)),i===e&&(i=o.substr(r,4),i.toLowerCase()===he?r+=4:(i=e,p===0&&T(ut)),i===e&&(i=o.substr(r,5),i.toLowerCase()===Fe?r+=5:(i=e,p===0&&T(tt)),i===e&&(i=o.substr(r,7),i.toLowerCase()===we?r+=7:(i=e,p===0&&T(St)),i===e&&(i=o.substr(r,4),i.toLowerCase()===He?r+=4:(i=e,p===0&&T(g))))))))),i!==e?s=o.substring(s,r):s=i,s!==e?(i=o.charAt(r),i.toLowerCase()===Te?r++:(i=e,p===0&&T(t)),i===e&&(i=null),c=r,p++,M=ye(),p--,M===e?c=void 0:(r=c,c=e),c!==e?n=pn(s):(r=n,n=e)):(r=n,n=e),n}function At(){var n,s,i,c,M,j;return n=r,s=Rr(),s!==e&&(s=hn()),n=s,n===e&&(n=r,s=ni(),s!==e&&(s=mn()),n=s,n===e&&(n=r,s=ii(),s!==e&&(s=gn()),n=s,n===e&&(n=r,s=ai(),s!==e&&(s=yn()),n=s,n===e&&(n=r,s=Pt(),s!==e?(i=Ue(),i!==e?(c=Hn(),c!==e?n=vn(s):(r=n,n=e)):(r=n,n=e)):(r=n,n=e),n===e&&(n=r,s=Pt(),s!==e?(i=Ue(),i!==e?(c=Zn(),c!==e?(M=Ue(),M!==e?(j=Rr(),j!==e?n=wn(s):(r=n,n=e)):(r=n,n=e)):(r=n,n=e)):(r=n,n=e)):(r=n,n=e),n===e&&(n=r,s=mr(),s!==e?(i=Ue(),i!==e?(c=pr(),c!==e?n=_n(c):(r=n,n=e)):(r=n,n=e)):(r=n,n=e),n===e&&(n=r,s=hr(),s!==e?(i=Ue(),i!==e?(c=pr(),c!==e?n=An(c):(r=n,n=e)):(r=n,n=e)):(r=n,n=e),n===e&&(n=r,s=Gn(),s!==e?(i=Ue(),i!==e?(c=Er(),c!==e?n=Tn(s,c):(r=n,n=e)):(r=n,n=e)):(r=n,n=e),n===e&&(n=r,s=pr(),s!==e&&(s=$n(s)),n=s,n===e&&(n=r,s=Un(),s!==e&&(s=Sn(s)),n=s)))))))))),n}function Gn(){var n,s;return n=r,s=Jn(),s!==e&&(s=bn()),n=s,n===e&&(n=r,s=mr(),s!==e&&(s=Fn()),n=s,n===e&&(n=r,s=hr(),s!==e&&(s=On()),n=s)),n}function Un(){var n,s,i,c,M,j,re,oe,le,fe,Ve,$e,Se,Pe,Le,Ie,Tt,pt,ht,Ht,qt,Qt,Ft,Ot,gr,$t;if(n=r,s=r,i=r,c=o.charAt(r),x.test(c)?r++:(c=e,p===0&&T(_)),c!==e)if(M=o.charAt(r),x.test(M)?r++:(M=e,p===0&&T(_)),M!==e)if(j=o.charAt(r),x.test(j)?r++:(j=e,p===0&&T(_)),j!==e)if(re=o.charAt(r),x.test(re)?r++:(re=e,p===0&&T(_)),re!==e)if(o.charCodeAt(r)===45?(oe=me,r++):(oe=e,p===0&&T(a)),oe!==e)if(le=o.charAt(r),x.test(le)?r++:(le=e,p===0&&T(_)),le!==e)if(fe=o.charAt(r),x.test(fe)?r++:(fe=e,p===0&&T(_)),fe!==e)if(o.charCodeAt(r)===45?(Ve=me,r++):(Ve=e,p===0&&T(a)),Ve!==e)if($e=o.charAt(r),x.test($e)?r++:($e=e,p===0&&T(_)),$e!==e)if(Se=o.charAt(r),x.test(Se)?r++:(Se=e,p===0&&T(_)),Se!==e)if(Pe=o.charAt(r),Xe.test(Pe)?r++:(Pe=e,p===0&&T(l)),Pe!==e)if(Le=o.charAt(r),x.test(Le)?r++:(Le=e,p===0&&T(_)),Le!==e)if(Ie=o.charAt(r),x.test(Ie)?r++:(Ie=e,p===0&&T(_)),Ie!==e)if(o.charCodeAt(r)===58?(Tt=Qe,r++):(Tt=e,p===0&&T(b)),Tt!==e)if(pt=o.charAt(r),x.test(pt)?r++:(pt=e,p===0&&T(_)),pt!==e)if(ht=o.charAt(r),x.test(ht)?r++:(ht=e,p===0&&T(_)),ht!==e)if(o.charCodeAt(r)===58?(Ht=Qe,r++):(Ht=e,p===0&&T(b)),Ht!==e)if(qt=o.charAt(r),x.test(qt)?r++:(qt=e,p===0&&T(_)),qt!==e)if(Qt=o.charAt(r),x.test(Qt)?r++:(Qt=e,p===0&&T(_)),Qt!==e){if(Ft=r,Ot=o.charAt(r),Ae.test(Ot)?r++:(Ot=e,p===0&&T(L)),Ot!==e){for(gr=[],$t=o.charAt(r),x.test($t)?r++:($t=e,p===0&&T(_));$t!==e;)gr.push($t),$t=o.charAt(r),x.test($t)?r++:($t=e,p===0&&T(_));Ot=[Ot,gr],Ft=Ot}else r=Ft,Ft=e;Ft===e&&(Ft=null),c=[c,M,j,re,oe,le,fe,Ve,$e,Se,Pe,Le,Ie,Tt,pt,ht,Ht,qt,Qt,Ft],i=c}else r=i,i=e;else r=i,i=e;else r=i,i=e;else r=i,i=e;else r=i,i=e;else r=i,i=e;else r=i,i=e;else r=i,i=e;else r=i,i=e;else r=i,i=e;else r=i,i=e;else r=i,i=e;else r=i,i=e;else r=i,i=e;else r=i,i=e;else r=i,i=e;else r=i,i=e;else r=i,i=e;else r=i,i=e;return i!==e?s=o.substring(s,r):s=i,s!==e&&(s=En(s)),n=s,n===e&&(n=r,s=r,i=r,c=o.charAt(r),x.test(c)?r++:(c=e,p===0&&T(_)),c!==e?(M=o.charAt(r),x.test(M)?r++:(M=e,p===0&&T(_)),M!==e?(j=o.charAt(r),x.test(j)?r++:(j=e,p===0&&T(_)),j!==e?(re=o.charAt(r),x.test(re)?r++:(re=e,p===0&&T(_)),re!==e?(o.charCodeAt(r)===45?(oe=me,r++):(oe=e,p===0&&T(a)),oe!==e?(le=o.charAt(r),x.test(le)?r++:(le=e,p===0&&T(_)),le!==e?(fe=o.charAt(r),x.test(fe)?r++:(fe=e,p===0&&T(_)),fe!==e?(o.charCodeAt(r)===45?(Ve=me,r++):(Ve=e,p===0&&T(a)),Ve!==e?($e=o.charAt(r),x.test($e)?r++:($e=e,p===0&&T(_)),$e!==e?(Se=o.charAt(r),x.test(Se)?r++:(Se=e,p===0&&T(_)),Se!==e?(o.charCodeAt(r)===45?(Pe=me,r++):(Pe=e,p===0&&T(a)),Pe!==e?(Le=o.charAt(r),et.test(Le)?r++:(Le=e,p===0&&T(K)),Le!==e?(Ie=o.charAt(r),mt.test(Ie)?r++:(Ie=e,p===0&&T(u)),Ie!==e?(c=[c,M,j,re,oe,le,fe,Ve,$e,Se,Pe,Le,Ie],i=c):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e),i!==e?s=o.substring(s,r):s=i,s!==e&&(s=kn(s)),n=s,n===e&&(n=r,s=r,i=r,c=o.charAt(r),x.test(c)?r++:(c=e,p===0&&T(_)),c!==e?(M=o.charAt(r),x.test(M)?r++:(M=e,p===0&&T(_)),M!==e?(j=o.charAt(r),x.test(j)?r++:(j=e,p===0&&T(_)),j!==e?(re=o.charAt(r),x.test(re)?r++:(re=e,p===0&&T(_)),re!==e?(o.charCodeAt(r)===45?(oe=me,r++):(oe=e,p===0&&T(a)),oe!==e?(le=o.charAt(r),vt.test(le)?r++:(le=e,p===0&&T(X)),le!==e?(fe=o.charAt(r),We.test(fe)?r++:(fe=e,p===0&&T(ue)),fe!==e?(c=[c,M,j,re,oe,le,fe],i=c):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e),i!==e?s=o.substring(s,r):s=i,s!==e&&(s=Rn(s)),n=s,n===e&&(n=r,s=r,i=r,c=o.charAt(r),x.test(c)?r++:(c=e,p===0&&T(_)),c!==e?(M=o.charAt(r),x.test(M)?r++:(M=e,p===0&&T(_)),M!==e?(j=o.charAt(r),x.test(j)?r++:(j=e,p===0&&T(_)),j!==e?(re=o.charAt(r),x.test(re)?r++:(re=e,p===0&&T(_)),re!==e?(o.charCodeAt(r)===45?(oe=me,r++):(oe=e,p===0&&T(a)),oe!==e?(le=o.charAt(r),x.test(le)?r++:(le=e,p===0&&T(_)),le!==e?(fe=o.charAt(r),x.test(fe)?r++:(fe=e,p===0&&T(_)),fe!==e?(o.charCodeAt(r)===45?(Ve=me,r++):(Ve=e,p===0&&T(a)),Ve!==e?($e=o.charAt(r),x.test($e)?r++:($e=e,p===0&&T(_)),$e!==e?(Se=o.charAt(r),x.test(Se)?r++:(Se=e,p===0&&T(_)),Se!==e?(Pe=o.charAt(r),Xe.test(Pe)?r++:(Pe=e,p===0&&T(l)),Pe!==e?(Le=o.charAt(r),x.test(Le)?r++:(Le=e,p===0&&T(_)),Le!==e?(Ie=o.charAt(r),x.test(Ie)?r++:(Ie=e,p===0&&T(_)),Ie!==e?(o.charCodeAt(r)===58?(Tt=Qe,r++):(Tt=e,p===0&&T(b)),Tt!==e?(pt=o.charAt(r),x.test(pt)?r++:(pt=e,p===0&&T(_)),pt!==e?(ht=o.charAt(r),x.test(ht)?r++:(ht=e,p===0&&T(_)),ht!==e?(c=[c,M,j,re,oe,le,fe,Ve,$e,Se,Pe,Le,Ie,Tt,pt,ht],i=c):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e),i!==e?s=o.substring(s,r):s=i,s!==e&&(s=Vn(s)),n=s,n===e&&(n=r,s=r,i=r,c=o.charAt(r),x.test(c)?r++:(c=e,p===0&&T(_)),c!==e?(M=o.charAt(r),x.test(M)?r++:(M=e,p===0&&T(_)),M!==e?(j=o.charAt(r),x.test(j)?r++:(j=e,p===0&&T(_)),j!==e?(re=o.charAt(r),x.test(re)?r++:(re=e,p===0&&T(_)),re!==e?(o.charCodeAt(r)===45?(oe=me,r++):(oe=e,p===0&&T(a)),oe!==e?(le=o.charAt(r),x.test(le)?r++:(le=e,p===0&&T(_)),le!==e?(fe=o.charAt(r),x.test(fe)?r++:(fe=e,p===0&&T(_)),fe!==e?(o.charCodeAt(r)===45?(Ve=me,r++):(Ve=e,p===0&&T(a)),Ve!==e?($e=o.charAt(r),x.test($e)?r++:($e=e,p===0&&T(_)),$e!==e?(Se=o.charAt(r),x.test(Se)?r++:(Se=e,p===0&&T(_)),Se!==e?(Pe=o.charAt(r),Xe.test(Pe)?r++:(Pe=e,p===0&&T(l)),Pe!==e?(Le=o.charAt(r),x.test(Le)?r++:(Le=e,p===0&&T(_)),Le!==e?(Ie=o.charAt(r),x.test(Ie)?r++:(Ie=e,p===0&&T(_)),Ie!==e?(c=[c,M,j,re,oe,le,fe,Ve,$e,Se,Pe,Le,Ie],i=c):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e),i!==e?s=o.substring(s,r):s=i,s!==e&&(s=Ln(s)),n=s,n===e&&(n=r,s=r,i=r,c=o.charAt(r),x.test(c)?r++:(c=e,p===0&&T(_)),c!==e?(M=o.charAt(r),x.test(M)?r++:(M=e,p===0&&T(_)),M!==e?(j=o.charAt(r),x.test(j)?r++:(j=e,p===0&&T(_)),j!==e?(re=o.charAt(r),x.test(re)?r++:(re=e,p===0&&T(_)),re!==e?(o.charCodeAt(r)===45?(oe=me,r++):(oe=e,p===0&&T(a)),oe!==e?(le=o.charAt(r),x.test(le)?r++:(le=e,p===0&&T(_)),le!==e?(fe=o.charAt(r),x.test(fe)?r++:(fe=e,p===0&&T(_)),fe!==e?(o.charCodeAt(r)===45?(Ve=me,r++):(Ve=e,p===0&&T(a)),Ve!==e?($e=o.charAt(r),x.test($e)?r++:($e=e,p===0&&T(_)),$e!==e?(Se=o.charAt(r),x.test(Se)?r++:(Se=e,p===0&&T(_)),Se!==e?(c=[c,M,j,re,oe,le,fe,Ve,$e,Se],i=c):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e),i!==e?s=o.substring(s,r):s=i,s!==e&&(s=In(s)),n=s,n===e&&(n=r,s=r,i=r,c=o.charAt(r),x.test(c)?r++:(c=e,p===0&&T(_)),c!==e?(M=o.charAt(r),x.test(M)?r++:(M=e,p===0&&T(_)),M!==e?(j=o.charAt(r),x.test(j)?r++:(j=e,p===0&&T(_)),j!==e?(re=o.charAt(r),x.test(re)?r++:(re=e,p===0&&T(_)),re!==e?(o.charCodeAt(r)===45?(oe=me,r++):(oe=e,p===0&&T(a)),oe!==e?(le=o.charAt(r),x.test(le)?r++:(le=e,p===0&&T(_)),le!==e?(fe=o.charAt(r),x.test(fe)?r++:(fe=e,p===0&&T(_)),fe!==e?(c=[c,M,j,re,oe,le,fe],i=c):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e),i!==e?s=o.substring(s,r):s=i,s!==e&&(s=Cn(s)),n=s,n===e&&(n=r,s=r,i=r,c=o.charAt(r),x.test(c)?r++:(c=e,p===0&&T(_)),c!==e?(M=o.charAt(r),x.test(M)?r++:(M=e,p===0&&T(_)),M!==e?(j=o.charAt(r),x.test(j)?r++:(j=e,p===0&&T(_)),j!==e?(re=o.charAt(r),x.test(re)?r++:(re=e,p===0&&T(_)),re!==e?(c=[c,M,j,re],i=c):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e),i!==e?s=o.substring(s,r):s=i,s!==e&&(s=Dn(s)),n=s))))))),n}function pr(){var n,s,i;return n=r,s=r,i=li(),i===e&&(i=fi(),i===e&&(i=ui(),i===e&&(i=ci(),i===e&&(i=di(),i===e&&(i=pi(),i===e&&(i=hi())))))),i!==e?s=o.substring(s,r):s=i,s!==e&&(s=Nn(s)),n=s,n}function kr(){var n,s;return n=r,s=oi(),s!==e&&(s=xn()),n=s,n===e&&(n=r,s=si(),s!==e&&(s=Pn()),n=s),n}function jn(){var n,s,i,c;return n=r,s=o.substr(r,3),s.toLowerCase()===nt?r+=3:(s=e,p===0&&T(ot)),s!==e?(i=r,p++,c=ye(),p--,c===e?i=void 0:(r=i,i=e),i!==e?(s=[s,i],n=s):(r=n,n=e)):(r=n,n=e),n}function Wn(){var n,s,i,c;return n=r,s=o.substr(r,4),s.toLowerCase()===Re?r+=4:(s=e,p===0&&T(J)),s!==e?(i=r,p++,c=ye(),p--,c===e?i=void 0:(r=i,i=e),i!==e?(s=[s,i],n=s):(r=n,n=e)):(r=n,n=e),n}function zn(){var n,s,i,c;return n=r,s=o.substr(r,4),s.toLowerCase()===je?r+=4:(s=e,p===0&&T(bt)),s!==e?(i=r,p++,c=ye(),p--,c===e?i=void 0:(r=i,i=e),i!==e?(s=[s,i],n=s):(r=n,n=e)):(r=n,n=e),n}function Yn(){var n,s,i,c;return n=r,s=o.substr(r,2),s.toLowerCase()===at?r+=2:(s=e,p===0&&T(xe)),s!==e?(i=r,p++,c=ye(),p--,c===e?i=void 0:(r=i,i=e),i!==e?(s=[s,i],n=s):(r=n,n=e)):(r=n,n=e),n}function Rr(){var n,s,i,c;return n=r,s=o.substr(r,3),s.toLowerCase()===st?r+=3:(s=e,p===0&&T(wt)),s!==e?(i=r,p++,c=ye(),p--,c===e?i=void 0:(r=i,i=e),i!==e?(s=[s,i],n=s):(r=n,n=e)):(r=n,n=e),n}function hr(){var n,s,i,c;return n=r,s=o.substr(r,4),s.toLowerCase()===ke?r+=4:(s=e,p===0&&T(er)),s!==e?(i=r,p++,c=ye(),p--,c===e?i=void 0:(r=i,i=e),i!==e?(s=[s,i],n=s):(r=n,n=e)):(r=n,n=e),n}function Jn(){var n,s,i,c;return n=r,s=o.substr(r,4),s.toLowerCase()===Ce?r+=4:(s=e,p===0&&T(tr)),s!==e?(i=r,p++,c=ye(),p--,c===e?i=void 0:(r=i,i=e),i!==e?(s=[s,i],n=s):(r=n,n=e)):(r=n,n=e),n}function mr(){var n,s,i,c;return n=r,s=o.substr(r,4),s.toLowerCase()===De?r+=4:(s=e,p===0&&T(jt)),s!==e?(i=r,p++,c=ye(),p--,c===e?i=void 0:(r=i,i=e),i!==e?(s=[s,i],n=s):(r=n,n=e)):(r=n,n=e),n}function Hn(){var n,s,i,c;return n=r,s=o.substr(r,3),s.toLowerCase()===lt?r+=3:(s=e,p===0&&T(Wt)),s!==e?(i=r,p++,c=ye(),p--,c===e?i=void 0:(r=i,i=e),i!==e?(s=[s,i],n=s):(r=n,n=e)):(r=n,n=e),n}function Zn(){var n,s,i,c;return n=r,s=o.substr(r,4),s.toLowerCase()===Me?r+=4:(s=e,p===0&&T(te)),s!==e?(i=r,p++,c=ye(),p--,c===e?i=void 0:(r=i,i=e),i!==e?(s=[s,i],n=s):(r=n,n=e)):(r=n,n=e),n}function Kn(){var n,s,i,c;return n=r,s=o.substr(r,6),s.toLowerCase()===Oe?r+=6:(s=e,p===0&&T(rr)),s!==e?(i=r,p++,c=ye(),p--,c===e?i=void 0:(r=i,i=e),i!==e?(s=[s,i],n=s):(r=n,n=e)):(r=n,n=e),n}function Xn(){var n,s,i,c;return n=r,s=o.substr(r,5),s.toLowerCase()===Ee?r+=5:(s=e,p===0&&T(Dt)),s!==e?(i=r,p++,c=ye(),p--,c===e?i=void 0:(r=i,i=e),i!==e?(s=[s,i],n=s):(r=n,n=e)):(r=n,n=e),n}function ei(){var n,s,i,c;return n=r,s=o.substr(r,7),s.toLowerCase()===Ze?r+=7:(s=e,p===0&&T(Nt)),s!==e?(i=r,p++,c=ye(),p--,c===e?i=void 0:(r=i,i=e),i!==e?(s=[s,i],n=s):(r=n,n=e)):(r=n,n=e),n}function ti(){var n,s,i,c;return n=r,s=o.substr(r,8),s.toLowerCase()===Ne?r+=8:(s=e,p===0&&T(zt)),s!==e?(i=r,p++,c=ye(),p--,c===e?i=void 0:(r=i,i=e),i!==e?(s=[s,i],n=s):(r=n,n=e)):(r=n,n=e),n}function ri(){var n,s,i,c;return n=r,s=o.substr(r,3),s.toLowerCase()===Ke?r+=3:(s=e,p===0&&T(nr)),s!==e?(i=r,p++,c=ye(),p--,c===e?i=void 0:(r=i,i=e),i!==e?(s=[s,i],n=s):(r=n,n=e)):(r=n,n=e),n}function ni(){var n,s,i,c;return n=r,s=o.substr(r,5),s.toLowerCase()===Ye?r+=5:(s=e,p===0&&T(ir)),s!==e?(i=r,p++,c=ye(),p--,c===e?i=void 0:(r=i,i=e),i!==e?(s=[s,i],n=s):(r=n,n=e)):(r=n,n=e),n}function ii(){var n,s,i,c;return n=r,s=o.substr(r,9),s.toLowerCase()===q?r+=9:(s=e,p===0&&T(rt)),s!==e?(i=r,p++,c=ye(),p--,c===e?i=void 0:(r=i,i=e),i!==e?(s=[s,i],n=s):(r=n,n=e)):(r=n,n=e),n}function ai(){var n,s,i,c;return n=r,s=o.substr(r,8),s.toLowerCase()===m?r+=8:(s=e,p===0&&T(Yt)),s!==e?(i=r,p++,c=ye(),p--,c===e?i=void 0:(r=i,i=e),i!==e?(s=[s,i],n=s):(r=n,n=e)):(r=n,n=e),n}function si(){var n,s,i,c;return n=r,s=o.substr(r,3),s.toLowerCase()===S?r+=3:(s=e,p===0&&T(ar)),s!==e?(i=r,p++,c=ye(),p--,c===e?i=void 0:(r=i,i=e),i!==e?(s=[s,i],n=s):(r=n,n=e)):(r=n,n=e),n}function oi(){var n,s,i,c;return n=r,s=o.substr(r,2),s.toLowerCase()===V?r+=2:(s=e,p===0&&T(sr)),s!==e?(i=r,p++,c=ye(),p--,c===e?i=void 0:(r=i,i=e),i!==e?(s=[s,i],n=s):(r=n,n=e)):(r=n,n=e),n}function li(){var n,s,i,c;return n=r,s=o.substr(r,6),s.toLowerCase()===E?r+=6:(s=e,p===0&&T(or)),s!==e?(i=r,p++,c=ye(),p--,c===e?i=void 0:(r=i,i=e),i!==e?(s=[s,i],n=s):(r=n,n=e)):(r=n,n=e),n}function fi(){var n,s,i,c;return n=r,s=o.substr(r,7),s.toLowerCase()===B?r+=7:(s=e,p===0&&T(lr)),s!==e?(i=r,p++,c=ye(),p--,c===e?i=void 0:(r=i,i=e),i!==e?(s=[s,i],n=s):(r=n,n=e)):(r=n,n=e),n}function ui(){var n,s,i,c;return n=r,s=o.substr(r,9),s.toLowerCase()===z?r+=9:(s=e,p===0&&T(fr)),s!==e?(i=r,p++,c=ye(),p--,c===e?i=void 0:(r=i,i=e),i!==e?(s=[s,i],n=s):(r=n,n=e)):(r=n,n=e),n}function ci(){var n,s,i,c;return n=r,s=o.substr(r,8),s.toLowerCase()===_e?r+=8:(s=e,p===0&&T(ur)),s!==e?(i=r,p++,c=ye(),p--,c===e?i=void 0:(r=i,i=e),i!==e?(s=[s,i],n=s):(r=n,n=e)):(r=n,n=e),n}function di(){var n,s,i,c;return n=r,s=o.substr(r,6),s.toLowerCase()===Be?r+=6:(s=e,p===0&&T(_t)),s!==e?(i=r,p++,c=ye(),p--,c===e?i=void 0:(r=i,i=e),i!==e?(s=[s,i],n=s):(r=n,n=e)):(r=n,n=e),n}function pi(){var n,s,i,c;return n=r,s=o.substr(r,8),s.toLowerCase()===it?r+=8:(s=e,p===0&&T(ge)),s!==e?(i=r,p++,c=ye(),p--,c===e?i=void 0:(r=i,i=e),i!==e?(s=[s,i],n=s):(r=n,n=e)):(r=n,n=e),n}function hi(){var n,s,i,c;return n=r,s=o.substr(r,6),s.toLowerCase()===Je?r+=6:(s=e,p===0&&T(h)),s!==e?(i=r,p++,c=ye(),p--,c===e?i=void 0:(r=i,i=e),i!==e?(s=[s,i],n=s):(r=n,n=e)):(r=n,n=e),n}function ye(){var n;return n=o.charAt(r),ft.test(n)?r++:(n=e,p===0&&T(v)),n}function It(){var n,s;for(p++,n=[],s=o.charAt(r),qe.test(s)?r++:(s=e,p===0&&T(D));s!==e;)n.push(s),s=o.charAt(r),qe.test(s)?r++:(s=e,p===0&&T(D));return p--,s=e,p===0&&T(R),n}function Ue(){var n,s;if(p++,n=[],s=o.charAt(r),qe.test(s)?r++:(s=e,p===0&&T(D)),s!==e)for(;s!==e;)n.push(s),s=o.charAt(r),qe.test(s)?r++:(s=e,p===0&&T(D));else n=e;return p--,n===e&&(s=e,p===0&&T(ee)),n}if(xt=Z(),d.peg$library)return{peg$result:xt,peg$currPos:r,peg$FAILED:e,peg$maxFailExpected:Jt,peg$maxFailPos:ct};if(xt!==e&&r===o.length)return xt;throw xt!==e&&r<o.length&&T(qn()),Qn(Jt,ct<o.length?o.charAt(ct):null,ct<o.length?Fr(ct,ct+1):Fr(ct,ct))}return Tr={StartRules:["temporalFilter"],SyntaxError:$,parse:y},Tr}var Qr;function Si(){return Qr||(Qr=1,(function(f){Object.defineProperty(f,"__esModule",{value:!0}),f.TemporalFilterExpression=void 0;const ie=Ct(),W=$i(),P=$r();f.TemporalFilterExpression={parse(y){if(y.match(/^\s*$/))return{parsed:null,log:[]};const o=(0,P.run_parser)(y,W.parse);return o.parsed&&(0,ie.isTemporalFilter)(o.parsed)?{parsed:o.parsed,log:[]}:{parsed:null,log:o.log}},unparse(y){if(y===null)return"";switch(y.operator){case"null":return k(y,"null");case"none":return k(y,"none");case"in":return k(y,w(y.in));case"()":return k(y,"("+f.TemporalFilterExpression.unparse(y.expr)+")");case"in_last":return k(y,$(y));case"last":case"next":return k(y,`${y.operator} ${$(y)}`);case"before":return`${y.not?"starting":"before"} ${w(y.before)}`;case"after":return`${y.not?"through":"after"} ${w(y.after)}`;case"to":return k(y,`${w(y.fromMoment)} to ${w(y.toMoment)}`);case"for":return k(y,`${w(y.begin)} for ${$(y)}`);case"or":return y.members.map(o=>f.TemporalFilterExpression.unparse(o)).join(" or ");case"and":return y.members.map(o=>f.TemporalFilterExpression.unparse(o)).join(" and ")}}};function k(y,o){return"not"in y&&y.not?"not "+o:o}function $(y){return y.n==="1"?`1 ${y.units}`:`${y.n} ${y.units}s`}function w(y){switch(y.moment){case"literal":return y.literal;case"now":case"today":case"yesterday":case"tomorrow":return y.moment;case"monday":case"tuesday":case"wednesday":case"thursday":case"friday":case"saturday":case"sunday":return y.which==="next"?"next "+y.moment:y.moment;case"this":case"next":case"last":return`${y.moment} ${y.units}`;case"ago":return`${$(y)} ago`;case"from_now":return`${$(y)} from now`}}})(Ar)),Ar}var Mr;function bi(){return Mr||(Mr=1,(function(f){var ie=Et&&Et.__createBinding||(Object.create?(function(y,o,d,e){e===void 0&&(e=d);var C=Object.getOwnPropertyDescriptor(o,d);(!C||("get"in C?!o.__esModule:C.writable||C.configurable))&&(C={enumerable:!0,get:function(){return o[d]}}),Object.defineProperty(y,e,C)}):(function(y,o,d,e){e===void 0&&(e=d),y[e]=o[d]})),W=Et&&Et.__exportStar||function(y,o){for(var d in y)d!=="default"&&!Object.prototype.hasOwnProperty.call(o,d)&&ie(o,y,d)};Object.defineProperty(f,"__esModule",{value:!0}),f.TemporalFilterExpression=f.StringFilterExpression=f.NumberFilterExpression=f.BooleanFilterExpression=void 0,W(Ct(),f);var P=vi();Object.defineProperty(f,"BooleanFilterExpression",{enumerable:!0,get:function(){return P.BooleanFilterExpression}});var k=_i();Object.defineProperty(f,"NumberFilterExpression",{enumerable:!0,get:function(){return k.NumberFilterExpression}});var $=Ti();Object.defineProperty(f,"StringFilterExpression",{enumerable:!0,get:function(){return $.StringFilterExpression}});var w=Si();Object.defineProperty(f,"TemporalFilterExpression",{enumerable:!0,get:function(){return w.TemporalFilterExpression}})})(Et)),Et}var kt={},Bt={},Br;function Hr(){return Br||(Br=1,Object.defineProperty(Bt,"__esModule",{value:!0}),Bt.MALLOY_INTERFACE_TYPES=void 0,Bt.MALLOY_INTERFACE_TYPES={Aggregate:{type:"struct",name:"Aggregate",fields:{name:{type:"string",optional:!0,array:!1},field:{type:"Field",optional:!1,array:!1}}},Annotation:{type:"struct",name:"Annotation",fields:{value:{type:"string",optional:!1,array:!1}}},AnonymousQueryInfo:{type:"struct",name:"AnonymousQueryInfo",fields:{schema:{type:"Schema",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0},definition:{type:"Query",optional:!0,array:!1},code:{type:"string",optional:!0,array:!1},location:{type:"Location",optional:!0,array:!1}}},ArrayCell:{type:"struct",name:"ArrayCell",fields:{array_value:{type:"Cell",array:!0,optional:!1}}},ArrayType:{type:"struct",name:"ArrayType",fields:{element_type:{type:"AtomicType",optional:!1,array:!1}}},AtomicType:{type:"union",name:"AtomicType",options:{string_type:"StringType",boolean_type:"BooleanType",number_type:"NumberType",json_type:"JSONType",sql_native_type:"SQLNativeType",date_type:"DateType",timestamp_type:"TimestampType",array_type:"ArrayType",record_type:"RecordType",timestamptz_type:"TimestamptzType"}},BooleanCell:{type:"struct",name:"BooleanCell",fields:{boolean_value:{type:"boolean",optional:!1,array:!1}}},BooleanLiteral:{type:"struct",name:"BooleanLiteral",fields:{boolean_value:{type:"boolean",optional:!1,array:!1}}},BooleanType:{type:"struct",name:"BooleanType",fields:{}},CalculateInfo:{type:"struct",name:"CalculateInfo",fields:{name:{type:"string",optional:!1,array:!1},type:{type:"AtomicType",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0}}},CalculateOperation:{type:"struct",name:"CalculateOperation",fields:{name:{type:"string",optional:!1,array:!1},field:{type:"Field",optional:!1,array:!1}}},Cell:{type:"union",name:"Cell",options:{string_cell:"StringCell",boolean_cell:"BooleanCell",date_cell:"DateCell",timestamp_cell:"TimestampCell",number_cell:"NumberCell",json_cell:"JSONCell",record_cell:"RecordCell",array_cell:"ArrayCell",null_cell:"NullCell",sql_native_cell:"SQLNativeCell"}},CompileModelRequest:{type:"struct",name:"CompileModelRequest",fields:{model_url:{type:"string",optional:!1,array:!1},extend_model_url:{type:"string",optional:!0,array:!1},exclude_references:{type:"boolean",optional:!0,array:!1},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1}}},CompileModelResponse:{type:"struct",name:"CompileModelResponse",fields:{model:{type:"ModelInfo",optional:!0,array:!1},logs:{type:"LogMessage",array:!0,optional:!0},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1},translations:{type:"Translation",array:!0,optional:!0},timing_info:{type:"TimingInfo",optional:!0,array:!1}}},CompileQueryRequest:{type:"struct",name:"CompileQueryRequest",fields:{model_url:{type:"string",optional:!1,array:!1},query:{type:"Query",optional:!0,array:!1},query_malloy:{type:"string",optional:!0,array:!1},default_row_limit:{type:"number",optional:!0,array:!1},exclude_references:{type:"boolean",optional:!0,array:!1},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1}}},CompileQueryResponse:{type:"struct",name:"CompileQueryResponse",fields:{result:{type:"Result",optional:!0,array:!1},default_row_limit_added:{type:"number",optional:!0,array:!1},logs:{type:"LogMessage",array:!0,optional:!0},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1},translations:{type:"Translation",array:!0,optional:!0},timing_info:{type:"TimingInfo",optional:!0,array:!1}}},CompileSourceRequest:{type:"struct",name:"CompileSourceRequest",fields:{model_url:{type:"string",optional:!1,array:!1},name:{type:"string",optional:!1,array:!1},extend_model_url:{type:"string",optional:!0,array:!1},exclude_references:{type:"boolean",optional:!0,array:!1},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1}}},CompileSourceResponse:{type:"struct",name:"CompileSourceResponse",fields:{source:{type:"SourceInfo",optional:!0,array:!1},logs:{type:"LogMessage",array:!0,optional:!0},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1},timing_info:{type:"TimingInfo",optional:!0,array:!1}}},CompilerNeeds:{type:"struct",name:"CompilerNeeds",fields:{table_schemas:{type:"SQLTable",array:!0,optional:!0},sql_schemas:{type:"SQLQuery",array:!0,optional:!0},files:{type:"File",array:!0,optional:!0},connections:{type:"Connection",array:!0,optional:!0},translations:{type:"Translation",array:!0,optional:!0}}},Connection:{type:"struct",name:"Connection",fields:{name:{type:"string",optional:!1,array:!1},dialect:{type:"string",optional:!0,array:!1}}},Data:{type:"union",name:"Data",options:{record_cell:"RecordCell",array_cell:"ArrayCell"}},DateCell:{type:"struct",name:"DateCell",fields:{date_value:{type:"string",optional:!1,array:!1}}},DateLiteral:{type:"struct",name:"DateLiteral",fields:{date_value:{type:"string",optional:!1,array:!1},granularity:{type:"DateTimeframe",optional:!0,array:!1},timezone:{type:"string",optional:!0,array:!1}}},DateTimeframe:{type:"enum",name:"DateTimeframe",values:{year:1,quarter:2,month:3,week:4,day:5}},DateType:{type:"struct",name:"DateType",fields:{timeframe:{type:"DateTimeframe",optional:!0,array:!1}}},DimensionInfo:{type:"struct",name:"DimensionInfo",fields:{name:{type:"string",optional:!1,array:!1},type:{type:"AtomicType",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0}}},DocumentPosition:{type:"struct",name:"DocumentPosition",fields:{line:{type:"number",optional:!1,array:!1},character:{type:"number",optional:!1,array:!1}}},DocumentRange:{type:"struct",name:"DocumentRange",fields:{start:{type:"DocumentPosition",optional:!1,array:!1},end:{type:"DocumentPosition",optional:!1,array:!1}}},DrillOperation:{type:"struct",name:"DrillOperation",fields:{filter:{type:"Filter",optional:!1,array:!1}}},Expression:{type:"union",name:"Expression",options:{field_reference:"Reference",time_truncation:"TimeTruncationFieldReference",filtered_field:"FilteredField",literal_value:"LiteralValueExpression",moving_average:"MovingAverage"}},Field:{type:"struct",name:"Field",fields:{expression:{type:"Expression",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0}}},FieldInfo:{type:"union",name:"FieldInfo",options:{dimension:"DimensionInfo",measure:"MeasureInfo",join:"JoinInfo",view:"ViewInfo",calculate:"CalculateInfo"}},File:{type:"struct",name:"File",fields:{url:{type:"string",optional:!1,array:!1},contents:{type:"string",optional:!0,array:!1},invalidation_key:{type:"string",optional:!0,array:!1}}},Filter:{type:"union",name:"Filter",options:{filter_string:"FilterStringApplication",literal_equality:"LiteralEqualityComparison"}},FilterExpressionLiteral:{type:"struct",name:"FilterExpressionLiteral",fields:{filter_expression_value:{type:"string",optional:!1,array:!1}}},FilterExpressionType:{type:"struct",name:"FilterExpressionType",fields:{filter_type:{type:"FilterableType",optional:!1,array:!1}}},FilterOperation:{type:"struct",name:"FilterOperation",fields:{filter:{type:"Filter",optional:!1,array:!1}}},FilterStringApplication:{type:"struct",name:"FilterStringApplication",fields:{expression:{type:"Expression",optional:!1,array:!1},filter:{type:"string",optional:!1,array:!1}}},FilterableType:{type:"union",name:"FilterableType",options:{string_type:"StringType",boolean_type:"BooleanType",number_type:"NumberType",date_type:"DateType",timestamp_type:"TimestampType",timestamptz_type:"TimestamptzType"}},FilteredField:{type:"struct",name:"FilteredField",fields:{field_reference:{type:"Reference",optional:!1,array:!1},where:{type:"FilterOperation",array:!0,optional:!1}}},GroupBy:{type:"struct",name:"GroupBy",fields:{name:{type:"string",optional:!0,array:!1},field:{type:"Field",optional:!1,array:!1}}},JSONCell:{type:"struct",name:"JSONCell",fields:{json_value:{type:"string",optional:!1,array:!1}}},JSONType:{type:"struct",name:"JSONType",fields:{}},JoinInfo:{type:"struct",name:"JoinInfo",fields:{name:{type:"string",optional:!1,array:!1},schema:{type:"Schema",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0},relationship:{type:"Relationship",optional:!1,array:!1}}},Limit:{type:"struct",name:"Limit",fields:{limit:{type:"number",optional:!1,array:!1}}},LiteralEqualityComparison:{type:"struct",name:"LiteralEqualityComparison",fields:{expression:{type:"Expression",optional:!1,array:!1},value:{type:"LiteralValue",optional:!1,array:!1}}},LiteralValue:{type:"union",name:"LiteralValue",options:{string_literal:"StringLiteral",number_literal:"NumberLiteral",date_literal:"DateLiteral",timestamp_literal:"TimestampLiteral",boolean_literal:"BooleanLiteral",null_literal:"NullLiteral",filter_expression_literal:"FilterExpressionLiteral"}},LiteralValueExpression:{type:"struct",name:"LiteralValueExpression",fields:{literal_value:{type:"LiteralValue",optional:!1,array:!1}}},Location:{type:"struct",name:"Location",fields:{url:{type:"string",optional:!1,array:!1},range:{type:"Range",optional:!1,array:!1}}},LogMessage:{type:"struct",name:"LogMessage",fields:{url:{type:"string",optional:!1,array:!1},range:{type:"DocumentRange",optional:!1,array:!1},severity:{type:"LogSeverity",optional:!1,array:!1},message:{type:"string",optional:!1,array:!1}}},LogSeverity:{type:"enum",name:"LogSeverity",values:{debug:1,info:2,warn:3,error:4}},MeasureInfo:{type:"struct",name:"MeasureInfo",fields:{name:{type:"string",optional:!1,array:!1},type:{type:"AtomicType",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0}}},ModelEntryValue:{type:"union",name:"ModelEntryValue",options:{source:"SourceInfo",query:"QueryInfo"}},ModelInfo:{type:"struct",name:"ModelInfo",fields:{entries:{type:"ModelEntryValue",array:!0,optional:!1},annotations:{type:"Annotation",array:!0,optional:!0},anonymous_queries:{type:"AnonymousQueryInfo",array:!0,optional:!1}}},MovingAverage:{type:"struct",name:"MovingAverage",fields:{field_reference:{type:"Reference",optional:!1,array:!1},rows_preceding:{type:"number",optional:!0,array:!1},rows_following:{type:"number",optional:!0,array:!1},partition_fields:{type:"Reference",array:!0,optional:!0}}},Nest:{type:"struct",name:"Nest",fields:{name:{type:"string",optional:!0,array:!1},view:{type:"View",optional:!1,array:!1}}},NullCell:{type:"struct",name:"NullCell",fields:{}},NullLiteral:{type:"struct",name:"NullLiteral",fields:{}},NumberCell:{type:"struct",name:"NumberCell",fields:{number_value:{type:"number",optional:!1,array:!1},subtype:{type:"NumberSubtype",optional:!0,array:!1},string_value:{type:"string",optional:!0,array:!1}}},NumberLiteral:{type:"struct",name:"NumberLiteral",fields:{number_value:{type:"number",optional:!1,array:!1},string_value:{type:"string",optional:!0,array:!1}}},NumberSubtype:{type:"enum",name:"NumberSubtype",values:{integer:1,decimal:2,bigint:3}},NumberType:{type:"struct",name:"NumberType",fields:{subtype:{type:"NumberSubtype",optional:!0,array:!1}}},OrderBy:{type:"struct",name:"OrderBy",fields:{field_reference:{type:"Reference",optional:!1,array:!1},direction:{type:"OrderByDirection",optional:!0,array:!1}}},OrderByDirection:{type:"enum",name:"OrderByDirection",values:{asc:1,desc:2}},ParameterInfo:{type:"struct",name:"ParameterInfo",fields:{name:{type:"string",optional:!1,array:!1},type:{type:"ParameterType",optional:!1,array:!1},default_value:{type:"LiteralValue",optional:!0,array:!1}}},ParameterType:{type:"union",name:"ParameterType",options:{string_type:"StringType",boolean_type:"BooleanType",number_type:"NumberType",json_type:"JSONType",sql_native_type:"SQLNativeType",date_type:"DateType",timestamp_type:"TimestampType",array_type:"ArrayType",record_type:"RecordType",filter_expression_type:"FilterExpressionType",timestamptz_type:"TimestamptzType"}},ParameterValue:{type:"struct",name:"ParameterValue",fields:{name:{type:"string",optional:!1,array:!1},value:{type:"LiteralValue",optional:!1,array:!1}}},Position:{type:"struct",name:"Position",fields:{line:{type:"number",optional:!1,array:!1},character:{type:"number",optional:!1,array:!1}}},Query:{type:"struct",name:"Query",fields:{definition:{type:"QueryDefinition",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0}}},QueryArrow:{type:"struct",name:"QueryArrow",fields:{source:{type:"QueryArrowSource",optional:!1,array:!1},view:{type:"ViewDefinition",optional:!1,array:!1}}},QueryArrowSource:{type:"union",name:"QueryArrowSource",options:{refinement:"QueryRefinement",source_reference:"Reference"}},QueryDefinition:{type:"union",name:"QueryDefinition",options:{arrow:"QueryArrow",query_reference:"Reference",refinement:"QueryRefinement"}},QueryInfo:{type:"struct",name:"QueryInfo",fields:{name:{type:"string",optional:!1,array:!1},schema:{type:"Schema",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0},definition:{type:"Query",optional:!0,array:!1},code:{type:"string",optional:!0,array:!1},location:{type:"Location",optional:!0,array:!1}}},QueryRefinement:{type:"struct",name:"QueryRefinement",fields:{base:{type:"QueryDefinition",optional:!1,array:!1},refinement:{type:"ViewDefinition",optional:!1,array:!1}}},Range:{type:"struct",name:"Range",fields:{start:{type:"Position",optional:!1,array:!1},end:{type:"Position",optional:!1,array:!1}}},RecordCell:{type:"struct",name:"RecordCell",fields:{record_value:{type:"Cell",array:!0,optional:!1}}},RecordType:{type:"struct",name:"RecordType",fields:{fields:{type:"DimensionInfo",array:!0,optional:!1}}},Reference:{type:"struct",name:"Reference",fields:{name:{type:"string",optional:!1,array:!1},path:{type:"string",array:!0,optional:!0},parameters:{type:"ParameterValue",array:!0,optional:!0}}},Relationship:{type:"enum",name:"Relationship",values:{one:1,many:2,cross:3}},Result:{type:"struct",name:"Result",fields:{data:{type:"Data",optional:!0,array:!1},schema:{type:"Schema",optional:!1,array:!1},sql:{type:"string",optional:!0,array:!1},connection_name:{type:"string",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0},model_annotations:{type:"Annotation",array:!0,optional:!0},query_timezone:{type:"string",optional:!0,array:!1},source_annotations:{type:"Annotation",array:!0,optional:!0}}},RunIndexQueryRequest:{type:"struct",name:"RunIndexQueryRequest",fields:{model_url:{type:"string",optional:!1,array:!1},source_name:{type:"string",optional:!1,array:!1},exclude_references:{type:"boolean",optional:!0,array:!1},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1}}},RunIndexQueryResponse:{type:"struct",name:"RunIndexQueryResponse",fields:{result:{type:"Result",optional:!0,array:!1},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1},timing_info:{type:"TimingInfo",optional:!0,array:!1}}},RunQueryRequest:{type:"struct",name:"RunQueryRequest",fields:{model_url:{type:"string",optional:!1,array:!1},query:{type:"Query",optional:!0,array:!1},query_malloy:{type:"string",optional:!0,array:!1},default_row_limit:{type:"number",optional:!0,array:!1},exclude_references:{type:"boolean",optional:!0,array:!1},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1}}},RunQueryResponse:{type:"struct",name:"RunQueryResponse",fields:{result:{type:"Result",optional:!0,array:!1},default_row_limit_added:{type:"number",optional:!0,array:!1},logs:{type:"LogMessage",array:!0,optional:!0},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1},timing_info:{type:"TimingInfo",optional:!0,array:!1}}},SQLNativeCell:{type:"struct",name:"SQLNativeCell",fields:{sql_native_value:{type:"string",optional:!1,array:!1}}},SQLNativeType:{type:"struct",name:"SQLNativeType",fields:{sql_type:{type:"string",optional:!0,array:!1}}},SQLQuery:{type:"struct",name:"SQLQuery",fields:{sql:{type:"string",optional:!1,array:!1},schema:{type:"Schema",optional:!0,array:!1},connection_name:{type:"string",optional:!1,array:!1}}},SQLTable:{type:"struct",name:"SQLTable",fields:{name:{type:"string",optional:!1,array:!1},schema:{type:"Schema",optional:!0,array:!1},connection_name:{type:"string",optional:!1,array:!1}}},Schema:{type:"struct",name:"Schema",fields:{fields:{type:"FieldInfo",array:!0,optional:!1}}},SourceInfo:{type:"struct",name:"SourceInfo",fields:{name:{type:"string",optional:!1,array:!1},schema:{type:"Schema",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0},parameters:{type:"ParameterInfo",array:!0,optional:!0}}},StringCell:{type:"struct",name:"StringCell",fields:{string_value:{type:"string",optional:!1,array:!1}}},StringLiteral:{type:"struct",name:"StringLiteral",fields:{string_value:{type:"string",optional:!1,array:!1}}},StringType:{type:"struct",name:"StringType",fields:{}},TimeTruncationFieldReference:{type:"struct",name:"TimeTruncationFieldReference",fields:{field_reference:{type:"Reference",optional:!1,array:!1},truncation:{type:"TimestampTimeframe",optional:!1,array:!1}}},TimestampCell:{type:"struct",name:"TimestampCell",fields:{timestamp_value:{type:"string",optional:!1,array:!1}}},TimestampLiteral:{type:"struct",name:"TimestampLiteral",fields:{timestamp_value:{type:"string",optional:!1,array:!1},granularity:{type:"TimestampTimeframe",optional:!0,array:!1},timezone:{type:"string",optional:!0,array:!1}}},TimestampTimeframe:{type:"enum",name:"TimestampTimeframe",values:{year:1,quarter:2,month:3,week:4,day:5,hour:6,minute:7,second:8}},TimestampType:{type:"struct",name:"TimestampType",fields:{timeframe:{type:"TimestampTimeframe",optional:!0,array:!1}}},TimestamptzType:{type:"struct",name:"TimestamptzType",fields:{timeframe:{type:"TimestampTimeframe",optional:!0,array:!1}}},TimingInfo:{type:"struct",name:"TimingInfo",fields:{name:{type:"string",optional:!1,array:!1},duration_ms:{type:"number",optional:!1,array:!1},detailed_timing:{type:"TimingInfo",array:!0,optional:!0}}},Translation:{type:"struct",name:"Translation",fields:{url:{type:"string",optional:!1,array:!1},compiled_model_json:{type:"string",optional:!0,array:!1}}},View:{type:"struct",name:"View",fields:{definition:{type:"ViewDefinition",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0}}},ViewArrow:{type:"struct",name:"ViewArrow",fields:{source:{type:"ViewDefinition",optional:!1,array:!1},view:{type:"ViewDefinition",optional:!1,array:!1}}},ViewDefinition:{type:"union",name:"ViewDefinition",options:{arrow:"ViewArrow",view_reference:"Reference",refinement:"ViewRefinement",segment:"ViewSegment"}},ViewInfo:{type:"struct",name:"ViewInfo",fields:{name:{type:"string",optional:!1,array:!1},schema:{type:"Schema",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0},definition:{type:"View",optional:!0,array:!1}}},ViewOperation:{type:"union",name:"ViewOperation",options:{group_by:"GroupBy",aggregate:"Aggregate",order_by:"OrderBy",limit:"Limit",where:"FilterOperation",nest:"Nest",having:"FilterOperation",drill:"DrillOperation",calculate:"CalculateOperation"}},ViewRefinement:{type:"struct",name:"ViewRefinement",fields:{base:{type:"ViewDefinition",optional:!1,array:!1},refinement:{type:"ViewDefinition",optional:!1,array:!1}}},ViewSegment:{type:"struct",name:"ViewSegment",fields:{operations:{type:"ViewOperation",array:!0,optional:!1}}}}),Bt}var Gt={},Kt={},Ut={},Gr;function Fi(){return Gr||(Gr=1,Object.defineProperty(Ut,"__esModule",{value:!0}),Ut.RESERVED_WORDS=void 0,Ut.RESERVED_WORDS=["all","and","as","asc","avg","boolean","by","case","cast","compose","count","date","day","days","desc","distinct","else","end","exclude","export","extend","false","filter","for","from","full","has","hour","hours","import","in","include","inner","internal","is","json","left","like","max","min","minute","minutes","month","months","not","now","null","number","on","or","pick","private","public","quarter","quarters","right","second","seconds","source","sql","string","sum","table","then","this","timestamp","timestamptz","to","true","virtual","week","weeks","when","with","year","years"]),Ut}var Ur;function Oi(){if(Ur)return Kt;Ur=1,Object.defineProperty(Kt,"__esModule",{value:!0}),Kt.maybeQuoteIdentifier=W;const f=Fi();function ie(P){const k=!P.match(/^[A-Za-z_][A-Za-z_0-9]*$/),$=f.RESERVED_WORDS.includes(P.toLowerCase());return k||$}function W(P){return ie(P)?`\`${P}\``:P}return Kt}var jr;function Ei(){if(jr)return Gt;jr=1,Object.defineProperty(Gt,"__esModule",{value:!0}),Gt.queryToMalloy=ie,Gt.filterToMalloy=W;const f=Oi();function ie(m,{tabWidth:S}={tabWidth:2}){const V=pe(m);return y(V,{tabWidth:S})}function W(m,{tabWidth:S}={tabWidth:2}){const V=Ne(m);return y(V,{tabWidth:S})}const P=Symbol("indent"),k=Symbol("newline"),$=Symbol("outdent"),w=Symbol("optional_newline_indent");function y(m,{tabWidth:S}={tabWidth:2}){let V="",E=0,B=!0;for(const z of m)if(z===k)V+=`
18
+ `,B=!0;else if(z===$)E--;else if(z===P)E++;else{if(z===w)continue;B&&(V+=" ".repeat(E*S),B=!1),V+=z}return V}function o(m,S,V,E){var B;if(S.includes(k))return[m,k,P,...S,k,$,V];const _e=((B=E?.spaces)!==null&&B!==void 0?B:!0)?" ":"";return[m,_e,...S,_e,V]}function d(m){return{contents:m,quoteCharacter:'"'}}function e(m,S){const V=[];for(let E=0;E<m.length;E++){const B=m[E];V.push(B),E<m.length-1&&V.push(S)}return V}function C(m){var S,V;switch(m.kind){case"filter_expression_literal":return[Ee(m.filter_expression_value)];case"boolean_literal":return[m.boolean_value.toString()];case"string_literal":{const{contents:E,quoteCharacter:B}=d(m.string_value);return[B,E,B]}case"number_literal":return[m.number_value.toString()];case"null_literal":return["null"];case"date_literal":return[Z(N(m.date_value),(S=m.granularity)!==null&&S!==void 0?S:"day",m.timezone)];case"timestamp_literal":return[Z(N(m.timestamp_value),(V=m.granularity)!==null&&V!==void 0?V:"second",m.timezone)]}}function N(m){let S;if(S=/(\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)/.exec(m)){const[V,E,B,z,_e,Be,it]=S;return[E,B,z,_e,Be,it]}else if(S=/(\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d)/.exec(m)){const[V,E,B,z,_e,Be]=S;return[E,B,z,_e,Be,"00"]}else if(S=/(\d\d\d\d)-(\d\d)-(\d\d) (\d\d)(?:00)?/.exec(m)){const[V,E,B,z,_e]=S;return[E,B,z,_e,"00","00"]}else if(S=/(\d\d\d\d)-(\d\d)-(\d\d)/.exec(m)){const[V,E,B,z]=S;return[E,B,z,"00","00","00"]}else if(S=/(\d\d\d\d)-(\d\d)/.exec(m)){const[V,E,B]=S;return[E,B,"01","00","00","00"]}else if(S=/(\d\d\d\d)/.exec(m)){const[V,E]=S;return[E,"01","01","00","00","00"]}return["1970","01","01","00","00","00"]}function Z([m,S,V,E,B,z],_e,Be){switch(_e){case"year":return`@${m}`;case"quarter":{const it=Math.floor(+S/3)+1;return`@${m}-Q${it}`}case"month":return`@${m}-${S}`;case"week":return`@${m}-${S}-${V}-WK`;case"day":return`@${m}-${S}-${V}`;case"hour":return`@${m}-${S}-${V} ${E}`;case"minute":return`@${m}-${S}-${V} ${E}:${B}`;case"second":return Be!==void 0?`@${m}-${S}-${V} ${E}:${B}:${z}[${Be}]`:`@${m}-${S}-${V} ${E}:${B}:${z}`;default:throw new Error("Unknown timeframe.")}}function ne(m){var S;const V=[];for(const E of(S=m.path)!==null&&S!==void 0?S:[])V.push((0,f.maybeQuoteIdentifier)(E)),V.push(".");if(V.push((0,f.maybeQuoteIdentifier)(m.name)),m.parameters){const E=[];for(let B=0;B<m.parameters.length;B++){const z=m.parameters[B];E.push((0,f.maybeQuoteIdentifier)(z.name)),E.push(" is "),E.push(...C(z.value)),B<m.parameters.length-1&&E.push(",",k)}V.push(...o("(",E,")",{spaces:!1}))}return V}function pe(m){const S=[];return S.push(...Ye(m.annotations)),S.push("run: "),S.push(...A(m.definition)),S}function O(m){const S=[];switch(m.kind){case"source_reference":{S.push(...ne(m));break}case"refinement":S.push(...A(m));break}return S}function A(m){const S=[];switch(m.kind){case"arrow":{S.push(...O(m.source)),S.push(" -> "),S.push(...F(m.view));break}case"query_reference":{S.push(...ne(m));break}case"refinement":{const V=A(m.base);m.base.kind==="arrow"?S.push(...o("(",V,")",{spaces:!1})):S.push(...V),S.push(" + "),S.push(...F(m.refinement));break}}return S}function F(m){const S=[];switch(m.kind){case"arrow":{S.push(...F(m.source)),S.push(" -> "),S.push(...F(m.view));break}case"view_reference":{S.push(...ne(m));break}case"refinement":{S.push(...F(m.base)),S.push(" + "),S.push(...F(m.refinement));break}case"segment":{S.push(...G(m));break}}return S}function G(m){if(m.operations.length===0)return["{ }"];const S=m.operations.length>1,V=[];for(let E=0;E<m.operations.length;E++){const B=m.operations[E],z=[B];for(;E<m.operations.length-1;){const _e=m.operations[E+1];if(_e.kind===B.kind)z.push(_e),E++;else break}V.push(...he(z)),S&&E<m.operations.length-1&&V.push(k)}return o("{",V,"}")}function he(m){switch(m[0].kind){case"aggregate":return Qe(m,"aggregate");case"group_by":return Qe(m,"group_by");case"order_by":return nt(m);case"nest":return je(m);case"limit":return Ce(m);case"where":return De(m);case"having":return Me(m);case"drill":return lt(m);case"calculate":return Qe(m,"calculate")}}function Fe(m,S,V=""){const E=[];E.push(`${m}:`);const B=S.length>1||S.some(z=>z.includes(k));B?E.push(k,P):E.push(" ");for(let z=0;z<S.length;z++){const _e=S[z];E.push(..._e),S.length>1&&z<S.length-1&&E.push(V),B&&z<S.length-1&&E.push(k)}return B&&E.push($),E}function we(m){const S=[];return S.push(...Te(m.expression)),S}function He(m){return m}function Te(m){var S;switch(m.kind){case"field_reference":return ne(m);case"time_truncation":return[...ne(m.field_reference),".",m.truncation];case"filtered_field":return[...ne(m.field_reference),...o(" {",De(m.where),"}")];case"literal_value":return C(m.literal_value);case"moving_average":{const V=["avg_moving",...o("(",[...ne(m.field_reference),m.rows_preceding!==void 0?`, ${m.rows_preceding}`:", 0",m.rows_following!==void 0?`, ${m.rows_following}`:""],")",{spaces:!1})];return!((S=m.partition_fields)===null||S===void 0)&&S.length&&V.push(...o(" {",["partition_by",": ",...e(m.partition_fields.flatMap(E=>ne(E)),", ")],"}")),V}}}function me(m,S=!1){const V=[];return S||V.push(...Ye(m.field.annotations)),m.name&&(V.push((0,f.maybeQuoteIdentifier)(m.name)),V.push(" is ")),V.push(...we(m.field)),V}function Qe(m,S){const V=[],E=m.length===1;return E&&V.push(...Ye(m[0].field.annotations)),V.push(...Fe(S,m.map(B=>me(B,E)))),V}function nt(m){return Fe("order_by",m.map(Re),",")}function Re(m){const S=[];return S.push(...ne(m.field_reference)),m.direction&&(S.push(" "),S.push(m.direction)),S}function je(m){const S=[],V=m.length===1;return V&&S.push(...Ye(m[0].view.annotations)),S.push(...Fe("nest",m.map(E=>at(E,V)))),S}function at(m,S=!1){const V=[];return S||V.push(...Ye(m.view.annotations)),m.name&&(V.push((0,f.maybeQuoteIdentifier)(m.name)),V.push(" is ")),V.push(...st(m.view)),V}function st(m){return F(m.definition)}function ke(m){return[`limit: ${m.limit}`]}function Ce(m){const S=[];for(let V=0;V<m.length;V++)V!==0&&S.push(k),S.push(...ke(m[V]));return S}function De(m){return Fe("where",m.map(Ke),",")}function lt(m){return Fe("drill",m.map(Ke),",")}function Me(m){return Fe("having",m.map(Ke),",")}const Oe=["`","'",'"'];function Ee(m){let S,V;for(const E of Oe){const B=Ze(m,E);if(B===m)return`f${E}${m}${E}`;(V===void 0||B.length<V.length)&&(S=E,V=B)}return`f${S}${V}${S}`}function Ze(m,S){let V="";for(let E=0;E<m.length;E++)m.slice(E).startsWith(S)?(V+="\\"+S,E+=S.length):(V+=m[E],m[E]==="\\"&&(V+=m[++E]));return V}function Ne(m){switch(m.kind){case"filter_string":return[...Te(m.expression)," ~ ",Ee(m.filter)];case"literal_equality":return[...Te(m.expression)," = ",...C(m.value)]}}function Ke(m){return Ne(m.filter)}function Ye(m){return m?m.flatMap(q):[]}function q(m){return[m.value.trim(),k]}return Gt}var Rt={},Wr;function ki(){if(Wr)return Rt;Wr=1,Object.defineProperty(Rt,"__esModule",{value:!0}),Rt.nestUnions=ie,Rt.unnestUnions=W,Rt.convertFromThrift=P,Rt.convertToThrift=$;const f=Hr();function ie(w){if(w==null)return w;if(typeof w=="string"||typeof w=="number"||typeof w=="boolean")return w;if(Array.isArray(w))return w.map(ie);{const y={};let o;for(const d in w)d==="kind"?o=w[d]:y[d]=ie(w[d]);return o===void 0?y:{[o]:y}}}function W(w,y){if(w==null)return w;if(typeof w=="string"||typeof w=="number"||typeof w=="boolean")return w;if(Array.isArray(w))return w.map(o=>W(o,y));{const o=k(y);if(o.type==="union"){for(const d in o.options)if(w[d]!==void 0){const e=W(w[d],o.options[d]);if(typeof e=="object")return{kind:d,...e}}}else if(o.type==="struct"){const d={};for(const e in w){const C=o.fields[e];if(C===void 0)throw new Error(`Unknown field ${e} in ${y}`);d[e]=W(w[e],C.type)}return d}else throw new Error(`Cannot unnest unions in an enum type ${y}`)}}function P(w,y){if(w==null)return w;if(typeof w=="string"||typeof w=="boolean")return w;if(typeof w=="number"){if(y==="number")return w;const o=k(y);if(o.type!=="enum")throw new Error(`Found a number where a ${y} was expected`);const d=Object.entries(o.values).find(([,e])=>e===w);if(d===void 0)throw new Error(`${w} is not a valid enum value for ${y}`);return d[0]}else{if(Array.isArray(w))return w.map(o=>P(o,y));{const o=k(y);if(o.type==="union"){for(const d in o.options)if(w[d]!==void 0&&w[d]!==null){const e=P(w[d],o.options[d]);if(typeof e=="object")return{kind:d,...e}}}else if(o.type==="struct"){const d={};for(const e in w){const C=o.fields[e];if(C===void 0)throw new Error(`Unknown field ${e} in ${y}`);d[e]=P(w[e],C.type)}return d}else throw new Error(`Cannot unnest unions in an enum type ${y}`)}}}function k(w){const y=f.MALLOY_INTERFACE_TYPES[w];if(y===void 0)throw new Error(`Unknown Malloy interface type ${w}`);return y}function $(w,y){if(w==null)return w;if(typeof w=="number"||typeof w=="boolean")return w;if(typeof w=="string"){if(y==="string")return w;const o=k(y);if(o.type==="enum"){const d=o.values[w];if(d===void 0)throw new Error(`${w} is not a valid enum value for ${y}`);return d}}else{if(Array.isArray(w))return w.map(o=>$(o,y));{const o=k(y);if(o.type==="union"){const d=w.kind,e=o.options[d];if(e===void 0)throw new Error(`${d} is not a valid union of ${y}`);const C=k(e);if(C.type!=="struct")throw new Error("Union fields must be structs");const N={};for(const Z in w){if(Z==="kind")continue;const ne=C.fields[Z];N[Z]=$(w[Z],ne.type)}return{[d]:N}}else if(o.type==="struct"){const d={};for(const e in w){const C=o.fields[e];if(C===void 0)throw new Error(`Unknown field ${e} in ${y}`);d[e]=$(w[e],C.type)}return d}}}}return Rt}var zr;function Ri(){return zr||(zr=1,(function(f){var ie=kt&&kt.__createBinding||(Object.create?(function($,w,y,o){o===void 0&&(o=y);var d=Object.getOwnPropertyDescriptor(w,y);(!d||("get"in d?!w.__esModule:d.writable||d.configurable))&&(d={enumerable:!0,get:function(){return w[y]}}),Object.defineProperty($,o,d)}):(function($,w,y,o){o===void 0&&(o=y),$[o]=w[y]})),W=kt&&kt.__exportStar||function($,w){for(var y in $)y!=="default"&&!Object.prototype.hasOwnProperty.call(w,y)&&ie(w,$,y)};Object.defineProperty(f,"__esModule",{value:!0}),f.thingy4sddfdfsd=f.thingy4sdfsd=f.thingy4dfdsfs=f.thingy4asdfas=f.thingy4asdfasdf=f.thingy3dfdf=f.thingy3=f.thingy2asdf=f.thingyssdfg=f.thingy123r=f.thingy1=f.res=f.test=f.convertToThrift=f.convertFromThrift=f.unnestUnions=f.nestUnions=f.filterToMalloy=f.queryToMalloy=void 0,W(Hr(),f);var P=Ei();Object.defineProperty(f,"queryToMalloy",{enumerable:!0,get:function(){return P.queryToMalloy}}),Object.defineProperty(f,"filterToMalloy",{enumerable:!0,get:function(){return P.filterToMalloy}});var k=ki();Object.defineProperty(f,"nestUnions",{enumerable:!0,get:function(){return k.nestUnions}}),Object.defineProperty(f,"unnestUnions",{enumerable:!0,get:function(){return k.unnestUnions}}),Object.defineProperty(f,"convertFromThrift",{enumerable:!0,get:function(){return k.convertFromThrift}}),Object.defineProperty(f,"convertToThrift",{enumerable:!0,get:function(){return k.convertToThrift}}),f.test={entries:[{kind:"source",name:"flights",schema:{fields:[{kind:"dimension",name:"carrier",type:{kind:"boolean_type"},annotations:[{value:"# foo=1"}]},{kind:"dimension",name:"arr",type:{kind:"array_type",element_type:{kind:"boolean_type"}}},{kind:"dimension",name:"arr_rec",type:{kind:"array_type",element_type:{kind:"record_type",fields:[{name:"arr",type:{kind:"array_type",element_type:{kind:"boolean_type"}}}]}}},{kind:"dimension",name:"rec",type:{kind:"record_type",fields:[{name:"arr",type:{kind:"array_type",element_type:{kind:"boolean_type"}}}]}},{kind:"join",name:"carriers",relationship:"one",schema:{fields:[{kind:"dimension",name:"code",type:{kind:"string_type"}}]}},{kind:"view",name:"by_carrier",schema:{fields:[{kind:"dimension",name:"carrier",type:{kind:"string_type"}},{kind:"dimension",name:"flight_count",type:{kind:"number_type"}}]}}]},parameters:[{name:"param",type:{kind:"number_type"},default_value:{kind:"number_literal",number_value:7}}]}],anonymous_queries:[]},f.res={connection_name:"foo",data:{kind:"array_cell",array_value:[{kind:"record_cell",record_value:[{kind:"string_cell",string_value:"UA"},{kind:"number_cell",number_value:12341234}]},{kind:"record_cell",record_value:[{kind:"string_cell",string_value:"AA"},{kind:"number_cell",number_value:2343}]}]},schema:{fields:[{kind:"dimension",name:"carrier",type:{kind:"string_type"}},{kind:"dimension",name:"flight_count",type:{kind:"number_type"}}]},sql:"SELECT * ..."},f.thingy1={definition:{kind:"query_reference",name:"flights_by_carrier"}},f.thingy123r={definition:{kind:"arrow",source:{kind:"source_reference",name:"flights"},view:{kind:"view_reference",name:"by_carrier"}}},f.thingyssdfg={definition:{kind:"refinement",base:{kind:"query_reference",name:"flights"},refinement:{kind:"view_reference",name:"by_carrier"}}},f.thingy2asdf={definition:{kind:"arrow",source:{kind:"source_reference",name:"flights"},view:{kind:"refinement",base:{kind:"view_reference",name:"by_carrier"},refinement:{kind:"segment",operations:[{kind:"where",filter:{kind:"filter_string",expression:{kind:"field_reference",name:"carrier"},filter:"WN"}}]}}}},f.thingy3={definition:{kind:"arrow",source:{kind:"source_reference",name:"flights"},view:{kind:"refinement",base:{kind:"view_reference",name:"by_carrier"},refinement:{kind:"segment",operations:[{kind:"group_by",field:{expression:{kind:"field_reference",name:"carrier"}}},{kind:"group_by",field:{expression:{kind:"field_reference",name:"foo"}}}]}}}},f.thingy3dfdf={definition:{kind:"arrow",source:{kind:"source_reference",name:"flights"},view:{kind:"refinement",base:{kind:"view_reference",name:"by_carrier"},refinement:{kind:"view_reference",name:"top10"}}}},f.thingy4asdfasdf={definition:{kind:"arrow",source:{kind:"source_reference",name:"flights"},view:{kind:"segment",operations:[{kind:"group_by",field:{expression:{kind:"field_reference",name:"carrier"}}},{kind:"group_by",field:{expression:{kind:"field_reference",name:"foo"}}}]}}},f.thingy4asdfas={definition:{kind:"arrow",source:{kind:"source_reference",name:"flights"},view:{kind:"view_reference",name:"by_carrier"}}},f.thingy4dfdsfs={definition:{kind:"arrow",source:{kind:"source_reference",name:"flights"},view:{kind:"refinement",base:{kind:"view_reference",name:"by_carrier"},refinement:{kind:"segment",operations:[{kind:"limit",limit:10}]}}}},f.thingy4sdfsd={definition:{kind:"arrow",source:{kind:"source_reference",name:"flights"},view:{kind:"segment",operations:[{kind:"group_by",field:{expression:{kind:"field_reference",name:"carrier"}}},{kind:"limit",limit:10}]}}},f.thingy4sddfdfsd={definition:{kind:"arrow",source:{kind:"source_reference",name:"flights"},view:{kind:"segment",operations:[]}}}})(kt)),kt}var Vt={},yt={},Yr;function Vi(){return Yr||(Yr=1,(function(f){var ie=yt&&yt.__createBinding||(Object.create?(function(g,t,a,l){l===void 0&&(l=a);var b=Object.getOwnPropertyDescriptor(t,a);(!b||("get"in b?!t.__esModule:b.writable||b.configurable))&&(b={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(g,l,b)}):(function(g,t,a,l){l===void 0&&(l=a),g[l]=t[a]})),W=yt&&yt.__setModuleDefault||(Object.create?(function(g,t){Object.defineProperty(g,"default",{enumerable:!0,value:t})}):function(g,t){g.default=t}),P=yt&&yt.__importStar||(function(){var g=function(t){return g=Object.getOwnPropertyNames||function(a){var l=[];for(var b in a)Object.prototype.hasOwnProperty.call(a,b)&&(l[l.length]=b);return l},g(t)};return function(t){if(t&&t.__esModule)return t;var a={};if(t!=null)for(var l=g(t),b=0;b<l.length;b++)l[b]!=="default"&&ie(a,t,l[b]);return W(a,t),a}})();Object.defineProperty(f,"__esModule",{value:!0}),f.ASTAnnotationList=f.ASTLimitViewOperation=f.ASTView=f.ASTFilterWithLiteralEquality=f.ASTFilterWithFilterString=f.ASTFilter=f.ASTCalculateViewOperation=f.ASTHavingViewOperation=f.ASTDrillViewOperation=f.ASTWhereViewOperation=f.ASTNestViewOperation=f.ASTFilteredFieldExpression=f.ASTFilterOperationList=f.ASTFilterOperation=f.ASTMovingAverageExpression=f.ASTFieldReferenceList=f.ASTLiteralValueExpression=f.ASTTimeTruncationExpression=f.ASTReferenceExpression=f.ASTExpression=f.ASTField=f.ASTAggregateViewOperation=f.ASTGroupByViewOperation=f.ASTOrderByViewOperation=f.ASTViewOperation=f.ASTViewOperationList=f.ASTSegmentViewDefinition=f.ASTRefinementViewDefinition=f.ASTArrowViewDefinition=f.ASTReferenceViewDefinition=f.ASTReferenceQueryArrowSource=f.ASTReferenceQueryDefinition=f.ASTRefinementQueryDefinition=f.ASTArrowQueryDefinition=f.ASTQueryDefinition=f.ASTQueryArrowSource=f.ASTUnimplemented=f.ASTFilterExpressionLiteralValue=f.ASTTimestampLiteralValue=f.ASTDateLiteralValue=f.ASTBooleanLiteralValue=f.ASTNumberLiteralValue=f.ASTNullLiteralValue=f.ASTStringLiteralValue=f.ASTLiteralValue=f.ASTParameterValue=f.ASTParameterValueList=f.ASTFieldReference=f.ASTReference=f.ASTQuery=void 0,f.ASTAnnotation=void 0;const k=P(Ri()),$=gi(),w=P(bi());class y{constructor(){this.edited=!1}edit(){return this.edited=!0,this._parent&&this._parent.edit(),this}get as(){const t=this;return{Query(){if(t instanceof C)return t;throw new Error("Not an ASTQuery")},Reference(){if(t instanceof N)return t;throw new Error("Not an ASTReference")},ReferenceQueryArrowSource(){if(t instanceof nt)return t;throw new Error("Not an ASTReferenceQueryArrowSource")},ParameterValueList(){if(t instanceof ne)return t;throw new Error("Not an ASTParameterValueList")},FilterOperation(){if(t instanceof S)return t;throw new Error("Not an ASTFilterOperation")},FilterOperationList(){if(t instanceof V)return t;throw new Error("Not an ASTFilterOperationList")},ParameterValue(){if(t instanceof pe)return t;throw new Error("Not an ASTParameterValue")},StringLiteralValue(){if(t instanceof O)return t;throw new Error("Not an ASTStringLiteralValue")},NumberLiteralValue(){if(t instanceof F)return t;throw new Error("Not an ASTNumberLiteralValue")},ViewOperationList(){if(t instanceof lt)return t;throw new Error("Not an ASTViewOperationList")},GroupByViewOperation(){if(t instanceof Oe)return t;throw new Error("Not an ASTGroupByViewOperation")},AggregateViewOperation(){if(t instanceof Ee)return t;throw new Error("Not an ASTAggregateViewOperation")},OrderByViewOperation(){if(t instanceof Me)return t;throw new Error("Not an ASTOrderByViewOperation")},Field(){if(t instanceof Ze)return t;throw new Error("Not an ASTField")},ReferenceExpression(){if(t instanceof Ne)return t;throw new Error("Not an ASTReferenceExpression")},ReferenceViewDefinition(){if(t instanceof st)return t;throw new Error("Not an ASTReferenceViewDefinition")},ArrowQueryDefinition(){if(t instanceof Te)return t;throw new Error("Not an ASTArrowQueryDefinition")},ArrowViewDefinition(){if(t instanceof ke)return t;throw new Error("Not an ASTArrowViewDefinition")},RefinementViewDefinition(){if(t instanceof Ce)return t;throw new Error("Not an ASTRefinementViewDefinition")},TimeTruncationExpression(){if(t instanceof Ke)return t;throw new Error("Not an ASTTimeTruncationExpression")},FilteredFieldExpression(){if(t instanceof E)return t;throw new Error("Not an ASTFilteredFieldExpression")},NestViewOperation(){if(t instanceof z)return t;throw new Error("Not an ASTNestViewOperation")},View(){if(t instanceof Ae)return t;throw new Error("Not an ASTView")},SegmentViewDefinition(){if(t instanceof De)return t;throw new Error("Not an ASTSegmentViewDefinition")},LimitViewOperation(){if(t instanceof et)return t;throw new Error("Not an ASTLimitViewOperation")},AnnotationList(){if(t instanceof We)return t;throw new Error("Not an ASTAnnotationList")},Annotation(){if(t instanceof ft)return t;throw new Error("Not an ASTAnnotation")}}}get find(){const t=this;return{Query(a){return t.findAny(a).as.Query()},Reference(a){return t.findAny(a).as.Reference()},ReferenceQueryArrowSource(a){return t.findAny(a).as.ReferenceQueryArrowSource()},ParameterValueList(a){return t.findAny(a).as.ParameterValueList()},FilterOperation(a){return t.findAny(a).as.FilterOperation()},FilterOperationList(a){return t.findAny(a).as.FilterOperationList()},ParameterValue(a){return t.findAny(a).as.ParameterValue()},StringLiteralValue(a){return t.findAny(a).as.StringLiteralValue()},NumberLiteralValue(a){return t.findAny(a).as.NumberLiteralValue()},ViewOperationList(a){return t.findAny(a).as.ViewOperationList()},GroupByViewOperation(a){return t.findAny(a).as.GroupByViewOperation()},AggregateViewOperation(a){return t.findAny(a).as.AggregateViewOperation()},OrderByViewOperation(a){return t.findAny(a).as.OrderByViewOperation()},Field(a){return t.findAny(a).as.Field()},ReferenceExpression(a){return t.findAny(a).as.ReferenceExpression()},ReferenceViewDefinition(a){return t.findAny(a).as.ReferenceViewDefinition()},ArrowQueryDefinition(a){return t.findAny(a).as.ArrowQueryDefinition()},ArrowViewDefinition(a){return t.findAny(a).as.ArrowViewDefinition()},RefinementViewDefinition(a){return t.findAny(a).as.RefinementViewDefinition()},TimeTruncationExpression(a){return t.findAny(a).as.TimeTruncationExpression()},FilteredFieldExpression(a){return t.findAny(a).as.FilteredFieldExpression()},NestViewOperation(a){return t.findAny(a).as.NestViewOperation()},View(a){return t.findAny(a).as.View()},SegmentViewDefinition(a){return t.findAny(a).as.SegmentViewDefinition()},LimitViewOperation(a){return t.findAny(a).as.LimitViewOperation()},AnnotationList(a){return t.findAny(a).as.AnnotationList()},Annotation(a){return t.findAny(a).as.Annotation()}}}get parent(){if(this._parent===void 0)throw new Error("This node does not have a parent");return this._parent}set parent(t){this._parent=t}static schemaTryGet(t,a,l){return y._schemaTryGet(t,a,l,!1)}static schemaTryGetDrillField(t,a,l){return y._schemaTryGet(t,a,l,!0)}static _schemaTryGet(t,a,l,b){let L=t.fields;for(const u of l??[]){const X=L.find(ue=>ue.name===u);if(X===void 0)throw new Error(`${u} not found`);if(X.kind==="join"||b&&X.kind==="view"){L=X.schema.fields;continue}if(X.kind==="dimension"||X.kind==="measure"){if(X.type.kind==="record_type"){L=X.type.fields.map(ue=>({kind:X.kind,...ue}));continue}else if(X.type.kind==="array_type"&&X.type.element_type.kind==="record_type"){L=X.type.element_type.fields.map(ue=>({kind:X.kind,...ue}));continue}}throw new Error(`${u} is not a join, record, or repeated record`)}return L.find(u=>u.name===a)}static schemaGet(t,a,l){const b=y.schemaTryGet(t,a,l);if(b===void 0)throw new Error(`${a} not found`);return b}static schemaGetDrillField(t,a,l){const b=y.schemaTryGetDrillField(t,a,l);if(b===void 0)throw new Error(`${a} not found`);return b}static schemaMerge(t,a){return{fields:[...t.fields,...a.fields]}}static tagFor(t,a="# "){var l,b;const L=(b=(l=t.annotations)===null||l===void 0?void 0:l.map(u=>u.value))===null||b===void 0?void 0:b.filter(u=>u.startsWith(a)),K=new $.TagParser;for(const u of L??[])K.parseAnnotation(u);return K.finish()}static fieldWasCalculation(t){if(t.kind!=="dimension")throw new Error(`${t.name} could not be an output field, because it is a ${t.kind}, and only dimensions can appear in output schemas`);return y.tagFor(t,"#(malloy) ").has("calculation")}}function o(g){return Array.isArray(g)||typeof g=="string"||typeof g=="number"||typeof g=="boolean"}class d extends y{constructor(t,a){super(),this.node=t,this.children=a,this.originalChildren=[...a],a.forEach(l=>l.parent=this)}*iter(){for(let t=0;t<this.length;t++)yield this.index(t)}get length(){return this.children.length}get last(){return this.children[this.children.length-1]}index(t){return this.children[t]}insert(t,a){this.edit(),this.children.splice(a,0,t),t.parent=this}add(t){this.edit(),this.children.push(t),t.parent=this}remove(t){const a=this.children.findIndex(l=>l===t);if(a===-1)return this;this.edit(),this.children.splice(a,1)}build(){if(!this.edited)return this.node;const t=this.children.map(a=>a.build());return this.edited=!1,this.originalChildren=[...this.children],this.node=t,t}findAny(t){if(t.length===0)return this;const[a,...l]=t;if(typeof a!="number")throw new Error(`${this.constructor.name} is a ASTListNode and thus cannot contain a ${a}`);return this.children[a].findAny(l)}findIndex(t){return this.children.findIndex(t)}indexOf(t){return this.children.indexOf(t)}}class e extends y{constructor(t,a){super(),this.node=t,this.children=a;for(const l in a){const b=a[l];b&&!o(b)&&(b.parent=this)}}build(){if(!this.edited)return this.node;let t=this.node;for(const a in this.children){const l=this.children[a];l===void 0?t={...t,[a]:void 0}:o(l)?this.edited&&(t={...t,[a]:l}):t={...t,[a]:l.build()}}return this.node=t,this.edited=!1,t}findAny(t){if(t.length===0)return this;const[a,...l]=t;if(typeof a!="string")throw new Error(`${this.constructor.name} is a ASTListNode and thus cannot contain a ${a}`);const b=this.children[a];if(o(b))throw new Error(`${this.constructor.name}.${a} refers to a basic type, not an ASTNode`);return b._find(l)}}class C extends e{constructor(t){var a,l;let b=t.source;if(b===void 0){if(t.model===void 0)throw new Error("Need a model or source");if(t.query){const X=t.query.definition;if(X.kind==="arrow"&&X.source.kind==="source_reference"){const ue=X.source.name;if(b=t.model.entries.find(ot=>ot.name===ue),b===void 0)throw new Error(`Model does not contain source or query named ${ue}`)}}if(b===void 0&&(b=t.model.entries[0]),b===void 0)throw new Error("Model does not contain any sources or queries")}const L=_(b),K=(a=t.query)!==null&&a!==void 0?a:{definition:{kind:"arrow",source:{kind:"source_reference",name:L.name},view:{kind:"segment",operations:[]}}},u=(l=t.model)!==null&&l!==void 0?l:{entries:[L],anonymous_queries:[]};super(K,{definition:f.ASTQueryDefinition.from(K.definition),annotations:K.annotations&&new We(K.annotations)}),this.model=u,t.source&&this.setSource(t.source.name)}get definition(){return this.children.definition}set definition(t){this.edit(),this.children.definition=t,t.parent=this}get annotations(){return this.children.annotations}reorderFields(t){this.definition.reorderFields(t)}getOrAddAnnotations(){if(this.annotations)return this.annotations;this.edit();const t=new We([]);return this.children.annotations=t,t.parent=this,t}getInheritedTag(t="# "){return qe(t,this.getInheritedAnnotations())}getIntrinsicTag(t="# "){var a,l;return(l=(a=this.annotations)===null||a===void 0?void 0:a.getIntrinsicTag(t))!==null&&l!==void 0?l:new $.Tag}getTag(t="# "){var a,l;return(l=(a=this.annotations)===null||a===void 0?void 0:a.getTag(t))!==null&&l!==void 0?l:this.getInheritedTag(t)}setTagProperty(t,a=null,l="# "){this.getOrAddAnnotations().setTagProperty(t,a,l)}removeTagProperty(t,a="# "){this.getTag().has(...t)&&this.getOrAddAnnotations().removeTagProperty(t,a)}setViewToEmptySegment(){if(!(this.definition instanceof Te))throw new Error("Must set source before setting view");return this.definition=new Te({kind:"arrow",source:this.definition.source.build(),view:{kind:"segment",operations:[]}}),this.definition.view.as.SegmentViewDefinition()}isRunnable(){return this.definition.isRunnable()}isEmpty(){return this.definition instanceof Te&&this.definition.view instanceof De&&this.definition.view.operations.length===0}getOrAddDefaultSegment(){return this.definition.getOrAddDefaultSegment()}setSource(t){if(this.definition instanceof Te&&this.definition.source instanceof nt&&this.definition.source.name===t)return;if(this.model.entries.find(l=>l.name===t)===void 0)throw new Error(`Source ${t} is not defined in model`);this.definition=new Te({kind:"arrow",source:{kind:"source_reference",name:t},view:this.definition instanceof Te?this.definition.view.build():{kind:"segment",operations:[]}})}setQueryHead(t){const a=this.model.entries.find(l=>l.name===t);if(a===void 0||a.kind!=="query")throw new Error(`No query named ${t} in the model`);this.definition=new Qe({kind:"query_reference",name:t})}getQueryInfo(t){const a=this.model.entries.find(l=>l.name===t);if(a===void 0)throw new Error(`Query ${t} is not defined in model`);if(a.kind!=="query")throw new Error(`Model entry ${t} is not a query`);return a}toMalloy(){return k.queryToMalloy(this.build())}build(){return super.build()}setView(t){if(!(this.definition instanceof Te))throw new Error("Must set source before setting view");return this.definition=new Te({kind:"arrow",source:this.definition.source.build(),view:{kind:"view_reference",name:t}}),this.definition.view.as.ReferenceViewDefinition()}_getInheritedAnnotations(t){var a;return t instanceof Qe?(a=this.getQueryInfo(t.name).annotations)!==null&&a!==void 0?a:[]:t instanceof me?this._getInheritedAnnotations(t.base):t instanceof Te?t.view.getInheritedAnnotations():[]}getInheritedAnnotations(){return this._getInheritedAnnotations(this.definition)}}f.ASTQuery=C;class N extends e{constructor(t){super(t,{name:t.name,path:t.path,parameters:t.parameters&&new ne(t.parameters)}),this.reference=t}get name(){return this.children.name}set name(t){this.edit(),this.children.name=t}get parameters(){return this.children.parameters}set parameters(t){this.edit(),this.children.parameters=t}get path(){return this.children.path}static getOrAddParameters(t){if(t.parameters)return t.parameters;t.edit();const a=new ne([]);return t.parameters=a,a}static setParameter(t,a,l){const b=N.tryGetParameter(t,a);if(b!==void 0){b.value=f.ASTLiteralValue.from(f.ASTLiteralValue.makeLiteral(l));return}return t.getOrAddParameters().addParameter(a,l)}static tryGetParameter(t,a){if(t.parameters!==void 0){for(const l of t.parameters.iter())if(l.name===a)return l}}getOrAddParameters(){return N.getOrAddParameters(this)}setParameter(t,a){return N.setParameter(this,t,a)}tryGetParameter(t){return N.tryGetParameter(this,t)}}f.ASTReference=N;class Z extends N{get segment(){const t=this.parent;return t instanceof E||t instanceof Ke?t.field.segment:t instanceof x||t instanceof Xe?t.segment:t.list.segment}getReferenceSchema(){return this.parent instanceof Me?this.segment.getOutputSchema():this.segment.getInputSchema()}getFieldInfo(){const t=this.getReferenceSchema();return y.schemaGet(t,this.name,this.path)}}f.ASTFieldReference=Z;class ne extends d{constructor(t){super(t,t.map(a=>new pe(a)))}get parameters(){return this.children}addParameter(t,a){this.add(new pe({name:t,value:f.ASTLiteralValue.makeLiteral(a)}))}}f.ASTParameterValueList=ne;class pe extends e{constructor(t){super(t,{name:t.name,value:f.ASTLiteralValue.from(t.value)}),this.parameter=t}get name(){return this.children.name}get value(){return this.children.value}set value(t){this.edit(),this.children.value=t}}f.ASTParameterValue=pe,f.ASTLiteralValue={from(g){switch(g.kind){case"string_literal":return new O(g);case"number_literal":return new F(g);case"boolean_literal":return new G(g);case"date_literal":return new he(g);case"timestamp_literal":return new Fe(g);case"null_literal":return new A(g);case"filter_expression_literal":return new we(g)}},makeLiteral(g){if(g!==null&&typeof g=="object"&&"kind"in g)return g;if(typeof g=="string")return{kind:"string_literal",string_value:g};if(typeof g=="boolean")return{kind:"boolean_literal",boolean_value:g};if(typeof g=="number")return{kind:"number_literal",number_value:g};if(g===null)return{kind:"null_literal"};if("date"in g){const t=g.granularity,a=de(g.date);return se(t)?{kind:"date_literal",date_value:a,granularity:t}:{kind:"timestamp_literal",timestamp_value:a,granularity:t}}throw new Error("Unknown literal type")}};class O extends e{constructor(t){super(t,{kind:t.kind,string_value:t.string_value}),this.node=t,this.kind="string_literal"}get fieldType(){return{kind:"string_type"}}}f.ASTStringLiteralValue=O;class A extends e{constructor(t){super(t,{kind:t.kind}),this.node=t,this.kind="null_literal"}get fieldType(){}}f.ASTNullLiteralValue=A;class F extends e{constructor(t){super(t,{kind:t.kind,number_value:t.number_value}),this.node=t,this.kind="number_literal"}get fieldType(){return{kind:"number_type",subtype:Number.isInteger(this.children.number_value)?"integer":"decimal"}}}f.ASTNumberLiteralValue=F;class G extends e{constructor(t){super(t,{kind:t.kind,boolean_value:t.boolean_value}),this.node=t,this.kind="boolean_literal"}get fieldType(){return{kind:"boolean_type"}}}f.ASTBooleanLiteralValue=G;class he extends e{constructor(t){super(t,{kind:t.kind,date_value:t.date_value,granularity:t.granularity}),this.node=t,this.kind="date_literal"}get fieldType(){return{kind:"date_type",timeframe:this.children.granularity}}}f.ASTDateLiteralValue=he;class Fe extends e{constructor(t){super(t,{kind:t.kind,timestamp_value:t.timestamp_value,granularity:t.granularity}),this.node=t,this.kind="timestamp_literal"}get fieldType(){return{kind:"timestamp_type",timeframe:this.children.granularity}}}f.ASTTimestampLiteralValue=Fe;class we extends e{constructor(t){super(t,{kind:t.kind,filter_expression_value:t.filter_expression_value}),this.node=t,this.kind="filter_expression_literal"}get fieldType(){}}f.ASTFilterExpressionLiteralValue=we;class He extends y{constructor(t){super(),this.node=t}get treeEdited(){return!1}build(){return this.node}findAny(){throw new Error("Tried to find a node from an unimplemented node type")}}f.ASTUnimplemented=He,f.ASTQueryArrowSource={from(g){switch(g.kind){case"refinement":return new me(g);case"source_reference":return new nt(g)}}},f.ASTQueryDefinition={from(g){switch(g.kind){case"arrow":return new Te(g);case"query_reference":return new Qe(g);case"refinement":return new me(g)}}};class Te extends e{constructor(t){super(t,{kind:"arrow",source:f.ASTQueryArrowSource.from(t.source),view:Re.from(t.view)}),this.node=t}get view(){return this.children.view}set view(t){this.edit(),this.children.view=t,t.parent=this}get source(){return this.children.source}set source(t){this.edit(),this.children.source=t}getOrAddDefaultSegment(){return this.view.getOrAddDefaultSegment()}getSourceInfo(){return this.source.getSourceInfo()}getOutputSchema(){return this.view.getRefinementSchema()}isRunnable(){return this.view.isRunnable()&&this.source.isRunnable()}get query(){return this.parent.as.Query()}propagateUp(t){this.propagateDown(t)}propagateDown(t){t(this.view),this.view.propagateDown(t)}reorderFields(t){this.view instanceof De?this.view.reorderFields(t):this.query.getOrAddAnnotations().setTagProperty(["field_order"],t)}}f.ASTArrowQueryDefinition=Te;class me extends e{constructor(t){super(t,{kind:"refinement",base:f.ASTQueryDefinition.from(t.base),refinement:Re.from(t.refinement)}),this.node=t}get base(){return this.children.base}get refinement(){return this.children.refinement}set refinement(t){this.edit(),this.children.refinement=t,t.parent=this}isRunnable(){return!0}get query(){return this.parent.as.Query()}getOrAddDefaultSegment(){return this.refinement.getOrAddDefaultSegment()}getOutputSchema(){const t=this.base.getOutputSchema(),a=this.refinement.getRefinementSchema();return C.schemaMerge(t,a)}propagateUp(t){this.propagateDown(t)}propagateDown(t){t(this.refinement),this.refinement.propagateDown(t)}reorderFields(t){this.query.getOrAddAnnotations().setTagProperty(["field_order"],t)}getSourceInfo(){return this.base.getSourceInfo()}}f.ASTRefinementQueryDefinition=me;class Qe extends e{constructor(t){super(t,{kind:"query_reference",name:t.name,path:t.path,parameters:t.parameters&&new ne(t.parameters)}),this.node=t}isRunnable(){return!0}get name(){return this.children.name}get query(){return this.parent.as.Query()}get parameters(){return this.children.parameters}set parameters(t){this.edit(),this.children.parameters=t}get path(){return this.children.path}getOrAddDefaultSegment(){const t=new me({kind:"refinement",base:this.build(),refinement:{kind:"segment",operations:[]}});return this.query.definition=t,t.refinement.as.SegmentViewDefinition()}propagateUp(t){}propagateDown(t){}reorderFields(t){this.query.getOrAddAnnotations().setTagProperty(["field_order"],t)}getOrAddParameters(){return N.getOrAddParameters(this)}setParameter(t,a){return N.setParameter(this,t,a)}tryGetParameter(t){return N.tryGetParameter(this,t)}getOutputSchema(){return this.getSourceInfo().schema}getSourceInfo(){const a=this.query.model.entries.find(l=>l.name===this.name);if(a===void 0)throw new Error(`Query not found with name ${this.name}`);return a}}f.ASTReferenceQueryDefinition=Qe;class nt extends e{constructor(t){super(t,{kind:"source_reference",name:t.name,path:t.path,parameters:t.parameters&&new ne(t.parameters)}),this.node=t}isRunnable(){return this.areRequiredParametersSet()}get name(){return this.children.name}get arrow(){return this.parent.as.ArrowQueryDefinition()}get parameters(){return this.children.parameters}set parameters(t){this.edit(),this.children.parameters=t}get path(){return this.children.path}getSourceInfo(){const t=this.arrow.query.model.entries.find(a=>a.name===this.name);if(t===void 0)throw new Error(`No query or source named ${this.name}`);return t}getOrAddDefaultSegment(){if(this.getSourceInfo().kind!=="query")throw new Error(`Cannot refine source ${this.name}`);const a=new me({kind:"refinement",base:{...this.build(),kind:"query_reference"},refinement:{kind:"segment",operations:[]}});return this.arrow.source=a,a.refinement.as.SegmentViewDefinition()}propagateUp(t){}propagateDown(t){}getOrAddParameters(){return N.getOrAddParameters(this)}setParameter(t,a){return N.setParameter(this,t,a)}tryGetParameter(t){return N.tryGetParameter(this,t)}get query(){return this.parent.parent.as.Query()}getSourceParameters(){var t;const a=this.getSourceInfo();return a.kind==="query"?[]:(t=a.parameters)!==null&&t!==void 0?t:[]}areRequiredParametersSet(){const t=this.getSourceParameters();for(const a of t){if(a.default_value!==void 0)continue;if(this.tryGetParameter(a.name)===void 0)return!1}return!0}}f.ASTReferenceQueryArrowSource=nt;const Re={from(g){switch(g.kind){case"arrow":return new ke(g);case"view_reference":return new st(g);case"segment":return new De(g);case"refinement":return new Ce(g)}}};function je(g,t){const a=g.parent;a instanceof Te?a.view=t:a instanceof me?a.refinement=t:a instanceof Ae?a.definition=t:a instanceof ke?a.source===g?a.source=t:a.view=t:a.base===g?a.base=t:a.refinement=t}function at(g,t,a=[]){const l=g.getInputSchema(),b=C.schemaGet(l,t,a);if(b===void 0)return{isValidViewRefinement:!1,error:`${t} is not defined`};if(b.kind!=="view")return{isValidViewRefinement:!1,error:`${t} is not a view`};const L=g.getOutputSchema();for(const K of b.schema.fields)if(C.schemaTryGet(L,K.name,[]))return{isValidViewRefinement:!1,error:`Cannot refine with ${t} because stage already has an output field named ${K.name}`};return{isValidViewRefinement:!0}}class st extends e{constructor(t){super(t,{kind:"view_reference",name:t.name,path:t.path,parameters:t.parameters&&new ne(t.parameters)}),this.node=t}isRunnable(){return!0}get name(){return this.children.name}get path(){return this.children.path}get parameters(){return this.children.parameters}set parameters(t){this.edit(),this.children.parameters=t}getOrAddDefaultSegment(){return this.addEmptyRefinement()}addEmptyRefinement(){const t=Ce.segmentRefinementOf(this.build());return je(this,t),t.refinement.as.SegmentViewDefinition()}addViewRefinement(t,a){const{error:l}=this.isValidViewRefinement(t,a);if(l)throw new Error(l);const b=Ce.viewRefinementOf(this.build(),t,a);return je(this,b),b.refinement.as.ReferenceViewDefinition()}convertToNest(t){const a=Re.from({kind:"segment",operations:[{kind:"nest",name:t,view:{definition:this.build()}}]});je(this,a)}isValidViewRefinement(t,a){return at(this,t,a)}getInputSchema(){return St(this.parent)}getOutputSchema(){return this.parent.getOutputSchema()}getImplicitName(){return this.name}getViewInfo(){const t=this.getInputSchema(),a=y.schemaGet(t,this.name,this.path);if(a.kind!=="view")throw new Error("Not a view");return a}getRefinementSchema(){return this.getViewInfo().schema}propagateUp(t){this.parent.propagateUp(t)}propagateDown(t){}getInheritedAnnotations(){var t;return(t=this.getViewInfo().annotations)!==null&&t!==void 0?t:[]}getOrAddParameters(){return N.getOrAddParameters(this)}setParameter(t,a){return N.setParameter(this,t,a)}tryGetParameter(t){return N.tryGetParameter(this,t)}}f.ASTReferenceViewDefinition=st;class ke extends e{constructor(t){super(t,{kind:"arrow",source:Re.from(t.source),view:Re.from(t.view)}),this.node=t}isRunnable(){return this.source.isRunnable()&&this.view.isRunnable()}get source(){return this.children.source}set source(t){this.edit(),this.children.source=t}get view(){return this.children.view}set view(t){this.edit(),this.children.view=t,t.parent=this}getOrAddDefaultSegment(){return this.view.getOrAddDefaultSegment()}addEmptyRefinement(){return this.view.addEmptyRefinement()}addViewRefinement(t,a){return this.view.addViewRefinement(t,a)}convertToNest(t){const a=Re.from({kind:"segment",operations:[{kind:"nest",name:t,view:{definition:this.build()}}]});je(this,a)}getInputSchema(){return this.source.getOutputSchema()}getOutputSchema(){return this.view.getRefinementSchema()}getImplicitName(){return this.view.getImplicitName()}getRefinementSchema(){throw new Error("An arrow is not a valid refinement")}isValidViewRefinement(t,a){return at(this,t,a)}propagateUp(t){this.propagateDown(t)}propagateDown(t){t(this.view),this.view.propagateDown(t)}getInheritedAnnotations(){return[]}}f.ASTArrowViewDefinition=ke;class Ce extends e{constructor(t){super(t,{kind:"refinement",base:Re.from(t.base),refinement:Re.from(t.refinement)}),this.node=t}isRunnable(){return this.getOutputSchema().fields.length>0}get refinement(){return this.children.refinement}set refinement(t){this.edit(),this.children.refinement=t,t.parent=this}get base(){return this.children.base}set base(t){this.edit(),this.children.base=t}convertToNest(t){const a=Re.from({kind:"segment",operations:[{kind:"nest",name:t,view:{definition:this.build()}}]});je(this,a)}getOrAddDefaultSegment(){return this.refinement.getOrAddDefaultSegment()}addEmptyRefinement(){return this.refinement.addEmptyRefinement()}addViewRefinement(t,a){return this.refinement.addViewRefinement(t,a)}getInputSchema(){return St(this.parent)}getOutputSchema(){return this.parent.getOutputSchema()}getRefinementSchema(){return y.schemaMerge(this.base.getRefinementSchema(),this.refinement.getRefinementSchema())}getImplicitName(){return this.base.getImplicitName()}isValidViewRefinement(t,a){return at(this,t,a)}propagateUp(t){this.parent.propagateUp(t)}propagateDown(t){t(this.base),t(this.refinement),this.base.propagateDown(t),this.refinement.propagateDown(t)}getInheritedAnnotations(){return this.base.getInheritedAnnotations()}static viewRefinementOf(t,a,l){return new Ce({kind:"refinement",base:t,refinement:{kind:"view_reference",name:a,path:l}})}static segmentRefinementOf(t){return new Ce({kind:"refinement",base:t,refinement:{kind:"segment",operations:[]}})}}f.ASTRefinementViewDefinition=Ce;class De extends e{constructor(t){super(t,{kind:"segment",operations:new lt(t.operations)}),this.node=t,this.DEFAULT_INSERTION_ORDER=["group_by","aggregate","drill","where","having","nest","order_by","calculate","limit"]}isRunnable(){let t=!1;for(const a of this.operations.iter()){if(a instanceof Ee||a instanceof Oe)return!0;if(a instanceof z){if(!a.view.definition.isRunnable())return!1;t=!0}}return t}get operations(){return this.children.operations}convertToNest(t){const a=Re.from({kind:"segment",operations:[{kind:"nest",name:t,view:{definition:this.build()}}]});je(this,a)}renameOrderBys(t,a){for(const l of this.operations.iter())l instanceof Me&&l.name===t&&l.setField(a)}propagateUp(t){this.parent.propagateUp(t)}propagateDown(t){}removeOrderBys(t){for(const a of this.operations.iter())a instanceof Me&&a.name===t&&a.delete()}reorderFields(t){const a=[],l=[],b={};let L=!1;for(const X of this.operations.iter()){if((X instanceof Ee||X instanceof Oe||X instanceof z)&&t.includes(X.name)){b[X.name]=X,L=!0;continue}L?l.push(X):a.push(X)}const K=[];for(const X of t){const ue=b[X];if(ue===void 0)throw new Error(`No field named ${X}`);K.push(ue)}const u=[...a,...K,...l];this.operations.items=u}renameField(t,a){if(t.name===a)return;const l=this.getOutputSchema();if(y.schemaTryGet(l,a,[]))throw new Error(`Output already has a field named ${a}`);const b=t.name;t.name=a,this.propagateUp(L=>{L instanceof De&&L.renameOrderBys(b,a)})}addOrderBy(t,a){const l=this.getOutputSchema();try{y.schemaGet(l,t,[])}catch{throw new Error(`No such field ${t} in stage output`)}for(const L of this.operations.iter())if(L instanceof Me&&L.name===t)return L.direction=a,L;const b=new Me({kind:"order_by",field_reference:{name:t},direction:a});return this.addOperation(b),b}addEmptyNest(t){const a=new z({kind:"nest",name:t,view:{definition:{kind:"segment",operations:[]}}});return this.addOperation(a),a}firstIndexOfOperationType(t){return this.operations.findIndex(a=>a.kind===t)}findInsertionPoint(t){const a=this.firstIndexOfOperationType(t);if(a>-1){let L=a;for(;this.operations.index(L)&&this.operations.index(L).kind===t;)L++;return L}const l=this.DEFAULT_INSERTION_ORDER.indexOf(t);if(l===-1)throw new Error(`Operation ${t} is not supported for \`findInsertionPoint\``);const b=this.DEFAULT_INSERTION_ORDER.slice(l+1);for(const L of b){const K=this.firstIndexOfOperationType(L);if(K>-1)return K}return this.operations.length}getFieldNamed(t){const a=this.tryGetFieldNamed(t);if(a===void 0)throw new Error("No such field");return a}hasFieldNamed(t){return this.tryGetFieldNamed(t)!==void 0}hasField(t,a){return this.tryGetField(t,a)!==void 0}getField(t,a){const l=this.tryGetField(t,a);if(l===void 0)throw new Error("No such field");return l}tryGetField(t,a){for(const l of this.operations.iter())if(l instanceof Oe||l instanceof Ee){const b=l.field.getReference();if(b&&b.name===t&&be(b.path,a))return l}else if(l instanceof z){if(l.view instanceof st)return l}else if(l instanceof Je){const b=l.expression.field.getReference();if(b&&b.name===t&&be(b.path,a))return l}}tryGetFieldNamed(t){for(const a of this.operations.iter())if((a instanceof Oe||a instanceof Ee||a instanceof z||a instanceof Je)&&a.name===t)return a}getGroupBy(t){for(const a of this.operations.iter())if(a instanceof Oe&&a.name===t)return a}removeGroupBy(t){var a;return(a=this.getGroupBy(t))===null||a===void 0||a.delete(),this}addGroupBy(t,a=[],l){const b=this.makeField(t,a,l,"dimension");return this.addOperation(b),b}addDrill(t){const a=new Be({kind:"drill",...t});return this.addOperation(a),a}addWhere(t,a,l){const b=Array.isArray(a)?a:[],L=l===void 0?a:l,K=typeof L=="string"?L:Ge(L),u=this.getInputSchema(),X=C.schemaGet(u,t,b);tt(X,L);const ue=new _e({kind:"where",filter:{kind:"filter_string",expression:{kind:"field_reference",name:t,path:b},filter:K}});return this.addOperation(ue),ue}addHaving(t,a,l){const b=Array.isArray(a)?a:[],L=l===void 0?a:l,K=typeof L=="string"?L:Ge(L),u=this.getInputSchema(),X=C.schemaGet(u,t,b);tt(X,L);const ue=new it({kind:"having",filter:{kind:"filter_string",expression:{kind:"field_reference",name:t,path:b},filter:K}});return this.addOperation(ue),ue}addCalculateMovingAverage(t,a,l,b,L){const K=new Je({kind:"calculate",name:t,field:{expression:{kind:"moving_average",field_reference:{name:a,path:l},rows_preceding:b,rows_following:L}}});return this.addOperation(K),K}addTimeGroupBy(t,a,l,b){const L=this.getInputSchema(),K=y.schemaGet(L,t,a);if(K===void 0)throw new Error(`No such field ${t}`);if(K.kind!=="dimension")throw new Error(`Cannot group by non-dimension ${t}`);if(K.type.kind!==b)throw new Error(`${t} is not a ${b}`);const u=new Oe({kind:"group_by",field:{expression:{kind:"time_truncation",field_reference:{name:t,path:a},truncation:l}}});return this.addOperation(u),u}addDateGroupBy(t,a,l){const b=l===void 0?a:l,L=l===void 0?[]:a;return this.addTimeGroupBy(t,L,b,"date_type")}addTimestampGroupBy(t,a,l){const b=l===void 0?a:l,L=l===void 0?[]:a;return this.addTimeGroupBy(t,L,b,"timestamp_type")}addTimestamptzGroupBy(t,a,l){const b=l===void 0?a:l,L=l===void 0?[]:a;return this.addTimeGroupBy(t,L,b,"timestamptz_type")}addAggregate(t,a=[],l){const b=this.makeField(t,a,l,"measure");return this.addOperation(b),b}addNest(t,a){const l=this.makeField(t,[],a,"view");return this.addOperation(l),l}makeField(t,a,l,b){const L=this.getInputSchema(),K=y.schemaGet(L,t,a);if(K===void 0)throw new Error(`No such field ${t}`);if(K.kind!==b){const u=mt(b),X=b;throw new Error(`Cannot ${u} non-${X} ${t}`)}return b==="dimension"?Oe.fromReference(t,a,l):b==="measure"?Ee.fromReference(t,a,l):z.fromReference(t,a,l)}addOperation(t){if((t instanceof Oe||t instanceof Ee||t instanceof z||t instanceof Je)&&this.hasFieldNamed(t.name))throw new Error(`Query already has a field named ${t.name}`);const a=this.findInsertionPoint(t.kind);return this.operations.insert(t,a),t}getRefinementSchema(){const t=[];for(const a of this.operations.iter())(a instanceof Oe||a instanceof Ee||a instanceof z||a instanceof Je)&&t.push(a.getFieldInfo());return{fields:t}}setLimit(t){et.validateLimit(t);const a=[...this.operations.iter()].find(f.ASTViewOperation.isLimit);a?a.limit=t:this.operations.add(new et({kind:"limit",limit:t}))}getOrAddDefaultSegment(){return this}addEmptyRefinement(){const t=Ce.segmentRefinementOf(this.build());return je(this,t),t.refinement.as.SegmentViewDefinition()}addViewRefinement(t,a){const{error:l}=this.isValidViewRefinement(t,a);if(l)throw new Error(l);const b=Ce.viewRefinementOf(this.build(),t,a);return je(this,b),b.refinement.as.ReferenceViewDefinition()}getInputSchema(){return St(this.parent)}getOutputSchema(){return this.parent.getOutputSchema()}getImplicitName(){}isValidViewRefinement(t,a){return at(this,t,a)}getInheritedAnnotations(){return[]}}f.ASTSegmentViewDefinition=De;class lt extends d{constructor(t){super(t,t.map(a=>f.ASTViewOperation.from(a)))}get items(){return this.children}set items(t){this.edit(),this.children=t}get segment(){return this.parent.as.SegmentViewDefinition()}}f.ASTViewOperationList=lt,f.ASTViewOperation={from(g){switch(g.kind){case"group_by":return new Oe(g);case"aggregate":return new Ee(g);case"order_by":return new Me(g);case"nest":return new z(g);case"limit":return new et(g);case"where":return new _e(g);case"drill":return new Be(g);case"having":return new it(g);case"calculate":return new Je(g)}},isLimit(g){return g instanceof et}};class Me extends e{constructor(t){super(t,{kind:"order_by",field_reference:new Z(t.field_reference),direction:t.direction}),this.node=t,this.kind="order_by"}get fieldReference(){return this.children.field_reference}get name(){return this.fieldReference.name}get direction(){return this.children.direction}set direction(t){this.direction!==t&&(this.edit(),this.children.direction=t)}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this)}setField(t){const a=this.list.segment.getOutputSchema();y.schemaGet(a,t,[]),this.edit(),this.children.field_reference=new Z({name:t})}setDirection(t){this.direction=t}}f.ASTOrderByViewOperation=Me;class Oe extends e{constructor(t){super(t,{kind:"group_by",name:t.name,field:new Ze(t.field)}),this.node=t,this.kind="group_by"}get field(){return this.children.field}get name(){var t;const a=(t=this.children.name)!==null&&t!==void 0?t:this.field.name;if(a===void 0)throw new Error("Group by does not have a name");return a}set name(t){this.name!==t&&(this.edit(),this.field.name===t?this.children.name=void 0:this.children.name=t)}get list(){return this.parent.as.ViewOperationList()}rename(t){this.list.segment.renameField(this,t)}delete(){this.list.remove(this),this.list.segment.propagateUp(t=>{t instanceof De&&t.removeOrderBys(this.name)})}getFieldInfo(){return{kind:"dimension",name:this.name,type:this.field.type}}get annotations(){return this.field.annotations}set annotations(t){this.edit(),this.field.annotations=t}getOrAddAnnotations(){return this.field.getOrAddAnnotations()}getInheritedTag(t="# "){return qe(t,this.field.getInheritedAnnotations())}getIntrinsicTag(t="# "){var a,l;return(l=(a=this.annotations)===null||a===void 0?void 0:a.getIntrinsicTag(t))!==null&&l!==void 0?l:new $.Tag}getTag(t="# "){var a,l;return(l=(a=this.annotations)===null||a===void 0?void 0:a.getTag(t))!==null&&l!==void 0?l:this.getInheritedTag(t)}setTagProperty(t,a=null,l="# "){this.getOrAddAnnotations().setTagProperty(t,a,l)}removeTagProperty(t,a="# "){this.getTag().has(...t)&&this.getOrAddAnnotations().removeTagProperty(t,a)}static fromReference(t,a,l){return new Oe({kind:"group_by",name:l,field:{expression:{kind:"field_reference",name:t,path:a}}})}}f.ASTGroupByViewOperation=Oe;class Ee extends e{constructor(t){super(t,{kind:"aggregate",name:t.name,field:new Ze(t.field)}),this.node=t,this.kind="aggregate"}get field(){return this.children.field}get name(){var t;const a=(t=this.children.name)!==null&&t!==void 0?t:this.field.name;if(a===void 0)throw new Error("Aggregate does not have a name");return a}set name(t){this.name!==t&&(this.edit(),this.field.name===t?this.children.name=void 0:this.children.name=t)}get annotations(){return this.field.annotations}rename(t){this.list.segment.renameField(this,t)}convertToCalculateMovingAverage(t,a,l=0,b=[]){if(!(this.field.expression instanceof Ne))throw new Error("Cannot convert aggregate to smoothed metric unless it is a field reference");this.list.remove(this);const L=new Je({kind:"calculate",name:t,field:{expression:{kind:"moving_average",field_reference:{name:this.field.expression.name,path:this.field.expression.path},rows_preceding:a,rows_following:l,partition_fields:b.map(K=>({name:K}))}}});return this.list.add(L),L}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this),this.list.segment.propagateUp(t=>{t instanceof De&&t.removeOrderBys(this.name)})}getFieldInfo(){return{annotations:[{value:$.Tag.withPrefix("#(malloy) ").set(["calculation"]).toString()}],kind:"dimension",name:this.name,type:this.field.type}}getOrAddAnnotations(){return this.field.getOrAddAnnotations()}getInheritedTag(t="# "){return qe(t,this.field.getInheritedAnnotations())}getIntrinsicTag(t="# "){var a,l;return(l=(a=this.annotations)===null||a===void 0?void 0:a.getIntrinsicTag(t))!==null&&l!==void 0?l:new $.Tag}getTag(t="# "){var a,l;return(l=(a=this.annotations)===null||a===void 0?void 0:a.getTag(t))!==null&&l!==void 0?l:this.getInheritedTag(t)}setTagProperty(t,a=null,l="# "){this.getOrAddAnnotations().setTagProperty(t,a,l)}removeTagProperty(t,a="# "){this.getTag().has(...t)&&this.getOrAddAnnotations().removeTagProperty(t,a)}addWhere(t,a,l){const b=Array.isArray(a)?a:[],L=l===void 0?a:l,K=typeof L=="string"?L:Ge(L),u=this.list.segment.getInputSchema(),X=C.schemaGet(u,t,b);tt(X,L);const ue={filter:{kind:"filter_string",expression:{kind:"field_reference",name:t,path:b},filter:K}};if(this.field.expression instanceof E)return this.field.expression.where.add(new S(ue)),this.field.expression;if(this.field.expression instanceof Ne){const ot=this.field.expression.build();return this.field.expression=new E({kind:"filtered_field",field_reference:{name:ot.name,path:ot.path,parameters:ot.parameters},where:[ue]}),this.field.expression}else throw new Error("This kind of expression does not support addWhere")}static fromReference(t,a,l){return new Ee({kind:"aggregate",name:l,field:{expression:{kind:"field_reference",name:t,path:a}}})}}f.ASTAggregateViewOperation=Ee;class Ze extends e{constructor(t){super(t,{expression:f.ASTExpression.from(t.expression),annotations:t.annotations&&new We(t.annotations)}),this.node=t}get expression(){return this.children.expression}set expression(t){this.edit(),this.children.expression=t,t.parent=this}get name(){return this.expression.name}get type(){const t=this.expression.fieldType;if(t===void 0)throw new Error("Field expression does not have a type");return t}get annotations(){return this.children.annotations}set annotations(t){this.edit(),this.children.annotations=t}getReference(){if(!(this.expression instanceof Ye))return this.expression.getReference()}getOrAddAnnotations(){if(this.annotations)return this.annotations;this.edit();const t=new We([]);return this.children.annotations=t,t.parent=this,t}getInheritedTag(t="# "){return qe(t,this.getInheritedAnnotations())}getIntrinsicTag(t="# "){var a,l;return(l=(a=this.annotations)===null||a===void 0?void 0:a.getIntrinsicTag(t))!==null&&l!==void 0?l:new $.Tag}getTag(t="# "){var a,l;return(l=(a=this.annotations)===null||a===void 0?void 0:a.getTag(t))!==null&&l!==void 0?l:this.getInheritedTag(t)}setTagProperty(t,a=null,l="# "){this.getOrAddAnnotations().setTagProperty(t,a,l)}removeTagProperty(t,a="# "){this.getTag().has(...t)&&this.getOrAddAnnotations().removeTagProperty(t,a)}get segment(){return this.parent.list.segment}getInheritedAnnotations(){return this.expression.getInheritedAnnotations()}}f.ASTField=Ze,f.ASTExpression={from(g){switch(g.kind){case"field_reference":return new Ne(g);case"filtered_field":return new E(g);case"time_truncation":return new Ke(g);case"literal_value":return new Ye(g);case"moving_average":return new m(g)}}};class Ne extends e{constructor(t){super(t,{kind:t.kind,name:t.name,path:t.path,parameters:t.parameters&&new ne(t.parameters)}),this.node=t,this.kind="field_reference"}get name(){return this.children.name}get parameters(){return this.children.parameters}set parameters(t){this.edit(),this.children.parameters=t}get segment(){const t=this.parent;if(t instanceof Ze)return t.segment;if(t instanceof x||t instanceof Xe)return t.segment;throw new Error("Invalid expression parent")}get path(){return this.children.path}getReference(){return this.build()}getFieldInfo(){const t=this.segment.getInputSchema(),l=this.parent instanceof Xe&&this.parent.parent instanceof Be?y.schemaGetDrillField(t,this.name,this.path):y.schemaGet(t,this.name,this.path);if(l.kind!=="dimension"&&l.kind!=="measure")throw new Error("Invalid field for ASTReferenceExpression");return l}get fieldType(){return this.getFieldInfo().type}getInheritedAnnotations(){var t;return(t=this.getFieldInfo().annotations)!==null&&t!==void 0?t:[]}getOrAddParameters(){return N.getOrAddParameters(this)}setParameter(t,a){return N.setParameter(this,t,a)}tryGetParameter(t){return N.tryGetParameter(this,t)}}f.ASTReferenceExpression=Ne;class Ke extends e{constructor(t){super(t,{kind:t.kind,field_reference:new Z(t.field_reference),truncation:t.truncation}),this.node=t,this.kind="time_truncation"}getReference(){return this.fieldReference.build()}get fieldReference(){return this.children.field_reference}get truncation(){return this.children.truncation}set truncation(t){this.edit(),this.children.truncation=t}get name(){return this.fieldReference.name}get field(){return this.parent.as.Field()}getFieldInfo(){const t=this.field.segment.getInputSchema(),a=y.schemaGet(t,this.name,this.fieldReference.path);if(a.kind!=="dimension"&&a.kind!=="measure")throw new Error("Invalid field for ASTReferenceExpression");return a}get fieldType(){const t=this.getFieldInfo();if(t.type.kind==="date_type")return{...t.type,timeframe:B(this.truncation)};if(t.type.kind==="timestamp_type"||t.type.kind==="timestamptz_type")return{...t.type,timeframe:this.truncation};throw new Error("This type of field cannot have a time truncation")}getInheritedAnnotations(){var t;return(t=this.getFieldInfo().annotations)!==null&&t!==void 0?t:[]}}f.ASTTimeTruncationExpression=Ke;class Ye extends e{constructor(t){super(t,{kind:t.kind,literal_value:f.ASTLiteralValue.from(t.literal_value)}),this.node=t,this.kind="time_truncation"}get name(){}get literalValue(){return this.children.literal_value}get fieldType(){return this.literalValue.fieldType}getInheritedAnnotations(){return[]}getFieldInfo(){}}f.ASTLiteralValueExpression=Ye;class q extends d{constructor(t){super(t,t.map(a=>new Z(a)))}}f.ASTFieldReferenceList=q;class m extends e{constructor(t){super(t,{kind:t.kind,field_reference:new Z(t.field_reference),rows_preceding:t.rows_preceding,rows_following:t.rows_following,partition_fields:new q(t.partition_fields||[])}),this.node=t,this.kind="moving_average"}getReference(){return this.fieldReference.build()}get fieldReference(){return this.children.field_reference}get rowsPreceding(){return this.children.rows_preceding}set rowsPreceding(t){this.edit(),this.children.rows_preceding=t}get rowsFollowing(){return this.children.rows_following}set rowsFollowing(t){this.edit(),this.children.rows_following=t}get name(){return this.fieldReference.name}get field(){return this.parent.as.Field()}get partitionFields(){return this.children.partition_fields}setPartitionFields(t){this.children.partition_fields=new q(t)}getFieldInfo(){const t=this.field.segment.getInputSchema(),a=y.schemaGet(t,this.name,this.fieldReference.path);if(a.kind!=="dimension"&&a.kind!=="measure")throw new Error("Invalid field for ASTReferenceExpression");return a}get fieldType(){return this.getFieldInfo().type}getInheritedAnnotations(){var t;return(t=this.getFieldInfo().annotations)!==null&&t!==void 0?t:[]}}f.ASTMovingAverageExpression=m;class S extends e{constructor(t){super(t,{filter:f.ASTFilter.from(t.filter)})}get filter(){return this.children.filter}get list(){return this.parent.as.FilterOperationList()}delete(){this.list.remove(this)}}f.ASTFilterOperation=S;class V extends d{constructor(t){super(t,t.map(a=>new S(a)))}get expression(){return this.parent.as.FilteredFieldExpression()}}f.ASTFilterOperationList=V;class E extends e{constructor(t){super(t,{kind:t.kind,field_reference:new Z(t.field_reference),where:new V(t.where)}),this.node=t,this.kind="filtered_field"}getReference(){return this.fieldReference.build()}get fieldReference(){return this.children.field_reference}get name(){return this.fieldReference.name}get where(){return this.children.where}get field(){return this.parent.as.Field()}getFieldInfo(){const t=this.field.segment.getInputSchema(),a=y.schemaGet(t,this.name,this.fieldReference.path);if(a.kind!=="measure")throw new Error("Invalid field for ASTFilteredFieldExpression");return a}get fieldType(){return this.getFieldInfo().type}getInheritedAnnotations(){var t;return(t=this.getFieldInfo().annotations)!==null&&t!==void 0?t:[]}}f.ASTFilteredFieldExpression=E;function B(g){switch(g){case"day":case"week":case"month":case"year":case"quarter":return g;default:throw new Error("Invalid date timeframe")}}class z extends e{constructor(t){super(t,{kind:"nest",name:t.name,view:new Ae(t.view)}),this.node=t,this.kind="nest"}get view(){return this.children.view}get annotations(){return this.view.annotations}get name(){var t;const a=(t=this.children.name)!==null&&t!==void 0?t:this.view.name;if(a===void 0)throw new Error("Nest does not have a name");return a}set name(t){this.name!==t&&(this.edit(),this.view.name===t?this.children.name=void 0:this.children.name=t)}get list(){return this.parent.as.ViewOperationList()}getOrAddAnnotations(){return this.view.getOrAddAnnotations()}getInheritedTag(t="# "){return qe(t,this.view.getInheritedAnnotations())}getIntrinsicTag(t="# "){var a,l;return(l=(a=this.annotations)===null||a===void 0?void 0:a.getIntrinsicTag(t))!==null&&l!==void 0?l:new $.Tag}getTag(t="# "){var a,l;return(l=(a=this.annotations)===null||a===void 0?void 0:a.getTag(t))!==null&&l!==void 0?l:this.getInheritedTag(t)}setTagProperty(t,a=null,l="# "){this.getOrAddAnnotations().setTagProperty(t,a,l)}removeTagProperty(t,a="# "){this.getTag().has(...t)&&this.getOrAddAnnotations().removeTagProperty(t,a)}delete(){this.list.remove(this)}rename(t){this.list.segment.renameField(this,t)}getFieldInfo(){return{kind:"view",name:this.name,definition:this.view.build(),schema:this.view.getOutputSchema()}}static fromReference(t,a,l){return new z({kind:"nest",name:l,view:{definition:{kind:"view_reference",name:t,path:a}}})}}f.ASTNestViewOperation=z;class _e extends e{constructor(t){super(t,{kind:"where",filter:f.ASTFilter.from(t.filter)}),this.node=t,this.kind="where"}get filter(){return this.children.filter}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this)}}f.ASTWhereViewOperation=_e;class Be extends e{constructor(t){super(t,{kind:"drill",filter:f.ASTFilter.from(t.filter)}),this.node=t,this.kind="drill"}get filter(){return this.children.filter}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this)}}f.ASTDrillViewOperation=Be;class it extends e{constructor(t){super(t,{kind:"having",filter:f.ASTFilter.from(t.filter)}),this.node=t,this.kind="having"}get filter(){return this.children.filter}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this)}}f.ASTHavingViewOperation=it;class Je extends e{constructor(t){super(t,{kind:"calculate",field:new Ze(t.field),name:t.name}),this.node=t,this.kind="calculate"}get expression(){return this.children.field.expression}set expression(t){this.edit(),this.children.field.expression=t,t.parent=this}get name(){return this.node.name}set name(t){this.name!==t&&(this.edit(),this.node.name=t)}getFieldInfo(){return{annotations:[{value:$.Tag.withPrefix("#(malloy) ").set(["calculation"]).toString()}],kind:"calculate",name:this.name,type:this.expression.fieldType}}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this)}}f.ASTCalculateViewOperation=Je,f.ASTFilter={from(g){switch(g.kind){case"filter_string":return new x(g);case"literal_equality":return new Xe(g)}},getSegment(g){const t=g.parent;return t instanceof S?t.list.expression.field.segment:t.list.segment}};class x extends e{constructor(t){super(t,{kind:"filter_string",expression:f.ASTExpression.from(t.expression),filter:t.filter}),this.node=t,this.kind="filter_string"}get expression(){return this.children.expression}get filterString(){return this.children.filter}set filterString(t){this.edit(),this.children.filter=t}setFilterString(t){const a=this.getFilterType();I(this.filterString,a),this.filterString=t}get segment(){return f.ASTFilter.getSegment(this)}getFieldInfo(){const t=this.expression.getFieldInfo();if(t===void 0||t.kind!=="dimension"&&t.kind!=="measure")throw new Error("Invalid field type for filter with filter string");return t}getFilterType(){const t=this.getFieldInfo();return ut(t)}setFilter(t){const a=this.getFilterType();if(a!==t.kind)throw new Error(`Invalid filter: expected type ${a}, got ${t.kind}`);this.filterString=Ge(t)}getFilter(){const t=this.getFilterType();return I(this.filterString,t)}}f.ASTFilterWithFilterString=x;class Xe extends e{constructor(t){super(t,{kind:"literal_equality",expression:f.ASTExpression.from(t.expression),value:f.ASTLiteralValue.from(t.value)}),this.node=t,this.kind="literal_equality"}get expression(){return this.children.expression}get value(){return this.children.value}get segment(){return f.ASTFilter.getSegment(this)}}f.ASTFilterWithLiteralEquality=Xe;class Ae extends e{constructor(t){super(t,{definition:Re.from(t.definition),annotations:t.annotations&&new We(t.annotations)}),this.node=t}get definition(){return this.children.definition}set definition(t){this.edit(),this.children.definition=t,t.parent=this}get name(){return this.definition.getImplicitName()}getOrAddDefaultSegment(){return this.definition.getOrAddDefaultSegment()}get nest(){return this.parent.as.NestViewOperation()}getInputSchema(){return this.nest.list.segment.getInputSchema()}getOutputSchema(){return this.definition.getRefinementSchema()}propagateUp(t){this.propagateDown(t)}propagateDown(t){t(this.definition),this.definition.propagateDown(t)}reorderFields(t){this.definition instanceof De?this.definition.reorderFields(t):this.getOrAddAnnotations().setTagProperty(["field_order"],t)}get annotations(){return this.children.annotations}getOrAddAnnotations(){if(this.annotations)return this.annotations;this.edit();const t=new We([]);return this.children.annotations=t,t.parent=this,t}getInheritedAnnotations(){return this.definition.getInheritedAnnotations()}getInheritedTag(t="# "){return qe(t,this.getInheritedAnnotations())}getIntrinsicTag(t="# "){var a,l;return(l=(a=this.annotations)===null||a===void 0?void 0:a.getIntrinsicTag(t))!==null&&l!==void 0?l:new $.Tag}getTag(t="# "){var a,l;return(l=(a=this.annotations)===null||a===void 0?void 0:a.getTag(t))!==null&&l!==void 0?l:this.getInheritedTag(t)}setTagProperty(t,a=null,l="# "){this.getOrAddAnnotations().setTagProperty(t,a,l)}removeTagProperty(t,a="# "){this.getTag().has(...t)&&this.getOrAddAnnotations().removeTagProperty(t,a)}}f.ASTView=Ae;class et extends e{get limit(){return this.children.limit}set limit(t){et.validateLimit(t),this.edit(),this.children.limit=t}constructor(t){super(t,{kind:t.kind,limit:t.limit}),this.node=t,this.kind="limit"}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this)}static validateLimit(t){if(!Number.isInteger(t))throw new Error("Limit must be an integer")}}f.ASTLimitViewOperation=et;function mt(g){switch(g){case"dimension":return"group by";case"measure":return"aggregate";case"view":return"nest";case"join":return"join";case"calculate":return"calculate"}}function vt(g){return g}class We extends d{constructor(t){super(t,t.map(a=>new ft(a)))}get items(){return this.children}getInheritedAnnotations(){return this.parent.getInheritedAnnotations()}getIntrinsicTag(t="# "){return qe(t,this.items)}getTag(t="# "){return qe(t,this.items,this.getInheritedAnnotations())}get annotations(){return this.children.map(t=>t.node)}setTagProperty(t,a=null,l="# "){let b;for(let L=this.items.length-1;L>=0;L--){const K=this.index(L);if(K.hasPrefix(l)&&(b=K,K.hasIntrinsicTagProperty(t))){K.setTagProperty(t,a);return}}b?b.setTagProperty(t,a):this.add(new ft({value:new $.Tag({prefix:l}).set(t,a).toString()}))}removeTagProperty(t,a="# "){let l;for(let b=this.items.length-1;b>=0;b--){const L=this.index(b);if(L.hasPrefix(a)&&(l=L,L.hasIntrinsicTagProperty(t))){L.removeTagProperty(t);return}}l?l.removeTagProperty(t):this.add(new ft({value:new $.Tag({prefix:a}).unset(...t).toString()}))}}f.ASTAnnotationList=We;class ft extends e{get value(){return this.children.value}set value(t){this.edit(),this.children.value=t}constructor(t){super(t,{value:t.value}),this.node=t}get list(){return this.parent.as.AnnotationList()}get index(){return this.list.indexOf(this)}delete(){this.list.remove(this)}getIntrinsicTag(){const t=new $.TagParser;return t.parseAnnotation(this.value),t.finish()}getTag(){const t=new $.TagParser;for(const a of this.list.getInheritedAnnotations())t.parseAnnotation(a.value);for(let a=0;a<=this.index;a++)t.parseAnnotation(this.list.index(a).value);return t.finish()}hasPrefix(t){return this.value.startsWith(t)}hasIntrinsicTagProperty(t){return this.getIntrinsicTag().has(...t)}setTagProperty(t,a){this.value=this.getIntrinsicTag().set(t,a).toString()}removeTagProperty(t){this.value=this.getTag().unset(...t).toString()}}f.ASTAnnotation=ft;function qe(g,t=[],a=[]){const l=new $.TagParser;for(const L of a)l.parseAnnotation(L.value);const b=t.map(L=>L.value).filter(L=>typeof g=="string"?L.startsWith(g):L.match(g));for(const L of b)l.parseAnnotation(L);return l.finish()}function Ge(g){switch(g.kind){case"string":return w.StringFilterExpression.unparse(g.parsed);case"number":return w.NumberFilterExpression.unparse(g.parsed);case"boolean":return w.BooleanFilterExpression.unparse(g.parsed);case"timestamp":case"timestamptz":case"date":return w.TemporalFilterExpression.unparse(g.parsed)}}function I(g,t){function a(l){const b=l.filter(L=>L.severity==="error");if(b.length!==0)throw new Error(`Invalid Malloy filter string: ${b[0].message}`)}switch(t){case"string":{const l=w.StringFilterExpression.parse(g);return a(l.log),{kind:t,parsed:l.parsed}}case"number":{const l=w.NumberFilterExpression.parse(g);return a(l.log),{kind:t,parsed:l.parsed}}case"boolean":{const l=w.BooleanFilterExpression.parse(g);return a(l.log),{kind:t,parsed:l.parsed}}case"timestamp":case"timestamptz":case"date":{const l=w.TemporalFilterExpression.parse(g);return a(l.log),{kind:t,parsed:l.parsed}}case"other":throw new Error("Not implemented")}}function _(g){return"kind"in g?g:{...g,kind:"source"}}function se(g){switch(g){case"year":case"quarter":case"month":case"week":case"day":return!0;default:return!1}}function Y(g,t){return g.toString().padStart(t,"0")}function de(g){const t=Y(g.getUTCFullYear(),4),a=Y(g.getUTCMonth()+1,2),l=Y(g.getUTCDate(),2),b=Y(g.getUTCHours(),2),L=Y(g.getUTCMinutes(),2),K=Y(g.getUTCSeconds(),2);return`${t}-${a}-${l} ${b}:${L}:${K}`}function be(g,t){const a=g??[],l=t??[];return a.length===l.length&&a.every((b,L)=>b===l[L])}function ut(g){switch(g.type.kind){case"string_type":return"string";case"boolean_type":return"boolean";case"number_type":return"number";case"date_type":return"date";case"timestamp_type":return"timestamp";case"timestamptz_type":return"timestamp";default:return"other"}}function tt(g,t){if(g.kind!=="dimension"&&g.kind!=="measure")throw new Error(`Cannot filter by field of type ${g.kind}`);const a=ut(g);if(typeof t=="string")I(t,a);else if(t.kind!==a)throw new Error(`Invalid filter for field ${g.name}; expected type ${a}, but got ${t.kind}`)}function St(g){if(g instanceof Te)return g.getSourceInfo().schema;if(g instanceof me)throw new Error("unimplemented");return g.getInputSchema()}})(yt)),yt}var Jr;function Li(){return Jr||(Jr=1,(function(f){var ie=Vt&&Vt.__createBinding||(Object.create?(function(P,k,$,w){w===void 0&&(w=$);var y=Object.getOwnPropertyDescriptor(k,$);(!y||("get"in y?!k.__esModule:y.writable||y.configurable))&&(y={enumerable:!0,get:function(){return k[$]}}),Object.defineProperty(P,w,y)}):(function(P,k,$,w){w===void 0&&(w=$),P[w]=k[$]})),W=Vt&&Vt.__exportStar||function(P,k){for(var $ in P)$!=="default"&&!Object.prototype.hasOwnProperty.call(k,$)&&ie(k,P,$)};Object.defineProperty(f,"__esModule",{value:!0}),W(Vi(),f)})(Vt)),Vt}var Zr=Li();const Ii=mi(Zr),Ni=yi({__proto__:null,default:Ii},[Zr]);export{Ri as a,Zr as d,Ni as i,bi as r};