@syncular/console 0.0.6-223 → 0.0.6-224

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-223",
3
+ "version": "0.0.6-224",
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-223",
72
- "@syncular/transport-http": "0.0.6-223",
73
- "@syncular/ui": "0.0.6-223",
71
+ "@syncular/observability-sentry": "0.0.6-224",
72
+ "@syncular/transport-http": "0.0.6-224",
73
+ "@syncular/ui": "0.0.6-224",
74
74
  "@tanstack/react-query": "^5.90.21",
75
75
  "@tanstack/react-router": "^1.163.2",
76
76
  "lucide-react": "^0.575.0"
@@ -45,4 +45,4 @@ ${l}
45
45
  ${u.right}px ${u.bottom}px,
46
46
  ${u.right}px ${u.top}px,
47
47
  ${u.left}px ${u.top}px
48
- )`}return d.jsx("div",{ref:n,role:"presentation","data-base-ui-inert":"",...o,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:l}})});function lh(e,t){e&&Object.assign(e.style,t)}const Kq={position:"relative",maxHeight:"100%",overflowX:"hidden",overflowY:"auto"},Yq={position:"fixed"},Xq=S.forwardRef(function(t,n){const{anchor:i,positionMethod:o="absolute",className:l,render:u,side:f="bottom",align:h="center",sideOffset:p=0,alignOffset:y=0,collisionBoundary:v="clipping-ancestors",collisionPadding:b,arrowPadding:x=5,sticky:E=!1,disableAnchorTracking:_,alignItemWithTrigger:T=!0,collisionAvoidance:C=JU,...M}=t,{store:R,listRef:N,labelsRef:k,alignItemWithTriggerActiveRef:z,selectedItemTextRef:j,valuesRef:A,initialValueRef:D,popupRef:G,setValue:F}=gu(),P=FN(),Q=st(R,rt.open),X=st(R,rt.mounted),te=st(R,rt.modal),L=st(R,rt.value),$=st(R,rt.openMethod),H=st(R,rt.positionerElement),V=st(R,rt.triggerElement),U=st(R,rt.isItemEqualToValue),I=st(R,rt.transitionStatus),K=S.useRef(null),Z=S.useRef(null),[W,se]=S.useState(T),ie=X&&W&&$!=="touch";!X&&W!==T&&se(T),De(()=>{X||(rt.scrollUpArrowVisible(R.state)&&R.set("scrollUpArrowVisible",!1),rt.scrollDownArrowVisible(R.state)&&R.set("scrollDownArrowVisible",!1))},[R,X]),S.useImperativeHandle(z,()=>ie),qN((ie||te)&&Q&&$!=="touch",V);const he=zN({anchor:i,floatingRootContext:P,positionMethod:o,mounted:X,side:f,sideOffset:p,align:h,alignOffset:y,arrowPadding:x,collisionBoundary:v,collisionPadding:b,sticky:E,disableAnchorTracking:_??ie,collisionAvoidance:C,keepMounted:!0}),xe=ie?"none":he.side,de=ie?Yq:he.positionerStyles,Be=S.useMemo(()=>{const be={};return Q||(be.pointerEvents="none"),{role:"presentation",hidden:!X,style:{...de,...be}}},[Q,X,de]),_e={open:Q,side:xe,align:he.align,anchorHidden:he.anchorHidden},re=je(be=>{R.set("positionerElement",be)}),fe=At("div",t,{ref:[n,re],state:_e,stateAttributesMapping:Nl,props:[Be,Ph(I),M]}),ae=S.useRef(0),Se=je(be=>{if(be.size===0&&ae.current===0||A.current.length===0)return;const ge=ae.current;if(ae.current=be.size,be.size===ge)return;const Le=Pt(Pi);if(ge!==0&&!R.state.multiple&&L!==null&&$g(A.current,L,U)===-1){const Ee=D.current,Ke=Ee!=null&&$g(A.current,Ee,U)!==-1?Ee:null;F(Ke,Le),Ke===null&&(R.set("selectedIndex",null),j.current=null)}if(ge!==0&&R.state.multiple&&Array.isArray(L)){const Oe=Fe=>$g(A.current,Fe,U)!==-1,Ee=L.filter(Fe=>Oe(Fe));(Ee.length!==L.length||Ee.some(Fe=>!_q(L,Fe,U)))&&(F(Ee,Le),Ee.length===0&&(R.set("selectedIndex",null),j.current=null))}if(Q&&ie){R.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});const Oe={height:""};lh(H,Oe),lh(G.current,Oe)}}),ye=S.useMemo(()=>({...he,side:xe,alignItemWithTriggerActive:ie,setControlledAlignItemWithTrigger:se,scrollUpArrowRef:K,scrollDownArrowRef:Z}),[he,xe,ie,se]);return d.jsx($N,{elementsRef:N,labelsRef:k,onMapChange:Se,children:d.jsxs(GN.Provider,{value:ye,children:[X&&te&&d.jsx(KN,{inert:cb(!Q),cutout:V}),fe]})})});function YN(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 id="base-ui-disable-scrollbar",pT={className:id,getElement(e){return d.jsx("style",{nonce:e,href:id,precedence:"base-ui:low",children:`.${id}{scrollbar-width:none}.${id}::-webkit-scrollbar{display:none}`})}},Qq=S.createContext(void 0);function XN(e){return S.useContext(Qq)}const Xa="ArrowUp",Ro="ArrowDown",Wc="ArrowLeft",Qa="ArrowRight",yu="Home",vu="End",QN=new Set([Wc,Qa]),Wq=new Set([Wc,Qa,yu,vu]),WN=new Set([Xa,Ro]),Zq=new Set([Xa,Ro,yu,vu]),ZN=new Set([...QN,...WN]),Jq=new Set([...ZN,yu,vu]),JN=new Set([Xa,Ro,Wc,Qa,yu,vu]),e8="Shift",t8="Control",n8="Alt",r8="Meta",s8=new Set([e8,t8,n8,r8]);function i8(e){return Lt(e)&&e.tagName==="INPUT"}function mT(e){return!!(i8(e)&&e.selectionStart!=null||Lt(e)&&e.tagName==="TEXTAREA")}function gT(e,t,n,i){if(!e||!t||!t.scrollTo)return;let o=e.scrollLeft,l=e.scrollTop;const u=e.clientWidth<e.scrollWidth,f=e.clientHeight<e.scrollHeight;if(u&&i!=="vertical"){const h=yT(e,t,"left"),p=od(e),y=od(t);n==="ltr"&&(h+t.offsetWidth+y.scrollMarginRight>e.scrollLeft+e.clientWidth-p.scrollPaddingRight?o=h+t.offsetWidth+y.scrollMarginRight-e.clientWidth+p.scrollPaddingRight:h-y.scrollMarginLeft<e.scrollLeft+p.scrollPaddingLeft&&(o=h-y.scrollMarginLeft-p.scrollPaddingLeft)),n==="rtl"&&(h-y.scrollMarginRight<e.scrollLeft+p.scrollPaddingLeft?o=h-y.scrollMarginLeft-p.scrollPaddingLeft:h+t.offsetWidth+y.scrollMarginRight>e.scrollLeft+e.clientWidth-p.scrollPaddingRight&&(o=h+t.offsetWidth+y.scrollMarginRight-e.clientWidth+p.scrollPaddingRight))}if(f&&i!=="horizontal"){const h=yT(e,t,"top"),p=od(e),y=od(t);h-y.scrollMarginTop<e.scrollTop+p.scrollPaddingTop?l=h-y.scrollMarginTop-p.scrollPaddingTop:h+t.offsetHeight+y.scrollMarginBottom>e.scrollTop+e.clientHeight-p.scrollPaddingBottom&&(l=h+t.offsetHeight+y.scrollMarginBottom-e.clientHeight+p.scrollPaddingBottom)}e.scrollTo({left:o,top:l,behavior:"auto"})}function yT(e,t,n){const i=n==="left"?"offsetLeft":"offsetTop";let o=0;for(;t.offsetParent&&(o+=t[i],t.offsetParent!==e);)t=t.offsetParent;return o}function od(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 Gg(e,t=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(t,Math.min(e,n))}const o8=S.createContext(void 0),a8={disableStyleElements:!1};function l8(){return S.useContext(o8)??a8}const xo=1,c8={...Nl,...Ko},u8=S.forwardRef(function(t,n){const{render:i,className:o,finalFocus:l,...u}=t,{store:f,popupRef:h,onOpenChangeComplete:p,setOpen:y,valueRef:v,selectedItemTextRef:b,keyboardActiveRef:x,multiple:E,handleScrollArrowVisibility:_,scrollHandlerRef:T,highlightItemOnHover:C}=gu(),{side:M,align:R,alignItemWithTriggerActive:N,setControlledAlignItemWithTrigger:k,scrollDownArrowRef:z,scrollUpArrowRef:j}=Gq(),A=XN()!=null,D=FN(),{nonce:G,disableStyleElements:F}=l8(),P=zr(),Q=st(f,rt.id),X=st(f,rt.open),te=st(f,rt.mounted),L=st(f,rt.popupProps),$=st(f,rt.transitionStatus),H=st(f,rt.triggerElement),V=st(f,rt.positionerElement),U=st(f,rt.listElement),I=S.useRef(0),K=S.useRef(!1),Z=S.useRef(0),W=S.useRef(!1),se=S.useRef({}),ie=rb(),he=je(_e=>{if(!V||!h.current||!W.current)return;if(K.current||!N){_();return}const re=V.style.top==="0px",fe=V.style.bottom==="0px",ae=V.getBoundingClientRect().height,Se=_t(V),ye=getComputedStyle(V),be=parseFloat(ye.marginTop),ge=parseFloat(ye.marginBottom),Le=vT(getComputedStyle(h.current)),Oe=Math.min(Se.documentElement.clientHeight-be-ge,Le),Ee=_e.scrollTop,Fe=bT(_e);let Ke=0,ze=null,Xe=!1,Ue=!1;const pe=He=>{V.style.height=`${He}px`},we=(He,dt)=>{const ot=Gg(He,0,Oe-ae);ot>0&&pe(ae+ot),_e.scrollTop=dt,Oe-(ae+ot)<=xo&&(K.current=!0),_()};if(re){const He=Fe-Ee,dt=ae+He,ot=Math.min(dt,Oe);if(Ke=ot,He<=xo){we(He,Fe);return}Oe-ot>xo?Ue=!0:Xe=!0}else if(fe){const He=Ee,dt=ae+He,ot=Math.min(dt,Oe),or=dt-Oe;if(Ke=ot,He<=xo){we(He,0);return}Oe-ot>xo?ze=0:(Xe=!0,Ee<Fe&&(ze=Ee-(He-or)))}if(Ke=Math.ceil(Ke),Ke!==0&&pe(Ke),Ue||ze!=null){const He=bT(_e),dt=Ue?He:Gg(ze,0,He);Math.abs(_e.scrollTop-dt)>xo&&(_e.scrollTop=dt)}(Xe||Ke>=Oe-xo)&&(K.current=!0),_()});S.useImperativeHandle(T,()=>he,[he]),Yo({open:X,ref:h,onComplete(){X&&p?.(!0)}});const xe={open:X,transitionStatus:$,side:M,align:R};De(()=>{!V||!h.current||Object.keys(se.current).length||(se.current={top:V.style.top||"0",left:V.style.left||"0",right:V.style.right,height:V.style.height,bottom:V.style.bottom,minHeight:V.style.minHeight,maxHeight:V.style.maxHeight,marginTop:V.style.marginTop,marginBottom:V.style.marginBottom})},[h,V]),De(()=>{X||N||(W.current=!1,K.current=!1,I.current=0,Z.current=0,lh(V,se.current))},[X,N,V,h]),De(()=>{const _e=h.current;if(!(!X||!H||!V||!_e||f.state.transitionStatus==="ending")){if(!N){W.current=!0,ie.request(_),_e.style.removeProperty("--transform-origin");return}queueMicrotask(()=>{const re=f8(_e);_e.style.removeProperty("--transform-origin");try{const fe=getComputedStyle(V),ae=getComputedStyle(_e),Se=_t(H),ye=Xt(V),be=H.getBoundingClientRect(),ge=V.getBoundingClientRect(),Le=be.left,Oe=be.height,Ee=U||_e,Fe=Ee.scrollHeight,Ke=parseFloat(ae.borderBottomWidth),ze=parseFloat(fe.marginTop)||10,Xe=parseFloat(fe.marginBottom)||10,Ue=parseFloat(fe.minHeight)||100,pe=vT(ae),we=5,He=5,dt=20,ot=Se.documentElement.clientHeight-ze-Xe,or=Se.documentElement.clientWidth,ar=ot-be.bottom+Oe,Ut=b.current,at=v.current;let yt,nt=0,Bt=0;if(Ut&&at){const Pn=at.getBoundingClientRect();yt=Ut.getBoundingClientRect();const $r=Pn.left-Le,$s=yt.left-ge.left,Gs=Pn.top-be.top+Pn.height/2,zn=yt.top-ge.top+yt.height/2;nt=$r-$s,Bt=zn-Gs}const rn=ar+Bt+Xe+Ke;let Ct=Math.min(ot,rn);const dn=ot-ze-Xe,Ln=rn-Ct,gn=Math.max(we,Le+nt),qr=or-He,Vr=Math.max(0,gn+ge.width-qr);V.style.left=`${gn-Vr}px`,V.style.height=`${Ct}px`,V.style.maxHeight="auto",V.style.marginTop=`${ze}px`,V.style.marginBottom=`${Xe}px`,_e.style.height="100%";const Qo=Ee.scrollHeight-Ee.clientHeight,Wi=Ln>=Qo;Wi&&(Ct=Math.min(ot,ge.height)-(Ln-Qo));const Zi=be.top<dt||be.bottom>ot-dt||Ct<Math.min(Fe,Ue),is=(ye.visualViewport?.scale??1)!==1&&Jv;if(Zi||is){W.current=!0,lh(V,se.current),Fi.flushSync(()=>k(!1));return}if(Wi){const Pn=Math.max(0,ot-rn);V.style.top=ge.height>=dn?"0":`${Pn}px`,V.style.height=`${Ct}px`,Ee.scrollTop=Ee.scrollHeight-Ee.clientHeight,I.current=Math.max(Ue,Ct)}else V.style.bottom="0",I.current=Math.max(Ue,Ct),Ee.scrollTop=Ln;if(yt){const Pn=ge.top,$r=ge.height,$s=yt.top+yt.height/2,Gs=$r>0?($s-Pn)/$r*100:50,zn=Gg(Gs,0,100);_e.style.setProperty("--transform-origin",`50% ${zn}%`)}(I.current===ot||Ct>=pe)&&(K.current=!0),_(),setTimeout(()=>{W.current=!0})}finally{re()}})}},[f,X,V,H,v,b,h,_,N,k,ie,z,j,U]),S.useEffect(()=>{if(!N||!V||!X)return;const _e=Xt(V);function re(fe){y(!1,Pt(wB,fe))}return _e.addEventListener("resize",re),()=>{_e.removeEventListener("resize",re)}},[y,N,V,X]);const de={...U?{role:"presentation","aria-orientation":void 0}:{role:"listbox","aria-multiselectable":E||void 0,id:`${Q}-list`},onKeyDown(_e){x.current=!0,A&&JN.has(_e.key)&&_e.stopPropagation()},onMouseMove(){x.current=!1},onPointerLeave(_e){if(!C||YN(_e)||_e.pointerType==="touch")return;const re=_e.currentTarget;P.start(0,()=>{f.set("activeIndex",null),re.focus({preventScroll:!0})})},onScroll(_e){U||he(_e.currentTarget)},...N&&{style:U?{height:"100%"}:Kq}},Be=At("div",t,{ref:[n,h],state:xe,stateAttributesMapping:c8,props:[L,de,Ph($),{className:!U&&N?pT.className:void 0},u]});return d.jsxs(S.Fragment,{children:[!F&&pT.getElement(G),d.jsx(wN,{context:D,modal:!1,disabled:!te,returnFocus:l,restoreFocus:!0,children:Be})]})});function vT(e){const t=e.maxHeight||"";return t.endsWith("px")&&parseFloat(t)||1/0}function bT(e){return Math.max(0,e.scrollHeight-e.clientHeight)}const xT=[["transform","none"],["scale","1"],["translate","0 0"]];function f8(e){const{style:t}=e,n={};for(const[i,o]of xT)n[i]=t.getPropertyValue(i),t.setProperty(i,o,"important");return()=>{for(const[i]of xT){const o=n[i];o?t.setProperty(i,o):t.removeProperty(i)}}}let ej=(function(e){return e[e.None=0]="None",e[e.GuessFromOrder=1]="GuessFromOrder",e})({});function ub(e={}){const{label:t,metadata:n,textRef:i,indexGuessBehavior:o,index:l}=e,{register:u,unregister:f,subscribeMapChange:h,elementsRef:p,labelsRef:y,nextIndexRef:v}=Fq(),b=S.useRef(-1),[x,E]=S.useState(l??(o===ej.GuessFromOrder?()=>{if(b.current===-1){const C=v.current;v.current+=1,b.current=C}return b.current}:-1)),_=S.useRef(null),T=S.useCallback(C=>{if(_.current=C,x!==-1&&C!==null&&(p.current[x]=C,y)){const M=t!==void 0;y.current[x]=M?t:i?.current?.textContent??C.textContent}},[x,p,y,t,i]);return De(()=>{if(l!=null)return;const C=_.current;if(C)return u(C,n),()=>{f(C)}},[l,u,f,n]),De(()=>{if(l==null)return h(C=>{const M=_.current?C.get(_.current)?.index:null;M!=null&&E(M)})},[l,h,E]),S.useMemo(()=>({ref:T,index:x}),[x,T])}const d8=S.createContext(void 0),h8=S.memo(S.forwardRef(function(t,n){const{render:i,className:o,value:l=null,label:u,disabled:f=!1,nativeButton:h=!1,...p}=t,y=S.useRef(null),v=ub({label:u,textRef:y,indexGuessBehavior:ej.GuessFromOrder}),{store:b,getItemProps:x,setOpen:E,setValue:_,selectionRef:T,typingRef:C,valuesRef:M,keyboardActiveRef:R,multiple:N,highlightItemOnHover:k}=gu(),z=zr(),j=st(b,rt.isActive,v.index),A=st(b,rt.isSelected,v.index,l),D=st(b,rt.isSelectedByFocus,v.index),G=st(b,rt.isItemEqualToValue),F=v.index,P=F!==-1,Q=S.useRef(null),X=ki(F);De(()=>{if(!P)return;const ie=M.current;return ie[F]=l,()=>{delete ie[F]}},[P,F,l,M]),De(()=>{if(!P)return;const ie=b.state.value;let he=ie;N&&Array.isArray(ie)&&ie.length>0&&(he=ie[ie.length-1]),he!==void 0&&ul(l,he,G)&&b.set("selectedIndex",F)},[P,F,N,G,b,l]);const te={disabled:f,selected:A,highlighted:j},L=x({active:j,selected:A});L.onFocus=void 0,L.id=void 0;const $=S.useRef(null),H=S.useRef("mouse"),V=S.useRef(!1),{getButtonProps:U,buttonRef:I}=El({disabled:f,focusableWhenDisabled:!0,native:h});function K(ie){const he=b.state.value;if(N){const xe=Array.isArray(he)?he:[],de=A?wq(xe,l,G):[...xe,l];_(de,Pt(Ig,ie))}else _(l,Pt(Ig,ie)),E(!1,Pt(Ig,ie))}const Z={role:"option","aria-selected":A,tabIndex:j?0:-1,onFocus(){b.set("activeIndex",F)},onMouseEnter(){!R.current&&b.state.selectedIndex===null&&k&&b.set("activeIndex",F)},onMouseMove(){k&&b.set("activeIndex",F)},onMouseLeave(ie){!k||R.current||YN(ie)||z.start(0,()=>{b.state.activeIndex===F&&b.set("activeIndex",null)})},onTouchStart(){T.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1}},onKeyDown(ie){$.current=ie.key,b.set("activeIndex",F)},onClick(ie){V.current=!1,!(ie.type==="keydown"&&$.current===null)&&(f||$.current===" "&&C.current||H.current!=="touch"&&!j||($.current=null,K(ie.nativeEvent)))},onPointerEnter(ie){H.current=ie.pointerType},onPointerDown(ie){H.current=ie.pointerType,V.current=!0},onMouseUp(ie){if(f)return;if(V.current){V.current=!1;return}const he=!T.current.allowSelectedMouseUp&&A,xe=!T.current.allowUnselectedMouseUp&&!A;he||xe||H.current!=="touch"&&!j||K(ie.nativeEvent)}},W=At("div",t,{ref:[I,n,v.ref,Q],state:te,props:[L,Z,p,U]}),se=S.useMemo(()=>({selected:A,indexRef:X,textRef:y,selectedByFocus:D,hasRegistered:P}),[A,X,y,D,P]);return d.jsx(d8.Provider,{value:se,children:W})})),p8=S.forwardRef(({className:e,children:t,...n},i)=>d.jsx(kq,{ref:i,className:me("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}));p8.displayName="SelectTrigger";const m8=S.forwardRef(({className:e,portalProps:t,positionerProps:n,...i},o)=>d.jsx(Dq,{...t,children:d.jsx(Xq,{...n,children:d.jsx(u8,{ref:o,className:me("bg-panel border border-border rounded-md py-1 shadow-lg z-50",e),...i})})}));m8.displayName="SelectContent";const g8=S.forwardRef(({className:e,...t},n)=>d.jsx(h8,{ref:n,className:me("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}));g8.displayName="SelectItem";const y8=S.forwardRef(({className:e,...t},n)=>d.jsx("textarea",{ref:n,className:me("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}));y8.displayName="Textarea";const tj=S.createContext(void 0);function v8(e=!0){const t=S.useContext(tj);if(t===void 0&&!e)throw new Error(nn(7));return t}function nj(e={}){const{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:i}=M1(),{ref:o,index:l}=ub(e),u=n===l,f=S.useRef(null),h=Us(o,f);return{compositeProps:S.useMemo(()=>({tabIndex:u?0:-1,onFocus(){i(l)},onMouseMove(){const y=f.current;if(!t||!y)return;const v=y.hasAttribute("disabled")||y.ariaDisabled==="true";!u&&!v&&y.focus()}}),[u,i,l,t]),compositeRef:h,index:l}}function b8(e){const{render:t,className:n,state:i=Kt,props:o=Yc,refs:l=Yc,metadata:u,stateAttributesMapping:f,tag:h="div",...p}=e,{compositeProps:y,compositeRef:v}=nj({metadata:u});return At(h,e,{state:i,ref:[...l,v],props:[y,...o,p],stateAttributesMapping:f})}const x8=S.forwardRef(function(t,n){const{className:i,defaultPressed:o=!1,disabled:l=!1,form:u,onPressedChange:f,pressed:h,render:p,type:y,value:v,nativeButton:b=!0,...x}=t,E=tr(v||void 0),_=v8(),T=_?.value??[],C=_?void 0:o,M=(l||_?.disabled)??!1,[R,N]=_h({controlled:_?E!==void 0&&T.indexOf(E)>-1:h,default:C,name:"Toggle",state:"pressed"}),k=je((P,Q)=>{E&&_?.setGroupValue?.(E,P,Q),f?.(P,Q)}),{getButtonProps:z,buttonRef:j}=El({disabled:M,native:b}),A={disabled:M,pressed:R},D=[j,n],G=[{"aria-pressed":R,onClick(P){const Q=!R,X=Pt(Pi,P.nativeEvent);k(Q,X),!X.isCanceled&&N(Q)}},x,z],F=At("button",t,{enabled:!_,state:A,ref:D,props:G});return _?d.jsx(b8,{tag:"button",render:p,className:i,state:A,refs:D,props:G}):F}),rj=S.forwardRef(({className:e,...t},n)=>d.jsx(x8,{ref:n,className:me("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}));rj.displayName="Toggle";function S8(e){return e==null||e.hasAttribute("disabled")||e.getAttribute("aria-disabled")==="true"}const sj="data-composite-item-active",E8=[];function _8(e){const{itemSizes:t,cols:n=1,loopFocus:i=!0,dense:o=!1,orientation:l="both",direction:u,highlightedIndex:f,onHighlightedIndexChange:h,rootRef:p,enableHomeAndEndKeys:y=!1,stopEventPropagation:v=!1,disabledIndices:b,modifierKeys:x=E8}=e,[E,_]=S.useState(0),T=n>1,C=S.useRef(null),M=Us(C,p),R=S.useRef([]),N=S.useRef(!1),k=f??E,z=je((D,G=!1)=>{if((h??_)(D),G){const F=R.current[D];gT(C.current,F,u,l)}}),j=je(D=>{if(D.size===0||N.current)return;N.current=!0;const G=Array.from(D.keys()),F=G.find(Q=>Q?.hasAttribute(sj))??null,P=F?G.indexOf(F):-1;P!==-1&&z(P),gT(C.current,F,u,l)}),A=S.useMemo(()=>({"aria-orientation":l==="both"?void 0:l,ref:M,onFocus(D){!C.current||!mT(D.target)||D.target.setSelectionRange(0,D.target.value.length??0)},onKeyDown(D){const G=y?Jq:ZN;if(!G.has(D.key)||w8(D,x)||!C.current)return;const P=u==="rtl",Q=P?Wc:Qa,X={horizontal:Q,vertical:Ro,both:Q}[l],te=P?Qa:Wc,L={horizontal:te,vertical:Xa,both:te}[l];if(mT(D.target)&&!S8(D.target)){const Z=D.target.selectionStart,W=D.target.selectionEnd,se=D.target.value??"";if(Z==null||D.shiftKey||Z!==W||D.key!==L&&Z<se.length||D.key!==X&&Z>0)return}let $=k;const H=zH(R,b),V=UH(R,b);if(T){const Z=t||Array.from({length:R.current.length},()=>({width:1,height:1})),W=HH(Z,n,o),se=W.findIndex(he=>he!=null&&!Dc(R,he,b)),ie=W.reduce((he,xe,de)=>xe!=null&&!Dc(R,xe,b)?de:he,-1);$=W[BH({current:W.map(he=>he?R.current[he]:null)},{event:D,orientation:l,loopFocus:i,cols:n,disabledIndices:qH([...b||R.current.map((he,xe)=>Dc(R,xe)?xe:void 0),void 0],W),minIndex:se,maxIndex:ie,prevIndex:FH(k>V?H:k,Z,W,n,D.key===Ro?"bl":D.key===Qa?"tr":"tl"),rtl:P})]}const U={horizontal:[Q],vertical:[Ro],both:[Q,Ro]}[l],I={horizontal:[te],vertical:[Xa],both:[te,Xa]}[l],K=T?G:{horizontal:y?Wq:QN,vertical:y?Zq:WN,both:G}[l];y&&(D.key===yu?$=H:D.key===vu&&($=V)),$===k&&(U.includes(D.key)||I.includes(D.key))&&(i&&$===V&&U.includes(D.key)?$=H:i&&$===H&&I.includes(D.key)?$=V:$=Kn(R,{startingIndex:$,decrement:I.includes(D.key),disabledIndices:b})),$!==k&&!Ed(R,$)&&(v&&D.stopPropagation(),K.has(D.key)&&D.preventDefault(),z($,!0),queueMicrotask(()=>{R.current[$]?.focus()}))}}),[n,o,u,b,R,y,k,T,t,i,M,x,z,l,v]);return S.useMemo(()=>({props:A,highlightedIndex:k,onHighlightedIndexChange:z,elementsRef:R,disabledIndices:b,onMapChange:j,relayKeyboardEvent:A.onKeyDown}),[A,k,z,R,b,j])}function w8(e,t){for(const n of s8.values())if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function ij(e){const{render:t,className:n,refs:i=Yc,props:o=Yc,state:l=Kt,stateAttributesMapping:u,highlightedIndex:f,onHighlightedIndexChange:h,orientation:p,dense:y,itemSizes:v,loopFocus:b,cols:x,enableHomeAndEndKeys:E,onMapChange:_,stopEventPropagation:T=!0,rootRef:C,disabledIndices:M,modifierKeys:R,highlightItemOnHover:N=!1,tag:k="div",...z}=e,j=LN(),{props:A,highlightedIndex:D,onHighlightedIndexChange:G,elementsRef:F,onMapChange:P,relayKeyboardEvent:Q}=_8({itemSizes:v,cols:x,loopFocus:b,dense:y,orientation:p,highlightedIndex:f,onHighlightedIndexChange:h,rootRef:C,stopEventPropagation:T,enableHomeAndEndKeys:E,direction:j,disabledIndices:M,modifierKeys:R}),X=At(k,e,{state:l,ref:i,props:[A,...o,z],stateAttributesMapping:u}),te=S.useMemo(()=>({highlightedIndex:D,onHighlightedIndexChange:G,highlightItemOnHover:N,relayKeyboardEvent:Q}),[D,G,N,Q]);return d.jsx(j1.Provider,{value:te,children:d.jsx($N,{elementsRef:F,onMapChange:L=>{_?.(L),P(L)},children:X})})}let T8=(function(e){return e.disabled="data-disabled",e.orientation="data-orientation",e.multiple="data-multiple",e})({});const ST={multiple(e){return e?{[T8.multiple]:""}:null}},C8=S.forwardRef(function(t,n){const{defaultValue:i,disabled:o=!1,loopFocus:l=!0,onValueChange:u,orientation:f="horizontal",multiple:h=!1,value:p,className:y,render:v,...b}=t,x=XN(),E=S.useMemo(()=>{if(p===void 0)return i??[]},[p,i]),_=S.useMemo(()=>p!==void 0||i!==void 0,[p,i]),T=(x?.disabled??!1)||o,[C,M]=_h({controlled:p,default:E,name:"ToggleGroup",state:"value"}),R=je((A,D,G)=>{let F;if(h?(F=C.slice(),D?F.push(A):F.splice(C.indexOf(A),1)):F=D?[A]:[],Array.isArray(F)){if(u?.(F,G),G.isCanceled)return;M(F)}}),N={disabled:T,multiple:h,orientation:f},k=S.useMemo(()=>({disabled:T,orientation:f,setGroupValue:R,value:C,isValueInitialized:_}),[T,f,R,C,_]),z={role:"group"},j=At("div",t,{enabled:!!x,state:N,ref:n,props:[z,b],stateAttributesMapping:ST});return d.jsx(tj.Provider,{value:k,children:x?j:d.jsx(ij,{render:v,className:y,state:N,refs:[n],props:[z,b],stateAttributesMapping:ST,loopFocus:l,enableHomeAndEndKeys:!0})})}),Cd=S.forwardRef(({className:e,...t},n)=>d.jsx(C8,{ref:n,className:me("flex items-center gap-0.5",e),...t}));Cd.displayName="ToggleGroup";const R8=me(q1({variant:"secondary",size:"sm"}),"h-7 whitespace-nowrap uppercase tracking-[0.08em] leading-none no-underline");function oj({active:e,onClick:t,children:n,className:i}){return d.jsxs("button",{type:"button",onClick:t,className:me("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",i),children:[n,e&&d.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 N8({items:e,activeId:t,onItemChange:n,renderItem:i,className:o}){return d.jsx("div",{className:me("flex items-center gap-0.5",o),children:e.map(l=>{const u=l.id===t,f=()=>n?.(l.id);return i?d.jsx("span",{children:i(l,{active:u,onClick:f})},l.id):d.jsx(oj,{active:u,onClick:f,children:l.label},l.id)})})}const j8=Vi("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}}),M8={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 A8({color:e,size:t,glow:n,pulse:i,className:o}){return d.jsx("span",{className:me(j8({color:e,size:t,glow:n}),i&&"dot-pulse",o),style:n?{boxShadow:M8[e??"healthy"]}:void 0})}const O8="0.0.6-223",k8={version:O8},I8=k8.version;function D8({label:e,className:t}){return d.jsxs("div",{className:me("flex items-center gap-3",t),children:[d.jsx(A8,{color:"healthy",size:"md",glow:!0}),d.jsx("span",{className:"font-display font-bold text-white text-sm tracking-tight",children:"syncular"}),e&&d.jsx("span",{className:"font-mono text-[9px] text-neutral-600 uppercase tracking-widest",children:e}),d.jsxs("span",{className:"font-mono text-[9px] text-neutral-600 tracking-wider",children:["v",I8]})]})}function L8({brand:e,center:t,right:n,className:i}){return d.jsxs(d.Fragment,{children:[d.jsx("div",{"aria-hidden":"true",className:"h-[42px] shrink-0"}),d.jsxs("nav",{className:me("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",i),children:[d.jsx("div",{className:"flex items-center gap-3",children:e}),d.jsx("div",{className:"flex items-center gap-0.5",children:t}),d.jsx("div",{className:"flex items-center gap-2",children:n})]})]})}const P8=Vi("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"}}),bn=S.forwardRef(({className:e,variant:t,...n},i)=>d.jsx("div",{ref:i,role:"alert",className:me(P8({variant:t,className:e})),...n}));bn.displayName="Alert";const bu=S.forwardRef(({className:e,...t},n)=>d.jsx("h5",{ref:n,className:me("font-medium text-white mb-1",e),...t}));bu.displayName="AlertTitle";const xn=S.forwardRef(({className:e,...t},n)=>d.jsx("p",{ref:n,className:me("text-neutral-400",e),...t}));xn.displayName="AlertDescription";const aj=S.createContext(void 0);function jl(e){const t=S.useContext(aj);if(e===!1&&t===void 0)throw new Error(nn(27));return t}const z8={...Nl,...Ko},fb=S.forwardRef(function(t,n){const{render:i,className:o,forceRender:l=!1,...u}=t,{store:f}=jl(),h=f.useState("open"),p=f.useState("nested"),y=f.useState("mounted"),v=f.useState("transitionStatus");return At("div",t,{state:{open:h,transitionStatus:v},ref:[f.context.backdropRef,n],stateAttributesMapping:z8,props:[{role:"presentation",hidden:!y,style:{userSelect:"none",WebkitUserSelect:"none"}},u],enabled:l||!p})}),lj=S.forwardRef(function(t,n){const{render:i,className:o,id:l,...u}=t,{store:f}=jl(),h=tr(l);return f.useSyncedValueWithCleanup("descriptionElementId",h),At("p",t,{ref:n,props:[{id:h},u]})});let U8=(function(e){return e.nestedDialogs="--nested-dialogs",e})({}),B8=(function(e){return e[e.open=Co.open]="open",e[e.closed=Co.closed]="closed",e[e.startingStyle=Co.startingStyle]="startingStyle",e[e.endingStyle=Co.endingStyle]="endingStyle",e.nested="data-nested",e.nestedDialogOpen="data-nested-dialog-open",e})({});const cj=S.createContext(void 0);function H8(){const e=S.useContext(cj);if(e===void 0)throw new Error(nn(26));return e}const F8={...Nl,...Ko,nestedDialogOpen(e){return e?{[B8.nestedDialogOpen]:""}:null}},uj=S.forwardRef(function(t,n){const{className:i,finalFocus:o,initialFocus:l,render:u,...f}=t,{store:h}=jl(),p=h.useState("descriptionElementId"),y=h.useState("disablePointerDismissal"),v=h.useState("floatingRootContext"),b=h.useState("popupProps"),x=h.useState("modal"),E=h.useState("mounted"),_=h.useState("nested"),T=h.useState("nestedOpenDialogCount"),C=h.useState("open"),M=h.useState("openMethod"),R=h.useState("titleElementId"),N=h.useState("transitionStatus"),k=h.useState("role");H8(),Yo({open:C,ref:h.context.popupRef,onComplete(){C&&h.context.onOpenChangeComplete?.(!0)}});function z(F){return F==="touch"?h.context.popupRef.current:!0}const j=l===void 0?z:l,A=T>0,G=At("div",t,{state:{open:C,nested:_,transitionStatus:N,nestedDialogOpen:A},props:[b,{"aria-labelledby":R??void 0,"aria-describedby":p??void 0,role:k,tabIndex:-1,hidden:!E,onKeyDown(F){JN.has(F.key)&&F.stopPropagation()},style:{[U8.nestedDialogs]:T}},f],ref:[n,h.context.popupRef,h.useStateSetter("popupElement")],stateAttributesMapping:F8});return d.jsx(wN,{context:v,openInteractionType:M,disabled:!E,closeOnFocusOut:!y,initialFocus:j,returnFocus:o,modal:x!==!1,restoreFocus:"popup",children:G})}),fj=S.forwardRef(function(t,n){const{keepMounted:i=!1,...o}=t,{store:l}=jl(),u=l.useState("mounted"),f=l.useState("modal"),h=l.useState("open");return u||i?d.jsx(cj.Provider,{value:i,children:d.jsxs(_N,{ref:n,...o,children:[u&&f===!0&&d.jsx(KN,{ref:l.context.internalBackdropRef,inert:cb(!h)}),t.children]})}):null});function q8(e){const{store:t,parentContext:n,actionsRef:i}=e,o=t.useState("open"),l=t.useState("disablePointerDismissal"),u=t.useState("modal"),f=t.useState("popupElement"),{openMethod:h,triggerProps:p,reset:y}=jq(o);bF(t);const{forceUnmount:v}=xF(o,t,()=>{y()}),b=je(G=>{const F=Pt(G);return F.preventUnmountOnClose=()=>{t.set("preventUnmountingOnClose",!0)},F}),x=S.useCallback(()=>{t.setOpen(!1,b(_B))},[t,b]);S.useImperativeHandle(i,()=>({unmount:v,close:x}),[v,x]);const E=CF({popupStore:t,onOpenChange:t.setOpen,treatPopupAsFloatingElement:!0,noEmit:!0}),[_,T]=S.useState(0),C=_===0,M=DF(E),R=aF(E,{outsidePressEvent(){return t.context.internalBackdropRef.current||t.context.backdropRef.current?"intentional":{mouse:u==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}},outsidePress(G){if(!t.context.outsidePressEnabledRef.current||"button"in G&&G.button!==0||"touches"in G&&G.touches.length!==1)return!1;const F=Sr(G);if(C&&!l){const P=F;return u&&(t.context.internalBackdropRef.current||t.context.backdropRef.current)?t.context.internalBackdropRef.current===P||t.context.backdropRef.current===P||Rt(P,f)&&!P?.hasAttribute("data-base-ui-portal"):!0}return!1},escapeKey:C});qN(o&&u===!0,f);const{getReferenceProps:N,getFloatingProps:k,getTriggerProps:z}=kF([M,R]);t.useContextCallback("onNestedDialogOpen",G=>{T(G+1)}),t.useContextCallback("onNestedDialogClose",()=>{T(0)}),S.useEffect(()=>(n?.onNestedDialogOpen&&o&&n.onNestedDialogOpen(_),n?.onNestedDialogClose&&!o&&n.onNestedDialogClose(),()=>{n?.onNestedDialogClose&&o&&n.onNestedDialogClose()}),[o,n,_]);const j=S.useMemo(()=>N(p),[N,p]),A=S.useMemo(()=>z(p),[z,p]),D=S.useMemo(()=>k(),[k]);t.useSyncedValues({openMethod:h,activeTriggerProps:j,inactiveTriggerProps:A,popupProps:D,floatingRootContext:E,nestedOpenDialogCount:_})}const V8={..._F,modal:ke(e=>e.modal),nested:ke(e=>e.nested),nestedOpenDialogCount:ke(e=>e.nestedOpenDialogCount),disablePointerDismissal:ke(e=>e.disablePointerDismissal),openMethod:ke(e=>e.openMethod),descriptionElementId:ke(e=>e.descriptionElementId),titleElementId:ke(e=>e.titleElementId),viewportElement:ke(e=>e.viewportElement),role:ke(e=>e.role)};class $8 extends kN{constructor(t){super(G8(t),{popupRef:S.createRef(),backdropRef:S.createRef(),internalBackdropRef:S.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:new ab,onOpenChange:void 0,onOpenChangeComplete:void 0},V8)}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 i={open:t,nativeEvent:n.event,reason:n.reason,nested:this.state.nested};this.state.floatingRootContext.context.events?.emit("openchange",i);const o={open:t},l=n.trigger?.id??null;(l||t)&&(o.activeTriggerId=l,o.activeTriggerElement=n.trigger??null),this.update(o)}}function G8(e={}){return{...EF(),modal:!0,disablePointerDismissal:!1,popupElement:null,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,role:"dialog",...e}}function K8(e){const{children:t,open:n,defaultOpen:i=!1,onOpenChange:o,onOpenChangeComplete:l,disablePointerDismissal:u=!1,modal:f=!0,actionsRef:h,handle:p,triggerId:y,defaultTriggerId:v=null}=e,b=jl(!0),x=!!b,E=En(()=>p?.store??new $8({open:i,openProp:n,activeTriggerId:v,triggerIdProp:y,modal:f,disablePointerDismissal:u,nested:x})).current;cH(()=>{n===void 0&&E.state.open===!1&&i===!0&&E.update({open:!0,activeTriggerId:v})}),E.useControlledProp("openProp",n),E.useControlledProp("triggerIdProp",y),E.useSyncedValues({disablePointerDismissal:u,nested:x,modal:f}),E.useContextCallback("onOpenChange",o),E.useContextCallback("onOpenChangeComplete",l);const _=E.useState("payload");q8({store:E,actionsRef:h,parentContext:b?.store.context});const T=S.useMemo(()=>({store:E}),[E]);return d.jsx(aj.Provider,{value:T,children:typeof t=="function"?t({payload:_}):t})}const dj=S.forwardRef(function(t,n){const{render:i,className:o,id:l,...u}=t,{store:f}=jl(),h=tr(l);return f.useSyncedValueWithCleanup("titleElementId",h),At("h2",t,{ref:n,props:[{id:h},u]})}),Er=K8,Y8=S.forwardRef(({className:e,...t},n)=>d.jsx(fb,{ref:n,className:me("fixed inset-0 z-50 bg-black/60 backdrop-blur-sm",e),...t}));Y8.displayName="DialogOverlay";const Xn=S.forwardRef(({className:e,children:t,...n},i)=>d.jsxs(fj,{children:[d.jsx(fb,{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm"}),d.jsx(uj,{ref:i,className:me("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})]}));Xn.displayName="DialogContent";const Qn=S.forwardRef(({className:e,...t},n)=>d.jsx("div",{ref:n,className:me("px-5 py-3 border-b border-border",e),...t}));Qn.displayName="DialogHeader";const pn=S.forwardRef(({className:e,...t},n)=>d.jsx("div",{ref:n,className:me("px-5 py-3 border-t border-border flex justify-end gap-2",e),...t}));pn.displayName="DialogFooter";const Wn=S.forwardRef(({className:e,...t},n)=>d.jsx(dj,{ref:n,className:me("font-mono text-[10px] text-neutral-500 uppercase tracking-widest",e),...t}));Wn.displayName="DialogTitle";const X8=S.forwardRef(({className:e,...t},n)=>d.jsx(lj,{ref:n,className:me("font-mono text-[10px] text-neutral-500",e),...t}));X8.displayName="DialogDescription";const db=S.forwardRef(({className:e,page:t,totalPages:n,totalItems:i,onPageChange:o,...l},u)=>d.jsxs("div",{ref:u,className:me("px-5 py-2.5 border-t border-border flex items-center justify-between",e),...l,children:[d.jsxs("span",{className:"font-mono text-[10px] text-neutral-600",children:[i," items · Page ",t," of ",n]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx(Ae,{size:"sm",variant:"default",disabled:t<=1,onClick:()=>o(t-1),children:"Prev"}),d.jsx(Ae,{size:"sm",variant:"default",disabled:t>=n,onClick:()=>o(t+1),children:"Next"})]})]}));db.displayName="Pagination";const Q8=S.forwardRef(({className:e,orientation:t="horizontal",...n},i)=>d.jsx("hr",{ref:i,"aria-orientation":t==="vertical"?"vertical":void 0,className:me("border-none m-0",t==="horizontal"?"h-px w-full bg-border":"w-px h-4 bg-border",e),...n}));Q8.displayName="Separator";const W8=Vi("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"}}),Z8=S.forwardRef(({className:e,side:t,children:n,...i},o)=>d.jsxs(fj,{children:[d.jsx(fb,{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm"}),d.jsx(uj,{ref:o,className:me(W8({side:t,className:e})),...i,children:n})]}));Z8.displayName="SheetContent";const J8=S.forwardRef(({className:e,...t},n)=>d.jsx("div",{ref:n,className:me("px-5 py-3 border-b border-border",e),...t}));J8.displayName="SheetHeader";const eV=S.forwardRef(({className:e,...t},n)=>d.jsx("div",{ref:n,className:me("px-5 py-3 border-t border-border flex justify-end gap-2",e),...t}));eV.displayName="SheetFooter";const tV=S.forwardRef(({className:e,...t},n)=>d.jsx(dj,{ref:n,className:me("font-mono text-[10px] text-neutral-500 uppercase tracking-widest",e),...t}));tV.displayName="SheetTitle";const nV=S.forwardRef(({className:e,...t},n)=>d.jsx(lj,{ref:n,className:me("text-sm text-neutral-400",e),...t}));nV.displayName="SheetDescription";const rV=S.forwardRef(({className:e,...t},n)=>d.jsx("div",{ref:n,className:me("rounded-md bg-neutral-800 animate-pulse",e),...t}));rV.displayName="Skeleton";const sV=S.createContext(void 0);function hb(){const e=S.useContext(sV);if(e===void 0)throw new Error(nn(64));return e}let iV=(function(e){return e.activationDirection="data-activation-direction",e.orientation="data-orientation",e})({});const hj={tabActivationDirection:e=>({[iV.activationDirection]:e})},pj=S.createContext(void 0);function oV(){const e=S.useContext(pj);if(e===void 0)throw new Error(nn(65));return e}const aV=S.forwardRef(function(t,n){const{className:i,disabled:o=!1,render:l,value:u,id:f,nativeButton:h=!0,...p}=t,{value:y,getTabPanelIdByValue:v,orientation:b}=hb(),{activateOnFocus:x,highlightedTabIndex:E,onTabActivation:_,setHighlightedTabIndex:T,tabsListElement:C}=oV(),M=tr(f),R=S.useMemo(()=>({disabled:o,id:M,value:u}),[o,M,u]),{compositeProps:N,compositeRef:k,index:z}=nj({metadata:R}),j=u===y,A=S.useRef(!1);De(()=>{if(A.current){A.current=!1;return}if(!(j&&z>-1&&E!==z))return;const V=C;if(V!=null){const U=Si(_t(V));if(U&&Rt(V,U))return}o||T(z)},[j,z,E,T,o,C]);const{getButtonProps:D,buttonRef:G}=El({disabled:o,native:h,focusableWhenDisabled:!0}),F=v(u),P=S.useRef(!1),Q=S.useRef(!1);function X(V){j||o||_(u,Pt(Pi,V.nativeEvent,void 0,{activationDirection:"none"}))}function te(V){j||(z>-1&&!o&&T(z),!o&&x&&(!P.current||P.current&&Q.current)&&_(u,Pt(Pi,V.nativeEvent,void 0,{activationDirection:"none"})))}function L(V){if(j||o)return;P.current=!0;function U(){P.current=!1,Q.current=!1}(!V.button||V.button===0)&&(Q.current=!0,_t(V.currentTarget).addEventListener("pointerup",U,{once:!0}))}return At("button",t,{state:{disabled:o,active:j,orientation:b},ref:[n,G,k],props:[N,{role:"tab","aria-controls":F,"aria-selected":j,id:M,onClick:X,onFocus:te,onPointerDown:L,[sj]:j?"":void 0,onKeyDownCapture(){A.current=!0}},p,D]})});let lV=(function(e){return e.index="data-index",e.activationDirection="data-activation-direction",e.orientation="data-orientation",e.hidden="data-hidden",e})({});const cV={...hj,...Ko},uV=S.forwardRef(function(t,n){const{className:i,value:o,render:l,keepMounted:u=!1,...f}=t,{value:h,getTabIdByPanelValue:p,orientation:y,tabActivationDirection:v,registerMountedTabPanel:b,unregisterMountedTabPanel:x}=hb(),E=tr(),_=S.useMemo(()=>({id:E,value:o}),[E,o]),{ref:T,index:C}=ub({metadata:_}),M=o===h,{mounted:R,transitionStatus:N,setMounted:k}=Lh(M),z=!R,j=p(o),A={hidden:z,orientation:y,tabActivationDirection:v,transitionStatus:N},D=S.useRef(null),G=At("div",t,{state:A,ref:[n,T,D],props:[{"aria-labelledby":j,hidden:z,id:E,role:"tabpanel",tabIndex:M?0:-1,inert:cb(!M),[lV.index]:C},f],stateAttributesMapping:cV});return Yo({open:M,ref:D,onComplete(){M||k(!1)}}),De(()=>{if(!(z&&!u)&&E!=null)return b(o,E),()=>{x(o,E)}},[z,u,o,E,b,x]),u||R?G:null}),fV=S.forwardRef(function(t,n){const{activateOnFocus:i=!1,className:o,loopFocus:l=!0,render:u,...f}=t,{getTabElementBySelectedValue:h,onValueChange:p,orientation:y,value:v,setTabMap:b,tabActivationDirection:x}=hb(),[E,_]=S.useState(0),[T,C]=S.useState(null),M=dV(v,y,T,h),R=je((j,A)=>{if(j!==v){const D=M(j);A.activationDirection=D,p(j,A)}}),N={orientation:y,tabActivationDirection:x},k={"aria-orientation":y==="vertical"?"vertical":void 0,role:"tablist"},z=S.useMemo(()=>({activateOnFocus:i,highlightedTabIndex:E,onTabActivation:R,setHighlightedTabIndex:_,tabsListElement:T,value:v}),[i,E,R,_,T,v]);return d.jsx(pj.Provider,{value:z,children:d.jsx(ij,{render:u,className:o,state:N,refs:[n,C],props:[k,f],stateAttributesMapping:hj,highlightedIndex:E,enableHomeAndEndKeys:!0,loopFocus:l,orientation:y,onHighlightedIndexChange:_,onMapChange:b,disabledIndices:Yc})})});function ET(e,t){const{left:n,top:i}=e.getBoundingClientRect(),{left:o,top:l}=t.getBoundingClientRect(),u=n-o,f=i-l;return{left:u,top:f}}function dV(e,t,n,i){const[o,l]=S.useState(null);return De(()=>{if(e==null||n==null){l(null);return}const u=i(e);if(u==null){l(null);return}const{left:f,top:h}=ET(u,n);l(t==="horizontal"?f:h)},[t,i,n,e]),S.useCallback(u=>{if(u===e)return"none";if(u==null)return l(null),"none";if(u!=null&&n!=null){const f=i(u);if(f!=null){const{left:h,top:p}=ET(f,n);if(o==null)return l(t==="horizontal"?h:p),"none";if(t==="horizontal"){if(h<o)return l(h),"left";if(h>o)return l(h),"right"}else{if(p<o)return l(p),"up";if(p>o)return l(p),"down"}}}return"none"},[i,t,o,n,e])}const hV=S.forwardRef(({className:e,...t},n)=>d.jsx(fV,{ref:n,className:me("flex items-center gap-0.5",e),...t}));hV.displayName="TabsList";const pV=Vi("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"}}),mV=S.forwardRef(({className:e,variant:t,...n},i)=>d.jsx(aV,{ref:i,className:me(pV({variant:t,className:e})),...n}));mV.displayName="TabsTrigger";const gV=S.forwardRef(({className:e,...t},n)=>d.jsx(uV,{ref:n,className:me("outline-none",e),...t}));gV.displayName="TabsContent";const yV=S.forwardRef(({className:e,...t},n)=>d.jsx("p",{ref:n,className:me("font-mono text-[11px] text-neutral-300",e),...t}));yV.displayName="Text";const vV=S.forwardRef(({className:e,...t},n)=>d.jsx("p",{ref:n,className:me("font-mono text-[10px] text-neutral-500",e),...t}));vV.displayName="TextMuted";const bV=S.forwardRef(({className:e,...t},n)=>d.jsx("code",{ref:n,className:me("font-mono text-[11px] text-white",e),...t}));bV.displayName="TextCode";const xV=S.forwardRef(({className:e,...t},n)=>d.jsx("span",{ref:n,className:me("font-mono text-[9px] uppercase tracking-wider text-neutral-500",e),...t}));xV.displayName="TextLabel";const SV=S.forwardRef(({className:e,...t},n)=>d.jsx("pre",{ref:n,className:me("font-mono text-[11px] text-neutral-300 p-3 rounded border border-border bg-panel-alt overflow-x-auto",e),...t}));SV.displayName="CodeBlock";function Xo(e,t){const[n,i]=S.useState(()=>{if(typeof window>"u")return t;try{const l=window.localStorage.getItem(e);return l===null?t:JSON.parse(l)}catch{return t}});S.useEffect(()=>{try{n==null?window.localStorage.removeItem(e):window.localStorage.setItem(e,JSON.stringify(n))}catch{}},[e,n]);const o=S.useCallback(l=>{i(u=>typeof l=="function"?l(u):l)},[]);return[n,o]}const EV="console:instance-id";function zh(){const[e,t]=Xo(EV,""),n=e.trim();return S.useMemo(()=>({instanceId:n.length>0?n:void 0,rawInstanceId:e,setInstanceId:t,clearInstanceId:()=>t("")}),[n,e,t])}const Dn={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 Qi(e,t){return e===0?!1:e??t}function _V(e){const t=new URLSearchParams;if(!e)return t;for(const[n,i]of Object.entries(e))i!=null&&t.set(n,String(i));return t}function mj(e,t,n){const i=e.endsWith("/")?e.slice(0,-1):e,l=_V(n)?.toString();return`${i}${t}${l?`?${l}`:""}`}function Uh(e,t){if(!t||!e)throw new Error("Not connected");return e}async function sr(e){const t={Authorization:`Bearer ${e.connectionConfig.token}`};e.body!==void 0&&(t["Content-Type"]="application/json");const n=await fetch(mj(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 wV(e){const t=await fetch(mj(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 Hr(e){const{config:t,isConnected:n}=$o();return wR({queryKey:e.queryKey,queryFn:()=>sr({connectionConfig:Uh(t,n),path:e.path,query:e.query,method:e.method,errorMessage:e.errorMessage}),enabled:(e.enabled??!0)&&n&&!!t,refetchInterval:e.refetchInterval})}function pb(e){const{config:t,isConnected:n}=$o();return wR({queryKey:e.queryKey,queryFn:()=>{if(e.id===void 0)throw new Error(e.requiredMessage);return sr({connectionConfig:Uh(t,n),path:e.path(e.id),query:e.query,errorMessage:e.errorMessage})},enabled:(e.enabled??!0)&&e.id!==void 0&&n&&!!t})}function TV(e,t){for(const n of t)e.invalidateQueries({queryKey:n})}function ir(e){const{instanceId:t}=zh();return e??t}function Fr(e){const{config:t,isConnected:n}=$o(),{instanceId:i}=zh(),o=Rv();return G5({mutationFn:l=>e.mutationFn({connectionConfig:Uh(t,n),variables:l,selectedInstanceId:i}),onSuccess:()=>{e.invalidateQueryKeys&&TV(o,e.invalidateQueryKeys)}})}function xu(e={}){const t=ir(e.instanceId);return Hr({queryKey:Dn.stats({partitionId:e.partitionId,instanceId:t}),path:"/console/stats",query:{partitionId:e.partitionId,instanceId:t},errorMessage:"Failed to fetch stats",refetchInterval:Qi(e.refetchIntervalMs,5e3)})}function CV(e={},t={}){const n=ir(e.instanceId);return Hr({queryKey:Dn.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:Qi(t.refetchIntervalMs,3e4)})}function RV(e={},t={}){const n=ir(e.instanceId);return Hr({queryKey:Dn.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:Qi(t.refetchIntervalMs,3e4)})}function NV(e={},t={}){const n=ir(e.instanceId);return Hr({queryKey:Dn.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:Qi(t.refetchIntervalMs,1e4)})}function jV(e,t={}){const n=ir(t.instanceId);return pb({queryKey:Dn.commitDetail(e,t.partitionId,n),id:e,requiredMessage:"Commit sequence is required",path:i=>`/console/commits/${encodeURIComponent(String(i))}`,query:{partitionId:t.partitionId,instanceId:n},errorMessage:"Failed to fetch commit detail",enabled:t.enabled})}function MV(e={},t={}){const n=ir(e.instanceId);return Hr({queryKey:Dn.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:Qi(t.refetchIntervalMs,1e4)})}function gj(e={},t={}){const n=ir(e.instanceId);return Hr({queryKey:Dn.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:Qi(t.refetchIntervalMs,1e4)})}function AV(e,t={}){const n=ir(t.instanceId);return pb({queryKey:Dn.eventDetail(e,t.partitionId,n),id:e,requiredMessage:"Event id is required",path:i=>`/console/events/${encodeURIComponent(String(i))}`,query:{partitionId:t.partitionId,instanceId:n},errorMessage:"Failed to fetch event detail",enabled:t.enabled})}function OV(e,t={}){const n=ir(t.instanceId);return pb({queryKey:Dn.eventPayload(e,t.partitionId,n),id:e,requiredMessage:"Event id is required",path:i=>`/console/events/${encodeURIComponent(String(i))}/payload`,query:{partitionId:t.partitionId,instanceId:n},errorMessage:"Failed to fetch event payload",enabled:t.enabled})}function kV(e={}){const t=ir(e.instanceId);return Hr({queryKey:Dn.handlers(t),path:"/console/handlers",query:{instanceId:t},errorMessage:"Failed to fetch handlers"})}function IV(e={}){const t=ir(e.instanceId);return Hr({queryKey:Dn.prunePreview(t),path:"/console/prune/preview",query:{instanceId:t},method:"POST",errorMessage:"Failed to fetch prune preview",enabled:e.enabled})}function DV(e={},t={}){const n=ir(e.instanceId);return Hr({queryKey:Dn.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:Qi(t.refetchIntervalMs,1e4)})}function LV(){return Fr({mutationFn:async({connectionConfig:e,selectedInstanceId:t})=>sr({connectionConfig:e,path:"/console/events",query:{instanceId:t},method:"DELETE",errorMessage:"Failed to clear events"}),invalidateQueryKeys:[["console","events"]]})}function PV(){return Fr({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>{const i=t.instanceId??n;return sr({connectionConfig:e,path:`/console/clients/${encodeURIComponent(t.clientId)}`,query:{partitionId:t.partitionId,instanceId:i},method:"DELETE",errorMessage:"Failed to evict client"})},invalidateQueryKeys:[["console","clients"],["console","stats"],["console","operations"]]})}function zV(){return Fr({mutationFn:async({connectionConfig:e,selectedInstanceId:t})=>sr({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 UV(){return Fr({mutationFn:async({connectionConfig:e,selectedInstanceId:t})=>sr({connectionConfig:e,path:"/console/compact",query:{instanceId:t},method:"POST",errorMessage:"Failed to compact"}),invalidateQueryKeys:[["console","stats"],["console","operations"]]})}function BV(){return Fr({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>{const i=t.instanceId??n;return sr({connectionConfig:e,path:"/console/notify-data-change",query:{instanceId:i},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 HV(e={}){const t=ir(e.instanceId);return Hr({queryKey:Dn.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 FV(){return Fr({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>sr({connectionConfig:e,path:"/console/api-keys",query:{instanceId:n},method:"POST",body:t,errorMessage:"Failed to create API key"}),invalidateQueryKeys:[["console","api-keys"]]})}function qV(){return Fr({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>sr({connectionConfig:e,path:`/console/api-keys/${encodeURIComponent(t)}`,query:{instanceId:n},method:"DELETE",errorMessage:"Failed to revoke API key"}),invalidateQueryKeys:[["console","api-keys"]]})}function VV(){return Fr({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>sr({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 $V(){return Fr({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>sr({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 GV(){return Fr({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>sr({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 KV(e={}){return Hr({queryKey:Dn.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:Qi(e.refetchIntervalMs,3e4)})}function YV(){return Fr({mutationFn:async({connectionConfig:e,variables:t})=>sr({connectionConfig:e,path:`/console/storage/${encodeURIComponent(t)}`,method:"DELETE",errorMessage:"Failed to delete blob"}),invalidateQueryKeys:[["console","storage"]]})}function XV(){const{config:e,isConnected:t}=$o();return async n=>{const i=await wV({connectionConfig:Uh(e,t),path:`/console/storage/${encodeURIComponent(n)}/download`,errorMessage:"Failed to download blob"}),o=URL.createObjectURL(i),l=document.createElement("a");l.href=o,l.download=n.split("/").pop()||n,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(o)}}const QV="console:partition-id";function Su(){const[e,t]=Xo(QV,""),n=e.trim();return S.useMemo(()=>({partitionId:n.length>0?n:void 0,rawPartitionId:e,setPartitionId:t,clearPartitionId:()=>t("")}),[n,e,t])}const _T={refreshInterval:5,timeFormat:"relative",showSparklines:!0,pageSize:20};function Eu(){const[e,t]=Xo("console:preferences",_T);return{preferences:e,setPreferences:t,updatePreference:(o,l)=>{t(u=>({...u,[o]:l}))},resetPreferences:()=>{t(_T)}}}const WV=[{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"}],ZV=[{value:10,label:"10"},{value:20,label:"20"},{value:50,label:"50"},{value:100,label:"100"}],mb="syncular-console-root";function JV(e){e.classList.add(mb)}const e$=[{suffix:"",label:"Command"},{suffix:"/stream",label:"Stream"},{suffix:"/fleet",label:"Fleet"},{suffix:"/ops",label:"Ops"},{suffix:"/storage",label:"Storage"},{suffix:"/config",label:"Config"}];function t$(e){const t=e?.trim()??"";return!t||t==="/"?"":(t.startsWith("/")?t:`/${t}`).replace(/\/+$/g,"")}function Kg(e,t){return e?t?`${e}${t}`:e:t||"/"}function n$({basePath:e,appHref:t,modeBadge:n}){const{connect:i,config:o,isConnected:l,isConnecting:u}=$o(),{preferences:f}=Eu(),{instanceId:h,rawInstanceId:p,setInstanceId:y,clearInstanceId:v}=zh(),{partitionId:b,rawPartitionId:x,setPartitionId:E,clearPartitionId:_}=Su(),T=er({select:D=>D.location.pathname}),{data:C}=xu({refetchIntervalMs:f.refreshInterval*1e3,partitionId:b,instanceId:h}),M=t$(e),R=S.useMemo(()=>e$.map(D=>({...D,id:Kg(M,D.suffix)})),[M]),N=Kg(M,""),k=Kg(M,"/config"),z=u?"connecting":l?"connected":o?"disconnected":"not-configured",j=R.find(D=>D.suffix===""?T===N||T===`${N}/`:T.startsWith(D.id))?.id??N,A=C?[{label:"HEAD",value:`#${C.maxCommitSeq}`},{label:"COMMITS",value:`${C.commitCount}`},{label:"CHANGES",value:`${C.changeCount}`},{label:"CLIENTS",value:`${C.activeClientCount}/${C.clientCount}`}]:[];return d.jsxs("div",{className:`${mb} h-screen bg-background text-foreground flex flex-col`,children:[d.jsx(L8,{brand:d.jsx($a,{to:N,children:d.jsx(D8,{label:"console"})}),center:d.jsx(N8,{items:R,activeId:j,renderItem:(D,{active:G})=>d.jsx($a,{to:D.id,children:d.jsx(oj,{active:G,children:D.label})},D.id)}),right:d.jsxs("div",{className:"flex items-center gap-2",children:[n?d.jsx(en,{variant:"flow",className:"hidden md:inline-flex px-2 py-1 text-[10px]",children:n}):null,d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx("span",{className:"font-mono text-[9px] text-neutral-500 uppercase tracking-wide",children:"Instance"}),d.jsx(An,{variant:"mono",value:p,onChange:D=>y(D.target.value),onBlur:D=>y(D.target.value.trim()),placeholder:"all",className:"h-7 w-[110px] px-2 py-1"}),h?d.jsx(Ae,{variant:"ghost",size:"sm",className:"h-7 px-2 text-[10px]",onClick:v,children:"All"}):null]}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx("span",{className:"font-mono text-[9px] text-neutral-500 uppercase tracking-wide",children:"Partition"}),d.jsx(An,{variant:"mono",value:x,onChange:D=>E(D.target.value),onBlur:D=>E(D.target.value.trim()),placeholder:"all",className:"h-7 w-[110px] px-2 py-1"}),b?d.jsx(Ae,{variant:"ghost",size:"sm",className:"h-7 px-2 text-[10px]",onClick:_,children:"All"}):null]}),d.jsx(AB,{state:z}),d.jsx($a,{to:k,children:d.jsx(Ae,{variant:T===k?"secondary":"ghost",size:"icon",children:d.jsx(YB,{className:"h-3 w-3"})})}),t?d.jsxs("a",{href:t,className:R8,children:[d.jsx(GB,{className:"h-3 w-3"}),"Go to app"]}):null]})}),d.jsx("main",{className:"flex-1 overflow-auto pb-[32px]",children:d.jsx("div",{className:"min-h-full",children:l||T===k?d.jsx("div",{style:{animation:"pageIn 0.3s ease-out"},children:d.jsx(XR,{})},T):d.jsx(r$,{configPath:k,hasSavedConfig:!!o,isConnecting:u,onConnect:()=>{i()}})})}),l&&d.jsx(H1,{isLive:l,metrics:A,uptime:"--"})]})}function r$({configPath:e,hasSavedConfig:t,isConnecting:n,onConnect:i}){return d.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[d.jsx("p",{className:"mb-4 text-foreground-muted",children:"Not connected to a @syncular server"}),d.jsxs("div",{className:"flex items-center gap-2",children:[t&&d.jsx(Ae,{variant:"default",onClick:i,disabled:n,children:n?"Connecting...":"Connect"}),d.jsx($a,{to:e,children:d.jsx(Ae,{variant:"link",children:"Configure connection"})})]})]})}const Vs=O3({component:n$});function s$(e={}){const{maxEvents:t=100,enabled:n=!0,staleAfterMs:i=65e3,replayLimit:o=100,partitionId:l,instanceId:u}=e,{config:f,isConnected:h}=$o(),{instanceId:p}=zh(),y=u??p,[v,b]=S.useState([]),[x,E]=S.useState(!1),[_,T]=S.useState("disconnected"),[C,M]=S.useState(null),R=S.useRef(null),N=S.useRef(null),k=S.useRef(null),z=S.useRef(0),j=S.useRef(0),A=S.useRef(null),D=S.useCallback(()=>{b([]),A.current=null},[]);return S.useEffect(()=>{if(!n||!h||!f?.serverUrl||!f?.token)return;let G=!1;const F=Number.isFinite(o)?Math.max(1,Math.min(500,Math.floor(o))):100;if(typeof WebSocket>"u")return;const P=()=>{N.current&&(clearTimeout(N.current),N.current=null)},Q=()=>{k.current&&(clearInterval(k.current),k.current=null)},X=()=>{if(G||N.current)return;z.current+=1;const $=Math.min(3e4,1e3*2**Math.max(0,z.current-1)),H=Math.floor($*.2*Math.random()),V=$+H;N.current=setTimeout(()=>{N.current=null,G||L()},V)},te=()=>{j.current=Date.now(),E(!0),T("connected")},L=()=>{if(G)return;T("connecting"),P();const $=(()=>{const V=new URL(f.serverUrl,window.location.origin);V.protocol=V.protocol==="https:"?"wss:":"ws:";const U=V.pathname.endsWith("/")?V.pathname.slice(0,-1):V.pathname;return V.pathname=`${U}/console/events/live`,V.search="",A.current&&V.searchParams.set("since",A.current),V.searchParams.set("replayLimit",String(F)),l&&V.searchParams.set("partitionId",l),y&&V.searchParams.set("instanceId",y),V.toString()})(),H=new WebSocket($);R.current=H,H.onopen=()=>{if(G){H.close();return}z.current=0,M(null),T("connecting"),E(!1);try{H.send(JSON.stringify({type:"auth",token:f.token}))}catch{H.close();return}Q(),k.current=setInterval(()=>{const V=R.current;if(!V||V.readyState!==WebSocket.OPEN)return;const U=j.current;!U||Date.now()-U<=i||(E(!1),T("stale"),V.close())},1e3)},H.onclose=()=>{G||(E(!1),T("disconnected"),Q(),X())},H.onerror=()=>{G||M(new Error("WebSocket connection failed"))},H.onmessage=V=>{try{const U=JSON.parse(V.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";M(new Error(se));return}const K={type:I,timestamp:U.timestamp||new Date().toISOString(),data:U};if(l&&K.data.partitionId!==l||y&&K.data.instanceId!==y)return;const Z=Date.parse(A.current??""),W=Date.parse(K.timestamp);Number.isFinite(W)&&(!Number.isFinite(Z)||W>Z)&&(A.current=K.timestamp),b(se=>[K,...se].slice(0,t))}catch{}}};return L(),()=>{G=!0,P(),Q(),R.current&&(R.current.close(),R.current=null),E(!1),T("disconnected")}},[n,h,f?.serverUrl,f?.token,t,l,y,o,i]),{events:v,isConnected:x,connectionState:_,error:C,clearEvents:D}}const i$=S.createContext(null);function yj(){const[e,t]=Xo("console:time-range","24h");return{range:e,setRange:t}}const o$=[{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 a$(e){const t=e.toLowerCase();for(const n of o$)if(t.includes(n.hint))return n.type;return"client"}function l$(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 c$(e,t){return typeof e.lagCommitCount=="number"?Math.max(0,e.lagCommitCount):t?Math.max(0,t.maxCommitSeq-e.cursor):0}function u$(e,t){return e.activityState==="stale"?"offline":t>0?"syncing":"online"}function f$(e,t){return e.length<=16?e:`${e.slice(0,12)}-${t+1}`}function d$(e,t,n={}){const i=n.maxNodes??10;return e.slice(0,i).map((o,l)=>{const u=c$(o,t),f=u$(o,u);return{id:f$(o.clientId,l),type:a$(o.clientId),status:f,cursor:Math.max(0,o.cursor),actor:o.actorId,mode:o.connectionMode,dialect:l$(o.clientId),scopes:Object.keys(o.effectiveScopes||{}),lastSeen:o.updatedAt}})}const h$={enabled:!1,thresholds:{p90Latency:500,errorRate:5,clientLag:100}};function wT(e,t="relative"){if(t==="absolute")return new Date(e).toLocaleString();const n=new Date(e),o=new Date().getTime()-n.getTime(),l=Math.floor(o/1e3);return l<60?`${l}s ago`:l<3600?`${Math.floor(l/60)}m ago`:l<86400?`${Math.floor(l/3600)}h ago`:`${Math.floor(l/86400)}d ago`}function p$(e){const t=e.length>1&&e.endsWith("/")?e.slice(0,-1):e;return t==="/console"||t.startsWith("/console/")?"/console/stream":"/stream"}function m$(){const e=Sh(),t=S.useMemo(()=>typeof window>"u"?"/stream":p$(window.location.pathname),[]),n=yj(),{range:i}=n,{preferences:o}=Eu(),{partitionId:l}=Su(),u=o.refreshInterval*1e3,[f]=Xo("console:alert-config",h$),[h,p]=S.useState("1h"),{data:y}=xu({refetchIntervalMs:u,partitionId:l}),{data:v}=CV({range:i,partitionId:l},{refetchIntervalMs:u}),{data:b}=RV({range:i,partitionId:l},{refetchIntervalMs:u}),{data:x}=NV({limit:5,partitionId:l},{refetchIntervalMs:u}),{data:E}=gj({limit:12,offset:0,partitionId:l},{refetchIntervalMs:u}),{events:_,isConnected:T}=s$({maxEvents:8,partitionId:l}),C=S.useMemo(()=>{const P=v?.buckets??[];let Q=0,X=0;for(const L of P)Q+=L.pushCount+L.pullCount,X+=L.errorCount;const te=Q>0?X/Q*100:0;return{totalEvents:Q,errorRate:te}},[v?.buckets]),M=S.useMemo(()=>E?.items?d$(E.items,y,{maxNodes:12}):[],[E?.items,y]),R=M.filter(P=>P.status!=="offline").length,N=M.filter(P=>P.status==="offline").length,k=S.useMemo(()=>y?[{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:y.activeClientCount,color:"syncing"},{label:"Pending",value:y.maxActiveClientCursor!==null&&y.maxCommitSeq>0?y.maxCommitSeq-(y.minActiveClientCursor??0):0,color:"relay"}]:[],[y,b,C.errorRate,C.totalEvents]),z=S.useMemo(()=>_.map(P=>({type:P.type.toUpperCase(),actor:P.data?.actorId??"",table:(P.data?.tables??[])[0]??"",time:wT(P.timestamp,o.timeFormat)})),[_,o.timeFormat]),j=S.useMemo(()=>{const P=v?.buckets;if(!P?.length)return[];const Q=Math.max(...P.map(X=>Math.max(X.pushCount,X.pullCount)),1);return P.map(X=>({pushPercent:Q>0?X.pushCount/Q*100:0,pullPercent:Q>0?X.pullCount/Q*100:0}))},[v?.buckets]),A=S.useMemo(()=>{if(!b)return[];const P=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/P*100,pullBarPercent:b.pull.p50/P*100},{label:"P90",pushMs:b.push.p90,pullMs:b.pull.p90,pushBarPercent:b.push.p90/P*100,pullBarPercent:b.pull.p90/P*100},{label:"P99",pushMs:b.push.p99,pullMs:b.pull.p99,pushBarPercent:b.push.p99/P*100,pullBarPercent:b.pull.p99/P*100}]},[b]),D=S.useMemo(()=>x?.items?x.items.map(P=>({seq:P.commitSeq,actor:P.actorId,changes:P.changeCount,tables:(P.affectedTables??[]).join(", "),time:wT(P.createdAt,o.timeFormat)})):[],[x?.items,o.timeFormat]),G=S.useMemo(()=>Math.max(0,100-C.errorRate),[C.errorRate]),F=S.useMemo(()=>{if(!f.enabled||!y)return[];const P=[];return b?.push?.p90&&b.push.p90>f.thresholds.p90Latency&&P.push(`P90 push latency (${b.push.p90}ms) exceeds threshold (${f.thresholds.p90Latency}ms)`),y.minActiveClientCursor!==null&&y.maxCommitSeq-y.minActiveClientCursor>f.thresholds.clientLag&&P.push(`Client lag (${y.maxCommitSeq-y.minActiveClientCursor}) exceeds threshold (${f.thresholds.clientLag})`),C.errorRate>f.thresholds.errorRate&&P.push(`Error rate (${C.errorRate.toFixed(1)}%) exceeds threshold (${f.thresholds.errorRate}%)`),P},[f,y,b,C.errorRate]);return y?d.jsx(i$.Provider,{value:n,children:d.jsxs("div",{className:"flex flex-col",children:[F.length>0&&d.jsx("div",{className:"px-6 pb-4",children:d.jsxs(bn,{variant:"destructive",children:[d.jsx(bu,{children:"Threshold Exceeded"}),d.jsx(xn,{children:F.map((P,Q)=>d.jsx("span",{className:"block",children:P},Q))})]})}),d.jsx(UN,{clients:M,totalNodes:M.length+2,onlineCount:R,offlineCount:N,relayClientIds:[]}),d.jsx(X1,{items:k}),d.jsxs("div",{className:"flex",children:[d.jsxs("div",{className:"flex-1 min-w-0 flex flex-col",children:[d.jsx("div",{className:"border-b border-border border-r border-border",children:d.jsx(S1,{bars:j,activeRange:h,onRangeChange:p})}),d.jsx("div",{className:"border-b border-border border-r border-border",children:d.jsx(Q1,{buckets:A,successRate:G})}),d.jsx("div",{className:"border-r border-border",children:d.jsx(F1,{commits:D,onViewAll:()=>e({href:t})})})]}),d.jsx(W1,{entries:z,isConnected:T,maxVisible:20,maxHeight:"calc(100vh - 200px)"})]})]})}):d.jsx("div",{className:"flex items-center justify-center py-24",children:d.jsx(Mt,{size:"lg"})})}function g$(){return d.jsx(m$,{})}const Dr=rj;function y$({children:e}){return d.jsxs("div",{className:"space-y-4 px-5 py-5",children:[d.jsx(v$,{}),d.jsx(_$,{}),d.jsx(w$,{}),e]})}function v$(){const{clearError:e,config:t,connect:n,disconnect:i,error:o,isConnected:l,isConnecting:u}=$o(),[f,h]=S.useState(t?.serverUrl??"/api"),[p,y]=S.useState(t?.token??""),[v,b]=S.useState(null),[x,E]=S.useState(!1),[_,T]=S.useState(null),[C,M]=Xo("console:disconnect-clear-saved-config",!1);S.useEffect(()=>{const j=new URLSearchParams(window.location.search),A=j.get("server");let D=!1;if(A&&(h(A),j.delete("server"),D=!0),j.has("token")&&(j.delete("token"),D=!0),D){const G=j.toString(),F=G?`${window.location.pathname}?${G}`:window.location.pathname;window.history.replaceState({},"",F)}},[]),S.useEffect(()=>{t?.serverUrl&&h(t.serverUrl),t?.token&&y(t.token)},[t?.serverUrl,t?.token]),S.useEffect(()=>{T(null)},[]);const R=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.")},N=()=>{i({clearSavedConfig:C}),C&&(h("/api"),y("")),T(C?"Disconnected and saved credentials cleared.":"Disconnected."),b(null)},k=async()=>{E(!0),b(null),T(null);const j=performance.now();try{const A=f.trim(),D=p.trim();if(!A||!D)throw new Error("Missing server URL or token");if(!(await fetch(`${A}/console/stats`,{headers:{Authorization:`Bearer ${D}`}})).ok)throw new Error("Failed to connect");b(Math.round(performance.now()-j))}catch{b(-1)}finally{E(!1)}},z=o??_??(v!==null?v<0?"Connection failed":`Connection successful (${v}ms latency)`:void 0);return d.jsx(V1,{isConnected:l,isConnecting:u,isTestingConnection:x,serverUrl:f,onServerUrlChange:h,consoleToken:p,onConsoleTokenChange:y,onSaveAndConnect:R,onDisconnect:N,onTestConnection:k,statusMessage:z,children:d.jsx("div",{className:"px-5 pb-5 -mt-2",children:d.jsxs("div",{className:"flex items-center justify-between rounded-md border border-border px-3 py-2",children:[d.jsxs("div",{children:[d.jsx("p",{className:"font-mono text-[10px] text-neutral-400",children:"Clear saved credentials on disconnect"}),d.jsx("p",{className:"font-mono text-[9px] text-neutral-500",children:"Removes stored server URL and token from this browser."})]}),d.jsx(Mh,{checked:C,onCheckedChange:M})]})})})}const b$=1440*60*1e3;function TT(e){const t=e.trim();if(!t)return null;const n=Number.parseInt(t,10);return!Number.isInteger(n)||n<=0?null:n}function Yg(e){if(!e)return"Never";const t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():"Invalid date"}function x$(e){return e.length===0?"all scopes":e.length<=2?e.join(", "):`${e.slice(0,2).join(", ")} +${e.length-2}`}function S$(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 i=Date.now();return n<=i?"expired":n<=i+t*b$?"expiring":"active"}function E$(e){return e==="revoked"?"destructive":e==="expired"?"offline":e==="expiring"?"syncing":"healthy"}function _$(){const[e,t]=S.useState("all"),[n,i]=S.useState("all"),[o,l]=S.useState("14"),[u,f]=S.useState(!1),[h,p]=S.useState(!1),[y,v]=S.useState(""),[b,x]=S.useState("relay"),[E,_]=S.useState(""),[T,C]=S.useState(""),[M,R]=S.useState(""),[N,k]=S.useState(null),[z,j]=S.useState([]),[A,D]=S.useState(null),[G,F]=S.useState(null),[P,Q]=S.useState(null),[X,te]=S.useState(null),[L,$]=S.useState(null),[H,V]=S.useState(null),[U,I]=S.useState(null),K=S.useMemo(()=>TT(o),[o]),Z=K??14,W=S.useMemo(()=>TT(M),[M]),se=M.trim().length>0,ie=!se||W!==null,he=S.useMemo(()=>({type:e==="all"?void 0:e,status:n==="all"?void 0:n,expiresWithinDays:n==="expiring"?Z:void 0}),[e,n,Z]),{data:xe,isLoading:de,error:Be}=HV(he),_e=FV(),re=VV(),fe=qV(),ae=$V(),Se=GV();S.useEffect(()=>{const pe=new Set((xe?.items??[]).map(we=>we.keyId));j(we=>we.filter(He=>pe.has(He)))},[xe?.items]);const ye=async()=>{try{const pe=T.split(",").map(He=>He.trim()).filter(He=>He.length>0),we=await _e.mutateAsync({name:y,keyType:b,actorId:E||void 0,scopeKeys:pe.length>0?pe:void 0,expiresInDays:se?W??void 0:void 0});k(we.secretKey),v(""),_(""),C(""),R("")}catch{}},be=pe=>{navigator.clipboard.writeText(pe),F(pe),setTimeout(()=>F(null),2e3)},ge=async()=>{if(P)try{await fe.mutateAsync(P)}finally{Q(null)}},Le=async()=>{if(z.length!==0)try{const pe=await re.mutateAsync({keyIds:z});D(pe),j([])}catch{}},Oe=async()=>{if(X)try{const pe=await Se.mutateAsync(X.keyId);$({oldKeyId:X.keyId,oldKeyName:X.name,secretKey:pe.secretKey})}catch{}},Ee=async()=>{if(L)try{await fe.mutateAsync(L.oldKeyId)}finally{$(null),te(null)}},Fe=async()=>{if(H)try{const pe=await ae.mutateAsync(H);I(pe.secretKey)}finally{V(null)}};if(de)return d.jsx("div",{className:"flex h-[200px] items-center justify-center",children:d.jsx(Mt,{size:"lg"})});if(Be)return d.jsx("div",{className:"flex h-[200px] items-center justify-center",children:d.jsxs("p",{className:"text-danger",children:["Failed to load API keys: ",Be.message]})});const Ke=(xe?.items??[]).filter(pe=>pe.revokedAt===null).map(pe=>pe.keyId),ze=Ke.length>0&&Ke.every(pe=>z.includes(pe)),Xe=z.length>0,Ue=(xe?.items??[]).filter(pe=>z.includes(pe.keyId)).map(pe=>pe.name);return d.jsxs(d.Fragment,{children:[d.jsxs(Qv,{title:"API Keys",description:"Issue, rotate, revoke, and audit key lifecycle state.",actions:d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsxs(Ae,{size:"sm",variant:"destructive",onClick:()=>p(!0),disabled:z.length===0,children:["Revoke Selected (",z.length,")"]}),d.jsx(Ae,{size:"sm",onClick:()=>f(!0),children:"Create Key"})]}),children:[d.jsxs("div",{className:"mb-4 grid gap-3 lg:grid-cols-3",children:[d.jsxs(Wr,{children:[d.jsx(Lr,{children:"Type filter"}),d.jsxs(Cd,{value:[e],multiple:!1,onValueChange:pe=>{const we=pe.find(He=>typeof He=="string");(we==="all"||we==="relay"||we==="proxy"||we==="admin")&&t(we)},children:[d.jsx(Dr,{value:"all",children:"all"}),d.jsx(Dr,{value:"relay",children:"relay"}),d.jsx(Dr,{value:"proxy",children:"proxy"}),d.jsx(Dr,{value:"admin",children:"admin"})]})]}),d.jsxs(Wr,{children:[d.jsx(Lr,{children:"Status filter"}),d.jsxs(Cd,{value:[n],multiple:!1,onValueChange:pe=>{const we=pe.find(He=>typeof He=="string");(we==="all"||we==="active"||we==="revoked"||we==="expiring")&&i(we)},children:[d.jsx(Dr,{value:"all",children:"all"}),d.jsx(Dr,{value:"active",children:"active"}),d.jsx(Dr,{value:"revoked",children:"revoked"}),d.jsx(Dr,{value:"expiring",children:"expiring"})]})]}),d.jsxs(Wr,{children:[d.jsx(Lr,{htmlFor:"api-key-expiring-window",children:"Expiring window (days)"}),d.jsx(Ha,{children:"Used when status filter is set to expiring."}),d.jsx(An,{id:"api-key-expiring-window",placeholder:"14",value:o,inputMode:"numeric",onChange:pe=>l(pe.target.value)}),K===null&&o.trim().length>0?d.jsx("p",{className:"font-mono text-[10px] text-offline",children:"Enter a positive whole number."}):null]})]}),xe?.items.length===0?d.jsx(Yv,{message:"No API keys match the current filters."}):d.jsxs(wl,{children:[d.jsx(Tl,{children:d.jsxs(Br,{children:[d.jsx(ut,{className:"w-[28px]",children:d.jsx($y,{checked:ze,indeterminate:!ze&&Xe&&Ke.length>0,onCheckedChange:pe=>{j(pe?Ke:[])},"aria-label":"Select all active keys"})}),d.jsx(ut,{className:"w-[100px]",children:"NAME"}),d.jsx(ut,{className:"w-[55px]",children:"TYPE"}),d.jsx(ut,{className:"w-[90px]",children:"KEY PREFIX"}),d.jsx(ut,{className:"w-[80px]",children:"ACTOR"}),d.jsx(ut,{className:"w-[100px]",children:"SCOPES"}),d.jsx(ut,{className:"w-[120px]",children:"CREATED"}),d.jsx(ut,{className:"w-[120px]",children:"LAST USED"}),d.jsx(ut,{className:"w-[120px]",children:"EXPIRES"}),d.jsx(ut,{className:"flex-1",children:"STATUS"})]})}),d.jsx(Cl,{children:(xe?.items??[]).map(pe=>{const we=S$(pe,Z);return d.jsxs(Br,{className:"group relative",children:[d.jsx(ft,{className:"w-[28px]",children:d.jsx($y,{checked:z.includes(pe.keyId),onCheckedChange:He=>{j(dt=>He?[...new Set([...dt,pe.keyId])]:dt.filter(ot=>ot!==pe.keyId))},"aria-label":`Select ${pe.name}`,disabled:pe.revokedAt!==null})}),d.jsx(ft,{className:"w-[100px] font-medium",children:pe.name}),d.jsx(ft,{className:"w-[55px]",children:d.jsx(en,{variant:pe.keyType==="admin"?"flow":pe.keyType==="proxy"?"ghost":"relay",children:pe.keyType})}),d.jsx(ft,{className:"w-[90px]",children:d.jsxs("code",{className:"font-mono text-[11px]",children:[pe.keyPrefix,"..."]})}),d.jsx(ft,{className:"w-[80px] text-neutral-500",children:pe.actorId??"-"}),d.jsx(ft,{className:"w-[100px] text-neutral-500",children:d.jsx("code",{className:"font-mono text-[10px]",children:x$(pe.scopeKeys)})}),d.jsx(ft,{className:"w-[120px] text-neutral-500",children:Yg(pe.createdAt)}),d.jsx(ft,{className:"w-[120px] text-neutral-500",children:Yg(pe.lastUsedAt)}),d.jsx(ft,{className:"w-[120px] text-neutral-500",children:Yg(pe.expiresAt)}),d.jsx(ft,{className:"flex-1",children:d.jsx(en,{variant:E$(we),children:we})}),pe.revokedAt===null&&d.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:[d.jsx("button",{type:"button",onClick:()=>te(pe),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"}),d.jsx("button",{type:"button",onClick:()=>V(pe.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"}),d.jsx("button",{type:"button",onClick:()=>Q(pe.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"})]})]},pe.keyId)})})]})]}),d.jsx(Er,{open:u,onOpenChange:f,children:d.jsxs(Xn,{children:[d.jsx(Qn,{children:d.jsx(Wn,{children:"Create API Key"})}),N?d.jsx(CT,{copiedKeyId:G,onClose:()=>{k(null),f(!1)},onCopy:be,secretKey:N,warning:"Copy this key now. You will not be able to view it again."}):d.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[d.jsxs(Wr,{children:[d.jsx(Lr,{htmlFor:"api-key-name",children:"Name"}),d.jsx(An,{id:"api-key-name",placeholder:"Backend Relay Key",value:y,onChange:pe=>v(pe.target.value)})]}),d.jsxs(Wr,{children:[d.jsx(Lr,{children:"Key type"}),d.jsxs(Cd,{value:[b],multiple:!1,onValueChange:pe=>{const we=pe.find(He=>typeof He=="string");(we==="relay"||we==="proxy"||we==="admin")&&x(we)},children:[d.jsx(Dr,{value:"relay",children:"relay"}),d.jsx(Dr,{value:"proxy",children:"proxy"}),d.jsx(Dr,{value:"admin",children:"admin"})]})]}),d.jsxs(Wr,{children:[d.jsx(Lr,{htmlFor:"api-key-actor-id",children:"Actor ID (optional)"}),d.jsx(Ha,{children:"Pin this key to a fixed actor ID"}),d.jsx(An,{id:"api-key-actor-id",placeholder:"actor-123",value:E,onChange:pe=>_(pe.target.value)})]}),d.jsxs(Wr,{children:[d.jsx(Lr,{htmlFor:"api-key-scope-keys",children:"Scope keys (optional)"}),d.jsx(Ha,{children:"Comma-separated list of allowed scope keys"}),d.jsx(An,{id:"api-key-scope-keys",placeholder:"scope-a, scope-b",value:T,onChange:pe=>C(pe.target.value)})]}),d.jsxs(Wr,{children:[d.jsx(Lr,{htmlFor:"api-key-expires-days",children:"Expires in days (optional)"}),d.jsx(Ha,{children:"Leave empty to keep the key non-expiring."}),d.jsx(An,{id:"api-key-expires-days",placeholder:"30",value:M,inputMode:"numeric",onChange:pe=>R(pe.target.value)}),ie?null:d.jsx("p",{className:"font-mono text-[10px] text-offline",children:"Enter a positive whole number."})]}),d.jsxs(pn,{children:[d.jsx(Ae,{variant:"default",onClick:()=>f(!1),children:"Cancel"}),d.jsx(Ae,{variant:"primary",onClick:ye,disabled:_e.isPending||!y||!ie,children:_e.isPending?d.jsxs(d.Fragment,{children:[d.jsx(Mt,{size:"sm"}),"Creating..."]}):"Create"})]})]})]})}),d.jsx(Er,{open:h,onOpenChange:pe=>{p(pe),pe||D(null)},children:d.jsxs(Xn,{children:[d.jsx(Qn,{children:d.jsx(Wn,{children:"Bulk Revoke API Keys"})}),A?d.jsxs("div",{className:"px-5 py-4 flex flex-col gap-3",children:[d.jsx(bn,{variant:"destructive",children:d.jsxs(xn,{children:["Requested ",A.requestedCount," keys. Revoked"," ",A.revokedCount,", already revoked"," ",A.alreadyRevokedCount,", not found"," ",A.notFoundCount,"."]})}),d.jsx(pn,{children:d.jsx(Ae,{variant:"primary",onClick:()=>{p(!1),D(null)},children:"Done"})})]}):d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"px-5 py-4 flex flex-col gap-3",children:[d.jsx(bn,{variant:"destructive",children:d.jsx(xn,{children:"This revokes selected keys immediately and cannot be undone."})}),d.jsxs("p",{className:"font-mono text-[10px] text-neutral-500",children:["Selected keys: ",Ue.slice(0,5).join(", "),Ue.length>5?` +${Ue.length-5} more`:""]})]}),d.jsxs(pn,{children:[d.jsx(Ae,{variant:"default",onClick:()=>p(!1),children:"Cancel"}),d.jsx(Ae,{variant:"destructive",onClick:Le,disabled:re.isPending||z.length===0,children:re.isPending?d.jsxs(d.Fragment,{children:[d.jsx(Mt,{size:"sm"}),"Revoking..."]}):"Revoke Selected"})]})]})]})}),d.jsx(Er,{open:X!==null||L!==null,onOpenChange:()=>{te(null),$(null)},children:d.jsxs(Xn,{children:[d.jsx(Qn,{children:d.jsx(Wn,{children:"Stage Rotate API Key"})}),L?d.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[d.jsx(bn,{variant:"default",children:d.jsxs(xn,{children:["Replacement key created for ",L.oldKeyName,". The old key is still active until you revoke it."]})}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("code",{className:"flex-1 rounded-md border border-border bg-surface p-3 font-mono text-[11px] text-white break-all",children:L.secretKey}),d.jsx(Ae,{variant:"default",size:"sm",onClick:()=>be(L.secretKey),children:G===L.secretKey?"Copied":"Copy"})]}),d.jsxs(pn,{children:[d.jsx(Ae,{variant:"default",onClick:()=>{$(null),te(null)},children:"Keep Old Key Active"}),d.jsx(Ae,{variant:"destructive",onClick:Ee,disabled:fe.isPending,children:fe.isPending?d.jsxs(d.Fragment,{children:[d.jsx(Mt,{size:"sm"}),"Revoking Old Key..."]}):"Finalize and Revoke Old Key"})]})]}):d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"px-5 py-4",children:d.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."})}),d.jsxs(pn,{children:[d.jsx(Ae,{variant:"default",onClick:()=>te(null),children:"Cancel"}),d.jsx(Ae,{variant:"primary",onClick:Oe,disabled:Se.isPending||!X,children:Se.isPending?d.jsxs(d.Fragment,{children:[d.jsx(Mt,{size:"sm"}),"Staging..."]}):"Create Replacement Key"})]})]})]})}),d.jsx(Er,{open:P!==null,onOpenChange:()=>Q(null),children:d.jsxs(Xn,{children:[d.jsx(Qn,{children:d.jsx(Wn,{children:"Revoke API Key"})}),d.jsx("div",{className:"px-5 py-4",children:d.jsx(bn,{variant:"destructive",children:d.jsx(xn,{children:"Revoking a key immediately invalidates it for all requests."})})}),d.jsxs(pn,{children:[d.jsx(Ae,{variant:"default",onClick:()=>Q(null),children:"Cancel"}),d.jsx(Ae,{variant:"destructive",onClick:ge,disabled:fe.isPending,children:fe.isPending?d.jsxs(d.Fragment,{children:[d.jsx(Mt,{size:"sm"}),"Revoking..."]}):"Revoke"})]})]})}),d.jsx(Er,{open:H!==null||U!==null,onOpenChange:()=>{V(null),I(null)},children:d.jsxs(Xn,{children:[d.jsx(Qn,{children:d.jsx(Wn,{children:"Rotate API Key"})}),U?d.jsx(CT,{copiedKeyId:G,onClose:()=>I(null),onCopy:be,secretKey:U,warning:"The previous key has been invalidated. Store this replacement securely."}):d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"px-5 py-4",children:d.jsx("p",{className:"font-mono text-[10px] text-neutral-500",children:"Rotating a key invalidates the previous secret immediately."})}),d.jsxs(pn,{children:[d.jsx(Ae,{variant:"default",onClick:()=>V(null),children:"Cancel"}),d.jsx(Ae,{variant:"primary",onClick:Fe,disabled:ae.isPending,children:ae.isPending?d.jsxs(d.Fragment,{children:[d.jsx(Mt,{size:"sm"}),"Rotating..."]}):"Rotate"})]})]})]})})]})}function w$(){const{preferences:e,updatePreference:t,resetPreferences:n}=Eu(),i=[{type:"filter",label:"Auto-refresh interval",options:WV.map(o=>({id:`${o.value}`,label:o.label})),activeId:`${e.refreshInterval}`,onActiveChange:o=>t("refreshInterval",Number.parseInt(o,10))},{type:"filter",label:"Items per page",options:ZV.map(o=>({id:`${o.value}`,label:o.label})),activeId:`${e.pageSize}`,onActiveChange:o=>t("pageSize",Number.parseInt(o,10))},{type:"filter",label:"Time format",options:[{id:"relative",label:"Relative"},{id:"absolute",label:"Absolute"}],activeId:e.timeFormat,onActiveChange:o=>t("timeFormat",o)},{type:"toggle",label:"Show sparklines",description:"Display mini trend charts in dashboard metric cards",checked:e.showSparklines,onCheckedChange:o=>t("showSparklines",o)}];return d.jsx(Z1,{rows:i,onResetDefaults:n})}function CT({copiedKeyId:e,onClose:t,onCopy:n,secretKey:i,warning:o}){return d.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[d.jsx(bn,{variant:"destructive",children:d.jsx(xn,{children:o})}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("code",{className:"flex-1 rounded-md border border-border bg-surface p-3 font-mono text-[11px] text-white break-all",children:i}),d.jsx(Ae,{variant:"default",size:"sm",onClick:()=>n(i),children:e===i?"Copied":"Copy"})]}),d.jsx(pn,{children:d.jsx(Ae,{variant:"primary",onClick:t,children:"Done"})})]})}function T$(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 C$(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 R$(e,t){if(t==="absolute")return new Date(e).toLocaleString();try{const n=new Date(e),o=new Date().getTime()-n.getTime(),l=Math.floor(o/1e3),u=Math.floor(l/60),f=Math.floor(u/60),h=Math.floor(f/24);return l<60?"just now":u<60?`${u}m ago`:f<24?`${f}h ago`:`${h}d ago`}catch{return e}}function N$(e,t,n){return{id:e.clientId,type:T$(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:C$(e.clientId),scopes:Object.keys(e.effectiveScopes??{}),lastSeen:R$(e.updatedAt,n)}}function j$({emptyState:e}={}){const[t,n]=S.useState(1),[i,o]=S.useState(null),{preferences:l}=Eu(),{partitionId:u}=Su(),f=l.pageSize,h=l.refreshInterval*1e3,{data:p,isLoading:y}=xu({refetchIntervalMs:h,partitionId:u}),{data:v,isLoading:b,error:x}=gj({limit:f,offset:(t-1)*f,partitionId:u},{refetchIntervalMs:h}),E=PV(),_=Math.ceil((v?.total??0)/f),T=p?.maxCommitSeq??0;S.useEffect(()=>{n(1)},[]);const C=async()=>{if(i)try{await E.mutateAsync({clientId:i,partitionId:u})}finally{o(null)}};if(b||y)return d.jsx("div",{className:"flex items-center justify-center h-[200px]",children:d.jsx(Mt,{size:"lg"})});if(x)return d.jsx("div",{className:"flex items-center justify-center h-[200px]",children:d.jsxs("p",{className:"text-danger",children:["Failed to load clients: ",x.message]})});const M=(v?.items??[]).map(R=>N$(R,T,l.timeFormat));return d.jsxs("div",{className:"flex flex-col gap-5 px-5 py-5",children:[M.length>0&&d.jsx(eN,{clients:M,headSeq:T}),M.length===0?e??d.jsx(rH,{children:d.jsx(Yv,{message:"No clients yet"})}):d.jsx(K1,{clients:M,headSeq:T,onEvict:R=>{const N=v?.items.find(k=>k.clientId===R);o(N?.clientId??R)}}),_>1&&d.jsx(db,{page:t,totalPages:_,totalItems:v?.total??0,onPageChange:n}),d.jsx(Er,{open:i!==null,onOpenChange:()=>o(null),children:d.jsxs(Xn,{children:[d.jsx(Qn,{children:d.jsx(Wn,{children:"Evict Client"})}),d.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[d.jsxs("p",{className:"font-mono text-[11px] text-neutral-300",children:["Are you sure you want to evict client"," ",d.jsxs("span",{className:"font-mono text-white",children:[i?.slice(0,12),"..."]}),"?"]}),d.jsx("p",{className:"font-mono text-[10px] text-neutral-500",children:"This will force the client to re-bootstrap on their next sync."})]}),d.jsxs(pn,{children:[d.jsx(Ae,{variant:"default",onClick:()=>o(null),children:"Cancel"}),d.jsx(Ae,{variant:"destructive",onClick:C,disabled:E.isPending,children:E.isPending?d.jsxs(d.Fragment,{children:[d.jsx(Mt,{size:"sm"}),"Evicting..."]}):"Evict"})]})]})})]})}const M$={latencyThresholdMs:1e3,errorRateThreshold:5,clientLagThreshold:50,enabled:!1};function A$(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 O$(e){const t=e.split(",").map(n=>n.trim()).filter(n=>n.length>0);return Array.from(new Set(t))}function k$(e){switch(e){case"notify_data_change":return"Notify";case"evict_client":return"Evict";case"compact":return"Compact";default:return"Prune"}}function RT(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function I$(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function D$(e){const t=RT(e.requestPayload),n=RT(e.resultPayload);if(e.operationType==="notify_data_change"){const l=I$(t?.tables),u=n?.commitSeq;return`${l.length} table${l.length===1?"":"s"} -> commit #${typeof u=="number"?u:"?"}`}if(e.operationType==="evict_client"){const l=n?.evicted===!0?"evicted":"not found";return`client ${e.targetClientId??"?"} ${l}`}if(e.operationType==="compact")return`${typeof n?.deletedChanges=="number"?n.deletedChanges:0} changes removed`;const i=typeof n?.deletedCommits=="number"?n.deletedCommits:0,o=typeof t?.watermarkCommitSeq=="number"?` at #${t.watermarkCommitSeq}`:"";return`${i} commits removed${o}`}function L$(e){const t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function P$(){const{partitionId:e}=Su();return d.jsxs("div",{className:"flex flex-col gap-4 px-5 py-5",children:[d.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[d.jsx(z$,{}),d.jsx(q$,{})]}),d.jsxs("div",{className:"grid gap-4 xl:grid-cols-3",children:[d.jsx(U$,{partitionId:e}),d.jsx(B$,{partitionId:e}),d.jsx(H$,{partitionId:e})]}),d.jsx(F$,{partitionId:e})]})}function z$(){const{data:e,isLoading:t,error:n}=kV();if(t)return d.jsx("div",{className:"flex items-center justify-center h-[200px]",children:d.jsx(Mt,{size:"lg"})});if(n)return d.jsx("div",{className:"flex items-center justify-center h-[200px]",children:d.jsxs("p",{className:"text-danger",children:["Failed to load handlers: ",n.message]})});const i=(e?.items??[]).map(o=>({table:o.table,dependsOn:o.dependsOn?.join(", ")??null,chunkTtl:o.snapshotChunkTtlMs?A$(o.snapshotChunkTtlMs):"default"}));return d.jsx(Y1,{handlers:i,tableCount:e?.items.length??0})}function U$({partitionId:e}){const[t,n]=S.useState(!1),[i,o]=S.useState(null),{data:l,isLoading:u}=xu({partitionId:e}),{data:f,isLoading:h,refetch:p}=IV({enabled:!1}),y=zV(),v=async()=>{n(!0),o(null),await p()},b=async()=>{const E=await y.mutateAsync();o(E.deletedCommits)};if(u)return d.jsx("div",{className:"flex items-center justify-center h-[200px]",children:d.jsx(Mt,{size:"lg"})});const x=[{label:"Total commits",value:l?.commitCount??0},{label:"Commit range",value:`${l?.minCommitSeq??0} - ${l?.maxCommitSeq??0}`},{label:"Min active cursor",value:l?.minActiveClientCursor??"N/A",tone:"syncing"}];return d.jsxs(d.Fragment,{children:[d.jsx(Ah,{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:v}),d.jsx(Er,{open:t,onOpenChange:n,children:d.jsxs(Xn,{children:[d.jsx(Qn,{children:d.jsx(Wn,{children:"Prune Old Commits"})}),d.jsx("div",{className:"px-5 py-4 flex flex-col gap-4",children:i!==null?d.jsxs(bn,{variant:"default",children:[d.jsx(bu,{children:"Pruning Complete"}),d.jsxs(xn,{children:["Successfully deleted ",d.jsx("strong",{children:i})," commits."]})]}):h?d.jsx("div",{className:"flex items-center justify-center py-8",children:d.jsx(Mt,{size:"sm"})}):f?d.jsxs(d.Fragment,{children:[d.jsx(bn,{variant:f.commitsToDelete>0?"destructive":"default",children:d.jsx(xn,{children:f.commitsToDelete>0?d.jsxs(d.Fragment,{children:["This will delete"," ",d.jsx("strong",{children:f.commitsToDelete})," commits up to sequence"," ",d.jsxs("code",{className:"font-mono",children:["#",f.watermarkCommitSeq]}),"."]}):"No commits are eligible for pruning."})}),d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsxs("div",{className:"flex justify-between font-mono text-[11px]",children:[d.jsx("span",{className:"text-neutral-500",children:"Watermark commit seq:"}),d.jsxs("span",{className:"text-white",children:["#",f.watermarkCommitSeq]})]}),d.jsxs("div",{className:"flex justify-between font-mono text-[11px] items-center",children:[d.jsx("span",{className:"text-neutral-500",children:"Commits to delete:"}),d.jsx(en,{variant:f.commitsToDelete>0?"offline":"ghost",children:f.commitsToDelete})]})]})]}):null}),d.jsxs(pn,{children:[d.jsx(Ae,{variant:"default",onClick:()=>n(!1),children:i!==null?"Close":"Cancel"}),i===null&&d.jsx(Ae,{variant:"destructive",onClick:b,disabled:y.isPending||h||(f?.commitsToDelete??0)===0,children:y.isPending?d.jsxs(d.Fragment,{children:[d.jsx(Mt,{size:"sm"}),"Pruning..."]}):"Prune Now"})]})]})})]})}function B$({partitionId:e}){const[t,n]=S.useState(!1),[i,o]=S.useState(null),{data:l,isLoading:u}=xu({partitionId:e}),f=UV(),h=()=>{n(!0),o(null)},p=async()=>{const v=await f.mutateAsync();o(v.deletedChanges)};if(u)return d.jsx("div",{className:"flex items-center justify-center h-[200px]",children:d.jsx(Mt,{size:"lg"})});const y=[{label:"Total changes",value:l?.changeCount??0},{label:"Total commits",value:l?.commitCount??0}];return d.jsxs(d.Fragment,{children:[d.jsx(Ah,{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:y,actionLabel:"Run Compaction",actionVariant:"primary",onAction:h}),d.jsx(Er,{open:t,onOpenChange:n,children:d.jsxs(Xn,{children:[d.jsx(Qn,{children:d.jsx(Wn,{children:"Compact Changes"})}),d.jsx("div",{className:"px-5 py-4 flex flex-col gap-4",children:i!==null?d.jsxs(bn,{variant:"default",children:[d.jsx(bu,{children:"Compaction Complete"}),d.jsxs(xn,{children:["Successfully removed ",d.jsx("strong",{children:i})," redundant changes."]})]}):d.jsx(bn,{variant:"default",children:d.jsx(xn,{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."})})}),d.jsxs(pn,{children:[d.jsx(Ae,{variant:"default",onClick:()=>n(!1),children:i!==null?"Close":"Cancel"}),i===null&&d.jsx(Ae,{variant:"primary",onClick:p,disabled:f.isPending,children:f.isPending?d.jsxs(d.Fragment,{children:[d.jsx(Mt,{size:"sm"}),"Compacting..."]}):"Compact Now"})]})]})})]})}function H$({partitionId:e}){const[t,n]=S.useState(!1),[i,o]=S.useState("tasks"),[l,u]=S.useState(e??""),[f,h]=S.useState(null),[p,y]=S.useState(null),v=BV(),b=O$(i),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??"—"}],E=()=>{n(!0),y(null)},_=async()=>{if(b.length===0){y("Provide at least one table name.");return}y(null);const T=await v.mutateAsync({tables:b,partitionId:l.trim()||void 0});h(T)};return d.jsxs(d.Fragment,{children:[d.jsx(Ah,{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:E}),d.jsx(Er,{open:t,onOpenChange:n,children:d.jsxs(Xn,{children:[d.jsx(Qn,{children:d.jsx(Wn,{children:"Notify External Data Change"})}),d.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4",children:[f?d.jsxs(bn,{variant:"default",children:[d.jsx(bu,{children:"Notification Sent"}),d.jsxs(xn,{children:["Created synthetic commit"," ",d.jsxs("strong",{children:["#",f.commitSeq]})," for"," ",d.jsx("strong",{children:f.tables.length})," table",f.tables.length===1?"":"s"," and cleared"," ",d.jsx("strong",{children:f.deletedChunks})," cached chunk",f.deletedChunks===1?"":"s","."]})]}):d.jsx(bn,{variant:"default",children:d.jsx(xn,{children:"Use this when data changed outside Syncular push flow. It invalidates cached snapshot chunks and forces clients to pull fresh data."})}),p?d.jsx(bn,{variant:"destructive",children:d.jsx(xn,{children:p})}):null,d.jsxs(Wr,{children:[d.jsx(Lr,{children:"Tables (comma-separated)"}),d.jsx(An,{value:i,onChange:T=>o(T.target.value),placeholder:"tasks, notes",disabled:v.isPending}),d.jsx(Ha,{children:"Enter one or more table names affected by the external change."})]}),d.jsxs(Wr,{children:[d.jsx(Lr,{children:"Partition ID (optional)"}),d.jsx(An,{value:l,onChange:T=>u(T.target.value),placeholder:"default",disabled:v.isPending})]})]}),d.jsxs(pn,{children:[d.jsx(Ae,{variant:"default",onClick:()=>n(!1),children:f?"Close":"Cancel"}),f?null:d.jsx(Ae,{variant:"primary",onClick:_,disabled:v.isPending,children:v.isPending?d.jsxs(d.Fragment,{children:[d.jsx(Mt,{size:"sm"}),"Notifying..."]}):"Notify Data Change"})]})]})})]})}function F$({partitionId:e}){const[t,n]=S.useState("all"),{data:i,isLoading:o,error:l}=DV({limit:20,offset:0,operationType:t==="all"?void 0:t,partitionId:e},{refetchIntervalMs:5e3});return d.jsx(Qv,{title:"Operation Audit",description:"Recent prune/compact/notify/evict actions with actor and result context.",actions:d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(Ae,{variant:t==="all"?"default":"ghost",size:"sm",onClick:()=>n("all"),children:"All"}),d.jsx(Ae,{variant:t==="prune"?"default":"ghost",size:"sm",onClick:()=>n("prune"),children:"Prune"}),d.jsx(Ae,{variant:t==="compact"?"default":"ghost",size:"sm",onClick:()=>n("compact"),children:"Compact"}),d.jsx(Ae,{variant:t==="notify_data_change"?"default":"ghost",size:"sm",onClick:()=>n("notify_data_change"),children:"Notify"}),d.jsx(Ae,{variant:t==="evict_client"?"default":"ghost",size:"sm",onClick:()=>n("evict_client"),children:"Evict"})]}),contentClassName:"pt-2",children:o?d.jsx("div",{className:"flex items-center justify-center py-10",children:d.jsx(Mt,{size:"lg"})}):l?d.jsx(bn,{variant:"destructive",children:d.jsxs(xn,{children:["Failed to load operation audit events: ",l.message]})}):(i?.items.length??0)===0?d.jsx("div",{className:"px-2 py-8 text-sm text-neutral-500",children:"No operation events found for this filter."}):d.jsx("div",{className:"overflow-x-auto",children:d.jsxs(wl,{children:[d.jsx(Tl,{children:d.jsxs(Br,{children:[d.jsx(ut,{children:"Time"}),d.jsx(ut,{children:"Type"}),d.jsx(ut,{children:"User"}),d.jsx(ut,{children:"Target"}),d.jsx(ut,{children:"Result"})]})}),d.jsx(Cl,{children:(i?.items??[]).map((u,f)=>d.jsxs(Br,{children:[d.jsx(ft,{className:"whitespace-nowrap text-xs text-neutral-400",children:L$(u.createdAt)}),d.jsx(ft,{children:d.jsx(en,{variant:"ghost",children:k$(u.operationType)})}),d.jsx(ft,{className:"font-mono text-xs",children:u.consoleUserId??"system"}),d.jsx(ft,{className:"font-mono text-xs",children:u.targetClientId??u.partitionId??(u.operationType==="notify_data_change"?"partition default":"global")}),d.jsx(ft,{className:"font-mono text-xs text-neutral-300",children:D$(u)})]},`${u.operationId}:${u.createdAt}:${f}`))})]})})})}function q$(){const[e,t]=Xo("console:alert-config",M$),n={p90Latency:e.latencyThresholdMs,errorRate:e.errorRateThreshold,clientLag:e.clientLagThreshold},i=l=>{t(u=>({...u,latencyThresholdMs:l.p90Latency,errorRateThreshold:l.errorRate,clientLagThreshold:l.clientLag}))},o=l=>{t(u=>({...u,enabled:l}))};return d.jsx(B1,{enabled:e.enabled,onEnabledChange:o,thresholds:n,onThresholdsChange:i})}function V$(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 $$(e){const t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function G$(){const[e,t]=S.useState(""),[n,i]=S.useState(void 0),[o,l]=S.useState(void 0),[u,f]=S.useState([]),[h,p]=S.useState(null),{data:y,isLoading:v,error:b}=KV({prefix:n,cursor:o,limit:100}),x=YV(),E=XV();function _(){const k=e.trim();i(k.length>0?k:void 0),l(void 0),f([])}function T(){t(""),i(void 0),l(void 0),f([])}function C(){y?.cursor&&(f(k=>[...k,o??""]),l(y.cursor))}function M(){f(k=>{const z=[...k],j=z.pop();return l(j&&j.length>0?j:void 0),z})}function R(){h&&x.mutate(h,{onSuccess:()=>p(null)})}if(v)return d.jsx("div",{className:"flex flex-col gap-4 px-5 py-5",children:d.jsx("div",{className:"flex items-center justify-center h-[200px]",children:d.jsx(Mt,{size:"lg"})})});if(b)return d.jsx("div",{className:"flex flex-col gap-4 px-5 py-5",children:d.jsx("div",{className:"flex items-center justify-center h-[200px]",children:d.jsxs("p",{className:"text-danger font-mono text-[11px]",children:["Failed to load storage items: ",b.message]})})});const N=y?.items??[];return d.jsxs("div",{className:"flex flex-col gap-4 px-5 py-5",children:[d.jsx(Qv,{title:"Storage",actions:d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(An,{placeholder:"Prefix filter...",value:e,onChange:k=>t(k.target.value),onKeyDown:k=>{k.key==="Enter"&&_()},className:"h-7 w-48 text-xs"}),d.jsx(Ae,{variant:"default",size:"sm",onClick:_,children:"Filter"}),n&&d.jsx(Ae,{variant:"ghost",size:"sm",onClick:T,children:"Clear"})]}),children:N.length===0?d.jsx(Yv,{message:n?`No storage items matching prefix "${n}".`:"No storage items found."}):d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"overflow-x-auto",children:d.jsxs(wl,{children:[d.jsx(Tl,{children:d.jsxs(Br,{children:[d.jsx(ut,{children:"Key"}),d.jsx(ut,{children:"Size"}),d.jsx(ut,{children:"Type"}),d.jsx(ut,{children:"Uploaded"}),d.jsx(ut,{children:"Actions"})]})}),d.jsx(Cl,{children:N.map(k=>d.jsxs(Br,{children:[d.jsx(ft,{className:"font-mono text-xs max-w-[320px]",title:k.key,children:k.key}),d.jsx(ft,{className:"font-mono text-xs text-neutral-400 whitespace-nowrap",children:V$(k.size)}),d.jsx(ft,{children:k.httpMetadata?.contentType?d.jsx(en,{variant:"ghost",children:k.httpMetadata.contentType}):d.jsx("span",{className:"text-neutral-500 text-xs",children:"--"})}),d.jsx(ft,{className:"whitespace-nowrap text-xs text-neutral-400",children:$$(k.uploaded)}),d.jsx(ft,{children:d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx(Ae,{variant:"ghost",size:"sm",onClick:()=>{E(k.key)},children:"Download"}),d.jsx(Ae,{variant:"ghost",size:"sm",onClick:()=>p(k.key),children:"Delete"})]})})]},k.key))})]})}),d.jsxs("div",{className:"flex items-center justify-between px-2 py-2",children:[d.jsx(Ae,{variant:"ghost",size:"sm",disabled:u.length===0,onClick:M,children:"Previous"}),d.jsx(Ae,{variant:"ghost",size:"sm",disabled:!y?.truncated,onClick:C,children:"Next"})]})]})}),d.jsx(Er,{open:h!==null,onOpenChange:()=>p(null),children:d.jsxs(Xn,{children:[d.jsx(Qn,{children:d.jsx(Wn,{children:"Delete Storage Item"})}),d.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[d.jsxs("p",{className:"font-mono text-[11px] text-neutral-300",children:["Are you sure you want to delete"," ",d.jsx("span",{className:"font-mono text-white",children:h}),"?"]}),d.jsx("p",{className:"font-mono text-[10px] text-neutral-500",children:"This action cannot be undone."})]}),d.jsxs(pn,{children:[d.jsx(Ae,{variant:"default",onClick:()=>p(null),children:"Cancel"}),d.jsx(Ae,{variant:"destructive",onClick:R,disabled:x.isPending,children:x.isPending?d.jsxs(d.Fragment,{children:[d.jsx(Mt,{size:"sm"})," Deleting..."]}):"Delete"})]})]})})]})}const K$={};function jc(e,t){if(t==="absolute")return new Date(e).toLocaleString();const n=new Date(e),o=new Date().getTime()-n.getTime(),l=Math.floor(o/1e3);return l<60?`${l}s`:l<3600?`${Math.floor(l/60)}m`:l<86400?`${Math.floor(l/3600)}h`:`${Math.floor(l/86400)}d`}function Y$(e){const t=e.split(/\s+/).map(o=>o.trim()).filter(o=>o.length>0),n={},i=[];for(const o of t){const[l="",...u]=o.split(":"),f=u.join(":").trim(),h=l.toLowerCase();if(!f){i.push(o);continue}if(h==="actor"){n.actorId=f;continue}if(h==="client"){n.clientId=f;continue}if(h==="table"){n.table=f;continue}if(h==="request"){n.requestId=f;continue}if(h==="trace"){n.traceId=f;continue}i.push(o)}return i.length>0&&(n.search=i.join(" ")),n}function X$(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 ad(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Q$(e,t){return e?`#${e.federatedCommitId??(t?`${t}:${e.commitSeq}`:String(e.commitSeq))}`:"#?"}function W$(e,t){return e?`E${e.federatedEventId??(t?`${t}:${e.eventId}`:e.eventId)}`:"E?"}function Z$(e,t,n){return!e||!t?null:e.replaceAll("{traceId}",encodeURIComponent(t)).replaceAll("{spanId}",encodeURIComponent(n??""))}function gb({initialSelectedEntryId:e}={}){const{preferences:t}=Eu(),{partitionId:n}=Su(),{range:i,setRange:o}=yj(),l=t.pageSize,u=t.refreshInterval*1e3,f=K$?.VITE_CONSOLE_TRACE_URL_TEMPLATE,[h,p]=S.useState(()=>e?.startsWith("#")?"commits":e?.startsWith("E")?"events":"all"),[y,v]=S.useState("all"),[b,x]=S.useState("all"),[E,_]=S.useState(""),[T,C]=S.useState(1),[M,R]=S.useState(!1),[N,k]=S.useState(e??null),z=S.useRef(!1),j=S.useMemo(()=>Y$(E),[E]),A=S.useMemo(()=>new Date(Date.now()-X$(i)).toISOString(),[i]),{data:D,isLoading:G,refetch:F}=MV({limit:l,offset:(T-1)*l,...n?{partitionId:n}:{},view:h,...h!=="commits"&&y!=="all"?{eventType:y}:{},...h!=="commits"&&b!=="all"?{outcome:b}:{},...j.actorId?{actorId:j.actorId}:{},...j.clientId?{clientId:j.clientId}:{},...j.requestId?{requestId:j.requestId}:{},...j.traceId?{traceId:j.traceId}:{},...j.table?{table:j.table}:{},...j.search?{search:j.search}:{},from:A},{refetchIntervalMs:u}),P=LV(),Q=N?.startsWith("#")?N.slice(1):void 0,X=N?.startsWith("E")?N.slice(1):void 0,te=Q&&Q!=="?"?Q:void 0,L=X&&X!=="?"?X:void 0,{data:$,isLoading:H,error:V}=jV(te,{enabled:te!==void 0,partitionId:n}),{data:U,isLoading:I,error:K}=AV(L,{enabled:L!==void 0,partitionId:n}),{data:Z,isLoading:W,error:se}=OV(L,{enabled:L!==void 0&&!!U?.payloadRef,partitionId:n}),ie=S.useMemo(()=>Z$(f,U?.traceId??null,U?.spanId??null),[U?.spanId,U?.traceId,f]);S.useEffect(()=>{C(1)},[]),S.useEffect(()=>{C(1)},[]),S.useEffect(()=>{e&&k(e)},[e]),S.useEffect(()=>{if(!z.current){z.current=!0;return}k(null)},[]),S.useEffect(()=>{C(1),k(null)},[]);const xe=S.useMemo(()=>(D?.items??[]).map(Se=>{const ye=Se.instanceId??Se.commit?.instanceId??Se.event?.instanceId,be=ye?`[${ye}] `:"";if(Se.type==="commit"&&Se.commit){const Le=Se.commit;return{type:"commit",id:Q$(Le,ye),outcome:"--",duration:"--",actor:Le.actorId,client:Le.clientId,detail:`${be}${Le.changeCount} chg | ${(Le.affectedTables??[]).join(", ")}`,time:jc(Se.timestamp,t.timeFormat)}}const ge=Se.event;return ge?{type:ge.eventType,id:W$(ge,ye),outcome:ge.outcome,duration:`${ge.durationMs}ms`,actor:ge.actorId,client:ge.clientId,detail:`${be}${(ge.tables??[]).join(", ")||"--"}`,time:jc(Se.timestamp,t.timeFormat)}:{type:"pull",id:"E?",outcome:"unknown",duration:"--",actor:"",client:"",detail:"--",time:jc(Se.timestamp,t.timeFormat)}}),[t.timeFormat,D?.items]),de=D?.total??0,Be=Math.max(1,Math.ceil(de/l)),_e=G,re=[{label:"",options:[{id:"all",label:"All"},{id:"commits",label:"Commits"},{id:"events",label:"Events"}],activeId:h,onActiveChange:ae=>{p(ae),ae==="commits"&&(v("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:i,onActiveChange:ae=>{o(ae),C(1)}},{label:"Type",options:[{id:"all",label:"All"},{id:"push",label:"Push"},{id:"pull",label:"Pull"}],activeId:y,onActiveChange:ae=>{v(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 fe(){P.mutate(void 0,{onSuccess:()=>{R(!1),F()}})}return d.jsxs("div",{className:"flex flex-col h-full",children:[_e&&xe.length===0?d.jsx("div",{className:"flex items-center justify-center py-24",children:d.jsx(Mt,{size:"lg"})}):d.jsx(J1,{entries:xe,selectedEntryId:N,onEntryClick:ae=>k(ae.id),filterBar:d.jsx($1,{groups:re,searchValue:E,searchPlaceholder:"Use actor:, client:, table:, request:, trace: or free text...",onSearchChange:_,actions:d.jsxs(d.Fragment,{children:[d.jsx(Ae,{size:"sm",variant:"ghost",onClick:()=>{F()},children:"Refresh"}),d.jsx(Ae,{size:"sm",variant:"ghost",children:"Export"}),d.jsx(Ae,{size:"sm",variant:"destructive",onClick:()=>R(!0),children:"Clear"})]})}),pagination:d.jsx(db,{page:T,totalPages:Be,totalItems:de,onPageChange:C})}),d.jsx(Er,{open:N!==null,onOpenChange:ae=>{ae||k(null)},children:d.jsxs(Xn,{children:[d.jsx(Qn,{children:d.jsx(Wn,{children:te!==void 0?`Commit #${te}`:L!==void 0?`Event E${L}`:"Entry details"})}),d.jsx("div",{className:"px-5 py-4 space-y-3 max-h-[70vh] overflow-y-auto",children:H||I?d.jsx("div",{className:"flex items-center justify-center py-8",children:d.jsx(Mt,{size:"sm"})}):V||K?d.jsx("p",{className:"font-mono text-[11px] text-offline",children:"Failed to load details."}):$?d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"grid grid-cols-2 gap-3 font-mono text-[11px]",children:[d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Actor"}),d.jsx("div",{className:"text-neutral-100",children:$.actorId})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Client"}),d.jsx("div",{className:"text-neutral-100",children:$.clientId})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Instance"}),d.jsx("div",{className:"text-neutral-100",children:$.instanceId??"--"})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Created"}),d.jsx("div",{className:"text-neutral-100",children:jc($.createdAt,t.timeFormat)})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Changes"}),d.jsx("div",{className:"text-neutral-100",children:$.changeCount})]})]}),d.jsxs("div",{children:[d.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2",children:"Affected Tables"}),d.jsx("p",{className:"font-mono text-[11px] text-neutral-200",children:$.affectedTables.join(", ")||"--"})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500",children:"Changes"}),$.changes.length===0?d.jsx("p",{className:"font-mono text-[11px] text-neutral-500",children:"No changes recorded."}):$.changes.map(ae=>d.jsxs("div",{className:"rounded-md border border-border p-3 space-y-2",children:[d.jsxs("div",{className:"flex items-center justify-between font-mono text-[11px]",children:[d.jsxs("span",{className:"text-neutral-300",children:[ae.table," | ",ae.op]}),d.jsxs("span",{className:"text-neutral-500",children:["#",ae.changeId]})]}),d.jsxs("div",{className:"font-mono text-[11px] text-neutral-400",children:["rowId: ",ae.rowId,ae.rowVersion!==null?` | version: ${ae.rowVersion}`:""]}),d.jsx("pre",{className:"font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200",children:ad(ae.rowJson)})]},ae.changeId))]})]}):U?d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"grid grid-cols-2 gap-3 font-mono text-[11px]",children:[d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Type"}),d.jsx("div",{className:"text-neutral-100",children:U.eventType})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Path"}),d.jsx("div",{className:"text-neutral-100",children:U.syncPath})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Instance"}),d.jsx("div",{className:"text-neutral-100",children:U.instanceId??"--"})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Outcome"}),d.jsx("div",{className:"text-neutral-100",children:U.outcome})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Response Status"}),d.jsx("div",{className:"text-neutral-100",children:U.responseStatus})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Actor"}),d.jsx("div",{className:"text-neutral-100",children:U.actorId})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Client"}),d.jsx("div",{className:"text-neutral-100",children:U.clientId})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Status"}),d.jsx("div",{className:"text-neutral-100",children:U.statusCode})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Transport"}),d.jsx("div",{className:"text-neutral-100",children:U.transportPath})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Duration"}),d.jsxs("div",{className:"text-neutral-100",children:[U.durationMs,"ms"]})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Request ID"}),d.jsx("div",{className:"text-neutral-100",children:U.requestId})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Trace ID"}),d.jsx("div",{className:"text-neutral-100",children:U.traceId??"--"}),ie&&d.jsx("a",{href:ie,target:"_blank",rel:"noreferrer",className:"font-mono text-[10px] text-flow underline underline-offset-4",children:"Open external trace"})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Span ID"}),d.jsx("div",{className:"text-neutral-100",children:U.spanId??"--"})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Commit Seq"}),d.jsx("div",{className:"text-neutral-100",children:U.commitSeq??"--"}),U.commitSeq!==null&&d.jsx(Ae,{variant:"ghost",size:"sm",onClick:()=>k(`#${U.instanceId?`${U.instanceId}:`:""}${U.commitSeq}`),children:"Open linked commit"})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Subscription Count"}),d.jsx("div",{className:"text-neutral-100",children:U.subscriptionCount??"--"})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Error Code"}),d.jsx("div",{className:"text-neutral-100",children:U.errorCode??"--"})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Payload Ref"}),d.jsx("div",{className:"text-neutral-100",children:U.payloadRef??"--"})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Created"}),d.jsx("div",{className:"text-neutral-100",children:jc(U.createdAt,t.timeFormat)})]})]}),d.jsxs("div",{children:[d.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2",children:"Tables"}),d.jsx("p",{className:"font-mono text-[11px] text-neutral-200",children:U.tables.join(", ")||"--"})]}),U.scopesSummary&&d.jsxs("div",{children:[d.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2",children:"Scopes Summary"}),d.jsx("pre",{className:"font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200",children:ad(U.scopesSummary)})]}),U.payloadRef&&d.jsxs("div",{children:[d.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2",children:"Payload Snapshot"}),W?d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(Mt,{size:"sm"}),d.jsx("span",{className:"font-mono text-[11px] text-neutral-400",children:"Loading payload snapshot..."})]}):se?d.jsx("p",{className:"font-mono text-[11px] text-offline",children:"Failed to load payload snapshot."}):Z?d.jsxs("div",{className:"space-y-2",children:[d.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500",children:"Request"}),d.jsx("pre",{className:"font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200",children:ad(Z.requestPayload)}),d.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500",children:"Response"}),d.jsx("pre",{className:"font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200",children:ad(Z.responsePayload)})]}):d.jsx("p",{className:"font-mono text-[11px] text-neutral-500",children:"No payload snapshot available."})]}),U.errorMessage&&d.jsxs("div",{children:[d.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2",children:"Error"}),d.jsx("p",{className:"font-mono text-[11px] text-offline",children:U.errorMessage})]})]}):d.jsx("p",{className:"font-mono text-[11px] text-neutral-500",children:"No details available for this row."})}),d.jsx(pn,{children:d.jsx(Ae,{variant:"default",size:"sm",onClick:()=>k(null),children:"Close"})})]})}),d.jsx(Er,{open:M,onOpenChange:ae=>{ae||R(!1)},children:d.jsxs(Xn,{children:[d.jsx(Qn,{children:d.jsx(Wn,{children:"Clear all events"})}),d.jsx("div",{className:"p-4",children:d.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?"})}),d.jsxs(pn,{children:[d.jsx(Ae,{variant:"default",size:"sm",onClick:()=>R(!1),children:"Cancel"}),d.jsx(Ae,{variant:"destructive",size:"sm",onClick:fe,disabled:P.isPending,children:P.isPending?"Clearing...":"Clear all"})]})]})})]})}const J$=Fs({getParentRoute:()=>Vs,path:"/config",component:y$}),e9=Fs({getParentRoute:()=>Vs,path:"/fleet",component:j$}),t9=Fs({getParentRoute:()=>Vs,path:"/",component:g$});function n9(){const{seq:e}=vj.useParams();return d.jsx(gb,{initialSelectedEntryId:`#${e}`})}const vj=Fs({getParentRoute:()=>Vs,path:"/investigate/commit/$seq",component:n9});function r9(){const{id:e}=bj.useParams();return d.jsx(gb,{initialSelectedEntryId:`E${e}`})}const bj=Fs({getParentRoute:()=>Vs,path:"/investigate/event/$id",component:r9}),s9=Fs({getParentRoute:()=>Vs,path:"/ops",component:P$}),i9=Fs({getParentRoute:()=>Vs,path:"/storage",component:G$}),o9=Fs({getParentRoute:()=>Vs,path:"/stream",component:gb}),a9=Vs.addChildren([t9,o9,vj,bj,e9,s9,i9,J$]),l9="syncular-console-basepath",c9="syncular-console-server-url",u9="syncular-console-token";function f9(e){if(!e)return;const t=e.trim();return t.length>0?t:void 0}function Gy(e){const t=globalThis.document;if(!t)return;const n=t.querySelector(`meta[name="${e}"]`)?.getAttribute("content");return f9(n)}function xj(e){return!e||e==="/"?"/":(e.startsWith("/")?e:`/${e}`).replace(/\/+$/g,"")||"/"}function d9(){return xj(Gy(l9))}function h9(){const e=Gy(c9),t=Gy(u9);return!e||!t?null:{serverUrl:e,token:t}}function p9(){return new k5({defaultOptions:{queries:{staleTime:5e3,retry:1}}})}function m9(e){return xj(e??d9())}function g9(e){const[t]=S.useState(()=>p9()),n=S.useMemo(()=>B3({routeTree:a9,basepath:m9(e.basePath)}),[e.basePath]),i=e.defaultConfig===void 0?h9():e.defaultConfig,o=e.autoConnect??e.defaultConfig===void 0;return d.jsx(I5,{client:t,children:d.jsx(t4,{defaultConfig:i,autoConnect:o,storageMode:e.storageMode,children:d.jsx(q3,{router:n})})})}function y9(e){return d.jsx("div",{className:mb,children:d.jsx(g9,{...e})})}function v9(e){const t=document.querySelector(e);if(!t)throw new Error(`Unable to mount console: ${e} not found`);return t}function b9(e,t={}){const n=v9(e);JV(n);const i=c5.createRoot(n),o=d.jsx(y9,{basePath:t.basePath,defaultConfig:t.defaultConfig,autoConnect:t.autoConnect});return t.strictMode===!1?(i.render(o),i):(i.render(d.jsx(S.StrictMode,{children:o})),i)}var x9={};const S9="syncular-sentry-dsn",E9="syncular-sentry-environment",_9="syncular-sentry-release";function Pc(e){if(!e)return;const t=e.trim();return t.length>0?t:void 0}function Xg(e){if(typeof document>"u")return;const t=document.querySelector(`meta[name="${e}"]`)?.getAttribute("content");return Pc(t)}function Qg(e){if(!(typeof process>"u"))return Pc(x9[e])}function Wg(e){for(const t of e)if(t)return t}function w9(){const e=Wg([Pc(globalThis.__SYNCULAR_SENTRY_DSN__),Xg(S9),Qg("SYNCULAR_SENTRY_DSN")]);if(!e)return null;const t=Wg([Pc(globalThis.__SYNCULAR_SENTRY_ENVIRONMENT__),Xg(E9),Qg("SYNCULAR_SENTRY_ENVIRONMENT")]),n=Wg([Pc(globalThis.__SYNCULAR_SENTRY_RELEASE__),Xg(_9),Qg("SYNCULAR_SENTRY_RELEASE")]);return{dsn:e,environment:t,release:n,enableLogs:!0,tracesSampleRate:.2,tracePropagationTargets:[/^https?:\/\/.*\/api\/.*/]}}const NT=w9();NT&&e5(NT);b9("#root");
48
+ )`}return d.jsx("div",{ref:n,role:"presentation","data-base-ui-inert":"",...o,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:l}})});function lh(e,t){e&&Object.assign(e.style,t)}const Kq={position:"relative",maxHeight:"100%",overflowX:"hidden",overflowY:"auto"},Yq={position:"fixed"},Xq=S.forwardRef(function(t,n){const{anchor:i,positionMethod:o="absolute",className:l,render:u,side:f="bottom",align:h="center",sideOffset:p=0,alignOffset:y=0,collisionBoundary:v="clipping-ancestors",collisionPadding:b,arrowPadding:x=5,sticky:E=!1,disableAnchorTracking:_,alignItemWithTrigger:T=!0,collisionAvoidance:C=JU,...M}=t,{store:R,listRef:N,labelsRef:k,alignItemWithTriggerActiveRef:z,selectedItemTextRef:j,valuesRef:A,initialValueRef:D,popupRef:G,setValue:F}=gu(),P=FN(),Q=st(R,rt.open),X=st(R,rt.mounted),te=st(R,rt.modal),L=st(R,rt.value),$=st(R,rt.openMethod),H=st(R,rt.positionerElement),V=st(R,rt.triggerElement),U=st(R,rt.isItemEqualToValue),I=st(R,rt.transitionStatus),K=S.useRef(null),Z=S.useRef(null),[W,se]=S.useState(T),ie=X&&W&&$!=="touch";!X&&W!==T&&se(T),De(()=>{X||(rt.scrollUpArrowVisible(R.state)&&R.set("scrollUpArrowVisible",!1),rt.scrollDownArrowVisible(R.state)&&R.set("scrollDownArrowVisible",!1))},[R,X]),S.useImperativeHandle(z,()=>ie),qN((ie||te)&&Q&&$!=="touch",V);const he=zN({anchor:i,floatingRootContext:P,positionMethod:o,mounted:X,side:f,sideOffset:p,align:h,alignOffset:y,arrowPadding:x,collisionBoundary:v,collisionPadding:b,sticky:E,disableAnchorTracking:_??ie,collisionAvoidance:C,keepMounted:!0}),xe=ie?"none":he.side,de=ie?Yq:he.positionerStyles,Be=S.useMemo(()=>{const be={};return Q||(be.pointerEvents="none"),{role:"presentation",hidden:!X,style:{...de,...be}}},[Q,X,de]),_e={open:Q,side:xe,align:he.align,anchorHidden:he.anchorHidden},re=je(be=>{R.set("positionerElement",be)}),fe=At("div",t,{ref:[n,re],state:_e,stateAttributesMapping:Nl,props:[Be,Ph(I),M]}),ae=S.useRef(0),Se=je(be=>{if(be.size===0&&ae.current===0||A.current.length===0)return;const ge=ae.current;if(ae.current=be.size,be.size===ge)return;const Le=Pt(Pi);if(ge!==0&&!R.state.multiple&&L!==null&&$g(A.current,L,U)===-1){const Ee=D.current,Ke=Ee!=null&&$g(A.current,Ee,U)!==-1?Ee:null;F(Ke,Le),Ke===null&&(R.set("selectedIndex",null),j.current=null)}if(ge!==0&&R.state.multiple&&Array.isArray(L)){const Oe=Fe=>$g(A.current,Fe,U)!==-1,Ee=L.filter(Fe=>Oe(Fe));(Ee.length!==L.length||Ee.some(Fe=>!_q(L,Fe,U)))&&(F(Ee,Le),Ee.length===0&&(R.set("selectedIndex",null),j.current=null))}if(Q&&ie){R.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});const Oe={height:""};lh(H,Oe),lh(G.current,Oe)}}),ye=S.useMemo(()=>({...he,side:xe,alignItemWithTriggerActive:ie,setControlledAlignItemWithTrigger:se,scrollUpArrowRef:K,scrollDownArrowRef:Z}),[he,xe,ie,se]);return d.jsx($N,{elementsRef:N,labelsRef:k,onMapChange:Se,children:d.jsxs(GN.Provider,{value:ye,children:[X&&te&&d.jsx(KN,{inert:cb(!Q),cutout:V}),fe]})})});function YN(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 id="base-ui-disable-scrollbar",pT={className:id,getElement(e){return d.jsx("style",{nonce:e,href:id,precedence:"base-ui:low",children:`.${id}{scrollbar-width:none}.${id}::-webkit-scrollbar{display:none}`})}},Qq=S.createContext(void 0);function XN(e){return S.useContext(Qq)}const Xa="ArrowUp",Ro="ArrowDown",Wc="ArrowLeft",Qa="ArrowRight",yu="Home",vu="End",QN=new Set([Wc,Qa]),Wq=new Set([Wc,Qa,yu,vu]),WN=new Set([Xa,Ro]),Zq=new Set([Xa,Ro,yu,vu]),ZN=new Set([...QN,...WN]),Jq=new Set([...ZN,yu,vu]),JN=new Set([Xa,Ro,Wc,Qa,yu,vu]),e8="Shift",t8="Control",n8="Alt",r8="Meta",s8=new Set([e8,t8,n8,r8]);function i8(e){return Lt(e)&&e.tagName==="INPUT"}function mT(e){return!!(i8(e)&&e.selectionStart!=null||Lt(e)&&e.tagName==="TEXTAREA")}function gT(e,t,n,i){if(!e||!t||!t.scrollTo)return;let o=e.scrollLeft,l=e.scrollTop;const u=e.clientWidth<e.scrollWidth,f=e.clientHeight<e.scrollHeight;if(u&&i!=="vertical"){const h=yT(e,t,"left"),p=od(e),y=od(t);n==="ltr"&&(h+t.offsetWidth+y.scrollMarginRight>e.scrollLeft+e.clientWidth-p.scrollPaddingRight?o=h+t.offsetWidth+y.scrollMarginRight-e.clientWidth+p.scrollPaddingRight:h-y.scrollMarginLeft<e.scrollLeft+p.scrollPaddingLeft&&(o=h-y.scrollMarginLeft-p.scrollPaddingLeft)),n==="rtl"&&(h-y.scrollMarginRight<e.scrollLeft+p.scrollPaddingLeft?o=h-y.scrollMarginLeft-p.scrollPaddingLeft:h+t.offsetWidth+y.scrollMarginRight>e.scrollLeft+e.clientWidth-p.scrollPaddingRight&&(o=h+t.offsetWidth+y.scrollMarginRight-e.clientWidth+p.scrollPaddingRight))}if(f&&i!=="horizontal"){const h=yT(e,t,"top"),p=od(e),y=od(t);h-y.scrollMarginTop<e.scrollTop+p.scrollPaddingTop?l=h-y.scrollMarginTop-p.scrollPaddingTop:h+t.offsetHeight+y.scrollMarginBottom>e.scrollTop+e.clientHeight-p.scrollPaddingBottom&&(l=h+t.offsetHeight+y.scrollMarginBottom-e.clientHeight+p.scrollPaddingBottom)}e.scrollTo({left:o,top:l,behavior:"auto"})}function yT(e,t,n){const i=n==="left"?"offsetLeft":"offsetTop";let o=0;for(;t.offsetParent&&(o+=t[i],t.offsetParent!==e);)t=t.offsetParent;return o}function od(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 Gg(e,t=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(t,Math.min(e,n))}const o8=S.createContext(void 0),a8={disableStyleElements:!1};function l8(){return S.useContext(o8)??a8}const xo=1,c8={...Nl,...Ko},u8=S.forwardRef(function(t,n){const{render:i,className:o,finalFocus:l,...u}=t,{store:f,popupRef:h,onOpenChangeComplete:p,setOpen:y,valueRef:v,selectedItemTextRef:b,keyboardActiveRef:x,multiple:E,handleScrollArrowVisibility:_,scrollHandlerRef:T,highlightItemOnHover:C}=gu(),{side:M,align:R,alignItemWithTriggerActive:N,setControlledAlignItemWithTrigger:k,scrollDownArrowRef:z,scrollUpArrowRef:j}=Gq(),A=XN()!=null,D=FN(),{nonce:G,disableStyleElements:F}=l8(),P=zr(),Q=st(f,rt.id),X=st(f,rt.open),te=st(f,rt.mounted),L=st(f,rt.popupProps),$=st(f,rt.transitionStatus),H=st(f,rt.triggerElement),V=st(f,rt.positionerElement),U=st(f,rt.listElement),I=S.useRef(0),K=S.useRef(!1),Z=S.useRef(0),W=S.useRef(!1),se=S.useRef({}),ie=rb(),he=je(_e=>{if(!V||!h.current||!W.current)return;if(K.current||!N){_();return}const re=V.style.top==="0px",fe=V.style.bottom==="0px",ae=V.getBoundingClientRect().height,Se=_t(V),ye=getComputedStyle(V),be=parseFloat(ye.marginTop),ge=parseFloat(ye.marginBottom),Le=vT(getComputedStyle(h.current)),Oe=Math.min(Se.documentElement.clientHeight-be-ge,Le),Ee=_e.scrollTop,Fe=bT(_e);let Ke=0,ze=null,Xe=!1,Ue=!1;const pe=He=>{V.style.height=`${He}px`},we=(He,dt)=>{const ot=Gg(He,0,Oe-ae);ot>0&&pe(ae+ot),_e.scrollTop=dt,Oe-(ae+ot)<=xo&&(K.current=!0),_()};if(re){const He=Fe-Ee,dt=ae+He,ot=Math.min(dt,Oe);if(Ke=ot,He<=xo){we(He,Fe);return}Oe-ot>xo?Ue=!0:Xe=!0}else if(fe){const He=Ee,dt=ae+He,ot=Math.min(dt,Oe),or=dt-Oe;if(Ke=ot,He<=xo){we(He,0);return}Oe-ot>xo?ze=0:(Xe=!0,Ee<Fe&&(ze=Ee-(He-or)))}if(Ke=Math.ceil(Ke),Ke!==0&&pe(Ke),Ue||ze!=null){const He=bT(_e),dt=Ue?He:Gg(ze,0,He);Math.abs(_e.scrollTop-dt)>xo&&(_e.scrollTop=dt)}(Xe||Ke>=Oe-xo)&&(K.current=!0),_()});S.useImperativeHandle(T,()=>he,[he]),Yo({open:X,ref:h,onComplete(){X&&p?.(!0)}});const xe={open:X,transitionStatus:$,side:M,align:R};De(()=>{!V||!h.current||Object.keys(se.current).length||(se.current={top:V.style.top||"0",left:V.style.left||"0",right:V.style.right,height:V.style.height,bottom:V.style.bottom,minHeight:V.style.minHeight,maxHeight:V.style.maxHeight,marginTop:V.style.marginTop,marginBottom:V.style.marginBottom})},[h,V]),De(()=>{X||N||(W.current=!1,K.current=!1,I.current=0,Z.current=0,lh(V,se.current))},[X,N,V,h]),De(()=>{const _e=h.current;if(!(!X||!H||!V||!_e||f.state.transitionStatus==="ending")){if(!N){W.current=!0,ie.request(_),_e.style.removeProperty("--transform-origin");return}queueMicrotask(()=>{const re=f8(_e);_e.style.removeProperty("--transform-origin");try{const fe=getComputedStyle(V),ae=getComputedStyle(_e),Se=_t(H),ye=Xt(V),be=H.getBoundingClientRect(),ge=V.getBoundingClientRect(),Le=be.left,Oe=be.height,Ee=U||_e,Fe=Ee.scrollHeight,Ke=parseFloat(ae.borderBottomWidth),ze=parseFloat(fe.marginTop)||10,Xe=parseFloat(fe.marginBottom)||10,Ue=parseFloat(fe.minHeight)||100,pe=vT(ae),we=5,He=5,dt=20,ot=Se.documentElement.clientHeight-ze-Xe,or=Se.documentElement.clientWidth,ar=ot-be.bottom+Oe,Ut=b.current,at=v.current;let yt,nt=0,Bt=0;if(Ut&&at){const Pn=at.getBoundingClientRect();yt=Ut.getBoundingClientRect();const $r=Pn.left-Le,$s=yt.left-ge.left,Gs=Pn.top-be.top+Pn.height/2,zn=yt.top-ge.top+yt.height/2;nt=$r-$s,Bt=zn-Gs}const rn=ar+Bt+Xe+Ke;let Ct=Math.min(ot,rn);const dn=ot-ze-Xe,Ln=rn-Ct,gn=Math.max(we,Le+nt),qr=or-He,Vr=Math.max(0,gn+ge.width-qr);V.style.left=`${gn-Vr}px`,V.style.height=`${Ct}px`,V.style.maxHeight="auto",V.style.marginTop=`${ze}px`,V.style.marginBottom=`${Xe}px`,_e.style.height="100%";const Qo=Ee.scrollHeight-Ee.clientHeight,Wi=Ln>=Qo;Wi&&(Ct=Math.min(ot,ge.height)-(Ln-Qo));const Zi=be.top<dt||be.bottom>ot-dt||Ct<Math.min(Fe,Ue),is=(ye.visualViewport?.scale??1)!==1&&Jv;if(Zi||is){W.current=!0,lh(V,se.current),Fi.flushSync(()=>k(!1));return}if(Wi){const Pn=Math.max(0,ot-rn);V.style.top=ge.height>=dn?"0":`${Pn}px`,V.style.height=`${Ct}px`,Ee.scrollTop=Ee.scrollHeight-Ee.clientHeight,I.current=Math.max(Ue,Ct)}else V.style.bottom="0",I.current=Math.max(Ue,Ct),Ee.scrollTop=Ln;if(yt){const Pn=ge.top,$r=ge.height,$s=yt.top+yt.height/2,Gs=$r>0?($s-Pn)/$r*100:50,zn=Gg(Gs,0,100);_e.style.setProperty("--transform-origin",`50% ${zn}%`)}(I.current===ot||Ct>=pe)&&(K.current=!0),_(),setTimeout(()=>{W.current=!0})}finally{re()}})}},[f,X,V,H,v,b,h,_,N,k,ie,z,j,U]),S.useEffect(()=>{if(!N||!V||!X)return;const _e=Xt(V);function re(fe){y(!1,Pt(wB,fe))}return _e.addEventListener("resize",re),()=>{_e.removeEventListener("resize",re)}},[y,N,V,X]);const de={...U?{role:"presentation","aria-orientation":void 0}:{role:"listbox","aria-multiselectable":E||void 0,id:`${Q}-list`},onKeyDown(_e){x.current=!0,A&&JN.has(_e.key)&&_e.stopPropagation()},onMouseMove(){x.current=!1},onPointerLeave(_e){if(!C||YN(_e)||_e.pointerType==="touch")return;const re=_e.currentTarget;P.start(0,()=>{f.set("activeIndex",null),re.focus({preventScroll:!0})})},onScroll(_e){U||he(_e.currentTarget)},...N&&{style:U?{height:"100%"}:Kq}},Be=At("div",t,{ref:[n,h],state:xe,stateAttributesMapping:c8,props:[L,de,Ph($),{className:!U&&N?pT.className:void 0},u]});return d.jsxs(S.Fragment,{children:[!F&&pT.getElement(G),d.jsx(wN,{context:D,modal:!1,disabled:!te,returnFocus:l,restoreFocus:!0,children:Be})]})});function vT(e){const t=e.maxHeight||"";return t.endsWith("px")&&parseFloat(t)||1/0}function bT(e){return Math.max(0,e.scrollHeight-e.clientHeight)}const xT=[["transform","none"],["scale","1"],["translate","0 0"]];function f8(e){const{style:t}=e,n={};for(const[i,o]of xT)n[i]=t.getPropertyValue(i),t.setProperty(i,o,"important");return()=>{for(const[i]of xT){const o=n[i];o?t.setProperty(i,o):t.removeProperty(i)}}}let ej=(function(e){return e[e.None=0]="None",e[e.GuessFromOrder=1]="GuessFromOrder",e})({});function ub(e={}){const{label:t,metadata:n,textRef:i,indexGuessBehavior:o,index:l}=e,{register:u,unregister:f,subscribeMapChange:h,elementsRef:p,labelsRef:y,nextIndexRef:v}=Fq(),b=S.useRef(-1),[x,E]=S.useState(l??(o===ej.GuessFromOrder?()=>{if(b.current===-1){const C=v.current;v.current+=1,b.current=C}return b.current}:-1)),_=S.useRef(null),T=S.useCallback(C=>{if(_.current=C,x!==-1&&C!==null&&(p.current[x]=C,y)){const M=t!==void 0;y.current[x]=M?t:i?.current?.textContent??C.textContent}},[x,p,y,t,i]);return De(()=>{if(l!=null)return;const C=_.current;if(C)return u(C,n),()=>{f(C)}},[l,u,f,n]),De(()=>{if(l==null)return h(C=>{const M=_.current?C.get(_.current)?.index:null;M!=null&&E(M)})},[l,h,E]),S.useMemo(()=>({ref:T,index:x}),[x,T])}const d8=S.createContext(void 0),h8=S.memo(S.forwardRef(function(t,n){const{render:i,className:o,value:l=null,label:u,disabled:f=!1,nativeButton:h=!1,...p}=t,y=S.useRef(null),v=ub({label:u,textRef:y,indexGuessBehavior:ej.GuessFromOrder}),{store:b,getItemProps:x,setOpen:E,setValue:_,selectionRef:T,typingRef:C,valuesRef:M,keyboardActiveRef:R,multiple:N,highlightItemOnHover:k}=gu(),z=zr(),j=st(b,rt.isActive,v.index),A=st(b,rt.isSelected,v.index,l),D=st(b,rt.isSelectedByFocus,v.index),G=st(b,rt.isItemEqualToValue),F=v.index,P=F!==-1,Q=S.useRef(null),X=ki(F);De(()=>{if(!P)return;const ie=M.current;return ie[F]=l,()=>{delete ie[F]}},[P,F,l,M]),De(()=>{if(!P)return;const ie=b.state.value;let he=ie;N&&Array.isArray(ie)&&ie.length>0&&(he=ie[ie.length-1]),he!==void 0&&ul(l,he,G)&&b.set("selectedIndex",F)},[P,F,N,G,b,l]);const te={disabled:f,selected:A,highlighted:j},L=x({active:j,selected:A});L.onFocus=void 0,L.id=void 0;const $=S.useRef(null),H=S.useRef("mouse"),V=S.useRef(!1),{getButtonProps:U,buttonRef:I}=El({disabled:f,focusableWhenDisabled:!0,native:h});function K(ie){const he=b.state.value;if(N){const xe=Array.isArray(he)?he:[],de=A?wq(xe,l,G):[...xe,l];_(de,Pt(Ig,ie))}else _(l,Pt(Ig,ie)),E(!1,Pt(Ig,ie))}const Z={role:"option","aria-selected":A,tabIndex:j?0:-1,onFocus(){b.set("activeIndex",F)},onMouseEnter(){!R.current&&b.state.selectedIndex===null&&k&&b.set("activeIndex",F)},onMouseMove(){k&&b.set("activeIndex",F)},onMouseLeave(ie){!k||R.current||YN(ie)||z.start(0,()=>{b.state.activeIndex===F&&b.set("activeIndex",null)})},onTouchStart(){T.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1}},onKeyDown(ie){$.current=ie.key,b.set("activeIndex",F)},onClick(ie){V.current=!1,!(ie.type==="keydown"&&$.current===null)&&(f||$.current===" "&&C.current||H.current!=="touch"&&!j||($.current=null,K(ie.nativeEvent)))},onPointerEnter(ie){H.current=ie.pointerType},onPointerDown(ie){H.current=ie.pointerType,V.current=!0},onMouseUp(ie){if(f)return;if(V.current){V.current=!1;return}const he=!T.current.allowSelectedMouseUp&&A,xe=!T.current.allowUnselectedMouseUp&&!A;he||xe||H.current!=="touch"&&!j||K(ie.nativeEvent)}},W=At("div",t,{ref:[I,n,v.ref,Q],state:te,props:[L,Z,p,U]}),se=S.useMemo(()=>({selected:A,indexRef:X,textRef:y,selectedByFocus:D,hasRegistered:P}),[A,X,y,D,P]);return d.jsx(d8.Provider,{value:se,children:W})})),p8=S.forwardRef(({className:e,children:t,...n},i)=>d.jsx(kq,{ref:i,className:me("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}));p8.displayName="SelectTrigger";const m8=S.forwardRef(({className:e,portalProps:t,positionerProps:n,...i},o)=>d.jsx(Dq,{...t,children:d.jsx(Xq,{...n,children:d.jsx(u8,{ref:o,className:me("bg-panel border border-border rounded-md py-1 shadow-lg z-50",e),...i})})}));m8.displayName="SelectContent";const g8=S.forwardRef(({className:e,...t},n)=>d.jsx(h8,{ref:n,className:me("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}));g8.displayName="SelectItem";const y8=S.forwardRef(({className:e,...t},n)=>d.jsx("textarea",{ref:n,className:me("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}));y8.displayName="Textarea";const tj=S.createContext(void 0);function v8(e=!0){const t=S.useContext(tj);if(t===void 0&&!e)throw new Error(nn(7));return t}function nj(e={}){const{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:i}=M1(),{ref:o,index:l}=ub(e),u=n===l,f=S.useRef(null),h=Us(o,f);return{compositeProps:S.useMemo(()=>({tabIndex:u?0:-1,onFocus(){i(l)},onMouseMove(){const y=f.current;if(!t||!y)return;const v=y.hasAttribute("disabled")||y.ariaDisabled==="true";!u&&!v&&y.focus()}}),[u,i,l,t]),compositeRef:h,index:l}}function b8(e){const{render:t,className:n,state:i=Kt,props:o=Yc,refs:l=Yc,metadata:u,stateAttributesMapping:f,tag:h="div",...p}=e,{compositeProps:y,compositeRef:v}=nj({metadata:u});return At(h,e,{state:i,ref:[...l,v],props:[y,...o,p],stateAttributesMapping:f})}const x8=S.forwardRef(function(t,n){const{className:i,defaultPressed:o=!1,disabled:l=!1,form:u,onPressedChange:f,pressed:h,render:p,type:y,value:v,nativeButton:b=!0,...x}=t,E=tr(v||void 0),_=v8(),T=_?.value??[],C=_?void 0:o,M=(l||_?.disabled)??!1,[R,N]=_h({controlled:_?E!==void 0&&T.indexOf(E)>-1:h,default:C,name:"Toggle",state:"pressed"}),k=je((P,Q)=>{E&&_?.setGroupValue?.(E,P,Q),f?.(P,Q)}),{getButtonProps:z,buttonRef:j}=El({disabled:M,native:b}),A={disabled:M,pressed:R},D=[j,n],G=[{"aria-pressed":R,onClick(P){const Q=!R,X=Pt(Pi,P.nativeEvent);k(Q,X),!X.isCanceled&&N(Q)}},x,z],F=At("button",t,{enabled:!_,state:A,ref:D,props:G});return _?d.jsx(b8,{tag:"button",render:p,className:i,state:A,refs:D,props:G}):F}),rj=S.forwardRef(({className:e,...t},n)=>d.jsx(x8,{ref:n,className:me("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}));rj.displayName="Toggle";function S8(e){return e==null||e.hasAttribute("disabled")||e.getAttribute("aria-disabled")==="true"}const sj="data-composite-item-active",E8=[];function _8(e){const{itemSizes:t,cols:n=1,loopFocus:i=!0,dense:o=!1,orientation:l="both",direction:u,highlightedIndex:f,onHighlightedIndexChange:h,rootRef:p,enableHomeAndEndKeys:y=!1,stopEventPropagation:v=!1,disabledIndices:b,modifierKeys:x=E8}=e,[E,_]=S.useState(0),T=n>1,C=S.useRef(null),M=Us(C,p),R=S.useRef([]),N=S.useRef(!1),k=f??E,z=je((D,G=!1)=>{if((h??_)(D),G){const F=R.current[D];gT(C.current,F,u,l)}}),j=je(D=>{if(D.size===0||N.current)return;N.current=!0;const G=Array.from(D.keys()),F=G.find(Q=>Q?.hasAttribute(sj))??null,P=F?G.indexOf(F):-1;P!==-1&&z(P),gT(C.current,F,u,l)}),A=S.useMemo(()=>({"aria-orientation":l==="both"?void 0:l,ref:M,onFocus(D){!C.current||!mT(D.target)||D.target.setSelectionRange(0,D.target.value.length??0)},onKeyDown(D){const G=y?Jq:ZN;if(!G.has(D.key)||w8(D,x)||!C.current)return;const P=u==="rtl",Q=P?Wc:Qa,X={horizontal:Q,vertical:Ro,both:Q}[l],te=P?Qa:Wc,L={horizontal:te,vertical:Xa,both:te}[l];if(mT(D.target)&&!S8(D.target)){const Z=D.target.selectionStart,W=D.target.selectionEnd,se=D.target.value??"";if(Z==null||D.shiftKey||Z!==W||D.key!==L&&Z<se.length||D.key!==X&&Z>0)return}let $=k;const H=zH(R,b),V=UH(R,b);if(T){const Z=t||Array.from({length:R.current.length},()=>({width:1,height:1})),W=HH(Z,n,o),se=W.findIndex(he=>he!=null&&!Dc(R,he,b)),ie=W.reduce((he,xe,de)=>xe!=null&&!Dc(R,xe,b)?de:he,-1);$=W[BH({current:W.map(he=>he?R.current[he]:null)},{event:D,orientation:l,loopFocus:i,cols:n,disabledIndices:qH([...b||R.current.map((he,xe)=>Dc(R,xe)?xe:void 0),void 0],W),minIndex:se,maxIndex:ie,prevIndex:FH(k>V?H:k,Z,W,n,D.key===Ro?"bl":D.key===Qa?"tr":"tl"),rtl:P})]}const U={horizontal:[Q],vertical:[Ro],both:[Q,Ro]}[l],I={horizontal:[te],vertical:[Xa],both:[te,Xa]}[l],K=T?G:{horizontal:y?Wq:QN,vertical:y?Zq:WN,both:G}[l];y&&(D.key===yu?$=H:D.key===vu&&($=V)),$===k&&(U.includes(D.key)||I.includes(D.key))&&(i&&$===V&&U.includes(D.key)?$=H:i&&$===H&&I.includes(D.key)?$=V:$=Kn(R,{startingIndex:$,decrement:I.includes(D.key),disabledIndices:b})),$!==k&&!Ed(R,$)&&(v&&D.stopPropagation(),K.has(D.key)&&D.preventDefault(),z($,!0),queueMicrotask(()=>{R.current[$]?.focus()}))}}),[n,o,u,b,R,y,k,T,t,i,M,x,z,l,v]);return S.useMemo(()=>({props:A,highlightedIndex:k,onHighlightedIndexChange:z,elementsRef:R,disabledIndices:b,onMapChange:j,relayKeyboardEvent:A.onKeyDown}),[A,k,z,R,b,j])}function w8(e,t){for(const n of s8.values())if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function ij(e){const{render:t,className:n,refs:i=Yc,props:o=Yc,state:l=Kt,stateAttributesMapping:u,highlightedIndex:f,onHighlightedIndexChange:h,orientation:p,dense:y,itemSizes:v,loopFocus:b,cols:x,enableHomeAndEndKeys:E,onMapChange:_,stopEventPropagation:T=!0,rootRef:C,disabledIndices:M,modifierKeys:R,highlightItemOnHover:N=!1,tag:k="div",...z}=e,j=LN(),{props:A,highlightedIndex:D,onHighlightedIndexChange:G,elementsRef:F,onMapChange:P,relayKeyboardEvent:Q}=_8({itemSizes:v,cols:x,loopFocus:b,dense:y,orientation:p,highlightedIndex:f,onHighlightedIndexChange:h,rootRef:C,stopEventPropagation:T,enableHomeAndEndKeys:E,direction:j,disabledIndices:M,modifierKeys:R}),X=At(k,e,{state:l,ref:i,props:[A,...o,z],stateAttributesMapping:u}),te=S.useMemo(()=>({highlightedIndex:D,onHighlightedIndexChange:G,highlightItemOnHover:N,relayKeyboardEvent:Q}),[D,G,N,Q]);return d.jsx(j1.Provider,{value:te,children:d.jsx($N,{elementsRef:F,onMapChange:L=>{_?.(L),P(L)},children:X})})}let T8=(function(e){return e.disabled="data-disabled",e.orientation="data-orientation",e.multiple="data-multiple",e})({});const ST={multiple(e){return e?{[T8.multiple]:""}:null}},C8=S.forwardRef(function(t,n){const{defaultValue:i,disabled:o=!1,loopFocus:l=!0,onValueChange:u,orientation:f="horizontal",multiple:h=!1,value:p,className:y,render:v,...b}=t,x=XN(),E=S.useMemo(()=>{if(p===void 0)return i??[]},[p,i]),_=S.useMemo(()=>p!==void 0||i!==void 0,[p,i]),T=(x?.disabled??!1)||o,[C,M]=_h({controlled:p,default:E,name:"ToggleGroup",state:"value"}),R=je((A,D,G)=>{let F;if(h?(F=C.slice(),D?F.push(A):F.splice(C.indexOf(A),1)):F=D?[A]:[],Array.isArray(F)){if(u?.(F,G),G.isCanceled)return;M(F)}}),N={disabled:T,multiple:h,orientation:f},k=S.useMemo(()=>({disabled:T,orientation:f,setGroupValue:R,value:C,isValueInitialized:_}),[T,f,R,C,_]),z={role:"group"},j=At("div",t,{enabled:!!x,state:N,ref:n,props:[z,b],stateAttributesMapping:ST});return d.jsx(tj.Provider,{value:k,children:x?j:d.jsx(ij,{render:v,className:y,state:N,refs:[n],props:[z,b],stateAttributesMapping:ST,loopFocus:l,enableHomeAndEndKeys:!0})})}),Cd=S.forwardRef(({className:e,...t},n)=>d.jsx(C8,{ref:n,className:me("flex items-center gap-0.5",e),...t}));Cd.displayName="ToggleGroup";const R8=me(q1({variant:"secondary",size:"sm"}),"h-7 whitespace-nowrap uppercase tracking-[0.08em] leading-none no-underline");function oj({active:e,onClick:t,children:n,className:i}){return d.jsxs("button",{type:"button",onClick:t,className:me("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",i),children:[n,e&&d.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 N8({items:e,activeId:t,onItemChange:n,renderItem:i,className:o}){return d.jsx("div",{className:me("flex items-center gap-0.5",o),children:e.map(l=>{const u=l.id===t,f=()=>n?.(l.id);return i?d.jsx("span",{children:i(l,{active:u,onClick:f})},l.id):d.jsx(oj,{active:u,onClick:f,children:l.label},l.id)})})}const j8=Vi("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}}),M8={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 A8({color:e,size:t,glow:n,pulse:i,className:o}){return d.jsx("span",{className:me(j8({color:e,size:t,glow:n}),i&&"dot-pulse",o),style:n?{boxShadow:M8[e??"healthy"]}:void 0})}const O8="0.0.6-224",k8={version:O8},I8=k8.version;function D8({label:e,className:t}){return d.jsxs("div",{className:me("flex items-center gap-3",t),children:[d.jsx(A8,{color:"healthy",size:"md",glow:!0}),d.jsx("span",{className:"font-display font-bold text-white text-sm tracking-tight",children:"syncular"}),e&&d.jsx("span",{className:"font-mono text-[9px] text-neutral-600 uppercase tracking-widest",children:e}),d.jsxs("span",{className:"font-mono text-[9px] text-neutral-600 tracking-wider",children:["v",I8]})]})}function L8({brand:e,center:t,right:n,className:i}){return d.jsxs(d.Fragment,{children:[d.jsx("div",{"aria-hidden":"true",className:"h-[42px] shrink-0"}),d.jsxs("nav",{className:me("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",i),children:[d.jsx("div",{className:"flex items-center gap-3",children:e}),d.jsx("div",{className:"flex items-center gap-0.5",children:t}),d.jsx("div",{className:"flex items-center gap-2",children:n})]})]})}const P8=Vi("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"}}),bn=S.forwardRef(({className:e,variant:t,...n},i)=>d.jsx("div",{ref:i,role:"alert",className:me(P8({variant:t,className:e})),...n}));bn.displayName="Alert";const bu=S.forwardRef(({className:e,...t},n)=>d.jsx("h5",{ref:n,className:me("font-medium text-white mb-1",e),...t}));bu.displayName="AlertTitle";const xn=S.forwardRef(({className:e,...t},n)=>d.jsx("p",{ref:n,className:me("text-neutral-400",e),...t}));xn.displayName="AlertDescription";const aj=S.createContext(void 0);function jl(e){const t=S.useContext(aj);if(e===!1&&t===void 0)throw new Error(nn(27));return t}const z8={...Nl,...Ko},fb=S.forwardRef(function(t,n){const{render:i,className:o,forceRender:l=!1,...u}=t,{store:f}=jl(),h=f.useState("open"),p=f.useState("nested"),y=f.useState("mounted"),v=f.useState("transitionStatus");return At("div",t,{state:{open:h,transitionStatus:v},ref:[f.context.backdropRef,n],stateAttributesMapping:z8,props:[{role:"presentation",hidden:!y,style:{userSelect:"none",WebkitUserSelect:"none"}},u],enabled:l||!p})}),lj=S.forwardRef(function(t,n){const{render:i,className:o,id:l,...u}=t,{store:f}=jl(),h=tr(l);return f.useSyncedValueWithCleanup("descriptionElementId",h),At("p",t,{ref:n,props:[{id:h},u]})});let U8=(function(e){return e.nestedDialogs="--nested-dialogs",e})({}),B8=(function(e){return e[e.open=Co.open]="open",e[e.closed=Co.closed]="closed",e[e.startingStyle=Co.startingStyle]="startingStyle",e[e.endingStyle=Co.endingStyle]="endingStyle",e.nested="data-nested",e.nestedDialogOpen="data-nested-dialog-open",e})({});const cj=S.createContext(void 0);function H8(){const e=S.useContext(cj);if(e===void 0)throw new Error(nn(26));return e}const F8={...Nl,...Ko,nestedDialogOpen(e){return e?{[B8.nestedDialogOpen]:""}:null}},uj=S.forwardRef(function(t,n){const{className:i,finalFocus:o,initialFocus:l,render:u,...f}=t,{store:h}=jl(),p=h.useState("descriptionElementId"),y=h.useState("disablePointerDismissal"),v=h.useState("floatingRootContext"),b=h.useState("popupProps"),x=h.useState("modal"),E=h.useState("mounted"),_=h.useState("nested"),T=h.useState("nestedOpenDialogCount"),C=h.useState("open"),M=h.useState("openMethod"),R=h.useState("titleElementId"),N=h.useState("transitionStatus"),k=h.useState("role");H8(),Yo({open:C,ref:h.context.popupRef,onComplete(){C&&h.context.onOpenChangeComplete?.(!0)}});function z(F){return F==="touch"?h.context.popupRef.current:!0}const j=l===void 0?z:l,A=T>0,G=At("div",t,{state:{open:C,nested:_,transitionStatus:N,nestedDialogOpen:A},props:[b,{"aria-labelledby":R??void 0,"aria-describedby":p??void 0,role:k,tabIndex:-1,hidden:!E,onKeyDown(F){JN.has(F.key)&&F.stopPropagation()},style:{[U8.nestedDialogs]:T}},f],ref:[n,h.context.popupRef,h.useStateSetter("popupElement")],stateAttributesMapping:F8});return d.jsx(wN,{context:v,openInteractionType:M,disabled:!E,closeOnFocusOut:!y,initialFocus:j,returnFocus:o,modal:x!==!1,restoreFocus:"popup",children:G})}),fj=S.forwardRef(function(t,n){const{keepMounted:i=!1,...o}=t,{store:l}=jl(),u=l.useState("mounted"),f=l.useState("modal"),h=l.useState("open");return u||i?d.jsx(cj.Provider,{value:i,children:d.jsxs(_N,{ref:n,...o,children:[u&&f===!0&&d.jsx(KN,{ref:l.context.internalBackdropRef,inert:cb(!h)}),t.children]})}):null});function q8(e){const{store:t,parentContext:n,actionsRef:i}=e,o=t.useState("open"),l=t.useState("disablePointerDismissal"),u=t.useState("modal"),f=t.useState("popupElement"),{openMethod:h,triggerProps:p,reset:y}=jq(o);bF(t);const{forceUnmount:v}=xF(o,t,()=>{y()}),b=je(G=>{const F=Pt(G);return F.preventUnmountOnClose=()=>{t.set("preventUnmountingOnClose",!0)},F}),x=S.useCallback(()=>{t.setOpen(!1,b(_B))},[t,b]);S.useImperativeHandle(i,()=>({unmount:v,close:x}),[v,x]);const E=CF({popupStore:t,onOpenChange:t.setOpen,treatPopupAsFloatingElement:!0,noEmit:!0}),[_,T]=S.useState(0),C=_===0,M=DF(E),R=aF(E,{outsidePressEvent(){return t.context.internalBackdropRef.current||t.context.backdropRef.current?"intentional":{mouse:u==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}},outsidePress(G){if(!t.context.outsidePressEnabledRef.current||"button"in G&&G.button!==0||"touches"in G&&G.touches.length!==1)return!1;const F=Sr(G);if(C&&!l){const P=F;return u&&(t.context.internalBackdropRef.current||t.context.backdropRef.current)?t.context.internalBackdropRef.current===P||t.context.backdropRef.current===P||Rt(P,f)&&!P?.hasAttribute("data-base-ui-portal"):!0}return!1},escapeKey:C});qN(o&&u===!0,f);const{getReferenceProps:N,getFloatingProps:k,getTriggerProps:z}=kF([M,R]);t.useContextCallback("onNestedDialogOpen",G=>{T(G+1)}),t.useContextCallback("onNestedDialogClose",()=>{T(0)}),S.useEffect(()=>(n?.onNestedDialogOpen&&o&&n.onNestedDialogOpen(_),n?.onNestedDialogClose&&!o&&n.onNestedDialogClose(),()=>{n?.onNestedDialogClose&&o&&n.onNestedDialogClose()}),[o,n,_]);const j=S.useMemo(()=>N(p),[N,p]),A=S.useMemo(()=>z(p),[z,p]),D=S.useMemo(()=>k(),[k]);t.useSyncedValues({openMethod:h,activeTriggerProps:j,inactiveTriggerProps:A,popupProps:D,floatingRootContext:E,nestedOpenDialogCount:_})}const V8={..._F,modal:ke(e=>e.modal),nested:ke(e=>e.nested),nestedOpenDialogCount:ke(e=>e.nestedOpenDialogCount),disablePointerDismissal:ke(e=>e.disablePointerDismissal),openMethod:ke(e=>e.openMethod),descriptionElementId:ke(e=>e.descriptionElementId),titleElementId:ke(e=>e.titleElementId),viewportElement:ke(e=>e.viewportElement),role:ke(e=>e.role)};class $8 extends kN{constructor(t){super(G8(t),{popupRef:S.createRef(),backdropRef:S.createRef(),internalBackdropRef:S.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:new ab,onOpenChange:void 0,onOpenChangeComplete:void 0},V8)}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 i={open:t,nativeEvent:n.event,reason:n.reason,nested:this.state.nested};this.state.floatingRootContext.context.events?.emit("openchange",i);const o={open:t},l=n.trigger?.id??null;(l||t)&&(o.activeTriggerId=l,o.activeTriggerElement=n.trigger??null),this.update(o)}}function G8(e={}){return{...EF(),modal:!0,disablePointerDismissal:!1,popupElement:null,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,role:"dialog",...e}}function K8(e){const{children:t,open:n,defaultOpen:i=!1,onOpenChange:o,onOpenChangeComplete:l,disablePointerDismissal:u=!1,modal:f=!0,actionsRef:h,handle:p,triggerId:y,defaultTriggerId:v=null}=e,b=jl(!0),x=!!b,E=En(()=>p?.store??new $8({open:i,openProp:n,activeTriggerId:v,triggerIdProp:y,modal:f,disablePointerDismissal:u,nested:x})).current;cH(()=>{n===void 0&&E.state.open===!1&&i===!0&&E.update({open:!0,activeTriggerId:v})}),E.useControlledProp("openProp",n),E.useControlledProp("triggerIdProp",y),E.useSyncedValues({disablePointerDismissal:u,nested:x,modal:f}),E.useContextCallback("onOpenChange",o),E.useContextCallback("onOpenChangeComplete",l);const _=E.useState("payload");q8({store:E,actionsRef:h,parentContext:b?.store.context});const T=S.useMemo(()=>({store:E}),[E]);return d.jsx(aj.Provider,{value:T,children:typeof t=="function"?t({payload:_}):t})}const dj=S.forwardRef(function(t,n){const{render:i,className:o,id:l,...u}=t,{store:f}=jl(),h=tr(l);return f.useSyncedValueWithCleanup("titleElementId",h),At("h2",t,{ref:n,props:[{id:h},u]})}),Er=K8,Y8=S.forwardRef(({className:e,...t},n)=>d.jsx(fb,{ref:n,className:me("fixed inset-0 z-50 bg-black/60 backdrop-blur-sm",e),...t}));Y8.displayName="DialogOverlay";const Xn=S.forwardRef(({className:e,children:t,...n},i)=>d.jsxs(fj,{children:[d.jsx(fb,{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm"}),d.jsx(uj,{ref:i,className:me("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})]}));Xn.displayName="DialogContent";const Qn=S.forwardRef(({className:e,...t},n)=>d.jsx("div",{ref:n,className:me("px-5 py-3 border-b border-border",e),...t}));Qn.displayName="DialogHeader";const pn=S.forwardRef(({className:e,...t},n)=>d.jsx("div",{ref:n,className:me("px-5 py-3 border-t border-border flex justify-end gap-2",e),...t}));pn.displayName="DialogFooter";const Wn=S.forwardRef(({className:e,...t},n)=>d.jsx(dj,{ref:n,className:me("font-mono text-[10px] text-neutral-500 uppercase tracking-widest",e),...t}));Wn.displayName="DialogTitle";const X8=S.forwardRef(({className:e,...t},n)=>d.jsx(lj,{ref:n,className:me("font-mono text-[10px] text-neutral-500",e),...t}));X8.displayName="DialogDescription";const db=S.forwardRef(({className:e,page:t,totalPages:n,totalItems:i,onPageChange:o,...l},u)=>d.jsxs("div",{ref:u,className:me("px-5 py-2.5 border-t border-border flex items-center justify-between",e),...l,children:[d.jsxs("span",{className:"font-mono text-[10px] text-neutral-600",children:[i," items · Page ",t," of ",n]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx(Ae,{size:"sm",variant:"default",disabled:t<=1,onClick:()=>o(t-1),children:"Prev"}),d.jsx(Ae,{size:"sm",variant:"default",disabled:t>=n,onClick:()=>o(t+1),children:"Next"})]})]}));db.displayName="Pagination";const Q8=S.forwardRef(({className:e,orientation:t="horizontal",...n},i)=>d.jsx("hr",{ref:i,"aria-orientation":t==="vertical"?"vertical":void 0,className:me("border-none m-0",t==="horizontal"?"h-px w-full bg-border":"w-px h-4 bg-border",e),...n}));Q8.displayName="Separator";const W8=Vi("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"}}),Z8=S.forwardRef(({className:e,side:t,children:n,...i},o)=>d.jsxs(fj,{children:[d.jsx(fb,{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm"}),d.jsx(uj,{ref:o,className:me(W8({side:t,className:e})),...i,children:n})]}));Z8.displayName="SheetContent";const J8=S.forwardRef(({className:e,...t},n)=>d.jsx("div",{ref:n,className:me("px-5 py-3 border-b border-border",e),...t}));J8.displayName="SheetHeader";const eV=S.forwardRef(({className:e,...t},n)=>d.jsx("div",{ref:n,className:me("px-5 py-3 border-t border-border flex justify-end gap-2",e),...t}));eV.displayName="SheetFooter";const tV=S.forwardRef(({className:e,...t},n)=>d.jsx(dj,{ref:n,className:me("font-mono text-[10px] text-neutral-500 uppercase tracking-widest",e),...t}));tV.displayName="SheetTitle";const nV=S.forwardRef(({className:e,...t},n)=>d.jsx(lj,{ref:n,className:me("text-sm text-neutral-400",e),...t}));nV.displayName="SheetDescription";const rV=S.forwardRef(({className:e,...t},n)=>d.jsx("div",{ref:n,className:me("rounded-md bg-neutral-800 animate-pulse",e),...t}));rV.displayName="Skeleton";const sV=S.createContext(void 0);function hb(){const e=S.useContext(sV);if(e===void 0)throw new Error(nn(64));return e}let iV=(function(e){return e.activationDirection="data-activation-direction",e.orientation="data-orientation",e})({});const hj={tabActivationDirection:e=>({[iV.activationDirection]:e})},pj=S.createContext(void 0);function oV(){const e=S.useContext(pj);if(e===void 0)throw new Error(nn(65));return e}const aV=S.forwardRef(function(t,n){const{className:i,disabled:o=!1,render:l,value:u,id:f,nativeButton:h=!0,...p}=t,{value:y,getTabPanelIdByValue:v,orientation:b}=hb(),{activateOnFocus:x,highlightedTabIndex:E,onTabActivation:_,setHighlightedTabIndex:T,tabsListElement:C}=oV(),M=tr(f),R=S.useMemo(()=>({disabled:o,id:M,value:u}),[o,M,u]),{compositeProps:N,compositeRef:k,index:z}=nj({metadata:R}),j=u===y,A=S.useRef(!1);De(()=>{if(A.current){A.current=!1;return}if(!(j&&z>-1&&E!==z))return;const V=C;if(V!=null){const U=Si(_t(V));if(U&&Rt(V,U))return}o||T(z)},[j,z,E,T,o,C]);const{getButtonProps:D,buttonRef:G}=El({disabled:o,native:h,focusableWhenDisabled:!0}),F=v(u),P=S.useRef(!1),Q=S.useRef(!1);function X(V){j||o||_(u,Pt(Pi,V.nativeEvent,void 0,{activationDirection:"none"}))}function te(V){j||(z>-1&&!o&&T(z),!o&&x&&(!P.current||P.current&&Q.current)&&_(u,Pt(Pi,V.nativeEvent,void 0,{activationDirection:"none"})))}function L(V){if(j||o)return;P.current=!0;function U(){P.current=!1,Q.current=!1}(!V.button||V.button===0)&&(Q.current=!0,_t(V.currentTarget).addEventListener("pointerup",U,{once:!0}))}return At("button",t,{state:{disabled:o,active:j,orientation:b},ref:[n,G,k],props:[N,{role:"tab","aria-controls":F,"aria-selected":j,id:M,onClick:X,onFocus:te,onPointerDown:L,[sj]:j?"":void 0,onKeyDownCapture(){A.current=!0}},p,D]})});let lV=(function(e){return e.index="data-index",e.activationDirection="data-activation-direction",e.orientation="data-orientation",e.hidden="data-hidden",e})({});const cV={...hj,...Ko},uV=S.forwardRef(function(t,n){const{className:i,value:o,render:l,keepMounted:u=!1,...f}=t,{value:h,getTabIdByPanelValue:p,orientation:y,tabActivationDirection:v,registerMountedTabPanel:b,unregisterMountedTabPanel:x}=hb(),E=tr(),_=S.useMemo(()=>({id:E,value:o}),[E,o]),{ref:T,index:C}=ub({metadata:_}),M=o===h,{mounted:R,transitionStatus:N,setMounted:k}=Lh(M),z=!R,j=p(o),A={hidden:z,orientation:y,tabActivationDirection:v,transitionStatus:N},D=S.useRef(null),G=At("div",t,{state:A,ref:[n,T,D],props:[{"aria-labelledby":j,hidden:z,id:E,role:"tabpanel",tabIndex:M?0:-1,inert:cb(!M),[lV.index]:C},f],stateAttributesMapping:cV});return Yo({open:M,ref:D,onComplete(){M||k(!1)}}),De(()=>{if(!(z&&!u)&&E!=null)return b(o,E),()=>{x(o,E)}},[z,u,o,E,b,x]),u||R?G:null}),fV=S.forwardRef(function(t,n){const{activateOnFocus:i=!1,className:o,loopFocus:l=!0,render:u,...f}=t,{getTabElementBySelectedValue:h,onValueChange:p,orientation:y,value:v,setTabMap:b,tabActivationDirection:x}=hb(),[E,_]=S.useState(0),[T,C]=S.useState(null),M=dV(v,y,T,h),R=je((j,A)=>{if(j!==v){const D=M(j);A.activationDirection=D,p(j,A)}}),N={orientation:y,tabActivationDirection:x},k={"aria-orientation":y==="vertical"?"vertical":void 0,role:"tablist"},z=S.useMemo(()=>({activateOnFocus:i,highlightedTabIndex:E,onTabActivation:R,setHighlightedTabIndex:_,tabsListElement:T,value:v}),[i,E,R,_,T,v]);return d.jsx(pj.Provider,{value:z,children:d.jsx(ij,{render:u,className:o,state:N,refs:[n,C],props:[k,f],stateAttributesMapping:hj,highlightedIndex:E,enableHomeAndEndKeys:!0,loopFocus:l,orientation:y,onHighlightedIndexChange:_,onMapChange:b,disabledIndices:Yc})})});function ET(e,t){const{left:n,top:i}=e.getBoundingClientRect(),{left:o,top:l}=t.getBoundingClientRect(),u=n-o,f=i-l;return{left:u,top:f}}function dV(e,t,n,i){const[o,l]=S.useState(null);return De(()=>{if(e==null||n==null){l(null);return}const u=i(e);if(u==null){l(null);return}const{left:f,top:h}=ET(u,n);l(t==="horizontal"?f:h)},[t,i,n,e]),S.useCallback(u=>{if(u===e)return"none";if(u==null)return l(null),"none";if(u!=null&&n!=null){const f=i(u);if(f!=null){const{left:h,top:p}=ET(f,n);if(o==null)return l(t==="horizontal"?h:p),"none";if(t==="horizontal"){if(h<o)return l(h),"left";if(h>o)return l(h),"right"}else{if(p<o)return l(p),"up";if(p>o)return l(p),"down"}}}return"none"},[i,t,o,n,e])}const hV=S.forwardRef(({className:e,...t},n)=>d.jsx(fV,{ref:n,className:me("flex items-center gap-0.5",e),...t}));hV.displayName="TabsList";const pV=Vi("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"}}),mV=S.forwardRef(({className:e,variant:t,...n},i)=>d.jsx(aV,{ref:i,className:me(pV({variant:t,className:e})),...n}));mV.displayName="TabsTrigger";const gV=S.forwardRef(({className:e,...t},n)=>d.jsx(uV,{ref:n,className:me("outline-none",e),...t}));gV.displayName="TabsContent";const yV=S.forwardRef(({className:e,...t},n)=>d.jsx("p",{ref:n,className:me("font-mono text-[11px] text-neutral-300",e),...t}));yV.displayName="Text";const vV=S.forwardRef(({className:e,...t},n)=>d.jsx("p",{ref:n,className:me("font-mono text-[10px] text-neutral-500",e),...t}));vV.displayName="TextMuted";const bV=S.forwardRef(({className:e,...t},n)=>d.jsx("code",{ref:n,className:me("font-mono text-[11px] text-white",e),...t}));bV.displayName="TextCode";const xV=S.forwardRef(({className:e,...t},n)=>d.jsx("span",{ref:n,className:me("font-mono text-[9px] uppercase tracking-wider text-neutral-500",e),...t}));xV.displayName="TextLabel";const SV=S.forwardRef(({className:e,...t},n)=>d.jsx("pre",{ref:n,className:me("font-mono text-[11px] text-neutral-300 p-3 rounded border border-border bg-panel-alt overflow-x-auto",e),...t}));SV.displayName="CodeBlock";function Xo(e,t){const[n,i]=S.useState(()=>{if(typeof window>"u")return t;try{const l=window.localStorage.getItem(e);return l===null?t:JSON.parse(l)}catch{return t}});S.useEffect(()=>{try{n==null?window.localStorage.removeItem(e):window.localStorage.setItem(e,JSON.stringify(n))}catch{}},[e,n]);const o=S.useCallback(l=>{i(u=>typeof l=="function"?l(u):l)},[]);return[n,o]}const EV="console:instance-id";function zh(){const[e,t]=Xo(EV,""),n=e.trim();return S.useMemo(()=>({instanceId:n.length>0?n:void 0,rawInstanceId:e,setInstanceId:t,clearInstanceId:()=>t("")}),[n,e,t])}const Dn={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 Qi(e,t){return e===0?!1:e??t}function _V(e){const t=new URLSearchParams;if(!e)return t;for(const[n,i]of Object.entries(e))i!=null&&t.set(n,String(i));return t}function mj(e,t,n){const i=e.endsWith("/")?e.slice(0,-1):e,l=_V(n)?.toString();return`${i}${t}${l?`?${l}`:""}`}function Uh(e,t){if(!t||!e)throw new Error("Not connected");return e}async function sr(e){const t={Authorization:`Bearer ${e.connectionConfig.token}`};e.body!==void 0&&(t["Content-Type"]="application/json");const n=await fetch(mj(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 wV(e){const t=await fetch(mj(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 Hr(e){const{config:t,isConnected:n}=$o();return wR({queryKey:e.queryKey,queryFn:()=>sr({connectionConfig:Uh(t,n),path:e.path,query:e.query,method:e.method,errorMessage:e.errorMessage}),enabled:(e.enabled??!0)&&n&&!!t,refetchInterval:e.refetchInterval})}function pb(e){const{config:t,isConnected:n}=$o();return wR({queryKey:e.queryKey,queryFn:()=>{if(e.id===void 0)throw new Error(e.requiredMessage);return sr({connectionConfig:Uh(t,n),path:e.path(e.id),query:e.query,errorMessage:e.errorMessage})},enabled:(e.enabled??!0)&&e.id!==void 0&&n&&!!t})}function TV(e,t){for(const n of t)e.invalidateQueries({queryKey:n})}function ir(e){const{instanceId:t}=zh();return e??t}function Fr(e){const{config:t,isConnected:n}=$o(),{instanceId:i}=zh(),o=Rv();return G5({mutationFn:l=>e.mutationFn({connectionConfig:Uh(t,n),variables:l,selectedInstanceId:i}),onSuccess:()=>{e.invalidateQueryKeys&&TV(o,e.invalidateQueryKeys)}})}function xu(e={}){const t=ir(e.instanceId);return Hr({queryKey:Dn.stats({partitionId:e.partitionId,instanceId:t}),path:"/console/stats",query:{partitionId:e.partitionId,instanceId:t},errorMessage:"Failed to fetch stats",refetchInterval:Qi(e.refetchIntervalMs,5e3)})}function CV(e={},t={}){const n=ir(e.instanceId);return Hr({queryKey:Dn.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:Qi(t.refetchIntervalMs,3e4)})}function RV(e={},t={}){const n=ir(e.instanceId);return Hr({queryKey:Dn.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:Qi(t.refetchIntervalMs,3e4)})}function NV(e={},t={}){const n=ir(e.instanceId);return Hr({queryKey:Dn.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:Qi(t.refetchIntervalMs,1e4)})}function jV(e,t={}){const n=ir(t.instanceId);return pb({queryKey:Dn.commitDetail(e,t.partitionId,n),id:e,requiredMessage:"Commit sequence is required",path:i=>`/console/commits/${encodeURIComponent(String(i))}`,query:{partitionId:t.partitionId,instanceId:n},errorMessage:"Failed to fetch commit detail",enabled:t.enabled})}function MV(e={},t={}){const n=ir(e.instanceId);return Hr({queryKey:Dn.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:Qi(t.refetchIntervalMs,1e4)})}function gj(e={},t={}){const n=ir(e.instanceId);return Hr({queryKey:Dn.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:Qi(t.refetchIntervalMs,1e4)})}function AV(e,t={}){const n=ir(t.instanceId);return pb({queryKey:Dn.eventDetail(e,t.partitionId,n),id:e,requiredMessage:"Event id is required",path:i=>`/console/events/${encodeURIComponent(String(i))}`,query:{partitionId:t.partitionId,instanceId:n},errorMessage:"Failed to fetch event detail",enabled:t.enabled})}function OV(e,t={}){const n=ir(t.instanceId);return pb({queryKey:Dn.eventPayload(e,t.partitionId,n),id:e,requiredMessage:"Event id is required",path:i=>`/console/events/${encodeURIComponent(String(i))}/payload`,query:{partitionId:t.partitionId,instanceId:n},errorMessage:"Failed to fetch event payload",enabled:t.enabled})}function kV(e={}){const t=ir(e.instanceId);return Hr({queryKey:Dn.handlers(t),path:"/console/handlers",query:{instanceId:t},errorMessage:"Failed to fetch handlers"})}function IV(e={}){const t=ir(e.instanceId);return Hr({queryKey:Dn.prunePreview(t),path:"/console/prune/preview",query:{instanceId:t},method:"POST",errorMessage:"Failed to fetch prune preview",enabled:e.enabled})}function DV(e={},t={}){const n=ir(e.instanceId);return Hr({queryKey:Dn.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:Qi(t.refetchIntervalMs,1e4)})}function LV(){return Fr({mutationFn:async({connectionConfig:e,selectedInstanceId:t})=>sr({connectionConfig:e,path:"/console/events",query:{instanceId:t},method:"DELETE",errorMessage:"Failed to clear events"}),invalidateQueryKeys:[["console","events"]]})}function PV(){return Fr({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>{const i=t.instanceId??n;return sr({connectionConfig:e,path:`/console/clients/${encodeURIComponent(t.clientId)}`,query:{partitionId:t.partitionId,instanceId:i},method:"DELETE",errorMessage:"Failed to evict client"})},invalidateQueryKeys:[["console","clients"],["console","stats"],["console","operations"]]})}function zV(){return Fr({mutationFn:async({connectionConfig:e,selectedInstanceId:t})=>sr({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 UV(){return Fr({mutationFn:async({connectionConfig:e,selectedInstanceId:t})=>sr({connectionConfig:e,path:"/console/compact",query:{instanceId:t},method:"POST",errorMessage:"Failed to compact"}),invalidateQueryKeys:[["console","stats"],["console","operations"]]})}function BV(){return Fr({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>{const i=t.instanceId??n;return sr({connectionConfig:e,path:"/console/notify-data-change",query:{instanceId:i},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 HV(e={}){const t=ir(e.instanceId);return Hr({queryKey:Dn.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 FV(){return Fr({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>sr({connectionConfig:e,path:"/console/api-keys",query:{instanceId:n},method:"POST",body:t,errorMessage:"Failed to create API key"}),invalidateQueryKeys:[["console","api-keys"]]})}function qV(){return Fr({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>sr({connectionConfig:e,path:`/console/api-keys/${encodeURIComponent(t)}`,query:{instanceId:n},method:"DELETE",errorMessage:"Failed to revoke API key"}),invalidateQueryKeys:[["console","api-keys"]]})}function VV(){return Fr({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>sr({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 $V(){return Fr({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>sr({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 GV(){return Fr({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>sr({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 KV(e={}){return Hr({queryKey:Dn.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:Qi(e.refetchIntervalMs,3e4)})}function YV(){return Fr({mutationFn:async({connectionConfig:e,variables:t})=>sr({connectionConfig:e,path:`/console/storage/${encodeURIComponent(t)}`,method:"DELETE",errorMessage:"Failed to delete blob"}),invalidateQueryKeys:[["console","storage"]]})}function XV(){const{config:e,isConnected:t}=$o();return async n=>{const i=await wV({connectionConfig:Uh(e,t),path:`/console/storage/${encodeURIComponent(n)}/download`,errorMessage:"Failed to download blob"}),o=URL.createObjectURL(i),l=document.createElement("a");l.href=o,l.download=n.split("/").pop()||n,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(o)}}const QV="console:partition-id";function Su(){const[e,t]=Xo(QV,""),n=e.trim();return S.useMemo(()=>({partitionId:n.length>0?n:void 0,rawPartitionId:e,setPartitionId:t,clearPartitionId:()=>t("")}),[n,e,t])}const _T={refreshInterval:5,timeFormat:"relative",showSparklines:!0,pageSize:20};function Eu(){const[e,t]=Xo("console:preferences",_T);return{preferences:e,setPreferences:t,updatePreference:(o,l)=>{t(u=>({...u,[o]:l}))},resetPreferences:()=>{t(_T)}}}const WV=[{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"}],ZV=[{value:10,label:"10"},{value:20,label:"20"},{value:50,label:"50"},{value:100,label:"100"}],mb="syncular-console-root";function JV(e){e.classList.add(mb)}const e$=[{suffix:"",label:"Command"},{suffix:"/stream",label:"Stream"},{suffix:"/fleet",label:"Fleet"},{suffix:"/ops",label:"Ops"},{suffix:"/storage",label:"Storage"},{suffix:"/config",label:"Config"}];function t$(e){const t=e?.trim()??"";return!t||t==="/"?"":(t.startsWith("/")?t:`/${t}`).replace(/\/+$/g,"")}function Kg(e,t){return e?t?`${e}${t}`:e:t||"/"}function n$({basePath:e,appHref:t,modeBadge:n}){const{connect:i,config:o,isConnected:l,isConnecting:u}=$o(),{preferences:f}=Eu(),{instanceId:h,rawInstanceId:p,setInstanceId:y,clearInstanceId:v}=zh(),{partitionId:b,rawPartitionId:x,setPartitionId:E,clearPartitionId:_}=Su(),T=er({select:D=>D.location.pathname}),{data:C}=xu({refetchIntervalMs:f.refreshInterval*1e3,partitionId:b,instanceId:h}),M=t$(e),R=S.useMemo(()=>e$.map(D=>({...D,id:Kg(M,D.suffix)})),[M]),N=Kg(M,""),k=Kg(M,"/config"),z=u?"connecting":l?"connected":o?"disconnected":"not-configured",j=R.find(D=>D.suffix===""?T===N||T===`${N}/`:T.startsWith(D.id))?.id??N,A=C?[{label:"HEAD",value:`#${C.maxCommitSeq}`},{label:"COMMITS",value:`${C.commitCount}`},{label:"CHANGES",value:`${C.changeCount}`},{label:"CLIENTS",value:`${C.activeClientCount}/${C.clientCount}`}]:[];return d.jsxs("div",{className:`${mb} h-screen bg-background text-foreground flex flex-col`,children:[d.jsx(L8,{brand:d.jsx($a,{to:N,children:d.jsx(D8,{label:"console"})}),center:d.jsx(N8,{items:R,activeId:j,renderItem:(D,{active:G})=>d.jsx($a,{to:D.id,children:d.jsx(oj,{active:G,children:D.label})},D.id)}),right:d.jsxs("div",{className:"flex items-center gap-2",children:[n?d.jsx(en,{variant:"flow",className:"hidden md:inline-flex px-2 py-1 text-[10px]",children:n}):null,d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx("span",{className:"font-mono text-[9px] text-neutral-500 uppercase tracking-wide",children:"Instance"}),d.jsx(An,{variant:"mono",value:p,onChange:D=>y(D.target.value),onBlur:D=>y(D.target.value.trim()),placeholder:"all",className:"h-7 w-[110px] px-2 py-1"}),h?d.jsx(Ae,{variant:"ghost",size:"sm",className:"h-7 px-2 text-[10px]",onClick:v,children:"All"}):null]}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx("span",{className:"font-mono text-[9px] text-neutral-500 uppercase tracking-wide",children:"Partition"}),d.jsx(An,{variant:"mono",value:x,onChange:D=>E(D.target.value),onBlur:D=>E(D.target.value.trim()),placeholder:"all",className:"h-7 w-[110px] px-2 py-1"}),b?d.jsx(Ae,{variant:"ghost",size:"sm",className:"h-7 px-2 text-[10px]",onClick:_,children:"All"}):null]}),d.jsx(AB,{state:z}),d.jsx($a,{to:k,children:d.jsx(Ae,{variant:T===k?"secondary":"ghost",size:"icon",children:d.jsx(YB,{className:"h-3 w-3"})})}),t?d.jsxs("a",{href:t,className:R8,children:[d.jsx(GB,{className:"h-3 w-3"}),"Go to app"]}):null]})}),d.jsx("main",{className:"flex-1 overflow-auto pb-[32px]",children:d.jsx("div",{className:"min-h-full",children:l||T===k?d.jsx("div",{style:{animation:"pageIn 0.3s ease-out"},children:d.jsx(XR,{})},T):d.jsx(r$,{configPath:k,hasSavedConfig:!!o,isConnecting:u,onConnect:()=>{i()}})})}),l&&d.jsx(H1,{isLive:l,metrics:A,uptime:"--"})]})}function r$({configPath:e,hasSavedConfig:t,isConnecting:n,onConnect:i}){return d.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[d.jsx("p",{className:"mb-4 text-foreground-muted",children:"Not connected to a @syncular server"}),d.jsxs("div",{className:"flex items-center gap-2",children:[t&&d.jsx(Ae,{variant:"default",onClick:i,disabled:n,children:n?"Connecting...":"Connect"}),d.jsx($a,{to:e,children:d.jsx(Ae,{variant:"link",children:"Configure connection"})})]})]})}const Vs=O3({component:n$});function s$(e={}){const{maxEvents:t=100,enabled:n=!0,staleAfterMs:i=65e3,replayLimit:o=100,partitionId:l,instanceId:u}=e,{config:f,isConnected:h}=$o(),{instanceId:p}=zh(),y=u??p,[v,b]=S.useState([]),[x,E]=S.useState(!1),[_,T]=S.useState("disconnected"),[C,M]=S.useState(null),R=S.useRef(null),N=S.useRef(null),k=S.useRef(null),z=S.useRef(0),j=S.useRef(0),A=S.useRef(null),D=S.useCallback(()=>{b([]),A.current=null},[]);return S.useEffect(()=>{if(!n||!h||!f?.serverUrl||!f?.token)return;let G=!1;const F=Number.isFinite(o)?Math.max(1,Math.min(500,Math.floor(o))):100;if(typeof WebSocket>"u")return;const P=()=>{N.current&&(clearTimeout(N.current),N.current=null)},Q=()=>{k.current&&(clearInterval(k.current),k.current=null)},X=()=>{if(G||N.current)return;z.current+=1;const $=Math.min(3e4,1e3*2**Math.max(0,z.current-1)),H=Math.floor($*.2*Math.random()),V=$+H;N.current=setTimeout(()=>{N.current=null,G||L()},V)},te=()=>{j.current=Date.now(),E(!0),T("connected")},L=()=>{if(G)return;T("connecting"),P();const $=(()=>{const V=new URL(f.serverUrl,window.location.origin);V.protocol=V.protocol==="https:"?"wss:":"ws:";const U=V.pathname.endsWith("/")?V.pathname.slice(0,-1):V.pathname;return V.pathname=`${U}/console/events/live`,V.search="",A.current&&V.searchParams.set("since",A.current),V.searchParams.set("replayLimit",String(F)),l&&V.searchParams.set("partitionId",l),y&&V.searchParams.set("instanceId",y),V.toString()})(),H=new WebSocket($);R.current=H,H.onopen=()=>{if(G){H.close();return}z.current=0,M(null),T("connecting"),E(!1);try{H.send(JSON.stringify({type:"auth",token:f.token}))}catch{H.close();return}Q(),k.current=setInterval(()=>{const V=R.current;if(!V||V.readyState!==WebSocket.OPEN)return;const U=j.current;!U||Date.now()-U<=i||(E(!1),T("stale"),V.close())},1e3)},H.onclose=()=>{G||(E(!1),T("disconnected"),Q(),X())},H.onerror=()=>{G||M(new Error("WebSocket connection failed"))},H.onmessage=V=>{try{const U=JSON.parse(V.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";M(new Error(se));return}const K={type:I,timestamp:U.timestamp||new Date().toISOString(),data:U};if(l&&K.data.partitionId!==l||y&&K.data.instanceId!==y)return;const Z=Date.parse(A.current??""),W=Date.parse(K.timestamp);Number.isFinite(W)&&(!Number.isFinite(Z)||W>Z)&&(A.current=K.timestamp),b(se=>[K,...se].slice(0,t))}catch{}}};return L(),()=>{G=!0,P(),Q(),R.current&&(R.current.close(),R.current=null),E(!1),T("disconnected")}},[n,h,f?.serverUrl,f?.token,t,l,y,o,i]),{events:v,isConnected:x,connectionState:_,error:C,clearEvents:D}}const i$=S.createContext(null);function yj(){const[e,t]=Xo("console:time-range","24h");return{range:e,setRange:t}}const o$=[{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 a$(e){const t=e.toLowerCase();for(const n of o$)if(t.includes(n.hint))return n.type;return"client"}function l$(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 c$(e,t){return typeof e.lagCommitCount=="number"?Math.max(0,e.lagCommitCount):t?Math.max(0,t.maxCommitSeq-e.cursor):0}function u$(e,t){return e.activityState==="stale"?"offline":t>0?"syncing":"online"}function f$(e,t){return e.length<=16?e:`${e.slice(0,12)}-${t+1}`}function d$(e,t,n={}){const i=n.maxNodes??10;return e.slice(0,i).map((o,l)=>{const u=c$(o,t),f=u$(o,u);return{id:f$(o.clientId,l),type:a$(o.clientId),status:f,cursor:Math.max(0,o.cursor),actor:o.actorId,mode:o.connectionMode,dialect:l$(o.clientId),scopes:Object.keys(o.effectiveScopes||{}),lastSeen:o.updatedAt}})}const h$={enabled:!1,thresholds:{p90Latency:500,errorRate:5,clientLag:100}};function wT(e,t="relative"){if(t==="absolute")return new Date(e).toLocaleString();const n=new Date(e),o=new Date().getTime()-n.getTime(),l=Math.floor(o/1e3);return l<60?`${l}s ago`:l<3600?`${Math.floor(l/60)}m ago`:l<86400?`${Math.floor(l/3600)}h ago`:`${Math.floor(l/86400)}d ago`}function p$(e){const t=e.length>1&&e.endsWith("/")?e.slice(0,-1):e;return t==="/console"||t.startsWith("/console/")?"/console/stream":"/stream"}function m$(){const e=Sh(),t=S.useMemo(()=>typeof window>"u"?"/stream":p$(window.location.pathname),[]),n=yj(),{range:i}=n,{preferences:o}=Eu(),{partitionId:l}=Su(),u=o.refreshInterval*1e3,[f]=Xo("console:alert-config",h$),[h,p]=S.useState("1h"),{data:y}=xu({refetchIntervalMs:u,partitionId:l}),{data:v}=CV({range:i,partitionId:l},{refetchIntervalMs:u}),{data:b}=RV({range:i,partitionId:l},{refetchIntervalMs:u}),{data:x}=NV({limit:5,partitionId:l},{refetchIntervalMs:u}),{data:E}=gj({limit:12,offset:0,partitionId:l},{refetchIntervalMs:u}),{events:_,isConnected:T}=s$({maxEvents:8,partitionId:l}),C=S.useMemo(()=>{const P=v?.buckets??[];let Q=0,X=0;for(const L of P)Q+=L.pushCount+L.pullCount,X+=L.errorCount;const te=Q>0?X/Q*100:0;return{totalEvents:Q,errorRate:te}},[v?.buckets]),M=S.useMemo(()=>E?.items?d$(E.items,y,{maxNodes:12}):[],[E?.items,y]),R=M.filter(P=>P.status!=="offline").length,N=M.filter(P=>P.status==="offline").length,k=S.useMemo(()=>y?[{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:y.activeClientCount,color:"syncing"},{label:"Pending",value:y.maxActiveClientCursor!==null&&y.maxCommitSeq>0?y.maxCommitSeq-(y.minActiveClientCursor??0):0,color:"relay"}]:[],[y,b,C.errorRate,C.totalEvents]),z=S.useMemo(()=>_.map(P=>({type:P.type.toUpperCase(),actor:P.data?.actorId??"",table:(P.data?.tables??[])[0]??"",time:wT(P.timestamp,o.timeFormat)})),[_,o.timeFormat]),j=S.useMemo(()=>{const P=v?.buckets;if(!P?.length)return[];const Q=Math.max(...P.map(X=>Math.max(X.pushCount,X.pullCount)),1);return P.map(X=>({pushPercent:Q>0?X.pushCount/Q*100:0,pullPercent:Q>0?X.pullCount/Q*100:0}))},[v?.buckets]),A=S.useMemo(()=>{if(!b)return[];const P=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/P*100,pullBarPercent:b.pull.p50/P*100},{label:"P90",pushMs:b.push.p90,pullMs:b.pull.p90,pushBarPercent:b.push.p90/P*100,pullBarPercent:b.pull.p90/P*100},{label:"P99",pushMs:b.push.p99,pullMs:b.pull.p99,pushBarPercent:b.push.p99/P*100,pullBarPercent:b.pull.p99/P*100}]},[b]),D=S.useMemo(()=>x?.items?x.items.map(P=>({seq:P.commitSeq,actor:P.actorId,changes:P.changeCount,tables:(P.affectedTables??[]).join(", "),time:wT(P.createdAt,o.timeFormat)})):[],[x?.items,o.timeFormat]),G=S.useMemo(()=>Math.max(0,100-C.errorRate),[C.errorRate]),F=S.useMemo(()=>{if(!f.enabled||!y)return[];const P=[];return b?.push?.p90&&b.push.p90>f.thresholds.p90Latency&&P.push(`P90 push latency (${b.push.p90}ms) exceeds threshold (${f.thresholds.p90Latency}ms)`),y.minActiveClientCursor!==null&&y.maxCommitSeq-y.minActiveClientCursor>f.thresholds.clientLag&&P.push(`Client lag (${y.maxCommitSeq-y.minActiveClientCursor}) exceeds threshold (${f.thresholds.clientLag})`),C.errorRate>f.thresholds.errorRate&&P.push(`Error rate (${C.errorRate.toFixed(1)}%) exceeds threshold (${f.thresholds.errorRate}%)`),P},[f,y,b,C.errorRate]);return y?d.jsx(i$.Provider,{value:n,children:d.jsxs("div",{className:"flex flex-col",children:[F.length>0&&d.jsx("div",{className:"px-6 pb-4",children:d.jsxs(bn,{variant:"destructive",children:[d.jsx(bu,{children:"Threshold Exceeded"}),d.jsx(xn,{children:F.map((P,Q)=>d.jsx("span",{className:"block",children:P},Q))})]})}),d.jsx(UN,{clients:M,totalNodes:M.length+2,onlineCount:R,offlineCount:N,relayClientIds:[]}),d.jsx(X1,{items:k}),d.jsxs("div",{className:"flex",children:[d.jsxs("div",{className:"flex-1 min-w-0 flex flex-col",children:[d.jsx("div",{className:"border-b border-border border-r border-border",children:d.jsx(S1,{bars:j,activeRange:h,onRangeChange:p})}),d.jsx("div",{className:"border-b border-border border-r border-border",children:d.jsx(Q1,{buckets:A,successRate:G})}),d.jsx("div",{className:"border-r border-border",children:d.jsx(F1,{commits:D,onViewAll:()=>e({href:t})})})]}),d.jsx(W1,{entries:z,isConnected:T,maxVisible:20,maxHeight:"calc(100vh - 200px)"})]})]})}):d.jsx("div",{className:"flex items-center justify-center py-24",children:d.jsx(Mt,{size:"lg"})})}function g$(){return d.jsx(m$,{})}const Dr=rj;function y$({children:e}){return d.jsxs("div",{className:"space-y-4 px-5 py-5",children:[d.jsx(v$,{}),d.jsx(_$,{}),d.jsx(w$,{}),e]})}function v$(){const{clearError:e,config:t,connect:n,disconnect:i,error:o,isConnected:l,isConnecting:u}=$o(),[f,h]=S.useState(t?.serverUrl??"/api"),[p,y]=S.useState(t?.token??""),[v,b]=S.useState(null),[x,E]=S.useState(!1),[_,T]=S.useState(null),[C,M]=Xo("console:disconnect-clear-saved-config",!1);S.useEffect(()=>{const j=new URLSearchParams(window.location.search),A=j.get("server");let D=!1;if(A&&(h(A),j.delete("server"),D=!0),j.has("token")&&(j.delete("token"),D=!0),D){const G=j.toString(),F=G?`${window.location.pathname}?${G}`:window.location.pathname;window.history.replaceState({},"",F)}},[]),S.useEffect(()=>{t?.serverUrl&&h(t.serverUrl),t?.token&&y(t.token)},[t?.serverUrl,t?.token]),S.useEffect(()=>{T(null)},[]);const R=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.")},N=()=>{i({clearSavedConfig:C}),C&&(h("/api"),y("")),T(C?"Disconnected and saved credentials cleared.":"Disconnected."),b(null)},k=async()=>{E(!0),b(null),T(null);const j=performance.now();try{const A=f.trim(),D=p.trim();if(!A||!D)throw new Error("Missing server URL or token");if(!(await fetch(`${A}/console/stats`,{headers:{Authorization:`Bearer ${D}`}})).ok)throw new Error("Failed to connect");b(Math.round(performance.now()-j))}catch{b(-1)}finally{E(!1)}},z=o??_??(v!==null?v<0?"Connection failed":`Connection successful (${v}ms latency)`:void 0);return d.jsx(V1,{isConnected:l,isConnecting:u,isTestingConnection:x,serverUrl:f,onServerUrlChange:h,consoleToken:p,onConsoleTokenChange:y,onSaveAndConnect:R,onDisconnect:N,onTestConnection:k,statusMessage:z,children:d.jsx("div",{className:"px-5 pb-5 -mt-2",children:d.jsxs("div",{className:"flex items-center justify-between rounded-md border border-border px-3 py-2",children:[d.jsxs("div",{children:[d.jsx("p",{className:"font-mono text-[10px] text-neutral-400",children:"Clear saved credentials on disconnect"}),d.jsx("p",{className:"font-mono text-[9px] text-neutral-500",children:"Removes stored server URL and token from this browser."})]}),d.jsx(Mh,{checked:C,onCheckedChange:M})]})})})}const b$=1440*60*1e3;function TT(e){const t=e.trim();if(!t)return null;const n=Number.parseInt(t,10);return!Number.isInteger(n)||n<=0?null:n}function Yg(e){if(!e)return"Never";const t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():"Invalid date"}function x$(e){return e.length===0?"all scopes":e.length<=2?e.join(", "):`${e.slice(0,2).join(", ")} +${e.length-2}`}function S$(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 i=Date.now();return n<=i?"expired":n<=i+t*b$?"expiring":"active"}function E$(e){return e==="revoked"?"destructive":e==="expired"?"offline":e==="expiring"?"syncing":"healthy"}function _$(){const[e,t]=S.useState("all"),[n,i]=S.useState("all"),[o,l]=S.useState("14"),[u,f]=S.useState(!1),[h,p]=S.useState(!1),[y,v]=S.useState(""),[b,x]=S.useState("relay"),[E,_]=S.useState(""),[T,C]=S.useState(""),[M,R]=S.useState(""),[N,k]=S.useState(null),[z,j]=S.useState([]),[A,D]=S.useState(null),[G,F]=S.useState(null),[P,Q]=S.useState(null),[X,te]=S.useState(null),[L,$]=S.useState(null),[H,V]=S.useState(null),[U,I]=S.useState(null),K=S.useMemo(()=>TT(o),[o]),Z=K??14,W=S.useMemo(()=>TT(M),[M]),se=M.trim().length>0,ie=!se||W!==null,he=S.useMemo(()=>({type:e==="all"?void 0:e,status:n==="all"?void 0:n,expiresWithinDays:n==="expiring"?Z:void 0}),[e,n,Z]),{data:xe,isLoading:de,error:Be}=HV(he),_e=FV(),re=VV(),fe=qV(),ae=$V(),Se=GV();S.useEffect(()=>{const pe=new Set((xe?.items??[]).map(we=>we.keyId));j(we=>we.filter(He=>pe.has(He)))},[xe?.items]);const ye=async()=>{try{const pe=T.split(",").map(He=>He.trim()).filter(He=>He.length>0),we=await _e.mutateAsync({name:y,keyType:b,actorId:E||void 0,scopeKeys:pe.length>0?pe:void 0,expiresInDays:se?W??void 0:void 0});k(we.secretKey),v(""),_(""),C(""),R("")}catch{}},be=pe=>{navigator.clipboard.writeText(pe),F(pe),setTimeout(()=>F(null),2e3)},ge=async()=>{if(P)try{await fe.mutateAsync(P)}finally{Q(null)}},Le=async()=>{if(z.length!==0)try{const pe=await re.mutateAsync({keyIds:z});D(pe),j([])}catch{}},Oe=async()=>{if(X)try{const pe=await Se.mutateAsync(X.keyId);$({oldKeyId:X.keyId,oldKeyName:X.name,secretKey:pe.secretKey})}catch{}},Ee=async()=>{if(L)try{await fe.mutateAsync(L.oldKeyId)}finally{$(null),te(null)}},Fe=async()=>{if(H)try{const pe=await ae.mutateAsync(H);I(pe.secretKey)}finally{V(null)}};if(de)return d.jsx("div",{className:"flex h-[200px] items-center justify-center",children:d.jsx(Mt,{size:"lg"})});if(Be)return d.jsx("div",{className:"flex h-[200px] items-center justify-center",children:d.jsxs("p",{className:"text-danger",children:["Failed to load API keys: ",Be.message]})});const Ke=(xe?.items??[]).filter(pe=>pe.revokedAt===null).map(pe=>pe.keyId),ze=Ke.length>0&&Ke.every(pe=>z.includes(pe)),Xe=z.length>0,Ue=(xe?.items??[]).filter(pe=>z.includes(pe.keyId)).map(pe=>pe.name);return d.jsxs(d.Fragment,{children:[d.jsxs(Qv,{title:"API Keys",description:"Issue, rotate, revoke, and audit key lifecycle state.",actions:d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsxs(Ae,{size:"sm",variant:"destructive",onClick:()=>p(!0),disabled:z.length===0,children:["Revoke Selected (",z.length,")"]}),d.jsx(Ae,{size:"sm",onClick:()=>f(!0),children:"Create Key"})]}),children:[d.jsxs("div",{className:"mb-4 grid gap-3 lg:grid-cols-3",children:[d.jsxs(Wr,{children:[d.jsx(Lr,{children:"Type filter"}),d.jsxs(Cd,{value:[e],multiple:!1,onValueChange:pe=>{const we=pe.find(He=>typeof He=="string");(we==="all"||we==="relay"||we==="proxy"||we==="admin")&&t(we)},children:[d.jsx(Dr,{value:"all",children:"all"}),d.jsx(Dr,{value:"relay",children:"relay"}),d.jsx(Dr,{value:"proxy",children:"proxy"}),d.jsx(Dr,{value:"admin",children:"admin"})]})]}),d.jsxs(Wr,{children:[d.jsx(Lr,{children:"Status filter"}),d.jsxs(Cd,{value:[n],multiple:!1,onValueChange:pe=>{const we=pe.find(He=>typeof He=="string");(we==="all"||we==="active"||we==="revoked"||we==="expiring")&&i(we)},children:[d.jsx(Dr,{value:"all",children:"all"}),d.jsx(Dr,{value:"active",children:"active"}),d.jsx(Dr,{value:"revoked",children:"revoked"}),d.jsx(Dr,{value:"expiring",children:"expiring"})]})]}),d.jsxs(Wr,{children:[d.jsx(Lr,{htmlFor:"api-key-expiring-window",children:"Expiring window (days)"}),d.jsx(Ha,{children:"Used when status filter is set to expiring."}),d.jsx(An,{id:"api-key-expiring-window",placeholder:"14",value:o,inputMode:"numeric",onChange:pe=>l(pe.target.value)}),K===null&&o.trim().length>0?d.jsx("p",{className:"font-mono text-[10px] text-offline",children:"Enter a positive whole number."}):null]})]}),xe?.items.length===0?d.jsx(Yv,{message:"No API keys match the current filters."}):d.jsxs(wl,{children:[d.jsx(Tl,{children:d.jsxs(Br,{children:[d.jsx(ut,{className:"w-[28px]",children:d.jsx($y,{checked:ze,indeterminate:!ze&&Xe&&Ke.length>0,onCheckedChange:pe=>{j(pe?Ke:[])},"aria-label":"Select all active keys"})}),d.jsx(ut,{className:"w-[100px]",children:"NAME"}),d.jsx(ut,{className:"w-[55px]",children:"TYPE"}),d.jsx(ut,{className:"w-[90px]",children:"KEY PREFIX"}),d.jsx(ut,{className:"w-[80px]",children:"ACTOR"}),d.jsx(ut,{className:"w-[100px]",children:"SCOPES"}),d.jsx(ut,{className:"w-[120px]",children:"CREATED"}),d.jsx(ut,{className:"w-[120px]",children:"LAST USED"}),d.jsx(ut,{className:"w-[120px]",children:"EXPIRES"}),d.jsx(ut,{className:"flex-1",children:"STATUS"})]})}),d.jsx(Cl,{children:(xe?.items??[]).map(pe=>{const we=S$(pe,Z);return d.jsxs(Br,{className:"group relative",children:[d.jsx(ft,{className:"w-[28px]",children:d.jsx($y,{checked:z.includes(pe.keyId),onCheckedChange:He=>{j(dt=>He?[...new Set([...dt,pe.keyId])]:dt.filter(ot=>ot!==pe.keyId))},"aria-label":`Select ${pe.name}`,disabled:pe.revokedAt!==null})}),d.jsx(ft,{className:"w-[100px] font-medium",children:pe.name}),d.jsx(ft,{className:"w-[55px]",children:d.jsx(en,{variant:pe.keyType==="admin"?"flow":pe.keyType==="proxy"?"ghost":"relay",children:pe.keyType})}),d.jsx(ft,{className:"w-[90px]",children:d.jsxs("code",{className:"font-mono text-[11px]",children:[pe.keyPrefix,"..."]})}),d.jsx(ft,{className:"w-[80px] text-neutral-500",children:pe.actorId??"-"}),d.jsx(ft,{className:"w-[100px] text-neutral-500",children:d.jsx("code",{className:"font-mono text-[10px]",children:x$(pe.scopeKeys)})}),d.jsx(ft,{className:"w-[120px] text-neutral-500",children:Yg(pe.createdAt)}),d.jsx(ft,{className:"w-[120px] text-neutral-500",children:Yg(pe.lastUsedAt)}),d.jsx(ft,{className:"w-[120px] text-neutral-500",children:Yg(pe.expiresAt)}),d.jsx(ft,{className:"flex-1",children:d.jsx(en,{variant:E$(we),children:we})}),pe.revokedAt===null&&d.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:[d.jsx("button",{type:"button",onClick:()=>te(pe),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"}),d.jsx("button",{type:"button",onClick:()=>V(pe.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"}),d.jsx("button",{type:"button",onClick:()=>Q(pe.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"})]})]},pe.keyId)})})]})]}),d.jsx(Er,{open:u,onOpenChange:f,children:d.jsxs(Xn,{children:[d.jsx(Qn,{children:d.jsx(Wn,{children:"Create API Key"})}),N?d.jsx(CT,{copiedKeyId:G,onClose:()=>{k(null),f(!1)},onCopy:be,secretKey:N,warning:"Copy this key now. You will not be able to view it again."}):d.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[d.jsxs(Wr,{children:[d.jsx(Lr,{htmlFor:"api-key-name",children:"Name"}),d.jsx(An,{id:"api-key-name",placeholder:"Backend Relay Key",value:y,onChange:pe=>v(pe.target.value)})]}),d.jsxs(Wr,{children:[d.jsx(Lr,{children:"Key type"}),d.jsxs(Cd,{value:[b],multiple:!1,onValueChange:pe=>{const we=pe.find(He=>typeof He=="string");(we==="relay"||we==="proxy"||we==="admin")&&x(we)},children:[d.jsx(Dr,{value:"relay",children:"relay"}),d.jsx(Dr,{value:"proxy",children:"proxy"}),d.jsx(Dr,{value:"admin",children:"admin"})]})]}),d.jsxs(Wr,{children:[d.jsx(Lr,{htmlFor:"api-key-actor-id",children:"Actor ID (optional)"}),d.jsx(Ha,{children:"Pin this key to a fixed actor ID"}),d.jsx(An,{id:"api-key-actor-id",placeholder:"actor-123",value:E,onChange:pe=>_(pe.target.value)})]}),d.jsxs(Wr,{children:[d.jsx(Lr,{htmlFor:"api-key-scope-keys",children:"Scope keys (optional)"}),d.jsx(Ha,{children:"Comma-separated list of allowed scope keys"}),d.jsx(An,{id:"api-key-scope-keys",placeholder:"scope-a, scope-b",value:T,onChange:pe=>C(pe.target.value)})]}),d.jsxs(Wr,{children:[d.jsx(Lr,{htmlFor:"api-key-expires-days",children:"Expires in days (optional)"}),d.jsx(Ha,{children:"Leave empty to keep the key non-expiring."}),d.jsx(An,{id:"api-key-expires-days",placeholder:"30",value:M,inputMode:"numeric",onChange:pe=>R(pe.target.value)}),ie?null:d.jsx("p",{className:"font-mono text-[10px] text-offline",children:"Enter a positive whole number."})]}),d.jsxs(pn,{children:[d.jsx(Ae,{variant:"default",onClick:()=>f(!1),children:"Cancel"}),d.jsx(Ae,{variant:"primary",onClick:ye,disabled:_e.isPending||!y||!ie,children:_e.isPending?d.jsxs(d.Fragment,{children:[d.jsx(Mt,{size:"sm"}),"Creating..."]}):"Create"})]})]})]})}),d.jsx(Er,{open:h,onOpenChange:pe=>{p(pe),pe||D(null)},children:d.jsxs(Xn,{children:[d.jsx(Qn,{children:d.jsx(Wn,{children:"Bulk Revoke API Keys"})}),A?d.jsxs("div",{className:"px-5 py-4 flex flex-col gap-3",children:[d.jsx(bn,{variant:"destructive",children:d.jsxs(xn,{children:["Requested ",A.requestedCount," keys. Revoked"," ",A.revokedCount,", already revoked"," ",A.alreadyRevokedCount,", not found"," ",A.notFoundCount,"."]})}),d.jsx(pn,{children:d.jsx(Ae,{variant:"primary",onClick:()=>{p(!1),D(null)},children:"Done"})})]}):d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"px-5 py-4 flex flex-col gap-3",children:[d.jsx(bn,{variant:"destructive",children:d.jsx(xn,{children:"This revokes selected keys immediately and cannot be undone."})}),d.jsxs("p",{className:"font-mono text-[10px] text-neutral-500",children:["Selected keys: ",Ue.slice(0,5).join(", "),Ue.length>5?` +${Ue.length-5} more`:""]})]}),d.jsxs(pn,{children:[d.jsx(Ae,{variant:"default",onClick:()=>p(!1),children:"Cancel"}),d.jsx(Ae,{variant:"destructive",onClick:Le,disabled:re.isPending||z.length===0,children:re.isPending?d.jsxs(d.Fragment,{children:[d.jsx(Mt,{size:"sm"}),"Revoking..."]}):"Revoke Selected"})]})]})]})}),d.jsx(Er,{open:X!==null||L!==null,onOpenChange:()=>{te(null),$(null)},children:d.jsxs(Xn,{children:[d.jsx(Qn,{children:d.jsx(Wn,{children:"Stage Rotate API Key"})}),L?d.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[d.jsx(bn,{variant:"default",children:d.jsxs(xn,{children:["Replacement key created for ",L.oldKeyName,". The old key is still active until you revoke it."]})}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("code",{className:"flex-1 rounded-md border border-border bg-surface p-3 font-mono text-[11px] text-white break-all",children:L.secretKey}),d.jsx(Ae,{variant:"default",size:"sm",onClick:()=>be(L.secretKey),children:G===L.secretKey?"Copied":"Copy"})]}),d.jsxs(pn,{children:[d.jsx(Ae,{variant:"default",onClick:()=>{$(null),te(null)},children:"Keep Old Key Active"}),d.jsx(Ae,{variant:"destructive",onClick:Ee,disabled:fe.isPending,children:fe.isPending?d.jsxs(d.Fragment,{children:[d.jsx(Mt,{size:"sm"}),"Revoking Old Key..."]}):"Finalize and Revoke Old Key"})]})]}):d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"px-5 py-4",children:d.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."})}),d.jsxs(pn,{children:[d.jsx(Ae,{variant:"default",onClick:()=>te(null),children:"Cancel"}),d.jsx(Ae,{variant:"primary",onClick:Oe,disabled:Se.isPending||!X,children:Se.isPending?d.jsxs(d.Fragment,{children:[d.jsx(Mt,{size:"sm"}),"Staging..."]}):"Create Replacement Key"})]})]})]})}),d.jsx(Er,{open:P!==null,onOpenChange:()=>Q(null),children:d.jsxs(Xn,{children:[d.jsx(Qn,{children:d.jsx(Wn,{children:"Revoke API Key"})}),d.jsx("div",{className:"px-5 py-4",children:d.jsx(bn,{variant:"destructive",children:d.jsx(xn,{children:"Revoking a key immediately invalidates it for all requests."})})}),d.jsxs(pn,{children:[d.jsx(Ae,{variant:"default",onClick:()=>Q(null),children:"Cancel"}),d.jsx(Ae,{variant:"destructive",onClick:ge,disabled:fe.isPending,children:fe.isPending?d.jsxs(d.Fragment,{children:[d.jsx(Mt,{size:"sm"}),"Revoking..."]}):"Revoke"})]})]})}),d.jsx(Er,{open:H!==null||U!==null,onOpenChange:()=>{V(null),I(null)},children:d.jsxs(Xn,{children:[d.jsx(Qn,{children:d.jsx(Wn,{children:"Rotate API Key"})}),U?d.jsx(CT,{copiedKeyId:G,onClose:()=>I(null),onCopy:be,secretKey:U,warning:"The previous key has been invalidated. Store this replacement securely."}):d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"px-5 py-4",children:d.jsx("p",{className:"font-mono text-[10px] text-neutral-500",children:"Rotating a key invalidates the previous secret immediately."})}),d.jsxs(pn,{children:[d.jsx(Ae,{variant:"default",onClick:()=>V(null),children:"Cancel"}),d.jsx(Ae,{variant:"primary",onClick:Fe,disabled:ae.isPending,children:ae.isPending?d.jsxs(d.Fragment,{children:[d.jsx(Mt,{size:"sm"}),"Rotating..."]}):"Rotate"})]})]})]})})]})}function w$(){const{preferences:e,updatePreference:t,resetPreferences:n}=Eu(),i=[{type:"filter",label:"Auto-refresh interval",options:WV.map(o=>({id:`${o.value}`,label:o.label})),activeId:`${e.refreshInterval}`,onActiveChange:o=>t("refreshInterval",Number.parseInt(o,10))},{type:"filter",label:"Items per page",options:ZV.map(o=>({id:`${o.value}`,label:o.label})),activeId:`${e.pageSize}`,onActiveChange:o=>t("pageSize",Number.parseInt(o,10))},{type:"filter",label:"Time format",options:[{id:"relative",label:"Relative"},{id:"absolute",label:"Absolute"}],activeId:e.timeFormat,onActiveChange:o=>t("timeFormat",o)},{type:"toggle",label:"Show sparklines",description:"Display mini trend charts in dashboard metric cards",checked:e.showSparklines,onCheckedChange:o=>t("showSparklines",o)}];return d.jsx(Z1,{rows:i,onResetDefaults:n})}function CT({copiedKeyId:e,onClose:t,onCopy:n,secretKey:i,warning:o}){return d.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[d.jsx(bn,{variant:"destructive",children:d.jsx(xn,{children:o})}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("code",{className:"flex-1 rounded-md border border-border bg-surface p-3 font-mono text-[11px] text-white break-all",children:i}),d.jsx(Ae,{variant:"default",size:"sm",onClick:()=>n(i),children:e===i?"Copied":"Copy"})]}),d.jsx(pn,{children:d.jsx(Ae,{variant:"primary",onClick:t,children:"Done"})})]})}function T$(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 C$(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 R$(e,t){if(t==="absolute")return new Date(e).toLocaleString();try{const n=new Date(e),o=new Date().getTime()-n.getTime(),l=Math.floor(o/1e3),u=Math.floor(l/60),f=Math.floor(u/60),h=Math.floor(f/24);return l<60?"just now":u<60?`${u}m ago`:f<24?`${f}h ago`:`${h}d ago`}catch{return e}}function N$(e,t,n){return{id:e.clientId,type:T$(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:C$(e.clientId),scopes:Object.keys(e.effectiveScopes??{}),lastSeen:R$(e.updatedAt,n)}}function j$({emptyState:e}={}){const[t,n]=S.useState(1),[i,o]=S.useState(null),{preferences:l}=Eu(),{partitionId:u}=Su(),f=l.pageSize,h=l.refreshInterval*1e3,{data:p,isLoading:y}=xu({refetchIntervalMs:h,partitionId:u}),{data:v,isLoading:b,error:x}=gj({limit:f,offset:(t-1)*f,partitionId:u},{refetchIntervalMs:h}),E=PV(),_=Math.ceil((v?.total??0)/f),T=p?.maxCommitSeq??0;S.useEffect(()=>{n(1)},[]);const C=async()=>{if(i)try{await E.mutateAsync({clientId:i,partitionId:u})}finally{o(null)}};if(b||y)return d.jsx("div",{className:"flex items-center justify-center h-[200px]",children:d.jsx(Mt,{size:"lg"})});if(x)return d.jsx("div",{className:"flex items-center justify-center h-[200px]",children:d.jsxs("p",{className:"text-danger",children:["Failed to load clients: ",x.message]})});const M=(v?.items??[]).map(R=>N$(R,T,l.timeFormat));return d.jsxs("div",{className:"flex flex-col gap-5 px-5 py-5",children:[M.length>0&&d.jsx(eN,{clients:M,headSeq:T}),M.length===0?e??d.jsx(rH,{children:d.jsx(Yv,{message:"No clients yet"})}):d.jsx(K1,{clients:M,headSeq:T,onEvict:R=>{const N=v?.items.find(k=>k.clientId===R);o(N?.clientId??R)}}),_>1&&d.jsx(db,{page:t,totalPages:_,totalItems:v?.total??0,onPageChange:n}),d.jsx(Er,{open:i!==null,onOpenChange:()=>o(null),children:d.jsxs(Xn,{children:[d.jsx(Qn,{children:d.jsx(Wn,{children:"Evict Client"})}),d.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[d.jsxs("p",{className:"font-mono text-[11px] text-neutral-300",children:["Are you sure you want to evict client"," ",d.jsxs("span",{className:"font-mono text-white",children:[i?.slice(0,12),"..."]}),"?"]}),d.jsx("p",{className:"font-mono text-[10px] text-neutral-500",children:"This will force the client to re-bootstrap on their next sync."})]}),d.jsxs(pn,{children:[d.jsx(Ae,{variant:"default",onClick:()=>o(null),children:"Cancel"}),d.jsx(Ae,{variant:"destructive",onClick:C,disabled:E.isPending,children:E.isPending?d.jsxs(d.Fragment,{children:[d.jsx(Mt,{size:"sm"}),"Evicting..."]}):"Evict"})]})]})})]})}const M$={latencyThresholdMs:1e3,errorRateThreshold:5,clientLagThreshold:50,enabled:!1};function A$(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 O$(e){const t=e.split(",").map(n=>n.trim()).filter(n=>n.length>0);return Array.from(new Set(t))}function k$(e){switch(e){case"notify_data_change":return"Notify";case"evict_client":return"Evict";case"compact":return"Compact";default:return"Prune"}}function RT(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function I$(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function D$(e){const t=RT(e.requestPayload),n=RT(e.resultPayload);if(e.operationType==="notify_data_change"){const l=I$(t?.tables),u=n?.commitSeq;return`${l.length} table${l.length===1?"":"s"} -> commit #${typeof u=="number"?u:"?"}`}if(e.operationType==="evict_client"){const l=n?.evicted===!0?"evicted":"not found";return`client ${e.targetClientId??"?"} ${l}`}if(e.operationType==="compact")return`${typeof n?.deletedChanges=="number"?n.deletedChanges:0} changes removed`;const i=typeof n?.deletedCommits=="number"?n.deletedCommits:0,o=typeof t?.watermarkCommitSeq=="number"?` at #${t.watermarkCommitSeq}`:"";return`${i} commits removed${o}`}function L$(e){const t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function P$(){const{partitionId:e}=Su();return d.jsxs("div",{className:"flex flex-col gap-4 px-5 py-5",children:[d.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[d.jsx(z$,{}),d.jsx(q$,{})]}),d.jsxs("div",{className:"grid gap-4 xl:grid-cols-3",children:[d.jsx(U$,{partitionId:e}),d.jsx(B$,{partitionId:e}),d.jsx(H$,{partitionId:e})]}),d.jsx(F$,{partitionId:e})]})}function z$(){const{data:e,isLoading:t,error:n}=kV();if(t)return d.jsx("div",{className:"flex items-center justify-center h-[200px]",children:d.jsx(Mt,{size:"lg"})});if(n)return d.jsx("div",{className:"flex items-center justify-center h-[200px]",children:d.jsxs("p",{className:"text-danger",children:["Failed to load handlers: ",n.message]})});const i=(e?.items??[]).map(o=>({table:o.table,dependsOn:o.dependsOn?.join(", ")??null,chunkTtl:o.snapshotChunkTtlMs?A$(o.snapshotChunkTtlMs):"default"}));return d.jsx(Y1,{handlers:i,tableCount:e?.items.length??0})}function U$({partitionId:e}){const[t,n]=S.useState(!1),[i,o]=S.useState(null),{data:l,isLoading:u}=xu({partitionId:e}),{data:f,isLoading:h,refetch:p}=IV({enabled:!1}),y=zV(),v=async()=>{n(!0),o(null),await p()},b=async()=>{const E=await y.mutateAsync();o(E.deletedCommits)};if(u)return d.jsx("div",{className:"flex items-center justify-center h-[200px]",children:d.jsx(Mt,{size:"lg"})});const x=[{label:"Total commits",value:l?.commitCount??0},{label:"Commit range",value:`${l?.minCommitSeq??0} - ${l?.maxCommitSeq??0}`},{label:"Min active cursor",value:l?.minActiveClientCursor??"N/A",tone:"syncing"}];return d.jsxs(d.Fragment,{children:[d.jsx(Ah,{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:v}),d.jsx(Er,{open:t,onOpenChange:n,children:d.jsxs(Xn,{children:[d.jsx(Qn,{children:d.jsx(Wn,{children:"Prune Old Commits"})}),d.jsx("div",{className:"px-5 py-4 flex flex-col gap-4",children:i!==null?d.jsxs(bn,{variant:"default",children:[d.jsx(bu,{children:"Pruning Complete"}),d.jsxs(xn,{children:["Successfully deleted ",d.jsx("strong",{children:i})," commits."]})]}):h?d.jsx("div",{className:"flex items-center justify-center py-8",children:d.jsx(Mt,{size:"sm"})}):f?d.jsxs(d.Fragment,{children:[d.jsx(bn,{variant:f.commitsToDelete>0?"destructive":"default",children:d.jsx(xn,{children:f.commitsToDelete>0?d.jsxs(d.Fragment,{children:["This will delete"," ",d.jsx("strong",{children:f.commitsToDelete})," commits up to sequence"," ",d.jsxs("code",{className:"font-mono",children:["#",f.watermarkCommitSeq]}),"."]}):"No commits are eligible for pruning."})}),d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsxs("div",{className:"flex justify-between font-mono text-[11px]",children:[d.jsx("span",{className:"text-neutral-500",children:"Watermark commit seq:"}),d.jsxs("span",{className:"text-white",children:["#",f.watermarkCommitSeq]})]}),d.jsxs("div",{className:"flex justify-between font-mono text-[11px] items-center",children:[d.jsx("span",{className:"text-neutral-500",children:"Commits to delete:"}),d.jsx(en,{variant:f.commitsToDelete>0?"offline":"ghost",children:f.commitsToDelete})]})]})]}):null}),d.jsxs(pn,{children:[d.jsx(Ae,{variant:"default",onClick:()=>n(!1),children:i!==null?"Close":"Cancel"}),i===null&&d.jsx(Ae,{variant:"destructive",onClick:b,disabled:y.isPending||h||(f?.commitsToDelete??0)===0,children:y.isPending?d.jsxs(d.Fragment,{children:[d.jsx(Mt,{size:"sm"}),"Pruning..."]}):"Prune Now"})]})]})})]})}function B$({partitionId:e}){const[t,n]=S.useState(!1),[i,o]=S.useState(null),{data:l,isLoading:u}=xu({partitionId:e}),f=UV(),h=()=>{n(!0),o(null)},p=async()=>{const v=await f.mutateAsync();o(v.deletedChanges)};if(u)return d.jsx("div",{className:"flex items-center justify-center h-[200px]",children:d.jsx(Mt,{size:"lg"})});const y=[{label:"Total changes",value:l?.changeCount??0},{label:"Total commits",value:l?.commitCount??0}];return d.jsxs(d.Fragment,{children:[d.jsx(Ah,{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:y,actionLabel:"Run Compaction",actionVariant:"primary",onAction:h}),d.jsx(Er,{open:t,onOpenChange:n,children:d.jsxs(Xn,{children:[d.jsx(Qn,{children:d.jsx(Wn,{children:"Compact Changes"})}),d.jsx("div",{className:"px-5 py-4 flex flex-col gap-4",children:i!==null?d.jsxs(bn,{variant:"default",children:[d.jsx(bu,{children:"Compaction Complete"}),d.jsxs(xn,{children:["Successfully removed ",d.jsx("strong",{children:i})," redundant changes."]})]}):d.jsx(bn,{variant:"default",children:d.jsx(xn,{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."})})}),d.jsxs(pn,{children:[d.jsx(Ae,{variant:"default",onClick:()=>n(!1),children:i!==null?"Close":"Cancel"}),i===null&&d.jsx(Ae,{variant:"primary",onClick:p,disabled:f.isPending,children:f.isPending?d.jsxs(d.Fragment,{children:[d.jsx(Mt,{size:"sm"}),"Compacting..."]}):"Compact Now"})]})]})})]})}function H$({partitionId:e}){const[t,n]=S.useState(!1),[i,o]=S.useState("tasks"),[l,u]=S.useState(e??""),[f,h]=S.useState(null),[p,y]=S.useState(null),v=BV(),b=O$(i),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??"—"}],E=()=>{n(!0),y(null)},_=async()=>{if(b.length===0){y("Provide at least one table name.");return}y(null);const T=await v.mutateAsync({tables:b,partitionId:l.trim()||void 0});h(T)};return d.jsxs(d.Fragment,{children:[d.jsx(Ah,{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:E}),d.jsx(Er,{open:t,onOpenChange:n,children:d.jsxs(Xn,{children:[d.jsx(Qn,{children:d.jsx(Wn,{children:"Notify External Data Change"})}),d.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4",children:[f?d.jsxs(bn,{variant:"default",children:[d.jsx(bu,{children:"Notification Sent"}),d.jsxs(xn,{children:["Created synthetic commit"," ",d.jsxs("strong",{children:["#",f.commitSeq]})," for"," ",d.jsx("strong",{children:f.tables.length})," table",f.tables.length===1?"":"s"," and cleared"," ",d.jsx("strong",{children:f.deletedChunks})," cached chunk",f.deletedChunks===1?"":"s","."]})]}):d.jsx(bn,{variant:"default",children:d.jsx(xn,{children:"Use this when data changed outside Syncular push flow. It invalidates cached snapshot chunks and forces clients to pull fresh data."})}),p?d.jsx(bn,{variant:"destructive",children:d.jsx(xn,{children:p})}):null,d.jsxs(Wr,{children:[d.jsx(Lr,{children:"Tables (comma-separated)"}),d.jsx(An,{value:i,onChange:T=>o(T.target.value),placeholder:"tasks, notes",disabled:v.isPending}),d.jsx(Ha,{children:"Enter one or more table names affected by the external change."})]}),d.jsxs(Wr,{children:[d.jsx(Lr,{children:"Partition ID (optional)"}),d.jsx(An,{value:l,onChange:T=>u(T.target.value),placeholder:"default",disabled:v.isPending})]})]}),d.jsxs(pn,{children:[d.jsx(Ae,{variant:"default",onClick:()=>n(!1),children:f?"Close":"Cancel"}),f?null:d.jsx(Ae,{variant:"primary",onClick:_,disabled:v.isPending,children:v.isPending?d.jsxs(d.Fragment,{children:[d.jsx(Mt,{size:"sm"}),"Notifying..."]}):"Notify Data Change"})]})]})})]})}function F$({partitionId:e}){const[t,n]=S.useState("all"),{data:i,isLoading:o,error:l}=DV({limit:20,offset:0,operationType:t==="all"?void 0:t,partitionId:e},{refetchIntervalMs:5e3});return d.jsx(Qv,{title:"Operation Audit",description:"Recent prune/compact/notify/evict actions with actor and result context.",actions:d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(Ae,{variant:t==="all"?"default":"ghost",size:"sm",onClick:()=>n("all"),children:"All"}),d.jsx(Ae,{variant:t==="prune"?"default":"ghost",size:"sm",onClick:()=>n("prune"),children:"Prune"}),d.jsx(Ae,{variant:t==="compact"?"default":"ghost",size:"sm",onClick:()=>n("compact"),children:"Compact"}),d.jsx(Ae,{variant:t==="notify_data_change"?"default":"ghost",size:"sm",onClick:()=>n("notify_data_change"),children:"Notify"}),d.jsx(Ae,{variant:t==="evict_client"?"default":"ghost",size:"sm",onClick:()=>n("evict_client"),children:"Evict"})]}),contentClassName:"pt-2",children:o?d.jsx("div",{className:"flex items-center justify-center py-10",children:d.jsx(Mt,{size:"lg"})}):l?d.jsx(bn,{variant:"destructive",children:d.jsxs(xn,{children:["Failed to load operation audit events: ",l.message]})}):(i?.items.length??0)===0?d.jsx("div",{className:"px-2 py-8 text-sm text-neutral-500",children:"No operation events found for this filter."}):d.jsx("div",{className:"overflow-x-auto",children:d.jsxs(wl,{children:[d.jsx(Tl,{children:d.jsxs(Br,{children:[d.jsx(ut,{children:"Time"}),d.jsx(ut,{children:"Type"}),d.jsx(ut,{children:"User"}),d.jsx(ut,{children:"Target"}),d.jsx(ut,{children:"Result"})]})}),d.jsx(Cl,{children:(i?.items??[]).map((u,f)=>d.jsxs(Br,{children:[d.jsx(ft,{className:"whitespace-nowrap text-xs text-neutral-400",children:L$(u.createdAt)}),d.jsx(ft,{children:d.jsx(en,{variant:"ghost",children:k$(u.operationType)})}),d.jsx(ft,{className:"font-mono text-xs",children:u.consoleUserId??"system"}),d.jsx(ft,{className:"font-mono text-xs",children:u.targetClientId??u.partitionId??(u.operationType==="notify_data_change"?"partition default":"global")}),d.jsx(ft,{className:"font-mono text-xs text-neutral-300",children:D$(u)})]},`${u.operationId}:${u.createdAt}:${f}`))})]})})})}function q$(){const[e,t]=Xo("console:alert-config",M$),n={p90Latency:e.latencyThresholdMs,errorRate:e.errorRateThreshold,clientLag:e.clientLagThreshold},i=l=>{t(u=>({...u,latencyThresholdMs:l.p90Latency,errorRateThreshold:l.errorRate,clientLagThreshold:l.clientLag}))},o=l=>{t(u=>({...u,enabled:l}))};return d.jsx(B1,{enabled:e.enabled,onEnabledChange:o,thresholds:n,onThresholdsChange:i})}function V$(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 $$(e){const t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function G$(){const[e,t]=S.useState(""),[n,i]=S.useState(void 0),[o,l]=S.useState(void 0),[u,f]=S.useState([]),[h,p]=S.useState(null),{data:y,isLoading:v,error:b}=KV({prefix:n,cursor:o,limit:100}),x=YV(),E=XV();function _(){const k=e.trim();i(k.length>0?k:void 0),l(void 0),f([])}function T(){t(""),i(void 0),l(void 0),f([])}function C(){y?.cursor&&(f(k=>[...k,o??""]),l(y.cursor))}function M(){f(k=>{const z=[...k],j=z.pop();return l(j&&j.length>0?j:void 0),z})}function R(){h&&x.mutate(h,{onSuccess:()=>p(null)})}if(v)return d.jsx("div",{className:"flex flex-col gap-4 px-5 py-5",children:d.jsx("div",{className:"flex items-center justify-center h-[200px]",children:d.jsx(Mt,{size:"lg"})})});if(b)return d.jsx("div",{className:"flex flex-col gap-4 px-5 py-5",children:d.jsx("div",{className:"flex items-center justify-center h-[200px]",children:d.jsxs("p",{className:"text-danger font-mono text-[11px]",children:["Failed to load storage items: ",b.message]})})});const N=y?.items??[];return d.jsxs("div",{className:"flex flex-col gap-4 px-5 py-5",children:[d.jsx(Qv,{title:"Storage",actions:d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(An,{placeholder:"Prefix filter...",value:e,onChange:k=>t(k.target.value),onKeyDown:k=>{k.key==="Enter"&&_()},className:"h-7 w-48 text-xs"}),d.jsx(Ae,{variant:"default",size:"sm",onClick:_,children:"Filter"}),n&&d.jsx(Ae,{variant:"ghost",size:"sm",onClick:T,children:"Clear"})]}),children:N.length===0?d.jsx(Yv,{message:n?`No storage items matching prefix "${n}".`:"No storage items found."}):d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"overflow-x-auto",children:d.jsxs(wl,{children:[d.jsx(Tl,{children:d.jsxs(Br,{children:[d.jsx(ut,{children:"Key"}),d.jsx(ut,{children:"Size"}),d.jsx(ut,{children:"Type"}),d.jsx(ut,{children:"Uploaded"}),d.jsx(ut,{children:"Actions"})]})}),d.jsx(Cl,{children:N.map(k=>d.jsxs(Br,{children:[d.jsx(ft,{className:"font-mono text-xs max-w-[320px]",title:k.key,children:k.key}),d.jsx(ft,{className:"font-mono text-xs text-neutral-400 whitespace-nowrap",children:V$(k.size)}),d.jsx(ft,{children:k.httpMetadata?.contentType?d.jsx(en,{variant:"ghost",children:k.httpMetadata.contentType}):d.jsx("span",{className:"text-neutral-500 text-xs",children:"--"})}),d.jsx(ft,{className:"whitespace-nowrap text-xs text-neutral-400",children:$$(k.uploaded)}),d.jsx(ft,{children:d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx(Ae,{variant:"ghost",size:"sm",onClick:()=>{E(k.key)},children:"Download"}),d.jsx(Ae,{variant:"ghost",size:"sm",onClick:()=>p(k.key),children:"Delete"})]})})]},k.key))})]})}),d.jsxs("div",{className:"flex items-center justify-between px-2 py-2",children:[d.jsx(Ae,{variant:"ghost",size:"sm",disabled:u.length===0,onClick:M,children:"Previous"}),d.jsx(Ae,{variant:"ghost",size:"sm",disabled:!y?.truncated,onClick:C,children:"Next"})]})]})}),d.jsx(Er,{open:h!==null,onOpenChange:()=>p(null),children:d.jsxs(Xn,{children:[d.jsx(Qn,{children:d.jsx(Wn,{children:"Delete Storage Item"})}),d.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[d.jsxs("p",{className:"font-mono text-[11px] text-neutral-300",children:["Are you sure you want to delete"," ",d.jsx("span",{className:"font-mono text-white",children:h}),"?"]}),d.jsx("p",{className:"font-mono text-[10px] text-neutral-500",children:"This action cannot be undone."})]}),d.jsxs(pn,{children:[d.jsx(Ae,{variant:"default",onClick:()=>p(null),children:"Cancel"}),d.jsx(Ae,{variant:"destructive",onClick:R,disabled:x.isPending,children:x.isPending?d.jsxs(d.Fragment,{children:[d.jsx(Mt,{size:"sm"})," Deleting..."]}):"Delete"})]})]})})]})}const K$={};function jc(e,t){if(t==="absolute")return new Date(e).toLocaleString();const n=new Date(e),o=new Date().getTime()-n.getTime(),l=Math.floor(o/1e3);return l<60?`${l}s`:l<3600?`${Math.floor(l/60)}m`:l<86400?`${Math.floor(l/3600)}h`:`${Math.floor(l/86400)}d`}function Y$(e){const t=e.split(/\s+/).map(o=>o.trim()).filter(o=>o.length>0),n={},i=[];for(const o of t){const[l="",...u]=o.split(":"),f=u.join(":").trim(),h=l.toLowerCase();if(!f){i.push(o);continue}if(h==="actor"){n.actorId=f;continue}if(h==="client"){n.clientId=f;continue}if(h==="table"){n.table=f;continue}if(h==="request"){n.requestId=f;continue}if(h==="trace"){n.traceId=f;continue}i.push(o)}return i.length>0&&(n.search=i.join(" ")),n}function X$(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 ad(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Q$(e,t){return e?`#${e.federatedCommitId??(t?`${t}:${e.commitSeq}`:String(e.commitSeq))}`:"#?"}function W$(e,t){return e?`E${e.federatedEventId??(t?`${t}:${e.eventId}`:e.eventId)}`:"E?"}function Z$(e,t,n){return!e||!t?null:e.replaceAll("{traceId}",encodeURIComponent(t)).replaceAll("{spanId}",encodeURIComponent(n??""))}function gb({initialSelectedEntryId:e}={}){const{preferences:t}=Eu(),{partitionId:n}=Su(),{range:i,setRange:o}=yj(),l=t.pageSize,u=t.refreshInterval*1e3,f=K$?.VITE_CONSOLE_TRACE_URL_TEMPLATE,[h,p]=S.useState(()=>e?.startsWith("#")?"commits":e?.startsWith("E")?"events":"all"),[y,v]=S.useState("all"),[b,x]=S.useState("all"),[E,_]=S.useState(""),[T,C]=S.useState(1),[M,R]=S.useState(!1),[N,k]=S.useState(e??null),z=S.useRef(!1),j=S.useMemo(()=>Y$(E),[E]),A=S.useMemo(()=>new Date(Date.now()-X$(i)).toISOString(),[i]),{data:D,isLoading:G,refetch:F}=MV({limit:l,offset:(T-1)*l,...n?{partitionId:n}:{},view:h,...h!=="commits"&&y!=="all"?{eventType:y}:{},...h!=="commits"&&b!=="all"?{outcome:b}:{},...j.actorId?{actorId:j.actorId}:{},...j.clientId?{clientId:j.clientId}:{},...j.requestId?{requestId:j.requestId}:{},...j.traceId?{traceId:j.traceId}:{},...j.table?{table:j.table}:{},...j.search?{search:j.search}:{},from:A},{refetchIntervalMs:u}),P=LV(),Q=N?.startsWith("#")?N.slice(1):void 0,X=N?.startsWith("E")?N.slice(1):void 0,te=Q&&Q!=="?"?Q:void 0,L=X&&X!=="?"?X:void 0,{data:$,isLoading:H,error:V}=jV(te,{enabled:te!==void 0,partitionId:n}),{data:U,isLoading:I,error:K}=AV(L,{enabled:L!==void 0,partitionId:n}),{data:Z,isLoading:W,error:se}=OV(L,{enabled:L!==void 0&&!!U?.payloadRef,partitionId:n}),ie=S.useMemo(()=>Z$(f,U?.traceId??null,U?.spanId??null),[U?.spanId,U?.traceId,f]);S.useEffect(()=>{C(1)},[]),S.useEffect(()=>{C(1)},[]),S.useEffect(()=>{e&&k(e)},[e]),S.useEffect(()=>{if(!z.current){z.current=!0;return}k(null)},[]),S.useEffect(()=>{C(1),k(null)},[]);const xe=S.useMemo(()=>(D?.items??[]).map(Se=>{const ye=Se.instanceId??Se.commit?.instanceId??Se.event?.instanceId,be=ye?`[${ye}] `:"";if(Se.type==="commit"&&Se.commit){const Le=Se.commit;return{type:"commit",id:Q$(Le,ye),outcome:"--",duration:"--",actor:Le.actorId,client:Le.clientId,detail:`${be}${Le.changeCount} chg | ${(Le.affectedTables??[]).join(", ")}`,time:jc(Se.timestamp,t.timeFormat)}}const ge=Se.event;return ge?{type:ge.eventType,id:W$(ge,ye),outcome:ge.outcome,duration:`${ge.durationMs}ms`,actor:ge.actorId,client:ge.clientId,detail:`${be}${(ge.tables??[]).join(", ")||"--"}`,time:jc(Se.timestamp,t.timeFormat)}:{type:"pull",id:"E?",outcome:"unknown",duration:"--",actor:"",client:"",detail:"--",time:jc(Se.timestamp,t.timeFormat)}}),[t.timeFormat,D?.items]),de=D?.total??0,Be=Math.max(1,Math.ceil(de/l)),_e=G,re=[{label:"",options:[{id:"all",label:"All"},{id:"commits",label:"Commits"},{id:"events",label:"Events"}],activeId:h,onActiveChange:ae=>{p(ae),ae==="commits"&&(v("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:i,onActiveChange:ae=>{o(ae),C(1)}},{label:"Type",options:[{id:"all",label:"All"},{id:"push",label:"Push"},{id:"pull",label:"Pull"}],activeId:y,onActiveChange:ae=>{v(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 fe(){P.mutate(void 0,{onSuccess:()=>{R(!1),F()}})}return d.jsxs("div",{className:"flex flex-col h-full",children:[_e&&xe.length===0?d.jsx("div",{className:"flex items-center justify-center py-24",children:d.jsx(Mt,{size:"lg"})}):d.jsx(J1,{entries:xe,selectedEntryId:N,onEntryClick:ae=>k(ae.id),filterBar:d.jsx($1,{groups:re,searchValue:E,searchPlaceholder:"Use actor:, client:, table:, request:, trace: or free text...",onSearchChange:_,actions:d.jsxs(d.Fragment,{children:[d.jsx(Ae,{size:"sm",variant:"ghost",onClick:()=>{F()},children:"Refresh"}),d.jsx(Ae,{size:"sm",variant:"ghost",children:"Export"}),d.jsx(Ae,{size:"sm",variant:"destructive",onClick:()=>R(!0),children:"Clear"})]})}),pagination:d.jsx(db,{page:T,totalPages:Be,totalItems:de,onPageChange:C})}),d.jsx(Er,{open:N!==null,onOpenChange:ae=>{ae||k(null)},children:d.jsxs(Xn,{children:[d.jsx(Qn,{children:d.jsx(Wn,{children:te!==void 0?`Commit #${te}`:L!==void 0?`Event E${L}`:"Entry details"})}),d.jsx("div",{className:"px-5 py-4 space-y-3 max-h-[70vh] overflow-y-auto",children:H||I?d.jsx("div",{className:"flex items-center justify-center py-8",children:d.jsx(Mt,{size:"sm"})}):V||K?d.jsx("p",{className:"font-mono text-[11px] text-offline",children:"Failed to load details."}):$?d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"grid grid-cols-2 gap-3 font-mono text-[11px]",children:[d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Actor"}),d.jsx("div",{className:"text-neutral-100",children:$.actorId})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Client"}),d.jsx("div",{className:"text-neutral-100",children:$.clientId})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Instance"}),d.jsx("div",{className:"text-neutral-100",children:$.instanceId??"--"})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Created"}),d.jsx("div",{className:"text-neutral-100",children:jc($.createdAt,t.timeFormat)})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Changes"}),d.jsx("div",{className:"text-neutral-100",children:$.changeCount})]})]}),d.jsxs("div",{children:[d.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2",children:"Affected Tables"}),d.jsx("p",{className:"font-mono text-[11px] text-neutral-200",children:$.affectedTables.join(", ")||"--"})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500",children:"Changes"}),$.changes.length===0?d.jsx("p",{className:"font-mono text-[11px] text-neutral-500",children:"No changes recorded."}):$.changes.map(ae=>d.jsxs("div",{className:"rounded-md border border-border p-3 space-y-2",children:[d.jsxs("div",{className:"flex items-center justify-between font-mono text-[11px]",children:[d.jsxs("span",{className:"text-neutral-300",children:[ae.table," | ",ae.op]}),d.jsxs("span",{className:"text-neutral-500",children:["#",ae.changeId]})]}),d.jsxs("div",{className:"font-mono text-[11px] text-neutral-400",children:["rowId: ",ae.rowId,ae.rowVersion!==null?` | version: ${ae.rowVersion}`:""]}),d.jsx("pre",{className:"font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200",children:ad(ae.rowJson)})]},ae.changeId))]})]}):U?d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"grid grid-cols-2 gap-3 font-mono text-[11px]",children:[d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Type"}),d.jsx("div",{className:"text-neutral-100",children:U.eventType})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Path"}),d.jsx("div",{className:"text-neutral-100",children:U.syncPath})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Instance"}),d.jsx("div",{className:"text-neutral-100",children:U.instanceId??"--"})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Outcome"}),d.jsx("div",{className:"text-neutral-100",children:U.outcome})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Response Status"}),d.jsx("div",{className:"text-neutral-100",children:U.responseStatus})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Actor"}),d.jsx("div",{className:"text-neutral-100",children:U.actorId})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Client"}),d.jsx("div",{className:"text-neutral-100",children:U.clientId})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Status"}),d.jsx("div",{className:"text-neutral-100",children:U.statusCode})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Transport"}),d.jsx("div",{className:"text-neutral-100",children:U.transportPath})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Duration"}),d.jsxs("div",{className:"text-neutral-100",children:[U.durationMs,"ms"]})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Request ID"}),d.jsx("div",{className:"text-neutral-100",children:U.requestId})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Trace ID"}),d.jsx("div",{className:"text-neutral-100",children:U.traceId??"--"}),ie&&d.jsx("a",{href:ie,target:"_blank",rel:"noreferrer",className:"font-mono text-[10px] text-flow underline underline-offset-4",children:"Open external trace"})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Span ID"}),d.jsx("div",{className:"text-neutral-100",children:U.spanId??"--"})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Commit Seq"}),d.jsx("div",{className:"text-neutral-100",children:U.commitSeq??"--"}),U.commitSeq!==null&&d.jsx(Ae,{variant:"ghost",size:"sm",onClick:()=>k(`#${U.instanceId?`${U.instanceId}:`:""}${U.commitSeq}`),children:"Open linked commit"})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Subscription Count"}),d.jsx("div",{className:"text-neutral-100",children:U.subscriptionCount??"--"})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Error Code"}),d.jsx("div",{className:"text-neutral-100",children:U.errorCode??"--"})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Payload Ref"}),d.jsx("div",{className:"text-neutral-100",children:U.payloadRef??"--"})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-neutral-500",children:"Created"}),d.jsx("div",{className:"text-neutral-100",children:jc(U.createdAt,t.timeFormat)})]})]}),d.jsxs("div",{children:[d.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2",children:"Tables"}),d.jsx("p",{className:"font-mono text-[11px] text-neutral-200",children:U.tables.join(", ")||"--"})]}),U.scopesSummary&&d.jsxs("div",{children:[d.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2",children:"Scopes Summary"}),d.jsx("pre",{className:"font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200",children:ad(U.scopesSummary)})]}),U.payloadRef&&d.jsxs("div",{children:[d.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2",children:"Payload Snapshot"}),W?d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(Mt,{size:"sm"}),d.jsx("span",{className:"font-mono text-[11px] text-neutral-400",children:"Loading payload snapshot..."})]}):se?d.jsx("p",{className:"font-mono text-[11px] text-offline",children:"Failed to load payload snapshot."}):Z?d.jsxs("div",{className:"space-y-2",children:[d.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500",children:"Request"}),d.jsx("pre",{className:"font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200",children:ad(Z.requestPayload)}),d.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500",children:"Response"}),d.jsx("pre",{className:"font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200",children:ad(Z.responsePayload)})]}):d.jsx("p",{className:"font-mono text-[11px] text-neutral-500",children:"No payload snapshot available."})]}),U.errorMessage&&d.jsxs("div",{children:[d.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2",children:"Error"}),d.jsx("p",{className:"font-mono text-[11px] text-offline",children:U.errorMessage})]})]}):d.jsx("p",{className:"font-mono text-[11px] text-neutral-500",children:"No details available for this row."})}),d.jsx(pn,{children:d.jsx(Ae,{variant:"default",size:"sm",onClick:()=>k(null),children:"Close"})})]})}),d.jsx(Er,{open:M,onOpenChange:ae=>{ae||R(!1)},children:d.jsxs(Xn,{children:[d.jsx(Qn,{children:d.jsx(Wn,{children:"Clear all events"})}),d.jsx("div",{className:"p-4",children:d.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?"})}),d.jsxs(pn,{children:[d.jsx(Ae,{variant:"default",size:"sm",onClick:()=>R(!1),children:"Cancel"}),d.jsx(Ae,{variant:"destructive",size:"sm",onClick:fe,disabled:P.isPending,children:P.isPending?"Clearing...":"Clear all"})]})]})})]})}const J$=Fs({getParentRoute:()=>Vs,path:"/config",component:y$}),e9=Fs({getParentRoute:()=>Vs,path:"/fleet",component:j$}),t9=Fs({getParentRoute:()=>Vs,path:"/",component:g$});function n9(){const{seq:e}=vj.useParams();return d.jsx(gb,{initialSelectedEntryId:`#${e}`})}const vj=Fs({getParentRoute:()=>Vs,path:"/investigate/commit/$seq",component:n9});function r9(){const{id:e}=bj.useParams();return d.jsx(gb,{initialSelectedEntryId:`E${e}`})}const bj=Fs({getParentRoute:()=>Vs,path:"/investigate/event/$id",component:r9}),s9=Fs({getParentRoute:()=>Vs,path:"/ops",component:P$}),i9=Fs({getParentRoute:()=>Vs,path:"/storage",component:G$}),o9=Fs({getParentRoute:()=>Vs,path:"/stream",component:gb}),a9=Vs.addChildren([t9,o9,vj,bj,e9,s9,i9,J$]),l9="syncular-console-basepath",c9="syncular-console-server-url",u9="syncular-console-token";function f9(e){if(!e)return;const t=e.trim();return t.length>0?t:void 0}function Gy(e){const t=globalThis.document;if(!t)return;const n=t.querySelector(`meta[name="${e}"]`)?.getAttribute("content");return f9(n)}function xj(e){return!e||e==="/"?"/":(e.startsWith("/")?e:`/${e}`).replace(/\/+$/g,"")||"/"}function d9(){return xj(Gy(l9))}function h9(){const e=Gy(c9),t=Gy(u9);return!e||!t?null:{serverUrl:e,token:t}}function p9(){return new k5({defaultOptions:{queries:{staleTime:5e3,retry:1}}})}function m9(e){return xj(e??d9())}function g9(e){const[t]=S.useState(()=>p9()),n=S.useMemo(()=>B3({routeTree:a9,basepath:m9(e.basePath)}),[e.basePath]),i=e.defaultConfig===void 0?h9():e.defaultConfig,o=e.autoConnect??e.defaultConfig===void 0;return d.jsx(I5,{client:t,children:d.jsx(t4,{defaultConfig:i,autoConnect:o,storageMode:e.storageMode,children:d.jsx(q3,{router:n})})})}function y9(e){return d.jsx("div",{className:mb,children:d.jsx(g9,{...e})})}function v9(e){const t=document.querySelector(e);if(!t)throw new Error(`Unable to mount console: ${e} not found`);return t}function b9(e,t={}){const n=v9(e);JV(n);const i=c5.createRoot(n),o=d.jsx(y9,{basePath:t.basePath,defaultConfig:t.defaultConfig,autoConnect:t.autoConnect});return t.strictMode===!1?(i.render(o),i):(i.render(d.jsx(S.StrictMode,{children:o})),i)}var x9={};const S9="syncular-sentry-dsn",E9="syncular-sentry-environment",_9="syncular-sentry-release";function Pc(e){if(!e)return;const t=e.trim();return t.length>0?t:void 0}function Xg(e){if(typeof document>"u")return;const t=document.querySelector(`meta[name="${e}"]`)?.getAttribute("content");return Pc(t)}function Qg(e){if(!(typeof process>"u"))return Pc(x9[e])}function Wg(e){for(const t of e)if(t)return t}function w9(){const e=Wg([Pc(globalThis.__SYNCULAR_SENTRY_DSN__),Xg(S9),Qg("SYNCULAR_SENTRY_DSN")]);if(!e)return null;const t=Wg([Pc(globalThis.__SYNCULAR_SENTRY_ENVIRONMENT__),Xg(E9),Qg("SYNCULAR_SENTRY_ENVIRONMENT")]),n=Wg([Pc(globalThis.__SYNCULAR_SENTRY_RELEASE__),Xg(_9),Qg("SYNCULAR_SENTRY_RELEASE")]);return{dsn:e,environment:t,release:n,enableLogs:!0,tracesSampleRate:.2,tracePropagationTargets:[/^https?:\/\/.*\/api\/.*/]}}const NT=w9();NT&&e5(NT);b9("#root");
@@ -10,7 +10,7 @@
10
10
  <meta name="syncular-sentry-environment" content="" />
11
11
  <meta name="syncular-sentry-release" content="" />
12
12
  <title>@syncular Console</title>
13
- <script type="module" crossorigin src="/assets/index-DWykiGXt.js"></script>
13
+ <script type="module" crossorigin src="/assets/index-BMDmV-35.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">