@syncular/console 0.0.6-86 → 0.0.6-90

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syncular/console",
3
- "version": "0.0.6-86",
3
+ "version": "0.0.6-90",
4
4
  "description": "Embeddable Syncular console UI",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Benjamin Kniffler",
@@ -68,9 +68,9 @@
68
68
  "release": "bunx syncular-publish"
69
69
  },
70
70
  "dependencies": {
71
- "@syncular/observability-sentry": "0.0.6-86",
72
- "@syncular/transport-http": "0.0.6-86",
73
- "@syncular/ui": "0.0.6-86",
71
+ "@syncular/observability-sentry": "0.0.6-90",
72
+ "@syncular/transport-http": "0.0.6-90",
73
+ "@syncular/ui": "0.0.6-90",
74
74
  "@tanstack/react-query": "^5.90.21",
75
75
  "@tanstack/react-router": "^1.162.9",
76
76
  "lucide-react": "^0.575.0"
@@ -83,4 +83,4 @@ ${a}
83
83
  ${l.right}px ${l.bottom}px,
84
84
  ${l.right}px ${l.top}px,
85
85
  ${l.left}px ${l.top}px
86
- )`}return h.jsx("div",{ref:n,role:"presentation","data-base-ui-inert":"",...i,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:a}})});function Jh(e,t){e&&Object.assign(e.style,t)}const ZG={position:"relative",maxHeight:"100%",overflowX:"hidden",overflowY:"auto"},YG={position:"fixed"},XG=_.forwardRef(function(t,n){const{anchor:s,positionMethod:i="absolute",className:a,render:l,side:f="bottom",align:d="center",sideOffset:p=0,alignOffset:g=0,collisionBoundary:y="clipping-ancestors",collisionPadding:b,arrowPadding:x=5,sticky:S=!1,disableAnchorTracking:w,alignItemWithTrigger:T=!0,collisionAvoidance:C=e8,...k}=t,{store:N,listRef:R,labelsRef:M,alignItemWithTriggerActiveRef:L,selectedItemTextRef:j,valuesRef:A,initialValueRef:P,popupRef:G,setValue:B}=Ju(),z=VA(),Q=at(N,it.open),Y=at(N,it.mounted),ee=at(N,it.modal),D=at(N,it.value),K=at(N,it.openMethod),q=at(N,it.positionerElement),V=at(N,it.triggerElement),U=at(N,it.isItemEqualToValue),I=at(N,it.transitionStatus),H=_.useRef(null),W=_.useRef(null),[X,oe]=_.useState(T),se=Y&&X&&K!=="touch";!Y&&X!==T&&oe(T),Le(()=>{Y||(it.scrollUpArrowVisible(N.state)&&N.set("scrollUpArrowVisible",!1),it.scrollDownArrowVisible(N.state)&&N.set("scrollDownArrowVisible",!1))},[N,Y]),_.useImperativeHandle(L,()=>se),KA((se||ee)&&Q&&K!=="touch",V);const de=BA({anchor:s,floatingRootContext:z,positionMethod:i,mounted:Y,side:f,sideOffset:p,align:d,alignOffset:g,arrowPadding:x,collisionBoundary:y,collisionPadding:b,sticky:S,disableAnchorTracking:w??se,collisionAvoidance:C,keepMounted:!0}),xe=se?"none":de.side,he=se?YG:de.positionerStyles,Me=_.useMemo(()=>{const Se={};return Q||(Se.pointerEvents="none"),{role:"presentation",hidden:!Y,style:{...he,...Se}}},[Q,Y,he]),_e={open:Q,side:xe,align:de.align,anchorHidden:de.anchorHidden},ne=Ae(Se=>{N.set("positionerElement",Se)}),pe=zt("div",t,{ref:[n,ne],state:_e,stateAttributesMapping:il,props:[Me,kp(I),k]}),ae=_.useRef(0),we=Ae(Se=>{if(Se.size===0&&ae.current===0||A.current.length===0)return;const ye=ae.current;if(ae.current=Se.size,Se.size===ye)return;const Ue=Yt(ii);if(ye!==0&&!N.state.multiple&&D!==null&&Uy(A.current,D,U)===-1){const Ee=P.current,Xe=Ee!=null&&Uy(A.current,Ee,U)!==-1?Ee:null;B(Xe,Ue),Xe===null&&(N.set("selectedIndex",null),j.current=null)}if(ye!==0&&N.state.multiple&&Array.isArray(D)){const Ie=Ve=>Uy(A.current,Ve,U)!==-1,Ee=D.filter(Ve=>Ie(Ve));(Ee.length!==D.length||Ee.some(Ve=>!EG(D,Ve,U)))&&(B(Ee,Ue),Ee.length===0&&(N.set("selectedIndex",null),j.current=null))}if(Q&&se){N.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});const Ie={height:""};Jh(q,Ie),Jh(G.current,Ie)}}),ve=_.useMemo(()=>({...de,side:xe,alignItemWithTriggerActive:se,setControlledAlignItemWithTrigger:oe,scrollUpArrowRef:H,scrollDownArrowRef:W}),[de,xe,se,oe]);return h.jsx(ZA,{elementsRef:R,labelsRef:M,onMapChange:we,children:h.jsxs(YA.Provider,{value:ve,children:[Y&&ee&&h.jsx(XA,{inert:hx(!Q),cutout:V}),pe]})})});function QA(e){const t=e.currentTarget.getBoundingClientRect();return t.top+1<=e.clientY&&e.clientY<=t.bottom-1&&t.left+1<=e.clientX&&e.clientX<=t.right-1}const Kd="base-ui-disable-scrollbar",UC={className:Kd,getElement(e){return h.jsx("style",{nonce:e,href:Kd,precedence:"base-ui:low",children:`.${Kd}{scrollbar-width:none}.${Kd}::-webkit-scrollbar{display:none}`})}},QG=_.createContext(void 0);function WA(e){return _.useContext(QG)}const Ec="ArrowUp",Qi="ArrowDown",ku="ArrowLeft",Tc="ArrowRight",ef="Home",tf="End",JA=new Set([ku,Tc]),WG=new Set([ku,Tc,ef,tf]),ek=new Set([Ec,Qi]),JG=new Set([Ec,Qi,ef,tf]),tk=new Set([...JA,...ek]),eZ=new Set([...tk,ef,tf]),nk=new Set([Ec,Qi,ku,Tc,ef,tf]),tZ="Shift",nZ="Control",rZ="Alt",sZ="Meta",oZ=new Set([tZ,nZ,rZ,sZ]);function iZ(e){return Zt(e)&&e.tagName==="INPUT"}function $C(e){return!!(iZ(e)&&e.selectionStart!=null||Zt(e)&&e.tagName==="TEXTAREA")}function BC(e,t,n,s){if(!e||!t||!t.scrollTo)return;let i=e.scrollLeft,a=e.scrollTop;const l=e.clientWidth<e.scrollWidth,f=e.clientHeight<e.scrollHeight;if(l&&s!=="vertical"){const d=FC(e,t,"left"),p=Gd(e),g=Gd(t);n==="ltr"&&(d+t.offsetWidth+g.scrollMarginRight>e.scrollLeft+e.clientWidth-p.scrollPaddingRight?i=d+t.offsetWidth+g.scrollMarginRight-e.clientWidth+p.scrollPaddingRight:d-g.scrollMarginLeft<e.scrollLeft+p.scrollPaddingLeft&&(i=d-g.scrollMarginLeft-p.scrollPaddingLeft)),n==="rtl"&&(d-g.scrollMarginRight<e.scrollLeft+p.scrollPaddingLeft?i=d-g.scrollMarginLeft-p.scrollPaddingLeft:d+t.offsetWidth+g.scrollMarginRight>e.scrollLeft+e.clientWidth-p.scrollPaddingRight&&(i=d+t.offsetWidth+g.scrollMarginRight-e.clientWidth+p.scrollPaddingRight))}if(f&&s!=="horizontal"){const d=FC(e,t,"top"),p=Gd(e),g=Gd(t);d-g.scrollMarginTop<e.scrollTop+p.scrollPaddingTop?a=d-g.scrollMarginTop-p.scrollPaddingTop:d+t.offsetHeight+g.scrollMarginBottom>e.scrollTop+e.clientHeight-p.scrollPaddingBottom&&(a=d+t.offsetHeight+g.scrollMarginBottom-e.clientHeight+p.scrollPaddingBottom)}e.scrollTo({left:i,top:a,behavior:"auto"})}function FC(e,t,n){const s=n==="left"?"offsetLeft":"offsetTop";let i=0;for(;t.offsetParent&&(i+=t[s],t.offsetParent!==e);)t=t.offsetParent;return i}function Gd(e){const t=getComputedStyle(e);return{scrollMarginTop:parseFloat(t.scrollMarginTop)||0,scrollMarginRight:parseFloat(t.scrollMarginRight)||0,scrollMarginBottom:parseFloat(t.scrollMarginBottom)||0,scrollMarginLeft:parseFloat(t.scrollMarginLeft)||0,scrollPaddingTop:parseFloat(t.scrollPaddingTop)||0,scrollPaddingRight:parseFloat(t.scrollPaddingRight)||0,scrollPaddingBottom:parseFloat(t.scrollPaddingBottom)||0,scrollPaddingLeft:parseFloat(t.scrollPaddingLeft)||0}}function $y(e,t=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(t,Math.min(e,n))}const aZ=_.createContext(void 0),cZ={disableStyleElements:!1};function lZ(){return _.useContext(aZ)??cZ}const qi=1,uZ={...il,...va},fZ=_.forwardRef(function(t,n){const{render:s,className:i,finalFocus:a,...l}=t,{store:f,popupRef:d,onOpenChangeComplete:p,setOpen:g,valueRef:y,selectedItemTextRef:b,keyboardActiveRef:x,multiple:S,handleScrollArrowVisibility:w,scrollHandlerRef:T,highlightItemOnHover:C}=Ju(),{side:k,align:N,alignItemWithTriggerActive:R,setControlledAlignItemWithTrigger:M,scrollDownArrowRef:L,scrollUpArrowRef:j}=GG(),A=WA()!=null,P=VA(),{nonce:G,disableStyleElements:B}=lZ(),z=rs(),Q=at(f,it.id),Y=at(f,it.open),ee=at(f,it.mounted),D=at(f,it.popupProps),K=at(f,it.transitionStatus),q=at(f,it.triggerElement),V=at(f,it.positionerElement),U=at(f,it.listElement),I=_.useRef(0),H=_.useRef(!1),W=_.useRef(0),X=_.useRef(!1),oe=_.useRef({}),se=ax(),de=Ae(_e=>{if(!V||!d.current||!X.current)return;if(H.current||!R){w();return}const ne=V.style.top==="0px",pe=V.style.bottom==="0px",ae=V.getBoundingClientRect().height,we=Rt(V),ve=getComputedStyle(V),Se=parseFloat(ve.marginTop),ye=parseFloat(ve.marginBottom),Ue=HC(getComputedStyle(d.current)),Ie=Math.min(we.documentElement.clientHeight-Se-ye,Ue),Ee=_e.scrollTop,Ve=qC(_e);let Xe=0,Be=null,We=!1,He=!1;const me=qe=>{V.style.height=`${qe}px`},Te=(qe,mt)=>{const lt=$y(qe,0,Ie-ae);lt>0&&me(ae+lt),_e.scrollTop=mt,Ie-(ae+lt)<=qi&&(H.current=!0),w()};if(ne){const qe=Ve-Ee,mt=ae+qe,lt=Math.min(mt,Ie);if(Xe=lt,qe<=qi){Te(qe,Ve);return}Ie-lt>qi?He=!0:We=!0}else if(pe){const qe=Ee,mt=ae+qe,lt=Math.min(mt,Ie),wr=mt-Ie;if(Xe=lt,qe<=qi){Te(qe,0);return}Ie-lt>qi?Be=0:(We=!0,Ee<Ve&&(Be=Ee-(qe-wr)))}if(Xe=Math.ceil(Xe),Xe!==0&&me(Xe),He||Be!=null){const qe=qC(_e),mt=He?qe:$y(Be,0,qe);Math.abs(_e.scrollTop-mt)>qi&&(_e.scrollTop=mt)}(We||Xe>=Ie-qi)&&(H.current=!0),w()});_.useImperativeHandle(T,()=>de,[de]),ba({open:Y,ref:d,onComplete(){Y&&p?.(!0)}});const xe={open:Y,transitionStatus:K,side:k,align:N};Le(()=>{!V||!d.current||Object.keys(oe.current).length||(oe.current={top:V.style.top||"0",left:V.style.left||"0",right:V.style.right,height:V.style.height,bottom:V.style.bottom,minHeight:V.style.minHeight,maxHeight:V.style.maxHeight,marginTop:V.style.marginTop,marginBottom:V.style.marginBottom})},[d,V]),Le(()=>{Y||R||(X.current=!1,H.current=!1,I.current=0,W.current=0,Jh(V,oe.current))},[Y,R,V,d]),Le(()=>{const _e=d.current;if(!(!Y||!q||!V||!_e||f.state.transitionStatus==="ending")){if(!R){X.current=!0,se.request(w),_e.style.removeProperty("--transform-origin");return}queueMicrotask(()=>{const ne=dZ(_e);_e.style.removeProperty("--transform-origin");try{const pe=getComputedStyle(V),ae=getComputedStyle(_e),we=Rt(q),ve=un(V),Se=q.getBoundingClientRect(),ye=V.getBoundingClientRect(),Ue=Se.left,Ie=Se.height,Ee=U||_e,Ve=Ee.scrollHeight,Xe=parseFloat(ae.borderBottomWidth),Be=parseFloat(pe.marginTop)||10,We=parseFloat(pe.marginBottom)||10,He=parseFloat(pe.minHeight)||100,me=HC(ae),Te=5,qe=5,mt=20,lt=we.documentElement.clientHeight-Be-We,wr=we.documentElement.clientWidth,Er=lt-Se.bottom+Ie,Qt=b.current,ut=y.current;let xt,ot=0,Wt=0;if(Qt&&ut){const tr=ut.getBoundingClientRect();xt=Qt.getBoundingClientRect();const ls=tr.left-Ue,uo=xt.left-ye.left,fo=tr.top-Se.top+tr.height/2,nr=xt.top-ye.top+xt.height/2;ot=ls-uo,Wt=nr-fo}const vn=Er+Wt+We+Xe;let kt=Math.min(lt,vn);const Cn=lt-Be-We,er=vn-kt,An=Math.max(Te,Ue+ot),as=wr-qe,cs=Math.max(0,An+ye.width-as);V.style.left=`${An-cs}px`,V.style.height=`${kt}px`,V.style.maxHeight="auto",V.style.marginTop=`${Be}px`,V.style.marginBottom=`${We}px`,_e.style.height="100%";const _a=Ee.scrollHeight-Ee.clientHeight,_i=er>=_a;_i&&(kt=Math.min(lt,ye.height)-(er-_a));const wi=Se.top<mt||Se.bottom>lt-mt||kt<Math.min(Ve,He),ws=(ve.visualViewport?.scale??1)!==1&&rx;if(wi||ws){X.current=!0,Jh(V,oe.current),hi.flushSync(()=>M(!1));return}if(_i){const tr=Math.max(0,lt-vn);V.style.top=ye.height>=Cn?"0":`${tr}px`,V.style.height=`${kt}px`,Ee.scrollTop=Ee.scrollHeight-Ee.clientHeight,I.current=Math.max(He,kt)}else V.style.bottom="0",I.current=Math.max(He,kt),Ee.scrollTop=er;if(xt){const tr=ye.top,ls=ye.height,uo=xt.top+xt.height/2,fo=ls>0?(uo-tr)/ls*100:50,nr=$y(fo,0,100);_e.style.setProperty("--transform-origin",`50% ${nr}%`)}(I.current===lt||kt>=me)&&(H.current=!0),w(),setTimeout(()=>{X.current=!0})}finally{ne()}})}},[f,Y,V,q,y,b,d,w,R,M,se,L,j,U]),_.useEffect(()=>{if(!R||!V||!Y)return;const _e=un(V);function ne(pe){g(!1,Yt(T8,pe))}return _e.addEventListener("resize",ne),()=>{_e.removeEventListener("resize",ne)}},[g,R,V,Y]);const he={...U?{role:"presentation","aria-orientation":void 0}:{role:"listbox","aria-multiselectable":S||void 0,id:`${Q}-list`},onKeyDown(_e){x.current=!0,A&&nk.has(_e.key)&&_e.stopPropagation()},onMouseMove(){x.current=!1},onPointerLeave(_e){if(!C||QA(_e)||_e.pointerType==="touch")return;const ne=_e.currentTarget;z.start(0,()=>{f.set("activeIndex",null),ne.focus({preventScroll:!0})})},onScroll(_e){U||de(_e.currentTarget)},...R&&{style:U?{height:"100%"}:ZG}},Me=zt("div",t,{ref:[n,d],state:xe,stateAttributesMapping:uZ,props:[D,he,kp(K),{className:!U&&R?UC.className:void 0},l]});return h.jsxs(_.Fragment,{children:[!B&&UC.getElement(G),h.jsx(RA,{context:P,modal:!1,disabled:!ee,returnFocus:a,restoreFocus:!0,children:Me})]})});function HC(e){const t=e.maxHeight||"";return t.endsWith("px")&&parseFloat(t)||1/0}function qC(e){return Math.max(0,e.scrollHeight-e.clientHeight)}const VC=[["transform","none"],["scale","1"],["translate","0 0"]];function dZ(e){const{style:t}=e,n={};for(const[s,i]of VC)n[s]=t.getPropertyValue(s),t.setProperty(s,i,"important");return()=>{for(const[s]of VC){const i=n[s];i?t.setProperty(s,i):t.removeProperty(s)}}}let rk=(function(e){return e[e.None=0]="None",e[e.GuessFromOrder=1]="GuessFromOrder",e})({});function px(e={}){const{label:t,metadata:n,textRef:s,indexGuessBehavior:i,index:a}=e,{register:l,unregister:f,subscribeMapChange:d,elementsRef:p,labelsRef:g,nextIndexRef:y}=HG(),b=_.useRef(-1),[x,S]=_.useState(a??(i===rk.GuessFromOrder?()=>{if(b.current===-1){const C=y.current;y.current+=1,b.current=C}return b.current}:-1)),w=_.useRef(null),T=_.useCallback(C=>{if(w.current=C,x!==-1&&C!==null&&(p.current[x]=C,g)){const k=t!==void 0;g.current[x]=k?t:s?.current?.textContent??C.textContent}},[x,p,g,t,s]);return Le(()=>{if(a!=null)return;const C=w.current;if(C)return l(C,n),()=>{f(C)}},[a,l,f,n]),Le(()=>{if(a==null)return d(C=>{const k=w.current?C.get(w.current)?.index:null;k!=null&&S(k)})},[a,d,S]),_.useMemo(()=>({ref:T,index:x}),[x,T])}const hZ=_.createContext(void 0),pZ=_.memo(_.forwardRef(function(t,n){const{render:s,className:i,value:a=null,label:l,disabled:f=!1,nativeButton:d=!1,...p}=t,g=_.useRef(null),y=px({label:l,textRef:g,indexGuessBehavior:rk.GuessFromOrder}),{store:b,getItemProps:x,setOpen:S,setValue:w,selectionRef:T,typingRef:C,valuesRef:k,keyboardActiveRef:N,multiple:R,highlightItemOnHover:M}=Ju(),L=rs(),j=at(b,it.isActive,y.index),A=at(b,it.isSelected,y.index,a),P=at(b,it.isSelectedByFocus,y.index),G=at(b,it.isItemEqualToValue),B=y.index,z=B!==-1,Q=_.useRef(null),Y=Jo(B);Le(()=>{if(!z)return;const se=k.current;return se[B]=a,()=>{delete se[B]}},[z,B,a,k]),Le(()=>{if(!z)return;const se=b.state.value;let de=se;R&&Array.isArray(se)&&se.length>0&&(de=se[se.length-1]),de!==void 0&&Bc(a,de,G)&&b.set("selectedIndex",B)},[z,B,R,G,b,a]);const ee={disabled:f,selected:A,highlighted:j},D=x({active:j,selected:A});D.onFocus=void 0,D.id=void 0;const K=_.useRef(null),q=_.useRef("mouse"),V=_.useRef(!1),{getButtonProps:U,buttonRef:I}=el({disabled:f,focusableWhenDisabled:!0,native:d});function H(se){const de=b.state.value;if(R){const xe=Array.isArray(de)?de:[],he=A?TG(xe,a,G):[...xe,a];w(he,Yt(Ny,se))}else w(a,Yt(Ny,se)),S(!1,Yt(Ny,se))}const W={role:"option","aria-selected":A,tabIndex:j?0:-1,onFocus(){b.set("activeIndex",B)},onMouseEnter(){!N.current&&b.state.selectedIndex===null&&M&&b.set("activeIndex",B)},onMouseMove(){M&&b.set("activeIndex",B)},onMouseLeave(se){!M||N.current||QA(se)||L.start(0,()=>{b.state.activeIndex===B&&b.set("activeIndex",null)})},onTouchStart(){T.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1}},onKeyDown(se){K.current=se.key,b.set("activeIndex",B)},onClick(se){V.current=!1,!(se.type==="keydown"&&K.current===null)&&(f||K.current===" "&&C.current||q.current!=="touch"&&!j||(K.current=null,H(se.nativeEvent)))},onPointerEnter(se){q.current=se.pointerType},onPointerDown(se){q.current=se.pointerType,V.current=!0},onMouseUp(se){if(f)return;if(V.current){V.current=!1;return}const de=!T.current.allowSelectedMouseUp&&A,xe=!T.current.allowUnselectedMouseUp&&!A;de||xe||q.current!=="touch"&&!j||H(se.nativeEvent)}},X=zt("div",t,{ref:[I,n,y.ref,Q],state:ee,props:[D,W,p,U]}),oe=_.useMemo(()=>({selected:A,indexRef:Y,textRef:g,selectedByFocus:P,hasRegistered:z}),[A,Y,g,P,z]);return h.jsx(hZ.Provider,{value:oe,children:X})})),mZ=_.forwardRef(({className:e,children:t,...n},s)=>h.jsx(IG,{ref:s,className:ge("inline-flex items-center justify-between bg-surface border border-border rounded-md px-3 py-1.5 font-mono text-[12px] text-foreground cursor-pointer hover:border-border-bright transition",e),...n,children:t}));mZ.displayName="SelectTrigger";const gZ=_.forwardRef(({className:e,portalProps:t,positionerProps:n,...s},i)=>h.jsx(DG,{...t,children:h.jsx(XG,{...n,children:h.jsx(fZ,{ref:i,className:ge("bg-panel border border-border rounded-md py-1 shadow-lg z-50",e),...s})})}));gZ.displayName="SelectContent";const yZ=_.forwardRef(({className:e,...t},n)=>h.jsx(pZ,{ref:n,className:ge("font-mono text-[11px] px-3 py-1.5 text-neutral-400 cursor-pointer hover:bg-white/[0.03] hover:text-white data-[highlighted]:bg-white/[0.03] data-[highlighted]:text-white outline-none",e),...t}));yZ.displayName="SelectItem";const vZ=_.forwardRef(({className:e,...t},n)=>h.jsx("textarea",{ref:n,className:ge("bg-surface border border-border rounded-md px-3 py-2 font-mono text-[12px] text-foreground outline-none w-full transition focus:border-flow placeholder:text-neutral-600 resize-none min-h-[80px]",e),...t}));vZ.displayName="Textarea";const sk=_.createContext(void 0);function bZ(e=!0){const t=_.useContext(sk);if(t===void 0&&!e)throw new Error(yn(7));return t}function ok(e={}){const{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:s}=Mj(),{ref:i,index:a}=px(e),l=n===a,f=_.useRef(null),d=so(i,f);return{compositeProps:_.useMemo(()=>({tabIndex:l?0:-1,onFocus(){s(a)},onMouseMove(){const g=f.current;if(!t||!g)return;const y=g.hasAttribute("disabled")||g.ariaDisabled==="true";!l&&!y&&g.focus()}}),[l,s,a,t]),compositeRef:d,index:a}}function xZ(e){const{render:t,className:n,state:s=an,props:i=Nu,refs:a=Nu,metadata:l,stateAttributesMapping:f,tag:d="div",...p}=e,{compositeProps:g,compositeRef:y}=ok({metadata:l});return zt(d,e,{state:s,ref:[...a,y],props:[g,...i,p],stateAttributesMapping:f})}const SZ=_.forwardRef(function(t,n){const{className:s,defaultPressed:i=!1,disabled:a=!1,form:l,onPressedChange:f,pressed:d,render:p,type:g,value:y,nativeButton:b=!0,...x}=t,S=br(y||void 0),w=bZ(),T=w?.value??[],C=w?void 0:i,k=(a||w?.disabled)??!1,[N,R]=yp({controlled:w?S!==void 0&&T.indexOf(S)>-1:d,default:C,name:"Toggle",state:"pressed"}),M=Ae((z,Q)=>{S&&w?.setGroupValue?.(S,z,Q),f?.(z,Q)}),{getButtonProps:L,buttonRef:j}=el({disabled:k,native:b}),A={disabled:k,pressed:N},P=[j,n],G=[{"aria-pressed":N,onClick(z){const Q=!N,Y=Yt(ii,z.nativeEvent);M(Q,Y),!Y.isCanceled&&R(Q)}},x,L],B=zt("button",t,{enabled:!w,state:A,ref:P,props:G});return w?h.jsx(xZ,{tag:"button",render:p,className:s,state:A,refs:P,props:G}):B}),Dr=_.forwardRef(({className:e,...t},n)=>h.jsx(SZ,{ref:n,className:ge("font-mono text-[10px] text-neutral-500 border border-transparent rounded-sm px-2.5 py-1 cursor-pointer transition-all hover:text-neutral-300 data-[pressed]:text-white data-[pressed]:border-border-bright data-[pressed]:bg-white/[0.03]",e),...t}));Dr.displayName="Toggle";function _Z(e){return e==null||e.hasAttribute("disabled")||e.getAttribute("aria-disabled")==="true"}const ik="data-composite-item-active",wZ=[];function EZ(e){const{itemSizes:t,cols:n=1,loopFocus:s=!0,dense:i=!1,orientation:a="both",direction:l,highlightedIndex:f,onHighlightedIndexChange:d,rootRef:p,enableHomeAndEndKeys:g=!1,stopEventPropagation:y=!1,disabledIndices:b,modifierKeys:x=wZ}=e,[S,w]=_.useState(0),T=n>1,C=_.useRef(null),k=so(C,p),N=_.useRef([]),R=_.useRef(!1),M=f??S,L=Ae((P,G=!1)=>{if((d??w)(P),G){const B=N.current[P];BC(C.current,B,l,a)}}),j=Ae(P=>{if(P.size===0||R.current)return;R.current=!0;const G=Array.from(P.keys()),B=G.find(Q=>Q?.hasAttribute(ik))??null,z=B?G.indexOf(B):-1;z!==-1&&L(z),BC(C.current,B,l,a)}),A=_.useMemo(()=>({"aria-orientation":a==="both"?void 0:a,ref:k,onFocus(P){!C.current||!$C(P.target)||P.target.setSelectionRange(0,P.target.value.length??0)},onKeyDown(P){const G=g?eZ:tk;if(!G.has(P.key)||TZ(P,x)||!C.current)return;const z=l==="rtl",Q=z?ku:Tc,Y={horizontal:Q,vertical:Qi,both:Q}[a],ee=z?Tc:ku,D={horizontal:ee,vertical:Ec,both:ee}[a];if($C(P.target)&&!_Z(P.target)){const W=P.target.selectionStart,X=P.target.selectionEnd,oe=P.target.value??"";if(W==null||P.shiftKey||W!==X||P.key!==D&&W<oe.length||P.key!==Y&&W>0)return}let K=M;const q=UV(N,b),V=$V(N,b);if(T){const W=t||Array.from({length:N.current.length},()=>({width:1,height:1})),X=FV(W,n,i),oe=X.findIndex(de=>de!=null&&!pu(N,de,b)),se=X.reduce((de,xe,he)=>xe!=null&&!pu(N,xe,b)?he:de,-1);K=X[BV({current:X.map(de=>de?N.current[de]:null)},{event:P,orientation:a,loopFocus:s,cols:n,disabledIndices:qV([...b||N.current.map((de,xe)=>pu(N,xe)?xe:void 0),void 0],X),minIndex:oe,maxIndex:se,prevIndex:HV(M>V?q:M,W,X,n,P.key===Qi?"bl":P.key===Tc?"tr":"tl"),rtl:z})]}const U={horizontal:[Q],vertical:[Qi],both:[Q,Qi]}[a],I={horizontal:[ee],vertical:[Ec],both:[ee,Ec]}[a],H=T?G:{horizontal:g?WG:JA,vertical:g?JG:ek,both:G}[a];g&&(P.key===ef?K=q:P.key===tf&&(K=V)),K===M&&(U.includes(P.key)||I.includes(P.key))&&(s&&K===V&&U.includes(P.key)?K=q:s&&K===q&&I.includes(P.key)?K=V:K=fr(N,{startingIndex:K,decrement:I.includes(P.key),disabledIndices:b})),K!==M&&!lh(N,K)&&(y&&P.stopPropagation(),H.has(P.key)&&P.preventDefault(),L(K,!0),queueMicrotask(()=>{N.current[K]?.focus()}))}}),[n,i,l,b,N,g,M,T,t,s,k,x,L,a,y]);return _.useMemo(()=>({props:A,highlightedIndex:M,onHighlightedIndexChange:L,elementsRef:N,disabledIndices:b,onMapChange:j,relayKeyboardEvent:A.onKeyDown}),[A,M,L,N,b,j])}function TZ(e,t){for(const n of oZ.values())if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function ak(e){const{render:t,className:n,refs:s=Nu,props:i=Nu,state:a=an,stateAttributesMapping:l,highlightedIndex:f,onHighlightedIndexChange:d,orientation:p,dense:g,itemSizes:y,loopFocus:b,cols:x,enableHomeAndEndKeys:S,onMapChange:w,stopEventPropagation:T=!0,rootRef:C,disabledIndices:k,modifierKeys:N,highlightItemOnHover:R=!1,tag:M="div",...L}=e,j=UA(),{props:A,highlightedIndex:P,onHighlightedIndexChange:G,elementsRef:B,onMapChange:z,relayKeyboardEvent:Q}=EZ({itemSizes:y,cols:x,loopFocus:b,dense:g,orientation:p,highlightedIndex:f,onHighlightedIndexChange:d,rootRef:C,stopEventPropagation:T,enableHomeAndEndKeys:S,direction:j,disabledIndices:k,modifierKeys:N}),Y=zt(M,e,{state:a,ref:s,props:[A,...i,L],stateAttributesMapping:l}),ee=_.useMemo(()=>({highlightedIndex:P,onHighlightedIndexChange:G,highlightItemOnHover:R,relayKeyboardEvent:Q}),[P,G,R,Q]);return h.jsx(Oj.Provider,{value:ee,children:h.jsx(ZA,{elementsRef:B,onMapChange:D=>{w?.(D),z(D)},children:Y})})}let CZ=(function(e){return e.disabled="data-disabled",e.orientation="data-orientation",e.multiple="data-multiple",e})({});const KC={multiple(e){return e?{[CZ.multiple]:""}:null}},RZ=_.forwardRef(function(t,n){const{defaultValue:s,disabled:i=!1,loopFocus:a=!0,onValueChange:l,orientation:f="horizontal",multiple:d=!1,value:p,className:g,render:y,...b}=t,x=WA(),S=_.useMemo(()=>{if(p===void 0)return s??[]},[p,s]),w=_.useMemo(()=>p!==void 0||s!==void 0,[p,s]),T=(x?.disabled??!1)||i,[C,k]=yp({controlled:p,default:S,name:"ToggleGroup",state:"value"}),N=Ae((A,P,G)=>{let B;if(d?(B=C.slice(),P?B.push(A):B.splice(C.indexOf(A),1)):B=P?[A]:[],Array.isArray(B)){if(l?.(B,G),G.isCanceled)return;k(B)}}),R={disabled:T,multiple:d,orientation:f},M=_.useMemo(()=>({disabled:T,orientation:f,setGroupValue:N,value:C,isValueInitialized:w}),[T,f,N,C,w]),L={role:"group"},j=zt("div",t,{enabled:!!x,state:R,ref:n,props:[L,b],stateAttributesMapping:KC});return h.jsx(sk.Provider,{value:M,children:x?j:h.jsx(ak,{render:y,className:g,state:R,refs:[n],props:[L,b],stateAttributesMapping:KC,loopFocus:a,enableHomeAndEndKeys:!0})})}),hh=_.forwardRef(({className:e,...t},n)=>h.jsx(RZ,{ref:n,className:ge("flex items-center gap-0.5",e),...t}));hh.displayName="ToggleGroup";const NZ=ge(Kj({variant:"secondary",size:"sm"}),"h-7 whitespace-nowrap uppercase tracking-[0.08em] leading-none no-underline");function ck({active:e,onClick:t,children:n,className:s}){return h.jsxs("button",{type:"button",onClick:t,className:ge("font-mono text-[10px] tracking-[1.5px] uppercase bg-transparent border-none px-3.5 py-1 cursor-pointer relative transition-colors",e?"text-white":"text-neutral-500 hover:text-neutral-300",s),children:[n,e&&h.jsx("span",{className:"absolute -bottom-2.5 left-1/2 -translate-x-1/2 w-4 h-0.5 bg-flow rounded-sm shadow-[0_0_8px_rgba(59,130,246,0.5)]"})]})}function jZ({items:e,activeId:t,onItemChange:n,renderItem:s,className:i}){return h.jsx("div",{className:ge("flex items-center gap-0.5",i),children:e.map(a=>{const l=a.id===t,f=()=>n?.(a.id);return s?h.jsx("span",{children:s(a,{active:l,onClick:f})},a.id):h.jsx(ck,{active:l,onClick:f,children:a.label},a.id)})})}const AZ=mi("rounded-full inline-block flex-shrink-0",{variants:{color:{healthy:"bg-healthy",syncing:"bg-syncing",offline:"bg-offline",flow:"bg-flow",relay:"bg-relay",encrypt:"bg-encrypt",muted:"bg-neutral-500"},size:{sm:"w-1.5 h-1.5",md:"w-2 h-2",lg:"w-2.5 h-2.5"},glow:{true:"",false:""}},defaultVariants:{color:"healthy",size:"sm",glow:!1}}),kZ={healthy:"0 0 6px #22c55e",syncing:"0 0 6px #f59e0b",offline:"0 0 6px #ef4444",flow:"0 0 6px #3b82f6",relay:"0 0 6px #8b5cf6",encrypt:"0 0 6px #f472b6",muted:"none"};function OZ({color:e,size:t,glow:n,pulse:s,className:i}){return h.jsx("span",{className:ge(AZ({color:e,size:t,glow:n}),s&&"dot-pulse",i),style:n?{boxShadow:kZ[e??"healthy"]}:void 0})}const MZ="0.0.6-86",IZ={version:MZ},PZ=IZ.version;function DZ({label:e,className:t}){return h.jsxs("div",{className:ge("flex items-center gap-3",t),children:[h.jsx(OZ,{color:"healthy",size:"md",glow:!0}),h.jsx("span",{className:"font-display font-bold text-white text-sm tracking-tight",children:"syncular"}),e&&h.jsx("span",{className:"font-mono text-[9px] text-neutral-600 uppercase tracking-widest",children:e}),h.jsxs("span",{className:"font-mono text-[9px] text-neutral-600 tracking-wider",children:["v",PZ]})]})}function zZ({brand:e,center:t,right:n,className:s}){return h.jsxs(h.Fragment,{children:[h.jsx("div",{"aria-hidden":"true",className:"h-[42px] shrink-0"}),h.jsxs("nav",{className:ge("fixed top-0 left-0 right-0 z-100 h-[42px] border-b border-border bg-surface/88 backdrop-blur-lg flex items-center justify-between px-5",s),children:[h.jsx("div",{className:"flex items-center gap-3",children:e}),h.jsx("div",{className:"flex items-center gap-0.5",children:t}),h.jsx("div",{className:"flex items-center gap-2",children:n})]})]})}const LZ=mi("border rounded-lg p-3 font-mono text-[11px]",{variants:{variant:{default:"border-border bg-panel",destructive:"border-offline/20 bg-offline/5 text-offline"}},defaultVariants:{variant:"default"}}),In=_.forwardRef(({className:e,variant:t,...n},s)=>h.jsx("div",{ref:s,role:"alert",className:ge(LZ({variant:t,className:e})),...n}));In.displayName="Alert";const nf=_.forwardRef(({className:e,...t},n)=>h.jsx("h5",{ref:n,className:ge("font-medium text-white mb-1",e),...t}));nf.displayName="AlertTitle";const Pn=_.forwardRef(({className:e,...t},n)=>h.jsx("p",{ref:n,className:ge("text-neutral-400",e),...t}));Pn.displayName="AlertDescription";const lk=_.createContext(void 0);function al(e){const t=_.useContext(lk);if(e===!1&&t===void 0)throw new Error(yn(27));return t}const UZ={...il,...va},mx=_.forwardRef(function(t,n){const{render:s,className:i,forceRender:a=!1,...l}=t,{store:f}=al(),d=f.useState("open"),p=f.useState("nested"),g=f.useState("mounted"),y=f.useState("transitionStatus");return zt("div",t,{state:{open:d,transitionStatus:y},ref:[f.context.backdropRef,n],stateAttributesMapping:UZ,props:[{role:"presentation",hidden:!g,style:{userSelect:"none",WebkitUserSelect:"none"}},l],enabled:a||!p})}),uk=_.forwardRef(function(t,n){const{render:s,className:i,id:a,...l}=t,{store:f}=al(),d=br(a);return f.useSyncedValueWithCleanup("descriptionElementId",d),zt("p",t,{ref:n,props:[{id:d},l]})});let $Z=(function(e){return e.nestedDialogs="--nested-dialogs",e})({}),BZ=(function(e){return e[e.open=Xi.open]="open",e[e.closed=Xi.closed]="closed",e[e.startingStyle=Xi.startingStyle]="startingStyle",e[e.endingStyle=Xi.endingStyle]="endingStyle",e.nested="data-nested",e.nestedDialogOpen="data-nested-dialog-open",e})({});const fk=_.createContext(void 0);function FZ(){const e=_.useContext(fk);if(e===void 0)throw new Error(yn(26));return e}const HZ={...il,...va,nestedDialogOpen(e){return e?{[BZ.nestedDialogOpen]:""}:null}},dk=_.forwardRef(function(t,n){const{className:s,finalFocus:i,initialFocus:a,render:l,...f}=t,{store:d}=al(),p=d.useState("descriptionElementId"),g=d.useState("disablePointerDismissal"),y=d.useState("floatingRootContext"),b=d.useState("popupProps"),x=d.useState("modal"),S=d.useState("mounted"),w=d.useState("nested"),T=d.useState("nestedOpenDialogCount"),C=d.useState("open"),k=d.useState("openMethod"),N=d.useState("titleElementId"),R=d.useState("transitionStatus"),M=d.useState("role");FZ(),ba({open:C,ref:d.context.popupRef,onComplete(){C&&d.context.onOpenChangeComplete?.(!0)}});function L(B){return B==="touch"?d.context.popupRef.current:!0}const j=a===void 0?L:a,A=T>0,G=zt("div",t,{state:{open:C,nested:w,transitionStatus:R,nestedDialogOpen:A},props:[b,{"aria-labelledby":N??void 0,"aria-describedby":p??void 0,role:M,tabIndex:-1,hidden:!S,onKeyDown(B){nk.has(B.key)&&B.stopPropagation()},style:{[$Z.nestedDialogs]:T}},f],ref:[n,d.context.popupRef,d.useStateSetter("popupElement")],stateAttributesMapping:HZ});return h.jsx(RA,{context:y,openInteractionType:k,disabled:!S,closeOnFocusOut:!g,initialFocus:j,returnFocus:i,modal:x!==!1,restoreFocus:"popup",children:G})}),hk=_.forwardRef(function(t,n){const{keepMounted:s=!1,...i}=t,{store:a}=al(),l=a.useState("mounted"),f=a.useState("modal"),d=a.useState("open");return l||s?h.jsx(fk.Provider,{value:s,children:h.jsxs(CA,{ref:n,...i,children:[l&&f===!0&&h.jsx(XA,{ref:a.context.internalBackdropRef,inert:hx(!d)}),t.children]})}):null});function qZ(e){const{store:t,parentContext:n,actionsRef:s}=e,i=t.useState("open"),a=t.useState("disablePointerDismissal"),l=t.useState("modal"),f=t.useState("popupElement"),{openMethod:d,triggerProps:p,reset:g}=AG(i);x7(t);const{forceUnmount:y}=S7(i,t,()=>{g()}),b=Ae(G=>{const B=Yt(G);return B.preventUnmountOnClose=()=>{t.set("preventUnmountingOnClose",!0)},B}),x=_.useCallback(()=>{t.setOpen(!1,b(E8))},[t,b]);_.useImperativeHandle(s,()=>({unmount:y,close:x}),[y,x]);const S=R7({popupStore:t,onOpenChange:t.setOpen,treatPopupAsFloatingElement:!0,noEmit:!0}),[w,T]=_.useState(0),C=w===0,k=D7(S),N=c7(S,{outsidePressEvent(){return t.context.internalBackdropRef.current||t.context.backdropRef.current?"intentional":{mouse:l==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}},outsidePress(G){if(!t.context.outsidePressEnabledRef.current||"button"in G&&G.button!==0||"touches"in G&&G.touches.length!==1)return!1;const B=Ur(G);if(C&&!a){const z=B;return l&&(t.context.internalBackdropRef.current||t.context.backdropRef.current)?t.context.internalBackdropRef.current===z||t.context.backdropRef.current===z||Ot(z,f)&&!z?.hasAttribute("data-base-ui-portal"):!0}return!1},escapeKey:C});KA(i&&l===!0,f);const{getReferenceProps:R,getFloatingProps:M,getTriggerProps:L}=I7([k,N]);t.useContextCallback("onNestedDialogOpen",G=>{T(G+1)}),t.useContextCallback("onNestedDialogClose",()=>{T(0)}),_.useEffect(()=>(n?.onNestedDialogOpen&&i&&n.onNestedDialogOpen(w),n?.onNestedDialogClose&&!i&&n.onNestedDialogClose(),()=>{n?.onNestedDialogClose&&i&&n.onNestedDialogClose()}),[i,n,w]);const j=_.useMemo(()=>R(p),[R,p]),A=_.useMemo(()=>L(p),[L,p]),P=_.useMemo(()=>M(),[M]);t.useSyncedValues({openMethod:d,activeTriggerProps:j,inactiveTriggerProps:A,popupProps:P,floatingRootContext:S,nestedOpenDialogCount:w})}const VZ={...E7,modal:Pe(e=>e.modal),nested:Pe(e=>e.nested),nestedOpenDialogCount:Pe(e=>e.nestedOpenDialogCount),disablePointerDismissal:Pe(e=>e.disablePointerDismissal),openMethod:Pe(e=>e.openMethod),descriptionElementId:Pe(e=>e.descriptionElementId),titleElementId:Pe(e=>e.titleElementId),viewportElement:Pe(e=>e.viewportElement),role:Pe(e=>e.role)};class KZ extends DA{constructor(t){super(GZ(t),{popupRef:_.createRef(),backdropRef:_.createRef(),internalBackdropRef:_.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:new fx,onOpenChange:void 0,onOpenChangeComplete:void 0},VZ)}setOpen=(t,n)=>{if(n.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},!t&&n.trigger==null&&this.state.activeTriggerId!=null&&(n.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(t,n),n.isCanceled)return;const s={open:t,nativeEvent:n.event,reason:n.reason,nested:this.state.nested};this.state.floatingRootContext.context.events?.emit("openchange",s);const i={open:t},a=n.trigger?.id??null;(a||t)&&(i.activeTriggerId=a,i.activeTriggerElement=n.trigger??null),this.update(i)}}function GZ(e={}){return{...w7(),modal:!0,disablePointerDismissal:!1,popupElement:null,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,role:"dialog",...e}}function ZZ(e){const{children:t,open:n,defaultOpen:s=!1,onOpenChange:i,onOpenChangeComplete:a,disablePointerDismissal:l=!1,modal:f=!0,actionsRef:d,handle:p,triggerId:g,defaultTriggerId:y=null}=e,b=al(!0),x=!!b,S=zn(()=>p?.store??new KZ({open:s,openProp:n,activeTriggerId:y,triggerIdProp:g,modal:f,disablePointerDismissal:l,nested:x})).current;uV(()=>{n===void 0&&S.state.open===!1&&s===!0&&S.update({open:!0,activeTriggerId:y})}),S.useControlledProp("openProp",n),S.useControlledProp("triggerIdProp",g),S.useSyncedValues({disablePointerDismissal:l,nested:x,modal:f}),S.useContextCallback("onOpenChange",i),S.useContextCallback("onOpenChangeComplete",a);const w=S.useState("payload");qZ({store:S,actionsRef:d,parentContext:b?.store.context});const T=_.useMemo(()=>({store:S}),[S]);return h.jsx(lk.Provider,{value:T,children:typeof t=="function"?t({payload:w}):t})}const pk=_.forwardRef(function(t,n){const{render:s,className:i,id:a,...l}=t,{store:f}=al(),d=br(a);return f.useSyncedValueWithCleanup("titleElementId",d),zt("h2",t,{ref:n,props:[{id:d},l]})}),$r=ZZ,YZ=_.forwardRef(({className:e,...t},n)=>h.jsx(mx,{ref:n,className:ge("fixed inset-0 z-50 bg-black/60 backdrop-blur-sm",e),...t}));YZ.displayName="DialogOverlay";const hr=_.forwardRef(({className:e,children:t,...n},s)=>h.jsxs(hk,{children:[h.jsx(mx,{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm"}),h.jsx(dk,{ref:s,className:ge("fixed z-50 top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-panel border border-border rounded-lg shadow-lg max-w-lg w-full p-0",e),...n,children:t})]}));hr.displayName="DialogContent";const pr=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("px-5 py-3 border-b border-border",e),...t}));pr.displayName="DialogHeader";const Nn=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("px-5 py-3 border-t border-border flex justify-end gap-2",e),...t}));Nn.displayName="DialogFooter";const mr=_.forwardRef(({className:e,...t},n)=>h.jsx(pk,{ref:n,className:ge("font-mono text-[10px] text-neutral-500 uppercase tracking-widest",e),...t}));mr.displayName="DialogTitle";const XZ=_.forwardRef(({className:e,...t},n)=>h.jsx(uk,{ref:n,className:ge("font-mono text-[10px] text-neutral-500",e),...t}));XZ.displayName="DialogDescription";const gx=_.forwardRef(({className:e,page:t,totalPages:n,totalItems:s,onPageChange:i,...a},l)=>h.jsxs("div",{ref:l,className:ge("px-5 py-2.5 border-t border-border flex items-center justify-between",e),...a,children:[h.jsxs("span",{className:"font-mono text-[10px] text-neutral-600",children:[s," items · Page ",t," of ",n]}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx(Oe,{size:"sm",variant:"default",disabled:t<=1,onClick:()=>i(t-1),children:"Prev"}),h.jsx(Oe,{size:"sm",variant:"default",disabled:t>=n,onClick:()=>i(t+1),children:"Next"})]})]}));gx.displayName="Pagination";const QZ=_.forwardRef(({className:e,orientation:t="horizontal",...n},s)=>h.jsx("hr",{ref:s,"aria-orientation":t==="vertical"?"vertical":void 0,className:ge("border-none m-0",t==="horizontal"?"h-px w-full bg-border":"w-px h-4 bg-border",e),...n}));QZ.displayName="Separator";const WZ=mi("fixed z-50 bg-panel shadow-lg overflow-auto",{variants:{side:{top:"top-0 left-0 w-full h-[400px] border-b border-border",right:"right-0 top-0 h-full w-[400px] border-l border-border",bottom:"bottom-0 left-0 w-full h-[400px] border-t border-border",left:"left-0 top-0 h-full w-[400px] border-r border-border"}},defaultVariants:{side:"right"}}),JZ=_.forwardRef(({className:e,side:t,children:n,...s},i)=>h.jsxs(hk,{children:[h.jsx(mx,{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm"}),h.jsx(dk,{ref:i,className:ge(WZ({side:t,className:e})),...s,children:n})]}));JZ.displayName="SheetContent";const eY=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("px-5 py-3 border-b border-border",e),...t}));eY.displayName="SheetHeader";const tY=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("px-5 py-3 border-t border-border flex justify-end gap-2",e),...t}));tY.displayName="SheetFooter";const nY=_.forwardRef(({className:e,...t},n)=>h.jsx(pk,{ref:n,className:ge("font-mono text-[10px] text-neutral-500 uppercase tracking-widest",e),...t}));nY.displayName="SheetTitle";const rY=_.forwardRef(({className:e,...t},n)=>h.jsx(uk,{ref:n,className:ge("text-sm text-neutral-400",e),...t}));rY.displayName="SheetDescription";const sY=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("rounded-md bg-neutral-800 animate-pulse",e),...t}));sY.displayName="Skeleton";const oY=_.createContext(void 0);function yx(){const e=_.useContext(oY);if(e===void 0)throw new Error(yn(64));return e}let iY=(function(e){return e.activationDirection="data-activation-direction",e.orientation="data-orientation",e})({});const mk={tabActivationDirection:e=>({[iY.activationDirection]:e})},gk=_.createContext(void 0);function aY(){const e=_.useContext(gk);if(e===void 0)throw new Error(yn(65));return e}const cY=_.forwardRef(function(t,n){const{className:s,disabled:i=!1,render:a,value:l,id:f,nativeButton:d=!0,...p}=t,{value:g,getTabPanelIdByValue:y,orientation:b}=yx(),{activateOnFocus:x,highlightedTabIndex:S,onTabActivation:w,setHighlightedTabIndex:T,tabsListElement:C}=aY(),k=br(f),N=_.useMemo(()=>({disabled:i,id:k,value:l}),[i,k,l]),{compositeProps:R,compositeRef:M,index:L}=ok({metadata:N}),j=l===g,A=_.useRef(!1);Le(()=>{if(A.current){A.current=!1;return}if(!(j&&L>-1&&S!==L))return;const V=C;if(V!=null){const U=Bo(Rt(V));if(U&&Ot(V,U))return}i||T(L)},[j,L,S,T,i,C]);const{getButtonProps:P,buttonRef:G}=el({disabled:i,native:d,focusableWhenDisabled:!0}),B=y(l),z=_.useRef(!1),Q=_.useRef(!1);function Y(V){j||i||w(l,Yt(ii,V.nativeEvent,void 0,{activationDirection:"none"}))}function ee(V){j||(L>-1&&!i&&T(L),!i&&x&&(!z.current||z.current&&Q.current)&&w(l,Yt(ii,V.nativeEvent,void 0,{activationDirection:"none"})))}function D(V){if(j||i)return;z.current=!0;function U(){z.current=!1,Q.current=!1}(!V.button||V.button===0)&&(Q.current=!0,Rt(V.currentTarget).addEventListener("pointerup",U,{once:!0}))}return zt("button",t,{state:{disabled:i,active:j,orientation:b},ref:[n,G,M],props:[R,{role:"tab","aria-controls":B,"aria-selected":j,id:k,onClick:Y,onFocus:ee,onPointerDown:D,[ik]:j?"":void 0,onKeyDownCapture(){A.current=!0}},p,P]})});let lY=(function(e){return e.index="data-index",e.activationDirection="data-activation-direction",e.orientation="data-orientation",e.hidden="data-hidden",e})({});const uY={...mk,...va},fY=_.forwardRef(function(t,n){const{className:s,value:i,render:a,keepMounted:l=!1,...f}=t,{value:d,getTabIdByPanelValue:p,orientation:g,tabActivationDirection:y,registerMountedTabPanel:b,unregisterMountedTabPanel:x}=yx(),S=br(),w=_.useMemo(()=>({id:S,value:i}),[S,i]),{ref:T,index:C}=px({metadata:w}),k=i===d,{mounted:N,transitionStatus:R,setMounted:M}=Ap(k),L=!N,j=p(i),A={hidden:L,orientation:g,tabActivationDirection:y,transitionStatus:R},P=_.useRef(null),G=zt("div",t,{state:A,ref:[n,T,P],props:[{"aria-labelledby":j,hidden:L,id:S,role:"tabpanel",tabIndex:k?0:-1,inert:hx(!k),[lY.index]:C},f],stateAttributesMapping:uY});return ba({open:k,ref:P,onComplete(){k||M(!1)}}),Le(()=>{if(!(L&&!l)&&S!=null)return b(i,S),()=>{x(i,S)}},[L,l,i,S,b,x]),l||N?G:null}),dY=_.forwardRef(function(t,n){const{activateOnFocus:s=!1,className:i,loopFocus:a=!0,render:l,...f}=t,{getTabElementBySelectedValue:d,onValueChange:p,orientation:g,value:y,setTabMap:b,tabActivationDirection:x}=yx(),[S,w]=_.useState(0),[T,C]=_.useState(null),k=hY(y,g,T,d),N=Ae((j,A)=>{if(j!==y){const P=k(j);A.activationDirection=P,p(j,A)}}),R={orientation:g,tabActivationDirection:x},M={"aria-orientation":g==="vertical"?"vertical":void 0,role:"tablist"},L=_.useMemo(()=>({activateOnFocus:s,highlightedTabIndex:S,onTabActivation:N,setHighlightedTabIndex:w,tabsListElement:T,value:y}),[s,S,N,w,T,y]);return h.jsx(gk.Provider,{value:L,children:h.jsx(ak,{render:l,className:i,state:R,refs:[n,C],props:[M,f],stateAttributesMapping:mk,highlightedIndex:S,enableHomeAndEndKeys:!0,loopFocus:a,orientation:g,onHighlightedIndexChange:w,onMapChange:b,disabledIndices:Nu})})});function GC(e,t){const{left:n,top:s}=e.getBoundingClientRect(),{left:i,top:a}=t.getBoundingClientRect(),l=n-i,f=s-a;return{left:l,top:f}}function hY(e,t,n,s){const[i,a]=_.useState(null);return Le(()=>{if(e==null||n==null){a(null);return}const l=s(e);if(l==null){a(null);return}const{left:f,top:d}=GC(l,n);a(t==="horizontal"?f:d)},[t,s,n,e]),_.useCallback(l=>{if(l===e)return"none";if(l==null)return a(null),"none";if(l!=null&&n!=null){const f=s(l);if(f!=null){const{left:d,top:p}=GC(f,n);if(i==null)return a(t==="horizontal"?d:p),"none";if(t==="horizontal"){if(d<i)return a(d),"left";if(d>i)return a(d),"right"}else{if(p<i)return a(p),"up";if(p>i)return a(p),"down"}}}return"none"},[s,t,i,n,e])}const pY=_.forwardRef(({className:e,...t},n)=>h.jsx(dY,{ref:n,className:ge("flex items-center gap-0.5",e),...t}));pY.displayName="TabsList";const mY=mi("inline-flex items-center justify-center cursor-pointer transition-all outline-none",{variants:{variant:{default:"font-mono text-[10px] text-neutral-500 border border-transparent rounded-sm px-2.5 py-1 hover:text-neutral-300 data-[selected]:text-white data-[selected]:border-border-bright data-[selected]:bg-white/[0.03]",pills:"font-mono text-[10px] text-neutral-500 border border-transparent rounded-full px-3 py-1 hover:text-neutral-300 data-[selected]:text-white data-[selected]:border-border-bright data-[selected]:bg-white/[0.03]"}},defaultVariants:{variant:"default"}}),gY=_.forwardRef(({className:e,variant:t,...n},s)=>h.jsx(cY,{ref:s,className:ge(mY({variant:t,className:e})),...n}));gY.displayName="TabsTrigger";const yY=_.forwardRef(({className:e,...t},n)=>h.jsx(fY,{ref:n,className:ge("outline-none",e),...t}));yY.displayName="TabsContent";const vY=_.forwardRef(({className:e,...t},n)=>h.jsx("p",{ref:n,className:ge("font-mono text-[11px] text-neutral-300",e),...t}));vY.displayName="Text";const bY=_.forwardRef(({className:e,...t},n)=>h.jsx("p",{ref:n,className:ge("font-mono text-[10px] text-neutral-500",e),...t}));bY.displayName="TextMuted";const xY=_.forwardRef(({className:e,...t},n)=>h.jsx("code",{ref:n,className:ge("font-mono text-[11px] text-white",e),...t}));xY.displayName="TextCode";const SY=_.forwardRef(({className:e,...t},n)=>h.jsx("span",{ref:n,className:ge("font-mono text-[9px] uppercase tracking-wider text-neutral-500",e),...t}));SY.displayName="TextLabel";const _Y=_.forwardRef(({className:e,...t},n)=>h.jsx("pre",{ref:n,className:ge("font-mono text-[11px] text-neutral-300 p-3 rounded border border-border bg-panel-alt overflow-x-auto",e),...t}));_Y.displayName="CodeBlock";function xa(e,t){const[n,s]=_.useState(()=>{if(typeof window>"u")return t;try{const a=window.localStorage.getItem(e);return a===null?t:JSON.parse(a)}catch{return t}});_.useEffect(()=>{try{n==null?window.localStorage.removeItem(e):window.localStorage.setItem(e,JSON.stringify(n))}catch{}},[e,n]);const i=_.useCallback(a=>{s(l=>typeof a=="function"?a(l):a)},[]);return[n,i]}const wY="console:instance-id";function Lt(){const[e,t]=xa(wY,""),n=e.trim();return _.useMemo(()=>({instanceId:n.length>0?n:void 0,rawInstanceId:e,setInstanceId:t,clearInstanceId:()=>t("")}),[n,e,t])}const Jn={stats:e=>["console","stats",e],timeseries:e=>["console","stats","timeseries",e],latency:e=>["console","stats","latency",e],commits:e=>["console","commits",e],commitDetail:(e,t,n)=>["console","commit-detail",e,t,n],timeline:e=>["console","timeline",e],clients:e=>["console","clients",e],eventDetail:(e,t,n)=>["console","event-detail",e,t,n],eventPayload:(e,t,n)=>["console","event-payload",e,t,n],handlers:e=>["console","handlers",e],prunePreview:e=>["console","prune","preview",e],operations:e=>["console","operations",e],apiKeys:e=>["console","api-keys",e],storage:e=>["console","storage",e]};function Si(e,t){return e===0?!1:e??t}function rf(e,t){return t?{...e,instanceId:t}:e}function Sa(e){return encodeURIComponent(String(e))}function Ln(e,t,n){const s=e.endsWith("/")?e.slice(0,-1):e,i=n?.toString();return`${s}${t}${i?`?${i}`:""}`}function sf(e={}){const t=Vt(),{instanceId:n}=Lt(),s=e.instanceId??n,i=rf(e.partitionId?{partitionId:e.partitionId}:{},s);return Wn({queryKey:Jn.stats({partitionId:e.partitionId,instanceId:s}),queryFn:()=>{if(!t)throw new Error("Not connected");return Xu(t.GET("/console/stats",{params:{query:i}}))},enabled:!!t,refetchInterval:Si(e.refetchIntervalMs,5e3)})}function EY(e={},t={}){const n=Vt(),{config:s}=Dt(),{instanceId:i}=Lt(),a=e.instanceId??i;return Wn({queryKey:Jn.timeseries({...e,instanceId:a}),queryFn:async()=>{if(!n||!s)throw new Error("Not connected");const l=new URLSearchParams;e.interval&&l.set("interval",e.interval),e.range&&l.set("range",e.range),e.partitionId&&l.set("partitionId",e.partitionId),a&&l.set("instanceId",a);const f=await fetch(`${s.serverUrl}/console/stats/timeseries?${l}`,{headers:{Authorization:`Bearer ${s.token}`}});if(!f.ok)throw new Error("Failed to fetch timeseries stats");return f.json()},enabled:(t.enabled??!0)&&!!n&&!!s,refetchInterval:Si(t.refetchIntervalMs,3e4)})}function TY(e={},t={}){const n=Vt(),{config:s}=Dt(),{instanceId:i}=Lt(),a=e.instanceId??i;return Wn({queryKey:Jn.latency({...e,instanceId:a}),queryFn:async()=>{if(!n||!s)throw new Error("Not connected");const l=new URLSearchParams;e.range&&l.set("range",e.range),e.partitionId&&l.set("partitionId",e.partitionId),a&&l.set("instanceId",a);const f=await fetch(`${s.serverUrl}/console/stats/latency?${l}`,{headers:{Authorization:`Bearer ${s.token}`}});if(!f.ok)throw new Error("Failed to fetch latency stats");return f.json()},enabled:(t.enabled??!0)&&!!n&&!!s,refetchInterval:Si(t.refetchIntervalMs,3e4)})}function CY(e={},t={}){const n=Vt(),{instanceId:s}=Lt(),i=e.instanceId??s,a=rf({limit:e.limit,offset:e.offset,partitionId:e.partitionId},i);return Wn({queryKey:Jn.commits({...e,instanceId:i}),queryFn:()=>{if(!n)throw new Error("Not connected");return Xu(n.GET("/console/commits",{params:{query:a}}))},enabled:(t.enabled??!0)&&!!n,refetchInterval:Si(t.refetchIntervalMs,1e4)})}function RY(e,t={}){const n=Vt(),{config:s}=Dt(),{instanceId:i}=Lt(),a=t.instanceId??i;return Wn({queryKey:Jn.commitDetail(e,t.partitionId,a),queryFn:async()=>{if(!n||!s)throw new Error("Not connected");if(e===void 0)throw new Error("Commit sequence is required");const l=new URLSearchParams;t.partitionId&&l.set("partitionId",t.partitionId),a&&l.set("instanceId",a);const f=l.toString(),d=await fetch(`${s.serverUrl}/console/commits/${Sa(e)}${f?`?${f}`:""}`,{headers:{Authorization:`Bearer ${s.token}`}});if(!d.ok)throw new Error("Failed to fetch commit detail");return d.json()},enabled:(t.enabled??!0)&&e!==void 0&&!!n})}function NY(e={},t={}){const n=Vt(),{instanceId:s}=Lt(),i=e.instanceId??s,a=rf({limit:e.limit,offset:e.offset,partitionId:e.partitionId,view:e.view,eventType:e.eventType,actorId:e.actorId,clientId:e.clientId,requestId:e.requestId,traceId:e.traceId,table:e.table,outcome:e.outcome,search:e.search,from:e.from,to:e.to},i);return Wn({queryKey:Jn.timeline({...e,instanceId:i}),queryFn:()=>{if(!n)throw new Error("Not connected");return Xu(n.GET("/console/timeline",{params:{query:a}}))},enabled:(t.enabled??!0)&&!!n,refetchInterval:Si(t.refetchIntervalMs,1e4)})}function yk(e={},t={}){const n=Vt(),{instanceId:s}=Lt(),i=e.instanceId??s,a=rf({limit:e.limit,offset:e.offset,partitionId:e.partitionId},i);return Wn({queryKey:Jn.clients({...e,instanceId:i}),queryFn:()=>{if(!n)throw new Error("Not connected");return Xu(n.GET("/console/clients",{params:{query:a}}))},enabled:(t.enabled??!0)&&!!n,refetchInterval:Si(t.refetchIntervalMs,1e4)})}function jY(e,t={}){const n=Vt(),{config:s}=Dt(),{instanceId:i}=Lt(),a=t.instanceId??i;return Wn({queryKey:Jn.eventDetail(e,t.partitionId,a),queryFn:async()=>{if(!n||!s)throw new Error("Not connected");if(e===void 0)throw new Error("Event id is required");const l=new URLSearchParams;t.partitionId&&l.set("partitionId",t.partitionId),a&&l.set("instanceId",a);const f=l.toString(),d=await fetch(`${s.serverUrl}/console/events/${Sa(e)}${f?`?${f}`:""}`,{headers:{Authorization:`Bearer ${s.token}`}});if(!d.ok)throw new Error("Failed to fetch event detail");return d.json()},enabled:(t.enabled??!0)&&e!==void 0&&!!n})}function AY(e,t={}){const n=Vt(),{config:s}=Dt(),{instanceId:i}=Lt(),a=t.instanceId??i;return Wn({queryKey:Jn.eventPayload(e,t.partitionId,a),queryFn:async()=>{if(!n||!s)throw new Error("Not connected");if(e===void 0)throw new Error("Event id is required");const l=new URLSearchParams;t.partitionId&&l.set("partitionId",t.partitionId),a&&l.set("instanceId",a);const f=l.toString(),d=await fetch(`${s.serverUrl}/console/events/${Sa(e)}/payload${f?`?${f}`:""}`,{headers:{Authorization:`Bearer ${s.token}`}});if(!d.ok)throw new Error("Failed to fetch event payload");return d.json()},enabled:(t.enabled??!0)&&e!==void 0&&!!n})}function kY(e={}){const t=Vt(),{config:n}=Dt(),{instanceId:s}=Lt(),i=e.instanceId??s;return Wn({queryKey:Jn.handlers(i),queryFn:async()=>{if(!t||!n)throw new Error("Not connected");const a=new URLSearchParams;i&&a.set("instanceId",i);const l=await fetch(Ln(n.serverUrl,"/console/handlers",a),{headers:{Authorization:`Bearer ${n.token}`}});if(!l.ok)throw new Error("Failed to fetch handlers");return l.json()},enabled:!!t&&!!n})}function OY(e={}){const t=Vt(),{config:n}=Dt(),{instanceId:s}=Lt(),i=e.instanceId??s;return Wn({queryKey:Jn.prunePreview(i),queryFn:async()=>{if(!t||!n)throw new Error("Not connected");const a=new URLSearchParams;i&&a.set("instanceId",i);const l=await fetch(Ln(n.serverUrl,"/console/prune/preview",a),{method:"POST",headers:{Authorization:`Bearer ${n.token}`}});if(!l.ok)throw new Error("Failed to fetch prune preview");return l.json()},enabled:!!t&&!!n&&(e.enabled??!0)})}function MY(e={},t={}){const n=Vt(),{instanceId:s}=Lt(),i=e.instanceId??s,a=rf({limit:e.limit,offset:e.offset,operationType:e.operationType,partitionId:e.partitionId},i);return Wn({queryKey:Jn.operations({...e,instanceId:i}),queryFn:()=>{if(!n)throw new Error("Not connected");return Xu(n.GET("/console/operations",{params:{query:a}}))},enabled:(t.enabled??!0)&&!!n,refetchInterval:Si(t.refetchIntervalMs,1e4)})}function IY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async({clientId:i,partitionId:a,instanceId:l})=>{if(!e||!t)throw new Error("Not connected");const f=l??n,d=new URLSearchParams;a&&d.set("partitionId",a),f&&d.set("instanceId",f);const p=await fetch(Ln(t.serverUrl,`/console/clients/${Sa(i)}`,d),{method:"DELETE",headers:{Authorization:`Bearer ${t.token}`}});if(!p.ok)throw new Error("Failed to evict client");return p.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","clients"]}),s.invalidateQueries({queryKey:["console","stats"]}),s.invalidateQueries({queryKey:["console","operations"]})}})}function PY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async()=>{if(!e||!t)throw new Error("Not connected");const i=new URLSearchParams;n&&i.set("instanceId",n);const a=await fetch(Ln(t.serverUrl,"/console/prune",i),{method:"POST",headers:{Authorization:`Bearer ${t.token}`}});if(!a.ok)throw new Error("Failed to prune");return a.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","stats"]}),s.invalidateQueries({queryKey:["console","commits"]}),s.invalidateQueries({queryKey:["console","timeline"]}),s.invalidateQueries({queryKey:["console","prune","preview"]}),s.invalidateQueries({queryKey:["console","operations"]})}})}function DY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async()=>{if(!e||!t)throw new Error("Not connected");const i=new URLSearchParams;n&&i.set("instanceId",n);const a=await fetch(Ln(t.serverUrl,"/console/compact",i),{method:"POST",headers:{Authorization:`Bearer ${t.token}`}});if(!a.ok)throw new Error("Failed to compact");return a.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","stats"]}),s.invalidateQueries({queryKey:["console","operations"]})}})}function zY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async i=>{if(!e||!t)throw new Error("Not connected");const a=i.instanceId??n,l=new URLSearchParams;a&&l.set("instanceId",a);const f=await fetch(Ln(t.serverUrl,"/console/notify-data-change",l),{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"Content-Type":"application/json"},body:JSON.stringify({tables:i.tables,partitionId:i.partitionId})});if(!f.ok)throw new Error("Failed to notify data change");return f.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","stats"]}),s.invalidateQueries({queryKey:["console","commits"]}),s.invalidateQueries({queryKey:["console","timeline"]}),s.invalidateQueries({queryKey:["console","operations"]})}})}function LY(e={}){const t=Vt(),{config:n}=Dt(),{instanceId:s}=Lt(),i=e.instanceId??s;return Wn({queryKey:Jn.apiKeys({...e,instanceId:i}),queryFn:async()=>{if(!t||!n)throw new Error("Not connected");const a=new URLSearchParams;e.limit!==void 0&&a.set("limit",String(e.limit)),e.offset!==void 0&&a.set("offset",String(e.offset)),e.type&&a.set("type",e.type),e.status&&a.set("status",e.status),e.expiresWithinDays!==void 0&&a.set("expiresWithinDays",String(e.expiresWithinDays)),i&&a.set("instanceId",i);const l=await fetch(Ln(n.serverUrl,"/console/api-keys",a),{headers:{Authorization:`Bearer ${n.token}`}});if(!l.ok)throw new Error("Failed to fetch API keys");return l.json()},enabled:!!t&&!!n})}function UY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async i=>{if(!e||!t)throw new Error("Not connected");const a=new URLSearchParams;n&&a.set("instanceId",n);const l=await fetch(Ln(t.serverUrl,"/console/api-keys",a),{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"Content-Type":"application/json"},body:JSON.stringify(i)});if(!l.ok)throw new Error("Failed to create API key");return l.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","api-keys"]})}})}function $Y(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async i=>{if(!e||!t)throw new Error("Not connected");const a=new URLSearchParams;n&&a.set("instanceId",n);const l=await fetch(Ln(t.serverUrl,`/console/api-keys/${Sa(i)}`,a),{method:"DELETE",headers:{Authorization:`Bearer ${t.token}`}});if(!l.ok)throw new Error("Failed to revoke API key");return l.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","api-keys"]})}})}function BY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async i=>{if(!e||!t)throw new Error("Not connected");const a=new URLSearchParams;n&&a.set("instanceId",n);const l=await fetch(Ln(t.serverUrl,"/console/api-keys/bulk-revoke",a),{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"Content-Type":"application/json"},body:JSON.stringify(i)});if(!l.ok)throw new Error("Failed to bulk revoke API keys");return l.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","api-keys"]})}})}function FY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async i=>{if(!e||!t)throw new Error("Not connected");const a=new URLSearchParams;n&&a.set("instanceId",n);const l=await fetch(Ln(t.serverUrl,`/console/api-keys/${Sa(i)}/rotate`,a),{method:"POST",headers:{Authorization:`Bearer ${t.token}`}});if(!l.ok)throw new Error("Failed to rotate API key");return l.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","api-keys"]})}})}function HY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async i=>{if(!e||!t)throw new Error("Not connected");const a=new URLSearchParams;n&&a.set("instanceId",n);const l=await fetch(Ln(t.serverUrl,`/console/api-keys/${Sa(i)}/rotate/stage`,a),{method:"POST",headers:{Authorization:`Bearer ${t.token}`}});if(!l.ok)throw new Error("Failed to stage-rotate API key");return l.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","api-keys"]})}})}function qY(e={}){const{config:t}=Dt();return Wn({queryKey:Jn.storage({prefix:e.prefix,cursor:e.cursor,limit:e.limit}),queryFn:async()=>{if(!t)throw new Error("Not connected");const n=new URLSearchParams;e.prefix&&n.set("prefix",e.prefix),e.cursor&&n.set("cursor",e.cursor),e.limit&&n.set("limit",String(e.limit));const s=await fetch(Ln(t.serverUrl,"/console/storage",n),{method:"GET",headers:{Authorization:`Bearer ${t.token}`}});if(!s.ok)throw new Error("Failed to list blobs");return s.json()},enabled:!!t,refetchInterval:Si(e.refetchIntervalMs,3e4)})}function VY(){const{config:e}=Dt(),t=_r();return is({mutationFn:async n=>{if(!e)throw new Error("Not connected");const s=encodeURIComponent(n),i=await fetch(Ln(e.serverUrl,`/console/storage/${s}`,new URLSearchParams),{method:"DELETE",headers:{Authorization:`Bearer ${e.token}`}});if(!i.ok)throw new Error("Failed to delete blob");return i.json()},onSuccess:()=>{t.invalidateQueries({queryKey:["console","storage"]})}})}function KY(){const{config:e}=Dt();return async t=>{if(!e)throw new Error("Not connected");const n=encodeURIComponent(t),s=await fetch(Ln(e.serverUrl,`/console/storage/${n}/download`,new URLSearchParams),{method:"GET",headers:{Authorization:`Bearer ${e.token}`}});if(!s.ok)throw new Error("Failed to download blob");const i=await s.blob(),a=URL.createObjectURL(i),l=document.createElement("a");l.href=a,l.download=t.split("/").pop()||t,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(a)}}const GY="console:partition-id";function of(){const[e,t]=xa(GY,""),n=e.trim();return _.useMemo(()=>({partitionId:n.length>0?n:void 0,rawPartitionId:e,setPartitionId:t,clearPartitionId:()=>t("")}),[n,e,t])}const ZC={refreshInterval:5,timeFormat:"relative",showSparklines:!0,pageSize:20};function af(){const[e,t]=xa("console:preferences",ZC);return{preferences:e,setPreferences:t,updatePreference:(i,a)=>{t(l=>({...l,[i]:a}))},resetPreferences:()=>{t(ZC)}}}const ZY=[{value:5,label:"5 seconds"},{value:10,label:"10 seconds"},{value:30,label:"30 seconds"},{value:60,label:"1 minute"},{value:0,label:"Manual only"}],YY=[{value:10,label:"10"},{value:20,label:"20"},{value:50,label:"50"},{value:100,label:"100"}],vx="syncular-console-root";function XY(e){e.classList.add(vx)}const QY=[{suffix:"",label:"Command"},{suffix:"/stream",label:"Stream"},{suffix:"/fleet",label:"Fleet"},{suffix:"/ops",label:"Ops"},{suffix:"/storage",label:"Storage"},{suffix:"/config",label:"Config"}];function WY(e){const t=e?.trim()??"";return!t||t==="/"?"":(t.startsWith("/")?t:`/${t}`).replace(/\/+$/g,"")}function By(e,t){return e?t?`${e}${t}`:e:t||"/"}function JY({basePath:e,appHref:t,modeBadge:n}){const{connect:s,config:i,isConnected:a,isConnecting:l}=Dt(),{preferences:f}=af(),{instanceId:d,rawInstanceId:p,setInstanceId:g,clearInstanceId:y}=Lt(),{partitionId:b,rawPartitionId:x,setPartitionId:S,clearPartitionId:w}=of(),T=vr({select:P=>P.location.pathname}),{data:C}=sf({refetchIntervalMs:f.refreshInterval*1e3,partitionId:b,instanceId:d}),k=WY(e),N=_.useMemo(()=>QY.map(P=>({...P,id:By(k,P.suffix)})),[k]),R=By(k,""),M=By(k,"/config"),L=l?"connecting":a?"connected":i?"disconnected":"not-configured",j=N.find(P=>P.suffix===""?T===R||T===`${R}/`:T.startsWith(P.id))?.id??R,A=C?[{label:"HEAD",value:`#${C.maxCommitSeq}`},{label:"COMMITS",value:`${C.commitCount}`},{label:"CHANGES",value:`${C.changeCount}`},{label:"CLIENTS",value:`${C.activeClientCount}/${C.clientCount}`}]:[];return h.jsxs("div",{className:`${vx} h-screen bg-background text-foreground flex flex-col`,children:[h.jsx(zZ,{brand:h.jsx(xc,{to:R,children:h.jsx(DZ,{label:"console"})}),center:h.jsx(jZ,{items:N,activeId:j,renderItem:(P,{active:G})=>h.jsx(xc,{to:P.id,children:h.jsx(ck,{active:G,children:P.label})},P.id)}),right:h.jsxs("div",{className:"flex items-center gap-2",children:[n?h.jsx(mn,{variant:"flow",className:"hidden md:inline-flex px-2 py-1 text-[10px]",children:n}):null,h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("span",{className:"font-mono text-[9px] text-neutral-500 uppercase tracking-wide",children:"Instance"}),h.jsx(Gn,{variant:"mono",value:p,onChange:P=>g(P.target.value),onBlur:P=>g(P.target.value.trim()),placeholder:"all",className:"h-7 w-[110px] px-2 py-1"}),d?h.jsx(Oe,{variant:"ghost",size:"sm",className:"h-7 px-2 text-[10px]",onClick:y,children:"All"}):null]}),h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("span",{className:"font-mono text-[9px] text-neutral-500 uppercase tracking-wide",children:"Partition"}),h.jsx(Gn,{variant:"mono",value:x,onChange:P=>S(P.target.value),onBlur:P=>S(P.target.value.trim()),placeholder:"all",className:"h-7 w-[110px] px-2 py-1"}),b?h.jsx(Oe,{variant:"ghost",size:"sm",className:"h-7 px-2 text-[10px]",onClick:w,children:"All"}):null]}),h.jsx(O8,{state:L}),h.jsx(xc,{to:M,children:h.jsx(Oe,{variant:T===M?"secondary":"ghost",size:"icon",children:h.jsx(Y8,{className:"h-3 w-3"})})}),t?h.jsxs("a",{href:t,className:NZ,children:[h.jsx(G8,{className:"h-3 w-3"}),"Go to app"]}):null]})}),h.jsx("main",{className:"flex-1 overflow-auto pb-[32px]",children:h.jsx("div",{className:"min-h-full",children:a||T===M?h.jsx("div",{style:{animation:"pageIn 0.3s ease-out"},children:h.jsx(WN,{})},T):h.jsx(eX,{configPath:M,hasSavedConfig:!!i,isConnecting:l,onConnect:()=>{s()}})})}),a&&h.jsx(qj,{isLive:a,metrics:A,uptime:"--"})]})}function eX({configPath:e,hasSavedConfig:t,isConnecting:n,onConnect:s}){return h.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[h.jsx("p",{className:"mb-4 text-foreground-muted",children:"Not connected to a @syncular server"}),h.jsxs("div",{className:"flex items-center gap-2",children:[t&&h.jsx(Oe,{variant:"default",onClick:s,disabled:n,children:n?"Connecting...":"Connect"}),h.jsx(xc,{to:e,children:h.jsx(Oe,{variant:"link",children:"Configure connection"})})]})]})}const lo=kH({component:JY});function tX(){return typeof window>"u"?!1:new URLSearchParams(window.location.search).get("swServer")==="1"}function nX(e={}){const{maxEvents:t=100,enabled:n=!0,staleAfterMs:s=65e3,replayLimit:i=100,partitionId:a,instanceId:l}=e,{config:f,isConnected:d}=Dt(),{instanceId:p}=Lt(),g=l??p,[y,b]=_.useState([]),[x,S]=_.useState(!1),[w,T]=_.useState("disconnected"),[C,k]=_.useState(null),N=_.useRef(null),R=_.useRef(null),M=_.useRef(null),L=_.useRef(0),j=_.useRef(0),A=_.useRef(null),P=_.useRef(null),G=_.useCallback(()=>{b([]),A.current=null,P.current=null},[]);return _.useEffect(()=>{if(!n||!d||!f?.serverUrl||!f?.token)return;let B=!1;const z=Number.isFinite(i)?Math.max(1,Math.min(500,Math.floor(i))):100;if(tX()||typeof WebSocket>"u"){T("connecting"),S(!1);let V=null,U=!1;const I=async()=>{if(!(B||U)){U=!0;try{const H=new URL(f.serverUrl,window.location.origin),W=H.pathname.endsWith("/")?H.pathname.slice(0,-1):H.pathname;H.pathname=`${W}/console/events`,H.search="",H.searchParams.set("limit",String(z)),H.searchParams.set("offset","0"),a&&H.searchParams.set("partitionId",a);const X=await fetch(H.toString(),{headers:{Authorization:`Bearer ${f.token}`}});if(!X.ok)throw new Error(`Live event polling failed (${X.status})`);const oe=await X.json(),de=(Array.isArray(oe.items)?oe.items:[]).filter(Me=>g?Me.instanceId===g:!0).sort((Me,_e)=>Me.eventId-_e.eventId),xe=P.current??-1,he=de.filter(Me=>Me.eventId>xe);if(he.length>0){const Me=he.map(ne=>({type:ne.eventType,timestamp:ne.createdAt,data:ne})).reverse();b(ne=>[...Me,...ne].slice(0,t));const _e=he[he.length-1];P.current=_e.eventId,A.current=_e.createdAt}else if(de.length>0){const Me=de[de.length-1];P.current=Math.max(P.current??-1,Me.eventId),A.current=Me.createdAt}k(null),S(!0),T("connected")}catch(H){B||(S(!1),T("disconnected"),k(H instanceof Error?H:new Error("Live event polling failed")))}finally{U=!1}}};return I(),V=setInterval(()=>{I()},2e3),()=>{B=!0,V&&clearInterval(V),S(!1),T("disconnected")}}const Y=()=>{R.current&&(clearTimeout(R.current),R.current=null)},ee=()=>{M.current&&(clearInterval(M.current),M.current=null)},D=()=>{if(B||R.current)return;L.current+=1;const V=Math.min(3e4,1e3*2**Math.max(0,L.current-1)),U=Math.floor(V*.2*Math.random()),I=V+U;R.current=setTimeout(()=>{R.current=null,B||q()},I)},K=()=>{j.current=Date.now(),S(!0),T("connected")},q=()=>{if(B)return;T("connecting"),Y();const V=(()=>{const I=new URL(f.serverUrl,window.location.origin);I.protocol=I.protocol==="https:"?"wss:":"ws:";const H=I.pathname.endsWith("/")?I.pathname.slice(0,-1):I.pathname;return I.pathname=`${H}/console/events/live`,I.search="",A.current&&I.searchParams.set("since",A.current),I.searchParams.set("replayLimit",String(z)),a&&I.searchParams.set("partitionId",a),g&&I.searchParams.set("instanceId",g),I.toString()})(),U=new WebSocket(V);N.current=U,U.onopen=()=>{if(B){U.close();return}L.current=0,k(null),T("connecting"),S(!1);try{U.send(JSON.stringify({type:"auth",token:f.token}))}catch{U.close();return}ee(),M.current=setInterval(()=>{const I=N.current;if(!I||I.readyState!==WebSocket.OPEN)return;const H=j.current;!H||Date.now()-H<=s||(S(!1),T("stale"),I.close())},1e3)},U.onclose=()=>{B||(S(!1),T("disconnected"),ee(),D())},U.onerror=()=>{B||k(new Error("WebSocket connection failed"))},U.onmessage=I=>{try{const H=JSON.parse(I.data),W=H.type;if(K(),W==="connected"||W==="heartbeat"||W==="auth_required")return;if(W==="error"){const de=typeof H.message=="string"?H.message:"Live events authentication failed";k(new Error(de));return}const X={type:W,timestamp:H.timestamp||new Date().toISOString(),data:H};if(a&&X.data.partitionId!==a||g&&X.data.instanceId!==g)return;const oe=Date.parse(A.current??""),se=Date.parse(X.timestamp);Number.isFinite(se)&&(!Number.isFinite(oe)||se>oe)&&(A.current=X.timestamp),b(de=>[X,...de].slice(0,t))}catch{}}};return q(),()=>{B=!0,Y(),ee(),N.current&&(N.current.close(),N.current=null),S(!1),T("disconnected")}},[n,d,f?.serverUrl,f?.token,t,a,g,i,s]),{events:y,isConnected:x,connectionState:w,error:C,clearEvents:G}}function rX(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async()=>{if(!e||!t)throw new Error("Not connected");const i=new URLSearchParams;n&&i.set("instanceId",n);const a=i.toString(),l=await fetch(`${t.serverUrl}/console/events${a?`?${a}`:""}`,{method:"DELETE",headers:{Authorization:`Bearer ${t.token}`}});if(!l.ok)throw new Error("Failed to clear events");return l.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","events"]})}})}const sX=_.createContext(null);function vk(){const[e,t]=xa("console:time-range","24h");return{range:e,setRange:t}}const oX=[{hint:"ios",type:"mobile"},{hint:"android",type:"mobile"},{hint:"mobile",type:"mobile"},{hint:"tablet",type:"tablet"},{hint:"desktop",type:"desktop"},{hint:"mac",type:"desktop"},{hint:"windows",type:"desktop"},{hint:"linux",type:"desktop"},{hint:"browser",type:"browser"},{hint:"web",type:"browser"},{hint:"server",type:"server"},{hint:"api",type:"server"},{hint:"iot",type:"iot"},{hint:"sensor",type:"iot"}];function iX(e){const t=e.toLowerCase();for(const n of oX)if(t.includes(n.hint))return n.type;return"client"}function aX(e){const t=e.toLowerCase();return t.includes("pglite")?"PGlite":t.includes("sqlite")||t.includes("wa-sqlite")?"SQLite":t.includes("postgres")||t.includes("pg")?"PostgreSQL":"unknown"}function cX(e,t){return typeof e.lagCommitCount=="number"?Math.max(0,e.lagCommitCount):t?Math.max(0,t.maxCommitSeq-e.cursor):0}function lX(e,t){return e.activityState==="stale"?"offline":t>0?"syncing":"online"}function uX(e,t){return e.length<=16?e:`${e.slice(0,12)}-${t+1}`}function fX(e,t,n={}){const s=n.maxNodes??10;return e.slice(0,s).map((i,a)=>{const l=cX(i,t),f=lX(i,l);return{id:uX(i.clientId,a),type:iX(i.clientId),status:f,cursor:Math.max(0,i.cursor),actor:i.actorId,mode:i.connectionMode,dialect:aX(i.clientId),scopes:Object.keys(i.effectiveScopes||{}),lastSeen:i.updatedAt}})}const dX={enabled:!1,thresholds:{p90Latency:500,errorRate:5,clientLag:100}};function YC(e,t="relative"){if(t==="absolute")return new Date(e).toLocaleString();const n=new Date(e),i=new Date().getTime()-n.getTime(),a=Math.floor(i/1e3);return a<60?`${a}s ago`:a<3600?`${Math.floor(a/60)}m ago`:a<86400?`${Math.floor(a/3600)}h ago`:`${Math.floor(a/86400)}d ago`}function hX(e){const t=e.length>1&&e.endsWith("/")?e.slice(0,-1):e;return t==="/console"||t.startsWith("/console/")?"/console/stream":"/stream"}function pX(){const e=mp(),t=_.useMemo(()=>typeof window>"u"?"/stream":hX(window.location.pathname),[]),n=vk(),{range:s}=n,{preferences:i}=af(),{partitionId:a}=of(),l=i.refreshInterval*1e3,[f]=xa("console:alert-config",dX),[d,p]=_.useState("1h"),{data:g}=sf({refetchIntervalMs:l,partitionId:a}),{data:y}=EY({range:s,partitionId:a},{refetchIntervalMs:l}),{data:b}=TY({range:s,partitionId:a},{refetchIntervalMs:l}),{data:x}=CY({limit:5,partitionId:a},{refetchIntervalMs:l}),{data:S}=yk({limit:12,offset:0,partitionId:a},{refetchIntervalMs:l}),{events:w,isConnected:T}=nX({maxEvents:8,partitionId:a}),C=_.useMemo(()=>{const z=y?.buckets??[];let Q=0,Y=0;for(const D of z)Q+=D.pushCount+D.pullCount,Y+=D.errorCount;const ee=Q>0?Y/Q*100:0;return{totalEvents:Q,errorRate:ee}},[y?.buckets]),k=_.useMemo(()=>S?.items?fX(S.items,g,{maxNodes:12}):[],[S?.items,g]),N=k.filter(z=>z.status!=="offline").length,R=k.filter(z=>z.status==="offline").length,M=_.useMemo(()=>g?[{label:"Ops (Range)",value:C.totalEvents,color:"flow"},{label:"P50 Latency",value:b?.push?.p50??0,unit:"ms",color:"healthy"},{label:"Error Rate",value:`${C.errorRate.toFixed(1)}%`,color:C.errorRate>0?"offline":"muted"},{label:"Active Clients",value:g.activeClientCount,color:"syncing"},{label:"Pending",value:g.maxActiveClientCursor!==null&&g.maxCommitSeq>0?g.maxCommitSeq-(g.minActiveClientCursor??0):0,color:"relay"}]:[],[g,b,C.errorRate,C.totalEvents]),L=_.useMemo(()=>w.map(z=>({type:z.type.toUpperCase(),actor:z.data?.actorId??"",table:(z.data?.tables??[])[0]??"",time:YC(z.timestamp,i.timeFormat)})),[w,i.timeFormat]),j=_.useMemo(()=>{const z=y?.buckets;if(!z?.length)return[];const Q=Math.max(...z.map(Y=>Math.max(Y.pushCount,Y.pullCount)),1);return z.map(Y=>({pushPercent:Q>0?Y.pushCount/Q*100:0,pullPercent:Q>0?Y.pullCount/Q*100:0}))},[y?.buckets]),A=_.useMemo(()=>{if(!b)return[];const z=Math.max(b.push.p50,b.push.p90,b.push.p99,b.pull.p50,b.pull.p90,b.pull.p99,1);return[{label:"P50",pushMs:b.push.p50,pullMs:b.pull.p50,pushBarPercent:b.push.p50/z*100,pullBarPercent:b.pull.p50/z*100},{label:"P90",pushMs:b.push.p90,pullMs:b.pull.p90,pushBarPercent:b.push.p90/z*100,pullBarPercent:b.pull.p90/z*100},{label:"P99",pushMs:b.push.p99,pullMs:b.pull.p99,pushBarPercent:b.push.p99/z*100,pullBarPercent:b.pull.p99/z*100}]},[b]),P=_.useMemo(()=>x?.items?x.items.map(z=>({seq:z.commitSeq,actor:z.actorId,changes:z.changeCount,tables:(z.affectedTables??[]).join(", "),time:YC(z.createdAt,i.timeFormat)})):[],[x?.items,i.timeFormat]),G=_.useMemo(()=>Math.max(0,100-C.errorRate),[C.errorRate]),B=_.useMemo(()=>{if(!f.enabled||!g)return[];const z=[];return b?.push?.p90&&b.push.p90>f.thresholds.p90Latency&&z.push(`P90 push latency (${b.push.p90}ms) exceeds threshold (${f.thresholds.p90Latency}ms)`),g.minActiveClientCursor!==null&&g.maxCommitSeq-g.minActiveClientCursor>f.thresholds.clientLag&&z.push(`Client lag (${g.maxCommitSeq-g.minActiveClientCursor}) exceeds threshold (${f.thresholds.clientLag})`),C.errorRate>f.thresholds.errorRate&&z.push(`Error rate (${C.errorRate.toFixed(1)}%) exceeds threshold (${f.thresholds.errorRate}%)`),z},[f,g,b,C.errorRate]);return g?h.jsx(sX.Provider,{value:n,children:h.jsxs("div",{className:"flex flex-col",children:[B.length>0&&h.jsx("div",{className:"px-6 pb-4",children:h.jsxs(In,{variant:"destructive",children:[h.jsx(nf,{children:"Threshold Exceeded"}),h.jsx(Pn,{children:B.map((z,Q)=>h.jsx("span",{className:"block",children:z},Q))})]})}),h.jsx(FA,{clients:k,totalNodes:k.length+2,onlineCount:N,offlineCount:R,relayClientIds:[]}),h.jsx(Wj,{items:M}),h.jsxs("div",{className:"flex",children:[h.jsxs("div",{className:"flex-1 min-w-0 flex flex-col",children:[h.jsx("div",{className:"border-b border-border border-r border-border",children:h.jsx(Ej,{bars:j,activeRange:d,onRangeChange:p})}),h.jsx("div",{className:"border-b border-border border-r border-border",children:h.jsx(Jj,{buckets:A,successRate:G})}),h.jsx("div",{className:"border-r border-border",children:h.jsx(Vj,{commits:P,onViewAll:()=>e({href:t})})})]}),h.jsx(eA,{entries:L,isConnected:T,maxVisible:20,maxHeight:"calc(100vh - 200px)"})]})]})}):h.jsx("div",{className:"flex items-center justify-center py-24",children:h.jsx(Pt,{size:"lg"})})}function mX(){return h.jsx(pX,{})}function gX({children:e}){return h.jsxs("div",{className:"space-y-4 px-5 py-5",children:[h.jsx(yX,{}),h.jsx(_X,{}),h.jsx(wX,{}),e]})}function yX(){const{clearError:e,config:t,connect:n,disconnect:s,error:i,isConnected:a,isConnecting:l}=Dt(),[f,d]=_.useState(t?.serverUrl??"/api"),[p,g]=_.useState(t?.token??""),[y,b]=_.useState(null),[x,S]=_.useState(!1),[w,T]=_.useState(null),[C,k]=xa("console:disconnect-clear-saved-config",!1);_.useEffect(()=>{const j=new URLSearchParams(window.location.search),A=j.get("server");let P=!1;if(A&&(d(A),j.delete("server"),P=!0),j.has("token")&&(j.delete("token"),P=!0),P){const G=j.toString(),B=G?`${window.location.pathname}?${G}`:window.location.pathname;window.history.replaceState({},"",B)}},[]),_.useEffect(()=>{t?.serverUrl&&d(t.serverUrl),t?.token&&g(t.token)},[t?.serverUrl,t?.token]),_.useEffect(()=>{T(null)},[]);const N=async()=>{e(),b(null);const j=await n({serverUrl:f.trim(),token:p.trim()},{persistOverride:!0});T(j?"Connected successfully and configuration saved.":"Failed to connect with the provided settings.")},R=()=>{s({clearSavedConfig:C}),C&&(d("/api"),g("")),T(C?"Disconnected and saved credentials cleared.":"Disconnected."),b(null)},M=async()=>{S(!0),b(null),T(null);const j=performance.now();try{const A=f.trim(),P=p.trim();if(!A||!P)throw new Error("Missing server URL or token");if(!(await fetch(`${A}/console/stats`,{headers:{Authorization:`Bearer ${P}`}})).ok)throw new Error("Failed to connect");b(Math.round(performance.now()-j))}catch{b(-1)}finally{S(!1)}},L=i??w??(y!==null?y<0?"Connection failed":`Connection successful (${y}ms latency)`:void 0);return h.jsx(Gj,{isConnected:a,isConnecting:l,isTestingConnection:x,serverUrl:f,onServerUrlChange:d,consoleToken:p,onConsoleTokenChange:g,onSaveAndConnect:N,onDisconnect:R,onTestConnection:M,statusMessage:L,children:h.jsx("div",{className:"px-5 pb-5 -mt-2",children:h.jsxs("div",{className:"flex items-center justify-between rounded-md border border-border px-3 py-2",children:[h.jsxs("div",{children:[h.jsx("p",{className:"font-mono text-[10px] text-neutral-400",children:"Clear saved credentials on disconnect"}),h.jsx("p",{className:"font-mono text-[9px] text-neutral-500",children:"Removes stored server URL and token from this browser."})]}),h.jsx(Ep,{checked:C,onCheckedChange:k})]})})})}const vX=1440*60*1e3;function XC(e){const t=e.trim();if(!t)return null;const n=Number.parseInt(t,10);return!Number.isInteger(n)||n<=0?null:n}function Fy(e){if(!e)return"Never";const t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():"Invalid date"}function bX(e){return e.length===0?"all scopes":e.length<=2?e.join(", "):`${e.slice(0,2).join(", ")} +${e.length-2}`}function xX(e,t){if(e.revokedAt)return"revoked";if(!e.expiresAt)return"active";const n=Date.parse(e.expiresAt);if(!Number.isFinite(n))return"active";const s=Date.now();return n<=s?"expired":n<=s+t*vX?"expiring":"active"}function SX(e){return e==="revoked"?"destructive":e==="expired"?"offline":e==="expiring"?"syncing":"healthy"}function _X(){const[e,t]=_.useState("all"),[n,s]=_.useState("all"),[i,a]=_.useState("14"),[l,f]=_.useState(!1),[d,p]=_.useState(!1),[g,y]=_.useState(""),[b,x]=_.useState("relay"),[S,w]=_.useState(""),[T,C]=_.useState(""),[k,N]=_.useState(""),[R,M]=_.useState(null),[L,j]=_.useState([]),[A,P]=_.useState(null),[G,B]=_.useState(null),[z,Q]=_.useState(null),[Y,ee]=_.useState(null),[D,K]=_.useState(null),[q,V]=_.useState(null),[U,I]=_.useState(null),H=_.useMemo(()=>XC(i),[i]),W=H??14,X=_.useMemo(()=>XC(k),[k]),oe=k.trim().length>0,se=!oe||X!==null,de=_.useMemo(()=>({type:e==="all"?void 0:e,status:n==="all"?void 0:n,expiresWithinDays:n==="expiring"?W:void 0}),[e,n,W]),{data:xe,isLoading:he,error:Me}=LY(de),_e=UY(),ne=BY(),pe=$Y(),ae=FY(),we=HY();_.useEffect(()=>{const me=new Set((xe?.items??[]).map(Te=>Te.keyId));j(Te=>Te.filter(qe=>me.has(qe)))},[xe?.items]);const ve=async()=>{try{const me=T.split(",").map(qe=>qe.trim()).filter(qe=>qe.length>0),Te=await _e.mutateAsync({name:g,keyType:b,actorId:S||void 0,scopeKeys:me.length>0?me:void 0,expiresInDays:oe?X??void 0:void 0});M(Te.secretKey),y(""),w(""),C(""),N("")}catch{}},Se=me=>{navigator.clipboard.writeText(me),B(me),setTimeout(()=>B(null),2e3)},ye=async()=>{if(z)try{await pe.mutateAsync(z)}finally{Q(null)}},Ue=async()=>{if(L.length!==0)try{const me=await ne.mutateAsync({keyIds:L});P(me),j([])}catch{}},Ie=async()=>{if(Y)try{const me=await we.mutateAsync(Y.keyId);K({oldKeyId:Y.keyId,oldKeyName:Y.name,secretKey:me.secretKey})}catch{}},Ee=async()=>{if(D)try{await pe.mutateAsync(D.oldKeyId)}finally{K(null),ee(null)}},Ve=async()=>{if(q)try{const me=await ae.mutateAsync(q);I(me.secretKey)}finally{V(null)}};if(he)return h.jsx("div",{className:"flex h-[200px] items-center justify-center",children:h.jsx(Pt,{size:"lg"})});if(Me)return h.jsx("div",{className:"flex h-[200px] items-center justify-center",children:h.jsxs("p",{className:"text-danger",children:["Failed to load API keys: ",Me.message]})});const Xe=(xe?.items??[]).filter(me=>me.revokedAt===null).map(me=>me.keyId),Be=Xe.length>0&&Xe.every(me=>L.includes(me)),We=L.length>0,He=(xe?.items??[]).filter(me=>L.includes(me.keyId)).map(me=>me.name);return h.jsxs(h.Fragment,{children:[h.jsxs(ex,{title:"API Keys",description:"Issue, rotate, revoke, and audit key lifecycle state.",actions:h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs(Oe,{size:"sm",variant:"destructive",onClick:()=>p(!0),disabled:L.length===0,children:["Revoke Selected (",L.length,")"]}),h.jsx(Oe,{size:"sm",onClick:()=>f(!0),children:"Create Key"})]}),children:[h.jsxs("div",{className:"mb-4 grid gap-3 lg:grid-cols-3",children:[h.jsxs(ms,{children:[h.jsx(ts,{children:"Type filter"}),h.jsxs(hh,{value:[e],multiple:!1,onValueChange:me=>{const Te=me.find(qe=>typeof qe=="string");(Te==="all"||Te==="relay"||Te==="proxy"||Te==="admin")&&t(Te)},children:[h.jsx(Dr,{value:"all",children:"all"}),h.jsx(Dr,{value:"relay",children:"relay"}),h.jsx(Dr,{value:"proxy",children:"proxy"}),h.jsx(Dr,{value:"admin",children:"admin"})]})]}),h.jsxs(ms,{children:[h.jsx(ts,{children:"Status filter"}),h.jsxs(hh,{value:[n],multiple:!1,onValueChange:me=>{const Te=me.find(qe=>typeof qe=="string");(Te==="all"||Te==="active"||Te==="revoked"||Te==="expiring")&&s(Te)},children:[h.jsx(Dr,{value:"all",children:"all"}),h.jsx(Dr,{value:"active",children:"active"}),h.jsx(Dr,{value:"revoked",children:"revoked"}),h.jsx(Dr,{value:"expiring",children:"expiring"})]})]}),h.jsxs(ms,{children:[h.jsx(ts,{htmlFor:"api-key-expiring-window",children:"Expiring window (days)"}),h.jsx(mc,{children:"Used when status filter is set to expiring."}),h.jsx(Gn,{id:"api-key-expiring-window",placeholder:"14",value:i,inputMode:"numeric",onChange:me=>a(me.target.value)}),H===null&&i.trim().length>0?h.jsx("p",{className:"font-mono text-[10px] text-offline",children:"Enter a positive whole number."}):null]})]}),xe?.items.length===0?h.jsx(Wb,{message:"No API keys match the current filters."}):h.jsxs(nl,{children:[h.jsx(rl,{children:h.jsxs(os,{children:[h.jsx(ht,{className:"w-[28px]",children:h.jsx(Fv,{checked:Be,indeterminate:!Be&&We&&Xe.length>0,onCheckedChange:me=>{j(me?Xe:[])},"aria-label":"Select all active keys"})}),h.jsx(ht,{className:"w-[100px]",children:"NAME"}),h.jsx(ht,{className:"w-[55px]",children:"TYPE"}),h.jsx(ht,{className:"w-[90px]",children:"KEY PREFIX"}),h.jsx(ht,{className:"w-[80px]",children:"ACTOR"}),h.jsx(ht,{className:"w-[100px]",children:"SCOPES"}),h.jsx(ht,{className:"w-[120px]",children:"CREATED"}),h.jsx(ht,{className:"w-[120px]",children:"LAST USED"}),h.jsx(ht,{className:"w-[120px]",children:"EXPIRES"}),h.jsx(ht,{className:"flex-1",children:"STATUS"})]})}),h.jsx(sl,{children:(xe?.items??[]).map(me=>{const Te=xX(me,W);return h.jsxs(os,{className:"group relative",children:[h.jsx(pt,{className:"w-[28px]",children:h.jsx(Fv,{checked:L.includes(me.keyId),onCheckedChange:qe=>{j(mt=>qe?[...new Set([...mt,me.keyId])]:mt.filter(lt=>lt!==me.keyId))},"aria-label":`Select ${me.name}`,disabled:me.revokedAt!==null})}),h.jsx(pt,{className:"w-[100px] font-medium",children:me.name}),h.jsx(pt,{className:"w-[55px]",children:h.jsx(mn,{variant:me.keyType==="admin"?"flow":me.keyType==="proxy"?"ghost":"relay",children:me.keyType})}),h.jsx(pt,{className:"w-[90px]",children:h.jsxs("code",{className:"font-mono text-[11px]",children:[me.keyPrefix,"..."]})}),h.jsx(pt,{className:"w-[80px] text-neutral-500",children:me.actorId??"-"}),h.jsx(pt,{className:"w-[100px] text-neutral-500",children:h.jsx("code",{className:"font-mono text-[10px]",children:bX(me.scopeKeys)})}),h.jsx(pt,{className:"w-[120px] text-neutral-500",children:Fy(me.createdAt)}),h.jsx(pt,{className:"w-[120px] text-neutral-500",children:Fy(me.lastUsedAt)}),h.jsx(pt,{className:"w-[120px] text-neutral-500",children:Fy(me.expiresAt)}),h.jsx(pt,{className:"flex-1",children:h.jsx(mn,{variant:SX(Te),children:Te})}),me.revokedAt===null&&h.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[h.jsx("button",{type:"button",onClick:()=>ee(me),className:"px-1.5 py-0.5 rounded text-[9px] font-mono text-neutral-600 hover:text-white hover:bg-white/[0.05] cursor-pointer transition-colors",children:"stage"}),h.jsx("button",{type:"button",onClick:()=>V(me.keyId),className:"px-1.5 py-0.5 rounded text-[9px] font-mono text-neutral-600 hover:text-white hover:bg-white/[0.05] cursor-pointer transition-colors",children:"rotate"}),h.jsx("button",{type:"button",onClick:()=>Q(me.keyId),className:"px-1.5 py-0.5 rounded text-[9px] font-mono text-neutral-600 hover:text-offline hover:bg-offline/10 cursor-pointer transition-colors",children:"revoke"})]})]},me.keyId)})})]})]}),h.jsx($r,{open:l,onOpenChange:f,children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Create API Key"})}),R?h.jsx(QC,{copiedKeyId:G,onClose:()=>{M(null),f(!1)},onCopy:Se,secretKey:R,warning:"Copy this key now. You will not be able to view it again."}):h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[h.jsxs(ms,{children:[h.jsx(ts,{htmlFor:"api-key-name",children:"Name"}),h.jsx(Gn,{id:"api-key-name",placeholder:"Backend Relay Key",value:g,onChange:me=>y(me.target.value)})]}),h.jsxs(ms,{children:[h.jsx(ts,{children:"Key type"}),h.jsxs(hh,{value:[b],multiple:!1,onValueChange:me=>{const Te=me.find(qe=>typeof qe=="string");(Te==="relay"||Te==="proxy"||Te==="admin")&&x(Te)},children:[h.jsx(Dr,{value:"relay",children:"relay"}),h.jsx(Dr,{value:"proxy",children:"proxy"}),h.jsx(Dr,{value:"admin",children:"admin"})]})]}),h.jsxs(ms,{children:[h.jsx(ts,{htmlFor:"api-key-actor-id",children:"Actor ID (optional)"}),h.jsx(mc,{children:"Pin this key to a fixed actor ID"}),h.jsx(Gn,{id:"api-key-actor-id",placeholder:"actor-123",value:S,onChange:me=>w(me.target.value)})]}),h.jsxs(ms,{children:[h.jsx(ts,{htmlFor:"api-key-scope-keys",children:"Scope keys (optional)"}),h.jsx(mc,{children:"Comma-separated list of allowed scope keys"}),h.jsx(Gn,{id:"api-key-scope-keys",placeholder:"scope-a, scope-b",value:T,onChange:me=>C(me.target.value)})]}),h.jsxs(ms,{children:[h.jsx(ts,{htmlFor:"api-key-expires-days",children:"Expires in days (optional)"}),h.jsx(mc,{children:"Leave empty to keep the key non-expiring."}),h.jsx(Gn,{id:"api-key-expires-days",placeholder:"30",value:k,inputMode:"numeric",onChange:me=>N(me.target.value)}),se?null:h.jsx("p",{className:"font-mono text-[10px] text-offline",children:"Enter a positive whole number."})]}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>f(!1),children:"Cancel"}),h.jsx(Oe,{variant:"primary",onClick:ve,disabled:_e.isPending||!g||!se,children:_e.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Creating..."]}):"Create"})]})]})]})}),h.jsx($r,{open:d,onOpenChange:me=>{p(me),me||P(null)},children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Bulk Revoke API Keys"})}),A?h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-3",children:[h.jsx(In,{variant:"destructive",children:h.jsxs(Pn,{children:["Requested ",A.requestedCount," keys. Revoked"," ",A.revokedCount,", already revoked"," ",A.alreadyRevokedCount,", not found"," ",A.notFoundCount,"."]})}),h.jsx(Nn,{children:h.jsx(Oe,{variant:"primary",onClick:()=>{p(!1),P(null)},children:"Done"})})]}):h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-3",children:[h.jsx(In,{variant:"destructive",children:h.jsx(Pn,{children:"This revokes selected keys immediately and cannot be undone."})}),h.jsxs("p",{className:"font-mono text-[10px] text-neutral-500",children:["Selected keys: ",He.slice(0,5).join(", "),He.length>5?` +${He.length-5} more`:""]})]}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>p(!1),children:"Cancel"}),h.jsx(Oe,{variant:"destructive",onClick:Ue,disabled:ne.isPending||L.length===0,children:ne.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Revoking..."]}):"Revoke Selected"})]})]})]})}),h.jsx($r,{open:Y!==null||D!==null,onOpenChange:()=>{ee(null),K(null)},children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Stage Rotate API Key"})}),D?h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[h.jsx(In,{variant:"default",children:h.jsxs(Pn,{children:["Replacement key created for ",D.oldKeyName,". The old key is still active until you revoke it."]})}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("code",{className:"flex-1 rounded-md border border-border bg-surface p-3 font-mono text-[11px] text-white break-all",children:D.secretKey}),h.jsx(Oe,{variant:"default",size:"sm",onClick:()=>Se(D.secretKey),children:G===D.secretKey?"Copied":"Copy"})]}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>{K(null),ee(null)},children:"Keep Old Key Active"}),h.jsx(Oe,{variant:"destructive",onClick:Ee,disabled:pe.isPending,children:pe.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Revoking Old Key..."]}):"Finalize and Revoke Old Key"})]})]}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"px-5 py-4",children:h.jsx("p",{className:"font-mono text-[10px] text-neutral-500",children:"Staged rotation creates a replacement key now and keeps the current key active until you explicitly revoke it."})}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>ee(null),children:"Cancel"}),h.jsx(Oe,{variant:"primary",onClick:Ie,disabled:we.isPending||!Y,children:we.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Staging..."]}):"Create Replacement Key"})]})]})]})}),h.jsx($r,{open:z!==null,onOpenChange:()=>Q(null),children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Revoke API Key"})}),h.jsx("div",{className:"px-5 py-4",children:h.jsx(In,{variant:"destructive",children:h.jsx(Pn,{children:"Revoking a key immediately invalidates it for all requests."})})}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>Q(null),children:"Cancel"}),h.jsx(Oe,{variant:"destructive",onClick:ye,disabled:pe.isPending,children:pe.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Revoking..."]}):"Revoke"})]})]})}),h.jsx($r,{open:q!==null||U!==null,onOpenChange:()=>{V(null),I(null)},children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Rotate API Key"})}),U?h.jsx(QC,{copiedKeyId:G,onClose:()=>I(null),onCopy:Se,secretKey:U,warning:"The previous key has been invalidated. Store this replacement securely."}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"px-5 py-4",children:h.jsx("p",{className:"font-mono text-[10px] text-neutral-500",children:"Rotating a key invalidates the previous secret immediately."})}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>V(null),children:"Cancel"}),h.jsx(Oe,{variant:"primary",onClick:Ve,disabled:ae.isPending,children:ae.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Rotating..."]}):"Rotate"})]})]})]})})]})}function wX(){const{preferences:e,updatePreference:t,resetPreferences:n}=af(),s=[{type:"filter",label:"Auto-refresh interval",options:ZY.map(i=>({id:`${i.value}`,label:i.label})),activeId:`${e.refreshInterval}`,onActiveChange:i=>t("refreshInterval",Number.parseInt(i,10))},{type:"filter",label:"Items per page",options:YY.map(i=>({id:`${i.value}`,label:i.label})),activeId:`${e.pageSize}`,onActiveChange:i=>t("pageSize",Number.parseInt(i,10))},{type:"filter",label:"Time format",options:[{id:"relative",label:"Relative"},{id:"absolute",label:"Absolute"}],activeId:e.timeFormat,onActiveChange:i=>t("timeFormat",i)},{type:"toggle",label:"Show sparklines",description:"Display mini trend charts in dashboard metric cards",checked:e.showSparklines,onCheckedChange:i=>t("showSparklines",i)}];return h.jsx(tA,{rows:s,onResetDefaults:n})}function QC({copiedKeyId:e,onClose:t,onCopy:n,secretKey:s,warning:i}){return h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[h.jsx(In,{variant:"destructive",children:h.jsx(Pn,{children:i})}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("code",{className:"flex-1 rounded-md border border-border bg-surface p-3 font-mono text-[11px] text-white break-all",children:s}),h.jsx(Oe,{variant:"default",size:"sm",onClick:()=>n(s),children:e===s?"Copied":"Copy"})]}),h.jsx(Nn,{children:h.jsx(Oe,{variant:"primary",onClick:t,children:"Done"})})]})}function EX(e){const t=e.toLowerCase();return t.includes("mobile")||t.includes("ios")||t.includes("android")?"mobile":t.includes("tablet")?"tablet":t.includes("desktop")||t.includes("laptop")?"desktop":t.includes("edge")?"edge":t.includes("iot")?"iot":"desktop"}function TX(e){const t=e.toLowerCase();return t.includes("pglite")?"PGlite":t.includes("wa-sqlite")||t.includes("sqlite")?"SQLite":t.includes("postgres")||t.includes("pg")?"PostgreSQL":"unknown"}function CX(e,t){if(t==="absolute")return new Date(e).toLocaleString();try{const n=new Date(e),i=new Date().getTime()-n.getTime(),a=Math.floor(i/1e3),l=Math.floor(a/60),f=Math.floor(l/60),d=Math.floor(f/24);return a<60?"just now":l<60?`${l}m ago`:f<24?`${f}h ago`:`${d}d ago`}catch{return e}}function RX(e,t,n){return{id:e.clientId,type:EX(e.clientId),status:e.activityState==="stale"?"offline":e.activityState==="idle"?"syncing":"online",cursor:e.cursor,actor:e.actorId,mode:e.connectionMode==="realtime"?"realtime":"polling",dialect:TX(e.clientId),scopes:Object.keys(e.effectiveScopes??{}),lastSeen:CX(e.updatedAt,n)}}function NX({emptyState:e}={}){const[t,n]=_.useState(1),[s,i]=_.useState(null),{preferences:a}=af(),{partitionId:l}=of(),f=a.pageSize,d=a.refreshInterval*1e3,{data:p,isLoading:g}=sf({refetchIntervalMs:d,partitionId:l}),{data:y,isLoading:b,error:x}=yk({limit:f,offset:(t-1)*f,partitionId:l},{refetchIntervalMs:d}),S=IY(),w=Math.ceil((y?.total??0)/f),T=p?.maxCommitSeq??0;_.useEffect(()=>{n(1)},[]);const C=async()=>{if(s)try{await S.mutateAsync({clientId:s,partitionId:l})}finally{i(null)}};if(b||g)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsx(Pt,{size:"lg"})});if(x)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsxs("p",{className:"text-danger",children:["Failed to load clients: ",x.message]})});const k=(y?.items??[]).map(N=>RX(N,T,a.timeFormat));return h.jsxs("div",{className:"flex flex-col gap-5 px-5 py-5",children:[k.length>0&&h.jsx(rA,{clients:k,headSeq:T}),k.length===0?e??h.jsx(sV,{children:h.jsx(Wb,{message:"No clients yet"})}):h.jsx(Xj,{clients:k,headSeq:T,onEvict:N=>{const R=y?.items.find(M=>M.clientId===N);i(R?.clientId??N)}}),w>1&&h.jsx(gx,{page:t,totalPages:w,totalItems:y?.total??0,onPageChange:n}),h.jsx($r,{open:s!==null,onOpenChange:()=>i(null),children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Evict Client"})}),h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[h.jsxs("p",{className:"font-mono text-[11px] text-neutral-300",children:["Are you sure you want to evict client"," ",h.jsxs("span",{className:"font-mono text-white",children:[s?.slice(0,12),"..."]}),"?"]}),h.jsx("p",{className:"font-mono text-[10px] text-neutral-500",children:"This will force the client to re-bootstrap on their next sync."})]}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>i(null),children:"Cancel"}),h.jsx(Oe,{variant:"destructive",onClick:C,disabled:S.isPending,children:S.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Evicting..."]}):"Evict"})]})]})})]})}const jX={latencyThresholdMs:1e3,errorRateThreshold:5,clientLagThreshold:50,enabled:!1};function AX(e){return e<1e3?`${e}ms`:e<6e4?`${Math.round(e/1e3)}s`:e<36e5?`${Math.round(e/6e4)}m`:`${Math.round(e/36e5)}h`}function kX(e){const t=e.split(",").map(n=>n.trim()).filter(n=>n.length>0);return Array.from(new Set(t))}function OX(e){switch(e){case"notify_data_change":return"Notify";case"evict_client":return"Evict";case"compact":return"Compact";default:return"Prune"}}function WC(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function MX(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function IX(e){const t=WC(e.requestPayload),n=WC(e.resultPayload);if(e.operationType==="notify_data_change"){const a=MX(t?.tables),l=n?.commitSeq;return`${a.length} table${a.length===1?"":"s"} -> commit #${typeof l=="number"?l:"?"}`}if(e.operationType==="evict_client"){const a=n?.evicted===!0?"evicted":"not found";return`client ${e.targetClientId??"?"} ${a}`}if(e.operationType==="compact")return`${typeof n?.deletedChanges=="number"?n.deletedChanges:0} changes removed`;const s=typeof n?.deletedCommits=="number"?n.deletedCommits:0,i=typeof t?.watermarkCommitSeq=="number"?` at #${t.watermarkCommitSeq}`:"";return`${s} commits removed${i}`}function PX(e){const t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function DX(){const{partitionId:e}=of();return h.jsxs("div",{className:"flex flex-col gap-4 px-5 py-5",children:[h.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[h.jsx(zX,{}),h.jsx(FX,{})]}),h.jsxs("div",{className:"grid gap-4 xl:grid-cols-3",children:[h.jsx(LX,{partitionId:e}),h.jsx(UX,{partitionId:e}),h.jsx($X,{partitionId:e})]}),h.jsx(BX,{partitionId:e})]})}function zX(){const{data:e,isLoading:t,error:n}=kY();if(t)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsx(Pt,{size:"lg"})});if(n)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsxs("p",{className:"text-danger",children:["Failed to load handlers: ",n.message]})});const s=(e?.items??[]).map(i=>({table:i.table,dependsOn:i.dependsOn?.join(", ")??null,chunkTtl:i.snapshotChunkTtlMs?AX(i.snapshotChunkTtlMs):"default"}));return h.jsx(Qj,{handlers:s,tableCount:e?.items.length??0})}function LX({partitionId:e}){const[t,n]=_.useState(!1),[s,i]=_.useState(null),{data:a,isLoading:l}=sf({partitionId:e}),{data:f,isLoading:d,refetch:p}=OY({enabled:!1}),g=PY(),y=async()=>{n(!0),i(null),await p()},b=async()=>{const S=await g.mutateAsync();i(S.deletedCommits)};if(l)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsx(Pt,{size:"lg"})});const x=[{label:"Total commits",value:a?.commitCount??0},{label:"Commit range",value:`${a?.minCommitSeq??0} - ${a?.maxCommitSeq??0}`},{label:"Min active cursor",value:a?.minActiveClientCursor??"N/A",tone:"syncing"}];return h.jsxs(h.Fragment,{children:[h.jsx(Tp,{title:"Prune",description:"Delete commits that all clients have already synced. Pruning removes commits older than the oldest active client cursor.",dotColor:"syncing",stats:x,actionLabel:"Preview Prune",actionVariant:"destructive",onAction:y}),h.jsx($r,{open:t,onOpenChange:n,children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Prune Old Commits"})}),h.jsx("div",{className:"px-5 py-4 flex flex-col gap-4",children:s!==null?h.jsxs(In,{variant:"default",children:[h.jsx(nf,{children:"Pruning Complete"}),h.jsxs(Pn,{children:["Successfully deleted ",h.jsx("strong",{children:s})," commits."]})]}):d?h.jsx("div",{className:"flex items-center justify-center py-8",children:h.jsx(Pt,{size:"sm"})}):f?h.jsxs(h.Fragment,{children:[h.jsx(In,{variant:f.commitsToDelete>0?"destructive":"default",children:h.jsx(Pn,{children:f.commitsToDelete>0?h.jsxs(h.Fragment,{children:["This will delete"," ",h.jsx("strong",{children:f.commitsToDelete})," commits up to sequence"," ",h.jsxs("code",{className:"font-mono",children:["#",f.watermarkCommitSeq]}),"."]}):"No commits are eligible for pruning."})}),h.jsxs("div",{className:"flex flex-col gap-2",children:[h.jsxs("div",{className:"flex justify-between font-mono text-[11px]",children:[h.jsx("span",{className:"text-neutral-500",children:"Watermark commit seq:"}),h.jsxs("span",{className:"text-white",children:["#",f.watermarkCommitSeq]})]}),h.jsxs("div",{className:"flex justify-between font-mono text-[11px] items-center",children:[h.jsx("span",{className:"text-neutral-500",children:"Commits to delete:"}),h.jsx(mn,{variant:f.commitsToDelete>0?"offline":"ghost",children:f.commitsToDelete})]})]})]}):null}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>n(!1),children:s!==null?"Close":"Cancel"}),s===null&&h.jsx(Oe,{variant:"destructive",onClick:b,disabled:g.isPending||d||(f?.commitsToDelete??0)===0,children:g.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Pruning..."]}):"Prune Now"})]})]})})]})}function UX({partitionId:e}){const[t,n]=_.useState(!1),[s,i]=_.useState(null),{data:a,isLoading:l}=sf({partitionId:e}),f=DY(),d=()=>{n(!0),i(null)},p=async()=>{const y=await f.mutateAsync();i(y.deletedChanges)};if(l)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsx(Pt,{size:"lg"})});const g=[{label:"Total changes",value:a?.changeCount??0},{label:"Total commits",value:a?.commitCount??0}];return h.jsxs(h.Fragment,{children:[h.jsx(Tp,{title:"Compact",description:"Merge old changes to reduce storage space. Compaction merges multiple changes to the same row into a single change.",dotColor:"flow",stats:g,actionLabel:"Run Compaction",actionVariant:"primary",onAction:d}),h.jsx($r,{open:t,onOpenChange:n,children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Compact Changes"})}),h.jsx("div",{className:"px-5 py-4 flex flex-col gap-4",children:s!==null?h.jsxs(In,{variant:"default",children:[h.jsx(nf,{children:"Compaction Complete"}),h.jsxs(Pn,{children:["Successfully removed ",h.jsx("strong",{children:s})," redundant changes."]})]}):h.jsx(In,{variant:"default",children:h.jsx(Pn,{children:"Compaction will merge multiple changes to the same row, keeping only the most recent version. This is safe and can be run at any time."})})}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>n(!1),children:s!==null?"Close":"Cancel"}),s===null&&h.jsx(Oe,{variant:"primary",onClick:p,disabled:f.isPending,children:f.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Compacting..."]}):"Compact Now"})]})]})})]})}function $X({partitionId:e}){const[t,n]=_.useState(!1),[s,i]=_.useState("tasks"),[a,l]=_.useState(e??""),[f,d]=_.useState(null),[p,g]=_.useState(null),y=zY(),b=kX(s),x=[{label:"Next tables",value:b.length,tone:"syncing"},{label:"Last commit seq",value:f?`#${f.commitSeq}`:"—",tone:"syncing"},{label:"Last chunks cleared",value:f?.deletedChunks??"—"}],S=()=>{n(!0),g(null)},w=async()=>{if(b.length===0){g("Provide at least one table name.");return}g(null);const T=await y.mutateAsync({tables:b,partitionId:a.trim()||void 0});d(T)};return h.jsxs(h.Fragment,{children:[h.jsx(Tp,{title:"Notify Data Change",description:"Create a synthetic commit after external imports or direct DB writes so clients re-bootstrap for affected tables.",dotColor:"healthy",stats:x,actionLabel:"Notify Clients",actionVariant:"primary",onAction:S}),h.jsx($r,{open:t,onOpenChange:n,children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Notify External Data Change"})}),h.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4",children:[f?h.jsxs(In,{variant:"default",children:[h.jsx(nf,{children:"Notification Sent"}),h.jsxs(Pn,{children:["Created synthetic commit"," ",h.jsxs("strong",{children:["#",f.commitSeq]})," for"," ",h.jsx("strong",{children:f.tables.length})," table",f.tables.length===1?"":"s"," and cleared"," ",h.jsx("strong",{children:f.deletedChunks})," cached chunk",f.deletedChunks===1?"":"s","."]})]}):h.jsx(In,{variant:"default",children:h.jsx(Pn,{children:"Use this when data changed outside Syncular push flow. It invalidates cached snapshot chunks and forces clients to pull fresh data."})}),p?h.jsx(In,{variant:"destructive",children:h.jsx(Pn,{children:p})}):null,h.jsxs(ms,{children:[h.jsx(ts,{children:"Tables (comma-separated)"}),h.jsx(Gn,{value:s,onChange:T=>i(T.target.value),placeholder:"tasks, notes",disabled:y.isPending}),h.jsx(mc,{children:"Enter one or more table names affected by the external change."})]}),h.jsxs(ms,{children:[h.jsx(ts,{children:"Partition ID (optional)"}),h.jsx(Gn,{value:a,onChange:T=>l(T.target.value),placeholder:"default",disabled:y.isPending})]})]}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>n(!1),children:f?"Close":"Cancel"}),f?null:h.jsx(Oe,{variant:"primary",onClick:w,disabled:y.isPending,children:y.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Notifying..."]}):"Notify Data Change"})]})]})})]})}function BX({partitionId:e}){const[t,n]=_.useState("all"),{data:s,isLoading:i,error:a}=MY({limit:20,offset:0,operationType:t==="all"?void 0:t,partitionId:e},{refetchIntervalMs:5e3});return h.jsx(ex,{title:"Operation Audit",description:"Recent prune/compact/notify/evict actions with actor and result context.",actions:h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Oe,{variant:t==="all"?"default":"ghost",size:"sm",onClick:()=>n("all"),children:"All"}),h.jsx(Oe,{variant:t==="prune"?"default":"ghost",size:"sm",onClick:()=>n("prune"),children:"Prune"}),h.jsx(Oe,{variant:t==="compact"?"default":"ghost",size:"sm",onClick:()=>n("compact"),children:"Compact"}),h.jsx(Oe,{variant:t==="notify_data_change"?"default":"ghost",size:"sm",onClick:()=>n("notify_data_change"),children:"Notify"}),h.jsx(Oe,{variant:t==="evict_client"?"default":"ghost",size:"sm",onClick:()=>n("evict_client"),children:"Evict"})]}),contentClassName:"pt-2",children:i?h.jsx("div",{className:"flex items-center justify-center py-10",children:h.jsx(Pt,{size:"lg"})}):a?h.jsx(In,{variant:"destructive",children:h.jsxs(Pn,{children:["Failed to load operation audit events: ",a.message]})}):(s?.items.length??0)===0?h.jsx("div",{className:"px-2 py-8 text-sm text-neutral-500",children:"No operation events found for this filter."}):h.jsx("div",{className:"overflow-x-auto",children:h.jsxs(nl,{children:[h.jsx(rl,{children:h.jsxs(os,{children:[h.jsx(ht,{children:"Time"}),h.jsx(ht,{children:"Type"}),h.jsx(ht,{children:"User"}),h.jsx(ht,{children:"Target"}),h.jsx(ht,{children:"Result"})]})}),h.jsx(sl,{children:(s?.items??[]).map((l,f)=>h.jsxs(os,{children:[h.jsx(pt,{className:"whitespace-nowrap text-xs text-neutral-400",children:PX(l.createdAt)}),h.jsx(pt,{children:h.jsx(mn,{variant:"ghost",children:OX(l.operationType)})}),h.jsx(pt,{className:"font-mono text-xs",children:l.consoleUserId??"system"}),h.jsx(pt,{className:"font-mono text-xs",children:l.targetClientId??l.partitionId??(l.operationType==="notify_data_change"?"partition default":"global")}),h.jsx(pt,{className:"font-mono text-xs text-neutral-300",children:IX(l)})]},`${l.operationId}:${l.createdAt}:${f}`))})]})})})}function FX(){const[e,t]=xa("console:alert-config",jX),n={p90Latency:e.latencyThresholdMs,errorRate:e.errorRateThreshold,clientLag:e.clientLagThreshold},s=a=>{t(l=>({...l,latencyThresholdMs:a.p90Latency,errorRateThreshold:a.errorRate,clientLagThreshold:a.clientLag}))},i=a=>{t(l=>({...l,enabled:a}))};return h.jsx(Hj,{enabled:e.enabled,onEnabledChange:i,thresholds:n,onThresholdsChange:s})}function HX(e){if(e===0)return"0 B";const t=["B","KB","MB","GB","TB"],n=Math.floor(Math.log(e)/Math.log(1024));return`${(e/1024**n).toFixed(n===0?0:1)} ${t[n]}`}function qX(e){const t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function VX(){const[e,t]=_.useState(""),[n,s]=_.useState(void 0),[i,a]=_.useState(void 0),[l,f]=_.useState([]),[d,p]=_.useState(null),{data:g,isLoading:y,error:b}=qY({prefix:n,cursor:i,limit:100}),x=VY(),S=KY();function w(){const M=e.trim();s(M.length>0?M:void 0),a(void 0),f([])}function T(){t(""),s(void 0),a(void 0),f([])}function C(){g?.cursor&&(f(M=>[...M,i??""]),a(g.cursor))}function k(){f(M=>{const L=[...M],j=L.pop();return a(j&&j.length>0?j:void 0),L})}function N(){d&&x.mutate(d,{onSuccess:()=>p(null)})}if(y)return h.jsx("div",{className:"flex flex-col gap-4 px-5 py-5",children:h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsx(Pt,{size:"lg"})})});if(b)return h.jsx("div",{className:"flex flex-col gap-4 px-5 py-5",children:h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsxs("p",{className:"text-danger font-mono text-[11px]",children:["Failed to load storage items: ",b.message]})})});const R=g?.items??[];return h.jsxs("div",{className:"flex flex-col gap-4 px-5 py-5",children:[h.jsx(ex,{title:"Storage",actions:h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Gn,{placeholder:"Prefix filter...",value:e,onChange:M=>t(M.target.value),onKeyDown:M=>{M.key==="Enter"&&w()},className:"h-7 w-48 text-xs"}),h.jsx(Oe,{variant:"default",size:"sm",onClick:w,children:"Filter"}),n&&h.jsx(Oe,{variant:"ghost",size:"sm",onClick:T,children:"Clear"})]}),children:R.length===0?h.jsx(Wb,{message:n?`No storage items matching prefix "${n}".`:"No storage items found."}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"overflow-x-auto",children:h.jsxs(nl,{children:[h.jsx(rl,{children:h.jsxs(os,{children:[h.jsx(ht,{children:"Key"}),h.jsx(ht,{children:"Size"}),h.jsx(ht,{children:"Type"}),h.jsx(ht,{children:"Uploaded"}),h.jsx(ht,{children:"Actions"})]})}),h.jsx(sl,{children:R.map(M=>h.jsxs(os,{children:[h.jsx(pt,{className:"font-mono text-xs max-w-[320px]",title:M.key,children:M.key}),h.jsx(pt,{className:"font-mono text-xs text-neutral-400 whitespace-nowrap",children:HX(M.size)}),h.jsx(pt,{children:M.httpMetadata?.contentType?h.jsx(mn,{variant:"ghost",children:M.httpMetadata.contentType}):h.jsx("span",{className:"text-neutral-500 text-xs",children:"--"})}),h.jsx(pt,{className:"whitespace-nowrap text-xs text-neutral-400",children:qX(M.uploaded)}),h.jsx(pt,{children:h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx(Oe,{variant:"ghost",size:"sm",onClick:()=>{S(M.key)},children:"Download"}),h.jsx(Oe,{variant:"ghost",size:"sm",onClick:()=>p(M.key),children:"Delete"})]})})]},M.key))})]})}),h.jsxs("div",{className:"flex items-center justify-between px-2 py-2",children:[h.jsx(Oe,{variant:"ghost",size:"sm",disabled:l.length===0,onClick:k,children:"Previous"}),h.jsx(Oe,{variant:"ghost",size:"sm",disabled:!g?.truncated,onClick:C,children:"Next"})]})]})}),h.jsx($r,{open:d!==null,onOpenChange:()=>p(null),children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Delete Storage Item"})}),h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[h.jsxs("p",{className:"font-mono text-[11px] text-neutral-300",children:["Are you sure you want to delete"," ",h.jsx("span",{className:"font-mono text-white",children:d}),"?"]}),h.jsx("p",{className:"font-mono text-[10px] text-neutral-500",children:"This action cannot be undone."})]}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>p(null),children:"Cancel"}),h.jsx(Oe,{variant:"destructive",onClick:N,disabled:x.isPending,children:x.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"})," Deleting..."]}):"Delete"})]})]})})]})}const KX={};function au(e,t){if(t==="absolute")return new Date(e).toLocaleString();const n=new Date(e),i=new Date().getTime()-n.getTime(),a=Math.floor(i/1e3);return a<60?`${a}s`:a<3600?`${Math.floor(a/60)}m`:a<86400?`${Math.floor(a/3600)}h`:`${Math.floor(a/86400)}d`}function GX(e){const t=e.split(/\s+/).map(i=>i.trim()).filter(i=>i.length>0),n={},s=[];for(const i of t){const[a="",...l]=i.split(":"),f=l.join(":").trim(),d=a.toLowerCase();if(!f){s.push(i);continue}if(d==="actor"){n.actorId=f;continue}if(d==="client"){n.clientId=f;continue}if(d==="table"){n.table=f;continue}if(d==="request"){n.requestId=f;continue}if(d==="trace"){n.traceId=f;continue}s.push(i)}return s.length>0&&(n.search=s.join(" ")),n}function ZX(e){return e==="1h"?3600*1e3:e==="6h"?360*60*1e3:e==="24h"?1440*60*1e3:e==="7d"?10080*60*1e3:720*60*60*1e3}function Zd(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function YX(e,t){return e?`#${e.federatedCommitId??(t?`${t}:${e.commitSeq}`:String(e.commitSeq))}`:"#?"}function XX(e,t){return e?`E${e.federatedEventId??(t?`${t}:${e.eventId}`:e.eventId)}`:"E?"}function QX(e,t,n){return!e||!t?null:e.replaceAll("{traceId}",encodeURIComponent(t)).replaceAll("{spanId}",encodeURIComponent(n??""))}function bx({initialSelectedEntryId:e}={}){const{preferences:t}=af(),{partitionId:n}=of(),{range:s,setRange:i}=vk(),a=t.pageSize,l=t.refreshInterval*1e3,f=KX?.VITE_CONSOLE_TRACE_URL_TEMPLATE,[d,p]=_.useState(()=>e?.startsWith("#")?"commits":e?.startsWith("E")?"events":"all"),[g,y]=_.useState("all"),[b,x]=_.useState("all"),[S,w]=_.useState(""),[T,C]=_.useState(1),[k,N]=_.useState(!1),[R,M]=_.useState(e??null),L=_.useRef(!1),j=_.useMemo(()=>GX(S),[S]),A=_.useMemo(()=>new Date(Date.now()-ZX(s)).toISOString(),[s]),{data:P,isLoading:G,refetch:B}=NY({limit:a,offset:(T-1)*a,...n?{partitionId:n}:{},view:d,...d!=="commits"&&g!=="all"?{eventType:g}:{},...d!=="commits"&&b!=="all"?{outcome:b}:{},...j.actorId?{actorId:j.actorId}:{},...j.clientId?{clientId:j.clientId}:{},...j.requestId?{requestId:j.requestId}:{},...j.traceId?{traceId:j.traceId}:{},...j.table?{table:j.table}:{},...j.search?{search:j.search}:{},from:A},{refetchIntervalMs:l}),z=rX(),Q=R?.startsWith("#")?R.slice(1):void 0,Y=R?.startsWith("E")?R.slice(1):void 0,ee=Q&&Q!=="?"?Q:void 0,D=Y&&Y!=="?"?Y:void 0,{data:K,isLoading:q,error:V}=RY(ee,{enabled:ee!==void 0,partitionId:n}),{data:U,isLoading:I,error:H}=jY(D,{enabled:D!==void 0,partitionId:n}),{data:W,isLoading:X,error:oe}=AY(D,{enabled:D!==void 0&&!!U?.payloadRef,partitionId:n}),se=_.useMemo(()=>QX(f,U?.traceId??null,U?.spanId??null),[U?.spanId,U?.traceId,f]);_.useEffect(()=>{C(1)},[]),_.useEffect(()=>{C(1)},[]),_.useEffect(()=>{e&&M(e)},[e]),_.useEffect(()=>{if(!L.current){L.current=!0;return}M(null)},[]),_.useEffect(()=>{C(1),M(null)},[]);const xe=_.useMemo(()=>(P?.items??[]).map(we=>{const ve=we.instanceId??we.commit?.instanceId??we.event?.instanceId,Se=ve?`[${ve}] `:"";if(we.type==="commit"&&we.commit){const Ue=we.commit;return{type:"commit",id:YX(Ue,ve),outcome:"--",duration:"--",actor:Ue.actorId,client:Ue.clientId,detail:`${Se}${Ue.changeCount} chg | ${(Ue.affectedTables??[]).join(", ")}`,time:au(we.timestamp,t.timeFormat)}}const ye=we.event;return ye?{type:ye.eventType,id:XX(ye,ve),outcome:ye.outcome,duration:`${ye.durationMs}ms`,actor:ye.actorId,client:ye.clientId,detail:`${Se}${(ye.tables??[]).join(", ")||"--"}`,time:au(we.timestamp,t.timeFormat)}:{type:"pull",id:"E?",outcome:"unknown",duration:"--",actor:"",client:"",detail:"--",time:au(we.timestamp,t.timeFormat)}}),[t.timeFormat,P?.items]),he=P?.total??0,Me=Math.max(1,Math.ceil(he/a)),_e=G,ne=[{label:"",options:[{id:"all",label:"All"},{id:"commits",label:"Commits"},{id:"events",label:"Events"}],activeId:d,onActiveChange:ae=>{p(ae),ae==="commits"&&(y("all"),x("all")),C(1)}},{label:"Time",options:[{id:"1h",label:"1h"},{id:"6h",label:"6h"},{id:"24h",label:"24h"},{id:"7d",label:"7d"},{id:"30d",label:"30d"}],activeId:s,onActiveChange:ae=>{i(ae),C(1)}},{label:"Type",options:[{id:"all",label:"All"},{id:"push",label:"Push"},{id:"pull",label:"Pull"}],activeId:g,onActiveChange:ae=>{y(ae),C(1)}},{label:"Outcome",options:[{id:"all",label:"All"},{id:"applied",label:"Applied"},{id:"error",label:"Error"},{id:"rejected",label:"Rejected"}],activeId:b,onActiveChange:ae=>{x(ae),C(1)}}];function pe(){z.mutate(void 0,{onSuccess:()=>{N(!1),B()}})}return h.jsxs("div",{className:"flex flex-col h-full",children:[_e&&xe.length===0?h.jsx("div",{className:"flex items-center justify-center py-24",children:h.jsx(Pt,{size:"lg"})}):h.jsx(nA,{entries:xe,selectedEntryId:R,onEntryClick:ae=>M(ae.id),filterBar:h.jsx(Zj,{groups:ne,searchValue:S,searchPlaceholder:"Use actor:, client:, table:, request:, trace: or free text...",onSearchChange:w,actions:h.jsxs(h.Fragment,{children:[h.jsx(Oe,{size:"sm",variant:"ghost",onClick:()=>{B()},children:"Refresh"}),h.jsx(Oe,{size:"sm",variant:"ghost",children:"Export"}),h.jsx(Oe,{size:"sm",variant:"destructive",onClick:()=>N(!0),children:"Clear"})]})}),pagination:h.jsx(gx,{page:T,totalPages:Me,totalItems:he,onPageChange:C})}),h.jsx($r,{open:R!==null,onOpenChange:ae=>{ae||M(null)},children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:ee!==void 0?`Commit #${ee}`:D!==void 0?`Event E${D}`:"Entry details"})}),h.jsx("div",{className:"px-5 py-4 space-y-3 max-h-[70vh] overflow-y-auto",children:q||I?h.jsx("div",{className:"flex items-center justify-center py-8",children:h.jsx(Pt,{size:"sm"})}):V||H?h.jsx("p",{className:"font-mono text-[11px] text-offline",children:"Failed to load details."}):K?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"grid grid-cols-2 gap-3 font-mono text-[11px]",children:[h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Actor"}),h.jsx("div",{className:"text-neutral-100",children:K.actorId})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Client"}),h.jsx("div",{className:"text-neutral-100",children:K.clientId})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Instance"}),h.jsx("div",{className:"text-neutral-100",children:K.instanceId??"--"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Created"}),h.jsx("div",{className:"text-neutral-100",children:au(K.createdAt,t.timeFormat)})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Changes"}),h.jsx("div",{className:"text-neutral-100",children:K.changeCount})]})]}),h.jsxs("div",{children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2",children:"Affected Tables"}),h.jsx("p",{className:"font-mono text-[11px] text-neutral-200",children:K.affectedTables.join(", ")||"--"})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500",children:"Changes"}),K.changes.length===0?h.jsx("p",{className:"font-mono text-[11px] text-neutral-500",children:"No changes recorded."}):K.changes.map(ae=>h.jsxs("div",{className:"rounded-md border border-border p-3 space-y-2",children:[h.jsxs("div",{className:"flex items-center justify-between font-mono text-[11px]",children:[h.jsxs("span",{className:"text-neutral-300",children:[ae.table," | ",ae.op]}),h.jsxs("span",{className:"text-neutral-500",children:["#",ae.changeId]})]}),h.jsxs("div",{className:"font-mono text-[11px] text-neutral-400",children:["rowId: ",ae.rowId,ae.rowVersion!==null?` | version: ${ae.rowVersion}`:""]}),h.jsx("pre",{className:"font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200",children:Zd(ae.rowJson)})]},ae.changeId))]})]}):U?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"grid grid-cols-2 gap-3 font-mono text-[11px]",children:[h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Type"}),h.jsx("div",{className:"text-neutral-100",children:U.eventType})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Path"}),h.jsx("div",{className:"text-neutral-100",children:U.syncPath})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Instance"}),h.jsx("div",{className:"text-neutral-100",children:U.instanceId??"--"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Outcome"}),h.jsx("div",{className:"text-neutral-100",children:U.outcome})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Response Status"}),h.jsx("div",{className:"text-neutral-100",children:U.responseStatus})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Actor"}),h.jsx("div",{className:"text-neutral-100",children:U.actorId})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Client"}),h.jsx("div",{className:"text-neutral-100",children:U.clientId})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Status"}),h.jsx("div",{className:"text-neutral-100",children:U.statusCode})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Transport"}),h.jsx("div",{className:"text-neutral-100",children:U.transportPath})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Duration"}),h.jsxs("div",{className:"text-neutral-100",children:[U.durationMs,"ms"]})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Request ID"}),h.jsx("div",{className:"text-neutral-100",children:U.requestId})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Trace ID"}),h.jsx("div",{className:"text-neutral-100",children:U.traceId??"--"}),se&&h.jsx("a",{href:se,target:"_blank",rel:"noreferrer",className:"font-mono text-[10px] text-flow underline underline-offset-4",children:"Open external trace"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Span ID"}),h.jsx("div",{className:"text-neutral-100",children:U.spanId??"--"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Commit Seq"}),h.jsx("div",{className:"text-neutral-100",children:U.commitSeq??"--"}),U.commitSeq!==null&&h.jsx(Oe,{variant:"ghost",size:"sm",onClick:()=>M(`#${U.instanceId?`${U.instanceId}:`:""}${U.commitSeq}`),children:"Open linked commit"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Subscription Count"}),h.jsx("div",{className:"text-neutral-100",children:U.subscriptionCount??"--"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Error Code"}),h.jsx("div",{className:"text-neutral-100",children:U.errorCode??"--"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Payload Ref"}),h.jsx("div",{className:"text-neutral-100",children:U.payloadRef??"--"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Created"}),h.jsx("div",{className:"text-neutral-100",children:au(U.createdAt,t.timeFormat)})]})]}),h.jsxs("div",{children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2",children:"Tables"}),h.jsx("p",{className:"font-mono text-[11px] text-neutral-200",children:U.tables.join(", ")||"--"})]}),U.scopesSummary&&h.jsxs("div",{children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2",children:"Scopes Summary"}),h.jsx("pre",{className:"font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200",children:Zd(U.scopesSummary)})]}),U.payloadRef&&h.jsxs("div",{children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2",children:"Payload Snapshot"}),X?h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Pt,{size:"sm"}),h.jsx("span",{className:"font-mono text-[11px] text-neutral-400",children:"Loading payload snapshot..."})]}):oe?h.jsx("p",{className:"font-mono text-[11px] text-offline",children:"Failed to load payload snapshot."}):W?h.jsxs("div",{className:"space-y-2",children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500",children:"Request"}),h.jsx("pre",{className:"font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200",children:Zd(W.requestPayload)}),h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500",children:"Response"}),h.jsx("pre",{className:"font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200",children:Zd(W.responsePayload)})]}):h.jsx("p",{className:"font-mono text-[11px] text-neutral-500",children:"No payload snapshot available."})]}),U.errorMessage&&h.jsxs("div",{children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2",children:"Error"}),h.jsx("p",{className:"font-mono text-[11px] text-offline",children:U.errorMessage})]})]}):h.jsx("p",{className:"font-mono text-[11px] text-neutral-500",children:"No details available for this row."})}),h.jsx(Nn,{children:h.jsx(Oe,{variant:"default",size:"sm",onClick:()=>M(null),children:"Close"})})]})}),h.jsx($r,{open:k,onOpenChange:ae=>{ae||N(!1)},children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Clear all events"})}),h.jsx("div",{className:"p-4",children:h.jsx("span",{className:"font-mono text-[11px] text-neutral-400",children:"This will permanently delete all request events. Commits are not affected. Are you sure?"})}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",size:"sm",onClick:()=>N(!1),children:"Cancel"}),h.jsx(Oe,{variant:"destructive",size:"sm",onClick:pe,disabled:z.isPending,children:z.isPending?"Clearing...":"Clear all"})]})]})})]})}const WX=ao({getParentRoute:()=>lo,path:"/config",component:gX}),JX=ao({getParentRoute:()=>lo,path:"/fleet",component:NX}),eQ=ao({getParentRoute:()=>lo,path:"/",component:mX});function tQ(){const{seq:e}=bk.useParams();return h.jsx(bx,{initialSelectedEntryId:`#${e}`})}const bk=ao({getParentRoute:()=>lo,path:"/investigate/commit/$seq",component:tQ});function nQ(){const{id:e}=xk.useParams();return h.jsx(bx,{initialSelectedEntryId:`E${e}`})}const xk=ao({getParentRoute:()=>lo,path:"/investigate/event/$id",component:nQ}),rQ=ao({getParentRoute:()=>lo,path:"/ops",component:DX}),sQ=ao({getParentRoute:()=>lo,path:"/storage",component:VX}),oQ=ao({getParentRoute:()=>lo,path:"/stream",component:bx}),iQ=lo.addChildren([eQ,oQ,bk,xk,JX,rQ,sQ,WX]),aQ="syncular-console-basepath",cQ="syncular-console-server-url",lQ="syncular-console-token";function uQ(e){if(!e)return;const t=e.trim();return t.length>0?t:void 0}function Hv(e){const t=globalThis.document;if(!t)return;const n=t.querySelector(`meta[name="${e}"]`)?.getAttribute("content");return uQ(n)}function Sk(e){return!e||e==="/"?"/":(e.startsWith("/")?e:`/${e}`).replace(/\/+$/g,"")||"/"}function fQ(){return Sk(Hv(aQ))}function dQ(){const e=Hv(cQ),t=Hv(lQ);return!e||!t?null:{serverUrl:e,token:t}}function hQ(){return new I6({defaultOptions:{queries:{staleTime:5e3,retry:1}}})}function pQ(e){return Sk(e??fQ())}function mQ(e){const[t]=_.useState(()=>hQ()),n=_.useMemo(()=>UH({routeTree:iQ,basepath:pQ(e.basePath)}),[e.basePath]),s=e.defaultConfig===void 0?dQ():e.defaultConfig,i=e.autoConnect??e.defaultConfig===void 0;return h.jsx(P6,{client:t,children:h.jsx(nq,{defaultConfig:s,autoConnect:i,storageMode:e.storageMode,children:h.jsx(FH,{router:n})})})}function gQ(e){return h.jsx("div",{className:vx,children:h.jsx(mQ,{...e})})}function yQ(e){const t=document.querySelector(e);if(!t)throw new Error(`Unable to mount console: ${e} not found`);return t}function vQ(e,t={}){const n=yQ(e);XY(n);const s=u6.createRoot(n),i=h.jsx(gQ,{basePath:t.basePath,defaultConfig:t.defaultConfig,autoConnect:t.autoConnect});return t.strictMode===!1?(s.render(i),s):(s.render(h.jsx(_.StrictMode,{children:i})),s)}var bQ={};const xQ="syncular-sentry-dsn",SQ="syncular-sentry-environment",_Q="syncular-sentry-release";function gu(e){if(!e)return;const t=e.trim();return t.length>0?t:void 0}function Hy(e){if(typeof document>"u")return;const t=document.querySelector(`meta[name="${e}"]`)?.getAttribute("content");return gu(t)}function qy(e){if(!(typeof process>"u"))return gu(bQ[e])}function Vy(e){for(const t of e)if(t)return t}function wQ(){const e=Vy([gu(globalThis.__SYNCULAR_SENTRY_DSN__),Hy(xQ),qy("SYNCULAR_SENTRY_DSN")]);if(!e)return null;const t=Vy([gu(globalThis.__SYNCULAR_SENTRY_ENVIRONMENT__),Hy(SQ),qy("SYNCULAR_SENTRY_ENVIRONMENT")]),n=Vy([gu(globalThis.__SYNCULAR_SENTRY_RELEASE__),Hy(_Q),qy("SYNCULAR_SENTRY_RELEASE")]);return{dsn:e,environment:t,release:n,enableLogs:!0,tracesSampleRate:.2,tracePropagationTargets:[/^https?:\/\/.*\/api\/.*/]}}const JC=wQ();JC&&t6(JC);vQ("#root");
86
+ )`}return h.jsx("div",{ref:n,role:"presentation","data-base-ui-inert":"",...i,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:a}})});function Jh(e,t){e&&Object.assign(e.style,t)}const ZG={position:"relative",maxHeight:"100%",overflowX:"hidden",overflowY:"auto"},YG={position:"fixed"},XG=_.forwardRef(function(t,n){const{anchor:s,positionMethod:i="absolute",className:a,render:l,side:f="bottom",align:d="center",sideOffset:p=0,alignOffset:g=0,collisionBoundary:y="clipping-ancestors",collisionPadding:b,arrowPadding:x=5,sticky:S=!1,disableAnchorTracking:w,alignItemWithTrigger:T=!0,collisionAvoidance:C=e8,...k}=t,{store:N,listRef:R,labelsRef:M,alignItemWithTriggerActiveRef:L,selectedItemTextRef:j,valuesRef:A,initialValueRef:P,popupRef:G,setValue:B}=Ju(),z=VA(),Q=at(N,it.open),Y=at(N,it.mounted),ee=at(N,it.modal),D=at(N,it.value),K=at(N,it.openMethod),q=at(N,it.positionerElement),V=at(N,it.triggerElement),U=at(N,it.isItemEqualToValue),I=at(N,it.transitionStatus),H=_.useRef(null),W=_.useRef(null),[X,oe]=_.useState(T),se=Y&&X&&K!=="touch";!Y&&X!==T&&oe(T),Le(()=>{Y||(it.scrollUpArrowVisible(N.state)&&N.set("scrollUpArrowVisible",!1),it.scrollDownArrowVisible(N.state)&&N.set("scrollDownArrowVisible",!1))},[N,Y]),_.useImperativeHandle(L,()=>se),KA((se||ee)&&Q&&K!=="touch",V);const de=BA({anchor:s,floatingRootContext:z,positionMethod:i,mounted:Y,side:f,sideOffset:p,align:d,alignOffset:g,arrowPadding:x,collisionBoundary:y,collisionPadding:b,sticky:S,disableAnchorTracking:w??se,collisionAvoidance:C,keepMounted:!0}),xe=se?"none":de.side,he=se?YG:de.positionerStyles,Me=_.useMemo(()=>{const Se={};return Q||(Se.pointerEvents="none"),{role:"presentation",hidden:!Y,style:{...he,...Se}}},[Q,Y,he]),_e={open:Q,side:xe,align:de.align,anchorHidden:de.anchorHidden},ne=Ae(Se=>{N.set("positionerElement",Se)}),pe=zt("div",t,{ref:[n,ne],state:_e,stateAttributesMapping:il,props:[Me,kp(I),k]}),ae=_.useRef(0),we=Ae(Se=>{if(Se.size===0&&ae.current===0||A.current.length===0)return;const ye=ae.current;if(ae.current=Se.size,Se.size===ye)return;const Ue=Yt(ii);if(ye!==0&&!N.state.multiple&&D!==null&&Uy(A.current,D,U)===-1){const Ee=P.current,Xe=Ee!=null&&Uy(A.current,Ee,U)!==-1?Ee:null;B(Xe,Ue),Xe===null&&(N.set("selectedIndex",null),j.current=null)}if(ye!==0&&N.state.multiple&&Array.isArray(D)){const Ie=Ve=>Uy(A.current,Ve,U)!==-1,Ee=D.filter(Ve=>Ie(Ve));(Ee.length!==D.length||Ee.some(Ve=>!EG(D,Ve,U)))&&(B(Ee,Ue),Ee.length===0&&(N.set("selectedIndex",null),j.current=null))}if(Q&&se){N.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});const Ie={height:""};Jh(q,Ie),Jh(G.current,Ie)}}),ve=_.useMemo(()=>({...de,side:xe,alignItemWithTriggerActive:se,setControlledAlignItemWithTrigger:oe,scrollUpArrowRef:H,scrollDownArrowRef:W}),[de,xe,se,oe]);return h.jsx(ZA,{elementsRef:R,labelsRef:M,onMapChange:we,children:h.jsxs(YA.Provider,{value:ve,children:[Y&&ee&&h.jsx(XA,{inert:hx(!Q),cutout:V}),pe]})})});function QA(e){const t=e.currentTarget.getBoundingClientRect();return t.top+1<=e.clientY&&e.clientY<=t.bottom-1&&t.left+1<=e.clientX&&e.clientX<=t.right-1}const Kd="base-ui-disable-scrollbar",UC={className:Kd,getElement(e){return h.jsx("style",{nonce:e,href:Kd,precedence:"base-ui:low",children:`.${Kd}{scrollbar-width:none}.${Kd}::-webkit-scrollbar{display:none}`})}},QG=_.createContext(void 0);function WA(e){return _.useContext(QG)}const Ec="ArrowUp",Qi="ArrowDown",ku="ArrowLeft",Tc="ArrowRight",ef="Home",tf="End",JA=new Set([ku,Tc]),WG=new Set([ku,Tc,ef,tf]),ek=new Set([Ec,Qi]),JG=new Set([Ec,Qi,ef,tf]),tk=new Set([...JA,...ek]),eZ=new Set([...tk,ef,tf]),nk=new Set([Ec,Qi,ku,Tc,ef,tf]),tZ="Shift",nZ="Control",rZ="Alt",sZ="Meta",oZ=new Set([tZ,nZ,rZ,sZ]);function iZ(e){return Zt(e)&&e.tagName==="INPUT"}function $C(e){return!!(iZ(e)&&e.selectionStart!=null||Zt(e)&&e.tagName==="TEXTAREA")}function BC(e,t,n,s){if(!e||!t||!t.scrollTo)return;let i=e.scrollLeft,a=e.scrollTop;const l=e.clientWidth<e.scrollWidth,f=e.clientHeight<e.scrollHeight;if(l&&s!=="vertical"){const d=FC(e,t,"left"),p=Gd(e),g=Gd(t);n==="ltr"&&(d+t.offsetWidth+g.scrollMarginRight>e.scrollLeft+e.clientWidth-p.scrollPaddingRight?i=d+t.offsetWidth+g.scrollMarginRight-e.clientWidth+p.scrollPaddingRight:d-g.scrollMarginLeft<e.scrollLeft+p.scrollPaddingLeft&&(i=d-g.scrollMarginLeft-p.scrollPaddingLeft)),n==="rtl"&&(d-g.scrollMarginRight<e.scrollLeft+p.scrollPaddingLeft?i=d-g.scrollMarginLeft-p.scrollPaddingLeft:d+t.offsetWidth+g.scrollMarginRight>e.scrollLeft+e.clientWidth-p.scrollPaddingRight&&(i=d+t.offsetWidth+g.scrollMarginRight-e.clientWidth+p.scrollPaddingRight))}if(f&&s!=="horizontal"){const d=FC(e,t,"top"),p=Gd(e),g=Gd(t);d-g.scrollMarginTop<e.scrollTop+p.scrollPaddingTop?a=d-g.scrollMarginTop-p.scrollPaddingTop:d+t.offsetHeight+g.scrollMarginBottom>e.scrollTop+e.clientHeight-p.scrollPaddingBottom&&(a=d+t.offsetHeight+g.scrollMarginBottom-e.clientHeight+p.scrollPaddingBottom)}e.scrollTo({left:i,top:a,behavior:"auto"})}function FC(e,t,n){const s=n==="left"?"offsetLeft":"offsetTop";let i=0;for(;t.offsetParent&&(i+=t[s],t.offsetParent!==e);)t=t.offsetParent;return i}function Gd(e){const t=getComputedStyle(e);return{scrollMarginTop:parseFloat(t.scrollMarginTop)||0,scrollMarginRight:parseFloat(t.scrollMarginRight)||0,scrollMarginBottom:parseFloat(t.scrollMarginBottom)||0,scrollMarginLeft:parseFloat(t.scrollMarginLeft)||0,scrollPaddingTop:parseFloat(t.scrollPaddingTop)||0,scrollPaddingRight:parseFloat(t.scrollPaddingRight)||0,scrollPaddingBottom:parseFloat(t.scrollPaddingBottom)||0,scrollPaddingLeft:parseFloat(t.scrollPaddingLeft)||0}}function $y(e,t=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(t,Math.min(e,n))}const aZ=_.createContext(void 0),cZ={disableStyleElements:!1};function lZ(){return _.useContext(aZ)??cZ}const qi=1,uZ={...il,...va},fZ=_.forwardRef(function(t,n){const{render:s,className:i,finalFocus:a,...l}=t,{store:f,popupRef:d,onOpenChangeComplete:p,setOpen:g,valueRef:y,selectedItemTextRef:b,keyboardActiveRef:x,multiple:S,handleScrollArrowVisibility:w,scrollHandlerRef:T,highlightItemOnHover:C}=Ju(),{side:k,align:N,alignItemWithTriggerActive:R,setControlledAlignItemWithTrigger:M,scrollDownArrowRef:L,scrollUpArrowRef:j}=GG(),A=WA()!=null,P=VA(),{nonce:G,disableStyleElements:B}=lZ(),z=rs(),Q=at(f,it.id),Y=at(f,it.open),ee=at(f,it.mounted),D=at(f,it.popupProps),K=at(f,it.transitionStatus),q=at(f,it.triggerElement),V=at(f,it.positionerElement),U=at(f,it.listElement),I=_.useRef(0),H=_.useRef(!1),W=_.useRef(0),X=_.useRef(!1),oe=_.useRef({}),se=ax(),de=Ae(_e=>{if(!V||!d.current||!X.current)return;if(H.current||!R){w();return}const ne=V.style.top==="0px",pe=V.style.bottom==="0px",ae=V.getBoundingClientRect().height,we=Rt(V),ve=getComputedStyle(V),Se=parseFloat(ve.marginTop),ye=parseFloat(ve.marginBottom),Ue=HC(getComputedStyle(d.current)),Ie=Math.min(we.documentElement.clientHeight-Se-ye,Ue),Ee=_e.scrollTop,Ve=qC(_e);let Xe=0,Be=null,We=!1,He=!1;const me=qe=>{V.style.height=`${qe}px`},Te=(qe,mt)=>{const lt=$y(qe,0,Ie-ae);lt>0&&me(ae+lt),_e.scrollTop=mt,Ie-(ae+lt)<=qi&&(H.current=!0),w()};if(ne){const qe=Ve-Ee,mt=ae+qe,lt=Math.min(mt,Ie);if(Xe=lt,qe<=qi){Te(qe,Ve);return}Ie-lt>qi?He=!0:We=!0}else if(pe){const qe=Ee,mt=ae+qe,lt=Math.min(mt,Ie),wr=mt-Ie;if(Xe=lt,qe<=qi){Te(qe,0);return}Ie-lt>qi?Be=0:(We=!0,Ee<Ve&&(Be=Ee-(qe-wr)))}if(Xe=Math.ceil(Xe),Xe!==0&&me(Xe),He||Be!=null){const qe=qC(_e),mt=He?qe:$y(Be,0,qe);Math.abs(_e.scrollTop-mt)>qi&&(_e.scrollTop=mt)}(We||Xe>=Ie-qi)&&(H.current=!0),w()});_.useImperativeHandle(T,()=>de,[de]),ba({open:Y,ref:d,onComplete(){Y&&p?.(!0)}});const xe={open:Y,transitionStatus:K,side:k,align:N};Le(()=>{!V||!d.current||Object.keys(oe.current).length||(oe.current={top:V.style.top||"0",left:V.style.left||"0",right:V.style.right,height:V.style.height,bottom:V.style.bottom,minHeight:V.style.minHeight,maxHeight:V.style.maxHeight,marginTop:V.style.marginTop,marginBottom:V.style.marginBottom})},[d,V]),Le(()=>{Y||R||(X.current=!1,H.current=!1,I.current=0,W.current=0,Jh(V,oe.current))},[Y,R,V,d]),Le(()=>{const _e=d.current;if(!(!Y||!q||!V||!_e||f.state.transitionStatus==="ending")){if(!R){X.current=!0,se.request(w),_e.style.removeProperty("--transform-origin");return}queueMicrotask(()=>{const ne=dZ(_e);_e.style.removeProperty("--transform-origin");try{const pe=getComputedStyle(V),ae=getComputedStyle(_e),we=Rt(q),ve=un(V),Se=q.getBoundingClientRect(),ye=V.getBoundingClientRect(),Ue=Se.left,Ie=Se.height,Ee=U||_e,Ve=Ee.scrollHeight,Xe=parseFloat(ae.borderBottomWidth),Be=parseFloat(pe.marginTop)||10,We=parseFloat(pe.marginBottom)||10,He=parseFloat(pe.minHeight)||100,me=HC(ae),Te=5,qe=5,mt=20,lt=we.documentElement.clientHeight-Be-We,wr=we.documentElement.clientWidth,Er=lt-Se.bottom+Ie,Qt=b.current,ut=y.current;let xt,ot=0,Wt=0;if(Qt&&ut){const tr=ut.getBoundingClientRect();xt=Qt.getBoundingClientRect();const ls=tr.left-Ue,uo=xt.left-ye.left,fo=tr.top-Se.top+tr.height/2,nr=xt.top-ye.top+xt.height/2;ot=ls-uo,Wt=nr-fo}const vn=Er+Wt+We+Xe;let kt=Math.min(lt,vn);const Cn=lt-Be-We,er=vn-kt,An=Math.max(Te,Ue+ot),as=wr-qe,cs=Math.max(0,An+ye.width-as);V.style.left=`${An-cs}px`,V.style.height=`${kt}px`,V.style.maxHeight="auto",V.style.marginTop=`${Be}px`,V.style.marginBottom=`${We}px`,_e.style.height="100%";const _a=Ee.scrollHeight-Ee.clientHeight,_i=er>=_a;_i&&(kt=Math.min(lt,ye.height)-(er-_a));const wi=Se.top<mt||Se.bottom>lt-mt||kt<Math.min(Ve,He),ws=(ve.visualViewport?.scale??1)!==1&&rx;if(wi||ws){X.current=!0,Jh(V,oe.current),hi.flushSync(()=>M(!1));return}if(_i){const tr=Math.max(0,lt-vn);V.style.top=ye.height>=Cn?"0":`${tr}px`,V.style.height=`${kt}px`,Ee.scrollTop=Ee.scrollHeight-Ee.clientHeight,I.current=Math.max(He,kt)}else V.style.bottom="0",I.current=Math.max(He,kt),Ee.scrollTop=er;if(xt){const tr=ye.top,ls=ye.height,uo=xt.top+xt.height/2,fo=ls>0?(uo-tr)/ls*100:50,nr=$y(fo,0,100);_e.style.setProperty("--transform-origin",`50% ${nr}%`)}(I.current===lt||kt>=me)&&(H.current=!0),w(),setTimeout(()=>{X.current=!0})}finally{ne()}})}},[f,Y,V,q,y,b,d,w,R,M,se,L,j,U]),_.useEffect(()=>{if(!R||!V||!Y)return;const _e=un(V);function ne(pe){g(!1,Yt(T8,pe))}return _e.addEventListener("resize",ne),()=>{_e.removeEventListener("resize",ne)}},[g,R,V,Y]);const he={...U?{role:"presentation","aria-orientation":void 0}:{role:"listbox","aria-multiselectable":S||void 0,id:`${Q}-list`},onKeyDown(_e){x.current=!0,A&&nk.has(_e.key)&&_e.stopPropagation()},onMouseMove(){x.current=!1},onPointerLeave(_e){if(!C||QA(_e)||_e.pointerType==="touch")return;const ne=_e.currentTarget;z.start(0,()=>{f.set("activeIndex",null),ne.focus({preventScroll:!0})})},onScroll(_e){U||de(_e.currentTarget)},...R&&{style:U?{height:"100%"}:ZG}},Me=zt("div",t,{ref:[n,d],state:xe,stateAttributesMapping:uZ,props:[D,he,kp(K),{className:!U&&R?UC.className:void 0},l]});return h.jsxs(_.Fragment,{children:[!B&&UC.getElement(G),h.jsx(RA,{context:P,modal:!1,disabled:!ee,returnFocus:a,restoreFocus:!0,children:Me})]})});function HC(e){const t=e.maxHeight||"";return t.endsWith("px")&&parseFloat(t)||1/0}function qC(e){return Math.max(0,e.scrollHeight-e.clientHeight)}const VC=[["transform","none"],["scale","1"],["translate","0 0"]];function dZ(e){const{style:t}=e,n={};for(const[s,i]of VC)n[s]=t.getPropertyValue(s),t.setProperty(s,i,"important");return()=>{for(const[s]of VC){const i=n[s];i?t.setProperty(s,i):t.removeProperty(s)}}}let rk=(function(e){return e[e.None=0]="None",e[e.GuessFromOrder=1]="GuessFromOrder",e})({});function px(e={}){const{label:t,metadata:n,textRef:s,indexGuessBehavior:i,index:a}=e,{register:l,unregister:f,subscribeMapChange:d,elementsRef:p,labelsRef:g,nextIndexRef:y}=HG(),b=_.useRef(-1),[x,S]=_.useState(a??(i===rk.GuessFromOrder?()=>{if(b.current===-1){const C=y.current;y.current+=1,b.current=C}return b.current}:-1)),w=_.useRef(null),T=_.useCallback(C=>{if(w.current=C,x!==-1&&C!==null&&(p.current[x]=C,g)){const k=t!==void 0;g.current[x]=k?t:s?.current?.textContent??C.textContent}},[x,p,g,t,s]);return Le(()=>{if(a!=null)return;const C=w.current;if(C)return l(C,n),()=>{f(C)}},[a,l,f,n]),Le(()=>{if(a==null)return d(C=>{const k=w.current?C.get(w.current)?.index:null;k!=null&&S(k)})},[a,d,S]),_.useMemo(()=>({ref:T,index:x}),[x,T])}const hZ=_.createContext(void 0),pZ=_.memo(_.forwardRef(function(t,n){const{render:s,className:i,value:a=null,label:l,disabled:f=!1,nativeButton:d=!1,...p}=t,g=_.useRef(null),y=px({label:l,textRef:g,indexGuessBehavior:rk.GuessFromOrder}),{store:b,getItemProps:x,setOpen:S,setValue:w,selectionRef:T,typingRef:C,valuesRef:k,keyboardActiveRef:N,multiple:R,highlightItemOnHover:M}=Ju(),L=rs(),j=at(b,it.isActive,y.index),A=at(b,it.isSelected,y.index,a),P=at(b,it.isSelectedByFocus,y.index),G=at(b,it.isItemEqualToValue),B=y.index,z=B!==-1,Q=_.useRef(null),Y=Jo(B);Le(()=>{if(!z)return;const se=k.current;return se[B]=a,()=>{delete se[B]}},[z,B,a,k]),Le(()=>{if(!z)return;const se=b.state.value;let de=se;R&&Array.isArray(se)&&se.length>0&&(de=se[se.length-1]),de!==void 0&&Bc(a,de,G)&&b.set("selectedIndex",B)},[z,B,R,G,b,a]);const ee={disabled:f,selected:A,highlighted:j},D=x({active:j,selected:A});D.onFocus=void 0,D.id=void 0;const K=_.useRef(null),q=_.useRef("mouse"),V=_.useRef(!1),{getButtonProps:U,buttonRef:I}=el({disabled:f,focusableWhenDisabled:!0,native:d});function H(se){const de=b.state.value;if(R){const xe=Array.isArray(de)?de:[],he=A?TG(xe,a,G):[...xe,a];w(he,Yt(Ny,se))}else w(a,Yt(Ny,se)),S(!1,Yt(Ny,se))}const W={role:"option","aria-selected":A,tabIndex:j?0:-1,onFocus(){b.set("activeIndex",B)},onMouseEnter(){!N.current&&b.state.selectedIndex===null&&M&&b.set("activeIndex",B)},onMouseMove(){M&&b.set("activeIndex",B)},onMouseLeave(se){!M||N.current||QA(se)||L.start(0,()=>{b.state.activeIndex===B&&b.set("activeIndex",null)})},onTouchStart(){T.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1}},onKeyDown(se){K.current=se.key,b.set("activeIndex",B)},onClick(se){V.current=!1,!(se.type==="keydown"&&K.current===null)&&(f||K.current===" "&&C.current||q.current!=="touch"&&!j||(K.current=null,H(se.nativeEvent)))},onPointerEnter(se){q.current=se.pointerType},onPointerDown(se){q.current=se.pointerType,V.current=!0},onMouseUp(se){if(f)return;if(V.current){V.current=!1;return}const de=!T.current.allowSelectedMouseUp&&A,xe=!T.current.allowUnselectedMouseUp&&!A;de||xe||q.current!=="touch"&&!j||H(se.nativeEvent)}},X=zt("div",t,{ref:[I,n,y.ref,Q],state:ee,props:[D,W,p,U]}),oe=_.useMemo(()=>({selected:A,indexRef:Y,textRef:g,selectedByFocus:P,hasRegistered:z}),[A,Y,g,P,z]);return h.jsx(hZ.Provider,{value:oe,children:X})})),mZ=_.forwardRef(({className:e,children:t,...n},s)=>h.jsx(IG,{ref:s,className:ge("inline-flex items-center justify-between bg-surface border border-border rounded-md px-3 py-1.5 font-mono text-[12px] text-foreground cursor-pointer hover:border-border-bright transition",e),...n,children:t}));mZ.displayName="SelectTrigger";const gZ=_.forwardRef(({className:e,portalProps:t,positionerProps:n,...s},i)=>h.jsx(DG,{...t,children:h.jsx(XG,{...n,children:h.jsx(fZ,{ref:i,className:ge("bg-panel border border-border rounded-md py-1 shadow-lg z-50",e),...s})})}));gZ.displayName="SelectContent";const yZ=_.forwardRef(({className:e,...t},n)=>h.jsx(pZ,{ref:n,className:ge("font-mono text-[11px] px-3 py-1.5 text-neutral-400 cursor-pointer hover:bg-white/[0.03] hover:text-white data-[highlighted]:bg-white/[0.03] data-[highlighted]:text-white outline-none",e),...t}));yZ.displayName="SelectItem";const vZ=_.forwardRef(({className:e,...t},n)=>h.jsx("textarea",{ref:n,className:ge("bg-surface border border-border rounded-md px-3 py-2 font-mono text-[12px] text-foreground outline-none w-full transition focus:border-flow placeholder:text-neutral-600 resize-none min-h-[80px]",e),...t}));vZ.displayName="Textarea";const sk=_.createContext(void 0);function bZ(e=!0){const t=_.useContext(sk);if(t===void 0&&!e)throw new Error(yn(7));return t}function ok(e={}){const{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:s}=Mj(),{ref:i,index:a}=px(e),l=n===a,f=_.useRef(null),d=so(i,f);return{compositeProps:_.useMemo(()=>({tabIndex:l?0:-1,onFocus(){s(a)},onMouseMove(){const g=f.current;if(!t||!g)return;const y=g.hasAttribute("disabled")||g.ariaDisabled==="true";!l&&!y&&g.focus()}}),[l,s,a,t]),compositeRef:d,index:a}}function xZ(e){const{render:t,className:n,state:s=an,props:i=Nu,refs:a=Nu,metadata:l,stateAttributesMapping:f,tag:d="div",...p}=e,{compositeProps:g,compositeRef:y}=ok({metadata:l});return zt(d,e,{state:s,ref:[...a,y],props:[g,...i,p],stateAttributesMapping:f})}const SZ=_.forwardRef(function(t,n){const{className:s,defaultPressed:i=!1,disabled:a=!1,form:l,onPressedChange:f,pressed:d,render:p,type:g,value:y,nativeButton:b=!0,...x}=t,S=br(y||void 0),w=bZ(),T=w?.value??[],C=w?void 0:i,k=(a||w?.disabled)??!1,[N,R]=yp({controlled:w?S!==void 0&&T.indexOf(S)>-1:d,default:C,name:"Toggle",state:"pressed"}),M=Ae((z,Q)=>{S&&w?.setGroupValue?.(S,z,Q),f?.(z,Q)}),{getButtonProps:L,buttonRef:j}=el({disabled:k,native:b}),A={disabled:k,pressed:N},P=[j,n],G=[{"aria-pressed":N,onClick(z){const Q=!N,Y=Yt(ii,z.nativeEvent);M(Q,Y),!Y.isCanceled&&R(Q)}},x,L],B=zt("button",t,{enabled:!w,state:A,ref:P,props:G});return w?h.jsx(xZ,{tag:"button",render:p,className:s,state:A,refs:P,props:G}):B}),Dr=_.forwardRef(({className:e,...t},n)=>h.jsx(SZ,{ref:n,className:ge("font-mono text-[10px] text-neutral-500 border border-transparent rounded-sm px-2.5 py-1 cursor-pointer transition-all hover:text-neutral-300 data-[pressed]:text-white data-[pressed]:border-border-bright data-[pressed]:bg-white/[0.03]",e),...t}));Dr.displayName="Toggle";function _Z(e){return e==null||e.hasAttribute("disabled")||e.getAttribute("aria-disabled")==="true"}const ik="data-composite-item-active",wZ=[];function EZ(e){const{itemSizes:t,cols:n=1,loopFocus:s=!0,dense:i=!1,orientation:a="both",direction:l,highlightedIndex:f,onHighlightedIndexChange:d,rootRef:p,enableHomeAndEndKeys:g=!1,stopEventPropagation:y=!1,disabledIndices:b,modifierKeys:x=wZ}=e,[S,w]=_.useState(0),T=n>1,C=_.useRef(null),k=so(C,p),N=_.useRef([]),R=_.useRef(!1),M=f??S,L=Ae((P,G=!1)=>{if((d??w)(P),G){const B=N.current[P];BC(C.current,B,l,a)}}),j=Ae(P=>{if(P.size===0||R.current)return;R.current=!0;const G=Array.from(P.keys()),B=G.find(Q=>Q?.hasAttribute(ik))??null,z=B?G.indexOf(B):-1;z!==-1&&L(z),BC(C.current,B,l,a)}),A=_.useMemo(()=>({"aria-orientation":a==="both"?void 0:a,ref:k,onFocus(P){!C.current||!$C(P.target)||P.target.setSelectionRange(0,P.target.value.length??0)},onKeyDown(P){const G=g?eZ:tk;if(!G.has(P.key)||TZ(P,x)||!C.current)return;const z=l==="rtl",Q=z?ku:Tc,Y={horizontal:Q,vertical:Qi,both:Q}[a],ee=z?Tc:ku,D={horizontal:ee,vertical:Ec,both:ee}[a];if($C(P.target)&&!_Z(P.target)){const W=P.target.selectionStart,X=P.target.selectionEnd,oe=P.target.value??"";if(W==null||P.shiftKey||W!==X||P.key!==D&&W<oe.length||P.key!==Y&&W>0)return}let K=M;const q=UV(N,b),V=$V(N,b);if(T){const W=t||Array.from({length:N.current.length},()=>({width:1,height:1})),X=FV(W,n,i),oe=X.findIndex(de=>de!=null&&!pu(N,de,b)),se=X.reduce((de,xe,he)=>xe!=null&&!pu(N,xe,b)?he:de,-1);K=X[BV({current:X.map(de=>de?N.current[de]:null)},{event:P,orientation:a,loopFocus:s,cols:n,disabledIndices:qV([...b||N.current.map((de,xe)=>pu(N,xe)?xe:void 0),void 0],X),minIndex:oe,maxIndex:se,prevIndex:HV(M>V?q:M,W,X,n,P.key===Qi?"bl":P.key===Tc?"tr":"tl"),rtl:z})]}const U={horizontal:[Q],vertical:[Qi],both:[Q,Qi]}[a],I={horizontal:[ee],vertical:[Ec],both:[ee,Ec]}[a],H=T?G:{horizontal:g?WG:JA,vertical:g?JG:ek,both:G}[a];g&&(P.key===ef?K=q:P.key===tf&&(K=V)),K===M&&(U.includes(P.key)||I.includes(P.key))&&(s&&K===V&&U.includes(P.key)?K=q:s&&K===q&&I.includes(P.key)?K=V:K=fr(N,{startingIndex:K,decrement:I.includes(P.key),disabledIndices:b})),K!==M&&!lh(N,K)&&(y&&P.stopPropagation(),H.has(P.key)&&P.preventDefault(),L(K,!0),queueMicrotask(()=>{N.current[K]?.focus()}))}}),[n,i,l,b,N,g,M,T,t,s,k,x,L,a,y]);return _.useMemo(()=>({props:A,highlightedIndex:M,onHighlightedIndexChange:L,elementsRef:N,disabledIndices:b,onMapChange:j,relayKeyboardEvent:A.onKeyDown}),[A,M,L,N,b,j])}function TZ(e,t){for(const n of oZ.values())if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function ak(e){const{render:t,className:n,refs:s=Nu,props:i=Nu,state:a=an,stateAttributesMapping:l,highlightedIndex:f,onHighlightedIndexChange:d,orientation:p,dense:g,itemSizes:y,loopFocus:b,cols:x,enableHomeAndEndKeys:S,onMapChange:w,stopEventPropagation:T=!0,rootRef:C,disabledIndices:k,modifierKeys:N,highlightItemOnHover:R=!1,tag:M="div",...L}=e,j=UA(),{props:A,highlightedIndex:P,onHighlightedIndexChange:G,elementsRef:B,onMapChange:z,relayKeyboardEvent:Q}=EZ({itemSizes:y,cols:x,loopFocus:b,dense:g,orientation:p,highlightedIndex:f,onHighlightedIndexChange:d,rootRef:C,stopEventPropagation:T,enableHomeAndEndKeys:S,direction:j,disabledIndices:k,modifierKeys:N}),Y=zt(M,e,{state:a,ref:s,props:[A,...i,L],stateAttributesMapping:l}),ee=_.useMemo(()=>({highlightedIndex:P,onHighlightedIndexChange:G,highlightItemOnHover:R,relayKeyboardEvent:Q}),[P,G,R,Q]);return h.jsx(Oj.Provider,{value:ee,children:h.jsx(ZA,{elementsRef:B,onMapChange:D=>{w?.(D),z(D)},children:Y})})}let CZ=(function(e){return e.disabled="data-disabled",e.orientation="data-orientation",e.multiple="data-multiple",e})({});const KC={multiple(e){return e?{[CZ.multiple]:""}:null}},RZ=_.forwardRef(function(t,n){const{defaultValue:s,disabled:i=!1,loopFocus:a=!0,onValueChange:l,orientation:f="horizontal",multiple:d=!1,value:p,className:g,render:y,...b}=t,x=WA(),S=_.useMemo(()=>{if(p===void 0)return s??[]},[p,s]),w=_.useMemo(()=>p!==void 0||s!==void 0,[p,s]),T=(x?.disabled??!1)||i,[C,k]=yp({controlled:p,default:S,name:"ToggleGroup",state:"value"}),N=Ae((A,P,G)=>{let B;if(d?(B=C.slice(),P?B.push(A):B.splice(C.indexOf(A),1)):B=P?[A]:[],Array.isArray(B)){if(l?.(B,G),G.isCanceled)return;k(B)}}),R={disabled:T,multiple:d,orientation:f},M=_.useMemo(()=>({disabled:T,orientation:f,setGroupValue:N,value:C,isValueInitialized:w}),[T,f,N,C,w]),L={role:"group"},j=zt("div",t,{enabled:!!x,state:R,ref:n,props:[L,b],stateAttributesMapping:KC});return h.jsx(sk.Provider,{value:M,children:x?j:h.jsx(ak,{render:y,className:g,state:R,refs:[n],props:[L,b],stateAttributesMapping:KC,loopFocus:a,enableHomeAndEndKeys:!0})})}),hh=_.forwardRef(({className:e,...t},n)=>h.jsx(RZ,{ref:n,className:ge("flex items-center gap-0.5",e),...t}));hh.displayName="ToggleGroup";const NZ=ge(Kj({variant:"secondary",size:"sm"}),"h-7 whitespace-nowrap uppercase tracking-[0.08em] leading-none no-underline");function ck({active:e,onClick:t,children:n,className:s}){return h.jsxs("button",{type:"button",onClick:t,className:ge("font-mono text-[10px] tracking-[1.5px] uppercase bg-transparent border-none px-3.5 py-1 cursor-pointer relative transition-colors",e?"text-white":"text-neutral-500 hover:text-neutral-300",s),children:[n,e&&h.jsx("span",{className:"absolute -bottom-2.5 left-1/2 -translate-x-1/2 w-4 h-0.5 bg-flow rounded-sm shadow-[0_0_8px_rgba(59,130,246,0.5)]"})]})}function jZ({items:e,activeId:t,onItemChange:n,renderItem:s,className:i}){return h.jsx("div",{className:ge("flex items-center gap-0.5",i),children:e.map(a=>{const l=a.id===t,f=()=>n?.(a.id);return s?h.jsx("span",{children:s(a,{active:l,onClick:f})},a.id):h.jsx(ck,{active:l,onClick:f,children:a.label},a.id)})})}const AZ=mi("rounded-full inline-block flex-shrink-0",{variants:{color:{healthy:"bg-healthy",syncing:"bg-syncing",offline:"bg-offline",flow:"bg-flow",relay:"bg-relay",encrypt:"bg-encrypt",muted:"bg-neutral-500"},size:{sm:"w-1.5 h-1.5",md:"w-2 h-2",lg:"w-2.5 h-2.5"},glow:{true:"",false:""}},defaultVariants:{color:"healthy",size:"sm",glow:!1}}),kZ={healthy:"0 0 6px #22c55e",syncing:"0 0 6px #f59e0b",offline:"0 0 6px #ef4444",flow:"0 0 6px #3b82f6",relay:"0 0 6px #8b5cf6",encrypt:"0 0 6px #f472b6",muted:"none"};function OZ({color:e,size:t,glow:n,pulse:s,className:i}){return h.jsx("span",{className:ge(AZ({color:e,size:t,glow:n}),s&&"dot-pulse",i),style:n?{boxShadow:kZ[e??"healthy"]}:void 0})}const MZ="0.0.6-90",IZ={version:MZ},PZ=IZ.version;function DZ({label:e,className:t}){return h.jsxs("div",{className:ge("flex items-center gap-3",t),children:[h.jsx(OZ,{color:"healthy",size:"md",glow:!0}),h.jsx("span",{className:"font-display font-bold text-white text-sm tracking-tight",children:"syncular"}),e&&h.jsx("span",{className:"font-mono text-[9px] text-neutral-600 uppercase tracking-widest",children:e}),h.jsxs("span",{className:"font-mono text-[9px] text-neutral-600 tracking-wider",children:["v",PZ]})]})}function zZ({brand:e,center:t,right:n,className:s}){return h.jsxs(h.Fragment,{children:[h.jsx("div",{"aria-hidden":"true",className:"h-[42px] shrink-0"}),h.jsxs("nav",{className:ge("fixed top-0 left-0 right-0 z-100 h-[42px] border-b border-border bg-surface/88 backdrop-blur-lg flex items-center justify-between px-5",s),children:[h.jsx("div",{className:"flex items-center gap-3",children:e}),h.jsx("div",{className:"flex items-center gap-0.5",children:t}),h.jsx("div",{className:"flex items-center gap-2",children:n})]})]})}const LZ=mi("border rounded-lg p-3 font-mono text-[11px]",{variants:{variant:{default:"border-border bg-panel",destructive:"border-offline/20 bg-offline/5 text-offline"}},defaultVariants:{variant:"default"}}),In=_.forwardRef(({className:e,variant:t,...n},s)=>h.jsx("div",{ref:s,role:"alert",className:ge(LZ({variant:t,className:e})),...n}));In.displayName="Alert";const nf=_.forwardRef(({className:e,...t},n)=>h.jsx("h5",{ref:n,className:ge("font-medium text-white mb-1",e),...t}));nf.displayName="AlertTitle";const Pn=_.forwardRef(({className:e,...t},n)=>h.jsx("p",{ref:n,className:ge("text-neutral-400",e),...t}));Pn.displayName="AlertDescription";const lk=_.createContext(void 0);function al(e){const t=_.useContext(lk);if(e===!1&&t===void 0)throw new Error(yn(27));return t}const UZ={...il,...va},mx=_.forwardRef(function(t,n){const{render:s,className:i,forceRender:a=!1,...l}=t,{store:f}=al(),d=f.useState("open"),p=f.useState("nested"),g=f.useState("mounted"),y=f.useState("transitionStatus");return zt("div",t,{state:{open:d,transitionStatus:y},ref:[f.context.backdropRef,n],stateAttributesMapping:UZ,props:[{role:"presentation",hidden:!g,style:{userSelect:"none",WebkitUserSelect:"none"}},l],enabled:a||!p})}),uk=_.forwardRef(function(t,n){const{render:s,className:i,id:a,...l}=t,{store:f}=al(),d=br(a);return f.useSyncedValueWithCleanup("descriptionElementId",d),zt("p",t,{ref:n,props:[{id:d},l]})});let $Z=(function(e){return e.nestedDialogs="--nested-dialogs",e})({}),BZ=(function(e){return e[e.open=Xi.open]="open",e[e.closed=Xi.closed]="closed",e[e.startingStyle=Xi.startingStyle]="startingStyle",e[e.endingStyle=Xi.endingStyle]="endingStyle",e.nested="data-nested",e.nestedDialogOpen="data-nested-dialog-open",e})({});const fk=_.createContext(void 0);function FZ(){const e=_.useContext(fk);if(e===void 0)throw new Error(yn(26));return e}const HZ={...il,...va,nestedDialogOpen(e){return e?{[BZ.nestedDialogOpen]:""}:null}},dk=_.forwardRef(function(t,n){const{className:s,finalFocus:i,initialFocus:a,render:l,...f}=t,{store:d}=al(),p=d.useState("descriptionElementId"),g=d.useState("disablePointerDismissal"),y=d.useState("floatingRootContext"),b=d.useState("popupProps"),x=d.useState("modal"),S=d.useState("mounted"),w=d.useState("nested"),T=d.useState("nestedOpenDialogCount"),C=d.useState("open"),k=d.useState("openMethod"),N=d.useState("titleElementId"),R=d.useState("transitionStatus"),M=d.useState("role");FZ(),ba({open:C,ref:d.context.popupRef,onComplete(){C&&d.context.onOpenChangeComplete?.(!0)}});function L(B){return B==="touch"?d.context.popupRef.current:!0}const j=a===void 0?L:a,A=T>0,G=zt("div",t,{state:{open:C,nested:w,transitionStatus:R,nestedDialogOpen:A},props:[b,{"aria-labelledby":N??void 0,"aria-describedby":p??void 0,role:M,tabIndex:-1,hidden:!S,onKeyDown(B){nk.has(B.key)&&B.stopPropagation()},style:{[$Z.nestedDialogs]:T}},f],ref:[n,d.context.popupRef,d.useStateSetter("popupElement")],stateAttributesMapping:HZ});return h.jsx(RA,{context:y,openInteractionType:k,disabled:!S,closeOnFocusOut:!g,initialFocus:j,returnFocus:i,modal:x!==!1,restoreFocus:"popup",children:G})}),hk=_.forwardRef(function(t,n){const{keepMounted:s=!1,...i}=t,{store:a}=al(),l=a.useState("mounted"),f=a.useState("modal"),d=a.useState("open");return l||s?h.jsx(fk.Provider,{value:s,children:h.jsxs(CA,{ref:n,...i,children:[l&&f===!0&&h.jsx(XA,{ref:a.context.internalBackdropRef,inert:hx(!d)}),t.children]})}):null});function qZ(e){const{store:t,parentContext:n,actionsRef:s}=e,i=t.useState("open"),a=t.useState("disablePointerDismissal"),l=t.useState("modal"),f=t.useState("popupElement"),{openMethod:d,triggerProps:p,reset:g}=AG(i);x7(t);const{forceUnmount:y}=S7(i,t,()=>{g()}),b=Ae(G=>{const B=Yt(G);return B.preventUnmountOnClose=()=>{t.set("preventUnmountingOnClose",!0)},B}),x=_.useCallback(()=>{t.setOpen(!1,b(E8))},[t,b]);_.useImperativeHandle(s,()=>({unmount:y,close:x}),[y,x]);const S=R7({popupStore:t,onOpenChange:t.setOpen,treatPopupAsFloatingElement:!0,noEmit:!0}),[w,T]=_.useState(0),C=w===0,k=D7(S),N=c7(S,{outsidePressEvent(){return t.context.internalBackdropRef.current||t.context.backdropRef.current?"intentional":{mouse:l==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}},outsidePress(G){if(!t.context.outsidePressEnabledRef.current||"button"in G&&G.button!==0||"touches"in G&&G.touches.length!==1)return!1;const B=Ur(G);if(C&&!a){const z=B;return l&&(t.context.internalBackdropRef.current||t.context.backdropRef.current)?t.context.internalBackdropRef.current===z||t.context.backdropRef.current===z||Ot(z,f)&&!z?.hasAttribute("data-base-ui-portal"):!0}return!1},escapeKey:C});KA(i&&l===!0,f);const{getReferenceProps:R,getFloatingProps:M,getTriggerProps:L}=I7([k,N]);t.useContextCallback("onNestedDialogOpen",G=>{T(G+1)}),t.useContextCallback("onNestedDialogClose",()=>{T(0)}),_.useEffect(()=>(n?.onNestedDialogOpen&&i&&n.onNestedDialogOpen(w),n?.onNestedDialogClose&&!i&&n.onNestedDialogClose(),()=>{n?.onNestedDialogClose&&i&&n.onNestedDialogClose()}),[i,n,w]);const j=_.useMemo(()=>R(p),[R,p]),A=_.useMemo(()=>L(p),[L,p]),P=_.useMemo(()=>M(),[M]);t.useSyncedValues({openMethod:d,activeTriggerProps:j,inactiveTriggerProps:A,popupProps:P,floatingRootContext:S,nestedOpenDialogCount:w})}const VZ={...E7,modal:Pe(e=>e.modal),nested:Pe(e=>e.nested),nestedOpenDialogCount:Pe(e=>e.nestedOpenDialogCount),disablePointerDismissal:Pe(e=>e.disablePointerDismissal),openMethod:Pe(e=>e.openMethod),descriptionElementId:Pe(e=>e.descriptionElementId),titleElementId:Pe(e=>e.titleElementId),viewportElement:Pe(e=>e.viewportElement),role:Pe(e=>e.role)};class KZ extends DA{constructor(t){super(GZ(t),{popupRef:_.createRef(),backdropRef:_.createRef(),internalBackdropRef:_.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:new fx,onOpenChange:void 0,onOpenChangeComplete:void 0},VZ)}setOpen=(t,n)=>{if(n.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},!t&&n.trigger==null&&this.state.activeTriggerId!=null&&(n.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(t,n),n.isCanceled)return;const s={open:t,nativeEvent:n.event,reason:n.reason,nested:this.state.nested};this.state.floatingRootContext.context.events?.emit("openchange",s);const i={open:t},a=n.trigger?.id??null;(a||t)&&(i.activeTriggerId=a,i.activeTriggerElement=n.trigger??null),this.update(i)}}function GZ(e={}){return{...w7(),modal:!0,disablePointerDismissal:!1,popupElement:null,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,role:"dialog",...e}}function ZZ(e){const{children:t,open:n,defaultOpen:s=!1,onOpenChange:i,onOpenChangeComplete:a,disablePointerDismissal:l=!1,modal:f=!0,actionsRef:d,handle:p,triggerId:g,defaultTriggerId:y=null}=e,b=al(!0),x=!!b,S=zn(()=>p?.store??new KZ({open:s,openProp:n,activeTriggerId:y,triggerIdProp:g,modal:f,disablePointerDismissal:l,nested:x})).current;uV(()=>{n===void 0&&S.state.open===!1&&s===!0&&S.update({open:!0,activeTriggerId:y})}),S.useControlledProp("openProp",n),S.useControlledProp("triggerIdProp",g),S.useSyncedValues({disablePointerDismissal:l,nested:x,modal:f}),S.useContextCallback("onOpenChange",i),S.useContextCallback("onOpenChangeComplete",a);const w=S.useState("payload");qZ({store:S,actionsRef:d,parentContext:b?.store.context});const T=_.useMemo(()=>({store:S}),[S]);return h.jsx(lk.Provider,{value:T,children:typeof t=="function"?t({payload:w}):t})}const pk=_.forwardRef(function(t,n){const{render:s,className:i,id:a,...l}=t,{store:f}=al(),d=br(a);return f.useSyncedValueWithCleanup("titleElementId",d),zt("h2",t,{ref:n,props:[{id:d},l]})}),$r=ZZ,YZ=_.forwardRef(({className:e,...t},n)=>h.jsx(mx,{ref:n,className:ge("fixed inset-0 z-50 bg-black/60 backdrop-blur-sm",e),...t}));YZ.displayName="DialogOverlay";const hr=_.forwardRef(({className:e,children:t,...n},s)=>h.jsxs(hk,{children:[h.jsx(mx,{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm"}),h.jsx(dk,{ref:s,className:ge("fixed z-50 top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-panel border border-border rounded-lg shadow-lg max-w-lg w-full p-0",e),...n,children:t})]}));hr.displayName="DialogContent";const pr=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("px-5 py-3 border-b border-border",e),...t}));pr.displayName="DialogHeader";const Nn=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("px-5 py-3 border-t border-border flex justify-end gap-2",e),...t}));Nn.displayName="DialogFooter";const mr=_.forwardRef(({className:e,...t},n)=>h.jsx(pk,{ref:n,className:ge("font-mono text-[10px] text-neutral-500 uppercase tracking-widest",e),...t}));mr.displayName="DialogTitle";const XZ=_.forwardRef(({className:e,...t},n)=>h.jsx(uk,{ref:n,className:ge("font-mono text-[10px] text-neutral-500",e),...t}));XZ.displayName="DialogDescription";const gx=_.forwardRef(({className:e,page:t,totalPages:n,totalItems:s,onPageChange:i,...a},l)=>h.jsxs("div",{ref:l,className:ge("px-5 py-2.5 border-t border-border flex items-center justify-between",e),...a,children:[h.jsxs("span",{className:"font-mono text-[10px] text-neutral-600",children:[s," items · Page ",t," of ",n]}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx(Oe,{size:"sm",variant:"default",disabled:t<=1,onClick:()=>i(t-1),children:"Prev"}),h.jsx(Oe,{size:"sm",variant:"default",disabled:t>=n,onClick:()=>i(t+1),children:"Next"})]})]}));gx.displayName="Pagination";const QZ=_.forwardRef(({className:e,orientation:t="horizontal",...n},s)=>h.jsx("hr",{ref:s,"aria-orientation":t==="vertical"?"vertical":void 0,className:ge("border-none m-0",t==="horizontal"?"h-px w-full bg-border":"w-px h-4 bg-border",e),...n}));QZ.displayName="Separator";const WZ=mi("fixed z-50 bg-panel shadow-lg overflow-auto",{variants:{side:{top:"top-0 left-0 w-full h-[400px] border-b border-border",right:"right-0 top-0 h-full w-[400px] border-l border-border",bottom:"bottom-0 left-0 w-full h-[400px] border-t border-border",left:"left-0 top-0 h-full w-[400px] border-r border-border"}},defaultVariants:{side:"right"}}),JZ=_.forwardRef(({className:e,side:t,children:n,...s},i)=>h.jsxs(hk,{children:[h.jsx(mx,{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm"}),h.jsx(dk,{ref:i,className:ge(WZ({side:t,className:e})),...s,children:n})]}));JZ.displayName="SheetContent";const eY=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("px-5 py-3 border-b border-border",e),...t}));eY.displayName="SheetHeader";const tY=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("px-5 py-3 border-t border-border flex justify-end gap-2",e),...t}));tY.displayName="SheetFooter";const nY=_.forwardRef(({className:e,...t},n)=>h.jsx(pk,{ref:n,className:ge("font-mono text-[10px] text-neutral-500 uppercase tracking-widest",e),...t}));nY.displayName="SheetTitle";const rY=_.forwardRef(({className:e,...t},n)=>h.jsx(uk,{ref:n,className:ge("text-sm text-neutral-400",e),...t}));rY.displayName="SheetDescription";const sY=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("rounded-md bg-neutral-800 animate-pulse",e),...t}));sY.displayName="Skeleton";const oY=_.createContext(void 0);function yx(){const e=_.useContext(oY);if(e===void 0)throw new Error(yn(64));return e}let iY=(function(e){return e.activationDirection="data-activation-direction",e.orientation="data-orientation",e})({});const mk={tabActivationDirection:e=>({[iY.activationDirection]:e})},gk=_.createContext(void 0);function aY(){const e=_.useContext(gk);if(e===void 0)throw new Error(yn(65));return e}const cY=_.forwardRef(function(t,n){const{className:s,disabled:i=!1,render:a,value:l,id:f,nativeButton:d=!0,...p}=t,{value:g,getTabPanelIdByValue:y,orientation:b}=yx(),{activateOnFocus:x,highlightedTabIndex:S,onTabActivation:w,setHighlightedTabIndex:T,tabsListElement:C}=aY(),k=br(f),N=_.useMemo(()=>({disabled:i,id:k,value:l}),[i,k,l]),{compositeProps:R,compositeRef:M,index:L}=ok({metadata:N}),j=l===g,A=_.useRef(!1);Le(()=>{if(A.current){A.current=!1;return}if(!(j&&L>-1&&S!==L))return;const V=C;if(V!=null){const U=Bo(Rt(V));if(U&&Ot(V,U))return}i||T(L)},[j,L,S,T,i,C]);const{getButtonProps:P,buttonRef:G}=el({disabled:i,native:d,focusableWhenDisabled:!0}),B=y(l),z=_.useRef(!1),Q=_.useRef(!1);function Y(V){j||i||w(l,Yt(ii,V.nativeEvent,void 0,{activationDirection:"none"}))}function ee(V){j||(L>-1&&!i&&T(L),!i&&x&&(!z.current||z.current&&Q.current)&&w(l,Yt(ii,V.nativeEvent,void 0,{activationDirection:"none"})))}function D(V){if(j||i)return;z.current=!0;function U(){z.current=!1,Q.current=!1}(!V.button||V.button===0)&&(Q.current=!0,Rt(V.currentTarget).addEventListener("pointerup",U,{once:!0}))}return zt("button",t,{state:{disabled:i,active:j,orientation:b},ref:[n,G,M],props:[R,{role:"tab","aria-controls":B,"aria-selected":j,id:k,onClick:Y,onFocus:ee,onPointerDown:D,[ik]:j?"":void 0,onKeyDownCapture(){A.current=!0}},p,P]})});let lY=(function(e){return e.index="data-index",e.activationDirection="data-activation-direction",e.orientation="data-orientation",e.hidden="data-hidden",e})({});const uY={...mk,...va},fY=_.forwardRef(function(t,n){const{className:s,value:i,render:a,keepMounted:l=!1,...f}=t,{value:d,getTabIdByPanelValue:p,orientation:g,tabActivationDirection:y,registerMountedTabPanel:b,unregisterMountedTabPanel:x}=yx(),S=br(),w=_.useMemo(()=>({id:S,value:i}),[S,i]),{ref:T,index:C}=px({metadata:w}),k=i===d,{mounted:N,transitionStatus:R,setMounted:M}=Ap(k),L=!N,j=p(i),A={hidden:L,orientation:g,tabActivationDirection:y,transitionStatus:R},P=_.useRef(null),G=zt("div",t,{state:A,ref:[n,T,P],props:[{"aria-labelledby":j,hidden:L,id:S,role:"tabpanel",tabIndex:k?0:-1,inert:hx(!k),[lY.index]:C},f],stateAttributesMapping:uY});return ba({open:k,ref:P,onComplete(){k||M(!1)}}),Le(()=>{if(!(L&&!l)&&S!=null)return b(i,S),()=>{x(i,S)}},[L,l,i,S,b,x]),l||N?G:null}),dY=_.forwardRef(function(t,n){const{activateOnFocus:s=!1,className:i,loopFocus:a=!0,render:l,...f}=t,{getTabElementBySelectedValue:d,onValueChange:p,orientation:g,value:y,setTabMap:b,tabActivationDirection:x}=yx(),[S,w]=_.useState(0),[T,C]=_.useState(null),k=hY(y,g,T,d),N=Ae((j,A)=>{if(j!==y){const P=k(j);A.activationDirection=P,p(j,A)}}),R={orientation:g,tabActivationDirection:x},M={"aria-orientation":g==="vertical"?"vertical":void 0,role:"tablist"},L=_.useMemo(()=>({activateOnFocus:s,highlightedTabIndex:S,onTabActivation:N,setHighlightedTabIndex:w,tabsListElement:T,value:y}),[s,S,N,w,T,y]);return h.jsx(gk.Provider,{value:L,children:h.jsx(ak,{render:l,className:i,state:R,refs:[n,C],props:[M,f],stateAttributesMapping:mk,highlightedIndex:S,enableHomeAndEndKeys:!0,loopFocus:a,orientation:g,onHighlightedIndexChange:w,onMapChange:b,disabledIndices:Nu})})});function GC(e,t){const{left:n,top:s}=e.getBoundingClientRect(),{left:i,top:a}=t.getBoundingClientRect(),l=n-i,f=s-a;return{left:l,top:f}}function hY(e,t,n,s){const[i,a]=_.useState(null);return Le(()=>{if(e==null||n==null){a(null);return}const l=s(e);if(l==null){a(null);return}const{left:f,top:d}=GC(l,n);a(t==="horizontal"?f:d)},[t,s,n,e]),_.useCallback(l=>{if(l===e)return"none";if(l==null)return a(null),"none";if(l!=null&&n!=null){const f=s(l);if(f!=null){const{left:d,top:p}=GC(f,n);if(i==null)return a(t==="horizontal"?d:p),"none";if(t==="horizontal"){if(d<i)return a(d),"left";if(d>i)return a(d),"right"}else{if(p<i)return a(p),"up";if(p>i)return a(p),"down"}}}return"none"},[s,t,i,n,e])}const pY=_.forwardRef(({className:e,...t},n)=>h.jsx(dY,{ref:n,className:ge("flex items-center gap-0.5",e),...t}));pY.displayName="TabsList";const mY=mi("inline-flex items-center justify-center cursor-pointer transition-all outline-none",{variants:{variant:{default:"font-mono text-[10px] text-neutral-500 border border-transparent rounded-sm px-2.5 py-1 hover:text-neutral-300 data-[selected]:text-white data-[selected]:border-border-bright data-[selected]:bg-white/[0.03]",pills:"font-mono text-[10px] text-neutral-500 border border-transparent rounded-full px-3 py-1 hover:text-neutral-300 data-[selected]:text-white data-[selected]:border-border-bright data-[selected]:bg-white/[0.03]"}},defaultVariants:{variant:"default"}}),gY=_.forwardRef(({className:e,variant:t,...n},s)=>h.jsx(cY,{ref:s,className:ge(mY({variant:t,className:e})),...n}));gY.displayName="TabsTrigger";const yY=_.forwardRef(({className:e,...t},n)=>h.jsx(fY,{ref:n,className:ge("outline-none",e),...t}));yY.displayName="TabsContent";const vY=_.forwardRef(({className:e,...t},n)=>h.jsx("p",{ref:n,className:ge("font-mono text-[11px] text-neutral-300",e),...t}));vY.displayName="Text";const bY=_.forwardRef(({className:e,...t},n)=>h.jsx("p",{ref:n,className:ge("font-mono text-[10px] text-neutral-500",e),...t}));bY.displayName="TextMuted";const xY=_.forwardRef(({className:e,...t},n)=>h.jsx("code",{ref:n,className:ge("font-mono text-[11px] text-white",e),...t}));xY.displayName="TextCode";const SY=_.forwardRef(({className:e,...t},n)=>h.jsx("span",{ref:n,className:ge("font-mono text-[9px] uppercase tracking-wider text-neutral-500",e),...t}));SY.displayName="TextLabel";const _Y=_.forwardRef(({className:e,...t},n)=>h.jsx("pre",{ref:n,className:ge("font-mono text-[11px] text-neutral-300 p-3 rounded border border-border bg-panel-alt overflow-x-auto",e),...t}));_Y.displayName="CodeBlock";function xa(e,t){const[n,s]=_.useState(()=>{if(typeof window>"u")return t;try{const a=window.localStorage.getItem(e);return a===null?t:JSON.parse(a)}catch{return t}});_.useEffect(()=>{try{n==null?window.localStorage.removeItem(e):window.localStorage.setItem(e,JSON.stringify(n))}catch{}},[e,n]);const i=_.useCallback(a=>{s(l=>typeof a=="function"?a(l):a)},[]);return[n,i]}const wY="console:instance-id";function Lt(){const[e,t]=xa(wY,""),n=e.trim();return _.useMemo(()=>({instanceId:n.length>0?n:void 0,rawInstanceId:e,setInstanceId:t,clearInstanceId:()=>t("")}),[n,e,t])}const Jn={stats:e=>["console","stats",e],timeseries:e=>["console","stats","timeseries",e],latency:e=>["console","stats","latency",e],commits:e=>["console","commits",e],commitDetail:(e,t,n)=>["console","commit-detail",e,t,n],timeline:e=>["console","timeline",e],clients:e=>["console","clients",e],eventDetail:(e,t,n)=>["console","event-detail",e,t,n],eventPayload:(e,t,n)=>["console","event-payload",e,t,n],handlers:e=>["console","handlers",e],prunePreview:e=>["console","prune","preview",e],operations:e=>["console","operations",e],apiKeys:e=>["console","api-keys",e],storage:e=>["console","storage",e]};function Si(e,t){return e===0?!1:e??t}function rf(e,t){return t?{...e,instanceId:t}:e}function Sa(e){return encodeURIComponent(String(e))}function Ln(e,t,n){const s=e.endsWith("/")?e.slice(0,-1):e,i=n?.toString();return`${s}${t}${i?`?${i}`:""}`}function sf(e={}){const t=Vt(),{instanceId:n}=Lt(),s=e.instanceId??n,i=rf(e.partitionId?{partitionId:e.partitionId}:{},s);return Wn({queryKey:Jn.stats({partitionId:e.partitionId,instanceId:s}),queryFn:()=>{if(!t)throw new Error("Not connected");return Xu(t.GET("/console/stats",{params:{query:i}}))},enabled:!!t,refetchInterval:Si(e.refetchIntervalMs,5e3)})}function EY(e={},t={}){const n=Vt(),{config:s}=Dt(),{instanceId:i}=Lt(),a=e.instanceId??i;return Wn({queryKey:Jn.timeseries({...e,instanceId:a}),queryFn:async()=>{if(!n||!s)throw new Error("Not connected");const l=new URLSearchParams;e.interval&&l.set("interval",e.interval),e.range&&l.set("range",e.range),e.partitionId&&l.set("partitionId",e.partitionId),a&&l.set("instanceId",a);const f=await fetch(`${s.serverUrl}/console/stats/timeseries?${l}`,{headers:{Authorization:`Bearer ${s.token}`}});if(!f.ok)throw new Error("Failed to fetch timeseries stats");return f.json()},enabled:(t.enabled??!0)&&!!n&&!!s,refetchInterval:Si(t.refetchIntervalMs,3e4)})}function TY(e={},t={}){const n=Vt(),{config:s}=Dt(),{instanceId:i}=Lt(),a=e.instanceId??i;return Wn({queryKey:Jn.latency({...e,instanceId:a}),queryFn:async()=>{if(!n||!s)throw new Error("Not connected");const l=new URLSearchParams;e.range&&l.set("range",e.range),e.partitionId&&l.set("partitionId",e.partitionId),a&&l.set("instanceId",a);const f=await fetch(`${s.serverUrl}/console/stats/latency?${l}`,{headers:{Authorization:`Bearer ${s.token}`}});if(!f.ok)throw new Error("Failed to fetch latency stats");return f.json()},enabled:(t.enabled??!0)&&!!n&&!!s,refetchInterval:Si(t.refetchIntervalMs,3e4)})}function CY(e={},t={}){const n=Vt(),{instanceId:s}=Lt(),i=e.instanceId??s,a=rf({limit:e.limit,offset:e.offset,partitionId:e.partitionId},i);return Wn({queryKey:Jn.commits({...e,instanceId:i}),queryFn:()=>{if(!n)throw new Error("Not connected");return Xu(n.GET("/console/commits",{params:{query:a}}))},enabled:(t.enabled??!0)&&!!n,refetchInterval:Si(t.refetchIntervalMs,1e4)})}function RY(e,t={}){const n=Vt(),{config:s}=Dt(),{instanceId:i}=Lt(),a=t.instanceId??i;return Wn({queryKey:Jn.commitDetail(e,t.partitionId,a),queryFn:async()=>{if(!n||!s)throw new Error("Not connected");if(e===void 0)throw new Error("Commit sequence is required");const l=new URLSearchParams;t.partitionId&&l.set("partitionId",t.partitionId),a&&l.set("instanceId",a);const f=l.toString(),d=await fetch(`${s.serverUrl}/console/commits/${Sa(e)}${f?`?${f}`:""}`,{headers:{Authorization:`Bearer ${s.token}`}});if(!d.ok)throw new Error("Failed to fetch commit detail");return d.json()},enabled:(t.enabled??!0)&&e!==void 0&&!!n})}function NY(e={},t={}){const n=Vt(),{instanceId:s}=Lt(),i=e.instanceId??s,a=rf({limit:e.limit,offset:e.offset,partitionId:e.partitionId,view:e.view,eventType:e.eventType,actorId:e.actorId,clientId:e.clientId,requestId:e.requestId,traceId:e.traceId,table:e.table,outcome:e.outcome,search:e.search,from:e.from,to:e.to},i);return Wn({queryKey:Jn.timeline({...e,instanceId:i}),queryFn:()=>{if(!n)throw new Error("Not connected");return Xu(n.GET("/console/timeline",{params:{query:a}}))},enabled:(t.enabled??!0)&&!!n,refetchInterval:Si(t.refetchIntervalMs,1e4)})}function yk(e={},t={}){const n=Vt(),{instanceId:s}=Lt(),i=e.instanceId??s,a=rf({limit:e.limit,offset:e.offset,partitionId:e.partitionId},i);return Wn({queryKey:Jn.clients({...e,instanceId:i}),queryFn:()=>{if(!n)throw new Error("Not connected");return Xu(n.GET("/console/clients",{params:{query:a}}))},enabled:(t.enabled??!0)&&!!n,refetchInterval:Si(t.refetchIntervalMs,1e4)})}function jY(e,t={}){const n=Vt(),{config:s}=Dt(),{instanceId:i}=Lt(),a=t.instanceId??i;return Wn({queryKey:Jn.eventDetail(e,t.partitionId,a),queryFn:async()=>{if(!n||!s)throw new Error("Not connected");if(e===void 0)throw new Error("Event id is required");const l=new URLSearchParams;t.partitionId&&l.set("partitionId",t.partitionId),a&&l.set("instanceId",a);const f=l.toString(),d=await fetch(`${s.serverUrl}/console/events/${Sa(e)}${f?`?${f}`:""}`,{headers:{Authorization:`Bearer ${s.token}`}});if(!d.ok)throw new Error("Failed to fetch event detail");return d.json()},enabled:(t.enabled??!0)&&e!==void 0&&!!n})}function AY(e,t={}){const n=Vt(),{config:s}=Dt(),{instanceId:i}=Lt(),a=t.instanceId??i;return Wn({queryKey:Jn.eventPayload(e,t.partitionId,a),queryFn:async()=>{if(!n||!s)throw new Error("Not connected");if(e===void 0)throw new Error("Event id is required");const l=new URLSearchParams;t.partitionId&&l.set("partitionId",t.partitionId),a&&l.set("instanceId",a);const f=l.toString(),d=await fetch(`${s.serverUrl}/console/events/${Sa(e)}/payload${f?`?${f}`:""}`,{headers:{Authorization:`Bearer ${s.token}`}});if(!d.ok)throw new Error("Failed to fetch event payload");return d.json()},enabled:(t.enabled??!0)&&e!==void 0&&!!n})}function kY(e={}){const t=Vt(),{config:n}=Dt(),{instanceId:s}=Lt(),i=e.instanceId??s;return Wn({queryKey:Jn.handlers(i),queryFn:async()=>{if(!t||!n)throw new Error("Not connected");const a=new URLSearchParams;i&&a.set("instanceId",i);const l=await fetch(Ln(n.serverUrl,"/console/handlers",a),{headers:{Authorization:`Bearer ${n.token}`}});if(!l.ok)throw new Error("Failed to fetch handlers");return l.json()},enabled:!!t&&!!n})}function OY(e={}){const t=Vt(),{config:n}=Dt(),{instanceId:s}=Lt(),i=e.instanceId??s;return Wn({queryKey:Jn.prunePreview(i),queryFn:async()=>{if(!t||!n)throw new Error("Not connected");const a=new URLSearchParams;i&&a.set("instanceId",i);const l=await fetch(Ln(n.serverUrl,"/console/prune/preview",a),{method:"POST",headers:{Authorization:`Bearer ${n.token}`}});if(!l.ok)throw new Error("Failed to fetch prune preview");return l.json()},enabled:!!t&&!!n&&(e.enabled??!0)})}function MY(e={},t={}){const n=Vt(),{instanceId:s}=Lt(),i=e.instanceId??s,a=rf({limit:e.limit,offset:e.offset,operationType:e.operationType,partitionId:e.partitionId},i);return Wn({queryKey:Jn.operations({...e,instanceId:i}),queryFn:()=>{if(!n)throw new Error("Not connected");return Xu(n.GET("/console/operations",{params:{query:a}}))},enabled:(t.enabled??!0)&&!!n,refetchInterval:Si(t.refetchIntervalMs,1e4)})}function IY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async({clientId:i,partitionId:a,instanceId:l})=>{if(!e||!t)throw new Error("Not connected");const f=l??n,d=new URLSearchParams;a&&d.set("partitionId",a),f&&d.set("instanceId",f);const p=await fetch(Ln(t.serverUrl,`/console/clients/${Sa(i)}`,d),{method:"DELETE",headers:{Authorization:`Bearer ${t.token}`}});if(!p.ok)throw new Error("Failed to evict client");return p.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","clients"]}),s.invalidateQueries({queryKey:["console","stats"]}),s.invalidateQueries({queryKey:["console","operations"]})}})}function PY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async()=>{if(!e||!t)throw new Error("Not connected");const i=new URLSearchParams;n&&i.set("instanceId",n);const a=await fetch(Ln(t.serverUrl,"/console/prune",i),{method:"POST",headers:{Authorization:`Bearer ${t.token}`}});if(!a.ok)throw new Error("Failed to prune");return a.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","stats"]}),s.invalidateQueries({queryKey:["console","commits"]}),s.invalidateQueries({queryKey:["console","timeline"]}),s.invalidateQueries({queryKey:["console","prune","preview"]}),s.invalidateQueries({queryKey:["console","operations"]})}})}function DY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async()=>{if(!e||!t)throw new Error("Not connected");const i=new URLSearchParams;n&&i.set("instanceId",n);const a=await fetch(Ln(t.serverUrl,"/console/compact",i),{method:"POST",headers:{Authorization:`Bearer ${t.token}`}});if(!a.ok)throw new Error("Failed to compact");return a.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","stats"]}),s.invalidateQueries({queryKey:["console","operations"]})}})}function zY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async i=>{if(!e||!t)throw new Error("Not connected");const a=i.instanceId??n,l=new URLSearchParams;a&&l.set("instanceId",a);const f=await fetch(Ln(t.serverUrl,"/console/notify-data-change",l),{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"Content-Type":"application/json"},body:JSON.stringify({tables:i.tables,partitionId:i.partitionId})});if(!f.ok)throw new Error("Failed to notify data change");return f.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","stats"]}),s.invalidateQueries({queryKey:["console","commits"]}),s.invalidateQueries({queryKey:["console","timeline"]}),s.invalidateQueries({queryKey:["console","operations"]})}})}function LY(e={}){const t=Vt(),{config:n}=Dt(),{instanceId:s}=Lt(),i=e.instanceId??s;return Wn({queryKey:Jn.apiKeys({...e,instanceId:i}),queryFn:async()=>{if(!t||!n)throw new Error("Not connected");const a=new URLSearchParams;e.limit!==void 0&&a.set("limit",String(e.limit)),e.offset!==void 0&&a.set("offset",String(e.offset)),e.type&&a.set("type",e.type),e.status&&a.set("status",e.status),e.expiresWithinDays!==void 0&&a.set("expiresWithinDays",String(e.expiresWithinDays)),i&&a.set("instanceId",i);const l=await fetch(Ln(n.serverUrl,"/console/api-keys",a),{headers:{Authorization:`Bearer ${n.token}`}});if(!l.ok)throw new Error("Failed to fetch API keys");return l.json()},enabled:!!t&&!!n})}function UY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async i=>{if(!e||!t)throw new Error("Not connected");const a=new URLSearchParams;n&&a.set("instanceId",n);const l=await fetch(Ln(t.serverUrl,"/console/api-keys",a),{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"Content-Type":"application/json"},body:JSON.stringify(i)});if(!l.ok)throw new Error("Failed to create API key");return l.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","api-keys"]})}})}function $Y(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async i=>{if(!e||!t)throw new Error("Not connected");const a=new URLSearchParams;n&&a.set("instanceId",n);const l=await fetch(Ln(t.serverUrl,`/console/api-keys/${Sa(i)}`,a),{method:"DELETE",headers:{Authorization:`Bearer ${t.token}`}});if(!l.ok)throw new Error("Failed to revoke API key");return l.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","api-keys"]})}})}function BY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async i=>{if(!e||!t)throw new Error("Not connected");const a=new URLSearchParams;n&&a.set("instanceId",n);const l=await fetch(Ln(t.serverUrl,"/console/api-keys/bulk-revoke",a),{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"Content-Type":"application/json"},body:JSON.stringify(i)});if(!l.ok)throw new Error("Failed to bulk revoke API keys");return l.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","api-keys"]})}})}function FY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async i=>{if(!e||!t)throw new Error("Not connected");const a=new URLSearchParams;n&&a.set("instanceId",n);const l=await fetch(Ln(t.serverUrl,`/console/api-keys/${Sa(i)}/rotate`,a),{method:"POST",headers:{Authorization:`Bearer ${t.token}`}});if(!l.ok)throw new Error("Failed to rotate API key");return l.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","api-keys"]})}})}function HY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async i=>{if(!e||!t)throw new Error("Not connected");const a=new URLSearchParams;n&&a.set("instanceId",n);const l=await fetch(Ln(t.serverUrl,`/console/api-keys/${Sa(i)}/rotate/stage`,a),{method:"POST",headers:{Authorization:`Bearer ${t.token}`}});if(!l.ok)throw new Error("Failed to stage-rotate API key");return l.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","api-keys"]})}})}function qY(e={}){const{config:t}=Dt();return Wn({queryKey:Jn.storage({prefix:e.prefix,cursor:e.cursor,limit:e.limit}),queryFn:async()=>{if(!t)throw new Error("Not connected");const n=new URLSearchParams;e.prefix&&n.set("prefix",e.prefix),e.cursor&&n.set("cursor",e.cursor),e.limit&&n.set("limit",String(e.limit));const s=await fetch(Ln(t.serverUrl,"/console/storage",n),{method:"GET",headers:{Authorization:`Bearer ${t.token}`}});if(!s.ok)throw new Error("Failed to list blobs");return s.json()},enabled:!!t,refetchInterval:Si(e.refetchIntervalMs,3e4)})}function VY(){const{config:e}=Dt(),t=_r();return is({mutationFn:async n=>{if(!e)throw new Error("Not connected");const s=encodeURIComponent(n),i=await fetch(Ln(e.serverUrl,`/console/storage/${s}`,new URLSearchParams),{method:"DELETE",headers:{Authorization:`Bearer ${e.token}`}});if(!i.ok)throw new Error("Failed to delete blob");return i.json()},onSuccess:()=>{t.invalidateQueries({queryKey:["console","storage"]})}})}function KY(){const{config:e}=Dt();return async t=>{if(!e)throw new Error("Not connected");const n=encodeURIComponent(t),s=await fetch(Ln(e.serverUrl,`/console/storage/${n}/download`,new URLSearchParams),{method:"GET",headers:{Authorization:`Bearer ${e.token}`}});if(!s.ok)throw new Error("Failed to download blob");const i=await s.blob(),a=URL.createObjectURL(i),l=document.createElement("a");l.href=a,l.download=t.split("/").pop()||t,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(a)}}const GY="console:partition-id";function of(){const[e,t]=xa(GY,""),n=e.trim();return _.useMemo(()=>({partitionId:n.length>0?n:void 0,rawPartitionId:e,setPartitionId:t,clearPartitionId:()=>t("")}),[n,e,t])}const ZC={refreshInterval:5,timeFormat:"relative",showSparklines:!0,pageSize:20};function af(){const[e,t]=xa("console:preferences",ZC);return{preferences:e,setPreferences:t,updatePreference:(i,a)=>{t(l=>({...l,[i]:a}))},resetPreferences:()=>{t(ZC)}}}const ZY=[{value:5,label:"5 seconds"},{value:10,label:"10 seconds"},{value:30,label:"30 seconds"},{value:60,label:"1 minute"},{value:0,label:"Manual only"}],YY=[{value:10,label:"10"},{value:20,label:"20"},{value:50,label:"50"},{value:100,label:"100"}],vx="syncular-console-root";function XY(e){e.classList.add(vx)}const QY=[{suffix:"",label:"Command"},{suffix:"/stream",label:"Stream"},{suffix:"/fleet",label:"Fleet"},{suffix:"/ops",label:"Ops"},{suffix:"/storage",label:"Storage"},{suffix:"/config",label:"Config"}];function WY(e){const t=e?.trim()??"";return!t||t==="/"?"":(t.startsWith("/")?t:`/${t}`).replace(/\/+$/g,"")}function By(e,t){return e?t?`${e}${t}`:e:t||"/"}function JY({basePath:e,appHref:t,modeBadge:n}){const{connect:s,config:i,isConnected:a,isConnecting:l}=Dt(),{preferences:f}=af(),{instanceId:d,rawInstanceId:p,setInstanceId:g,clearInstanceId:y}=Lt(),{partitionId:b,rawPartitionId:x,setPartitionId:S,clearPartitionId:w}=of(),T=vr({select:P=>P.location.pathname}),{data:C}=sf({refetchIntervalMs:f.refreshInterval*1e3,partitionId:b,instanceId:d}),k=WY(e),N=_.useMemo(()=>QY.map(P=>({...P,id:By(k,P.suffix)})),[k]),R=By(k,""),M=By(k,"/config"),L=l?"connecting":a?"connected":i?"disconnected":"not-configured",j=N.find(P=>P.suffix===""?T===R||T===`${R}/`:T.startsWith(P.id))?.id??R,A=C?[{label:"HEAD",value:`#${C.maxCommitSeq}`},{label:"COMMITS",value:`${C.commitCount}`},{label:"CHANGES",value:`${C.changeCount}`},{label:"CLIENTS",value:`${C.activeClientCount}/${C.clientCount}`}]:[];return h.jsxs("div",{className:`${vx} h-screen bg-background text-foreground flex flex-col`,children:[h.jsx(zZ,{brand:h.jsx(xc,{to:R,children:h.jsx(DZ,{label:"console"})}),center:h.jsx(jZ,{items:N,activeId:j,renderItem:(P,{active:G})=>h.jsx(xc,{to:P.id,children:h.jsx(ck,{active:G,children:P.label})},P.id)}),right:h.jsxs("div",{className:"flex items-center gap-2",children:[n?h.jsx(mn,{variant:"flow",className:"hidden md:inline-flex px-2 py-1 text-[10px]",children:n}):null,h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("span",{className:"font-mono text-[9px] text-neutral-500 uppercase tracking-wide",children:"Instance"}),h.jsx(Gn,{variant:"mono",value:p,onChange:P=>g(P.target.value),onBlur:P=>g(P.target.value.trim()),placeholder:"all",className:"h-7 w-[110px] px-2 py-1"}),d?h.jsx(Oe,{variant:"ghost",size:"sm",className:"h-7 px-2 text-[10px]",onClick:y,children:"All"}):null]}),h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("span",{className:"font-mono text-[9px] text-neutral-500 uppercase tracking-wide",children:"Partition"}),h.jsx(Gn,{variant:"mono",value:x,onChange:P=>S(P.target.value),onBlur:P=>S(P.target.value.trim()),placeholder:"all",className:"h-7 w-[110px] px-2 py-1"}),b?h.jsx(Oe,{variant:"ghost",size:"sm",className:"h-7 px-2 text-[10px]",onClick:w,children:"All"}):null]}),h.jsx(O8,{state:L}),h.jsx(xc,{to:M,children:h.jsx(Oe,{variant:T===M?"secondary":"ghost",size:"icon",children:h.jsx(Y8,{className:"h-3 w-3"})})}),t?h.jsxs("a",{href:t,className:NZ,children:[h.jsx(G8,{className:"h-3 w-3"}),"Go to app"]}):null]})}),h.jsx("main",{className:"flex-1 overflow-auto pb-[32px]",children:h.jsx("div",{className:"min-h-full",children:a||T===M?h.jsx("div",{style:{animation:"pageIn 0.3s ease-out"},children:h.jsx(WN,{})},T):h.jsx(eX,{configPath:M,hasSavedConfig:!!i,isConnecting:l,onConnect:()=>{s()}})})}),a&&h.jsx(qj,{isLive:a,metrics:A,uptime:"--"})]})}function eX({configPath:e,hasSavedConfig:t,isConnecting:n,onConnect:s}){return h.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[h.jsx("p",{className:"mb-4 text-foreground-muted",children:"Not connected to a @syncular server"}),h.jsxs("div",{className:"flex items-center gap-2",children:[t&&h.jsx(Oe,{variant:"default",onClick:s,disabled:n,children:n?"Connecting...":"Connect"}),h.jsx(xc,{to:e,children:h.jsx(Oe,{variant:"link",children:"Configure connection"})})]})]})}const lo=kH({component:JY});function tX(){return typeof window>"u"?!1:new URLSearchParams(window.location.search).get("swServer")==="1"}function nX(e={}){const{maxEvents:t=100,enabled:n=!0,staleAfterMs:s=65e3,replayLimit:i=100,partitionId:a,instanceId:l}=e,{config:f,isConnected:d}=Dt(),{instanceId:p}=Lt(),g=l??p,[y,b]=_.useState([]),[x,S]=_.useState(!1),[w,T]=_.useState("disconnected"),[C,k]=_.useState(null),N=_.useRef(null),R=_.useRef(null),M=_.useRef(null),L=_.useRef(0),j=_.useRef(0),A=_.useRef(null),P=_.useRef(null),G=_.useCallback(()=>{b([]),A.current=null,P.current=null},[]);return _.useEffect(()=>{if(!n||!d||!f?.serverUrl||!f?.token)return;let B=!1;const z=Number.isFinite(i)?Math.max(1,Math.min(500,Math.floor(i))):100;if(tX()||typeof WebSocket>"u"){T("connecting"),S(!1);let V=null,U=!1;const I=async()=>{if(!(B||U)){U=!0;try{const H=new URL(f.serverUrl,window.location.origin),W=H.pathname.endsWith("/")?H.pathname.slice(0,-1):H.pathname;H.pathname=`${W}/console/events`,H.search="",H.searchParams.set("limit",String(z)),H.searchParams.set("offset","0"),a&&H.searchParams.set("partitionId",a);const X=await fetch(H.toString(),{headers:{Authorization:`Bearer ${f.token}`}});if(!X.ok)throw new Error(`Live event polling failed (${X.status})`);const oe=await X.json(),de=(Array.isArray(oe.items)?oe.items:[]).filter(Me=>g?Me.instanceId===g:!0).sort((Me,_e)=>Me.eventId-_e.eventId),xe=P.current??-1,he=de.filter(Me=>Me.eventId>xe);if(he.length>0){const Me=he.map(ne=>({type:ne.eventType,timestamp:ne.createdAt,data:ne})).reverse();b(ne=>[...Me,...ne].slice(0,t));const _e=he[he.length-1];P.current=_e.eventId,A.current=_e.createdAt}else if(de.length>0){const Me=de[de.length-1];P.current=Math.max(P.current??-1,Me.eventId),A.current=Me.createdAt}k(null),S(!0),T("connected")}catch(H){B||(S(!1),T("disconnected"),k(H instanceof Error?H:new Error("Live event polling failed")))}finally{U=!1}}};return I(),V=setInterval(()=>{I()},2e3),()=>{B=!0,V&&clearInterval(V),S(!1),T("disconnected")}}const Y=()=>{R.current&&(clearTimeout(R.current),R.current=null)},ee=()=>{M.current&&(clearInterval(M.current),M.current=null)},D=()=>{if(B||R.current)return;L.current+=1;const V=Math.min(3e4,1e3*2**Math.max(0,L.current-1)),U=Math.floor(V*.2*Math.random()),I=V+U;R.current=setTimeout(()=>{R.current=null,B||q()},I)},K=()=>{j.current=Date.now(),S(!0),T("connected")},q=()=>{if(B)return;T("connecting"),Y();const V=(()=>{const I=new URL(f.serverUrl,window.location.origin);I.protocol=I.protocol==="https:"?"wss:":"ws:";const H=I.pathname.endsWith("/")?I.pathname.slice(0,-1):I.pathname;return I.pathname=`${H}/console/events/live`,I.search="",A.current&&I.searchParams.set("since",A.current),I.searchParams.set("replayLimit",String(z)),a&&I.searchParams.set("partitionId",a),g&&I.searchParams.set("instanceId",g),I.toString()})(),U=new WebSocket(V);N.current=U,U.onopen=()=>{if(B){U.close();return}L.current=0,k(null),T("connecting"),S(!1);try{U.send(JSON.stringify({type:"auth",token:f.token}))}catch{U.close();return}ee(),M.current=setInterval(()=>{const I=N.current;if(!I||I.readyState!==WebSocket.OPEN)return;const H=j.current;!H||Date.now()-H<=s||(S(!1),T("stale"),I.close())},1e3)},U.onclose=()=>{B||(S(!1),T("disconnected"),ee(),D())},U.onerror=()=>{B||k(new Error("WebSocket connection failed"))},U.onmessage=I=>{try{const H=JSON.parse(I.data),W=H.type;if(K(),W==="connected"||W==="heartbeat"||W==="auth_required")return;if(W==="error"){const de=typeof H.message=="string"?H.message:"Live events authentication failed";k(new Error(de));return}const X={type:W,timestamp:H.timestamp||new Date().toISOString(),data:H};if(a&&X.data.partitionId!==a||g&&X.data.instanceId!==g)return;const oe=Date.parse(A.current??""),se=Date.parse(X.timestamp);Number.isFinite(se)&&(!Number.isFinite(oe)||se>oe)&&(A.current=X.timestamp),b(de=>[X,...de].slice(0,t))}catch{}}};return q(),()=>{B=!0,Y(),ee(),N.current&&(N.current.close(),N.current=null),S(!1),T("disconnected")}},[n,d,f?.serverUrl,f?.token,t,a,g,i,s]),{events:y,isConnected:x,connectionState:w,error:C,clearEvents:G}}function rX(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async()=>{if(!e||!t)throw new Error("Not connected");const i=new URLSearchParams;n&&i.set("instanceId",n);const a=i.toString(),l=await fetch(`${t.serverUrl}/console/events${a?`?${a}`:""}`,{method:"DELETE",headers:{Authorization:`Bearer ${t.token}`}});if(!l.ok)throw new Error("Failed to clear events");return l.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","events"]})}})}const sX=_.createContext(null);function vk(){const[e,t]=xa("console:time-range","24h");return{range:e,setRange:t}}const oX=[{hint:"ios",type:"mobile"},{hint:"android",type:"mobile"},{hint:"mobile",type:"mobile"},{hint:"tablet",type:"tablet"},{hint:"desktop",type:"desktop"},{hint:"mac",type:"desktop"},{hint:"windows",type:"desktop"},{hint:"linux",type:"desktop"},{hint:"browser",type:"browser"},{hint:"web",type:"browser"},{hint:"server",type:"server"},{hint:"api",type:"server"},{hint:"iot",type:"iot"},{hint:"sensor",type:"iot"}];function iX(e){const t=e.toLowerCase();for(const n of oX)if(t.includes(n.hint))return n.type;return"client"}function aX(e){const t=e.toLowerCase();return t.includes("pglite")?"PGlite":t.includes("sqlite")||t.includes("wa-sqlite")?"SQLite":t.includes("postgres")||t.includes("pg")?"PostgreSQL":"unknown"}function cX(e,t){return typeof e.lagCommitCount=="number"?Math.max(0,e.lagCommitCount):t?Math.max(0,t.maxCommitSeq-e.cursor):0}function lX(e,t){return e.activityState==="stale"?"offline":t>0?"syncing":"online"}function uX(e,t){return e.length<=16?e:`${e.slice(0,12)}-${t+1}`}function fX(e,t,n={}){const s=n.maxNodes??10;return e.slice(0,s).map((i,a)=>{const l=cX(i,t),f=lX(i,l);return{id:uX(i.clientId,a),type:iX(i.clientId),status:f,cursor:Math.max(0,i.cursor),actor:i.actorId,mode:i.connectionMode,dialect:aX(i.clientId),scopes:Object.keys(i.effectiveScopes||{}),lastSeen:i.updatedAt}})}const dX={enabled:!1,thresholds:{p90Latency:500,errorRate:5,clientLag:100}};function YC(e,t="relative"){if(t==="absolute")return new Date(e).toLocaleString();const n=new Date(e),i=new Date().getTime()-n.getTime(),a=Math.floor(i/1e3);return a<60?`${a}s ago`:a<3600?`${Math.floor(a/60)}m ago`:a<86400?`${Math.floor(a/3600)}h ago`:`${Math.floor(a/86400)}d ago`}function hX(e){const t=e.length>1&&e.endsWith("/")?e.slice(0,-1):e;return t==="/console"||t.startsWith("/console/")?"/console/stream":"/stream"}function pX(){const e=mp(),t=_.useMemo(()=>typeof window>"u"?"/stream":hX(window.location.pathname),[]),n=vk(),{range:s}=n,{preferences:i}=af(),{partitionId:a}=of(),l=i.refreshInterval*1e3,[f]=xa("console:alert-config",dX),[d,p]=_.useState("1h"),{data:g}=sf({refetchIntervalMs:l,partitionId:a}),{data:y}=EY({range:s,partitionId:a},{refetchIntervalMs:l}),{data:b}=TY({range:s,partitionId:a},{refetchIntervalMs:l}),{data:x}=CY({limit:5,partitionId:a},{refetchIntervalMs:l}),{data:S}=yk({limit:12,offset:0,partitionId:a},{refetchIntervalMs:l}),{events:w,isConnected:T}=nX({maxEvents:8,partitionId:a}),C=_.useMemo(()=>{const z=y?.buckets??[];let Q=0,Y=0;for(const D of z)Q+=D.pushCount+D.pullCount,Y+=D.errorCount;const ee=Q>0?Y/Q*100:0;return{totalEvents:Q,errorRate:ee}},[y?.buckets]),k=_.useMemo(()=>S?.items?fX(S.items,g,{maxNodes:12}):[],[S?.items,g]),N=k.filter(z=>z.status!=="offline").length,R=k.filter(z=>z.status==="offline").length,M=_.useMemo(()=>g?[{label:"Ops (Range)",value:C.totalEvents,color:"flow"},{label:"P50 Latency",value:b?.push?.p50??0,unit:"ms",color:"healthy"},{label:"Error Rate",value:`${C.errorRate.toFixed(1)}%`,color:C.errorRate>0?"offline":"muted"},{label:"Active Clients",value:g.activeClientCount,color:"syncing"},{label:"Pending",value:g.maxActiveClientCursor!==null&&g.maxCommitSeq>0?g.maxCommitSeq-(g.minActiveClientCursor??0):0,color:"relay"}]:[],[g,b,C.errorRate,C.totalEvents]),L=_.useMemo(()=>w.map(z=>({type:z.type.toUpperCase(),actor:z.data?.actorId??"",table:(z.data?.tables??[])[0]??"",time:YC(z.timestamp,i.timeFormat)})),[w,i.timeFormat]),j=_.useMemo(()=>{const z=y?.buckets;if(!z?.length)return[];const Q=Math.max(...z.map(Y=>Math.max(Y.pushCount,Y.pullCount)),1);return z.map(Y=>({pushPercent:Q>0?Y.pushCount/Q*100:0,pullPercent:Q>0?Y.pullCount/Q*100:0}))},[y?.buckets]),A=_.useMemo(()=>{if(!b)return[];const z=Math.max(b.push.p50,b.push.p90,b.push.p99,b.pull.p50,b.pull.p90,b.pull.p99,1);return[{label:"P50",pushMs:b.push.p50,pullMs:b.pull.p50,pushBarPercent:b.push.p50/z*100,pullBarPercent:b.pull.p50/z*100},{label:"P90",pushMs:b.push.p90,pullMs:b.pull.p90,pushBarPercent:b.push.p90/z*100,pullBarPercent:b.pull.p90/z*100},{label:"P99",pushMs:b.push.p99,pullMs:b.pull.p99,pushBarPercent:b.push.p99/z*100,pullBarPercent:b.pull.p99/z*100}]},[b]),P=_.useMemo(()=>x?.items?x.items.map(z=>({seq:z.commitSeq,actor:z.actorId,changes:z.changeCount,tables:(z.affectedTables??[]).join(", "),time:YC(z.createdAt,i.timeFormat)})):[],[x?.items,i.timeFormat]),G=_.useMemo(()=>Math.max(0,100-C.errorRate),[C.errorRate]),B=_.useMemo(()=>{if(!f.enabled||!g)return[];const z=[];return b?.push?.p90&&b.push.p90>f.thresholds.p90Latency&&z.push(`P90 push latency (${b.push.p90}ms) exceeds threshold (${f.thresholds.p90Latency}ms)`),g.minActiveClientCursor!==null&&g.maxCommitSeq-g.minActiveClientCursor>f.thresholds.clientLag&&z.push(`Client lag (${g.maxCommitSeq-g.minActiveClientCursor}) exceeds threshold (${f.thresholds.clientLag})`),C.errorRate>f.thresholds.errorRate&&z.push(`Error rate (${C.errorRate.toFixed(1)}%) exceeds threshold (${f.thresholds.errorRate}%)`),z},[f,g,b,C.errorRate]);return g?h.jsx(sX.Provider,{value:n,children:h.jsxs("div",{className:"flex flex-col",children:[B.length>0&&h.jsx("div",{className:"px-6 pb-4",children:h.jsxs(In,{variant:"destructive",children:[h.jsx(nf,{children:"Threshold Exceeded"}),h.jsx(Pn,{children:B.map((z,Q)=>h.jsx("span",{className:"block",children:z},Q))})]})}),h.jsx(FA,{clients:k,totalNodes:k.length+2,onlineCount:N,offlineCount:R,relayClientIds:[]}),h.jsx(Wj,{items:M}),h.jsxs("div",{className:"flex",children:[h.jsxs("div",{className:"flex-1 min-w-0 flex flex-col",children:[h.jsx("div",{className:"border-b border-border border-r border-border",children:h.jsx(Ej,{bars:j,activeRange:d,onRangeChange:p})}),h.jsx("div",{className:"border-b border-border border-r border-border",children:h.jsx(Jj,{buckets:A,successRate:G})}),h.jsx("div",{className:"border-r border-border",children:h.jsx(Vj,{commits:P,onViewAll:()=>e({href:t})})})]}),h.jsx(eA,{entries:L,isConnected:T,maxVisible:20,maxHeight:"calc(100vh - 200px)"})]})]})}):h.jsx("div",{className:"flex items-center justify-center py-24",children:h.jsx(Pt,{size:"lg"})})}function mX(){return h.jsx(pX,{})}function gX({children:e}){return h.jsxs("div",{className:"space-y-4 px-5 py-5",children:[h.jsx(yX,{}),h.jsx(_X,{}),h.jsx(wX,{}),e]})}function yX(){const{clearError:e,config:t,connect:n,disconnect:s,error:i,isConnected:a,isConnecting:l}=Dt(),[f,d]=_.useState(t?.serverUrl??"/api"),[p,g]=_.useState(t?.token??""),[y,b]=_.useState(null),[x,S]=_.useState(!1),[w,T]=_.useState(null),[C,k]=xa("console:disconnect-clear-saved-config",!1);_.useEffect(()=>{const j=new URLSearchParams(window.location.search),A=j.get("server");let P=!1;if(A&&(d(A),j.delete("server"),P=!0),j.has("token")&&(j.delete("token"),P=!0),P){const G=j.toString(),B=G?`${window.location.pathname}?${G}`:window.location.pathname;window.history.replaceState({},"",B)}},[]),_.useEffect(()=>{t?.serverUrl&&d(t.serverUrl),t?.token&&g(t.token)},[t?.serverUrl,t?.token]),_.useEffect(()=>{T(null)},[]);const N=async()=>{e(),b(null);const j=await n({serverUrl:f.trim(),token:p.trim()},{persistOverride:!0});T(j?"Connected successfully and configuration saved.":"Failed to connect with the provided settings.")},R=()=>{s({clearSavedConfig:C}),C&&(d("/api"),g("")),T(C?"Disconnected and saved credentials cleared.":"Disconnected."),b(null)},M=async()=>{S(!0),b(null),T(null);const j=performance.now();try{const A=f.trim(),P=p.trim();if(!A||!P)throw new Error("Missing server URL or token");if(!(await fetch(`${A}/console/stats`,{headers:{Authorization:`Bearer ${P}`}})).ok)throw new Error("Failed to connect");b(Math.round(performance.now()-j))}catch{b(-1)}finally{S(!1)}},L=i??w??(y!==null?y<0?"Connection failed":`Connection successful (${y}ms latency)`:void 0);return h.jsx(Gj,{isConnected:a,isConnecting:l,isTestingConnection:x,serverUrl:f,onServerUrlChange:d,consoleToken:p,onConsoleTokenChange:g,onSaveAndConnect:N,onDisconnect:R,onTestConnection:M,statusMessage:L,children:h.jsx("div",{className:"px-5 pb-5 -mt-2",children:h.jsxs("div",{className:"flex items-center justify-between rounded-md border border-border px-3 py-2",children:[h.jsxs("div",{children:[h.jsx("p",{className:"font-mono text-[10px] text-neutral-400",children:"Clear saved credentials on disconnect"}),h.jsx("p",{className:"font-mono text-[9px] text-neutral-500",children:"Removes stored server URL and token from this browser."})]}),h.jsx(Ep,{checked:C,onCheckedChange:k})]})})})}const vX=1440*60*1e3;function XC(e){const t=e.trim();if(!t)return null;const n=Number.parseInt(t,10);return!Number.isInteger(n)||n<=0?null:n}function Fy(e){if(!e)return"Never";const t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():"Invalid date"}function bX(e){return e.length===0?"all scopes":e.length<=2?e.join(", "):`${e.slice(0,2).join(", ")} +${e.length-2}`}function xX(e,t){if(e.revokedAt)return"revoked";if(!e.expiresAt)return"active";const n=Date.parse(e.expiresAt);if(!Number.isFinite(n))return"active";const s=Date.now();return n<=s?"expired":n<=s+t*vX?"expiring":"active"}function SX(e){return e==="revoked"?"destructive":e==="expired"?"offline":e==="expiring"?"syncing":"healthy"}function _X(){const[e,t]=_.useState("all"),[n,s]=_.useState("all"),[i,a]=_.useState("14"),[l,f]=_.useState(!1),[d,p]=_.useState(!1),[g,y]=_.useState(""),[b,x]=_.useState("relay"),[S,w]=_.useState(""),[T,C]=_.useState(""),[k,N]=_.useState(""),[R,M]=_.useState(null),[L,j]=_.useState([]),[A,P]=_.useState(null),[G,B]=_.useState(null),[z,Q]=_.useState(null),[Y,ee]=_.useState(null),[D,K]=_.useState(null),[q,V]=_.useState(null),[U,I]=_.useState(null),H=_.useMemo(()=>XC(i),[i]),W=H??14,X=_.useMemo(()=>XC(k),[k]),oe=k.trim().length>0,se=!oe||X!==null,de=_.useMemo(()=>({type:e==="all"?void 0:e,status:n==="all"?void 0:n,expiresWithinDays:n==="expiring"?W:void 0}),[e,n,W]),{data:xe,isLoading:he,error:Me}=LY(de),_e=UY(),ne=BY(),pe=$Y(),ae=FY(),we=HY();_.useEffect(()=>{const me=new Set((xe?.items??[]).map(Te=>Te.keyId));j(Te=>Te.filter(qe=>me.has(qe)))},[xe?.items]);const ve=async()=>{try{const me=T.split(",").map(qe=>qe.trim()).filter(qe=>qe.length>0),Te=await _e.mutateAsync({name:g,keyType:b,actorId:S||void 0,scopeKeys:me.length>0?me:void 0,expiresInDays:oe?X??void 0:void 0});M(Te.secretKey),y(""),w(""),C(""),N("")}catch{}},Se=me=>{navigator.clipboard.writeText(me),B(me),setTimeout(()=>B(null),2e3)},ye=async()=>{if(z)try{await pe.mutateAsync(z)}finally{Q(null)}},Ue=async()=>{if(L.length!==0)try{const me=await ne.mutateAsync({keyIds:L});P(me),j([])}catch{}},Ie=async()=>{if(Y)try{const me=await we.mutateAsync(Y.keyId);K({oldKeyId:Y.keyId,oldKeyName:Y.name,secretKey:me.secretKey})}catch{}},Ee=async()=>{if(D)try{await pe.mutateAsync(D.oldKeyId)}finally{K(null),ee(null)}},Ve=async()=>{if(q)try{const me=await ae.mutateAsync(q);I(me.secretKey)}finally{V(null)}};if(he)return h.jsx("div",{className:"flex h-[200px] items-center justify-center",children:h.jsx(Pt,{size:"lg"})});if(Me)return h.jsx("div",{className:"flex h-[200px] items-center justify-center",children:h.jsxs("p",{className:"text-danger",children:["Failed to load API keys: ",Me.message]})});const Xe=(xe?.items??[]).filter(me=>me.revokedAt===null).map(me=>me.keyId),Be=Xe.length>0&&Xe.every(me=>L.includes(me)),We=L.length>0,He=(xe?.items??[]).filter(me=>L.includes(me.keyId)).map(me=>me.name);return h.jsxs(h.Fragment,{children:[h.jsxs(ex,{title:"API Keys",description:"Issue, rotate, revoke, and audit key lifecycle state.",actions:h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs(Oe,{size:"sm",variant:"destructive",onClick:()=>p(!0),disabled:L.length===0,children:["Revoke Selected (",L.length,")"]}),h.jsx(Oe,{size:"sm",onClick:()=>f(!0),children:"Create Key"})]}),children:[h.jsxs("div",{className:"mb-4 grid gap-3 lg:grid-cols-3",children:[h.jsxs(ms,{children:[h.jsx(ts,{children:"Type filter"}),h.jsxs(hh,{value:[e],multiple:!1,onValueChange:me=>{const Te=me.find(qe=>typeof qe=="string");(Te==="all"||Te==="relay"||Te==="proxy"||Te==="admin")&&t(Te)},children:[h.jsx(Dr,{value:"all",children:"all"}),h.jsx(Dr,{value:"relay",children:"relay"}),h.jsx(Dr,{value:"proxy",children:"proxy"}),h.jsx(Dr,{value:"admin",children:"admin"})]})]}),h.jsxs(ms,{children:[h.jsx(ts,{children:"Status filter"}),h.jsxs(hh,{value:[n],multiple:!1,onValueChange:me=>{const Te=me.find(qe=>typeof qe=="string");(Te==="all"||Te==="active"||Te==="revoked"||Te==="expiring")&&s(Te)},children:[h.jsx(Dr,{value:"all",children:"all"}),h.jsx(Dr,{value:"active",children:"active"}),h.jsx(Dr,{value:"revoked",children:"revoked"}),h.jsx(Dr,{value:"expiring",children:"expiring"})]})]}),h.jsxs(ms,{children:[h.jsx(ts,{htmlFor:"api-key-expiring-window",children:"Expiring window (days)"}),h.jsx(mc,{children:"Used when status filter is set to expiring."}),h.jsx(Gn,{id:"api-key-expiring-window",placeholder:"14",value:i,inputMode:"numeric",onChange:me=>a(me.target.value)}),H===null&&i.trim().length>0?h.jsx("p",{className:"font-mono text-[10px] text-offline",children:"Enter a positive whole number."}):null]})]}),xe?.items.length===0?h.jsx(Wb,{message:"No API keys match the current filters."}):h.jsxs(nl,{children:[h.jsx(rl,{children:h.jsxs(os,{children:[h.jsx(ht,{className:"w-[28px]",children:h.jsx(Fv,{checked:Be,indeterminate:!Be&&We&&Xe.length>0,onCheckedChange:me=>{j(me?Xe:[])},"aria-label":"Select all active keys"})}),h.jsx(ht,{className:"w-[100px]",children:"NAME"}),h.jsx(ht,{className:"w-[55px]",children:"TYPE"}),h.jsx(ht,{className:"w-[90px]",children:"KEY PREFIX"}),h.jsx(ht,{className:"w-[80px]",children:"ACTOR"}),h.jsx(ht,{className:"w-[100px]",children:"SCOPES"}),h.jsx(ht,{className:"w-[120px]",children:"CREATED"}),h.jsx(ht,{className:"w-[120px]",children:"LAST USED"}),h.jsx(ht,{className:"w-[120px]",children:"EXPIRES"}),h.jsx(ht,{className:"flex-1",children:"STATUS"})]})}),h.jsx(sl,{children:(xe?.items??[]).map(me=>{const Te=xX(me,W);return h.jsxs(os,{className:"group relative",children:[h.jsx(pt,{className:"w-[28px]",children:h.jsx(Fv,{checked:L.includes(me.keyId),onCheckedChange:qe=>{j(mt=>qe?[...new Set([...mt,me.keyId])]:mt.filter(lt=>lt!==me.keyId))},"aria-label":`Select ${me.name}`,disabled:me.revokedAt!==null})}),h.jsx(pt,{className:"w-[100px] font-medium",children:me.name}),h.jsx(pt,{className:"w-[55px]",children:h.jsx(mn,{variant:me.keyType==="admin"?"flow":me.keyType==="proxy"?"ghost":"relay",children:me.keyType})}),h.jsx(pt,{className:"w-[90px]",children:h.jsxs("code",{className:"font-mono text-[11px]",children:[me.keyPrefix,"..."]})}),h.jsx(pt,{className:"w-[80px] text-neutral-500",children:me.actorId??"-"}),h.jsx(pt,{className:"w-[100px] text-neutral-500",children:h.jsx("code",{className:"font-mono text-[10px]",children:bX(me.scopeKeys)})}),h.jsx(pt,{className:"w-[120px] text-neutral-500",children:Fy(me.createdAt)}),h.jsx(pt,{className:"w-[120px] text-neutral-500",children:Fy(me.lastUsedAt)}),h.jsx(pt,{className:"w-[120px] text-neutral-500",children:Fy(me.expiresAt)}),h.jsx(pt,{className:"flex-1",children:h.jsx(mn,{variant:SX(Te),children:Te})}),me.revokedAt===null&&h.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[h.jsx("button",{type:"button",onClick:()=>ee(me),className:"px-1.5 py-0.5 rounded text-[9px] font-mono text-neutral-600 hover:text-white hover:bg-white/[0.05] cursor-pointer transition-colors",children:"stage"}),h.jsx("button",{type:"button",onClick:()=>V(me.keyId),className:"px-1.5 py-0.5 rounded text-[9px] font-mono text-neutral-600 hover:text-white hover:bg-white/[0.05] cursor-pointer transition-colors",children:"rotate"}),h.jsx("button",{type:"button",onClick:()=>Q(me.keyId),className:"px-1.5 py-0.5 rounded text-[9px] font-mono text-neutral-600 hover:text-offline hover:bg-offline/10 cursor-pointer transition-colors",children:"revoke"})]})]},me.keyId)})})]})]}),h.jsx($r,{open:l,onOpenChange:f,children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Create API Key"})}),R?h.jsx(QC,{copiedKeyId:G,onClose:()=>{M(null),f(!1)},onCopy:Se,secretKey:R,warning:"Copy this key now. You will not be able to view it again."}):h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[h.jsxs(ms,{children:[h.jsx(ts,{htmlFor:"api-key-name",children:"Name"}),h.jsx(Gn,{id:"api-key-name",placeholder:"Backend Relay Key",value:g,onChange:me=>y(me.target.value)})]}),h.jsxs(ms,{children:[h.jsx(ts,{children:"Key type"}),h.jsxs(hh,{value:[b],multiple:!1,onValueChange:me=>{const Te=me.find(qe=>typeof qe=="string");(Te==="relay"||Te==="proxy"||Te==="admin")&&x(Te)},children:[h.jsx(Dr,{value:"relay",children:"relay"}),h.jsx(Dr,{value:"proxy",children:"proxy"}),h.jsx(Dr,{value:"admin",children:"admin"})]})]}),h.jsxs(ms,{children:[h.jsx(ts,{htmlFor:"api-key-actor-id",children:"Actor ID (optional)"}),h.jsx(mc,{children:"Pin this key to a fixed actor ID"}),h.jsx(Gn,{id:"api-key-actor-id",placeholder:"actor-123",value:S,onChange:me=>w(me.target.value)})]}),h.jsxs(ms,{children:[h.jsx(ts,{htmlFor:"api-key-scope-keys",children:"Scope keys (optional)"}),h.jsx(mc,{children:"Comma-separated list of allowed scope keys"}),h.jsx(Gn,{id:"api-key-scope-keys",placeholder:"scope-a, scope-b",value:T,onChange:me=>C(me.target.value)})]}),h.jsxs(ms,{children:[h.jsx(ts,{htmlFor:"api-key-expires-days",children:"Expires in days (optional)"}),h.jsx(mc,{children:"Leave empty to keep the key non-expiring."}),h.jsx(Gn,{id:"api-key-expires-days",placeholder:"30",value:k,inputMode:"numeric",onChange:me=>N(me.target.value)}),se?null:h.jsx("p",{className:"font-mono text-[10px] text-offline",children:"Enter a positive whole number."})]}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>f(!1),children:"Cancel"}),h.jsx(Oe,{variant:"primary",onClick:ve,disabled:_e.isPending||!g||!se,children:_e.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Creating..."]}):"Create"})]})]})]})}),h.jsx($r,{open:d,onOpenChange:me=>{p(me),me||P(null)},children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Bulk Revoke API Keys"})}),A?h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-3",children:[h.jsx(In,{variant:"destructive",children:h.jsxs(Pn,{children:["Requested ",A.requestedCount," keys. Revoked"," ",A.revokedCount,", already revoked"," ",A.alreadyRevokedCount,", not found"," ",A.notFoundCount,"."]})}),h.jsx(Nn,{children:h.jsx(Oe,{variant:"primary",onClick:()=>{p(!1),P(null)},children:"Done"})})]}):h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-3",children:[h.jsx(In,{variant:"destructive",children:h.jsx(Pn,{children:"This revokes selected keys immediately and cannot be undone."})}),h.jsxs("p",{className:"font-mono text-[10px] text-neutral-500",children:["Selected keys: ",He.slice(0,5).join(", "),He.length>5?` +${He.length-5} more`:""]})]}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>p(!1),children:"Cancel"}),h.jsx(Oe,{variant:"destructive",onClick:Ue,disabled:ne.isPending||L.length===0,children:ne.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Revoking..."]}):"Revoke Selected"})]})]})]})}),h.jsx($r,{open:Y!==null||D!==null,onOpenChange:()=>{ee(null),K(null)},children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Stage Rotate API Key"})}),D?h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[h.jsx(In,{variant:"default",children:h.jsxs(Pn,{children:["Replacement key created for ",D.oldKeyName,". The old key is still active until you revoke it."]})}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("code",{className:"flex-1 rounded-md border border-border bg-surface p-3 font-mono text-[11px] text-white break-all",children:D.secretKey}),h.jsx(Oe,{variant:"default",size:"sm",onClick:()=>Se(D.secretKey),children:G===D.secretKey?"Copied":"Copy"})]}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>{K(null),ee(null)},children:"Keep Old Key Active"}),h.jsx(Oe,{variant:"destructive",onClick:Ee,disabled:pe.isPending,children:pe.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Revoking Old Key..."]}):"Finalize and Revoke Old Key"})]})]}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"px-5 py-4",children:h.jsx("p",{className:"font-mono text-[10px] text-neutral-500",children:"Staged rotation creates a replacement key now and keeps the current key active until you explicitly revoke it."})}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>ee(null),children:"Cancel"}),h.jsx(Oe,{variant:"primary",onClick:Ie,disabled:we.isPending||!Y,children:we.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Staging..."]}):"Create Replacement Key"})]})]})]})}),h.jsx($r,{open:z!==null,onOpenChange:()=>Q(null),children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Revoke API Key"})}),h.jsx("div",{className:"px-5 py-4",children:h.jsx(In,{variant:"destructive",children:h.jsx(Pn,{children:"Revoking a key immediately invalidates it for all requests."})})}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>Q(null),children:"Cancel"}),h.jsx(Oe,{variant:"destructive",onClick:ye,disabled:pe.isPending,children:pe.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Revoking..."]}):"Revoke"})]})]})}),h.jsx($r,{open:q!==null||U!==null,onOpenChange:()=>{V(null),I(null)},children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Rotate API Key"})}),U?h.jsx(QC,{copiedKeyId:G,onClose:()=>I(null),onCopy:Se,secretKey:U,warning:"The previous key has been invalidated. Store this replacement securely."}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"px-5 py-4",children:h.jsx("p",{className:"font-mono text-[10px] text-neutral-500",children:"Rotating a key invalidates the previous secret immediately."})}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>V(null),children:"Cancel"}),h.jsx(Oe,{variant:"primary",onClick:Ve,disabled:ae.isPending,children:ae.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Rotating..."]}):"Rotate"})]})]})]})})]})}function wX(){const{preferences:e,updatePreference:t,resetPreferences:n}=af(),s=[{type:"filter",label:"Auto-refresh interval",options:ZY.map(i=>({id:`${i.value}`,label:i.label})),activeId:`${e.refreshInterval}`,onActiveChange:i=>t("refreshInterval",Number.parseInt(i,10))},{type:"filter",label:"Items per page",options:YY.map(i=>({id:`${i.value}`,label:i.label})),activeId:`${e.pageSize}`,onActiveChange:i=>t("pageSize",Number.parseInt(i,10))},{type:"filter",label:"Time format",options:[{id:"relative",label:"Relative"},{id:"absolute",label:"Absolute"}],activeId:e.timeFormat,onActiveChange:i=>t("timeFormat",i)},{type:"toggle",label:"Show sparklines",description:"Display mini trend charts in dashboard metric cards",checked:e.showSparklines,onCheckedChange:i=>t("showSparklines",i)}];return h.jsx(tA,{rows:s,onResetDefaults:n})}function QC({copiedKeyId:e,onClose:t,onCopy:n,secretKey:s,warning:i}){return h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[h.jsx(In,{variant:"destructive",children:h.jsx(Pn,{children:i})}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("code",{className:"flex-1 rounded-md border border-border bg-surface p-3 font-mono text-[11px] text-white break-all",children:s}),h.jsx(Oe,{variant:"default",size:"sm",onClick:()=>n(s),children:e===s?"Copied":"Copy"})]}),h.jsx(Nn,{children:h.jsx(Oe,{variant:"primary",onClick:t,children:"Done"})})]})}function EX(e){const t=e.toLowerCase();return t.includes("mobile")||t.includes("ios")||t.includes("android")?"mobile":t.includes("tablet")?"tablet":t.includes("desktop")||t.includes("laptop")?"desktop":t.includes("edge")?"edge":t.includes("iot")?"iot":"desktop"}function TX(e){const t=e.toLowerCase();return t.includes("pglite")?"PGlite":t.includes("wa-sqlite")||t.includes("sqlite")?"SQLite":t.includes("postgres")||t.includes("pg")?"PostgreSQL":"unknown"}function CX(e,t){if(t==="absolute")return new Date(e).toLocaleString();try{const n=new Date(e),i=new Date().getTime()-n.getTime(),a=Math.floor(i/1e3),l=Math.floor(a/60),f=Math.floor(l/60),d=Math.floor(f/24);return a<60?"just now":l<60?`${l}m ago`:f<24?`${f}h ago`:`${d}d ago`}catch{return e}}function RX(e,t,n){return{id:e.clientId,type:EX(e.clientId),status:e.activityState==="stale"?"offline":e.activityState==="idle"?"syncing":"online",cursor:e.cursor,actor:e.actorId,mode:e.connectionMode==="realtime"?"realtime":"polling",dialect:TX(e.clientId),scopes:Object.keys(e.effectiveScopes??{}),lastSeen:CX(e.updatedAt,n)}}function NX({emptyState:e}={}){const[t,n]=_.useState(1),[s,i]=_.useState(null),{preferences:a}=af(),{partitionId:l}=of(),f=a.pageSize,d=a.refreshInterval*1e3,{data:p,isLoading:g}=sf({refetchIntervalMs:d,partitionId:l}),{data:y,isLoading:b,error:x}=yk({limit:f,offset:(t-1)*f,partitionId:l},{refetchIntervalMs:d}),S=IY(),w=Math.ceil((y?.total??0)/f),T=p?.maxCommitSeq??0;_.useEffect(()=>{n(1)},[]);const C=async()=>{if(s)try{await S.mutateAsync({clientId:s,partitionId:l})}finally{i(null)}};if(b||g)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsx(Pt,{size:"lg"})});if(x)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsxs("p",{className:"text-danger",children:["Failed to load clients: ",x.message]})});const k=(y?.items??[]).map(N=>RX(N,T,a.timeFormat));return h.jsxs("div",{className:"flex flex-col gap-5 px-5 py-5",children:[k.length>0&&h.jsx(rA,{clients:k,headSeq:T}),k.length===0?e??h.jsx(sV,{children:h.jsx(Wb,{message:"No clients yet"})}):h.jsx(Xj,{clients:k,headSeq:T,onEvict:N=>{const R=y?.items.find(M=>M.clientId===N);i(R?.clientId??N)}}),w>1&&h.jsx(gx,{page:t,totalPages:w,totalItems:y?.total??0,onPageChange:n}),h.jsx($r,{open:s!==null,onOpenChange:()=>i(null),children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Evict Client"})}),h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[h.jsxs("p",{className:"font-mono text-[11px] text-neutral-300",children:["Are you sure you want to evict client"," ",h.jsxs("span",{className:"font-mono text-white",children:[s?.slice(0,12),"..."]}),"?"]}),h.jsx("p",{className:"font-mono text-[10px] text-neutral-500",children:"This will force the client to re-bootstrap on their next sync."})]}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>i(null),children:"Cancel"}),h.jsx(Oe,{variant:"destructive",onClick:C,disabled:S.isPending,children:S.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Evicting..."]}):"Evict"})]})]})})]})}const jX={latencyThresholdMs:1e3,errorRateThreshold:5,clientLagThreshold:50,enabled:!1};function AX(e){return e<1e3?`${e}ms`:e<6e4?`${Math.round(e/1e3)}s`:e<36e5?`${Math.round(e/6e4)}m`:`${Math.round(e/36e5)}h`}function kX(e){const t=e.split(",").map(n=>n.trim()).filter(n=>n.length>0);return Array.from(new Set(t))}function OX(e){switch(e){case"notify_data_change":return"Notify";case"evict_client":return"Evict";case"compact":return"Compact";default:return"Prune"}}function WC(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function MX(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function IX(e){const t=WC(e.requestPayload),n=WC(e.resultPayload);if(e.operationType==="notify_data_change"){const a=MX(t?.tables),l=n?.commitSeq;return`${a.length} table${a.length===1?"":"s"} -> commit #${typeof l=="number"?l:"?"}`}if(e.operationType==="evict_client"){const a=n?.evicted===!0?"evicted":"not found";return`client ${e.targetClientId??"?"} ${a}`}if(e.operationType==="compact")return`${typeof n?.deletedChanges=="number"?n.deletedChanges:0} changes removed`;const s=typeof n?.deletedCommits=="number"?n.deletedCommits:0,i=typeof t?.watermarkCommitSeq=="number"?` at #${t.watermarkCommitSeq}`:"";return`${s} commits removed${i}`}function PX(e){const t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function DX(){const{partitionId:e}=of();return h.jsxs("div",{className:"flex flex-col gap-4 px-5 py-5",children:[h.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[h.jsx(zX,{}),h.jsx(FX,{})]}),h.jsxs("div",{className:"grid gap-4 xl:grid-cols-3",children:[h.jsx(LX,{partitionId:e}),h.jsx(UX,{partitionId:e}),h.jsx($X,{partitionId:e})]}),h.jsx(BX,{partitionId:e})]})}function zX(){const{data:e,isLoading:t,error:n}=kY();if(t)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsx(Pt,{size:"lg"})});if(n)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsxs("p",{className:"text-danger",children:["Failed to load handlers: ",n.message]})});const s=(e?.items??[]).map(i=>({table:i.table,dependsOn:i.dependsOn?.join(", ")??null,chunkTtl:i.snapshotChunkTtlMs?AX(i.snapshotChunkTtlMs):"default"}));return h.jsx(Qj,{handlers:s,tableCount:e?.items.length??0})}function LX({partitionId:e}){const[t,n]=_.useState(!1),[s,i]=_.useState(null),{data:a,isLoading:l}=sf({partitionId:e}),{data:f,isLoading:d,refetch:p}=OY({enabled:!1}),g=PY(),y=async()=>{n(!0),i(null),await p()},b=async()=>{const S=await g.mutateAsync();i(S.deletedCommits)};if(l)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsx(Pt,{size:"lg"})});const x=[{label:"Total commits",value:a?.commitCount??0},{label:"Commit range",value:`${a?.minCommitSeq??0} - ${a?.maxCommitSeq??0}`},{label:"Min active cursor",value:a?.minActiveClientCursor??"N/A",tone:"syncing"}];return h.jsxs(h.Fragment,{children:[h.jsx(Tp,{title:"Prune",description:"Delete commits that all clients have already synced. Pruning removes commits older than the oldest active client cursor.",dotColor:"syncing",stats:x,actionLabel:"Preview Prune",actionVariant:"destructive",onAction:y}),h.jsx($r,{open:t,onOpenChange:n,children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Prune Old Commits"})}),h.jsx("div",{className:"px-5 py-4 flex flex-col gap-4",children:s!==null?h.jsxs(In,{variant:"default",children:[h.jsx(nf,{children:"Pruning Complete"}),h.jsxs(Pn,{children:["Successfully deleted ",h.jsx("strong",{children:s})," commits."]})]}):d?h.jsx("div",{className:"flex items-center justify-center py-8",children:h.jsx(Pt,{size:"sm"})}):f?h.jsxs(h.Fragment,{children:[h.jsx(In,{variant:f.commitsToDelete>0?"destructive":"default",children:h.jsx(Pn,{children:f.commitsToDelete>0?h.jsxs(h.Fragment,{children:["This will delete"," ",h.jsx("strong",{children:f.commitsToDelete})," commits up to sequence"," ",h.jsxs("code",{className:"font-mono",children:["#",f.watermarkCommitSeq]}),"."]}):"No commits are eligible for pruning."})}),h.jsxs("div",{className:"flex flex-col gap-2",children:[h.jsxs("div",{className:"flex justify-between font-mono text-[11px]",children:[h.jsx("span",{className:"text-neutral-500",children:"Watermark commit seq:"}),h.jsxs("span",{className:"text-white",children:["#",f.watermarkCommitSeq]})]}),h.jsxs("div",{className:"flex justify-between font-mono text-[11px] items-center",children:[h.jsx("span",{className:"text-neutral-500",children:"Commits to delete:"}),h.jsx(mn,{variant:f.commitsToDelete>0?"offline":"ghost",children:f.commitsToDelete})]})]})]}):null}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>n(!1),children:s!==null?"Close":"Cancel"}),s===null&&h.jsx(Oe,{variant:"destructive",onClick:b,disabled:g.isPending||d||(f?.commitsToDelete??0)===0,children:g.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Pruning..."]}):"Prune Now"})]})]})})]})}function UX({partitionId:e}){const[t,n]=_.useState(!1),[s,i]=_.useState(null),{data:a,isLoading:l}=sf({partitionId:e}),f=DY(),d=()=>{n(!0),i(null)},p=async()=>{const y=await f.mutateAsync();i(y.deletedChanges)};if(l)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsx(Pt,{size:"lg"})});const g=[{label:"Total changes",value:a?.changeCount??0},{label:"Total commits",value:a?.commitCount??0}];return h.jsxs(h.Fragment,{children:[h.jsx(Tp,{title:"Compact",description:"Merge old changes to reduce storage space. Compaction merges multiple changes to the same row into a single change.",dotColor:"flow",stats:g,actionLabel:"Run Compaction",actionVariant:"primary",onAction:d}),h.jsx($r,{open:t,onOpenChange:n,children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Compact Changes"})}),h.jsx("div",{className:"px-5 py-4 flex flex-col gap-4",children:s!==null?h.jsxs(In,{variant:"default",children:[h.jsx(nf,{children:"Compaction Complete"}),h.jsxs(Pn,{children:["Successfully removed ",h.jsx("strong",{children:s})," redundant changes."]})]}):h.jsx(In,{variant:"default",children:h.jsx(Pn,{children:"Compaction will merge multiple changes to the same row, keeping only the most recent version. This is safe and can be run at any time."})})}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>n(!1),children:s!==null?"Close":"Cancel"}),s===null&&h.jsx(Oe,{variant:"primary",onClick:p,disabled:f.isPending,children:f.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Compacting..."]}):"Compact Now"})]})]})})]})}function $X({partitionId:e}){const[t,n]=_.useState(!1),[s,i]=_.useState("tasks"),[a,l]=_.useState(e??""),[f,d]=_.useState(null),[p,g]=_.useState(null),y=zY(),b=kX(s),x=[{label:"Next tables",value:b.length,tone:"syncing"},{label:"Last commit seq",value:f?`#${f.commitSeq}`:"—",tone:"syncing"},{label:"Last chunks cleared",value:f?.deletedChunks??"—"}],S=()=>{n(!0),g(null)},w=async()=>{if(b.length===0){g("Provide at least one table name.");return}g(null);const T=await y.mutateAsync({tables:b,partitionId:a.trim()||void 0});d(T)};return h.jsxs(h.Fragment,{children:[h.jsx(Tp,{title:"Notify Data Change",description:"Create a synthetic commit after external imports or direct DB writes so clients re-bootstrap for affected tables.",dotColor:"healthy",stats:x,actionLabel:"Notify Clients",actionVariant:"primary",onAction:S}),h.jsx($r,{open:t,onOpenChange:n,children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Notify External Data Change"})}),h.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4",children:[f?h.jsxs(In,{variant:"default",children:[h.jsx(nf,{children:"Notification Sent"}),h.jsxs(Pn,{children:["Created synthetic commit"," ",h.jsxs("strong",{children:["#",f.commitSeq]})," for"," ",h.jsx("strong",{children:f.tables.length})," table",f.tables.length===1?"":"s"," and cleared"," ",h.jsx("strong",{children:f.deletedChunks})," cached chunk",f.deletedChunks===1?"":"s","."]})]}):h.jsx(In,{variant:"default",children:h.jsx(Pn,{children:"Use this when data changed outside Syncular push flow. It invalidates cached snapshot chunks and forces clients to pull fresh data."})}),p?h.jsx(In,{variant:"destructive",children:h.jsx(Pn,{children:p})}):null,h.jsxs(ms,{children:[h.jsx(ts,{children:"Tables (comma-separated)"}),h.jsx(Gn,{value:s,onChange:T=>i(T.target.value),placeholder:"tasks, notes",disabled:y.isPending}),h.jsx(mc,{children:"Enter one or more table names affected by the external change."})]}),h.jsxs(ms,{children:[h.jsx(ts,{children:"Partition ID (optional)"}),h.jsx(Gn,{value:a,onChange:T=>l(T.target.value),placeholder:"default",disabled:y.isPending})]})]}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>n(!1),children:f?"Close":"Cancel"}),f?null:h.jsx(Oe,{variant:"primary",onClick:w,disabled:y.isPending,children:y.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Notifying..."]}):"Notify Data Change"})]})]})})]})}function BX({partitionId:e}){const[t,n]=_.useState("all"),{data:s,isLoading:i,error:a}=MY({limit:20,offset:0,operationType:t==="all"?void 0:t,partitionId:e},{refetchIntervalMs:5e3});return h.jsx(ex,{title:"Operation Audit",description:"Recent prune/compact/notify/evict actions with actor and result context.",actions:h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Oe,{variant:t==="all"?"default":"ghost",size:"sm",onClick:()=>n("all"),children:"All"}),h.jsx(Oe,{variant:t==="prune"?"default":"ghost",size:"sm",onClick:()=>n("prune"),children:"Prune"}),h.jsx(Oe,{variant:t==="compact"?"default":"ghost",size:"sm",onClick:()=>n("compact"),children:"Compact"}),h.jsx(Oe,{variant:t==="notify_data_change"?"default":"ghost",size:"sm",onClick:()=>n("notify_data_change"),children:"Notify"}),h.jsx(Oe,{variant:t==="evict_client"?"default":"ghost",size:"sm",onClick:()=>n("evict_client"),children:"Evict"})]}),contentClassName:"pt-2",children:i?h.jsx("div",{className:"flex items-center justify-center py-10",children:h.jsx(Pt,{size:"lg"})}):a?h.jsx(In,{variant:"destructive",children:h.jsxs(Pn,{children:["Failed to load operation audit events: ",a.message]})}):(s?.items.length??0)===0?h.jsx("div",{className:"px-2 py-8 text-sm text-neutral-500",children:"No operation events found for this filter."}):h.jsx("div",{className:"overflow-x-auto",children:h.jsxs(nl,{children:[h.jsx(rl,{children:h.jsxs(os,{children:[h.jsx(ht,{children:"Time"}),h.jsx(ht,{children:"Type"}),h.jsx(ht,{children:"User"}),h.jsx(ht,{children:"Target"}),h.jsx(ht,{children:"Result"})]})}),h.jsx(sl,{children:(s?.items??[]).map((l,f)=>h.jsxs(os,{children:[h.jsx(pt,{className:"whitespace-nowrap text-xs text-neutral-400",children:PX(l.createdAt)}),h.jsx(pt,{children:h.jsx(mn,{variant:"ghost",children:OX(l.operationType)})}),h.jsx(pt,{className:"font-mono text-xs",children:l.consoleUserId??"system"}),h.jsx(pt,{className:"font-mono text-xs",children:l.targetClientId??l.partitionId??(l.operationType==="notify_data_change"?"partition default":"global")}),h.jsx(pt,{className:"font-mono text-xs text-neutral-300",children:IX(l)})]},`${l.operationId}:${l.createdAt}:${f}`))})]})})})}function FX(){const[e,t]=xa("console:alert-config",jX),n={p90Latency:e.latencyThresholdMs,errorRate:e.errorRateThreshold,clientLag:e.clientLagThreshold},s=a=>{t(l=>({...l,latencyThresholdMs:a.p90Latency,errorRateThreshold:a.errorRate,clientLagThreshold:a.clientLag}))},i=a=>{t(l=>({...l,enabled:a}))};return h.jsx(Hj,{enabled:e.enabled,onEnabledChange:i,thresholds:n,onThresholdsChange:s})}function HX(e){if(e===0)return"0 B";const t=["B","KB","MB","GB","TB"],n=Math.floor(Math.log(e)/Math.log(1024));return`${(e/1024**n).toFixed(n===0?0:1)} ${t[n]}`}function qX(e){const t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function VX(){const[e,t]=_.useState(""),[n,s]=_.useState(void 0),[i,a]=_.useState(void 0),[l,f]=_.useState([]),[d,p]=_.useState(null),{data:g,isLoading:y,error:b}=qY({prefix:n,cursor:i,limit:100}),x=VY(),S=KY();function w(){const M=e.trim();s(M.length>0?M:void 0),a(void 0),f([])}function T(){t(""),s(void 0),a(void 0),f([])}function C(){g?.cursor&&(f(M=>[...M,i??""]),a(g.cursor))}function k(){f(M=>{const L=[...M],j=L.pop();return a(j&&j.length>0?j:void 0),L})}function N(){d&&x.mutate(d,{onSuccess:()=>p(null)})}if(y)return h.jsx("div",{className:"flex flex-col gap-4 px-5 py-5",children:h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsx(Pt,{size:"lg"})})});if(b)return h.jsx("div",{className:"flex flex-col gap-4 px-5 py-5",children:h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsxs("p",{className:"text-danger font-mono text-[11px]",children:["Failed to load storage items: ",b.message]})})});const R=g?.items??[];return h.jsxs("div",{className:"flex flex-col gap-4 px-5 py-5",children:[h.jsx(ex,{title:"Storage",actions:h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Gn,{placeholder:"Prefix filter...",value:e,onChange:M=>t(M.target.value),onKeyDown:M=>{M.key==="Enter"&&w()},className:"h-7 w-48 text-xs"}),h.jsx(Oe,{variant:"default",size:"sm",onClick:w,children:"Filter"}),n&&h.jsx(Oe,{variant:"ghost",size:"sm",onClick:T,children:"Clear"})]}),children:R.length===0?h.jsx(Wb,{message:n?`No storage items matching prefix "${n}".`:"No storage items found."}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"overflow-x-auto",children:h.jsxs(nl,{children:[h.jsx(rl,{children:h.jsxs(os,{children:[h.jsx(ht,{children:"Key"}),h.jsx(ht,{children:"Size"}),h.jsx(ht,{children:"Type"}),h.jsx(ht,{children:"Uploaded"}),h.jsx(ht,{children:"Actions"})]})}),h.jsx(sl,{children:R.map(M=>h.jsxs(os,{children:[h.jsx(pt,{className:"font-mono text-xs max-w-[320px]",title:M.key,children:M.key}),h.jsx(pt,{className:"font-mono text-xs text-neutral-400 whitespace-nowrap",children:HX(M.size)}),h.jsx(pt,{children:M.httpMetadata?.contentType?h.jsx(mn,{variant:"ghost",children:M.httpMetadata.contentType}):h.jsx("span",{className:"text-neutral-500 text-xs",children:"--"})}),h.jsx(pt,{className:"whitespace-nowrap text-xs text-neutral-400",children:qX(M.uploaded)}),h.jsx(pt,{children:h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx(Oe,{variant:"ghost",size:"sm",onClick:()=>{S(M.key)},children:"Download"}),h.jsx(Oe,{variant:"ghost",size:"sm",onClick:()=>p(M.key),children:"Delete"})]})})]},M.key))})]})}),h.jsxs("div",{className:"flex items-center justify-between px-2 py-2",children:[h.jsx(Oe,{variant:"ghost",size:"sm",disabled:l.length===0,onClick:k,children:"Previous"}),h.jsx(Oe,{variant:"ghost",size:"sm",disabled:!g?.truncated,onClick:C,children:"Next"})]})]})}),h.jsx($r,{open:d!==null,onOpenChange:()=>p(null),children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Delete Storage Item"})}),h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[h.jsxs("p",{className:"font-mono text-[11px] text-neutral-300",children:["Are you sure you want to delete"," ",h.jsx("span",{className:"font-mono text-white",children:d}),"?"]}),h.jsx("p",{className:"font-mono text-[10px] text-neutral-500",children:"This action cannot be undone."})]}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>p(null),children:"Cancel"}),h.jsx(Oe,{variant:"destructive",onClick:N,disabled:x.isPending,children:x.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"})," Deleting..."]}):"Delete"})]})]})})]})}const KX={};function au(e,t){if(t==="absolute")return new Date(e).toLocaleString();const n=new Date(e),i=new Date().getTime()-n.getTime(),a=Math.floor(i/1e3);return a<60?`${a}s`:a<3600?`${Math.floor(a/60)}m`:a<86400?`${Math.floor(a/3600)}h`:`${Math.floor(a/86400)}d`}function GX(e){const t=e.split(/\s+/).map(i=>i.trim()).filter(i=>i.length>0),n={},s=[];for(const i of t){const[a="",...l]=i.split(":"),f=l.join(":").trim(),d=a.toLowerCase();if(!f){s.push(i);continue}if(d==="actor"){n.actorId=f;continue}if(d==="client"){n.clientId=f;continue}if(d==="table"){n.table=f;continue}if(d==="request"){n.requestId=f;continue}if(d==="trace"){n.traceId=f;continue}s.push(i)}return s.length>0&&(n.search=s.join(" ")),n}function ZX(e){return e==="1h"?3600*1e3:e==="6h"?360*60*1e3:e==="24h"?1440*60*1e3:e==="7d"?10080*60*1e3:720*60*60*1e3}function Zd(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function YX(e,t){return e?`#${e.federatedCommitId??(t?`${t}:${e.commitSeq}`:String(e.commitSeq))}`:"#?"}function XX(e,t){return e?`E${e.federatedEventId??(t?`${t}:${e.eventId}`:e.eventId)}`:"E?"}function QX(e,t,n){return!e||!t?null:e.replaceAll("{traceId}",encodeURIComponent(t)).replaceAll("{spanId}",encodeURIComponent(n??""))}function bx({initialSelectedEntryId:e}={}){const{preferences:t}=af(),{partitionId:n}=of(),{range:s,setRange:i}=vk(),a=t.pageSize,l=t.refreshInterval*1e3,f=KX?.VITE_CONSOLE_TRACE_URL_TEMPLATE,[d,p]=_.useState(()=>e?.startsWith("#")?"commits":e?.startsWith("E")?"events":"all"),[g,y]=_.useState("all"),[b,x]=_.useState("all"),[S,w]=_.useState(""),[T,C]=_.useState(1),[k,N]=_.useState(!1),[R,M]=_.useState(e??null),L=_.useRef(!1),j=_.useMemo(()=>GX(S),[S]),A=_.useMemo(()=>new Date(Date.now()-ZX(s)).toISOString(),[s]),{data:P,isLoading:G,refetch:B}=NY({limit:a,offset:(T-1)*a,...n?{partitionId:n}:{},view:d,...d!=="commits"&&g!=="all"?{eventType:g}:{},...d!=="commits"&&b!=="all"?{outcome:b}:{},...j.actorId?{actorId:j.actorId}:{},...j.clientId?{clientId:j.clientId}:{},...j.requestId?{requestId:j.requestId}:{},...j.traceId?{traceId:j.traceId}:{},...j.table?{table:j.table}:{},...j.search?{search:j.search}:{},from:A},{refetchIntervalMs:l}),z=rX(),Q=R?.startsWith("#")?R.slice(1):void 0,Y=R?.startsWith("E")?R.slice(1):void 0,ee=Q&&Q!=="?"?Q:void 0,D=Y&&Y!=="?"?Y:void 0,{data:K,isLoading:q,error:V}=RY(ee,{enabled:ee!==void 0,partitionId:n}),{data:U,isLoading:I,error:H}=jY(D,{enabled:D!==void 0,partitionId:n}),{data:W,isLoading:X,error:oe}=AY(D,{enabled:D!==void 0&&!!U?.payloadRef,partitionId:n}),se=_.useMemo(()=>QX(f,U?.traceId??null,U?.spanId??null),[U?.spanId,U?.traceId,f]);_.useEffect(()=>{C(1)},[]),_.useEffect(()=>{C(1)},[]),_.useEffect(()=>{e&&M(e)},[e]),_.useEffect(()=>{if(!L.current){L.current=!0;return}M(null)},[]),_.useEffect(()=>{C(1),M(null)},[]);const xe=_.useMemo(()=>(P?.items??[]).map(we=>{const ve=we.instanceId??we.commit?.instanceId??we.event?.instanceId,Se=ve?`[${ve}] `:"";if(we.type==="commit"&&we.commit){const Ue=we.commit;return{type:"commit",id:YX(Ue,ve),outcome:"--",duration:"--",actor:Ue.actorId,client:Ue.clientId,detail:`${Se}${Ue.changeCount} chg | ${(Ue.affectedTables??[]).join(", ")}`,time:au(we.timestamp,t.timeFormat)}}const ye=we.event;return ye?{type:ye.eventType,id:XX(ye,ve),outcome:ye.outcome,duration:`${ye.durationMs}ms`,actor:ye.actorId,client:ye.clientId,detail:`${Se}${(ye.tables??[]).join(", ")||"--"}`,time:au(we.timestamp,t.timeFormat)}:{type:"pull",id:"E?",outcome:"unknown",duration:"--",actor:"",client:"",detail:"--",time:au(we.timestamp,t.timeFormat)}}),[t.timeFormat,P?.items]),he=P?.total??0,Me=Math.max(1,Math.ceil(he/a)),_e=G,ne=[{label:"",options:[{id:"all",label:"All"},{id:"commits",label:"Commits"},{id:"events",label:"Events"}],activeId:d,onActiveChange:ae=>{p(ae),ae==="commits"&&(y("all"),x("all")),C(1)}},{label:"Time",options:[{id:"1h",label:"1h"},{id:"6h",label:"6h"},{id:"24h",label:"24h"},{id:"7d",label:"7d"},{id:"30d",label:"30d"}],activeId:s,onActiveChange:ae=>{i(ae),C(1)}},{label:"Type",options:[{id:"all",label:"All"},{id:"push",label:"Push"},{id:"pull",label:"Pull"}],activeId:g,onActiveChange:ae=>{y(ae),C(1)}},{label:"Outcome",options:[{id:"all",label:"All"},{id:"applied",label:"Applied"},{id:"error",label:"Error"},{id:"rejected",label:"Rejected"}],activeId:b,onActiveChange:ae=>{x(ae),C(1)}}];function pe(){z.mutate(void 0,{onSuccess:()=>{N(!1),B()}})}return h.jsxs("div",{className:"flex flex-col h-full",children:[_e&&xe.length===0?h.jsx("div",{className:"flex items-center justify-center py-24",children:h.jsx(Pt,{size:"lg"})}):h.jsx(nA,{entries:xe,selectedEntryId:R,onEntryClick:ae=>M(ae.id),filterBar:h.jsx(Zj,{groups:ne,searchValue:S,searchPlaceholder:"Use actor:, client:, table:, request:, trace: or free text...",onSearchChange:w,actions:h.jsxs(h.Fragment,{children:[h.jsx(Oe,{size:"sm",variant:"ghost",onClick:()=>{B()},children:"Refresh"}),h.jsx(Oe,{size:"sm",variant:"ghost",children:"Export"}),h.jsx(Oe,{size:"sm",variant:"destructive",onClick:()=>N(!0),children:"Clear"})]})}),pagination:h.jsx(gx,{page:T,totalPages:Me,totalItems:he,onPageChange:C})}),h.jsx($r,{open:R!==null,onOpenChange:ae=>{ae||M(null)},children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:ee!==void 0?`Commit #${ee}`:D!==void 0?`Event E${D}`:"Entry details"})}),h.jsx("div",{className:"px-5 py-4 space-y-3 max-h-[70vh] overflow-y-auto",children:q||I?h.jsx("div",{className:"flex items-center justify-center py-8",children:h.jsx(Pt,{size:"sm"})}):V||H?h.jsx("p",{className:"font-mono text-[11px] text-offline",children:"Failed to load details."}):K?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"grid grid-cols-2 gap-3 font-mono text-[11px]",children:[h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Actor"}),h.jsx("div",{className:"text-neutral-100",children:K.actorId})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Client"}),h.jsx("div",{className:"text-neutral-100",children:K.clientId})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Instance"}),h.jsx("div",{className:"text-neutral-100",children:K.instanceId??"--"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Created"}),h.jsx("div",{className:"text-neutral-100",children:au(K.createdAt,t.timeFormat)})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Changes"}),h.jsx("div",{className:"text-neutral-100",children:K.changeCount})]})]}),h.jsxs("div",{children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2",children:"Affected Tables"}),h.jsx("p",{className:"font-mono text-[11px] text-neutral-200",children:K.affectedTables.join(", ")||"--"})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500",children:"Changes"}),K.changes.length===0?h.jsx("p",{className:"font-mono text-[11px] text-neutral-500",children:"No changes recorded."}):K.changes.map(ae=>h.jsxs("div",{className:"rounded-md border border-border p-3 space-y-2",children:[h.jsxs("div",{className:"flex items-center justify-between font-mono text-[11px]",children:[h.jsxs("span",{className:"text-neutral-300",children:[ae.table," | ",ae.op]}),h.jsxs("span",{className:"text-neutral-500",children:["#",ae.changeId]})]}),h.jsxs("div",{className:"font-mono text-[11px] text-neutral-400",children:["rowId: ",ae.rowId,ae.rowVersion!==null?` | version: ${ae.rowVersion}`:""]}),h.jsx("pre",{className:"font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200",children:Zd(ae.rowJson)})]},ae.changeId))]})]}):U?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"grid grid-cols-2 gap-3 font-mono text-[11px]",children:[h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Type"}),h.jsx("div",{className:"text-neutral-100",children:U.eventType})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Path"}),h.jsx("div",{className:"text-neutral-100",children:U.syncPath})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Instance"}),h.jsx("div",{className:"text-neutral-100",children:U.instanceId??"--"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Outcome"}),h.jsx("div",{className:"text-neutral-100",children:U.outcome})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Response Status"}),h.jsx("div",{className:"text-neutral-100",children:U.responseStatus})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Actor"}),h.jsx("div",{className:"text-neutral-100",children:U.actorId})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Client"}),h.jsx("div",{className:"text-neutral-100",children:U.clientId})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Status"}),h.jsx("div",{className:"text-neutral-100",children:U.statusCode})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Transport"}),h.jsx("div",{className:"text-neutral-100",children:U.transportPath})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Duration"}),h.jsxs("div",{className:"text-neutral-100",children:[U.durationMs,"ms"]})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Request ID"}),h.jsx("div",{className:"text-neutral-100",children:U.requestId})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Trace ID"}),h.jsx("div",{className:"text-neutral-100",children:U.traceId??"--"}),se&&h.jsx("a",{href:se,target:"_blank",rel:"noreferrer",className:"font-mono text-[10px] text-flow underline underline-offset-4",children:"Open external trace"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Span ID"}),h.jsx("div",{className:"text-neutral-100",children:U.spanId??"--"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Commit Seq"}),h.jsx("div",{className:"text-neutral-100",children:U.commitSeq??"--"}),U.commitSeq!==null&&h.jsx(Oe,{variant:"ghost",size:"sm",onClick:()=>M(`#${U.instanceId?`${U.instanceId}:`:""}${U.commitSeq}`),children:"Open linked commit"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Subscription Count"}),h.jsx("div",{className:"text-neutral-100",children:U.subscriptionCount??"--"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Error Code"}),h.jsx("div",{className:"text-neutral-100",children:U.errorCode??"--"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Payload Ref"}),h.jsx("div",{className:"text-neutral-100",children:U.payloadRef??"--"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Created"}),h.jsx("div",{className:"text-neutral-100",children:au(U.createdAt,t.timeFormat)})]})]}),h.jsxs("div",{children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2",children:"Tables"}),h.jsx("p",{className:"font-mono text-[11px] text-neutral-200",children:U.tables.join(", ")||"--"})]}),U.scopesSummary&&h.jsxs("div",{children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2",children:"Scopes Summary"}),h.jsx("pre",{className:"font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200",children:Zd(U.scopesSummary)})]}),U.payloadRef&&h.jsxs("div",{children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2",children:"Payload Snapshot"}),X?h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Pt,{size:"sm"}),h.jsx("span",{className:"font-mono text-[11px] text-neutral-400",children:"Loading payload snapshot..."})]}):oe?h.jsx("p",{className:"font-mono text-[11px] text-offline",children:"Failed to load payload snapshot."}):W?h.jsxs("div",{className:"space-y-2",children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500",children:"Request"}),h.jsx("pre",{className:"font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200",children:Zd(W.requestPayload)}),h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500",children:"Response"}),h.jsx("pre",{className:"font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200",children:Zd(W.responsePayload)})]}):h.jsx("p",{className:"font-mono text-[11px] text-neutral-500",children:"No payload snapshot available."})]}),U.errorMessage&&h.jsxs("div",{children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2",children:"Error"}),h.jsx("p",{className:"font-mono text-[11px] text-offline",children:U.errorMessage})]})]}):h.jsx("p",{className:"font-mono text-[11px] text-neutral-500",children:"No details available for this row."})}),h.jsx(Nn,{children:h.jsx(Oe,{variant:"default",size:"sm",onClick:()=>M(null),children:"Close"})})]})}),h.jsx($r,{open:k,onOpenChange:ae=>{ae||N(!1)},children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Clear all events"})}),h.jsx("div",{className:"p-4",children:h.jsx("span",{className:"font-mono text-[11px] text-neutral-400",children:"This will permanently delete all request events. Commits are not affected. Are you sure?"})}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",size:"sm",onClick:()=>N(!1),children:"Cancel"}),h.jsx(Oe,{variant:"destructive",size:"sm",onClick:pe,disabled:z.isPending,children:z.isPending?"Clearing...":"Clear all"})]})]})})]})}const WX=ao({getParentRoute:()=>lo,path:"/config",component:gX}),JX=ao({getParentRoute:()=>lo,path:"/fleet",component:NX}),eQ=ao({getParentRoute:()=>lo,path:"/",component:mX});function tQ(){const{seq:e}=bk.useParams();return h.jsx(bx,{initialSelectedEntryId:`#${e}`})}const bk=ao({getParentRoute:()=>lo,path:"/investigate/commit/$seq",component:tQ});function nQ(){const{id:e}=xk.useParams();return h.jsx(bx,{initialSelectedEntryId:`E${e}`})}const xk=ao({getParentRoute:()=>lo,path:"/investigate/event/$id",component:nQ}),rQ=ao({getParentRoute:()=>lo,path:"/ops",component:DX}),sQ=ao({getParentRoute:()=>lo,path:"/storage",component:VX}),oQ=ao({getParentRoute:()=>lo,path:"/stream",component:bx}),iQ=lo.addChildren([eQ,oQ,bk,xk,JX,rQ,sQ,WX]),aQ="syncular-console-basepath",cQ="syncular-console-server-url",lQ="syncular-console-token";function uQ(e){if(!e)return;const t=e.trim();return t.length>0?t:void 0}function Hv(e){const t=globalThis.document;if(!t)return;const n=t.querySelector(`meta[name="${e}"]`)?.getAttribute("content");return uQ(n)}function Sk(e){return!e||e==="/"?"/":(e.startsWith("/")?e:`/${e}`).replace(/\/+$/g,"")||"/"}function fQ(){return Sk(Hv(aQ))}function dQ(){const e=Hv(cQ),t=Hv(lQ);return!e||!t?null:{serverUrl:e,token:t}}function hQ(){return new I6({defaultOptions:{queries:{staleTime:5e3,retry:1}}})}function pQ(e){return Sk(e??fQ())}function mQ(e){const[t]=_.useState(()=>hQ()),n=_.useMemo(()=>UH({routeTree:iQ,basepath:pQ(e.basePath)}),[e.basePath]),s=e.defaultConfig===void 0?dQ():e.defaultConfig,i=e.autoConnect??e.defaultConfig===void 0;return h.jsx(P6,{client:t,children:h.jsx(nq,{defaultConfig:s,autoConnect:i,storageMode:e.storageMode,children:h.jsx(FH,{router:n})})})}function gQ(e){return h.jsx("div",{className:vx,children:h.jsx(mQ,{...e})})}function yQ(e){const t=document.querySelector(e);if(!t)throw new Error(`Unable to mount console: ${e} not found`);return t}function vQ(e,t={}){const n=yQ(e);XY(n);const s=u6.createRoot(n),i=h.jsx(gQ,{basePath:t.basePath,defaultConfig:t.defaultConfig,autoConnect:t.autoConnect});return t.strictMode===!1?(s.render(i),s):(s.render(h.jsx(_.StrictMode,{children:i})),s)}var bQ={};const xQ="syncular-sentry-dsn",SQ="syncular-sentry-environment",_Q="syncular-sentry-release";function gu(e){if(!e)return;const t=e.trim();return t.length>0?t:void 0}function Hy(e){if(typeof document>"u")return;const t=document.querySelector(`meta[name="${e}"]`)?.getAttribute("content");return gu(t)}function qy(e){if(!(typeof process>"u"))return gu(bQ[e])}function Vy(e){for(const t of e)if(t)return t}function wQ(){const e=Vy([gu(globalThis.__SYNCULAR_SENTRY_DSN__),Hy(xQ),qy("SYNCULAR_SENTRY_DSN")]);if(!e)return null;const t=Vy([gu(globalThis.__SYNCULAR_SENTRY_ENVIRONMENT__),Hy(SQ),qy("SYNCULAR_SENTRY_ENVIRONMENT")]),n=Vy([gu(globalThis.__SYNCULAR_SENTRY_RELEASE__),Hy(_Q),qy("SYNCULAR_SENTRY_RELEASE")]);return{dsn:e,environment:t,release:n,enableLogs:!0,tracesSampleRate:.2,tracePropagationTargets:[/^https?:\/\/.*\/api\/.*/]}}const JC=wQ();JC&&t6(JC);vQ("#root");
@@ -10,7 +10,7 @@
10
10
  <meta name="syncular-sentry-environment" content="" />
11
11
  <meta name="syncular-sentry-release" content="" />
12
12
  <title>@syncular Console</title>
13
- <script type="module" crossorigin src="/assets/index-BJsNmMGm.js"></script>
13
+ <script type="module" crossorigin src="/assets/index-CDpgHlJf.js"></script>
14
14
  <link rel="stylesheet" crossorigin href="/assets/index-D_fQabjS.css">
15
15
  </head>
16
16
  <body class="syncular-console-root min-h-screen bg-background text-foreground">