@malloy-publisher/sdk 0.0.23 → 0.0.26
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 +2 -2
- package/dist/index.es.js +47 -50
- package/package.json +1 -1
- package/src/components/Model/SourcesExplorer.tsx +12 -13
- package/src/components/Notebook/NotebookCell.tsx +7 -1
- package/src/components/Package/Connections.tsx +3 -24
- package/src/components/Package/Models.tsx +22 -25
- package/src/components/Package/Notebooks.tsx +22 -27
package/dist/index.cjs.js
CHANGED
|
@@ -2880,12 +2880,12 @@ 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);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
|
|
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()}})}),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}"
|
|
2887
2887
|
accessToken={accessToken}
|
|
2888
|
-
/>`}D.axios.defaults.baseURL="http://localhost:4000";const $0r=new nIe(new Oo),B0r=new D.QueryClient;function q0r({server:a,projectName:u,packageName:d,versionId:f,accessToken:m}){const{data:g,isSuccess:x,isError:E,error:v}=D.useQuery({queryKey:["package",a,u,d,f],queryFn:()=>$0r.getPackage(u,d,f,!1,{baseURL:a,withCredentials:!m,headers:{Authorization:m&&`Bearer ${m}`}}),retry:!1},B0r);return D.jsxRuntimeExports.jsx(mo,{variant:"outlined",sx:{padding:"10px",width:"100%"},children:D.jsxRuntimeExports.jsxs(Va,{children:[D.jsxRuntimeExports.jsx(D.Typography,{variant:"overline",fontWeight:"bold",children:"Package Config"}),D.jsxRuntimeExports.jsx(D.Divider,{}),D.jsxRuntimeExports.jsx(D.Box$1,{sx:{mt:"10px",maxHeight:"200px",overflowY:"auto"},children:D.jsxRuntimeExports.jsxs(D.List,{dense:!0,disablePadding:!0,children:[D.jsxRuntimeExports.jsx(D.ListItem,{dense:!0,disablePadding:!0,children:D.jsxRuntimeExports.jsx(D.ListItemText,{primary:"Name",secondary:d})}),!x&&!E&&D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",sx:{p:"20px",m:"auto"},children:"Fethching Package Metadata..."}),x&&(g.data&&D.jsxRuntimeExports.jsx(D.ListItem,{dense:!0,disablePadding:!0,children:D.jsxRuntimeExports.jsx(D.ListItemText,{primary:"Description",secondary:g.data.description})})||D.jsxRuntimeExports.jsxs(D.ListItem,{disablePadding:!0,dense:!0,sx:{mt:"20px"},children:[D.jsxRuntimeExports.jsx(D.ErrorIcon,{sx:{color:"grey.600",mr:"10px"}}),D.jsxRuntimeExports.jsx(D.ListItemText,{primary:"No package manifest"})]})),E&&D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",sx:{p:"10px",m:"auto"},children:`${u} > ${d} > ${f} - ${v.message}`})]})})]})})}const U0r=new Aie(new Oo),z0r=new D.QueryClient;function H0r({connectionProps:a,connection:u}){const{projectName:d}=a;return D.jsxRuntimeExports.jsxs(D.TableRow,{children:[D.jsxRuntimeExports.jsx(D.TableCell,{children:D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",sx:{cursor:"pointer",color:"primary.main"},onClick:()=>a.navigate(`/${d}/connections/${u.name}/`),children:u.name})}),D.jsxRuntimeExports.jsx(D.TableCell,{children:D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",children:u.type})})]},u.name)}function G0r(a){const{server:u,projectName:d,accessToken:f}=a,{data:m,isSuccess:g,isError:x,error:E}=D.useQuery({queryKey:["connections",u,d],queryFn:()=>U0r.listConnections(d,{baseURL:u,withCredentials:!f,headers:{Authorization:f&&`Bearer ${f}`}}),retry:!1},z0r);return D.jsxRuntimeExports.jsx(mo,{variant:"outlined",sx:{padding:"10px",width:"100%"},children:D.jsxRuntimeExports.jsxs(Va,{children:[D.jsxRuntimeExports.jsx(D.Typography,{variant:"overline",fontWeight:"bold",children:"Database Connections"}),D.jsxRuntimeExports.jsx(D.Divider,{}),D.jsxRuntimeExports.jsxs(D.Box$1,{sx:{mt:"10px",maxHeight:"200px",overflowY:"auto"},children:[!g&&!x&&D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",sx:{p:"20px",m:"auto"},children:"Fetching Connections..."}),g&&m.data.length>0&&D.jsxRuntimeExports.jsx(D.Table,{size:"small",children:D.jsxRuntimeExports.jsxs(D.TableBody,{children:[D.jsxRuntimeExports.jsxs(D.TableRow,{children:[D.jsxRuntimeExports.jsx(D.TableCell,{children:D.jsxRuntimeExports.jsx(D.Typography,{variant:"subtitle2",fontWeight:"bold",children:"Connection Name"})}),D.jsxRuntimeExports.jsx(D.TableCell,{children:D.jsxRuntimeExports.jsx(D.Typography,{variant:"subtitle2",fontWeight:"bold",children:"Type"})})]}),m.data.map(v=>D.jsxRuntimeExports.jsx(H0r,{connectionProps:a,connection:v},v.name))]})}),g&&m.data.length===0&&D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",children:"No Connections"}),x&&D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",sx:{p:"10px",m:"auto"},children:`${d} - ${E.message}`})]})]})})}const W0r=new WHt(new Oo),V0r=new D.QueryClient;function Q0r({server:a,projectName:u,packageName:d,versionId:f,accessToken:m}){const{data:g,isSuccess:x,isError:E,error:v}=D.useQuery({queryKey:["databases",a,u,d,f],queryFn:()=>W0r.listDatabases(u,d,f,{baseURL:a,withCredentials:!m,headers:{Authorization:m&&`Bearer ${m}`}}),retry:!1},V0r),_=S=>S>=1024*1024*1024*1024?`${(S/(1024*1024*1024)).toFixed(2)} T`:S>=1024*1024*1024?`${(S/(1024*1024*1024)).toFixed(2)} G`:S>=1024*1024?`${(S/(1024*1024)).toFixed(2)} M`:`${(S/1024).toFixed(2)} K`;return D.jsxRuntimeExports.jsx(mo,{variant:"outlined",sx:{padding:"10px",width:"100%"},children:D.jsxRuntimeExports.jsxs(Va,{children:[D.jsxRuntimeExports.jsx(D.Typography,{variant:"overline",fontWeight:"bold",children:"Embedded Databases"}),D.jsxRuntimeExports.jsx(D.Divider,{}),D.jsxRuntimeExports.jsxs(D.Box$1,{sx:{mt:"10px",maxHeight:"200px",overflowY:"auto"},children:[!x&&!E&&D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",sx:{p:"20px",m:"auto"},children:"Fetching Databases..."}),x&&g.data.length>0&&D.jsxRuntimeExports.jsx(D.TableContainer,{children:D.jsxRuntimeExports.jsxs(D.Table,{size:"small",children:[D.jsxRuntimeExports.jsx(D.TableHead,{children:D.jsxRuntimeExports.jsxs(D.TableRow,{children:[D.jsxRuntimeExports.jsx(D.TableCell,{children:D.jsxRuntimeExports.jsx(D.Typography,{variant:"subtitle2",fontWeight:"bold",children:"Database Name"})}),D.jsxRuntimeExports.jsx(D.TableCell,{align:"right",children:D.jsxRuntimeExports.jsx(D.Typography,{variant:"subtitle2",fontWeight:"bold",children:"Table Rows"})})]})}),D.jsxRuntimeExports.jsx(D.TableBody,{children:g.data.map(S=>D.jsxRuntimeExports.jsxs(D.TableRow,{children:[D.jsxRuntimeExports.jsx(D.TableCell,{children:D.jsxRuntimeExports.jsx(Y0r,{database:S})}),D.jsxRuntimeExports.jsx(D.TableCell,{align:"right",children:D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",children:_(S.info.rowCount)})})]},S.path))})]})}),x&&g.data.length===0&&D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",children:"No Embedded Databases"}),E&&D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",sx:{p:"10px",m:"auto"},children:`${u} > ${d} > ${f} - ${v.message}`})]})]})})}function Y0r({database:a}){const[u,d]=Pe.useState(!1);return D.jsxRuntimeExports.jsxs(D.Box$1,{sx:{display:"flex",alignItems:"center"},onClick:()=>d(!u),style:{cursor:"pointer"},children:[D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",color:"primary",sx:{maxWidth:"200px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a.path})," ",D.jsxRuntimeExports.jsx(D.Box$1,{sx:{display:"flex",alignItems:"center"},children:D.jsxRuntimeExports.jsx(D.Box$1,{sx:{mr:1,display:"flex",alignItems:"center"},children:D.jsxRuntimeExports.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[D.jsxRuntimeExports.jsx("path",{d:"M11 7H6C5.46957 7 4.96086 7.21071 4.58579 7.58579C4.21071 7.96086 4 8.46957 4 9V18C4 18.5304 4.21071 19.0391 4.58579 19.4142C4.96086 19.7893 5.46957 20 6 20H15C15.5304 20 16.0391 19.7893 16.4142 19.4142C16.7893 19.0391 17 18.5304 17 18V13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),D.jsxRuntimeExports.jsx("path",{d:"M9 15L20 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),D.jsxRuntimeExports.jsx("path",{d:"M15 4H20V9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})})}),D.jsxRuntimeExports.jsx(K0r,{database:a,open:u,setClose:()=>d(!1)})]})}function K0r({database:a,open:u,setClose:d}){return D.jsxRuntimeExports.jsxs(D.Dialog,{open:u,onClose:d,maxWidth:"sm",fullWidth:!0,children:[D.jsxRuntimeExports.jsxs(D.DialogTitle,{children:["Schema:"," ",D.jsxRuntimeExports.jsx(D.Typography,{fontSize:"large",variant:"body2",fontFamily:"monospace",component:"span",children:a.path}),D.jsxRuntimeExports.jsx(D.IconButton,{"aria-label":"close",onClick:d,sx:{position:"absolute",right:8,top:8},children:D.jsxRuntimeExports.jsx(D.Box$1,{sx:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center"},children:"X"})})]}),D.jsxRuntimeExports.jsx(D.DialogContent,{children:D.jsxRuntimeExports.jsx(D.TableContainer,{children:D.jsxRuntimeExports.jsxs(D.Table,{size:"small",sx:{"& .MuiTableCell-root":{padding:"10px"}},children:[D.jsxRuntimeExports.jsx(D.TableHead,{children:D.jsxRuntimeExports.jsxs(D.TableRow,{children:[D.jsxRuntimeExports.jsx(D.TableCell,{children:"NAME"}),D.jsxRuntimeExports.jsx(D.TableCell,{children:"TYPE"})]})}),D.jsxRuntimeExports.jsx(D.TableBody,{children:a.info.columns.map(f=>D.jsxRuntimeExports.jsxs(D.TableRow,{children:[D.jsxRuntimeExports.jsx(D.TableCell,{children:f.name}),D.jsxRuntimeExports.jsx(D.TableCell,{children:f.type})]},f.name))})]})})})]})}function Nqe({items:a,defaultExpandedItems:u,navigate:d}){return D.jsxRuntimeExports.jsx(D.RichTreeView,{items:tgr(a,d),defaultExpandedItems:u,slots:{item:egr}})}const X0r=D.animated(D.Collapse);function J0r(a){const u=D.useSpring({to:{opacity:a.in?1:0,transform:`translate3d(0,${a.in?0:20}px,0)`}});return D.jsxRuntimeExports.jsx(X0r,{style:u,...a})}function Z0r({item:a,...u}){return D.jsxRuntimeExports.jsxs(D.TreeItem2Label,{...u,sx:{display:"flex",alignItems:"center",color:"grey.600"},children:[a.fileType==="directory"&&D.jsxRuntimeExports.jsx(D.FolderIcon,{})||a.fileType==="notebook"&&D.jsxRuntimeExports.jsx(D.ArticleIcon,{})||a.fileType==="model"&&D.jsxRuntimeExports.jsx(D.DataArrayIcon,{})||a.fileType=="database"&&D.jsxRuntimeExports.jsx(D.DnsIcon,{})||D.jsxRuntimeExports.jsx(D.ErrorIcon,{}),D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",sx:{marginLeft:"5px"},color:a.link?"primary.main":"grey.600",children:a.label})]})}const egr=Y.forwardRef(function(u,d){const{id:f,itemId:m,label:g,children:x,disabled:E,...v}=u,{getRootProps:_,getContentProps:S,getLabelProps:R,getIconContainerProps:w,getGroupTransitionProps:N,status:k,publicAPI:B}=D.unstable_useTreeItem2({id:f,itemId:m,children:x,label:g,disabled:E,rootRef:d}),P=B.getItem(m);return k.selected=!1,k.focused=!1,D.jsxRuntimeExports.jsx(D.TreeItem2Provider,{itemId:m,children:D.jsxRuntimeExports.jsxs(D.TreeItem2Root,{..._(v),children:[D.jsxRuntimeExports.jsxs(D.TreeItem2Content,{...S(),...P.link&&{onClick:()=>P.link()},sx:{pointerEvents:!P.selectable&&"none"},children:[D.jsxRuntimeExports.jsx(D.TreeItem2IconContainer,{...w(),children:D.jsxRuntimeExports.jsx(D.TreeItem2Icon,{status:k})}),D.jsxRuntimeExports.jsx(Z0r,{...R({item:P})})]}),x&&D.jsxRuntimeExports.jsx(J0r,{...N()})]})})});function tgr(a,u){const d=new Map;return a.map(f=>{let m=d;const g=f.path.split("/");g.forEach((x,E)=>{E===g.length-1?m.set(x,f):(m.has(x)||m.set(x,new Map),m=m.get(x))})}),Dqe(d,"",u)}function Dqe(a,u,d){const f=[];return a.forEach((m,g)=>{const x=g.endsWith(".malloy")&&"model"||g.endsWith(".malloynb")&&"notebook"||g.endsWith(".parquet")&&"database"||"unknown";x!=="unknown"?f.push({id:u+g,label:g,fileType:x,link:x==="model"||x==="notebook"?d.bind(null,u+g):void 0,selectable:x==="model"||x==="notebook"}):(u+=`${g}/`,f.push({id:u,label:g,fileType:"directory",selectable:!0,link:void 0,children:Dqe(m,u,d)}))}),f}D.axios.defaults.baseURL="http://localhost:4000";const rgr=new TM(new Oo),ngr=new D.QueryClient,igr=["notebooks/","models/"];function sgr({server:a,projectName:u,packageName:d,versionId:f,navigate:m,accessToken:g}){const{data:x,isError:E,error:v,isLoading:_}=D.useQuery({queryKey:["models",a,u,d,f],queryFn:()=>rgr.listModels(u,d,f,{baseURL:a,withCredentials:!g,headers:{Authorization:g&&`Bearer ${g}`}}),retry:!1},ngr);return E?D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",sx:{p:"10px",m:"auto"},children:`${u} > ${d} > ${f} - ${v.message}`}):_?D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",sx:{p:"10px",m:"auto"},children:"Fetching Models..."}):D.jsxRuntimeExports.jsx(mo,{variant:"outlined",sx:{padding:"10px",width:"100%"},children:D.jsxRuntimeExports.jsxs(Va,{children:[D.jsxRuntimeExports.jsx(D.Typography,{variant:"overline",fontWeight:"bold",children:"Semantic Models"}),D.jsxRuntimeExports.jsx(D.Divider,{}),D.jsxRuntimeExports.jsx(D.Box$1,{sx:{mt:"10px",maxHeight:"200px",overflowY:"auto"},children:x.data.length>0?D.jsxRuntimeExports.jsx(Nqe,{items:x.data.sort((S,R)=>S.path.localeCompare(R.path)),defaultExpandedItems:igr,navigate:m}):D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",sx:{p:"10px",m:"auto"},children:"No models found"})})]})})}const ogr=new rIe(new Oo),agr=new D.QueryClient,lgr=["notebooks/"];function ugr({server:a,projectName:u,packageName:d,versionId:f,navigate:m,accessToken:g}){const{data:x,isLoading:E,isError:v,error:_}=D.useQuery({queryKey:["notebooks",a,u,d,f],queryFn:()=>ogr.listNotebooks(u,d,f,{baseURL:a,withCredentials:!g,headers:{Authorization:g&&`Bearer ${g}`}}),retry:!1},agr);return v?D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",sx:{p:"10px",m:"auto"},children:`${u} > ${d} > ${f} - ${_.message}`}):E?D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",sx:{p:"10px",m:"auto"},children:"Fetching Notebooks..."}):D.jsxRuntimeExports.jsx(mo,{variant:"outlined",sx:{padding:"10px",width:"100%"},children:D.jsxRuntimeExports.jsxs(Va,{children:[D.jsxRuntimeExports.jsx(D.Typography,{variant:"overline",fontWeight:"bold",children:"Notebooks"}),D.jsxRuntimeExports.jsx(D.Divider,{}),D.jsxRuntimeExports.jsx(D.Box$1,{sx:{mt:"10px",maxHeight:"200px",overflowY:"auto"},children:x.data.length>0?D.jsxRuntimeExports.jsx(Nqe,{items:x.data.sort((S,R)=>S.path.localeCompare(R.path)),defaultExpandedItems:lgr,navigate:m}):D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",sx:{p:"10px",m:"auto"},children:"No notebooks found"})})]})})}D.axios.defaults.baseURL="http://localhost:4000";const cgr=new tGt(new Oo),dgr=new D.QueryClient;function fgr({server:a,projectName:u,packageName:d,versionId:f,accessToken:m}){const{data:g,isError:x,isLoading:E,error:v}=D.useQuery({queryKey:["schedules",a,u,d,f],queryFn:()=>cgr.listSchedules(u,d,f,{baseURL:a,withCredentials:!m,headers:{Authorization:m&&`Bearer ${m}`}}),retry:!1},dgr);return E?D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",sx:{p:"20px",m:"auto"},children:"Fetching Schedules..."}):x?D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",sx:{p:"10px",m:"auto"},children:`${d} > ${f} - ${v.message}`}):g.data.length?D.jsxRuntimeExports.jsx(mo,{variant:"outlined",sx:{padding:"10px",width:"100%"},children:D.jsxRuntimeExports.jsxs(Va,{children:[D.jsxRuntimeExports.jsx(D.Typography,{variant:"overline",fontWeight:"bold",children:"Scheduler"}),D.jsxRuntimeExports.jsx(D.Divider,{}),D.jsxRuntimeExports.jsx(D.Box$1,{sx:{mt:"10px",maxHeight:"200px",overflowY:"auto"},children:D.jsxRuntimeExports.jsx(D.TableContainer,{component:D.Paper,children:D.jsxRuntimeExports.jsxs(D.Table,{sx:{minWidth:300},size:"small",children:[D.jsxRuntimeExports.jsx(D.TableHead,{children:D.jsxRuntimeExports.jsxs(D.TableRow,{children:[D.jsxRuntimeExports.jsx(D.TableCell,{align:"left",children:"Resource"}),D.jsxRuntimeExports.jsx(D.TableCell,{align:"left",children:"Schedule"}),D.jsxRuntimeExports.jsx(D.TableCell,{align:"left",children:"Action"}),D.jsxRuntimeExports.jsx(D.TableCell,{align:"left",children:"Connection"}),D.jsxRuntimeExports.jsx(D.TableCell,{align:"left",children:"Last Run"}),D.jsxRuntimeExports.jsx(D.TableCell,{align:"left",children:"Status"})]})}),D.jsxRuntimeExports.jsx(D.TableBody,{children:g.data.map(_=>D.jsxRuntimeExports.jsxs(D.TableRow,{sx:{"&:last-child td, &:last-child th":{border:0}},children:[D.jsxRuntimeExports.jsx(D.TableCell,{align:"left",children:_.resource}),D.jsxRuntimeExports.jsx(D.TableCell,{align:"left",children:_.schedule}),D.jsxRuntimeExports.jsx(D.TableCell,{align:"left",children:_.action}),D.jsxRuntimeExports.jsx(D.TableCell,{align:"left",children:_.connection}),D.jsxRuntimeExports.jsx(D.TableCell,{align:"left",children:_.lastRunTime?new Date(_.lastRunTime).toLocaleString():"n/a"}),D.jsxRuntimeExports.jsx(D.TableCell,{align:"left",children:_.lastRunStatus})]},_.resource))})]})})})]})}):null}const hgr="README.malloynb";function pgr({server:a,projectName:u,packageName:d,versionId:f,navigate:m,accessToken:g}){return m||(m=x=>{window.location.href=x}),D.jsxRuntimeExports.jsx(FIe,{server:a,accessToken:g,projectName:u,packageName:d,versionId:f,children:D.jsxRuntimeExports.jsxs(D.Grid,{container:!0,spacing:2,columns:12,sx:{mb:x=>x.spacing(2)},children:[D.jsxRuntimeExports.jsx(D.Grid,{size:{xs:12,md:4},children:D.jsxRuntimeExports.jsx(q0r,{server:a,projectName:u,packageName:d,versionId:f,accessToken:g})}),D.jsxRuntimeExports.jsx(D.Grid,{size:{xs:12,md:4},children:D.jsxRuntimeExports.jsx(ugr,{server:a,projectName:u,packageName:d,versionId:f,navigate:m,accessToken:g})}),D.jsxRuntimeExports.jsx(D.Grid,{size:{xs:12,md:4},children:D.jsxRuntimeExports.jsx(sgr,{server:a,projectName:u,packageName:d,versionId:f,navigate:m,accessToken:g})}),D.jsxRuntimeExports.jsx(D.Grid,{size:{xs:12,md:6},children:D.jsxRuntimeExports.jsx(Q0r,{server:a,projectName:u,packageName:d,versionId:f,accessToken:g})}),D.jsxRuntimeExports.jsx(D.Grid,{size:{xs:12,md:6},children:D.jsxRuntimeExports.jsx(G0r,{navigate:m,server:a,projectName:u,accessToken:g})}),D.jsxRuntimeExports.jsx(D.Grid,{size:{xs:12,md:12},children:D.jsxRuntimeExports.jsx(fgr,{server:a,projectName:u,packageName:d,versionId:f,accessToken:g})}),D.jsxRuntimeExports.jsx(D.Grid,{size:{xs:12,md:12},children:D.jsxRuntimeExports.jsx(kqe,{notebookPath:hgr,expandCodeCells:!0})})]})})}const mgr=Pe.lazy(()=>Promise.resolve().then(()=>require("./RenderedResult-DjdrYRPY.cjs")));function ggr({cell:a,notebookPath:u,queryResultCodeSnippet:d,expandCodeCell:f,hideCodeCellIcon:m,expandEmbedding:g,hideEmbeddingIcon:x}){const[E,v]=Pe.useState(f||a.type==="code"&&!a.result),[_,S]=Pe.useState(g),[R,w]=Pe.useState(),[N,k]=Pe.useState(),[B,P]=Pe.useState(!1);return Pe.useEffect(()=>{a.type==="code"&&zv(a.text,"malloy").then($=>{w($)})},[a]),Pe.useEffect(()=>{zv(d,"typescript").then($=>{k($)})},[d]),a.type==="markdown"&&D.jsxRuntimeExports.jsx(mo,{variant:"outlined",sx:{border:0},children:D.jsxRuntimeExports.jsx(Va,{children:D.jsxRuntimeExports.jsx(D.Markdown,{children:a.text})})})||a.type==="code"&&D.jsxRuntimeExports.jsxs(mo,{variant:"outlined",children:[(!m||!x&&a.result)&&D.jsxRuntimeExports.jsx(D.Stack,{sx:{flexDirection:"row",justifyContent:"right"},children:D.jsxRuntimeExports.jsxs(D.CardActions,{sx:{padding:"0px 10px 0px 10px",mb:"auto",mt:"auto"},children:[!m&&D.jsxRuntimeExports.jsx(D.Tooltip,{title:E?"Hide Code":"View Code",children:D.jsxRuntimeExports.jsx(D.IconButton,{size:"small",onClick:()=>{v(!E)},children:D.jsxRuntimeExports.jsx(D.CodeIcon,{})})}),!x&&a.result&&D.jsxRuntimeExports.jsx(D.Tooltip,{title:_?"Hide Embedding":"View Embedding",children:D.jsxRuntimeExports.jsx(D.IconButton,{size:"small",onClick:()=>{S(!_)},children:D.jsxRuntimeExports.jsx(D.LinkOutlinedIcon,{})})}),a.newSources&&a.newSources.length>0&&D.jsxRuntimeExports.jsx(D.Tooltip,{title:"Explore Data Sources",children:D.jsxRuntimeExports.jsx(D.IconButton,{size:"small",onClick:()=>{P(!B),S(!1),v(!1)},children:D.jsxRuntimeExports.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:D.jsxRuntimeExports.jsx("path",{d:"M3 3h18v18H3V3zm2 2v14h14V5H5zm2 2h10v2H7V7zm0 4h10v2H7v-2zm0 4h10v2H7v-2z",fill:"currentColor"})})})})]})}),D.jsxRuntimeExports.jsxs(D.Collapse,{in:_,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,{component:"div",sx:{fontSize:"12px","& .line":{textWrap:"wrap"}},dangerouslySetInnerHTML:{__html:N}}),D.jsxRuntimeExports.jsx(D.Tooltip,{title:"Copy Embeddable Code",children:D.jsxRuntimeExports.jsx(D.IconButton,{sx:{width:"24px",height:"24px"},onClick:()=>{navigator.clipboard.writeText(d)},children:D.jsxRuntimeExports.jsx(D.ContentCopyIcon,{})})})]})]}),D.jsxRuntimeExports.jsxs(D.Collapse,{in:E,timeout:"auto",unmountOnExit:!0,children:[D.jsxRuntimeExports.jsx(D.Divider,{}),D.jsxRuntimeExports.jsx(D.Stack,{sx:{p:"10px",borderRadius:0,flexDirection:"row",justifyContent:"space-between"},children:D.jsxRuntimeExports.jsx(D.Typography,{component:"div",className:"content",sx:{fontSize:"12px","& .line":{textWrap:"wrap"}},dangerouslySetInnerHTML:{__html:R}})})]}),D.jsxRuntimeExports.jsxs(D.Collapse,{in:B,timeout:"auto",unmountOnExit:!0,children:[D.jsxRuntimeExports.jsx(D.Stack,{sx:{p:"10px"},children:D.jsxRuntimeExports.jsx(D.Typography,{children:"Sources"})}),D.jsxRuntimeExports.jsx(Uoe,{sourceAndPaths:a.newSources.map($=>({sourceInfo:JSON.parse($),modelPath:u}))})]}),a.result&&!B&&D.jsxRuntimeExports.jsxs(D.jsxRuntimeExports.Fragment,{children:[D.jsxRuntimeExports.jsx(D.Divider,{sx:{mb:"10px"}}),D.jsxRuntimeExports.jsx(D.CardContent,{sx:{maxHeight:"800px",overflow:"auto"},children:D.jsxRuntimeExports.jsx(Pe.Suspense,{fallback:"Loading malloy...",children:D.jsxRuntimeExports.jsx(mgr,{result:a.result})})})]})]})}const xgr=new rIe(new Oo),ygr=new D.QueryClient;function kqe({notebookPath:a,expandCodeCells:u,hideCodeCellIcons:d,expandEmbeddings:f,hideEmbeddingIcons:m}){const[g,x]=Pe.useState(!1),[E,v]=Pe.useState(),{server:_,projectName:S,packageName:R,accessToken:w,versionId:N}=gS(),k=bgr(_,R,a,!0);Pe.useEffect(()=>{zv(k,"typescript").then(z=>{v(z)})},[g,k]);const{data:B,isSuccess:P,isError:$,error:q}=D.useQuery({queryKey:["notebook",_,S,R,a,N],queryFn:()=>xgr.getNotebook(S,R,a,N,{baseURL:_,withCredentials:!w,headers:{Authorization:w&&`Bearer ${w}`}}),retry:!1},ygr);return D.jsxRuntimeExports.jsxs(mo,{variant:"outlined",children:[D.jsxRuntimeExports.jsxs(Va,{children:[D.jsxRuntimeExports.jsxs(D.Stack,{sx:{flexDirection:"row",justifyContent:"space-between"},children:[D.jsxRuntimeExports.jsx(D.Typography,{variant:"overline",fontWeight:"bold",children:"Notebook"}),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(k)},children:D.jsxRuntimeExports.jsx(D.ContentCopyIcon,{})})})]})]}),D.jsxRuntimeExports.jsx(D.Divider,{})]}),D.jsxRuntimeExports.jsx(mS,{children:D.jsxRuntimeExports.jsxs(D.Stack,{spacing:1,component:"section",children:[!P&&!$&&D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",sx:{p:"10px",m:"auto"},children:"Fetching Notebook..."}),P&&B.data.notebookCells?.map((z,W)=>D.jsxRuntimeExports.jsx(ggr,{cell:z,notebookPath:a,queryResultCodeSnippet:vgr(_,S,R,a,z.text),expandCodeCell:u,hideCodeCellIcon:d,expandEmbedding:f,hideEmbeddingIcon:m},W)),$&&D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",sx:{p:"10px",m:"auto"},children:q.message.includes("404")&&`${a} does not exist`||`${S} > ${R} > ${a} > ${N} - ${q.message}`})]})})]})}function vgr(a,u,d,f,m){return`<QueryResult
|
|
2888
|
+
/>`}D.axios.defaults.baseURL="http://localhost:4000";const $0r=new nIe(new Oo),B0r=new D.QueryClient;function q0r({server:a,projectName:u,packageName:d,versionId:f,accessToken:m}){const{data:g,isSuccess:x,isError:E,error:v}=D.useQuery({queryKey:["package",a,u,d,f],queryFn:()=>$0r.getPackage(u,d,f,!1,{baseURL:a,withCredentials:!m,headers:{Authorization:m&&`Bearer ${m}`}}),retry:!1},B0r);return D.jsxRuntimeExports.jsx(mo,{variant:"outlined",sx:{padding:"10px",width:"100%"},children:D.jsxRuntimeExports.jsxs(Va,{children:[D.jsxRuntimeExports.jsx(D.Typography,{variant:"overline",fontWeight:"bold",children:"Package Config"}),D.jsxRuntimeExports.jsx(D.Divider,{}),D.jsxRuntimeExports.jsx(D.Box$1,{sx:{mt:"10px",maxHeight:"200px",overflowY:"auto"},children:D.jsxRuntimeExports.jsxs(D.List,{dense:!0,disablePadding:!0,children:[D.jsxRuntimeExports.jsx(D.ListItem,{dense:!0,disablePadding:!0,children:D.jsxRuntimeExports.jsx(D.ListItemText,{primary:"Name",secondary:d})}),!x&&!E&&D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",sx:{p:"20px",m:"auto"},children:"Fethching Package Metadata..."}),x&&(g.data&&D.jsxRuntimeExports.jsx(D.ListItem,{dense:!0,disablePadding:!0,children:D.jsxRuntimeExports.jsx(D.ListItemText,{primary:"Description",secondary:g.data.description})})||D.jsxRuntimeExports.jsxs(D.ListItem,{disablePadding:!0,dense:!0,sx:{mt:"20px"},children:[D.jsxRuntimeExports.jsx(D.ErrorIcon,{sx:{color:"grey.600",mr:"10px"}}),D.jsxRuntimeExports.jsx(D.ListItemText,{primary:"No package manifest"})]})),E&&D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",sx:{p:"10px",m:"auto"},children:`${u} > ${d} > ${f} - ${v.message}`})]})})]})})}const U0r=new Aie(new Oo),z0r=new D.QueryClient;function H0r({connection:a}){return D.jsxRuntimeExports.jsxs(D.TableRow,{children:[D.jsxRuntimeExports.jsx(D.TableCell,{children:D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",children:a.name})}),D.jsxRuntimeExports.jsx(D.TableCell,{children:D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",children:a.type})})]},a.name)}function G0r(a){const{server:u,projectName:d,accessToken:f}=a,{data:m,isSuccess:g,isError:x,error:E}=D.useQuery({queryKey:["connections",u,d],queryFn:()=>U0r.listConnections(d,{baseURL:u,withCredentials:!f,headers:{Authorization:f&&`Bearer ${f}`}}),retry:!1},z0r);return D.jsxRuntimeExports.jsx(mo,{variant:"outlined",sx:{padding:"10px",width:"100%"},children:D.jsxRuntimeExports.jsxs(Va,{children:[D.jsxRuntimeExports.jsx(D.Typography,{variant:"overline",fontWeight:"bold",children:"Database Connections"}),D.jsxRuntimeExports.jsx(D.Divider,{}),D.jsxRuntimeExports.jsxs(D.Box$1,{sx:{mt:"10px",maxHeight:"200px",overflowY:"auto"},children:[!g&&!x&&D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",sx:{p:"20px",m:"auto"},children:"Fetching Connections..."}),g&&m.data.length>0&&D.jsxRuntimeExports.jsx(D.Table,{size:"small",children:D.jsxRuntimeExports.jsxs(D.TableBody,{children:[D.jsxRuntimeExports.jsxs(D.TableRow,{children:[D.jsxRuntimeExports.jsx(D.TableCell,{children:D.jsxRuntimeExports.jsx(D.Typography,{variant:"subtitle2",fontWeight:"bold",children:"Connection Name"})}),D.jsxRuntimeExports.jsx(D.TableCell,{children:D.jsxRuntimeExports.jsx(D.Typography,{variant:"subtitle2",fontWeight:"bold",children:"Type"})})]}),m.data.map(v=>D.jsxRuntimeExports.jsx(H0r,{connection:v},v.name))]})}),g&&m.data.length===0&&D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",children:"No Connections"}),x&&D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",sx:{p:"10px",m:"auto"},children:`${d} - ${E.message}`})]})]})})}const W0r=new WHt(new Oo),V0r=new D.QueryClient;function Q0r({server:a,projectName:u,packageName:d,versionId:f,accessToken:m}){const{data:g,isSuccess:x,isError:E,error:v}=D.useQuery({queryKey:["databases",a,u,d,f],queryFn:()=>W0r.listDatabases(u,d,f,{baseURL:a,withCredentials:!m,headers:{Authorization:m&&`Bearer ${m}`}}),retry:!1},V0r),_=S=>S>=1024*1024*1024*1024?`${(S/(1024*1024*1024)).toFixed(2)} T`:S>=1024*1024*1024?`${(S/(1024*1024*1024)).toFixed(2)} G`:S>=1024*1024?`${(S/(1024*1024)).toFixed(2)} M`:`${(S/1024).toFixed(2)} K`;return D.jsxRuntimeExports.jsx(mo,{variant:"outlined",sx:{padding:"10px",width:"100%"},children:D.jsxRuntimeExports.jsxs(Va,{children:[D.jsxRuntimeExports.jsx(D.Typography,{variant:"overline",fontWeight:"bold",children:"Embedded Databases"}),D.jsxRuntimeExports.jsx(D.Divider,{}),D.jsxRuntimeExports.jsxs(D.Box$1,{sx:{mt:"10px",maxHeight:"200px",overflowY:"auto"},children:[!x&&!E&&D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",sx:{p:"20px",m:"auto"},children:"Fetching Databases..."}),x&&g.data.length>0&&D.jsxRuntimeExports.jsx(D.TableContainer,{children:D.jsxRuntimeExports.jsxs(D.Table,{size:"small",children:[D.jsxRuntimeExports.jsx(D.TableHead,{children:D.jsxRuntimeExports.jsxs(D.TableRow,{children:[D.jsxRuntimeExports.jsx(D.TableCell,{children:D.jsxRuntimeExports.jsx(D.Typography,{variant:"subtitle2",fontWeight:"bold",children:"Database Name"})}),D.jsxRuntimeExports.jsx(D.TableCell,{align:"right",children:D.jsxRuntimeExports.jsx(D.Typography,{variant:"subtitle2",fontWeight:"bold",children:"Table Rows"})})]})}),D.jsxRuntimeExports.jsx(D.TableBody,{children:g.data.map(S=>D.jsxRuntimeExports.jsxs(D.TableRow,{children:[D.jsxRuntimeExports.jsx(D.TableCell,{children:D.jsxRuntimeExports.jsx(Y0r,{database:S})}),D.jsxRuntimeExports.jsx(D.TableCell,{align:"right",children:D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",children:_(S.info.rowCount)})})]},S.path))})]})}),x&&g.data.length===0&&D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",children:"No Embedded Databases"}),E&&D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",sx:{p:"10px",m:"auto"},children:`${u} > ${d} > ${f} - ${v.message}`})]})]})})}function Y0r({database:a}){const[u,d]=Pe.useState(!1);return D.jsxRuntimeExports.jsxs(D.Box$1,{sx:{display:"flex",alignItems:"center"},onClick:()=>d(!u),style:{cursor:"pointer"},children:[D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",color:"primary",sx:{maxWidth:"200px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a.path})," ",D.jsxRuntimeExports.jsx(D.Box$1,{sx:{display:"flex",alignItems:"center"},children:D.jsxRuntimeExports.jsx(D.Box$1,{sx:{mr:1,display:"flex",alignItems:"center"},children:D.jsxRuntimeExports.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[D.jsxRuntimeExports.jsx("path",{d:"M11 7H6C5.46957 7 4.96086 7.21071 4.58579 7.58579C4.21071 7.96086 4 8.46957 4 9V18C4 18.5304 4.21071 19.0391 4.58579 19.4142C4.96086 19.7893 5.46957 20 6 20H15C15.5304 20 16.0391 19.7893 16.4142 19.4142C16.7893 19.0391 17 18.5304 17 18V13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),D.jsxRuntimeExports.jsx("path",{d:"M9 15L20 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),D.jsxRuntimeExports.jsx("path",{d:"M15 4H20V9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})})}),D.jsxRuntimeExports.jsx(K0r,{database:a,open:u,setClose:()=>d(!1)})]})}function K0r({database:a,open:u,setClose:d}){return D.jsxRuntimeExports.jsxs(D.Dialog,{open:u,onClose:d,maxWidth:"sm",fullWidth:!0,children:[D.jsxRuntimeExports.jsxs(D.DialogTitle,{children:["Schema:"," ",D.jsxRuntimeExports.jsx(D.Typography,{fontSize:"large",variant:"body2",fontFamily:"monospace",component:"span",children:a.path}),D.jsxRuntimeExports.jsx(D.IconButton,{"aria-label":"close",onClick:d,sx:{position:"absolute",right:8,top:8},children:D.jsxRuntimeExports.jsx(D.Box$1,{sx:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center"},children:"X"})})]}),D.jsxRuntimeExports.jsx(D.DialogContent,{children:D.jsxRuntimeExports.jsx(D.TableContainer,{children:D.jsxRuntimeExports.jsxs(D.Table,{size:"small",sx:{"& .MuiTableCell-root":{padding:"10px"}},children:[D.jsxRuntimeExports.jsx(D.TableHead,{children:D.jsxRuntimeExports.jsxs(D.TableRow,{children:[D.jsxRuntimeExports.jsx(D.TableCell,{children:"NAME"}),D.jsxRuntimeExports.jsx(D.TableCell,{children:"TYPE"})]})}),D.jsxRuntimeExports.jsx(D.TableBody,{children:a.info.columns.map(f=>D.jsxRuntimeExports.jsxs(D.TableRow,{children:[D.jsxRuntimeExports.jsx(D.TableCell,{children:f.name}),D.jsxRuntimeExports.jsx(D.TableCell,{children:f.type})]},f.name))})]})})})]})}function Nqe({items:a,defaultExpandedItems:u,navigate:d}){return D.jsxRuntimeExports.jsx(D.RichTreeView,{items:tgr(a,d),defaultExpandedItems:u,slots:{item:egr}})}const X0r=D.animated(D.Collapse);function J0r(a){const u=D.useSpring({to:{opacity:a.in?1:0,transform:`translate3d(0,${a.in?0:20}px,0)`}});return D.jsxRuntimeExports.jsx(X0r,{style:u,...a})}function Z0r({item:a,...u}){return D.jsxRuntimeExports.jsxs(D.TreeItem2Label,{...u,sx:{display:"flex",alignItems:"center",color:"grey.600"},children:[a.fileType==="directory"&&D.jsxRuntimeExports.jsx(D.FolderIcon,{})||a.fileType==="notebook"&&D.jsxRuntimeExports.jsx(D.ArticleIcon,{})||a.fileType==="model"&&D.jsxRuntimeExports.jsx(D.DataArrayIcon,{})||a.fileType=="database"&&D.jsxRuntimeExports.jsx(D.DnsIcon,{})||D.jsxRuntimeExports.jsx(D.ErrorIcon,{}),D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",sx:{marginLeft:"5px"},color:a.link?"primary.main":"grey.600",children:a.label})]})}const egr=Y.forwardRef(function(u,d){const{id:f,itemId:m,label:g,children:x,disabled:E,...v}=u,{getRootProps:_,getContentProps:S,getLabelProps:R,getIconContainerProps:w,getGroupTransitionProps:N,status:k,publicAPI:B}=D.unstable_useTreeItem2({id:f,itemId:m,children:x,label:g,disabled:E,rootRef:d}),P=B.getItem(m);return k.selected=!1,k.focused=!1,D.jsxRuntimeExports.jsx(D.TreeItem2Provider,{itemId:m,children:D.jsxRuntimeExports.jsxs(D.TreeItem2Root,{..._(v),children:[D.jsxRuntimeExports.jsxs(D.TreeItem2Content,{...S(),...P.link&&{onClick:()=>P.link()},sx:{pointerEvents:!P.selectable&&"none"},children:[D.jsxRuntimeExports.jsx(D.TreeItem2IconContainer,{...w(),children:D.jsxRuntimeExports.jsx(D.TreeItem2Icon,{status:k})}),D.jsxRuntimeExports.jsx(Z0r,{...R({item:P})})]}),x&&D.jsxRuntimeExports.jsx(J0r,{...N()})]})})});function tgr(a,u){const d=new Map;return a.map(f=>{let m=d;const g=f.path.split("/");g.forEach((x,E)=>{E===g.length-1?m.set(x,f):(m.has(x)||m.set(x,new Map),m=m.get(x))})}),Dqe(d,"",u)}function Dqe(a,u,d){const f=[];return a.forEach((m,g)=>{const x=g.endsWith(".malloy")&&"model"||g.endsWith(".malloynb")&&"notebook"||g.endsWith(".parquet")&&"database"||"unknown";x!=="unknown"?f.push({id:u+g,label:g,fileType:x,link:x==="model"||x==="notebook"?d.bind(null,u+g):void 0,selectable:x==="model"||x==="notebook"}):(u+=`${g}/`,f.push({id:u,label:g,fileType:"directory",selectable:!0,link:void 0,children:Dqe(m,u,d)}))}),f}D.axios.defaults.baseURL="http://localhost:4000";const rgr=new TM(new Oo),ngr=new D.QueryClient,igr=["notebooks/","models/"];function sgr({server:a,projectName:u,packageName:d,versionId:f,navigate:m,accessToken:g}){const{data:x,isError:E,error:v,isLoading:_,isSuccess:S}=D.useQuery({queryKey:["models",a,u,d,f],queryFn:()=>rgr.listModels(u,d,f,{baseURL:a,withCredentials:!g,headers:{Authorization:g&&`Bearer ${g}`}}),retry:!1},ngr);return D.jsxRuntimeExports.jsx(mo,{variant:"outlined",sx:{padding:"10px",width:"100%"},children:D.jsxRuntimeExports.jsxs(Va,{children:[D.jsxRuntimeExports.jsx(D.Typography,{variant:"overline",fontWeight:"bold",children:"Semantic Models"}),D.jsxRuntimeExports.jsx(D.Divider,{}),D.jsxRuntimeExports.jsxs(D.Box$1,{sx:{mt:"10px",maxHeight:"200px",overflowY:"auto"},children:[_&&D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",sx:{p:"10px",m:"auto"},children:"Fetching Models..."}),S&&(x.data.length>0?D.jsxRuntimeExports.jsx(Nqe,{items:x.data.sort((R,w)=>R.path.localeCompare(w.path)),defaultExpandedItems:igr,navigate:m}):D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",sx:{p:"10px",m:"auto"},children:"No models found"})),E&&D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",sx:{p:"10px",m:"auto"},children:`${u} > ${d} > ${f} - ${v.message}`})]})]})})}const ogr=new rIe(new Oo),agr=new D.QueryClient,lgr=["notebooks/"];function ugr({server:a,projectName:u,packageName:d,versionId:f,navigate:m,accessToken:g}){const{data:x,isLoading:E,isError:v,error:_,isSuccess:S}=D.useQuery({queryKey:["notebooks",a,u,d,f],queryFn:()=>ogr.listNotebooks(u,d,f,{baseURL:a,withCredentials:!g,headers:{Authorization:g&&`Bearer ${g}`}}),retry:!1},agr);return D.jsxRuntimeExports.jsx(mo,{variant:"outlined",sx:{padding:"10px",width:"100%"},children:D.jsxRuntimeExports.jsxs(Va,{children:[D.jsxRuntimeExports.jsx(D.Typography,{variant:"overline",fontWeight:"bold",children:"Notebooks"}),D.jsxRuntimeExports.jsx(D.Divider,{}),D.jsxRuntimeExports.jsxs(D.Box$1,{sx:{mt:"10px",maxHeight:"200px",overflowY:"auto"},children:[E&&D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",sx:{p:"10px",m:"auto"},children:"Fetching Notebooks..."}),S&&(x.data.length>0?D.jsxRuntimeExports.jsx(Nqe,{items:x.data.sort((R,w)=>R.path.localeCompare(w.path)),defaultExpandedItems:lgr,navigate:m}):D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",sx:{p:"10px",m:"auto"},children:"No notebooks found"})),v&&D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",sx:{p:"10px",m:"auto"},children:`${u} > ${d} > ${f} - ${_.message}`})]})]})})}D.axios.defaults.baseURL="http://localhost:4000";const cgr=new tGt(new Oo),dgr=new D.QueryClient;function fgr({server:a,projectName:u,packageName:d,versionId:f,accessToken:m}){const{data:g,isError:x,isLoading:E,error:v}=D.useQuery({queryKey:["schedules",a,u,d,f],queryFn:()=>cgr.listSchedules(u,d,f,{baseURL:a,withCredentials:!m,headers:{Authorization:m&&`Bearer ${m}`}}),retry:!1},dgr);return E?D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",sx:{p:"20px",m:"auto"},children:"Fetching Schedules..."}):x?D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",sx:{p:"10px",m:"auto"},children:`${d} > ${f} - ${v.message}`}):g.data.length?D.jsxRuntimeExports.jsx(mo,{variant:"outlined",sx:{padding:"10px",width:"100%"},children:D.jsxRuntimeExports.jsxs(Va,{children:[D.jsxRuntimeExports.jsx(D.Typography,{variant:"overline",fontWeight:"bold",children:"Scheduler"}),D.jsxRuntimeExports.jsx(D.Divider,{}),D.jsxRuntimeExports.jsx(D.Box$1,{sx:{mt:"10px",maxHeight:"200px",overflowY:"auto"},children:D.jsxRuntimeExports.jsx(D.TableContainer,{component:D.Paper,children:D.jsxRuntimeExports.jsxs(D.Table,{sx:{minWidth:300},size:"small",children:[D.jsxRuntimeExports.jsx(D.TableHead,{children:D.jsxRuntimeExports.jsxs(D.TableRow,{children:[D.jsxRuntimeExports.jsx(D.TableCell,{align:"left",children:"Resource"}),D.jsxRuntimeExports.jsx(D.TableCell,{align:"left",children:"Schedule"}),D.jsxRuntimeExports.jsx(D.TableCell,{align:"left",children:"Action"}),D.jsxRuntimeExports.jsx(D.TableCell,{align:"left",children:"Connection"}),D.jsxRuntimeExports.jsx(D.TableCell,{align:"left",children:"Last Run"}),D.jsxRuntimeExports.jsx(D.TableCell,{align:"left",children:"Status"})]})}),D.jsxRuntimeExports.jsx(D.TableBody,{children:g.data.map(_=>D.jsxRuntimeExports.jsxs(D.TableRow,{sx:{"&:last-child td, &:last-child th":{border:0}},children:[D.jsxRuntimeExports.jsx(D.TableCell,{align:"left",children:_.resource}),D.jsxRuntimeExports.jsx(D.TableCell,{align:"left",children:_.schedule}),D.jsxRuntimeExports.jsx(D.TableCell,{align:"left",children:_.action}),D.jsxRuntimeExports.jsx(D.TableCell,{align:"left",children:_.connection}),D.jsxRuntimeExports.jsx(D.TableCell,{align:"left",children:_.lastRunTime?new Date(_.lastRunTime).toLocaleString():"n/a"}),D.jsxRuntimeExports.jsx(D.TableCell,{align:"left",children:_.lastRunStatus})]},_.resource))})]})})})]})}):null}const hgr="README.malloynb";function pgr({server:a,projectName:u,packageName:d,versionId:f,navigate:m,accessToken:g}){return m||(m=x=>{window.location.href=x}),D.jsxRuntimeExports.jsx(FIe,{server:a,accessToken:g,projectName:u,packageName:d,versionId:f,children:D.jsxRuntimeExports.jsxs(D.Grid,{container:!0,spacing:2,columns:12,sx:{mb:x=>x.spacing(2)},children:[D.jsxRuntimeExports.jsx(D.Grid,{size:{xs:12,md:4},children:D.jsxRuntimeExports.jsx(q0r,{server:a,projectName:u,packageName:d,versionId:f,accessToken:g})}),D.jsxRuntimeExports.jsx(D.Grid,{size:{xs:12,md:4},children:D.jsxRuntimeExports.jsx(ugr,{server:a,projectName:u,packageName:d,versionId:f,navigate:m,accessToken:g})}),D.jsxRuntimeExports.jsx(D.Grid,{size:{xs:12,md:4},children:D.jsxRuntimeExports.jsx(sgr,{server:a,projectName:u,packageName:d,versionId:f,navigate:m,accessToken:g})}),D.jsxRuntimeExports.jsx(D.Grid,{size:{xs:12,md:6},children:D.jsxRuntimeExports.jsx(Q0r,{server:a,projectName:u,packageName:d,versionId:f,accessToken:g})}),D.jsxRuntimeExports.jsx(D.Grid,{size:{xs:12,md:6},children:D.jsxRuntimeExports.jsx(G0r,{navigate:m,server:a,projectName:u,accessToken:g})}),D.jsxRuntimeExports.jsx(D.Grid,{size:{xs:12,md:12},children:D.jsxRuntimeExports.jsx(fgr,{server:a,projectName:u,packageName:d,versionId:f,accessToken:g})}),D.jsxRuntimeExports.jsx(D.Grid,{size:{xs:12,md:12},children:D.jsxRuntimeExports.jsx(kqe,{notebookPath:hgr,expandCodeCells:!0})})]})})}const mgr=Pe.lazy(()=>Promise.resolve().then(()=>require("./RenderedResult-DjdrYRPY.cjs")));function ggr({cell:a,notebookPath:u,queryResultCodeSnippet:d,expandCodeCell:f,hideCodeCellIcon:m,expandEmbedding:g,hideEmbeddingIcon:x}){const[E,v]=Pe.useState(f||a.type==="code"&&!a.result),[_,S]=Pe.useState(g),[R,w]=Pe.useState(),[N,k]=Pe.useState(),[B,P]=Pe.useState(!1);return Pe.useEffect(()=>{a.type==="code"&&zv(a.text,"malloy").then($=>{w($)})},[a]),Pe.useEffect(()=>{zv(d,"typescript").then($=>{k($)})},[d]),a.type==="markdown"&&D.jsxRuntimeExports.jsx(mo,{variant:"outlined",sx:{border:0},children:D.jsxRuntimeExports.jsx(Va,{children:D.jsxRuntimeExports.jsx(D.Markdown,{children:a.text})})})||a.type==="code"&&D.jsxRuntimeExports.jsxs(mo,{variant:"outlined",children:[(!m||!x&&a.result)&&D.jsxRuntimeExports.jsx(D.Stack,{sx:{flexDirection:"row",justifyContent:"right"},children:D.jsxRuntimeExports.jsxs(D.CardActions,{sx:{padding:"0px 10px 0px 10px",mb:"auto",mt:"auto"},children:[!m&&D.jsxRuntimeExports.jsx(D.Tooltip,{title:E?"Hide Code":"View Code",children:D.jsxRuntimeExports.jsx(D.IconButton,{size:"small",onClick:()=>{v(!E)},children:D.jsxRuntimeExports.jsx(D.CodeIcon,{})})}),!x&&a.result&&D.jsxRuntimeExports.jsx(D.Tooltip,{title:_?"Hide Embedding":"View Embedding",children:D.jsxRuntimeExports.jsx(D.IconButton,{size:"small",onClick:()=>{S(!_)},children:D.jsxRuntimeExports.jsx(D.LinkOutlinedIcon,{})})}),a.newSources&&a.newSources.length>0&&D.jsxRuntimeExports.jsx(D.Tooltip,{title:"Explore Data Sources",children:D.jsxRuntimeExports.jsx(D.IconButton,{size:"small",onClick:()=>{P(!B),S(!1),v(!1)},children:D.jsxRuntimeExports.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:D.jsxRuntimeExports.jsx("path",{d:"M3 3h18v18H3V3zm2 2v14h14V5H5zm2 2h10v2H7V7zm0 4h10v2H7v-2zm0 4h10v2H7v-2z",fill:"currentColor"})})})})]})}),D.jsxRuntimeExports.jsxs(D.Collapse,{in:_,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,{component:"div",sx:{fontSize:"12px","& .line":{textWrap:"wrap"}},dangerouslySetInnerHTML:{__html:N}}),D.jsxRuntimeExports.jsx(D.Tooltip,{title:"Copy Embeddable Code",children:D.jsxRuntimeExports.jsx(D.IconButton,{sx:{width:"24px",height:"24px"},onClick:()=>{navigator.clipboard.writeText(d)},children:D.jsxRuntimeExports.jsx(D.ContentCopyIcon,{})})})]})]}),D.jsxRuntimeExports.jsxs(D.Collapse,{in:E,timeout:"auto",unmountOnExit:!0,children:[D.jsxRuntimeExports.jsx(D.Divider,{}),D.jsxRuntimeExports.jsx(D.Stack,{sx:{p:"10px",borderRadius:0,flexDirection:"row",justifyContent:"space-between"},children:D.jsxRuntimeExports.jsx(D.Typography,{component:"div",className:"content",sx:{fontSize:"12px","& .line":{textWrap:"wrap"}},dangerouslySetInnerHTML:{__html:R}})})]}),D.jsxRuntimeExports.jsxs(D.Collapse,{in:B,timeout:"auto",unmountOnExit:!0,children:[D.jsxRuntimeExports.jsx(D.Stack,{sx:{p:"10px"},children:D.jsxRuntimeExports.jsx(D.Typography,{children:"Sources"})}),D.jsxRuntimeExports.jsx(Uoe,{sourceAndPaths:a.newSources.map($=>({sourceInfo:JSON.parse($),modelPath:u}))})]}),a.result&&!B&&D.jsxRuntimeExports.jsxs(D.jsxRuntimeExports.Fragment,{children:[D.jsxRuntimeExports.jsx(D.Divider,{sx:{mb:"10px"}}),D.jsxRuntimeExports.jsx(D.CardContent,{sx:{minHeight:"100px",maxHeight:"800px",overflow:"auto"},children:D.jsxRuntimeExports.jsx(Pe.Suspense,{fallback:"Loading malloy...",children:D.jsxRuntimeExports.jsx(mgr,{result:a.result})})})]})]})}const xgr=new rIe(new Oo),ygr=new D.QueryClient;function kqe({notebookPath:a,expandCodeCells:u,hideCodeCellIcons:d,expandEmbeddings:f,hideEmbeddingIcons:m}){const[g,x]=Pe.useState(!1),[E,v]=Pe.useState(),{server:_,projectName:S,packageName:R,accessToken:w,versionId:N}=gS(),k=bgr(_,R,a,!0);Pe.useEffect(()=>{zv(k,"typescript").then(z=>{v(z)})},[g,k]);const{data:B,isSuccess:P,isError:$,error:q}=D.useQuery({queryKey:["notebook",_,S,R,a,N],queryFn:()=>xgr.getNotebook(S,R,a,N,{baseURL:_,withCredentials:!w,headers:{Authorization:w&&`Bearer ${w}`}}),retry:!1},ygr);return D.jsxRuntimeExports.jsxs(mo,{variant:"outlined",children:[D.jsxRuntimeExports.jsxs(Va,{children:[D.jsxRuntimeExports.jsxs(D.Stack,{sx:{flexDirection:"row",justifyContent:"space-between"},children:[D.jsxRuntimeExports.jsx(D.Typography,{variant:"overline",fontWeight:"bold",children:"Notebook"}),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(k)},children:D.jsxRuntimeExports.jsx(D.ContentCopyIcon,{})})})]})]}),D.jsxRuntimeExports.jsx(D.Divider,{})]}),D.jsxRuntimeExports.jsx(mS,{children:D.jsxRuntimeExports.jsxs(D.Stack,{spacing:1,component:"section",children:[!P&&!$&&D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",sx:{p:"10px",m:"auto"},children:"Fetching Notebook..."}),P&&B.data.notebookCells?.map((z,W)=>D.jsxRuntimeExports.jsx(ggr,{cell:z,notebookPath:a,queryResultCodeSnippet:vgr(_,S,R,a,z.text),expandCodeCell:u,hideCodeCellIcon:d,expandEmbedding:f,hideEmbeddingIcon:m},W)),$&&D.jsxRuntimeExports.jsx(D.Typography,{variant:"body2",sx:{p:"10px",m:"auto"},children:q.message.includes("404")&&`${a} does not exist`||`${S} > ${R} > ${a} > ${N} - ${q.message}`})]})})]})}function vgr(a,u,d,f,m){return`<QueryResult
|
|
2889
2889
|
server="${a}"
|
|
2890
2890
|
accessToken={accessToken}
|
|
2891
2891
|
projectName="${u}"
|
package/dist/index.es.js
CHANGED
|
@@ -137314,7 +137314,7 @@ function SUe({
|
|
|
137314
137314
|
Sgr,
|
|
137315
137315
|
{
|
|
137316
137316
|
runQuery: () => {
|
|
137317
|
-
R.mutate()
|
|
137317
|
+
R.mutate();
|
|
137318
137318
|
}
|
|
137319
137319
|
}
|
|
137320
137320
|
)
|
|
@@ -137618,25 +137618,11 @@ function p1r({
|
|
|
137618
137618
|
] }) });
|
|
137619
137619
|
}
|
|
137620
137620
|
const m1r = new hse(new Uo()), g1r = new Ca();
|
|
137621
|
-
function y1r({
|
|
137622
|
-
connectionProps: a,
|
|
137623
|
-
connection: u
|
|
137624
|
-
}) {
|
|
137625
|
-
const { projectName: d } = a;
|
|
137621
|
+
function y1r({ connection: a }) {
|
|
137626
137622
|
return /* @__PURE__ */ P.jsxs(Ph, { children: [
|
|
137627
|
-
/* @__PURE__ */ P.jsx(bi, { children: /* @__PURE__ */ P.jsx(
|
|
137628
|
-
|
|
137629
|
-
|
|
137630
|
-
variant: "body2",
|
|
137631
|
-
sx: { cursor: "pointer", color: "primary.main" },
|
|
137632
|
-
onClick: () => a.navigate(
|
|
137633
|
-
`/${d}/connections/${u.name}/`
|
|
137634
|
-
),
|
|
137635
|
-
children: u.name
|
|
137636
|
-
}
|
|
137637
|
-
) }),
|
|
137638
|
-
/* @__PURE__ */ P.jsx(bi, { children: /* @__PURE__ */ P.jsx(yr, { variant: "body2", children: u.type }) })
|
|
137639
|
-
] }, u.name);
|
|
137623
|
+
/* @__PURE__ */ P.jsx(bi, { children: /* @__PURE__ */ P.jsx(yr, { variant: "body2", children: a.name }) }),
|
|
137624
|
+
/* @__PURE__ */ P.jsx(bi, { children: /* @__PURE__ */ P.jsx(yr, { variant: "body2", children: a.type }) })
|
|
137625
|
+
] }, a.name);
|
|
137640
137626
|
}
|
|
137641
137627
|
function x1r(a) {
|
|
137642
137628
|
const { server: u, projectName: d, accessToken: f } = a, { data: m, isSuccess: g, isError: y, error: E } = wa(
|
|
@@ -137671,14 +137657,7 @@ function x1r(a) {
|
|
|
137671
137657
|
/* @__PURE__ */ P.jsx(bi, { children: /* @__PURE__ */ P.jsx(yr, { variant: "subtitle2", fontWeight: "bold", children: "Connection Name" }) }),
|
|
137672
137658
|
/* @__PURE__ */ P.jsx(bi, { children: /* @__PURE__ */ P.jsx(yr, { variant: "subtitle2", fontWeight: "bold", children: "Type" }) })
|
|
137673
137659
|
] }),
|
|
137674
|
-
m.data.map((v) => /* @__PURE__ */ P.jsx(
|
|
137675
|
-
y1r,
|
|
137676
|
-
{
|
|
137677
|
-
connectionProps: a,
|
|
137678
|
-
connection: v
|
|
137679
|
-
},
|
|
137680
|
-
v.name
|
|
137681
|
-
))
|
|
137660
|
+
m.data.map((v) => /* @__PURE__ */ P.jsx(y1r, { connection: v }, v.name))
|
|
137682
137661
|
] }) }),
|
|
137683
137662
|
g && m.data.length === 0 && /* @__PURE__ */ P.jsx(yr, { variant: "body2", children: "No Connections" }),
|
|
137684
137663
|
y && /* @__PURE__ */ P.jsx(yr, { variant: "body2", sx: { p: "10px", m: "auto" }, children: `${d} - ${E.message}` })
|
|
@@ -138029,7 +138008,7 @@ function k1r({
|
|
|
138029
138008
|
navigate: m,
|
|
138030
138009
|
accessToken: g
|
|
138031
138010
|
}) {
|
|
138032
|
-
const { data: y, isError: E, error: v, isLoading: _ } = wa(
|
|
138011
|
+
const { data: y, isError: E, error: v, isLoading: _, isSuccess: S } = wa(
|
|
138033
138012
|
{
|
|
138034
138013
|
queryKey: ["models", a, u, d, f],
|
|
138035
138014
|
queryFn: () => O1r.listModels(u, d, f, {
|
|
@@ -138043,10 +138022,10 @@ function k1r({
|
|
|
138043
138022
|
},
|
|
138044
138023
|
N1r
|
|
138045
138024
|
);
|
|
138046
|
-
return
|
|
138025
|
+
return /* @__PURE__ */ P.jsx(Ro, { variant: "outlined", sx: { padding: "10px", width: "100%" }, children: /* @__PURE__ */ P.jsxs(ul, { children: [
|
|
138047
138026
|
/* @__PURE__ */ P.jsx(yr, { variant: "overline", fontWeight: "bold", children: "Semantic Models" }),
|
|
138048
138027
|
/* @__PURE__ */ P.jsx(ss, {}),
|
|
138049
|
-
/* @__PURE__ */ P.
|
|
138028
|
+
/* @__PURE__ */ P.jsxs(
|
|
138050
138029
|
Vi,
|
|
138051
138030
|
{
|
|
138052
138031
|
sx: {
|
|
@@ -138054,14 +138033,18 @@ function k1r({
|
|
|
138054
138033
|
maxHeight: "200px",
|
|
138055
138034
|
overflowY: "auto"
|
|
138056
138035
|
},
|
|
138057
|
-
children:
|
|
138058
|
-
|
|
138059
|
-
|
|
138060
|
-
|
|
138061
|
-
|
|
138062
|
-
|
|
138063
|
-
|
|
138064
|
-
|
|
138036
|
+
children: [
|
|
138037
|
+
_ && /* @__PURE__ */ P.jsx(yr, { variant: "body2", sx: { p: "10px", m: "auto" }, children: "Fetching Models..." }),
|
|
138038
|
+
S && (y.data.length > 0 ? /* @__PURE__ */ P.jsx(
|
|
138039
|
+
AUe,
|
|
138040
|
+
{
|
|
138041
|
+
items: y.data.sort((w, R) => w.path.localeCompare(R.path)),
|
|
138042
|
+
defaultExpandedItems: D1r,
|
|
138043
|
+
navigate: m
|
|
138044
|
+
}
|
|
138045
|
+
) : /* @__PURE__ */ P.jsx(yr, { variant: "body2", sx: { p: "10px", m: "auto" }, children: "No models found" })),
|
|
138046
|
+
E && /* @__PURE__ */ P.jsx(yr, { variant: "body2", sx: { p: "10px", m: "auto" }, children: `${u} > ${d} > ${f} - ${v.message}` })
|
|
138047
|
+
]
|
|
138065
138048
|
}
|
|
138066
138049
|
)
|
|
138067
138050
|
] }) });
|
|
@@ -138075,7 +138058,7 @@ function F1r({
|
|
|
138075
138058
|
navigate: m,
|
|
138076
138059
|
accessToken: g
|
|
138077
138060
|
}) {
|
|
138078
|
-
const { data: y, isLoading: E, isError: v, error: _ } = wa(
|
|
138061
|
+
const { data: y, isLoading: E, isError: v, error: _, isSuccess: S } = wa(
|
|
138079
138062
|
{
|
|
138080
138063
|
queryKey: ["notebooks", a, u, d, f],
|
|
138081
138064
|
queryFn: () => L1r.listNotebooks(u, d, f, {
|
|
@@ -138089,10 +138072,10 @@ function F1r({
|
|
|
138089
138072
|
},
|
|
138090
138073
|
I1r
|
|
138091
138074
|
);
|
|
138092
|
-
return
|
|
138075
|
+
return /* @__PURE__ */ P.jsx(Ro, { variant: "outlined", sx: { padding: "10px", width: "100%" }, children: /* @__PURE__ */ P.jsxs(ul, { children: [
|
|
138093
138076
|
/* @__PURE__ */ P.jsx(yr, { variant: "overline", fontWeight: "bold", children: "Notebooks" }),
|
|
138094
138077
|
/* @__PURE__ */ P.jsx(ss, {}),
|
|
138095
|
-
/* @__PURE__ */ P.
|
|
138078
|
+
/* @__PURE__ */ P.jsxs(
|
|
138096
138079
|
Vi,
|
|
138097
138080
|
{
|
|
138098
138081
|
sx: {
|
|
@@ -138100,14 +138083,18 @@ function F1r({
|
|
|
138100
138083
|
maxHeight: "200px",
|
|
138101
138084
|
overflowY: "auto"
|
|
138102
138085
|
},
|
|
138103
|
-
children:
|
|
138104
|
-
|
|
138105
|
-
|
|
138106
|
-
|
|
138107
|
-
|
|
138108
|
-
|
|
138109
|
-
|
|
138110
|
-
|
|
138086
|
+
children: [
|
|
138087
|
+
E && /* @__PURE__ */ P.jsx(yr, { variant: "body2", sx: { p: "10px", m: "auto" }, children: "Fetching Notebooks..." }),
|
|
138088
|
+
S && (y.data.length > 0 ? /* @__PURE__ */ P.jsx(
|
|
138089
|
+
AUe,
|
|
138090
|
+
{
|
|
138091
|
+
items: y.data.sort((w, R) => w.path.localeCompare(R.path)),
|
|
138092
|
+
defaultExpandedItems: P1r,
|
|
138093
|
+
navigate: m
|
|
138094
|
+
}
|
|
138095
|
+
) : /* @__PURE__ */ P.jsx(yr, { variant: "body2", sx: { p: "10px", m: "auto" }, children: "No notebooks found" })),
|
|
138096
|
+
v && /* @__PURE__ */ P.jsx(yr, { variant: "body2", sx: { p: "10px", m: "auto" }, children: `${u} > ${d} > ${f} - ${_.message}` })
|
|
138097
|
+
]
|
|
138111
138098
|
}
|
|
138112
138099
|
)
|
|
138113
138100
|
] }) });
|
|
@@ -138452,7 +138439,17 @@ function U1r({
|
|
|
138452
138439
|
] }),
|
|
138453
138440
|
a.result && !B && /* @__PURE__ */ P.jsxs(P.Fragment, { children: [
|
|
138454
138441
|
/* @__PURE__ */ P.jsx(ss, { sx: { mb: "10px" } }),
|
|
138455
|
-
/* @__PURE__ */ P.jsx(
|
|
138442
|
+
/* @__PURE__ */ P.jsx(
|
|
138443
|
+
s$,
|
|
138444
|
+
{
|
|
138445
|
+
sx: {
|
|
138446
|
+
minHeight: "100px",
|
|
138447
|
+
maxHeight: "800px",
|
|
138448
|
+
overflow: "auto"
|
|
138449
|
+
},
|
|
138450
|
+
children: /* @__PURE__ */ P.jsx(fse, { fallback: "Loading malloy...", children: /* @__PURE__ */ P.jsx(q1r, { result: a.result }) })
|
|
138451
|
+
}
|
|
138452
|
+
)
|
|
138456
138453
|
] })
|
|
138457
138454
|
] });
|
|
138458
138455
|
}
|
package/package.json
CHANGED
|
@@ -87,8 +87,8 @@ export function SourcesExplorer({
|
|
|
87
87
|
const [selectedTab, setSelectedTab] = React.useState(
|
|
88
88
|
existingSourceName
|
|
89
89
|
? sourceAndPaths.findIndex(
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
(entry) => entry.sourceInfo.name === existingSourceName,
|
|
91
|
+
)
|
|
92
92
|
: 0,
|
|
93
93
|
);
|
|
94
94
|
|
|
@@ -312,7 +312,6 @@ export function SourceExplorerComponent({
|
|
|
312
312
|
<QueryPanel
|
|
313
313
|
runQuery={() => {
|
|
314
314
|
mutation.mutate();
|
|
315
|
-
window.alert(query.malloyQuery);
|
|
316
315
|
}}
|
|
317
316
|
/>
|
|
318
317
|
</ResizableCollapsiblePanel>
|
|
@@ -325,16 +324,16 @@ export function SourceExplorerComponent({
|
|
|
325
324
|
submittedQuery={
|
|
326
325
|
query?.malloyQuery
|
|
327
326
|
? {
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
327
|
+
executionState: mutation.isPending
|
|
328
|
+
? "running"
|
|
329
|
+
: "finished",
|
|
330
|
+
response: {
|
|
331
|
+
result: query.malloyResult,
|
|
332
|
+
},
|
|
333
|
+
query: query.malloyQuery,
|
|
334
|
+
queryResolutionStartMillis: Date.now(),
|
|
335
|
+
onCancel: mutation.reset,
|
|
336
|
+
}
|
|
338
337
|
: undefined
|
|
339
338
|
}
|
|
340
339
|
options={{ showRawQuery: true }}
|
|
@@ -213,7 +213,13 @@ export function NotebookCell({
|
|
|
213
213
|
{cell.result && !sourcesExpanded && (
|
|
214
214
|
<>
|
|
215
215
|
<Divider sx={{ mb: "10px" }} />
|
|
216
|
-
<CardContent
|
|
216
|
+
<CardContent
|
|
217
|
+
sx={{
|
|
218
|
+
minHeight: "100px",
|
|
219
|
+
maxHeight: "800px",
|
|
220
|
+
overflow: "auto",
|
|
221
|
+
}}
|
|
222
|
+
>
|
|
217
223
|
<Suspense fallback="Loading malloy...">
|
|
218
224
|
<RenderedResult result={cell.result} />
|
|
219
225
|
</Suspense>
|
|
@@ -23,28 +23,11 @@ interface ConnectionsProps {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
// TODO(jjs) - Move this UI to the ConnectionExplorer component
|
|
26
|
-
function Connection({
|
|
27
|
-
connectionProps,
|
|
28
|
-
connection,
|
|
29
|
-
}: {
|
|
30
|
-
connectionProps: ConnectionsProps;
|
|
31
|
-
connection: ApiConnection;
|
|
32
|
-
}) {
|
|
33
|
-
const { projectName } = connectionProps;
|
|
26
|
+
function Connection({ connection }: { connection: ApiConnection }) {
|
|
34
27
|
return (
|
|
35
28
|
<TableRow key={connection.name}>
|
|
36
29
|
<TableCell>
|
|
37
|
-
<Typography
|
|
38
|
-
variant="body2"
|
|
39
|
-
sx={{ cursor: "pointer", color: "primary.main" }}
|
|
40
|
-
onClick={() =>
|
|
41
|
-
connectionProps.navigate(
|
|
42
|
-
`/${projectName}/connections/${connection.name}/`,
|
|
43
|
-
)
|
|
44
|
-
}
|
|
45
|
-
>
|
|
46
|
-
{connection.name}
|
|
47
|
-
</Typography>
|
|
30
|
+
<Typography variant="body2">{connection.name}</Typography>
|
|
48
31
|
</TableCell>
|
|
49
32
|
<TableCell>
|
|
50
33
|
<Typography variant="body2">{connection.type}</Typography>
|
|
@@ -106,11 +89,7 @@ export default function Connections(connectionProps: ConnectionsProps) {
|
|
|
106
89
|
</TableCell>
|
|
107
90
|
</TableRow>
|
|
108
91
|
{data.data.map((conn) => (
|
|
109
|
-
<Connection
|
|
110
|
-
key={conn.name}
|
|
111
|
-
connectionProps={connectionProps}
|
|
112
|
-
connection={conn}
|
|
113
|
-
/>
|
|
92
|
+
<Connection key={conn.name} connection={conn} />
|
|
114
93
|
))}
|
|
115
94
|
</TableBody>
|
|
116
95
|
</Table>
|
|
@@ -28,7 +28,7 @@ export default function Models({
|
|
|
28
28
|
navigate,
|
|
29
29
|
accessToken,
|
|
30
30
|
}: ModelsProps) {
|
|
31
|
-
const { data, isError, error, isLoading } = useQuery(
|
|
31
|
+
const { data, isError, error, isLoading, isSuccess } = useQuery(
|
|
32
32
|
{
|
|
33
33
|
queryKey: ["models", server, projectName, packageName, versionId],
|
|
34
34
|
queryFn: () =>
|
|
@@ -43,20 +43,6 @@ export default function Models({
|
|
|
43
43
|
},
|
|
44
44
|
queryClient,
|
|
45
45
|
);
|
|
46
|
-
if (isError) {
|
|
47
|
-
return (
|
|
48
|
-
<Typography variant="body2" sx={{ p: "10px", m: "auto" }}>
|
|
49
|
-
{`${projectName} > ${packageName} > ${versionId} - ${error.message}`}
|
|
50
|
-
</Typography>
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
if (isLoading) {
|
|
54
|
-
return (
|
|
55
|
-
<Typography variant="body2" sx={{ p: "10px", m: "auto" }}>
|
|
56
|
-
Fetching Models...
|
|
57
|
-
</Typography>
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
46
|
|
|
61
47
|
return (
|
|
62
48
|
<StyledCard variant="outlined" sx={{ padding: "10px", width: "100%" }}>
|
|
@@ -72,17 +58,28 @@ export default function Models({
|
|
|
72
58
|
overflowY: "auto",
|
|
73
59
|
}}
|
|
74
60
|
>
|
|
75
|
-
{
|
|
76
|
-
<FileTreeView
|
|
77
|
-
items={data.data.sort((a, b) => {
|
|
78
|
-
return a.path.localeCompare(b.path);
|
|
79
|
-
})}
|
|
80
|
-
defaultExpandedItems={DEFAULT_EXPANDED_FOLDERS}
|
|
81
|
-
navigate={navigate}
|
|
82
|
-
/>
|
|
83
|
-
) : (
|
|
61
|
+
{isLoading && (
|
|
84
62
|
<Typography variant="body2" sx={{ p: "10px", m: "auto" }}>
|
|
85
|
-
|
|
63
|
+
Fetching Models...
|
|
64
|
+
</Typography>
|
|
65
|
+
)}
|
|
66
|
+
{isSuccess &&
|
|
67
|
+
(data.data.length > 0 ? (
|
|
68
|
+
<FileTreeView
|
|
69
|
+
items={data.data.sort((a, b) => {
|
|
70
|
+
return a.path.localeCompare(b.path);
|
|
71
|
+
})}
|
|
72
|
+
defaultExpandedItems={DEFAULT_EXPANDED_FOLDERS}
|
|
73
|
+
navigate={navigate}
|
|
74
|
+
/>
|
|
75
|
+
) : (
|
|
76
|
+
<Typography variant="body2" sx={{ p: "10px", m: "auto" }}>
|
|
77
|
+
No models found
|
|
78
|
+
</Typography>
|
|
79
|
+
))}
|
|
80
|
+
{isError && (
|
|
81
|
+
<Typography variant="body2" sx={{ p: "10px", m: "auto" }}>
|
|
82
|
+
{`${projectName} > ${packageName} > ${versionId} - ${error.message}`}
|
|
86
83
|
</Typography>
|
|
87
84
|
)}
|
|
88
85
|
</Box>
|
|
@@ -26,7 +26,7 @@ export default function Notebooks({
|
|
|
26
26
|
navigate,
|
|
27
27
|
accessToken,
|
|
28
28
|
}: ModelsProps) {
|
|
29
|
-
const { data, isLoading, isError, error } = useQuery(
|
|
29
|
+
const { data, isLoading, isError, error, isSuccess } = useQuery(
|
|
30
30
|
{
|
|
31
31
|
queryKey: ["notebooks", server, projectName, packageName, versionId],
|
|
32
32
|
queryFn: () =>
|
|
@@ -42,22 +42,6 @@ export default function Notebooks({
|
|
|
42
42
|
queryClient,
|
|
43
43
|
);
|
|
44
44
|
|
|
45
|
-
if (isError) {
|
|
46
|
-
return (
|
|
47
|
-
<Typography variant="body2" sx={{ p: "10px", m: "auto" }}>
|
|
48
|
-
{`${projectName} > ${packageName} > ${versionId} - ${error.message}`}
|
|
49
|
-
</Typography>
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (isLoading) {
|
|
54
|
-
return (
|
|
55
|
-
<Typography variant="body2" sx={{ p: "10px", m: "auto" }}>
|
|
56
|
-
Fetching Notebooks...
|
|
57
|
-
</Typography>
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
45
|
return (
|
|
62
46
|
<StyledCard variant="outlined" sx={{ padding: "10px", width: "100%" }}>
|
|
63
47
|
<StyledCardContent>
|
|
@@ -72,17 +56,28 @@ export default function Notebooks({
|
|
|
72
56
|
overflowY: "auto",
|
|
73
57
|
}}
|
|
74
58
|
>
|
|
75
|
-
{
|
|
76
|
-
<
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
59
|
+
{isLoading && (
|
|
60
|
+
<Typography variant="body2" sx={{ p: "10px", m: "auto" }}>
|
|
61
|
+
Fetching Notebooks...
|
|
62
|
+
</Typography>
|
|
63
|
+
)}
|
|
64
|
+
{isSuccess &&
|
|
65
|
+
(data.data.length > 0 ? (
|
|
66
|
+
<FileTreeView
|
|
67
|
+
items={data.data.sort((a, b) => {
|
|
68
|
+
return a.path.localeCompare(b.path);
|
|
69
|
+
})}
|
|
70
|
+
defaultExpandedItems={DEFAULT_EXPANDED_FOLDERS}
|
|
71
|
+
navigate={navigate}
|
|
72
|
+
/>
|
|
73
|
+
) : (
|
|
74
|
+
<Typography variant="body2" sx={{ p: "10px", m: "auto" }}>
|
|
75
|
+
No notebooks found
|
|
76
|
+
</Typography>
|
|
77
|
+
))}
|
|
78
|
+
{isError && (
|
|
84
79
|
<Typography variant="body2" sx={{ p: "10px", m: "auto" }}>
|
|
85
|
-
|
|
80
|
+
{`${projectName} > ${packageName} > ${versionId} - ${error.message}`}
|
|
86
81
|
</Typography>
|
|
87
82
|
)}
|
|
88
83
|
</Box>
|