@syncular/console 0.0.6-168 → 0.0.6-177
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-
|
|
3
|
+
"version": "0.0.6-177",
|
|
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-
|
|
72
|
-
"@syncular/transport-http": "0.0.6-
|
|
73
|
-
"@syncular/ui": "0.0.6-
|
|
71
|
+
"@syncular/observability-sentry": "0.0.6-177",
|
|
72
|
+
"@syncular/transport-http": "0.0.6-177",
|
|
73
|
+
"@syncular/ui": "0.0.6-177",
|
|
74
74
|
"@tanstack/react-query": "^5.90.21",
|
|
75
75
|
"@tanstack/react-router": "^1.163.2",
|
|
76
76
|
"lucide-react": "^0.575.0"
|
|
@@ -83,4 +83,4 @@ ${a}
|
|
|
83
83
|
${c.right}px ${c.bottom}px,
|
|
84
84
|
${c.right}px ${c.top}px,
|
|
85
85
|
${c.left}px ${c.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 Zh(e,t){e&&Object.assign(e.style,t)}const QG={position:"relative",maxHeight:"100%",overflowX:"hidden",overflowY:"auto"},WG={position:"fixed"},JG=_.forwardRef(function(t,n){const{anchor:s,positionMethod:i="absolute",className:a,render:c,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=r8,...A}=t,{store:N,listRef:R,labelsRef:k,alignItemWithTriggerActiveRef:L,selectedItemTextRef:j,valuesRef:O,initialValueRef:D,popupRef:K,setValue:F}=Yu(),z=KA(),X=at(N,it.open),Y=at(N,it.mounted),te=at(N,it.modal),P=at(N,it.value),V=at(N,it.openMethod),B=at(N,it.positionerElement),q=at(N,it.triggerElement),U=at(N,it.isItemEqualToValue),I=at(N,it.transitionStatus),G=_.useRef(null),W=_.useRef(null),[Q,se]=_.useState(T),oe=Y&&Q&&V!=="touch";!Y&&Q!==T&&se(T),ze(()=>{Y||(it.scrollUpArrowVisible(N.state)&&N.set("scrollUpArrowVisible",!1),it.scrollDownArrowVisible(N.state)&&N.set("scrollDownArrowVisible",!1))},[N,Y]),_.useImperativeHandle(L,()=>oe),GA((oe||te)&&X&&V!=="touch",q);const pe=FA({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??oe,collisionAvoidance:C,keepMounted:!0}),Se=oe?"none":pe.side,he=oe?WG:pe.positionerStyles,He=_.useMemo(()=>{const xe={};return X||(xe.pointerEvents="none"),{role:"presentation",hidden:!Y,style:{...he,...xe}}},[X,Y,he]),Ee={open:X,side:Se,align:pe.align,anchorHidden:pe.anchorHidden},re=Ae(xe=>{N.set("positionerElement",xe)}),de=Pt("div",t,{ref:[n,re],state:Ee,stateAttributesMapping:rc,props:[He,Cp(I),A]}),ae=_.useRef(0),_e=Ae(xe=>{if(xe.size===0&&ae.current===0||O.current.length===0)return;const ye=ae.current;if(ae.current=xe.size,xe.size===ye)return;const Le=Kt(ri);if(ye!==0&&!N.state.multiple&&P!==null&&Py(O.current,P,U)===-1){const we=D.current,Xe=we!=null&&Py(O.current,we,U)!==-1?we:null;F(Xe,Le),Xe===null&&(N.set("selectedIndex",null),j.current=null)}if(ye!==0&&N.state.multiple&&Array.isArray(P)){const ke=Ve=>Py(O.current,Ve,U)!==-1,we=P.filter(Ve=>ke(Ve));(we.length!==P.length||we.some(Ve=>!RG(P,Ve,U)))&&(F(we,Le),we.length===0&&(N.set("selectedIndex",null),j.current=null))}if(X&&oe){N.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});const ke={height:""};Zh(B,ke),Zh(K.current,ke)}}),ve=_.useMemo(()=>({...pe,side:Se,alignItemWithTriggerActive:oe,setControlledAlignItemWithTrigger:se,scrollUpArrowRef:G,scrollDownArrowRef:W}),[pe,Se,oe,se]);return h.jsx(YA,{elementsRef:R,labelsRef:k,onMapChange:_e,children:h.jsxs(XA.Provider,{value:ve,children:[Y&&te&&h.jsx(QA,{inert:dx(!X),cutout:q}),de]})})});function WA(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 Bd="base-ui-disable-scrollbar",UC={className:Bd,getElement(e){return h.jsx("style",{nonce:e,href:Bd,precedence:"base-ui:low",children:`.${Bd}{scrollbar-width:none}.${Bd}::-webkit-scrollbar{display:none}`})}},eZ=_.createContext(void 0);function JA(e){return _.useContext(eZ)}const Sl="ArrowUp",Zi="ArrowDown",Nu="ArrowLeft",_l="ArrowRight",Xu="Home",Qu="End",eO=new Set([Nu,_l]),tZ=new Set([Nu,_l,Xu,Qu]),tO=new Set([Sl,Zi]),nZ=new Set([Sl,Zi,Xu,Qu]),nO=new Set([...eO,...tO]),rZ=new Set([...nO,Xu,Qu]),rO=new Set([Sl,Zi,Nu,_l,Xu,Qu]),sZ="Shift",oZ="Control",iZ="Alt",aZ="Meta",lZ=new Set([sZ,oZ,iZ,aZ]);function cZ(e){return Vt(e)&&e.tagName==="INPUT"}function $C(e){return!!(cZ(e)&&e.selectionStart!=null||Vt(e)&&e.tagName==="TEXTAREA")}function BC(e,t,n,s){if(!e||!t||!t.scrollTo)return;let i=e.scrollLeft,a=e.scrollTop;const c=e.clientWidth<e.scrollWidth,f=e.clientHeight<e.scrollHeight;if(c&&s!=="vertical"){const d=FC(e,t,"left"),p=Fd(e),g=Fd(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=Fd(e),g=Fd(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 Fd(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 zy(e,t=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(t,Math.min(e,n))}const uZ=_.createContext(void 0),fZ={disableStyleElements:!1};function dZ(){return _.useContext(uZ)??fZ}const Bi=1,hZ={...rc,...ga},pZ=_.forwardRef(function(t,n){const{render:s,className:i,finalFocus:a,...c}=t,{store:f,popupRef:d,onOpenChangeComplete:p,setOpen:g,valueRef:y,selectedItemTextRef:b,keyboardActiveRef:x,multiple:S,handleScrollArrowVisibility:w,scrollHandlerRef:T,highlightItemOnHover:C}=Yu(),{side:A,align:N,alignItemWithTriggerActive:R,setControlledAlignItemWithTrigger:k,scrollDownArrowRef:L,scrollUpArrowRef:j}=XG(),O=JA()!=null,D=KA(),{nonce:K,disableStyleElements:F}=dZ(),z=Jr(),X=at(f,it.id),Y=at(f,it.open),te=at(f,it.mounted),P=at(f,it.popupProps),V=at(f,it.transitionStatus),B=at(f,it.triggerElement),q=at(f,it.positionerElement),U=at(f,it.listElement),I=_.useRef(0),G=_.useRef(!1),W=_.useRef(0),Q=_.useRef(!1),se=_.useRef({}),oe=ix(),pe=Ae(Ee=>{if(!q||!d.current||!Q.current)return;if(G.current||!R){w();return}const re=q.style.top==="0px",de=q.style.bottom==="0px",ae=q.getBoundingClientRect().height,_e=Rt(q),ve=getComputedStyle(q),xe=parseFloat(ve.marginTop),ye=parseFloat(ve.marginBottom),Le=HC(getComputedStyle(d.current)),ke=Math.min(_e.documentElement.clientHeight-xe-ye,Le),we=Ee.scrollTop,Ve=qC(Ee);let Xe=0,$e=null,We=!1,Fe=!1;const me=qe=>{q.style.height=`${qe}px`},Te=(qe,mt)=>{const ct=zy(qe,0,ke-ae);ct>0&&me(ae+ct),Ee.scrollTop=mt,ke-(ae+ct)<=Bi&&(G.current=!0),w()};if(re){const qe=Ve-we,mt=ae+qe,ct=Math.min(mt,ke);if(Xe=ct,qe<=Bi){Te(qe,Ve);return}ke-ct>Bi?Fe=!0:We=!0}else if(de){const qe=we,mt=ae+qe,ct=Math.min(mt,ke),br=mt-ke;if(Xe=ct,qe<=Bi){Te(qe,0);return}ke-ct>Bi?$e=0:(We=!0,we<Ve&&($e=we-(qe-br)))}if(Xe=Math.ceil(Xe),Xe!==0&&me(Xe),Fe||$e!=null){const qe=qC(Ee),mt=Fe?qe:zy($e,0,qe);Math.abs(Ee.scrollTop-mt)>Bi&&(Ee.scrollTop=mt)}(We||Xe>=ke-Bi)&&(G.current=!0),w()});_.useImperativeHandle(T,()=>pe,[pe]),ya({open:Y,ref:d,onComplete(){Y&&p?.(!0)}});const Se={open:Y,transitionStatus:V,side:A,align:N};ze(()=>{!q||!d.current||Object.keys(se.current).length||(se.current={top:q.style.top||"0",left:q.style.left||"0",right:q.style.right,height:q.style.height,bottom:q.style.bottom,minHeight:q.style.minHeight,maxHeight:q.style.maxHeight,marginTop:q.style.marginTop,marginBottom:q.style.marginBottom})},[d,q]),ze(()=>{Y||R||(Q.current=!1,G.current=!1,I.current=0,W.current=0,Zh(q,se.current))},[Y,R,q,d]),ze(()=>{const Ee=d.current;if(!(!Y||!B||!q||!Ee||f.state.transitionStatus==="ending")){if(!R){Q.current=!0,oe.request(w),Ee.style.removeProperty("--transform-origin");return}queueMicrotask(()=>{const re=mZ(Ee);Ee.style.removeProperty("--transform-origin");try{const de=getComputedStyle(q),ae=getComputedStyle(Ee),_e=Rt(B),ve=an(q),xe=B.getBoundingClientRect(),ye=q.getBoundingClientRect(),Le=xe.left,ke=xe.height,we=U||Ee,Ve=we.scrollHeight,Xe=parseFloat(ae.borderBottomWidth),$e=parseFloat(de.marginTop)||10,We=parseFloat(de.marginBottom)||10,Fe=parseFloat(de.minHeight)||100,me=HC(ae),Te=5,qe=5,mt=20,ct=_e.documentElement.clientHeight-$e-We,br=_e.documentElement.clientWidth,xr=ct-xe.bottom+ke,Zt=b.current,ut=y.current;let xt,ot=0,Yt=0;if(Zt&&ut){const Xn=ut.getBoundingClientRect();xt=Zt.getBoundingClientRect();const is=Xn.left-Le,ao=xt.left-ye.left,lo=Xn.top-xe.top+Xn.height/2,Qn=xt.top-ye.top+xt.height/2;ot=is-ao,Yt=Qn-lo}const mn=xr+Yt+We+Xe;let Ot=Math.min(ct,mn);const wn=ct-$e-We,Yn=mn-Ot,Rn=Math.max(Te,Le+ot),ss=br-qe,os=Math.max(0,Rn+ye.width-ss);q.style.left=`${Rn-os}px`,q.style.height=`${Ot}px`,q.style.maxHeight="auto",q.style.marginTop=`${$e}px`,q.style.marginBottom=`${We}px`,Ee.style.height="100%";const ba=we.scrollHeight-we.clientHeight,bi=Yn>=ba;bi&&(Ot=Math.min(ct,ye.height)-(Yn-ba));const xi=xe.top<mt||xe.bottom>ct-mt||Ot<Math.min(Ve,Fe),xs=(ve.visualViewport?.scale??1)!==1&&nx;if(xi||xs){Q.current=!0,Zh(q,se.current),ui.flushSync(()=>k(!1));return}if(bi){const Xn=Math.max(0,ct-mn);q.style.top=ye.height>=wn?"0":`${Xn}px`,q.style.height=`${Ot}px`,we.scrollTop=we.scrollHeight-we.clientHeight,I.current=Math.max(Fe,Ot)}else q.style.bottom="0",I.current=Math.max(Fe,Ot),we.scrollTop=Yn;if(xt){const Xn=ye.top,is=ye.height,ao=xt.top+xt.height/2,lo=is>0?(ao-Xn)/is*100:50,Qn=zy(lo,0,100);Ee.style.setProperty("--transform-origin",`50% ${Qn}%`)}(I.current===ct||Ot>=me)&&(G.current=!0),w(),setTimeout(()=>{Q.current=!0})}finally{re()}})}},[f,Y,q,B,y,b,d,w,R,k,oe,L,j,U]),_.useEffect(()=>{if(!R||!q||!Y)return;const Ee=an(q);function re(de){g(!1,Kt(N8,de))}return Ee.addEventListener("resize",re),()=>{Ee.removeEventListener("resize",re)}},[g,R,q,Y]);const he={...U?{role:"presentation","aria-orientation":void 0}:{role:"listbox","aria-multiselectable":S||void 0,id:`${X}-list`},onKeyDown(Ee){x.current=!0,O&&rO.has(Ee.key)&&Ee.stopPropagation()},onMouseMove(){x.current=!1},onPointerLeave(Ee){if(!C||WA(Ee)||Ee.pointerType==="touch")return;const re=Ee.currentTarget;z.start(0,()=>{f.set("activeIndex",null),re.focus({preventScroll:!0})})},onScroll(Ee){U||pe(Ee.currentTarget)},...R&&{style:U?{height:"100%"}:QG}},He=Pt("div",t,{ref:[n,d],state:Se,stateAttributesMapping:hZ,props:[P,he,Cp(V),{className:!U&&R?UC.className:void 0},c]});return h.jsxs(_.Fragment,{children:[!F&&UC.getElement(K),h.jsx(NA,{context:D,modal:!1,disabled:!te,returnFocus:a,restoreFocus:!0,children:He})]})});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 mZ(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 sO=(function(e){return e[e.None=0]="None",e[e.GuessFromOrder=1]="GuessFromOrder",e})({});function hx(e={}){const{label:t,metadata:n,textRef:s,indexGuessBehavior:i,index:a}=e,{register:c,unregister:f,subscribeMapChange:d,elementsRef:p,labelsRef:g,nextIndexRef:y}=KG(),b=_.useRef(-1),[x,S]=_.useState(a??(i===sO.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 A=t!==void 0;g.current[x]=A?t:s?.current?.textContent??C.textContent}},[x,p,g,t,s]);return ze(()=>{if(a!=null)return;const C=w.current;if(C)return c(C,n),()=>{f(C)}},[a,c,f,n]),ze(()=>{if(a==null)return d(C=>{const A=w.current?C.get(w.current)?.index:null;A!=null&&S(A)})},[a,d,S]),_.useMemo(()=>({ref:T,index:x}),[x,T])}const gZ=_.createContext(void 0),yZ=_.memo(_.forwardRef(function(t,n){const{render:s,className:i,value:a=null,label:c,disabled:f=!1,nativeButton:d=!1,...p}=t,g=_.useRef(null),y=hx({label:c,textRef:g,indexGuessBehavior:sO.GuessFromOrder}),{store:b,getItemProps:x,setOpen:S,setValue:w,selectionRef:T,typingRef:C,valuesRef:A,keyboardActiveRef:N,multiple:R,highlightItemOnHover:k}=Yu(),L=Jr(),j=at(b,it.isActive,y.index),O=at(b,it.isSelected,y.index,a),D=at(b,it.isSelectedByFocus,y.index),K=at(b,it.isItemEqualToValue),F=y.index,z=F!==-1,X=_.useRef(null),Y=Xo(F);ze(()=>{if(!z)return;const oe=A.current;return oe[F]=a,()=>{delete oe[F]}},[z,F,a,A]),ze(()=>{if(!z)return;const oe=b.state.value;let pe=oe;R&&Array.isArray(oe)&&oe.length>0&&(pe=oe[oe.length-1]),pe!==void 0&&Ll(a,pe,K)&&b.set("selectedIndex",F)},[z,F,R,K,b,a]);const te={disabled:f,selected:O,highlighted:j},P=x({active:j,selected:O});P.onFocus=void 0,P.id=void 0;const V=_.useRef(null),B=_.useRef("mouse"),q=_.useRef(!1),{getButtonProps:U,buttonRef:I}=Ql({disabled:f,focusableWhenDisabled:!0,native:d});function G(oe){const pe=b.state.value;if(R){const Se=Array.isArray(pe)?pe:[],he=O?NG(Se,a,K):[...Se,a];w(he,Kt(Ty,oe))}else w(a,Kt(Ty,oe)),S(!1,Kt(Ty,oe))}const W={role:"option","aria-selected":O,tabIndex:j?0:-1,onFocus(){b.set("activeIndex",F)},onMouseEnter(){!N.current&&b.state.selectedIndex===null&&k&&b.set("activeIndex",F)},onMouseMove(){k&&b.set("activeIndex",F)},onMouseLeave(oe){!k||N.current||WA(oe)||L.start(0,()=>{b.state.activeIndex===F&&b.set("activeIndex",null)})},onTouchStart(){T.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1}},onKeyDown(oe){V.current=oe.key,b.set("activeIndex",F)},onClick(oe){q.current=!1,!(oe.type==="keydown"&&V.current===null)&&(f||V.current===" "&&C.current||B.current!=="touch"&&!j||(V.current=null,G(oe.nativeEvent)))},onPointerEnter(oe){B.current=oe.pointerType},onPointerDown(oe){B.current=oe.pointerType,q.current=!0},onMouseUp(oe){if(f)return;if(q.current){q.current=!1;return}const pe=!T.current.allowSelectedMouseUp&&O,Se=!T.current.allowUnselectedMouseUp&&!O;pe||Se||B.current!=="touch"&&!j||G(oe.nativeEvent)}},Q=Pt("div",t,{ref:[I,n,y.ref,X],state:te,props:[P,W,p,U]}),se=_.useMemo(()=>({selected:O,indexRef:Y,textRef:g,selectedByFocus:D,hasRegistered:z}),[O,Y,g,D,z]);return h.jsx(gZ.Provider,{value:se,children:Q})})),vZ=_.forwardRef(({className:e,children:t,...n},s)=>h.jsx(zG,{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}));vZ.displayName="SelectTrigger";const bZ=_.forwardRef(({className:e,portalProps:t,positionerProps:n,...s},i)=>h.jsx(UG,{...t,children:h.jsx(JG,{...n,children:h.jsx(pZ,{ref:i,className:ge("bg-panel border border-border rounded-md py-1 shadow-lg z-50",e),...s})})}));bZ.displayName="SelectContent";const xZ=_.forwardRef(({className:e,...t},n)=>h.jsx(yZ,{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}));xZ.displayName="SelectItem";const SZ=_.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}));SZ.displayName="Textarea";const oO=_.createContext(void 0);function _Z(e=!0){const t=_.useContext(oO);if(t===void 0&&!e)throw new Error(pn(7));return t}function iO(e={}){const{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:s}=Ij(),{ref:i,index:a}=hx(e),c=n===a,f=_.useRef(null),d=to(i,f);return{compositeProps:_.useMemo(()=>({tabIndex:c?0:-1,onFocus(){s(a)},onMouseMove(){const g=f.current;if(!t||!g)return;const y=g.hasAttribute("disabled")||g.ariaDisabled==="true";!c&&!y&&g.focus()}}),[c,s,a,t]),compositeRef:d,index:a}}function wZ(e){const{render:t,className:n,state:s=rn,props:i=Tu,refs:a=Tu,metadata:c,stateAttributesMapping:f,tag:d="div",...p}=e,{compositeProps:g,compositeRef:y}=iO({metadata:c});return Pt(d,e,{state:s,ref:[...a,y],props:[g,...i,p],stateAttributesMapping:f})}const EZ=_.forwardRef(function(t,n){const{className:s,defaultPressed:i=!1,disabled:a=!1,form:c,onPressedChange:f,pressed:d,render:p,type:g,value:y,nativeButton:b=!0,...x}=t,S=pr(y||void 0),w=_Z(),T=w?.value??[],C=w?void 0:i,A=(a||w?.disabled)??!1,[N,R]=dp({controlled:w?S!==void 0&&T.indexOf(S)>-1:d,default:C,name:"Toggle",state:"pressed"}),k=Ae((z,X)=>{S&&w?.setGroupValue?.(S,z,X),f?.(z,X)}),{getButtonProps:L,buttonRef:j}=Ql({disabled:A,native:b}),O={disabled:A,pressed:N},D=[j,n],K=[{"aria-pressed":N,onClick(z){const X=!N,Y=Kt(ri,z.nativeEvent);k(X,Y),!Y.isCanceled&&R(X)}},x,L],F=Pt("button",t,{enabled:!w,state:O,ref:D,props:K});return w?h.jsx(wZ,{tag:"button",render:p,className:s,state:O,refs:D,props:K}):F}),aO=_.forwardRef(({className:e,...t},n)=>h.jsx(EZ,{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}));aO.displayName="Toggle";function TZ(e){return e==null||e.hasAttribute("disabled")||e.getAttribute("aria-disabled")==="true"}const lO="data-composite-item-active",CZ=[];function RZ(e){const{itemSizes:t,cols:n=1,loopFocus:s=!0,dense:i=!1,orientation:a="both",direction:c,highlightedIndex:f,onHighlightedIndexChange:d,rootRef:p,enableHomeAndEndKeys:g=!1,stopEventPropagation:y=!1,disabledIndices:b,modifierKeys:x=CZ}=e,[S,w]=_.useState(0),T=n>1,C=_.useRef(null),A=to(C,p),N=_.useRef([]),R=_.useRef(!1),k=f??S,L=Ae((D,K=!1)=>{if((d??w)(D),K){const F=N.current[D];BC(C.current,F,c,a)}}),j=Ae(D=>{if(D.size===0||R.current)return;R.current=!0;const K=Array.from(D.keys()),F=K.find(X=>X?.hasAttribute(lO))??null,z=F?K.indexOf(F):-1;z!==-1&&L(z),BC(C.current,F,c,a)}),O=_.useMemo(()=>({"aria-orientation":a==="both"?void 0:a,ref:A,onFocus(D){!C.current||!$C(D.target)||D.target.setSelectionRange(0,D.target.value.length??0)},onKeyDown(D){const K=g?rZ:nO;if(!K.has(D.key)||NZ(D,x)||!C.current)return;const z=c==="rtl",X=z?Nu:_l,Y={horizontal:X,vertical:Zi,both:X}[a],te=z?_l:Nu,P={horizontal:te,vertical:Sl,both:te}[a];if($C(D.target)&&!TZ(D.target)){const W=D.target.selectionStart,Q=D.target.selectionEnd,se=D.target.value??"";if(W==null||D.shiftKey||W!==Q||D.key!==P&&W<se.length||D.key!==Y&&W>0)return}let V=k;const B=FV(N,b),q=HV(N,b);if(T){const W=t||Array.from({length:N.current.length},()=>({width:1,height:1})),Q=VV(W,n,i),se=Q.findIndex(pe=>pe!=null&&!fu(N,pe,b)),oe=Q.reduce((pe,Se,he)=>Se!=null&&!fu(N,Se,b)?he:pe,-1);V=Q[qV({current:Q.map(pe=>pe?N.current[pe]:null)},{event:D,orientation:a,loopFocus:s,cols:n,disabledIndices:GV([...b||N.current.map((pe,Se)=>fu(N,Se)?Se:void 0),void 0],Q),minIndex:se,maxIndex:oe,prevIndex:KV(k>q?B:k,W,Q,n,D.key===Zi?"bl":D.key===_l?"tr":"tl"),rtl:z})]}const U={horizontal:[X],vertical:[Zi],both:[X,Zi]}[a],I={horizontal:[te],vertical:[Sl],both:[te,Sl]}[a],G=T?K:{horizontal:g?tZ:eO,vertical:g?nZ:tO,both:K}[a];g&&(D.key===Xu?V=B:D.key===Qu&&(V=q)),V===k&&(U.includes(D.key)||I.includes(D.key))&&(s&&V===q&&U.includes(D.key)?V=B:s&&V===B&&I.includes(D.key)?V=q:V=ir(N,{startingIndex:V,decrement:I.includes(D.key),disabledIndices:b})),V!==k&&!sh(N,V)&&(y&&D.stopPropagation(),G.has(D.key)&&D.preventDefault(),L(V,!0),queueMicrotask(()=>{N.current[V]?.focus()}))}}),[n,i,c,b,N,g,k,T,t,s,A,x,L,a,y]);return _.useMemo(()=>({props:O,highlightedIndex:k,onHighlightedIndexChange:L,elementsRef:N,disabledIndices:b,onMapChange:j,relayKeyboardEvent:O.onKeyDown}),[O,k,L,N,b,j])}function NZ(e,t){for(const n of lZ.values())if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function cO(e){const{render:t,className:n,refs:s=Tu,props:i=Tu,state:a=rn,stateAttributesMapping:c,highlightedIndex:f,onHighlightedIndexChange:d,orientation:p,dense:g,itemSizes:y,loopFocus:b,cols:x,enableHomeAndEndKeys:S,onMapChange:w,stopEventPropagation:T=!0,rootRef:C,disabledIndices:A,modifierKeys:N,highlightItemOnHover:R=!1,tag:k="div",...L}=e,j=$A(),{props:O,highlightedIndex:D,onHighlightedIndexChange:K,elementsRef:F,onMapChange:z,relayKeyboardEvent:X}=RZ({itemSizes:y,cols:x,loopFocus:b,dense:g,orientation:p,highlightedIndex:f,onHighlightedIndexChange:d,rootRef:C,stopEventPropagation:T,enableHomeAndEndKeys:S,direction:j,disabledIndices:A,modifierKeys:N}),Y=Pt(k,e,{state:a,ref:s,props:[O,...i,L],stateAttributesMapping:c}),te=_.useMemo(()=>({highlightedIndex:D,onHighlightedIndexChange:K,highlightItemOnHover:R,relayKeyboardEvent:X}),[D,K,R,X]);return h.jsx(kj.Provider,{value:te,children:h.jsx(YA,{elementsRef:F,onMapChange:P=>{w?.(P),z(P)},children:Y})})}let jZ=(function(e){return e.disabled="data-disabled",e.orientation="data-orientation",e.multiple="data-multiple",e})({});const KC={multiple(e){return e?{[jZ.multiple]:""}:null}},AZ=_.forwardRef(function(t,n){const{defaultValue:s,disabled:i=!1,loopFocus:a=!0,onValueChange:c,orientation:f="horizontal",multiple:d=!1,value:p,className:g,render:y,...b}=t,x=JA(),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,A]=dp({controlled:p,default:S,name:"ToggleGroup",state:"value"}),N=Ae((O,D,K)=>{let F;if(d?(F=C.slice(),D?F.push(O):F.splice(C.indexOf(O),1)):F=D?[O]:[],Array.isArray(F)){if(c?.(F,K),K.isCanceled)return;A(F)}}),R={disabled:T,multiple:d,orientation:f},k=_.useMemo(()=>({disabled:T,orientation:f,setGroupValue:N,value:C,isValueInitialized:w}),[T,f,N,C,w]),L={role:"group"},j=Pt("div",t,{enabled:!!x,state:R,ref:n,props:[L,b],stateAttributesMapping:KC});return h.jsx(oO.Provider,{value:k,children:x?j:h.jsx(cO,{render:y,className:g,state:R,refs:[n],props:[L,b],stateAttributesMapping:KC,loopFocus:a,enableHomeAndEndKeys:!0})})}),lh=_.forwardRef(({className:e,...t},n)=>h.jsx(AZ,{ref:n,className:ge("flex items-center gap-0.5",e),...t}));lh.displayName="ToggleGroup";const OZ=ge(Gj({variant:"secondary",size:"sm"}),"h-7 whitespace-nowrap uppercase tracking-[0.08em] leading-none no-underline");function uO({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 MZ({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 c=a.id===t,f=()=>n?.(a.id);return s?h.jsx("span",{children:s(a,{active:c,onClick:f})},a.id):h.jsx(uO,{active:c,onClick:f,children:a.label},a.id)})})}const kZ=di("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}}),IZ={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 DZ({color:e,size:t,glow:n,pulse:s,className:i}){return h.jsx("span",{className:ge(kZ({color:e,size:t,glow:n}),s&&"dot-pulse",i),style:n?{boxShadow:IZ[e??"healthy"]}:void 0})}const PZ="0.0.6-168",zZ={version:PZ},LZ=zZ.version;function UZ({label:e,className:t}){return h.jsxs("div",{className:ge("flex items-center gap-3",t),children:[h.jsx(DZ,{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",LZ]})]})}function $Z({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 BZ=di("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"}}),On=_.forwardRef(({className:e,variant:t,...n},s)=>h.jsx("div",{ref:s,role:"alert",className:ge(BZ({variant:t,className:e})),...n}));On.displayName="Alert";const Wu=_.forwardRef(({className:e,...t},n)=>h.jsx("h5",{ref:n,className:ge("font-medium text-white mb-1",e),...t}));Wu.displayName="AlertTitle";const Mn=_.forwardRef(({className:e,...t},n)=>h.jsx("p",{ref:n,className:ge("text-neutral-400",e),...t}));Mn.displayName="AlertDescription";const fO=_.createContext(void 0);function sc(e){const t=_.useContext(fO);if(e===!1&&t===void 0)throw new Error(pn(27));return t}const FZ={...rc,...ga},px=_.forwardRef(function(t,n){const{render:s,className:i,forceRender:a=!1,...c}=t,{store:f}=sc(),d=f.useState("open"),p=f.useState("nested"),g=f.useState("mounted"),y=f.useState("transitionStatus");return Pt("div",t,{state:{open:d,transitionStatus:y},ref:[f.context.backdropRef,n],stateAttributesMapping:FZ,props:[{role:"presentation",hidden:!g,style:{userSelect:"none",WebkitUserSelect:"none"}},c],enabled:a||!p})}),dO=_.forwardRef(function(t,n){const{render:s,className:i,id:a,...c}=t,{store:f}=sc(),d=pr(a);return f.useSyncedValueWithCleanup("descriptionElementId",d),Pt("p",t,{ref:n,props:[{id:d},c]})});let HZ=(function(e){return e.nestedDialogs="--nested-dialogs",e})({}),qZ=(function(e){return e[e.open=Gi.open]="open",e[e.closed=Gi.closed]="closed",e[e.startingStyle=Gi.startingStyle]="startingStyle",e[e.endingStyle=Gi.endingStyle]="endingStyle",e.nested="data-nested",e.nestedDialogOpen="data-nested-dialog-open",e})({});const hO=_.createContext(void 0);function VZ(){const e=_.useContext(hO);if(e===void 0)throw new Error(pn(26));return e}const KZ={...rc,...ga,nestedDialogOpen(e){return e?{[qZ.nestedDialogOpen]:""}:null}},pO=_.forwardRef(function(t,n){const{className:s,finalFocus:i,initialFocus:a,render:c,...f}=t,{store:d}=sc(),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"),A=d.useState("openMethod"),N=d.useState("titleElementId"),R=d.useState("transitionStatus"),k=d.useState("role");VZ(),ya({open:C,ref:d.context.popupRef,onComplete(){C&&d.context.onOpenChangeComplete?.(!0)}});function L(F){return F==="touch"?d.context.popupRef.current:!0}const j=a===void 0?L:a,O=T>0,K=Pt("div",t,{state:{open:C,nested:w,transitionStatus:R,nestedDialogOpen:O},props:[b,{"aria-labelledby":N??void 0,"aria-describedby":p??void 0,role:k,tabIndex:-1,hidden:!S,onKeyDown(F){rO.has(F.key)&&F.stopPropagation()},style:{[HZ.nestedDialogs]:T}},f],ref:[n,d.context.popupRef,d.useStateSetter("popupElement")],stateAttributesMapping:KZ});return h.jsx(NA,{context:y,openInteractionType:A,disabled:!S,closeOnFocusOut:!g,initialFocus:j,returnFocus:i,modal:x!==!1,restoreFocus:"popup",children:K})}),mO=_.forwardRef(function(t,n){const{keepMounted:s=!1,...i}=t,{store:a}=sc(),c=a.useState("mounted"),f=a.useState("modal"),d=a.useState("open");return c||s?h.jsx(hO.Provider,{value:s,children:h.jsxs(RA,{ref:n,...i,children:[c&&f===!0&&h.jsx(QA,{ref:a.context.internalBackdropRef,inert:dx(!d)}),t.children]})}):null});function GZ(e){const{store:t,parentContext:n,actionsRef:s}=e,i=t.useState("open"),a=t.useState("disablePointerDismissal"),c=t.useState("modal"),f=t.useState("popupElement"),{openMethod:d,triggerProps:p,reset:g}=kG(i);wK(t);const{forceUnmount:y}=EK(i,t,()=>{g()}),b=Ae(K=>{const F=Kt(K);return F.preventUnmountOnClose=()=>{t.set("preventUnmountingOnClose",!0)},F}),x=_.useCallback(()=>{t.setOpen(!1,b(R8))},[t,b]);_.useImperativeHandle(s,()=>({unmount:y,close:x}),[y,x]);const S=AK({popupStore:t,onOpenChange:t.setOpen,treatPopupAsFloatingElement:!0,noEmit:!0}),[w,T]=_.useState(0),C=w===0,A=UK(S),N=fK(S,{outsidePressEvent(){return t.context.internalBackdropRef.current||t.context.backdropRef.current?"intentional":{mouse:c==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}},outsidePress(K){if(!t.context.outsidePressEnabledRef.current||"button"in K&&K.button!==0||"touches"in K&&K.touches.length!==1)return!1;const F=Ir(K);if(C&&!a){const z=F;return c&&(t.context.internalBackdropRef.current||t.context.backdropRef.current)?t.context.internalBackdropRef.current===z||t.context.backdropRef.current===z||Mt(z,f)&&!z?.hasAttribute("data-base-ui-portal"):!0}return!1},escapeKey:C});GA(i&&c===!0,f);const{getReferenceProps:R,getFloatingProps:k,getTriggerProps:L}=zK([A,N]);t.useContextCallback("onNestedDialogOpen",K=>{T(K+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]),O=_.useMemo(()=>L(p),[L,p]),D=_.useMemo(()=>k(),[k]);t.useSyncedValues({openMethod:d,activeTriggerProps:j,inactiveTriggerProps:O,popupProps:D,floatingRootContext:S,nestedOpenDialogCount:w})}const ZZ={...RK,modal:Ie(e=>e.modal),nested:Ie(e=>e.nested),nestedOpenDialogCount:Ie(e=>e.nestedOpenDialogCount),disablePointerDismissal:Ie(e=>e.disablePointerDismissal),openMethod:Ie(e=>e.openMethod),descriptionElementId:Ie(e=>e.descriptionElementId),titleElementId:Ie(e=>e.titleElementId),viewportElement:Ie(e=>e.viewportElement),role:Ie(e=>e.role)};class YZ extends zA{constructor(t){super(XZ(t),{popupRef:_.createRef(),backdropRef:_.createRef(),internalBackdropRef:_.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:new ux,onOpenChange:void 0,onOpenChangeComplete:void 0},ZZ)}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 XZ(e={}){return{...CK(),modal:!0,disablePointerDismissal:!1,popupElement:null,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,role:"dialog",...e}}function QZ(e){const{children:t,open:n,defaultOpen:s=!1,onOpenChange:i,onOpenChangeComplete:a,disablePointerDismissal:c=!1,modal:f=!0,actionsRef:d,handle:p,triggerId:g,defaultTriggerId:y=null}=e,b=sc(!0),x=!!b,S=In(()=>p?.store??new YZ({open:s,openProp:n,activeTriggerId:y,triggerIdProp:g,modal:f,disablePointerDismissal:c,nested:x})).current;hV(()=>{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:c,nested:x,modal:f}),S.useContextCallback("onOpenChange",i),S.useContextCallback("onOpenChangeComplete",a);const w=S.useState("payload");GZ({store:S,actionsRef:d,parentContext:b?.store.context});const T=_.useMemo(()=>({store:S}),[S]);return h.jsx(fO.Provider,{value:T,children:typeof t=="function"?t({payload:w}):t})}const gO=_.forwardRef(function(t,n){const{render:s,className:i,id:a,...c}=t,{store:f}=sc(),d=pr(a);return f.useSyncedValueWithCleanup("titleElementId",d),Pt("h2",t,{ref:n,props:[{id:d},c]})}),Dr=QZ,WZ=_.forwardRef(({className:e,...t},n)=>h.jsx(px,{ref:n,className:ge("fixed inset-0 z-50 bg-black/60 backdrop-blur-sm",e),...t}));WZ.displayName="DialogOverlay";const lr=_.forwardRef(({className:e,children:t,...n},s)=>h.jsxs(mO,{children:[h.jsx(px,{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm"}),h.jsx(pO,{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})]}));lr.displayName="DialogContent";const cr=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("px-5 py-3 border-b border-border",e),...t}));cr.displayName="DialogHeader";const Tn=_.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}));Tn.displayName="DialogFooter";const ur=_.forwardRef(({className:e,...t},n)=>h.jsx(gO,{ref:n,className:ge("font-mono text-[10px] text-neutral-500 uppercase tracking-widest",e),...t}));ur.displayName="DialogTitle";const JZ=_.forwardRef(({className:e,...t},n)=>h.jsx(dO,{ref:n,className:ge("font-mono text-[10px] text-neutral-500",e),...t}));JZ.displayName="DialogDescription";const mx=_.forwardRef(({className:e,page:t,totalPages:n,totalItems:s,onPageChange:i,...a},c)=>h.jsxs("div",{ref:c,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(Me,{size:"sm",variant:"default",disabled:t<=1,onClick:()=>i(t-1),children:"Prev"}),h.jsx(Me,{size:"sm",variant:"default",disabled:t>=n,onClick:()=>i(t+1),children:"Next"})]})]}));mx.displayName="Pagination";const eY=_.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}));eY.displayName="Separator";const tY=di("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"}}),nY=_.forwardRef(({className:e,side:t,children:n,...s},i)=>h.jsxs(mO,{children:[h.jsx(px,{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm"}),h.jsx(pO,{ref:i,className:ge(tY({side:t,className:e})),...s,children:n})]}));nY.displayName="SheetContent";const rY=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("px-5 py-3 border-b border-border",e),...t}));rY.displayName="SheetHeader";const sY=_.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}));sY.displayName="SheetFooter";const oY=_.forwardRef(({className:e,...t},n)=>h.jsx(gO,{ref:n,className:ge("font-mono text-[10px] text-neutral-500 uppercase tracking-widest",e),...t}));oY.displayName="SheetTitle";const iY=_.forwardRef(({className:e,...t},n)=>h.jsx(dO,{ref:n,className:ge("text-sm text-neutral-400",e),...t}));iY.displayName="SheetDescription";const aY=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("rounded-md bg-neutral-800 animate-pulse",e),...t}));aY.displayName="Skeleton";const lY=_.createContext(void 0);function gx(){const e=_.useContext(lY);if(e===void 0)throw new Error(pn(64));return e}let cY=(function(e){return e.activationDirection="data-activation-direction",e.orientation="data-orientation",e})({});const yO={tabActivationDirection:e=>({[cY.activationDirection]:e})},vO=_.createContext(void 0);function uY(){const e=_.useContext(vO);if(e===void 0)throw new Error(pn(65));return e}const fY=_.forwardRef(function(t,n){const{className:s,disabled:i=!1,render:a,value:c,id:f,nativeButton:d=!0,...p}=t,{value:g,getTabPanelIdByValue:y,orientation:b}=gx(),{activateOnFocus:x,highlightedTabIndex:S,onTabActivation:w,setHighlightedTabIndex:T,tabsListElement:C}=uY(),A=pr(f),N=_.useMemo(()=>({disabled:i,id:A,value:c}),[i,A,c]),{compositeProps:R,compositeRef:k,index:L}=iO({metadata:N}),j=c===g,O=_.useRef(!1);ze(()=>{if(O.current){O.current=!1;return}if(!(j&&L>-1&&S!==L))return;const q=C;if(q!=null){const U=Lo(Rt(q));if(U&&Mt(q,U))return}i||T(L)},[j,L,S,T,i,C]);const{getButtonProps:D,buttonRef:K}=Ql({disabled:i,native:d,focusableWhenDisabled:!0}),F=y(c),z=_.useRef(!1),X=_.useRef(!1);function Y(q){j||i||w(c,Kt(ri,q.nativeEvent,void 0,{activationDirection:"none"}))}function te(q){j||(L>-1&&!i&&T(L),!i&&x&&(!z.current||z.current&&X.current)&&w(c,Kt(ri,q.nativeEvent,void 0,{activationDirection:"none"})))}function P(q){if(j||i)return;z.current=!0;function U(){z.current=!1,X.current=!1}(!q.button||q.button===0)&&(X.current=!0,Rt(q.currentTarget).addEventListener("pointerup",U,{once:!0}))}return Pt("button",t,{state:{disabled:i,active:j,orientation:b},ref:[n,K,k],props:[R,{role:"tab","aria-controls":F,"aria-selected":j,id:A,onClick:Y,onFocus:te,onPointerDown:P,[lO]:j?"":void 0,onKeyDownCapture(){O.current=!0}},p,D]})});let dY=(function(e){return e.index="data-index",e.activationDirection="data-activation-direction",e.orientation="data-orientation",e.hidden="data-hidden",e})({});const hY={...yO,...ga},pY=_.forwardRef(function(t,n){const{className:s,value:i,render:a,keepMounted:c=!1,...f}=t,{value:d,getTabIdByPanelValue:p,orientation:g,tabActivationDirection:y,registerMountedTabPanel:b,unregisterMountedTabPanel:x}=gx(),S=pr(),w=_.useMemo(()=>({id:S,value:i}),[S,i]),{ref:T,index:C}=hx({metadata:w}),A=i===d,{mounted:N,transitionStatus:R,setMounted:k}=Tp(A),L=!N,j=p(i),O={hidden:L,orientation:g,tabActivationDirection:y,transitionStatus:R},D=_.useRef(null),K=Pt("div",t,{state:O,ref:[n,T,D],props:[{"aria-labelledby":j,hidden:L,id:S,role:"tabpanel",tabIndex:A?0:-1,inert:dx(!A),[dY.index]:C},f],stateAttributesMapping:hY});return ya({open:A,ref:D,onComplete(){A||k(!1)}}),ze(()=>{if(!(L&&!c)&&S!=null)return b(i,S),()=>{x(i,S)}},[L,c,i,S,b,x]),c||N?K:null}),mY=_.forwardRef(function(t,n){const{activateOnFocus:s=!1,className:i,loopFocus:a=!0,render:c,...f}=t,{getTabElementBySelectedValue:d,onValueChange:p,orientation:g,value:y,setTabMap:b,tabActivationDirection:x}=gx(),[S,w]=_.useState(0),[T,C]=_.useState(null),A=gY(y,g,T,d),N=Ae((j,O)=>{if(j!==y){const D=A(j);O.activationDirection=D,p(j,O)}}),R={orientation:g,tabActivationDirection:x},k={"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(vO.Provider,{value:L,children:h.jsx(cO,{render:c,className:i,state:R,refs:[n,C],props:[k,f],stateAttributesMapping:yO,highlightedIndex:S,enableHomeAndEndKeys:!0,loopFocus:a,orientation:g,onHighlightedIndexChange:w,onMapChange:b,disabledIndices:Tu})})});function GC(e,t){const{left:n,top:s}=e.getBoundingClientRect(),{left:i,top:a}=t.getBoundingClientRect(),c=n-i,f=s-a;return{left:c,top:f}}function gY(e,t,n,s){const[i,a]=_.useState(null);return ze(()=>{if(e==null||n==null){a(null);return}const c=s(e);if(c==null){a(null);return}const{left:f,top:d}=GC(c,n);a(t==="horizontal"?f:d)},[t,s,n,e]),_.useCallback(c=>{if(c===e)return"none";if(c==null)return a(null),"none";if(c!=null&&n!=null){const f=s(c);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 yY=_.forwardRef(({className:e,...t},n)=>h.jsx(mY,{ref:n,className:ge("flex items-center gap-0.5",e),...t}));yY.displayName="TabsList";const vY=di("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"}}),bY=_.forwardRef(({className:e,variant:t,...n},s)=>h.jsx(fY,{ref:s,className:ge(vY({variant:t,className:e})),...n}));bY.displayName="TabsTrigger";const xY=_.forwardRef(({className:e,...t},n)=>h.jsx(pY,{ref:n,className:ge("outline-none",e),...t}));xY.displayName="TabsContent";const SY=_.forwardRef(({className:e,...t},n)=>h.jsx("p",{ref:n,className:ge("font-mono text-[11px] text-neutral-300",e),...t}));SY.displayName="Text";const _Y=_.forwardRef(({className:e,...t},n)=>h.jsx("p",{ref:n,className:ge("font-mono text-[10px] text-neutral-500",e),...t}));_Y.displayName="TextMuted";const wY=_.forwardRef(({className:e,...t},n)=>h.jsx("code",{ref:n,className:ge("font-mono text-[11px] text-white",e),...t}));wY.displayName="TextCode";const EY=_.forwardRef(({className:e,...t},n)=>h.jsx("span",{ref:n,className:ge("font-mono text-[9px] uppercase tracking-wider text-neutral-500",e),...t}));EY.displayName="TextLabel";const TY=_.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}));TY.displayName="CodeBlock";function va(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(c=>typeof a=="function"?a(c):a)},[]);return[n,i]}const CY="console:instance-id";function Rp(){const[e,t]=va(CY,""),n=e.trim();return _.useMemo(()=>({instanceId:n.length>0?n:void 0,rawInstanceId:e,setInstanceId:t,clearInstanceId:()=>t("")}),[n,e,t])}const Zn={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 vi(e,t){return e===0?!1:e??t}function RY(e){const t=new URLSearchParams;if(!e)return t;for(const[n,s]of Object.entries(e))s!=null&&t.set(n,String(s));return t}function bO(e,t,n){const s=e.endsWith("/")?e.slice(0,-1):e,a=RY(n)?.toString();return`${s}${t}${a?`?${a}`:""}`}function Np(e,t){if(!t||!e)throw new Error("Not connected");return e}async function yr(e){const t={Authorization:`Bearer ${e.connectionConfig.token}`};e.body!==void 0&&(t["Content-Type"]="application/json");const n=await fetch(bO(e.connectionConfig.serverUrl,e.path,e.query),{method:e.method??"GET",headers:t,body:e.body===void 0?void 0:JSON.stringify(e.body)});if(!n.ok)throw new Error(e.errorMessage);return n.json()}async function NY(e){const t=await fetch(bO(e.connectionConfig.serverUrl,e.path,e.query),{method:"GET",headers:{Authorization:`Bearer ${e.connectionConfig.token}`}});if(!t.ok)throw new Error(e.errorMessage);return t.blob()}function ns(e){const{config:t,isConnected:n}=pa();return NN({queryKey:e.queryKey,queryFn:()=>yr({connectionConfig:Np(t,n),path:e.path,query:e.query,method:e.method,errorMessage:e.errorMessage}),enabled:(e.enabled??!0)&&n&&!!t,refetchInterval:e.refetchInterval})}function yx(e){const{config:t,isConnected:n}=pa();return NN({queryKey:e.queryKey,queryFn:()=>{if(e.id===void 0)throw new Error(e.requiredMessage);return yr({connectionConfig:Np(t,n),path:e.path(e.id),query:e.query,errorMessage:e.errorMessage})},enabled:(e.enabled??!0)&&e.id!==void 0&&n&&!!t})}function jY(e,t){for(const n of t)e.invalidateQueries({queryKey:n})}function vr(e){const{instanceId:t}=Rp();return e??t}function rs(e){const{config:t,isConnected:n}=pa(),{instanceId:s}=Rp(),i=Ab();return X6({mutationFn:a=>e.mutationFn({connectionConfig:Np(t,n),variables:a,selectedInstanceId:s}),onSuccess:()=>{e.invalidateQueryKeys&&jY(i,e.invalidateQueryKeys)}})}function Ju(e={}){const t=vr(e.instanceId);return ns({queryKey:Zn.stats({partitionId:e.partitionId,instanceId:t}),path:"/console/stats",query:{partitionId:e.partitionId,instanceId:t},errorMessage:"Failed to fetch stats",refetchInterval:vi(e.refetchIntervalMs,5e3)})}function AY(e={},t={}){const n=vr(e.instanceId);return ns({queryKey:Zn.timeseries({...e,instanceId:n}),path:"/console/stats/timeseries",query:{interval:e.interval,range:e.range,partitionId:e.partitionId,instanceId:n},errorMessage:"Failed to fetch timeseries stats",enabled:t.enabled,refetchInterval:vi(t.refetchIntervalMs,3e4)})}function OY(e={},t={}){const n=vr(e.instanceId);return ns({queryKey:Zn.latency({...e,instanceId:n}),path:"/console/stats/latency",query:{range:e.range,partitionId:e.partitionId,instanceId:n},errorMessage:"Failed to fetch latency stats",enabled:t.enabled,refetchInterval:vi(t.refetchIntervalMs,3e4)})}function MY(e={},t={}){const n=vr(e.instanceId);return ns({queryKey:Zn.commits({...e,instanceId:n}),path:"/console/commits",query:{limit:e.limit,offset:e.offset,partitionId:e.partitionId,instanceId:n},errorMessage:"Failed to fetch commits",enabled:t.enabled,refetchInterval:vi(t.refetchIntervalMs,1e4)})}function kY(e,t={}){const n=vr(t.instanceId);return yx({queryKey:Zn.commitDetail(e,t.partitionId,n),id:e,requiredMessage:"Commit sequence is required",path:s=>`/console/commits/${encodeURIComponent(String(s))}`,query:{partitionId:t.partitionId,instanceId:n},errorMessage:"Failed to fetch commit detail",enabled:t.enabled})}function IY(e={},t={}){const n=vr(e.instanceId);return ns({queryKey:Zn.timeline({...e,instanceId:n}),path:"/console/timeline",query:{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,instanceId:n},errorMessage:"Failed to fetch timeline",enabled:t.enabled,refetchInterval:vi(t.refetchIntervalMs,1e4)})}function xO(e={},t={}){const n=vr(e.instanceId);return ns({queryKey:Zn.clients({...e,instanceId:n}),path:"/console/clients",query:{limit:e.limit,offset:e.offset,partitionId:e.partitionId,instanceId:n},errorMessage:"Failed to fetch clients",enabled:t.enabled,refetchInterval:vi(t.refetchIntervalMs,1e4)})}function DY(e,t={}){const n=vr(t.instanceId);return yx({queryKey:Zn.eventDetail(e,t.partitionId,n),id:e,requiredMessage:"Event id is required",path:s=>`/console/events/${encodeURIComponent(String(s))}`,query:{partitionId:t.partitionId,instanceId:n},errorMessage:"Failed to fetch event detail",enabled:t.enabled})}function PY(e,t={}){const n=vr(t.instanceId);return yx({queryKey:Zn.eventPayload(e,t.partitionId,n),id:e,requiredMessage:"Event id is required",path:s=>`/console/events/${encodeURIComponent(String(s))}/payload`,query:{partitionId:t.partitionId,instanceId:n},errorMessage:"Failed to fetch event payload",enabled:t.enabled})}function zY(e={}){const t=vr(e.instanceId);return ns({queryKey:Zn.handlers(t),path:"/console/handlers",query:{instanceId:t},errorMessage:"Failed to fetch handlers"})}function LY(e={}){const t=vr(e.instanceId);return ns({queryKey:Zn.prunePreview(t),path:"/console/prune/preview",query:{instanceId:t},method:"POST",errorMessage:"Failed to fetch prune preview",enabled:e.enabled})}function UY(e={},t={}){const n=vr(e.instanceId);return ns({queryKey:Zn.operations({...e,instanceId:n}),path:"/console/operations",query:{limit:e.limit,offset:e.offset,operationType:e.operationType,partitionId:e.partitionId,instanceId:n},errorMessage:"Failed to fetch operations",enabled:t.enabled,refetchInterval:vi(t.refetchIntervalMs,1e4)})}function $Y(){return rs({mutationFn:async({connectionConfig:e,selectedInstanceId:t})=>yr({connectionConfig:e,path:"/console/events",query:{instanceId:t},method:"DELETE",errorMessage:"Failed to clear events"}),invalidateQueryKeys:[["console","events"]]})}function BY(){return rs({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>{const s=t.instanceId??n;return yr({connectionConfig:e,path:`/console/clients/${encodeURIComponent(t.clientId)}`,query:{partitionId:t.partitionId,instanceId:s},method:"DELETE",errorMessage:"Failed to evict client"})},invalidateQueryKeys:[["console","clients"],["console","stats"],["console","operations"]]})}function FY(){return rs({mutationFn:async({connectionConfig:e,selectedInstanceId:t})=>yr({connectionConfig:e,path:"/console/prune",query:{instanceId:t},method:"POST",errorMessage:"Failed to prune"}),invalidateQueryKeys:[["console","stats"],["console","commits"],["console","timeline"],["console","prune","preview"],["console","operations"]]})}function HY(){return rs({mutationFn:async({connectionConfig:e,selectedInstanceId:t})=>yr({connectionConfig:e,path:"/console/compact",query:{instanceId:t},method:"POST",errorMessage:"Failed to compact"}),invalidateQueryKeys:[["console","stats"],["console","operations"]]})}function qY(){return rs({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>{const s=t.instanceId??n;return yr({connectionConfig:e,path:"/console/notify-data-change",query:{instanceId:s},method:"POST",body:{tables:t.tables,partitionId:t.partitionId},errorMessage:"Failed to notify data change"})},invalidateQueryKeys:[["console","stats"],["console","commits"],["console","timeline"],["console","operations"]]})}function VY(e={}){const t=vr(e.instanceId);return ns({queryKey:Zn.apiKeys({...e,instanceId:t}),path:"/console/api-keys",query:{limit:e.limit,offset:e.offset,type:e.type,status:e.status,expiresWithinDays:e.expiresWithinDays,instanceId:t},errorMessage:"Failed to fetch API keys"})}function KY(){return rs({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>yr({connectionConfig:e,path:"/console/api-keys",query:{instanceId:n},method:"POST",body:t,errorMessage:"Failed to create API key"}),invalidateQueryKeys:[["console","api-keys"]]})}function GY(){return rs({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>yr({connectionConfig:e,path:`/console/api-keys/${encodeURIComponent(t)}`,query:{instanceId:n},method:"DELETE",errorMessage:"Failed to revoke API key"}),invalidateQueryKeys:[["console","api-keys"]]})}function ZY(){return rs({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>yr({connectionConfig:e,path:"/console/api-keys/bulk-revoke",query:{instanceId:n},method:"POST",body:t,errorMessage:"Failed to bulk revoke API keys"}),invalidateQueryKeys:[["console","api-keys"]]})}function YY(){return rs({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>yr({connectionConfig:e,path:`/console/api-keys/${encodeURIComponent(t)}/rotate`,query:{instanceId:n},method:"POST",errorMessage:"Failed to rotate API key"}),invalidateQueryKeys:[["console","api-keys"]]})}function XY(){return rs({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>yr({connectionConfig:e,path:`/console/api-keys/${encodeURIComponent(t)}/rotate/stage`,query:{instanceId:n},method:"POST",errorMessage:"Failed to stage-rotate API key"}),invalidateQueryKeys:[["console","api-keys"]]})}function QY(e={}){return ns({queryKey:Zn.storage({prefix:e.prefix,cursor:e.cursor,limit:e.limit}),path:"/console/storage",query:{prefix:e.prefix,cursor:e.cursor,limit:e.limit},errorMessage:"Failed to list blobs",refetchInterval:vi(e.refetchIntervalMs,3e4)})}function WY(){return rs({mutationFn:async({connectionConfig:e,variables:t})=>yr({connectionConfig:e,path:`/console/storage/${encodeURIComponent(t)}`,method:"DELETE",errorMessage:"Failed to delete blob"}),invalidateQueryKeys:[["console","storage"]]})}function JY(){const{config:e,isConnected:t}=pa();return async n=>{const s=await NY({connectionConfig:Np(e,t),path:`/console/storage/${encodeURIComponent(n)}/download`,errorMessage:"Failed to download blob"}),i=URL.createObjectURL(s),a=document.createElement("a");a.href=i,a.download=n.split("/").pop()||n,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}}const eX="console:partition-id";function ef(){const[e,t]=va(eX,""),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 tf(){const[e,t]=va("console:preferences",ZC);return{preferences:e,setPreferences:t,updatePreference:(i,a)=>{t(c=>({...c,[i]:a}))},resetPreferences:()=>{t(ZC)}}}const tX=[{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"}],nX=[{value:10,label:"10"},{value:20,label:"20"},{value:50,label:"50"},{value:100,label:"100"}],vx="syncular-console-root";function rX(e){e.classList.add(vx)}const sX=[{suffix:"",label:"Command"},{suffix:"/stream",label:"Stream"},{suffix:"/fleet",label:"Fleet"},{suffix:"/ops",label:"Ops"},{suffix:"/storage",label:"Storage"},{suffix:"/config",label:"Config"}];function oX(e){const t=e?.trim()??"";return!t||t==="/"?"":(t.startsWith("/")?t:`/${t}`).replace(/\/+$/g,"")}function Ly(e,t){return e?t?`${e}${t}`:e:t||"/"}function iX({basePath:e,appHref:t,modeBadge:n}){const{connect:s,config:i,isConnected:a,isConnecting:c}=pa(),{preferences:f}=tf(),{instanceId:d,rawInstanceId:p,setInstanceId:g,clearInstanceId:y}=Rp(),{partitionId:b,rawPartitionId:x,setPartitionId:S,clearPartitionId:w}=ef(),T=hr({select:D=>D.location.pathname}),{data:C}=Ju({refetchIntervalMs:f.refreshInterval*1e3,partitionId:b,instanceId:d}),A=oX(e),N=_.useMemo(()=>sX.map(D=>({...D,id:Ly(A,D.suffix)})),[A]),R=Ly(A,""),k=Ly(A,"/config"),L=c?"connecting":a?"connected":i?"disconnected":"not-configured",j=N.find(D=>D.suffix===""?T===R||T===`${R}/`:T.startsWith(D.id))?.id??R,O=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($Z,{brand:h.jsx(yl,{to:R,children:h.jsx(UZ,{label:"console"})}),center:h.jsx(MZ,{items:N,activeId:j,renderItem:(D,{active:K})=>h.jsx(yl,{to:D.id,children:h.jsx(uO,{active:K,children:D.label})},D.id)}),right:h.jsxs("div",{className:"flex items-center gap-2",children:[n?h.jsx(dn,{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(Hn,{variant:"mono",value:p,onChange:D=>g(D.target.value),onBlur:D=>g(D.target.value.trim()),placeholder:"all",className:"h-7 w-[110px] px-2 py-1"}),d?h.jsx(Me,{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(Hn,{variant:"mono",value:x,onChange:D=>S(D.target.value),onBlur:D=>S(D.target.value.trim()),placeholder:"all",className:"h-7 w-[110px] px-2 py-1"}),b?h.jsx(Me,{variant:"ghost",size:"sm",className:"h-7 px-2 text-[10px]",onClick:w,children:"All"}):null]}),h.jsx(D8,{state:L}),h.jsx(yl,{to:k,children:h.jsx(Me,{variant:T===k?"secondary":"ghost",size:"icon",children:h.jsx(W8,{className:"h-3 w-3"})})}),t?h.jsxs("a",{href:t,className:OZ,children:[h.jsx(X8,{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===k?h.jsx("div",{style:{animation:"pageIn 0.3s ease-out"},children:h.jsx(JN,{})},T):h.jsx(aX,{configPath:k,hasSavedConfig:!!i,isConnecting:c,onConnect:()=>{s()}})})}),a&&h.jsx(Vj,{isLive:a,metrics:O,uptime:"--"})]})}function aX({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(Me,{variant:"default",onClick:s,disabled:n,children:n?"Connecting...":"Connect"}),h.jsx(yl,{to:e,children:h.jsx(Me,{variant:"link",children:"Configure connection"})})]})]})}const io=PH({component:iX});function lX(e={}){const{maxEvents:t=100,enabled:n=!0,staleAfterMs:s=65e3,replayLimit:i=100,partitionId:a,instanceId:c}=e,{config:f,isConnected:d}=pa(),{instanceId:p}=Rp(),g=c??p,[y,b]=_.useState([]),[x,S]=_.useState(!1),[w,T]=_.useState("disconnected"),[C,A]=_.useState(null),N=_.useRef(null),R=_.useRef(null),k=_.useRef(null),L=_.useRef(0),j=_.useRef(0),O=_.useRef(null),D=_.useCallback(()=>{b([]),O.current=null},[]);return _.useEffect(()=>{if(!n||!d||!f?.serverUrl||!f?.token)return;let K=!1;const F=Number.isFinite(i)?Math.max(1,Math.min(500,Math.floor(i))):100;if(typeof WebSocket>"u")return;const z=()=>{R.current&&(clearTimeout(R.current),R.current=null)},X=()=>{k.current&&(clearInterval(k.current),k.current=null)},Y=()=>{if(K||R.current)return;L.current+=1;const V=Math.min(3e4,1e3*2**Math.max(0,L.current-1)),B=Math.floor(V*.2*Math.random()),q=V+B;R.current=setTimeout(()=>{R.current=null,K||P()},q)},te=()=>{j.current=Date.now(),S(!0),T("connected")},P=()=>{if(K)return;T("connecting"),z();const V=(()=>{const q=new URL(f.serverUrl,window.location.origin);q.protocol=q.protocol==="https:"?"wss:":"ws:";const U=q.pathname.endsWith("/")?q.pathname.slice(0,-1):q.pathname;return q.pathname=`${U}/console/events/live`,q.search="",O.current&&q.searchParams.set("since",O.current),q.searchParams.set("replayLimit",String(F)),a&&q.searchParams.set("partitionId",a),g&&q.searchParams.set("instanceId",g),q.toString()})(),B=new WebSocket(V);N.current=B,B.onopen=()=>{if(K){B.close();return}L.current=0,A(null),T("connecting"),S(!1);try{B.send(JSON.stringify({type:"auth",token:f.token}))}catch{B.close();return}X(),k.current=setInterval(()=>{const q=N.current;if(!q||q.readyState!==WebSocket.OPEN)return;const U=j.current;!U||Date.now()-U<=s||(S(!1),T("stale"),q.close())},1e3)},B.onclose=()=>{K||(S(!1),T("disconnected"),X(),Y())},B.onerror=()=>{K||A(new Error("WebSocket connection failed"))},B.onmessage=q=>{try{const U=JSON.parse(q.data),I=U.type;if(te(),I==="connected"||I==="heartbeat"||I==="auth_required")return;if(I==="error"){const se=typeof U.message=="string"?U.message:"Live events authentication failed";A(new Error(se));return}const G={type:I,timestamp:U.timestamp||new Date().toISOString(),data:U};if(a&&G.data.partitionId!==a||g&&G.data.instanceId!==g)return;const W=Date.parse(O.current??""),Q=Date.parse(G.timestamp);Number.isFinite(Q)&&(!Number.isFinite(W)||Q>W)&&(O.current=G.timestamp),b(se=>[G,...se].slice(0,t))}catch{}}};return P(),()=>{K=!0,z(),X(),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:D}}const cX=_.createContext(null);function SO(){const[e,t]=va("console:time-range","24h");return{range:e,setRange:t}}const uX=[{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 fX(e){const t=e.toLowerCase();for(const n of uX)if(t.includes(n.hint))return n.type;return"client"}function dX(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 hX(e,t){return typeof e.lagCommitCount=="number"?Math.max(0,e.lagCommitCount):t?Math.max(0,t.maxCommitSeq-e.cursor):0}function pX(e,t){return e.activityState==="stale"?"offline":t>0?"syncing":"online"}function mX(e,t){return e.length<=16?e:`${e.slice(0,12)}-${t+1}`}function gX(e,t,n={}){const s=n.maxNodes??10;return e.slice(0,s).map((i,a)=>{const c=hX(i,t),f=pX(i,c);return{id:mX(i.clientId,a),type:fX(i.clientId),status:f,cursor:Math.max(0,i.cursor),actor:i.actorId,mode:i.connectionMode,dialect:dX(i.clientId),scopes:Object.keys(i.effectiveScopes||{}),lastSeen:i.updatedAt}})}const yX={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 vX(e){const t=e.length>1&&e.endsWith("/")?e.slice(0,-1):e;return t==="/console"||t.startsWith("/console/")?"/console/stream":"/stream"}function bX(){const e=up(),t=_.useMemo(()=>typeof window>"u"?"/stream":vX(window.location.pathname),[]),n=SO(),{range:s}=n,{preferences:i}=tf(),{partitionId:a}=ef(),c=i.refreshInterval*1e3,[f]=va("console:alert-config",yX),[d,p]=_.useState("1h"),{data:g}=Ju({refetchIntervalMs:c,partitionId:a}),{data:y}=AY({range:s,partitionId:a},{refetchIntervalMs:c}),{data:b}=OY({range:s,partitionId:a},{refetchIntervalMs:c}),{data:x}=MY({limit:5,partitionId:a},{refetchIntervalMs:c}),{data:S}=xO({limit:12,offset:0,partitionId:a},{refetchIntervalMs:c}),{events:w,isConnected:T}=lX({maxEvents:8,partitionId:a}),C=_.useMemo(()=>{const z=y?.buckets??[];let X=0,Y=0;for(const P of z)X+=P.pushCount+P.pullCount,Y+=P.errorCount;const te=X>0?Y/X*100:0;return{totalEvents:X,errorRate:te}},[y?.buckets]),A=_.useMemo(()=>S?.items?gX(S.items,g,{maxNodes:12}):[],[S?.items,g]),N=A.filter(z=>z.status!=="offline").length,R=A.filter(z=>z.status==="offline").length,k=_.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 X=Math.max(...z.map(Y=>Math.max(Y.pushCount,Y.pullCount)),1);return z.map(Y=>({pushPercent:X>0?Y.pushCount/X*100:0,pullPercent:X>0?Y.pullCount/X*100:0}))},[y?.buckets]),O=_.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]),D=_.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]),K=_.useMemo(()=>Math.max(0,100-C.errorRate),[C.errorRate]),F=_.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(cX.Provider,{value:n,children:h.jsxs("div",{className:"flex flex-col",children:[F.length>0&&h.jsx("div",{className:"px-6 pb-4",children:h.jsxs(On,{variant:"destructive",children:[h.jsx(Wu,{children:"Threshold Exceeded"}),h.jsx(Mn,{children:F.map((z,X)=>h.jsx("span",{className:"block",children:z},X))})]})}),h.jsx(HA,{clients:A,totalNodes:A.length+2,onlineCount:N,offlineCount:R,relayClientIds:[]}),h.jsx(Jj,{items:k}),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(Tj,{bars:j,activeRange:d,onRangeChange:p})}),h.jsx("div",{className:"border-b border-border border-r border-border",children:h.jsx(eA,{buckets:O,successRate:K})}),h.jsx("div",{className:"border-r border-border",children:h.jsx(Kj,{commits:D,onViewAll:()=>e({href:t})})})]}),h.jsx(tA,{entries:L,isConnected:T,maxVisible:20,maxHeight:"calc(100vh - 200px)"})]})]})}):h.jsx("div",{className:"flex items-center justify-center py-24",children:h.jsx(Dt,{size:"lg"})})}function xX(){return h.jsx(bX,{})}const Xr=aO;function SX({children:e}){return h.jsxs("div",{className:"space-y-4 px-5 py-5",children:[h.jsx(_X,{}),h.jsx(RX,{}),h.jsx(NX,{}),e]})}function _X(){const{clearError:e,config:t,connect:n,disconnect:s,error:i,isConnected:a,isConnecting:c}=pa(),[f,d]=_.useState(t?.serverUrl??"/api"),[p,g]=_.useState(t?.token??""),[y,b]=_.useState(null),[x,S]=_.useState(!1),[w,T]=_.useState(null),[C,A]=va("console:disconnect-clear-saved-config",!1);_.useEffect(()=>{const j=new URLSearchParams(window.location.search),O=j.get("server");let D=!1;if(O&&(d(O),j.delete("server"),D=!0),j.has("token")&&(j.delete("token"),D=!0),D){const K=j.toString(),F=K?`${window.location.pathname}?${K}`:window.location.pathname;window.history.replaceState({},"",F)}},[]),_.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)},k=async()=>{S(!0),b(null),T(null);const j=performance.now();try{const O=f.trim(),D=p.trim();if(!O||!D)throw new Error("Missing server URL or token");if(!(await fetch(`${O}/console/stats`,{headers:{Authorization:`Bearer ${D}`}})).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(Zj,{isConnected:a,isConnecting:c,isTestingConnection:x,serverUrl:f,onServerUrlChange:d,consoleToken:p,onConsoleTokenChange:g,onSaveAndConnect:N,onDisconnect:R,onTestConnection:k,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(bp,{checked:C,onCheckedChange:A})]})})})}const wX=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 Uy(e){if(!e)return"Never";const t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():"Invalid date"}function EX(e){return e.length===0?"all scopes":e.length<=2?e.join(", "):`${e.slice(0,2).join(", ")} +${e.length-2}`}function TX(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*wX?"expiring":"active"}function CX(e){return e==="revoked"?"destructive":e==="expired"?"offline":e==="expiring"?"syncing":"healthy"}function RX(){const[e,t]=_.useState("all"),[n,s]=_.useState("all"),[i,a]=_.useState("14"),[c,f]=_.useState(!1),[d,p]=_.useState(!1),[g,y]=_.useState(""),[b,x]=_.useState("relay"),[S,w]=_.useState(""),[T,C]=_.useState(""),[A,N]=_.useState(""),[R,k]=_.useState(null),[L,j]=_.useState([]),[O,D]=_.useState(null),[K,F]=_.useState(null),[z,X]=_.useState(null),[Y,te]=_.useState(null),[P,V]=_.useState(null),[B,q]=_.useState(null),[U,I]=_.useState(null),G=_.useMemo(()=>XC(i),[i]),W=G??14,Q=_.useMemo(()=>XC(A),[A]),se=A.trim().length>0,oe=!se||Q!==null,pe=_.useMemo(()=>({type:e==="all"?void 0:e,status:n==="all"?void 0:n,expiresWithinDays:n==="expiring"?W:void 0}),[e,n,W]),{data:Se,isLoading:he,error:He}=VY(pe),Ee=KY(),re=ZY(),de=GY(),ae=YY(),_e=XY();_.useEffect(()=>{const me=new Set((Se?.items??[]).map(Te=>Te.keyId));j(Te=>Te.filter(qe=>me.has(qe)))},[Se?.items]);const ve=async()=>{try{const me=T.split(",").map(qe=>qe.trim()).filter(qe=>qe.length>0),Te=await Ee.mutateAsync({name:g,keyType:b,actorId:S||void 0,scopeKeys:me.length>0?me:void 0,expiresInDays:se?Q??void 0:void 0});k(Te.secretKey),y(""),w(""),C(""),N("")}catch{}},xe=me=>{navigator.clipboard.writeText(me),F(me),setTimeout(()=>F(null),2e3)},ye=async()=>{if(z)try{await de.mutateAsync(z)}finally{X(null)}},Le=async()=>{if(L.length!==0)try{const me=await re.mutateAsync({keyIds:L});D(me),j([])}catch{}},ke=async()=>{if(Y)try{const me=await _e.mutateAsync(Y.keyId);V({oldKeyId:Y.keyId,oldKeyName:Y.name,secretKey:me.secretKey})}catch{}},we=async()=>{if(P)try{await de.mutateAsync(P.oldKeyId)}finally{V(null),te(null)}},Ve=async()=>{if(B)try{const me=await ae.mutateAsync(B);I(me.secretKey)}finally{q(null)}};if(he)return h.jsx("div",{className:"flex h-[200px] items-center justify-center",children:h.jsx(Dt,{size:"lg"})});if(He)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: ",He.message]})});const Xe=(Se?.items??[]).filter(me=>me.revokedAt===null).map(me=>me.keyId),$e=Xe.length>0&&Xe.every(me=>L.includes(me)),We=L.length>0,Fe=(Se?.items??[]).filter(me=>L.includes(me.keyId)).map(me=>me.name);return h.jsxs(h.Fragment,{children:[h.jsxs(Jb,{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(Me,{size:"sm",variant:"destructive",onClick:()=>p(!0),disabled:L.length===0,children:["Revoke Selected (",L.length,")"]}),h.jsx(Me,{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(ds,{children:[h.jsx(Qr,{children:"Type filter"}),h.jsxs(lh,{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(Xr,{value:"all",children:"all"}),h.jsx(Xr,{value:"relay",children:"relay"}),h.jsx(Xr,{value:"proxy",children:"proxy"}),h.jsx(Xr,{value:"admin",children:"admin"})]})]}),h.jsxs(ds,{children:[h.jsx(Qr,{children:"Status filter"}),h.jsxs(lh,{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(Xr,{value:"all",children:"all"}),h.jsx(Xr,{value:"active",children:"active"}),h.jsx(Xr,{value:"revoked",children:"revoked"}),h.jsx(Xr,{value:"expiring",children:"expiring"})]})]}),h.jsxs(ds,{children:[h.jsx(Qr,{htmlFor:"api-key-expiring-window",children:"Expiring window (days)"}),h.jsx(dl,{children:"Used when status filter is set to expiring."}),h.jsx(Hn,{id:"api-key-expiring-window",placeholder:"14",value:i,inputMode:"numeric",onChange:me=>a(me.target.value)}),G===null&&i.trim().length>0?h.jsx("p",{className:"font-mono text-[10px] text-offline",children:"Enter a positive whole number."}):null]})]}),Se?.items.length===0?h.jsx(Qb,{message:"No API keys match the current filters."}):h.jsxs(Jl,{children:[h.jsx(ec,{children:h.jsxs(ts,{children:[h.jsx(ht,{className:"w-[28px]",children:h.jsx(Uv,{checked:$e,indeterminate:!$e&&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(tc,{children:(Se?.items??[]).map(me=>{const Te=TX(me,W);return h.jsxs(ts,{className:"group relative",children:[h.jsx(pt,{className:"w-[28px]",children:h.jsx(Uv,{checked:L.includes(me.keyId),onCheckedChange:qe=>{j(mt=>qe?[...new Set([...mt,me.keyId])]:mt.filter(ct=>ct!==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(dn,{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:EX(me.scopeKeys)})}),h.jsx(pt,{className:"w-[120px] text-neutral-500",children:Uy(me.createdAt)}),h.jsx(pt,{className:"w-[120px] text-neutral-500",children:Uy(me.lastUsedAt)}),h.jsx(pt,{className:"w-[120px] text-neutral-500",children:Uy(me.expiresAt)}),h.jsx(pt,{className:"flex-1",children:h.jsx(dn,{variant:CX(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:()=>te(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:()=>q(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:()=>X(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(Dr,{open:c,onOpenChange:f,children:h.jsxs(lr,{children:[h.jsx(cr,{children:h.jsx(ur,{children:"Create API Key"})}),R?h.jsx(QC,{copiedKeyId:K,onClose:()=>{k(null),f(!1)},onCopy:xe,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(ds,{children:[h.jsx(Qr,{htmlFor:"api-key-name",children:"Name"}),h.jsx(Hn,{id:"api-key-name",placeholder:"Backend Relay Key",value:g,onChange:me=>y(me.target.value)})]}),h.jsxs(ds,{children:[h.jsx(Qr,{children:"Key type"}),h.jsxs(lh,{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(Xr,{value:"relay",children:"relay"}),h.jsx(Xr,{value:"proxy",children:"proxy"}),h.jsx(Xr,{value:"admin",children:"admin"})]})]}),h.jsxs(ds,{children:[h.jsx(Qr,{htmlFor:"api-key-actor-id",children:"Actor ID (optional)"}),h.jsx(dl,{children:"Pin this key to a fixed actor ID"}),h.jsx(Hn,{id:"api-key-actor-id",placeholder:"actor-123",value:S,onChange:me=>w(me.target.value)})]}),h.jsxs(ds,{children:[h.jsx(Qr,{htmlFor:"api-key-scope-keys",children:"Scope keys (optional)"}),h.jsx(dl,{children:"Comma-separated list of allowed scope keys"}),h.jsx(Hn,{id:"api-key-scope-keys",placeholder:"scope-a, scope-b",value:T,onChange:me=>C(me.target.value)})]}),h.jsxs(ds,{children:[h.jsx(Qr,{htmlFor:"api-key-expires-days",children:"Expires in days (optional)"}),h.jsx(dl,{children:"Leave empty to keep the key non-expiring."}),h.jsx(Hn,{id:"api-key-expires-days",placeholder:"30",value:A,inputMode:"numeric",onChange:me=>N(me.target.value)}),oe?null:h.jsx("p",{className:"font-mono text-[10px] text-offline",children:"Enter a positive whole number."})]}),h.jsxs(Tn,{children:[h.jsx(Me,{variant:"default",onClick:()=>f(!1),children:"Cancel"}),h.jsx(Me,{variant:"primary",onClick:ve,disabled:Ee.isPending||!g||!oe,children:Ee.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Dt,{size:"sm"}),"Creating..."]}):"Create"})]})]})]})}),h.jsx(Dr,{open:d,onOpenChange:me=>{p(me),me||D(null)},children:h.jsxs(lr,{children:[h.jsx(cr,{children:h.jsx(ur,{children:"Bulk Revoke API Keys"})}),O?h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-3",children:[h.jsx(On,{variant:"destructive",children:h.jsxs(Mn,{children:["Requested ",O.requestedCount," keys. Revoked"," ",O.revokedCount,", already revoked"," ",O.alreadyRevokedCount,", not found"," ",O.notFoundCount,"."]})}),h.jsx(Tn,{children:h.jsx(Me,{variant:"primary",onClick:()=>{p(!1),D(null)},children:"Done"})})]}):h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-3",children:[h.jsx(On,{variant:"destructive",children:h.jsx(Mn,{children:"This revokes selected keys immediately and cannot be undone."})}),h.jsxs("p",{className:"font-mono text-[10px] text-neutral-500",children:["Selected keys: ",Fe.slice(0,5).join(", "),Fe.length>5?` +${Fe.length-5} more`:""]})]}),h.jsxs(Tn,{children:[h.jsx(Me,{variant:"default",onClick:()=>p(!1),children:"Cancel"}),h.jsx(Me,{variant:"destructive",onClick:Le,disabled:re.isPending||L.length===0,children:re.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Dt,{size:"sm"}),"Revoking..."]}):"Revoke Selected"})]})]})]})}),h.jsx(Dr,{open:Y!==null||P!==null,onOpenChange:()=>{te(null),V(null)},children:h.jsxs(lr,{children:[h.jsx(cr,{children:h.jsx(ur,{children:"Stage Rotate API Key"})}),P?h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[h.jsx(On,{variant:"default",children:h.jsxs(Mn,{children:["Replacement key created for ",P.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:P.secretKey}),h.jsx(Me,{variant:"default",size:"sm",onClick:()=>xe(P.secretKey),children:K===P.secretKey?"Copied":"Copy"})]}),h.jsxs(Tn,{children:[h.jsx(Me,{variant:"default",onClick:()=>{V(null),te(null)},children:"Keep Old Key Active"}),h.jsx(Me,{variant:"destructive",onClick:we,disabled:de.isPending,children:de.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Dt,{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(Tn,{children:[h.jsx(Me,{variant:"default",onClick:()=>te(null),children:"Cancel"}),h.jsx(Me,{variant:"primary",onClick:ke,disabled:_e.isPending||!Y,children:_e.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Dt,{size:"sm"}),"Staging..."]}):"Create Replacement Key"})]})]})]})}),h.jsx(Dr,{open:z!==null,onOpenChange:()=>X(null),children:h.jsxs(lr,{children:[h.jsx(cr,{children:h.jsx(ur,{children:"Revoke API Key"})}),h.jsx("div",{className:"px-5 py-4",children:h.jsx(On,{variant:"destructive",children:h.jsx(Mn,{children:"Revoking a key immediately invalidates it for all requests."})})}),h.jsxs(Tn,{children:[h.jsx(Me,{variant:"default",onClick:()=>X(null),children:"Cancel"}),h.jsx(Me,{variant:"destructive",onClick:ye,disabled:de.isPending,children:de.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Dt,{size:"sm"}),"Revoking..."]}):"Revoke"})]})]})}),h.jsx(Dr,{open:B!==null||U!==null,onOpenChange:()=>{q(null),I(null)},children:h.jsxs(lr,{children:[h.jsx(cr,{children:h.jsx(ur,{children:"Rotate API Key"})}),U?h.jsx(QC,{copiedKeyId:K,onClose:()=>I(null),onCopy:xe,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(Tn,{children:[h.jsx(Me,{variant:"default",onClick:()=>q(null),children:"Cancel"}),h.jsx(Me,{variant:"primary",onClick:Ve,disabled:ae.isPending,children:ae.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Dt,{size:"sm"}),"Rotating..."]}):"Rotate"})]})]})]})})]})}function NX(){const{preferences:e,updatePreference:t,resetPreferences:n}=tf(),s=[{type:"filter",label:"Auto-refresh interval",options:tX.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:nX.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(nA,{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(On,{variant:"destructive",children:h.jsx(Mn,{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(Me,{variant:"default",size:"sm",onClick:()=>n(s),children:e===s?"Copied":"Copy"})]}),h.jsx(Tn,{children:h.jsx(Me,{variant:"primary",onClick:t,children:"Done"})})]})}function jX(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 AX(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 OX(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),c=Math.floor(a/60),f=Math.floor(c/60),d=Math.floor(f/24);return a<60?"just now":c<60?`${c}m ago`:f<24?`${f}h ago`:`${d}d ago`}catch{return e}}function MX(e,t,n){return{id:e.clientId,type:jX(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:AX(e.clientId),scopes:Object.keys(e.effectiveScopes??{}),lastSeen:OX(e.updatedAt,n)}}function kX({emptyState:e}={}){const[t,n]=_.useState(1),[s,i]=_.useState(null),{preferences:a}=tf(),{partitionId:c}=ef(),f=a.pageSize,d=a.refreshInterval*1e3,{data:p,isLoading:g}=Ju({refetchIntervalMs:d,partitionId:c}),{data:y,isLoading:b,error:x}=xO({limit:f,offset:(t-1)*f,partitionId:c},{refetchIntervalMs:d}),S=BY(),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:c})}finally{i(null)}};if(b||g)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsx(Dt,{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 A=(y?.items??[]).map(N=>MX(N,T,a.timeFormat));return h.jsxs("div",{className:"flex flex-col gap-5 px-5 py-5",children:[A.length>0&&h.jsx(sA,{clients:A,headSeq:T}),A.length===0?e??h.jsx(aV,{children:h.jsx(Qb,{message:"No clients yet"})}):h.jsx(Qj,{clients:A,headSeq:T,onEvict:N=>{const R=y?.items.find(k=>k.clientId===N);i(R?.clientId??N)}}),w>1&&h.jsx(mx,{page:t,totalPages:w,totalItems:y?.total??0,onPageChange:n}),h.jsx(Dr,{open:s!==null,onOpenChange:()=>i(null),children:h.jsxs(lr,{children:[h.jsx(cr,{children:h.jsx(ur,{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(Tn,{children:[h.jsx(Me,{variant:"default",onClick:()=>i(null),children:"Cancel"}),h.jsx(Me,{variant:"destructive",onClick:C,disabled:S.isPending,children:S.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Dt,{size:"sm"}),"Evicting..."]}):"Evict"})]})]})})]})}const IX={latencyThresholdMs:1e3,errorRateThreshold:5,clientLagThreshold:50,enabled:!1};function DX(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 PX(e){const t=e.split(",").map(n=>n.trim()).filter(n=>n.length>0);return Array.from(new Set(t))}function zX(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 LX(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function UX(e){const t=WC(e.requestPayload),n=WC(e.resultPayload);if(e.operationType==="notify_data_change"){const a=LX(t?.tables),c=n?.commitSeq;return`${a.length} table${a.length===1?"":"s"} -> commit #${typeof c=="number"?c:"?"}`}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 $X(e){const t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function BX(){const{partitionId:e}=ef();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(FX,{}),h.jsx(GX,{})]}),h.jsxs("div",{className:"grid gap-4 xl:grid-cols-3",children:[h.jsx(HX,{partitionId:e}),h.jsx(qX,{partitionId:e}),h.jsx(VX,{partitionId:e})]}),h.jsx(KX,{partitionId:e})]})}function FX(){const{data:e,isLoading:t,error:n}=zY();if(t)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsx(Dt,{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?DX(i.snapshotChunkTtlMs):"default"}));return h.jsx(Wj,{handlers:s,tableCount:e?.items.length??0})}function HX({partitionId:e}){const[t,n]=_.useState(!1),[s,i]=_.useState(null),{data:a,isLoading:c}=Ju({partitionId:e}),{data:f,isLoading:d,refetch:p}=LY({enabled:!1}),g=FY(),y=async()=>{n(!0),i(null),await p()},b=async()=>{const S=await g.mutateAsync();i(S.deletedCommits)};if(c)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsx(Dt,{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(xp,{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(Dr,{open:t,onOpenChange:n,children:h.jsxs(lr,{children:[h.jsx(cr,{children:h.jsx(ur,{children:"Prune Old Commits"})}),h.jsx("div",{className:"px-5 py-4 flex flex-col gap-4",children:s!==null?h.jsxs(On,{variant:"default",children:[h.jsx(Wu,{children:"Pruning Complete"}),h.jsxs(Mn,{children:["Successfully deleted ",h.jsx("strong",{children:s})," commits."]})]}):d?h.jsx("div",{className:"flex items-center justify-center py-8",children:h.jsx(Dt,{size:"sm"})}):f?h.jsxs(h.Fragment,{children:[h.jsx(On,{variant:f.commitsToDelete>0?"destructive":"default",children:h.jsx(Mn,{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(dn,{variant:f.commitsToDelete>0?"offline":"ghost",children:f.commitsToDelete})]})]})]}):null}),h.jsxs(Tn,{children:[h.jsx(Me,{variant:"default",onClick:()=>n(!1),children:s!==null?"Close":"Cancel"}),s===null&&h.jsx(Me,{variant:"destructive",onClick:b,disabled:g.isPending||d||(f?.commitsToDelete??0)===0,children:g.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Dt,{size:"sm"}),"Pruning..."]}):"Prune Now"})]})]})})]})}function qX({partitionId:e}){const[t,n]=_.useState(!1),[s,i]=_.useState(null),{data:a,isLoading:c}=Ju({partitionId:e}),f=HY(),d=()=>{n(!0),i(null)},p=async()=>{const y=await f.mutateAsync();i(y.deletedChanges)};if(c)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsx(Dt,{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(xp,{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(Dr,{open:t,onOpenChange:n,children:h.jsxs(lr,{children:[h.jsx(cr,{children:h.jsx(ur,{children:"Compact Changes"})}),h.jsx("div",{className:"px-5 py-4 flex flex-col gap-4",children:s!==null?h.jsxs(On,{variant:"default",children:[h.jsx(Wu,{children:"Compaction Complete"}),h.jsxs(Mn,{children:["Successfully removed ",h.jsx("strong",{children:s})," redundant changes."]})]}):h.jsx(On,{variant:"default",children:h.jsx(Mn,{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(Tn,{children:[h.jsx(Me,{variant:"default",onClick:()=>n(!1),children:s!==null?"Close":"Cancel"}),s===null&&h.jsx(Me,{variant:"primary",onClick:p,disabled:f.isPending,children:f.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Dt,{size:"sm"}),"Compacting..."]}):"Compact Now"})]})]})})]})}function VX({partitionId:e}){const[t,n]=_.useState(!1),[s,i]=_.useState("tasks"),[a,c]=_.useState(e??""),[f,d]=_.useState(null),[p,g]=_.useState(null),y=qY(),b=PX(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(xp,{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(Dr,{open:t,onOpenChange:n,children:h.jsxs(lr,{children:[h.jsx(cr,{children:h.jsx(ur,{children:"Notify External Data Change"})}),h.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4",children:[f?h.jsxs(On,{variant:"default",children:[h.jsx(Wu,{children:"Notification Sent"}),h.jsxs(Mn,{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(On,{variant:"default",children:h.jsx(Mn,{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(On,{variant:"destructive",children:h.jsx(Mn,{children:p})}):null,h.jsxs(ds,{children:[h.jsx(Qr,{children:"Tables (comma-separated)"}),h.jsx(Hn,{value:s,onChange:T=>i(T.target.value),placeholder:"tasks, notes",disabled:y.isPending}),h.jsx(dl,{children:"Enter one or more table names affected by the external change."})]}),h.jsxs(ds,{children:[h.jsx(Qr,{children:"Partition ID (optional)"}),h.jsx(Hn,{value:a,onChange:T=>c(T.target.value),placeholder:"default",disabled:y.isPending})]})]}),h.jsxs(Tn,{children:[h.jsx(Me,{variant:"default",onClick:()=>n(!1),children:f?"Close":"Cancel"}),f?null:h.jsx(Me,{variant:"primary",onClick:w,disabled:y.isPending,children:y.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Dt,{size:"sm"}),"Notifying..."]}):"Notify Data Change"})]})]})})]})}function KX({partitionId:e}){const[t,n]=_.useState("all"),{data:s,isLoading:i,error:a}=UY({limit:20,offset:0,operationType:t==="all"?void 0:t,partitionId:e},{refetchIntervalMs:5e3});return h.jsx(Jb,{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(Me,{variant:t==="all"?"default":"ghost",size:"sm",onClick:()=>n("all"),children:"All"}),h.jsx(Me,{variant:t==="prune"?"default":"ghost",size:"sm",onClick:()=>n("prune"),children:"Prune"}),h.jsx(Me,{variant:t==="compact"?"default":"ghost",size:"sm",onClick:()=>n("compact"),children:"Compact"}),h.jsx(Me,{variant:t==="notify_data_change"?"default":"ghost",size:"sm",onClick:()=>n("notify_data_change"),children:"Notify"}),h.jsx(Me,{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(Dt,{size:"lg"})}):a?h.jsx(On,{variant:"destructive",children:h.jsxs(Mn,{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(Jl,{children:[h.jsx(ec,{children:h.jsxs(ts,{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(tc,{children:(s?.items??[]).map((c,f)=>h.jsxs(ts,{children:[h.jsx(pt,{className:"whitespace-nowrap text-xs text-neutral-400",children:$X(c.createdAt)}),h.jsx(pt,{children:h.jsx(dn,{variant:"ghost",children:zX(c.operationType)})}),h.jsx(pt,{className:"font-mono text-xs",children:c.consoleUserId??"system"}),h.jsx(pt,{className:"font-mono text-xs",children:c.targetClientId??c.partitionId??(c.operationType==="notify_data_change"?"partition default":"global")}),h.jsx(pt,{className:"font-mono text-xs text-neutral-300",children:UX(c)})]},`${c.operationId}:${c.createdAt}:${f}`))})]})})})}function GX(){const[e,t]=va("console:alert-config",IX),n={p90Latency:e.latencyThresholdMs,errorRate:e.errorRateThreshold,clientLag:e.clientLagThreshold},s=a=>{t(c=>({...c,latencyThresholdMs:a.p90Latency,errorRateThreshold:a.errorRate,clientLagThreshold:a.clientLag}))},i=a=>{t(c=>({...c,enabled:a}))};return h.jsx(qj,{enabled:e.enabled,onEnabledChange:i,thresholds:n,onThresholdsChange:s})}function ZX(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 YX(e){const t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function XX(){const[e,t]=_.useState(""),[n,s]=_.useState(void 0),[i,a]=_.useState(void 0),[c,f]=_.useState([]),[d,p]=_.useState(null),{data:g,isLoading:y,error:b}=QY({prefix:n,cursor:i,limit:100}),x=WY(),S=JY();function w(){const k=e.trim();s(k.length>0?k:void 0),a(void 0),f([])}function T(){t(""),s(void 0),a(void 0),f([])}function C(){g?.cursor&&(f(k=>[...k,i??""]),a(g.cursor))}function A(){f(k=>{const L=[...k],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(Dt,{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(Jb,{title:"Storage",actions:h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Hn,{placeholder:"Prefix filter...",value:e,onChange:k=>t(k.target.value),onKeyDown:k=>{k.key==="Enter"&&w()},className:"h-7 w-48 text-xs"}),h.jsx(Me,{variant:"default",size:"sm",onClick:w,children:"Filter"}),n&&h.jsx(Me,{variant:"ghost",size:"sm",onClick:T,children:"Clear"})]}),children:R.length===0?h.jsx(Qb,{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(Jl,{children:[h.jsx(ec,{children:h.jsxs(ts,{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(tc,{children:R.map(k=>h.jsxs(ts,{children:[h.jsx(pt,{className:"font-mono text-xs max-w-[320px]",title:k.key,children:k.key}),h.jsx(pt,{className:"font-mono text-xs text-neutral-400 whitespace-nowrap",children:ZX(k.size)}),h.jsx(pt,{children:k.httpMetadata?.contentType?h.jsx(dn,{variant:"ghost",children:k.httpMetadata.contentType}):h.jsx("span",{className:"text-neutral-500 text-xs",children:"--"})}),h.jsx(pt,{className:"whitespace-nowrap text-xs text-neutral-400",children:YX(k.uploaded)}),h.jsx(pt,{children:h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{S(k.key)},children:"Download"}),h.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>p(k.key),children:"Delete"})]})})]},k.key))})]})}),h.jsxs("div",{className:"flex items-center justify-between px-2 py-2",children:[h.jsx(Me,{variant:"ghost",size:"sm",disabled:c.length===0,onClick:A,children:"Previous"}),h.jsx(Me,{variant:"ghost",size:"sm",disabled:!g?.truncated,onClick:C,children:"Next"})]})]})}),h.jsx(Dr,{open:d!==null,onOpenChange:()=>p(null),children:h.jsxs(lr,{children:[h.jsx(cr,{children:h.jsx(ur,{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(Tn,{children:[h.jsx(Me,{variant:"default",onClick:()=>p(null),children:"Cancel"}),h.jsx(Me,{variant:"destructive",onClick:N,disabled:x.isPending,children:x.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Dt,{size:"sm"})," Deleting..."]}):"Delete"})]})]})})]})}const QX={};function su(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 WX(e){const t=e.split(/\s+/).map(i=>i.trim()).filter(i=>i.length>0),n={},s=[];for(const i of t){const[a="",...c]=i.split(":"),f=c.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 JX(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 Hd(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function eQ(e,t){return e?`#${e.federatedCommitId??(t?`${t}:${e.commitSeq}`:String(e.commitSeq))}`:"#?"}function tQ(e,t){return e?`E${e.federatedEventId??(t?`${t}:${e.eventId}`:e.eventId)}`:"E?"}function nQ(e,t,n){return!e||!t?null:e.replaceAll("{traceId}",encodeURIComponent(t)).replaceAll("{spanId}",encodeURIComponent(n??""))}function bx({initialSelectedEntryId:e}={}){const{preferences:t}=tf(),{partitionId:n}=ef(),{range:s,setRange:i}=SO(),a=t.pageSize,c=t.refreshInterval*1e3,f=QX?.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),[A,N]=_.useState(!1),[R,k]=_.useState(e??null),L=_.useRef(!1),j=_.useMemo(()=>WX(S),[S]),O=_.useMemo(()=>new Date(Date.now()-JX(s)).toISOString(),[s]),{data:D,isLoading:K,refetch:F}=IY({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:O},{refetchIntervalMs:c}),z=$Y(),X=R?.startsWith("#")?R.slice(1):void 0,Y=R?.startsWith("E")?R.slice(1):void 0,te=X&&X!=="?"?X:void 0,P=Y&&Y!=="?"?Y:void 0,{data:V,isLoading:B,error:q}=kY(te,{enabled:te!==void 0,partitionId:n}),{data:U,isLoading:I,error:G}=DY(P,{enabled:P!==void 0,partitionId:n}),{data:W,isLoading:Q,error:se}=PY(P,{enabled:P!==void 0&&!!U?.payloadRef,partitionId:n}),oe=_.useMemo(()=>nQ(f,U?.traceId??null,U?.spanId??null),[U?.spanId,U?.traceId,f]);_.useEffect(()=>{C(1)},[]),_.useEffect(()=>{C(1)},[]),_.useEffect(()=>{e&&k(e)},[e]),_.useEffect(()=>{if(!L.current){L.current=!0;return}k(null)},[]),_.useEffect(()=>{C(1),k(null)},[]);const Se=_.useMemo(()=>(D?.items??[]).map(_e=>{const ve=_e.instanceId??_e.commit?.instanceId??_e.event?.instanceId,xe=ve?`[${ve}] `:"";if(_e.type==="commit"&&_e.commit){const Le=_e.commit;return{type:"commit",id:eQ(Le,ve),outcome:"--",duration:"--",actor:Le.actorId,client:Le.clientId,detail:`${xe}${Le.changeCount} chg | ${(Le.affectedTables??[]).join(", ")}`,time:su(_e.timestamp,t.timeFormat)}}const ye=_e.event;return ye?{type:ye.eventType,id:tQ(ye,ve),outcome:ye.outcome,duration:`${ye.durationMs}ms`,actor:ye.actorId,client:ye.clientId,detail:`${xe}${(ye.tables??[]).join(", ")||"--"}`,time:su(_e.timestamp,t.timeFormat)}:{type:"pull",id:"E?",outcome:"unknown",duration:"--",actor:"",client:"",detail:"--",time:su(_e.timestamp,t.timeFormat)}}),[t.timeFormat,D?.items]),he=D?.total??0,He=Math.max(1,Math.ceil(he/a)),Ee=K,re=[{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 de(){z.mutate(void 0,{onSuccess:()=>{N(!1),F()}})}return h.jsxs("div",{className:"flex flex-col h-full",children:[Ee&&Se.length===0?h.jsx("div",{className:"flex items-center justify-center py-24",children:h.jsx(Dt,{size:"lg"})}):h.jsx(rA,{entries:Se,selectedEntryId:R,onEntryClick:ae=>k(ae.id),filterBar:h.jsx(Yj,{groups:re,searchValue:S,searchPlaceholder:"Use actor:, client:, table:, request:, trace: or free text...",onSearchChange:w,actions:h.jsxs(h.Fragment,{children:[h.jsx(Me,{size:"sm",variant:"ghost",onClick:()=>{F()},children:"Refresh"}),h.jsx(Me,{size:"sm",variant:"ghost",children:"Export"}),h.jsx(Me,{size:"sm",variant:"destructive",onClick:()=>N(!0),children:"Clear"})]})}),pagination:h.jsx(mx,{page:T,totalPages:He,totalItems:he,onPageChange:C})}),h.jsx(Dr,{open:R!==null,onOpenChange:ae=>{ae||k(null)},children:h.jsxs(lr,{children:[h.jsx(cr,{children:h.jsx(ur,{children:te!==void 0?`Commit #${te}`:P!==void 0?`Event E${P}`:"Entry details"})}),h.jsx("div",{className:"px-5 py-4 space-y-3 max-h-[70vh] overflow-y-auto",children:B||I?h.jsx("div",{className:"flex items-center justify-center py-8",children:h.jsx(Dt,{size:"sm"})}):q||G?h.jsx("p",{className:"font-mono text-[11px] text-offline",children:"Failed to load details."}):V?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:V.actorId})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Client"}),h.jsx("div",{className:"text-neutral-100",children:V.clientId})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Instance"}),h.jsx("div",{className:"text-neutral-100",children:V.instanceId??"--"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Created"}),h.jsx("div",{className:"text-neutral-100",children:su(V.createdAt,t.timeFormat)})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Changes"}),h.jsx("div",{className:"text-neutral-100",children:V.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:V.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"}),V.changes.length===0?h.jsx("p",{className:"font-mono text-[11px] text-neutral-500",children:"No changes recorded."}):V.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:Hd(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??"--"}),oe&&h.jsx("a",{href:oe,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(Me,{variant:"ghost",size:"sm",onClick:()=>k(`#${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:su(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:Hd(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"}),Q?h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Dt,{size:"sm"}),h.jsx("span",{className:"font-mono text-[11px] text-neutral-400",children:"Loading payload snapshot..."})]}):se?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:Hd(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:Hd(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(Tn,{children:h.jsx(Me,{variant:"default",size:"sm",onClick:()=>k(null),children:"Close"})})]})}),h.jsx(Dr,{open:A,onOpenChange:ae=>{ae||N(!1)},children:h.jsxs(lr,{children:[h.jsx(cr,{children:h.jsx(ur,{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(Tn,{children:[h.jsx(Me,{variant:"default",size:"sm",onClick:()=>N(!1),children:"Cancel"}),h.jsx(Me,{variant:"destructive",size:"sm",onClick:de,disabled:z.isPending,children:z.isPending?"Clearing...":"Clear all"})]})]})})]})}const rQ=so({getParentRoute:()=>io,path:"/config",component:SX}),sQ=so({getParentRoute:()=>io,path:"/fleet",component:kX}),oQ=so({getParentRoute:()=>io,path:"/",component:xX});function iQ(){const{seq:e}=_O.useParams();return h.jsx(bx,{initialSelectedEntryId:`#${e}`})}const _O=so({getParentRoute:()=>io,path:"/investigate/commit/$seq",component:iQ});function aQ(){const{id:e}=wO.useParams();return h.jsx(bx,{initialSelectedEntryId:`E${e}`})}const wO=so({getParentRoute:()=>io,path:"/investigate/event/$id",component:aQ}),lQ=so({getParentRoute:()=>io,path:"/ops",component:BX}),cQ=so({getParentRoute:()=>io,path:"/storage",component:XX}),uQ=so({getParentRoute:()=>io,path:"/stream",component:bx}),fQ=io.addChildren([oQ,uQ,_O,wO,sQ,lQ,cQ,rQ]),dQ="syncular-console-basepath",hQ="syncular-console-server-url",pQ="syncular-console-token";function mQ(e){if(!e)return;const t=e.trim();return t.length>0?t:void 0}function $v(e){const t=globalThis.document;if(!t)return;const n=t.querySelector(`meta[name="${e}"]`)?.getAttribute("content");return mQ(n)}function EO(e){return!e||e==="/"?"/":(e.startsWith("/")?e:`/${e}`).replace(/\/+$/g,"")||"/"}function gQ(){return EO($v(dQ))}function yQ(){const e=$v(hQ),t=$v(pQ);return!e||!t?null:{serverUrl:e,token:t}}function vQ(){return new z6({defaultOptions:{queries:{staleTime:5e3,retry:1}}})}function bQ(e){return EO(e??gQ())}function xQ(e){const[t]=_.useState(()=>vQ()),n=_.useMemo(()=>qH({routeTree:fQ,basepath:bQ(e.basePath)}),[e.basePath]),s=e.defaultConfig===void 0?yQ():e.defaultConfig,i=e.autoConnect??e.defaultConfig===void 0;return h.jsx(L6,{client:t,children:h.jsx(oq,{defaultConfig:s,autoConnect:i,storageMode:e.storageMode,children:h.jsx(GH,{router:n})})})}function SQ(e){return h.jsx("div",{className:vx,children:h.jsx(xQ,{...e})})}function _Q(e){const t=document.querySelector(e);if(!t)throw new Error(`Unable to mount console: ${e} not found`);return t}function wQ(e,t={}){const n=_Q(e);rX(n);const s=h6.createRoot(n),i=h.jsx(SQ,{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 EQ={};const TQ="syncular-sentry-dsn",CQ="syncular-sentry-environment",RQ="syncular-sentry-release";function hu(e){if(!e)return;const t=e.trim();return t.length>0?t:void 0}function $y(e){if(typeof document>"u")return;const t=document.querySelector(`meta[name="${e}"]`)?.getAttribute("content");return hu(t)}function By(e){if(!(typeof process>"u"))return hu(EQ[e])}function Fy(e){for(const t of e)if(t)return t}function NQ(){const e=Fy([hu(globalThis.__SYNCULAR_SENTRY_DSN__),$y(TQ),By("SYNCULAR_SENTRY_DSN")]);if(!e)return null;const t=Fy([hu(globalThis.__SYNCULAR_SENTRY_ENVIRONMENT__),$y(CQ),By("SYNCULAR_SENTRY_ENVIRONMENT")]),n=Fy([hu(globalThis.__SYNCULAR_SENTRY_RELEASE__),$y(RQ),By("SYNCULAR_SENTRY_RELEASE")]);return{dsn:e,environment:t,release:n,enableLogs:!0,tracesSampleRate:.2,tracePropagationTargets:[/^https?:\/\/.*\/api\/.*/]}}const JC=NQ();JC&&s6(JC);wQ("#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 Zh(e,t){e&&Object.assign(e.style,t)}const QG={position:"relative",maxHeight:"100%",overflowX:"hidden",overflowY:"auto"},WG={position:"fixed"},JG=_.forwardRef(function(t,n){const{anchor:s,positionMethod:i="absolute",className:a,render:c,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=r8,...A}=t,{store:N,listRef:R,labelsRef:k,alignItemWithTriggerActiveRef:L,selectedItemTextRef:j,valuesRef:O,initialValueRef:D,popupRef:K,setValue:F}=Yu(),z=KA(),X=at(N,it.open),Y=at(N,it.mounted),te=at(N,it.modal),P=at(N,it.value),V=at(N,it.openMethod),B=at(N,it.positionerElement),q=at(N,it.triggerElement),U=at(N,it.isItemEqualToValue),I=at(N,it.transitionStatus),G=_.useRef(null),W=_.useRef(null),[Q,se]=_.useState(T),oe=Y&&Q&&V!=="touch";!Y&&Q!==T&&se(T),ze(()=>{Y||(it.scrollUpArrowVisible(N.state)&&N.set("scrollUpArrowVisible",!1),it.scrollDownArrowVisible(N.state)&&N.set("scrollDownArrowVisible",!1))},[N,Y]),_.useImperativeHandle(L,()=>oe),GA((oe||te)&&X&&V!=="touch",q);const pe=FA({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??oe,collisionAvoidance:C,keepMounted:!0}),Se=oe?"none":pe.side,he=oe?WG:pe.positionerStyles,He=_.useMemo(()=>{const xe={};return X||(xe.pointerEvents="none"),{role:"presentation",hidden:!Y,style:{...he,...xe}}},[X,Y,he]),Ee={open:X,side:Se,align:pe.align,anchorHidden:pe.anchorHidden},re=Ae(xe=>{N.set("positionerElement",xe)}),de=Pt("div",t,{ref:[n,re],state:Ee,stateAttributesMapping:rc,props:[He,Cp(I),A]}),ae=_.useRef(0),_e=Ae(xe=>{if(xe.size===0&&ae.current===0||O.current.length===0)return;const ye=ae.current;if(ae.current=xe.size,xe.size===ye)return;const Le=Kt(ri);if(ye!==0&&!N.state.multiple&&P!==null&&Py(O.current,P,U)===-1){const we=D.current,Xe=we!=null&&Py(O.current,we,U)!==-1?we:null;F(Xe,Le),Xe===null&&(N.set("selectedIndex",null),j.current=null)}if(ye!==0&&N.state.multiple&&Array.isArray(P)){const ke=Ve=>Py(O.current,Ve,U)!==-1,we=P.filter(Ve=>ke(Ve));(we.length!==P.length||we.some(Ve=>!RG(P,Ve,U)))&&(F(we,Le),we.length===0&&(N.set("selectedIndex",null),j.current=null))}if(X&&oe){N.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});const ke={height:""};Zh(B,ke),Zh(K.current,ke)}}),ve=_.useMemo(()=>({...pe,side:Se,alignItemWithTriggerActive:oe,setControlledAlignItemWithTrigger:se,scrollUpArrowRef:G,scrollDownArrowRef:W}),[pe,Se,oe,se]);return h.jsx(YA,{elementsRef:R,labelsRef:k,onMapChange:_e,children:h.jsxs(XA.Provider,{value:ve,children:[Y&&te&&h.jsx(QA,{inert:dx(!X),cutout:q}),de]})})});function WA(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 Bd="base-ui-disable-scrollbar",UC={className:Bd,getElement(e){return h.jsx("style",{nonce:e,href:Bd,precedence:"base-ui:low",children:`.${Bd}{scrollbar-width:none}.${Bd}::-webkit-scrollbar{display:none}`})}},eZ=_.createContext(void 0);function JA(e){return _.useContext(eZ)}const Sl="ArrowUp",Zi="ArrowDown",Nu="ArrowLeft",_l="ArrowRight",Xu="Home",Qu="End",eO=new Set([Nu,_l]),tZ=new Set([Nu,_l,Xu,Qu]),tO=new Set([Sl,Zi]),nZ=new Set([Sl,Zi,Xu,Qu]),nO=new Set([...eO,...tO]),rZ=new Set([...nO,Xu,Qu]),rO=new Set([Sl,Zi,Nu,_l,Xu,Qu]),sZ="Shift",oZ="Control",iZ="Alt",aZ="Meta",lZ=new Set([sZ,oZ,iZ,aZ]);function cZ(e){return Vt(e)&&e.tagName==="INPUT"}function $C(e){return!!(cZ(e)&&e.selectionStart!=null||Vt(e)&&e.tagName==="TEXTAREA")}function BC(e,t,n,s){if(!e||!t||!t.scrollTo)return;let i=e.scrollLeft,a=e.scrollTop;const c=e.clientWidth<e.scrollWidth,f=e.clientHeight<e.scrollHeight;if(c&&s!=="vertical"){const d=FC(e,t,"left"),p=Fd(e),g=Fd(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=Fd(e),g=Fd(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 Fd(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 zy(e,t=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(t,Math.min(e,n))}const uZ=_.createContext(void 0),fZ={disableStyleElements:!1};function dZ(){return _.useContext(uZ)??fZ}const Bi=1,hZ={...rc,...ga},pZ=_.forwardRef(function(t,n){const{render:s,className:i,finalFocus:a,...c}=t,{store:f,popupRef:d,onOpenChangeComplete:p,setOpen:g,valueRef:y,selectedItemTextRef:b,keyboardActiveRef:x,multiple:S,handleScrollArrowVisibility:w,scrollHandlerRef:T,highlightItemOnHover:C}=Yu(),{side:A,align:N,alignItemWithTriggerActive:R,setControlledAlignItemWithTrigger:k,scrollDownArrowRef:L,scrollUpArrowRef:j}=XG(),O=JA()!=null,D=KA(),{nonce:K,disableStyleElements:F}=dZ(),z=Jr(),X=at(f,it.id),Y=at(f,it.open),te=at(f,it.mounted),P=at(f,it.popupProps),V=at(f,it.transitionStatus),B=at(f,it.triggerElement),q=at(f,it.positionerElement),U=at(f,it.listElement),I=_.useRef(0),G=_.useRef(!1),W=_.useRef(0),Q=_.useRef(!1),se=_.useRef({}),oe=ix(),pe=Ae(Ee=>{if(!q||!d.current||!Q.current)return;if(G.current||!R){w();return}const re=q.style.top==="0px",de=q.style.bottom==="0px",ae=q.getBoundingClientRect().height,_e=Rt(q),ve=getComputedStyle(q),xe=parseFloat(ve.marginTop),ye=parseFloat(ve.marginBottom),Le=HC(getComputedStyle(d.current)),ke=Math.min(_e.documentElement.clientHeight-xe-ye,Le),we=Ee.scrollTop,Ve=qC(Ee);let Xe=0,$e=null,We=!1,Fe=!1;const me=qe=>{q.style.height=`${qe}px`},Te=(qe,mt)=>{const ct=zy(qe,0,ke-ae);ct>0&&me(ae+ct),Ee.scrollTop=mt,ke-(ae+ct)<=Bi&&(G.current=!0),w()};if(re){const qe=Ve-we,mt=ae+qe,ct=Math.min(mt,ke);if(Xe=ct,qe<=Bi){Te(qe,Ve);return}ke-ct>Bi?Fe=!0:We=!0}else if(de){const qe=we,mt=ae+qe,ct=Math.min(mt,ke),br=mt-ke;if(Xe=ct,qe<=Bi){Te(qe,0);return}ke-ct>Bi?$e=0:(We=!0,we<Ve&&($e=we-(qe-br)))}if(Xe=Math.ceil(Xe),Xe!==0&&me(Xe),Fe||$e!=null){const qe=qC(Ee),mt=Fe?qe:zy($e,0,qe);Math.abs(Ee.scrollTop-mt)>Bi&&(Ee.scrollTop=mt)}(We||Xe>=ke-Bi)&&(G.current=!0),w()});_.useImperativeHandle(T,()=>pe,[pe]),ya({open:Y,ref:d,onComplete(){Y&&p?.(!0)}});const Se={open:Y,transitionStatus:V,side:A,align:N};ze(()=>{!q||!d.current||Object.keys(se.current).length||(se.current={top:q.style.top||"0",left:q.style.left||"0",right:q.style.right,height:q.style.height,bottom:q.style.bottom,minHeight:q.style.minHeight,maxHeight:q.style.maxHeight,marginTop:q.style.marginTop,marginBottom:q.style.marginBottom})},[d,q]),ze(()=>{Y||R||(Q.current=!1,G.current=!1,I.current=0,W.current=0,Zh(q,se.current))},[Y,R,q,d]),ze(()=>{const Ee=d.current;if(!(!Y||!B||!q||!Ee||f.state.transitionStatus==="ending")){if(!R){Q.current=!0,oe.request(w),Ee.style.removeProperty("--transform-origin");return}queueMicrotask(()=>{const re=mZ(Ee);Ee.style.removeProperty("--transform-origin");try{const de=getComputedStyle(q),ae=getComputedStyle(Ee),_e=Rt(B),ve=an(q),xe=B.getBoundingClientRect(),ye=q.getBoundingClientRect(),Le=xe.left,ke=xe.height,we=U||Ee,Ve=we.scrollHeight,Xe=parseFloat(ae.borderBottomWidth),$e=parseFloat(de.marginTop)||10,We=parseFloat(de.marginBottom)||10,Fe=parseFloat(de.minHeight)||100,me=HC(ae),Te=5,qe=5,mt=20,ct=_e.documentElement.clientHeight-$e-We,br=_e.documentElement.clientWidth,xr=ct-xe.bottom+ke,Zt=b.current,ut=y.current;let xt,ot=0,Yt=0;if(Zt&&ut){const Xn=ut.getBoundingClientRect();xt=Zt.getBoundingClientRect();const is=Xn.left-Le,ao=xt.left-ye.left,lo=Xn.top-xe.top+Xn.height/2,Qn=xt.top-ye.top+xt.height/2;ot=is-ao,Yt=Qn-lo}const mn=xr+Yt+We+Xe;let Ot=Math.min(ct,mn);const wn=ct-$e-We,Yn=mn-Ot,Rn=Math.max(Te,Le+ot),ss=br-qe,os=Math.max(0,Rn+ye.width-ss);q.style.left=`${Rn-os}px`,q.style.height=`${Ot}px`,q.style.maxHeight="auto",q.style.marginTop=`${$e}px`,q.style.marginBottom=`${We}px`,Ee.style.height="100%";const ba=we.scrollHeight-we.clientHeight,bi=Yn>=ba;bi&&(Ot=Math.min(ct,ye.height)-(Yn-ba));const xi=xe.top<mt||xe.bottom>ct-mt||Ot<Math.min(Ve,Fe),xs=(ve.visualViewport?.scale??1)!==1&&nx;if(xi||xs){Q.current=!0,Zh(q,se.current),ui.flushSync(()=>k(!1));return}if(bi){const Xn=Math.max(0,ct-mn);q.style.top=ye.height>=wn?"0":`${Xn}px`,q.style.height=`${Ot}px`,we.scrollTop=we.scrollHeight-we.clientHeight,I.current=Math.max(Fe,Ot)}else q.style.bottom="0",I.current=Math.max(Fe,Ot),we.scrollTop=Yn;if(xt){const Xn=ye.top,is=ye.height,ao=xt.top+xt.height/2,lo=is>0?(ao-Xn)/is*100:50,Qn=zy(lo,0,100);Ee.style.setProperty("--transform-origin",`50% ${Qn}%`)}(I.current===ct||Ot>=me)&&(G.current=!0),w(),setTimeout(()=>{Q.current=!0})}finally{re()}})}},[f,Y,q,B,y,b,d,w,R,k,oe,L,j,U]),_.useEffect(()=>{if(!R||!q||!Y)return;const Ee=an(q);function re(de){g(!1,Kt(N8,de))}return Ee.addEventListener("resize",re),()=>{Ee.removeEventListener("resize",re)}},[g,R,q,Y]);const he={...U?{role:"presentation","aria-orientation":void 0}:{role:"listbox","aria-multiselectable":S||void 0,id:`${X}-list`},onKeyDown(Ee){x.current=!0,O&&rO.has(Ee.key)&&Ee.stopPropagation()},onMouseMove(){x.current=!1},onPointerLeave(Ee){if(!C||WA(Ee)||Ee.pointerType==="touch")return;const re=Ee.currentTarget;z.start(0,()=>{f.set("activeIndex",null),re.focus({preventScroll:!0})})},onScroll(Ee){U||pe(Ee.currentTarget)},...R&&{style:U?{height:"100%"}:QG}},He=Pt("div",t,{ref:[n,d],state:Se,stateAttributesMapping:hZ,props:[P,he,Cp(V),{className:!U&&R?UC.className:void 0},c]});return h.jsxs(_.Fragment,{children:[!F&&UC.getElement(K),h.jsx(NA,{context:D,modal:!1,disabled:!te,returnFocus:a,restoreFocus:!0,children:He})]})});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 mZ(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 sO=(function(e){return e[e.None=0]="None",e[e.GuessFromOrder=1]="GuessFromOrder",e})({});function hx(e={}){const{label:t,metadata:n,textRef:s,indexGuessBehavior:i,index:a}=e,{register:c,unregister:f,subscribeMapChange:d,elementsRef:p,labelsRef:g,nextIndexRef:y}=KG(),b=_.useRef(-1),[x,S]=_.useState(a??(i===sO.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 A=t!==void 0;g.current[x]=A?t:s?.current?.textContent??C.textContent}},[x,p,g,t,s]);return ze(()=>{if(a!=null)return;const C=w.current;if(C)return c(C,n),()=>{f(C)}},[a,c,f,n]),ze(()=>{if(a==null)return d(C=>{const A=w.current?C.get(w.current)?.index:null;A!=null&&S(A)})},[a,d,S]),_.useMemo(()=>({ref:T,index:x}),[x,T])}const gZ=_.createContext(void 0),yZ=_.memo(_.forwardRef(function(t,n){const{render:s,className:i,value:a=null,label:c,disabled:f=!1,nativeButton:d=!1,...p}=t,g=_.useRef(null),y=hx({label:c,textRef:g,indexGuessBehavior:sO.GuessFromOrder}),{store:b,getItemProps:x,setOpen:S,setValue:w,selectionRef:T,typingRef:C,valuesRef:A,keyboardActiveRef:N,multiple:R,highlightItemOnHover:k}=Yu(),L=Jr(),j=at(b,it.isActive,y.index),O=at(b,it.isSelected,y.index,a),D=at(b,it.isSelectedByFocus,y.index),K=at(b,it.isItemEqualToValue),F=y.index,z=F!==-1,X=_.useRef(null),Y=Xo(F);ze(()=>{if(!z)return;const oe=A.current;return oe[F]=a,()=>{delete oe[F]}},[z,F,a,A]),ze(()=>{if(!z)return;const oe=b.state.value;let pe=oe;R&&Array.isArray(oe)&&oe.length>0&&(pe=oe[oe.length-1]),pe!==void 0&&Ll(a,pe,K)&&b.set("selectedIndex",F)},[z,F,R,K,b,a]);const te={disabled:f,selected:O,highlighted:j},P=x({active:j,selected:O});P.onFocus=void 0,P.id=void 0;const V=_.useRef(null),B=_.useRef("mouse"),q=_.useRef(!1),{getButtonProps:U,buttonRef:I}=Ql({disabled:f,focusableWhenDisabled:!0,native:d});function G(oe){const pe=b.state.value;if(R){const Se=Array.isArray(pe)?pe:[],he=O?NG(Se,a,K):[...Se,a];w(he,Kt(Ty,oe))}else w(a,Kt(Ty,oe)),S(!1,Kt(Ty,oe))}const W={role:"option","aria-selected":O,tabIndex:j?0:-1,onFocus(){b.set("activeIndex",F)},onMouseEnter(){!N.current&&b.state.selectedIndex===null&&k&&b.set("activeIndex",F)},onMouseMove(){k&&b.set("activeIndex",F)},onMouseLeave(oe){!k||N.current||WA(oe)||L.start(0,()=>{b.state.activeIndex===F&&b.set("activeIndex",null)})},onTouchStart(){T.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1}},onKeyDown(oe){V.current=oe.key,b.set("activeIndex",F)},onClick(oe){q.current=!1,!(oe.type==="keydown"&&V.current===null)&&(f||V.current===" "&&C.current||B.current!=="touch"&&!j||(V.current=null,G(oe.nativeEvent)))},onPointerEnter(oe){B.current=oe.pointerType},onPointerDown(oe){B.current=oe.pointerType,q.current=!0},onMouseUp(oe){if(f)return;if(q.current){q.current=!1;return}const pe=!T.current.allowSelectedMouseUp&&O,Se=!T.current.allowUnselectedMouseUp&&!O;pe||Se||B.current!=="touch"&&!j||G(oe.nativeEvent)}},Q=Pt("div",t,{ref:[I,n,y.ref,X],state:te,props:[P,W,p,U]}),se=_.useMemo(()=>({selected:O,indexRef:Y,textRef:g,selectedByFocus:D,hasRegistered:z}),[O,Y,g,D,z]);return h.jsx(gZ.Provider,{value:se,children:Q})})),vZ=_.forwardRef(({className:e,children:t,...n},s)=>h.jsx(zG,{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}));vZ.displayName="SelectTrigger";const bZ=_.forwardRef(({className:e,portalProps:t,positionerProps:n,...s},i)=>h.jsx(UG,{...t,children:h.jsx(JG,{...n,children:h.jsx(pZ,{ref:i,className:ge("bg-panel border border-border rounded-md py-1 shadow-lg z-50",e),...s})})}));bZ.displayName="SelectContent";const xZ=_.forwardRef(({className:e,...t},n)=>h.jsx(yZ,{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}));xZ.displayName="SelectItem";const SZ=_.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}));SZ.displayName="Textarea";const oO=_.createContext(void 0);function _Z(e=!0){const t=_.useContext(oO);if(t===void 0&&!e)throw new Error(pn(7));return t}function iO(e={}){const{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:s}=Ij(),{ref:i,index:a}=hx(e),c=n===a,f=_.useRef(null),d=to(i,f);return{compositeProps:_.useMemo(()=>({tabIndex:c?0:-1,onFocus(){s(a)},onMouseMove(){const g=f.current;if(!t||!g)return;const y=g.hasAttribute("disabled")||g.ariaDisabled==="true";!c&&!y&&g.focus()}}),[c,s,a,t]),compositeRef:d,index:a}}function wZ(e){const{render:t,className:n,state:s=rn,props:i=Tu,refs:a=Tu,metadata:c,stateAttributesMapping:f,tag:d="div",...p}=e,{compositeProps:g,compositeRef:y}=iO({metadata:c});return Pt(d,e,{state:s,ref:[...a,y],props:[g,...i,p],stateAttributesMapping:f})}const EZ=_.forwardRef(function(t,n){const{className:s,defaultPressed:i=!1,disabled:a=!1,form:c,onPressedChange:f,pressed:d,render:p,type:g,value:y,nativeButton:b=!0,...x}=t,S=pr(y||void 0),w=_Z(),T=w?.value??[],C=w?void 0:i,A=(a||w?.disabled)??!1,[N,R]=dp({controlled:w?S!==void 0&&T.indexOf(S)>-1:d,default:C,name:"Toggle",state:"pressed"}),k=Ae((z,X)=>{S&&w?.setGroupValue?.(S,z,X),f?.(z,X)}),{getButtonProps:L,buttonRef:j}=Ql({disabled:A,native:b}),O={disabled:A,pressed:N},D=[j,n],K=[{"aria-pressed":N,onClick(z){const X=!N,Y=Kt(ri,z.nativeEvent);k(X,Y),!Y.isCanceled&&R(X)}},x,L],F=Pt("button",t,{enabled:!w,state:O,ref:D,props:K});return w?h.jsx(wZ,{tag:"button",render:p,className:s,state:O,refs:D,props:K}):F}),aO=_.forwardRef(({className:e,...t},n)=>h.jsx(EZ,{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}));aO.displayName="Toggle";function TZ(e){return e==null||e.hasAttribute("disabled")||e.getAttribute("aria-disabled")==="true"}const lO="data-composite-item-active",CZ=[];function RZ(e){const{itemSizes:t,cols:n=1,loopFocus:s=!0,dense:i=!1,orientation:a="both",direction:c,highlightedIndex:f,onHighlightedIndexChange:d,rootRef:p,enableHomeAndEndKeys:g=!1,stopEventPropagation:y=!1,disabledIndices:b,modifierKeys:x=CZ}=e,[S,w]=_.useState(0),T=n>1,C=_.useRef(null),A=to(C,p),N=_.useRef([]),R=_.useRef(!1),k=f??S,L=Ae((D,K=!1)=>{if((d??w)(D),K){const F=N.current[D];BC(C.current,F,c,a)}}),j=Ae(D=>{if(D.size===0||R.current)return;R.current=!0;const K=Array.from(D.keys()),F=K.find(X=>X?.hasAttribute(lO))??null,z=F?K.indexOf(F):-1;z!==-1&&L(z),BC(C.current,F,c,a)}),O=_.useMemo(()=>({"aria-orientation":a==="both"?void 0:a,ref:A,onFocus(D){!C.current||!$C(D.target)||D.target.setSelectionRange(0,D.target.value.length??0)},onKeyDown(D){const K=g?rZ:nO;if(!K.has(D.key)||NZ(D,x)||!C.current)return;const z=c==="rtl",X=z?Nu:_l,Y={horizontal:X,vertical:Zi,both:X}[a],te=z?_l:Nu,P={horizontal:te,vertical:Sl,both:te}[a];if($C(D.target)&&!TZ(D.target)){const W=D.target.selectionStart,Q=D.target.selectionEnd,se=D.target.value??"";if(W==null||D.shiftKey||W!==Q||D.key!==P&&W<se.length||D.key!==Y&&W>0)return}let V=k;const B=FV(N,b),q=HV(N,b);if(T){const W=t||Array.from({length:N.current.length},()=>({width:1,height:1})),Q=VV(W,n,i),se=Q.findIndex(pe=>pe!=null&&!fu(N,pe,b)),oe=Q.reduce((pe,Se,he)=>Se!=null&&!fu(N,Se,b)?he:pe,-1);V=Q[qV({current:Q.map(pe=>pe?N.current[pe]:null)},{event:D,orientation:a,loopFocus:s,cols:n,disabledIndices:GV([...b||N.current.map((pe,Se)=>fu(N,Se)?Se:void 0),void 0],Q),minIndex:se,maxIndex:oe,prevIndex:KV(k>q?B:k,W,Q,n,D.key===Zi?"bl":D.key===_l?"tr":"tl"),rtl:z})]}const U={horizontal:[X],vertical:[Zi],both:[X,Zi]}[a],I={horizontal:[te],vertical:[Sl],both:[te,Sl]}[a],G=T?K:{horizontal:g?tZ:eO,vertical:g?nZ:tO,both:K}[a];g&&(D.key===Xu?V=B:D.key===Qu&&(V=q)),V===k&&(U.includes(D.key)||I.includes(D.key))&&(s&&V===q&&U.includes(D.key)?V=B:s&&V===B&&I.includes(D.key)?V=q:V=ir(N,{startingIndex:V,decrement:I.includes(D.key),disabledIndices:b})),V!==k&&!sh(N,V)&&(y&&D.stopPropagation(),G.has(D.key)&&D.preventDefault(),L(V,!0),queueMicrotask(()=>{N.current[V]?.focus()}))}}),[n,i,c,b,N,g,k,T,t,s,A,x,L,a,y]);return _.useMemo(()=>({props:O,highlightedIndex:k,onHighlightedIndexChange:L,elementsRef:N,disabledIndices:b,onMapChange:j,relayKeyboardEvent:O.onKeyDown}),[O,k,L,N,b,j])}function NZ(e,t){for(const n of lZ.values())if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function cO(e){const{render:t,className:n,refs:s=Tu,props:i=Tu,state:a=rn,stateAttributesMapping:c,highlightedIndex:f,onHighlightedIndexChange:d,orientation:p,dense:g,itemSizes:y,loopFocus:b,cols:x,enableHomeAndEndKeys:S,onMapChange:w,stopEventPropagation:T=!0,rootRef:C,disabledIndices:A,modifierKeys:N,highlightItemOnHover:R=!1,tag:k="div",...L}=e,j=$A(),{props:O,highlightedIndex:D,onHighlightedIndexChange:K,elementsRef:F,onMapChange:z,relayKeyboardEvent:X}=RZ({itemSizes:y,cols:x,loopFocus:b,dense:g,orientation:p,highlightedIndex:f,onHighlightedIndexChange:d,rootRef:C,stopEventPropagation:T,enableHomeAndEndKeys:S,direction:j,disabledIndices:A,modifierKeys:N}),Y=Pt(k,e,{state:a,ref:s,props:[O,...i,L],stateAttributesMapping:c}),te=_.useMemo(()=>({highlightedIndex:D,onHighlightedIndexChange:K,highlightItemOnHover:R,relayKeyboardEvent:X}),[D,K,R,X]);return h.jsx(kj.Provider,{value:te,children:h.jsx(YA,{elementsRef:F,onMapChange:P=>{w?.(P),z(P)},children:Y})})}let jZ=(function(e){return e.disabled="data-disabled",e.orientation="data-orientation",e.multiple="data-multiple",e})({});const KC={multiple(e){return e?{[jZ.multiple]:""}:null}},AZ=_.forwardRef(function(t,n){const{defaultValue:s,disabled:i=!1,loopFocus:a=!0,onValueChange:c,orientation:f="horizontal",multiple:d=!1,value:p,className:g,render:y,...b}=t,x=JA(),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,A]=dp({controlled:p,default:S,name:"ToggleGroup",state:"value"}),N=Ae((O,D,K)=>{let F;if(d?(F=C.slice(),D?F.push(O):F.splice(C.indexOf(O),1)):F=D?[O]:[],Array.isArray(F)){if(c?.(F,K),K.isCanceled)return;A(F)}}),R={disabled:T,multiple:d,orientation:f},k=_.useMemo(()=>({disabled:T,orientation:f,setGroupValue:N,value:C,isValueInitialized:w}),[T,f,N,C,w]),L={role:"group"},j=Pt("div",t,{enabled:!!x,state:R,ref:n,props:[L,b],stateAttributesMapping:KC});return h.jsx(oO.Provider,{value:k,children:x?j:h.jsx(cO,{render:y,className:g,state:R,refs:[n],props:[L,b],stateAttributesMapping:KC,loopFocus:a,enableHomeAndEndKeys:!0})})}),lh=_.forwardRef(({className:e,...t},n)=>h.jsx(AZ,{ref:n,className:ge("flex items-center gap-0.5",e),...t}));lh.displayName="ToggleGroup";const OZ=ge(Gj({variant:"secondary",size:"sm"}),"h-7 whitespace-nowrap uppercase tracking-[0.08em] leading-none no-underline");function uO({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 MZ({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 c=a.id===t,f=()=>n?.(a.id);return s?h.jsx("span",{children:s(a,{active:c,onClick:f})},a.id):h.jsx(uO,{active:c,onClick:f,children:a.label},a.id)})})}const kZ=di("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}}),IZ={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 DZ({color:e,size:t,glow:n,pulse:s,className:i}){return h.jsx("span",{className:ge(kZ({color:e,size:t,glow:n}),s&&"dot-pulse",i),style:n?{boxShadow:IZ[e??"healthy"]}:void 0})}const PZ="0.0.6-177",zZ={version:PZ},LZ=zZ.version;function UZ({label:e,className:t}){return h.jsxs("div",{className:ge("flex items-center gap-3",t),children:[h.jsx(DZ,{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",LZ]})]})}function $Z({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 BZ=di("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"}}),On=_.forwardRef(({className:e,variant:t,...n},s)=>h.jsx("div",{ref:s,role:"alert",className:ge(BZ({variant:t,className:e})),...n}));On.displayName="Alert";const Wu=_.forwardRef(({className:e,...t},n)=>h.jsx("h5",{ref:n,className:ge("font-medium text-white mb-1",e),...t}));Wu.displayName="AlertTitle";const Mn=_.forwardRef(({className:e,...t},n)=>h.jsx("p",{ref:n,className:ge("text-neutral-400",e),...t}));Mn.displayName="AlertDescription";const fO=_.createContext(void 0);function sc(e){const t=_.useContext(fO);if(e===!1&&t===void 0)throw new Error(pn(27));return t}const FZ={...rc,...ga},px=_.forwardRef(function(t,n){const{render:s,className:i,forceRender:a=!1,...c}=t,{store:f}=sc(),d=f.useState("open"),p=f.useState("nested"),g=f.useState("mounted"),y=f.useState("transitionStatus");return Pt("div",t,{state:{open:d,transitionStatus:y},ref:[f.context.backdropRef,n],stateAttributesMapping:FZ,props:[{role:"presentation",hidden:!g,style:{userSelect:"none",WebkitUserSelect:"none"}},c],enabled:a||!p})}),dO=_.forwardRef(function(t,n){const{render:s,className:i,id:a,...c}=t,{store:f}=sc(),d=pr(a);return f.useSyncedValueWithCleanup("descriptionElementId",d),Pt("p",t,{ref:n,props:[{id:d},c]})});let HZ=(function(e){return e.nestedDialogs="--nested-dialogs",e})({}),qZ=(function(e){return e[e.open=Gi.open]="open",e[e.closed=Gi.closed]="closed",e[e.startingStyle=Gi.startingStyle]="startingStyle",e[e.endingStyle=Gi.endingStyle]="endingStyle",e.nested="data-nested",e.nestedDialogOpen="data-nested-dialog-open",e})({});const hO=_.createContext(void 0);function VZ(){const e=_.useContext(hO);if(e===void 0)throw new Error(pn(26));return e}const KZ={...rc,...ga,nestedDialogOpen(e){return e?{[qZ.nestedDialogOpen]:""}:null}},pO=_.forwardRef(function(t,n){const{className:s,finalFocus:i,initialFocus:a,render:c,...f}=t,{store:d}=sc(),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"),A=d.useState("openMethod"),N=d.useState("titleElementId"),R=d.useState("transitionStatus"),k=d.useState("role");VZ(),ya({open:C,ref:d.context.popupRef,onComplete(){C&&d.context.onOpenChangeComplete?.(!0)}});function L(F){return F==="touch"?d.context.popupRef.current:!0}const j=a===void 0?L:a,O=T>0,K=Pt("div",t,{state:{open:C,nested:w,transitionStatus:R,nestedDialogOpen:O},props:[b,{"aria-labelledby":N??void 0,"aria-describedby":p??void 0,role:k,tabIndex:-1,hidden:!S,onKeyDown(F){rO.has(F.key)&&F.stopPropagation()},style:{[HZ.nestedDialogs]:T}},f],ref:[n,d.context.popupRef,d.useStateSetter("popupElement")],stateAttributesMapping:KZ});return h.jsx(NA,{context:y,openInteractionType:A,disabled:!S,closeOnFocusOut:!g,initialFocus:j,returnFocus:i,modal:x!==!1,restoreFocus:"popup",children:K})}),mO=_.forwardRef(function(t,n){const{keepMounted:s=!1,...i}=t,{store:a}=sc(),c=a.useState("mounted"),f=a.useState("modal"),d=a.useState("open");return c||s?h.jsx(hO.Provider,{value:s,children:h.jsxs(RA,{ref:n,...i,children:[c&&f===!0&&h.jsx(QA,{ref:a.context.internalBackdropRef,inert:dx(!d)}),t.children]})}):null});function GZ(e){const{store:t,parentContext:n,actionsRef:s}=e,i=t.useState("open"),a=t.useState("disablePointerDismissal"),c=t.useState("modal"),f=t.useState("popupElement"),{openMethod:d,triggerProps:p,reset:g}=kG(i);wK(t);const{forceUnmount:y}=EK(i,t,()=>{g()}),b=Ae(K=>{const F=Kt(K);return F.preventUnmountOnClose=()=>{t.set("preventUnmountingOnClose",!0)},F}),x=_.useCallback(()=>{t.setOpen(!1,b(R8))},[t,b]);_.useImperativeHandle(s,()=>({unmount:y,close:x}),[y,x]);const S=AK({popupStore:t,onOpenChange:t.setOpen,treatPopupAsFloatingElement:!0,noEmit:!0}),[w,T]=_.useState(0),C=w===0,A=UK(S),N=fK(S,{outsidePressEvent(){return t.context.internalBackdropRef.current||t.context.backdropRef.current?"intentional":{mouse:c==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}},outsidePress(K){if(!t.context.outsidePressEnabledRef.current||"button"in K&&K.button!==0||"touches"in K&&K.touches.length!==1)return!1;const F=Ir(K);if(C&&!a){const z=F;return c&&(t.context.internalBackdropRef.current||t.context.backdropRef.current)?t.context.internalBackdropRef.current===z||t.context.backdropRef.current===z||Mt(z,f)&&!z?.hasAttribute("data-base-ui-portal"):!0}return!1},escapeKey:C});GA(i&&c===!0,f);const{getReferenceProps:R,getFloatingProps:k,getTriggerProps:L}=zK([A,N]);t.useContextCallback("onNestedDialogOpen",K=>{T(K+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]),O=_.useMemo(()=>L(p),[L,p]),D=_.useMemo(()=>k(),[k]);t.useSyncedValues({openMethod:d,activeTriggerProps:j,inactiveTriggerProps:O,popupProps:D,floatingRootContext:S,nestedOpenDialogCount:w})}const ZZ={...RK,modal:Ie(e=>e.modal),nested:Ie(e=>e.nested),nestedOpenDialogCount:Ie(e=>e.nestedOpenDialogCount),disablePointerDismissal:Ie(e=>e.disablePointerDismissal),openMethod:Ie(e=>e.openMethod),descriptionElementId:Ie(e=>e.descriptionElementId),titleElementId:Ie(e=>e.titleElementId),viewportElement:Ie(e=>e.viewportElement),role:Ie(e=>e.role)};class YZ extends zA{constructor(t){super(XZ(t),{popupRef:_.createRef(),backdropRef:_.createRef(),internalBackdropRef:_.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:new ux,onOpenChange:void 0,onOpenChangeComplete:void 0},ZZ)}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 XZ(e={}){return{...CK(),modal:!0,disablePointerDismissal:!1,popupElement:null,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,role:"dialog",...e}}function QZ(e){const{children:t,open:n,defaultOpen:s=!1,onOpenChange:i,onOpenChangeComplete:a,disablePointerDismissal:c=!1,modal:f=!0,actionsRef:d,handle:p,triggerId:g,defaultTriggerId:y=null}=e,b=sc(!0),x=!!b,S=In(()=>p?.store??new YZ({open:s,openProp:n,activeTriggerId:y,triggerIdProp:g,modal:f,disablePointerDismissal:c,nested:x})).current;hV(()=>{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:c,nested:x,modal:f}),S.useContextCallback("onOpenChange",i),S.useContextCallback("onOpenChangeComplete",a);const w=S.useState("payload");GZ({store:S,actionsRef:d,parentContext:b?.store.context});const T=_.useMemo(()=>({store:S}),[S]);return h.jsx(fO.Provider,{value:T,children:typeof t=="function"?t({payload:w}):t})}const gO=_.forwardRef(function(t,n){const{render:s,className:i,id:a,...c}=t,{store:f}=sc(),d=pr(a);return f.useSyncedValueWithCleanup("titleElementId",d),Pt("h2",t,{ref:n,props:[{id:d},c]})}),Dr=QZ,WZ=_.forwardRef(({className:e,...t},n)=>h.jsx(px,{ref:n,className:ge("fixed inset-0 z-50 bg-black/60 backdrop-blur-sm",e),...t}));WZ.displayName="DialogOverlay";const lr=_.forwardRef(({className:e,children:t,...n},s)=>h.jsxs(mO,{children:[h.jsx(px,{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm"}),h.jsx(pO,{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})]}));lr.displayName="DialogContent";const cr=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("px-5 py-3 border-b border-border",e),...t}));cr.displayName="DialogHeader";const Tn=_.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}));Tn.displayName="DialogFooter";const ur=_.forwardRef(({className:e,...t},n)=>h.jsx(gO,{ref:n,className:ge("font-mono text-[10px] text-neutral-500 uppercase tracking-widest",e),...t}));ur.displayName="DialogTitle";const JZ=_.forwardRef(({className:e,...t},n)=>h.jsx(dO,{ref:n,className:ge("font-mono text-[10px] text-neutral-500",e),...t}));JZ.displayName="DialogDescription";const mx=_.forwardRef(({className:e,page:t,totalPages:n,totalItems:s,onPageChange:i,...a},c)=>h.jsxs("div",{ref:c,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(Me,{size:"sm",variant:"default",disabled:t<=1,onClick:()=>i(t-1),children:"Prev"}),h.jsx(Me,{size:"sm",variant:"default",disabled:t>=n,onClick:()=>i(t+1),children:"Next"})]})]}));mx.displayName="Pagination";const eY=_.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}));eY.displayName="Separator";const tY=di("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"}}),nY=_.forwardRef(({className:e,side:t,children:n,...s},i)=>h.jsxs(mO,{children:[h.jsx(px,{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm"}),h.jsx(pO,{ref:i,className:ge(tY({side:t,className:e})),...s,children:n})]}));nY.displayName="SheetContent";const rY=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("px-5 py-3 border-b border-border",e),...t}));rY.displayName="SheetHeader";const sY=_.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}));sY.displayName="SheetFooter";const oY=_.forwardRef(({className:e,...t},n)=>h.jsx(gO,{ref:n,className:ge("font-mono text-[10px] text-neutral-500 uppercase tracking-widest",e),...t}));oY.displayName="SheetTitle";const iY=_.forwardRef(({className:e,...t},n)=>h.jsx(dO,{ref:n,className:ge("text-sm text-neutral-400",e),...t}));iY.displayName="SheetDescription";const aY=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("rounded-md bg-neutral-800 animate-pulse",e),...t}));aY.displayName="Skeleton";const lY=_.createContext(void 0);function gx(){const e=_.useContext(lY);if(e===void 0)throw new Error(pn(64));return e}let cY=(function(e){return e.activationDirection="data-activation-direction",e.orientation="data-orientation",e})({});const yO={tabActivationDirection:e=>({[cY.activationDirection]:e})},vO=_.createContext(void 0);function uY(){const e=_.useContext(vO);if(e===void 0)throw new Error(pn(65));return e}const fY=_.forwardRef(function(t,n){const{className:s,disabled:i=!1,render:a,value:c,id:f,nativeButton:d=!0,...p}=t,{value:g,getTabPanelIdByValue:y,orientation:b}=gx(),{activateOnFocus:x,highlightedTabIndex:S,onTabActivation:w,setHighlightedTabIndex:T,tabsListElement:C}=uY(),A=pr(f),N=_.useMemo(()=>({disabled:i,id:A,value:c}),[i,A,c]),{compositeProps:R,compositeRef:k,index:L}=iO({metadata:N}),j=c===g,O=_.useRef(!1);ze(()=>{if(O.current){O.current=!1;return}if(!(j&&L>-1&&S!==L))return;const q=C;if(q!=null){const U=Lo(Rt(q));if(U&&Mt(q,U))return}i||T(L)},[j,L,S,T,i,C]);const{getButtonProps:D,buttonRef:K}=Ql({disabled:i,native:d,focusableWhenDisabled:!0}),F=y(c),z=_.useRef(!1),X=_.useRef(!1);function Y(q){j||i||w(c,Kt(ri,q.nativeEvent,void 0,{activationDirection:"none"}))}function te(q){j||(L>-1&&!i&&T(L),!i&&x&&(!z.current||z.current&&X.current)&&w(c,Kt(ri,q.nativeEvent,void 0,{activationDirection:"none"})))}function P(q){if(j||i)return;z.current=!0;function U(){z.current=!1,X.current=!1}(!q.button||q.button===0)&&(X.current=!0,Rt(q.currentTarget).addEventListener("pointerup",U,{once:!0}))}return Pt("button",t,{state:{disabled:i,active:j,orientation:b},ref:[n,K,k],props:[R,{role:"tab","aria-controls":F,"aria-selected":j,id:A,onClick:Y,onFocus:te,onPointerDown:P,[lO]:j?"":void 0,onKeyDownCapture(){O.current=!0}},p,D]})});let dY=(function(e){return e.index="data-index",e.activationDirection="data-activation-direction",e.orientation="data-orientation",e.hidden="data-hidden",e})({});const hY={...yO,...ga},pY=_.forwardRef(function(t,n){const{className:s,value:i,render:a,keepMounted:c=!1,...f}=t,{value:d,getTabIdByPanelValue:p,orientation:g,tabActivationDirection:y,registerMountedTabPanel:b,unregisterMountedTabPanel:x}=gx(),S=pr(),w=_.useMemo(()=>({id:S,value:i}),[S,i]),{ref:T,index:C}=hx({metadata:w}),A=i===d,{mounted:N,transitionStatus:R,setMounted:k}=Tp(A),L=!N,j=p(i),O={hidden:L,orientation:g,tabActivationDirection:y,transitionStatus:R},D=_.useRef(null),K=Pt("div",t,{state:O,ref:[n,T,D],props:[{"aria-labelledby":j,hidden:L,id:S,role:"tabpanel",tabIndex:A?0:-1,inert:dx(!A),[dY.index]:C},f],stateAttributesMapping:hY});return ya({open:A,ref:D,onComplete(){A||k(!1)}}),ze(()=>{if(!(L&&!c)&&S!=null)return b(i,S),()=>{x(i,S)}},[L,c,i,S,b,x]),c||N?K:null}),mY=_.forwardRef(function(t,n){const{activateOnFocus:s=!1,className:i,loopFocus:a=!0,render:c,...f}=t,{getTabElementBySelectedValue:d,onValueChange:p,orientation:g,value:y,setTabMap:b,tabActivationDirection:x}=gx(),[S,w]=_.useState(0),[T,C]=_.useState(null),A=gY(y,g,T,d),N=Ae((j,O)=>{if(j!==y){const D=A(j);O.activationDirection=D,p(j,O)}}),R={orientation:g,tabActivationDirection:x},k={"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(vO.Provider,{value:L,children:h.jsx(cO,{render:c,className:i,state:R,refs:[n,C],props:[k,f],stateAttributesMapping:yO,highlightedIndex:S,enableHomeAndEndKeys:!0,loopFocus:a,orientation:g,onHighlightedIndexChange:w,onMapChange:b,disabledIndices:Tu})})});function GC(e,t){const{left:n,top:s}=e.getBoundingClientRect(),{left:i,top:a}=t.getBoundingClientRect(),c=n-i,f=s-a;return{left:c,top:f}}function gY(e,t,n,s){const[i,a]=_.useState(null);return ze(()=>{if(e==null||n==null){a(null);return}const c=s(e);if(c==null){a(null);return}const{left:f,top:d}=GC(c,n);a(t==="horizontal"?f:d)},[t,s,n,e]),_.useCallback(c=>{if(c===e)return"none";if(c==null)return a(null),"none";if(c!=null&&n!=null){const f=s(c);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 yY=_.forwardRef(({className:e,...t},n)=>h.jsx(mY,{ref:n,className:ge("flex items-center gap-0.5",e),...t}));yY.displayName="TabsList";const vY=di("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"}}),bY=_.forwardRef(({className:e,variant:t,...n},s)=>h.jsx(fY,{ref:s,className:ge(vY({variant:t,className:e})),...n}));bY.displayName="TabsTrigger";const xY=_.forwardRef(({className:e,...t},n)=>h.jsx(pY,{ref:n,className:ge("outline-none",e),...t}));xY.displayName="TabsContent";const SY=_.forwardRef(({className:e,...t},n)=>h.jsx("p",{ref:n,className:ge("font-mono text-[11px] text-neutral-300",e),...t}));SY.displayName="Text";const _Y=_.forwardRef(({className:e,...t},n)=>h.jsx("p",{ref:n,className:ge("font-mono text-[10px] text-neutral-500",e),...t}));_Y.displayName="TextMuted";const wY=_.forwardRef(({className:e,...t},n)=>h.jsx("code",{ref:n,className:ge("font-mono text-[11px] text-white",e),...t}));wY.displayName="TextCode";const EY=_.forwardRef(({className:e,...t},n)=>h.jsx("span",{ref:n,className:ge("font-mono text-[9px] uppercase tracking-wider text-neutral-500",e),...t}));EY.displayName="TextLabel";const TY=_.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}));TY.displayName="CodeBlock";function va(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(c=>typeof a=="function"?a(c):a)},[]);return[n,i]}const CY="console:instance-id";function Rp(){const[e,t]=va(CY,""),n=e.trim();return _.useMemo(()=>({instanceId:n.length>0?n:void 0,rawInstanceId:e,setInstanceId:t,clearInstanceId:()=>t("")}),[n,e,t])}const Zn={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 vi(e,t){return e===0?!1:e??t}function RY(e){const t=new URLSearchParams;if(!e)return t;for(const[n,s]of Object.entries(e))s!=null&&t.set(n,String(s));return t}function bO(e,t,n){const s=e.endsWith("/")?e.slice(0,-1):e,a=RY(n)?.toString();return`${s}${t}${a?`?${a}`:""}`}function Np(e,t){if(!t||!e)throw new Error("Not connected");return e}async function yr(e){const t={Authorization:`Bearer ${e.connectionConfig.token}`};e.body!==void 0&&(t["Content-Type"]="application/json");const n=await fetch(bO(e.connectionConfig.serverUrl,e.path,e.query),{method:e.method??"GET",headers:t,body:e.body===void 0?void 0:JSON.stringify(e.body)});if(!n.ok)throw new Error(e.errorMessage);return n.json()}async function NY(e){const t=await fetch(bO(e.connectionConfig.serverUrl,e.path,e.query),{method:"GET",headers:{Authorization:`Bearer ${e.connectionConfig.token}`}});if(!t.ok)throw new Error(e.errorMessage);return t.blob()}function ns(e){const{config:t,isConnected:n}=pa();return NN({queryKey:e.queryKey,queryFn:()=>yr({connectionConfig:Np(t,n),path:e.path,query:e.query,method:e.method,errorMessage:e.errorMessage}),enabled:(e.enabled??!0)&&n&&!!t,refetchInterval:e.refetchInterval})}function yx(e){const{config:t,isConnected:n}=pa();return NN({queryKey:e.queryKey,queryFn:()=>{if(e.id===void 0)throw new Error(e.requiredMessage);return yr({connectionConfig:Np(t,n),path:e.path(e.id),query:e.query,errorMessage:e.errorMessage})},enabled:(e.enabled??!0)&&e.id!==void 0&&n&&!!t})}function jY(e,t){for(const n of t)e.invalidateQueries({queryKey:n})}function vr(e){const{instanceId:t}=Rp();return e??t}function rs(e){const{config:t,isConnected:n}=pa(),{instanceId:s}=Rp(),i=Ab();return X6({mutationFn:a=>e.mutationFn({connectionConfig:Np(t,n),variables:a,selectedInstanceId:s}),onSuccess:()=>{e.invalidateQueryKeys&&jY(i,e.invalidateQueryKeys)}})}function Ju(e={}){const t=vr(e.instanceId);return ns({queryKey:Zn.stats({partitionId:e.partitionId,instanceId:t}),path:"/console/stats",query:{partitionId:e.partitionId,instanceId:t},errorMessage:"Failed to fetch stats",refetchInterval:vi(e.refetchIntervalMs,5e3)})}function AY(e={},t={}){const n=vr(e.instanceId);return ns({queryKey:Zn.timeseries({...e,instanceId:n}),path:"/console/stats/timeseries",query:{interval:e.interval,range:e.range,partitionId:e.partitionId,instanceId:n},errorMessage:"Failed to fetch timeseries stats",enabled:t.enabled,refetchInterval:vi(t.refetchIntervalMs,3e4)})}function OY(e={},t={}){const n=vr(e.instanceId);return ns({queryKey:Zn.latency({...e,instanceId:n}),path:"/console/stats/latency",query:{range:e.range,partitionId:e.partitionId,instanceId:n},errorMessage:"Failed to fetch latency stats",enabled:t.enabled,refetchInterval:vi(t.refetchIntervalMs,3e4)})}function MY(e={},t={}){const n=vr(e.instanceId);return ns({queryKey:Zn.commits({...e,instanceId:n}),path:"/console/commits",query:{limit:e.limit,offset:e.offset,partitionId:e.partitionId,instanceId:n},errorMessage:"Failed to fetch commits",enabled:t.enabled,refetchInterval:vi(t.refetchIntervalMs,1e4)})}function kY(e,t={}){const n=vr(t.instanceId);return yx({queryKey:Zn.commitDetail(e,t.partitionId,n),id:e,requiredMessage:"Commit sequence is required",path:s=>`/console/commits/${encodeURIComponent(String(s))}`,query:{partitionId:t.partitionId,instanceId:n},errorMessage:"Failed to fetch commit detail",enabled:t.enabled})}function IY(e={},t={}){const n=vr(e.instanceId);return ns({queryKey:Zn.timeline({...e,instanceId:n}),path:"/console/timeline",query:{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,instanceId:n},errorMessage:"Failed to fetch timeline",enabled:t.enabled,refetchInterval:vi(t.refetchIntervalMs,1e4)})}function xO(e={},t={}){const n=vr(e.instanceId);return ns({queryKey:Zn.clients({...e,instanceId:n}),path:"/console/clients",query:{limit:e.limit,offset:e.offset,partitionId:e.partitionId,instanceId:n},errorMessage:"Failed to fetch clients",enabled:t.enabled,refetchInterval:vi(t.refetchIntervalMs,1e4)})}function DY(e,t={}){const n=vr(t.instanceId);return yx({queryKey:Zn.eventDetail(e,t.partitionId,n),id:e,requiredMessage:"Event id is required",path:s=>`/console/events/${encodeURIComponent(String(s))}`,query:{partitionId:t.partitionId,instanceId:n},errorMessage:"Failed to fetch event detail",enabled:t.enabled})}function PY(e,t={}){const n=vr(t.instanceId);return yx({queryKey:Zn.eventPayload(e,t.partitionId,n),id:e,requiredMessage:"Event id is required",path:s=>`/console/events/${encodeURIComponent(String(s))}/payload`,query:{partitionId:t.partitionId,instanceId:n},errorMessage:"Failed to fetch event payload",enabled:t.enabled})}function zY(e={}){const t=vr(e.instanceId);return ns({queryKey:Zn.handlers(t),path:"/console/handlers",query:{instanceId:t},errorMessage:"Failed to fetch handlers"})}function LY(e={}){const t=vr(e.instanceId);return ns({queryKey:Zn.prunePreview(t),path:"/console/prune/preview",query:{instanceId:t},method:"POST",errorMessage:"Failed to fetch prune preview",enabled:e.enabled})}function UY(e={},t={}){const n=vr(e.instanceId);return ns({queryKey:Zn.operations({...e,instanceId:n}),path:"/console/operations",query:{limit:e.limit,offset:e.offset,operationType:e.operationType,partitionId:e.partitionId,instanceId:n},errorMessage:"Failed to fetch operations",enabled:t.enabled,refetchInterval:vi(t.refetchIntervalMs,1e4)})}function $Y(){return rs({mutationFn:async({connectionConfig:e,selectedInstanceId:t})=>yr({connectionConfig:e,path:"/console/events",query:{instanceId:t},method:"DELETE",errorMessage:"Failed to clear events"}),invalidateQueryKeys:[["console","events"]]})}function BY(){return rs({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>{const s=t.instanceId??n;return yr({connectionConfig:e,path:`/console/clients/${encodeURIComponent(t.clientId)}`,query:{partitionId:t.partitionId,instanceId:s},method:"DELETE",errorMessage:"Failed to evict client"})},invalidateQueryKeys:[["console","clients"],["console","stats"],["console","operations"]]})}function FY(){return rs({mutationFn:async({connectionConfig:e,selectedInstanceId:t})=>yr({connectionConfig:e,path:"/console/prune",query:{instanceId:t},method:"POST",errorMessage:"Failed to prune"}),invalidateQueryKeys:[["console","stats"],["console","commits"],["console","timeline"],["console","prune","preview"],["console","operations"]]})}function HY(){return rs({mutationFn:async({connectionConfig:e,selectedInstanceId:t})=>yr({connectionConfig:e,path:"/console/compact",query:{instanceId:t},method:"POST",errorMessage:"Failed to compact"}),invalidateQueryKeys:[["console","stats"],["console","operations"]]})}function qY(){return rs({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>{const s=t.instanceId??n;return yr({connectionConfig:e,path:"/console/notify-data-change",query:{instanceId:s},method:"POST",body:{tables:t.tables,partitionId:t.partitionId},errorMessage:"Failed to notify data change"})},invalidateQueryKeys:[["console","stats"],["console","commits"],["console","timeline"],["console","operations"]]})}function VY(e={}){const t=vr(e.instanceId);return ns({queryKey:Zn.apiKeys({...e,instanceId:t}),path:"/console/api-keys",query:{limit:e.limit,offset:e.offset,type:e.type,status:e.status,expiresWithinDays:e.expiresWithinDays,instanceId:t},errorMessage:"Failed to fetch API keys"})}function KY(){return rs({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>yr({connectionConfig:e,path:"/console/api-keys",query:{instanceId:n},method:"POST",body:t,errorMessage:"Failed to create API key"}),invalidateQueryKeys:[["console","api-keys"]]})}function GY(){return rs({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>yr({connectionConfig:e,path:`/console/api-keys/${encodeURIComponent(t)}`,query:{instanceId:n},method:"DELETE",errorMessage:"Failed to revoke API key"}),invalidateQueryKeys:[["console","api-keys"]]})}function ZY(){return rs({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>yr({connectionConfig:e,path:"/console/api-keys/bulk-revoke",query:{instanceId:n},method:"POST",body:t,errorMessage:"Failed to bulk revoke API keys"}),invalidateQueryKeys:[["console","api-keys"]]})}function YY(){return rs({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>yr({connectionConfig:e,path:`/console/api-keys/${encodeURIComponent(t)}/rotate`,query:{instanceId:n},method:"POST",errorMessage:"Failed to rotate API key"}),invalidateQueryKeys:[["console","api-keys"]]})}function XY(){return rs({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>yr({connectionConfig:e,path:`/console/api-keys/${encodeURIComponent(t)}/rotate/stage`,query:{instanceId:n},method:"POST",errorMessage:"Failed to stage-rotate API key"}),invalidateQueryKeys:[["console","api-keys"]]})}function QY(e={}){return ns({queryKey:Zn.storage({prefix:e.prefix,cursor:e.cursor,limit:e.limit}),path:"/console/storage",query:{prefix:e.prefix,cursor:e.cursor,limit:e.limit},errorMessage:"Failed to list blobs",refetchInterval:vi(e.refetchIntervalMs,3e4)})}function WY(){return rs({mutationFn:async({connectionConfig:e,variables:t})=>yr({connectionConfig:e,path:`/console/storage/${encodeURIComponent(t)}`,method:"DELETE",errorMessage:"Failed to delete blob"}),invalidateQueryKeys:[["console","storage"]]})}function JY(){const{config:e,isConnected:t}=pa();return async n=>{const s=await NY({connectionConfig:Np(e,t),path:`/console/storage/${encodeURIComponent(n)}/download`,errorMessage:"Failed to download blob"}),i=URL.createObjectURL(s),a=document.createElement("a");a.href=i,a.download=n.split("/").pop()||n,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}}const eX="console:partition-id";function ef(){const[e,t]=va(eX,""),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 tf(){const[e,t]=va("console:preferences",ZC);return{preferences:e,setPreferences:t,updatePreference:(i,a)=>{t(c=>({...c,[i]:a}))},resetPreferences:()=>{t(ZC)}}}const tX=[{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"}],nX=[{value:10,label:"10"},{value:20,label:"20"},{value:50,label:"50"},{value:100,label:"100"}],vx="syncular-console-root";function rX(e){e.classList.add(vx)}const sX=[{suffix:"",label:"Command"},{suffix:"/stream",label:"Stream"},{suffix:"/fleet",label:"Fleet"},{suffix:"/ops",label:"Ops"},{suffix:"/storage",label:"Storage"},{suffix:"/config",label:"Config"}];function oX(e){const t=e?.trim()??"";return!t||t==="/"?"":(t.startsWith("/")?t:`/${t}`).replace(/\/+$/g,"")}function Ly(e,t){return e?t?`${e}${t}`:e:t||"/"}function iX({basePath:e,appHref:t,modeBadge:n}){const{connect:s,config:i,isConnected:a,isConnecting:c}=pa(),{preferences:f}=tf(),{instanceId:d,rawInstanceId:p,setInstanceId:g,clearInstanceId:y}=Rp(),{partitionId:b,rawPartitionId:x,setPartitionId:S,clearPartitionId:w}=ef(),T=hr({select:D=>D.location.pathname}),{data:C}=Ju({refetchIntervalMs:f.refreshInterval*1e3,partitionId:b,instanceId:d}),A=oX(e),N=_.useMemo(()=>sX.map(D=>({...D,id:Ly(A,D.suffix)})),[A]),R=Ly(A,""),k=Ly(A,"/config"),L=c?"connecting":a?"connected":i?"disconnected":"not-configured",j=N.find(D=>D.suffix===""?T===R||T===`${R}/`:T.startsWith(D.id))?.id??R,O=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($Z,{brand:h.jsx(yl,{to:R,children:h.jsx(UZ,{label:"console"})}),center:h.jsx(MZ,{items:N,activeId:j,renderItem:(D,{active:K})=>h.jsx(yl,{to:D.id,children:h.jsx(uO,{active:K,children:D.label})},D.id)}),right:h.jsxs("div",{className:"flex items-center gap-2",children:[n?h.jsx(dn,{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(Hn,{variant:"mono",value:p,onChange:D=>g(D.target.value),onBlur:D=>g(D.target.value.trim()),placeholder:"all",className:"h-7 w-[110px] px-2 py-1"}),d?h.jsx(Me,{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(Hn,{variant:"mono",value:x,onChange:D=>S(D.target.value),onBlur:D=>S(D.target.value.trim()),placeholder:"all",className:"h-7 w-[110px] px-2 py-1"}),b?h.jsx(Me,{variant:"ghost",size:"sm",className:"h-7 px-2 text-[10px]",onClick:w,children:"All"}):null]}),h.jsx(D8,{state:L}),h.jsx(yl,{to:k,children:h.jsx(Me,{variant:T===k?"secondary":"ghost",size:"icon",children:h.jsx(W8,{className:"h-3 w-3"})})}),t?h.jsxs("a",{href:t,className:OZ,children:[h.jsx(X8,{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===k?h.jsx("div",{style:{animation:"pageIn 0.3s ease-out"},children:h.jsx(JN,{})},T):h.jsx(aX,{configPath:k,hasSavedConfig:!!i,isConnecting:c,onConnect:()=>{s()}})})}),a&&h.jsx(Vj,{isLive:a,metrics:O,uptime:"--"})]})}function aX({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(Me,{variant:"default",onClick:s,disabled:n,children:n?"Connecting...":"Connect"}),h.jsx(yl,{to:e,children:h.jsx(Me,{variant:"link",children:"Configure connection"})})]})]})}const io=PH({component:iX});function lX(e={}){const{maxEvents:t=100,enabled:n=!0,staleAfterMs:s=65e3,replayLimit:i=100,partitionId:a,instanceId:c}=e,{config:f,isConnected:d}=pa(),{instanceId:p}=Rp(),g=c??p,[y,b]=_.useState([]),[x,S]=_.useState(!1),[w,T]=_.useState("disconnected"),[C,A]=_.useState(null),N=_.useRef(null),R=_.useRef(null),k=_.useRef(null),L=_.useRef(0),j=_.useRef(0),O=_.useRef(null),D=_.useCallback(()=>{b([]),O.current=null},[]);return _.useEffect(()=>{if(!n||!d||!f?.serverUrl||!f?.token)return;let K=!1;const F=Number.isFinite(i)?Math.max(1,Math.min(500,Math.floor(i))):100;if(typeof WebSocket>"u")return;const z=()=>{R.current&&(clearTimeout(R.current),R.current=null)},X=()=>{k.current&&(clearInterval(k.current),k.current=null)},Y=()=>{if(K||R.current)return;L.current+=1;const V=Math.min(3e4,1e3*2**Math.max(0,L.current-1)),B=Math.floor(V*.2*Math.random()),q=V+B;R.current=setTimeout(()=>{R.current=null,K||P()},q)},te=()=>{j.current=Date.now(),S(!0),T("connected")},P=()=>{if(K)return;T("connecting"),z();const V=(()=>{const q=new URL(f.serverUrl,window.location.origin);q.protocol=q.protocol==="https:"?"wss:":"ws:";const U=q.pathname.endsWith("/")?q.pathname.slice(0,-1):q.pathname;return q.pathname=`${U}/console/events/live`,q.search="",O.current&&q.searchParams.set("since",O.current),q.searchParams.set("replayLimit",String(F)),a&&q.searchParams.set("partitionId",a),g&&q.searchParams.set("instanceId",g),q.toString()})(),B=new WebSocket(V);N.current=B,B.onopen=()=>{if(K){B.close();return}L.current=0,A(null),T("connecting"),S(!1);try{B.send(JSON.stringify({type:"auth",token:f.token}))}catch{B.close();return}X(),k.current=setInterval(()=>{const q=N.current;if(!q||q.readyState!==WebSocket.OPEN)return;const U=j.current;!U||Date.now()-U<=s||(S(!1),T("stale"),q.close())},1e3)},B.onclose=()=>{K||(S(!1),T("disconnected"),X(),Y())},B.onerror=()=>{K||A(new Error("WebSocket connection failed"))},B.onmessage=q=>{try{const U=JSON.parse(q.data),I=U.type;if(te(),I==="connected"||I==="heartbeat"||I==="auth_required")return;if(I==="error"){const se=typeof U.message=="string"?U.message:"Live events authentication failed";A(new Error(se));return}const G={type:I,timestamp:U.timestamp||new Date().toISOString(),data:U};if(a&&G.data.partitionId!==a||g&&G.data.instanceId!==g)return;const W=Date.parse(O.current??""),Q=Date.parse(G.timestamp);Number.isFinite(Q)&&(!Number.isFinite(W)||Q>W)&&(O.current=G.timestamp),b(se=>[G,...se].slice(0,t))}catch{}}};return P(),()=>{K=!0,z(),X(),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:D}}const cX=_.createContext(null);function SO(){const[e,t]=va("console:time-range","24h");return{range:e,setRange:t}}const uX=[{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 fX(e){const t=e.toLowerCase();for(const n of uX)if(t.includes(n.hint))return n.type;return"client"}function dX(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 hX(e,t){return typeof e.lagCommitCount=="number"?Math.max(0,e.lagCommitCount):t?Math.max(0,t.maxCommitSeq-e.cursor):0}function pX(e,t){return e.activityState==="stale"?"offline":t>0?"syncing":"online"}function mX(e,t){return e.length<=16?e:`${e.slice(0,12)}-${t+1}`}function gX(e,t,n={}){const s=n.maxNodes??10;return e.slice(0,s).map((i,a)=>{const c=hX(i,t),f=pX(i,c);return{id:mX(i.clientId,a),type:fX(i.clientId),status:f,cursor:Math.max(0,i.cursor),actor:i.actorId,mode:i.connectionMode,dialect:dX(i.clientId),scopes:Object.keys(i.effectiveScopes||{}),lastSeen:i.updatedAt}})}const yX={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 vX(e){const t=e.length>1&&e.endsWith("/")?e.slice(0,-1):e;return t==="/console"||t.startsWith("/console/")?"/console/stream":"/stream"}function bX(){const e=up(),t=_.useMemo(()=>typeof window>"u"?"/stream":vX(window.location.pathname),[]),n=SO(),{range:s}=n,{preferences:i}=tf(),{partitionId:a}=ef(),c=i.refreshInterval*1e3,[f]=va("console:alert-config",yX),[d,p]=_.useState("1h"),{data:g}=Ju({refetchIntervalMs:c,partitionId:a}),{data:y}=AY({range:s,partitionId:a},{refetchIntervalMs:c}),{data:b}=OY({range:s,partitionId:a},{refetchIntervalMs:c}),{data:x}=MY({limit:5,partitionId:a},{refetchIntervalMs:c}),{data:S}=xO({limit:12,offset:0,partitionId:a},{refetchIntervalMs:c}),{events:w,isConnected:T}=lX({maxEvents:8,partitionId:a}),C=_.useMemo(()=>{const z=y?.buckets??[];let X=0,Y=0;for(const P of z)X+=P.pushCount+P.pullCount,Y+=P.errorCount;const te=X>0?Y/X*100:0;return{totalEvents:X,errorRate:te}},[y?.buckets]),A=_.useMemo(()=>S?.items?gX(S.items,g,{maxNodes:12}):[],[S?.items,g]),N=A.filter(z=>z.status!=="offline").length,R=A.filter(z=>z.status==="offline").length,k=_.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 X=Math.max(...z.map(Y=>Math.max(Y.pushCount,Y.pullCount)),1);return z.map(Y=>({pushPercent:X>0?Y.pushCount/X*100:0,pullPercent:X>0?Y.pullCount/X*100:0}))},[y?.buckets]),O=_.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]),D=_.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]),K=_.useMemo(()=>Math.max(0,100-C.errorRate),[C.errorRate]),F=_.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(cX.Provider,{value:n,children:h.jsxs("div",{className:"flex flex-col",children:[F.length>0&&h.jsx("div",{className:"px-6 pb-4",children:h.jsxs(On,{variant:"destructive",children:[h.jsx(Wu,{children:"Threshold Exceeded"}),h.jsx(Mn,{children:F.map((z,X)=>h.jsx("span",{className:"block",children:z},X))})]})}),h.jsx(HA,{clients:A,totalNodes:A.length+2,onlineCount:N,offlineCount:R,relayClientIds:[]}),h.jsx(Jj,{items:k}),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(Tj,{bars:j,activeRange:d,onRangeChange:p})}),h.jsx("div",{className:"border-b border-border border-r border-border",children:h.jsx(eA,{buckets:O,successRate:K})}),h.jsx("div",{className:"border-r border-border",children:h.jsx(Kj,{commits:D,onViewAll:()=>e({href:t})})})]}),h.jsx(tA,{entries:L,isConnected:T,maxVisible:20,maxHeight:"calc(100vh - 200px)"})]})]})}):h.jsx("div",{className:"flex items-center justify-center py-24",children:h.jsx(Dt,{size:"lg"})})}function xX(){return h.jsx(bX,{})}const Xr=aO;function SX({children:e}){return h.jsxs("div",{className:"space-y-4 px-5 py-5",children:[h.jsx(_X,{}),h.jsx(RX,{}),h.jsx(NX,{}),e]})}function _X(){const{clearError:e,config:t,connect:n,disconnect:s,error:i,isConnected:a,isConnecting:c}=pa(),[f,d]=_.useState(t?.serverUrl??"/api"),[p,g]=_.useState(t?.token??""),[y,b]=_.useState(null),[x,S]=_.useState(!1),[w,T]=_.useState(null),[C,A]=va("console:disconnect-clear-saved-config",!1);_.useEffect(()=>{const j=new URLSearchParams(window.location.search),O=j.get("server");let D=!1;if(O&&(d(O),j.delete("server"),D=!0),j.has("token")&&(j.delete("token"),D=!0),D){const K=j.toString(),F=K?`${window.location.pathname}?${K}`:window.location.pathname;window.history.replaceState({},"",F)}},[]),_.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)},k=async()=>{S(!0),b(null),T(null);const j=performance.now();try{const O=f.trim(),D=p.trim();if(!O||!D)throw new Error("Missing server URL or token");if(!(await fetch(`${O}/console/stats`,{headers:{Authorization:`Bearer ${D}`}})).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(Zj,{isConnected:a,isConnecting:c,isTestingConnection:x,serverUrl:f,onServerUrlChange:d,consoleToken:p,onConsoleTokenChange:g,onSaveAndConnect:N,onDisconnect:R,onTestConnection:k,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(bp,{checked:C,onCheckedChange:A})]})})})}const wX=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 Uy(e){if(!e)return"Never";const t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():"Invalid date"}function EX(e){return e.length===0?"all scopes":e.length<=2?e.join(", "):`${e.slice(0,2).join(", ")} +${e.length-2}`}function TX(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*wX?"expiring":"active"}function CX(e){return e==="revoked"?"destructive":e==="expired"?"offline":e==="expiring"?"syncing":"healthy"}function RX(){const[e,t]=_.useState("all"),[n,s]=_.useState("all"),[i,a]=_.useState("14"),[c,f]=_.useState(!1),[d,p]=_.useState(!1),[g,y]=_.useState(""),[b,x]=_.useState("relay"),[S,w]=_.useState(""),[T,C]=_.useState(""),[A,N]=_.useState(""),[R,k]=_.useState(null),[L,j]=_.useState([]),[O,D]=_.useState(null),[K,F]=_.useState(null),[z,X]=_.useState(null),[Y,te]=_.useState(null),[P,V]=_.useState(null),[B,q]=_.useState(null),[U,I]=_.useState(null),G=_.useMemo(()=>XC(i),[i]),W=G??14,Q=_.useMemo(()=>XC(A),[A]),se=A.trim().length>0,oe=!se||Q!==null,pe=_.useMemo(()=>({type:e==="all"?void 0:e,status:n==="all"?void 0:n,expiresWithinDays:n==="expiring"?W:void 0}),[e,n,W]),{data:Se,isLoading:he,error:He}=VY(pe),Ee=KY(),re=ZY(),de=GY(),ae=YY(),_e=XY();_.useEffect(()=>{const me=new Set((Se?.items??[]).map(Te=>Te.keyId));j(Te=>Te.filter(qe=>me.has(qe)))},[Se?.items]);const ve=async()=>{try{const me=T.split(",").map(qe=>qe.trim()).filter(qe=>qe.length>0),Te=await Ee.mutateAsync({name:g,keyType:b,actorId:S||void 0,scopeKeys:me.length>0?me:void 0,expiresInDays:se?Q??void 0:void 0});k(Te.secretKey),y(""),w(""),C(""),N("")}catch{}},xe=me=>{navigator.clipboard.writeText(me),F(me),setTimeout(()=>F(null),2e3)},ye=async()=>{if(z)try{await de.mutateAsync(z)}finally{X(null)}},Le=async()=>{if(L.length!==0)try{const me=await re.mutateAsync({keyIds:L});D(me),j([])}catch{}},ke=async()=>{if(Y)try{const me=await _e.mutateAsync(Y.keyId);V({oldKeyId:Y.keyId,oldKeyName:Y.name,secretKey:me.secretKey})}catch{}},we=async()=>{if(P)try{await de.mutateAsync(P.oldKeyId)}finally{V(null),te(null)}},Ve=async()=>{if(B)try{const me=await ae.mutateAsync(B);I(me.secretKey)}finally{q(null)}};if(he)return h.jsx("div",{className:"flex h-[200px] items-center justify-center",children:h.jsx(Dt,{size:"lg"})});if(He)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: ",He.message]})});const Xe=(Se?.items??[]).filter(me=>me.revokedAt===null).map(me=>me.keyId),$e=Xe.length>0&&Xe.every(me=>L.includes(me)),We=L.length>0,Fe=(Se?.items??[]).filter(me=>L.includes(me.keyId)).map(me=>me.name);return h.jsxs(h.Fragment,{children:[h.jsxs(Jb,{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(Me,{size:"sm",variant:"destructive",onClick:()=>p(!0),disabled:L.length===0,children:["Revoke Selected (",L.length,")"]}),h.jsx(Me,{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(ds,{children:[h.jsx(Qr,{children:"Type filter"}),h.jsxs(lh,{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(Xr,{value:"all",children:"all"}),h.jsx(Xr,{value:"relay",children:"relay"}),h.jsx(Xr,{value:"proxy",children:"proxy"}),h.jsx(Xr,{value:"admin",children:"admin"})]})]}),h.jsxs(ds,{children:[h.jsx(Qr,{children:"Status filter"}),h.jsxs(lh,{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(Xr,{value:"all",children:"all"}),h.jsx(Xr,{value:"active",children:"active"}),h.jsx(Xr,{value:"revoked",children:"revoked"}),h.jsx(Xr,{value:"expiring",children:"expiring"})]})]}),h.jsxs(ds,{children:[h.jsx(Qr,{htmlFor:"api-key-expiring-window",children:"Expiring window (days)"}),h.jsx(dl,{children:"Used when status filter is set to expiring."}),h.jsx(Hn,{id:"api-key-expiring-window",placeholder:"14",value:i,inputMode:"numeric",onChange:me=>a(me.target.value)}),G===null&&i.trim().length>0?h.jsx("p",{className:"font-mono text-[10px] text-offline",children:"Enter a positive whole number."}):null]})]}),Se?.items.length===0?h.jsx(Qb,{message:"No API keys match the current filters."}):h.jsxs(Jl,{children:[h.jsx(ec,{children:h.jsxs(ts,{children:[h.jsx(ht,{className:"w-[28px]",children:h.jsx(Uv,{checked:$e,indeterminate:!$e&&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(tc,{children:(Se?.items??[]).map(me=>{const Te=TX(me,W);return h.jsxs(ts,{className:"group relative",children:[h.jsx(pt,{className:"w-[28px]",children:h.jsx(Uv,{checked:L.includes(me.keyId),onCheckedChange:qe=>{j(mt=>qe?[...new Set([...mt,me.keyId])]:mt.filter(ct=>ct!==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(dn,{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:EX(me.scopeKeys)})}),h.jsx(pt,{className:"w-[120px] text-neutral-500",children:Uy(me.createdAt)}),h.jsx(pt,{className:"w-[120px] text-neutral-500",children:Uy(me.lastUsedAt)}),h.jsx(pt,{className:"w-[120px] text-neutral-500",children:Uy(me.expiresAt)}),h.jsx(pt,{className:"flex-1",children:h.jsx(dn,{variant:CX(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:()=>te(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:()=>q(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:()=>X(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(Dr,{open:c,onOpenChange:f,children:h.jsxs(lr,{children:[h.jsx(cr,{children:h.jsx(ur,{children:"Create API Key"})}),R?h.jsx(QC,{copiedKeyId:K,onClose:()=>{k(null),f(!1)},onCopy:xe,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(ds,{children:[h.jsx(Qr,{htmlFor:"api-key-name",children:"Name"}),h.jsx(Hn,{id:"api-key-name",placeholder:"Backend Relay Key",value:g,onChange:me=>y(me.target.value)})]}),h.jsxs(ds,{children:[h.jsx(Qr,{children:"Key type"}),h.jsxs(lh,{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(Xr,{value:"relay",children:"relay"}),h.jsx(Xr,{value:"proxy",children:"proxy"}),h.jsx(Xr,{value:"admin",children:"admin"})]})]}),h.jsxs(ds,{children:[h.jsx(Qr,{htmlFor:"api-key-actor-id",children:"Actor ID (optional)"}),h.jsx(dl,{children:"Pin this key to a fixed actor ID"}),h.jsx(Hn,{id:"api-key-actor-id",placeholder:"actor-123",value:S,onChange:me=>w(me.target.value)})]}),h.jsxs(ds,{children:[h.jsx(Qr,{htmlFor:"api-key-scope-keys",children:"Scope keys (optional)"}),h.jsx(dl,{children:"Comma-separated list of allowed scope keys"}),h.jsx(Hn,{id:"api-key-scope-keys",placeholder:"scope-a, scope-b",value:T,onChange:me=>C(me.target.value)})]}),h.jsxs(ds,{children:[h.jsx(Qr,{htmlFor:"api-key-expires-days",children:"Expires in days (optional)"}),h.jsx(dl,{children:"Leave empty to keep the key non-expiring."}),h.jsx(Hn,{id:"api-key-expires-days",placeholder:"30",value:A,inputMode:"numeric",onChange:me=>N(me.target.value)}),oe?null:h.jsx("p",{className:"font-mono text-[10px] text-offline",children:"Enter a positive whole number."})]}),h.jsxs(Tn,{children:[h.jsx(Me,{variant:"default",onClick:()=>f(!1),children:"Cancel"}),h.jsx(Me,{variant:"primary",onClick:ve,disabled:Ee.isPending||!g||!oe,children:Ee.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Dt,{size:"sm"}),"Creating..."]}):"Create"})]})]})]})}),h.jsx(Dr,{open:d,onOpenChange:me=>{p(me),me||D(null)},children:h.jsxs(lr,{children:[h.jsx(cr,{children:h.jsx(ur,{children:"Bulk Revoke API Keys"})}),O?h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-3",children:[h.jsx(On,{variant:"destructive",children:h.jsxs(Mn,{children:["Requested ",O.requestedCount," keys. Revoked"," ",O.revokedCount,", already revoked"," ",O.alreadyRevokedCount,", not found"," ",O.notFoundCount,"."]})}),h.jsx(Tn,{children:h.jsx(Me,{variant:"primary",onClick:()=>{p(!1),D(null)},children:"Done"})})]}):h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-3",children:[h.jsx(On,{variant:"destructive",children:h.jsx(Mn,{children:"This revokes selected keys immediately and cannot be undone."})}),h.jsxs("p",{className:"font-mono text-[10px] text-neutral-500",children:["Selected keys: ",Fe.slice(0,5).join(", "),Fe.length>5?` +${Fe.length-5} more`:""]})]}),h.jsxs(Tn,{children:[h.jsx(Me,{variant:"default",onClick:()=>p(!1),children:"Cancel"}),h.jsx(Me,{variant:"destructive",onClick:Le,disabled:re.isPending||L.length===0,children:re.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Dt,{size:"sm"}),"Revoking..."]}):"Revoke Selected"})]})]})]})}),h.jsx(Dr,{open:Y!==null||P!==null,onOpenChange:()=>{te(null),V(null)},children:h.jsxs(lr,{children:[h.jsx(cr,{children:h.jsx(ur,{children:"Stage Rotate API Key"})}),P?h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[h.jsx(On,{variant:"default",children:h.jsxs(Mn,{children:["Replacement key created for ",P.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:P.secretKey}),h.jsx(Me,{variant:"default",size:"sm",onClick:()=>xe(P.secretKey),children:K===P.secretKey?"Copied":"Copy"})]}),h.jsxs(Tn,{children:[h.jsx(Me,{variant:"default",onClick:()=>{V(null),te(null)},children:"Keep Old Key Active"}),h.jsx(Me,{variant:"destructive",onClick:we,disabled:de.isPending,children:de.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Dt,{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(Tn,{children:[h.jsx(Me,{variant:"default",onClick:()=>te(null),children:"Cancel"}),h.jsx(Me,{variant:"primary",onClick:ke,disabled:_e.isPending||!Y,children:_e.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Dt,{size:"sm"}),"Staging..."]}):"Create Replacement Key"})]})]})]})}),h.jsx(Dr,{open:z!==null,onOpenChange:()=>X(null),children:h.jsxs(lr,{children:[h.jsx(cr,{children:h.jsx(ur,{children:"Revoke API Key"})}),h.jsx("div",{className:"px-5 py-4",children:h.jsx(On,{variant:"destructive",children:h.jsx(Mn,{children:"Revoking a key immediately invalidates it for all requests."})})}),h.jsxs(Tn,{children:[h.jsx(Me,{variant:"default",onClick:()=>X(null),children:"Cancel"}),h.jsx(Me,{variant:"destructive",onClick:ye,disabled:de.isPending,children:de.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Dt,{size:"sm"}),"Revoking..."]}):"Revoke"})]})]})}),h.jsx(Dr,{open:B!==null||U!==null,onOpenChange:()=>{q(null),I(null)},children:h.jsxs(lr,{children:[h.jsx(cr,{children:h.jsx(ur,{children:"Rotate API Key"})}),U?h.jsx(QC,{copiedKeyId:K,onClose:()=>I(null),onCopy:xe,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(Tn,{children:[h.jsx(Me,{variant:"default",onClick:()=>q(null),children:"Cancel"}),h.jsx(Me,{variant:"primary",onClick:Ve,disabled:ae.isPending,children:ae.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Dt,{size:"sm"}),"Rotating..."]}):"Rotate"})]})]})]})})]})}function NX(){const{preferences:e,updatePreference:t,resetPreferences:n}=tf(),s=[{type:"filter",label:"Auto-refresh interval",options:tX.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:nX.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(nA,{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(On,{variant:"destructive",children:h.jsx(Mn,{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(Me,{variant:"default",size:"sm",onClick:()=>n(s),children:e===s?"Copied":"Copy"})]}),h.jsx(Tn,{children:h.jsx(Me,{variant:"primary",onClick:t,children:"Done"})})]})}function jX(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 AX(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 OX(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),c=Math.floor(a/60),f=Math.floor(c/60),d=Math.floor(f/24);return a<60?"just now":c<60?`${c}m ago`:f<24?`${f}h ago`:`${d}d ago`}catch{return e}}function MX(e,t,n){return{id:e.clientId,type:jX(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:AX(e.clientId),scopes:Object.keys(e.effectiveScopes??{}),lastSeen:OX(e.updatedAt,n)}}function kX({emptyState:e}={}){const[t,n]=_.useState(1),[s,i]=_.useState(null),{preferences:a}=tf(),{partitionId:c}=ef(),f=a.pageSize,d=a.refreshInterval*1e3,{data:p,isLoading:g}=Ju({refetchIntervalMs:d,partitionId:c}),{data:y,isLoading:b,error:x}=xO({limit:f,offset:(t-1)*f,partitionId:c},{refetchIntervalMs:d}),S=BY(),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:c})}finally{i(null)}};if(b||g)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsx(Dt,{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 A=(y?.items??[]).map(N=>MX(N,T,a.timeFormat));return h.jsxs("div",{className:"flex flex-col gap-5 px-5 py-5",children:[A.length>0&&h.jsx(sA,{clients:A,headSeq:T}),A.length===0?e??h.jsx(aV,{children:h.jsx(Qb,{message:"No clients yet"})}):h.jsx(Qj,{clients:A,headSeq:T,onEvict:N=>{const R=y?.items.find(k=>k.clientId===N);i(R?.clientId??N)}}),w>1&&h.jsx(mx,{page:t,totalPages:w,totalItems:y?.total??0,onPageChange:n}),h.jsx(Dr,{open:s!==null,onOpenChange:()=>i(null),children:h.jsxs(lr,{children:[h.jsx(cr,{children:h.jsx(ur,{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(Tn,{children:[h.jsx(Me,{variant:"default",onClick:()=>i(null),children:"Cancel"}),h.jsx(Me,{variant:"destructive",onClick:C,disabled:S.isPending,children:S.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Dt,{size:"sm"}),"Evicting..."]}):"Evict"})]})]})})]})}const IX={latencyThresholdMs:1e3,errorRateThreshold:5,clientLagThreshold:50,enabled:!1};function DX(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 PX(e){const t=e.split(",").map(n=>n.trim()).filter(n=>n.length>0);return Array.from(new Set(t))}function zX(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 LX(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function UX(e){const t=WC(e.requestPayload),n=WC(e.resultPayload);if(e.operationType==="notify_data_change"){const a=LX(t?.tables),c=n?.commitSeq;return`${a.length} table${a.length===1?"":"s"} -> commit #${typeof c=="number"?c:"?"}`}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 $X(e){const t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function BX(){const{partitionId:e}=ef();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(FX,{}),h.jsx(GX,{})]}),h.jsxs("div",{className:"grid gap-4 xl:grid-cols-3",children:[h.jsx(HX,{partitionId:e}),h.jsx(qX,{partitionId:e}),h.jsx(VX,{partitionId:e})]}),h.jsx(KX,{partitionId:e})]})}function FX(){const{data:e,isLoading:t,error:n}=zY();if(t)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsx(Dt,{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?DX(i.snapshotChunkTtlMs):"default"}));return h.jsx(Wj,{handlers:s,tableCount:e?.items.length??0})}function HX({partitionId:e}){const[t,n]=_.useState(!1),[s,i]=_.useState(null),{data:a,isLoading:c}=Ju({partitionId:e}),{data:f,isLoading:d,refetch:p}=LY({enabled:!1}),g=FY(),y=async()=>{n(!0),i(null),await p()},b=async()=>{const S=await g.mutateAsync();i(S.deletedCommits)};if(c)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsx(Dt,{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(xp,{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(Dr,{open:t,onOpenChange:n,children:h.jsxs(lr,{children:[h.jsx(cr,{children:h.jsx(ur,{children:"Prune Old Commits"})}),h.jsx("div",{className:"px-5 py-4 flex flex-col gap-4",children:s!==null?h.jsxs(On,{variant:"default",children:[h.jsx(Wu,{children:"Pruning Complete"}),h.jsxs(Mn,{children:["Successfully deleted ",h.jsx("strong",{children:s})," commits."]})]}):d?h.jsx("div",{className:"flex items-center justify-center py-8",children:h.jsx(Dt,{size:"sm"})}):f?h.jsxs(h.Fragment,{children:[h.jsx(On,{variant:f.commitsToDelete>0?"destructive":"default",children:h.jsx(Mn,{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(dn,{variant:f.commitsToDelete>0?"offline":"ghost",children:f.commitsToDelete})]})]})]}):null}),h.jsxs(Tn,{children:[h.jsx(Me,{variant:"default",onClick:()=>n(!1),children:s!==null?"Close":"Cancel"}),s===null&&h.jsx(Me,{variant:"destructive",onClick:b,disabled:g.isPending||d||(f?.commitsToDelete??0)===0,children:g.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Dt,{size:"sm"}),"Pruning..."]}):"Prune Now"})]})]})})]})}function qX({partitionId:e}){const[t,n]=_.useState(!1),[s,i]=_.useState(null),{data:a,isLoading:c}=Ju({partitionId:e}),f=HY(),d=()=>{n(!0),i(null)},p=async()=>{const y=await f.mutateAsync();i(y.deletedChanges)};if(c)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsx(Dt,{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(xp,{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(Dr,{open:t,onOpenChange:n,children:h.jsxs(lr,{children:[h.jsx(cr,{children:h.jsx(ur,{children:"Compact Changes"})}),h.jsx("div",{className:"px-5 py-4 flex flex-col gap-4",children:s!==null?h.jsxs(On,{variant:"default",children:[h.jsx(Wu,{children:"Compaction Complete"}),h.jsxs(Mn,{children:["Successfully removed ",h.jsx("strong",{children:s})," redundant changes."]})]}):h.jsx(On,{variant:"default",children:h.jsx(Mn,{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(Tn,{children:[h.jsx(Me,{variant:"default",onClick:()=>n(!1),children:s!==null?"Close":"Cancel"}),s===null&&h.jsx(Me,{variant:"primary",onClick:p,disabled:f.isPending,children:f.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Dt,{size:"sm"}),"Compacting..."]}):"Compact Now"})]})]})})]})}function VX({partitionId:e}){const[t,n]=_.useState(!1),[s,i]=_.useState("tasks"),[a,c]=_.useState(e??""),[f,d]=_.useState(null),[p,g]=_.useState(null),y=qY(),b=PX(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(xp,{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(Dr,{open:t,onOpenChange:n,children:h.jsxs(lr,{children:[h.jsx(cr,{children:h.jsx(ur,{children:"Notify External Data Change"})}),h.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4",children:[f?h.jsxs(On,{variant:"default",children:[h.jsx(Wu,{children:"Notification Sent"}),h.jsxs(Mn,{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(On,{variant:"default",children:h.jsx(Mn,{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(On,{variant:"destructive",children:h.jsx(Mn,{children:p})}):null,h.jsxs(ds,{children:[h.jsx(Qr,{children:"Tables (comma-separated)"}),h.jsx(Hn,{value:s,onChange:T=>i(T.target.value),placeholder:"tasks, notes",disabled:y.isPending}),h.jsx(dl,{children:"Enter one or more table names affected by the external change."})]}),h.jsxs(ds,{children:[h.jsx(Qr,{children:"Partition ID (optional)"}),h.jsx(Hn,{value:a,onChange:T=>c(T.target.value),placeholder:"default",disabled:y.isPending})]})]}),h.jsxs(Tn,{children:[h.jsx(Me,{variant:"default",onClick:()=>n(!1),children:f?"Close":"Cancel"}),f?null:h.jsx(Me,{variant:"primary",onClick:w,disabled:y.isPending,children:y.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Dt,{size:"sm"}),"Notifying..."]}):"Notify Data Change"})]})]})})]})}function KX({partitionId:e}){const[t,n]=_.useState("all"),{data:s,isLoading:i,error:a}=UY({limit:20,offset:0,operationType:t==="all"?void 0:t,partitionId:e},{refetchIntervalMs:5e3});return h.jsx(Jb,{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(Me,{variant:t==="all"?"default":"ghost",size:"sm",onClick:()=>n("all"),children:"All"}),h.jsx(Me,{variant:t==="prune"?"default":"ghost",size:"sm",onClick:()=>n("prune"),children:"Prune"}),h.jsx(Me,{variant:t==="compact"?"default":"ghost",size:"sm",onClick:()=>n("compact"),children:"Compact"}),h.jsx(Me,{variant:t==="notify_data_change"?"default":"ghost",size:"sm",onClick:()=>n("notify_data_change"),children:"Notify"}),h.jsx(Me,{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(Dt,{size:"lg"})}):a?h.jsx(On,{variant:"destructive",children:h.jsxs(Mn,{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(Jl,{children:[h.jsx(ec,{children:h.jsxs(ts,{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(tc,{children:(s?.items??[]).map((c,f)=>h.jsxs(ts,{children:[h.jsx(pt,{className:"whitespace-nowrap text-xs text-neutral-400",children:$X(c.createdAt)}),h.jsx(pt,{children:h.jsx(dn,{variant:"ghost",children:zX(c.operationType)})}),h.jsx(pt,{className:"font-mono text-xs",children:c.consoleUserId??"system"}),h.jsx(pt,{className:"font-mono text-xs",children:c.targetClientId??c.partitionId??(c.operationType==="notify_data_change"?"partition default":"global")}),h.jsx(pt,{className:"font-mono text-xs text-neutral-300",children:UX(c)})]},`${c.operationId}:${c.createdAt}:${f}`))})]})})})}function GX(){const[e,t]=va("console:alert-config",IX),n={p90Latency:e.latencyThresholdMs,errorRate:e.errorRateThreshold,clientLag:e.clientLagThreshold},s=a=>{t(c=>({...c,latencyThresholdMs:a.p90Latency,errorRateThreshold:a.errorRate,clientLagThreshold:a.clientLag}))},i=a=>{t(c=>({...c,enabled:a}))};return h.jsx(qj,{enabled:e.enabled,onEnabledChange:i,thresholds:n,onThresholdsChange:s})}function ZX(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 YX(e){const t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function XX(){const[e,t]=_.useState(""),[n,s]=_.useState(void 0),[i,a]=_.useState(void 0),[c,f]=_.useState([]),[d,p]=_.useState(null),{data:g,isLoading:y,error:b}=QY({prefix:n,cursor:i,limit:100}),x=WY(),S=JY();function w(){const k=e.trim();s(k.length>0?k:void 0),a(void 0),f([])}function T(){t(""),s(void 0),a(void 0),f([])}function C(){g?.cursor&&(f(k=>[...k,i??""]),a(g.cursor))}function A(){f(k=>{const L=[...k],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(Dt,{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(Jb,{title:"Storage",actions:h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Hn,{placeholder:"Prefix filter...",value:e,onChange:k=>t(k.target.value),onKeyDown:k=>{k.key==="Enter"&&w()},className:"h-7 w-48 text-xs"}),h.jsx(Me,{variant:"default",size:"sm",onClick:w,children:"Filter"}),n&&h.jsx(Me,{variant:"ghost",size:"sm",onClick:T,children:"Clear"})]}),children:R.length===0?h.jsx(Qb,{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(Jl,{children:[h.jsx(ec,{children:h.jsxs(ts,{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(tc,{children:R.map(k=>h.jsxs(ts,{children:[h.jsx(pt,{className:"font-mono text-xs max-w-[320px]",title:k.key,children:k.key}),h.jsx(pt,{className:"font-mono text-xs text-neutral-400 whitespace-nowrap",children:ZX(k.size)}),h.jsx(pt,{children:k.httpMetadata?.contentType?h.jsx(dn,{variant:"ghost",children:k.httpMetadata.contentType}):h.jsx("span",{className:"text-neutral-500 text-xs",children:"--"})}),h.jsx(pt,{className:"whitespace-nowrap text-xs text-neutral-400",children:YX(k.uploaded)}),h.jsx(pt,{children:h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{S(k.key)},children:"Download"}),h.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>p(k.key),children:"Delete"})]})})]},k.key))})]})}),h.jsxs("div",{className:"flex items-center justify-between px-2 py-2",children:[h.jsx(Me,{variant:"ghost",size:"sm",disabled:c.length===0,onClick:A,children:"Previous"}),h.jsx(Me,{variant:"ghost",size:"sm",disabled:!g?.truncated,onClick:C,children:"Next"})]})]})}),h.jsx(Dr,{open:d!==null,onOpenChange:()=>p(null),children:h.jsxs(lr,{children:[h.jsx(cr,{children:h.jsx(ur,{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(Tn,{children:[h.jsx(Me,{variant:"default",onClick:()=>p(null),children:"Cancel"}),h.jsx(Me,{variant:"destructive",onClick:N,disabled:x.isPending,children:x.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Dt,{size:"sm"})," Deleting..."]}):"Delete"})]})]})})]})}const QX={};function su(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 WX(e){const t=e.split(/\s+/).map(i=>i.trim()).filter(i=>i.length>0),n={},s=[];for(const i of t){const[a="",...c]=i.split(":"),f=c.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 JX(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 Hd(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function eQ(e,t){return e?`#${e.federatedCommitId??(t?`${t}:${e.commitSeq}`:String(e.commitSeq))}`:"#?"}function tQ(e,t){return e?`E${e.federatedEventId??(t?`${t}:${e.eventId}`:e.eventId)}`:"E?"}function nQ(e,t,n){return!e||!t?null:e.replaceAll("{traceId}",encodeURIComponent(t)).replaceAll("{spanId}",encodeURIComponent(n??""))}function bx({initialSelectedEntryId:e}={}){const{preferences:t}=tf(),{partitionId:n}=ef(),{range:s,setRange:i}=SO(),a=t.pageSize,c=t.refreshInterval*1e3,f=QX?.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),[A,N]=_.useState(!1),[R,k]=_.useState(e??null),L=_.useRef(!1),j=_.useMemo(()=>WX(S),[S]),O=_.useMemo(()=>new Date(Date.now()-JX(s)).toISOString(),[s]),{data:D,isLoading:K,refetch:F}=IY({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:O},{refetchIntervalMs:c}),z=$Y(),X=R?.startsWith("#")?R.slice(1):void 0,Y=R?.startsWith("E")?R.slice(1):void 0,te=X&&X!=="?"?X:void 0,P=Y&&Y!=="?"?Y:void 0,{data:V,isLoading:B,error:q}=kY(te,{enabled:te!==void 0,partitionId:n}),{data:U,isLoading:I,error:G}=DY(P,{enabled:P!==void 0,partitionId:n}),{data:W,isLoading:Q,error:se}=PY(P,{enabled:P!==void 0&&!!U?.payloadRef,partitionId:n}),oe=_.useMemo(()=>nQ(f,U?.traceId??null,U?.spanId??null),[U?.spanId,U?.traceId,f]);_.useEffect(()=>{C(1)},[]),_.useEffect(()=>{C(1)},[]),_.useEffect(()=>{e&&k(e)},[e]),_.useEffect(()=>{if(!L.current){L.current=!0;return}k(null)},[]),_.useEffect(()=>{C(1),k(null)},[]);const Se=_.useMemo(()=>(D?.items??[]).map(_e=>{const ve=_e.instanceId??_e.commit?.instanceId??_e.event?.instanceId,xe=ve?`[${ve}] `:"";if(_e.type==="commit"&&_e.commit){const Le=_e.commit;return{type:"commit",id:eQ(Le,ve),outcome:"--",duration:"--",actor:Le.actorId,client:Le.clientId,detail:`${xe}${Le.changeCount} chg | ${(Le.affectedTables??[]).join(", ")}`,time:su(_e.timestamp,t.timeFormat)}}const ye=_e.event;return ye?{type:ye.eventType,id:tQ(ye,ve),outcome:ye.outcome,duration:`${ye.durationMs}ms`,actor:ye.actorId,client:ye.clientId,detail:`${xe}${(ye.tables??[]).join(", ")||"--"}`,time:su(_e.timestamp,t.timeFormat)}:{type:"pull",id:"E?",outcome:"unknown",duration:"--",actor:"",client:"",detail:"--",time:su(_e.timestamp,t.timeFormat)}}),[t.timeFormat,D?.items]),he=D?.total??0,He=Math.max(1,Math.ceil(he/a)),Ee=K,re=[{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 de(){z.mutate(void 0,{onSuccess:()=>{N(!1),F()}})}return h.jsxs("div",{className:"flex flex-col h-full",children:[Ee&&Se.length===0?h.jsx("div",{className:"flex items-center justify-center py-24",children:h.jsx(Dt,{size:"lg"})}):h.jsx(rA,{entries:Se,selectedEntryId:R,onEntryClick:ae=>k(ae.id),filterBar:h.jsx(Yj,{groups:re,searchValue:S,searchPlaceholder:"Use actor:, client:, table:, request:, trace: or free text...",onSearchChange:w,actions:h.jsxs(h.Fragment,{children:[h.jsx(Me,{size:"sm",variant:"ghost",onClick:()=>{F()},children:"Refresh"}),h.jsx(Me,{size:"sm",variant:"ghost",children:"Export"}),h.jsx(Me,{size:"sm",variant:"destructive",onClick:()=>N(!0),children:"Clear"})]})}),pagination:h.jsx(mx,{page:T,totalPages:He,totalItems:he,onPageChange:C})}),h.jsx(Dr,{open:R!==null,onOpenChange:ae=>{ae||k(null)},children:h.jsxs(lr,{children:[h.jsx(cr,{children:h.jsx(ur,{children:te!==void 0?`Commit #${te}`:P!==void 0?`Event E${P}`:"Entry details"})}),h.jsx("div",{className:"px-5 py-4 space-y-3 max-h-[70vh] overflow-y-auto",children:B||I?h.jsx("div",{className:"flex items-center justify-center py-8",children:h.jsx(Dt,{size:"sm"})}):q||G?h.jsx("p",{className:"font-mono text-[11px] text-offline",children:"Failed to load details."}):V?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:V.actorId})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Client"}),h.jsx("div",{className:"text-neutral-100",children:V.clientId})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Instance"}),h.jsx("div",{className:"text-neutral-100",children:V.instanceId??"--"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Created"}),h.jsx("div",{className:"text-neutral-100",children:su(V.createdAt,t.timeFormat)})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Changes"}),h.jsx("div",{className:"text-neutral-100",children:V.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:V.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"}),V.changes.length===0?h.jsx("p",{className:"font-mono text-[11px] text-neutral-500",children:"No changes recorded."}):V.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:Hd(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??"--"}),oe&&h.jsx("a",{href:oe,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(Me,{variant:"ghost",size:"sm",onClick:()=>k(`#${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:su(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:Hd(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"}),Q?h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Dt,{size:"sm"}),h.jsx("span",{className:"font-mono text-[11px] text-neutral-400",children:"Loading payload snapshot..."})]}):se?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:Hd(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:Hd(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(Tn,{children:h.jsx(Me,{variant:"default",size:"sm",onClick:()=>k(null),children:"Close"})})]})}),h.jsx(Dr,{open:A,onOpenChange:ae=>{ae||N(!1)},children:h.jsxs(lr,{children:[h.jsx(cr,{children:h.jsx(ur,{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(Tn,{children:[h.jsx(Me,{variant:"default",size:"sm",onClick:()=>N(!1),children:"Cancel"}),h.jsx(Me,{variant:"destructive",size:"sm",onClick:de,disabled:z.isPending,children:z.isPending?"Clearing...":"Clear all"})]})]})})]})}const rQ=so({getParentRoute:()=>io,path:"/config",component:SX}),sQ=so({getParentRoute:()=>io,path:"/fleet",component:kX}),oQ=so({getParentRoute:()=>io,path:"/",component:xX});function iQ(){const{seq:e}=_O.useParams();return h.jsx(bx,{initialSelectedEntryId:`#${e}`})}const _O=so({getParentRoute:()=>io,path:"/investigate/commit/$seq",component:iQ});function aQ(){const{id:e}=wO.useParams();return h.jsx(bx,{initialSelectedEntryId:`E${e}`})}const wO=so({getParentRoute:()=>io,path:"/investigate/event/$id",component:aQ}),lQ=so({getParentRoute:()=>io,path:"/ops",component:BX}),cQ=so({getParentRoute:()=>io,path:"/storage",component:XX}),uQ=so({getParentRoute:()=>io,path:"/stream",component:bx}),fQ=io.addChildren([oQ,uQ,_O,wO,sQ,lQ,cQ,rQ]),dQ="syncular-console-basepath",hQ="syncular-console-server-url",pQ="syncular-console-token";function mQ(e){if(!e)return;const t=e.trim();return t.length>0?t:void 0}function $v(e){const t=globalThis.document;if(!t)return;const n=t.querySelector(`meta[name="${e}"]`)?.getAttribute("content");return mQ(n)}function EO(e){return!e||e==="/"?"/":(e.startsWith("/")?e:`/${e}`).replace(/\/+$/g,"")||"/"}function gQ(){return EO($v(dQ))}function yQ(){const e=$v(hQ),t=$v(pQ);return!e||!t?null:{serverUrl:e,token:t}}function vQ(){return new z6({defaultOptions:{queries:{staleTime:5e3,retry:1}}})}function bQ(e){return EO(e??gQ())}function xQ(e){const[t]=_.useState(()=>vQ()),n=_.useMemo(()=>qH({routeTree:fQ,basepath:bQ(e.basePath)}),[e.basePath]),s=e.defaultConfig===void 0?yQ():e.defaultConfig,i=e.autoConnect??e.defaultConfig===void 0;return h.jsx(L6,{client:t,children:h.jsx(oq,{defaultConfig:s,autoConnect:i,storageMode:e.storageMode,children:h.jsx(GH,{router:n})})})}function SQ(e){return h.jsx("div",{className:vx,children:h.jsx(xQ,{...e})})}function _Q(e){const t=document.querySelector(e);if(!t)throw new Error(`Unable to mount console: ${e} not found`);return t}function wQ(e,t={}){const n=_Q(e);rX(n);const s=h6.createRoot(n),i=h.jsx(SQ,{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 EQ={};const TQ="syncular-sentry-dsn",CQ="syncular-sentry-environment",RQ="syncular-sentry-release";function hu(e){if(!e)return;const t=e.trim();return t.length>0?t:void 0}function $y(e){if(typeof document>"u")return;const t=document.querySelector(`meta[name="${e}"]`)?.getAttribute("content");return hu(t)}function By(e){if(!(typeof process>"u"))return hu(EQ[e])}function Fy(e){for(const t of e)if(t)return t}function NQ(){const e=Fy([hu(globalThis.__SYNCULAR_SENTRY_DSN__),$y(TQ),By("SYNCULAR_SENTRY_DSN")]);if(!e)return null;const t=Fy([hu(globalThis.__SYNCULAR_SENTRY_ENVIRONMENT__),$y(CQ),By("SYNCULAR_SENTRY_ENVIRONMENT")]),n=Fy([hu(globalThis.__SYNCULAR_SENTRY_RELEASE__),$y(RQ),By("SYNCULAR_SENTRY_RELEASE")]);return{dsn:e,environment:t,release:n,enableLogs:!0,tracesSampleRate:.2,tracePropagationTargets:[/^https?:\/\/.*\/api\/.*/]}}const JC=NQ();JC&&s6(JC);wQ("#root");
|
package/web-dist/index.html
CHANGED
|
@@ -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-
|
|
13
|
+
<script type="module" crossorigin src="/assets/index-B1BCMzGq.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">
|