@malloy-publisher/app 0.12.3 → 0.12.4
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 +17 -1
- package/dist/assets/{EnvironmentPage-CewgI-x8.js → EnvironmentPage-gNvDKTtA.js} +1 -1
- package/dist/assets/{HomePage-B-7xHDxu.js → HomePage-lrIG8Qjk.js} +1 -1
- package/dist/assets/{MainPage-swHGcEfw.js → MainPage-CJf3Uuul.js} +1 -1
- package/dist/assets/{ModelPage-BP7XeFQu.js → ModelPage-t_Ln0qr1.js} +2 -2
- package/dist/assets/{PackagePage-CMIewiLY.js → PackagePage-Cxa0_alv.js} +1 -1
- package/dist/assets/{PackageSplatRoute-CfR6aEOF.js → PackageSplatRoute-FyScmoYw.js} +2 -2
- package/dist/assets/{RenderedResult-DqPvGZgL.es-Cga6-xj5.js → RenderedResult-DqPvGZgL.es-BNxk46Vn.js} +1 -1
- package/dist/assets/{RouteError-JKbL4qo3.js → RouteError-BZUUKmNE.js} +1 -1
- package/dist/assets/{ThemeEditorPage-DomLLlrf.js → ThemeEditorPage-vDnfPmZz.js} +1 -1
- package/dist/assets/{ToggleButtonGroup-D5xHfdFe.js → ToggleButtonGroup-DdUWm7cB.js} +1 -1
- package/dist/assets/{documentRoutes-BxF_zGoi.js → documentRoutes-DtWdqG6B.js} +1 -1
- package/dist/assets/{editPageMounted-C972ZdQO.js → editPageMounted-vEdUjhAX.js} +2 -2
- package/dist/assets/{index-Dc7yoJFF.js → index-D-htCO4q.js} +6 -6
- package/dist/assets/{index-p8cCzaE5.js → index-DYHeNKEh.js} +1 -1
- package/dist/assets/{index-NoukhIo4.js → index-dUom3Bdm.js} +1 -1
- package/dist/assets/{index-DhoAPSk5.js → index-diN_kmcj.js} +1 -1
- package/dist/assets/{index.es-COxgMbi1.js → index.es-DpNxHwgw.js} +1 -1
- package/dist/assets/usePackageLinkNavigate-D2TepxAX.js +1 -0
- package/dist/assets/{usePackageRoute-1hM9kuTm.js → usePackageRoute-CjGpnrTp.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +2 -2
- package/dist/assets/usePackageLinkNavigate-Do-ihosf.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-diN_kmcj.js","assets/index-CRAwrhYM.js","assets/index-dUom3Bdm.js","assets/core-B8oMW4sm.es-hOkwvru5.js","assets/engine-oniguruma-C4vnmooL.es-jdkXmgTr.js","assets/index-DYHeNKEh.js","assets/index-DgBiwYeC.js","assets/MainPage-CJf3Uuul.js","assets/editPageMounted-vEdUjhAX.js","assets/documentRoutes-DtWdqG6B.js","assets/usePackageRoute-CjGpnrTp.js","assets/PackageSplatRoute-FyScmoYw.js","assets/PackagePage-Cxa0_alv.js","assets/usePackageLinkNavigate-D2TepxAX.js","assets/ThemeEditorPage-vDnfPmZz.js","assets/ToggleButtonGroup-DdUWm7cB.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
function uL(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 ZRe=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function A$(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var vS={exports:{}},Rm={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.production.js
|
|
@@ -469,13 +469,13 @@ ${t}`}function Mce(e){return e?.status===403}function Zp(e){return`\`${e.replace
|
|
|
469
469
|
`));u&&A.current&&A.current.getSectionContent(O.startIndex).focus()},[]),{interactions:B,returnedValue:{autoFocus:u,readOnly:n,focused:d??z,sectionListRef:F,onBlur:oe,onClick:H,onFocus:K,onInput:Y,onPaste:ae,enableAccessibleFieldDOMStructure:!0,elements:fe,tabIndex:w===0?-1:0,contentEditable:le,value:me,onChange:he,areAllSectionsEmpty:P}}},$p=e=>e.replace(/[\u2066\u2067\u2068\u2069]/g,""),Ige=(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=$2(s,n?"input-rtl":"input-ltr",t),d=`${s.startSeparator}${l}${s.endSeparator}`,u=$p(d).length,m=d.length,g=$p(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},Lge=e=>{const t=Fs(),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),N=C.useMemo(()=>Ige(x.sections,_,t),[x.sections,_,t]),B=C.useMemo(()=>({syncSelectionToDOM:()=>{if(!R.current)return;if(g==null){R.current.scrollLeft&&(R.current.scrollLeft=0);return}if(R.current!==Ua(document))return;const ee=R.current.scrollTop;if(g==="all")R.current.select();else{const Z=N[g],de=Z.type==="empty"?Z.startInInput-Z.startSeparator.length:Z.startInInput,le=Z.type==="empty"?Z.endInInput+Z.endSeparator.length:Z.endInInput;(de!==R.current.selectionStart||le!==R.current.selectionEnd)&&R.current===Ua(document)&&R.current.setSelectionRange(de,le),clearTimeout(r.current),r.current=setTimeout(()=>{R.current&&R.current===Ua(document)&&R.current.selectionStart===R.current.selectionEnd&&(R.current.selectionStart!==de||R.current.selectionEnd!==le)&&B.syncSelectionToDOM()})}R.current.scrollTop=ee},getActiveSectionIndexFromDOM:()=>{const ee=R.current.selectionStart??0,Z=R.current.selectionEnd??0;if(ee===0&&Z===0)return null;const de=ee<=N[0].startInInput?1:N.findIndex(le=>le.startInInput-le.startSeparator.length>ee);return de===-1?N.length-1:de-1},focusField:(ee=0)=>{Ua(document)!==R.current&&(R.current?.focus(),A(ee))},setSelectedSections:ee=>A(ee),isFieldFocused:()=>R.current===Ua(document)}),[R,g,N,A]),I=()=>{const ee=R.current.selectionStart??0;let Z;ee<=N[0].startInInput||ee>=N[N.length-1].endInInput?Z=1:Z=N.findIndex(le=>le.startInInput-le.startSeparator.length>ee);const de=Z===-1?N.length-1:Z-1;A(de)},H=Yt((...ee)=>{o?.(...ee);const Z=R.current;clearTimeout(n.current),n.current=setTimeout(()=>{!Z||Z!==R.current||y==null&&(Z.value.length&&Number(Z.selectionEnd)-Number(Z.selectionStart)===Z.value.length?A("all"):I())})}),Y=Yt((ee,...Z)=>{ee.isDefaultPrevented()||(a?.(ee,...Z),I())}),ae=Yt(ee=>{if(i?.(ee),ee.preventDefault(),u||m)return;const Z=ee.clipboardData.getData("text");if(typeof g=="number"){const de=x.sections[g],le=/^[a-zA-Z]+$/.test(Z),fe=/^[0-9]+$/.test(Z),he=/^(([a-zA-Z]+)|)([0-9]+)(([a-zA-Z]+)|)$/.test(Z);if(de.contentType==="letter"&&le||de.contentType==="digit"&&fe||de.contentType==="digit-with-letter"&&he){$(),k({activeSection:de,newSectionValue:Z,shouldGoToNextSection:!0});return}if(le||fe)return}$(),T(Z)}),K=Yt((...ee)=>{s?.(...ee),A(null)}),oe=Yt(ee=>{if(u)return;const Z=ee.target.value;if(Z===""){$(),P();return}const de=ee.nativeEvent.data,le=de&&de.length>1,fe=le?de:Z,he=$p(fe);if(g==="all"&&A(y),y==null||le){T(le?de:he);return}let me;if(g==="all"&&he.length===1)me=he;else{const se=$p(w.getV6InputValueFromSections(N,_,t));let ve=-1,Le=-1;for(let re=0;re<se.length;re+=1)ve===-1&&se[re]!==he[re]&&(ve=re),Le===-1&&se[se.length-re-1]!==he[he.length-re-1]&&(Le=re);const Ae=N[y];if(ve<Ae.start||se.length-Le-1>Ae.end)return;const Re=he.length-se.length+Ae.end-$p(Ae.endSeparator||"").length;me=he.slice(Ae.start+$p(Ae.startSeparator||"").length,Re)}if(me.length===0){_ue()&&D(fe),$(),O();return}b({keyPressed:me,sectionIndex:y})}),ue=C.useMemo(()=>d!==void 0?d:w.getV6InputValueFromSections(F(S.emptyValue),_,t),[d,w,F,S.emptyValue,_,t]),G=C.useMemo(()=>x.tempValueStrAndroid??w.getV6InputValueFromSections(x.sections,_,t),[x.sections,w,x.tempValueStrAndroid,_,t]);C.useEffect(()=>(R.current&&R.current===Ua(document)&&A("all"),()=>{clearTimeout(n.current),clearTimeout(r.current)}),[]);const ie=C.useMemo(()=>y==null||x.sections[y].contentType==="letter"?"text":"numeric",[y,x.sections]),Q=!(R.current&&R.current===Ua(document))&&L;return{interactions:B,returnedValue:{readOnly:u,onBlur:K,onClick:Y,onFocus:H,onPaste:ae,inputRef:z,enableAccessibleFieldDOMStructure:!1,placeholder:ue,inputMode:ie,autoComplete:"off",value:Q?"":G,onChange:oe}}},zge=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=Fs(),S=jge(e),{state:b,activeSectionIndex:$,parsedSelectedSections:k,setSelectedSections:T,clearValue:O,clearActiveSection:P,updateSectionValue:D,setTempAndroidValueStr:A,sectionsValueBoundaries:F,localizedDigits:L,timezone:_}=S,R=Dge({sections:b.sections,updateSectionValue:D,sectionsValueBoundaries:F,localizedDigits:L,setTempAndroidValueStr:A,timezone:_}),{resetCharacterQuery:z}=R,N=y.areValuesEqual(t,b.value,y.emptyValue),B=a?Nge:Lge,I=C.useMemo(()=>Bue(b.sections,w&&!a),[b.sections,w,a]),{returnedValue:H,interactions:Y}=B(Fe({},e,S,R,{areAllSectionsEmpty:N,sectionOrder:I})),ae=Yt(Q=>{if(l?.(Q),!i)switch(!0){case((Q.ctrlKey||Q.metaKey)&&String.fromCharCode(Q.keyCode)==="A"&&!Q.shiftKey&&!Q.altKey):{Q.preventDefault(),T("all");break}case Q.key==="ArrowRight":{if(Q.preventDefault(),k==null)T(I.startIndex);else if(k==="all")T(I.endIndex);else{const ee=I.neighbors[k].rightIndex;ee!==null&&T(ee)}break}case Q.key==="ArrowLeft":{if(Q.preventDefault(),k==null)T(I.endIndex);else if(k==="all")T(I.startIndex);else{const ee=I.neighbors[k].leftIndex;ee!==null&&T(ee)}break}case Q.key==="Delete":{if(Q.preventDefault(),s)break;k==null||k==="all"?O():P(),z();break}case["ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(Q.key):{if(Q.preventDefault(),s||$==null)break;k==="all"&&T($);const ee=b.sections[$],Z=g.getActiveDateManager(t,b,ee),de=Aue(t,_,ee,Q.key,F,L,Z.date,{minutesStep:o});D({activeSection:ee,newSectionValue:de,shouldGoToNextSection:!1});break}}});Go(()=>{Y.syncSelectionToDOM()});const{hasValidationError:K}=d3({props:n,validator:x,timezone:_,value:b.value,onError:n.onError}),oe=C.useMemo(()=>d!==void 0?d:K,[K,d]);C.useEffect(()=>{!oe&&$==null&&z()},[b.referenceValue,$,oe]),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 ue=Yt((Q,...ee)=>{Q.preventDefault(),m?.(Q,...ee),O(),Y.isFieldFocused()?T(I.startIndex):Y.focusField(0)}),G={onKeyDown:ae,onClear:ue,error:oe,clearable:!!(u&&!N&&!s&&!i)},ie={disabled:i,readOnly:s};return Fe({},e.forwardedProps,G,ie,H)},Fge=["clearable","onClear","InputProps","sx","slots","slotProps"],_ge=["ownerState"],Bge=e=>{const t=vc(),{clearable:n,onClear:r,InputProps:o,sx:a,slots:i,slotProps:s}=e,l=Hn(e,Fge),d=i?.clearButton??Tu,u=Cr({elementType:d,externalSlotProps:s?.clearButton,ownerState:{},className:"clearButton",additionalProps:{title:t.fieldClearLabel}}),m=Hn(u,_ge),g=i?.clearIcon??Qhe,y=Cr({elementType:g,externalSlotProps:s?.clearIcon,ownerState:{}});return Fe({},l,{InputProps:Fe({},o,{endAdornment:p.jsxs(C.Fragment,{children:[n&&p.jsx(f3,{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]]})},Uge=["value","defaultValue","referenceDate","format","formatDensity","onChange","timezone","onError","shouldRespectLeadingZeros","selectedSections","onSelectedSectionsChange","unstableFieldRef","enableAccessibleFieldDOMStructure","disabled","readOnly","dateSeparator"],qge=(e,t)=>C.useMemo(()=>{const n=Fe({},e),r={},o=a=>{n.hasOwnProperty(a)&&(r[a]=n[a],delete n[a])};return Uge.forEach(o),c3.forEach(o),{forwardedProps:n,internalProps:r}},[e,t]),Hge=e=>{const t=Qr(),n=ev();return Fe({},e,{disablePast:e.disablePast??!1,disableFuture:e.disableFuture??!1,format:e.format??t.formats.keyboardDate,minDate:cs(t,e.minDate,n.minDate),maxDate:cs(t,e.maxDate,n.maxDate)})},Vge=e=>{const t=Hge(e),{forwardedProps:n,internalProps:r}=qge(t,"date");return zge({forwardedProps:n,internalProps:r,valueManager:Cl,fieldValueManager:Vue,validator:tv,valueType:"date"})};function Wge(e){return Cn("MuiPickersTextField",e)}fn("MuiPickersTextField",["root","focused","disabled","error","required"]);function Yge(e){return Cn("MuiPickersInputBase",e)}const Ip=fn("MuiPickersInputBase",["root","focused","disabled","error","notchedOutline","sectionContent","sectionBefore","sectionAfter","adornedStart","adornedEnd","input"]);function Gge(e){return Cn("MuiPickersSectionList",e)}const eg=fn("MuiPickersSectionList",["root","section","sectionContent"]),Kge=["slots","slotProps","elements","sectionListRef"],G3=nt("div",{name:"MuiPickersSectionList",slot:"Root",overridesResolver:(e,t)=>t.root})({direction:"ltr /*! @noflip */",outline:"none"}),K3=nt("span",{name:"MuiPickersSectionList",slot:"Section",overridesResolver:(e,t)=>t.section})({}),Q3=nt("span",{name:"MuiPickersSectionList",slot:"SectionSeparator",overridesResolver:(e,t)=>t.sectionSeparator})({whiteSpace:"pre"}),X3=nt("span",{name:"MuiPickersSectionList",slot:"SectionContent",overridesResolver:(e,t)=>t.sectionContent})({outline:"none"}),Qge=e=>{const{classes:t}=e;return bn({root:["root"],section:["section"],sectionContent:["sectionContent"]},Gge,t)};function Xge(e){const{slots:t,slotProps:n,element:r,classes:o}=e,a=t?.section??K3,i=Cr({elementType:a,externalSlotProps:n?.section,externalForwardedProps:r.container,className:o.section,ownerState:{}}),s=t?.sectionContent??X3,l=Cr({elementType:s,externalSlotProps:n?.sectionContent,externalForwardedProps:r.content,additionalProps:{suppressContentEditableWarning:!0},className:o.sectionContent,ownerState:{}}),d=t?.sectionSeparator??Q3,u=Cr({elementType:d,externalSlotProps:n?.sectionSeparator,externalForwardedProps:r.before,ownerState:{position:"before"}}),m=Cr({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 Zge=C.forwardRef(function(e,t){const n=Kr({props:e,name:"MuiPickersSectionList"}),{slots:r,slotProps:o,elements:a,sectionListRef:i}=n,s=Hn(n,Kge),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(`.${eg.section}[data-sectionindex="${x}"]`)},getSectionContent(x){return m("getSectionContent").querySelector(`.${eg.section}[data-sectionindex="${x}"] .${eg.sectionContent}`)},getSectionIndexFromDOMElement(x){const w=m("getSectionIndexFromDOMElement");if(x==null||!w.contains(x))return null;let S=null;return x.classList.contains(eg.section)?S=x:x.classList.contains(eg.sectionContent)&&(S=x.parentElement),S==null?null:Number(S.dataset.sectionindex)}}));const g=r?.root??G3,y=Cr({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(Xge,{slots:r,slotProps:o,element:x,classes:l},w))})}))}),Jge=["elements","areAllSectionsEmpty","defaultValue","label","value","onChange","id","autoFocus","endAdornment","startAdornment","renderSuffix","slots","slotProps","contentEditable","tabIndex","onInput","onPaste","onKeyDown","fullWidth","name","readOnly","inputProps","inputRef","sectionListRef"],eye=e=>Math.round(e*1e5)/1e5,O1=nt("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:`${eye(.15/16)}em`,variants:[{props:{fullWidth:!0},style:{width:"100%"}}]})),Y2=nt(G3,{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}}]})),tye=nt(K3,{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"})),nye=nt(X3,{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"})),rye=nt(Q3,{name:"MuiPickersInputBase",slot:"Separator",overridesResolver:(e,t)=>t.separator})(()=>({whiteSpace:"pre",letterSpacing:"inherit"})),oye=nt("input",{name:"MuiPickersInputBase",slot:"Input",overridesResolver:(e,t)=>t.hiddenInput})(Fe({},bue)),aye=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${Tt(s)}`,l==="small"&&"inputSizeSmall",!!u&&"adornedStart",!!d&&"adornedEnd"],notchedOutline:["notchedOutline"],input:["input"],sectionsContainer:["sectionsContainer"],sectionContent:["sectionContent"],sectionBefore:["sectionBefore"],sectionAfter:["sectionAfter"]};return bn(m,Yge,o)},G2=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=Hn(n,Jge),A=C.useRef(null),F=vr(t,A),L=vr(T?.ref,O),_=Fs(),R=Ai();if(!R)throw new Error("MUI X: PickersInputBase should always be used inside a PickersTextField component");const z=ae=>{if(R.disabled){ae.stopPropagation();return}R.onFocus?.(ae)};C.useEffect(()=>{R&&R.setAdornedStart(!!d)},[R,d]),C.useEffect(()=>{R&&(o?R.onEmpty():R.onFilled())},[R,o]);const N=Fe({},n,R,{isRtl:_}),B=aye(N),I=m?.root||O1,H=Cr({elementType:I,externalSlotProps:g?.root,externalForwardedProps:D,additionalProps:{"aria-invalid":R.error,ref:F},className:B.root,ownerState:N}),Y=m?.input||Y2;return p.jsxs(I,Fe({},H,{children:[d,p.jsx(Zge,{sectionListRef:P,elements:r,contentEditable:y,tabIndex:x,className:B.sectionsContainer,onFocus:z,onBlur:R.onBlur,onInput:w,onPaste:S,onKeyDown:b,slots:{root:Y,section:tye,sectionContent:nye,sectionSeparator:rye},slotProps:{root:{ownerState:N},sectionContent:{className:Ip.sectionContent},sectionSeparator:({position:ae})=>({className:ae==="before"?Ip.sectionBefore:Ip.sectionAfter})}}),l,u?u(Fe({},R)):null,p.jsx(oye,Fe({name:$,className:B.input,value:a,onChange:i,id:s,"aria-hidden":"true",tabIndex:-1,readOnly:k,required:R.required,disabled:R.disabled},T,{ref:L}))]}))});function iye(e){return Cn("MuiPickersOutlinedInput",e)}const js=Fe({},Ip,fn("MuiPickersOutlinedInput",["root","notchedOutline","input"])),sye=["children","className","label","notched","shrink"],lye=nt("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}}),zN=nt("span")(({theme:e})=>({fontFamily:e.typography.fontFamily,fontSize:"inherit"})),cye=nt("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 uye(e){const{className:t,label:n}=e,r=Hn(e,sye),o=n!=null&&n!=="",a=Fe({},e,{withLabel:o});return p.jsx(lye,Fe({"aria-hidden":!0,className:t},r,{ownerState:a,children:p.jsx(cye,{ownerState:a,children:o?p.jsx(zN,{children:n}):p.jsx(zN,{className:"notranslate",children:""})})}))}const dye=["label","autoFocus","ownerState","notched"],fye=nt(O1,{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 .${js.notchedOutline}`]:{borderColor:(e.vars||e).palette.text.primary},"@media (hover: none)":{[`&:hover .${js.notchedOutline}`]:{borderColor:e.vars?`rgba(${e.vars.palette.common.onBackgroundChannel} / 0.23)`:t}},[`&.${js.focused} .${js.notchedOutline}`]:{borderStyle:"solid",borderWidth:2},[`&.${js.disabled}`]:{[`& .${js.notchedOutline}`]:{borderColor:(e.vars||e).palette.action.disabled},"*":{color:(e.vars||e).palette.action.disabled}},[`&.${js.error} .${js.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:{[`&.${js.focused}:not(.${js.error}) .${js.notchedOutline}`]:{borderColor:(e.vars||e).palette[n].main}}}))}}),pye=nt(Y2,{name:"MuiPickersOutlinedInput",slot:"SectionsContainer",overridesResolver:(e,t)=>t.sectionsContainer})({padding:"16.5px 0",variants:[{props:{size:"small"},style:{padding:"8.5px 0"}}]}),hye=e=>{const{classes:t}=e,n=bn({root:["root"],notchedOutline:["notchedOutline"],input:["input"]},iye,t);return Fe({},t,n)},Z3=C.forwardRef(function(e,t){const n=Kr({props:e,name:"MuiPickersOutlinedInput"}),{label:r,ownerState:o,notched:a}=n,i=Hn(n,dye),s=Ai(),l=Fe({},n,o,s,{color:s?.color||"primary"}),d=hye(l);return p.jsx(G2,Fe({slots:{root:fye,input:pye},renderSuffix:u=>p.jsx(uye,{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}))});Z3.muiName="Input";function mye(e){return Cn("MuiPickersFilledInput",e)}const cd=Fe({},Ip,fn("MuiPickersFilledInput",["root","underline","input"])),gye=["label","autoFocus","disableUnderline","ownerState"],yye=nt(O1,{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}},[`&.${cd.focused}`]:{backgroundColor:e.vars?e.vars.palette.FilledInput.bg:r},[`&.${cd.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"},[`&.${cd.focused}:after`]:{transform:"scaleX(1) translateX(0)"},[`&.${cd.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(.${cd.disabled}, .${cd.error}):before`]:{borderBottom:`1px solid ${(e.vars||e).palette.text.primary}`},[`&.${cd.disabled}:before`]:{borderBottomStyle:"dotted"}}},{props:({startAdornment:i})=>!!i,style:{paddingLeft:12}},{props:({endAdornment:i})=>!!i,style:{paddingRight:12}}]}}),vye=nt(Y2,{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}}]}),bye=e=>{const{classes:t,disableUnderline:n}=e,r=bn({root:["root",!n&&"underline"],input:["input"]},mye,t);return Fe({},t,r)},J3=C.forwardRef(function(e,t){const n=Kr({props:e,name:"MuiPickersFilledInput"}),{label:r,disableUnderline:o=!1,ownerState:a}=n,i=Hn(n,gye),s=Ai(),l=Fe({},n,a,s,{color:s?.color||"primary"}),d=bye(l);return p.jsx(G2,Fe({slots:{root:yye,input:vye},slotProps:{root:{disableUnderline:o}}},i,{label:r,classes:d,ref:t}))});J3.muiName="Input";function xye(e){return Cn("MuiPickersFilledInput",e)}const tg=Fe({},Ip,fn("MuiPickersInput",["root","input"])),wye=["label","autoFocus","disableUnderline","ownerState"],Sye=nt(O1,{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"},[`&.${tg.focused}:after`]:{transform:"scaleX(1) translateX(0)"},[`&.${tg.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(.${tg.disabled}, .${tg.error}):before`]:{borderBottom:`2px solid ${(e.vars||e).palette.text.primary}`,"@media (hover: none)":{borderBottom:`1px solid ${t}`}},[`&.${tg.disabled}:before`]:{borderBottomStyle:"dotted"}}}]}}),Cye=e=>{const{classes:t,disableUnderline:n}=e,r=bn({root:["root",!n&&"underline"],input:["input"]},xye,t);return Fe({},t,r)},e_=C.forwardRef(function(e,t){const n=Kr({props:e,name:"MuiPickersInput"}),{label:r,disableUnderline:o=!1,ownerState:a}=n,i=Hn(n,wye),s=Ai(),l=Fe({},n,a,s,{disableUnderline:o,color:s?.color||"primary"}),d=Cye(l);return p.jsx(G2,Fe({slots:{root:Sye}},i,{label:r,classes:d,ref:t}))});e_.muiName="Input";const kye=["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"],$ye={standard:e_,filled:J3,outlined:Z3},Rye=nt(L3,{name:"MuiPickersTextField",slot:"Root",overridesResolver:(e,t)=>t.root})({maxWidth:"100%"}),Tye=e=>{const{focused:t,disabled:n,classes:r,required:o}=e;return bn({root:["root",t&&!n&&"focused",n&&"disabled",o&&"required"]},Wge,r)},Eye=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:N,name:B,helperText:I,FormHelperTextProps:H,label:Y,InputLabelProps:ae}=n,K=Hn(n,kye),oe=C.useRef(null),ue=vr(t,oe),G=_s(N),ie=I&&G?`${G}-helper-text`:void 0,Q=Y&&G?`${G}-label`:void 0,ee=Fe({},n,{color:i,disabled:s,error:l,focused:L,required:u,variant:d}),Z=Tye(ee),de=$ye[d];return p.jsxs(Rye,Fe({className:Ht(Z.root,a),ref:ue,focused:L,onFocus:r,onBlur:o,disabled:s,variant:d,error:l,color:i,fullWidth:z,required:u,ownerState:ee},K,{children:[p.jsx(I3,Fe({htmlFor:G,id:Q},ae,{children:Y})),p.jsx(de,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:G,fullWidth:z,inputProps:g,inputRef:y,sectionListRef:x,label:Y,name:B,role:"group","aria-labelledby":Q,"aria-describedby":ie,"aria-live":ie?"polite":void 0},m)),I&&p.jsx(z3,Fe({id:ie},H,{children:I}))]}))}),Mye=["enableAccessibleFieldDOMStructure"],Oye=["InputProps","readOnly"],Pye=["onPaste","onKeyDown","inputMode","readOnly","InputProps","inputProps","inputRef"],jye=e=>{let{enableAccessibleFieldDOMStructure:t}=e,n=Hn(e,Mye);if(t){const{InputProps:m,readOnly:g}=n,y=Hn(n,Oye);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=Hn(n,Pye);return Fe({},u,{InputProps:Fe({},s??{},{readOnly:i}),inputProps:Fe({},l??{},{inputMode:a,onPaste:r,onKeyDown:o,ref:d})})},Aye=["slots","slotProps","InputProps","inputProps"],t_=C.forwardRef(function(e,t){const n=Kr({props:e,name:"MuiDateField"}),{slots:r,slotProps:o,InputProps:a,inputProps:i}=n,s=Hn(n,Aye),l=n,d=r?.textField??(e.enableAccessibleFieldDOMStructure?Eye:yr),u=Cr({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=Vge(u),g=jye(m),y=Bge(Fe({},g,{slots:r,slotProps:o}));return p.jsx(d,Fe({},y))}),n_=({shouldDisableDate:e,shouldDisableMonth:t,shouldDisableYear:n,minDate:r,maxDate:o,disableFuture:a,disablePast:i,timezone:s})=>{const l=ef();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])},Dye=(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")}},Nye=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(Dye(!!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=n_({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}},Iye=e=>Cn("MuiPickersFadeTransitionGroup",e);fn("MuiPickersFadeTransitionGroup",["root"]);const Lye=e=>{const{classes:t}=e;return bn({root:["root"]},Iye,t)},zye=nt(nv,{name:"MuiPickersFadeTransitionGroup",slot:"Root",overridesResolver:(e,t)=>t.root})({display:"block",position:"relative"});function r_(e){const t=Kr({props:e,name:"MuiPickersFadeTransitionGroup"}),{children:n,className:r,reduceAnimations:o,transKey:a}=t,i=Lye(t),s=Xd();return o?n:p.jsx(zye,{className:Ht(i.root,r),children:p.jsx(Hd,{appear:!1,mountOnEnter:!0,unmountOnExit:!0,timeout:{appear:s.transitions.duration.enteringScreen,enter:s.transitions.duration.enteringScreen,exit:0},children:n},a)})}function Fye(e){return Cn("MuiPickersDay",e)}const ud=fn("MuiPickersDay",["root","dayWithMargin","dayOutsideMonth","hiddenDaySpacingFiller","today","selected","disabled"]),_ye=["autoFocus","className","day","disabled","disableHighlightToday","disableMargin","hidden","isAnimating","onClick","onDaySelect","onFocus","onBlur","onKeyDown","onMouseDown","onMouseEnter","outsideCurrentMonth","selected","showDaysOutsideCurrentMonth","children","today","isFirstVisibleCell","isLastVisibleCell"],Bye=e=>{const{selected:t,disableMargin:n,disableHighlightToday:r,today:o,disabled:a,outsideCurrentMonth:i,showDaysOutsideCurrentMonth:s,classes:l}=e,d=i&&!s;return bn({root:["root",t&&!d&&"selected",a&&"disabled",!n&&"dayWithMargin",!r&&o&&"today",i&&s&&"dayOutsideMonth",d&&"hiddenDaySpacingFiller"],hiddenDaySpacingFiller:["hiddenDaySpacingFiller"]},Fye,l)},o_=({theme:e})=>Fe({},e.typography.caption,{width:by,height:by,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})`:as(e.palette.primary.main,e.palette.action.hoverOpacity)}},"&:focus":{backgroundColor:e.vars?`rgba(${e.vars.palette.primary.mainChannel} / ${e.vars.palette.action.focusOpacity})`:as(e.palette.primary.main,e.palette.action.focusOpacity),[`&.${ud.selected}`]:{willChange:"background-color",backgroundColor:(e.vars||e).palette.primary.dark}},[`&.${ud.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}},[`&.${ud.disabled}:not(.${ud.selected})`]:{color:(e.vars||e).palette.text.disabled},[`&.${ud.disabled}&.${ud.selected}`]:{opacity:.6},variants:[{props:{disableMargin:!1},style:{margin:`0 ${k1}px`}},{props:{outsideCurrentMonth:!0,showDaysOutsideCurrentMonth:!0},style:{color:(e.vars||e).palette.text.secondary}},{props:{disableHighlightToday:!1,today:!0},style:{[`&:not(.${ud.selected})`]:{border:`1px solid ${(e.vars||e).palette.text.secondary}`}}}]}),a_=(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]},Uye=nt(qd,{name:"MuiPickersDay",slot:"Root",overridesResolver:a_})(o_),qye=nt("div",{name:"MuiPickersDay",slot:"Root",overridesResolver:a_})(({theme:e})=>Fe({},o_({theme:e}),{opacity:0,pointerEvents:"none"})),ng=()=>{},Hye=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=ng,onBlur:y=ng,onKeyDown:x=ng,onMouseDown:w=ng,onMouseEnter:S=ng,outsideCurrentMonth:b,selected:$=!1,showDaysOutsideCurrentMonth:k=!1,children:T,today:O=!1}=n,P=Hn(n,_ye),D=Fe({},n,{autoFocus:r,disabled:i,disableHighlightToday:s,disableMargin:l,selected:$,showDaysOutsideCurrentMonth:k,today:O}),A=Bye(D),F=Qr(),L=C.useRef(null),_=vr(L,t);Go(()=>{r&&!i&&!d&&!b&&L.current.focus()},[r,i,d,b]);const R=N=>{w(N),b&&N.preventDefault()},z=N=>{i||m(a),b&&N.currentTarget.focus(),u&&u(N)};return b&&!k?p.jsx(qye,{className:Ht(A.root,A.hiddenDaySpacingFiller,o),ownerState:D,role:P.role}):p.jsx(Uye,Fe({className:Ht(A.root,o),ref:_,centerRipple:!0,disabled:i,tabIndex:$?0:-1,onKeyDown:N=>x(N,a),onFocus:N=>g(N,a),onBlur:N=>y(N,a),onMouseEnter:N=>S(N,a),onClick:z,onMouseDown:R},P,{ownerState:D,children:T||F.format(a,"dayOfMonth")}))}),Vye=C.memo(Hye),Wye=e=>Cn("MuiPickersSlideTransition",e),Hi=fn("MuiPickersSlideTransition",["root","slideEnter-left","slideEnter-right","slideEnterActive","slideExit","slideExitActiveLeft-left","slideExitActiveLeft-right"]),Yye=["children","className","reduceAnimations","slideDirection","transKey","classes"],Gye=e=>{const{classes:t,slideDirection:n}=e,r={root:["root"],exit:["slideExit"],enterActive:["slideEnterActive"],enter:[`slideEnter-${n}`],exitActive:[`slideExitActiveLeft-${n}`]};return bn(r,Wye,t)},Kye=nt(nv,{name:"MuiPickersSlideTransition",slot:"Root",overridesResolver:(e,t)=>[t.root,{[`.${Hi["slideEnter-left"]}`]:t["slideEnter-left"]},{[`.${Hi["slideEnter-right"]}`]:t["slideEnter-right"]},{[`.${Hi.slideEnterActive}`]:t.slideEnterActive},{[`.${Hi.slideExit}`]:t.slideExit},{[`.${Hi["slideExitActiveLeft-left"]}`]:t["slideExitActiveLeft-left"]},{[`.${Hi["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},[`& .${Hi["slideEnter-left"]}`]:{willChange:"transform",transform:"translate(100%)",zIndex:1},[`& .${Hi["slideEnter-right"]}`]:{willChange:"transform",transform:"translate(-100%)",zIndex:1},[`& .${Hi.slideEnterActive}`]:{transform:"translate(0%)",transition:t},[`& .${Hi.slideExit}`]:{transform:"translate(0%)"},[`& .${Hi["slideExitActiveLeft-left"]}`]:{willChange:"transform",transform:"translate(-100%)",transition:t,zIndex:0},[`& .${Hi["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=Hn(t,Yye),s=Gye(t),l=Xd();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(Kye,{className:Ht(s.root,r),childFactory:u=>C.cloneElement(u,{classNames:d}),role:"presentation",children:p.jsx(T2,Fe({mountOnEnter:!0,unmountOnExit:!0,timeout:l.transitions.duration.complex,classNames:d},i,{children:n}),a)})}const Xye=e=>Cn("MuiDayCalendar",e);fn("MuiDayCalendar",["root","header","weekDayLabel","loadingContainer","slideTransition","monthContainer","weekContainer","weekNumberLabel","weekNumber"]);const Zye=["parentProps","day","focusableDay","selectedDays","isDateDisabled","currentMonthNumber","isViewFocused"],Jye=["ownerState"],eve=e=>{const{classes:t}=e;return bn({root:["root"],header:["header"],weekDayLabel:["weekDayLabel"],loadingContainer:["loadingContainer"],slideTransition:["slideTransition"],monthContainer:["monthContainer"],weekContainer:["weekContainer"],weekNumberLabel:["weekNumberLabel"],weekNumber:["weekNumber"]},Xye,t)},i_=(by+k1*2)*6,tve=nt("div",{name:"MuiDayCalendar",slot:"Root",overridesResolver:(e,t)=>t.root})({}),nve=nt("div",{name:"MuiDayCalendar",slot:"Header",overridesResolver:(e,t)=>t.header})({display:"flex",justifyContent:"center",alignItems:"center"}),rve=nt(Sr,{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})),ove=nt(Sr,{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})),ave=nt(Sr,{name:"MuiDayCalendar",slot:"WeekNumber",overridesResolver:(e,t)=>t.weekNumber})(({theme:e})=>Fe({},e.typography.caption,{width:by,height:by,padding:0,margin:`0 ${k1}px`,color:e.palette.text.disabled,fontSize:"0.75rem",alignItems:"center",justifyContent:"center",display:"inline-flex"})),ive=nt("div",{name:"MuiDayCalendar",slot:"LoadingContainer",overridesResolver:(e,t)=>t.loadingContainer})({display:"flex",justifyContent:"center",alignItems:"center",minHeight:i_}),sve=nt(Qye,{name:"MuiDayCalendar",slot:"SlideTransition",overridesResolver:(e,t)=>t.slideTransition})({minHeight:i_}),lve=nt("div",{name:"MuiDayCalendar",slot:"MonthContainer",overridesResolver:(e,t)=>t.monthContainer})({overflow:"hidden"}),cve=nt("div",{name:"MuiDayCalendar",slot:"WeekContainer",overridesResolver:(e,t)=>t.weekContainer})({margin:`${k1}px 0`,display:"flex",justifyContent:"center"});function uve(e){let{parentProps:t,day:n,focusableDay:r,selectedDays:o,isDateDisabled:a,currentMonthNumber:i,isViewFocused:s}=e,l=Hn(e,Zye);const{disabled:d,disableHighlightToday:u,isMonthSwitchingAnimating:m,showDaysOutsideCurrentMonth:g,slots:y,slotProps:x,timezone:w}=t,S=Qr(),b=w1(w),$=r!==null&&S.isSameDay(n,r),k=o.some(R=>S.isSameDay(R,n)),T=S.isSameDay(n,b),O=y?.day??Vye,P=Cr({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=Hn(P,Jye),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 dve(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=Ae=>n.format(Ae,"weekdayShort").charAt(0).toUpperCase(),hasFocus:A,onFocusedViewChange:F,gridLabelId:L,displayWeekNumber:_,fixedWeekNumber:R,autoFocus:z,timezone:N}=t,B=w1(N),I=eve(t),H=Fs(),Y=n_({shouldDisableDate:T,shouldDisableMonth:O,shouldDisableYear:P,minDate:$,maxDate:k,disablePast:S,disableFuture:b,timezone:N}),ae=vc(),[K,oe]=Ti({name:"DayCalendar",state:"hasFocus",controlled:A,default:z??!1}),[ue,G]=C.useState(()=>s||B),ie=Yt(Ae=>{m||d(Ae)}),Q=Ae=>{Y(Ae)||(r(Ae),G(Ae),F?.(!0),oe(!0))},ee=Yt((Ae,Re)=>{switch(Ae.key){case"ArrowUp":Q(n.addDays(Re,-7)),Ae.preventDefault();break;case"ArrowDown":Q(n.addDays(Re,7)),Ae.preventDefault();break;case"ArrowLeft":{const re=n.addDays(Re,H?1:-1),_e=n.addMonths(Re,H?1:-1),Me=qg({utils:n,date:re,minDate:H?re:n.startOfMonth(_e),maxDate:H?n.endOfMonth(_e):re,isDateDisabled:Y,timezone:N});Q(Me||re),Ae.preventDefault();break}case"ArrowRight":{const re=n.addDays(Re,H?-1:1),_e=n.addMonths(Re,H?-1:1),Me=qg({utils:n,date:re,minDate:H?n.startOfMonth(_e):re,maxDate:H?re:n.endOfMonth(_e),isDateDisabled:Y,timezone:N});Q(Me||re),Ae.preventDefault();break}case"Home":Q(n.startOfWeek(Re)),Ae.preventDefault();break;case"End":Q(n.endOfWeek(Re)),Ae.preventDefault();break;case"PageUp":Q(n.addMonths(Re,1)),Ae.preventDefault();break;case"PageDown":Q(n.addMonths(Re,-1)),Ae.preventDefault();break}}),Z=Yt((Ae,Re)=>Q(Re)),de=Yt((Ae,Re)=>{K&&n.isSameDay(ue,Re)&&F?.(!1)}),le=n.getMonth(a),fe=n.getYear(a),he=C.useMemo(()=>i.filter(Ae=>!!Ae).map(Ae=>n.startOfDay(Ae)),[n,i]),me=`${fe}-${le}`,se=C.useMemo(()=>C.createRef(),[me]),ve=C.useMemo(()=>{const Ae=n.startOfMonth(a),Re=n.endOfMonth(a);return Y(ue)||n.isAfterDay(ue,Re)||n.isBeforeDay(ue,Ae)?qg({utils:n,date:ue,minDate:Ae,maxDate:Re,disablePast:S,disableFuture:b,isDateDisabled:Y,timezone:N}):ue},[a,b,S,ue,Y,n,N]),Le=C.useMemo(()=>{const Ae=n.getWeekArray(a);let Re=n.addMonths(a,1);for(;R&&Ae.length<R;){const re=n.getWeekArray(Re),_e=n.isSameDay(Ae[Ae.length-1][0],re[0][0]);re.slice(_e?1:0).forEach(Me=>{Ae.length<R&&Ae.push(Me)}),Re=n.addMonths(Re,1)}return Ae},[a,R,n]);return p.jsxs(tve,{role:"grid","aria-labelledby":L,className:I.root,children:[p.jsxs(nve,{role:"row",className:I.header,children:[_&&p.jsx(ove,{variant:"caption",role:"columnheader","aria-label":ae.calendarWeekNumberHeaderLabel,className:I.weekNumberLabel,children:ae.calendarWeekNumberHeaderText}),kue(n,B).map((Ae,Re)=>p.jsx(rve,{variant:"caption",role:"columnheader","aria-label":n.format(Ae,"weekday"),className:I.weekDayLabel,children:D(Ae)},Re.toString()))]}),l?p.jsx(ive,{className:I.loadingContainer,children:y()}):p.jsx(sve,Fe({transKey:me,onExited:u,reduceAnimations:g,slideDirection:x,className:Ht(o,I.slideTransition)},w,{nodeRef:se,children:p.jsx(lve,{ref:se,role:"rowgroup",className:I.monthContainer,children:Le.map((Ae,Re)=>p.jsxs(cve,{role:"row",className:I.weekContainer,"aria-rowindex":Re+1,children:[_&&p.jsx(ave,{className:I.weekNumber,role:"rowheader","aria-label":ae.calendarWeekNumberAriaLabelText(n.getWeekNumber(Ae[0])),children:ae.calendarWeekNumberText(n.getWeekNumber(Ae[0]))}),Ae.map((re,_e)=>p.jsx(uve,{parentProps:t,day:re,selectedDays:he,focusableDay:ve,onKeyDown:ee,onFocus:Z,onBlur:de,onDaySelect:ie,isDateDisabled:Y,currentMonthNumber:le,isViewFocused:K,"aria-colindex":_e+1},re.toString()))]},`week-${Ae[0]}`))})}))]})}function fve(e){return Cn("MuiPickersMonth",e)}const Ib=fn("MuiPickersMonth",["root","monthButton","disabled","selected"]),pve=["autoFocus","className","children","disabled","selected","value","tabIndex","onClick","onKeyDown","onFocus","onBlur","aria-current","aria-label","monthsPerRow","slots","slotProps"],hve=e=>{const{disabled:t,selected:n,classes:r}=e;return bn({root:["root"],monthButton:["monthButton",t&&"disabled",n&&"selected"]},fve,r)},mve=nt("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%"}}]}),gve=nt("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})`:as(e.palette.action.active,e.palette.action.hoverOpacity)},"&:hover":{backgroundColor:e.vars?`rgba(${e.vars.palette.action.activeChannel} / ${e.vars.palette.action.hoverOpacity})`:as(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}}})),yve=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=Hn(t,pve),$=C.useRef(null),k=hve(t);Go(()=>{n&&$.current?.focus()},[n]);const T=w?.monthButton??gve,O=Cr({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(mve,Fe({className:Ht(k.root,r),ownerState:t},b,{children:p.jsx(T,Fe({},O))}))});function vve(e){return Cn("MuiMonthCalendar",e)}fn("MuiMonthCalendar",["root"]);const bve=["className","value","defaultValue","referenceDate","disabled","disableFuture","disablePast","maxDate","minDate","onChange","shouldDisableMonth","readOnly","disableHighlightToday","autoFocus","onMonthFocus","hasFocus","onFocusedViewChange","monthsPerRow","timezone","gridLabelId","slots","slotProps"],xve=e=>{const{classes:t}=e;return bn({root:["root"]},vve,t)};function wve(e,t){const n=Qr(),r=ev(),o=Kr({props:e,name:t});return Fe({disableFuture:!1,disablePast:!1},o,{minDate:cs(n,o.minDate,r.minDate),maxDate:cs(n,o.maxDate,r.maxDate)})}const Sve=nt("div",{name:"MuiMonthCalendar",slot:"Root",overridesResolver:(e,t)=>t.root})({display:"flex",flexWrap:"wrap",alignContent:"stretch",padding:"0 4px",width:$1,boxSizing:"border-box"}),Cve=C.forwardRef(function(e,t){const n=wve(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=Hn(n,bve),{value:F,handleValueChange:L,timezone:_}=F2({name:"MonthCalendar",timezone:T,value:o,defaultValue:a,referenceDate:i,onChange:g,valueManager:Cl}),R=w1(_),z=Fs(),N=Qr(),B=C.useMemo(()=>Cl.getInitialReferenceValue({value:F,utils:N,props:n,timezone:_,referenceDate:i,granularity:dl.month}),[]),I=n,H=xve(I),Y=C.useMemo(()=>N.getMonth(R),[N,R]),ae=C.useMemo(()=>F!=null?N.getMonth(F):null,[F,N]),[K,oe]=C.useState(()=>ae||N.getMonth(B)),[ue,G]=Ti({name:"MonthCalendar",state:"hasFocus",controlled:b,default:w??!1}),ie=Yt(he=>{G(he),$&&$(he)}),Q=C.useCallback(he=>{const me=N.startOfMonth(d&&N.isAfter(R,m)?R:m),se=N.startOfMonth(l&&N.isBefore(R,u)?R:u),ve=N.startOfMonth(he);return N.isBefore(ve,me)||N.isAfter(ve,se)?!0:y?y(ve):!1},[l,d,u,m,R,y,N]),ee=Yt((he,me)=>{if(x)return;const se=N.setMonth(F??B,me);L(se)}),Z=Yt(he=>{Q(N.setMonth(F??B,he))||(oe(he),ie(!0),S&&S(he))});C.useEffect(()=>{oe(he=>ae!==null&&he!==ae?ae:he)},[ae]);const de=Yt((he,me)=>{switch(he.key){case"ArrowUp":Z((12+me-3)%12),he.preventDefault();break;case"ArrowDown":Z((12+me+3)%12),he.preventDefault();break;case"ArrowLeft":Z((12+me+(z?1:-1))%12),he.preventDefault();break;case"ArrowRight":Z((12+me+(z?-1:1))%12),he.preventDefault();break}}),le=Yt((he,me)=>{Z(me)}),fe=Yt((he,me)=>{K===me&&ie(!1)});return p.jsx(Sve,Fe({ref:t,className:Ht(H.root,r),ownerState:I,role:"radiogroup","aria-labelledby":O},A,{children:S2(N,F??B).map(he=>{const me=N.getMonth(he),se=N.format(he,"monthShort"),ve=N.format(he,"month"),Le=me===ae,Ae=s||Q(he);return p.jsx(yve,{selected:Le,value:me,onClick:ee,onKeyDown:de,autoFocus:ue&&me===K,disabled:Ae,tabIndex:me===K&&!Ae?0:-1,onFocus:le,onBlur:fe,"aria-current":Y===me?"date":void 0,"aria-label":ve,monthsPerRow:k,slots:P,slotProps:D,children:se},se)})}))});function kve(e){return Cn("MuiPickersYear",e)}const Lb=fn("MuiPickersYear",["root","yearButton","selected","disabled"]),$ve=["autoFocus","className","children","disabled","selected","value","tabIndex","onClick","onKeyDown","onFocus","onBlur","aria-current","yearsPerRow","slots","slotProps"],Rve=e=>{const{disabled:t,selected:n,classes:r}=e;return bn({root:["root"],yearButton:["yearButton",t&&"disabled",n&&"selected"]},kve,r)},Tve=nt("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%"}}]}),Eve=nt("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})`:as(e.palette.action.active,e.palette.action.focusOpacity)},"&:hover":{backgroundColor:e.vars?`rgba(${e.vars.palette.action.activeChannel} / ${e.vars.palette.action.hoverOpacity})`:as(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}}})),Mve=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=Hn(t,$ve),b=C.useRef(null),$=Rve(t);Go(()=>{n&&b.current?.focus()},[n]);const k=x?.yearButton??Eve,T=Cr({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(Tve,Fe({className:Ht($.root,r),ownerState:t},S,{children:p.jsx(k,Fe({},T))}))});function Ove(e){return Cn("MuiYearCalendar",e)}fn("MuiYearCalendar",["root"]);const Pve=["autoFocus","className","value","defaultValue","referenceDate","disabled","disableFuture","disablePast","maxDate","minDate","onChange","readOnly","shouldDisableYear","disableHighlightToday","onYearFocus","hasFocus","onFocusedViewChange","yearsOrder","yearsPerRow","timezone","gridLabelId","slots","slotProps"],jve=e=>{const{classes:t}=e;return bn({root:["root"]},Ove,t)};function Ave(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:cs(n,o.minDate,r.minDate),maxDate:cs(n,o.maxDate,r.maxDate)})}const Dve=nt("div",{name:"MuiYearCalendar",slot:"Root",overridesResolver:(e,t)=>t.root})({display:"flex",flexDirection:"row",flexWrap:"wrap",overflowY:"auto",height:"100%",padding:"0 4px",width:$1,maxHeight:Phe,boxSizing:"border-box",position:"relative"}),Nve=C.forwardRef(function(e,t){const n=Ave(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=Hn(n,Pve),{value:L,handleValueChange:_,timezone:R}=F2({name:"YearCalendar",timezone:O,value:a,defaultValue:i,referenceDate:s,onChange:y,valueManager:Cl}),z=w1(R),N=Fs(),B=Qr(),I=C.useMemo(()=>Cl.getInitialReferenceValue({value:L,utils:B,props:n,timezone:R,referenceDate:s,granularity:dl.year}),[]),H=n,Y=jve(H),ae=C.useMemo(()=>B.getYear(z),[B,z]),K=C.useMemo(()=>L!=null?B.getYear(L):null,[L,B]),[oe,ue]=C.useState(()=>K||B.getYear(I)),[G,ie]=Ti({name:"YearCalendar",state:"hasFocus",controlled:b,default:r??!1}),Q=Yt(Re=>{ie(Re),$&&$(Re)}),ee=C.useCallback(Re=>{if(u&&B.isBeforeYear(Re,z)||d&&B.isAfterYear(Re,z)||g&&B.isBeforeYear(Re,g)||m&&B.isAfterYear(Re,m))return!0;if(!w)return!1;const re=B.startOfYear(Re);return w(re)},[d,u,m,g,z,w,B]),Z=Yt((Re,re)=>{if(x)return;const _e=B.setYear(L??I,re);_(_e)}),de=Yt(Re=>{ee(B.setYear(L??I,Re))||(ue(Re),Q(!0),S?.(Re))});C.useEffect(()=>{ue(Re=>K!==null&&Re!==K?K:Re)},[K]);const le=k!=="desc"?T*1:T*-1,fe=N&&k==="asc"||!N&&k==="desc"?-1:1,he=Yt((Re,re)=>{switch(Re.key){case"ArrowUp":de(re-le),Re.preventDefault();break;case"ArrowDown":de(re+le),Re.preventDefault();break;case"ArrowLeft":de(re-fe),Re.preventDefault();break;case"ArrowRight":de(re+fe),Re.preventDefault();break}}),me=Yt((Re,re)=>{de(re)}),se=Yt((Re,re)=>{oe===re&&Q(!1)}),ve=C.useRef(null),Le=vr(t,ve);C.useEffect(()=>{if(r||ve.current===null)return;const Re=ve.current.querySelector('[tabindex="0"]');if(!Re)return;const re=Re.offsetHeight,_e=Re.offsetTop,Me=ve.current.clientHeight,Ge=ve.current.scrollTop,Je=_e+re;re>Me||_e<Ge||(ve.current.scrollTop=Je-Me/2-re/2)},[r]);const Ae=B.getYearRange([g,m]);return k==="desc"&&Ae.reverse(),p.jsx(Dve,Fe({ref:Le,className:Ht(Y.root,o),ownerState:H,role:"radiogroup","aria-labelledby":P},F,{children:Ae.map(Re=>{const re=B.getYear(Re),_e=re===K,Me=l||ee(Re);return p.jsx(Mve,{selected:_e,value:re,onClick:Z,onKeyDown:he,autoFocus:G&&re===oe,disabled:Me,tabIndex:re===oe&&!Me?0:-1,onFocus:me,onBlur:se,"aria-current":ae===re?"date":void 0,yearsPerRow:T,slots:D,slotProps:A,children:B.format(Re,"year")},B.format(Re,"year"))})}))}),Ive=e=>Cn("MuiPickersCalendarHeader",e),Lve=fn("MuiPickersCalendarHeader",["root","labelContainer","label","switchViewButton","switchViewIcon"]);function zve(e){return Cn("MuiPickersArrowSwitcher",e)}fn("MuiPickersArrowSwitcher",["root","spacer","button","previousIconButton","nextIconButton","leftArrowIcon","rightArrowIcon"]);const Fve=["children","className","slots","slotProps","isNextDisabled","isNextHidden","onGoToNext","nextLabel","isPreviousDisabled","isPreviousHidden","onGoToPrevious","previousLabel","labelId"],_ve=["ownerState"],Bve=["ownerState"],Uve=nt("div",{name:"MuiPickersArrowSwitcher",slot:"Root",overridesResolver:(e,t)=>t.root})({display:"flex"}),qve=nt("div",{name:"MuiPickersArrowSwitcher",slot:"Spacer",overridesResolver:(e,t)=>t.spacer})(({theme:e})=>({width:e.spacing(3)})),FN=nt(Tu,{name:"MuiPickersArrowSwitcher",slot:"Button",overridesResolver:(e,t)=>t.button})({variants:[{props:{hidden:!0},style:{visibility:"hidden"}}]}),Hve=e=>{const{classes:t}=e;return bn({root:["root"],spacer:["spacer"],button:["button"],previousIconButton:["previousIconButton"],nextIconButton:["nextIconButton"],leftArrowIcon:["leftArrowIcon"],rightArrowIcon:["rightArrowIcon"]},zve,t)},Vve=C.forwardRef(function(e,t){const n=Fs(),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=Hn(r,Fve),$=r,k=Hve($),T={isDisabled:l,isHidden:d,goTo:u,label:m},O={isDisabled:g,isHidden:y,goTo:x,label:w},P=i?.previousIconButton??FN,D=Cr({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??FN,F=Cr({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??Yhe,_=Cr({elementType:L,externalSlotProps:s?.leftArrowIcon,additionalProps:{fontSize:"inherit"},ownerState:$,className:k.leftArrowIcon}),R=Hn(_,_ve),z=i?.rightArrowIcon??Ghe,N=Cr({elementType:z,externalSlotProps:s?.rightArrowIcon,additionalProps:{fontSize:"inherit"},ownerState:$,className:k.rightArrowIcon}),B=Hn(N,Bve);return p.jsxs(Uve,Fe({ref:t,className:Ht(k.root,a),ownerState:$},b,{children:[p.jsx(P,Fe({},D,{children:n?p.jsx(z,Fe({},B)):p.jsx(L,Fe({},R))})),o?p.jsx(Sr,{variant:"subtitle1",component:"span",id:S,children:o}):p.jsx(qve,{className:k.spacer,ownerState:$}),p.jsx(A,Fe({},F,{children:n?p.jsx(L,Fe({},R)):p.jsx(z,Fe({},B))}))]}))});function Wve(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 Yve(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 Gve=["slots","slotProps","currentMonth","disabled","disableFuture","disablePast","maxDate","minDate","onMonthChange","onViewChange","view","reduceAnimations","views","labelId","className","timezone","format"],Kve=["ownerState"],Qve=e=>{const{classes:t}=e;return bn({root:["root"],labelContainer:["labelContainer"],label:["label"],switchViewButton:["switchViewButton"],switchViewIcon:["switchViewIcon"]},Ive,t)},Xve=nt("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}),Zve=nt("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})),Jve=nt("div",{name:"MuiPickersCalendarHeader",slot:"Label",overridesResolver:(e,t)=>t.label})({marginRight:6}),ebe=nt(Tu,{name:"MuiPickersCalendarHeader",slot:"SwitchViewButton",overridesResolver:(e,t)=>t.switchViewButton})({marginRight:"auto",variants:[{props:{view:"year"},style:{[`.${Lve.switchViewIcon}`]:{transform:"rotate(180deg)"}}}]}),tbe=nt(Whe,{name:"MuiPickersCalendarHeader",slot:"SwitchViewIcon",overridesResolver:(e,t)=>t.switchViewIcon})(({theme:e})=>({willChange:"transform",transition:e.transitions.create("transform"),transform:"rotate(0deg)"})),nbe=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=Hn(o,Gve),D=o,A=Qve(o),F=a?.switchViewButton??ebe,L=Cr({elementType:F,externalSlotProps:i?.switchViewButton,additionalProps:{size:"small","aria-label":n.calendarViewSwitchingButtonAriaLabel(w)},ownerState:D,className:A.switchViewButton}),_=a?.switchViewIcon??tbe,R=Cr({elementType:_,externalSlotProps:i?.switchViewIcon,ownerState:D,className:A.switchViewIcon}),z=Hn(R,Kve),N=()=>y(r.addMonths(s,1),"left"),B=()=>y(r.addMonths(s,-1),"right"),I=Wve(s,{disableFuture:d,maxDate:m,timezone:T}),H=Yve(s,{disablePast:u,minDate:g,timezone:T}),Y=()=>{if(!(b.length===1||!x||l))if(b.length===2)x(b.find(K=>K!==w)||b[0]);else{const K=b.indexOf(w)!==0?0:1;x(b[K])}};if(b.length===1&&b[0]==="year")return null;const ae=r.formatByString(s,O);return p.jsxs(Xve,Fe({},P,{ownerState:D,className:Ht(A.root,k),ref:t,children:[p.jsxs(Zve,{role:"presentation",onClick:Y,ownerState:D,"aria-live":"polite",className:A.labelContainer,children:[p.jsx(r_,{reduceAnimations:S,transKey:ae,children:p.jsx(Jve,{id:$,ownerState:D,className:A.label,children:ae})}),b.length>1&&!l&&p.jsx(F,Fe({},L,{children:p.jsx(_,Fe({},z))}))]}),p.jsx(Hd,{in:w==="day",appear:!S,enter:!S,children:p.jsx(Vve,{slots:a,slotProps:i,onGoToPrevious:B,isPreviousDisabled:H,previousLabel:n.previousMonth,onGoToNext:N,isNextDisabled:I,nextLabel:n.nextMonth})})]}))}),rbe=nt("div")({overflow:"hidden",width:$1,maxHeight:_2,display:"flex",flexDirection:"column",margin:"0 auto"}),obe=e=>Cn("MuiDateCalendar",e);fn("MuiDateCalendar",["root","viewTransitionContainer"]);const abe=["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"],ibe=e=>{const{classes:t}=e;return bn({root:["root"],viewTransitionContainer:["viewTransitionContainer"]},obe,t)};function sbe(e,t){const n=Qr(),r=ev(),o=R3(),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:cs(n,a.minDate,r.minDate),maxDate:cs(n,a.maxDate,r.maxDate)})}const lbe=nt(rbe,{name:"MuiDateCalendar",slot:"Root",overridesResolver:(e,t)=>t.root})({display:"flex",flexDirection:"column",height:_2}),cbe=nt(r_,{name:"MuiDateCalendar",slot:"ViewTransitionContainer",overridesResolver:(e,t)=>t.viewTransitionContainer})({}),ube=C.forwardRef(function(e,t){const n=Qr(),r=_s(),o=sbe(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:N,fixedWeekNumber:B,dayOfWeekFormatter:I,slots:H,slotProps:Y,loading:ae,renderLoading:K,displayWeekNumber:oe,yearsOrder:ue,yearsPerRow:G,monthsPerRow:ie,timezone:Q}=o,ee=Hn(o,abe),{value:Z,handleValueChange:de,timezone:le}=F2({name:"DateCalendar",timezone:Q,value:s,defaultValue:l,referenceDate:d,onChange:g,valueManager:Cl}),{view:fe,setView:he,focusedView:me,setFocusedView:se,goToNextView:ve,setValueAndGoToNextView:Le}=T3({view:k,views:T,openTo:O,onChange:de,onViewChange:i,autoFocus:a,focusedView:R,onFocusedViewChange:z}),{referenceDate:Ae,calendarState:Re,changeFocusedDay:re,changeMonth:_e,handleChangeMonth:Me,isDateDisabled:Ge,onMonthSwitchingAnimationEnd:Je}=Nye({value:Z,referenceDate:d,reduceAnimations:w,onMonthChange:x,minDate:F,maxDate:L,shouldDisableDate:S,disablePast:m,disableFuture:u,timezone:le}),St=D&&Z||F,Ut=D&&Z||L,at=`${r}-grid-label`,tt=me!==null,pt=H?.calendarHeader??nbe,ze=Cr({elementType:pt,externalSlotProps:Y?.calendarHeader,additionalProps:{views:T,view:fe,currentMonth:Re.currentMonth,onViewChange:he,onMonthChange:(nn,Bt)=>Me({newMonth:nn,direction:Bt}),minDate:St,maxDate:Ut,disabled:D,disablePast:m,disableFuture:u,reduceAnimations:w,timezone:le,labelId:at},ownerState:o}),be=Yt(nn=>{const Bt=n.startOfMonth(nn),pn=n.endOfMonth(nn),$n=Ge(nn)?qg({utils:n,date:nn,minDate:n.isBefore(F,Bt)?Bt:F,maxDate:n.isAfter(L,pn)?pn:L,disablePast:m,disableFuture:u,isDateDisabled:Ge,timezone:le}):nn;$n?(Le($n,"finish"),x?.(Bt)):(ve(),_e(Bt)),re($n,!0)}),Ve=Yt(nn=>{const Bt=n.startOfYear(nn),pn=n.endOfYear(nn),$n=Ge(nn)?qg({utils:n,date:nn,minDate:n.isBefore(F,Bt)?Bt:F,maxDate:n.isAfter(L,pn)?pn:L,disablePast:m,disableFuture:u,isDateDisabled:Ge,timezone:le}):nn;$n?(Le($n,"finish"),y?.($n)):(ve(),_e(Bt)),re($n,!0)}),Oe=Yt(nn=>de(nn&&H0(n,nn,Z??Ae),"finish",fe));C.useEffect(()=>{Z!=null&&n.isValid(Z)&&_e(Z)},[Z]);const $t=o,Rt=ibe($t),vt={disablePast:m,disableFuture:u,maxDate:L,minDate:F},it={disableHighlightToday:_,readOnly:A,disabled:D,timezone:le,gridLabelId:at,slots:H,slotProps:Y},st=C.useRef(fe);C.useEffect(()=>{st.current!==fe&&(me===st.current&&se(fe,!0),st.current=fe)},[me,se,fe]);const Dt=C.useMemo(()=>[Z],[Z]);return p.jsxs(lbe,Fe({ref:t,className:Ht(Rt.root,P),ownerState:$t},ee,{children:[p.jsx(pt,Fe({},ze,{slots:H,slotProps:Y})),p.jsx(cbe,{reduceAnimations:w,className:Rt.viewTransitionContainer,transKey:fe,ownerState:$t,children:p.jsxs("div",{children:[fe==="year"&&p.jsx(Nve,Fe({},vt,it,{value:Z,onChange:Ve,shouldDisableYear:$,hasFocus:tt,onFocusedViewChange:nn=>se("year",nn),yearsOrder:ue,yearsPerRow:G,referenceDate:Ae})),fe==="month"&&p.jsx(Cve,Fe({},vt,it,{hasFocus:tt,className:P,value:Z,onChange:be,shouldDisableMonth:b,onFocusedViewChange:nn=>se("month",nn),monthsPerRow:ie,referenceDate:Ae})),fe==="day"&&p.jsx(dve,Fe({},Re,vt,it,{onMonthSwitchingAnimationEnd:Je,onFocusedDayChange:re,reduceAnimations:w,selectedDays:Dt,onSelectedDaysChange:Oe,shouldDisableDate:S,shouldDisableMonth:b,shouldDisableYear:$,hasFocus:tt,onFocusedViewChange:nn=>se("day",nn),showDaysOutsideCurrentMonth:N,fixedWeekNumber:B,dayOfWeekFormatter:I,displayWeekNumber:oe,loading:ae,renderLoading:K}))]})})]}))}),Lp=({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:N,showDaysOutsideCurrentMonth:B,dayOfWeekFormatter:I,sx:H,autoFocus:Y,fixedWeekNumber:ae,displayWeekNumber:K,timezone:oe})=>p.jsx(ube,{view:e,onViewChange:t,views:n.filter(YD),focusedView:r&&YD(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:N,showDaysOutsideCurrentMonth:B,dayOfWeekFormatter:I,sx:H,autoFocus:Y,fixedWeekNumber:ae,displayWeekNumber:K,timezone:oe}),s_=C.forwardRef(function(e,t){const n=vc(),r=Qr(),o=l3(e,"MuiDesktopDatePicker"),a=Fe({day:Lp,month:Lp,year:Lp},o.viewRenderers),i=Fe({},o,{viewRenderers:a,format:C2(r,o,!1),yearsPerRow:o.yearsPerRow??4,slots:Fe({openPickerIcon:Khe,field:t_},o.slots),slotProps:Fe({},o.slotProps,{field:l=>Fe({},b1(o.slotProps?.field,l),u3(o),{ref:t}),toolbar:Fe({hidden:!0},o.slotProps?.toolbar)})}),{renderPicker:s}=Vhe({props:i,valueManager:Cl,valueType:"date",getOpenDialogAriaText:i3({utils:r,formatKey:"fullDate",contextTranslation:n.openDatePickerDialogue,propsTranslation:i.localeText?.openDatePickerDialogue}),validator:tv});return s()});s_.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:GF,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 dbe(e){return Cn("MuiDialogContent",e)}fn("MuiDialogContent",["root","dividers"]);const fbe=fn("MuiDialogTitle",["root"]),pbe=e=>{const{classes:t,dividers:n}=e;return bn({root:["root",n&&"dividers"]},dbe,t)},hbe=nt("div",{name:"MuiDialogContent",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.root,n.dividers&&t.dividers]}})(Gn(({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:{[`.${fbe.root} + &`]:{paddingTop:0}}}]}))),mbe=C.forwardRef(function(e,t){const n=Kn({props:e,name:"MuiDialogContent"}),{className:r,dividers:o=!1,...a}=n,i={...n,dividers:o},s=pbe(i);return p.jsx(hbe,{className:Ht(s.root,r),ownerState:i,ref:t,...a})});function gbe(e){return Cn("MuiDialog",e)}const Gg=fn("MuiDialog",["root","scrollPaper","scrollBody","container","paper","paperScrollPaper","paperScrollBody","paperWidthFalse","paperWidthXs","paperWidthSm","paperWidthMd","paperWidthLg","paperWidthXl","paperFullWidth","paperFullScreen"]),ybe=C.createContext({}),vbe=nt(_3,{name:"MuiDialog",slot:"Backdrop",overrides:(e,t)=>t.backdrop})({zIndex:-1}),bbe=e=>{const{classes:t,scroll:n,maxWidth:r,fullWidth:o,fullScreen:a}=e,i={root:["root"],container:["container",`scroll${Tt(n)}`],paper:["paper",`paperScroll${Tt(n)}`,`paperWidth${Tt(String(r))}`,o&&"paperFullWidth",a&&"paperFullScreen"]};return bn(i,gbe,t)},xbe=nt(B3,{name:"MuiDialog",slot:"Root"})({"@media print":{position:"absolute !important"}}),wbe=nt("div",{name:"MuiDialog",slot:"Container",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.container,t[`scroll${Tt(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"}}}]}),Sbe=nt(tf,{name:"MuiDialog",slot:"Paper",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.paper,t[`scrollPaper${Tt(n.scroll)}`],t[`paperWidth${Tt(String(n.maxWidth))}`],n.fullWidth&&t.paperFullWidth,n.fullScreen&&t.paperFullScreen]}})(Gn(({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)`,[`&.${Gg.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}`,[`&.${Gg.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,[`&.${Gg.paperScrollBody}`]:{margin:0,maxWidth:"100%"}}}]}))),Cbe=C.forwardRef(function(e,t){const n=Kn({props:e,name:"MuiDialog"}),r=Xd(),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=tf,PaperProps:T={},scroll:O="paper",slots:P={},slotProps:D={},TransitionComponent:A=Hd,transitionDuration:F=o,TransitionProps:L,..._}=n,R={...n,disableEscapeKeyDown:g,fullScreen:y,fullWidth:x,maxWidth:w,scroll:O},z=bbe(R),N=C.useRef(),B=me=>{N.current=me.target===me.currentTarget},I=me=>{S&&S(me),N.current&&(N.current=null,b&&b(me,"backdropClick"))},H=_s(i),Y=C.useMemo(()=>({titleId:H}),[H]),ae={transition:A,...P},K={transition:L,paper:T,backdrop:d,...D},oe={slots:ae,slotProps:K},[ue,G]=ur("root",{elementType:xbe,shouldForwardComponentProp:!0,externalForwardedProps:oe,ownerState:R,className:Ht(z.root,m),ref:t}),[ie,Q]=ur("backdrop",{elementType:vbe,shouldForwardComponentProp:!0,externalForwardedProps:oe,ownerState:R}),[ee,Z]=ur("paper",{elementType:Sbe,shouldForwardComponentProp:!0,externalForwardedProps:oe,ownerState:R,className:Ht(z.paper,T.className)}),[de,le]=ur("container",{elementType:wbe,externalForwardedProps:oe,ownerState:R,className:z.container}),[fe,he]=ur("transition",{elementType:Hd,externalForwardedProps:oe,ownerState:R,additionalProps:{appear:!0,in:$,timeout:F,role:"presentation"}});return p.jsx(ue,{closeAfterTransition:!0,slots:{backdrop:ie},slotProps:{backdrop:{transitionDuration:F,as:l,...Q}},disableEscapeKeyDown:g,onClose:b,open:$,onClick:I,...G,..._,children:p.jsx(fe,{...he,children:p.jsx(de,{onMouseDown:B,...le,children:p.jsx(ee,{as:k,elevation:24,role:"dialog","aria-describedby":a,"aria-labelledby":H,"aria-modal":s,...Z,children:p.jsx(ybe.Provider,{value:Y,children:u})})})})})}),kbe=nt(Cbe)({[`& .${Gg.container}`]:{outline:0},[`& .${Gg.paper}`]:{outline:0,minWidth:$1}}),$be=nt(mbe)({"&:first-of-type":{padding:0}});function Rbe(e){const{children:t,onDismiss:n,open:r,slots:o,slotProps:a}=e,i=o?.dialog??kbe,s=o?.mobileTransition??Hd;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($be,{children:t})}))}const Tbe=["props","getOpenDialogAriaText"],Ebe=e=>{let{props:t,getOpenDialogAriaText:n}=e,r=Hn(e,Tbe);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=_s(),P=a?.toolbar?.hidden??!1,{open:D,actions:A,layoutProps:F,renderCurrentView:L,fieldProps:_,contextValue:R}=E3(Fe({},r,{props:t,fieldRef:T,autoFocusView:!0,additionalViewProps:{},wrapperVariant:"mobile"})),z=o.field,N=Cr({elementType:z,externalSlotProps:a?.field,additionalProps:Fe({},_,P&&{id:O},!($||b)&&{onClick:A.onOpen,onKeyDown:Ppe(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});N.inputProps=Fe({},N.inputProps,{"aria-label":n(_.value)});const B=Fe({textField:o.textField},N.slots),I=o.layout??D3;let H=O;P&&(w?H=`${O}-label`:H=void 0);const Y=Fe({},a,{toolbar:Fe({},a?.toolbar,{titleId:O}),mobilePaper:Fe({"aria-labelledby":H},a?.mobilePaper)}),ae=vr(T,N.unstableFieldRef);return{renderPicker:()=>p.jsxs(N3,{contextValue:R,localeText:k,children:[p.jsx(z,Fe({},N,{slots:B,slotProps:Y,unstableFieldRef:ae})),p.jsx(Rbe,Fe({},A,{open:D,slots:o,slotProps:Y,children:p.jsx(I,Fe({},F,Y?.layout,{slots:o,slotProps:Y,children:L()}))}))]})}},l_=C.forwardRef(function(e,t){const n=vc(),r=Qr(),o=l3(e,"MuiMobileDatePicker"),a=Fe({day:Lp,month:Lp,year:Lp},o.viewRenderers),i=Fe({},o,{viewRenderers:a,format:C2(r,o,!1),slots:Fe({field:t_},o.slots),slotProps:Fe({},o.slotProps,{field:l=>Fe({},b1(o.slotProps?.field,l),u3(o),{ref:t}),toolbar:Fe({hidden:!1},o.slotProps?.toolbar)})}),{renderPicker:s}=Ebe({props:i,valueManager:Cl,valueType:"date",getOpenDialogAriaText:i3({utils:r,formatKey:"fullDate",contextTranslation:n.openDatePickerDialogue,propsTranslation:i.localeText?.openDatePickerDialogue}),validator:tv});return s()});l_.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:GF,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 Mbe=["desktopModeMediaQuery"],Obe=C.forwardRef(function(e,t){const n=Kr({props:e,name:"MuiDatePicker"}),{desktopModeMediaQuery:r=jpe}=n,o=Hn(n,Mbe);return YF(r,{defaultMatches:!0})?p.jsx(s_,Fe({ref:t},o)):p.jsx(l_,Fe({ref:t},o))}),c_=400;function u_(e,t){const[n,r]=C.useState(e);return C.useEffect(()=>{const o=setTimeout(()=>r(e),t);return()=>clearTimeout(o)},[e,t]),n}function d_(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]),$=u_(b,c_);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 Pbe=250,jbe=300*1e3;function Abe(e,t){const n=C.useContext(HR),r=t.trim(),[o,a]=C.useState("");C.useEffect(()=>{const m=setTimeout(()=>a(r),Pbe);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:jbe}).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 P1(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"?Dbe(n):n}function Dbe(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}Ar.extend(h2);const _N=14,Nbe=42;function Ibe(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 f_({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}=Vr(),m=e.type??"string",g=Ibe(e),y=P1(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"||TF(t),$=Q=>p.jsx(Ri,{label:d,value:String(t),error:!0,inputProps:{readOnly:!0},helperText:p.jsxs(p.Fragment,{children:[`Not a ${Q}. Clear it to pick one.`,w?p.jsx("br",{}):null,w]}),slotProps:{input:{endAdornment:p.jsx(p_,{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"?RF(t):[]:typeof t=="string"&&t!==""?[t]:[]:[],[A,F]=C.useState(""),[L,_]=C.useState(null),R=C.useRef(null),z=Abe(P?s:void 0,A);if(P&&S&&b&&!(!T&&D.length>1)){const Q=Z=>{const de=O?m2(Z):void 0;if(Z.length===0||de===""){n(null);return}n(O?de:Z[0])},ee=Ube(z,i,s);return p.jsx(h_.Provider,{value:ee,children:p.jsx(gK,{multiple:T,disableCloseOnSelect:T,onOpen:l,freeSolo:!0,forcePopupIcon:!0,autoSelect:!T,options:z.page?.values??r??[],...z.page?{filterOptions:Z=>Z}:{},onInputChange:(Z,de,le)=>F(le==="input"?de:""),loading:o||z.searching,loadingText:z.searching?"Searching…":"Loading…",noOptionsText:a?"Options unavailable":"No matching values",slots:{paper:Bbe},value:T?D:D[0]??null,onChange:(Z,de)=>Q(de===null?[]:Array.isArray(de)?de:[de]),renderInput:Z=>p.jsx(Ri,{...Z,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:{...Z.InputProps,endAdornment:p.jsxs(p.Fragment,{children:[o&&p.jsx(ku,{size:16}),Z.InputProps.endAdornment]})},htmlInput:{...Z.inputProps,onBlur:de=>{if(Z.inputProps.onBlur?.(de),!T)return;const le=de.target.value.trim();le!==""&&!D.includes(le)&&Q([...D,le])}}}}),fullWidth:!0})})}const N=ou(m)&&uu(m)==="number",{rangeMin:B,rangeMax:I}=e,H=N&&typeof t=="string"?MF(t):void 0,Y=N&&typeof t=="string"?OF(t):void 0;if((N||m==="number")&&B!==void 0&&I!==void 0&&(!N||t===void 0||t===null||t===""||H!==void 0||Y!==void 0)){const Q=Y??(H!==void 0?[H,I]:void 0),ee=N?Q?.[0]:typeof t=="number"?t:void 0;if(ee===void 0&&t!==void 0&&t!==null&&t!=="")return $("number");const Z=L!==null,de=Z?Array.isArray(L)?L[0]:L:ee??B,le=Array.isArray(L)?[L[0],L[1]]:Q??[B,I],fe=le[1]>=I?`≥ ${le[0]}`:`${le[0]} to ${le[1]}`,he=N&&t===""&&!Z,me=ee!==void 0||he||Z;return p.jsxs(gk,{fullWidth:!0,children:[p.jsxs(Te,{component:"fieldset",sx:se=>({m:0,minWidth:0,border:u.cardBorder,borderRadius:2,px:`${_N}px`,pt:0,pb:.75,minHeight:Nbe,transition:"border-color 120ms ease-in","&:hover":{borderColor:se.palette.text.secondary},"&:focus-within":{borderColor:se.palette.text.primary}}),children:[p.jsx(wt,{component:"legend",variant:"caption",color:"text.secondary",sx:{px:.5,lineHeight:1},children:d}),p.jsxs(Yn,{direction:"row",alignItems:"center",spacing:1,children:[p.jsx(wt,{variant:"body2",sx:{fontWeight:"fontWeightMedium"},children:me?he?"Any":N?fe:String(de):N?"Any":y??"Unset"}),me&&p.jsx(xy,{onClear:()=>n(null),sx:{p:0}})]}),p.jsx(cJ,{size:"small",min:B,max:I,value:N?le:de,disableSwap:N,valueLabelDisplay:"auto","aria-label":N?void 0:d,getAriaLabel:N?se=>se===0?`${d} from`:`${d} to`:void 0,sx:{py:0,mt:.5},onChange:(se,ve)=>{R.current=ve,_(ve)},onChangeCommitted:()=>{const se=R.current;if(R.current=null,_(null),se!==null){if(N){const[ve,Le]=Array.isArray(se)?[se[0],se[1]]:[se,se];if(ve<=B&&Le>=I){n(null);return}n(Le>=I?pce(ve):hce(ve,Le));return}n(Array.isArray(se)?se[0]:se)}}}),p.jsxs(Yn,{direction:"row",justifyContent:"space-between",children:[p.jsx(wt,{variant:"caption",color:"text.secondary",children:B}),p.jsx(wt,{variant:"caption",color:"text.secondary",children:I})]})]}),w&&p.jsx(yk,{sx:{mx:`${_N}px`},children:w})]})}const ae=ou(m)?uu(m):void 0,K=ae==="date"||ae==="timestamp"||ae==="timestamptz",oe=typeof t=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(t),ue=t==null||oe;if(K&&!oe){const Q=Fbe(t);if(Q!==void 0)return p.jsx(_be,{label:d,state:Q,onChange:n,helperNode:w,defaultDisplay:y})}if(K&&ue){const Q=oe?Ar.utc(t):null;return p.jsx(K0,{label:d,committed:Q?.isValid()?Q:null,toValue:ee=>ee.format("YYYY-MM-DD"),onChange:n,helperText:w})}if(uu(m)==="boolean"){const Q=typeof t=="string"?fce(t):void 0;if(t==null||t===""||Q!==void 0)return p.jsx(zbe,{label:d,picked:Q,emptyOverride:t==="",onChange:n,helperNode:w,defaultDisplay:y})}if(m==="boolean"){const Q=typeof t=="boolean";if(!Q&&t!==void 0&&t!==null)return $("true or false");const ee=e.default?.trim()==="true";return p.jsxs(gk,{children:[p.jsxs(Yn,{direction:"row",alignItems:"center",children:[p.jsx(MR,{control:p.jsx(oQ,{checked:Q?t:ee,onChange:Z=>n(Z.target.checked)}),label:d}),Q&&p.jsx(xy,{onClear:()=>n(null),edge:"end"})]}),w&&p.jsx(yk,{children:w})]})}if(m==="number"){const Q=t!=null;return Q&&t!==""&&typeof t!="number"?$("number"):p.jsx(BN,{label:d,type:"number",committed:typeof t=="number"?String(t):"",onCommit:ee=>n(ee===""?null:Number(ee)),placeholder:y,helperText:w,isOverridden:Q,onClear:()=>n(null)})}if(m==="date"||m==="timestamp"||m==="timestamptz"){const Q=t instanceof Date?t:typeof t=="string"?(Z=>Z instanceof Date?Z:null)(FF(m,t)):null,ee=Q?Ar.utc(Q):null;return t!=null&&t!==""&&Q===null?$("date"):p.jsx(K0,{label:d,committed:ee,toValue:Z=>wce(Z,Q??void 0),onChange:n,helperText:w})}const G=typeof t=="string"?t:"",ie=t!=null;return p.jsx(BN,{label:d,committed:G,onCommit:n,placeholder:ie?void 0:y??(m.startsWith("filter<")?m:void 0),helperText:w,isOverridden:ie,emptyOverrides:!0,onClear:()=>n(null)})}function BN({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}=d_(n,r,{unset:s&&!i});return p.jsx(Ri,{label:e,type:t,value:d,onChange:y=>u(y.target.value),placeholder:o,helperText:a,slotProps:{input:{endAdornment:i&&p.jsx(p_,{onClear:()=>{m(""),l()}})}},...g,fullWidth:!0,size:"small"})}const Lbe=(e,t)=>e===null||t===null?e===t:e.year()===t.year()&&e.month()===t.month()&&e.date()===t.date();function K0({label:e,committed:t,toValue:n,onChange:r,helperText:o,minDate:a}){const{draft:i,change:s,reset:l,bind:d}=d_(t,u=>{u===null?r(null):u.isValid()&&r(n(u))},{same:Lbe});return p.jsx(a3,{dateAdapter:fue,children:p.jsx(Obe,{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 xy({onClear:e,edge:t,sx:n}){return p.jsx(ro,{size:"small","aria-label":"Clear value",onClick:e,edge:t,sx:[{minWidth:24,minHeight:24},...Array.isArray(n)?n:[n]],children:p.jsx(Uce,{fontSize:"small"})})}function p_({onClear:e}){return p.jsx(PR,{position:"end",onMouseDown:t=>t.preventDefault(),children:p.jsx(xy,{onClear:e,edge:"end"})})}const zb="__any__";function zbe({label:e,picked:t,emptyOverride:n,onChange:r,helperNode:o,defaultDisplay:a}){const i=t??(n?zb:"");return p.jsx(Te,{"data-testid":"boolean-filter",children:p.jsxs(Ri,{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(xy,{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 Fbe(e){if(e==null)return{kind:"unset"};if(typeof e!="string")return;if(e==="")return{kind:"any"};const t=PF(e);if(t!==void 0)return{kind:"preset",key:t};const n=jF(e);if(n!==void 0)return{kind:"days",...n}}const Fb="__custom__",RC="__any__";function _be({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&&!Ar.utc(x.to).isBefore(Ar.utc(x.from))&&n(yce(x.from,x.to))},y=x=>{const w=x?Ar.utc(x):null;return w?.isValid()?w:null};return p.jsxs(Yn,{direction:"row",spacing:1,"data-testid":"time-range",children:[p.jsxs(Ri,{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=my.find(S=>S.key===x);return w?w.label:o??"Any time"}},input:{endAdornment:u?p.jsx(xy,{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=mce(w);S!==void 0&&n(S)},children:[t.kind==="any"&&p.jsx(ea,{value:RC,children:"Any time"}),my.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(K0,{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(K0,{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 h_=C.createContext(void 0);function Bbe({children:e,...t}){const n=C.useContext(h_);return p.jsxs(Qa,{...t,children:[e,n&&p.jsx(Te,{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 Ube(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(Md)}.`:e.page?.truncated?`Showing the first ${_b(v2)} matches. Keep typing to narrow them.`:void 0;if(t)return n?`Showing the first ${_b(Md)} values. Type to search them all.`:`Showing the first ${_b(Md)} values. A value not listed can still be typed.`}const qbe=C.createContext(void 0),Sh=()=>C.useContext(qbe),Tg="remove-badge",Hbe={[`& .${Tg}`]:{opacity:0},[`&:hover .${Tg}, &:focus-within .${Tg}`]:{opacity:1},"@media (hover: none)":{[`& .${Tg}`]:{opacity:1}}};function Vbe({label:e,onRemove:t,disabledReason:n,inset:r=0}){const{theme:o}=Vr(),a=n!==void 0,i=p.jsx(ro,{className:Tg,"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 ${Zd(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:mF(o.cardBorder,o.tileTitle)}}),children:p.jsx(xh,{sx:{fontSize:12}})});return a?p.jsx(Br,{title:n,children:i}):i}const K2=e=>e.required===!0,Wbe=(e,t)=>e==null||e===""&&!zF(t);function Ybe(e,t,n){return e.filter(r=>r.name!==void 0&&K2(r)&&Wbe(t.get(r.name),r.type)&&(n?.[r.name]===void 0||n[r.name]===null))}function Gbe(e,t){if(!t||e.length===0)return[];const n=new Set(t);return e.filter(r=>r.name&&n.has(r.name))}const m_=e=>e.label??e.name??"";function g_(e){return e.length<2?e.join(""):`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function Kbe(e){const t=e.map(m_);return`Pick a value for ${g_(t)} to see this report.`}function Qbe(e){return`Waiting for ${g_(e.map(m_))}.`}const y$=28,Xbe=/^\d{4}-\d{2}-\d{2}$/,y_=new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric",timeZone:"UTC"});function TC(e){if(!Xbe.test(e))return e;const t=new Date(`${e}T00:00:00Z`);return Number.isNaN(t.getTime())?e:y_.format(t)}function Zbe(e,t){if(e.length===0)return"";const n=e.join(", ");return t?n:n.length<=y$||e.length===1?Q0(n,t):`${Q0(e[0]??"",t)} +${e.length-1}`}function Q0(e,t){return!t&&e.length>y$?`${e.slice(0,y$-1)}…`:e}function Jbe(e,t){if(K2(e))return"Required";const n=e.type??"string",r=P1(n,e.default);if(r!==void 0&&r!=="")return v_(n,r,t);const o=uu(n)??n;return e.control==="select"||e.control==="multiselect"||o==="string"?"All":"Any"}function v_(e,t,n){if(!ou(e))return Q0(TC(t),n);const r=uu(e);if(r==="string"&&TF(t))return Zbe(RF(t),n);if(r==="number"){const o=OF(t);if(o)return`${o[0]}–${o[1]}`;const a=MF(t);if(a!==void 0)return`≥ ${a}`}if(r==="date"||r==="timestamp"||r==="timestamptz"){const o=PF(t);if(o)return my.find(i=>i.key===o)?.label??t;const a=jF(t);if(a)return`${TC(a.firstDay)} – ${TC(a.lastDay)}`}return Q0(t,n)}function b_(e,t,n){return t==null?Jbe(e,n):t instanceof Date?Number.isNaN(t.getTime())?"":y_.format(t):typeof t=="boolean"?t?"Yes":"No":typeof t=="number"?String(t):t===""?"(empty)":v_(e.type??"string",t,n)}function e0e(e,t){return b_(e,t,!1)}function t0e(e,t){return b_(e,t,!0)}function n0e(e){const{given:t,value:n,onChange:r}=e,{theme:o}=Vr(),a=o.ui,i=Sh(),[s,l]=C.useState(null),d=t.name??"",u=t.label??d,m=n!=null,g=e0e(t,n),y=s!==null,x=i?.stateOf(d),w=x?.problem,S=x?.fixed,b=p.jsxs(x_,{name:d,set:m,open:y,problem:w,fixed:S!==void 0,required:!m&&K2(t),children:[p.jsxs(is,{"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(Te,{component:"span",sx:$=>({color:m?o.accent:$.palette.text.secondary,whiteSpace:"nowrap"}),children:u}),p.jsx(Te,{component:"span",sx:{fontWeight:a.type.control.fontWeight,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:g}),!m&&p.jsx(hF,{"aria-hidden":!0,sx:$=>({fontSize:16,color:$.palette.text.secondary,transform:y?"rotate(180deg)":"none"})})]}),m&&p.jsx(ro,{"aria-label":`Clear ${u}`,onClick:()=>r(null),sx:{width:22,height:22,mr:"4px",borderRadius:"4px",color:o.accent},children:p.jsx(xh,{sx:{fontSize:14}})})]});return p.jsxs(p.Fragment,{children:[w?p.jsx(Br,{title:w,children:b}):b,p.jsxs(DR,{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(f_,{...e}),i&&p.jsxs(Te,{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(a0e,{name:d,type:t.type,text:r0e(n,t.type)}),S===void 0?p.jsx(Vn,{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(Vn,{size:"small",onClick:()=>{l(null),x.openModel?.()},sx:{px:.75,minWidth:0,...a.type.control},children:"Open the model"})]})]})]})}function r0e(e,t){if(e!=null)return IF(e,t)}function o0e(e,t){return e===void 0||!t?.startsWith("filter<")?e:/^f(['"])([\s\S]*)\1$/.exec(e)?.[2]??e}function a0e({name:e,type:t,text:n}){const r=Sh(),o=Vr().theme.ui;if(!r?.setStartingValue)return null;const a=r.setStartingValue,i=o0e(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(pF,{"aria-hidden":!0,sx:{fontSize:14}}),"Report default"]}),n!==void 0&&n!==i&&p.jsx(Vn,{size:"small",onClick:()=>a(e,n),sx:l,children:"Make this the report's default"}),i!==void 0&&p.jsx(Vn,{size:"small",onClick:()=>a(e,void 0),sx:l,children:s?"Use the filter's default":"Use the model's default"})]})}function x_({name:e,set:t=!1,open:n=!1,unused:r=!1,problem:o,fixed:a=!1,required:i=!1,children:s}){const{theme:l}=Vr(),d=l.ui,u=Sh();return p.jsxs(Te,{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:Zd(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:mF(l.cardBorder,l.tileTitle)},maxWidth:"100%",...Hbe}),children:[s,u&&!a&&p.jsx(Vbe,{label:`Remove filter ${e}`,onRemove:()=>u.onRemove(e)})]})}function i0e({name:e,label:t,unused:n=!0}){const r=Sh(),o=Vr().theme.ui;if(!r)return null;const a=r.stateOf(e)?.problem,i=p.jsx(x_,{name:e,unused:n,problem:a,children:p.jsxs(is,{"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(Te,{component:"span",sx:{fontStyle:"italic"},children:"Unused"})]})});return a?p.jsx(Br,{title:a,children:i}):i}function s0e(){const{theme:e}=Vr(),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(Vn,{variant:"outlined",startIcon:p.jsx(f1,{}),"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:Zd(e.cardBorder),color:o.palette.text.secondary,boxShadow:"none",...t.type.control,"& .MuiButton-startIcon":{mr:.5},"& .MuiButton-startIcon svg":{fontSize:16}}),children:"Filter"})})})}function j1({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(Te,{children:p.jsx(f_,{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(Yn,{direction:"row",alignItems:"center",spacing:1,children:[m&&p.jsx(Vn,{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(Vn,{variant:"text",size:"small",onClick:r,children:"Reset"})]});return a==="bar"?p.jsxs(Yn,{direction:"row",role:"group","aria-label":g??"Filters",useFlexGap:!0,sx:{flexWrap:"wrap",alignItems:"center",gap:1},children:[e.map(T=>p.jsx(n0e,{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(i0e,{name:T.name,label:T.label},T.name)),p.jsx(s0e,{}),p.jsx(Te,{sx:{ml:"auto"},children:k})]}):p.jsxs(Qa,{elevation:0,sx:{p:3,backgroundColor:"transparent",border:"none",boxShadow:"none"},children:[p.jsxs(Yn,{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(Te,{sx:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(220px, 1fr))",alignItems:"start",columnGap:3,rowGap:2.5},children:$})]})}const l0e=/^(https?|mailto|tel):/i,c0e=/^[a-z][a-z0-9+.-]*:/i;function u0e({href:e,title:t,children:n,context:r}){const o=!!e&&c0e.test(e),a=!!e&&!o&&!e.startsWith("/")&&!e.startsWith("#");if(!e||!a||!r){const m=o&&!l0e.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 d0e=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:ple},"& 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 f0e({alt:e}){return p.jsx(p.Fragment,{children:e})}function oh({children:e,variant:t="caption",links:n,sx:r}){const{theme:o}=Vr();return p.jsx(Te,{sx:[d0e(o.ui)[t],{fontFamily:o.font.family},...Array.isArray(r)?r:[r]],children:p.jsx(Zoe,{options:{forceBlock:t==="document",disableParsingRawHTML:!0,overrides:{a:{component:u0e,props:{context:n}},img:{component:f0e}}},children:e})})}const wu={opening:e=>e?`Opening the ${e}…`:"Opening…",running:"Running…",loading:"Loading…"};function Bo({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(Te,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:a},children:[p.jsx(ku,{size:t,color:n,thickness:r}),e&&p.jsx(wt,{variant:i,color:"text.secondary",children:e})]});return o?p.jsx(Te,{sx:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"200px",width:"100%"},children:s}):s}let rg;function p0e(){return rg||(rg=wo(()=>import("./index-DgBiwYeC.js"),[]),rg.catch(()=>{rg=void 0})),rg}function Q2(){typeof window>"u"||p0e().catch(()=>{})}const w_=Jt(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 zp({sx:e,...t}){const{theme:n}=Vr();return p.jsx(ro,{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 h0e=new Set(["warn","error"]);function m0e(e){if(!e?.length)return;const t=[];let n=!1;for(const r of e)!r.message||!h0e.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 g0e=C.lazy(()=>wo(()=>import("./RenderedResult-DqPvGZgL.es-Cga6-xj5.js"),[]).then(e=>e.c));function A1({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(()=>Q2(),[]);const[u,m]=C.useState(void 0),[g,y]=C.useState(void 0),[x,w]=C.useState(void 0),S=C.useCallback((B,I)=>{m(B),w(I)},[]),[b,$]=C.useState(!1),[k,T]=C.useState(void 0),O=m0e(a);C.useEffect(()=>{const B=d.current;if(!s||!B)return;const I=new ResizeObserver(([H])=>{T(Math.round(H.contentRect.height)),F(Math.round(H.contentRect.width))});return I.observe(B),()=>I.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(Te,{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(gae,{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(Vn,{variant:"contained",color:"primary",onClick:()=>$(!0),children:"Proceed"})]});const _=p.jsx(Bo,{text:wu.loading,centered:!0,size:32}),R=Dle({renderAs:x,maxHeight:t,tableMaxHeight:n}),z=MD({sizing:u,contentHeight:g,maxHeight:R,fillHeight:s?k:void 0,firstPaintHeight:r}),N=p.jsx(C.Suspense,{fallback:_,children:p.jsx(g0e,{result:e,height:z,onSizeChange:y,onSizing:S,drill:i,fill:s})});return p.jsxs(Te,{ref:d,sx:{position:"relative",height:"auto",border:"0px",borderRadius:0,overflowX:"hidden",overflowY:s?"hidden":"auto",...s&&{flex:`1 1 ${MD({sizing:u,contentHeight:g,maxHeight:R,firstPaintHeight:r})}px`,minHeight:0}},children:[s?p.jsx(Te,{className:Ble,...L&&P!==void 0?{[_le]:""}:{},sx:{position:"absolute",inset:0,overflowX:"hidden",overflowY:"auto"},children:N}):N,O&&p.jsx(Te,{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(zp,{"aria-label":"Render tag warnings",children:p.jsx(w_,{fontSize:"small",color:O.severity==="error"?"error":"warning"})})})})]})}function X2({state:e,context:t,loadingText:n=wu.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&&Q2()},[b]);const $=m?.data.result,k=C.useMemo(()=>$!==void 0&&u?u($):$,[$,u]),T=C.useMemo(()=>xle(k),[k]);if(y)return p.jsx(Te,{sx:{p:2},children:p.jsx(ja,{context:t,error:x})});if(!g)return p.jsx(Bo,{text:w==="idle"?wu.loading:n});if(T)return p.jsx(Te,{sx:{p:2},children:p.jsx(wt,{variant:"body2",role:"status",color:"text.secondary",children:T})});const O=p.jsx(A1,{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(Te,{"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(hz,{"aria-label":n,sx:{position:"absolute",top:0,left:0,right:0,height:2,zIndex:1,bgcolor:"transparent",borderRadius:1}}),p.jsx(Te,{className:"result-body",children:O})]})}const Pd=()=>typeof performance<"u"?performance.now():Date.now(),y0e=Jt(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"})),v0e=3;function b0e(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 x0e(e){return e.length<2?e.join(""):`${e.slice(0,-1).join(", ")} or ${e[e.length-1]}`}function w0e({ignored:e}){const{theme:t}=Vr();if(e.length===0)return null;const n=e.length>v0e?`Doesn't respond to ${e.length} filters`:`Doesn't respond to ${e.join(", ")}`;return p.jsxs(Te,{"data-testid":"tile-filter-tag",title:`This tile's query never reads ${x0e(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(y0e,{sx:{fontSize:12}}),p.jsx(Te,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n})]})}const S0e=/\.malloy(nb)?$/,D1=e=>e&&e.slice(e.lastIndexOf("/")+1).replace(S0e,"")||void 0,C0e=e=>e.replace(/\.malloy$/,"").split("/").map(encodeURIComponent).join("/"),S_=(e,t,n)=>`/${encodeURIComponent(e)}/${encodeURIComponent(t)}/${C0e(n)}`,k0e="edit",$0e=(e,t,n)=>`${S_(e,t,n)}?${k0e}`,Z2=e=>e.layout==="linear"?"linear":"grid",v$=e=>({layout:Z2(e),path:e.path,editable:e.editable!==!1});function R0e(e,t){const n=t.find(r=>r.path===e);return n?.path?v$({...n,path:n.path}):void 0}function T0e(e){return e===""||e.startsWith("/")?!1:e.split("/").every(t=>t!==""&&t!=="."&&t!=="..")}function E0e(e,t){if(!T0e(e))return{kind:"unresolved"};for(const n of[`${e}.malloy`,e]){const r=R0e(n,t);if(r)return{kind:"path",report:r}}return{kind:"unresolved"}}const M0e=(e,t,n)=>["reports",e,t,n];async function O0e(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 C_(e,t,n,r=!0){const{apiClients:o}=tr(),a=co({queryKey:M0e(e,t,n),queryFn:()=>O0e(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 k_=20,P0e={radius:"8px",padding:`${k_}px`};function TTe(e,t=P0e){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 j0e={query:120,text:72};function X0({borderless:e=!1,chrome:t="card",kind:n="query",sx:r,cardRef:o,children:a}){const{theme:i}=Vr(),s=i.ui,l=e||t==="none";return p.jsx(Qa,{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:j0e[n],p:t==="none"?0:e?"12px 0":`${k_}px`},...Array.isArray(r)?r:[r]],children:a})}const A0e=Sl.tileHeading;function $_({title:e,subtitle:t,tooltip:n,action:r,quiet:o=!1}){const{theme:a}=Vr(),i=a.ui;return p.jsxs(Te,{className:A0e,sx:{pb:o?.5:1.5,display:"flex",alignItems:"flex-start",gap:1},children:[p.jsxs(Te,{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 D0e=-1;function N0e(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 I0e(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 L0e(){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=N0e(r),a=o??window;let i=0;const s=()=>{i=0,t(I0e(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 z0e=4,F0e="--publisher-sticky-top",_0e=2;function b$({layout:e,notice:t,header:n,controls:r,children:o,sx:a}){return p.jsxs(Yn,{className:Sl.report,"data-layout":e,sx:[{gap:_0e},...Array.isArray(a)?a:[a]],children:[t,n,r,o]})}function R_({title:e,description:t,actions:n}){const r=Vr().theme.ui;return p.jsxs(Yn,{className:Sl.header,sx:{gap:1.5},children:[p.jsxs(Yn,{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(Te,{sx:{my:"-4px"},children:n})]}),t]})}function N1({sx:e,children:t}){return p.jsx(X0,{chrome:"none",kind:"text",...e?{sx:e}:{},children:t})}function T_({children:e}){const{theme:t}=Vr(),{stickyRef:n,stuck:r}=L0e();return p.jsx(Te,{ref:n,className:Sl.filterRow,"data-stuck":r||void 0,sx:{position:"sticky",top:`calc(var(${F0e}, 0px) + ${D0e}px)`,zIndex:z0e,bgcolor:r?"background.default":"transparent",pb:1,pt:1,mt:-1,boxShadow:r?`0 1px 0 ${Zd(t.cardBorder)}`:"none",transition:`box-shadow ${Zy}`,...Jy},children:e})}const Xr=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 J2(e,t){if(e[t])return e;const n=e.default;return n?.[t]?n:e}const B0e=e=>J2(e,"MalloyTranslator"),U0e=e=>J2(e,"parseAnnotation"),q0e=e=>J2(e,"ASTQuery");async function ETe(){return B0e(await wo(()=>import("./index-DhoAPSk5.js").then(e=>e.i),__vite__mapDeps([0,1])))}async function MTe(){return U0e(await wo(()=>Promise.resolve().then(()=>Rae),void 0))}async function H0e(){return q0e(await wo(()=>import("./index-NoukhIo4.js").then(e=>e.i),__vite__mapDeps([2,1])))}async function V0e(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 E_(e){return e.find(t=>t.authoritative)??e.find(t=>t.writeable)}function W0e({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 OTe(e,t){return e??(t===void 0?void 0:await V0e(t))}function PTe({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 jTe(e){return e instanceof Error?e.message:String(e)}function Y0e(e){const t=e.response?.data;return t?.message?t.message:e instanceof Error?e.message:String(e)}async function ATe({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(Y0e(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 NTe(e){if(!("resourceUri"in e))return{environmentName:e.environmentName,packageName:e.packageName,versionId:void 0,namesBoth:!0};let t;try{t=Xr(e.resourceUri)}catch{t=void 0}return{environmentName:t?.environmentName??"",packageName:t?.packageName??"",versionId:t?.versionId,namesBoth:!!t?.environmentName&&!!t?.packageName}}class M_ extends Error{constructor(t){super(t),this.name="DocumentNotFoundError"}}const O_=e=>e instanceof M_||e instanceof Error&&e.name==="DocumentNotFoundError",G0e=String.raw`##?\|?[ \t]*(?:[([{<][ \t]*)?(?:(?:(?:row|source)[-_]?)?authorize|access[-_]?filter)(?=[)\]}>]|[ \t]|$)`;function P_(e,t){if(/[\r\n]/.test(t))return`A ${e} is one line; it cannot hold a line break.`;if(new RegExp(G0e,"iu").test(t))return`A ${e} cannot contain what reads as an access-control tag (authorize, row_authorize, source_authorize or access_filter).`}const og=e=>Wy(e)?e:`\`${e}\``;function eT(e){const{title:t,modelPath:n,source:r,view:o}=e;if(t.trim()==="")return"A title cannot be empty.";const a=P_("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 K0e=e=>{const t=e.replace(/[-_]+/g," ").trim();return t.charAt(0).toUpperCase()+t.slice(1)},UN=e=>`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`,Q0e="report.malloy";function tT(e,t,n=Q0e){const r=eT(e);if(r)throw new Error(r);const{modelPath:o,source:a,view:i}=e,s=e.title.trim(),l=UN(s),d=og(`${a}_tiles`),u=og(`${i}_tile`),m=`"${d} -> ${u}"`;return["##! experimental.givens",`##| artifact { layout=${t} title=${l}`," tiles=[",` ${m}`," ]",t==="grid"?"} dashboard { columns=12 }":"}","|##",`import { ${og(a)} } from "${wF(o,n)}"`,"",`source: ${d} is ${og(a)} extend {`,` # label=${UN(K0e(i))}`,` view: ${u} is ${og(i)}`,"}",""].join(`
|
|
472
|
+
`)}}const g0e=C.lazy(()=>wo(()=>import("./RenderedResult-DqPvGZgL.es-BNxk46Vn.js"),[]).then(e=>e.c));function A1({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(()=>Q2(),[]);const[u,m]=C.useState(void 0),[g,y]=C.useState(void 0),[x,w]=C.useState(void 0),S=C.useCallback((B,I)=>{m(B),w(I)},[]),[b,$]=C.useState(!1),[k,T]=C.useState(void 0),O=m0e(a);C.useEffect(()=>{const B=d.current;if(!s||!B)return;const I=new ResizeObserver(([H])=>{T(Math.round(H.contentRect.height)),F(Math.round(H.contentRect.width))});return I.observe(B),()=>I.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(Te,{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(gae,{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(Vn,{variant:"contained",color:"primary",onClick:()=>$(!0),children:"Proceed"})]});const _=p.jsx(Bo,{text:wu.loading,centered:!0,size:32}),R=Dle({renderAs:x,maxHeight:t,tableMaxHeight:n}),z=MD({sizing:u,contentHeight:g,maxHeight:R,fillHeight:s?k:void 0,firstPaintHeight:r}),N=p.jsx(C.Suspense,{fallback:_,children:p.jsx(g0e,{result:e,height:z,onSizeChange:y,onSizing:S,drill:i,fill:s})});return p.jsxs(Te,{ref:d,sx:{position:"relative",height:"auto",border:"0px",borderRadius:0,overflowX:"hidden",overflowY:s?"hidden":"auto",...s&&{flex:`1 1 ${MD({sizing:u,contentHeight:g,maxHeight:R,firstPaintHeight:r})}px`,minHeight:0}},children:[s?p.jsx(Te,{className:Ble,...L&&P!==void 0?{[_le]:""}:{},sx:{position:"absolute",inset:0,overflowX:"hidden",overflowY:"auto"},children:N}):N,O&&p.jsx(Te,{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(zp,{"aria-label":"Render tag warnings",children:p.jsx(w_,{fontSize:"small",color:O.severity==="error"?"error":"warning"})})})})]})}function X2({state:e,context:t,loadingText:n=wu.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&&Q2()},[b]);const $=m?.data.result,k=C.useMemo(()=>$!==void 0&&u?u($):$,[$,u]),T=C.useMemo(()=>xle(k),[k]);if(y)return p.jsx(Te,{sx:{p:2},children:p.jsx(ja,{context:t,error:x})});if(!g)return p.jsx(Bo,{text:w==="idle"?wu.loading:n});if(T)return p.jsx(Te,{sx:{p:2},children:p.jsx(wt,{variant:"body2",role:"status",color:"text.secondary",children:T})});const O=p.jsx(A1,{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(Te,{"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(hz,{"aria-label":n,sx:{position:"absolute",top:0,left:0,right:0,height:2,zIndex:1,bgcolor:"transparent",borderRadius:1}}),p.jsx(Te,{className:"result-body",children:O})]})}const Pd=()=>typeof performance<"u"?performance.now():Date.now(),y0e=Jt(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"})),v0e=3;function b0e(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 x0e(e){return e.length<2?e.join(""):`${e.slice(0,-1).join(", ")} or ${e[e.length-1]}`}function w0e({ignored:e}){const{theme:t}=Vr();if(e.length===0)return null;const n=e.length>v0e?`Doesn't respond to ${e.length} filters`:`Doesn't respond to ${e.join(", ")}`;return p.jsxs(Te,{"data-testid":"tile-filter-tag",title:`This tile's query never reads ${x0e(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(y0e,{sx:{fontSize:12}}),p.jsx(Te,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n})]})}const S0e=/\.malloy(nb)?$/,D1=e=>e&&e.slice(e.lastIndexOf("/")+1).replace(S0e,"")||void 0,C0e=e=>e.replace(/\.malloy$/,"").split("/").map(encodeURIComponent).join("/"),S_=(e,t,n)=>`/${encodeURIComponent(e)}/${encodeURIComponent(t)}/${C0e(n)}`,k0e="edit",$0e=(e,t,n)=>`${S_(e,t,n)}?${k0e}`,Z2=e=>e.layout==="linear"?"linear":"grid",v$=e=>({layout:Z2(e),path:e.path,editable:e.editable!==!1});function R0e(e,t){const n=t.find(r=>r.path===e);return n?.path?v$({...n,path:n.path}):void 0}function T0e(e){return e===""||e.startsWith("/")?!1:e.split("/").every(t=>t!==""&&t!=="."&&t!=="..")}function E0e(e,t){if(!T0e(e))return{kind:"unresolved"};for(const n of[`${e}.malloy`,e]){const r=R0e(n,t);if(r)return{kind:"path",report:r}}return{kind:"unresolved"}}const M0e=(e,t,n)=>["reports",e,t,n];async function O0e(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 C_(e,t,n,r=!0){const{apiClients:o}=tr(),a=co({queryKey:M0e(e,t,n),queryFn:()=>O0e(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 k_=20,P0e={radius:"8px",padding:`${k_}px`};function TTe(e,t=P0e){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 j0e={query:120,text:72};function X0({borderless:e=!1,chrome:t="card",kind:n="query",sx:r,cardRef:o,children:a}){const{theme:i}=Vr(),s=i.ui,l=e||t==="none";return p.jsx(Qa,{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:j0e[n],p:t==="none"?0:e?"12px 0":`${k_}px`},...Array.isArray(r)?r:[r]],children:a})}const A0e=Sl.tileHeading;function $_({title:e,subtitle:t,tooltip:n,action:r,quiet:o=!1}){const{theme:a}=Vr(),i=a.ui;return p.jsxs(Te,{className:A0e,sx:{pb:o?.5:1.5,display:"flex",alignItems:"flex-start",gap:1},children:[p.jsxs(Te,{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 D0e=-1;function N0e(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 I0e(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 L0e(){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=N0e(r),a=o??window;let i=0;const s=()=>{i=0,t(I0e(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 z0e=4,F0e="--publisher-sticky-top",_0e=2;function b$({layout:e,notice:t,header:n,controls:r,children:o,sx:a}){return p.jsxs(Yn,{className:Sl.report,"data-layout":e,sx:[{gap:_0e},...Array.isArray(a)?a:[a]],children:[t,n,r,o]})}function R_({title:e,description:t,actions:n}){const r=Vr().theme.ui;return p.jsxs(Yn,{className:Sl.header,sx:{gap:1.5},children:[p.jsxs(Yn,{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(Te,{sx:{my:"-4px"},children:n})]}),t]})}function N1({sx:e,children:t}){return p.jsx(X0,{chrome:"none",kind:"text",...e?{sx:e}:{},children:t})}function T_({children:e}){const{theme:t}=Vr(),{stickyRef:n,stuck:r}=L0e();return p.jsx(Te,{ref:n,className:Sl.filterRow,"data-stuck":r||void 0,sx:{position:"sticky",top:`calc(var(${F0e}, 0px) + ${D0e}px)`,zIndex:z0e,bgcolor:r?"background.default":"transparent",pb:1,pt:1,mt:-1,boxShadow:r?`0 1px 0 ${Zd(t.cardBorder)}`:"none",transition:`box-shadow ${Zy}`,...Jy},children:e})}const Xr=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 J2(e,t){if(e[t])return e;const n=e.default;return n?.[t]?n:e}const B0e=e=>J2(e,"MalloyTranslator"),U0e=e=>J2(e,"parseAnnotation"),q0e=e=>J2(e,"ASTQuery");async function ETe(){return B0e(await wo(()=>import("./index-diN_kmcj.js").then(e=>e.i),__vite__mapDeps([0,1])))}async function MTe(){return U0e(await wo(()=>Promise.resolve().then(()=>Rae),void 0))}async function H0e(){return q0e(await wo(()=>import("./index-dUom3Bdm.js").then(e=>e.i),__vite__mapDeps([2,1])))}async function V0e(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 E_(e){return e.find(t=>t.authoritative)??e.find(t=>t.writeable)}function W0e({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 OTe(e,t){return e??(t===void 0?void 0:await V0e(t))}function PTe({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 jTe(e){return e instanceof Error?e.message:String(e)}function Y0e(e){const t=e.response?.data;return t?.message?t.message:e instanceof Error?e.message:String(e)}async function ATe({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(Y0e(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 NTe(e){if(!("resourceUri"in e))return{environmentName:e.environmentName,packageName:e.packageName,versionId:void 0,namesBoth:!0};let t;try{t=Xr(e.resourceUri)}catch{t=void 0}return{environmentName:t?.environmentName??"",packageName:t?.packageName??"",versionId:t?.versionId,namesBoth:!!t?.environmentName&&!!t?.packageName}}class M_ extends Error{constructor(t){super(t),this.name="DocumentNotFoundError"}}const O_=e=>e instanceof M_||e instanceof Error&&e.name==="DocumentNotFoundError",G0e=String.raw`##?\|?[ \t]*(?:[([{<][ \t]*)?(?:(?:(?:row|source)[-_]?)?authorize|access[-_]?filter)(?=[)\]}>]|[ \t]|$)`;function P_(e,t){if(/[\r\n]/.test(t))return`A ${e} is one line; it cannot hold a line break.`;if(new RegExp(G0e,"iu").test(t))return`A ${e} cannot contain what reads as an access-control tag (authorize, row_authorize, source_authorize or access_filter).`}const og=e=>Wy(e)?e:`\`${e}\``;function eT(e){const{title:t,modelPath:n,source:r,view:o}=e;if(t.trim()==="")return"A title cannot be empty.";const a=P_("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 K0e=e=>{const t=e.replace(/[-_]+/g," ").trim();return t.charAt(0).toUpperCase()+t.slice(1)},UN=e=>`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`,Q0e="report.malloy";function tT(e,t,n=Q0e){const r=eT(e);if(r)throw new Error(r);const{modelPath:o,source:a,view:i}=e,s=e.title.trim(),l=UN(s),d=og(`${a}_tiles`),u=og(`${i}_tile`),m=`"${d} -> ${u}"`;return["##! experimental.givens",`##| artifact { layout=${t} title=${l}`," tiles=[",` ${m}`," ]",t==="grid"?"} dashboard { columns=12 }":"}","|##",`import { ${og(a)} } from "${wF(o,n)}"`,"",`source: ${d} is ${og(a)} extend {`,` # label=${UN(K0e(i))}`,` view: ${u} is ${og(i)}`,"}",""].join(`
|
|
473
473
|
`)}function ITe(e,t){return tT(e,"linear",t)}function X0e(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,80)}function Z0e({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.`:P_("title",e)}function LTe(e,t){const n=Z0e(e);if(n)throw new Error(n);return tT(e,"grid",t)}const j_=e=>(e??"").trim().replace(/\\/g,"/").split("/").filter(t=>t!=="").join("/");function J0e(e,t){const n=j_(t);return`${n===""?"":`${n}/`}${e}.malloy`}function exe(e){return X0e(e)||"untitled"}function A_(e,t=1,n){const r=exe(e);return J0e(t>1?`${r}-${t}`:r,n)}const wy=(e,t,n)=>`${e}/${t}/${n}`,txe=(e,t,n,r,o)=>({workspace:t,type:e,path:wy(n,r,o)}),nT=20;function nxe(e){const{savesTo:t,writer:n}=W0e({...e,readFailed:!1});return t==="browser"?void 0:n}const qN=e=>e.slice(e.lastIndexOf("/")+1).replace(/\.malloy$/,"");function D_(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 rxe(e){const t=e.layout??"linear",n=Pd();let r;try{r=await oxe(e,t)}catch(o){throw Kk({path:e.path??"",layout:t},e.onEvent).emit({type:"report.create_refused",reason:o instanceof Error?o.message:String(o)}),o}return Kk({path:r.path,layout:t},e.onEvent).emit({type:"report.created",where:e.target.route==="package"?"package":"host",durationMs:Pd()-n}),e.onCreated?.(r),r}async function oxe(e,t){const{document:n,target:r}=e,o=eT(n);if(o)throw new Error(o);const a=j_(e.directory),i=e.path!==void 0?[e.path]:Array.from({length:nT},(w,S)=>A_(n.title,S+1,a));for(const w of i){const S=D_(w);if(S)throw new Error(S)}const s=w=>tT(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(!axe($))throw $}if(S===void 0)throw HN(n.title,e.path);return{layout:t,path:S,slug:qN(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=txe(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(!O_(k))throw k;$=!1}if(!$){x={layout:t,path:b,slug:qN(b),locator:S};break}}if(x===void 0)throw HN(n.title,e.path);return await l.saveDocument(x.locator,s(x.path)),x}const axe=e=>e?.response?.status===409,HN=(e,t)=>new Error(t!==void 0?`${t} already exists. Fix: choose a different location.`:`No free file name for "${e}" after ${nT} tries. Fix: choose a different title.`);function ixe(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 VN(e){for(const t of e??[]){const n=/^#\(doc\)\s*(.*)$/s.exec(t.trim());if(n)return n[1].trim()}}function sxe(e){for(const t of e??[]){const n=/^#\s*(?:-[A-Za-z_]+\s+)*([a-z_]+)/.exec(t.trim())?.[1];if(n&&dF.includes(n))return n}}function lxe({environmentName:e,packageName:t,versionId:n,models:r,enabled:o}){const{apiClients:a,server:i}=tr(),s=Bz({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=[],$=ixe(w.data?.modelInfo);for(const k of w.data?.sources??[]){if(typeof k.name!="string"||!$.has(k.name))continue;const T=VN(k.annotations);for(const O of k.views??[])if(typeof O.name=="string"){const P=VN(O.annotations),D=sxe(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&&L4(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 N_=C.createContext(void 0);function cxe({children:e,documentStorage:t}){const n=C.useMemo(()=>({documentStorage:t}),[t]);return p.jsx(N_.Provider,{value:n,children:e})}function I_(){return C.useContext(N_)}function uxe(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 zTe=1e4,L_=e=>e==="notebook"?"linear":"grid",FTe=(e,t)=>`${e}s/${t}.malloy`;function dxe(e,t,n){return[["dashboards"],["notebooks"],["dashboard"],...n===void 0?[]:[[I1({environmentName:e,packageName:t,modelPath:n})]]]}function fxe(e,t,n,r){for(const o of[["report"],["reports"],...dxe(t,n,r)])e.invalidateQueries({queryKey:o})}function co(e){const{server:t}=tr(),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 zd(n,JR)}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,JR)}function pxe(e){return["queryResult",e.environmentName,e.packageName,e.versionId,e.modelPath,e.queryName,e.query,e.sourceName,JSON.stringify(e.givens??{})]}function _Te(e){return["queryResult",e.environmentName,e.packageName,e.versionId,e.modelPath]}function rT(e,{enabled:t=!0}={}){const{apiClients:n}=tr(),r=pxe(e);return co({queryKey:r,queryFn:({signal:o})=>n.models.executeQueryModel(e.environmentName,e.packageName,e.modelPath,{queryName:e.queryName,query:e.query,sourceName:e.sourceName,givens:e.givens,versionId:e.versionId},void 0,{signal:o}),enabled:t,placeholderData:(o,a)=>a&&mxe(a.queryKey,r)?o:void 0,...Ire})}const hxe=8;function mxe(e,t){return e.every((n,r)=>r===hxe||r>=t.length||n===t[r])}const gxe=/<\/?[A-Za-z][^>]*>|<!--|<![A-Za-z]/;function z_(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&&gxe.test(a)){e.delete("label"),t=!0;continue}}const o=Array.isArray(r.eq)?r.eq:[];for(const a of[r,...o])z_(a)&&(t=!0)}return t}function yxe(e){const t=e.trim();if(!/^#(?:\||[ \t\r\n]|$)/.test(t))return e;if(t.includes("@env."))return"";let n;try{n=e1.parseAnnotation(t)}catch{return""}return n.log.length>0?"":z_(n.tag)?`${n.tag.toString()}
|
|
474
474
|
`:e}function x$(e){if(Array.isArray(e)){for(const n of e)x$(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=yxe(a.value))}else x$(r)}function F_(e){let t;try{t=JSON.parse(e)}catch{return e}const n=JSON.stringify(t);x$(t);const r=JSON.stringify(t);return r===n?e:r}const vxe=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"]),bxe={value:`# big_value
|
|
475
475
|
`};function xxe(e){const t=e.schema?.fields;if(!Array.isArray(t)||t.length===0||!t.every(r=>Gk(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 wxe(e){for(const t of e){const n=t.trim();if(!n.startsWith("#")||n.startsWith("#(")||n.startsWith('#"'))continue;const r=p1(n.slice(1));for(const o of r.split(/[\s{}=.,[\]]+/))if(vxe.has(o))return!0}return!1}function __(e){let t;try{t=JSON.parse(e)}catch{return e}if(!t||typeof t!="object"||!xxe(t))return e;const n=Array.isArray(t.annotations)?t.annotations:[],r=n.map(o=>o?.value).filter(o=>typeof o=="string");return wxe(r)?e:JSON.stringify({...t,annotations:[bxe,...n]})}const Sxe=e=>F_(__(e));function WN(e){const t=e.split("->").at(-1)?.trim()??e;return/^[A-Za-z_][\w-]*$/.test(t)?DF(t):e}function B_({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:_}=Vr(),[R,z]=Gle(),N=rT({environmentName:e,packageName:t,modelPath:r,versionId:n,queryName:o,query:a!==void 0?v1(D??"",`${i?`${i}
|
|
476
476
|
`:""}run: ${a}`):void 0,givens:y2(Jd(m,y,x),g,x)},{enabled:z&&A!==!0&&F===void 0}),{emit:B}=g1(),I=N.isError?N.error:void 0;C.useEffect(()=>{I!==void 0&&B({type:"report.query_failed",...L!==void 0?{tile:L}:{},category:U0(I)})},[I,B,L]);const H=A===!0||D!==void 0&&N.isError&&Mce(N.error);return p.jsxs(X0,{cardRef:R,borderless:u,chrome:O,sx:{"& .malloy-render, & .malloy-table":{width:"100%"},"& .publisher-tile-explore":{opacity:0,transition:`opacity ${Zy}`,...Jy,...fle},"&:hover .publisher-tile-explore, & .publisher-tile-explore:focus-visible":{opacity:1}},children:[a!==void 0&&p.jsx($_,{title:d?.title??s??WN(a),subtitle:d?d.subtitle:l,quiet:O==="none",tooltip:a,action:T&&p.jsx(Br,{title:"Explore from here",children:p.jsx(ro,{className:"publisher-tile-explore",size:"small","aria-label":`Explore ${s??WN(a)}`,onClick:T,sx:{mt:-.5,mr:-.5,color:_.tileTitle},children:p.jsx(Vle,{fontSize:"small"})})})}),P&&p.jsx(w0e,{ignored:P}),F!==void 0?p.jsx(Te,{sx:{p:2},children:p.jsx(wt,{variant:"body2",role:"status",color:"text.secondary",children:F})}):H?p.jsx(Te,{sx:{p:2},children:p.jsx(wt,{variant:"body2",role:"status",color:"text.secondary",children:Ece})}):p.jsx(X2,{fill:!0,state:N,context:a??o??r,maxHeight:w,tableMaxHeight:S,compactToFit:b,firstPaintHeight:yF,maxResultSize:$,drill:k,transform:D!==void 0?a!==void 0?Sxe:F_:a!==void 0?__:void 0})]})}function BTe(e,{enabled:t=!0}={}){const{apiClients:n}=tr();return co({queryKey:["compiled-document",e.environmentName,e.packageName,e.modelPath,e.source,e.givens??null],queryFn:async()=>{const r=(await n.models.compileModelSource(e.environmentName,e.packageName,e.modelPath,{source:e.source,scope:"append",...e.givens&&Object.keys(e.givens).length>0?{givens:e.givens}:{}})).data;return{document:r.document,result:r}},enabled:t})}Jt(p.jsx("path",{d:"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20z"}));const U_="(max-width:599.95px)";function Cxe(){return oee(U_,{noSsr:!0})}function kxe(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(U_).matches}function UTe({children:e}){const[t]=C.useState(kxe),[n,r]=C.useState(!1);return!t||n?p.jsx(p.Fragment,{children:e}):p.jsxs(Yn,{sx:{alignItems:"flex-start",gap:1.5,py:3},children:[p.jsx(wt,{variant:"h6",children:"Editing works best on a larger screen"}),p.jsx(wt,{variant:"body2",color:"text.secondary",children:"The editor is built for a wider window. You can still try it here."}),p.jsx(Vn,{variant:"outlined",onClick:()=>r(!0),children:"Edit anyway"})]})}function qTe(){const e=Ay();return(t,n)=>{if(!n||!n.metaKey&&!n.ctrlKey&&!n.shiftKey&&n.button!==1){e(t);return}const r=new URL(t,window.location.href).href;(n.metaKey||n.ctrlKey||n.button===1||n.shiftKey)&&window.open(r,"_blank")}}function q_(e,t){return e.flatMap(({filter:n})=>{if(n.kind!=="literal_equality"||n.expression.kind!=="field_reference")return[];const r=$xe(n.value,t);return r===void 0?[]:[{field:n.expression.name,label:r,expression:n.expression}]})}function H_(e,t){switch(e.kind){case"string_literal":return`'${p2(e.string_value)}'`;case"number_literal":return e.string_value!==void 0?/^-?\d+(\.\d+)?$/.test(e.string_value)?e.string_value:void 0:Number.isFinite(e.number_value)?String(e.number_value):void 0;case"boolean_literal":return String(e.boolean_value);case"date_literal":{const n=V_(e.date_value);return n&&`@${n[0]}-${n[1]}-${n[2]}`}case"timestamp_literal":{const n=Y_(e.timestamp_value,t);return n&&`@${n[0]}-${n[1]}-${n[2]} ${n[3]}:${n[4]}:${n[5]}${W_(e.timestamp_value)}`}default:return}}function $xe(e,t){switch(e.kind){case"string_literal":return e.string_value;case"null_literal":return"null";case"date_literal":{const n=V_(e.date_value);return n&&YN([...n,"00","00","00"],e.granularity??"day")}case"timestamp_literal":{const n=Y_(e.timestamp_value,t);return n&&YN(n,e.granularity??"second")+(e.granularity===void 0?W_(e.timestamp_value):"")}default:return H_(e)}}function V_(e){const t=/^(\d{4})-(\d{2})-(\d{2})/.exec(e);return t?[t[1],t[2],t[3]]:void 0}function W_(e){const t=/:\d{2}\.(\d+)/.exec(e)?.[1]?.replace(/0+$/,"");return t?`.${t}`:""}function Y_(e,t){const n=new Date(e);if(Number.isNaN(n.getTime()))return;let r;try{r=new Intl.DateTimeFormat("en-US",{timeZone:t??"UTC",hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).formatToParts(n)}catch{return}const o=a=>r.find(i=>i.type===a)?.value??"";return[o("year").padStart(4,"0"),o("month"),o("day"),o("hour"),o("minute"),o("second")]}function YN([e,t,n,r,o,a],i){switch(i){case"year":return e;case"quarter":return`${e}-Q${Math.floor((Number(t)-1)/3)+1}`;case"month":return`${e}-${t}`;case"week":case"day":return`${e}-${t}-${n}`;case"hour":return`${e}-${t}-${n} ${r}`;case"minute":return`${e}-${t}-${n} ${r}:${o}`;default:return`${e}-${t}-${n} ${r}:${o}:${a}`}}const Rxe="drill_metadata_corrected",Z0=e=>e,ah=e=>{try{return e?.()}catch{return}},G_=e=>ah(e.isBasic?.bind(e))===!0&&ah(e.wasDimension?.bind(e))===!0,Txe=e=>[e.isString,e.isNumber,e.isBoolean,e.isTime].some(t=>ah(t?.bind(e))===!0);function J0(e){const t=e.metadataTag?.text("drill_expression","code");return t===void 0||t.trim()===""?void 0:t}function K_(e){const t=[];for(let n=e.parent;n;n=n.parent)t.push(n);return t}function Q_(e){const t=K_(e),n=(t[t.length-1]??e).metadataTag,r=n?.text("source","name");if(!r||!n?.array||n.array("source","parameters")!==void 0||n.has?.(Rxe)!==!0)return;const o=[];for(const i of[...t].reverse())if(ah(i.isArray?.bind(i))===!0){if(i.metadataTag?.has?.("drillable")!==!0)return;for(const s of i.metadataTag?.array?.("drill_filters")??[]){const l=s.text("code");if(!l)return;o.push(l)}}const a=n?.text("query_name");return{source:r,filters:o,...a&&!a.startsWith("__")?{queryName:a}:{}}}function av(e){const t=new Set;for(const n of K_(e))for(const r of n.fields??[])G_(r)&&t.add(r);return[...t]}function X_(e){const t=new Set(av(e).filter(n=>ah(n.isTime?.bind(n))===!0).map(n=>ah(n.getEffectiveQueryTimezone?.bind(n))));return t.size>1?null:[...t][0]}function GN(e){return!G_(e)||J0(e)===void 0||Q_(e)===void 0||X_(e)===null?!1:av(e).every(t=>J0(t)!==void 0&&t.drillStableExpression!==void 0&&Txe(t))}function Exe(e,t){const n=av(e),r=[],o=new Set;for(const a of t){if(a.kind==="drill")continue;const{filter:i}=a;if(i.kind!=="literal_equality")return;const s=JSON.stringify(i.expression),l=n.find(u=>JSON.stringify(u.drillStableExpression)===s),d=l&&J0(l);if(l===void 0||d===void 0)return;r.push({code:d,value:i.value}),o.add(l)}return n.every(a=>o.has(a))&&r.length>0?r:void 0}const Mxe=360;function w$(e){return e?e.getLabel?.()??e.tag?.text("label")??Z0(e).metadataTag?.text("label")??e.name:""}function Oxe(e,t){const n=e.drillClauses?q_(e.drillClauses,e.timezone):[];if(n.length===0)return`${w$(t)}: ${e.label}`;const r=av(Z0(t));return n.map(o=>{const a=JSON.stringify(o.expression),i=r.find(s=>JSON.stringify(s.drillStableExpression)===a);return`${i?w$(i):o.field}: ${o.label}`}).join(", ")}function Z_({onNavigate:e,onSelf:t,destinationTitle:n,canSelf:r,onRows:o}){const[a,i]=C.useState(null),s=C.useCallback((S,b)=>S.filter($=>$===Gm?t!==void 0&&(r?.(b)??!0):e!==void 0),[e,t,r]),l=C.useCallback((S,b,$)=>{if(b===Gm){t?.(S.given,S.rawValue);return}e?.({path:b,dashboard:b,givens:{[S.given]:S.value}},$)},[e,t]),d=C.useCallback(S=>{if(!o||S.noRows||S.isHeader||!S.field)return;const b=Z0(S.field);if(!GN(b))return;const $=Q_(b);if($===void 0)return;const k=S.drillClauses;let T;if(k!==void 0){const P=Exe(b,k);if(P===void 0)return;T={dimensions:P}}else{const P=J0(b);if(P===void 0||av(b).length!==1||y1(S.value)===void 0||typeof S.value=="number"&&Number.isInteger(S.value)&&!Number.isSafeInteger(S.value))return;T={code:P}}const O=X_(b)??void 0;return{field:S.field.name,rawValue:S.value,label:Zk(S.value),target:$,...T,...S.context===void 0?{}:{context:S.context},...k===void 0?{}:{drillClauses:k},...O===void 0?{}:{timezone:O}}},[o]),u=C.useCallback(S=>{const b=vce(S),$=d(S),k=b?Array.from(new Set(s(b.to,b.given))).sort((P,D)=>+(D===Gm)-+(P===Gm)):[],T=`${w$(S.field)}: ${b?.label??Zk(S.value)}`,O=k.map(P=>({key:`to:${P}`,label:P===Gm?`Filter to ${T}`:`Open ${n?.(P)??DF(P.split("/").pop()??P)} (${T})`,run:()=>{b&&l(b,P,S.event)}}));$&&S.field&&O.push({key:"rows",label:`Show rows (${Oxe($,S.field)})`,run:()=>o?.($)}),O.length!==0&&i({items:O,top:S.event?.clientY??0,left:S.event?.clientX??0})},[l,s,o,d,n]),m=C.useCallback(S=>s(AF(S),NF(S)).length>0,[s]),g=C.useCallback(S=>o!==void 0&&GN(Z0(S)),[o]),y=C.useMemo(()=>({onClick:u,canDrill:S=>m(S)||g(S)}),[u,m,g]),x=C.useCallback((S,b)=>({canDrill:$=>m($)||b&&g($),onClick:$=>u({...$,...S===void 0?{}:{context:S},...b?{}:{noRows:!0}})}),[u,m,g]),w=C.useCallback(()=>i(null),[]);return{drill:y,bindingFor:x,drillMenu:p.jsx(uc,{open:a!==null,onClose:w,anchorReference:"anchorPosition",anchorPosition:{top:a?.top??0,left:a?.left??0},children:(a?.items??[]).map(S=>p.jsx(ea,{title:S.label,"aria-label":S.label,onClick:()=>{w(),S.run()},sx:{maxWidth:Mxe},children:p.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:S.label})},S.key))})}}const Pxe=e=>{const t=C.useRef({});return C.useEffect(()=>{t.current=e}),t.current};function HTe(){const[e]=nV(),t=Ay(),n=hs(),r=C.useMemo(()=>Object.fromEntries(e.entries()),[e]),o=C.useRef(new Set),a=C.useRef(null),i=C.useCallback(d=>{const u=a.current,m=new URLSearchParams(u?.key===n.key?u.search:n.search);d(m);const g=m.toString();a.current={key:n.key,search:g},t({search:g,hash:n.hash},{replace:!0})},[t,n]),s=C.useCallback((d,u)=>{const m=new Set([...u,...o.current]);o.current=new Set([...o.current,...Object.keys(d),...u]),i(g=>{for(const y of m)Object.prototype.hasOwnProperty.call(d,y)||g.delete(y);for(const[y,x]of Object.entries(d))g.set(y,x)})},[i]),l=C.useCallback((d,u)=>i(m=>{u===void 0?m.delete(d):m.set(d,u)}),[i]);return{params:r,onGivensChange:s,setParam:l}}const jxe=Jt(p.jsx("path",{d:"M5 20h14v-2H5zM19 9h-4V3H9v6H5l7 7z"}));function Eg(e){return/^[=+\-@\t\r]/.test(e)?`'${e}`:e}function Mg(e){return/[",\r\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e}function Axe(e){if(e===void 0)return"";switch(e.kind){case"null_cell":return"";case"number_cell":return e.string_value??String(e.number_value);case"boolean_cell":return e.boolean_value?"true":"false";case"date_cell":return e.date_value;case"timestamp_cell":return e.timestamp_value;case"string_cell":return Mg(Eg(e.string_value));case"json_cell":return Mg(Eg(e.json_value));case"sql_native_cell":return Mg(Eg(e.sql_native_value));default:return Mg(Eg(JSON.stringify(e)))}}function J_(e){const t=e.data;return t?.kind!=="array_cell"?[]:t.array_value.flatMap(n=>n.kind==="record_cell"?[n.record_value]:[])}function Dxe(e){const t=e.schema.fields;return`\uFEFF${[t.map(n=>Mg(Eg(n.name))).join(","),...J_(e).map(n=>t.map((r,o)=>Axe(n[o])).join(","))].join(`\r
|
|
477
477
|
`)}\r
|
|
478
|
-
`}function Nxe(e,t){return[e,"rows",...t].join("_").replace(/[^A-Za-z0-9._-]+/g,"_").replace(/_+/g,"_").replace(/^[_.]+|[_.]+$/g,"").slice(0,120)||"rows"}function Ixe(e,t,n){return n==="server_default"&&t!==void 0&&e>=t?t:void 0}const KN="Download the rows behind this value as CSV, up to the server's row limit",Lxe=4e4;function zxe(e,t){const n=URL.createObjectURL(new Blob([e],{type:"text/csv;charset=utf-8"})),r=document.createElement("a");r.href=n,r.download=t,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),Lxe)}function Fxe(e){const t=e?.response?.data?.message;return typeof t=="string"&&t!==""?t:e instanceof Error&&e.message!==""?e.message:"The request failed."}function _xe({query:e,preamble:t,environmentName:n,packageName:r,modelPath:o,versionId:a,givens:i,fileName:s}){const{apiClients:l}=tr(),[d,u]=C.useState(!1),[m,g]=C.useState(KN),[y,x]=C.useState(void 0),w=C.useRef(void 0);C.useEffect(()=>()=>w.current?.abort(),[]);const S=async()=>{w.current?.abort();const b=new AbortController;w.current=b,u(!0),x(void 0);try{const $=await l.models.executeQueryModel(n,r,o,{query:t===void 0?e:v1(t,e),givens:i,versionId:a},void 0,{signal:b.signal});if(b.signal.aborted)return;const k=$.data,T=JSON.parse(k.result??"{}"),O=Ixe(J_(T).length,k.queryRowLimit,k.queryRowLimitSource);g(O===void 0?KN:`First ${O} rows: the server's row limit, so there may be more`),zxe(Dxe(T),O===void 0?`${s}.csv`:`${s}_first_${O}_rows_server_limit.csv`)}catch($){if(b.signal.aborted)return;x(`Download failed: ${Fxe($)}`)}finally{w.current===b&&(w.current=void 0,u(!1))}};return p.jsxs(Te,{sx:{display:"flex",alignItems:"center",gap:1},children:[y&&p.jsx(wt,{role:"alert",variant:"caption",color:"error",sx:{maxWidth:320},children:y}),p.jsx(Br,{title:m,children:p.jsx("span",{children:p.jsx(Vn,{size:"small",startIcon:p.jsx(jxe,{fontSize:"small"}),onClick:()=>void S(),disabled:d,children:"Download CSV"})})})]})}const e6=200;function Bxe(e){const{target:t}=e;if(t!==void 0&&!(e.dimensions===void 0&&e.code===void 0))return{...e,target:t}}function QN(e,t=e6){const n=qxe(e);if(n===void 0)return;const r=[...e.target.filters,...n].join(", "),o=e.timezone?`timezone: '${p2(e.timezone)}'; `:"",a=t===null?"":`; limit: ${t}`,i=Uxe(e.target.source);if(i!==void 0)return`run: ${i} -> { ${o}where: ${r}; select: *${a} }`}function Uxe(e){return Wy(e)?e:e.includes("`")?void 0:`\`${e}\``}function EC(e){return/^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)*$/.test(e)?e:`(${e})`}function qxe(e){if(e.dimensions){const n=[];for(const{code:r,value:o}of e.dimensions){if(o.kind==="null_literal"){n.push(`${EC(r)} is null`);continue}const a=H_(o,e.timezone);if(a===void 0)return;n.push(`${EC(r)} = ${a}`)}return n}const t=Zle(e.rawValue);return e.code!==void 0&&t?[`${EC(e.code)} = ${t}`]:void 0}const Hxe="This value cannot be written as a filter, so its rows cannot be fetched.";function XN(e){const t=e.drillClauses?q_(e.drillClauses,e.timezone):[];return t.length>0?t:[{field:e.field,label:e.label}]}function Vxe({request:e,environmentName:t,packageName:n,versionId:r,modelPath:o,preamble:a,givens:i,onClose:s,onDone:l,actions:d}){const{theme:u}=Vr(),m=e?QN(e):void 0,g=e?QN(e,null):void 0,y=e&&g!==void 0?{query:g,...a===void 0?{}:{preamble:a},environmentName:t,packageName:n,modelPath:o,...r===void 0?{}:{versionId:r},givens:i,fileName:Nxe(e.target.source,XN(e).map(x=>x.label))}:void 0;return p.jsxs(zx,{open:e!==void 0,onClose:s,maxWidth:"lg",fullWidth:!0,children:[p.jsxs(_x,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",pb:.5},children:[p.jsxs(Te,{children:[e?p.jsxs(p.Fragment,{children:["Rows where"," ",XN(e).map((x,w)=>p.jsxs(C.Fragment,{children:[w>0&&" and ",p.jsx(Te,{component:"code",sx:{fontSize:"0.9em"},children:x.field})," ","is ",x.label]},w))]}):"Rows",p.jsx(wt,{component:"div",variant:"caption",sx:{color:u.tileTitle,mt:.25},children:e?`The first ${e6} rows of ${e.target.source} behind this value, with the tile's own filters and the controls applied.`:""})]}),p.jsxs(Te,{sx:{display:"flex",alignItems:"center",gap:1,ml:1},children:[y&&(d?d(y):p.jsx(_xe,{...y})),p.jsx(ro,{onClick:s,"aria-label":"Close",size:"small",sx:{color:"text.secondary"},children:p.jsx(xh,{fontSize:"small"})})]})]}),p.jsxs(Fx,{dividers:!0,sx:{p:0,minHeight:240},children:[m===void 0&&e&&p.jsx(wt,{variant:"body2",sx:{p:2},children:Hxe}),m!==void 0&&p.jsx(Wxe,{query:a===void 0?m:v1(a,m),environmentName:t,packageName:n,...r===void 0?{}:{versionId:r},modelPath:o,givens:i,...l?{onDone:l}:{}})]}),p.jsxs(pz,{sx:{px:3,py:1.5},children:[m!==void 0&&p.jsx(wt,{variant:"caption",sx:{mr:"auto",color:u.tileTitle,fontFamily:u.ui.font.mono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:m,children:m}),p.jsx(Vn,{onClick:s,children:"Close"})]})]})}function Wxe({query:e,environmentName:t,packageName:n,versionId:r,modelPath:o,givens:a,onDone:i}){const s=rT({environmentName:t,packageName:n,modelPath:o,...r===void 0?{}:{versionId:r},query:e,givens:a}),{isSuccess:l,isError:d}=s,u=C.useRef(void 0);return C.useEffect(()=>{u.current=Pd()},[e]),C.useEffect(()=>{u.current===void 0||!l&&!d||(i?.(l,Pd()-u.current),u.current=void 0)},[l,d,i]),p.jsx(Te,{sx:{p:1},children:p.jsx(X2,{state:s,context:e})})}function t6({manifest:e,environmentName:t,packageName:n,versionId:r,documentName:o,givens:a,onGivensChange:i,onNavigate:s,height:l,maxResultSize:d,controlsLayout:u="bar",preamble:m,runModelPath:g,hiddenGivens:y,literalReads:x,onLinkNavigate:w,actions:S,rowsActions:b}){const $=C.useMemo(()=>w?{environmentName:t,packageName:n,sourcePath:e.path??o,onNavigate:w}:void 0,[t,n,e.path,o,w]),k=C.useMemo(()=>(e.givens??[]).filter(le=>!(m!==void 0&&le.secure===!0)&&!(le.name!==void 0&&y?.includes(le.name))),[e,y,m]),T=C.useMemo(()=>a===void 0?void 0:Object.fromEntries(Object.entries(a).filter(([,le])=>typeof le=="string")),[a]),O=b2({specs:k,loaded:!0,startingValues:e.startingGivens,params:T,onGivensChange:i,documentKey:`${t}/${n}/${r??""}/${o}`,autorun:e.autorun!==!1,environmentName:t,packageName:n,modelPath:g??e.path,versionId:r,documentName:o,...m!==void 0?{preamble:m}:{},...a?{hostGivens:a}:{}}),{applied:P,declaredTypes:D,canSelf:A,onSelf:F}=O,L=g1(),_=C.useMemo(()=>{const le=new Set((e.tiles??[]).flatMap(fe=>fe.givenNames??[]));return Object.fromEntries(Object.entries(a??{}).filter(([fe])=>le.has(fe)&&!D.has(fe)))},[e,a,D]),[R,z]=C.useState(void 0),N=C.useCallback(le=>{const fe=Bxe(le);fe!==void 0&&z(fe)},[]),B=C.useMemo(()=>y2(Jd(P,D),_),[P,D,_]),{reports:I}=C_(t,n,r,s!==void 0),H=C.useCallback(le=>{const fe=E0e(le,I);if(fe.kind!=="path")return;const he=fe.report.path;return I.find(me=>me.path===he)?.title||void 0},[I]),{bindingFor:Y,drillMenu:ae}=Z_({onNavigate:s,onSelf:F,canSelf:A,onRows:N,destinationTitle:H}),K=C.useCallback((le,fe)=>Y(le,fe!==!0),[Y]),{columns:oe,layout:ue,tileMaxHeight:G,tableMaxHeight:ie}=qle(e.layout,e.dashboardColumns),Q=C.useMemo(()=>Ybe(k,P,a),[k,P,a]);if(e.error)return p.jsx(b$,{layout:ue,header:p.jsx(ZN,{manifest:e,links:$,actions:S}),children:p.jsx(lo,{severity:"error",children:e.error})});const ee=g??e.path,Z=e.tiles??[],de=uF(Z);return p.jsxs(b$,{layout:ue,header:p.jsx(ZN,{manifest:e,links:$,actions:S}),controls:k.length>0?p.jsx(T_,{children:p.jsx(j1,{...O.panel,layout:u})}):void 0,children:[Q.length>0&&p.jsx(lo,{severity:"info",children:Kbe(Q)}),ee===void 0?p.jsx(lo,{severity:"error",children:"This dashboard has no model path, so there is nothing to run."}):Z.length>0?p.jsx(ile,{tiles:Z,columns:oe,minTilePx:sF,rowGapPx:vl,keyOf:(le,fe)=>`${fe}:${le.kind==="text"?`text:${le.name}`:le.query}`,renderTile:(le,fe)=>le.kind==="text"||le.query===void 0?p.jsx(Te,{sx:le.rowspan!==void 0||de?{minHeight:0,overflow:"auto"}:void 0,children:p.jsx(Yxe,{markdown:le.markdown??"",links:$})}):p.jsx(B_,{index:fe,environmentName:t,packageName:n,versionId:r,modelPath:ee,tile:le.query,label:le.label,subtitle:le.subtitle,borderless:le.borderless,givens:P,hostGivens:_,declaredTypes:D,givenNames:le.givenNames,height:le.rowspan!==void 0||de?iF(le.rowspan??cF.query):ue==="grid"?l??G:G,tableMaxHeight:ie,fixedHeight:le.rowspan!==void 0||de,maxResultSize:d,drill:K(le.query,le.restricted),ignoredFilters:b0e(le.givenNames&&(le.query&&x?.[le.query]?[...le.givenNames,...x[le.query]]:le.givenNames),k),...m!==void 0?{preamble:m,restricted:le.restricted}:{},...(()=>{const he=Gbe(Q,le.givenNames);return he.length>0?{waitingFor:Qbe(he)}:{}})()})}):p.jsx(lo,{severity:"warning",children:"This dashboard names neither a query nor any tiles."}),ae,ee!==void 0&&p.jsx(Vxe,{request:R,environmentName:t,packageName:n,...r===void 0?{}:{versionId:r},modelPath:ee,...m===void 0?{}:{preamble:m},givens:B,...b===void 0?{}:{actions:b},onClose:()=>z(void 0),onDone:(le,fe)=>{R&&L.emit({type:"report.rows_shown",source:R.target.source,view:R.target.queryName??"",field:R.field,ok:le,durationMs:fe})}})]})}function Yxe({markdown:e,links:t}){return p.jsx(N1,{children:p.jsx(oh,{variant:"document",links:t,children:e})})}function ZN({manifest:e,links:t,actions:n}){return p.jsx(R_,{title:e.title??e.name,actions:n,description:e.description?p.jsx(N1,{children:p.jsx(oh,{variant:"document",links:t,children:e.description})}):void 0})}const n6=Jt(p.jsx("path",{d:"M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3z"})),Gxe="publisher:resize";function Kxe(e){return typeof e=="object"&&e!==null&&e.type===Gxe&&typeof e.height=="number"}function r6(e){return e.replace(/\/api\/v0\/?$/,"")}function Qxe({server:e,environmentName:t,packageName:n,path:r,versionId:o}){const a=r.startsWith("public/")?r.slice(7):r,i=`${r6(e)}/environments/${encodeURIComponent(t)}/packages/${encodeURIComponent(n)}/`+a;return o===void 0?i:`${i}${i.includes("?")?"&":"?"}versionId=${encodeURIComponent(o)}`}function Xxe(e){try{const{environmentName:t,packageName:n,modelPath:r,versionId:o}=Xr(e);return!t||!n||!r?null:{environmentName:t,packageName:n,dataAppPath:r,versionId:o}}catch{return null}}function VTe({resourceUri:e}){const{server:t,apiClients:n}=tr(),r=Xxe(e),o=r?.environmentName??"",a=r?.packageName??"",i=r?.dataAppPath??"",s=r?.versionId,l=C.useMemo(()=>Qxe({server:t,environmentName:o,packageName:a,path:i,...s!==void 0?{versionId:s}:{}}),[t,o,a,i,s]),d=co({queryKey:["data-apps",o,a,s],queryFn:()=>n.dataApps.listDataApps(o,a,s),enabled:!!r}).data?.data?.find(w=>w.path===i),u=d?.title??i,m=d?.fit==="viewport",g=C.useRef(null),[y,x]=C.useState(120);return C.useEffect(()=>{if(m)return;function w(S){Kxe(S.data)&&S.source===g.current?.contentWindow&&S.data.height>0&&x(Math.ceil(S.data.height))}return window.addEventListener("message",w),()=>window.removeEventListener("message",w)},[m]),r?p.jsxs(Te,{sx:{p:3,...m?{height:"100%",display:"flex",flexDirection:"column"}:{maxWidth:1600,mx:"auto"}},children:[p.jsxs(Yn,{direction:"row",alignItems:"baseline",spacing:1,sx:{mb:1,flexShrink:0},children:[p.jsx(wt,{variant:"h6",sx:{fontWeight:"fontWeightMedium",letterSpacing:"-0.025em"},children:u}),p.jsx(wt,{variant:"caption",color:"text.secondary",sx:{fontFamily:Fo},children:i}),p.jsx(Te,{sx:{flex:1}}),p.jsx(Br,{title:"Open standalone in new tab",children:p.jsx(ro,{size:"small",href:l,target:"_blank",rel:"noopener noreferrer","aria-label":"Open standalone in new tab",sx:{color:"text.secondary"},children:p.jsx(n6,{fontSize:"small"})})})]}),p.jsx(Te,{sx:{border:"1px solid",borderColor:"divider",borderRadius:1.5,overflow:"hidden",backgroundColor:"background.paper",...m?{flex:1,minHeight:0}:{}},children:p.jsx("iframe",{ref:g,src:l,title:u,sandbox:"allow-scripts allow-same-origin allow-forms",style:{display:"block",width:"100%",height:m?"100%":y,border:0}})})]}):p.jsxs(Te,{sx:{p:3,maxWidth:1600,mx:"auto"},children:[p.jsx(wt,{variant:"h6",sx:{fontWeight:"fontWeightMedium"},children:"Can't open data app"}),p.jsxs(wt,{variant:"body2",color:"text.secondary",sx:{mt:1},children:["This data app link is missing an environment, package, or path:",p.jsx(Te,{component:"span",sx:{fontFamily:Fo,ml:1},children:e})]})]})}function Ns({title:e,count:t,description:n,action:r,children:o}){const a=C.useId();return p.jsxs(Te,{component:"section","aria-labelledby":a,sx:{mb:4},children:[p.jsxs(Yn,{direction:"row",alignItems:"center",justifyContent:"space-between",sx:{mb:n?0:1,minHeight:40},children:[p.jsxs(Yn,{direction:"row",alignItems:"baseline",spacing:1,children:[p.jsx(wt,{id:a,variant:"h6",sx:{fontWeight:600,letterSpacing:"-0.025em",lineHeight:1.2},children:e}),t!==void 0&&p.jsxs(wt,{variant:"caption",color:"text.secondary",children:["(",t,")"]})]}),r]}),n&&p.jsx(wt,{variant:"body2",color:"text.secondary",sx:{mb:1.5},children:n}),p.jsx(Te,{children:o})]})}function Zxe({resourceUri:e}){const{environmentName:t}=Xr(e),{apiClients:n}=tr(),[r,o]=C.useState(!1),a=90,{data:i,isSuccess:s,isError:l,error:d}=co({queryKey:["about",t],queryFn:()=>n.environments.getEnvironment(t,!1)}),u=i?.data?.readme||"",m=u.split(/\s+/),g=m.length>a,y=m.slice(0,a).join(" ");return p.jsxs(p.Fragment,{children:[!s&&!l&&p.jsx(Bo,{text:"Fetching About..."}),s&&u&&p.jsxs(Ns,{title:"Readme",children:[p.jsx(oh,{variant:"caption",children:r||!g?u:y}),g&&p.jsx(Te,{sx:{mt:1},children:p.jsx(Xy,{label:r?"Read less":"Read more",onClick:()=>o(!r)})})]}),l&&p.jsx(ja,{error:d,context:`${t} > About`})]})}function Jxe(e={}){const{autoHideDuration:t=null,disableWindowBlurListener:n=!1,onClose:r,open:o,resumeHideDuration:a}=e,i=w2();C.useEffect(()=>{if(!o)return;function S(b){b.defaultPrevented||b.key==="Escape"&&r?.(b,"escapeKeyDown")}return document.addEventListener("keydown",S),()=>{document.removeEventListener("keydown",S)}},[o,r]);const s=Yt((S,b)=>{r?.(S,b)}),l=Yt(S=>{!r||S==null||i.start(S,()=>{s(null,"timeout")})});C.useEffect(()=>(o&&l(t),i.clear),[o,t,l,i]);const d=S=>{r?.(S,"clickaway")},u=i.clear,m=C.useCallback(()=>{t!=null&&l(a??t*.5)},[t,a,l]),g=S=>b=>{const $=S.onBlur;$?.(b),m()},y=S=>b=>{const $=S.onFocus;$?.(b),u()},x=S=>b=>{const $=S.onMouseEnter;$?.(b),u()},w=S=>b=>{const $=S.onMouseLeave;$?.(b),m()};return C.useEffect(()=>{if(!n&&o)return window.addEventListener("focus",m),window.addEventListener("blur",u),()=>{window.removeEventListener("focus",m),window.removeEventListener("blur",u)}},[n,o,m,u]),{getRootProps:(S={})=>{const b={...q0(e),...q0(S)};return{role:"presentation",...S,...b,onBlur:g(b),onFocus:y(b),onMouseEnter:x(b),onMouseLeave:w(b)}},onClickAway:d}}function JN(e){return e.substring(2).toLowerCase()}function e1e(e,t){return t.documentElement.clientWidth<e.clientX||t.documentElement.clientHeight<e.clientY}function t1e(e){const{children:t,disableReactTree:n=!1,mouseEvent:r="onClick",onClickAway:o,touchEvent:a="onTouchEnd"}=e,i=C.useRef(!1),s=C.useRef(null),l=C.useRef(!1),d=C.useRef(!1);C.useEffect(()=>(setTimeout(()=>{l.current=!0},0),()=>{l.current=!1}),[]);const u=vr(wh(t),s),m=Yt(x=>{const w=d.current;d.current=!1;const S=Yo(s.current);if(!l.current||!s.current||"clientX"in x&&e1e(x,S))return;if(i.current){i.current=!1;return}let b;x.composedPath?b=x.composedPath().includes(s.current):b=!S.documentElement.contains(x.target)||s.current.contains(x.target),!b&&(n||!w)&&o(x)}),g=x=>w=>{d.current=!0;const S=t.props[x];S&&S(w)},y={ref:u};return a!==!1&&(y[a]=g(a)),C.useEffect(()=>{if(a!==!1){const x=JN(a),w=Yo(s.current),S=()=>{i.current=!0};return w.addEventListener(x,m),w.addEventListener("touchmove",S),()=>{w.removeEventListener(x,m),w.removeEventListener("touchmove",S)}}},[m,a]),r!==!1&&(y[r]=g(r)),C.useEffect(()=>{if(r!==!1){const x=JN(r),w=Yo(s.current);return w.addEventListener(x,m),()=>{w.removeEventListener(x,m)}}},[m,r]),C.cloneElement(t,y)}function n1e(e){return Cn("MuiSnackbarContent",e)}fn("MuiSnackbarContent",["root","message","action"]);const r1e=e=>{const{classes:t}=e;return bn({root:["root"],action:["action"],message:["message"]},n1e,t)},o1e=nt(tf,{name:"MuiSnackbarContent",slot:"Root"})(Gn(({theme:e})=>{const t=e.palette.mode==="light"?.8:.98;return{...e.typography.body2,color:e.vars?e.vars.palette.SnackbarContent.color:e.palette.getContrastText(Bk(e.palette.background.default,t)),backgroundColor:e.vars?e.vars.palette.SnackbarContent.bg:Bk(e.palette.background.default,t),display:"flex",alignItems:"center",flexWrap:"wrap",padding:"6px 16px",flexGrow:1,[e.breakpoints.up("sm")]:{flexGrow:"initial",minWidth:288}}})),a1e=nt("div",{name:"MuiSnackbarContent",slot:"Message"})({padding:"8px 0"}),i1e=nt("div",{name:"MuiSnackbarContent",slot:"Action"})({display:"flex",alignItems:"center",marginLeft:"auto",paddingLeft:16,marginRight:-8}),s1e=C.forwardRef(function(e,t){const n=Kn({props:e,name:"MuiSnackbarContent"}),{action:r,className:o,message:a,role:i="alert",...s}=n,l=n,d=r1e(l);return p.jsxs(o1e,{role:i,elevation:6,className:Ht(d.root,o),ownerState:l,ref:t,...s,children:[p.jsx(a1e,{className:d.message,ownerState:l,children:a}),r?p.jsx(i1e,{className:d.action,ownerState:l,children:r}):null]})});function l1e(e){return Cn("MuiSnackbar",e)}fn("MuiSnackbar",["root","anchorOriginTopCenter","anchorOriginBottomCenter","anchorOriginTopRight","anchorOriginBottomRight","anchorOriginTopLeft","anchorOriginBottomLeft"]);const c1e=e=>{const{classes:t,anchorOrigin:n}=e,r={root:["root",`anchorOrigin${Tt(n.vertical)}${Tt(n.horizontal)}`]};return bn(r,l1e,t)},u1e=nt("div",{name:"MuiSnackbar",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.root,t[`anchorOrigin${Tt(n.anchorOrigin.vertical)}${Tt(n.anchorOrigin.horizontal)}`]]}})(Gn(({theme:e})=>({zIndex:(e.vars||e).zIndex.snackbar,position:"fixed",display:"flex",left:8,right:8,justifyContent:"center",alignItems:"center",variants:[{props:({ownerState:t})=>t.anchorOrigin.vertical==="top",style:{top:8,[e.breakpoints.up("sm")]:{top:24}}},{props:({ownerState:t})=>t.anchorOrigin.vertical!=="top",style:{bottom:8,[e.breakpoints.up("sm")]:{bottom:24}}},{props:({ownerState:t})=>t.anchorOrigin.horizontal==="left",style:{justifyContent:"flex-start",[e.breakpoints.up("sm")]:{left:24,right:"auto"}}},{props:({ownerState:t})=>t.anchorOrigin.horizontal==="right",style:{justifyContent:"flex-end",[e.breakpoints.up("sm")]:{right:24,left:"auto"}}},{props:({ownerState:t})=>t.anchorOrigin.horizontal==="center",style:{[e.breakpoints.up("sm")]:{left:"50%",right:"auto",transform:"translateX(-50%)"}}}]}))),d1e=C.forwardRef(function(e,t){const n=Kn({props:e,name:"MuiSnackbar"}),r=Xd(),o={enter:r.transitions.duration.enteringScreen,exit:r.transitions.duration.leavingScreen},{action:a,anchorOrigin:{vertical:i,horizontal:s}={vertical:"bottom",horizontal:"left"},autoHideDuration:l=null,children:d,className:u,ClickAwayListenerProps:m,ContentProps:g,disableWindowBlurListener:y=!1,message:x,onBlur:w,onClose:S,onFocus:b,onMouseEnter:$,onMouseLeave:k,open:T,resumeHideDuration:O,slots:P={},slotProps:D={},TransitionComponent:A,transitionDuration:F=o,TransitionProps:{onEnter:L,onExited:_,...R}={},...z}=n,N={...n,anchorOrigin:{vertical:i,horizontal:s},autoHideDuration:l,disableWindowBlurListener:y,TransitionComponent:A,transitionDuration:F},B=c1e(N),{getRootProps:I,onClickAway:H}=Jxe({...N}),[Y,ae]=C.useState(!0),K=me=>{ae(!0),_&&_(me)},oe=(me,se)=>{ae(!1),L&&L(me,se)},ue={slots:{transition:A,...P},slotProps:{content:g,clickAwayListener:m,transition:R,...D}},[G,ie]=ur("root",{ref:t,className:[B.root,u],elementType:u1e,getSlotProps:I,externalForwardedProps:{...ue,...z},ownerState:N}),[Q,{ownerState:ee,...Z}]=ur("clickAwayListener",{elementType:t1e,externalForwardedProps:ue,getSlotProps:me=>({onClickAway:(...se)=>{const ve=se[0];me.onClickAway?.(...se),!ve?.defaultMuiPrevented&&H(...se)}}),ownerState:N}),[de,le]=ur("content",{elementType:s1e,shouldForwardComponentProp:!0,externalForwardedProps:ue,additionalProps:{message:x,action:a},ownerState:N}),[fe,he]=ur("transition",{elementType:gy,externalForwardedProps:ue,getSlotProps:me=>({onEnter:(...se)=>{me.onEnter?.(...se),oe(...se)},onExited:(...se)=>{me.onExited?.(...se),K(...se)}}),additionalProps:{appear:!0,in:T,timeout:F,direction:i==="top"?"down":"up"},ownerState:N});return!T&&Y?null:p.jsx(Q,{...Z,...P.clickAwayListener&&{ownerState:ee},children:p.jsx(G,{...ie,children:p.jsx(fe,{...he,children:d||p.jsx(de,{...le})})})})});let S$;function f1e(e){S$=e}function eI(e){if(S$)try{S$(e)}catch{}}function rc(e,t,n){return(async r=>{const o=Date.now();try{const a=await n(r);return eI({type:"console.mutation",resource:e,action:t,ok:!0,durationMs:Date.now()-o}),a}catch(a){throw eI({type:"console.mutation",resource:e,action:t,ok:!1,durationMs:Date.now()-o,reason:a instanceof Error?a.message:"An unknown error occurred"}),a}})}function Ch({mutationFn:e,success:t,invalidates:n,closeDialog:r,resource:o,action:a}){const i=Tl(),[s,l]=C.useState(""),d=hl({mutationFn:rc(o,a,e),onSuccess(){r();for(const u of n)i.invalidateQueries({queryKey:u});l(t)},onError(u){l(u instanceof Error?u.message:"An unknown error occurred")}});return{mutate:d.mutate,isPending:d.isPending,notice:p.jsx(d1e,{open:s!=="",autoHideDuration:6e3,onClose:()=>l(""),message:s})}}const o6="https://docs.malloydata.dev/documentation",tI=`${o6}/user_guides/publishing`,Bb="https://github.com/malloydata/publisher/blob/main/docs",tu={docsHome:`${o6}/`,publishing:`${tI}/publishing`,mcpAgents:`${tI}/mcp_agents`,surfaces:`${Bb}/choosing-a-surface.md`,givens:`${Bb}/givens.md`,materialization:`${Bb}/materialization.md`,connections:`${Bb}/connections.md`};function p1e({resourceUri:e}){const[t,n]=C.useState(!1),{apiClients:r}=tr(),{environmentName:o}=Xr(e),a=Ch({mutationFn(s){return r.packages.createPackage(o,{name:s.name,description:s.description,location:s.location})},success:"Package created",invalidates:[["packages",o]],closeDialog:()=>n(!1),resource:"package",action:"create"}),i=s=>{s.preventDefault();const l=new FormData(s.currentTarget),d=l.get("name")?.toString(),u=l.get("description")?.toString(),m=l.get("location")?.toString();a.mutate({name:d,description:u,location:m})};return p.jsxs(p.Fragment,{children:[p.jsx(Qy,{label:"Package",onClick:()=>n(!0)}),p.jsx(Oo,{open:t,onClose:()=>n(!1),title:"New package",description:p.jsxs(p.Fragment,{children:["A package is a directory of Malloy models and their data. Give its location as a GitHub, S3 or GCS URL, or an absolute path the server can read; see the"," ",p.jsx(Te,{component:"a",href:tu.publishing,target:"_blank",rel:"noopener noreferrer",sx:{color:"text.primary"},children:"package format"}),"."]}),actions:p.jsxs(p.Fragment,{children:[p.jsx(Vn,{disabled:a.isPending,onClick:()=>n(!1),children:"Cancel"}),p.jsx(Vn,{type:"submit",form:"package-form",variant:"contained",loading:a.isPending,children:"Create package"})]}),children:p.jsx("form",{onSubmit:i,id:"package-form",children:p.jsxs(Yn,{sx:{gap:2},children:[p.jsx(Ri,{autoFocus:!0,required:!0,id:"name",name:"name",label:"Name",type:"text",fullWidth:!0,size:"small",InputLabelProps:{shrink:!0}}),p.jsx(Ri,{id:"description",name:"description",label:"Description",multiline:!0,rows:3,fullWidth:!0,size:"small",InputLabelProps:{shrink:!0}}),p.jsx(Ri,{id:"location",name:"location",label:"Location",type:"text",placeholder:"e.g. s3://my-bucket/my-package.zip",fullWidth:!0,size:"small",InputLabelProps:{shrink:!0}})]})})}),a.notice]})}const h1e=Jt(p.jsx("path",{d:"M2 20h20v-4H2zm2-3h2v2H4zM2 4v4h20V4zm4 3H4V5h2zm-4 7h20v-4H2zm2-3h2v2H4z"}));function L1({icon:e,tint:t,label:n,mono:r,description:o,rightLabel:a,trailingAction:i,onClick:s,ariaLabel:l}){const d=!!s;return p.jsxs(Te,{onClick:s,onKeyDown:d?u=>{s&&(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),s(u))}:void 0,role:d?"button":void 0,tabIndex:d?0:void 0,"aria-label":l,sx:u=>({display:"flex",alignItems:"center",gap:1.5,py:1,px:1,mx:-1,cursor:d?"pointer":"default",borderRadius:1.5,transition:"background-color 0.1s","&:hover":d?{backgroundColor:u.palette.mode==="dark"?"rgba(255, 255, 255, 0.08)":"grey.100"}:void 0,"&:focus-visible":d?{outline:"2px solid",outlineColor:"primary.main",outlineOffset:2}:void 0}),children:[p.jsx(Te,{sx:{width:32,height:32,borderRadius:1,bgcolor:t,color:"#FFFFFF",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e}),p.jsxs(Te,{sx:{flex:1,minWidth:0,display:"flex",alignItems:"baseline",gap:1.5},children:[p.jsx(wt,{variant:"body2",sx:{...r?{fontFamily:Fo}:{},flexShrink:0,maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n}),o&&p.jsx(wt,{variant:"body2",color:"text.secondary",sx:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:o})]}),a&&p.jsx(wt,{variant:"caption",color:"text.secondary",sx:{flexShrink:0},children:a}),i&&p.jsx(Te,{sx:{flexShrink:0,display:"flex",alignItems:"center"},children:i})]})}const a6=Jt(p.jsx("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6zM19 4h-3.5l-1-1h-5l-1 1H5v2h14z"})),m1e=fn("MuiBox",["root"]),g1e=tF(),Ta=sR({themeId:bh,defaultTheme:g1e,defaultClassName:m1e.root,generateClassName:B4.generate}),z1=hR({createStyledComponent:nt("div",{name:"MuiStack",slot:"Root"}),useThemeProps:e=>Kn({props:e,name:"MuiStack"})}),nI=fn("MuiDivider",["root","absolute","fullWidth","inset","middle","flexItem","light","vertical","withChildren","withChildrenVertical","textAlignRight","textAlignLeft","wrapper","wrapperVertical"]);function y1e(e){return Cn("MuiListItemIcon",e)}const rI=fn("MuiListItemIcon",["root","alignItemsFlexStart"]),v1e=e=>{const{alignItems:t,classes:n}=e;return bn({root:["root",t==="flex-start"&&"alignItemsFlexStart"]},y1e,n)},b1e=nt("div",{name:"MuiListItemIcon",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.root,n.alignItems==="flex-start"&&t.alignItemsFlexStart]}})(Gn(({theme:e})=>({minWidth:56,color:(e.vars||e).palette.action.active,flexShrink:0,display:"inline-flex",variants:[{props:{alignItems:"flex-start"},style:{marginTop:8}}]}))),oT=C.forwardRef(function(e,t){const n=Kn({props:e,name:"MuiListItemIcon"}),{className:r,...o}=n,a=C.useContext(ic),i={...n,alignItems:a.alignItems},s=v1e(i);return p.jsx(b1e,{className:Ht(s.root,r),ownerState:i,ref:t,...o})});function x1e(e){return Cn("MuiListItemText",e)}const Rp=fn("MuiListItemText",["root","multiline","dense","inset","primary","secondary"]),w1e=e=>{const{classes:t,inset:n,primary:r,secondary:o,dense:a}=e;return bn({root:["root",n&&"inset",a&&"dense",r&&o&&"multiline"],primary:["primary"],secondary:["secondary"]},x1e,t)},S1e=nt("div",{name:"MuiListItemText",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[{[`& .${Rp.primary}`]:t.primary},{[`& .${Rp.secondary}`]:t.secondary},t.root,n.inset&&t.inset,n.primary&&n.secondary&&t.multiline,n.dense&&t.dense]}})({flex:"1 1 auto",minWidth:0,marginTop:4,marginBottom:4,[`.${eN.root}:where(& .${Rp.primary})`]:{display:"block"},[`.${eN.root}:where(& .${Rp.secondary})`]:{display:"block"},variants:[{props:({ownerState:e})=>e.primary&&e.secondary,style:{marginTop:6,marginBottom:6}},{props:({ownerState:e})=>e.inset,style:{paddingLeft:56}}]}),aT=C.forwardRef(function(e,t){const n=Kn({props:e,name:"MuiListItemText"}),{children:r,className:o,disableTypography:a=!1,inset:i=!1,primary:s,primaryTypographyProps:l,secondary:d,secondaryTypographyProps:u,slots:m={},slotProps:g={},...y}=n,{dense:x}=C.useContext(ic);let w=s??r,S=d;const b={...n,disableTypography:a,inset:i,primary:!!w,secondary:!!S,dense:x},$=w1e(b),k={slots:m,slotProps:{primary:l,secondary:u,...g}},[T,O]=ur("root",{className:Ht($.root,o),elementType:S1e,externalForwardedProps:{...k,...y},ownerState:b,ref:t}),[P,D]=ur("primary",{className:$.primary,elementType:Sr,externalForwardedProps:k,ownerState:b}),[A,F]=ur("secondary",{className:$.secondary,elementType:Sr,externalForwardedProps:k,ownerState:b});return w!=null&&w.type!==Sr&&!a&&(w=p.jsx(P,{variant:x?"body2":"body1",component:D?.variant?void 0:"span",...D,children:w})),S!=null&&S.type!==Sr&&!a&&(S=p.jsx(A,{variant:"body2",color:"textSecondary",...F,children:S})),p.jsxs(T,{...O,children:[w,S]})});function C1e(e){return Cn("MuiMenuItem",e)}const ag=fn("MuiMenuItem",["root","focusVisible","dense","disabled","divider","gutters","selected"]),k1e=(e,t)=>{const{ownerState:n}=e;return[t.root,n.dense&&t.dense,n.divider&&t.divider,!n.disableGutters&&t.gutters]},$1e=e=>{const{disabled:t,dense:n,divider:r,disableGutters:o,selected:a,classes:i}=e,s=bn({root:["root",n&&"dense",t&&"disabled",!o&&"gutters",r&&"divider",a&&"selected"]},C1e,i);return{...i,...s}},R1e=nt(qd,{shouldForwardProp:e=>ei(e)||e==="classes",name:"MuiMenuItem",slot:"Root",overridesResolver:k1e})(Gn(({theme:e})=>({...e.typography.body1,display:"flex",justifyContent:"flex-start",alignItems:"center",position:"relative",textDecoration:"none",minHeight:48,paddingTop:6,paddingBottom:6,boxSizing:"border-box",whiteSpace:"nowrap","&:hover":{textDecoration:"none",backgroundColor:(e.vars||e).palette.action.hover,"@media (hover: none)":{backgroundColor:"transparent"}},[`&.${ag.selected}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,(e.vars||e).palette.action.selectedOpacity),[`&.${ag.focusVisible}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.focusOpacity}`)}},[`&.${ag.selected}:hover`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.hoverOpacity}`),"@media (hover: none)":{backgroundColor:e.alpha((e.vars||e).palette.primary.main,(e.vars||e).palette.action.selectedOpacity)}},[`&.${ag.focusVisible}`]:{backgroundColor:(e.vars||e).palette.action.focus},[`&.${ag.disabled}`]:{opacity:(e.vars||e).palette.action.disabledOpacity},[`& + .${nI.root}`]:{marginTop:e.spacing(1),marginBottom:e.spacing(1)},[`& + .${nI.inset}`]:{marginLeft:52},[`& .${Rp.root}`]:{marginTop:0,marginBottom:0},[`& .${Rp.inset}`]:{paddingLeft:36},[`& .${rI.root}`]:{minWidth:36},variants:[{props:({ownerState:t})=>!t.disableGutters,style:{paddingLeft:16,paddingRight:16}},{props:({ownerState:t})=>t.divider,style:{borderBottom:`1px solid ${(e.vars||e).palette.divider}`,backgroundClip:"padding-box"}},{props:({ownerState:t})=>!t.dense,style:{[e.breakpoints.up("sm")]:{minHeight:"auto"}}},{props:({ownerState:t})=>t.dense,style:{minHeight:32,paddingTop:4,paddingBottom:4,...e.typography.body2,[`& .${rI.root} svg`]:{fontSize:"1.25rem"}}}]}))),Vo=C.forwardRef(function(e,t){const n=Kn({props:e,name:"MuiMenuItem"}),{autoFocus:r=!1,component:o="li",dense:a=!1,divider:i=!1,disableGutters:s=!1,focusVisibleClassName:l,role:d="menuitem",tabIndex:u,className:m,...g}=n,y=C.useContext(ic),x=C.useMemo(()=>({dense:a||y.dense||!1,disableGutters:s}),[y.dense,a,s]),w=C.useRef(null);Go(()=>{r&&w.current&&w.current.focus()},[r]);const S={...n,dense:x.dense,divider:i,disableGutters:s},b=$1e(n),$=vr(w,t);let k;return n.disabled||(k=u!==void 0?u:-1),p.jsx(ic.Provider,{value:x,children:p.jsx(R1e,{ref:$,role:d,tabIndex:k,component:o,focusVisibleClassName:Ht(b.focusVisible,l),className:Ht(b.root,m),...g,ownerState:S,classes:b})})}),ac={postgres:[{label:"Host",name:"host",type:"text",required:!1},{label:"Port",name:"port",type:"number",required:!1},{label:"Database Name",name:"databaseName",type:"text",required:!1},{label:"User Name",name:"userName",type:"text",required:!1},{label:"Password",name:"password",type:"password",required:!1},{label:"Connection String",name:"connectionString",type:"text",required:!1}],bigquery:[{label:"Project ID",name:"defaultProjectId",type:"text",required:!1},{label:"Billing Project ID",name:"billingProjectId",type:"text",required:!1},{label:"Location",name:"location",type:"text",required:!1},{label:"Service Account Key JSON",name:"serviceAccountKeyJson",type:"text",required:!0},{label:"Maximum Bytes Billed",name:"maximumBytesBilled",type:"text",required:!1},{label:"Query Timeout Milliseconds",name:"queryTimeoutMilliseconds",type:"text",required:!1}],snowflake:[{label:"Account",name:"account",type:"text",required:!0},{label:"Username",name:"username",type:"text",required:!0},{label:"Password",name:"password",type:"password",required:!1},{label:"Role",name:"role",type:"text",required:!1},{label:"Warehouse",name:"warehouse",type:"text",required:!0},{label:"Database",name:"database",type:"text",required:!1},{label:"Schema",name:"schema",type:"text",required:!1},{label:"Response Timeout Milliseconds",name:"responseTimeoutMilliseconds",type:"text",required:!1},{label:"Private Key",name:"privateKey",type:"password",required:!1},{label:"Private Key Passphrase",name:"privateKeyPass",type:"password",required:!1}],trino:[{label:"Server",name:"server",type:"text",required:!0},{label:"Port",name:"port",type:"number",required:!1},{label:"Catalog",name:"catalog",type:"text",required:!1},{label:"Schema",name:"schema",type:"text",required:!1},{label:"User",name:"user",type:"text",required:!0},{label:"Password",name:"password",type:"password",required:!1},{label:"Peaka Key",name:"peakaKey",type:"password",required:!1}],databricks:[{label:"Host",name:"host",type:"text",required:!0},{label:"HTTP Path",name:"path",type:"text",required:!0},{label:"Access Token",name:"token",type:"password",required:!1},{label:"OAuth Client ID",name:"oauthClientId",type:"text",required:!1},{label:"OAuth Client Secret",name:"oauthClientSecret",type:"password",required:!1},{label:"Default Catalog",name:"defaultCatalog",type:"text",required:!1},{label:"Default Schema",name:"defaultSchema",type:"text",required:!1}],mysql:[{label:"Host",name:"host",type:"text",required:!0},{label:"Port",name:"port",type:"number",required:!0},{label:"User",name:"user",type:"text",required:!0},{label:"Password",name:"password",type:"password",required:!0},{label:"Database",name:"database",type:"text",required:!0}],sqlserver:[{label:"Server",name:"server",type:"text",required:!0},{label:"Port",name:"port",type:"number",required:!1},{label:"Database",name:"database",type:"text",required:!0},{label:"User",name:"user",type:"text",required:!0},{label:"Password",name:"password",type:"password",required:!0},{label:"Encrypt",name:"encrypt",type:"text",required:!1,selectOptions:[{label:"Yes",value:"true"},{label:"No",value:"false"}]},{label:"Trust server certificate",name:"trustServerCertificate",type:"text",required:!1,selectOptions:[{label:"No",value:"false"},{label:"Yes",value:"true"}]},{label:"Host name in certificate",name:"hostNameInCertificate",type:"text",required:!1},{label:"Instance name",name:"instanceName",type:"text",required:!1}],duckdb:[],motherduck:[{label:"Access Token",name:"accessToken",type:"text",required:!0},{label:"Database",name:"database",type:"text",required:!1}],ducklake:[],publisher:[]},Og={postgres:"postgresConnection",bigquery:"bigqueryConnection",snowflake:"snowflakeConnection",trino:"trinoConnection",databricks:"databricksConnection",mysql:"mysqlConnection",sqlserver:"sqlserverConnection",duckdb:"duckdbConnection",motherduck:"motherduckConnection",ducklake:"ducklakeConnection",publisher:"publisherConnection"},T1e={sqlserver:{port:"integer",encrypt:"boolean",trustServerCertificate:"boolean"}},E1e={sqlserver:["hostNameInCertificate","instanceName"]};function i6(e,t){const n=T1e[e],r=E1e[e];if(!n&&!r)return t;const o={...t};for(const a of r??[])o[a]===""&&delete o[a];for(const[a,i]of Object.entries(n??{})){const s=t[a];if(s!==void 0){if(s===""){delete o[a];continue}if(i==="integer"){const l=Number(s);Number.isInteger(l)&&(o[a]=l)}else(s==="true"||s==="false")&&(o[a]=s==="true")}}return o}const s6=Object.values(hA).filter(e=>e!==hA.Publisher),C$={postgres:"postgresConnection",bigquery:"bigqueryConnection",snowflake:"snowflakeConnection",gcs:"gcsConnection",s3:"s3Connection",azure:"azureConnection"},Sy=[{label:"Credential Provider",name:"provider",type:"text",required:!1,selectOptions:[{label:"Access key pair",value:"config"},{label:"Host credential chain",value:"credential_chain"}]},{label:"Access Key ID",name:"accessKeyId",type:"text",required:!1,visibleWhen:{field:"provider",value:"config"}},{label:"Secret Access Key",name:"secretAccessKey",type:"password",required:!1,visibleWhen:{field:"provider",value:"config"}},{label:"Credential Chain",name:"chain",type:"text",required:!1,visibleWhen:{field:"provider",value:"credential_chain"}},{label:"Region",name:"region",type:"text",required:!1},{label:"Endpoint",name:"endpoint",type:"text",required:!1},{label:"Session Token",name:"sessionToken",type:"password",required:!1,visibleWhen:{field:"provider",value:"config"}}],Cy=[{label:"Key ID",name:"keyId",type:"text",required:!0},{label:"Secret",name:"secret",type:"password",required:!0}],M1e=[{label:"Auth Type",name:"authType",type:"text",required:!0,selectOptions:[{label:"SAS Token",value:"sas_token"},{label:"Service Principal (SPN)",value:"service_principal"}]},{label:"SAS URL (e.g. https://account.blob.core.windows.net/container/file.parquet?sp=r&st=...)",name:"sasUrl",type:"text",required:!1,visibleWhen:{field:"authType",value:"sas_token"}},{label:"Tenant ID",name:"tenantId",type:"text",required:!1,visibleWhen:{field:"authType",value:"service_principal"}},{label:"Client ID",name:"clientId",type:"text",required:!1,visibleWhen:{field:"authType",value:"service_principal"}},{label:"Client Secret",name:"clientSecret",type:"password",required:!1,visibleWhen:{field:"authType",value:"service_principal"}},{label:"Account Name",name:"accountName",type:"text",required:!1,visibleWhen:{field:"authType",value:"service_principal"}},{label:"File URL (e.g. abfss://container/path/file.parquet)",name:"fileUrl",type:"text",required:!1,visibleWhen:{field:"authType",value:"service_principal"}}];function ex(e){return e==="postgres"||e==="bigquery"||e==="snowflake"?ac[e]||[]:e==="s3"?Sy:e==="gcs"?Cy:e==="azure"?M1e:[]}function O1e({onSubmit:e,isSubmitting:t}){const[n,r]=C.useState(!1),[o,a]=C.useState("postgres"),[i,s]=C.useState([]),[l,d]=C.useState("postgres"),[u,m]=C.useState("s3"),[g,y]=C.useState("config"),x=()=>{r(!0)},w=()=>{r(!1),s([]),a("postgres"),d("postgres"),m("s3"),y("config")},S=async T=>{T.preventDefault();const O=new FormData(T.currentTarget),P=O.get("name")?.toString(),D=O.get("type")?.toString(),A=ac[D];if(!P)throw new Error("Name is required");if(!D)throw new Error("Type is required");let F;if(D==="ducklake"){const L={};if(l==="postgres"){const z=ac.postgres,N={};if(z.forEach(B=>{const I=O.get(`ducklake_pg_${B.name}`)?.toString();I&&(N[B.name]=I)}),Object.keys(N).length===0)throw new Error("DuckLake requires catalog connection");L.postgresConnection=N}const _=O.get("ducklake_bucketUrl")?.toString();if(!_)throw new Error("DuckLake requires a bucket URL");const R={bucketUrl:_};if(u==="s3"){const z={};if(Sy.forEach(N=>{const B=O.get(`ducklake_s3_${N.name}`)?.toString();B&&(z[N.name]=B)}),z.provider==="credential_chain")delete z.accessKeyId,delete z.secretAccessKey,delete z.sessionToken;else{if(delete z.chain,!z.accessKeyId)throw new Error("S3 Access Key ID is required");if(!z.secretAccessKey)throw new Error("S3 Secret Access Key is required")}Object.keys(z).length>0&&(R.s3Connection=z)}else if(u==="gcs"){const z={};if(Cy.forEach(N=>{const B=O.get(`ducklake_gcs_${N.name}`)?.toString();B&&(z[N.name]=B)}),!z.keyId)throw new Error("GCS Key ID is required");if(!z.secret)throw new Error("GCS Secret is required");Object.keys(z).length>0&&(R.gcsConnection=z)}F={name:P,type:D,ducklakeConnection:{catalog:L,storage:R}}}else if(D==="duckdb"){if(i.length===0)throw new Error("DuckDB connection must have at least one attached database");const L=i.map((_,R)=>{const z=_.dbType,N=O.get(`attachedDb_${R}_name`)?.toString();if(!N)throw new Error(`Attached database at index ${R} must have a name`);const B={name:N,type:z},I=ex(z);if(I&&I.length>0){const H={};if(I.forEach(ae=>{const K=O.get(`attachedDb_${R}_${ae.name}`)?.toString();K&&(H[ae.name]=K)}),z==="s3"){if(H.provider==="credential_chain")delete H.accessKeyId,delete H.secretAccessKey,delete H.sessionToken;else if(delete H.chain,!H.accessKeyId||!H.secretAccessKey)throw new Error(`Attached database "${N}" requires an S3 Access Key ID and Secret Access Key, or Credential Provider set to the host credential chain`)}const Y=C$[z];Y&&(B[Y]=H)}return B});F={name:P,type:D,duckdbConnection:{attachedDatabases:L}}}else{const L={};if(A.forEach(_=>{const R=O.get(_.name)?.toString();R&&(L[_.name]=R)}),D==="postgres"){if(!L.connectionString?.trim()){const _=["host","port","databaseName","userName","password"];for(const R of _)if(!L[R])throw new Error(`${A.find(z=>z.name===R)?.label||R} is required`)}}else if(D==="bigquery"){if(!L.serviceAccountKeyJson)throw new Error("Service Account Key JSON is required")}else if(D==="snowflake"){if(!L.account)throw new Error("Account is required");if(!L.username)throw new Error("Username is required");if(!L.warehouse)throw new Error("Warehouse is required");if(!L.password&&!L.privateKey)throw new Error("Either password or private key is required")}else if(D==="trino"){if(!L.server)throw new Error("Server is required");if(!L.user)throw new Error("User is required");if(L.server.trim().startsWith("https://")&&!L.password&&!L.peakaKey)throw new Error("Password is required for HTTPS connections (or use Peaka Key)")}else if(D==="mysql"){const _=["host","port","database","user","password"];for(const R of _)if(!L[R])throw new Error(`${A.find(z=>z.name===R)?.label||R} is required`)}else if(D==="sqlserver"){const _=["server","database","user","password"];if(!L.instanceName&&!L.port)throw new Error("Port is required unless an instance name is given");for(const R of _)if(!L[R])throw new Error(`${A.find(z=>z.name===R)?.label||R} is required`)}else if(D==="motherduck"){if(!L.accessToken)throw new Error("Access Token is required")}else if(D==="databricks"){if(!L.host)throw new Error("Host is required");if(!L.path)throw new Error("HTTP Path is required");const _=L.oauthClientId&&L.oauthClientSecret;if(!L.token&&!_)throw new Error("Either Access Token or OAuth Client ID + Secret is required")}F={name:P,type:D,[Og[D]]:i6(D,L)}}await e(F),w()},b=()=>{s([...i,{name:"",dbType:"postgres"}])},$=T=>{s(i.filter((O,P)=>P!==T))},k=(T,O)=>{const P=[...i];P[T]={...P[T],dbType:O},s(P)};return p.jsxs(kn.Fragment,{children:[p.jsx(Qy,{label:"Connection",onClick:x}),p.jsx(Oo,{open:n,onClose:w,title:"New connection",description:"Add a connection so packages in this environment can query your database with Malloy.",actions:p.jsxs(p.Fragment,{children:[p.jsx(Co,{disabled:t,onClick:w,children:"Cancel"}),p.jsx(Co,{type:"submit",form:"connection-form",variant:"contained",loading:t,children:"Create connection"})]}),children:p.jsx("form",{onSubmit:S,id:"connection-form",children:p.jsxs(z1,{sx:{gap:2},children:[p.jsx(yr,{autoFocus:!0,required:!0,id:"name",name:"name",label:"Name",type:"text",fullWidth:!0,size:"small"}),p.jsx(yr,{id:"type",name:"type",label:"Connection Type",fullWidth:!0,size:"small",value:o,select:!0,onChange:T=>a(T.target.value),children:s6.map(T=>p.jsx(Vo,{value:T,children:T},T))}),o==="ducklake"?p.jsxs(Ta,{sx:{mt:2},children:[p.jsxs(Ta,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[p.jsx(Sr,{variant:"subtitle2",sx:{mb:2},fontWeight:500,children:"Catalog"}),p.jsx(yr,{id:"ducklake_catalogType",label:"Catalog Type",fullWidth:!0,size:"small",value:l,select:!0,onChange:T=>d(T.target.value),children:p.jsx(Vo,{value:"postgres",children:"PostgreSQL"})}),l==="postgres"&&p.jsx(p.Fragment,{children:ac.postgres.map(T=>p.jsx(yr,{id:`ducklake_pg_${T.name}`,name:`ducklake_pg_${T.name}`,label:T.label,type:T.type,fullWidth:!0,size:"small"},`pg_${T.name}`))})]}),p.jsxs(Ta,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[p.jsx(Sr,{variant:"subtitle2",sx:{mb:2},fontWeight:500,children:"Storage"}),p.jsxs(yr,{id:"ducklake_storageType",label:"Storage Type",fullWidth:!0,size:"small",value:u,select:!0,onChange:T=>m(T.target.value),children:[p.jsx(Vo,{value:"s3",children:"S3"}),p.jsx(Vo,{value:"gcs",children:"GCS"})]}),p.jsx(yr,{required:!0,id:"ducklake_bucketUrl",name:"ducklake_bucketUrl",label:u==="s3"?"Bucket URL (e.g. s3://my-bucket/path)":"Bucket URL (e.g. gs://my-bucket/path)",type:"text",fullWidth:!0,size:"small"}),u==="s3"&&p.jsxs(p.Fragment,{children:[p.jsx(Sr,{variant:"caption",sx:{mt:2,mb:1,display:"block"},color:"text.secondary",children:"S3 Credentials"}),Sy.filter(T=>T.visibleWhen?g===T.visibleWhen.value:!0).map(T=>p.jsx(yr,{id:`ducklake_s3_${T.name}`,name:`ducklake_s3_${T.name}`,label:T.label,type:T.selectOptions?void 0:T.type,fullWidth:!0,size:"small",required:T.required,select:!!T.selectOptions,defaultValue:T.selectOptions?g:void 0,onChange:T.name==="provider"?O=>y(O.target.value):void 0,placeholder:T.name==="region"?"us-east-1":void 0,children:T.selectOptions?.map(O=>p.jsx(Vo,{value:O.value,children:O.label},O.value))},`s3_${T.name}`))]}),u==="gcs"&&p.jsxs(p.Fragment,{children:[p.jsx(Sr,{variant:"caption",sx:{mt:2,mb:1,display:"block"},color:"text.secondary",children:"GCS Credentials"}),Cy.map(T=>p.jsx(yr,{id:`ducklake_gcs_${T.name}`,name:`ducklake_gcs_${T.name}`,label:T.label,type:T.type,fullWidth:!0,size:"small",required:T.required},`gcs_${T.name}`))]})]})]}):o==="duckdb"?p.jsxs(Ta,{sx:{mt:2},children:[p.jsxs(Ta,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[p.jsx(Sr,{variant:"subtitle1",fontWeight:500,children:"Attached Databases"}),p.jsx(Xy,{label:"Database",icon:p.jsx(f1,{}),onClick:b,ariaLabel:"Add database"})]}),i.length===0&&p.jsx(Sr,{variant:"body2",color:"text.secondary",sx:{mb:2},children:'DuckDB connections require at least one attached database. Click "Add Database" to get started.'}),i.map((T,O)=>{const P=ex(T.dbType);return p.jsxs(Ta,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[p.jsxs(Ta,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[p.jsxs(Sr,{variant:"subtitle2",children:["Database ",O+1]}),p.jsx(Tu,{onClick:()=>$(O),size:"small",color:"error",children:p.jsx(a6,{fontSize:"small"})})]}),p.jsx(yr,{required:!0,id:`attachedDb_${O}_name`,name:`attachedDb_${O}_name`,label:"Database Name",type:"text",fullWidth:!0,size:"small",defaultValue:T.name}),p.jsx(yr,{id:`attachedDb_${O}_type`,name:`attachedDb_${O}_type`,label:"Database Type",fullWidth:!0,size:"small",value:T.dbType,select:!0,onChange:D=>k(O,D.target.value),children:Object.values($4).map(D=>p.jsx(Vo,{value:D,children:D},D))}),P.filter(D=>D.visibleWhen?(T[D.visibleWhen.field]||P.find(A=>A.name===D.visibleWhen?.field)?.selectOptions?.[0]?.value)===D.visibleWhen.value:!0).map(D=>p.jsx(yr,{id:`attachedDb_${O}_${D.name}`,name:`attachedDb_${O}_${D.name}`,label:D.label,type:D.selectOptions?void 0:D.type,fullWidth:!0,size:"small",required:D.required,select:!!D.selectOptions,defaultValue:D.selectOptions?.[0]?.value,onChange:D.selectOptions?A=>{const F=[...i];F[O]={...F[O],[D.name]:A.target.value},s(F)}:void 0,children:D.selectOptions?.map(A=>p.jsx(Vo,{value:A.value,children:A.label},A.value))},D.name))]},O)})]}):ac[o].map(T=>p.jsx(yr,{id:T.name,name:T.name,label:T.label,type:T.type,fullWidth:!0,size:"small",required:T.required,select:!!T.selectOptions,defaultValue:T.selectOptions?T.selectOptions[0]?.value:void 0,children:T.selectOptions?.map(O=>p.jsx(Vo,{value:O.value,children:O.label},O.value))},T.name))]})})})]})}function P1e({connection:e,onCloseDialog:t,isMutating:n,onDelete:r}){const[o,a]=C.useState(!1),i=()=>{a(!0)},s=()=>{a(!1),t()};return p.jsxs(kn.Fragment,{children:[p.jsxs(Vo,{"aria-label":`Delete connection ${e?.name??""}`.trim(),onClick:l=>{l.stopPropagation(),i()},sx:{color:"error.main"},children:[p.jsx(oT,{sx:{color:"inherit"},children:p.jsx(Zx,{fontSize:"small"})}),p.jsx(aT,{children:"Delete"})]}),p.jsx(Oo,{open:o,onClose:s,title:"Delete connection",actions:p.jsxs(p.Fragment,{children:[p.jsx(Co,{onClick:s,children:"Cancel"}),p.jsx(Co,{variant:"contained",color:"error",autoFocus:!0,onClick:()=>r(),loading:n,children:"Delete connection"})]}),children:p.jsxs(Sr,{variant:"body2",children:["Delete ",p.jsx("strong",{children:e.name}),"? Packages that query through it stop working, and this cannot be undone."]})})]})}const oI=new Set(["password","connectionString","privateKey","privateKeyPass","serviceAccountKeyJson","token","oauthClientSecret","accessToken","peakaKey","secret","secretAccessKey","sessionToken","clientSecret","sasUrl"]);function aI(e){const t=e.duckdbConnection?.attachedDatabases;return!t||t.length===0?[]:t.map(n=>({name:n.name||"",dbType:n.type||"postgres"}))}function iI(e){const t=e.ducklakeConnection;return t&&t.storage?.gcsConnection?"gcs":"s3"}function j1e({connection:e,onSubmit:t,isSubmitting:n,onCloseDialog:r}){const[o,a]=C.useState(!1),[i,s]=C.useState(e.type),l=kn.useMemo(()=>new Set(e.withheldFields??[]),[e.withheldFields]),[d,u]=C.useState(()=>aI(e)),[m,g]=C.useState("postgres"),[y,x]=C.useState(()=>iI(e)),[w,S]=C.useState(()=>e.ducklakeConnection?.storage?.s3Connection?.provider??"config"),b=()=>{u(aI(e)),s(e.type),S(e.ducklakeConnection?.storage?.s3Connection?.provider??"config"),g("postgres"),x(iI(e)),a(!0)},$=()=>{a(!1),r?.()},k=async F=>{F.preventDefault();const L=new FormData(F.currentTarget),_=L.get("name")?.toString(),R=L.get("type")?.toString(),z=ac[R];if(!_)throw new Error("Name is required");if(!R)throw new Error("Type is required");let N;if(R==="ducklake"){const B={};if(m==="postgres"){const Y=ac.postgres,ae={};if(Y.forEach(K=>{const oe=L.get(`ducklake_pg_${K.name}`)?.toString();oe&&(ae[K.name]=oe)}),Object.keys(ae).length===0)throw new Error("DuckLake requires catalog connection");B.postgresConnection=ae}const I=L.get("ducklake_bucketUrl")?.toString();if(!I)throw new Error("DuckLake requires a bucket URL");const H={bucketUrl:I};if(y==="s3"){const Y={};Sy.forEach(K=>{const oe=L.get(`ducklake_s3_${K.name}`)?.toString();oe&&(Y[K.name]=oe)});const ae=e.ducklakeConnection?.storage?.s3Connection;if(ae&&(!Y.provider&&ae.provider&&(Y.provider=ae.provider),!Y.chain&&ae.chain&&(Y.chain=ae.chain),!Y.accessKeyId&&ae.accessKeyId&&(Y.accessKeyId=ae.accessKeyId)),Y.provider==="credential_chain")delete Y.accessKeyId,delete Y.secretAccessKey,delete Y.sessionToken;else if(delete Y.chain,!Y.accessKeyId)throw new Error("S3 Access Key ID is required");Object.keys(Y).length>0&&(H.s3Connection=Y)}else if(y==="gcs"){const Y={};Cy.forEach(K=>{const oe=L.get(`ducklake_gcs_${K.name}`)?.toString();oe&&(Y[K.name]=oe)});const ae=e.ducklakeConnection?.storage?.gcsConnection;if(ae&&!Y.keyId&&ae.keyId&&(Y.keyId=ae.keyId),!Y.keyId)throw new Error("GCS Key ID is required");Object.keys(Y).length>0&&(H.gcsConnection=Y)}N={name:_,type:R,ducklakeConnection:{catalog:B,storage:H}}}else if(R==="duckdb"){if(d.length===0)throw new Error("DuckDB connection must have at least one attached database");const B=d.map((I,H)=>{const Y=I.dbType,ae=L.get(`attachedDb_${H}_name`)?.toString();if(!ae)throw new Error(`Attached database at index ${H} must have a name`);const K={name:ae,type:Y},oe=ex(Y);if(oe&&oe.length>0){const ue={};if(oe.forEach(ie=>{const Q=L.get(`attachedDb_${H}_${ie.name}`)?.toString();Q&&(ue[ie.name]=Q)}),Y==="s3"){if(ue.provider==="credential_chain")delete ue.accessKeyId,delete ue.secretAccessKey,delete ue.sessionToken;else if(delete ue.chain,!ue.accessKeyId||!ue.secretAccessKey)throw new Error(`Attached database "${ae}" requires an S3 Access Key ID and Secret Access Key, or Credential Provider set to the host credential chain`)}const G=C$[Y];G&&(K[G]=ue)}return K});N={name:_,type:R,duckdbConnection:{attachedDatabases:B}}}else{const B=e[Og[R]]||{},I={};if(z.forEach(H=>{const Y=L.get(H.name)?.toString(),ae=B[H.name];Y?I[H.name]=Y:oI.has(H.name)||(Y!==void 0?I[H.name]=Y:ae&&(I[H.name]=ae))}),R==="postgres"){const H=["host","port","databaseName","userName"],Y=l.has("postgresConnection.connectionString");if(!(I.connectionString?.trim()||Y)){const ae=H;for(const K of ae)if(!I[K])throw new Error(`${z.find(oe=>oe.name===K)?.label||K} is required`)}}else if(R==="snowflake"){if(!I.account)throw new Error("Account is required");if(!I.username)throw new Error("Username is required");if(!I.warehouse)throw new Error("Warehouse is required")}else if(R==="trino"){if(!I.server)throw new Error("Server is required");if(!I.user)throw new Error("User is required")}else if(R==="mysql"){const H=["host","port","database","user"];for(const Y of H)if(!I[Y])throw new Error(`${z.find(ae=>ae.name===Y)?.label||Y} is required`)}else if(R==="sqlserver"){const H=["server","database","user"];if(!I.instanceName&&!I.port)throw new Error("Port is required unless an instance name is given");for(const Y of H)if(!I[Y])throw new Error(`${z.find(ae=>ae.name===Y)?.label||Y} is required`)}else if(R==="databricks"){if(!I.host)throw new Error("Host is required");if(!I.path)throw new Error("HTTP Path is required")}N={name:_,type:R,[Og[R]]:i6(R,I)}}await t(N),$()},T=()=>{u([...d,{name:"",dbType:"postgres"}])},O=F=>{u(d.filter((L,_)=>_!==F))},P=(F,L)=>{const _=[...d];_[F]={..._[F],dbType:L},u(_)},D=(F,L)=>{const _=e.duckdbConnection?.attachedDatabases;if(!_||!_[F])return"";const R=_[F],z=C$[R.type||""];return z&&R[z]?R[z][L]??"":""},A=F=>{const L=e.ducklakeConnection;if(!L)return"";if(F.startsWith("pg_")){const _=F.replace("pg_","");return L.catalog?.postgresConnection?.[_]??""}if(F==="bucketUrl")return L.storage?.bucketUrl??"";if(F.startsWith("s3_")){const _=F.replace("s3_","");return L.storage?.s3Connection?.[_]??""}if(F.startsWith("gcs_")){const _=F.replace("gcs_","");return L.storage?.gcsConnection?.[_]??""}return""};return p.jsxs(kn.Fragment,{children:[p.jsxs(Vo,{"aria-label":`Edit connection ${e?.name??""}`.trim(),onClick:F=>{F.preventDefault(),F.stopPropagation(),b()},children:[p.jsx(oT,{children:p.jsx(r2,{fontSize:"small"})}),p.jsx(aT,{children:"Edit"})]}),p.jsx(Oo,{open:o,onClose:$,title:"Edit connection",description:"Change how packages in this environment reach your database.",actions:p.jsxs(p.Fragment,{children:[p.jsx(Co,{disabled:n,onClick:$,children:"Cancel"}),p.jsx(Co,{type:"submit",form:"connection-form",variant:"contained",loading:n,children:"Save changes"})]}),children:p.jsx("form",{onSubmit:k,id:"connection-form",children:p.jsxs(z1,{sx:{gap:2},children:[p.jsx(yr,{autoFocus:!0,required:!0,id:"name",name:"name",label:"Name",type:"text",fullWidth:!0,size:"small",defaultValue:e.name}),p.jsx(yr,{id:"type",name:"type",label:"Connection Type",fullWidth:!0,size:"small",value:i,select:!0,onChange:F=>s(F.target.value),children:s6.map(F=>p.jsx(Vo,{value:F,children:F},F))}),i==="ducklake"?p.jsxs(Ta,{sx:{mt:2},children:[p.jsxs(Ta,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[p.jsx(Sr,{variant:"subtitle2",sx:{mb:2},fontWeight:500,children:"Catalog"}),p.jsx(yr,{id:"ducklake_catalogType",label:"Catalog Type",fullWidth:!0,size:"small",value:m,select:!0,onChange:F=>g(F.target.value),children:p.jsx(Vo,{value:"postgres",children:"PostgreSQL"})}),m==="postgres"&&p.jsx(p.Fragment,{children:ac.postgres.map(F=>p.jsx(yr,{id:`ducklake_pg_${F.name}`,name:`ducklake_pg_${F.name}`,label:F.label,type:F.type,fullWidth:!0,size:"small",defaultValue:A(`pg_${F.name}`)},`pg_${F.name}`))})]}),p.jsxs(Ta,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[p.jsx(Sr,{variant:"subtitle2",sx:{mb:2},fontWeight:500,children:"Storage"}),p.jsxs(yr,{id:"ducklake_storageType",label:"Storage Type",fullWidth:!0,size:"small",value:y,select:!0,onChange:F=>x(F.target.value),children:[p.jsx(Vo,{value:"s3",children:"S3"}),p.jsx(Vo,{value:"gcs",children:"GCS"})]}),p.jsx(yr,{required:!0,id:"ducklake_bucketUrl",name:"ducklake_bucketUrl",label:y==="s3"?"Bucket URL (e.g. s3://my-bucket/path)":"Bucket URL (e.g. gs://my-bucket/path)",type:"text",fullWidth:!0,size:"small",defaultValue:A("bucketUrl")}),y==="s3"&&p.jsxs(p.Fragment,{children:[p.jsx(Sr,{variant:"caption",sx:{mt:2,mb:1,display:"block"},color:"text.secondary",children:"S3 Credentials"}),Sy.filter(F=>F.visibleWhen?w===F.visibleWhen.value:!0).map(F=>p.jsx(yr,{id:`ducklake_s3_${F.name}`,name:`ducklake_s3_${F.name}`,label:F.label,type:F.selectOptions?void 0:F.type,fullWidth:!0,size:"small",required:F.required&&F.name!=="secretAccessKey",select:!!F.selectOptions,defaultValue:F.selectOptions?w:A(`s3_${F.name}`),onChange:F.name==="provider"?L=>S(L.target.value):void 0,placeholder:F.name==="region"?"us-east-1":F.name==="secretAccessKey"&&l.has("ducklakeConnection.storage.s3Connection.secretAccessKey")?"Leave empty to keep existing":void 0,children:F.selectOptions?.map(L=>p.jsx(Vo,{value:L.value,children:L.label},L.value))},`s3_${F.name}`))]}),y==="gcs"&&p.jsxs(p.Fragment,{children:[p.jsx(Sr,{variant:"caption",sx:{mt:2,mb:1,display:"block"},color:"text.secondary",children:"GCS Credentials"}),Cy.map(F=>p.jsx(yr,{id:`ducklake_gcs_${F.name}`,name:`ducklake_gcs_${F.name}`,label:F.label,type:F.type,fullWidth:!0,size:"small",required:F.required&&F.name!=="secret",defaultValue:A(`gcs_${F.name}`),placeholder:F.name==="secret"&&l.has("ducklakeConnection.storage.gcsConnection.secret")?"Leave empty to keep existing":void 0},`gcs_${F.name}`))]})]})]}):i==="duckdb"?p.jsxs(Ta,{sx:{mt:2},children:[p.jsxs(Ta,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[p.jsx(Sr,{variant:"subtitle1",fontWeight:500,children:"Attached Databases"}),p.jsx(Xy,{label:"Database",icon:p.jsx(f1,{}),onClick:T,ariaLabel:"Add database"})]}),d.length===0&&p.jsx(Sr,{variant:"body2",color:"text.secondary",sx:{mb:2},children:'DuckDB connections require at least one attached database. Click "Add Database" to get started.'}),d.map((F,L)=>{const _=ex(F.dbType);return p.jsxs(Ta,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[p.jsxs(Ta,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[p.jsxs(Sr,{variant:"subtitle2",children:["Database ",L+1]}),p.jsx(Tu,{"aria-label":`Remove attached database ${L+1}`,onClick:()=>O(L),size:"small",color:"error",children:p.jsx(a6,{fontSize:"small"})})]}),p.jsx(yr,{required:!0,id:`attachedDb_${L}_name`,name:`attachedDb_${L}_name`,label:"Database Name",type:"text",fullWidth:!0,size:"small",defaultValue:F.name}),p.jsx(yr,{id:`attachedDb_${L}_type`,name:`attachedDb_${L}_type`,label:"Database Type",fullWidth:!0,size:"small",value:F.dbType,select:!0,onChange:R=>P(L,R.target.value),children:Object.values($4).map(R=>p.jsx(Vo,{value:R,children:R},R))}),_.filter(R=>R.visibleWhen?(F[R.visibleWhen.field]||D(L,R.visibleWhen.field)||_.find(z=>z.name===R.visibleWhen?.field)?.selectOptions?.[0]?.value)===R.visibleWhen.value:!0).map(R=>p.jsx(yr,{id:`attachedDb_${L}_${R.name}`,name:`attachedDb_${L}_${R.name}`,label:R.label,type:R.selectOptions?void 0:R.type,fullWidth:!0,size:"small",required:R.required,select:!!R.selectOptions,defaultValue:D(L,R.name)||R.selectOptions?.[0]?.value,onChange:R.selectOptions?z=>{const N=[...d];N[L]={...N[L],[R.name]:z.target.value},u(N)}:void 0,children:R.selectOptions?.map(z=>p.jsx(Vo,{value:z.value,children:z.label},z.value))},R.name))]},L)})]}):ac[i].map(F=>{const L=e?.[Og[i]??""]?.[F.name??""]??"",_=F.type==="password"||oI.has(F.name),R=l.has(`${Og[i]??""}.${F.name}`),z=F.selectOptions?L===""||L===void 0?F.selectOptions[0]?.value:String(L):void 0;return p.jsx(yr,{id:F.name,name:F.name,label:F.label,type:F.type,fullWidth:!0,size:"small",required:F.required&&!_&&!L,select:!!F.selectOptions,defaultValue:F.selectOptions?z:L,placeholder:R?"Leave empty to keep existing":void 0,helperText:_?R?"Stored value is not shown. Leave empty to keep it.":"No value stored.":void 0,children:F.selectOptions?.map(N=>p.jsx(Vo,{value:N.value,children:N.label},N.value))},F.name)})]})})})]})}function sI(e,t){return!e||e.type!=="duckdb"?!1:(e.duckdbConnection?.attachedDatabases||[]).some(n=>n.type==="azure"&&n.name===t)}function A1e(e){return e.startsWith("gs://")||e.startsWith("s3://")||e.startsWith("https://")||e.startsWith("abfss://")||e.startsWith("az://")}function D1e({connectionName:e,resourceUri:t,schema:n,connection:r}){const{apiClients:o}=tr(),{environmentName:a}=Xr(t),[i,s]=kn.useState(null),[l,d]=kn.useState(n||null),[u,m]=kn.useState(!1),{data:g,isError:y,isLoading:x,error:w}=co({queryKey:["schemas",a,e],queryFn:()=>o.connections.listSchemas(a,e)}),S=g?.data||[];return p.jsxs(Cp,{container:!0,spacing:1,children:[!n&&p.jsx(Cp,{size:{xs:12,md:4},children:p.jsxs(Qa,{sx:{p:1,m:0},children:[p.jsxs(Te,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:0},children:[p.jsx(wt,{variant:"overline",fontWeight:"bold",children:"Table Paths"}),p.jsx(MR,{control:p.jsx(Cz,{checked:u,onChange:b=>m(b.target.checked)}),label:"Hidden Schemas"})]}),p.jsx(wl,{sx:{mt:"2px"}}),p.jsxs(Te,{sx:{mt:"2px",maxHeight:"600px",overflowY:"auto"},children:[x&&p.jsx(Bo,{text:"Loading schemas..."}),y&&p.jsx(ja,{error:w,context:`${a} > ${e} > Schemas`}),!x&&!y&&S.length===0&&p.jsx(wt,{variant:"body2",children:"No Schemas"}),!x&&!y&&S.length>0&&p.jsx(AR,{dense:!0,disablePadding:!0,children:S.map(b=>{const $=b.name;return b.isHidden&&!u?null:p.jsx(mz,{selected:l===$,onClick:()=>{d($),s(null)},children:p.jsx(Ci,{primary:$})},$)})})]})]})}),p.jsx(Cp,{size:{xs:12,md:n?6:4},children:l&&p.jsx(Qa,{sx:{p:1,m:0},children:p.jsx(L1e,{connectionName:e,schemaName:l,onTableSelect:b=>{s(b)},resourceUri:t,connection:r})})}),p.jsx(Cp,{size:{xs:12,md:n?6:4},children:l&&i&&p.jsx(N1e,{environmentName:a,connectionName:e,schemaName:l,tableResource:i})})]})}function N1e({environmentName:e,connectionName:t,schemaName:n,tableResource:r}){const{apiClients:o}=tr(),{data:a,isLoading:i,isError:s,error:l}=co({queryKey:["connectionTableDetail",e,t,n,r],queryFn:()=>o.connections.getTable(e,t,n,r),enabled:!!n&&!!r}),d={resource:a?.data?.resource??r,columns:a?.data?.columns??[]};return p.jsxs(Qa,{sx:{p:1,m:0},children:[s&&p.jsx(ja,{error:l,context:`${e} > ${t} > ${n} > ${r}`}),!s&&p.jsx(I1e,{table:d,loading:i})]})}function I1e({table:e,loading:t}){return t?p.jsx(Bo,{text:"Loading columns..."}):p.jsxs(p.Fragment,{children:[p.jsxs(wt,{variant:"overline",fontWeight:"bold",sx:{display:"block",wordBreak:"break-all"},children:[e.resource.includes("://")||/\.(parquet|csv|json|tsv|ndjson)$/i.test(e.resource)?"File":"Table",": ",e.resource]}),p.jsx(wl,{}),p.jsx(Te,{sx:{mt:"10px",maxHeight:"600px",overflowY:"auto"},children:p.jsx(WJ,{children:p.jsxs(Bx,{size:"small",sx:{"& .MuiTableCell-root":{padding:"10px"}},children:[p.jsx(Hx,{children:p.jsxs(vu,{children:[p.jsx(dr,{children:"NAME"}),p.jsx(dr,{children:"TYPE"})]})}),p.jsx(qx,{children:e.columns?.sort((n,r)=>n.name.localeCompare(r.name))?.map(n=>p.jsxs(vu,{children:[p.jsx(dr,{children:n.name}),p.jsx(dr,{children:n.type})]},n.name))})]})})})]})}function L1e({connectionName:e,schemaName:t,onTableSelect:n,resourceUri:r,connection:o}){const{environmentName:a}=Xr(r),{apiClients:i}=tr(),[s,l]=C.useState(""),{data:d,isSuccess:u,isError:m,error:g,isLoading:y}=co({queryKey:["tablesInSchema",a,e,t],queryFn:()=>i.connections.listTables(a,e,t)}),x=sI(o,t),w=b=>x?b:b.split(".").pop()||b,S=u&&d?.data?d.data.filter(b=>w(b.resource).toLowerCase().includes(s.toLowerCase())).sort((b,$)=>w(b.resource).localeCompare(w($.resource))):[];return p.jsxs(p.Fragment,{children:[p.jsx(wt,{variant:"overline",fontWeight:"bold",children:A1e(t)||sI(o,t)?`Files in ${t}`:`Tables in ${t}`}),p.jsx(wl,{}),p.jsx(Te,{sx:{mt:1,mb:1},children:p.jsx(Ri,{size:"small",fullWidth:!0,placeholder:"Search tables...",value:s,onChange:b=>l(b.target.value),variant:"outlined"})}),p.jsx(wl,{}),p.jsxs(Te,{sx:{mt:"2px",maxHeight:"600px",overflowY:"auto"},children:[y&&p.jsx(Bo,{text:"Fetching Tables..."}),m&&p.jsx(ja,{error:g,context:`${a} > ${e} > ${t}`}),u&&S.length===0&&p.jsx(wt,{variant:"body2",children:"No Tables"}),u&&d?.data&&d.data.length>0&&p.jsx(AR,{dense:!0,disablePadding:!0,children:S.map(b=>{let $=w(b.resource);return!x&&b.resource.includes("://")&&($=b.resource.split("/").pop()||b.resource),p.jsx(mz,{onClick:()=>n(b.resource),children:p.jsx(Ci,{primary:$,secondary:b.columns.length>0?`${b.columns.length} columns`:void 0})},b.resource)})})]})]})}const z1e={bigquery:"BigQuery",snowflake:"Snowflake",postgres:"PostgreSQL",mysql:"MySQL",sqlserver:"SQL Server",trino:"Trino",databricks:"Databricks",duckdb:"DuckDB",ducklake:"DuckLake",s3:"S3",gcs:"GCS",azure:"Azure"};function F1e(e){return e?z1e[e]??e:""}function _1e({resourceUri:e}){const{apiClients:t,mutable:n}=tr(),r=Tl(),{environmentName:o}=Xr(e),[a,i]=C.useState(""),[s,l]=C.useState(null),d=I1({environmentName:o,connectionName:s}),{data:u,isSuccess:m,isError:g,error:y}=co({queryKey:["connections",o],queryFn:()=>t.connections.listConnections(o)}),x=hl({mutationFn:rc("connection","create",k=>t.environments.updateEnvironment(o,{name:o,connections:[...u.data,k]})),onSuccess(){i("Connection added successfully"),r.invalidateQueries({queryKey:["connections",o]})},onError(k){i(k.message)}}),w=hl({mutationFn:rc("connection","update",k=>t.environments.updateEnvironment(o,{name:o,connections:u.data.map(T=>T.name===k.name?k:T)})),onSuccess(k,T){i(`Connection ${T.name} updated successfully`),r.invalidateQueries({queryKey:["connections",o]})},onError(k){i(k.message)}}),S=hl({mutationFn:rc("connection","delete",k=>{if(!k.name)throw new Error("Cannot delete a connection with no name");return t.connections.deleteConnection(o,k.name)}),onSuccess(k,T){i(`Connection ${T.name} deleted successfully`),r.invalidateQueries({queryKey:["connections",o]})},onError(k){i(k.message)}}),b=m?[...u.data].sort((k,T)=>(k.name??"").localeCompare(T.name??"")):[],$=x.isPending||w.isPending||S.isPending;return p.jsxs(Ns,{title:"Connections",...m?{count:b.length}:{},description:"Database connections available to packages in this environment",...n&&m?{action:p.jsx(O1e,{onSubmit:k=>x.mutateAsync(k),isSubmitting:x.isPending})}:{},children:[!m&&!g&&p.jsx(wt,{variant:"body2",color:"text.secondary",children:"Fetching Connections..."}),g&&p.jsx(ja,{error:y,context:`${o} > Connections`}),m&&b.length===0&&p.jsx(wt,{variant:"body2",color:"text.secondary",children:"No connections yet."}),m&&b.length>0&&p.jsx(Yn,{children:b.map(k=>p.jsx(B1e,{connection:k,mutable:n,isMutating:$,onOpenExplorer:()=>l(k.name??null),onEdit:T=>w.mutateAsync(T),onDelete:T=>S.mutateAsync(T)},k.name))}),p.jsx(hh,{open:a!=="",autoHideDuration:6e3,onClose:()=>i(""),message:a}),p.jsx(Oo,{open:s!==null,onClose:()=>l(null),maxWidth:"lg",title:`Connection explorer: ${s??""}`,showClose:!0,children:s&&p.jsx(D1e,{resourceUri:d,connectionName:s,connection:u?.data?.find(k=>k.name===s)})})]})}function B1e({connection:e,mutable:t,isMutating:n,onOpenExplorer:r,onEdit:o,onDelete:a}){const[i,s]=C.useState(null),l=!!i,d=m=>{m.stopPropagation(),s(m.currentTarget)},u=()=>s(null);return p.jsx(L1,{icon:p.jsx(h1e,{sx:{fontSize:18}}),tint:ZR.connection,label:e.name??"",ariaLabel:e.name??"",description:F1e(e.type),onClick:r,...t?{trailingAction:p.jsxs(p.Fragment,{children:[p.jsx(ro,{size:"small",onClick:d,"aria-label":`Connection actions for ${e.name??""}`.trim(),children:p.jsx(Jx,{fontSize:"small"})}),p.jsxs(uc,{anchorEl:i,open:l,onClose:u,onClick:m=>m.stopPropagation(),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[p.jsx(j1e,{connection:e,onSubmit:o,isSubmitting:n,onCloseDialog:u}),p.jsx(P1e,{connection:e,onCloseDialog:u,isMutating:n,onDelete:()=>a(e)})]})]})}:{}})}const U1e=Jt([p.jsx("path",{d:"M20 2H4c-1 0-2 .9-2 2v3.01c0 .72.43 1.34 1 1.69V20c0 1.1 1.1 2 2 2h14c.9 0 2-.9 2-2V8.7c.57-.35 1-.97 1-1.69V4c0-1.1-1-2-2-2m-1 18H5V9h14zm1-13H4V4h16z"},"0"),p.jsx("path",{d:"M9 12h6v2H9z"},"1")]);function q1e({resourceUri:e,onCloseDialog:t}){const[n,r]=C.useState(!1),{apiClients:o}=tr(),a=()=>{r(!0)},i=()=>{r(!1),t()},{environmentName:s,packageName:l}=Xr(e),d=Ch({mutationFn:()=>o.packages.deletePackage(s,l),success:"Package deleted",invalidates:[["packages",s]],closeDialog:i,resource:"package",action:"delete"});return p.jsxs(kn.Fragment,{children:[p.jsxs(ea,{onClick:a,children:[p.jsx(ml,{children:p.jsx(Zx,{fontSize:"small"})}),p.jsx(Ci,{children:"Delete"})]}),p.jsx(Oo,{open:n,onClose:i,title:"Delete package",actions:p.jsxs(p.Fragment,{children:[p.jsx(Co,{onClick:i,children:"Cancel"}),p.jsx(Co,{variant:"contained",color:"error",autoFocus:!0,onClick:()=>d.mutate(),loading:d.isPending,children:"Delete package"})]}),children:p.jsxs(Sr,{variant:"body2",children:["Delete ",p.jsx("strong",{children:l}),"? The package stops being served and this cannot be undone."]})}),d.notice]})}function H1e({package:e,resourceUri:t,onCloseDialog:n}){const[r,o]=C.useState(!1),{apiClients:a}=tr(),i=()=>{o(!0)},s=()=>{o(!1),n()},{packageName:l,environmentName:d}=Xr(t),u=Ch({mutationFn(g){return a.packages.updatePackage(d,l,{name:l,description:g.description})},success:"Package updated",invalidates:[["packages",d]],closeDialog:s,resource:"package",action:"update"}),m=g=>{g.preventDefault();const y=new FormData(g.currentTarget).get("description")?.toString();u.mutate({description:y})};return p.jsxs(kn.Fragment,{children:[p.jsxs(ea,{onClick:i,children:[p.jsx(ml,{children:p.jsx(r2,{fontSize:"small"})}),p.jsx(Ci,{children:"Edit"})]}),p.jsx(Oo,{open:r,onClose:s,title:"Edit package",description:`What ${e.name} is, for the people who open it.`,actions:p.jsxs(p.Fragment,{children:[p.jsx(Co,{disabled:u.isPending,onClick:s,children:"Cancel"}),p.jsx(Co,{type:"submit",form:"package-form",variant:"contained",loading:u.isPending,children:"Save changes"})]}),children:p.jsx("form",{onSubmit:m,id:"package-form",children:p.jsxs(Yn,{sx:{gap:2},children:[p.jsx(yr,{autoFocus:!0,required:!0,id:"name",name:"name",label:"Name",disabled:!0,type:"text",fullWidth:!0,size:"small",defaultValue:e.name,InputLabelProps:{shrink:!0}}),p.jsx(yr,{id:"description",name:"description",label:"Description",multiline:!0,fullWidth:!0,rows:4,size:"small",defaultValue:e.description,InputLabelProps:{shrink:!0}})]})})}),u.notice]})}function V1e({onSelectPackage:e,resourceUri:t}){const{apiClients:n}=tr(),{environmentName:r}=Xr(t),{data:o,isSuccess:a,isError:i,error:s}=co({queryKey:["packages",r],queryFn:()=>n.packages.listPackages(r)});if(i)return p.jsx(ja,{error:s,context:`${r} > Packages`});if(!a)return p.jsx(Bo,{text:"Fetching Packages..."});const l=[...o.data].sort((d,u)=>d.name.localeCompare(u.name));return p.jsx(Yn,{children:l.map(d=>{const u=I1({environmentName:r,packageName:d.name});return p.jsx(W1e,{pkg:d,packageResourceUri:u,onSelectPackage:e},d.name)})})}function W1e({pkg:e,packageResourceUri:t,onSelectPackage:n}){const{mutable:r}=tr(),o=e.versionId!==void 0||e.latestVersion!==void 0,[a,i]=C.useState(null),s=!!a,l=u=>{u.stopPropagation(),i(u.currentTarget)},d=()=>i(null);return p.jsx(L1,{icon:p.jsx(U1e,{sx:{fontSize:18}}),tint:ZR.package,label:e.name,ariaLabel:e.name,...e.description?{description:e.description}:{},onClick:u=>n(e.name,u),...r?{trailingAction:p.jsxs(p.Fragment,{children:[p.jsx(ro,{size:"small",onClick:l,"aria-label":`Package actions for ${e.name}`,children:p.jsx(Jx,{fontSize:"small"})}),p.jsxs(uc,{anchorEl:a,open:s,onClose:d,onClick:u=>u.stopPropagation(),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[!o&&p.jsx(H1e,{package:e,resourceUri:t,onCloseDialog:d}),p.jsx(q1e,{resourceUri:t,onCloseDialog:d})]})]})}:{}})}function WTe({onSelectPackage:e,resourceUri:t}){const{apiClients:n,mutable:r}=tr(),{environmentName:o}=Xr(t),a=co({queryKey:["packages",o],queryFn:()=>n.packages.listPackages(o)});return C.useEffect(()=>{window.scrollTo({top:0,behavior:"auto"})},[]),p.jsxs(O0,{maxWidth:!1,sx:{maxWidth:1024,mx:"auto",px:3,py:6},children:[p.jsxs(Te,{sx:{mb:4},children:[p.jsx(wt,{variant:"h4",component:"h1",sx:{fontWeight:600,letterSpacing:"-0.025em",mb:.5},children:o}),p.jsx(wt,{variant:"body2",color:"text.secondary",children:"Manage packages and database connections in this environment. Open a package to explore its models and notebooks."})]}),p.jsx(Ns,{title:"Packages",...a.isSuccess?{count:a.data.data.length}:{},description:"Published packages available for use in this environment",...r?{action:p.jsx(p1e,{resourceUri:t})}:{},children:p.jsx(V1e,{onSelectPackage:e,resourceUri:t})}),p.jsx(_1e,{resourceUri:t}),p.jsx(Zxe,{resourceUri:t})]})}function lI({array1:e,array2:t,parser:n=r=>r}){return e&&t&&e.length===t.length&&e.every((r,o)=>n(r)===n(t[o]))}function cI(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"")}function Y1e(e={}){const{ignoreAccents:t=!0,ignoreCase:n=!0,limit:r,matchFrom:o="any",stringify:a,trim:i=!1}=e;return(s,{inputValue:l,getOptionLabel:d})=>{let u=i?l.trim():l;n&&(u=u.toLowerCase()),t&&(u=cI(u));const m=u?s.filter(g=>{let y=(a||d)(g);return n&&(y=y.toLowerCase()),t&&(y=cI(y)),o==="start"?y.startsWith(u):y.includes(u)}):s;return typeof r=="number"?m.slice(0,r):m}}const G1e=Y1e(),uI=5,K1e=e=>e.current!==null&&e.current.parentElement?.contains(document.activeElement),Q1e=[];function dI(e,t,n,r){if(t||e==null||r)return"";const o=n(e);return typeof o=="string"?o:""}function X1e(e){const{unstable_isActiveElementInListbox:t=K1e,unstable_classNamePrefix:n="Mui",autoComplete:r=!1,autoHighlight:o=!1,autoSelect:a=!1,blurOnSelect:i=!1,clearOnBlur:s=!e.freeSolo,clearOnEscape:l=!1,componentName:d="useAutocomplete",defaultValue:u=e.multiple?Q1e:null,disableClearable:m=!1,disableCloseOnSelect:g=!1,disabled:y,disabledItemsFocusable:x=!1,disableListWrap:w=!1,filterOptions:S=G1e,filterSelectedOptions:b=!1,freeSolo:$=!1,getOptionDisabled:k,getOptionKey:T,getOptionLabel:O=ge=>ge.label??ge,groupBy:P,handleHomeEndKeys:D=!e.freeSolo,id:A,includeInputInList:F=!1,inputValue:L,isOptionEqualToValue:_=(ge,ye)=>ge===ye,multiple:R=!1,onChange:z,onClose:N,onHighlightChange:B,onInputChange:I,onOpen:H,open:Y,openOnFocus:ae=!1,options:K,readOnly:oe=!1,renderValue:ue,selectOnFocus:G=!e.freeSolo,value:ie}=e,Q=_s(A);let ee=O;ee=ge=>{const ye=O(ge);return typeof ye!="string"?String(ye):ye};const Z=C.useRef(!1),de=C.useRef(!0),le=C.useRef(null),fe=C.useRef(null),[he,me]=C.useState(null),[se,ve]=C.useState(-1),Le=o?0:-1,Ae=C.useRef(Le),Re=C.useRef(dI(u??ie,R,ee)).current,[re,_e]=Ti({controlled:ie,default:u,name:d}),[Me,Ge]=Ti({controlled:L,default:Re,name:d,state:"inputValue"}),[Je,St]=C.useState(!1),Ut=C.useCallback((ge,ye,Ue)=>{if(!(R?re.length<ye.length:ye!==null)&&!s)return;const gt=dI(ye,R,ee,ue);Me!==gt&&(Ge(gt),I&&I(ge,gt,Ue))},[ee,Me,R,I,Ge,s,re,ue]),[at,tt]=Ti({controlled:Y,default:!1,name:d,state:"open"}),[pt,ze]=C.useState(!0),be=!R&&re!=null&&Me===ee(re),Ve=at&&!oe,Oe=Ve?S(K.filter(ge=>!(b&&(R?re:[re]).some(ye=>ye!==null&&_(ge,ye)))),{inputValue:be&&pt?"":Me,getOptionLabel:ee}):[],$t=Pxe({filteredOptions:Oe,value:re,inputValue:Me});C.useEffect(()=>{const ge=re!==$t.value;Je&&!ge||$&&!ge||Ut(null,re,"reset")},[re,Ut,Je,$t.value,$]);const Rt=at&&Oe.length>0&&!oe,vt=Yt(ge=>{if(ge===-1)le.current.focus();else{const ye=ue?"data-item-index":"data-tag-index";he.querySelector(`[${ye}="${ge}"]`).focus()}});C.useEffect(()=>{R&&se>re.length-1&&(ve(-1),vt(-1))},[re,R,se,vt]);function it(ge,ye){if(!fe.current||ge<0||ge>=Oe.length)return-1;let Ue=ge;for(;;){const gt=fe.current.querySelector(`[data-option-index="${Ue}"]`),We=x?!1:!gt||gt.disabled||gt.getAttribute("aria-disabled")==="true";if(gt&>.hasAttribute("tabindex")&&!We)return Ue;if(ye==="next"?Ue=(Ue+1)%Oe.length:Ue=(Ue-1+Oe.length)%Oe.length,Ue===ge)return-1}}const st=Yt(({event:ge,index:ye,reason:Ue})=>{if(Ae.current=ye,ye===-1?le.current.removeAttribute("aria-activedescendant"):le.current.setAttribute("aria-activedescendant",`${Q}-option-${ye}`),B&&["mouse","keyboard","touch"].includes(Ue)&&B(ge,ye===-1?null:Oe[ye],Ue),!fe.current)return;const gt=fe.current.querySelector(`[role="option"].${n}-focused`);gt&&(gt.classList.remove(`${n}-focused`),gt.classList.remove(`${n}-focusVisible`));let We=fe.current;if(fe.current.getAttribute("role")!=="listbox"&&(We=fe.current.parentElement.querySelector('[role="listbox"]')),!We)return;if(ye===-1){We.scrollTop=0;return}const Nt=fe.current.querySelector(`[data-option-index="${ye}"]`);if(Nt&&(Nt.classList.add(`${n}-focused`),Ue==="keyboard"&&Nt.classList.add(`${n}-focusVisible`),We.scrollHeight>We.clientHeight&&Ue!=="mouse"&&Ue!=="touch")){const Kt=Nt,hn=We.clientHeight+We.scrollTop,we=Kt.offsetTop+Kt.offsetHeight;we>hn?We.scrollTop=we-We.clientHeight:Kt.offsetTop-Kt.offsetHeight*(P?1.3:0)<We.scrollTop&&(We.scrollTop=Kt.offsetTop-Kt.offsetHeight*(P?1.3:0))}}),Dt=Yt(({event:ge,diff:ye,direction:Ue="next",reason:gt})=>{if(!Ve)return;const We=it((()=>{const Nt=Oe.length-1;if(ye==="reset")return Le;if(ye==="start")return 0;if(ye==="end")return Nt;const Kt=Ae.current+ye;return Kt<0?Kt===-1&&F?-1:w&&Ae.current!==-1||Math.abs(ye)>1?0:Nt:Kt>Nt?Kt===Nt+1&&F?-1:w||Math.abs(ye)>1?Nt:0:Kt})(),Ue);if(st({index:We,reason:gt,event:ge}),r&&ye!=="reset")if(We===-1)le.current.value=Me;else{const Nt=ee(Oe[We]);le.current.value=Nt,Nt.toLowerCase().indexOf(Me.toLowerCase())===0&&Me.length>0&&le.current.setSelectionRange(Me.length,Nt.length)}}),nn=!lI({array1:$t.filteredOptions,array2:Oe,parser:ee}),Bt=()=>{const ge=(ye,Ue)=>{const gt=ye?ee(ye):"",We=Ue?ee(Ue):"";return gt===We};if(Ae.current!==-1&&!lI({array1:$t.filteredOptions,array2:Oe,parser:ee})&&$t.inputValue===Me&&(R?re.length===$t.value.length&&$t.value.every((ye,Ue)=>ee(re[Ue])===ee(ye)):ge($t.value,re))){const ye=$t.filteredOptions[Ae.current];if(ye)return Oe.findIndex(Ue=>ee(Ue)===ee(ye))}return-1},pn=C.useCallback(()=>{if(!Ve)return;const ge=Bt();if(ge!==-1){Ae.current=ge;return}const ye=R?re[0]:re;if(Oe.length===0||ye==null){Dt({diff:"reset"});return}if(fe.current){if(ye!=null){const Ue=Oe[Ae.current];if(R&&Ue&&re.findIndex(We=>_(Ue,We))!==-1)return;const gt=Oe.findIndex(We=>_(We,ye));gt===-1?Dt({diff:"reset"}):st({index:gt});return}if(Ae.current>=Oe.length-1){st({index:Oe.length-1});return}st({index:Ae.current})}},[Oe.length,R?!1:re,b,Dt,st,Ve,Me,R]),$n=Yt(ge=>{Vk(fe,ge),ge&&pn()});C.useEffect(()=>{nn&&pn()},[pn,nn]);const qt=ge=>{at||(tt(!0),ze(!0),H&&H(ge))},Pn=(ge,ye)=>{at&&(tt(!1),N&&N(ge,ye))},Se=(ge,ye,Ue,gt)=>{if(R){if(re.length===ye.length&&re.every((We,Nt)=>We===ye[Nt]))return}else if(re===ye)return;z&&z(ge,ye,Ue,gt),_e(ye)},jn=C.useRef(!1),Rn=(ge,ye,Ue="selectOption",gt="options")=>{let We=Ue,Nt=ye;if(R){Nt=Array.isArray(re)?re.slice():[];const Kt=Nt.findIndex(hn=>_(ye,hn));Kt===-1?Nt.push(ye):gt!=="freeSolo"&&(Nt.splice(Kt,1),We="removeOption")}Ut(ge,Nt,We),Se(ge,Nt,We,{option:ye}),!g&&(!ge||!ge.ctrlKey&&!ge.metaKey)&&Pn(ge,We),(i===!0||i==="touch"&&jn.current||i==="mouse"&&!jn.current)&&le.current.blur()};function en(ge,ye){if(ge===-1)return-1;let Ue=ge;for(;;){if(ye==="next"&&Ue===re.length||ye==="previous"&&Ue===-1)return-1;const gt=ue?"data-item-index":"data-tag-index",We=he.querySelector(`[${gt}="${Ue}"]`);if(!We||!We.hasAttribute("tabindex")||We.disabled||We.getAttribute("aria-disabled")==="true")Ue+=ye==="next"?1:-1;else return Ue}}const jt=(ge,ye)=>{if(!R)return;Me===""&&Pn(ge,"toggleInput");let Ue=se;se===-1?Me===""&&ye==="previous"&&(Ue=re.length-1):(Ue+=ye==="next"?1:-1,Ue<0&&(Ue=0),Ue===re.length&&(Ue=-1)),Ue=en(Ue,ye),ve(Ue),vt(Ue)},Ur=ge=>{Z.current=!0,Ge(""),I&&I(ge,"","clear"),Se(ge,R?[]:null,"clear")},qn=ge=>ye=>{if(ge.onKeyDown&&ge.onKeyDown(ye),!ye.defaultMuiPrevented&&(se!==-1&&!["ArrowLeft","ArrowRight"].includes(ye.key)&&(ve(-1),vt(-1)),ye.which!==229))switch(ye.key){case"Home":Ve&&D&&(ye.preventDefault(),Dt({diff:"start",direction:"next",reason:"keyboard",event:ye}));break;case"End":Ve&&D&&(ye.preventDefault(),Dt({diff:"end",direction:"previous",reason:"keyboard",event:ye}));break;case"PageUp":ye.preventDefault(),Dt({diff:-uI,direction:"previous",reason:"keyboard",event:ye}),qt(ye);break;case"PageDown":ye.preventDefault(),Dt({diff:uI,direction:"next",reason:"keyboard",event:ye}),qt(ye);break;case"ArrowDown":ye.preventDefault(),Dt({diff:1,direction:"next",reason:"keyboard",event:ye}),qt(ye);break;case"ArrowUp":ye.preventDefault(),Dt({diff:-1,direction:"previous",reason:"keyboard",event:ye}),qt(ye);break;case"ArrowLeft":!R&&ue?vt(0):jt(ye,"previous");break;case"ArrowRight":!R&&ue?vt(-1):jt(ye,"next");break;case"Enter":if(Ae.current!==-1&&Ve){const Ue=Oe[Ae.current],gt=k?k(Ue):!1;if(ye.preventDefault(),gt)return;Rn(ye,Ue,"selectOption"),r&&le.current.setSelectionRange(le.current.value.length,le.current.value.length)}else $&&Me!==""&&be===!1&&(R&&ye.preventDefault(),Rn(ye,Me,"createOption","freeSolo"));break;case"Escape":Ve?(ye.preventDefault(),ye.stopPropagation(),Pn(ye,"escape")):l&&(Me!==""||R&&re.length>0||ue)&&(ye.preventDefault(),ye.stopPropagation(),Ur(ye));break;case"Backspace":if(R&&!oe&&Me===""&&re.length>0){const Ue=se===-1?re.length-1:se,gt=re.slice();gt.splice(Ue,1),Se(ye,gt,"removeOption",{option:re[Ue]})}!R&&ue&&!oe&&(_e(null),vt(-1));break;case"Delete":if(R&&!oe&&Me===""&&re.length>0&&se!==-1){const Ue=se,gt=re.slice();gt.splice(Ue,1),Se(ye,gt,"removeOption",{option:re[Ue]})}!R&&ue&&!oe&&(_e(null),vt(-1));break}},mn=ge=>{St(!0),ae&&!Z.current&&qt(ge)},Bn=ge=>{if(t(fe)){le.current.focus();return}St(!1),de.current=!0,Z.current=!1,a&&Ae.current!==-1&&Ve?Rn(ge,Oe[Ae.current],"blur"):a&&$&&Me!==""?Rn(ge,Me,"blur","freeSolo"):s&&Ut(ge,re,"blur"),Pn(ge,"blur")},xe=ge=>{const ye=ge.target.value;Me!==ye&&(Ge(ye),ze(!1),I&&I(ge,ye,"input")),ye===""?!m&&!R&&Se(ge,null,"clear"):qt(ge)},Ee=ge=>{const ye=Number(ge.currentTarget.getAttribute("data-option-index"));Ae.current!==ye&&st({event:ge,index:ye,reason:"mouse"})},Be=ge=>{st({event:ge,index:Number(ge.currentTarget.getAttribute("data-option-index")),reason:"touch"}),jn.current=!0},Ye=ge=>{const ye=Number(ge.currentTarget.getAttribute("data-option-index"));Rn(ge,Oe[ye],"selectOption"),jn.current=!1},ut=ge=>ye=>{const Ue=re.slice();Ue.splice(ge,1),Se(ye,Ue,"removeOption",{option:re[ge]})},Et=ge=>{Se(ge,null,"removeOption",{option:re})},Ct=ge=>{at?Pn(ge,"toggleInput"):qt(ge)},Mt=ge=>{ge.currentTarget.contains(ge.target)&&ge.target.getAttribute("id")!==Q&&ge.preventDefault()},Lt=ge=>{ge.currentTarget.contains(ge.target)&&(le.current.focus(),G&&de.current&&le.current.selectionEnd-le.current.selectionStart===0&&le.current.select(),de.current=!1)},Xt=ge=>{!y&&(Me===""||!at)&&Ct(ge)};let zt=$&&Me.length>0;zt=zt||(R?re.length>0:re!==null);let Vt=Oe;return P&&(Vt=Oe.reduce((ge,ye,Ue)=>{const gt=P(ye);return ge.length>0&&ge[ge.length-1].group===gt?ge[ge.length-1].options.push(ye):ge.push({key:Ue,index:Ue,group:gt,options:[ye]}),ge},[])),y&&Je&&Bn(),{getRootProps:(ge={})=>({...ge,onKeyDown:qn(ge),onMouseDown:Mt,onClick:Lt}),getInputLabelProps:()=>({id:`${Q}-label`,htmlFor:Q}),getInputProps:()=>({id:Q,value:Me,onBlur:Bn,onFocus:mn,onChange:xe,onMouseDown:Xt,"aria-activedescendant":Ve?"":null,"aria-autocomplete":r?"both":"list","aria-controls":Rt?`${Q}-listbox`:void 0,"aria-expanded":Rt,autoComplete:"off",ref:le,autoCapitalize:"none",spellCheck:"false",role:"combobox",disabled:y}),getClearProps:()=>({tabIndex:-1,type:"button",onClick:Ur}),getItemProps:({index:ge=0}={})=>({...R&&{key:ge},...ue?{"data-item-index":ge}:{"data-tag-index":ge},tabIndex:-1,...!oe&&{onDelete:R?ut(ge):Et}}),getPopupIndicatorProps:()=>({tabIndex:-1,type:"button",onClick:Ct}),getTagProps:({index:ge})=>({key:ge,"data-tag-index":ge,tabIndex:-1,...!oe&&{onDelete:ut(ge)}}),getListboxProps:()=>({role:"listbox",id:`${Q}-listbox`,"aria-labelledby":`${Q}-label`,ref:$n,onMouseDown:ge=>{ge.preventDefault()}}),getOptionProps:({index:ge,option:ye})=>{const Ue=(R?re:[re]).some(We=>We!=null&&_(ye,We)),gt=k?k(ye):!1;return{key:T?.(ye)??ee(ye),tabIndex:-1,role:"option",id:`${Q}-option-${ge}`,onMouseMove:Ee,onClick:Ye,onTouchStart:Be,"data-option-index":ge,"aria-disabled":gt,"aria-selected":Ue}},id:Q,inputValue:Me,value:re,dirty:zt,expanded:Ve&&he,popupOpen:Ve,focused:Je||se!==-1,anchorEl:he,setAnchorEl:me,focusedItem:se,focusedTag:se,groupedOptions:Vt}}function Z1e(e){return Cn("MuiListSubheader",e)}fn("MuiListSubheader",["root","colorPrimary","colorInherit","gutters","inset","sticky"]);const J1e=e=>{const{classes:t,color:n,disableGutters:r,inset:o,disableSticky:a}=e,i={root:["root",n!=="default"&&`color${Tt(n)}`,!r&&"gutters",o&&"inset",!a&&"sticky"]};return bn(i,Z1e,t)},ewe=nt("li",{name:"MuiListSubheader",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.root,n.color!=="default"&&t[`color${Tt(n.color)}`],!n.disableGutters&&t.gutters,n.inset&&t.inset,!n.disableSticky&&t.sticky]}})(Gn(({theme:e})=>({boxSizing:"border-box",lineHeight:"48px",listStyle:"none",color:(e.vars||e).palette.text.secondary,fontFamily:e.typography.fontFamily,fontWeight:e.typography.fontWeightMedium,fontSize:e.typography.pxToRem(14),variants:[{props:{color:"primary"},style:{color:(e.vars||e).palette.primary.main}},{props:{color:"inherit"},style:{color:"inherit"}},{props:({ownerState:t})=>!t.disableGutters,style:{paddingLeft:16,paddingRight:16}},{props:({ownerState:t})=>t.inset,style:{paddingLeft:72}},{props:({ownerState:t})=>!t.disableSticky,style:{position:"sticky",top:0,zIndex:1,backgroundColor:(e.vars||e).palette.background.paper}}]}))),k$=C.forwardRef(function(e,t){const n=Kn({props:e,name:"MuiListSubheader"}),{className:r,color:o="default",component:a="li",disableGutters:i=!1,disableSticky:s=!1,inset:l=!1,...d}=n,u={...n,color:o,component:a,disableGutters:i,disableSticky:s,inset:l},m=J1e(u);return p.jsx(ewe,{as:a,className:Ht(m.root,r),ref:t,ownerState:u,...d})});k$&&(k$.muiSkipListHighlight=!0);const twe=Jt(p.jsx("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"}));function nwe(e){return Cn("MuiAutocomplete",e)}const Jn=fn("MuiAutocomplete",["root","expanded","fullWidth","focused","focusVisible","tag","tagSizeSmall","tagSizeMedium","hasPopupIcon","hasClearIcon","inputRoot","input","inputFocused","endAdornment","clearIndicator","popupIndicator","popupIndicatorOpen","popper","popperDisablePortal","paper","listbox","loading","noOptions","option","groupLabel","groupUl"]);var fI,pI;const rwe=e=>{const{classes:t,disablePortal:n,expanded:r,focused:o,fullWidth:a,hasClearIcon:i,hasPopupIcon:s,inputFocused:l,popupOpen:d,size:u}=e,m={root:["root",r&&"expanded",o&&"focused",a&&"fullWidth",i&&"hasClearIcon",s&&"hasPopupIcon"],inputRoot:["inputRoot"],input:["input",l&&"inputFocused"],tag:["tag",`tagSize${Tt(u)}`],endAdornment:["endAdornment"],clearIndicator:["clearIndicator"],popupIndicator:["popupIndicator",d&&"popupIndicatorOpen"],popper:["popper",n&&"popperDisablePortal"],paper:["paper"],listbox:["listbox"],loading:["loading"],noOptions:["noOptions"],option:["option"],groupLabel:["groupLabel"],groupUl:["groupUl"]};return bn(m,nwe,t)},owe=nt("div",{name:"MuiAutocomplete",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:n}=e,{fullWidth:r,hasClearIcon:o,hasPopupIcon:a,inputFocused:i,size:s}=n;return[{[`& .${Jn.tag}`]:t.tag},{[`& .${Jn.tag}`]:t[`tagSize${Tt(s)}`]},{[`& .${Jn.inputRoot}`]:t.inputRoot},{[`& .${Jn.input}`]:t.input},{[`& .${Jn.input}`]:i&&t.inputFocused},t.root,r&&t.fullWidth,a&&t.hasPopupIcon,o&&t.hasClearIcon]}})({[`&.${Jn.focused} .${Jn.clearIndicator}`]:{visibility:"visible"},"@media (pointer: fine)":{[`&:hover .${Jn.clearIndicator}`]:{visibility:"visible"}},[`& .${Jn.tag}`]:{margin:3,maxWidth:"calc(100% - 6px)"},[`& .${Jn.inputRoot}`]:{[`.${Jn.hasPopupIcon}&, .${Jn.hasClearIcon}&`]:{paddingRight:30},[`.${Jn.hasPopupIcon}.${Jn.hasClearIcon}&`]:{paddingRight:56},[`& .${Jn.input}`]:{width:0,minWidth:30}},[`& .${au.root}`]:{paddingBottom:1,"& .MuiInput-input":{padding:"4px 4px 4px 0px"}},[`& .${au.root}.${bi.sizeSmall}`]:{[`& .${au.input}`]:{padding:"2px 4px 3px 0"}},[`& .${Wi.root}`]:{padding:9,[`.${Jn.hasPopupIcon}&, .${Jn.hasClearIcon}&`]:{paddingRight:39},[`.${Jn.hasPopupIcon}.${Jn.hasClearIcon}&`]:{paddingRight:65},[`& .${Jn.input}`]:{padding:"7.5px 4px 7.5px 5px"},[`& .${Jn.endAdornment}`]:{right:9}},[`& .${Wi.root}.${bi.sizeSmall}`]:{paddingTop:6,paddingBottom:6,paddingLeft:6,[`& .${Jn.input}`]:{padding:"2.5px 4px 2.5px 8px"}},[`& .${xi.root}`]:{paddingTop:19,paddingLeft:8,[`.${Jn.hasPopupIcon}&, .${Jn.hasClearIcon}&`]:{paddingRight:39},[`.${Jn.hasPopupIcon}.${Jn.hasClearIcon}&`]:{paddingRight:65},[`& .${xi.input}`]:{padding:"7px 4px"},[`& .${Jn.endAdornment}`]:{right:9}},[`& .${xi.root}.${bi.sizeSmall}`]:{paddingBottom:1,[`& .${xi.input}`]:{padding:"2.5px 4px"}},[`& .${bi.hiddenLabel}`]:{paddingTop:8},[`& .${xi.root}.${bi.hiddenLabel}`]:{paddingTop:0,paddingBottom:0,[`& .${Jn.input}`]:{paddingTop:16,paddingBottom:17}},[`& .${xi.root}.${bi.hiddenLabel}.${bi.sizeSmall}`]:{[`& .${Jn.input}`]:{paddingTop:8,paddingBottom:9}},[`& .${Jn.input}`]:{flexGrow:1,textOverflow:"ellipsis",opacity:0},variants:[{props:{fullWidth:!0},style:{width:"100%"}},{props:{size:"small"},style:{[`& .${Jn.tag}`]:{margin:2,maxWidth:"calc(100% - 4px)"}}},{props:{inputFocused:!0},style:{[`& .${Jn.input}`]:{opacity:1}}},{props:{multiple:!0},style:{[`& .${Jn.inputRoot}`]:{flexWrap:"wrap"}}}]}),awe=nt("div",{name:"MuiAutocomplete",slot:"EndAdornment"})({position:"absolute",right:0,top:"50%",transform:"translate(0, -50%)"}),iwe=nt(Tu,{name:"MuiAutocomplete",slot:"ClearIndicator"})({marginRight:-2,padding:4,visibility:"hidden"}),swe=nt(Tu,{name:"MuiAutocomplete",slot:"PopupIndicator",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.popupIndicator,n.popupOpen&&t.popupIndicatorOpen]}})({padding:2,marginRight:-2,variants:[{props:{popupOpen:!0},style:{transform:"rotate(180deg)"}}]}),lwe=nt(L2,{name:"MuiAutocomplete",slot:"Popper",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[{[`& .${Jn.option}`]:t.option},t.popper,n.disablePortal&&t.popperDisablePortal]}})(Gn(({theme:e})=>({zIndex:(e.vars||e).zIndex.modal,variants:[{props:{disablePortal:!0},style:{position:"absolute"}}]}))),cwe=nt(tf,{name:"MuiAutocomplete",slot:"Paper"})(Gn(({theme:e})=>({...e.typography.body1,overflow:"auto"}))),uwe=nt("div",{name:"MuiAutocomplete",slot:"Loading"})(Gn(({theme:e})=>({color:(e.vars||e).palette.text.secondary,padding:"14px 16px"}))),dwe=nt("div",{name:"MuiAutocomplete",slot:"NoOptions"})(Gn(({theme:e})=>({color:(e.vars||e).palette.text.secondary,padding:"14px 16px"}))),fwe=nt("ul",{name:"MuiAutocomplete",slot:"Listbox"})(Gn(({theme:e})=>({listStyle:"none",margin:0,padding:"8px 0",maxHeight:"40vh",overflow:"auto",position:"relative",[`& .${Jn.option}`]:{minHeight:48,display:"flex",overflow:"hidden",justifyContent:"flex-start",alignItems:"center",cursor:"pointer",paddingTop:6,boxSizing:"border-box",outline:"0",WebkitTapHighlightColor:"transparent",paddingBottom:6,paddingLeft:16,paddingRight:16,[e.breakpoints.up("sm")]:{minHeight:"auto"},[`&.${Jn.focused}`]:{backgroundColor:(e.vars||e).palette.action.hover,"@media (hover: none)":{backgroundColor:"transparent"}},'&[aria-disabled="true"]':{opacity:(e.vars||e).palette.action.disabledOpacity,pointerEvents:"none"},[`&.${Jn.focusVisible}`]:{backgroundColor:(e.vars||e).palette.action.focus},'&[aria-selected="true"]':{backgroundColor:e.alpha((e.vars||e).palette.primary.main,(e.vars||e).palette.action.selectedOpacity),[`&.${Jn.focused}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.hoverOpacity}`),"@media (hover: none)":{backgroundColor:(e.vars||e).palette.action.selected}},[`&.${Jn.focusVisible}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.focusOpacity}`)}}}}))),pwe=nt(k$,{name:"MuiAutocomplete",slot:"GroupLabel"})(Gn(({theme:e})=>({backgroundColor:(e.vars||e).palette.background.paper,top:-8}))),hwe=nt("ul",{name:"MuiAutocomplete",slot:"GroupUl"})({padding:0,[`& .${Jn.option}`]:{paddingLeft:24}}),mwe=C.forwardRef(function(e,t){const n=Kn({props:e,name:"MuiAutocomplete"}),{autoComplete:r=!1,autoHighlight:o=!1,autoSelect:a=!1,blurOnSelect:i=!1,ChipProps:s,className:l,clearIcon:d=fI||(fI=p.jsx(twe,{fontSize:"small"})),clearOnBlur:u=!n.freeSolo,clearOnEscape:m=!1,clearText:g="Clear",closeText:y="Close",componentsProps:x,defaultValue:w=n.multiple?[]:null,disableClearable:S=!1,disableCloseOnSelect:b=!1,disabled:$=!1,disabledItemsFocusable:k=!1,disableListWrap:T=!1,disablePortal:O=!1,filterOptions:P,filterSelectedOptions:D=!1,forcePopupIcon:A="auto",freeSolo:F=!1,fullWidth:L=!1,getLimitTagsText:_=we=>`+${we}`,getOptionDisabled:R,getOptionKey:z,getOptionLabel:N,isOptionEqualToValue:B,groupBy:I,handleHomeEndKeys:H=!n.freeSolo,id:Y,includeInputInList:ae=!1,inputValue:K,limitTags:oe=-1,ListboxComponent:ue,ListboxProps:G,loading:ie=!1,loadingText:Q="Loading…",multiple:ee=!1,noOptionsText:Z="No options",onChange:de,onClose:le,onHighlightChange:fe,onInputChange:he,onOpen:me,open:se,openOnFocus:ve=!1,openText:Le="Open",options:Ae,PaperComponent:Re,PopperComponent:re,popupIcon:_e=pI||(pI=p.jsx(W3,{})),readOnly:Me=!1,renderGroup:Ge,renderInput:Je,renderOption:St,renderTags:Ut,renderValue:at,selectOnFocus:tt=!n.freeSolo,size:pt="medium",slots:ze={},slotProps:be={},value:Ve,...Oe}=n,{getRootProps:$t,getInputProps:Rt,getInputLabelProps:vt,getPopupIndicatorProps:it,getClearProps:st,getItemProps:Dt,getListboxProps:nn,getOptionProps:Bt,value:pn,dirty:$n,expanded:qt,id:Pn,popupOpen:Se,focused:jn,focusedItem:Rn,anchorEl:en,setAnchorEl:jt,inputValue:Ur,groupedOptions:qn}=X1e({...n,componentName:"Autocomplete"}),mn=!S&&!$&&$n&&!Me,Bn=(!F||A===!0)&&A!==!1,{onMouseDown:xe}=Rt(),{ref:Ee,...Be}=nn(),Ye=N||(we=>we.label??we),ut={...n,disablePortal:O,expanded:qt,focused:jn,fullWidth:L,getOptionLabel:Ye,hasClearIcon:mn,hasPopupIcon:Bn,inputFocused:Rn===-1,popupOpen:Se,size:pt},Et=rwe(ut),Ct={slots:{paper:Re,popper:re,...ze},slotProps:{chip:s,listbox:G,...x,...be}},[Mt,Lt]=ur("listbox",{elementType:fwe,externalForwardedProps:Ct,ownerState:ut,className:Et.listbox,additionalProps:Be,ref:Ee}),[Xt,zt]=ur("paper",{elementType:tf,externalForwardedProps:Ct,ownerState:ut,className:Et.paper}),[Vt,ge]=ur("popper",{elementType:L2,externalForwardedProps:Ct,ownerState:ut,className:Et.popper,additionalProps:{disablePortal:O,style:{width:en?en.clientWidth:null},role:"presentation",anchorEl:en,open:Se}});let ye;const Ue=we=>({className:Et.tag,disabled:$,...Dt(we)});if(ee?pn.length>0&&(Ut?ye=Ut(pn,Ue,ut):at?ye=at(pn,Ue,ut):ye=pn.map((we,Pe)=>{const{key:ft,...kt}=Ue({index:Pe});return p.jsx(A3,{label:Ye(we),size:pt,...kt,...Ct.slotProps.chip},ft)})):at&&pn!=null&&(ye=at(pn,Ue,ut)),oe>-1&&Array.isArray(ye)){const we=ye.length-oe;!jn&&we>0&&(ye=ye.splice(0,oe),ye.push(p.jsx("span",{className:Et.tag,children:_(we)},ye.length)))}const gt=Ge||(we=>p.jsxs("li",{children:[p.jsx(pwe,{className:Et.groupLabel,ownerState:ut,component:"div",children:we.group}),p.jsx(hwe,{className:Et.groupUl,ownerState:ut,children:we.children})]},we.key)),We=St||((we,Pe)=>{const{key:ft,...kt}=we;return p.jsx("li",{...kt,children:Ye(Pe)},ft)}),Nt=(we,Pe)=>{const ft=Bt({option:we,index:Pe});return We({...ft,className:Et.option},we,{selected:ft["aria-selected"],index:Pe,inputValue:Ur},ut)},Kt=Ct.slotProps.clearIndicator,hn=Ct.slotProps.popupIndicator;return p.jsxs(C.Fragment,{children:[p.jsx(owe,{ref:t,className:Ht(Et.root,l),ownerState:ut,...$t(Oe),children:Je({id:Pn,disabled:$,fullWidth:!0,size:pt==="small"?"small":void 0,InputLabelProps:vt(),InputProps:{ref:jt,className:Et.inputRoot,startAdornment:ye,onMouseDown:we=>{we.target===we.currentTarget&&xe(we)},...(mn||Bn)&&{endAdornment:p.jsxs(awe,{className:Et.endAdornment,ownerState:ut,children:[mn?p.jsx(iwe,{...st(),"aria-label":g,title:g,ownerState:ut,...Kt,className:Ht(Et.clearIndicator,Kt?.className),children:d}):null,Bn?p.jsx(swe,{...it(),disabled:$,"aria-label":Se?y:Le,title:Se?y:Le,ownerState:ut,...hn,className:Ht(Et.popupIndicator,hn?.className),children:_e}):null]})}},inputProps:{className:Et.input,disabled:$,readOnly:Me,...Rt()}})}),en?p.jsx(lwe,{as:Vt,...ge,children:p.jsxs(cwe,{as:Xt,...zt,children:[ie&&qn.length===0?p.jsx(uwe,{className:Et.loading,ownerState:ut,children:Q}):null,qn.length===0&&!F&&!ie?p.jsx(dwe,{className:Et.noOptions,ownerState:ut,role:"presentation",onMouseDown:we=>{we.preventDefault()},children:Z}):null,qn.length>0?p.jsx(Mt,{as:ue,...Lt,children:qn.map((we,Pe)=>I?gt({key:we.key,group:we.group,children:we.options.map((ft,kt)=>Nt(ft,we.index+kt))}):Nt(we,Pe))}):null]})}):null]})});Ar.extend(h2);const gwe=Jt(p.jsx("path",{d:"m9.17 6 2 2H20v10H4V6zM10 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8z"})),l6=e=>{if(!e)return"Explore semantic models, run queries, and build reports";const t=e.replace(/^#+\s+/gm,"").replace(/\*\*(.*?)\*\*/g,"$1").replace(/\*(.*?)\*/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/`([^`]+)`/g,"$1").trim(),n=t.split(/\n\s*\n/)[1]||t;if(n.length<=120)return n;const r=n.substring(0,120).split(" ");return r.pop(),r.join(" ")+"..."},c6=(e,t)=>{const n=(e.readme||void 0)?.split(`
|
|
478
|
+
`}function Nxe(e,t){return[e,"rows",...t].join("_").replace(/[^A-Za-z0-9._-]+/g,"_").replace(/_+/g,"_").replace(/^[_.]+|[_.]+$/g,"").slice(0,120)||"rows"}function Ixe(e,t,n){return n==="server_default"&&t!==void 0&&e>=t?t:void 0}const KN="Download the rows behind this value as CSV, up to the server's row limit",Lxe=4e4;function zxe(e,t){const n=URL.createObjectURL(new Blob([e],{type:"text/csv;charset=utf-8"})),r=document.createElement("a");r.href=n,r.download=t,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),Lxe)}function Fxe(e){const t=e?.response?.data?.message;return typeof t=="string"&&t!==""?t:e instanceof Error&&e.message!==""?e.message:"The request failed."}function _xe({query:e,preamble:t,environmentName:n,packageName:r,modelPath:o,versionId:a,givens:i,fileName:s}){const{apiClients:l}=tr(),[d,u]=C.useState(!1),[m,g]=C.useState(KN),[y,x]=C.useState(void 0),w=C.useRef(void 0);C.useEffect(()=>()=>w.current?.abort(),[]);const S=async()=>{w.current?.abort();const b=new AbortController;w.current=b,u(!0),x(void 0);try{const $=await l.models.executeQueryModel(n,r,o,{query:t===void 0?e:v1(t,e),givens:i,versionId:a},void 0,{signal:b.signal});if(b.signal.aborted)return;const k=$.data,T=JSON.parse(k.result??"{}"),O=Ixe(J_(T).length,k.queryRowLimit,k.queryRowLimitSource);g(O===void 0?KN:`First ${O} rows: the server's row limit, so there may be more`),zxe(Dxe(T),O===void 0?`${s}.csv`:`${s}_first_${O}_rows_server_limit.csv`)}catch($){if(b.signal.aborted)return;x(`Download failed: ${Fxe($)}`)}finally{w.current===b&&(w.current=void 0,u(!1))}};return p.jsxs(Te,{sx:{display:"flex",alignItems:"center",gap:1},children:[y&&p.jsx(wt,{role:"alert",variant:"caption",color:"error",sx:{maxWidth:320},children:y}),p.jsx(Br,{title:m,children:p.jsx("span",{children:p.jsx(Vn,{size:"small",startIcon:p.jsx(jxe,{fontSize:"small"}),onClick:()=>void S(),disabled:d,children:"Download CSV"})})})]})}const e6=200;function Bxe(e){const{target:t}=e;if(t!==void 0&&!(e.dimensions===void 0&&e.code===void 0))return{...e,target:t}}function QN(e,t=e6){const n=qxe(e);if(n===void 0)return;const r=[...e.target.filters,...n].join(", "),o=e.timezone?`timezone: '${p2(e.timezone)}'; `:"",a=t===null?"":`; limit: ${t}`,i=Uxe(e.target.source);if(i!==void 0)return`run: ${i} -> { ${o}where: ${r}; select: *${a} }`}function Uxe(e){return Wy(e)?e:e.includes("`")?void 0:`\`${e}\``}function EC(e){return/^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)*$/.test(e)?e:`(${e})`}function qxe(e){if(e.dimensions){const n=[];for(const{code:r,value:o}of e.dimensions){if(o.kind==="null_literal"){n.push(`${EC(r)} is null`);continue}const a=H_(o,e.timezone);if(a===void 0)return;n.push(`${EC(r)} = ${a}`)}return n}const t=Zle(e.rawValue);return e.code!==void 0&&t?[`${EC(e.code)} = ${t}`]:void 0}const Hxe="This value cannot be written as a filter, so its rows cannot be fetched.";function XN(e){const t=e.drillClauses?q_(e.drillClauses,e.timezone):[];return t.length>0?t:[{field:e.field,label:e.label}]}function Vxe({request:e,environmentName:t,packageName:n,versionId:r,modelPath:o,preamble:a,givens:i,onClose:s,onDone:l,actions:d}){const{theme:u}=Vr(),m=e?QN(e):void 0,g=e?QN(e,null):void 0,y=e&&g!==void 0?{query:g,...a===void 0?{}:{preamble:a},environmentName:t,packageName:n,modelPath:o,...r===void 0?{}:{versionId:r},givens:i,fileName:Nxe(e.target.source,XN(e).map(x=>x.label))}:void 0;return p.jsxs(zx,{open:e!==void 0,onClose:s,maxWidth:"lg",fullWidth:!0,children:[p.jsxs(_x,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",pb:.5},children:[p.jsxs(Te,{children:[e?p.jsxs(p.Fragment,{children:["Rows where"," ",XN(e).map((x,w)=>p.jsxs(C.Fragment,{children:[w>0&&" and ",p.jsx(Te,{component:"code",sx:{fontSize:"0.9em"},children:x.field})," ","is ",x.label]},w))]}):"Rows",p.jsx(wt,{component:"div",variant:"caption",sx:{color:u.tileTitle,mt:.25},children:e?`The first ${e6} rows of ${e.target.source} behind this value, with the tile's own filters and the controls applied.`:""})]}),p.jsxs(Te,{sx:{display:"flex",alignItems:"center",gap:1,ml:1},children:[y&&(d?d(y):p.jsx(_xe,{...y})),p.jsx(ro,{onClick:s,"aria-label":"Close",size:"small",sx:{color:"text.secondary"},children:p.jsx(xh,{fontSize:"small"})})]})]}),p.jsxs(Fx,{dividers:!0,sx:{p:0,minHeight:240},children:[m===void 0&&e&&p.jsx(wt,{variant:"body2",sx:{p:2},children:Hxe}),m!==void 0&&p.jsx(Wxe,{query:a===void 0?m:v1(a,m),environmentName:t,packageName:n,...r===void 0?{}:{versionId:r},modelPath:o,givens:i,...l?{onDone:l}:{}})]}),p.jsxs(pz,{sx:{px:3,py:1.5},children:[m!==void 0&&p.jsx(wt,{variant:"caption",sx:{mr:"auto",color:u.tileTitle,fontFamily:u.ui.font.mono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:m,children:m}),p.jsx(Vn,{onClick:s,children:"Close"})]})]})}function Wxe({query:e,environmentName:t,packageName:n,versionId:r,modelPath:o,givens:a,onDone:i}){const s=rT({environmentName:t,packageName:n,modelPath:o,...r===void 0?{}:{versionId:r},query:e,givens:a}),{isSuccess:l,isError:d}=s,u=C.useRef(void 0);return C.useEffect(()=>{u.current=Pd()},[e]),C.useEffect(()=>{u.current===void 0||!l&&!d||(i?.(l,Pd()-u.current),u.current=void 0)},[l,d,i]),p.jsx(Te,{sx:{p:1},children:p.jsx(X2,{state:s,context:e})})}function t6({manifest:e,environmentName:t,packageName:n,versionId:r,documentName:o,givens:a,onGivensChange:i,onNavigate:s,height:l,maxResultSize:d,controlsLayout:u="bar",preamble:m,runModelPath:g,hiddenGivens:y,literalReads:x,onLinkNavigate:w,actions:S,rowsActions:b}){const $=C.useMemo(()=>w?{environmentName:t,packageName:n,sourcePath:e.path??o,onNavigate:w}:void 0,[t,n,e.path,o,w]),k=C.useMemo(()=>(e.givens??[]).filter(le=>!(m!==void 0&&le.secure===!0)&&!(le.name!==void 0&&y?.includes(le.name))),[e,y,m]),T=C.useMemo(()=>a===void 0?void 0:Object.fromEntries(Object.entries(a).filter(([,le])=>typeof le=="string")),[a]),O=b2({specs:k,loaded:!0,startingValues:e.startingGivens,params:T,onGivensChange:i,documentKey:`${t}/${n}/${r??""}/${o}`,autorun:e.autorun!==!1,environmentName:t,packageName:n,modelPath:g??e.path,versionId:r,documentName:o,...m!==void 0?{preamble:m}:{},...a?{hostGivens:a}:{}}),{applied:P,declaredTypes:D,canSelf:A,onSelf:F}=O,L=g1(),_=C.useMemo(()=>{const le=new Set((e.tiles??[]).flatMap(fe=>fe.givenNames??[]));return Object.fromEntries(Object.entries(a??{}).filter(([fe])=>le.has(fe)&&!D.has(fe)))},[e,a,D]),[R,z]=C.useState(void 0),N=C.useCallback(le=>{const fe=Bxe(le);fe!==void 0&&z(fe)},[]),B=C.useMemo(()=>y2(Jd(P,D),_),[P,D,_]),{reports:I}=C_(t,n,r,s!==void 0),H=C.useCallback(le=>{const fe=E0e(le,I);if(fe.kind!=="path")return;const he=fe.report.path;return I.find(me=>me.path===he)?.title||void 0},[I]),{bindingFor:Y,drillMenu:ae}=Z_({onNavigate:s,onSelf:F,canSelf:A,onRows:N,destinationTitle:H}),K=C.useCallback((le,fe)=>Y(le,fe!==!0),[Y]),{columns:oe,layout:ue,tileMaxHeight:G,tableMaxHeight:ie}=qle(e.layout,e.dashboardColumns),Q=C.useMemo(()=>Ybe(k,P,a),[k,P,a]);if(e.error)return p.jsx(b$,{layout:ue,header:p.jsx(ZN,{manifest:e,links:$,actions:S}),children:p.jsx(lo,{severity:"error",children:e.error})});const ee=g??e.path,Z=e.tiles??[],de=uF(Z);return p.jsxs(b$,{layout:ue,header:p.jsx(ZN,{manifest:e,links:$,actions:S}),controls:k.length>0?p.jsx(T_,{children:p.jsx(j1,{...O.panel,layout:u})}):void 0,children:[Q.length>0&&p.jsx(lo,{severity:"info",children:Kbe(Q)}),ee===void 0?p.jsx(lo,{severity:"error",children:"This dashboard has no model path, so there is nothing to run."}):Z.length>0?p.jsx(ile,{tiles:Z,columns:oe,minTilePx:sF,rowGapPx:vl,keyOf:(le,fe)=>`${fe}:${le.kind==="text"?`text:${le.name}`:le.query}`,renderTile:(le,fe)=>le.kind==="text"||le.query===void 0?p.jsx(Te,{sx:le.rowspan!==void 0||de?{minHeight:0,overflow:"auto"}:void 0,children:p.jsx(Yxe,{markdown:le.markdown??"",links:$})}):p.jsx(B_,{index:fe,environmentName:t,packageName:n,versionId:r,modelPath:ee,tile:le.query,label:le.label,subtitle:le.subtitle,borderless:le.borderless,givens:P,hostGivens:_,declaredTypes:D,givenNames:le.givenNames,height:le.rowspan!==void 0||de?iF(le.rowspan??cF.query):ue==="grid"?l??G:G,tableMaxHeight:ie,fixedHeight:le.rowspan!==void 0||de,maxResultSize:d,drill:K(le.query,le.restricted),ignoredFilters:b0e(le.givenNames&&(le.query&&x?.[le.query]?[...le.givenNames,...x[le.query]]:le.givenNames),k),...m!==void 0?{preamble:m,restricted:le.restricted}:{},...(()=>{const he=Gbe(Q,le.givenNames);return he.length>0?{waitingFor:Qbe(he)}:{}})()})}):p.jsx(lo,{severity:"warning",children:"This dashboard names neither a query nor any tiles."}),ae,ee!==void 0&&p.jsx(Vxe,{request:R,environmentName:t,packageName:n,...r===void 0?{}:{versionId:r},modelPath:ee,...m===void 0?{}:{preamble:m},givens:B,...b===void 0?{}:{actions:b},onClose:()=>z(void 0),onDone:(le,fe)=>{R&&L.emit({type:"report.rows_shown",source:R.target.source,view:R.target.queryName??"",field:R.field,ok:le,durationMs:fe})}})]})}function Yxe({markdown:e,links:t}){return p.jsx(N1,{children:p.jsx(oh,{variant:"document",links:t,children:e})})}function ZN({manifest:e,links:t,actions:n}){return p.jsx(R_,{title:e.title??e.name,actions:n,description:e.description?p.jsx(N1,{children:p.jsx(oh,{variant:"document",links:t,children:e.description})}):void 0})}const n6=Jt(p.jsx("path",{d:"M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3z"})),Gxe="publisher:resize";function Kxe(e){return typeof e=="object"&&e!==null&&e.type===Gxe&&typeof e.height=="number"}function r6(e){return e.replace(/\/api\/v0\/?$/,"")}function Qxe({server:e,environmentName:t,packageName:n,path:r,versionId:o}){const a=r.startsWith("public/")?r.slice(7):r,i=`${r6(e)}/environments/${encodeURIComponent(t)}/packages/${encodeURIComponent(n)}/`+a;return o===void 0?i:`${i}${i.includes("?")?"&":"?"}versionId=${encodeURIComponent(o)}`}function Xxe(e){try{const{environmentName:t,packageName:n,modelPath:r,versionId:o}=Xr(e);return!t||!n||!r?null:{environmentName:t,packageName:n,dataAppPath:r,versionId:o}}catch{return null}}function VTe({resourceUri:e}){const{server:t,apiClients:n}=tr(),r=Xxe(e),o=r?.environmentName??"",a=r?.packageName??"",i=r?.dataAppPath??"",s=r?.versionId,l=C.useMemo(()=>Qxe({server:t,environmentName:o,packageName:a,path:i,...s!==void 0?{versionId:s}:{}}),[t,o,a,i,s]),d=co({queryKey:["data-apps",o,a,s],queryFn:()=>n.dataApps.listDataApps(o,a,s),enabled:!!r}).data?.data?.find(w=>w.path===i),u=d?.title??i,m=d?.fit==="viewport",g=C.useRef(null),[y,x]=C.useState(120);return C.useEffect(()=>{if(m)return;function w(S){Kxe(S.data)&&S.source===g.current?.contentWindow&&S.data.height>0&&x(Math.ceil(S.data.height))}return window.addEventListener("message",w),()=>window.removeEventListener("message",w)},[m]),r?p.jsxs(Te,{sx:{p:3,...m?{height:"100%",display:"flex",flexDirection:"column"}:{maxWidth:1600,mx:"auto"}},children:[p.jsxs(Yn,{direction:"row",alignItems:"baseline",spacing:1,sx:{mb:1,flexShrink:0},children:[p.jsx(wt,{variant:"h6",sx:{fontWeight:"fontWeightMedium",letterSpacing:"-0.025em"},children:u}),p.jsx(wt,{variant:"caption",color:"text.secondary",sx:{fontFamily:Fo},children:i}),p.jsx(Te,{sx:{flex:1}}),p.jsx(Br,{title:"Open standalone in new tab",children:p.jsx(ro,{size:"small",href:l,target:"_blank",rel:"noopener noreferrer","aria-label":"Open standalone in new tab",sx:{color:"text.secondary"},children:p.jsx(n6,{fontSize:"small"})})})]}),p.jsx(Te,{sx:{border:"1px solid",borderColor:"divider",borderRadius:1.5,overflow:"hidden",backgroundColor:"background.paper",...m?{flex:1,minHeight:0}:{}},children:p.jsx("iframe",{ref:g,src:l,title:u,sandbox:"allow-scripts allow-same-origin allow-forms",style:{display:"block",width:"100%",height:m?"100%":y,border:0}})})]}):p.jsxs(Te,{sx:{p:3,maxWidth:1600,mx:"auto"},children:[p.jsx(wt,{variant:"h6",sx:{fontWeight:"fontWeightMedium"},children:"Can't open data app"}),p.jsxs(wt,{variant:"body2",color:"text.secondary",sx:{mt:1},children:["This data app link is missing an environment, package, or path:",p.jsx(Te,{component:"span",sx:{fontFamily:Fo,ml:1},children:e})]})]})}function Ns({title:e,count:t,description:n,action:r,children:o}){const a=C.useId();return p.jsxs(Te,{component:"section","aria-labelledby":a,sx:{mb:4},children:[p.jsxs(Yn,{direction:"row",alignItems:"center",justifyContent:"space-between",sx:{mb:n?0:1,minHeight:40},children:[p.jsxs(Yn,{direction:"row",alignItems:"baseline",spacing:1,children:[p.jsx(wt,{id:a,variant:"h6",sx:{fontWeight:600,letterSpacing:"-0.025em",lineHeight:1.2},children:e}),t!==void 0&&p.jsxs(wt,{variant:"caption",color:"text.secondary",children:["(",t,")"]})]}),r]}),n&&p.jsx(wt,{variant:"body2",color:"text.secondary",sx:{mb:1.5},children:n}),p.jsx(Te,{children:o})]})}function Zxe({resourceUri:e}){const{environmentName:t}=Xr(e),{apiClients:n}=tr(),[r,o]=C.useState(!1),a=90,{data:i,isSuccess:s,isError:l,error:d}=co({queryKey:["about",t],queryFn:()=>n.environments.getEnvironment(t,!1)}),u=i?.data?.readme||"",m=u.split(/\s+/),g=m.length>a,y=m.slice(0,a).join(" ");return p.jsxs(p.Fragment,{children:[!s&&!l&&p.jsx(Bo,{text:"Fetching About..."}),s&&u&&p.jsxs(Ns,{title:"Readme",children:[p.jsx(oh,{variant:"caption",children:r||!g?u:y}),g&&p.jsx(Te,{sx:{mt:1},children:p.jsx(Xy,{label:r?"Read less":"Read more",onClick:()=>o(!r)})})]}),l&&p.jsx(ja,{error:d,context:`${t} > About`})]})}function Jxe(e={}){const{autoHideDuration:t=null,disableWindowBlurListener:n=!1,onClose:r,open:o,resumeHideDuration:a}=e,i=w2();C.useEffect(()=>{if(!o)return;function S(b){b.defaultPrevented||b.key==="Escape"&&r?.(b,"escapeKeyDown")}return document.addEventListener("keydown",S),()=>{document.removeEventListener("keydown",S)}},[o,r]);const s=Yt((S,b)=>{r?.(S,b)}),l=Yt(S=>{!r||S==null||i.start(S,()=>{s(null,"timeout")})});C.useEffect(()=>(o&&l(t),i.clear),[o,t,l,i]);const d=S=>{r?.(S,"clickaway")},u=i.clear,m=C.useCallback(()=>{t!=null&&l(a??t*.5)},[t,a,l]),g=S=>b=>{const $=S.onBlur;$?.(b),m()},y=S=>b=>{const $=S.onFocus;$?.(b),u()},x=S=>b=>{const $=S.onMouseEnter;$?.(b),u()},w=S=>b=>{const $=S.onMouseLeave;$?.(b),m()};return C.useEffect(()=>{if(!n&&o)return window.addEventListener("focus",m),window.addEventListener("blur",u),()=>{window.removeEventListener("focus",m),window.removeEventListener("blur",u)}},[n,o,m,u]),{getRootProps:(S={})=>{const b={...q0(e),...q0(S)};return{role:"presentation",...S,...b,onBlur:g(b),onFocus:y(b),onMouseEnter:x(b),onMouseLeave:w(b)}},onClickAway:d}}function JN(e){return e.substring(2).toLowerCase()}function e1e(e,t){return t.documentElement.clientWidth<e.clientX||t.documentElement.clientHeight<e.clientY}function t1e(e){const{children:t,disableReactTree:n=!1,mouseEvent:r="onClick",onClickAway:o,touchEvent:a="onTouchEnd"}=e,i=C.useRef(!1),s=C.useRef(null),l=C.useRef(!1),d=C.useRef(!1);C.useEffect(()=>(setTimeout(()=>{l.current=!0},0),()=>{l.current=!1}),[]);const u=vr(wh(t),s),m=Yt(x=>{const w=d.current;d.current=!1;const S=Yo(s.current);if(!l.current||!s.current||"clientX"in x&&e1e(x,S))return;if(i.current){i.current=!1;return}let b;x.composedPath?b=x.composedPath().includes(s.current):b=!S.documentElement.contains(x.target)||s.current.contains(x.target),!b&&(n||!w)&&o(x)}),g=x=>w=>{d.current=!0;const S=t.props[x];S&&S(w)},y={ref:u};return a!==!1&&(y[a]=g(a)),C.useEffect(()=>{if(a!==!1){const x=JN(a),w=Yo(s.current),S=()=>{i.current=!0};return w.addEventListener(x,m),w.addEventListener("touchmove",S),()=>{w.removeEventListener(x,m),w.removeEventListener("touchmove",S)}}},[m,a]),r!==!1&&(y[r]=g(r)),C.useEffect(()=>{if(r!==!1){const x=JN(r),w=Yo(s.current);return w.addEventListener(x,m),()=>{w.removeEventListener(x,m)}}},[m,r]),C.cloneElement(t,y)}function n1e(e){return Cn("MuiSnackbarContent",e)}fn("MuiSnackbarContent",["root","message","action"]);const r1e=e=>{const{classes:t}=e;return bn({root:["root"],action:["action"],message:["message"]},n1e,t)},o1e=nt(tf,{name:"MuiSnackbarContent",slot:"Root"})(Gn(({theme:e})=>{const t=e.palette.mode==="light"?.8:.98;return{...e.typography.body2,color:e.vars?e.vars.palette.SnackbarContent.color:e.palette.getContrastText(Bk(e.palette.background.default,t)),backgroundColor:e.vars?e.vars.palette.SnackbarContent.bg:Bk(e.palette.background.default,t),display:"flex",alignItems:"center",flexWrap:"wrap",padding:"6px 16px",flexGrow:1,[e.breakpoints.up("sm")]:{flexGrow:"initial",minWidth:288}}})),a1e=nt("div",{name:"MuiSnackbarContent",slot:"Message"})({padding:"8px 0"}),i1e=nt("div",{name:"MuiSnackbarContent",slot:"Action"})({display:"flex",alignItems:"center",marginLeft:"auto",paddingLeft:16,marginRight:-8}),s1e=C.forwardRef(function(e,t){const n=Kn({props:e,name:"MuiSnackbarContent"}),{action:r,className:o,message:a,role:i="alert",...s}=n,l=n,d=r1e(l);return p.jsxs(o1e,{role:i,elevation:6,className:Ht(d.root,o),ownerState:l,ref:t,...s,children:[p.jsx(a1e,{className:d.message,ownerState:l,children:a}),r?p.jsx(i1e,{className:d.action,ownerState:l,children:r}):null]})});function l1e(e){return Cn("MuiSnackbar",e)}fn("MuiSnackbar",["root","anchorOriginTopCenter","anchorOriginBottomCenter","anchorOriginTopRight","anchorOriginBottomRight","anchorOriginTopLeft","anchorOriginBottomLeft"]);const c1e=e=>{const{classes:t,anchorOrigin:n}=e,r={root:["root",`anchorOrigin${Tt(n.vertical)}${Tt(n.horizontal)}`]};return bn(r,l1e,t)},u1e=nt("div",{name:"MuiSnackbar",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.root,t[`anchorOrigin${Tt(n.anchorOrigin.vertical)}${Tt(n.anchorOrigin.horizontal)}`]]}})(Gn(({theme:e})=>({zIndex:(e.vars||e).zIndex.snackbar,position:"fixed",display:"flex",left:8,right:8,justifyContent:"center",alignItems:"center",variants:[{props:({ownerState:t})=>t.anchorOrigin.vertical==="top",style:{top:8,[e.breakpoints.up("sm")]:{top:24}}},{props:({ownerState:t})=>t.anchorOrigin.vertical!=="top",style:{bottom:8,[e.breakpoints.up("sm")]:{bottom:24}}},{props:({ownerState:t})=>t.anchorOrigin.horizontal==="left",style:{justifyContent:"flex-start",[e.breakpoints.up("sm")]:{left:24,right:"auto"}}},{props:({ownerState:t})=>t.anchorOrigin.horizontal==="right",style:{justifyContent:"flex-end",[e.breakpoints.up("sm")]:{right:24,left:"auto"}}},{props:({ownerState:t})=>t.anchorOrigin.horizontal==="center",style:{[e.breakpoints.up("sm")]:{left:"50%",right:"auto",transform:"translateX(-50%)"}}}]}))),d1e=C.forwardRef(function(e,t){const n=Kn({props:e,name:"MuiSnackbar"}),r=Xd(),o={enter:r.transitions.duration.enteringScreen,exit:r.transitions.duration.leavingScreen},{action:a,anchorOrigin:{vertical:i,horizontal:s}={vertical:"bottom",horizontal:"left"},autoHideDuration:l=null,children:d,className:u,ClickAwayListenerProps:m,ContentProps:g,disableWindowBlurListener:y=!1,message:x,onBlur:w,onClose:S,onFocus:b,onMouseEnter:$,onMouseLeave:k,open:T,resumeHideDuration:O,slots:P={},slotProps:D={},TransitionComponent:A,transitionDuration:F=o,TransitionProps:{onEnter:L,onExited:_,...R}={},...z}=n,N={...n,anchorOrigin:{vertical:i,horizontal:s},autoHideDuration:l,disableWindowBlurListener:y,TransitionComponent:A,transitionDuration:F},B=c1e(N),{getRootProps:I,onClickAway:H}=Jxe({...N}),[Y,ae]=C.useState(!0),K=me=>{ae(!0),_&&_(me)},oe=(me,se)=>{ae(!1),L&&L(me,se)},ue={slots:{transition:A,...P},slotProps:{content:g,clickAwayListener:m,transition:R,...D}},[G,ie]=ur("root",{ref:t,className:[B.root,u],elementType:u1e,getSlotProps:I,externalForwardedProps:{...ue,...z},ownerState:N}),[Q,{ownerState:ee,...Z}]=ur("clickAwayListener",{elementType:t1e,externalForwardedProps:ue,getSlotProps:me=>({onClickAway:(...se)=>{const ve=se[0];me.onClickAway?.(...se),!ve?.defaultMuiPrevented&&H(...se)}}),ownerState:N}),[de,le]=ur("content",{elementType:s1e,shouldForwardComponentProp:!0,externalForwardedProps:ue,additionalProps:{message:x,action:a},ownerState:N}),[fe,he]=ur("transition",{elementType:gy,externalForwardedProps:ue,getSlotProps:me=>({onEnter:(...se)=>{me.onEnter?.(...se),oe(...se)},onExited:(...se)=>{me.onExited?.(...se),K(...se)}}),additionalProps:{appear:!0,in:T,timeout:F,direction:i==="top"?"down":"up"},ownerState:N});return!T&&Y?null:p.jsx(Q,{...Z,...P.clickAwayListener&&{ownerState:ee},children:p.jsx(G,{...ie,children:p.jsx(fe,{...he,children:d||p.jsx(de,{...le})})})})});let S$;function f1e(e){S$=e}function eI(e){if(S$)try{S$(e)}catch{}}function rc(e,t,n){return(async r=>{const o=Date.now();try{const a=await n(r);return eI({type:"console.mutation",resource:e,action:t,ok:!0,durationMs:Date.now()-o}),a}catch(a){throw eI({type:"console.mutation",resource:e,action:t,ok:!1,durationMs:Date.now()-o,reason:a instanceof Error?a.message:"An unknown error occurred"}),a}})}function Ch({mutationFn:e,success:t,invalidates:n,closeDialog:r,resource:o,action:a}){const i=Tl(),[s,l]=C.useState(""),d=hl({mutationFn:rc(o,a,e),onSuccess(){r();for(const u of n)i.invalidateQueries({queryKey:u});l(t)},onError(u){l(u instanceof Error?u.message:"An unknown error occurred")}});return{mutate:d.mutate,isPending:d.isPending,notice:p.jsx(d1e,{open:s!=="",autoHideDuration:6e3,onClose:()=>l(""),message:s})}}const o6="https://docs.malloydata.dev/documentation",tI=`${o6}/user_guides/publishing`,Bb="https://github.com/malloydata/publisher/blob/main/docs",tu={docsHome:`${o6}/`,publishing:`${tI}/publishing`,mcpAgents:`${tI}/mcp_agents`,surfaces:`${Bb}/choosing-a-surface.md`,givens:`${Bb}/givens.md`,materialization:`${Bb}/materialization.md`,connections:`${Bb}/connections.md`};function p1e({resourceUri:e}){const[t,n]=C.useState(!1),{apiClients:r}=tr(),{environmentName:o}=Xr(e),a=Ch({mutationFn(s){return r.packages.createPackage(o,{name:s.name,description:s.description,location:s.location})},success:"Package created",invalidates:[["packages",o]],closeDialog:()=>n(!1),resource:"package",action:"create"}),i=s=>{s.preventDefault();const l=new FormData(s.currentTarget),d=l.get("name")?.toString(),u=l.get("description")?.toString(),m=l.get("location")?.toString();a.mutate({name:d,description:u,location:m})};return p.jsxs(p.Fragment,{children:[p.jsx(Qy,{label:"Package",onClick:()=>n(!0)}),p.jsx(Oo,{open:t,onClose:()=>n(!1),title:"New package",description:p.jsxs(p.Fragment,{children:["A package is a directory of Malloy models and their data. Give its location as a GitHub, S3 or GCS URL, or an absolute path the server can read; see the"," ",p.jsx(Te,{component:"a",href:tu.publishing,target:"_blank",rel:"noopener noreferrer",sx:{color:"text.primary"},children:"package format"}),"."]}),actions:p.jsxs(p.Fragment,{children:[p.jsx(Vn,{disabled:a.isPending,onClick:()=>n(!1),children:"Cancel"}),p.jsx(Vn,{type:"submit",form:"package-form",variant:"contained",loading:a.isPending,children:"Create package"})]}),children:p.jsx("form",{onSubmit:i,id:"package-form",children:p.jsxs(Yn,{sx:{gap:2},children:[p.jsx(Ri,{autoFocus:!0,required:!0,id:"name",name:"name",label:"Name",type:"text",fullWidth:!0,size:"small",InputLabelProps:{shrink:!0}}),p.jsx(Ri,{id:"description",name:"description",label:"Description",multiline:!0,rows:3,fullWidth:!0,size:"small",InputLabelProps:{shrink:!0}}),p.jsx(Ri,{id:"location",name:"location",label:"Location",type:"text",placeholder:"e.g. s3://my-bucket/my-package.zip",fullWidth:!0,size:"small",InputLabelProps:{shrink:!0}})]})})}),a.notice]})}const h1e=Jt(p.jsx("path",{d:"M2 20h20v-4H2zm2-3h2v2H4zM2 4v4h20V4zm4 3H4V5h2zm-4 7h20v-4H2zm2-3h2v2H4z"}));function L1({icon:e,tint:t,label:n,mono:r,description:o,rightLabel:a,trailingAction:i,onClick:s,ariaLabel:l}){const d=!!s;return p.jsxs(Te,{onClick:s,onKeyDown:d?u=>{s&&(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),s(u))}:void 0,role:d?"button":void 0,tabIndex:d?0:void 0,"aria-label":l,sx:u=>({display:"flex",alignItems:"center",gap:1.5,py:1,px:1,mx:-1,cursor:d?"pointer":"default",borderRadius:1.5,transition:"background-color 0.1s","&:hover":d?{backgroundColor:u.palette.mode==="dark"?"rgba(255, 255, 255, 0.08)":"grey.100"}:void 0,"&:focus-visible":d?{outline:"2px solid",outlineColor:"primary.main",outlineOffset:2}:void 0}),children:[p.jsx(Te,{sx:{width:32,height:32,borderRadius:1,bgcolor:t,color:"#FFFFFF",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e}),p.jsxs(Te,{sx:{flex:1,minWidth:0,display:"flex",alignItems:"baseline",gap:1.5},children:[p.jsx(wt,{variant:"body2",sx:{...r?{fontFamily:Fo}:{},flexShrink:0,maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n}),o&&p.jsx(wt,{variant:"body2",color:"text.secondary",sx:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:o})]}),a&&p.jsx(wt,{variant:"caption",color:"text.secondary",sx:{flexShrink:0},children:a}),i&&p.jsx(Te,{sx:{flexShrink:0,display:"flex",alignItems:"center"},children:i})]})}const a6=Jt(p.jsx("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6zM19 4h-3.5l-1-1h-5l-1 1H5v2h14z"})),m1e=fn("MuiBox",["root"]),g1e=tF(),Ta=sR({themeId:bh,defaultTheme:g1e,defaultClassName:m1e.root,generateClassName:B4.generate}),z1=hR({createStyledComponent:nt("div",{name:"MuiStack",slot:"Root"}),useThemeProps:e=>Kn({props:e,name:"MuiStack"})}),nI=fn("MuiDivider",["root","absolute","fullWidth","inset","middle","flexItem","light","vertical","withChildren","withChildrenVertical","textAlignRight","textAlignLeft","wrapper","wrapperVertical"]);function y1e(e){return Cn("MuiListItemIcon",e)}const rI=fn("MuiListItemIcon",["root","alignItemsFlexStart"]),v1e=e=>{const{alignItems:t,classes:n}=e;return bn({root:["root",t==="flex-start"&&"alignItemsFlexStart"]},y1e,n)},b1e=nt("div",{name:"MuiListItemIcon",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.root,n.alignItems==="flex-start"&&t.alignItemsFlexStart]}})(Gn(({theme:e})=>({minWidth:56,color:(e.vars||e).palette.action.active,flexShrink:0,display:"inline-flex",variants:[{props:{alignItems:"flex-start"},style:{marginTop:8}}]}))),oT=C.forwardRef(function(e,t){const n=Kn({props:e,name:"MuiListItemIcon"}),{className:r,...o}=n,a=C.useContext(ic),i={...n,alignItems:a.alignItems},s=v1e(i);return p.jsx(b1e,{className:Ht(s.root,r),ownerState:i,ref:t,...o})});function x1e(e){return Cn("MuiListItemText",e)}const Rp=fn("MuiListItemText",["root","multiline","dense","inset","primary","secondary"]),w1e=e=>{const{classes:t,inset:n,primary:r,secondary:o,dense:a}=e;return bn({root:["root",n&&"inset",a&&"dense",r&&o&&"multiline"],primary:["primary"],secondary:["secondary"]},x1e,t)},S1e=nt("div",{name:"MuiListItemText",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[{[`& .${Rp.primary}`]:t.primary},{[`& .${Rp.secondary}`]:t.secondary},t.root,n.inset&&t.inset,n.primary&&n.secondary&&t.multiline,n.dense&&t.dense]}})({flex:"1 1 auto",minWidth:0,marginTop:4,marginBottom:4,[`.${eN.root}:where(& .${Rp.primary})`]:{display:"block"},[`.${eN.root}:where(& .${Rp.secondary})`]:{display:"block"},variants:[{props:({ownerState:e})=>e.primary&&e.secondary,style:{marginTop:6,marginBottom:6}},{props:({ownerState:e})=>e.inset,style:{paddingLeft:56}}]}),aT=C.forwardRef(function(e,t){const n=Kn({props:e,name:"MuiListItemText"}),{children:r,className:o,disableTypography:a=!1,inset:i=!1,primary:s,primaryTypographyProps:l,secondary:d,secondaryTypographyProps:u,slots:m={},slotProps:g={},...y}=n,{dense:x}=C.useContext(ic);let w=s??r,S=d;const b={...n,disableTypography:a,inset:i,primary:!!w,secondary:!!S,dense:x},$=w1e(b),k={slots:m,slotProps:{primary:l,secondary:u,...g}},[T,O]=ur("root",{className:Ht($.root,o),elementType:S1e,externalForwardedProps:{...k,...y},ownerState:b,ref:t}),[P,D]=ur("primary",{className:$.primary,elementType:Sr,externalForwardedProps:k,ownerState:b}),[A,F]=ur("secondary",{className:$.secondary,elementType:Sr,externalForwardedProps:k,ownerState:b});return w!=null&&w.type!==Sr&&!a&&(w=p.jsx(P,{variant:x?"body2":"body1",component:D?.variant?void 0:"span",...D,children:w})),S!=null&&S.type!==Sr&&!a&&(S=p.jsx(A,{variant:"body2",color:"textSecondary",...F,children:S})),p.jsxs(T,{...O,children:[w,S]})});function C1e(e){return Cn("MuiMenuItem",e)}const ag=fn("MuiMenuItem",["root","focusVisible","dense","disabled","divider","gutters","selected"]),k1e=(e,t)=>{const{ownerState:n}=e;return[t.root,n.dense&&t.dense,n.divider&&t.divider,!n.disableGutters&&t.gutters]},$1e=e=>{const{disabled:t,dense:n,divider:r,disableGutters:o,selected:a,classes:i}=e,s=bn({root:["root",n&&"dense",t&&"disabled",!o&&"gutters",r&&"divider",a&&"selected"]},C1e,i);return{...i,...s}},R1e=nt(qd,{shouldForwardProp:e=>ei(e)||e==="classes",name:"MuiMenuItem",slot:"Root",overridesResolver:k1e})(Gn(({theme:e})=>({...e.typography.body1,display:"flex",justifyContent:"flex-start",alignItems:"center",position:"relative",textDecoration:"none",minHeight:48,paddingTop:6,paddingBottom:6,boxSizing:"border-box",whiteSpace:"nowrap","&:hover":{textDecoration:"none",backgroundColor:(e.vars||e).palette.action.hover,"@media (hover: none)":{backgroundColor:"transparent"}},[`&.${ag.selected}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,(e.vars||e).palette.action.selectedOpacity),[`&.${ag.focusVisible}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.focusOpacity}`)}},[`&.${ag.selected}:hover`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.hoverOpacity}`),"@media (hover: none)":{backgroundColor:e.alpha((e.vars||e).palette.primary.main,(e.vars||e).palette.action.selectedOpacity)}},[`&.${ag.focusVisible}`]:{backgroundColor:(e.vars||e).palette.action.focus},[`&.${ag.disabled}`]:{opacity:(e.vars||e).palette.action.disabledOpacity},[`& + .${nI.root}`]:{marginTop:e.spacing(1),marginBottom:e.spacing(1)},[`& + .${nI.inset}`]:{marginLeft:52},[`& .${Rp.root}`]:{marginTop:0,marginBottom:0},[`& .${Rp.inset}`]:{paddingLeft:36},[`& .${rI.root}`]:{minWidth:36},variants:[{props:({ownerState:t})=>!t.disableGutters,style:{paddingLeft:16,paddingRight:16}},{props:({ownerState:t})=>t.divider,style:{borderBottom:`1px solid ${(e.vars||e).palette.divider}`,backgroundClip:"padding-box"}},{props:({ownerState:t})=>!t.dense,style:{[e.breakpoints.up("sm")]:{minHeight:"auto"}}},{props:({ownerState:t})=>t.dense,style:{minHeight:32,paddingTop:4,paddingBottom:4,...e.typography.body2,[`& .${rI.root} svg`]:{fontSize:"1.25rem"}}}]}))),Vo=C.forwardRef(function(e,t){const n=Kn({props:e,name:"MuiMenuItem"}),{autoFocus:r=!1,component:o="li",dense:a=!1,divider:i=!1,disableGutters:s=!1,focusVisibleClassName:l,role:d="menuitem",tabIndex:u,className:m,...g}=n,y=C.useContext(ic),x=C.useMemo(()=>({dense:a||y.dense||!1,disableGutters:s}),[y.dense,a,s]),w=C.useRef(null);Go(()=>{r&&w.current&&w.current.focus()},[r]);const S={...n,dense:x.dense,divider:i,disableGutters:s},b=$1e(n),$=vr(w,t);let k;return n.disabled||(k=u!==void 0?u:-1),p.jsx(ic.Provider,{value:x,children:p.jsx(R1e,{ref:$,role:d,tabIndex:k,component:o,focusVisibleClassName:Ht(b.focusVisible,l),className:Ht(b.root,m),...g,ownerState:S,classes:b})})}),ac={postgres:[{label:"Host",name:"host",type:"text",required:!1},{label:"Port",name:"port",type:"number",required:!1},{label:"Database Name",name:"databaseName",type:"text",required:!1},{label:"User Name",name:"userName",type:"text",required:!1},{label:"Password",name:"password",type:"password",required:!1},{label:"Connection String",name:"connectionString",type:"text",required:!1}],bigquery:[{label:"Project ID",name:"defaultProjectId",type:"text",required:!1},{label:"Billing Project ID",name:"billingProjectId",type:"text",required:!1},{label:"Location",name:"location",type:"text",required:!1},{label:"Service Account Key JSON",name:"serviceAccountKeyJson",type:"text",required:!0},{label:"Maximum Bytes Billed",name:"maximumBytesBilled",type:"text",required:!1},{label:"Query Timeout Milliseconds",name:"queryTimeoutMilliseconds",type:"text",required:!1},{label:"Database Metadata",name:"dbmeta",type:"text",required:!1,selectOptions:[{label:"No",value:"false"},{label:"Yes",value:"true"}]}],snowflake:[{label:"Account",name:"account",type:"text",required:!0},{label:"Username",name:"username",type:"text",required:!0},{label:"Password",name:"password",type:"password",required:!1},{label:"Role",name:"role",type:"text",required:!1},{label:"Warehouse",name:"warehouse",type:"text",required:!0},{label:"Database",name:"database",type:"text",required:!1},{label:"Schema",name:"schema",type:"text",required:!1},{label:"Response Timeout Milliseconds",name:"responseTimeoutMilliseconds",type:"text",required:!1},{label:"Private Key",name:"privateKey",type:"password",required:!1},{label:"Private Key Passphrase",name:"privateKeyPass",type:"password",required:!1}],trino:[{label:"Server",name:"server",type:"text",required:!0},{label:"Port",name:"port",type:"number",required:!1},{label:"Catalog",name:"catalog",type:"text",required:!1},{label:"Schema",name:"schema",type:"text",required:!1},{label:"User",name:"user",type:"text",required:!0},{label:"Password",name:"password",type:"password",required:!1},{label:"Peaka Key",name:"peakaKey",type:"password",required:!1}],databricks:[{label:"Host",name:"host",type:"text",required:!0},{label:"HTTP Path",name:"path",type:"text",required:!0},{label:"Access Token",name:"token",type:"password",required:!1},{label:"OAuth Client ID",name:"oauthClientId",type:"text",required:!1},{label:"OAuth Client Secret",name:"oauthClientSecret",type:"password",required:!1},{label:"Default Catalog",name:"defaultCatalog",type:"text",required:!1},{label:"Default Schema",name:"defaultSchema",type:"text",required:!1}],mysql:[{label:"Host",name:"host",type:"text",required:!0},{label:"Port",name:"port",type:"number",required:!0},{label:"User",name:"user",type:"text",required:!0},{label:"Password",name:"password",type:"password",required:!0},{label:"Database",name:"database",type:"text",required:!0}],sqlserver:[{label:"Server",name:"server",type:"text",required:!0},{label:"Port",name:"port",type:"number",required:!1},{label:"Database",name:"database",type:"text",required:!0},{label:"User",name:"user",type:"text",required:!0},{label:"Password",name:"password",type:"password",required:!0},{label:"Encrypt",name:"encrypt",type:"text",required:!1,selectOptions:[{label:"Yes",value:"true"},{label:"No",value:"false"}]},{label:"Trust server certificate",name:"trustServerCertificate",type:"text",required:!1,selectOptions:[{label:"No",value:"false"},{label:"Yes",value:"true"}]},{label:"Host name in certificate",name:"hostNameInCertificate",type:"text",required:!1},{label:"Instance name",name:"instanceName",type:"text",required:!1}],duckdb:[],motherduck:[{label:"Access Token",name:"accessToken",type:"text",required:!0},{label:"Database",name:"database",type:"text",required:!1}],ducklake:[],publisher:[]},Og={postgres:"postgresConnection",bigquery:"bigqueryConnection",snowflake:"snowflakeConnection",trino:"trinoConnection",databricks:"databricksConnection",mysql:"mysqlConnection",sqlserver:"sqlserverConnection",duckdb:"duckdbConnection",motherduck:"motherduckConnection",ducklake:"ducklakeConnection",publisher:"publisherConnection"},T1e={bigquery:{dbmeta:"boolean"},sqlserver:{port:"integer",encrypt:"boolean",trustServerCertificate:"boolean"}},E1e={sqlserver:["hostNameInCertificate","instanceName"]};function i6(e,t){const n=T1e[e],r=E1e[e];if(!n&&!r)return t;const o={...t};for(const a of r??[])o[a]===""&&delete o[a];for(const[a,i]of Object.entries(n??{})){const s=t[a];if(s!==void 0){if(s===""){delete o[a];continue}if(i==="integer"){const l=Number(s);Number.isInteger(l)&&(o[a]=l)}else(s==="true"||s==="false")&&(o[a]=s==="true")}}return o}const s6=Object.values(hA).filter(e=>e!==hA.Publisher),C$={postgres:"postgresConnection",bigquery:"bigqueryConnection",snowflake:"snowflakeConnection",gcs:"gcsConnection",s3:"s3Connection",azure:"azureConnection"},Sy=[{label:"Credential Provider",name:"provider",type:"text",required:!1,selectOptions:[{label:"Access key pair",value:"config"},{label:"Host credential chain",value:"credential_chain"}]},{label:"Access Key ID",name:"accessKeyId",type:"text",required:!1,visibleWhen:{field:"provider",value:"config"}},{label:"Secret Access Key",name:"secretAccessKey",type:"password",required:!1,visibleWhen:{field:"provider",value:"config"}},{label:"Credential Chain",name:"chain",type:"text",required:!1,visibleWhen:{field:"provider",value:"credential_chain"}},{label:"Region",name:"region",type:"text",required:!1},{label:"Endpoint",name:"endpoint",type:"text",required:!1},{label:"Session Token",name:"sessionToken",type:"password",required:!1,visibleWhen:{field:"provider",value:"config"}}],Cy=[{label:"Key ID",name:"keyId",type:"text",required:!0},{label:"Secret",name:"secret",type:"password",required:!0}],M1e=[{label:"Auth Type",name:"authType",type:"text",required:!0,selectOptions:[{label:"SAS Token",value:"sas_token"},{label:"Service Principal (SPN)",value:"service_principal"}]},{label:"SAS URL (e.g. https://account.blob.core.windows.net/container/file.parquet?sp=r&st=...)",name:"sasUrl",type:"text",required:!1,visibleWhen:{field:"authType",value:"sas_token"}},{label:"Tenant ID",name:"tenantId",type:"text",required:!1,visibleWhen:{field:"authType",value:"service_principal"}},{label:"Client ID",name:"clientId",type:"text",required:!1,visibleWhen:{field:"authType",value:"service_principal"}},{label:"Client Secret",name:"clientSecret",type:"password",required:!1,visibleWhen:{field:"authType",value:"service_principal"}},{label:"Account Name",name:"accountName",type:"text",required:!1,visibleWhen:{field:"authType",value:"service_principal"}},{label:"File URL (e.g. abfss://container/path/file.parquet)",name:"fileUrl",type:"text",required:!1,visibleWhen:{field:"authType",value:"service_principal"}}];function ex(e){return e==="postgres"||e==="bigquery"||e==="snowflake"?ac[e]||[]:e==="s3"?Sy:e==="gcs"?Cy:e==="azure"?M1e:[]}function O1e({onSubmit:e,isSubmitting:t}){const[n,r]=C.useState(!1),[o,a]=C.useState("postgres"),[i,s]=C.useState([]),[l,d]=C.useState("postgres"),[u,m]=C.useState("s3"),[g,y]=C.useState("config"),x=()=>{r(!0)},w=()=>{r(!1),s([]),a("postgres"),d("postgres"),m("s3"),y("config")},S=async T=>{T.preventDefault();const O=new FormData(T.currentTarget),P=O.get("name")?.toString(),D=O.get("type")?.toString(),A=ac[D];if(!P)throw new Error("Name is required");if(!D)throw new Error("Type is required");let F;if(D==="ducklake"){const L={};if(l==="postgres"){const z=ac.postgres,N={};if(z.forEach(B=>{const I=O.get(`ducklake_pg_${B.name}`)?.toString();I&&(N[B.name]=I)}),Object.keys(N).length===0)throw new Error("DuckLake requires catalog connection");L.postgresConnection=N}const _=O.get("ducklake_bucketUrl")?.toString();if(!_)throw new Error("DuckLake requires a bucket URL");const R={bucketUrl:_};if(u==="s3"){const z={};if(Sy.forEach(N=>{const B=O.get(`ducklake_s3_${N.name}`)?.toString();B&&(z[N.name]=B)}),z.provider==="credential_chain")delete z.accessKeyId,delete z.secretAccessKey,delete z.sessionToken;else{if(delete z.chain,!z.accessKeyId)throw new Error("S3 Access Key ID is required");if(!z.secretAccessKey)throw new Error("S3 Secret Access Key is required")}Object.keys(z).length>0&&(R.s3Connection=z)}else if(u==="gcs"){const z={};if(Cy.forEach(N=>{const B=O.get(`ducklake_gcs_${N.name}`)?.toString();B&&(z[N.name]=B)}),!z.keyId)throw new Error("GCS Key ID is required");if(!z.secret)throw new Error("GCS Secret is required");Object.keys(z).length>0&&(R.gcsConnection=z)}F={name:P,type:D,ducklakeConnection:{catalog:L,storage:R}}}else if(D==="duckdb"){if(i.length===0)throw new Error("DuckDB connection must have at least one attached database");const L=i.map((_,R)=>{const z=_.dbType,N=O.get(`attachedDb_${R}_name`)?.toString();if(!N)throw new Error(`Attached database at index ${R} must have a name`);const B={name:N,type:z},I=ex(z);if(I&&I.length>0){const H={};if(I.forEach(ae=>{const K=O.get(`attachedDb_${R}_${ae.name}`)?.toString();K&&(H[ae.name]=K)}),z==="s3"){if(H.provider==="credential_chain")delete H.accessKeyId,delete H.secretAccessKey,delete H.sessionToken;else if(delete H.chain,!H.accessKeyId||!H.secretAccessKey)throw new Error(`Attached database "${N}" requires an S3 Access Key ID and Secret Access Key, or Credential Provider set to the host credential chain`)}const Y=C$[z];Y&&(B[Y]=H)}return B});F={name:P,type:D,duckdbConnection:{attachedDatabases:L}}}else{const L={};if(A.forEach(_=>{const R=O.get(_.name)?.toString();R&&(L[_.name]=R)}),D==="postgres"){if(!L.connectionString?.trim()){const _=["host","port","databaseName","userName","password"];for(const R of _)if(!L[R])throw new Error(`${A.find(z=>z.name===R)?.label||R} is required`)}}else if(D==="bigquery"){if(!L.serviceAccountKeyJson)throw new Error("Service Account Key JSON is required")}else if(D==="snowflake"){if(!L.account)throw new Error("Account is required");if(!L.username)throw new Error("Username is required");if(!L.warehouse)throw new Error("Warehouse is required");if(!L.password&&!L.privateKey)throw new Error("Either password or private key is required")}else if(D==="trino"){if(!L.server)throw new Error("Server is required");if(!L.user)throw new Error("User is required");if(L.server.trim().startsWith("https://")&&!L.password&&!L.peakaKey)throw new Error("Password is required for HTTPS connections (or use Peaka Key)")}else if(D==="mysql"){const _=["host","port","database","user","password"];for(const R of _)if(!L[R])throw new Error(`${A.find(z=>z.name===R)?.label||R} is required`)}else if(D==="sqlserver"){const _=["server","database","user","password"];if(!L.instanceName&&!L.port)throw new Error("Port is required unless an instance name is given");for(const R of _)if(!L[R])throw new Error(`${A.find(z=>z.name===R)?.label||R} is required`)}else if(D==="motherduck"){if(!L.accessToken)throw new Error("Access Token is required")}else if(D==="databricks"){if(!L.host)throw new Error("Host is required");if(!L.path)throw new Error("HTTP Path is required");const _=L.oauthClientId&&L.oauthClientSecret;if(!L.token&&!_)throw new Error("Either Access Token or OAuth Client ID + Secret is required")}F={name:P,type:D,[Og[D]]:i6(D,L)}}await e(F),w()},b=()=>{s([...i,{name:"",dbType:"postgres"}])},$=T=>{s(i.filter((O,P)=>P!==T))},k=(T,O)=>{const P=[...i];P[T]={...P[T],dbType:O},s(P)};return p.jsxs(kn.Fragment,{children:[p.jsx(Qy,{label:"Connection",onClick:x}),p.jsx(Oo,{open:n,onClose:w,title:"New connection",description:"Add a connection so packages in this environment can query your database with Malloy.",actions:p.jsxs(p.Fragment,{children:[p.jsx(Co,{disabled:t,onClick:w,children:"Cancel"}),p.jsx(Co,{type:"submit",form:"connection-form",variant:"contained",loading:t,children:"Create connection"})]}),children:p.jsx("form",{onSubmit:S,id:"connection-form",children:p.jsxs(z1,{sx:{gap:2},children:[p.jsx(yr,{autoFocus:!0,required:!0,id:"name",name:"name",label:"Name",type:"text",fullWidth:!0,size:"small"}),p.jsx(yr,{id:"type",name:"type",label:"Connection Type",fullWidth:!0,size:"small",value:o,select:!0,onChange:T=>a(T.target.value),children:s6.map(T=>p.jsx(Vo,{value:T,children:T},T))}),o==="ducklake"?p.jsxs(Ta,{sx:{mt:2},children:[p.jsxs(Ta,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[p.jsx(Sr,{variant:"subtitle2",sx:{mb:2},fontWeight:500,children:"Catalog"}),p.jsx(yr,{id:"ducklake_catalogType",label:"Catalog Type",fullWidth:!0,size:"small",value:l,select:!0,onChange:T=>d(T.target.value),children:p.jsx(Vo,{value:"postgres",children:"PostgreSQL"})}),l==="postgres"&&p.jsx(p.Fragment,{children:ac.postgres.map(T=>p.jsx(yr,{id:`ducklake_pg_${T.name}`,name:`ducklake_pg_${T.name}`,label:T.label,type:T.type,fullWidth:!0,size:"small"},`pg_${T.name}`))})]}),p.jsxs(Ta,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[p.jsx(Sr,{variant:"subtitle2",sx:{mb:2},fontWeight:500,children:"Storage"}),p.jsxs(yr,{id:"ducklake_storageType",label:"Storage Type",fullWidth:!0,size:"small",value:u,select:!0,onChange:T=>m(T.target.value),children:[p.jsx(Vo,{value:"s3",children:"S3"}),p.jsx(Vo,{value:"gcs",children:"GCS"})]}),p.jsx(yr,{required:!0,id:"ducklake_bucketUrl",name:"ducklake_bucketUrl",label:u==="s3"?"Bucket URL (e.g. s3://my-bucket/path)":"Bucket URL (e.g. gs://my-bucket/path)",type:"text",fullWidth:!0,size:"small"}),u==="s3"&&p.jsxs(p.Fragment,{children:[p.jsx(Sr,{variant:"caption",sx:{mt:2,mb:1,display:"block"},color:"text.secondary",children:"S3 Credentials"}),Sy.filter(T=>T.visibleWhen?g===T.visibleWhen.value:!0).map(T=>p.jsx(yr,{id:`ducklake_s3_${T.name}`,name:`ducklake_s3_${T.name}`,label:T.label,type:T.selectOptions?void 0:T.type,fullWidth:!0,size:"small",required:T.required,select:!!T.selectOptions,defaultValue:T.selectOptions?g:void 0,onChange:T.name==="provider"?O=>y(O.target.value):void 0,placeholder:T.name==="region"?"us-east-1":void 0,children:T.selectOptions?.map(O=>p.jsx(Vo,{value:O.value,children:O.label},O.value))},`s3_${T.name}`))]}),u==="gcs"&&p.jsxs(p.Fragment,{children:[p.jsx(Sr,{variant:"caption",sx:{mt:2,mb:1,display:"block"},color:"text.secondary",children:"GCS Credentials"}),Cy.map(T=>p.jsx(yr,{id:`ducklake_gcs_${T.name}`,name:`ducklake_gcs_${T.name}`,label:T.label,type:T.type,fullWidth:!0,size:"small",required:T.required},`gcs_${T.name}`))]})]})]}):o==="duckdb"?p.jsxs(Ta,{sx:{mt:2},children:[p.jsxs(Ta,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[p.jsx(Sr,{variant:"subtitle1",fontWeight:500,children:"Attached Databases"}),p.jsx(Xy,{label:"Database",icon:p.jsx(f1,{}),onClick:b,ariaLabel:"Add database"})]}),i.length===0&&p.jsx(Sr,{variant:"body2",color:"text.secondary",sx:{mb:2},children:'DuckDB connections require at least one attached database. Click "Add Database" to get started.'}),i.map((T,O)=>{const P=ex(T.dbType);return p.jsxs(Ta,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[p.jsxs(Ta,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[p.jsxs(Sr,{variant:"subtitle2",children:["Database ",O+1]}),p.jsx(Tu,{onClick:()=>$(O),size:"small",color:"error",children:p.jsx(a6,{fontSize:"small"})})]}),p.jsx(yr,{required:!0,id:`attachedDb_${O}_name`,name:`attachedDb_${O}_name`,label:"Database Name",type:"text",fullWidth:!0,size:"small",defaultValue:T.name}),p.jsx(yr,{id:`attachedDb_${O}_type`,name:`attachedDb_${O}_type`,label:"Database Type",fullWidth:!0,size:"small",value:T.dbType,select:!0,onChange:D=>k(O,D.target.value),children:Object.values($4).map(D=>p.jsx(Vo,{value:D,children:D},D))}),P.filter(D=>D.visibleWhen?(T[D.visibleWhen.field]||P.find(A=>A.name===D.visibleWhen?.field)?.selectOptions?.[0]?.value)===D.visibleWhen.value:!0).map(D=>p.jsx(yr,{id:`attachedDb_${O}_${D.name}`,name:`attachedDb_${O}_${D.name}`,label:D.label,type:D.selectOptions?void 0:D.type,fullWidth:!0,size:"small",required:D.required,select:!!D.selectOptions,defaultValue:D.selectOptions?.[0]?.value,onChange:D.selectOptions?A=>{const F=[...i];F[O]={...F[O],[D.name]:A.target.value},s(F)}:void 0,children:D.selectOptions?.map(A=>p.jsx(Vo,{value:A.value,children:A.label},A.value))},D.name))]},O)})]}):ac[o].map(T=>p.jsx(yr,{id:T.name,name:T.name,label:T.label,type:T.type,fullWidth:!0,size:"small",required:T.required,select:!!T.selectOptions,defaultValue:T.selectOptions?T.selectOptions[0]?.value:void 0,children:T.selectOptions?.map(O=>p.jsx(Vo,{value:O.value,children:O.label},O.value))},T.name))]})})})]})}function P1e({connection:e,onCloseDialog:t,isMutating:n,onDelete:r}){const[o,a]=C.useState(!1),i=()=>{a(!0)},s=()=>{a(!1),t()};return p.jsxs(kn.Fragment,{children:[p.jsxs(Vo,{"aria-label":`Delete connection ${e?.name??""}`.trim(),onClick:l=>{l.stopPropagation(),i()},sx:{color:"error.main"},children:[p.jsx(oT,{sx:{color:"inherit"},children:p.jsx(Zx,{fontSize:"small"})}),p.jsx(aT,{children:"Delete"})]}),p.jsx(Oo,{open:o,onClose:s,title:"Delete connection",actions:p.jsxs(p.Fragment,{children:[p.jsx(Co,{onClick:s,children:"Cancel"}),p.jsx(Co,{variant:"contained",color:"error",autoFocus:!0,onClick:()=>r(),loading:n,children:"Delete connection"})]}),children:p.jsxs(Sr,{variant:"body2",children:["Delete ",p.jsx("strong",{children:e.name}),"? Packages that query through it stop working, and this cannot be undone."]})})]})}const oI=new Set(["password","connectionString","privateKey","privateKeyPass","serviceAccountKeyJson","token","oauthClientSecret","accessToken","peakaKey","secret","secretAccessKey","sessionToken","clientSecret","sasUrl"]);function aI(e){const t=e.duckdbConnection?.attachedDatabases;return!t||t.length===0?[]:t.map(n=>({name:n.name||"",dbType:n.type||"postgres"}))}function iI(e){const t=e.ducklakeConnection;return t&&t.storage?.gcsConnection?"gcs":"s3"}function j1e({connection:e,onSubmit:t,isSubmitting:n,onCloseDialog:r}){const[o,a]=C.useState(!1),[i,s]=C.useState(e.type),l=kn.useMemo(()=>new Set(e.withheldFields??[]),[e.withheldFields]),[d,u]=C.useState(()=>aI(e)),[m,g]=C.useState("postgres"),[y,x]=C.useState(()=>iI(e)),[w,S]=C.useState(()=>e.ducklakeConnection?.storage?.s3Connection?.provider??"config"),b=()=>{u(aI(e)),s(e.type),S(e.ducklakeConnection?.storage?.s3Connection?.provider??"config"),g("postgres"),x(iI(e)),a(!0)},$=()=>{a(!1),r?.()},k=async F=>{F.preventDefault();const L=new FormData(F.currentTarget),_=L.get("name")?.toString(),R=L.get("type")?.toString(),z=ac[R];if(!_)throw new Error("Name is required");if(!R)throw new Error("Type is required");let N;if(R==="ducklake"){const B={};if(m==="postgres"){const Y=ac.postgres,ae={};if(Y.forEach(K=>{const oe=L.get(`ducklake_pg_${K.name}`)?.toString();oe&&(ae[K.name]=oe)}),Object.keys(ae).length===0)throw new Error("DuckLake requires catalog connection");B.postgresConnection=ae}const I=L.get("ducklake_bucketUrl")?.toString();if(!I)throw new Error("DuckLake requires a bucket URL");const H={bucketUrl:I};if(y==="s3"){const Y={};Sy.forEach(K=>{const oe=L.get(`ducklake_s3_${K.name}`)?.toString();oe&&(Y[K.name]=oe)});const ae=e.ducklakeConnection?.storage?.s3Connection;if(ae&&(!Y.provider&&ae.provider&&(Y.provider=ae.provider),!Y.chain&&ae.chain&&(Y.chain=ae.chain),!Y.accessKeyId&&ae.accessKeyId&&(Y.accessKeyId=ae.accessKeyId)),Y.provider==="credential_chain")delete Y.accessKeyId,delete Y.secretAccessKey,delete Y.sessionToken;else if(delete Y.chain,!Y.accessKeyId)throw new Error("S3 Access Key ID is required");Object.keys(Y).length>0&&(H.s3Connection=Y)}else if(y==="gcs"){const Y={};Cy.forEach(K=>{const oe=L.get(`ducklake_gcs_${K.name}`)?.toString();oe&&(Y[K.name]=oe)});const ae=e.ducklakeConnection?.storage?.gcsConnection;if(ae&&!Y.keyId&&ae.keyId&&(Y.keyId=ae.keyId),!Y.keyId)throw new Error("GCS Key ID is required");Object.keys(Y).length>0&&(H.gcsConnection=Y)}N={name:_,type:R,ducklakeConnection:{catalog:B,storage:H}}}else if(R==="duckdb"){if(d.length===0)throw new Error("DuckDB connection must have at least one attached database");const B=d.map((I,H)=>{const Y=I.dbType,ae=L.get(`attachedDb_${H}_name`)?.toString();if(!ae)throw new Error(`Attached database at index ${H} must have a name`);const K={name:ae,type:Y},oe=ex(Y);if(oe&&oe.length>0){const ue={};if(oe.forEach(ie=>{const Q=L.get(`attachedDb_${H}_${ie.name}`)?.toString();Q&&(ue[ie.name]=Q)}),Y==="s3"){if(ue.provider==="credential_chain")delete ue.accessKeyId,delete ue.secretAccessKey,delete ue.sessionToken;else if(delete ue.chain,!ue.accessKeyId||!ue.secretAccessKey)throw new Error(`Attached database "${ae}" requires an S3 Access Key ID and Secret Access Key, or Credential Provider set to the host credential chain`)}const G=C$[Y];G&&(K[G]=ue)}return K});N={name:_,type:R,duckdbConnection:{attachedDatabases:B}}}else{const B=e[Og[R]]||{},I={};if(z.forEach(H=>{const Y=L.get(H.name)?.toString(),ae=B[H.name];Y?I[H.name]=Y:oI.has(H.name)||(Y!==void 0?I[H.name]=Y:ae&&(I[H.name]=ae))}),R==="postgres"){const H=["host","port","databaseName","userName"],Y=l.has("postgresConnection.connectionString");if(!(I.connectionString?.trim()||Y)){const ae=H;for(const K of ae)if(!I[K])throw new Error(`${z.find(oe=>oe.name===K)?.label||K} is required`)}}else if(R==="snowflake"){if(!I.account)throw new Error("Account is required");if(!I.username)throw new Error("Username is required");if(!I.warehouse)throw new Error("Warehouse is required")}else if(R==="trino"){if(!I.server)throw new Error("Server is required");if(!I.user)throw new Error("User is required")}else if(R==="mysql"){const H=["host","port","database","user"];for(const Y of H)if(!I[Y])throw new Error(`${z.find(ae=>ae.name===Y)?.label||Y} is required`)}else if(R==="sqlserver"){const H=["server","database","user"];if(!I.instanceName&&!I.port)throw new Error("Port is required unless an instance name is given");for(const Y of H)if(!I[Y])throw new Error(`${z.find(ae=>ae.name===Y)?.label||Y} is required`)}else if(R==="databricks"){if(!I.host)throw new Error("Host is required");if(!I.path)throw new Error("HTTP Path is required")}N={name:_,type:R,[Og[R]]:i6(R,I)}}await t(N),$()},T=()=>{u([...d,{name:"",dbType:"postgres"}])},O=F=>{u(d.filter((L,_)=>_!==F))},P=(F,L)=>{const _=[...d];_[F]={..._[F],dbType:L},u(_)},D=(F,L)=>{const _=e.duckdbConnection?.attachedDatabases;if(!_||!_[F])return"";const R=_[F],z=C$[R.type||""];return z&&R[z]?R[z][L]??"":""},A=F=>{const L=e.ducklakeConnection;if(!L)return"";if(F.startsWith("pg_")){const _=F.replace("pg_","");return L.catalog?.postgresConnection?.[_]??""}if(F==="bucketUrl")return L.storage?.bucketUrl??"";if(F.startsWith("s3_")){const _=F.replace("s3_","");return L.storage?.s3Connection?.[_]??""}if(F.startsWith("gcs_")){const _=F.replace("gcs_","");return L.storage?.gcsConnection?.[_]??""}return""};return p.jsxs(kn.Fragment,{children:[p.jsxs(Vo,{"aria-label":`Edit connection ${e?.name??""}`.trim(),onClick:F=>{F.preventDefault(),F.stopPropagation(),b()},children:[p.jsx(oT,{children:p.jsx(r2,{fontSize:"small"})}),p.jsx(aT,{children:"Edit"})]}),p.jsx(Oo,{open:o,onClose:$,title:"Edit connection",description:"Change how packages in this environment reach your database.",actions:p.jsxs(p.Fragment,{children:[p.jsx(Co,{disabled:n,onClick:$,children:"Cancel"}),p.jsx(Co,{type:"submit",form:"connection-form",variant:"contained",loading:n,children:"Save changes"})]}),children:p.jsx("form",{onSubmit:k,id:"connection-form",children:p.jsxs(z1,{sx:{gap:2},children:[p.jsx(yr,{autoFocus:!0,required:!0,id:"name",name:"name",label:"Name",type:"text",fullWidth:!0,size:"small",defaultValue:e.name}),p.jsx(yr,{id:"type",name:"type",label:"Connection Type",fullWidth:!0,size:"small",value:i,select:!0,onChange:F=>s(F.target.value),children:s6.map(F=>p.jsx(Vo,{value:F,children:F},F))}),i==="ducklake"?p.jsxs(Ta,{sx:{mt:2},children:[p.jsxs(Ta,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[p.jsx(Sr,{variant:"subtitle2",sx:{mb:2},fontWeight:500,children:"Catalog"}),p.jsx(yr,{id:"ducklake_catalogType",label:"Catalog Type",fullWidth:!0,size:"small",value:m,select:!0,onChange:F=>g(F.target.value),children:p.jsx(Vo,{value:"postgres",children:"PostgreSQL"})}),m==="postgres"&&p.jsx(p.Fragment,{children:ac.postgres.map(F=>p.jsx(yr,{id:`ducklake_pg_${F.name}`,name:`ducklake_pg_${F.name}`,label:F.label,type:F.type,fullWidth:!0,size:"small",defaultValue:A(`pg_${F.name}`)},`pg_${F.name}`))})]}),p.jsxs(Ta,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[p.jsx(Sr,{variant:"subtitle2",sx:{mb:2},fontWeight:500,children:"Storage"}),p.jsxs(yr,{id:"ducklake_storageType",label:"Storage Type",fullWidth:!0,size:"small",value:y,select:!0,onChange:F=>x(F.target.value),children:[p.jsx(Vo,{value:"s3",children:"S3"}),p.jsx(Vo,{value:"gcs",children:"GCS"})]}),p.jsx(yr,{required:!0,id:"ducklake_bucketUrl",name:"ducklake_bucketUrl",label:y==="s3"?"Bucket URL (e.g. s3://my-bucket/path)":"Bucket URL (e.g. gs://my-bucket/path)",type:"text",fullWidth:!0,size:"small",defaultValue:A("bucketUrl")}),y==="s3"&&p.jsxs(p.Fragment,{children:[p.jsx(Sr,{variant:"caption",sx:{mt:2,mb:1,display:"block"},color:"text.secondary",children:"S3 Credentials"}),Sy.filter(F=>F.visibleWhen?w===F.visibleWhen.value:!0).map(F=>p.jsx(yr,{id:`ducklake_s3_${F.name}`,name:`ducklake_s3_${F.name}`,label:F.label,type:F.selectOptions?void 0:F.type,fullWidth:!0,size:"small",required:F.required&&F.name!=="secretAccessKey",select:!!F.selectOptions,defaultValue:F.selectOptions?w:A(`s3_${F.name}`),onChange:F.name==="provider"?L=>S(L.target.value):void 0,placeholder:F.name==="region"?"us-east-1":F.name==="secretAccessKey"&&l.has("ducklakeConnection.storage.s3Connection.secretAccessKey")?"Leave empty to keep existing":void 0,children:F.selectOptions?.map(L=>p.jsx(Vo,{value:L.value,children:L.label},L.value))},`s3_${F.name}`))]}),y==="gcs"&&p.jsxs(p.Fragment,{children:[p.jsx(Sr,{variant:"caption",sx:{mt:2,mb:1,display:"block"},color:"text.secondary",children:"GCS Credentials"}),Cy.map(F=>p.jsx(yr,{id:`ducklake_gcs_${F.name}`,name:`ducklake_gcs_${F.name}`,label:F.label,type:F.type,fullWidth:!0,size:"small",required:F.required&&F.name!=="secret",defaultValue:A(`gcs_${F.name}`),placeholder:F.name==="secret"&&l.has("ducklakeConnection.storage.gcsConnection.secret")?"Leave empty to keep existing":void 0},`gcs_${F.name}`))]})]})]}):i==="duckdb"?p.jsxs(Ta,{sx:{mt:2},children:[p.jsxs(Ta,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[p.jsx(Sr,{variant:"subtitle1",fontWeight:500,children:"Attached Databases"}),p.jsx(Xy,{label:"Database",icon:p.jsx(f1,{}),onClick:T,ariaLabel:"Add database"})]}),d.length===0&&p.jsx(Sr,{variant:"body2",color:"text.secondary",sx:{mb:2},children:'DuckDB connections require at least one attached database. Click "Add Database" to get started.'}),d.map((F,L)=>{const _=ex(F.dbType);return p.jsxs(Ta,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[p.jsxs(Ta,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[p.jsxs(Sr,{variant:"subtitle2",children:["Database ",L+1]}),p.jsx(Tu,{"aria-label":`Remove attached database ${L+1}`,onClick:()=>O(L),size:"small",color:"error",children:p.jsx(a6,{fontSize:"small"})})]}),p.jsx(yr,{required:!0,id:`attachedDb_${L}_name`,name:`attachedDb_${L}_name`,label:"Database Name",type:"text",fullWidth:!0,size:"small",defaultValue:F.name}),p.jsx(yr,{id:`attachedDb_${L}_type`,name:`attachedDb_${L}_type`,label:"Database Type",fullWidth:!0,size:"small",value:F.dbType,select:!0,onChange:R=>P(L,R.target.value),children:Object.values($4).map(R=>p.jsx(Vo,{value:R,children:R},R))}),_.filter(R=>R.visibleWhen?(F[R.visibleWhen.field]||D(L,R.visibleWhen.field)||_.find(z=>z.name===R.visibleWhen?.field)?.selectOptions?.[0]?.value)===R.visibleWhen.value:!0).map(R=>p.jsx(yr,{id:`attachedDb_${L}_${R.name}`,name:`attachedDb_${L}_${R.name}`,label:R.label,type:R.selectOptions?void 0:R.type,fullWidth:!0,size:"small",required:R.required,select:!!R.selectOptions,defaultValue:D(L,R.name)||R.selectOptions?.[0]?.value,onChange:R.selectOptions?z=>{const N=[...d];N[L]={...N[L],[R.name]:z.target.value},u(N)}:void 0,children:R.selectOptions?.map(z=>p.jsx(Vo,{value:z.value,children:z.label},z.value))},R.name))]},L)})]}):ac[i].map(F=>{const L=e?.[Og[i]??""]?.[F.name??""]??"",_=F.type==="password"||oI.has(F.name),R=l.has(`${Og[i]??""}.${F.name}`),z=F.selectOptions?L===""||L===void 0?F.selectOptions[0]?.value:String(L):void 0;return p.jsx(yr,{id:F.name,name:F.name,label:F.label,type:F.type,fullWidth:!0,size:"small",required:F.required&&!_&&!L,select:!!F.selectOptions,defaultValue:F.selectOptions?z:L,placeholder:R?"Leave empty to keep existing":void 0,helperText:_?R?"Stored value is not shown. Leave empty to keep it.":"No value stored.":void 0,children:F.selectOptions?.map(N=>p.jsx(Vo,{value:N.value,children:N.label},N.value))},F.name)})]})})})]})}function sI(e,t){return!e||e.type!=="duckdb"?!1:(e.duckdbConnection?.attachedDatabases||[]).some(n=>n.type==="azure"&&n.name===t)}function A1e(e){return e.startsWith("gs://")||e.startsWith("s3://")||e.startsWith("https://")||e.startsWith("abfss://")||e.startsWith("az://")}function D1e({connectionName:e,resourceUri:t,schema:n,connection:r}){const{apiClients:o}=tr(),{environmentName:a}=Xr(t),[i,s]=kn.useState(null),[l,d]=kn.useState(n||null),[u,m]=kn.useState(!1),{data:g,isError:y,isLoading:x,error:w}=co({queryKey:["schemas",a,e],queryFn:()=>o.connections.listSchemas(a,e)}),S=g?.data||[];return p.jsxs(Cp,{container:!0,spacing:1,children:[!n&&p.jsx(Cp,{size:{xs:12,md:4},children:p.jsxs(Qa,{sx:{p:1,m:0},children:[p.jsxs(Te,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:0},children:[p.jsx(wt,{variant:"overline",fontWeight:"bold",children:"Table Paths"}),p.jsx(MR,{control:p.jsx(Cz,{checked:u,onChange:b=>m(b.target.checked)}),label:"Hidden Schemas"})]}),p.jsx(wl,{sx:{mt:"2px"}}),p.jsxs(Te,{sx:{mt:"2px",maxHeight:"600px",overflowY:"auto"},children:[x&&p.jsx(Bo,{text:"Loading schemas..."}),y&&p.jsx(ja,{error:w,context:`${a} > ${e} > Schemas`}),!x&&!y&&S.length===0&&p.jsx(wt,{variant:"body2",children:"No Schemas"}),!x&&!y&&S.length>0&&p.jsx(AR,{dense:!0,disablePadding:!0,children:S.map(b=>{const $=b.name;return b.isHidden&&!u?null:p.jsx(mz,{selected:l===$,onClick:()=>{d($),s(null)},children:p.jsx(Ci,{primary:$})},$)})})]})]})}),p.jsx(Cp,{size:{xs:12,md:n?6:4},children:l&&p.jsx(Qa,{sx:{p:1,m:0},children:p.jsx(L1e,{connectionName:e,schemaName:l,onTableSelect:b=>{s(b)},resourceUri:t,connection:r})})}),p.jsx(Cp,{size:{xs:12,md:n?6:4},children:l&&i&&p.jsx(N1e,{environmentName:a,connectionName:e,schemaName:l,tableResource:i})})]})}function N1e({environmentName:e,connectionName:t,schemaName:n,tableResource:r}){const{apiClients:o}=tr(),{data:a,isLoading:i,isError:s,error:l}=co({queryKey:["connectionTableDetail",e,t,n,r],queryFn:()=>o.connections.getTable(e,t,n,r),enabled:!!n&&!!r}),d={resource:a?.data?.resource??r,columns:a?.data?.columns??[]};return p.jsxs(Qa,{sx:{p:1,m:0},children:[s&&p.jsx(ja,{error:l,context:`${e} > ${t} > ${n} > ${r}`}),!s&&p.jsx(I1e,{table:d,loading:i})]})}function I1e({table:e,loading:t}){return t?p.jsx(Bo,{text:"Loading columns..."}):p.jsxs(p.Fragment,{children:[p.jsxs(wt,{variant:"overline",fontWeight:"bold",sx:{display:"block",wordBreak:"break-all"},children:[e.resource.includes("://")||/\.(parquet|csv|json|tsv|ndjson)$/i.test(e.resource)?"File":"Table",": ",e.resource]}),p.jsx(wl,{}),p.jsx(Te,{sx:{mt:"10px",maxHeight:"600px",overflowY:"auto"},children:p.jsx(WJ,{children:p.jsxs(Bx,{size:"small",sx:{"& .MuiTableCell-root":{padding:"10px"}},children:[p.jsx(Hx,{children:p.jsxs(vu,{children:[p.jsx(dr,{children:"NAME"}),p.jsx(dr,{children:"TYPE"})]})}),p.jsx(qx,{children:e.columns?.sort((n,r)=>n.name.localeCompare(r.name))?.map(n=>p.jsxs(vu,{children:[p.jsx(dr,{children:n.name}),p.jsx(dr,{children:n.type})]},n.name))})]})})})]})}function L1e({connectionName:e,schemaName:t,onTableSelect:n,resourceUri:r,connection:o}){const{environmentName:a}=Xr(r),{apiClients:i}=tr(),[s,l]=C.useState(""),{data:d,isSuccess:u,isError:m,error:g,isLoading:y}=co({queryKey:["tablesInSchema",a,e,t],queryFn:()=>i.connections.listTables(a,e,t)}),x=sI(o,t),w=b=>x?b:b.split(".").pop()||b,S=u&&d?.data?d.data.filter(b=>w(b.resource).toLowerCase().includes(s.toLowerCase())).sort((b,$)=>w(b.resource).localeCompare(w($.resource))):[];return p.jsxs(p.Fragment,{children:[p.jsx(wt,{variant:"overline",fontWeight:"bold",children:A1e(t)||sI(o,t)?`Files in ${t}`:`Tables in ${t}`}),p.jsx(wl,{}),p.jsx(Te,{sx:{mt:1,mb:1},children:p.jsx(Ri,{size:"small",fullWidth:!0,placeholder:"Search tables...",value:s,onChange:b=>l(b.target.value),variant:"outlined"})}),p.jsx(wl,{}),p.jsxs(Te,{sx:{mt:"2px",maxHeight:"600px",overflowY:"auto"},children:[y&&p.jsx(Bo,{text:"Fetching Tables..."}),m&&p.jsx(ja,{error:g,context:`${a} > ${e} > ${t}`}),u&&S.length===0&&p.jsx(wt,{variant:"body2",children:"No Tables"}),u&&d?.data&&d.data.length>0&&p.jsx(AR,{dense:!0,disablePadding:!0,children:S.map(b=>{let $=w(b.resource);return!x&&b.resource.includes("://")&&($=b.resource.split("/").pop()||b.resource),p.jsx(mz,{onClick:()=>n(b.resource),children:p.jsx(Ci,{primary:$,secondary:b.columns.length>0?`${b.columns.length} columns`:void 0})},b.resource)})})]})]})}const z1e={bigquery:"BigQuery",snowflake:"Snowflake",postgres:"PostgreSQL",mysql:"MySQL",sqlserver:"SQL Server",trino:"Trino",databricks:"Databricks",duckdb:"DuckDB",ducklake:"DuckLake",s3:"S3",gcs:"GCS",azure:"Azure"};function F1e(e){return e?z1e[e]??e:""}function _1e({resourceUri:e}){const{apiClients:t,mutable:n}=tr(),r=Tl(),{environmentName:o}=Xr(e),[a,i]=C.useState(""),[s,l]=C.useState(null),d=I1({environmentName:o,connectionName:s}),{data:u,isSuccess:m,isError:g,error:y}=co({queryKey:["connections",o],queryFn:()=>t.connections.listConnections(o)}),x=hl({mutationFn:rc("connection","create",k=>t.environments.updateEnvironment(o,{name:o,connections:[...u.data,k]})),onSuccess(){i("Connection added successfully"),r.invalidateQueries({queryKey:["connections",o]})},onError(k){i(k.message)}}),w=hl({mutationFn:rc("connection","update",k=>t.environments.updateEnvironment(o,{name:o,connections:u.data.map(T=>T.name===k.name?k:T)})),onSuccess(k,T){i(`Connection ${T.name} updated successfully`),r.invalidateQueries({queryKey:["connections",o]})},onError(k){i(k.message)}}),S=hl({mutationFn:rc("connection","delete",k=>{if(!k.name)throw new Error("Cannot delete a connection with no name");return t.connections.deleteConnection(o,k.name)}),onSuccess(k,T){i(`Connection ${T.name} deleted successfully`),r.invalidateQueries({queryKey:["connections",o]})},onError(k){i(k.message)}}),b=m?[...u.data].sort((k,T)=>(k.name??"").localeCompare(T.name??"")):[],$=x.isPending||w.isPending||S.isPending;return p.jsxs(Ns,{title:"Connections",...m?{count:b.length}:{},description:"Database connections available to packages in this environment",...n&&m?{action:p.jsx(O1e,{onSubmit:k=>x.mutateAsync(k),isSubmitting:x.isPending})}:{},children:[!m&&!g&&p.jsx(wt,{variant:"body2",color:"text.secondary",children:"Fetching Connections..."}),g&&p.jsx(ja,{error:y,context:`${o} > Connections`}),m&&b.length===0&&p.jsx(wt,{variant:"body2",color:"text.secondary",children:"No connections yet."}),m&&b.length>0&&p.jsx(Yn,{children:b.map(k=>p.jsx(B1e,{connection:k,mutable:n,isMutating:$,onOpenExplorer:()=>l(k.name??null),onEdit:T=>w.mutateAsync(T),onDelete:T=>S.mutateAsync(T)},k.name))}),p.jsx(hh,{open:a!=="",autoHideDuration:6e3,onClose:()=>i(""),message:a}),p.jsx(Oo,{open:s!==null,onClose:()=>l(null),maxWidth:"lg",title:`Connection explorer: ${s??""}`,showClose:!0,children:s&&p.jsx(D1e,{resourceUri:d,connectionName:s,connection:u?.data?.find(k=>k.name===s)})})]})}function B1e({connection:e,mutable:t,isMutating:n,onOpenExplorer:r,onEdit:o,onDelete:a}){const[i,s]=C.useState(null),l=!!i,d=m=>{m.stopPropagation(),s(m.currentTarget)},u=()=>s(null);return p.jsx(L1,{icon:p.jsx(h1e,{sx:{fontSize:18}}),tint:ZR.connection,label:e.name??"",ariaLabel:e.name??"",description:F1e(e.type),onClick:r,...t?{trailingAction:p.jsxs(p.Fragment,{children:[p.jsx(ro,{size:"small",onClick:d,"aria-label":`Connection actions for ${e.name??""}`.trim(),children:p.jsx(Jx,{fontSize:"small"})}),p.jsxs(uc,{anchorEl:i,open:l,onClose:u,onClick:m=>m.stopPropagation(),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[p.jsx(j1e,{connection:e,onSubmit:o,isSubmitting:n,onCloseDialog:u}),p.jsx(P1e,{connection:e,onCloseDialog:u,isMutating:n,onDelete:()=>a(e)})]})]})}:{}})}const U1e=Jt([p.jsx("path",{d:"M20 2H4c-1 0-2 .9-2 2v3.01c0 .72.43 1.34 1 1.69V20c0 1.1 1.1 2 2 2h14c.9 0 2-.9 2-2V8.7c.57-.35 1-.97 1-1.69V4c0-1.1-1-2-2-2m-1 18H5V9h14zm1-13H4V4h16z"},"0"),p.jsx("path",{d:"M9 12h6v2H9z"},"1")]);function q1e({resourceUri:e,onCloseDialog:t}){const[n,r]=C.useState(!1),{apiClients:o}=tr(),a=()=>{r(!0)},i=()=>{r(!1),t()},{environmentName:s,packageName:l}=Xr(e),d=Ch({mutationFn:()=>o.packages.deletePackage(s,l),success:"Package deleted",invalidates:[["packages",s]],closeDialog:i,resource:"package",action:"delete"});return p.jsxs(kn.Fragment,{children:[p.jsxs(ea,{onClick:a,children:[p.jsx(ml,{children:p.jsx(Zx,{fontSize:"small"})}),p.jsx(Ci,{children:"Delete"})]}),p.jsx(Oo,{open:n,onClose:i,title:"Delete package",actions:p.jsxs(p.Fragment,{children:[p.jsx(Co,{onClick:i,children:"Cancel"}),p.jsx(Co,{variant:"contained",color:"error",autoFocus:!0,onClick:()=>d.mutate(),loading:d.isPending,children:"Delete package"})]}),children:p.jsxs(Sr,{variant:"body2",children:["Delete ",p.jsx("strong",{children:l}),"? The package stops being served and this cannot be undone."]})}),d.notice]})}function H1e({package:e,resourceUri:t,onCloseDialog:n}){const[r,o]=C.useState(!1),{apiClients:a}=tr(),i=()=>{o(!0)},s=()=>{o(!1),n()},{packageName:l,environmentName:d}=Xr(t),u=Ch({mutationFn(g){return a.packages.updatePackage(d,l,{name:l,description:g.description})},success:"Package updated",invalidates:[["packages",d]],closeDialog:s,resource:"package",action:"update"}),m=g=>{g.preventDefault();const y=new FormData(g.currentTarget).get("description")?.toString();u.mutate({description:y})};return p.jsxs(kn.Fragment,{children:[p.jsxs(ea,{onClick:i,children:[p.jsx(ml,{children:p.jsx(r2,{fontSize:"small"})}),p.jsx(Ci,{children:"Edit"})]}),p.jsx(Oo,{open:r,onClose:s,title:"Edit package",description:`What ${e.name} is, for the people who open it.`,actions:p.jsxs(p.Fragment,{children:[p.jsx(Co,{disabled:u.isPending,onClick:s,children:"Cancel"}),p.jsx(Co,{type:"submit",form:"package-form",variant:"contained",loading:u.isPending,children:"Save changes"})]}),children:p.jsx("form",{onSubmit:m,id:"package-form",children:p.jsxs(Yn,{sx:{gap:2},children:[p.jsx(yr,{autoFocus:!0,required:!0,id:"name",name:"name",label:"Name",disabled:!0,type:"text",fullWidth:!0,size:"small",defaultValue:e.name,InputLabelProps:{shrink:!0}}),p.jsx(yr,{id:"description",name:"description",label:"Description",multiline:!0,fullWidth:!0,rows:4,size:"small",defaultValue:e.description,InputLabelProps:{shrink:!0}})]})})}),u.notice]})}function V1e({onSelectPackage:e,resourceUri:t}){const{apiClients:n}=tr(),{environmentName:r}=Xr(t),{data:o,isSuccess:a,isError:i,error:s}=co({queryKey:["packages",r],queryFn:()=>n.packages.listPackages(r)});if(i)return p.jsx(ja,{error:s,context:`${r} > Packages`});if(!a)return p.jsx(Bo,{text:"Fetching Packages..."});const l=[...o.data].sort((d,u)=>d.name.localeCompare(u.name));return p.jsx(Yn,{children:l.map(d=>{const u=I1({environmentName:r,packageName:d.name});return p.jsx(W1e,{pkg:d,packageResourceUri:u,onSelectPackage:e},d.name)})})}function W1e({pkg:e,packageResourceUri:t,onSelectPackage:n}){const{mutable:r}=tr(),o=e.versionId!==void 0||e.latestVersion!==void 0,[a,i]=C.useState(null),s=!!a,l=u=>{u.stopPropagation(),i(u.currentTarget)},d=()=>i(null);return p.jsx(L1,{icon:p.jsx(U1e,{sx:{fontSize:18}}),tint:ZR.package,label:e.name,ariaLabel:e.name,...e.description?{description:e.description}:{},onClick:u=>n(e.name,u),...r?{trailingAction:p.jsxs(p.Fragment,{children:[p.jsx(ro,{size:"small",onClick:l,"aria-label":`Package actions for ${e.name}`,children:p.jsx(Jx,{fontSize:"small"})}),p.jsxs(uc,{anchorEl:a,open:s,onClose:d,onClick:u=>u.stopPropagation(),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[!o&&p.jsx(H1e,{package:e,resourceUri:t,onCloseDialog:d}),p.jsx(q1e,{resourceUri:t,onCloseDialog:d})]})]})}:{}})}function WTe({onSelectPackage:e,resourceUri:t}){const{apiClients:n,mutable:r}=tr(),{environmentName:o}=Xr(t),a=co({queryKey:["packages",o],queryFn:()=>n.packages.listPackages(o)});return C.useEffect(()=>{window.scrollTo({top:0,behavior:"auto"})},[]),p.jsxs(O0,{maxWidth:!1,sx:{maxWidth:1024,mx:"auto",px:3,py:6},children:[p.jsxs(Te,{sx:{mb:4},children:[p.jsx(wt,{variant:"h4",component:"h1",sx:{fontWeight:600,letterSpacing:"-0.025em",mb:.5},children:o}),p.jsx(wt,{variant:"body2",color:"text.secondary",children:"Manage packages and database connections in this environment. Open a package to explore its models and notebooks."})]}),p.jsx(Ns,{title:"Packages",...a.isSuccess?{count:a.data.data.length}:{},description:"Published packages available for use in this environment",...r?{action:p.jsx(p1e,{resourceUri:t})}:{},children:p.jsx(V1e,{onSelectPackage:e,resourceUri:t})}),p.jsx(_1e,{resourceUri:t}),p.jsx(Zxe,{resourceUri:t})]})}function lI({array1:e,array2:t,parser:n=r=>r}){return e&&t&&e.length===t.length&&e.every((r,o)=>n(r)===n(t[o]))}function cI(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"")}function Y1e(e={}){const{ignoreAccents:t=!0,ignoreCase:n=!0,limit:r,matchFrom:o="any",stringify:a,trim:i=!1}=e;return(s,{inputValue:l,getOptionLabel:d})=>{let u=i?l.trim():l;n&&(u=u.toLowerCase()),t&&(u=cI(u));const m=u?s.filter(g=>{let y=(a||d)(g);return n&&(y=y.toLowerCase()),t&&(y=cI(y)),o==="start"?y.startsWith(u):y.includes(u)}):s;return typeof r=="number"?m.slice(0,r):m}}const G1e=Y1e(),uI=5,K1e=e=>e.current!==null&&e.current.parentElement?.contains(document.activeElement),Q1e=[];function dI(e,t,n,r){if(t||e==null||r)return"";const o=n(e);return typeof o=="string"?o:""}function X1e(e){const{unstable_isActiveElementInListbox:t=K1e,unstable_classNamePrefix:n="Mui",autoComplete:r=!1,autoHighlight:o=!1,autoSelect:a=!1,blurOnSelect:i=!1,clearOnBlur:s=!e.freeSolo,clearOnEscape:l=!1,componentName:d="useAutocomplete",defaultValue:u=e.multiple?Q1e:null,disableClearable:m=!1,disableCloseOnSelect:g=!1,disabled:y,disabledItemsFocusable:x=!1,disableListWrap:w=!1,filterOptions:S=G1e,filterSelectedOptions:b=!1,freeSolo:$=!1,getOptionDisabled:k,getOptionKey:T,getOptionLabel:O=ge=>ge.label??ge,groupBy:P,handleHomeEndKeys:D=!e.freeSolo,id:A,includeInputInList:F=!1,inputValue:L,isOptionEqualToValue:_=(ge,ye)=>ge===ye,multiple:R=!1,onChange:z,onClose:N,onHighlightChange:B,onInputChange:I,onOpen:H,open:Y,openOnFocus:ae=!1,options:K,readOnly:oe=!1,renderValue:ue,selectOnFocus:G=!e.freeSolo,value:ie}=e,Q=_s(A);let ee=O;ee=ge=>{const ye=O(ge);return typeof ye!="string"?String(ye):ye};const Z=C.useRef(!1),de=C.useRef(!0),le=C.useRef(null),fe=C.useRef(null),[he,me]=C.useState(null),[se,ve]=C.useState(-1),Le=o?0:-1,Ae=C.useRef(Le),Re=C.useRef(dI(u??ie,R,ee)).current,[re,_e]=Ti({controlled:ie,default:u,name:d}),[Me,Ge]=Ti({controlled:L,default:Re,name:d,state:"inputValue"}),[Je,St]=C.useState(!1),Ut=C.useCallback((ge,ye,Ue)=>{if(!(R?re.length<ye.length:ye!==null)&&!s)return;const gt=dI(ye,R,ee,ue);Me!==gt&&(Ge(gt),I&&I(ge,gt,Ue))},[ee,Me,R,I,Ge,s,re,ue]),[at,tt]=Ti({controlled:Y,default:!1,name:d,state:"open"}),[pt,ze]=C.useState(!0),be=!R&&re!=null&&Me===ee(re),Ve=at&&!oe,Oe=Ve?S(K.filter(ge=>!(b&&(R?re:[re]).some(ye=>ye!==null&&_(ge,ye)))),{inputValue:be&&pt?"":Me,getOptionLabel:ee}):[],$t=Pxe({filteredOptions:Oe,value:re,inputValue:Me});C.useEffect(()=>{const ge=re!==$t.value;Je&&!ge||$&&!ge||Ut(null,re,"reset")},[re,Ut,Je,$t.value,$]);const Rt=at&&Oe.length>0&&!oe,vt=Yt(ge=>{if(ge===-1)le.current.focus();else{const ye=ue?"data-item-index":"data-tag-index";he.querySelector(`[${ye}="${ge}"]`).focus()}});C.useEffect(()=>{R&&se>re.length-1&&(ve(-1),vt(-1))},[re,R,se,vt]);function it(ge,ye){if(!fe.current||ge<0||ge>=Oe.length)return-1;let Ue=ge;for(;;){const gt=fe.current.querySelector(`[data-option-index="${Ue}"]`),We=x?!1:!gt||gt.disabled||gt.getAttribute("aria-disabled")==="true";if(gt&>.hasAttribute("tabindex")&&!We)return Ue;if(ye==="next"?Ue=(Ue+1)%Oe.length:Ue=(Ue-1+Oe.length)%Oe.length,Ue===ge)return-1}}const st=Yt(({event:ge,index:ye,reason:Ue})=>{if(Ae.current=ye,ye===-1?le.current.removeAttribute("aria-activedescendant"):le.current.setAttribute("aria-activedescendant",`${Q}-option-${ye}`),B&&["mouse","keyboard","touch"].includes(Ue)&&B(ge,ye===-1?null:Oe[ye],Ue),!fe.current)return;const gt=fe.current.querySelector(`[role="option"].${n}-focused`);gt&&(gt.classList.remove(`${n}-focused`),gt.classList.remove(`${n}-focusVisible`));let We=fe.current;if(fe.current.getAttribute("role")!=="listbox"&&(We=fe.current.parentElement.querySelector('[role="listbox"]')),!We)return;if(ye===-1){We.scrollTop=0;return}const Nt=fe.current.querySelector(`[data-option-index="${ye}"]`);if(Nt&&(Nt.classList.add(`${n}-focused`),Ue==="keyboard"&&Nt.classList.add(`${n}-focusVisible`),We.scrollHeight>We.clientHeight&&Ue!=="mouse"&&Ue!=="touch")){const Kt=Nt,hn=We.clientHeight+We.scrollTop,we=Kt.offsetTop+Kt.offsetHeight;we>hn?We.scrollTop=we-We.clientHeight:Kt.offsetTop-Kt.offsetHeight*(P?1.3:0)<We.scrollTop&&(We.scrollTop=Kt.offsetTop-Kt.offsetHeight*(P?1.3:0))}}),Dt=Yt(({event:ge,diff:ye,direction:Ue="next",reason:gt})=>{if(!Ve)return;const We=it((()=>{const Nt=Oe.length-1;if(ye==="reset")return Le;if(ye==="start")return 0;if(ye==="end")return Nt;const Kt=Ae.current+ye;return Kt<0?Kt===-1&&F?-1:w&&Ae.current!==-1||Math.abs(ye)>1?0:Nt:Kt>Nt?Kt===Nt+1&&F?-1:w||Math.abs(ye)>1?Nt:0:Kt})(),Ue);if(st({index:We,reason:gt,event:ge}),r&&ye!=="reset")if(We===-1)le.current.value=Me;else{const Nt=ee(Oe[We]);le.current.value=Nt,Nt.toLowerCase().indexOf(Me.toLowerCase())===0&&Me.length>0&&le.current.setSelectionRange(Me.length,Nt.length)}}),nn=!lI({array1:$t.filteredOptions,array2:Oe,parser:ee}),Bt=()=>{const ge=(ye,Ue)=>{const gt=ye?ee(ye):"",We=Ue?ee(Ue):"";return gt===We};if(Ae.current!==-1&&!lI({array1:$t.filteredOptions,array2:Oe,parser:ee})&&$t.inputValue===Me&&(R?re.length===$t.value.length&&$t.value.every((ye,Ue)=>ee(re[Ue])===ee(ye)):ge($t.value,re))){const ye=$t.filteredOptions[Ae.current];if(ye)return Oe.findIndex(Ue=>ee(Ue)===ee(ye))}return-1},pn=C.useCallback(()=>{if(!Ve)return;const ge=Bt();if(ge!==-1){Ae.current=ge;return}const ye=R?re[0]:re;if(Oe.length===0||ye==null){Dt({diff:"reset"});return}if(fe.current){if(ye!=null){const Ue=Oe[Ae.current];if(R&&Ue&&re.findIndex(We=>_(Ue,We))!==-1)return;const gt=Oe.findIndex(We=>_(We,ye));gt===-1?Dt({diff:"reset"}):st({index:gt});return}if(Ae.current>=Oe.length-1){st({index:Oe.length-1});return}st({index:Ae.current})}},[Oe.length,R?!1:re,b,Dt,st,Ve,Me,R]),$n=Yt(ge=>{Vk(fe,ge),ge&&pn()});C.useEffect(()=>{nn&&pn()},[pn,nn]);const qt=ge=>{at||(tt(!0),ze(!0),H&&H(ge))},Pn=(ge,ye)=>{at&&(tt(!1),N&&N(ge,ye))},Se=(ge,ye,Ue,gt)=>{if(R){if(re.length===ye.length&&re.every((We,Nt)=>We===ye[Nt]))return}else if(re===ye)return;z&&z(ge,ye,Ue,gt),_e(ye)},jn=C.useRef(!1),Rn=(ge,ye,Ue="selectOption",gt="options")=>{let We=Ue,Nt=ye;if(R){Nt=Array.isArray(re)?re.slice():[];const Kt=Nt.findIndex(hn=>_(ye,hn));Kt===-1?Nt.push(ye):gt!=="freeSolo"&&(Nt.splice(Kt,1),We="removeOption")}Ut(ge,Nt,We),Se(ge,Nt,We,{option:ye}),!g&&(!ge||!ge.ctrlKey&&!ge.metaKey)&&Pn(ge,We),(i===!0||i==="touch"&&jn.current||i==="mouse"&&!jn.current)&&le.current.blur()};function en(ge,ye){if(ge===-1)return-1;let Ue=ge;for(;;){if(ye==="next"&&Ue===re.length||ye==="previous"&&Ue===-1)return-1;const gt=ue?"data-item-index":"data-tag-index",We=he.querySelector(`[${gt}="${Ue}"]`);if(!We||!We.hasAttribute("tabindex")||We.disabled||We.getAttribute("aria-disabled")==="true")Ue+=ye==="next"?1:-1;else return Ue}}const jt=(ge,ye)=>{if(!R)return;Me===""&&Pn(ge,"toggleInput");let Ue=se;se===-1?Me===""&&ye==="previous"&&(Ue=re.length-1):(Ue+=ye==="next"?1:-1,Ue<0&&(Ue=0),Ue===re.length&&(Ue=-1)),Ue=en(Ue,ye),ve(Ue),vt(Ue)},Ur=ge=>{Z.current=!0,Ge(""),I&&I(ge,"","clear"),Se(ge,R?[]:null,"clear")},qn=ge=>ye=>{if(ge.onKeyDown&&ge.onKeyDown(ye),!ye.defaultMuiPrevented&&(se!==-1&&!["ArrowLeft","ArrowRight"].includes(ye.key)&&(ve(-1),vt(-1)),ye.which!==229))switch(ye.key){case"Home":Ve&&D&&(ye.preventDefault(),Dt({diff:"start",direction:"next",reason:"keyboard",event:ye}));break;case"End":Ve&&D&&(ye.preventDefault(),Dt({diff:"end",direction:"previous",reason:"keyboard",event:ye}));break;case"PageUp":ye.preventDefault(),Dt({diff:-uI,direction:"previous",reason:"keyboard",event:ye}),qt(ye);break;case"PageDown":ye.preventDefault(),Dt({diff:uI,direction:"next",reason:"keyboard",event:ye}),qt(ye);break;case"ArrowDown":ye.preventDefault(),Dt({diff:1,direction:"next",reason:"keyboard",event:ye}),qt(ye);break;case"ArrowUp":ye.preventDefault(),Dt({diff:-1,direction:"previous",reason:"keyboard",event:ye}),qt(ye);break;case"ArrowLeft":!R&&ue?vt(0):jt(ye,"previous");break;case"ArrowRight":!R&&ue?vt(-1):jt(ye,"next");break;case"Enter":if(Ae.current!==-1&&Ve){const Ue=Oe[Ae.current],gt=k?k(Ue):!1;if(ye.preventDefault(),gt)return;Rn(ye,Ue,"selectOption"),r&&le.current.setSelectionRange(le.current.value.length,le.current.value.length)}else $&&Me!==""&&be===!1&&(R&&ye.preventDefault(),Rn(ye,Me,"createOption","freeSolo"));break;case"Escape":Ve?(ye.preventDefault(),ye.stopPropagation(),Pn(ye,"escape")):l&&(Me!==""||R&&re.length>0||ue)&&(ye.preventDefault(),ye.stopPropagation(),Ur(ye));break;case"Backspace":if(R&&!oe&&Me===""&&re.length>0){const Ue=se===-1?re.length-1:se,gt=re.slice();gt.splice(Ue,1),Se(ye,gt,"removeOption",{option:re[Ue]})}!R&&ue&&!oe&&(_e(null),vt(-1));break;case"Delete":if(R&&!oe&&Me===""&&re.length>0&&se!==-1){const Ue=se,gt=re.slice();gt.splice(Ue,1),Se(ye,gt,"removeOption",{option:re[Ue]})}!R&&ue&&!oe&&(_e(null),vt(-1));break}},mn=ge=>{St(!0),ae&&!Z.current&&qt(ge)},Bn=ge=>{if(t(fe)){le.current.focus();return}St(!1),de.current=!0,Z.current=!1,a&&Ae.current!==-1&&Ve?Rn(ge,Oe[Ae.current],"blur"):a&&$&&Me!==""?Rn(ge,Me,"blur","freeSolo"):s&&Ut(ge,re,"blur"),Pn(ge,"blur")},xe=ge=>{const ye=ge.target.value;Me!==ye&&(Ge(ye),ze(!1),I&&I(ge,ye,"input")),ye===""?!m&&!R&&Se(ge,null,"clear"):qt(ge)},Ee=ge=>{const ye=Number(ge.currentTarget.getAttribute("data-option-index"));Ae.current!==ye&&st({event:ge,index:ye,reason:"mouse"})},Be=ge=>{st({event:ge,index:Number(ge.currentTarget.getAttribute("data-option-index")),reason:"touch"}),jn.current=!0},Ye=ge=>{const ye=Number(ge.currentTarget.getAttribute("data-option-index"));Rn(ge,Oe[ye],"selectOption"),jn.current=!1},ut=ge=>ye=>{const Ue=re.slice();Ue.splice(ge,1),Se(ye,Ue,"removeOption",{option:re[ge]})},Et=ge=>{Se(ge,null,"removeOption",{option:re})},Ct=ge=>{at?Pn(ge,"toggleInput"):qt(ge)},Mt=ge=>{ge.currentTarget.contains(ge.target)&&ge.target.getAttribute("id")!==Q&&ge.preventDefault()},Lt=ge=>{ge.currentTarget.contains(ge.target)&&(le.current.focus(),G&&de.current&&le.current.selectionEnd-le.current.selectionStart===0&&le.current.select(),de.current=!1)},Xt=ge=>{!y&&(Me===""||!at)&&Ct(ge)};let zt=$&&Me.length>0;zt=zt||(R?re.length>0:re!==null);let Vt=Oe;return P&&(Vt=Oe.reduce((ge,ye,Ue)=>{const gt=P(ye);return ge.length>0&&ge[ge.length-1].group===gt?ge[ge.length-1].options.push(ye):ge.push({key:Ue,index:Ue,group:gt,options:[ye]}),ge},[])),y&&Je&&Bn(),{getRootProps:(ge={})=>({...ge,onKeyDown:qn(ge),onMouseDown:Mt,onClick:Lt}),getInputLabelProps:()=>({id:`${Q}-label`,htmlFor:Q}),getInputProps:()=>({id:Q,value:Me,onBlur:Bn,onFocus:mn,onChange:xe,onMouseDown:Xt,"aria-activedescendant":Ve?"":null,"aria-autocomplete":r?"both":"list","aria-controls":Rt?`${Q}-listbox`:void 0,"aria-expanded":Rt,autoComplete:"off",ref:le,autoCapitalize:"none",spellCheck:"false",role:"combobox",disabled:y}),getClearProps:()=>({tabIndex:-1,type:"button",onClick:Ur}),getItemProps:({index:ge=0}={})=>({...R&&{key:ge},...ue?{"data-item-index":ge}:{"data-tag-index":ge},tabIndex:-1,...!oe&&{onDelete:R?ut(ge):Et}}),getPopupIndicatorProps:()=>({tabIndex:-1,type:"button",onClick:Ct}),getTagProps:({index:ge})=>({key:ge,"data-tag-index":ge,tabIndex:-1,...!oe&&{onDelete:ut(ge)}}),getListboxProps:()=>({role:"listbox",id:`${Q}-listbox`,"aria-labelledby":`${Q}-label`,ref:$n,onMouseDown:ge=>{ge.preventDefault()}}),getOptionProps:({index:ge,option:ye})=>{const Ue=(R?re:[re]).some(We=>We!=null&&_(ye,We)),gt=k?k(ye):!1;return{key:T?.(ye)??ee(ye),tabIndex:-1,role:"option",id:`${Q}-option-${ge}`,onMouseMove:Ee,onClick:Ye,onTouchStart:Be,"data-option-index":ge,"aria-disabled":gt,"aria-selected":Ue}},id:Q,inputValue:Me,value:re,dirty:zt,expanded:Ve&&he,popupOpen:Ve,focused:Je||se!==-1,anchorEl:he,setAnchorEl:me,focusedItem:se,focusedTag:se,groupedOptions:Vt}}function Z1e(e){return Cn("MuiListSubheader",e)}fn("MuiListSubheader",["root","colorPrimary","colorInherit","gutters","inset","sticky"]);const J1e=e=>{const{classes:t,color:n,disableGutters:r,inset:o,disableSticky:a}=e,i={root:["root",n!=="default"&&`color${Tt(n)}`,!r&&"gutters",o&&"inset",!a&&"sticky"]};return bn(i,Z1e,t)},ewe=nt("li",{name:"MuiListSubheader",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.root,n.color!=="default"&&t[`color${Tt(n.color)}`],!n.disableGutters&&t.gutters,n.inset&&t.inset,!n.disableSticky&&t.sticky]}})(Gn(({theme:e})=>({boxSizing:"border-box",lineHeight:"48px",listStyle:"none",color:(e.vars||e).palette.text.secondary,fontFamily:e.typography.fontFamily,fontWeight:e.typography.fontWeightMedium,fontSize:e.typography.pxToRem(14),variants:[{props:{color:"primary"},style:{color:(e.vars||e).palette.primary.main}},{props:{color:"inherit"},style:{color:"inherit"}},{props:({ownerState:t})=>!t.disableGutters,style:{paddingLeft:16,paddingRight:16}},{props:({ownerState:t})=>t.inset,style:{paddingLeft:72}},{props:({ownerState:t})=>!t.disableSticky,style:{position:"sticky",top:0,zIndex:1,backgroundColor:(e.vars||e).palette.background.paper}}]}))),k$=C.forwardRef(function(e,t){const n=Kn({props:e,name:"MuiListSubheader"}),{className:r,color:o="default",component:a="li",disableGutters:i=!1,disableSticky:s=!1,inset:l=!1,...d}=n,u={...n,color:o,component:a,disableGutters:i,disableSticky:s,inset:l},m=J1e(u);return p.jsx(ewe,{as:a,className:Ht(m.root,r),ref:t,ownerState:u,...d})});k$&&(k$.muiSkipListHighlight=!0);const twe=Jt(p.jsx("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"}));function nwe(e){return Cn("MuiAutocomplete",e)}const Jn=fn("MuiAutocomplete",["root","expanded","fullWidth","focused","focusVisible","tag","tagSizeSmall","tagSizeMedium","hasPopupIcon","hasClearIcon","inputRoot","input","inputFocused","endAdornment","clearIndicator","popupIndicator","popupIndicatorOpen","popper","popperDisablePortal","paper","listbox","loading","noOptions","option","groupLabel","groupUl"]);var fI,pI;const rwe=e=>{const{classes:t,disablePortal:n,expanded:r,focused:o,fullWidth:a,hasClearIcon:i,hasPopupIcon:s,inputFocused:l,popupOpen:d,size:u}=e,m={root:["root",r&&"expanded",o&&"focused",a&&"fullWidth",i&&"hasClearIcon",s&&"hasPopupIcon"],inputRoot:["inputRoot"],input:["input",l&&"inputFocused"],tag:["tag",`tagSize${Tt(u)}`],endAdornment:["endAdornment"],clearIndicator:["clearIndicator"],popupIndicator:["popupIndicator",d&&"popupIndicatorOpen"],popper:["popper",n&&"popperDisablePortal"],paper:["paper"],listbox:["listbox"],loading:["loading"],noOptions:["noOptions"],option:["option"],groupLabel:["groupLabel"],groupUl:["groupUl"]};return bn(m,nwe,t)},owe=nt("div",{name:"MuiAutocomplete",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:n}=e,{fullWidth:r,hasClearIcon:o,hasPopupIcon:a,inputFocused:i,size:s}=n;return[{[`& .${Jn.tag}`]:t.tag},{[`& .${Jn.tag}`]:t[`tagSize${Tt(s)}`]},{[`& .${Jn.inputRoot}`]:t.inputRoot},{[`& .${Jn.input}`]:t.input},{[`& .${Jn.input}`]:i&&t.inputFocused},t.root,r&&t.fullWidth,a&&t.hasPopupIcon,o&&t.hasClearIcon]}})({[`&.${Jn.focused} .${Jn.clearIndicator}`]:{visibility:"visible"},"@media (pointer: fine)":{[`&:hover .${Jn.clearIndicator}`]:{visibility:"visible"}},[`& .${Jn.tag}`]:{margin:3,maxWidth:"calc(100% - 6px)"},[`& .${Jn.inputRoot}`]:{[`.${Jn.hasPopupIcon}&, .${Jn.hasClearIcon}&`]:{paddingRight:30},[`.${Jn.hasPopupIcon}.${Jn.hasClearIcon}&`]:{paddingRight:56},[`& .${Jn.input}`]:{width:0,minWidth:30}},[`& .${au.root}`]:{paddingBottom:1,"& .MuiInput-input":{padding:"4px 4px 4px 0px"}},[`& .${au.root}.${bi.sizeSmall}`]:{[`& .${au.input}`]:{padding:"2px 4px 3px 0"}},[`& .${Wi.root}`]:{padding:9,[`.${Jn.hasPopupIcon}&, .${Jn.hasClearIcon}&`]:{paddingRight:39},[`.${Jn.hasPopupIcon}.${Jn.hasClearIcon}&`]:{paddingRight:65},[`& .${Jn.input}`]:{padding:"7.5px 4px 7.5px 5px"},[`& .${Jn.endAdornment}`]:{right:9}},[`& .${Wi.root}.${bi.sizeSmall}`]:{paddingTop:6,paddingBottom:6,paddingLeft:6,[`& .${Jn.input}`]:{padding:"2.5px 4px 2.5px 8px"}},[`& .${xi.root}`]:{paddingTop:19,paddingLeft:8,[`.${Jn.hasPopupIcon}&, .${Jn.hasClearIcon}&`]:{paddingRight:39},[`.${Jn.hasPopupIcon}.${Jn.hasClearIcon}&`]:{paddingRight:65},[`& .${xi.input}`]:{padding:"7px 4px"},[`& .${Jn.endAdornment}`]:{right:9}},[`& .${xi.root}.${bi.sizeSmall}`]:{paddingBottom:1,[`& .${xi.input}`]:{padding:"2.5px 4px"}},[`& .${bi.hiddenLabel}`]:{paddingTop:8},[`& .${xi.root}.${bi.hiddenLabel}`]:{paddingTop:0,paddingBottom:0,[`& .${Jn.input}`]:{paddingTop:16,paddingBottom:17}},[`& .${xi.root}.${bi.hiddenLabel}.${bi.sizeSmall}`]:{[`& .${Jn.input}`]:{paddingTop:8,paddingBottom:9}},[`& .${Jn.input}`]:{flexGrow:1,textOverflow:"ellipsis",opacity:0},variants:[{props:{fullWidth:!0},style:{width:"100%"}},{props:{size:"small"},style:{[`& .${Jn.tag}`]:{margin:2,maxWidth:"calc(100% - 4px)"}}},{props:{inputFocused:!0},style:{[`& .${Jn.input}`]:{opacity:1}}},{props:{multiple:!0},style:{[`& .${Jn.inputRoot}`]:{flexWrap:"wrap"}}}]}),awe=nt("div",{name:"MuiAutocomplete",slot:"EndAdornment"})({position:"absolute",right:0,top:"50%",transform:"translate(0, -50%)"}),iwe=nt(Tu,{name:"MuiAutocomplete",slot:"ClearIndicator"})({marginRight:-2,padding:4,visibility:"hidden"}),swe=nt(Tu,{name:"MuiAutocomplete",slot:"PopupIndicator",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.popupIndicator,n.popupOpen&&t.popupIndicatorOpen]}})({padding:2,marginRight:-2,variants:[{props:{popupOpen:!0},style:{transform:"rotate(180deg)"}}]}),lwe=nt(L2,{name:"MuiAutocomplete",slot:"Popper",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[{[`& .${Jn.option}`]:t.option},t.popper,n.disablePortal&&t.popperDisablePortal]}})(Gn(({theme:e})=>({zIndex:(e.vars||e).zIndex.modal,variants:[{props:{disablePortal:!0},style:{position:"absolute"}}]}))),cwe=nt(tf,{name:"MuiAutocomplete",slot:"Paper"})(Gn(({theme:e})=>({...e.typography.body1,overflow:"auto"}))),uwe=nt("div",{name:"MuiAutocomplete",slot:"Loading"})(Gn(({theme:e})=>({color:(e.vars||e).palette.text.secondary,padding:"14px 16px"}))),dwe=nt("div",{name:"MuiAutocomplete",slot:"NoOptions"})(Gn(({theme:e})=>({color:(e.vars||e).palette.text.secondary,padding:"14px 16px"}))),fwe=nt("ul",{name:"MuiAutocomplete",slot:"Listbox"})(Gn(({theme:e})=>({listStyle:"none",margin:0,padding:"8px 0",maxHeight:"40vh",overflow:"auto",position:"relative",[`& .${Jn.option}`]:{minHeight:48,display:"flex",overflow:"hidden",justifyContent:"flex-start",alignItems:"center",cursor:"pointer",paddingTop:6,boxSizing:"border-box",outline:"0",WebkitTapHighlightColor:"transparent",paddingBottom:6,paddingLeft:16,paddingRight:16,[e.breakpoints.up("sm")]:{minHeight:"auto"},[`&.${Jn.focused}`]:{backgroundColor:(e.vars||e).palette.action.hover,"@media (hover: none)":{backgroundColor:"transparent"}},'&[aria-disabled="true"]':{opacity:(e.vars||e).palette.action.disabledOpacity,pointerEvents:"none"},[`&.${Jn.focusVisible}`]:{backgroundColor:(e.vars||e).palette.action.focus},'&[aria-selected="true"]':{backgroundColor:e.alpha((e.vars||e).palette.primary.main,(e.vars||e).palette.action.selectedOpacity),[`&.${Jn.focused}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.hoverOpacity}`),"@media (hover: none)":{backgroundColor:(e.vars||e).palette.action.selected}},[`&.${Jn.focusVisible}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.focusOpacity}`)}}}}))),pwe=nt(k$,{name:"MuiAutocomplete",slot:"GroupLabel"})(Gn(({theme:e})=>({backgroundColor:(e.vars||e).palette.background.paper,top:-8}))),hwe=nt("ul",{name:"MuiAutocomplete",slot:"GroupUl"})({padding:0,[`& .${Jn.option}`]:{paddingLeft:24}}),mwe=C.forwardRef(function(e,t){const n=Kn({props:e,name:"MuiAutocomplete"}),{autoComplete:r=!1,autoHighlight:o=!1,autoSelect:a=!1,blurOnSelect:i=!1,ChipProps:s,className:l,clearIcon:d=fI||(fI=p.jsx(twe,{fontSize:"small"})),clearOnBlur:u=!n.freeSolo,clearOnEscape:m=!1,clearText:g="Clear",closeText:y="Close",componentsProps:x,defaultValue:w=n.multiple?[]:null,disableClearable:S=!1,disableCloseOnSelect:b=!1,disabled:$=!1,disabledItemsFocusable:k=!1,disableListWrap:T=!1,disablePortal:O=!1,filterOptions:P,filterSelectedOptions:D=!1,forcePopupIcon:A="auto",freeSolo:F=!1,fullWidth:L=!1,getLimitTagsText:_=we=>`+${we}`,getOptionDisabled:R,getOptionKey:z,getOptionLabel:N,isOptionEqualToValue:B,groupBy:I,handleHomeEndKeys:H=!n.freeSolo,id:Y,includeInputInList:ae=!1,inputValue:K,limitTags:oe=-1,ListboxComponent:ue,ListboxProps:G,loading:ie=!1,loadingText:Q="Loading…",multiple:ee=!1,noOptionsText:Z="No options",onChange:de,onClose:le,onHighlightChange:fe,onInputChange:he,onOpen:me,open:se,openOnFocus:ve=!1,openText:Le="Open",options:Ae,PaperComponent:Re,PopperComponent:re,popupIcon:_e=pI||(pI=p.jsx(W3,{})),readOnly:Me=!1,renderGroup:Ge,renderInput:Je,renderOption:St,renderTags:Ut,renderValue:at,selectOnFocus:tt=!n.freeSolo,size:pt="medium",slots:ze={},slotProps:be={},value:Ve,...Oe}=n,{getRootProps:$t,getInputProps:Rt,getInputLabelProps:vt,getPopupIndicatorProps:it,getClearProps:st,getItemProps:Dt,getListboxProps:nn,getOptionProps:Bt,value:pn,dirty:$n,expanded:qt,id:Pn,popupOpen:Se,focused:jn,focusedItem:Rn,anchorEl:en,setAnchorEl:jt,inputValue:Ur,groupedOptions:qn}=X1e({...n,componentName:"Autocomplete"}),mn=!S&&!$&&$n&&!Me,Bn=(!F||A===!0)&&A!==!1,{onMouseDown:xe}=Rt(),{ref:Ee,...Be}=nn(),Ye=N||(we=>we.label??we),ut={...n,disablePortal:O,expanded:qt,focused:jn,fullWidth:L,getOptionLabel:Ye,hasClearIcon:mn,hasPopupIcon:Bn,inputFocused:Rn===-1,popupOpen:Se,size:pt},Et=rwe(ut),Ct={slots:{paper:Re,popper:re,...ze},slotProps:{chip:s,listbox:G,...x,...be}},[Mt,Lt]=ur("listbox",{elementType:fwe,externalForwardedProps:Ct,ownerState:ut,className:Et.listbox,additionalProps:Be,ref:Ee}),[Xt,zt]=ur("paper",{elementType:tf,externalForwardedProps:Ct,ownerState:ut,className:Et.paper}),[Vt,ge]=ur("popper",{elementType:L2,externalForwardedProps:Ct,ownerState:ut,className:Et.popper,additionalProps:{disablePortal:O,style:{width:en?en.clientWidth:null},role:"presentation",anchorEl:en,open:Se}});let ye;const Ue=we=>({className:Et.tag,disabled:$,...Dt(we)});if(ee?pn.length>0&&(Ut?ye=Ut(pn,Ue,ut):at?ye=at(pn,Ue,ut):ye=pn.map((we,Pe)=>{const{key:ft,...kt}=Ue({index:Pe});return p.jsx(A3,{label:Ye(we),size:pt,...kt,...Ct.slotProps.chip},ft)})):at&&pn!=null&&(ye=at(pn,Ue,ut)),oe>-1&&Array.isArray(ye)){const we=ye.length-oe;!jn&&we>0&&(ye=ye.splice(0,oe),ye.push(p.jsx("span",{className:Et.tag,children:_(we)},ye.length)))}const gt=Ge||(we=>p.jsxs("li",{children:[p.jsx(pwe,{className:Et.groupLabel,ownerState:ut,component:"div",children:we.group}),p.jsx(hwe,{className:Et.groupUl,ownerState:ut,children:we.children})]},we.key)),We=St||((we,Pe)=>{const{key:ft,...kt}=we;return p.jsx("li",{...kt,children:Ye(Pe)},ft)}),Nt=(we,Pe)=>{const ft=Bt({option:we,index:Pe});return We({...ft,className:Et.option},we,{selected:ft["aria-selected"],index:Pe,inputValue:Ur},ut)},Kt=Ct.slotProps.clearIndicator,hn=Ct.slotProps.popupIndicator;return p.jsxs(C.Fragment,{children:[p.jsx(owe,{ref:t,className:Ht(Et.root,l),ownerState:ut,...$t(Oe),children:Je({id:Pn,disabled:$,fullWidth:!0,size:pt==="small"?"small":void 0,InputLabelProps:vt(),InputProps:{ref:jt,className:Et.inputRoot,startAdornment:ye,onMouseDown:we=>{we.target===we.currentTarget&&xe(we)},...(mn||Bn)&&{endAdornment:p.jsxs(awe,{className:Et.endAdornment,ownerState:ut,children:[mn?p.jsx(iwe,{...st(),"aria-label":g,title:g,ownerState:ut,...Kt,className:Ht(Et.clearIndicator,Kt?.className),children:d}):null,Bn?p.jsx(swe,{...it(),disabled:$,"aria-label":Se?y:Le,title:Se?y:Le,ownerState:ut,...hn,className:Ht(Et.popupIndicator,hn?.className),children:_e}):null]})}},inputProps:{className:Et.input,disabled:$,readOnly:Me,...Rt()}})}),en?p.jsx(lwe,{as:Vt,...ge,children:p.jsxs(cwe,{as:Xt,...zt,children:[ie&&qn.length===0?p.jsx(uwe,{className:Et.loading,ownerState:ut,children:Q}):null,qn.length===0&&!F&&!ie?p.jsx(dwe,{className:Et.noOptions,ownerState:ut,role:"presentation",onMouseDown:we=>{we.preventDefault()},children:Z}):null,qn.length>0?p.jsx(Mt,{as:ue,...Lt,children:qn.map((we,Pe)=>I?gt({key:we.key,group:we.group,children:we.options.map((ft,kt)=>Nt(ft,we.index+kt))}):Nt(we,Pe))}):null]})}):null]})});Ar.extend(h2);const gwe=Jt(p.jsx("path",{d:"m9.17 6 2 2H20v10H4V6zM10 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8z"})),l6=e=>{if(!e)return"Explore semantic models, run queries, and build reports";const t=e.replace(/^#+\s+/gm,"").replace(/\*\*(.*?)\*\*/g,"$1").replace(/\*(.*?)\*/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/`([^`]+)`/g,"$1").trim(),n=t.split(/\n\s*\n/)[1]||t;if(n.length<=120)return n;const r=n.substring(0,120).split(" ");return r.pop(),r.join(" ")+"..."},c6=(e,t)=>{const n=(e.readme||void 0)?.split(`
|
|
479
479
|
`)??[];return n.length===0&&(n.push(`# ${e.name}`),n.push("")),(e.readme?.length??0)>0&&t?n.splice(2,1,t):t&&n.push(t),n.join(`
|
|
480
480
|
`)};function hI(){const[e,t]=C.useState(!1),{apiClients:n}=tr(),r=()=>{t(!0)},o=()=>{t(!1)},a=Ch({mutationFn(s){return n.environments.createEnvironment({name:s.name,readme:c6({name:s.name,readme:""},s.description)})},success:"Environment created",invalidates:[["environments"]],closeDialog:o,resource:"environment",action:"create"}),i=async s=>{s.preventDefault();const l=new FormData(s.currentTarget),d=l.get("name")?.toString(),u=l.get("description")?.toString();if(!d)throw new Error("Name is required");a.mutate({name:d,description:u})};return p.jsxs(kn.Fragment,{children:[p.jsx(Qy,{label:"Environment",onClick:r}),p.jsx(Oo,{open:e,onClose:o,title:"New environment",description:"An environment holds packages and the connections they query through.",actions:p.jsxs(p.Fragment,{children:[p.jsx(Co,{disabled:a.isPending,onClick:o,children:"Cancel"}),p.jsx(Co,{type:"submit",form:"environment-form",variant:"contained",loading:a.isPending,children:"Create environment"})]}),children:p.jsx("form",{onSubmit:i,id:"environment-form",children:p.jsxs(z1,{sx:{gap:2},children:[p.jsx(yr,{autoFocus:!0,required:!0,id:"name",name:"name",label:"Name",type:"text",fullWidth:!0,size:"small",InputLabelProps:{shrink:!0}}),p.jsx(yr,{id:"description",name:"description",label:"Description",placeholder:"Explore semantic models, run queries, and build reports",type:"text",fullWidth:!0,size:"small",InputLabelProps:{shrink:!0}})]})})}),a.notice]})}function ywe({environment:e,onCloseDialog:t}){const[n,r]=C.useState(!1),{apiClients:o}=tr(),a=()=>{r(!0)},i=()=>{r(!1),t()},s=Ch({mutationFn:()=>o.environments.deleteEnvironment(e.name),success:"Environment deleted",invalidates:[["environments"]],closeDialog:i,resource:"environment",action:"delete"});return p.jsxs(kn.Fragment,{children:[p.jsxs(ea,{onClick:a,children:[p.jsx(ml,{children:p.jsx(Zx,{fontSize:"small"})}),p.jsx(Ci,{children:"Delete"})]}),p.jsx(Oo,{open:n,onClose:i,title:"Delete environment",actions:p.jsxs(p.Fragment,{children:[p.jsx(Co,{onClick:i,children:"Cancel"}),p.jsx(Co,{variant:"contained",color:"error",autoFocus:!0,onClick:()=>s.mutate(),loading:s.isPending,children:"Delete environment"})]}),children:p.jsxs(Sr,{variant:"body2",children:["Delete ",p.jsx("strong",{children:e.name}),"? Its packages stop being served and this cannot be undone."]})}),s.notice]})}function vwe({environment:e,onCloseDialog:t}){const[n,r]=C.useState(!1),{apiClients:o}=tr(),a=()=>{r(!0)},i=()=>{r(!1),t()},s=Ch({mutationFn(d){return o.environments.updateEnvironment(e.name,{name:e.name,readme:c6({name:e.name,readme:e.readme},d.description)})},success:"Environment updated",invalidates:[["environments"]],closeDialog:i,resource:"environment",action:"update"}),l=d=>{d.preventDefault();const u=new FormData(d.currentTarget).get("description")?.toString();s.mutate({description:u})};return p.jsxs(kn.Fragment,{children:[p.jsxs(ea,{onClick:a,children:[p.jsx(ml,{children:p.jsx(r2,{fontSize:"small"})}),p.jsx(Ci,{children:"Edit"})]}),p.jsx(Oo,{open:n,onClose:i,title:"Edit environment",description:"What this environment is, for the people who open it.",actions:p.jsxs(p.Fragment,{children:[p.jsx(Co,{disabled:s.isPending,onClick:i,children:"Cancel"}),p.jsx(Co,{type:"submit",form:"environment-form",variant:"contained",loading:s.isPending,children:"Save changes"})]}),children:p.jsx("form",{onSubmit:l,id:"environment-form",children:p.jsxs(z1,{sx:{gap:2},children:[p.jsx(yr,{autoFocus:!0,required:!0,id:"name",name:"name",label:"Name",disabled:!0,type:"text",fullWidth:!0,size:"small",defaultValue:e.name,InputLabelProps:{shrink:!0}}),p.jsx(yr,{id:"description",name:"description",label:"Description",type:"text",fullWidth:!0,size:"small",defaultValue:l6(e.readme),InputLabelProps:{shrink:!0}})]})})}),s.notice]})}const bwe=[{title:"Model",body:"An agent writes what the data means in Malloy — sources, joins, measures — from a warehouse or a file, and validates each edit without a restart.",href:tu.publishing},{title:"Analyze",body:"Claude, Cursor, Codex or an agent you build asks over MCP; applications and BI tools use REST. Every question runs against the model, never the raw tables.",href:tu.mcpAgents},{title:"Surface",body:"Reports declared in Malloy, laid out as a grid or read top to bottom, and no-build HTML data apps, all shipped inside the package, plus this Console for browsing them.",href:tu.surfaces},{title:"Govern",body:"Runtime parameters, row-level filters and per-source gates are declared in the model, so every surface reads the same rules rather than writing its own.",href:tu.givens},{title:"Optimize",body:"One annotation materializes an expensive source into a table, and another rolls a measure up to a coarser grain, rebuilt on demand or on a schedule.",href:tu.materialization},{title:"Run anywhere",body:"DuckDB is built in for CSV, Parquet, JSON and Excel; BigQuery, Snowflake, Postgres, Databricks, MotherDuck and more connect by configuration.",href:tu.connections}];function xwe({href:e,children:t}){return p.jsx(Te,{component:"a",href:e,target:"_blank",rel:"noopener noreferrer",sx:{color:"text.primary",textDecoration:"underline"},children:t})}function YTe({onClickEnvironment:e}){const{apiClients:t,mutable:n}=tr(),{data:r,isSuccess:o,isError:a,error:i}=co({queryKey:["environments"],queryFn:()=>t.environments.listEnvironments()});if(a)return p.jsx(ja,{error:i,context:"Environments List"});if(!o)return p.jsx(Bo,{text:"Loading environments..."});const s=r.data??[];return p.jsxs(O0,{maxWidth:"md",sx:{py:6},children:[p.jsxs(Te,{sx:{mb:5},children:[p.jsx(wt,{variant:"h3",component:"h1",sx:{fontWeight:500,letterSpacing:"-0.025em",mb:1},children:"Publisher"}),p.jsx(wt,{variant:"body1",color:"text.secondary",sx:{mb:3},children:"The analytics engine for Malloy."}),p.jsx(wt,{variant:"body2",color:"text.secondary",sx:{maxWidth:720,lineHeight:1.6},children:"One data model, served over MCP and REST to AI agents, applications and BI tools. Write down what your data means — the sources, the joins, the measures, who may see what — and every surface asks the same model, so the same question returns the same numbers tomorrow."})]}),p.jsx(Cp,{container:!0,spacing:4,sx:{mb:5},children:bwe.map(l=>p.jsx(Cp,{size:{xs:12,sm:6},children:p.jsxs(Yn,{spacing:1,children:[p.jsx(wt,{variant:"body2",component:"a",href:l.href,target:"_blank",rel:"noopener noreferrer",sx:{fontWeight:500,color:"text.primary",textDecoration:"none","&:hover":{textDecoration:"underline"}},children:l.title}),p.jsx(wt,{variant:"body2",color:"text.secondary",sx:{lineHeight:1.6},children:l.body})]})},l.title))}),p.jsx(wl,{sx:{my:4}}),s.length>0?p.jsx(Ns,{title:"Environments",count:s.length,description:"Published environments available on this server",...n?{action:p.jsx(hI,{})}:{},children:p.jsx(Yn,{children:s.map(l=>p.jsx(wwe,{environment:l,...e?{onClickEnvironment:e}:{}},l.name))})}):p.jsxs(Te,{sx:{mb:4},children:[p.jsx(wt,{variant:"h5",sx:{fontWeight:500,letterSpacing:"-0.025em",mb:1},children:"Get started"}),p.jsx(wt,{variant:"body2",color:"text.secondary",sx:{mb:3,maxWidth:600},children:"Create your first Malloy environment to start exploring semantic models and building data experiences."}),n?p.jsx(hI,{}):p.jsx(Vn,{variant:"contained",color:"primary",href:tu.publishing,target:"_blank",rel:"noopener noreferrer",children:"Learn how to create models"})]}),p.jsx(wl,{sx:{my:4}}),p.jsxs(wt,{variant:"body2",color:"text.secondary",sx:{maxWidth:720,lineHeight:1.6,mt:2},children:["Join the"," ",p.jsx(xwe,{href:"https://join.slack.com/t/malloy-community/shared_invite/zt-1kgfwgi5g-CrsdaRqs81QY67QW0~t_uw",children:"Malloy Slack community"})," ","to ask questions, share ideas, and contribute."]})]})}function wwe({environment:e,onClickEnvironment:t}){const{mutable:n}=tr(),[r,o]=C.useState(null),a=!!r,i=l6(e.readme),s=d=>{d.stopPropagation(),o(d.currentTarget)},l=()=>o(null);return p.jsx(L1,{icon:p.jsx(gwe,{sx:{fontSize:18}}),tint:ZR.environment,label:e.name??"",ariaLabel:e.name??"",...i?{description:i}:{},...e.name&&t?{onClick:d=>t(`/${e.name}/`,d)}:{},...n?{trailingAction:p.jsxs(p.Fragment,{children:[p.jsx(ro,{size:"small",onClick:s,"aria-label":`Environment actions for ${e.name}`,children:p.jsx(Jx,{fontSize:"small"})}),p.jsxs(uc,{anchorEl:r,open:a,onClose:l,onClick:d=>d.stopPropagation(),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[p.jsx(vwe,{environment:e,onCloseDialog:l}),p.jsx(ywe,{environment:e,onCloseDialog:l})]})]})}:{}})}var fp={},hi={},ig={},pp={},mI={},gI;function Swe(){return gI||(gI=1,Object.defineProperty(mI,"__esModule",{value:!0})),mI}var sg={},lg={},yI;function rf(){if(yI)return lg;yI=1,Object.defineProperty(lg,"__esModule",{value:!0}),lg.CronField=void 0;let e=class u6{#e=!1;#t=!1;#n=!1;#o=[];options={rawValue:""};static get min(){throw new Error("min must be overridden")}static get max(){throw new Error("max must be overridden")}static get chars(){return Object.freeze([])}static get validChars(){return/^[?,*\dH/-]+$|^.*H\(\d+-\d+\)\/\d+.*$|^.*H\(\d+-\d+\).*$|^.*H\/\d+.*$/}static get constraints(){return{min:this.min,max:this.max,chars:this.chars,validChars:this.validChars}}constructor(n,r={rawValue:""}){if(!Array.isArray(n))throw new Error(`${this.constructor.name} Validation error, values is not an array`);if(!(n.length>0))throw new Error(`${this.constructor.name} Validation error, values contains no values`);this.options={...r,rawValue:r.rawValue??""},this.#o=n.sort(u6.sorter),this.#n=this.options.wildcard!==void 0?this.options.wildcard:this.#r(),this.#e=this.options.rawValue.includes("L")||n.includes("L"),this.#t=this.options.rawValue.includes("?")||n.includes("?")}get min(){return this.constructor.min}get max(){return this.constructor.max}get chars(){return this.constructor.chars}get hasLastChar(){return this.#e}get hasQuestionMarkChar(){return this.#t}get isWildcard(){return this.#n}get values(){return this.#o}static sorter(n,r){const o=typeof n=="number",a=typeof r=="number";return o&&a?n-r:!o&&!a?n.localeCompare(r):o?-1:1}static findNearestValueInList(n,r,o){if(o){for(let a=n.length-1;a>=0;a--)if(n[a]<r)return n[a];return null}for(let a=0;a<n.length;a++)if(n[a]>r)return n[a];return null}findNearestValue(n,r){return this.constructor.findNearestValueInList(this.values,n,r)}serialize(){return{wildcard:this.#n,values:this.#o}}validate(){let n;const r=this.chars.length>0?` or chars ${this.chars.join("")}`:"",o=s=>l=>new RegExp(`^\\d{0,2}${l}$`).test(s),a=s=>(n=s,typeof s=="number"?s>=this.min&&s<=this.max:this.chars.some(o(s)));if(!this.#o.every(a))throw new Error(`${this.constructor.name} Validation error, got value ${n} expected range ${this.min}-${this.max}${r}`);const i=this.#o.find((s,l)=>this.#o.indexOf(s)!==l);if(i)throw new Error(`${this.constructor.name} Validation error, duplicate values found: ${i}`)}#r(){return this.options.rawValue.length>0?["*","?"].includes(this.options.rawValue):Array.from({length:this.max-this.min+1},(n,r)=>r+this.min).every(n=>this.#o.includes(n))}};return lg.CronField=e,lg}var vI;function Cwe(){if(vI)return sg;vI=1,Object.defineProperty(sg,"__esModule",{value:!0}),sg.CronDayOfMonth=void 0;const e=rf(),t=1,n=31,r=Object.freeze(["L"]);let o=class extends e.CronField{static get min(){return t}static get max(){return n}static get chars(){return r}static get validChars(){return/^[?,*\dLH/-]+$|^.*H\(\d+-\d+\)\/\d+.*$|^.*H\(\d+-\d+\).*$|^.*H\/\d+.*$/}constructor(a,i){super(a,i),this.validate()}get values(){return super.values}};return sg.CronDayOfMonth=o,sg}var cg={},bI;function kwe(){if(bI)return cg;bI=1,Object.defineProperty(cg,"__esModule",{value:!0}),cg.CronDayOfWeek=void 0;const e=rf(),t=0,n=7,r=Object.freeze(["L"]);let o=class extends e.CronField{static get min(){return t}static get max(){return n}static get chars(){return r}static get validChars(){return/^[?,*\dLH#/-]+$|^.*H\(\d+-\d+\)\/\d+.*$|^.*H\(\d+-\d+\).*$|^.*H\/\d+.*$/}constructor(a,i){super(a,i),this.validate()}get values(){return super.values}get nthDay(){return this.options.nthDayOfWeek??0}};return cg.CronDayOfWeek=o,cg}var ug={},xI;function $we(){if(xI)return ug;xI=1,Object.defineProperty(ug,"__esModule",{value:!0}),ug.CronHour=void 0;const e=rf(),t=0,n=23,r=Object.freeze([]);let o=class extends e.CronField{static get min(){return t}static get max(){return n}static get chars(){return r}constructor(a,i){super(a,i),this.validate()}get values(){return super.values}};return ug.CronHour=o,ug}var dg={},wI;function Rwe(){if(wI)return dg;wI=1,Object.defineProperty(dg,"__esModule",{value:!0}),dg.CronMinute=void 0;const e=rf(),t=0,n=59,r=Object.freeze([]);let o=class extends e.CronField{static get min(){return t}static get max(){return n}static get chars(){return r}constructor(a,i){super(a,i),this.validate()}get values(){return super.values}};return dg.CronMinute=o,dg}var fg={},SI={},Ba={},CI;function Twe(){if(CI)return Ba;CI=1,Object.defineProperty(Ba,"__esModule",{value:!0});class e extends Error{}class t extends e{constructor(M){super(`Invalid DateTime: ${M.toMessage()}`)}}class n extends e{constructor(M){super(`Invalid Interval: ${M.toMessage()}`)}}class r extends e{constructor(M){super(`Invalid Duration: ${M.toMessage()}`)}}class o extends e{}class a extends e{constructor(M){super(`Invalid unit ${M}`)}}class i extends e{}class s extends e{constructor(){super("Zone is an abstract class")}}const l="numeric",d="short",u="long",m={year:l,month:l,day:l},g={year:l,month:d,day:l},y={year:l,month:d,day:l,weekday:d},x={year:l,month:u,day:l},w={year:l,month:u,day:l,weekday:u},S={hour:l,minute:l},b={hour:l,minute:l,second:l},$={hour:l,minute:l,second:l,timeZoneName:d},k={hour:l,minute:l,second:l,timeZoneName:u},T={hour:l,minute:l,hourCycle:"h23"},O={hour:l,minute:l,second:l,hourCycle:"h23"},P={hour:l,minute:l,second:l,hourCycle:"h23",timeZoneName:d},D={hour:l,minute:l,second:l,hourCycle:"h23",timeZoneName:u},A={year:l,month:l,day:l,hour:l,minute:l},F={year:l,month:l,day:l,hour:l,minute:l,second:l},L={year:l,month:d,day:l,hour:l,minute:l},_={year:l,month:d,day:l,hour:l,minute:l,second:l},R={year:l,month:d,day:l,weekday:d,hour:l,minute:l},z={year:l,month:u,day:l,hour:l,minute:l,timeZoneName:d},N={year:l,month:u,day:l,hour:l,minute:l,second:l,timeZoneName:d},B={year:l,month:u,day:l,weekday:u,hour:l,minute:l,timeZoneName:u},I={year:l,month:u,day:l,weekday:u,hour:l,minute:l,second:l,timeZoneName:u};class H{get type(){throw new s}get name(){throw new s}get ianaName(){return this.name}get isUniversal(){throw new s}offsetName(M,q){throw new s}formatOffset(M,q){throw new s}offset(M){throw new s}equals(M){throw new s}get isValid(){throw new s}}let Y=null;class ae extends H{static get instance(){return Y===null&&(Y=new ae),Y}get type(){return"system"}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(M,{format:q,locale:J}){return Ou(M,q,J)}formatOffset(M,q){return Us(this.offset(M),q)}offset(M){return-new Date(M).getTimezoneOffset()}equals(M){return M.type==="system"}get isValid(){return!0}}const K=new Map;function oe(W){let M=K.get(W);return M===void 0&&(M=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:W,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",era:"short"}),K.set(W,M)),M}const ue={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function G(W,M){const q=W.format(M).replace(/\u200E/g,""),J=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(q),[,ce,Ce,Ne,qe,Xe,At,Mn]=J;return[Ne,ce,Ce,qe,Xe,At,Mn]}function ie(W,M){const q=W.formatToParts(M),J=[];for(let ce=0;ce<q.length;ce++){const{type:Ce,value:Ne}=q[ce],qe=ue[Ce];Ce==="era"?J[qe]=Ne:We(qe)||(J[qe]=parseInt(Ne,10))}return J}const Q=new Map;class ee extends H{static create(M){let q=Q.get(M);return q===void 0&&Q.set(M,q=new ee(M)),q}static resetCache(){Q.clear(),K.clear()}static isValidSpecifier(M){return this.isValidZone(M)}static isValidZone(M){if(!M)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:M}).format(),!0}catch{return!1}}constructor(M){super(),this.zoneName=M,this.valid=ee.isValidZone(M)}get type(){return"iana"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(M,{format:q,locale:J}){return Ou(M,q,J,this.name)}formatOffset(M,q){return Us(this.offset(M),q)}offset(M){if(!this.valid)return NaN;const q=new Date(M);if(isNaN(q))return NaN;const J=oe(this.name);let[ce,Ce,Ne,qe,Xe,At,Mn]=J.formatToParts?ie(J,q):G(J,q);qe==="BC"&&(ce=-Math.abs(ce)+1);const Fn=ti({year:ce,month:Ce,day:Ne,hour:Xe===24?0:Xe,minute:At,second:Mn,millisecond:0});let pr=+q;const An=pr%1e3;return pr-=An>=0?An:1e3+An,(Fn-pr)/(60*1e3)}equals(M){return M.type==="iana"&&M.name===this.name}get isValid(){return this.valid}}let Z={};function de(W,M={}){const q=JSON.stringify([W,M]);let J=Z[q];return J||(J=new Intl.ListFormat(W,M),Z[q]=J),J}const le=new Map;function fe(W,M={}){const q=JSON.stringify([W,M]);let J=le.get(q);return J===void 0&&(J=new Intl.DateTimeFormat(W,M),le.set(q,J)),J}const he=new Map;function me(W,M={}){const q=JSON.stringify([W,M]);let J=he.get(q);return J===void 0&&(J=new Intl.NumberFormat(W,M),he.set(q,J)),J}const se=new Map;function ve(W,M={}){const{base:q,...J}=M,ce=JSON.stringify([W,J]);let Ce=se.get(ce);return Ce===void 0&&(Ce=new Intl.RelativeTimeFormat(W,M),se.set(ce,Ce)),Ce}let Le=null;function Ae(){return Le||(Le=new Intl.DateTimeFormat().resolvedOptions().locale,Le)}const Re=new Map;function re(W){let M=Re.get(W);return M===void 0&&(M=new Intl.DateTimeFormat(W).resolvedOptions(),Re.set(W,M)),M}const _e=new Map;function Me(W){let M=_e.get(W);if(!M){const q=new Intl.Locale(W);M="getWeekInfo"in q?q.getWeekInfo():q.weekInfo,"minimalDays"in M||(M={...Ve,...M}),_e.set(W,M)}return M}function Ge(W){const M=W.indexOf("-x-");M!==-1&&(W=W.substring(0,M));const q=W.indexOf("-u-");if(q===-1)return[W];{let J,ce;try{J=fe(W).resolvedOptions(),ce=W}catch{const qe=W.substring(0,q);J=fe(qe).resolvedOptions(),ce=qe}const{numberingSystem:Ce,calendar:Ne}=J;return[ce,Ce,Ne]}}function Je(W,M,q){return(q||M)&&(W.includes("-u-")||(W+="-u"),q&&(W+=`-ca-${q}`),M&&(W+=`-nu-${M}`)),W}function St(W){const M=[];for(let q=1;q<=12;q++){const J=En.utc(2009,q,1);M.push(W(J))}return M}function Ut(W){const M=[];for(let q=1;q<=7;q++){const J=En.utc(2016,11,13+q);M.push(W(J))}return M}function at(W,M,q,J){const ce=W.listingMode();return ce==="error"?null:ce==="en"?q(M):J(M)}function tt(W){return W.numberingSystem&&W.numberingSystem!=="latn"?!1:W.numberingSystem==="latn"||!W.locale||W.locale.startsWith("en")||re(W.locale).numberingSystem==="latn"}class pt{constructor(M,q,J){this.padTo=J.padTo||0,this.floor=J.floor||!1;const{padTo:ce,floor:Ce,...Ne}=J;if(!q||Object.keys(Ne).length>0){const qe={useGrouping:!1,...J};J.padTo>0&&(qe.minimumIntegerDigits=J.padTo),this.inf=me(M,qe)}}format(M){if(this.inf){const q=this.floor?Math.floor(M):M;return this.inf.format(q)}else{const q=this.floor?Math.floor(M):vs(M,3);return tn(q,this.padTo)}}}class ze{constructor(M,q,J){this.opts=J,this.originalZone=void 0;let ce;if(this.opts.timeZone)this.dt=M;else if(M.zone.type==="fixed"){const Ne=-1*(M.offset/60),qe=Ne>=0?`Etc/GMT+${Ne}`:`Etc/GMT${Ne}`;M.offset!==0&&ee.create(qe).valid?(ce=qe,this.dt=M):(ce="UTC",this.dt=M.offset===0?M:M.setZone("UTC").plus({minutes:M.offset}),this.originalZone=M.zone)}else M.zone.type==="system"?this.dt=M:M.zone.type==="iana"?(this.dt=M,ce=M.zone.name):(ce="UTC",this.dt=M.setZone("UTC").plus({minutes:M.offset}),this.originalZone=M.zone);const Ce={...this.opts};Ce.timeZone=Ce.timeZone||ce,this.dtf=fe(q,Ce)}format(){return this.originalZone?this.formatToParts().map(({value:M})=>M).join(""):this.dtf.format(this.dt.toJSDate())}formatToParts(){const M=this.dtf.formatToParts(this.dt.toJSDate());return this.originalZone?M.map(q=>{if(q.type==="timeZoneName"){const J=this.originalZone.offsetName(this.dt.ts,{locale:this.dt.locale,format:this.opts.timeZoneName});return{...q,value:J}}else return q}):M}resolvedOptions(){return this.dtf.resolvedOptions()}}class be{constructor(M,q,J){this.opts={style:"long",...J},!q&&Pe()&&(this.rtf=ve(M,J))}format(M,q){return this.rtf?this.rtf.format(M,q):Sc(q,M,this.opts.numeric,this.opts.style!=="long")}formatToParts(M,q){return this.rtf?this.rtf.formatToParts(M,q):[]}}const Ve={firstDay:1,minimalDays:4,weekend:[6,7]};class Oe{static fromOpts(M){return Oe.create(M.locale,M.numberingSystem,M.outputCalendar,M.weekSettings,M.defaultToEN)}static create(M,q,J,ce,Ce=!1){const Ne=M||mn.defaultLocale,qe=Ne||(Ce?"en-US":Ae()),Xe=q||mn.defaultNumberingSystem,At=J||mn.defaultOutputCalendar,Mn=on(ce)||mn.defaultWeekSettings;return new Oe(qe,Xe,At,Mn,Ne)}static resetCache(){Le=null,le.clear(),he.clear(),se.clear(),Re.clear(),_e.clear()}static fromObject({locale:M,numberingSystem:q,outputCalendar:J,weekSettings:ce}={}){return Oe.create(M,q,J,ce)}constructor(M,q,J,ce,Ce){const[Ne,qe,Xe]=Ge(M);this.locale=Ne,this.numberingSystem=q||qe||null,this.outputCalendar=J||Xe||null,this.weekSettings=ce,this.intl=Je(this.locale,this.numberingSystem,this.outputCalendar),this.weekdaysCache={format:{},standalone:{}},this.monthsCache={format:{},standalone:{}},this.meridiemCache=null,this.eraCache={},this.specifiedLocale=Ce,this.fastNumbersCached=null}get fastNumbers(){return this.fastNumbersCached==null&&(this.fastNumbersCached=tt(this)),this.fastNumbersCached}listingMode(){const M=this.isEnglish(),q=(this.numberingSystem===null||this.numberingSystem==="latn")&&(this.outputCalendar===null||this.outputCalendar==="gregory");return M&&q?"en":"intl"}clone(M){return!M||Object.getOwnPropertyNames(M).length===0?this:Oe.create(M.locale||this.specifiedLocale,M.numberingSystem||this.numberingSystem,M.outputCalendar||this.outputCalendar,on(M.weekSettings)||this.weekSettings,M.defaultToEN||!1)}redefaultToEN(M={}){return this.clone({...M,defaultToEN:!0})}redefaultToSystem(M={}){return this.clone({...M,defaultToEN:!1})}months(M,q=!1){return at(this,M,Pl,()=>{const J=this.intl==="ja"||this.intl.startsWith("ja-");q&=!J;const ce=q?{month:M,day:"numeric"}:{month:M},Ce=q?"format":"standalone";if(!this.monthsCache[Ce][M]){const Ne=J?qe=>this.dtFormatter(qe,ce).format():qe=>this.extract(qe,ce,"month");this.monthsCache[Ce][M]=St(Ne)}return this.monthsCache[Ce][M]})}weekdays(M,q=!1){return at(this,M,ws,()=>{const J=q?{weekday:M,year:"numeric",month:"long",day:"numeric"}:{weekday:M},ce=q?"format":"standalone";return this.weekdaysCache[ce][M]||(this.weekdaysCache[ce][M]=Ut(Ce=>this.extract(Ce,J,"weekday"))),this.weekdaysCache[ce][M]})}meridiems(){return at(this,void 0,()=>ju,()=>{if(!this.meridiemCache){const M={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[En.utc(2016,11,13,9),En.utc(2016,11,13,19)].map(q=>this.extract(q,M,"dayperiod"))}return this.meridiemCache})}eras(M){return at(this,M,Da,()=>{const q={era:M};return this.eraCache[M]||(this.eraCache[M]=[En.utc(-40,1,1),En.utc(2017,1,1)].map(J=>this.extract(J,q,"era"))),this.eraCache[M]})}extract(M,q,J){const ce=this.dtFormatter(M,q),Ce=ce.formatToParts(),Ne=Ce.find(qe=>qe.type.toLowerCase()===J);return Ne?Ne.value:null}numberFormatter(M={}){return new pt(this.intl,M.forceSimple||this.fastNumbers,M)}dtFormatter(M,q={}){return new ze(M,this.intl,q)}relFormatter(M={}){return new be(this.intl,this.isEnglish(),M)}listFormatter(M={}){return de(this.intl,M)}isEnglish(){return this.locale==="en"||this.locale.toLowerCase()==="en-us"||re(this.intl).locale.startsWith("en-us")}getWeekSettings(){return this.weekSettings?this.weekSettings:ft()?Me(this.locale):Ve}getStartOfWeek(){return this.getWeekSettings().firstDay}getMinDaysInFirstWeek(){return this.getWeekSettings().minimalDays}getWeekendDays(){return this.getWeekSettings().weekend}equals(M){return this.locale===M.locale&&this.numberingSystem===M.numberingSystem&&this.outputCalendar===M.outputCalendar}toString(){return`Locale(${this.locale}, ${this.numberingSystem}, ${this.outputCalendar})`}}let $t=null;class Rt extends H{static get utcInstance(){return $t===null&&($t=new Rt(0)),$t}static instance(M){return M===0?Rt.utcInstance:new Rt(M)}static parseSpecifier(M){if(M){const q=M.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(q)return new Rt(Ml(q[1],q[2]))}return null}constructor(M){super(),this.fixed=M}get type(){return"fixed"}get name(){return this.fixed===0?"UTC":`UTC${Us(this.fixed,"narrow")}`}get ianaName(){return this.fixed===0?"Etc/UTC":`Etc/GMT${Us(-this.fixed,"narrow")}`}offsetName(){return this.name}formatOffset(M,q){return Us(this.fixed,q)}get isUniversal(){return!0}offset(){return this.fixed}equals(M){return M.type==="fixed"&&M.fixed===this.fixed}get isValid(){return!0}}class vt extends H{constructor(M){super(),this.zoneName=M}get type(){return"invalid"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(){return null}formatOffset(){return""}offset(){return NaN}equals(){return!1}get isValid(){return!1}}function it(W,M){if(We(W)||W===null)return M;if(W instanceof H)return W;if(hn(W)){const q=W.toLowerCase();return q==="default"?M:q==="local"||q==="system"?ae.instance:q==="utc"||q==="gmt"?Rt.utcInstance:Rt.parseSpecifier(q)||ee.create(W)}else return Nt(W)?Rt.instance(W):typeof W=="object"&&"offset"in W&&typeof W.offset=="function"?W:new vt(W)}const st={arab:"[٠-٩]",arabext:"[۰-۹]",bali:"[᭐-᭙]",beng:"[০-৯]",deva:"[०-९]",fullwide:"[0-9]",gujr:"[૦-૯]",hanidec:"[〇|一|二|三|四|五|六|七|八|九]",khmr:"[០-៩]",knda:"[೦-೯]",laoo:"[໐-໙]",limb:"[᥆-᥏]",mlym:"[൦-൯]",mong:"[᠐-᠙]",mymr:"[၀-၉]",orya:"[୦-୯]",tamldec:"[௦-௯]",telu:"[౦-౯]",thai:"[๐-๙]",tibt:"[༠-༩]",latn:"\\d"},Dt={arab:[1632,1641],arabext:[1776,1785],bali:[6992,7001],beng:[2534,2543],deva:[2406,2415],fullwide:[65296,65303],gujr:[2790,2799],khmr:[6112,6121],knda:[3302,3311],laoo:[3792,3801],limb:[6470,6479],mlym:[3430,3439],mong:[6160,6169],mymr:[4160,4169],orya:[2918,2927],tamldec:[3046,3055],telu:[3174,3183],thai:[3664,3673],tibt:[3872,3881]},nn=st.hanidec.replace(/[\[|\]]/g,"").split("");function Bt(W){let M=parseInt(W,10);if(isNaN(M)){M="";for(let q=0;q<W.length;q++){const J=W.charCodeAt(q);if(W[q].search(st.hanidec)!==-1)M+=nn.indexOf(W[q]);else for(const ce in Dt){const[Ce,Ne]=Dt[ce];J>=Ce&&J<=Ne&&(M+=J-Ce)}}return parseInt(M,10)}else return M}const pn=new Map;function $n(){pn.clear()}function qt({numberingSystem:W},M=""){const q=W||"latn";let J=pn.get(q);J===void 0&&(J=new Map,pn.set(q,J));let ce=J.get(M);return ce===void 0&&(ce=new RegExp(`${st[q]}${M}`),J.set(M,ce)),ce}let Pn=()=>Date.now(),Se="system",jn=null,Rn=null,en=null,jt=60,Ur,qn=null;class mn{static get now(){return Pn}static set now(M){Pn=M}static set defaultZone(M){Se=M}static get defaultZone(){return it(Se,ae.instance)}static get defaultLocale(){return jn}static set defaultLocale(M){jn=M}static get defaultNumberingSystem(){return Rn}static set defaultNumberingSystem(M){Rn=M}static get defaultOutputCalendar(){return en}static set defaultOutputCalendar(M){en=M}static get defaultWeekSettings(){return qn}static set defaultWeekSettings(M){qn=on(M)}static get twoDigitCutoffYear(){return jt}static set twoDigitCutoffYear(M){jt=M%100}static get throwOnInvalid(){return Ur}static set throwOnInvalid(M){Ur=M}static resetCaches(){Oe.resetCache(),ee.resetCache(),En.resetCache(),$n()}}class Bn{constructor(M,q){this.reason=M,this.explanation=q}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}}const xe=[0,31,59,90,120,151,181,212,243,273,304,334],Ee=[0,31,60,91,121,152,182,213,244,274,305,335];function Be(W,M){return new Bn("unit out of range",`you specified ${M} (of type ${typeof M}) as a ${W}, which is invalid`)}function Ye(W,M,q){const J=new Date(Date.UTC(W,M-1,q));W<100&&W>=0&&J.setUTCFullYear(J.getUTCFullYear()-1900);const ce=J.getUTCDay();return ce===0?7:ce}function ut(W,M,q){return q+(ca(W)?Ee:xe)[M-1]}function Et(W,M){const q=ca(W)?Ee:xe,J=q.findIndex(Ce=>Ce<M),ce=M-q[J];return{month:J+1,day:ce}}function Ct(W,M){return(W-M+7)%7+1}function Mt(W,M=4,q=1){const{year:J,month:ce,day:Ce}=W,Ne=ut(J,ce,Ce),qe=Ct(Ye(J,ce,Ce),q);let Xe=Math.floor((Ne-qe+14-M)/7),At;return Xe<1?(At=J-1,Xe=bs(At,M,q)):Xe>bs(J,M,q)?(At=J+1,Xe=1):At=J,{weekYear:At,weekNumber:Xe,weekday:qe,...Ol(W)}}function Lt(W,M=4,q=1){const{weekYear:J,weekNumber:ce,weekday:Ce}=W,Ne=Ct(Ye(J,1,M),q),qe=fr(J);let Xe=ce*7+Ce-Ne-7+M,At;Xe<1?(At=J-1,Xe+=fr(At)):Xe>qe?(At=J+1,Xe-=fr(J)):At=J;const{month:Mn,day:Fn}=Et(At,Xe);return{year:At,month:Mn,day:Fn,...Ol(W)}}function Xt(W){const{year:M,month:q,day:J}=W,ce=ut(M,q,J);return{year:M,ordinal:ce,...Ol(W)}}function zt(W){const{year:M,ordinal:q}=W,{month:J,day:ce}=Et(M,q);return{year:M,month:J,day:ce,...Ol(W)}}function Vt(W,M){if(!We(W.localWeekday)||!We(W.localWeekNumber)||!We(W.localWeekYear)){if(!We(W.weekday)||!We(W.weekNumber)||!We(W.weekYear))throw new o("Cannot mix locale-based week fields with ISO-based week fields");return We(W.localWeekday)||(W.weekday=W.localWeekday),We(W.localWeekNumber)||(W.weekNumber=W.localWeekNumber),We(W.localWeekYear)||(W.weekYear=W.localWeekYear),delete W.localWeekday,delete W.localWeekNumber,delete W.localWeekYear,{minDaysInFirstWeek:M.getMinDaysInFirstWeek(),startOfWeek:M.getStartOfWeek()}}else return{minDaysInFirstWeek:4,startOfWeek:1}}function ge(W,M=4,q=1){const J=Kt(W.weekYear),ce=On(W.weekNumber,1,bs(W.weekYear,M,q)),Ce=On(W.weekday,1,7);return J?ce?Ce?!1:Be("weekday",W.weekday):Be("week",W.weekNumber):Be("weekYear",W.weekYear)}function ye(W){const M=Kt(W.year),q=On(W.ordinal,1,fr(W.year));return M?q?!1:Be("ordinal",W.ordinal):Be("year",W.year)}function Ue(W){const M=Kt(W.year),q=On(W.month,1,12),J=On(W.day,1,qr(W.year,W.month));return M?q?J?!1:Be("day",W.day):Be("month",W.month):Be("year",W.year)}function gt(W){const{hour:M,minute:q,second:J,millisecond:ce}=W,Ce=On(M,0,23)||M===24&&q===0&&J===0&&ce===0,Ne=On(q,0,59),qe=On(J,0,59),Xe=On(ce,0,999);return Ce?Ne?qe?Xe?!1:Be("millisecond",ce):Be("second",J):Be("minute",q):Be("hour",M)}function We(W){return typeof W>"u"}function Nt(W){return typeof W=="number"}function Kt(W){return typeof W=="number"&&W%1===0}function hn(W){return typeof W=="string"}function we(W){return Object.prototype.toString.call(W)==="[object Date]"}function Pe(){try{return typeof Intl<"u"&&!!Intl.RelativeTimeFormat}catch{return!1}}function ft(){try{return typeof Intl<"u"&&!!Intl.Locale&&("weekInfo"in Intl.Locale.prototype||"getWeekInfo"in Intl.Locale.prototype)}catch{return!1}}function kt(W){return Array.isArray(W)?W:[W]}function Ot(W,M,q){if(W.length!==0)return W.reduce((J,ce)=>{const Ce=[M(ce),ce];return J&&q(J[0],Ce[0])===J[0]?J:Ce},null)[1]}function Pt(W,M){return M.reduce((q,J)=>(q[J]=W[J],q),{})}function Ft(W,M){return Object.prototype.hasOwnProperty.call(W,M)}function on(W){if(W==null)return null;if(typeof W!="object")throw new i("Week settings must be an object");if(!On(W.firstDay,1,7)||!On(W.minimalDays,1,7)||!Array.isArray(W.weekend)||W.weekend.some(M=>!On(M,1,7)))throw new i("Invalid week settings");return{firstDay:W.firstDay,minimalDays:W.minimalDays,weekend:Array.from(W.weekend)}}function On(W,M,q){return Kt(W)&&W>=M&&W<=q}function or(W,M){return W-M*Math.floor(W/M)}function tn(W,M=2){const q=W<0;let J;return q?J="-"+(""+-W).padStart(M,"0"):J=(""+W).padStart(M,"0"),J}function Dr(W){if(!(We(W)||W===null||W===""))return parseInt(W,10)}function fo(W){if(!(We(W)||W===null||W===""))return parseFloat(W)}function Do(W){if(!(We(W)||W===null||W==="")){const M=parseFloat("0."+W)*1e3;return Math.floor(M)}}function vs(W,M,q="round"){const J=10**M;switch(q){case"expand":return W>0?Math.ceil(W*J)/J:Math.floor(W*J)/J;case"trunc":return Math.trunc(W*J)/J;case"round":return Math.round(W*J)/J;case"floor":return Math.floor(W*J)/J;case"ceil":return Math.ceil(W*J)/J;default:throw new RangeError(`Value rounding ${q} is out of range`)}}function ca(W){return W%4===0&&(W%100!==0||W%400===0)}function fr(W){return ca(W)?366:365}function qr(W,M){const q=or(M-1,12)+1,J=W+(M-q)/12;return q===2?ca(J)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][q-1]}function ti(W){let M=Date.UTC(W.year,W.month-1,W.day,W.hour,W.minute,W.second,W.millisecond);return W.year<100&&W.year>=0&&(M=new Date(M),M.setUTCFullYear(W.year,W.month-1,W.day)),+M}function El(W,M,q){return-Ct(Ye(W,1,M),q)+M-1}function bs(W,M=4,q=1){const J=El(W,M,q),ce=El(W+1,M,q);return(fr(W)-J+ce)/7}function Di(W){return W>99?W:W>mn.twoDigitCutoffYear?1900+W:2e3+W}function Ou(W,M,q,J=null){const ce=new Date(W),Ce={hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"};J&&(Ce.timeZone=J);const Ne={timeZoneName:M,...Ce},qe=new Intl.DateTimeFormat(q,Ne).formatToParts(ce).find(Xe=>Xe.type.toLowerCase()==="timezonename");return qe?qe.value:null}function Ml(W,M){let q=parseInt(W,10);Number.isNaN(q)&&(q=0);const J=parseInt(M,10)||0,ce=q<0||Object.is(q,-0)?-J:J;return q*60+ce}function xs(W){const M=Number(W);if(typeof W=="boolean"||W===""||!Number.isFinite(M))throw new i(`Invalid unit value ${W}`);return M}function bc(W,M){const q={};for(const J in W)if(Ft(W,J)){const ce=W[J];if(ce==null)continue;q[M(J)]=xs(ce)}return q}function Us(W,M){const q=Math.trunc(Math.abs(W/60)),J=Math.trunc(Math.abs(W%60)),ce=W>=0?"+":"-";switch(M){case"short":return`${ce}${tn(q,2)}:${tn(J,2)}`;case"narrow":return`${ce}${q}${J>0?`:${J}`:""}`;case"techie":return`${ce}${tn(q,2)}${tn(J,2)}`;default:throw new RangeError(`Value format ${M} is out of range for property format`)}}function Ol(W){return Pt(W,["hour","minute","second","millisecond"])}const Pu=["January","February","March","April","May","June","July","August","September","October","November","December"],af=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],$h=["J","F","M","A","M","J","J","A","S","O","N","D"];function Pl(W){switch(W){case"narrow":return[...$h];case"short":return[...af];case"long":return[...Pu];case"numeric":return["1","2","3","4","5","6","7","8","9","10","11","12"];case"2-digit":return["01","02","03","04","05","06","07","08","09","10","11","12"];default:return null}}const xc=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],wc=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],qs=["M","T","W","T","F","S","S"];function ws(W){switch(W){case"narrow":return[...qs];case"short":return[...wc];case"long":return[...xc];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}const ju=["AM","PM"],Au=["Before Christ","Anno Domini"],sf=["BC","AD"],jl=["B","A"];function Da(W){switch(W){case"narrow":return[...jl];case"short":return[...sf];case"long":return[...Au];default:return null}}function Du(W){return ju[W.hour<12?0:1]}function Al(W,M){return ws(M)[W.weekday-1]}function Ni(W,M){return Pl(M)[W.month-1]}function Nu(W,M){return Da(M)[W.year<0?0:1]}function Sc(W,M,q="always",J=!1){const ce={years:["year","yr."],quarters:["quarter","qtr."],months:["month","mo."],weeks:["week","wk."],days:["day","day","days"],hours:["hour","hr."],minutes:["minute","min."],seconds:["second","sec."]},Ce=["hours","minutes","seconds"].indexOf(W)===-1;if(q==="auto"&&Ce){const Fn=W==="days";switch(M){case 1:return Fn?"tomorrow":`next ${ce[W][0]}`;case-1:return Fn?"yesterday":`last ${ce[W][0]}`;case 0:return Fn?"today":`this ${ce[W][0]}`}}const Ne=Object.is(M,-0)||M<0,qe=Math.abs(M),Xe=qe===1,At=ce[W],Mn=J?Xe?At[1]:At[2]||At[1]:Xe?ce[W][0]:W;return Ne?`${qe} ${Mn} ago`:`in ${qe} ${Mn}`}function Iu(W,M){let q="";for(const J of W)J.literal?q+=J.val:q+=M(J.val);return q}const Cc={D:m,DD:g,DDD:x,DDDD:w,t:S,tt:b,ttt:$,tttt:k,T,TT:O,TTT:P,TTTT:D,f:A,ff:L,fff:z,ffff:B,F,FF:_,FFF:N,FFFF:I};class oo{static create(M,q={}){return new oo(M,q)}static parseFormat(M){let q=null,J="",ce=!1;const Ce=[];for(let Ne=0;Ne<M.length;Ne++){const qe=M.charAt(Ne);qe==="'"?((J.length>0||ce)&&Ce.push({literal:ce||/^\s+$/.test(J),val:J===""?"'":J}),q=null,J="",ce=!ce):ce||qe===q?J+=qe:(J.length>0&&Ce.push({literal:/^\s+$/.test(J),val:J}),J=qe,q=qe)}return J.length>0&&Ce.push({literal:ce||/^\s+$/.test(J),val:J}),Ce}static macroTokenToFormatOpts(M){return Cc[M]}constructor(M,q){this.opts=q,this.loc=M,this.systemLoc=null}formatWithSystemDefault(M,q){return this.systemLoc===null&&(this.systemLoc=this.loc.redefaultToSystem()),this.systemLoc.dtFormatter(M,{...this.opts,...q}).format()}dtFormatter(M,q={}){return this.loc.dtFormatter(M,{...this.opts,...q})}formatDateTime(M,q){return this.dtFormatter(M,q).format()}formatDateTimeParts(M,q){return this.dtFormatter(M,q).formatToParts()}formatInterval(M,q){return this.dtFormatter(M.start,q).dtf.formatRange(M.start.toJSDate(),M.end.toJSDate())}resolvedOptions(M,q){return this.dtFormatter(M,q).resolvedOptions()}num(M,q=0,J=void 0){if(this.opts.forceSimple)return tn(M,q);const ce={...this.opts};return q>0&&(ce.padTo=q),J&&(ce.signDisplay=J),this.loc.numberFormatter(ce).format(M)}formatDateTimeFromString(M,q){const J=this.loc.listingMode()==="en",ce=this.loc.outputCalendar&&this.loc.outputCalendar!=="gregory",Ce=(An,Jr)=>this.loc.extract(M,An,Jr),Ne=An=>M.isOffsetFixed&&M.offset===0&&An.allowZ?"Z":M.isValid?M.zone.formatOffset(M.ts,An.format):"",qe=()=>J?Du(M):Ce({hour:"numeric",hourCycle:"h12"},"dayperiod"),Xe=(An,Jr)=>J?Ni(M,An):Ce(Jr?{month:An}:{month:An,day:"numeric"},"month"),At=(An,Jr)=>J?Al(M,An):Ce(Jr?{weekday:An}:{weekday:An,month:"long",day:"numeric"},"weekday"),Mn=An=>{const Jr=oo.macroTokenToFormatOpts(An);return Jr?this.formatWithSystemDefault(M,Jr):An},Fn=An=>J?Nu(M,An):Ce({era:An},"era"),pr=An=>{switch(An){case"S":return this.num(M.millisecond);case"u":case"SSS":return this.num(M.millisecond,3);case"s":return this.num(M.second);case"ss":return this.num(M.second,2);case"uu":return this.num(Math.floor(M.millisecond/10),2);case"uuu":return this.num(Math.floor(M.millisecond/100));case"m":return this.num(M.minute);case"mm":return this.num(M.minute,2);case"h":return this.num(M.hour%12===0?12:M.hour%12);case"hh":return this.num(M.hour%12===0?12:M.hour%12,2);case"H":return this.num(M.hour);case"HH":return this.num(M.hour,2);case"Z":return Ne({format:"narrow",allowZ:this.opts.allowZ});case"ZZ":return Ne({format:"short",allowZ:this.opts.allowZ});case"ZZZ":return Ne({format:"techie",allowZ:this.opts.allowZ});case"ZZZZ":return M.zone.offsetName(M.ts,{format:"short",locale:this.loc.locale});case"ZZZZZ":return M.zone.offsetName(M.ts,{format:"long",locale:this.loc.locale});case"z":return M.zoneName;case"a":return qe();case"d":return ce?Ce({day:"numeric"},"day"):this.num(M.day);case"dd":return ce?Ce({day:"2-digit"},"day"):this.num(M.day,2);case"c":return this.num(M.weekday);case"ccc":return At("short",!0);case"cccc":return At("long",!0);case"ccccc":return At("narrow",!0);case"E":return this.num(M.weekday);case"EEE":return At("short",!1);case"EEEE":return At("long",!1);case"EEEEE":return At("narrow",!1);case"L":return ce?Ce({month:"numeric",day:"numeric"},"month"):this.num(M.month);case"LL":return ce?Ce({month:"2-digit",day:"numeric"},"month"):this.num(M.month,2);case"LLL":return Xe("short",!0);case"LLLL":return Xe("long",!0);case"LLLLL":return Xe("narrow",!0);case"M":return ce?Ce({month:"numeric"},"month"):this.num(M.month);case"MM":return ce?Ce({month:"2-digit"},"month"):this.num(M.month,2);case"MMM":return Xe("short",!1);case"MMMM":return Xe("long",!1);case"MMMMM":return Xe("narrow",!1);case"y":return ce?Ce({year:"numeric"},"year"):this.num(M.year);case"yy":return ce?Ce({year:"2-digit"},"year"):this.num(M.year.toString().slice(-2),2);case"yyyy":return ce?Ce({year:"numeric"},"year"):this.num(M.year,4);case"yyyyyy":return ce?Ce({year:"numeric"},"year"):this.num(M.year,6);case"G":return Fn("short");case"GG":return Fn("long");case"GGGGG":return Fn("narrow");case"kk":return this.num(M.weekYear.toString().slice(-2),2);case"kkkk":return this.num(M.weekYear,4);case"W":return this.num(M.weekNumber);case"WW":return this.num(M.weekNumber,2);case"n":return this.num(M.localWeekNumber);case"nn":return this.num(M.localWeekNumber,2);case"ii":return this.num(M.localWeekYear.toString().slice(-2),2);case"iiii":return this.num(M.localWeekYear,4);case"o":return this.num(M.ordinal);case"ooo":return this.num(M.ordinal,3);case"q":return this.num(M.quarter);case"qq":return this.num(M.quarter,2);case"X":return this.num(Math.floor(M.ts/1e3));case"x":return this.num(M.ts);default:return Mn(An)}};return Iu(oo.parseFormat(q),pr)}formatDurationFromString(M,q){const J=this.opts.signMode==="negativeLargestOnly"?-1:1,ce=Mn=>{switch(Mn[0]){case"S":return"milliseconds";case"s":return"seconds";case"m":return"minutes";case"h":return"hours";case"d":return"days";case"w":return"weeks";case"M":return"months";case"y":return"years";default:return null}},Ce=(Mn,Fn)=>pr=>{const An=ce(pr);if(An){const Jr=Fn.isNegativeDuration&&An!==Fn.largestUnit?J:1;let Qo;return this.opts.signMode==="negativeLargestOnly"&&An!==Fn.largestUnit?Qo="never":this.opts.signMode==="all"?Qo="always":Qo="auto",this.num(Mn.get(An)*Jr,pr.length,Qo)}else return pr},Ne=oo.parseFormat(q),qe=Ne.reduce((Mn,{literal:Fn,val:pr})=>Fn?Mn:Mn.concat(pr),[]),Xe=M.shiftTo(...qe.map(ce).filter(Mn=>Mn)),At={isNegativeDuration:Xe<0,largestUnit:Object.keys(Xe.values)[0]};return Iu(Ne,Ce(Xe,At))}}const Lu=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function U(...W){const M=W.reduce((q,J)=>q+J.source,"");return RegExp(`^${M}$`)}function $o(...W){return M=>W.reduce(([q,J,ce],Ce)=>{const[Ne,qe,Xe]=Ce(M,ce);return[{...q,...Ne},qe||J,Xe]},[{},null,1]).slice(0,2)}function ao(W,...M){if(W==null)return[null,null];for(const[q,J]of M){const ce=q.exec(W);if(ce)return J(ce)}return[null,null]}function ni(...W){return(M,q)=>{const J={};let ce;for(ce=0;ce<W.length;ce++)J[W[ce]]=Dr(M[q+ce]);return[J,null,q+ce]}}const je=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,Ss=`(?:${je.source}?(?:\\[(${Lu.source})\\])?)?`,zn=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,Ko=RegExp(`${zn.source}${Ss}`),Hs=RegExp(`(?:[Tt]${Ko.source})?`),zu=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,lf=/(\d{4})-?W(\d\d)(?:-?(\d))?/,cf=/(\d{4})-?(\d{3})/,ot=ni("weekYear","weekNumber","weekDay"),Fu=ni("year","ordinal"),_u=/(\d{4})-(\d\d)-(\d\d)/,kc=RegExp(`${zn.source} ?(?:${je.source}|(${Lu.source}))?`),uf=RegExp(`(?: ${kc.source})?`);function Vs(W,M,q){const J=W[M];return We(J)?q:Dr(J)}function Dl(W,M){return[{year:Vs(W,M),month:Vs(W,M+1,1),day:Vs(W,M+2,1)},null,M+3]}function Cs(W,M){return[{hours:Vs(W,M,0),minutes:Vs(W,M+1,0),seconds:Vs(W,M+2,0),milliseconds:Do(W[M+3])},null,M+4]}function Ws(W,M){const q=!W[M]&&!W[M+1],J=Ml(W[M+1],W[M+2]),ce=q?null:Rt.instance(J);return[{},ce,M+3]}function ua(W,M){const q=W[M]?ee.create(W[M]):null;return[{},q,M+1]}const Rh=RegExp(`^T?${zn.source}$`),Th=/^-?P(?:(?:(-?\d{1,20}(?:\.\d{1,20})?)Y)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20}(?:\.\d{1,20})?)W)?(?:(-?\d{1,20}(?:\.\d{1,20})?)D)?(?:T(?:(-?\d{1,20}(?:\.\d{1,20})?)H)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,20}))?S)?)?)$/;function Nl(W){const[M,q,J,ce,Ce,Ne,qe,Xe,At]=W,Mn=M[0]==="-",Fn=Xe&&Xe[0]==="-",pr=(An,Jr=!1)=>An!==void 0&&(Jr||An&&Mn)?-An:An;return[{years:pr(fo(q)),months:pr(fo(J)),weeks:pr(fo(ce)),days:pr(fo(Ce)),hours:pr(fo(Ne)),minutes:pr(fo(qe)),seconds:pr(fo(Xe),Xe==="-0"),milliseconds:pr(Do(At),Fn)}]}const df={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function Bu(W,M,q,J,ce,Ce,Ne){const qe={year:M.length===2?Di(Dr(M)):Dr(M),month:af.indexOf(q)+1,day:Dr(J),hour:Dr(ce),minute:Dr(Ce)};return Ne&&(qe.second=Dr(Ne)),W&&(qe.weekday=W.length>3?xc.indexOf(W)+1:wc.indexOf(W)+1),qe}const Eh=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/;function ff(W){const[,M,q,J,ce,Ce,Ne,qe,Xe,At,Mn,Fn]=W,pr=Bu(M,ce,J,q,Ce,Ne,qe);let An;return Xe?An=df[Xe]:At?An=0:An=Ml(Mn,Fn),[pr,new Rt(An)]}function Mh(W){return W.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}const pf=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/,Uu=/^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/,Oh=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/;function $c(W){const[,M,q,J,ce,Ce,Ne,qe]=W;return[Bu(M,ce,J,q,Ce,Ne,qe),Rt.utcInstance]}function Ph(W){const[,M,q,J,ce,Ce,Ne,qe]=W;return[Bu(M,qe,q,J,ce,Ce,Ne),Rt.utcInstance]}const jh=U(zu,Hs),Ah=U(lf,Hs),Dh=U(cf,Hs),qu=U(Ko),Ys=$o(Dl,Cs,Ws,ua),Nh=$o(ot,Cs,Ws,ua),hf=$o(Fu,Cs,Ws,ua),mf=$o(Cs,Ws,ua);function gf(W){return ao(W,[jh,Ys],[Ah,Nh],[Dh,hf],[qu,mf])}function yf(W){return ao(Mh(W),[Eh,ff])}function vf(W){return ao(W,[pf,$c],[Uu,$c],[Oh,Ph])}function Gs(W){return ao(W,[Th,Nl])}const Ih=$o(Cs);function Lh(W){return ao(W,[Rh,Ih])}const zh=U(_u,uf),bf=U(kc),xf=$o(Cs,Ws,ua);function Il(W){return ao(W,[zh,Ys],[bf,xf])}const ar="Invalid Duration",ks={weeks:{days:7,hours:168,minutes:10080,seconds:10080*60,milliseconds:10080*60*1e3},days:{hours:24,minutes:1440,seconds:1440*60,milliseconds:1440*60*1e3},hours:{minutes:60,seconds:3600,milliseconds:3600*1e3},minutes:{seconds:60,milliseconds:60*1e3},seconds:{milliseconds:1e3}},Zr={years:{quarters:4,months:12,weeks:52,days:365,hours:365*24,minutes:365*24*60,seconds:365*24*60*60,milliseconds:365*24*60*60*1e3},quarters:{months:3,weeks:13,days:91,hours:2184,minutes:2184*60,seconds:2184*60*60,milliseconds:2184*60*60*1e3},months:{weeks:4,days:30,hours:720,minutes:720*60,seconds:720*60*60,milliseconds:720*60*60*1e3},...ks},V=146097/400,te=146097/4800,X={years:{quarters:4,months:12,weeks:V/7,days:V,hours:V*24,minutes:V*24*60,seconds:V*24*60*60,milliseconds:V*24*60*60*1e3},quarters:{months:3,weeks:V/28,days:V/4,hours:V*24/4,minutes:V*24*60/4,seconds:V*24*60*60/4,milliseconds:V*24*60*60*1e3/4},months:{weeks:te/7,days:te,hours:te*24,minutes:te*24*60,seconds:te*24*60*60,milliseconds:te*24*60*60*1e3},...ks},$e=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],Zt=$e.slice(0).reverse();function Gt(W,M,q=!1){const J={values:q?M.values:{...W.values,...M.values||{}},loc:W.loc.clone(M.loc),conversionAccuracy:M.conversionAccuracy||W.conversionAccuracy,matrix:M.matrix||W.matrix};return new Qt(J)}function Dn(W,M){var q;let J=(q=M.milliseconds)!=null?q:0;for(const ce of Zt.slice(1))M[ce]&&(J+=M[ce]*W[ce].milliseconds);return J}function Qn(W,M){const q=Dn(W,M)<0?-1:1;$e.reduceRight((J,ce)=>{if(We(M[ce]))return J;if(J){const Ce=M[J]*q,Ne=W[ce][J],qe=Math.floor(Ce/Ne);M[ce]+=qe*q,M[J]-=qe*Ne*q}return ce},null),$e.reduce((J,ce)=>{if(We(M[ce]))return J;if(J){const Ce=M[J]%1;M[J]-=Ce,M[ce]+=Ce*W[J][ce]}return ce},null)}function Xn(W){const M={};for(const[q,J]of Object.entries(W))J!==0&&(M[q]=J);return M}class Qt{constructor(M){const q=M.conversionAccuracy==="longterm"||!1;let J=q?X:Zr;M.matrix&&(J=M.matrix),this.values=M.values,this.loc=M.loc||Oe.create(),this.conversionAccuracy=q?"longterm":"casual",this.invalid=M.invalid||null,this.matrix=J,this.isLuxonDuration=!0}static fromMillis(M,q){return Qt.fromObject({milliseconds:M},q)}static fromObject(M,q={}){if(M==null||typeof M!="object")throw new i(`Duration.fromObject: argument expected to be an object, got ${M===null?"null":typeof M}`);return new Qt({values:bc(M,Qt.normalizeUnit),loc:Oe.fromObject(q),conversionAccuracy:q.conversionAccuracy,matrix:q.matrix})}static fromDurationLike(M){if(Nt(M))return Qt.fromMillis(M);if(Qt.isDuration(M))return M;if(typeof M=="object")return Qt.fromObject(M);throw new i(`Unknown duration argument ${M} of type ${typeof M}`)}static fromISO(M,q){const[J]=Gs(M);return J?Qt.fromObject(J,q):Qt.invalid("unparsable",`the input "${M}" can't be parsed as ISO 8601`)}static fromISOTime(M,q){const[J]=Lh(M);return J?Qt.fromObject(J,q):Qt.invalid("unparsable",`the input "${M}" can't be parsed as ISO 8601`)}static invalid(M,q=null){if(!M)throw new i("need to specify a reason the Duration is invalid");const J=M instanceof Bn?M:new Bn(M,q);if(mn.throwOnInvalid)throw new r(J);return new Qt({invalid:J})}static normalizeUnit(M){const q={year:"years",years:"years",quarter:"quarters",quarters:"quarters",month:"months",months:"months",week:"weeks",weeks:"weeks",day:"days",days:"days",hour:"hours",hours:"hours",minute:"minutes",minutes:"minutes",second:"seconds",seconds:"seconds",millisecond:"milliseconds",milliseconds:"milliseconds"}[M&&M.toLowerCase()];if(!q)throw new a(M);return q}static isDuration(M){return M&&M.isLuxonDuration||!1}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}toFormat(M,q={}){const J={...q,floor:q.round!==!1&&q.floor!==!1};return this.isValid?oo.create(this.loc,J).formatDurationFromString(this,M):ar}toHuman(M={}){if(!this.isValid)return ar;const q=M.showZeros!==!1,J=$e.map(ce=>{const Ce=this.values[ce];return We(Ce)||Ce===0&&!q?null:this.loc.numberFormatter({style:"unit",unitDisplay:"long",...M,unit:ce.slice(0,-1)}).format(Ce)}).filter(ce=>ce);return this.loc.listFormatter({type:"conjunction",style:M.listStyle||"narrow",...M}).format(J)}toObject(){return this.isValid?{...this.values}:{}}toISO(){if(!this.isValid)return null;let M="P";return this.years!==0&&(M+=this.years+"Y"),(this.months!==0||this.quarters!==0)&&(M+=this.months+this.quarters*3+"M"),this.weeks!==0&&(M+=this.weeks+"W"),this.days!==0&&(M+=this.days+"D"),(this.hours!==0||this.minutes!==0||this.seconds!==0||this.milliseconds!==0)&&(M+="T"),this.hours!==0&&(M+=this.hours+"H"),this.minutes!==0&&(M+=this.minutes+"M"),(this.seconds!==0||this.milliseconds!==0)&&(M+=vs(this.seconds+this.milliseconds/1e3,3)+"S"),M==="P"&&(M+="T0S"),M}toISOTime(M={}){if(!this.isValid)return null;const q=this.toMillis();return q<0||q>=864e5?null:(M={suppressMilliseconds:!1,suppressSeconds:!1,includePrefix:!1,format:"extended",...M,includeOffset:!1},En.fromMillis(q,{zone:"UTC"}).toISOTime(M))}toJSON(){return this.toISO()}toString(){return this.toISO()}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Duration { values: ${JSON.stringify(this.values)} }`:`Duration { Invalid, reason: ${this.invalidReason} }`}toMillis(){return this.isValid?Dn(this.matrix,this.values):NaN}valueOf(){return this.toMillis()}plus(M){if(!this.isValid)return this;const q=Qt.fromDurationLike(M),J={};for(const ce of $e)(Ft(q.values,ce)||Ft(this.values,ce))&&(J[ce]=q.get(ce)+this.get(ce));return Gt(this,{values:J},!0)}minus(M){if(!this.isValid)return this;const q=Qt.fromDurationLike(M);return this.plus(q.negate())}mapUnits(M){if(!this.isValid)return this;const q={};for(const J of Object.keys(this.values))q[J]=xs(M(this.values[J],J));return Gt(this,{values:q},!0)}get(M){return this[Qt.normalizeUnit(M)]}set(M){if(!this.isValid)return this;const q={...this.values,...bc(M,Qt.normalizeUnit)};return Gt(this,{values:q})}reconfigure({locale:M,numberingSystem:q,conversionAccuracy:J,matrix:ce}={}){const Ce={loc:this.loc.clone({locale:M,numberingSystem:q}),matrix:ce,conversionAccuracy:J};return Gt(this,Ce)}as(M){return this.isValid?this.shiftTo(M).get(M):NaN}normalize(){if(!this.isValid)return this;const M=this.toObject();return Qn(this.matrix,M),Gt(this,{values:M},!0)}rescale(){if(!this.isValid)return this;const M=Xn(this.normalize().shiftToAll().toObject());return Gt(this,{values:M},!0)}shiftTo(...M){if(!this.isValid)return this;if(M.length===0)return this;M=M.map(Ne=>Qt.normalizeUnit(Ne));const q={},J={},ce=this.toObject();let Ce;for(const Ne of $e)if(M.indexOf(Ne)>=0){Ce=Ne;let qe=0;for(const At in J)qe+=this.matrix[At][Ne]*J[At],J[At]=0;Nt(ce[Ne])&&(qe+=ce[Ne]);const Xe=Math.trunc(qe);q[Ne]=Xe,J[Ne]=(qe*1e3-Xe*1e3)/1e3}else Nt(ce[Ne])&&(J[Ne]=ce[Ne]);for(const Ne in J)J[Ne]!==0&&(q[Ce]+=Ne===Ce?J[Ne]:J[Ne]/this.matrix[Ce][Ne]);return Qn(this.matrix,q),Gt(this,{values:q},!0)}shiftToAll(){return this.isValid?this.shiftTo("years","months","weeks","days","hours","minutes","seconds","milliseconds"):this}negate(){if(!this.isValid)return this;const M={};for(const q of Object.keys(this.values))M[q]=this.values[q]===0?0:-this.values[q];return Gt(this,{values:M},!0)}removeZeros(){if(!this.isValid)return this;const M=Xn(this.values);return Gt(this,{values:M},!0)}get years(){return this.isValid?this.values.years||0:NaN}get quarters(){return this.isValid?this.values.quarters||0:NaN}get months(){return this.isValid?this.values.months||0:NaN}get weeks(){return this.isValid?this.values.weeks||0:NaN}get days(){return this.isValid?this.values.days||0:NaN}get hours(){return this.isValid?this.values.hours||0:NaN}get minutes(){return this.isValid?this.values.minutes||0:NaN}get seconds(){return this.isValid?this.values.seconds||0:NaN}get milliseconds(){return this.isValid?this.values.milliseconds||0:NaN}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}equals(M){if(!this.isValid||!M.isValid||!this.loc.equals(M.loc))return!1;function q(J,ce){return J===void 0||J===0?ce===void 0||ce===0:J===ce}for(const J of $e)if(!q(this.values[J],M.values[J]))return!1;return!0}}const $r="Invalid Interval";function Rr(W,M){return!W||!W.isValid?xn.invalid("missing or invalid start"):!M||!M.isValid?xn.invalid("missing or invalid end"):M<W?xn.invalid("end before start",`The end of an interval must be after its start, but you had start=${W.toISO()} and end=${M.toISO()}`):null}class xn{constructor(M){this.s=M.start,this.e=M.end,this.invalid=M.invalid||null,this.isLuxonInterval=!0}static invalid(M,q=null){if(!M)throw new i("need to specify a reason the Interval is invalid");const J=M instanceof Bn?M:new Bn(M,q);if(mn.throwOnInvalid)throw new n(J);return new xn({invalid:J})}static fromDateTimes(M,q){const J=li(M),ce=li(q);return Rr(J,ce)??new xn({start:J,end:ce})}static after(M,q){const J=Qt.fromDurationLike(q),ce=li(M);return xn.fromDateTimes(ce,ce.plus(J))}static before(M,q){const J=Qt.fromDurationLike(q),ce=li(M);return xn.fromDateTimes(ce.minus(J),ce)}static fromISO(M,q){const[J,ce]=(M||"").split("/",2);if(J&&ce){let Ce,Ne;try{Ce=En.fromISO(J,q),Ne=Ce.isValid}catch{Ne=!1}let qe,Xe;try{qe=En.fromISO(ce,q),Xe=qe.isValid}catch{Xe=!1}if(Ne&&Xe)return xn.fromDateTimes(Ce,qe);if(Ne){const At=Qt.fromISO(ce,q);if(At.isValid)return xn.after(Ce,At)}else if(Xe){const At=Qt.fromISO(J,q);if(At.isValid)return xn.before(qe,At)}}return xn.invalid("unparsable",`the input "${M}" can't be parsed as ISO 8601`)}static isInterval(M){return M&&M.isLuxonInterval||!1}get start(){return this.isValid?this.s:null}get end(){return this.isValid?this.e:null}get lastDateTime(){return this.isValid&&this.e?this.e.minus(1):null}get isValid(){return this.invalidReason===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}length(M="milliseconds"){return this.isValid?this.toDuration(M).get(M):NaN}count(M="milliseconds",q){if(!this.isValid)return NaN;const J=this.start.startOf(M,q);let ce;return q!=null&&q.useLocaleWeeks?ce=this.end.reconfigure({locale:J.locale}):ce=this.end,ce=ce.startOf(M,q),Math.floor(ce.diff(J,M).get(M))+(ce.valueOf()!==this.end.valueOf())}hasSame(M){return this.isValid?this.isEmpty()||this.e.minus(1).hasSame(this.s,M):!1}isEmpty(){return this.s.valueOf()===this.e.valueOf()}isAfter(M){return this.isValid?this.s>M:!1}isBefore(M){return this.isValid?this.e<=M:!1}contains(M){return this.isValid?this.s<=M&&this.e>M:!1}set({start:M,end:q}={}){return this.isValid?xn.fromDateTimes(M||this.s,q||this.e):this}splitAt(...M){if(!this.isValid)return[];const q=M.map(li).filter(Ne=>this.contains(Ne)).sort((Ne,qe)=>Ne.toMillis()-qe.toMillis()),J=[];let{s:ce}=this,Ce=0;for(;ce<this.e;){const Ne=q[Ce]||this.e,qe=+Ne>+this.e?this.e:Ne;J.push(xn.fromDateTimes(ce,qe)),ce=qe,Ce+=1}return J}splitBy(M){const q=Qt.fromDurationLike(M);if(!this.isValid||!q.isValid||q.as("milliseconds")===0)return[];let{s:J}=this,ce=1,Ce;const Ne=[];for(;J<this.e;){const qe=this.start.plus(q.mapUnits(Xe=>Xe*ce));Ce=+qe>+this.e?this.e:qe,Ne.push(xn.fromDateTimes(J,Ce)),J=Ce,ce+=1}return Ne}divideEqually(M){return this.isValid?this.splitBy(this.length()/M).slice(0,M):[]}overlaps(M){return this.e>M.s&&this.s<M.e}abutsStart(M){return this.isValid?+this.e==+M.s:!1}abutsEnd(M){return this.isValid?+M.e==+this.s:!1}engulfs(M){return this.isValid?this.s<=M.s&&this.e>=M.e:!1}equals(M){return!this.isValid||!M.isValid?!1:this.s.equals(M.s)&&this.e.equals(M.e)}intersection(M){if(!this.isValid)return this;const q=this.s>M.s?this.s:M.s,J=this.e<M.e?this.e:M.e;return q>=J?null:xn.fromDateTimes(q,J)}union(M){if(!this.isValid)return this;const q=this.s<M.s?this.s:M.s,J=this.e>M.e?this.e:M.e;return xn.fromDateTimes(q,J)}static merge(M){const[q,J]=M.sort((ce,Ce)=>ce.s-Ce.s).reduce(([ce,Ce],Ne)=>Ce?Ce.overlaps(Ne)||Ce.abutsStart(Ne)?[ce,Ce.union(Ne)]:[ce.concat([Ce]),Ne]:[ce,Ne],[[],null]);return J&&q.push(J),q}static xor(M){let q=null,J=0;const ce=[],Ce=M.map(Xe=>[{time:Xe.s,type:"s"},{time:Xe.e,type:"e"}]),Ne=Array.prototype.concat(...Ce),qe=Ne.sort((Xe,At)=>Xe.time-At.time);for(const Xe of qe)J+=Xe.type==="s"?1:-1,J===1?q=Xe.time:(q&&+q!=+Xe.time&&ce.push(xn.fromDateTimes(q,Xe.time)),q=null);return xn.merge(ce)}difference(...M){return xn.xor([this].concat(M)).map(q=>this.intersection(q)).filter(q=>q&&!q.isEmpty())}toString(){return this.isValid?`[${this.s.toISO()} – ${this.e.toISO()})`:$r}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Interval { start: ${this.s.toISO()}, end: ${this.e.toISO()} }`:`Interval { Invalid, reason: ${this.invalidReason} }`}toLocaleString(M=m,q={}){return this.isValid?oo.create(this.s.loc.clone(q),M).formatInterval(this):$r}toISO(M){return this.isValid?`${this.s.toISO(M)}/${this.e.toISO(M)}`:$r}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:$r}toISOTime(M){return this.isValid?`${this.s.toISOTime(M)}/${this.e.toISOTime(M)}`:$r}toFormat(M,{separator:q=" – "}={}){return this.isValid?`${this.s.toFormat(M)}${q}${this.e.toFormat(M)}`:$r}toDuration(M,q){return this.isValid?this.e.diff(this.s,M,q):Qt.invalid(this.invalidReason)}mapEndpoints(M){return xn.fromDateTimes(M(this.s),M(this.e))}}class br{static hasDST(M=mn.defaultZone){const q=En.now().setZone(M).set({month:12});return!M.isUniversal&&q.offset!==q.set({month:6}).offset}static isValidIANAZone(M){return ee.isValidZone(M)}static normalizeZone(M){return it(M,mn.defaultZone)}static getStartOfWeek({locale:M=null,locObj:q=null}={}){return(q||Oe.create(M)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:M=null,locObj:q=null}={}){return(q||Oe.create(M)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:M=null,locObj:q=null}={}){return(q||Oe.create(M)).getWeekendDays().slice()}static months(M="long",{locale:q=null,numberingSystem:J=null,locObj:ce=null,outputCalendar:Ce="gregory"}={}){return(ce||Oe.create(q,J,Ce)).months(M)}static monthsFormat(M="long",{locale:q=null,numberingSystem:J=null,locObj:ce=null,outputCalendar:Ce="gregory"}={}){return(ce||Oe.create(q,J,Ce)).months(M,!0)}static weekdays(M="long",{locale:q=null,numberingSystem:J=null,locObj:ce=null}={}){return(ce||Oe.create(q,J,null)).weekdays(M)}static weekdaysFormat(M="long",{locale:q=null,numberingSystem:J=null,locObj:ce=null}={}){return(ce||Oe.create(q,J,null)).weekdays(M,!0)}static meridiems({locale:M=null}={}){return Oe.create(M).meridiems()}static eras(M="short",{locale:q=null}={}){return Oe.create(q,null,"gregory").eras(M)}static features(){return{relative:Pe(),localeWeek:ft()}}}function Wr(W,M){const q=ce=>ce.toUTC(0,{keepLocalTime:!0}).startOf("day").valueOf(),J=q(M)-q(W);return Math.floor(Qt.fromMillis(J).as("days"))}function Gr(W,M,q){const J=[["years",(Xe,At)=>At.year-Xe.year],["quarters",(Xe,At)=>At.quarter-Xe.quarter+(At.year-Xe.year)*4],["months",(Xe,At)=>At.month-Xe.month+(At.year-Xe.year)*12],["weeks",(Xe,At)=>{const Mn=Wr(Xe,At);return(Mn-Mn%7)/7}],["days",Wr]],ce={},Ce=W;let Ne,qe;for(const[Xe,At]of J)q.indexOf(Xe)>=0&&(Ne=Xe,ce[Xe]=At(W,M),qe=Ce.plus(ce),qe>M?(ce[Xe]--,W=Ce.plus(ce),W>M&&(qe=W,ce[Xe]--,W=Ce.plus(ce))):W=qe);return[W,ce,qe,Ne]}function ri(W,M,q,J){let[ce,Ce,Ne,qe]=Gr(W,M,q);const Xe=M-ce,At=q.filter(Fn=>["hours","minutes","seconds","milliseconds"].indexOf(Fn)>=0);At.length===0&&(Ne<M&&(Ne=ce.plus({[qe]:1})),Ne!==ce&&(Ce[qe]=(Ce[qe]||0)+Xe/(Ne-ce)));const Mn=Qt.fromObject(Ce,J);return At.length>0?Qt.fromMillis(Xe,J).shiftTo(...At).plus(Mn):Mn}const wa="missing Intl.DateTimeFormat.formatToParts support";function Un(W,M=q=>q){return{regex:W,deser:([q])=>M(Bt(q))}}const Ll="[ ]",Sa=new RegExp(Ll,"g");function $s(W){return W.replace(/\./g,"\\.?").replace(Sa,Ll)}function da(W){return W.replace(/\./g,"").replace(Sa," ").toLowerCase()}function io(W,M){return W===null?null:{regex:RegExp(W.map($s).join("|")),deser:([q])=>W.findIndex(J=>da(q)===da(J))+M}}function zl(W,M){return{regex:W,deser:([,q,J])=>Ml(q,J),groups:M}}function Ro(W){return{regex:W,deser:([M])=>M}}function Rc(W){return W.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function Fh(W,M){const q=qt(M),J=qt(M,"{2}"),ce=qt(M,"{3}"),Ce=qt(M,"{4}"),Ne=qt(M,"{6}"),qe=qt(M,"{1,2}"),Xe=qt(M,"{1,3}"),At=qt(M,"{1,6}"),Mn=qt(M,"{1,9}"),Fn=qt(M,"{2,4}"),pr=qt(M,"{4,6}"),An=Qo=>({regex:RegExp(Rc(Qo.val)),deser:([Na])=>Na,literal:!0}),Jr=(Qo=>{if(W.literal)return An(Qo);switch(Qo.val){case"G":return io(M.eras("short"),0);case"GG":return io(M.eras("long"),0);case"y":return Un(At);case"yy":return Un(Fn,Di);case"yyyy":return Un(Ce);case"yyyyy":return Un(pr);case"yyyyyy":return Un(Ne);case"M":return Un(qe);case"MM":return Un(J);case"MMM":return io(M.months("short",!0),1);case"MMMM":return io(M.months("long",!0),1);case"L":return Un(qe);case"LL":return Un(J);case"LLL":return io(M.months("short",!1),1);case"LLLL":return io(M.months("long",!1),1);case"d":return Un(qe);case"dd":return Un(J);case"o":return Un(Xe);case"ooo":return Un(ce);case"HH":return Un(J);case"H":return Un(qe);case"hh":return Un(J);case"h":return Un(qe);case"mm":return Un(J);case"m":return Un(qe);case"q":return Un(qe);case"qq":return Un(J);case"s":return Un(qe);case"ss":return Un(J);case"S":return Un(Xe);case"SSS":return Un(ce);case"u":return Ro(Mn);case"uu":return Ro(qe);case"uuu":return Un(q);case"a":return io(M.meridiems(),0);case"kkkk":return Un(Ce);case"kk":return Un(Fn,Di);case"W":return Un(qe);case"WW":return Un(J);case"E":case"c":return Un(q);case"EEE":return io(M.weekdays("short",!1),1);case"EEEE":return io(M.weekdays("long",!1),1);case"ccc":return io(M.weekdays("short",!0),1);case"cccc":return io(M.weekdays("long",!0),1);case"Z":case"ZZ":return zl(new RegExp(`([+-]${qe.source})(?::(${J.source}))?`),2);case"ZZZ":return zl(new RegExp(`([+-]${qe.source})(${J.source})?`),2);case"z":return Ro(/[a-z_+-/]{1,256}?/i);case" ":return Ro(/[^\S\n\r]/);default:return An(Qo)}})(W)||{invalidReason:wa};return Jr.token=W,Jr}const sv={year:{"2-digit":"yy",numeric:"yyyyy"},month:{numeric:"M","2-digit":"MM",short:"MMM",long:"MMMM"},day:{numeric:"d","2-digit":"dd"},weekday:{short:"EEE",long:"EEEE"},dayperiod:"a",dayPeriod:"a",hour12:{numeric:"h","2-digit":"hh"},hour24:{numeric:"H","2-digit":"HH"},minute:{numeric:"m","2-digit":"mm"},second:{numeric:"s","2-digit":"ss"},timeZoneName:{long:"ZZZZZ",short:"ZZZ"}};function Fl(W,M,q){const{type:J,value:ce}=W;if(J==="literal"){const Xe=/^\s+$/.test(ce);return{literal:!Xe,val:Xe?" ":ce}}const Ce=M[J];let Ne=J;J==="hour"&&(M.hour12!=null?Ne=M.hour12?"hour12":"hour24":M.hourCycle!=null?M.hourCycle==="h11"||M.hourCycle==="h12"?Ne="hour12":Ne="hour24":Ne=q.hour12?"hour12":"hour24");let qe=sv[Ne];if(typeof qe=="object"&&(qe=qe[Ce]),qe)return{literal:!1,val:qe}}function lv(W){return[`^${W.map(M=>M.regex).reduce((M,q)=>`${M}(${q.source})`,"")}$`,W]}function cv(W,M,q){const J=W.match(M);if(J){const ce={};let Ce=1;for(const Ne in q)if(Ft(q,Ne)){const qe=q[Ne],Xe=qe.groups?qe.groups+1:1;!qe.literal&&qe.token&&(ce[qe.token.val[0]]=qe.deser(J.slice(Ce,Ce+Xe))),Ce+=Xe}return[J,ce]}else return[J,{}]}function uv(W){const M=ce=>{switch(ce){case"S":return"millisecond";case"s":return"second";case"m":return"minute";case"h":case"H":return"hour";case"d":return"day";case"o":return"ordinal";case"L":case"M":return"month";case"y":return"year";case"E":case"c":return"weekday";case"W":return"weekNumber";case"k":return"weekYear";case"q":return"quarter";default:return null}};let q=null,J;return We(W.z)||(q=ee.create(W.z)),We(W.Z)||(q||(q=new Rt(W.Z)),J=W.Z),We(W.q)||(W.M=(W.q-1)*3+1),We(W.h)||(W.h<12&&W.a===1?W.h+=12:W.h===12&&W.a===0&&(W.h=0)),W.G===0&&W.y&&(W.y=-W.y),We(W.u)||(W.S=Do(W.u)),[Object.keys(W).reduce((ce,Ce)=>{const Ne=M(Ce);return Ne&&(ce[Ne]=W[Ce]),ce},{}),q,J]}let _h=null;function H1(){return _h||(_h=En.fromMillis(1555555555555)),_h}function V1(W,M){if(W.literal)return W;const q=oo.macroTokenToFormatOpts(W.val),J=qh(q,M);return J==null||J.includes(void 0)?W:J}function Bh(W,M){return Array.prototype.concat(...W.map(q=>V1(q,M)))}class Uh{constructor(M,q){if(this.locale=M,this.format=q,this.tokens=Bh(oo.parseFormat(q),M),this.units=this.tokens.map(J=>Fh(J,M)),this.disqualifyingUnit=this.units.find(J=>J.invalidReason),!this.disqualifyingUnit){const[J,ce]=lv(this.units);this.regex=RegExp(J,"i"),this.handlers=ce}}explainFromTokens(M){if(this.isValid){const[q,J]=cv(M,this.regex,this.handlers),[ce,Ce,Ne]=J?uv(J):[null,null,void 0];if(Ft(J,"a")&&Ft(J,"H"))throw new o("Can't include meridiem when specifying 24-hour format");return{input:M,tokens:this.tokens,regex:this.regex,rawMatches:q,matches:J,result:ce,zone:Ce,specificOffset:Ne}}else return{input:M,tokens:this.tokens,invalidReason:this.invalidReason}}get isValid(){return!this.disqualifyingUnit}get invalidReason(){return this.disqualifyingUnit?this.disqualifyingUnit.invalidReason:null}}function wf(W,M,q){return new Uh(W,q).explainFromTokens(M)}function oi(W,M,q){const{result:J,zone:ce,specificOffset:Ce,invalidReason:Ne}=wf(W,M,q);return[J,ce,Ce,Ne]}function qh(W,M){if(!W)return null;const q=oo.create(M,W).dtFormatter(H1()),J=q.formatToParts(),ce=q.resolvedOptions();return J.map(Ce=>Fl(Ce,W,ce))}const fa="Invalid DateTime",Ca=864e13;function Ii(W){return new Bn("unsupported zone",`the zone "${W.name}" is not supported`)}function Hu(W){return W.weekData===null&&(W.weekData=Mt(W.c)),W.weekData}function Tc(W){return W.localWeekData===null&&(W.localWeekData=Mt(W.c,W.loc.getMinDaysInFirstWeek(),W.loc.getStartOfWeek())),W.localWeekData}function Li(W,M){const q={ts:W.ts,zone:W.zone,c:W.c,o:W.o,loc:W.loc,invalid:W.invalid};return new En({...q,...M,old:q})}function Sf(W,M,q){let J=W-M*60*1e3;const ce=q.offset(J);if(M===ce)return[J,M];J-=(ce-M)*60*1e3;const Ce=q.offset(J);return ce===Ce?[J,ce]:[W-Math.min(ce,Ce)*60*1e3,Math.max(ce,Ce)]}function Rs(W,M){W+=M*60*1e3;const q=new Date(W);return{year:q.getUTCFullYear(),month:q.getUTCMonth()+1,day:q.getUTCDate(),hour:q.getUTCHours(),minute:q.getUTCMinutes(),second:q.getUTCSeconds(),millisecond:q.getUTCMilliseconds()}}function Vu(W,M,q){return Sf(ti(W),M,q)}function Wu(W,M){const q=W.o,J=W.c.year+Math.trunc(M.years),ce=W.c.month+Math.trunc(M.months)+Math.trunc(M.quarters)*3,Ce={...W.c,year:J,month:ce,day:Math.min(W.c.day,qr(J,ce))+Math.trunc(M.days)+Math.trunc(M.weeks)*7},Ne=Qt.fromObject({years:M.years-Math.trunc(M.years),quarters:M.quarters-Math.trunc(M.quarters),months:M.months-Math.trunc(M.months),weeks:M.weeks-Math.trunc(M.weeks),days:M.days-Math.trunc(M.days),hours:M.hours,minutes:M.minutes,seconds:M.seconds,milliseconds:M.milliseconds}).as("milliseconds"),qe=ti(Ce);let[Xe,At]=Sf(qe,q,W.zone);return Ne!==0&&(Xe+=Ne,At=W.zone.offset(Xe)),{ts:Xe,o:At}}function ai(W,M,q,J,ce,Ce){const{setZone:Ne,zone:qe}=q;if(W&&Object.keys(W).length!==0||M){const Xe=M||qe,At=En.fromObject(W,{...q,zone:Xe,specificOffset:Ce});return Ne?At:At.setZone(qe)}else return En.invalid(new Bn("unparsable",`the input "${ce}" can't be parsed as ${J}`))}function Cf(W,M,q=!0){return W.isValid?oo.create(Oe.create("en-US"),{allowZ:q,forceSimple:!0}).formatDateTimeFromString(W,M):null}function ra(W,M,q){const J=W.c.year>9999||W.c.year<0;let ce="";if(J&&W.c.year>=0&&(ce+="+"),ce+=tn(W.c.year,J?6:4),q==="year")return ce;if(M){if(ce+="-",ce+=tn(W.c.month),q==="month")return ce;ce+="-"}else if(ce+=tn(W.c.month),q==="month")return ce;return ce+=tn(W.c.day),ce}function kf(W,M,q,J,ce,Ce,Ne){let qe=!q||W.c.millisecond!==0||W.c.second!==0,Xe="";switch(Ne){case"day":case"month":case"year":break;default:if(Xe+=tn(W.c.hour),Ne==="hour")break;if(M){if(Xe+=":",Xe+=tn(W.c.minute),Ne==="minute")break;qe&&(Xe+=":",Xe+=tn(W.c.second))}else{if(Xe+=tn(W.c.minute),Ne==="minute")break;qe&&(Xe+=tn(W.c.second))}if(Ne==="second")break;qe&&(!J||W.c.millisecond!==0)&&(Xe+=".",Xe+=tn(W.c.millisecond,3))}return ce&&(W.isOffsetFixed&&W.offset===0&&!Ce?Xe+="Z":W.o<0?(Xe+="-",Xe+=tn(Math.trunc(-W.o/60)),Xe+=":",Xe+=tn(Math.trunc(-W.o%60))):(Xe+="+",Xe+=tn(Math.trunc(W.o/60)),Xe+=":",Xe+=tn(Math.trunc(W.o%60)))),Ce&&(Xe+="["+W.zone.ianaName+"]"),Xe}const zi={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},dv={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},$f={ordinal:1,hour:0,minute:0,second:0,millisecond:0},Fi=["year","month","day","hour","minute","second","millisecond"],Hh=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],Vh=["year","ordinal","hour","minute","second","millisecond"];function Ts(W){const M={year:"year",years:"year",month:"month",months:"month",day:"day",days:"day",hour:"hour",hours:"hour",minute:"minute",minutes:"minute",quarter:"quarter",quarters:"quarter",second:"second",seconds:"second",millisecond:"millisecond",milliseconds:"millisecond",weekday:"weekday",weekdays:"weekday",weeknumber:"weekNumber",weeksnumber:"weekNumber",weeknumbers:"weekNumber",weekyear:"weekYear",weekyears:"weekYear",ordinal:"ordinal"}[W.toLowerCase()];if(!M)throw new a(W);return M}function _l(W){switch(W.toLowerCase()){case"localweekday":case"localweekdays":return"localWeekday";case"localweeknumber":case"localweeknumbers":return"localWeekNumber";case"localweekyear":case"localweekyears":return"localWeekYear";default:return Ts(W)}}function Rf(W){if(ii===void 0&&(ii=mn.now()),W.type!=="iana")return W.offset(ii);const M=W.name;let q=si.get(M);return q===void 0&&(q=W.offset(ii),si.set(M,q)),q}function Yu(W,M){const q=it(M.zone,mn.defaultZone);if(!q.isValid)return En.invalid(Ii(q));const J=Oe.fromObject(M);let ce,Ce;if(We(W.year))ce=mn.now();else{for(const Xe of Fi)We(W[Xe])&&(W[Xe]=zi[Xe]);const Ne=Ue(W)||gt(W);if(Ne)return En.invalid(Ne);const qe=Rf(q);[ce,Ce]=Vu(W,qe,q)}return new En({ts:ce,zone:q,loc:J,o:Ce})}function ka(W,M,q){const J=We(q.round)?!0:q.round,ce=We(q.rounding)?"trunc":q.rounding,Ce=(qe,Xe)=>(qe=vs(qe,J||q.calendary?0:2,q.calendary?"round":ce),M.loc.clone(q).relFormatter(q).format(qe,Xe)),Ne=qe=>q.calendary?M.hasSame(W,qe)?0:M.startOf(qe).diff(W.startOf(qe),qe).get(qe):M.diff(W,qe).get(qe);if(q.unit)return Ce(Ne(q.unit),q.unit);for(const qe of q.units){const Xe=Ne(qe);if(Math.abs(Xe)>=1)return Ce(Xe,qe)}return Ce(W>M?-0:0,q.units[q.units.length-1])}function $a(W){let M={},q;return W.length>0&&typeof W[W.length-1]=="object"?(M=W[W.length-1],q=Array.from(W).slice(0,W.length-1)):q=Array.from(W),[M,q]}let ii;const si=new Map;class En{constructor(M){const q=M.zone||mn.defaultZone;let J=M.invalid||(Number.isNaN(M.ts)?new Bn("invalid input"):null)||(q.isValid?null:Ii(q));this.ts=We(M.ts)?mn.now():M.ts;let ce=null,Ce=null;if(!J)if(M.old&&M.old.ts===this.ts&&M.old.zone.equals(q))[ce,Ce]=[M.old.c,M.old.o];else{const Ne=Nt(M.o)&&!M.old?M.o:q.offset(this.ts);ce=Rs(this.ts,Ne),J=Number.isNaN(ce.year)?new Bn("invalid input"):null,ce=J?null:ce,Ce=J?null:Ne}this._zone=q,this.loc=M.loc||Oe.create(),this.invalid=J,this.weekData=null,this.localWeekData=null,this.c=ce,this.o=Ce,this.isLuxonDateTime=!0}static now(){return new En({})}static local(){const[M,q]=$a(arguments),[J,ce,Ce,Ne,qe,Xe,At]=q;return Yu({year:J,month:ce,day:Ce,hour:Ne,minute:qe,second:Xe,millisecond:At},M)}static utc(){const[M,q]=$a(arguments),[J,ce,Ce,Ne,qe,Xe,At]=q;return M.zone=Rt.utcInstance,Yu({year:J,month:ce,day:Ce,hour:Ne,minute:qe,second:Xe,millisecond:At},M)}static fromJSDate(M,q={}){const J=we(M)?M.valueOf():NaN;if(Number.isNaN(J))return En.invalid("invalid input");const ce=it(q.zone,mn.defaultZone);return ce.isValid?new En({ts:J,zone:ce,loc:Oe.fromObject(q)}):En.invalid(Ii(ce))}static fromMillis(M,q={}){if(Nt(M))return M<-Ca||M>Ca?En.invalid("Timestamp out of range"):new En({ts:M,zone:it(q.zone,mn.defaultZone),loc:Oe.fromObject(q)});throw new i(`fromMillis requires a numerical input, but received a ${typeof M} with value ${M}`)}static fromSeconds(M,q={}){if(Nt(M))return new En({ts:M*1e3,zone:it(q.zone,mn.defaultZone),loc:Oe.fromObject(q)});throw new i("fromSeconds requires a numerical input")}static fromObject(M,q={}){M=M||{};const J=it(q.zone,mn.defaultZone);if(!J.isValid)return En.invalid(Ii(J));const ce=Oe.fromObject(q),Ce=bc(M,_l),{minDaysInFirstWeek:Ne,startOfWeek:qe}=Vt(Ce,ce),Xe=mn.now(),At=We(q.specificOffset)?J.offset(Xe):q.specificOffset,Mn=!We(Ce.ordinal),Fn=!We(Ce.year),pr=!We(Ce.month)||!We(Ce.day),An=Fn||pr,Jr=Ce.weekYear||Ce.weekNumber;if((An||Mn)&&Jr)throw new o("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(pr&&Mn)throw new o("Can't mix ordinal dates with month/day");const Qo=Jr||Ce.weekday&&!An;let Na,Ia,La=Rs(Xe,At);Qo?(Na=Hh,Ia=dv,La=Mt(La,Ne,qe)):Mn?(Na=Vh,Ia=$f,La=Xt(La)):(Na=Fi,Ia=zi);let _i=!1;for(const Ks of Na){const pv=Ce[Ks];We(pv)?_i?Ce[Ks]=Ia[Ks]:Ce[Ks]=La[Ks]:_i=!0}const Wh=Qo?ge(Ce,Ne,qe):Mn?ye(Ce):Ue(Ce),Tf=Wh||gt(Ce);if(Tf)return En.invalid(Tf);const Gu=Qo?Lt(Ce,Ne,qe):Mn?zt(Ce):Ce,[Ef,Bl]=Vu(Gu,At,J),po=new En({ts:Ef,zone:J,o:Bl,loc:ce});return Ce.weekday&&An&&M.weekday!==po.weekday?En.invalid("mismatched weekday",`you can't specify both a weekday of ${Ce.weekday} and a date of ${po.toISO()}`):po.isValid?po:En.invalid(po.invalid)}static fromISO(M,q={}){const[J,ce]=gf(M);return ai(J,ce,q,"ISO 8601",M)}static fromRFC2822(M,q={}){const[J,ce]=yf(M);return ai(J,ce,q,"RFC 2822",M)}static fromHTTP(M,q={}){const[J,ce]=vf(M);return ai(J,ce,q,"HTTP",q)}static fromFormat(M,q,J={}){if(We(M)||We(q))throw new i("fromFormat requires an input string and a format");const{locale:ce=null,numberingSystem:Ce=null}=J,Ne=Oe.fromOpts({locale:ce,numberingSystem:Ce,defaultToEN:!0}),[qe,Xe,At,Mn]=oi(Ne,M,q);return Mn?En.invalid(Mn):ai(qe,Xe,J,`format ${q}`,M,At)}static fromString(M,q,J={}){return En.fromFormat(M,q,J)}static fromSQL(M,q={}){const[J,ce]=Il(M);return ai(J,ce,q,"SQL",M)}static invalid(M,q=null){if(!M)throw new i("need to specify a reason the DateTime is invalid");const J=M instanceof Bn?M:new Bn(M,q);if(mn.throwOnInvalid)throw new t(J);return new En({invalid:J})}static isDateTime(M){return M&&M.isLuxonDateTime||!1}static parseFormatForOpts(M,q={}){const J=qh(M,Oe.fromObject(q));return J?J.map(ce=>ce?ce.val:null).join(""):null}static expandFormat(M,q={}){return Bh(oo.parseFormat(M),Oe.fromObject(q)).map(J=>J.val).join("")}static resetCache(){ii=void 0,si.clear()}get(M){return this[M]}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}get outputCalendar(){return this.isValid?this.loc.outputCalendar:null}get zone(){return this._zone}get zoneName(){return this.isValid?this.zone.name:null}get year(){return this.isValid?this.c.year:NaN}get quarter(){return this.isValid?Math.ceil(this.c.month/3):NaN}get month(){return this.isValid?this.c.month:NaN}get day(){return this.isValid?this.c.day:NaN}get hour(){return this.isValid?this.c.hour:NaN}get minute(){return this.isValid?this.c.minute:NaN}get second(){return this.isValid?this.c.second:NaN}get millisecond(){return this.isValid?this.c.millisecond:NaN}get weekYear(){return this.isValid?Hu(this).weekYear:NaN}get weekNumber(){return this.isValid?Hu(this).weekNumber:NaN}get weekday(){return this.isValid?Hu(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?Tc(this).weekday:NaN}get localWeekNumber(){return this.isValid?Tc(this).weekNumber:NaN}get localWeekYear(){return this.isValid?Tc(this).weekYear:NaN}get ordinal(){return this.isValid?Xt(this.c).ordinal:NaN}get monthShort(){return this.isValid?br.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?br.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?br.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?br.weekdays("long",{locObj:this.loc})[this.weekday-1]:null}get offset(){return this.isValid?+this.o:NaN}get offsetNameShort(){return this.isValid?this.zone.offsetName(this.ts,{format:"short",locale:this.locale}):null}get offsetNameLong(){return this.isValid?this.zone.offsetName(this.ts,{format:"long",locale:this.locale}):null}get isOffsetFixed(){return this.isValid?this.zone.isUniversal:null}get isInDST(){return this.isOffsetFixed?!1:this.offset>this.set({month:1,day:1}).offset||this.offset>this.set({month:5}).offset}getPossibleOffsets(){if(!this.isValid||this.isOffsetFixed)return[this];const M=864e5,q=6e4,J=ti(this.c),ce=this.zone.offset(J-M),Ce=this.zone.offset(J+M),Ne=this.zone.offset(J-ce*q),qe=this.zone.offset(J-Ce*q);if(Ne===qe)return[this];const Xe=J-Ne*q,At=J-qe*q,Mn=Rs(Xe,Ne),Fn=Rs(At,qe);return Mn.hour===Fn.hour&&Mn.minute===Fn.minute&&Mn.second===Fn.second&&Mn.millisecond===Fn.millisecond?[Li(this,{ts:Xe}),Li(this,{ts:At})]:[this]}get isInLeapYear(){return ca(this.year)}get daysInMonth(){return qr(this.year,this.month)}get daysInYear(){return this.isValid?fr(this.year):NaN}get weeksInWeekYear(){return this.isValid?bs(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?bs(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(M={}){const{locale:q,numberingSystem:J,calendar:ce}=oo.create(this.loc.clone(M),M).resolvedOptions(this);return{locale:q,numberingSystem:J,outputCalendar:ce}}toUTC(M=0,q={}){return this.setZone(Rt.instance(M),q)}toLocal(){return this.setZone(mn.defaultZone)}setZone(M,{keepLocalTime:q=!1,keepCalendarTime:J=!1}={}){if(M=it(M,mn.defaultZone),M.equals(this.zone))return this;if(M.isValid){let ce=this.ts;if(q||J){const Ce=M.offset(this.ts),Ne=this.toObject();[ce]=Vu(Ne,Ce,M)}return Li(this,{ts:ce,zone:M})}else return En.invalid(Ii(M))}reconfigure({locale:M,numberingSystem:q,outputCalendar:J}={}){const ce=this.loc.clone({locale:M,numberingSystem:q,outputCalendar:J});return Li(this,{loc:ce})}setLocale(M){return this.reconfigure({locale:M})}set(M){if(!this.isValid)return this;const q=bc(M,_l),{minDaysInFirstWeek:J,startOfWeek:ce}=Vt(q,this.loc),Ce=!We(q.weekYear)||!We(q.weekNumber)||!We(q.weekday),Ne=!We(q.ordinal),qe=!We(q.year),Xe=!We(q.month)||!We(q.day),At=qe||Xe,Mn=q.weekYear||q.weekNumber;if((At||Ne)&&Mn)throw new o("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(Xe&&Ne)throw new o("Can't mix ordinal dates with month/day");let Fn;Ce?Fn=Lt({...Mt(this.c,J,ce),...q},J,ce):We(q.ordinal)?(Fn={...this.toObject(),...q},We(q.day)&&(Fn.day=Math.min(qr(Fn.year,Fn.month),Fn.day))):Fn=zt({...Xt(this.c),...q});const[pr,An]=Vu(Fn,this.o,this.zone);return Li(this,{ts:pr,o:An})}plus(M){if(!this.isValid)return this;const q=Qt.fromDurationLike(M);return Li(this,Wu(this,q))}minus(M){if(!this.isValid)return this;const q=Qt.fromDurationLike(M).negate();return Li(this,Wu(this,q))}startOf(M,{useLocaleWeeks:q=!1}={}){if(!this.isValid)return this;const J={},ce=Qt.normalizeUnit(M);switch(ce){case"years":J.month=1;case"quarters":case"months":J.day=1;case"weeks":case"days":J.hour=0;case"hours":J.minute=0;case"minutes":J.second=0;case"seconds":J.millisecond=0;break}if(ce==="weeks")if(q){const Ce=this.loc.getStartOfWeek(),{weekday:Ne}=this;Ne<Ce&&(J.weekNumber=this.weekNumber-1),J.weekday=Ce}else J.weekday=1;if(ce==="quarters"){const Ce=Math.ceil(this.month/3);J.month=(Ce-1)*3+1}return this.set(J)}endOf(M,q){return this.isValid?this.plus({[M]:1}).startOf(M,q).minus(1):this}toFormat(M,q={}){return this.isValid?oo.create(this.loc.redefaultToEN(q)).formatDateTimeFromString(this,M):fa}toLocaleString(M=m,q={}){return this.isValid?oo.create(this.loc.clone(q),M).formatDateTime(this):fa}toLocaleParts(M={}){return this.isValid?oo.create(this.loc.clone(M),M).formatDateTimeParts(this):[]}toISO({format:M="extended",suppressSeconds:q=!1,suppressMilliseconds:J=!1,includeOffset:ce=!0,extendedZone:Ce=!1,precision:Ne="milliseconds"}={}){if(!this.isValid)return null;Ne=Ts(Ne);const qe=M==="extended";let Xe=ra(this,qe,Ne);return Fi.indexOf(Ne)>=3&&(Xe+="T"),Xe+=kf(this,qe,q,J,ce,Ce,Ne),Xe}toISODate({format:M="extended",precision:q="day"}={}){return this.isValid?ra(this,M==="extended",Ts(q)):null}toISOWeekDate(){return Cf(this,"kkkk-'W'WW-c")}toISOTime({suppressMilliseconds:M=!1,suppressSeconds:q=!1,includeOffset:J=!0,includePrefix:ce=!1,extendedZone:Ce=!1,format:Ne="extended",precision:qe="milliseconds"}={}){return this.isValid?(qe=Ts(qe),(ce&&Fi.indexOf(qe)>=3?"T":"")+kf(this,Ne==="extended",q,M,J,Ce,qe)):null}toRFC2822(){return Cf(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",!1)}toHTTP(){return Cf(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss 'GMT'")}toSQLDate(){return this.isValid?ra(this,!0):null}toSQLTime({includeOffset:M=!0,includeZone:q=!1,includeOffsetSpace:J=!0}={}){let ce="HH:mm:ss.SSS";return(q||M)&&(J&&(ce+=" "),q?ce+="z":M&&(ce+="ZZ")),Cf(this,ce,!0)}toSQL(M={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(M)}`:null}toString(){return this.isValid?this.toISO():fa}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`DateTime { ts: ${this.toISO()}, zone: ${this.zone.name}, locale: ${this.locale} }`:`DateTime { Invalid, reason: ${this.invalidReason} }`}valueOf(){return this.toMillis()}toMillis(){return this.isValid?this.ts:NaN}toSeconds(){return this.isValid?this.ts/1e3:NaN}toUnixInteger(){return this.isValid?Math.floor(this.ts/1e3):NaN}toJSON(){return this.toISO()}toBSON(){return this.toJSDate()}toObject(M={}){if(!this.isValid)return{};const q={...this.c};return M.includeConfig&&(q.outputCalendar=this.outputCalendar,q.numberingSystem=this.loc.numberingSystem,q.locale=this.loc.locale),q}toJSDate(){return new Date(this.isValid?this.ts:NaN)}diff(M,q="milliseconds",J={}){if(!this.isValid||!M.isValid)return Qt.invalid("created by diffing an invalid DateTime");const ce={locale:this.locale,numberingSystem:this.numberingSystem,...J},Ce=kt(q).map(Qt.normalizeUnit),Ne=M.valueOf()>this.valueOf(),qe=Ne?this:M,Xe=Ne?M:this,At=ri(qe,Xe,Ce,ce);return Ne?At.negate():At}diffNow(M="milliseconds",q={}){return this.diff(En.now(),M,q)}until(M){return this.isValid?xn.fromDateTimes(this,M):this}hasSame(M,q,J){if(!this.isValid)return!1;const ce=M.valueOf(),Ce=this.setZone(M.zone,{keepLocalTime:!0});return Ce.startOf(q,J)<=ce&&ce<=Ce.endOf(q,J)}equals(M){return this.isValid&&M.isValid&&this.valueOf()===M.valueOf()&&this.zone.equals(M.zone)&&this.loc.equals(M.loc)}toRelative(M={}){if(!this.isValid)return null;const q=M.base||En.fromObject({},{zone:this.zone}),J=M.padding?this<q?-M.padding:M.padding:0;let ce=["years","months","days","hours","minutes","seconds"],Ce=M.unit;return Array.isArray(M.unit)&&(ce=M.unit,Ce=void 0),ka(q,this.plus(J),{...M,numeric:"always",units:ce,unit:Ce})}toRelativeCalendar(M={}){return this.isValid?ka(M.base||En.fromObject({},{zone:this.zone}),this,{...M,numeric:"auto",units:["years","months","days"],calendary:!0}):null}static min(...M){if(!M.every(En.isDateTime))throw new i("min requires all arguments be DateTimes");return Ot(M,q=>q.valueOf(),Math.min)}static max(...M){if(!M.every(En.isDateTime))throw new i("max requires all arguments be DateTimes");return Ot(M,q=>q.valueOf(),Math.max)}static fromFormatExplain(M,q,J={}){const{locale:ce=null,numberingSystem:Ce=null}=J,Ne=Oe.fromOpts({locale:ce,numberingSystem:Ce,defaultToEN:!0});return wf(Ne,M,q)}static fromStringExplain(M,q,J={}){return En.fromFormatExplain(M,q,J)}static buildFormatParser(M,q={}){const{locale:J=null,numberingSystem:ce=null}=q,Ce=Oe.fromOpts({locale:J,numberingSystem:ce,defaultToEN:!0});return new Uh(Ce,M)}static fromFormatParser(M,q,J={}){if(We(M)||We(q))throw new i("fromFormatParser requires an input string and a format parser");const{locale:ce=null,numberingSystem:Ce=null}=J,Ne=Oe.fromOpts({locale:ce,numberingSystem:Ce,defaultToEN:!0});if(!Ne.equals(q.locale))throw new i(`fromFormatParser called with a locale of ${Ne}, but the format parser was created for ${q.locale}`);const{result:qe,zone:Xe,specificOffset:At,invalidReason:Mn}=q.explainFromTokens(M);return Mn?En.invalid(Mn):ai(qe,Xe,J,`format ${q.format}`,M,At)}static get DATE_SHORT(){return m}static get DATE_MED(){return g}static get DATE_MED_WITH_WEEKDAY(){return y}static get DATE_FULL(){return x}static get DATE_HUGE(){return w}static get TIME_SIMPLE(){return S}static get TIME_WITH_SECONDS(){return b}static get TIME_WITH_SHORT_OFFSET(){return $}static get TIME_WITH_LONG_OFFSET(){return k}static get TIME_24_SIMPLE(){return T}static get TIME_24_WITH_SECONDS(){return O}static get TIME_24_WITH_SHORT_OFFSET(){return P}static get TIME_24_WITH_LONG_OFFSET(){return D}static get DATETIME_SHORT(){return A}static get DATETIME_SHORT_WITH_SECONDS(){return F}static get DATETIME_MED(){return L}static get DATETIME_MED_WITH_SECONDS(){return _}static get DATETIME_MED_WITH_WEEKDAY(){return R}static get DATETIME_FULL(){return z}static get DATETIME_FULL_WITH_SECONDS(){return N}static get DATETIME_HUGE(){return B}static get DATETIME_HUGE_WITH_SECONDS(){return I}}function li(W){if(En.isDateTime(W))return W;if(W&&W.valueOf&&Nt(W.valueOf()))return En.fromJSDate(W);if(W&&typeof W=="object")return En.fromObject(W);throw new i(`Unknown datetime argument: ${W}, of type ${typeof W}`)}const fv="3.7.2";return Ba.DateTime=En,Ba.Duration=Qt,Ba.FixedOffsetZone=Rt,Ba.IANAZone=ee,Ba.Info=br,Ba.Interval=xn,Ba.InvalidZone=vt,Ba.Settings=mn,Ba.SystemZone=ae,Ba.VERSION=fv,Ba.Zone=H,Ba}var kI;function iT(){return kI||(kI=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.CronDate=e.DAYS_IN_MONTH=e.DateMathOp=e.TimeUnit=void 0;const t=Twe();var n;(function(a){a.Second="Second",a.Minute="Minute",a.Hour="Hour",a.Day="Day",a.Month="Month",a.Year="Year"})(n||(e.TimeUnit=n={}));var r;(function(a){a.Add="Add",a.Subtract="Subtract"})(r||(e.DateMathOp=r={})),e.DAYS_IN_MONTH=Object.freeze([31,29,31,30,31,30,31,31,30,31,30,31]);class o{#e;#t=null;#n=null;constructor(i,s){const l={zone:s};if(i?i instanceof o?(this.#e=i.#e,this.#t=i.#t,this.#n=i.#n):i instanceof Date?this.#e=t.DateTime.fromJSDate(i,l):typeof i=="number"?this.#e=t.DateTime.fromMillis(i,l):(this.#e=t.DateTime.fromISO(i,l),this.#e.isValid||(this.#e=t.DateTime.fromRFC2822(i,l)),this.#e.isValid||(this.#e=t.DateTime.fromSQL(i,l)),this.#e.isValid||(this.#e=t.DateTime.fromFormat(i,"EEE, d MMM yyyy HH:mm:ss",l))):this.#e=t.DateTime.local(),!this.#e.isValid)throw new Error(`CronDate: unhandled timestamp: ${i}`);s&&s!==this.#e.zoneName&&(this.#e=this.#e.setZone(s))}static#o(i){return i%4===0&&i%100!==0||i%400===0}get dstStart(){return this.#t}set dstStart(i){this.#t=i}get dstEnd(){return this.#n}set dstEnd(i){this.#n=i}addYear(){this.#e=this.#e.plus({years:1})}addMonth(){this.#e=this.#e.plus({months:1}).startOf("month")}addDay(){this.#e=this.#e.plus({days:1}).startOf("day")}addHour(){this.#e=this.#e.plus({hours:1}).startOf("hour")}addMinute(){this.#e=this.#e.plus({minutes:1}).startOf("minute")}addSecond(){this.#e=this.#e.plus({seconds:1})}subtractYear(){this.#e=this.#e.minus({years:1})}subtractMonth(){this.#e=this.#e.minus({months:1}).endOf("month").startOf("second")}subtractDay(){this.#e=this.#e.minus({days:1}).endOf("day").startOf("second")}subtractHour(){this.#e=this.#e.minus({hours:1}).endOf("hour").startOf("second")}subtractMinute(){this.#e=this.#e.minus({minutes:1}).endOf("minute").startOf("second")}subtractSecond(){this.#e=this.#e.minus({seconds:1})}addUnit(i){switch(i){case n.Year:return this.addYear();case n.Month:return this.addMonth();case n.Day:return this.addDay();case n.Hour:return this.addHour();case n.Minute:return this.addMinute();case n.Second:return this.addSecond()}}subtractUnit(i){switch(i){case n.Year:return this.subtractYear();case n.Month:return this.subtractMonth();case n.Day:return this.subtractDay();case n.Hour:return this.subtractHour();case n.Minute:return this.subtractMinute();case n.Second:return this.subtractSecond()}}invokeDateOperation(i,s){if(i===r.Add){this.addUnit(s);return}if(i===r.Subtract){this.subtractUnit(s);return}throw new Error(`Invalid verb: ${i}`)}getDate(){return this.#e.day}getFullYear(){return this.#e.year}getDay(){const i=this.#e.weekday;return i===7?0:i}getMonth(){return this.#e.month-1}getHours(){return this.#e.hour}getMinutes(){return this.#e.minute}getSeconds(){return this.#e.second}getMilliseconds(){return this.#e.millisecond}getUTCOffset(){return this.#e.offset}setStartOfDay(){this.#e=this.#e.startOf("day")}setEndOfDay(){this.#e=this.#e.endOf("day")}getTime(){return this.#e.valueOf()}getUTCDate(){return this.#r().day}getUTCFullYear(){return this.#r().year}getUTCDay(){const i=this.#r().weekday;return i===7?0:i}getUTCMonth(){return this.#r().month-1}getUTCHours(){return this.#r().hour}getUTCMinutes(){return this.#r().minute}getUTCSeconds(){return this.#r().second}toISOString(){return this.#e.toUTC().toISO()}toJSON(){return this.#e.toJSON()}setDate(i){this.#e=this.#e.set({day:i})}setFullYear(i){this.#e=this.#e.set({year:i})}setDay(i){this.#e=this.#e.set({weekday:i})}setMonth(i){this.#e=this.#e.set({month:i+1})}setHours(i){this.#e=this.#e.set({hour:i})}setMinutes(i){this.#e=this.#e.set({minute:i})}setSeconds(i){this.#e=this.#e.set({second:i})}setMilliseconds(i){this.#e=this.#e.set({millisecond:i})}toString(){return this.toDate().toString()}toDate(){return this.#e.toJSDate()}isLastDayOfMonth(){const{day:i,month:s}=this.#e;if(s===2){const l=o.#o(this.#e.year);return i===e.DAYS_IN_MONTH[s-1]-(l?0:1)}return i===e.DAYS_IN_MONTH[s-1]}isLastWeekdayOfMonth(){const{day:i,month:s}=this.#e;let l;return s===2?l=e.DAYS_IN_MONTH[s-1]-(o.#o(this.#e.year)?0:1):l=e.DAYS_IN_MONTH[s-1],i>l-7}applyDateOperation(i,s,l){if(s===n.Month||s===n.Day){this.invokeDateOperation(i,s);return}const d=this.getHours();this.invokeDateOperation(i,s);const u=this.getHours(),m=u-d;m===2?l!==24&&(this.dstStart=d+1):m===0&&this.getMinutes()===0&&this.getSeconds()===0&&l!==24&&(this.dstEnd=u)}#r(){return this.#e.toUTC()}}e.CronDate=o,e.default=o})(SI)),SI}var $I;function Ewe(){if($I)return fg;$I=1,Object.defineProperty(fg,"__esModule",{value:!0}),fg.CronMonth=void 0;const e=iT(),t=rf(),n=1,r=12,o=Object.freeze([]);let a=class extends t.CronField{static get min(){return n}static get max(){return r}static get chars(){return o}static get daysInMonth(){return e.DAYS_IN_MONTH}constructor(i,s){super(i,s),this.validate()}get values(){return super.values}};return fg.CronMonth=a,fg}var pg={},RI;function Mwe(){if(RI)return pg;RI=1,Object.defineProperty(pg,"__esModule",{value:!0}),pg.CronSecond=void 0;const e=rf(),t=0,n=59,r=Object.freeze([]);let o=class extends e.CronField{static get min(){return t}static get max(){return n}static get chars(){return r}constructor(a,i){super(a,i),this.validate()}get values(){return super.values}};return pg.CronSecond=o,pg}var TI;function sT(){return TI||(TI=1,(function(e){var t=pp&&pp.__createBinding||(Object.create?(function(r,o,a,i){i===void 0&&(i=a);var s=Object.getOwnPropertyDescriptor(o,a);(!s||("get"in s?!o.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return o[a]}}),Object.defineProperty(r,i,s)}):(function(r,o,a,i){i===void 0&&(i=a),r[i]=o[a]})),n=pp&&pp.__exportStar||function(r,o){for(var a in r)a!=="default"&&!Object.prototype.hasOwnProperty.call(o,a)&&t(o,r,a)};Object.defineProperty(e,"__esModule",{value:!0}),n(Swe(),e),n(Cwe(),e),n(kwe(),e),n(rf(),e),n($we(),e),n(Rwe(),e),n(Ewe(),e),n(Mwe(),e)})(pp)),pp}var EI;function d6(){if(EI)return ig;EI=1,Object.defineProperty(ig,"__esModule",{value:!0}),ig.CronFieldCollection=void 0;const e=sT();let t=class Pg{#e;#t;#n;#o;#r;#a;static from(r,o){return new Pg({second:this.resolveField(e.CronSecond,r.second,o.second),minute:this.resolveField(e.CronMinute,r.minute,o.minute),hour:this.resolveField(e.CronHour,r.hour,o.hour),dayOfMonth:this.resolveField(e.CronDayOfMonth,r.dayOfMonth,o.dayOfMonth),month:this.resolveField(e.CronMonth,r.month,o.month),dayOfWeek:this.resolveField(e.CronDayOfWeek,r.dayOfWeek,o.dayOfWeek)})}static resolveField(r,o,a){return a?a instanceof e.CronField?a:new r(a):o}constructor({second:r,minute:o,hour:a,dayOfMonth:i,month:s,dayOfWeek:l}){if(!r)throw new Error("Validation error, Field second is missing");if(!o)throw new Error("Validation error, Field minute is missing");if(!a)throw new Error("Validation error, Field hour is missing");if(!i)throw new Error("Validation error, Field dayOfMonth is missing");if(!s)throw new Error("Validation error, Field month is missing");if(!l)throw new Error("Validation error, Field dayOfWeek is missing");if(s.values.length===1&&!i.hasLastChar&&l.isWildcard&&!(parseInt(i.values[0],10)<=e.CronMonth.daysInMonth[s.values[0]-1]))throw new Error("Invalid explicit day of month definition");this.#e=r,this.#t=o,this.#n=a,this.#r=s,this.#a=l,this.#o=i}get second(){return this.#e}get minute(){return this.#t}get hour(){return this.#n}get dayOfMonth(){return this.#o}get month(){return this.#r}get dayOfWeek(){return this.#a}static compactField(r){if(r.length===0)return[];const o=[];let a;return r.forEach((i,s,l)=>{if(a===void 0){a={start:i,count:1};return}const d=l[s-1]||a.start,u=l[s+1];if(i==="L"||i==="W"){o.push(a),o.push({start:i,count:1}),a=void 0;return}if(a.step===void 0&&u!==void 0){const m=i-d,g=u-i;if(m<=g){a={...a,count:2,end:i,step:m};return}a.step=1}i-(a.end??0)===a.step?(a.count++,a.end=i):(a.count===1?o.push({start:a.start,count:1}):a.count===2?(o.push({start:a.start,count:1}),o.push({start:a.end??d,count:1})):o.push(a),a={start:i,count:1})}),a&&o.push(a),o}static#s(r,o,a){const i=o.step;return i?i===1&&o.start===r.min&&o.end&&o.end>=a?r.hasQuestionMarkChar?"?":"*":i!==1&&o.start===r.min&&o.end&&o.end>=a-i+1?`*/${i}`:null:null}static#i(r,o){const a=r.step;if(a===1)return`${r.start}-${r.end}`;const i=r.start===0?r.count-1:r.count;if(!a)throw new Error("Unexpected range step");if(!r.end)throw new Error("Unexpected range end");if(a*i>r.end){const s=(d,u)=>{if(typeof r.start!="number")throw new Error("Unexpected range start");return u%a===0?r.start+u:null};if(typeof r.start!="number")throw new Error("Unexpected range start");const l={length:r.end-r.start+1};return Array.from(l,s).filter(d=>d!==null).join(",")}return r.end===o-a+1?`${r.start}/${a}`:`${r.start}-${r.end}/${a}`}stringifyField(r){let o=r.max,a=r.values;if(r instanceof e.CronDayOfWeek){o=6;const s=this.#a.values;a=s[s.length-1]===7?s.slice(0,-1):s}r instanceof e.CronDayOfMonth&&(o=this.#r.values.length===1?e.CronMonth.daysInMonth[this.#r.values[0]-1]:r.max);const i=Pg.compactField(a);if(i.length===1){const s=Pg.#s(r,i[0],o);if(s)return s}return i.map(s=>{const l=s.count===1?s.start.toString():Pg.#i(s,o);return r instanceof e.CronDayOfWeek&&r.nthDay>0?`${l}#${r.nthDay}`:l}).join(",")}stringify(r=!1){const o=[];return r&&o.push(this.stringifyField(this.#e)),o.push(this.stringifyField(this.#t),this.stringifyField(this.#n),this.stringifyField(this.#o),this.stringifyField(this.#r),this.stringifyField(this.#a)),o.join(" ")}serialize(){return{second:this.#e.serialize(),minute:this.#t.serialize(),hour:this.#n.serialize(),dayOfMonth:this.#o.serialize(),month:this.#r.serialize(),dayOfWeek:this.#a.serialize()}}};return ig.CronFieldCollection=t,ig}var MI={},OI;function f6(){return OI||(OI=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.CronExpression=e.LOOPS_LIMIT_EXCEEDED_ERROR_MESSAGE=e.TIME_SPAN_OUT_OF_BOUNDS_ERROR_MESSAGE=void 0;const t=iT();e.TIME_SPAN_OUT_OF_BOUNDS_ERROR_MESSAGE="Out of the time span range",e.LOOPS_LIMIT_EXCEEDED_ERROR_MESSAGE="Invalid expression, loop limit exceeded";const n=1e4;class r{#e;#t;#n;#o;#r;#a;#s=null;#i=!1;constructor(a,i){this.#e=i,this.#t=i.tz,this.#o=i.startDate?new t.CronDate(i.startDate,this.#t):null,this.#r=i.endDate?new t.CronDate(i.endDate,this.#t):null;let s=i.currentDate??i.startDate;if(s){const l=new t.CronDate(s,this.#t);this.#o&&l.getTime()<this.#o.getTime()?s=this.#o:this.#r&&l.getTime()>this.#r.getTime()&&(s=this.#r)}this.#n=new t.CronDate(s,this.#t),this.#a=a}get fields(){return this.#a}static fieldsToExpression(a,i){return new r(a,i||{})}static#c(a,i){return i.some(s=>s===a)}#l(a,i){return a[i?a.length-1:0]}#d(a){const i=`${a.getFullYear()}-${a.getMonth()+1}-${a.getDate()}`;if(this.#s===i)return this.#i;const s=new t.CronDate(a);s.setStartOfDay();const l=new t.CronDate(a);return l.setEndOfDay(),this.#s=i,this.#i=s.getUTCOffset()!==l.getUTCOffset(),this.#i}#u(a,i,s){const l=this.#a.second.values,d=a.getSeconds(),u=this.#a.second.findNearestValue(d,s);if(u!==null){a.setSeconds(u);return}a.applyDateOperation(i,t.TimeUnit.Minute,this.#a.hour.values.length),a.setSeconds(this.#l(l,s))}#p(a,i,s){const l=this.#a.minute.values,d=this.#a.second.values,u=a.getMinutes(),m=this.#a.minute.findNearestValue(u,s);if(m!==null){a.setMinutes(m),a.setSeconds(this.#l(d,s));return}a.applyDateOperation(i,t.TimeUnit.Hour,this.#a.hour.values.length),a.setMinutes(this.#l(l,s)),a.setSeconds(this.#l(d,s))}static#f(a,i){const s=i.isLastWeekdayOfMonth();return a.some(l=>{const d=parseInt(l.toString().charAt(0),10)%7;if(Number.isNaN(d))throw new Error(`Invalid last weekday of the month expression: ${l}`);return i.getDay()===d&&s})}next(){return this.#h()}prev(){return this.#h(!0)}hasNext(){const a=this.#n;try{return this.#h(),!0}catch{return!1}finally{this.#n=a}}hasPrev(){const a=this.#n;try{return this.#h(!0),!0}catch{return!1}finally{this.#n=a}}take(a){const i=[];if(a>=0)for(let s=0;s<a;s++)try{i.push(this.next())}catch{return i}else for(let s=0;s>a;s--)try{i.push(this.prev())}catch{return i}return i}reset(a){this.#n=new t.CronDate(a||this.#e.currentDate,this.#t)}stringify(a=!1){return this.#a.stringify(a)}includesDate(a){const{second:i,minute:s,hour:l,month:d}=this.#a,u=new t.CronDate(a,this.#t);return!(!i.values.includes(u.getSeconds())||!s.values.includes(u.getMinutes())||!l.values.includes(u.getHours())||!d.values.includes(u.getMonth()+1)||!this.#m(u)||this.#a.dayOfWeek.nthDay>0&&Math.ceil(u.getDate()/7)!==this.#a.dayOfWeek.nthDay)}toString(){return this.#e.expression||this.stringify(!0)}#m(a){const i=this.#a.dayOfMonth.isWildcard,s=!i,l=this.#a.dayOfWeek.isWildcard,d=!l,u=r.#c(a.getDate(),this.#a.dayOfMonth.values)||this.#a.dayOfMonth.hasLastChar&&a.isLastDayOfMonth(),m=r.#c(a.getDay(),this.#a.dayOfWeek.values)||this.#a.dayOfWeek.hasLastChar&&r.#f(this.#a.dayOfWeek.values,a);return!!(s&&d&&(u||m)||u&&!d||i&&!l&&m)}#g(a,i,s){const l=this.#a.hour.values,d=l,u=a.getHours(),m=r.#c(u,l),g=a.dstEnd===u;if(a.dstStart!==null&&a.dstStart===u-1&&r.#c(a.dstStart,l))return!0;if(g&&!s)return a.dstEnd=null,a.applyDateOperation(t.DateMathOp.Add,t.TimeUnit.Hour,d.length),!1;if(m)return!0;a.dstStart=null;const y=this.#a.hour.findNearestValue(u,s);if(y===null)return a.applyDateOperation(i,t.TimeUnit.Day,d.length),!1;if(this.#d(a)){const x=s?u-y:y-u;for(let w=0;w<x&&(a.applyDateOperation(i,t.TimeUnit.Hour,d.length),!(!s&&a.getHours()>=y||s&&a.getHours()<=y));w++);}else a.setHours(y);return a.setMinutes(this.#l(this.#a.minute.values,s)),a.setSeconds(this.#l(this.#a.second.values,s)),!1}#y(a){if(!this.#o&&!this.#r)return;const i=a.getTime();if(this.#o&&i<this.#o.getTime())throw new Error(e.TIME_SPAN_OUT_OF_BOUNDS_ERROR_MESSAGE);if(this.#r&&i>this.#r.getTime())throw new Error(e.TIME_SPAN_OUT_OF_BOUNDS_ERROR_MESSAGE)}#h(a=!1){const i=a?t.DateMathOp.Subtract:t.DateMathOp.Add,s=new t.CronDate(this.#n),l=s.getTime();let d=0;for(;++d<n;){if(this.#y(s),!this.#m(s)){s.applyDateOperation(i,t.TimeUnit.Day,this.#a.hour.values.length);continue}if(!(this.#a.dayOfWeek.nthDay<=0||Math.ceil(s.getDate()/7)===this.#a.dayOfWeek.nthDay)){s.applyDateOperation(i,t.TimeUnit.Day,this.#a.hour.values.length);continue}if(!r.#c(s.getMonth()+1,this.#a.month.values)){s.applyDateOperation(i,t.TimeUnit.Month,this.#a.hour.values.length);continue}if(this.#g(s,i,a)){if(!r.#c(s.getMinutes(),this.#a.minute.values)){this.#p(s,i,a);continue}if(!r.#c(s.getSeconds(),this.#a.second.values)){this.#u(s,i,a);continue}if(l===s.getTime()){(i==="Add"||s.getMilliseconds()===0)&&s.applyDateOperation(i,t.TimeUnit.Second,this.#a.hour.values.length);continue}break}}if(d>n)throw new Error(e.LOOPS_LIMIT_EXCEEDED_ERROR_MESSAGE);return s.getMilliseconds()!==0&&s.setMilliseconds(0),this.#n=s,s}[Symbol.iterator](){return{next:()=>{try{return{value:this.#h(),done:!1}}catch{return{value:void 0,done:!0}}}}}}e.CronExpression=r,e.default=r})(MI)),MI}var Ub={},PI;function Owe(){if(PI)return Ub;PI=1,Object.defineProperty(Ub,"__esModule",{value:!0}),Ub.seededRandom=n;function e(r){let o=2166136261;for(let a=0;a<r.length;a++)o^=r.charCodeAt(a),o=Math.imul(o,16777619);return()=>o>>>0}function t(r){return()=>{let o=r+=1831565813;return o=Math.imul(o^o>>>15,o|1),o^=o+Math.imul(o^o>>>7,o|61),((o^o>>>14)>>>0)/4294967296}}function n(r){const o=r?e(r)():Math.floor(Math.random()*1e10);return t(o)}return Ub}var jI;function $$(){if(jI)return hi;jI=1,Object.defineProperty(hi,"__esModule",{value:!0}),hi.CronExpressionParser=hi.DayOfWeek=hi.Months=hi.CronUnit=hi.PredefinedExpressions=void 0;const e=d6(),t=f6(),n=Owe(),r=sT();var o;(function(d){d["@yearly"]="0 0 0 1 1 *",d["@annually"]="0 0 0 1 1 *",d["@monthly"]="0 0 0 1 * *",d["@weekly"]="0 0 0 * * 0",d["@daily"]="0 0 0 * * *",d["@hourly"]="0 0 * * * *",d["@minutely"]="0 * * * * *",d["@secondly"]="* * * * * *",d["@weekdays"]="0 0 0 * * 1-5",d["@weekends"]="0 0 0 * * 0,6"})(o||(hi.PredefinedExpressions=o={}));var a;(function(d){d.Second="Second",d.Minute="Minute",d.Hour="Hour",d.DayOfMonth="DayOfMonth",d.Month="Month",d.DayOfWeek="DayOfWeek"})(a||(hi.CronUnit=a={}));var i;(function(d){d[d.jan=1]="jan",d[d.feb=2]="feb",d[d.mar=3]="mar",d[d.apr=4]="apr",d[d.may=5]="may",d[d.jun=6]="jun",d[d.jul=7]="jul",d[d.aug=8]="aug",d[d.sep=9]="sep",d[d.oct=10]="oct",d[d.nov=11]="nov",d[d.dec=12]="dec"})(i||(hi.Months=i={}));var s;(function(d){d[d.sun=0]="sun",d[d.mon=1]="mon",d[d.tue=2]="tue",d[d.wed=3]="wed",d[d.thu=4]="thu",d[d.fri=5]="fri",d[d.sat=6]="sat"})(s||(hi.DayOfWeek=s={}));let l=class mi{static parse(u,m={}){const{strict:g=!1,hashSeed:y}=m,x=(0,n.seededRandom)(y);u=o[u]||u;const w=mi.#e(u,g);if(!(w.dayOfMonth==="*"||w.dayOfWeek==="*"||!g))throw new Error("Cannot use both dayOfMonth and dayOfWeek together in strict mode!");const S=mi.#t(a.Second,w.second,r.CronSecond.constraints,x),b=mi.#t(a.Minute,w.minute,r.CronMinute.constraints,x),$=mi.#t(a.Hour,w.hour,r.CronHour.constraints,x),k=mi.#t(a.Month,w.month,r.CronMonth.constraints,x),T=mi.#t(a.DayOfMonth,w.dayOfMonth,r.CronDayOfMonth.constraints,x),{dayOfWeek:O,nthDayOfWeek:P}=mi.#d(w.dayOfWeek),D=mi.#t(a.DayOfWeek,O,r.CronDayOfWeek.constraints,x),A=new e.CronFieldCollection({second:new r.CronSecond(S,{rawValue:w.second}),minute:new r.CronMinute(b,{rawValue:w.minute}),hour:new r.CronHour($,{rawValue:w.hour}),dayOfMonth:new r.CronDayOfMonth(T,{rawValue:w.dayOfMonth}),month:new r.CronMonth(k,{rawValue:w.month}),dayOfWeek:new r.CronDayOfWeek(D,{rawValue:w.dayOfWeek,nthDayOfWeek:P})});return new t.CronExpression(A,{...m,expression:u})}static#e(u,m){if(m&&!u.length)throw new Error("Invalid cron expression");u=u||"0 * * * * *";const g=u.trim().split(/\s+/);if(m&&g.length<6)throw new Error("Invalid cron expression, expected 6 fields");if(g.length>6)throw new Error("Invalid cron expression, too many fields");const y=["*","*","*","*","*","0"];g.length<y.length&&g.unshift(...y.slice(g.length));const[x,w,S,b,$,k]=g;return{second:x,minute:w,hour:S,dayOfMonth:b,month:$,dayOfWeek:k}}static#t(u,m,g,y){if((u===a.Month||u===a.DayOfWeek)&&(m=m.replace(/[a-z]{3}/gi,x=>{x=x.toLowerCase();const w=i[x]||s[x];if(w===void 0)throw new Error(`Validation error, cannot resolve alias "${x}"`);return w.toString()})),!g.validChars.test(m))throw new Error(`Invalid characters, got value: ${m}`);return m=this.#n(m,g),m=this.#o(m,g,y),this.#r(u,m,g)}static#n(u,m){return u.replace(/[*?]/g,m.min+"-"+m.max)}static#o(u,m,g){const y=g();return u.replace(/H(?:\((\d+)-(\d+)\))?(?:\/(\d+))?/g,(x,w,S,b)=>{if(w&&S&&b){const $=parseInt(w,10),k=parseInt(S,10),T=parseInt(b,10);if($>k)throw new Error(`Invalid range: ${$}-${k}, min > max`);if(T<=0)throw new Error(`Invalid step: ${T}, must be positive`);const O=Math.max($,m.min),P=Math.floor(y*T),D=[];for(let A=Math.floor(O/T)*T+P;A<=k;A+=T)A>=O&&D.push(A);return D.join(",")}else if(w&&S){const $=parseInt(w,10),k=parseInt(S,10);if($>k)throw new Error(`Invalid range: ${$}-${k}, min > max`);return String(Math.floor(y*(k-$+1))+$)}else if(b){const $=parseInt(b,10);if($<=0)throw new Error(`Invalid step: ${$}, must be positive`);const k=Math.floor(y*$),T=[];for(let O=Math.floor(m.min/$)*$+k;O<=m.max;O+=$)O>=m.min&&T.push(O);return T.join(",")}else return String(Math.floor(y*(m.max-m.min+1)+m.min))})}static#r(u,m,g){const y=[];function x(w,S){if(Array.isArray(w))y.push(...w);else if(mi.#u(S,w))y.push(w);else{const b=parseInt(w.toString(),10);if(!(b>=S.min&&b<=S.max))throw new Error(`Constraint error, got value ${w} expected range ${S.min}-${S.max}`);y.push(u===a.DayOfWeek?b%7:w)}}return m.split(",").forEach(w=>{if(!(w.length>0))throw new Error("Invalid list value format");x(mi.#a(u,w,g),g)}),y}static#a(u,m,g){const y=m.split("/");if(y.length>2)throw new Error(`Invalid repeat: ${m}`);return y.length===2?(y[0].includes("-")||(y[0]=`${y[0]}-${g.max}`),mi.#l(u,y[0],parseInt(y[1],10),g)):mi.#l(u,m,1,g)}static#s(u,m,g){if(!(!isNaN(u)&&!isNaN(m)&&u>=g.min&&m<=g.max))throw new Error(`Constraint error, got range ${u}-${m} expected range ${g.min}-${g.max}`);if(u>m)throw new Error(`Invalid range: ${u}-${m}, min(${u}) > max(${m})`)}static#i(u){if(!(!isNaN(u)&&u>0))throw new Error(`Constraint error, cannot repeat at every ${u} time.`)}static#c(u,m,g,y){const x=[];u===a.DayOfWeek&&g%7===0&&x.push(0);for(let w=m;w<=g;w+=y)x.indexOf(w)===-1&&x.push(w);return x}static#l(u,m,g,y){const x=m.split("-");if(x.length<=1)return isNaN(+m)?m:+m;const[w,S]=x.map(b=>parseInt(b,10));return this.#s(w,S,y),this.#i(g),this.#c(u,w,S,g)}static#d(u){const m=u.split("#");if(m.length<=1)return{dayOfWeek:m[0]};const g=+m[m.length-1],y=u.match(/([,-/])/);if(y!==null)throw new Error(`Constraint error, invalid dayOfWeek \`#\` and \`${y?.[0]}\` special characters are incompatible`);if(!(m.length<=2&&!isNaN(g)&&g>=1&&g<=5))throw new Error("Constraint error, invalid dayOfWeek occurrence number (#)");return{dayOfWeek:m[0],nthDayOfWeek:g}}static#u(u,m){return u.chars.some(g=>m.toString().includes(g))}};return hi.CronExpressionParser=l,hi}var As={};const Pwe={},jwe=Object.freeze(Object.defineProperty({__proto__:null,default:Pwe},Symbol.toStringTag,{value:"Module"})),AI=Eae(jwe);var DI;function Awe(){if(DI)return As;DI=1;var e=As&&As.__createBinding||(Object.create?(function(a,i,s,l){l===void 0&&(l=s);var d=Object.getOwnPropertyDescriptor(i,s);(!d||("get"in d?!i.__esModule:d.writable||d.configurable))&&(d={enumerable:!0,get:function(){return i[s]}}),Object.defineProperty(a,l,d)}):(function(a,i,s,l){l===void 0&&(l=s),a[l]=i[s]})),t=As&&As.__setModuleDefault||(Object.create?(function(a,i){Object.defineProperty(a,"default",{enumerable:!0,value:i})}):function(a,i){a.default=i}),n=As&&As.__importStar||(function(){var a=function(i){return a=Object.getOwnPropertyNames||function(s){var l=[];for(var d in s)Object.prototype.hasOwnProperty.call(s,d)&&(l[l.length]=d);return l},a(i)};return function(i){if(i&&i.__esModule)return i;var s={};if(i!=null)for(var l=a(i),d=0;d<l.length;d++)l[d]!=="default"&&e(s,i,l[d]);return t(s,i),s}})();Object.defineProperty(As,"__esModule",{value:!0}),As.CronFileParser=void 0;const r=$$();let o=class y0{static async parseFile(i){const{readFile:s}=await Promise.resolve().then(()=>n(AI)),l=await s(i,"utf8");return y0.#e(l)}static parseFileSync(i){const{readFileSync:s}=AI,l=s(i,"utf8");return y0.#e(l)}static#e(i){const s=i.split(`
|
|
481
481
|
`),l={variables:{},expressions:[],errors:{}};for(const d of s){const u=d.trim();if(u.length===0||u.startsWith("#"))continue;const m=u.match(/^(.*)=(.*)$/);if(m){const[,g,y]=m;l.variables[g]=y.replace(/["']/g,"");continue}try{const g=y0.#t(u);l.expressions.push(g.interval)}catch(g){l.errors[u]=g}}return l}static#t(i){const s=i.split(" ");return{interval:r.CronExpressionParser.parse(s.slice(0,5).join(" ")),command:s.slice(5,s.length)}}};return As.CronFileParser=o,As}var NI;function Dwe(){return NI||(NI=1,(function(e){var t=fp&&fp.__createBinding||(Object.create?(function(d,u,m,g){g===void 0&&(g=m);var y=Object.getOwnPropertyDescriptor(u,m);(!y||("get"in y?!u.__esModule:y.writable||y.configurable))&&(y={enumerable:!0,get:function(){return u[m]}}),Object.defineProperty(d,g,y)}):(function(d,u,m,g){g===void 0&&(g=m),d[g]=u[m]})),n=fp&&fp.__exportStar||function(d,u){for(var m in d)m!=="default"&&!Object.prototype.hasOwnProperty.call(u,m)&&t(u,d,m)};Object.defineProperty(e,"__esModule",{value:!0}),e.CronFileParser=e.CronExpressionParser=e.CronExpression=e.CronFieldCollection=e.CronDate=void 0;const r=$$();var o=iT();Object.defineProperty(e,"CronDate",{enumerable:!0,get:function(){return o.CronDate}});var a=d6();Object.defineProperty(e,"CronFieldCollection",{enumerable:!0,get:function(){return a.CronFieldCollection}});var i=f6();Object.defineProperty(e,"CronExpression",{enumerable:!0,get:function(){return i.CronExpression}});var s=$$();Object.defineProperty(e,"CronExpressionParser",{enumerable:!0,get:function(){return s.CronExpressionParser}});var l=Awe();Object.defineProperty(e,"CronFileParser",{enumerable:!0,get:function(){return l.CronFileParser}}),n(sT(),e),e.default=r.CronExpressionParser})(fp)),fp}var Nwe=Dwe(),II={exports:{}},LI;function Iwe(){return LI||(LI=1,(function(e,t){(function(n,r){e.exports=r()})(globalThis,()=>(()=>{var n={949:((i,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.CronParser=void 0;var d=l(515),u=(function(){function m(g,y,x){y===void 0&&(y=!0),x===void 0&&(x=!1),this.expression=g,this.dayOfWeekStartIndexZero=y,this.monthStartIndexZero=x}return m.prototype.parse=function(){var g,y,x=(g=this.expression)!==null&&g!==void 0?g:"";if(x==="@reboot")return y=["@reboot","","","","","",""],y;if(x.startsWith("@")){var w=this.parseSpecial(this.expression);y=this.extractParts(w)}else y=this.extractParts(this.expression);return this.normalize(y),this.validate(y),y},m.prototype.parseSpecial=function(g){var y={"@yearly":"0 0 1 1 *","@annually":"0 0 1 1 *","@monthly":"0 0 1 * *","@weekly":"0 0 * * 0","@daily":"0 0 * * *","@midnight":"0 0 * * *","@hourly":"0 * * * *","@reboot":"@reboot"},x=y[g];if(!x)throw new Error("Unknown special expression.");return x},m.prototype.extractParts=function(g){if(!this.expression)throw new Error("cron expression is empty");for(var y=g.trim().split(/[ ]+/),x=0;x<y.length;x++)if(y[x].includes(",")){var w=y[x].split(",").map(function(b){return b.trim()}).filter(function(b){return b!==""}).map(function(b){return isNaN(Number(b))?b:Number(b)}).filter(function(b){return b!==null&&b!==""});w.length===0&&w.push("*"),w.sort(function(b,$){return b!==null&&$!==null?b-$:0}),y[x]=w.map(function(b){return b!==null?b.toString():""}).join(",")}if(y.length<5)throw new Error("Expression has only ".concat(y.length," part").concat(y.length==1?"":"s",". At least 5 parts are required."));if(y.length==5)y.unshift(""),y.push("");else if(y.length==6){var S=/\d{4}$/.test(y[5])||y[4]=="?"||y[2]=="?";S?y.unshift(""):y.push("")}else if(y.length>7)throw new Error("Expression has ".concat(y.length," parts; too many!"));return y},m.prototype.normalize=function(g){var y=this;if(g[3]=g[3].replace("?","*"),g[5]=g[5].replace("?","*"),g[2]=g[2].replace("?","*"),g[0].indexOf("0/")==0&&(g[0]=g[0].replace("0/","*/")),g[1].indexOf("0/")==0&&(g[1]=g[1].replace("0/","*/")),g[2].indexOf("0/")==0&&(g[2]=g[2].replace("0/","*/")),g[3].indexOf("1/")==0&&(g[3]=g[3].replace("1/","*/")),g[4].indexOf("1/")==0&&(g[4]=g[4].replace("1/","*/")),g[6].indexOf("1/")==0&&(g[6]=g[6].replace("1/","*/")),g[5]=g[5].replace(/(^\d)|([^#/\s]\d)/g,function(O){var P=O.replace(/\D/,""),D=P;return y.dayOfWeekStartIndexZero?P=="7"&&(D="0"):D=(parseInt(P)-1).toString(),O.replace(P,D)}),g[5]=="L"&&(g[5]="6"),g[3]=="?"&&(g[3]="*"),g[3].indexOf("W")>-1&&(g[3].indexOf(",")>-1||g[3].indexOf("-")>-1))throw new Error("The 'W' character can be specified only when the day-of-month is a single day, not a range or list of days.");var x={SUN:0,MON:1,TUE:2,WED:3,THU:4,FRI:5,SAT:6};for(var w in x)g[5]=g[5].replace(new RegExp(w,"gi"),x[w].toString());g[4]=g[4].replace(/(^\d{1,2})|([^#/\s]\d{1,2})/g,function(O){var P=O.replace(/\D/,""),D=P;return y.monthStartIndexZero&&(D=(parseInt(P)+1).toString()),O.replace(P,D)});var S={JAN:1,FEB:2,MAR:3,APR:4,MAY:5,JUN:6,JUL:7,AUG:8,SEP:9,OCT:10,NOV:11,DEC:12};for(var b in S)g[4]=g[4].replace(new RegExp(b,"gi"),S[b].toString());g[0]=="0"&&(g[0]=""),!/\*|\-|\,|\//.test(g[2])&&(/\*|\//.test(g[1])||/\*|\//.test(g[0]))&&(g[2]+="-".concat(g[2]));for(var $=0;$<g.length;$++)if(g[$].indexOf(",")!=-1&&(g[$]=g[$].split(",").filter(function(O){return O!==""}).join(",")||"*"),g[$]=="*/1"&&(g[$]="*"),g[$].indexOf("/")>-1&&!/^\*|\-|\,/.test(g[$])){var k=null;switch($){case 4:k="12";break;case 5:k="6";break;case 6:k="9999";break;default:k=null;break}if(k!==null){var T=g[$].split("/");g[$]="".concat(T[0],"-").concat(k,"/").concat(T[1])}}},m.prototype.validate=function(g){var y="0-9,\\-*/";this.validateOnlyExpectedCharactersFound(g[0],y),this.validateOnlyExpectedCharactersFound(g[1],y),this.validateOnlyExpectedCharactersFound(g[2],y),this.validateOnlyExpectedCharactersFound(g[3],"0-9,\\-*/LW"),this.validateOnlyExpectedCharactersFound(g[4],y),this.validateOnlyExpectedCharactersFound(g[5],"0-9,\\-*/L#"),this.validateOnlyExpectedCharactersFound(g[6],y),this.validateAnyRanges(g)},m.prototype.validateAnyRanges=function(g){d.default.secondRange(g[0]),d.default.minuteRange(g[1]),d.default.hourRange(g[2]),d.default.dayOfMonthRange(g[3]),d.default.monthRange(g[4],this.monthStartIndexZero),d.default.dayOfWeekRange(g[5],this.dayOfWeekStartIndexZero)},m.prototype.validateOnlyExpectedCharactersFound=function(g,y){var x=g.match(new RegExp("[^".concat(y,"]+"),"gi"));if(x&&x.length)throw new Error("Expression contains invalid values: '".concat(x.toString(),"'"))},m})();s.CronParser=u}),333:((i,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.ExpressionDescriptor=void 0;var d=l(823),u=l(949),m=(function(){function g(y,x){if(this.expression=y,this.options=x,this.expressionParts=new Array(5),!this.options.locale&&g.defaultLocale&&(this.options.locale=g.defaultLocale),!g.locales[this.options.locale]){var w=Object.keys(g.locales)[0];console.warn("Locale '".concat(this.options.locale,"' could not be found; falling back to '").concat(w,"'.")),this.options.locale=w}this.i18n=g.locales[this.options.locale],x.use24HourTimeFormat===void 0&&(x.use24HourTimeFormat=this.i18n.use24HourTimeFormatByDefault())}return g.toString=function(y,x){var w=x===void 0?{}:x,S=w.throwExceptionOnParseError,b=S===void 0?!0:S,$=w.verbose,k=$===void 0?!1:$,T=w.dayOfWeekStartIndexZero,O=T===void 0?!0:T,P=w.monthStartIndexZero,D=P===void 0?!1:P,A=w.use24HourTimeFormat,F=w.locale,L=F===void 0?null:F,_={throwExceptionOnParseError:b,verbose:k,dayOfWeekStartIndexZero:O,monthStartIndexZero:D,use24HourTimeFormat:A,locale:L};_.tzOffset&&console.warn("'tzOffset' option has been deprecated and is no longer supported.");var R=new g(y,_);return R.getFullDescription()},g.initialize=function(y,x){x===void 0&&(x="en"),g.specialCharacters=["/","-",",","*"],g.defaultLocale=x,y.load(g.locales)},g.prototype.getFullDescription=function(){var y,x,w="";try{var S=new u.CronParser(this.expression,this.options.dayOfWeekStartIndexZero,this.options.monthStartIndexZero);if(this.expressionParts=S.parse(),this.expressionParts[0]==="@reboot")return((x=(y=this.i18n).atReboot)===null||x===void 0?void 0:x.call(y))||"Run once, at startup";var b=this.getTimeOfDayDescription(),$=this.getDayOfMonthDescription(),k=this.getMonthDescription(),T=this.getDayOfWeekDescription(),O=this.getYearDescription();w+=b+$+T+k+O,w=this.transformVerbosity(w,!!this.options.verbose),w=w.charAt(0).toLocaleUpperCase()+w.substr(1)}catch(P){if(!this.options.throwExceptionOnParseError)w=this.i18n.anErrorOccuredWhenGeneratingTheExpressionD();else throw"".concat(P)}return w},g.prototype.getTimeOfDayDescription=function(){var y=this.expressionParts[0],x=this.expressionParts[1],w=this.expressionParts[2],S="";if(!d.StringUtilities.containsAny(x,g.specialCharacters)&&!d.StringUtilities.containsAny(w,g.specialCharacters)&&!d.StringUtilities.containsAny(y,g.specialCharacters))S+=this.i18n.atSpace()+this.formatTime(w,x,y);else if(!y&&x.indexOf("-")>-1&&!(x.indexOf(",")>-1)&&!(x.indexOf("/")>-1)&&!d.StringUtilities.containsAny(w,g.specialCharacters)){var b=x.split("-");S+=d.StringUtilities.format(this.i18n.everyMinuteBetweenX0AndX1(),this.formatTime(w,b[0],""),this.formatTime(w,b[1],""))}else if(!y&&w.indexOf(",")>-1&&w.indexOf("-")==-1&&w.indexOf("/")==-1&&!d.StringUtilities.containsAny(x,g.specialCharacters)){var $=w.split(",");S+=this.i18n.at();for(var k=0;k<$.length;k++)S+=" ",S+=this.formatTime($[k],x,""),k<$.length-2&&(S+=","),k==$.length-2&&(S+=this.i18n.spaceAnd())}else{var T=this.getSecondsDescription(),O=this.getMinutesDescription(),P=this.getHoursDescription();if(S+=T,S&&O&&(S+=", "),S+=O,O===P)return S;S&&P&&(S+=", "),S+=P}return S},g.prototype.getSecondsDescription=function(){var y=this,x=this.getSegmentDescription(this.expressionParts[0],this.i18n.everySecond(),function(w){return w},function(w){return d.StringUtilities.format(y.i18n.everyX0Seconds(w),w)},function(w){return y.i18n.secondsX0ThroughX1PastTheMinute()},function(w){return w=="0"?"":parseInt(w)<20?y.i18n.atX0SecondsPastTheMinute(w):y.i18n.atX0SecondsPastTheMinuteGt20()||y.i18n.atX0SecondsPastTheMinute(w)});return x},g.prototype.getMinutesDescription=function(){var y=this,x=this.expressionParts[0],w=this.expressionParts[2],S=this.getSegmentDescription(this.expressionParts[1],this.i18n.everyMinute(),function(b){return b},function(b){return d.StringUtilities.format(y.i18n.everyX0Minutes(b),b)},function(b){return y.i18n.minutesX0ThroughX1PastTheHour()},function(b){try{return b=="0"&&w.indexOf("/")==-1&&x==""?y.i18n.everyHour():parseInt(b)<20?y.i18n.atX0MinutesPastTheHour(b):y.i18n.atX0MinutesPastTheHourGt20()||y.i18n.atX0MinutesPastTheHour(b)}catch{return y.i18n.atX0MinutesPastTheHour(b)}});return S},g.prototype.getHoursDescription=function(){var y=this,x=this.expressionParts[2],w=0,S=[];x.split("/")[0].split(",").forEach(function(k){var T=k.split("-");T.length===2&&S.push({value:T[1],index:w+1}),w+=T.length});var b=0,$=this.getSegmentDescription(x,this.i18n.everyHour(),function(k){var T=S.find(function(P){return P.value===k&&P.index===b}),O=T&&y.expressionParts[1]!=="0";return b++,O?y.formatTime(k,"59",""):y.formatTime(k,"0","")},function(k){return d.StringUtilities.format(y.i18n.everyX0Hours(k),k)},function(k){return y.i18n.betweenX0AndX1()},function(k){return y.i18n.atX0()});return $},g.prototype.getDayOfWeekDescription=function(){var y=this,x=this.i18n.daysOfTheWeek(),w=null;return this.expressionParts[5]=="*"?w="":w=this.getSegmentDescription(this.expressionParts[5],this.i18n.commaEveryDay(),function(S,b){var $=S;S.indexOf("#")>-1?$=S.substring(0,S.indexOf("#")):S.indexOf("L")>-1&&($=$.replace("L",""));var k=parseInt($),T=y.i18n.daysOfTheWeekInCase?y.i18n.daysOfTheWeekInCase(b)[k]:x[k];if(S.indexOf("#")>-1){var O=null,P=S.substring(S.indexOf("#")+1),D=S.substring(0,S.indexOf("#"));switch(P){case"1":O=y.i18n.first(D);break;case"2":O=y.i18n.second(D);break;case"3":O=y.i18n.third(D);break;case"4":O=y.i18n.fourth(D);break;case"5":O=y.i18n.fifth(D);break}T=O+" "+T}return T},function(S){return parseInt(S)==1?"":d.StringUtilities.format(y.i18n.commaEveryX0DaysOfTheWeek(S),S)},function(S){var b=S.substring(0,S.indexOf("-")),$=y.expressionParts[3]!="*";return $?y.i18n.commaAndX0ThroughX1(b):y.i18n.commaX0ThroughX1(b)},function(S){var b=null;if(S.indexOf("#")>-1){var $=S.substring(S.indexOf("#")+1),k=S.substring(0,S.indexOf("#"));b=y.i18n.commaOnThe($,k).trim()+y.i18n.spaceX0OfTheMonth()}else if(S.indexOf("L")>-1)b=y.i18n.commaOnTheLastX0OfTheMonth(S.replace("L",""));else{var T=y.expressionParts[3]!="*";b=T?y.i18n.commaAndOnX0():y.i18n.commaOnlyOnX0(S)}return b}),w},g.prototype.getMonthDescription=function(){var y=this,x=this.i18n.monthsOfTheYear(),w=this.getSegmentDescription(this.expressionParts[4],"",function(S,b){return b&&y.i18n.monthsOfTheYearInCase?y.i18n.monthsOfTheYearInCase(b)[parseInt(S)-1]:x[parseInt(S)-1]},function(S){return parseInt(S)==1?"":d.StringUtilities.format(y.i18n.commaEveryX0Months(S),S)},function(S){return y.i18n.commaMonthX0ThroughMonthX1()||y.i18n.commaX0ThroughX1()},function(S){return y.i18n.commaOnlyInMonthX0?y.i18n.commaOnlyInMonthX0():y.i18n.commaOnlyInX0()});return w},g.prototype.getDayOfMonthDescription=function(){var y=this,x=null,w=this.expressionParts[3];switch(w){case"L":x=this.i18n.commaOnTheLastDayOfTheMonth();break;case"WL":case"LW":x=this.i18n.commaOnTheLastWeekdayOfTheMonth();break;default:var S=w.match(/(\d{1,2}W)|(W\d{1,2})/);if(S){var b=parseInt(S[0].replace("W","")),$=b==1?this.i18n.firstWeekday():d.StringUtilities.format(this.i18n.weekdayNearestDayX0(),b.toString());x=d.StringUtilities.format(this.i18n.commaOnTheX0OfTheMonth(),$);break}else{var k=w.match(/L-(\d{1,2})/);if(k){var T=k[1];x=d.StringUtilities.format(this.i18n.commaDaysBeforeTheLastDayOfTheMonth(T),T);break}else{if(w=="*"&&this.expressionParts[5]!="*")return"";x=this.getSegmentDescription(w,this.i18n.commaEveryDay(),function(O){return O=="L"?y.i18n.lastDay():y.i18n.dayX0?d.StringUtilities.format(y.i18n.dayX0(),O):O},function(O){return O=="1"?y.i18n.commaEveryDay():y.i18n.commaEveryX0Days(O)},function(O){return y.i18n.commaBetweenDayX0AndX1OfTheMonth(O)},function(O){return y.i18n.commaOnDayX0OfTheMonth(O)})}break}}return x},g.prototype.getYearDescription=function(){var y=this,x=this.getSegmentDescription(this.expressionParts[6],"",function(w){return/^\d+$/.test(w)?new Date(parseInt(w),1).getFullYear().toString():w},function(w){return d.StringUtilities.format(y.i18n.commaEveryX0Years(w),w)},function(w){return y.i18n.commaYearX0ThroughYearX1()||y.i18n.commaX0ThroughX1()},function(w){return y.i18n.commaOnlyInYearX0?y.i18n.commaOnlyInYearX0():y.i18n.commaOnlyInX0()});return x},g.prototype.getSegmentDescription=function(y,x,w,S,b,$){var k=null,T=y.indexOf("/")>-1,O=y.indexOf("-")>-1,P=y.indexOf(",")>-1;if(!y)k="";else if(y==="*")k=x;else if(!T&&!O&&!P)k=d.StringUtilities.format($(y),w(y));else if(P){for(var D=y.split(","),A="",F=0;F<D.length;F++)if(F>0&&D.length>2&&(A+=",",F<D.length-1&&(A+=" ")),F>0&&D.length>1&&(F==D.length-1||D.length==2)&&(A+="".concat(this.i18n.spaceAnd()," ")),D[F].indexOf("/")>-1||D[F].indexOf("-")>-1){var L=D[F].indexOf("-")>-1&&D[F].indexOf("/")==-1,_=this.getSegmentDescription(D[F],x,w,S,L?this.i18n.commaX0ThroughX1:b,$);L&&(_=_.replace(", ","")),A+=_}else T?A+=this.getSegmentDescription(D[F],x,w,S,b,$):A+=w(D[F]);T?k=A:k=d.StringUtilities.format($(y),A)}else if(T){var D=y.split("/");if(k=d.StringUtilities.format(S(D[1]),D[1]),D[0].indexOf("-")>-1){var R=this.generateRangeSegmentDescription(D[0],b,w);R.indexOf(", ")!=0&&(k+=", "),k+=R}else if(D[0].indexOf("*")==-1){var z=d.StringUtilities.format($(D[0]),w(D[0]));z=z.replace(", ",""),k+=d.StringUtilities.format(this.i18n.commaStartingX0(),z)}}else O&&(k=this.generateRangeSegmentDescription(y,b,w));return k},g.prototype.generateRangeSegmentDescription=function(y,x,w){var S="",b=y.split("-"),$=w(b[0],1),k=w(b[1],2),T=x(y);return S+=d.StringUtilities.format(T,$,k),S},g.prototype.formatTime=function(y,x,w){var S=0,b=0,$=parseInt(y)+S,k=parseInt(x)+b;k>=60?(k-=60,$+=1):k<0&&(k+=60,$-=1),$>=24?$=$-24:$<0&&($=24+$);var T="",O=!1;this.options.use24HourTimeFormat||(O=!!(this.i18n.setPeriodBeforeTime&&this.i18n.setPeriodBeforeTime()),T=O?"".concat(this.getPeriod($)," "):" ".concat(this.getPeriod($)),$>12&&($-=12),$===0&&($=12));var P="";return w&&(P=":".concat(("00"+w).substring(w.length))),"".concat(O?T:"").concat(("00"+$.toString()).substring($.toString().length),":").concat(("00"+k.toString()).substring(k.toString().length)).concat(P).concat(O?"":T)},g.prototype.transformVerbosity=function(y,x){if(!x&&(y=y.replace(new RegExp(", ".concat(this.i18n.everyMinute()),"g"),""),y=y.replace(new RegExp(", ".concat(this.i18n.everyHour()),"g"),""),y=y.replace(new RegExp(this.i18n.commaEveryDay(),"g"),""),y=y.replace(/\, ?$/,""),this.i18n.conciseVerbosityReplacements))for(var w=0,S=Object.entries(this.i18n.conciseVerbosityReplacements());w<S.length;w++){var b=S[w],$=b[0],k=b[1];y=y.replace(new RegExp($,"g"),k)}return y},g.prototype.getPeriod=function(y){return y>=12?this.i18n.pm&&this.i18n.pm()||"PM":this.i18n.am&&this.i18n.am()||"AM"},g.locales={},g})();s.ExpressionDescriptor=m}),747:((i,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.enLocaleLoader=void 0;var d=l(486),u=(function(){function m(){}return m.prototype.load=function(g){g.en=new d.en},m})();s.enLocaleLoader=u}),486:((i,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.en=void 0;var l=(function(){function d(){}return d.prototype.atX0SecondsPastTheMinuteGt20=function(){return null},d.prototype.atX0MinutesPastTheHourGt20=function(){return null},d.prototype.commaMonthX0ThroughMonthX1=function(){return null},d.prototype.commaYearX0ThroughYearX1=function(){return null},d.prototype.use24HourTimeFormatByDefault=function(){return!1},d.prototype.anErrorOccuredWhenGeneratingTheExpressionD=function(){return"An error occurred when generating the expression description. Check the cron expression syntax."},d.prototype.everyMinute=function(){return"every minute"},d.prototype.everyHour=function(){return"every hour"},d.prototype.atSpace=function(){return"At "},d.prototype.everyMinuteBetweenX0AndX1=function(){return"Every minute between %s and %s"},d.prototype.at=function(){return"At"},d.prototype.spaceAnd=function(){return" and"},d.prototype.everySecond=function(){return"every second"},d.prototype.everyX0Seconds=function(){return"every %s seconds"},d.prototype.secondsX0ThroughX1PastTheMinute=function(){return"seconds %s through %s past the minute"},d.prototype.atX0SecondsPastTheMinute=function(){return"at %s seconds past the minute"},d.prototype.everyX0Minutes=function(){return"every %s minutes"},d.prototype.minutesX0ThroughX1PastTheHour=function(){return"minutes %s through %s past the hour"},d.prototype.atX0MinutesPastTheHour=function(){return"at %s minutes past the hour"},d.prototype.everyX0Hours=function(){return"every %s hours"},d.prototype.betweenX0AndX1=function(){return"between %s and %s"},d.prototype.atX0=function(){return"at %s"},d.prototype.commaEveryDay=function(){return", every day"},d.prototype.commaEveryX0DaysOfTheWeek=function(){return", every %s days of the week"},d.prototype.commaX0ThroughX1=function(){return", %s through %s"},d.prototype.commaAndX0ThroughX1=function(){return", %s through %s"},d.prototype.first=function(){return"first"},d.prototype.second=function(){return"second"},d.prototype.third=function(){return"third"},d.prototype.fourth=function(){return"fourth"},d.prototype.fifth=function(){return"fifth"},d.prototype.commaOnThe=function(){return", on the "},d.prototype.spaceX0OfTheMonth=function(){return" %s of the month"},d.prototype.lastDay=function(){return"the last day"},d.prototype.commaOnTheLastX0OfTheMonth=function(){return", on the last %s of the month"},d.prototype.commaOnlyOnX0=function(){return", only on %s"},d.prototype.commaAndOnX0=function(){return", and on %s"},d.prototype.commaEveryX0Months=function(){return", every %s months"},d.prototype.commaOnlyInX0=function(){return", only in %s"},d.prototype.commaOnTheLastDayOfTheMonth=function(){return", on the last day of the month"},d.prototype.commaOnTheLastWeekdayOfTheMonth=function(){return", on the last weekday of the month"},d.prototype.commaDaysBeforeTheLastDayOfTheMonth=function(){return", %s days before the last day of the month"},d.prototype.firstWeekday=function(){return"first weekday"},d.prototype.weekdayNearestDayX0=function(){return"weekday nearest day %s"},d.prototype.commaOnTheX0OfTheMonth=function(){return", on the %s of the month"},d.prototype.commaEveryX0Days=function(){return", every %s days"},d.prototype.commaBetweenDayX0AndX1OfTheMonth=function(){return", between day %s and %s of the month"},d.prototype.commaOnDayX0OfTheMonth=function(){return", on day %s of the month"},d.prototype.commaEveryHour=function(){return", every hour"},d.prototype.commaEveryX0Years=function(){return", every %s years"},d.prototype.commaStartingX0=function(){return", starting %s"},d.prototype.daysOfTheWeek=function(){return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},d.prototype.monthsOfTheYear=function(){return["January","February","March","April","May","June","July","August","September","October","November","December"]},d.prototype.atReboot=function(){return"Run once, at startup"},d})();s.en=l}),515:((i,s)=>{Object.defineProperty(s,"__esModule",{value:!0});function l(u,m){if(!u)throw new Error(m)}var d=(function(){function u(){}return u.secondRange=function(m){for(var g=m.split(","),y=0;y<g.length;y++)if(!isNaN(parseInt(g[y],10))){var x=parseInt(g[y],10);l(x>=0&&x<=59,"seconds part must be >= 0 and <= 59")}},u.minuteRange=function(m){for(var g=m.split(","),y=0;y<g.length;y++)if(!isNaN(parseInt(g[y],10))){var x=parseInt(g[y],10);l(x>=0&&x<=59,"minutes part must be >= 0 and <= 59")}},u.hourRange=function(m){for(var g=m.split(","),y=0;y<g.length;y++)if(!isNaN(parseInt(g[y],10))){var x=parseInt(g[y],10);l(x>=0&&x<=23,"hours part must be >= 0 and <= 23")}},u.dayOfMonthRange=function(m){for(var g=m.split(","),y=0;y<g.length;y++)if(!isNaN(parseInt(g[y],10))){var x=parseInt(g[y],10);l(x>=1&&x<=31,"DOM part must be >= 1 and <= 31")}},u.monthRange=function(m,g){for(var y=m.split(","),x=0;x<y.length;x++)if(!isNaN(parseInt(y[x],10))){var w=parseInt(y[x],10);l(w>=1&&w<=12,g?"month part must be >= 0 and <= 11":"month part must be >= 1 and <= 12")}},u.dayOfWeekRange=function(m,g){for(var y=m.split(","),x=0;x<y.length;x++)if(!isNaN(parseInt(y[x],10))){var w=parseInt(y[x],10);l(w>=0&&w<=6,g?"DOW part must be >= 0 and <= 6":"DOW part must be >= 1 and <= 7")}},u})();s.default=d}),823:((i,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.StringUtilities=void 0;var l=(function(){function d(){}return d.format=function(u){for(var m=[],g=1;g<arguments.length;g++)m[g-1]=arguments[g];return u.replace(/%s/g,function(y){return m.shift()})},d.containsAny=function(u,m){return m.some(function(g){return u.indexOf(g)>-1})},d})();s.StringUtilities=l})},r={};function o(i){var s=r[i];if(s!==void 0)return s.exports;var l=r[i]={exports:{}};return n[i](l,l.exports,o),l.exports}var a={};return(()=>{var i=a;Object.defineProperty(i,"__esModule",{value:!0}),i.toString=void 0;var s=o(333),l=o(747);s.ExpressionDescriptor.initialize(new l.enLocaleLoader),i.default=s.ExpressionDescriptor;var d=s.ExpressionDescriptor.toString;i.toString=d})(),a})())})(II)),II.exports}var Lwe=Iwe();const zwe=yc(Lwe),Fwe=new Set(["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC","SUN","MON","TUE","WED","THU","FRI","SAT"]);function _we(e){for(const t of e.trim().split(/\s+/)){if(/[#?]/.test(t))return!1;for(const n of t.split(/[,\-/]/))if(!(n===""||n==="*")&&/[A-Za-z]/.test(n)&&!Fwe.has(n.toUpperCase()))return!1}return!0}function lT(e){const t=(e??"").trim();if(t.split(/\s+/).filter(Boolean).length!==5)return{valid:!1,description:"",nextRun:null,error:"Expected a 5-field UNIX cron: minute hour day-of-month month day-of-week."};if(!_we(t))return{valid:!1,description:"",nextRun:null,error:"Unsupported cron syntax: L, W, #, and ? extensions are not allowed (plain 5-field UNIX cron only)."};try{const n=zwe.toString(t,{use24HourTimeFormat:!0,verbose:!1}),r=Nwe.CronExpressionParser.parse(t,{tz:"UTC"}).next().toDate();return{valid:!0,description:n,nextRun:r}}catch(n){return{valid:!1,description:"",nextRun:null,error:n instanceof Error?n.message:"Invalid cron expression."}}}function p6(e){return e?e.toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",timeZone:"UTC",hour12:!1})+" UTC":"—"}function Bwe({onSubmit:e,isSubmitting:t,disabled:n,disabledReason:r}){const[o,a]=C.useState(!1),[i,s]=C.useState(!1),l=()=>a(!1),d=async()=>{try{await e({forceRefresh:i}),a(!1)}catch{}},u=p.jsx("span",{children:p.jsx(Qy,{label:"Materialization",onClick:()=>a(!0),disabled:n})});return p.jsxs(p.Fragment,{children:[n&&r?p.jsx(Br,{title:r,children:u}):u,p.jsx(Oo,{open:o,onClose:l,title:"New materialization",description:"Compile the package, build a table for every persist source, and load them so queries serve from the tables.",actions:p.jsxs(p.Fragment,{children:[p.jsx(Vn,{onClick:l,children:"Cancel"}),p.jsx(Vn,{variant:"contained",loading:t,onClick:d,children:"Materialize"})]}),children:p.jsx(uX,{children:p.jsx(MR,{control:p.jsx(Cz,{checked:i,onChange:m=>s(m.target.checked)}),label:"Force refresh (rebuild even if unchanged)"})})})]})}function v0({children:e}){return p.jsx(wt,{variant:"caption",component:"h6",sx:{display:"block",textTransform:"uppercase",letterSpacing:"0.06em",fontWeight:600,color:"text.secondary",mb:1},children:e})}function tx(e){return e===Ea.Pending||e===Ea.ManifestRowsReady}function Uwe(e){return e===Ea.ManifestFileReady||e===Ea.Failed||e===Ea.Cancelled}function h6(e){switch(e){case Ea.ManifestFileReady:return"Done";case Ea.Failed:return"Failed";case Ea.Cancelled:return"Cancelled";case Ea.Pending:case Ea.ManifestRowsReady:return"Pending";default:return"Unknown"}}function R$(e){switch(e){case Ea.ManifestRowsReady:return"info";case Ea.ManifestFileReady:return"success";case Ea.Failed:return"error";case Ea.Cancelled:return"warning";case Ea.Pending:default:return"default"}}function qwe(e){const t=Object.values(cT(e).refusedSources??{}).map(r=>({name:r.name,message:r.message})),n=Object.values(e.manifest?.failures??{}).filter(r=>r.refused).map(r=>({name:r.sourceName??r.sourceEntityId,message:r.reason}));return[...t,...n].sort((r,o)=>r.name.localeCompare(o.name))}function m6(e,t){const n=[`${e.sourcesBuilt??0} built`,`${e.sourcesReused??0} reused`];return e.sourcesRefused&&n.push(`${e.sourcesRefused} refused`),n.join(t)}function cT(e){return e.metadata??{}}function Hwe(e){return e.trigger==="SCHEDULER"?"Scheduled":"Manual"}function g6(e,t){if(!e)return"-";const n=new Date(e).getTime(),r=t?new Date(t).getTime():Date.now(),o=Math.max(0,r-n);if(o<1e3)return`${o}ms`;const a=Math.round(o/1e3);if(a<60)return`${a}s`;const i=Math.floor(a/60),s=a%60;if(i<60)return`${i}m ${s}s`;const l=Math.floor(i/60),d=i%60;return`${l}h ${d}m`}function T$(e){if(!e)return"—";const t=new Date(e);return Number.isNaN(t.getTime())?"—":t.toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function Vwe(e){if(!e)return"-";const t=new Date(e).getTime(),n=Math.round((Date.now()-t)/1e3);if(n<60)return"just now";const r=Math.floor(n/60);if(r<60)return`${r}m ago`;const o=Math.floor(r/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}function Wwe({entries:e,builtAt:t}){const n=Object.entries(e??{});return p.jsxs(Te,{children:[p.jsxs(Yn,{direction:"row",alignItems:"baseline",justifyContent:"space-between",children:[p.jsx(v0,{children:"Build manifest"}),t&&p.jsxs(wt,{variant:"caption",color:"text.secondary",children:["Built ",T$(t)]})]}),n.length===0?p.jsx(wt,{variant:"body2",color:"text.secondary",sx:{fontStyle:"italic"},children:"No materialized tables yet."}):p.jsxs(Bx,{size:"small",children:[p.jsx(Hx,{children:p.jsxs(vu,{children:[p.jsx(dr,{children:"Source"}),p.jsx(dr,{children:"Table name"}),p.jsx(dr,{children:"Connection"}),p.jsx(dr,{children:"Realization"}),p.jsx(dr,{align:"right",children:"Rows"})]})}),p.jsx(qx,{children:n.map(([r,o])=>p.jsxs(vu,{children:[p.jsx(dr,{sx:{fontFamily:Fo},children:o.sourceName??r}),p.jsx(dr,{sx:{fontFamily:Fo},children:o.physicalTableName??"-"}),p.jsx(dr,{sx:{fontFamily:Fo},children:o.connectionName??"-"}),p.jsx(dr,{children:o.realization??"-"}),p.jsx(dr,{align:"right",children:o.rowCount??"-"})]},r))})]})]})}function y6({meta:e}){const t=e.trigger==="SCHEDULER";return p.jsx(Br,{title:t?"Fired by the materialization schedule":"Triggered manually",children:p.jsx(wt,{variant:"body2",color:"text.secondary",children:Hwe(e)})})}function Ywe({materialization:e,buildPlan:t,onClose:n}){const r=e?cT(e):{},o=e?qwe(e):[],a=t.status==="ready"?Object.values(t.plan?.sources??{}):[];return p.jsx(zx,{open:e!==null,onClose:n,maxWidth:"md",fullWidth:!0,"aria-labelledby":"materialization-detail-title",children:e&&p.jsxs(p.Fragment,{children:[p.jsxs(_x,{sx:{pr:6,pb:1.5},id:"materialization-detail-title",children:[p.jsxs(Yn,{direction:"row",alignItems:"center",spacing:1,sx:{mb:.75},children:[p.jsx(TR,{size:"small",label:h6(e.status),color:R$(e.status),variant:tx(e.status)?"filled":"outlined"}),p.jsx(y6,{meta:r})]}),p.jsx(wt,{variant:"subtitle1",sx:{fontWeight:600},children:e.packageName??"Materialization"}),p.jsx(wt,{variant:"caption",color:"text.secondary",sx:{fontFamily:Fo,wordBreak:"break-all"},children:e.id}),p.jsx(ro,{"aria-label":"close",onClick:n,sx:{position:"absolute",right:8,top:8},children:p.jsx(xh,{fontSize:"small"})})]}),p.jsxs(Fx,{dividers:!0,children:[p.jsxs(Te,{sx:{bgcolor:"action.hover",borderRadius:2,p:2,mb:3,display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(140px, 1fr))",gap:2},children:[p.jsx(hg,{label:"Started",value:T$(e.startedAt??e.createdAt)}),p.jsx(hg,{label:"Completed",value:T$(e.completedAt)}),p.jsx(hg,{label:"Duration",value:g6(e.startedAt,e.completedAt)}),p.jsx(hg,{label:"Sources",value:m6(r," · ")}),p.jsx(hg,{label:"Force refresh",value:r.forceRefresh?"Yes":"No"})]}),e.error&&p.jsxs(Te,{sx:{borderRadius:2,p:2,mb:3,border:"1px solid",borderColor:"error.main"},children:[p.jsx(v0,{children:p.jsx(Te,{component:"span",sx:{color:"error.main"},children:"Error"})}),p.jsx(wt,{variant:"body2",sx:{fontFamily:Fo,whiteSpace:"pre-wrap"},children:e.error})]}),o.length>0&&p.jsxs(Te,{sx:{borderRadius:2,p:2,mb:3,border:"1px solid",borderColor:"warning.main"},children:[p.jsx(v0,{children:p.jsx(Te,{component:"span",sx:{color:"warning.main"},children:"Refused sources"})}),p.jsx(wt,{variant:"body2",color:"text.secondary",sx:{mb:1},children:"Not built, because materializing them would be unsafe. They serve live until the model changes."}),o.map(i=>p.jsxs(Te,{sx:{mt:1},children:[p.jsx(wt,{variant:"body2",sx:{fontFamily:Fo},children:i.name}),p.jsx(wt,{variant:"body2",color:"text.secondary",sx:{whiteSpace:"pre-wrap"},children:i.message})]},i.name))]}),p.jsxs(Te,{sx:{mb:3},children:[p.jsx(v0,{children:"Build plan"}),t.status==="loading"?p.jsx(Bo,{text:wu.loading,size:16,centered:!1}):t.status==="unavailable"?p.jsx(wt,{variant:"body2",color:"text.secondary",sx:{fontStyle:"italic"},children:"The build plan is unavailable."}):a.length===0?p.jsx(wt,{variant:"body2",color:"text.secondary",sx:{fontStyle:"italic"},children:"This package has no persist sources."}):p.jsxs(Bx,{size:"small",children:[p.jsx(Hx,{children:p.jsxs(vu,{children:[p.jsx(dr,{children:"Source"}),p.jsx(dr,{children:"Connection"}),p.jsx(dr,{children:"Dialect"}),p.jsx(dr,{align:"right",children:"Columns"}),p.jsx(dr,{children:"Source Entity ID"})]})}),p.jsx(qx,{children:a.map(i=>p.jsxs(vu,{children:[p.jsx(dr,{sx:{fontFamily:Fo},children:i.name}),p.jsx(dr,{sx:{fontFamily:Fo},children:i.connectionName}),p.jsx(dr,{children:i.dialect??"-"}),p.jsx(dr,{align:"right",children:i.columns?.length??0}),p.jsx(dr,{sx:{fontFamily:Fo,fontSize:"0.75rem",wordBreak:"break-all",maxWidth:220},children:i.sourceEntityId})]},i.sourceID))})]})]}),p.jsx(Wwe,{entries:e.manifest?.entries,builtAt:e.manifest?.builtAt})]})]})})}function hg({label:e,value:t}){return p.jsxs(Te,{children:[p.jsx(wt,{variant:"caption",color:"text.secondary",display:"block",children:e}),p.jsx(wt,{variant:"body2",children:t})]})}const Gwe=Jt(p.jsx("path",{d:"M6 6h12v12H6z"}));function Kwe(e){return Cn("PrivateSwitchBase",e)}fn("PrivateSwitchBase",["root","checked","disabled","input","edgeStart","edgeEnd"]);const Qwe=e=>{const{classes:t,checked:n,disabled:r,edge:o}=e,a={root:["root",n&&"checked",r&&"disabled",o&&`edge${Tt(o)}`],input:["input"]};return bn(a,Kwe,t)},Xwe=nt(qd,{name:"MuiSwitchBase"})({padding:9,borderRadius:"50%",variants:[{props:{edge:"start",size:"small"},style:{marginLeft:-3}},{props:({edge:e,ownerState:t})=>e==="start"&&t.size!=="small",style:{marginLeft:-12}},{props:{edge:"end",size:"small"},style:{marginRight:-3}},{props:({edge:e,ownerState:t})=>e==="end"&&t.size!=="small",style:{marginRight:-12}}]}),Zwe=nt("input",{name:"MuiSwitchBase",shouldForwardProp:ei})({cursor:"inherit",position:"absolute",opacity:0,width:"100%",height:"100%",top:0,left:0,margin:0,padding:0,zIndex:1}),Jwe=C.forwardRef(function(e,t){const{autoFocus:n,checked:r,checkedIcon:o,defaultChecked:a,disabled:i,disableFocusRipple:s=!1,edge:l=!1,icon:d,id:u,inputProps:m,inputRef:g,name:y,onBlur:x,onChange:w,onFocus:S,readOnly:b,required:$=!1,tabIndex:k,type:T,value:O,slots:P={},slotProps:D={},...A}=e,[F,L]=Ti({controlled:r,default:!!a,name:"SwitchBase",state:"checked"}),_=Ai(),R=ie=>{S&&S(ie),_&&_.onFocus&&_.onFocus(ie)},z=ie=>{x&&x(ie),_&&_.onBlur&&_.onBlur(ie)},N=ie=>{if(ie.nativeEvent.defaultPrevented)return;const Q=ie.target.checked;L(Q),w&&w(ie,Q)};let B=i;_&&typeof B>"u"&&(B=_.disabled);const I=T==="checkbox"||T==="radio",H={...e,checked:F,disabled:B,disableFocusRipple:s,edge:l},Y=Qwe(H),ae={slots:P,slotProps:{input:m,...D}},[K,oe]=ur("root",{ref:t,elementType:Xwe,className:Y.root,shouldForwardComponentProp:!0,externalForwardedProps:{...ae,component:"span",...A},getSlotProps:ie=>({...ie,onFocus:Q=>{ie.onFocus?.(Q),R(Q)},onBlur:Q=>{ie.onBlur?.(Q),z(Q)}}),ownerState:H,additionalProps:{centerRipple:!0,focusRipple:!s,disabled:B,role:void 0,tabIndex:null}}),[ue,G]=ur("input",{ref:g,elementType:Zwe,className:Y.input,externalForwardedProps:ae,getSlotProps:ie=>({...ie,onChange:Q=>{ie.onChange?.(Q),N(Q)}}),ownerState:H,additionalProps:{autoFocus:n,checked:r,defaultChecked:a,disabled:B,id:I?u:void 0,name:y,readOnly:b,required:$,tabIndex:k,type:T,...T==="checkbox"&&O===void 0?{}:{value:O}}});return p.jsxs(K,{...oe,children:[p.jsx(ue,{...G}),F?o:d]})}),eSe=Jt(p.jsx("path",{d:"M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z"})),tSe=Jt(p.jsx("path",{d:"M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.11 0 2-.9 2-2V5c0-1.1-.89-2-2-2zm-9 14l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"})),nSe=Jt(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-2zm-2 10H7v-2h10v2z"}));function rSe(e){return Cn("MuiCheckbox",e)}const MC=fn("MuiCheckbox",["root","checked","disabled","indeterminate","colorPrimary","colorSecondary","sizeSmall","sizeMedium"]),oSe=e=>{const{classes:t,indeterminate:n,color:r,size:o}=e,a={root:["root",n&&"indeterminate",`color${Tt(r)}`,`size${Tt(o)}`]},i=bn(a,rSe,t);return{...t,...i}},aSe=nt(Jwe,{shouldForwardProp:e=>ei(e)||e==="classes",name:"MuiCheckbox",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.root,n.indeterminate&&t.indeterminate,t[`size${Tt(n.size)}`],n.color!=="default"&&t[`color${Tt(n.color)}`]]}})(Gn(({theme:e})=>({color:(e.vars||e).palette.text.secondary,variants:[{props:{color:"default",disableRipple:!1},style:{"&:hover":{backgroundColor:e.alpha((e.vars||e).palette.action.active,(e.vars||e).palette.action.hoverOpacity)}}},...Object.entries(e.palette).filter(Ma()).map(([t])=>({props:{color:t,disableRipple:!1},style:{"&:hover":{backgroundColor:e.alpha((e.vars||e).palette[t].main,(e.vars||e).palette.action.hoverOpacity)}}})),...Object.entries(e.palette).filter(Ma()).map(([t])=>({props:{color:t},style:{[`&.${MC.checked}, &.${MC.indeterminate}`]:{color:(e.vars||e).palette[t].main},[`&.${MC.disabled}`]:{color:(e.vars||e).palette.action.disabled}}})),{props:{disableRipple:!1},style:{"&:hover":{"@media (hover: none)":{backgroundColor:"transparent"}}}}]}))),iSe=p.jsx(tSe,{}),sSe=p.jsx(eSe,{}),lSe=p.jsx(nSe,{}),cSe=C.forwardRef(function(e,t){const n=Kn({props:e,name:"MuiCheckbox"}),{checkedIcon:r=iSe,color:o="primary",icon:a=sSe,indeterminate:i=!1,indeterminateIcon:s=lSe,inputProps:l,size:d="medium",disableRipple:u=!1,className:m,slots:g={},slotProps:y={},...x}=n,w=i?s:a,S=i?s:r,b={...n,disableRipple:u,color:o,indeterminate:i,size:d},$=oSe(b),k=y.input??l,[T,O]=ur("root",{ref:t,elementType:aSe,className:Ht($.root,m),shouldForwardComponentProp:!0,externalForwardedProps:{slots:g,slotProps:y,...x},ownerState:b,additionalProps:{type:"checkbox",icon:C.cloneElement(w,{fontSize:w.props.fontSize??d}),checkedIcon:C.cloneElement(S,{fontSize:S.props.fontSize??d}),disableRipple:u,slots:g,slotProps:{input:aF(typeof k=="function"?k(b):k,{"data-indeterminate":i})}}});return p.jsx(T,{...O,classes:$})});function uSe(e){return Cn("MuiFormControlLabel",e)}const jg=fn("MuiFormControlLabel",["root","labelPlacementStart","labelPlacementTop","labelPlacementBottom","disabled","label","error","required","asterisk"]),dSe=e=>{const{classes:t,disabled:n,labelPlacement:r,error:o,required:a}=e,i={root:["root",n&&"disabled",`labelPlacement${Tt(r)}`,o&&"error",a&&"required"],label:["label",n&&"disabled"],asterisk:["asterisk",o&&"error"]};return bn(i,uSe,t)},fSe=nt("label",{name:"MuiFormControlLabel",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[{[`& .${jg.label}`]:t.label},t.root,t[`labelPlacement${Tt(n.labelPlacement)}`]]}})(Gn(({theme:e})=>({display:"inline-flex",alignItems:"center",cursor:"pointer",verticalAlign:"middle",WebkitTapHighlightColor:"transparent",marginLeft:-11,marginRight:16,[`&.${jg.disabled}`]:{cursor:"default"},[`& .${jg.label}`]:{[`&.${jg.disabled}`]:{color:(e.vars||e).palette.text.disabled}},variants:[{props:{labelPlacement:"start"},style:{flexDirection:"row-reverse",marginRight:-11}},{props:{labelPlacement:"top"},style:{flexDirection:"column-reverse"}},{props:{labelPlacement:"bottom"},style:{flexDirection:"column"}},{props:({labelPlacement:t})=>t==="start"||t==="top"||t==="bottom",style:{marginLeft:16}}]}))),pSe=nt("span",{name:"MuiFormControlLabel",slot:"Asterisk"})(Gn(({theme:e})=>({[`&.${jg.error}`]:{color:(e.vars||e).palette.error.main}}))),hSe=C.forwardRef(function(e,t){const n=Kn({props:e,name:"MuiFormControlLabel"}),{checked:r,className:o,componentsProps:a={},control:i,disabled:s,disableTypography:l,inputRef:d,label:u,labelPlacement:m="end",name:g,onChange:y,required:x,slots:w={},slotProps:S={},value:b,...$}=n,k=Ai(),T=s??i.props.disabled??k?.disabled,O=x??i.props.required,P={disabled:T,required:O};["checked","name","onChange","value","inputRef"].forEach(N=>{typeof i.props[N]>"u"&&typeof n[N]<"u"&&(P[N]=n[N])});const D=nf({props:n,muiFormControl:k,states:["error"]}),A={...n,disabled:T,labelPlacement:m,required:O,error:D.error},F=dSe(A),L={slots:w,slotProps:{...a,...S}},[_,R]=ur("typography",{elementType:Sr,externalForwardedProps:L,ownerState:A});let z=u;return z!=null&&z.type!==Sr&&!l&&(z=p.jsx(_,{component:"span",...R,className:Ht(F.label,R?.className),children:z})),p.jsxs(fSe,{className:Ht(F.root,o),ownerState:A,ref:t,...$,children:[C.cloneElement(i,P),O?p.jsxs("div",{children:[z,p.jsxs(pSe,{ownerState:A,"aria-hidden":!0,className:F.asterisk,children:[" ","*"]})]}):z]})});function mSe({materialization:e,onCloseDialog:t,isMutating:n,onDelete:r}){const[o,a]=C.useState(!1),[i,s]=C.useState(!1),l=()=>a(!0),d=()=>{a(!1),s(!1),t()};return p.jsxs(kn.Fragment,{children:[p.jsxs(Vo,{"aria-label":`Delete materialization ${e?.id??""}`.trim(),onClick:u=>{u.stopPropagation(),l()},sx:{color:"error.main"},children:[p.jsx(oT,{sx:{color:"inherit"},children:p.jsx(Zx,{fontSize:"small"})}),p.jsx(aT,{children:"Delete"})]}),p.jsxs(Oo,{open:o,onClose:d,title:"Delete materialization",actions:p.jsxs(p.Fragment,{children:[p.jsx(Co,{onClick:d,children:"Cancel"}),p.jsx(Co,{variant:"contained",color:"error",autoFocus:!0,onClick:()=>r(i),loading:n,children:"Delete run"})]}),children:[p.jsx(Sr,{variant:"body2",children:"Delete this run's record? This cannot be undone."}),p.jsx(hSe,{control:p.jsx(cSe,{checked:i,onChange:u=>s(u.target.checked)}),label:"Also drop the materialized tables this run produced"})]})]})}function gSe({materializations:e,mutable:t,isMutating:n,onStop:r,onDelete:o,onViewDetails:a}){return e.length===0?p.jsx(wt,{variant:"body2",color:"text.secondary",sx:{py:1,fontStyle:"italic"},children:"No materializations yet."}):p.jsxs(Bx,{size:"small",sx:{"& td, & th":{borderColor:"divider"},"& td:first-of-type, & th:first-of-type":{pl:0},"& td:last-of-type, & th:last-of-type":{pr:0},"& th":{color:"text.secondary",fontWeight:600}},children:[p.jsx(Hx,{children:p.jsxs(vu,{children:[p.jsx(dr,{children:"Status"}),p.jsx(dr,{children:"Trigger"}),p.jsx(dr,{children:"Started"}),p.jsx(dr,{children:"Duration"}),p.jsx(dr,{children:"Sources"}),p.jsx(dr,{align:"right",children:"Actions"})]})}),p.jsx(qx,{children:e.map(i=>p.jsx(ySe,{materialization:i,mutable:t,isMutating:n,onStop:r,onDelete:o,onViewDetails:a},i.id))})]})}function ySe({materialization:e,mutable:t,isMutating:n,onStop:r,onDelete:o,onViewDetails:a}){const[i,s]=C.useState(null),l=!!i,d=()=>s(null),u=cT(e),m=u.sourcesBuilt!==void 0||u.sourcesReused!==void 0?m6(u,", "):"-",g=tx(e.status),y=Uwe(e.status),x=e.error??void 0,w=t&&(g||y);return p.jsxs(vu,{hover:!0,sx:{cursor:"pointer","&:focus-visible":{outline:"2px solid",outlineColor:"primary.main",outlineOffset:"-2px"}},onClick:()=>a(e),onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),a(e))},role:"button",tabIndex:0,"aria-label":`View materialization ${e.id??""} details`.trim(),children:[p.jsx(dr,{children:p.jsxs(Te,{sx:{display:"flex",alignItems:"center",gap:.5},children:[p.jsx(wt,{variant:"body2",sx:{fontWeight:500,color:R$(e.status)==="default"?"text.primary":`${R$(e.status)}.main`},children:h6(e.status)}),x&&p.jsx(Br,{title:x,children:p.jsx(w_,{fontSize:"small",color:"error"})})]})}),p.jsx(dr,{children:p.jsx(y6,{meta:u})}),p.jsx(dr,{children:Vwe(e.startedAt??e.createdAt)}),p.jsx(dr,{children:g6(e.startedAt,e.completedAt)}),p.jsx(dr,{children:m}),p.jsx(dr,{align:"right",onClick:S=>S.stopPropagation(),children:w&&p.jsxs(p.Fragment,{children:[p.jsx(ro,{size:"small","aria-label":`Materialization actions for ${e.id??""}`.trim(),onClick:S=>s(S.currentTarget),children:p.jsx(Jx,{fontSize:"small"})}),p.jsxs(uc,{anchorEl:i,open:l,onClose:d,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[t&&g&&p.jsxs(ea,{"aria-label":`Stop materialization ${e.id??""}`.trim(),disabled:n,onClick:()=>{d(),r(e)},children:[p.jsx(ml,{children:p.jsx(Gwe,{fontSize:"small"})}),p.jsx(Ci,{children:"Stop"})]}),t&&y&&p.jsx(mSe,{materialization:e,isMutating:n,onCloseDialog:d,onDelete:S=>o(e,S)})]})]})})]})}const vSe=Jt(p.jsx("path",{d:"m11.99 18.54-7.37-5.73L3 14.07l9 7 9-7-1.63-1.27zM12 16l7.36-5.73L21 9l-9-7-9 7 1.63 1.27zm0-11.47L17.74 9 12 13.47 6.26 9z"})),bSe={package:"Materialized artifacts are shared across versions",version:"Materialized artifacts are per published version"};function xSe({scope:e,disabled:t,disabledReason:n,isSubmitting:r,onChange:o}){const[a,i]=C.useState(null),s=async l=>{i(null),l!==e&&await o(l).catch(()=>{})};return p.jsxs(p.Fragment,{children:[p.jsx(Xy,{label:"Scope",icon:p.jsx(vSe,{}),onClick:l=>i(l.currentTarget),disabled:t||r,...n?{disabledReason:n}:{},ariaHasPopup:"menu",ariaLabel:`Scope: ${e}`}),p.jsx(uc,{anchorEl:a,open:!!a,onClose:()=>i(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:["package","version"].map(l=>p.jsxs(ea,{selected:l===e,onClick:()=>void s(l),children:[p.jsx(ml,{sx:{minWidth:32},children:l===e&&p.jsx(pF,{fontSize:"small"})}),p.jsx(Ci,{primary:l,secondary:bSe[l]})]},l))})]})}const wSe=Jt([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 8"},"0"),p.jsx("path",{d:"M12.5 7H11v6l5.25 3.15.75-1.23-4.5-2.67z"},"1")]),zI="0 6 * * *";function SSe({currentSchedule:e,isSubmitting:t,disabled:n,disabledReason:r,onSubmit:o}){const[a,i]=C.useState(!1),[s,l]=C.useState(e??zI),d=()=>{l(e??zI),i(!0)},u=()=>i(!1),m=lT(s),g=async y=>{try{await o(y),i(!1)}catch{}};return p.jsxs(p.Fragment,{children:[p.jsx(Xy,{label:"Schedule",icon:p.jsx(wSe,{}),onClick:d,disabled:n,...r?{disabledReason:r}:{},ariaHasPopup:"dialog",ariaLabel:e?"Edit schedule":"Set schedule"}),p.jsxs(Oo,{open:a,onClose:u,title:e?"Edit schedule":"Set schedule",description:"The publisher rebuilds this package's materializations on this cadence: a 5-field UNIX cron, in UTC. In a hosted deployment the change takes effect on your next publish.",actions:p.jsxs(p.Fragment,{children:[e&&p.jsx(Vn,{color:"error",loading:t,onClick:()=>g(null),sx:{mr:"auto"},children:"Clear schedule"}),p.jsx(Vn,{onClick:u,children:"Cancel"}),p.jsx(Vn,{variant:"contained",loading:t,disabled:!m.valid,onClick:()=>g(s.trim()),children:"Save schedule"})]}),children:[p.jsx(Ri,{autoFocus:!0,fullWidth:!0,size:"small",label:"Cron expression",value:s,onChange:y=>l(y.target.value),error:s.trim()!==""&&!m.valid,helperText:m.valid?`${m.description} · next run ${p6(m.nextRun)}`:m.error,slotProps:{htmlInput:{style:{fontFamily:Fo}}}}),p.jsxs(lo,{severity:"info",children:["A schedule runs only on version-scoped packages, so saving one sets ",p.jsx("code",{children:"scope: version"})," for this package."]})]})]})}const CSe=3e3;function kSe({resourceUri:e,versioned:t=!1}){const{apiClients:n,mutable:r}=tr(),o=Tl(),{environmentName:a,packageName:i,versionId:s}=Xr(e),[l,d]=C.useState(""),[u,m]=C.useState(null);if(!i)throw new Error("Materializations requires a package in the resource URI");const g=co({queryKey:["materializations",a,i,s],queryFn:()=>n.materializations.listMaterializations(a,i,void 0,void 0,s),refetchInterval:H=>(H.state.data?.data??[]).some(Y=>tx(Y.status))?CSe:!1}),y=co({queryKey:["package",a,i,s],queryFn:()=>n.packages.getPackage(a,i,s)}),x=co({queryKey:["package-build-plan",a,i,s],queryFn:async({signal:H})=>{try{return{inline:!1,plan:(await n.packages.getPackageBuildPlan(a,i,s,{signal:H})).data}}catch(Y){if(Y?.response?.status===404)return{inline:!0,plan:null};throw Y}},enabled:u!==null}),w=()=>o.invalidateQueries({queryKey:["materializations",a,i]}),S=hl({mutationFn:rc("materialization","create",H=>n.materializations.createMaterialization(a,i,{forceRefresh:H.forceRefresh,...s!==void 0?{versionId:s}:{}})),onSuccess(){d("Materialization requested"),w()},onError(H){d(H.message),w()}}),b=hl({mutationFn:rc("materialization","update",H=>n.materializations.materializationAction(a,i,H.id,xre.Stop,s)),onSuccess(){d("Materialization stopped"),w()},onError(H){d(H.message)}}),$=hl({mutationFn:rc("materialization","delete",({materialization:H,dropTables:Y})=>n.materializations.deleteMaterialization(a,i,H.id,Y,s)),onSuccess(){d("Materialization deleted"),w()},onError(H){d(H.message)}}),k=y.data?.data,T=hl({mutationFn:rc("schedule","update",H=>n.packages.updatePackage(a,i,{name:i,description:k?.description,...H?{scope:Cb.Version}:{},materialization:{schedule:H}})),onSuccess(H,Y){d(Y?"Schedule updated":"Schedule cleared"),o.invalidateQueries({queryKey:["package",a,i]})},onError(H){d(H.message)}}),O=hl({mutationFn:rc("scope","update",H=>n.packages.updatePackage(a,i,{name:i,description:k?.description,scope:H})),onSuccess(){d("Scope updated"),o.invalidateQueries({queryKey:["package",a,i]})},onError(H){d(H.message)}}),P=g.data?.data??[],D=P.find(H=>H.id===u)??null,A=P.some(H=>tx(H.status)),F=S.isPending||b.isPending||$.isPending,L=x.isError?{status:"unavailable"}:x.isSuccess?x.data.inline?y.isSuccess?{status:"ready",plan:k?.buildPlan??null}:y.isError?{status:"unavailable"}:{status:"loading"}:{status:"ready",plan:x.data.plan}:{status:"loading"},_=k?.materialization?.schedule??null,R=k?.scope===Cb.Version?"version":"package",z=!!k?.manifestLocation,N=!!k?.materialization?.freshness,B=_?lT(_):null,I=z?"Control-plane managed: refresh is driven by the control plane, not the built-in scheduler.":[B?B.valid?`${B.description} (${_}), next run ${p6(B.nextRun)}`:`Unrecognized cron expression (${_})`:N?"Refreshed by a freshness policy; a cron schedule does not apply":"On demand only, no schedule set",`scope: ${R}`].join(" · ");return p.jsxs(p.Fragment,{children:[p.jsxs(Ns,{title:"Materializations",count:g.isSuccess?P.length:void 0,action:r&&p.jsxs(Yn,{direction:"row",spacing:1,alignItems:"center",children:[!z&&!t&&p.jsx(xSe,{scope:R,disabled:!!_,disabledReason:"A schedule requires version scope. Clear the schedule to change it.",isSubmitting:O.isPending,onChange:H=>O.mutateAsync(H==="version"?Cb.Version:Cb.Package)}),!z&&!t&&p.jsx(SSe,{currentSchedule:_,isSubmitting:T.isPending,disabled:N,disabledReason:"This package declares a freshness policy; a schedule and freshness are mutually exclusive.",onSubmit:H=>T.mutateAsync(H)}),p.jsx(Bwe,{onSubmit:H=>S.mutateAsync(H),isSubmitting:S.isPending,disabled:A,disabledReason:"A materialization is already pending or running for this package."})]}),children:[y.isSuccess&&p.jsx(wt,{variant:"body2",color:"text.secondary",sx:{mb:1.5},children:I}),g.isError&&p.jsx(ja,{error:g.error,context:`${a} > ${i} > Materializations`}),!g.isSuccess&&!g.isError&&p.jsx(Bo,{text:"Loading materializations..."}),g.isSuccess&&p.jsx(gSe,{materializations:P,mutable:r,isMutating:F,onStop:H=>b.mutate(H),onDelete:(H,Y)=>$.mutate({materialization:H,dropTables:Y}),onViewDetails:H=>m(H.id??null)})]}),p.jsx(Ywe,{materialization:D,buildPlan:L,onClose:()=>m(null)}),p.jsx(hh,{open:l!=="",autoHideDuration:6e3,onClose:()=>d(""),message:l})]})}const uT=Jt(p.jsx("path",{d:"M17 7h-4v2h4c1.65 0 3 1.35 3 3s-1.35 3-3 3h-4v2h4c2.76 0 5-2.24 5-5s-2.24-5-5-5m-6 8H7c-1.65 0-3-1.35-3-3s1.35-3 3-3h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4zm-3-4h8v2H8z"}));function ih(e){return v6(e).join(`
|
|
@@ -490,7 +490,7 @@ ${t}`}function Mce(e){return e?.status===403}function Zp(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&&JSe.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 tCe(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*\`?${of(t)}\`?\\s+is\\s+`).exec(e);i&&a(O$(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]?O$(e.slice(l.index+l[0].length)):l[1]);return{sources:r,unresolved:o}}function O$(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"}},$6=C.createContext(void 0);function mT({layer:e,title:t,children:n,testId:r}){const o=C.useContext($6);if(!o||!e||!o.layers.includes(e))return p.jsx(Br,{title:t,children:p.jsx(Te,{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(Te,{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 nCe(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 rCe={authorize:[],accessFilter:[]};function _I(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim()!==""):[]}function oCe(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=_I(o.authorize),i=_I(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)||rCe}function mc(e){return!!e&&e.authorize.some(t=>t.trim()!=="true")}function Mu(e){return!!e&&e.accessFilter.length>0}const BI=/^\(?\s*(?:'([^']*)'|"([^"]*)")\s+in\s+\$GROUPS\s*\)?$/;function aCe(e){const t=e.trim();if(t==="false")return"no one";const n=BI.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=>BI.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 R6(e){const t=e.authorize.filter(n=>n.trim()!=="true").map(n=>aCe(n)??"readers its access rule admits");return Array.from(new Set(t)).join(", and ")}const T6="Only some readers can query this source",E6="Each reader sees only the rows they're allowed to see";function iCe(e,t){return e?mc(t)?`You can't access ${e}. It is restricted to ${R6(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 sCe(e,t){if(!(!Mu(e)||t===void 0))return nCe(t)===0?"Filtered to your rows: this source shows each reader only the rows they're allowed to see.":void 0}function M6(e){return mc(e)||Mu(e)}function lCe(e,t){return`This join doesn't apply the ${mc(t)&&Mu(t)?"access rule and row filter":mc(t)?"access rule":"row filter"} on ${e}: its rows are read under this source's rules.`}function cCe({access:e}){return p.jsxs(p.Fragment,{children:[mc(e)&&p.jsx(UI,{label:"Restricted",meaning:T6}),Mu(e)&&p.jsx(UI,{label:"Row filtered",meaning:E6})]})}function UI({label:e,meaning:t}){return p.jsx(mT,{layer:"access",title:`${e}: ${t}`,testId:`source-access-chip-${e==="Restricted"?"restricted":"row-filtered"}`,children:p.jsx(fs,{tone:"neutral",size:"header",children:e})})}function O6({access:e}){return p.jsxs(p.Fragment,{children:[mc(e)&&p.jsx(Br,{title:`Restricted: ${T6}`,children:p.jsx(fs,{voice:"token",tone:"neutral",sx:{alignSelf:"center"},children:"Restricted"})}),Mu(e)&&p.jsx(Br,{title:`Row filtered: ${E6}`,children:p.jsx(fs,{voice:"token",tone:"neutral",sx:{alignSelf:"center"},children:"Row filtered"})})]})}function uCe(e){return[mc(e)&&"restricted",Mu(e)&&"row filtered"].filter(Boolean).map(t=>`, ${t}`).join("")}function dCe({access:e,showRules:t}){const n=mc(e),r=Mu(e);return!n&&!r?null:p.jsxs(Te,{"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:R6(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 qI="Private",fCe="index.malloy doesn't export this file, so only people who can edit the package see it.";function HI(){return p.jsx(mT,{title:`${qI}: ${fCe}`,testId:"model-viewer-off-surface",children:p.jsx(fs,{tone:"warning",size:"header",children:qI})})}const VI="Public",pCe="index.malloy exports this source, so everyone who can read the package can query it.";function hCe(){return p.jsx(mT,{title:`${VI}: ${pCe}`,testId:"model-viewer-public-surface",children:p.jsx(fs,{tone:"positive",size:"header",children:VI})})}function mCe(e){const t=C.useRef(e);return e!==void 0&&(t.current=e),t.current}function OC({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)||Mu(u),S=w?["access"]:[],[b,$]=C.useState(void 0),k=b!==void 0&&S.includes(b)?b:void 0,T=mCe(k),O=C.useId(),P={openLayer:k,layers:S,toggle:L=>$(_=>_===L?void 0:L),cardId:O},D=w||y||x||!!s,A=Vr().theme.ui.type.pageTitle,F=typeof A.fontSize=="number"?`${A.fontSize}px`:A.fontSize;return p.jsxs(Te,{children:[p.jsxs(Te,{"data-testid":"model-viewer-source-heading",sx:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:1.5,pt:M$,pb:.5},children:[p.jsx(Te,{component:l,sx:{m:0,fontSize:l==="h1"?F:`calc(${F} * 0.8)`,fontWeight:A.fontWeight??600,lineHeight:1.25,color:"text.primary",fontFamily:os,minWidth:0,overflowWrap:"anywhere"},children:e}),t,i&&p.jsx(Te,{sx:{ml:"auto",display:"flex",alignItems:"center",gap:1},children:i})]}),!g&&y&&p.jsx(Te,{sx:{display:"flex",alignItems:"center",pt:.5,pb:1},children:p.jsx(HI,{})}),g&&D&&p.jsx($6.Provider,{value:P,children:p.jsxs(Te,{"data-testid":"model-viewer-status-row",sx:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:1.5,pt:.5,pb:1},children:[p.jsx(cCe,{access:u}),y&&p.jsx(HI,{}),x&&p.jsx(hCe,{}),s]})}),d&&p.jsx(WI,{doc:d,label:"model description",testId:"model-viewer-model-doc"},`model:${d}`),o&&p.jsx(WI,{doc:o},o),(n!==void 0||r!==void 0||a)&&p.jsxs(Te,{"data-testid":"model-viewer-source-meta",sx:{display:"flex",alignItems:"center",gap:.75,minWidth:0,pb:2,fontSize:Xa.body,color:"text.secondary",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[n!==void 0&&p.jsx(Te,{component:"span","data-testid":"model-viewer-source-kind",children:n}),n!==void 0&&(r!==void 0||a)&&p.jsx(Te,{component:"span","aria-hidden":!0,children:"·"}),r!==void 0&&p.jsx(Te,{component:"span",children:r}),r!==void 0&&a&&p.jsx(Te,{component:"span","aria-hidden":!0,children:"·"}),a&&p.jsx(Te,{component:"span",sx:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis"},children:a})]}),p.jsx(Up,{in:k!==void 0,timeout:"auto",unmountOnExit:!0,children:p.jsx(Te,{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(dCe,{access:u,showRules:m})})})]})}const gCe=2;function WI({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(Te,{"data-testid":n,sx:{pb:.5},children:[p.jsx(Te,{ref:s,sx:{fontSize:Xa.body,lineHeight:1.5,color:"text.secondary",whiteSpace:"pre-line",...r?{}:{display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:gCe,overflow:"hidden"}},children:P6(e)}),(a||r)&&p.jsx(Te,{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:Xa.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 P6(e){return e.split(/(`[^`\n]+`)/g).map((t,n)=>/^`[^`]+`$/.test(t)?p.jsx(Te,{component:"code",sx:{fontFamily:os,fontSize:"0.92em",color:"text.primary"},children:t.slice(1,-1)},n):t)}function B1(e){const t=e?.response?.status;return typeof t=="number"?t:void 0}function yCe(e){const t=B1(e);return t===403||t===404}function vCe(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 gT=C.createContext([]),nx="text.primary",mg=e=>({main:e,tint:`color-mix(in srgb, ${e} 12%, transparent)`,onTint:e}),Tp={steel:mg(hr.cyan),sage:mg(hr.lime),brown:mg(hr.slate),olive:mg(hr.violet),amber:mg(hr.amber)};function YI(e){return e==="measure"?Tp.sage:e==="calculate"?Tp.amber:e==="view"?Tp.olive:Tp.steel}const GI=["steel","brown","olive","sage"];function bCe(e){return GI[e%GI.length]}const j6={small:13,caption:12},xCe={fontFamily:os,fontSize:j6.small,fontWeight:500,color:nx},A6={fontSize:j6.caption,color:"text.secondary"};function sh({label:e,count:t,level:n="h2",testId:r,action:o,children:a}){return t===0?null:n==="h3"?p.jsxs(Te,{component:"section","aria-label":e,"data-testid":r,sx:{mb:2},children:[p.jsx(Te,{component:"h3",sx:{m:0,mb:1,fontSize:Xa.bodyLarge,fontWeight:E$.strong,color:nx},children:e}),a]}):p.jsxs(Te,{component:"section","aria-label":e,"data-testid":r,sx:{mb:3},children:[p.jsxs(Te,{sx:{mb:2},children:[p.jsx(Te,{component:"h2",sx:{m:0,fontSize:"1.25rem",fontWeight:E$.strong,color:nx},children:e}),o&&p.jsx(Te,{sx:{...A6,mt:.25,display:"flex",alignItems:"center"},children:o})]}),a]})}function Qg(e,t){return e.length<=1?e.join(""):`${e.slice(0,-1).join(", ")} ${t} ${e.at(-1)}`}function KI(e,t){return`${e.label??e.name}: ${t0e(e,t)}`}const Hb=e=>e.label??e.name;function D6(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(Hb).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 ${Qg(O.map(Hb),"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=>KI(T)).join(", ")}`:"",x=[];g.length>0&&x.push(`Ran without a value for ${g.length===1?"the given":"the givens"} ${Qg(g.map(Hb),"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=>KI(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 ${Qg($.map(Hb),"or")}. Where it does, it ran with ${k}.`)}return x.length>0?{kind:"noted",note:x.join(" ")}:{kind:"ok"}}const wCe=400;function SCe({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 ${Qg(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=u_(r,wCe),b=C.useMemo(()=>({values:S,declaredTypes:u}),[S,u]),{options:$,isLoading:k,failed:T,truncated:O,search:P}=qF(i,s,l,m,d,b,void 0,y,!0);return p.jsxs(sh,{label:"Givens",count:e.length,testId:"model-givens-section",children:[p.jsx(Te,{sx:{"& .MuiPaper-root":{borderColor:"divider"}},children:p.jsx(j1,{layout:"bar",givens:m,values:r,onChange:o,onReset:a,options:$,optionsLoading:k,optionsFailed:T,optionsTruncated:O,optionSearch:P,onControlOpen:w})}),g&&p.jsx(Wd,{"data-testid":"model-givens-unknown",sx:{mt:1},children:g}),n&&n.size>0&&p.jsx(Wd,{"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 CCe="A source is a queryable entry point into the model — pick one to browse its dimensions, measures, views and joins.";function kCe(e,t=!1){return e===0?"No sources":`${e} ${t?"public ":""}source${e===1?"":"s"}`}const $Ce=Jt(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=Jt(p.jsx("path",{d:"M6 6v2h8.59L5 17.59 6.41 19 16 9.41V18h2V6z"})),TCe=Jt(p.jsx("path",{d:"M4 9h4v11H4zm12 4h4v7h-4zm-6-9h4v16h-4z"})),ECe=Jt([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")]),N6=Jt(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"})),MCe=Jt(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"})),OCe=Jt(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"})),PCe=Jt(p.jsx("path",{d:"M15 4v2h3v12h-3v2h5V4zM4 20h5v-2H6V6h3V4H4z"})),jCe=Jt(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"})),ACe=Jt(p.jsx("path",{d:"m12 8-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z"})),DCe=Jt(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"})),I6=Jt(p.jsx("path",{d:"M7.41 8.59 12 13.17l4.59-4.58L18 10l-6 6-6-6z"})),NCe=Jt(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"})),ICe=Jt(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"})),L6=Jt(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"})),LCe=Jt([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")]),z6=Jt(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"})),zCe=Jt(p.jsx("path",{d:"M3 17v2h6v-2zM3 5v2h10V5zm10 16v-2h8v-2h-8v-2h-2v6zM7 9v2H3v2h4v2h2V9zm14 4v-2H11v2zm-6-4h2V7h4V5h-4V3h-2z"})),F6=Jt(p.jsx("path",{d:"M3 5v14h18V5zm5.33 12H5V7h3.33zm5.34 0h-3.33V7h3.33zM19 17h-3.33V7H19z"})),FCe=Jt(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 _Ce=Ao($Ce,"IconText"),QI=Ao(RCe,"IconOpen"),_6=Ao(TCe,"IconResult"),BCe=Ao(ECe,"IconCalculation"),UCe=Ao(N6,"IconDate"),qCe=Ao(MCe,"IconJoin"),HCe=Ao(OCe,"IconCode"),VCe=Ao(PCe,"IconList"),WCe=Ao(jCe,"IconRecord"),YCe=Ao(ACe,"IconCollapse"),GCe=Ao(hF,"IconExpand"),KCe=Ao(DCe,"IconFields"),QCe=Ao(I6,"IconDropdown"),XCe=Ao(NCe,"IconLock"),B6=Ao(ICe,"IconNumber"),ZCe=Ao(L6,"IconTimestamp"),JCe=Ao(LCe,"IconValues"),eke=Ao(z6,"IconBoolean"),tke=Ao(zCe,"IconGivens"),U6=Ao(F6,"IconColumn");Ao(FCe,"IconWarning");const Ty=C.createContext(void 0);function yT(){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 nke({allOpen:e,onToggle:t,noun:n,disabledReason:r}){const o=e?p.jsx(YCe,{size:16,"aria-hidden":!0}):p.jsx(GCe,{size:16,"aria-hidden":!0});return p.jsx(Br,{title:r??"",children:p.jsx("span",{children:p.jsxs(is,{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 rx({noun:e,disabledReason:t}){const[n,r]=C.useState(void 0),o=n?.open??!1;return{command:n,action:p.jsx(nke,{allOpen:o,onToggle:()=>r({open:!o,n:(n?.n??0)+1}),noun:e,disabledReason:t})}}let PC;function rke(e,t){if(PC?.text===t)return PC.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 PC={text:t,parsed:r},r}function U1(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 q6,Vb;function oke(){return Vb??=wo(()=>import("./index-
|
|
493
|
+
`)}let q6,Vb;function oke(){return Vb??=wo(()=>import("./index-diN_kmcj.js").then(e=>e.i),__vite__mapDeps([0,1])).then(e=>{const t="Malloy"in e?e:e.default;return q6=t,t}),Vb.catch(()=>{Vb=void 0}),Vb}function H6(e,t=!0){const[n,r]=C.useState(q6),[o,a]=C.useState(!1),i=!!e&&t;return C.useEffect(()=>{if(!i||n)return;let s=!0;return oke().then(l=>s&&r(l),()=>s&&a(!0)),()=>{s=!1}},[i,n]),{parsed:C.useMemo(()=>i&&n&&e?rke(n,e):void 0,[i,n,e]),pending:i&&!n&&!o}}function ake(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: ${U1(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 ike(e,t){const n=V6(t),r=of(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(Te,{sx:{p:1},children:p.jsx(q1,{messa
|
|
|
507
507
|
`)}}function qke(e,t){const n=(e[t.line]??"").slice(0,t.character),r=n.trim()==="";if(!r&&!eL.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&&eL.test(e[a.next])?[...o(a.next-1).out,...a.out]:a.out}const Hke=/(?<![\w:])([A-Za-z_]\w*)\s*:(?!:)/g;function Vke(e){let t;for(const n of Wke(e).matchAll(Hke))t=n[1];return t}function Wke(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=Yke(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 Yke(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 Gke(e){return/^`?[A-Za-z_]\w*`?\s+is\s+`?([A-Za-z_]\w*)`?\s*(?:extend\b|$)/.exec(e)?.[1]}function kT(e){return e.replace(/^`(.*)`$/,"$1")}const Kke=["fields","code"],tL={display:"inline-flex",alignItems:"center",color:"text.secondary",borderRadius:1,padding:"2px",flexShrink:0,"&:hover":{color:nx}};function Qke({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]=yT(),{layers:y,layer:x,setLayer:w}=X6(Kke),S=C.useMemo(()=>a?eB({entities:a,loading:!!i,error:!!s}):void 0,[a,i,s]),b=e.dimensions.length+e.measures.length,$=p.jsxs(Te,{sx:{display:"inline-flex",alignItems:"center",gap:1},children:[m&&p.jsx(Z6,{"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:tL,children:p.jsx(QI,{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:tL,children:p.jsx(QI,{size:14})}),o?.kind==="join-only"&&p.jsx(Te,{component:"span",sx:{fontSize:Xa.micro,fontStyle:"italic",color:"text.secondary",flexShrink:0},children:"only accessible via join"})]});return p.jsxs(Te,{"data-testid":"model-viewer-join-row","data-name":e.name,sx:m?{pb:1.25}:void 0,children:[p.jsx(CT,{glyph:p.jsx(xT,{kind:"join"}),name:e.name,typeLabel:`${b} ${b===1?"field":"fields"}`,stackPills:!0,descriptors:p.jsxs(fs,{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(O6,{access:d.access})}),p.jsx(Up,{in:m,timeout:"auto",unmountOnExit:!0,children:p.jsx(Te,{sx:{mx:"10px",mt:"2px"},children:x==="code"&&l?p.jsx(Ey,{testId:"model-viewer-join-code",code:l}):p.jsxs(Te,{"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:lCe(d.sourceName,d.access)}),p.jsx(Xg,{label:"Measures",noun:["measure","measures"],level:"h3",items:e.measures,run:t,modelPath:n,sourceName:r,getFieldCode:S}),p.jsx(Xg,{label:"Dimensions",noun:["dimension","dimensions"],level:"h3",items:e.dimensions,run:t,modelPath:n,sourceName:r,getFieldCode:S})]})})})]})}function Xke({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}=_1(),b=C.useMemo(()=>S?e.views.filter(F=>S({modelPath:t,sourceName:e.name,field:F,joined:!1})):e.views,[S,e,t]),$=rx({noun:["view","views"]}),k=rx({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}=H6(a,T),D=C.useMemo(()=>zke(O,e.name),[O,e.name]),A=C.useMemo(()=>eB({entities:n,loading:!!r,error:!!o,columnDescriptions:m,declarations:D,declarationsLoading:P}),[n,r,o,m,D,P]);return p.jsxs(Te,{sx:{paddingBottom:"24px"},children:[x,p.jsx(sh,{label:"Views",count:b.length,action:$.action,children:p.jsx(Ty.Provider,{value:$.command,children:b.map(F=>p.jsx(J6,{field:F,modelPath:t,sourceName:e.name,fieldCode:A(F),run:g},F.name))})}),y,p.jsx(Xg,{label:"Measures",noun:["measure","measures"],items:e.measures,getFieldCode:A,...w}),p.jsx(Xg,{label:"Calculations",noun:["calculation","calculations"],items:e.calculations,getFieldCode:A,...w}),p.jsx(Xg,{label:"Dimensions",noun:["dimension","dimensions"],items:e.dimensions,getFieldCode:A,...w}),p.jsx(sh,{label:"Joins",count:e.joins.length,action:k.action,children:p.jsx(Ty.Provider,{value:k.command,children:e.joins.map(F=>p.jsx(Qke,{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 P$(e){return{name:e.name,kind:e.kind,dataType:fT(e.type),typeTip:MSe(e.type),tags:OSe(e.annotations),doc:ih(e.annotations),indexed:e.kind==="dimension"?VSe(e):void 0,preaggregate:e.kind==="measure"?ESe(e.annotations):void 0}}function Zke(e){const t=[],n=[];for(const r of e.schema?.fields??[]){if(r.kind!=="dimension"&&r.kind!=="measure")continue;const o={...P$(r),indexed:!1,preaggregate:!1};r.kind==="dimension"?t.push(o):n.push(o)}return{name:e.name,relationship:e.relationship,doc:ih(e.annotations),dimensions:t,measures:n}}function Jke(e,t){const n={name:e.name,doc:ih(e.annotations),docParts:v6(e.annotations),accent:bCe(t),persist:TSe(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(P$(r));break;case"calculate":n.calculations.push(P$(r));break;case"view":n.views.push({name:r.name,kind:"view",doc:ih(r.annotations),tags:dT(r.annotations)});break;case"join":n.joins.push(Zke(r));break}return n}function e$e(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:ih(r),tags:dT(r)})}return t}function tB(e){return e.dimensions.length+e.measures.length+e.calculations.length+e.views.length}function t$e(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 n$e(e,t,n){if(!e||!t)return;const r=new RegExp("source:\\s*`?"+of(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 NC(e,t){return`${e} ${e===1?t:`${t}s`}`}function r$e(e){const t=tB(e),n=[NC(e.views.length,"view"),NC(t,"field")];return e.joins.length>0&&n.push(NC(e.joins.length,"join")),n.join(" · ")}function o$e(e,t,n){if(n){const s=n.exportOrder,l=s.length>0&&e.some(d=>s.includes(d.name));return{sources:s$e(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 a$e(e){return/^`.*`$/.test(e)?e.slice(1,-1):e}function i$e(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=a$e(o.trim());a&&!n.includes(a)&&n.push(a)}return n}function s$e(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 l$e(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 c$e="This package's curated sources, in the order its index.malloy exports them.",u$e="This package's public sources.";function d$e(e){return e.mostViews?", most views":""}function f$e({anchorEl:e,onClose:t,sources:n,currentName:r,onPickSource:o,curated:a=!1,exportOrdered:i=!1}){return p.jsxs(DR,{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(Te,{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?c$e:u$e:CCe})]}),p.jsx(Te,{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(is,{"data-item-name":s.name,"aria-label":`Open source ${s.name}${d$e(s)}${uCe(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?xo.background.muted:void 0,"&:hover":{bgcolor:l?xo.background.strong:xo.background.muted},...Ry},children:[p.jsx(Te,{component:"span","aria-hidden":!0,sx:{color:Tp.steel.main,display:"inline-flex",pt:"2px"},children:p.jsx(U6,{size:16})}),p.jsxs(Te,{component:"span",sx:{minWidth:0,flex:1},children:[p.jsxs(Te,{component:"span",sx:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:1},children:[p.jsx(Te,{component:"span",sx:{fontFamily:os,fontSize:Xa.body,fontWeight:500,color:"text.primary"},children:s.name}),s.mostViews&&p.jsx(fs,{tone:"quiet",sx:{alignSelf:"center"},children:p$e}),M6(s.access)&&p.jsx(O6,{access:s.access}),s.status]}),(s.description||s.descriptionPending)&&p.jsxs(Te,{component:"span",sx:{display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:2,overflow:"hidden",mt:.25,fontSize:Xa.small,color:"text.secondary",minHeight:s.description?void 0:"1.4em"},children:[s.description?.generated&&p.jsx(fs,{tone:"quiet","data-testid":"model-sources-summary-generated",sx:{mr:.75,verticalAlign:"baseline"},children:"Generated"}),s.description&&P6(s.description.text)]}),p.jsx(ky,{"data-testid":"model-sources-row-meta",sx:{display:"block",mt:.25},children:s.meta})]})]},`source:${s.name}`)})})]})}const p$e="Most views";function h$e({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(Eke,{size:"small",variant:"outlined",onClick:d=>{i?.(),l(d.currentTarget)},endIcon:p.jsx(QCe,{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(f$e,{anchorEl:s,onClose:()=>l(null),sources:e,currentName:t,onPickSource:r,curated:o,exportOrdered:a})]})}const m$e=[],g$e=[],y$e=[],v$e=new Map;function b$e(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 x$e(e,t){if(typeof e=="string")try{const r=FI(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 FI(n)}async function w$e(e,t,n,r,o,a){const i=await e.models.getModel(t,n,r,o,a),s=S$e(i.data);return{sourceInfos:(i.data.sourceInfos??[]).map(l=>JSON.parse(l)),queries:i.data.queries??[],sourceText:s,givens:LSe(r,i.data),access:oCe(i.data),modelDoc:x$e(i.data.modelInfo,s),hasImports:b$e(i.data)}}function S$e(e){const t=e.sourceText;return typeof t=="string"?t:void 0}function C$e(e,t,n,r,o=!1){return["model-viewer-sources",e,t,n,r??"",...o?["off-surface"]:[]]}function k$e(e,t,n,r,o,a=!1){return{queryKey:C$e(t,n,r,o,a),queryFn:()=>w$e(e,t,n,r,o,a),...o&&o!=="latest"?{staleTime:1/0}:{}}}function $$e(e,t,n,r,o=!0,a=!1){const{apiClients:i}=tr(),s=zd({...k$e(i,e,t,n,r,a),enabled:o&&!!(e&&t&&n)});return{sources:s.data?.sourceInfos??m$e,queries:s.data?.queries??g$e,sourceText:s.data?.sourceText,givens:s.data?.givens??y$e,access:s.data?.access??v$e,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 nL(e){return(e.split("/").pop()??e).replace(/\.malloy$/,"")}function T$e(e,t){const n=KSe(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. ${Qg(r.map(a=>a.name),"and")} ${r.length===1?"comes":"come"} from a file this one imports; the rest are declared here. ${o}`}function E$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}=Xr(e),F=Vr().theme.ui.font.mono,{sources:L,queries:_,sourceText:R,givens:z,access:N,modelDoc:B,hasImports:I,isLoading:H,isError:Y,error:ae,refetch:K}=$$e(O,P,D,A,!0,o),oe=C.useMemo(()=>new Set(a??[]),[a]),ue=C.useMemo(()=>z.filter(Bt=>!oe.has(Bt.name)),[z,oe]),G=C.useMemo(()=>L.map(Jke),[L]),ie=C.useMemo(()=>e$e(_),[_]),Q=C.useMemo(()=>YSe(G),[G]),ee=C.useMemo(()=>WSe(L),[L]),Z=C.useMemo(()=>zSe(ue),[ue]),de=JSON.stringify(i??null),le=C.useMemo(()=>i&&Object.fromEntries(Object.entries(i).filter(([Bt])=>Z.has(Bt))),[de,Z]),fe=!H&&!Y,he=C.useCallback(Bt=>s?.(Bt,Array.from(Z.keys())),[s,Z]),me=_F({declaredTypes:Z,params:le,onParamsChange:fe&&s?he:void 0,documentKey:`${O}/${P}@${A??""}/${D}`,autorun:!0}),se=C.useMemo(()=>FSe(me.applied,Z),[me.applied,Z]),{givensBySource:ve,unknownGivensBySource:Le}=C.useMemo(()=>{const Bt=new Map,pn=new Map;for(const $n of G){const qt=XSe(R,$n.name,ue);Bt.set($n.name,qt.givens),qt.unknown.size>0&&pn.set($n.name,qt.unknown)}return{givensBySource:Bt,unknownGivensBySource:pn}},[G,R,ue]),Ae=C.useMemo(()=>({projectName:O,packageName:P,versionId:A,givens:ue,givensBySource:ve,unknownGivensBySource:Le,requiredFiltersBySource:ee,givenValues:se,accessBySource:N,includeHiddenFilesAndSources:o,queryMetadata:b,onQueryRun:$,maxResultSize:k}),[O,P,A,ue,ve,Le,ee,se,N,o,b,$,k]),[Re,re]=C.useState(r),_e=t!==void 0,Me=_e?t:Re,Ge=C.useCallback(Bt=>{_e||re(Bt),n?.(Bt)},[_e,n]),Je=C.useMemo(()=>t$e(G,D),[G,D]),St=G.find(Bt=>Bt.name===Me)??(_e?void 0:Je),Ut=C.useMemo(()=>St?ve.get(St.name)??ue:ue,[St,ve,ue]),at=C.useMemo(()=>St?ZSe(R,St.name,ue,Q):new Map,[St,R,ue,Q]),tt=C.useMemo(()=>n$e(R,St?.name,Q),[R,St?.name,Q]),pt=C.useMemo(()=>St?$Se(St,G.find(Bt=>Bt.name===tt)):void 0,[St,G,tt]),ze=C.useMemo(()=>g?GSe(g):R$e,[g]),be=St?ze.get(St.name):void 0,{joinLinks:Ve,joinEntities:Oe,joinCodes:$t,joinAccessRules:Rt}=C.useMemo(()=>{const Bt=new Map,pn=new Map,$n=new Map,qt=new Map,Pn=new Map([[D,new Set(Q)]]);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&&pn.set(Se.name,Rn);const en=b0(N,jn.sourceName);M6(en)&&qt.set(Se.name,{sourceName:jn.sourceName,access:en});const jt=vCe(jn,Pn);Bt.set(Se.name,jt.kind==="link"?{...jt,onOpen:()=>Ge(jn.sourceName)}:jt)}else{const Rn=S?.(jn);Rn&&Bt.set(Se.name,{kind:"link",href:Rn})}}return{joinLinks:Bt,joinEntities:pn,joinCodes:$n,joinAccessRules:qt}},[be,ze,D,Q,N,Ge,S]),vt=D==="index.malloy"&&!o,it=C.useMemo(()=>o$e(G,Je,vt?{exportOrder:i$e(R)}:void 0),[G,Je,vt,R]),st=T?.describePickerSource,Dt=C.useMemo(()=>it.sources.map(Bt=>{const pn=st?.({modelPath:D,sourceName:Bt.name});return{name:Bt.name,description:l$e(Bt.doc,pn?.summary),descriptionPending:!Bt.doc?.trim()&&!pn?.summary&&!!pn?.summaryPending,meta:r$e(Bt),mostViews:it.mostViews===Bt.name,access:b0(N,Bt.name),status:pn?.status}}),[it,N,st,D]),nn=(()=>{if(H)return p.jsx(Bo,{text:"Fetching Model..."});if(Y)return yCe(ae)?p.jsx(Te,{sx:{pt:M$},children:p.jsx(Kg,{message:K6(ae)??`${P}/${D} doesn't exist, or you don't have access to it.`})}):p.jsx(q1,{message:Q6("Failed to load model",ae),onRetry:()=>void K()});const Bt=ie.length>0&&p.jsx(Lke,{queries:ie,sourceText:R,modelPath:D,run:Ae});if(G.length===0)return ie.length===0?p.jsxs(p.Fragment,{children:[p.jsx(OC,{headingLevel:d,title:nL(D),meta:ue.length>0?`${ue.length} ${ue.length===1?"given":"givens"}`:void 0,actions:u,isSource:!1,offSurface:o}),p.jsx(Kg,{message:"This model defines no sources or queries.",secondary:I&&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(sh,{label:"Givens",count:ue.length,testId:"model-viewer-declared-givens",children:[p.jsx(Wd,{"data-testid":"model-viewer-declared-givens-where",sx:{mb:1},children:T$e(R,ue)}),p.jsx(pT,{givens:ue})]})]}):p.jsxs(p.Fragment,{children:[p.jsx(OC,{headingLevel:d,title:nL(D),meta:`${ie.length} ${ie.length===1?"query":"queries"}`,actions:u,isSource:!1,offSurface:o}),Bt]});if(!St)return p.jsx(Te,{sx:{pt:M$},children:p.jsx(Kg,{message:`This model has no source named ${Me}.`,secondary:p.jsxs(Te,{component:"span","data-testid":"model-viewer-source-links",children:["Sources in this model: ",G.map((Se,jn)=>p.jsxs("span",{children:[jn>0&&", ",p.jsx(P0,{component:"button",type:"button",onClick:()=>Ge(Se.name),sx:{fontFamily:os,verticalAlign:"baseline"},children:Se.name})]},Se.name))]})})});const pn=tB(St),$n=tt?void 0:[...be?.values()??[]].find(Se=>Se.table)?.table,qt=tt?p.jsxs(p.Fragment,{children:["from ",p.jsx(P0,{component:"button",type:"button",onClick:()=>Ge(tt),sx:{fontFamily:os,color:F1,textDecorationColor:"inherit",verticalAlign:"baseline"},children:tt})]}):$n?p.jsxs(p.Fragment,{children:["reads ",p.jsx(Te,{component:"span","data-testid":"model-viewer-source-table",sx:{fontFamily:os},children:[$n.connectionName,$n.catalogName,$n.schemaName,$n.tableName].filter(Boolean).join(".")})]}):void 0,Pn=T?.renderSourceDetail?.({modelPath:D,sourceName:St.name});return p.jsxs(p.Fragment,{children:[p.jsx(OC,{headingLevel:d,title:St.name,titleAdornments:G.length>1&&p.jsx(h$e,{sources:Dt,currentName:St.name,countLabel:kCe(Dt.length,it.curated),onPickSource:Ge,curated:it.curated,exportOrdered:it.exportOrdered}),actions:u,status:m?.(St.name),kindLabel:"Source",meta:`${pn} ${pn===1?"field":"fields"}`,doc:pt,modelDoc:B,access:b0(N,St.name),showRules:l,offSurface:o,publicSurface:vt,provenance:qt}),Pn&&p.jsx(Te,{"data-testid":"model-viewer-source-detail",sx:{mt:1.5},children:Pn}),p.jsx(gT.Provider,{value:ue,children:p.jsx(Xke,{source:St,modelPath:D,entitiesByName:be,entitiesLoading:y,entitiesError:x,columnDescriptions:w?.get(St.name),modelText:R,joinLinks:Ve,joinAccess:Rt,showRules:l,joinEntities:Oe,joinCodes:$t,run:Ae,queries:Bt,givens:p.jsx(SCe,{givens:Ut,unknown:St?Le.get(St.name):void 0,inheritedFrom:at,values:me.draft,onChange:me.setGiven,onReset:me.reset,environmentName:O,packageName:P,modelPath:D,versionId:A,declaredTypes:Z})},St.name)})]})})();return p.jsx(C6.Provider,{value:T??{},children:p.jsx(Te,{"data-testid":"model-viewer",sx:{...ASe,pb:2,[x6]:F},children:p.jsx(Te,{sx:DSe,children:nn})})})}const M$e=Jt(p.jsx("path",{d:"M8 5v14l11-7z"}));function nB({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(Te,{sx:{height:"70vh",overflow:"auto"},children:p.jsx(A1,{result:n,maxHeight:Ile,maxResultSize:1e6,renderLogs:o,drill:a})})})}function O$e({queryName:e,annotations:t,resourceUri:n,runOnDemand:r=!1,maxResultSize:o=0}){const[a,i]=kn.useState(),[s,l]=kn.useState(!1),[d,u]=kn.useState(!1),{packageName:m,environmentName:g,versionId:y,modelPath:x}=Xr(n),w=!r||d,S=rT({environmentName:g,packageName:m,modelPath:x,versionId:y,queryName:e},{enabled:w}),b=S.data,{mode:$}=Vr();return C.useEffect(()=>{if(t&&t.length>0){const k=t.map(T=>`// ${T}`).join(`
|
|
510
|
-
`);ST(k,"typescript",$).then(T=>{i(T)})}},[t,$]),p.jsxs(Te,{children:[a&&p.jsx(Te,{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(Te,{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(zp,{"aria-label":"Expand results",onClick:()=>l(!0),children:p.jsx(Kp,{})})]}),p.jsxs(x4,{sx:{position:"relative"},children:[r&&!d&&p.jsxs(Te,{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(Vn,{variant:"contained",startIcon:p.jsx(M$e,{}),onClick:()=>u(!0),children:"Run Query"})]}),w&&p.jsx(X2,{state:S,context:e,maxHeight:Nle,maxResultSize:o})]}),p.jsx(nB,{open:s,onClose:()=>l(!1),result:b?.data?.result||"",renderLogs:b?.data?.renderLogs,title:`Query: ${e}`})]})}function P$e(e){return e!=null}function j$e(e,t){const n=[],r=[];for(const a of e){if(a.name===void 0||P$e(t.get(a.name)))continue;if(a.default==null){n.push(a.name);continue}const i=P1(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 A$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 kn.useEffect(()=>{o&&o(t)},[t,o]),p.jsx(b4,{children:p.jsxs(C9,{spacing:2,component:"section",children:[p.jsx(I$e,{sourceAndPath:e[t],existingQuery:n,onChange:l=>{r&&r(l)},resourceUri:a,givens:i,gate:s}),p.jsx(g5,{height:"5px"})]})})}function IC(){return{query:void 0,malloyQuery:void 0,malloyResult:void 0}}function N$e({sourceAndPath:e,onChange:t,existingQuery:n,explorerComponents:r,QueryBuilder:o,resourceUri:a,givens:i,gate:s}){const[l,d]=kn.useState(n||IC()),[u,m]=kn.useState(void 0);kn.useEffect(()=>{n&&d(n)},[n]);const[g,y]=kn.useState([]),{MalloyExplorerProvider:x,QueryPanel:w,ResizableCollapsiblePanel:S,ResultPanel:b,SourcePanel:$}=r;kn.useEffect(()=>{t&&t(l)},[t,l]);const{environmentName:k,packageName:T,versionId:O}=Xr(a),{apiClients:P}=tr(),D=kn.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 N=D.current;m(B=>B?{...B,executionState:"finished",response:{result:z,...N?.defaultsNote?{messages:[{severity:"INFO",title:N.defaultsNote}]}:{}}}:void 0)}},onError:R=>{console.error("Query execution error:",R);const z=R?.data?.message??R?.message??"The query could not be run.",N=[{severity:"ERROR",title:z}],B=D.current?.missing??[];(R?.status===403||/Access denied for source/i.test(z))&&B.length>0&&N.push({severity:"WARN",title:A$e(B)}),m(I=>I?{...I,executionState:"finished",response:{messages:N}}:void 0)}}),[F,L]=kn.useState(e.sourceInfo.name);kn.useEffect(()=>{F!==e.sourceInfo.name&&(L(e.sourceInfo.name),d(IC()),m(void 0))},[e,F]);const _=kn.useCallback(R=>{d({...l,malloyQuery:R,malloyResult:void 0})},[l]);return F!==e.sourceInfo.name?p.jsx("div",{children:"Loading..."}):p.jsx(w4,{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(IC())})}),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 I$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([wo(()=>import("./index-p8cCzaE5.js"),__vite__mapDeps([5,0,1,2,6])),H0e()]).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(Wne,{children:p.jsx(w4,{children:p.jsx(g5,{sx:{alignItems:"center",justifyContent:"center",height:"200px",color:"text.secondary"},children:"Loading explorer..."})})}):p.jsx(N$e,{...e,explorerComponents:t,QueryBuilder:r,resourceUri:e.resourceUri})}function rB(e,t=!0){const{modelPath:n,environmentName:r,packageName:o,versionId:a}=Xr(e),{apiClients:i}=tr();return co({queryKey:["package",r,o,n,a],queryFn:async()=>(await i.models.getModel(r,o,n,a)).data,enabled:t})}function oB({data:e,onChange:t,existingQuery:n,initialSelectedSourceIndex:r=0,onSourceChange:o,resourceUri:a,givens:i,onGivensChange:s,startingGivens:l}){const[d,u]=kn.useState(r);kn.useEffect(()=>{u(r)},[r]);const{data:m,isError:g,isLoading:y,error:x}=rB(a,!e),{environmentName:w,packageName:S,modelPath:b,versionId:$}=Xr(a),k=e||m,T=kn.useMemo(()=>k?.givens??[],[k]),O=b2({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(()=>Jd(O.applied,O.declaredTypes),[O.applied,O.declaredTypes]),D=C.useMemo(()=>j$e(T,O.applied),[T,O.applied]);if(y&&!e)return p.jsx(Bo,{text:"Fetching Model..."});if(g&&!e)return console.log("error",x),p.jsx(ja,{error:x,context:`ModelExplorer > ${b}`});if(!k)return p.jsx(Bo,{text:wu.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(Hne,{variant:"outlined",children:[p.jsx(Vne,{children:p.jsx(Yn,{sx:{flexDirection:"row"},children:p.jsx(mwe,{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(j1,{...O.panel}),p.jsx(b4,{children:p.jsxs(Yn,{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(Te,{height:"5px"})]})})]})}function aB({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(zx,{open:e,onClose:t,fullScreen:!0,children:[p.jsxs(_x,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[o,p.jsx(ro,{onClick:t,sx:{color:"text.secondary"},children:p.jsx(xh,{})})]}),p.jsx(Fx,{children:a?p.jsx(oB,{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 L$e({onChange:e,resourceUri:t,runOnDemand:n=!1,maxResultSize:r=0,givens:o,onGivensChange:a}){const{modelPath:i}=Xr(t),{data:s,isError:l,isLoading:d,error:u}=rB(t),[m,g]=kn.useState(!1),[y,x]=kn.useState(),[w,S]=kn.useState(0),[b,$]=C.useState(""),[k,T]=kn.useState({}),O=o??k,P=a??(R=>T(R)),D=s?.modelDef,A=kn.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(Bo,{text:"Fetching Model..."});if(l)return console.log("error",u),p.jsx(ja,{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(Te,{sx:{position:"relative",maxWidth:"1200px",margin:"0 auto",paddingTop:"24px"},children:[Array.isArray(s?.sourceInfos)&&s.sourceInfos.length>0&&p.jsxs(Yn,{spacing:2,component:"section",children:[p.jsxs(Te,{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(ro,{size:"small","aria-label":"Copy link",onClick:_,sx:{color:"text.secondary"},children:p.jsx(uT,{fontSize:"small"})})})]}),p.jsx(oB,{data:s,onChange:F,onSourceChange:L,existingQuery:y,initialSelectedSourceIndex:w,resourceUri:t,givens:O,onGivensChange:P}),p.jsx(zp,{"aria-label":"Expand results",sx:{position:"absolute",top:"90px",right:"4px",zIndex:2},onClick:()=>g(!0),children:p.jsx(Kp,{})})]}),s?.queries?.length>0&&p.jsxs(Yn,{spacing:2,component:"section",sx:{marginTop:"24px"},children:[p.jsx(Te,{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(O$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(Te,{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(aB,{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(hh,{open:b!=="",autoHideDuration:6e3,onClose:()=>$(""),message:b})]})}function z$e(){const[e,t]=C.useState("");return p.jsxs(p.Fragment,{children:[p.jsx(Br,{title:"Copy link",children:p.jsx(ro,{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(uT,{fontSize:"small"})})}),p.jsx(hh,{open:e!=="",autoHideDuration:6e3,onClose:()=>t(""),message:e})]})}function GTe(e){const{modelPage:t,isLoadingStatus:n}=tr();if(n)return p.jsx(Bo,{text:"Fetching Model..."});if(t!=="viewer")return p.jsx(L$e,{...e});const{onChange:r,runOnDemand:o,headerActions:a,...i}=e;return p.jsx(E$e,{...i,headerActions:a??p.jsx(z$e,{})})}function F$e({warnings:e}){const[t,n]=C.useState(!1),r=(e??[]).filter(a=>a.severity==="error"),o=(e??[]).filter(a=>a.severity!=="error");return r.length===0&&o.length===0?null:p.jsxs(Yn,{sx:{gap:1,mb:4},children:[r.length>0&&p.jsxs(lo,{severity:"warning",children:[p.jsx(vY,{children:r.length===1?"1 problem in this package":`${r.length} problems in this package`}),p.jsx(rL,{findings:r})]}),o.length>0&&p.jsxs(Te,{children:[p.jsxs(Vn,{size:"small","aria-expanded":t,onClick:()=>n(a=>!a),sx:{px:.5,color:"text.secondary"},children:[t?"Hide":"Show"," ",o.length," ",o.length===1?"note":"notes"]}),t&&p.jsx(Te,{sx:{pl:.5,pt:.5},children:p.jsx(rL,{findings:o})})]})]})}function rL({findings:e}){return p.jsx(Yn,{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(Te,{component:"span",sx:{fontFamily:Fo,fontSize:"0.85em",mr:1},children:t.model}),t.message]},`${t.model??""}:${t.code??""}:${n}`))})}function _$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=Xr(e),{apiClients:x}=tr(),w=y.environmentName??"",S=y.packageName??"",b=y.versionId,$=!!y.environmentName&&!!y.packageName,{data:k,isSuccess:T,isError:O,error:P}=co({...uxe(x,{environmentName:w,packageName:S,path:t,versionId:b},u),enabled:$&&t!==""}),D=k?.layout,A=ace({path:t,layout:D},l),F=`${e}|${t}`,L=C.useRef(void 0),_=C.useRef({key:F,at:Pd()});_.current.key!==F&&(_.current={key:F,at:Pd()}),C.useEffect(()=>{L.current!==F&&($?O?(L.current=F,A.emit({type:"report.load_failed",surface:"view",category:U0(P)})):k?.notebook?.format==="malloynb"?(L.current=F,A.emit({type:"report.load_failed",surface:"view",category:"unsupported"})):T&&k&&(L.current=F,A.emit({type:"report.opened",surface:"view",from:"package",tiles:k.tiles?.length??0,durationMs:Pd()-_.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((B,I)=>{const H=o?.(B,I);H&&A.emit({type:"report.drill",to:"report",outcome:H})},[o,A]),z=o?R:void 0;if(!$)return p.jsxs(lo,{severity:"error",children:["A report resource URI must name an environment and a package. Received: ",e]});if(O)return p.jsx(ja,{context:`${w} > ${S} > ${t}`,error:P});if(!T||!k)return p.jsx(Bo,{text:wu.opening("report")});if(k.notebook?.format==="malloynb")return p.jsxs(lo,{severity:"info",children:[t," is a .malloynb notebook, which Report does not run: render it with Notebook."]});const N=p.jsx(t6,{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($F.Provider,{value:A,children:N})}function B$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?L_(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),[N,B]=C.useState(""),[I,H]=C.useState(!1),[Y,ae]=C.useState(!1),[K,oe]=C.useState(!1),[ue,G]=C.useState(void 0),ie=u!=null,{choices:Q,isLoading:ee,isSuccess:Z,failed:de,retry:le,canRetry:fe}=lxe({environmentName:a,packageName:i,...s!==void 0?{versionId:s}:{},models:l,enabled:e&&l.length>0}),he=C.useMemo(()=>Q.get(D)??[],[Q,D]),me=C.useMemo(()=>new Map([...Q.entries()].flatMap(([st,Dt])=>Dt.map(nn=>[LC(st,nn.source,nn.view),{model:st,source:nn.source,view:nn.view}]))),[Q]),se=C.useMemo(()=>{const st=Q.size>1;return[...Q.entries()].flatMap(([Dt,nn])=>{const Bt=new Map;for(const pn of nn)Bt.set(pn.source,[...Bt.get(pn.source)??[],pn]);return[...Bt.entries()].map(([pn,$n])=>({key:`${Dt}::${pn}`,label:pn,ariaLabel:`${pn} in ${Dt}`,...st||$n[0]?.sourceDescription?{detail:[st?Dt:void 0,$n[0]?.sourceDescription].filter(Boolean).join(" · ")}:{},entries:$n.map(qt=>({key:LC(Dt,qt.source,qt.view),name:qt.view,title:qt.description??vC(qt.view),...qt.chart?{chart:qt.chart}:{}}))}))})},[Q]),ve=st=>{const Dt=me.get(st);Dt&&(A(Dt.model),L(`${Dt.source}::${Dt.view}`))},Le=he.find(st=>`${st.source}::${st.view}`===F),Ae=Le?LC(D,Le.source,Le.view):void 0,Re=U$e(Le,250);C.useEffect(()=>{e&&T(b)},[e,b]),C.useEffect(()=>{if(!e)return;const st=[...Q.keys()];D===""&&st.length>0&&A(st[0])},[e,Q,D]),C.useEffect(()=>{!e||he.length===0||F!==""||L(`${he[0].source}::${he[0].view}`)},[e,he,F]),C.useEffect(()=>{!e||I||Le===void 0||B(vC(Le.view))},[e,I,Le]),C.useEffect(()=>{e||(A(""),L(""),R(""),B(""),H(!1),P(void 0),ae(!1),G(void 0))},[e]);const re=C.useMemo(()=>{if(N.trim()!=="")for(let st=1;st<=nT;st++){const Dt=A_(N,st);if(!g.existing?.includes(Dt))return Dt}},[N,g]),_e=O?.trim(),Me=_e===void 0||_e===""?void 0:_e.endsWith(".malloy")?_e:`${_e}.malloy`,Ge=Me??re,Je=Me===void 0?void 0:D_(Me)??(g.existing?.includes(Me)?`${Me} already exists; choose another location.`:void 0),St=(Le===void 0?void 0:eT({title:N,modelPath:D,source:Le.source,view:Le.view}))??(N.trim()!==""&&Ge===void 0?"No free file name for this title; choose another.":void 0),Ut=St!==void 0&&(Y||N.trim()!==""),at=d||ee,{theme:tt}=Vr(),pt=tt.ui,ze=Zd(tt.cardBorder),be=Q.size===0&&(ie||de.length>0),Ve=at?"Loading the model":be?"Couldn't read the model to start from":Q.size===0?"Nothing in the model to start from yet":Le===void 0?"Pick what to start from":void 0,Oe="report",$t=K?`Creating ${Oe}…`:`Create ${Oe}`,Rt=F!==""&&Le===void 0&&he.length>0,vt=async()=>{if(!(Ve!==void 0||Le===void 0||K)){if(St!==void 0||Je!==void 0){ae(!0);return}oe(!0),G(void 0);try{const st=await rxe({layout:k,...Me!==void 0?{path:Me}:{},document:{title:N,modelPath:D,source:Le.source,view:Le.view},target:g,...S?{onEvent:S}:{}});w(st)}catch(st){const Dt=st.response?.data?.message;G(Dt??(st instanceof Error?st.message:String(st)))}finally{oe(!1)}}},it=st=>p.jsx(Vn,{color:"inherit",size:"small",onClick:st,children:"Retry"});return p.jsx(Oo,{className:`${Sl.dialog} ${Sl.newReportDialog}`,maxWidth:"md",initialFocus:z,open:e,onClose:K?()=>{}:x,title:`New ${Oe}`,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(Vn,{onClick:x,disabled:K,children:"Cancel"}),p.jsx(Br,{title:K?"":Ve??"",children:p.jsx("span",{children:p.jsx(Vn,{variant:"contained",disabled:K||Ve!==void 0,"aria-label":!K&&Ve!==void 0?`${$t}: ${Ve}`:$t,onClick:()=>void vt(),children:$t})})})]}),children:p.jsxs(Yn,{sx:{gap:1.5},children:[ie?p.jsx(lo,{severity:"error",action:m&&L4(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(lo,{severity:"info",children:["This package has no models yet. Add a .malloy file that declares a source with a view, then create a ",Oe," from it."]}):de.length>0?p.jsxs(lo,{severity:"warning",action:fe?it(le):void 0,children:["Couldn't read ",de.join(", "),", so nothing from"," ",de.length===1?"it":"them"," is listed."]}):Z&&Q.size===0&&p.jsxs(lo,{severity:"info",children:["A ",Oe," 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(Te,{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(Te,{sx:{display:"flex",flexDirection:"column",minHeight:0,borderRight:{md:`1px solid ${ze}`},maxHeight:{xs:280,md:"none"}},children:p.jsx(Ele,{groups:se,query:_,onQuery:R,picked:Ae,onPick:ve,onTake:st=>{ve(st)},searchRef:z,disabled:K,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(Te,{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(Te,{children:[p.jsx(oL,{children:"Layout"}),p.jsx(Te,{role:"radiogroup","aria-label":"Layout",sx:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:1},children:["linear","grid"].map(st=>p.jsx(V$e,{layout:st,checked:k===st,disabled:K,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(Te,{children:[p.jsx(oL,{children:"First query"}),p.jsx(Te,{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&&Re?p.jsx(Te,{sx:{flex:1,minWidth:0,px:2,pt:1.5},children:p.jsx(B_,{environmentName:a,packageName:i,...s!==void 0?{versionId:s}:{},modelPath:D,tile:`${Re.source} -> ${Re.view}`,label:N.trim()||vC(Re.view),borderless:!0,givens:q$e,declaredTypes:H$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(Ri,{size:"small",label:"Title",value:N,disabled:K,onChange:st=>{H(!0),B(st.target.value)},InputLabelProps:{shrink:!0},inputProps:{"aria-label":"Report title"},error:Ut,helperText:Ut?St:g.route==="package"?"Names the file too, unless you type a location.":y??`Saved as a new ${Oe} in the host's store, and opened in the builder.`}),p.jsx(Ri,{size:"small",label:"Location",value:O??re??"",placeholder:"report.malloy",disabled:K,onChange:st=>P(st.target.value),InputLabelProps:{shrink:!0},inputProps:{"aria-label":"Location"},error:Je!==void 0,helperText:Je??(Ge?`Written as ${Ge} in the package, and opened in the builder.`:"A path in the package; the package root by default.")}),ue&&p.jsx(lo,{severity:"error",children:ue})]})]})]})})}function U$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 LC=(e,t,n)=>`${e}::${t}::${n}`,q$e=new Map,H$e=new Map;function oL({children:e}){const t=Vr().theme.ui;return p.jsx(wt,{component:"div",sx:{...t.type.label,color:"text.secondary",mb:.75},children:e})}function V$e({layout:e,checked:t,disabled:n,onPick:r}){const{theme:o}=Vr(),a=o.ui,i=Zd(o.cardBorder),s=t?o.accent:"currentColor";return p.jsxs(is,{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(Te,{children:[p.jsx(Te,{sx:{...a.type.control,fontWeight:t?a.type.label.fontWeight:500,color:t?o.accent:"text.primary"},children:e==="linear"?"Linear":"Grid"}),p.jsx(Te,{sx:{...a.type.caption,color:"text.secondary"},children:e==="linear"?"Read top to bottom":"Tiles side by side"})]})]})}const W$e=Jt(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"})),Y$e=Jt(p.jsx("path",{d:"M15 4v2h3v12h-3v2h5V4zM4 20h5v-2H6V6h3V4H4z"})),G$e=Jt(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"})),K$e=Jt(p.jsx("path",{d:"M20 10V8h-4V4h-2v4h-4V4H8v4H4v2h4v4H4v2h4v4h2v-4h4v4h2v-4h4v-2h-4v-4zm-6 4h-4v-4h4z"})),iB={dashboard:hr.blue,report:hr.violet,model:hr.cyan,dataApp:hr.pink,data:hr.lime,materialization:hr.amber,agent:hr.red};function sB({type:e,size:t=18,sx:n,...r}){return p.jsx(B0,{...r,viewBox:"0 0 24 24",sx:{width:t,height:t,fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",...n},children:Q$e[e]()})}const Q$e={report:X$e,model:Z$e,data:J$e,materialization:eRe,dataApp:rRe,dashboard:tRe,agent:nRe};function X$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 Z$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 J$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 eRe(){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 tRe(){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 nRe(){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 rRe(){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 lB(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 oRe=12;function aRe(e){const t=e?.trim().toLowerCase()??"";if(t.startsWith("array")||t.endsWith("[]"))return Y$e;if(t.startsWith("record")||t.startsWith("struct"))return G$e;switch(t.split(/[\s(<]/)[0]){case"string":return W$e;case"number":return K$e;case"date":return N6;case"timestamp":case"timestamptz":return L6;case"boolean":return z6;default:return F6}}function iRe({column:e}){const t=aRe(e.type);return p.jsxs(Te,{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(Te,{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 sRe({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:lB(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(Yn,{direction:"row",alignItems:"center",spacing:1.5,sx:{minWidth:0},children:[p.jsx(Te,{"aria-hidden":!0,sx:{width:32,height:32,borderRadius:1,bgcolor:iB.data,color:"#FFFFFF",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:p.jsx(sB,{type:"data",size:18})}),p.jsxs(Te,{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(lo,{severity:"error",variant:"outlined",children:r.error}),r&&!r.error&&p.jsxs(Te,{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(Yn,{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>oRe&&p.jsx(Lx,{value:a,onChange:$=>i($.target.value),placeholder:"Filter columns",inputProps:{"aria-label":"Filter columns"},startAdornment:p.jsx(PR,{position:"start",children:p.jsx(Kp,{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(Te,{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(Te,{component:"ul","aria-labelledby":d,sx:{listStyle:"none",m:0,p:0},children:b.map(($,k)=>p.jsx(iRe,{column:$},`${$.name}-${k}`))})})]})]})}const cB=(e,t,n)=>["packageVersions",e,t,n];async function uB(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 lRe(e,t,n={}){const{apiClients:r,server:o}=tr(),a=(n.enabled??!0)&&e!==""&&t!=="",i=zd({queryKey:cB(e,t,o),queryFn:()=>uB(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 cRe(e,t){const{apiClients:n,server:r}=tr(),o=Tl();return C.useCallback(()=>o.fetchQuery({queryKey:cB(e,t,r),queryFn:()=>uB(n,e,t),staleTime:0,retry:!1}),[o,n,r,e,t])}function uRe(e,t){const n=Tl();return C.useCallback(()=>n.invalidateQueries({predicate:r=>r.queryKey[1]===e&&r.queryKey[2]===t}),[n,e,t])}const dRe=Jt(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"})),fRe=Jt(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"})),pRe=Jt(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"})),hRe=Jt(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"})),gg=e=>{const t=e?.response?.data?.message;return typeof t=="string"&&t!==""?t:e instanceof Error?e.message:"Unknown error"},mRe=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})},Ep=e=>e.archiveStatus==="archive",zC="Tables built for this version alone (under scope: version) are dropped.";function aL(e,t){const n=!Ep(e)&&t.filter(o=>!Ep(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 gRe({environmentName:e,packageName:t,versions:n,selectedVersionId:r,onSelectVersion:o,onReplaceVersion:a,onPackageDeleted:i,canManage:s}){const{apiClients:l}=tr(),d=Tl(),u=uRe(e,t),m=cRe(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,N=()=>Promise.all([u(),d.invalidateQueries({queryKey:["packages",e]})]),B=async(fe,he)=>{const me=he??await m().catch(()=>{});if(me===void 0)return;const se=me.find(Le=>Le.latest)?.id,ve=se??me.find(Le=>Le.id!==fe&&!Ep(Le))?.id;ve!==void 0&&(a?a(ve===se?void 0:ve):o(ve))},I=a0({mutationFn:fe=>l.versions.setPackageLatestVersion(e,t,{version:fe}),onSuccess:async()=>{b(null),await N()},onError:()=>void N()}),H=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 B(he),await N()},onError:(fe,{id:he,archiveStatus:me})=>{me==="unarchive"&&D(`Couldn't unarchive v${he}: ${gg(fe)}`),N()}}),Y=H.isPending?H.variables?.id:void 0,ae=a0({mutationFn:({id:fe})=>l.versions.deletePackageVersion(e,t,fe),onSuccess:async(fe,{id:he,read:me})=>{O(null);const se=await m().catch(()=>{})??me.filter(ve=>ve.id!==he);if(se.length===0){await d.invalidateQueries({queryKey:["packages",e]}),i?.();return}he===z&&await B(he,se),await N()},onError:()=>void N()}),K=()=>w(null),oe=x?aL(x.version,n):{},ue=x!==null&&!Ep(x.version)&&x.version.latest&&oe.archive!==void 0&&oe.delete!==void 0,G=T!==null&&T.versions===void 0,ie=T?.versions!==void 0&&T.versions.length<=1,Q=T?.versions!==void 0?aL(T.version,T.versions).delete:void 0,ee=async fe=>{K(),y(null),ae.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: ${gg(ve)}`);return}const se=me.find(ve=>ve.id===fe.id);if(se===void 0){he(null),D(`v${fe.id} is no longer a version of ${t}.`),N();return}he({version:se,versions:me})},Z=(fe,he)=>{!s||Y===fe.id||w({version:fe,anchor:_.current.get(fe.id)??he})},de=(fe,he)=>{const me=fe.key==="ArrowRight"||fe.key==="ContextMenu"||fe.key==="F10"&&fe.shiftKey;!s||!me||(fe.preventDefault(),fe.stopPropagation(),Z(he,fe.currentTarget))},le=x&&p.jsxs(ea,{disabled:oe.delete!==void 0,onClick:()=>void ee(x.version),children:[p.jsx(ml,{children:p.jsx(SF,{fontSize:"small"})}),p.jsx(Ci,{primary:"Delete version",secondary:oe.delete})]},"delete");return p.jsxs(p.Fragment,{children:[p.jsx(Vn,{size:"small",variant:"outlined",endIcon:p.jsx(I6,{}),"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=Ep(fe),se=[me?"Archived":void 0,mRe(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=>de(ve,fe),onClick:ve=>{if(me){Z(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?as(ve.palette.primary.main,.04):void 0,cursor:he||me&&!s?"default":"pointer"}),children:[p.jsx(Ci,{primary:fe.id,secondary:se,sx:{opacity:me?.6:1},slotProps:{primary:{sx:{fontWeight:he?600:400}}}}),fe.latest&&p.jsx(TR,{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(ro,{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(fRe,{fontSize:"small"})})})})]},fe.id)})}),p.jsx(uc,{anchorEl:x?.anchor??null,open:x!==null,onClose:K,slotProps:{list:{"aria-label":x?`Actions for version ${x.version.id}`:void 0,disabledItemsFocusable:!0,autoFocus:ue}},children:x&&Ep(x.version)?[p.jsxs(ea,{onClick:()=>{const{id:fe}=x.version;K(),H.mutate({id:fe,archiveStatus:"unarchive"})},children:[p.jsx(ml,{children:p.jsx(hRe,{fontSize:"small"})}),p.jsx(Ci,{primary:"Unarchive"})]},"unarchive"),p.jsx(wl,{},"divider"),le]:x&&[p.jsxs(ea,{disabled:x.version.latest,onClick:()=>{b(x.version),I.reset(),K(),y(null)},children:[p.jsx(ml,{children:p.jsx(pRe,{fontSize:"small"})}),p.jsx(Ci,{primary:"Pin as latest",secondary:x.version.latest?"Already the latest version":void 0})]},"pin-latest"),p.jsxs(ea,{disabled:oe.archive!==void 0,onClick:()=>{k(x.version),H.reset(),K(),y(null)},children:[p.jsx(ml,{children:p.jsx(dRe,{fontSize:"small"})}),p.jsx(Ci,{primary:"Archive",secondary:oe.archive})]},"archive"),p.jsx(wl,{},"divider"),le]}),p.jsx(Oo,{open:S!==null,onClose:()=>{I.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(Vn,{ref:A,disabled:I.isPending,onClick:()=>b(null),children:"Cancel"}),p.jsx(Vn,{variant:"contained",loading:I.isPending,onClick:()=>S&&I.mutate(S.id),children:"Pin as latest"})]}),children:p.jsxs(Yn,{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.`}),I.isError&&S&&p.jsx(lo,{severity:"error",role:"alert",children:`Couldn't pin v${S.id} as latest: ${gg(I.error)}`})]})}),p.jsx(Oo,{open:$!==null,onClose:()=>{H.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(Vn,{ref:F,disabled:H.isPending,onClick:()=>k(null),children:"Cancel"}),p.jsx(Vn,{variant:"contained",loading:H.isPending,onClick:()=>$&&H.mutate({id:$.id,archiveStatus:"archive"}),children:"Archive"})]}),children:p.jsxs(Yn,{spacing:1.5,children:[p.jsx(wt,{variant:"body2",color:"text.secondary",children:`${zC} Its scheduled builds stop, and once unarchived it serves live until it is built again.`}),H.isError&&$&&p.jsx(lo,{severity:"error",role:"alert",children:`Couldn't archive v${$.id}: ${gg(H.error)}`})]})}),p.jsx(Oo,{open:T!==null,onClose:()=>{ae.isPending||O(null)},title:T?`Delete v${T.version.id}`:"",initialFocus:L,actions:p.jsxs(p.Fragment,{children:[p.jsx(Vn,{ref:L,disabled:ae.isPending,onClick:()=>O(null),children:"Cancel"}),p.jsx(Vn,{variant:"contained",color:"error",loading:ae.isPending,disabled:G||Q!==void 0,onClick:()=>T?.versions&&ae.mutate({id:T.version.id,read:T.versions}),children:ie?"Delete package":"Delete version"})]}),children:p.jsxs(Yn,{spacing:1.5,children:[G&&T&&p.jsx(wt,{variant:"body2",children:`Checking ${t}'s versions before deleting v${T.version.id}…`}),T&&!G&&p.jsx(wt,{variant:"body2",children:ie?`v${T.version.id} is the only version of ${t}, so deleting it deletes the package. ${zC} This cannot be undone.`:`v${T.version.id} stops being served and its files are removed. ${zC} Links that name it stop working, and this cannot be undone.`}),Q!==void 0&&T&&p.jsx(lo,{severity:"warning",role:"alert",children:`v${T.version.id} can't be deleted now: ${Q}.`}),ae.isError&&T&&p.jsx(lo,{severity:"error",role:"alert",children:`Couldn't delete v${T.version.id}: ${gg(ae.error)}`})]})}),p.jsx(hh,{open:P!==null,autoHideDuration:8e3,onClose:()=>D(null),anchorOrigin:{vertical:"bottom",horizontal:"center"},children:p.jsx(Te,{children:p.jsx(lo,{severity:"error",variant:"filled",onClose:()=>D(null),children:P})})})]})}const yRe="README.malloynb",vRe=e=>!!e&&!e.includes("/")&&D1(e)?.toLowerCase()==="readme";function KTe({onClickPackageFile:e,onOpenDocument:t,resourceUri:n,onEvent:r,onSelectVersion:o,onReplaceVersion:a}){const{apiClients:i,server:s,mutable:l}=tr(),d=Tl(),u=e??(re=>{window.location.href=re}),{environmentName:m,packageName:g,versionId:y}=Xr(n),x=lRe(m,g),{versions:w}=x,S=w.length>0,b=!S&&!x.isPending&&!x.isError,$=o??((re,_e)=>u(`/${encodeURIComponent(m)}/${encodeURIComponent(g)}/${encodeURIComponent(re)}`,_e)),k=t??((re,_e)=>{const Me=re.mode==="edit"?$0e(m,g,re.path):S_(m,g,re.path);_e?u(Me,_e):u(Me)}),[T,O]=C.useState(null),[P,D]=C.useState(!1),A=Cxe(),F=I_()?.documentStorage,[L,_]=C.useState([]),[R,z]=C.useState({state:F?"pending":"ready"}),N=C.useCallback(async()=>{if(!F)return;let re;try{re=await F.listWorkspaces(!1)}catch{z({state:"failed"});return}z({state:"ready",chosen:E_(re)});const _e=[],Me=wy(m,g,"");for(const Ge of re.filter(Je=>Je.writeable))for(const Je of await F.listDocuments(Ge))Je.path.startsWith(Me)&&_e.push({locator:Je,where:Ge.description});_(_e)},[F,m,g]);C.useEffect(()=>{N()},[N]);const B=re=>re.path.slice(wy(m,g,"").length),I=co({queryKey:["package",m,g,y],queryFn:()=>i.packages.getPackage(m,g,y,!1)}),H=co({queryKey:["package-agents",m,g,y],queryFn:()=>i.agents.listAgents(m,g,y)}),Y=C_(m,g,y),ae=co({queryKey:["models",m,g,y],queryFn:()=>i.models.listModels(m,g,y)}),K=co({queryKey:["databases",m,g,y],queryFn:()=>i.databases.listDatabases(m,g,y)}),oe=co({queryKey:["data-apps",m,g,y],queryFn:async()=>{try{return await i.dataApps.listDataApps(m,g,y)}catch(re){const _e=re?.response?.status;if(_e===404||_e===void 0)return{data:[]};throw re}}}).data?.data??[],ue=Y.reports.filter(re=>!!re.path),G=xRe(ue),ie=new Set(ue.map(re=>re.path).filter(re=>re!==void 0)),Q=(ae.data?.data??[]).slice().filter(re=>!ie.has(re.path)).sort((re,_e)=>re.path.localeCompare(_e.path)),ee=(K.data?.data??[]).slice().sort((re,_e)=>re.path.localeCompare(_e.path)),Z=R.state==="ready"?nxe({authoritative:R.chosen?.authoritative===!0,mutable:l&&b,canStore:R.chosen?.writeable===!0,...y===void 0?{}:{versionId:y}}):void 0,de=Y.settled&&(ae.isSuccess||ae.isError),le=Z!==void 0&&de,fe=le&&!A,he=C.useMemo(()=>{if(!le)return;const re=[...Y.reports.flatMap(_e=>_e.path?[_e.path]:[]),...(ae.data?.data??[]).flatMap(_e=>_e.path?[_e.path]:[])];if(Z==="storage"&&F&&R.state==="ready")return R.chosen?{route:Z,storage:F,workspace:R.chosen,environmentName:m,packageName:g,existing:re}:void 0;if(Z==="package")return{route:Z,existing:re,write:async(_e,Me)=>{await i.models.updateModelSource(m,g,_e,{source:Me})}}},[le,Z,F,R,m,g,i,Y.reports,ae.data]),me=I.data?.data?.description??"",se=H.data?.data??[],ve=(ue.find(re=>re.path===yRe)??ue.find(re=>vRe(re.path)))?.path,Le=!Y.settled,Ae=S?p.jsx(gRe,{environmentName:m,packageName:g,versions:w,...y!==void 0?{selectedVersionId:y}:{},onSelectVersion:$,...a?{onReplaceVersion:a}:{},onPackageDeleted:()=>u(`/${encodeURIComponent(m)}`),canManage:l}):null,Re=p.jsxs(Yn,{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}),Ae]});if(I.isError){const re=p.jsx(ja,{error:I.error,context:`${m} > ${g}`});return Ae?p.jsxs(O0,{maxWidth:!1,sx:{maxWidth:1024,mx:"auto",px:3,py:6},children:[p.jsx(Te,{sx:{mb:4},children:Re}),re]}):re}return p.jsxs(O0,{maxWidth:!1,sx:{maxWidth:1024,mx:"auto",px:3,py:6},children:[p.jsxs(Te,{sx:{mb:4},children:[Re,me&&p.jsx(wt,{variant:"body2",color:"text.secondary",children:me})]}),p.jsx(F$e,{warnings:I.data?.data?.warnings}),x.isError&&p.jsx(Te,{sx:{mb:4},children:p.jsx(lo,{severity:"warning",action:p.jsx(Vn,{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(Bo,{text:"Loading package..."}),he&&p.jsx(B$e,{open:P,layout:"linear",environmentName:m,packageName:g,...y!==void 0?{versionId:y}:{},models:Q.map(re=>re.path).filter(re=>typeof re=="string"&&re.endsWith(".malloy")&&!ie.has(re)),modelsLoading:ae.isPending,...ae.isError?{modelsError:ae.error}:{},onRetryModels:()=>void ae.refetch(),target:he,...r?{onEvent:r}:{},onClose:()=>D(!1),onCreated:re=>{D(!1),fxe(d,m,g),d.invalidateQueries({queryKey:["models"]}),k({path:re.path,layout:re.layout,slug:re.slug,mode:"edit"})}}),!Le&&p.jsxs(p.Fragment,{children:[Y.isError&&p.jsx(Te,{sx:{mb:4},children:p.jsx(lo,{severity:"warning",action:p.jsx(Vn,{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."})}),(G.length>0||le)&&p.jsxs(Ns,{title:"Reports",count:G.length,...fe?{action:p.jsx(Qy,{label:"Report",onClick:()=>D(!0)})}:{},children:[G.length===0&&p.jsx(FC,{label:"No reports yet",...fe?{action:{label:"Add report",onClick:()=>D(!0)}}:{}}),G.map(re=>p.jsx(wp,{type:re.layout==="grid"?"dashboard":"report",label:re.label,rightLabel:re.layout,...re.secondary===void 0?{}:{description:re.secondary},onClick:_e=>re.path.endsWith(".malloynb")?u(`/${m}/${g}/${re.path}`,_e):k({path:re.path,layout:re.layout,slug:re.slug,mode:"view"},_e)},re.path))]}),b&&L.length>0&&p.jsx(Ns,{title:"Drafts",count:L.length,children:L.map(({locator:re,where:_e})=>p.jsx(wp,{type:re.type==="grid"?"dashboard":"report",label:B(re),rightLabel:_e,onClick:Me=>k({path:B(re),layout:re.type,slug:D1(B(re))??"",mode:"edit"},Me),trailingAction:p.jsx(Br,{title:"Delete this draft",children:p.jsx(ro,{size:"small","aria-label":`Delete draft ${B(re)}`,onClick:Me=>{Me.stopPropagation(),F?.deleteDocument(re).then(N)},children:p.jsx(SF,{fontSize:"small"})})})},`${re.workspace}:${re.path}`))}),oe.length>0&&p.jsx(Ns,{title:"Apps",count:oe.length,children:oe.map(re=>{const _e=!!re.title&&re.title!==re.path,Me=`${r6(s)}${re.resource}`;return p.jsx(wp,{type:"dataApp",label:_e?re.title:re.path,rightLabel:_e?re.path:void 0,onClick:Ge=>{e?e(`/${m}/${g}/data-apps/${re.path}`,Ge):Ge&&(Ge.metaKey||Ge.ctrlKey)?window.open(Me,"_blank"):window.location.href=Me},trailingAction:p.jsx(Br,{title:"Open standalone in new tab",children:p.jsx(ro,{size:"small",href:Me,target:"_blank",rel:"noopener noreferrer","aria-label":"Open standalone in new tab",onClick:Ge=>Ge.stopPropagation(),sx:{color:"text.secondary"},children:p.jsx(n6,{fontSize:"small"})})})},re.path)})}),p.jsxs(Ns,{title:"Models",count:Q.length,children:[Q.map(re=>p.jsx(wp,{type:"model",label:re.path,onClick:_e=>u(`/${m}/${g}/${re.path}`,_e)},re.path)),Q.length===0&&p.jsx(FC,{label:"No models"})]}),se.length>0&&p.jsx(Ns,{title:"Agents",count:se.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:se.map(re=>p.jsx(bRe,{agent:re},re.name))}),p.jsxs(Ns,{title:"Data",count:ee.length,children:[ee.map(re=>p.jsx(wp,{type:"data",label:re.path,rightLabel:re.info?lB(re.info.rowCount):"Unreadable",onClick:()=>O(re)},re.path)),ee.length===0&&p.jsx(FC,{label:"No data files"})]}),p.jsx(kSe,{resourceUri:n,versioned:!b}),ve&&p.jsx(Te,{sx:{mt:6},children:p.jsx(_$e,{resourceUri:I1({environmentName:m,packageName:g,versionId:y}),path:ve,onLinkNavigate:u})})]}),p.jsx(sRe,{database:T,onClose:()=>O(null)})]})}function wp({type:e,label:t,description:n,rightLabel:r,onClick:o,trailingAction:a}){return p.jsx(L1,{icon:p.jsx(sB,{type:e}),tint:iB[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 bRe({agent:e}){return p.jsxs(p.Fragment,{children:[p.jsx(wp,{type:"agent",label:e.name??"",...e.description?{description:e.description}:{},...e.model&&e.model!=="inherit"?{rightLabel:e.model}:{}}),(e.schedules??[]).map(t=>{const n=lT(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 xRe(e){const t=e.map(r=>({path:r.path??"",layout:Z2(r),slug:D1(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 FC({label:e,action:t}){return p.jsxs(Yn,{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(Vn,{size:"small",onClick:t.onClick,children:t.label})]})}const iL=/^publisher:document:(dashboard|notebook):(.+)$/;function wRe(e,t){const n=[];for(let r=0;r<e.length;r++){const o=e.key(r);o!==null&&iL.test(o)&&n.push(o)}for(const r of n){const[,o,a]=iL.exec(r),i=e.getItem(r);i!==null&&t(a,L_(o),i)&&e.removeItem(r)}}const _C={name:"Local",description:"Stored in this browser only",writeable:!0},j$="publisher:report:",gd=e=>`${j$}${e}`;function yg(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 BC=(e,t)=>localStorage.setItem(gd(e),JSON.stringify(t));class SRe{migrated=!1;migrate(){this.migrated||(this.migrated=!0,wRe(localStorage,(t,n,r)=>yg(gd(t))!==void 0?!1:(BC(t,{type:n,content:r}),!0)))}async listWorkspaces(t){return[_C]}async listDocuments(t,n){if(t.name!==_C.name)return[];this.migrate();const r=[];for(let o=0;o<localStorage.length;o++){const a=localStorage.key(o);if(a===null||!a.startsWith(j$))continue;const i=yg(a);i&&(n===void 0||i.type===n)&&r.push({workspace:_C.name,type:i.type,path:a.slice(j$.length)})}return r}async getDocument(t){this.migrate();const n=yg(gd(t.path));if(n===void 0)throw UC(t);return n.content}async getDocumentType(t){this.migrate();const n=yg(gd(t.path));if(n===void 0)throw UC(t);return n.type}async saveDocument(t,n){this.migrate(),BC(t.path,{type:t.type,content:n})}async deleteDocument(t){if(this.migrate(),yg(gd(t.path))===void 0)throw UC(t);localStorage.removeItem(gd(t.path))}async moveDocument(t,n){const r=await this.getDocument(t);BC(n.path,{type:n.type,content:r}),n.path!==t.path&&localStorage.removeItem(gd(t.path))}}function UC(e){return new M_(`No report at ${e.workspace}/${e.path}`)}async function CRe(e,t,n,r){const o=E_(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(O_(i))return;throw i}return(await e.listDocuments(o)).find(i=>i.path===a)?.type}function QTe(e,t,n,r=!0){const o=I_()?.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 CRe(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 kRe(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 $Re(e){return e.type==="code"}function RRe(e){return(e.text??"").split(`
|
|
510
|
+
`);ST(k,"typescript",$).then(T=>{i(T)})}},[t,$]),p.jsxs(Te,{children:[a&&p.jsx(Te,{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(Te,{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(zp,{"aria-label":"Expand results",onClick:()=>l(!0),children:p.jsx(Kp,{})})]}),p.jsxs(x4,{sx:{position:"relative"},children:[r&&!d&&p.jsxs(Te,{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(Vn,{variant:"contained",startIcon:p.jsx(M$e,{}),onClick:()=>u(!0),children:"Run Query"})]}),w&&p.jsx(X2,{state:S,context:e,maxHeight:Nle,maxResultSize:o})]}),p.jsx(nB,{open:s,onClose:()=>l(!1),result:b?.data?.result||"",renderLogs:b?.data?.renderLogs,title:`Query: ${e}`})]})}function P$e(e){return e!=null}function j$e(e,t){const n=[],r=[];for(const a of e){if(a.name===void 0||P$e(t.get(a.name)))continue;if(a.default==null){n.push(a.name);continue}const i=P1(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 A$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 kn.useEffect(()=>{o&&o(t)},[t,o]),p.jsx(b4,{children:p.jsxs(C9,{spacing:2,component:"section",children:[p.jsx(I$e,{sourceAndPath:e[t],existingQuery:n,onChange:l=>{r&&r(l)},resourceUri:a,givens:i,gate:s}),p.jsx(g5,{height:"5px"})]})})}function IC(){return{query:void 0,malloyQuery:void 0,malloyResult:void 0}}function N$e({sourceAndPath:e,onChange:t,existingQuery:n,explorerComponents:r,QueryBuilder:o,resourceUri:a,givens:i,gate:s}){const[l,d]=kn.useState(n||IC()),[u,m]=kn.useState(void 0);kn.useEffect(()=>{n&&d(n)},[n]);const[g,y]=kn.useState([]),{MalloyExplorerProvider:x,QueryPanel:w,ResizableCollapsiblePanel:S,ResultPanel:b,SourcePanel:$}=r;kn.useEffect(()=>{t&&t(l)},[t,l]);const{environmentName:k,packageName:T,versionId:O}=Xr(a),{apiClients:P}=tr(),D=kn.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 N=D.current;m(B=>B?{...B,executionState:"finished",response:{result:z,...N?.defaultsNote?{messages:[{severity:"INFO",title:N.defaultsNote}]}:{}}}:void 0)}},onError:R=>{console.error("Query execution error:",R);const z=R?.data?.message??R?.message??"The query could not be run.",N=[{severity:"ERROR",title:z}],B=D.current?.missing??[];(R?.status===403||/Access denied for source/i.test(z))&&B.length>0&&N.push({severity:"WARN",title:A$e(B)}),m(I=>I?{...I,executionState:"finished",response:{messages:N}}:void 0)}}),[F,L]=kn.useState(e.sourceInfo.name);kn.useEffect(()=>{F!==e.sourceInfo.name&&(L(e.sourceInfo.name),d(IC()),m(void 0))},[e,F]);const _=kn.useCallback(R=>{d({...l,malloyQuery:R,malloyResult:void 0})},[l]);return F!==e.sourceInfo.name?p.jsx("div",{children:"Loading..."}):p.jsx(w4,{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(IC())})}),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 I$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([wo(()=>import("./index-DYHeNKEh.js"),__vite__mapDeps([5,0,1,2,6])),H0e()]).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(Wne,{children:p.jsx(w4,{children:p.jsx(g5,{sx:{alignItems:"center",justifyContent:"center",height:"200px",color:"text.secondary"},children:"Loading explorer..."})})}):p.jsx(N$e,{...e,explorerComponents:t,QueryBuilder:r,resourceUri:e.resourceUri})}function rB(e,t=!0){const{modelPath:n,environmentName:r,packageName:o,versionId:a}=Xr(e),{apiClients:i}=tr();return co({queryKey:["package",r,o,n,a],queryFn:async()=>(await i.models.getModel(r,o,n,a)).data,enabled:t})}function oB({data:e,onChange:t,existingQuery:n,initialSelectedSourceIndex:r=0,onSourceChange:o,resourceUri:a,givens:i,onGivensChange:s,startingGivens:l}){const[d,u]=kn.useState(r);kn.useEffect(()=>{u(r)},[r]);const{data:m,isError:g,isLoading:y,error:x}=rB(a,!e),{environmentName:w,packageName:S,modelPath:b,versionId:$}=Xr(a),k=e||m,T=kn.useMemo(()=>k?.givens??[],[k]),O=b2({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(()=>Jd(O.applied,O.declaredTypes),[O.applied,O.declaredTypes]),D=C.useMemo(()=>j$e(T,O.applied),[T,O.applied]);if(y&&!e)return p.jsx(Bo,{text:"Fetching Model..."});if(g&&!e)return console.log("error",x),p.jsx(ja,{error:x,context:`ModelExplorer > ${b}`});if(!k)return p.jsx(Bo,{text:wu.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(Hne,{variant:"outlined",children:[p.jsx(Vne,{children:p.jsx(Yn,{sx:{flexDirection:"row"},children:p.jsx(mwe,{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(j1,{...O.panel}),p.jsx(b4,{children:p.jsxs(Yn,{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(Te,{height:"5px"})]})})]})}function aB({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(zx,{open:e,onClose:t,fullScreen:!0,children:[p.jsxs(_x,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[o,p.jsx(ro,{onClick:t,sx:{color:"text.secondary"},children:p.jsx(xh,{})})]}),p.jsx(Fx,{children:a?p.jsx(oB,{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 L$e({onChange:e,resourceUri:t,runOnDemand:n=!1,maxResultSize:r=0,givens:o,onGivensChange:a}){const{modelPath:i}=Xr(t),{data:s,isError:l,isLoading:d,error:u}=rB(t),[m,g]=kn.useState(!1),[y,x]=kn.useState(),[w,S]=kn.useState(0),[b,$]=C.useState(""),[k,T]=kn.useState({}),O=o??k,P=a??(R=>T(R)),D=s?.modelDef,A=kn.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(Bo,{text:"Fetching Model..."});if(l)return console.log("error",u),p.jsx(ja,{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(Te,{sx:{position:"relative",maxWidth:"1200px",margin:"0 auto",paddingTop:"24px"},children:[Array.isArray(s?.sourceInfos)&&s.sourceInfos.length>0&&p.jsxs(Yn,{spacing:2,component:"section",children:[p.jsxs(Te,{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(ro,{size:"small","aria-label":"Copy link",onClick:_,sx:{color:"text.secondary"},children:p.jsx(uT,{fontSize:"small"})})})]}),p.jsx(oB,{data:s,onChange:F,onSourceChange:L,existingQuery:y,initialSelectedSourceIndex:w,resourceUri:t,givens:O,onGivensChange:P}),p.jsx(zp,{"aria-label":"Expand results",sx:{position:"absolute",top:"90px",right:"4px",zIndex:2},onClick:()=>g(!0),children:p.jsx(Kp,{})})]}),s?.queries?.length>0&&p.jsxs(Yn,{spacing:2,component:"section",sx:{marginTop:"24px"},children:[p.jsx(Te,{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(O$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(Te,{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(aB,{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(hh,{open:b!=="",autoHideDuration:6e3,onClose:()=>$(""),message:b})]})}function z$e(){const[e,t]=C.useState("");return p.jsxs(p.Fragment,{children:[p.jsx(Br,{title:"Copy link",children:p.jsx(ro,{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(uT,{fontSize:"small"})})}),p.jsx(hh,{open:e!=="",autoHideDuration:6e3,onClose:()=>t(""),message:e})]})}function GTe(e){const{modelPage:t,isLoadingStatus:n}=tr();if(n)return p.jsx(Bo,{text:"Fetching Model..."});if(t!=="viewer")return p.jsx(L$e,{...e});const{onChange:r,runOnDemand:o,headerActions:a,...i}=e;return p.jsx(E$e,{...i,headerActions:a??p.jsx(z$e,{})})}function F$e({warnings:e}){const[t,n]=C.useState(!1),r=(e??[]).filter(a=>a.severity==="error"),o=(e??[]).filter(a=>a.severity!=="error");return r.length===0&&o.length===0?null:p.jsxs(Yn,{sx:{gap:1,mb:4},children:[r.length>0&&p.jsxs(lo,{severity:"warning",children:[p.jsx(vY,{children:r.length===1?"1 problem in this package":`${r.length} problems in this package`}),p.jsx(rL,{findings:r})]}),o.length>0&&p.jsxs(Te,{children:[p.jsxs(Vn,{size:"small","aria-expanded":t,onClick:()=>n(a=>!a),sx:{px:.5,color:"text.secondary"},children:[t?"Hide":"Show"," ",o.length," ",o.length===1?"note":"notes"]}),t&&p.jsx(Te,{sx:{pl:.5,pt:.5},children:p.jsx(rL,{findings:o})})]})]})}function rL({findings:e}){return p.jsx(Yn,{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(Te,{component:"span",sx:{fontFamily:Fo,fontSize:"0.85em",mr:1},children:t.model}),t.message]},`${t.model??""}:${t.code??""}:${n}`))})}function _$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=Xr(e),{apiClients:x}=tr(),w=y.environmentName??"",S=y.packageName??"",b=y.versionId,$=!!y.environmentName&&!!y.packageName,{data:k,isSuccess:T,isError:O,error:P}=co({...uxe(x,{environmentName:w,packageName:S,path:t,versionId:b},u),enabled:$&&t!==""}),D=k?.layout,A=ace({path:t,layout:D},l),F=`${e}|${t}`,L=C.useRef(void 0),_=C.useRef({key:F,at:Pd()});_.current.key!==F&&(_.current={key:F,at:Pd()}),C.useEffect(()=>{L.current!==F&&($?O?(L.current=F,A.emit({type:"report.load_failed",surface:"view",category:U0(P)})):k?.notebook?.format==="malloynb"?(L.current=F,A.emit({type:"report.load_failed",surface:"view",category:"unsupported"})):T&&k&&(L.current=F,A.emit({type:"report.opened",surface:"view",from:"package",tiles:k.tiles?.length??0,durationMs:Pd()-_.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((B,I)=>{const H=o?.(B,I);H&&A.emit({type:"report.drill",to:"report",outcome:H})},[o,A]),z=o?R:void 0;if(!$)return p.jsxs(lo,{severity:"error",children:["A report resource URI must name an environment and a package. Received: ",e]});if(O)return p.jsx(ja,{context:`${w} > ${S} > ${t}`,error:P});if(!T||!k)return p.jsx(Bo,{text:wu.opening("report")});if(k.notebook?.format==="malloynb")return p.jsxs(lo,{severity:"info",children:[t," is a .malloynb notebook, which Report does not run: render it with Notebook."]});const N=p.jsx(t6,{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($F.Provider,{value:A,children:N})}function B$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?L_(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),[N,B]=C.useState(""),[I,H]=C.useState(!1),[Y,ae]=C.useState(!1),[K,oe]=C.useState(!1),[ue,G]=C.useState(void 0),ie=u!=null,{choices:Q,isLoading:ee,isSuccess:Z,failed:de,retry:le,canRetry:fe}=lxe({environmentName:a,packageName:i,...s!==void 0?{versionId:s}:{},models:l,enabled:e&&l.length>0}),he=C.useMemo(()=>Q.get(D)??[],[Q,D]),me=C.useMemo(()=>new Map([...Q.entries()].flatMap(([st,Dt])=>Dt.map(nn=>[LC(st,nn.source,nn.view),{model:st,source:nn.source,view:nn.view}]))),[Q]),se=C.useMemo(()=>{const st=Q.size>1;return[...Q.entries()].flatMap(([Dt,nn])=>{const Bt=new Map;for(const pn of nn)Bt.set(pn.source,[...Bt.get(pn.source)??[],pn]);return[...Bt.entries()].map(([pn,$n])=>({key:`${Dt}::${pn}`,label:pn,ariaLabel:`${pn} in ${Dt}`,...st||$n[0]?.sourceDescription?{detail:[st?Dt:void 0,$n[0]?.sourceDescription].filter(Boolean).join(" · ")}:{},entries:$n.map(qt=>({key:LC(Dt,qt.source,qt.view),name:qt.view,title:qt.description??vC(qt.view),...qt.chart?{chart:qt.chart}:{}}))}))})},[Q]),ve=st=>{const Dt=me.get(st);Dt&&(A(Dt.model),L(`${Dt.source}::${Dt.view}`))},Le=he.find(st=>`${st.source}::${st.view}`===F),Ae=Le?LC(D,Le.source,Le.view):void 0,Re=U$e(Le,250);C.useEffect(()=>{e&&T(b)},[e,b]),C.useEffect(()=>{if(!e)return;const st=[...Q.keys()];D===""&&st.length>0&&A(st[0])},[e,Q,D]),C.useEffect(()=>{!e||he.length===0||F!==""||L(`${he[0].source}::${he[0].view}`)},[e,he,F]),C.useEffect(()=>{!e||I||Le===void 0||B(vC(Le.view))},[e,I,Le]),C.useEffect(()=>{e||(A(""),L(""),R(""),B(""),H(!1),P(void 0),ae(!1),G(void 0))},[e]);const re=C.useMemo(()=>{if(N.trim()!=="")for(let st=1;st<=nT;st++){const Dt=A_(N,st);if(!g.existing?.includes(Dt))return Dt}},[N,g]),_e=O?.trim(),Me=_e===void 0||_e===""?void 0:_e.endsWith(".malloy")?_e:`${_e}.malloy`,Ge=Me??re,Je=Me===void 0?void 0:D_(Me)??(g.existing?.includes(Me)?`${Me} already exists; choose another location.`:void 0),St=(Le===void 0?void 0:eT({title:N,modelPath:D,source:Le.source,view:Le.view}))??(N.trim()!==""&&Ge===void 0?"No free file name for this title; choose another.":void 0),Ut=St!==void 0&&(Y||N.trim()!==""),at=d||ee,{theme:tt}=Vr(),pt=tt.ui,ze=Zd(tt.cardBorder),be=Q.size===0&&(ie||de.length>0),Ve=at?"Loading the model":be?"Couldn't read the model to start from":Q.size===0?"Nothing in the model to start from yet":Le===void 0?"Pick what to start from":void 0,Oe="report",$t=K?`Creating ${Oe}…`:`Create ${Oe}`,Rt=F!==""&&Le===void 0&&he.length>0,vt=async()=>{if(!(Ve!==void 0||Le===void 0||K)){if(St!==void 0||Je!==void 0){ae(!0);return}oe(!0),G(void 0);try{const st=await rxe({layout:k,...Me!==void 0?{path:Me}:{},document:{title:N,modelPath:D,source:Le.source,view:Le.view},target:g,...S?{onEvent:S}:{}});w(st)}catch(st){const Dt=st.response?.data?.message;G(Dt??(st instanceof Error?st.message:String(st)))}finally{oe(!1)}}},it=st=>p.jsx(Vn,{color:"inherit",size:"small",onClick:st,children:"Retry"});return p.jsx(Oo,{className:`${Sl.dialog} ${Sl.newReportDialog}`,maxWidth:"md",initialFocus:z,open:e,onClose:K?()=>{}:x,title:`New ${Oe}`,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(Vn,{onClick:x,disabled:K,children:"Cancel"}),p.jsx(Br,{title:K?"":Ve??"",children:p.jsx("span",{children:p.jsx(Vn,{variant:"contained",disabled:K||Ve!==void 0,"aria-label":!K&&Ve!==void 0?`${$t}: ${Ve}`:$t,onClick:()=>void vt(),children:$t})})})]}),children:p.jsxs(Yn,{sx:{gap:1.5},children:[ie?p.jsx(lo,{severity:"error",action:m&&L4(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(lo,{severity:"info",children:["This package has no models yet. Add a .malloy file that declares a source with a view, then create a ",Oe," from it."]}):de.length>0?p.jsxs(lo,{severity:"warning",action:fe?it(le):void 0,children:["Couldn't read ",de.join(", "),", so nothing from"," ",de.length===1?"it":"them"," is listed."]}):Z&&Q.size===0&&p.jsxs(lo,{severity:"info",children:["A ",Oe," 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(Te,{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(Te,{sx:{display:"flex",flexDirection:"column",minHeight:0,borderRight:{md:`1px solid ${ze}`},maxHeight:{xs:280,md:"none"}},children:p.jsx(Ele,{groups:se,query:_,onQuery:R,picked:Ae,onPick:ve,onTake:st=>{ve(st)},searchRef:z,disabled:K,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(Te,{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(Te,{children:[p.jsx(oL,{children:"Layout"}),p.jsx(Te,{role:"radiogroup","aria-label":"Layout",sx:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:1},children:["linear","grid"].map(st=>p.jsx(V$e,{layout:st,checked:k===st,disabled:K,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(Te,{children:[p.jsx(oL,{children:"First query"}),p.jsx(Te,{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&&Re?p.jsx(Te,{sx:{flex:1,minWidth:0,px:2,pt:1.5},children:p.jsx(B_,{environmentName:a,packageName:i,...s!==void 0?{versionId:s}:{},modelPath:D,tile:`${Re.source} -> ${Re.view}`,label:N.trim()||vC(Re.view),borderless:!0,givens:q$e,declaredTypes:H$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(Ri,{size:"small",label:"Title",value:N,disabled:K,onChange:st=>{H(!0),B(st.target.value)},InputLabelProps:{shrink:!0},inputProps:{"aria-label":"Report title"},error:Ut,helperText:Ut?St:g.route==="package"?"Names the file too, unless you type a location.":y??`Saved as a new ${Oe} in the host's store, and opened in the builder.`}),p.jsx(Ri,{size:"small",label:"Location",value:O??re??"",placeholder:"report.malloy",disabled:K,onChange:st=>P(st.target.value),InputLabelProps:{shrink:!0},inputProps:{"aria-label":"Location"},error:Je!==void 0,helperText:Je??(Ge?`Written as ${Ge} in the package, and opened in the builder.`:"A path in the package; the package root by default.")}),ue&&p.jsx(lo,{severity:"error",children:ue})]})]})]})})}function U$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 LC=(e,t,n)=>`${e}::${t}::${n}`,q$e=new Map,H$e=new Map;function oL({children:e}){const t=Vr().theme.ui;return p.jsx(wt,{component:"div",sx:{...t.type.label,color:"text.secondary",mb:.75},children:e})}function V$e({layout:e,checked:t,disabled:n,onPick:r}){const{theme:o}=Vr(),a=o.ui,i=Zd(o.cardBorder),s=t?o.accent:"currentColor";return p.jsxs(is,{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(Te,{children:[p.jsx(Te,{sx:{...a.type.control,fontWeight:t?a.type.label.fontWeight:500,color:t?o.accent:"text.primary"},children:e==="linear"?"Linear":"Grid"}),p.jsx(Te,{sx:{...a.type.caption,color:"text.secondary"},children:e==="linear"?"Read top to bottom":"Tiles side by side"})]})]})}const W$e=Jt(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"})),Y$e=Jt(p.jsx("path",{d:"M15 4v2h3v12h-3v2h5V4zM4 20h5v-2H6V6h3V4H4z"})),G$e=Jt(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"})),K$e=Jt(p.jsx("path",{d:"M20 10V8h-4V4h-2v4h-4V4H8v4H4v2h4v4H4v2h4v4h2v-4h4v4h2v-4h4v-2h-4v-4zm-6 4h-4v-4h4z"})),iB={dashboard:hr.blue,report:hr.violet,model:hr.cyan,dataApp:hr.pink,data:hr.lime,materialization:hr.amber,agent:hr.red};function sB({type:e,size:t=18,sx:n,...r}){return p.jsx(B0,{...r,viewBox:"0 0 24 24",sx:{width:t,height:t,fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",...n},children:Q$e[e]()})}const Q$e={report:X$e,model:Z$e,data:J$e,materialization:eRe,dataApp:rRe,dashboard:tRe,agent:nRe};function X$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 Z$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 J$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 eRe(){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 tRe(){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 nRe(){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 rRe(){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 lB(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 oRe=12;function aRe(e){const t=e?.trim().toLowerCase()??"";if(t.startsWith("array")||t.endsWith("[]"))return Y$e;if(t.startsWith("record")||t.startsWith("struct"))return G$e;switch(t.split(/[\s(<]/)[0]){case"string":return W$e;case"number":return K$e;case"date":return N6;case"timestamp":case"timestamptz":return L6;case"boolean":return z6;default:return F6}}function iRe({column:e}){const t=aRe(e.type);return p.jsxs(Te,{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(Te,{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 sRe({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:lB(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(Yn,{direction:"row",alignItems:"center",spacing:1.5,sx:{minWidth:0},children:[p.jsx(Te,{"aria-hidden":!0,sx:{width:32,height:32,borderRadius:1,bgcolor:iB.data,color:"#FFFFFF",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:p.jsx(sB,{type:"data",size:18})}),p.jsxs(Te,{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(lo,{severity:"error",variant:"outlined",children:r.error}),r&&!r.error&&p.jsxs(Te,{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(Yn,{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>oRe&&p.jsx(Lx,{value:a,onChange:$=>i($.target.value),placeholder:"Filter columns",inputProps:{"aria-label":"Filter columns"},startAdornment:p.jsx(PR,{position:"start",children:p.jsx(Kp,{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(Te,{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(Te,{component:"ul","aria-labelledby":d,sx:{listStyle:"none",m:0,p:0},children:b.map(($,k)=>p.jsx(iRe,{column:$},`${$.name}-${k}`))})})]})]})}const cB=(e,t,n)=>["packageVersions",e,t,n];async function uB(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 lRe(e,t,n={}){const{apiClients:r,server:o}=tr(),a=(n.enabled??!0)&&e!==""&&t!=="",i=zd({queryKey:cB(e,t,o),queryFn:()=>uB(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 cRe(e,t){const{apiClients:n,server:r}=tr(),o=Tl();return C.useCallback(()=>o.fetchQuery({queryKey:cB(e,t,r),queryFn:()=>uB(n,e,t),staleTime:0,retry:!1}),[o,n,r,e,t])}function uRe(e,t){const n=Tl();return C.useCallback(()=>n.invalidateQueries({predicate:r=>r.queryKey[1]===e&&r.queryKey[2]===t}),[n,e,t])}const dRe=Jt(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"})),fRe=Jt(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"})),pRe=Jt(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"})),hRe=Jt(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"})),gg=e=>{const t=e?.response?.data?.message;return typeof t=="string"&&t!==""?t:e instanceof Error?e.message:"Unknown error"},mRe=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})},Ep=e=>e.archiveStatus==="archive",zC="Tables built for this version alone (under scope: version) are dropped.";function aL(e,t){const n=!Ep(e)&&t.filter(o=>!Ep(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 gRe({environmentName:e,packageName:t,versions:n,selectedVersionId:r,onSelectVersion:o,onReplaceVersion:a,onPackageDeleted:i,canManage:s}){const{apiClients:l}=tr(),d=Tl(),u=uRe(e,t),m=cRe(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,N=()=>Promise.all([u(),d.invalidateQueries({queryKey:["packages",e]})]),B=async(fe,he)=>{const me=he??await m().catch(()=>{});if(me===void 0)return;const se=me.find(Le=>Le.latest)?.id,ve=se??me.find(Le=>Le.id!==fe&&!Ep(Le))?.id;ve!==void 0&&(a?a(ve===se?void 0:ve):o(ve))},I=a0({mutationFn:fe=>l.versions.setPackageLatestVersion(e,t,{version:fe}),onSuccess:async()=>{b(null),await N()},onError:()=>void N()}),H=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 B(he),await N()},onError:(fe,{id:he,archiveStatus:me})=>{me==="unarchive"&&D(`Couldn't unarchive v${he}: ${gg(fe)}`),N()}}),Y=H.isPending?H.variables?.id:void 0,ae=a0({mutationFn:({id:fe})=>l.versions.deletePackageVersion(e,t,fe),onSuccess:async(fe,{id:he,read:me})=>{O(null);const se=await m().catch(()=>{})??me.filter(ve=>ve.id!==he);if(se.length===0){await d.invalidateQueries({queryKey:["packages",e]}),i?.();return}he===z&&await B(he,se),await N()},onError:()=>void N()}),K=()=>w(null),oe=x?aL(x.version,n):{},ue=x!==null&&!Ep(x.version)&&x.version.latest&&oe.archive!==void 0&&oe.delete!==void 0,G=T!==null&&T.versions===void 0,ie=T?.versions!==void 0&&T.versions.length<=1,Q=T?.versions!==void 0?aL(T.version,T.versions).delete:void 0,ee=async fe=>{K(),y(null),ae.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: ${gg(ve)}`);return}const se=me.find(ve=>ve.id===fe.id);if(se===void 0){he(null),D(`v${fe.id} is no longer a version of ${t}.`),N();return}he({version:se,versions:me})},Z=(fe,he)=>{!s||Y===fe.id||w({version:fe,anchor:_.current.get(fe.id)??he})},de=(fe,he)=>{const me=fe.key==="ArrowRight"||fe.key==="ContextMenu"||fe.key==="F10"&&fe.shiftKey;!s||!me||(fe.preventDefault(),fe.stopPropagation(),Z(he,fe.currentTarget))},le=x&&p.jsxs(ea,{disabled:oe.delete!==void 0,onClick:()=>void ee(x.version),children:[p.jsx(ml,{children:p.jsx(SF,{fontSize:"small"})}),p.jsx(Ci,{primary:"Delete version",secondary:oe.delete})]},"delete");return p.jsxs(p.Fragment,{children:[p.jsx(Vn,{size:"small",variant:"outlined",endIcon:p.jsx(I6,{}),"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=Ep(fe),se=[me?"Archived":void 0,mRe(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=>de(ve,fe),onClick:ve=>{if(me){Z(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?as(ve.palette.primary.main,.04):void 0,cursor:he||me&&!s?"default":"pointer"}),children:[p.jsx(Ci,{primary:fe.id,secondary:se,sx:{opacity:me?.6:1},slotProps:{primary:{sx:{fontWeight:he?600:400}}}}),fe.latest&&p.jsx(TR,{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(ro,{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(fRe,{fontSize:"small"})})})})]},fe.id)})}),p.jsx(uc,{anchorEl:x?.anchor??null,open:x!==null,onClose:K,slotProps:{list:{"aria-label":x?`Actions for version ${x.version.id}`:void 0,disabledItemsFocusable:!0,autoFocus:ue}},children:x&&Ep(x.version)?[p.jsxs(ea,{onClick:()=>{const{id:fe}=x.version;K(),H.mutate({id:fe,archiveStatus:"unarchive"})},children:[p.jsx(ml,{children:p.jsx(hRe,{fontSize:"small"})}),p.jsx(Ci,{primary:"Unarchive"})]},"unarchive"),p.jsx(wl,{},"divider"),le]:x&&[p.jsxs(ea,{disabled:x.version.latest,onClick:()=>{b(x.version),I.reset(),K(),y(null)},children:[p.jsx(ml,{children:p.jsx(pRe,{fontSize:"small"})}),p.jsx(Ci,{primary:"Pin as latest",secondary:x.version.latest?"Already the latest version":void 0})]},"pin-latest"),p.jsxs(ea,{disabled:oe.archive!==void 0,onClick:()=>{k(x.version),H.reset(),K(),y(null)},children:[p.jsx(ml,{children:p.jsx(dRe,{fontSize:"small"})}),p.jsx(Ci,{primary:"Archive",secondary:oe.archive})]},"archive"),p.jsx(wl,{},"divider"),le]}),p.jsx(Oo,{open:S!==null,onClose:()=>{I.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(Vn,{ref:A,disabled:I.isPending,onClick:()=>b(null),children:"Cancel"}),p.jsx(Vn,{variant:"contained",loading:I.isPending,onClick:()=>S&&I.mutate(S.id),children:"Pin as latest"})]}),children:p.jsxs(Yn,{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.`}),I.isError&&S&&p.jsx(lo,{severity:"error",role:"alert",children:`Couldn't pin v${S.id} as latest: ${gg(I.error)}`})]})}),p.jsx(Oo,{open:$!==null,onClose:()=>{H.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(Vn,{ref:F,disabled:H.isPending,onClick:()=>k(null),children:"Cancel"}),p.jsx(Vn,{variant:"contained",loading:H.isPending,onClick:()=>$&&H.mutate({id:$.id,archiveStatus:"archive"}),children:"Archive"})]}),children:p.jsxs(Yn,{spacing:1.5,children:[p.jsx(wt,{variant:"body2",color:"text.secondary",children:`${zC} Its scheduled builds stop, and once unarchived it serves live until it is built again.`}),H.isError&&$&&p.jsx(lo,{severity:"error",role:"alert",children:`Couldn't archive v${$.id}: ${gg(H.error)}`})]})}),p.jsx(Oo,{open:T!==null,onClose:()=>{ae.isPending||O(null)},title:T?`Delete v${T.version.id}`:"",initialFocus:L,actions:p.jsxs(p.Fragment,{children:[p.jsx(Vn,{ref:L,disabled:ae.isPending,onClick:()=>O(null),children:"Cancel"}),p.jsx(Vn,{variant:"contained",color:"error",loading:ae.isPending,disabled:G||Q!==void 0,onClick:()=>T?.versions&&ae.mutate({id:T.version.id,read:T.versions}),children:ie?"Delete package":"Delete version"})]}),children:p.jsxs(Yn,{spacing:1.5,children:[G&&T&&p.jsx(wt,{variant:"body2",children:`Checking ${t}'s versions before deleting v${T.version.id}…`}),T&&!G&&p.jsx(wt,{variant:"body2",children:ie?`v${T.version.id} is the only version of ${t}, so deleting it deletes the package. ${zC} This cannot be undone.`:`v${T.version.id} stops being served and its files are removed. ${zC} Links that name it stop working, and this cannot be undone.`}),Q!==void 0&&T&&p.jsx(lo,{severity:"warning",role:"alert",children:`v${T.version.id} can't be deleted now: ${Q}.`}),ae.isError&&T&&p.jsx(lo,{severity:"error",role:"alert",children:`Couldn't delete v${T.version.id}: ${gg(ae.error)}`})]})}),p.jsx(hh,{open:P!==null,autoHideDuration:8e3,onClose:()=>D(null),anchorOrigin:{vertical:"bottom",horizontal:"center"},children:p.jsx(Te,{children:p.jsx(lo,{severity:"error",variant:"filled",onClose:()=>D(null),children:P})})})]})}const yRe="README.malloynb",vRe=e=>!!e&&!e.includes("/")&&D1(e)?.toLowerCase()==="readme";function KTe({onClickPackageFile:e,onOpenDocument:t,resourceUri:n,onEvent:r,onSelectVersion:o,onReplaceVersion:a}){const{apiClients:i,server:s,mutable:l}=tr(),d=Tl(),u=e??(re=>{window.location.href=re}),{environmentName:m,packageName:g,versionId:y}=Xr(n),x=lRe(m,g),{versions:w}=x,S=w.length>0,b=!S&&!x.isPending&&!x.isError,$=o??((re,_e)=>u(`/${encodeURIComponent(m)}/${encodeURIComponent(g)}/${encodeURIComponent(re)}`,_e)),k=t??((re,_e)=>{const Me=re.mode==="edit"?$0e(m,g,re.path):S_(m,g,re.path);_e?u(Me,_e):u(Me)}),[T,O]=C.useState(null),[P,D]=C.useState(!1),A=Cxe(),F=I_()?.documentStorage,[L,_]=C.useState([]),[R,z]=C.useState({state:F?"pending":"ready"}),N=C.useCallback(async()=>{if(!F)return;let re;try{re=await F.listWorkspaces(!1)}catch{z({state:"failed"});return}z({state:"ready",chosen:E_(re)});const _e=[],Me=wy(m,g,"");for(const Ge of re.filter(Je=>Je.writeable))for(const Je of await F.listDocuments(Ge))Je.path.startsWith(Me)&&_e.push({locator:Je,where:Ge.description});_(_e)},[F,m,g]);C.useEffect(()=>{N()},[N]);const B=re=>re.path.slice(wy(m,g,"").length),I=co({queryKey:["package",m,g,y],queryFn:()=>i.packages.getPackage(m,g,y,!1)}),H=co({queryKey:["package-agents",m,g,y],queryFn:()=>i.agents.listAgents(m,g,y)}),Y=C_(m,g,y),ae=co({queryKey:["models",m,g,y],queryFn:()=>i.models.listModels(m,g,y)}),K=co({queryKey:["databases",m,g,y],queryFn:()=>i.databases.listDatabases(m,g,y)}),oe=co({queryKey:["data-apps",m,g,y],queryFn:async()=>{try{return await i.dataApps.listDataApps(m,g,y)}catch(re){const _e=re?.response?.status;if(_e===404||_e===void 0)return{data:[]};throw re}}}).data?.data??[],ue=Y.reports.filter(re=>!!re.path),G=xRe(ue),ie=new Set(ue.map(re=>re.path).filter(re=>re!==void 0)),Q=(ae.data?.data??[]).slice().filter(re=>!ie.has(re.path)).sort((re,_e)=>re.path.localeCompare(_e.path)),ee=(K.data?.data??[]).slice().sort((re,_e)=>re.path.localeCompare(_e.path)),Z=R.state==="ready"?nxe({authoritative:R.chosen?.authoritative===!0,mutable:l&&b,canStore:R.chosen?.writeable===!0,...y===void 0?{}:{versionId:y}}):void 0,de=Y.settled&&(ae.isSuccess||ae.isError),le=Z!==void 0&&de,fe=le&&!A,he=C.useMemo(()=>{if(!le)return;const re=[...Y.reports.flatMap(_e=>_e.path?[_e.path]:[]),...(ae.data?.data??[]).flatMap(_e=>_e.path?[_e.path]:[])];if(Z==="storage"&&F&&R.state==="ready")return R.chosen?{route:Z,storage:F,workspace:R.chosen,environmentName:m,packageName:g,existing:re}:void 0;if(Z==="package")return{route:Z,existing:re,write:async(_e,Me)=>{await i.models.updateModelSource(m,g,_e,{source:Me})}}},[le,Z,F,R,m,g,i,Y.reports,ae.data]),me=I.data?.data?.description??"",se=H.data?.data??[],ve=(ue.find(re=>re.path===yRe)??ue.find(re=>vRe(re.path)))?.path,Le=!Y.settled,Ae=S?p.jsx(gRe,{environmentName:m,packageName:g,versions:w,...y!==void 0?{selectedVersionId:y}:{},onSelectVersion:$,...a?{onReplaceVersion:a}:{},onPackageDeleted:()=>u(`/${encodeURIComponent(m)}`),canManage:l}):null,Re=p.jsxs(Yn,{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}),Ae]});if(I.isError){const re=p.jsx(ja,{error:I.error,context:`${m} > ${g}`});return Ae?p.jsxs(O0,{maxWidth:!1,sx:{maxWidth:1024,mx:"auto",px:3,py:6},children:[p.jsx(Te,{sx:{mb:4},children:Re}),re]}):re}return p.jsxs(O0,{maxWidth:!1,sx:{maxWidth:1024,mx:"auto",px:3,py:6},children:[p.jsxs(Te,{sx:{mb:4},children:[Re,me&&p.jsx(wt,{variant:"body2",color:"text.secondary",children:me})]}),p.jsx(F$e,{warnings:I.data?.data?.warnings}),x.isError&&p.jsx(Te,{sx:{mb:4},children:p.jsx(lo,{severity:"warning",action:p.jsx(Vn,{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(Bo,{text:"Loading package..."}),he&&p.jsx(B$e,{open:P,layout:"linear",environmentName:m,packageName:g,...y!==void 0?{versionId:y}:{},models:Q.map(re=>re.path).filter(re=>typeof re=="string"&&re.endsWith(".malloy")&&!ie.has(re)),modelsLoading:ae.isPending,...ae.isError?{modelsError:ae.error}:{},onRetryModels:()=>void ae.refetch(),target:he,...r?{onEvent:r}:{},onClose:()=>D(!1),onCreated:re=>{D(!1),fxe(d,m,g),d.invalidateQueries({queryKey:["models"]}),k({path:re.path,layout:re.layout,slug:re.slug,mode:"edit"})}}),!Le&&p.jsxs(p.Fragment,{children:[Y.isError&&p.jsx(Te,{sx:{mb:4},children:p.jsx(lo,{severity:"warning",action:p.jsx(Vn,{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."})}),(G.length>0||le)&&p.jsxs(Ns,{title:"Reports",count:G.length,...fe?{action:p.jsx(Qy,{label:"Report",onClick:()=>D(!0)})}:{},children:[G.length===0&&p.jsx(FC,{label:"No reports yet",...fe?{action:{label:"Add report",onClick:()=>D(!0)}}:{}}),G.map(re=>p.jsx(wp,{type:re.layout==="grid"?"dashboard":"report",label:re.label,rightLabel:re.layout,...re.secondary===void 0?{}:{description:re.secondary},onClick:_e=>re.path.endsWith(".malloynb")?u(`/${m}/${g}/${re.path}`,_e):k({path:re.path,layout:re.layout,slug:re.slug,mode:"view"},_e)},re.path))]}),b&&L.length>0&&p.jsx(Ns,{title:"Drafts",count:L.length,children:L.map(({locator:re,where:_e})=>p.jsx(wp,{type:re.type==="grid"?"dashboard":"report",label:B(re),rightLabel:_e,onClick:Me=>k({path:B(re),layout:re.type,slug:D1(B(re))??"",mode:"edit"},Me),trailingAction:p.jsx(Br,{title:"Delete this draft",children:p.jsx(ro,{size:"small","aria-label":`Delete draft ${B(re)}`,onClick:Me=>{Me.stopPropagation(),F?.deleteDocument(re).then(N)},children:p.jsx(SF,{fontSize:"small"})})})},`${re.workspace}:${re.path}`))}),oe.length>0&&p.jsx(Ns,{title:"Apps",count:oe.length,children:oe.map(re=>{const _e=!!re.title&&re.title!==re.path,Me=`${r6(s)}${re.resource}`;return p.jsx(wp,{type:"dataApp",label:_e?re.title:re.path,rightLabel:_e?re.path:void 0,onClick:Ge=>{e?e(`/${m}/${g}/data-apps/${re.path}`,Ge):Ge&&(Ge.metaKey||Ge.ctrlKey)?window.open(Me,"_blank"):window.location.href=Me},trailingAction:p.jsx(Br,{title:"Open standalone in new tab",children:p.jsx(ro,{size:"small",href:Me,target:"_blank",rel:"noopener noreferrer","aria-label":"Open standalone in new tab",onClick:Ge=>Ge.stopPropagation(),sx:{color:"text.secondary"},children:p.jsx(n6,{fontSize:"small"})})})},re.path)})}),p.jsxs(Ns,{title:"Models",count:Q.length,children:[Q.map(re=>p.jsx(wp,{type:"model",label:re.path,onClick:_e=>u(`/${m}/${g}/${re.path}`,_e)},re.path)),Q.length===0&&p.jsx(FC,{label:"No models"})]}),se.length>0&&p.jsx(Ns,{title:"Agents",count:se.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:se.map(re=>p.jsx(bRe,{agent:re},re.name))}),p.jsxs(Ns,{title:"Data",count:ee.length,children:[ee.map(re=>p.jsx(wp,{type:"data",label:re.path,rightLabel:re.info?lB(re.info.rowCount):"Unreadable",onClick:()=>O(re)},re.path)),ee.length===0&&p.jsx(FC,{label:"No data files"})]}),p.jsx(kSe,{resourceUri:n,versioned:!b}),ve&&p.jsx(Te,{sx:{mt:6},children:p.jsx(_$e,{resourceUri:I1({environmentName:m,packageName:g,versionId:y}),path:ve,onLinkNavigate:u})})]}),p.jsx(sRe,{database:T,onClose:()=>O(null)})]})}function wp({type:e,label:t,description:n,rightLabel:r,onClick:o,trailingAction:a}){return p.jsx(L1,{icon:p.jsx(sB,{type:e}),tint:iB[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 bRe({agent:e}){return p.jsxs(p.Fragment,{children:[p.jsx(wp,{type:"agent",label:e.name??"",...e.description?{description:e.description}:{},...e.model&&e.model!=="inherit"?{rightLabel:e.model}:{}}),(e.schedules??[]).map(t=>{const n=lT(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 xRe(e){const t=e.map(r=>({path:r.path??"",layout:Z2(r),slug:D1(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 FC({label:e,action:t}){return p.jsxs(Yn,{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(Vn,{size:"small",onClick:t.onClick,children:t.label})]})}const iL=/^publisher:document:(dashboard|notebook):(.+)$/;function wRe(e,t){const n=[];for(let r=0;r<e.length;r++){const o=e.key(r);o!==null&&iL.test(o)&&n.push(o)}for(const r of n){const[,o,a]=iL.exec(r),i=e.getItem(r);i!==null&&t(a,L_(o),i)&&e.removeItem(r)}}const _C={name:"Local",description:"Stored in this browser only",writeable:!0},j$="publisher:report:",gd=e=>`${j$}${e}`;function yg(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 BC=(e,t)=>localStorage.setItem(gd(e),JSON.stringify(t));class SRe{migrated=!1;migrate(){this.migrated||(this.migrated=!0,wRe(localStorage,(t,n,r)=>yg(gd(t))!==void 0?!1:(BC(t,{type:n,content:r}),!0)))}async listWorkspaces(t){return[_C]}async listDocuments(t,n){if(t.name!==_C.name)return[];this.migrate();const r=[];for(let o=0;o<localStorage.length;o++){const a=localStorage.key(o);if(a===null||!a.startsWith(j$))continue;const i=yg(a);i&&(n===void 0||i.type===n)&&r.push({workspace:_C.name,type:i.type,path:a.slice(j$.length)})}return r}async getDocument(t){this.migrate();const n=yg(gd(t.path));if(n===void 0)throw UC(t);return n.content}async getDocumentType(t){this.migrate();const n=yg(gd(t.path));if(n===void 0)throw UC(t);return n.type}async saveDocument(t,n){this.migrate(),BC(t.path,{type:t.type,content:n})}async deleteDocument(t){if(this.migrate(),yg(gd(t.path))===void 0)throw UC(t);localStorage.removeItem(gd(t.path))}async moveDocument(t,n){const r=await this.getDocument(t);BC(n.path,{type:n.type,content:r}),n.path!==t.path&&localStorage.removeItem(gd(t.path))}}function UC(e){return new M_(`No report at ${e.workspace}/${e.path}`)}async function CRe(e,t,n,r){const o=E_(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(O_(i))return;throw i}return(await e.listDocuments(o)).find(i=>i.path===a)?.type}function QTe(e,t,n,r=!0){const o=I_()?.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 CRe(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 kRe(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 $Re(e){return e.type==="code"}function RRe(e){return(e.text??"").split(`
|
|
511
511
|
`).filter(t=>!t.trimStart().startsWith("##")).join(`
|
|
512
|
-
`)}const TRe=Jt(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 ERe({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]=kn.useState(!1),[x,w]=kn.useState(!1),[S,b]=kn.useState(),[$,k]=kn.useState(!1),{modelPage:T,isLoadingStatus:O}=tr(),P=!O&&T!=="viewer",[D,A]=C.useState(""),{environmentName:F,packageName:L,modelPath:_}=Xr(t),R={environmentName:F,packageName:L,sourcePath:_,onNavigate:i},{drill:z,drillMenu:N}=Z_({onNavigate:d,onSelf:s,canSelf:l}),B=/import\s*\{([^}]+)\}\s*from\s*['"`][^'"`]+['"`]/,I=/import\s*(?:\{[^}]*\}\s*from\s*)?['"`]([^'"`]+)['"`]/,H=!!e.text&&(B.test(e.text)||I.test(e.text)),Y=()=>{if(!e.newSources||e.newSources.length===0)return 0;let G=[],ie="";if(e.text){const Q=e.text.match(B);Q&&(G=Q[1].split(",").map(Z=>Z.trim()));const ee=e.text.match(I);ee&&(ie=ee[1].trim())}for(let Q=0;Q<e.newSources.length;Q++)try{const ee=JSON.parse(e.newSources[Q]);if(G.length>0&&G.includes(ee.name)||ie&&ie===ee.path)return Q}catch{continue}return 0},ae=kn.useMemo(()=>e.newSources&&e.newSources.length>0?{sourceInfos:e.newSources,resource:t,givens:m}:void 0,[e.newSources,t,m]),{mode:K}=Vr();C.useEffect(()=>{e.type==="code"&&ST(RRe(e),"malloy",K).then(G=>{b(G)})},[e,K]);const oe=()=>{const G=window.location.href;navigator.clipboard.writeText(G).then(()=>A("URL copied to clipboard!")).catch(()=>A("Failed to copy URL"))},ue=p.jsx(Oo,{open:g,onClose:()=>y(!1),title:"Malloy code",maxWidth:"lg",showClose:!0,children:p.jsx(Te,{sx:G=>({border:`1px solid ${G.palette.divider}`,borderRadius:"8px",padding:"16px",fontFamily:Fo,fontSize:"14px",lineHeight:"1.5",overflow:"auto",maxHeight:"70vh",backgroundColor:G.palette.background.paper,color:G.palette.text.primary}),children:p.jsx("pre",{className:"code-display",style:{margin:0},dangerouslySetInnerHTML:{__html:S}})})});return e.type==="markdown"&&p.jsx(Te,{children:p.jsxs(N1,{children:[n?p.jsxs(Yn,{direction:"row",alignItems:"flex-start",justifyContent:"space-between",children:[p.jsx(oh,{variant:"document",links:R,children:e.text}),p.jsx(Br,{title:"Copy link",children:p.jsx(ro,{"aria-label":"Copy link",onClick:oe,sx:{color:"text.secondary",mt:"18px"},children:p.jsx(uT,{sx:{fontSize:"24px"}})})})]}):p.jsx(oh,{variant:"document",links:R,children:e.text}),p.jsx(hh,{open:D!=="",autoHideDuration:6e3,onClose:()=>A(""),message:D})]})})||e.type==="code"&&p.jsxs(Te,{children:[e.newSources&&e.newSources.length>0&&p.jsx(Yn,{sx:{flexDirection:"column",gap:"8px",marginBottom:"2px"},children:p.jsx(x4,{sx:{position:"relative",padding:"0"},children:p.jsxs(Te,{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"}}),H&&P&&p.jsx(zp,{"aria-label":"Data sources",sx:{flexShrink:0},onClick:()=>k(!0),children:p.jsx(Kp,{})})]})})}),p.jsx(aB,{open:$&&P,onClose:()=>k(!1),title:"Data Sources",hasValidImport:H,resourceUri:t,data:ae,initialSelectedSourceIndex:Y(),startingGivens:u}),ue,p.jsx(nB,{open:x,onClose:()=>w(!1),result:e.result||"",title:"Results",drill:z}),o&&!e.result&&!e.error&&!H&&!(e.newSources&&e.newSources.length>0)&&p.jsx(X0,{children:p.jsx(Te,{sx:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:200},children:p.jsx(ku,{size:32})})}),!e.result&&e.error&&p.jsx(CF,{summary:"This cell could not be run.",detail:e.error}),e.result&&a&&p.jsx(hz,{"aria-label":"Re-run pending",sx:{mb:1,height:2,borderRadius:1}}),e.result&&p.jsxs(X0,{children:[p.jsx($_,{title:"",action:p.jsxs(Yn,{direction:"row",sx:{gap:.5,mt:"-4px"},children:[p.jsx(zp,{"aria-label":"Malloy code",onClick:G=>{G.stopPropagation(),y(!0)},children:p.jsx(TRe,{})}),p.jsx(zp,{"aria-label":"Expand results",onClick:()=>w(!0),children:p.jsx(Kp,{})})]})}),p.jsx(A1,{result:e.result,maxHeight:jle,maxResultSize:r,drill:z}),N]})]})}function MRe({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 ORe=4;function PRe(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 jRe({resourceUri:e,title:t,description:n,maxResultSize:r=0,givens:o,onGivensChange:a,onNavigate:i,onDrillNavigate:s,notebook:l,error:d,runCell:u}){const{environmentName:m,packageName:g,versionId:y,modelPath:x}=Xr(e),w=l!==void 0,S=!w&&!!d,[b,$]=C.useState([]),[k,T]=C.useState(!1),[O,P]=C.useState(!1),D=C.useRef(void 0),[A,F]=C.useState(null),L=kRe(l),_=l?.autorun!==!1,R=g1(),z=b2({specs:L,loaded:w,startingValues:l?.startingGivens,params:o,onGivensChange:a,documentKey:e,autorun:_,environmentName:m,packageName:g,modelPath:x,versionId:y,documentName:x}),{applied:N,declaredTypes:B,canSelf:I,onSelf:H}=z,Y=C.useCallback(fe=>{const he=Jd(fe,B);return Object.keys(he).length>0?JSON.stringify(he):void 0},[B]),ae=C.useMemo(()=>m0(N,B),[N,B]),K=C.useRef(0),oe=C.useRef(null),ue=C.useRef(null),G=C.useRef(void 0);C.useEffect(()=>()=>{oe.current?.abort(),ue.current=null,clearTimeout(G.current?.timer),G.current=void 0},[]);const ie=C.useCallback(async(fe=new Map)=>{if(!w||!l?.notebookCells)return;const he=++K.current;oe.current?.abort();const me=new AbortController;oe.current=me,$(l.notebookCells.map(se=>({...se}))),T(!0),F(null);try{const se=[];for(let Le=0;Le<l.notebookCells.length;Le++){const Ae=l.notebookCells[Le];if(!$Re(Ae))continue;const Re=Le,re=async()=>{try{const _e=await u({cell:Ae,index:Re,givens:fe,declaredTypes:B,signal:me.signal});if(K.current!==he)return;const Me=_e.result,Ge=Ae.newSources||_e.newSources;$(Je=>{const St=[...Je];return St[Re]||(St[Re]={...Ae}),St[Re]={...St[Re],result:Me,newSources:Ge},St})}catch(_e){if(me.signal.aborted||K.current!==he)return;R.emit({type:"report.query_failed",tile:Re,category:U0(_e)}),R.listening||console.error(`Error executing cell ${Re}:`,_e);const Me=PRe(_e);$(Ge=>{const Je=[...Ge];return Je[Re]||(Je[Re]={...Ae}),Je[Re]={...Je[Re],error:Me},Je})}};se.push(re)}const ve=[];for(const Le of se){const Ae=Le().then(()=>{ve.splice(ve.indexOf(Ae),1)});ve.push(Ae),ve.length>=ORe&&await Promise.race(ve)}await Promise.all(ve)}catch(se){if(me.signal.aborted||K.current!==he)return;R.emit({type:"report.query_failed",category:U0(se)}),R.listening||console.error("Error executing notebook cells:",se),F(se)}finally{K.current===he&&(T(!1),oe.current=null)}},[w,l,B,u,R]),Q=C.useRef(0),ee=C.useRef(void 0);ee.current!==l&&(ee.current=l,Q.current+=1);const Z=Q.current;C.useEffect(()=>{const fe=`${e}|${Z}`,he=`${fe}|${Y(N)??""}`;D.current!==void 0&&D.current!==fe&&(oe.current?.abort(),oe.current=null),D.current=fe;const me=MRe({ready:w&&!!l?.notebookCells,lastRunKey:ue.current,pendingKey:G.current?.key,runKey:he,documentKey:fe});if(me.cancelPending&&(clearTimeout(G.current?.timer),G.current=void 0,P(!1)),me.dispatch==="none")return;const se=()=>{G.current=void 0,P(!1),ue.current=he,ie(N)};if(me.dispatch==="now"){se();return}P(!0),G.current={key:he,timer:setTimeout(se,c_)}},[w,l,Z,e,N,Y,ie]);const de=b.length>0?b:l?.notebookCells||[],le=0;return p.jsxs(b$,{layout:"linear",header:t||n?p.jsx(R_,{title:t??"",description:n?p.jsx(N1,{children:p.jsx(oh,{variant:"document",children:n})}):void 0}):null,controls:z.panel.givens.length>0?p.jsx(T_,{children:p.jsx(j1,{...z.panel,layout:"bar"})}):void 0,children:[!w&&!S&&p.jsx(Bo,{text:wu.opening("report")}),w&&de.map((fe,he)=>p.jsx(ERe,{cell:fe,showCopyLink:he===le,resourceUri:e,maxResultSize:r,isExecuting:k,givens:ae,givenSpecs:L,pendingRerun:O,onNavigate:i,onDrillNavigate:s,onDrillSelf:L.length>0?H:void 0,canDrillSelf:I},he)),S&&d?.status===404&&p.jsxs(wt,{variant:"body2",sx:{color:"text.secondary"},children:[p.jsx("code",{children:`${m} > ${g} > ${x}`})," ","not found."]}),S&&d?.status!==404&&p.jsx(ja,{error:d,context:`${m} > ${g} > ${x}`}),A&&p.jsx(ja,{error:{message:A.message,status:500,name:"ExecutionError"},context:"Notebook Execution"})]})}function dB(e){const{apiClients:t}=tr(),{environmentName:n,packageName:r,versionId:o,modelPath:a}=Xr(e);return co({queryKey:[e],queryFn:async()=>(await t.notebooks.getNotebook(n,r,a,o)).data})}function ARe(e){const{apiClients:t}=tr(),{environmentName:n,packageName:r,versionId:o,modelPath:a}=Xr(e.resourceUri),i=dB(e.resourceUri),s=C.useCallback(async({index:l,givens:d,declaredTypes:u,signal:m})=>{const g=Jd(d,u);return(await t.notebooks.executeNotebookCell(n,r,a,l,o,void 0,void 0,Object.keys(g).length>0?JSON.stringify(g):void 0,{signal:m})).data},[t.notebooks,n,r,a,o]);return p.jsx(jRe,{...e,notebook:i.isSuccess?i.data:void 0,error:i.isError?i.error:void 0,runCell:s})}function XTe(e){const{data:t}=dB(e.resourceUri);if(t?.dashboard){const{environmentName:n,packageName:r,versionId:o,modelPath:a}=Xr(e.resourceUri);return p.jsx(t6,{manifest:{...t.dashboard,layout:"linear"},environmentName:n,packageName:r,versionId:o,documentName:a,givens:e.givens,onGivensChange:e.onGivensChange,onNavigate:e.onDrillNavigate,...e.onNavigate?{onLinkNavigate:e.onNavigate}:{},maxResultSize:e.maxResultSize})}return p.jsx(ARe,{...e})}function ZTe(e,t,n="grid"){const r=t.filter(a=>!!a.path).filter(a=>D1(a.path)===e),o=r.filter(a=>Z2(a)===n);return o.length===1?{found:v$(o[0])}:r.length===1?{found:v$(r[0])}:r.length===0?{missing:!0}:{ambiguous:r.map(a=>a.path).sort()}}const DRe=/^(dashboards|notebooks)\/([^/]+)$/;function JTe(e){const t=DRe.exec(e);if(t)return{name:t[2],prefer:t[1]==="dashboards"?"grid":"linear"}}const sL="[publisher.report]",lL="[publisher.console]";function NRe(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 eEe(e){return t=>{const n={...e,...t,at:new Date().toISOString()};NRe(t)?console.warn(sL,n):console.info(sL,n)}}function IRe(e){const t={...e,at:new Date().toISOString()};e.ok?console.info(lL,t):console.warn(lL,t)}const Lo={white:"#FFFFFF",offWhite:"#F8FAFC",grey:{light:"#E2E8F0",mid:"#64748B"},black:"#0F172A",semantic:{success:{main:hr.emerald,light:"#D1FAE5",dark:"#047857"},warning:{main:hr.amber,light:"#FEF3C7",dark:"#92400E"},error:{main:hr.red,light:"#FEE2E2",dark:"#B91C1C"},info:{main:hr.blue,light:"#DBEAFE",dark:"#1D4ED8"}}},Wb='"Inter", "Helvetica Neue", "Arial", sans-serif',Ho={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},tEe={headerHeight:56},cL="0 1px 3px rgba(0, 0, 0, 0.1)",LRe="#0f172a",zRe="#1e293b",FRe="#f1f5f9",_Re="#cbd5e1",BRe="#334155",fB=(e="light",t)=>{const n=e==="dark",r=n?LRe:Lo.white,o=n?zRe:Lo.white,a=n?FRe:Lo.black,i=n?_Re:Lo.grey.mid,s=n?BRe:Lo.grey.light,{accent:l,accentHover:d,accentContrast:u}=t??Ik(void 0,e);return Tx({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:Ho,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":`${Ho[300]} ${Ho[100]}`,"&::-webkit-scrollbar":{width:"8px",height:"8px"},"&::-webkit-scrollbar-track":{background:n?"#1e293b":Ho[100],borderRadius:"4px"},"&::-webkit-scrollbar-thumb":{background:n?"#475569":Ho[300],borderRadius:"4px","&:hover":{background:n?"#64748b":Ho[400]}},"&::-webkit-scrollbar-corner":{background:n?"#1e293b":Ho[100]}},".malloy-table.root":{scrollbarWidth:"auto",scrollbarColor:"auto","&::-webkit-scrollbar, &::-webkit-scrollbar-track, &::-webkit-scrollbar-corner":{background:n?"#1e293b":Ho[100]},"&::-webkit-scrollbar-thumb":{background:n?"#475569":Ho[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)":Ho[200],color:n?"#64748b":Ho[500]}},outlined:{color:a,borderColor:n?"#475569":Ho[300],"&:hover":{borderColor:n?"#64748b":Ho[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:cL,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?Ho[600]:Ho[300]}`,borderRadius:6,transition:`border-color ${Zy} ease-in`,...Jy,backgroundColor:o,"&:hover":{borderColor:n?"#64748b":Ho[400]},"&.Mui-focused":{borderColor:n?Ho[400]:Ho[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:Ho[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:cL}}}}})};fB("light");function URe({children:e}){const{mode:t,theme:n}=Vr(),{accent:r,accentHover:o,accentContrast:a}=n,i=C.useMemo(()=>fB(t,{accent:r,accentHover:o,accentContrast:a}),[t,r,o,a]);return p.jsxs(r7,{theme:i,children:[p.jsx(dQ,{}),e]})}const qRe=C.lazy(()=>wo(()=>import("./HomePage-B-7xHDxu.js"),[])),HRe=C.lazy(()=>wo(()=>import("./MainPage-swHGcEfw.js"),__vite__mapDeps([7,8,9,10]))),VRe=C.lazy(()=>wo(()=>import("./PackageSplatRoute-CfR6aEOF.js").then(e=>e.a),__vite__mapDeps([11,10]))),WRe=C.lazy(()=>wo(()=>import("./PackagePage-CMIewiLY.js"),__vite__mapDeps([12,9,10,13]))),YRe=C.lazy(()=>wo(()=>import("./EnvironmentPage-CewgI-x8.js"),[])),GRe=C.lazy(()=>wo(()=>import("./RouteError-JKbL4qo3.js"),[])),KRe=C.lazy(()=>wo(()=>import("./ThemeEditorPage-DomLLlrf.js"),__vite__mapDeps([14,15]))),QRe=(e="/",t=new SRe,n)=>(f1e(IRe),KH([{path:e,element:p.jsx(qre,{children:p.jsx(cxe,{documentStorage:t,children:p.jsx(URe,{children:p.jsx(C.Suspense,{fallback:p.jsx(Bo,{}),children:p.jsx(HRe,{headerProps:n})})})})}),errorElement:p.jsx(GRe,{}),children:[{index:!0,element:p.jsx(qRe,{})},{path:"settings/theme",element:p.jsx(KRe,{})},{path:"settings",element:p.jsx(CH,{to:"/settings/theme",replace:!0})},{path:":environmentName",element:p.jsx(YRe,{})},{path:":environmentName/:packageName",element:p.jsx(WRe,{})},{path:":environmentName/:packageName/*",element:p.jsx(VRe,{})}]}])),XRe=QRe("/");NU.createRoot(document.getElementById("root")).render(p.jsx(C.StrictMode,{children:p.jsx(lV,{router:XRe})}));export{t2e as $,JRe as A,is as B,Ay as C,Cxe as D,C_ as E,Xy as F,R0e as G,Te as H,TR as I,ro as J,Br as K,AR as L,dz as M,tr as N,zd as O,Qa as P,tu as Q,Vr as R,rk as S,wt as T,mz as U,ml as V,Ci as W,oee as X,tEe as Y,YTe as Z,qTe as _,wn as a,L_ as a$,Bo as a0,lo as a1,Vn as a2,kn as a3,wo as a4,eEe as a5,CH as a6,I1 as a7,KTe as a8,lRe as a9,Jne as aA,k_ as aB,C2e as aC,hTe as aD,_le as aE,MTe as aF,p0e as aG,TTe as aH,mTe as aI,Ble as aJ,yTe as aK,Ple as aL,pTe as aM,gTe as aN,Zd as aO,mF as aP,wl as aQ,hF as aR,f1 as aS,uc as aT,kTe as aU,qle as aV,uF as aW,tTe as aX,Q2e as aY,vTe as aZ,b$ as a_,WTe as aa,dH as ab,O0 as ac,Yn as ad,_P as ae,Ri as af,DR as ag,C4 as ah,Lk as ai,ea as aj,Tl as ak,a0 as al,DK as am,zK as an,hh as ao,Oo as ap,kae as aq,su as ar,ux as as,jd as at,ji as au,e1 as av,mae as aw,ZRe as ax,A$ as ay,Sl as az,sl as b,ETe as b$,NTe as b0,D1 as b1,Pd as b2,I_ as b3,co as b4,DTe as b5,Kk as b6,U0 as b7,PTe as b8,ja as b9,OTe as bA,ATe as bB,fxe as bC,wTe as bD,uxe as bE,BTe as bF,$Te as bG,b2 as bH,Ybe as bI,X0 as bJ,$_ as bK,B_ as bL,b0e as bM,Gbe as bN,Qbe as bO,rTe as bP,Kbe as bQ,j1 as bR,ble as bS,sxe as bT,F2e as bU,W2e as bV,rae as bW,q2e as bX,H2e as bY,V2e as bZ,G2e as b_,STe as ba,ixe as bb,VN as bc,Zy as bd,Jt as be,wi as bf,dTe as bg,vl as bh,eTe as bi,rle as bj,iF as bk,ile as bl,cF as bm,uTe as bn,T_ as bo,qbe as bp,i0e as bq,s0e as br,R_ as bs,N1 as bt,FTe as bu,E_ as bv,txe as bw,O_ as bx,jTe as by,oce as bz,Za as c,ITe as c$,OA as c0,pF as c1,d2 as c2,J2e as c3,Z2e as c4,nle as c5,Jse as c6,Jy as c7,Hbe as c8,Vbe as c9,Zle as cA,nTe as cB,iTe as cC,sTe as cD,U2e as cE,Qx as cF,aTe as cG,oTe as cH,cTe as cI,K2e as cJ,P_ as cK,N4 as cL,oae as cM,fF as cN,h1 as cO,bTe as cP,gK as cQ,vC as cR,Y2e as cS,_2e as cT,gle as cU,Ule as cV,nT as cW,rxe as cX,nxe as cY,LTe as cZ,eT as c_,X2e as ca,Tg as cb,A0e as cc,Up as cd,oQ as ce,fTe as cf,SF as cg,lTe as ch,dle as ci,WN as cj,sle as ck,Cz as cl,Wy as cm,Ele as cn,Tle as co,oh as cp,Lx as cq,ple as cr,W0e as cs,_Te as ct,zTe as cu,Bz as cv,xTe as cw,xF as cx,Hle as cy,B2e as cz,_t as d,J0e as d0,A_ as d1,X0e as d2,exe as d3,lxe as d4,ay as d5,_r as d6,T0e as d7,E0e as d8,S_ as d9,HTe as da,XTe as db,_$e as dc,e2e as dd,CTe as de,UTe as df,JTe as dg,ZTe as dh,GL as di,Fo as dj,QTe as dk,wu as dl,VTe as dm,Qxe as dn,GTe as dp,P0 as dq,k0e as dr,$0e as ds,JC as e,vn as f,yn as g,gc as h,zs as i,p as j,uo as k,Kd as l,dn as m,F5 as n,lc as o,H5 as p,Bp as q,C as r,ct as s,Fy as t,Sn as u,_5 as v,Ln as w,lt as x,Aa as y,hs as z};
|
|
512
|
+
`)}const TRe=Jt(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 ERe({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]=kn.useState(!1),[x,w]=kn.useState(!1),[S,b]=kn.useState(),[$,k]=kn.useState(!1),{modelPage:T,isLoadingStatus:O}=tr(),P=!O&&T!=="viewer",[D,A]=C.useState(""),{environmentName:F,packageName:L,modelPath:_}=Xr(t),R={environmentName:F,packageName:L,sourcePath:_,onNavigate:i},{drill:z,drillMenu:N}=Z_({onNavigate:d,onSelf:s,canSelf:l}),B=/import\s*\{([^}]+)\}\s*from\s*['"`][^'"`]+['"`]/,I=/import\s*(?:\{[^}]*\}\s*from\s*)?['"`]([^'"`]+)['"`]/,H=!!e.text&&(B.test(e.text)||I.test(e.text)),Y=()=>{if(!e.newSources||e.newSources.length===0)return 0;let G=[],ie="";if(e.text){const Q=e.text.match(B);Q&&(G=Q[1].split(",").map(Z=>Z.trim()));const ee=e.text.match(I);ee&&(ie=ee[1].trim())}for(let Q=0;Q<e.newSources.length;Q++)try{const ee=JSON.parse(e.newSources[Q]);if(G.length>0&&G.includes(ee.name)||ie&&ie===ee.path)return Q}catch{continue}return 0},ae=kn.useMemo(()=>e.newSources&&e.newSources.length>0?{sourceInfos:e.newSources,resource:t,givens:m}:void 0,[e.newSources,t,m]),{mode:K}=Vr();C.useEffect(()=>{e.type==="code"&&ST(RRe(e),"malloy",K).then(G=>{b(G)})},[e,K]);const oe=()=>{const G=window.location.href;navigator.clipboard.writeText(G).then(()=>A("URL copied to clipboard!")).catch(()=>A("Failed to copy URL"))},ue=p.jsx(Oo,{open:g,onClose:()=>y(!1),title:"Malloy code",maxWidth:"lg",showClose:!0,children:p.jsx(Te,{sx:G=>({border:`1px solid ${G.palette.divider}`,borderRadius:"8px",padding:"16px",fontFamily:Fo,fontSize:"14px",lineHeight:"1.5",overflow:"auto",maxHeight:"70vh",backgroundColor:G.palette.background.paper,color:G.palette.text.primary}),children:p.jsx("pre",{className:"code-display",style:{margin:0},dangerouslySetInnerHTML:{__html:S}})})});return e.type==="markdown"&&p.jsx(Te,{children:p.jsxs(N1,{children:[n?p.jsxs(Yn,{direction:"row",alignItems:"flex-start",justifyContent:"space-between",children:[p.jsx(oh,{variant:"document",links:R,children:e.text}),p.jsx(Br,{title:"Copy link",children:p.jsx(ro,{"aria-label":"Copy link",onClick:oe,sx:{color:"text.secondary",mt:"18px"},children:p.jsx(uT,{sx:{fontSize:"24px"}})})})]}):p.jsx(oh,{variant:"document",links:R,children:e.text}),p.jsx(hh,{open:D!=="",autoHideDuration:6e3,onClose:()=>A(""),message:D})]})})||e.type==="code"&&p.jsxs(Te,{children:[e.newSources&&e.newSources.length>0&&p.jsx(Yn,{sx:{flexDirection:"column",gap:"8px",marginBottom:"2px"},children:p.jsx(x4,{sx:{position:"relative",padding:"0"},children:p.jsxs(Te,{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"}}),H&&P&&p.jsx(zp,{"aria-label":"Data sources",sx:{flexShrink:0},onClick:()=>k(!0),children:p.jsx(Kp,{})})]})})}),p.jsx(aB,{open:$&&P,onClose:()=>k(!1),title:"Data Sources",hasValidImport:H,resourceUri:t,data:ae,initialSelectedSourceIndex:Y(),startingGivens:u}),ue,p.jsx(nB,{open:x,onClose:()=>w(!1),result:e.result||"",title:"Results",drill:z}),o&&!e.result&&!e.error&&!H&&!(e.newSources&&e.newSources.length>0)&&p.jsx(X0,{children:p.jsx(Te,{sx:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:200},children:p.jsx(ku,{size:32})})}),!e.result&&e.error&&p.jsx(CF,{summary:"This cell could not be run.",detail:e.error}),e.result&&a&&p.jsx(hz,{"aria-label":"Re-run pending",sx:{mb:1,height:2,borderRadius:1}}),e.result&&p.jsxs(X0,{children:[p.jsx($_,{title:"",action:p.jsxs(Yn,{direction:"row",sx:{gap:.5,mt:"-4px"},children:[p.jsx(zp,{"aria-label":"Malloy code",onClick:G=>{G.stopPropagation(),y(!0)},children:p.jsx(TRe,{})}),p.jsx(zp,{"aria-label":"Expand results",onClick:()=>w(!0),children:p.jsx(Kp,{})})]})}),p.jsx(A1,{result:e.result,maxHeight:jle,maxResultSize:r,drill:z}),N]})]})}function MRe({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 ORe=4;function PRe(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 jRe({resourceUri:e,title:t,description:n,maxResultSize:r=0,givens:o,onGivensChange:a,onNavigate:i,onDrillNavigate:s,notebook:l,error:d,runCell:u}){const{environmentName:m,packageName:g,versionId:y,modelPath:x}=Xr(e),w=l!==void 0,S=!w&&!!d,[b,$]=C.useState([]),[k,T]=C.useState(!1),[O,P]=C.useState(!1),D=C.useRef(void 0),[A,F]=C.useState(null),L=kRe(l),_=l?.autorun!==!1,R=g1(),z=b2({specs:L,loaded:w,startingValues:l?.startingGivens,params:o,onGivensChange:a,documentKey:e,autorun:_,environmentName:m,packageName:g,modelPath:x,versionId:y,documentName:x}),{applied:N,declaredTypes:B,canSelf:I,onSelf:H}=z,Y=C.useCallback(fe=>{const he=Jd(fe,B);return Object.keys(he).length>0?JSON.stringify(he):void 0},[B]),ae=C.useMemo(()=>m0(N,B),[N,B]),K=C.useRef(0),oe=C.useRef(null),ue=C.useRef(null),G=C.useRef(void 0);C.useEffect(()=>()=>{oe.current?.abort(),ue.current=null,clearTimeout(G.current?.timer),G.current=void 0},[]);const ie=C.useCallback(async(fe=new Map)=>{if(!w||!l?.notebookCells)return;const he=++K.current;oe.current?.abort();const me=new AbortController;oe.current=me,$(l.notebookCells.map(se=>({...se}))),T(!0),F(null);try{const se=[];for(let Le=0;Le<l.notebookCells.length;Le++){const Ae=l.notebookCells[Le];if(!$Re(Ae))continue;const Re=Le,re=async()=>{try{const _e=await u({cell:Ae,index:Re,givens:fe,declaredTypes:B,signal:me.signal});if(K.current!==he)return;const Me=_e.result,Ge=Ae.newSources||_e.newSources;$(Je=>{const St=[...Je];return St[Re]||(St[Re]={...Ae}),St[Re]={...St[Re],result:Me,newSources:Ge},St})}catch(_e){if(me.signal.aborted||K.current!==he)return;R.emit({type:"report.query_failed",tile:Re,category:U0(_e)}),R.listening||console.error(`Error executing cell ${Re}:`,_e);const Me=PRe(_e);$(Ge=>{const Je=[...Ge];return Je[Re]||(Je[Re]={...Ae}),Je[Re]={...Je[Re],error:Me},Je})}};se.push(re)}const ve=[];for(const Le of se){const Ae=Le().then(()=>{ve.splice(ve.indexOf(Ae),1)});ve.push(Ae),ve.length>=ORe&&await Promise.race(ve)}await Promise.all(ve)}catch(se){if(me.signal.aborted||K.current!==he)return;R.emit({type:"report.query_failed",category:U0(se)}),R.listening||console.error("Error executing notebook cells:",se),F(se)}finally{K.current===he&&(T(!1),oe.current=null)}},[w,l,B,u,R]),Q=C.useRef(0),ee=C.useRef(void 0);ee.current!==l&&(ee.current=l,Q.current+=1);const Z=Q.current;C.useEffect(()=>{const fe=`${e}|${Z}`,he=`${fe}|${Y(N)??""}`;D.current!==void 0&&D.current!==fe&&(oe.current?.abort(),oe.current=null),D.current=fe;const me=MRe({ready:w&&!!l?.notebookCells,lastRunKey:ue.current,pendingKey:G.current?.key,runKey:he,documentKey:fe});if(me.cancelPending&&(clearTimeout(G.current?.timer),G.current=void 0,P(!1)),me.dispatch==="none")return;const se=()=>{G.current=void 0,P(!1),ue.current=he,ie(N)};if(me.dispatch==="now"){se();return}P(!0),G.current={key:he,timer:setTimeout(se,c_)}},[w,l,Z,e,N,Y,ie]);const de=b.length>0?b:l?.notebookCells||[],le=0;return p.jsxs(b$,{layout:"linear",header:t||n?p.jsx(R_,{title:t??"",description:n?p.jsx(N1,{children:p.jsx(oh,{variant:"document",children:n})}):void 0}):null,controls:z.panel.givens.length>0?p.jsx(T_,{children:p.jsx(j1,{...z.panel,layout:"bar"})}):void 0,children:[!w&&!S&&p.jsx(Bo,{text:wu.opening("report")}),w&&de.map((fe,he)=>p.jsx(ERe,{cell:fe,showCopyLink:he===le,resourceUri:e,maxResultSize:r,isExecuting:k,givens:ae,givenSpecs:L,pendingRerun:O,onNavigate:i,onDrillNavigate:s,onDrillSelf:L.length>0?H:void 0,canDrillSelf:I},he)),S&&d?.status===404&&p.jsxs(wt,{variant:"body2",sx:{color:"text.secondary"},children:[p.jsx("code",{children:`${m} > ${g} > ${x}`})," ","not found."]}),S&&d?.status!==404&&p.jsx(ja,{error:d,context:`${m} > ${g} > ${x}`}),A&&p.jsx(ja,{error:{message:A.message,status:500,name:"ExecutionError"},context:"Notebook Execution"})]})}function dB(e){const{apiClients:t}=tr(),{environmentName:n,packageName:r,versionId:o,modelPath:a}=Xr(e);return co({queryKey:[e],queryFn:async()=>(await t.notebooks.getNotebook(n,r,a,o)).data})}function ARe(e){const{apiClients:t}=tr(),{environmentName:n,packageName:r,versionId:o,modelPath:a}=Xr(e.resourceUri),i=dB(e.resourceUri),s=C.useCallback(async({index:l,givens:d,declaredTypes:u,signal:m})=>{const g=Jd(d,u);return(await t.notebooks.executeNotebookCell(n,r,a,l,o,void 0,void 0,Object.keys(g).length>0?JSON.stringify(g):void 0,{signal:m})).data},[t.notebooks,n,r,a,o]);return p.jsx(jRe,{...e,notebook:i.isSuccess?i.data:void 0,error:i.isError?i.error:void 0,runCell:s})}function XTe(e){const{data:t}=dB(e.resourceUri);if(t?.dashboard){const{environmentName:n,packageName:r,versionId:o,modelPath:a}=Xr(e.resourceUri);return p.jsx(t6,{manifest:{...t.dashboard,layout:"linear"},environmentName:n,packageName:r,versionId:o,documentName:a,givens:e.givens,onGivensChange:e.onGivensChange,onNavigate:e.onDrillNavigate,...e.onNavigate?{onLinkNavigate:e.onNavigate}:{},maxResultSize:e.maxResultSize})}return p.jsx(ARe,{...e})}function ZTe(e,t,n="grid"){const r=t.filter(a=>!!a.path).filter(a=>D1(a.path)===e),o=r.filter(a=>Z2(a)===n);return o.length===1?{found:v$(o[0])}:r.length===1?{found:v$(r[0])}:r.length===0?{missing:!0}:{ambiguous:r.map(a=>a.path).sort()}}const DRe=/^(dashboards|notebooks)\/([^/]+)$/;function JTe(e){const t=DRe.exec(e);if(t)return{name:t[2],prefer:t[1]==="dashboards"?"grid":"linear"}}const sL="[publisher.report]",lL="[publisher.console]";function NRe(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 eEe(e){return t=>{const n={...e,...t,at:new Date().toISOString()};NRe(t)?console.warn(sL,n):console.info(sL,n)}}function IRe(e){const t={...e,at:new Date().toISOString()};e.ok?console.info(lL,t):console.warn(lL,t)}const Lo={white:"#FFFFFF",offWhite:"#F8FAFC",grey:{light:"#E2E8F0",mid:"#64748B"},black:"#0F172A",semantic:{success:{main:hr.emerald,light:"#D1FAE5",dark:"#047857"},warning:{main:hr.amber,light:"#FEF3C7",dark:"#92400E"},error:{main:hr.red,light:"#FEE2E2",dark:"#B91C1C"},info:{main:hr.blue,light:"#DBEAFE",dark:"#1D4ED8"}}},Wb='"Inter", "Helvetica Neue", "Arial", sans-serif',Ho={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},tEe={headerHeight:56},cL="0 1px 3px rgba(0, 0, 0, 0.1)",LRe="#0f172a",zRe="#1e293b",FRe="#f1f5f9",_Re="#cbd5e1",BRe="#334155",fB=(e="light",t)=>{const n=e==="dark",r=n?LRe:Lo.white,o=n?zRe:Lo.white,a=n?FRe:Lo.black,i=n?_Re:Lo.grey.mid,s=n?BRe:Lo.grey.light,{accent:l,accentHover:d,accentContrast:u}=t??Ik(void 0,e);return Tx({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:Ho,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":`${Ho[300]} ${Ho[100]}`,"&::-webkit-scrollbar":{width:"8px",height:"8px"},"&::-webkit-scrollbar-track":{background:n?"#1e293b":Ho[100],borderRadius:"4px"},"&::-webkit-scrollbar-thumb":{background:n?"#475569":Ho[300],borderRadius:"4px","&:hover":{background:n?"#64748b":Ho[400]}},"&::-webkit-scrollbar-corner":{background:n?"#1e293b":Ho[100]}},".malloy-table.root":{scrollbarWidth:"auto",scrollbarColor:"auto","&::-webkit-scrollbar, &::-webkit-scrollbar-track, &::-webkit-scrollbar-corner":{background:n?"#1e293b":Ho[100]},"&::-webkit-scrollbar-thumb":{background:n?"#475569":Ho[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)":Ho[200],color:n?"#64748b":Ho[500]}},outlined:{color:a,borderColor:n?"#475569":Ho[300],"&:hover":{borderColor:n?"#64748b":Ho[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:cL,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?Ho[600]:Ho[300]}`,borderRadius:6,transition:`border-color ${Zy} ease-in`,...Jy,backgroundColor:o,"&:hover":{borderColor:n?"#64748b":Ho[400]},"&.Mui-focused":{borderColor:n?Ho[400]:Ho[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:Ho[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:cL}}}}})};fB("light");function URe({children:e}){const{mode:t,theme:n}=Vr(),{accent:r,accentHover:o,accentContrast:a}=n,i=C.useMemo(()=>fB(t,{accent:r,accentHover:o,accentContrast:a}),[t,r,o,a]);return p.jsxs(r7,{theme:i,children:[p.jsx(dQ,{}),e]})}const qRe=C.lazy(()=>wo(()=>import("./HomePage-lrIG8Qjk.js"),[])),HRe=C.lazy(()=>wo(()=>import("./MainPage-CJf3Uuul.js"),__vite__mapDeps([7,8,9,10]))),VRe=C.lazy(()=>wo(()=>import("./PackageSplatRoute-FyScmoYw.js").then(e=>e.a),__vite__mapDeps([11,10]))),WRe=C.lazy(()=>wo(()=>import("./PackagePage-Cxa0_alv.js"),__vite__mapDeps([12,9,10,13]))),YRe=C.lazy(()=>wo(()=>import("./EnvironmentPage-gNvDKTtA.js"),[])),GRe=C.lazy(()=>wo(()=>import("./RouteError-BZUUKmNE.js"),[])),KRe=C.lazy(()=>wo(()=>import("./ThemeEditorPage-vDnfPmZz.js"),__vite__mapDeps([14,15]))),QRe=(e="/",t=new SRe,n)=>(f1e(IRe),KH([{path:e,element:p.jsx(qre,{children:p.jsx(cxe,{documentStorage:t,children:p.jsx(URe,{children:p.jsx(C.Suspense,{fallback:p.jsx(Bo,{}),children:p.jsx(HRe,{headerProps:n})})})})}),errorElement:p.jsx(GRe,{}),children:[{index:!0,element:p.jsx(qRe,{})},{path:"settings/theme",element:p.jsx(KRe,{})},{path:"settings",element:p.jsx(CH,{to:"/settings/theme",replace:!0})},{path:":environmentName",element:p.jsx(YRe,{})},{path:":environmentName/:packageName",element:p.jsx(WRe,{})},{path:":environmentName/:packageName/*",element:p.jsx(VRe,{})}]}])),XRe=QRe("/");NU.createRoot(document.getElementById("root")).render(p.jsx(C.StrictMode,{children:p.jsx(lV,{router:XRe})}));export{t2e as $,JRe as A,is as B,Ay as C,Cxe as D,C_ as E,Xy as F,R0e as G,Te as H,TR as I,ro as J,Br as K,AR as L,dz as M,tr as N,zd as O,Qa as P,tu as Q,Vr as R,rk as S,wt as T,mz as U,ml as V,Ci as W,oee as X,tEe as Y,YTe as Z,qTe as _,wn as a,L_ as a$,Bo as a0,lo as a1,Vn as a2,kn as a3,wo as a4,eEe as a5,CH as a6,I1 as a7,KTe as a8,lRe as a9,Jne as aA,k_ as aB,C2e as aC,hTe as aD,_le as aE,MTe as aF,p0e as aG,TTe as aH,mTe as aI,Ble as aJ,yTe as aK,Ple as aL,pTe as aM,gTe as aN,Zd as aO,mF as aP,wl as aQ,hF as aR,f1 as aS,uc as aT,kTe as aU,qle as aV,uF as aW,tTe as aX,Q2e as aY,vTe as aZ,b$ as a_,WTe as aa,dH as ab,O0 as ac,Yn as ad,_P as ae,Ri as af,DR as ag,C4 as ah,Lk as ai,ea as aj,Tl as ak,a0 as al,DK as am,zK as an,hh as ao,Oo as ap,kae as aq,su as ar,ux as as,jd as at,ji as au,e1 as av,mae as aw,ZRe as ax,A$ as ay,Sl as az,sl as b,ETe as b$,NTe as b0,D1 as b1,Pd as b2,I_ as b3,co as b4,DTe as b5,Kk as b6,U0 as b7,PTe as b8,ja as b9,OTe as bA,ATe as bB,fxe as bC,wTe as bD,uxe as bE,BTe as bF,$Te as bG,b2 as bH,Ybe as bI,X0 as bJ,$_ as bK,B_ as bL,b0e as bM,Gbe as bN,Qbe as bO,rTe as bP,Kbe as bQ,j1 as bR,ble as bS,sxe as bT,F2e as bU,W2e as bV,rae as bW,q2e as bX,H2e as bY,V2e as bZ,G2e as b_,STe as ba,ixe as bb,VN as bc,Zy as bd,Jt as be,wi as bf,dTe as bg,vl as bh,eTe as bi,rle as bj,iF as bk,ile as bl,cF as bm,uTe as bn,T_ as bo,qbe as bp,i0e as bq,s0e as br,R_ as bs,N1 as bt,FTe as bu,E_ as bv,txe as bw,O_ as bx,jTe as by,oce as bz,Za as c,ITe as c$,OA as c0,pF as c1,d2 as c2,J2e as c3,Z2e as c4,nle as c5,Jse as c6,Jy as c7,Hbe as c8,Vbe as c9,Zle as cA,nTe as cB,iTe as cC,sTe as cD,U2e as cE,Qx as cF,aTe as cG,oTe as cH,cTe as cI,K2e as cJ,P_ as cK,N4 as cL,oae as cM,fF as cN,h1 as cO,bTe as cP,gK as cQ,vC as cR,Y2e as cS,_2e as cT,gle as cU,Ule as cV,nT as cW,rxe as cX,nxe as cY,LTe as cZ,eT as c_,X2e as ca,Tg as cb,A0e as cc,Up as cd,oQ as ce,fTe as cf,SF as cg,lTe as ch,dle as ci,WN as cj,sle as ck,Cz as cl,Wy as cm,Ele as cn,Tle as co,oh as cp,Lx as cq,ple as cr,W0e as cs,_Te as ct,zTe as cu,Bz as cv,xTe as cw,xF as cx,Hle as cy,B2e as cz,_t as d,J0e as d0,A_ as d1,X0e as d2,exe as d3,lxe as d4,ay as d5,_r as d6,T0e as d7,E0e as d8,S_ as d9,HTe as da,XTe as db,_$e as dc,e2e as dd,CTe as de,UTe as df,JTe as dg,ZTe as dh,GL as di,Fo as dj,QTe as dk,wu as dl,VTe as dm,Qxe as dn,GTe as dp,P0 as dq,k0e as dr,$0e as ds,JC as e,vn as f,yn as g,gc as h,zs as i,p as j,uo as k,Kd as l,dn as m,F5 as n,lc as o,H5 as p,Bp as q,C as r,ct as s,Fy as t,Sn as u,_5 as v,Ln as w,lt as x,Aa as y,hs as z};
|