@malloy-publisher/server 0.8.5 → 0.9.1

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 (25) hide show
  1. package/README.docker.md +86 -2
  2. package/dist/app/api-doc.yaml +17 -1
  3. package/dist/app/assets/{EnvironmentPage-D0689eMH.js → EnvironmentPage-UMS7Py4Q.js} +1 -1
  4. package/dist/app/assets/{HomePage-CQwxmRju.js → HomePage-D3MvQaZn.js} +1 -1
  5. package/dist/app/assets/{LightMode-DzUuDGQu.js → LightMode-e1lNBfpL.js} +1 -1
  6. package/dist/app/assets/{MainPage-CWebuoie.js → MainPage-B0ozqtQO.js} +1 -1
  7. package/dist/app/assets/{ModelPage-DddcQtR_.js → ModelPage-lQj4Axqu.js} +2 -2
  8. package/dist/app/assets/{PackagePage-B_6x-Kp1.js → PackagePage-BT0YKNKU.js} +1 -1
  9. package/dist/app/assets/{RenderedResult-BRgIgxWh.es-B6GsiQaB.js → RenderedResult-BRgIgxWh.es-DiE7kPNX.js} +2 -2
  10. package/dist/app/assets/{RouteError-D85c0IXR.js → RouteError-BQnzPJvb.js} +1 -1
  11. package/dist/app/assets/{ThemeEditorPage-DPFZnuXS.js → ThemeEditorPage-D6t7w9Js.js} +1 -1
  12. package/dist/app/assets/{ToggleButtonGroup-B2KkD7kC.js → ToggleButtonGroup-CJT2JKTC.js} +1 -1
  13. package/dist/app/assets/index-ByieDZlo.js +23 -0
  14. package/dist/app/assets/{index-BbrJd6fQ.js → index-CCNqF0-G.js} +1 -1
  15. package/dist/app/assets/{index-125-Lr5Z.js → index-CKmZ4HG7.js} +388 -388
  16. package/dist/app/assets/{index-mS-LEGFh.js → index-CdExa3Pk.js} +1 -1
  17. package/dist/app/assets/{index-BSBGZfIc.js → index-TiWjmdoW.js} +4 -4
  18. package/dist/app/assets/{index-DSoCUF-f.js → index-ireHUsv_.js} +419 -422
  19. package/dist/app/assets/{index-BK_RS5eN.js → index-ufFZR_K-.js} +1 -1
  20. package/dist/app/assets/{index.es-Dixkq2YH.js → index.es-iUV0gCYk.js} +4 -4
  21. package/dist/app/index.html +1 -1
  22. package/dist/package_load_worker.mjs +147 -118
  23. package/dist/server.mjs +742 -915
  24. package/package.json +14 -14
  25. package/dist/app/assets/index-w_0OQJgZ.js +0 -23
@@ -1 +1 @@
1
- import{r as l,d as w,b as N,bj as A,h as P,j as G,k as S,C as W,l as h,s as j,B as D,m as U,bk as F}from"./index-BSBGZfIc.js";function H(t){return l.Children.toArray(t).filter(o=>l.isValidElement(o))}function q(t){return N("MuiToggleButton",t)}const f=w("MuiToggleButton",["root","disabled","selected","standard","primary","secondary","sizeSmall","sizeMedium","sizeLarge","fullWidth"]),E=l.createContext({}),V=l.createContext(void 0);function I(t,o){return o===void 0||t===void 0?!1:Array.isArray(o)?o.includes(t):t===o}const J=t=>{const{classes:o,fullWidth:a,selected:i,disabled:d,size:g,color:B}=t,u={root:["root",i&&"selected",d&&"disabled",a&&"fullWidth",`size${W(g)}`,B]};return h(u,q,o)},K=j(D,{name:"MuiToggleButton",slot:"Root",overridesResolver:(t,o)=>{const{ownerState:a}=t;return[o.root,o[`size${W(a.size)}`]]}})(U(({theme:t})=>({...t.typography.button,borderRadius:(t.vars||t).shape.borderRadius,padding:11,border:`1px solid ${(t.vars||t).palette.divider}`,color:(t.vars||t).palette.action.active,[`&.${f.disabled}`]:{color:(t.vars||t).palette.action.disabled,border:`1px solid ${(t.vars||t).palette.action.disabledBackground}`},"&:hover":{textDecoration:"none",backgroundColor:t.alpha((t.vars||t).palette.text.primary,(t.vars||t).palette.action.hoverOpacity),"@media (hover: none)":{backgroundColor:"transparent"}},variants:[{props:{color:"standard"},style:{[`&.${f.selected}`]:{color:(t.vars||t).palette.text.primary,backgroundColor:t.alpha((t.vars||t).palette.text.primary,(t.vars||t).palette.action.selectedOpacity),"&:hover":{backgroundColor:t.alpha((t.vars||t).palette.text.primary,`${(t.vars||t).palette.action.selectedOpacity} + ${(t.vars||t).palette.action.hoverOpacity}`),"@media (hover: none)":{backgroundColor:t.alpha((t.vars||t).palette.text.primary,(t.vars||t).palette.action.selectedOpacity)}}}}},...Object.entries(t.palette).filter(F()).map(([o])=>({props:{color:o},style:{[`&.${f.selected}`]:{color:(t.vars||t).palette[o].main,backgroundColor:t.alpha((t.vars||t).palette[o].main,(t.vars||t).palette.action.selectedOpacity),"&:hover":{backgroundColor:t.alpha((t.vars||t).palette[o].main,`${(t.vars||t).palette.action.selectedOpacity} + ${(t.vars||t).palette.action.hoverOpacity}`),"@media (hover: none)":{backgroundColor:t.alpha((t.vars||t).palette[o].main,(t.vars||t).palette.action.selectedOpacity)}}}}})),{props:{fullWidth:!0},style:{width:"100%"}},{props:{size:"small"},style:{padding:7,fontSize:t.typography.pxToRem(13)}},{props:{size:"large"},style:{padding:15,fontSize:t.typography.pxToRem(15)}}]}))),_=l.forwardRef(function(o,a){const{value:i,...d}=l.useContext(E),g=l.useContext(V),B=A({...d,selected:I(o.value,i)},o),u=P({props:B,name:"MuiToggleButton"}),{children:R,className:$,color:p="standard",disabled:z=!1,disableFocusRipple:v=!1,fullWidth:s=!1,onChange:C,onClick:x,selected:c,size:k="medium",value:b,...L}=u,y={...u,color:p,disabled:z,disableFocusRipple:v,fullWidth:s,size:k},O=J(y),M=r=>{x&&(x(r,b),r.defaultPrevented)||C&&C(r,b)},n=g||"";return G.jsx(K,{className:S(d.className,O.root,$,n),disabled:z,focusRipple:!v,ref:a,onClick:M,onChange:C,value:b,ownerState:y,"aria-pressed":c,...L,children:R})});function Q(t){return N("MuiToggleButtonGroup",t)}const e=w("MuiToggleButtonGroup",["root","selected","horizontal","vertical","disabled","grouped","groupedHorizontal","groupedVertical","fullWidth","firstButton","lastButton","middleButton"]),X=t=>{const{classes:o,orientation:a,fullWidth:i,disabled:d}=t,g={root:["root",a,i&&"fullWidth"],grouped:["grouped",`grouped${W(a)}`,d&&"disabled"],firstButton:["firstButton"],lastButton:["lastButton"],middleButton:["middleButton"]};return h(g,Q,o)},Y=j("div",{name:"MuiToggleButtonGroup",slot:"Root",overridesResolver:(t,o)=>{const{ownerState:a}=t;return[{[`& .${e.grouped}`]:o.grouped},{[`& .${e.grouped}`]:o[`grouped${W(a.orientation)}`]},{[`& .${e.firstButton}`]:o.firstButton},{[`& .${e.lastButton}`]:o.lastButton},{[`& .${e.middleButton}`]:o.middleButton},o.root,a.orientation==="vertical"&&o.vertical,a.fullWidth&&o.fullWidth]}})(U(({theme:t})=>({display:"inline-flex",borderRadius:(t.vars||t).shape.borderRadius,variants:[{props:{orientation:"vertical"},style:{flexDirection:"column",[`& .${e.grouped}`]:{[`&.${e.selected} + .${e.grouped}.${e.selected}`]:{borderTop:0,marginTop:0}},[`& .${e.firstButton},& .${e.middleButton}`]:{borderBottomLeftRadius:0,borderBottomRightRadius:0},[`& .${e.lastButton},& .${e.middleButton}`]:{marginTop:-1,borderTop:"1px solid transparent",borderTopLeftRadius:0,borderTopRightRadius:0},[`& .${e.lastButton}.${f.disabled},& .${e.middleButton}.${f.disabled}`]:{borderTop:"1px solid transparent"}}},{props:{fullWidth:!0},style:{width:"100%"}},{props:{orientation:"horizontal"},style:{[`& .${e.grouped}`]:{[`&.${e.selected} + .${e.grouped}.${e.selected}`]:{borderLeft:0,marginLeft:0}},[`& .${e.firstButton},& .${e.middleButton}`]:{borderTopRightRadius:0,borderBottomRightRadius:0},[`& .${e.lastButton},& .${e.middleButton}`]:{marginLeft:-1,borderLeft:"1px solid transparent",borderTopLeftRadius:0,borderBottomLeftRadius:0},[`& .${e.lastButton}.${f.disabled},& .${e.middleButton}.${f.disabled}`]:{borderLeft:"1px solid transparent"}}}]}))),tt=l.forwardRef(function(o,a){const i=P({props:o,name:"MuiToggleButtonGroup"}),{children:d,className:g,color:B="standard",disabled:u=!1,exclusive:R=!1,fullWidth:$=!1,onChange:p,orientation:z="horizontal",size:v="medium",value:s,...C}=i,x={...i,disabled:u,fullWidth:$,orientation:z,size:v},c=X(x),k=l.useCallback((n,r)=>{if(!p)return;const T=s&&s.indexOf(r);let m;s&&T>=0?(m=s.slice(),m.splice(T,1)):m=s?s.concat(r):[r],p(n,m)},[p,s]),b=l.useCallback((n,r)=>{p&&p(n,s===r?null:r)},[p,s]),L=l.useMemo(()=>({className:c.grouped,onChange:R?b:k,value:s,size:v,fullWidth:$,color:B,disabled:u}),[c.grouped,R,b,k,s,v,$,B,u]),y=H(d),O=y.length,M=n=>{const r=n===0,T=n===O-1;return r&&T?"":r?c.firstButton:T?c.lastButton:c.middleButton};return G.jsx(Y,{role:"group",className:S(c.root,g),ref:a,ownerState:x,...C,children:G.jsx(E.Provider,{value:L,children:y.map((n,r)=>G.jsx(V.Provider,{value:M(r),children:n},r))})})});export{tt as T,_ as a};
1
+ import{r as l,d as w,b as N,bj as A,h as P,j as G,k as S,C as W,l as h,s as j,B as D,m as U,bk as F}from"./index-TiWjmdoW.js";function H(t){return l.Children.toArray(t).filter(o=>l.isValidElement(o))}function q(t){return N("MuiToggleButton",t)}const f=w("MuiToggleButton",["root","disabled","selected","standard","primary","secondary","sizeSmall","sizeMedium","sizeLarge","fullWidth"]),E=l.createContext({}),V=l.createContext(void 0);function I(t,o){return o===void 0||t===void 0?!1:Array.isArray(o)?o.includes(t):t===o}const J=t=>{const{classes:o,fullWidth:a,selected:i,disabled:d,size:g,color:B}=t,u={root:["root",i&&"selected",d&&"disabled",a&&"fullWidth",`size${W(g)}`,B]};return h(u,q,o)},K=j(D,{name:"MuiToggleButton",slot:"Root",overridesResolver:(t,o)=>{const{ownerState:a}=t;return[o.root,o[`size${W(a.size)}`]]}})(U(({theme:t})=>({...t.typography.button,borderRadius:(t.vars||t).shape.borderRadius,padding:11,border:`1px solid ${(t.vars||t).palette.divider}`,color:(t.vars||t).palette.action.active,[`&.${f.disabled}`]:{color:(t.vars||t).palette.action.disabled,border:`1px solid ${(t.vars||t).palette.action.disabledBackground}`},"&:hover":{textDecoration:"none",backgroundColor:t.alpha((t.vars||t).palette.text.primary,(t.vars||t).palette.action.hoverOpacity),"@media (hover: none)":{backgroundColor:"transparent"}},variants:[{props:{color:"standard"},style:{[`&.${f.selected}`]:{color:(t.vars||t).palette.text.primary,backgroundColor:t.alpha((t.vars||t).palette.text.primary,(t.vars||t).palette.action.selectedOpacity),"&:hover":{backgroundColor:t.alpha((t.vars||t).palette.text.primary,`${(t.vars||t).palette.action.selectedOpacity} + ${(t.vars||t).palette.action.hoverOpacity}`),"@media (hover: none)":{backgroundColor:t.alpha((t.vars||t).palette.text.primary,(t.vars||t).palette.action.selectedOpacity)}}}}},...Object.entries(t.palette).filter(F()).map(([o])=>({props:{color:o},style:{[`&.${f.selected}`]:{color:(t.vars||t).palette[o].main,backgroundColor:t.alpha((t.vars||t).palette[o].main,(t.vars||t).palette.action.selectedOpacity),"&:hover":{backgroundColor:t.alpha((t.vars||t).palette[o].main,`${(t.vars||t).palette.action.selectedOpacity} + ${(t.vars||t).palette.action.hoverOpacity}`),"@media (hover: none)":{backgroundColor:t.alpha((t.vars||t).palette[o].main,(t.vars||t).palette.action.selectedOpacity)}}}}})),{props:{fullWidth:!0},style:{width:"100%"}},{props:{size:"small"},style:{padding:7,fontSize:t.typography.pxToRem(13)}},{props:{size:"large"},style:{padding:15,fontSize:t.typography.pxToRem(15)}}]}))),_=l.forwardRef(function(o,a){const{value:i,...d}=l.useContext(E),g=l.useContext(V),B=A({...d,selected:I(o.value,i)},o),u=P({props:B,name:"MuiToggleButton"}),{children:R,className:$,color:p="standard",disabled:z=!1,disableFocusRipple:v=!1,fullWidth:s=!1,onChange:C,onClick:x,selected:c,size:k="medium",value:b,...L}=u,y={...u,color:p,disabled:z,disableFocusRipple:v,fullWidth:s,size:k},O=J(y),M=r=>{x&&(x(r,b),r.defaultPrevented)||C&&C(r,b)},n=g||"";return G.jsx(K,{className:S(d.className,O.root,$,n),disabled:z,focusRipple:!v,ref:a,onClick:M,onChange:C,value:b,ownerState:y,"aria-pressed":c,...L,children:R})});function Q(t){return N("MuiToggleButtonGroup",t)}const e=w("MuiToggleButtonGroup",["root","selected","horizontal","vertical","disabled","grouped","groupedHorizontal","groupedVertical","fullWidth","firstButton","lastButton","middleButton"]),X=t=>{const{classes:o,orientation:a,fullWidth:i,disabled:d}=t,g={root:["root",a,i&&"fullWidth"],grouped:["grouped",`grouped${W(a)}`,d&&"disabled"],firstButton:["firstButton"],lastButton:["lastButton"],middleButton:["middleButton"]};return h(g,Q,o)},Y=j("div",{name:"MuiToggleButtonGroup",slot:"Root",overridesResolver:(t,o)=>{const{ownerState:a}=t;return[{[`& .${e.grouped}`]:o.grouped},{[`& .${e.grouped}`]:o[`grouped${W(a.orientation)}`]},{[`& .${e.firstButton}`]:o.firstButton},{[`& .${e.lastButton}`]:o.lastButton},{[`& .${e.middleButton}`]:o.middleButton},o.root,a.orientation==="vertical"&&o.vertical,a.fullWidth&&o.fullWidth]}})(U(({theme:t})=>({display:"inline-flex",borderRadius:(t.vars||t).shape.borderRadius,variants:[{props:{orientation:"vertical"},style:{flexDirection:"column",[`& .${e.grouped}`]:{[`&.${e.selected} + .${e.grouped}.${e.selected}`]:{borderTop:0,marginTop:0}},[`& .${e.firstButton},& .${e.middleButton}`]:{borderBottomLeftRadius:0,borderBottomRightRadius:0},[`& .${e.lastButton},& .${e.middleButton}`]:{marginTop:-1,borderTop:"1px solid transparent",borderTopLeftRadius:0,borderTopRightRadius:0},[`& .${e.lastButton}.${f.disabled},& .${e.middleButton}.${f.disabled}`]:{borderTop:"1px solid transparent"}}},{props:{fullWidth:!0},style:{width:"100%"}},{props:{orientation:"horizontal"},style:{[`& .${e.grouped}`]:{[`&.${e.selected} + .${e.grouped}.${e.selected}`]:{borderLeft:0,marginLeft:0}},[`& .${e.firstButton},& .${e.middleButton}`]:{borderTopRightRadius:0,borderBottomRightRadius:0},[`& .${e.lastButton},& .${e.middleButton}`]:{marginLeft:-1,borderLeft:"1px solid transparent",borderTopLeftRadius:0,borderBottomLeftRadius:0},[`& .${e.lastButton}.${f.disabled},& .${e.middleButton}.${f.disabled}`]:{borderLeft:"1px solid transparent"}}}]}))),tt=l.forwardRef(function(o,a){const i=P({props:o,name:"MuiToggleButtonGroup"}),{children:d,className:g,color:B="standard",disabled:u=!1,exclusive:R=!1,fullWidth:$=!1,onChange:p,orientation:z="horizontal",size:v="medium",value:s,...C}=i,x={...i,disabled:u,fullWidth:$,orientation:z,size:v},c=X(x),k=l.useCallback((n,r)=>{if(!p)return;const T=s&&s.indexOf(r);let m;s&&T>=0?(m=s.slice(),m.splice(T,1)):m=s?s.concat(r):[r],p(n,m)},[p,s]),b=l.useCallback((n,r)=>{p&&p(n,s===r?null:r)},[p,s]),L=l.useMemo(()=>({className:c.grouped,onChange:R?b:k,value:s,size:v,fullWidth:$,color:B,disabled:u}),[c.grouped,R,b,k,s,v,$,B,u]),y=H(d),O=y.length,M=n=>{const r=n===0,T=n===O-1;return r&&T?"":r?c.firstButton:T?c.lastButton:c.middleButton};return G.jsx(Y,{role:"group",className:S(c.root,g),ref:a,ownerState:x,...C,children:G.jsx(E.Provider,{value:L,children:y.map((n,r)=>G.jsx(V.Provider,{value:M(r),children:n},r))})})});export{tt as T,_ as a};
@@ -0,0 +1,23 @@
1
+ var te={},ae={},me;function xe(){if(me)return ae;me=1,Object.defineProperty(ae,"__esModule",{value:!0}),ae.Tag=void 0,ae.interfaceFromTag=O,ae.interfaceFromDict=I;function a(){return Object.create(null)}function P(i,e){if(i!==void 0)return Object.prototype.hasOwnProperty.call(i,e)?i[e]:void 0}class q{get parent(){return this._parent}get root(){let e=this;for(;e._parent!==void 0;)e=e._parent;return e}static id(e){let t=q.ids.get(e);return t===void 0&&(t=q.nextTagId,q.ids.set(e,t),q.nextTagId+=1),t}peek(e=0){const t=" ".repeat(e);let n=`#${q.id(this)}`;if(this.properties===void 0&&this.eq&&typeof this.eq=="string")return n+`=${this.eq}`;if(n+=" {",this.eq!==void 0&&(Array.isArray(this.eq)?n+=`
2
+ ${t} =: [
3
+ ${t} ${this.eq.map(h=>h.peek(e+4)).join(`
4
+ ${t} `)}
5
+ ${t} ]`:n+=`
6
+ ${t} =: ${this.eq}`),this.properties)for(const[h,s]of Object.entries(this.properties))n+=`
7
+ ${t} ${h}: ${s.peek(e+2)}`;return n+=`
8
+ ${t}}`,n}constructor(e={},t){if(this._read=!1,t!==void 0&&(this._parent=t),e.eq!==void 0&&(Array.isArray(e.eq)?this.eq=e.eq.map(n=>n instanceof q?n:new q(n,this)):this.eq=e.eq),e.properties){const n=a();for(const[h,s]of Object.entries(e.properties))n[h]=s instanceof q?s:new q(s,this);this.properties=n}e.deleted&&(this.deleted=e.deleted),e.prefix&&(this.prefix=e.prefix)}static withPrefix(e){return new q({prefix:e})}tag(...e){return this.find(e)}text(...e){var t;const n=(t=this.find(e))===null||t===void 0?void 0:t.getEq();if(!(n===void 0||Array.isArray(n)))return n instanceof Date?n.toISOString():String(n)}scalarType(...e){var t;const n=e.length>0?(t=this.find(e))===null||t===void 0?void 0:t.getEq():this.getEq();if(!(n===void 0||Array.isArray(n)))return n instanceof Date?"date":typeof n}numeric(...e){var t;const n=(t=this.find(e))===null||t===void 0?void 0:t.getEq();if(typeof n=="number")return n;if(typeof n=="string"){const h=Number.parseFloat(n);if(!Number.isNaN(h))return h}}boolean(...e){var t;const n=(t=this.find(e))===null||t===void 0?void 0:t.getEq();if(typeof n=="boolean")return n}isTrue(...e){var t;return((t=this.find(e))===null||t===void 0?void 0:t.getEq())===!0}isFalse(...e){var t;return((t=this.find(e))===null||t===void 0?void 0:t.getEq())===!1}date(...e){var t;const n=(t=this.find(e))===null||t===void 0?void 0:t.getEq();if(n instanceof Date)return n}bare(...e){const t=this.find(e);if(t!==void 0)return!t.hasProperties()}getEq(){return this.eq}getProperty(e){return P(this.properties,e)}getArrayElement(e){if(Array.isArray(this.eq)&&e<this.eq.length)return this.eq[e]}get dict(){var e;return(e=this.properties)!==null&&e!==void 0?e:a()}*entries(){if(this.properties)for(const e of Object.entries(this.properties))yield e}*keys(){if(this.properties)for(const e of Object.keys(this.properties))yield e}hasProperties(){return this.properties!==void 0&&Object.keys(this.properties).length>0}array(...e){const t=this.find(e);if(t===void 0)return;const n=t.getEq();if(Array.isArray(n))return n.map((h,s)=>t.getArrayElement(s))}textArray(...e){const t=this.find(e);if(t===void 0)return;const n=t.getEq();if(Array.isArray(n))return n.reduce((h,s,o)=>{const g=t.getArrayElement(o),d=g?.getEq();return d===void 0||Array.isArray(d)?h:d instanceof Date?h.concat(d.toISOString()):h.concat(String(d))},[])}numericArray(...e){const t=this.find(e);if(t===void 0)return;const n=t.getEq();if(Array.isArray(n))return n.reduce((h,s,o)=>{const g=t.getArrayElement(o),d=g?.getEq();if(typeof d=="number")return h.concat(d);if(typeof d=="string"){const R=Number.parseFloat(d);if(!Number.isNaN(R))return h.concat(R)}return h},[])}getProperties(){return this.properties===void 0&&(this.properties=a()),this.properties}clone(e){this._read=!0;const t=new q({},e);if(t.prefix=this.prefix,t.deleted=this.deleted,t.location=this.location,t._clonedFrom=this,this.eq!==void 0&&(Array.isArray(this.eq)?t.eq=this.eq.map(n=>n.clone(t)):t.eq=this.eq instanceof Date?new Date(this.eq):this.eq),this.properties){const n=a();for(const[h,s]of Object.entries(this.properties))n[h]=s.clone(t);t.properties=n}return t}toJSON(){const e={};if(this.eq!==void 0&&(Array.isArray(this.eq)?e.eq=this.eq.map(t=>t.toJSON()):e.eq=this.eq),this.properties!==void 0){const t=a();for(const[n,h]of Object.entries(this.properties))t[n]=h.toJSON();e.properties=t}return this.deleted&&(e.deleted=!0),this.prefix&&(e.prefix=this.prefix),this.location&&(e.location=this.location),e}validateReferences(){const e=[];return this.collectReferenceErrors(e,[]),e}collectReferenceErrors(e,t){if(this.properties)for(const[n,h]of Object.entries(this.properties))h.deleted||h.collectReferenceErrors(e,[...t,n]);Array.isArray(this.eq)&&this.eq.forEach((n,h)=>{n.collectReferenceErrors(e,[...t,`[${h}]`])})}static escapeString(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n")}static escapeProp(e){return e.replace(/\\/g,"\\\\").replace(/`/g,"\\`")}static quoteAndEscape(e,t=!1){return e.match(/^[0-9A-Za-z_]+$/)?e:t?`\`${q.escapeProp(e)}\``:`"${q.escapeString(e)}"`}static serializeScalar(e){return typeof e=="boolean"?e?"@true":"@false":e instanceof Date?`@${e.toISOString()}`:typeof e=="number"?String(e):q.quoteAndEscape(e)}toString(){var e;let t=(e=this.prefix)!==null&&e!==void 0?e:"# ";function n(o){var g;const d=Object.entries((g=o.properties)!==null&&g!==void 0?g:{});for(let R=0;R<d.length;R++){const[M,N]=d[R];s(M,N),R<d.length-1&&(t+=" ")}}function h(o,g=!1){if(o.eq!==void 0)if(g||(t+=" = "),Array.isArray(o.eq)){t+="[";for(let d=0;d<o.eq.length;d++)h(o.eq[d],!0),d!==o.eq.length-1&&(t+=", ");t+="]"}else t+=q.serializeScalar(o.eq);if(o.properties){const d=Object.values(o.properties);!g&&d.length===1&&!d.some(R=>R.deleted)&&o.eq===void 0?(t+=".",n(o)):((!g||o.eq!==void 0)&&(t+=" "),t+="{ ",n(o),t+=" }")}}function s(o,g){if(g.deleted){t+=`-${q.quoteAndEscape(o,!0)}`;return}t+=q.quoteAndEscape(o,!0),h(g)}return n(this),t+=`
9
+ `,t}find(e){let t=this;for(const n of e){let h;if(typeof n=="number"?h=t.getArrayElement(n):h=t.getProperty(n),h===void 0)return;h.markRead(),t=h}return t.deleted?void 0:t}markRead(){this._read=!0,this._clonedFrom&&(this._clonedFrom._read=!0)}get wasRead(){return this._read}*walk(e=[]){if(this.properties)for(const[t,n]of Object.entries(this.properties)){if(n.deleted)continue;const h=[...e,t];yield{path:h,tag:n},yield*n.walk(h)}if(Array.isArray(this.eq))for(let t=0;t<this.eq.length;t++){const n=[...e,t.toString()];yield{path:n,tag:this.eq[t]},yield*this.eq[t].walk(n)}}resetReadTracking(){this._read=!1;for(const{tag:e}of this.walk())e._read=!1}getUnreadProperties(e=[]){const t=[];if(this.properties)for(const[n,h]of Object.entries(this.properties)){if(h.deleted)continue;const s=[...e,n];h._read?t.push(...h.getUnreadProperties(s)):t.push(s)}return t}has(...e){return this.find(e)!==void 0}set(e,t=null){let n=this,h,s;for(const o of e)if(h=n,s=o,typeof o=="number"){if(n.eq===void 0||!Array.isArray(n.eq))n.eq=Array.from({length:o+1}).map(()=>new q({},n));else if(n.eq.length<=o){const g=n.eq,d=Array.from({length:o+1}).map((R,M)=>M<g.length?g[M]:new q({},n));n.eq=d}n=n.eq[o]}else{const g=n.getProperties(),d=P(g,o);if(d!==void 0)n=d,n.deleted&&(n.deleted=!1);else{const R=new q({},n);g[o]=R,n=R}}if(t===null)n.eq=void 0;else if(t instanceof q){const o=t.clone(h);h&&s!==void 0&&(typeof s=="number"&&Array.isArray(h.eq)?h.eq[s]=o:typeof s=="string"&&h.properties&&(h.properties[s]=o))}else typeof t=="string"||typeof t=="number"||typeof t=="boolean"||t instanceof Date?n.eq=t:Array.isArray(t)&&(n.eq=t.map(o=>new q({eq:o},n)));return this}delete(...e){return this.remove(e,!1)}unset(...e){return this.remove(e,!0)}remove(e,t=!1){let n=this;for(const s of e.slice(0,e.length-1))if(typeof s=="number"){if(n.eq===void 0||!Array.isArray(n.eq)){if(!t)return this;n.eq=Array.from({length:s}).map(()=>new q({},n))}else if(n.eq.length<=s){if(!t)return this;const o=n.eq,g=Array.from({length:s}).map((d,R)=>R<o.length?o[R]:new q({},n));n.eq=g}n=n.eq[s]}else{const o=P(n.properties,s);if(o!==void 0)n=o;else{if(!t)return this;const g=new q({},n);n.getProperties()[s]=g,n=g}}const h=e[e.length-1];if(typeof h=="string"){const s=n.properties;s&&P(s,h)!==void 0?delete s[h]:t&&(n.getProperties()[h]=new q({deleted:!0},n))}else Array.isArray(n.eq)&&n.eq.splice(h,1);return this}}ae.Tag=q,q.ids=new Map,q.nextTagId=1e3;function O(i){const e={};return i.eq!==void 0&&(Array.isArray(i.eq)?e.eq=i.eq.map(t=>O(t)):e.eq=i.eq),i.properties!==void 0&&(e.properties=I(i.properties)),i.deleted&&(e.deleted=!0),e}function I(i){const e=a();for(const[t,n]of Object.entries(i))e[t]=O(n);return e}return ae}var ue={},ye={},ne={},ke;function le(){if(ke)return ne;ke=1,Object.defineProperty(ne,"__esModule",{value:!0}),ne.formatRef=a,ne.emptyProperties=P,ne.getProperty=q,ne.isRef=O,ne.isDataNode=I,ne.isEnvRef=i,ne.isMotlyError=e;function a(t){let n="$";for(let s=0;s<t.linkUps;s++)n+="^";let h=!0;for(const s of t.linkTo)typeof s=="string"?((!h||t.linkUps>0)&&(n+="."),n+=s,h=!1):n+=`[${s}]`;return n}function P(){return Object.create(null)}function q(t,n){if(t!==void 0)return Object.prototype.hasOwnProperty.call(t,n)?t[n]:void 0}function O(t){return typeof t=="object"&&t!==null&&"linkTo"in t&&"linkUps"in t&&!Array.isArray(t)&&!(t instanceof Date)}function I(t){return typeof t=="object"&&t!==null&&!O(t)}function i(t){return typeof t=="object"&&t!==null&&"env"in t&&!Array.isArray(t)&&!(t instanceof Date)}function e(t){return typeof t=="object"&&t!==null&&"code"in t&&"message"in t&&"begin"in t&&"end"in t}return ne}var oe={},be;function Oe(){if(be)return oe;be=1,Object.defineProperty(oe,"__esModule",{value:!0}),oe.MotValue=oe.Mot=void 0,oe.buildMot=h;const a=le();class P{text(...o){return this.get(...o)._text()}numeric(...o){return this.get(...o)._numeric()}boolean(...o){return this.get(...o)._boolean()}date(...o){return this.get(...o)._date()}valueType(...o){return this.get(...o)._valueType()}values(...o){return this.get(...o)._values()}texts(...o){const g=this.get(...o)._values();if(!g)return;const d=[];for(const R of g){const M=R._text();if(M===void 0)return;d.push(M)}return d}numerics(...o){const g=this.get(...o)._values();if(!g)return;const d=[];for(const R of g){const M=R._numeric();if(M===void 0)return;d.push(M)}return d}booleans(...o){const g=this.get(...o)._values();if(!g)return;const d=[];for(const R of g){const M=R._boolean();if(M===void 0)return;d.push(M)}return d}dates(...o){const g=this.get(...o)._values();if(!g)return;const d=[];for(const R of g){const M=R._date();if(M===void 0)return;d.push(M)}return d}has(...o){return this.get(...o).exists}}oe.Mot=P;class q extends P{constructor(o,g,d=!0){super(),this.isRef=!1,this._val=o,this._props=g,this.exists=d}_text(){return this._val?.type==="string"?this._val.value:void 0}_numeric(){return this._val?.type==="number"?this._val.value:void 0}_boolean(){return this._val?.type==="boolean"?this._val.value:void 0}_date(){return this._val?.type==="date"?this._val.value:void 0}_values(){return this._val?.type==="array"?this._val.value:void 0}_valueType(){return this._val?.type}get keys(){return this._props.keys()}get entries(){return this._props.entries()}get(...o){let g=this;for(const d of o){if(typeof d=="number"){const R=g.values();if(!R||!Number.isInteger(d)||d<0||d>=R.length)return e;g=R[d]}else g===this?g=this._props.get(d)??e:g=g.get(d);if(!g.exists)return e}return g}}oe.MotValue=q;class O extends P{constructor(o,g){super(),this.exists=!0,this.isRef=!0,this._target=g}_text(){return this._target.text()}_numeric(){return this._target.numeric()}_boolean(){return this._target.boolean()}_date(){return this._target.date()}_values(){return this._target.values()}_valueType(){return this._target.valueType()}get keys(){return this._target.keys}get entries(){return this._target.entries}get(...o){return this._target.get(...o)}}const I={[Symbol.iterator]:()=>({next:()=>({done:!0,value:void 0})})};class i extends P{constructor(){super(...arguments),this.exists=!1,this.isRef=!1}_text(){}_numeric(){}_boolean(){}_date(){}_values(){}_valueType(){}get keys(){return I}get entries(){return I}get(...o){return this}}const e=new i,t={createMot(s,o){return new q(s,o)},createRefMot(s,o){return new O(s,o)},undefinedMot:e};function n(s,o,g,d){let R,M;if(s.linkUps===0)R=o,M=[];else{const $=g.length-s.linkUps;if($<0||$>=g.length)return;R=g[$],M=g.slice(0,$)}let N=R,W=M,K=R;for(let $=0;$<s.linkTo.length;$++){if((0,a.isRef)(N)){if(d.has(N))return;d.add(N);const X=n(N,o,W,d);if(d.delete(N),!X)return;N=X.target,W=X.ancestors,K=N,$--;continue}const B=N,Q=s.linkTo[$];if(typeof Q=="string"){const X=(0,a.getProperty)(B.properties,Q);if(X===void 0)return;$>0&&(W=[...W,K]),K=B,N=X}else{if(!B.eq||!Array.isArray(B.eq)||Q>=B.eq.length)return;$>0&&(W=[...W,K]),K=B,N=B.eq[Q]}}if((0,a.isRef)(N)){if(d.has(N))return;d.add(N);const $=n(N,o,W,d);return d.delete(N),$}return{target:N,ancestors:W}}function h(s,o){const g=o?.env,d=o?.factory??t,R=d.undefinedMot,M=new Map;function N($,B,Q){if($.deleted)return R;if(M.has($))return M.get($);const X=new Map,Y=K($.eq,B,Q,$),J=d.createMot(Y,X);if(M.set($,J),$.properties)for(const[z,l]of Object.entries($.properties)){const v=W(l,B,Q,$);v.exists&&X.set(z,v)}return J}function W($,B,Q,X){if((0,a.isRef)($)){const J=new Set;J.add($);const z=n($,B,Q,J);if(!z||z.target.deleted)return R;const l=N(z.target,B,z.ancestors);return d.createRefMot($,l)}const Y=$;return Y.deleted?R:N(Y,B,[...Q,X])}function K($,B,Q,X){if($!==void 0){if((0,a.isEnvRef)($)){const Y=(0,a.getProperty)(g,$.env);return Y===void 0?void 0:{type:"string",value:Y}}if(Array.isArray($)){const Y=[...Q,X],J=[];for(const z of $)J.push(W(z,B,Y,X));return{type:"array",value:J}}if(typeof $=="string")return{type:"string",value:$};if(typeof $=="number")return{type:"number",value:$};if(typeof $=="boolean")return{type:"boolean",value:$};if($ instanceof Date)return{type:"date",value:$}}}return N(s,s,[s])}return oe}var re={},de={},qe;function Me(){if(qe)return de;qe=1,Object.defineProperty(de,"__esModule",{value:!0}),de.parse=O;class a{constructor(i){this.input=i,this.pos=0}peekChar(){return this.pos<this.input.length?this.input[this.pos]:void 0}advance(i){this.pos+=i}startsWith(i){return this.input.startsWith(i,this.pos)}eatChar(i){return this.peekChar()===i?(this.advance(1),!0):!1}expectChar(i){if(!this.eatChar(i)){const e=this.peekChar();throw this.errorPoint(`Expected '${i}', found ${e===void 0?"end of input":`'${e}'`}`)}}position(){const i=this.input.substring(0,this.pos),e=(i.match(/\n/g)||[]).length,t=i.lastIndexOf(`
10
+ `),n=this.pos-(t===-1?0:t+1);return{line:e,column:n,offset:this.pos}}errorPoint(i){const e=this.position();return{code:"tag-parse-syntax-error",message:i,begin:e,end:e}}errorSpan(i,e){return{code:"tag-parse-syntax-error",message:i,begin:e,end:this.position()}}skipWs(){for(;;){for(;this.pos<this.input.length;){const i=this.input[this.pos];if(i===" "||i===" "||i==="\r"||i===`
11
+ `)this.pos++;else break}if(this.peekChar()==="#")for(;this.pos<this.input.length;){const i=this.input[this.pos];if(i==="\r"||i===`
12
+ `)break;this.pos++}else break}}skipWsAndCommas(){for(this.skipWs();this.peekChar()===",";)this.advance(1),this.skipWs()}parseStatements(){const i=[];for(this.skipWsAndCommas();this.pos<this.input.length;)i.push(this.parseStatement()),this.skipWsAndCommas();return i}parseStatement(){const i=this.position();if(this.startsWith("-..."))return this.advance(4),{kind:"clearAll",span:{begin:i,end:this.position()}};if(this.peekChar()==="-")return this.advance(1),{kind:"define",path:this.parsePropName(),deleted:!0,span:{begin:i,end:this.position()}};const e=this.parsePropName();this.skipWs();const t=this.peekChar();if(t===":"&&this.startsWith(":=")){this.advance(2),this.skipWs();const n=this.parseEqValue();if(this.skipWs(),this.peekChar()==="{"){const h=this.parsePropertiesBlock();return{kind:"assignBoth",path:e,value:n,properties:h,span:{begin:i,end:this.position()}}}return{kind:"assignBoth",path:e,value:n,properties:null,span:{begin:i,end:this.position()}}}if(t==="="){if(this.advance(1),this.skipWs(),this.peekChar()==="{")throw this.errorPoint("'=' requires a value; use ': { ... }' to replace properties");const n=this.parseEqValue();if(this.skipWs(),this.peekChar()==="{"){const h=this.parsePropertiesBlock();return{kind:"setEq",path:e,value:n,properties:h,span:{begin:i,end:this.position()}}}return{kind:"setEq",path:e,value:n,properties:null,span:{begin:i,end:this.position()}}}if(t===":"){this.advance(1),this.skipWs();const n=this.parsePropertiesBlock();return{kind:"replaceProperties",path:e,properties:n,span:{begin:i,end:this.position()}}}if(t==="{"){const n=this.parsePropertiesBlock();return{kind:"updateProperties",path:e,properties:n,span:{begin:i,end:this.position()}}}return{kind:"define",path:e,deleted:!1,span:{begin:i,end:this.position()}}}parsePropName(){const e=[this.parseIdentifier()];for(;this.peekChar()===".";)this.advance(1),e.push(this.parseIdentifier());return e}parseIdentifier(){return this.peekChar()==="`"?this.parseBacktickString():this.parseBareString()}parseEqValue(i=!0){const e=this.peekChar();if(i&&e==="[")return{kind:"array",elements:this.parseArray()};if(this.startsWith("<<<"))return{kind:"scalar",value:{kind:"string",value:this.parseHeredoc()}};if(e==="@")return{kind:"scalar",value:this.parseAtValue()};if(e==="$")return{kind:"scalar",value:this.parseReference()};if(e==='"')return this.startsWith('"""')?{kind:"scalar",value:{kind:"string",value:this.parseTripleString()}}:{kind:"scalar",value:{kind:"string",value:this.parseDoubleQuotedString()}};if(e==="'")return this.startsWith("'''")?{kind:"scalar",value:{kind:"string",value:this.parseTripleSingleQuotedString()}}:{kind:"scalar",value:{kind:"string",value:this.parseSingleQuotedString()}};if(e!==void 0&&(e==="-"||e>="0"&&e<="9"||e==="."))return this.parseNumberOrString();if(e!==void 0&&P(e))return{kind:"scalar",value:{kind:"string",value:this.parseBareString()}};throw this.errorPoint("Expected a value")}parseAtValue(){const i=this.position();if(this.expectChar("@"),this.startsWith("true")&&!this.isBareCharAt(4))return this.advance(4),{kind:"boolean",value:!0};if(this.startsWith("false")&&!this.isBareCharAt(5))return this.advance(5),{kind:"boolean",value:!1};if(this.startsWith("none")&&!this.isBareCharAt(4))return this.advance(4),{kind:"none"};if(this.startsWith("env."))return this.advance(4),{kind:"env",name:this.parseIdentifier()};const e=this.peekChar();if(e!==void 0&&e>="0"&&e<="9")return this.parseDate(i);const t=this.pos;for(;this.pos<this.input.length&&P(this.input[this.pos]);)this.pos++;const n=this.pos>t?this.input.substring(t,this.pos):"";throw this.errorSpan(`Illegal constant @${n}; expected @true, @false, @none, @env.NAME, or @date`,i)}isBareCharAt(i){const e=this.pos+i;return e<this.input.length&&P(this.input[e])}parseDate(i){const e=this.pos;if(this.consumeDigits(4,i),this.expectChar("-"),this.consumeDigits(2,i),this.expectChar("-"),this.consumeDigits(2,i),this.peekChar()==="T"){if(this.advance(1),this.consumeDigits(2,i),this.expectChar(":"),this.consumeDigits(2,i),this.peekChar()===":"&&(this.advance(1),this.consumeDigits(2,i),this.peekChar()===".")){this.advance(1);const h=this.pos;for(;this.pos<this.input.length&&this.input[this.pos]>="0"&&this.input[this.pos]<="9";)this.pos++;if(this.pos===h)throw this.errorSpan("Expected fractional digits in date",i)}const n=this.peekChar();n==="Z"?this.advance(1):(n==="+"||n==="-")&&(this.advance(1),this.consumeDigits(2,i),this.peekChar()===":"&&this.advance(1),this.consumeDigits(2,i))}return{kind:"date",value:this.input.substring(e,this.pos)}}consumeDigits(i,e){for(let t=0;t<i;t++){const n=this.peekChar();if(n===void 0||n<"0"||n>"9")throw this.errorSpan("Expected digit",e);this.advance(1)}}parseOptionalExponent(i){const e=this.peekChar();if(e!=="e"&&e!=="E")return;this.advance(1);const t=this.peekChar();(t==="+"||t==="-")&&this.advance(1);const n=this.pos;for(;this.pos<this.input.length&&this.input[this.pos]>="0"&&this.input[this.pos]<="9";)this.advance(1);if(this.pos===n)throw this.errorSpan("Expected exponent digits",i)}parseNumberOrString(){const i=this.pos,e=this.position(),t=this.peekChar()==="-";t&&this.advance(1);let n=!1,h=!1;for(;this.pos<this.input.length&&this.input[this.pos]>="0"&&this.input[this.pos]<="9";)n=!0,this.advance(1);if(this.peekChar()==="."){h=!0,this.advance(1);const d=this.pos;for(;this.pos<this.input.length&&this.input[this.pos]>="0"&&this.input[this.pos]<="9";)this.advance(1);if(this.pos===d)return this.pos=i,this.parseIntegerOrBare(i,t)}if(!n&&!h){if(this.pos=i,t)throw this.errorPoint("Expected a value");return{kind:"scalar",value:{kind:"string",value:this.parseBareString()}}}this.parseOptionalExponent(e);const s=this.peekChar();if(s!==void 0&&P(s)&&!(s>="0"&&s<="9")){if(this.pos=i,t)throw this.errorPoint("Expected a value");return{kind:"scalar",value:{kind:"string",value:this.parseBareString()}}}const o=this.input.substring(i,this.pos),g=parseFloat(o);if(isNaN(g))throw this.errorSpan(`Invalid number: ${o}`,e);return{kind:"scalar",value:{kind:"number",value:g}}}parseIntegerOrBare(i,e){this.pos=i;const t=this.position();e&&this.advance(1);const n=this.pos;for(;this.pos<this.input.length&&this.input[this.pos]>="0"&&this.input[this.pos]<="9";)this.advance(1);if(this.pos===n){if(this.pos=i,e)throw this.errorPoint("Expected a value");return{kind:"scalar",value:{kind:"string",value:this.parseBareString()}}}if(!e){const o=this.peekChar();if(o!==void 0&&P(o)&&!(o>="0"&&o<="9"))return this.pos=i,{kind:"scalar",value:{kind:"string",value:this.parseBareString()}}}this.parseOptionalExponent(t);const h=this.input.substring(i,this.pos),s=parseFloat(h);if(isNaN(s))throw this.errorSpan(`Invalid number: ${h}`,t);return{kind:"scalar",value:{kind:"number",value:s}}}parseBareString(){const i=this.pos;for(;this.pos<this.input.length&&P(this.input[this.pos]);)this.pos++;if(this.pos===i)throw this.errorPoint("Expected an identifier");return this.input.substring(i,this.pos)}parseDoubleQuotedString(){const i=this.position();this.expectChar('"');let e="";for(;;){const t=this.peekChar();if(t===void 0||t==="\r"||t===`
13
+ `)throw this.errorSpan("Unterminated string",i);if(t==='"')return this.advance(1),e;t==="\\"?(this.advance(1),e+=this.parseEscapeChar()):(this.advance(1),e+=t)}}parseSingleQuotedString(){const i=this.position();this.expectChar("'");let e="";for(;;){const t=this.peekChar();if(t===void 0||t==="\r"||t===`
14
+ `)throw this.errorSpan("Unterminated string",i);if(t==="'")return this.advance(1),e;if(t==="\\"){this.advance(1),e+="\\";const n=this.peekChar();if(n===void 0||n==="\r"||n===`
15
+ `)throw this.errorSpan("Unterminated string",i);this.advance(1),e+=n}else this.advance(1),e+=t}}parseTripleSingleQuotedString(){const i=this.position();if(!this.startsWith("'''"))throw this.errorPoint("Expected triple-single-quoted string");this.advance(3);let e="";for(;;){if(this.startsWith("'''"))return this.advance(3),e;const t=this.peekChar();if(t===void 0)throw this.errorSpan("Unterminated triple-single-quoted string",i);if(t==="\\"){this.advance(1),e+="\\";const n=this.peekChar();if(n===void 0)throw this.errorSpan("Unterminated triple-single-quoted string",i);this.advance(1),e+=n}else this.advance(1),e+=t}}parseBacktickString(){const i=this.position();this.expectChar("`");let e="";for(;;){const t=this.peekChar();if(t===void 0||t==="\r"||t===`
16
+ `)throw this.errorSpan("Unterminated backtick string",i);if(t==="`")return this.advance(1),e;t==="\\"?(this.advance(1),e+=this.parseEscapeChar()):(this.advance(1),e+=t)}}parseTripleString(){const i=this.position();if(!this.startsWith('"""'))throw this.errorPoint("Expected triple-quoted string");this.advance(3);let e="";for(;;){if(this.startsWith('"""'))return this.advance(3),e;const t=this.peekChar();if(t===void 0)throw this.errorSpan("Unterminated triple-quoted string",i);t==="\\"?(this.advance(1),e+=this.parseEscapeChar()):(this.advance(1),e+=t)}}parseEscapeChar(){const i=this.peekChar();if(i===void 0)throw this.errorPoint("Unterminated escape sequence");switch(i){case"b":return this.advance(1),"\b";case"f":return this.advance(1),"\f";case"n":return this.advance(1),`
17
+ `;case"r":return this.advance(1),"\r";case"t":return this.advance(1)," ";case"u":{const e=this.position();this.advance(1);const t=this.pos;for(let s=0;s<4;s++){const o=this.peekChar();if(o===void 0||!q(o))throw this.errorSpan("Expected 4 hex digits in \\uXXXX",e);this.advance(1)}const n=this.input.substring(t,this.pos),h=parseInt(n,16);return String.fromCharCode(h)}default:return this.advance(1),i}}parseHeredoc(){const i=this.position();for(this.advance(3);this.pos<this.input.length;){const s=this.input[this.pos];if(s===" "||s===" ")this.pos++;else break}if(this.pos<this.input.length&&this.input[this.pos]==="\r"&&this.advance(1),this.pos>=this.input.length||this.input[this.pos]!==`
18
+ `)throw this.errorSpan("Expected newline after <<<",i);this.advance(1);const e=[];let t=!1;for(;this.pos<this.input.length;){const s=this.pos;for(;this.pos<this.input.length&&this.input[this.pos]!==`
19
+ `;)this.pos++;let o=this.input.substring(s,this.pos);if(o.endsWith("\r")&&(o=o.substring(0,o.length-1)),this.pos<this.input.length&&this.input[this.pos]===`
20
+ `&&this.advance(1),o.trim()===">>>"){t=!0;break}e.push(o)}if(!t)throw this.errorSpan("Unterminated heredoc (expected >>>)",i);if(e.length===0)return"";let n=0;for(const s of e){const o=s.trimStart();if(o.length>0){n=s.length-o.length;break}}return e.map(s=>s.trimStart().length===0?"":n<=s.length?s.substring(n):s).join(`
21
+ `)+`
22
+ `}parseArray(){const i=this.position();if(this.expectChar("["),this.skipWs(),this.eatChar("]"))return[];const e=[];for(e.push(this.parseArrayElement());;){if(this.skipWs(),this.eatChar("]"))return e;if(this.eatChar(",")){if(this.skipWs(),this.peekChar()==="]")return this.advance(1),e;e.push(this.parseArrayElement())}else throw this.pos>=this.input.length?this.errorSpan("Unclosed '['",i):this.errorPoint("Expected ',' or ']' in array")}}parseArrayElement(){this.skipWs();const i=this.position(),e=this.peekChar();if(e==="{")return{value:null,properties:this.parsePropertiesBlock(),span:{begin:i,end:this.position()}};if(e==="["){const n=this.parseArray();if(this.skipWs(),this.peekChar()==="{"){const h=this.parsePropertiesBlock();return{value:{kind:"array",elements:n},properties:h,span:{begin:i,end:this.position()}}}return{value:{kind:"array",elements:n},properties:null,span:{begin:i,end:this.position()}}}const t=this.parseEqValue(!1);if(this.skipWs(),this.peekChar()==="{"){const n=this.parsePropertiesBlock();return{value:t,properties:n,span:{begin:i,end:this.position()}}}return{value:t,properties:null,span:{begin:i,end:this.position()}}}parsePropertiesBlock(){const i=this.position();this.expectChar("{");const e=[];for(;;){if(this.skipWsAndCommas(),this.eatChar("}"))return e;if(this.pos>=this.input.length)throw this.errorSpan("Unclosed '{'",i);e.push(this.parseStatement())}}parseReference(){this.expectChar("$");let i=0;for(;this.peekChar()==="^";)this.advance(1),i++;if(i>0){if(this.peekChar()!==".")return{kind:"reference",ups:i,path:[]};this.advance(1)}const e=[],t=this.parseIdentifier();if(e.push({kind:"name",name:t}),this.peekChar()==="["){this.advance(1),this.skipWs();const n=this.parseRefIndex();e.push({kind:"index",index:n}),this.skipWs(),this.expectChar("]")}for(;this.peekChar()===".";){this.advance(1);const n=this.parseIdentifier();if(e.push({kind:"name",name:n}),this.peekChar()==="["){this.advance(1),this.skipWs();const h=this.parseRefIndex();e.push({kind:"index",index:h}),this.skipWs(),this.expectChar("]")}}return{kind:"reference",ups:i,path:e}}parseRefIndex(){const i=this.position(),e=this.pos;for(;this.pos<this.input.length&&this.input[this.pos]>="0"&&this.input[this.pos]<="9";)this.pos++;if(this.pos===e)throw this.errorPoint("Expected array index");const t=parseInt(this.input.substring(e,this.pos),10);if(isNaN(t))throw this.errorSpan("Invalid array index",i);return t}}function P(I){const i=I.charCodeAt(0);return i>=48&&i<=57||i>=65&&i<=90||i>=97&&i<=122||i===95||i>=192&&i<=591||i>=7680&&i<=7935}function q(I){const i=I.charCodeAt(0);return i>=48&&i<=57||i>=65&&i<=70||i>=97&&i<=102}function O(I){return new a(I).parseStatements()}return de}var fe={},ie={},we;function $e(){if(we)return ie;we=1,Object.defineProperty(ie,"__esModule",{value:!0}),ie.clonePropertyValue=ie.cloneValue=void 0,ie.cloneNode=P,ie.cloneMotlyNode=q;const a=le();function P(O){const I={};if(O.deleted&&(I.deleted=!0),O.eq!==void 0&&(O.eq instanceof Date?I.eq=new Date(O.eq.getTime()):Array.isArray(O.eq)?I.eq=O.eq.map(q):(0,a.isEnvRef)(O.eq)?I.eq={env:O.eq.env}:I.eq=O.eq),O.properties){const i=(0,a.emptyProperties)();for(const e of Object.keys(O.properties))i[e]=q(O.properties[e]);I.properties=i}return O.location&&(I.location={parseId:O.location.parseId,begin:{...O.location.begin},end:{...O.location.end}}),I}function q(O){return(0,a.isRef)(O)?{linkTo:[...O.linkTo],linkUps:O.linkUps}:P(O)}return ie.cloneValue=P,ie.clonePropertyValue=q,ie}var Ae;function je(){if(Ae)return fe;Ae=1,Object.defineProperty(fe,"__esModule",{value:!0}),fe.flatten=q,fe.chunk=i,fe.topoSort=o,fe.executeChunked=g;const a=le(),P=$e();function q(r,f){const c=[];return O(r,[],f.parseId,c),c}function O(r,f,c,p){for(const u of r)I(u,f,c,p)}function I(r,f,c,p){switch(r.kind){case"setEq":{const u=[...f,...r.path];if(r.value.kind==="scalar"&&r.value.value.kind==="reference"){const k=r.value.value;p.push({path:u,op:{kind:"link",ups:k.ups,refPath:k.path},span:r.span,parseId:c})}else p.push({path:u,op:{kind:"setValue",value:r.value},span:r.span,parseId:c}),r.properties!==null&&O(r.properties,u,c,p);break}case"assignBoth":{const u=[...f,...r.path];if(r.value.kind==="scalar"&&r.value.value.kind==="reference"){const k=r.value.value;p.push({path:u,op:{kind:"clone",ups:k.ups,refPath:k.path},span:r.span,parseId:c}),r.properties!==null&&(p.push({path:u,op:{kind:"clearProperties"},span:r.span,parseId:c}),O(r.properties,u,c,p))}else p.push({path:u,op:{kind:"assignValue",value:r.value},span:r.span,parseId:c}),r.properties!==null&&O(r.properties,u,c,p);break}case"replaceProperties":{const u=[...f,...r.path];p.push({path:u,op:{kind:"clearProperties"},span:r.span,parseId:c}),O(r.properties,u,c,p);break}case"updateProperties":{const u=[...f,...r.path];p.push({path:u,op:{kind:"define"},span:r.span,parseId:c}),O(r.properties,u,c,p);break}case"define":{const u=[...f,...r.path];p.push({path:u,op:{kind:r.deleted?"delete":"define"},span:r.span,parseId:c});break}case"clearAll":{p.push({path:[...f],op:{kind:"clearAll"},span:r.span,parseId:c});break}}}function i(r){const f=r.length;if(f===0)return{splits:[0],deps:[]};const c=new Map;for(let j=0;j<f;j++)c.set(e(r[j].path),j);const p=new Set([0,f]),u=new Set,k=[];for(let j=0;j<f;j++){const F=r[j],G=e(F.path);if(F.op.kind==="link"||F.op.kind==="clone"){const Z=h(F.path,F.op.ups,F.op.refPath);if(!t(u,Z)){k.push({refIdx:j,targetKey:Z}),p.add(j),p.add(j+1);const se=n(c,Z);se>j&&p.add(se)}}u.add(G)}const w=Array.from(p).sort((j,F)=>j-F),x=w.length-1,_=Array.from({length:x},()=>new Set);for(const{refIdx:j,targetKey:F}of k){const G=s(w,j),Z=n(c,F);if(Z!==-1){const ee=s(w,Z);ee!==G&&_[G].add(ee)}const se=e(r[j].path);for(let ee=j+1;ee<f;ee++){const ce=e(r[ee].path);if(ce===se||ce.startsWith(se+"\0")){const he=s(w,ee);he!==G&&_[he].add(G)}}}const C=_.map(j=>Array.from(j));return{splits:w,deps:C}}function e(r){return r.join("\0")}function t(r,f){for(const c of r)if(c===f||c.startsWith(f+"\0"))return!0;return!1}function n(r,f){let c=-1;for(const[p,u]of r)(p===f||p.startsWith(f+"\0")||f.startsWith(p+"\0"))&&(c=Math.max(c,u));return c}function h(r,f,c){const p=[];if(f>0){const u=Math.max(0,r.length-1-f);for(let k=0;k<u;k++)p.push(r[k])}for(const u of c)u.kind==="name"?p.push(u.name):p.push(`[${u.index}]`);return p.join("\0")}function s(r,f){let c=0,p=r.length-2;for(;c<p;){const u=c+p+1>>1;r[u]<=f?c=u:p=u-1}return c}function o(r){const f=r.length,c=new Array(f).fill(0),p=Array.from({length:f},()=>[]);for(let _=0;_<f;_++)for(const C of r[_])p[C].push(_),c[_]++;const u=[];for(let _=0;_<f;_++)c[_]===0&&u.push(_);const k=[];let w=0;for(;w<u.length;){const _=u[w++];k.push(_);for(const C of p[_])--c[C]===0&&u.push(C)}const x=[];if(k.length<f){const _=new Set(k);for(let C=0;C<f;C++)_.has(C)||x.push(C)}return{order:k,cycles:x}}function g(r,f,c,p,u){const k=[],w=[];for(const x of c){const _=f[x],C=f[x+1];for(let j=_;j<C;j++)R(r[j],p,u,k,w)}return d(k,w),k}function d(r,f){if(f.length<2)return;const c=new Map;for(const w of f)c.set(w.sourcePath,w);const p=new Set,u=new Set;for(const w of f){if(u.has(w.sourcePath))continue;const x=[],_=new Set;let C=w;for(;C&&!_.has(C.sourcePath)&&!u.has(C.sourcePath);)x.push(C),_.add(C.sourcePath),C=c.get(C.targetPath);if(C&&_.has(C.sourcePath)){const j=C.sourcePath,F=[];let G=!1;for(const H of x)H.sourcePath===j&&(G=!0),G&&F.push(H);const Z=H=>H.replace(/\0/g,"."),se=F.map(H=>Z(H.sourcePath)),ee=F.map(H=>`$${Z(H.targetPath)}`);let ce=se[0];for(let H=0;H<ee.length;H++)ce+=` clones ${ee[H]}`,H<ee.length-1&&(ce+=`, ${se[H+1]}`);for(const H of F)p.add(H.errorIndex);const he=F[0].errorIndex,ve={line:0,column:0,offset:0};r[he]={code:"circular-reference",message:`Circular clone dependency: ${ce}`,begin:ve,end:ve}}for(const j of x)u.add(j.sourcePath)}const k=Array.from(p).sort((w,x)=>x-w);for(const w of k)r[w].code!=="circular-reference"&&r.splice(w,1)}function R(r,f,c,p,u){const k={parseId:r.parseId,options:c};switch(r.op.kind){case"setValue":M(r.path,r.op.value,f,k,r.span,p);break;case"assignValue":N(r.path,r.op.value,f,k,r.span,p);break;case"clearProperties":W(r.path,f,k,r.span,p);break;case"clearAll":K(r.path,f,k,r.span,p);break;case"define":$(r.path,f,k,r.span,p);break;case"delete":B(r.path,f,k,r.span,p);break;case"link":Q(r.path,r.op.ups,r.op.refPath,f,k,r.span,p);break;case"clone":X(r.path,r.op.ups,r.op.refPath,f,k,r.span,p,u);break}}function M(r,f,c,p,u,k){if(r.length===0){l(c,f,p,k);return}const w=z(c,r,p,u,k);if(!w)return;const[x,_]=w,C=D(_);(0,a.getProperty)(C,x)===void 0&&(C[x]={});const j=V(C,x);J(j,p,u),l(j,f,p,k)}function N(r,f,c,p,u,k){if(r.length===0){delete c.properties,c.location=Y(p,u),l(c,f,p,k);return}const w=z(c,r,p,u,k);if(!w)return;const[x,_]=w,C={};C.location=Y(p,u),l(C,f,p,k),D(_)[x]=C}function W(r,f,c,p,u){if(r.length===0){delete f.properties;return}const k=z(f,r,c,p,u);if(!k)return;const[w,x]=k,_=D(x),C=(0,a.getProperty)(_,w);if(C!==void 0&&!(0,a.isRef)(C))delete C.properties;else{const j={};j.location=Y(c,p),_[w]=j}}function K(r,f,c,p,u){if(r.length===0){delete f.eq,f.properties=(0,a.emptyProperties)();return}const k=z(f,r,c,p,u);if(!k)return;const[w,x]=k,_=D(x),C=(0,a.getProperty)(_,w);C!==void 0&&!(0,a.isRef)(C)?(delete C.eq,C.properties=(0,a.emptyProperties)()):_[w]={}}function $(r,f,c,p,u){const k=z(f,r,c,p,u);if(!k)return;const[w,x]=k,_=D(x);if((0,a.getProperty)(_,w)===void 0){const C={};C.location=Y(c,p),_[w]=C}}function B(r,f,c,p,u){const k=z(f,r,c,p,u);if(!k)return;const[w,x]=k,_={deleted:!0};_.location=Y(c,p),D(x)[w]=_}function Q(r,f,c,p,u,k,w){u.options.disableReferences&&w.push({code:"ref-not-allowed",message:"References are not allowed in this session. Use := for cloning.",begin:k.begin,end:k.end});const x=z(p,r,u,k,w);if(!x)return;const[_,C]=x;D(C)[_]=y(f,c)}function X(r,f,c,p,u,k,w,x){const _=z(p,r,u,k,w);if(!_)return;const[C,j]=_;let F;try{F=E(p,r,f,c)}catch(G){if((0,a.isMotlyError)(G)){const Z=w.length;w.push(G),x.push({sourcePath:e(r),targetPath:h(r,f,c),errorIndex:Z})}return}T(F,0,w),F.location=Y(u,k),D(j)[C]=F}function Y(r,f){return{parseId:r.parseId,begin:f.begin,end:f.end}}function J(r,f,c){r.location||(r.location=Y(f,c))}function z(r,f,c,p,u){let k=r;for(let w=0;w<f.length-1;w++){const x=f[w],_=D(k),C=(0,a.getProperty)(_,x);if(C!==void 0&&(0,a.isRef)(C))return u.push({code:"write-through-link",message:`Cannot write through link reference "${x}"`,begin:p.begin,end:p.end}),null;if(C===void 0){const j={};j.location=Y(c,p),_[x]=j}k=V(_,x),J(k,c,p)}return[f[f.length-1],k]}function l(r,f,c,p){if(f.kind==="array")r.eq=v(f.elements,p,c);else{const u=f.value;switch(u.kind){case"string":r.eq=u.value;break;case"number":r.eq=u.value;break;case"boolean":r.eq=u.value;break;case"date":r.eq=new Date(u.value);break;case"reference":throw new Error("References should be handled before calling setEqSlot");case"env":r.eq={env:u.name};break;case"none":delete r.eq;break}}}function v(r,f,c){return r.map(p=>b(p,f,c))}function b(r,f,c){if(r.value!==null&&r.value.kind==="scalar"&&r.value.value.kind==="reference"){if(c.options.disableReferences&&f.push({code:"ref-not-allowed",message:"References are not allowed in this session. Use := for cloning.",begin:r.span.begin,end:r.span.end}),r.properties!==null){const u={line:0,column:0,offset:0};f.push({code:"ref-with-properties",message:"Cannot add properties to a reference. Did you mean := (clone)?",begin:u,end:u})}return y(r.value.value.ups,r.value.value.path)}const p={};if(p.location=Y(c,r.span),r.value!==null&&l(p,r.value,c,f),r.properties!==null){const u=q(r.properties,c),{splits:k,deps:w}=i(u),{order:x}=o(w);f.push(...g(u,k,x,p,c.options))}return p}function y(r,f){return{linkTo:f.map(c=>c.kind==="name"?c.name:c.index),linkUps:r}}function m(r,f){let c="$";for(let u=0;u<r;u++)c+="^";let p=!0;for(const u of f)u.kind==="name"?((!p||r>0)&&(c+="."),c+=u.name,p=!1):c+=`[${u.index}]`;return c}function E(r,f,c,p){const u=m(c,p);let k;if(c===0)k=r;else{const x=f.length-1-c;if(x<0)throw A(`Clone reference ${u} goes ${c} level(s) up but only ${f.length-1} ancestor(s) available`);k=r;for(let _=0;_<x;_++){if(!k.properties)throw A(`Clone reference ${u} could not be resolved: path segment "${f[_]}" not found`);const C=(0,a.getProperty)(k.properties,f[_]);if(C===void 0)throw A(`Clone reference ${u} could not be resolved: path segment "${f[_]}" not found`);if((0,a.isRef)(C)){const j=S(r,C);if(!j)throw A(`Clone reference ${u} could not be resolved: path segment "${f[_]}" is an unresolvable link reference`);k=j;continue}k=C}}let w=k;for(const x of p)if(x.kind==="name"){if(!w.properties)throw A(`Clone reference ${u} could not be resolved: property "${x.name}" not found`);const _=(0,a.getProperty)(w.properties,x.name);if(_===void 0)throw A(`Clone reference ${u} could not be resolved: property "${x.name}" not found`);if((0,a.isRef)(_)){const C=S(r,_);if(!C)throw A(`Clone reference ${u} could not be resolved: property "${x.name}" is an unresolvable link reference`);w=C;continue}w=_}else{if(!w.eq||!Array.isArray(w.eq))throw A(`Clone reference ${u} could not be resolved: index [${x.index}] used on non-array`);if(x.index>=w.eq.length)throw A(`Clone reference ${u} could not be resolved: index [${x.index}] out of bounds (array length ${w.eq.length})`);const _=w.eq[x.index];if((0,a.isRef)(_)){const C=S(r,_);if(!C)throw A(`Clone reference ${u} could not be resolved: index [${x.index}] is an unresolvable link reference`);w=C;continue}w=_}return(0,P.cloneNode)(w)}function A(r){const f={line:0,column:0,offset:0};return{code:"unresolved-clone-reference",message:r,begin:f,end:f}}function S(r,f,c){c||(c=new Set);const p=(0,a.formatRef)(f);if(c.has(p)||(c.add(p),f.linkUps>0))return null;let u=r;for(const k of f.linkTo){if(u===void 0)return null;if((0,a.isRef)(u)){const x=S(r,u,c);if(!x)return null;u=x}if(!(0,a.isDataNode)(u))return null;const w=u;if(typeof k=="string"){const x=(0,a.getProperty)(w.properties,k);if(x===void 0)return null;u=x}else{if(!w.eq||!Array.isArray(w.eq)||k>=w.eq.length)return null;u=w.eq[k]}}return u!==void 0&&(0,a.isRef)(u)?S(r,u,c):u??null}function T(r,f,c){if(r.eq!==void 0&&Array.isArray(r.eq))for(let p=0;p<r.eq.length;p++)U(r.eq,p,f+1,c);if(r.properties)for(const p of Object.keys(r.properties))L(r.properties,p,f+1,c)}function U(r,f,c,p){const u=r[f];if((0,a.isRef)(u)){if(u.linkUps>0&&u.linkUps>c){const k={line:0,column:0,offset:0};p.push({code:"clone-reference-out-of-scope",message:`Cloned reference "${(0,a.formatRef)(u)}" escapes the clone boundary (${u.linkUps} level(s) up from depth ${c})`,begin:k,end:k}),r[f]={}}}else T(u,c,p)}function L(r,f,c,p){const u=r[f];if((0,a.isRef)(u)){if(u.linkUps>0&&u.linkUps>c){const k={line:0,column:0,offset:0};p.push({code:"clone-reference-out-of-scope",message:`Cloned reference "${(0,a.formatRef)(u)}" escapes the clone boundary (${u.linkUps} level(s) up from depth ${c})`,begin:k,end:k}),r[f]={}}}else T(u,c,p)}function D(r){return r.properties||(r.properties=(0,a.emptyProperties)()),r.properties}function V(r,f){const c=(0,a.getProperty)(r,f);if(c===void 0||(0,a.isRef)(c)){const p={};return r[f]=p,p}return c}return fe}var pe={},Pe;function Te(){if(Pe)return pe;Pe=1,Object.defineProperty(pe,"__esModule",{value:!0}),pe.validateReferences=q,pe.validateSchema=h;const a=le();function P(l,v,b,y,m){const E={code:v,message:b,path:y};m?.location&&(E.location=m.location),l.push(E)}function q(l){const v=[];return O(l,[],[l],l,v),v}function O(l,v,b,y,m){if(l.eq!==void 0&&Array.isArray(l.eq)&&I(l.eq,v,b,l,y,m),l.properties)for(const E of Object.keys(l.properties)){const A=l.properties[E];if(v.push(E),(0,a.isRef)(A)){const S=i(A,b,y);if(S!==null){const T={message:S,path:[...v],code:"unresolved-reference"};l.location&&(T.location=l.location),m.push(T)}}else b.push(l),O(A,v,b,y,m),b.pop();v.pop()}}function I(l,v,b,y,m,E){for(let A=0;A<l.length;A++){const S=l[A],T=`[${A}]`;if(v.push(T),(0,a.isRef)(S)){const U=i(S,b,m);U!==null&&E.push({message:U,path:[...v],code:"unresolved-reference"})}else b.push(y),O(S,v,b,m,E),b.pop();v.pop()}}function i(l,v,b){const y=(0,a.formatRef)(l);let m;if(l.linkUps===0)m=b;else{const E=v.length-l.linkUps;if(E<0||E>=v.length)return`Reference "${y}" goes ${l.linkUps} level(s) up but only ${v.length} ancestor(s) available`;m=v[E]}return e(m,l.linkTo,y)}function e(l,v,b){let y=l;for(const m of v){if(y==="terminal")return`Reference "${b}" could not be resolved: cannot follow path through a link`;if(typeof m=="string"){if(!y.properties)return`Reference "${b}" could not be resolved: property "${m}" not found (node has no properties)`;const E=(0,a.getProperty)(y.properties,m);if(E===void 0)return`Reference "${b}" could not be resolved: property "${m}" not found`;(0,a.isRef)(E)?y="terminal":y=E}else{if(y.eq===void 0||!Array.isArray(y.eq))return`Reference "${b}" could not be resolved: index [${m}] used on non-array`;if(m>=y.eq.length)return`Reference "${b}" could not be resolved: index [${m}] out of bounds (array length ${y.eq.length})`;const E=y.eq[m];(0,a.isRef)(E)?y="terminal":y=E}}return null}const t=64,n=new Map([["string",{properties:{VALUE:{eq:"string"}}}],["number",{properties:{VALUE:{eq:"number"}}}],["integer",{properties:{VALUE:{eq:"integer"}}}],["boolean",{properties:{VALUE:{eq:"boolean"}}}],["date",{properties:{VALUE:{eq:"date"}}}],["flag",{properties:{ADDITIONAL:{eq:"reject"}}}],["tag",{properties:{ADDITIONAL:{eq:"accept"}}}],["any",{properties:{ADDITIONAL:{eq:"accept"}}}]]);function h(l,v){const b=[],y=s(v,b);return g(l,v,y,[],b,0),b}function s(l,v){const b=new Map(n),y=o(l,"TYPES");if(y?.properties){for(const[m,E]of Object.entries(y.properties))if(!(0,a.isRef)(E)){if(n.has(m)){v.push({message:`Type "${m}" cannot shadow pre-loaded type`,path:["TYPES",m],code:"invalid-schema"});continue}b.set(m,E)}}return b}function o(l,v){const b=(0,a.getProperty)(l.properties,v);if(!(b===void 0||(0,a.isRef)(b)))return b}function g(l,v,b,y,m,E){if(E>t){P(m,"invalid-schema","Maximum validation depth exceeded (possible recursive type cycle)",[...y],l);return}const A=o(v,"ONEOF");if(A&&Array.isArray(A.eq)){Y(l,A.eq,b,y,m,E);return}const S=o(v,"VALUE");S&&d(l,S,b,y,m),$(l,v,b,y,m,E)}function d(l,v,b,y,m,E){const A=typeof v.eq=="string"?v.eq:void 0;if(!A)return;const S=l.eq;switch(A){case"string":if(typeof S!="string"){P(m,"wrong-type",`Expected string, got ${R(S)}`,[...y],l);return}M(S,v,y,m,l);break;case"number":if(typeof S!="number"){P(m,"wrong-type",`Expected number, got ${R(S)}`,[...y],l);return}N(S,v,y,m,l);break;case"integer":if(typeof S!="number"||!Number.isInteger(S)){P(m,"wrong-type",`Expected integer, got ${R(S)}`,[...y],l);return}N(S,v,y,m,l);break;case"boolean":if(typeof S!="boolean"){P(m,"wrong-type",`Expected boolean, got ${R(S)}`,[...y],l);return}W(S,v,y,m,l);break;case"date":if(!(S instanceof Date)){P(m,"wrong-type",`Expected date, got ${R(S)}`,[...y],l);return}W(S,v,y,m,l);break;default:{const T=b.get(A);if(!T){P(m,"invalid-schema",`Unknown VALUE type "${A}"`,[...y],l);return}const U=o(T,"VALUE");if(!U){P(m,"invalid-schema",`Type "${A}" cannot be used as a VALUE type (no VALUE constraint)`,[...y],l);return}d(l,U,b,y,m)}}}function R(l){return l===void 0?"no value":l instanceof Date?`date ${l.toISOString()}`:Array.isArray(l)?"array":typeof l=="string"?`string ${JSON.stringify(l)}`:typeof l=="number"||typeof l=="boolean"?`${typeof l} ${l}`:typeof l}function M(l,v,b,y,m){W(l,v,b,y,m);const E=o(v,"MATCHES");if(E&&typeof E.eq=="string")try{new RegExp(E.eq).test(l)||P(y,"pattern-mismatch",`Value "${l}" does not match pattern "${E.eq}"`,[...b],m)}catch(T){P(y,"invalid-schema",`Invalid regex pattern "${E.eq}": ${T}`,[...b],m)}const A=o(v,"MIN_LENGTH");A&&typeof A.eq=="number"&&l.length<A.eq&&P(y,"length-violation",`String length ${l.length} is less than minimum ${A.eq}`,[...b],m);const S=o(v,"MAX_LENGTH");S&&typeof S.eq=="number"&&l.length>S.eq&&P(y,"length-violation",`String length ${l.length} exceeds maximum ${S.eq}`,[...b],m)}function N(l,v,b,y,m){W(l,v,b,y,m);const E=o(v,"MIN");E&&typeof E.eq=="number"&&l<E.eq&&P(y,"out-of-range",`Value ${l} is less than minimum ${E.eq}`,[...b],m);const A=o(v,"MAX");A&&typeof A.eq=="number"&&l>A.eq&&P(y,"out-of-range",`Value ${l} exceeds maximum ${A.eq}`,[...b],m)}function W(l,v,b,y,m){const E=o(v,"ENUM");if(!E||!Array.isArray(E.eq))return;if(!E.eq.some(S=>{if((0,a.isRef)(S))return!1;const T=S.eq;return T instanceof Date&&l instanceof Date?T.getTime()===l.getTime():T===l})){const S=E.eq.filter(T=>!(0,a.isRef)(T)).map(T=>String(T.eq));P(y,"invalid-enum-value",`${R(l)} is not one of: [${S.join(", ")}]`,[...b],m)}}function K(l){const v=(0,a.getProperty)(l.properties,"ADDITIONAL");return v===void 0?{kind:"reject"}:(0,a.isRef)(v)?{kind:"reject"}:typeof v.eq=="string"?v.eq==="reject"?{kind:"reject"}:v.eq==="accept"?{kind:"accept"}:{kind:"type",typeName:v.eq}:v.properties&&Object.keys(v.properties).some(y=>y==="VALUE"||y==="REQUIRED"||y==="OPTIONAL"||y==="ADDITIONAL"||y==="ONEOF")?{kind:"inline",constraint:v}:{kind:"accept"}}function $(l,v,b,y,m,E){const A=o(v,"REQUIRED")?.properties,S=o(v,"OPTIONAL")?.properties,T=K(v),U=l.properties;if(A)for(const[L,D]of Object.entries(A)){if((0,a.isRef)(D))continue;const V=[...y,L],r=(0,a.getProperty)(U,L);r===void 0?P(m,"missing-required",`Missing required property "${L}"`,V,l):B(r,D,b,V,m,E)}if(S&&U)for(const[L,D]of Object.entries(S)){if((0,a.isRef)(D))continue;const V=(0,a.getProperty)(U,L);V!==void 0&&B(V,D,b,[...y,L],m,E)}if(U){const L=new Set;if(A)for(const D of Object.keys(A))L.add(D);if(S)for(const D of Object.keys(S))L.add(D);for(const D of Object.keys(U)){if(L.has(D))continue;const V=[...y,D];switch(T.kind){case"reject":{const r=U[D];P(m,"unknown-property",`Unknown property "${D}"`,V,(0,a.isRef)(r)?void 0:r);break}case"accept":break;case"type":B(U[D],{eq:T.typeName},b,V,m,E);break;case"inline":{const r=U[D];(0,a.isRef)(r)?P(m,"wrong-type",`Expected a value but found a link ${(0,a.formatRef)(r)}`,V):g(r,T.constraint,b,V,m,E+1);break}}}}J(A,S,U,y,m),z(A,S,U,y,m)}function B(l,v,b,y,m,E){if((0,a.isRef)(l)){P(m,"wrong-type",`Expected a value but found a link ${(0,a.formatRef)(l)}`,[...y]);return}const A=typeof v.eq=="string"?v.eq:void 0;if(A){Q(l,A,b,y,m,E);return}g(l,v,b,y,m,E+1)}function Q(l,v,b,y,m,E){if(v.endsWith("[]")){X(l,v.slice(0,-2),b,y,m,E);return}const A=b.get(v);if(!A){P(m,"invalid-schema",`Unknown type "${v}" in schema`,[...y],l);return}if(Array.isArray(A.eq)){Y(l,A.eq,b,y,m,E);return}g(l,A,b,y,m,E+1)}function X(l,v,b,y,m,E){if(!Array.isArray(l.eq)){P(m,"wrong-type",`Expected ${v}[], got ${R(l.eq)}`,[...y],l);return}for(let A=0;A<l.eq.length;A++){const S=[...y,`[${A}]`],T=l.eq[A];(0,a.isRef)(T)?P(m,"wrong-type",`Expected ${v}, got link ${(0,a.formatRef)(T)}`,S):Q(T,v,b,S,m,E)}}function Y(l,v,b,y,m,E){const A=[];let S,T;for(const L of v){if((0,a.isRef)(L))continue;const D=typeof L.eq=="string"?L.eq:void 0;if(!D)continue;A.push(D);const V=[];if(Q(l,D,b,y,V,E),V.length===0)return;(!S||V.length<S.length)&&(S=V,T=D)}let U=`Value does not match any type in oneOf: [${A.join(", ")}]`;if(S&&S.length>0&&A.length>1){const L=S.map(D=>D.message).join("; ");U+=`. Closest match "${T}": ${L}`}P(m,"wrong-type",U,[...y],l)}function J(l,v,b,y,m){if(!b)return;const E=new Map;function A(S){if(S)for(const[T,U]of Object.entries(S)){if((0,a.isRef)(U))continue;const L=o(U,"EXCLUSIVE");if(!L)continue;let D;if(typeof L.eq=="string")D=[L.eq];else if(Array.isArray(L.eq))D=L.eq.filter(V=>!(0,a.isRef)(V)).map(V=>String(V.eq));else continue;for(const V of D){const r=E.get(V);r?r.push(T):E.set(V,[T])}}}A(l),A(v);for(const[S,T]of E){const U=T.filter(L=>(0,a.getProperty)(b,L)!==void 0);U.length>1&&P(m,"exclusive-violation",`Properties [${U.join(", ")}] are mutually exclusive (group "${S}")`,[...y])}}function z(l,v,b,y,m){if(!b)return;function E(A){if(A)for(const[S,T]of Object.entries(A)){if((0,a.isRef)(T)||(0,a.getProperty)(b,S)===void 0)continue;const U=o(T,"REQUIRES");if(!(!U||!Array.isArray(U.eq)))for(const L of U.eq){if((0,a.isRef)(L))continue;const D=typeof L.eq=="string"?L.eq:void 0;D&&(0,a.getProperty)(b,D)===void 0&&P(m,"requires-violation",`Property "${S}" requires "${D}" to be present`,[...y,S])}}}E(l),E(v)}return pe}var Re;function De(){if(Re)return re;Re=1,Object.defineProperty(re,"__esModule",{value:!0}),re.MOTLYSchema=re.MOTLYResult=re.MOTLYSession=void 0;const a=le(),P=Me(),q=je(),O=Te(),I=$e(),i=Oe();class e{constructor(s){this.accumulated=[],this.nextParseId=0,this.finished=!1,this.disposed=!1,this.options=s??{}}parse(s){if(this.ensureAlive(),this.finished)throw new Error("MOTLYSession is spent after finish() — create a new session");const o=this.nextParseId++;try{const g=(0,P.parse)(s);return this.accumulated.push({stmts:g,parseId:o}),{parseId:o,errors:[]}}catch(g){if((0,a.isMotlyError)(g))return{parseId:o,errors:[g]};throw g}}finish(){if(this.ensureAlive(),this.finished)throw new Error("finish() has already been called on this session");this.finished=!0;const s=[],o={},g=[];for(const{stmts:W,parseId:K}of this.accumulated){const $={parseId:K,options:{disableReferences:this.options.disableReferences}};g.push(...(0,q.flatten)(W,$))}const{splits:d,deps:R}=(0,q.chunk)(g),{order:M}=(0,q.topoSort)(R),N=(0,q.executeChunked)(g,d,M,o,this.options);if(s.push(...N),!this.options.disableReferences){const W=(0,O.validateReferences)(o);for(const K of W)s.push({code:K.code,message:K.message,begin:{line:0,column:0,offset:0},end:{line:0,column:0,offset:0}})}return new t(o,s)}dispose(){this.disposed=!0}ensureAlive(){if(this.disposed)throw new Error("MOTLYSession has been disposed")}}re.MOTLYSession=e;class t{constructor(s,o){this.value=s,this.errors=o}getValue(){return(0,I.cloneNode)(this.value)}getMot(s){return(0,i.buildMot)(this.value,s)}}re.MOTLYResult=t;class n{constructor(s){this.tree=s}static parse(s){const o={disableReferences:!0},g={parseId:0,options:o};try{const d=(0,P.parse)(s),R={},M=(0,q.flatten)(d,g),{splits:N,deps:W}=(0,q.chunk)(M),{order:K}=(0,q.topoSort)(W),$=(0,q.executeChunked)(M,N,K,R,o);return{schema:new n(R),errors:$}}catch(d){if((0,a.isMotlyError)(d))return{schema:new n({}),errors:[d]};throw d}}validate(s){return(0,O.validateSchema)(s,this.tree)}}return re.MOTLYSchema=n,re}var Ee;function Ie(){return Ee||(Ee=1,(function(a){Object.defineProperty(a,"__esModule",{value:!0}),a.MOTLYSchema=a.MOTLYResult=a.MOTLYSession=a.MotValue=a.Mot=a.getProperty=a.formatRef=a.isMotlyError=a.isEnvRef=a.isDataNode=a.isRef=void 0;var P=le();Object.defineProperty(a,"isRef",{enumerable:!0,get:function(){return P.isRef}}),Object.defineProperty(a,"isDataNode",{enumerable:!0,get:function(){return P.isDataNode}}),Object.defineProperty(a,"isEnvRef",{enumerable:!0,get:function(){return P.isEnvRef}}),Object.defineProperty(a,"isMotlyError",{enumerable:!0,get:function(){return P.isMotlyError}}),Object.defineProperty(a,"formatRef",{enumerable:!0,get:function(){return P.formatRef}}),Object.defineProperty(a,"getProperty",{enumerable:!0,get:function(){return P.getProperty}});var q=Oe();Object.defineProperty(a,"Mot",{enumerable:!0,get:function(){return q.Mot}}),Object.defineProperty(a,"MotValue",{enumerable:!0,get:function(){return q.MotValue}});var O=De();Object.defineProperty(a,"MOTLYSession",{enumerable:!0,get:function(){return O.MOTLYSession}}),Object.defineProperty(a,"MOTLYResult",{enumerable:!0,get:function(){return O.MOTLYResult}}),Object.defineProperty(a,"MOTLYSchema",{enumerable:!0,get:function(){return O.MOTLYSchema}})})(ye)),ye}var Se;function Ne(){if(Se)return ue;Se=1;var a={};Object.defineProperty(ue,"__esModule",{value:!0}),ue.TagParser=void 0,ue.parseTag=n,ue.parseAnnotation=h;const P=Ie(),q=xe();function O(s){const o=s.search(/[ \t\r\n]/);return o>0?s.slice(o):""}function I(s){return{code:s.code,message:s.message,line:s.begin.line,offset:s.begin.column}}function i(s,o){const g=o.get(s.parseId);if(g)return{url:g.url,range:{start:{line:g.startLine+s.begin.line,character:s.begin.line===0?g.startColumn+s.begin.column:s.begin.column},end:{line:g.startLine+s.end.line,character:s.end.line===0?g.startColumn+s.end.column:s.end.column}}}}function e(s,o,g){if((0,P.isRef)(s))return new q.Tag({deleted:!0},o);const d=new q.Tag({},o);if(s.location&&g&&(d.location=i(s.location,g)),s.eq!==void 0)if(Array.isArray(s.eq))d.eq=s.eq.map(R=>e(R,d,g));else if((0,P.isEnvRef)(s.eq)){const R=a[s.eq.env];R!==void 0&&(d.eq=R)}else s.eq instanceof Date?d.eq=new Date(s.eq):d.eq=s.eq;if(s.properties!==void 0){const R=d.getProperties();for(const[M,N]of Object.entries(s.properties))R[M]=e(N,d,g)}return s.deleted&&(d.deleted=!0),d}class t{constructor(){this.origins=new Map,this.session=new P.MOTLYSession}parse(o,g){return this.parseSource(o,0,g)}parseAnnotation(o,g){const d=O(o),R=o.length-d.length;return this.parseSource(d,R,g)}parseSource(o,g,d){const{parseId:R,errors:M}=this.session.parse(o);d&&this.origins.set(R,{url:d.url,startLine:d.startLine,startColumn:d.startColumn+g});const N=M.map(I);return{tag:new q.Tag,log:N}}finish(){const g=this.session.finish().getValue();return this.session.dispose(),e(g,void 0,this.origins)}}ue.TagParser=t;function n(s){const o=new t;if(typeof s=="string"){const{log:d}=o.parse(s);return{tag:o.finish(),log:d}}const g=[];for(let d=0;d<s.length;d++){const R=o.parse(s[d]);for(const M of R.log)g.push({...M,line:d+M.line})}return{tag:o.finish(),log:g}}function h(s){const o=new t;if(typeof s=="string"){const{log:d}=o.parseAnnotation(s);return{tag:o.finish(),log:d}}const g=[];for(let d=0;d<s.length;d++){const R=o.parseAnnotation(s[d]);for(const M of R.log)g.push({...M,line:d+M.line})}return{tag:o.finish(),log:g}}return ue}var ge={},_e;function Ue(){if(_e)return ge;_e=1,Object.defineProperty(ge,"__esModule",{value:!0}),ge.parseString=P;var a;(function(q){q[q.Normal=0]="Normal",q[q.ReverseVirgule=1]="ReverseVirgule",q[q.Unicode=2]="Unicode"})(a||(a={}));function P(q,O=""){let I=q.slice(O.length),i=a.Normal;O.length&&(I=I.slice(0,-O.length));let e="",t="";for(const n of I)switch(i){case a.Normal:{n==="\\"?i=a.ReverseVirgule:e+=n;break}case a.ReverseVirgule:{let h=n;if(n==="u"){i=a.Unicode,t="";continue}n==="b"?h="\b":n==="f"?h="\f":n==="n"?h=`
23
+ `:n==="r"?h="\r":n==="t"&&(h=" "),e+=h,i=a.Normal;break}case a.Unicode:"ABCDEFabcdef0123456789".includes(n)?(t+=n,t.length===4&&(e+=String.fromCharCode(parseInt(t,16)),i=a.Normal)):i=a.Normal}return e}return ge}var Ce;function Le(){return Ce||(Ce=1,(function(a){var P=te&&te.__createBinding||(Object.create?(function(e,t,n,h){h===void 0&&(h=n);var s=Object.getOwnPropertyDescriptor(t,n);(!s||("get"in s?!t.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,h,s)}):(function(e,t,n,h){h===void 0&&(h=n),e[h]=t[n]})),q=te&&te.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),O=te&&te.__exportStar||function(e,t){for(var n in e)n!=="default"&&!Object.prototype.hasOwnProperty.call(t,n)&&P(t,e,n)},I=te&&te.__importStar||(function(){var e=function(t){return e=Object.getOwnPropertyNames||function(n){var h=[];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(h[h.length]=s);return h},e(t)};return function(t){if(t&&t.__esModule)return t;var n={};if(t!=null)for(var h=e(t),s=0;s<h.length;s++)h[s]!=="default"&&P(n,t,h[s]);return q(n,t),n}})();Object.defineProperty(a,"__esModule",{value:!0}),a.ParseUtil=a.TagParser=a.parseAnnotation=a.parseTag=void 0,O(xe(),a);var i=Ne();Object.defineProperty(a,"parseTag",{enumerable:!0,get:function(){return i.parseTag}}),Object.defineProperty(a,"parseAnnotation",{enumerable:!0,get:function(){return i.parseAnnotation}}),Object.defineProperty(a,"TagParser",{enumerable:!0,get:function(){return i.TagParser}}),a.ParseUtil=I(Ue())})(te)),te}export{Le as r};
@@ -1 +1 @@
1
- import{aK as Le,aL as Ne}from"./index-BSBGZfIc.js";import{r as Ge}from"./index-CRAwrhYM.js";import{r as $e}from"./index-w_0OQJgZ.js";function qe(r,q){for(var N=0;N<q.length;N++){const w=q[N];if(typeof w!="string"&&!Array.isArray(w)){for(const g in w)if(g!=="default"&&!(g in r)){const l=Object.getOwnPropertyDescriptor(w,g);l&&Object.defineProperty(r,g,l.get?l:{enumerable:!0,get:()=>w[g]})}}}return Object.freeze(Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}))}var $={},V={},Ve;function xe(){return Ve||(Ve=1,(function(r){var q=V&&V.__createBinding||(Object.create?(function(i,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(i,n,s)}):(function(i,e,t,n){n===void 0&&(n=t),i[n]=e[t]})),N=V&&V.__setModuleDefault||(Object.create?(function(i,e){Object.defineProperty(i,"default",{enumerable:!0,value:e})}):function(i,e){i.default=e}),w=V&&V.__importStar||(function(){var i=function(e){return i=Object.getOwnPropertyNames||function(t){var n=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(n[n.length]=s);return n},i(e)};return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=i(e),s=0;s<n.length;s++)n[s]!=="default"&&q(t,e,n[s]);return N(t,e),t}})();Object.defineProperty(r,"__esModule",{value:!0}),r.ASTAnnotationList=r.ASTLimitViewOperation=r.ASTView=r.ASTFilterWithLiteralEquality=r.ASTFilterWithFilterString=r.ASTFilter=r.ASTCalculateViewOperation=r.ASTHavingViewOperation=r.ASTDrillViewOperation=r.ASTWhereViewOperation=r.ASTNestViewOperation=r.ASTFilteredFieldExpression=r.ASTFilterOperationList=r.ASTFilterOperation=r.ASTMovingAverageExpression=r.ASTFieldReferenceList=r.ASTLiteralValueExpression=r.ASTTimeTruncationExpression=r.ASTReferenceExpression=r.ASTExpression=r.ASTField=r.ASTAggregateViewOperation=r.ASTGroupByViewOperation=r.ASTOrderByViewOperation=r.ASTViewOperation=r.ASTViewOperationList=r.ASTSegmentViewDefinition=r.ASTRefinementViewDefinition=r.ASTArrowViewDefinition=r.ASTReferenceViewDefinition=r.ASTReferenceQueryArrowSource=r.ASTReferenceQueryDefinition=r.ASTRefinementQueryDefinition=r.ASTArrowQueryDefinition=r.ASTQueryDefinition=r.ASTQueryArrowSource=r.ASTUnimplemented=r.ASTFilterExpressionLiteralValue=r.ASTTimestampLiteralValue=r.ASTDateLiteralValue=r.ASTBooleanLiteralValue=r.ASTNumberLiteralValue=r.ASTNullLiteralValue=r.ASTStringLiteralValue=r.ASTLiteralValue=r.ASTParameterValue=r.ASTParameterValueList=r.ASTFieldReference=r.ASTReference=r.ASTQuery=void 0,r.ASTAnnotation=void 0;const g=w(Ge()),l=$e(),p=w(Le());class h{constructor(){this.edited=!1}edit(){return this.edited=!0,this._parent&&this._parent.edit(),this}get as(){const e=this;return{Query(){if(e instanceof k)return e;throw new Error("Not an ASTQuery")},Reference(){if(e instanceof c)return e;throw new Error("Not an ASTReference")},ReferenceQueryArrowSource(){if(e instanceof Y)return e;throw new Error("Not an ASTReferenceQueryArrowSource")},ParameterValueList(){if(e instanceof b)return e;throw new Error("Not an ASTParameterValueList")},FilterOperation(){if(e instanceof j)return e;throw new Error("Not an ASTFilterOperation")},FilterOperationList(){if(e instanceof he)return e;throw new Error("Not an ASTFilterOperationList")},ParameterValue(){if(e instanceof H)return e;throw new Error("Not an ASTParameterValue")},StringLiteralValue(){if(e instanceof ae)return e;throw new Error("Not an ASTStringLiteralValue")},NumberLiteralValue(){if(e instanceof oe)return e;throw new Error("Not an ASTNumberLiteralValue")},ViewOperationList(){if(e instanceof de)return e;throw new Error("Not an ASTViewOperationList")},GroupByViewOperation(){if(e instanceof A)return e;throw new Error("Not an ASTGroupByViewOperation")},AggregateViewOperation(){if(e instanceof S)return e;throw new Error("Not an ASTAggregateViewOperation")},OrderByViewOperation(){if(e instanceof F)return e;throw new Error("Not an ASTOrderByViewOperation")},Field(){if(e instanceof x)return e;throw new Error("Not an ASTField")},ReferenceExpression(){if(e instanceof U)return e;throw new Error("Not an ASTReferenceExpression")},ReferenceViewDefinition(){if(e instanceof X)return e;throw new Error("Not an ASTReferenceViewDefinition")},ArrowQueryDefinition(){if(e instanceof y)return e;throw new Error("Not an ASTArrowQueryDefinition")},ArrowViewDefinition(){if(e instanceof Z)return e;throw new Error("Not an ASTArrowViewDefinition")},RefinementViewDefinition(){if(e instanceof _)return e;throw new Error("Not an ASTRefinementViewDefinition")},TimeTruncationExpression(){if(e instanceof ee)return e;throw new Error("Not an ASTTimeTruncationExpression")},FilteredFieldExpression(){if(e instanceof Q)return e;throw new Error("Not an ASTFilteredFieldExpression")},NestViewOperation(){if(e instanceof T)return e;throw new Error("Not an ASTNestViewOperation")},View(){if(e instanceof ie)return e;throw new Error("Not an ASTView")},SegmentViewDefinition(){if(e instanceof O)return e;throw new Error("Not an ASTSegmentViewDefinition")},LimitViewOperation(){if(e instanceof P)return e;throw new Error("Not an ASTLimitViewOperation")},AnnotationList(){if(e instanceof D)return e;throw new Error("Not an ASTAnnotationList")},Annotation(){if(e instanceof W)return e;throw new Error("Not an ASTAnnotation")}}}get find(){const e=this;return{Query(t){return e.findAny(t).as.Query()},Reference(t){return e.findAny(t).as.Reference()},ReferenceQueryArrowSource(t){return e.findAny(t).as.ReferenceQueryArrowSource()},ParameterValueList(t){return e.findAny(t).as.ParameterValueList()},FilterOperation(t){return e.findAny(t).as.FilterOperation()},FilterOperationList(t){return e.findAny(t).as.FilterOperationList()},ParameterValue(t){return e.findAny(t).as.ParameterValue()},StringLiteralValue(t){return e.findAny(t).as.StringLiteralValue()},NumberLiteralValue(t){return e.findAny(t).as.NumberLiteralValue()},ViewOperationList(t){return e.findAny(t).as.ViewOperationList()},GroupByViewOperation(t){return e.findAny(t).as.GroupByViewOperation()},AggregateViewOperation(t){return e.findAny(t).as.AggregateViewOperation()},OrderByViewOperation(t){return e.findAny(t).as.OrderByViewOperation()},Field(t){return e.findAny(t).as.Field()},ReferenceExpression(t){return e.findAny(t).as.ReferenceExpression()},ReferenceViewDefinition(t){return e.findAny(t).as.ReferenceViewDefinition()},ArrowQueryDefinition(t){return e.findAny(t).as.ArrowQueryDefinition()},ArrowViewDefinition(t){return e.findAny(t).as.ArrowViewDefinition()},RefinementViewDefinition(t){return e.findAny(t).as.RefinementViewDefinition()},TimeTruncationExpression(t){return e.findAny(t).as.TimeTruncationExpression()},FilteredFieldExpression(t){return e.findAny(t).as.FilteredFieldExpression()},NestViewOperation(t){return e.findAny(t).as.NestViewOperation()},View(t){return e.findAny(t).as.View()},SegmentViewDefinition(t){return e.findAny(t).as.SegmentViewDefinition()},LimitViewOperation(t){return e.findAny(t).as.LimitViewOperation()},AnnotationList(t){return e.findAny(t).as.AnnotationList()},Annotation(t){return e.findAny(t).as.Annotation()}}}get parent(){if(this._parent===void 0)throw new Error("This node does not have a parent");return this._parent}set parent(e){this._parent=e}static schemaTryGet(e,t,n){return h._schemaTryGet(e,t,n,!1)}static schemaTryGetDrillField(e,t,n){return h._schemaTryGet(e,t,n,!0)}static _schemaTryGet(e,t,n,s){let a=e.fields;for(const f of n??[]){const u=a.find(m=>m.name===f);if(u===void 0)throw new Error(`${f} not found`);if(u.kind==="join"||s&&u.kind==="view"){a=u.schema.fields;continue}if(u.kind==="dimension"||u.kind==="measure"){if(u.type.kind==="record_type"){a=u.type.fields.map(m=>({kind:u.kind,...m}));continue}else if(u.type.kind==="array_type"&&u.type.element_type.kind==="record_type"){a=u.type.element_type.fields.map(m=>({kind:u.kind,...m}));continue}}throw new Error(`${f} is not a join, record, or repeated record`)}return a.find(f=>f.name===t)}static schemaGet(e,t,n){const s=h.schemaTryGet(e,t,n);if(s===void 0)throw new Error(`${t} not found`);return s}static schemaGetDrillField(e,t,n){const s=h.schemaTryGetDrillField(e,t,n);if(s===void 0)throw new Error(`${t} not found`);return s}static schemaMerge(e,t){return{fields:[...e.fields,...t.fields]}}static tagFor(e,t="# "){var n,s;const a=(s=(n=e.annotations)===null||n===void 0?void 0:n.map(f=>f.value))===null||s===void 0?void 0:s.filter(f=>f.startsWith(t)),o=new l.TagParser;for(const f of a??[])o.parseAnnotation(f);return o.finish()}static fieldWasCalculation(e){if(e.kind!=="dimension")throw new Error(`${e.name} could not be an output field, because it is a ${e.kind}, and only dimensions can appear in output schemas`);return h.tagFor(e,"#(malloy) ").has("calculation")}}function se(i){return Array.isArray(i)||typeof i=="string"||typeof i=="number"||typeof i=="boolean"}class M extends h{constructor(e,t){super(),this.node=e,this.children=t,this.originalChildren=[...t],t.forEach(n=>n.parent=this)}*iter(){for(let e=0;e<this.length;e++)yield this.index(e)}get length(){return this.children.length}get last(){return this.children[this.children.length-1]}index(e){return this.children[e]}insert(e,t){this.edit(),this.children.splice(t,0,e),e.parent=this}add(e){this.edit(),this.children.push(e),e.parent=this}remove(e){const t=this.children.findIndex(n=>n===e);if(t===-1)return this;this.edit(),this.children.splice(t,1)}build(){if(!this.edited)return this.node;const e=this.children.map(t=>t.build());return this.edited=!1,this.originalChildren=[...this.children],this.node=e,e}findAny(e){if(e.length===0)return this;const[t,...n]=e;if(typeof t!="number")throw new Error(`${this.constructor.name} is a ASTListNode and thus cannot contain a ${t}`);return this.children[t].findAny(n)}findIndex(e){return this.children.findIndex(e)}indexOf(e){return this.children.indexOf(e)}}class d extends h{constructor(e,t){super(),this.node=e,this.children=t;for(const n in t){const s=t[n];s&&!se(s)&&(s.parent=this)}}build(){if(!this.edited)return this.node;let e=this.node;for(const t in this.children){const n=this.children[t];n===void 0?e={...e,[t]:void 0}:se(n)?this.edited&&(e={...e,[t]:n}):e={...e,[t]:n.build()}}return this.node=e,this.edited=!1,e}findAny(e){if(e.length===0)return this;const[t,...n]=e;if(typeof t!="string")throw new Error(`${this.constructor.name} is a ASTListNode and thus cannot contain a ${t}`);const s=this.children[t];if(se(s))throw new Error(`${this.constructor.name}.${t} refers to a basic type, not an ASTNode`);return s._find(n)}}class k extends d{constructor(e){var t,n;let s=e.source;if(s===void 0){if(e.model===void 0)throw new Error("Need a model or source");if(e.query){const u=e.query.definition;if(u.kind==="arrow"&&u.source.kind==="source_reference"){const m=u.source.name;if(s=e.model.entries.find(z=>z.name===m),s===void 0)throw new Error(`Model does not contain source or query named ${m}`)}}if(s===void 0&&(s=e.model.entries[0]),s===void 0)throw new Error("Model does not contain any sources or queries")}const a=Re(s),o=(t=e.query)!==null&&t!==void 0?t:{definition:{kind:"arrow",source:{kind:"source_reference",name:a.name},view:{kind:"segment",operations:[]}}},f=(n=e.model)!==null&&n!==void 0?n:{entries:[a],anonymous_queries:[]};super(o,{definition:r.ASTQueryDefinition.from(o.definition),annotations:o.annotations&&new D(o.annotations)}),this.model=f,e.source&&this.setSource(e.source.name)}get definition(){return this.children.definition}set definition(e){this.edit(),this.children.definition=e,e.parent=this}get annotations(){return this.children.annotations}reorderFields(e){this.definition.reorderFields(e)}getOrAddAnnotations(){if(this.annotations)return this.annotations;this.edit();const e=new D([]);return this.children.annotations=e,e.parent=this,e}getInheritedTag(e="# "){return L(e,this.getInheritedAnnotations())}getIntrinsicTag(e="# "){var t,n;return(n=(t=this.annotations)===null||t===void 0?void 0:t.getIntrinsicTag(e))!==null&&n!==void 0?n:new l.Tag}getTag(e="# "){var t,n;return(n=(t=this.annotations)===null||t===void 0?void 0:t.getTag(e))!==null&&n!==void 0?n:this.getInheritedTag(e)}setTagProperty(e,t=null,n="# "){this.getOrAddAnnotations().setTagProperty(e,t,n)}removeTagProperty(e,t="# "){this.getTag().has(...e)&&this.getOrAddAnnotations().removeTagProperty(e,t)}setViewToEmptySegment(){if(!(this.definition instanceof y))throw new Error("Must set source before setting view");return this.definition=new y({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 y&&this.definition.view instanceof O&&this.definition.view.operations.length===0}getOrAddDefaultSegment(){return this.definition.getOrAddDefaultSegment()}setSource(e){if(this.definition instanceof y&&this.definition.source instanceof Y&&this.definition.source.name===e)return;if(this.model.entries.find(n=>n.name===e)===void 0)throw new Error(`Source ${e} is not defined in model`);this.definition=new y({kind:"arrow",source:{kind:"source_reference",name:e},view:this.definition instanceof y?this.definition.view.build():{kind:"segment",operations:[]}})}setQueryHead(e){const t=this.model.entries.find(n=>n.name===e);if(t===void 0||t.kind!=="query")throw new Error(`No query named ${e} in the model`);this.definition=new K({kind:"query_reference",name:e})}getQueryInfo(e){const t=this.model.entries.find(n=>n.name===e);if(t===void 0)throw new Error(`Query ${e} is not defined in model`);if(t.kind!=="query")throw new Error(`Model entry ${e} is not a query`);return t}toMalloy(){return g.queryToMalloy(this.build())}build(){return super.build()}setView(e){if(!(this.definition instanceof y))throw new Error("Must set source before setting view");return this.definition=new y({kind:"arrow",source:this.definition.source.build(),view:{kind:"view_reference",name:e}}),this.definition.view.as.ReferenceViewDefinition()}_getInheritedAnnotations(e){var t;return e instanceof K?(t=this.getQueryInfo(e.name).annotations)!==null&&t!==void 0?t:[]:e instanceof E?this._getInheritedAnnotations(e.base):e instanceof y?e.view.getInheritedAnnotations():[]}getInheritedAnnotations(){return this._getInheritedAnnotations(this.definition)}}r.ASTQuery=k;class c extends d{constructor(e){super(e,{name:e.name,path:e.path,parameters:e.parameters&&new b(e.parameters)}),this.reference=e}get name(){return this.children.name}set name(e){this.edit(),this.children.name=e}get parameters(){return this.children.parameters}set parameters(e){this.edit(),this.children.parameters=e}get path(){return this.children.path}static getOrAddParameters(e){if(e.parameters)return e.parameters;e.edit();const t=new b([]);return e.parameters=t,t}static setParameter(e,t,n){const s=c.tryGetParameter(e,t);if(s!==void 0){s.value=r.ASTLiteralValue.from(r.ASTLiteralValue.makeLiteral(n));return}return e.getOrAddParameters().addParameter(t,n)}static tryGetParameter(e,t){if(e.parameters!==void 0){for(const n of e.parameters.iter())if(n.name===t)return n}}getOrAddParameters(){return c.getOrAddParameters(this)}setParameter(e,t){return c.setParameter(this,e,t)}tryGetParameter(e){return c.tryGetParameter(this,e)}}r.ASTReference=c;class G extends c{get segment(){const e=this.parent;return e instanceof Q||e instanceof ee?e.field.segment:e instanceof ne||e instanceof C?e.segment:e.list.segment}getReferenceSchema(){return this.parent instanceof F?this.segment.getOutputSchema():this.segment.getInputSchema()}getFieldInfo(){const e=this.getReferenceSchema();return h.schemaGet(e,this.name,this.path)}}r.ASTFieldReference=G;class b extends M{constructor(e){super(e,e.map(t=>new H(t)))}get parameters(){return this.children}addParameter(e,t){this.add(new H({name:e,value:r.ASTLiteralValue.makeLiteral(t)}))}}r.ASTParameterValueList=b;class H extends d{constructor(e){super(e,{name:e.name,value:r.ASTLiteralValue.from(e.value)}),this.parameter=e}get name(){return this.children.name}get value(){return this.children.value}set value(e){this.edit(),this.children.value=e}}r.ASTParameterValue=H,r.ASTLiteralValue={from(i){switch(i.kind){case"string_literal":return new ae(i);case"number_literal":return new oe(i);case"boolean_literal":return new ye(i);case"date_literal":return new Ae(i);case"timestamp_literal":return new Te(i);case"null_literal":return new we(i);case"filter_expression_literal":return new Se(i)}},makeLiteral(i){if(i!==null&&typeof i=="object"&&"kind"in i)return i;if(typeof i=="string")return{kind:"string_literal",string_value:i};if(typeof i=="boolean")return{kind:"boolean_literal",boolean_value:i};if(typeof i=="number")return{kind:"number_literal",number_value:i};if(i===null)return{kind:"null_literal"};if("date"in i){const e=i.granularity,t=De(i.date);return Pe(e)?{kind:"date_literal",date_value:t,granularity:e}:{kind:"timestamp_literal",timestamp_value:t,granularity:e}}throw new Error("Unknown literal type")}};class ae extends d{constructor(e){super(e,{kind:e.kind,string_value:e.string_value}),this.node=e,this.kind="string_literal"}get fieldType(){return{kind:"string_type"}}}r.ASTStringLiteralValue=ae;class we extends d{constructor(e){super(e,{kind:e.kind}),this.node=e,this.kind="null_literal"}get fieldType(){}}r.ASTNullLiteralValue=we;class oe extends d{constructor(e){super(e,{kind:e.kind,number_value:e.number_value}),this.node=e,this.kind="number_literal"}get fieldType(){return{kind:"number_type",subtype:Number.isInteger(this.children.number_value)?"integer":"decimal"}}}r.ASTNumberLiteralValue=oe;class ye extends d{constructor(e){super(e,{kind:e.kind,boolean_value:e.boolean_value}),this.node=e,this.kind="boolean_literal"}get fieldType(){return{kind:"boolean_type"}}}r.ASTBooleanLiteralValue=ye;class Ae extends d{constructor(e){super(e,{kind:e.kind,date_value:e.date_value,granularity:e.granularity}),this.node=e,this.kind="date_literal"}get fieldType(){return{kind:"date_type",timeframe:this.children.granularity}}}r.ASTDateLiteralValue=Ae;class Te extends d{constructor(e){super(e,{kind:e.kind,timestamp_value:e.timestamp_value,granularity:e.granularity}),this.node=e,this.kind="timestamp_literal"}get fieldType(){return{kind:"timestamp_type",timeframe:this.children.granularity}}}r.ASTTimestampLiteralValue=Te;class Se extends d{constructor(e){super(e,{kind:e.kind,filter_expression_value:e.filter_expression_value}),this.node=e,this.kind="filter_expression_literal"}get fieldType(){}}r.ASTFilterExpressionLiteralValue=Se;class Ee extends h{constructor(e){super(),this.node=e}get treeEdited(){return!1}build(){return this.node}findAny(){throw new Error("Tried to find a node from an unimplemented node type")}}r.ASTUnimplemented=Ee,r.ASTQueryArrowSource={from(i){switch(i.kind){case"refinement":return new E(i);case"source_reference":return new Y(i)}}},r.ASTQueryDefinition={from(i){switch(i.kind){case"arrow":return new y(i);case"query_reference":return new K(i);case"refinement":return new E(i)}}};class y extends d{constructor(e){super(e,{kind:"arrow",source:r.ASTQueryArrowSource.from(e.source),view:v.from(e.view)}),this.node=e}get view(){return this.children.view}set view(e){this.edit(),this.children.view=e,e.parent=this}get source(){return this.children.source}set source(e){this.edit(),this.children.source=e}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(e){this.propagateDown(e)}propagateDown(e){e(this.view),this.view.propagateDown(e)}reorderFields(e){this.view instanceof O?this.view.reorderFields(e):this.query.getOrAddAnnotations().setTagProperty(["field_order"],e)}}r.ASTArrowQueryDefinition=y;class E extends d{constructor(e){super(e,{kind:"refinement",base:r.ASTQueryDefinition.from(e.base),refinement:v.from(e.refinement)}),this.node=e}get base(){return this.children.base}get refinement(){return this.children.refinement}set refinement(e){this.edit(),this.children.refinement=e,e.parent=this}isRunnable(){return!0}get query(){return this.parent.as.Query()}getOrAddDefaultSegment(){return this.refinement.getOrAddDefaultSegment()}getOutputSchema(){const e=this.base.getOutputSchema(),t=this.refinement.getRefinementSchema();return k.schemaMerge(e,t)}propagateUp(e){this.propagateDown(e)}propagateDown(e){e(this.refinement),this.refinement.propagateDown(e)}reorderFields(e){this.query.getOrAddAnnotations().setTagProperty(["field_order"],e)}getSourceInfo(){return this.base.getSourceInfo()}}r.ASTRefinementQueryDefinition=E;class K extends d{constructor(e){super(e,{kind:"query_reference",name:e.name,path:e.path,parameters:e.parameters&&new b(e.parameters)}),this.node=e}isRunnable(){return!0}get name(){return this.children.name}get query(){return this.parent.as.Query()}get parameters(){return this.children.parameters}set parameters(e){this.edit(),this.children.parameters=e}get path(){return this.children.path}getOrAddDefaultSegment(){const e=new E({kind:"refinement",base:this.build(),refinement:{kind:"segment",operations:[]}});return this.query.definition=e,e.refinement.as.SegmentViewDefinition()}propagateUp(e){}propagateDown(e){}reorderFields(e){this.query.getOrAddAnnotations().setTagProperty(["field_order"],e)}getOrAddParameters(){return c.getOrAddParameters(this)}setParameter(e,t){return c.setParameter(this,e,t)}tryGetParameter(e){return c.tryGetParameter(this,e)}getOutputSchema(){return this.getSourceInfo().schema}getSourceInfo(){const t=this.query.model.entries.find(n=>n.name===this.name);if(t===void 0)throw new Error(`Query not found with name ${this.name}`);return t}}r.ASTReferenceQueryDefinition=K;class Y extends d{constructor(e){super(e,{kind:"source_reference",name:e.name,path:e.path,parameters:e.parameters&&new b(e.parameters)}),this.node=e}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(e){this.edit(),this.children.parameters=e}get path(){return this.children.path}getSourceInfo(){const e=this.arrow.query.model.entries.find(t=>t.name===this.name);if(e===void 0)throw new Error(`No query or source named ${this.name}`);return e}getOrAddDefaultSegment(){if(this.getSourceInfo().kind!=="query")throw new Error(`Cannot refine source ${this.name}`);const t=new E({kind:"refinement",base:{...this.build(),kind:"query_reference"},refinement:{kind:"segment",operations:[]}});return this.arrow.source=t,t.refinement.as.SegmentViewDefinition()}propagateUp(e){}propagateDown(e){}getOrAddParameters(){return c.getOrAddParameters(this)}setParameter(e,t){return c.setParameter(this,e,t)}tryGetParameter(e){return c.tryGetParameter(this,e)}get query(){return this.parent.parent.as.Query()}getSourceParameters(){var e;const t=this.getSourceInfo();return t.kind==="query"?[]:(e=t.parameters)!==null&&e!==void 0?e:[]}areRequiredParametersSet(){const e=this.getSourceParameters();for(const t of e){if(t.default_value!==void 0)continue;if(this.tryGetParameter(t.name)===void 0)return!1}return!0}}r.ASTReferenceQueryArrowSource=Y;const v={from(i){switch(i.kind){case"arrow":return new Z(i);case"view_reference":return new X(i);case"segment":return new O(i);case"refinement":return new _(i)}}};function I(i,e){const t=i.parent;t instanceof y?t.view=e:t instanceof E?t.refinement=e:t instanceof ie?t.definition=e:t instanceof Z?t.source===i?t.source=e:t.view=e:t.base===i?t.base=e:t.refinement=e}function J(i,e,t=[]){const n=i.getInputSchema(),s=k.schemaGet(n,e,t);if(s===void 0)return{isValidViewRefinement:!1,error:`${e} is not defined`};if(s.kind!=="view")return{isValidViewRefinement:!1,error:`${e} is not a view`};const a=i.getOutputSchema();for(const o of s.schema.fields)if(k.schemaTryGet(a,o.name,[]))return{isValidViewRefinement:!1,error:`Cannot refine with ${e} because stage already has an output field named ${o.name}`};return{isValidViewRefinement:!0}}class X extends d{constructor(e){super(e,{kind:"view_reference",name:e.name,path:e.path,parameters:e.parameters&&new b(e.parameters)}),this.node=e}isRunnable(){return!0}get name(){return this.children.name}get path(){return this.children.path}get parameters(){return this.children.parameters}set parameters(e){this.edit(),this.children.parameters=e}getOrAddDefaultSegment(){return this.addEmptyRefinement()}addEmptyRefinement(){const e=_.segmentRefinementOf(this.build());return I(this,e),e.refinement.as.SegmentViewDefinition()}addViewRefinement(e,t){const{error:n}=this.isValidViewRefinement(e,t);if(n)throw new Error(n);const s=_.viewRefinementOf(this.build(),e,t);return I(this,s),s.refinement.as.ReferenceViewDefinition()}convertToNest(e){const t=v.from({kind:"segment",operations:[{kind:"nest",name:e,view:{definition:this.build()}}]});I(this,t)}isValidViewRefinement(e,t){return J(this,e,t)}getInputSchema(){return pe(this.parent)}getOutputSchema(){return this.parent.getOutputSchema()}getImplicitName(){return this.name}getViewInfo(){const e=this.getInputSchema(),t=h.schemaGet(e,this.name,this.path);if(t.kind!=="view")throw new Error("Not a view");return t}getRefinementSchema(){return this.getViewInfo().schema}propagateUp(e){this.parent.propagateUp(e)}propagateDown(e){}getInheritedAnnotations(){var e;return(e=this.getViewInfo().annotations)!==null&&e!==void 0?e:[]}getOrAddParameters(){return c.getOrAddParameters(this)}setParameter(e,t){return c.setParameter(this,e,t)}tryGetParameter(e){return c.tryGetParameter(this,e)}}r.ASTReferenceViewDefinition=X;class Z extends d{constructor(e){super(e,{kind:"arrow",source:v.from(e.source),view:v.from(e.view)}),this.node=e}isRunnable(){return this.source.isRunnable()&&this.view.isRunnable()}get source(){return this.children.source}set source(e){this.edit(),this.children.source=e}get view(){return this.children.view}set view(e){this.edit(),this.children.view=e,e.parent=this}getOrAddDefaultSegment(){return this.view.getOrAddDefaultSegment()}addEmptyRefinement(){return this.view.addEmptyRefinement()}addViewRefinement(e,t){return this.view.addViewRefinement(e,t)}convertToNest(e){const t=v.from({kind:"segment",operations:[{kind:"nest",name:e,view:{definition:this.build()}}]});I(this,t)}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(e,t){return J(this,e,t)}propagateUp(e){this.propagateDown(e)}propagateDown(e){e(this.view),this.view.propagateDown(e)}getInheritedAnnotations(){return[]}}r.ASTArrowViewDefinition=Z;class _ extends d{constructor(e){super(e,{kind:"refinement",base:v.from(e.base),refinement:v.from(e.refinement)}),this.node=e}isRunnable(){return this.getOutputSchema().fields.length>0}get refinement(){return this.children.refinement}set refinement(e){this.edit(),this.children.refinement=e,e.parent=this}get base(){return this.children.base}set base(e){this.edit(),this.children.base=e}convertToNest(e){const t=v.from({kind:"segment",operations:[{kind:"nest",name:e,view:{definition:this.build()}}]});I(this,t)}getOrAddDefaultSegment(){return this.refinement.getOrAddDefaultSegment()}addEmptyRefinement(){return this.refinement.addEmptyRefinement()}addViewRefinement(e,t){return this.refinement.addViewRefinement(e,t)}getInputSchema(){return pe(this.parent)}getOutputSchema(){return this.parent.getOutputSchema()}getRefinementSchema(){return h.schemaMerge(this.base.getRefinementSchema(),this.refinement.getRefinementSchema())}getImplicitName(){return this.base.getImplicitName()}isValidViewRefinement(e,t){return J(this,e,t)}propagateUp(e){this.parent.propagateUp(e)}propagateDown(e){e(this.base),e(this.refinement),this.base.propagateDown(e),this.refinement.propagateDown(e)}getInheritedAnnotations(){return this.base.getInheritedAnnotations()}static viewRefinementOf(e,t,n){return new _({kind:"refinement",base:e,refinement:{kind:"view_reference",name:t,path:n}})}static segmentRefinementOf(e){return new _({kind:"refinement",base:e,refinement:{kind:"segment",operations:[]}})}}r.ASTRefinementViewDefinition=_;class O extends d{constructor(e){super(e,{kind:"segment",operations:new de(e.operations)}),this.node=e,this.DEFAULT_INSERTION_ORDER=["group_by","aggregate","drill","where","having","nest","order_by","calculate","limit"]}isRunnable(){let e=!1;for(const t of this.operations.iter()){if(t instanceof S||t instanceof A)return!0;if(t instanceof T){if(!t.view.definition.isRunnable())return!1;e=!0}}return e}get operations(){return this.children.operations}convertToNest(e){const t=v.from({kind:"segment",operations:[{kind:"nest",name:e,view:{definition:this.build()}}]});I(this,t)}renameOrderBys(e,t){for(const n of this.operations.iter())n instanceof F&&n.name===e&&n.setField(t)}propagateUp(e){this.parent.propagateUp(e)}propagateDown(e){}removeOrderBys(e){for(const t of this.operations.iter())t instanceof F&&t.name===e&&t.delete()}reorderFields(e){const t=[],n=[],s={};let a=!1;for(const u of this.operations.iter()){if((u instanceof S||u instanceof A||u instanceof T)&&e.includes(u.name)){s[u.name]=u,a=!0;continue}a?n.push(u):t.push(u)}const o=[];for(const u of e){const m=s[u];if(m===void 0)throw new Error(`No field named ${u}`);o.push(m)}const f=[...t,...o,...n];this.operations.items=f}renameField(e,t){if(e.name===t)return;const n=this.getOutputSchema();if(h.schemaTryGet(n,t,[]))throw new Error(`Output already has a field named ${t}`);const s=e.name;e.name=t,this.propagateUp(a=>{a instanceof O&&a.renameOrderBys(s,t)})}addOrderBy(e,t){const n=this.getOutputSchema();try{h.schemaGet(n,e,[])}catch{throw new Error(`No such field ${e} in stage output`)}for(const a of this.operations.iter())if(a instanceof F&&a.name===e)return a.direction=t,a;const s=new F({kind:"order_by",field_reference:{name:e},direction:t});return this.addOperation(s),s}addEmptyNest(e){const t=new T({kind:"nest",name:e,view:{definition:{kind:"segment",operations:[]}}});return this.addOperation(t),t}firstIndexOfOperationType(e){return this.operations.findIndex(t=>t.kind===e)}findInsertionPoint(e){const t=this.firstIndexOfOperationType(e);if(t>-1){let a=t;for(;this.operations.index(a)&&this.operations.index(a).kind===e;)a++;return a}const n=this.DEFAULT_INSERTION_ORDER.indexOf(e);if(n===-1)throw new Error(`Operation ${e} is not supported for \`findInsertionPoint\``);const s=this.DEFAULT_INSERTION_ORDER.slice(n+1);for(const a of s){const o=this.firstIndexOfOperationType(a);if(o>-1)return o}return this.operations.length}getFieldNamed(e){const t=this.tryGetFieldNamed(e);if(t===void 0)throw new Error("No such field");return t}hasFieldNamed(e){return this.tryGetFieldNamed(e)!==void 0}hasField(e,t){return this.tryGetField(e,t)!==void 0}getField(e,t){const n=this.tryGetField(e,t);if(n===void 0)throw new Error("No such field");return n}tryGetField(e,t){for(const n of this.operations.iter())if(n instanceof A||n instanceof S){const s=n.field.getReference();if(s&&s.name===e&&_e(s.path,t))return n}else if(n instanceof T){if(n.view instanceof X)return n}else if(n instanceof R){const s=n.expression.field.getReference();if(s&&s.name===e&&_e(s.path,t))return n}}tryGetFieldNamed(e){for(const t of this.operations.iter())if((t instanceof A||t instanceof S||t instanceof T||t instanceof R)&&t.name===e)return t}getGroupBy(e){for(const t of this.operations.iter())if(t instanceof A&&t.name===e)return t}removeGroupBy(e){var t;return(t=this.getGroupBy(e))===null||t===void 0||t.delete(),this}addGroupBy(e,t=[],n){const s=this.makeField(e,t,n,"dimension");return this.addOperation(s),s}addDrill(e){const t=new te({kind:"drill",...e});return this.addOperation(t),t}addWhere(e,t,n){const s=Array.isArray(t)?t:[],a=n===void 0?t:n,o=typeof a=="string"?a:re(a),f=this.getInputSchema(),u=k.schemaGet(f,e,s);ge(u,a);const m=new fe({kind:"where",filter:{kind:"filter_string",expression:{kind:"field_reference",name:e,path:s},filter:o}});return this.addOperation(m),m}addHaving(e,t,n){const s=Array.isArray(t)?t:[],a=n===void 0?t:n,o=typeof a=="string"?a:re(a),f=this.getInputSchema(),u=k.schemaGet(f,e,s);ge(u,a);const m=new ce({kind:"having",filter:{kind:"filter_string",expression:{kind:"field_reference",name:e,path:s},filter:o}});return this.addOperation(m),m}addCalculateMovingAverage(e,t,n,s,a){const o=new R({kind:"calculate",name:e,field:{expression:{kind:"moving_average",field_reference:{name:t,path:n},rows_preceding:s,rows_following:a}}});return this.addOperation(o),o}addTimeGroupBy(e,t,n,s){const a=this.getInputSchema(),o=h.schemaGet(a,e,t);if(o===void 0)throw new Error(`No such field ${e}`);if(o.kind!=="dimension")throw new Error(`Cannot group by non-dimension ${e}`);if(o.type.kind!==s)throw new Error(`${e} is not a ${s}`);const f=new A({kind:"group_by",field:{expression:{kind:"time_truncation",field_reference:{name:e,path:t},truncation:n}}});return this.addOperation(f),f}addDateGroupBy(e,t,n){const s=n===void 0?t:n,a=n===void 0?[]:t;return this.addTimeGroupBy(e,a,s,"date_type")}addTimestampGroupBy(e,t,n){const s=n===void 0?t:n,a=n===void 0?[]:t;return this.addTimeGroupBy(e,a,s,"timestamp_type")}addTimestamptzGroupBy(e,t,n){const s=n===void 0?t:n,a=n===void 0?[]:t;return this.addTimeGroupBy(e,a,s,"timestamptz_type")}addAggregate(e,t=[],n){const s=this.makeField(e,t,n,"measure");return this.addOperation(s),s}addNest(e,t){const n=this.makeField(e,[],t,"view");return this.addOperation(n),n}makeField(e,t,n,s){const a=this.getInputSchema(),o=h.schemaGet(a,e,t);if(o===void 0)throw new Error(`No such field ${e}`);if(o.kind!==s){const f=Fe(s),u=s;throw new Error(`Cannot ${f} non-${u} ${e}`)}return s==="dimension"?A.fromReference(e,t,n):s==="measure"?S.fromReference(e,t,n):T.fromReference(e,t,n)}addOperation(e){if((e instanceof A||e instanceof S||e instanceof T||e instanceof R)&&this.hasFieldNamed(e.name))throw new Error(`Query already has a field named ${e.name}`);const t=this.findInsertionPoint(e.kind);return this.operations.insert(e,t),e}getRefinementSchema(){const e=[];for(const t of this.operations.iter())(t instanceof A||t instanceof S||t instanceof T||t instanceof R)&&e.push(t.getFieldInfo());return{fields:e}}setLimit(e){P.validateLimit(e);const t=[...this.operations.iter()].find(r.ASTViewOperation.isLimit);t?t.limit=e:this.operations.add(new P({kind:"limit",limit:e}))}getOrAddDefaultSegment(){return this}addEmptyRefinement(){const e=_.segmentRefinementOf(this.build());return I(this,e),e.refinement.as.SegmentViewDefinition()}addViewRefinement(e,t){const{error:n}=this.isValidViewRefinement(e,t);if(n)throw new Error(n);const s=_.viewRefinementOf(this.build(),e,t);return I(this,s),s.refinement.as.ReferenceViewDefinition()}getInputSchema(){return pe(this.parent)}getOutputSchema(){return this.parent.getOutputSchema()}getImplicitName(){}isValidViewRefinement(e,t){return J(this,e,t)}getInheritedAnnotations(){return[]}}r.ASTSegmentViewDefinition=O;class de extends M{constructor(e){super(e,e.map(t=>r.ASTViewOperation.from(t)))}get items(){return this.children}set items(e){this.edit(),this.children=e}get segment(){return this.parent.as.SegmentViewDefinition()}}r.ASTViewOperationList=de,r.ASTViewOperation={from(i){switch(i.kind){case"group_by":return new A(i);case"aggregate":return new S(i);case"order_by":return new F(i);case"nest":return new T(i);case"limit":return new P(i);case"where":return new fe(i);case"drill":return new te(i);case"having":return new ce(i);case"calculate":return new R(i)}},isLimit(i){return i instanceof P}};class F extends d{constructor(e){super(e,{kind:"order_by",field_reference:new G(e.field_reference),direction:e.direction}),this.node=e,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(e){this.direction!==e&&(this.edit(),this.children.direction=e)}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this)}setField(e){const t=this.list.segment.getOutputSchema();h.schemaGet(t,e,[]),this.edit(),this.children.field_reference=new G({name:e})}setDirection(e){this.direction=e}}r.ASTOrderByViewOperation=F;class A extends d{constructor(e){super(e,{kind:"group_by",name:e.name,field:new x(e.field)}),this.node=e,this.kind="group_by"}get field(){return this.children.field}get name(){var e;const t=(e=this.children.name)!==null&&e!==void 0?e:this.field.name;if(t===void 0)throw new Error("Group by does not have a name");return t}set name(e){this.name!==e&&(this.edit(),this.field.name===e?this.children.name=void 0:this.children.name=e)}get list(){return this.parent.as.ViewOperationList()}rename(e){this.list.segment.renameField(this,e)}delete(){this.list.remove(this),this.list.segment.propagateUp(e=>{e instanceof O&&e.removeOrderBys(this.name)})}getFieldInfo(){return{kind:"dimension",name:this.name,type:this.field.type}}get annotations(){return this.field.annotations}set annotations(e){this.edit(),this.field.annotations=e}getOrAddAnnotations(){return this.field.getOrAddAnnotations()}getInheritedTag(e="# "){return L(e,this.field.getInheritedAnnotations())}getIntrinsicTag(e="# "){var t,n;return(n=(t=this.annotations)===null||t===void 0?void 0:t.getIntrinsicTag(e))!==null&&n!==void 0?n:new l.Tag}getTag(e="# "){var t,n;return(n=(t=this.annotations)===null||t===void 0?void 0:t.getTag(e))!==null&&n!==void 0?n:this.getInheritedTag(e)}setTagProperty(e,t=null,n="# "){this.getOrAddAnnotations().setTagProperty(e,t,n)}removeTagProperty(e,t="# "){this.getTag().has(...e)&&this.getOrAddAnnotations().removeTagProperty(e,t)}static fromReference(e,t,n){return new A({kind:"group_by",name:n,field:{expression:{kind:"field_reference",name:e,path:t}}})}}r.ASTGroupByViewOperation=A;class S extends d{constructor(e){super(e,{kind:"aggregate",name:e.name,field:new x(e.field)}),this.node=e,this.kind="aggregate"}get field(){return this.children.field}get name(){var e;const t=(e=this.children.name)!==null&&e!==void 0?e:this.field.name;if(t===void 0)throw new Error("Aggregate does not have a name");return t}set name(e){this.name!==e&&(this.edit(),this.field.name===e?this.children.name=void 0:this.children.name=e)}get annotations(){return this.field.annotations}rename(e){this.list.segment.renameField(this,e)}convertToCalculateMovingAverage(e,t,n=0,s=[]){if(!(this.field.expression instanceof U))throw new Error("Cannot convert aggregate to smoothed metric unless it is a field reference");this.list.remove(this);const a=new R({kind:"calculate",name:e,field:{expression:{kind:"moving_average",field_reference:{name:this.field.expression.name,path:this.field.expression.path},rows_preceding:t,rows_following:n,partition_fields:s.map(o=>({name:o}))}}});return this.list.add(a),a}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this),this.list.segment.propagateUp(e=>{e instanceof O&&e.removeOrderBys(this.name)})}getFieldInfo(){return{annotations:[{value:l.Tag.withPrefix("#(malloy) ").set(["calculation"]).toString()}],kind:"dimension",name:this.name,type:this.field.type}}getOrAddAnnotations(){return this.field.getOrAddAnnotations()}getInheritedTag(e="# "){return L(e,this.field.getInheritedAnnotations())}getIntrinsicTag(e="# "){var t,n;return(n=(t=this.annotations)===null||t===void 0?void 0:t.getIntrinsicTag(e))!==null&&n!==void 0?n:new l.Tag}getTag(e="# "){var t,n;return(n=(t=this.annotations)===null||t===void 0?void 0:t.getTag(e))!==null&&n!==void 0?n:this.getInheritedTag(e)}setTagProperty(e,t=null,n="# "){this.getOrAddAnnotations().setTagProperty(e,t,n)}removeTagProperty(e,t="# "){this.getTag().has(...e)&&this.getOrAddAnnotations().removeTagProperty(e,t)}addWhere(e,t,n){const s=Array.isArray(t)?t:[],a=n===void 0?t:n,o=typeof a=="string"?a:re(a),f=this.list.segment.getInputSchema(),u=k.schemaGet(f,e,s);ge(u,a);const m={filter:{kind:"filter_string",expression:{kind:"field_reference",name:e,path:s},filter:o}};if(this.field.expression instanceof Q)return this.field.expression.where.add(new j(m)),this.field.expression;if(this.field.expression instanceof U){const z=this.field.expression.build();return this.field.expression=new Q({kind:"filtered_field",field_reference:{name:z.name,path:z.path,parameters:z.parameters},where:[m]}),this.field.expression}else throw new Error("This kind of expression does not support addWhere")}static fromReference(e,t,n){return new S({kind:"aggregate",name:n,field:{expression:{kind:"field_reference",name:e,path:t}}})}}r.ASTAggregateViewOperation=S;class x extends d{constructor(e){super(e,{expression:r.ASTExpression.from(e.expression),annotations:e.annotations&&new D(e.annotations)}),this.node=e}get expression(){return this.children.expression}set expression(e){this.edit(),this.children.expression=e,e.parent=this}get name(){return this.expression.name}get type(){const e=this.expression.fieldType;if(e===void 0)throw new Error("Field expression does not have a type");return e}get annotations(){return this.children.annotations}set annotations(e){this.edit(),this.children.annotations=e}getReference(){if(!(this.expression instanceof ue))return this.expression.getReference()}getOrAddAnnotations(){if(this.annotations)return this.annotations;this.edit();const e=new D([]);return this.children.annotations=e,e.parent=this,e}getInheritedTag(e="# "){return L(e,this.getInheritedAnnotations())}getIntrinsicTag(e="# "){var t,n;return(n=(t=this.annotations)===null||t===void 0?void 0:t.getIntrinsicTag(e))!==null&&n!==void 0?n:new l.Tag}getTag(e="# "){var t,n;return(n=(t=this.annotations)===null||t===void 0?void 0:t.getTag(e))!==null&&n!==void 0?n:this.getInheritedTag(e)}setTagProperty(e,t=null,n="# "){this.getOrAddAnnotations().setTagProperty(e,t,n)}removeTagProperty(e,t="# "){this.getTag().has(...e)&&this.getOrAddAnnotations().removeTagProperty(e,t)}get segment(){return this.parent.list.segment}getInheritedAnnotations(){return this.expression.getInheritedAnnotations()}}r.ASTField=x,r.ASTExpression={from(i){switch(i.kind){case"field_reference":return new U(i);case"filtered_field":return new Q(i);case"time_truncation":return new ee(i);case"literal_value":return new ue(i);case"moving_average":return new ve(i)}}};class U extends d{constructor(e){super(e,{kind:e.kind,name:e.name,path:e.path,parameters:e.parameters&&new b(e.parameters)}),this.node=e,this.kind="field_reference"}get name(){return this.children.name}get parameters(){return this.children.parameters}set parameters(e){this.edit(),this.children.parameters=e}get segment(){const e=this.parent;if(e instanceof x)return e.segment;if(e instanceof ne||e instanceof C)return e.segment;throw new Error("Invalid expression parent")}get path(){return this.children.path}getReference(){return this.build()}getFieldInfo(){const e=this.segment.getInputSchema(),n=this.parent instanceof C&&this.parent.parent instanceof te?h.schemaGetDrillField(e,this.name,this.path):h.schemaGet(e,this.name,this.path);if(n.kind!=="dimension"&&n.kind!=="measure")throw new Error("Invalid field for ASTReferenceExpression");return n}get fieldType(){return this.getFieldInfo().type}getInheritedAnnotations(){var e;return(e=this.getFieldInfo().annotations)!==null&&e!==void 0?e:[]}getOrAddParameters(){return c.getOrAddParameters(this)}setParameter(e,t){return c.setParameter(this,e,t)}tryGetParameter(e){return c.tryGetParameter(this,e)}}r.ASTReferenceExpression=U;class ee extends d{constructor(e){super(e,{kind:e.kind,field_reference:new G(e.field_reference),truncation:e.truncation}),this.node=e,this.kind="time_truncation"}getReference(){return this.fieldReference.build()}get fieldReference(){return this.children.field_reference}get truncation(){return this.children.truncation}set truncation(e){this.edit(),this.children.truncation=e}get name(){return this.fieldReference.name}get field(){return this.parent.as.Field()}getFieldInfo(){const e=this.field.segment.getInputSchema(),t=h.schemaGet(e,this.name,this.fieldReference.path);if(t.kind!=="dimension"&&t.kind!=="measure")throw new Error("Invalid field for ASTReferenceExpression");return t}get fieldType(){const e=this.getFieldInfo();if(e.type.kind==="date_type")return{...e.type,timeframe:Ie(this.truncation)};if(e.type.kind==="timestamp_type"||e.type.kind==="timestamptz_type")return{...e.type,timeframe:this.truncation};throw new Error("This type of field cannot have a time truncation")}getInheritedAnnotations(){var e;return(e=this.getFieldInfo().annotations)!==null&&e!==void 0?e:[]}}r.ASTTimeTruncationExpression=ee;class ue extends d{constructor(e){super(e,{kind:e.kind,literal_value:r.ASTLiteralValue.from(e.literal_value)}),this.node=e,this.kind="time_truncation"}get name(){}get literalValue(){return this.children.literal_value}get fieldType(){return this.literalValue.fieldType}getInheritedAnnotations(){return[]}getFieldInfo(){}}r.ASTLiteralValueExpression=ue;class le extends M{constructor(e){super(e,e.map(t=>new G(t)))}}r.ASTFieldReferenceList=le;class ve extends d{constructor(e){super(e,{kind:e.kind,field_reference:new G(e.field_reference),rows_preceding:e.rows_preceding,rows_following:e.rows_following,partition_fields:new le(e.partition_fields||[])}),this.node=e,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(e){this.edit(),this.children.rows_preceding=e}get rowsFollowing(){return this.children.rows_following}set rowsFollowing(e){this.edit(),this.children.rows_following=e}get name(){return this.fieldReference.name}get field(){return this.parent.as.Field()}get partitionFields(){return this.children.partition_fields}setPartitionFields(e){this.children.partition_fields=new le(e)}getFieldInfo(){const e=this.field.segment.getInputSchema(),t=h.schemaGet(e,this.name,this.fieldReference.path);if(t.kind!=="dimension"&&t.kind!=="measure")throw new Error("Invalid field for ASTReferenceExpression");return t}get fieldType(){return this.getFieldInfo().type}getInheritedAnnotations(){var e;return(e=this.getFieldInfo().annotations)!==null&&e!==void 0?e:[]}}r.ASTMovingAverageExpression=ve;class j extends d{constructor(e){super(e,{filter:r.ASTFilter.from(e.filter)})}get filter(){return this.children.filter}get list(){return this.parent.as.FilterOperationList()}delete(){this.list.remove(this)}}r.ASTFilterOperation=j;class he extends M{constructor(e){super(e,e.map(t=>new j(t)))}get expression(){return this.parent.as.FilteredFieldExpression()}}r.ASTFilterOperationList=he;class Q extends d{constructor(e){super(e,{kind:e.kind,field_reference:new G(e.field_reference),where:new he(e.where)}),this.node=e,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 e=this.field.segment.getInputSchema(),t=h.schemaGet(e,this.name,this.fieldReference.path);if(t.kind!=="measure")throw new Error("Invalid field for ASTFilteredFieldExpression");return t}get fieldType(){return this.getFieldInfo().type}getInheritedAnnotations(){var e;return(e=this.getFieldInfo().annotations)!==null&&e!==void 0?e:[]}}r.ASTFilteredFieldExpression=Q;function Ie(i){switch(i){case"day":case"week":case"month":case"year":case"quarter":return i;default:throw new Error("Invalid date timeframe")}}class T extends d{constructor(e){super(e,{kind:"nest",name:e.name,view:new ie(e.view)}),this.node=e,this.kind="nest"}get view(){return this.children.view}get annotations(){return this.view.annotations}get name(){var e;const t=(e=this.children.name)!==null&&e!==void 0?e:this.view.name;if(t===void 0)throw new Error("Nest does not have a name");return t}set name(e){this.name!==e&&(this.edit(),this.view.name===e?this.children.name=void 0:this.children.name=e)}get list(){return this.parent.as.ViewOperationList()}getOrAddAnnotations(){return this.view.getOrAddAnnotations()}getInheritedTag(e="# "){return L(e,this.view.getInheritedAnnotations())}getIntrinsicTag(e="# "){var t,n;return(n=(t=this.annotations)===null||t===void 0?void 0:t.getIntrinsicTag(e))!==null&&n!==void 0?n:new l.Tag}getTag(e="# "){var t,n;return(n=(t=this.annotations)===null||t===void 0?void 0:t.getTag(e))!==null&&n!==void 0?n:this.getInheritedTag(e)}setTagProperty(e,t=null,n="# "){this.getOrAddAnnotations().setTagProperty(e,t,n)}removeTagProperty(e,t="# "){this.getTag().has(...e)&&this.getOrAddAnnotations().removeTagProperty(e,t)}delete(){this.list.remove(this)}rename(e){this.list.segment.renameField(this,e)}getFieldInfo(){return{kind:"view",name:this.name,definition:this.view.build(),schema:this.view.getOutputSchema()}}static fromReference(e,t,n){return new T({kind:"nest",name:n,view:{definition:{kind:"view_reference",name:e,path:t}}})}}r.ASTNestViewOperation=T;class fe extends d{constructor(e){super(e,{kind:"where",filter:r.ASTFilter.from(e.filter)}),this.node=e,this.kind="where"}get filter(){return this.children.filter}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this)}}r.ASTWhereViewOperation=fe;class te extends d{constructor(e){super(e,{kind:"drill",filter:r.ASTFilter.from(e.filter)}),this.node=e,this.kind="drill"}get filter(){return this.children.filter}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this)}}r.ASTDrillViewOperation=te;class ce extends d{constructor(e){super(e,{kind:"having",filter:r.ASTFilter.from(e.filter)}),this.node=e,this.kind="having"}get filter(){return this.children.filter}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this)}}r.ASTHavingViewOperation=ce;class R extends d{constructor(e){super(e,{kind:"calculate",field:new x(e.field),name:e.name}),this.node=e,this.kind="calculate"}get expression(){return this.children.field.expression}set expression(e){this.edit(),this.children.field.expression=e,e.parent=this}get name(){return this.node.name}set name(e){this.name!==e&&(this.edit(),this.node.name=e)}getFieldInfo(){return{annotations:[{value:l.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)}}r.ASTCalculateViewOperation=R,r.ASTFilter={from(i){switch(i.kind){case"filter_string":return new ne(i);case"literal_equality":return new C(i)}},getSegment(i){const e=i.parent;return e instanceof j?e.list.expression.field.segment:e.list.segment}};class ne extends d{constructor(e){super(e,{kind:"filter_string",expression:r.ASTExpression.from(e.expression),filter:e.filter}),this.node=e,this.kind="filter_string"}get expression(){return this.children.expression}get filterString(){return this.children.filter}set filterString(e){this.edit(),this.children.filter=e}setFilterString(e){const t=this.getFilterType();me(this.filterString,t),this.filterString=e}get segment(){return r.ASTFilter.getSegment(this)}getFieldInfo(){const e=this.expression.getFieldInfo();if(e===void 0||e.kind!=="dimension"&&e.kind!=="measure")throw new Error("Invalid field type for filter with filter string");return e}getFilterType(){const e=this.getFieldInfo();return Oe(e)}setFilter(e){const t=this.getFilterType();if(t!==e.kind)throw new Error(`Invalid filter: expected type ${t}, got ${e.kind}`);this.filterString=re(e)}getFilter(){const e=this.getFilterType();return me(this.filterString,e)}}r.ASTFilterWithFilterString=ne;class C extends d{constructor(e){super(e,{kind:"literal_equality",expression:r.ASTExpression.from(e.expression),value:r.ASTLiteralValue.from(e.value)}),this.node=e,this.kind="literal_equality"}get expression(){return this.children.expression}get value(){return this.children.value}get segment(){return r.ASTFilter.getSegment(this)}}r.ASTFilterWithLiteralEquality=C;class ie extends d{constructor(e){super(e,{definition:v.from(e.definition),annotations:e.annotations&&new D(e.annotations)}),this.node=e}get definition(){return this.children.definition}set definition(e){this.edit(),this.children.definition=e,e.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(e){this.propagateDown(e)}propagateDown(e){e(this.definition),this.definition.propagateDown(e)}reorderFields(e){this.definition instanceof O?this.definition.reorderFields(e):this.getOrAddAnnotations().setTagProperty(["field_order"],e)}get annotations(){return this.children.annotations}getOrAddAnnotations(){if(this.annotations)return this.annotations;this.edit();const e=new D([]);return this.children.annotations=e,e.parent=this,e}getInheritedAnnotations(){return this.definition.getInheritedAnnotations()}getInheritedTag(e="# "){return L(e,this.getInheritedAnnotations())}getIntrinsicTag(e="# "){var t,n;return(n=(t=this.annotations)===null||t===void 0?void 0:t.getIntrinsicTag(e))!==null&&n!==void 0?n:new l.Tag}getTag(e="# "){var t,n;return(n=(t=this.annotations)===null||t===void 0?void 0:t.getTag(e))!==null&&n!==void 0?n:this.getInheritedTag(e)}setTagProperty(e,t=null,n="# "){this.getOrAddAnnotations().setTagProperty(e,t,n)}removeTagProperty(e,t="# "){this.getTag().has(...e)&&this.getOrAddAnnotations().removeTagProperty(e,t)}}r.ASTView=ie;class P extends d{get limit(){return this.children.limit}set limit(e){P.validateLimit(e),this.edit(),this.children.limit=e}constructor(e){super(e,{kind:e.kind,limit:e.limit}),this.node=e,this.kind="limit"}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this)}static validateLimit(e){if(!Number.isInteger(e))throw new Error("Limit must be an integer")}}r.ASTLimitViewOperation=P;function Fe(i){switch(i){case"dimension":return"group by";case"measure":return"aggregate";case"view":return"nest";case"join":return"join";case"calculate":return"calculate"}}function Me(i){return i}class D extends M{constructor(e){super(e,e.map(t=>new W(t)))}get items(){return this.children}getInheritedAnnotations(){return this.parent.getInheritedAnnotations()}getIntrinsicTag(e="# "){return L(e,this.items)}getTag(e="# "){return L(e,this.items,this.getInheritedAnnotations())}get annotations(){return this.children.map(e=>e.node)}setTagProperty(e,t=null,n="# "){let s;for(let a=this.items.length-1;a>=0;a--){const o=this.index(a);if(o.hasPrefix(n)&&(s=o,o.hasIntrinsicTagProperty(e))){o.setTagProperty(e,t);return}}s?s.setTagProperty(e,t):this.add(new W({value:new l.Tag({prefix:n}).set(e,t).toString()}))}removeTagProperty(e,t="# "){let n;for(let s=this.items.length-1;s>=0;s--){const a=this.index(s);if(a.hasPrefix(t)&&(n=a,a.hasIntrinsicTagProperty(e))){a.removeTagProperty(e);return}}n?n.removeTagProperty(e):this.add(new W({value:new l.Tag({prefix:t}).unset(...e).toString()}))}}r.ASTAnnotationList=D;class W extends d{get value(){return this.children.value}set value(e){this.edit(),this.children.value=e}constructor(e){super(e,{value:e.value}),this.node=e}get list(){return this.parent.as.AnnotationList()}get index(){return this.list.indexOf(this)}delete(){this.list.remove(this)}getIntrinsicTag(){const e=new l.TagParser;return e.parseAnnotation(this.value),e.finish()}getTag(){const e=new l.TagParser;for(const t of this.list.getInheritedAnnotations())e.parseAnnotation(t.value);for(let t=0;t<=this.index;t++)e.parseAnnotation(this.list.index(t).value);return e.finish()}hasPrefix(e){return this.value.startsWith(e)}hasIntrinsicTagProperty(e){return this.getIntrinsicTag().has(...e)}setTagProperty(e,t){this.value=this.getIntrinsicTag().set(e,t).toString()}removeTagProperty(e){this.value=this.getTag().unset(...e).toString()}}r.ASTAnnotation=W;function L(i,e=[],t=[]){const n=new l.TagParser;for(const a of t)n.parseAnnotation(a.value);const s=e.map(a=>a.value).filter(a=>typeof i=="string"?a.startsWith(i):a.match(i));for(const a of s)n.parseAnnotation(a);return n.finish()}function re(i){switch(i.kind){case"string":return p.StringFilterExpression.unparse(i.parsed);case"number":return p.NumberFilterExpression.unparse(i.parsed);case"boolean":return p.BooleanFilterExpression.unparse(i.parsed);case"timestamp":case"timestamptz":case"date":return p.TemporalFilterExpression.unparse(i.parsed)}}function me(i,e){function t(n){const s=n.filter(a=>a.severity==="error");if(s.length!==0)throw new Error(`Invalid Malloy filter string: ${s[0].message}`)}switch(e){case"string":{const n=p.StringFilterExpression.parse(i);return t(n.log),{kind:e,parsed:n.parsed}}case"number":{const n=p.NumberFilterExpression.parse(i);return t(n.log),{kind:e,parsed:n.parsed}}case"boolean":{const n=p.BooleanFilterExpression.parse(i);return t(n.log),{kind:e,parsed:n.parsed}}case"timestamp":case"timestamptz":case"date":{const n=p.TemporalFilterExpression.parse(i);return t(n.log),{kind:e,parsed:n.parsed}}case"other":throw new Error("Not implemented")}}function Re(i){return"kind"in i?i:{...i,kind:"source"}}function Pe(i){switch(i){case"year":case"quarter":case"month":case"week":case"day":return!0;default:return!1}}function B(i,e){return i.toString().padStart(e,"0")}function De(i){const e=B(i.getUTCFullYear(),4),t=B(i.getUTCMonth()+1,2),n=B(i.getUTCDate(),2),s=B(i.getUTCHours(),2),a=B(i.getUTCMinutes(),2),o=B(i.getUTCSeconds(),2);return`${e}-${t}-${n} ${s}:${a}:${o}`}function _e(i,e){const t=i??[],n=e??[];return t.length===n.length&&t.every((s,a)=>s===n[a])}function Oe(i){switch(i.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 ge(i,e){if(i.kind!=="dimension"&&i.kind!=="measure")throw new Error(`Cannot filter by field of type ${i.kind}`);const t=Oe(i);if(typeof e=="string")me(e,t);else if(e.kind!==t)throw new Error(`Invalid filter for field ${i.name}; expected type ${t}, but got ${e.kind}`)}function pe(i){if(i instanceof y)return i.getSourceInfo().schema;if(i instanceof E)throw new Error("unimplemented");return i.getInputSchema()}})(V)),V}var ke;function Qe(){return ke||(ke=1,(function(r){var q=$&&$.__createBinding||(Object.create?(function(w,g,l,p){p===void 0&&(p=l);var h=Object.getOwnPropertyDescriptor(g,l);(!h||("get"in h?!g.__esModule:h.writable||h.configurable))&&(h={enumerable:!0,get:function(){return g[l]}}),Object.defineProperty(w,p,h)}):(function(w,g,l,p){p===void 0&&(p=l),w[p]=g[l]})),N=$&&$.__exportStar||function(w,g){for(var l in w)l!=="default"&&!Object.prototype.hasOwnProperty.call(g,l)&&q(g,w,l)};Object.defineProperty(r,"__esModule",{value:!0}),N(xe(),r)})($)),$}var be=Qe();const Be=Ne(be),We=qe({__proto__:null,default:Be},[be]);export{be as d,We as i};
1
+ import{aK as Le,aL as Ne}from"./index-TiWjmdoW.js";import{r as Ge}from"./index-CRAwrhYM.js";import{r as $e}from"./index-ByieDZlo.js";function qe(r,q){for(var N=0;N<q.length;N++){const w=q[N];if(typeof w!="string"&&!Array.isArray(w)){for(const g in w)if(g!=="default"&&!(g in r)){const l=Object.getOwnPropertyDescriptor(w,g);l&&Object.defineProperty(r,g,l.get?l:{enumerable:!0,get:()=>w[g]})}}}return Object.freeze(Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}))}var $={},V={},Ve;function xe(){return Ve||(Ve=1,(function(r){var q=V&&V.__createBinding||(Object.create?(function(i,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(i,n,s)}):(function(i,e,t,n){n===void 0&&(n=t),i[n]=e[t]})),N=V&&V.__setModuleDefault||(Object.create?(function(i,e){Object.defineProperty(i,"default",{enumerable:!0,value:e})}):function(i,e){i.default=e}),w=V&&V.__importStar||(function(){var i=function(e){return i=Object.getOwnPropertyNames||function(t){var n=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(n[n.length]=s);return n},i(e)};return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=i(e),s=0;s<n.length;s++)n[s]!=="default"&&q(t,e,n[s]);return N(t,e),t}})();Object.defineProperty(r,"__esModule",{value:!0}),r.ASTAnnotationList=r.ASTLimitViewOperation=r.ASTView=r.ASTFilterWithLiteralEquality=r.ASTFilterWithFilterString=r.ASTFilter=r.ASTCalculateViewOperation=r.ASTHavingViewOperation=r.ASTDrillViewOperation=r.ASTWhereViewOperation=r.ASTNestViewOperation=r.ASTFilteredFieldExpression=r.ASTFilterOperationList=r.ASTFilterOperation=r.ASTMovingAverageExpression=r.ASTFieldReferenceList=r.ASTLiteralValueExpression=r.ASTTimeTruncationExpression=r.ASTReferenceExpression=r.ASTExpression=r.ASTField=r.ASTAggregateViewOperation=r.ASTGroupByViewOperation=r.ASTOrderByViewOperation=r.ASTViewOperation=r.ASTViewOperationList=r.ASTSegmentViewDefinition=r.ASTRefinementViewDefinition=r.ASTArrowViewDefinition=r.ASTReferenceViewDefinition=r.ASTReferenceQueryArrowSource=r.ASTReferenceQueryDefinition=r.ASTRefinementQueryDefinition=r.ASTArrowQueryDefinition=r.ASTQueryDefinition=r.ASTQueryArrowSource=r.ASTUnimplemented=r.ASTFilterExpressionLiteralValue=r.ASTTimestampLiteralValue=r.ASTDateLiteralValue=r.ASTBooleanLiteralValue=r.ASTNumberLiteralValue=r.ASTNullLiteralValue=r.ASTStringLiteralValue=r.ASTLiteralValue=r.ASTParameterValue=r.ASTParameterValueList=r.ASTFieldReference=r.ASTReference=r.ASTQuery=void 0,r.ASTAnnotation=void 0;const g=w(Ge()),l=$e(),p=w(Le());class h{constructor(){this.edited=!1}edit(){return this.edited=!0,this._parent&&this._parent.edit(),this}get as(){const e=this;return{Query(){if(e instanceof k)return e;throw new Error("Not an ASTQuery")},Reference(){if(e instanceof c)return e;throw new Error("Not an ASTReference")},ReferenceQueryArrowSource(){if(e instanceof Y)return e;throw new Error("Not an ASTReferenceQueryArrowSource")},ParameterValueList(){if(e instanceof b)return e;throw new Error("Not an ASTParameterValueList")},FilterOperation(){if(e instanceof j)return e;throw new Error("Not an ASTFilterOperation")},FilterOperationList(){if(e instanceof he)return e;throw new Error("Not an ASTFilterOperationList")},ParameterValue(){if(e instanceof H)return e;throw new Error("Not an ASTParameterValue")},StringLiteralValue(){if(e instanceof ae)return e;throw new Error("Not an ASTStringLiteralValue")},NumberLiteralValue(){if(e instanceof oe)return e;throw new Error("Not an ASTNumberLiteralValue")},ViewOperationList(){if(e instanceof de)return e;throw new Error("Not an ASTViewOperationList")},GroupByViewOperation(){if(e instanceof A)return e;throw new Error("Not an ASTGroupByViewOperation")},AggregateViewOperation(){if(e instanceof S)return e;throw new Error("Not an ASTAggregateViewOperation")},OrderByViewOperation(){if(e instanceof F)return e;throw new Error("Not an ASTOrderByViewOperation")},Field(){if(e instanceof x)return e;throw new Error("Not an ASTField")},ReferenceExpression(){if(e instanceof U)return e;throw new Error("Not an ASTReferenceExpression")},ReferenceViewDefinition(){if(e instanceof X)return e;throw new Error("Not an ASTReferenceViewDefinition")},ArrowQueryDefinition(){if(e instanceof y)return e;throw new Error("Not an ASTArrowQueryDefinition")},ArrowViewDefinition(){if(e instanceof Z)return e;throw new Error("Not an ASTArrowViewDefinition")},RefinementViewDefinition(){if(e instanceof _)return e;throw new Error("Not an ASTRefinementViewDefinition")},TimeTruncationExpression(){if(e instanceof ee)return e;throw new Error("Not an ASTTimeTruncationExpression")},FilteredFieldExpression(){if(e instanceof Q)return e;throw new Error("Not an ASTFilteredFieldExpression")},NestViewOperation(){if(e instanceof T)return e;throw new Error("Not an ASTNestViewOperation")},View(){if(e instanceof ie)return e;throw new Error("Not an ASTView")},SegmentViewDefinition(){if(e instanceof O)return e;throw new Error("Not an ASTSegmentViewDefinition")},LimitViewOperation(){if(e instanceof P)return e;throw new Error("Not an ASTLimitViewOperation")},AnnotationList(){if(e instanceof D)return e;throw new Error("Not an ASTAnnotationList")},Annotation(){if(e instanceof W)return e;throw new Error("Not an ASTAnnotation")}}}get find(){const e=this;return{Query(t){return e.findAny(t).as.Query()},Reference(t){return e.findAny(t).as.Reference()},ReferenceQueryArrowSource(t){return e.findAny(t).as.ReferenceQueryArrowSource()},ParameterValueList(t){return e.findAny(t).as.ParameterValueList()},FilterOperation(t){return e.findAny(t).as.FilterOperation()},FilterOperationList(t){return e.findAny(t).as.FilterOperationList()},ParameterValue(t){return e.findAny(t).as.ParameterValue()},StringLiteralValue(t){return e.findAny(t).as.StringLiteralValue()},NumberLiteralValue(t){return e.findAny(t).as.NumberLiteralValue()},ViewOperationList(t){return e.findAny(t).as.ViewOperationList()},GroupByViewOperation(t){return e.findAny(t).as.GroupByViewOperation()},AggregateViewOperation(t){return e.findAny(t).as.AggregateViewOperation()},OrderByViewOperation(t){return e.findAny(t).as.OrderByViewOperation()},Field(t){return e.findAny(t).as.Field()},ReferenceExpression(t){return e.findAny(t).as.ReferenceExpression()},ReferenceViewDefinition(t){return e.findAny(t).as.ReferenceViewDefinition()},ArrowQueryDefinition(t){return e.findAny(t).as.ArrowQueryDefinition()},ArrowViewDefinition(t){return e.findAny(t).as.ArrowViewDefinition()},RefinementViewDefinition(t){return e.findAny(t).as.RefinementViewDefinition()},TimeTruncationExpression(t){return e.findAny(t).as.TimeTruncationExpression()},FilteredFieldExpression(t){return e.findAny(t).as.FilteredFieldExpression()},NestViewOperation(t){return e.findAny(t).as.NestViewOperation()},View(t){return e.findAny(t).as.View()},SegmentViewDefinition(t){return e.findAny(t).as.SegmentViewDefinition()},LimitViewOperation(t){return e.findAny(t).as.LimitViewOperation()},AnnotationList(t){return e.findAny(t).as.AnnotationList()},Annotation(t){return e.findAny(t).as.Annotation()}}}get parent(){if(this._parent===void 0)throw new Error("This node does not have a parent");return this._parent}set parent(e){this._parent=e}static schemaTryGet(e,t,n){return h._schemaTryGet(e,t,n,!1)}static schemaTryGetDrillField(e,t,n){return h._schemaTryGet(e,t,n,!0)}static _schemaTryGet(e,t,n,s){let a=e.fields;for(const f of n??[]){const u=a.find(m=>m.name===f);if(u===void 0)throw new Error(`${f} not found`);if(u.kind==="join"||s&&u.kind==="view"){a=u.schema.fields;continue}if(u.kind==="dimension"||u.kind==="measure"){if(u.type.kind==="record_type"){a=u.type.fields.map(m=>({kind:u.kind,...m}));continue}else if(u.type.kind==="array_type"&&u.type.element_type.kind==="record_type"){a=u.type.element_type.fields.map(m=>({kind:u.kind,...m}));continue}}throw new Error(`${f} is not a join, record, or repeated record`)}return a.find(f=>f.name===t)}static schemaGet(e,t,n){const s=h.schemaTryGet(e,t,n);if(s===void 0)throw new Error(`${t} not found`);return s}static schemaGetDrillField(e,t,n){const s=h.schemaTryGetDrillField(e,t,n);if(s===void 0)throw new Error(`${t} not found`);return s}static schemaMerge(e,t){return{fields:[...e.fields,...t.fields]}}static tagFor(e,t="# "){var n,s;const a=(s=(n=e.annotations)===null||n===void 0?void 0:n.map(f=>f.value))===null||s===void 0?void 0:s.filter(f=>f.startsWith(t)),o=new l.TagParser;for(const f of a??[])o.parseAnnotation(f);return o.finish()}static fieldWasCalculation(e){if(e.kind!=="dimension")throw new Error(`${e.name} could not be an output field, because it is a ${e.kind}, and only dimensions can appear in output schemas`);return h.tagFor(e,"#(malloy) ").has("calculation")}}function se(i){return Array.isArray(i)||typeof i=="string"||typeof i=="number"||typeof i=="boolean"}class M extends h{constructor(e,t){super(),this.node=e,this.children=t,this.originalChildren=[...t],t.forEach(n=>n.parent=this)}*iter(){for(let e=0;e<this.length;e++)yield this.index(e)}get length(){return this.children.length}get last(){return this.children[this.children.length-1]}index(e){return this.children[e]}insert(e,t){this.edit(),this.children.splice(t,0,e),e.parent=this}add(e){this.edit(),this.children.push(e),e.parent=this}remove(e){const t=this.children.findIndex(n=>n===e);if(t===-1)return this;this.edit(),this.children.splice(t,1)}build(){if(!this.edited)return this.node;const e=this.children.map(t=>t.build());return this.edited=!1,this.originalChildren=[...this.children],this.node=e,e}findAny(e){if(e.length===0)return this;const[t,...n]=e;if(typeof t!="number")throw new Error(`${this.constructor.name} is a ASTListNode and thus cannot contain a ${t}`);return this.children[t].findAny(n)}findIndex(e){return this.children.findIndex(e)}indexOf(e){return this.children.indexOf(e)}}class d extends h{constructor(e,t){super(),this.node=e,this.children=t;for(const n in t){const s=t[n];s&&!se(s)&&(s.parent=this)}}build(){if(!this.edited)return this.node;let e=this.node;for(const t in this.children){const n=this.children[t];n===void 0?e={...e,[t]:void 0}:se(n)?this.edited&&(e={...e,[t]:n}):e={...e,[t]:n.build()}}return this.node=e,this.edited=!1,e}findAny(e){if(e.length===0)return this;const[t,...n]=e;if(typeof t!="string")throw new Error(`${this.constructor.name} is a ASTListNode and thus cannot contain a ${t}`);const s=this.children[t];if(se(s))throw new Error(`${this.constructor.name}.${t} refers to a basic type, not an ASTNode`);return s._find(n)}}class k extends d{constructor(e){var t,n;let s=e.source;if(s===void 0){if(e.model===void 0)throw new Error("Need a model or source");if(e.query){const u=e.query.definition;if(u.kind==="arrow"&&u.source.kind==="source_reference"){const m=u.source.name;if(s=e.model.entries.find(z=>z.name===m),s===void 0)throw new Error(`Model does not contain source or query named ${m}`)}}if(s===void 0&&(s=e.model.entries[0]),s===void 0)throw new Error("Model does not contain any sources or queries")}const a=Re(s),o=(t=e.query)!==null&&t!==void 0?t:{definition:{kind:"arrow",source:{kind:"source_reference",name:a.name},view:{kind:"segment",operations:[]}}},f=(n=e.model)!==null&&n!==void 0?n:{entries:[a],anonymous_queries:[]};super(o,{definition:r.ASTQueryDefinition.from(o.definition),annotations:o.annotations&&new D(o.annotations)}),this.model=f,e.source&&this.setSource(e.source.name)}get definition(){return this.children.definition}set definition(e){this.edit(),this.children.definition=e,e.parent=this}get annotations(){return this.children.annotations}reorderFields(e){this.definition.reorderFields(e)}getOrAddAnnotations(){if(this.annotations)return this.annotations;this.edit();const e=new D([]);return this.children.annotations=e,e.parent=this,e}getInheritedTag(e="# "){return L(e,this.getInheritedAnnotations())}getIntrinsicTag(e="# "){var t,n;return(n=(t=this.annotations)===null||t===void 0?void 0:t.getIntrinsicTag(e))!==null&&n!==void 0?n:new l.Tag}getTag(e="# "){var t,n;return(n=(t=this.annotations)===null||t===void 0?void 0:t.getTag(e))!==null&&n!==void 0?n:this.getInheritedTag(e)}setTagProperty(e,t=null,n="# "){this.getOrAddAnnotations().setTagProperty(e,t,n)}removeTagProperty(e,t="# "){this.getTag().has(...e)&&this.getOrAddAnnotations().removeTagProperty(e,t)}setViewToEmptySegment(){if(!(this.definition instanceof y))throw new Error("Must set source before setting view");return this.definition=new y({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 y&&this.definition.view instanceof O&&this.definition.view.operations.length===0}getOrAddDefaultSegment(){return this.definition.getOrAddDefaultSegment()}setSource(e){if(this.definition instanceof y&&this.definition.source instanceof Y&&this.definition.source.name===e)return;if(this.model.entries.find(n=>n.name===e)===void 0)throw new Error(`Source ${e} is not defined in model`);this.definition=new y({kind:"arrow",source:{kind:"source_reference",name:e},view:this.definition instanceof y?this.definition.view.build():{kind:"segment",operations:[]}})}setQueryHead(e){const t=this.model.entries.find(n=>n.name===e);if(t===void 0||t.kind!=="query")throw new Error(`No query named ${e} in the model`);this.definition=new K({kind:"query_reference",name:e})}getQueryInfo(e){const t=this.model.entries.find(n=>n.name===e);if(t===void 0)throw new Error(`Query ${e} is not defined in model`);if(t.kind!=="query")throw new Error(`Model entry ${e} is not a query`);return t}toMalloy(){return g.queryToMalloy(this.build())}build(){return super.build()}setView(e){if(!(this.definition instanceof y))throw new Error("Must set source before setting view");return this.definition=new y({kind:"arrow",source:this.definition.source.build(),view:{kind:"view_reference",name:e}}),this.definition.view.as.ReferenceViewDefinition()}_getInheritedAnnotations(e){var t;return e instanceof K?(t=this.getQueryInfo(e.name).annotations)!==null&&t!==void 0?t:[]:e instanceof E?this._getInheritedAnnotations(e.base):e instanceof y?e.view.getInheritedAnnotations():[]}getInheritedAnnotations(){return this._getInheritedAnnotations(this.definition)}}r.ASTQuery=k;class c extends d{constructor(e){super(e,{name:e.name,path:e.path,parameters:e.parameters&&new b(e.parameters)}),this.reference=e}get name(){return this.children.name}set name(e){this.edit(),this.children.name=e}get parameters(){return this.children.parameters}set parameters(e){this.edit(),this.children.parameters=e}get path(){return this.children.path}static getOrAddParameters(e){if(e.parameters)return e.parameters;e.edit();const t=new b([]);return e.parameters=t,t}static setParameter(e,t,n){const s=c.tryGetParameter(e,t);if(s!==void 0){s.value=r.ASTLiteralValue.from(r.ASTLiteralValue.makeLiteral(n));return}return e.getOrAddParameters().addParameter(t,n)}static tryGetParameter(e,t){if(e.parameters!==void 0){for(const n of e.parameters.iter())if(n.name===t)return n}}getOrAddParameters(){return c.getOrAddParameters(this)}setParameter(e,t){return c.setParameter(this,e,t)}tryGetParameter(e){return c.tryGetParameter(this,e)}}r.ASTReference=c;class G extends c{get segment(){const e=this.parent;return e instanceof Q||e instanceof ee?e.field.segment:e instanceof ne||e instanceof C?e.segment:e.list.segment}getReferenceSchema(){return this.parent instanceof F?this.segment.getOutputSchema():this.segment.getInputSchema()}getFieldInfo(){const e=this.getReferenceSchema();return h.schemaGet(e,this.name,this.path)}}r.ASTFieldReference=G;class b extends M{constructor(e){super(e,e.map(t=>new H(t)))}get parameters(){return this.children}addParameter(e,t){this.add(new H({name:e,value:r.ASTLiteralValue.makeLiteral(t)}))}}r.ASTParameterValueList=b;class H extends d{constructor(e){super(e,{name:e.name,value:r.ASTLiteralValue.from(e.value)}),this.parameter=e}get name(){return this.children.name}get value(){return this.children.value}set value(e){this.edit(),this.children.value=e}}r.ASTParameterValue=H,r.ASTLiteralValue={from(i){switch(i.kind){case"string_literal":return new ae(i);case"number_literal":return new oe(i);case"boolean_literal":return new ye(i);case"date_literal":return new Ae(i);case"timestamp_literal":return new Te(i);case"null_literal":return new we(i);case"filter_expression_literal":return new Se(i)}},makeLiteral(i){if(i!==null&&typeof i=="object"&&"kind"in i)return i;if(typeof i=="string")return{kind:"string_literal",string_value:i};if(typeof i=="boolean")return{kind:"boolean_literal",boolean_value:i};if(typeof i=="number")return{kind:"number_literal",number_value:i};if(i===null)return{kind:"null_literal"};if("date"in i){const e=i.granularity,t=De(i.date);return Pe(e)?{kind:"date_literal",date_value:t,granularity:e}:{kind:"timestamp_literal",timestamp_value:t,granularity:e}}throw new Error("Unknown literal type")}};class ae extends d{constructor(e){super(e,{kind:e.kind,string_value:e.string_value}),this.node=e,this.kind="string_literal"}get fieldType(){return{kind:"string_type"}}}r.ASTStringLiteralValue=ae;class we extends d{constructor(e){super(e,{kind:e.kind}),this.node=e,this.kind="null_literal"}get fieldType(){}}r.ASTNullLiteralValue=we;class oe extends d{constructor(e){super(e,{kind:e.kind,number_value:e.number_value}),this.node=e,this.kind="number_literal"}get fieldType(){return{kind:"number_type",subtype:Number.isInteger(this.children.number_value)?"integer":"decimal"}}}r.ASTNumberLiteralValue=oe;class ye extends d{constructor(e){super(e,{kind:e.kind,boolean_value:e.boolean_value}),this.node=e,this.kind="boolean_literal"}get fieldType(){return{kind:"boolean_type"}}}r.ASTBooleanLiteralValue=ye;class Ae extends d{constructor(e){super(e,{kind:e.kind,date_value:e.date_value,granularity:e.granularity}),this.node=e,this.kind="date_literal"}get fieldType(){return{kind:"date_type",timeframe:this.children.granularity}}}r.ASTDateLiteralValue=Ae;class Te extends d{constructor(e){super(e,{kind:e.kind,timestamp_value:e.timestamp_value,granularity:e.granularity}),this.node=e,this.kind="timestamp_literal"}get fieldType(){return{kind:"timestamp_type",timeframe:this.children.granularity}}}r.ASTTimestampLiteralValue=Te;class Se extends d{constructor(e){super(e,{kind:e.kind,filter_expression_value:e.filter_expression_value}),this.node=e,this.kind="filter_expression_literal"}get fieldType(){}}r.ASTFilterExpressionLiteralValue=Se;class Ee extends h{constructor(e){super(),this.node=e}get treeEdited(){return!1}build(){return this.node}findAny(){throw new Error("Tried to find a node from an unimplemented node type")}}r.ASTUnimplemented=Ee,r.ASTQueryArrowSource={from(i){switch(i.kind){case"refinement":return new E(i);case"source_reference":return new Y(i)}}},r.ASTQueryDefinition={from(i){switch(i.kind){case"arrow":return new y(i);case"query_reference":return new K(i);case"refinement":return new E(i)}}};class y extends d{constructor(e){super(e,{kind:"arrow",source:r.ASTQueryArrowSource.from(e.source),view:v.from(e.view)}),this.node=e}get view(){return this.children.view}set view(e){this.edit(),this.children.view=e,e.parent=this}get source(){return this.children.source}set source(e){this.edit(),this.children.source=e}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(e){this.propagateDown(e)}propagateDown(e){e(this.view),this.view.propagateDown(e)}reorderFields(e){this.view instanceof O?this.view.reorderFields(e):this.query.getOrAddAnnotations().setTagProperty(["field_order"],e)}}r.ASTArrowQueryDefinition=y;class E extends d{constructor(e){super(e,{kind:"refinement",base:r.ASTQueryDefinition.from(e.base),refinement:v.from(e.refinement)}),this.node=e}get base(){return this.children.base}get refinement(){return this.children.refinement}set refinement(e){this.edit(),this.children.refinement=e,e.parent=this}isRunnable(){return!0}get query(){return this.parent.as.Query()}getOrAddDefaultSegment(){return this.refinement.getOrAddDefaultSegment()}getOutputSchema(){const e=this.base.getOutputSchema(),t=this.refinement.getRefinementSchema();return k.schemaMerge(e,t)}propagateUp(e){this.propagateDown(e)}propagateDown(e){e(this.refinement),this.refinement.propagateDown(e)}reorderFields(e){this.query.getOrAddAnnotations().setTagProperty(["field_order"],e)}getSourceInfo(){return this.base.getSourceInfo()}}r.ASTRefinementQueryDefinition=E;class K extends d{constructor(e){super(e,{kind:"query_reference",name:e.name,path:e.path,parameters:e.parameters&&new b(e.parameters)}),this.node=e}isRunnable(){return!0}get name(){return this.children.name}get query(){return this.parent.as.Query()}get parameters(){return this.children.parameters}set parameters(e){this.edit(),this.children.parameters=e}get path(){return this.children.path}getOrAddDefaultSegment(){const e=new E({kind:"refinement",base:this.build(),refinement:{kind:"segment",operations:[]}});return this.query.definition=e,e.refinement.as.SegmentViewDefinition()}propagateUp(e){}propagateDown(e){}reorderFields(e){this.query.getOrAddAnnotations().setTagProperty(["field_order"],e)}getOrAddParameters(){return c.getOrAddParameters(this)}setParameter(e,t){return c.setParameter(this,e,t)}tryGetParameter(e){return c.tryGetParameter(this,e)}getOutputSchema(){return this.getSourceInfo().schema}getSourceInfo(){const t=this.query.model.entries.find(n=>n.name===this.name);if(t===void 0)throw new Error(`Query not found with name ${this.name}`);return t}}r.ASTReferenceQueryDefinition=K;class Y extends d{constructor(e){super(e,{kind:"source_reference",name:e.name,path:e.path,parameters:e.parameters&&new b(e.parameters)}),this.node=e}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(e){this.edit(),this.children.parameters=e}get path(){return this.children.path}getSourceInfo(){const e=this.arrow.query.model.entries.find(t=>t.name===this.name);if(e===void 0)throw new Error(`No query or source named ${this.name}`);return e}getOrAddDefaultSegment(){if(this.getSourceInfo().kind!=="query")throw new Error(`Cannot refine source ${this.name}`);const t=new E({kind:"refinement",base:{...this.build(),kind:"query_reference"},refinement:{kind:"segment",operations:[]}});return this.arrow.source=t,t.refinement.as.SegmentViewDefinition()}propagateUp(e){}propagateDown(e){}getOrAddParameters(){return c.getOrAddParameters(this)}setParameter(e,t){return c.setParameter(this,e,t)}tryGetParameter(e){return c.tryGetParameter(this,e)}get query(){return this.parent.parent.as.Query()}getSourceParameters(){var e;const t=this.getSourceInfo();return t.kind==="query"?[]:(e=t.parameters)!==null&&e!==void 0?e:[]}areRequiredParametersSet(){const e=this.getSourceParameters();for(const t of e){if(t.default_value!==void 0)continue;if(this.tryGetParameter(t.name)===void 0)return!1}return!0}}r.ASTReferenceQueryArrowSource=Y;const v={from(i){switch(i.kind){case"arrow":return new Z(i);case"view_reference":return new X(i);case"segment":return new O(i);case"refinement":return new _(i)}}};function I(i,e){const t=i.parent;t instanceof y?t.view=e:t instanceof E?t.refinement=e:t instanceof ie?t.definition=e:t instanceof Z?t.source===i?t.source=e:t.view=e:t.base===i?t.base=e:t.refinement=e}function J(i,e,t=[]){const n=i.getInputSchema(),s=k.schemaGet(n,e,t);if(s===void 0)return{isValidViewRefinement:!1,error:`${e} is not defined`};if(s.kind!=="view")return{isValidViewRefinement:!1,error:`${e} is not a view`};const a=i.getOutputSchema();for(const o of s.schema.fields)if(k.schemaTryGet(a,o.name,[]))return{isValidViewRefinement:!1,error:`Cannot refine with ${e} because stage already has an output field named ${o.name}`};return{isValidViewRefinement:!0}}class X extends d{constructor(e){super(e,{kind:"view_reference",name:e.name,path:e.path,parameters:e.parameters&&new b(e.parameters)}),this.node=e}isRunnable(){return!0}get name(){return this.children.name}get path(){return this.children.path}get parameters(){return this.children.parameters}set parameters(e){this.edit(),this.children.parameters=e}getOrAddDefaultSegment(){return this.addEmptyRefinement()}addEmptyRefinement(){const e=_.segmentRefinementOf(this.build());return I(this,e),e.refinement.as.SegmentViewDefinition()}addViewRefinement(e,t){const{error:n}=this.isValidViewRefinement(e,t);if(n)throw new Error(n);const s=_.viewRefinementOf(this.build(),e,t);return I(this,s),s.refinement.as.ReferenceViewDefinition()}convertToNest(e){const t=v.from({kind:"segment",operations:[{kind:"nest",name:e,view:{definition:this.build()}}]});I(this,t)}isValidViewRefinement(e,t){return J(this,e,t)}getInputSchema(){return pe(this.parent)}getOutputSchema(){return this.parent.getOutputSchema()}getImplicitName(){return this.name}getViewInfo(){const e=this.getInputSchema(),t=h.schemaGet(e,this.name,this.path);if(t.kind!=="view")throw new Error("Not a view");return t}getRefinementSchema(){return this.getViewInfo().schema}propagateUp(e){this.parent.propagateUp(e)}propagateDown(e){}getInheritedAnnotations(){var e;return(e=this.getViewInfo().annotations)!==null&&e!==void 0?e:[]}getOrAddParameters(){return c.getOrAddParameters(this)}setParameter(e,t){return c.setParameter(this,e,t)}tryGetParameter(e){return c.tryGetParameter(this,e)}}r.ASTReferenceViewDefinition=X;class Z extends d{constructor(e){super(e,{kind:"arrow",source:v.from(e.source),view:v.from(e.view)}),this.node=e}isRunnable(){return this.source.isRunnable()&&this.view.isRunnable()}get source(){return this.children.source}set source(e){this.edit(),this.children.source=e}get view(){return this.children.view}set view(e){this.edit(),this.children.view=e,e.parent=this}getOrAddDefaultSegment(){return this.view.getOrAddDefaultSegment()}addEmptyRefinement(){return this.view.addEmptyRefinement()}addViewRefinement(e,t){return this.view.addViewRefinement(e,t)}convertToNest(e){const t=v.from({kind:"segment",operations:[{kind:"nest",name:e,view:{definition:this.build()}}]});I(this,t)}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(e,t){return J(this,e,t)}propagateUp(e){this.propagateDown(e)}propagateDown(e){e(this.view),this.view.propagateDown(e)}getInheritedAnnotations(){return[]}}r.ASTArrowViewDefinition=Z;class _ extends d{constructor(e){super(e,{kind:"refinement",base:v.from(e.base),refinement:v.from(e.refinement)}),this.node=e}isRunnable(){return this.getOutputSchema().fields.length>0}get refinement(){return this.children.refinement}set refinement(e){this.edit(),this.children.refinement=e,e.parent=this}get base(){return this.children.base}set base(e){this.edit(),this.children.base=e}convertToNest(e){const t=v.from({kind:"segment",operations:[{kind:"nest",name:e,view:{definition:this.build()}}]});I(this,t)}getOrAddDefaultSegment(){return this.refinement.getOrAddDefaultSegment()}addEmptyRefinement(){return this.refinement.addEmptyRefinement()}addViewRefinement(e,t){return this.refinement.addViewRefinement(e,t)}getInputSchema(){return pe(this.parent)}getOutputSchema(){return this.parent.getOutputSchema()}getRefinementSchema(){return h.schemaMerge(this.base.getRefinementSchema(),this.refinement.getRefinementSchema())}getImplicitName(){return this.base.getImplicitName()}isValidViewRefinement(e,t){return J(this,e,t)}propagateUp(e){this.parent.propagateUp(e)}propagateDown(e){e(this.base),e(this.refinement),this.base.propagateDown(e),this.refinement.propagateDown(e)}getInheritedAnnotations(){return this.base.getInheritedAnnotations()}static viewRefinementOf(e,t,n){return new _({kind:"refinement",base:e,refinement:{kind:"view_reference",name:t,path:n}})}static segmentRefinementOf(e){return new _({kind:"refinement",base:e,refinement:{kind:"segment",operations:[]}})}}r.ASTRefinementViewDefinition=_;class O extends d{constructor(e){super(e,{kind:"segment",operations:new de(e.operations)}),this.node=e,this.DEFAULT_INSERTION_ORDER=["group_by","aggregate","drill","where","having","nest","order_by","calculate","limit"]}isRunnable(){let e=!1;for(const t of this.operations.iter()){if(t instanceof S||t instanceof A)return!0;if(t instanceof T){if(!t.view.definition.isRunnable())return!1;e=!0}}return e}get operations(){return this.children.operations}convertToNest(e){const t=v.from({kind:"segment",operations:[{kind:"nest",name:e,view:{definition:this.build()}}]});I(this,t)}renameOrderBys(e,t){for(const n of this.operations.iter())n instanceof F&&n.name===e&&n.setField(t)}propagateUp(e){this.parent.propagateUp(e)}propagateDown(e){}removeOrderBys(e){for(const t of this.operations.iter())t instanceof F&&t.name===e&&t.delete()}reorderFields(e){const t=[],n=[],s={};let a=!1;for(const u of this.operations.iter()){if((u instanceof S||u instanceof A||u instanceof T)&&e.includes(u.name)){s[u.name]=u,a=!0;continue}a?n.push(u):t.push(u)}const o=[];for(const u of e){const m=s[u];if(m===void 0)throw new Error(`No field named ${u}`);o.push(m)}const f=[...t,...o,...n];this.operations.items=f}renameField(e,t){if(e.name===t)return;const n=this.getOutputSchema();if(h.schemaTryGet(n,t,[]))throw new Error(`Output already has a field named ${t}`);const s=e.name;e.name=t,this.propagateUp(a=>{a instanceof O&&a.renameOrderBys(s,t)})}addOrderBy(e,t){const n=this.getOutputSchema();try{h.schemaGet(n,e,[])}catch{throw new Error(`No such field ${e} in stage output`)}for(const a of this.operations.iter())if(a instanceof F&&a.name===e)return a.direction=t,a;const s=new F({kind:"order_by",field_reference:{name:e},direction:t});return this.addOperation(s),s}addEmptyNest(e){const t=new T({kind:"nest",name:e,view:{definition:{kind:"segment",operations:[]}}});return this.addOperation(t),t}firstIndexOfOperationType(e){return this.operations.findIndex(t=>t.kind===e)}findInsertionPoint(e){const t=this.firstIndexOfOperationType(e);if(t>-1){let a=t;for(;this.operations.index(a)&&this.operations.index(a).kind===e;)a++;return a}const n=this.DEFAULT_INSERTION_ORDER.indexOf(e);if(n===-1)throw new Error(`Operation ${e} is not supported for \`findInsertionPoint\``);const s=this.DEFAULT_INSERTION_ORDER.slice(n+1);for(const a of s){const o=this.firstIndexOfOperationType(a);if(o>-1)return o}return this.operations.length}getFieldNamed(e){const t=this.tryGetFieldNamed(e);if(t===void 0)throw new Error("No such field");return t}hasFieldNamed(e){return this.tryGetFieldNamed(e)!==void 0}hasField(e,t){return this.tryGetField(e,t)!==void 0}getField(e,t){const n=this.tryGetField(e,t);if(n===void 0)throw new Error("No such field");return n}tryGetField(e,t){for(const n of this.operations.iter())if(n instanceof A||n instanceof S){const s=n.field.getReference();if(s&&s.name===e&&_e(s.path,t))return n}else if(n instanceof T){if(n.view instanceof X)return n}else if(n instanceof R){const s=n.expression.field.getReference();if(s&&s.name===e&&_e(s.path,t))return n}}tryGetFieldNamed(e){for(const t of this.operations.iter())if((t instanceof A||t instanceof S||t instanceof T||t instanceof R)&&t.name===e)return t}getGroupBy(e){for(const t of this.operations.iter())if(t instanceof A&&t.name===e)return t}removeGroupBy(e){var t;return(t=this.getGroupBy(e))===null||t===void 0||t.delete(),this}addGroupBy(e,t=[],n){const s=this.makeField(e,t,n,"dimension");return this.addOperation(s),s}addDrill(e){const t=new te({kind:"drill",...e});return this.addOperation(t),t}addWhere(e,t,n){const s=Array.isArray(t)?t:[],a=n===void 0?t:n,o=typeof a=="string"?a:re(a),f=this.getInputSchema(),u=k.schemaGet(f,e,s);ge(u,a);const m=new fe({kind:"where",filter:{kind:"filter_string",expression:{kind:"field_reference",name:e,path:s},filter:o}});return this.addOperation(m),m}addHaving(e,t,n){const s=Array.isArray(t)?t:[],a=n===void 0?t:n,o=typeof a=="string"?a:re(a),f=this.getInputSchema(),u=k.schemaGet(f,e,s);ge(u,a);const m=new ce({kind:"having",filter:{kind:"filter_string",expression:{kind:"field_reference",name:e,path:s},filter:o}});return this.addOperation(m),m}addCalculateMovingAverage(e,t,n,s,a){const o=new R({kind:"calculate",name:e,field:{expression:{kind:"moving_average",field_reference:{name:t,path:n},rows_preceding:s,rows_following:a}}});return this.addOperation(o),o}addTimeGroupBy(e,t,n,s){const a=this.getInputSchema(),o=h.schemaGet(a,e,t);if(o===void 0)throw new Error(`No such field ${e}`);if(o.kind!=="dimension")throw new Error(`Cannot group by non-dimension ${e}`);if(o.type.kind!==s)throw new Error(`${e} is not a ${s}`);const f=new A({kind:"group_by",field:{expression:{kind:"time_truncation",field_reference:{name:e,path:t},truncation:n}}});return this.addOperation(f),f}addDateGroupBy(e,t,n){const s=n===void 0?t:n,a=n===void 0?[]:t;return this.addTimeGroupBy(e,a,s,"date_type")}addTimestampGroupBy(e,t,n){const s=n===void 0?t:n,a=n===void 0?[]:t;return this.addTimeGroupBy(e,a,s,"timestamp_type")}addTimestamptzGroupBy(e,t,n){const s=n===void 0?t:n,a=n===void 0?[]:t;return this.addTimeGroupBy(e,a,s,"timestamptz_type")}addAggregate(e,t=[],n){const s=this.makeField(e,t,n,"measure");return this.addOperation(s),s}addNest(e,t){const n=this.makeField(e,[],t,"view");return this.addOperation(n),n}makeField(e,t,n,s){const a=this.getInputSchema(),o=h.schemaGet(a,e,t);if(o===void 0)throw new Error(`No such field ${e}`);if(o.kind!==s){const f=Fe(s),u=s;throw new Error(`Cannot ${f} non-${u} ${e}`)}return s==="dimension"?A.fromReference(e,t,n):s==="measure"?S.fromReference(e,t,n):T.fromReference(e,t,n)}addOperation(e){if((e instanceof A||e instanceof S||e instanceof T||e instanceof R)&&this.hasFieldNamed(e.name))throw new Error(`Query already has a field named ${e.name}`);const t=this.findInsertionPoint(e.kind);return this.operations.insert(e,t),e}getRefinementSchema(){const e=[];for(const t of this.operations.iter())(t instanceof A||t instanceof S||t instanceof T||t instanceof R)&&e.push(t.getFieldInfo());return{fields:e}}setLimit(e){P.validateLimit(e);const t=[...this.operations.iter()].find(r.ASTViewOperation.isLimit);t?t.limit=e:this.operations.add(new P({kind:"limit",limit:e}))}getOrAddDefaultSegment(){return this}addEmptyRefinement(){const e=_.segmentRefinementOf(this.build());return I(this,e),e.refinement.as.SegmentViewDefinition()}addViewRefinement(e,t){const{error:n}=this.isValidViewRefinement(e,t);if(n)throw new Error(n);const s=_.viewRefinementOf(this.build(),e,t);return I(this,s),s.refinement.as.ReferenceViewDefinition()}getInputSchema(){return pe(this.parent)}getOutputSchema(){return this.parent.getOutputSchema()}getImplicitName(){}isValidViewRefinement(e,t){return J(this,e,t)}getInheritedAnnotations(){return[]}}r.ASTSegmentViewDefinition=O;class de extends M{constructor(e){super(e,e.map(t=>r.ASTViewOperation.from(t)))}get items(){return this.children}set items(e){this.edit(),this.children=e}get segment(){return this.parent.as.SegmentViewDefinition()}}r.ASTViewOperationList=de,r.ASTViewOperation={from(i){switch(i.kind){case"group_by":return new A(i);case"aggregate":return new S(i);case"order_by":return new F(i);case"nest":return new T(i);case"limit":return new P(i);case"where":return new fe(i);case"drill":return new te(i);case"having":return new ce(i);case"calculate":return new R(i)}},isLimit(i){return i instanceof P}};class F extends d{constructor(e){super(e,{kind:"order_by",field_reference:new G(e.field_reference),direction:e.direction}),this.node=e,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(e){this.direction!==e&&(this.edit(),this.children.direction=e)}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this)}setField(e){const t=this.list.segment.getOutputSchema();h.schemaGet(t,e,[]),this.edit(),this.children.field_reference=new G({name:e})}setDirection(e){this.direction=e}}r.ASTOrderByViewOperation=F;class A extends d{constructor(e){super(e,{kind:"group_by",name:e.name,field:new x(e.field)}),this.node=e,this.kind="group_by"}get field(){return this.children.field}get name(){var e;const t=(e=this.children.name)!==null&&e!==void 0?e:this.field.name;if(t===void 0)throw new Error("Group by does not have a name");return t}set name(e){this.name!==e&&(this.edit(),this.field.name===e?this.children.name=void 0:this.children.name=e)}get list(){return this.parent.as.ViewOperationList()}rename(e){this.list.segment.renameField(this,e)}delete(){this.list.remove(this),this.list.segment.propagateUp(e=>{e instanceof O&&e.removeOrderBys(this.name)})}getFieldInfo(){return{kind:"dimension",name:this.name,type:this.field.type}}get annotations(){return this.field.annotations}set annotations(e){this.edit(),this.field.annotations=e}getOrAddAnnotations(){return this.field.getOrAddAnnotations()}getInheritedTag(e="# "){return L(e,this.field.getInheritedAnnotations())}getIntrinsicTag(e="# "){var t,n;return(n=(t=this.annotations)===null||t===void 0?void 0:t.getIntrinsicTag(e))!==null&&n!==void 0?n:new l.Tag}getTag(e="# "){var t,n;return(n=(t=this.annotations)===null||t===void 0?void 0:t.getTag(e))!==null&&n!==void 0?n:this.getInheritedTag(e)}setTagProperty(e,t=null,n="# "){this.getOrAddAnnotations().setTagProperty(e,t,n)}removeTagProperty(e,t="# "){this.getTag().has(...e)&&this.getOrAddAnnotations().removeTagProperty(e,t)}static fromReference(e,t,n){return new A({kind:"group_by",name:n,field:{expression:{kind:"field_reference",name:e,path:t}}})}}r.ASTGroupByViewOperation=A;class S extends d{constructor(e){super(e,{kind:"aggregate",name:e.name,field:new x(e.field)}),this.node=e,this.kind="aggregate"}get field(){return this.children.field}get name(){var e;const t=(e=this.children.name)!==null&&e!==void 0?e:this.field.name;if(t===void 0)throw new Error("Aggregate does not have a name");return t}set name(e){this.name!==e&&(this.edit(),this.field.name===e?this.children.name=void 0:this.children.name=e)}get annotations(){return this.field.annotations}rename(e){this.list.segment.renameField(this,e)}convertToCalculateMovingAverage(e,t,n=0,s=[]){if(!(this.field.expression instanceof U))throw new Error("Cannot convert aggregate to smoothed metric unless it is a field reference");this.list.remove(this);const a=new R({kind:"calculate",name:e,field:{expression:{kind:"moving_average",field_reference:{name:this.field.expression.name,path:this.field.expression.path},rows_preceding:t,rows_following:n,partition_fields:s.map(o=>({name:o}))}}});return this.list.add(a),a}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this),this.list.segment.propagateUp(e=>{e instanceof O&&e.removeOrderBys(this.name)})}getFieldInfo(){return{annotations:[{value:l.Tag.withPrefix("#(malloy) ").set(["calculation"]).toString()}],kind:"dimension",name:this.name,type:this.field.type}}getOrAddAnnotations(){return this.field.getOrAddAnnotations()}getInheritedTag(e="# "){return L(e,this.field.getInheritedAnnotations())}getIntrinsicTag(e="# "){var t,n;return(n=(t=this.annotations)===null||t===void 0?void 0:t.getIntrinsicTag(e))!==null&&n!==void 0?n:new l.Tag}getTag(e="# "){var t,n;return(n=(t=this.annotations)===null||t===void 0?void 0:t.getTag(e))!==null&&n!==void 0?n:this.getInheritedTag(e)}setTagProperty(e,t=null,n="# "){this.getOrAddAnnotations().setTagProperty(e,t,n)}removeTagProperty(e,t="# "){this.getTag().has(...e)&&this.getOrAddAnnotations().removeTagProperty(e,t)}addWhere(e,t,n){const s=Array.isArray(t)?t:[],a=n===void 0?t:n,o=typeof a=="string"?a:re(a),f=this.list.segment.getInputSchema(),u=k.schemaGet(f,e,s);ge(u,a);const m={filter:{kind:"filter_string",expression:{kind:"field_reference",name:e,path:s},filter:o}};if(this.field.expression instanceof Q)return this.field.expression.where.add(new j(m)),this.field.expression;if(this.field.expression instanceof U){const z=this.field.expression.build();return this.field.expression=new Q({kind:"filtered_field",field_reference:{name:z.name,path:z.path,parameters:z.parameters},where:[m]}),this.field.expression}else throw new Error("This kind of expression does not support addWhere")}static fromReference(e,t,n){return new S({kind:"aggregate",name:n,field:{expression:{kind:"field_reference",name:e,path:t}}})}}r.ASTAggregateViewOperation=S;class x extends d{constructor(e){super(e,{expression:r.ASTExpression.from(e.expression),annotations:e.annotations&&new D(e.annotations)}),this.node=e}get expression(){return this.children.expression}set expression(e){this.edit(),this.children.expression=e,e.parent=this}get name(){return this.expression.name}get type(){const e=this.expression.fieldType;if(e===void 0)throw new Error("Field expression does not have a type");return e}get annotations(){return this.children.annotations}set annotations(e){this.edit(),this.children.annotations=e}getReference(){if(!(this.expression instanceof ue))return this.expression.getReference()}getOrAddAnnotations(){if(this.annotations)return this.annotations;this.edit();const e=new D([]);return this.children.annotations=e,e.parent=this,e}getInheritedTag(e="# "){return L(e,this.getInheritedAnnotations())}getIntrinsicTag(e="# "){var t,n;return(n=(t=this.annotations)===null||t===void 0?void 0:t.getIntrinsicTag(e))!==null&&n!==void 0?n:new l.Tag}getTag(e="# "){var t,n;return(n=(t=this.annotations)===null||t===void 0?void 0:t.getTag(e))!==null&&n!==void 0?n:this.getInheritedTag(e)}setTagProperty(e,t=null,n="# "){this.getOrAddAnnotations().setTagProperty(e,t,n)}removeTagProperty(e,t="# "){this.getTag().has(...e)&&this.getOrAddAnnotations().removeTagProperty(e,t)}get segment(){return this.parent.list.segment}getInheritedAnnotations(){return this.expression.getInheritedAnnotations()}}r.ASTField=x,r.ASTExpression={from(i){switch(i.kind){case"field_reference":return new U(i);case"filtered_field":return new Q(i);case"time_truncation":return new ee(i);case"literal_value":return new ue(i);case"moving_average":return new ve(i)}}};class U extends d{constructor(e){super(e,{kind:e.kind,name:e.name,path:e.path,parameters:e.parameters&&new b(e.parameters)}),this.node=e,this.kind="field_reference"}get name(){return this.children.name}get parameters(){return this.children.parameters}set parameters(e){this.edit(),this.children.parameters=e}get segment(){const e=this.parent;if(e instanceof x)return e.segment;if(e instanceof ne||e instanceof C)return e.segment;throw new Error("Invalid expression parent")}get path(){return this.children.path}getReference(){return this.build()}getFieldInfo(){const e=this.segment.getInputSchema(),n=this.parent instanceof C&&this.parent.parent instanceof te?h.schemaGetDrillField(e,this.name,this.path):h.schemaGet(e,this.name,this.path);if(n.kind!=="dimension"&&n.kind!=="measure")throw new Error("Invalid field for ASTReferenceExpression");return n}get fieldType(){return this.getFieldInfo().type}getInheritedAnnotations(){var e;return(e=this.getFieldInfo().annotations)!==null&&e!==void 0?e:[]}getOrAddParameters(){return c.getOrAddParameters(this)}setParameter(e,t){return c.setParameter(this,e,t)}tryGetParameter(e){return c.tryGetParameter(this,e)}}r.ASTReferenceExpression=U;class ee extends d{constructor(e){super(e,{kind:e.kind,field_reference:new G(e.field_reference),truncation:e.truncation}),this.node=e,this.kind="time_truncation"}getReference(){return this.fieldReference.build()}get fieldReference(){return this.children.field_reference}get truncation(){return this.children.truncation}set truncation(e){this.edit(),this.children.truncation=e}get name(){return this.fieldReference.name}get field(){return this.parent.as.Field()}getFieldInfo(){const e=this.field.segment.getInputSchema(),t=h.schemaGet(e,this.name,this.fieldReference.path);if(t.kind!=="dimension"&&t.kind!=="measure")throw new Error("Invalid field for ASTReferenceExpression");return t}get fieldType(){const e=this.getFieldInfo();if(e.type.kind==="date_type")return{...e.type,timeframe:Ie(this.truncation)};if(e.type.kind==="timestamp_type"||e.type.kind==="timestamptz_type")return{...e.type,timeframe:this.truncation};throw new Error("This type of field cannot have a time truncation")}getInheritedAnnotations(){var e;return(e=this.getFieldInfo().annotations)!==null&&e!==void 0?e:[]}}r.ASTTimeTruncationExpression=ee;class ue extends d{constructor(e){super(e,{kind:e.kind,literal_value:r.ASTLiteralValue.from(e.literal_value)}),this.node=e,this.kind="time_truncation"}get name(){}get literalValue(){return this.children.literal_value}get fieldType(){return this.literalValue.fieldType}getInheritedAnnotations(){return[]}getFieldInfo(){}}r.ASTLiteralValueExpression=ue;class le extends M{constructor(e){super(e,e.map(t=>new G(t)))}}r.ASTFieldReferenceList=le;class ve extends d{constructor(e){super(e,{kind:e.kind,field_reference:new G(e.field_reference),rows_preceding:e.rows_preceding,rows_following:e.rows_following,partition_fields:new le(e.partition_fields||[])}),this.node=e,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(e){this.edit(),this.children.rows_preceding=e}get rowsFollowing(){return this.children.rows_following}set rowsFollowing(e){this.edit(),this.children.rows_following=e}get name(){return this.fieldReference.name}get field(){return this.parent.as.Field()}get partitionFields(){return this.children.partition_fields}setPartitionFields(e){this.children.partition_fields=new le(e)}getFieldInfo(){const e=this.field.segment.getInputSchema(),t=h.schemaGet(e,this.name,this.fieldReference.path);if(t.kind!=="dimension"&&t.kind!=="measure")throw new Error("Invalid field for ASTReferenceExpression");return t}get fieldType(){return this.getFieldInfo().type}getInheritedAnnotations(){var e;return(e=this.getFieldInfo().annotations)!==null&&e!==void 0?e:[]}}r.ASTMovingAverageExpression=ve;class j extends d{constructor(e){super(e,{filter:r.ASTFilter.from(e.filter)})}get filter(){return this.children.filter}get list(){return this.parent.as.FilterOperationList()}delete(){this.list.remove(this)}}r.ASTFilterOperation=j;class he extends M{constructor(e){super(e,e.map(t=>new j(t)))}get expression(){return this.parent.as.FilteredFieldExpression()}}r.ASTFilterOperationList=he;class Q extends d{constructor(e){super(e,{kind:e.kind,field_reference:new G(e.field_reference),where:new he(e.where)}),this.node=e,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 e=this.field.segment.getInputSchema(),t=h.schemaGet(e,this.name,this.fieldReference.path);if(t.kind!=="measure")throw new Error("Invalid field for ASTFilteredFieldExpression");return t}get fieldType(){return this.getFieldInfo().type}getInheritedAnnotations(){var e;return(e=this.getFieldInfo().annotations)!==null&&e!==void 0?e:[]}}r.ASTFilteredFieldExpression=Q;function Ie(i){switch(i){case"day":case"week":case"month":case"year":case"quarter":return i;default:throw new Error("Invalid date timeframe")}}class T extends d{constructor(e){super(e,{kind:"nest",name:e.name,view:new ie(e.view)}),this.node=e,this.kind="nest"}get view(){return this.children.view}get annotations(){return this.view.annotations}get name(){var e;const t=(e=this.children.name)!==null&&e!==void 0?e:this.view.name;if(t===void 0)throw new Error("Nest does not have a name");return t}set name(e){this.name!==e&&(this.edit(),this.view.name===e?this.children.name=void 0:this.children.name=e)}get list(){return this.parent.as.ViewOperationList()}getOrAddAnnotations(){return this.view.getOrAddAnnotations()}getInheritedTag(e="# "){return L(e,this.view.getInheritedAnnotations())}getIntrinsicTag(e="# "){var t,n;return(n=(t=this.annotations)===null||t===void 0?void 0:t.getIntrinsicTag(e))!==null&&n!==void 0?n:new l.Tag}getTag(e="# "){var t,n;return(n=(t=this.annotations)===null||t===void 0?void 0:t.getTag(e))!==null&&n!==void 0?n:this.getInheritedTag(e)}setTagProperty(e,t=null,n="# "){this.getOrAddAnnotations().setTagProperty(e,t,n)}removeTagProperty(e,t="# "){this.getTag().has(...e)&&this.getOrAddAnnotations().removeTagProperty(e,t)}delete(){this.list.remove(this)}rename(e){this.list.segment.renameField(this,e)}getFieldInfo(){return{kind:"view",name:this.name,definition:this.view.build(),schema:this.view.getOutputSchema()}}static fromReference(e,t,n){return new T({kind:"nest",name:n,view:{definition:{kind:"view_reference",name:e,path:t}}})}}r.ASTNestViewOperation=T;class fe extends d{constructor(e){super(e,{kind:"where",filter:r.ASTFilter.from(e.filter)}),this.node=e,this.kind="where"}get filter(){return this.children.filter}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this)}}r.ASTWhereViewOperation=fe;class te extends d{constructor(e){super(e,{kind:"drill",filter:r.ASTFilter.from(e.filter)}),this.node=e,this.kind="drill"}get filter(){return this.children.filter}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this)}}r.ASTDrillViewOperation=te;class ce extends d{constructor(e){super(e,{kind:"having",filter:r.ASTFilter.from(e.filter)}),this.node=e,this.kind="having"}get filter(){return this.children.filter}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this)}}r.ASTHavingViewOperation=ce;class R extends d{constructor(e){super(e,{kind:"calculate",field:new x(e.field),name:e.name}),this.node=e,this.kind="calculate"}get expression(){return this.children.field.expression}set expression(e){this.edit(),this.children.field.expression=e,e.parent=this}get name(){return this.node.name}set name(e){this.name!==e&&(this.edit(),this.node.name=e)}getFieldInfo(){return{annotations:[{value:l.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)}}r.ASTCalculateViewOperation=R,r.ASTFilter={from(i){switch(i.kind){case"filter_string":return new ne(i);case"literal_equality":return new C(i)}},getSegment(i){const e=i.parent;return e instanceof j?e.list.expression.field.segment:e.list.segment}};class ne extends d{constructor(e){super(e,{kind:"filter_string",expression:r.ASTExpression.from(e.expression),filter:e.filter}),this.node=e,this.kind="filter_string"}get expression(){return this.children.expression}get filterString(){return this.children.filter}set filterString(e){this.edit(),this.children.filter=e}setFilterString(e){const t=this.getFilterType();me(this.filterString,t),this.filterString=e}get segment(){return r.ASTFilter.getSegment(this)}getFieldInfo(){const e=this.expression.getFieldInfo();if(e===void 0||e.kind!=="dimension"&&e.kind!=="measure")throw new Error("Invalid field type for filter with filter string");return e}getFilterType(){const e=this.getFieldInfo();return Oe(e)}setFilter(e){const t=this.getFilterType();if(t!==e.kind)throw new Error(`Invalid filter: expected type ${t}, got ${e.kind}`);this.filterString=re(e)}getFilter(){const e=this.getFilterType();return me(this.filterString,e)}}r.ASTFilterWithFilterString=ne;class C extends d{constructor(e){super(e,{kind:"literal_equality",expression:r.ASTExpression.from(e.expression),value:r.ASTLiteralValue.from(e.value)}),this.node=e,this.kind="literal_equality"}get expression(){return this.children.expression}get value(){return this.children.value}get segment(){return r.ASTFilter.getSegment(this)}}r.ASTFilterWithLiteralEquality=C;class ie extends d{constructor(e){super(e,{definition:v.from(e.definition),annotations:e.annotations&&new D(e.annotations)}),this.node=e}get definition(){return this.children.definition}set definition(e){this.edit(),this.children.definition=e,e.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(e){this.propagateDown(e)}propagateDown(e){e(this.definition),this.definition.propagateDown(e)}reorderFields(e){this.definition instanceof O?this.definition.reorderFields(e):this.getOrAddAnnotations().setTagProperty(["field_order"],e)}get annotations(){return this.children.annotations}getOrAddAnnotations(){if(this.annotations)return this.annotations;this.edit();const e=new D([]);return this.children.annotations=e,e.parent=this,e}getInheritedAnnotations(){return this.definition.getInheritedAnnotations()}getInheritedTag(e="# "){return L(e,this.getInheritedAnnotations())}getIntrinsicTag(e="# "){var t,n;return(n=(t=this.annotations)===null||t===void 0?void 0:t.getIntrinsicTag(e))!==null&&n!==void 0?n:new l.Tag}getTag(e="# "){var t,n;return(n=(t=this.annotations)===null||t===void 0?void 0:t.getTag(e))!==null&&n!==void 0?n:this.getInheritedTag(e)}setTagProperty(e,t=null,n="# "){this.getOrAddAnnotations().setTagProperty(e,t,n)}removeTagProperty(e,t="# "){this.getTag().has(...e)&&this.getOrAddAnnotations().removeTagProperty(e,t)}}r.ASTView=ie;class P extends d{get limit(){return this.children.limit}set limit(e){P.validateLimit(e),this.edit(),this.children.limit=e}constructor(e){super(e,{kind:e.kind,limit:e.limit}),this.node=e,this.kind="limit"}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this)}static validateLimit(e){if(!Number.isInteger(e))throw new Error("Limit must be an integer")}}r.ASTLimitViewOperation=P;function Fe(i){switch(i){case"dimension":return"group by";case"measure":return"aggregate";case"view":return"nest";case"join":return"join";case"calculate":return"calculate"}}function Me(i){return i}class D extends M{constructor(e){super(e,e.map(t=>new W(t)))}get items(){return this.children}getInheritedAnnotations(){return this.parent.getInheritedAnnotations()}getIntrinsicTag(e="# "){return L(e,this.items)}getTag(e="# "){return L(e,this.items,this.getInheritedAnnotations())}get annotations(){return this.children.map(e=>e.node)}setTagProperty(e,t=null,n="# "){let s;for(let a=this.items.length-1;a>=0;a--){const o=this.index(a);if(o.hasPrefix(n)&&(s=o,o.hasIntrinsicTagProperty(e))){o.setTagProperty(e,t);return}}s?s.setTagProperty(e,t):this.add(new W({value:new l.Tag({prefix:n}).set(e,t).toString()}))}removeTagProperty(e,t="# "){let n;for(let s=this.items.length-1;s>=0;s--){const a=this.index(s);if(a.hasPrefix(t)&&(n=a,a.hasIntrinsicTagProperty(e))){a.removeTagProperty(e);return}}n?n.removeTagProperty(e):this.add(new W({value:new l.Tag({prefix:t}).unset(...e).toString()}))}}r.ASTAnnotationList=D;class W extends d{get value(){return this.children.value}set value(e){this.edit(),this.children.value=e}constructor(e){super(e,{value:e.value}),this.node=e}get list(){return this.parent.as.AnnotationList()}get index(){return this.list.indexOf(this)}delete(){this.list.remove(this)}getIntrinsicTag(){const e=new l.TagParser;return e.parseAnnotation(this.value),e.finish()}getTag(){const e=new l.TagParser;for(const t of this.list.getInheritedAnnotations())e.parseAnnotation(t.value);for(let t=0;t<=this.index;t++)e.parseAnnotation(this.list.index(t).value);return e.finish()}hasPrefix(e){return this.value.startsWith(e)}hasIntrinsicTagProperty(e){return this.getIntrinsicTag().has(...e)}setTagProperty(e,t){this.value=this.getIntrinsicTag().set(e,t).toString()}removeTagProperty(e){this.value=this.getTag().unset(...e).toString()}}r.ASTAnnotation=W;function L(i,e=[],t=[]){const n=new l.TagParser;for(const a of t)n.parseAnnotation(a.value);const s=e.map(a=>a.value).filter(a=>typeof i=="string"?a.startsWith(i):a.match(i));for(const a of s)n.parseAnnotation(a);return n.finish()}function re(i){switch(i.kind){case"string":return p.StringFilterExpression.unparse(i.parsed);case"number":return p.NumberFilterExpression.unparse(i.parsed);case"boolean":return p.BooleanFilterExpression.unparse(i.parsed);case"timestamp":case"timestamptz":case"date":return p.TemporalFilterExpression.unparse(i.parsed)}}function me(i,e){function t(n){const s=n.filter(a=>a.severity==="error");if(s.length!==0)throw new Error(`Invalid Malloy filter string: ${s[0].message}`)}switch(e){case"string":{const n=p.StringFilterExpression.parse(i);return t(n.log),{kind:e,parsed:n.parsed}}case"number":{const n=p.NumberFilterExpression.parse(i);return t(n.log),{kind:e,parsed:n.parsed}}case"boolean":{const n=p.BooleanFilterExpression.parse(i);return t(n.log),{kind:e,parsed:n.parsed}}case"timestamp":case"timestamptz":case"date":{const n=p.TemporalFilterExpression.parse(i);return t(n.log),{kind:e,parsed:n.parsed}}case"other":throw new Error("Not implemented")}}function Re(i){return"kind"in i?i:{...i,kind:"source"}}function Pe(i){switch(i){case"year":case"quarter":case"month":case"week":case"day":return!0;default:return!1}}function B(i,e){return i.toString().padStart(e,"0")}function De(i){const e=B(i.getUTCFullYear(),4),t=B(i.getUTCMonth()+1,2),n=B(i.getUTCDate(),2),s=B(i.getUTCHours(),2),a=B(i.getUTCMinutes(),2),o=B(i.getUTCSeconds(),2);return`${e}-${t}-${n} ${s}:${a}:${o}`}function _e(i,e){const t=i??[],n=e??[];return t.length===n.length&&t.every((s,a)=>s===n[a])}function Oe(i){switch(i.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 ge(i,e){if(i.kind!=="dimension"&&i.kind!=="measure")throw new Error(`Cannot filter by field of type ${i.kind}`);const t=Oe(i);if(typeof e=="string")me(e,t);else if(e.kind!==t)throw new Error(`Invalid filter for field ${i.name}; expected type ${t}, but got ${e.kind}`)}function pe(i){if(i instanceof y)return i.getSourceInfo().schema;if(i instanceof E)throw new Error("unimplemented");return i.getInputSchema()}})(V)),V}var ke;function Qe(){return ke||(ke=1,(function(r){var q=$&&$.__createBinding||(Object.create?(function(w,g,l,p){p===void 0&&(p=l);var h=Object.getOwnPropertyDescriptor(g,l);(!h||("get"in h?!g.__esModule:h.writable||h.configurable))&&(h={enumerable:!0,get:function(){return g[l]}}),Object.defineProperty(w,p,h)}):(function(w,g,l,p){p===void 0&&(p=l),w[p]=g[l]})),N=$&&$.__exportStar||function(w,g){for(var l in w)l!=="default"&&!Object.prototype.hasOwnProperty.call(g,l)&&q(g,w,l)};Object.defineProperty(r,"__esModule",{value:!0}),N(xe(),r)})($)),$}var be=Qe();const Be=Ne(be),We=qe({__proto__:null,default:Be},[be]);export{be as d,We as i};