@malloy-publisher/sdk 0.0.22 → 0.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js
CHANGED
|
@@ -2880,7 +2880,7 @@ Vt.version="2.30.1";oor(Pi);Vt.fn=nr;Vt.min=Kar;Vt.max=Xar;Vt.now=Jar;Vt.utc=Sh;
|
|
|
2880
2880
|
|
|
2881
2881
|
If you want to hide the \`${u.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
2882
2882
|
|
|
2883
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${u.docsSlug}`;return Y.useEffect(()=>{a&&(document.getElementById(a)||console.error(d))},[d,a]),null},emr="DialogDescriptionWarning",tmr=({contentRef:a,descriptionId:u})=>{const f=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${dqe(emr).contentName}}.`;return Y.useEffect(()=>{var m;const g=(m=a.current)==null?void 0:m.getAttribute("aria-describedby");u&&g&&(document.getElementById(u)||console.warn(f))},[f,a,u]),null},rmr=ZBe,nmr=rqe,imr=nqe,smr=iqe,omr=oqe,amr=lqe;function fqe({rootQuery:a,view:u,target:d,open:f,setOpen:m}){const[g,x]=Pe.useState(""),{setQuery:E}=Pe.useContext(ai);if(Pe.useEffect(()=>{d&&x(d.name)},[d,f]),!d)return null;const v=()=>{d.name=g,E?.(a?.build()),m(!1)},{fields:_}=u.getOutputSchema(),S=g!==d.name&&_.some(R=>R.name===g);return D.jsxRuntimeExports.jsx(rmr,{open:f,onOpenChange:m,children:D.jsxRuntimeExports.jsx(nmr,{children:D.jsxRuntimeExports.jsx(imr,{className:"mly5uxqc1 mlyixxii4 mly13vifvy mlyu96u03 mly3m8u43 mly1ey2m1c mlyrvj5dj mly1ku5rj1 mly11uqc5h",children:D.jsxRuntimeExports.jsxs(smr,{...Lt.props(HO.content,Fr.body),children:[D.jsxRuntimeExports.jsxs(amr,{className:"mly1s85apg",children:["Rename ",d.name]}),D.jsxRuntimeExports.jsxs(omr,{className:"mly1j61zf2 mly1ghz6dp",children:["Rename ",d.name]}),D.jsxRuntimeExports.jsxs("div",{className:"mlyqyf9gi mly78zum5 mlydt5ytf mly167g77z",children:[D.jsxRuntimeExports.jsxs("div",{className:"mly78zum5 mly167g77z",children:[D.jsxRuntimeExports.jsx("input",{value:g,onChange:R=>x(R.target.value),...Lt.props({...HO.editorCell,...HO.input}),onKeyDown:R=>{R.key==="Enter"?v():R.key==="Esc"&&m(!1)}}),S&&D.jsxRuntimeExports.jsx(n$,{errorMessage:"Name already in use"})]}),D.jsxRuntimeExports.jsxs("div",{className:"mly78zum5 mly167g77z",children:[D.jsxRuntimeExports.jsx($i,{label:"Cancel",onClick:()=>m(!1),customStyle:HO.editorCell}),D.jsxRuntimeExports.jsx($i,{variant:"primary",label:"Rename",onClick:v,customStyle:HO.editorCell,disabled:S})]})]})]})})})})}const HO={content:{display:"mly78zum5",flexDirection:"mlydt5ytf",boxShadow:"mly5n1uv4",backgroundColor:"mly12peec7",borderRadius:"mlyur7f20",borderStartStartRadius:null,borderStartEndRadius:null,borderEndStartRadius:null,borderEndEndRadius:null,borderTopLeftRadius:null,borderTopRightRadius:null,borderBottomLeftRadius:null,borderBottomRightRadius:null,padding:"mlye8ttls",paddingInline:null,paddingStart:null,paddingLeft:null,paddingEnd:null,paddingRight:null,paddingBlock:null,paddingTop:null,paddingBottom:null,minWidth:"mlylm99nl",maxWidth:"mly1jkqq1h",gap:"mly167g77z",rowGap:null,columnGap:null,$$css:!0},editorCell:{flexGrow:"mly1iyjqo2",$$css:!0},input:{border:"mly2yh2zd",borderWidth:null,borderInlineWidth:null,borderInlineStartWidth:null,borderLeftWidth:null,borderInlineEndWidth:null,borderRightWidth:null,borderBlockWidth:null,borderTopWidth:null,borderBottomWidth:null,borderStyle:null,borderInlineStyle:null,borderInlineStartStyle:null,borderLeftStyle:null,borderInlineEndStyle:null,borderRightStyle:null,borderBlockStyle:null,borderTopStyle:null,borderBottomStyle:null,borderColor:null,borderInlineColor:null,borderInlineStartColor:null,borderLeftColor:null,borderInlineEndColor:null,borderRightColor:null,borderBlockColor:null,borderTopColor:null,borderBottomColor:null,color:"mlyizdh9v",padding:"mly9cpjcd",paddingInline:null,paddingStart:null,paddingLeft:null,paddingEnd:null,paddingRight:null,paddingBlock:null,paddingTop:null,paddingBottom:null,borderRadius:"mly1sxf85j",borderStartStartRadius:null,borderStartEndRadius:null,borderEndStartRadius:null,borderEndEndRadius:null,borderTopLeftRadius:null,borderTopRightRadius:null,borderBottomLeftRadius:null,borderBottomRightRadius:null,$$css:!0}};function hqe({rootQuery:a,segment:u,view:d,operations:f,kind:m}){const{setQuery:g}=Pe.useContext(ai),x=Tfr(Rfr(Ooe)),E=Pe.useMemo(()=>f.map(R=>({id:R.name,operation:R})),[f]);if(f.length===0)return null;function v(R){const N=u.operations.items.filter(P=>P instanceof Zr.ASTAggregateViewOperation||P instanceof Zr.ASTGroupByViewOperation||P instanceof Zr.ASTNestViewOperation).map(P=>P.name),{active:k,over:B}=R;if(B&&k.id!==B.id){const P=N.indexOf(k.id),$=N.indexOf(B.id);u.reorderFields(Noe(N,P,$)),g?.(a.build())}}const{fields:_}=eb(d),S=m==="group_by"?{title:"group by",actionTitle:"Add group by",types:["dimension"],onClick:(R,w)=>{$$(d,R,w),g?.(a.build())}}:{title:"aggregate",actionTitle:"Add aggregate",types:["measure"],onClick:(R,w)=>{B$(d,R,w),g?.(a.build())}};return D.jsxRuntimeExports.jsxs("div",{children:[D.jsxRuntimeExports.jsx(Gpr,{rootQuery:a,view:d,fields:_,...S}),D.jsxRuntimeExports.jsx("div",{...Lt.props(Id.tokenContainer),children:D.jsxRuntimeExports.jsx(Dhr,{sensors:x,collisionDetection:kfr,onDragEnd:v,children:D.jsxRuntimeExports.jsx(Uhr,{items:E,children:E.map(R=>D.jsxRuntimeExports.jsx(umr,{rootQuery:a,id:R.id,color:m==="group_by"?"cyan":"green",view:d,operation:R.operation},R.id))})})})]})}const lmr=[];function umr({rootQuery:a,id:u,view:d,operation:f,color:m}){var g;const{setQuery:x}=Pe.useContext(ai),E=f.getFieldInfo(),v=((g=f.field.getReference())==null?void 0:g.path)??lmr,{attributes:_,listeners:S,setNodeRef:R,transform:w,transition:N}=Yhr({id:u,data:{name:E.name}}),[k,B]=Pe.useState(!1),[P,$]=Pe.useState(),[q,z]=Pe.useState(!1),W={transform:B5.Transform.toString(w),transition:N},X=Pe.useMemo(()=>D.jsxRuntimeExports.jsxs(D.jsxRuntimeExports.Fragment,{children:[D.jsxRuntimeExports.jsx(boe,{trigger:D.jsxRuntimeExports.jsx($i,{variant:"flat",icon:"meatballs",size:"compact",tooltip:"More Actions"}),onOpenChange:z,children:[D.jsxRuntimeExports.jsx(M5,{label:"Rename",onClick:()=>{$(f),B(!0)}},"rename")]},[...v,E.name].join(".")),D.jsxRuntimeExports.jsx(DN,{onClick:()=>{f.delete(),x?.(a?.build())}})]}),[E,f,v,a,x]),J=fmr(E,f.field);let ee="orderBy";return(E.kind==="dimension"||E.kind==="measure")&&(ee=I$(E.type.kind)),D.jsxRuntimeExports.jsxs("div",{id:u,ref:R,style:W,children:[J?D.jsxRuntimeExports.jsxs(hN,{customStyle:hmr.tokenGroup,children:[D.jsxRuntimeExports.jsx($s,{color:m,icon:ee,label:E.name,dragProps:{attributes:_,listeners:S}}),D.jsxRuntimeExports.jsx(d$,{color:m,value:J.value,onChange:fe=>{f.field.expression instanceof Zr.ASTTimeTruncationExpression&&(f.field.expression.truncation=fe),x?.(a.build())},items:J.options})]}):D.jsxRuntimeExports.jsx(hS,{field:E,color:m,hoverActionsVisible:q,hoverActions:X,tooltip:D.jsxRuntimeExports.jsx(SM,{field:E,path:v}),tooltipProps:{side:"right",align:"start",alignOffset:28},dragProps:{attributes:_,listeners:S}}),D.jsxRuntimeExports.jsx(fqe,{rootQuery:a,view:d,target:P,open:k,setOpen:B})]})}const cmr=["day","week","month","quarter","year"],dmr=["second","minute","hour","day","week","month","quarter","year"];function fmr(a,u){return a.kind!=="dimension"||!(u.expression instanceof Zr.ASTTimeTruncationExpression)?null:a.type.kind==="timestamp_type"?{value:a.type.timeframe??"second",options:dmr.map(d=>({label:d,value:d}))}:a.type.kind==="date_type"?{value:a.type.timeframe??"day",options:cmr.map(d=>({label:d,value:d}))}:null}const hmr={tokenGroup:{display:"mly78zum5",$$css:!0}};function pmr({rootQuery:a,segment:u,view:d,groupBys:f}){return D.jsxRuntimeExports.jsx(hqe,{rootQuery:a,segment:u,view:d,operations:f,kind:"group_by"})}class mmr extends Y.Component{constructor(u){super(u),this.state={hasError:!1}}static getDerivedStateFromError(u){return{hasError:!0}}componentDidCatch(u,d){console.error(u,d)}render(){return this.state.hasError?this.props.fallback:this.props.children}}const pqe=(a,u)=>{if(a.parsed===null)return{op:"",value:u};let d="",f=u;switch(a.kind){case"boolean":{const m=a.parsed,{operator:g,not:x}=m;d=x?"is not":"is",f=g}break;case"string":{const m=a.parsed,{operator:g}=m;switch(g){case"~":d="is like",f=m.escaped_values.join(", ");break;case"=":{const{not:x,values:E}=m;d=x?"is not":"is",f=E.join(", ")}break;case"contains":{const{not:x,values:E}=m;d=x?"does not contain":"contains",f=E.join(", ")}break;case"starts":{const{not:x,values:E}=m;d=x?"does not start with":"starts with",f=E.join(", ")}break;case"ends":{const{not:x,values:E}=m;d=x?"does not end with":"ends with",f=E.join(", ")}break;case"empty":{const{not:x}=m;d=x?"is not empty":"is empty",f=""}break;case"null":{const{not:x}=m;d=x?"is not":"is",f="null"}break}}break;case"number":{const m=a.parsed,{operator:g}=m;switch(g){case"=":case"!=":case"<=":case">=":case"<":case">":d=g,f=m.values.join(", ");break;case"range":d="in between",f=m.startValue+" and "+m.endValue;break;case"null":d=m.not?"is not":"is",f="null";break}}break;case"date":case"timestamp":{const m=a.parsed,{operator:g}=m;switch(g){case"after":{const{not:x}=m;d=`is${x?" not":""} after`,f=one(m.after)}break;case"before":{const{not:x}=m;d=`is${x?" not":""} before`,f=one(m.before)}break;case"in":{const{not:x}=m;d=`is${x?" not":""} in`,f=one(m.in)}break;case"in_last":{const{not:x}=m;d=`is${x?" not":""} in last`,f=m.n+" "+m.units}break;case"last":{const{not:x}=m;d=`is${x?" not":""} last complete`,f=m.n+" "+m.units}break;case"next":{const{not:x}=m;d=`is${x?" not":""} next complete`,f=m.n+" "+m.units}break;case"for":{const{not:x}=m;d=`is${x?" not":""} for`,f=m.n+" "+m.units}break;case"null":d=m.not?"is not":"is",f="null";break}}}return{op:d,value:f}};function one(a){return a?a.moment==="literal"?a.literal:a.moment==="now"?"now":a.moment:""}function gmr({rootQuery:a,filters:u}){const{setQuery:d}=Pe.useContext(ai);return u.length===0?null:D.jsxRuntimeExports.jsxs("div",{children:[D.jsxRuntimeExports.jsx("div",{...Lt.props(Id.title),children:"filter by"}),D.jsxRuntimeExports.jsx("div",{...Lt.props(Id.tokenContainer),children:u.map((f,m)=>D.jsxRuntimeExports.jsx(mmr,{fallback:D.jsxRuntimeExports.jsxs("div",{children:["Invalid filter",D.jsxRuntimeExports.jsx(DN,{onClick:()=>{f.delete(),d?.(a.build())}})]}),children:D.jsxRuntimeExports.jsx(xmr,{filterOperation:f,rootQuery:a})},m))})]})}function xmr({rootQuery:a,filterOperation:u}){const{setQuery:d}=Pe.useContext(ai),f=Pe.useCallback(R=>{u.filter instanceof Zr.ASTFilterWithFilterString&&u.filter.setFilter(R),d?.(a.build())},[u.filter,a,d]);if(!(u.filter instanceof Zr.ASTFilterWithFilterString))return null;const{fieldReference:m,filterString:g}=u.filter,x=u.filter.getFilter(),E=m.getFieldInfo();if(E.kind!=="dimension"&&E.kind!=="measure")throw new Error(`Invalid filter field kind: ${E.kind}`);const{op:v,value:_}=pqe(x,g),S=`${E.name} ${v} ${_}`;return D.jsxRuntimeExports.jsxs("div",{...Lt.props(f0.main),children:[D.jsxRuntimeExports.jsx(U5,{fieldInfo:E,path:m.path??[],filter:x,setFilter:f,trigger:D.jsxRuntimeExports.jsx($s,{icon:"filter",color:"cyan",label:S}),layoutProps:{align:"start",side:"bottom",sideOffset:1}}),D.jsxRuntimeExports.jsx("div",{...Lt.props(f0.hoverActions),children:D.jsxRuntimeExports.jsx(DN,{onClick:()=>{u.delete(),d?.(a.build())}})})]})}function ymr({rootQuery:a,limit:u}){const{setQuery:d}=Pe.useContext(ai);return u?D.jsxRuntimeExports.jsxs("div",{children:[D.jsxRuntimeExports.jsx("div",{...Lt.props(Id.title),children:"limit"}),D.jsxRuntimeExports.jsxs("div",{...Lt.props(f0.main),children:[D.jsxRuntimeExports.jsx(Fne,{type:"number",value:u.limit,onChange:f=>{u.limit=f,d?.(a.build())},errorMessage:u.limit<0?"Limit must be positive":void 0}),D.jsxRuntimeExports.jsx("div",{...Lt.props(f0.hoverActions),children:D.jsxRuntimeExports.jsx(DN,{onClick:()=>{u.delete(),d?.(a.build())}})})]})]}):null}function vmr({rootQuery:a,segment:u,view:d,aggregates:f}){return D.jsxRuntimeExports.jsx(hqe,{rootQuery:a,segment:u,view:d,operations:f,kind:"aggregate"})}function bmr({rootQuery:a,orderBys:u}){const{setQuery:d}=Pe.useContext(ai);return u.length===0?null:D.jsxRuntimeExports.jsxs("div",{children:[D.jsxRuntimeExports.jsx("div",{...Lt.props(Id.title),children:"order by"}),D.jsxRuntimeExports.jsx("div",{...Lt.props(Id.tokenContainer),children:u.map(f=>{const{fieldReference:m}=f,g=m.getFieldInfo(),x=m.path??[];let E="orderBy";(g.kind==="dimension"||g.kind==="measure")&&(E=I$(g.type.kind));const v=gBe(g.kind);return D.jsxRuntimeExports.jsxs("div",{...Lt.props(f0.main),children:[D.jsxRuntimeExports.jsxs(hN,{children:[D.jsxRuntimeExports.jsx($s,{color:v,icon:E,label:g.name}),D.jsxRuntimeExports.jsx(d$,{color:v,items:[{label:"ascending",value:"asc"},{label:"descending",value:"desc"}],value:f.direction??"asc",onChange:_=>{f.direction=_,d?.(a.build())}})]}),D.jsxRuntimeExports.jsx("div",{...Lt.props(f0.hoverActions),children:D.jsxRuntimeExports.jsx(DN,{onClick:()=>{f.delete(),d?.(a.build())}})})]},[...x,g.name].join("."))})})]})}function Emr({rootQuery:a,view:u}){return D.jsxRuntimeExports.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[D.jsxRuntimeExports.jsx(qBe,{rootQuery:a,view:u}),D.jsxRuntimeExports.jsx(y5,{rootQuery:a,view:u,viewDef:u.definition})]})}function Pv({icon:a,label:u,detail:d,disable:f,onClick:m,open:g}){const x=f?.(),E=()=>{f?.()||m?.()};return D.jsxRuntimeExports.jsxs(oN,{children:[D.jsxRuntimeExports.jsx(aN,{asChild:!0,children:D.jsxRuntimeExports.jsxs("div",{role:"menuitem",tabIndex:-1,...Lt.props(Al.item,Al.clickable,g?_mr.open:null),onClick:E,"data-disabled":x?"true":void 0,children:[D.jsxRuntimeExports.jsxs("div",{...Lt.props(Al.label),children:[a,D.jsxRuntimeExports.jsx("div",{children:u})]}),g!==void 0&&D.jsxRuntimeExports.jsx(An,{name:"chevronRight",color:"gray"})]})}),d?D.jsxRuntimeExports.jsx(lN,{children:D.jsxRuntimeExports.jsx(uN,{...Lt.props(Al.tooltip),side:"right",align:"start",alignOffset:-16,children:d})}):null]})}const _mr={open:{background:"mly16o7sp0",backgroundAttachment:null,backgroundClip:null,backgroundColor:null,backgroundImage:null,backgroundOrigin:null,backgroundPosition:null,backgroundPositionX:null,backgroundPositionY:null,backgroundRepeat:null,backgroundSize:null,$$css:!0}};function Smr({rootQuery:a,view:u}){const{setQuery:d}=Pe.useContext(ai),f=h0(u),m=f?Fpr(f):!1;return D.jsxRuntimeExports.jsx(Pv,{icon:D.jsxRuntimeExports.jsx(An,{name:"limit"}),label:"Limit",disable:()=>m,onClick:()=>{u.getOrAddDefaultSegment().setLimit(10),d?.(a.build())}})}function Amr({rootQuery:a,view:u}){const{setQuery:d}=Pe.useContext(ai);return D.jsxRuntimeExports.jsx(Pv,{icon:D.jsxRuntimeExports.jsx(An,{name:"nest"}),label:"Add blank nested query",onClick:()=>{const f=u.getOrAddDefaultSegment(),m=Upr(f,"Nest");f.addEmptyNest(m>1?`Nest ${m}`:"Nest"),d?.(a.build())}})}function kN({view:a,fields:u,onAddOperation:d,types:f,filter:m,isFilterOperation:g,search:x}){return D.jsxRuntimeExports.jsx(Ioe,{types:f,filter:m,view:a,fields:u,onAddOperation:d,isFilterOperation:g,search:x,customStyle:Cmr.list})}const Cmr={list:{minWidth:"mly2ixbly",maxWidth:"mly1j9u4d2",$$css:!0}};function Rmr({rootQuery:a,view:u,search:d}){const{setQuery:f}=Pe.useContext(ai),m=u.getOutputSchema().fields,g=h0(u),x=Pe.useMemo(()=>m.filter(E=>E.kind==="dimension").filter(E=>Tmr.includes(E.type.kind)).filter(E=>g?!Mpr(g,E.name):!0),[m,g]);return D.jsxRuntimeExports.jsx(kN,{label:"Add order by",icon:"orderBy",view:u,fields:x,types:["dimension"],onAddOperation:E=>{Hpr(u,E),f?.(a.build())},disabledMessage:"There must be at least one field in the output to order by.",search:d})}const Tmr=["string_type","number_type","boolean_type","date_type","timestamp_type"];function wmr({rootQuery:a,view:u,search:d}){const{setQuery:f}=Pe.useContext(ai),{fields:m}=eb(u),g=h0(u),x=(E,v,_)=>!g?.hasField(v.name,_)&&kx(v);return D.jsxRuntimeExports.jsx(kN,{label:"Add group by",icon:"groupBy",view:u,fields:m,types:["dimension"],filter:x,onAddOperation:(E,v)=>{$$(u,E,v),f?.(a.build())},search:d})}function Omr({rootQuery:a,view:u,search:d}){const{setQuery:f}=Pe.useContext(ai),{fields:m}=eb(u),g=h0(u),x=(E,v,_)=>!g?.hasField(v.name,_)&&kx(v);return D.jsxRuntimeExports.jsx(kN,{label:"Add aggregate",icon:"aggregate",view:u,fields:m,types:["measure"],filter:x,onAddOperation:(E,v)=>{B$(u,E,v),f?.(a.build())},search:d})}function Nmr({view:a,search:u}){const{rootQuery:d,setQuery:f}=Y.useContext(ai),{fields:m}=eb(a);return D.jsxRuntimeExports.jsx(kN,{label:"Add filter",icon:"filter",view:a,fields:m,types:["measure","dimension"],filter:(g,x)=>(x.kind==="dimension"||x.kind==="measure")&&Dmr.has(x.type.kind)&&kx(x),onAddOperation:(g,x,E)=>{E&&(g.kind==="dimension"||g.kind==="measure")&&(XBe(a,g,x,E),f?.(d?.build()))},isFilterOperation:!0,search:u})}const Dmr=new Set(["string_type","boolean_type","number_type","date_type","timestamp_type"]);function kmr({rootQuery:a,view:u,search:d}){const{setQuery:f}=Pe.useContext(ai),m=eb(u).fields,g=Pe.useMemo(()=>m.filter(x=>x.kind==="view"&&!$Be(x)),[m]);return D.jsxRuntimeExports.jsx(kN,{label:"Add view",icon:"view",view:u,fields:g,types:["view"],filter:(x,E)=>kx(E),onAddOperation:x=>{a.isEmpty()?a.setView(x.name):Poe(u,x),f?.(a.build())},search:d})}function mqe({rootQuery:a,view:u}){const[d,f]=Pe.useState(!1),[m,g]=Pe.useState(""),{setQuery:x}=Pe.useContext(ai),[E,v]=Pe.useState(""),_=h0(u),S=R=>{g(R===m?"":R)};return D.jsxRuntimeExports.jsxs(AN,{open:d,onOpenChange:R=>{f(R),R||v("")},children:[D.jsxRuntimeExports.jsx(T$,{asChild:!0,children:D.jsxRuntimeExports.jsx($i,{icon:"insert",variant:"flat",size:"compact",onClick:()=>f(!d),tooltip:"Add query elements"})}),D.jsxRuntimeExports.jsx(CN,{children:D.jsxRuntimeExports.jsxs(w$,{onPointerDownOutside:()=>f(!1),...Lt.props(Al.content),side:"bottom",align:"start",role:"menu",children:[D.jsxRuntimeExports.jsx("div",{...Lt.props(Al.item),children:D.jsxRuntimeExports.jsx(c$,{icon:"search",value:E,onChange:v,placeholder:"Search...",customStyle:Lmr.search})}),D.jsxRuntimeExports.jsx(Y_,{}),D.jsxRuntimeExports.jsxs("div",{className:"mly78zum5 mly1odjw0f mlywib8y2 mly1xyq3li",children:[E&&!m?D.jsxRuntimeExports.jsxs("div",{className:"mly1odjw0f",children:[D.jsxRuntimeExports.jsx(Ioe,{view:u,fields:eb(u).fields,filter:(R,w,N)=>!_?.hasField(w.name,N)&&kx(w),types:["dimension","measure","view"],onAddOperation:function(R,w){R.kind==="dimension"?$$(u,R,w):R.kind==="measure"?B$(u,R,w):Poe(u,R),x?.(a.build())},search:E}),D.jsxRuntimeExports.jsx(Y_,{}),D.jsxRuntimeExports.jsx(VBe,{search:E,onClick:R=>{const w=R.fieldName.split("."),N=w.pop();u.getOrAddDefaultSegment().addWhere(N,w,{kind:"string",parsed:{operator:"=",values:[R.fieldValue??"∅"]}}),x?.(a.build())}})]}):D.jsxRuntimeExports.jsxs("div",{"data-testid":"add-menu-operations",className:"mly18kybhu",children:[D.jsxRuntimeExports.jsx(Pv,{icon:D.jsxRuntimeExports.jsx(An,{name:"groupBy"}),label:"Add group by",onClick:()=>S("group_by"),open:m==="group_by"}),D.jsxRuntimeExports.jsx(Pv,{icon:D.jsxRuntimeExports.jsx(An,{name:"aggregate"}),label:"Add aggregate",onClick:()=>S("aggregate"),open:m==="aggregate"}),D.jsxRuntimeExports.jsx(Pv,{icon:D.jsxRuntimeExports.jsx(An,{name:"filter"}),label:"Add filter",onClick:()=>S("where"),open:m==="where"}),D.jsxRuntimeExports.jsx(Pv,{icon:D.jsxRuntimeExports.jsx(An,{name:"view"}),label:"Add view",onClick:()=>S("view"),open:m==="view"}),D.jsxRuntimeExports.jsx(Y_,{}),D.jsxRuntimeExports.jsx(Smr,{rootQuery:a,view:u}),D.jsxRuntimeExports.jsx(Pv,{icon:D.jsxRuntimeExports.jsx(An,{name:"orderBy"}),label:"Order by",onClick:()=>S("order_by"),open:m==="order_by"}),D.jsxRuntimeExports.jsx(Amr,{rootQuery:a,view:u})]}),D.jsxRuntimeExports.jsxs("div",{"data-testid":"add-menu-right-column",style:{overflowY:"auto"},children:[m==="group_by"&&D.jsxRuntimeExports.jsx(wmr,{rootQuery:a,view:u,search:E}),m==="aggregate"&&D.jsxRuntimeExports.jsx(Omr,{rootQuery:a,view:u,search:E}),m==="where"&&D.jsxRuntimeExports.jsx(Nmr,{rootQuery:a,view:u,search:E}),m==="view"&&D.jsxRuntimeExports.jsx(kmr,{rootQuery:a,view:u,search:E}),m==="order_by"&&D.jsxRuntimeExports.jsx(Rmr,{rootQuery:a,view:u,search:E})]})]})]})})]})}const Lmr={search:{width:"mlyh8yej3",$$css:!0}},Sie=Pe.createContext([]);function gqe({children:a,nest:u}){const{focusNestView:d,focusMainView:f}=cN(),m=Pe.useContext(Sie);return D.jsxRuntimeExports.jsx("div",{onPointerDown:g=>{g.stopPropagation(),u?d([...m,u.name]):f()},children:u?D.jsxRuntimeExports.jsx(Sie.Provider,{value:[...m,u.name],children:D.jsxRuntimeExports.jsx("div",{children:a})}):D.jsxRuntimeExports.jsx("div",{children:a})})}function Imr({rootQuery:a,view:u,nests:d}){return d.length===0?null:D.jsxRuntimeExports.jsx("div",{...Lt.props(Id.tokenContainer),children:d.map(f=>D.jsxRuntimeExports.jsx(Pmr,{rootQuery:a,view:u,nest:f},f.name))})}function Pmr({rootQuery:a,view:u,nest:d}){const{setQuery:f}=Pe.useContext(ai),[m,g]=Pe.useState(!1),x=Pe.useContext(Sie),{focusNestView:E,isNestViewFocused:v}=cN(),_=S=>D.jsxRuntimeExports.jsxs(D.jsxRuntimeExports.Fragment,{children:[D.jsxRuntimeExports.jsxs(boe,{trigger:D.jsxRuntimeExports.jsx($i,{variant:"flat",icon:"meatballs",size:"compact",tooltip:"More Actions"}),children:[D.jsxRuntimeExports.jsx(M5,{icon:"clear",label:"Delete Query",onClick:()=>{E([...x]),S.delete(),f?.(a.build())}}),D.jsxRuntimeExports.jsx(M5,{label:"Rename",onClick:()=>{g(!0)}})]}),D.jsxRuntimeExports.jsx(mqe,{rootQuery:a,view:S.view})]});return D.jsxRuntimeExports.jsx(gqe,{nest:d,children:D.jsxRuntimeExports.jsxs("div",{className:"mlyj3b58b mly1yf7rl7 mly1xmf6yo mlyh8yej3",children:[D.jsxRuntimeExports.jsx(_se,{title:d.name,icon:xBe(d.view),defaultOpen:!0,controls:_(d),collapsedControls:_(d),isFocused:v([...x,d.name]),children:D.jsxRuntimeExports.jsx(Emr,{rootQuery:a,view:d.view})}),D.jsxRuntimeExports.jsx(fqe,{rootQuery:a,view:u,target:d,open:m,setOpen:g})]},d.name)})}function jmr({rootQuery:a,view:u,viewDef:d}){const f=[],m=[],g=[],x=[],E=[],v=[];let _;if(!(d instanceof Zr.ASTSegmentViewDefinition))return null;const S=d;return S.operations.items.forEach(R=>{R instanceof Zr.ASTGroupByViewOperation?f.push(R):R instanceof Zr.ASTAggregateViewOperation?m.push(R):R instanceof Zr.ASTWhereViewOperation||R instanceof Zr.ASTHavingViewOperation?x.push(R):R instanceof Zr.ASTOrderByViewOperation?E.push(R):R instanceof Zr.ASTNestViewOperation?v.push(R):R instanceof Zr.ASTDrillViewOperation?g.push(R):_=R}),D.jsxRuntimeExports.jsxs("div",{className:"mly1tpqehw mly10lvyaf",children:[D.jsxRuntimeExports.jsx(pmr,{rootQuery:a,segment:S,view:u,groupBys:f}),D.jsxRuntimeExports.jsx(vmr,{rootQuery:a,segment:S,view:u,aggregates:m}),D.jsxRuntimeExports.jsx(cfr,{rootQuery:a,drills:g}),D.jsxRuntimeExports.jsx(gmr,{rootQuery:a,filters:x}),D.jsxRuntimeExports.jsx(bmr,{rootQuery:a,orderBys:E}),D.jsxRuntimeExports.jsx(Imr,{rootQuery:a,view:u,nests:v}),D.jsxRuntimeExports.jsx(ymr,{rootQuery:a,limit:_})]})}function y5({rootQuery:a,view:u,viewDef:d}){return d instanceof Zr.ASTArrowViewDefinition?D.jsxRuntimeExports.jsx(y5,{rootQuery:a,view:u,viewDef:d.view}):d instanceof Zr.ASTRefinementViewDefinition?D.jsxRuntimeExports.jsxs("div",{children:[D.jsxRuntimeExports.jsx(y5,{rootQuery:a,view:u,viewDef:d.base}),D.jsxRuntimeExports.jsx(y5,{rootQuery:a,view:u,viewDef:d.refinement})]}):d instanceof Zr.ASTSegmentViewDefinition?D.jsxRuntimeExports.jsx(jmr,{rootQuery:a,view:u,viewDef:d}):D.jsxRuntimeExports.jsx(Fmr,{rootQuery:a,viewDef:d})}function Fmr({viewDef:a}){const[u,d]=Pe.useState(!1);return D.jsxRuntimeExports.jsxs("div",{...{0:{className:"mly78zum5 mlydt5ytf mly1cy8zhl mly1nhvcw1 mly12oqio5 mlygqa5hp mlyt7dq6l mlywib8y2 mly163pfp mlyy13l1i"},1:{className:"mly78zum5 mlydt5ytf mly1cy8zhl mly1nhvcw1 mly12oqio5 mlygqa5hp mlyt7dq6l mly163pfp mlyy13l1i mly18d9i69"}}[!!u<<0],children:[D.jsxRuntimeExports.jsxs("div",{className:"mlyrvj5dj mly1mt1orb mly1g3yg12 mlyydnxy5 mly6s0dn4 mlylqzeqv mly167g77z mly12oqio5 mlyc342km mly1n2onr6 mlyb3r6kr mlygqa5hp mlyh8yej3",children:[D.jsxRuntimeExports.jsx(An,{name:"query",color:"purple"}),D.jsxRuntimeExports.jsx("div",{className:"mlyuxw1ft mlyb3r6kr mlylyipyv",children:a.name}),D.jsxRuntimeExports.jsx($i,{icon:u?"chevronRight":"chevronDown",onClick:()=>d(!u),size:"compact"})]}),!u&&D.jsxRuntimeExports.jsx(Loe,{viewInfo:a.getViewInfo(),style:Mmr.preview})]})}const Mmr={preview:{height:"mlyt7dq6l",maxHeight:"mly1hkcv85",background:"mlyo6guvx",backgroundAttachment:null,backgroundClip:null,backgroundColor:null,backgroundImage:null,backgroundOrigin:null,backgroundPosition:null,backgroundPositionX:null,backgroundPositionY:null,backgroundRepeat:null,backgroundSize:null,borderRadius:"mly12oqio5",borderStartStartRadius:null,borderStartEndRadius:null,borderEndStartRadius:null,borderEndEndRadius:null,borderTopLeftRadius:null,borderTopRightRadius:null,borderBottomLeftRadius:null,borderBottomRightRadius:null,$$css:!0}};function $mr({rootQuery:a,query:u,setQuery:d}){const{focusMainView:f,isMainViewFocused:m}=cN();return D.jsxRuntimeExports.jsx(gqe,{children:D.jsxRuntimeExports.jsxs(_se,{title:"Main query",isFocused:m,controls:D.jsxRuntimeExports.jsxs(D.jsxRuntimeExports.Fragment,{children:[D.jsxRuntimeExports.jsx(boe,{trigger:D.jsxRuntimeExports.jsx($i,{variant:"flat",icon:"meatballs",size:"compact",tooltip:"More Actions"}),children:d?D.jsxRuntimeExports.jsxs(D.jsxRuntimeExports.Fragment,{children:[D.jsxRuntimeExports.jsx(M5,{icon:"clear",label:"Clear query",onClick:()=>{f(),d?.(void 0)},disabled:a.isEmpty()}),D.jsxRuntimeExports.jsx(M5,{icon:"nest",label:"Nest query",onClick:()=>{a.definition instanceof Zr.ASTArrowQueryDefinition&&a.definition.view.convertToNest("Nest"),d?.(a.build())},disabled:a.isEmpty()||!(a.definition instanceof Zr.ASTArrowQueryDefinition)})]}):D.jsxRuntimeExports.jsx(D.jsxRuntimeExports.Fragment,{})}),u.definition instanceof Zr.ASTArrowQueryDefinition?D.jsxRuntimeExports.jsx(mqe,{rootQuery:a,view:u.definition}):null]}),collapsedControls:D.jsxRuntimeExports.jsx(An,{name:xBe(u)}),children:[u.definition instanceof Zr.ASTArrowQueryDefinition?D.jsxRuntimeExports.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[!u.isEmpty()&&D.jsxRuntimeExports.jsx(qBe,{rootQuery:a,view:u}),D.jsxRuntimeExports.jsx(y5,{rootQuery:a,view:u.definition,viewDef:u.definition.view})]}):null,u.isEmpty()?D.jsxRuntimeExports.jsx("div",{className:"mly78zum5 mlyl56j7k mly6s0dn4 mlyng8ra",children:D.jsxRuntimeExports.jsxs("div",{className:"mly78zum5 mly6s0dn4 mlywzxoxx",children:[D.jsxRuntimeExports.jsx("div",{children:"Click"}),D.jsxRuntimeExports.jsx(An,{name:"insert",color:"disabled"}),D.jsxRuntimeExports.jsx("div",{children:"to get started"})]})}):null]})})}function Bmr({rootQuery:a}){return a.definition instanceof Zr.ASTArrowQueryDefinition?D.jsxRuntimeExports.jsx("div",{...Lt.props(Id.queryCard,qmr.content),children:D.jsxRuntimeExports.jsxs("div",{...Lt.props(Id.labelWithIcon),children:[D.jsxRuntimeExports.jsx(An,{name:"database"}),D.jsxRuntimeExports.jsx("div",{className:"mlyb3r6kr mlylyipyv mly117nqv4",children:a.definition.as.ArrowQueryDefinition().source.as.ReferenceQueryArrowSource().name})]})}):null}const qmr={content:{display:"mlyrvj5dj",gridAutoFlow:"mly1mt1orb",gridTemplateColumns:"mlybyjr8",gap:"mly1jnr06f",rowGap:null,columnGap:null,$$css:!0}};function Umr({value:a,setValue:u,customStyle:d}){const[f,m]=Pe.useState(""),[g,x]=Pe.useState(!1),E=Pe.useRef(null),v=Pe.useRef(null),_=a.kind==="date_literal",S=_?a.date_value:a.timestamp_value,R=_?"day":"second",w=N=>{N?(m(""),u(_?{kind:"date_literal",date_value:Vt.utc(N).format(fS.day)}:{kind:"timestamp_literal",timestamp_value:Vt.utc(N).format(fS.second)})):m("Invalid date")};return GBe([E,v],()=>{x(!1)}),D.jsxRuntimeExports.jsxs(AN,{open:g,onOpenChange:()=>{},children:[D.jsxRuntimeExports.jsx(T$,{asChild:!0,children:D.jsxRuntimeExports.jsx("div",{...Lt.props(Cx.main,GO.wrapper,d),children:D.jsxRuntimeExports.jsx(gM,{value:Vt.utc(S).toDate(),setValue:w,units:R,onFocus:()=>x(!0),customStyle:{...GO.input,..._?GO.dateInput:GO.timestampInput},forwardRef:E})})}),f&&D.jsxRuntimeExports.jsx(n$,{errorMessage:f}),D.jsxRuntimeExports.jsx(CN,{children:D.jsxRuntimeExports.jsx(w$,{align:"center",asChild:!0,children:D.jsxRuntimeExports.jsx(doe,{value:Vt.utc(S).toDate(),setValue:w,units:R,maxLevel:R,customStyle:GO.datePicker,forwardRef:v})})})]})}const GO={input:{border:"mly1gs6z28",borderWidth:null,borderInlineWidth:null,borderInlineStartWidth:null,borderLeftWidth:null,borderInlineEndWidth:null,borderRightWidth:null,borderBlockWidth:null,borderTopWidth:null,borderBottomWidth:null,borderStyle:null,borderInlineStyle:null,borderInlineStartStyle:null,borderLeftStyle:null,borderInlineEndStyle:null,borderRightStyle:null,borderBlockStyle:null,borderTopStyle:null,borderBottomStyle:null,borderColor:null,borderInlineColor:null,borderInlineStartColor:null,borderLeftColor:null,borderInlineEndColor:null,borderRightColor:null,borderBlockColor:null,borderTopColor:null,borderBottomColor:null,height:"mlyd7y6wv",backgroundColor:"mlyjbqb8w mlytw1abo",$$css:!0},dateInput:{width:"mly869kya",$$css:!0},timestampInput:{width:"mlynrytzq",$$css:!0},wrapper:{$$css:!0},datePicker:{display:"mly78zum5",flexDirection:"mlydt5ytf",boxShadow:"mly5n1uv4",backgroundColor:"mly12peec7",borderRadius:"mlyur7f20",borderStartStartRadius:null,borderStartEndRadius:null,borderEndStartRadius:null,borderEndEndRadius:null,borderTopLeftRadius:null,borderTopRightRadius:null,borderBottomLeftRadius:null,borderBottomRightRadius:null,width:"mly1hfn5x7",$$css:!0}};function zmr({filterType:a,value:u,setValue:d}){let f=null;switch(a){case"string_type":{const{parsed:_}=Xm.StringFilterExpression.parse(u.filter_expression_value);f={kind:"string",parsed:_}}break;case"number_type":{const{parsed:_}=Xm.NumberFilterExpression.parse(u.filter_expression_value);f={kind:"number",parsed:_}}break;case"boolean_type":{const{parsed:_}=Xm.BooleanFilterExpression.parse(u.filter_expression_value);f={kind:"boolean",parsed:_}}break;case"date_type":{const{parsed:_}=Xm.TemporalFilterExpression.parse(u.filter_expression_value);f={kind:"date",parsed:_}}break;case"timestamp_type":{const{parsed:_}=Xm.TemporalFilterExpression.parse(u.filter_expression_value);f={kind:"timestamp",parsed:_}}break}const{op:m,value:g}=pqe(f,u.filter_expression_value),x=`${m} ${g}`,E={kind:"dimension",name:"parameter",type:{kind:a}},v=_=>{switch(_.kind){case"string":d({kind:"filter_expression_literal",filter_expression_value:Xm.StringFilterExpression.unparse(_.parsed)});break;case"boolean":d({kind:"filter_expression_literal",filter_expression_value:Xm.BooleanFilterExpression.unparse(_.parsed)});break;case"number":d({kind:"filter_expression_literal",filter_expression_value:Xm.NumberFilterExpression.unparse(_.parsed)});break;case"date":case"timestamp":d({kind:"filter_expression_literal",filter_expression_value:Xm.TemporalFilterExpression.unparse(_.parsed)});break}};return D.jsxRuntimeExports.jsx(U5,{fieldInfo:E,path:[],filter:f,setFilter:v,trigger:D.jsxRuntimeExports.jsx($s,{label:x}),layoutProps:{align:"start",side:"bottom",sideOffset:1}})}function Hmr({value:a,filterType:u,setValue:d,customStyle:f}){if(!a)return null;switch(a.kind){case"boolean_literal":return D.jsxRuntimeExports.jsx(d$,{value:a.boolean_value?"true":"false",items:[{label:"true",value:"true"},{label:"false",value:"false"}],onChange:m=>d({kind:"boolean_literal",boolean_value:m==="true"}),customStyle:f});case"date_literal":case"timestamp_literal":return D.jsxRuntimeExports.jsx(Umr,{value:a,setValue:d,customStyle:f});case"null_literal":return D.jsxRuntimeExports.jsx($s,{label:"∅"});case"number_literal":return D.jsxRuntimeExports.jsx(Fne,{value:a.number_value,type:"number",onChange:m=>d({kind:"number_literal",number_value:m}),customStyle:f});case"string_literal":return D.jsxRuntimeExports.jsx(Fne,{value:a.string_value,onChange:m=>d({kind:"string_literal",string_value:m}),customStyle:f});case"filter_expression_literal":return D.jsxRuntimeExports.jsx(zmr,{value:a,filterType:u,setValue:d,customStyle:f})}}function Gmr({rootQuery:a}){const{setQuery:u}=Pe.useContext(ai);if(a.definition instanceof Zr.ASTArrowQueryDefinition){const d=a.definition.as.ArrowQueryDefinition().source.as.ReferenceQueryArrowSource(),f=d.getSourceParameters();return!f||f.length===0?null:D.jsxRuntimeExports.jsx(_se,{title:"Source parameters",children:D.jsxRuntimeExports.jsx("div",{className:"mly78zum5 mlydt5ytf mly1jnr06f mlynm25rq",children:f.map(m=>{var g;return D.jsxRuntimeExports.jsxs(hN,{customStyle:Wmr.tokenGroup,children:[D.jsxRuntimeExports.jsx($s,{icon:I$(m.type.kind),label:m.name}),D.jsxRuntimeExports.jsx(Hmr,{filterType:m.type.kind==="filter_expression_type"?m.type.filter_type.kind:"string_type",value:((g=d.tryGetParameter(m.name))==null?void 0:g.parameter.value)??m.default_value,setValue:x=>{d.setParameter(m.name,x),u?.(a.build())}})]},m.name)})})})}return null}const Wmr={tokenGroup:{display:"mly78zum5",$$css:!0}};function Vmr(){const{rootQuery:a,setQuery:u}=Pe.useContext(ai);return a?D.jsxRuntimeExports.jsxs("div",{...Lt.props(Fr.body,Qmr.main),children:[D.jsxRuntimeExports.jsx(Bmr,{rootQuery:a}),D.jsxRuntimeExports.jsx(Gmr,{rootQuery:a}),D.jsxRuntimeExports.jsx($mr,{rootQuery:a,query:a,setQuery:u})]}):(console.error("Missing <MalloyExplorerProvider>"),null)}const Qmr={main:{display:"mly78zum5",flexDirection:"mlydt5ytf",overflow:"mlyysyzu8",overflowX:null,overflowY:null,gap:"mly167g77z",rowGap:null,columnGap:null,padding:"mly1fut7tt",paddingInline:null,paddingStart:null,paddingLeft:null,paddingEnd:null,paddingRight:null,paddingBlock:null,paddingTop:null,paddingBottom:null,$$css:!0}};function Ymr({runQuery:a}){return D.jsxRuntimeExports.jsxs("div",{className:"mly78zum5 mlydt5ytf mly5yr21d mlyotlr4g mly1roky18",children:[D.jsxRuntimeExports.jsx(tfr,{runQuery:a}),D.jsxRuntimeExports.jsx(Vmr,{})]})}function Kmr({viewInfo:a,onClick:u}){const d=MBe(a.annotations??[]);return D.jsxRuntimeExports.jsx("div",{children:D.jsxRuntimeExports.jsx(htr,{header:D.jsxRuntimeExports.jsxs("div",{children:[D.jsxRuntimeExports.jsxs("div",{className:"mly78zum5 mly1q0g3np mly1qughib",children:[D.jsxRuntimeExports.jsx(Ex,{label:"view",icon:"view_filled",color:"purple",customStyle:K9e.viewBadge}),D.jsxRuntimeExports.jsx($i,{variant:"default",size:"compact",label:"Add",onClick:u})]}),D.jsxRuntimeExports.jsxs("div",{children:[D.jsxRuntimeExports.jsx("div",{...Lt.props(Fr.emphasized),children:a.name}),d&&D.jsxRuntimeExports.jsx(zBe,{text:d})]})]}),customStyle:K9e.card,children:D.jsxRuntimeExports.jsx(Loe,{viewInfo:a})})})}const K9e={viewBadge:{backgroundColor:"mlyjbqb8w",$$css:!0},card:{width:"mlyxsgkw5",$$css:!0}};function Xmr({views:a,onSelectView:u}){return D.jsxRuntimeExports.jsx("div",{className:"mly78zum5 mlydt5ytf mlyh8yej3 mly5yr21d mlyysyzu8",children:D.jsxRuntimeExports.jsxs("div",{className:"mly1bpp3o7 mly78zum5 mlydt5ytf mlyl56j7k mly6s0dn4",children:[D.jsxRuntimeExports.jsx("div",{...Lt.props(Jmr.header,Fr.emphasized),children:"Start with a Bookmarked View"}),D.jsxRuntimeExports.jsx("div",{className:"mly78zum5 mlyl56j7k mly6s0dn4 mly1a02dak mly883omv mlym6i5cn",children:a.filter(d=>!Doe(d.annotations??[])).slice(0,3).map(d=>D.jsxRuntimeExports.jsx(Kmr,{viewInfo:d,onClick:()=>{u(d)}},d.name))})]})})}const Jmr={header:{paddingBottom:"mly1l90r2v",$$css:!0}};var Boe="Tabs",[Zmr,kyr]=Md(Boe,[N$]),xqe=N$(),[e0r,qoe]=Zmr(Boe),yqe=Y.forwardRef((a,u)=>{const{__scopeTabs:d,value:f,onValueChange:m,defaultValue:g,orientation:x="horizontal",dir:E,activationMode:v="automatic",..._}=a,S=dN(E),[R,w]=Dx({prop:f,onChange:m,defaultProp:g});return D.jsxRuntimeExports.jsx(e0r,{scope:d,baseId:ic(),value:R,onValueChange:w,orientation:x,dir:S,activationMode:v,children:D.jsxRuntimeExports.jsx(rn.div,{dir:S,"data-orientation":x,..._,ref:u})})});yqe.displayName=Boe;var vqe="TabsList",bqe=Y.forwardRef((a,u)=>{const{__scopeTabs:d,loop:f=!0,...m}=a,g=qoe(vqe,d),x=xqe(d);return D.jsxRuntimeExports.jsx(j$e,{asChild:!0,...x,orientation:g.orientation,dir:g.dir,loop:f,children:D.jsxRuntimeExports.jsx(rn.div,{role:"tablist","aria-orientation":g.orientation,...m,ref:u})})});bqe.displayName=vqe;var Eqe="TabsTrigger",_qe=Y.forwardRef((a,u)=>{const{__scopeTabs:d,value:f,disabled:m=!1,...g}=a,x=qoe(Eqe,d),E=xqe(d),v=Cqe(x.baseId,f),_=Rqe(x.baseId,f),S=f===x.value;return D.jsxRuntimeExports.jsx(F$e,{asChild:!0,...E,focusable:!m,active:S,children:D.jsxRuntimeExports.jsx(rn.button,{type:"button",role:"tab","aria-selected":S,"aria-controls":_,"data-state":S?"active":"inactive","data-disabled":m?"":void 0,disabled:m,id:v,...g,ref:u,onMouseDown:xr(a.onMouseDown,R=>{!m&&R.button===0&&R.ctrlKey===!1?x.onValueChange(f):R.preventDefault()}),onKeyDown:xr(a.onKeyDown,R=>{[" ","Enter"].includes(R.key)&&x.onValueChange(f)}),onFocus:xr(a.onFocus,()=>{const R=x.activationMode!=="manual";!S&&!m&&R&&x.onValueChange(f)})})})});_qe.displayName=Eqe;var Sqe="TabsContent",Aqe=Y.forwardRef((a,u)=>{const{__scopeTabs:d,value:f,forceMount:m,children:g,...x}=a,E=qoe(Sqe,d),v=Cqe(E.baseId,f),_=Rqe(E.baseId,f),S=f===E.value,R=Y.useRef(S);return Y.useEffect(()=>{const w=requestAnimationFrame(()=>R.current=!1);return()=>cancelAnimationFrame(w)},[]),D.jsxRuntimeExports.jsx(Do,{present:m||S,children:({present:w})=>D.jsxRuntimeExports.jsx(rn.div,{"data-state":S?"active":"inactive","data-orientation":E.orientation,role:"tabpanel","aria-labelledby":v,hidden:!w,id:_,tabIndex:0,...x,ref:u,style:{...a.style,animationDuration:R.current?"0s":void 0},children:w&&g})})});Aqe.displayName=Sqe;function Cqe(a,u){return`${a}-trigger-${u}`}function Rqe(a,u){return`${a}-content-${u}`}var t0r=yqe,r0r=bqe,aF=_qe,lF=Aqe;const n0r={compiling:"Compiling",running:"Running",finished:"Finished",canceled:"Canceled"},i0r="start",s0r="bottom";function o0r({runInfo:a}){return D.jsxRuntimeExports.jsxs(oN,{children:[D.jsxRuntimeExports.jsx(aN,{asChild:!0,children:D.jsxRuntimeExports.jsxs("div",{...Lt.props(ane.triggerContentContainer,Fr.body),children:[D.jsxRuntimeExports.jsx(An,{name:"info",color:"disabled"})," Query run details"]})}),D.jsxRuntimeExports.jsx(lN,{children:D.jsxRuntimeExports.jsx(uN,{side:s0r,align:i0r,children:D.jsxRuntimeExports.jsx(HBe,{customStyle:ane.card,children:D.jsxRuntimeExports.jsxs(D.jsxRuntimeExports.Fragment,{children:[a.customContent,a?.performanceAspects&&Object.entries(a.performanceAspects).map(([u,d])=>D.jsxRuntimeExports.jsx("div",{children:Object.entries(d).map(([f,m])=>D.jsxRuntimeExports.jsxs("div",{children:[D.jsxRuntimeExports.jsxs("span",{...Lt.props(Fr.emphasized),children:[f,":"]})," ",D.jsxRuntimeExports.jsx("span",{...Lt.props(Fr.body),children:m})]},f))},u)),a.queryLink&&D.jsxRuntimeExports.jsx("a",{href:a.queryLink.href,target:"_blank",rel:"noreferrer",...Lt.props(ane.link,Fr.link),children:a.queryLink.linkText})]})})})})]})}const ane={card:{maxWidth:"mly1dc814f",$$css:!0},triggerContentContainer:{display:"mly3nfvp2",alignItems:"mly6s0dn4",justifyContent:"mlylqzeqv",$$css:!0},link:{backgroundColor:"mlyjbqb8w",border:"mly1gs6z28",borderWidth:null,borderInlineWidth:null,borderInlineStartWidth:null,borderLeftWidth:null,borderInlineEndWidth:null,borderRightWidth:null,borderBlockWidth:null,borderTopWidth:null,borderBottomWidth:null,borderStyle:null,borderInlineStyle:null,borderInlineStartStyle:null,borderLeftStyle:null,borderInlineEndStyle:null,borderRightStyle:null,borderBlockStyle:null,borderTopStyle:null,borderBottomStyle:null,borderColor:null,borderInlineColor:null,borderInlineStartColor:null,borderLeftColor:null,borderInlineEndColor:null,borderRightColor:null,borderBlockColor:null,borderTopColor:null,borderBottomColor:null,padding:"mly1717udv",paddingInline:null,paddingStart:null,paddingLeft:null,paddingEnd:null,paddingRight:null,paddingBlock:null,paddingTop:null,paddingBottom:null,cursor:"mly1ypdohk",textDecoration:"mly1hl2dhg",textDecorationColor:null,textDecorationLine:null,textDecorationStyle:null,textDecorationThickness:null,$$css:!0}};function a0r({source:a,query:u}){let d;switch(u.executionState){case"compiling":case"running":d=D.jsxRuntimeExports.jsx(d0r,{onCancel:u.onCancel,executionState:u.executionState,queryResolutionStartMillis:u.queryResolutionStartMillis});break;case"canceled":d=D.jsxRuntimeExports.jsx("div",{className:"mly78zum5 mlydt5ytf mlyh8yej3 mly5yr21d mlyl56j7k mly6s0dn4 mly1665zp3",children:D.jsxRuntimeExports.jsxs("div",{className:"mly78zum5 mlydt5ytf mly6s0dn4 mlyl56j7k mly167g77z",children:[D.jsxRuntimeExports.jsx("div",{...Lt.props(Fr.emphasized),children:"Query Canceled"}),D.jsxRuntimeExports.jsx("div",{...Lt.props(Fr.body),children:"Your query was canceled; nothing to display."})]})});break;case"finished":d=D.jsxRuntimeExports.jsx(l0r,{source:a,response:u.response});break}return d}function l0r({source:a,response:u}){let d=null;return u?u.error||u.messages?d=D.jsxRuntimeExports.jsx(u0r,{messages:[...u.error?[u.error]:[],...u.messages?u.messages:[]]}):u.result||(d=D.jsxRuntimeExports.jsx(hie,{title:"Empty Result",variant:"critical"})):d=D.jsxRuntimeExports.jsx(hie,{title:"Empty Response",variant:"critical"}),D.jsxRuntimeExports.jsxs("div",{className:"mly78zum5 mlydt5ytf mly167g77z mly5yr21d",children:[u?.runInfo&&D.jsxRuntimeExports.jsx(o0r,{runInfo:u.runInfo}),d,u?.result&&D.jsxRuntimeExports.jsx(c0r,{result:u.result,source:a})]})}function u0r({messages:a}){return D.jsxRuntimeExports.jsx("div",{children:a.map(u=>{let d=null;if(u.customRenderer)d=u.customRenderer;else{let f;switch(u.severity){case"DEBUG":case"INFO":f="info";break;case"WARN":f="warn";break;case"ERROR":case"FATAL":f="critical";break;default:f="critical"}d=D.jsxRuntimeExports.jsx(hie,{title:u.title,description:u.description,variant:f,children:u.content})}return D.jsxRuntimeExports.jsx("div",{children:d},u.title)})})}function c0r({result:a,source:u}){const[d,f]=Pe.useState(),{onDrill:m,setQuery:g}=Pe.useContext(ai);return Pe.useEffect(()=>{const x=document.createElement("malloy-render");x.malloyResult=a,x.onDrill=({stableQuery:E,stableDrillClauses:v})=>{if(m){m({stableQuery:E,stableDrillClauses:v});return}const _=new Zr.ASTQuery({query:E,source:u});g?.(_.build())},x.tableConfig={enableDrill:!0},f(x)},[m,a,u,g]),d?D.jsxRuntimeExports.jsx(TMe,{element:d,style:{overflow:"hidden",height:"100%"}}):D.jsxRuntimeExports.jsx("div",{className:"mly78zum5 mlyl56j7k mly6s0dn4",children:D.jsxRuntimeExports.jsxs("div",{className:"mly78zum5 mlydt5ytf mlyl56j7k mly6s0dn4 mly167g77z",children:[D.jsxRuntimeExports.jsx(wMe,{size:"large"}),D.jsxRuntimeExports.jsx("div",{...Lt.props(Fr.emphasized),children:"Rendering..."})]})})}function d0r({onCancel:a,executionState:u,queryResolutionStartMillis:d}){const f=f0r(d);return D.jsxRuntimeExports.jsxs("div",{className:"mly78zum5 mlydt5ytf mlyh8yej3 mly5yr21d mlyl56j7k mly6s0dn4 mly1665zp3",children:[D.jsxRuntimeExports.jsxs("div",{className:"mly78zum5 mlydt5ytf mly6s0dn4 mlyl56j7k mly167g77z",children:[D.jsxRuntimeExports.jsx(wMe,{size:"large",customStyle:h0r.spinner}),D.jsxRuntimeExports.jsx("div",{...Lt.props(Fr.emphasized),children:`${n0r[u]} query...`}),D.jsxRuntimeExports.jsx("div",{...Lt.props(Fr.body),children:`Total time elapsed: ${(f/1e3).toFixed(0)}s`})]}),D.jsxRuntimeExports.jsx($i,{onClick:a,label:"Cancel Query"})]})}function f0r(a){const[u,d]=Y.useState(Date.now()-a);return Y.useEffect(()=>{const f=setInterval(()=>{d(Date.now()-a)},1e3);return()=>clearInterval(f)},[a]),u}const h0r={spinner:{marginBottom:"mly1e56ztr",$$css:!0}};function p0r({query:a,debug:u}){var d;const[f,m]=Pe.useState((d=u?.debuggers)==null?void 0:d.at(0));return D.jsxRuntimeExports.jsxs("div",{children:[!!u?.debuggers.length&&D.jsxRuntimeExports.jsxs("div",{className:"mly78zum5 mly167g77z mly6s0dn4",children:[D.jsxRuntimeExports.jsx("div",{...Lt.props(Fr.largeBody),children:"Debug with:"}),D.jsxRuntimeExports.jsx(Hx,{options:u.debuggers.map(g=>({label:g,value:g})),value:f,onChange:g=>m(g)}),D.jsxRuntimeExports.jsx($i,{variant:"default",label:"Run",isDisabled:!f,onClick:()=>f&&u.onDebugQuery(a,f)})]}),D.jsxRuntimeExports.jsx(iie,{code:JSON.stringify(a,null,2),language:"json"})]})}const m0r=800;function g0r({text:a,label:u}){const[d,f]=Pe.useState(!1);return Pe.useEffect(()=>{if(!d)return()=>{};const m=setTimeout(()=>{f(!1)},m0r);return()=>{clearTimeout(m),f(!1)}},[d]),D.jsxRuntimeExports.jsx($i,{variant:"flat",size:"compact",label:d?"Copied!":u,icon:"copy",isDisabled:d,onClick:()=>{navigator.clipboard.writeText(a).then(()=>f(!0))}})}var is=function(a){return a.RESULTS="Results",a.MALLOY="Malloy",a.SQL="SQL",a.RAW_QUERY="Raw Query",a}(is||{});function x0r({source:a,draftQuery:u,setDraftQuery:d,submittedQuery:f,options:m}){var g,x,E;const[v,_]=Pe.useState(is.MALLOY),S=(g=Sje(a,u))==null?void 0:g.toMalloy(),R=a.schema.fields.filter(k=>k.kind==="view"),w=f!==void 0;!w&&(v===is.RESULTS||v===is.SQL)&&_(is.MALLOY),Pe.useEffect(()=>{_(is.RESULTS)},[f]);const N=(()=>{var k,B;return v===is.MALLOY&&S?S:v===is.SQL&&((B=(k=f?.response)==null?void 0:k.result)!=null&&B.sql)?f.response.result.sql:v===is.RAW_QUERY?JSON.stringify(u):null})();return u||f?D.jsxRuntimeExports.jsxs(t0r,{...Lt.props(lh.tabRoot,Fr.body),value:v,onValueChange:k=>_(k),children:[D.jsxRuntimeExports.jsxs("div",{className:"mly78zum5 mly1q0g3np mly1qughib mly6s0dn4 mly153ncpu",children:[D.jsxRuntimeExports.jsxs(r0r,{className:"mly78zum5 mly6s0dn4 mly167g77z",children:[D.jsxRuntimeExports.jsx(aF,{value:is.RESULTS,disabled:!w,...Lt.props(Fr.body,lh.tab,!w&&lh.disabledTab),title:w?void 0:"Run a query to see the results.",children:is.RESULTS}),D.jsxRuntimeExports.jsx(aF,{value:is.MALLOY,...Lt.props(Fr.body,lh.tab),children:is.MALLOY}),D.jsxRuntimeExports.jsx(aF,{value:is.SQL,disabled:!w,...Lt.props(Fr.body,lh.tab,!w&&lh.disabledTab),title:w?void 0:"Run a query to see generated SQL.",children:is.SQL}),m?.showRawQuery&&D.jsxRuntimeExports.jsx(aF,{value:is.RAW_QUERY,...Lt.props(Fr.body,lh.tab),children:is.RAW_QUERY})]}),v!==is.RESULTS&&N&&D.jsxRuntimeExports.jsx(g0r,{text:N,label:"Copy Code"})]}),D.jsxRuntimeExports.jsxs("div",{className:"mly1iyjqo2 mlyb3r6kr",children:[D.jsxRuntimeExports.jsx(lF,{value:is.RESULTS,className:"mlyc7ga6q mlyh8yej3 mly5yr21d mly9f619",children:f&&D.jsxRuntimeExports.jsxs(D.jsxRuntimeExports.Fragment,{children:[u&&f&&!y0r(u,f.query)&&D.jsxRuntimeExports.jsxs("div",{...Lt.props(lh.warning,Fr.body),children:[D.jsxRuntimeExports.jsx(An,{name:"warning",color:"warning",customStyle:lh.warningIcon}),D.jsxRuntimeExports.jsxs("div",{children:[D.jsxRuntimeExports.jsx("span",{children:"Query was updated. Run query to see new result or"}),D.jsxRuntimeExports.jsx("button",{...Lt.props(lh.warningAction,Fr.link),onClick:()=>{d(f.query)},children:" revert "}),D.jsxRuntimeExports.jsx("span",{children:"to the last run query."})]})]}),D.jsxRuntimeExports.jsx(a0r,{source:a,query:f})]})}),D.jsxRuntimeExports.jsx(lF,{value:is.MALLOY,className:"mlywp4ipm mlyh8yej3 mly5yr21d mly9f619",children:D.jsxRuntimeExports.jsx(iie,{code:S??"",language:"malloy"})}),D.jsxRuntimeExports.jsx(lF,{value:is.SQL,className:"mlywp4ipm mlyh8yej3 mly5yr21d mly9f619",children:((E=(x=f?.response)==null?void 0:x.result)==null?void 0:E.sql)&&D.jsxRuntimeExports.jsx(iie,{code:f.response.result.sql,language:"sql"})}),m?.showRawQuery&&D.jsxRuntimeExports.jsx(lF,{value:is.RAW_QUERY,className:"mlywp4ipm mlyh8yej3 mly5yr21d mly9f619",children:D.jsxRuntimeExports.jsx(p0r,{query:u,debug:m.debugOptions?{debuggers:m.debugOptions.debuggers,onDebugQuery:m.debugOptions.onDebugQuery}:void 0})})]})]}):D.jsxRuntimeExports.jsx(Xmr,{views:R,onSelectView:k=>d(v0r(k.name,a.name))})}function y0r(a,u){return JSON.stringify(a)===JSON.stringify(u)}function v0r(a,u){return{definition:{kind:"arrow",source:{kind:"source_reference",name:u},view:{kind:"view_reference",name:a}}}}const lh={tabRoot:{height:"mly5yr21d",width:"mlyh8yej3",display:"mly78zum5",flexDirection:"mlydt5ytf",$$css:!0},tab:{border:"mly1gs6z28",borderWidth:null,borderInlineWidth:null,borderInlineStartWidth:null,borderLeftWidth:null,borderInlineEndWidth:null,borderRightWidth:null,borderBlockWidth:null,borderTopWidth:null,borderBottomWidth:null,borderStyle:null,borderInlineStyle:null,borderInlineStartStyle:null,borderLeftStyle:null,borderInlineEndStyle:null,borderRightStyle:null,borderBlockStyle:null,borderTopStyle:null,borderBottomStyle:null,borderColor:null,borderInlineColor:null,borderInlineStartColor:null,borderLeftColor:null,borderInlineEndColor:null,borderRightColor:null,borderBlockColor:null,borderTopColor:null,borderBottomColor:null,padding:"mlydqdrvq",paddingInline:null,paddingStart:null,paddingLeft:null,paddingEnd:null,paddingRight:null,paddingBlock:null,paddingTop:null,paddingBottom:null,borderRadius:"mlyur7f20",borderStartStartRadius:null,borderStartEndRadius:null,borderEndStartRadius:null,borderEndEndRadius:null,borderTopLeftRadius:null,borderTopRightRadius:null,borderBottomLeftRadius:null,borderBottomRightRadius:null,backgroundColor:"mlyjbqb8w",cursor:"mly1ypdohk",":is([data-state='active'])_color":"mlyb0tsu4",":is([data-state='active'])_fontWeight":"mly1uifvsu",":is([data-state='active'])_backgroundColor":"mly14vaotu",$$css:!0},disabledTab:{color:"mly1jwwhvr",cursor:"mly1ipiool",$$css:!0},warning:{display:"mly78zum5",alignItems:"mly6s0dn4",marginBottom:"mly1e56ztr",$$css:!0},warningAction:{backgroundColor:"mlyjbqb8w",border:"mly1gs6z28",borderWidth:null,borderInlineWidth:null,borderInlineStartWidth:null,borderLeftWidth:null,borderInlineEndWidth:null,borderRightWidth:null,borderBlockWidth:null,borderTopWidth:null,borderBottomWidth:null,borderStyle:null,borderInlineStyle:null,borderInlineStartStyle:null,borderLeftStyle:null,borderInlineEndStyle:null,borderRightStyle:null,borderBlockStyle:null,borderTopStyle:null,borderBottomStyle:null,borderColor:null,borderInlineColor:null,borderInlineStartColor:null,borderLeftColor:null,borderInlineEndColor:null,borderRightColor:null,borderBlockColor:null,borderTopColor:null,borderBottomColor:null,padding:"mly1717udv",paddingInline:null,paddingStart:null,paddingLeft:null,paddingEnd:null,paddingRight:null,paddingBlock:null,paddingTop:null,paddingBottom:null,cursor:"mly1ypdohk",$$css:!0},warningIcon:{paddingRight:"mlyy13l1i",paddingInlineStart:null,paddingInlineEnd:null,$$css:!0}};function v5(a,u=[]){return a.flatMap(d=>{switch(d.kind){case"view":return $Be(d)?[]:u.length>0?[]:[{path:u,field:d}];case"measure":case"dimension":return d.type.kind==="array_type"&&d.type.element_type.kind==="record_type"?[{path:u,field:d},...v5(d.type.element_type.fields.map(f=>({kind:d.kind,...f})),[...u,d.name])]:d.type.kind==="record_type"?[{path:u,field:d},...v5(d.type.fields.map(f=>({kind:d.kind,...f})),[...u,d.name])]:[{path:u,field:d}];case"join":return v5(d.schema.fields,[...u,d.name]);default:return[]}})}function b0r(a){return v5(a.schema.fields)}function Tqe(a,u){return Object.values(u.reduce((d,f)=>{const m=[a.name,...f.path].join(".");return d[m]||(d[m]={groupPath:f.path,items:[]}),d[m].items.push(f),d},{}))}function wqe(a){return Object.values(a.reduce((u,d)=>{const f=d.field.kind;return u[f]||(u[f]={group:f,items:[]}),u[f].items.push(d),u},{}))}const E0r={view:"Views",measure:"Measures",dimension:"Dimensions"};function _0r(a,u,d){const f=M$(d,u.name),g=Pe.useMemo(()=>{const{fields:S}=eb(a),R=d.join(".");return v5(S).filter(w=>w.path.join(".")===R)},[d,a]).find(S=>u.name===S.field.name),x=Pe.useMemo(()=>{const S=h0(a);return g?.field.kind!=="dimension"?"Grouping is only available on a dimenion.":S?.hasField(u.name,d)?"Cannot group by a field already in the view.":kx(u)?"":"This field is annotated with #NO_UI."},[a,g?.field.kind,u,d]),E=Pe.useMemo(()=>{if(g?.field.kind!=="measure")return"Aggregation only supports measure fields.";const S=h0(a);return S?.hasField(u.name,d)?"This field is already used in the query.":kx(u)?"":"This field is annotated with #NO_UI."},[g?.field.kind,a,u,d]),v=Pe.useMemo(()=>g?["dimension","measure"].includes(g.field.kind)?S0r.includes(g.field.type.kind)?"":"Filtering only supports string, boolean, number, date and time fields.":"Filtering is only available for a dimension or measure.":`Unexpected Error: Could not find a field ${f}.`,[f,g]),_=Pe.useMemo(()=>{if(!g)return`Unexpected Error: Could not find a field ${f}.`;const S=h0(a);return S&&$pr(S,d,u.name)?"Query is already ordered by this field.":!S||!qpr(S,d,u.name)?"Order by is only available for fields in the output.":["dimension","measure"].includes(g.field.kind)?A0r.includes(g.field.type.kind)?"":"Order By only supports string, boolean, number, date and time fields.":"Order By is only available for dimension or measure fields."},[g,a,d,u.name,f]);return{isGroupByAllowed:!x,groupByDisabledReason:x,isAggregateAllowed:!E,aggregateDisabledReason:E,isFilterAllowed:!v,filterDisabledReason:v,isOrderByAllowed:!_,orderByDisabledReason:_}}const S0r=["string_type","boolean_type","number_type","date_type","timestamp_type"],A0r=["string_type","number_type","boolean_type","date_type","timestamp_type"];function Oqe({field:a,path:u,viewDef:d}){const{rootQuery:f,setQuery:m}=Pe.useContext(ai),{focusedNestView:g}=cN(),x=g??d,{groupByDisabledReason:E,aggregateDisabledReason:v,filterDisabledReason:_,orderByDisabledReason:S}=_0r(x,a,u),[R,w]=Pe.useState(),[N,k]=Pe.useState(!1),B=(q,z)=>{(a.kind==="dimension"||a.kind==="measure")&&(q==="groupBy"&&!E?$$(x,a,u):q==="aggregate"&&!v?B$(x,a,u):q==="orderBy"&&!S?zpr(x,u,a.name):q==="filter"&&!_&&z&&XBe(x,a,u,z),m?.(f?.build()))},P=()=>{a.kind==="view"&&f?.isEmpty()&&(f?.setView(a.name),m?.(f?.build()))},$=()=>{a.kind==="view"&&(Poe(x,a),m?.(f?.build()))};return D.jsxRuntimeExports.jsx(hS,{field:a,hoverActions:a.kind==="view"?D.jsxRuntimeExports.jsxs(D.jsxRuntimeExports.Fragment,{children:[D.jsxRuntimeExports.jsx(hx,{icon:"insert",disabled:!f?.isEmpty(),onClick:P,tooltip:f?.isEmpty()?"Add view":"Can only add a view to an empty query.",onTooltipOpenChange:k}),D.jsxRuntimeExports.jsx(hx,{icon:"nest",onClick:$,tooltip:"Add as new nested query",onTooltipOpenChange:k})]}):a.kind==="measure"?D.jsxRuntimeExports.jsxs(D.jsxRuntimeExports.Fragment,{children:[D.jsxRuntimeExports.jsx(hx,{icon:"aggregate",tooltip:v||"Add as aggregate",disabled:!!v,onClick:()=>B("aggregate"),onTooltipOpenChange:k}),D.jsxRuntimeExports.jsx(U5,{fieldInfo:a,path:u,setFilter:q=>B("filter",q),trigger:D.jsxRuntimeExports.jsx(hx,{icon:"filter",tooltip:_||"Add as filter",disabled:!!_,onTooltipOpenChange:k}),onOpenChange:w}),D.jsxRuntimeExports.jsx(hx,{icon:"orderBy",tooltip:S||"Add as order by",disabled:!!S,onClick:()=>B("orderBy"),onTooltipOpenChange:k})]}):a.kind==="dimension"?D.jsxRuntimeExports.jsxs(D.jsxRuntimeExports.Fragment,{children:[D.jsxRuntimeExports.jsx(hx,{icon:"groupBy",tooltip:E||"Add as group by",disabled:!!E,onClick:()=>B("groupBy"),onTooltipOpenChange:k}),D.jsxRuntimeExports.jsx(U5,{fieldInfo:a,path:u,setFilter:q=>B("filter",q),trigger:D.jsxRuntimeExports.jsx(hx,{icon:"filter",tooltip:_||"Add as filter",disabled:!!_,onTooltipOpenChange:k}),onOpenChange:w}),D.jsxRuntimeExports.jsx(hx,{icon:"orderBy",tooltip:S||"Add as order by",disabled:!!S,onClick:()=>B("orderBy"),onTooltipOpenChange:k})]}):null,onClick:a.kind==="dimension"&&!E?()=>B("groupBy"):a.kind==="measure"&&!v?()=>B("aggregate"):a.kind==="view"?()=>{f?.isEmpty()?P():$()}:void 0,hoverActionsVisible:R||N,tooltip:D.jsxRuntimeExports.jsx(SM,{field:a,path:u}),tooltipProps:{side:"right",align:"start",alignOffset:28}})}function hx({tooltip:a,onTooltipOpenChange:u,...d}){return D.jsxRuntimeExports.jsxs(LS,{delayDuration:300,onOpenChange:u,children:[D.jsxRuntimeExports.jsx(IS,{asChild:!0,children:D.jsxRuntimeExports.jsx($i,{variant:"flat",size:"compact",...d})}),D.jsxRuntimeExports.jsx(PS,{children:D.jsxRuntimeExports.jsx(jS,{sideOffset:8,...Lt.props(Fr.body,g0.default),children:a})})]})}const X9e=["dimension","measure","view"];function C0r({source:a,items:u}){const d=Y.useMemo(()=>wqe(u).sort((g,x)=>X9e.indexOf(g.group)-X9e.indexOf(x.group)).map(g=>({...g,items:Tqe(a,g.items)})),[a,u]),{rootQuery:f}=Y.useContext(ai),m=f?.definition;return m instanceof Zr.ASTArrowQueryDefinition?D.jsxRuntimeExports.jsxs("div",{className:"mly78zum5 mlydt5ytf mly1cy8zhl mlyou54vl mlye8ttls mly10cdfl8",children:[D.jsxRuntimeExports.jsx("div",{...Lt.props(Fr.body,J9e.heading),children:`${u.length} result${u.length>1?"s":""}`}),d.map(({group:g,items:x})=>D.jsxRuntimeExports.jsxs("div",{children:[D.jsxRuntimeExports.jsx("div",{...Lt.props(Fr.body,J9e.groupTitle),children:E0r[g]}),D.jsxRuntimeExports.jsx("div",{className:"mly78zum5 mlydt5ytf mlyou54vl",children:x.map(({groupPath:E,items:v})=>Pe.createElement("div",{className:"mly78zum5 mlydt5ytf mly1jnr06f",key:E.join(".")},D.jsxRuntimeExports.jsx("div",{...Lt.props(Fr.supporting),children:E.join(" > ")}),v.map(({field:_,path:S})=>D.jsxRuntimeExports.jsx(Oqe,{field:_,path:S,viewDef:m},[...S,_.name].join(".")))))})]},g))]}):null}const J9e={heading:{fontWeight:"mly1xlr1w8",$$css:!0},groupTitle:{fontWeight:"mly1xlr1w8",fontSize:"mlyfifm61",$$css:!0}},R0r=(a,u)=>u.at(-1)??a.name,T0r=(a,u)=>u.length>0?`joined to ${[...u.slice(0,-1),a.name].join(" > ")}`:void 0;function lne({source:a,fieldItems:u,fieldGroupType:d}){const f=Y.useMemo(()=>a?wqe(u).map(E=>({...E,items:Tqe(a,E.items)})):[],[a,u]),m=Y.useMemo(()=>{var E;return((E=f.find(({group:v})=>v===d))==null?void 0:E.items)??[]},[f,d]),{rootQuery:g}=Y.useContext(ai),x=g?.definition;return x instanceof Zr.ASTArrowQueryDefinition?D.jsxRuntimeExports.jsx("div",{className:"mly78zum5 mlydt5ytf mly167g77z",children:D.jsxRuntimeExports.jsx(pZt,{children:m.map((E,v)=>D.jsxRuntimeExports.jsx(gtr,{label:R0r(a,E.groupPath),sublabel:T0r(a,E.groupPath),isInitiallyExpanded:v===0,children:E.items.map(({field:_,path:S})=>D.jsxRuntimeExports.jsx(Oqe,{field:_,path:S,viewDef:x},[...S,_.name].join(".")))},E.groupPath.join(".")))})}):null}function w0r({onRefresh:a}){const{source:u}=Y.useContext(ai),[d,f]=Y.useState(""),{onCollapse:m}=Pe.useContext(L$),g=Y.useMemo(()=>u?b0r(u).filter(R=>!Doe(R.field.annotations??[])):[],[u]),x=g.filter(R=>R.field.kind==="view"),E=g.filter(R=>R.field.kind==="measure"),v=g.filter(R=>R.field.kind==="dimension"),_=Y.useMemo(()=>{if(d){const R=d.toLocaleLowerCase();return g.filter(w=>w.field.name.toLocaleLowerCase().includes(R))}return[]},[g,d]),S=!!d;return u?D.jsxRuntimeExports.jsxs("div",{className:"mly78zum5 mlydt5ytf mly5yr21d mly1gzqxud mlyfuqftd",children:[D.jsxRuntimeExports.jsxs("div",{...Lt.props(Fr.body,Z9e.header),children:[D.jsxRuntimeExports.jsxs("div",{className:"mly78zum5 mly1qughib",children:[D.jsxRuntimeExports.jsxs("div",{className:"mly78zum5 mly6s0dn4 mly167g77z mlydqdrvq mlyb3r6kr",children:[D.jsxRuntimeExports.jsx(An,{name:"database",color:"gray"}),D.jsxRuntimeExports.jsx("div",{...Lt.props(Fr.largeBody,Z9e.title),children:u.name})]}),D.jsxRuntimeExports.jsxs("div",{className:"mly78zum5",children:[D.jsxRuntimeExports.jsx($i,{icon:"refresh",tooltip:"Refresh the source",onClick:a,size:"compact",variant:"flat"}),m&&D.jsxRuntimeExports.jsx($i,{icon:"sidebarCollapse",tooltip:"Close the source panel",onClick:m,size:"compact",variant:"flat"})]})]}),D.jsxRuntimeExports.jsx(c$,{value:d,onChange:R=>f(R),placeholder:"Search",size:"compact",icon:"search",hasClear:!0})]}),D.jsxRuntimeExports.jsx(Y_,{}),D.jsxRuntimeExports.jsx("div",{className:"mly78zum5 mlydt5ytf mlyysyzu8 mly1iyjqo2",children:S?D.jsxRuntimeExports.jsx(C0r,{source:u,items:_}):D.jsxRuntimeExports.jsxs(Tcr,{defaultExpandedItemId:"views",children:[D.jsxRuntimeExports.jsx(Jre,{id:"dimensions",label:"Dimensions",startIcon:D.jsxRuntimeExports.jsx(An,{name:"dimension",color:"cyan"}),badge:D.jsxRuntimeExports.jsx(Ex,{label:v.length.toString(),color:"cyan"}),children:D.jsxRuntimeExports.jsx(lne,{source:u,fieldItems:g,fieldGroupType:"dimension"})},"dimensions"),D.jsxRuntimeExports.jsx(Jre,{id:"measures",label:"Measures",startIcon:D.jsxRuntimeExports.jsx(An,{name:"measure",color:"green"}),badge:D.jsxRuntimeExports.jsx(Ex,{label:E.length.toString(),color:"green"}),children:D.jsxRuntimeExports.jsx(lne,{source:u,fieldItems:g,fieldGroupType:"measure"})},"measures"),D.jsxRuntimeExports.jsx(Jre,{id:"views",label:"Views",startIcon:D.jsxRuntimeExports.jsx(An,{name:"view",color:"purple"}),badge:D.jsxRuntimeExports.jsx(Ex,{label:x.length.toString(),color:"purple"}),children:D.jsxRuntimeExports.jsx(lne,{source:u,fieldItems:g,fieldGroupType:"view"})},"views")]})})]}):null}const Z9e={header:{display:"mly78zum5",flexDirection:"mlydt5ytf",padding:"mlye8ttls",paddingInline:null,paddingStart:null,paddingLeft:null,paddingEnd:null,paddingRight:null,paddingBlock:null,paddingTop:null,paddingBottom:null,gap:"mly167g77z",rowGap:null,columnGap:null,$$css:!0},title:{overflow:"mlyb3r6kr",overflowX:null,overflowY:null,textOverflow:"mlylyipyv",fontWeight:"mly1xlr1w8",color:"mly1ue28sr",$$css:!0}};function O0r({icon:a,title:u,tooltip:d}){const{onExpand:f}=Y.useContext(L$);return D.jsxRuntimeExports.jsx("div",{className:"mly78zum5 mlydt5ytf mly7a106z mlylqzeqv mly5yr21d mly1gzqxud mlyfuqftd",children:D.jsxRuntimeExports.jsxs("div",{className:"mly78zum5 mlydt5ytf mly6s0dn4 mlyl56j7k mly167g77z mlye8ttls",children:[D.jsxRuntimeExports.jsx($i,{icon:a,variant:"flat",size:"compact",tooltip:d,onClick:f}),u&&D.jsxRuntimeExports.jsx("div",{...Lt.props(Fr.body,N0r.title),children:u})]})})}const N0r={title:{fontWeight:"mly1xlr1w8",cursor:"mlyt0e3qv","writing-mode":"mly35i7",$$css:!0}};function eIe({isInitiallyExpanded:a=!0,initialWidth:u,minWidth:d,icon:f,title:m,children:g}){const[x,E]=Y.useState(a),[v,_]=Y.useState(u),S=!x;return D.jsxRuntimeExports.jsxs(L$.Provider,{value:{onExpand:()=>E(!0),onCollapse:()=>E(!1)},children:[D.jsxRuntimeExports.jsxs("div",{...{0:{className:"mly1n2onr6 mly5yr21d mly3psx0u"},1:{className:"mly1n2onr6 mly5yr21d mly3psx0u mly1s85apg"}}[!!S<<0],style:{width:`${v}px`},children:[g,D.jsxRuntimeExports.jsx(Acr,{width:v,minWidth:d,onWidthChange:_})]}),S&&D.jsxRuntimeExports.jsx(O0r,{icon:f,title:m})]})}const D0r=new sIe(new Oo),k0r=new D.QueryClient,L0r=D.styled(D.Box)(({theme:a})=>({display:"flex",flexWrap:"wrap",gap:a.spacing(.5),borderBottom:`1px solid ${a.palette.divider}`,minHeight:36})),I0r=D.styled(D.Button)(({theme:a,selected:u})=>({minHeight:36,padding:a.spacing(.5,2),borderRadius:a.shape.borderRadius,background:u?a.palette.action.selected:"none",color:u?a.palette.primary.main:a.palette.text.primary,fontWeight:u?600:400,border:u?`1px solid ${a.palette.primary.main}`:"1px solid transparent",boxShadow:u?a.shadows[1]:"none",textTransform:"uppercase","&:hover":{background:a.palette.action.hover,border:`1px solid ${a.palette.primary.light}`}}));function Uoe({sourceAndPaths:a,saveResult:u,existingQuery:d,existingSourceName:f}){const[m,g]=Pe.useState(f?a.findIndex(v=>v.sourceInfo.name===f):0),[x,E]=Pe.useState(d||jF());return D.jsxRuntimeExports.jsxs(mo,{variant:"outlined",children:[D.jsxRuntimeExports.jsx(Va,{children:D.jsxRuntimeExports.jsxs(D.Stack$1,{sx:{flexDirection:"row",justifyContent:"space-between"},children:[a.length>0&&D.jsxRuntimeExports.jsx(L0r,{children:a.map((v,_)=>D.jsxRuntimeExports.jsx(I0r,{selected:m===_,onClick:()=>g(_),children:v.sourceInfo.name||`Source ${_+1}`},v.sourceInfo.name||_))}),u&&D.jsxRuntimeExports.jsx(D.CardActions,{sx:{padding:"0px 10px 0px 10px",mb:"auto",mt:"auto"},children:D.jsxRuntimeExports.jsx(D.Button,{onClick:()=>u(a[m].modelPath,a[m].sourceInfo.name,x),children:"Save"})})]})}),D.jsxRuntimeExports.jsx(mS,{children:D.jsxRuntimeExports.jsxs(D.Stack$1,{spacing:2,component:"section",children:[D.jsxRuntimeExports.jsx(zoe,{sourceAndPath:a[m],existingQuery:x,onChange:E}),D.jsxRuntimeExports.jsx(D.Box,{height:"5px"})]})})]})}function jF(){return{query:void 0,malloyQuery:void 0,malloyResult:void 0}}function zoe({sourceAndPath:a,onChange:u,existingQuery:d}){const[f,m]=Pe.useState(d||jF()),[g,x]=Pe.useState([]);Pe.useEffect(()=>{u&&u(f)},[u,f]);const{server:E,projectName:v,packageName:_,versionId:S,accessToken:R}=gS(),w=D.useMutation({mutationFn:()=>{const P=new Zr.ASTQuery({source:a.sourceInfo,query:f?.malloyQuery}).toMalloy();return m({...f,query:P}),D0r.executeQuery(v,_,a.modelPath,P,void 0,void 0,S,{baseURL:E,withCredentials:!R,headers:{Authorization:R&&`Bearer ${R}`}})},onSuccess:P=>{if(P){const $=JSON.parse(P.data.result);m({...f,malloyResult:$})}}},k0r),[N,k]=Pe.useState(a.sourceInfo.name);if(Pe.useEffect(()=>{N!==a.sourceInfo.name&&(k(a.sourceInfo.name),m(jF()))},[a,N]),N!==a.sourceInfo.name)return D.jsxRuntimeExports.jsx("div",{children:"Loading..."});const B=Pe.useCallback(P=>{m({...f,malloyQuery:P})},[f]);return D.jsxRuntimeExports.jsx(tVt,{children:D.jsxRuntimeExports.jsx(rVt,{children:D.jsxRuntimeExports.jsx(GXt,{source:a.sourceInfo,query:f?.malloyQuery,onQueryChange:B,focusedNestViewPath:g,onFocusedNestViewPathChange:x,onDrill:P=>{console.info(P),window.alert("Drill!")},children:D.jsxRuntimeExports.jsx("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:D.jsxRuntimeExports.jsxs("div",{style:{display:"flex",height:"100%",overflowY:"auto"},children:[D.jsxRuntimeExports.jsx(eIe,{isInitiallyExpanded:!0,initialWidth:280,minWidth:180,icon:"database",title:a.sourceInfo.name,children:D.jsxRuntimeExports.jsx(w0r,{onRefresh:()=>m(jF())})}),D.jsxRuntimeExports.jsx(eIe,{isInitiallyExpanded:!0,initialWidth:360,minWidth:280,icon:"filterSliders",title:"Query",children:D.jsxRuntimeExports.jsx(Ymr,{runQuery:()=>{w.mutate(),window.alert(f.malloyQuery)}})}),D.jsxRuntimeExports.jsx(x0r,{source:a.sourceInfo,draftQuery:f?.malloyQuery,setDraftQuery:P=>m({...f,malloyQuery:P}),submittedQuery:f?.malloyQuery?{executionState:w.isPending?"running":"finished",response:{result:f.malloyResult},query:f.malloyQuery,queryResolutionStartMillis:Date.now(),onCancel:w.reset}:void 0,options:{showRawQuery:!0}})]})})})})},a.sourceInfo.name)}const P0r=new TM(new Oo),j0r=new D.QueryClient;function F0r({modelPath:a,expandResults:u,hideResultIcons:d,expandEmbeddings:f,hideEmbeddingIcons:m}){const[g,x]=Pe.useState(!1),[E,v]=Pe.useState(),[_,S]=Pe.useState(0),{server:R,projectName:w,packageName:N,versionId:k,accessToken:B}=gS(),P=M0r(R,N,a);Pe.useEffect(()=>{zv(P,"typescript").then(X=>{v(X)})},[g,P]);const{data:$,isError:q,isLoading:z,error:W}=D.useQuery({queryKey:["package",R,w,N,a,k],queryFn:()=>P0r.getModel(w,N,a,k,{baseURL:R,withCredentials:!B,headers:{Authorization:B&&`Bearer ${B}`}})},j0r);return z?D.jsxRuntimeExports.jsx(D.Typography,{sx:{p:"20px",m:"auto"},children:"Fetching Model..."}):q?D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",sx:{p:"10px",m:"auto"},children:`${N} > ${a} > ${k} - ${W.message}`}):D.jsxRuntimeExports.jsxs(mo,{variant:"outlined",children:[D.jsxRuntimeExports.jsxs(Va,{children:[D.jsxRuntimeExports.jsxs(D.Stack,{sx:{flexDirection:"row",justifyContent:"space-between"},children:[Array.isArray($.data.sourceInfos)&&$.data.sourceInfos.length>0&&D.jsxRuntimeExports.jsx(D.Tabs,{value:_,onChange:(X,J)=>S(J),variant:"scrollable",scrollButtons:"auto",sx:{borderBottom:1,borderColor:"divider",minHeight:36},children:$.data.sourceInfos.map((X,J)=>{let ee;try{ee=JSON.parse(X)}catch{ee={name:String(J)}}return D.jsxRuntimeExports.jsx(D.Tab,{label:ee.name||`Source ${J+1}`,sx:{minHeight:36}},ee.name||J)})}),D.jsxRuntimeExports.jsx(D.CardActions,{sx:{padding:"0px 10px 0px 10px",mb:"auto",mt:"auto"},children:D.jsxRuntimeExports.jsx(D.Tooltip,{title:g?"Hide Embedding":"View Embedding",children:D.jsxRuntimeExports.jsx(D.IconButton,{size:"small",onClick:()=>{x(!g)},children:D.jsxRuntimeExports.jsx(D.LinkOutlinedIcon,{})})})})]}),D.jsxRuntimeExports.jsxs(D.Collapse,{in:g,timeout:"auto",unmountOnExit:!0,children:[D.jsxRuntimeExports.jsx(D.Divider,{}),D.jsxRuntimeExports.jsxs(D.Stack,{sx:{p:"10px",borderRadius:0,flexDirection:"row",justifyContent:"space-between"},children:[D.jsxRuntimeExports.jsx(D.Typography,{sx:{fontSize:"12px","& .line":{textWrap:"wrap"}},children:D.jsxRuntimeExports.jsx("div",{dangerouslySetInnerHTML:{__html:E}})}),D.jsxRuntimeExports.jsx(D.Tooltip,{title:"Copy Embeddable Code",children:D.jsxRuntimeExports.jsx(D.IconButton,{sx:{width:"24px",height:"24px"},onClick:()=>{navigator.clipboard.writeText(P)},children:D.jsxRuntimeExports.jsx(D.ContentCopyIcon,{})})})]})]}),D.jsxRuntimeExports.jsx(D.Divider,{})]}),D.jsxRuntimeExports.jsx(mS,{children:D.jsxRuntimeExports.jsxs(D.Stack,{spacing:2,component:"section",children:[Array.isArray($.data.sourceInfos)&&$.data.sourceInfos.length>0&&D.jsxRuntimeExports.jsx(zoe,{sourceAndPath:{modelPath:a,sourceInfo:JSON.parse($.data.sourceInfos[_])}}),$.data.queries?.length>0&&D.jsxRuntimeExports.jsxs(mo,{variant:"outlined",sx:{padding:"0px 10px 0px 10px"},children:[D.jsxRuntimeExports.jsx(Va,{sx:{p:"10px"},children:D.jsxRuntimeExports.jsx(D.Typography,{variant:"subtitle1",children:"Named Queries"})}),D.jsxRuntimeExports.jsx(D.Stack,{spacing:1,component:"section",children:$.data.queries.map(X=>D.jsxRuntimeExports.jsx(ZWt,{server:R,projectName:w,packageName:N,modelPath:a,versionId:k,queryName:X.name,expandResult:u,hideResultIcon:d,expandEmbedding:f,hideEmbeddingIcon:m,accessToken:B,noView:!0,annotations:X.annotations},X.name))}),D.jsxRuntimeExports.jsx(D.Box$1,{height:"10px"})]}),D.jsxRuntimeExports.jsx(D.Box$1,{height:"5px"})]})})]})}function M0r(a,u,d){return`<Model
|
|
2883
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${u.docsSlug}`;return Y.useEffect(()=>{a&&(document.getElementById(a)||console.error(d))},[d,a]),null},emr="DialogDescriptionWarning",tmr=({contentRef:a,descriptionId:u})=>{const f=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${dqe(emr).contentName}}.`;return Y.useEffect(()=>{var m;const g=(m=a.current)==null?void 0:m.getAttribute("aria-describedby");u&&g&&(document.getElementById(u)||console.warn(f))},[f,a,u]),null},rmr=ZBe,nmr=rqe,imr=nqe,smr=iqe,omr=oqe,amr=lqe;function fqe({rootQuery:a,view:u,target:d,open:f,setOpen:m}){const[g,x]=Pe.useState(""),{setQuery:E}=Pe.useContext(ai);if(Pe.useEffect(()=>{d&&x(d.name)},[d,f]),!d)return null;const v=()=>{d.name=g,E?.(a?.build()),m(!1)},{fields:_}=u.getOutputSchema(),S=g!==d.name&&_.some(R=>R.name===g);return D.jsxRuntimeExports.jsx(rmr,{open:f,onOpenChange:m,children:D.jsxRuntimeExports.jsx(nmr,{children:D.jsxRuntimeExports.jsx(imr,{className:"mly5uxqc1 mlyixxii4 mly13vifvy mlyu96u03 mly3m8u43 mly1ey2m1c mlyrvj5dj mly1ku5rj1 mly11uqc5h",children:D.jsxRuntimeExports.jsxs(smr,{...Lt.props(HO.content,Fr.body),children:[D.jsxRuntimeExports.jsxs(amr,{className:"mly1s85apg",children:["Rename ",d.name]}),D.jsxRuntimeExports.jsxs(omr,{className:"mly1j61zf2 mly1ghz6dp",children:["Rename ",d.name]}),D.jsxRuntimeExports.jsxs("div",{className:"mlyqyf9gi mly78zum5 mlydt5ytf mly167g77z",children:[D.jsxRuntimeExports.jsxs("div",{className:"mly78zum5 mly167g77z",children:[D.jsxRuntimeExports.jsx("input",{value:g,onChange:R=>x(R.target.value),...Lt.props({...HO.editorCell,...HO.input}),onKeyDown:R=>{R.key==="Enter"?v():R.key==="Esc"&&m(!1)}}),S&&D.jsxRuntimeExports.jsx(n$,{errorMessage:"Name already in use"})]}),D.jsxRuntimeExports.jsxs("div",{className:"mly78zum5 mly167g77z",children:[D.jsxRuntimeExports.jsx($i,{label:"Cancel",onClick:()=>m(!1),customStyle:HO.editorCell}),D.jsxRuntimeExports.jsx($i,{variant:"primary",label:"Rename",onClick:v,customStyle:HO.editorCell,disabled:S})]})]})]})})})})}const HO={content:{display:"mly78zum5",flexDirection:"mlydt5ytf",boxShadow:"mly5n1uv4",backgroundColor:"mly12peec7",borderRadius:"mlyur7f20",borderStartStartRadius:null,borderStartEndRadius:null,borderEndStartRadius:null,borderEndEndRadius:null,borderTopLeftRadius:null,borderTopRightRadius:null,borderBottomLeftRadius:null,borderBottomRightRadius:null,padding:"mlye8ttls",paddingInline:null,paddingStart:null,paddingLeft:null,paddingEnd:null,paddingRight:null,paddingBlock:null,paddingTop:null,paddingBottom:null,minWidth:"mlylm99nl",maxWidth:"mly1jkqq1h",gap:"mly167g77z",rowGap:null,columnGap:null,$$css:!0},editorCell:{flexGrow:"mly1iyjqo2",$$css:!0},input:{border:"mly2yh2zd",borderWidth:null,borderInlineWidth:null,borderInlineStartWidth:null,borderLeftWidth:null,borderInlineEndWidth:null,borderRightWidth:null,borderBlockWidth:null,borderTopWidth:null,borderBottomWidth:null,borderStyle:null,borderInlineStyle:null,borderInlineStartStyle:null,borderLeftStyle:null,borderInlineEndStyle:null,borderRightStyle:null,borderBlockStyle:null,borderTopStyle:null,borderBottomStyle:null,borderColor:null,borderInlineColor:null,borderInlineStartColor:null,borderLeftColor:null,borderInlineEndColor:null,borderRightColor:null,borderBlockColor:null,borderTopColor:null,borderBottomColor:null,color:"mlyizdh9v",padding:"mly9cpjcd",paddingInline:null,paddingStart:null,paddingLeft:null,paddingEnd:null,paddingRight:null,paddingBlock:null,paddingTop:null,paddingBottom:null,borderRadius:"mly1sxf85j",borderStartStartRadius:null,borderStartEndRadius:null,borderEndStartRadius:null,borderEndEndRadius:null,borderTopLeftRadius:null,borderTopRightRadius:null,borderBottomLeftRadius:null,borderBottomRightRadius:null,$$css:!0}};function hqe({rootQuery:a,segment:u,view:d,operations:f,kind:m}){const{setQuery:g}=Pe.useContext(ai),x=Tfr(Rfr(Ooe)),E=Pe.useMemo(()=>f.map(R=>({id:R.name,operation:R})),[f]);if(f.length===0)return null;function v(R){const N=u.operations.items.filter(P=>P instanceof Zr.ASTAggregateViewOperation||P instanceof Zr.ASTGroupByViewOperation||P instanceof Zr.ASTNestViewOperation).map(P=>P.name),{active:k,over:B}=R;if(B&&k.id!==B.id){const P=N.indexOf(k.id),$=N.indexOf(B.id);u.reorderFields(Noe(N,P,$)),g?.(a.build())}}const{fields:_}=eb(d),S=m==="group_by"?{title:"group by",actionTitle:"Add group by",types:["dimension"],onClick:(R,w)=>{$$(d,R,w),g?.(a.build())}}:{title:"aggregate",actionTitle:"Add aggregate",types:["measure"],onClick:(R,w)=>{B$(d,R,w),g?.(a.build())}};return D.jsxRuntimeExports.jsxs("div",{children:[D.jsxRuntimeExports.jsx(Gpr,{rootQuery:a,view:d,fields:_,...S}),D.jsxRuntimeExports.jsx("div",{...Lt.props(Id.tokenContainer),children:D.jsxRuntimeExports.jsx(Dhr,{sensors:x,collisionDetection:kfr,onDragEnd:v,children:D.jsxRuntimeExports.jsx(Uhr,{items:E,children:E.map(R=>D.jsxRuntimeExports.jsx(umr,{rootQuery:a,id:R.id,color:m==="group_by"?"cyan":"green",view:d,operation:R.operation},R.id))})})})]})}const lmr=[];function umr({rootQuery:a,id:u,view:d,operation:f,color:m}){var g;const{setQuery:x}=Pe.useContext(ai),E=f.getFieldInfo(),v=((g=f.field.getReference())==null?void 0:g.path)??lmr,{attributes:_,listeners:S,setNodeRef:R,transform:w,transition:N}=Yhr({id:u,data:{name:E.name}}),[k,B]=Pe.useState(!1),[P,$]=Pe.useState(),[q,z]=Pe.useState(!1),W={transform:B5.Transform.toString(w),transition:N},X=Pe.useMemo(()=>D.jsxRuntimeExports.jsxs(D.jsxRuntimeExports.Fragment,{children:[D.jsxRuntimeExports.jsx(boe,{trigger:D.jsxRuntimeExports.jsx($i,{variant:"flat",icon:"meatballs",size:"compact",tooltip:"More Actions"}),onOpenChange:z,children:[D.jsxRuntimeExports.jsx(M5,{label:"Rename",onClick:()=>{$(f),B(!0)}},"rename")]},[...v,E.name].join(".")),D.jsxRuntimeExports.jsx(DN,{onClick:()=>{f.delete(),x?.(a?.build())}})]}),[E,f,v,a,x]),J=fmr(E,f.field);let ee="orderBy";return(E.kind==="dimension"||E.kind==="measure")&&(ee=I$(E.type.kind)),D.jsxRuntimeExports.jsxs("div",{id:u,ref:R,style:W,children:[J?D.jsxRuntimeExports.jsxs(hN,{customStyle:hmr.tokenGroup,children:[D.jsxRuntimeExports.jsx($s,{color:m,icon:ee,label:E.name,dragProps:{attributes:_,listeners:S}}),D.jsxRuntimeExports.jsx(d$,{color:m,value:J.value,onChange:fe=>{f.field.expression instanceof Zr.ASTTimeTruncationExpression&&(f.field.expression.truncation=fe),x?.(a.build())},items:J.options})]}):D.jsxRuntimeExports.jsx(hS,{field:E,color:m,hoverActionsVisible:q,hoverActions:X,tooltip:D.jsxRuntimeExports.jsx(SM,{field:E,path:v}),tooltipProps:{side:"right",align:"start",alignOffset:28},dragProps:{attributes:_,listeners:S}}),D.jsxRuntimeExports.jsx(fqe,{rootQuery:a,view:d,target:P,open:k,setOpen:B})]})}const cmr=["day","week","month","quarter","year"],dmr=["second","minute","hour","day","week","month","quarter","year"];function fmr(a,u){return a.kind!=="dimension"||!(u.expression instanceof Zr.ASTTimeTruncationExpression)?null:a.type.kind==="timestamp_type"?{value:a.type.timeframe??"second",options:dmr.map(d=>({label:d,value:d}))}:a.type.kind==="date_type"?{value:a.type.timeframe??"day",options:cmr.map(d=>({label:d,value:d}))}:null}const hmr={tokenGroup:{display:"mly78zum5",$$css:!0}};function pmr({rootQuery:a,segment:u,view:d,groupBys:f}){return D.jsxRuntimeExports.jsx(hqe,{rootQuery:a,segment:u,view:d,operations:f,kind:"group_by"})}class mmr extends Y.Component{constructor(u){super(u),this.state={hasError:!1}}static getDerivedStateFromError(u){return{hasError:!0}}componentDidCatch(u,d){console.error(u,d)}render(){return this.state.hasError?this.props.fallback:this.props.children}}const pqe=(a,u)=>{if(a.parsed===null)return{op:"",value:u};let d="",f=u;switch(a.kind){case"boolean":{const m=a.parsed,{operator:g,not:x}=m;d=x?"is not":"is",f=g}break;case"string":{const m=a.parsed,{operator:g}=m;switch(g){case"~":d="is like",f=m.escaped_values.join(", ");break;case"=":{const{not:x,values:E}=m;d=x?"is not":"is",f=E.join(", ")}break;case"contains":{const{not:x,values:E}=m;d=x?"does not contain":"contains",f=E.join(", ")}break;case"starts":{const{not:x,values:E}=m;d=x?"does not start with":"starts with",f=E.join(", ")}break;case"ends":{const{not:x,values:E}=m;d=x?"does not end with":"ends with",f=E.join(", ")}break;case"empty":{const{not:x}=m;d=x?"is not empty":"is empty",f=""}break;case"null":{const{not:x}=m;d=x?"is not":"is",f="null"}break}}break;case"number":{const m=a.parsed,{operator:g}=m;switch(g){case"=":case"!=":case"<=":case">=":case"<":case">":d=g,f=m.values.join(", ");break;case"range":d="in between",f=m.startValue+" and "+m.endValue;break;case"null":d=m.not?"is not":"is",f="null";break}}break;case"date":case"timestamp":{const m=a.parsed,{operator:g}=m;switch(g){case"after":{const{not:x}=m;d=`is${x?" not":""} after`,f=one(m.after)}break;case"before":{const{not:x}=m;d=`is${x?" not":""} before`,f=one(m.before)}break;case"in":{const{not:x}=m;d=`is${x?" not":""} in`,f=one(m.in)}break;case"in_last":{const{not:x}=m;d=`is${x?" not":""} in last`,f=m.n+" "+m.units}break;case"last":{const{not:x}=m;d=`is${x?" not":""} last complete`,f=m.n+" "+m.units}break;case"next":{const{not:x}=m;d=`is${x?" not":""} next complete`,f=m.n+" "+m.units}break;case"for":{const{not:x}=m;d=`is${x?" not":""} for`,f=m.n+" "+m.units}break;case"null":d=m.not?"is not":"is",f="null";break}}}return{op:d,value:f}};function one(a){return a?a.moment==="literal"?a.literal:a.moment==="now"?"now":a.moment:""}function gmr({rootQuery:a,filters:u}){const{setQuery:d}=Pe.useContext(ai);return u.length===0?null:D.jsxRuntimeExports.jsxs("div",{children:[D.jsxRuntimeExports.jsx("div",{...Lt.props(Id.title),children:"filter by"}),D.jsxRuntimeExports.jsx("div",{...Lt.props(Id.tokenContainer),children:u.map((f,m)=>D.jsxRuntimeExports.jsx(mmr,{fallback:D.jsxRuntimeExports.jsxs("div",{children:["Invalid filter",D.jsxRuntimeExports.jsx(DN,{onClick:()=>{f.delete(),d?.(a.build())}})]}),children:D.jsxRuntimeExports.jsx(xmr,{filterOperation:f,rootQuery:a})},m))})]})}function xmr({rootQuery:a,filterOperation:u}){const{setQuery:d}=Pe.useContext(ai),f=Pe.useCallback(R=>{u.filter instanceof Zr.ASTFilterWithFilterString&&u.filter.setFilter(R),d?.(a.build())},[u.filter,a,d]);if(!(u.filter instanceof Zr.ASTFilterWithFilterString))return null;const{fieldReference:m,filterString:g}=u.filter,x=u.filter.getFilter(),E=m.getFieldInfo();if(E.kind!=="dimension"&&E.kind!=="measure")throw new Error(`Invalid filter field kind: ${E.kind}`);const{op:v,value:_}=pqe(x,g),S=`${E.name} ${v} ${_}`;return D.jsxRuntimeExports.jsxs("div",{...Lt.props(f0.main),children:[D.jsxRuntimeExports.jsx(U5,{fieldInfo:E,path:m.path??[],filter:x,setFilter:f,trigger:D.jsxRuntimeExports.jsx($s,{icon:"filter",color:"cyan",label:S}),layoutProps:{align:"start",side:"bottom",sideOffset:1}}),D.jsxRuntimeExports.jsx("div",{...Lt.props(f0.hoverActions),children:D.jsxRuntimeExports.jsx(DN,{onClick:()=>{u.delete(),d?.(a.build())}})})]})}function ymr({rootQuery:a,limit:u}){const{setQuery:d}=Pe.useContext(ai);return u?D.jsxRuntimeExports.jsxs("div",{children:[D.jsxRuntimeExports.jsx("div",{...Lt.props(Id.title),children:"limit"}),D.jsxRuntimeExports.jsxs("div",{...Lt.props(f0.main),children:[D.jsxRuntimeExports.jsx(Fne,{type:"number",value:u.limit,onChange:f=>{u.limit=f,d?.(a.build())},errorMessage:u.limit<0?"Limit must be positive":void 0}),D.jsxRuntimeExports.jsx("div",{...Lt.props(f0.hoverActions),children:D.jsxRuntimeExports.jsx(DN,{onClick:()=>{u.delete(),d?.(a.build())}})})]})]}):null}function vmr({rootQuery:a,segment:u,view:d,aggregates:f}){return D.jsxRuntimeExports.jsx(hqe,{rootQuery:a,segment:u,view:d,operations:f,kind:"aggregate"})}function bmr({rootQuery:a,orderBys:u}){const{setQuery:d}=Pe.useContext(ai);return u.length===0?null:D.jsxRuntimeExports.jsxs("div",{children:[D.jsxRuntimeExports.jsx("div",{...Lt.props(Id.title),children:"order by"}),D.jsxRuntimeExports.jsx("div",{...Lt.props(Id.tokenContainer),children:u.map(f=>{const{fieldReference:m}=f,g=m.getFieldInfo(),x=m.path??[];let E="orderBy";(g.kind==="dimension"||g.kind==="measure")&&(E=I$(g.type.kind));const v=gBe(g.kind);return D.jsxRuntimeExports.jsxs("div",{...Lt.props(f0.main),children:[D.jsxRuntimeExports.jsxs(hN,{children:[D.jsxRuntimeExports.jsx($s,{color:v,icon:E,label:g.name}),D.jsxRuntimeExports.jsx(d$,{color:v,items:[{label:"ascending",value:"asc"},{label:"descending",value:"desc"}],value:f.direction??"asc",onChange:_=>{f.direction=_,d?.(a.build())}})]}),D.jsxRuntimeExports.jsx("div",{...Lt.props(f0.hoverActions),children:D.jsxRuntimeExports.jsx(DN,{onClick:()=>{f.delete(),d?.(a.build())}})})]},[...x,g.name].join("."))})})]})}function Emr({rootQuery:a,view:u}){return D.jsxRuntimeExports.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[D.jsxRuntimeExports.jsx(qBe,{rootQuery:a,view:u}),D.jsxRuntimeExports.jsx(y5,{rootQuery:a,view:u,viewDef:u.definition})]})}function Pv({icon:a,label:u,detail:d,disable:f,onClick:m,open:g}){const x=f?.(),E=()=>{f?.()||m?.()};return D.jsxRuntimeExports.jsxs(oN,{children:[D.jsxRuntimeExports.jsx(aN,{asChild:!0,children:D.jsxRuntimeExports.jsxs("div",{role:"menuitem",tabIndex:-1,...Lt.props(Al.item,Al.clickable,g?_mr.open:null),onClick:E,"data-disabled":x?"true":void 0,children:[D.jsxRuntimeExports.jsxs("div",{...Lt.props(Al.label),children:[a,D.jsxRuntimeExports.jsx("div",{children:u})]}),g!==void 0&&D.jsxRuntimeExports.jsx(An,{name:"chevronRight",color:"gray"})]})}),d?D.jsxRuntimeExports.jsx(lN,{children:D.jsxRuntimeExports.jsx(uN,{...Lt.props(Al.tooltip),side:"right",align:"start",alignOffset:-16,children:d})}):null]})}const _mr={open:{background:"mly16o7sp0",backgroundAttachment:null,backgroundClip:null,backgroundColor:null,backgroundImage:null,backgroundOrigin:null,backgroundPosition:null,backgroundPositionX:null,backgroundPositionY:null,backgroundRepeat:null,backgroundSize:null,$$css:!0}};function Smr({rootQuery:a,view:u}){const{setQuery:d}=Pe.useContext(ai),f=h0(u),m=f?Fpr(f):!1;return D.jsxRuntimeExports.jsx(Pv,{icon:D.jsxRuntimeExports.jsx(An,{name:"limit"}),label:"Limit",disable:()=>m,onClick:()=>{u.getOrAddDefaultSegment().setLimit(10),d?.(a.build())}})}function Amr({rootQuery:a,view:u}){const{setQuery:d}=Pe.useContext(ai);return D.jsxRuntimeExports.jsx(Pv,{icon:D.jsxRuntimeExports.jsx(An,{name:"nest"}),label:"Add blank nested query",onClick:()=>{const f=u.getOrAddDefaultSegment(),m=Upr(f,"Nest");f.addEmptyNest(m>1?`Nest ${m}`:"Nest"),d?.(a.build())}})}function kN({view:a,fields:u,onAddOperation:d,types:f,filter:m,isFilterOperation:g,search:x}){return D.jsxRuntimeExports.jsx(Ioe,{types:f,filter:m,view:a,fields:u,onAddOperation:d,isFilterOperation:g,search:x,customStyle:Cmr.list})}const Cmr={list:{minWidth:"mly2ixbly",maxWidth:"mly1j9u4d2",$$css:!0}};function Rmr({rootQuery:a,view:u,search:d}){const{setQuery:f}=Pe.useContext(ai),m=u.getOutputSchema().fields,g=h0(u),x=Pe.useMemo(()=>m.filter(E=>E.kind==="dimension").filter(E=>Tmr.includes(E.type.kind)).filter(E=>g?!Mpr(g,E.name):!0),[m,g]);return D.jsxRuntimeExports.jsx(kN,{label:"Add order by",icon:"orderBy",view:u,fields:x,types:["dimension"],onAddOperation:E=>{Hpr(u,E),f?.(a.build())},disabledMessage:"There must be at least one field in the output to order by.",search:d})}const Tmr=["string_type","number_type","boolean_type","date_type","timestamp_type"];function wmr({rootQuery:a,view:u,search:d}){const{setQuery:f}=Pe.useContext(ai),{fields:m}=eb(u),g=h0(u),x=(E,v,_)=>!g?.hasField(v.name,_)&&kx(v);return D.jsxRuntimeExports.jsx(kN,{label:"Add group by",icon:"groupBy",view:u,fields:m,types:["dimension"],filter:x,onAddOperation:(E,v)=>{$$(u,E,v),f?.(a.build())},search:d})}function Omr({rootQuery:a,view:u,search:d}){const{setQuery:f}=Pe.useContext(ai),{fields:m}=eb(u),g=h0(u),x=(E,v,_)=>!g?.hasField(v.name,_)&&kx(v);return D.jsxRuntimeExports.jsx(kN,{label:"Add aggregate",icon:"aggregate",view:u,fields:m,types:["measure"],filter:x,onAddOperation:(E,v)=>{B$(u,E,v),f?.(a.build())},search:d})}function Nmr({view:a,search:u}){const{rootQuery:d,setQuery:f}=Y.useContext(ai),{fields:m}=eb(a);return D.jsxRuntimeExports.jsx(kN,{label:"Add filter",icon:"filter",view:a,fields:m,types:["measure","dimension"],filter:(g,x)=>(x.kind==="dimension"||x.kind==="measure")&&Dmr.has(x.type.kind)&&kx(x),onAddOperation:(g,x,E)=>{E&&(g.kind==="dimension"||g.kind==="measure")&&(XBe(a,g,x,E),f?.(d?.build()))},isFilterOperation:!0,search:u})}const Dmr=new Set(["string_type","boolean_type","number_type","date_type","timestamp_type"]);function kmr({rootQuery:a,view:u,search:d}){const{setQuery:f}=Pe.useContext(ai),m=eb(u).fields,g=Pe.useMemo(()=>m.filter(x=>x.kind==="view"&&!$Be(x)),[m]);return D.jsxRuntimeExports.jsx(kN,{label:"Add view",icon:"view",view:u,fields:g,types:["view"],filter:(x,E)=>kx(E),onAddOperation:x=>{a.isEmpty()?a.setView(x.name):Poe(u,x),f?.(a.build())},search:d})}function mqe({rootQuery:a,view:u}){const[d,f]=Pe.useState(!1),[m,g]=Pe.useState(""),{setQuery:x}=Pe.useContext(ai),[E,v]=Pe.useState(""),_=h0(u),S=R=>{g(R===m?"":R)};return D.jsxRuntimeExports.jsxs(AN,{open:d,onOpenChange:R=>{f(R),R||v("")},children:[D.jsxRuntimeExports.jsx(T$,{asChild:!0,children:D.jsxRuntimeExports.jsx($i,{icon:"insert",variant:"flat",size:"compact",onClick:()=>f(!d),tooltip:"Add query elements"})}),D.jsxRuntimeExports.jsx(CN,{children:D.jsxRuntimeExports.jsxs(w$,{onPointerDownOutside:()=>f(!1),...Lt.props(Al.content),side:"bottom",align:"start",role:"menu",children:[D.jsxRuntimeExports.jsx("div",{...Lt.props(Al.item),children:D.jsxRuntimeExports.jsx(c$,{icon:"search",value:E,onChange:v,placeholder:"Search...",customStyle:Lmr.search})}),D.jsxRuntimeExports.jsx(Y_,{}),D.jsxRuntimeExports.jsxs("div",{className:"mly78zum5 mly1odjw0f mlywib8y2 mly1xyq3li",children:[E&&!m?D.jsxRuntimeExports.jsxs("div",{className:"mly1odjw0f",children:[D.jsxRuntimeExports.jsx(Ioe,{view:u,fields:eb(u).fields,filter:(R,w,N)=>!_?.hasField(w.name,N)&&kx(w),types:["dimension","measure","view"],onAddOperation:function(R,w){R.kind==="dimension"?$$(u,R,w):R.kind==="measure"?B$(u,R,w):Poe(u,R),x?.(a.build())},search:E}),D.jsxRuntimeExports.jsx(Y_,{}),D.jsxRuntimeExports.jsx(VBe,{search:E,onClick:R=>{const w=R.fieldName.split("."),N=w.pop();u.getOrAddDefaultSegment().addWhere(N,w,{kind:"string",parsed:{operator:"=",values:[R.fieldValue??"∅"]}}),x?.(a.build())}})]}):D.jsxRuntimeExports.jsxs("div",{"data-testid":"add-menu-operations",className:"mly18kybhu",children:[D.jsxRuntimeExports.jsx(Pv,{icon:D.jsxRuntimeExports.jsx(An,{name:"groupBy"}),label:"Add group by",onClick:()=>S("group_by"),open:m==="group_by"}),D.jsxRuntimeExports.jsx(Pv,{icon:D.jsxRuntimeExports.jsx(An,{name:"aggregate"}),label:"Add aggregate",onClick:()=>S("aggregate"),open:m==="aggregate"}),D.jsxRuntimeExports.jsx(Pv,{icon:D.jsxRuntimeExports.jsx(An,{name:"filter"}),label:"Add filter",onClick:()=>S("where"),open:m==="where"}),D.jsxRuntimeExports.jsx(Pv,{icon:D.jsxRuntimeExports.jsx(An,{name:"view"}),label:"Add view",onClick:()=>S("view"),open:m==="view"}),D.jsxRuntimeExports.jsx(Y_,{}),D.jsxRuntimeExports.jsx(Smr,{rootQuery:a,view:u}),D.jsxRuntimeExports.jsx(Pv,{icon:D.jsxRuntimeExports.jsx(An,{name:"orderBy"}),label:"Order by",onClick:()=>S("order_by"),open:m==="order_by"}),D.jsxRuntimeExports.jsx(Amr,{rootQuery:a,view:u})]}),D.jsxRuntimeExports.jsxs("div",{"data-testid":"add-menu-right-column",style:{overflowY:"auto"},children:[m==="group_by"&&D.jsxRuntimeExports.jsx(wmr,{rootQuery:a,view:u,search:E}),m==="aggregate"&&D.jsxRuntimeExports.jsx(Omr,{rootQuery:a,view:u,search:E}),m==="where"&&D.jsxRuntimeExports.jsx(Nmr,{rootQuery:a,view:u,search:E}),m==="view"&&D.jsxRuntimeExports.jsx(kmr,{rootQuery:a,view:u,search:E}),m==="order_by"&&D.jsxRuntimeExports.jsx(Rmr,{rootQuery:a,view:u,search:E})]})]})]})})]})}const Lmr={search:{width:"mlyh8yej3",$$css:!0}},Sie=Pe.createContext([]);function gqe({children:a,nest:u}){const{focusNestView:d,focusMainView:f}=cN(),m=Pe.useContext(Sie);return D.jsxRuntimeExports.jsx("div",{onPointerDown:g=>{g.stopPropagation(),u?d([...m,u.name]):f()},children:u?D.jsxRuntimeExports.jsx(Sie.Provider,{value:[...m,u.name],children:D.jsxRuntimeExports.jsx("div",{children:a})}):D.jsxRuntimeExports.jsx("div",{children:a})})}function Imr({rootQuery:a,view:u,nests:d}){return d.length===0?null:D.jsxRuntimeExports.jsx("div",{...Lt.props(Id.tokenContainer),children:d.map(f=>D.jsxRuntimeExports.jsx(Pmr,{rootQuery:a,view:u,nest:f},f.name))})}function Pmr({rootQuery:a,view:u,nest:d}){const{setQuery:f}=Pe.useContext(ai),[m,g]=Pe.useState(!1),x=Pe.useContext(Sie),{focusNestView:E,isNestViewFocused:v}=cN(),_=S=>D.jsxRuntimeExports.jsxs(D.jsxRuntimeExports.Fragment,{children:[D.jsxRuntimeExports.jsxs(boe,{trigger:D.jsxRuntimeExports.jsx($i,{variant:"flat",icon:"meatballs",size:"compact",tooltip:"More Actions"}),children:[D.jsxRuntimeExports.jsx(M5,{icon:"clear",label:"Delete Query",onClick:()=>{E([...x]),S.delete(),f?.(a.build())}}),D.jsxRuntimeExports.jsx(M5,{label:"Rename",onClick:()=>{g(!0)}})]}),D.jsxRuntimeExports.jsx(mqe,{rootQuery:a,view:S.view})]});return D.jsxRuntimeExports.jsx(gqe,{nest:d,children:D.jsxRuntimeExports.jsxs("div",{className:"mlyj3b58b mly1yf7rl7 mly1xmf6yo mlyh8yej3",children:[D.jsxRuntimeExports.jsx(_se,{title:d.name,icon:xBe(d.view),defaultOpen:!0,controls:_(d),collapsedControls:_(d),isFocused:v([...x,d.name]),children:D.jsxRuntimeExports.jsx(Emr,{rootQuery:a,view:d.view})}),D.jsxRuntimeExports.jsx(fqe,{rootQuery:a,view:u,target:d,open:m,setOpen:g})]},d.name)})}function jmr({rootQuery:a,view:u,viewDef:d}){const f=[],m=[],g=[],x=[],E=[],v=[];let _;if(!(d instanceof Zr.ASTSegmentViewDefinition))return null;const S=d;return S.operations.items.forEach(R=>{R instanceof Zr.ASTGroupByViewOperation?f.push(R):R instanceof Zr.ASTAggregateViewOperation?m.push(R):R instanceof Zr.ASTWhereViewOperation||R instanceof Zr.ASTHavingViewOperation?x.push(R):R instanceof Zr.ASTOrderByViewOperation?E.push(R):R instanceof Zr.ASTNestViewOperation?v.push(R):R instanceof Zr.ASTDrillViewOperation?g.push(R):_=R}),D.jsxRuntimeExports.jsxs("div",{className:"mly1tpqehw mly10lvyaf",children:[D.jsxRuntimeExports.jsx(pmr,{rootQuery:a,segment:S,view:u,groupBys:f}),D.jsxRuntimeExports.jsx(vmr,{rootQuery:a,segment:S,view:u,aggregates:m}),D.jsxRuntimeExports.jsx(cfr,{rootQuery:a,drills:g}),D.jsxRuntimeExports.jsx(gmr,{rootQuery:a,filters:x}),D.jsxRuntimeExports.jsx(bmr,{rootQuery:a,orderBys:E}),D.jsxRuntimeExports.jsx(Imr,{rootQuery:a,view:u,nests:v}),D.jsxRuntimeExports.jsx(ymr,{rootQuery:a,limit:_})]})}function y5({rootQuery:a,view:u,viewDef:d}){return d instanceof Zr.ASTArrowViewDefinition?D.jsxRuntimeExports.jsx(y5,{rootQuery:a,view:u,viewDef:d.view}):d instanceof Zr.ASTRefinementViewDefinition?D.jsxRuntimeExports.jsxs("div",{children:[D.jsxRuntimeExports.jsx(y5,{rootQuery:a,view:u,viewDef:d.base}),D.jsxRuntimeExports.jsx(y5,{rootQuery:a,view:u,viewDef:d.refinement})]}):d instanceof Zr.ASTSegmentViewDefinition?D.jsxRuntimeExports.jsx(jmr,{rootQuery:a,view:u,viewDef:d}):D.jsxRuntimeExports.jsx(Fmr,{rootQuery:a,viewDef:d})}function Fmr({viewDef:a}){const[u,d]=Pe.useState(!1);return D.jsxRuntimeExports.jsxs("div",{...{0:{className:"mly78zum5 mlydt5ytf mly1cy8zhl mly1nhvcw1 mly12oqio5 mlygqa5hp mlyt7dq6l mlywib8y2 mly163pfp mlyy13l1i"},1:{className:"mly78zum5 mlydt5ytf mly1cy8zhl mly1nhvcw1 mly12oqio5 mlygqa5hp mlyt7dq6l mly163pfp mlyy13l1i mly18d9i69"}}[!!u<<0],children:[D.jsxRuntimeExports.jsxs("div",{className:"mlyrvj5dj mly1mt1orb mly1g3yg12 mlyydnxy5 mly6s0dn4 mlylqzeqv mly167g77z mly12oqio5 mlyc342km mly1n2onr6 mlyb3r6kr mlygqa5hp mlyh8yej3",children:[D.jsxRuntimeExports.jsx(An,{name:"query",color:"purple"}),D.jsxRuntimeExports.jsx("div",{className:"mlyuxw1ft mlyb3r6kr mlylyipyv",children:a.name}),D.jsxRuntimeExports.jsx($i,{icon:u?"chevronRight":"chevronDown",onClick:()=>d(!u),size:"compact"})]}),!u&&D.jsxRuntimeExports.jsx(Loe,{viewInfo:a.getViewInfo(),style:Mmr.preview})]})}const Mmr={preview:{height:"mlyt7dq6l",maxHeight:"mly1hkcv85",background:"mlyo6guvx",backgroundAttachment:null,backgroundClip:null,backgroundColor:null,backgroundImage:null,backgroundOrigin:null,backgroundPosition:null,backgroundPositionX:null,backgroundPositionY:null,backgroundRepeat:null,backgroundSize:null,borderRadius:"mly12oqio5",borderStartStartRadius:null,borderStartEndRadius:null,borderEndStartRadius:null,borderEndEndRadius:null,borderTopLeftRadius:null,borderTopRightRadius:null,borderBottomLeftRadius:null,borderBottomRightRadius:null,$$css:!0}};function $mr({rootQuery:a,query:u,setQuery:d}){const{focusMainView:f,isMainViewFocused:m}=cN();return D.jsxRuntimeExports.jsx(gqe,{children:D.jsxRuntimeExports.jsxs(_se,{title:"Main query",isFocused:m,controls:D.jsxRuntimeExports.jsxs(D.jsxRuntimeExports.Fragment,{children:[D.jsxRuntimeExports.jsx(boe,{trigger:D.jsxRuntimeExports.jsx($i,{variant:"flat",icon:"meatballs",size:"compact",tooltip:"More Actions"}),children:d?D.jsxRuntimeExports.jsxs(D.jsxRuntimeExports.Fragment,{children:[D.jsxRuntimeExports.jsx(M5,{icon:"clear",label:"Clear query",onClick:()=>{f(),d?.(void 0)},disabled:a.isEmpty()}),D.jsxRuntimeExports.jsx(M5,{icon:"nest",label:"Nest query",onClick:()=>{a.definition instanceof Zr.ASTArrowQueryDefinition&&a.definition.view.convertToNest("Nest"),d?.(a.build())},disabled:a.isEmpty()||!(a.definition instanceof Zr.ASTArrowQueryDefinition)})]}):D.jsxRuntimeExports.jsx(D.jsxRuntimeExports.Fragment,{})}),u.definition instanceof Zr.ASTArrowQueryDefinition?D.jsxRuntimeExports.jsx(mqe,{rootQuery:a,view:u.definition}):null]}),collapsedControls:D.jsxRuntimeExports.jsx(An,{name:xBe(u)}),children:[u.definition instanceof Zr.ASTArrowQueryDefinition?D.jsxRuntimeExports.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[!u.isEmpty()&&D.jsxRuntimeExports.jsx(qBe,{rootQuery:a,view:u}),D.jsxRuntimeExports.jsx(y5,{rootQuery:a,view:u.definition,viewDef:u.definition.view})]}):null,u.isEmpty()?D.jsxRuntimeExports.jsx("div",{className:"mly78zum5 mlyl56j7k mly6s0dn4 mlyng8ra",children:D.jsxRuntimeExports.jsxs("div",{className:"mly78zum5 mly6s0dn4 mlywzxoxx",children:[D.jsxRuntimeExports.jsx("div",{children:"Click"}),D.jsxRuntimeExports.jsx(An,{name:"insert",color:"disabled"}),D.jsxRuntimeExports.jsx("div",{children:"to get started"})]})}):null]})})}function Bmr({rootQuery:a}){return a.definition instanceof Zr.ASTArrowQueryDefinition?D.jsxRuntimeExports.jsx("div",{...Lt.props(Id.queryCard,qmr.content),children:D.jsxRuntimeExports.jsxs("div",{...Lt.props(Id.labelWithIcon),children:[D.jsxRuntimeExports.jsx(An,{name:"database"}),D.jsxRuntimeExports.jsx("div",{className:"mlyb3r6kr mlylyipyv mly117nqv4",children:a.definition.as.ArrowQueryDefinition().source.as.ReferenceQueryArrowSource().name})]})}):null}const qmr={content:{display:"mlyrvj5dj",gridAutoFlow:"mly1mt1orb",gridTemplateColumns:"mlybyjr8",gap:"mly1jnr06f",rowGap:null,columnGap:null,$$css:!0}};function Umr({value:a,setValue:u,customStyle:d}){const[f,m]=Pe.useState(""),[g,x]=Pe.useState(!1),E=Pe.useRef(null),v=Pe.useRef(null),_=a.kind==="date_literal",S=_?a.date_value:a.timestamp_value,R=_?"day":"second",w=N=>{N?(m(""),u(_?{kind:"date_literal",date_value:Vt.utc(N).format(fS.day)}:{kind:"timestamp_literal",timestamp_value:Vt.utc(N).format(fS.second)})):m("Invalid date")};return GBe([E,v],()=>{x(!1)}),D.jsxRuntimeExports.jsxs(AN,{open:g,onOpenChange:()=>{},children:[D.jsxRuntimeExports.jsx(T$,{asChild:!0,children:D.jsxRuntimeExports.jsx("div",{...Lt.props(Cx.main,GO.wrapper,d),children:D.jsxRuntimeExports.jsx(gM,{value:Vt.utc(S).toDate(),setValue:w,units:R,onFocus:()=>x(!0),customStyle:{...GO.input,..._?GO.dateInput:GO.timestampInput},forwardRef:E})})}),f&&D.jsxRuntimeExports.jsx(n$,{errorMessage:f}),D.jsxRuntimeExports.jsx(CN,{children:D.jsxRuntimeExports.jsx(w$,{align:"center",asChild:!0,children:D.jsxRuntimeExports.jsx(doe,{value:Vt.utc(S).toDate(),setValue:w,units:R,maxLevel:R,customStyle:GO.datePicker,forwardRef:v})})})]})}const GO={input:{border:"mly1gs6z28",borderWidth:null,borderInlineWidth:null,borderInlineStartWidth:null,borderLeftWidth:null,borderInlineEndWidth:null,borderRightWidth:null,borderBlockWidth:null,borderTopWidth:null,borderBottomWidth:null,borderStyle:null,borderInlineStyle:null,borderInlineStartStyle:null,borderLeftStyle:null,borderInlineEndStyle:null,borderRightStyle:null,borderBlockStyle:null,borderTopStyle:null,borderBottomStyle:null,borderColor:null,borderInlineColor:null,borderInlineStartColor:null,borderLeftColor:null,borderInlineEndColor:null,borderRightColor:null,borderBlockColor:null,borderTopColor:null,borderBottomColor:null,height:"mlyd7y6wv",backgroundColor:"mlyjbqb8w mlytw1abo",$$css:!0},dateInput:{width:"mly869kya",$$css:!0},timestampInput:{width:"mlynrytzq",$$css:!0},wrapper:{$$css:!0},datePicker:{display:"mly78zum5",flexDirection:"mlydt5ytf",boxShadow:"mly5n1uv4",backgroundColor:"mly12peec7",borderRadius:"mlyur7f20",borderStartStartRadius:null,borderStartEndRadius:null,borderEndStartRadius:null,borderEndEndRadius:null,borderTopLeftRadius:null,borderTopRightRadius:null,borderBottomLeftRadius:null,borderBottomRightRadius:null,width:"mly1hfn5x7",$$css:!0}};function zmr({filterType:a,value:u,setValue:d}){let f=null;switch(a){case"string_type":{const{parsed:_}=Xm.StringFilterExpression.parse(u.filter_expression_value);f={kind:"string",parsed:_}}break;case"number_type":{const{parsed:_}=Xm.NumberFilterExpression.parse(u.filter_expression_value);f={kind:"number",parsed:_}}break;case"boolean_type":{const{parsed:_}=Xm.BooleanFilterExpression.parse(u.filter_expression_value);f={kind:"boolean",parsed:_}}break;case"date_type":{const{parsed:_}=Xm.TemporalFilterExpression.parse(u.filter_expression_value);f={kind:"date",parsed:_}}break;case"timestamp_type":{const{parsed:_}=Xm.TemporalFilterExpression.parse(u.filter_expression_value);f={kind:"timestamp",parsed:_}}break}const{op:m,value:g}=pqe(f,u.filter_expression_value),x=`${m} ${g}`,E={kind:"dimension",name:"parameter",type:{kind:a}},v=_=>{switch(_.kind){case"string":d({kind:"filter_expression_literal",filter_expression_value:Xm.StringFilterExpression.unparse(_.parsed)});break;case"boolean":d({kind:"filter_expression_literal",filter_expression_value:Xm.BooleanFilterExpression.unparse(_.parsed)});break;case"number":d({kind:"filter_expression_literal",filter_expression_value:Xm.NumberFilterExpression.unparse(_.parsed)});break;case"date":case"timestamp":d({kind:"filter_expression_literal",filter_expression_value:Xm.TemporalFilterExpression.unparse(_.parsed)});break}};return D.jsxRuntimeExports.jsx(U5,{fieldInfo:E,path:[],filter:f,setFilter:v,trigger:D.jsxRuntimeExports.jsx($s,{label:x}),layoutProps:{align:"start",side:"bottom",sideOffset:1}})}function Hmr({value:a,filterType:u,setValue:d,customStyle:f}){if(!a)return null;switch(a.kind){case"boolean_literal":return D.jsxRuntimeExports.jsx(d$,{value:a.boolean_value?"true":"false",items:[{label:"true",value:"true"},{label:"false",value:"false"}],onChange:m=>d({kind:"boolean_literal",boolean_value:m==="true"}),customStyle:f});case"date_literal":case"timestamp_literal":return D.jsxRuntimeExports.jsx(Umr,{value:a,setValue:d,customStyle:f});case"null_literal":return D.jsxRuntimeExports.jsx($s,{label:"∅"});case"number_literal":return D.jsxRuntimeExports.jsx(Fne,{value:a.number_value,type:"number",onChange:m=>d({kind:"number_literal",number_value:m}),customStyle:f});case"string_literal":return D.jsxRuntimeExports.jsx(Fne,{value:a.string_value,onChange:m=>d({kind:"string_literal",string_value:m}),customStyle:f});case"filter_expression_literal":return D.jsxRuntimeExports.jsx(zmr,{value:a,filterType:u,setValue:d,customStyle:f})}}function Gmr({rootQuery:a}){const{setQuery:u}=Pe.useContext(ai);if(a.definition instanceof Zr.ASTArrowQueryDefinition){const d=a.definition.as.ArrowQueryDefinition().source.as.ReferenceQueryArrowSource(),f=d.getSourceParameters();return!f||f.length===0?null:D.jsxRuntimeExports.jsx(_se,{title:"Source parameters",children:D.jsxRuntimeExports.jsx("div",{className:"mly78zum5 mlydt5ytf mly1jnr06f mlynm25rq",children:f.map(m=>{var g;return D.jsxRuntimeExports.jsxs(hN,{customStyle:Wmr.tokenGroup,children:[D.jsxRuntimeExports.jsx($s,{icon:I$(m.type.kind),label:m.name}),D.jsxRuntimeExports.jsx(Hmr,{filterType:m.type.kind==="filter_expression_type"?m.type.filter_type.kind:"string_type",value:((g=d.tryGetParameter(m.name))==null?void 0:g.parameter.value)??m.default_value,setValue:x=>{d.setParameter(m.name,x),u?.(a.build())}})]},m.name)})})})}return null}const Wmr={tokenGroup:{display:"mly78zum5",$$css:!0}};function Vmr(){const{rootQuery:a,setQuery:u}=Pe.useContext(ai);return a?D.jsxRuntimeExports.jsxs("div",{...Lt.props(Fr.body,Qmr.main),children:[D.jsxRuntimeExports.jsx(Bmr,{rootQuery:a}),D.jsxRuntimeExports.jsx(Gmr,{rootQuery:a}),D.jsxRuntimeExports.jsx($mr,{rootQuery:a,query:a,setQuery:u})]}):(console.error("Missing <MalloyExplorerProvider>"),null)}const Qmr={main:{display:"mly78zum5",flexDirection:"mlydt5ytf",overflow:"mlyysyzu8",overflowX:null,overflowY:null,gap:"mly167g77z",rowGap:null,columnGap:null,padding:"mly1fut7tt",paddingInline:null,paddingStart:null,paddingLeft:null,paddingEnd:null,paddingRight:null,paddingBlock:null,paddingTop:null,paddingBottom:null,$$css:!0}};function Ymr({runQuery:a}){return D.jsxRuntimeExports.jsxs("div",{className:"mly78zum5 mlydt5ytf mly5yr21d mlyotlr4g mly1roky18",children:[D.jsxRuntimeExports.jsx(tfr,{runQuery:a}),D.jsxRuntimeExports.jsx(Vmr,{})]})}function Kmr({viewInfo:a,onClick:u}){const d=MBe(a.annotations??[]);return D.jsxRuntimeExports.jsx("div",{children:D.jsxRuntimeExports.jsx(htr,{header:D.jsxRuntimeExports.jsxs("div",{children:[D.jsxRuntimeExports.jsxs("div",{className:"mly78zum5 mly1q0g3np mly1qughib",children:[D.jsxRuntimeExports.jsx(Ex,{label:"view",icon:"view_filled",color:"purple",customStyle:K9e.viewBadge}),D.jsxRuntimeExports.jsx($i,{variant:"default",size:"compact",label:"Add",onClick:u})]}),D.jsxRuntimeExports.jsxs("div",{children:[D.jsxRuntimeExports.jsx("div",{...Lt.props(Fr.emphasized),children:a.name}),d&&D.jsxRuntimeExports.jsx(zBe,{text:d})]})]}),customStyle:K9e.card,children:D.jsxRuntimeExports.jsx(Loe,{viewInfo:a})})})}const K9e={viewBadge:{backgroundColor:"mlyjbqb8w",$$css:!0},card:{width:"mlyxsgkw5",$$css:!0}};function Xmr({views:a,onSelectView:u}){return D.jsxRuntimeExports.jsx("div",{className:"mly78zum5 mlydt5ytf mlyh8yej3 mly5yr21d mlyysyzu8",children:D.jsxRuntimeExports.jsxs("div",{className:"mly1bpp3o7 mly78zum5 mlydt5ytf mlyl56j7k mly6s0dn4",children:[D.jsxRuntimeExports.jsx("div",{...Lt.props(Jmr.header,Fr.emphasized),children:"Start with a Bookmarked View"}),D.jsxRuntimeExports.jsx("div",{className:"mly78zum5 mlyl56j7k mly6s0dn4 mly1a02dak mly883omv mlym6i5cn",children:a.filter(d=>!Doe(d.annotations??[])).slice(0,3).map(d=>D.jsxRuntimeExports.jsx(Kmr,{viewInfo:d,onClick:()=>{u(d)}},d.name))})]})})}const Jmr={header:{paddingBottom:"mly1l90r2v",$$css:!0}};var Boe="Tabs",[Zmr,kyr]=Md(Boe,[N$]),xqe=N$(),[e0r,qoe]=Zmr(Boe),yqe=Y.forwardRef((a,u)=>{const{__scopeTabs:d,value:f,onValueChange:m,defaultValue:g,orientation:x="horizontal",dir:E,activationMode:v="automatic",..._}=a,S=dN(E),[R,w]=Dx({prop:f,onChange:m,defaultProp:g});return D.jsxRuntimeExports.jsx(e0r,{scope:d,baseId:ic(),value:R,onValueChange:w,orientation:x,dir:S,activationMode:v,children:D.jsxRuntimeExports.jsx(rn.div,{dir:S,"data-orientation":x,..._,ref:u})})});yqe.displayName=Boe;var vqe="TabsList",bqe=Y.forwardRef((a,u)=>{const{__scopeTabs:d,loop:f=!0,...m}=a,g=qoe(vqe,d),x=xqe(d);return D.jsxRuntimeExports.jsx(j$e,{asChild:!0,...x,orientation:g.orientation,dir:g.dir,loop:f,children:D.jsxRuntimeExports.jsx(rn.div,{role:"tablist","aria-orientation":g.orientation,...m,ref:u})})});bqe.displayName=vqe;var Eqe="TabsTrigger",_qe=Y.forwardRef((a,u)=>{const{__scopeTabs:d,value:f,disabled:m=!1,...g}=a,x=qoe(Eqe,d),E=xqe(d),v=Cqe(x.baseId,f),_=Rqe(x.baseId,f),S=f===x.value;return D.jsxRuntimeExports.jsx(F$e,{asChild:!0,...E,focusable:!m,active:S,children:D.jsxRuntimeExports.jsx(rn.button,{type:"button",role:"tab","aria-selected":S,"aria-controls":_,"data-state":S?"active":"inactive","data-disabled":m?"":void 0,disabled:m,id:v,...g,ref:u,onMouseDown:xr(a.onMouseDown,R=>{!m&&R.button===0&&R.ctrlKey===!1?x.onValueChange(f):R.preventDefault()}),onKeyDown:xr(a.onKeyDown,R=>{[" ","Enter"].includes(R.key)&&x.onValueChange(f)}),onFocus:xr(a.onFocus,()=>{const R=x.activationMode!=="manual";!S&&!m&&R&&x.onValueChange(f)})})})});_qe.displayName=Eqe;var Sqe="TabsContent",Aqe=Y.forwardRef((a,u)=>{const{__scopeTabs:d,value:f,forceMount:m,children:g,...x}=a,E=qoe(Sqe,d),v=Cqe(E.baseId,f),_=Rqe(E.baseId,f),S=f===E.value,R=Y.useRef(S);return Y.useEffect(()=>{const w=requestAnimationFrame(()=>R.current=!1);return()=>cancelAnimationFrame(w)},[]),D.jsxRuntimeExports.jsx(Do,{present:m||S,children:({present:w})=>D.jsxRuntimeExports.jsx(rn.div,{"data-state":S?"active":"inactive","data-orientation":E.orientation,role:"tabpanel","aria-labelledby":v,hidden:!w,id:_,tabIndex:0,...x,ref:u,style:{...a.style,animationDuration:R.current?"0s":void 0},children:w&&g})})});Aqe.displayName=Sqe;function Cqe(a,u){return`${a}-trigger-${u}`}function Rqe(a,u){return`${a}-content-${u}`}var t0r=yqe,r0r=bqe,aF=_qe,lF=Aqe;const n0r={compiling:"Compiling",running:"Running",finished:"Finished",canceled:"Canceled"},i0r="start",s0r="bottom";function o0r({runInfo:a}){return D.jsxRuntimeExports.jsxs(oN,{children:[D.jsxRuntimeExports.jsx(aN,{asChild:!0,children:D.jsxRuntimeExports.jsxs("div",{...Lt.props(ane.triggerContentContainer,Fr.body),children:[D.jsxRuntimeExports.jsx(An,{name:"info",color:"disabled"})," Query run details"]})}),D.jsxRuntimeExports.jsx(lN,{children:D.jsxRuntimeExports.jsx(uN,{side:s0r,align:i0r,children:D.jsxRuntimeExports.jsx(HBe,{customStyle:ane.card,children:D.jsxRuntimeExports.jsxs(D.jsxRuntimeExports.Fragment,{children:[a.customContent,a?.performanceAspects&&Object.entries(a.performanceAspects).map(([u,d])=>D.jsxRuntimeExports.jsx("div",{children:Object.entries(d).map(([f,m])=>D.jsxRuntimeExports.jsxs("div",{children:[D.jsxRuntimeExports.jsxs("span",{...Lt.props(Fr.emphasized),children:[f,":"]})," ",D.jsxRuntimeExports.jsx("span",{...Lt.props(Fr.body),children:m})]},f))},u)),a.queryLink&&D.jsxRuntimeExports.jsx("a",{href:a.queryLink.href,target:"_blank",rel:"noreferrer",...Lt.props(ane.link,Fr.link),children:a.queryLink.linkText})]})})})})]})}const ane={card:{maxWidth:"mly1dc814f",$$css:!0},triggerContentContainer:{display:"mly3nfvp2",alignItems:"mly6s0dn4",justifyContent:"mlylqzeqv",$$css:!0},link:{backgroundColor:"mlyjbqb8w",border:"mly1gs6z28",borderWidth:null,borderInlineWidth:null,borderInlineStartWidth:null,borderLeftWidth:null,borderInlineEndWidth:null,borderRightWidth:null,borderBlockWidth:null,borderTopWidth:null,borderBottomWidth:null,borderStyle:null,borderInlineStyle:null,borderInlineStartStyle:null,borderLeftStyle:null,borderInlineEndStyle:null,borderRightStyle:null,borderBlockStyle:null,borderTopStyle:null,borderBottomStyle:null,borderColor:null,borderInlineColor:null,borderInlineStartColor:null,borderLeftColor:null,borderInlineEndColor:null,borderRightColor:null,borderBlockColor:null,borderTopColor:null,borderBottomColor:null,padding:"mly1717udv",paddingInline:null,paddingStart:null,paddingLeft:null,paddingEnd:null,paddingRight:null,paddingBlock:null,paddingTop:null,paddingBottom:null,cursor:"mly1ypdohk",textDecoration:"mly1hl2dhg",textDecorationColor:null,textDecorationLine:null,textDecorationStyle:null,textDecorationThickness:null,$$css:!0}};function a0r({source:a,query:u}){let d;switch(u.executionState){case"compiling":case"running":d=D.jsxRuntimeExports.jsx(d0r,{onCancel:u.onCancel,executionState:u.executionState,queryResolutionStartMillis:u.queryResolutionStartMillis});break;case"canceled":d=D.jsxRuntimeExports.jsx("div",{className:"mly78zum5 mlydt5ytf mlyh8yej3 mly5yr21d mlyl56j7k mly6s0dn4 mly1665zp3",children:D.jsxRuntimeExports.jsxs("div",{className:"mly78zum5 mlydt5ytf mly6s0dn4 mlyl56j7k mly167g77z",children:[D.jsxRuntimeExports.jsx("div",{...Lt.props(Fr.emphasized),children:"Query Canceled"}),D.jsxRuntimeExports.jsx("div",{...Lt.props(Fr.body),children:"Your query was canceled; nothing to display."})]})});break;case"finished":d=D.jsxRuntimeExports.jsx(l0r,{source:a,response:u.response});break}return d}function l0r({source:a,response:u}){let d=null;return u?u.error||u.messages?d=D.jsxRuntimeExports.jsx(u0r,{messages:[...u.error?[u.error]:[],...u.messages?u.messages:[]]}):u.result||(d=D.jsxRuntimeExports.jsx(hie,{title:"Empty Result",variant:"critical"})):d=D.jsxRuntimeExports.jsx(hie,{title:"Empty Response",variant:"critical"}),D.jsxRuntimeExports.jsxs("div",{className:"mly78zum5 mlydt5ytf mly167g77z mly5yr21d",children:[u?.runInfo&&D.jsxRuntimeExports.jsx(o0r,{runInfo:u.runInfo}),d,u?.result&&D.jsxRuntimeExports.jsx(c0r,{result:u.result,source:a})]})}function u0r({messages:a}){return D.jsxRuntimeExports.jsx("div",{children:a.map(u=>{let d=null;if(u.customRenderer)d=u.customRenderer;else{let f;switch(u.severity){case"DEBUG":case"INFO":f="info";break;case"WARN":f="warn";break;case"ERROR":case"FATAL":f="critical";break;default:f="critical"}d=D.jsxRuntimeExports.jsx(hie,{title:u.title,description:u.description,variant:f,children:u.content})}return D.jsxRuntimeExports.jsx("div",{children:d},u.title)})})}function c0r({result:a,source:u}){const[d,f]=Pe.useState(),{onDrill:m,setQuery:g}=Pe.useContext(ai);return Pe.useEffect(()=>{const x=document.createElement("malloy-render");x.malloyResult=a,x.onDrill=({stableQuery:E,stableDrillClauses:v})=>{if(m){m({stableQuery:E,stableDrillClauses:v});return}const _=new Zr.ASTQuery({query:E,source:u});g?.(_.build())},x.tableConfig={enableDrill:!0},f(x)},[m,a,u,g]),d?D.jsxRuntimeExports.jsx(TMe,{element:d,style:{overflow:"hidden",height:"100%"}}):D.jsxRuntimeExports.jsx("div",{className:"mly78zum5 mlyl56j7k mly6s0dn4",children:D.jsxRuntimeExports.jsxs("div",{className:"mly78zum5 mlydt5ytf mlyl56j7k mly6s0dn4 mly167g77z",children:[D.jsxRuntimeExports.jsx(wMe,{size:"large"}),D.jsxRuntimeExports.jsx("div",{...Lt.props(Fr.emphasized),children:"Rendering..."})]})})}function d0r({onCancel:a,executionState:u,queryResolutionStartMillis:d}){const f=f0r(d);return D.jsxRuntimeExports.jsxs("div",{className:"mly78zum5 mlydt5ytf mlyh8yej3 mly5yr21d mlyl56j7k mly6s0dn4 mly1665zp3",children:[D.jsxRuntimeExports.jsxs("div",{className:"mly78zum5 mlydt5ytf mly6s0dn4 mlyl56j7k mly167g77z",children:[D.jsxRuntimeExports.jsx(wMe,{size:"large",customStyle:h0r.spinner}),D.jsxRuntimeExports.jsx("div",{...Lt.props(Fr.emphasized),children:`${n0r[u]} query...`}),D.jsxRuntimeExports.jsx("div",{...Lt.props(Fr.body),children:`Total time elapsed: ${(f/1e3).toFixed(0)}s`})]}),D.jsxRuntimeExports.jsx($i,{onClick:a,label:"Cancel Query"})]})}function f0r(a){const[u,d]=Y.useState(Date.now()-a);return Y.useEffect(()=>{const f=setInterval(()=>{d(Date.now()-a)},1e3);return()=>clearInterval(f)},[a]),u}const h0r={spinner:{marginBottom:"mly1e56ztr",$$css:!0}};function p0r({query:a,debug:u}){var d;const[f,m]=Pe.useState((d=u?.debuggers)==null?void 0:d.at(0));return D.jsxRuntimeExports.jsxs("div",{children:[!!u?.debuggers.length&&D.jsxRuntimeExports.jsxs("div",{className:"mly78zum5 mly167g77z mly6s0dn4",children:[D.jsxRuntimeExports.jsx("div",{...Lt.props(Fr.largeBody),children:"Debug with:"}),D.jsxRuntimeExports.jsx(Hx,{options:u.debuggers.map(g=>({label:g,value:g})),value:f,onChange:g=>m(g)}),D.jsxRuntimeExports.jsx($i,{variant:"default",label:"Run",isDisabled:!f,onClick:()=>f&&u.onDebugQuery(a,f)})]}),D.jsxRuntimeExports.jsx(iie,{code:JSON.stringify(a,null,2),language:"json"})]})}const m0r=800;function g0r({text:a,label:u}){const[d,f]=Pe.useState(!1);return Pe.useEffect(()=>{if(!d)return()=>{};const m=setTimeout(()=>{f(!1)},m0r);return()=>{clearTimeout(m),f(!1)}},[d]),D.jsxRuntimeExports.jsx($i,{variant:"flat",size:"compact",label:d?"Copied!":u,icon:"copy",isDisabled:d,onClick:()=>{navigator.clipboard.writeText(a).then(()=>f(!0))}})}var is=function(a){return a.RESULTS="Results",a.MALLOY="Malloy",a.SQL="SQL",a.RAW_QUERY="Raw Query",a}(is||{});function x0r({source:a,draftQuery:u,setDraftQuery:d,submittedQuery:f,options:m}){var g,x,E;const[v,_]=Pe.useState(is.MALLOY),S=(g=Sje(a,u))==null?void 0:g.toMalloy(),R=a.schema.fields.filter(k=>k.kind==="view"),w=f!==void 0;!w&&(v===is.RESULTS||v===is.SQL)&&_(is.MALLOY),Pe.useEffect(()=>{_(is.RESULTS)},[f]);const N=(()=>{var k,B;return v===is.MALLOY&&S?S:v===is.SQL&&((B=(k=f?.response)==null?void 0:k.result)!=null&&B.sql)?f.response.result.sql:v===is.RAW_QUERY?JSON.stringify(u):null})();return u||f?D.jsxRuntimeExports.jsxs(t0r,{...Lt.props(lh.tabRoot,Fr.body),value:v,onValueChange:k=>_(k),children:[D.jsxRuntimeExports.jsxs("div",{className:"mly78zum5 mly1q0g3np mly1qughib mly6s0dn4 mly153ncpu",children:[D.jsxRuntimeExports.jsxs(r0r,{className:"mly78zum5 mly6s0dn4 mly167g77z",children:[D.jsxRuntimeExports.jsx(aF,{value:is.RESULTS,disabled:!w,...Lt.props(Fr.body,lh.tab,!w&&lh.disabledTab),title:w?void 0:"Run a query to see the results.",children:is.RESULTS}),D.jsxRuntimeExports.jsx(aF,{value:is.MALLOY,...Lt.props(Fr.body,lh.tab),children:is.MALLOY}),D.jsxRuntimeExports.jsx(aF,{value:is.SQL,disabled:!w,...Lt.props(Fr.body,lh.tab,!w&&lh.disabledTab),title:w?void 0:"Run a query to see generated SQL.",children:is.SQL}),m?.showRawQuery&&D.jsxRuntimeExports.jsx(aF,{value:is.RAW_QUERY,...Lt.props(Fr.body,lh.tab),children:is.RAW_QUERY})]}),v!==is.RESULTS&&N&&D.jsxRuntimeExports.jsx(g0r,{text:N,label:"Copy Code"})]}),D.jsxRuntimeExports.jsxs("div",{className:"mly1iyjqo2 mlyb3r6kr",children:[D.jsxRuntimeExports.jsx(lF,{value:is.RESULTS,className:"mlyc7ga6q mlyh8yej3 mly5yr21d mly9f619",children:f&&D.jsxRuntimeExports.jsxs(D.jsxRuntimeExports.Fragment,{children:[u&&f&&!y0r(u,f.query)&&D.jsxRuntimeExports.jsxs("div",{...Lt.props(lh.warning,Fr.body),children:[D.jsxRuntimeExports.jsx(An,{name:"warning",color:"warning",customStyle:lh.warningIcon}),D.jsxRuntimeExports.jsxs("div",{children:[D.jsxRuntimeExports.jsx("span",{children:"Query was updated. Run query to see new result or"}),D.jsxRuntimeExports.jsx("button",{...Lt.props(lh.warningAction,Fr.link),onClick:()=>{d(f.query)},children:" revert "}),D.jsxRuntimeExports.jsx("span",{children:"to the last run query."})]})]}),D.jsxRuntimeExports.jsx(a0r,{source:a,query:f})]})}),D.jsxRuntimeExports.jsx(lF,{value:is.MALLOY,className:"mlywp4ipm mlyh8yej3 mly5yr21d mly9f619",children:D.jsxRuntimeExports.jsx(iie,{code:S??"",language:"malloy"})}),D.jsxRuntimeExports.jsx(lF,{value:is.SQL,className:"mlywp4ipm mlyh8yej3 mly5yr21d mly9f619",children:((E=(x=f?.response)==null?void 0:x.result)==null?void 0:E.sql)&&D.jsxRuntimeExports.jsx(iie,{code:f.response.result.sql,language:"sql"})}),m?.showRawQuery&&D.jsxRuntimeExports.jsx(lF,{value:is.RAW_QUERY,className:"mlywp4ipm mlyh8yej3 mly5yr21d mly9f619",children:D.jsxRuntimeExports.jsx(p0r,{query:u,debug:m.debugOptions?{debuggers:m.debugOptions.debuggers,onDebugQuery:m.debugOptions.onDebugQuery}:void 0})})]})]}):D.jsxRuntimeExports.jsx(Xmr,{views:R,onSelectView:k=>d(v0r(k.name,a.name))})}function y0r(a,u){return JSON.stringify(a)===JSON.stringify(u)}function v0r(a,u){return{definition:{kind:"arrow",source:{kind:"source_reference",name:u},view:{kind:"view_reference",name:a}}}}const lh={tabRoot:{height:"mly5yr21d",width:"mlyh8yej3",display:"mly78zum5",flexDirection:"mlydt5ytf",$$css:!0},tab:{border:"mly1gs6z28",borderWidth:null,borderInlineWidth:null,borderInlineStartWidth:null,borderLeftWidth:null,borderInlineEndWidth:null,borderRightWidth:null,borderBlockWidth:null,borderTopWidth:null,borderBottomWidth:null,borderStyle:null,borderInlineStyle:null,borderInlineStartStyle:null,borderLeftStyle:null,borderInlineEndStyle:null,borderRightStyle:null,borderBlockStyle:null,borderTopStyle:null,borderBottomStyle:null,borderColor:null,borderInlineColor:null,borderInlineStartColor:null,borderLeftColor:null,borderInlineEndColor:null,borderRightColor:null,borderBlockColor:null,borderTopColor:null,borderBottomColor:null,padding:"mlydqdrvq",paddingInline:null,paddingStart:null,paddingLeft:null,paddingEnd:null,paddingRight:null,paddingBlock:null,paddingTop:null,paddingBottom:null,borderRadius:"mlyur7f20",borderStartStartRadius:null,borderStartEndRadius:null,borderEndStartRadius:null,borderEndEndRadius:null,borderTopLeftRadius:null,borderTopRightRadius:null,borderBottomLeftRadius:null,borderBottomRightRadius:null,backgroundColor:"mlyjbqb8w",cursor:"mly1ypdohk",":is([data-state='active'])_color":"mlyb0tsu4",":is([data-state='active'])_fontWeight":"mly1uifvsu",":is([data-state='active'])_backgroundColor":"mly14vaotu",$$css:!0},disabledTab:{color:"mly1jwwhvr",cursor:"mly1ipiool",$$css:!0},warning:{display:"mly78zum5",alignItems:"mly6s0dn4",marginBottom:"mly1e56ztr",$$css:!0},warningAction:{backgroundColor:"mlyjbqb8w",border:"mly1gs6z28",borderWidth:null,borderInlineWidth:null,borderInlineStartWidth:null,borderLeftWidth:null,borderInlineEndWidth:null,borderRightWidth:null,borderBlockWidth:null,borderTopWidth:null,borderBottomWidth:null,borderStyle:null,borderInlineStyle:null,borderInlineStartStyle:null,borderLeftStyle:null,borderInlineEndStyle:null,borderRightStyle:null,borderBlockStyle:null,borderTopStyle:null,borderBottomStyle:null,borderColor:null,borderInlineColor:null,borderInlineStartColor:null,borderLeftColor:null,borderInlineEndColor:null,borderRightColor:null,borderBlockColor:null,borderTopColor:null,borderBottomColor:null,padding:"mly1717udv",paddingInline:null,paddingStart:null,paddingLeft:null,paddingEnd:null,paddingRight:null,paddingBlock:null,paddingTop:null,paddingBottom:null,cursor:"mly1ypdohk",$$css:!0},warningIcon:{paddingRight:"mlyy13l1i",paddingInlineStart:null,paddingInlineEnd:null,$$css:!0}};function v5(a,u=[]){return a.flatMap(d=>{switch(d.kind){case"view":return $Be(d)?[]:u.length>0?[]:[{path:u,field:d}];case"measure":case"dimension":return d.type.kind==="array_type"&&d.type.element_type.kind==="record_type"?[{path:u,field:d},...v5(d.type.element_type.fields.map(f=>({kind:d.kind,...f})),[...u,d.name])]:d.type.kind==="record_type"?[{path:u,field:d},...v5(d.type.fields.map(f=>({kind:d.kind,...f})),[...u,d.name])]:[{path:u,field:d}];case"join":return v5(d.schema.fields,[...u,d.name]);default:return[]}})}function b0r(a){return v5(a.schema.fields)}function Tqe(a,u){return Object.values(u.reduce((d,f)=>{const m=[a.name,...f.path].join(".");return d[m]||(d[m]={groupPath:f.path,items:[]}),d[m].items.push(f),d},{}))}function wqe(a){return Object.values(a.reduce((u,d)=>{const f=d.field.kind;return u[f]||(u[f]={group:f,items:[]}),u[f].items.push(d),u},{}))}const E0r={view:"Views",measure:"Measures",dimension:"Dimensions"};function _0r(a,u,d){const f=M$(d,u.name),g=Pe.useMemo(()=>{const{fields:S}=eb(a),R=d.join(".");return v5(S).filter(w=>w.path.join(".")===R)},[d,a]).find(S=>u.name===S.field.name),x=Pe.useMemo(()=>{const S=h0(a);return g?.field.kind!=="dimension"?"Grouping is only available on a dimenion.":S?.hasField(u.name,d)?"Cannot group by a field already in the view.":kx(u)?"":"This field is annotated with #NO_UI."},[a,g?.field.kind,u,d]),E=Pe.useMemo(()=>{if(g?.field.kind!=="measure")return"Aggregation only supports measure fields.";const S=h0(a);return S?.hasField(u.name,d)?"This field is already used in the query.":kx(u)?"":"This field is annotated with #NO_UI."},[g?.field.kind,a,u,d]),v=Pe.useMemo(()=>g?["dimension","measure"].includes(g.field.kind)?S0r.includes(g.field.type.kind)?"":"Filtering only supports string, boolean, number, date and time fields.":"Filtering is only available for a dimension or measure.":`Unexpected Error: Could not find a field ${f}.`,[f,g]),_=Pe.useMemo(()=>{if(!g)return`Unexpected Error: Could not find a field ${f}.`;const S=h0(a);return S&&$pr(S,d,u.name)?"Query is already ordered by this field.":!S||!qpr(S,d,u.name)?"Order by is only available for fields in the output.":["dimension","measure"].includes(g.field.kind)?A0r.includes(g.field.type.kind)?"":"Order By only supports string, boolean, number, date and time fields.":"Order By is only available for dimension or measure fields."},[g,a,d,u.name,f]);return{isGroupByAllowed:!x,groupByDisabledReason:x,isAggregateAllowed:!E,aggregateDisabledReason:E,isFilterAllowed:!v,filterDisabledReason:v,isOrderByAllowed:!_,orderByDisabledReason:_}}const S0r=["string_type","boolean_type","number_type","date_type","timestamp_type"],A0r=["string_type","number_type","boolean_type","date_type","timestamp_type"];function Oqe({field:a,path:u,viewDef:d}){const{rootQuery:f,setQuery:m}=Pe.useContext(ai),{focusedNestView:g}=cN(),x=g??d,{groupByDisabledReason:E,aggregateDisabledReason:v,filterDisabledReason:_,orderByDisabledReason:S}=_0r(x,a,u),[R,w]=Pe.useState(),[N,k]=Pe.useState(!1),B=(q,z)=>{(a.kind==="dimension"||a.kind==="measure")&&(q==="groupBy"&&!E?$$(x,a,u):q==="aggregate"&&!v?B$(x,a,u):q==="orderBy"&&!S?zpr(x,u,a.name):q==="filter"&&!_&&z&&XBe(x,a,u,z),m?.(f?.build()))},P=()=>{a.kind==="view"&&f?.isEmpty()&&(f?.setView(a.name),m?.(f?.build()))},$=()=>{a.kind==="view"&&(Poe(x,a),m?.(f?.build()))};return D.jsxRuntimeExports.jsx(hS,{field:a,hoverActions:a.kind==="view"?D.jsxRuntimeExports.jsxs(D.jsxRuntimeExports.Fragment,{children:[D.jsxRuntimeExports.jsx(hx,{icon:"insert",disabled:!f?.isEmpty(),onClick:P,tooltip:f?.isEmpty()?"Add view":"Can only add a view to an empty query.",onTooltipOpenChange:k}),D.jsxRuntimeExports.jsx(hx,{icon:"nest",onClick:$,tooltip:"Add as new nested query",onTooltipOpenChange:k})]}):a.kind==="measure"?D.jsxRuntimeExports.jsxs(D.jsxRuntimeExports.Fragment,{children:[D.jsxRuntimeExports.jsx(hx,{icon:"aggregate",tooltip:v||"Add as aggregate",disabled:!!v,onClick:()=>B("aggregate"),onTooltipOpenChange:k}),D.jsxRuntimeExports.jsx(U5,{fieldInfo:a,path:u,setFilter:q=>B("filter",q),trigger:D.jsxRuntimeExports.jsx(hx,{icon:"filter",tooltip:_||"Add as filter",disabled:!!_,onTooltipOpenChange:k}),onOpenChange:w}),D.jsxRuntimeExports.jsx(hx,{icon:"orderBy",tooltip:S||"Add as order by",disabled:!!S,onClick:()=>B("orderBy"),onTooltipOpenChange:k})]}):a.kind==="dimension"?D.jsxRuntimeExports.jsxs(D.jsxRuntimeExports.Fragment,{children:[D.jsxRuntimeExports.jsx(hx,{icon:"groupBy",tooltip:E||"Add as group by",disabled:!!E,onClick:()=>B("groupBy"),onTooltipOpenChange:k}),D.jsxRuntimeExports.jsx(U5,{fieldInfo:a,path:u,setFilter:q=>B("filter",q),trigger:D.jsxRuntimeExports.jsx(hx,{icon:"filter",tooltip:_||"Add as filter",disabled:!!_,onTooltipOpenChange:k}),onOpenChange:w}),D.jsxRuntimeExports.jsx(hx,{icon:"orderBy",tooltip:S||"Add as order by",disabled:!!S,onClick:()=>B("orderBy"),onTooltipOpenChange:k})]}):null,onClick:a.kind==="dimension"&&!E?()=>B("groupBy"):a.kind==="measure"&&!v?()=>B("aggregate"):a.kind==="view"?()=>{f?.isEmpty()?P():$()}:void 0,hoverActionsVisible:R||N,tooltip:D.jsxRuntimeExports.jsx(SM,{field:a,path:u}),tooltipProps:{side:"right",align:"start",alignOffset:28}})}function hx({tooltip:a,onTooltipOpenChange:u,...d}){return D.jsxRuntimeExports.jsxs(LS,{delayDuration:300,onOpenChange:u,children:[D.jsxRuntimeExports.jsx(IS,{asChild:!0,children:D.jsxRuntimeExports.jsx($i,{variant:"flat",size:"compact",...d})}),D.jsxRuntimeExports.jsx(PS,{children:D.jsxRuntimeExports.jsx(jS,{sideOffset:8,...Lt.props(Fr.body,g0.default),children:a})})]})}const X9e=["dimension","measure","view"];function C0r({source:a,items:u}){const d=Y.useMemo(()=>wqe(u).sort((g,x)=>X9e.indexOf(g.group)-X9e.indexOf(x.group)).map(g=>({...g,items:Tqe(a,g.items)})),[a,u]),{rootQuery:f}=Y.useContext(ai),m=f?.definition;return m instanceof Zr.ASTArrowQueryDefinition?D.jsxRuntimeExports.jsxs("div",{className:"mly78zum5 mlydt5ytf mly1cy8zhl mlyou54vl mlye8ttls mly10cdfl8",children:[D.jsxRuntimeExports.jsx("div",{...Lt.props(Fr.body,J9e.heading),children:`${u.length} result${u.length>1?"s":""}`}),d.map(({group:g,items:x})=>D.jsxRuntimeExports.jsxs("div",{children:[D.jsxRuntimeExports.jsx("div",{...Lt.props(Fr.body,J9e.groupTitle),children:E0r[g]}),D.jsxRuntimeExports.jsx("div",{className:"mly78zum5 mlydt5ytf mlyou54vl",children:x.map(({groupPath:E,items:v})=>Pe.createElement("div",{className:"mly78zum5 mlydt5ytf mly1jnr06f",key:E.join(".")},D.jsxRuntimeExports.jsx("div",{...Lt.props(Fr.supporting),children:E.join(" > ")}),v.map(({field:_,path:S})=>D.jsxRuntimeExports.jsx(Oqe,{field:_,path:S,viewDef:m},[...S,_.name].join(".")))))})]},g))]}):null}const J9e={heading:{fontWeight:"mly1xlr1w8",$$css:!0},groupTitle:{fontWeight:"mly1xlr1w8",fontSize:"mlyfifm61",$$css:!0}},R0r=(a,u)=>u.at(-1)??a.name,T0r=(a,u)=>u.length>0?`joined to ${[...u.slice(0,-1),a.name].join(" > ")}`:void 0;function lne({source:a,fieldItems:u,fieldGroupType:d}){const f=Y.useMemo(()=>a?wqe(u).map(E=>({...E,items:Tqe(a,E.items)})):[],[a,u]),m=Y.useMemo(()=>{var E;return((E=f.find(({group:v})=>v===d))==null?void 0:E.items)??[]},[f,d]),{rootQuery:g}=Y.useContext(ai),x=g?.definition;return x instanceof Zr.ASTArrowQueryDefinition?D.jsxRuntimeExports.jsx("div",{className:"mly78zum5 mlydt5ytf mly167g77z",children:D.jsxRuntimeExports.jsx(pZt,{children:m.map((E,v)=>D.jsxRuntimeExports.jsx(gtr,{label:R0r(a,E.groupPath),sublabel:T0r(a,E.groupPath),isInitiallyExpanded:v===0,children:E.items.map(({field:_,path:S})=>D.jsxRuntimeExports.jsx(Oqe,{field:_,path:S,viewDef:x},[...S,_.name].join(".")))},E.groupPath.join(".")))})}):null}function w0r({onRefresh:a}){const{source:u}=Y.useContext(ai),[d,f]=Y.useState(""),{onCollapse:m}=Pe.useContext(L$),g=Y.useMemo(()=>u?b0r(u).filter(R=>!Doe(R.field.annotations??[])):[],[u]),x=g.filter(R=>R.field.kind==="view"),E=g.filter(R=>R.field.kind==="measure"),v=g.filter(R=>R.field.kind==="dimension"),_=Y.useMemo(()=>{if(d){const R=d.toLocaleLowerCase();return g.filter(w=>w.field.name.toLocaleLowerCase().includes(R))}return[]},[g,d]),S=!!d;return u?D.jsxRuntimeExports.jsxs("div",{className:"mly78zum5 mlydt5ytf mly5yr21d mly1gzqxud mlyfuqftd",children:[D.jsxRuntimeExports.jsxs("div",{...Lt.props(Fr.body,Z9e.header),children:[D.jsxRuntimeExports.jsxs("div",{className:"mly78zum5 mly1qughib",children:[D.jsxRuntimeExports.jsxs("div",{className:"mly78zum5 mly6s0dn4 mly167g77z mlydqdrvq mlyb3r6kr",children:[D.jsxRuntimeExports.jsx(An,{name:"database",color:"gray"}),D.jsxRuntimeExports.jsx("div",{...Lt.props(Fr.largeBody,Z9e.title),children:u.name})]}),D.jsxRuntimeExports.jsxs("div",{className:"mly78zum5",children:[D.jsxRuntimeExports.jsx($i,{icon:"refresh",tooltip:"Refresh the source",onClick:a,size:"compact",variant:"flat"}),m&&D.jsxRuntimeExports.jsx($i,{icon:"sidebarCollapse",tooltip:"Close the source panel",onClick:m,size:"compact",variant:"flat"})]})]}),D.jsxRuntimeExports.jsx(c$,{value:d,onChange:R=>f(R),placeholder:"Search",size:"compact",icon:"search",hasClear:!0})]}),D.jsxRuntimeExports.jsx(Y_,{}),D.jsxRuntimeExports.jsx("div",{className:"mly78zum5 mlydt5ytf mlyysyzu8 mly1iyjqo2",children:S?D.jsxRuntimeExports.jsx(C0r,{source:u,items:_}):D.jsxRuntimeExports.jsxs(Tcr,{defaultExpandedItemId:"views",children:[D.jsxRuntimeExports.jsx(Jre,{id:"dimensions",label:"Dimensions",startIcon:D.jsxRuntimeExports.jsx(An,{name:"dimension",color:"cyan"}),badge:D.jsxRuntimeExports.jsx(Ex,{label:v.length.toString(),color:"cyan"}),children:D.jsxRuntimeExports.jsx(lne,{source:u,fieldItems:g,fieldGroupType:"dimension"})},"dimensions"),D.jsxRuntimeExports.jsx(Jre,{id:"measures",label:"Measures",startIcon:D.jsxRuntimeExports.jsx(An,{name:"measure",color:"green"}),badge:D.jsxRuntimeExports.jsx(Ex,{label:E.length.toString(),color:"green"}),children:D.jsxRuntimeExports.jsx(lne,{source:u,fieldItems:g,fieldGroupType:"measure"})},"measures"),D.jsxRuntimeExports.jsx(Jre,{id:"views",label:"Views",startIcon:D.jsxRuntimeExports.jsx(An,{name:"view",color:"purple"}),badge:D.jsxRuntimeExports.jsx(Ex,{label:x.length.toString(),color:"purple"}),children:D.jsxRuntimeExports.jsx(lne,{source:u,fieldItems:g,fieldGroupType:"view"})},"views")]})})]}):null}const Z9e={header:{display:"mly78zum5",flexDirection:"mlydt5ytf",padding:"mlye8ttls",paddingInline:null,paddingStart:null,paddingLeft:null,paddingEnd:null,paddingRight:null,paddingBlock:null,paddingTop:null,paddingBottom:null,gap:"mly167g77z",rowGap:null,columnGap:null,$$css:!0},title:{overflow:"mlyb3r6kr",overflowX:null,overflowY:null,textOverflow:"mlylyipyv",fontWeight:"mly1xlr1w8",color:"mly1ue28sr",$$css:!0}};function O0r({icon:a,title:u,tooltip:d}){const{onExpand:f}=Y.useContext(L$);return D.jsxRuntimeExports.jsx("div",{className:"mly78zum5 mlydt5ytf mly7a106z mlylqzeqv mly5yr21d mly1gzqxud mlyfuqftd",children:D.jsxRuntimeExports.jsxs("div",{className:"mly78zum5 mlydt5ytf mly6s0dn4 mlyl56j7k mly167g77z mlye8ttls",children:[D.jsxRuntimeExports.jsx($i,{icon:a,variant:"flat",size:"compact",tooltip:d,onClick:f}),u&&D.jsxRuntimeExports.jsx("div",{...Lt.props(Fr.body,N0r.title),children:u})]})})}const N0r={title:{fontWeight:"mly1xlr1w8",cursor:"mlyt0e3qv","writing-mode":"mly35i7",$$css:!0}};function eIe({isInitiallyExpanded:a=!0,initialWidth:u,minWidth:d,icon:f,title:m,children:g}){const[x,E]=Y.useState(a),[v,_]=Y.useState(u),S=!x;return D.jsxRuntimeExports.jsxs(L$.Provider,{value:{onExpand:()=>E(!0),onCollapse:()=>E(!1)},children:[D.jsxRuntimeExports.jsxs("div",{...{0:{className:"mly1n2onr6 mly5yr21d mly3psx0u"},1:{className:"mly1n2onr6 mly5yr21d mly3psx0u mly1s85apg"}}[!!S<<0],style:{width:`${v}px`},children:[g,D.jsxRuntimeExports.jsx(Acr,{width:v,minWidth:d,onWidthChange:_})]}),S&&D.jsxRuntimeExports.jsx(O0r,{icon:f,title:m})]})}const D0r=new sIe(new Oo),k0r=new D.QueryClient,L0r=D.styled(D.Box)(({theme:a})=>({display:"flex",flexWrap:"wrap",gap:a.spacing(.5),borderBottom:`1px solid ${a.palette.divider}`,minHeight:36})),I0r=D.styled(D.Button)(({theme:a,selected:u})=>({minHeight:36,padding:a.spacing(.5,2),borderRadius:a.shape.borderRadius,background:u?a.palette.action.selected:"none",color:u?a.palette.primary.main:a.palette.text.primary,fontWeight:u?600:400,border:u?`1px solid ${a.palette.primary.main}`:"1px solid transparent",boxShadow:u?a.shadows[1]:"none",textTransform:"uppercase","&:hover":{background:a.palette.action.hover,border:`1px solid ${a.palette.primary.light}`}}));function Uoe({sourceAndPaths:a,saveResult:u,existingQuery:d,existingSourceName:f}){const[m,g]=Pe.useState(f?a.findIndex(v=>v.sourceInfo.name===f):0),[x,E]=Pe.useState(d||jF());return D.jsxRuntimeExports.jsxs(mo,{variant:"outlined",children:[D.jsxRuntimeExports.jsx(Va,{children:D.jsxRuntimeExports.jsxs(D.Stack$1,{sx:{flexDirection:"row",justifyContent:"space-between"},children:[a.length>0&&D.jsxRuntimeExports.jsx(L0r,{children:a.map((v,_)=>D.jsxRuntimeExports.jsx(I0r,{selected:m===_,onClick:()=>g(_),children:v.sourceInfo.name||`Source ${_+1}`},v.sourceInfo.name||_))}),u&&D.jsxRuntimeExports.jsx(D.CardActions,{sx:{padding:"0px 10px 0px 10px",mb:"auto",mt:"auto"},children:D.jsxRuntimeExports.jsx(D.Button,{onClick:()=>u(a[m].modelPath,a[m].sourceInfo.name,x),children:"Save"})})]})}),D.jsxRuntimeExports.jsx(mS,{children:D.jsxRuntimeExports.jsxs(D.Stack$1,{spacing:2,component:"section",children:[D.jsxRuntimeExports.jsx(zoe,{sourceAndPath:a[m],existingQuery:x,onChange:E}),D.jsxRuntimeExports.jsx(D.Box,{height:"5px"})]})})]})}function jF(){return{query:void 0,malloyQuery:void 0,malloyResult:void 0}}function zoe({sourceAndPath:a,onChange:u,existingQuery:d}){const[f,m]=Pe.useState(d||jF()),[g,x]=Pe.useState([]);Pe.useEffect(()=>{u&&u(f)},[u,f]);const{server:E,projectName:v,packageName:_,versionId:S,accessToken:R}=gS(),w=D.useMutation({mutationFn:()=>{const P=new Zr.ASTQuery({source:a.sourceInfo,query:f?.malloyQuery}).toMalloy();return m({...f,query:P}),D0r.executeQuery(v,_,a.modelPath,P,void 0,void 0,S,{baseURL:E,withCredentials:!R,headers:{Authorization:R&&`Bearer ${R}`}})},onSuccess:P=>{if(P){const $=JSON.parse(P.data.result);m({...f,malloyResult:$})}}},k0r),[N,k]=Pe.useState(a.sourceInfo.name);Pe.useEffect(()=>{N!==a.sourceInfo.name&&(k(a.sourceInfo.name),m(jF()))},[a,N]);const B=Pe.useCallback(P=>{m({...f,malloyQuery:P})},[f]);return N!==a.sourceInfo.name?D.jsxRuntimeExports.jsx("div",{children:"Loading..."}):D.jsxRuntimeExports.jsx(tVt,{children:D.jsxRuntimeExports.jsx(rVt,{children:D.jsxRuntimeExports.jsx(GXt,{source:a.sourceInfo,query:f?.malloyQuery,onQueryChange:B,focusedNestViewPath:g,onFocusedNestViewPathChange:x,onDrill:P=>{console.info(P),window.alert("Drill!")},children:D.jsxRuntimeExports.jsx("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:D.jsxRuntimeExports.jsxs("div",{style:{display:"flex",height:"100%",overflowY:"auto"},children:[D.jsxRuntimeExports.jsx(eIe,{isInitiallyExpanded:!0,initialWidth:280,minWidth:180,icon:"database",title:a.sourceInfo.name,children:D.jsxRuntimeExports.jsx(w0r,{onRefresh:()=>m(jF())})}),D.jsxRuntimeExports.jsx(eIe,{isInitiallyExpanded:!0,initialWidth:360,minWidth:280,icon:"filterSliders",title:"Query",children:D.jsxRuntimeExports.jsx(Ymr,{runQuery:()=>{w.mutate(),window.alert(f.malloyQuery)}})}),D.jsxRuntimeExports.jsx(x0r,{source:a.sourceInfo,draftQuery:f?.malloyQuery,setDraftQuery:P=>m({...f,malloyQuery:P}),submittedQuery:f?.malloyQuery?{executionState:w.isPending?"running":"finished",response:{result:f.malloyResult},query:f.malloyQuery,queryResolutionStartMillis:Date.now(),onCancel:w.reset}:void 0,options:{showRawQuery:!0}})]})})})})},a.sourceInfo.name)}const P0r=new TM(new Oo),j0r=new D.QueryClient;function F0r({modelPath:a,expandResults:u,hideResultIcons:d,expandEmbeddings:f,hideEmbeddingIcons:m}){const[g,x]=Pe.useState(!1),[E,v]=Pe.useState(),[_,S]=Pe.useState(0),{server:R,projectName:w,packageName:N,versionId:k,accessToken:B}=gS(),P=M0r(R,N,a);Pe.useEffect(()=>{zv(P,"typescript").then(X=>{v(X)})},[g,P]);const{data:$,isError:q,isLoading:z,error:W}=D.useQuery({queryKey:["package",R,w,N,a,k],queryFn:()=>P0r.getModel(w,N,a,k,{baseURL:R,withCredentials:!B,headers:{Authorization:B&&`Bearer ${B}`}})},j0r);return z?D.jsxRuntimeExports.jsx(D.Typography,{sx:{p:"20px",m:"auto"},children:"Fetching Model..."}):q?D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",sx:{p:"10px",m:"auto"},children:`${N} > ${a} > ${k} - ${W.message}`}):D.jsxRuntimeExports.jsxs(mo,{variant:"outlined",children:[D.jsxRuntimeExports.jsxs(Va,{children:[D.jsxRuntimeExports.jsxs(D.Stack,{sx:{flexDirection:"row",justifyContent:"space-between"},children:[Array.isArray($.data.sourceInfos)&&$.data.sourceInfos.length>0&&D.jsxRuntimeExports.jsx(D.Tabs,{value:_,onChange:(X,J)=>S(J),variant:"scrollable",scrollButtons:"auto",sx:{borderBottom:1,borderColor:"divider",minHeight:36},children:$.data.sourceInfos.map((X,J)=>{let ee;try{ee=JSON.parse(X)}catch{ee={name:String(J)}}return D.jsxRuntimeExports.jsx(D.Tab,{label:ee.name||`Source ${J+1}`,sx:{minHeight:36}},ee.name||J)})}),D.jsxRuntimeExports.jsx(D.CardActions,{sx:{padding:"0px 10px 0px 10px",mb:"auto",mt:"auto"},children:D.jsxRuntimeExports.jsx(D.Tooltip,{title:g?"Hide Embedding":"View Embedding",children:D.jsxRuntimeExports.jsx(D.IconButton,{size:"small",onClick:()=>{x(!g)},children:D.jsxRuntimeExports.jsx(D.LinkOutlinedIcon,{})})})})]}),D.jsxRuntimeExports.jsxs(D.Collapse,{in:g,timeout:"auto",unmountOnExit:!0,children:[D.jsxRuntimeExports.jsx(D.Divider,{}),D.jsxRuntimeExports.jsxs(D.Stack,{sx:{p:"10px",borderRadius:0,flexDirection:"row",justifyContent:"space-between"},children:[D.jsxRuntimeExports.jsx(D.Typography,{sx:{fontSize:"12px","& .line":{textWrap:"wrap"}},children:D.jsxRuntimeExports.jsx("div",{dangerouslySetInnerHTML:{__html:E}})}),D.jsxRuntimeExports.jsx(D.Tooltip,{title:"Copy Embeddable Code",children:D.jsxRuntimeExports.jsx(D.IconButton,{sx:{width:"24px",height:"24px"},onClick:()=>{navigator.clipboard.writeText(P)},children:D.jsxRuntimeExports.jsx(D.ContentCopyIcon,{})})})]})]}),D.jsxRuntimeExports.jsx(D.Divider,{})]}),D.jsxRuntimeExports.jsx(mS,{children:D.jsxRuntimeExports.jsxs(D.Stack,{spacing:2,component:"section",children:[Array.isArray($.data.sourceInfos)&&$.data.sourceInfos.length>0&&D.jsxRuntimeExports.jsx(zoe,{sourceAndPath:{modelPath:a,sourceInfo:JSON.parse($.data.sourceInfos[_])}}),$.data.queries?.length>0&&D.jsxRuntimeExports.jsxs(mo,{variant:"outlined",sx:{padding:"0px 10px 0px 10px"},children:[D.jsxRuntimeExports.jsx(Va,{sx:{p:"10px"},children:D.jsxRuntimeExports.jsx(D.Typography,{variant:"subtitle1",children:"Named Queries"})}),D.jsxRuntimeExports.jsx(D.Stack,{spacing:1,component:"section",children:$.data.queries.map(X=>D.jsxRuntimeExports.jsx(ZWt,{server:R,projectName:w,packageName:N,modelPath:a,versionId:k,queryName:X.name,expandResult:u,hideResultIcon:d,expandEmbedding:f,hideEmbeddingIcon:m,accessToken:B,noView:!0,annotations:X.annotations},X.name))}),D.jsxRuntimeExports.jsx(D.Box$1,{height:"10px"})]}),D.jsxRuntimeExports.jsx(D.Box$1,{height:"5px"})]})})]})}function M0r(a,u,d){return`<Model
|
|
2884
2884
|
server="${a}"
|
|
2885
2885
|
packageName="${u}"
|
|
2886
2886
|
modelPath="${d}"
|
|
@@ -2889,7 +2889,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${u.do
|
|
|
2889
2889
|
server="${a}"
|
|
2890
2890
|
accessToken={accessToken}
|
|
2891
2891
|
projectName="${u}"
|
|
2892
|
-
packageName="${d}"
|
|
2892
|
+
packageName="${d}"
|
|
2893
2893
|
modelPath="${f}"
|
|
2894
2894
|
query="
|
|
2895
2895
|
${m}
|
package/dist/index.es.js
CHANGED
|
@@ -137249,17 +137249,16 @@ function SUe({
|
|
|
137249
137249
|
), [N, D] = wr.useState(
|
|
137250
137250
|
a.sourceInfo.name
|
|
137251
137251
|
);
|
|
137252
|
-
|
|
137252
|
+
wr.useEffect(() => {
|
|
137253
137253
|
N !== a.sourceInfo.name && (D(a.sourceInfo.name), m(hj()));
|
|
137254
|
-
}, [a, N])
|
|
137255
|
-
return /* @__PURE__ */ P.jsx("div", { children: "Loading..." });
|
|
137254
|
+
}, [a, N]);
|
|
137256
137255
|
const B = wr.useCallback(
|
|
137257
137256
|
(I) => {
|
|
137258
137257
|
m({ ...f, malloyQuery: I });
|
|
137259
137258
|
},
|
|
137260
137259
|
[f]
|
|
137261
137260
|
);
|
|
137262
|
-
return /* @__PURE__ */ P.jsx(RQt, { children: /* @__PURE__ */ P.jsx(OQt, { children: /* @__PURE__ */ P.jsx(
|
|
137261
|
+
return N !== a.sourceInfo.name ? /* @__PURE__ */ P.jsx("div", { children: "Loading..." }) : /* @__PURE__ */ P.jsx(RQt, { children: /* @__PURE__ */ P.jsx(OQt, { children: /* @__PURE__ */ P.jsx(
|
|
137263
137262
|
vZt,
|
|
137264
137263
|
{
|
|
137265
137264
|
source: a.sourceInfo,
|
|
@@ -138623,7 +138622,7 @@ function W1r(a, u, d, f, m) {
|
|
|
138623
138622
|
server="${a}"
|
|
138624
138623
|
accessToken={accessToken}
|
|
138625
138624
|
projectName="${u}"
|
|
138626
|
-
packageName="${d}"
|
|
138625
|
+
packageName="${d}"
|
|
138627
138626
|
modelPath="${f}"
|
|
138628
138627
|
query="
|
|
138629
138628
|
${m}
|
package/package.json
CHANGED
|
@@ -250,10 +250,6 @@ export function SourceExplorerComponent({
|
|
|
250
250
|
}
|
|
251
251
|
}, [sourceAndPath, oldSourceInfo]);
|
|
252
252
|
|
|
253
|
-
if (oldSourceInfo !== sourceAndPath.sourceInfo.name) {
|
|
254
|
-
return <div>Loading...</div>;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
253
|
const onQueryChange = React.useCallback(
|
|
258
254
|
(malloyQuery: Malloy.Query) => {
|
|
259
255
|
setQuery({ ...query, malloyQuery });
|
|
@@ -261,6 +257,10 @@ export function SourceExplorerComponent({
|
|
|
261
257
|
[query],
|
|
262
258
|
);
|
|
263
259
|
|
|
260
|
+
if (oldSourceInfo !== sourceAndPath.sourceInfo.name) {
|
|
261
|
+
return <div>Loading...</div>;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
264
|
return (
|
|
265
265
|
<StyledExplorerPage key={sourceAndPath.sourceInfo.name}>
|
|
266
266
|
<StyledExplorerContent>
|