@malloy-publisher/app 0.17.2 → 0.17.3
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/api-doc.yaml +504 -85
- package/dist/assets/{EnvironmentPage-DF2PahCR.js → EnvironmentPage-Cpetyfj1.js} +1 -1
- package/dist/assets/{HomePage-DIYlgPCz.js → HomePage-RlrpQRV8.js} +1 -1
- package/dist/assets/{MainPage-C7PGAA5k.js → MainPage-C1559_mQ.js} +1 -1
- package/dist/assets/{ModelPage-BMoBnrW7.js → ModelPage-D8T03Bd7.js} +2 -2
- package/dist/assets/{PackagePage-DD2vLSFe.js → PackagePage-BIl1r9eP.js} +1 -1
- package/dist/assets/{PackageSplatRoute-BYIMwnLL.js → PackageSplatRoute-DJlJXk6p.js} +2 -2
- package/dist/assets/{RenderedResult-CYJ2Y9Fm.es-C8nokn71.js → RenderedResult-Cm0Wwtek.es-CfBPkvGU.js} +1 -1
- package/dist/assets/{RouteError-B8dE60Vs.js → RouteError-DRuMstfb.js} +1 -1
- package/dist/assets/{ThemeEditorPage-D0wf74fh.js → ThemeEditorPage-ss_tmVWo.js} +1 -1
- package/dist/assets/{ToggleButtonGroup-CX0_J2zR.js → ToggleButtonGroup-DA9EfQQB.js} +1 -1
- package/dist/assets/{documentRoutes-DgSMAc0m.js → documentRoutes-_ma0jaCp.js} +1 -1
- package/dist/assets/{editPageMounted-BUGVg-_g.js → editPageMounted-DxNTqmFg.js} +2 -2
- package/dist/assets/{index-DRkw60sj.js → index-BL_7q21Q.js} +5 -5
- package/dist/assets/{index-BQL8UUcK.js → index-BZA1HAyp.js} +1 -1
- package/dist/assets/{index-DAQjZOAL.js → index-DrkXqbpl.js} +1 -1
- package/dist/assets/{index-BiOT4K_d.js → index-w1w5RvZI.js} +1 -1
- package/dist/assets/{index.es-DgNl8IqU.js → index.es-XV_AUlWO.js} +1 -1
- package/dist/assets/usePackageLinkNavigate-BKkPNdJ4.js +1 -0
- package/dist/assets/{usePackageRoute-BhB6txS6.js → usePackageRoute-ev5b1KRn.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +2 -2
- package/dist/assets/usePackageLinkNavigate-bHr_AFYo.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-w1w5RvZI.js","assets/index-B0BUzE-t.js","assets/index-DrkXqbpl.js","assets/core-B8oMW4sm.es-hOkwvru5.js","assets/engine-oniguruma-C4vnmooL.es-jdkXmgTr.js","assets/index-BZA1HAyp.js","assets/index-Co7C9Gew.js","assets/MainPage-C1559_mQ.js","assets/editPageMounted-DxNTqmFg.js","assets/documentRoutes-_ma0jaCp.js","assets/usePackageRoute-ev5b1KRn.js","assets/PackageSplatRoute-DJlJXk6p.js","assets/PackagePage-BIl1r9eP.js","assets/usePackageLinkNavigate-BKkPNdJ4.js","assets/ThemeEditorPage-ss_tmVWo.js","assets/ToggleButtonGroup-DA9EfQQB.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
function iL(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const o in r)if(o!=="default"&&!(o in e)){const a=Object.getOwnPropertyDescriptor(r,o);a&&Object.defineProperty(e,o,a.get?a:{enumerable:!0,get:()=>r[o]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const a of o)if(a.type==="childList")for(const i of a.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(o){const a={};return o.integrity&&(a.integrity=o.integrity),o.referrerPolicy&&(a.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?a.credentials="include":o.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(o){if(o.ep)return;o.ep=!0;const a=n(o);fetch(o.href,a)}})();var PRe=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function P$(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var bS={exports:{}},Rm={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.production.js
|
|
@@ -469,7 +469,7 @@ ${t}`}function Cce(e){return e?.status===403}function Xp(e){return`\`${e.replace
|
|
|
469
469
|
`));u&&A.current&&A.current.getSectionContent(O.startIndex).focus()},[]),{interactions:U,returnedValue:{autoFocus:u,readOnly:n,focused:d??z,sectionListRef:F,onBlur:ae,onClick:q,onFocus:Q,onInput:Y,onPaste:oe,enableAccessibleFieldDOMStructure:!0,elements:fe,tabIndex:w===0?-1:0,contentEditable:ie,value:me,onChange:he,areAllSectionsEmpty:P}}},kp=e=>e.replace(/[\u2066\u2067\u2068\u2069]/g,""),Oge=(e,t,n)=>{let r=0,o=n?1:0;const a=[];for(let i=0;i<e.length;i+=1){const s=e[i],l=S2(s,n?"input-rtl":"input-ltr",t),d=`${s.startSeparator}${l}${s.endSeparator}`,u=kp(d).length,m=d.length,g=kp(l),y=o+(g===""?0:l.indexOf(g[0]))+s.startSeparator.length,x=y+g.length;a.push(Fe({},s,{start:r,end:r+u,startInInput:y,endInInput:x})),r+=u,o+=m}return a},Pge=e=>{const t=zs(),n=C.useRef(void 0),r=C.useRef(void 0),{forwardedProps:{onFocus:o,onClick:a,onPaste:i,onBlur:s,inputRef:l,placeholder:d},internalProps:{readOnly:u=!1,disabled:m=!1},parsedSelectedSections:g,activeSectionIndex:y,state:x,fieldValueManager:w,valueManager:S,applyCharacterEditing:b,resetCharacterQuery:$,updateSectionValue:k,updateValueFromValueStr:T,clearActiveSection:O,clearValue:P,setTempAndroidValueStr:D,setSelectedSections:A,getSectionsFromValue:F,areAllSectionsEmpty:L,localizedDigits:_}=e,R=C.useRef(null),z=vr(l,R),I=C.useMemo(()=>Oge(x.sections,_,t),[x.sections,_,t]),U=C.useMemo(()=>({syncSelectionToDOM:()=>{if(!R.current)return;if(g==null){R.current.scrollLeft&&(R.current.scrollLeft=0);return}if(R.current!==_a(document))return;const Z=R.current.scrollTop;if(g==="all")R.current.select();else{const G=I[g],ue=G.type==="empty"?G.startInInput-G.startSeparator.length:G.startInInput,ie=G.type==="empty"?G.endInInput+G.endSeparator.length:G.endInInput;(ue!==R.current.selectionStart||ie!==R.current.selectionEnd)&&R.current===_a(document)&&R.current.setSelectionRange(ue,ie),clearTimeout(r.current),r.current=setTimeout(()=>{R.current&&R.current===_a(document)&&R.current.selectionStart===R.current.selectionEnd&&(R.current.selectionStart!==ue||R.current.selectionEnd!==ie)&&U.syncSelectionToDOM()})}R.current.scrollTop=Z},getActiveSectionIndexFromDOM:()=>{const Z=R.current.selectionStart??0,G=R.current.selectionEnd??0;if(Z===0&&G===0)return null;const ue=Z<=I[0].startInInput?1:I.findIndex(ie=>ie.startInInput-ie.startSeparator.length>Z);return ue===-1?I.length-1:ue-1},focusField:(Z=0)=>{_a(document)!==R.current&&(R.current?.focus(),A(Z))},setSelectedSections:Z=>A(Z),isFieldFocused:()=>R.current===_a(document)}),[R,g,I,A]),N=()=>{const Z=R.current.selectionStart??0;let G;Z<=I[0].startInInput||Z>=I[I.length-1].endInInput?G=1:G=I.findIndex(ie=>ie.startInInput-ie.startSeparator.length>Z);const ue=G===-1?I.length-1:G-1;A(ue)},q=Yt((...Z)=>{o?.(...Z);const G=R.current;clearTimeout(n.current),n.current=setTimeout(()=>{!G||G!==R.current||y==null&&(G.value.length&&Number(G.selectionEnd)-Number(G.selectionStart)===G.value.length?A("all"):N())})}),Y=Yt((Z,...G)=>{Z.isDefaultPrevented()||(a?.(Z,...G),N())}),oe=Yt(Z=>{if(i?.(Z),Z.preventDefault(),u||m)return;const G=Z.clipboardData.getData("text");if(typeof g=="number"){const ue=x.sections[g],ie=/^[a-zA-Z]+$/.test(G),fe=/^[0-9]+$/.test(G),he=/^(([a-zA-Z]+)|)([0-9]+)(([a-zA-Z]+)|)$/.test(G);if(ue.contentType==="letter"&&ie||ue.contentType==="digit"&&fe||ue.contentType==="digit-with-letter"&&he){$(),k({activeSection:ue,newSectionValue:G,shouldGoToNextSection:!0});return}if(ie||fe)return}$(),T(G)}),Q=Yt((...Z)=>{s?.(...Z),A(null)}),ae=Yt(Z=>{if(u)return;const G=Z.target.value;if(G===""){$(),P();return}const ue=Z.nativeEvent.data,ie=ue&&ue.length>1,fe=ie?ue:G,he=kp(fe);if(g==="all"&&A(y),y==null||ie){T(ie?ue:he);return}let me;if(g==="all"&&he.length===1)me=he;else{const le=kp(w.getV6InputValueFromSections(I,_,t));let ve=-1,Le=-1;for(let ne=0;ne<le.length;ne+=1)ve===-1&&le[ne]!==he[ne]&&(ve=ne),Le===-1&&le[le.length-ne-1]!==he[he.length-ne-1]&&(Le=ne);const Ie=I[y];if(ve<Ie.start||le.length-Le-1>Ie.end)return;const Te=he.length-le.length+Ie.end-kp(Ie.endSeparator||"").length;me=he.slice(Ie.start+kp(Ie.startSeparator||"").length,Te)}if(me.length===0){Due()&&D(fe),$(),O();return}b({keyPressed:me,sectionIndex:y})}),de=C.useMemo(()=>d!==void 0?d:w.getV6InputValueFromSections(F(S.emptyValue),_,t),[d,w,F,S.emptyValue,_,t]),X=C.useMemo(()=>x.tempValueStrAndroid??w.getV6InputValueFromSections(x.sections,_,t),[x.sections,w,x.tempValueStrAndroid,_,t]);C.useEffect(()=>(R.current&&R.current===_a(document)&&A("all"),()=>{clearTimeout(n.current),clearTimeout(r.current)}),[]);const se=C.useMemo(()=>y==null||x.sections[y].contentType==="letter"?"text":"numeric",[y,x.sections]),J=!(R.current&&R.current===_a(document))&&L;return{interactions:U,returnedValue:{readOnly:u,onBlur:Q,onClick:Y,onFocus:q,onPaste:oe,inputRef:z,enableAccessibleFieldDOMStructure:!1,placeholder:de,inputMode:se,autoComplete:"off",value:J?"":X,onChange:ae}}},jge=e=>{const t=Qr(),{internalProps:n,internalProps:{unstableFieldRef:r,minutesStep:o,enableAccessibleFieldDOMStructure:a=!1,disabled:i=!1,readOnly:s=!1},forwardedProps:{onKeyDown:l,error:d,clearable:u,onClear:m},fieldValueManager:g,valueManager:y,validator:x}=e,w=zs(),S=Rge(e),{state:b,activeSectionIndex:$,parsedSelectedSections:k,setSelectedSections:T,clearValue:O,clearActiveSection:P,updateSectionValue:D,setTempAndroidValueStr:A,sectionsValueBoundaries:F,localizedDigits:L,timezone:_}=S,R=Ege({sections:b.sections,updateSectionValue:D,sectionsValueBoundaries:F,localizedDigits:L,setTempAndroidValueStr:A,timezone:_}),{resetCharacterQuery:z}=R,I=y.areValuesEqual(t,b.value,y.emptyValue),U=a?Mge:Pge,N=C.useMemo(()=>Nue(b.sections,w&&!a),[b.sections,w,a]),{returnedValue:q,interactions:Y}=U(Fe({},e,S,R,{areAllSectionsEmpty:I,sectionOrder:N})),oe=Yt(J=>{if(l?.(J),!i)switch(!0){case((J.ctrlKey||J.metaKey)&&String.fromCharCode(J.keyCode)==="A"&&!J.shiftKey&&!J.altKey):{J.preventDefault(),T("all");break}case J.key==="ArrowRight":{if(J.preventDefault(),k==null)T(N.startIndex);else if(k==="all")T(N.endIndex);else{const Z=N.neighbors[k].rightIndex;Z!==null&&T(Z)}break}case J.key==="ArrowLeft":{if(J.preventDefault(),k==null)T(N.endIndex);else if(k==="all")T(N.startIndex);else{const Z=N.neighbors[k].leftIndex;Z!==null&&T(Z)}break}case J.key==="Delete":{if(J.preventDefault(),s)break;k==null||k==="all"?O():P(),z();break}case["ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(J.key):{if(J.preventDefault(),s||$==null)break;k==="all"&&T($);const Z=b.sections[$],G=g.getActiveDateManager(t,b,Z),ue=Tue(t,_,Z,J.key,F,L,G.date,{minutesStep:o});D({activeSection:Z,newSectionValue:ue,shouldGoToNextSection:!1});break}}});Yo(()=>{Y.syncSelectionToDOM()});const{hasValidationError:Q}=s3({props:n,validator:x,timezone:_,value:b.value,onError:n.onError}),ae=C.useMemo(()=>d!==void 0?d:Q,[Q,d]);C.useEffect(()=>{!ae&&$==null&&z()},[b.referenceValue,$,ae]),C.useEffect(()=>{b.tempValueStrAndroid!=null&&$!=null&&(z(),P())},[b.sections]),C.useImperativeHandle(r,()=>({getSections:()=>b.sections,getActiveSectionIndex:Y.getActiveSectionIndexFromDOM,setSelectedSections:Y.setSelectedSections,focusField:Y.focusField,isFieldFocused:Y.isFieldFocused}));const de=Yt((J,...Z)=>{J.preventDefault(),m?.(J,...Z),O(),Y.isFieldFocused()?T(N.startIndex):Y.focusField(0)}),X={onKeyDown:oe,onClear:de,error:ae,clearable:!!(u&&!I&&!s&&!i)},se={disabled:i,readOnly:s};return Fe({},e.forwardedProps,X,se,q)},Age=["clearable","onClear","InputProps","sx","slots","slotProps"],Dge=["ownerState"],Nge=e=>{const t=vc(),{clearable:n,onClear:r,InputProps:o,sx:a,slots:i,slotProps:s}=e,l=qn(e,Age),d=i?.clearButton??Ru,u=Sr({elementType:d,externalSlotProps:s?.clearButton,ownerState:{},className:"clearButton",additionalProps:{title:t.fieldClearLabel}}),m=qn(u,Dge),g=i?.clearIcon??qhe,y=Sr({elementType:g,externalSlotProps:s?.clearIcon,ownerState:{}});return Fe({},l,{InputProps:Fe({},o,{endAdornment:p.jsxs(C.Fragment,{children:[n&&p.jsx(l3,{position:"end",sx:{marginRight:o?.endAdornment?-1:-1.5},children:p.jsx(d,Fe({},m,{onClick:r,children:p.jsx(g,Fe({fontSize:"small"},y))}))}),o?.endAdornment]})}),sx:[{"& .clearButton":{opacity:1},"@media (pointer: fine)":{"& .clearButton":{opacity:0},"&:hover, &:focus-within":{".clearButton":{opacity:1}}}},...Array.isArray(a)?a:[a]]})},Ige=["value","defaultValue","referenceDate","format","formatDensity","onChange","timezone","onError","shouldRespectLeadingZeros","selectedSections","onSelectedSectionsChange","unstableFieldRef","enableAccessibleFieldDOMStructure","disabled","readOnly","dateSeparator"],Lge=(e,t)=>C.useMemo(()=>{const n=Fe({},e),r={},o=a=>{n.hasOwnProperty(a)&&(r[a]=n[a],delete n[a])};return Ige.forEach(o),a3.forEach(o),{forwardedProps:n,internalProps:r}},[e,t]),zge=e=>{const t=Qr(),n=ev();return Fe({},e,{disablePast:e.disablePast??!1,disableFuture:e.disableFuture??!1,format:e.format??t.formats.keyboardDate,minDate:is(t,e.minDate,n.minDate),maxDate:is(t,e.maxDate,n.maxDate)})},Fge=e=>{const t=zge(e),{forwardedProps:n,internalProps:r}=Lge(t,"date");return jge({forwardedProps:n,internalProps:r,valueManager:Cl,fieldValueManager:Fue,validator:tv,valueType:"date"})};function _ge(e){return kn("MuiPickersTextField",e)}vn("MuiPickersTextField",["root","focused","disabled","error","required"]);function Bge(e){return kn("MuiPickersInputBase",e)}const Np=vn("MuiPickersInputBase",["root","focused","disabled","error","notchedOutline","sectionContent","sectionBefore","sectionAfter","adornedStart","adornedEnd","input"]);function Uge(e){return kn("MuiPickersSectionList",e)}const Jm=vn("MuiPickersSectionList",["root","section","sectionContent"]),Vge=["slots","slotProps","elements","sectionListRef"],q3=ot("div",{name:"MuiPickersSectionList",slot:"Root",overridesResolver:(e,t)=>t.root})({direction:"ltr /*! @noflip */",outline:"none"}),H3=ot("span",{name:"MuiPickersSectionList",slot:"Section",overridesResolver:(e,t)=>t.section})({}),W3=ot("span",{name:"MuiPickersSectionList",slot:"SectionSeparator",overridesResolver:(e,t)=>t.sectionSeparator})({whiteSpace:"pre"}),Y3=ot("span",{name:"MuiPickersSectionList",slot:"SectionContent",overridesResolver:(e,t)=>t.sectionContent})({outline:"none"}),qge=e=>{const{classes:t}=e;return Sn({root:["root"],section:["section"],sectionContent:["sectionContent"]},Uge,t)};function Hge(e){const{slots:t,slotProps:n,element:r,classes:o}=e,a=t?.section??H3,i=Sr({elementType:a,externalSlotProps:n?.section,externalForwardedProps:r.container,className:o.section,ownerState:{}}),s=t?.sectionContent??Y3,l=Sr({elementType:s,externalSlotProps:n?.sectionContent,externalForwardedProps:r.content,additionalProps:{suppressContentEditableWarning:!0},className:o.sectionContent,ownerState:{}}),d=t?.sectionSeparator??W3,u=Sr({elementType:d,externalSlotProps:n?.sectionSeparator,externalForwardedProps:r.before,ownerState:{position:"before"}}),m=Sr({elementType:d,externalSlotProps:n?.sectionSeparator,externalForwardedProps:r.after,ownerState:{position:"after"}});return p.jsxs(a,Fe({},i,{children:[p.jsx(d,Fe({},u)),p.jsx(s,Fe({},l)),p.jsx(d,Fe({},m))]}))}const Wge=C.forwardRef(function(e,t){const n=Kr({props:e,name:"MuiPickersSectionList"}),{slots:r,slotProps:o,elements:a,sectionListRef:i}=n,s=qn(n,Vge),l=qge(n),d=C.useRef(null),u=vr(t,d),m=x=>{if(!d.current)throw new Error(`MUI X: Cannot call sectionListRef.${x} before the mount of the component.`);return d.current};C.useImperativeHandle(i,()=>({getRoot(){return m("getRoot")},getSectionContainer(x){return m("getSectionContainer").querySelector(`.${Jm.section}[data-sectionindex="${x}"]`)},getSectionContent(x){return m("getSectionContent").querySelector(`.${Jm.section}[data-sectionindex="${x}"] .${Jm.sectionContent}`)},getSectionIndexFromDOMElement(x){const w=m("getSectionIndexFromDOMElement");if(x==null||!w.contains(x))return null;let S=null;return x.classList.contains(Jm.section)?S=x:x.classList.contains(Jm.sectionContent)&&(S=x.parentElement),S==null?null:Number(S.dataset.sectionindex)}}));const g=r?.root??q3,y=Sr({elementType:g,externalSlotProps:o?.root,externalForwardedProps:s,additionalProps:{ref:u,suppressContentEditableWarning:!0},className:l.root,ownerState:{}});return p.jsx(g,Fe({},y,{children:y.contentEditable?a.map(({content:x,before:w,after:S})=>`${w.children}${x.children}${S.children}`).join(""):p.jsx(C.Fragment,{children:a.map((x,w)=>p.jsx(Hge,{slots:r,slotProps:o,element:x,classes:l},w))})}))}),Yge=["elements","areAllSectionsEmpty","defaultValue","label","value","onChange","id","autoFocus","endAdornment","startAdornment","renderSuffix","slots","slotProps","contentEditable","tabIndex","onInput","onPaste","onKeyDown","fullWidth","name","readOnly","inputProps","inputRef","sectionListRef"],Gge=e=>Math.round(e*1e5)/1e5,P1=ot("div",{name:"MuiPickersInputBase",slot:"Root",overridesResolver:(e,t)=>t.root})(({theme:e})=>Fe({},e.typography.body1,{color:(e.vars||e).palette.text.primary,cursor:"text",padding:0,display:"flex",justifyContent:"flex-start",alignItems:"center",position:"relative",boxSizing:"border-box",letterSpacing:`${Gge(.15/16)}em`,variants:[{props:{fullWidth:!0},style:{width:"100%"}}]})),q2=ot(q3,{name:"MuiPickersInputBase",slot:"SectionsContainer",overridesResolver:(e,t)=>t.sectionsContainer})(({theme:e})=>({padding:"4px 0 5px",fontFamily:e.typography.fontFamily,fontSize:"inherit",lineHeight:"1.4375em",flexGrow:1,outline:"none",display:"flex",flexWrap:"nowrap",overflow:"hidden",letterSpacing:"inherit",width:"182px",variants:[{props:{isRtl:!0},style:{textAlign:"right /*! @noflip */"}},{props:{size:"small"},style:{paddingTop:1}},{props:{adornedStart:!1,focused:!1,filled:!1},style:{color:"currentColor",opacity:0}},{props:({adornedStart:t,focused:n,filled:r,label:o})=>!t&&!n&&!r&&o==null,style:e.vars?{opacity:e.vars.opacity.inputPlaceholder}:{opacity:e.palette.mode==="light"?.42:.5}}]})),Kge=ot(H3,{name:"MuiPickersInputBase",slot:"Section",overridesResolver:(e,t)=>t.section})(({theme:e})=>({fontFamily:e.typography.fontFamily,fontSize:"inherit",letterSpacing:"inherit",lineHeight:"1.4375em",display:"inline-block",whiteSpace:"nowrap"})),Qge=ot(Y3,{name:"MuiPickersInputBase",slot:"SectionContent",overridesResolver:(e,t)=>t.content})(({theme:e})=>({fontFamily:e.typography.fontFamily,lineHeight:"1.4375em",letterSpacing:"inherit",width:"fit-content",outline:"none"})),Xge=ot(W3,{name:"MuiPickersInputBase",slot:"Separator",overridesResolver:(e,t)=>t.separator})(()=>({whiteSpace:"pre",letterSpacing:"inherit"})),Zge=ot("input",{name:"MuiPickersInputBase",slot:"Input",overridesResolver:(e,t)=>t.hiddenInput})(Fe({},pue)),Jge=e=>{const{focused:t,disabled:n,error:r,classes:o,fullWidth:a,readOnly:i,color:s,size:l,endAdornment:d,startAdornment:u}=e,m={root:["root",t&&!n&&"focused",n&&"disabled",i&&"readOnly",r&&"error",a&&"fullWidth",`color${zt(s)}`,l==="small"&&"inputSizeSmall",!!u&&"adornedStart",!!d&&"adornedEnd"],notchedOutline:["notchedOutline"],input:["input"],sectionsContainer:["sectionsContainer"],sectionContent:["sectionContent"],sectionBefore:["sectionBefore"],sectionAfter:["sectionAfter"]};return Sn(m,Bge,o)},H2=C.forwardRef(function(e,t){const n=Kr({props:e,name:"MuiPickersInputBase"}),{elements:r,areAllSectionsEmpty:o,value:a,onChange:i,id:s,endAdornment:l,startAdornment:d,renderSuffix:u,slots:m,slotProps:g,contentEditable:y,tabIndex:x,onInput:w,onPaste:S,onKeyDown:b,name:$,readOnly:k,inputProps:T,inputRef:O,sectionListRef:P}=n,D=qn(n,Yge),A=C.useRef(null),F=vr(t,A),L=vr(T?.ref,O),_=zs(),R=_s();if(!R)throw new Error("MUI X: PickersInputBase should always be used inside a PickersTextField component");const z=oe=>{if(R.disabled){oe.stopPropagation();return}R.onFocus?.(oe)};C.useEffect(()=>{R&&R.setAdornedStart(!!d)},[R,d]),C.useEffect(()=>{R&&(o?R.onEmpty():R.onFilled())},[R,o]);const I=Fe({},n,R,{isRtl:_}),U=Jge(I),N=m?.root||P1,q=Sr({elementType:N,externalSlotProps:g?.root,externalForwardedProps:D,additionalProps:{"aria-invalid":R.error,ref:F},className:U.root,ownerState:I}),Y=m?.input||q2;return p.jsxs(N,Fe({},q,{children:[d,p.jsx(Wge,{sectionListRef:P,elements:r,contentEditable:y,tabIndex:x,className:U.sectionsContainer,onFocus:z,onBlur:R.onBlur,onInput:w,onPaste:S,onKeyDown:b,slots:{root:Y,section:Kge,sectionContent:Qge,sectionSeparator:Xge},slotProps:{root:{ownerState:I},sectionContent:{className:Np.sectionContent},sectionSeparator:({position:oe})=>({className:oe==="before"?Np.sectionBefore:Np.sectionAfter})}}),l,u?u(Fe({},R)):null,p.jsx(Zge,Fe({name:$,className:U.input,value:a,onChange:i,id:s,"aria-hidden":"true",tabIndex:-1,readOnly:k,required:R.required,disabled:R.disabled},T,{ref:L}))]}))});function eye(e){return kn("MuiPickersOutlinedInput",e)}const Ps=Fe({},Np,vn("MuiPickersOutlinedInput",["root","notchedOutline","input"])),tye=["children","className","label","notched","shrink"],nye=ot("fieldset",{name:"MuiPickersOutlinedInput",slot:"NotchedOutline",overridesResolver:(e,t)=>t.notchedOutline})(({theme:e})=>{const t=e.palette.mode==="light"?"rgba(0, 0, 0, 0.23)":"rgba(255, 255, 255, 0.23)";return{textAlign:"left",position:"absolute",bottom:0,right:0,top:-5,left:0,margin:0,padding:"0 8px",pointerEvents:"none",borderRadius:"inherit",borderStyle:"solid",borderWidth:1,overflow:"hidden",minWidth:"0%",borderColor:e.vars?`rgba(${e.vars.palette.common.onBackgroundChannel} / 0.23)`:t}}),DN=ot("span")(({theme:e})=>({fontFamily:e.typography.fontFamily,fontSize:"inherit"})),rye=ot("legend")(({theme:e})=>({float:"unset",width:"auto",overflow:"hidden",variants:[{props:{withLabel:!1},style:{padding:0,lineHeight:"11px",transition:e.transitions.create("width",{duration:150,easing:e.transitions.easing.easeOut})}},{props:{withLabel:!0},style:{display:"block",padding:0,height:11,fontSize:"0.75em",visibility:"hidden",maxWidth:.01,transition:e.transitions.create("max-width",{duration:50,easing:e.transitions.easing.easeOut}),whiteSpace:"nowrap","& > span":{paddingLeft:5,paddingRight:5,display:"inline-block",opacity:0,visibility:"visible"}}},{props:{withLabel:!0,notched:!0},style:{maxWidth:"100%",transition:e.transitions.create("max-width",{duration:100,easing:e.transitions.easing.easeOut,delay:50})}}]}));function oye(e){const{className:t,label:n}=e,r=qn(e,tye),o=n!=null&&n!=="",a=Fe({},e,{withLabel:o});return p.jsx(nye,Fe({"aria-hidden":!0,className:t},r,{ownerState:a,children:p.jsx(rye,{ownerState:a,children:o?p.jsx(DN,{children:n}):p.jsx(DN,{className:"notranslate",children:""})})}))}const aye=["label","autoFocus","ownerState","notched"],iye=ot(P1,{name:"MuiPickersOutlinedInput",slot:"Root",overridesResolver:(e,t)=>t.root})(({theme:e})=>{const t=e.palette.mode==="light"?"rgba(0, 0, 0, 0.23)":"rgba(255, 255, 255, 0.23)";return{padding:"0 14px",borderRadius:(e.vars||e).shape.borderRadius,[`&:hover .${Ps.notchedOutline}`]:{borderColor:(e.vars||e).palette.text.primary},"@media (hover: none)":{[`&:hover .${Ps.notchedOutline}`]:{borderColor:e.vars?`rgba(${e.vars.palette.common.onBackgroundChannel} / 0.23)`:t}},[`&.${Ps.focused} .${Ps.notchedOutline}`]:{borderStyle:"solid",borderWidth:2},[`&.${Ps.disabled}`]:{[`& .${Ps.notchedOutline}`]:{borderColor:(e.vars||e).palette.action.disabled},"*":{color:(e.vars||e).palette.action.disabled}},[`&.${Ps.error} .${Ps.notchedOutline}`]:{borderColor:(e.vars||e).palette.error.main},variants:Object.keys((e.vars??e).palette).filter(n=>(e.vars??e).palette[n]?.main??!1).map(n=>({props:{color:n},style:{[`&.${Ps.focused}:not(.${Ps.error}) .${Ps.notchedOutline}`]:{borderColor:(e.vars||e).palette[n].main}}}))}}),sye=ot(q2,{name:"MuiPickersOutlinedInput",slot:"SectionsContainer",overridesResolver:(e,t)=>t.sectionsContainer})({padding:"16.5px 0",variants:[{props:{size:"small"},style:{padding:"8.5px 0"}}]}),lye=e=>{const{classes:t}=e,n=Sn({root:["root"],notchedOutline:["notchedOutline"],input:["input"]},eye,t);return Fe({},t,n)},G3=C.forwardRef(function(e,t){const n=Kr({props:e,name:"MuiPickersOutlinedInput"}),{label:r,ownerState:o,notched:a}=n,i=qn(n,aye),s=_s(),l=Fe({},n,o,s,{color:s?.color||"primary"}),d=lye(l);return p.jsx(H2,Fe({slots:{root:iye,input:sye},renderSuffix:u=>p.jsx(oye,{shrink:!!(a||u.adornedStart||u.focused||u.filled),notched:!!(a||u.adornedStart||u.focused||u.filled),className:d.notchedOutline,label:r!=null&&r!==""&&s?.required?p.jsxs(C.Fragment,{children:[r," ","*"]}):r,ownerState:l})},i,{label:r,classes:d,ref:t}))});G3.muiName="Input";function cye(e){return kn("MuiPickersFilledInput",e)}const ld=Fe({},Np,vn("MuiPickersFilledInput",["root","underline","input"])),uye=["label","autoFocus","disableUnderline","ownerState"],dye=ot(P1,{name:"MuiPickersFilledInput",slot:"Root",overridesResolver:(e,t)=>t.root,shouldForwardProp:e=>e0(e)&&e!=="disableUnderline"})(({theme:e})=>{const t=e.palette.mode==="light",n=t?"rgba(0, 0, 0, 0.42)":"rgba(255, 255, 255, 0.7)",r=t?"rgba(0, 0, 0, 0.06)":"rgba(255, 255, 255, 0.09)",o=t?"rgba(0, 0, 0, 0.09)":"rgba(255, 255, 255, 0.13)",a=t?"rgba(0, 0, 0, 0.12)":"rgba(255, 255, 255, 0.12)";return{backgroundColor:e.vars?e.vars.palette.FilledInput.bg:r,borderTopLeftRadius:(e.vars||e).shape.borderRadius,borderTopRightRadius:(e.vars||e).shape.borderRadius,transition:e.transitions.create("background-color",{duration:e.transitions.duration.shorter,easing:e.transitions.easing.easeOut}),"&:hover":{backgroundColor:e.vars?e.vars.palette.FilledInput.hoverBg:o,"@media (hover: none)":{backgroundColor:e.vars?e.vars.palette.FilledInput.bg:r}},[`&.${ld.focused}`]:{backgroundColor:e.vars?e.vars.palette.FilledInput.bg:r},[`&.${ld.disabled}`]:{backgroundColor:e.vars?e.vars.palette.FilledInput.disabledBg:a},variants:[...Object.keys((e.vars??e).palette).filter(i=>(e.vars??e).palette[i].main).map(i=>({props:{color:i,disableUnderline:!1},style:{"&::after":{borderBottom:`2px solid ${(e.vars||e).palette[i]?.main}`}}})),{props:{disableUnderline:!1},style:{"&::after":{left:0,bottom:0,content:'""',position:"absolute",right:0,transform:"scaleX(0)",transition:e.transitions.create("transform",{duration:e.transitions.duration.shorter,easing:e.transitions.easing.easeOut}),pointerEvents:"none"},[`&.${ld.focused}:after`]:{transform:"scaleX(1) translateX(0)"},[`&.${ld.error}`]:{"&:before, &:after":{borderBottomColor:(e.vars||e).palette.error.main}},"&::before":{borderBottom:`1px solid ${e.vars?`rgba(${e.vars.palette.common.onBackgroundChannel} / ${e.vars.opacity.inputUnderline})`:n}`,left:0,bottom:0,content:'"\\00a0"',position:"absolute",right:0,transition:e.transitions.create("border-bottom-color",{duration:e.transitions.duration.shorter}),pointerEvents:"none"},[`&:hover:not(.${ld.disabled}, .${ld.error}):before`]:{borderBottom:`1px solid ${(e.vars||e).palette.text.primary}`},[`&.${ld.disabled}:before`]:{borderBottomStyle:"dotted"}}},{props:({startAdornment:i})=>!!i,style:{paddingLeft:12}},{props:({endAdornment:i})=>!!i,style:{paddingRight:12}}]}}),fye=ot(q2,{name:"MuiPickersFilledInput",slot:"sectionsContainer",overridesResolver:(e,t)=>t.sectionsContainer})({paddingTop:25,paddingRight:12,paddingBottom:8,paddingLeft:12,variants:[{props:{size:"small"},style:{paddingTop:21,paddingBottom:4}},{props:({startAdornment:e})=>!!e,style:{paddingLeft:0}},{props:({endAdornment:e})=>!!e,style:{paddingRight:0}},{props:{hiddenLabel:!0},style:{paddingTop:16,paddingBottom:17}},{props:{hiddenLabel:!0,size:"small"},style:{paddingTop:8,paddingBottom:9}}]}),pye=e=>{const{classes:t,disableUnderline:n}=e,r=Sn({root:["root",!n&&"underline"],input:["input"]},cye,t);return Fe({},t,r)},K3=C.forwardRef(function(e,t){const n=Kr({props:e,name:"MuiPickersFilledInput"}),{label:r,disableUnderline:o=!1,ownerState:a}=n,i=qn(n,uye),s=_s(),l=Fe({},n,a,s,{color:s?.color||"primary"}),d=pye(l);return p.jsx(H2,Fe({slots:{root:dye,input:fye},slotProps:{root:{disableUnderline:o}}},i,{label:r,classes:d,ref:t}))});K3.muiName="Input";function hye(e){return kn("MuiPickersFilledInput",e)}const eg=Fe({},Np,vn("MuiPickersInput",["root","input"])),mye=["label","autoFocus","disableUnderline","ownerState"],gye=ot(P1,{name:"MuiPickersInput",slot:"Root",overridesResolver:(e,t)=>t.root})(({theme:e})=>{let t=e.palette.mode==="light"?"rgba(0, 0, 0, 0.42)":"rgba(255, 255, 255, 0.7)";return e.vars&&(t=`rgba(${e.vars.palette.common.onBackgroundChannel} / ${e.vars.opacity.inputUnderline})`),{"label + &":{marginTop:16},variants:[...Object.keys((e.vars??e).palette).filter(n=>(e.vars??e).palette[n].main).map(n=>({props:{color:n},style:{"&::after":{borderBottom:`2px solid ${(e.vars||e).palette[n].main}`}}})),{props:{disableUnderline:!1},style:{"&::after":{background:"red",left:0,bottom:0,content:'""',position:"absolute",right:0,transform:"scaleX(0)",transition:e.transitions.create("transform",{duration:e.transitions.duration.shorter,easing:e.transitions.easing.easeOut}),pointerEvents:"none"},[`&.${eg.focused}:after`]:{transform:"scaleX(1) translateX(0)"},[`&.${eg.error}`]:{"&:before, &:after":{borderBottomColor:(e.vars||e).palette.error.main}},"&::before":{borderBottom:`1px solid ${t}`,left:0,bottom:0,content:'"\\00a0"',position:"absolute",right:0,transition:e.transitions.create("border-bottom-color",{duration:e.transitions.duration.shorter}),pointerEvents:"none"},[`&:hover:not(.${eg.disabled}, .${eg.error}):before`]:{borderBottom:`2px solid ${(e.vars||e).palette.text.primary}`,"@media (hover: none)":{borderBottom:`1px solid ${t}`}},[`&.${eg.disabled}:before`]:{borderBottomStyle:"dotted"}}}]}}),yye=e=>{const{classes:t,disableUnderline:n}=e,r=Sn({root:["root",!n&&"underline"],input:["input"]},hye,t);return Fe({},t,r)},Q3=C.forwardRef(function(e,t){const n=Kr({props:e,name:"MuiPickersInput"}),{label:r,disableUnderline:o=!1,ownerState:a}=n,i=qn(n,mye),s=_s(),l=Fe({},n,a,s,{disableUnderline:o,color:s?.color||"primary"}),d=yye(l);return p.jsx(H2,Fe({slots:{root:gye}},i,{label:r,classes:d,ref:t}))});Q3.muiName="Input";const vye=["onFocus","onBlur","className","color","disabled","error","variant","required","InputProps","inputProps","inputRef","sectionListRef","elements","areAllSectionsEmpty","onClick","onKeyDown","onKeyUp","onPaste","onInput","endAdornment","startAdornment","tabIndex","contentEditable","focused","value","onChange","fullWidth","id","name","helperText","FormHelperTextProps","label","InputLabelProps"],bye={standard:Q3,filled:K3,outlined:G3},xye=ot(A3,{name:"MuiPickersTextField",slot:"Root",overridesResolver:(e,t)=>t.root})({maxWidth:"100%"}),wye=e=>{const{focused:t,disabled:n,classes:r,required:o}=e;return Sn({root:["root",t&&!n&&"focused",n&&"disabled",o&&"required"]},_ge,r)},Sye=C.forwardRef(function(e,t){const n=Kr({props:e,name:"MuiPickersTextField"}),{onFocus:r,onBlur:o,className:a,color:i="primary",disabled:s=!1,error:l=!1,variant:d="outlined",required:u=!1,InputProps:m,inputProps:g,inputRef:y,sectionListRef:x,elements:w,areAllSectionsEmpty:S,onClick:b,onKeyDown:$,onKeyUp:k,onPaste:T,onInput:O,endAdornment:P,startAdornment:D,tabIndex:A,contentEditable:F,focused:L,value:_,onChange:R,fullWidth:z,id:I,name:U,helperText:N,FormHelperTextProps:q,label:Y,InputLabelProps:oe}=n,Q=qn(n,vye),ae=C.useRef(null),de=vr(t,ae),X=Fs(I),se=N&&X?`${X}-helper-text`:void 0,J=Y&&X?`${X}-label`:void 0,Z=Fe({},n,{color:i,disabled:s,error:l,focused:L,required:u,variant:d}),G=wye(Z),ue=bye[d];return p.jsxs(xye,Fe({className:Ht(G.root,a),ref:de,focused:L,onFocus:r,onBlur:o,disabled:s,variant:d,error:l,color:i,fullWidth:z,required:u,ownerState:Z},Q,{children:[p.jsx(j3,Fe({htmlFor:X,id:J},oe,{children:Y})),p.jsx(ue,Fe({elements:w,areAllSectionsEmpty:S,onClick:b,onKeyDown:$,onKeyUp:k,onInput:O,onPaste:T,endAdornment:P,startAdornment:D,tabIndex:A,contentEditable:F,value:_,onChange:R,id:X,fullWidth:z,inputProps:g,inputRef:y,sectionListRef:x,label:Y,name:U,role:"group","aria-labelledby":J,"aria-describedby":se,"aria-live":se?"polite":void 0},m)),N&&p.jsx(D3,Fe({id:se},q,{children:N}))]}))}),Cye=["enableAccessibleFieldDOMStructure"],kye=["InputProps","readOnly"],$ye=["onPaste","onKeyDown","inputMode","readOnly","InputProps","inputProps","inputRef"],Rye=e=>{let{enableAccessibleFieldDOMStructure:t}=e,n=qn(e,Cye);if(t){const{InputProps:m,readOnly:g}=n,y=qn(n,kye);return Fe({},y,{InputProps:Fe({},m??{},{readOnly:g})})}const{onPaste:r,onKeyDown:o,inputMode:a,readOnly:i,InputProps:s,inputProps:l,inputRef:d}=n,u=qn(n,$ye);return Fe({},u,{InputProps:Fe({},s??{},{readOnly:i}),inputProps:Fe({},l??{},{inputMode:a,onPaste:r,onKeyDown:o,ref:d})})},Tye=["slots","slotProps","InputProps","inputProps"],X3=C.forwardRef(function(e,t){const n=Kr({props:e,name:"MuiDateField"}),{slots:r,slotProps:o,InputProps:a,inputProps:i}=n,s=qn(n,Tye),l=n,d=r?.textField??(e.enableAccessibleFieldDOMStructure?Sye:yr),u=Sr({elementType:d,externalSlotProps:o?.textField,externalForwardedProps:s,additionalProps:{ref:t},ownerState:l});u.inputProps=Fe({},i,u.inputProps),u.InputProps=Fe({},a,u.InputProps);const m=Fge(u),g=Rye(m),y=Nge(Fe({},g,{slots:r,slotProps:o}));return p.jsx(d,Fe({},y))}),Z3=({shouldDisableDate:e,shouldDisableMonth:t,shouldDisableYear:n,minDate:r,maxDate:o,disableFuture:a,disablePast:i,timezone:s})=>{const l=Jd();return C.useCallback(d=>tv({adapter:l,value:d,timezone:s,props:{shouldDisableDate:e,shouldDisableMonth:t,shouldDisableYear:n,minDate:r,maxDate:o,disableFuture:a,disablePast:i}})!==null,[l,e,t,n,r,o,a,i,s])},Eye=(e,t,n)=>(r,o)=>{switch(o.type){case"changeMonth":return Fe({},r,{slideDirection:o.direction,currentMonth:o.newMonth,isMonthSwitchingAnimating:!e});case"changeMonthTimezone":{const a=o.newTimezone;if(n.getTimezone(r.currentMonth)===a)return r;let i=n.setTimezone(r.currentMonth,a);return n.getMonth(i)!==n.getMonth(r.currentMonth)&&(i=n.setMonth(i,n.getMonth(r.currentMonth))),Fe({},r,{currentMonth:i})}case"finishMonthSwitchingAnimation":return Fe({},r,{isMonthSwitchingAnimating:!1});case"changeFocusedDay":{if(r.focusedDay!=null&&o.focusedDay!=null&&n.isSameDay(o.focusedDay,r.focusedDay))return r;const a=o.focusedDay!=null&&!t&&!n.isSameMonth(r.currentMonth,o.focusedDay);return Fe({},r,{focusedDay:o.focusedDay,isMonthSwitchingAnimating:a&&!e&&!o.withoutMonthSwitchingAnimation,currentMonth:a?n.startOfMonth(o.focusedDay):r.currentMonth,slideDirection:o.focusedDay!=null&&n.isAfterDay(o.focusedDay,r.currentMonth)?"left":"right"})}default:throw new Error("missing support")}},Mye=e=>{const{value:t,referenceDate:n,disableFuture:r,disablePast:o,disableSwitchToMonthOnDayFocus:a=!1,maxDate:i,minDate:s,onMonthChange:l,reduceAnimations:d,shouldDisableDate:u,timezone:m}=e,g=Qr(),y=C.useRef(Eye(!!d,a,g)).current,x=C.useMemo(()=>Cl.getInitialReferenceValue({value:t,utils:g,timezone:m,props:e,referenceDate:n,granularity:dl.day}),[n,m]),[w,S]=C.useReducer(y,{isMonthSwitchingAnimating:!1,focusedDay:x,currentMonth:g.startOfMonth(x),slideDirection:"left"});C.useEffect(()=>{S({type:"changeMonthTimezone",newTimezone:g.getTimezone(x)})},[x,g]);const b=C.useCallback(P=>{S(Fe({type:"changeMonth"},P)),l&&l(P.newMonth)},[l]),$=C.useCallback(P=>{const D=P;g.isSameMonth(D,w.currentMonth)||b({newMonth:g.startOfMonth(D),direction:g.isAfterDay(D,w.currentMonth)?"left":"right"})},[w.currentMonth,b,g]),k=Z3({shouldDisableDate:u,minDate:s,maxDate:i,disableFuture:r,disablePast:o,timezone:m}),T=C.useCallback(()=>{S({type:"finishMonthSwitchingAnimation"})},[]),O=Yt((P,D)=>{k(P)||S({type:"changeFocusedDay",focusedDay:P,withoutMonthSwitchingAnimation:D})});return{referenceDate:x,calendarState:w,changeMonth:$,changeFocusedDay:O,isDateDisabled:k,onMonthSwitchingAnimationEnd:T,handleChangeMonth:b}},Oye=e=>kn("MuiPickersFadeTransitionGroup",e);vn("MuiPickersFadeTransitionGroup",["root"]);const Pye=e=>{const{classes:t}=e;return Sn({root:["root"]},Oye,t)},jye=ot(nv,{name:"MuiPickersFadeTransitionGroup",slot:"Root",overridesResolver:(e,t)=>t.root})({display:"block",position:"relative"});function J3(e){const t=Kr({props:e,name:"MuiPickersFadeTransitionGroup"}),{children:n,className:r,reduceAnimations:o,transKey:a}=t,i=Pye(t),s=Qd();return o?n:p.jsx(jye,{className:Ht(i.root,r),children:p.jsx(Ud,{appear:!1,mountOnEnter:!0,unmountOnExit:!0,timeout:{appear:s.transitions.duration.enteringScreen,enter:s.transitions.duration.enteringScreen,exit:0},children:n},a)})}function Aye(e){return kn("MuiPickersDay",e)}const cd=vn("MuiPickersDay",["root","dayWithMargin","dayOutsideMonth","hiddenDaySpacingFiller","today","selected","disabled"]),Dye=["autoFocus","className","day","disabled","disableHighlightToday","disableMargin","hidden","isAnimating","onClick","onDaySelect","onFocus","onBlur","onKeyDown","onMouseDown","onMouseEnter","outsideCurrentMonth","selected","showDaysOutsideCurrentMonth","children","today","isFirstVisibleCell","isLastVisibleCell"],Nye=e=>{const{selected:t,disableMargin:n,disableHighlightToday:r,today:o,disabled:a,outsideCurrentMonth:i,showDaysOutsideCurrentMonth:s,classes:l}=e,d=i&&!s;return Sn({root:["root",t&&!d&&"selected",a&&"disabled",!n&&"dayWithMargin",!r&&o&&"today",i&&s&&"dayOutsideMonth",d&&"hiddenDaySpacingFiller"],hiddenDaySpacingFiller:["hiddenDaySpacingFiller"]},Aye,l)},e_=({theme:e})=>Fe({},e.typography.caption,{width:vy,height:vy,borderRadius:"50%",padding:0,backgroundColor:"transparent",transition:e.transitions.create("background-color",{duration:e.transitions.duration.short}),color:(e.vars||e).palette.text.primary,"@media (pointer: fine)":{"&:hover":{backgroundColor:e.vars?`rgba(${e.vars.palette.primary.mainChannel} / ${e.vars.palette.action.hoverOpacity})`:ns(e.palette.primary.main,e.palette.action.hoverOpacity)}},"&:focus":{backgroundColor:e.vars?`rgba(${e.vars.palette.primary.mainChannel} / ${e.vars.palette.action.focusOpacity})`:ns(e.palette.primary.main,e.palette.action.focusOpacity),[`&.${cd.selected}`]:{willChange:"background-color",backgroundColor:(e.vars||e).palette.primary.dark}},[`&.${cd.selected}`]:{color:(e.vars||e).palette.primary.contrastText,backgroundColor:(e.vars||e).palette.primary.main,fontWeight:e.typography.fontWeightMedium,"&:hover":{willChange:"background-color",backgroundColor:(e.vars||e).palette.primary.dark}},[`&.${cd.disabled}:not(.${cd.selected})`]:{color:(e.vars||e).palette.text.disabled},[`&.${cd.disabled}&.${cd.selected}`]:{opacity:.6},variants:[{props:{disableMargin:!1},style:{margin:`0 ${$1}px`}},{props:{outsideCurrentMonth:!0,showDaysOutsideCurrentMonth:!0},style:{color:(e.vars||e).palette.text.secondary}},{props:{disableHighlightToday:!1,today:!0},style:{[`&:not(.${cd.selected})`]:{border:`1px solid ${(e.vars||e).palette.text.secondary}`}}}]}),t_=(e,t)=>{const{ownerState:n}=e;return[t.root,!n.disableMargin&&t.dayWithMargin,!n.disableHighlightToday&&n.today&&t.today,!n.outsideCurrentMonth&&n.showDaysOutsideCurrentMonth&&t.dayOutsideMonth,n.outsideCurrentMonth&&!n.showDaysOutsideCurrentMonth&&t.hiddenDaySpacingFiller]},Iye=ot(Jp,{name:"MuiPickersDay",slot:"Root",overridesResolver:t_})(e_),Lye=ot("div",{name:"MuiPickersDay",slot:"Root",overridesResolver:t_})(({theme:e})=>Fe({},e_({theme:e}),{opacity:0,pointerEvents:"none"})),tg=()=>{},zye=C.forwardRef(function(e,t){const n=Kr({props:e,name:"MuiPickersDay"}),{autoFocus:r=!1,className:o,day:a,disabled:i=!1,disableHighlightToday:s=!1,disableMargin:l=!1,isAnimating:d,onClick:u,onDaySelect:m,onFocus:g=tg,onBlur:y=tg,onKeyDown:x=tg,onMouseDown:w=tg,onMouseEnter:S=tg,outsideCurrentMonth:b,selected:$=!1,showDaysOutsideCurrentMonth:k=!1,children:T,today:O=!1}=n,P=qn(n,Dye),D=Fe({},n,{autoFocus:r,disabled:i,disableHighlightToday:s,disableMargin:l,selected:$,showDaysOutsideCurrentMonth:k,today:O}),A=Nye(D),F=Qr(),L=C.useRef(null),_=vr(L,t);Yo(()=>{r&&!i&&!d&&!b&&L.current.focus()},[r,i,d,b]);const R=I=>{w(I),b&&I.preventDefault()},z=I=>{i||m(a),b&&I.currentTarget.focus(),u&&u(I)};return b&&!k?p.jsx(Lye,{className:Ht(A.root,A.hiddenDaySpacingFiller,o),ownerState:D,role:P.role}):p.jsx(Iye,Fe({className:Ht(A.root,o),ref:_,centerRipple:!0,disabled:i,tabIndex:$?0:-1,onKeyDown:I=>x(I,a),onFocus:I=>g(I,a),onBlur:I=>y(I,a),onMouseEnter:I=>S(I,a),onClick:z,onMouseDown:R},P,{ownerState:D,children:T||F.format(a,"dayOfMonth")}))}),Fye=C.memo(zye),_ye=e=>kn("MuiPickersSlideTransition",e),_i=vn("MuiPickersSlideTransition",["root","slideEnter-left","slideEnter-right","slideEnterActive","slideExit","slideExitActiveLeft-left","slideExitActiveLeft-right"]),Bye=["children","className","reduceAnimations","slideDirection","transKey","classes"],Uye=e=>{const{classes:t,slideDirection:n}=e,r={root:["root"],exit:["slideExit"],enterActive:["slideEnterActive"],enter:[`slideEnter-${n}`],exitActive:[`slideExitActiveLeft-${n}`]};return Sn(r,_ye,t)},Vye=ot(nv,{name:"MuiPickersSlideTransition",slot:"Root",overridesResolver:(e,t)=>[t.root,{[`.${_i["slideEnter-left"]}`]:t["slideEnter-left"]},{[`.${_i["slideEnter-right"]}`]:t["slideEnter-right"]},{[`.${_i.slideEnterActive}`]:t.slideEnterActive},{[`.${_i.slideExit}`]:t.slideExit},{[`.${_i["slideExitActiveLeft-left"]}`]:t["slideExitActiveLeft-left"]},{[`.${_i["slideExitActiveLeft-right"]}`]:t["slideExitActiveLeft-right"]}]})(({theme:e})=>{const t=e.transitions.create("transform",{duration:e.transitions.duration.complex,easing:"cubic-bezier(0.35, 0.8, 0.4, 1)"});return{display:"block",position:"relative",overflowX:"hidden","& > *":{position:"absolute",top:0,right:0,left:0},[`& .${_i["slideEnter-left"]}`]:{willChange:"transform",transform:"translate(100%)",zIndex:1},[`& .${_i["slideEnter-right"]}`]:{willChange:"transform",transform:"translate(-100%)",zIndex:1},[`& .${_i.slideEnterActive}`]:{transform:"translate(0%)",transition:t},[`& .${_i.slideExit}`]:{transform:"translate(0%)"},[`& .${_i["slideExitActiveLeft-left"]}`]:{willChange:"transform",transform:"translate(-100%)",transition:t,zIndex:0},[`& .${_i["slideExitActiveLeft-right"]}`]:{willChange:"transform",transform:"translate(100%)",transition:t,zIndex:0}}});function qye(e){const t=Kr({props:e,name:"MuiPickersSlideTransition"}),{children:n,className:r,reduceAnimations:o,transKey:a}=t,i=qn(t,Bye),s=Uye(t),l=Qd();if(o)return p.jsx("div",{className:Ht(s.root,r),children:n});const d={exit:s.exit,enterActive:s.enterActive,enter:s.enter,exitActive:s.exitActive};return p.jsx(Vye,{className:Ht(s.root,r),childFactory:u=>C.cloneElement(u,{classNames:d}),role:"presentation",children:p.jsx(k2,Fe({mountOnEnter:!0,unmountOnExit:!0,timeout:l.transitions.duration.complex,classNames:d},i,{children:n}),a)})}const Hye=e=>kn("MuiDayCalendar",e);vn("MuiDayCalendar",["root","header","weekDayLabel","loadingContainer","slideTransition","monthContainer","weekContainer","weekNumberLabel","weekNumber"]);const Wye=["parentProps","day","focusableDay","selectedDays","isDateDisabled","currentMonthNumber","isViewFocused"],Yye=["ownerState"],Gye=e=>{const{classes:t}=e;return Sn({root:["root"],header:["header"],weekDayLabel:["weekDayLabel"],loadingContainer:["loadingContainer"],slideTransition:["slideTransition"],monthContainer:["monthContainer"],weekContainer:["weekContainer"],weekNumberLabel:["weekNumberLabel"],weekNumber:["weekNumber"]},Hye,t)},n_=(vy+$1*2)*6,Kye=ot("div",{name:"MuiDayCalendar",slot:"Root",overridesResolver:(e,t)=>t.root})({}),Qye=ot("div",{name:"MuiDayCalendar",slot:"Header",overridesResolver:(e,t)=>t.header})({display:"flex",justifyContent:"center",alignItems:"center"}),Xye=ot(Ar,{name:"MuiDayCalendar",slot:"WeekDayLabel",overridesResolver:(e,t)=>t.weekDayLabel})(({theme:e})=>({width:36,height:40,margin:"0 2px",textAlign:"center",display:"flex",justifyContent:"center",alignItems:"center",color:(e.vars||e).palette.text.secondary})),Zye=ot(Ar,{name:"MuiDayCalendar",slot:"WeekNumberLabel",overridesResolver:(e,t)=>t.weekNumberLabel})(({theme:e})=>({width:36,height:40,margin:"0 2px",textAlign:"center",display:"flex",justifyContent:"center",alignItems:"center",color:e.palette.text.disabled})),Jye=ot(Ar,{name:"MuiDayCalendar",slot:"WeekNumber",overridesResolver:(e,t)=>t.weekNumber})(({theme:e})=>Fe({},e.typography.caption,{width:vy,height:vy,padding:0,margin:`0 ${$1}px`,color:e.palette.text.disabled,fontSize:"0.75rem",alignItems:"center",justifyContent:"center",display:"inline-flex"})),eve=ot("div",{name:"MuiDayCalendar",slot:"LoadingContainer",overridesResolver:(e,t)=>t.loadingContainer})({display:"flex",justifyContent:"center",alignItems:"center",minHeight:n_}),tve=ot(qye,{name:"MuiDayCalendar",slot:"SlideTransition",overridesResolver:(e,t)=>t.slideTransition})({minHeight:n_}),nve=ot("div",{name:"MuiDayCalendar",slot:"MonthContainer",overridesResolver:(e,t)=>t.monthContainer})({overflow:"hidden"}),rve=ot("div",{name:"MuiDayCalendar",slot:"WeekContainer",overridesResolver:(e,t)=>t.weekContainer})({margin:`${$1}px 0`,display:"flex",justifyContent:"center"});function ove(e){let{parentProps:t,day:n,focusableDay:r,selectedDays:o,isDateDisabled:a,currentMonthNumber:i,isViewFocused:s}=e,l=qn(e,Wye);const{disabled:d,disableHighlightToday:u,isMonthSwitchingAnimating:m,showDaysOutsideCurrentMonth:g,slots:y,slotProps:x,timezone:w}=t,S=Qr(),b=S1(w),$=r!==null&&S.isSameDay(n,r),k=o.some(R=>S.isSameDay(R,n)),T=S.isSameDay(n,b),O=y?.day??Fye,P=Sr({elementType:O,externalSlotProps:x?.day,additionalProps:Fe({disableHighlightToday:u,showDaysOutsideCurrentMonth:g,role:"gridcell",isAnimating:m,"data-timestamp":S.toJsDate(n).valueOf()},l),ownerState:Fe({},t,{day:n,selected:k})}),D=qn(P,Yye),A=C.useMemo(()=>d||a(n),[d,a,n]),F=C.useMemo(()=>S.getMonth(n)!==i,[S,n,i]),L=C.useMemo(()=>{const R=S.startOfMonth(S.setMonth(n,i));return g?S.isSameDay(n,S.startOfWeek(R)):S.isSameDay(n,R)},[i,n,g,S]),_=C.useMemo(()=>{const R=S.endOfMonth(S.setMonth(n,i));return g?S.isSameDay(n,S.endOfWeek(R)):S.isSameDay(n,R)},[i,n,g,S]);return p.jsx(O,Fe({},D,{day:n,disabled:A,autoFocus:s&&$,today:T,outsideCurrentMonth:F,isFirstVisibleCell:L,isLastVisibleCell:_,selected:k,tabIndex:$?0:-1,"aria-selected":k,"aria-current":T?"date":void 0}))}function ave(e){const t=Kr({props:e,name:"MuiDayCalendar"}),n=Qr(),{onFocusedDayChange:r,className:o,currentMonth:a,selectedDays:i,focusedDay:s,loading:l,onSelectedDaysChange:d,onMonthSwitchingAnimationEnd:u,readOnly:m,reduceAnimations:g,renderLoading:y=()=>p.jsx("span",{children:"..."}),slideDirection:x,TransitionProps:w,disablePast:S,disableFuture:b,minDate:$,maxDate:k,shouldDisableDate:T,shouldDisableMonth:O,shouldDisableYear:P,dayOfWeekFormatter:D=Ie=>n.format(Ie,"weekdayShort").charAt(0).toUpperCase(),hasFocus:A,onFocusedViewChange:F,gridLabelId:L,displayWeekNumber:_,fixedWeekNumber:R,autoFocus:z,timezone:I}=t,U=S1(I),N=Gye(t),q=zs(),Y=Z3({shouldDisableDate:T,shouldDisableMonth:O,shouldDisableYear:P,minDate:$,maxDate:k,disablePast:S,disableFuture:b,timezone:I}),oe=vc(),[Q,ae]=Ji({name:"DayCalendar",state:"hasFocus",controlled:A,default:z??!1}),[de,X]=C.useState(()=>s||U),se=Yt(Ie=>{m||d(Ie)}),J=Ie=>{Y(Ie)||(r(Ie),X(Ie),F?.(!0),ae(!0))},Z=Yt((Ie,Te)=>{switch(Ie.key){case"ArrowUp":J(n.addDays(Te,-7)),Ie.preventDefault();break;case"ArrowDown":J(n.addDays(Te,7)),Ie.preventDefault();break;case"ArrowLeft":{const ne=n.addDays(Te,q?1:-1),qe=n.addMonths(Te,q?1:-1),Oe=Bg({utils:n,date:ne,minDate:q?ne:n.startOfMonth(qe),maxDate:q?n.endOfMonth(qe):ne,isDateDisabled:Y,timezone:I});J(Oe||ne),Ie.preventDefault();break}case"ArrowRight":{const ne=n.addDays(Te,q?-1:1),qe=n.addMonths(Te,q?-1:1),Oe=Bg({utils:n,date:ne,minDate:q?n.startOfMonth(qe):ne,maxDate:q?ne:n.endOfMonth(qe),isDateDisabled:Y,timezone:I});J(Oe||ne),Ie.preventDefault();break}case"Home":J(n.startOfWeek(Te)),Ie.preventDefault();break;case"End":J(n.endOfWeek(Te)),Ie.preventDefault();break;case"PageUp":J(n.addMonths(Te,1)),Ie.preventDefault();break;case"PageDown":J(n.addMonths(Te,-1)),Ie.preventDefault();break}}),G=Yt((Ie,Te)=>J(Te)),ue=Yt((Ie,Te)=>{Q&&n.isSameDay(de,Te)&&F?.(!1)}),ie=n.getMonth(a),fe=n.getYear(a),he=C.useMemo(()=>i.filter(Ie=>!!Ie).map(Ie=>n.startOfDay(Ie)),[n,i]),me=`${fe}-${ie}`,le=C.useMemo(()=>C.createRef(),[me]),ve=C.useMemo(()=>{const Ie=n.startOfMonth(a),Te=n.endOfMonth(a);return Y(de)||n.isAfterDay(de,Te)||n.isBeforeDay(de,Ie)?Bg({utils:n,date:de,minDate:Ie,maxDate:Te,disablePast:S,disableFuture:b,isDateDisabled:Y,timezone:I}):de},[a,b,S,de,Y,n,I]),Le=C.useMemo(()=>{const Ie=n.getWeekArray(a);let Te=n.addMonths(a,1);for(;R&&Ie.length<R;){const ne=n.getWeekArray(Te),qe=n.isSameDay(Ie[Ie.length-1][0],ne[0][0]);ne.slice(qe?1:0).forEach(Oe=>{Ie.length<R&&Ie.push(Oe)}),Te=n.addMonths(Te,1)}return Ie},[a,R,n]);return p.jsxs(Kye,{role:"grid","aria-labelledby":L,className:N.root,children:[p.jsxs(Qye,{role:"row",className:N.header,children:[_&&p.jsx(Zye,{variant:"caption",role:"columnheader","aria-label":oe.calendarWeekNumberHeaderLabel,className:N.weekNumberLabel,children:oe.calendarWeekNumberHeaderText}),vue(n,U).map((Ie,Te)=>p.jsx(Xye,{variant:"caption",role:"columnheader","aria-label":n.format(Ie,"weekday"),className:N.weekDayLabel,children:D(Ie)},Te.toString()))]}),l?p.jsx(eve,{className:N.loadingContainer,children:y()}):p.jsx(tve,Fe({transKey:me,onExited:u,reduceAnimations:g,slideDirection:x,className:Ht(o,N.slideTransition)},w,{nodeRef:le,children:p.jsx(nve,{ref:le,role:"rowgroup",className:N.monthContainer,children:Le.map((Ie,Te)=>p.jsxs(rve,{role:"row",className:N.weekContainer,"aria-rowindex":Te+1,children:[_&&p.jsx(Jye,{className:N.weekNumber,role:"rowheader","aria-label":oe.calendarWeekNumberAriaLabelText(n.getWeekNumber(Ie[0])),children:oe.calendarWeekNumberText(n.getWeekNumber(Ie[0]))}),Ie.map((ne,qe)=>p.jsx(ove,{parentProps:t,day:ne,selectedDays:he,focusableDay:ve,onKeyDown:Z,onFocus:G,onBlur:ue,onDaySelect:se,isDateDisabled:Y,currentMonthNumber:ie,isViewFocused:Q,"aria-colindex":qe+1},ne.toString()))]},`week-${Ie[0]}`))})}))]})}function ive(e){return kn("MuiPickersMonth",e)}const Ib=vn("MuiPickersMonth",["root","monthButton","disabled","selected"]),sve=["autoFocus","className","children","disabled","selected","value","tabIndex","onClick","onKeyDown","onFocus","onBlur","aria-current","aria-label","monthsPerRow","slots","slotProps"],lve=e=>{const{disabled:t,selected:n,classes:r}=e;return Sn({root:["root"],monthButton:["monthButton",t&&"disabled",n&&"selected"]},ive,r)},cve=ot("div",{name:"MuiPickersMonth",slot:"Root",overridesResolver:(e,t)=>[t.root]})({display:"flex",alignItems:"center",justifyContent:"center",flexBasis:"33.3%",variants:[{props:{monthsPerRow:4},style:{flexBasis:"25%"}}]}),uve=ot("button",{name:"MuiPickersMonth",slot:"MonthButton",overridesResolver:(e,t)=>[t.monthButton,{[`&.${Ib.disabled}`]:t.disabled},{[`&.${Ib.selected}`]:t.selected}]})(({theme:e})=>Fe({color:"unset",backgroundColor:"transparent",border:0,outline:0},e.typography.subtitle1,{margin:"8px 0",height:36,width:72,borderRadius:18,cursor:"pointer","&:focus":{backgroundColor:e.vars?`rgba(${e.vars.palette.action.activeChannel} / ${e.vars.palette.action.hoverOpacity})`:ns(e.palette.action.active,e.palette.action.hoverOpacity)},"&:hover":{backgroundColor:e.vars?`rgba(${e.vars.palette.action.activeChannel} / ${e.vars.palette.action.hoverOpacity})`:ns(e.palette.action.active,e.palette.action.hoverOpacity)},"&:disabled":{cursor:"auto",pointerEvents:"none"},[`&.${Ib.disabled}`]:{color:(e.vars||e).palette.text.secondary},[`&.${Ib.selected}`]:{color:(e.vars||e).palette.primary.contrastText,backgroundColor:(e.vars||e).palette.primary.main,"&:focus, &:hover":{backgroundColor:(e.vars||e).palette.primary.dark}}})),dve=C.memo(function(e){const t=Kr({props:e,name:"MuiPickersMonth"}),{autoFocus:n,className:r,children:o,disabled:a,selected:i,value:s,tabIndex:l,onClick:d,onKeyDown:u,onFocus:m,onBlur:g,"aria-current":y,"aria-label":x,slots:w,slotProps:S}=t,b=qn(t,sve),$=C.useRef(null),k=lve(t);Yo(()=>{n&&$.current?.focus()},[n]);const T=w?.monthButton??uve,O=Sr({elementType:T,externalSlotProps:S?.monthButton,additionalProps:{children:o,disabled:a,tabIndex:l,ref:$,type:"button",role:"radio","aria-current":y,"aria-checked":i,"aria-label":x,onClick:P=>d(P,s),onKeyDown:P=>u(P,s),onFocus:P=>m(P,s),onBlur:P=>g(P,s)},ownerState:t,className:k.monthButton});return p.jsx(cve,Fe({className:Ht(k.root,r),ownerState:t},b,{children:p.jsx(T,Fe({},O))}))});function fve(e){return kn("MuiMonthCalendar",e)}vn("MuiMonthCalendar",["root"]);const pve=["className","value","defaultValue","referenceDate","disabled","disableFuture","disablePast","maxDate","minDate","onChange","shouldDisableMonth","readOnly","disableHighlightToday","autoFocus","onMonthFocus","hasFocus","onFocusedViewChange","monthsPerRow","timezone","gridLabelId","slots","slotProps"],hve=e=>{const{classes:t}=e;return Sn({root:["root"]},fve,t)};function mve(e,t){const n=Qr(),r=ev(),o=Kr({props:e,name:t});return Fe({disableFuture:!1,disablePast:!1},o,{minDate:is(n,o.minDate,r.minDate),maxDate:is(n,o.maxDate,r.maxDate)})}const gve=ot("div",{name:"MuiMonthCalendar",slot:"Root",overridesResolver:(e,t)=>t.root})({display:"flex",flexWrap:"wrap",alignContent:"stretch",padding:"0 4px",width:R1,boxSizing:"border-box"}),yve=C.forwardRef(function(e,t){const n=mve(e,"MuiMonthCalendar"),{className:r,value:o,defaultValue:a,referenceDate:i,disabled:s,disableFuture:l,disablePast:d,maxDate:u,minDate:m,onChange:g,shouldDisableMonth:y,readOnly:x,autoFocus:w=!1,onMonthFocus:S,hasFocus:b,onFocusedViewChange:$,monthsPerRow:k=3,timezone:T,gridLabelId:O,slots:P,slotProps:D}=n,A=qn(n,pve),{value:F,handleValueChange:L,timezone:_}=I2({name:"MonthCalendar",timezone:T,value:o,defaultValue:a,referenceDate:i,onChange:g,valueManager:Cl}),R=S1(_),z=zs(),I=Qr(),U=C.useMemo(()=>Cl.getInitialReferenceValue({value:F,utils:I,props:n,timezone:_,referenceDate:i,granularity:dl.month}),[]),N=n,q=hve(N),Y=C.useMemo(()=>I.getMonth(R),[I,R]),oe=C.useMemo(()=>F!=null?I.getMonth(F):null,[F,I]),[Q,ae]=C.useState(()=>oe||I.getMonth(U)),[de,X]=Ji({name:"MonthCalendar",state:"hasFocus",controlled:b,default:w??!1}),se=Yt(he=>{X(he),$&&$(he)}),J=C.useCallback(he=>{const me=I.startOfMonth(d&&I.isAfter(R,m)?R:m),le=I.startOfMonth(l&&I.isBefore(R,u)?R:u),ve=I.startOfMonth(he);return I.isBefore(ve,me)||I.isAfter(ve,le)?!0:y?y(ve):!1},[l,d,u,m,R,y,I]),Z=Yt((he,me)=>{if(x)return;const le=I.setMonth(F??U,me);L(le)}),G=Yt(he=>{J(I.setMonth(F??U,he))||(ae(he),se(!0),S&&S(he))});C.useEffect(()=>{ae(he=>oe!==null&&he!==oe?oe:he)},[oe]);const ue=Yt((he,me)=>{switch(he.key){case"ArrowUp":G((12+me-3)%12),he.preventDefault();break;case"ArrowDown":G((12+me+3)%12),he.preventDefault();break;case"ArrowLeft":G((12+me+(z?1:-1))%12),he.preventDefault();break;case"ArrowRight":G((12+me+(z?-1:1))%12),he.preventDefault();break}}),ie=Yt((he,me)=>{G(me)}),fe=Yt((he,me)=>{Q===me&&se(!1)});return p.jsx(gve,Fe({ref:t,className:Ht(q.root,r),ownerState:N,role:"radiogroup","aria-labelledby":O},A,{children:b2(I,F??U).map(he=>{const me=I.getMonth(he),le=I.format(he,"monthShort"),ve=I.format(he,"month"),Le=me===oe,Ie=s||J(he);return p.jsx(dve,{selected:Le,value:me,onClick:Z,onKeyDown:ue,autoFocus:de&&me===Q,disabled:Ie,tabIndex:me===Q&&!Ie?0:-1,onFocus:ie,onBlur:fe,"aria-current":Y===me?"date":void 0,"aria-label":ve,monthsPerRow:k,slots:P,slotProps:D,children:le},le)})}))});function vve(e){return kn("MuiPickersYear",e)}const Lb=vn("MuiPickersYear",["root","yearButton","selected","disabled"]),bve=["autoFocus","className","children","disabled","selected","value","tabIndex","onClick","onKeyDown","onFocus","onBlur","aria-current","yearsPerRow","slots","slotProps"],xve=e=>{const{disabled:t,selected:n,classes:r}=e;return Sn({root:["root"],yearButton:["yearButton",t&&"disabled",n&&"selected"]},vve,r)},wve=ot("div",{name:"MuiPickersYear",slot:"Root",overridesResolver:(e,t)=>[t.root]})({display:"flex",alignItems:"center",justifyContent:"center",flexBasis:"33.3%",variants:[{props:{yearsPerRow:4},style:{flexBasis:"25%"}}]}),Sve=ot("button",{name:"MuiPickersYear",slot:"YearButton",overridesResolver:(e,t)=>[t.yearButton,{[`&.${Lb.disabled}`]:t.disabled},{[`&.${Lb.selected}`]:t.selected}]})(({theme:e})=>Fe({color:"unset",backgroundColor:"transparent",border:0,outline:0},e.typography.subtitle1,{margin:"6px 0",height:36,width:72,borderRadius:18,cursor:"pointer","&:focus":{backgroundColor:e.vars?`rgba(${e.vars.palette.action.activeChannel} / ${e.vars.palette.action.focusOpacity})`:ns(e.palette.action.active,e.palette.action.focusOpacity)},"&:hover":{backgroundColor:e.vars?`rgba(${e.vars.palette.action.activeChannel} / ${e.vars.palette.action.hoverOpacity})`:ns(e.palette.action.active,e.palette.action.hoverOpacity)},"&:disabled":{cursor:"auto",pointerEvents:"none"},[`&.${Lb.disabled}`]:{color:(e.vars||e).palette.text.secondary},[`&.${Lb.selected}`]:{color:(e.vars||e).palette.primary.contrastText,backgroundColor:(e.vars||e).palette.primary.main,"&:focus, &:hover":{backgroundColor:(e.vars||e).palette.primary.dark}}})),Cve=C.memo(function(e){const t=Kr({props:e,name:"MuiPickersYear"}),{autoFocus:n,className:r,children:o,disabled:a,selected:i,value:s,tabIndex:l,onClick:d,onKeyDown:u,onFocus:m,onBlur:g,"aria-current":y,slots:x,slotProps:w}=t,S=qn(t,bve),b=C.useRef(null),$=xve(t);Yo(()=>{n&&b.current?.focus()},[n]);const k=x?.yearButton??Sve,T=Sr({elementType:k,externalSlotProps:w?.yearButton,additionalProps:{children:o,disabled:a,tabIndex:l,ref:b,type:"button",role:"radio","aria-current":y,"aria-checked":i,onClick:O=>d(O,s),onKeyDown:O=>u(O,s),onFocus:O=>m(O,s),onBlur:O=>g(O,s)},ownerState:t,className:$.yearButton});return p.jsx(wve,Fe({className:Ht($.root,r),ownerState:t},S,{children:p.jsx(k,Fe({},T))}))});function kve(e){return kn("MuiYearCalendar",e)}vn("MuiYearCalendar",["root"]);const $ve=["autoFocus","className","value","defaultValue","referenceDate","disabled","disableFuture","disablePast","maxDate","minDate","onChange","readOnly","shouldDisableYear","disableHighlightToday","onYearFocus","hasFocus","onFocusedViewChange","yearsOrder","yearsPerRow","timezone","gridLabelId","slots","slotProps"],Rve=e=>{const{classes:t}=e;return Sn({root:["root"]},kve,t)};function Tve(e,t){const n=Qr(),r=ev(),o=Kr({props:e,name:t});return Fe({disablePast:!1,disableFuture:!1},o,{yearsPerRow:o.yearsPerRow??3,minDate:is(n,o.minDate,r.minDate),maxDate:is(n,o.maxDate,r.maxDate)})}const Eve=ot("div",{name:"MuiYearCalendar",slot:"Root",overridesResolver:(e,t)=>t.root})({display:"flex",flexDirection:"row",flexWrap:"wrap",overflowY:"auto",height:"100%",padding:"0 4px",width:R1,maxHeight:$he,boxSizing:"border-box",position:"relative"}),Mve=C.forwardRef(function(e,t){const n=Tve(e,"MuiYearCalendar"),{autoFocus:r,className:o,value:a,defaultValue:i,referenceDate:s,disabled:l,disableFuture:d,disablePast:u,maxDate:m,minDate:g,onChange:y,readOnly:x,shouldDisableYear:w,onYearFocus:S,hasFocus:b,onFocusedViewChange:$,yearsOrder:k="asc",yearsPerRow:T,timezone:O,gridLabelId:P,slots:D,slotProps:A}=n,F=qn(n,$ve),{value:L,handleValueChange:_,timezone:R}=I2({name:"YearCalendar",timezone:O,value:a,defaultValue:i,referenceDate:s,onChange:y,valueManager:Cl}),z=S1(R),I=zs(),U=Qr(),N=C.useMemo(()=>Cl.getInitialReferenceValue({value:L,utils:U,props:n,timezone:R,referenceDate:s,granularity:dl.year}),[]),q=n,Y=Rve(q),oe=C.useMemo(()=>U.getYear(z),[U,z]),Q=C.useMemo(()=>L!=null?U.getYear(L):null,[L,U]),[ae,de]=C.useState(()=>Q||U.getYear(N)),[X,se]=Ji({name:"YearCalendar",state:"hasFocus",controlled:b,default:r??!1}),J=Yt(Te=>{se(Te),$&&$(Te)}),Z=C.useCallback(Te=>{if(u&&U.isBeforeYear(Te,z)||d&&U.isAfterYear(Te,z)||g&&U.isBeforeYear(Te,g)||m&&U.isAfterYear(Te,m))return!0;if(!w)return!1;const ne=U.startOfYear(Te);return w(ne)},[d,u,m,g,z,w,U]),G=Yt((Te,ne)=>{if(x)return;const qe=U.setYear(L??N,ne);_(qe)}),ue=Yt(Te=>{Z(U.setYear(L??N,Te))||(de(Te),J(!0),S?.(Te))});C.useEffect(()=>{de(Te=>Q!==null&&Te!==Q?Q:Te)},[Q]);const ie=k!=="desc"?T*1:T*-1,fe=I&&k==="asc"||!I&&k==="desc"?-1:1,he=Yt((Te,ne)=>{switch(Te.key){case"ArrowUp":ue(ne-ie),Te.preventDefault();break;case"ArrowDown":ue(ne+ie),Te.preventDefault();break;case"ArrowLeft":ue(ne-fe),Te.preventDefault();break;case"ArrowRight":ue(ne+fe),Te.preventDefault();break}}),me=Yt((Te,ne)=>{ue(ne)}),le=Yt((Te,ne)=>{ae===ne&&J(!1)}),ve=C.useRef(null),Le=vr(t,ve);C.useEffect(()=>{if(r||ve.current===null)return;const Te=ve.current.querySelector('[tabindex="0"]');if(!Te)return;const ne=Te.offsetHeight,qe=Te.offsetTop,Oe=ve.current.clientHeight,Qe=ve.current.scrollTop,nt=qe+ne;ne>Oe||qe<Qe||(ve.current.scrollTop=nt-Oe/2-ne/2)},[r]);const Ie=U.getYearRange([g,m]);return k==="desc"&&Ie.reverse(),p.jsx(Eve,Fe({ref:Le,className:Ht(Y.root,o),ownerState:q,role:"radiogroup","aria-labelledby":P},F,{children:Ie.map(Te=>{const ne=U.getYear(Te),qe=ne===Q,Oe=l||Z(Te);return p.jsx(Cve,{selected:qe,value:ne,onClick:G,onKeyDown:he,autoFocus:X&&ne===ae,disabled:Oe,tabIndex:ne===ae&&!Oe?0:-1,onFocus:me,onBlur:le,"aria-current":oe===ne?"date":void 0,yearsPerRow:T,slots:D,slotProps:A,children:U.format(Te,"year")},U.format(Te,"year"))})}))}),Ove=e=>kn("MuiPickersCalendarHeader",e),Pve=vn("MuiPickersCalendarHeader",["root","labelContainer","label","switchViewButton","switchViewIcon"]);function jve(e){return kn("MuiPickersArrowSwitcher",e)}vn("MuiPickersArrowSwitcher",["root","spacer","button","previousIconButton","nextIconButton","leftArrowIcon","rightArrowIcon"]);const Ave=["children","className","slots","slotProps","isNextDisabled","isNextHidden","onGoToNext","nextLabel","isPreviousDisabled","isPreviousHidden","onGoToPrevious","previousLabel","labelId"],Dve=["ownerState"],Nve=["ownerState"],Ive=ot("div",{name:"MuiPickersArrowSwitcher",slot:"Root",overridesResolver:(e,t)=>t.root})({display:"flex"}),Lve=ot("div",{name:"MuiPickersArrowSwitcher",slot:"Spacer",overridesResolver:(e,t)=>t.spacer})(({theme:e})=>({width:e.spacing(3)})),NN=ot(Ru,{name:"MuiPickersArrowSwitcher",slot:"Button",overridesResolver:(e,t)=>t.button})({variants:[{props:{hidden:!0},style:{visibility:"hidden"}}]}),zve=e=>{const{classes:t}=e;return Sn({root:["root"],spacer:["spacer"],button:["button"],previousIconButton:["previousIconButton"],nextIconButton:["nextIconButton"],leftArrowIcon:["leftArrowIcon"],rightArrowIcon:["rightArrowIcon"]},jve,t)},Fve=C.forwardRef(function(e,t){const n=zs(),r=Kr({props:e,name:"MuiPickersArrowSwitcher"}),{children:o,className:a,slots:i,slotProps:s,isNextDisabled:l,isNextHidden:d,onGoToNext:u,nextLabel:m,isPreviousDisabled:g,isPreviousHidden:y,onGoToPrevious:x,previousLabel:w,labelId:S}=r,b=qn(r,Ave),$=r,k=zve($),T={isDisabled:l,isHidden:d,goTo:u,label:m},O={isDisabled:g,isHidden:y,goTo:x,label:w},P=i?.previousIconButton??NN,D=Sr({elementType:P,externalSlotProps:s?.previousIconButton,additionalProps:{size:"medium",title:O.label,"aria-label":O.label,disabled:O.isDisabled,edge:"end",onClick:O.goTo},ownerState:Fe({},$,{hidden:O.isHidden}),className:Ht(k.button,k.previousIconButton)}),A=i?.nextIconButton??NN,F=Sr({elementType:A,externalSlotProps:s?.nextIconButton,additionalProps:{size:"medium",title:T.label,"aria-label":T.label,disabled:T.isDisabled,edge:"start",onClick:T.goTo},ownerState:Fe({},$,{hidden:T.isHidden}),className:Ht(k.button,k.nextIconButton)}),L=i?.leftArrowIcon??Bhe,_=Sr({elementType:L,externalSlotProps:s?.leftArrowIcon,additionalProps:{fontSize:"inherit"},ownerState:$,className:k.leftArrowIcon}),R=qn(_,Dve),z=i?.rightArrowIcon??Uhe,I=Sr({elementType:z,externalSlotProps:s?.rightArrowIcon,additionalProps:{fontSize:"inherit"},ownerState:$,className:k.rightArrowIcon}),U=qn(I,Nve);return p.jsxs(Ive,Fe({ref:t,className:Ht(k.root,a),ownerState:$},b,{children:[p.jsx(P,Fe({},D,{children:n?p.jsx(z,Fe({},U)):p.jsx(L,Fe({},R))})),o?p.jsx(Ar,{variant:"subtitle1",component:"span",id:S,children:o}):p.jsx(Lve,{className:k.spacer,ownerState:$}),p.jsx(A,Fe({},F,{children:n?p.jsx(L,Fe({},R)):p.jsx(z,Fe({},U))}))]}))});function _ve(e,{disableFuture:t,maxDate:n,timezone:r}){const o=Qr();return C.useMemo(()=>{const a=o.date(void 0,r),i=o.startOfMonth(t&&o.isBefore(a,n)?a:n);return!o.isAfter(i,e)},[t,n,e,o,r])}function Bve(e,{disablePast:t,minDate:n,timezone:r}){const o=Qr();return C.useMemo(()=>{const a=o.date(void 0,r),i=o.startOfMonth(t&&o.isAfter(a,n)?a:n);return!o.isBefore(i,e)},[t,n,e,o,r])}const Uve=["slots","slotProps","currentMonth","disabled","disableFuture","disablePast","maxDate","minDate","onMonthChange","onViewChange","view","reduceAnimations","views","labelId","className","timezone","format"],Vve=["ownerState"],qve=e=>{const{classes:t}=e;return Sn({root:["root"],labelContainer:["labelContainer"],label:["label"],switchViewButton:["switchViewButton"],switchViewIcon:["switchViewIcon"]},Ove,t)},Hve=ot("div",{name:"MuiPickersCalendarHeader",slot:"Root",overridesResolver:(e,t)=>t.root})({display:"flex",alignItems:"center",marginTop:12,marginBottom:4,paddingLeft:24,paddingRight:12,maxHeight:40,minHeight:40}),Wve=ot("div",{name:"MuiPickersCalendarHeader",slot:"LabelContainer",overridesResolver:(e,t)=>t.labelContainer})(({theme:e})=>Fe({display:"flex",overflow:"hidden",alignItems:"center",cursor:"pointer",marginRight:"auto"},e.typography.body1,{fontWeight:e.typography.fontWeightMedium})),Yve=ot("div",{name:"MuiPickersCalendarHeader",slot:"Label",overridesResolver:(e,t)=>t.label})({marginRight:6}),Gve=ot(Ru,{name:"MuiPickersCalendarHeader",slot:"SwitchViewButton",overridesResolver:(e,t)=>t.switchViewButton})({marginRight:"auto",variants:[{props:{view:"year"},style:{[`.${Pve.switchViewIcon}`]:{transform:"rotate(180deg)"}}}]}),Kve=ot(_he,{name:"MuiPickersCalendarHeader",slot:"SwitchViewIcon",overridesResolver:(e,t)=>t.switchViewIcon})(({theme:e})=>({willChange:"transform",transition:e.transitions.create("transform"),transform:"rotate(0deg)"})),Qve=C.forwardRef(function(e,t){const n=vc(),r=Qr(),o=Kr({props:e,name:"MuiPickersCalendarHeader"}),{slots:a,slotProps:i,currentMonth:s,disabled:l,disableFuture:d,disablePast:u,maxDate:m,minDate:g,onMonthChange:y,onViewChange:x,view:w,reduceAnimations:S,views:b,labelId:$,className:k,timezone:T,format:O=`${r.formats.month} ${r.formats.year}`}=o,P=qn(o,Uve),D=o,A=qve(o),F=a?.switchViewButton??Gve,L=Sr({elementType:F,externalSlotProps:i?.switchViewButton,additionalProps:{size:"small","aria-label":n.calendarViewSwitchingButtonAriaLabel(w)},ownerState:D,className:A.switchViewButton}),_=a?.switchViewIcon??Kve,R=Sr({elementType:_,externalSlotProps:i?.switchViewIcon,ownerState:D,className:A.switchViewIcon}),z=qn(R,Vve),I=()=>y(r.addMonths(s,1),"left"),U=()=>y(r.addMonths(s,-1),"right"),N=_ve(s,{disableFuture:d,maxDate:m,timezone:T}),q=Bve(s,{disablePast:u,minDate:g,timezone:T}),Y=()=>{if(!(b.length===1||!x||l))if(b.length===2)x(b.find(Q=>Q!==w)||b[0]);else{const Q=b.indexOf(w)!==0?0:1;x(b[Q])}};if(b.length===1&&b[0]==="year")return null;const oe=r.formatByString(s,O);return p.jsxs(Hve,Fe({},P,{ownerState:D,className:Ht(A.root,k),ref:t,children:[p.jsxs(Wve,{role:"presentation",onClick:Y,ownerState:D,"aria-live":"polite",className:A.labelContainer,children:[p.jsx(J3,{reduceAnimations:S,transKey:oe,children:p.jsx(Yve,{id:$,ownerState:D,className:A.label,children:oe})}),b.length>1&&!l&&p.jsx(F,Fe({},L,{children:p.jsx(_,Fe({},z))}))]}),p.jsx(Ud,{in:w==="day",appear:!S,enter:!S,children:p.jsx(Fve,{slots:a,slotProps:i,onGoToPrevious:U,isPreviousDisabled:q,previousLabel:n.previousMonth,onGoToNext:I,isNextDisabled:N,nextLabel:n.nextMonth})})]}))}),Xve=ot("div")({overflow:"hidden",width:R1,maxHeight:L2,display:"flex",flexDirection:"column",margin:"0 auto"}),Zve=e=>kn("MuiDateCalendar",e);vn("MuiDateCalendar",["root","viewTransitionContainer"]);const Jve=["autoFocus","onViewChange","value","defaultValue","referenceDate","disableFuture","disablePast","onChange","onYearChange","onMonthChange","reduceAnimations","shouldDisableDate","shouldDisableMonth","shouldDisableYear","view","views","openTo","className","disabled","readOnly","minDate","maxDate","disableHighlightToday","focusedView","onFocusedViewChange","showDaysOutsideCurrentMonth","fixedWeekNumber","dayOfWeekFormatter","slots","slotProps","loading","renderLoading","displayWeekNumber","yearsOrder","yearsPerRow","monthsPerRow","timezone"],ebe=e=>{const{classes:t}=e;return Sn({root:["root"],viewTransitionContainer:["viewTransitionContainer"]},Zve,t)};function tbe(e,t){const n=Qr(),r=ev(),o=S3(),a=Kr({props:e,name:t});return Fe({},a,{loading:a.loading??!1,disablePast:a.disablePast??!1,disableFuture:a.disableFuture??!1,openTo:a.openTo??"day",views:a.views??["year","day"],reduceAnimations:a.reduceAnimations??o,renderLoading:a.renderLoading??(()=>p.jsx("span",{children:"..."})),minDate:is(n,a.minDate,r.minDate),maxDate:is(n,a.maxDate,r.maxDate)})}const nbe=ot(Xve,{name:"MuiDateCalendar",slot:"Root",overridesResolver:(e,t)=>t.root})({display:"flex",flexDirection:"column",height:L2}),rbe=ot(J3,{name:"MuiDateCalendar",slot:"ViewTransitionContainer",overridesResolver:(e,t)=>t.viewTransitionContainer})({}),obe=C.forwardRef(function(e,t){const n=Qr(),r=Fs(),o=tbe(e,"MuiDateCalendar"),{autoFocus:a,onViewChange:i,value:s,defaultValue:l,referenceDate:d,disableFuture:u,disablePast:m,onChange:g,onYearChange:y,onMonthChange:x,reduceAnimations:w,shouldDisableDate:S,shouldDisableMonth:b,shouldDisableYear:$,view:k,views:T,openTo:O,className:P,disabled:D,readOnly:A,minDate:F,maxDate:L,disableHighlightToday:_,focusedView:R,onFocusedViewChange:z,showDaysOutsideCurrentMonth:I,fixedWeekNumber:U,dayOfWeekFormatter:N,slots:q,slotProps:Y,loading:oe,renderLoading:Q,displayWeekNumber:ae,yearsOrder:de,yearsPerRow:X,monthsPerRow:se,timezone:J}=o,Z=qn(o,Jve),{value:G,handleValueChange:ue,timezone:ie}=I2({name:"DateCalendar",timezone:J,value:s,defaultValue:l,referenceDate:d,onChange:g,valueManager:Cl}),{view:fe,setView:he,focusedView:me,setFocusedView:le,goToNextView:ve,setValueAndGoToNextView:Le}=C3({view:k,views:T,openTo:O,onChange:ue,onViewChange:i,autoFocus:a,focusedView:R,onFocusedViewChange:z}),{referenceDate:Ie,calendarState:Te,changeFocusedDay:ne,changeMonth:qe,handleChangeMonth:Oe,isDateDisabled:Qe,onMonthSwitchingAnimationEnd:nt}=Mye({value:G,referenceDate:d,reduceAnimations:w,onMonthChange:x,minDate:F,maxDate:L,shouldDisableDate:S,disablePast:m,disableFuture:u,timezone:ie}),kt=D&&G||F,Ut=D&&G||L,at=`${r}-grid-label`,et=me!==null,pt=q?.calendarHeader??Qve,ze=Sr({elementType:pt,externalSlotProps:Y?.calendarHeader,additionalProps:{views:T,view:fe,currentMonth:Te.currentMonth,onViewChange:he,onMonthChange:(tn,Bt)=>Oe({newMonth:tn,direction:Bt}),minDate:kt,maxDate:Ut,disabled:D,disablePast:m,disableFuture:u,reduceAnimations:w,timezone:ie,labelId:at},ownerState:o}),be=Yt(tn=>{const Bt=n.startOfMonth(tn),an=n.endOfMonth(tn),$n=Qe(tn)?Bg({utils:n,date:tn,minDate:n.isBefore(F,Bt)?Bt:F,maxDate:n.isAfter(L,an)?an:L,disablePast:m,disableFuture:u,isDateDisabled:Qe,timezone:ie}):tn;$n?(Le($n,"finish"),x?.(Bt)):(ve(),qe(Bt)),ne($n,!0)}),He=Yt(tn=>{const Bt=n.startOfYear(tn),an=n.endOfYear(tn),$n=Qe(tn)?Bg({utils:n,date:tn,minDate:n.isBefore(F,Bt)?Bt:F,maxDate:n.isAfter(L,an)?an:L,disablePast:m,disableFuture:u,isDateDisabled:Qe,timezone:ie}):tn;$n?(Le($n,"finish"),y?.($n)):(ve(),qe(Bt)),ne($n,!0)}),Me=Yt(tn=>ue(tn&&H0(n,tn,G??Ie),"finish",fe));C.useEffect(()=>{G!=null&&n.isValid(G)&&qe(G)},[G]);const $t=o,Rt=ebe($t),vt={disablePast:m,disableFuture:u,maxDate:L,minDate:F},it={disableHighlightToday:_,readOnly:A,disabled:D,timezone:ie,gridLabelId:at,slots:q,slotProps:Y},st=C.useRef(fe);C.useEffect(()=>{st.current!==fe&&(me===st.current&&le(fe,!0),st.current=fe)},[me,le,fe]);const At=C.useMemo(()=>[G],[G]);return p.jsxs(nbe,Fe({ref:t,className:Ht(Rt.root,P),ownerState:$t},Z,{children:[p.jsx(pt,Fe({},ze,{slots:q,slotProps:Y})),p.jsx(rbe,{reduceAnimations:w,className:Rt.viewTransitionContainer,transKey:fe,ownerState:$t,children:p.jsxs("div",{children:[fe==="year"&&p.jsx(Mve,Fe({},vt,it,{value:G,onChange:He,shouldDisableYear:$,hasFocus:et,onFocusedViewChange:tn=>le("year",tn),yearsOrder:de,yearsPerRow:X,referenceDate:Ie})),fe==="month"&&p.jsx(yve,Fe({},vt,it,{hasFocus:et,className:P,value:G,onChange:be,shouldDisableMonth:b,onFocusedViewChange:tn=>le("month",tn),monthsPerRow:se,referenceDate:Ie})),fe==="day"&&p.jsx(ave,Fe({},Te,vt,it,{onMonthSwitchingAnimationEnd:nt,onFocusedDayChange:ne,reduceAnimations:w,selectedDays:At,onSelectedDaysChange:Me,shouldDisableDate:S,shouldDisableMonth:b,shouldDisableYear:$,hasFocus:et,onFocusedViewChange:tn=>le("day",tn),showDaysOutsideCurrentMonth:I,fixedWeekNumber:U,dayOfWeekFormatter:N,displayWeekNumber:ae,loading:oe,renderLoading:Q}))]})})]}))}),Ip=({view:e,onViewChange:t,views:n,focusedView:r,onFocusedViewChange:o,value:a,defaultValue:i,referenceDate:s,onChange:l,className:d,classes:u,disableFuture:m,disablePast:g,minDate:y,maxDate:x,shouldDisableDate:w,shouldDisableMonth:S,shouldDisableYear:b,reduceAnimations:$,onMonthChange:k,monthsPerRow:T,onYearChange:O,yearsOrder:P,yearsPerRow:D,slots:A,slotProps:F,loading:L,renderLoading:_,disableHighlightToday:R,readOnly:z,disabled:I,showDaysOutsideCurrentMonth:U,dayOfWeekFormatter:N,sx:q,autoFocus:Y,fixedWeekNumber:oe,displayWeekNumber:Q,timezone:ae})=>p.jsx(obe,{view:e,onViewChange:t,views:n.filter(VD),focusedView:r&&VD(r)?r:null,onFocusedViewChange:o,value:a,defaultValue:i,referenceDate:s,onChange:l,className:d,classes:u,disableFuture:m,disablePast:g,minDate:y,maxDate:x,shouldDisableDate:w,shouldDisableMonth:S,shouldDisableYear:b,reduceAnimations:$,onMonthChange:k,monthsPerRow:T,onYearChange:O,yearsOrder:P,yearsPerRow:D,slots:A,slotProps:F,loading:L,renderLoading:_,disableHighlightToday:R,readOnly:z,disabled:I,showDaysOutsideCurrentMonth:U,dayOfWeekFormatter:N,sx:q,autoFocus:Y,fixedWeekNumber:oe,displayWeekNumber:Q,timezone:ae}),r_=C.forwardRef(function(e,t){const n=vc(),r=Qr(),o=o3(e,"MuiDesktopDatePicker"),a=Fe({day:Ip,month:Ip,year:Ip},o.viewRenderers),i=Fe({},o,{viewRenderers:a,format:x2(r,o,!1),yearsPerRow:o.yearsPerRow??4,slots:Fe({openPickerIcon:Vhe,field:X3},o.slots),slotProps:Fe({},o.slotProps,{field:l=>Fe({},x1(o.slotProps?.field,l),i3(o),{ref:t}),toolbar:Fe({hidden:!0},o.slotProps?.toolbar)})}),{renderPicker:s}=Fhe({props:i,valueManager:Cl,valueType:"date",getOpenDialogAriaText:n3({utils:r,formatKey:"fullDate",contextTranslation:n.openDatePickerDialogue,propsTranslation:i.localeText?.openDatePickerDialogue}),validator:tv});return s()});r_.propTypes={autoFocus:dt.bool,className:dt.string,closeOnSelect:dt.bool,dayOfWeekFormatter:dt.func,defaultValue:dt.object,disabled:dt.bool,disableFuture:dt.bool,disableHighlightToday:dt.bool,disableOpenPicker:dt.bool,disablePast:dt.bool,displayWeekNumber:dt.bool,enableAccessibleFieldDOMStructure:dt.any,fixedWeekNumber:dt.number,format:dt.string,formatDensity:dt.oneOf(["dense","spacious"]),inputRef:qF,label:dt.node,loading:dt.bool,localeText:dt.object,maxDate:dt.object,minDate:dt.object,monthsPerRow:dt.oneOf([3,4]),name:dt.string,onAccept:dt.func,onChange:dt.func,onClose:dt.func,onError:dt.func,onMonthChange:dt.func,onOpen:dt.func,onSelectedSectionsChange:dt.func,onViewChange:dt.func,onYearChange:dt.func,open:dt.bool,openTo:dt.oneOf(["day","month","year"]),orientation:dt.oneOf(["landscape","portrait"]),readOnly:dt.bool,reduceAnimations:dt.bool,referenceDate:dt.object,renderLoading:dt.func,selectedSections:dt.oneOfType([dt.oneOf(["all","day","empty","hours","meridiem","minutes","month","seconds","weekDay","year"]),dt.number]),shouldDisableDate:dt.func,shouldDisableMonth:dt.func,shouldDisableYear:dt.func,showDaysOutsideCurrentMonth:dt.bool,slotProps:dt.object,slots:dt.object,sx:dt.oneOfType([dt.arrayOf(dt.oneOfType([dt.func,dt.object,dt.bool])),dt.func,dt.object]),timezone:dt.string,value:dt.object,view:dt.oneOf(["day","month","year"]),viewRenderers:dt.shape({day:dt.func,month:dt.func,year:dt.func}),views:dt.arrayOf(dt.oneOf(["day","month","year"]).isRequired),yearsOrder:dt.oneOf(["asc","desc"]),yearsPerRow:dt.oneOf([3,4])};function abe(e){return kn("MuiDialogContent",e)}vn("MuiDialogContent",["root","dividers"]);const ibe=vn("MuiDialogTitle",["root"]),sbe=e=>{const{classes:t,dividers:n}=e;return Sn({root:["root",n&&"dividers"]},abe,t)},lbe=ot("div",{name:"MuiDialogContent",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.root,n.dividers&&t.dividers]}})(rr(({theme:e})=>({flex:"1 1 auto",WebkitOverflowScrolling:"touch",overflowY:"auto",padding:"20px 24px",variants:[{props:({ownerState:t})=>t.dividers,style:{padding:"16px 24px",borderTop:`1px solid ${(e.vars||e).palette.divider}`,borderBottom:`1px solid ${(e.vars||e).palette.divider}`}},{props:({ownerState:t})=>!t.dividers,style:{[`.${ibe.root} + &`]:{paddingTop:0}}}]}))),cbe=C.forwardRef(function(e,t){const n=tr({props:e,name:"MuiDialogContent"}),{className:r,dividers:o=!1,...a}=n,i={...n,dividers:o},s=sbe(i);return p.jsx(lbe,{className:Ht(s.root,r),ownerState:i,ref:t,...a})});function ube(e){return kn("MuiDialog",e)}const Wg=vn("MuiDialog",["root","scrollPaper","scrollBody","container","paper","paperScrollPaper","paperScrollBody","paperWidthFalse","paperWidthXs","paperWidthSm","paperWidthMd","paperWidthLg","paperWidthXl","paperFullWidth","paperFullScreen"]),dbe=C.createContext({}),fbe=ot(I3,{name:"MuiDialog",slot:"Backdrop",overrides:(e,t)=>t.backdrop})({zIndex:-1}),pbe=e=>{const{classes:t,scroll:n,maxWidth:r,fullWidth:o,fullScreen:a}=e,i={root:["root"],container:["container",`scroll${zt(n)}`],paper:["paper",`paperScroll${zt(n)}`,`paperWidth${zt(String(r))}`,o&&"paperFullWidth",a&&"paperFullScreen"]};return Sn(i,ube,t)},hbe=ot(L3,{name:"MuiDialog",slot:"Root"})({"@media print":{position:"absolute !important"}}),mbe=ot("div",{name:"MuiDialog",slot:"Container",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.container,t[`scroll${zt(n.scroll)}`]]}})({height:"100%","@media print":{height:"auto"},outline:0,variants:[{props:{scroll:"paper"},style:{display:"flex",justifyContent:"center",alignItems:"center"}},{props:{scroll:"body"},style:{overflowY:"auto",overflowX:"hidden",textAlign:"center","&::after":{content:'""',display:"inline-block",verticalAlign:"middle",height:"100%",width:"0"}}}]}),gbe=ot(ef,{name:"MuiDialog",slot:"Paper",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.paper,t[`scrollPaper${zt(n.scroll)}`],t[`paperWidth${zt(String(n.maxWidth))}`],n.fullWidth&&t.paperFullWidth,n.fullScreen&&t.paperFullScreen]}})(rr(({theme:e})=>({margin:32,position:"relative",overflowY:"auto","@media print":{overflowY:"visible",boxShadow:"none"},variants:[{props:{scroll:"paper"},style:{display:"flex",flexDirection:"column",maxHeight:"calc(100% - 64px)"}},{props:{scroll:"body"},style:{display:"inline-block",verticalAlign:"middle",textAlign:"initial"}},{props:({ownerState:t})=>!t.maxWidth,style:{maxWidth:"calc(100% - 64px)"}},{props:{maxWidth:"xs"},style:{maxWidth:e.breakpoints.unit==="px"?Math.max(e.breakpoints.values.xs,444):`max(${e.breakpoints.values.xs}${e.breakpoints.unit}, 444px)`,[`&.${Wg.paperScrollBody}`]:{[e.breakpoints.down(Math.max(e.breakpoints.values.xs,444)+64)]:{maxWidth:"calc(100% - 64px)"}}}},...Object.keys(e.breakpoints.values).filter(t=>t!=="xs").map(t=>({props:{maxWidth:t},style:{maxWidth:`${e.breakpoints.values[t]}${e.breakpoints.unit}`,[`&.${Wg.paperScrollBody}`]:{[e.breakpoints.down(e.breakpoints.values[t]+64)]:{maxWidth:"calc(100% - 64px)"}}}})),{props:({ownerState:t})=>t.fullWidth,style:{width:"calc(100% - 64px)"}},{props:({ownerState:t})=>t.fullScreen,style:{margin:0,width:"100%",maxWidth:"100%",height:"100%",maxHeight:"none",borderRadius:0,[`&.${Wg.paperScrollBody}`]:{margin:0,maxWidth:"100%"}}}]}))),ybe=C.forwardRef(function(e,t){const n=tr({props:e,name:"MuiDialog"}),r=Qd(),o={enter:r.transitions.duration.enteringScreen,exit:r.transitions.duration.leavingScreen},{"aria-describedby":a,"aria-labelledby":i,"aria-modal":s=!0,BackdropComponent:l,BackdropProps:d,children:u,className:m,disableEscapeKeyDown:g=!1,fullScreen:y=!1,fullWidth:x=!1,maxWidth:w="sm",onClick:S,onClose:b,open:$,PaperComponent:k=ef,PaperProps:T={},scroll:O="paper",slots:P={},slotProps:D={},TransitionComponent:A=Ud,transitionDuration:F=o,TransitionProps:L,..._}=n,R={...n,disableEscapeKeyDown:g,fullScreen:y,fullWidth:x,maxWidth:w,scroll:O},z=pbe(R),I=C.useRef(),U=me=>{I.current=me.target===me.currentTarget},N=me=>{S&&S(me),I.current&&(I.current=null,b&&b(me,"backdropClick"))},q=Fs(i),Y=C.useMemo(()=>({titleId:q}),[q]),oe={transition:A,...P},Q={transition:L,paper:T,backdrop:d,...D},ae={slots:oe,slotProps:Q},[de,X]=mr("root",{elementType:hbe,shouldForwardComponentProp:!0,externalForwardedProps:ae,ownerState:R,className:Ht(z.root,m),ref:t}),[se,J]=mr("backdrop",{elementType:fbe,shouldForwardComponentProp:!0,externalForwardedProps:ae,ownerState:R}),[Z,G]=mr("paper",{elementType:gbe,shouldForwardComponentProp:!0,externalForwardedProps:ae,ownerState:R,className:Ht(z.paper,T.className)}),[ue,ie]=mr("container",{elementType:mbe,externalForwardedProps:ae,ownerState:R,className:z.container}),[fe,he]=mr("transition",{elementType:Ud,externalForwardedProps:ae,ownerState:R,additionalProps:{appear:!0,in:$,timeout:F,role:"presentation"}});return p.jsx(de,{closeAfterTransition:!0,slots:{backdrop:se},slotProps:{backdrop:{transitionDuration:F,as:l,...J}},disableEscapeKeyDown:g,onClose:b,open:$,onClick:N,...X,..._,children:p.jsx(fe,{...he,children:p.jsx(ue,{onMouseDown:U,...ie,children:p.jsx(Z,{as:k,elevation:24,role:"dialog","aria-describedby":a,"aria-labelledby":q,"aria-modal":s,...G,children:p.jsx(dbe.Provider,{value:Y,children:u})})})})})}),vbe=ot(ybe)({[`& .${Wg.container}`]:{outline:0},[`& .${Wg.paper}`]:{outline:0,minWidth:R1}}),bbe=ot(cbe)({"&:first-of-type":{padding:0}});function xbe(e){const{children:t,onDismiss:n,open:r,slots:o,slotProps:a}=e,i=o?.dialog??vbe,s=o?.mobileTransition??Ud;return p.jsx(i,Fe({open:r,onClose:n},a?.dialog,{TransitionComponent:s,TransitionProps:a?.mobileTransition,PaperComponent:o?.mobilePaper,PaperProps:a?.mobilePaper,children:p.jsx(bbe,{children:t})}))}const wbe=["props","getOpenDialogAriaText"],Sbe=e=>{let{props:t,getOpenDialogAriaText:n}=e,r=qn(e,wbe);const{slots:o,slotProps:a,className:i,sx:s,format:l,formatDensity:d,enableAccessibleFieldDOMStructure:u,selectedSections:m,onSelectedSectionsChange:g,timezone:y,name:x,label:w,inputRef:S,readOnly:b,disabled:$,localeText:k}=t,T=C.useRef(null),O=Fs(),P=a?.toolbar?.hidden??!1,{open:D,actions:A,layoutProps:F,renderCurrentView:L,fieldProps:_,contextValue:R}=k3(Fe({},r,{props:t,fieldRef:T,autoFocusView:!0,additionalViewProps:{},wrapperVariant:"mobile"})),z=o.field,I=Sr({elementType:z,externalSlotProps:a?.field,additionalProps:Fe({},_,P&&{id:O},!($||b)&&{onClick:A.onOpen,onKeyDown:$pe(A.onOpen)},{readOnly:b??!0,disabled:$,className:i,sx:s,format:l,formatDensity:d,enableAccessibleFieldDOMStructure:u,selectedSections:m,onSelectedSectionsChange:g,timezone:y,label:w,name:x},S?{inputRef:S}:{}),ownerState:t});I.inputProps=Fe({},I.inputProps,{"aria-label":n(_.value)});const U=Fe({textField:o.textField},I.slots),N=o.layout??O3;let q=O;P&&(w?q=`${O}-label`:q=void 0);const Y=Fe({},a,{toolbar:Fe({},a?.toolbar,{titleId:O}),mobilePaper:Fe({"aria-labelledby":q},a?.mobilePaper)}),oe=vr(T,I.unstableFieldRef);return{renderPicker:()=>p.jsxs(P3,{contextValue:R,localeText:k,children:[p.jsx(z,Fe({},I,{slots:U,slotProps:Y,unstableFieldRef:oe})),p.jsx(xbe,Fe({},A,{open:D,slots:o,slotProps:Y,children:p.jsx(N,Fe({},F,Y?.layout,{slots:o,slotProps:Y,children:L()}))}))]})}},o_=C.forwardRef(function(e,t){const n=vc(),r=Qr(),o=o3(e,"MuiMobileDatePicker"),a=Fe({day:Ip,month:Ip,year:Ip},o.viewRenderers),i=Fe({},o,{viewRenderers:a,format:x2(r,o,!1),slots:Fe({field:X3},o.slots),slotProps:Fe({},o.slotProps,{field:l=>Fe({},x1(o.slotProps?.field,l),i3(o),{ref:t}),toolbar:Fe({hidden:!1},o.slotProps?.toolbar)})}),{renderPicker:s}=Sbe({props:i,valueManager:Cl,valueType:"date",getOpenDialogAriaText:n3({utils:r,formatKey:"fullDate",contextTranslation:n.openDatePickerDialogue,propsTranslation:i.localeText?.openDatePickerDialogue}),validator:tv});return s()});o_.propTypes={autoFocus:dt.bool,className:dt.string,closeOnSelect:dt.bool,dayOfWeekFormatter:dt.func,defaultValue:dt.object,disabled:dt.bool,disableFuture:dt.bool,disableHighlightToday:dt.bool,disableOpenPicker:dt.bool,disablePast:dt.bool,displayWeekNumber:dt.bool,enableAccessibleFieldDOMStructure:dt.any,fixedWeekNumber:dt.number,format:dt.string,formatDensity:dt.oneOf(["dense","spacious"]),inputRef:qF,label:dt.node,loading:dt.bool,localeText:dt.object,maxDate:dt.object,minDate:dt.object,monthsPerRow:dt.oneOf([3,4]),name:dt.string,onAccept:dt.func,onChange:dt.func,onClose:dt.func,onError:dt.func,onMonthChange:dt.func,onOpen:dt.func,onSelectedSectionsChange:dt.func,onViewChange:dt.func,onYearChange:dt.func,open:dt.bool,openTo:dt.oneOf(["day","month","year"]),orientation:dt.oneOf(["landscape","portrait"]),readOnly:dt.bool,reduceAnimations:dt.bool,referenceDate:dt.object,renderLoading:dt.func,selectedSections:dt.oneOfType([dt.oneOf(["all","day","empty","hours","meridiem","minutes","month","seconds","weekDay","year"]),dt.number]),shouldDisableDate:dt.func,shouldDisableMonth:dt.func,shouldDisableYear:dt.func,showDaysOutsideCurrentMonth:dt.bool,slotProps:dt.object,slots:dt.object,sx:dt.oneOfType([dt.arrayOf(dt.oneOfType([dt.func,dt.object,dt.bool])),dt.func,dt.object]),timezone:dt.string,value:dt.object,view:dt.oneOf(["day","month","year"]),viewRenderers:dt.shape({day:dt.func,month:dt.func,year:dt.func}),views:dt.arrayOf(dt.oneOf(["day","month","year"]).isRequired),yearsOrder:dt.oneOf(["asc","desc"]),yearsPerRow:dt.oneOf([3,4])};const Cbe=["desktopModeMediaQuery"],kbe=C.forwardRef(function(e,t){const n=Kr({props:e,name:"MuiDatePicker"}),{desktopModeMediaQuery:r=Rpe}=n,o=qn(n,Cbe);return VF(r,{defaultMatches:!0})?p.jsx(r_,Fe({ref:t},o)):p.jsx(o_,Fe({ref:t},o))}),a_=400;function i_(e,t){const[n,r]=C.useState(e);return C.useEffect(()=>{const o=setTimeout(()=>r(e),t);return()=>clearTimeout(o)},[e,t]),n}function s_(e,t,{same:n=Object.is,unset:r=!1}={}){const[o,a]=C.useState(e),[i,s]=C.useState(!1),l=C.useRef(!1),d=C.useRef(null),u=C.useRef(!1),m=C.useRef({draft:o,committed:e,focused:i,unset:r,commit:t,same:n});C.useEffect(()=>{m.current={draft:o,committed:e,focused:i,unset:r,commit:t,same:n}});const g=()=>{const k=m.current,T=d.current?d.current.value:k.committed;return l.current&&(k.unset||!k.same(k.draft,T))},y=()=>{const k=m.current;d.current={value:k.draft},k.commit(k.draft),k.unset&&k.same(k.draft,k.committed)&&(l.current=!1)},x=()=>{g()&&y()},[w,S]=C.useState(0),b=C.useMemo(()=>({draft:o,gen:w}),[o,w]),$=i_(b,a_);return C.useEffect(()=>{const k=m.current;k.same($.draft,k.draft)&&g()&&!u.current&&y()},[$]),C.useEffect(()=>()=>x(),[]),C.useEffect(()=>{if(d.current&&n(d.current.value,e)&&(d.current=null),n(o,e)){!r&&!d.current&&(l.current=!1);return}(!i||!l.current)&&a(e)},[e,i,o,r,n]),{draft:o,change:k=>{l.current=!0,a(k),!m.current.focused&&!n(k,e)&&t(k)},reset:k=>{l.current=!1,d.current=null,a(k)},bind:{onFocus:()=>s(!0),onBlur:()=>{s(!1),x(),d.current=null},onKeyDown:k=>{k.key==="Enter"&&!k.nativeEvent.isComposing&&x()},onCompositionStart:()=>{u.current=!0},onCompositionEnd:()=>{u.current=!1,S(k=>k+1)}}}}const $be=250,Rbe=300*1e3;function Tbe(e,t){const n=C.useContext(UR),r=t.trim(),[o,a]=C.useState("");C.useEffect(()=>{const m=setTimeout(()=>a(r),$be);return()=>clearTimeout(m)},[r]);const[i,s]=C.useState(),l=e?JSON.stringify(e.key):void 0;C.useEffect(()=>{if(!e||!n||o==="")return;let m=!0;return n.fetchQuery({queryKey:[...e.key,o],queryFn:({signal:g})=>e.run(o,g),staleTime:Rbe}).then(g=>{m&&s({key:l,text:o,page:g})}).catch(()=>{m&&s({key:l,text:o,failed:!0})}),()=>{m=!1}},[n,l,o]);const d=e!==void 0&&n!==void 0&&r!=="",u=i!==void 0&&i.key===l&&i.text===r;return{active:d,searching:d&&!u,page:d&&u?i.page:void 0,failed:d&&u&&i.failed===!0}}function j1(e,t){if(!t)return;const n=t.trim();if(!n)return;const r=e??"string";if(r==="date"||r==="timestamp"||r==="timestamptz")return n.replace(/^@/,"");if(r.startsWith("filter<")){const o=n.replace(/^f(?=['"])/,""),a=o.match(/^'([^'\\]*)'$/)??o.match(/^"([^"\\]*)"$/);return a?a[1]:o}return r==="string"?Ebe(n):n}function Ebe(e){const t=e[0];return e.length>=2&&(t==="'"||t==='"')&&e[e.length-1]===t?e.slice(1,-1).replace(/\\(["'\\ntr])/g,(n,r)=>r==="n"?`
|
|
470
470
|
`:r==="t"?" ":r==="r"?"\r":r):e}jr.extend(d2);const IN=14,Mbe=42;function Obe(e){const t=(e.annotations??[]).filter(r=>r.trim().startsWith("#("));if(t.length===0)return;const n=[];for(const r of t){const o=r.trim(),a=o.match(/description="([^"]*)"/);if(a){n.push(a[1]);continue}const i=o.replace(/^#\(/,"").replace(/\)\s*$/,"").trim();i&&n.push(i)}return n.length>0?n.join(`
|
|
471
471
|
`):void 0}function l_({given:e,value:t,onChange:n,options:r,optionsLoading:o,optionsFailed:a,optionsTruncated:i,optionSearch:s,onOpen:l}){const d=e.label??e.name??"",{theme:u}=Hr(),m=e.type??"string",g=Obe(e),y=j1(m,e.default),x=y!==void 0?`Default: ${y===""?"(empty)":y}`:void 0,w=g||x?p.jsxs(p.Fragment,{children:[g,g&&x?p.jsx("br",{}):null,x]}):void 0,S=m==="string"||uu(m)==="string",b=!ou(m)||typeof t!="string"||CF(t),$=J=>p.jsx(ki,{label:d,value:String(t),error:!0,inputProps:{readOnly:!0},helperText:p.jsxs(p.Fragment,{children:[`Not a ${J}. Clear it to pick one.`,w?p.jsx("br",{}):null,w]}),slotProps:{input:{endAdornment:p.jsx(c_,{onClear:()=>n(null)})}},fullWidth:!0,size:"small"}),k=ou(m),T=e.control==="multiselect"&&k,O=ou(m),P=e.control==="select"||e.control==="multiselect",D=P?O?typeof t=="string"?SF(t):[]:typeof t=="string"&&t!==""?[t]:[]:[],[A,F]=C.useState(""),[L,_]=C.useState(null),R=C.useRef(null),z=Tbe(P?s:void 0,A);if(P&&S&&b&&!(!T&&D.length>1)){const J=G=>{const ue=O?f2(G):void 0;if(G.length===0||ue===""){n(null);return}n(O?ue:G[0])},Z=Ibe(z,i,s);return p.jsx(u_.Provider,{value:Z,children:p.jsx(pK,{multiple:T,disableCloseOnSelect:T,onOpen:l,freeSolo:!0,forcePopupIcon:!0,autoSelect:!T,options:z.page?.values??r??[],...z.page?{filterOptions:G=>G}:{},onInputChange:(G,ue,ie)=>F(ie==="input"?ue:""),loading:o||z.searching,loadingText:z.searching?"Searching…":"Loading…",noOptionsText:a?"Options unavailable":"No matching values",slots:{paper:Nbe},value:T?D:D[0]??null,onChange:(G,ue)=>J(ue===null?[]:Array.isArray(ue)?ue:[ue]),renderInput:G=>p.jsx(ki,{...G,label:d,size:"small",placeholder:D.length!==0?void 0:t===""?"All":y??"All",error:a,helperText:a?p.jsxs(p.Fragment,{children:["Could not load the options for this control. Type a value to filter anyway.",w?p.jsx("br",{}):null,w]}):w,slotProps:{input:{...G.InputProps,endAdornment:p.jsxs(p.Fragment,{children:[o&&p.jsx(Cu,{size:16}),G.InputProps.endAdornment]})},htmlInput:{...G.inputProps,onBlur:ue=>{if(G.inputProps.onBlur?.(ue),!T)return;const ie=ue.target.value.trim();ie!==""&&!D.includes(ie)&&J([...D,ie])}}}}),fullWidth:!0})})}const I=ou(m)&&uu(m)==="number",{rangeMin:U,rangeMax:N}=e,q=I&&typeof t=="string"?$F(t):void 0,Y=I&&typeof t=="string"?RF(t):void 0;if((I||m==="number")&&U!==void 0&&N!==void 0&&(!I||t===void 0||t===null||t===""||q!==void 0||Y!==void 0)){const J=Y??(q!==void 0?[q,N]:void 0),Z=I?J?.[0]:typeof t=="number"?t:void 0;if(Z===void 0&&t!==void 0&&t!==null&&t!=="")return $("number");const G=L!==null,ue=G?Array.isArray(L)?L[0]:L:Z??U,ie=Array.isArray(L)?[L[0],L[1]]:J??[U,N],fe=ie[1]>=N?`≥ ${ie[0]}`:`${ie[0]} to ${ie[1]}`,he=I&&t===""&&!G,me=Z!==void 0||he||G;return p.jsxs(mk,{fullWidth:!0,children:[p.jsxs(Re,{component:"fieldset",sx:le=>({m:0,minWidth:0,border:u.cardBorder,borderRadius:2,px:`${IN}px`,pt:0,pb:.75,minHeight:Mbe,transition:"border-color 120ms ease-in","&:hover":{borderColor:le.palette.text.secondary},"&:focus-within":{borderColor:le.palette.text.primary}}),children:[p.jsx(wt,{component:"legend",variant:"caption",color:"text.secondary",sx:{px:.5,lineHeight:1},children:d}),p.jsxs(Wn,{direction:"row",alignItems:"center",spacing:1,children:[p.jsx(wt,{variant:"body2",sx:{fontWeight:"fontWeightMedium"},children:me?he?"Any":I?fe:String(ue):I?"Any":y??"Unset"}),me&&p.jsx(by,{onClear:()=>n(null),sx:{p:0}})]}),p.jsx(iJ,{size:"small",min:U,max:N,value:I?ie:ue,disableSwap:I,valueLabelDisplay:"auto","aria-label":I?void 0:d,getAriaLabel:I?le=>le===0?`${d} from`:`${d} to`:void 0,sx:{py:0,mt:.5},onChange:(le,ve)=>{R.current=ve,_(ve)},onChangeCommitted:()=>{const le=R.current;if(R.current=null,_(null),le!==null){if(I){const[ve,Le]=Array.isArray(le)?[le[0],le[1]]:[le,le];if(ve<=U&&Le>=N){n(null);return}n(Le>=N?sce(ve):lce(ve,Le));return}n(Array.isArray(le)?le[0]:le)}}}),p.jsxs(Wn,{direction:"row",justifyContent:"space-between",children:[p.jsx(wt,{variant:"caption",color:"text.secondary",children:U}),p.jsx(wt,{variant:"caption",color:"text.secondary",children:N})]})]}),w&&p.jsx(gk,{sx:{mx:`${IN}px`},children:w})]})}const oe=ou(m)?uu(m):void 0,Q=oe==="date"||oe==="timestamp"||oe==="timestamptz",ae=typeof t=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(t),de=t==null||ae;if(Q&&!ae){const J=Abe(t);if(J!==void 0)return p.jsx(Dbe,{label:d,state:J,onChange:n,helperNode:w,defaultDisplay:y})}if(Q&&de){const J=ae?jr.utc(t):null;return p.jsx(Q0,{label:d,committed:J?.isValid()?J:null,toValue:Z=>Z.format("YYYY-MM-DD"),onChange:n,helperText:w})}if(uu(m)==="boolean"){const J=typeof t=="string"?ice(t):void 0;if(t==null||t===""||J!==void 0)return p.jsx(jbe,{label:d,picked:J,emptyOverride:t==="",onChange:n,helperNode:w,defaultDisplay:y})}if(m==="boolean"){const J=typeof t=="boolean";if(!J&&t!==void 0&&t!==null)return $("true or false");const Z=e.default?.trim()==="true";return p.jsxs(mk,{children:[p.jsxs(Wn,{direction:"row",alignItems:"center",children:[p.jsx(TR,{control:p.jsx(tQ,{checked:J?t:Z,onChange:G=>n(G.target.checked)}),label:d}),J&&p.jsx(by,{onClear:()=>n(null),edge:"end"})]}),w&&p.jsx(gk,{children:w})]})}if(m==="number"){const J=t!=null;return J&&t!==""&&typeof t!="number"?$("number"):p.jsx(LN,{label:d,type:"number",committed:typeof t=="number"?String(t):"",onCommit:Z=>n(Z===""?null:Number(Z)),placeholder:y,helperText:w,isOverridden:J,onClear:()=>n(null)})}if(m==="date"||m==="timestamp"||m==="timestamptz"){const J=t instanceof Date?t:typeof t=="string"?(G=>G instanceof Date?G:null)(NF(m,t)):null,Z=J?jr.utc(J):null;return t!=null&&t!==""&&J===null?$("date"):p.jsx(Q0,{label:d,committed:Z,toValue:G=>mce(G,J??void 0),onChange:n,helperText:w})}const X=typeof t=="string"?t:"",se=t!=null;return p.jsx(LN,{label:d,committed:X,onCommit:n,placeholder:se?void 0:y??(m.startsWith("filter<")?m:void 0),helperText:w,isOverridden:se,emptyOverrides:!0,onClear:()=>n(null)})}function LN({label:e,type:t,committed:n,onCommit:r,placeholder:o,helperText:a,isOverridden:i,emptyOverrides:s=!1,onClear:l}){const{draft:d,change:u,reset:m,bind:g}=s_(n,r,{unset:s&&!i});return p.jsx(ki,{label:e,type:t,value:d,onChange:y=>u(y.target.value),placeholder:o,helperText:a,slotProps:{input:{endAdornment:i&&p.jsx(c_,{onClear:()=>{m(""),l()}})}},...g,fullWidth:!0,size:"small"})}const Pbe=(e,t)=>e===null||t===null?e===t:e.year()===t.year()&&e.month()===t.month()&&e.date()===t.date();function Q0({label:e,committed:t,toValue:n,onChange:r,helperText:o,minDate:a}){const{draft:i,change:s,reset:l,bind:d}=s_(t,u=>{u===null?r(null):u.isValid()&&r(n(u))},{same:Pbe});return p.jsx(t3,{dateAdapter:iue,children:p.jsx(kbe,{label:e,value:i,minDate:a,onChange:s,slotProps:{textField:{fullWidth:!0,size:"small",helperText:o,...d},field:{clearable:!0,onClear:()=>{l(null),r(null)}},clearButton:{onMouseDown:u=>u.preventDefault()}}})})}function by({onClear:e,edge:t,sx:n}){return p.jsx(no,{size:"small","aria-label":"Clear value",onClick:e,edge:t,sx:[{minWidth:24,minHeight:24},...Array.isArray(n)?n:[n]],children:p.jsx(Ice,{fontSize:"small"})})}function c_({onClear:e}){return p.jsx(MR,{position:"end",onMouseDown:t=>t.preventDefault(),children:p.jsx(by,{onClear:e,edge:"end"})})}const zb="__any__";function jbe({label:e,picked:t,emptyOverride:n,onChange:r,helperNode:o,defaultDisplay:a}){const i=t??(n?zb:"");return p.jsx(Re,{"data-testid":"boolean-filter",children:p.jsxs(ki,{select:!0,label:e,value:i,size:"small",fullWidth:!0,helperText:o,slotProps:{select:{displayEmpty:!0,renderValue:s=>s==="true"||s==="false"?s:s===zb?"Any":a||"Any"},input:{endAdornment:i!==""?p.jsx(by,{onClear:()=>r(null),sx:{mr:2}}):void 0}},onChange:s=>{s.target.value!==zb&&r(s.target.value)},children:[n&&p.jsx(ea,{value:zb,children:"Any"}),p.jsx(ea,{value:"true",children:"true"}),p.jsx(ea,{value:"false",children:"false"})]})})}function Abe(e){if(e==null)return{kind:"unset"};if(typeof e!="string")return;if(e==="")return{kind:"any"};const t=TF(e);if(t!==void 0)return{kind:"preset",key:t};const n=EF(e);if(n!==void 0)return{kind:"days",...n}}const Fb="__custom__",RC="__any__";function Dbe({label:e,state:t,onChange:n,helperNode:r,defaultDisplay:o}){const a=t.kind==="days"?`days:${t.firstDay}/${t.lastDay}`:t.kind==="preset"?`preset:${t.key}`:t.kind,[i,s]=C.useState(t.kind==="days"),[l,d]=C.useState(t.kind==="days"?{from:t.firstDay,to:t.lastDay}:{});C.useEffect(()=>{t.kind==="days"?(s(!0),d({from:t.firstDay,to:t.lastDay})):t.kind!=="unset"&&s(!1)},[a]);const u=t.kind!=="unset",m=i?Fb:t.kind==="preset"?t.key:t.kind==="any"?RC:"",g=x=>{d(x),x.from&&x.to&&!jr.utc(x.to).isBefore(jr.utc(x.from))&&n(dce(x.from,x.to))},y=x=>{const w=x?jr.utc(x):null;return w?.isValid()?w:null};return p.jsxs(Wn,{direction:"row",spacing:1,"data-testid":"time-range",children:[p.jsxs(ki,{select:!0,label:e,value:m,size:"small",fullWidth:!0,helperText:r,slotProps:{select:{displayEmpty:!0,renderValue:x=>{if(x===Fb)return"Custom range";if(x===RC)return"Any time";const w=hy.find(S=>S.key===x);return w?w.label:o??"Any time"}},input:{endAdornment:u?p.jsx(by,{onClear:()=>{s(!1),d({}),n(null)},sx:{mr:2}}):void 0}},onChange:x=>{const w=x.target.value;if(w===Fb){s(!0);return}s(!1);const S=cce(w);S!==void 0&&n(S)},children:[t.kind==="any"&&p.jsx(ea,{value:RC,children:"Any time"}),hy.map(x=>p.jsx(ea,{value:x.key,children:x.label},x.key)),p.jsx(ea,{value:Fb,children:"Custom range"})]}),i&&p.jsxs(p.Fragment,{children:[p.jsx(Q0,{label:"From",committed:y(l.from),toValue:x=>x.format("YYYY-MM-DD"),onChange:x=>g({...l,from:x===null?void 0:String(x)})}),p.jsx(Q0,{label:"To",committed:y(l.to),minDate:y(l.from)??void 0,toValue:x=>x.format("YYYY-MM-DD"),onChange:x=>g({...l,to:x===null?void 0:String(x)})})]})]})}const u_=C.createContext(void 0);function Nbe({children:e,...t}){const n=C.useContext(u_);return p.jsxs(Ga,{...t,children:[e,n&&p.jsx(Re,{role:"note",sx:{px:2,py:1,borderTop:1,borderColor:"divider",color:"text.secondary",typography:"caption"},children:n})]})}const _b=e=>e.toLocaleString("en-US");function Ibe(e,t,n){if(e.active)return e.searching?"Searching all values…":e.failed?`Could not search all values. Showing matches in the first ${_b(Ed)}.`:e.page?.truncated?`Showing the first ${_b(m2)} matches. Keep typing to narrow them.`:void 0;if(t)return n?`Showing the first ${_b(Ed)} values. Type to search them all.`:`Showing the first ${_b(Ed)} values. A value not listed can still be typed.`}const Lbe=C.createContext(void 0),Sh=()=>C.useContext(Lbe),Rg="remove-badge",zbe={[`& .${Rg}`]:{opacity:0},[`&:hover .${Rg}, &:focus-within .${Rg}`]:{opacity:1},"@media (hover: none)":{[`& .${Rg}`]:{opacity:1}}};function Fbe({label:e,onRemove:t,disabledReason:n,inset:r=0}){const{theme:o}=Hr(),a=n!==void 0,i=p.jsx(no,{className:Rg,"aria-label":e,"aria-disabled":a||void 0,...a?{"aria-description":n}:{},onClick:s=>{s.stopPropagation(),a||t()},onPointerDown:s=>s.stopPropagation(),sx:s=>({position:"absolute",top:-8-r,right:-8-r,zIndex:3,width:18,height:18,p:0,borderRadius:"50%",border:`1px solid ${Xd(o.cardBorder)}`,bgcolor:s.palette.background.paper,color:s.palette.text.secondary,cursor:a?"default":"pointer",transition:`opacity ${Zy}`,...Jy,"&:hover":{bgcolor:s.palette.background.paper,color:a?s.palette.text.secondary:s.palette.text.primary,borderColor:dF(o.cardBorder,o.tileTitle)}}),children:p.jsx(bh,{sx:{fontSize:12}})});return a?p.jsx(Br,{title:n,children:i}):i}const W2=e=>e.required===!0,_be=(e,t)=>e==null||e===""&&!DF(t);function Bbe(e,t,n){return e.filter(r=>r.name!==void 0&&W2(r)&&_be(t.get(r.name),r.type)&&(n?.[r.name]===void 0||n[r.name]===null))}function Ube(e,t){if(!t||e.length===0)return[];const n=new Set(t);return e.filter(r=>r.name&&n.has(r.name))}const d_=e=>e.label??e.name??"";function f_(e){return e.length<2?e.join(""):`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function Vbe(e){const t=e.map(d_);return`Pick a value for ${f_(t)} to see this report.`}function qbe(e){return`Waiting for ${f_(e.map(d_))}.`}const m$=28,Hbe=/^\d{4}-\d{2}-\d{2}$/,p_=new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric",timeZone:"UTC"});function TC(e){if(!Hbe.test(e))return e;const t=new Date(`${e}T00:00:00Z`);return Number.isNaN(t.getTime())?e:p_.format(t)}function Wbe(e,t){if(e.length===0)return"";const n=e.join(", ");return t?n:n.length<=m$||e.length===1?X0(n,t):`${X0(e[0]??"",t)} +${e.length-1}`}function X0(e,t){return!t&&e.length>m$?`${e.slice(0,m$-1)}…`:e}function Ybe(e,t){if(W2(e))return"Required";const n=e.type??"string",r=j1(n,e.default);if(r!==void 0&&r!=="")return h_(n,r,t);const o=uu(n)??n;return e.control==="select"||e.control==="multiselect"||o==="string"?"All":"Any"}function h_(e,t,n){if(!ou(e))return X0(TC(t),n);const r=uu(e);if(r==="string"&&CF(t))return Wbe(SF(t),n);if(r==="number"){const o=RF(t);if(o)return`${o[0]}–${o[1]}`;const a=$F(t);if(a!==void 0)return`≥ ${a}`}if(r==="date"||r==="timestamp"||r==="timestamptz"){const o=TF(t);if(o)return hy.find(i=>i.key===o)?.label??t;const a=EF(t);if(a)return`${TC(a.firstDay)} – ${TC(a.lastDay)}`}return X0(t,n)}function m_(e,t,n){return t==null?Ybe(e,n):t instanceof Date?Number.isNaN(t.getTime())?"":p_.format(t):typeof t=="boolean"?t?"Yes":"No":typeof t=="number"?String(t):t===""?"(empty)":h_(e.type??"string",t,n)}function Gbe(e,t){return m_(e,t,!1)}function Kbe(e,t){return m_(e,t,!0)}function Qbe(e){const{given:t,value:n,onChange:r}=e,{theme:o}=Hr(),a=o.ui,i=Sh(),[s,l]=C.useState(null),d=t.name??"",u=t.label??d,m=n!=null,g=Gbe(t,n),y=s!==null,x=i?.stateOf(d),w=x?.problem,S=x?.fixed,b=p.jsxs(g_,{name:d,set:m,open:y,problem:w,fixed:S!==void 0,required:!m&&W2(t),children:[p.jsxs(rs,{"aria-haspopup":"dialog","aria-expanded":y,"aria-label":`${u}: ${g}`,onClick:$=>{l($.currentTarget),e.onOpen?.()},sx:$=>({height:"100%",borderRadius:a.radius.control,pl:"10px",pr:m?"4px":"8px",gap:"6px",fontFamily:"inherit",fontSize:a.type.control.fontSize,lineHeight:1,minWidth:0,color:$.palette.text.primary}),children:[p.jsx(Re,{component:"span",sx:$=>({color:m?o.accent:$.palette.text.secondary,whiteSpace:"nowrap"}),children:u}),p.jsx(Re,{component:"span",sx:{fontWeight:a.type.control.fontWeight,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:g}),!m&&p.jsx(uF,{"aria-hidden":!0,sx:$=>({fontSize:16,color:$.palette.text.secondary,transform:y?"rotate(180deg)":"none"})})]}),m&&p.jsx(no,{"aria-label":`Clear ${u}`,onClick:()=>r(null),sx:{width:22,height:22,mr:"4px",borderRadius:"4px",color:o.accent},children:p.jsx(bh,{sx:{fontSize:14}})})]});return p.jsxs(p.Fragment,{children:[w?p.jsx(Br,{title:w,children:b}):b,p.jsxs(jR,{className:Sl.filterPopover,open:y,anchorEl:s,onClose:()=>l(null),anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},slotProps:{paper:{role:"dialog","aria-label":`${u} filter`,sx:{mt:.75,p:1.5,width:300,maxWidth:"calc(100vw - 32px)",boxSizing:"border-box",borderRadius:a.radius.tile,border:o.cardBorder,boxShadow:o.shadow.lift}}},children:[p.jsx(l_,{...e}),i&&p.jsxs(Re,{sx:$=>({mt:1.5,pt:1,borderTop:`1px solid ${$.palette.divider}`,display:"flex",flexDirection:"column",alignItems:"flex-start",gap:.5}),children:[w&&p.jsx(wt,{sx:{...a.type.caption,color:"warning.main"},children:w}),S!==void 0&&p.jsx(wt,{sx:$=>({...a.type.caption,color:$.palette.text.secondary}),children:S}),p.jsx(Jbe,{name:d,type:t.type,text:Xbe(n,t.type)}),S===void 0?p.jsx(Hn,{size:"small","aria-label":`Edit filter ${d}`,"aria-haspopup":"dialog",onClick:()=>{l(null),i.onEdit(d)},sx:{px:.75,minWidth:0,...a.type.control},children:"Filter settings…"}):x?.openModel&&p.jsx(Hn,{size:"small",onClick:()=>{l(null),x.openModel?.()},sx:{px:.75,minWidth:0,...a.type.control},children:"Open the model"})]})]})]})}function Xbe(e,t){if(e!=null)return jF(e,t)}function Zbe(e,t){return e===void 0||!t?.startsWith("filter<")?e:/^f(['"])([\s\S]*)\1$/.exec(e)?.[2]??e}function Jbe({name:e,type:t,text:n}){const r=Sh(),o=Hr().theme.ui;if(!r?.setStartingValue)return null;const a=r.setStartingValue,i=Zbe(r.startingValueOf?.(e),t),s=r.stateOf(e)?.origin==="dashboard",l={px:.75,minWidth:0,...o.type.control};return p.jsxs(p.Fragment,{children:[i!==void 0&&i===n&&p.jsxs(wt,{sx:d=>({...o.type.caption,color:d.palette.text.secondary,px:.75,display:"flex",alignItems:"center",gap:.5}),children:[p.jsx(cF,{"aria-hidden":!0,sx:{fontSize:14}}),"Report default"]}),n!==void 0&&n!==i&&p.jsx(Hn,{size:"small",onClick:()=>a(e,n),sx:l,children:"Make this the report's default"}),i!==void 0&&p.jsx(Hn,{size:"small",onClick:()=>a(e,void 0),sx:l,children:s?"Use the filter's default":"Use the model's default"})]})}function g_({name:e,set:t=!1,open:n=!1,unused:r=!1,problem:o,fixed:a=!1,required:i=!1,children:s}){const{theme:l}=Hr(),d=l.ui,u=Sh();return p.jsxs(Re,{className:Sl.filter,"data-filter":e,"data-set":t||void 0,"data-problem":o?!0:void 0,"data-required":i||void 0,sx:m=>({position:"relative",display:"inline-flex",alignItems:"center",height:d.size.control,boxSizing:"border-box",borderRadius:d.radius.control,border:"1px solid",borderStyle:r?"dashed":"solid",borderColor:o||i?m.palette.warning.main:t?`color-mix(in srgb, ${l.accent} 45%, transparent)`:n?l.accent:Xd(l.cardBorder),bgcolor:t?`color-mix(in srgb, ${l.accent} 8%, ${m.palette.background.paper})`:m.palette.background.paper,opacity:r?.75:1,transition:`border-color ${Zy}`,...Jy,"&:hover":{borderColor:t||n||o?void 0:dF(l.cardBorder,l.tileTitle)},maxWidth:"100%",...zbe}),children:[s,u&&!a&&p.jsx(Fbe,{label:`Remove filter ${e}`,onRemove:()=>u.onRemove(e)})]})}function e0e({name:e,label:t,unused:n=!0}){const r=Sh(),o=Hr().theme.ui;if(!r)return null;const a=r.stateOf(e)?.problem,i=p.jsx(g_,{name:e,unused:n,problem:a,children:p.jsxs(rs,{"aria-label":`Edit filter ${e}`,"aria-haspopup":"dialog",onClick:()=>r.onEdit(e),sx:s=>({height:"100%",borderRadius:o.radius.control,px:"10px",gap:"6px",fontFamily:"inherit",fontSize:o.type.control.fontSize,lineHeight:1,color:s.palette.text.secondary,whiteSpace:"nowrap"}),children:[p.jsx("span",{children:t}),n&&p.jsx(Re,{component:"span",sx:{fontStyle:"italic"},children:"Unused"})]})});return a?p.jsx(Br,{title:a,children:i}):i}function t0e(){const{theme:e}=Hr(),t=e.ui,n=Sh();if(!n)return null;const r=n.addDisabledReason!==void 0;return p.jsx(Br,{title:n.addDisabledReason??"",children:p.jsx("span",{children:p.jsx(Hn,{variant:"outlined",startIcon:p.jsx(p1,{}),"aria-label":"Add filter","aria-haspopup":"dialog",disabled:r,onClick:()=>n.onAdd(),sx:o=>({height:t.size.control,minHeight:t.size.control,px:1.25,borderRadius:t.radius.control,borderStyle:"dashed",borderColor:Xd(e.cardBorder),color:o.palette.text.secondary,boxShadow:"none",...t.type.control,"& .MuiButton-startIcon":{mr:.5},"& .MuiButton-startIcon svg":{fontSize:16}}),children:"Filter"})})})}function A1({givens:e,values:t,onChange:n,onReset:r,canReset:o,layout:a="panel",options:i,optionsLoading:s,optionsFailed:l,optionsTruncated:d,optionSearch:u,apply:m,title:g,onControlOpen:y}){const x=Sh();if(e.length===0&&!(x&&a==="bar"))return null;const w=Array.from(t.values()).some(T=>T!==null),S=o??w,b=T=>{if(T===void 0)return{};const O=u?.get(T);return{...d?.has(T)?{optionsTruncated:!0}:{},...O?{optionSearch:O}:{},...y?{onOpen:()=>y(T)}:{}}},$=e.map(T=>p.jsx(Re,{children:p.jsx(l_,{given:T,value:T.name?t.get(T.name):void 0,onChange:O=>T.name&&n(T.name,O),options:T.name?i?.get(T.name):void 0,optionsLoading:s,optionsFailed:T.name?l?.has(T.name):void 0,...b(T.name)})},T.name)),k=p.jsxs(Wn,{direction:"row",alignItems:"center",spacing:1,children:[m&&p.jsx(Hn,{variant:"contained",size:"small",disableElevation:!0,onClick:()=>m.pending&&m.onApply(),"aria-disabled":!m.pending,sx:{"&[aria-disabled='true']":{cursor:"default",color:"action.disabled",backgroundColor:"action.disabledBackground","&:hover":{backgroundColor:"action.disabledBackground"}}},children:"Apply"}),S&&p.jsx(Hn,{variant:"text",size:"small",onClick:r,children:"Reset"})]});return a==="bar"?p.jsxs(Wn,{direction:"row",role:"group","aria-label":g??"Filters",useFlexGap:!0,sx:{flexWrap:"wrap",alignItems:"center",gap:1},children:[e.map(T=>p.jsx(Qbe,{given:T,value:T.name?t.get(T.name):void 0,onChange:O=>T.name&&n(T.name,O),options:T.name?i?.get(T.name):void 0,optionsLoading:s,optionsFailed:T.name?l?.has(T.name):void 0,...b(T.name)},T.name)),x?.unrendered.map(T=>p.jsx(e0e,{name:T.name,label:T.label},T.name)),p.jsx(t0e,{}),p.jsx(Re,{sx:{ml:"auto"},children:k})]}):p.jsxs(Ga,{elevation:0,sx:{p:3,backgroundColor:"transparent",border:"none",boxShadow:"none"},children:[p.jsxs(Wn,{direction:"row",alignItems:"center",justifyContent:"space-between",sx:{mb:2},children:[p.jsx(wt,{variant:"subtitle2",sx:{fontWeight:"fontWeightMedium",color:"text.primary"},children:g??"Filters"}),k]}),p.jsx(Re,{sx:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(220px, 1fr))",alignItems:"start",columnGap:3,rowGap:2.5},children:$})]})}const n0e=/^(https?|mailto|tel):/i,r0e=/^[a-z][a-z0-9+.-]*:/i;function o0e({href:e,title:t,children:n,context:r}){const o=!!e&&r0e.test(e),a=!!e&&!o&&!e.startsWith("/")&&!e.startsWith("#");if(!e||!a||!r){const m=o&&!n0e.test(e??"");return p.jsx("a",{href:m?void 0:e,title:t,...o?{target:"_blank",rel:"noopener noreferrer"}:{},children:n})}const i=r.sourcePath&&r.sourcePath.includes("/")?r.sourcePath.slice(0,r.sourcePath.lastIndexOf("/")+1):"",s=new URL(e,`https://malloy.invalid/${i}`),l=s.pathname.slice(1)+s.search+s.hash,d=`/${r.environmentName}/${r.packageName}/${l}`,{onNavigate:u}=r;return p.jsx("a",{href:d,title:t,onClick:u?m=>{m.preventDefault(),u(d,m)}:void 0,children:n})}const a0e=e=>({document:{"& > :first-child, & > div:only-child > :first-child":{mt:0},"& > :last-child, & > div:only-child > :last-child":{mb:0},"& h1, & h2, & h3, & h4, & h5, & h6":{fontWeight:"fontWeightMedium",color:"text.primary",mb:1,mt:2},"& h1":{fontSize:"28px"},"& h2":{fontSize:"24px"},"& h3":{fontSize:"20px"},"& p, & ul, & ol":{color:"text.primary",...e.type.prose,mb:1,maxWidth:sle},"& li":{mb:.5}},caption:{color:"text.secondary",typography:"body2","& > :first-of-type":{mt:0},"& > :last-child":{mb:0},"& h1, & h2, & h3, & h4, & h5, & h6":{fontSize:"inherit",fontWeight:"fontWeightMedium",m:"0.5em 0 0.25em"},"& p":{m:"0.5em 0"},"& ul, & ol":{m:"0.5em 0",pl:3},"& code":{fontFamily:e.font.mono,fontSize:"0.9em"}}});function i0e({alt:e}){return p.jsx(p.Fragment,{children:e})}function xy({children:e,variant:t="caption",links:n,sx:r}){const{theme:o}=Hr();return p.jsx(Re,{sx:[a0e(o.ui)[t],{fontFamily:o.font.family},...Array.isArray(r)?r:[r]],children:p.jsx(Hoe,{options:{forceBlock:t==="document",disableParsingRawHTML:!0,overrides:{a:{component:o0e,props:{context:n}},img:{component:i0e}}},children:e})})}const qd={opening:e=>e?`Opening the ${e}…`:"Opening…",running:"Running…",loading:"Loading…"};function Go({text:e,size:t=20,color:n="primary",thickness:r=3.6,centered:o=!0,spacing:a=2,textVariant:i="body2"}){const s=p.jsxs(Re,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:a},children:[p.jsx(Cu,{size:t,color:n,thickness:r}),e&&p.jsx(wt,{variant:i,color:"text.secondary",children:e})]});return o?p.jsx(Re,{sx:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"200px",width:"100%"},children:s}):s}let ng;function s0e(){return ng||(ng=vo(()=>import("./index-Co7C9Gew.js"),[]),ng.catch(()=>{ng=void 0})),ng}function Y2(){typeof window>"u"||s0e().catch(()=>{})}const y_=rn(p.jsx("path",{d:"M11 7h2v2h-2zm0 4h2v6h-2zm1-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8"}));function Lp({sx:e,...t}){const{theme:n}=Hr();return p.jsx(no,{size:"small",...t,sx:[{width:32,height:32,bgcolor:n.tile,border:n.border,color:n.tileTitle,"&:hover":{bgcolor:n.tile,color:n.drillLink},"& .MuiSvgIcon-root":{fontSize:18}},...Array.isArray(e)?e:[e]]})}const l0e=new Set(["warn","error"]);function c0e(e){if(!e?.length)return;const t=[];let n=!1;for(const r of e)!r.message||!l0e.has(r.severity??"")||(r.severity==="error"&&(n=!0),t.includes(r.message)||t.push(r.message));if(t.length)return{severity:n?"error":"warn",title:t.join(`
|
|
472
|
-
`)}}const u0e=C.lazy(()=>vo(()=>import("./RenderedResult-CYJ2Y9Fm.es-C8nokn71.js"),[]).then(e=>e.c));function D1({result:e,maxHeight:t,tableMaxHeight:n,firstPaintHeight:r,maxResultSize:o=0,renderLogs:a,drill:i,fill:s=!1,compactToFit:l=!1}){const d=C.useRef(null);C.useEffect(()=>Y2(),[]);const[u,m]=C.useState(void 0),[g,y]=C.useState(void 0),[x,w]=C.useState(void 0),S=C.useCallback((U,N)=>{m(U),w(N)},[]),[b,$]=C.useState(!1),[k,T]=C.useState(void 0),O=c0e(a);C.useEffect(()=>{const U=d.current;if(!s||!U)return;const N=new ResizeObserver(([q])=>{T(Math.round(q.contentRect.height)),F(Math.round(q.contentRect.width))});return N.observe(U),()=>N.disconnect()},[s,!!e,b]);const[P,D]=C.useState(void 0),[A,F]=C.useState(void 0),L=s&&l&&u==="content";if(C.useEffect(()=>{D(void 0)},[e,A,L]),C.useEffect(()=>{L&&(k===void 0||g===void 0||(P===void 0&&g>k+1?D(g):P!==void 0&&k>=P&&D(void 0)))},[L,k,g,P]),!e)return null;if(o>0&&e.length>o&&!b)return p.jsxs(Re,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2,p:4,backgroundColor:"#fafafa",border:"1px solid",borderColor:"#e0e0e0",borderRadius:1},children:[p.jsx(cae,{sx:{fontSize:48,color:"#757575"}}),p.jsx(wt,{variant:"h6",color:"text.secondary",align:"center",children:"Processing large results may cause browser performance issues. Proceed?"}),p.jsx(Hn,{variant:"contained",color:"primary",onClick:()=>$(!0),children:"Proceed"})]});const _=p.jsx(Go,{text:qd.loading,centered:!0,size:32}),R=Ele({renderAs:x,maxHeight:t,tableMaxHeight:n}),z=$D({sizing:u,contentHeight:g,maxHeight:R,fillHeight:s?k:void 0,firstPaintHeight:r}),I=p.jsx(C.Suspense,{fallback:_,children:p.jsx(u0e,{result:e,height:z,onSizeChange:y,onSizing:S,drill:i,fill:s})});return p.jsxs(Re,{ref:d,sx:{position:"relative",height:"auto",border:"0px",borderRadius:0,overflowX:"hidden",overflowY:s?"hidden":"auto",...s&&{flex:`1 1 ${$D({sizing:u,contentHeight:g,maxHeight:R,firstPaintHeight:r})}px`,minHeight:0}},children:[s?p.jsx(Re,{className:Nle,...L&&P!==void 0?{[Dle]:""}:{},sx:{position:"absolute",inset:0,overflowX:"hidden",overflowY:"auto"},children:I}):I,O&&p.jsx(Re,{sx:{position:"absolute",top:4,right:4,zIndex:1},children:p.jsx(Br,{title:O.title,slotProps:{tooltip:{sx:{whiteSpace:"pre-line"}}},children:p.jsx(Lp,{"aria-label":"Render tag warnings",children:p.jsx(y_,{fontSize:"small",color:O.severity==="error"?"error":"warning"})})})})]})}function G2({state:e,context:t,loadingText:n=qd.running,maxHeight:r,tableMaxHeight:o,firstPaintHeight:a,maxResultSize:i,drill:s,fill:l,compactToFit:d,transform:u}){const{data:m,isSuccess:g,isError:y,error:x,fetchStatus:w,isPlaceholderData:S}=e,b=g||w==="fetching";C.useEffect(()=>{b&&Y2()},[b]);const $=m?.data.result,k=C.useMemo(()=>$!==void 0&&u?u($):$,[$,u]),T=C.useMemo(()=>hle(k),[k]);if(y)return p.jsx(Re,{sx:{p:2},children:p.jsx(Xa,{context:t,error:x})});if(!g)return p.jsx(Go,{text:w==="idle"?qd.loading:n});if(T)return p.jsx(Re,{sx:{p:2},children:p.jsx(wt,{variant:"body2",role:"status",color:"text.secondary",children:T})});const O=p.jsx(D1,{result:k,maxHeight:r,tableMaxHeight:o,...a!==void 0?{firstPaintHeight:a}:{},maxResultSize:i,renderLogs:m.data.renderLogs,drill:s,fill:l,compactToFit:d});return p.jsxs(Re,{"aria-busy":S||void 0,sx:{position:"relative",display:"flex",flexDirection:"column",flex:"1 1 auto",minHeight:0,minWidth:0,...l?{height:"100%"}:{},"& > .result-body":{display:"flex",flexDirection:"column",flex:"1 1 auto",minHeight:0,minWidth:0,...l?{height:"100%"}:{},opacity:S?.55:1,transition:S?"opacity 160ms ease 200ms":"opacity 120ms ease","@media (prefers-reduced-motion: reduce)":{transition:"none"}}},children:[S&&p.jsx(uz,{"aria-label":n,sx:{position:"absolute",top:0,left:0,right:0,height:2,zIndex:1,bgcolor:"transparent",borderRadius:1}}),p.jsx(Re,{className:"result-body",children:O})]})}const Od=()=>typeof performance<"u"?performance.now():Date.now(),d0e=rn(p.jsx("path",{d:"m16.95 6-3.57 4.55 1.43 1.43c1.03-1.31 4.98-6.37 4.98-6.37C20.3 4.95 19.83 4 19 4H6.83l2 2zM2.81 2.81 1.39 4.22 10 13v6c0 .55.45 1 1 1h2c.55 0 1-.45 1-1v-2.17l5.78 5.78 1.41-1.41z"})),f0e=3;function p0e(e,t){if(e===void 0)return[];const n=new Set(e);return t.flatMap(r=>r.name&&!n.has(r.name)?[r.label??r.name]:[])}function h0e(e){return e.length<2?e.join(""):`${e.slice(0,-1).join(", ")} or ${e[e.length-1]}`}function m0e({ignored:e}){const{theme:t}=Hr();if(e.length===0)return null;const n=e.length>f0e?`Doesn't respond to ${e.length} filters`:`Doesn't respond to ${e.join(", ")}`;return p.jsxs(Re,{"data-testid":"tile-filter-tag",title:`This tile's query never reads ${h0e(e)}, so changing ${e.length===1?"it":"them"} won't change this tile`,sx:{display:"inline-flex",alignItems:"center",gap:.5,maxWidth:"100%",mb:1,alignSelf:"flex-start",px:.75,py:.125,border:1,borderColor:"warning.main",borderRadius:1,fontSize:11,lineHeight:1.6,color:"warning.main",fontFamily:t.font.family},children:[p.jsx(d0e,{sx:{fontSize:12}}),p.jsx(Re,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n})]})}const g0e=/\.malloy(nb)?$/,N1=e=>e&&e.slice(e.lastIndexOf("/")+1).replace(g0e,"")||void 0,y0e=e=>e.replace(/\.malloy$/,"").split("/").map(encodeURIComponent).join("/"),v_=(e,t,n)=>`/${encodeURIComponent(e)}/${encodeURIComponent(t)}/${y0e(n)}`,v0e="edit",b0e=(e,t,n)=>`${v_(e,t,n)}?${v0e}`,K2=e=>e.layout==="linear"?"linear":"grid",g$=e=>({layout:K2(e),path:e.path,editable:e.editable!==!1});function x0e(e,t){const n=t.find(r=>r.path===e);return n?.path?g$({...n,path:n.path}):void 0}function w0e(e){return e===""||e.startsWith("/")?!1:e.split("/").every(t=>t!==""&&t!=="."&&t!=="..")}function S0e(e,t){if(!w0e(e))return{kind:"unresolved"};for(const n of[`${e}.malloy`,e]){const r=x0e(n,t);if(r)return{kind:"path",report:r}}return{kind:"unresolved"}}const C0e=(e,t,n)=>["reports",e,t,n];async function k0e(e,t,n,r){try{return(await e.reports.listReports(t,n,r)).data}catch(o){if(o?.response?.status===404)return[];throw o}}function b_(e,t,n,r=!0){const{apiClients:o}=er(),a=wo({queryKey:C0e(e,t,n),queryFn:()=>k0e(o,e,t,n),enabled:r,staleTime:6e4});return{reports:a.data??[],settled:a.isSuccess||a.isError,isFetching:a.isFetching,isError:a.isError,error:a.error,refetch:a.refetch}}const x_=20,$0e={radius:"8px",padding:`${x_}px`};function oTe(e,t=$0e){return{"--malloy-render--font-family":e.font.family,"--malloy-render--table-font-size":`${e.font.size}px`,"--malloy-render--table-header-color":e.tableHeader,"--malloy-render--table-body-color":e.tableBody,"--malloy-render--table-border":e.border,"--malloy-render--table-pinned-border":e.pinnedBorder,"--malloy-render--tile-background":e.tile,"--publisher-dashboard-root":e.dashboardRoot,"--malloy-render--label-color":e.tileTitle,"--malloy-render--value-color":e.valueColor,"--publisher-drill-link":e.drillLink,"--publisher-dashboard-card-radius":t.radius,"--publisher-dashboard-card-padding":t.padding,"--publisher-dashboard-card-border":e.cardBorder}}const R0e={query:120,text:72};function Z0({borderless:e=!1,chrome:t="card",kind:n="query",sx:r,cardRef:o,children:a}){const{theme:i}=Hr(),s=i.ui,l=e||t==="none";return p.jsx(Ga,{ref:o,className:Sl.tile,elevation:0,"data-chrome":t,"data-tile-kind":n,sx:[{border:l?"none":i.cardBorder,borderRadius:l?0:s.radius.tile,background:l?"none":i.tile,overflow:"hidden",isolation:"isolate",display:"flex",flexDirection:"column",minWidth:0,minHeight:t==="none"?0:R0e[n],p:t==="none"?0:e?"12px 0":`${x_}px`},...Array.isArray(r)?r:[r]],children:a})}const T0e=Sl.tileHeading;function w_({title:e,subtitle:t,tooltip:n,action:r,quiet:o=!1}){const{theme:a}=Hr(),i=a.ui;return p.jsxs(Re,{className:T0e,sx:{pb:o?.5:1.5,display:"flex",alignItems:"flex-start",gap:1},children:[p.jsxs(Re,{sx:{minWidth:0,flex:1},children:[p.jsx(wt,{component:"div",sx:{...i.type.tileTitle,display:"block",color:a.tileTitle,fontFamily:a.font.family},title:n,children:e}),t!==void 0&&p.jsx(wt,{component:"div",sx:{...i.type.caption,display:"block",mt:"2px",color:a.tileTitle,fontFamily:a.font.family,opacity:.75},children:t})]}),r]})}const E0e=-1;function M0e(e){const t=e.ownerDocument;for(let n=e.parentElement;n&&n!==t.body&&n!==t.documentElement;n=n.parentElement)if(/(auto|scroll|overlay)/.test(getComputedStyle(n).overflowY))return n}function O0e(e,t){if((t?t.scrollTop:window.scrollY)<=0)return!1;const n=parseFloat(getComputedStyle(e).top);if(Number.isNaN(n))return!1;const r=t?t.getBoundingClientRect().top+t.clientTop:0;return e.getBoundingClientRect().top-r<=n+.5}function P0e(){const[e,t]=C.useState(!1),n=C.useRef(null);return{stickyRef:C.useCallback(r=>{if(n.current?.(),n.current=null,!r||typeof window>"u")return;const o=M0e(r),a=o??window;let i=0;const s=()=>{i=0,t(O0e(r,o))},l=()=>{i===0&&(i=requestAnimationFrame(s))};a.addEventListener("scroll",l,{passive:!0}),window.addEventListener("resize",l),s(),n.current=()=>{a.removeEventListener("scroll",l),window.removeEventListener("resize",l),i!==0&&cancelAnimationFrame(i)}},[]),stuck:e}}const j0e=4,A0e="--publisher-sticky-top",D0e=2;function y$({layout:e,notice:t,header:n,controls:r,children:o,sx:a}){return p.jsxs(Wn,{className:Sl.report,"data-layout":e,sx:[{gap:D0e},...Array.isArray(a)?a:[a]],children:[t,n,r,o]})}function N0e({title:e,description:t,actions:n}){const r=Hr().theme.ui;return p.jsxs(Wn,{className:Sl.header,sx:{gap:1.5},children:[p.jsxs(Wn,{direction:"row",sx:{alignItems:"center",gap:2},children:[p.jsx(wt,{component:"h1",className:Sl.title,sx:{...r.type.pageTitle,m:0,flex:1,minWidth:0},children:e}),n&&p.jsx(Re,{sx:{my:"-4px"},children:n})]}),t]})}function Q2({sx:e,children:t}){return p.jsx(Z0,{chrome:"none",kind:"text",...e?{sx:e}:{},children:t})}function S_({children:e}){const{theme:t}=Hr(),{stickyRef:n,stuck:r}=P0e();return p.jsx(Re,{ref:n,className:Sl.filterRow,"data-stuck":r||void 0,sx:{position:"sticky",top:`calc(var(${A0e}, 0px) + ${E0e}px)`,zIndex:j0e,bgcolor:r?"background.default":"transparent",pb:1,pt:1,mt:-1,boxShadow:r?`0 1px 0 ${Xd(t.cardBorder)}`:"none",transition:`box-shadow ${Zy}`,...Jy},children:e})}const ko=e=>{const t=new URL(e),n={};if(t.protocol!=="publisher:")throw new Error(`Failed to parse resource URI: ${e}`);const r=(t.hostname+t.pathname).split("/");for(let o=0;o<r.length;o+=2){const a=r[o];a==="environments"?n.environmentName=decodeURI(r[o+1])||void 0:a==="packages"?n.packageName=decodeURI(r[o+1])||void 0:a==="connections"?n.connectionName=decodeURI(r[o+1])||void 0:a==="models"&&(n.modelPath=decodeURI(r.slice(o+1).join("/"))||void 0)}if(n.versionId=t.searchParams.get("versionId")||void 0,!n.environmentName)throw new Error(`Failed to parse resource URI: ${e}`);return n},I1=e=>{if(!e.environmentName)throw new Error(`Failed to encode resource URI, missing environment name: ${e}`);let t=`publisher://environments/${e.environmentName}`;return e.packageName&&(t+=`/packages/${e.packageName}`),e.connectionName&&(t+=`/connections/${e.connectionName}`),e.modelPath&&(t+=`/models/${e.modelPath}`),e.packageName&&e.versionId&&(t+=`?versionId=${encodeURIComponent(e.versionId)}`),t};function X2(e,t){if(e[t])return e;const n=e.default;return n?.[t]?n:e}const I0e=e=>X2(e,"MalloyTranslator"),L0e=e=>X2(e,"parseAnnotation"),z0e=e=>X2(e,"ASTQuery");async function aTe(){return I0e(await vo(()=>import("./index-BiOT4K_d.js").then(e=>e.i),__vite__mapDeps([0,1])))}async function iTe(){return L0e(await vo(()=>Promise.resolve().then(()=>bae),void 0))}async function F0e(){return z0e(await vo(()=>import("./index-DAQjZOAL.js").then(e=>e.i),__vite__mapDeps([2,1])))}async function _0e(e){const t=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return Array.from(new Uint8Array(t),n=>n.toString(16).padStart(2,"0")).join("")}function C_(e){return e.find(t=>t.authoritative)??e.find(t=>t.writeable)}function B0e({authoritative:e,mutable:t,versionId:n,canStore:r,readFailed:o}){const a=e?"host":t?"package":"browser",i=n!==void 0&&a==="package";return{savesTo:a,pinnedPackageSave:i,writer:o?void 0:e?r?"storage":void 0:i?void 0:t?"package":r?"storage":void 0}}async function sTe(e,t){return e??(t===void 0?void 0:await _0e(t))}function lTe({authoritative:e,mutable:t,pinnedPackageSave:n,workspace:r,readFailure:o,versionId:a}){return o!==void 0?`The saved copy could not be read, so Save is off: ${o}`:e&&r?r.writeable?r.description:`${r.description}: you cannot save into it.`:n?`Reading version ${a}: a version is a fixed point in history, so Save is off.`:t?"Save writes the file into the package.":r?`${r.description}: this server does not take writes.`:"This server does not take writes."}function cTe(e){return e instanceof Error?e.message:String(e)}function U0e(e){const t=e.response?.data;return t?.message?t.message:e instanceof Error?e.message:String(e)}async function uTe({apiClients:e,queryClient:t,environmentName:n,packageName:r,modelPath:o,source:a,expectedHash:i,invalidateOnError:s,invalidate:l,afterWrite:d}){let u;try{u=await e.models.updateModelSource(n,r,o,{source:a,expectedHash:i})}catch(g){for(const y of s)t.invalidateQueries({queryKey:y});throw new Error(U0e(g))}const m=u.data.contentHash;await d?.(m);for(const{queryKey:g,refetchType:y,wait:x}of l){const w=t.invalidateQueries({queryKey:g,...y?{refetchType:y}:{}});x&&await w}return m}function dTe(e,t){return t===void 0||!/\.(saved|save_undone)$/.test(e.type)||e.where==="package"?e:{...e,workspace:t}}function fTe(e){if(!("resourceUri"in e))return{environmentName:e.environmentName,packageName:e.packageName,versionId:void 0,namesBoth:!0};let t;try{t=ko(e.resourceUri)}catch{t=void 0}return{environmentName:t?.environmentName??"",packageName:t?.packageName??"",versionId:t?.versionId,namesBoth:!!t?.environmentName&&!!t?.packageName}}class k_ extends Error{constructor(t){super(t),this.name="DocumentNotFoundError"}}const $_=e=>e instanceof k_||e instanceof Error&&e.name==="DocumentNotFoundError",V0e=String.raw`##?\|?[ \t]*(?:[([{<][ \t]*)?(?:(?:(?:row|source)[-_]?)?authorize|access[-_]?filter)(?=[)\]}>]|[ \t]|$)`;function R_(e,t){if(/[\r\n]/.test(t))return`A ${e} is one line; it cannot hold a line break.`;if(new RegExp(V0e,"iu").test(t))return`A ${e} cannot contain what reads as an access-control tag (authorize, row_authorize, source_authorize or access_filter).`}const rg=e=>Wy(e)?e:`\`${e}\``;function Z2(e){const{title:t,modelPath:n,source:r,view:o}=e;if(t.trim()==="")return"A title cannot be empty.";const a=R_("title",t);if(a)return a;if(t.includes("|##"))return"A title cannot contain `|##`, which closes the report's artifact tag.";if(/["\\\r\n]/.test(n)||n.trim()==="")return`The model path ${JSON.stringify(n)} cannot be written as an import.`;for(const[i,s]of[["source",r],["view",o]])if(s.trim()===""||/[`\r\n\\]/.test(s))return`The ${i} name ${JSON.stringify(s)} cannot be written as a Malloy name.`}const q0e=e=>{const t=e.replace(/[-_]+/g," ").trim();return t.charAt(0).toUpperCase()+t.slice(1)},zN=e=>`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`,H0e="report.malloy";function J2(e,t,n=H0e){const r=Z2(e);if(r)throw new Error(r);const{modelPath:o,source:a,view:i}=e,s=e.title.trim(),l=zN(s),d=rg(`${a}_tiles`),u=rg(`${i}_tile`),m=`"${d} -> ${u}"`;return["##! experimental.givens",`##| artifact { layout=${t} title=${l}`," tiles=[",` ${m}`," ]",t==="grid"?"} dashboard { columns=12 }":"}","|##",`import { ${rg(a)} } from "${yF(o,n)}"`,"",`source: ${d} is ${rg(a)} extend {`,` # label=${zN(q0e(i))}`,` view: ${u} is ${rg(i)}`,"}",""].join(`
|
|
472
|
+
`)}}const u0e=C.lazy(()=>vo(()=>import("./RenderedResult-Cm0Wwtek.es-CfBPkvGU.js"),[]).then(e=>e.c));function D1({result:e,maxHeight:t,tableMaxHeight:n,firstPaintHeight:r,maxResultSize:o=0,renderLogs:a,drill:i,fill:s=!1,compactToFit:l=!1}){const d=C.useRef(null);C.useEffect(()=>Y2(),[]);const[u,m]=C.useState(void 0),[g,y]=C.useState(void 0),[x,w]=C.useState(void 0),S=C.useCallback((U,N)=>{m(U),w(N)},[]),[b,$]=C.useState(!1),[k,T]=C.useState(void 0),O=c0e(a);C.useEffect(()=>{const U=d.current;if(!s||!U)return;const N=new ResizeObserver(([q])=>{T(Math.round(q.contentRect.height)),F(Math.round(q.contentRect.width))});return N.observe(U),()=>N.disconnect()},[s,!!e,b]);const[P,D]=C.useState(void 0),[A,F]=C.useState(void 0),L=s&&l&&u==="content";if(C.useEffect(()=>{D(void 0)},[e,A,L]),C.useEffect(()=>{L&&(k===void 0||g===void 0||(P===void 0&&g>k+1?D(g):P!==void 0&&k>=P&&D(void 0)))},[L,k,g,P]),!e)return null;if(o>0&&e.length>o&&!b)return p.jsxs(Re,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2,p:4,backgroundColor:"#fafafa",border:"1px solid",borderColor:"#e0e0e0",borderRadius:1},children:[p.jsx(cae,{sx:{fontSize:48,color:"#757575"}}),p.jsx(wt,{variant:"h6",color:"text.secondary",align:"center",children:"Processing large results may cause browser performance issues. Proceed?"}),p.jsx(Hn,{variant:"contained",color:"primary",onClick:()=>$(!0),children:"Proceed"})]});const _=p.jsx(Go,{text:qd.loading,centered:!0,size:32}),R=Ele({renderAs:x,maxHeight:t,tableMaxHeight:n}),z=$D({sizing:u,contentHeight:g,maxHeight:R,fillHeight:s?k:void 0,firstPaintHeight:r}),I=p.jsx(C.Suspense,{fallback:_,children:p.jsx(u0e,{result:e,height:z,onSizeChange:y,onSizing:S,drill:i,fill:s})});return p.jsxs(Re,{ref:d,sx:{position:"relative",height:"auto",border:"0px",borderRadius:0,overflowX:"hidden",overflowY:s?"hidden":"auto",...s&&{flex:`1 1 ${$D({sizing:u,contentHeight:g,maxHeight:R,firstPaintHeight:r})}px`,minHeight:0}},children:[s?p.jsx(Re,{className:Nle,...L&&P!==void 0?{[Dle]:""}:{},sx:{position:"absolute",inset:0,overflowX:"hidden",overflowY:"auto"},children:I}):I,O&&p.jsx(Re,{sx:{position:"absolute",top:4,right:4,zIndex:1},children:p.jsx(Br,{title:O.title,slotProps:{tooltip:{sx:{whiteSpace:"pre-line"}}},children:p.jsx(Lp,{"aria-label":"Render tag warnings",children:p.jsx(y_,{fontSize:"small",color:O.severity==="error"?"error":"warning"})})})})]})}function G2({state:e,context:t,loadingText:n=qd.running,maxHeight:r,tableMaxHeight:o,firstPaintHeight:a,maxResultSize:i,drill:s,fill:l,compactToFit:d,transform:u}){const{data:m,isSuccess:g,isError:y,error:x,fetchStatus:w,isPlaceholderData:S}=e,b=g||w==="fetching";C.useEffect(()=>{b&&Y2()},[b]);const $=m?.data.result,k=C.useMemo(()=>$!==void 0&&u?u($):$,[$,u]),T=C.useMemo(()=>hle(k),[k]);if(y)return p.jsx(Re,{sx:{p:2},children:p.jsx(Xa,{context:t,error:x})});if(!g)return p.jsx(Go,{text:w==="idle"?qd.loading:n});if(T)return p.jsx(Re,{sx:{p:2},children:p.jsx(wt,{variant:"body2",role:"status",color:"text.secondary",children:T})});const O=p.jsx(D1,{result:k,maxHeight:r,tableMaxHeight:o,...a!==void 0?{firstPaintHeight:a}:{},maxResultSize:i,renderLogs:m.data.renderLogs,drill:s,fill:l,compactToFit:d});return p.jsxs(Re,{"aria-busy":S||void 0,sx:{position:"relative",display:"flex",flexDirection:"column",flex:"1 1 auto",minHeight:0,minWidth:0,...l?{height:"100%"}:{},"& > .result-body":{display:"flex",flexDirection:"column",flex:"1 1 auto",minHeight:0,minWidth:0,...l?{height:"100%"}:{},opacity:S?.55:1,transition:S?"opacity 160ms ease 200ms":"opacity 120ms ease","@media (prefers-reduced-motion: reduce)":{transition:"none"}}},children:[S&&p.jsx(uz,{"aria-label":n,sx:{position:"absolute",top:0,left:0,right:0,height:2,zIndex:1,bgcolor:"transparent",borderRadius:1}}),p.jsx(Re,{className:"result-body",children:O})]})}const Od=()=>typeof performance<"u"?performance.now():Date.now(),d0e=rn(p.jsx("path",{d:"m16.95 6-3.57 4.55 1.43 1.43c1.03-1.31 4.98-6.37 4.98-6.37C20.3 4.95 19.83 4 19 4H6.83l2 2zM2.81 2.81 1.39 4.22 10 13v6c0 .55.45 1 1 1h2c.55 0 1-.45 1-1v-2.17l5.78 5.78 1.41-1.41z"})),f0e=3;function p0e(e,t){if(e===void 0)return[];const n=new Set(e);return t.flatMap(r=>r.name&&!n.has(r.name)?[r.label??r.name]:[])}function h0e(e){return e.length<2?e.join(""):`${e.slice(0,-1).join(", ")} or ${e[e.length-1]}`}function m0e({ignored:e}){const{theme:t}=Hr();if(e.length===0)return null;const n=e.length>f0e?`Doesn't respond to ${e.length} filters`:`Doesn't respond to ${e.join(", ")}`;return p.jsxs(Re,{"data-testid":"tile-filter-tag",title:`This tile's query never reads ${h0e(e)}, so changing ${e.length===1?"it":"them"} won't change this tile`,sx:{display:"inline-flex",alignItems:"center",gap:.5,maxWidth:"100%",mb:1,alignSelf:"flex-start",px:.75,py:.125,border:1,borderColor:"warning.main",borderRadius:1,fontSize:11,lineHeight:1.6,color:"warning.main",fontFamily:t.font.family},children:[p.jsx(d0e,{sx:{fontSize:12}}),p.jsx(Re,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n})]})}const g0e=/\.malloy(nb)?$/,N1=e=>e&&e.slice(e.lastIndexOf("/")+1).replace(g0e,"")||void 0,y0e=e=>e.replace(/\.malloy$/,"").split("/").map(encodeURIComponent).join("/"),v_=(e,t,n)=>`/${encodeURIComponent(e)}/${encodeURIComponent(t)}/${y0e(n)}`,v0e="edit",b0e=(e,t,n)=>`${v_(e,t,n)}?${v0e}`,K2=e=>e.layout==="linear"?"linear":"grid",g$=e=>({layout:K2(e),path:e.path,editable:e.editable!==!1});function x0e(e,t){const n=t.find(r=>r.path===e);return n?.path?g$({...n,path:n.path}):void 0}function w0e(e){return e===""||e.startsWith("/")?!1:e.split("/").every(t=>t!==""&&t!=="."&&t!=="..")}function S0e(e,t){if(!w0e(e))return{kind:"unresolved"};for(const n of[`${e}.malloy`,e]){const r=x0e(n,t);if(r)return{kind:"path",report:r}}return{kind:"unresolved"}}const C0e=(e,t,n)=>["reports",e,t,n];async function k0e(e,t,n,r){try{return(await e.reports.listReports(t,n,r)).data}catch(o){if(o?.response?.status===404)return[];throw o}}function b_(e,t,n,r=!0){const{apiClients:o}=er(),a=wo({queryKey:C0e(e,t,n),queryFn:()=>k0e(o,e,t,n),enabled:r,staleTime:6e4});return{reports:a.data??[],settled:a.isSuccess||a.isError,isFetching:a.isFetching,isError:a.isError,error:a.error,refetch:a.refetch}}const x_=20,$0e={radius:"8px",padding:`${x_}px`};function oTe(e,t=$0e){return{"--malloy-render--font-family":e.font.family,"--malloy-render--table-font-size":`${e.font.size}px`,"--malloy-render--table-header-color":e.tableHeader,"--malloy-render--table-body-color":e.tableBody,"--malloy-render--table-border":e.border,"--malloy-render--table-pinned-border":e.pinnedBorder,"--malloy-render--tile-background":e.tile,"--publisher-dashboard-root":e.dashboardRoot,"--malloy-render--label-color":e.tileTitle,"--malloy-render--value-color":e.valueColor,"--publisher-drill-link":e.drillLink,"--publisher-dashboard-card-radius":t.radius,"--publisher-dashboard-card-padding":t.padding,"--publisher-dashboard-card-border":e.cardBorder}}const R0e={query:120,text:72};function Z0({borderless:e=!1,chrome:t="card",kind:n="query",sx:r,cardRef:o,children:a}){const{theme:i}=Hr(),s=i.ui,l=e||t==="none";return p.jsx(Ga,{ref:o,className:Sl.tile,elevation:0,"data-chrome":t,"data-tile-kind":n,sx:[{border:l?"none":i.cardBorder,borderRadius:l?0:s.radius.tile,background:l?"none":i.tile,overflow:"hidden",isolation:"isolate",display:"flex",flexDirection:"column",minWidth:0,minHeight:t==="none"?0:R0e[n],p:t==="none"?0:e?"12px 0":`${x_}px`},...Array.isArray(r)?r:[r]],children:a})}const T0e=Sl.tileHeading;function w_({title:e,subtitle:t,tooltip:n,action:r,quiet:o=!1}){const{theme:a}=Hr(),i=a.ui;return p.jsxs(Re,{className:T0e,sx:{pb:o?.5:1.5,display:"flex",alignItems:"flex-start",gap:1},children:[p.jsxs(Re,{sx:{minWidth:0,flex:1},children:[p.jsx(wt,{component:"div",sx:{...i.type.tileTitle,display:"block",color:a.tileTitle,fontFamily:a.font.family},title:n,children:e}),t!==void 0&&p.jsx(wt,{component:"div",sx:{...i.type.caption,display:"block",mt:"2px",color:a.tileTitle,fontFamily:a.font.family,opacity:.75},children:t})]}),r]})}const E0e=-1;function M0e(e){const t=e.ownerDocument;for(let n=e.parentElement;n&&n!==t.body&&n!==t.documentElement;n=n.parentElement)if(/(auto|scroll|overlay)/.test(getComputedStyle(n).overflowY))return n}function O0e(e,t){if((t?t.scrollTop:window.scrollY)<=0)return!1;const n=parseFloat(getComputedStyle(e).top);if(Number.isNaN(n))return!1;const r=t?t.getBoundingClientRect().top+t.clientTop:0;return e.getBoundingClientRect().top-r<=n+.5}function P0e(){const[e,t]=C.useState(!1),n=C.useRef(null);return{stickyRef:C.useCallback(r=>{if(n.current?.(),n.current=null,!r||typeof window>"u")return;const o=M0e(r),a=o??window;let i=0;const s=()=>{i=0,t(O0e(r,o))},l=()=>{i===0&&(i=requestAnimationFrame(s))};a.addEventListener("scroll",l,{passive:!0}),window.addEventListener("resize",l),s(),n.current=()=>{a.removeEventListener("scroll",l),window.removeEventListener("resize",l),i!==0&&cancelAnimationFrame(i)}},[]),stuck:e}}const j0e=4,A0e="--publisher-sticky-top",D0e=2;function y$({layout:e,notice:t,header:n,controls:r,children:o,sx:a}){return p.jsxs(Wn,{className:Sl.report,"data-layout":e,sx:[{gap:D0e},...Array.isArray(a)?a:[a]],children:[t,n,r,o]})}function N0e({title:e,description:t,actions:n}){const r=Hr().theme.ui;return p.jsxs(Wn,{className:Sl.header,sx:{gap:1.5},children:[p.jsxs(Wn,{direction:"row",sx:{alignItems:"center",gap:2},children:[p.jsx(wt,{component:"h1",className:Sl.title,sx:{...r.type.pageTitle,m:0,flex:1,minWidth:0},children:e}),n&&p.jsx(Re,{sx:{my:"-4px"},children:n})]}),t]})}function Q2({sx:e,children:t}){return p.jsx(Z0,{chrome:"none",kind:"text",...e?{sx:e}:{},children:t})}function S_({children:e}){const{theme:t}=Hr(),{stickyRef:n,stuck:r}=P0e();return p.jsx(Re,{ref:n,className:Sl.filterRow,"data-stuck":r||void 0,sx:{position:"sticky",top:`calc(var(${A0e}, 0px) + ${E0e}px)`,zIndex:j0e,bgcolor:r?"background.default":"transparent",pb:1,pt:1,mt:-1,boxShadow:r?`0 1px 0 ${Xd(t.cardBorder)}`:"none",transition:`box-shadow ${Zy}`,...Jy},children:e})}const ko=e=>{const t=new URL(e),n={};if(t.protocol!=="publisher:")throw new Error(`Failed to parse resource URI: ${e}`);const r=(t.hostname+t.pathname).split("/");for(let o=0;o<r.length;o+=2){const a=r[o];a==="environments"?n.environmentName=decodeURI(r[o+1])||void 0:a==="packages"?n.packageName=decodeURI(r[o+1])||void 0:a==="connections"?n.connectionName=decodeURI(r[o+1])||void 0:a==="models"&&(n.modelPath=decodeURI(r.slice(o+1).join("/"))||void 0)}if(n.versionId=t.searchParams.get("versionId")||void 0,!n.environmentName)throw new Error(`Failed to parse resource URI: ${e}`);return n},I1=e=>{if(!e.environmentName)throw new Error(`Failed to encode resource URI, missing environment name: ${e}`);let t=`publisher://environments/${e.environmentName}`;return e.packageName&&(t+=`/packages/${e.packageName}`),e.connectionName&&(t+=`/connections/${e.connectionName}`),e.modelPath&&(t+=`/models/${e.modelPath}`),e.packageName&&e.versionId&&(t+=`?versionId=${encodeURIComponent(e.versionId)}`),t};function X2(e,t){if(e[t])return e;const n=e.default;return n?.[t]?n:e}const I0e=e=>X2(e,"MalloyTranslator"),L0e=e=>X2(e,"parseAnnotation"),z0e=e=>X2(e,"ASTQuery");async function aTe(){return I0e(await vo(()=>import("./index-w1w5RvZI.js").then(e=>e.i),__vite__mapDeps([0,1])))}async function iTe(){return L0e(await vo(()=>Promise.resolve().then(()=>bae),void 0))}async function F0e(){return z0e(await vo(()=>import("./index-DrkXqbpl.js").then(e=>e.i),__vite__mapDeps([2,1])))}async function _0e(e){const t=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return Array.from(new Uint8Array(t),n=>n.toString(16).padStart(2,"0")).join("")}function C_(e){return e.find(t=>t.authoritative)??e.find(t=>t.writeable)}function B0e({authoritative:e,mutable:t,versionId:n,canStore:r,readFailed:o}){const a=e?"host":t?"package":"browser",i=n!==void 0&&a==="package";return{savesTo:a,pinnedPackageSave:i,writer:o?void 0:e?r?"storage":void 0:i?void 0:t?"package":r?"storage":void 0}}async function sTe(e,t){return e??(t===void 0?void 0:await _0e(t))}function lTe({authoritative:e,mutable:t,pinnedPackageSave:n,workspace:r,readFailure:o,versionId:a}){return o!==void 0?`The saved copy could not be read, so Save is off: ${o}`:e&&r?r.writeable?r.description:`${r.description}: you cannot save into it.`:n?`Reading version ${a}: a version is a fixed point in history, so Save is off.`:t?"Save writes the file into the package.":r?`${r.description}: this server does not take writes.`:"This server does not take writes."}function cTe(e){return e instanceof Error?e.message:String(e)}function U0e(e){const t=e.response?.data;return t?.message?t.message:e instanceof Error?e.message:String(e)}async function uTe({apiClients:e,queryClient:t,environmentName:n,packageName:r,modelPath:o,source:a,expectedHash:i,invalidateOnError:s,invalidate:l,afterWrite:d}){let u;try{u=await e.models.updateModelSource(n,r,o,{source:a,expectedHash:i})}catch(g){for(const y of s)t.invalidateQueries({queryKey:y});throw new Error(U0e(g))}const m=u.data.contentHash;await d?.(m);for(const{queryKey:g,refetchType:y,wait:x}of l){const w=t.invalidateQueries({queryKey:g,...y?{refetchType:y}:{}});x&&await w}return m}function dTe(e,t){return t===void 0||!/\.(saved|save_undone)$/.test(e.type)||e.where==="package"?e:{...e,workspace:t}}function fTe(e){if(!("resourceUri"in e))return{environmentName:e.environmentName,packageName:e.packageName,versionId:void 0,namesBoth:!0};let t;try{t=ko(e.resourceUri)}catch{t=void 0}return{environmentName:t?.environmentName??"",packageName:t?.packageName??"",versionId:t?.versionId,namesBoth:!!t?.environmentName&&!!t?.packageName}}class k_ extends Error{constructor(t){super(t),this.name="DocumentNotFoundError"}}const $_=e=>e instanceof k_||e instanceof Error&&e.name==="DocumentNotFoundError",V0e=String.raw`##?\|?[ \t]*(?:[([{<][ \t]*)?(?:(?:(?:row|source)[-_]?)?authorize|access[-_]?filter)(?=[)\]}>]|[ \t]|$)`;function R_(e,t){if(/[\r\n]/.test(t))return`A ${e} is one line; it cannot hold a line break.`;if(new RegExp(V0e,"iu").test(t))return`A ${e} cannot contain what reads as an access-control tag (authorize, row_authorize, source_authorize or access_filter).`}const rg=e=>Wy(e)?e:`\`${e}\``;function Z2(e){const{title:t,modelPath:n,source:r,view:o}=e;if(t.trim()==="")return"A title cannot be empty.";const a=R_("title",t);if(a)return a;if(t.includes("|##"))return"A title cannot contain `|##`, which closes the report's artifact tag.";if(/["\\\r\n]/.test(n)||n.trim()==="")return`The model path ${JSON.stringify(n)} cannot be written as an import.`;for(const[i,s]of[["source",r],["view",o]])if(s.trim()===""||/[`\r\n\\]/.test(s))return`The ${i} name ${JSON.stringify(s)} cannot be written as a Malloy name.`}const q0e=e=>{const t=e.replace(/[-_]+/g," ").trim();return t.charAt(0).toUpperCase()+t.slice(1)},zN=e=>`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`,H0e="report.malloy";function J2(e,t,n=H0e){const r=Z2(e);if(r)throw new Error(r);const{modelPath:o,source:a,view:i}=e,s=e.title.trim(),l=zN(s),d=rg(`${a}_tiles`),u=rg(`${i}_tile`),m=`"${d} -> ${u}"`;return["##! experimental.givens",`##| artifact { layout=${t} title=${l}`," tiles=[",` ${m}`," ]",t==="grid"?"} dashboard { columns=12 }":"}","|##",`import { ${rg(a)} } from "${yF(o,n)}"`,"",`source: ${d} is ${rg(a)} extend {`,` # label=${zN(q0e(i))}`,` view: ${u} is ${rg(i)}`,"}",""].join(`
|
|
473
473
|
`)}function pTe(e,t){return J2(e,"linear",t)}function W0e(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,80)}function Y0e({title:e,modelPath:t,source:n,view:r}){for(const[o,a]of[["source",n],["view",r]])if(!Wy(a))return`The ${o} name ${JSON.stringify(a)} cannot be written as a Malloy name.`;return/["\\\r\n]/.test(t)?`The model path ${JSON.stringify(t)} cannot be written into an import.`:R_("title",e)}function hTe(e,t){const n=Y0e(e);if(n)throw new Error(n);return J2(e,"grid",t)}const T_=e=>(e??"").trim().replace(/\\/g,"/").split("/").filter(t=>t!=="").join("/");function G0e(e,t){const n=T_(t);return`${n===""?"":`${n}/`}${e}.malloy`}function K0e(e){return W0e(e)||"untitled"}function E_(e,t=1,n){const r=K0e(e);return G0e(t>1?`${r}-${t}`:r,n)}const wy=(e,t,n)=>`${e}/${t}/${n}`,Q0e=(e,t,n,r,o)=>({workspace:t,type:e,path:wy(n,r,o)}),eT=20;function X0e(e){const{savesTo:t,writer:n}=B0e({...e,readFailed:!1});return t==="browser"?void 0:n}const FN=e=>e.slice(e.lastIndexOf("/")+1).replace(/\.malloy$/,"");function M_(e){if(!e.endsWith(".malloy"))return"A report's file name ends in .malloy.";const t=e.split("/");if(t.some(n=>n===""||n==="."||n===".."))return"A location is a path inside the package, such as sales/q3.malloy.";if(t.at(-1)===".malloy")return"A report's file needs a name.";if(t[0].toLowerCase()==="public")return"A report cannot live under public/, which is served as plain files.";if(e.toLowerCase()==="index.malloy")return"The package's index.malloy is its surface, never a report."}async function Z0e(e){const t=e.layout??"linear",n=Od();let r;try{r=await J0e(e,t)}catch(o){throw Yk({path:e.path??"",layout:t},e.onEvent).emit({type:"report.create_refused",reason:o instanceof Error?o.message:String(o)}),o}return Yk({path:r.path,layout:t},e.onEvent).emit({type:"report.created",where:e.target.route==="package"?"package":"host",durationMs:Od()-n}),e.onCreated?.(r),r}async function J0e(e,t){const{document:n,target:r}=e,o=Z2(n);if(o)throw new Error(o);const a=T_(e.directory),i=e.path!==void 0?[e.path]:Array.from({length:eT},(w,S)=>E_(n.title,S+1,a));for(const w of i){const S=M_(w);if(S)throw new Error(S)}const s=w=>J2(n,t,w);if(r.route==="package"){const w=new Set(r.existing);let S;for(const b of i)if(!w.has(b))try{await r.write(b,s(b)),S=b;break}catch($){if(!txe($))throw $}if(S===void 0)throw _N(n.title,e.path);return{layout:t,path:S,slug:FN(S)}}const{storage:l,workspace:d,environmentName:u,packageName:m}=r,g=new Set(r.existing),y=new Set((await l.listDocuments(d)).map(w=>w.path));let x;for(const w of i){const S=Q0e(t,d.name,u,m,w),b=await l.resolveDocumentPath?.(S)??w;if(y.has(S.path)||g.has(w)||g.has(b))continue;let $=!0;try{await l.getDocument(S)}catch(k){if(!$_(k))throw k;$=!1}if(!$){x={layout:t,path:b,slug:FN(b),locator:S};break}}if(x===void 0)throw _N(n.title,e.path);return await l.saveDocument(x.locator,s(x.path)),x}const exe=/^`[^`]+` already exists in the package\b/;function txe(e){const t=e?.response;if(t?.status!==409)return!1;const n=t.data?.reason;if(n==="FILE_EXISTS")return!0;if(n!=null)return!1;const r=t.data?.message;return typeof r=="string"&&exe.test(r)}const _N=(e,t)=>new Error(t!==void 0?`${t} already exists. Fix: choose a different location.`:`No free file name for "${e}" after ${eT} tries. Fix: choose a different title.`);function nxe(e){try{const t=JSON.parse(e??"");return new Set((t.entries??[]).flatMap(n=>n.kind==="source"&&typeof n.name=="string"?[n.name]:[]))}catch{return new Set}}function BN(e){for(const t of e??[]){const n=/^#\(doc\)\s*(.*)$/s.exec(t.trim());if(n)return n[1].trim()}}function rxe(e){for(const t of e??[]){const n=/^#\s*(?:-[A-Za-z_]+\s+)*([a-z_]+)/.exec(t.trim())?.[1];if(n&&sF.includes(n))return n}}function oxe({environmentName:e,packageName:t,versionId:n,models:r,enabled:o}){const{apiClients:a,server:i}=er(),s=Lz({queries:r.map(x=>({queryKey:["new-document-model",e,t,n,x,i],queryFn:async()=>(await a.models.getModel(e,t,x,n)).data,enabled:o,retry:!1,staleTime:300*1e3,refetchOnWindowFocus:!1}))}),l=s.map(x=>x.dataUpdatedAt).join(),d=C.useMemo(()=>{const x=new Map;return s.forEach((w,S)=>{const b=[],$=nxe(w.data?.modelInfo);for(const k of w.data?.sources??[]){if(typeof k.name!="string"||!$.has(k.name))continue;const T=BN(k.annotations);for(const O of k.views??[])if(typeof O.name=="string"){const P=BN(O.annotations),D=rxe(O.annotations);b.push({source:k.name,view:O.name,...P?{description:P}:{},...D?{chart:D}:{},...T?{sourceDescription:T}:{}})}}b.length>0&&x.set(r[S],b)}),x},[l,r]),u=s.some(x=>x.isLoading),m=u?[]:r.filter((x,w)=>s[w]?.isError),g=!u&&s.some(x=>x.isError&&D4(x.error)),y=()=>{s.forEach(x=>{x.isError&&x.refetch()})};return{choices:d,isLoading:u,isSuccess:s.length>0&&s.every(x=>!x.isPending),failed:m,retry:y,canRetry:g}}const O_=C.createContext(void 0);function axe({children:e,documentStorage:t}){const n=C.useMemo(()=>({documentStorage:t}),[t]);return p.jsx(O_.Provider,{value:n,children:e})}function P_(){return C.useContext(O_)}function ixe(e,{environmentName:t,packageName:n,path:r,versionId:o},a){return{queryKey:["report",t,n,o,r],queryFn:async({signal:i})=>(await e.reports.getReport(t,n,r,o,{signal:i})).data,...a===void 0?{}:{staleTime:a}}}const mTe=1e4,j_=e=>e==="notebook"?"linear":"grid",gTe=(e,t)=>`${e}s/${t}.malloy`;function sxe(e){for(const t of[["report"],["reports"]])e.invalidateQueries({queryKey:t})}function wo(e){const{server:t}=er(),n={...e,queryKey:[...e.queryKey,t],queryFn:async r=>{try{return await e.queryFn(r)}catch(o){if(o&&typeof o=="object"&&"response"in o){const a=o;if(a.response?.data){const i=new Error(a.response.data.message||a.message);throw i.status=a.response.status,i.data=a.response.data,i}}throw o}},retry:!1,throwOnError:!1};return Ld(n,dy)}function hl(e){const t={...e,mutationFn:async n=>{try{return await e.mutationFn(n)}catch(r){if(r&&typeof r=="object"&&"response"in r){const o=r;if(o.response?.data){const a=new Error(o.response.data.message||o.message);throw a.status=o.response.status,a.data=o.response.data,a}}throw r}},retry:!1,throwOnError:!1};return a0(t,dy)}function A_(e){return["queryResult",e.environmentName,e.packageName,e.versionId,e.modelPath,e.queryName,e.query,e.sourceName,JSON.stringify(e.givens??{})]}function yTe(e){return["queryResult",e.environmentName,e.packageName,e.versionId,e.modelPath]}function D_(e,t,n){return e.models.executeQueryModel(t.environmentName,t.packageName,t.modelPath,{queryName:t.queryName,query:t.query,sourceName:t.sourceName,givens:t.givens,versionId:t.versionId},void 0,void 0,{signal:n})}function tT(e,{enabled:t=!0}={}){const{apiClients:n}=er(),r=A_(e);return wo({queryKey:r,queryFn:({signal:o})=>D_(n,e,o),enabled:t,placeholderData:(o,a)=>a&&cxe(a.queryKey,r)?o:void 0,...S4})}const lxe=8;function cxe(e,t){return e.every((n,r)=>r===lxe||r>=t.length||n===t[r])}const uxe=/<\/?[A-Za-z][^>]*>|<!--|<![A-Za-z]/;function N_(e){let t=!1;for(const[n,r]of Array.from(e.entries())){if(r.deleted)continue;if(n==="image"||n==="link"){e.delete(n),t=!0;continue}if(n==="label"){let a;try{a=e.text("label")}catch{a=void 0}if(a!==void 0&&uxe.test(a)){e.delete("label"),t=!0;continue}}const o=Array.isArray(r.eq)?r.eq:[];for(const a of[r,...o])N_(a)&&(t=!0)}return t}function dxe(e){const t=e.trim();if(!/^#(?:\||[ \t\r\n]|$)/.test(t))return e;if(t.includes("@env."))return"";let n;try{n=t1.parseAnnotation(t)}catch{return""}return n.log.length>0?"":N_(n.tag)?`${n.tag.toString()}
|
|
474
474
|
`:e}function v$(e){if(Array.isArray(e)){for(const n of e)v$(n);return}if(e===null||typeof e!="object")return;const t=e;for(const[n,r]of Object.entries(t))if(n==="annotations"&&Array.isArray(r))for(const o of r){const a=o;typeof a?.value=="string"&&(a.value=dxe(a.value))}else v$(r)}function I_(e){let t;try{t=JSON.parse(e)}catch{return e}const n=JSON.stringify(t);v$(t);const r=JSON.stringify(t);return r===n?e:r}const fxe=new Set(["bar_chart","line_chart","scatter_chart","combo_chart","shape_map","segment_map","point_map","big_value","sparkline","list","list_detail","dashboard","transpose","table","json","image","link","text"]),pxe={value:`# big_value
|
|
475
475
|
`};function hxe(e){const t=e.schema?.fields;if(!Array.isArray(t)||t.length===0||!t.every(r=>Wk(r)))return!1;const n=e.data;return n?n.kind==="record_cell"?!0:n.kind==="array_cell"&&Array.isArray(n.array_value)&&n.array_value.length===1:!1}function mxe(e){for(const t of e){const n=t.trim();if(!n.startsWith("#")||n.startsWith("#(")||n.startsWith('#"'))continue;const r=h1(n.slice(1));for(const o of r.split(/[\s{}=.,[\]]+/))if(fxe.has(o))return!0}return!1}function L_(e){let t;try{t=JSON.parse(e)}catch{return e}if(!t||typeof t!="object"||!hxe(t))return e;const n=Array.isArray(t.annotations)?t.annotations:[],r=n.map(o=>o?.value).filter(o=>typeof o=="string");return mxe(r)?e:JSON.stringify({...t,annotations:[pxe,...n]})}const gxe=e=>I_(L_(e));function UN(e){const t=e.split("->").at(-1)?.trim()??e;return/^[A-Za-z_][\w-]*$/.test(t)?OF(t):e}function z_({environmentName:e,packageName:t,versionId:n,modelPath:r,queryName:o,tile:a,annotation:i,label:s,subtitle:l,heading:d,borderless:u,givens:m,hostGivens:g,declaredTypes:y,givenNames:x,height:w,tableMaxHeight:S,fixedHeight:b,maxResultSize:$,drill:k,onExplore:T,chrome:O="card",ignoredFilters:P,preamble:D,restricted:A,waitingFor:F,index:L}){const{theme:_}=Hr(),[R,z]=Ule(),I=tT({environmentName:e,packageName:t,modelPath:r,versionId:n,queryName:o,query:a!==void 0?b1(D??"",`${i?`${i}
|
|
@@ -490,7 +490,7 @@ ${t}`}function Cce(e){return e?.status===403}function Xp(e){return`\`${e.replace
|
|
|
490
490
|
`)){const i=r===0?/^source\s*:\s*`?([A-Za-z_]\w*)`?\s+is\b/.exec(a):null;i?(o(),n={name:i[1],lines:[a]}):r===0&&OSe.test(a)?o():n&&n.lines.push(a);for(const s of a)s==="{"?r+=1:s==="}"&&(r=Math.max(0,r-1))}return o(),t}function jSe(e,t,n){const r=[];let o=!1;const a=l=>{l===null||l===t||(l!==void 0&&n.has(l)?r.push(l):o=!0)},i=new RegExp(`source\\s*:\\s*\`?${nf(t)}\`?\\s+is\\s+`).exec(e);i&&a(E$(e.slice(i.index+i[0].length)));const s=/join_\w+\s*:\s*`?([A-Za-z_]\w*)`?(\s+is\s+)?/g;for(let l=s.exec(e);l;l=s.exec(e))a(l[2]?E$(e.slice(l.index+l[0].length)):l[1]);return{sources:r,unresolved:o}}function E$(e){const t=/^`?([A-Za-z_]\w*)`?/.exec(e);if(!t)return;const n=e.slice(t[0].length).trimStart();if(n.startsWith("."))return null;if(!n.startsWith("("))return t[1]}const Ry={"&:focus-visible":{outline:"2px solid",outlineColor:"primary.main",outlineOffset:"-2px"}},C6=C.createContext(void 0);function fT({layer:e,title:t,children:n,testId:r}){const o=C.useContext(C6);if(!o||!e||!o.layers.includes(e))return p.jsx(Br,{title:t,children:p.jsx(Re,{component:"span",tabIndex:0,role:"img","aria-label":t,"data-testid":r,sx:{display:"inline-flex",borderRadius:1,...Ry},children:n})});const a=o.openLayer===e;return p.jsx(Br,{title:t,children:p.jsx(Re,{component:"button",type:"button",onClick:()=>o.toggle(e),"aria-expanded":a,"aria-controls":o.cardId,"aria-label":`${t} ${a?"Hide":"Show"} details.`,"data-testid":r,"data-header-chip":e,sx:{appearance:"none",border:"none",background:"none",font:"inherit",p:0,cursor:"pointer",display:"inline-flex",alignItems:"center",borderRadius:1,"& [data-pill-tone]":{transition:"filter 120ms ease",...a?{filter:"brightness(0.9)"}:{}},"&:hover [data-pill-tone]":{filter:a?"brightness(0.9)":"brightness(0.94)"},...Ry},children:n})})}function ASe(e){try{const{data:t}=JSON.parse(e);return t?.kind==="array_cell"?t.array_value.length:t?.kind==="record_cell"?1:0}catch{return}}const DSe={authorize:[],accessFilter:[]};function II(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim()!==""):[]}function NSe(e){const t=new Map,n=e?.sources;if(!Array.isArray(n))return t;for(const r of n){if(!r||typeof r!="object")continue;const o=r;if(typeof o.name!="string"||!o.name)continue;const a=II(o.authorize),i=II(o.accessFilter);a.length===0&&i.length===0||t.set(o.name,{authorize:a,accessFilter:i})}return t}function b0(e,t){return t&&e?.get(t)||DSe}function mc(e){return!!e&&e.authorize.some(t=>t.trim()!=="true")}function Eu(e){return!!e&&e.accessFilter.length>0}const LI=/^\(?\s*(?:'([^']*)'|"([^"]*)")\s+in\s+\$GROUPS\s*\)?$/;function ISe(e){const t=e.trim();if(t==="false")return"no one";const n=LI.exec(t);if(n)return`members of ${n[1]??n[2]}`;for(const r of["or","and"]){const o=t.split(new RegExp(`\\s+${r}\\s+`));if(o.length<2)continue;const a=o.map(i=>LI.exec(i.trim()));if(a.every(i=>i)){const i=a.map(s=>s[1]??s[2]);return r==="or"?`members of ${i.slice(0,-1).join(", ")} or ${i[i.length-1]}`:`members of all of ${i.join(", ")}`}}}function k6(e){const t=e.authorize.filter(n=>n.trim()!=="true").map(n=>ISe(n)??"readers its access rule admits");return Array.from(new Set(t)).join(", and ")}const $6="Only some readers can query this source",R6="Each reader sees only the rows they're allowed to see";function LSe(e,t){return e?mc(t)?`You can't access ${e}. It is restricted to ${k6(t)}; ask an administrator of this package for access.`:`You can't access ${e}. Ask an administrator of this package for access.`:"You don't have access to run this. Ask an administrator of this package for access."}function zSe(e,t){if(!(!Eu(e)||t===void 0))return ASe(t)===0?"Filtered to your rows: this source shows each reader only the rows they're allowed to see.":void 0}function T6(e){return mc(e)||Eu(e)}function FSe(e,t){return`This join doesn't apply the ${mc(t)&&Eu(t)?"access rule and row filter":mc(t)?"access rule":"row filter"} on ${e}: its rows are read under this source's rules.`}function _Se({access:e}){return p.jsxs(p.Fragment,{children:[mc(e)&&p.jsx(zI,{label:"Restricted",meaning:$6}),Eu(e)&&p.jsx(zI,{label:"Row filtered",meaning:R6})]})}function zI({label:e,meaning:t}){return p.jsx(fT,{layer:"access",title:`${e}: ${t}`,testId:`source-access-chip-${e==="Restricted"?"restricted":"row-filtered"}`,children:p.jsx(cs,{tone:"neutral",size:"header",children:e})})}function E6({access:e}){return p.jsxs(p.Fragment,{children:[mc(e)&&p.jsx(Br,{title:`Restricted: ${$6}`,children:p.jsx(cs,{voice:"token",tone:"neutral",sx:{alignSelf:"center"},children:"Restricted"})}),Eu(e)&&p.jsx(Br,{title:`Row filtered: ${R6}`,children:p.jsx(cs,{voice:"token",tone:"neutral",sx:{alignSelf:"center"},children:"Row filtered"})})]})}function BSe(e){return[mc(e)&&"restricted",Eu(e)&&"row filtered"].filter(Boolean).map(t=>`, ${t}`).join("")}function USe({access:e,showRules:t}){const n=mc(e),r=Eu(e);return!n&&!r?null:p.jsxs(Re,{"data-testid":"source-access-facts",sx:{display:"grid",gridTemplateColumns:"max-content 1fr",columnGap:"16px",rowGap:"6px",alignItems:"baseline"},children:[n&&p.jsx(oc,{label:"Restricted to",value:k6(e)}),n&&t&&e.authorize.filter(o=>o.trim()!=="true").map((o,a)=>p.jsx(oc,{label:"Access rule",value:o,mono:!0},`a${a}`)),r&&p.jsx(oc,{label:"Rows",value:"Rows are filtered for each reader"}),r&&t&&e.accessFilter.map((o,a)=>p.jsx(oc,{label:"Row filter",value:o,mono:!0},`f${a}`))]})}const FI="Private",VSe="index.malloy doesn't export this file, so only people who can edit the package see it.";function _I(){return p.jsx(fT,{title:`${FI}: ${VSe}`,testId:"model-viewer-off-surface",children:p.jsx(cs,{tone:"warning",size:"header",children:FI})})}const BI="Public",qSe="index.malloy exports this source, so everyone who can read the package can query it.";function HSe(){return p.jsx(fT,{title:`${BI}: ${qSe}`,testId:"model-viewer-public-surface",children:p.jsx(cs,{tone:"positive",size:"header",children:BI})})}function WSe(e){const t=C.useRef(e);return e!==void 0&&(t.current=e),t.current}function MC({title:e,titleAdornments:t,kindLabel:n,meta:r,doc:o,provenance:a,actions:i,status:s,headingLevel:l="h1",modelDoc:d,access:u,showRules:m=!1,isSource:g=!0,offSurface:y,publicSurface:x=!1}){const w=mc(u)||Eu(u),S=w?["access"]:[],[b,$]=C.useState(void 0),k=b!==void 0&&S.includes(b)?b:void 0,T=WSe(k),O=C.useId(),P={openLayer:k,layers:S,toggle:L=>$(_=>_===L?void 0:L),cardId:O},D=w||y||x||!!s,A=Hr().theme.ui.type.pageTitle,F=typeof A.fontSize=="number"?`${A.fontSize}px`:A.fontSize;return p.jsxs(Re,{children:[p.jsxs(Re,{"data-testid":"model-viewer-source-heading",sx:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:1.5,pt:T$,pb:.5},children:[p.jsx(Re,{component:l,sx:{m:0,fontSize:l==="h1"?F:`calc(${F} * 0.8)`,fontWeight:A.fontWeight??600,lineHeight:1.25,color:"text.primary",fontFamily:ts,minWidth:0,overflowWrap:"anywhere"},children:e}),t,i&&p.jsx(Re,{sx:{ml:"auto",display:"flex",alignItems:"center",gap:1},children:i})]}),!g&&y&&p.jsx(Re,{sx:{display:"flex",alignItems:"center",pt:.5,pb:1},children:p.jsx(_I,{})}),g&&D&&p.jsx(C6.Provider,{value:P,children:p.jsxs(Re,{"data-testid":"model-viewer-status-row",sx:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:1.5,pt:.5,pb:1},children:[p.jsx(_Se,{access:u}),y&&p.jsx(_I,{}),x&&p.jsx(HSe,{}),s]})}),d&&p.jsx(UI,{doc:d,label:"model description",testId:"model-viewer-model-doc"},`model:${d}`),o&&p.jsx(UI,{doc:o},o),(n!==void 0||r!==void 0||a)&&p.jsxs(Re,{"data-testid":"model-viewer-source-meta",sx:{display:"flex",alignItems:"center",gap:.75,minWidth:0,pb:2,fontSize:Ka.body,color:"text.secondary",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[n!==void 0&&p.jsx(Re,{component:"span","data-testid":"model-viewer-source-kind",children:n}),n!==void 0&&(r!==void 0||a)&&p.jsx(Re,{component:"span","aria-hidden":!0,children:"·"}),r!==void 0&&p.jsx(Re,{component:"span",children:r}),r!==void 0&&a&&p.jsx(Re,{component:"span","aria-hidden":!0,children:"·"}),a&&p.jsx(Re,{component:"span",sx:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis"},children:a})]}),p.jsx(Bp,{in:k!==void 0,timeout:"auto",unmountOnExit:!0,children:p.jsx(Re,{id:O,"data-testid":"model-viewer-source-detail","data-layer":T??void 0,sx:{...kh,p:$y,mb:2},children:T==="access"&&u&&p.jsx(USe,{access:u,showRules:m})})})]})}const YSe=2;function UI({doc:e,label:t="description",testId:n="model-viewer-source-doc"}){const[r,o]=C.useState(!1),[a,i]=C.useState(!1),s=C.useRef(null);return C.useEffect(()=>{const l=s.current;if(!l||r)return;const d=()=>i(l.scrollHeight>l.clientHeight+1);if(d(),typeof ResizeObserver>"u")return;const u=new ResizeObserver(d);return u.observe(l),()=>u.disconnect()},[r,e]),p.jsxs(Re,{"data-testid":n,sx:{pb:.5},children:[p.jsx(Re,{ref:s,sx:{fontSize:Ka.body,lineHeight:1.5,color:"text.secondary",whiteSpace:"pre-line",...r?{}:{display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:YSe,overflow:"hidden"}},children:M6(e)}),(a||r)&&p.jsx(Re,{component:"button",type:"button",onClick:()=>o(!r),"aria-expanded":r,"aria-label":r?`Show less of the ${t}`:`Show the full ${t}`,sx:{all:"unset",cursor:"pointer",fontSize:Ka.small,color:"text.secondary",textDecoration:"underline","&:hover":{color:"text.primary"},"&:focus-visible":{outline:"2px solid",outlineColor:"primary.main",outlineOffset:2}},children:r?"Less":"More"})]})}function M6(e){return e.split(/(`[^`\n]+`)/g).map((t,n)=>/^`[^`]+`$/.test(t)?p.jsx(Re,{component:"code",sx:{fontFamily:ts,fontSize:"0.92em",color:"text.primary"},children:t.slice(1,-1)},n):t)}function U1(e){const t=e?.response?.status;return typeof t=="number"?t:void 0}function GSe(e){const t=U1(e);return t===403||t===404}function KSe(e,t){if(!e?.modelPath||!e.sourceName)return{kind:"unknown"};const n=t.get(e.modelPath);return n?n.has(e.sourceName)?{kind:"link"}:{kind:"join-only"}:{kind:"unknown"}}const pT=C.createContext([]),rx="text.primary",hg=e=>({main:e,tint:`color-mix(in srgb, ${e} 12%, transparent)`,onTint:e}),Rp={steel:hg(pr.cyan),sage:hg(pr.lime),brown:hg(pr.slate),olive:hg(pr.violet),amber:hg(pr.amber)};function VI(e){return e==="measure"?Rp.sage:e==="calculate"?Rp.amber:e==="view"?Rp.olive:Rp.steel}const qI=["steel","brown","olive","sage"];function QSe(e){return qI[e%qI.length]}const O6={small:13,caption:12},XSe={fontFamily:ts,fontSize:O6.small,fontWeight:500,color:rx},P6={fontSize:O6.caption,color:"text.secondary"};function ih({label:e,count:t,level:n="h2",testId:r,action:o,children:a}){return t===0?null:n==="h3"?p.jsxs(Re,{component:"section","aria-label":e,"data-testid":r,sx:{mb:2},children:[p.jsx(Re,{component:"h3",sx:{m:0,mb:1,fontSize:Ka.bodyLarge,fontWeight:R$.strong,color:rx},children:e}),a]}):p.jsxs(Re,{component:"section","aria-label":e,"data-testid":r,sx:{mb:3},children:[p.jsxs(Re,{sx:{mb:2},children:[p.jsx(Re,{component:"h2",sx:{m:0,fontSize:"1.25rem",fontWeight:R$.strong,color:rx},children:e}),o&&p.jsx(Re,{sx:{...P6,mt:.25,display:"flex",alignItems:"center"},children:o})]}),a]})}function Gg(e,t){return e.length<=1?e.join(""):`${e.slice(0,-1).join(", ")} ${t} ${e.at(-1)}`}function HI(e,t){return`${e.label??e.name}: ${Kbe(e,t)}`}const qb=e=>e.label??e.name;function j6(e,t,n=void 0,r=void 0,o=!1,a="source"){const i=e??[],s=k=>n?.[k.name]!==void 0,l=k=>r?.has(k.name)===!0,d=i.filter(k=>!s(k)&&k.default===void 0),u=t??[],m=u.length===0&&d.length>0&&d.every(k=>l(k)),g=o&&m?d:[];if(g.length===0&&(d.length>0||u.length>0)){const k=d.length>0?`a value for ${d.length===1?"the given":"the givens"} ${d.map(qb).join(", ")}`:"",T=u.length>0?`${u.length===1?"the required filter":"the required filters"} ${u.join(", ")}`:"",O=d.filter(l),P=O.length===0?"":O.length===d.length?` This page can't tell whether this ${a} reads ${d.length===1?"it":"them"}.`:` This page can't tell whether this ${a} reads ${Gg(O.map(qb),"or")}.`;let D;return T===""?D=`This needs ${k}. Set ${d.length===1?"it":"them"} in the Givens section above.${P}`:k===""?D=`This needs ${T}, which this page can't set; open the source in a dashboard or notebook.`:D=`This needs ${k} (set ${d.length===1?"it":"them"} in the Givens section above) and ${T}, which this page can't set; open the source in a dashboard or notebook.${P}`,{kind:"blocked",reason:D,canRunAnyway:m}}const y=k=>k.length>0?`${k.length===1?"the default":"the defaults"} ${k.map(T=>HI(T)).join(", ")}`:"",x=[];g.length>0&&x.push(`Ran without a value for ${g.length===1?"the given":"the givens"} ${Gg(g.map(qb),"and")}, which this page can't tell this ${a} reads.`);const w=i.filter(k=>!g.includes(k)),S=w.filter(k=>!l(k)),b=y(S.filter(k=>!s(k)));b!==""&&x.push(`Ran with ${b}.`);const $=w.filter(l);if($.length>0){const k=[$.filter(s).map(T=>HI(T,n?.[T.name])).join(", "),y($.filter(T=>!s(T)))].filter(T=>T!=="").join(" and ");x.push($.length===w.length?`This page can't tell which givens this ${a} reads. Where it reads one, it ran with ${k}.`:`This page can't tell whether this ${a} reads ${Gg($.map(qb),"or")}. Where it does, it ran with ${k}.`)}return x.length>0?{kind:"noted",note:x.join(" ")}:{kind:"ok"}}const ZSe=400;function JSe({givens:e,unknown:t,inheritedFrom:n,values:r,onChange:o,onReset:a,environmentName:i,packageName:s,modelPath:l,versionId:d,declaredTypes:u}){const m=C.useMemo(()=>[...e],[e]),g=C.useMemo(()=>{const D=e.filter(A=>t?.has(A.name));if(D.length!==0)return D.length===e.length?"This page can't tell which of these givens this source reads, so a value set here may not apply to it.":`This page can't tell whether this source reads ${Gg(D.map(A=>A.label??A.name),"or")}, so a value set for ${D.length===1?"it":"them"} may not apply.`},[e,t]),[y,x]=C.useState(()=>new Set),w=C.useCallback(D=>x(A=>A.has(D)?A:new Set([...A,D])),[]),S=i_(r,ZSe),b=C.useMemo(()=>({values:S,declaredTypes:u}),[S,u]),{options:$,isLoading:k,failed:T,truncated:O,search:P}=FF(i,s,l,m,d,b,void 0,y,!0);return p.jsxs(ih,{label:"Givens",count:e.length,testId:"model-givens-section",children:[p.jsx(Re,{sx:{"& .MuiPaper-root":{borderColor:"divider"}},children:p.jsx(A1,{layout:"bar",givens:m,values:r,onChange:o,onReset:a,options:$,optionsLoading:k,optionsFailed:T,optionsTruncated:O,optionSearch:P,onControlOpen:w})}),g&&p.jsx(Hd,{"data-testid":"model-givens-unknown",sx:{mt:1},children:g}),n&&n.size>0&&p.jsx(Hd,{"data-testid":"model-givens-inherited",sx:{mt:1},children:[...n].map(([D,A])=>A.length===1?`${D} is inherited from ${A[0]}, which this model doesn't export.`:`${D} is inherited from ${A.slice(0,-1).join(", ")} and ${A.at(-1)}, none of which this model exports.`).join(" ")})]})}const eCe="A source is a queryable entry point into the model — pick one to browse its dimensions, measures, views and joins.";function tCe(e,t=!1){return e===0?"No sources":`${e} ${t?"public ":""}source${e===1?"":"s"}`}const nCe=rn(p.jsx("path",{d:"M21 11h-1.5v-.5h-2v3h2V13H21v1c0 .55-.45 1-1 1h-3c-.55 0-1-.45-1-1v-4c0-.55.45-1 1-1h3c.55 0 1 .45 1 1zM8 10v5H6.5v-1.5h-2V15H3v-5c0-.55.45-1 1-1h3c.55 0 1 .45 1 1m-1.5.5h-2V12h2zm7 1.5c.55 0 1 .45 1 1v1c0 .55-.45 1-1 1h-4V9h4c.55 0 1 .45 1 1v1c0 .55-.45 1-1 1M11 10.5v.75h2v-.75zm2 2.25h-2v.75h2z"})),rCe=rn(p.jsx("path",{d:"M6 6v2h8.59L5 17.59 6.41 19 16 9.41V18h2V6z"})),oCe=rn(p.jsx("path",{d:"M4 9h4v11H4zm12 4h4v7h-4zm-6-9h4v16h-4z"})),aCe=rn([p.jsx("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2m0 16H5V5h14z"},"0"),p.jsx("path",{d:"M6.25 7.72h5v1.5h-5zM13 15.75h5v1.5h-5zm0-2.5h5v1.5h-5zM8 18h1.5v-2h2v-1.5h-2v-2H8v2H6V16h2zm6.09-7.05 1.41-1.41 1.41 1.41 1.06-1.06-1.41-1.42 1.41-1.41L16.91 6 15.5 7.41 14.09 6l-1.06 1.06 1.41 1.41-1.41 1.42z"},"1")]),A6=rn(p.jsx("path",{d:"M20 3h-1V1h-2v2H7V1H5v2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2m0 18H4V10h16zm0-13H4V5h16z"})),iCe=rn(p.jsx("path",{d:"M17 20.41 18.41 19 15 15.59 13.59 17zM7.5 8H11v5.59L5.59 19 7 20.41l6-6V8h3.5L12 3.5z"})),sCe=rn(p.jsx("path",{d:"M9.4 16.6 4.8 12l4.6-4.6L8 6l-6 6 6 6zm5.2 0 4.6-4.6-4.6-4.6L16 6l6 6-6 6z"})),lCe=rn(p.jsx("path",{d:"M15 4v2h3v12h-3v2h5V4zM4 20h5v-2H6V6h3V4H4z"})),cCe=rn(p.jsx("path",{d:"M4 7v2c0 .55-.45 1-1 1H2v4h1c.55 0 1 .45 1 1v2c0 1.65 1.35 3 3 3h3v-2H7c-.55 0-1-.45-1-1v-2c0-1.3-.84-2.42-2-2.83v-.34C5.16 11.42 6 10.3 6 9V7c0-.55.45-1 1-1h3V4H7C5.35 4 4 5.35 4 7m17 3c-.55 0-1-.45-1-1V7c0-1.65-1.35-3-3-3h-3v2h3c.55 0 1 .45 1 1v2c0 1.3.84 2.42 2 2.83v.34c-1.16.41-2 1.52-2 2.83v2c0 .55-.45 1-1 1h-3v2h3c1.65 0 3-1.35 3-3v-2c0-.55.45-1 1-1h1v-4z"})),uCe=rn(p.jsx("path",{d:"m12 8-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z"})),dCe=rn(p.jsx("path",{d:"M4 10.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5m0-6c-.83 0-1.5.67-1.5 1.5S3.17 7.5 4 7.5 5.5 6.83 5.5 6 4.83 4.5 4 4.5m0 12c-.83 0-1.5.68-1.5 1.5s.68 1.5 1.5 1.5 1.5-.68 1.5-1.5-.67-1.5-1.5-1.5M7 19h14v-2H7zm0-6h14v-2H7zm0-8v2h14V5z"})),D6=rn(p.jsx("path",{d:"M7.41 8.59 12 13.17l4.59-4.58L18 10l-6 6-6-6z"})),fCe=rn(p.jsx("path",{d:"M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2M9 6c0-1.66 1.34-3 3-3s3 1.34 3 3v2H9zm9 14H6V10h12zm-6-3c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2"})),pCe=rn(p.jsx("path",{d:"m20.5 10 .5-2h-4l1-4h-2l-1 4h-4l1-4h-2L9 8H5l-.5 2h4l-1 4h-4L3 16h4l-1 4h2l1-4h4l-1 4h2l1-4h4l.5-2h-4l1-4zm-7 4h-4l1-4h4z"})),N6=rn(p.jsx("path",{d:"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2M12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8m.5-13H11v6l5.25 3.15.75-1.23-4.5-2.67z"})),hCe=rn([p.jsx("path",{d:"m21.41 11.41-8.83-8.83c-.37-.37-.88-.58-1.41-.58H4c-1.1 0-2 .9-2 2v7.17c0 .53.21 1.04.59 1.41l8.83 8.83c.78.78 2.05.78 2.83 0l7.17-7.17c.78-.78.78-2.04-.01-2.83M12.83 20 4 11.17V4h7.17L20 12.83z"},"0"),p.jsx("circle",{cx:"6.5",cy:"6.5",r:"1.5"},"1")]),I6=rn(p.jsx("path",{d:"M17 6H7c-3.31 0-6 2.69-6 6s2.69 6 6 6h10c3.31 0 6-2.69 6-6s-2.69-6-6-6m0 10H7c-2.21 0-4-1.79-4-4s1.79-4 4-4h10c2.21 0 4 1.79 4 4s-1.79 4-4 4m0-7c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3"})),mCe=rn(p.jsx("path",{d:"M3 17v2h6v-2zM3 5v2h10V5zm10 16v-2h8v-2h-8v-2h-2v6zM7 9v2H3v2h4v2h2V9zm14 4v-2H11v2zm-6-4h2V7h4V5h-4V3h-2z"})),L6=rn(p.jsx("path",{d:"M3 5v14h18V5zm5.33 12H5V7h3.33zm5.34 0h-3.33V7h3.33zM19 17h-3.33V7H19z"})),gCe=rn(p.jsx("path",{d:"M12 5.99 19.53 19H4.47zM12 2 1 21h22zm1 14h-2v2h2zm0-6h-2v4h2z"}));function Ao(e,t){const n=({size:r,...o})=>p.jsx(e,{...o,sx:{fontSize:r}});return n.displayName=t,n}const yCe=Ao(nCe,"IconText"),WI=Ao(rCe,"IconOpen"),z6=Ao(oCe,"IconResult"),vCe=Ao(aCe,"IconCalculation"),bCe=Ao(A6,"IconDate"),xCe=Ao(iCe,"IconJoin"),wCe=Ao(sCe,"IconCode"),SCe=Ao(lCe,"IconList"),CCe=Ao(cCe,"IconRecord"),kCe=Ao(uCe,"IconCollapse"),$Ce=Ao(uF,"IconExpand"),RCe=Ao(dCe,"IconFields"),TCe=Ao(D6,"IconDropdown"),ECe=Ao(fCe,"IconLock"),F6=Ao(pCe,"IconNumber"),MCe=Ao(N6,"IconTimestamp"),OCe=Ao(hCe,"IconValues"),PCe=Ao(I6,"IconBoolean"),jCe=Ao(mCe,"IconGivens"),_6=Ao(L6,"IconColumn");Ao(gCe,"IconWarning");const Ty=C.createContext(void 0);function hT(){const[e,t]=C.useState(!1),n=C.useContext(Ty),[r,o]=C.useState(n?.n);return n&&n.n!==r&&(o(n.n),t(n.open)),[e,t]}function ACe({allOpen:e,onToggle:t,noun:n,disabledReason:r}){const o=e?p.jsx(kCe,{size:16,"aria-hidden":!0}):p.jsx($Ce,{size:16,"aria-hidden":!0});return p.jsx(Br,{title:r??"",children:p.jsx("span",{children:p.jsxs(rs,{disabled:!!r,onClick:t,"aria-label":r??`${e?"Collapse":"Expand"} all ${n[1]}`,sx:{font:"inherit",color:"text.secondary",gap:.25,borderRadius:1,"&:hover":{color:"text.primary",textDecoration:"underline"},...Ry,"&.Mui-disabled":{opacity:.5}},children:[o,e?"Collapse all":"Expand all"]})})})}function ox({noun:e,disabledReason:t}){const[n,r]=C.useState(void 0),o=n?.open??!1;return{command:n,action:p.jsx(ACe,{allOpen:o,onToggle:()=>r({open:!o,n:(n?.n??0)+1}),noun:e,disabledReason:t})}}let OC;function DCe(e,t){if(OC?.text===t)return OC.parsed;const n=t.replace(/\r\n/g,`
|
|
491
491
|
`);let r;try{r={lines:n.split(`
|
|
492
492
|
`),symbols:e.Malloy.parse({source:n}).symbols}}catch{r=void 0}return OC={text:t,parsed:r},r}function V1(e,t){const{start:n,end:r}=t;return n.line===r.line?(e[n.line]??"").slice(n.character,r.character):[(e[n.line]??"").slice(n.character),...e.slice(n.line+1,r.line),(e[r.line]??"").slice(0,r.character)].join(`
|
|
493
|
-
`)}let B6,Hb;function NCe(){return Hb??=vo(()=>import("./index-
|
|
493
|
+
`)}let B6,Hb;function NCe(){return Hb??=vo(()=>import("./index-w1w5RvZI.js").then(e=>e.i),__vite__mapDeps([0,1])).then(e=>{const t="Malloy"in e?e:e.default;return B6=t,t}),Hb.catch(()=>{Hb=void 0}),Hb}function U6(e,t=!0){const[n,r]=C.useState(B6),[o,a]=C.useState(!1),i=!!e&&t;return C.useEffect(()=>{if(!i||n)return;let s=!0;return NCe().then(l=>s&&r(l),()=>s&&a(!0)),()=>{s=!1}},[i,n]),{parsed:C.useMemo(()=>i&&n&&e?DCe(n,e):void 0,[i,n,e]),pending:i&&!n&&!o}}function ICe(e,t){if(!e)return;const n=e.symbols.filter(r=>r.type==="query"&&r.name.replace(/^`(.*)`$/,"$1")===t);if(n.length===1)return`query: ${V1(e.lines,n[0].range).trimEnd()}`}function V6(e){const t=e.replace(/^\n+/,"").split(`
|
|
494
494
|
`),n=[];let r=0;for(;r<t.length;){const o=t[r].trim();if(!o.startsWith("#"))break;!o.startsWith('#"')&&!o.startsWith("#(doc)")&&n.push(t[r]),r+=1}return[...n,...t.slice(r)].join(`
|
|
495
495
|
`).trim()}function LCe(e,t){const n=V6(t),r=nf(e),o=new RegExp(`^(?:(?:dimension|measure|view)\\s*:\\s*)?${r}\\s+is\\s+`),a=n.replace(o,"");if(a===n||!(a.startsWith("{")&&a.endsWith("}")))return n;const i=a.slice(1,-1).replace(/^\n/,"").replace(/\s+$/,"").split(`
|
|
496
496
|
`),s=i.filter(d=>d.trim()).map(d=>d.match(/^[ \t]*/)[0].length),l=s.length?Math.min(...s):0;return i.map(d=>d.slice(l)).join(`
|
|
@@ -507,6 +507,6 @@ ${o.inheritedFrom.code}`,framed:!1}):p.jsx(Re,{sx:{p:1},children:p.jsx(q1,{messa
|
|
|
507
507
|
`)}}function xke(e,t){const n=(e[t.line]??"").slice(0,t.character),r=n.trim()==="";if(!r&&!QI.test(n))return[];const o=i=>{const s=[];let l=i;for(;l>=0&&e[l].trim().startsWith("#");)s.unshift(e[l--].trim());return{out:s,next:l}},a=o(t.line-1);return r&&a.next>=0&&QI.test(e[a.next])?[...o(a.next-1).out,...a.out]:a.out}const wke=/(?<![\w:])([A-Za-z_]\w*)\s*:(?!:)/g;function Ske(e){let t;for(const n of Cke(e).matchAll(wke))t=n[1];return t}function Cke(e){let t="";for(let n=0;n<e.length;n++){const r=e[n];if(e.startsWith('"""',n)){const o=e.indexOf('"""',n+3),a=o===-1?e.length:o+3;t+=" ".repeat(a-n),n=a-1}else if(r==='"'||r==="'"||r==="`"){const o=kke(e,n);t+=" ".repeat(o-n+1),n=o}else if(r==="#"||r==="/"&&e[n+1]==="/"||r==="-"&&e[n+1]==="-"){const o=e.indexOf(`
|
|
508
508
|
`,n),a=o===-1?e.length:o;t+=" ".repeat(a-n),n=a-1}else t+=r}return t}function kke(e,t){const n=e[t];for(let r=t+1;r<e.length;r++)if(e[r]==="\\")r++;else if(e[r]===n)return r;return e.length}function $ke(e){return/^`?[A-Za-z_]\w*`?\s+is\s+`?([A-Za-z_]\w*)`?\s*(?:extend\b|$)/.exec(e)?.[1]}function wT(e){return e.replace(/^`(.*)`$/,"$1")}const Rke=["fields","code"],XI={display:"inline-flex",alignItems:"center",color:"text.secondary",borderRadius:1,padding:"2px",flexShrink:0,"&:hover":{color:rx}};function Tke({join:e,run:t,modelPath:n,sourceName:r,link:o,entitiesByName:a,entitiesLoading:i,entitiesError:s,code:l,target:d,showRules:u=!1}){const[m,g]=hT(),{layers:y,layer:x,setLayer:w}=K6(Rke),S=C.useMemo(()=>a?Z6({entities:a,loading:!!i,error:!!s}):void 0,[a,i,s]),b=e.dimensions.length+e.measures.length,$=p.jsxs(Re,{sx:{display:"inline-flex",alignItems:"center",gap:1},children:[m&&p.jsx(Q6,{"aria-label":`Show for ${e.name}`,layers:y,value:x,onChange:w,disabledReasons:{code:l?void 0:"No Malloy code to show for this join"}}),o?.kind==="link"&&o.href&&p.jsx(P0,{href:o.href,"aria-label":`Open ${e.name}`,title:`Open ${e.name}`,sx:XI,children:p.jsx(WI,{size:14})}),o?.kind==="link"&&!o.href&&o.onOpen&&p.jsx(P0,{component:"button",type:"button",onClick:o.onOpen,"aria-label":`Open ${e.name}`,title:`Open ${e.name}`,sx:XI,children:p.jsx(WI,{size:14})}),o?.kind==="join-only"&&p.jsx(Re,{component:"span",sx:{fontSize:Ka.micro,fontStyle:"italic",color:"text.secondary",flexShrink:0},children:"only accessible via join"})]});return p.jsxs(Re,{"data-testid":"model-viewer-join-row","data-name":e.name,sx:m?{pb:1.25}:void 0,children:[p.jsx(xT,{glyph:p.jsx(yT,{kind:"join"}),name:e.name,typeLabel:`${b} ${b===1?"field":"fields"}`,stackPills:!0,descriptors:p.jsxs(cs,{tone:"quiet",voice:"token",sx:{alignSelf:"center",flexShrink:0},children:["join_",e.relationship]}),doc:e.doc,open:m,expandable:!0,onToggle:()=>g(k=>!k),trailing:$,pills:d&&p.jsx(E6,{access:d.access})}),p.jsx(Bp,{in:m,timeout:"auto",unmountOnExit:!0,children:p.jsx(Re,{sx:{mx:"10px",mt:"2px"},children:x==="code"&&l?p.jsx(Ey,{testId:"model-viewer-join-code",code:l}):p.jsxs(Re,{"data-testid":"model-viewer-join-fields",sx:{...kh,bgcolor:"transparent",p:1.5,pb:0},children:[d&&u&&p.jsx(ky,{component:"div","data-testid":"model-viewer-join-gate-warning",sx:{mb:1},children:FSe(d.sourceName,d.access)}),p.jsx(Kg,{label:"Measures",noun:["measure","measures"],level:"h3",items:e.measures,run:t,modelPath:n,sourceName:r,getFieldCode:S}),p.jsx(Kg,{label:"Dimensions",noun:["dimension","dimensions"],level:"h3",items:e.dimensions,run:t,modelPath:n,sourceName:r,getFieldCode:S})]})})})]})}function Eke({source:e,modelPath:t,entitiesByName:n,entitiesLoading:r,entitiesError:o,modelText:a,joinLinks:i,joinEntities:s,joinCodes:l,joinAccess:d,showRules:u=!1,columnDescriptions:m,run:g,queries:y,givens:x}){const w={run:g,modelPath:t,sourceName:e.name},{showField:S}=B1(),b=C.useMemo(()=>S?e.views.filter(F=>S({modelPath:t,sourceName:e.name,field:F,joined:!1})):e.views,[S,e,t]),$=ox({noun:["view","views"]}),k=ox({noun:["join","joins"]}),T=C.useMemo(()=>!r&&[...e.views,...e.measures,...e.calculations,...e.dimensions].some(F=>!n?.get(F.name)),[r,n,e]),{parsed:O,pending:P}=U6(a,T),D=C.useMemo(()=>mke(O,e.name),[O,e.name]),A=C.useMemo(()=>Z6({entities:n,loading:!!r,error:!!o,columnDescriptions:m,declarations:D,declarationsLoading:P}),[n,r,o,m,D,P]);return p.jsxs(Re,{sx:{paddingBottom:"24px"},children:[x,p.jsx(ih,{label:"Views",count:b.length,action:$.action,children:p.jsx(Ty.Provider,{value:$.command,children:b.map(F=>p.jsx(X6,{field:F,modelPath:t,sourceName:e.name,fieldCode:A(F),run:g},F.name))})}),y,p.jsx(Kg,{label:"Measures",noun:["measure","measures"],items:e.measures,getFieldCode:A,...w}),p.jsx(Kg,{label:"Calculations",noun:["calculation","calculations"],items:e.calculations,getFieldCode:A,...w}),p.jsx(Kg,{label:"Dimensions",noun:["dimension","dimensions"],items:e.dimensions,getFieldCode:A,...w}),p.jsx(ih,{label:"Joins",count:e.joins.length,action:k.action,children:p.jsx(Ty.Provider,{value:k.command,children:e.joins.map(F=>p.jsx(Tke,{join:F,run:g,modelPath:t,sourceName:e.name,link:i?.get(F.name),entitiesByName:s?.get(F.name),code:l?.get(F.name),target:d?.get(F.name),showRules:u,entitiesLoading:r,entitiesError:o},F.name))})})]})}function M$(e){return{name:e.name,kind:e.kind,dataType:cT(e.type),typeTip:iSe(e.type),tags:sSe(e.annotations),doc:ah(e.annotations),indexed:e.kind==="dimension"?SSe(e):void 0,preaggregate:e.kind==="measure"?aSe(e.annotations):void 0}}function Mke(e){const t=[],n=[];for(const r of e.schema?.fields??[]){if(r.kind!=="dimension"&&r.kind!=="measure")continue;const o={...M$(r),indexed:!1,preaggregate:!1};r.kind==="dimension"?t.push(o):n.push(o)}return{name:e.name,relationship:e.relationship,doc:ah(e.annotations),dimensions:t,measures:n}}function Oke(e,t){const n={name:e.name,doc:ah(e.annotations),docParts:g6(e.annotations),accent:QSe(t),persist:oSe(e.annotations),dimensions:[],measures:[],calculations:[],views:[],joins:[]};for(const r of e.schema?.fields??[])switch(r.kind){case"dimension":case"measure":n[r.kind==="dimension"?"dimensions":"measures"].push(M$(r));break;case"calculate":n.calculations.push(M$(r));break;case"view":n.views.push({name:r.name,kind:"view",doc:ah(r.annotations),tags:lT(r.annotations)});break;case"join":n.joins.push(Mke(r));break}return n}function Pke(e){const t=[];for(const n of e??[]){if(!n.name)continue;const r=(n.annotations??[]).map(o=>({value:o}));t.push({name:n.name,sourceName:n.sourceName||void 0,doc:ah(r),tags:lT(r)})}return t}function J6(e){return e.dimensions.length+e.measures.length+e.calculations.length+e.views.length}function jke(e,t){if(e.length===0)return null;const n=d=>d.toLowerCase().replace(/[-_]/g,""),r=t?n((t.split("/").pop()??t).replace(/\.malloy$/,"")):void 0,o=new Map(e.map(d=>[d.name,new Set(d.views.map(u=>u.name))])),a=d=>e.some(u=>{if(u.name===d.name||u.views.length===0)return!1;const m=o.get(d.name);return u.views.length<d.views.length&&[...o.get(u.name)].every(g=>m.has(g))}),i=e.filter(d=>!a(d)),s=i.length>0?i:e;let l=s[0];for(const d of s.slice(1)){if(d.views.length!==l.views.length){d.views.length>l.views.length&&(l=d);continue}r&&n(d.name)===r&&n(l.name)!==r&&(l=d)}return l}function Ake(e,t,n){if(!e||!t)return;const r=new RegExp("source:\\s*`?"+nf(t)+"`?\\s+is\\s+`?([A-Za-z_]\\w*)`?\\s*(?:->|extend\\b)").exec(e);if(!r)return;const o=r[1];return n.has(o)?o:void 0}function DC(e,t){return`${e} ${e===1?t:`${t}s`}`}function Dke(e){const t=J6(e),n=[DC(e.views.length,"view"),DC(t,"field")];return e.joins.length>0&&n.push(DC(e.joins.length,"join")),n.join(" · ")}function Nke(e,t,n){if(n){const s=n.exportOrder,l=s.length>0&&e.some(d=>s.includes(d.name));return{sources:zke(e,d=>d.name,s),curated:!0,exportOrdered:l}}const r=e.map((s,l)=>({source:s,index:l})).filter(({source:s})=>s.name!==t?.name).sort((s,l)=>l.source.views.length-s.source.views.length||s.index-l.index).map(({source:s})=>s),o=t?[t,...r]:r,a=t?.views.length??0,i=t&&a>0&&e.every(s=>s.views.length<=a)?t.name:void 0;return{sources:o,curated:!1,exportOrdered:!1,mostViews:i}}function Ike(e){return/^`.*`$/.test(e)?e.slice(1,-1):e}function Lke(e){if(!e)return[];const t=iv(e),n=[];for(const r of t.matchAll(/(?:^|[\s;])export\s*\{([^}]*)\}/gi))for(const o of r[1].split(",")){const a=Ike(o.trim());a&&!n.includes(a)&&n.push(a)}return n}function zke(e,t,n){if(n.length===0)return[...e];const r=o=>{const a=n.indexOf(t(o));return a===-1?n.length:a};return e.map((o,a)=>({item:o,index:a})).sort((o,a)=>r(o.item)-r(a.item)||o.index-a.index).map(({item:o})=>o)}function Fke(e,t){const n=e?.trim();if(n)return{text:n,generated:!1};const r=t?.trim();return r?{text:r,generated:!0}:void 0}const _ke="This package's curated sources, in the order its index.malloy exports them.",Bke="This package's public sources.";function Uke(e){return e.mostViews?", most views":""}function Vke({anchorEl:e,onClose:t,sources:n,currentName:r,onPickSource:o,curated:a=!1,exportOrdered:i=!1}){return p.jsxs(jR,{open:!!e,anchorEl:e,onClose:t,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},slotProps:{paper:{sx:{width:460,maxWidth:"calc(100vw - 32px)",maxHeight:"min(70vh, 560px)",display:"flex",flexDirection:"column",borderRadius:"10px"},"data-testid":"model-sources-dropdown"}},children:[p.jsxs(Re,{sx:{px:2,pt:1.5,pb:1,borderBottom:1,borderColor:"divider"},children:[p.jsx(wt,{variant:"subtitle2",component:"h2",sx:{m:0},children:"Sources"}),p.jsx(ky,{component:"p",sx:{m:0},children:a?i?_ke:Bke:eCe})]}),p.jsx(Re,{sx:{overflowY:"auto",py:.5},children:n.length===0?p.jsx(wt,{variant:"body2",color:"text.secondary",sx:{py:4,textAlign:"center"},children:"This model defines no sources."}):n.map(s=>{const l=s.name===r;return p.jsxs(rs,{"data-item-name":s.name,"aria-label":`Open source ${s.name}${Uke(s)}${BSe(s.access)}`,"aria-current":l||void 0,onClick:()=>{t(),o(s.name)},sx:{display:"flex",width:"100%",alignItems:"flex-start",justifyContent:"flex-start",textAlign:"left",gap:1.25,px:2,py:1,bgcolor:l?yo.background.muted:void 0,"&:hover":{bgcolor:l?yo.background.strong:yo.background.muted},...Ry},children:[p.jsx(Re,{component:"span","aria-hidden":!0,sx:{color:Rp.steel.main,display:"inline-flex",pt:"2px"},children:p.jsx(_6,{size:16})}),p.jsxs(Re,{component:"span",sx:{minWidth:0,flex:1},children:[p.jsxs(Re,{component:"span",sx:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:1},children:[p.jsx(Re,{component:"span",sx:{fontFamily:ts,fontSize:Ka.body,fontWeight:500,color:"text.primary"},children:s.name}),s.mostViews&&p.jsx(cs,{tone:"quiet",sx:{alignSelf:"center"},children:qke}),T6(s.access)&&p.jsx(E6,{access:s.access}),s.status]}),(s.description||s.descriptionPending)&&p.jsxs(Re,{component:"span",sx:{display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:2,overflow:"hidden",mt:.25,fontSize:Ka.small,color:"text.secondary",minHeight:s.description?void 0:"1.4em"},children:[s.description?.generated&&p.jsx(cs,{tone:"quiet","data-testid":"model-sources-summary-generated",sx:{mr:.75,verticalAlign:"baseline"},children:"Generated"}),s.description&&M6(s.description.text)]}),p.jsx(ky,{"data-testid":"model-sources-row-meta",sx:{display:"block",mt:.25},children:s.meta})]})]},`source:${s.name}`)})})]})}const qke="Most views";function Hke({sources:e,currentName:t,countLabel:n,onPickSource:r,curated:o=!1,exportOrdered:a=!1,onWarm:i}){const[s,l]=C.useState(null);return p.jsxs(p.Fragment,{children:[p.jsx(ake,{size:"small",variant:"outlined",onClick:d=>{i?.(),l(d.currentTarget)},endIcon:p.jsx(TCe,{size:20}),"aria-label":`${n}. Showing ${t}, one of the ${n} in this model`,"aria-haspopup":"dialog","aria-expanded":!!s,onPointerEnter:i,onFocus:i,sx:{ml:1,transition:"none"},children:n}),p.jsx(Vke,{anchorEl:s,onClose:()=>l(null),sources:e,currentName:t,onPickSource:r,curated:o,exportOrdered:a})]})}const Wke=[],Yke=[],Gke=[],Kke=new Map;function Qke(e){const t=e.modelDef;if(typeof t!="string")return!1;try{const n=JSON.parse(t);return Array.isArray(n.imports)&&n.imports.length>0}catch{return!1}}function Xke(e,t){if(typeof e=="string")try{const r=NI(JSON.parse(e).annotations);if(r)return r}catch{}if(!t)return;const n=t.split(`
|
|
509
509
|
`).filter(r=>/^##(\(doc\)|")/.test(r.trim())).map(r=>({value:r}));return NI(n)}async function Zke(e,t,n,r,o,a){const i=await e.models.getModel(t,n,r,o,a),s=Jke(i.data);return{sourceInfos:(i.data.sourceInfos??[]).map(l=>JSON.parse(l)),queries:i.data.queries??[],sourceText:s,givens:hSe(r,i.data),access:NSe(i.data),modelDoc:Xke(i.data.modelInfo,s),hasImports:Qke(i.data)}}function Jke(e){const t=e.sourceText;return typeof t=="string"?t:void 0}function e$e(e,t,n,r,o=!1){return["model-viewer-sources",e,t,n,r??"",...o?["off-surface"]:[]]}function t$e(e,t,n,r,o,a=!1){return{queryKey:e$e(t,n,r,o,a),queryFn:()=>Zke(e,t,n,r,o,a),...o&&o!=="latest"?{staleTime:1/0}:{}}}function n$e(e,t,n,r,o=!0,a=!1){const{apiClients:i}=er(),s=Ld({...t$e(i,e,t,n,r,a),enabled:o&&!!(e&&t&&n)});return{sources:s.data?.sourceInfos??Wke,queries:s.data?.queries??Yke,sourceText:s.data?.sourceText,givens:s.data?.givens??Gke,access:s.data?.access??Kke,modelDoc:s.data?.modelDoc,hasImports:s.data?.hasImports??!1,isLoading:s.isLoading,isError:s.isError,error:s.error,refetch:s.refetch}}const r$e=new Map;function ZI(e){return(e.split("/").pop()??e).replace(/\.malloy$/,"")}function o$e(e,t){const n=RSe(e,t),r=t.filter(a=>!n.has(a.name)),o="Nothing on this page reads them.";return r.length===0?`Declared here for the models that import this file. ${o}`:r.length===t.length?`Imported from another file, for the models that import this one. ${o}`:`For the models that import this file. ${Gg(r.map(a=>a.name),"and")} ${r.length===1?"comes":"come"} from a file this one imports; the rest are declared here. ${o}`}function a$e({resourceUri:e,sourceName:t,onSourceChange:n,initialSourceName:r,includeHiddenFilesAndSources:o=!1,hostGivenNames:a,givens:i,onGivensChange:s,showAccessRules:l=!1,headingLevel:d="h1",headerActions:u,renderSourceStatus:m,entities:g,entitiesLoading:y=!1,entitiesError:x=!1,columnDescriptions:w,joinHref:S,queryMetadata:b,onQueryRun:$,maxResultSize:k,extensions:T}){const{environmentName:O,packageName:P,modelPath:D="",versionId:A}=ko(e),F=Hr().theme.ui.font.mono,{sources:L,queries:_,sourceText:R,givens:z,access:I,modelDoc:U,hasImports:N,isLoading:q,isError:Y,error:oe,refetch:Q}=n$e(O,P,D,A,!0,o),ae=C.useMemo(()=>new Set(a??[]),[a]),de=C.useMemo(()=>z.filter(Bt=>!ae.has(Bt.name)),[z,ae]),X=C.useMemo(()=>L.map(Oke),[L]),se=C.useMemo(()=>Pke(_),[_]),J=C.useMemo(()=>kSe(X),[X]),Z=C.useMemo(()=>CSe(L),[L]),G=C.useMemo(()=>mSe(de),[de]),ue=JSON.stringify(i??null),ie=C.useMemo(()=>i&&Object.fromEntries(Object.entries(i).filter(([Bt])=>G.has(Bt))),[ue,G]),fe=!q&&!Y,he=C.useCallback(Bt=>s?.(Bt,Array.from(G.keys())),[s,G]),me=IF({declaredTypes:G,params:ie,onParamsChange:fe&&s?he:void 0,documentKey:`${O}/${P}@${A??""}/${D}`,autorun:!0}),le=C.useMemo(()=>gSe(me.applied,G),[me.applied,G]),{givensBySource:ve,unknownGivensBySource:Le}=C.useMemo(()=>{const Bt=new Map,an=new Map;for(const $n of X){const Vt=ESe(R,$n.name,de);Bt.set($n.name,Vt.givens),Vt.unknown.size>0&&an.set($n.name,Vt.unknown)}return{givensBySource:Bt,unknownGivensBySource:an}},[X,R,de]),Ie=C.useMemo(()=>({projectName:O,packageName:P,versionId:A,givens:de,givensBySource:ve,unknownGivensBySource:Le,requiredFiltersBySource:Z,givenValues:le,accessBySource:I,includeHiddenFilesAndSources:o,queryMetadata:b,onQueryRun:$,maxResultSize:k}),[O,P,A,de,ve,Le,Z,le,I,o,b,$,k]),[Te,ne]=C.useState(r),qe=t!==void 0,Oe=qe?t:Te,Qe=C.useCallback(Bt=>{qe||ne(Bt),n?.(Bt)},[qe,n]),nt=C.useMemo(()=>jke(X,D),[X,D]),kt=X.find(Bt=>Bt.name===Oe)??(qe?void 0:nt),Ut=C.useMemo(()=>kt?ve.get(kt.name)??de:de,[kt,ve,de]),at=C.useMemo(()=>kt?MSe(R,kt.name,de,J):new Map,[kt,R,de,J]),et=C.useMemo(()=>Ake(R,kt?.name,J),[R,kt?.name,J]),pt=C.useMemo(()=>kt?nSe(kt,X.find(Bt=>Bt.name===et)):void 0,[kt,X,et]),ze=C.useMemo(()=>g?$Se(g):r$e,[g]),be=kt?ze.get(kt.name):void 0,{joinLinks:He,joinEntities:Me,joinCodes:$t,joinAccessRules:Rt}=C.useMemo(()=>{const Bt=new Map,an=new Map,$n=new Map,Vt=new Map,Pn=new Map([[D,new Set(J)]]);for(const Se of be?.values()??[]){if(Se.fieldType!=="join")continue;Se.code&&$n.set(Se.name,Se.code);const jn=Se.joinTarget;if(jn)if(jn.modelPath===D){const Rn=ze.get(jn.sourceName);Rn&&an.set(Se.name,Rn);const Jt=b0(I,jn.sourceName);T6(Jt)&&Vt.set(Se.name,{sourceName:jn.sourceName,access:Jt});const Pt=KSe(jn,Pn);Bt.set(Se.name,Pt.kind==="link"?{...Pt,onOpen:()=>Qe(jn.sourceName)}:Pt)}else{const Rn=S?.(jn);Rn&&Bt.set(Se.name,{kind:"link",href:Rn})}}return{joinLinks:Bt,joinEntities:an,joinCodes:$n,joinAccessRules:Vt}},[be,ze,D,J,I,Qe,S]),vt=D==="index.malloy"&&!o,it=C.useMemo(()=>Nke(X,nt,vt?{exportOrder:Lke(R)}:void 0),[X,nt,vt,R]),st=T?.describePickerSource,At=C.useMemo(()=>it.sources.map(Bt=>{const an=st?.({modelPath:D,sourceName:Bt.name});return{name:Bt.name,description:Fke(Bt.doc,an?.summary),descriptionPending:!Bt.doc?.trim()&&!an?.summary&&!!an?.summaryPending,meta:Dke(Bt),mostViews:it.mostViews===Bt.name,access:b0(I,Bt.name),status:an?.status}}),[it,I,st,D]),tn=(()=>{if(q)return p.jsx(Go,{text:"Fetching Model..."});if(Y)return GSe(oe)?p.jsx(Re,{sx:{pt:T$},children:p.jsx(Yg,{message:Y6(oe)??`${P}/${D} doesn't exist, or you don't have access to it.`})}):p.jsx(q1,{message:G6("Failed to load model",oe),onRetry:()=>void Q()});const Bt=se.length>0&&p.jsx(hke,{queries:se,sourceText:R,modelPath:D,run:Ie});if(X.length===0)return se.length===0?p.jsxs(p.Fragment,{children:[p.jsx(MC,{headingLevel:d,title:ZI(D),meta:de.length>0?`${de.length} ${de.length===1?"given":"givens"}`:void 0,actions:u,isSource:!1,offSurface:o}),p.jsx(Yg,{message:"This model defines no sources or queries.",secondary:N&&p.jsxs(p.Fragment,{children:["It imports other files but re-exports nothing. Add"," ",p.jsxs("code",{children:["export ","{ source_name }"]})," to surface imported sources here."]})}),p.jsxs(ih,{label:"Givens",count:de.length,testId:"model-viewer-declared-givens",children:[p.jsx(Hd,{"data-testid":"model-viewer-declared-givens-where",sx:{mb:1},children:o$e(R,de)}),p.jsx(uT,{givens:de})]})]}):p.jsxs(p.Fragment,{children:[p.jsx(MC,{headingLevel:d,title:ZI(D),meta:`${se.length} ${se.length===1?"query":"queries"}`,actions:u,isSource:!1,offSurface:o}),Bt]});if(!kt)return p.jsx(Re,{sx:{pt:T$},children:p.jsx(Yg,{message:`This model has no source named ${Oe}.`,secondary:p.jsxs(Re,{component:"span","data-testid":"model-viewer-source-links",children:["Sources in this model: ",X.map((Se,jn)=>p.jsxs("span",{children:[jn>0&&", ",p.jsx(P0,{component:"button",type:"button",onClick:()=>Qe(Se.name),sx:{fontFamily:ts,verticalAlign:"baseline"},children:Se.name})]},Se.name))]})})});const an=J6(kt),$n=et?void 0:[...be?.values()??[]].find(Se=>Se.table)?.table,Vt=et?p.jsxs(p.Fragment,{children:["from ",p.jsx(P0,{component:"button",type:"button",onClick:()=>Qe(et),sx:{fontFamily:ts,color:_1,textDecorationColor:"inherit",verticalAlign:"baseline"},children:et})]}):$n?p.jsxs(p.Fragment,{children:["reads ",p.jsx(Re,{component:"span","data-testid":"model-viewer-source-table",sx:{fontFamily:ts},children:[$n.connectionName,$n.catalogName,$n.schemaName,$n.tableName].filter(Boolean).join(".")})]}):void 0,Pn=T?.renderSourceDetail?.({modelPath:D,sourceName:kt.name});return p.jsxs(p.Fragment,{children:[p.jsx(MC,{headingLevel:d,title:kt.name,titleAdornments:X.length>1&&p.jsx(Hke,{sources:At,currentName:kt.name,countLabel:tCe(At.length,it.curated),onPickSource:Qe,curated:it.curated,exportOrdered:it.exportOrdered}),actions:u,status:m?.(kt.name),kindLabel:"Source",meta:`${an} ${an===1?"field":"fields"}`,doc:pt,modelDoc:U,access:b0(I,kt.name),showRules:l,offSurface:o,publicSurface:vt,provenance:Vt}),Pn&&p.jsx(Re,{"data-testid":"model-viewer-source-detail",sx:{mt:1.5},children:Pn}),p.jsx(pT.Provider,{value:de,children:p.jsx(Eke,{source:kt,modelPath:D,entitiesByName:be,entitiesLoading:y,entitiesError:x,columnDescriptions:w?.get(kt.name),modelText:R,joinLinks:He,joinAccess:Rt,showRules:l,joinEntities:Me,joinCodes:$t,run:Ie,queries:Bt,givens:p.jsx(JSe,{givens:Ut,unknown:kt?Le.get(kt.name):void 0,inheritedFrom:at,values:me.draft,onChange:me.setGiven,onReset:me.reset,environmentName:O,packageName:P,modelPath:D,versionId:A,declaredTypes:G})},kt.name)})]})})();return p.jsx(w6.Provider,{value:T??{},children:p.jsx(Re,{"data-testid":"model-viewer",sx:{...uSe,pb:2,[v6]:F},children:p.jsx(Re,{sx:dSe,children:tn})})})}const i$e=rn(p.jsx("path",{d:"M8 5v14l11-7z"}));function eB({open:e,onClose:t,result:n,title:r="Results",renderLogs:o,drill:a}){return p.jsx(Oo,{open:e,onClose:t,title:r,maxWidth:!1,showClose:!0,children:p.jsx(Re,{sx:{height:"70vh",overflow:"auto"},children:p.jsx(D1,{result:n,maxHeight:Ole,maxResultSize:1e6,renderLogs:o,drill:a})})})}function s$e({queryName:e,annotations:t,resourceUri:n,runOnDemand:r=!1,maxResultSize:o=0}){const[a,i]=Cn.useState(),[s,l]=Cn.useState(!1),[d,u]=Cn.useState(!1),{packageName:m,environmentName:g,versionId:y,modelPath:x}=ko(n),w=!r||d,S=tT({environmentName:g,packageName:m,modelPath:x,versionId:y,queryName:e},{enabled:w}),b=S.data,{mode:$}=Hr();return C.useEffect(()=>{if(t&&t.length>0){const k=t.map(T=>`// ${T}`).join(`
|
|
510
|
-
`);bT(k,"typescript",$).then(T=>{i(T)})}},[t,$]),p.jsxs(Re,{children:[a&&p.jsx(Re,{sx:{marginBottom:"16px"},children:p.jsx(wt,{fontSize:"12px",sx:{fontSize:"12px","& .line":{textWrap:"wrap"}},children:p.jsx("div",{className:"content",dangerouslySetInnerHTML:{__html:a}})})}),p.jsxs(Re,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"8px"},children:[p.jsx(wt,{variant:"body2",sx:{fontSize:"15px",fontWeight:600,color:"text.primary",px:2,py:1,bgcolor:"action.hover",borderRadius:1.5,border:1,borderColor:"divider"},children:e}),p.jsx(Lp,{"aria-label":"Expand results",onClick:()=>l(!0),children:p.jsx(Gp,{})})]}),p.jsxs(g4,{sx:{position:"relative"},children:[r&&!d&&p.jsxs(Re,{sx:{padding:"40px 20px",textAlign:"center",display:"flex",flexDirection:"column",alignItems:"center",gap:"16px"},children:[p.jsx(wt,{variant:"body2",color:"text.secondary",children:"Click Run to execute the query"}),p.jsx(Hn,{variant:"contained",startIcon:p.jsx(i$e,{}),onClick:()=>u(!0),children:"Run Query"})]}),w&&p.jsx(G2,{state:S,context:e,maxHeight:Mle,maxResultSize:o})]}),p.jsx(eB,{open:s,onClose:()=>l(!1),result:b?.data?.result||"",renderLogs:b?.data?.renderLogs,title:`Query: ${e}`})]})}function l$e(e){return e!=null}function c$e(e,t){const n=[],r=[];for(const a of e){if(a.name===void 0||l$e(t.get(a.name)))continue;if(a.default==null){n.push(a.name);continue}const i=j1(a.type??"string",a.default);i&&r.push(`${a.name} = ${i}`)}const o={missing:n};return r.length>0&&(o.defaultsNote=r.length===1?`Ran with the default ${r[0]}`:`Ran with defaults ${r.join(", ")}`),o}function u$e(e){return e.length===1?`This source may need a value for the given ${e[0]}. Set it in the parameters above.`:`This source may need values for the givens ${e.join(", ")}. Set them in the parameters above.`}function d$e({sourceAndPaths:e,selectedSourceIndex:t,existingQuery:n,onQueryChange:r,onSourceChange:o,resourceUri:a,givens:i,gate:s}){return Cn.useEffect(()=>{o&&o(t)},[t,o]),p.jsx(m4,{children:p.jsxs(x9,{spacing:2,component:"section",children:[p.jsx(p$e,{sourceAndPath:e[t],existingQuery:n,onChange:l=>{r&&r(l)},resourceUri:a,givens:i,gate:s}),p.jsx(f5,{height:"5px"})]})})}function NC(){return{query:void 0,malloyQuery:void 0,malloyResult:void 0}}function f$e({sourceAndPath:e,onChange:t,existingQuery:n,explorerComponents:r,QueryBuilder:o,resourceUri:a,givens:i,gate:s}){const[l,d]=Cn.useState(n||NC()),[u,m]=Cn.useState(void 0);Cn.useEffect(()=>{n&&d(n)},[n]);const[g,y]=Cn.useState([]),{MalloyExplorerProvider:x,QueryPanel:w,ResizableCollapsiblePanel:S,ResultPanel:b,SourcePanel:$}=r;Cn.useEffect(()=>{t&&t(l)},[t,l]);const{environmentName:k,packageName:T,versionId:O}=ko(a),{apiClients:P}=er(),D=Cn.useRef(void 0),A=hl({mutationFn:()=>{D.current=s,m({executionState:"running",query:l?.malloyQuery,queryResolutionStartMillis:Date.now(),onCancel:()=>{A.reset(),m(void 0)},response:{}});const R=typeof l?.malloyQuery=="string"?l.malloyQuery:new o.ASTQuery({source:e.sourceInfo,query:l?.malloyQuery}).toMalloy();return d({...l,query:R}),P.models.executeQueryModel(k,T,e.modelPath,{query:R,sourceName:void 0,queryName:void 0,versionId:O,...i&&Object.keys(i).length>0?{givens:i}:{}})},onSuccess:R=>{if(R){const z=JSON.parse(R.data.result);d({...l,malloyResult:z});const I=D.current;m(U=>U?{...U,executionState:"finished",response:{result:z,...I?.defaultsNote?{messages:[{severity:"INFO",title:I.defaultsNote}]}:{}}}:void 0)}},onError:R=>{console.error("Query execution error:",R);const z=R?.data?.message??R?.message??"The query could not be run.",I=[{severity:"ERROR",title:z}],U=D.current?.missing??[];(R?.status===403||/Access denied for source/i.test(z))&&U.length>0&&I.push({severity:"WARN",title:u$e(U)}),m(N=>N?{...N,executionState:"finished",response:{messages:I}}:void 0)}}),[F,L]=Cn.useState(e.sourceInfo.name);Cn.useEffect(()=>{F!==e.sourceInfo.name&&(L(e.sourceInfo.name),d(NC()),m(void 0))},[e,F]);const _=Cn.useCallback(R=>{d({...l,malloyQuery:R,malloyResult:void 0})},[l]);return F!==e.sourceInfo.name?p.jsx("div",{children:"Loading..."}):p.jsx(y4,{sx:{border:"1px solid #e0e0e0",borderRadius:"8px",overflow:"hidden"},children:p.jsx(x,{source:e.sourceInfo,query:l?.malloyQuery,topValues:[],onFocusedNestViewPathChange:y,focusedNestViewPath:g,onQueryChange:_,children:p.jsxs("div",{style:{display:"flex",height:"100%",overflowY:"auto"},children:[p.jsx(S,{isInitiallyExpanded:!0,initialWidth:180,minWidth:180,icon:"database",title:e.sourceInfo.name,children:p.jsx($,{onRefresh:()=>d(NC())})}),p.jsx(S,{isInitiallyExpanded:!0,initialWidth:280,minWidth:280,icon:"filterSliders",title:"Query",children:p.jsx(w,{runQuery:()=>{console.log(`running query with: ${l?.malloyQuery}`);try{A.mutate()}catch(R){console.error("Error running query:",R)}}})}),p.jsx(b,{source:e.sourceInfo,draftQuery:l?.malloyQuery,setDraftQuery:R=>d({...l,malloyQuery:R}),submittedQuery:u,options:{showRawQuery:!0}})]})})},e.sourceInfo.name)}function p$e(e){const[t,n]=C.useState(null),[r,o]=C.useState(null),[a,i]=C.useState(!0);return C.useEffect(()=>{let s=!0;return Promise.all([vo(()=>import("./index-BQL8UUcK.js"),__vite__mapDeps([5,0,1,2,6])),F0e()]).then(([l,d])=>{s&&(n(l),o(d),i(!1))}).catch(l=>{console.error("Failed to load Malloy components:",l),s&&i(!1)}),()=>{s=!1}},[]),a||!t||!r?p.jsx(qne,{children:p.jsx(y4,{children:p.jsx(f5,{sx:{alignItems:"center",justifyContent:"center",height:"200px",color:"text.secondary"},children:"Loading explorer..."})})}):p.jsx(f$e,{...e,explorerComponents:t,QueryBuilder:r,resourceUri:e.resourceUri})}function tB(e,t=!0){const{modelPath:n,environmentName:r,packageName:o,versionId:a}=ko(e),{apiClients:i}=er();return wo({queryKey:["package",r,o,n,a],queryFn:async()=>(await i.models.getModel(r,o,n,a)).data,enabled:t})}function nB({data:e,onChange:t,existingQuery:n,initialSelectedSourceIndex:r=0,onSourceChange:o,resourceUri:a,givens:i,onGivensChange:s,startingGivens:l}){const[d,u]=Cn.useState(r);Cn.useEffect(()=>{u(r)},[r]);const{data:m,isError:g,isLoading:y,error:x}=tB(a,!e),{environmentName:w,packageName:S,modelPath:b,versionId:$}=ko(a),k=e||m,T=Cn.useMemo(()=>k?.givens??[],[k]),O=g2({specs:T,loaded:!!k,params:i,onGivensChange:s,startingValues:l,documentKey:a,autorun:!0,environmentName:w??"",packageName:S??"",modelPath:b,versionId:$,documentName:b}),P=C.useMemo(()=>Zd(O.applied,O.declaredTypes),[O.applied,O.declaredTypes]),D=C.useMemo(()=>c$e(T,O.applied),[T,O.applied]);if(y&&!e)return p.jsx(Go,{text:"Fetching Model..."});if(g&&!e)return console.log("error",x),p.jsx(Xa,{error:x,context:`ModelExplorer > ${b}`});if(!k)return p.jsx(Go,{text:qd.loading});const A=(k?.sourceInfos||[]).map((L,_)=>{try{return JSON.parse(L)?.name||`Source ${_+1}`}catch{return`Source ${_+1}`}}),F=A[d]||"";return p.jsxs(Une,{variant:"outlined",children:[p.jsx(Vne,{children:p.jsx(Wn,{sx:{flexDirection:"row"},children:p.jsx(uwe,{size:"small",id:"size-small-standard",disablePortal:!0,options:A,value:F,onChange:(L,_)=>{if(!_)return;const R=A.indexOf(_);R>=0&&(u(R),o?.(R))},renderInput:L=>p.jsx(yr,{...L}),style:{width:350,marginTop:"3px",marginLeft:"6px",marginBottom:"8px"}})})}),p.jsx(A1,{...O.panel}),p.jsx(m4,{children:p.jsxs(Wn,{spacing:2,component:"section",children:[Array.isArray(k.sourceInfos)&&k.sourceInfos.length>0&&p.jsx(d$e,{sourceAndPaths:k.sourceInfos.map(L=>({sourceInfo:JSON.parse(L),modelPath:b})),selectedSourceIndex:d,existingQuery:n,onQueryChange:t,resourceUri:a,givens:P,gate:D}),p.jsx(Re,{height:"5px"})]})})]})}function rB({open:e,onClose:t,resourceUri:n,data:r,title:o="Data Sources",hasValidImport:a=!0,existingQuery:i,initialSelectedSourceIndex:s,onChange:l,onSourceChange:d,givens:u,onGivensChange:m,startingGivens:g}){return p.jsxs(Fx,{open:e,onClose:t,fullScreen:!0,children:[p.jsxs(Bx,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[o,p.jsx(no,{onClick:t,sx:{color:"text.secondary"},children:p.jsx(bh,{})})]}),p.jsx(_x,{children:a?p.jsx(nB,{resourceUri:n,data:r,existingQuery:i,initialSelectedSourceIndex:s,onChange:l,onSourceChange:d,givens:u,onGivensChange:m,startingGivens:g}):p.jsx("div",{children:"No valid import statement found in cell"})})]})}function h$e({onChange:e,resourceUri:t,runOnDemand:n=!1,maxResultSize:r=0,givens:o,onGivensChange:a}){const{modelPath:i}=ko(t),{data:s,isError:l,isLoading:d,error:u}=tB(t),[m,g]=Cn.useState(!1),[y,x]=Cn.useState(),[w,S]=Cn.useState(0),[b,$]=C.useState(""),[k,T]=Cn.useState({}),O=o??k,P=a??(R=>T(R)),D=s?.modelDef,A=Cn.useMemo(()=>{if(!D)return!1;try{const R=JSON.parse(D);return Array.isArray(R.imports)&&R.imports.length>0}catch{return!1}},[D]);if(d)return p.jsx(Go,{text:"Fetching Model..."});if(l)return console.log("error",u),p.jsx(Xa,{error:u,context:`Model > ${i}`});const F=R=>{x(R),e&&e(R)},L=R=>{S(R)},_=()=>{const R=window.location.href;navigator.clipboard.writeText(R).then(()=>$("URL copied to clipboard!")).catch(()=>$("Failed to copy URL"))};return p.jsxs(p.Fragment,{children:[p.jsxs(Re,{sx:{position:"relative",maxWidth:"1200px",margin:"0 auto",paddingTop:"24px"},children:[Array.isArray(s?.sourceInfos)&&s.sourceInfos.length>0&&p.jsxs(Wn,{spacing:2,component:"section",children:[p.jsxs(Re,{sx:{padding:"0 0 16px 0",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[p.jsx(wt,{variant:"h1",sx:{fontSize:"28px",fontWeight:"600",color:"#1a1a1a",marginBottom:"8px",marginTop:"0",paddingLeft:"0"},children:"Sources"}),p.jsx(Br,{title:"Copy link",children:p.jsx(no,{size:"small","aria-label":"Copy link",onClick:_,sx:{color:"text.secondary"},children:p.jsx(sT,{fontSize:"small"})})})]}),p.jsx(nB,{data:s,onChange:F,onSourceChange:L,existingQuery:y,initialSelectedSourceIndex:w,resourceUri:t,givens:O,onGivensChange:P}),p.jsx(Lp,{"aria-label":"Expand results",sx:{position:"absolute",top:"90px",right:"4px",zIndex:2},onClick:()=>g(!0),children:p.jsx(Gp,{})})]}),s?.queries?.length>0&&p.jsxs(Wn,{spacing:2,component:"section",sx:{marginTop:"24px"},children:[p.jsx(Re,{sx:{padding:"0 0 16px 0"},children:p.jsx(wt,{variant:"h2",sx:{fontSize:"24px",fontWeight:"600",color:"#1a1a1a",marginBottom:"0",marginTop:"8px",paddingLeft:"0"},children:"Named Queries"})}),s.queries.map(R=>p.jsx(s$e,{queryName:R.name,annotations:R.annotations,resourceUri:t,runOnDemand:n,maxResultSize:r},R.name))]}),(!Array.isArray(s?.sourceInfos)||s.sourceInfos.length===0)&&!(s?.queries&&s.queries.length>0)&&p.jsxs(Re,{sx:{textAlign:"center",py:6},children:[p.jsx(wt,{variant:"body1",sx:{color:"text.secondary",marginBottom:"8px"},children:"This model exposes no sources or queries."}),A&&p.jsxs(wt,{variant:"body2",color:"text.secondary",children:["It imports other files but re-exports nothing. Add"," ",p.jsxs("code",{children:["export ","{ source_name }"]})," to surface imported sources here."]})]}),p.jsx(rB,{open:m,onClose:()=>g(!1),resourceUri:t,data:s,title:`Model: ${i.split("/").pop()}`,existingQuery:y,initialSelectedSourceIndex:w,onChange:F,onSourceChange:L,givens:O,onGivensChange:P})]}),p.jsx(ph,{open:b!=="",autoHideDuration:6e3,onClose:()=>$(""),message:b})]})}function m$e(){const[e,t]=C.useState("");return p.jsxs(p.Fragment,{children:[p.jsx(Br,{title:"Copy link",children:p.jsx(no,{size:"small","aria-label":"Copy link",onClick:()=>{navigator.clipboard.writeText(window.location.href).then(()=>t("URL copied to clipboard!")).catch(()=>t("Failed to copy URL"))},sx:{color:"text.secondary"},children:p.jsx(sT,{fontSize:"small"})})}),p.jsx(ph,{open:e!=="",autoHideDuration:6e3,onClose:()=>t(""),message:e})]})}function $Te(e){const{modelPage:t,isLoadingStatus:n}=er();if(n)return p.jsx(Go,{text:"Fetching Model..."});if(t!=="viewer")return p.jsx(h$e,{...e});const{onChange:r,runOnDemand:o,headerActions:a,...i}=e;return p.jsx(a$e,{...i,headerActions:a??p.jsx(m$e,{})})}const g$e={"persist-source-refused":"persist-not-built","preaggregate-not-built":"rollup-not-built","preaggregate-join-one-key-repeated":"rollup-join-one-key-repeated","stored-native-schema-missing":"database-native-type-missing"};function y$e(e){const t=(r,o)=>`${r}\0${o.subject??""}\0${o.message??""}`,n=new Set(e.map(r=>t(r.code,r)));return e.filter(r=>{const o=r.code!==void 0?g$e[r.code]:void 0;return o===void 0||!n.has(t(o,r))})}function v$e({warnings:e}){const[t,n]=C.useState(!1),r=y$e(e??[]),o=r.filter(i=>i.severity==="error"),a=r.filter(i=>i.severity!=="error");return o.length===0&&a.length===0?null:p.jsxs(Wn,{sx:{gap:1,mb:4},children:[o.length>0&&p.jsxs(xo,{severity:"warning",children:[p.jsx(mY,{children:o.length===1?"1 problem in this package":`${o.length} problems in this package`}),p.jsx(JI,{findings:o})]}),a.length>0&&p.jsxs(Re,{children:[p.jsxs(Hn,{size:"small","aria-expanded":t,onClick:()=>n(i=>!i),sx:{px:.5,color:"text.secondary"},children:[t?"Hide":"Show"," ",a.length," ",a.length===1?"note":"notes"]}),t&&p.jsx(Re,{sx:{pl:.5,pt:.5},children:p.jsx(JI,{findings:a})})]})]})}function JI({findings:e}){return p.jsx(Wn,{component:"ul",sx:{m:0,p:0,listStyle:"none",gap:.75},children:e.map((t,n)=>p.jsxs(wt,{component:"li",variant:"body2",children:[t.model&&p.jsx(Re,{component:"span",sx:{fontFamily:Fo,fontSize:"0.85em",mr:1},children:t.model}),t.message]},`${t.model??""}:${t.code??""}:${n}`))})}function b$e(e){return C.useMemo(()=>{if(!e?.sources?.length)return[];const t=new Map;for(const n of e.sources)if(n.givens?.length)for(const r of n.givens)r.name&&!t.has(r.name)&&t.set(r.name,r);return Array.from(t.values())},[e])}function x$e(e){return e.type==="code"}function w$e(e){return(e.text??"").split(`
|
|
510
|
+
`);bT(k,"typescript",$).then(T=>{i(T)})}},[t,$]),p.jsxs(Re,{children:[a&&p.jsx(Re,{sx:{marginBottom:"16px"},children:p.jsx(wt,{fontSize:"12px",sx:{fontSize:"12px","& .line":{textWrap:"wrap"}},children:p.jsx("div",{className:"content",dangerouslySetInnerHTML:{__html:a}})})}),p.jsxs(Re,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"8px"},children:[p.jsx(wt,{variant:"body2",sx:{fontSize:"15px",fontWeight:600,color:"text.primary",px:2,py:1,bgcolor:"action.hover",borderRadius:1.5,border:1,borderColor:"divider"},children:e}),p.jsx(Lp,{"aria-label":"Expand results",onClick:()=>l(!0),children:p.jsx(Gp,{})})]}),p.jsxs(g4,{sx:{position:"relative"},children:[r&&!d&&p.jsxs(Re,{sx:{padding:"40px 20px",textAlign:"center",display:"flex",flexDirection:"column",alignItems:"center",gap:"16px"},children:[p.jsx(wt,{variant:"body2",color:"text.secondary",children:"Click Run to execute the query"}),p.jsx(Hn,{variant:"contained",startIcon:p.jsx(i$e,{}),onClick:()=>u(!0),children:"Run Query"})]}),w&&p.jsx(G2,{state:S,context:e,maxHeight:Mle,maxResultSize:o})]}),p.jsx(eB,{open:s,onClose:()=>l(!1),result:b?.data?.result||"",renderLogs:b?.data?.renderLogs,title:`Query: ${e}`})]})}function l$e(e){return e!=null}function c$e(e,t){const n=[],r=[];for(const a of e){if(a.name===void 0||l$e(t.get(a.name)))continue;if(a.default==null){n.push(a.name);continue}const i=j1(a.type??"string",a.default);i&&r.push(`${a.name} = ${i}`)}const o={missing:n};return r.length>0&&(o.defaultsNote=r.length===1?`Ran with the default ${r[0]}`:`Ran with defaults ${r.join(", ")}`),o}function u$e(e){return e.length===1?`This source may need a value for the given ${e[0]}. Set it in the parameters above.`:`This source may need values for the givens ${e.join(", ")}. Set them in the parameters above.`}function d$e({sourceAndPaths:e,selectedSourceIndex:t,existingQuery:n,onQueryChange:r,onSourceChange:o,resourceUri:a,givens:i,gate:s}){return Cn.useEffect(()=>{o&&o(t)},[t,o]),p.jsx(m4,{children:p.jsxs(x9,{spacing:2,component:"section",children:[p.jsx(p$e,{sourceAndPath:e[t],existingQuery:n,onChange:l=>{r&&r(l)},resourceUri:a,givens:i,gate:s}),p.jsx(f5,{height:"5px"})]})})}function NC(){return{query:void 0,malloyQuery:void 0,malloyResult:void 0}}function f$e({sourceAndPath:e,onChange:t,existingQuery:n,explorerComponents:r,QueryBuilder:o,resourceUri:a,givens:i,gate:s}){const[l,d]=Cn.useState(n||NC()),[u,m]=Cn.useState(void 0);Cn.useEffect(()=>{n&&d(n)},[n]);const[g,y]=Cn.useState([]),{MalloyExplorerProvider:x,QueryPanel:w,ResizableCollapsiblePanel:S,ResultPanel:b,SourcePanel:$}=r;Cn.useEffect(()=>{t&&t(l)},[t,l]);const{environmentName:k,packageName:T,versionId:O}=ko(a),{apiClients:P}=er(),D=Cn.useRef(void 0),A=hl({mutationFn:()=>{D.current=s,m({executionState:"running",query:l?.malloyQuery,queryResolutionStartMillis:Date.now(),onCancel:()=>{A.reset(),m(void 0)},response:{}});const R=typeof l?.malloyQuery=="string"?l.malloyQuery:new o.ASTQuery({source:e.sourceInfo,query:l?.malloyQuery}).toMalloy();return d({...l,query:R}),P.models.executeQueryModel(k,T,e.modelPath,{query:R,sourceName:void 0,queryName:void 0,versionId:O,...i&&Object.keys(i).length>0?{givens:i}:{}})},onSuccess:R=>{if(R){const z=JSON.parse(R.data.result);d({...l,malloyResult:z});const I=D.current;m(U=>U?{...U,executionState:"finished",response:{result:z,...I?.defaultsNote?{messages:[{severity:"INFO",title:I.defaultsNote}]}:{}}}:void 0)}},onError:R=>{console.error("Query execution error:",R);const z=R?.data?.message??R?.message??"The query could not be run.",I=[{severity:"ERROR",title:z}],U=D.current?.missing??[];(R?.status===403||/Access denied for source/i.test(z))&&U.length>0&&I.push({severity:"WARN",title:u$e(U)}),m(N=>N?{...N,executionState:"finished",response:{messages:I}}:void 0)}}),[F,L]=Cn.useState(e.sourceInfo.name);Cn.useEffect(()=>{F!==e.sourceInfo.name&&(L(e.sourceInfo.name),d(NC()),m(void 0))},[e,F]);const _=Cn.useCallback(R=>{d({...l,malloyQuery:R,malloyResult:void 0})},[l]);return F!==e.sourceInfo.name?p.jsx("div",{children:"Loading..."}):p.jsx(y4,{sx:{border:"1px solid #e0e0e0",borderRadius:"8px",overflow:"hidden"},children:p.jsx(x,{source:e.sourceInfo,query:l?.malloyQuery,topValues:[],onFocusedNestViewPathChange:y,focusedNestViewPath:g,onQueryChange:_,children:p.jsxs("div",{style:{display:"flex",height:"100%",overflowY:"auto"},children:[p.jsx(S,{isInitiallyExpanded:!0,initialWidth:180,minWidth:180,icon:"database",title:e.sourceInfo.name,children:p.jsx($,{onRefresh:()=>d(NC())})}),p.jsx(S,{isInitiallyExpanded:!0,initialWidth:280,minWidth:280,icon:"filterSliders",title:"Query",children:p.jsx(w,{runQuery:()=>{console.log(`running query with: ${l?.malloyQuery}`);try{A.mutate()}catch(R){console.error("Error running query:",R)}}})}),p.jsx(b,{source:e.sourceInfo,draftQuery:l?.malloyQuery,setDraftQuery:R=>d({...l,malloyQuery:R}),submittedQuery:u,options:{showRawQuery:!0}})]})})},e.sourceInfo.name)}function p$e(e){const[t,n]=C.useState(null),[r,o]=C.useState(null),[a,i]=C.useState(!0);return C.useEffect(()=>{let s=!0;return Promise.all([vo(()=>import("./index-BZA1HAyp.js"),__vite__mapDeps([5,0,1,2,6])),F0e()]).then(([l,d])=>{s&&(n(l),o(d),i(!1))}).catch(l=>{console.error("Failed to load Malloy components:",l),s&&i(!1)}),()=>{s=!1}},[]),a||!t||!r?p.jsx(qne,{children:p.jsx(y4,{children:p.jsx(f5,{sx:{alignItems:"center",justifyContent:"center",height:"200px",color:"text.secondary"},children:"Loading explorer..."})})}):p.jsx(f$e,{...e,explorerComponents:t,QueryBuilder:r,resourceUri:e.resourceUri})}function tB(e,t=!0){const{modelPath:n,environmentName:r,packageName:o,versionId:a}=ko(e),{apiClients:i}=er();return wo({queryKey:["package",r,o,n,a],queryFn:async()=>(await i.models.getModel(r,o,n,a)).data,enabled:t})}function nB({data:e,onChange:t,existingQuery:n,initialSelectedSourceIndex:r=0,onSourceChange:o,resourceUri:a,givens:i,onGivensChange:s,startingGivens:l}){const[d,u]=Cn.useState(r);Cn.useEffect(()=>{u(r)},[r]);const{data:m,isError:g,isLoading:y,error:x}=tB(a,!e),{environmentName:w,packageName:S,modelPath:b,versionId:$}=ko(a),k=e||m,T=Cn.useMemo(()=>k?.givens??[],[k]),O=g2({specs:T,loaded:!!k,params:i,onGivensChange:s,startingValues:l,documentKey:a,autorun:!0,environmentName:w??"",packageName:S??"",modelPath:b,versionId:$,documentName:b}),P=C.useMemo(()=>Zd(O.applied,O.declaredTypes),[O.applied,O.declaredTypes]),D=C.useMemo(()=>c$e(T,O.applied),[T,O.applied]);if(y&&!e)return p.jsx(Go,{text:"Fetching Model..."});if(g&&!e)return console.log("error",x),p.jsx(Xa,{error:x,context:`ModelExplorer > ${b}`});if(!k)return p.jsx(Go,{text:qd.loading});const A=(k?.sourceInfos||[]).map((L,_)=>{try{return JSON.parse(L)?.name||`Source ${_+1}`}catch{return`Source ${_+1}`}}),F=A[d]||"";return p.jsxs(Une,{variant:"outlined",children:[p.jsx(Vne,{children:p.jsx(Wn,{sx:{flexDirection:"row"},children:p.jsx(uwe,{size:"small",id:"size-small-standard",disablePortal:!0,options:A,value:F,onChange:(L,_)=>{if(!_)return;const R=A.indexOf(_);R>=0&&(u(R),o?.(R))},renderInput:L=>p.jsx(yr,{...L}),style:{width:350,marginTop:"3px",marginLeft:"6px",marginBottom:"8px"}})})}),p.jsx(A1,{...O.panel}),p.jsx(m4,{children:p.jsxs(Wn,{spacing:2,component:"section",children:[Array.isArray(k.sourceInfos)&&k.sourceInfos.length>0&&p.jsx(d$e,{sourceAndPaths:k.sourceInfos.map(L=>({sourceInfo:JSON.parse(L),modelPath:b})),selectedSourceIndex:d,existingQuery:n,onQueryChange:t,resourceUri:a,givens:P,gate:D}),p.jsx(Re,{height:"5px"})]})})]})}function rB({open:e,onClose:t,resourceUri:n,data:r,title:o="Data Sources",hasValidImport:a=!0,existingQuery:i,initialSelectedSourceIndex:s,onChange:l,onSourceChange:d,givens:u,onGivensChange:m,startingGivens:g}){return p.jsxs(Fx,{open:e,onClose:t,fullScreen:!0,children:[p.jsxs(Bx,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[o,p.jsx(no,{onClick:t,sx:{color:"text.secondary"},children:p.jsx(bh,{})})]}),p.jsx(_x,{children:a?p.jsx(nB,{resourceUri:n,data:r,existingQuery:i,initialSelectedSourceIndex:s,onChange:l,onSourceChange:d,givens:u,onGivensChange:m,startingGivens:g}):p.jsx("div",{children:"No valid import statement found in cell"})})]})}function h$e({onChange:e,resourceUri:t,runOnDemand:n=!1,maxResultSize:r=0,givens:o,onGivensChange:a}){const{modelPath:i}=ko(t),{data:s,isError:l,isLoading:d,error:u}=tB(t),[m,g]=Cn.useState(!1),[y,x]=Cn.useState(),[w,S]=Cn.useState(0),[b,$]=C.useState(""),[k,T]=Cn.useState({}),O=o??k,P=a??(R=>T(R)),D=s?.modelDef,A=Cn.useMemo(()=>{if(!D)return!1;try{const R=JSON.parse(D);return Array.isArray(R.imports)&&R.imports.length>0}catch{return!1}},[D]);if(d)return p.jsx(Go,{text:"Fetching Model..."});if(l)return console.log("error",u),p.jsx(Xa,{error:u,context:`Model > ${i}`});const F=R=>{x(R),e&&e(R)},L=R=>{S(R)},_=()=>{const R=window.location.href;navigator.clipboard.writeText(R).then(()=>$("URL copied to clipboard!")).catch(()=>$("Failed to copy URL"))};return p.jsxs(p.Fragment,{children:[p.jsxs(Re,{sx:{position:"relative",maxWidth:"1200px",margin:"0 auto",paddingTop:"24px"},children:[Array.isArray(s?.sourceInfos)&&s.sourceInfos.length>0&&p.jsxs(Wn,{spacing:2,component:"section",children:[p.jsxs(Re,{sx:{padding:"0 0 16px 0",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[p.jsx(wt,{variant:"h1",sx:{fontSize:"28px",fontWeight:"600",color:"#1a1a1a",marginBottom:"8px",marginTop:"0",paddingLeft:"0"},children:"Sources"}),p.jsx(Br,{title:"Copy link",children:p.jsx(no,{size:"small","aria-label":"Copy link",onClick:_,sx:{color:"text.secondary"},children:p.jsx(sT,{fontSize:"small"})})})]}),p.jsx(nB,{data:s,onChange:F,onSourceChange:L,existingQuery:y,initialSelectedSourceIndex:w,resourceUri:t,givens:O,onGivensChange:P}),p.jsx(Lp,{"aria-label":"Expand results",sx:{position:"absolute",top:"90px",right:"4px",zIndex:2},onClick:()=>g(!0),children:p.jsx(Gp,{})})]}),s?.queries?.length>0&&p.jsxs(Wn,{spacing:2,component:"section",sx:{marginTop:"24px"},children:[p.jsx(Re,{sx:{padding:"0 0 16px 0"},children:p.jsx(wt,{variant:"h2",sx:{fontSize:"24px",fontWeight:"600",color:"#1a1a1a",marginBottom:"0",marginTop:"8px",paddingLeft:"0"},children:"Named Queries"})}),s.queries.map(R=>p.jsx(s$e,{queryName:R.name,annotations:R.annotations,resourceUri:t,runOnDemand:n,maxResultSize:r},R.name))]}),(!Array.isArray(s?.sourceInfos)||s.sourceInfos.length===0)&&!(s?.queries&&s.queries.length>0)&&p.jsxs(Re,{sx:{textAlign:"center",py:6},children:[p.jsx(wt,{variant:"body1",sx:{color:"text.secondary",marginBottom:"8px"},children:"This model exposes no sources or queries."}),A&&p.jsxs(wt,{variant:"body2",color:"text.secondary",children:["It imports other files but re-exports nothing. Add"," ",p.jsxs("code",{children:["export ","{ source_name }"]})," to surface imported sources here."]})]}),p.jsx(rB,{open:m,onClose:()=>g(!1),resourceUri:t,data:s,title:`Model: ${i.split("/").pop()}`,existingQuery:y,initialSelectedSourceIndex:w,onChange:F,onSourceChange:L,givens:O,onGivensChange:P})]}),p.jsx(ph,{open:b!=="",autoHideDuration:6e3,onClose:()=>$(""),message:b})]})}function m$e(){const[e,t]=C.useState("");return p.jsxs(p.Fragment,{children:[p.jsx(Br,{title:"Copy link",children:p.jsx(no,{size:"small","aria-label":"Copy link",onClick:()=>{navigator.clipboard.writeText(window.location.href).then(()=>t("URL copied to clipboard!")).catch(()=>t("Failed to copy URL"))},sx:{color:"text.secondary"},children:p.jsx(sT,{fontSize:"small"})})}),p.jsx(ph,{open:e!=="",autoHideDuration:6e3,onClose:()=>t(""),message:e})]})}function $Te(e){const{modelPage:t,isLoadingStatus:n}=er();if(n)return p.jsx(Go,{text:"Fetching Model..."});if(t!=="viewer")return p.jsx(h$e,{...e});const{onChange:r,runOnDemand:o,headerActions:a,...i}=e;return p.jsx(a$e,{...i,headerActions:a??p.jsx(m$e,{})})}const g$e={"persist-source-refused":"persist-not-built","preaggregate-not-built":"rollup-not-built","preaggregate-join-one-key-repeated":"rollup-join-one-key-repeated","stored-native-schema-missing":"database-native-type-missing"};function y$e(e){const t=(r,o)=>`${r}\0${o.subject??""}\0${o.message??""}`,n=new Set(e.map(r=>t(r.code,r)));return e.filter(r=>{const o=r.code!==void 0?g$e[r.code]:void 0;return o===void 0||!n.has(t(o,r))})}function v$e({warnings:e}){const[t,n]=C.useState(!1),r=y$e(e??[]),o=r.filter(i=>i.severity==="error"),a=r.filter(i=>i.severity!=="error");return o.length===0&&a.length===0?null:p.jsxs(Wn,{sx:{gap:1,mb:4},children:[o.length>0&&p.jsxs(xo,{severity:"warning",children:[p.jsx(mY,{children:o.length===1?"1 problem in this package":`${o.length} problems in this package`}),p.jsx(JI,{findings:o})]}),a.length>0&&p.jsxs(Re,{children:[p.jsxs(Hn,{size:"small","aria-expanded":t,onClick:()=>n(i=>!i),sx:{px:.5,color:"text.secondary"},children:[t?"Hide":"Show"," ",a.length," ",a.length===1?"note":"notes"]}),t&&p.jsx(Re,{sx:{pl:.5,pt:.5},children:p.jsx(JI,{findings:a})})]})]})}function JI({findings:e}){return p.jsx(Wn,{component:"ul",sx:{m:0,p:0,listStyle:"none",gap:.75},children:e.map((t,n)=>p.jsxs(wt,{component:"li",variant:"body2",children:[t.model&&p.jsx(Re,{component:"span",sx:{fontFamily:Fo,fontSize:"0.85em",mr:1},children:t.model}),t.message]},`${t.model??""}:${t.code??""}:${n}`))})}function b$e(e){return C.useMemo(()=>{if(!e?.sources?.length)return[];const t=new Map;for(const n of e.sources)if(n.givens?.length)for(const r of n.givens)r.name&&!t.has(r.name)&&t.set(r.name,r);return Array.from(t.values())},[e])}function x$e(e){return e.type==="code"}function w$e(e){return(e.text??"").split(`
|
|
511
511
|
`).filter(t=>!t.trimStart().startsWith("##")).join(`
|
|
512
|
-
`)}const S$e=rn(p.jsx("path",{d:"M9.4 16.6 4.8 12l4.6-4.6L8 6l-6 6 6 6zm5.2 0 4.6-4.6-4.6-4.6L16 6l6 6-6 6z"}));function C$e({cell:e,resourceUri:t,showCopyLink:n,maxResultSize:r,isExecuting:o,pendingRerun:a,onNavigate:i,onDrillSelf:s,canDrillSelf:l,onDrillNavigate:d,givens:u,givenSpecs:m}){const[g,y]=Cn.useState(!1),[x,w]=Cn.useState(!1),[S,b]=Cn.useState(),[$,k]=Cn.useState(!1),{modelPage:T,isLoadingStatus:O}=er(),P=!O&&T!=="viewer",[D,A]=C.useState(""),{environmentName:F,packageName:L,modelPath:_}=ko(t),R={environmentName:F,packageName:L,sourcePath:_,onNavigate:i},{drill:z,drillMenu:I}=K_({onNavigate:d,onSelf:s,canSelf:l}),U=/import\s*\{([^}]+)\}\s*from\s*['"`][^'"`]+['"`]/,N=/import\s*(?:\{[^}]*\}\s*from\s*)?['"`]([^'"`]+)['"`]/,q=!!e.text&&(U.test(e.text)||N.test(e.text)),Y=()=>{if(!e.newSources||e.newSources.length===0)return 0;let X=[],se="";if(e.text){const J=e.text.match(U);J&&(X=J[1].split(",").map(G=>G.trim()));const Z=e.text.match(N);Z&&(se=Z[1].trim())}for(let J=0;J<e.newSources.length;J++)try{const Z=JSON.parse(e.newSources[J]);if(X.length>0&&X.includes(Z.name)||se&&se===Z.path)return J}catch{continue}return 0},oe=Cn.useMemo(()=>e.newSources&&e.newSources.length>0?{sourceInfos:e.newSources,resource:t,givens:m}:void 0,[e.newSources,t,m]),{mode:Q}=Hr();C.useEffect(()=>{e.type==="code"&&bT(w$e(e),"malloy",Q).then(X=>{b(X)})},[e,Q]);const ae=()=>{const X=window.location.href;navigator.clipboard.writeText(X).then(()=>A("URL copied to clipboard!")).catch(()=>A("Failed to copy URL"))},de=p.jsx(Oo,{open:g,onClose:()=>y(!1),title:"Malloy code",maxWidth:"lg",showClose:!0,children:p.jsx(Re,{sx:X=>({border:`1px solid ${X.palette.divider}`,borderRadius:"8px",padding:"16px",fontFamily:Fo,fontSize:"14px",lineHeight:"1.5",overflow:"auto",maxHeight:"70vh",backgroundColor:X.palette.background.paper,color:X.palette.text.primary}),children:p.jsx("pre",{className:"code-display",style:{margin:0},dangerouslySetInnerHTML:{__html:S}})})});return e.type==="markdown"&&p.jsx(Re,{children:p.jsxs(Q2,{children:[n?p.jsxs(Wn,{direction:"row",alignItems:"flex-start",justifyContent:"space-between",children:[p.jsx(xy,{variant:"document",links:R,children:e.text}),p.jsx(Br,{title:"Copy link",children:p.jsx(no,{"aria-label":"Copy link",onClick:ae,sx:{color:"text.secondary",mt:"18px"},children:p.jsx(sT,{sx:{fontSize:"24px"}})})})]}):p.jsx(xy,{variant:"document",links:R,children:e.text}),p.jsx(ph,{open:D!=="",autoHideDuration:6e3,onClose:()=>A(""),message:D})]})})||e.type==="code"&&p.jsxs(Re,{children:[e.newSources&&e.newSources.length>0&&p.jsx(Wn,{sx:{flexDirection:"column",gap:"8px",marginBottom:"2px"},children:p.jsx(g4,{sx:{position:"relative",padding:"0"},children:p.jsxs(Re,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingLeft:"24px",paddingRight:"8px"},children:[S&&p.jsx("span",{dangerouslySetInnerHTML:{__html:S},style:{fontFamily:Fo,fontSize:"14px",flex:1,marginRight:"8px"}}),q&&P&&p.jsx(Lp,{"aria-label":"Data sources",sx:{flexShrink:0},onClick:()=>k(!0),children:p.jsx(Gp,{})})]})})}),p.jsx(rB,{open:$&&P,onClose:()=>k(!1),title:"Data Sources",hasValidImport:q,resourceUri:t,data:oe,initialSelectedSourceIndex:Y(),startingGivens:u}),de,p.jsx(eB,{open:x,onClose:()=>w(!1),result:e.result||"",title:"Results",drill:z}),o&&!e.result&&!e.error&&!q&&!(e.newSources&&e.newSources.length>0)&&p.jsx(Z0,{children:p.jsx(Re,{sx:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:200},children:p.jsx(Cu,{size:32})})}),!e.result&&e.error&&p.jsx(bF,{summary:"This cell could not be run.",detail:e.error}),e.result&&a&&p.jsx(uz,{"aria-label":"Re-run pending",sx:{mb:1,height:2,borderRadius:1}}),e.result&&p.jsxs(Z0,{children:[p.jsx(w_,{title:"",action:p.jsxs(Wn,{direction:"row",sx:{gap:.5,mt:"-4px"},children:[p.jsx(Lp,{"aria-label":"Malloy code",onClick:X=>{X.stopPropagation(),y(!0)},children:p.jsx(S$e,{})}),p.jsx(Lp,{"aria-label":"Expand results",onClick:()=>w(!0),children:p.jsx(Gp,{})})]})}),p.jsx(D1,{result:e.result,maxHeight:Rle,maxResultSize:r,drill:z}),I]})]})}function k$e({ready:e,lastRunKey:t,pendingKey:n,runKey:r,documentKey:o}){if(!e)return{cancelPending:n!==void 0,dispatch:"none"};const a=n!==void 0&&n!==r;if(t===r)return{cancelPending:a,dispatch:"none"};if(n===r)return{cancelPending:a,dispatch:"none"};const i=t===null||!t.startsWith(`${o}|`);return{cancelPending:a,dispatch:i?"now":"settle"}}const $$e=4;function R$e(e){const t=e?.response?.data?.message;return typeof t=="string"&&t!==""?t:e instanceof Error&&e.message!==""?e.message:"The server did not say why."}function T$e({resourceUri:e,maxResultSize:t=0,givens:n,onGivensChange:r,onNavigate:o,onDrillNavigate:a,actions:i,notebook:s,runCell:l}){const{environmentName:d,packageName:u,versionId:m,modelPath:g}=ko(e),[y,x]=C.useState([]),[w,S]=C.useState(!1),[b,$]=C.useState(!1),k=C.useRef(void 0),[T,O]=C.useState(null),P=b$e(s),D=s.autorun!==!1,A=y1(),F=g2({specs:P,loaded:!0,startingValues:s.startingGivens,params:n,onGivensChange:r,documentKey:e,autorun:D,environmentName:d,packageName:u,modelPath:g,versionId:m,documentName:g}),{applied:L,declaredTypes:_,canSelf:R,onSelf:z}=F,I=C.useCallback(Z=>{const G=Zd(Z,_);return Object.keys(G).length>0?JSON.stringify(G):void 0},[_]),U=C.useMemo(()=>m0(L,_),[L,_]),N=C.useRef(0),q=C.useRef(null),Y=C.useRef(null),oe=C.useRef(void 0);C.useEffect(()=>()=>{q.current?.abort(),Y.current=null,clearTimeout(oe.current?.timer),oe.current=void 0},[]);const Q=C.useCallback(async(Z=new Map)=>{if(!s.notebookCells)return;const G=++N.current;q.current?.abort();const ue=new AbortController;q.current=ue,x(s.notebookCells.map(ie=>({...ie}))),S(!0),O(null);try{const ie=[];for(let he=0;he<s.notebookCells.length;he++){const me=s.notebookCells[he];if(!x$e(me))continue;const le=he,ve=async()=>{try{const Le=await l({cell:me,givens:Z,declaredTypes:_,signal:ue.signal});if(N.current!==G)return;const Ie=Le.result;x(Te=>{const ne=[...Te];return ne[le]||(ne[le]={...me}),ne[le]={...ne[le],result:Ie},ne})}catch(Le){if(ue.signal.aborted||N.current!==G)return;A.emit({type:"report.query_failed",tile:le,category:V0(Le)}),A.listening||console.error(`Error executing cell ${le}:`,Le);const Ie=R$e(Le);x(Te=>{const ne=[...Te];return ne[le]||(ne[le]={...me}),ne[le]={...ne[le],error:Ie},ne})}};ie.push(ve)}const fe=[];for(const he of ie){const me=he().then(()=>{fe.splice(fe.indexOf(me),1)});fe.push(me),fe.length>=$$e&&await Promise.race(fe)}await Promise.all(fe)}catch(ie){if(ue.signal.aborted||N.current!==G)return;A.emit({type:"report.query_failed",category:V0(ie)}),A.listening||console.error("Error executing notebook cells:",ie),O(ie)}finally{N.current===G&&(S(!1),q.current=null)}},[s,_,l,A]),ae=C.useRef(0),de=C.useRef(void 0);de.current!==s&&(de.current=s,ae.current+=1);const X=ae.current;C.useEffect(()=>{const Z=`${e}|${X}`,G=`${Z}|${I(L)??""}`;k.current!==void 0&&k.current!==Z&&(q.current?.abort(),q.current=null),k.current=Z;const ue=k$e({ready:!!s.notebookCells,lastRunKey:Y.current,pendingKey:oe.current?.key,runKey:G,documentKey:Z});if(ue.cancelPending&&(clearTimeout(oe.current?.timer),oe.current=void 0,$(!1)),ue.dispatch==="none")return;const ie=()=>{oe.current=void 0,$(!1),Y.current=G,Q(L)};if(ue.dispatch==="now"){ie();return}$(!0),oe.current={key:G,timer:setTimeout(ie,a_)}},[s,X,e,L,I,Q]);const se=y.length>0?y:s.notebookCells||[],J=0;return p.jsxs(y$,{layout:"linear",header:i?p.jsx(Wn,{direction:"row",sx:{justifyContent:"flex-end"},children:i}):null,controls:F.panel.givens.length>0?p.jsx(S_,{children:p.jsx(A1,{...F.panel,layout:"bar"})}):void 0,children:[se.map((Z,G)=>p.jsx(C$e,{cell:Z,showCopyLink:G===J,resourceUri:e,maxResultSize:t,isExecuting:w,givens:U,givenSpecs:P,pendingRerun:b,onNavigate:o,onDrillNavigate:a,onDrillSelf:P.length>0?z:void 0,canDrillSelf:R},G)),T&&p.jsx(Xa,{error:{message:T.message,status:500,name:"ExecutionError"},context:"Notebook Execution"})]})}function E$e({environmentName:e,packageName:t,versionId:n,path:r,notebook:o,...a}){const{apiClients:i,server:s}=er(),l=C.useCallback(async({cell:d,givens:u,declaredTypes:m,signal:g})=>{const y=d.runQuery;if(y===void 0)return{};g.throwIfAborted();const x=Zd(u,m),w={environmentName:e,packageName:t,versionId:n,modelPath:r,query:y,givens:Object.keys(x).length>0?x:void 0},S=[...A_(w),s],b=()=>dy.fetchQuery({queryKey:S,queryFn:({signal:k})=>D_(i,w,k),...S4}),$=()=>void dy.cancelQueries({queryKey:S,exact:!0});g.addEventListener("abort",$,{once:!0});try{let k;try{k=await b()}catch(T){if(!mee(T)||g.aborted)throw T;k=await b()}return{result:k.data.result}}finally{g.removeEventListener("abort",$)}},[i,s,e,t,r,n]);return p.jsx(T$e,{...a,resourceUri:I1({environmentName:e,packageName:t,modelPath:r,versionId:n}),notebook:o,runCell:l})}function M$e({resourceUri:e,path:t,givens:n,onGivensChange:r,onNavigate:o,onLinkNavigate:a,height:i,maxResultSize:s,onEvent:l,chrome:d,manifestStaleTime:u,actions:m,rowsActions:g}){const y=ko(e),{apiClients:x}=er(),w=y.environmentName??"",S=y.packageName??"",b=y.versionId,$=!!y.environmentName&&!!y.packageName,{data:k,isSuccess:T,isError:O,error:P}=wo({...ixe(x,{environmentName:w,packageName:S,path:t,versionId:b},u),enabled:$&&t!==""}),D=k?.layout,A=Jle({path:t,layout:D},l),F=`${e}|${t}`,L=C.useRef(void 0),_=C.useRef({key:F,at:Od()});_.current.key!==F&&(_.current={key:F,at:Od()}),C.useEffect(()=>{L.current!==F&&($?O?(L.current=F,A.emit({type:"report.load_failed",surface:"view",category:V0(P)})):T&&k&&(L.current=F,A.emit({type:"report.opened",surface:"view",from:"package",tiles:k.tiles?.length??k.notebook?.notebookCells?.filter(U=>U.type==="code"&&U.runQuery!==void 0).length??0,durationMs:Od()-_.current.at})):(L.current=F,A.emit({type:"report.load_failed",surface:"view",category:"invalid"})))},[F,$,O,P,T,k,A]);const R=C.useCallback((U,N)=>{const q=o?.(U,N);q&&A.emit({type:"report.drill",to:"report",outcome:q})},[o,A]),z=o?R:void 0;if(!$)return p.jsxs(xo,{severity:"error",children:["A report resource URI must name an environment and a package. Received: ",e]});if(O)return p.jsx(Xa,{context:`${w} > ${S} > ${t}`,error:P});if(!T||!k)return p.jsx(Go,{text:qd.opening("report")});const I=k.notebook?.format==="malloynb"?p.jsx(E$e,{environmentName:w,packageName:S,versionId:b,path:t,notebook:k.notebook,givens:n,onGivensChange:r,onNavigate:a,onDrillNavigate:z,maxResultSize:s,...m!==void 0?{actions:m}:{}}):p.jsx(Bxe,{manifest:k,environmentName:w,packageName:S,versionId:b,documentName:t,givens:n,onGivensChange:r,onNavigate:z,...a?{onLinkNavigate:a}:{},height:i,maxResultSize:s,chrome:d,...m!==void 0?{actions:m}:{},...g!==void 0?{rowsActions:g}:{}});return p.jsx(wF.Provider,{value:A,children:I})}function O$e({open:e,layout:t,kind:n,allowLayoutChange:r,allowKindChange:o,environmentName:a,packageName:i,versionId:s,models:l,modelsLoading:d=!1,modelsError:u,onRetryModels:m,target:g,savedAs:y,onClose:x,onCreated:w,onEvent:S}){const b=t??(n?j_(n):"linear"),$=r??o??!0,[k,T]=C.useState(b),[O,P]=C.useState(void 0),[D,A]=C.useState(""),[F,L]=C.useState(""),[_,R]=C.useState(""),z=C.useRef(null),[I,U]=C.useState(""),[N,q]=C.useState(!1),[Y,oe]=C.useState(!1),[Q,ae]=C.useState(!1),[de,X]=C.useState(void 0),se=u!=null,{choices:J,isLoading:Z,isSuccess:G,failed:ue,retry:ie,canRetry:fe}=oxe({environmentName:a,packageName:i,...s!==void 0?{versionId:s}:{},models:l,enabled:e&&l.length>0}),he=C.useMemo(()=>J.get(D)??[],[J,D]),me=C.useMemo(()=>new Map([...J.entries()].flatMap(([st,At])=>At.map(tn=>[IC(st,tn.source,tn.view),{model:st,source:tn.source,view:tn.view}]))),[J]),le=C.useMemo(()=>{const st=J.size>1;return[...J.entries()].flatMap(([At,tn])=>{const Bt=new Map;for(const an of tn)Bt.set(an.source,[...Bt.get(an.source)??[],an]);return[...Bt.entries()].map(([an,$n])=>({key:`${At}::${an}`,label:an,ariaLabel:`${an} in ${At}`,...st||$n[0]?.sourceDescription?{detail:[st?At:void 0,$n[0]?.sourceDescription].filter(Boolean).join(" · ")}:{},entries:$n.map(Vt=>({key:IC(At,Vt.source,Vt.view),name:Vt.view,title:Vt.description??vC(Vt.view),...Vt.chart?{chart:Vt.chart}:{}}))}))})},[J]),ve=st=>{const At=me.get(st);At&&(A(At.model),L(`${At.source}::${At.view}`))},Le=he.find(st=>`${st.source}::${st.view}`===F),Ie=Le?IC(D,Le.source,Le.view):void 0,Te=P$e(Le,250);C.useEffect(()=>{e&&T(b)},[e,b]),C.useEffect(()=>{if(!e)return;const st=[...J.keys()];D===""&&st.length>0&&A(st[0])},[e,J,D]),C.useEffect(()=>{!e||he.length===0||F!==""||L(`${he[0].source}::${he[0].view}`)},[e,he,F]),C.useEffect(()=>{!e||N||Le===void 0||U(vC(Le.view))},[e,N,Le]),C.useEffect(()=>{e||(A(""),L(""),R(""),U(""),q(!1),P(void 0),oe(!1),X(void 0))},[e]);const ne=C.useMemo(()=>{if(I.trim()!=="")for(let st=1;st<=eT;st++){const At=E_(I,st);if(!g.existing?.includes(At))return At}},[I,g]),qe=O?.trim(),Oe=qe===void 0||qe===""?void 0:qe.endsWith(".malloy")?qe:`${qe}.malloy`,Qe=Oe??ne,nt=Oe===void 0?void 0:M_(Oe)??(g.existing?.includes(Oe)?`${Oe} already exists; choose another location.`:void 0),kt=(Le===void 0?void 0:Z2({title:I,modelPath:D,source:Le.source,view:Le.view}))??(I.trim()!==""&&Qe===void 0?"No free file name for this title; choose another.":void 0),Ut=kt!==void 0&&(Y||I.trim()!==""),at=d||Z,{theme:et}=Hr(),pt=et.ui,ze=Xd(et.cardBorder),be=J.size===0&&(se||ue.length>0),He=at?"Loading the model":be?"Couldn't read the model to start from":J.size===0?"Nothing in the model to start from yet":Le===void 0?"Pick what to start from":void 0,Me="report",$t=Q?`Creating ${Me}…`:`Create ${Me}`,Rt=F!==""&&Le===void 0&&he.length>0,vt=async()=>{if(!(He!==void 0||Le===void 0||Q)){if(kt!==void 0||nt!==void 0){oe(!0);return}ae(!0),X(void 0);try{const st=await Z0e({layout:k,...Oe!==void 0?{path:Oe}:{},document:{title:I,modelPath:D,source:Le.source,view:Le.view},target:g,...S?{onEvent:S}:{}});w(st)}catch(st){const At=st.response?.data?.message;X(At??(st instanceof Error?st.message:String(st)))}finally{ae(!1)}}},it=st=>p.jsx(Hn,{color:"inherit",size:"small",onClick:st,children:"Retry"});return p.jsx(Oo,{className:`${Sl.dialog} ${Sl.newReportDialog}`,maxWidth:"md",initialFocus:z,open:e,onClose:Q?()=>{}:x,title:`New ${Me}`,description:"A report is a Malloy file in the package that lays out text and queries. Pick what its first query shows; the rest is the builder.",actions:p.jsxs(p.Fragment,{children:[p.jsx(Hn,{onClick:x,disabled:Q,children:"Cancel"}),p.jsx(Br,{title:Q?"":He??"",children:p.jsx("span",{children:p.jsx(Hn,{variant:"contained",disabled:Q||He!==void 0,"aria-label":!Q&&He!==void 0?`${$t}: ${He}`:$t,onClick:()=>void vt(),children:$t})})})]}),children:p.jsxs(Wn,{sx:{gap:1.5},children:[se?p.jsx(xo,{severity:"error",action:m&&D4(u)?it(m):void 0,children:"Couldn't read this package's models, so no view is listed to start from."}):l.length===0?!d&&p.jsxs(xo,{severity:"info",children:["This package has no models yet. Add a .malloy file that declares a source with a view, then create a ",Me," from it."]}):ue.length>0?p.jsxs(xo,{severity:"warning",action:fe?it(ie):void 0,children:["Couldn't read ",ue.join(", "),", so nothing from"," ",ue.length===1?"it":"them"," is listed."]}):G&&J.size===0&&p.jsxs(xo,{severity:"info",children:["A ",Me," starts from a view of a source, and no model in this package declares one yet. Add a view to a source in a model file and this list fills in."]}),p.jsxs(Re,{sx:{mx:-3,mb:-1,borderTop:`1px solid ${ze}`,borderBottom:`1px solid ${ze}`,display:"grid",gridTemplateColumns:{xs:"1fr",md:"320px minmax(0, 1fr)"},height:{md:500}},children:[p.jsx(Re,{sx:{display:"flex",flexDirection:"column",minHeight:0,borderRight:{md:`1px solid ${ze}`},maxHeight:{xs:280,md:"none"}},children:p.jsx(Sle,{groups:le,query:_,onQuery:R,picked:Ie,onPick:ve,onTake:st=>{ve(st)},searchRef:z,disabled:Q,empty:p.jsx(wt,{variant:"body2",sx:{color:"text.secondary",p:2},children:at?"Reading the package's models…":"Nothing to start from."})})}),p.jsxs(Re,{sx:st=>({p:2.5,display:"flex",flexDirection:"column",gap:2,minHeight:0,overflowY:"auto",bgcolor:`color-mix(in srgb, ${st.palette.text.primary} 3%, ${st.palette.background.paper})`}),children:[$&&p.jsxs(Re,{children:[p.jsx(eL,{children:"Layout"}),p.jsx(Re,{role:"radiogroup","aria-label":"Layout",sx:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:1},children:["linear","grid"].map(st=>p.jsx(D$e,{layout:st,checked:k===st,disabled:Q,onPick:()=>T(st)},st))}),p.jsx(wt,{variant:"caption",component:"p",sx:{color:"text.secondary",mt:.75},children:"Switch it any time in the builder."})]}),p.jsxs(Re,{children:[p.jsx(eL,{children:"First query"}),p.jsx(Re,{role:"region","aria-label":"Preview",sx:st=>({height:200,display:"flex",position:"relative",overflow:"hidden",borderRadius:pt.radius.tile,border:`1px solid ${ze}`,bgcolor:st.palette.background.paper,"&::after":{content:'""',position:"absolute",left:0,right:0,bottom:0,height:40,pointerEvents:"none",background:`linear-gradient(to bottom, transparent, ${st.palette.background.paper})`}}),children:Le&&Te?p.jsx(Re,{sx:{flex:1,minWidth:0,px:2,pt:1.5},children:p.jsx(z_,{environmentName:a,packageName:i,...s!==void 0?{versionId:s}:{},modelPath:D,tile:`${Te.source} -> ${Te.view}`,label:I.trim()||vC(Te.view),borderless:!0,givens:j$e,declaredTypes:A$e,height:180})}):p.jsx(wt,{variant:"body2",sx:{color:"text.secondary",m:"auto"},children:Rt?"What you picked is no longer in this model; pick something else.":"Pick what to start from."})}),p.jsx(wt,{variant:"caption",component:"p",sx:{color:"text.secondary",mt:.75},children:"More are added in the builder."})]}),p.jsx(ki,{size:"small",label:"Title",value:I,disabled:Q,onChange:st=>{q(!0),U(st.target.value)},InputLabelProps:{shrink:!0},inputProps:{"aria-label":"Report title"},error:Ut,helperText:Ut?kt:g.route==="package"?"Names the file too, unless you type a location.":y??`Saved as a new ${Me} in the host's store, and opened in the builder.`}),p.jsx(ki,{size:"small",label:"Location",value:O??ne??"",placeholder:"report.malloy",disabled:Q,onChange:st=>P(st.target.value),InputLabelProps:{shrink:!0},inputProps:{"aria-label":"Location"},error:nt!==void 0,helperText:nt??(Qe?`Written as ${Qe} in the package, and opened in the builder.`:"A path in the package; the package root by default.")}),de&&p.jsx(xo,{severity:"error",children:de})]})]})]})})}function P$e(e,t){const[n,r]=C.useState(void 0);return C.useEffect(()=>{const o=window.setTimeout(()=>r(e),t);return()=>window.clearTimeout(o)},[e,t]),n}const IC=(e,t,n)=>`${e}::${t}::${n}`,j$e=new Map,A$e=new Map;function eL({children:e}){const t=Hr().theme.ui;return p.jsx(wt,{component:"div",sx:{...t.type.label,color:"text.secondary",mb:.75},children:e})}function D$e({layout:e,checked:t,disabled:n,onPick:r}){const{theme:o}=Hr(),a=o.ui,i=Xd(o.cardBorder),s=t?o.accent:"currentColor";return p.jsxs(rs,{role:"radio","aria-checked":t,"aria-label":e==="linear"?"Linear":"Grid",disabled:n,onClick:r,sx:l=>({justifyContent:"flex-start",gap:1.25,px:1.25,py:1,borderRadius:a.radius.tile,border:`1px solid ${t?o.accent:i}`,boxShadow:t?`0 0 0 1px ${o.accent}`:"none",bgcolor:t?`color-mix(in srgb, ${o.accent} 6%, ${l.palette.background.paper})`:l.palette.background.paper,color:l.palette.text.secondary,textAlign:"left"}),children:[p.jsx("svg",{width:"34",height:"26",viewBox:"0 0 34 26","aria-hidden":!0,children:e==="linear"?p.jsxs("g",{fill:"none",stroke:s,strokeWidth:"1.5",children:[p.jsx("rect",{x:"3",y:"2",width:"28",height:"7",rx:"1.5"}),p.jsx("rect",{x:"3",y:"12",width:"28",height:"5",rx:"1.5"}),p.jsx("path",{d:"M5 21.5h20",strokeLinecap:"round"})]}):p.jsxs("g",{fill:"none",stroke:s,strokeWidth:"1.5",children:[p.jsx("rect",{x:"2",y:"2",width:"14",height:"10",rx:"1.5"}),p.jsx("rect",{x:"18",y:"2",width:"14",height:"10",rx:"1.5"}),p.jsx("rect",{x:"2",y:"14",width:"30",height:"10",rx:"1.5"})]})}),p.jsxs(Re,{children:[p.jsx(Re,{sx:{...a.type.control,fontWeight:t?a.type.label.fontWeight:500,color:t?o.accent:"text.primary"},children:e==="linear"?"Linear":"Grid"}),p.jsx(Re,{sx:{...a.type.caption,color:"text.secondary"},children:e==="linear"?"Read top to bottom":"Tiles side by side"})]})]})}const N$e=rn(p.jsx("path",{d:"M21 11h-1.5v-.5h-2v3h2V13H21v1c0 .55-.45 1-1 1h-3c-.55 0-1-.45-1-1v-4c0-.55.45-1 1-1h3c.55 0 1 .45 1 1zM8 10v5H6.5v-1.5h-2V15H3v-5c0-.55.45-1 1-1h3c.55 0 1 .45 1 1m-1.5.5h-2V12h2zm7 1.5c.55 0 1 .45 1 1v1c0 .55-.45 1-1 1h-4V9h4c.55 0 1 .45 1 1v1c0 .55-.45 1-1 1M11 10.5v.75h2v-.75zm2 2.25h-2v.75h2z"})),I$e=rn(p.jsx("path",{d:"M15 4v2h3v12h-3v2h5V4zM4 20h5v-2H6V6h3V4H4z"})),L$e=rn(p.jsx("path",{d:"M4 7v2c0 .55-.45 1-1 1H2v4h1c.55 0 1 .45 1 1v2c0 1.65 1.35 3 3 3h3v-2H7c-.55 0-1-.45-1-1v-2c0-1.3-.84-2.42-2-2.83v-.34C5.16 11.42 6 10.3 6 9V7c0-.55.45-1 1-1h3V4H7C5.35 4 4 5.35 4 7m17 3c-.55 0-1-.45-1-1V7c0-1.65-1.35-3-3-3h-3v2h3c.55 0 1 .45 1 1v2c0 1.3.84 2.42 2 2.83v.34c-1.16.41-2 1.52-2 2.83v2c0 .55-.45 1-1 1h-3v2h3c1.65 0 3-1.35 3-3v-2c0-.55.45-1 1-1h1v-4z"})),z$e=rn(p.jsx("path",{d:"M20 10V8h-4V4h-2v4h-4V4H8v4H4v2h4v4H4v2h4v4h2v-4h4v4h2v-4h4v-2h-4v-4zm-6 4h-4v-4h4z"})),oB={dashboard:pr.blue,report:pr.violet,model:pr.cyan,dataApp:pr.pink,data:pr.lime,materialization:pr.amber,agent:pr.red};function aB({type:e,size:t=18,sx:n,...r}){return p.jsx(U0,{...r,viewBox:"0 0 24 24",sx:{width:t,height:t,fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",...n},children:F$e[e]()})}const F$e={report:_$e,model:B$e,data:U$e,materialization:V$e,dataApp:W$e,dashboard:q$e,agent:H$e};function _$e(){return p.jsxs(p.Fragment,{children:[p.jsx("path",{d:"M14 3 H6 a2 2 0 0 0 -2 2 v14 a2 2 0 0 0 2 2 h12 a2 2 0 0 0 2 -2 V9 z"}),p.jsx("path",{d:"M14 3 v4 a2 2 0 0 0 2 2 h4"}),p.jsx("path",{d:"M8 17 v-3"}),p.jsx("path",{d:"M12 17 v-6"}),p.jsx("path",{d:"M16 17 v-4"})]})}function B$e(){return p.jsxs(p.Fragment,{children:[p.jsx("path",{d:"M12 3 L4 7 v10 l8 4 l8 -4 V7 z"}),p.jsx("path",{d:"M4 7 l8 4 l8 -4"}),p.jsx("path",{d:"M12 11 v10"})]})}function U$e(){return p.jsxs(p.Fragment,{children:[p.jsx("rect",{x:"3.5",y:"3.5",width:"17",height:"17",rx:"2"}),p.jsx("path",{d:"M3.5 9.5 H20.5"}),p.jsx("path",{d:"M9.5 3.5 V20.5"})]})}function V$e(){return p.jsxs(p.Fragment,{children:[p.jsx("path",{d:"M12 3 L21 7.5 L12 12 L3 7.5 Z"}),p.jsx("path",{d:"M3 12 L12 16.5 L21 12"}),p.jsx("path",{d:"M3 16.5 L12 21 L21 16.5"})]})}function q$e(){return p.jsxs(p.Fragment,{children:[p.jsx("rect",{x:"3.5",y:"3.5",width:"17",height:"17",rx:"2"}),p.jsx("path",{d:"M3.5 9.5 H20.5"}),p.jsx("path",{d:"M12 9.5 V20.5"}),p.jsx("path",{d:"M12 15 H20.5"})]})}function H$e(){return p.jsxs(p.Fragment,{children:[p.jsx("circle",{cx:"12",cy:"8",r:"3.5"}),p.jsx("path",{d:"M5 20 a7 7 0 0 1 14 0"})]})}function W$e(){return p.jsxs(p.Fragment,{children:[p.jsx("rect",{x:"3.5",y:"4.5",width:"17",height:"15",rx:"2"}),p.jsx("path",{d:"M3.5 9.5 H20.5"}),p.jsx("path",{d:"M7 13.5 H17"}),p.jsx("path",{d:"M7 16.5 H13"})]})}function iB(e){return e>=1e9?`${(e/1e9).toFixed(1)} B rows`:e>=1e6?`${(e/1e6).toFixed(1)} M rows`:e>=1e3?`${(e/1e3).toFixed(1)} K rows`:`${e} rows`}const Y$e=12;function G$e(e){const t=e?.trim().toLowerCase()??"";if(t.startsWith("array")||t.endsWith("[]"))return I$e;if(t.startsWith("record")||t.startsWith("struct"))return L$e;switch(t.split(/[\s(<]/)[0]){case"string":return N$e;case"number":return z$e;case"date":return A6;case"timestamp":case"timestamptz":return N6;case"boolean":return I6;default:return L6}}function K$e({column:e}){const t=G$e(e.type);return p.jsxs(Re,{component:"li",sx:n=>({display:"flex",alignItems:"center",gap:1.25,px:1,py:.625,borderRadius:1,transition:"background-color 0.1s","&:hover":{backgroundColor:n.palette.mode==="dark"?"rgba(255, 255, 255, 0.06)":n.palette.grey[100]}}),children:[p.jsx(t,{"aria-hidden":!0,sx:{fontSize:18,color:"primary.main",flexShrink:0}}),p.jsxs(Re,{sx:{display:"flex",alignItems:"baseline",gap:1,minWidth:0,flex:1},children:[p.jsx(wt,{component:"span",sx:{fontFamily:Fo,fontSize:"0.8125rem",fontWeight:500,color:"text.primary",minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),e.type&&p.jsx(wt,{component:"span",variant:"caption",color:"text.secondary",sx:{flexShrink:0,maxWidth:"50%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.type})]})]})}function Q$e({database:e,onClose:t}){const n=e!==null,[r,o]=C.useState(e);e!==null&&e!==r&&o(e);const[a,i]=C.useState(""),[s,l]=C.useState(r?.path);s!==r?.path&&(l(r?.path),i(""));const d=C.useId(),u=r?.path??"",m=u.split("/").pop()||u,g=u.slice(0,Math.max(0,u.length-m.length-1)),y=r?.info?.rowCount,x=[g,y===void 0?null:iB(y)].filter(Boolean).join(" · "),w=C.useMemo(()=>r?.info?.columns??[],[r]),S=a.trim().toLowerCase(),b=C.useMemo(()=>S?w.filter($=>$.name?.toLowerCase().includes(S)||$.type?.toLowerCase().includes(S)):w,[w,S]);return p.jsxs(Oo,{open:n,onClose:t,showClose:!0,title:p.jsxs(Wn,{direction:"row",alignItems:"center",spacing:1.5,sx:{minWidth:0},children:[p.jsx(Re,{"aria-hidden":!0,sx:{width:32,height:32,borderRadius:1,bgcolor:oB.data,color:"#FFFFFF",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:p.jsx(aB,{type:"data",size:18})}),p.jsxs(Re,{sx:{minWidth:0},children:[p.jsx(wt,{component:"span",noWrap:!0,title:u,sx:{display:"block",fontFamily:Fo,fontSize:"1rem",fontWeight:600,letterSpacing:0,lineHeight:1.4},children:m||"Columns"}),x&&p.jsx(wt,{component:"span",variant:"caption",color:"text.secondary",noWrap:!0,sx:{display:"block",lineHeight:1.4},children:x})]})]}),children:[r?.error&&p.jsx(xo,{severity:"error",variant:"outlined",children:r.error}),r&&!r.error&&p.jsxs(Re,{component:"section","aria-labelledby":d,sx:{display:"flex",flexDirection:"column",border:"1px solid",borderColor:"divider",borderRadius:2,bgcolor:"background.paper",overflow:"hidden",mb:2},children:[p.jsxs(Wn,{direction:"row",alignItems:"center",spacing:1,sx:{px:1.5,py:1,minHeight:44,borderBottom:"1px solid",borderColor:"divider"},children:[p.jsxs(wt,{id:d,component:"h3",sx:{fontSize:"0.875rem",fontWeight:600},children:["Columns",p.jsxs(wt,{component:"span",variant:"caption",color:"text.secondary",sx:{ml:.75,fontVariantNumeric:"tabular-nums"},children:["· ",S?`${b.length} of `:"",w.length]})]}),w.length>Y$e&&p.jsx(zx,{value:a,onChange:$=>i($.target.value),placeholder:"Filter columns",inputProps:{"aria-label":"Filter columns"},startAdornment:p.jsx(MR,{position:"start",children:p.jsx(Gp,{sx:{fontSize:16,color:"text.secondary"}})}),sx:{ml:"auto !important",width:200,fontSize:"0.8125rem",px:1,py:.25,border:"1px solid",borderColor:"divider",borderRadius:1.5,"&.Mui-focused":{borderColor:"primary.main"}}})]}),p.jsx(Re,{sx:{overflowY:"auto",maxHeight:420,px:.75,py:.75},children:b.length===0?p.jsx(wt,{variant:"body2",color:"text.secondary",sx:{fontStyle:"italic",px:1,py:1},children:S?"No columns match":"No columns"}):p.jsx(Re,{component:"ul","aria-labelledby":d,sx:{listStyle:"none",m:0,p:0},children:b.map(($,k)=>p.jsx(K$e,{column:$},`${$.name}-${k}`))})})]})]})}const sB=(e,t,n)=>["packageVersions",e,t,n];async function lB(e,t,n){try{return(await e.versions.listPackageVersions(t,n)).data}catch(r){const o=r?.response?.status;if(o===404||o===501)return[];throw r}}function X$e(e,t,n={}){const{apiClients:r,server:o}=er(),a=(n.enabled??!0)&&e!==""&&t!=="",i=Ld({queryKey:sB(e,t,o),queryFn:()=>lB(r,e,t),enabled:a,staleTime:3e4,retry:!1}),{refetch:s}=i,l=C.useCallback(()=>void s(),[s]),d=i.data??[];return{versions:d,latest:d.find(u=>u.latest)?.id,isPending:a&&i.isPending,isError:a&&i.isError,refetch:l}}function Z$e(e,t){const{apiClients:n,server:r}=er(),o=Tl();return C.useCallback(()=>o.fetchQuery({queryKey:sB(e,t,r),queryFn:()=>lB(n,e,t),staleTime:0,retry:!1}),[o,n,r,e,t])}function J$e(e,t){const n=Tl();return C.useCallback(()=>n.invalidateQueries({predicate:r=>r.queryKey[1]===e&&r.queryKey[2]===t}),[n,e,t])}const eRe=rn(p.jsx("path",{d:"m20.54 5.23-1.39-1.68C18.88 3.21 18.47 3 18 3H6c-.47 0-.88.21-1.16.55L3.46 5.23C3.17 5.57 3 6.02 3 6.5V19c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V6.5c0-.48-.17-.93-.46-1.27M6.24 5h11.52l.81.97H5.44zM5 19V8h14v11zm8.45-9h-2.9v3H8l4 4 4-4h-2.55z"})),tRe=rn(p.jsx("path",{d:"M6 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m12 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m-6 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"})),nRe=rn(p.jsx("path",{d:"M14 4v5c0 1.12.37 2.16 1 3H9c.65-.86 1-1.9 1-3V4zm3-2H7c-.55 0-1 .45-1 1s.45 1 1 1h1v5c0 1.66-1.34 3-3 3v2h5.97v7l1 1 1-1v-7H19v-2c-1.66 0-3-1.34-3-3V4h1c.55 0 1-.45 1-1s-.45-1-1-1"})),rRe=rn(p.jsx("path",{d:"m20.54 5.23-1.39-1.68C18.88 3.21 18.47 3 18 3H6c-.47 0-.88.21-1.16.55L3.46 5.23C3.17 5.57 3 6.02 3 6.5V19c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V6.5c0-.48-.17-.93-.46-1.27M6.24 5h11.52l.83 1H5.42zM5 19V8h14v11zm3-5h2.55v3h2.9v-3H16l-4-4z"})),mg=e=>{const t=e?.response?.data?.message;return typeof t=="string"&&t!==""?t:e instanceof Error?e.message:"Unknown error"},oRe=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})},Tp=e=>e.archiveStatus==="archive",LC="Tables built for this version alone (under scope: version) are dropped.";function tL(e,t){const n=!Tp(e)&&t.filter(o=>!Tp(o)).length<=1,r=t.length<=1;return{archive:e.latest?"The latest version can't be archived":n?"The last version in service can't be archived":void 0,delete:r?void 0:e.latest?"Pin another version as latest first":n?"The last version in service; delete the archived versions first":void 0}}function aRe({environmentName:e,packageName:t,versions:n,selectedVersionId:r,onSelectVersion:o,onReplaceVersion:a,onPackageDeleted:i,canManage:s}){const{apiClients:l}=er(),d=Tl(),u=J$e(e,t),m=Z$e(e,t),[g,y]=C.useState(null),[x,w]=C.useState(null),[S,b]=C.useState(null),[$,k]=C.useState(null),[T,O]=C.useState(null),[P,D]=C.useState(null),A=C.useRef(null),F=C.useRef(null),L=C.useRef(null),_=C.useRef(new Map),R=n.find(fe=>fe.latest)?.id,z=r??R,I=()=>Promise.all([u(),d.invalidateQueries({queryKey:["packages",e]})]),U=async(fe,he)=>{const me=he??await m().catch(()=>{});if(me===void 0)return;const le=me.find(Le=>Le.latest)?.id,ve=le??me.find(Le=>Le.id!==fe&&!Tp(Le))?.id;ve!==void 0&&(a?a(ve===le?void 0:ve):o(ve))},N=a0({mutationFn:fe=>l.versions.setPackageLatestVersion(e,t,{version:fe}),onSuccess:async()=>{b(null),await I()},onError:()=>void I()}),q=a0({mutationFn:({id:fe,archiveStatus:he})=>l.versions.updatePackageVersion(e,t,fe,{archiveStatus:he}),onSuccess:async(fe,{id:he,archiveStatus:me})=>{k(null),me==="archive"&&he===z&&await U(he),await I()},onError:(fe,{id:he,archiveStatus:me})=>{me==="unarchive"&&D(`Couldn't unarchive v${he}: ${mg(fe)}`),I()}}),Y=q.isPending?q.variables?.id:void 0,oe=a0({mutationFn:({id:fe})=>l.versions.deletePackageVersion(e,t,fe),onSuccess:async(fe,{id:he,read:me})=>{O(null);const le=await m().catch(()=>{})??me.filter(ve=>ve.id!==he);if(le.length===0){await d.invalidateQueries({queryKey:["packages",e]}),i?.();return}he===z&&await U(he,le),await I()},onError:()=>void I()}),Q=()=>w(null),ae=x?tL(x.version,n):{},de=x!==null&&!Tp(x.version)&&x.version.latest&&ae.archive!==void 0&&ae.delete!==void 0,X=T!==null&&T.versions===void 0,se=T?.versions!==void 0&&T.versions.length<=1,J=T?.versions!==void 0?tL(T.version,T.versions).delete:void 0,Z=async fe=>{Q(),y(null),oe.reset(),O({version:fe});const he=ve=>O(Le=>Le!==null&&Le.version.id===fe.id&&Le.versions===void 0?ve:Le);let me;try{me=await m()}catch(ve){he(null),D(`Couldn't check v${fe.id} before deleting it: ${mg(ve)}`);return}const le=me.find(ve=>ve.id===fe.id);if(le===void 0){he(null),D(`v${fe.id} is no longer a version of ${t}.`),I();return}he({version:le,versions:me})},G=(fe,he)=>{!s||Y===fe.id||w({version:fe,anchor:_.current.get(fe.id)??he})},ue=(fe,he)=>{const me=fe.key==="ArrowRight"||fe.key==="ContextMenu"||fe.key==="F10"&&fe.shiftKey;!s||!me||(fe.preventDefault(),fe.stopPropagation(),G(he,fe.currentTarget))},ie=x&&p.jsxs(ea,{disabled:ae.delete!==void 0,onClick:()=>void Z(x.version),children:[p.jsx(ml,{children:p.jsx(vF,{fontSize:"small"})}),p.jsx(xi,{primary:"Delete version",secondary:ae.delete})]},"delete");return p.jsxs(p.Fragment,{children:[p.jsx(Hn,{size:"small",variant:"outlined",endIcon:p.jsx(D6,{}),"aria-label":z?`Version v${z}, change version`:"Select a version","aria-haspopup":"menu",onClick:fe=>y(fe.currentTarget),sx:{borderRadius:999,textTransform:"none",fontWeight:500,px:1.5,minWidth:0,whiteSpace:"nowrap"},children:z?`v${z}`:"Select a version"}),p.jsx(uc,{anchorEl:g,open:g!==null,onClose:()=>y(null),slotProps:{paper:{sx:{minWidth:320,maxWidth:400,mt:1,borderRadius:3}},list:{"aria-label":`Versions of ${t}`,disabledItemsFocusable:!0}},children:n.map(fe=>{const he=fe.id===z,me=Tp(fe),le=[me?"Archived":void 0,oRe(fe.createdAt),fe.gitCommitSha?fe.gitCommitSha.slice(0,7):void 0].filter(Boolean).join(" · ");return p.jsxs(ea,{"aria-current":he?"true":void 0,"aria-disabled":me&&!s?"true":void 0,"aria-haspopup":s?"menu":void 0,"data-testid":"version-row",onKeyDown:ve=>ue(ve,fe),onClick:ve=>{if(me){G(fe,ve.currentTarget);return}he||(y(null),o(fe.id,ve))},sx:ve=>({gap:1,borderLeft:"3px solid",borderLeftColor:he?ve.palette.primary.main:"transparent",backgroundColor:he?ns(ve.palette.primary.main,.04):void 0,cursor:he||me&&!s?"default":"pointer"}),children:[p.jsx(xi,{primary:fe.id,secondary:le,sx:{opacity:me?.6:1},slotProps:{primary:{sx:{fontWeight:he?600:400}}}}),fe.latest&&p.jsx($R,{size:"small",label:"Latest",color:"info",variant:"outlined",sx:{height:20,fontSize:11,fontWeight:600}}),s&&p.jsx(Br,{title:Y===fe.id?"Updating this version…":"",children:p.jsx("span",{children:p.jsx(no,{ref:ve=>{ve?_.current.set(fe.id,ve):_.current.delete(fe.id)},size:"small","aria-label":`More actions for version ${fe.id}`,"aria-haspopup":"menu",disabled:Y===fe.id,onClick:ve=>{ve.stopPropagation(),w({version:fe,anchor:ve.currentTarget})},children:p.jsx(tRe,{fontSize:"small"})})})})]},fe.id)})}),p.jsx(uc,{anchorEl:x?.anchor??null,open:x!==null,onClose:Q,slotProps:{list:{"aria-label":x?`Actions for version ${x.version.id}`:void 0,disabledItemsFocusable:!0,autoFocus:de}},children:x&&Tp(x.version)?[p.jsxs(ea,{onClick:()=>{const{id:fe}=x.version;Q(),q.mutate({id:fe,archiveStatus:"unarchive"})},children:[p.jsx(ml,{children:p.jsx(rRe,{fontSize:"small"})}),p.jsx(xi,{primary:"Unarchive"})]},"unarchive"),p.jsx(wl,{},"divider"),ie]:x&&[p.jsxs(ea,{disabled:x.version.latest,onClick:()=>{b(x.version),N.reset(),Q(),y(null)},children:[p.jsx(ml,{children:p.jsx(nRe,{fontSize:"small"})}),p.jsx(xi,{primary:"Pin as latest",secondary:x.version.latest?"Already the latest version":void 0})]},"pin-latest"),p.jsxs(ea,{disabled:ae.archive!==void 0,onClick:()=>{k(x.version),q.reset(),Q(),y(null)},children:[p.jsx(ml,{children:p.jsx(eRe,{fontSize:"small"})}),p.jsx(xi,{primary:"Archive",secondary:ae.archive})]},"archive"),p.jsx(wl,{},"divider"),ie]}),p.jsx(Oo,{open:S!==null,onClose:()=>{N.isPending||b(null)},title:S?`Pin v${S.id} as latest`:"",description:S?`Requests that name no version will be served from v${S.id}.`:void 0,initialFocus:A,actions:p.jsxs(p.Fragment,{children:[p.jsx(Hn,{ref:A,disabled:N.isPending,onClick:()=>b(null),children:"Cancel"}),p.jsx(Hn,{variant:"contained",loading:N.isPending,onClick:()=>S&&N.mutate(S.id),children:"Pin as latest"})]}),children:p.jsxs(Wn,{spacing:1.5,children:[R&&S&&R!==S.id&&p.jsx(wt,{variant:"body2",color:"text.secondary",children:`The latest version is v${R} now. Links and requests that name a version keep answering as before.`}),N.isError&&S&&p.jsx(xo,{severity:"error",role:"alert",children:`Couldn't pin v${S.id} as latest: ${mg(N.error)}`})]})}),p.jsx(Oo,{open:$!==null,onClose:()=>{q.isPending||k(null)},title:$?`Archive v${$.id}`:"",description:$?`v${$.id} stops being served and is unloaded. Its files stay, so it can be unarchived.`:void 0,initialFocus:F,actions:p.jsxs(p.Fragment,{children:[p.jsx(Hn,{ref:F,disabled:q.isPending,onClick:()=>k(null),children:"Cancel"}),p.jsx(Hn,{variant:"contained",loading:q.isPending,onClick:()=>$&&q.mutate({id:$.id,archiveStatus:"archive"}),children:"Archive"})]}),children:p.jsxs(Wn,{spacing:1.5,children:[p.jsx(wt,{variant:"body2",color:"text.secondary",children:`${LC} Its scheduled builds stop, and once unarchived it serves live until it is built again.`}),q.isError&&$&&p.jsx(xo,{severity:"error",role:"alert",children:`Couldn't archive v${$.id}: ${mg(q.error)}`})]})}),p.jsx(Oo,{open:T!==null,onClose:()=>{oe.isPending||O(null)},title:T?`Delete v${T.version.id}`:"",initialFocus:L,actions:p.jsxs(p.Fragment,{children:[p.jsx(Hn,{ref:L,disabled:oe.isPending,onClick:()=>O(null),children:"Cancel"}),p.jsx(Hn,{variant:"contained",color:"error",loading:oe.isPending,disabled:X||J!==void 0,onClick:()=>T?.versions&&oe.mutate({id:T.version.id,read:T.versions}),children:se?"Delete package":"Delete version"})]}),children:p.jsxs(Wn,{spacing:1.5,children:[X&&T&&p.jsx(wt,{variant:"body2",children:`Checking ${t}'s versions before deleting v${T.version.id}…`}),T&&!X&&p.jsx(wt,{variant:"body2",children:se?`v${T.version.id} is the only version of ${t}, so deleting it deletes the package. ${LC} This cannot be undone.`:`v${T.version.id} stops being served and its files are removed. ${LC} Links that name it stop working, and this cannot be undone.`}),J!==void 0&&T&&p.jsx(xo,{severity:"warning",role:"alert",children:`v${T.version.id} can't be deleted now: ${J}.`}),oe.isError&&T&&p.jsx(xo,{severity:"error",role:"alert",children:`Couldn't delete v${T.version.id}: ${mg(oe.error)}`})]})}),p.jsx(ph,{open:P!==null,autoHideDuration:8e3,onClose:()=>D(null),anchorOrigin:{vertical:"bottom",horizontal:"center"},children:p.jsx(Re,{children:p.jsx(xo,{severity:"error",variant:"filled",onClose:()=>D(null),children:P})})})]})}const iRe="README.malloynb",sRe=e=>!!e&&!e.includes("/")&&N1(e)?.toLowerCase()==="readme";function RTe({onClickPackageFile:e,onOpenDocument:t,resourceUri:n,onEvent:r,onSelectVersion:o,onReplaceVersion:a}){const{apiClients:i,server:s,mutable:l}=er(),d=Tl(),u=e??(ne=>{window.location.href=ne}),{environmentName:m,packageName:g,versionId:y}=ko(n),x=X$e(m,g),{versions:w}=x,S=w.length>0,b=!S&&!x.isPending&&!x.isError,$=o??((ne,qe)=>u(`/${encodeURIComponent(m)}/${encodeURIComponent(g)}/${encodeURIComponent(ne)}`,qe)),k=t??((ne,qe)=>{const Oe=ne.mode==="edit"?b0e(m,g,ne.path):v_(m,g,ne.path);qe?u(Oe,qe):u(Oe)}),[T,O]=C.useState(null),[P,D]=C.useState(!1),A=yxe(),F=P_()?.documentStorage,[L,_]=C.useState([]),[R,z]=C.useState({state:F?"pending":"ready"}),I=C.useCallback(async()=>{if(!F)return;let ne;try{ne=await F.listWorkspaces(!1)}catch{z({state:"failed"});return}z({state:"ready",chosen:C_(ne)});const qe=[],Oe=wy(m,g,"");for(const Qe of ne.filter(nt=>nt.writeable))for(const nt of await F.listDocuments(Qe))nt.path.startsWith(Oe)&&qe.push({locator:nt,where:Qe.description});_(qe)},[F,m,g]);C.useEffect(()=>{I()},[I]);const U=ne=>ne.path.slice(wy(m,g,"").length),N=wo({queryKey:["package",m,g,y],queryFn:()=>i.packages.getPackage(m,g,y,!1)}),q=wo({queryKey:["package-agents",m,g,y],queryFn:()=>i.agents.listAgents(m,g,y)}),Y=b_(m,g,y),oe=wo({queryKey:["models",m,g,y],queryFn:()=>i.models.listModels(m,g,y)}),Q=wo({queryKey:["databases",m,g,y],queryFn:()=>i.databases.listDatabases(m,g,y)}),ae=wo({queryKey:["data-apps",m,g,y],queryFn:async()=>{try{return await i.dataApps.listDataApps(m,g,y)}catch(ne){const qe=ne?.response?.status;if(qe===404||qe===void 0)return{data:[]};throw ne}}}).data?.data??[],de=Y.reports.filter(ne=>!!ne.path),X=cRe(de),se=new Set(de.map(ne=>ne.path).filter(ne=>ne!==void 0)),J=(oe.data?.data??[]).slice().filter(ne=>!se.has(ne.path)).sort((ne,qe)=>ne.path.localeCompare(qe.path)),Z=(Q.data?.data??[]).slice().sort((ne,qe)=>ne.path.localeCompare(qe.path)),G=R.state==="ready"?X0e({authoritative:R.chosen?.authoritative===!0,mutable:l&&b,canStore:R.chosen?.writeable===!0,...y===void 0?{}:{versionId:y}}):void 0,ue=Y.settled&&(oe.isSuccess||oe.isError),ie=G!==void 0&&ue,fe=ie&&!A,he=C.useMemo(()=>{if(!ie)return;const ne=[...Y.reports.flatMap(qe=>qe.path?[qe.path]:[]),...(oe.data?.data??[]).flatMap(qe=>qe.path?[qe.path]:[])];if(G==="storage"&&F&&R.state==="ready")return R.chosen?{route:G,storage:F,workspace:R.chosen,environmentName:m,packageName:g,existing:ne}:void 0;if(G==="package")return{route:G,existing:ne,write:async(qe,Oe)=>{await i.models.updateModelSource(m,g,qe,{source:Oe})}}},[ie,G,F,R,m,g,i,Y.reports,oe.data]),me=N.data?.data?.description??"",le=q.data?.data??[],ve=(de.find(ne=>ne.path===iRe)??de.find(ne=>sRe(ne.path)))?.path,Le=!Y.settled,Ie=S?p.jsx(aRe,{environmentName:m,packageName:g,versions:w,...y!==void 0?{selectedVersionId:y}:{},onSelectVersion:$,...a?{onReplaceVersion:a}:{},onPackageDeleted:()=>u(`/${encodeURIComponent(m)}`),canManage:l}):null,Te=p.jsxs(Wn,{direction:"row",alignItems:"center",spacing:1.5,sx:{mb:.5},children:[p.jsx(wt,{variant:"h4",component:"h1",sx:{fontWeight:600,letterSpacing:"-0.025em"},children:g}),Ie]});if(N.isError){const ne=p.jsx(Xa,{error:N.error,context:`${m} > ${g}`});return Ie?p.jsxs(O0,{maxWidth:!1,sx:{maxWidth:1024,mx:"auto",px:3,py:6},children:[p.jsx(Re,{sx:{mb:4},children:Te}),ne]}):ne}return p.jsxs(O0,{maxWidth:!1,sx:{maxWidth:1024,mx:"auto",px:3,py:6},children:[p.jsxs(Re,{sx:{mb:4},children:[Te,me&&p.jsx(wt,{variant:"body2",color:"text.secondary",children:me})]}),p.jsx(v$e,{warnings:N.data?.data?.warnings}),x.isError&&p.jsx(Re,{sx:{mb:4},children:p.jsx(xo,{severity:"warning",action:p.jsx(Hn,{color:"inherit",size:"small",onClick:x.refetch,children:"Retry"}),children:"Could not read this package's versions, so nothing that changes it is offered until they load."})}),Le&&p.jsx(Go,{text:"Loading package..."}),he&&p.jsx(O$e,{open:P,layout:"linear",environmentName:m,packageName:g,...y!==void 0?{versionId:y}:{},models:J.map(ne=>ne.path).filter(ne=>typeof ne=="string"&&ne.endsWith(".malloy")&&!se.has(ne)),modelsLoading:oe.isPending,...oe.isError?{modelsError:oe.error}:{},onRetryModels:()=>void oe.refetch(),target:he,...r?{onEvent:r}:{},onClose:()=>D(!1),onCreated:ne=>{D(!1),sxe(d),d.invalidateQueries({queryKey:["models"]}),k({path:ne.path,layout:ne.layout,slug:ne.slug,mode:"edit"})}}),!Le&&p.jsxs(p.Fragment,{children:[Y.isError&&p.jsx(Re,{sx:{mb:4},children:p.jsx(xo,{severity:"warning",action:p.jsx(Hn,{color:"inherit",size:"small",onClick:()=>void Y.refetch(),children:"Retry"}),children:"Could not list this package's reports, so any it has are missing from this page."})}),(X.length>0||ie)&&p.jsxs(Ds,{title:"Reports",count:X.length,...fe?{action:p.jsx(Qy,{label:"Report",onClick:()=>D(!0)})}:{},children:[X.length===0&&p.jsx(zC,{label:"No reports yet",...fe?{action:{label:"Add report",onClick:()=>D(!0)}}:{}}),X.map(ne=>p.jsx(xp,{type:ne.layout==="grid"?"dashboard":"report",label:ne.label,rightLabel:ne.layout,...ne.secondary===void 0?{}:{description:ne.secondary},onClick:qe=>ne.path.endsWith(".malloynb")?u(`/${m}/${g}/${ne.path}`,qe):k({path:ne.path,layout:ne.layout,slug:ne.slug,mode:"view"},qe)},ne.path))]}),b&&L.length>0&&p.jsx(Ds,{title:"Drafts",count:L.length,children:L.map(({locator:ne,where:qe})=>p.jsx(xp,{type:ne.type==="grid"?"dashboard":"report",label:U(ne),rightLabel:qe,onClick:Oe=>k({path:U(ne),layout:ne.type,slug:N1(U(ne))??"",mode:"edit"},Oe),trailingAction:p.jsx(Br,{title:"Delete this draft",children:p.jsx(no,{size:"small","aria-label":`Delete draft ${U(ne)}`,onClick:Oe=>{Oe.stopPropagation(),F?.deleteDocument(ne).then(I)},children:p.jsx(vF,{fontSize:"small"})})})},`${ne.workspace}:${ne.path}`))}),ae.length>0&&p.jsx(Ds,{title:"Apps",count:ae.length,children:ae.map(ne=>{const qe=!!ne.title&&ne.title!==ne.path,Oe=`${J_(s)}${ne.resource}`;return p.jsx(xp,{type:"dataApp",label:qe?ne.title:ne.path,rightLabel:qe?ne.path:void 0,onClick:Qe=>{e?e(`/${m}/${g}/data-apps/${ne.path}`,Qe):Qe&&(Qe.metaKey||Qe.ctrlKey)?window.open(Oe,"_blank"):window.location.href=Oe},trailingAction:p.jsx(Br,{title:"Open standalone in new tab",children:p.jsx(no,{size:"small",href:Oe,target:"_blank",rel:"noopener noreferrer","aria-label":"Open standalone in new tab",onClick:Qe=>Qe.stopPropagation(),sx:{color:"text.secondary"},children:p.jsx(Z_,{fontSize:"small"})})})},ne.path)})}),p.jsxs(Ds,{title:"Models",count:J.length,children:[J.map(ne=>p.jsx(xp,{type:"model",label:ne.path,onClick:qe=>u(`/${m}/${g}/${ne.path}`,qe)},ne.path)),J.length===0&&p.jsx(zC,{label:"No models"})]}),le.length>0&&p.jsx(Ds,{title:"Agents",count:le.length,description:"Declared in publisher.json. Name one in an agent session to work as it. Schedules are listed only; nothing runs them yet.",children:le.map(ne=>p.jsx(lRe,{agent:ne},ne.name))}),p.jsxs(Ds,{title:"Data",count:Z.length,children:[Z.map(ne=>p.jsx(xp,{type:"data",label:ne.path,rightLabel:ne.info?iB(ne.info.rowCount):"Unreadable",onClick:()=>O(ne)},ne.path)),Z.length===0&&p.jsx(zC,{label:"No data files"})]}),p.jsx(tSe,{resourceUri:n,versioned:!b}),ve&&p.jsx(Re,{sx:{mt:6},children:p.jsx(M$e,{resourceUri:I1({environmentName:m,packageName:g,versionId:y}),path:ve,onLinkNavigate:u})})]}),p.jsx(Q$e,{database:T,onClose:()=>O(null)})]})}function xp({type:e,label:t,description:n,rightLabel:r,onClick:o,trailingAction:a}){return p.jsx(L1,{icon:p.jsx(aB,{type:e}),tint:oB[e],label:t,mono:!0,...n===void 0?{}:{description:n},...r===void 0?{}:{rightLabel:r},...o===void 0?{}:{onClick:o},...a===void 0?{}:{trailingAction:a}})}function lRe({agent:e}){return p.jsxs(p.Fragment,{children:[p.jsx(xp,{type:"agent",label:e.name??"",...e.description?{description:e.description}:{},...e.model&&e.model!=="inherit"?{rightLabel:e.model}:{}}),(e.schedules??[]).map(t=>{const n=iT(t.cron??"");return p.jsxs(wt,{variant:"caption",color:"text.secondary",sx:{display:"block",ml:6,mb:.5},children:[n.valid?n.description:t.cron," (UTC), task"," ",t.task,". Not run yet."]},`${t.cron}|${t.task}`)})]})}function cRe(e){const t=e.map(r=>({path:r.path??"",layout:K2(r),slug:N1(r.path)??r.path??"",title:r.title})),n=new Map;for(const r of t)n.set(r.slug,(n.get(r.slug)??0)+1);return t.map(({title:r,...o})=>{const a=!!r&&r!==o.slug&&r!==o.path,i=(n.get(o.slug)??0)>1,s=a?r:o.path.endsWith(".malloynb")?o.path:o.slug;return{...o,label:s,secondary:s!==o.path&&(a||i||o.path.includes("/"))?o.path:void 0}}).sort((r,o)=>r.label.localeCompare(o.label)||r.path.localeCompare(o.path))}function zC({label:e,action:t}){return p.jsxs(Wn,{direction:"row",sx:{alignItems:"center",gap:1,py:1},children:[p.jsx(wt,{variant:"body2",color:"text.secondary",sx:{fontStyle:"italic"},children:e}),t&&p.jsx(Hn,{size:"small",onClick:t.onClick,children:t.label})]})}const nL=/^publisher:document:(dashboard|notebook):(.+)$/;function uRe(e,t){const n=[];for(let r=0;r<e.length;r++){const o=e.key(r);o!==null&&nL.test(o)&&n.push(o)}for(const r of n){const[,o,a]=nL.exec(r),i=e.getItem(r);i!==null&&t(a,j_(o),i)&&e.removeItem(r)}}const FC={name:"Local",description:"Stored in this browser only",writeable:!0},O$="publisher:report:",md=e=>`${O$}${e}`;function gg(e){const t=localStorage.getItem(e);if(t!==null)try{const n=JSON.parse(t);if(typeof n.content=="string"&&(n.type==="grid"||n.type==="linear"))return{type:n.type,content:n.content}}catch{}}const _C=(e,t)=>localStorage.setItem(md(e),JSON.stringify(t));class dRe{migrated=!1;migrate(){this.migrated||(this.migrated=!0,uRe(localStorage,(t,n,r)=>gg(md(t))!==void 0?!1:(_C(t,{type:n,content:r}),!0)))}async listWorkspaces(t){return[FC]}async listDocuments(t,n){if(t.name!==FC.name)return[];this.migrate();const r=[];for(let o=0;o<localStorage.length;o++){const a=localStorage.key(o);if(a===null||!a.startsWith(O$))continue;const i=gg(a);i&&(n===void 0||i.type===n)&&r.push({workspace:FC.name,type:i.type,path:a.slice(O$.length)})}return r}async getDocument(t){this.migrate();const n=gg(md(t.path));if(n===void 0)throw BC(t);return n.content}async getDocumentType(t){this.migrate();const n=gg(md(t.path));if(n===void 0)throw BC(t);return n.type}async saveDocument(t,n){this.migrate(),_C(t.path,{type:t.type,content:n})}async deleteDocument(t){if(this.migrate(),gg(md(t.path))===void 0)throw BC(t);localStorage.removeItem(md(t.path))}async moveDocument(t,n){const r=await this.getDocument(t);_C(n.path,{type:n.type,content:r}),n.path!==t.path&&localStorage.removeItem(md(t.path))}}function BC(e){return new k_(`No report at ${e.workspace}/${e.path}`)}async function fRe(e,t,n,r){const o=C_(await e.listWorkspaces(!1));if(!o)return;const a=wy(t,n,r);if(e.getDocumentType)try{return await e.getDocumentType({workspace:o.name,path:a})}catch(i){if($_(i))return;throw i}return(await e.listDocuments(o)).find(i=>i.path===a)?.type}function TTe(e,t,n,r=!0){const o=P_()?.documentStorage,a=r&&o!==void 0,[i,s]=C.useState(),l=wy(e,t,n);return C.useEffect(()=>{if(!a||!o)return;let d=!1;return fRe(o,e,t,n).catch(()=>{}).then(u=>{d||s({key:l,layout:u})}),()=>{d=!0}},[a,o,e,t,n,l]),a?i?.key===l?{layout:i.layout,settled:!0}:{layout:void 0,settled:!1}:{layout:void 0,settled:!0}}function ETe(e,t,n="grid"){const r=t.filter(a=>!!a.path).filter(a=>N1(a.path)===e),o=r.filter(a=>K2(a)===n);return o.length===1?{found:g$(o[0])}:r.length===1?{found:g$(r[0])}:r.length===0?{missing:!0}:{ambiguous:r.map(a=>a.path).sort()}}const pRe=/^(dashboards|notebooks)\/([^/]+)$/;function MTe(e){const t=pRe.exec(e);if(t)return{name:t[2],prefer:t[1]==="dashboards"?"grid":"linear"}}const rL="[publisher.report]",oL="[publisher.console]";function hRe(e){switch(e.type){case"report.load_failed":case"report.query_failed":case"report.save_refused":case"report.save_undo_refused":case"report.create_refused":return!0;case"report.rows_shown":return!e.ok;case"report.drill":return e.outcome==="unresolved"||e.outcome==="malformed";default:return!1}}function OTe(e){return t=>{const n={...e,...t,at:new Date().toISOString()};hRe(t)?console.warn(rL,n):console.info(rL,n)}}function mRe(e){const t={...e,at:new Date().toISOString()};e.ok?console.info(oL,t):console.warn(oL,t)}const Lo={white:"#FFFFFF",offWhite:"#F8FAFC",grey:{light:"#E2E8F0",mid:"#64748B"},black:"#0F172A",semantic:{success:{main:pr.emerald,light:"#D1FAE5",dark:"#047857"},warning:{main:pr.amber,light:"#FEF3C7",dark:"#92400E"},error:{main:pr.red,light:"#FEE2E2",dark:"#B91C1C"},info:{main:pr.blue,light:"#DBEAFE",dark:"#1D4ED8"}}},Wb='"Inter", "Helvetica Neue", "Arial", sans-serif',Vo={50:Lo.offWhite,100:"#F1F5F9",200:Lo.grey.light,300:"#CBD5E1",400:"#94A3B8",500:Lo.grey.mid,600:"#475569",700:"#334155",800:"#1E293B",900:Lo.black},PTe={headerHeight:56},aL="0 1px 3px rgba(0, 0, 0, 0.1)",gRe="#0f172a",yRe="#1e293b",vRe="#f1f5f9",bRe="#cbd5e1",xRe="#334155",cB=(e="light",t)=>{const n=e==="dark",r=n?gRe:Lo.white,o=n?yRe:Lo.white,a=n?vRe:Lo.black,i=n?bRe:Lo.grey.mid,s=n?xRe:Lo.grey.light,{accent:l,accentHover:d,accentContrast:u}=t??Dk(void 0,e);return Ex({cssVariables:{nativeColor:!0},palette:{mode:e,primary:{main:l,light:Lo.grey.light,dark:d,contrastText:u},secondary:{main:Lo.grey.mid,light:Lo.grey.light,dark:Lo.black},grey:Vo,success:Lo.semantic.success,warning:Lo.semantic.warning,error:Lo.semantic.error,info:Lo.semantic.info,background:{default:r,paper:o},text:{primary:a,secondary:i},divider:s},typography:{fontFamily:Wb,h1:{fontWeight:500,letterSpacing:"-0.025em"},h2:{fontWeight:500,letterSpacing:"-0.025em"},h3:{fontWeight:500,letterSpacing:"-0.025em"},h4:{fontWeight:500,letterSpacing:"-0.025em"},h5:{fontWeight:500,letterSpacing:"-0.025em"},h6:{fontWeight:500,letterSpacing:"-0.025em"},subtitle1:{fontWeight:500,letterSpacing:"-0.025em"},subtitle2:{fontWeight:500,letterSpacing:"-0.025em"},body1:{letterSpacing:"-0.025em"},body2:{letterSpacing:"-0.025em"},button:{fontWeight:500,letterSpacing:"-0.025em",textTransform:"none"}},shape:{borderRadius:6},components:{MuiButtonBase:{defaultProps:{disableRipple:!0,disableTouchRipple:!0},styleOverrides:{root:{"&:focus-visible":{outline:`2px solid ${l}`,outlineOffset:2}}}},MuiCssBaseline:{styleOverrides:{"*":{scrollbarWidth:"thin",scrollbarColor:n?"#475569 #1e293b":`${Vo[300]} ${Vo[100]}`,"&::-webkit-scrollbar":{width:"8px",height:"8px"},"&::-webkit-scrollbar-track":{background:n?"#1e293b":Vo[100],borderRadius:"4px"},"&::-webkit-scrollbar-thumb":{background:n?"#475569":Vo[300],borderRadius:"4px","&:hover":{background:n?"#64748b":Vo[400]}},"&::-webkit-scrollbar-corner":{background:n?"#1e293b":Vo[100]}},".malloy-table.root":{scrollbarWidth:"auto",scrollbarColor:"auto","&::-webkit-scrollbar, &::-webkit-scrollbar-track, &::-webkit-scrollbar-corner":{background:n?"#1e293b":Vo[100]},"&::-webkit-scrollbar-thumb":{background:n?"#475569":Vo[300],border:"none",borderRadius:"4px"}},"div[data-radix-popper-content-wrapper]":{zIndex:"1300 !important"}}},MuiButton:{styleOverrides:{root:{borderRadius:6,textTransform:"none",fontWeight:500,fontSize:13,minHeight:32,paddingTop:0,paddingBottom:0,boxShadow:"none","&:hover":{boxShadow:"none"}},sizeSmall:{minHeight:32,paddingLeft:10,paddingRight:10},sizeMedium:{minHeight:32,paddingLeft:12,paddingRight:12},contained:{"&:hover":{boxShadow:"none"},"&.Mui-disabled":{backgroundColor:n?"rgba(255, 255, 255, 0.06)":Vo[200],color:n?"#64748b":Vo[500]}},outlined:{color:a,borderColor:n?"#475569":Vo[300],"&:hover":{borderColor:n?"#64748b":Vo[400],backgroundColor:n?"rgba(255, 255, 255, 0.06)":"rgba(0, 0, 0, 0.04)"}}}},MuiIconButton:{styleOverrides:{root:{borderRadius:6}}},MuiPopover:{styleOverrides:{paper:{borderRadius:8}}},MuiCard:{styleOverrides:{root:{borderRadius:8,boxShadow:aL,border:"1px solid",borderColor:s,backgroundColor:o}}},MuiChip:{styleOverrides:{root:{borderRadius:6,fontWeight:500}}},MuiTextField:{styleOverrides:{root:{"& .MuiOutlinedInput-root":{borderRadius:6},"& .MuiInputLabel-outlined":{backgroundColor:o,paddingLeft:4,paddingRight:4,"&.MuiInputLabel-shrink":{transform:"translate(14px, -9px) scale(0.75)"}}}}},MuiPaper:{styleOverrides:{root:{backgroundImage:"none"}}},MuiDialog:{styleOverrides:{paper:{borderRadius:12,backgroundColor:o,boxShadow:"0px 20px 25px -5px rgba(0, 0, 0, 0.1), 0px 10px 10px -5px rgba(0, 0, 0, 0.04)"}}},MuiSelect:{styleOverrides:{select:{fontFamily:Wb,fontSize:"0.875rem",color:a}}},MuiInputLabel:{styleOverrides:{root:{"&.MuiInputLabel-outlined":{backgroundColor:o,paddingLeft:4,paddingRight:4}}}},MuiOutlinedInput:{styleOverrides:{notchedOutline:{border:"none"},root:{border:`1px solid ${n?Vo[600]:Vo[300]}`,borderRadius:6,transition:`border-color ${Zy} ease-in`,...Jy,backgroundColor:o,"&:hover":{borderColor:n?"#64748b":Vo[400]},"&.Mui-focused":{borderColor:n?Vo[400]:Vo[500],outline:"none"}}}},MuiMenuItem:{styleOverrides:{root:{fontFamily:Wb,fontSize:"0.875rem"}}},MuiInputBase:{styleOverrides:{root:{fontFamily:Wb}}},MuiMenu:{styleOverrides:{paper:{borderRadius:8,boxShadow:"0px 10px 15px -3px rgba(0, 0, 0, 0.1), 0px 4px 6px -2px rgba(0, 0, 0, 0.05)",border:`1px solid ${s}`,backgroundColor:o,color:a}}},MuiBreadcrumbs:{styleOverrides:{root:{"& .MuiBreadcrumbs-separator":{margin:"0 6px",color:Vo[400]}}}},MuiDivider:{styleOverrides:{root:{borderColor:s}},defaultProps:{sx:{my:1}}},MuiListItemButton:{styleOverrides:{root:{borderRadius:6,margin:"2px 8px",padding:"8px 16px","&:hover":{backgroundColor:n?"rgba(255, 255, 255, 0.08)":Lo.offWhite},"&.Mui-selected":{backgroundColor:n?"rgba(255, 255, 255, 0.12)":Lo.offWhite,color:a,"& .MuiListItemIcon-root":{color:a},"& .MuiListItemText-primary":{color:a},"&:hover":{backgroundColor:n?"rgba(255, 255, 255, 0.16)":Lo.grey.light}}}}},MuiAppBar:{styleOverrides:{root:{backgroundColor:o,color:a,boxShadow:aL}}}}})};cB("light");function wRe({children:e}){const{mode:t,theme:n}=Hr(),{accent:r,accentHover:o,accentContrast:a}=n,i=C.useMemo(()=>cB(t,{accent:r,accentHover:o,accentContrast:a}),[t,r,o,a]);return p.jsxs(e7,{theme:i,children:[p.jsx(lQ,{}),e]})}const SRe=C.lazy(()=>vo(()=>import("./HomePage-DIYlgPCz.js"),[])),CRe=C.lazy(()=>vo(()=>import("./MainPage-C7PGAA5k.js"),__vite__mapDeps([7,8,9,10]))),kRe=C.lazy(()=>vo(()=>import("./PackageSplatRoute-BYIMwnLL.js").then(e=>e.a),__vite__mapDeps([11,10]))),$Re=C.lazy(()=>vo(()=>import("./PackagePage-DD2vLSFe.js"),__vite__mapDeps([12,9,10,13]))),RRe=C.lazy(()=>vo(()=>import("./EnvironmentPage-DF2PahCR.js"),[])),TRe=C.lazy(()=>vo(()=>import("./RouteError-B8dE60Vs.js"),[])),ERe=C.lazy(()=>vo(()=>import("./ThemeEditorPage-D0wf74fh.js"),__vite__mapDeps([14,15]))),MRe=(e="/",t=new dRe,n)=>(s1e(mRe),Wq([{path:e,element:p.jsx(Ire,{children:p.jsx(axe,{documentStorage:t,children:p.jsx(wRe,{children:p.jsx(C.Suspense,{fallback:p.jsx(Go,{}),children:p.jsx(CRe,{headerProps:n})})})})}),errorElement:p.jsx(TRe,{}),children:[{index:!0,element:p.jsx(SRe,{})},{path:"settings/theme",element:p.jsx(ERe,{})},{path:"settings",element:p.jsx(xq,{to:"/settings/theme",replace:!0})},{path:":environmentName",element:p.jsx(RRe,{})},{path:":environmentName/:packageName",element:p.jsx($Re,{})},{path:":environmentName/:packageName/*",element:p.jsx(kRe,{})}]}])),ORe=MRe("/");jU.createRoot(document.getElementById("root")).render(p.jsx(C.StrictMode,{children:p.jsx(aH,{router:ORe})}));export{DRe as $,ds as A,rs as B,jRe as C,Ay as D,b_ as E,Xy as F,x0e as G,Re as H,$R as I,no as J,Br as K,PR as L,sz as M,kTe as N,er as O,Ga as P,Ld as Q,tu as R,nk as S,wt as T,Hr as U,dz as V,ml as W,xi as X,yxe as Y,tee as Z,PTe as _,xn as a,j_ as a$,Go as a0,xo as a1,Hn as a2,Cn as a3,vo as a4,OTe as a5,xq as a6,I1 as a7,RTe as a8,X$e as a9,Xne as aA,x_ as aB,n2e as aC,H2e as aD,Dle as aE,iTe as aF,s0e as aG,oTe as aH,W2e as aI,Nle as aJ,G2e as aK,$le as aL,q2e as aM,Y2e as aN,Xd as aO,dF as aP,wl as aQ,uF as aR,p1 as aS,uc as aT,tTe as aU,Lle as aV,iF as aW,j2e as aX,T2e as aY,K2e as aZ,y$ as a_,CTe as aa,lq as ab,O0 as ac,Wn as ad,LP as ae,ki as af,jR as ag,b4 as ah,Nk as ai,ea as aj,Tl as ak,a0 as al,PK as am,NK as an,ph as ao,Oo as ap,yae as aq,su as ar,dx as as,Pd as at,Mi as au,t1 as av,lae as aw,PRe as ax,P$ as ay,Sl as az,sl as b,aTe as b$,fTe as b0,N1 as b1,Od as b2,P_ as b3,wo as b4,dTe as b5,Yk as b6,V0 as b7,lTe as b8,Xa as b9,sTe as bA,uTe as bB,sxe as bC,Z2e as bD,ixe as bE,vTe as bF,nTe as bG,g2 as bH,Bbe as bI,Z0 as bJ,w_ as bK,z_ as bL,p0e as bM,Ube as bN,qbe as bO,D2e as bP,Vbe as bQ,A1 as bR,ple as bS,rxe as bT,g2e as bU,C2e as bV,Qoe as bW,x2e as bX,w2e as bY,S2e as bZ,$2e as b_,J2e as ba,nxe as bb,BN as bc,Zy as bd,rn as be,vi as bf,U2e as bg,vl as bh,P2e as bi,Xse as bj,nF as bk,ele as bl,aF as bm,B2e as bn,S_ as bo,Lbe as bp,e0e as bq,t0e as br,N0e as bs,Q2 as bt,gTe as bu,C_ as bv,Q0e as bw,$_ as bx,cTe as by,Zle as bz,Qa as c,pTe as c$,RA as c0,cF as c1,l2 as c2,O2e as c3,M2e as c4,Qse as c5,Yse as c6,Jy as c7,zbe as c8,Fbe as c9,Wle as cA,A2e as cB,L2e as cC,z2e as cD,b2e as cE,Xx as cF,I2e as cG,N2e as cH,_2e as cI,R2e as cJ,R_ as cK,j4 as cL,Xoe as cM,lF as cN,m1 as cO,Q2e as cP,pK as cQ,vC as cR,k2e as cS,y2e as cT,ule as cU,Ile as cV,eT as cW,Z0e as cX,X0e as cY,hTe as cZ,Z2 as c_,E2e as ca,Rg as cb,T0e as cc,Bp as cd,tQ as ce,V2e as cf,vF as cg,F2e as ch,ale as ci,UN as cj,tle as ck,bz as cl,Wy as cm,Sle as cn,wle as co,xy as cp,zx as cq,sle as cr,B0e as cs,yTe as ct,mTe as cu,Lz as cv,X2e as cw,gF as cx,zle as cy,v2e as cz,Ft as d,G0e as d0,E_ as d1,W0e as d2,K0e as d3,oxe as d4,ry as d5,_r as d6,w0e as d7,S0e as d8,v_ as d9,wTe as da,M$e as db,ARe as dc,eTe as dd,bTe as de,MTe as df,ETe as dg,qL as dh,Fo as di,TTe as dj,qd as dk,STe as dl,Hxe as dm,$Te as dn,P0 as dp,v0e as dq,b0e as dr,ZC as e,yn as f,gn as g,gc as h,Ls as i,p as j,so as k,Gd as l,on as m,N5 as n,lc as o,_5 as p,_p as q,C as r,ct as s,Fy as t,wn as u,I5 as v,Ln as w,xTe as x,lt as y,Pa as z};
|
|
512
|
+
`)}const S$e=rn(p.jsx("path",{d:"M9.4 16.6 4.8 12l4.6-4.6L8 6l-6 6 6 6zm5.2 0 4.6-4.6-4.6-4.6L16 6l6 6-6 6z"}));function C$e({cell:e,resourceUri:t,showCopyLink:n,maxResultSize:r,isExecuting:o,pendingRerun:a,onNavigate:i,onDrillSelf:s,canDrillSelf:l,onDrillNavigate:d,givens:u,givenSpecs:m}){const[g,y]=Cn.useState(!1),[x,w]=Cn.useState(!1),[S,b]=Cn.useState(),[$,k]=Cn.useState(!1),{modelPage:T,isLoadingStatus:O}=er(),P=!O&&T!=="viewer",[D,A]=C.useState(""),{environmentName:F,packageName:L,modelPath:_}=ko(t),R={environmentName:F,packageName:L,sourcePath:_,onNavigate:i},{drill:z,drillMenu:I}=K_({onNavigate:d,onSelf:s,canSelf:l}),U=/import\s*\{([^}]+)\}\s*from\s*['"`][^'"`]+['"`]/,N=/import\s*(?:\{[^}]*\}\s*from\s*)?['"`]([^'"`]+)['"`]/,q=!!e.text&&(U.test(e.text)||N.test(e.text)),Y=()=>{if(!e.newSources||e.newSources.length===0)return 0;let X=[],se="";if(e.text){const J=e.text.match(U);J&&(X=J[1].split(",").map(G=>G.trim()));const Z=e.text.match(N);Z&&(se=Z[1].trim())}for(let J=0;J<e.newSources.length;J++)try{const Z=JSON.parse(e.newSources[J]);if(X.length>0&&X.includes(Z.name)||se&&se===Z.path)return J}catch{continue}return 0},oe=Cn.useMemo(()=>e.newSources&&e.newSources.length>0?{sourceInfos:e.newSources,resource:t,givens:m}:void 0,[e.newSources,t,m]),{mode:Q}=Hr();C.useEffect(()=>{e.type==="code"&&bT(w$e(e),"malloy",Q).then(X=>{b(X)})},[e,Q]);const ae=()=>{const X=window.location.href;navigator.clipboard.writeText(X).then(()=>A("URL copied to clipboard!")).catch(()=>A("Failed to copy URL"))},de=p.jsx(Oo,{open:g,onClose:()=>y(!1),title:"Malloy code",maxWidth:"lg",showClose:!0,children:p.jsx(Re,{sx:X=>({border:`1px solid ${X.palette.divider}`,borderRadius:"8px",padding:"16px",fontFamily:Fo,fontSize:"14px",lineHeight:"1.5",overflow:"auto",maxHeight:"70vh",backgroundColor:X.palette.background.paper,color:X.palette.text.primary}),children:p.jsx("pre",{className:"code-display",style:{margin:0},dangerouslySetInnerHTML:{__html:S}})})});return e.type==="markdown"&&p.jsx(Re,{children:p.jsxs(Q2,{children:[n?p.jsxs(Wn,{direction:"row",alignItems:"flex-start",justifyContent:"space-between",children:[p.jsx(xy,{variant:"document",links:R,children:e.text}),p.jsx(Br,{title:"Copy link",children:p.jsx(no,{"aria-label":"Copy link",onClick:ae,sx:{color:"text.secondary",mt:"18px"},children:p.jsx(sT,{sx:{fontSize:"24px"}})})})]}):p.jsx(xy,{variant:"document",links:R,children:e.text}),p.jsx(ph,{open:D!=="",autoHideDuration:6e3,onClose:()=>A(""),message:D})]})})||e.type==="code"&&p.jsxs(Re,{children:[e.newSources&&e.newSources.length>0&&p.jsx(Wn,{sx:{flexDirection:"column",gap:"8px",marginBottom:"2px"},children:p.jsx(g4,{sx:{position:"relative",padding:"0"},children:p.jsxs(Re,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingLeft:"24px",paddingRight:"8px"},children:[S&&p.jsx("span",{dangerouslySetInnerHTML:{__html:S},style:{fontFamily:Fo,fontSize:"14px",flex:1,marginRight:"8px"}}),q&&P&&p.jsx(Lp,{"aria-label":"Data sources",sx:{flexShrink:0},onClick:()=>k(!0),children:p.jsx(Gp,{})})]})})}),p.jsx(rB,{open:$&&P,onClose:()=>k(!1),title:"Data Sources",hasValidImport:q,resourceUri:t,data:oe,initialSelectedSourceIndex:Y(),startingGivens:u}),de,p.jsx(eB,{open:x,onClose:()=>w(!1),result:e.result||"",title:"Results",drill:z}),o&&!e.result&&!e.error&&!q&&!(e.newSources&&e.newSources.length>0)&&p.jsx(Z0,{children:p.jsx(Re,{sx:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:200},children:p.jsx(Cu,{size:32})})}),!e.result&&e.error&&p.jsx(bF,{summary:"This cell could not be run.",detail:e.error}),e.result&&a&&p.jsx(uz,{"aria-label":"Re-run pending",sx:{mb:1,height:2,borderRadius:1}}),e.result&&p.jsxs(Z0,{children:[p.jsx(w_,{title:"",action:p.jsxs(Wn,{direction:"row",sx:{gap:.5,mt:"-4px"},children:[p.jsx(Lp,{"aria-label":"Malloy code",onClick:X=>{X.stopPropagation(),y(!0)},children:p.jsx(S$e,{})}),p.jsx(Lp,{"aria-label":"Expand results",onClick:()=>w(!0),children:p.jsx(Gp,{})})]})}),p.jsx(D1,{result:e.result,maxHeight:Rle,maxResultSize:r,drill:z}),I]})]})}function k$e({ready:e,lastRunKey:t,pendingKey:n,runKey:r,documentKey:o}){if(!e)return{cancelPending:n!==void 0,dispatch:"none"};const a=n!==void 0&&n!==r;if(t===r)return{cancelPending:a,dispatch:"none"};if(n===r)return{cancelPending:a,dispatch:"none"};const i=t===null||!t.startsWith(`${o}|`);return{cancelPending:a,dispatch:i?"now":"settle"}}const $$e=4;function R$e(e){const t=e?.response?.data?.message;return typeof t=="string"&&t!==""?t:e instanceof Error&&e.message!==""?e.message:"The server did not say why."}function T$e({resourceUri:e,maxResultSize:t=0,givens:n,onGivensChange:r,onNavigate:o,onDrillNavigate:a,actions:i,notebook:s,runCell:l}){const{environmentName:d,packageName:u,versionId:m,modelPath:g}=ko(e),[y,x]=C.useState([]),[w,S]=C.useState(!1),[b,$]=C.useState(!1),k=C.useRef(void 0),[T,O]=C.useState(null),P=b$e(s),D=s.autorun!==!1,A=y1(),F=g2({specs:P,loaded:!0,startingValues:s.startingGivens,params:n,onGivensChange:r,documentKey:e,autorun:D,environmentName:d,packageName:u,modelPath:g,versionId:m,documentName:g}),{applied:L,declaredTypes:_,canSelf:R,onSelf:z}=F,I=C.useCallback(Z=>{const G=Zd(Z,_);return Object.keys(G).length>0?JSON.stringify(G):void 0},[_]),U=C.useMemo(()=>m0(L,_),[L,_]),N=C.useRef(0),q=C.useRef(null),Y=C.useRef(null),oe=C.useRef(void 0);C.useEffect(()=>()=>{q.current?.abort(),Y.current=null,clearTimeout(oe.current?.timer),oe.current=void 0},[]);const Q=C.useCallback(async(Z=new Map)=>{if(!s.notebookCells)return;const G=++N.current;q.current?.abort();const ue=new AbortController;q.current=ue,x(s.notebookCells.map(ie=>({...ie}))),S(!0),O(null);try{const ie=[];for(let he=0;he<s.notebookCells.length;he++){const me=s.notebookCells[he];if(!x$e(me))continue;const le=he,ve=async()=>{try{const Le=await l({cell:me,givens:Z,declaredTypes:_,signal:ue.signal});if(N.current!==G)return;const Ie=Le.result;x(Te=>{const ne=[...Te];return ne[le]||(ne[le]={...me}),ne[le]={...ne[le],result:Ie},ne})}catch(Le){if(ue.signal.aborted||N.current!==G)return;A.emit({type:"report.query_failed",tile:le,category:V0(Le)}),A.listening||console.error(`Error executing cell ${le}:`,Le);const Ie=R$e(Le);x(Te=>{const ne=[...Te];return ne[le]||(ne[le]={...me}),ne[le]={...ne[le],error:Ie},ne})}};ie.push(ve)}const fe=[];for(const he of ie){const me=he().then(()=>{fe.splice(fe.indexOf(me),1)});fe.push(me),fe.length>=$$e&&await Promise.race(fe)}await Promise.all(fe)}catch(ie){if(ue.signal.aborted||N.current!==G)return;A.emit({type:"report.query_failed",category:V0(ie)}),A.listening||console.error("Error executing notebook cells:",ie),O(ie)}finally{N.current===G&&(S(!1),q.current=null)}},[s,_,l,A]),ae=C.useRef(0),de=C.useRef(void 0);de.current!==s&&(de.current=s,ae.current+=1);const X=ae.current;C.useEffect(()=>{const Z=`${e}|${X}`,G=`${Z}|${I(L)??""}`;k.current!==void 0&&k.current!==Z&&(q.current?.abort(),q.current=null),k.current=Z;const ue=k$e({ready:!!s.notebookCells,lastRunKey:Y.current,pendingKey:oe.current?.key,runKey:G,documentKey:Z});if(ue.cancelPending&&(clearTimeout(oe.current?.timer),oe.current=void 0,$(!1)),ue.dispatch==="none")return;const ie=()=>{oe.current=void 0,$(!1),Y.current=G,Q(L)};if(ue.dispatch==="now"){ie();return}$(!0),oe.current={key:G,timer:setTimeout(ie,a_)}},[s,X,e,L,I,Q]);const se=y.length>0?y:s.notebookCells||[],J=0;return p.jsxs(y$,{layout:"linear",header:i?p.jsx(Wn,{direction:"row",sx:{justifyContent:"flex-end"},children:i}):null,controls:F.panel.givens.length>0?p.jsx(S_,{children:p.jsx(A1,{...F.panel,layout:"bar"})}):void 0,children:[se.map((Z,G)=>p.jsx(C$e,{cell:Z,showCopyLink:G===J,resourceUri:e,maxResultSize:t,isExecuting:w,givens:U,givenSpecs:P,pendingRerun:b,onNavigate:o,onDrillNavigate:a,onDrillSelf:P.length>0?z:void 0,canDrillSelf:R},G)),T&&p.jsx(Xa,{error:{message:T.message,status:500,name:"ExecutionError"},context:"Notebook Execution"})]})}function E$e({environmentName:e,packageName:t,versionId:n,path:r,notebook:o,...a}){const{apiClients:i,server:s}=er(),l=C.useCallback(async({cell:d,givens:u,declaredTypes:m,signal:g})=>{const y=d.runQuery;if(y===void 0)return{};g.throwIfAborted();const x=Zd(u,m),w={environmentName:e,packageName:t,versionId:n,modelPath:r,query:y,givens:Object.keys(x).length>0?x:void 0},S=[...A_(w),s],b=()=>dy.fetchQuery({queryKey:S,queryFn:({signal:k})=>D_(i,w,k),...S4}),$=()=>void dy.cancelQueries({queryKey:S,exact:!0});g.addEventListener("abort",$,{once:!0});try{let k;try{k=await b()}catch(T){if(!mee(T)||g.aborted)throw T;k=await b()}return{result:k.data.result}}finally{g.removeEventListener("abort",$)}},[i,s,e,t,r,n]);return p.jsx(T$e,{...a,resourceUri:I1({environmentName:e,packageName:t,modelPath:r,versionId:n}),notebook:o,runCell:l})}function M$e({resourceUri:e,path:t,givens:n,onGivensChange:r,onNavigate:o,onLinkNavigate:a,height:i,maxResultSize:s,onEvent:l,chrome:d,manifestStaleTime:u,actions:m,rowsActions:g}){const y=ko(e),{apiClients:x}=er(),w=y.environmentName??"",S=y.packageName??"",b=y.versionId,$=!!y.environmentName&&!!y.packageName,{data:k,isSuccess:T,isError:O,error:P}=wo({...ixe(x,{environmentName:w,packageName:S,path:t,versionId:b},u),enabled:$&&t!==""}),D=k?.layout,A=Jle({path:t,layout:D},l),F=`${e}|${t}`,L=C.useRef(void 0),_=C.useRef({key:F,at:Od()});_.current.key!==F&&(_.current={key:F,at:Od()}),C.useEffect(()=>{L.current!==F&&($?O?(L.current=F,A.emit({type:"report.load_failed",surface:"view",category:V0(P)})):T&&k&&(L.current=F,A.emit({type:"report.opened",surface:"view",from:"package",tiles:k.tiles?.length??k.notebook?.notebookCells?.filter(U=>U.type==="code"&&U.runQuery!==void 0).length??0,durationMs:Od()-_.current.at})):(L.current=F,A.emit({type:"report.load_failed",surface:"view",category:"invalid"})))},[F,$,O,P,T,k,A]);const R=C.useCallback((U,N)=>{const q=o?.(U,N);q&&A.emit({type:"report.drill",to:"report",outcome:q})},[o,A]),z=o?R:void 0;if(!$)return p.jsxs(xo,{severity:"error",children:["A report resource URI must name an environment and a package. Received: ",e]});if(O)return p.jsx(Xa,{context:`${w} > ${S} > ${t}`,error:P});if(!T||!k)return p.jsx(Go,{text:qd.opening("report")});const I=k.notebook?.format==="malloynb"?p.jsx(E$e,{environmentName:w,packageName:S,versionId:b,path:t,notebook:k.notebook,givens:n,onGivensChange:r,onNavigate:a,onDrillNavigate:z,maxResultSize:s,...m!==void 0?{actions:m}:{}}):p.jsx(Bxe,{manifest:k,environmentName:w,packageName:S,versionId:b,documentName:t,givens:n,onGivensChange:r,onNavigate:z,...a?{onLinkNavigate:a}:{},height:i,maxResultSize:s,chrome:d,...m!==void 0?{actions:m}:{},...g!==void 0?{rowsActions:g}:{}});return p.jsx(wF.Provider,{value:A,children:I})}function O$e({open:e,layout:t,kind:n,allowLayoutChange:r,allowKindChange:o,environmentName:a,packageName:i,versionId:s,models:l,modelsLoading:d=!1,modelsError:u,onRetryModels:m,target:g,savedAs:y,onClose:x,onCreated:w,onEvent:S}){const b=t??(n?j_(n):"linear"),$=r??o??!0,[k,T]=C.useState(b),[O,P]=C.useState(void 0),[D,A]=C.useState(""),[F,L]=C.useState(""),[_,R]=C.useState(""),z=C.useRef(null),[I,U]=C.useState(""),[N,q]=C.useState(!1),[Y,oe]=C.useState(!1),[Q,ae]=C.useState(!1),[de,X]=C.useState(void 0),se=u!=null,{choices:J,isLoading:Z,isSuccess:G,failed:ue,retry:ie,canRetry:fe}=oxe({environmentName:a,packageName:i,...s!==void 0?{versionId:s}:{},models:l,enabled:e&&l.length>0}),he=C.useMemo(()=>J.get(D)??[],[J,D]),me=C.useMemo(()=>new Map([...J.entries()].flatMap(([st,At])=>At.map(tn=>[IC(st,tn.source,tn.view),{model:st,source:tn.source,view:tn.view}]))),[J]),le=C.useMemo(()=>{const st=J.size>1;return[...J.entries()].flatMap(([At,tn])=>{const Bt=new Map;for(const an of tn)Bt.set(an.source,[...Bt.get(an.source)??[],an]);return[...Bt.entries()].map(([an,$n])=>({key:`${At}::${an}`,label:an,ariaLabel:`${an} in ${At}`,...st||$n[0]?.sourceDescription?{detail:[st?At:void 0,$n[0]?.sourceDescription].filter(Boolean).join(" · ")}:{},entries:$n.map(Vt=>({key:IC(At,Vt.source,Vt.view),name:Vt.view,title:Vt.description??vC(Vt.view),...Vt.chart?{chart:Vt.chart}:{}}))}))})},[J]),ve=st=>{const At=me.get(st);At&&(A(At.model),L(`${At.source}::${At.view}`))},Le=he.find(st=>`${st.source}::${st.view}`===F),Ie=Le?IC(D,Le.source,Le.view):void 0,Te=P$e(Le,250);C.useEffect(()=>{e&&T(b)},[e,b]),C.useEffect(()=>{if(!e)return;const st=[...J.keys()];D===""&&st.length>0&&A(st[0])},[e,J,D]),C.useEffect(()=>{!e||he.length===0||F!==""||L(`${he[0].source}::${he[0].view}`)},[e,he,F]),C.useEffect(()=>{!e||N||Le===void 0||U(vC(Le.view))},[e,N,Le]),C.useEffect(()=>{e||(A(""),L(""),R(""),U(""),q(!1),P(void 0),oe(!1),X(void 0))},[e]);const ne=C.useMemo(()=>{if(I.trim()!=="")for(let st=1;st<=eT;st++){const At=E_(I,st);if(!g.existing?.includes(At))return At}},[I,g]),qe=O?.trim(),Oe=qe===void 0||qe===""?void 0:qe.endsWith(".malloy")?qe:`${qe}.malloy`,Qe=Oe??ne,nt=Oe===void 0?void 0:M_(Oe)??(g.existing?.includes(Oe)?`${Oe} already exists; choose another location.`:void 0),kt=(Le===void 0?void 0:Z2({title:I,modelPath:D,source:Le.source,view:Le.view}))??(I.trim()!==""&&Qe===void 0?"No free file name for this title; choose another.":void 0),Ut=kt!==void 0&&(Y||I.trim()!==""),at=d||Z,{theme:et}=Hr(),pt=et.ui,ze=Xd(et.cardBorder),be=J.size===0&&(se||ue.length>0),He=at?"Loading the model":be?"Couldn't read the model to start from":J.size===0?"Nothing in the model to start from yet":Le===void 0?"Pick what to start from":void 0,Me="report",$t=Q?`Creating ${Me}…`:`Create ${Me}`,Rt=F!==""&&Le===void 0&&he.length>0,vt=async()=>{if(!(He!==void 0||Le===void 0||Q)){if(kt!==void 0||nt!==void 0){oe(!0);return}ae(!0),X(void 0);try{const st=await Z0e({layout:k,...Oe!==void 0?{path:Oe}:{},document:{title:I,modelPath:D,source:Le.source,view:Le.view},target:g,...S?{onEvent:S}:{}});w(st)}catch(st){const At=st.response?.data?.message;X(At??(st instanceof Error?st.message:String(st)))}finally{ae(!1)}}},it=st=>p.jsx(Hn,{color:"inherit",size:"small",onClick:st,children:"Retry"});return p.jsx(Oo,{className:`${Sl.dialog} ${Sl.newReportDialog}`,maxWidth:"md",initialFocus:z,open:e,onClose:Q?()=>{}:x,title:`New ${Me}`,description:"A report is a Malloy file in the package that lays out text and queries. Pick what its first query shows; the rest is the builder.",actions:p.jsxs(p.Fragment,{children:[p.jsx(Hn,{onClick:x,disabled:Q,children:"Cancel"}),p.jsx(Br,{title:Q?"":He??"",children:p.jsx("span",{children:p.jsx(Hn,{variant:"contained",disabled:Q||He!==void 0,"aria-label":!Q&&He!==void 0?`${$t}: ${He}`:$t,onClick:()=>void vt(),children:$t})})})]}),children:p.jsxs(Wn,{sx:{gap:1.5},children:[se?p.jsx(xo,{severity:"error",action:m&&D4(u)?it(m):void 0,children:"Couldn't read this package's models, so no view is listed to start from."}):l.length===0?!d&&p.jsxs(xo,{severity:"info",children:["This package has no models yet. Add a .malloy file that declares a source with a view, then create a ",Me," from it."]}):ue.length>0?p.jsxs(xo,{severity:"warning",action:fe?it(ie):void 0,children:["Couldn't read ",ue.join(", "),", so nothing from"," ",ue.length===1?"it":"them"," is listed."]}):G&&J.size===0&&p.jsxs(xo,{severity:"info",children:["A ",Me," starts from a view of a source, and no model in this package declares one yet. Add a view to a source in a model file and this list fills in."]}),p.jsxs(Re,{sx:{mx:-3,mb:-1,borderTop:`1px solid ${ze}`,borderBottom:`1px solid ${ze}`,display:"grid",gridTemplateColumns:{xs:"1fr",md:"320px minmax(0, 1fr)"},height:{md:500}},children:[p.jsx(Re,{sx:{display:"flex",flexDirection:"column",minHeight:0,borderRight:{md:`1px solid ${ze}`},maxHeight:{xs:280,md:"none"}},children:p.jsx(Sle,{groups:le,query:_,onQuery:R,picked:Ie,onPick:ve,onTake:st=>{ve(st)},searchRef:z,disabled:Q,empty:p.jsx(wt,{variant:"body2",sx:{color:"text.secondary",p:2},children:at?"Reading the package's models…":"Nothing to start from."})})}),p.jsxs(Re,{sx:st=>({p:2.5,display:"flex",flexDirection:"column",gap:2,minHeight:0,overflowY:"auto",bgcolor:`color-mix(in srgb, ${st.palette.text.primary} 3%, ${st.palette.background.paper})`}),children:[$&&p.jsxs(Re,{children:[p.jsx(eL,{children:"Layout"}),p.jsx(Re,{role:"radiogroup","aria-label":"Layout",sx:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:1},children:["linear","grid"].map(st=>p.jsx(D$e,{layout:st,checked:k===st,disabled:Q,onPick:()=>T(st)},st))}),p.jsx(wt,{variant:"caption",component:"p",sx:{color:"text.secondary",mt:.75},children:"Switch it any time in the builder."})]}),p.jsxs(Re,{children:[p.jsx(eL,{children:"First query"}),p.jsx(Re,{role:"region","aria-label":"Preview",sx:st=>({height:200,display:"flex",position:"relative",overflow:"hidden",borderRadius:pt.radius.tile,border:`1px solid ${ze}`,bgcolor:st.palette.background.paper,"&::after":{content:'""',position:"absolute",left:0,right:0,bottom:0,height:40,pointerEvents:"none",background:`linear-gradient(to bottom, transparent, ${st.palette.background.paper})`}}),children:Le&&Te?p.jsx(Re,{sx:{flex:1,minWidth:0,px:2,pt:1.5},children:p.jsx(z_,{environmentName:a,packageName:i,...s!==void 0?{versionId:s}:{},modelPath:D,tile:`${Te.source} -> ${Te.view}`,label:I.trim()||vC(Te.view),borderless:!0,givens:j$e,declaredTypes:A$e,height:180})}):p.jsx(wt,{variant:"body2",sx:{color:"text.secondary",m:"auto"},children:Rt?"What you picked is no longer in this model; pick something else.":"Pick what to start from."})}),p.jsx(wt,{variant:"caption",component:"p",sx:{color:"text.secondary",mt:.75},children:"More are added in the builder."})]}),p.jsx(ki,{size:"small",label:"Title",value:I,disabled:Q,onChange:st=>{q(!0),U(st.target.value)},InputLabelProps:{shrink:!0},inputProps:{"aria-label":"Report title"},error:Ut,helperText:Ut?kt:g.route==="package"?"Names the file too, unless you type a location.":y??`Saved as a new ${Me} in the host's store, and opened in the builder.`}),p.jsx(ki,{size:"small",label:"Location",value:O??ne??"",placeholder:"report.malloy",disabled:Q,onChange:st=>P(st.target.value),InputLabelProps:{shrink:!0},inputProps:{"aria-label":"Location"},error:nt!==void 0,helperText:nt??(Qe?`Written as ${Qe} in the package, and opened in the builder.`:"A path in the package; the package root by default.")}),de&&p.jsx(xo,{severity:"error",children:de})]})]})]})})}function P$e(e,t){const[n,r]=C.useState(void 0);return C.useEffect(()=>{const o=window.setTimeout(()=>r(e),t);return()=>window.clearTimeout(o)},[e,t]),n}const IC=(e,t,n)=>`${e}::${t}::${n}`,j$e=new Map,A$e=new Map;function eL({children:e}){const t=Hr().theme.ui;return p.jsx(wt,{component:"div",sx:{...t.type.label,color:"text.secondary",mb:.75},children:e})}function D$e({layout:e,checked:t,disabled:n,onPick:r}){const{theme:o}=Hr(),a=o.ui,i=Xd(o.cardBorder),s=t?o.accent:"currentColor";return p.jsxs(rs,{role:"radio","aria-checked":t,"aria-label":e==="linear"?"Linear":"Grid",disabled:n,onClick:r,sx:l=>({justifyContent:"flex-start",gap:1.25,px:1.25,py:1,borderRadius:a.radius.tile,border:`1px solid ${t?o.accent:i}`,boxShadow:t?`0 0 0 1px ${o.accent}`:"none",bgcolor:t?`color-mix(in srgb, ${o.accent} 6%, ${l.palette.background.paper})`:l.palette.background.paper,color:l.palette.text.secondary,textAlign:"left"}),children:[p.jsx("svg",{width:"34",height:"26",viewBox:"0 0 34 26","aria-hidden":!0,children:e==="linear"?p.jsxs("g",{fill:"none",stroke:s,strokeWidth:"1.5",children:[p.jsx("rect",{x:"3",y:"2",width:"28",height:"7",rx:"1.5"}),p.jsx("rect",{x:"3",y:"12",width:"28",height:"5",rx:"1.5"}),p.jsx("path",{d:"M5 21.5h20",strokeLinecap:"round"})]}):p.jsxs("g",{fill:"none",stroke:s,strokeWidth:"1.5",children:[p.jsx("rect",{x:"2",y:"2",width:"14",height:"10",rx:"1.5"}),p.jsx("rect",{x:"18",y:"2",width:"14",height:"10",rx:"1.5"}),p.jsx("rect",{x:"2",y:"14",width:"30",height:"10",rx:"1.5"})]})}),p.jsxs(Re,{children:[p.jsx(Re,{sx:{...a.type.control,fontWeight:t?a.type.label.fontWeight:500,color:t?o.accent:"text.primary"},children:e==="linear"?"Linear":"Grid"}),p.jsx(Re,{sx:{...a.type.caption,color:"text.secondary"},children:e==="linear"?"Read top to bottom":"Tiles side by side"})]})]})}const N$e=rn(p.jsx("path",{d:"M21 11h-1.5v-.5h-2v3h2V13H21v1c0 .55-.45 1-1 1h-3c-.55 0-1-.45-1-1v-4c0-.55.45-1 1-1h3c.55 0 1 .45 1 1zM8 10v5H6.5v-1.5h-2V15H3v-5c0-.55.45-1 1-1h3c.55 0 1 .45 1 1m-1.5.5h-2V12h2zm7 1.5c.55 0 1 .45 1 1v1c0 .55-.45 1-1 1h-4V9h4c.55 0 1 .45 1 1v1c0 .55-.45 1-1 1M11 10.5v.75h2v-.75zm2 2.25h-2v.75h2z"})),I$e=rn(p.jsx("path",{d:"M15 4v2h3v12h-3v2h5V4zM4 20h5v-2H6V6h3V4H4z"})),L$e=rn(p.jsx("path",{d:"M4 7v2c0 .55-.45 1-1 1H2v4h1c.55 0 1 .45 1 1v2c0 1.65 1.35 3 3 3h3v-2H7c-.55 0-1-.45-1-1v-2c0-1.3-.84-2.42-2-2.83v-.34C5.16 11.42 6 10.3 6 9V7c0-.55.45-1 1-1h3V4H7C5.35 4 4 5.35 4 7m17 3c-.55 0-1-.45-1-1V7c0-1.65-1.35-3-3-3h-3v2h3c.55 0 1 .45 1 1v2c0 1.3.84 2.42 2 2.83v.34c-1.16.41-2 1.52-2 2.83v2c0 .55-.45 1-1 1h-3v2h3c1.65 0 3-1.35 3-3v-2c0-.55.45-1 1-1h1v-4z"})),z$e=rn(p.jsx("path",{d:"M20 10V8h-4V4h-2v4h-4V4H8v4H4v2h4v4H4v2h4v4h2v-4h4v4h2v-4h4v-2h-4v-4zm-6 4h-4v-4h4z"})),oB={dashboard:pr.blue,report:pr.violet,model:pr.cyan,dataApp:pr.pink,data:pr.lime,materialization:pr.amber,agent:pr.red};function aB({type:e,size:t=18,sx:n,...r}){return p.jsx(U0,{...r,viewBox:"0 0 24 24",sx:{width:t,height:t,fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",...n},children:F$e[e]()})}const F$e={report:_$e,model:B$e,data:U$e,materialization:V$e,dataApp:W$e,dashboard:q$e,agent:H$e};function _$e(){return p.jsxs(p.Fragment,{children:[p.jsx("path",{d:"M14 3 H6 a2 2 0 0 0 -2 2 v14 a2 2 0 0 0 2 2 h12 a2 2 0 0 0 2 -2 V9 z"}),p.jsx("path",{d:"M14 3 v4 a2 2 0 0 0 2 2 h4"}),p.jsx("path",{d:"M8 17 v-3"}),p.jsx("path",{d:"M12 17 v-6"}),p.jsx("path",{d:"M16 17 v-4"})]})}function B$e(){return p.jsxs(p.Fragment,{children:[p.jsx("path",{d:"M12 3 L4 7 v10 l8 4 l8 -4 V7 z"}),p.jsx("path",{d:"M4 7 l8 4 l8 -4"}),p.jsx("path",{d:"M12 11 v10"})]})}function U$e(){return p.jsxs(p.Fragment,{children:[p.jsx("rect",{x:"3.5",y:"3.5",width:"17",height:"17",rx:"2"}),p.jsx("path",{d:"M3.5 9.5 H20.5"}),p.jsx("path",{d:"M9.5 3.5 V20.5"})]})}function V$e(){return p.jsxs(p.Fragment,{children:[p.jsx("path",{d:"M12 3 L21 7.5 L12 12 L3 7.5 Z"}),p.jsx("path",{d:"M3 12 L12 16.5 L21 12"}),p.jsx("path",{d:"M3 16.5 L12 21 L21 16.5"})]})}function q$e(){return p.jsxs(p.Fragment,{children:[p.jsx("rect",{x:"3.5",y:"3.5",width:"17",height:"17",rx:"2"}),p.jsx("path",{d:"M3.5 9.5 H20.5"}),p.jsx("path",{d:"M12 9.5 V20.5"}),p.jsx("path",{d:"M12 15 H20.5"})]})}function H$e(){return p.jsxs(p.Fragment,{children:[p.jsx("circle",{cx:"12",cy:"8",r:"3.5"}),p.jsx("path",{d:"M5 20 a7 7 0 0 1 14 0"})]})}function W$e(){return p.jsxs(p.Fragment,{children:[p.jsx("rect",{x:"3.5",y:"4.5",width:"17",height:"15",rx:"2"}),p.jsx("path",{d:"M3.5 9.5 H20.5"}),p.jsx("path",{d:"M7 13.5 H17"}),p.jsx("path",{d:"M7 16.5 H13"})]})}function iB(e){return e>=1e9?`${(e/1e9).toFixed(1)} B rows`:e>=1e6?`${(e/1e6).toFixed(1)} M rows`:e>=1e3?`${(e/1e3).toFixed(1)} K rows`:`${e} rows`}const Y$e=12;function G$e(e){const t=e?.trim().toLowerCase()??"";if(t.startsWith("array")||t.endsWith("[]"))return I$e;if(t.startsWith("record")||t.startsWith("struct"))return L$e;switch(t.split(/[\s(<]/)[0]){case"string":return N$e;case"number":return z$e;case"date":return A6;case"timestamp":case"timestamptz":return N6;case"boolean":return I6;default:return L6}}function K$e({column:e}){const t=G$e(e.type);return p.jsxs(Re,{component:"li",sx:n=>({display:"flex",alignItems:"center",gap:1.25,px:1,py:.625,borderRadius:1,transition:"background-color 0.1s","&:hover":{backgroundColor:n.palette.mode==="dark"?"rgba(255, 255, 255, 0.06)":n.palette.grey[100]}}),children:[p.jsx(t,{"aria-hidden":!0,sx:{fontSize:18,color:"primary.main",flexShrink:0}}),p.jsxs(Re,{sx:{display:"flex",alignItems:"baseline",gap:1,minWidth:0,flex:1},children:[p.jsx(wt,{component:"span",sx:{fontFamily:Fo,fontSize:"0.8125rem",fontWeight:500,color:"text.primary",minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),e.type&&p.jsx(wt,{component:"span",variant:"caption",color:"text.secondary",sx:{flexShrink:0,maxWidth:"50%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.type})]})]})}function Q$e({database:e,onClose:t}){const n=e!==null,[r,o]=C.useState(e);e!==null&&e!==r&&o(e);const[a,i]=C.useState(""),[s,l]=C.useState(r?.path);s!==r?.path&&(l(r?.path),i(""));const d=C.useId(),u=r?.path??"",m=u.split("/").pop()||u,g=u.slice(0,Math.max(0,u.length-m.length-1)),y=r?.info?.rowCount,x=[g,y===void 0?null:iB(y)].filter(Boolean).join(" · "),w=C.useMemo(()=>r?.info?.columns??[],[r]),S=a.trim().toLowerCase(),b=C.useMemo(()=>S?w.filter($=>$.name?.toLowerCase().includes(S)||$.type?.toLowerCase().includes(S)):w,[w,S]);return p.jsxs(Oo,{open:n,onClose:t,showClose:!0,title:p.jsxs(Wn,{direction:"row",alignItems:"center",spacing:1.5,sx:{minWidth:0},children:[p.jsx(Re,{"aria-hidden":!0,sx:{width:32,height:32,borderRadius:1,bgcolor:oB.data,color:"#FFFFFF",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:p.jsx(aB,{type:"data",size:18})}),p.jsxs(Re,{sx:{minWidth:0},children:[p.jsx(wt,{component:"span",noWrap:!0,title:u,sx:{display:"block",fontFamily:Fo,fontSize:"1rem",fontWeight:600,letterSpacing:0,lineHeight:1.4},children:m||"Columns"}),x&&p.jsx(wt,{component:"span",variant:"caption",color:"text.secondary",noWrap:!0,sx:{display:"block",lineHeight:1.4},children:x})]})]}),children:[r?.error&&p.jsx(xo,{severity:"error",variant:"outlined",children:r.error}),r&&!r.error&&p.jsxs(Re,{component:"section","aria-labelledby":d,sx:{display:"flex",flexDirection:"column",border:"1px solid",borderColor:"divider",borderRadius:2,bgcolor:"background.paper",overflow:"hidden",mb:2},children:[p.jsxs(Wn,{direction:"row",alignItems:"center",spacing:1,sx:{px:1.5,py:1,minHeight:44,borderBottom:"1px solid",borderColor:"divider"},children:[p.jsxs(wt,{id:d,component:"h3",sx:{fontSize:"0.875rem",fontWeight:600},children:["Columns",p.jsxs(wt,{component:"span",variant:"caption",color:"text.secondary",sx:{ml:.75,fontVariantNumeric:"tabular-nums"},children:["· ",S?`${b.length} of `:"",w.length]})]}),w.length>Y$e&&p.jsx(zx,{value:a,onChange:$=>i($.target.value),placeholder:"Filter columns",inputProps:{"aria-label":"Filter columns"},startAdornment:p.jsx(MR,{position:"start",children:p.jsx(Gp,{sx:{fontSize:16,color:"text.secondary"}})}),sx:{ml:"auto !important",width:200,fontSize:"0.8125rem",px:1,py:.25,border:"1px solid",borderColor:"divider",borderRadius:1.5,"&.Mui-focused":{borderColor:"primary.main"}}})]}),p.jsx(Re,{sx:{overflowY:"auto",maxHeight:420,px:.75,py:.75},children:b.length===0?p.jsx(wt,{variant:"body2",color:"text.secondary",sx:{fontStyle:"italic",px:1,py:1},children:S?"No columns match":"No columns"}):p.jsx(Re,{component:"ul","aria-labelledby":d,sx:{listStyle:"none",m:0,p:0},children:b.map(($,k)=>p.jsx(K$e,{column:$},`${$.name}-${k}`))})})]})]})}const sB=(e,t,n)=>["packageVersions",e,t,n];async function lB(e,t,n){try{return(await e.versions.listPackageVersions(t,n)).data}catch(r){const o=r?.response?.status;if(o===404||o===501)return[];throw r}}function X$e(e,t,n={}){const{apiClients:r,server:o}=er(),a=(n.enabled??!0)&&e!==""&&t!=="",i=Ld({queryKey:sB(e,t,o),queryFn:()=>lB(r,e,t),enabled:a,staleTime:3e4,retry:!1}),{refetch:s}=i,l=C.useCallback(()=>void s(),[s]),d=i.data??[];return{versions:d,latest:d.find(u=>u.latest)?.id,isPending:a&&i.isPending,isError:a&&i.isError,refetch:l}}function Z$e(e,t){const{apiClients:n,server:r}=er(),o=Tl();return C.useCallback(()=>o.fetchQuery({queryKey:sB(e,t,r),queryFn:()=>lB(n,e,t),staleTime:0,retry:!1}),[o,n,r,e,t])}function J$e(e,t){const n=Tl();return C.useCallback(()=>n.invalidateQueries({predicate:r=>r.queryKey[1]===e&&r.queryKey[2]===t}),[n,e,t])}const eRe=rn(p.jsx("path",{d:"m20.54 5.23-1.39-1.68C18.88 3.21 18.47 3 18 3H6c-.47 0-.88.21-1.16.55L3.46 5.23C3.17 5.57 3 6.02 3 6.5V19c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V6.5c0-.48-.17-.93-.46-1.27M6.24 5h11.52l.81.97H5.44zM5 19V8h14v11zm8.45-9h-2.9v3H8l4 4 4-4h-2.55z"})),tRe=rn(p.jsx("path",{d:"M6 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m12 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m-6 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"})),nRe=rn(p.jsx("path",{d:"M14 4v5c0 1.12.37 2.16 1 3H9c.65-.86 1-1.9 1-3V4zm3-2H7c-.55 0-1 .45-1 1s.45 1 1 1h1v5c0 1.66-1.34 3-3 3v2h5.97v7l1 1 1-1v-7H19v-2c-1.66 0-3-1.34-3-3V4h1c.55 0 1-.45 1-1s-.45-1-1-1"})),rRe=rn(p.jsx("path",{d:"m20.54 5.23-1.39-1.68C18.88 3.21 18.47 3 18 3H6c-.47 0-.88.21-1.16.55L3.46 5.23C3.17 5.57 3 6.02 3 6.5V19c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V6.5c0-.48-.17-.93-.46-1.27M6.24 5h11.52l.83 1H5.42zM5 19V8h14v11zm3-5h2.55v3h2.9v-3H16l-4-4z"})),mg=e=>{const t=e?.response?.data?.message;return typeof t=="string"&&t!==""?t:e instanceof Error?e.message:"Unknown error"},oRe=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})},Tp=e=>e.archiveStatus==="archive",LC="Tables built for this version alone (under scope: version) are dropped.";function tL(e,t){const n=!Tp(e)&&t.filter(o=>!Tp(o)).length<=1,r=t.length<=1;return{archive:e.latest?"The latest version can't be archived":n?"The last version in service can't be archived":void 0,delete:r?void 0:e.latest?"Pin another version as latest first":n?"The last version in service; delete the archived versions first":void 0}}function aRe({environmentName:e,packageName:t,versions:n,selectedVersionId:r,onSelectVersion:o,onReplaceVersion:a,onPackageDeleted:i,canManage:s}){const{apiClients:l}=er(),d=Tl(),u=J$e(e,t),m=Z$e(e,t),[g,y]=C.useState(null),[x,w]=C.useState(null),[S,b]=C.useState(null),[$,k]=C.useState(null),[T,O]=C.useState(null),[P,D]=C.useState(null),A=C.useRef(null),F=C.useRef(null),L=C.useRef(null),_=C.useRef(new Map),R=n.find(fe=>fe.latest)?.id,z=r??R,I=()=>Promise.all([u(),d.invalidateQueries({queryKey:["packages",e]})]),U=async(fe,he)=>{const me=he??await m().catch(()=>{});if(me===void 0)return;const le=me.find(Le=>Le.latest)?.id,ve=le??me.find(Le=>Le.id!==fe&&!Tp(Le))?.id;ve!==void 0&&(a?a(ve===le?void 0:ve):o(ve))},N=a0({mutationFn:fe=>l.versions.setPackageLatestVersion(e,t,{version:fe}),onSuccess:async()=>{b(null),await I()},onError:()=>void I()}),q=a0({mutationFn:({id:fe,archiveStatus:he})=>l.versions.updatePackageVersion(e,t,fe,{archiveStatus:he}),onSuccess:async(fe,{id:he,archiveStatus:me})=>{k(null),me==="archive"&&he===z&&await U(he),await I()},onError:(fe,{id:he,archiveStatus:me})=>{me==="unarchive"&&D(`Couldn't unarchive v${he}: ${mg(fe)}`),I()}}),Y=q.isPending?q.variables?.id:void 0,oe=a0({mutationFn:({id:fe})=>l.versions.deletePackageVersion(e,t,fe),onSuccess:async(fe,{id:he,read:me})=>{O(null);const le=await m().catch(()=>{})??me.filter(ve=>ve.id!==he);if(le.length===0){await d.invalidateQueries({queryKey:["packages",e]}),i?.();return}he===z&&await U(he,le),await I()},onError:()=>void I()}),Q=()=>w(null),ae=x?tL(x.version,n):{},de=x!==null&&!Tp(x.version)&&x.version.latest&&ae.archive!==void 0&&ae.delete!==void 0,X=T!==null&&T.versions===void 0,se=T?.versions!==void 0&&T.versions.length<=1,J=T?.versions!==void 0?tL(T.version,T.versions).delete:void 0,Z=async fe=>{Q(),y(null),oe.reset(),O({version:fe});const he=ve=>O(Le=>Le!==null&&Le.version.id===fe.id&&Le.versions===void 0?ve:Le);let me;try{me=await m()}catch(ve){he(null),D(`Couldn't check v${fe.id} before deleting it: ${mg(ve)}`);return}const le=me.find(ve=>ve.id===fe.id);if(le===void 0){he(null),D(`v${fe.id} is no longer a version of ${t}.`),I();return}he({version:le,versions:me})},G=(fe,he)=>{!s||Y===fe.id||w({version:fe,anchor:_.current.get(fe.id)??he})},ue=(fe,he)=>{const me=fe.key==="ArrowRight"||fe.key==="ContextMenu"||fe.key==="F10"&&fe.shiftKey;!s||!me||(fe.preventDefault(),fe.stopPropagation(),G(he,fe.currentTarget))},ie=x&&p.jsxs(ea,{disabled:ae.delete!==void 0,onClick:()=>void Z(x.version),children:[p.jsx(ml,{children:p.jsx(vF,{fontSize:"small"})}),p.jsx(xi,{primary:"Delete version",secondary:ae.delete})]},"delete");return p.jsxs(p.Fragment,{children:[p.jsx(Hn,{size:"small",variant:"outlined",endIcon:p.jsx(D6,{}),"aria-label":z?`Version v${z}, change version`:"Select a version","aria-haspopup":"menu",onClick:fe=>y(fe.currentTarget),sx:{borderRadius:999,textTransform:"none",fontWeight:500,px:1.5,minWidth:0,whiteSpace:"nowrap"},children:z?`v${z}`:"Select a version"}),p.jsx(uc,{anchorEl:g,open:g!==null,onClose:()=>y(null),slotProps:{paper:{sx:{minWidth:320,maxWidth:400,mt:1,borderRadius:3}},list:{"aria-label":`Versions of ${t}`,disabledItemsFocusable:!0}},children:n.map(fe=>{const he=fe.id===z,me=Tp(fe),le=[me?"Archived":void 0,oRe(fe.createdAt),fe.gitCommitSha?fe.gitCommitSha.slice(0,7):void 0].filter(Boolean).join(" · ");return p.jsxs(ea,{"aria-current":he?"true":void 0,"aria-disabled":me&&!s?"true":void 0,"aria-haspopup":s?"menu":void 0,"data-testid":"version-row",onKeyDown:ve=>ue(ve,fe),onClick:ve=>{if(me){G(fe,ve.currentTarget);return}he||(y(null),o(fe.id,ve))},sx:ve=>({gap:1,borderLeft:"3px solid",borderLeftColor:he?ve.palette.primary.main:"transparent",backgroundColor:he?ns(ve.palette.primary.main,.04):void 0,cursor:he||me&&!s?"default":"pointer"}),children:[p.jsx(xi,{primary:fe.id,secondary:le,sx:{opacity:me?.6:1},slotProps:{primary:{sx:{fontWeight:he?600:400}}}}),fe.latest&&p.jsx($R,{size:"small",label:"Latest",color:"info",variant:"outlined",sx:{height:20,fontSize:11,fontWeight:600}}),s&&p.jsx(Br,{title:Y===fe.id?"Updating this version…":"",children:p.jsx("span",{children:p.jsx(no,{ref:ve=>{ve?_.current.set(fe.id,ve):_.current.delete(fe.id)},size:"small","aria-label":`More actions for version ${fe.id}`,"aria-haspopup":"menu",disabled:Y===fe.id,onClick:ve=>{ve.stopPropagation(),w({version:fe,anchor:ve.currentTarget})},children:p.jsx(tRe,{fontSize:"small"})})})})]},fe.id)})}),p.jsx(uc,{anchorEl:x?.anchor??null,open:x!==null,onClose:Q,slotProps:{list:{"aria-label":x?`Actions for version ${x.version.id}`:void 0,disabledItemsFocusable:!0,autoFocus:de}},children:x&&Tp(x.version)?[p.jsxs(ea,{onClick:()=>{const{id:fe}=x.version;Q(),q.mutate({id:fe,archiveStatus:"unarchive"})},children:[p.jsx(ml,{children:p.jsx(rRe,{fontSize:"small"})}),p.jsx(xi,{primary:"Unarchive"})]},"unarchive"),p.jsx(wl,{},"divider"),ie]:x&&[p.jsxs(ea,{disabled:x.version.latest,onClick:()=>{b(x.version),N.reset(),Q(),y(null)},children:[p.jsx(ml,{children:p.jsx(nRe,{fontSize:"small"})}),p.jsx(xi,{primary:"Pin as latest",secondary:x.version.latest?"Already the latest version":void 0})]},"pin-latest"),p.jsxs(ea,{disabled:ae.archive!==void 0,onClick:()=>{k(x.version),q.reset(),Q(),y(null)},children:[p.jsx(ml,{children:p.jsx(eRe,{fontSize:"small"})}),p.jsx(xi,{primary:"Archive",secondary:ae.archive})]},"archive"),p.jsx(wl,{},"divider"),ie]}),p.jsx(Oo,{open:S!==null,onClose:()=>{N.isPending||b(null)},title:S?`Pin v${S.id} as latest`:"",description:S?`Requests that name no version will be served from v${S.id}.`:void 0,initialFocus:A,actions:p.jsxs(p.Fragment,{children:[p.jsx(Hn,{ref:A,disabled:N.isPending,onClick:()=>b(null),children:"Cancel"}),p.jsx(Hn,{variant:"contained",loading:N.isPending,onClick:()=>S&&N.mutate(S.id),children:"Pin as latest"})]}),children:p.jsxs(Wn,{spacing:1.5,children:[R&&S&&R!==S.id&&p.jsx(wt,{variant:"body2",color:"text.secondary",children:`The latest version is v${R} now. Links and requests that name a version keep answering as before.`}),N.isError&&S&&p.jsx(xo,{severity:"error",role:"alert",children:`Couldn't pin v${S.id} as latest: ${mg(N.error)}`})]})}),p.jsx(Oo,{open:$!==null,onClose:()=>{q.isPending||k(null)},title:$?`Archive v${$.id}`:"",description:$?`v${$.id} stops being served and is unloaded. Its files stay, so it can be unarchived.`:void 0,initialFocus:F,actions:p.jsxs(p.Fragment,{children:[p.jsx(Hn,{ref:F,disabled:q.isPending,onClick:()=>k(null),children:"Cancel"}),p.jsx(Hn,{variant:"contained",loading:q.isPending,onClick:()=>$&&q.mutate({id:$.id,archiveStatus:"archive"}),children:"Archive"})]}),children:p.jsxs(Wn,{spacing:1.5,children:[p.jsx(wt,{variant:"body2",color:"text.secondary",children:`${LC} Its scheduled builds stop, and once unarchived it serves live until it is built again.`}),q.isError&&$&&p.jsx(xo,{severity:"error",role:"alert",children:`Couldn't archive v${$.id}: ${mg(q.error)}`})]})}),p.jsx(Oo,{open:T!==null,onClose:()=>{oe.isPending||O(null)},title:T?`Delete v${T.version.id}`:"",initialFocus:L,actions:p.jsxs(p.Fragment,{children:[p.jsx(Hn,{ref:L,disabled:oe.isPending,onClick:()=>O(null),children:"Cancel"}),p.jsx(Hn,{variant:"contained",color:"error",loading:oe.isPending,disabled:X||J!==void 0,onClick:()=>T?.versions&&oe.mutate({id:T.version.id,read:T.versions}),children:se?"Delete package":"Delete version"})]}),children:p.jsxs(Wn,{spacing:1.5,children:[X&&T&&p.jsx(wt,{variant:"body2",children:`Checking ${t}'s versions before deleting v${T.version.id}…`}),T&&!X&&p.jsx(wt,{variant:"body2",children:se?`v${T.version.id} is the only version of ${t}, so deleting it deletes the package. ${LC} This cannot be undone.`:`v${T.version.id} stops being served and its files are removed. ${LC} Links that name it stop working, and this cannot be undone.`}),J!==void 0&&T&&p.jsx(xo,{severity:"warning",role:"alert",children:`v${T.version.id} can't be deleted now: ${J}.`}),oe.isError&&T&&p.jsx(xo,{severity:"error",role:"alert",children:`Couldn't delete v${T.version.id}: ${mg(oe.error)}`})]})}),p.jsx(ph,{open:P!==null,autoHideDuration:8e3,onClose:()=>D(null),anchorOrigin:{vertical:"bottom",horizontal:"center"},children:p.jsx(Re,{children:p.jsx(xo,{severity:"error",variant:"filled",onClose:()=>D(null),children:P})})})]})}const iRe="README.malloynb",sRe=e=>!!e&&!e.includes("/")&&N1(e)?.toLowerCase()==="readme";function RTe({onClickPackageFile:e,onOpenDocument:t,resourceUri:n,onEvent:r,onSelectVersion:o,onReplaceVersion:a}){const{apiClients:i,server:s,mutable:l}=er(),d=Tl(),u=e??(ne=>{window.location.href=ne}),{environmentName:m,packageName:g,versionId:y}=ko(n),x=X$e(m,g),{versions:w}=x,S=w.length>0,b=!S&&!x.isPending&&!x.isError,$=o??((ne,qe)=>u(`/${encodeURIComponent(m)}/${encodeURIComponent(g)}/${encodeURIComponent(ne)}`,qe)),k=t??((ne,qe)=>{const Oe=ne.mode==="edit"?b0e(m,g,ne.path):v_(m,g,ne.path);qe?u(Oe,qe):u(Oe)}),[T,O]=C.useState(null),[P,D]=C.useState(!1),A=yxe(),F=P_()?.documentStorage,[L,_]=C.useState([]),[R,z]=C.useState({state:F?"pending":"ready"}),I=C.useCallback(async()=>{if(!F)return;let ne;try{ne=await F.listWorkspaces(!1)}catch{z({state:"failed"});return}z({state:"ready",chosen:C_(ne)});const qe=[],Oe=wy(m,g,"");for(const Qe of ne.filter(nt=>nt.writeable))for(const nt of await F.listDocuments(Qe))nt.path.startsWith(Oe)&&qe.push({locator:nt,where:Qe.description});_(qe)},[F,m,g]);C.useEffect(()=>{I()},[I]);const U=ne=>ne.path.slice(wy(m,g,"").length),N=wo({queryKey:["package",m,g,y],queryFn:()=>i.packages.getPackage(m,g,y,!1)}),q=wo({queryKey:["package-agents",m,g,y],queryFn:()=>i.agents.listAgents(m,g,y)}),Y=b_(m,g,y),oe=wo({queryKey:["models",m,g,y],queryFn:()=>i.models.listModels(m,g,y)}),Q=wo({queryKey:["databases",m,g,y],queryFn:()=>i.databases.listDatabases(m,g,y)}),ae=wo({queryKey:["data-apps",m,g,y],queryFn:async()=>{try{return await i.dataApps.listDataApps(m,g,y)}catch(ne){const qe=ne?.response?.status;if(qe===404||qe===void 0)return{data:[]};throw ne}}}).data?.data??[],de=Y.reports.filter(ne=>!!ne.path),X=cRe(de),se=new Set(de.map(ne=>ne.path).filter(ne=>ne!==void 0)),J=(oe.data?.data??[]).slice().filter(ne=>!se.has(ne.path)).sort((ne,qe)=>ne.path.localeCompare(qe.path)),Z=(Q.data?.data??[]).slice().sort((ne,qe)=>ne.path.localeCompare(qe.path)),G=R.state==="ready"?X0e({authoritative:R.chosen?.authoritative===!0,mutable:l&&b,canStore:R.chosen?.writeable===!0,...y===void 0?{}:{versionId:y}}):void 0,ue=Y.settled&&(oe.isSuccess||oe.isError),ie=G!==void 0&&ue,fe=ie&&!A,he=C.useMemo(()=>{if(!ie)return;const ne=[...Y.reports.flatMap(qe=>qe.path?[qe.path]:[]),...(oe.data?.data??[]).flatMap(qe=>qe.path?[qe.path]:[])];if(G==="storage"&&F&&R.state==="ready")return R.chosen?{route:G,storage:F,workspace:R.chosen,environmentName:m,packageName:g,existing:ne}:void 0;if(G==="package")return{route:G,existing:ne,write:async(qe,Oe)=>{await i.models.updateModelSource(m,g,qe,{source:Oe})}}},[ie,G,F,R,m,g,i,Y.reports,oe.data]),me=N.data?.data?.description??"",le=q.data?.data??[],ve=(de.find(ne=>ne.path===iRe)??de.find(ne=>sRe(ne.path)))?.path,Le=!Y.settled,Ie=S?p.jsx(aRe,{environmentName:m,packageName:g,versions:w,...y!==void 0?{selectedVersionId:y}:{},onSelectVersion:$,...a?{onReplaceVersion:a}:{},onPackageDeleted:()=>u(`/${encodeURIComponent(m)}`),canManage:l}):null,Te=p.jsxs(Wn,{direction:"row",alignItems:"center",spacing:1.5,sx:{mb:.5},children:[p.jsx(wt,{variant:"h4",component:"h1",sx:{fontWeight:600,letterSpacing:"-0.025em"},children:g}),Ie]});if(N.isError){const ne=p.jsx(Xa,{error:N.error,context:`${m} > ${g}`});return Ie?p.jsxs(O0,{maxWidth:!1,sx:{maxWidth:1024,mx:"auto",px:3,py:6},children:[p.jsx(Re,{sx:{mb:4},children:Te}),ne]}):ne}return p.jsxs(O0,{maxWidth:!1,sx:{maxWidth:1024,mx:"auto",px:3,py:6},children:[p.jsxs(Re,{sx:{mb:4},children:[Te,me&&p.jsx(wt,{variant:"body2",color:"text.secondary",children:me})]}),p.jsx(v$e,{warnings:N.data?.data?.warnings}),x.isError&&p.jsx(Re,{sx:{mb:4},children:p.jsx(xo,{severity:"warning",action:p.jsx(Hn,{color:"inherit",size:"small",onClick:x.refetch,children:"Retry"}),children:"Could not read this package's versions, so nothing that changes it is offered until they load."})}),Le&&p.jsx(Go,{text:"Loading package..."}),he&&p.jsx(O$e,{open:P,layout:"linear",environmentName:m,packageName:g,...y!==void 0?{versionId:y}:{},models:J.map(ne=>ne.path).filter(ne=>typeof ne=="string"&&ne.endsWith(".malloy")&&!se.has(ne)),modelsLoading:oe.isPending,...oe.isError?{modelsError:oe.error}:{},onRetryModels:()=>void oe.refetch(),target:he,...r?{onEvent:r}:{},onClose:()=>D(!1),onCreated:ne=>{D(!1),sxe(d),d.invalidateQueries({queryKey:["models"]}),k({path:ne.path,layout:ne.layout,slug:ne.slug,mode:"edit"})}}),!Le&&p.jsxs(p.Fragment,{children:[Y.isError&&p.jsx(Re,{sx:{mb:4},children:p.jsx(xo,{severity:"warning",action:p.jsx(Hn,{color:"inherit",size:"small",onClick:()=>void Y.refetch(),children:"Retry"}),children:"Could not list this package's reports, so any it has are missing from this page."})}),(X.length>0||ie)&&p.jsxs(Ds,{title:"Reports",count:X.length,...fe?{action:p.jsx(Qy,{label:"Report",onClick:()=>D(!0)})}:{},children:[X.length===0&&p.jsx(zC,{label:"No reports yet",...fe?{action:{label:"Add report",onClick:()=>D(!0)}}:{}}),X.map(ne=>p.jsx(xp,{type:ne.layout==="grid"?"dashboard":"report",label:ne.label,rightLabel:ne.layout,...ne.secondary===void 0?{}:{description:ne.secondary},onClick:qe=>ne.path.endsWith(".malloynb")?u(`/${m}/${g}/${ne.path}`,qe):k({path:ne.path,layout:ne.layout,slug:ne.slug,mode:"view"},qe)},ne.path))]}),b&&L.length>0&&p.jsx(Ds,{title:"Drafts",count:L.length,children:L.map(({locator:ne,where:qe})=>p.jsx(xp,{type:ne.type==="grid"?"dashboard":"report",label:U(ne),rightLabel:qe,onClick:Oe=>k({path:U(ne),layout:ne.type,slug:N1(U(ne))??"",mode:"edit"},Oe),trailingAction:p.jsx(Br,{title:"Delete this draft",children:p.jsx(no,{size:"small","aria-label":`Delete draft ${U(ne)}`,onClick:Oe=>{Oe.stopPropagation(),F?.deleteDocument(ne).then(I)},children:p.jsx(vF,{fontSize:"small"})})})},`${ne.workspace}:${ne.path}`))}),ae.length>0&&p.jsx(Ds,{title:"Apps",count:ae.length,children:ae.map(ne=>{const qe=!!ne.title&&ne.title!==ne.path,Oe=`${J_(s)}${ne.resource}`;return p.jsx(xp,{type:"dataApp",label:qe?ne.title:ne.path,rightLabel:qe?ne.path:void 0,onClick:Qe=>{e?e(`/${m}/${g}/data-apps/${ne.path}`,Qe):Qe&&(Qe.metaKey||Qe.ctrlKey)?window.open(Oe,"_blank"):window.location.href=Oe},trailingAction:p.jsx(Br,{title:"Open standalone in new tab",children:p.jsx(no,{size:"small",href:Oe,target:"_blank",rel:"noopener noreferrer","aria-label":"Open standalone in new tab",onClick:Qe=>Qe.stopPropagation(),sx:{color:"text.secondary"},children:p.jsx(Z_,{fontSize:"small"})})})},ne.path)})}),p.jsxs(Ds,{title:"Models",count:J.length,children:[J.map(ne=>p.jsx(xp,{type:"model",label:ne.path,onClick:qe=>u(`/${m}/${g}/${ne.path}`,qe)},ne.path)),J.length===0&&p.jsx(zC,{label:"No models"})]}),le.length>0&&p.jsx(Ds,{title:"Agents",count:le.length,description:"Declared in publisher.json. Name one in an agent session to work as it. Schedules are listed only; nothing runs them yet.",children:le.map(ne=>p.jsx(lRe,{agent:ne},ne.name))}),p.jsxs(Ds,{title:"Data",count:Z.length,children:[Z.map(ne=>p.jsx(xp,{type:"data",label:ne.path,rightLabel:ne.info?iB(ne.info.rowCount):"Unreadable",onClick:()=>O(ne)},ne.path)),Z.length===0&&p.jsx(zC,{label:"No data files"})]}),p.jsx(tSe,{resourceUri:n,versioned:!b}),ve&&p.jsx(Re,{sx:{mt:6},children:p.jsx(M$e,{resourceUri:I1({environmentName:m,packageName:g,versionId:y}),path:ve,onLinkNavigate:u})})]}),p.jsx(Q$e,{database:T,onClose:()=>O(null)})]})}function xp({type:e,label:t,description:n,rightLabel:r,onClick:o,trailingAction:a}){return p.jsx(L1,{icon:p.jsx(aB,{type:e}),tint:oB[e],label:t,mono:!0,...n===void 0?{}:{description:n},...r===void 0?{}:{rightLabel:r},...o===void 0?{}:{onClick:o},...a===void 0?{}:{trailingAction:a}})}function lRe({agent:e}){return p.jsxs(p.Fragment,{children:[p.jsx(xp,{type:"agent",label:e.name??"",...e.description?{description:e.description}:{},...e.model&&e.model!=="inherit"?{rightLabel:e.model}:{}}),(e.schedules??[]).map(t=>{const n=iT(t.cron??"");return p.jsxs(wt,{variant:"caption",color:"text.secondary",sx:{display:"block",ml:6,mb:.5},children:[n.valid?n.description:t.cron," (UTC), task"," ",t.task,". Not run yet."]},`${t.cron}|${t.task}`)})]})}function cRe(e){const t=e.map(r=>({path:r.path??"",layout:K2(r),slug:N1(r.path)??r.path??"",title:r.title})),n=new Map;for(const r of t)n.set(r.slug,(n.get(r.slug)??0)+1);return t.map(({title:r,...o})=>{const a=!!r&&r!==o.slug&&r!==o.path,i=(n.get(o.slug)??0)>1,s=a?r:o.path.endsWith(".malloynb")?o.path:o.slug;return{...o,label:s,secondary:s!==o.path&&(a||i||o.path.includes("/"))?o.path:void 0}}).sort((r,o)=>r.label.localeCompare(o.label)||r.path.localeCompare(o.path))}function zC({label:e,action:t}){return p.jsxs(Wn,{direction:"row",sx:{alignItems:"center",gap:1,py:1},children:[p.jsx(wt,{variant:"body2",color:"text.secondary",sx:{fontStyle:"italic"},children:e}),t&&p.jsx(Hn,{size:"small",onClick:t.onClick,children:t.label})]})}const nL=/^publisher:document:(dashboard|notebook):(.+)$/;function uRe(e,t){const n=[];for(let r=0;r<e.length;r++){const o=e.key(r);o!==null&&nL.test(o)&&n.push(o)}for(const r of n){const[,o,a]=nL.exec(r),i=e.getItem(r);i!==null&&t(a,j_(o),i)&&e.removeItem(r)}}const FC={name:"Local",description:"Stored in this browser only",writeable:!0},O$="publisher:report:",md=e=>`${O$}${e}`;function gg(e){const t=localStorage.getItem(e);if(t!==null)try{const n=JSON.parse(t);if(typeof n.content=="string"&&(n.type==="grid"||n.type==="linear"))return{type:n.type,content:n.content}}catch{}}const _C=(e,t)=>localStorage.setItem(md(e),JSON.stringify(t));class dRe{migrated=!1;migrate(){this.migrated||(this.migrated=!0,uRe(localStorage,(t,n,r)=>gg(md(t))!==void 0?!1:(_C(t,{type:n,content:r}),!0)))}async listWorkspaces(t){return[FC]}async listDocuments(t,n){if(t.name!==FC.name)return[];this.migrate();const r=[];for(let o=0;o<localStorage.length;o++){const a=localStorage.key(o);if(a===null||!a.startsWith(O$))continue;const i=gg(a);i&&(n===void 0||i.type===n)&&r.push({workspace:FC.name,type:i.type,path:a.slice(O$.length)})}return r}async getDocument(t){this.migrate();const n=gg(md(t.path));if(n===void 0)throw BC(t);return n.content}async getDocumentType(t){this.migrate();const n=gg(md(t.path));if(n===void 0)throw BC(t);return n.type}async saveDocument(t,n){this.migrate(),_C(t.path,{type:t.type,content:n})}async deleteDocument(t){if(this.migrate(),gg(md(t.path))===void 0)throw BC(t);localStorage.removeItem(md(t.path))}async moveDocument(t,n){const r=await this.getDocument(t);_C(n.path,{type:n.type,content:r}),n.path!==t.path&&localStorage.removeItem(md(t.path))}}function BC(e){return new k_(`No report at ${e.workspace}/${e.path}`)}async function fRe(e,t,n,r){const o=C_(await e.listWorkspaces(!1));if(!o)return;const a=wy(t,n,r);if(e.getDocumentType)try{return await e.getDocumentType({workspace:o.name,path:a})}catch(i){if($_(i))return;throw i}return(await e.listDocuments(o)).find(i=>i.path===a)?.type}function TTe(e,t,n,r=!0){const o=P_()?.documentStorage,a=r&&o!==void 0,[i,s]=C.useState(),l=wy(e,t,n);return C.useEffect(()=>{if(!a||!o)return;let d=!1;return fRe(o,e,t,n).catch(()=>{}).then(u=>{d||s({key:l,layout:u})}),()=>{d=!0}},[a,o,e,t,n,l]),a?i?.key===l?{layout:i.layout,settled:!0}:{layout:void 0,settled:!1}:{layout:void 0,settled:!0}}function ETe(e,t,n="grid"){const r=t.filter(a=>!!a.path).filter(a=>N1(a.path)===e),o=r.filter(a=>K2(a)===n);return o.length===1?{found:g$(o[0])}:r.length===1?{found:g$(r[0])}:r.length===0?{missing:!0}:{ambiguous:r.map(a=>a.path).sort()}}const pRe=/^(dashboards|notebooks)\/([^/]+)$/;function MTe(e){const t=pRe.exec(e);if(t)return{name:t[2],prefer:t[1]==="dashboards"?"grid":"linear"}}const rL="[publisher.report]",oL="[publisher.console]";function hRe(e){switch(e.type){case"report.load_failed":case"report.query_failed":case"report.save_refused":case"report.save_undo_refused":case"report.create_refused":return!0;case"report.rows_shown":return!e.ok;case"report.drill":return e.outcome==="unresolved"||e.outcome==="malformed";default:return!1}}function OTe(e){return t=>{const n={...e,...t,at:new Date().toISOString()};hRe(t)?console.warn(rL,n):console.info(rL,n)}}function mRe(e){const t={...e,at:new Date().toISOString()};e.ok?console.info(oL,t):console.warn(oL,t)}const Lo={white:"#FFFFFF",offWhite:"#F8FAFC",grey:{light:"#E2E8F0",mid:"#64748B"},black:"#0F172A",semantic:{success:{main:pr.emerald,light:"#D1FAE5",dark:"#047857"},warning:{main:pr.amber,light:"#FEF3C7",dark:"#92400E"},error:{main:pr.red,light:"#FEE2E2",dark:"#B91C1C"},info:{main:pr.blue,light:"#DBEAFE",dark:"#1D4ED8"}}},Wb='"Inter", "Helvetica Neue", "Arial", sans-serif',Vo={50:Lo.offWhite,100:"#F1F5F9",200:Lo.grey.light,300:"#CBD5E1",400:"#94A3B8",500:Lo.grey.mid,600:"#475569",700:"#334155",800:"#1E293B",900:Lo.black},PTe={headerHeight:56},aL="0 1px 3px rgba(0, 0, 0, 0.1)",gRe="#0f172a",yRe="#1e293b",vRe="#f1f5f9",bRe="#cbd5e1",xRe="#334155",cB=(e="light",t)=>{const n=e==="dark",r=n?gRe:Lo.white,o=n?yRe:Lo.white,a=n?vRe:Lo.black,i=n?bRe:Lo.grey.mid,s=n?xRe:Lo.grey.light,{accent:l,accentHover:d,accentContrast:u}=t??Dk(void 0,e);return Ex({cssVariables:{nativeColor:!0},palette:{mode:e,primary:{main:l,light:Lo.grey.light,dark:d,contrastText:u},secondary:{main:Lo.grey.mid,light:Lo.grey.light,dark:Lo.black},grey:Vo,success:Lo.semantic.success,warning:Lo.semantic.warning,error:Lo.semantic.error,info:Lo.semantic.info,background:{default:r,paper:o},text:{primary:a,secondary:i},divider:s},typography:{fontFamily:Wb,h1:{fontWeight:500,letterSpacing:"-0.025em"},h2:{fontWeight:500,letterSpacing:"-0.025em"},h3:{fontWeight:500,letterSpacing:"-0.025em"},h4:{fontWeight:500,letterSpacing:"-0.025em"},h5:{fontWeight:500,letterSpacing:"-0.025em"},h6:{fontWeight:500,letterSpacing:"-0.025em"},subtitle1:{fontWeight:500,letterSpacing:"-0.025em"},subtitle2:{fontWeight:500,letterSpacing:"-0.025em"},body1:{letterSpacing:"-0.025em"},body2:{letterSpacing:"-0.025em"},button:{fontWeight:500,letterSpacing:"-0.025em",textTransform:"none"}},shape:{borderRadius:6},components:{MuiButtonBase:{defaultProps:{disableRipple:!0,disableTouchRipple:!0},styleOverrides:{root:{"&:focus-visible":{outline:`2px solid ${l}`,outlineOffset:2}}}},MuiCssBaseline:{styleOverrides:{"*":{scrollbarWidth:"thin",scrollbarColor:n?"#475569 #1e293b":`${Vo[300]} ${Vo[100]}`,"&::-webkit-scrollbar":{width:"8px",height:"8px"},"&::-webkit-scrollbar-track":{background:n?"#1e293b":Vo[100],borderRadius:"4px"},"&::-webkit-scrollbar-thumb":{background:n?"#475569":Vo[300],borderRadius:"4px","&:hover":{background:n?"#64748b":Vo[400]}},"&::-webkit-scrollbar-corner":{background:n?"#1e293b":Vo[100]}},".malloy-table.root":{scrollbarWidth:"auto",scrollbarColor:"auto","&::-webkit-scrollbar, &::-webkit-scrollbar-track, &::-webkit-scrollbar-corner":{background:n?"#1e293b":Vo[100]},"&::-webkit-scrollbar-thumb":{background:n?"#475569":Vo[300],border:"none",borderRadius:"4px"}},"div[data-radix-popper-content-wrapper]":{zIndex:"1300 !important"}}},MuiButton:{styleOverrides:{root:{borderRadius:6,textTransform:"none",fontWeight:500,fontSize:13,minHeight:32,paddingTop:0,paddingBottom:0,boxShadow:"none","&:hover":{boxShadow:"none"}},sizeSmall:{minHeight:32,paddingLeft:10,paddingRight:10},sizeMedium:{minHeight:32,paddingLeft:12,paddingRight:12},contained:{"&:hover":{boxShadow:"none"},"&.Mui-disabled":{backgroundColor:n?"rgba(255, 255, 255, 0.06)":Vo[200],color:n?"#64748b":Vo[500]}},outlined:{color:a,borderColor:n?"#475569":Vo[300],"&:hover":{borderColor:n?"#64748b":Vo[400],backgroundColor:n?"rgba(255, 255, 255, 0.06)":"rgba(0, 0, 0, 0.04)"}}}},MuiIconButton:{styleOverrides:{root:{borderRadius:6}}},MuiPopover:{styleOverrides:{paper:{borderRadius:8}}},MuiCard:{styleOverrides:{root:{borderRadius:8,boxShadow:aL,border:"1px solid",borderColor:s,backgroundColor:o}}},MuiChip:{styleOverrides:{root:{borderRadius:6,fontWeight:500}}},MuiTextField:{styleOverrides:{root:{"& .MuiOutlinedInput-root":{borderRadius:6},"& .MuiInputLabel-outlined":{backgroundColor:o,paddingLeft:4,paddingRight:4,"&.MuiInputLabel-shrink":{transform:"translate(14px, -9px) scale(0.75)"}}}}},MuiPaper:{styleOverrides:{root:{backgroundImage:"none"}}},MuiDialog:{styleOverrides:{paper:{borderRadius:12,backgroundColor:o,boxShadow:"0px 20px 25px -5px rgba(0, 0, 0, 0.1), 0px 10px 10px -5px rgba(0, 0, 0, 0.04)"}}},MuiSelect:{styleOverrides:{select:{fontFamily:Wb,fontSize:"0.875rem",color:a}}},MuiInputLabel:{styleOverrides:{root:{"&.MuiInputLabel-outlined":{backgroundColor:o,paddingLeft:4,paddingRight:4}}}},MuiOutlinedInput:{styleOverrides:{notchedOutline:{border:"none"},root:{border:`1px solid ${n?Vo[600]:Vo[300]}`,borderRadius:6,transition:`border-color ${Zy} ease-in`,...Jy,backgroundColor:o,"&:hover":{borderColor:n?"#64748b":Vo[400]},"&.Mui-focused":{borderColor:n?Vo[400]:Vo[500],outline:"none"}}}},MuiMenuItem:{styleOverrides:{root:{fontFamily:Wb,fontSize:"0.875rem"}}},MuiInputBase:{styleOverrides:{root:{fontFamily:Wb}}},MuiMenu:{styleOverrides:{paper:{borderRadius:8,boxShadow:"0px 10px 15px -3px rgba(0, 0, 0, 0.1), 0px 4px 6px -2px rgba(0, 0, 0, 0.05)",border:`1px solid ${s}`,backgroundColor:o,color:a}}},MuiBreadcrumbs:{styleOverrides:{root:{"& .MuiBreadcrumbs-separator":{margin:"0 6px",color:Vo[400]}}}},MuiDivider:{styleOverrides:{root:{borderColor:s}},defaultProps:{sx:{my:1}}},MuiListItemButton:{styleOverrides:{root:{borderRadius:6,margin:"2px 8px",padding:"8px 16px","&:hover":{backgroundColor:n?"rgba(255, 255, 255, 0.08)":Lo.offWhite},"&.Mui-selected":{backgroundColor:n?"rgba(255, 255, 255, 0.12)":Lo.offWhite,color:a,"& .MuiListItemIcon-root":{color:a},"& .MuiListItemText-primary":{color:a},"&:hover":{backgroundColor:n?"rgba(255, 255, 255, 0.16)":Lo.grey.light}}}}},MuiAppBar:{styleOverrides:{root:{backgroundColor:o,color:a,boxShadow:aL}}}}})};cB("light");function wRe({children:e}){const{mode:t,theme:n}=Hr(),{accent:r,accentHover:o,accentContrast:a}=n,i=C.useMemo(()=>cB(t,{accent:r,accentHover:o,accentContrast:a}),[t,r,o,a]);return p.jsxs(e7,{theme:i,children:[p.jsx(lQ,{}),e]})}const SRe=C.lazy(()=>vo(()=>import("./HomePage-RlrpQRV8.js"),[])),CRe=C.lazy(()=>vo(()=>import("./MainPage-C1559_mQ.js"),__vite__mapDeps([7,8,9,10]))),kRe=C.lazy(()=>vo(()=>import("./PackageSplatRoute-DJlJXk6p.js").then(e=>e.a),__vite__mapDeps([11,10]))),$Re=C.lazy(()=>vo(()=>import("./PackagePage-BIl1r9eP.js"),__vite__mapDeps([12,9,10,13]))),RRe=C.lazy(()=>vo(()=>import("./EnvironmentPage-Cpetyfj1.js"),[])),TRe=C.lazy(()=>vo(()=>import("./RouteError-DRuMstfb.js"),[])),ERe=C.lazy(()=>vo(()=>import("./ThemeEditorPage-ss_tmVWo.js"),__vite__mapDeps([14,15]))),MRe=(e="/",t=new dRe,n)=>(s1e(mRe),Wq([{path:e,element:p.jsx(Ire,{children:p.jsx(axe,{documentStorage:t,children:p.jsx(wRe,{children:p.jsx(C.Suspense,{fallback:p.jsx(Go,{}),children:p.jsx(CRe,{headerProps:n})})})})}),errorElement:p.jsx(TRe,{}),children:[{index:!0,element:p.jsx(SRe,{})},{path:"settings/theme",element:p.jsx(ERe,{})},{path:"settings",element:p.jsx(xq,{to:"/settings/theme",replace:!0})},{path:":environmentName",element:p.jsx(RRe,{})},{path:":environmentName/:packageName",element:p.jsx($Re,{})},{path:":environmentName/:packageName/*",element:p.jsx(kRe,{})}]}])),ORe=MRe("/");jU.createRoot(document.getElementById("root")).render(p.jsx(C.StrictMode,{children:p.jsx(aH,{router:ORe})}));export{DRe as $,ds as A,rs as B,jRe as C,Ay as D,b_ as E,Xy as F,x0e as G,Re as H,$R as I,no as J,Br as K,PR as L,sz as M,kTe as N,er as O,Ga as P,Ld as Q,tu as R,nk as S,wt as T,Hr as U,dz as V,ml as W,xi as X,yxe as Y,tee as Z,PTe as _,xn as a,j_ as a$,Go as a0,xo as a1,Hn as a2,Cn as a3,vo as a4,OTe as a5,xq as a6,I1 as a7,RTe as a8,X$e as a9,Xne as aA,x_ as aB,n2e as aC,H2e as aD,Dle as aE,iTe as aF,s0e as aG,oTe as aH,W2e as aI,Nle as aJ,G2e as aK,$le as aL,q2e as aM,Y2e as aN,Xd as aO,dF as aP,wl as aQ,uF as aR,p1 as aS,uc as aT,tTe as aU,Lle as aV,iF as aW,j2e as aX,T2e as aY,K2e as aZ,y$ as a_,CTe as aa,lq as ab,O0 as ac,Wn as ad,LP as ae,ki as af,jR as ag,b4 as ah,Nk as ai,ea as aj,Tl as ak,a0 as al,PK as am,NK as an,ph as ao,Oo as ap,yae as aq,su as ar,dx as as,Pd as at,Mi as au,t1 as av,lae as aw,PRe as ax,P$ as ay,Sl as az,sl as b,aTe as b$,fTe as b0,N1 as b1,Od as b2,P_ as b3,wo as b4,dTe as b5,Yk as b6,V0 as b7,lTe as b8,Xa as b9,sTe as bA,uTe as bB,sxe as bC,Z2e as bD,ixe as bE,vTe as bF,nTe as bG,g2 as bH,Bbe as bI,Z0 as bJ,w_ as bK,z_ as bL,p0e as bM,Ube as bN,qbe as bO,D2e as bP,Vbe as bQ,A1 as bR,ple as bS,rxe as bT,g2e as bU,C2e as bV,Qoe as bW,x2e as bX,w2e as bY,S2e as bZ,$2e as b_,J2e as ba,nxe as bb,BN as bc,Zy as bd,rn as be,vi as bf,U2e as bg,vl as bh,P2e as bi,Xse as bj,nF as bk,ele as bl,aF as bm,B2e as bn,S_ as bo,Lbe as bp,e0e as bq,t0e as br,N0e as bs,Q2 as bt,gTe as bu,C_ as bv,Q0e as bw,$_ as bx,cTe as by,Zle as bz,Qa as c,pTe as c$,RA as c0,cF as c1,l2 as c2,O2e as c3,M2e as c4,Qse as c5,Yse as c6,Jy as c7,zbe as c8,Fbe as c9,Wle as cA,A2e as cB,L2e as cC,z2e as cD,b2e as cE,Xx as cF,I2e as cG,N2e as cH,_2e as cI,R2e as cJ,R_ as cK,j4 as cL,Xoe as cM,lF as cN,m1 as cO,Q2e as cP,pK as cQ,vC as cR,k2e as cS,y2e as cT,ule as cU,Ile as cV,eT as cW,Z0e as cX,X0e as cY,hTe as cZ,Z2 as c_,E2e as ca,Rg as cb,T0e as cc,Bp as cd,tQ as ce,V2e as cf,vF as cg,F2e as ch,ale as ci,UN as cj,tle as ck,bz as cl,Wy as cm,Sle as cn,wle as co,xy as cp,zx as cq,sle as cr,B0e as cs,yTe as ct,mTe as cu,Lz as cv,X2e as cw,gF as cx,zle as cy,v2e as cz,Ft as d,G0e as d0,E_ as d1,W0e as d2,K0e as d3,oxe as d4,ry as d5,_r as d6,w0e as d7,S0e as d8,v_ as d9,wTe as da,M$e as db,ARe as dc,eTe as dd,bTe as de,MTe as df,ETe as dg,qL as dh,Fo as di,TTe as dj,qd as dk,STe as dl,Hxe as dm,$Te as dn,P0 as dp,v0e as dq,b0e as dr,ZC as e,yn as f,gn as g,gc as h,Ls as i,p as j,so as k,Gd as l,on as m,N5 as n,lc as o,_5 as p,_p as q,C as r,ct as s,Fy as t,wn as u,I5 as v,Ln as w,xTe as x,lt as y,Pa as z};
|