@syncular/console 0.0.6-84 → 0.0.6-85
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@syncular/console",
|
|
3
|
-
"version": "0.0.6-
|
|
3
|
+
"version": "0.0.6-85",
|
|
4
4
|
"description": "Embeddable Syncular console UI",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Benjamin Kniffler",
|
|
@@ -68,9 +68,9 @@
|
|
|
68
68
|
"release": "bunx syncular-publish"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@syncular/observability-sentry": "0.0.6-
|
|
72
|
-
"@syncular/transport-http": "0.0.6-
|
|
73
|
-
"@syncular/ui": "0.0.6-
|
|
71
|
+
"@syncular/observability-sentry": "0.0.6-85",
|
|
72
|
+
"@syncular/transport-http": "0.0.6-85",
|
|
73
|
+
"@syncular/ui": "0.0.6-85",
|
|
74
74
|
"@tanstack/react-query": "^5.90.21",
|
|
75
75
|
"@tanstack/react-router": "^1.162.9",
|
|
76
76
|
"lucide-react": "^0.575.0"
|
|
@@ -83,4 +83,4 @@ ${a}
|
|
|
83
83
|
${l.right}px ${l.bottom}px,
|
|
84
84
|
${l.right}px ${l.top}px,
|
|
85
85
|
${l.left}px ${l.top}px
|
|
86
|
-
)`}return h.jsx("div",{ref:n,role:"presentation","data-base-ui-inert":"",...i,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:a}})});function Wh(e,t){e&&Object.assign(e.style,t)}const HG={position:"relative",maxHeight:"100%",overflowX:"hidden",overflowY:"auto"},qG={position:"fixed"},VG=_.forwardRef(function(t,n){const{anchor:s,positionMethod:i="absolute",className:a,render:l,side:f="bottom",align:d="center",sideOffset:p=0,alignOffset:g=0,collisionBoundary:y="clipping-ancestors",collisionPadding:b,arrowPadding:x=5,sticky:S=!1,disableAnchorTracking:w,alignItemWithTrigger:T=!0,collisionAvoidance:C=Y9,...O}=t,{store:N,listRef:R,labelsRef:M,alignItemWithTriggerActiveRef:L,selectedItemTextRef:j,valuesRef:A,initialValueRef:P,popupRef:Z,setValue:B}=Wu(),z=BA(),Q=at(N,it.open),Y=at(N,it.mounted),ee=at(N,it.modal),D=at(N,it.value),V=at(N,it.openMethod),q=at(N,it.positionerElement),K=at(N,it.triggerElement),U=at(N,it.isItemEqualToValue),I=at(N,it.transitionStatus),H=_.useRef(null),W=_.useRef(null),[X,oe]=_.useState(T),se=Y&&X&&V!=="touch";!Y&&X!==T&&oe(T),Le(()=>{Y||(it.scrollUpArrowVisible(N.state)&&N.set("scrollUpArrowVisible",!1),it.scrollDownArrowVisible(N.state)&&N.set("scrollDownArrowVisible",!1))},[N,Y]),_.useImperativeHandle(L,()=>se),FA((se||ee)&&Q&&V!=="touch",K);const pe=zA({anchor:s,floatingRootContext:z,positionMethod:i,mounted:Y,side:f,sideOffset:p,align:d,alignOffset:g,arrowPadding:x,collisionBoundary:y,collisionPadding:b,sticky:S,disableAnchorTracking:w??se,collisionAvoidance:C,keepMounted:!0}),xe=se?"none":pe.side,de=se?qG:pe.positionerStyles,Me=_.useMemo(()=>{const Se={};return Q||(Se.pointerEvents="none"),{role:"presentation",hidden:!Y,style:{...de,...Se}}},[Q,Y,de]),_e={open:Q,side:xe,align:pe.align,anchorHidden:pe.anchorHidden},ne=Ae(Se=>{N.set("positionerElement",Se)}),he=zt("div",t,{ref:[n,ne],state:_e,stateAttributesMapping:il,props:[Me,Ap(I),O]}),ae=_.useRef(0),we=Ae(Se=>{if(Se.size===0&&ae.current===0||A.current.length===0)return;const ye=ae.current;if(ae.current=Se.size,Se.size===ye)return;const Ue=Yt(ii);if(ye!==0&&!N.state.multiple&&D!==null&&Ly(A.current,D,U)===-1){const Ee=P.current,Xe=Ee!=null&&Ly(A.current,Ee,U)!==-1?Ee:null;B(Xe,Ue),Xe===null&&(N.set("selectedIndex",null),j.current=null)}if(ye!==0&&N.state.multiple&&Array.isArray(D)){const Ie=Ve=>Ly(A.current,Ve,U)!==-1,Ee=D.filter(Ve=>Ie(Ve));(Ee.length!==D.length||Ee.some(Ve=>!bG(D,Ve,U)))&&(B(Ee,Ue),Ee.length===0&&(N.set("selectedIndex",null),j.current=null))}if(Q&&se){N.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});const Ie={height:""};Wh(q,Ie),Wh(Z.current,Ie)}}),ve=_.useMemo(()=>({...pe,side:xe,alignItemWithTriggerActive:se,setControlledAlignItemWithTrigger:oe,scrollUpArrowRef:H,scrollDownArrowRef:W}),[pe,xe,se,oe]);return h.jsx(qA,{elementsRef:R,labelsRef:M,onMapChange:we,children:h.jsxs(VA.Provider,{value:ve,children:[Y&&ee&&h.jsx(KA,{inert:fx(!Q),cutout:K}),he]})})});function GA(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 Vd="base-ui-disable-scrollbar",DC={className:Vd,getElement(e){return h.jsx("style",{nonce:e,href:Vd,precedence:"base-ui:low",children:`.${Vd}{scrollbar-width:none}.${Vd}::-webkit-scrollbar{display:none}`})}},KG=_.createContext(void 0);function ZA(e){return _.useContext(KG)}const Ec="ArrowUp",Wi="ArrowDown",Au="ArrowLeft",Tc="ArrowRight",Ju="Home",ef="End",YA=new Set([Au,Tc]),GG=new Set([Au,Tc,Ju,ef]),XA=new Set([Ec,Wi]),ZG=new Set([Ec,Wi,Ju,ef]),QA=new Set([...YA,...XA]),YG=new Set([...QA,Ju,ef]),WA=new Set([Ec,Wi,Au,Tc,Ju,ef]),XG="Shift",QG="Control",WG="Alt",JG="Meta",eZ=new Set([XG,QG,WG,JG]);function tZ(e){return Zt(e)&&e.tagName==="INPUT"}function zC(e){return!!(tZ(e)&&e.selectionStart!=null||Zt(e)&&e.tagName==="TEXTAREA")}function LC(e,t,n,s){if(!e||!t||!t.scrollTo)return;let i=e.scrollLeft,a=e.scrollTop;const l=e.clientWidth<e.scrollWidth,f=e.clientHeight<e.scrollHeight;if(l&&s!=="vertical"){const d=UC(e,t,"left"),p=Kd(e),g=Kd(t);n==="ltr"&&(d+t.offsetWidth+g.scrollMarginRight>e.scrollLeft+e.clientWidth-p.scrollPaddingRight?i=d+t.offsetWidth+g.scrollMarginRight-e.clientWidth+p.scrollPaddingRight:d-g.scrollMarginLeft<e.scrollLeft+p.scrollPaddingLeft&&(i=d-g.scrollMarginLeft-p.scrollPaddingLeft)),n==="rtl"&&(d-g.scrollMarginRight<e.scrollLeft+p.scrollPaddingLeft?i=d-g.scrollMarginLeft-p.scrollPaddingLeft:d+t.offsetWidth+g.scrollMarginRight>e.scrollLeft+e.clientWidth-p.scrollPaddingRight&&(i=d+t.offsetWidth+g.scrollMarginRight-e.clientWidth+p.scrollPaddingRight))}if(f&&s!=="horizontal"){const d=UC(e,t,"top"),p=Kd(e),g=Kd(t);d-g.scrollMarginTop<e.scrollTop+p.scrollPaddingTop?a=d-g.scrollMarginTop-p.scrollPaddingTop:d+t.offsetHeight+g.scrollMarginBottom>e.scrollTop+e.clientHeight-p.scrollPaddingBottom&&(a=d+t.offsetHeight+g.scrollMarginBottom-e.clientHeight+p.scrollPaddingBottom)}e.scrollTo({left:i,top:a,behavior:"auto"})}function UC(e,t,n){const s=n==="left"?"offsetLeft":"offsetTop";let i=0;for(;t.offsetParent&&(i+=t[s],t.offsetParent!==e);)t=t.offsetParent;return i}function Kd(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 Uy(e,t=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(t,Math.min(e,n))}const nZ=_.createContext(void 0),rZ={disableStyleElements:!1};function sZ(){return _.useContext(nZ)??rZ}const Vi=1,oZ={...il,...ba},iZ=_.forwardRef(function(t,n){const{render:s,className:i,finalFocus:a,...l}=t,{store:f,popupRef:d,onOpenChangeComplete:p,setOpen:g,valueRef:y,selectedItemTextRef:b,keyboardActiveRef:x,multiple:S,handleScrollArrowVisibility:w,scrollHandlerRef:T,highlightItemOnHover:C}=Wu(),{side:O,align:N,alignItemWithTriggerActive:R,setControlledAlignItemWithTrigger:M,scrollDownArrowRef:L,scrollUpArrowRef:j}=FG(),A=ZA()!=null,P=BA(),{nonce:Z,disableStyleElements:B}=sZ(),z=rs(),Q=at(f,it.id),Y=at(f,it.open),ee=at(f,it.mounted),D=at(f,it.popupProps),V=at(f,it.transitionStatus),q=at(f,it.triggerElement),K=at(f,it.positionerElement),U=at(f,it.listElement),I=_.useRef(0),H=_.useRef(!1),W=_.useRef(0),X=_.useRef(!1),oe=_.useRef({}),se=ox(),pe=Ae(_e=>{if(!K||!d.current||!X.current)return;if(H.current||!R){w();return}const ne=K.style.top==="0px",he=K.style.bottom==="0px",ae=K.getBoundingClientRect().height,we=Rt(K),ve=getComputedStyle(K),Se=parseFloat(ve.marginTop),ye=parseFloat(ve.marginBottom),Ue=$C(getComputedStyle(d.current)),Ie=Math.min(we.documentElement.clientHeight-Se-ye,Ue),Ee=_e.scrollTop,Ve=BC(_e);let Xe=0,Be=null,We=!1,He=!1;const me=qe=>{K.style.height=`${qe}px`},Te=(qe,mt)=>{const lt=Uy(qe,0,Ie-ae);lt>0&&me(ae+lt),_e.scrollTop=mt,Ie-(ae+lt)<=Vi&&(H.current=!0),w()};if(ne){const qe=Ve-Ee,mt=ae+qe,lt=Math.min(mt,Ie);if(Xe=lt,qe<=Vi){Te(qe,Ve);return}Ie-lt>Vi?He=!0:We=!0}else if(he){const qe=Ee,mt=ae+qe,lt=Math.min(mt,Ie),wr=mt-Ie;if(Xe=lt,qe<=Vi){Te(qe,0);return}Ie-lt>Vi?Be=0:(We=!0,Ee<Ve&&(Be=Ee-(qe-wr)))}if(Xe=Math.ceil(Xe),Xe!==0&&me(Xe),He||Be!=null){const qe=BC(_e),mt=He?qe:Uy(Be,0,qe);Math.abs(_e.scrollTop-mt)>Vi&&(_e.scrollTop=mt)}(We||Xe>=Ie-Vi)&&(H.current=!0),w()});_.useImperativeHandle(T,()=>pe,[pe]),xa({open:Y,ref:d,onComplete(){Y&&p?.(!0)}});const xe={open:Y,transitionStatus:V,side:O,align:N};Le(()=>{!K||!d.current||Object.keys(oe.current).length||(oe.current={top:K.style.top||"0",left:K.style.left||"0",right:K.style.right,height:K.style.height,bottom:K.style.bottom,minHeight:K.style.minHeight,maxHeight:K.style.maxHeight,marginTop:K.style.marginTop,marginBottom:K.style.marginBottom})},[d,K]),Le(()=>{Y||R||(X.current=!1,H.current=!1,I.current=0,W.current=0,Wh(K,oe.current))},[Y,R,K,d]),Le(()=>{const _e=d.current;if(!(!Y||!q||!K||!_e||f.state.transitionStatus==="ending")){if(!R){X.current=!0,se.request(w),_e.style.removeProperty("--transform-origin");return}queueMicrotask(()=>{const ne=aZ(_e);_e.style.removeProperty("--transform-origin");try{const he=getComputedStyle(K),ae=getComputedStyle(_e),we=Rt(q),ve=un(K),Se=q.getBoundingClientRect(),ye=K.getBoundingClientRect(),Ue=Se.left,Ie=Se.height,Ee=U||_e,Ve=Ee.scrollHeight,Xe=parseFloat(ae.borderBottomWidth),Be=parseFloat(he.marginTop)||10,We=parseFloat(he.marginBottom)||10,He=parseFloat(he.minHeight)||100,me=$C(ae),Te=5,qe=5,mt=20,lt=we.documentElement.clientHeight-Be-We,wr=we.documentElement.clientWidth,Er=lt-Se.bottom+Ie,Qt=b.current,ut=y.current;let xt,ot=0,Wt=0;if(Qt&&ut){const tr=ut.getBoundingClientRect();xt=Qt.getBoundingClientRect();const ls=tr.left-Ue,uo=xt.left-ye.left,fo=tr.top-Se.top+tr.height/2,nr=xt.top-ye.top+xt.height/2;ot=ls-uo,Wt=nr-fo}const vn=Er+Wt+We+Xe;let kt=Math.min(lt,vn);const Cn=lt-Be-We,er=vn-kt,An=Math.max(Te,Ue+ot),as=wr-qe,cs=Math.max(0,An+ye.width-as);K.style.left=`${An-cs}px`,K.style.height=`${kt}px`,K.style.maxHeight="auto",K.style.marginTop=`${Be}px`,K.style.marginBottom=`${We}px`,_e.style.height="100%";const _a=Ee.scrollHeight-Ee.clientHeight,wi=er>=_a;wi&&(kt=Math.min(lt,ye.height)-(er-_a));const Ei=Se.top<mt||Se.bottom>lt-mt||kt<Math.min(Ve,He),ws=(ve.visualViewport?.scale??1)!==1&&tx;if(Ei||ws){X.current=!0,Wh(K,oe.current),hi.flushSync(()=>M(!1));return}if(wi){const tr=Math.max(0,lt-vn);K.style.top=ye.height>=Cn?"0":`${tr}px`,K.style.height=`${kt}px`,Ee.scrollTop=Ee.scrollHeight-Ee.clientHeight,I.current=Math.max(He,kt)}else K.style.bottom="0",I.current=Math.max(He,kt),Ee.scrollTop=er;if(xt){const tr=ye.top,ls=ye.height,uo=xt.top+xt.height/2,fo=ls>0?(uo-tr)/ls*100:50,nr=Uy(fo,0,100);_e.style.setProperty("--transform-origin",`50% ${nr}%`)}(I.current===lt||kt>=me)&&(H.current=!0),w(),setTimeout(()=>{X.current=!0})}finally{ne()}})}},[f,Y,K,q,y,b,d,w,R,M,se,L,j,U]),_.useEffect(()=>{if(!R||!K||!Y)return;const _e=un(K);function ne(he){g(!1,Yt(x8,he))}return _e.addEventListener("resize",ne),()=>{_e.removeEventListener("resize",ne)}},[g,R,K,Y]);const de={...U?{role:"presentation","aria-orientation":void 0}:{role:"listbox","aria-multiselectable":S||void 0,id:`${Q}-list`},onKeyDown(_e){x.current=!0,A&&WA.has(_e.key)&&_e.stopPropagation()},onMouseMove(){x.current=!1},onPointerLeave(_e){if(!C||GA(_e)||_e.pointerType==="touch")return;const ne=_e.currentTarget;z.start(0,()=>{f.set("activeIndex",null),ne.focus({preventScroll:!0})})},onScroll(_e){U||pe(_e.currentTarget)},...R&&{style:U?{height:"100%"}:HG}},Me=zt("div",t,{ref:[n,d],state:xe,stateAttributesMapping:oZ,props:[D,de,Ap(V),{className:!U&&R?DC.className:void 0},l]});return h.jsxs(_.Fragment,{children:[!B&&DC.getElement(Z),h.jsx(wA,{context:P,modal:!1,disabled:!ee,returnFocus:a,restoreFocus:!0,children:Me})]})});function $C(e){const t=e.maxHeight||"";return t.endsWith("px")&&parseFloat(t)||1/0}function BC(e){return Math.max(0,e.scrollHeight-e.clientHeight)}const FC=[["transform","none"],["scale","1"],["translate","0 0"]];function aZ(e){const{style:t}=e,n={};for(const[s,i]of FC)n[s]=t.getPropertyValue(s),t.setProperty(s,i,"important");return()=>{for(const[s]of FC){const i=n[s];i?t.setProperty(s,i):t.removeProperty(s)}}}let JA=(function(e){return e[e.None=0]="None",e[e.GuessFromOrder=1]="GuessFromOrder",e})({});function dx(e={}){const{label:t,metadata:n,textRef:s,indexGuessBehavior:i,index:a}=e,{register:l,unregister:f,subscribeMapChange:d,elementsRef:p,labelsRef:g,nextIndexRef:y}=LG(),b=_.useRef(-1),[x,S]=_.useState(a??(i===JA.GuessFromOrder?()=>{if(b.current===-1){const C=y.current;y.current+=1,b.current=C}return b.current}:-1)),w=_.useRef(null),T=_.useCallback(C=>{if(w.current=C,x!==-1&&C!==null&&(p.current[x]=C,g)){const O=t!==void 0;g.current[x]=O?t:s?.current?.textContent??C.textContent}},[x,p,g,t,s]);return Le(()=>{if(a!=null)return;const C=w.current;if(C)return l(C,n),()=>{f(C)}},[a,l,f,n]),Le(()=>{if(a==null)return d(C=>{const O=w.current?C.get(w.current)?.index:null;O!=null&&S(O)})},[a,d,S]),_.useMemo(()=>({ref:T,index:x}),[x,T])}const cZ=_.createContext(void 0),lZ=_.memo(_.forwardRef(function(t,n){const{render:s,className:i,value:a=null,label:l,disabled:f=!1,nativeButton:d=!1,...p}=t,g=_.useRef(null),y=dx({label:l,textRef:g,indexGuessBehavior:JA.GuessFromOrder}),{store:b,getItemProps:x,setOpen:S,setValue:w,selectionRef:T,typingRef:C,valuesRef:O,keyboardActiveRef:N,multiple:R,highlightItemOnHover:M}=Wu(),L=rs(),j=at(b,it.isActive,y.index),A=at(b,it.isSelected,y.index,a),P=at(b,it.isSelectedByFocus,y.index),Z=at(b,it.isItemEqualToValue),B=y.index,z=B!==-1,Q=_.useRef(null),Y=Jo(B);Le(()=>{if(!z)return;const se=O.current;return se[B]=a,()=>{delete se[B]}},[z,B,a,O]),Le(()=>{if(!z)return;const se=b.state.value;let pe=se;R&&Array.isArray(se)&&se.length>0&&(pe=se[se.length-1]),pe!==void 0&&Bc(a,pe,Z)&&b.set("selectedIndex",B)},[z,B,R,Z,b,a]);const ee={disabled:f,selected:A,highlighted:j},D=x({active:j,selected:A});D.onFocus=void 0,D.id=void 0;const V=_.useRef(null),q=_.useRef("mouse"),K=_.useRef(!1),{getButtonProps:U,buttonRef:I}=el({disabled:f,focusableWhenDisabled:!0,native:d});function H(se){const pe=b.state.value;if(R){const xe=Array.isArray(pe)?pe:[],de=A?xG(xe,a,Z):[...xe,a];w(de,Yt(Ry,se))}else w(a,Yt(Ry,se)),S(!1,Yt(Ry,se))}const W={role:"option","aria-selected":A,tabIndex:j?0:-1,onFocus(){b.set("activeIndex",B)},onMouseEnter(){!N.current&&b.state.selectedIndex===null&&M&&b.set("activeIndex",B)},onMouseMove(){M&&b.set("activeIndex",B)},onMouseLeave(se){!M||N.current||GA(se)||L.start(0,()=>{b.state.activeIndex===B&&b.set("activeIndex",null)})},onTouchStart(){T.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1}},onKeyDown(se){V.current=se.key,b.set("activeIndex",B)},onClick(se){K.current=!1,!(se.type==="keydown"&&V.current===null)&&(f||V.current===" "&&C.current||q.current!=="touch"&&!j||(V.current=null,H(se.nativeEvent)))},onPointerEnter(se){q.current=se.pointerType},onPointerDown(se){q.current=se.pointerType,K.current=!0},onMouseUp(se){if(f)return;if(K.current){K.current=!1;return}const pe=!T.current.allowSelectedMouseUp&&A,xe=!T.current.allowUnselectedMouseUp&&!A;pe||xe||q.current!=="touch"&&!j||H(se.nativeEvent)}},X=zt("div",t,{ref:[I,n,y.ref,Q],state:ee,props:[D,W,p,U]}),oe=_.useMemo(()=>({selected:A,indexRef:Y,textRef:g,selectedByFocus:P,hasRegistered:z}),[A,Y,g,P,z]);return h.jsx(cZ.Provider,{value:oe,children:X})})),uZ=_.forwardRef(({className:e,children:t,...n},s)=>h.jsx(jG,{ref:s,className:ge("inline-flex items-center justify-between bg-surface border border-border rounded-md px-3 py-1.5 font-mono text-[12px] text-foreground cursor-pointer hover:border-border-bright transition",e),...n,children:t}));uZ.displayName="SelectTrigger";const fZ=_.forwardRef(({className:e,portalProps:t,positionerProps:n,...s},i)=>h.jsx(kG,{...t,children:h.jsx(VG,{...n,children:h.jsx(iZ,{ref:i,className:ge("bg-panel border border-border rounded-md py-1 shadow-lg z-50",e),...s})})}));fZ.displayName="SelectContent";const dZ=_.forwardRef(({className:e,...t},n)=>h.jsx(lZ,{ref:n,className:ge("font-mono text-[11px] px-3 py-1.5 text-neutral-400 cursor-pointer hover:bg-white/[0.03] hover:text-white data-[highlighted]:bg-white/[0.03] data-[highlighted]:text-white outline-none",e),...t}));dZ.displayName="SelectItem";const hZ=_.forwardRef(({className:e,...t},n)=>h.jsx("textarea",{ref:n,className:ge("bg-surface border border-border rounded-md px-3 py-2 font-mono text-[12px] text-foreground outline-none w-full transition focus:border-flow placeholder:text-neutral-600 resize-none min-h-[80px]",e),...t}));hZ.displayName="Textarea";const ek=_.createContext(void 0);function pZ(e=!0){const t=_.useContext(ek);if(t===void 0&&!e)throw new Error(yn(7));return t}function tk(e={}){const{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:s}=jj(),{ref:i,index:a}=dx(e),l=n===a,f=_.useRef(null),d=so(i,f);return{compositeProps:_.useMemo(()=>({tabIndex:l?0:-1,onFocus(){s(a)},onMouseMove(){const g=f.current;if(!t||!g)return;const y=g.hasAttribute("disabled")||g.ariaDisabled==="true";!l&&!y&&g.focus()}}),[l,s,a,t]),compositeRef:d,index:a}}function mZ(e){const{render:t,className:n,state:s=an,props:i=Ru,refs:a=Ru,metadata:l,stateAttributesMapping:f,tag:d="div",...p}=e,{compositeProps:g,compositeRef:y}=tk({metadata:l});return zt(d,e,{state:s,ref:[...a,y],props:[g,...i,p],stateAttributesMapping:f})}const gZ=_.forwardRef(function(t,n){const{className:s,defaultPressed:i=!1,disabled:a=!1,form:l,onPressedChange:f,pressed:d,render:p,type:g,value:y,nativeButton:b=!0,...x}=t,S=br(y||void 0),w=pZ(),T=w?.value??[],C=w?void 0:i,O=(a||w?.disabled)??!1,[N,R]=gp({controlled:w?S!==void 0&&T.indexOf(S)>-1:d,default:C,name:"Toggle",state:"pressed"}),M=Ae((z,Q)=>{S&&w?.setGroupValue?.(S,z,Q),f?.(z,Q)}),{getButtonProps:L,buttonRef:j}=el({disabled:O,native:b}),A={disabled:O,pressed:N},P=[j,n],Z=[{"aria-pressed":N,onClick(z){const Q=!N,Y=Yt(ii,z.nativeEvent);M(Q,Y),!Y.isCanceled&&R(Q)}},x,L],B=zt("button",t,{enabled:!w,state:A,ref:P,props:Z});return w?h.jsx(mZ,{tag:"button",render:p,className:s,state:A,refs:P,props:Z}):B}),Dr=_.forwardRef(({className:e,...t},n)=>h.jsx(gZ,{ref:n,className:ge("font-mono text-[10px] text-neutral-500 border border-transparent rounded-sm px-2.5 py-1 cursor-pointer transition-all hover:text-neutral-300 data-[pressed]:text-white data-[pressed]:border-border-bright data-[pressed]:bg-white/[0.03]",e),...t}));Dr.displayName="Toggle";function yZ(e){return e==null||e.hasAttribute("disabled")||e.getAttribute("aria-disabled")==="true"}const nk="data-composite-item-active",vZ=[];function bZ(e){const{itemSizes:t,cols:n=1,loopFocus:s=!0,dense:i=!1,orientation:a="both",direction:l,highlightedIndex:f,onHighlightedIndexChange:d,rootRef:p,enableHomeAndEndKeys:g=!1,stopEventPropagation:y=!1,disabledIndices:b,modifierKeys:x=vZ}=e,[S,w]=_.useState(0),T=n>1,C=_.useRef(null),O=so(C,p),N=_.useRef([]),R=_.useRef(!1),M=f??S,L=Ae((P,Z=!1)=>{if((d??w)(P),Z){const B=N.current[P];LC(C.current,B,l,a)}}),j=Ae(P=>{if(P.size===0||R.current)return;R.current=!0;const Z=Array.from(P.keys()),B=Z.find(Q=>Q?.hasAttribute(nk))??null,z=B?Z.indexOf(B):-1;z!==-1&&L(z),LC(C.current,B,l,a)}),A=_.useMemo(()=>({"aria-orientation":a==="both"?void 0:a,ref:O,onFocus(P){!C.current||!zC(P.target)||P.target.setSelectionRange(0,P.target.value.length??0)},onKeyDown(P){const Z=g?YG:QA;if(!Z.has(P.key)||xZ(P,x)||!C.current)return;const z=l==="rtl",Q=z?Au:Tc,Y={horizontal:Q,vertical:Wi,both:Q}[a],ee=z?Tc:Au,D={horizontal:ee,vertical:Ec,both:ee}[a];if(zC(P.target)&&!yZ(P.target)){const W=P.target.selectionStart,X=P.target.selectionEnd,oe=P.target.value??"";if(W==null||P.shiftKey||W!==X||P.key!==D&&W<oe.length||P.key!==Y&&W>0)return}let V=M;const q=IV(N,b),K=PV(N,b);if(T){const W=t||Array.from({length:N.current.length},()=>({width:1,height:1})),X=zV(W,n,i),oe=X.findIndex(pe=>pe!=null&&!pu(N,pe,b)),se=X.reduce((pe,xe,de)=>xe!=null&&!pu(N,xe,b)?de:pe,-1);V=X[DV({current:X.map(pe=>pe?N.current[pe]:null)},{event:P,orientation:a,loopFocus:s,cols:n,disabledIndices:UV([...b||N.current.map((pe,xe)=>pu(N,xe)?xe:void 0),void 0],X),minIndex:oe,maxIndex:se,prevIndex:LV(M>K?q:M,W,X,n,P.key===Wi?"bl":P.key===Tc?"tr":"tl"),rtl:z})]}const U={horizontal:[Q],vertical:[Wi],both:[Q,Wi]}[a],I={horizontal:[ee],vertical:[Ec],both:[ee,Ec]}[a],H=T?Z:{horizontal:g?GG:YA,vertical:g?ZG:XA,both:Z}[a];g&&(P.key===Ju?V=q:P.key===ef&&(V=K)),V===M&&(U.includes(P.key)||I.includes(P.key))&&(s&&V===K&&U.includes(P.key)?V=q:s&&V===q&&I.includes(P.key)?V=K:V=fr(N,{startingIndex:V,decrement:I.includes(P.key),disabledIndices:b})),V!==M&&!ch(N,V)&&(y&&P.stopPropagation(),H.has(P.key)&&P.preventDefault(),L(V,!0),queueMicrotask(()=>{N.current[V]?.focus()}))}}),[n,i,l,b,N,g,M,T,t,s,O,x,L,a,y]);return _.useMemo(()=>({props:A,highlightedIndex:M,onHighlightedIndexChange:L,elementsRef:N,disabledIndices:b,onMapChange:j,relayKeyboardEvent:A.onKeyDown}),[A,M,L,N,b,j])}function xZ(e,t){for(const n of eZ.values())if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function rk(e){const{render:t,className:n,refs:s=Ru,props:i=Ru,state:a=an,stateAttributesMapping:l,highlightedIndex:f,onHighlightedIndexChange:d,orientation:p,dense:g,itemSizes:y,loopFocus:b,cols:x,enableHomeAndEndKeys:S,onMapChange:w,stopEventPropagation:T=!0,rootRef:C,disabledIndices:O,modifierKeys:N,highlightItemOnHover:R=!1,tag:M="div",...L}=e,j=PA(),{props:A,highlightedIndex:P,onHighlightedIndexChange:Z,elementsRef:B,onMapChange:z,relayKeyboardEvent:Q}=bZ({itemSizes:y,cols:x,loopFocus:b,dense:g,orientation:p,highlightedIndex:f,onHighlightedIndexChange:d,rootRef:C,stopEventPropagation:T,enableHomeAndEndKeys:S,direction:j,disabledIndices:O,modifierKeys:N}),Y=zt(M,e,{state:a,ref:s,props:[A,...i,L],stateAttributesMapping:l}),ee=_.useMemo(()=>({highlightedIndex:P,onHighlightedIndexChange:Z,highlightItemOnHover:R,relayKeyboardEvent:Q}),[P,Z,R,Q]);return h.jsx(Nj.Provider,{value:ee,children:h.jsx(qA,{elementsRef:B,onMapChange:D=>{w?.(D),z(D)},children:Y})})}let SZ=(function(e){return e.disabled="data-disabled",e.orientation="data-orientation",e.multiple="data-multiple",e})({});const HC={multiple(e){return e?{[SZ.multiple]:""}:null}},_Z=_.forwardRef(function(t,n){const{defaultValue:s,disabled:i=!1,loopFocus:a=!0,onValueChange:l,orientation:f="horizontal",multiple:d=!1,value:p,className:g,render:y,...b}=t,x=ZA(),S=_.useMemo(()=>{if(p===void 0)return s??[]},[p,s]),w=_.useMemo(()=>p!==void 0||s!==void 0,[p,s]),T=(x?.disabled??!1)||i,[C,O]=gp({controlled:p,default:S,name:"ToggleGroup",state:"value"}),N=Ae((A,P,Z)=>{let B;if(d?(B=C.slice(),P?B.push(A):B.splice(C.indexOf(A),1)):B=P?[A]:[],Array.isArray(B)){if(l?.(B,Z),Z.isCanceled)return;O(B)}}),R={disabled:T,multiple:d,orientation:f},M=_.useMemo(()=>({disabled:T,orientation:f,setGroupValue:N,value:C,isValueInitialized:w}),[T,f,N,C,w]),L={role:"group"},j=zt("div",t,{enabled:!!x,state:R,ref:n,props:[L,b],stateAttributesMapping:HC});return h.jsx(ek.Provider,{value:M,children:x?j:h.jsx(rk,{render:y,className:g,state:R,refs:[n],props:[L,b],stateAttributesMapping:HC,loopFocus:a,enableHomeAndEndKeys:!0})})}),dh=_.forwardRef(({className:e,...t},n)=>h.jsx(_Z,{ref:n,className:ge("flex items-center gap-0.5",e),...t}));dh.displayName="ToggleGroup";const wZ=ge(Fj({variant:"secondary",size:"sm"}),"h-7 whitespace-nowrap uppercase tracking-[0.08em] leading-none no-underline");function sk({active:e,onClick:t,children:n,className:s}){return h.jsxs("button",{type:"button",onClick:t,className:ge("font-mono text-[10px] tracking-[1.5px] uppercase bg-transparent border-none px-3.5 py-1 cursor-pointer relative transition-colors",e?"text-white":"text-neutral-500 hover:text-neutral-300",s),children:[n,e&&h.jsx("span",{className:"absolute -bottom-2.5 left-1/2 -translate-x-1/2 w-4 h-0.5 bg-flow rounded-sm shadow-[0_0_8px_rgba(59,130,246,0.5)]"})]})}function EZ({items:e,activeId:t,onItemChange:n,renderItem:s,className:i}){return h.jsx("div",{className:ge("flex items-center gap-0.5",i),children:e.map(a=>{const l=a.id===t,f=()=>n?.(a.id);return s?h.jsx("span",{children:s(a,{active:l,onClick:f})},a.id):h.jsx(sk,{active:l,onClick:f,children:a.label},a.id)})})}const TZ=gi("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}}),CZ={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 RZ({color:e,size:t,glow:n,pulse:s,className:i}){return h.jsx("span",{className:ge(TZ({color:e,size:t,glow:n}),s&&"dot-pulse",i),style:n?{boxShadow:CZ[e??"healthy"]}:void 0})}const NZ="0.0.6-84",jZ={version:NZ},AZ=jZ.version;function kZ({label:e,className:t}){return h.jsxs("div",{className:ge("flex items-center gap-3",t),children:[h.jsx(RZ,{color:"healthy",size:"md",glow:!0}),h.jsx("span",{className:"font-display font-bold text-white text-sm tracking-tight",children:"syncular"}),e&&h.jsx("span",{className:"font-mono text-[9px] text-neutral-600 uppercase tracking-widest",children:e}),h.jsxs("span",{className:"font-mono text-[9px] text-neutral-600 tracking-wider",children:["v",AZ]})]})}function OZ({brand:e,center:t,right:n,className:s}){return h.jsxs(h.Fragment,{children:[h.jsx("div",{"aria-hidden":"true",className:"h-[42px] shrink-0"}),h.jsxs("nav",{className:ge("fixed top-0 left-0 right-0 z-100 h-[42px] border-b border-border bg-surface/88 backdrop-blur-lg flex items-center justify-between px-5",s),children:[h.jsx("div",{className:"flex items-center gap-3",children:e}),h.jsx("div",{className:"flex items-center gap-0.5",children:t}),h.jsx("div",{className:"flex items-center gap-2",children:n})]})]})}const MZ=gi("border rounded-lg p-3 font-mono text-[11px]",{variants:{variant:{default:"border-border bg-panel",destructive:"border-offline/20 bg-offline/5 text-offline"}},defaultVariants:{variant:"default"}}),In=_.forwardRef(({className:e,variant:t,...n},s)=>h.jsx("div",{ref:s,role:"alert",className:ge(MZ({variant:t,className:e})),...n}));In.displayName="Alert";const tf=_.forwardRef(({className:e,...t},n)=>h.jsx("h5",{ref:n,className:ge("font-medium text-white mb-1",e),...t}));tf.displayName="AlertTitle";const Pn=_.forwardRef(({className:e,...t},n)=>h.jsx("p",{ref:n,className:ge("text-neutral-400",e),...t}));Pn.displayName="AlertDescription";const ok=_.createContext(void 0);function al(e){const t=_.useContext(ok);if(e===!1&&t===void 0)throw new Error(yn(27));return t}const IZ={...il,...ba},hx=_.forwardRef(function(t,n){const{render:s,className:i,forceRender:a=!1,...l}=t,{store:f}=al(),d=f.useState("open"),p=f.useState("nested"),g=f.useState("mounted"),y=f.useState("transitionStatus");return zt("div",t,{state:{open:d,transitionStatus:y},ref:[f.context.backdropRef,n],stateAttributesMapping:IZ,props:[{role:"presentation",hidden:!g,style:{userSelect:"none",WebkitUserSelect:"none"}},l],enabled:a||!p})}),ik=_.forwardRef(function(t,n){const{render:s,className:i,id:a,...l}=t,{store:f}=al(),d=br(a);return f.useSyncedValueWithCleanup("descriptionElementId",d),zt("p",t,{ref:n,props:[{id:d},l]})});let PZ=(function(e){return e.nestedDialogs="--nested-dialogs",e})({}),DZ=(function(e){return e[e.open=Qi.open]="open",e[e.closed=Qi.closed]="closed",e[e.startingStyle=Qi.startingStyle]="startingStyle",e[e.endingStyle=Qi.endingStyle]="endingStyle",e.nested="data-nested",e.nestedDialogOpen="data-nested-dialog-open",e})({});const ak=_.createContext(void 0);function zZ(){const e=_.useContext(ak);if(e===void 0)throw new Error(yn(26));return e}const LZ={...il,...ba,nestedDialogOpen(e){return e?{[DZ.nestedDialogOpen]:""}:null}},ck=_.forwardRef(function(t,n){const{className:s,finalFocus:i,initialFocus:a,render:l,...f}=t,{store:d}=al(),p=d.useState("descriptionElementId"),g=d.useState("disablePointerDismissal"),y=d.useState("floatingRootContext"),b=d.useState("popupProps"),x=d.useState("modal"),S=d.useState("mounted"),w=d.useState("nested"),T=d.useState("nestedOpenDialogCount"),C=d.useState("open"),O=d.useState("openMethod"),N=d.useState("titleElementId"),R=d.useState("transitionStatus"),M=d.useState("role");zZ(),xa({open:C,ref:d.context.popupRef,onComplete(){C&&d.context.onOpenChangeComplete?.(!0)}});function L(B){return B==="touch"?d.context.popupRef.current:!0}const j=a===void 0?L:a,A=T>0,Z=zt("div",t,{state:{open:C,nested:w,transitionStatus:R,nestedDialogOpen:A},props:[b,{"aria-labelledby":N??void 0,"aria-describedby":p??void 0,role:M,tabIndex:-1,hidden:!S,onKeyDown(B){WA.has(B.key)&&B.stopPropagation()},style:{[PZ.nestedDialogs]:T}},f],ref:[n,d.context.popupRef,d.useStateSetter("popupElement")],stateAttributesMapping:LZ});return h.jsx(wA,{context:y,openInteractionType:O,disabled:!S,closeOnFocusOut:!g,initialFocus:j,returnFocus:i,modal:x!==!1,restoreFocus:"popup",children:Z})}),lk=_.forwardRef(function(t,n){const{keepMounted:s=!1,...i}=t,{store:a}=al(),l=a.useState("mounted"),f=a.useState("modal"),d=a.useState("open");return l||s?h.jsx(ak.Provider,{value:s,children:h.jsxs(_A,{ref:n,...i,children:[l&&f===!0&&h.jsx(KA,{ref:a.context.internalBackdropRef,inert:fx(!d)}),t.children]})}):null});function UZ(e){const{store:t,parentContext:n,actionsRef:s}=e,i=t.useState("open"),a=t.useState("disablePointerDismissal"),l=t.useState("modal"),f=t.useState("popupElement"),{openMethod:d,triggerProps:p,reset:g}=TG(i);m7(t);const{forceUnmount:y}=g7(i,t,()=>{g()}),b=Ae(Z=>{const B=Yt(Z);return B.preventUnmountOnClose=()=>{t.set("preventUnmountingOnClose",!0)},B}),x=_.useCallback(()=>{t.setOpen(!1,b(b8))},[t,b]);_.useImperativeHandle(s,()=>({unmount:y,close:x}),[y,x]);const S=_7({popupStore:t,onOpenChange:t.setOpen,treatPopupAsFloatingElement:!0,noEmit:!0}),[w,T]=_.useState(0),C=w===0,O=k7(S),N=r7(S,{outsidePressEvent(){return t.context.internalBackdropRef.current||t.context.backdropRef.current?"intentional":{mouse:l==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}},outsidePress(Z){if(!t.context.outsidePressEnabledRef.current||"button"in Z&&Z.button!==0||"touches"in Z&&Z.touches.length!==1)return!1;const B=Ur(Z);if(C&&!a){const z=B;return l&&(t.context.internalBackdropRef.current||t.context.backdropRef.current)?t.context.internalBackdropRef.current===z||t.context.backdropRef.current===z||Ot(z,f)&&!z?.hasAttribute("data-base-ui-portal"):!0}return!1},escapeKey:C});FA(i&&l===!0,f);const{getReferenceProps:R,getFloatingProps:M,getTriggerProps:L}=j7([O,N]);t.useContextCallback("onNestedDialogOpen",Z=>{T(Z+1)}),t.useContextCallback("onNestedDialogClose",()=>{T(0)}),_.useEffect(()=>(n?.onNestedDialogOpen&&i&&n.onNestedDialogOpen(w),n?.onNestedDialogClose&&!i&&n.onNestedDialogClose(),()=>{n?.onNestedDialogClose&&i&&n.onNestedDialogClose()}),[i,n,w]);const j=_.useMemo(()=>R(p),[R,p]),A=_.useMemo(()=>L(p),[L,p]),P=_.useMemo(()=>M(),[M]);t.useSyncedValues({openMethod:d,activeTriggerProps:j,inactiveTriggerProps:A,popupProps:P,floatingRootContext:S,nestedOpenDialogCount:w})}const $Z={...b7,modal:Pe(e=>e.modal),nested:Pe(e=>e.nested),nestedOpenDialogCount:Pe(e=>e.nestedOpenDialogCount),disablePointerDismissal:Pe(e=>e.disablePointerDismissal),openMethod:Pe(e=>e.openMethod),descriptionElementId:Pe(e=>e.descriptionElementId),titleElementId:Pe(e=>e.titleElementId),viewportElement:Pe(e=>e.viewportElement),role:Pe(e=>e.role)};class BZ extends OA{constructor(t){super(FZ(t),{popupRef:_.createRef(),backdropRef:_.createRef(),internalBackdropRef:_.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:new lx,onOpenChange:void 0,onOpenChangeComplete:void 0},$Z)}setOpen=(t,n)=>{if(n.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},!t&&n.trigger==null&&this.state.activeTriggerId!=null&&(n.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(t,n),n.isCanceled)return;const s={open:t,nativeEvent:n.event,reason:n.reason,nested:this.state.nested};this.state.floatingRootContext.context.events?.emit("openchange",s);const i={open:t},a=n.trigger?.id??null;(a||t)&&(i.activeTriggerId=a,i.activeTriggerElement=n.trigger??null),this.update(i)}}function FZ(e={}){return{...v7(),modal:!0,disablePointerDismissal:!1,popupElement:null,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,role:"dialog",...e}}function HZ(e){const{children:t,open:n,defaultOpen:s=!1,onOpenChange:i,onOpenChangeComplete:a,disablePointerDismissal:l=!1,modal:f=!0,actionsRef:d,handle:p,triggerId:g,defaultTriggerId:y=null}=e,b=al(!0),x=!!b,S=zn(()=>p?.store??new BZ({open:s,openProp:n,activeTriggerId:y,triggerIdProp:g,modal:f,disablePointerDismissal:l,nested:x})).current;oV(()=>{n===void 0&&S.state.open===!1&&s===!0&&S.update({open:!0,activeTriggerId:y})}),S.useControlledProp("openProp",n),S.useControlledProp("triggerIdProp",g),S.useSyncedValues({disablePointerDismissal:l,nested:x,modal:f}),S.useContextCallback("onOpenChange",i),S.useContextCallback("onOpenChangeComplete",a);const w=S.useState("payload");UZ({store:S,actionsRef:d,parentContext:b?.store.context});const T=_.useMemo(()=>({store:S}),[S]);return h.jsx(ok.Provider,{value:T,children:typeof t=="function"?t({payload:w}):t})}const uk=_.forwardRef(function(t,n){const{render:s,className:i,id:a,...l}=t,{store:f}=al(),d=br(a);return f.useSyncedValueWithCleanup("titleElementId",d),zt("h2",t,{ref:n,props:[{id:d},l]})}),$r=HZ,qZ=_.forwardRef(({className:e,...t},n)=>h.jsx(hx,{ref:n,className:ge("fixed inset-0 z-50 bg-black/60 backdrop-blur-sm",e),...t}));qZ.displayName="DialogOverlay";const hr=_.forwardRef(({className:e,children:t,...n},s)=>h.jsxs(lk,{children:[h.jsx(hx,{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm"}),h.jsx(ck,{ref:s,className:ge("fixed z-50 top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-panel border border-border rounded-lg shadow-lg max-w-lg w-full p-0",e),...n,children:t})]}));hr.displayName="DialogContent";const pr=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("px-5 py-3 border-b border-border",e),...t}));pr.displayName="DialogHeader";const Nn=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("px-5 py-3 border-t border-border flex justify-end gap-2",e),...t}));Nn.displayName="DialogFooter";const mr=_.forwardRef(({className:e,...t},n)=>h.jsx(uk,{ref:n,className:ge("font-mono text-[10px] text-neutral-500 uppercase tracking-widest",e),...t}));mr.displayName="DialogTitle";const VZ=_.forwardRef(({className:e,...t},n)=>h.jsx(ik,{ref:n,className:ge("font-mono text-[10px] text-neutral-500",e),...t}));VZ.displayName="DialogDescription";const px=_.forwardRef(({className:e,page:t,totalPages:n,totalItems:s,onPageChange:i,...a},l)=>h.jsxs("div",{ref:l,className:ge("px-5 py-2.5 border-t border-border flex items-center justify-between",e),...a,children:[h.jsxs("span",{className:"font-mono text-[10px] text-neutral-600",children:[s," items · Page ",t," of ",n]}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx(Oe,{size:"sm",variant:"default",disabled:t<=1,onClick:()=>i(t-1),children:"Prev"}),h.jsx(Oe,{size:"sm",variant:"default",disabled:t>=n,onClick:()=>i(t+1),children:"Next"})]})]}));px.displayName="Pagination";const KZ=_.forwardRef(({className:e,orientation:t="horizontal",...n},s)=>h.jsx("hr",{ref:s,"aria-orientation":t==="vertical"?"vertical":void 0,className:ge("border-none m-0",t==="horizontal"?"h-px w-full bg-border":"w-px h-4 bg-border",e),...n}));KZ.displayName="Separator";const GZ=gi("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"}}),ZZ=_.forwardRef(({className:e,side:t,children:n,...s},i)=>h.jsxs(lk,{children:[h.jsx(hx,{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm"}),h.jsx(ck,{ref:i,className:ge(GZ({side:t,className:e})),...s,children:n})]}));ZZ.displayName="SheetContent";const YZ=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("px-5 py-3 border-b border-border",e),...t}));YZ.displayName="SheetHeader";const XZ=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("px-5 py-3 border-t border-border flex justify-end gap-2",e),...t}));XZ.displayName="SheetFooter";const QZ=_.forwardRef(({className:e,...t},n)=>h.jsx(uk,{ref:n,className:ge("font-mono text-[10px] text-neutral-500 uppercase tracking-widest",e),...t}));QZ.displayName="SheetTitle";const WZ=_.forwardRef(({className:e,...t},n)=>h.jsx(ik,{ref:n,className:ge("text-sm text-neutral-400",e),...t}));WZ.displayName="SheetDescription";const JZ=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("rounded-md bg-neutral-800 animate-pulse",e),...t}));JZ.displayName="Skeleton";const eY=_.createContext(void 0);function mx(){const e=_.useContext(eY);if(e===void 0)throw new Error(yn(64));return e}let tY=(function(e){return e.activationDirection="data-activation-direction",e.orientation="data-orientation",e})({});const fk={tabActivationDirection:e=>({[tY.activationDirection]:e})},dk=_.createContext(void 0);function nY(){const e=_.useContext(dk);if(e===void 0)throw new Error(yn(65));return e}const rY=_.forwardRef(function(t,n){const{className:s,disabled:i=!1,render:a,value:l,id:f,nativeButton:d=!0,...p}=t,{value:g,getTabPanelIdByValue:y,orientation:b}=mx(),{activateOnFocus:x,highlightedTabIndex:S,onTabActivation:w,setHighlightedTabIndex:T,tabsListElement:C}=nY(),O=br(f),N=_.useMemo(()=>({disabled:i,id:O,value:l}),[i,O,l]),{compositeProps:R,compositeRef:M,index:L}=tk({metadata:N}),j=l===g,A=_.useRef(!1);Le(()=>{if(A.current){A.current=!1;return}if(!(j&&L>-1&&S!==L))return;const K=C;if(K!=null){const U=Bo(Rt(K));if(U&&Ot(K,U))return}i||T(L)},[j,L,S,T,i,C]);const{getButtonProps:P,buttonRef:Z}=el({disabled:i,native:d,focusableWhenDisabled:!0}),B=y(l),z=_.useRef(!1),Q=_.useRef(!1);function Y(K){j||i||w(l,Yt(ii,K.nativeEvent,void 0,{activationDirection:"none"}))}function ee(K){j||(L>-1&&!i&&T(L),!i&&x&&(!z.current||z.current&&Q.current)&&w(l,Yt(ii,K.nativeEvent,void 0,{activationDirection:"none"})))}function D(K){if(j||i)return;z.current=!0;function U(){z.current=!1,Q.current=!1}(!K.button||K.button===0)&&(Q.current=!0,Rt(K.currentTarget).addEventListener("pointerup",U,{once:!0}))}return zt("button",t,{state:{disabled:i,active:j,orientation:b},ref:[n,Z,M],props:[R,{role:"tab","aria-controls":B,"aria-selected":j,id:O,onClick:Y,onFocus:ee,onPointerDown:D,[nk]:j?"":void 0,onKeyDownCapture(){A.current=!0}},p,P]})});let sY=(function(e){return e.index="data-index",e.activationDirection="data-activation-direction",e.orientation="data-orientation",e.hidden="data-hidden",e})({});const oY={...fk,...ba},iY=_.forwardRef(function(t,n){const{className:s,value:i,render:a,keepMounted:l=!1,...f}=t,{value:d,getTabIdByPanelValue:p,orientation:g,tabActivationDirection:y,registerMountedTabPanel:b,unregisterMountedTabPanel:x}=mx(),S=br(),w=_.useMemo(()=>({id:S,value:i}),[S,i]),{ref:T,index:C}=dx({metadata:w}),O=i===d,{mounted:N,transitionStatus:R,setMounted:M}=jp(O),L=!N,j=p(i),A={hidden:L,orientation:g,tabActivationDirection:y,transitionStatus:R},P=_.useRef(null),Z=zt("div",t,{state:A,ref:[n,T,P],props:[{"aria-labelledby":j,hidden:L,id:S,role:"tabpanel",tabIndex:O?0:-1,inert:fx(!O),[sY.index]:C},f],stateAttributesMapping:oY});return xa({open:O,ref:P,onComplete(){O||M(!1)}}),Le(()=>{if(!(L&&!l)&&S!=null)return b(i,S),()=>{x(i,S)}},[L,l,i,S,b,x]),l||N?Z:null}),aY=_.forwardRef(function(t,n){const{activateOnFocus:s=!1,className:i,loopFocus:a=!0,render:l,...f}=t,{getTabElementBySelectedValue:d,onValueChange:p,orientation:g,value:y,setTabMap:b,tabActivationDirection:x}=mx(),[S,w]=_.useState(0),[T,C]=_.useState(null),O=cY(y,g,T,d),N=Ae((j,A)=>{if(j!==y){const P=O(j);A.activationDirection=P,p(j,A)}}),R={orientation:g,tabActivationDirection:x},M={"aria-orientation":g==="vertical"?"vertical":void 0,role:"tablist"},L=_.useMemo(()=>({activateOnFocus:s,highlightedTabIndex:S,onTabActivation:N,setHighlightedTabIndex:w,tabsListElement:T,value:y}),[s,S,N,w,T,y]);return h.jsx(dk.Provider,{value:L,children:h.jsx(rk,{render:l,className:i,state:R,refs:[n,C],props:[M,f],stateAttributesMapping:fk,highlightedIndex:S,enableHomeAndEndKeys:!0,loopFocus:a,orientation:g,onHighlightedIndexChange:w,onMapChange:b,disabledIndices:Ru})})});function qC(e,t){const{left:n,top:s}=e.getBoundingClientRect(),{left:i,top:a}=t.getBoundingClientRect(),l=n-i,f=s-a;return{left:l,top:f}}function cY(e,t,n,s){const[i,a]=_.useState(null);return Le(()=>{if(e==null||n==null){a(null);return}const l=s(e);if(l==null){a(null);return}const{left:f,top:d}=qC(l,n);a(t==="horizontal"?f:d)},[t,s,n,e]),_.useCallback(l=>{if(l===e)return"none";if(l==null)return a(null),"none";if(l!=null&&n!=null){const f=s(l);if(f!=null){const{left:d,top:p}=qC(f,n);if(i==null)return a(t==="horizontal"?d:p),"none";if(t==="horizontal"){if(d<i)return a(d),"left";if(d>i)return a(d),"right"}else{if(p<i)return a(p),"up";if(p>i)return a(p),"down"}}}return"none"},[s,t,i,n,e])}const lY=_.forwardRef(({className:e,...t},n)=>h.jsx(aY,{ref:n,className:ge("flex items-center gap-0.5",e),...t}));lY.displayName="TabsList";const uY=gi("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"}}),fY=_.forwardRef(({className:e,variant:t,...n},s)=>h.jsx(rY,{ref:s,className:ge(uY({variant:t,className:e})),...n}));fY.displayName="TabsTrigger";const dY=_.forwardRef(({className:e,...t},n)=>h.jsx(iY,{ref:n,className:ge("outline-none",e),...t}));dY.displayName="TabsContent";const hY=_.forwardRef(({className:e,...t},n)=>h.jsx("p",{ref:n,className:ge("font-mono text-[11px] text-neutral-300",e),...t}));hY.displayName="Text";const pY=_.forwardRef(({className:e,...t},n)=>h.jsx("p",{ref:n,className:ge("font-mono text-[10px] text-neutral-500",e),...t}));pY.displayName="TextMuted";const mY=_.forwardRef(({className:e,...t},n)=>h.jsx("code",{ref:n,className:ge("font-mono text-[11px] text-white",e),...t}));mY.displayName="TextCode";const gY=_.forwardRef(({className:e,...t},n)=>h.jsx("span",{ref:n,className:ge("font-mono text-[9px] uppercase tracking-wider text-neutral-500",e),...t}));gY.displayName="TextLabel";const yY=_.forwardRef(({className:e,...t},n)=>h.jsx("pre",{ref:n,className:ge("font-mono text-[11px] text-neutral-300 p-3 rounded border border-border bg-panel-alt overflow-x-auto",e),...t}));yY.displayName="CodeBlock";const vY="console:instance-id";function Lt(){const[e,t]=pi(vY,""),n=e.trim();return _.useMemo(()=>({instanceId:n.length>0?n:void 0,rawInstanceId:e,setInstanceId:t,clearInstanceId:()=>t("")}),[n,e,t])}const Jn={stats:e=>["console","stats",e],timeseries:e=>["console","stats","timeseries",e],latency:e=>["console","stats","latency",e],commits:e=>["console","commits",e],commitDetail:(e,t,n)=>["console","commit-detail",e,t,n],timeline:e=>["console","timeline",e],clients:e=>["console","clients",e],eventDetail:(e,t,n)=>["console","event-detail",e,t,n],eventPayload:(e,t,n)=>["console","event-payload",e,t,n],handlers:e=>["console","handlers",e],prunePreview:e=>["console","prune","preview",e],operations:e=>["console","operations",e],apiKeys:e=>["console","api-keys",e],storage:e=>["console","storage",e]};function _i(e,t){return e===0?!1:e??t}function nf(e,t){return t?{...e,instanceId:t}:e}function Sa(e){return encodeURIComponent(String(e))}function Ln(e,t,n){const s=e.endsWith("/")?e.slice(0,-1):e,i=n?.toString();return`${s}${t}${i?`?${i}`:""}`}function rf(e={}){const t=Vt(),{instanceId:n}=Lt(),s=e.instanceId??n,i=nf(e.partitionId?{partitionId:e.partitionId}:{},s);return Wn({queryKey:Jn.stats({partitionId:e.partitionId,instanceId:s}),queryFn:()=>{if(!t)throw new Error("Not connected");return Yu(t.GET("/console/stats",{params:{query:i}}))},enabled:!!t,refetchInterval:_i(e.refetchIntervalMs,5e3)})}function bY(e={},t={}){const n=Vt(),{config:s}=Dt(),{instanceId:i}=Lt(),a=e.instanceId??i;return Wn({queryKey:Jn.timeseries({...e,instanceId:a}),queryFn:async()=>{if(!n||!s)throw new Error("Not connected");const l=new URLSearchParams;e.interval&&l.set("interval",e.interval),e.range&&l.set("range",e.range),e.partitionId&&l.set("partitionId",e.partitionId),a&&l.set("instanceId",a);const f=await fetch(`${s.serverUrl}/console/stats/timeseries?${l}`,{headers:{Authorization:`Bearer ${s.token}`}});if(!f.ok)throw new Error("Failed to fetch timeseries stats");return f.json()},enabled:(t.enabled??!0)&&!!n&&!!s,refetchInterval:_i(t.refetchIntervalMs,3e4)})}function xY(e={},t={}){const n=Vt(),{config:s}=Dt(),{instanceId:i}=Lt(),a=e.instanceId??i;return Wn({queryKey:Jn.latency({...e,instanceId:a}),queryFn:async()=>{if(!n||!s)throw new Error("Not connected");const l=new URLSearchParams;e.range&&l.set("range",e.range),e.partitionId&&l.set("partitionId",e.partitionId),a&&l.set("instanceId",a);const f=await fetch(`${s.serverUrl}/console/stats/latency?${l}`,{headers:{Authorization:`Bearer ${s.token}`}});if(!f.ok)throw new Error("Failed to fetch latency stats");return f.json()},enabled:(t.enabled??!0)&&!!n&&!!s,refetchInterval:_i(t.refetchIntervalMs,3e4)})}function SY(e={},t={}){const n=Vt(),{instanceId:s}=Lt(),i=e.instanceId??s,a=nf({limit:e.limit,offset:e.offset,partitionId:e.partitionId},i);return Wn({queryKey:Jn.commits({...e,instanceId:i}),queryFn:()=>{if(!n)throw new Error("Not connected");return Yu(n.GET("/console/commits",{params:{query:a}}))},enabled:(t.enabled??!0)&&!!n,refetchInterval:_i(t.refetchIntervalMs,1e4)})}function _Y(e,t={}){const n=Vt(),{config:s}=Dt(),{instanceId:i}=Lt(),a=t.instanceId??i;return Wn({queryKey:Jn.commitDetail(e,t.partitionId,a),queryFn:async()=>{if(!n||!s)throw new Error("Not connected");if(e===void 0)throw new Error("Commit sequence is required");const l=new URLSearchParams;t.partitionId&&l.set("partitionId",t.partitionId),a&&l.set("instanceId",a);const f=l.toString(),d=await fetch(`${s.serverUrl}/console/commits/${Sa(e)}${f?`?${f}`:""}`,{headers:{Authorization:`Bearer ${s.token}`}});if(!d.ok)throw new Error("Failed to fetch commit detail");return d.json()},enabled:(t.enabled??!0)&&e!==void 0&&!!n})}function wY(e={},t={}){const n=Vt(),{instanceId:s}=Lt(),i=e.instanceId??s,a=nf({limit:e.limit,offset:e.offset,partitionId:e.partitionId,view:e.view,eventType:e.eventType,actorId:e.actorId,clientId:e.clientId,requestId:e.requestId,traceId:e.traceId,table:e.table,outcome:e.outcome,search:e.search,from:e.from,to:e.to},i);return Wn({queryKey:Jn.timeline({...e,instanceId:i}),queryFn:()=>{if(!n)throw new Error("Not connected");return Yu(n.GET("/console/timeline",{params:{query:a}}))},enabled:(t.enabled??!0)&&!!n,refetchInterval:_i(t.refetchIntervalMs,1e4)})}function hk(e={},t={}){const n=Vt(),{instanceId:s}=Lt(),i=e.instanceId??s,a=nf({limit:e.limit,offset:e.offset,partitionId:e.partitionId},i);return Wn({queryKey:Jn.clients({...e,instanceId:i}),queryFn:()=>{if(!n)throw new Error("Not connected");return Yu(n.GET("/console/clients",{params:{query:a}}))},enabled:(t.enabled??!0)&&!!n,refetchInterval:_i(t.refetchIntervalMs,1e4)})}function EY(e,t={}){const n=Vt(),{config:s}=Dt(),{instanceId:i}=Lt(),a=t.instanceId??i;return Wn({queryKey:Jn.eventDetail(e,t.partitionId,a),queryFn:async()=>{if(!n||!s)throw new Error("Not connected");if(e===void 0)throw new Error("Event id is required");const l=new URLSearchParams;t.partitionId&&l.set("partitionId",t.partitionId),a&&l.set("instanceId",a);const f=l.toString(),d=await fetch(`${s.serverUrl}/console/events/${Sa(e)}${f?`?${f}`:""}`,{headers:{Authorization:`Bearer ${s.token}`}});if(!d.ok)throw new Error("Failed to fetch event detail");return d.json()},enabled:(t.enabled??!0)&&e!==void 0&&!!n})}function TY(e,t={}){const n=Vt(),{config:s}=Dt(),{instanceId:i}=Lt(),a=t.instanceId??i;return Wn({queryKey:Jn.eventPayload(e,t.partitionId,a),queryFn:async()=>{if(!n||!s)throw new Error("Not connected");if(e===void 0)throw new Error("Event id is required");const l=new URLSearchParams;t.partitionId&&l.set("partitionId",t.partitionId),a&&l.set("instanceId",a);const f=l.toString(),d=await fetch(`${s.serverUrl}/console/events/${Sa(e)}/payload${f?`?${f}`:""}`,{headers:{Authorization:`Bearer ${s.token}`}});if(!d.ok)throw new Error("Failed to fetch event payload");return d.json()},enabled:(t.enabled??!0)&&e!==void 0&&!!n})}function CY(e={}){const t=Vt(),{config:n}=Dt(),{instanceId:s}=Lt(),i=e.instanceId??s;return Wn({queryKey:Jn.handlers(i),queryFn:async()=>{if(!t||!n)throw new Error("Not connected");const a=new URLSearchParams;i&&a.set("instanceId",i);const l=await fetch(Ln(n.serverUrl,"/console/handlers",a),{headers:{Authorization:`Bearer ${n.token}`}});if(!l.ok)throw new Error("Failed to fetch handlers");return l.json()},enabled:!!t&&!!n})}function RY(e={}){const t=Vt(),{config:n}=Dt(),{instanceId:s}=Lt(),i=e.instanceId??s;return Wn({queryKey:Jn.prunePreview(i),queryFn:async()=>{if(!t||!n)throw new Error("Not connected");const a=new URLSearchParams;i&&a.set("instanceId",i);const l=await fetch(Ln(n.serverUrl,"/console/prune/preview",a),{method:"POST",headers:{Authorization:`Bearer ${n.token}`}});if(!l.ok)throw new Error("Failed to fetch prune preview");return l.json()},enabled:!!t&&!!n&&(e.enabled??!0)})}function NY(e={},t={}){const n=Vt(),{instanceId:s}=Lt(),i=e.instanceId??s,a=nf({limit:e.limit,offset:e.offset,operationType:e.operationType,partitionId:e.partitionId},i);return Wn({queryKey:Jn.operations({...e,instanceId:i}),queryFn:()=>{if(!n)throw new Error("Not connected");return Yu(n.GET("/console/operations",{params:{query:a}}))},enabled:(t.enabled??!0)&&!!n,refetchInterval:_i(t.refetchIntervalMs,1e4)})}function jY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async({clientId:i,partitionId:a,instanceId:l})=>{if(!e||!t)throw new Error("Not connected");const f=l??n,d=new URLSearchParams;a&&d.set("partitionId",a),f&&d.set("instanceId",f);const p=await fetch(Ln(t.serverUrl,`/console/clients/${Sa(i)}`,d),{method:"DELETE",headers:{Authorization:`Bearer ${t.token}`}});if(!p.ok)throw new Error("Failed to evict client");return p.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","clients"]}),s.invalidateQueries({queryKey:["console","stats"]}),s.invalidateQueries({queryKey:["console","operations"]})}})}function AY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async()=>{if(!e||!t)throw new Error("Not connected");const i=new URLSearchParams;n&&i.set("instanceId",n);const a=await fetch(Ln(t.serverUrl,"/console/prune",i),{method:"POST",headers:{Authorization:`Bearer ${t.token}`}});if(!a.ok)throw new Error("Failed to prune");return a.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","stats"]}),s.invalidateQueries({queryKey:["console","commits"]}),s.invalidateQueries({queryKey:["console","timeline"]}),s.invalidateQueries({queryKey:["console","prune","preview"]}),s.invalidateQueries({queryKey:["console","operations"]})}})}function kY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async()=>{if(!e||!t)throw new Error("Not connected");const i=new URLSearchParams;n&&i.set("instanceId",n);const a=await fetch(Ln(t.serverUrl,"/console/compact",i),{method:"POST",headers:{Authorization:`Bearer ${t.token}`}});if(!a.ok)throw new Error("Failed to compact");return a.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","stats"]}),s.invalidateQueries({queryKey:["console","operations"]})}})}function OY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async i=>{if(!e||!t)throw new Error("Not connected");const a=i.instanceId??n,l=new URLSearchParams;a&&l.set("instanceId",a);const f=await fetch(Ln(t.serverUrl,"/console/notify-data-change",l),{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"Content-Type":"application/json"},body:JSON.stringify({tables:i.tables,partitionId:i.partitionId})});if(!f.ok)throw new Error("Failed to notify data change");return f.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","stats"]}),s.invalidateQueries({queryKey:["console","commits"]}),s.invalidateQueries({queryKey:["console","timeline"]}),s.invalidateQueries({queryKey:["console","operations"]})}})}function MY(e={}){const t=Vt(),{config:n}=Dt(),{instanceId:s}=Lt(),i=e.instanceId??s;return Wn({queryKey:Jn.apiKeys({...e,instanceId:i}),queryFn:async()=>{if(!t||!n)throw new Error("Not connected");const a=new URLSearchParams;e.limit!==void 0&&a.set("limit",String(e.limit)),e.offset!==void 0&&a.set("offset",String(e.offset)),e.type&&a.set("type",e.type),e.status&&a.set("status",e.status),e.expiresWithinDays!==void 0&&a.set("expiresWithinDays",String(e.expiresWithinDays)),i&&a.set("instanceId",i);const l=await fetch(Ln(n.serverUrl,"/console/api-keys",a),{headers:{Authorization:`Bearer ${n.token}`}});if(!l.ok)throw new Error("Failed to fetch API keys");return l.json()},enabled:!!t&&!!n})}function IY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async i=>{if(!e||!t)throw new Error("Not connected");const a=new URLSearchParams;n&&a.set("instanceId",n);const l=await fetch(Ln(t.serverUrl,"/console/api-keys",a),{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"Content-Type":"application/json"},body:JSON.stringify(i)});if(!l.ok)throw new Error("Failed to create API key");return l.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","api-keys"]})}})}function PY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async i=>{if(!e||!t)throw new Error("Not connected");const a=new URLSearchParams;n&&a.set("instanceId",n);const l=await fetch(Ln(t.serverUrl,`/console/api-keys/${Sa(i)}`,a),{method:"DELETE",headers:{Authorization:`Bearer ${t.token}`}});if(!l.ok)throw new Error("Failed to revoke API key");return l.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","api-keys"]})}})}function DY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async i=>{if(!e||!t)throw new Error("Not connected");const a=new URLSearchParams;n&&a.set("instanceId",n);const l=await fetch(Ln(t.serverUrl,"/console/api-keys/bulk-revoke",a),{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"Content-Type":"application/json"},body:JSON.stringify(i)});if(!l.ok)throw new Error("Failed to bulk revoke API keys");return l.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","api-keys"]})}})}function zY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async i=>{if(!e||!t)throw new Error("Not connected");const a=new URLSearchParams;n&&a.set("instanceId",n);const l=await fetch(Ln(t.serverUrl,`/console/api-keys/${Sa(i)}/rotate`,a),{method:"POST",headers:{Authorization:`Bearer ${t.token}`}});if(!l.ok)throw new Error("Failed to rotate API key");return l.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","api-keys"]})}})}function LY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async i=>{if(!e||!t)throw new Error("Not connected");const a=new URLSearchParams;n&&a.set("instanceId",n);const l=await fetch(Ln(t.serverUrl,`/console/api-keys/${Sa(i)}/rotate/stage`,a),{method:"POST",headers:{Authorization:`Bearer ${t.token}`}});if(!l.ok)throw new Error("Failed to stage-rotate API key");return l.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","api-keys"]})}})}function UY(e={}){const{config:t}=Dt();return Wn({queryKey:Jn.storage({prefix:e.prefix,cursor:e.cursor,limit:e.limit}),queryFn:async()=>{if(!t)throw new Error("Not connected");const n=new URLSearchParams;e.prefix&&n.set("prefix",e.prefix),e.cursor&&n.set("cursor",e.cursor),e.limit&&n.set("limit",String(e.limit));const s=await fetch(Ln(t.serverUrl,"/console/storage",n),{method:"GET",headers:{Authorization:`Bearer ${t.token}`}});if(!s.ok)throw new Error("Failed to list blobs");return s.json()},enabled:!!t,refetchInterval:_i(e.refetchIntervalMs,3e4)})}function $Y(){const{config:e}=Dt(),t=_r();return is({mutationFn:async n=>{if(!e)throw new Error("Not connected");const s=encodeURIComponent(n),i=await fetch(Ln(e.serverUrl,`/console/storage/${s}`,new URLSearchParams),{method:"DELETE",headers:{Authorization:`Bearer ${e.token}`}});if(!i.ok)throw new Error("Failed to delete blob");return i.json()},onSuccess:()=>{t.invalidateQueries({queryKey:["console","storage"]})}})}function BY(){const{config:e}=Dt();return async t=>{if(!e)throw new Error("Not connected");const n=encodeURIComponent(t),s=await fetch(Ln(e.serverUrl,`/console/storage/${n}/download`,new URLSearchParams),{method:"GET",headers:{Authorization:`Bearer ${e.token}`}});if(!s.ok)throw new Error("Failed to download blob");const i=await s.blob(),a=URL.createObjectURL(i),l=document.createElement("a");l.href=a,l.download=t.split("/").pop()||t,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(a)}}const FY="console:partition-id";function sf(){const[e,t]=pi(FY,""),n=e.trim();return _.useMemo(()=>({partitionId:n.length>0?n:void 0,rawPartitionId:e,setPartitionId:t,clearPartitionId:()=>t("")}),[n,e,t])}const VC={refreshInterval:5,timeFormat:"relative",showSparklines:!0,pageSize:20};function of(){const[e,t]=pi("console:preferences",VC);return{preferences:e,setPreferences:t,updatePreference:(i,a)=>{t(l=>({...l,[i]:a}))},resetPreferences:()=>{t(VC)}}}const HY=[{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"}],qY=[{value:10,label:"10"},{value:20,label:"20"},{value:50,label:"50"},{value:100,label:"100"}],gx="syncular-console-root";function VY(e){e.classList.add(gx)}const KY=[{suffix:"",label:"Command"},{suffix:"/stream",label:"Stream"},{suffix:"/fleet",label:"Fleet"},{suffix:"/ops",label:"Ops"},{suffix:"/storage",label:"Storage"},{suffix:"/config",label:"Config"}];function GY(e){const t=e?.trim()??"";return!t||t==="/"?"":(t.startsWith("/")?t:`/${t}`).replace(/\/+$/g,"")}function $y(e,t){return e?t?`${e}${t}`:e:t||"/"}function ZY({basePath:e,appHref:t,modeBadge:n}){const{connect:s,config:i,isConnected:a,isConnecting:l}=Dt(),{preferences:f}=of(),{instanceId:d,rawInstanceId:p,setInstanceId:g,clearInstanceId:y}=Lt(),{partitionId:b,rawPartitionId:x,setPartitionId:S,clearPartitionId:w}=sf(),T=vr({select:P=>P.location.pathname}),{data:C}=rf({refetchIntervalMs:f.refreshInterval*1e3,partitionId:b,instanceId:d}),O=GY(e),N=_.useMemo(()=>KY.map(P=>({...P,id:$y(O,P.suffix)})),[O]),R=$y(O,""),M=$y(O,"/config"),L=l?"connecting":a?"connected":i?"disconnected":"not-configured",j=N.find(P=>P.suffix===""?T===R||T===`${R}/`:T.startsWith(P.id))?.id??R,A=C?[{label:"HEAD",value:`#${C.maxCommitSeq}`},{label:"COMMITS",value:`${C.commitCount}`},{label:"CHANGES",value:`${C.changeCount}`},{label:"CLIENTS",value:`${C.activeClientCount}/${C.clientCount}`}]:[];return h.jsxs("div",{className:`${gx} h-screen bg-background text-foreground flex flex-col`,children:[h.jsx(OZ,{brand:h.jsx(xc,{to:R,children:h.jsx(kZ,{label:"console"})}),center:h.jsx(EZ,{items:N,activeId:j,renderItem:(P,{active:Z})=>h.jsx(xc,{to:P.id,children:h.jsx(sk,{active:Z,children:P.label})},P.id)}),right:h.jsxs("div",{className:"flex items-center gap-2",children:[n?h.jsx(mn,{variant:"flow",className:"hidden md:inline-flex px-2 py-1 text-[10px]",children:n}):null,h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("span",{className:"font-mono text-[9px] text-neutral-500 uppercase tracking-wide",children:"Instance"}),h.jsx(Gn,{variant:"mono",value:p,onChange:P=>g(P.target.value),onBlur:P=>g(P.target.value.trim()),placeholder:"all",className:"h-7 w-[110px] px-2 py-1"}),d?h.jsx(Oe,{variant:"ghost",size:"sm",className:"h-7 px-2 text-[10px]",onClick:y,children:"All"}):null]}),h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("span",{className:"font-mono text-[9px] text-neutral-500 uppercase tracking-wide",children:"Partition"}),h.jsx(Gn,{variant:"mono",value:x,onChange:P=>S(P.target.value),onBlur:P=>S(P.target.value.trim()),placeholder:"all",className:"h-7 w-[110px] px-2 py-1"}),b?h.jsx(Oe,{variant:"ghost",size:"sm",className:"h-7 px-2 text-[10px]",onClick:w,children:"All"}):null]}),h.jsx(R8,{state:L}),h.jsx(xc,{to:M,children:h.jsx(Oe,{variant:T===M?"secondary":"ghost",size:"icon",children:h.jsx(q8,{className:"h-3 w-3"})})}),t?h.jsxs("a",{href:t,className:wZ,children:[h.jsx(F8,{className:"h-3 w-3"}),"Go to app"]}):null]})}),h.jsx("main",{className:"flex-1 overflow-auto pb-[32px]",children:h.jsx("div",{className:"min-h-full",children:a||T===M?h.jsx("div",{style:{animation:"pageIn 0.3s ease-out"},children:h.jsx(YN,{})},T):h.jsx(YY,{configPath:M,hasSavedConfig:!!i,isConnecting:l,onConnect:()=>{s()}})})}),a&&h.jsx($j,{isLive:a,metrics:A,uptime:"--"})]})}function YY({configPath:e,hasSavedConfig:t,isConnecting:n,onConnect:s}){return h.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[h.jsx("p",{className:"mb-4 text-foreground-muted",children:"Not connected to a @syncular server"}),h.jsxs("div",{className:"flex items-center gap-2",children:[t&&h.jsx(Oe,{variant:"default",onClick:s,disabled:n,children:n?"Connecting...":"Connect"}),h.jsx(xc,{to:e,children:h.jsx(Oe,{variant:"link",children:"Configure connection"})})]})]})}const lo=RH({component:ZY});function XY(){return typeof window>"u"?!1:new URLSearchParams(window.location.search).get("swServer")==="1"}function QY(e={}){const{maxEvents:t=100,enabled:n=!0,staleAfterMs:s=65e3,replayLimit:i=100,partitionId:a,instanceId:l}=e,{config:f,isConnected:d}=Dt(),{instanceId:p}=Lt(),g=l??p,[y,b]=_.useState([]),[x,S]=_.useState(!1),[w,T]=_.useState("disconnected"),[C,O]=_.useState(null),N=_.useRef(null),R=_.useRef(null),M=_.useRef(null),L=_.useRef(0),j=_.useRef(0),A=_.useRef(null),P=_.useRef(null),Z=_.useCallback(()=>{b([]),A.current=null,P.current=null},[]);return _.useEffect(()=>{if(!n||!d||!f?.serverUrl||!f?.token)return;let B=!1;const z=Number.isFinite(i)?Math.max(1,Math.min(500,Math.floor(i))):100;if(XY()||typeof WebSocket>"u"){T("connecting"),S(!1);let K=null,U=!1;const I=async()=>{if(!(B||U)){U=!0;try{const H=new URL(f.serverUrl,window.location.origin),W=H.pathname.endsWith("/")?H.pathname.slice(0,-1):H.pathname;H.pathname=`${W}/console/events`,H.search="",H.searchParams.set("limit",String(z)),H.searchParams.set("offset","0"),a&&H.searchParams.set("partitionId",a);const X=await fetch(H.toString(),{headers:{Authorization:`Bearer ${f.token}`}});if(!X.ok)throw new Error(`Live event polling failed (${X.status})`);const oe=await X.json(),pe=(Array.isArray(oe.items)?oe.items:[]).filter(Me=>g?Me.instanceId===g:!0).sort((Me,_e)=>Me.eventId-_e.eventId),xe=P.current??-1,de=pe.filter(Me=>Me.eventId>xe);if(de.length>0){const Me=de.map(ne=>({type:ne.eventType,timestamp:ne.createdAt,data:ne})).reverse();b(ne=>[...Me,...ne].slice(0,t));const _e=de[de.length-1];P.current=_e.eventId,A.current=_e.createdAt}else if(pe.length>0){const Me=pe[pe.length-1];P.current=Math.max(P.current??-1,Me.eventId),A.current=Me.createdAt}O(null),S(!0),T("connected")}catch(H){B||(S(!1),T("disconnected"),O(H instanceof Error?H:new Error("Live event polling failed")))}finally{U=!1}}};return I(),K=setInterval(()=>{I()},2e3),()=>{B=!0,K&&clearInterval(K),S(!1),T("disconnected")}}const Y=()=>{R.current&&(clearTimeout(R.current),R.current=null)},ee=()=>{M.current&&(clearInterval(M.current),M.current=null)},D=()=>{if(B||R.current)return;L.current+=1;const K=Math.min(3e4,1e3*2**Math.max(0,L.current-1)),U=Math.floor(K*.2*Math.random()),I=K+U;R.current=setTimeout(()=>{R.current=null,B||q()},I)},V=()=>{j.current=Date.now(),S(!0),T("connected")},q=()=>{if(B)return;T("connecting"),Y();const K=(()=>{const I=new URL(f.serverUrl,window.location.origin);I.protocol=I.protocol==="https:"?"wss:":"ws:";const H=I.pathname.endsWith("/")?I.pathname.slice(0,-1):I.pathname;return I.pathname=`${H}/console/events/live`,I.search="",I.searchParams.set("token",f.token),A.current&&I.searchParams.set("since",A.current),I.searchParams.set("replayLimit",String(z)),a&&I.searchParams.set("partitionId",a),g&&I.searchParams.set("instanceId",g),I.toString()})(),U=new WebSocket(K);N.current=U,U.onopen=()=>{if(B){U.close();return}L.current=0,V(),O(null),ee(),M.current=setInterval(()=>{const I=N.current;if(!I||I.readyState!==WebSocket.OPEN)return;const H=j.current;!H||Date.now()-H<=s||(S(!1),T("stale"),I.close())},1e3)},U.onclose=()=>{B||(S(!1),T("disconnected"),ee(),D())},U.onerror=()=>{B||O(new Error("WebSocket connection failed"))},U.onmessage=I=>{try{const H=JSON.parse(I.data),W=H.type;if(V(),W==="connected"||W==="heartbeat")return;const X={type:W,timestamp:H.timestamp||new Date().toISOString(),data:H};if(a&&X.data.partitionId!==a||g&&X.data.instanceId!==g)return;const oe=Date.parse(A.current??""),se=Date.parse(X.timestamp);Number.isFinite(se)&&(!Number.isFinite(oe)||se>oe)&&(A.current=X.timestamp),b(pe=>[X,...pe].slice(0,t))}catch{}}};return q(),()=>{B=!0,Y(),ee(),N.current&&(N.current.close(),N.current=null),S(!1),T("disconnected")}},[n,d,f?.serverUrl,f?.token,t,a,g,i,s]),{events:y,isConnected:x,connectionState:w,error:C,clearEvents:Z}}function WY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async()=>{if(!e||!t)throw new Error("Not connected");const i=new URLSearchParams;n&&i.set("instanceId",n);const a=i.toString(),l=await fetch(`${t.serverUrl}/console/events${a?`?${a}`:""}`,{method:"DELETE",headers:{Authorization:`Bearer ${t.token}`}});if(!l.ok)throw new Error("Failed to clear events");return l.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","events"]})}})}const JY=_.createContext(null);function pk(){const[e,t]=pi("console:time-range","24h");return{range:e,setRange:t}}const eX=[{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 tX(e){const t=e.toLowerCase();for(const n of eX)if(t.includes(n.hint))return n.type;return"client"}function nX(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 rX(e,t){return typeof e.lagCommitCount=="number"?Math.max(0,e.lagCommitCount):t?Math.max(0,t.maxCommitSeq-e.cursor):0}function sX(e,t){return e.activityState==="stale"?"offline":t>0?"syncing":"online"}function oX(e,t){return e.length<=16?e:`${e.slice(0,12)}-${t+1}`}function iX(e,t,n={}){const s=n.maxNodes??10;return e.slice(0,s).map((i,a)=>{const l=rX(i,t),f=sX(i,l);return{id:oX(i.clientId,a),type:tX(i.clientId),status:f,cursor:Math.max(0,i.cursor),actor:i.actorId,mode:i.connectionMode,dialect:nX(i.clientId),scopes:Object.keys(i.effectiveScopes||{}),lastSeen:i.updatedAt}})}const aX={enabled:!1,thresholds:{p90Latency:500,errorRate:5,clientLag:100}};function KC(e,t="relative"){if(t==="absolute")return new Date(e).toLocaleString();const n=new Date(e),i=new Date().getTime()-n.getTime(),a=Math.floor(i/1e3);return a<60?`${a}s ago`:a<3600?`${Math.floor(a/60)}m ago`:a<86400?`${Math.floor(a/3600)}h ago`:`${Math.floor(a/86400)}d ago`}function cX(e){const t=e.length>1&&e.endsWith("/")?e.slice(0,-1):e;return t==="/console"||t.startsWith("/console/")?"/console/stream":"/stream"}function lX(){const e=pp(),t=_.useMemo(()=>typeof window>"u"?"/stream":cX(window.location.pathname),[]),n=pk(),{range:s}=n,{preferences:i}=of(),{partitionId:a}=sf(),l=i.refreshInterval*1e3,[f]=pi("console:alert-config",aX),[d,p]=_.useState("1h"),{data:g}=rf({refetchIntervalMs:l,partitionId:a}),{data:y}=bY({range:s,partitionId:a},{refetchIntervalMs:l}),{data:b}=xY({range:s,partitionId:a},{refetchIntervalMs:l}),{data:x}=SY({limit:5,partitionId:a},{refetchIntervalMs:l}),{data:S}=hk({limit:12,offset:0,partitionId:a},{refetchIntervalMs:l}),{events:w,isConnected:T}=QY({maxEvents:8,partitionId:a}),C=_.useMemo(()=>{const z=y?.buckets??[];let Q=0,Y=0;for(const D of z)Q+=D.pushCount+D.pullCount,Y+=D.errorCount;const ee=Q>0?Y/Q*100:0;return{totalEvents:Q,errorRate:ee}},[y?.buckets]),O=_.useMemo(()=>S?.items?iX(S.items,g,{maxNodes:12}):[],[S?.items,g]),N=O.filter(z=>z.status!=="offline").length,R=O.filter(z=>z.status==="offline").length,M=_.useMemo(()=>g?[{label:"Ops (Range)",value:C.totalEvents,color:"flow"},{label:"P50 Latency",value:b?.push?.p50??0,unit:"ms",color:"healthy"},{label:"Error Rate",value:`${C.errorRate.toFixed(1)}%`,color:C.errorRate>0?"offline":"muted"},{label:"Active Clients",value:g.activeClientCount,color:"syncing"},{label:"Pending",value:g.maxActiveClientCursor!==null&&g.maxCommitSeq>0?g.maxCommitSeq-(g.minActiveClientCursor??0):0,color:"relay"}]:[],[g,b,C.errorRate,C.totalEvents]),L=_.useMemo(()=>w.map(z=>({type:z.type.toUpperCase(),actor:z.data?.actorId??"",table:(z.data?.tables??[])[0]??"",time:KC(z.timestamp,i.timeFormat)})),[w,i.timeFormat]),j=_.useMemo(()=>{const z=y?.buckets;if(!z?.length)return[];const Q=Math.max(...z.map(Y=>Math.max(Y.pushCount,Y.pullCount)),1);return z.map(Y=>({pushPercent:Q>0?Y.pushCount/Q*100:0,pullPercent:Q>0?Y.pullCount/Q*100:0}))},[y?.buckets]),A=_.useMemo(()=>{if(!b)return[];const z=Math.max(b.push.p50,b.push.p90,b.push.p99,b.pull.p50,b.pull.p90,b.pull.p99,1);return[{label:"P50",pushMs:b.push.p50,pullMs:b.pull.p50,pushBarPercent:b.push.p50/z*100,pullBarPercent:b.pull.p50/z*100},{label:"P90",pushMs:b.push.p90,pullMs:b.pull.p90,pushBarPercent:b.push.p90/z*100,pullBarPercent:b.pull.p90/z*100},{label:"P99",pushMs:b.push.p99,pullMs:b.pull.p99,pushBarPercent:b.push.p99/z*100,pullBarPercent:b.pull.p99/z*100}]},[b]),P=_.useMemo(()=>x?.items?x.items.map(z=>({seq:z.commitSeq,actor:z.actorId,changes:z.changeCount,tables:(z.affectedTables??[]).join(", "),time:KC(z.createdAt,i.timeFormat)})):[],[x?.items,i.timeFormat]),Z=_.useMemo(()=>Math.max(0,100-C.errorRate),[C.errorRate]),B=_.useMemo(()=>{if(!f.enabled||!g)return[];const z=[];return b?.push?.p90&&b.push.p90>f.thresholds.p90Latency&&z.push(`P90 push latency (${b.push.p90}ms) exceeds threshold (${f.thresholds.p90Latency}ms)`),g.minActiveClientCursor!==null&&g.maxCommitSeq-g.minActiveClientCursor>f.thresholds.clientLag&&z.push(`Client lag (${g.maxCommitSeq-g.minActiveClientCursor}) exceeds threshold (${f.thresholds.clientLag})`),C.errorRate>f.thresholds.errorRate&&z.push(`Error rate (${C.errorRate.toFixed(1)}%) exceeds threshold (${f.thresholds.errorRate}%)`),z},[f,g,b,C.errorRate]);return g?h.jsx(JY.Provider,{value:n,children:h.jsxs("div",{className:"flex flex-col",children:[B.length>0&&h.jsx("div",{className:"px-6 pb-4",children:h.jsxs(In,{variant:"destructive",children:[h.jsx(tf,{children:"Threshold Exceeded"}),h.jsx(Pn,{children:B.map((z,Q)=>h.jsx("span",{className:"block",children:z},Q))})]})}),h.jsx(LA,{clients:O,totalNodes:O.length+2,onlineCount:N,offlineCount:R,relayClientIds:[]}),h.jsx(Zj,{items:M}),h.jsxs("div",{className:"flex",children:[h.jsxs("div",{className:"flex-1 min-w-0 flex flex-col",children:[h.jsx("div",{className:"border-b border-border border-r border-border",children:h.jsx(xj,{bars:j,activeRange:d,onRangeChange:p})}),h.jsx("div",{className:"border-b border-border border-r border-border",children:h.jsx(Yj,{buckets:A,successRate:Z})}),h.jsx("div",{className:"border-r border-border",children:h.jsx(Bj,{commits:P,onViewAll:()=>e({href:t})})})]}),h.jsx(Xj,{entries:L,isConnected:T,maxVisible:20,maxHeight:"calc(100vh - 200px)"})]})]})}):h.jsx("div",{className:"flex items-center justify-center py-24",children:h.jsx(Pt,{size:"lg"})})}function uX(){return h.jsx(lX,{})}function fX({children:e}){return h.jsxs("div",{className:"space-y-4 px-5 py-5",children:[h.jsx(dX,{}),h.jsx(yX,{}),h.jsx(vX,{}),e]})}function dX(){const{clearError:e,config:t,connect:n,disconnect:s,error:i,isConnected:a,isConnecting:l}=Dt(),[f,d]=_.useState(t?.serverUrl??"/api"),[p,g]=_.useState(t?.token??""),[y,b]=_.useState(null),[x,S]=_.useState(!1),[w,T]=_.useState(null),[C,O]=pi("console:disconnect-clear-saved-config",!1);_.useEffect(()=>{const j=new URLSearchParams(window.location.search),A=j.get("token"),P=j.get("server");A&&(g(A),window.history.replaceState({},"",window.location.pathname)),P&&d(P)},[]),_.useEffect(()=>{t?.serverUrl&&d(t.serverUrl),t?.token&&g(t.token)},[t?.serverUrl,t?.token]),_.useEffect(()=>{T(null)},[]);const N=async()=>{e(),b(null);const j=await n({serverUrl:f.trim(),token:p.trim()},{persistOverride:!0});T(j?"Connected successfully and configuration saved.":"Failed to connect with the provided settings.")},R=()=>{s({clearSavedConfig:C}),C&&(d("/api"),g("")),T(C?"Disconnected and saved credentials cleared.":"Disconnected."),b(null)},M=async()=>{S(!0),b(null),T(null);const j=performance.now();try{const A=f.trim(),P=p.trim();if(!A||!P)throw new Error("Missing server URL or token");if(!(await fetch(`${A}/console/stats`,{headers:{Authorization:`Bearer ${P}`}})).ok)throw new Error("Failed to connect");b(Math.round(performance.now()-j))}catch{b(-1)}finally{S(!1)}},L=i??w??(y!==null?y<0?"Connection failed":`Connection successful (${y}ms latency)`:void 0);return h.jsx(Hj,{isConnected:a,isConnecting:l,isTestingConnection:x,serverUrl:f,onServerUrlChange:d,consoleToken:p,onConsoleTokenChange:g,onSaveAndConnect:N,onDisconnect:R,onTestConnection:M,statusMessage:L,children:h.jsx("div",{className:"px-5 pb-5 -mt-2",children:h.jsxs("div",{className:"flex items-center justify-between rounded-md border border-border px-3 py-2",children:[h.jsxs("div",{children:[h.jsx("p",{className:"font-mono text-[10px] text-neutral-400",children:"Clear saved credentials on disconnect"}),h.jsx("p",{className:"font-mono text-[9px] text-neutral-500",children:"Removes stored server URL and token from this browser."})]}),h.jsx(wp,{checked:C,onCheckedChange:O})]})})})}const hX=1440*60*1e3;function GC(e){const t=e.trim();if(!t)return null;const n=Number.parseInt(t,10);return!Number.isInteger(n)||n<=0?null:n}function By(e){if(!e)return"Never";const t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():"Invalid date"}function pX(e){return e.length===0?"all scopes":e.length<=2?e.join(", "):`${e.slice(0,2).join(", ")} +${e.length-2}`}function mX(e,t){if(e.revokedAt)return"revoked";if(!e.expiresAt)return"active";const n=Date.parse(e.expiresAt);if(!Number.isFinite(n))return"active";const s=Date.now();return n<=s?"expired":n<=s+t*hX?"expiring":"active"}function gX(e){return e==="revoked"?"destructive":e==="expired"?"offline":e==="expiring"?"syncing":"healthy"}function yX(){const[e,t]=_.useState("all"),[n,s]=_.useState("all"),[i,a]=_.useState("14"),[l,f]=_.useState(!1),[d,p]=_.useState(!1),[g,y]=_.useState(""),[b,x]=_.useState("relay"),[S,w]=_.useState(""),[T,C]=_.useState(""),[O,N]=_.useState(""),[R,M]=_.useState(null),[L,j]=_.useState([]),[A,P]=_.useState(null),[Z,B]=_.useState(null),[z,Q]=_.useState(null),[Y,ee]=_.useState(null),[D,V]=_.useState(null),[q,K]=_.useState(null),[U,I]=_.useState(null),H=_.useMemo(()=>GC(i),[i]),W=H??14,X=_.useMemo(()=>GC(O),[O]),oe=O.trim().length>0,se=!oe||X!==null,pe=_.useMemo(()=>({type:e==="all"?void 0:e,status:n==="all"?void 0:n,expiresWithinDays:n==="expiring"?W:void 0}),[e,n,W]),{data:xe,isLoading:de,error:Me}=MY(pe),_e=IY(),ne=DY(),he=PY(),ae=zY(),we=LY();_.useEffect(()=>{const me=new Set((xe?.items??[]).map(Te=>Te.keyId));j(Te=>Te.filter(qe=>me.has(qe)))},[xe?.items]);const ve=async()=>{try{const me=T.split(",").map(qe=>qe.trim()).filter(qe=>qe.length>0),Te=await _e.mutateAsync({name:g,keyType:b,actorId:S||void 0,scopeKeys:me.length>0?me:void 0,expiresInDays:oe?X??void 0:void 0});M(Te.secretKey),y(""),w(""),C(""),N("")}catch{}},Se=me=>{navigator.clipboard.writeText(me),B(me),setTimeout(()=>B(null),2e3)},ye=async()=>{if(z)try{await he.mutateAsync(z)}finally{Q(null)}},Ue=async()=>{if(L.length!==0)try{const me=await ne.mutateAsync({keyIds:L});P(me),j([])}catch{}},Ie=async()=>{if(Y)try{const me=await we.mutateAsync(Y.keyId);V({oldKeyId:Y.keyId,oldKeyName:Y.name,secretKey:me.secretKey})}catch{}},Ee=async()=>{if(D)try{await he.mutateAsync(D.oldKeyId)}finally{V(null),ee(null)}},Ve=async()=>{if(q)try{const me=await ae.mutateAsync(q);I(me.secretKey)}finally{K(null)}};if(de)return h.jsx("div",{className:"flex h-[200px] items-center justify-center",children:h.jsx(Pt,{size:"lg"})});if(Me)return h.jsx("div",{className:"flex h-[200px] items-center justify-center",children:h.jsxs("p",{className:"text-danger",children:["Failed to load API keys: ",Me.message]})});const Xe=(xe?.items??[]).filter(me=>me.revokedAt===null).map(me=>me.keyId),Be=Xe.length>0&&Xe.every(me=>L.includes(me)),We=L.length>0,He=(xe?.items??[]).filter(me=>L.includes(me.keyId)).map(me=>me.name);return h.jsxs(h.Fragment,{children:[h.jsxs(Wb,{title:"API Keys",description:"Issue, rotate, revoke, and audit key lifecycle state.",actions:h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs(Oe,{size:"sm",variant:"destructive",onClick:()=>p(!0),disabled:L.length===0,children:["Revoke Selected (",L.length,")"]}),h.jsx(Oe,{size:"sm",onClick:()=>f(!0),children:"Create Key"})]}),children:[h.jsxs("div",{className:"mb-4 grid gap-3 lg:grid-cols-3",children:[h.jsxs(ms,{children:[h.jsx(ts,{children:"Type filter"}),h.jsxs(dh,{value:[e],multiple:!1,onValueChange:me=>{const Te=me.find(qe=>typeof qe=="string");(Te==="all"||Te==="relay"||Te==="proxy"||Te==="admin")&&t(Te)},children:[h.jsx(Dr,{value:"all",children:"all"}),h.jsx(Dr,{value:"relay",children:"relay"}),h.jsx(Dr,{value:"proxy",children:"proxy"}),h.jsx(Dr,{value:"admin",children:"admin"})]})]}),h.jsxs(ms,{children:[h.jsx(ts,{children:"Status filter"}),h.jsxs(dh,{value:[n],multiple:!1,onValueChange:me=>{const Te=me.find(qe=>typeof qe=="string");(Te==="all"||Te==="active"||Te==="revoked"||Te==="expiring")&&s(Te)},children:[h.jsx(Dr,{value:"all",children:"all"}),h.jsx(Dr,{value:"active",children:"active"}),h.jsx(Dr,{value:"revoked",children:"revoked"}),h.jsx(Dr,{value:"expiring",children:"expiring"})]})]}),h.jsxs(ms,{children:[h.jsx(ts,{htmlFor:"api-key-expiring-window",children:"Expiring window (days)"}),h.jsx(mc,{children:"Used when status filter is set to expiring."}),h.jsx(Gn,{id:"api-key-expiring-window",placeholder:"14",value:i,inputMode:"numeric",onChange:me=>a(me.target.value)}),H===null&&i.trim().length>0?h.jsx("p",{className:"font-mono text-[10px] text-offline",children:"Enter a positive whole number."}):null]})]}),xe?.items.length===0?h.jsx(Xb,{message:"No API keys match the current filters."}):h.jsxs(nl,{children:[h.jsx(rl,{children:h.jsxs(os,{children:[h.jsx(ht,{className:"w-[28px]",children:h.jsx($v,{checked:Be,indeterminate:!Be&&We&&Xe.length>0,onCheckedChange:me=>{j(me?Xe:[])},"aria-label":"Select all active keys"})}),h.jsx(ht,{className:"w-[100px]",children:"NAME"}),h.jsx(ht,{className:"w-[55px]",children:"TYPE"}),h.jsx(ht,{className:"w-[90px]",children:"KEY PREFIX"}),h.jsx(ht,{className:"w-[80px]",children:"ACTOR"}),h.jsx(ht,{className:"w-[100px]",children:"SCOPES"}),h.jsx(ht,{className:"w-[120px]",children:"CREATED"}),h.jsx(ht,{className:"w-[120px]",children:"LAST USED"}),h.jsx(ht,{className:"w-[120px]",children:"EXPIRES"}),h.jsx(ht,{className:"flex-1",children:"STATUS"})]})}),h.jsx(sl,{children:(xe?.items??[]).map(me=>{const Te=mX(me,W);return h.jsxs(os,{className:"group relative",children:[h.jsx(pt,{className:"w-[28px]",children:h.jsx($v,{checked:L.includes(me.keyId),onCheckedChange:qe=>{j(mt=>qe?[...new Set([...mt,me.keyId])]:mt.filter(lt=>lt!==me.keyId))},"aria-label":`Select ${me.name}`,disabled:me.revokedAt!==null})}),h.jsx(pt,{className:"w-[100px] font-medium",children:me.name}),h.jsx(pt,{className:"w-[55px]",children:h.jsx(mn,{variant:me.keyType==="admin"?"flow":me.keyType==="proxy"?"ghost":"relay",children:me.keyType})}),h.jsx(pt,{className:"w-[90px]",children:h.jsxs("code",{className:"font-mono text-[11px]",children:[me.keyPrefix,"..."]})}),h.jsx(pt,{className:"w-[80px] text-neutral-500",children:me.actorId??"-"}),h.jsx(pt,{className:"w-[100px] text-neutral-500",children:h.jsx("code",{className:"font-mono text-[10px]",children:pX(me.scopeKeys)})}),h.jsx(pt,{className:"w-[120px] text-neutral-500",children:By(me.createdAt)}),h.jsx(pt,{className:"w-[120px] text-neutral-500",children:By(me.lastUsedAt)}),h.jsx(pt,{className:"w-[120px] text-neutral-500",children:By(me.expiresAt)}),h.jsx(pt,{className:"flex-1",children:h.jsx(mn,{variant:gX(Te),children:Te})}),me.revokedAt===null&&h.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[h.jsx("button",{type:"button",onClick:()=>ee(me),className:"px-1.5 py-0.5 rounded text-[9px] font-mono text-neutral-600 hover:text-white hover:bg-white/[0.05] cursor-pointer transition-colors",children:"stage"}),h.jsx("button",{type:"button",onClick:()=>K(me.keyId),className:"px-1.5 py-0.5 rounded text-[9px] font-mono text-neutral-600 hover:text-white hover:bg-white/[0.05] cursor-pointer transition-colors",children:"rotate"}),h.jsx("button",{type:"button",onClick:()=>Q(me.keyId),className:"px-1.5 py-0.5 rounded text-[9px] font-mono text-neutral-600 hover:text-offline hover:bg-offline/10 cursor-pointer transition-colors",children:"revoke"})]})]},me.keyId)})})]})]}),h.jsx($r,{open:l,onOpenChange:f,children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Create API Key"})}),R?h.jsx(ZC,{copiedKeyId:Z,onClose:()=>{M(null),f(!1)},onCopy:Se,secretKey:R,warning:"Copy this key now. You will not be able to view it again."}):h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[h.jsxs(ms,{children:[h.jsx(ts,{htmlFor:"api-key-name",children:"Name"}),h.jsx(Gn,{id:"api-key-name",placeholder:"Backend Relay Key",value:g,onChange:me=>y(me.target.value)})]}),h.jsxs(ms,{children:[h.jsx(ts,{children:"Key type"}),h.jsxs(dh,{value:[b],multiple:!1,onValueChange:me=>{const Te=me.find(qe=>typeof qe=="string");(Te==="relay"||Te==="proxy"||Te==="admin")&&x(Te)},children:[h.jsx(Dr,{value:"relay",children:"relay"}),h.jsx(Dr,{value:"proxy",children:"proxy"}),h.jsx(Dr,{value:"admin",children:"admin"})]})]}),h.jsxs(ms,{children:[h.jsx(ts,{htmlFor:"api-key-actor-id",children:"Actor ID (optional)"}),h.jsx(mc,{children:"Pin this key to a fixed actor ID"}),h.jsx(Gn,{id:"api-key-actor-id",placeholder:"actor-123",value:S,onChange:me=>w(me.target.value)})]}),h.jsxs(ms,{children:[h.jsx(ts,{htmlFor:"api-key-scope-keys",children:"Scope keys (optional)"}),h.jsx(mc,{children:"Comma-separated list of allowed scope keys"}),h.jsx(Gn,{id:"api-key-scope-keys",placeholder:"scope-a, scope-b",value:T,onChange:me=>C(me.target.value)})]}),h.jsxs(ms,{children:[h.jsx(ts,{htmlFor:"api-key-expires-days",children:"Expires in days (optional)"}),h.jsx(mc,{children:"Leave empty to keep the key non-expiring."}),h.jsx(Gn,{id:"api-key-expires-days",placeholder:"30",value:O,inputMode:"numeric",onChange:me=>N(me.target.value)}),se?null:h.jsx("p",{className:"font-mono text-[10px] text-offline",children:"Enter a positive whole number."})]}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>f(!1),children:"Cancel"}),h.jsx(Oe,{variant:"primary",onClick:ve,disabled:_e.isPending||!g||!se,children:_e.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Creating..."]}):"Create"})]})]})]})}),h.jsx($r,{open:d,onOpenChange:me=>{p(me),me||P(null)},children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Bulk Revoke API Keys"})}),A?h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-3",children:[h.jsx(In,{variant:"destructive",children:h.jsxs(Pn,{children:["Requested ",A.requestedCount," keys. Revoked"," ",A.revokedCount,", already revoked"," ",A.alreadyRevokedCount,", not found"," ",A.notFoundCount,"."]})}),h.jsx(Nn,{children:h.jsx(Oe,{variant:"primary",onClick:()=>{p(!1),P(null)},children:"Done"})})]}):h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-3",children:[h.jsx(In,{variant:"destructive",children:h.jsx(Pn,{children:"This revokes selected keys immediately and cannot be undone."})}),h.jsxs("p",{className:"font-mono text-[10px] text-neutral-500",children:["Selected keys: ",He.slice(0,5).join(", "),He.length>5?` +${He.length-5} more`:""]})]}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>p(!1),children:"Cancel"}),h.jsx(Oe,{variant:"destructive",onClick:Ue,disabled:ne.isPending||L.length===0,children:ne.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Revoking..."]}):"Revoke Selected"})]})]})]})}),h.jsx($r,{open:Y!==null||D!==null,onOpenChange:()=>{ee(null),V(null)},children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Stage Rotate API Key"})}),D?h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[h.jsx(In,{variant:"default",children:h.jsxs(Pn,{children:["Replacement key created for ",D.oldKeyName,". The old key is still active until you revoke it."]})}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("code",{className:"flex-1 rounded-md border border-border bg-surface p-3 font-mono text-[11px] text-white break-all",children:D.secretKey}),h.jsx(Oe,{variant:"default",size:"sm",onClick:()=>Se(D.secretKey),children:Z===D.secretKey?"Copied":"Copy"})]}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>{V(null),ee(null)},children:"Keep Old Key Active"}),h.jsx(Oe,{variant:"destructive",onClick:Ee,disabled:he.isPending,children:he.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Revoking Old Key..."]}):"Finalize and Revoke Old Key"})]})]}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"px-5 py-4",children:h.jsx("p",{className:"font-mono text-[10px] text-neutral-500",children:"Staged rotation creates a replacement key now and keeps the current key active until you explicitly revoke it."})}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>ee(null),children:"Cancel"}),h.jsx(Oe,{variant:"primary",onClick:Ie,disabled:we.isPending||!Y,children:we.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Staging..."]}):"Create Replacement Key"})]})]})]})}),h.jsx($r,{open:z!==null,onOpenChange:()=>Q(null),children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Revoke API Key"})}),h.jsx("div",{className:"px-5 py-4",children:h.jsx(In,{variant:"destructive",children:h.jsx(Pn,{children:"Revoking a key immediately invalidates it for all requests."})})}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>Q(null),children:"Cancel"}),h.jsx(Oe,{variant:"destructive",onClick:ye,disabled:he.isPending,children:he.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Revoking..."]}):"Revoke"})]})]})}),h.jsx($r,{open:q!==null||U!==null,onOpenChange:()=>{K(null),I(null)},children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Rotate API Key"})}),U?h.jsx(ZC,{copiedKeyId:Z,onClose:()=>I(null),onCopy:Se,secretKey:U,warning:"The previous key has been invalidated. Store this replacement securely."}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"px-5 py-4",children:h.jsx("p",{className:"font-mono text-[10px] text-neutral-500",children:"Rotating a key invalidates the previous secret immediately."})}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>K(null),children:"Cancel"}),h.jsx(Oe,{variant:"primary",onClick:Ve,disabled:ae.isPending,children:ae.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Rotating..."]}):"Rotate"})]})]})]})})]})}function vX(){const{preferences:e,updatePreference:t,resetPreferences:n}=of(),s=[{type:"filter",label:"Auto-refresh interval",options:HY.map(i=>({id:`${i.value}`,label:i.label})),activeId:`${e.refreshInterval}`,onActiveChange:i=>t("refreshInterval",Number.parseInt(i,10))},{type:"filter",label:"Items per page",options:qY.map(i=>({id:`${i.value}`,label:i.label})),activeId:`${e.pageSize}`,onActiveChange:i=>t("pageSize",Number.parseInt(i,10))},{type:"filter",label:"Time format",options:[{id:"relative",label:"Relative"},{id:"absolute",label:"Absolute"}],activeId:e.timeFormat,onActiveChange:i=>t("timeFormat",i)},{type:"toggle",label:"Show sparklines",description:"Display mini trend charts in dashboard metric cards",checked:e.showSparklines,onCheckedChange:i=>t("showSparklines",i)}];return h.jsx(Qj,{rows:s,onResetDefaults:n})}function ZC({copiedKeyId:e,onClose:t,onCopy:n,secretKey:s,warning:i}){return h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[h.jsx(In,{variant:"destructive",children:h.jsx(Pn,{children:i})}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("code",{className:"flex-1 rounded-md border border-border bg-surface p-3 font-mono text-[11px] text-white break-all",children:s}),h.jsx(Oe,{variant:"default",size:"sm",onClick:()=>n(s),children:e===s?"Copied":"Copy"})]}),h.jsx(Nn,{children:h.jsx(Oe,{variant:"primary",onClick:t,children:"Done"})})]})}function bX(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 xX(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 SX(e,t){if(t==="absolute")return new Date(e).toLocaleString();try{const n=new Date(e),i=new Date().getTime()-n.getTime(),a=Math.floor(i/1e3),l=Math.floor(a/60),f=Math.floor(l/60),d=Math.floor(f/24);return a<60?"just now":l<60?`${l}m ago`:f<24?`${f}h ago`:`${d}d ago`}catch{return e}}function _X(e,t,n){return{id:e.clientId,type:bX(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:xX(e.clientId),scopes:Object.keys(e.effectiveScopes??{}),lastSeen:SX(e.updatedAt,n)}}function wX({emptyState:e}={}){const[t,n]=_.useState(1),[s,i]=_.useState(null),{preferences:a}=of(),{partitionId:l}=sf(),f=a.pageSize,d=a.refreshInterval*1e3,{data:p,isLoading:g}=rf({refetchIntervalMs:d,partitionId:l}),{data:y,isLoading:b,error:x}=hk({limit:f,offset:(t-1)*f,partitionId:l},{refetchIntervalMs:d}),S=jY(),w=Math.ceil((y?.total??0)/f),T=p?.maxCommitSeq??0;_.useEffect(()=>{n(1)},[]);const C=async()=>{if(s)try{await S.mutateAsync({clientId:s,partitionId:l})}finally{i(null)}};if(b||g)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsx(Pt,{size:"lg"})});if(x)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsxs("p",{className:"text-danger",children:["Failed to load clients: ",x.message]})});const O=(y?.items??[]).map(N=>_X(N,T,a.timeFormat));return h.jsxs("div",{className:"flex flex-col gap-5 px-5 py-5",children:[O.length>0&&h.jsx(Jj,{clients:O,headSeq:T}),O.length===0?e??h.jsx(J8,{children:h.jsx(Xb,{message:"No clients yet"})}):h.jsx(Kj,{clients:O,headSeq:T,onEvict:N=>{const R=y?.items.find(M=>M.clientId===N);i(R?.clientId??N)}}),w>1&&h.jsx(px,{page:t,totalPages:w,totalItems:y?.total??0,onPageChange:n}),h.jsx($r,{open:s!==null,onOpenChange:()=>i(null),children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Evict Client"})}),h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[h.jsxs("p",{className:"font-mono text-[11px] text-neutral-300",children:["Are you sure you want to evict client"," ",h.jsxs("span",{className:"font-mono text-white",children:[s?.slice(0,12),"..."]}),"?"]}),h.jsx("p",{className:"font-mono text-[10px] text-neutral-500",children:"This will force the client to re-bootstrap on their next sync."})]}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>i(null),children:"Cancel"}),h.jsx(Oe,{variant:"destructive",onClick:C,disabled:S.isPending,children:S.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Evicting..."]}):"Evict"})]})]})})]})}const EX={latencyThresholdMs:1e3,errorRateThreshold:5,clientLagThreshold:50,enabled:!1};function TX(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 CX(e){const t=e.split(",").map(n=>n.trim()).filter(n=>n.length>0);return Array.from(new Set(t))}function RX(e){switch(e){case"notify_data_change":return"Notify";case"evict_client":return"Evict";case"compact":return"Compact";default:return"Prune"}}function YC(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function NX(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function jX(e){const t=YC(e.requestPayload),n=YC(e.resultPayload);if(e.operationType==="notify_data_change"){const a=NX(t?.tables),l=n?.commitSeq;return`${a.length} table${a.length===1?"":"s"} -> commit #${typeof l=="number"?l:"?"}`}if(e.operationType==="evict_client"){const a=n?.evicted===!0?"evicted":"not found";return`client ${e.targetClientId??"?"} ${a}`}if(e.operationType==="compact")return`${typeof n?.deletedChanges=="number"?n.deletedChanges:0} changes removed`;const s=typeof n?.deletedCommits=="number"?n.deletedCommits:0,i=typeof t?.watermarkCommitSeq=="number"?` at #${t.watermarkCommitSeq}`:"";return`${s} commits removed${i}`}function AX(e){const t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function kX(){const{partitionId:e}=sf();return h.jsxs("div",{className:"flex flex-col gap-4 px-5 py-5",children:[h.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[h.jsx(OX,{}),h.jsx(zX,{})]}),h.jsxs("div",{className:"grid gap-4 xl:grid-cols-3",children:[h.jsx(MX,{partitionId:e}),h.jsx(IX,{partitionId:e}),h.jsx(PX,{partitionId:e})]}),h.jsx(DX,{partitionId:e})]})}function OX(){const{data:e,isLoading:t,error:n}=CY();if(t)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsx(Pt,{size:"lg"})});if(n)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsxs("p",{className:"text-danger",children:["Failed to load handlers: ",n.message]})});const s=(e?.items??[]).map(i=>({table:i.table,dependsOn:i.dependsOn?.join(", ")??null,chunkTtl:i.snapshotChunkTtlMs?TX(i.snapshotChunkTtlMs):"default"}));return h.jsx(Gj,{handlers:s,tableCount:e?.items.length??0})}function MX({partitionId:e}){const[t,n]=_.useState(!1),[s,i]=_.useState(null),{data:a,isLoading:l}=rf({partitionId:e}),{data:f,isLoading:d,refetch:p}=RY({enabled:!1}),g=AY(),y=async()=>{n(!0),i(null),await p()},b=async()=>{const S=await g.mutateAsync();i(S.deletedCommits)};if(l)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsx(Pt,{size:"lg"})});const x=[{label:"Total commits",value:a?.commitCount??0},{label:"Commit range",value:`${a?.minCommitSeq??0} - ${a?.maxCommitSeq??0}`},{label:"Min active cursor",value:a?.minActiveClientCursor??"N/A",tone:"syncing"}];return h.jsxs(h.Fragment,{children:[h.jsx(Ep,{title:"Prune",description:"Delete commits that all clients have already synced. Pruning removes commits older than the oldest active client cursor.",dotColor:"syncing",stats:x,actionLabel:"Preview Prune",actionVariant:"destructive",onAction:y}),h.jsx($r,{open:t,onOpenChange:n,children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Prune Old Commits"})}),h.jsx("div",{className:"px-5 py-4 flex flex-col gap-4",children:s!==null?h.jsxs(In,{variant:"default",children:[h.jsx(tf,{children:"Pruning Complete"}),h.jsxs(Pn,{children:["Successfully deleted ",h.jsx("strong",{children:s})," commits."]})]}):d?h.jsx("div",{className:"flex items-center justify-center py-8",children:h.jsx(Pt,{size:"sm"})}):f?h.jsxs(h.Fragment,{children:[h.jsx(In,{variant:f.commitsToDelete>0?"destructive":"default",children:h.jsx(Pn,{children:f.commitsToDelete>0?h.jsxs(h.Fragment,{children:["This will delete"," ",h.jsx("strong",{children:f.commitsToDelete})," commits up to sequence"," ",h.jsxs("code",{className:"font-mono",children:["#",f.watermarkCommitSeq]}),"."]}):"No commits are eligible for pruning."})}),h.jsxs("div",{className:"flex flex-col gap-2",children:[h.jsxs("div",{className:"flex justify-between font-mono text-[11px]",children:[h.jsx("span",{className:"text-neutral-500",children:"Watermark commit seq:"}),h.jsxs("span",{className:"text-white",children:["#",f.watermarkCommitSeq]})]}),h.jsxs("div",{className:"flex justify-between font-mono text-[11px] items-center",children:[h.jsx("span",{className:"text-neutral-500",children:"Commits to delete:"}),h.jsx(mn,{variant:f.commitsToDelete>0?"offline":"ghost",children:f.commitsToDelete})]})]})]}):null}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>n(!1),children:s!==null?"Close":"Cancel"}),s===null&&h.jsx(Oe,{variant:"destructive",onClick:b,disabled:g.isPending||d||(f?.commitsToDelete??0)===0,children:g.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Pruning..."]}):"Prune Now"})]})]})})]})}function IX({partitionId:e}){const[t,n]=_.useState(!1),[s,i]=_.useState(null),{data:a,isLoading:l}=rf({partitionId:e}),f=kY(),d=()=>{n(!0),i(null)},p=async()=>{const y=await f.mutateAsync();i(y.deletedChanges)};if(l)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsx(Pt,{size:"lg"})});const g=[{label:"Total changes",value:a?.changeCount??0},{label:"Total commits",value:a?.commitCount??0}];return h.jsxs(h.Fragment,{children:[h.jsx(Ep,{title:"Compact",description:"Merge old changes to reduce storage space. Compaction merges multiple changes to the same row into a single change.",dotColor:"flow",stats:g,actionLabel:"Run Compaction",actionVariant:"primary",onAction:d}),h.jsx($r,{open:t,onOpenChange:n,children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Compact Changes"})}),h.jsx("div",{className:"px-5 py-4 flex flex-col gap-4",children:s!==null?h.jsxs(In,{variant:"default",children:[h.jsx(tf,{children:"Compaction Complete"}),h.jsxs(Pn,{children:["Successfully removed ",h.jsx("strong",{children:s})," redundant changes."]})]}):h.jsx(In,{variant:"default",children:h.jsx(Pn,{children:"Compaction will merge multiple changes to the same row, keeping only the most recent version. This is safe and can be run at any time."})})}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>n(!1),children:s!==null?"Close":"Cancel"}),s===null&&h.jsx(Oe,{variant:"primary",onClick:p,disabled:f.isPending,children:f.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Compacting..."]}):"Compact Now"})]})]})})]})}function PX({partitionId:e}){const[t,n]=_.useState(!1),[s,i]=_.useState("tasks"),[a,l]=_.useState(e??""),[f,d]=_.useState(null),[p,g]=_.useState(null),y=OY(),b=CX(s),x=[{label:"Next tables",value:b.length,tone:"syncing"},{label:"Last commit seq",value:f?`#${f.commitSeq}`:"—",tone:"syncing"},{label:"Last chunks cleared",value:f?.deletedChunks??"—"}],S=()=>{n(!0),g(null)},w=async()=>{if(b.length===0){g("Provide at least one table name.");return}g(null);const T=await y.mutateAsync({tables:b,partitionId:a.trim()||void 0});d(T)};return h.jsxs(h.Fragment,{children:[h.jsx(Ep,{title:"Notify Data Change",description:"Create a synthetic commit after external imports or direct DB writes so clients re-bootstrap for affected tables.",dotColor:"healthy",stats:x,actionLabel:"Notify Clients",actionVariant:"primary",onAction:S}),h.jsx($r,{open:t,onOpenChange:n,children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Notify External Data Change"})}),h.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4",children:[f?h.jsxs(In,{variant:"default",children:[h.jsx(tf,{children:"Notification Sent"}),h.jsxs(Pn,{children:["Created synthetic commit"," ",h.jsxs("strong",{children:["#",f.commitSeq]})," for"," ",h.jsx("strong",{children:f.tables.length})," table",f.tables.length===1?"":"s"," and cleared"," ",h.jsx("strong",{children:f.deletedChunks})," cached chunk",f.deletedChunks===1?"":"s","."]})]}):h.jsx(In,{variant:"default",children:h.jsx(Pn,{children:"Use this when data changed outside Syncular push flow. It invalidates cached snapshot chunks and forces clients to pull fresh data."})}),p?h.jsx(In,{variant:"destructive",children:h.jsx(Pn,{children:p})}):null,h.jsxs(ms,{children:[h.jsx(ts,{children:"Tables (comma-separated)"}),h.jsx(Gn,{value:s,onChange:T=>i(T.target.value),placeholder:"tasks, notes",disabled:y.isPending}),h.jsx(mc,{children:"Enter one or more table names affected by the external change."})]}),h.jsxs(ms,{children:[h.jsx(ts,{children:"Partition ID (optional)"}),h.jsx(Gn,{value:a,onChange:T=>l(T.target.value),placeholder:"default",disabled:y.isPending})]})]}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>n(!1),children:f?"Close":"Cancel"}),f?null:h.jsx(Oe,{variant:"primary",onClick:w,disabled:y.isPending,children:y.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Notifying..."]}):"Notify Data Change"})]})]})})]})}function DX({partitionId:e}){const[t,n]=_.useState("all"),{data:s,isLoading:i,error:a}=NY({limit:20,offset:0,operationType:t==="all"?void 0:t,partitionId:e},{refetchIntervalMs:5e3});return h.jsx(Wb,{title:"Operation Audit",description:"Recent prune/compact/notify/evict actions with actor and result context.",actions:h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Oe,{variant:t==="all"?"default":"ghost",size:"sm",onClick:()=>n("all"),children:"All"}),h.jsx(Oe,{variant:t==="prune"?"default":"ghost",size:"sm",onClick:()=>n("prune"),children:"Prune"}),h.jsx(Oe,{variant:t==="compact"?"default":"ghost",size:"sm",onClick:()=>n("compact"),children:"Compact"}),h.jsx(Oe,{variant:t==="notify_data_change"?"default":"ghost",size:"sm",onClick:()=>n("notify_data_change"),children:"Notify"}),h.jsx(Oe,{variant:t==="evict_client"?"default":"ghost",size:"sm",onClick:()=>n("evict_client"),children:"Evict"})]}),contentClassName:"pt-2",children:i?h.jsx("div",{className:"flex items-center justify-center py-10",children:h.jsx(Pt,{size:"lg"})}):a?h.jsx(In,{variant:"destructive",children:h.jsxs(Pn,{children:["Failed to load operation audit events: ",a.message]})}):(s?.items.length??0)===0?h.jsx("div",{className:"px-2 py-8 text-sm text-neutral-500",children:"No operation events found for this filter."}):h.jsx("div",{className:"overflow-x-auto",children:h.jsxs(nl,{children:[h.jsx(rl,{children:h.jsxs(os,{children:[h.jsx(ht,{children:"Time"}),h.jsx(ht,{children:"Type"}),h.jsx(ht,{children:"User"}),h.jsx(ht,{children:"Target"}),h.jsx(ht,{children:"Result"})]})}),h.jsx(sl,{children:(s?.items??[]).map((l,f)=>h.jsxs(os,{children:[h.jsx(pt,{className:"whitespace-nowrap text-xs text-neutral-400",children:AX(l.createdAt)}),h.jsx(pt,{children:h.jsx(mn,{variant:"ghost",children:RX(l.operationType)})}),h.jsx(pt,{className:"font-mono text-xs",children:l.consoleUserId??"system"}),h.jsx(pt,{className:"font-mono text-xs",children:l.targetClientId??l.partitionId??(l.operationType==="notify_data_change"?"partition default":"global")}),h.jsx(pt,{className:"font-mono text-xs text-neutral-300",children:jX(l)})]},`${l.operationId}:${l.createdAt}:${f}`))})]})})})}function zX(){const[e,t]=pi("console:alert-config",EX),n={p90Latency:e.latencyThresholdMs,errorRate:e.errorRateThreshold,clientLag:e.clientLagThreshold},s=a=>{t(l=>({...l,latencyThresholdMs:a.p90Latency,errorRateThreshold:a.errorRate,clientLagThreshold:a.clientLag}))},i=a=>{t(l=>({...l,enabled:a}))};return h.jsx(Uj,{enabled:e.enabled,onEnabledChange:i,thresholds:n,onThresholdsChange:s})}function LX(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 UX(e){const t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function $X(){const[e,t]=_.useState(""),[n,s]=_.useState(void 0),[i,a]=_.useState(void 0),[l,f]=_.useState([]),[d,p]=_.useState(null),{data:g,isLoading:y,error:b}=UY({prefix:n,cursor:i,limit:100}),x=$Y(),S=BY();function w(){const M=e.trim();s(M.length>0?M:void 0),a(void 0),f([])}function T(){t(""),s(void 0),a(void 0),f([])}function C(){g?.cursor&&(f(M=>[...M,i??""]),a(g.cursor))}function O(){f(M=>{const L=[...M],j=L.pop();return a(j&&j.length>0?j:void 0),L})}function N(){d&&x.mutate(d,{onSuccess:()=>p(null)})}if(y)return h.jsx("div",{className:"flex flex-col gap-4 px-5 py-5",children:h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsx(Pt,{size:"lg"})})});if(b)return h.jsx("div",{className:"flex flex-col gap-4 px-5 py-5",children:h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsxs("p",{className:"text-danger font-mono text-[11px]",children:["Failed to load storage items: ",b.message]})})});const R=g?.items??[];return h.jsxs("div",{className:"flex flex-col gap-4 px-5 py-5",children:[h.jsx(Wb,{title:"Storage",actions:h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Gn,{placeholder:"Prefix filter...",value:e,onChange:M=>t(M.target.value),onKeyDown:M=>{M.key==="Enter"&&w()},className:"h-7 w-48 text-xs"}),h.jsx(Oe,{variant:"default",size:"sm",onClick:w,children:"Filter"}),n&&h.jsx(Oe,{variant:"ghost",size:"sm",onClick:T,children:"Clear"})]}),children:R.length===0?h.jsx(Xb,{message:n?`No storage items matching prefix "${n}".`:"No storage items found."}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"overflow-x-auto",children:h.jsxs(nl,{children:[h.jsx(rl,{children:h.jsxs(os,{children:[h.jsx(ht,{children:"Key"}),h.jsx(ht,{children:"Size"}),h.jsx(ht,{children:"Type"}),h.jsx(ht,{children:"Uploaded"}),h.jsx(ht,{children:"Actions"})]})}),h.jsx(sl,{children:R.map(M=>h.jsxs(os,{children:[h.jsx(pt,{className:"font-mono text-xs max-w-[320px]",title:M.key,children:M.key}),h.jsx(pt,{className:"font-mono text-xs text-neutral-400 whitespace-nowrap",children:LX(M.size)}),h.jsx(pt,{children:M.httpMetadata?.contentType?h.jsx(mn,{variant:"ghost",children:M.httpMetadata.contentType}):h.jsx("span",{className:"text-neutral-500 text-xs",children:"--"})}),h.jsx(pt,{className:"whitespace-nowrap text-xs text-neutral-400",children:UX(M.uploaded)}),h.jsx(pt,{children:h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx(Oe,{variant:"ghost",size:"sm",onClick:()=>{S(M.key)},children:"Download"}),h.jsx(Oe,{variant:"ghost",size:"sm",onClick:()=>p(M.key),children:"Delete"})]})})]},M.key))})]})}),h.jsxs("div",{className:"flex items-center justify-between px-2 py-2",children:[h.jsx(Oe,{variant:"ghost",size:"sm",disabled:l.length===0,onClick:O,children:"Previous"}),h.jsx(Oe,{variant:"ghost",size:"sm",disabled:!g?.truncated,onClick:C,children:"Next"})]})]})}),h.jsx($r,{open:d!==null,onOpenChange:()=>p(null),children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Delete Storage Item"})}),h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[h.jsxs("p",{className:"font-mono text-[11px] text-neutral-300",children:["Are you sure you want to delete"," ",h.jsx("span",{className:"font-mono text-white",children:d}),"?"]}),h.jsx("p",{className:"font-mono text-[10px] text-neutral-500",children:"This action cannot be undone."})]}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>p(null),children:"Cancel"}),h.jsx(Oe,{variant:"destructive",onClick:N,disabled:x.isPending,children:x.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"})," Deleting..."]}):"Delete"})]})]})})]})}const BX={};function au(e,t){if(t==="absolute")return new Date(e).toLocaleString();const n=new Date(e),i=new Date().getTime()-n.getTime(),a=Math.floor(i/1e3);return a<60?`${a}s`:a<3600?`${Math.floor(a/60)}m`:a<86400?`${Math.floor(a/3600)}h`:`${Math.floor(a/86400)}d`}function FX(e){const t=e.split(/\s+/).map(i=>i.trim()).filter(i=>i.length>0),n={},s=[];for(const i of t){const[a="",...l]=i.split(":"),f=l.join(":").trim(),d=a.toLowerCase();if(!f){s.push(i);continue}if(d==="actor"){n.actorId=f;continue}if(d==="client"){n.clientId=f;continue}if(d==="table"){n.table=f;continue}if(d==="request"){n.requestId=f;continue}if(d==="trace"){n.traceId=f;continue}s.push(i)}return s.length>0&&(n.search=s.join(" ")),n}function HX(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 Gd(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function qX(e,t){return e?`#${e.federatedCommitId??(t?`${t}:${e.commitSeq}`:String(e.commitSeq))}`:"#?"}function VX(e,t){return e?`E${e.federatedEventId??(t?`${t}:${e.eventId}`:e.eventId)}`:"E?"}function KX(e,t,n){return!e||!t?null:e.replaceAll("{traceId}",encodeURIComponent(t)).replaceAll("{spanId}",encodeURIComponent(n??""))}function yx({initialSelectedEntryId:e}={}){const{preferences:t}=of(),{partitionId:n}=sf(),{range:s,setRange:i}=pk(),a=t.pageSize,l=t.refreshInterval*1e3,f=BX?.VITE_CONSOLE_TRACE_URL_TEMPLATE,[d,p]=_.useState(()=>e?.startsWith("#")?"commits":e?.startsWith("E")?"events":"all"),[g,y]=_.useState("all"),[b,x]=_.useState("all"),[S,w]=_.useState(""),[T,C]=_.useState(1),[O,N]=_.useState(!1),[R,M]=_.useState(e??null),L=_.useRef(!1),j=_.useMemo(()=>FX(S),[S]),A=_.useMemo(()=>new Date(Date.now()-HX(s)).toISOString(),[s]),{data:P,isLoading:Z,refetch:B}=wY({limit:a,offset:(T-1)*a,...n?{partitionId:n}:{},view:d,...d!=="commits"&&g!=="all"?{eventType:g}:{},...d!=="commits"&&b!=="all"?{outcome:b}:{},...j.actorId?{actorId:j.actorId}:{},...j.clientId?{clientId:j.clientId}:{},...j.requestId?{requestId:j.requestId}:{},...j.traceId?{traceId:j.traceId}:{},...j.table?{table:j.table}:{},...j.search?{search:j.search}:{},from:A},{refetchIntervalMs:l}),z=WY(),Q=R?.startsWith("#")?R.slice(1):void 0,Y=R?.startsWith("E")?R.slice(1):void 0,ee=Q&&Q!=="?"?Q:void 0,D=Y&&Y!=="?"?Y:void 0,{data:V,isLoading:q,error:K}=_Y(ee,{enabled:ee!==void 0,partitionId:n}),{data:U,isLoading:I,error:H}=EY(D,{enabled:D!==void 0,partitionId:n}),{data:W,isLoading:X,error:oe}=TY(D,{enabled:D!==void 0&&!!U?.payloadRef,partitionId:n}),se=_.useMemo(()=>KX(f,U?.traceId??null,U?.spanId??null),[U?.spanId,U?.traceId,f]);_.useEffect(()=>{C(1)},[]),_.useEffect(()=>{C(1)},[]),_.useEffect(()=>{e&&M(e)},[e]),_.useEffect(()=>{if(!L.current){L.current=!0;return}M(null)},[]),_.useEffect(()=>{C(1),M(null)},[]);const xe=_.useMemo(()=>(P?.items??[]).map(we=>{const ve=we.instanceId??we.commit?.instanceId??we.event?.instanceId,Se=ve?`[${ve}] `:"";if(we.type==="commit"&&we.commit){const Ue=we.commit;return{type:"commit",id:qX(Ue,ve),outcome:"--",duration:"--",actor:Ue.actorId,client:Ue.clientId,detail:`${Se}${Ue.changeCount} chg | ${(Ue.affectedTables??[]).join(", ")}`,time:au(we.timestamp,t.timeFormat)}}const ye=we.event;return ye?{type:ye.eventType,id:VX(ye,ve),outcome:ye.outcome,duration:`${ye.durationMs}ms`,actor:ye.actorId,client:ye.clientId,detail:`${Se}${(ye.tables??[]).join(", ")||"--"}`,time:au(we.timestamp,t.timeFormat)}:{type:"pull",id:"E?",outcome:"unknown",duration:"--",actor:"",client:"",detail:"--",time:au(we.timestamp,t.timeFormat)}}),[t.timeFormat,P?.items]),de=P?.total??0,Me=Math.max(1,Math.ceil(de/a)),_e=Z,ne=[{label:"",options:[{id:"all",label:"All"},{id:"commits",label:"Commits"},{id:"events",label:"Events"}],activeId:d,onActiveChange:ae=>{p(ae),ae==="commits"&&(y("all"),x("all")),C(1)}},{label:"Time",options:[{id:"1h",label:"1h"},{id:"6h",label:"6h"},{id:"24h",label:"24h"},{id:"7d",label:"7d"},{id:"30d",label:"30d"}],activeId:s,onActiveChange:ae=>{i(ae),C(1)}},{label:"Type",options:[{id:"all",label:"All"},{id:"push",label:"Push"},{id:"pull",label:"Pull"}],activeId:g,onActiveChange:ae=>{y(ae),C(1)}},{label:"Outcome",options:[{id:"all",label:"All"},{id:"applied",label:"Applied"},{id:"error",label:"Error"},{id:"rejected",label:"Rejected"}],activeId:b,onActiveChange:ae=>{x(ae),C(1)}}];function he(){z.mutate(void 0,{onSuccess:()=>{N(!1),B()}})}return h.jsxs("div",{className:"flex flex-col h-full",children:[_e&&xe.length===0?h.jsx("div",{className:"flex items-center justify-center py-24",children:h.jsx(Pt,{size:"lg"})}):h.jsx(Wj,{entries:xe,selectedEntryId:R,onEntryClick:ae=>M(ae.id),filterBar:h.jsx(qj,{groups:ne,searchValue:S,searchPlaceholder:"Use actor:, client:, table:, request:, trace: or free text...",onSearchChange:w,actions:h.jsxs(h.Fragment,{children:[h.jsx(Oe,{size:"sm",variant:"ghost",onClick:()=>{B()},children:"Refresh"}),h.jsx(Oe,{size:"sm",variant:"ghost",children:"Export"}),h.jsx(Oe,{size:"sm",variant:"destructive",onClick:()=>N(!0),children:"Clear"})]})}),pagination:h.jsx(px,{page:T,totalPages:Me,totalItems:de,onPageChange:C})}),h.jsx($r,{open:R!==null,onOpenChange:ae=>{ae||M(null)},children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:ee!==void 0?`Commit #${ee}`:D!==void 0?`Event E${D}`:"Entry details"})}),h.jsx("div",{className:"px-5 py-4 space-y-3 max-h-[70vh] overflow-y-auto",children:q||I?h.jsx("div",{className:"flex items-center justify-center py-8",children:h.jsx(Pt,{size:"sm"})}):K||H?h.jsx("p",{className:"font-mono text-[11px] text-offline",children:"Failed to load details."}):V?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"grid grid-cols-2 gap-3 font-mono text-[11px]",children:[h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Actor"}),h.jsx("div",{className:"text-neutral-100",children:V.actorId})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Client"}),h.jsx("div",{className:"text-neutral-100",children:V.clientId})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Instance"}),h.jsx("div",{className:"text-neutral-100",children:V.instanceId??"--"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Created"}),h.jsx("div",{className:"text-neutral-100",children:au(V.createdAt,t.timeFormat)})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Changes"}),h.jsx("div",{className:"text-neutral-100",children:V.changeCount})]})]}),h.jsxs("div",{children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2",children:"Affected Tables"}),h.jsx("p",{className:"font-mono text-[11px] text-neutral-200",children:V.affectedTables.join(", ")||"--"})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500",children:"Changes"}),V.changes.length===0?h.jsx("p",{className:"font-mono text-[11px] text-neutral-500",children:"No changes recorded."}):V.changes.map(ae=>h.jsxs("div",{className:"rounded-md border border-border p-3 space-y-2",children:[h.jsxs("div",{className:"flex items-center justify-between font-mono text-[11px]",children:[h.jsxs("span",{className:"text-neutral-300",children:[ae.table," | ",ae.op]}),h.jsxs("span",{className:"text-neutral-500",children:["#",ae.changeId]})]}),h.jsxs("div",{className:"font-mono text-[11px] text-neutral-400",children:["rowId: ",ae.rowId,ae.rowVersion!==null?` | version: ${ae.rowVersion}`:""]}),h.jsx("pre",{className:"font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200",children:Gd(ae.rowJson)})]},ae.changeId))]})]}):U?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"grid grid-cols-2 gap-3 font-mono text-[11px]",children:[h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Type"}),h.jsx("div",{className:"text-neutral-100",children:U.eventType})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Path"}),h.jsx("div",{className:"text-neutral-100",children:U.syncPath})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Instance"}),h.jsx("div",{className:"text-neutral-100",children:U.instanceId??"--"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Outcome"}),h.jsx("div",{className:"text-neutral-100",children:U.outcome})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Response Status"}),h.jsx("div",{className:"text-neutral-100",children:U.responseStatus})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Actor"}),h.jsx("div",{className:"text-neutral-100",children:U.actorId})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Client"}),h.jsx("div",{className:"text-neutral-100",children:U.clientId})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Status"}),h.jsx("div",{className:"text-neutral-100",children:U.statusCode})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Transport"}),h.jsx("div",{className:"text-neutral-100",children:U.transportPath})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Duration"}),h.jsxs("div",{className:"text-neutral-100",children:[U.durationMs,"ms"]})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Request ID"}),h.jsx("div",{className:"text-neutral-100",children:U.requestId})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Trace ID"}),h.jsx("div",{className:"text-neutral-100",children:U.traceId??"--"}),se&&h.jsx("a",{href:se,target:"_blank",rel:"noreferrer",className:"font-mono text-[10px] text-flow underline underline-offset-4",children:"Open external trace"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Span ID"}),h.jsx("div",{className:"text-neutral-100",children:U.spanId??"--"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Commit Seq"}),h.jsx("div",{className:"text-neutral-100",children:U.commitSeq??"--"}),U.commitSeq!==null&&h.jsx(Oe,{variant:"ghost",size:"sm",onClick:()=>M(`#${U.instanceId?`${U.instanceId}:`:""}${U.commitSeq}`),children:"Open linked commit"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Subscription Count"}),h.jsx("div",{className:"text-neutral-100",children:U.subscriptionCount??"--"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Error Code"}),h.jsx("div",{className:"text-neutral-100",children:U.errorCode??"--"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Payload Ref"}),h.jsx("div",{className:"text-neutral-100",children:U.payloadRef??"--"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Created"}),h.jsx("div",{className:"text-neutral-100",children:au(U.createdAt,t.timeFormat)})]})]}),h.jsxs("div",{children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2",children:"Tables"}),h.jsx("p",{className:"font-mono text-[11px] text-neutral-200",children:U.tables.join(", ")||"--"})]}),U.scopesSummary&&h.jsxs("div",{children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2",children:"Scopes Summary"}),h.jsx("pre",{className:"font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200",children:Gd(U.scopesSummary)})]}),U.payloadRef&&h.jsxs("div",{children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2",children:"Payload Snapshot"}),X?h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Pt,{size:"sm"}),h.jsx("span",{className:"font-mono text-[11px] text-neutral-400",children:"Loading payload snapshot..."})]}):oe?h.jsx("p",{className:"font-mono text-[11px] text-offline",children:"Failed to load payload snapshot."}):W?h.jsxs("div",{className:"space-y-2",children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500",children:"Request"}),h.jsx("pre",{className:"font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200",children:Gd(W.requestPayload)}),h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500",children:"Response"}),h.jsx("pre",{className:"font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200",children:Gd(W.responsePayload)})]}):h.jsx("p",{className:"font-mono text-[11px] text-neutral-500",children:"No payload snapshot available."})]}),U.errorMessage&&h.jsxs("div",{children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2",children:"Error"}),h.jsx("p",{className:"font-mono text-[11px] text-offline",children:U.errorMessage})]})]}):h.jsx("p",{className:"font-mono text-[11px] text-neutral-500",children:"No details available for this row."})}),h.jsx(Nn,{children:h.jsx(Oe,{variant:"default",size:"sm",onClick:()=>M(null),children:"Close"})})]})}),h.jsx($r,{open:O,onOpenChange:ae=>{ae||N(!1)},children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Clear all events"})}),h.jsx("div",{className:"p-4",children:h.jsx("span",{className:"font-mono text-[11px] text-neutral-400",children:"This will permanently delete all request events. Commits are not affected. Are you sure?"})}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",size:"sm",onClick:()=>N(!1),children:"Cancel"}),h.jsx(Oe,{variant:"destructive",size:"sm",onClick:he,disabled:z.isPending,children:z.isPending?"Clearing...":"Clear all"})]})]})})]})}const GX=ao({getParentRoute:()=>lo,path:"/config",component:fX}),ZX=ao({getParentRoute:()=>lo,path:"/fleet",component:wX}),YX=ao({getParentRoute:()=>lo,path:"/",component:uX});function XX(){const{seq:e}=mk.useParams();return h.jsx(yx,{initialSelectedEntryId:`#${e}`})}const mk=ao({getParentRoute:()=>lo,path:"/investigate/commit/$seq",component:XX});function QX(){const{id:e}=gk.useParams();return h.jsx(yx,{initialSelectedEntryId:`E${e}`})}const gk=ao({getParentRoute:()=>lo,path:"/investigate/event/$id",component:QX}),WX=ao({getParentRoute:()=>lo,path:"/ops",component:kX}),JX=ao({getParentRoute:()=>lo,path:"/storage",component:$X}),eQ=ao({getParentRoute:()=>lo,path:"/stream",component:yx}),tQ=lo.addChildren([YX,eQ,mk,gk,ZX,WX,JX,GX]),nQ="syncular-console-basepath",rQ="syncular-console-server-url",sQ="syncular-console-token";function oQ(e){if(!e)return;const t=e.trim();return t.length>0?t:void 0}function Bv(e){const t=globalThis.document;if(!t)return;const n=t.querySelector(`meta[name="${e}"]`)?.getAttribute("content");return oQ(n)}function yk(e){return!e||e==="/"?"/":(e.startsWith("/")?e:`/${e}`).replace(/\/+$/g,"")||"/"}function iQ(){return yk(Bv(nQ))}function aQ(){const e=Bv(rQ),t=Bv(sQ);return!e||!t?null:{serverUrl:e,token:t}}function cQ(){return new A6({defaultOptions:{queries:{staleTime:5e3,retry:1}}})}function lQ(e){return yk(e??iQ())}function uQ(e){const[t]=_.useState(()=>cQ()),n=_.useMemo(()=>PH({routeTree:tQ,basepath:lQ(e.basePath)}),[e.basePath]),s=e.defaultConfig===void 0?aQ():e.defaultConfig,i=e.autoConnect??e.defaultConfig===void 0;return h.jsx(k6,{client:t,children:h.jsx(QH,{defaultConfig:s,autoConnect:i,children:h.jsx(LH,{router:n})})})}function fQ(e){return h.jsx("div",{className:gx,children:h.jsx(uQ,{...e})})}function dQ(e){const t=document.querySelector(e);if(!t)throw new Error(`Unable to mount console: ${e} not found`);return t}function hQ(e,t={}){const n=dQ(e);VY(n);const s=i6.createRoot(n),i=h.jsx(fQ,{basePath:t.basePath,defaultConfig:t.defaultConfig,autoConnect:t.autoConnect});return t.strictMode===!1?(s.render(i),s):(s.render(h.jsx(_.StrictMode,{children:i})),s)}var pQ={};const mQ="syncular-sentry-dsn",gQ="syncular-sentry-environment",yQ="syncular-sentry-release";function gu(e){if(!e)return;const t=e.trim();return t.length>0?t:void 0}function Fy(e){if(typeof document>"u")return;const t=document.querySelector(`meta[name="${e}"]`)?.getAttribute("content");return gu(t)}function Hy(e){if(!(typeof process>"u"))return gu(pQ[e])}function qy(e){for(const t of e)if(t)return t}function vQ(){const e=qy([gu(globalThis.__SYNCULAR_SENTRY_DSN__),Fy(mQ),Hy("SYNCULAR_SENTRY_DSN")]);if(!e)return null;const t=qy([gu(globalThis.__SYNCULAR_SENTRY_ENVIRONMENT__),Fy(gQ),Hy("SYNCULAR_SENTRY_ENVIRONMENT")]),n=qy([gu(globalThis.__SYNCULAR_SENTRY_RELEASE__),Fy(yQ),Hy("SYNCULAR_SENTRY_RELEASE")]);return{dsn:e,environment:t,release:n,enableLogs:!0,tracesSampleRate:.2,tracePropagationTargets:[/^https?:\/\/.*\/api\/.*/]}}const XC=vQ();XC&&QB(XC);hQ("#root");
|
|
86
|
+
)`}return h.jsx("div",{ref:n,role:"presentation","data-base-ui-inert":"",...i,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:a}})});function Wh(e,t){e&&Object.assign(e.style,t)}const HG={position:"relative",maxHeight:"100%",overflowX:"hidden",overflowY:"auto"},qG={position:"fixed"},VG=_.forwardRef(function(t,n){const{anchor:s,positionMethod:i="absolute",className:a,render:l,side:f="bottom",align:d="center",sideOffset:p=0,alignOffset:g=0,collisionBoundary:y="clipping-ancestors",collisionPadding:b,arrowPadding:x=5,sticky:S=!1,disableAnchorTracking:w,alignItemWithTrigger:T=!0,collisionAvoidance:C=Y9,...O}=t,{store:N,listRef:R,labelsRef:M,alignItemWithTriggerActiveRef:L,selectedItemTextRef:j,valuesRef:A,initialValueRef:P,popupRef:Z,setValue:B}=Wu(),z=BA(),Q=at(N,it.open),Y=at(N,it.mounted),ee=at(N,it.modal),D=at(N,it.value),V=at(N,it.openMethod),q=at(N,it.positionerElement),K=at(N,it.triggerElement),U=at(N,it.isItemEqualToValue),I=at(N,it.transitionStatus),H=_.useRef(null),W=_.useRef(null),[X,oe]=_.useState(T),se=Y&&X&&V!=="touch";!Y&&X!==T&&oe(T),Le(()=>{Y||(it.scrollUpArrowVisible(N.state)&&N.set("scrollUpArrowVisible",!1),it.scrollDownArrowVisible(N.state)&&N.set("scrollDownArrowVisible",!1))},[N,Y]),_.useImperativeHandle(L,()=>se),FA((se||ee)&&Q&&V!=="touch",K);const pe=zA({anchor:s,floatingRootContext:z,positionMethod:i,mounted:Y,side:f,sideOffset:p,align:d,alignOffset:g,arrowPadding:x,collisionBoundary:y,collisionPadding:b,sticky:S,disableAnchorTracking:w??se,collisionAvoidance:C,keepMounted:!0}),xe=se?"none":pe.side,de=se?qG:pe.positionerStyles,Me=_.useMemo(()=>{const Se={};return Q||(Se.pointerEvents="none"),{role:"presentation",hidden:!Y,style:{...de,...Se}}},[Q,Y,de]),_e={open:Q,side:xe,align:pe.align,anchorHidden:pe.anchorHidden},ne=Ae(Se=>{N.set("positionerElement",Se)}),he=zt("div",t,{ref:[n,ne],state:_e,stateAttributesMapping:il,props:[Me,Ap(I),O]}),ae=_.useRef(0),we=Ae(Se=>{if(Se.size===0&&ae.current===0||A.current.length===0)return;const ye=ae.current;if(ae.current=Se.size,Se.size===ye)return;const Ue=Yt(ii);if(ye!==0&&!N.state.multiple&&D!==null&&Ly(A.current,D,U)===-1){const Ee=P.current,Xe=Ee!=null&&Ly(A.current,Ee,U)!==-1?Ee:null;B(Xe,Ue),Xe===null&&(N.set("selectedIndex",null),j.current=null)}if(ye!==0&&N.state.multiple&&Array.isArray(D)){const Ie=Ve=>Ly(A.current,Ve,U)!==-1,Ee=D.filter(Ve=>Ie(Ve));(Ee.length!==D.length||Ee.some(Ve=>!bG(D,Ve,U)))&&(B(Ee,Ue),Ee.length===0&&(N.set("selectedIndex",null),j.current=null))}if(Q&&se){N.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});const Ie={height:""};Wh(q,Ie),Wh(Z.current,Ie)}}),ve=_.useMemo(()=>({...pe,side:xe,alignItemWithTriggerActive:se,setControlledAlignItemWithTrigger:oe,scrollUpArrowRef:H,scrollDownArrowRef:W}),[pe,xe,se,oe]);return h.jsx(qA,{elementsRef:R,labelsRef:M,onMapChange:we,children:h.jsxs(VA.Provider,{value:ve,children:[Y&&ee&&h.jsx(KA,{inert:fx(!Q),cutout:K}),he]})})});function GA(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 Vd="base-ui-disable-scrollbar",DC={className:Vd,getElement(e){return h.jsx("style",{nonce:e,href:Vd,precedence:"base-ui:low",children:`.${Vd}{scrollbar-width:none}.${Vd}::-webkit-scrollbar{display:none}`})}},KG=_.createContext(void 0);function ZA(e){return _.useContext(KG)}const Ec="ArrowUp",Wi="ArrowDown",Au="ArrowLeft",Tc="ArrowRight",Ju="Home",ef="End",YA=new Set([Au,Tc]),GG=new Set([Au,Tc,Ju,ef]),XA=new Set([Ec,Wi]),ZG=new Set([Ec,Wi,Ju,ef]),QA=new Set([...YA,...XA]),YG=new Set([...QA,Ju,ef]),WA=new Set([Ec,Wi,Au,Tc,Ju,ef]),XG="Shift",QG="Control",WG="Alt",JG="Meta",eZ=new Set([XG,QG,WG,JG]);function tZ(e){return Zt(e)&&e.tagName==="INPUT"}function zC(e){return!!(tZ(e)&&e.selectionStart!=null||Zt(e)&&e.tagName==="TEXTAREA")}function LC(e,t,n,s){if(!e||!t||!t.scrollTo)return;let i=e.scrollLeft,a=e.scrollTop;const l=e.clientWidth<e.scrollWidth,f=e.clientHeight<e.scrollHeight;if(l&&s!=="vertical"){const d=UC(e,t,"left"),p=Kd(e),g=Kd(t);n==="ltr"&&(d+t.offsetWidth+g.scrollMarginRight>e.scrollLeft+e.clientWidth-p.scrollPaddingRight?i=d+t.offsetWidth+g.scrollMarginRight-e.clientWidth+p.scrollPaddingRight:d-g.scrollMarginLeft<e.scrollLeft+p.scrollPaddingLeft&&(i=d-g.scrollMarginLeft-p.scrollPaddingLeft)),n==="rtl"&&(d-g.scrollMarginRight<e.scrollLeft+p.scrollPaddingLeft?i=d-g.scrollMarginLeft-p.scrollPaddingLeft:d+t.offsetWidth+g.scrollMarginRight>e.scrollLeft+e.clientWidth-p.scrollPaddingRight&&(i=d+t.offsetWidth+g.scrollMarginRight-e.clientWidth+p.scrollPaddingRight))}if(f&&s!=="horizontal"){const d=UC(e,t,"top"),p=Kd(e),g=Kd(t);d-g.scrollMarginTop<e.scrollTop+p.scrollPaddingTop?a=d-g.scrollMarginTop-p.scrollPaddingTop:d+t.offsetHeight+g.scrollMarginBottom>e.scrollTop+e.clientHeight-p.scrollPaddingBottom&&(a=d+t.offsetHeight+g.scrollMarginBottom-e.clientHeight+p.scrollPaddingBottom)}e.scrollTo({left:i,top:a,behavior:"auto"})}function UC(e,t,n){const s=n==="left"?"offsetLeft":"offsetTop";let i=0;for(;t.offsetParent&&(i+=t[s],t.offsetParent!==e);)t=t.offsetParent;return i}function Kd(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 Uy(e,t=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(t,Math.min(e,n))}const nZ=_.createContext(void 0),rZ={disableStyleElements:!1};function sZ(){return _.useContext(nZ)??rZ}const Vi=1,oZ={...il,...ba},iZ=_.forwardRef(function(t,n){const{render:s,className:i,finalFocus:a,...l}=t,{store:f,popupRef:d,onOpenChangeComplete:p,setOpen:g,valueRef:y,selectedItemTextRef:b,keyboardActiveRef:x,multiple:S,handleScrollArrowVisibility:w,scrollHandlerRef:T,highlightItemOnHover:C}=Wu(),{side:O,align:N,alignItemWithTriggerActive:R,setControlledAlignItemWithTrigger:M,scrollDownArrowRef:L,scrollUpArrowRef:j}=FG(),A=ZA()!=null,P=BA(),{nonce:Z,disableStyleElements:B}=sZ(),z=rs(),Q=at(f,it.id),Y=at(f,it.open),ee=at(f,it.mounted),D=at(f,it.popupProps),V=at(f,it.transitionStatus),q=at(f,it.triggerElement),K=at(f,it.positionerElement),U=at(f,it.listElement),I=_.useRef(0),H=_.useRef(!1),W=_.useRef(0),X=_.useRef(!1),oe=_.useRef({}),se=ox(),pe=Ae(_e=>{if(!K||!d.current||!X.current)return;if(H.current||!R){w();return}const ne=K.style.top==="0px",he=K.style.bottom==="0px",ae=K.getBoundingClientRect().height,we=Rt(K),ve=getComputedStyle(K),Se=parseFloat(ve.marginTop),ye=parseFloat(ve.marginBottom),Ue=$C(getComputedStyle(d.current)),Ie=Math.min(we.documentElement.clientHeight-Se-ye,Ue),Ee=_e.scrollTop,Ve=BC(_e);let Xe=0,Be=null,We=!1,He=!1;const me=qe=>{K.style.height=`${qe}px`},Te=(qe,mt)=>{const lt=Uy(qe,0,Ie-ae);lt>0&&me(ae+lt),_e.scrollTop=mt,Ie-(ae+lt)<=Vi&&(H.current=!0),w()};if(ne){const qe=Ve-Ee,mt=ae+qe,lt=Math.min(mt,Ie);if(Xe=lt,qe<=Vi){Te(qe,Ve);return}Ie-lt>Vi?He=!0:We=!0}else if(he){const qe=Ee,mt=ae+qe,lt=Math.min(mt,Ie),wr=mt-Ie;if(Xe=lt,qe<=Vi){Te(qe,0);return}Ie-lt>Vi?Be=0:(We=!0,Ee<Ve&&(Be=Ee-(qe-wr)))}if(Xe=Math.ceil(Xe),Xe!==0&&me(Xe),He||Be!=null){const qe=BC(_e),mt=He?qe:Uy(Be,0,qe);Math.abs(_e.scrollTop-mt)>Vi&&(_e.scrollTop=mt)}(We||Xe>=Ie-Vi)&&(H.current=!0),w()});_.useImperativeHandle(T,()=>pe,[pe]),xa({open:Y,ref:d,onComplete(){Y&&p?.(!0)}});const xe={open:Y,transitionStatus:V,side:O,align:N};Le(()=>{!K||!d.current||Object.keys(oe.current).length||(oe.current={top:K.style.top||"0",left:K.style.left||"0",right:K.style.right,height:K.style.height,bottom:K.style.bottom,minHeight:K.style.minHeight,maxHeight:K.style.maxHeight,marginTop:K.style.marginTop,marginBottom:K.style.marginBottom})},[d,K]),Le(()=>{Y||R||(X.current=!1,H.current=!1,I.current=0,W.current=0,Wh(K,oe.current))},[Y,R,K,d]),Le(()=>{const _e=d.current;if(!(!Y||!q||!K||!_e||f.state.transitionStatus==="ending")){if(!R){X.current=!0,se.request(w),_e.style.removeProperty("--transform-origin");return}queueMicrotask(()=>{const ne=aZ(_e);_e.style.removeProperty("--transform-origin");try{const he=getComputedStyle(K),ae=getComputedStyle(_e),we=Rt(q),ve=un(K),Se=q.getBoundingClientRect(),ye=K.getBoundingClientRect(),Ue=Se.left,Ie=Se.height,Ee=U||_e,Ve=Ee.scrollHeight,Xe=parseFloat(ae.borderBottomWidth),Be=parseFloat(he.marginTop)||10,We=parseFloat(he.marginBottom)||10,He=parseFloat(he.minHeight)||100,me=$C(ae),Te=5,qe=5,mt=20,lt=we.documentElement.clientHeight-Be-We,wr=we.documentElement.clientWidth,Er=lt-Se.bottom+Ie,Qt=b.current,ut=y.current;let xt,ot=0,Wt=0;if(Qt&&ut){const tr=ut.getBoundingClientRect();xt=Qt.getBoundingClientRect();const ls=tr.left-Ue,uo=xt.left-ye.left,fo=tr.top-Se.top+tr.height/2,nr=xt.top-ye.top+xt.height/2;ot=ls-uo,Wt=nr-fo}const vn=Er+Wt+We+Xe;let kt=Math.min(lt,vn);const Cn=lt-Be-We,er=vn-kt,An=Math.max(Te,Ue+ot),as=wr-qe,cs=Math.max(0,An+ye.width-as);K.style.left=`${An-cs}px`,K.style.height=`${kt}px`,K.style.maxHeight="auto",K.style.marginTop=`${Be}px`,K.style.marginBottom=`${We}px`,_e.style.height="100%";const _a=Ee.scrollHeight-Ee.clientHeight,wi=er>=_a;wi&&(kt=Math.min(lt,ye.height)-(er-_a));const Ei=Se.top<mt||Se.bottom>lt-mt||kt<Math.min(Ve,He),ws=(ve.visualViewport?.scale??1)!==1&&tx;if(Ei||ws){X.current=!0,Wh(K,oe.current),hi.flushSync(()=>M(!1));return}if(wi){const tr=Math.max(0,lt-vn);K.style.top=ye.height>=Cn?"0":`${tr}px`,K.style.height=`${kt}px`,Ee.scrollTop=Ee.scrollHeight-Ee.clientHeight,I.current=Math.max(He,kt)}else K.style.bottom="0",I.current=Math.max(He,kt),Ee.scrollTop=er;if(xt){const tr=ye.top,ls=ye.height,uo=xt.top+xt.height/2,fo=ls>0?(uo-tr)/ls*100:50,nr=Uy(fo,0,100);_e.style.setProperty("--transform-origin",`50% ${nr}%`)}(I.current===lt||kt>=me)&&(H.current=!0),w(),setTimeout(()=>{X.current=!0})}finally{ne()}})}},[f,Y,K,q,y,b,d,w,R,M,se,L,j,U]),_.useEffect(()=>{if(!R||!K||!Y)return;const _e=un(K);function ne(he){g(!1,Yt(x8,he))}return _e.addEventListener("resize",ne),()=>{_e.removeEventListener("resize",ne)}},[g,R,K,Y]);const de={...U?{role:"presentation","aria-orientation":void 0}:{role:"listbox","aria-multiselectable":S||void 0,id:`${Q}-list`},onKeyDown(_e){x.current=!0,A&&WA.has(_e.key)&&_e.stopPropagation()},onMouseMove(){x.current=!1},onPointerLeave(_e){if(!C||GA(_e)||_e.pointerType==="touch")return;const ne=_e.currentTarget;z.start(0,()=>{f.set("activeIndex",null),ne.focus({preventScroll:!0})})},onScroll(_e){U||pe(_e.currentTarget)},...R&&{style:U?{height:"100%"}:HG}},Me=zt("div",t,{ref:[n,d],state:xe,stateAttributesMapping:oZ,props:[D,de,Ap(V),{className:!U&&R?DC.className:void 0},l]});return h.jsxs(_.Fragment,{children:[!B&&DC.getElement(Z),h.jsx(wA,{context:P,modal:!1,disabled:!ee,returnFocus:a,restoreFocus:!0,children:Me})]})});function $C(e){const t=e.maxHeight||"";return t.endsWith("px")&&parseFloat(t)||1/0}function BC(e){return Math.max(0,e.scrollHeight-e.clientHeight)}const FC=[["transform","none"],["scale","1"],["translate","0 0"]];function aZ(e){const{style:t}=e,n={};for(const[s,i]of FC)n[s]=t.getPropertyValue(s),t.setProperty(s,i,"important");return()=>{for(const[s]of FC){const i=n[s];i?t.setProperty(s,i):t.removeProperty(s)}}}let JA=(function(e){return e[e.None=0]="None",e[e.GuessFromOrder=1]="GuessFromOrder",e})({});function dx(e={}){const{label:t,metadata:n,textRef:s,indexGuessBehavior:i,index:a}=e,{register:l,unregister:f,subscribeMapChange:d,elementsRef:p,labelsRef:g,nextIndexRef:y}=LG(),b=_.useRef(-1),[x,S]=_.useState(a??(i===JA.GuessFromOrder?()=>{if(b.current===-1){const C=y.current;y.current+=1,b.current=C}return b.current}:-1)),w=_.useRef(null),T=_.useCallback(C=>{if(w.current=C,x!==-1&&C!==null&&(p.current[x]=C,g)){const O=t!==void 0;g.current[x]=O?t:s?.current?.textContent??C.textContent}},[x,p,g,t,s]);return Le(()=>{if(a!=null)return;const C=w.current;if(C)return l(C,n),()=>{f(C)}},[a,l,f,n]),Le(()=>{if(a==null)return d(C=>{const O=w.current?C.get(w.current)?.index:null;O!=null&&S(O)})},[a,d,S]),_.useMemo(()=>({ref:T,index:x}),[x,T])}const cZ=_.createContext(void 0),lZ=_.memo(_.forwardRef(function(t,n){const{render:s,className:i,value:a=null,label:l,disabled:f=!1,nativeButton:d=!1,...p}=t,g=_.useRef(null),y=dx({label:l,textRef:g,indexGuessBehavior:JA.GuessFromOrder}),{store:b,getItemProps:x,setOpen:S,setValue:w,selectionRef:T,typingRef:C,valuesRef:O,keyboardActiveRef:N,multiple:R,highlightItemOnHover:M}=Wu(),L=rs(),j=at(b,it.isActive,y.index),A=at(b,it.isSelected,y.index,a),P=at(b,it.isSelectedByFocus,y.index),Z=at(b,it.isItemEqualToValue),B=y.index,z=B!==-1,Q=_.useRef(null),Y=Jo(B);Le(()=>{if(!z)return;const se=O.current;return se[B]=a,()=>{delete se[B]}},[z,B,a,O]),Le(()=>{if(!z)return;const se=b.state.value;let pe=se;R&&Array.isArray(se)&&se.length>0&&(pe=se[se.length-1]),pe!==void 0&&Bc(a,pe,Z)&&b.set("selectedIndex",B)},[z,B,R,Z,b,a]);const ee={disabled:f,selected:A,highlighted:j},D=x({active:j,selected:A});D.onFocus=void 0,D.id=void 0;const V=_.useRef(null),q=_.useRef("mouse"),K=_.useRef(!1),{getButtonProps:U,buttonRef:I}=el({disabled:f,focusableWhenDisabled:!0,native:d});function H(se){const pe=b.state.value;if(R){const xe=Array.isArray(pe)?pe:[],de=A?xG(xe,a,Z):[...xe,a];w(de,Yt(Ry,se))}else w(a,Yt(Ry,se)),S(!1,Yt(Ry,se))}const W={role:"option","aria-selected":A,tabIndex:j?0:-1,onFocus(){b.set("activeIndex",B)},onMouseEnter(){!N.current&&b.state.selectedIndex===null&&M&&b.set("activeIndex",B)},onMouseMove(){M&&b.set("activeIndex",B)},onMouseLeave(se){!M||N.current||GA(se)||L.start(0,()=>{b.state.activeIndex===B&&b.set("activeIndex",null)})},onTouchStart(){T.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1}},onKeyDown(se){V.current=se.key,b.set("activeIndex",B)},onClick(se){K.current=!1,!(se.type==="keydown"&&V.current===null)&&(f||V.current===" "&&C.current||q.current!=="touch"&&!j||(V.current=null,H(se.nativeEvent)))},onPointerEnter(se){q.current=se.pointerType},onPointerDown(se){q.current=se.pointerType,K.current=!0},onMouseUp(se){if(f)return;if(K.current){K.current=!1;return}const pe=!T.current.allowSelectedMouseUp&&A,xe=!T.current.allowUnselectedMouseUp&&!A;pe||xe||q.current!=="touch"&&!j||H(se.nativeEvent)}},X=zt("div",t,{ref:[I,n,y.ref,Q],state:ee,props:[D,W,p,U]}),oe=_.useMemo(()=>({selected:A,indexRef:Y,textRef:g,selectedByFocus:P,hasRegistered:z}),[A,Y,g,P,z]);return h.jsx(cZ.Provider,{value:oe,children:X})})),uZ=_.forwardRef(({className:e,children:t,...n},s)=>h.jsx(jG,{ref:s,className:ge("inline-flex items-center justify-between bg-surface border border-border rounded-md px-3 py-1.5 font-mono text-[12px] text-foreground cursor-pointer hover:border-border-bright transition",e),...n,children:t}));uZ.displayName="SelectTrigger";const fZ=_.forwardRef(({className:e,portalProps:t,positionerProps:n,...s},i)=>h.jsx(kG,{...t,children:h.jsx(VG,{...n,children:h.jsx(iZ,{ref:i,className:ge("bg-panel border border-border rounded-md py-1 shadow-lg z-50",e),...s})})}));fZ.displayName="SelectContent";const dZ=_.forwardRef(({className:e,...t},n)=>h.jsx(lZ,{ref:n,className:ge("font-mono text-[11px] px-3 py-1.5 text-neutral-400 cursor-pointer hover:bg-white/[0.03] hover:text-white data-[highlighted]:bg-white/[0.03] data-[highlighted]:text-white outline-none",e),...t}));dZ.displayName="SelectItem";const hZ=_.forwardRef(({className:e,...t},n)=>h.jsx("textarea",{ref:n,className:ge("bg-surface border border-border rounded-md px-3 py-2 font-mono text-[12px] text-foreground outline-none w-full transition focus:border-flow placeholder:text-neutral-600 resize-none min-h-[80px]",e),...t}));hZ.displayName="Textarea";const ek=_.createContext(void 0);function pZ(e=!0){const t=_.useContext(ek);if(t===void 0&&!e)throw new Error(yn(7));return t}function tk(e={}){const{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:s}=jj(),{ref:i,index:a}=dx(e),l=n===a,f=_.useRef(null),d=so(i,f);return{compositeProps:_.useMemo(()=>({tabIndex:l?0:-1,onFocus(){s(a)},onMouseMove(){const g=f.current;if(!t||!g)return;const y=g.hasAttribute("disabled")||g.ariaDisabled==="true";!l&&!y&&g.focus()}}),[l,s,a,t]),compositeRef:d,index:a}}function mZ(e){const{render:t,className:n,state:s=an,props:i=Ru,refs:a=Ru,metadata:l,stateAttributesMapping:f,tag:d="div",...p}=e,{compositeProps:g,compositeRef:y}=tk({metadata:l});return zt(d,e,{state:s,ref:[...a,y],props:[g,...i,p],stateAttributesMapping:f})}const gZ=_.forwardRef(function(t,n){const{className:s,defaultPressed:i=!1,disabled:a=!1,form:l,onPressedChange:f,pressed:d,render:p,type:g,value:y,nativeButton:b=!0,...x}=t,S=br(y||void 0),w=pZ(),T=w?.value??[],C=w?void 0:i,O=(a||w?.disabled)??!1,[N,R]=gp({controlled:w?S!==void 0&&T.indexOf(S)>-1:d,default:C,name:"Toggle",state:"pressed"}),M=Ae((z,Q)=>{S&&w?.setGroupValue?.(S,z,Q),f?.(z,Q)}),{getButtonProps:L,buttonRef:j}=el({disabled:O,native:b}),A={disabled:O,pressed:N},P=[j,n],Z=[{"aria-pressed":N,onClick(z){const Q=!N,Y=Yt(ii,z.nativeEvent);M(Q,Y),!Y.isCanceled&&R(Q)}},x,L],B=zt("button",t,{enabled:!w,state:A,ref:P,props:Z});return w?h.jsx(mZ,{tag:"button",render:p,className:s,state:A,refs:P,props:Z}):B}),Dr=_.forwardRef(({className:e,...t},n)=>h.jsx(gZ,{ref:n,className:ge("font-mono text-[10px] text-neutral-500 border border-transparent rounded-sm px-2.5 py-1 cursor-pointer transition-all hover:text-neutral-300 data-[pressed]:text-white data-[pressed]:border-border-bright data-[pressed]:bg-white/[0.03]",e),...t}));Dr.displayName="Toggle";function yZ(e){return e==null||e.hasAttribute("disabled")||e.getAttribute("aria-disabled")==="true"}const nk="data-composite-item-active",vZ=[];function bZ(e){const{itemSizes:t,cols:n=1,loopFocus:s=!0,dense:i=!1,orientation:a="both",direction:l,highlightedIndex:f,onHighlightedIndexChange:d,rootRef:p,enableHomeAndEndKeys:g=!1,stopEventPropagation:y=!1,disabledIndices:b,modifierKeys:x=vZ}=e,[S,w]=_.useState(0),T=n>1,C=_.useRef(null),O=so(C,p),N=_.useRef([]),R=_.useRef(!1),M=f??S,L=Ae((P,Z=!1)=>{if((d??w)(P),Z){const B=N.current[P];LC(C.current,B,l,a)}}),j=Ae(P=>{if(P.size===0||R.current)return;R.current=!0;const Z=Array.from(P.keys()),B=Z.find(Q=>Q?.hasAttribute(nk))??null,z=B?Z.indexOf(B):-1;z!==-1&&L(z),LC(C.current,B,l,a)}),A=_.useMemo(()=>({"aria-orientation":a==="both"?void 0:a,ref:O,onFocus(P){!C.current||!zC(P.target)||P.target.setSelectionRange(0,P.target.value.length??0)},onKeyDown(P){const Z=g?YG:QA;if(!Z.has(P.key)||xZ(P,x)||!C.current)return;const z=l==="rtl",Q=z?Au:Tc,Y={horizontal:Q,vertical:Wi,both:Q}[a],ee=z?Tc:Au,D={horizontal:ee,vertical:Ec,both:ee}[a];if(zC(P.target)&&!yZ(P.target)){const W=P.target.selectionStart,X=P.target.selectionEnd,oe=P.target.value??"";if(W==null||P.shiftKey||W!==X||P.key!==D&&W<oe.length||P.key!==Y&&W>0)return}let V=M;const q=IV(N,b),K=PV(N,b);if(T){const W=t||Array.from({length:N.current.length},()=>({width:1,height:1})),X=zV(W,n,i),oe=X.findIndex(pe=>pe!=null&&!pu(N,pe,b)),se=X.reduce((pe,xe,de)=>xe!=null&&!pu(N,xe,b)?de:pe,-1);V=X[DV({current:X.map(pe=>pe?N.current[pe]:null)},{event:P,orientation:a,loopFocus:s,cols:n,disabledIndices:UV([...b||N.current.map((pe,xe)=>pu(N,xe)?xe:void 0),void 0],X),minIndex:oe,maxIndex:se,prevIndex:LV(M>K?q:M,W,X,n,P.key===Wi?"bl":P.key===Tc?"tr":"tl"),rtl:z})]}const U={horizontal:[Q],vertical:[Wi],both:[Q,Wi]}[a],I={horizontal:[ee],vertical:[Ec],both:[ee,Ec]}[a],H=T?Z:{horizontal:g?GG:YA,vertical:g?ZG:XA,both:Z}[a];g&&(P.key===Ju?V=q:P.key===ef&&(V=K)),V===M&&(U.includes(P.key)||I.includes(P.key))&&(s&&V===K&&U.includes(P.key)?V=q:s&&V===q&&I.includes(P.key)?V=K:V=fr(N,{startingIndex:V,decrement:I.includes(P.key),disabledIndices:b})),V!==M&&!ch(N,V)&&(y&&P.stopPropagation(),H.has(P.key)&&P.preventDefault(),L(V,!0),queueMicrotask(()=>{N.current[V]?.focus()}))}}),[n,i,l,b,N,g,M,T,t,s,O,x,L,a,y]);return _.useMemo(()=>({props:A,highlightedIndex:M,onHighlightedIndexChange:L,elementsRef:N,disabledIndices:b,onMapChange:j,relayKeyboardEvent:A.onKeyDown}),[A,M,L,N,b,j])}function xZ(e,t){for(const n of eZ.values())if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function rk(e){const{render:t,className:n,refs:s=Ru,props:i=Ru,state:a=an,stateAttributesMapping:l,highlightedIndex:f,onHighlightedIndexChange:d,orientation:p,dense:g,itemSizes:y,loopFocus:b,cols:x,enableHomeAndEndKeys:S,onMapChange:w,stopEventPropagation:T=!0,rootRef:C,disabledIndices:O,modifierKeys:N,highlightItemOnHover:R=!1,tag:M="div",...L}=e,j=PA(),{props:A,highlightedIndex:P,onHighlightedIndexChange:Z,elementsRef:B,onMapChange:z,relayKeyboardEvent:Q}=bZ({itemSizes:y,cols:x,loopFocus:b,dense:g,orientation:p,highlightedIndex:f,onHighlightedIndexChange:d,rootRef:C,stopEventPropagation:T,enableHomeAndEndKeys:S,direction:j,disabledIndices:O,modifierKeys:N}),Y=zt(M,e,{state:a,ref:s,props:[A,...i,L],stateAttributesMapping:l}),ee=_.useMemo(()=>({highlightedIndex:P,onHighlightedIndexChange:Z,highlightItemOnHover:R,relayKeyboardEvent:Q}),[P,Z,R,Q]);return h.jsx(Nj.Provider,{value:ee,children:h.jsx(qA,{elementsRef:B,onMapChange:D=>{w?.(D),z(D)},children:Y})})}let SZ=(function(e){return e.disabled="data-disabled",e.orientation="data-orientation",e.multiple="data-multiple",e})({});const HC={multiple(e){return e?{[SZ.multiple]:""}:null}},_Z=_.forwardRef(function(t,n){const{defaultValue:s,disabled:i=!1,loopFocus:a=!0,onValueChange:l,orientation:f="horizontal",multiple:d=!1,value:p,className:g,render:y,...b}=t,x=ZA(),S=_.useMemo(()=>{if(p===void 0)return s??[]},[p,s]),w=_.useMemo(()=>p!==void 0||s!==void 0,[p,s]),T=(x?.disabled??!1)||i,[C,O]=gp({controlled:p,default:S,name:"ToggleGroup",state:"value"}),N=Ae((A,P,Z)=>{let B;if(d?(B=C.slice(),P?B.push(A):B.splice(C.indexOf(A),1)):B=P?[A]:[],Array.isArray(B)){if(l?.(B,Z),Z.isCanceled)return;O(B)}}),R={disabled:T,multiple:d,orientation:f},M=_.useMemo(()=>({disabled:T,orientation:f,setGroupValue:N,value:C,isValueInitialized:w}),[T,f,N,C,w]),L={role:"group"},j=zt("div",t,{enabled:!!x,state:R,ref:n,props:[L,b],stateAttributesMapping:HC});return h.jsx(ek.Provider,{value:M,children:x?j:h.jsx(rk,{render:y,className:g,state:R,refs:[n],props:[L,b],stateAttributesMapping:HC,loopFocus:a,enableHomeAndEndKeys:!0})})}),dh=_.forwardRef(({className:e,...t},n)=>h.jsx(_Z,{ref:n,className:ge("flex items-center gap-0.5",e),...t}));dh.displayName="ToggleGroup";const wZ=ge(Fj({variant:"secondary",size:"sm"}),"h-7 whitespace-nowrap uppercase tracking-[0.08em] leading-none no-underline");function sk({active:e,onClick:t,children:n,className:s}){return h.jsxs("button",{type:"button",onClick:t,className:ge("font-mono text-[10px] tracking-[1.5px] uppercase bg-transparent border-none px-3.5 py-1 cursor-pointer relative transition-colors",e?"text-white":"text-neutral-500 hover:text-neutral-300",s),children:[n,e&&h.jsx("span",{className:"absolute -bottom-2.5 left-1/2 -translate-x-1/2 w-4 h-0.5 bg-flow rounded-sm shadow-[0_0_8px_rgba(59,130,246,0.5)]"})]})}function EZ({items:e,activeId:t,onItemChange:n,renderItem:s,className:i}){return h.jsx("div",{className:ge("flex items-center gap-0.5",i),children:e.map(a=>{const l=a.id===t,f=()=>n?.(a.id);return s?h.jsx("span",{children:s(a,{active:l,onClick:f})},a.id):h.jsx(sk,{active:l,onClick:f,children:a.label},a.id)})})}const TZ=gi("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}}),CZ={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 RZ({color:e,size:t,glow:n,pulse:s,className:i}){return h.jsx("span",{className:ge(TZ({color:e,size:t,glow:n}),s&&"dot-pulse",i),style:n?{boxShadow:CZ[e??"healthy"]}:void 0})}const NZ="0.0.6-85",jZ={version:NZ},AZ=jZ.version;function kZ({label:e,className:t}){return h.jsxs("div",{className:ge("flex items-center gap-3",t),children:[h.jsx(RZ,{color:"healthy",size:"md",glow:!0}),h.jsx("span",{className:"font-display font-bold text-white text-sm tracking-tight",children:"syncular"}),e&&h.jsx("span",{className:"font-mono text-[9px] text-neutral-600 uppercase tracking-widest",children:e}),h.jsxs("span",{className:"font-mono text-[9px] text-neutral-600 tracking-wider",children:["v",AZ]})]})}function OZ({brand:e,center:t,right:n,className:s}){return h.jsxs(h.Fragment,{children:[h.jsx("div",{"aria-hidden":"true",className:"h-[42px] shrink-0"}),h.jsxs("nav",{className:ge("fixed top-0 left-0 right-0 z-100 h-[42px] border-b border-border bg-surface/88 backdrop-blur-lg flex items-center justify-between px-5",s),children:[h.jsx("div",{className:"flex items-center gap-3",children:e}),h.jsx("div",{className:"flex items-center gap-0.5",children:t}),h.jsx("div",{className:"flex items-center gap-2",children:n})]})]})}const MZ=gi("border rounded-lg p-3 font-mono text-[11px]",{variants:{variant:{default:"border-border bg-panel",destructive:"border-offline/20 bg-offline/5 text-offline"}},defaultVariants:{variant:"default"}}),In=_.forwardRef(({className:e,variant:t,...n},s)=>h.jsx("div",{ref:s,role:"alert",className:ge(MZ({variant:t,className:e})),...n}));In.displayName="Alert";const tf=_.forwardRef(({className:e,...t},n)=>h.jsx("h5",{ref:n,className:ge("font-medium text-white mb-1",e),...t}));tf.displayName="AlertTitle";const Pn=_.forwardRef(({className:e,...t},n)=>h.jsx("p",{ref:n,className:ge("text-neutral-400",e),...t}));Pn.displayName="AlertDescription";const ok=_.createContext(void 0);function al(e){const t=_.useContext(ok);if(e===!1&&t===void 0)throw new Error(yn(27));return t}const IZ={...il,...ba},hx=_.forwardRef(function(t,n){const{render:s,className:i,forceRender:a=!1,...l}=t,{store:f}=al(),d=f.useState("open"),p=f.useState("nested"),g=f.useState("mounted"),y=f.useState("transitionStatus");return zt("div",t,{state:{open:d,transitionStatus:y},ref:[f.context.backdropRef,n],stateAttributesMapping:IZ,props:[{role:"presentation",hidden:!g,style:{userSelect:"none",WebkitUserSelect:"none"}},l],enabled:a||!p})}),ik=_.forwardRef(function(t,n){const{render:s,className:i,id:a,...l}=t,{store:f}=al(),d=br(a);return f.useSyncedValueWithCleanup("descriptionElementId",d),zt("p",t,{ref:n,props:[{id:d},l]})});let PZ=(function(e){return e.nestedDialogs="--nested-dialogs",e})({}),DZ=(function(e){return e[e.open=Qi.open]="open",e[e.closed=Qi.closed]="closed",e[e.startingStyle=Qi.startingStyle]="startingStyle",e[e.endingStyle=Qi.endingStyle]="endingStyle",e.nested="data-nested",e.nestedDialogOpen="data-nested-dialog-open",e})({});const ak=_.createContext(void 0);function zZ(){const e=_.useContext(ak);if(e===void 0)throw new Error(yn(26));return e}const LZ={...il,...ba,nestedDialogOpen(e){return e?{[DZ.nestedDialogOpen]:""}:null}},ck=_.forwardRef(function(t,n){const{className:s,finalFocus:i,initialFocus:a,render:l,...f}=t,{store:d}=al(),p=d.useState("descriptionElementId"),g=d.useState("disablePointerDismissal"),y=d.useState("floatingRootContext"),b=d.useState("popupProps"),x=d.useState("modal"),S=d.useState("mounted"),w=d.useState("nested"),T=d.useState("nestedOpenDialogCount"),C=d.useState("open"),O=d.useState("openMethod"),N=d.useState("titleElementId"),R=d.useState("transitionStatus"),M=d.useState("role");zZ(),xa({open:C,ref:d.context.popupRef,onComplete(){C&&d.context.onOpenChangeComplete?.(!0)}});function L(B){return B==="touch"?d.context.popupRef.current:!0}const j=a===void 0?L:a,A=T>0,Z=zt("div",t,{state:{open:C,nested:w,transitionStatus:R,nestedDialogOpen:A},props:[b,{"aria-labelledby":N??void 0,"aria-describedby":p??void 0,role:M,tabIndex:-1,hidden:!S,onKeyDown(B){WA.has(B.key)&&B.stopPropagation()},style:{[PZ.nestedDialogs]:T}},f],ref:[n,d.context.popupRef,d.useStateSetter("popupElement")],stateAttributesMapping:LZ});return h.jsx(wA,{context:y,openInteractionType:O,disabled:!S,closeOnFocusOut:!g,initialFocus:j,returnFocus:i,modal:x!==!1,restoreFocus:"popup",children:Z})}),lk=_.forwardRef(function(t,n){const{keepMounted:s=!1,...i}=t,{store:a}=al(),l=a.useState("mounted"),f=a.useState("modal"),d=a.useState("open");return l||s?h.jsx(ak.Provider,{value:s,children:h.jsxs(_A,{ref:n,...i,children:[l&&f===!0&&h.jsx(KA,{ref:a.context.internalBackdropRef,inert:fx(!d)}),t.children]})}):null});function UZ(e){const{store:t,parentContext:n,actionsRef:s}=e,i=t.useState("open"),a=t.useState("disablePointerDismissal"),l=t.useState("modal"),f=t.useState("popupElement"),{openMethod:d,triggerProps:p,reset:g}=TG(i);m7(t);const{forceUnmount:y}=g7(i,t,()=>{g()}),b=Ae(Z=>{const B=Yt(Z);return B.preventUnmountOnClose=()=>{t.set("preventUnmountingOnClose",!0)},B}),x=_.useCallback(()=>{t.setOpen(!1,b(b8))},[t,b]);_.useImperativeHandle(s,()=>({unmount:y,close:x}),[y,x]);const S=_7({popupStore:t,onOpenChange:t.setOpen,treatPopupAsFloatingElement:!0,noEmit:!0}),[w,T]=_.useState(0),C=w===0,O=k7(S),N=r7(S,{outsidePressEvent(){return t.context.internalBackdropRef.current||t.context.backdropRef.current?"intentional":{mouse:l==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}},outsidePress(Z){if(!t.context.outsidePressEnabledRef.current||"button"in Z&&Z.button!==0||"touches"in Z&&Z.touches.length!==1)return!1;const B=Ur(Z);if(C&&!a){const z=B;return l&&(t.context.internalBackdropRef.current||t.context.backdropRef.current)?t.context.internalBackdropRef.current===z||t.context.backdropRef.current===z||Ot(z,f)&&!z?.hasAttribute("data-base-ui-portal"):!0}return!1},escapeKey:C});FA(i&&l===!0,f);const{getReferenceProps:R,getFloatingProps:M,getTriggerProps:L}=j7([O,N]);t.useContextCallback("onNestedDialogOpen",Z=>{T(Z+1)}),t.useContextCallback("onNestedDialogClose",()=>{T(0)}),_.useEffect(()=>(n?.onNestedDialogOpen&&i&&n.onNestedDialogOpen(w),n?.onNestedDialogClose&&!i&&n.onNestedDialogClose(),()=>{n?.onNestedDialogClose&&i&&n.onNestedDialogClose()}),[i,n,w]);const j=_.useMemo(()=>R(p),[R,p]),A=_.useMemo(()=>L(p),[L,p]),P=_.useMemo(()=>M(),[M]);t.useSyncedValues({openMethod:d,activeTriggerProps:j,inactiveTriggerProps:A,popupProps:P,floatingRootContext:S,nestedOpenDialogCount:w})}const $Z={...b7,modal:Pe(e=>e.modal),nested:Pe(e=>e.nested),nestedOpenDialogCount:Pe(e=>e.nestedOpenDialogCount),disablePointerDismissal:Pe(e=>e.disablePointerDismissal),openMethod:Pe(e=>e.openMethod),descriptionElementId:Pe(e=>e.descriptionElementId),titleElementId:Pe(e=>e.titleElementId),viewportElement:Pe(e=>e.viewportElement),role:Pe(e=>e.role)};class BZ extends OA{constructor(t){super(FZ(t),{popupRef:_.createRef(),backdropRef:_.createRef(),internalBackdropRef:_.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:new lx,onOpenChange:void 0,onOpenChangeComplete:void 0},$Z)}setOpen=(t,n)=>{if(n.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},!t&&n.trigger==null&&this.state.activeTriggerId!=null&&(n.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(t,n),n.isCanceled)return;const s={open:t,nativeEvent:n.event,reason:n.reason,nested:this.state.nested};this.state.floatingRootContext.context.events?.emit("openchange",s);const i={open:t},a=n.trigger?.id??null;(a||t)&&(i.activeTriggerId=a,i.activeTriggerElement=n.trigger??null),this.update(i)}}function FZ(e={}){return{...v7(),modal:!0,disablePointerDismissal:!1,popupElement:null,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,role:"dialog",...e}}function HZ(e){const{children:t,open:n,defaultOpen:s=!1,onOpenChange:i,onOpenChangeComplete:a,disablePointerDismissal:l=!1,modal:f=!0,actionsRef:d,handle:p,triggerId:g,defaultTriggerId:y=null}=e,b=al(!0),x=!!b,S=zn(()=>p?.store??new BZ({open:s,openProp:n,activeTriggerId:y,triggerIdProp:g,modal:f,disablePointerDismissal:l,nested:x})).current;oV(()=>{n===void 0&&S.state.open===!1&&s===!0&&S.update({open:!0,activeTriggerId:y})}),S.useControlledProp("openProp",n),S.useControlledProp("triggerIdProp",g),S.useSyncedValues({disablePointerDismissal:l,nested:x,modal:f}),S.useContextCallback("onOpenChange",i),S.useContextCallback("onOpenChangeComplete",a);const w=S.useState("payload");UZ({store:S,actionsRef:d,parentContext:b?.store.context});const T=_.useMemo(()=>({store:S}),[S]);return h.jsx(ok.Provider,{value:T,children:typeof t=="function"?t({payload:w}):t})}const uk=_.forwardRef(function(t,n){const{render:s,className:i,id:a,...l}=t,{store:f}=al(),d=br(a);return f.useSyncedValueWithCleanup("titleElementId",d),zt("h2",t,{ref:n,props:[{id:d},l]})}),$r=HZ,qZ=_.forwardRef(({className:e,...t},n)=>h.jsx(hx,{ref:n,className:ge("fixed inset-0 z-50 bg-black/60 backdrop-blur-sm",e),...t}));qZ.displayName="DialogOverlay";const hr=_.forwardRef(({className:e,children:t,...n},s)=>h.jsxs(lk,{children:[h.jsx(hx,{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm"}),h.jsx(ck,{ref:s,className:ge("fixed z-50 top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-panel border border-border rounded-lg shadow-lg max-w-lg w-full p-0",e),...n,children:t})]}));hr.displayName="DialogContent";const pr=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("px-5 py-3 border-b border-border",e),...t}));pr.displayName="DialogHeader";const Nn=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("px-5 py-3 border-t border-border flex justify-end gap-2",e),...t}));Nn.displayName="DialogFooter";const mr=_.forwardRef(({className:e,...t},n)=>h.jsx(uk,{ref:n,className:ge("font-mono text-[10px] text-neutral-500 uppercase tracking-widest",e),...t}));mr.displayName="DialogTitle";const VZ=_.forwardRef(({className:e,...t},n)=>h.jsx(ik,{ref:n,className:ge("font-mono text-[10px] text-neutral-500",e),...t}));VZ.displayName="DialogDescription";const px=_.forwardRef(({className:e,page:t,totalPages:n,totalItems:s,onPageChange:i,...a},l)=>h.jsxs("div",{ref:l,className:ge("px-5 py-2.5 border-t border-border flex items-center justify-between",e),...a,children:[h.jsxs("span",{className:"font-mono text-[10px] text-neutral-600",children:[s," items · Page ",t," of ",n]}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx(Oe,{size:"sm",variant:"default",disabled:t<=1,onClick:()=>i(t-1),children:"Prev"}),h.jsx(Oe,{size:"sm",variant:"default",disabled:t>=n,onClick:()=>i(t+1),children:"Next"})]})]}));px.displayName="Pagination";const KZ=_.forwardRef(({className:e,orientation:t="horizontal",...n},s)=>h.jsx("hr",{ref:s,"aria-orientation":t==="vertical"?"vertical":void 0,className:ge("border-none m-0",t==="horizontal"?"h-px w-full bg-border":"w-px h-4 bg-border",e),...n}));KZ.displayName="Separator";const GZ=gi("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"}}),ZZ=_.forwardRef(({className:e,side:t,children:n,...s},i)=>h.jsxs(lk,{children:[h.jsx(hx,{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm"}),h.jsx(ck,{ref:i,className:ge(GZ({side:t,className:e})),...s,children:n})]}));ZZ.displayName="SheetContent";const YZ=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("px-5 py-3 border-b border-border",e),...t}));YZ.displayName="SheetHeader";const XZ=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("px-5 py-3 border-t border-border flex justify-end gap-2",e),...t}));XZ.displayName="SheetFooter";const QZ=_.forwardRef(({className:e,...t},n)=>h.jsx(uk,{ref:n,className:ge("font-mono text-[10px] text-neutral-500 uppercase tracking-widest",e),...t}));QZ.displayName="SheetTitle";const WZ=_.forwardRef(({className:e,...t},n)=>h.jsx(ik,{ref:n,className:ge("text-sm text-neutral-400",e),...t}));WZ.displayName="SheetDescription";const JZ=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("rounded-md bg-neutral-800 animate-pulse",e),...t}));JZ.displayName="Skeleton";const eY=_.createContext(void 0);function mx(){const e=_.useContext(eY);if(e===void 0)throw new Error(yn(64));return e}let tY=(function(e){return e.activationDirection="data-activation-direction",e.orientation="data-orientation",e})({});const fk={tabActivationDirection:e=>({[tY.activationDirection]:e})},dk=_.createContext(void 0);function nY(){const e=_.useContext(dk);if(e===void 0)throw new Error(yn(65));return e}const rY=_.forwardRef(function(t,n){const{className:s,disabled:i=!1,render:a,value:l,id:f,nativeButton:d=!0,...p}=t,{value:g,getTabPanelIdByValue:y,orientation:b}=mx(),{activateOnFocus:x,highlightedTabIndex:S,onTabActivation:w,setHighlightedTabIndex:T,tabsListElement:C}=nY(),O=br(f),N=_.useMemo(()=>({disabled:i,id:O,value:l}),[i,O,l]),{compositeProps:R,compositeRef:M,index:L}=tk({metadata:N}),j=l===g,A=_.useRef(!1);Le(()=>{if(A.current){A.current=!1;return}if(!(j&&L>-1&&S!==L))return;const K=C;if(K!=null){const U=Bo(Rt(K));if(U&&Ot(K,U))return}i||T(L)},[j,L,S,T,i,C]);const{getButtonProps:P,buttonRef:Z}=el({disabled:i,native:d,focusableWhenDisabled:!0}),B=y(l),z=_.useRef(!1),Q=_.useRef(!1);function Y(K){j||i||w(l,Yt(ii,K.nativeEvent,void 0,{activationDirection:"none"}))}function ee(K){j||(L>-1&&!i&&T(L),!i&&x&&(!z.current||z.current&&Q.current)&&w(l,Yt(ii,K.nativeEvent,void 0,{activationDirection:"none"})))}function D(K){if(j||i)return;z.current=!0;function U(){z.current=!1,Q.current=!1}(!K.button||K.button===0)&&(Q.current=!0,Rt(K.currentTarget).addEventListener("pointerup",U,{once:!0}))}return zt("button",t,{state:{disabled:i,active:j,orientation:b},ref:[n,Z,M],props:[R,{role:"tab","aria-controls":B,"aria-selected":j,id:O,onClick:Y,onFocus:ee,onPointerDown:D,[nk]:j?"":void 0,onKeyDownCapture(){A.current=!0}},p,P]})});let sY=(function(e){return e.index="data-index",e.activationDirection="data-activation-direction",e.orientation="data-orientation",e.hidden="data-hidden",e})({});const oY={...fk,...ba},iY=_.forwardRef(function(t,n){const{className:s,value:i,render:a,keepMounted:l=!1,...f}=t,{value:d,getTabIdByPanelValue:p,orientation:g,tabActivationDirection:y,registerMountedTabPanel:b,unregisterMountedTabPanel:x}=mx(),S=br(),w=_.useMemo(()=>({id:S,value:i}),[S,i]),{ref:T,index:C}=dx({metadata:w}),O=i===d,{mounted:N,transitionStatus:R,setMounted:M}=jp(O),L=!N,j=p(i),A={hidden:L,orientation:g,tabActivationDirection:y,transitionStatus:R},P=_.useRef(null),Z=zt("div",t,{state:A,ref:[n,T,P],props:[{"aria-labelledby":j,hidden:L,id:S,role:"tabpanel",tabIndex:O?0:-1,inert:fx(!O),[sY.index]:C},f],stateAttributesMapping:oY});return xa({open:O,ref:P,onComplete(){O||M(!1)}}),Le(()=>{if(!(L&&!l)&&S!=null)return b(i,S),()=>{x(i,S)}},[L,l,i,S,b,x]),l||N?Z:null}),aY=_.forwardRef(function(t,n){const{activateOnFocus:s=!1,className:i,loopFocus:a=!0,render:l,...f}=t,{getTabElementBySelectedValue:d,onValueChange:p,orientation:g,value:y,setTabMap:b,tabActivationDirection:x}=mx(),[S,w]=_.useState(0),[T,C]=_.useState(null),O=cY(y,g,T,d),N=Ae((j,A)=>{if(j!==y){const P=O(j);A.activationDirection=P,p(j,A)}}),R={orientation:g,tabActivationDirection:x},M={"aria-orientation":g==="vertical"?"vertical":void 0,role:"tablist"},L=_.useMemo(()=>({activateOnFocus:s,highlightedTabIndex:S,onTabActivation:N,setHighlightedTabIndex:w,tabsListElement:T,value:y}),[s,S,N,w,T,y]);return h.jsx(dk.Provider,{value:L,children:h.jsx(rk,{render:l,className:i,state:R,refs:[n,C],props:[M,f],stateAttributesMapping:fk,highlightedIndex:S,enableHomeAndEndKeys:!0,loopFocus:a,orientation:g,onHighlightedIndexChange:w,onMapChange:b,disabledIndices:Ru})})});function qC(e,t){const{left:n,top:s}=e.getBoundingClientRect(),{left:i,top:a}=t.getBoundingClientRect(),l=n-i,f=s-a;return{left:l,top:f}}function cY(e,t,n,s){const[i,a]=_.useState(null);return Le(()=>{if(e==null||n==null){a(null);return}const l=s(e);if(l==null){a(null);return}const{left:f,top:d}=qC(l,n);a(t==="horizontal"?f:d)},[t,s,n,e]),_.useCallback(l=>{if(l===e)return"none";if(l==null)return a(null),"none";if(l!=null&&n!=null){const f=s(l);if(f!=null){const{left:d,top:p}=qC(f,n);if(i==null)return a(t==="horizontal"?d:p),"none";if(t==="horizontal"){if(d<i)return a(d),"left";if(d>i)return a(d),"right"}else{if(p<i)return a(p),"up";if(p>i)return a(p),"down"}}}return"none"},[s,t,i,n,e])}const lY=_.forwardRef(({className:e,...t},n)=>h.jsx(aY,{ref:n,className:ge("flex items-center gap-0.5",e),...t}));lY.displayName="TabsList";const uY=gi("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"}}),fY=_.forwardRef(({className:e,variant:t,...n},s)=>h.jsx(rY,{ref:s,className:ge(uY({variant:t,className:e})),...n}));fY.displayName="TabsTrigger";const dY=_.forwardRef(({className:e,...t},n)=>h.jsx(iY,{ref:n,className:ge("outline-none",e),...t}));dY.displayName="TabsContent";const hY=_.forwardRef(({className:e,...t},n)=>h.jsx("p",{ref:n,className:ge("font-mono text-[11px] text-neutral-300",e),...t}));hY.displayName="Text";const pY=_.forwardRef(({className:e,...t},n)=>h.jsx("p",{ref:n,className:ge("font-mono text-[10px] text-neutral-500",e),...t}));pY.displayName="TextMuted";const mY=_.forwardRef(({className:e,...t},n)=>h.jsx("code",{ref:n,className:ge("font-mono text-[11px] text-white",e),...t}));mY.displayName="TextCode";const gY=_.forwardRef(({className:e,...t},n)=>h.jsx("span",{ref:n,className:ge("font-mono text-[9px] uppercase tracking-wider text-neutral-500",e),...t}));gY.displayName="TextLabel";const yY=_.forwardRef(({className:e,...t},n)=>h.jsx("pre",{ref:n,className:ge("font-mono text-[11px] text-neutral-300 p-3 rounded border border-border bg-panel-alt overflow-x-auto",e),...t}));yY.displayName="CodeBlock";const vY="console:instance-id";function Lt(){const[e,t]=pi(vY,""),n=e.trim();return _.useMemo(()=>({instanceId:n.length>0?n:void 0,rawInstanceId:e,setInstanceId:t,clearInstanceId:()=>t("")}),[n,e,t])}const Jn={stats:e=>["console","stats",e],timeseries:e=>["console","stats","timeseries",e],latency:e=>["console","stats","latency",e],commits:e=>["console","commits",e],commitDetail:(e,t,n)=>["console","commit-detail",e,t,n],timeline:e=>["console","timeline",e],clients:e=>["console","clients",e],eventDetail:(e,t,n)=>["console","event-detail",e,t,n],eventPayload:(e,t,n)=>["console","event-payload",e,t,n],handlers:e=>["console","handlers",e],prunePreview:e=>["console","prune","preview",e],operations:e=>["console","operations",e],apiKeys:e=>["console","api-keys",e],storage:e=>["console","storage",e]};function _i(e,t){return e===0?!1:e??t}function nf(e,t){return t?{...e,instanceId:t}:e}function Sa(e){return encodeURIComponent(String(e))}function Ln(e,t,n){const s=e.endsWith("/")?e.slice(0,-1):e,i=n?.toString();return`${s}${t}${i?`?${i}`:""}`}function rf(e={}){const t=Vt(),{instanceId:n}=Lt(),s=e.instanceId??n,i=nf(e.partitionId?{partitionId:e.partitionId}:{},s);return Wn({queryKey:Jn.stats({partitionId:e.partitionId,instanceId:s}),queryFn:()=>{if(!t)throw new Error("Not connected");return Yu(t.GET("/console/stats",{params:{query:i}}))},enabled:!!t,refetchInterval:_i(e.refetchIntervalMs,5e3)})}function bY(e={},t={}){const n=Vt(),{config:s}=Dt(),{instanceId:i}=Lt(),a=e.instanceId??i;return Wn({queryKey:Jn.timeseries({...e,instanceId:a}),queryFn:async()=>{if(!n||!s)throw new Error("Not connected");const l=new URLSearchParams;e.interval&&l.set("interval",e.interval),e.range&&l.set("range",e.range),e.partitionId&&l.set("partitionId",e.partitionId),a&&l.set("instanceId",a);const f=await fetch(`${s.serverUrl}/console/stats/timeseries?${l}`,{headers:{Authorization:`Bearer ${s.token}`}});if(!f.ok)throw new Error("Failed to fetch timeseries stats");return f.json()},enabled:(t.enabled??!0)&&!!n&&!!s,refetchInterval:_i(t.refetchIntervalMs,3e4)})}function xY(e={},t={}){const n=Vt(),{config:s}=Dt(),{instanceId:i}=Lt(),a=e.instanceId??i;return Wn({queryKey:Jn.latency({...e,instanceId:a}),queryFn:async()=>{if(!n||!s)throw new Error("Not connected");const l=new URLSearchParams;e.range&&l.set("range",e.range),e.partitionId&&l.set("partitionId",e.partitionId),a&&l.set("instanceId",a);const f=await fetch(`${s.serverUrl}/console/stats/latency?${l}`,{headers:{Authorization:`Bearer ${s.token}`}});if(!f.ok)throw new Error("Failed to fetch latency stats");return f.json()},enabled:(t.enabled??!0)&&!!n&&!!s,refetchInterval:_i(t.refetchIntervalMs,3e4)})}function SY(e={},t={}){const n=Vt(),{instanceId:s}=Lt(),i=e.instanceId??s,a=nf({limit:e.limit,offset:e.offset,partitionId:e.partitionId},i);return Wn({queryKey:Jn.commits({...e,instanceId:i}),queryFn:()=>{if(!n)throw new Error("Not connected");return Yu(n.GET("/console/commits",{params:{query:a}}))},enabled:(t.enabled??!0)&&!!n,refetchInterval:_i(t.refetchIntervalMs,1e4)})}function _Y(e,t={}){const n=Vt(),{config:s}=Dt(),{instanceId:i}=Lt(),a=t.instanceId??i;return Wn({queryKey:Jn.commitDetail(e,t.partitionId,a),queryFn:async()=>{if(!n||!s)throw new Error("Not connected");if(e===void 0)throw new Error("Commit sequence is required");const l=new URLSearchParams;t.partitionId&&l.set("partitionId",t.partitionId),a&&l.set("instanceId",a);const f=l.toString(),d=await fetch(`${s.serverUrl}/console/commits/${Sa(e)}${f?`?${f}`:""}`,{headers:{Authorization:`Bearer ${s.token}`}});if(!d.ok)throw new Error("Failed to fetch commit detail");return d.json()},enabled:(t.enabled??!0)&&e!==void 0&&!!n})}function wY(e={},t={}){const n=Vt(),{instanceId:s}=Lt(),i=e.instanceId??s,a=nf({limit:e.limit,offset:e.offset,partitionId:e.partitionId,view:e.view,eventType:e.eventType,actorId:e.actorId,clientId:e.clientId,requestId:e.requestId,traceId:e.traceId,table:e.table,outcome:e.outcome,search:e.search,from:e.from,to:e.to},i);return Wn({queryKey:Jn.timeline({...e,instanceId:i}),queryFn:()=>{if(!n)throw new Error("Not connected");return Yu(n.GET("/console/timeline",{params:{query:a}}))},enabled:(t.enabled??!0)&&!!n,refetchInterval:_i(t.refetchIntervalMs,1e4)})}function hk(e={},t={}){const n=Vt(),{instanceId:s}=Lt(),i=e.instanceId??s,a=nf({limit:e.limit,offset:e.offset,partitionId:e.partitionId},i);return Wn({queryKey:Jn.clients({...e,instanceId:i}),queryFn:()=>{if(!n)throw new Error("Not connected");return Yu(n.GET("/console/clients",{params:{query:a}}))},enabled:(t.enabled??!0)&&!!n,refetchInterval:_i(t.refetchIntervalMs,1e4)})}function EY(e,t={}){const n=Vt(),{config:s}=Dt(),{instanceId:i}=Lt(),a=t.instanceId??i;return Wn({queryKey:Jn.eventDetail(e,t.partitionId,a),queryFn:async()=>{if(!n||!s)throw new Error("Not connected");if(e===void 0)throw new Error("Event id is required");const l=new URLSearchParams;t.partitionId&&l.set("partitionId",t.partitionId),a&&l.set("instanceId",a);const f=l.toString(),d=await fetch(`${s.serverUrl}/console/events/${Sa(e)}${f?`?${f}`:""}`,{headers:{Authorization:`Bearer ${s.token}`}});if(!d.ok)throw new Error("Failed to fetch event detail");return d.json()},enabled:(t.enabled??!0)&&e!==void 0&&!!n})}function TY(e,t={}){const n=Vt(),{config:s}=Dt(),{instanceId:i}=Lt(),a=t.instanceId??i;return Wn({queryKey:Jn.eventPayload(e,t.partitionId,a),queryFn:async()=>{if(!n||!s)throw new Error("Not connected");if(e===void 0)throw new Error("Event id is required");const l=new URLSearchParams;t.partitionId&&l.set("partitionId",t.partitionId),a&&l.set("instanceId",a);const f=l.toString(),d=await fetch(`${s.serverUrl}/console/events/${Sa(e)}/payload${f?`?${f}`:""}`,{headers:{Authorization:`Bearer ${s.token}`}});if(!d.ok)throw new Error("Failed to fetch event payload");return d.json()},enabled:(t.enabled??!0)&&e!==void 0&&!!n})}function CY(e={}){const t=Vt(),{config:n}=Dt(),{instanceId:s}=Lt(),i=e.instanceId??s;return Wn({queryKey:Jn.handlers(i),queryFn:async()=>{if(!t||!n)throw new Error("Not connected");const a=new URLSearchParams;i&&a.set("instanceId",i);const l=await fetch(Ln(n.serverUrl,"/console/handlers",a),{headers:{Authorization:`Bearer ${n.token}`}});if(!l.ok)throw new Error("Failed to fetch handlers");return l.json()},enabled:!!t&&!!n})}function RY(e={}){const t=Vt(),{config:n}=Dt(),{instanceId:s}=Lt(),i=e.instanceId??s;return Wn({queryKey:Jn.prunePreview(i),queryFn:async()=>{if(!t||!n)throw new Error("Not connected");const a=new URLSearchParams;i&&a.set("instanceId",i);const l=await fetch(Ln(n.serverUrl,"/console/prune/preview",a),{method:"POST",headers:{Authorization:`Bearer ${n.token}`}});if(!l.ok)throw new Error("Failed to fetch prune preview");return l.json()},enabled:!!t&&!!n&&(e.enabled??!0)})}function NY(e={},t={}){const n=Vt(),{instanceId:s}=Lt(),i=e.instanceId??s,a=nf({limit:e.limit,offset:e.offset,operationType:e.operationType,partitionId:e.partitionId},i);return Wn({queryKey:Jn.operations({...e,instanceId:i}),queryFn:()=>{if(!n)throw new Error("Not connected");return Yu(n.GET("/console/operations",{params:{query:a}}))},enabled:(t.enabled??!0)&&!!n,refetchInterval:_i(t.refetchIntervalMs,1e4)})}function jY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async({clientId:i,partitionId:a,instanceId:l})=>{if(!e||!t)throw new Error("Not connected");const f=l??n,d=new URLSearchParams;a&&d.set("partitionId",a),f&&d.set("instanceId",f);const p=await fetch(Ln(t.serverUrl,`/console/clients/${Sa(i)}`,d),{method:"DELETE",headers:{Authorization:`Bearer ${t.token}`}});if(!p.ok)throw new Error("Failed to evict client");return p.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","clients"]}),s.invalidateQueries({queryKey:["console","stats"]}),s.invalidateQueries({queryKey:["console","operations"]})}})}function AY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async()=>{if(!e||!t)throw new Error("Not connected");const i=new URLSearchParams;n&&i.set("instanceId",n);const a=await fetch(Ln(t.serverUrl,"/console/prune",i),{method:"POST",headers:{Authorization:`Bearer ${t.token}`}});if(!a.ok)throw new Error("Failed to prune");return a.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","stats"]}),s.invalidateQueries({queryKey:["console","commits"]}),s.invalidateQueries({queryKey:["console","timeline"]}),s.invalidateQueries({queryKey:["console","prune","preview"]}),s.invalidateQueries({queryKey:["console","operations"]})}})}function kY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async()=>{if(!e||!t)throw new Error("Not connected");const i=new URLSearchParams;n&&i.set("instanceId",n);const a=await fetch(Ln(t.serverUrl,"/console/compact",i),{method:"POST",headers:{Authorization:`Bearer ${t.token}`}});if(!a.ok)throw new Error("Failed to compact");return a.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","stats"]}),s.invalidateQueries({queryKey:["console","operations"]})}})}function OY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async i=>{if(!e||!t)throw new Error("Not connected");const a=i.instanceId??n,l=new URLSearchParams;a&&l.set("instanceId",a);const f=await fetch(Ln(t.serverUrl,"/console/notify-data-change",l),{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"Content-Type":"application/json"},body:JSON.stringify({tables:i.tables,partitionId:i.partitionId})});if(!f.ok)throw new Error("Failed to notify data change");return f.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","stats"]}),s.invalidateQueries({queryKey:["console","commits"]}),s.invalidateQueries({queryKey:["console","timeline"]}),s.invalidateQueries({queryKey:["console","operations"]})}})}function MY(e={}){const t=Vt(),{config:n}=Dt(),{instanceId:s}=Lt(),i=e.instanceId??s;return Wn({queryKey:Jn.apiKeys({...e,instanceId:i}),queryFn:async()=>{if(!t||!n)throw new Error("Not connected");const a=new URLSearchParams;e.limit!==void 0&&a.set("limit",String(e.limit)),e.offset!==void 0&&a.set("offset",String(e.offset)),e.type&&a.set("type",e.type),e.status&&a.set("status",e.status),e.expiresWithinDays!==void 0&&a.set("expiresWithinDays",String(e.expiresWithinDays)),i&&a.set("instanceId",i);const l=await fetch(Ln(n.serverUrl,"/console/api-keys",a),{headers:{Authorization:`Bearer ${n.token}`}});if(!l.ok)throw new Error("Failed to fetch API keys");return l.json()},enabled:!!t&&!!n})}function IY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async i=>{if(!e||!t)throw new Error("Not connected");const a=new URLSearchParams;n&&a.set("instanceId",n);const l=await fetch(Ln(t.serverUrl,"/console/api-keys",a),{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"Content-Type":"application/json"},body:JSON.stringify(i)});if(!l.ok)throw new Error("Failed to create API key");return l.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","api-keys"]})}})}function PY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async i=>{if(!e||!t)throw new Error("Not connected");const a=new URLSearchParams;n&&a.set("instanceId",n);const l=await fetch(Ln(t.serverUrl,`/console/api-keys/${Sa(i)}`,a),{method:"DELETE",headers:{Authorization:`Bearer ${t.token}`}});if(!l.ok)throw new Error("Failed to revoke API key");return l.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","api-keys"]})}})}function DY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async i=>{if(!e||!t)throw new Error("Not connected");const a=new URLSearchParams;n&&a.set("instanceId",n);const l=await fetch(Ln(t.serverUrl,"/console/api-keys/bulk-revoke",a),{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"Content-Type":"application/json"},body:JSON.stringify(i)});if(!l.ok)throw new Error("Failed to bulk revoke API keys");return l.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","api-keys"]})}})}function zY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async i=>{if(!e||!t)throw new Error("Not connected");const a=new URLSearchParams;n&&a.set("instanceId",n);const l=await fetch(Ln(t.serverUrl,`/console/api-keys/${Sa(i)}/rotate`,a),{method:"POST",headers:{Authorization:`Bearer ${t.token}`}});if(!l.ok)throw new Error("Failed to rotate API key");return l.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","api-keys"]})}})}function LY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async i=>{if(!e||!t)throw new Error("Not connected");const a=new URLSearchParams;n&&a.set("instanceId",n);const l=await fetch(Ln(t.serverUrl,`/console/api-keys/${Sa(i)}/rotate/stage`,a),{method:"POST",headers:{Authorization:`Bearer ${t.token}`}});if(!l.ok)throw new Error("Failed to stage-rotate API key");return l.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","api-keys"]})}})}function UY(e={}){const{config:t}=Dt();return Wn({queryKey:Jn.storage({prefix:e.prefix,cursor:e.cursor,limit:e.limit}),queryFn:async()=>{if(!t)throw new Error("Not connected");const n=new URLSearchParams;e.prefix&&n.set("prefix",e.prefix),e.cursor&&n.set("cursor",e.cursor),e.limit&&n.set("limit",String(e.limit));const s=await fetch(Ln(t.serverUrl,"/console/storage",n),{method:"GET",headers:{Authorization:`Bearer ${t.token}`}});if(!s.ok)throw new Error("Failed to list blobs");return s.json()},enabled:!!t,refetchInterval:_i(e.refetchIntervalMs,3e4)})}function $Y(){const{config:e}=Dt(),t=_r();return is({mutationFn:async n=>{if(!e)throw new Error("Not connected");const s=encodeURIComponent(n),i=await fetch(Ln(e.serverUrl,`/console/storage/${s}`,new URLSearchParams),{method:"DELETE",headers:{Authorization:`Bearer ${e.token}`}});if(!i.ok)throw new Error("Failed to delete blob");return i.json()},onSuccess:()=>{t.invalidateQueries({queryKey:["console","storage"]})}})}function BY(){const{config:e}=Dt();return async t=>{if(!e)throw new Error("Not connected");const n=encodeURIComponent(t),s=await fetch(Ln(e.serverUrl,`/console/storage/${n}/download`,new URLSearchParams),{method:"GET",headers:{Authorization:`Bearer ${e.token}`}});if(!s.ok)throw new Error("Failed to download blob");const i=await s.blob(),a=URL.createObjectURL(i),l=document.createElement("a");l.href=a,l.download=t.split("/").pop()||t,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(a)}}const FY="console:partition-id";function sf(){const[e,t]=pi(FY,""),n=e.trim();return _.useMemo(()=>({partitionId:n.length>0?n:void 0,rawPartitionId:e,setPartitionId:t,clearPartitionId:()=>t("")}),[n,e,t])}const VC={refreshInterval:5,timeFormat:"relative",showSparklines:!0,pageSize:20};function of(){const[e,t]=pi("console:preferences",VC);return{preferences:e,setPreferences:t,updatePreference:(i,a)=>{t(l=>({...l,[i]:a}))},resetPreferences:()=>{t(VC)}}}const HY=[{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"}],qY=[{value:10,label:"10"},{value:20,label:"20"},{value:50,label:"50"},{value:100,label:"100"}],gx="syncular-console-root";function VY(e){e.classList.add(gx)}const KY=[{suffix:"",label:"Command"},{suffix:"/stream",label:"Stream"},{suffix:"/fleet",label:"Fleet"},{suffix:"/ops",label:"Ops"},{suffix:"/storage",label:"Storage"},{suffix:"/config",label:"Config"}];function GY(e){const t=e?.trim()??"";return!t||t==="/"?"":(t.startsWith("/")?t:`/${t}`).replace(/\/+$/g,"")}function $y(e,t){return e?t?`${e}${t}`:e:t||"/"}function ZY({basePath:e,appHref:t,modeBadge:n}){const{connect:s,config:i,isConnected:a,isConnecting:l}=Dt(),{preferences:f}=of(),{instanceId:d,rawInstanceId:p,setInstanceId:g,clearInstanceId:y}=Lt(),{partitionId:b,rawPartitionId:x,setPartitionId:S,clearPartitionId:w}=sf(),T=vr({select:P=>P.location.pathname}),{data:C}=rf({refetchIntervalMs:f.refreshInterval*1e3,partitionId:b,instanceId:d}),O=GY(e),N=_.useMemo(()=>KY.map(P=>({...P,id:$y(O,P.suffix)})),[O]),R=$y(O,""),M=$y(O,"/config"),L=l?"connecting":a?"connected":i?"disconnected":"not-configured",j=N.find(P=>P.suffix===""?T===R||T===`${R}/`:T.startsWith(P.id))?.id??R,A=C?[{label:"HEAD",value:`#${C.maxCommitSeq}`},{label:"COMMITS",value:`${C.commitCount}`},{label:"CHANGES",value:`${C.changeCount}`},{label:"CLIENTS",value:`${C.activeClientCount}/${C.clientCount}`}]:[];return h.jsxs("div",{className:`${gx} h-screen bg-background text-foreground flex flex-col`,children:[h.jsx(OZ,{brand:h.jsx(xc,{to:R,children:h.jsx(kZ,{label:"console"})}),center:h.jsx(EZ,{items:N,activeId:j,renderItem:(P,{active:Z})=>h.jsx(xc,{to:P.id,children:h.jsx(sk,{active:Z,children:P.label})},P.id)}),right:h.jsxs("div",{className:"flex items-center gap-2",children:[n?h.jsx(mn,{variant:"flow",className:"hidden md:inline-flex px-2 py-1 text-[10px]",children:n}):null,h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("span",{className:"font-mono text-[9px] text-neutral-500 uppercase tracking-wide",children:"Instance"}),h.jsx(Gn,{variant:"mono",value:p,onChange:P=>g(P.target.value),onBlur:P=>g(P.target.value.trim()),placeholder:"all",className:"h-7 w-[110px] px-2 py-1"}),d?h.jsx(Oe,{variant:"ghost",size:"sm",className:"h-7 px-2 text-[10px]",onClick:y,children:"All"}):null]}),h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("span",{className:"font-mono text-[9px] text-neutral-500 uppercase tracking-wide",children:"Partition"}),h.jsx(Gn,{variant:"mono",value:x,onChange:P=>S(P.target.value),onBlur:P=>S(P.target.value.trim()),placeholder:"all",className:"h-7 w-[110px] px-2 py-1"}),b?h.jsx(Oe,{variant:"ghost",size:"sm",className:"h-7 px-2 text-[10px]",onClick:w,children:"All"}):null]}),h.jsx(R8,{state:L}),h.jsx(xc,{to:M,children:h.jsx(Oe,{variant:T===M?"secondary":"ghost",size:"icon",children:h.jsx(q8,{className:"h-3 w-3"})})}),t?h.jsxs("a",{href:t,className:wZ,children:[h.jsx(F8,{className:"h-3 w-3"}),"Go to app"]}):null]})}),h.jsx("main",{className:"flex-1 overflow-auto pb-[32px]",children:h.jsx("div",{className:"min-h-full",children:a||T===M?h.jsx("div",{style:{animation:"pageIn 0.3s ease-out"},children:h.jsx(YN,{})},T):h.jsx(YY,{configPath:M,hasSavedConfig:!!i,isConnecting:l,onConnect:()=>{s()}})})}),a&&h.jsx($j,{isLive:a,metrics:A,uptime:"--"})]})}function YY({configPath:e,hasSavedConfig:t,isConnecting:n,onConnect:s}){return h.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[h.jsx("p",{className:"mb-4 text-foreground-muted",children:"Not connected to a @syncular server"}),h.jsxs("div",{className:"flex items-center gap-2",children:[t&&h.jsx(Oe,{variant:"default",onClick:s,disabled:n,children:n?"Connecting...":"Connect"}),h.jsx(xc,{to:e,children:h.jsx(Oe,{variant:"link",children:"Configure connection"})})]})]})}const lo=RH({component:ZY});function XY(){return typeof window>"u"?!1:new URLSearchParams(window.location.search).get("swServer")==="1"}function QY(e={}){const{maxEvents:t=100,enabled:n=!0,staleAfterMs:s=65e3,replayLimit:i=100,partitionId:a,instanceId:l}=e,{config:f,isConnected:d}=Dt(),{instanceId:p}=Lt(),g=l??p,[y,b]=_.useState([]),[x,S]=_.useState(!1),[w,T]=_.useState("disconnected"),[C,O]=_.useState(null),N=_.useRef(null),R=_.useRef(null),M=_.useRef(null),L=_.useRef(0),j=_.useRef(0),A=_.useRef(null),P=_.useRef(null),Z=_.useCallback(()=>{b([]),A.current=null,P.current=null},[]);return _.useEffect(()=>{if(!n||!d||!f?.serverUrl||!f?.token)return;let B=!1;const z=Number.isFinite(i)?Math.max(1,Math.min(500,Math.floor(i))):100;if(XY()||typeof WebSocket>"u"){T("connecting"),S(!1);let K=null,U=!1;const I=async()=>{if(!(B||U)){U=!0;try{const H=new URL(f.serverUrl,window.location.origin),W=H.pathname.endsWith("/")?H.pathname.slice(0,-1):H.pathname;H.pathname=`${W}/console/events`,H.search="",H.searchParams.set("limit",String(z)),H.searchParams.set("offset","0"),a&&H.searchParams.set("partitionId",a);const X=await fetch(H.toString(),{headers:{Authorization:`Bearer ${f.token}`}});if(!X.ok)throw new Error(`Live event polling failed (${X.status})`);const oe=await X.json(),pe=(Array.isArray(oe.items)?oe.items:[]).filter(Me=>g?Me.instanceId===g:!0).sort((Me,_e)=>Me.eventId-_e.eventId),xe=P.current??-1,de=pe.filter(Me=>Me.eventId>xe);if(de.length>0){const Me=de.map(ne=>({type:ne.eventType,timestamp:ne.createdAt,data:ne})).reverse();b(ne=>[...Me,...ne].slice(0,t));const _e=de[de.length-1];P.current=_e.eventId,A.current=_e.createdAt}else if(pe.length>0){const Me=pe[pe.length-1];P.current=Math.max(P.current??-1,Me.eventId),A.current=Me.createdAt}O(null),S(!0),T("connected")}catch(H){B||(S(!1),T("disconnected"),O(H instanceof Error?H:new Error("Live event polling failed")))}finally{U=!1}}};return I(),K=setInterval(()=>{I()},2e3),()=>{B=!0,K&&clearInterval(K),S(!1),T("disconnected")}}const Y=()=>{R.current&&(clearTimeout(R.current),R.current=null)},ee=()=>{M.current&&(clearInterval(M.current),M.current=null)},D=()=>{if(B||R.current)return;L.current+=1;const K=Math.min(3e4,1e3*2**Math.max(0,L.current-1)),U=Math.floor(K*.2*Math.random()),I=K+U;R.current=setTimeout(()=>{R.current=null,B||q()},I)},V=()=>{j.current=Date.now(),S(!0),T("connected")},q=()=>{if(B)return;T("connecting"),Y();const K=(()=>{const I=new URL(f.serverUrl,window.location.origin);I.protocol=I.protocol==="https:"?"wss:":"ws:";const H=I.pathname.endsWith("/")?I.pathname.slice(0,-1):I.pathname;return I.pathname=`${H}/console/events/live`,I.search="",I.searchParams.set("token",f.token),A.current&&I.searchParams.set("since",A.current),I.searchParams.set("replayLimit",String(z)),a&&I.searchParams.set("partitionId",a),g&&I.searchParams.set("instanceId",g),I.toString()})(),U=new WebSocket(K);N.current=U,U.onopen=()=>{if(B){U.close();return}L.current=0,V(),O(null),ee(),M.current=setInterval(()=>{const I=N.current;if(!I||I.readyState!==WebSocket.OPEN)return;const H=j.current;!H||Date.now()-H<=s||(S(!1),T("stale"),I.close())},1e3)},U.onclose=()=>{B||(S(!1),T("disconnected"),ee(),D())},U.onerror=()=>{B||O(new Error("WebSocket connection failed"))},U.onmessage=I=>{try{const H=JSON.parse(I.data),W=H.type;if(V(),W==="connected"||W==="heartbeat")return;const X={type:W,timestamp:H.timestamp||new Date().toISOString(),data:H};if(a&&X.data.partitionId!==a||g&&X.data.instanceId!==g)return;const oe=Date.parse(A.current??""),se=Date.parse(X.timestamp);Number.isFinite(se)&&(!Number.isFinite(oe)||se>oe)&&(A.current=X.timestamp),b(pe=>[X,...pe].slice(0,t))}catch{}}};return q(),()=>{B=!0,Y(),ee(),N.current&&(N.current.close(),N.current=null),S(!1),T("disconnected")}},[n,d,f?.serverUrl,f?.token,t,a,g,i,s]),{events:y,isConnected:x,connectionState:w,error:C,clearEvents:Z}}function WY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async()=>{if(!e||!t)throw new Error("Not connected");const i=new URLSearchParams;n&&i.set("instanceId",n);const a=i.toString(),l=await fetch(`${t.serverUrl}/console/events${a?`?${a}`:""}`,{method:"DELETE",headers:{Authorization:`Bearer ${t.token}`}});if(!l.ok)throw new Error("Failed to clear events");return l.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","events"]})}})}const JY=_.createContext(null);function pk(){const[e,t]=pi("console:time-range","24h");return{range:e,setRange:t}}const eX=[{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 tX(e){const t=e.toLowerCase();for(const n of eX)if(t.includes(n.hint))return n.type;return"client"}function nX(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 rX(e,t){return typeof e.lagCommitCount=="number"?Math.max(0,e.lagCommitCount):t?Math.max(0,t.maxCommitSeq-e.cursor):0}function sX(e,t){return e.activityState==="stale"?"offline":t>0?"syncing":"online"}function oX(e,t){return e.length<=16?e:`${e.slice(0,12)}-${t+1}`}function iX(e,t,n={}){const s=n.maxNodes??10;return e.slice(0,s).map((i,a)=>{const l=rX(i,t),f=sX(i,l);return{id:oX(i.clientId,a),type:tX(i.clientId),status:f,cursor:Math.max(0,i.cursor),actor:i.actorId,mode:i.connectionMode,dialect:nX(i.clientId),scopes:Object.keys(i.effectiveScopes||{}),lastSeen:i.updatedAt}})}const aX={enabled:!1,thresholds:{p90Latency:500,errorRate:5,clientLag:100}};function KC(e,t="relative"){if(t==="absolute")return new Date(e).toLocaleString();const n=new Date(e),i=new Date().getTime()-n.getTime(),a=Math.floor(i/1e3);return a<60?`${a}s ago`:a<3600?`${Math.floor(a/60)}m ago`:a<86400?`${Math.floor(a/3600)}h ago`:`${Math.floor(a/86400)}d ago`}function cX(e){const t=e.length>1&&e.endsWith("/")?e.slice(0,-1):e;return t==="/console"||t.startsWith("/console/")?"/console/stream":"/stream"}function lX(){const e=pp(),t=_.useMemo(()=>typeof window>"u"?"/stream":cX(window.location.pathname),[]),n=pk(),{range:s}=n,{preferences:i}=of(),{partitionId:a}=sf(),l=i.refreshInterval*1e3,[f]=pi("console:alert-config",aX),[d,p]=_.useState("1h"),{data:g}=rf({refetchIntervalMs:l,partitionId:a}),{data:y}=bY({range:s,partitionId:a},{refetchIntervalMs:l}),{data:b}=xY({range:s,partitionId:a},{refetchIntervalMs:l}),{data:x}=SY({limit:5,partitionId:a},{refetchIntervalMs:l}),{data:S}=hk({limit:12,offset:0,partitionId:a},{refetchIntervalMs:l}),{events:w,isConnected:T}=QY({maxEvents:8,partitionId:a}),C=_.useMemo(()=>{const z=y?.buckets??[];let Q=0,Y=0;for(const D of z)Q+=D.pushCount+D.pullCount,Y+=D.errorCount;const ee=Q>0?Y/Q*100:0;return{totalEvents:Q,errorRate:ee}},[y?.buckets]),O=_.useMemo(()=>S?.items?iX(S.items,g,{maxNodes:12}):[],[S?.items,g]),N=O.filter(z=>z.status!=="offline").length,R=O.filter(z=>z.status==="offline").length,M=_.useMemo(()=>g?[{label:"Ops (Range)",value:C.totalEvents,color:"flow"},{label:"P50 Latency",value:b?.push?.p50??0,unit:"ms",color:"healthy"},{label:"Error Rate",value:`${C.errorRate.toFixed(1)}%`,color:C.errorRate>0?"offline":"muted"},{label:"Active Clients",value:g.activeClientCount,color:"syncing"},{label:"Pending",value:g.maxActiveClientCursor!==null&&g.maxCommitSeq>0?g.maxCommitSeq-(g.minActiveClientCursor??0):0,color:"relay"}]:[],[g,b,C.errorRate,C.totalEvents]),L=_.useMemo(()=>w.map(z=>({type:z.type.toUpperCase(),actor:z.data?.actorId??"",table:(z.data?.tables??[])[0]??"",time:KC(z.timestamp,i.timeFormat)})),[w,i.timeFormat]),j=_.useMemo(()=>{const z=y?.buckets;if(!z?.length)return[];const Q=Math.max(...z.map(Y=>Math.max(Y.pushCount,Y.pullCount)),1);return z.map(Y=>({pushPercent:Q>0?Y.pushCount/Q*100:0,pullPercent:Q>0?Y.pullCount/Q*100:0}))},[y?.buckets]),A=_.useMemo(()=>{if(!b)return[];const z=Math.max(b.push.p50,b.push.p90,b.push.p99,b.pull.p50,b.pull.p90,b.pull.p99,1);return[{label:"P50",pushMs:b.push.p50,pullMs:b.pull.p50,pushBarPercent:b.push.p50/z*100,pullBarPercent:b.pull.p50/z*100},{label:"P90",pushMs:b.push.p90,pullMs:b.pull.p90,pushBarPercent:b.push.p90/z*100,pullBarPercent:b.pull.p90/z*100},{label:"P99",pushMs:b.push.p99,pullMs:b.pull.p99,pushBarPercent:b.push.p99/z*100,pullBarPercent:b.pull.p99/z*100}]},[b]),P=_.useMemo(()=>x?.items?x.items.map(z=>({seq:z.commitSeq,actor:z.actorId,changes:z.changeCount,tables:(z.affectedTables??[]).join(", "),time:KC(z.createdAt,i.timeFormat)})):[],[x?.items,i.timeFormat]),Z=_.useMemo(()=>Math.max(0,100-C.errorRate),[C.errorRate]),B=_.useMemo(()=>{if(!f.enabled||!g)return[];const z=[];return b?.push?.p90&&b.push.p90>f.thresholds.p90Latency&&z.push(`P90 push latency (${b.push.p90}ms) exceeds threshold (${f.thresholds.p90Latency}ms)`),g.minActiveClientCursor!==null&&g.maxCommitSeq-g.minActiveClientCursor>f.thresholds.clientLag&&z.push(`Client lag (${g.maxCommitSeq-g.minActiveClientCursor}) exceeds threshold (${f.thresholds.clientLag})`),C.errorRate>f.thresholds.errorRate&&z.push(`Error rate (${C.errorRate.toFixed(1)}%) exceeds threshold (${f.thresholds.errorRate}%)`),z},[f,g,b,C.errorRate]);return g?h.jsx(JY.Provider,{value:n,children:h.jsxs("div",{className:"flex flex-col",children:[B.length>0&&h.jsx("div",{className:"px-6 pb-4",children:h.jsxs(In,{variant:"destructive",children:[h.jsx(tf,{children:"Threshold Exceeded"}),h.jsx(Pn,{children:B.map((z,Q)=>h.jsx("span",{className:"block",children:z},Q))})]})}),h.jsx(LA,{clients:O,totalNodes:O.length+2,onlineCount:N,offlineCount:R,relayClientIds:[]}),h.jsx(Zj,{items:M}),h.jsxs("div",{className:"flex",children:[h.jsxs("div",{className:"flex-1 min-w-0 flex flex-col",children:[h.jsx("div",{className:"border-b border-border border-r border-border",children:h.jsx(xj,{bars:j,activeRange:d,onRangeChange:p})}),h.jsx("div",{className:"border-b border-border border-r border-border",children:h.jsx(Yj,{buckets:A,successRate:Z})}),h.jsx("div",{className:"border-r border-border",children:h.jsx(Bj,{commits:P,onViewAll:()=>e({href:t})})})]}),h.jsx(Xj,{entries:L,isConnected:T,maxVisible:20,maxHeight:"calc(100vh - 200px)"})]})]})}):h.jsx("div",{className:"flex items-center justify-center py-24",children:h.jsx(Pt,{size:"lg"})})}function uX(){return h.jsx(lX,{})}function fX({children:e}){return h.jsxs("div",{className:"space-y-4 px-5 py-5",children:[h.jsx(dX,{}),h.jsx(yX,{}),h.jsx(vX,{}),e]})}function dX(){const{clearError:e,config:t,connect:n,disconnect:s,error:i,isConnected:a,isConnecting:l}=Dt(),[f,d]=_.useState(t?.serverUrl??"/api"),[p,g]=_.useState(t?.token??""),[y,b]=_.useState(null),[x,S]=_.useState(!1),[w,T]=_.useState(null),[C,O]=pi("console:disconnect-clear-saved-config",!1);_.useEffect(()=>{const j=new URLSearchParams(window.location.search),A=j.get("token"),P=j.get("server");A&&(g(A),window.history.replaceState({},"",window.location.pathname)),P&&d(P)},[]),_.useEffect(()=>{t?.serverUrl&&d(t.serverUrl),t?.token&&g(t.token)},[t?.serverUrl,t?.token]),_.useEffect(()=>{T(null)},[]);const N=async()=>{e(),b(null);const j=await n({serverUrl:f.trim(),token:p.trim()},{persistOverride:!0});T(j?"Connected successfully and configuration saved.":"Failed to connect with the provided settings.")},R=()=>{s({clearSavedConfig:C}),C&&(d("/api"),g("")),T(C?"Disconnected and saved credentials cleared.":"Disconnected."),b(null)},M=async()=>{S(!0),b(null),T(null);const j=performance.now();try{const A=f.trim(),P=p.trim();if(!A||!P)throw new Error("Missing server URL or token");if(!(await fetch(`${A}/console/stats`,{headers:{Authorization:`Bearer ${P}`}})).ok)throw new Error("Failed to connect");b(Math.round(performance.now()-j))}catch{b(-1)}finally{S(!1)}},L=i??w??(y!==null?y<0?"Connection failed":`Connection successful (${y}ms latency)`:void 0);return h.jsx(Hj,{isConnected:a,isConnecting:l,isTestingConnection:x,serverUrl:f,onServerUrlChange:d,consoleToken:p,onConsoleTokenChange:g,onSaveAndConnect:N,onDisconnect:R,onTestConnection:M,statusMessage:L,children:h.jsx("div",{className:"px-5 pb-5 -mt-2",children:h.jsxs("div",{className:"flex items-center justify-between rounded-md border border-border px-3 py-2",children:[h.jsxs("div",{children:[h.jsx("p",{className:"font-mono text-[10px] text-neutral-400",children:"Clear saved credentials on disconnect"}),h.jsx("p",{className:"font-mono text-[9px] text-neutral-500",children:"Removes stored server URL and token from this browser."})]}),h.jsx(wp,{checked:C,onCheckedChange:O})]})})})}const hX=1440*60*1e3;function GC(e){const t=e.trim();if(!t)return null;const n=Number.parseInt(t,10);return!Number.isInteger(n)||n<=0?null:n}function By(e){if(!e)return"Never";const t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():"Invalid date"}function pX(e){return e.length===0?"all scopes":e.length<=2?e.join(", "):`${e.slice(0,2).join(", ")} +${e.length-2}`}function mX(e,t){if(e.revokedAt)return"revoked";if(!e.expiresAt)return"active";const n=Date.parse(e.expiresAt);if(!Number.isFinite(n))return"active";const s=Date.now();return n<=s?"expired":n<=s+t*hX?"expiring":"active"}function gX(e){return e==="revoked"?"destructive":e==="expired"?"offline":e==="expiring"?"syncing":"healthy"}function yX(){const[e,t]=_.useState("all"),[n,s]=_.useState("all"),[i,a]=_.useState("14"),[l,f]=_.useState(!1),[d,p]=_.useState(!1),[g,y]=_.useState(""),[b,x]=_.useState("relay"),[S,w]=_.useState(""),[T,C]=_.useState(""),[O,N]=_.useState(""),[R,M]=_.useState(null),[L,j]=_.useState([]),[A,P]=_.useState(null),[Z,B]=_.useState(null),[z,Q]=_.useState(null),[Y,ee]=_.useState(null),[D,V]=_.useState(null),[q,K]=_.useState(null),[U,I]=_.useState(null),H=_.useMemo(()=>GC(i),[i]),W=H??14,X=_.useMemo(()=>GC(O),[O]),oe=O.trim().length>0,se=!oe||X!==null,pe=_.useMemo(()=>({type:e==="all"?void 0:e,status:n==="all"?void 0:n,expiresWithinDays:n==="expiring"?W:void 0}),[e,n,W]),{data:xe,isLoading:de,error:Me}=MY(pe),_e=IY(),ne=DY(),he=PY(),ae=zY(),we=LY();_.useEffect(()=>{const me=new Set((xe?.items??[]).map(Te=>Te.keyId));j(Te=>Te.filter(qe=>me.has(qe)))},[xe?.items]);const ve=async()=>{try{const me=T.split(",").map(qe=>qe.trim()).filter(qe=>qe.length>0),Te=await _e.mutateAsync({name:g,keyType:b,actorId:S||void 0,scopeKeys:me.length>0?me:void 0,expiresInDays:oe?X??void 0:void 0});M(Te.secretKey),y(""),w(""),C(""),N("")}catch{}},Se=me=>{navigator.clipboard.writeText(me),B(me),setTimeout(()=>B(null),2e3)},ye=async()=>{if(z)try{await he.mutateAsync(z)}finally{Q(null)}},Ue=async()=>{if(L.length!==0)try{const me=await ne.mutateAsync({keyIds:L});P(me),j([])}catch{}},Ie=async()=>{if(Y)try{const me=await we.mutateAsync(Y.keyId);V({oldKeyId:Y.keyId,oldKeyName:Y.name,secretKey:me.secretKey})}catch{}},Ee=async()=>{if(D)try{await he.mutateAsync(D.oldKeyId)}finally{V(null),ee(null)}},Ve=async()=>{if(q)try{const me=await ae.mutateAsync(q);I(me.secretKey)}finally{K(null)}};if(de)return h.jsx("div",{className:"flex h-[200px] items-center justify-center",children:h.jsx(Pt,{size:"lg"})});if(Me)return h.jsx("div",{className:"flex h-[200px] items-center justify-center",children:h.jsxs("p",{className:"text-danger",children:["Failed to load API keys: ",Me.message]})});const Xe=(xe?.items??[]).filter(me=>me.revokedAt===null).map(me=>me.keyId),Be=Xe.length>0&&Xe.every(me=>L.includes(me)),We=L.length>0,He=(xe?.items??[]).filter(me=>L.includes(me.keyId)).map(me=>me.name);return h.jsxs(h.Fragment,{children:[h.jsxs(Wb,{title:"API Keys",description:"Issue, rotate, revoke, and audit key lifecycle state.",actions:h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs(Oe,{size:"sm",variant:"destructive",onClick:()=>p(!0),disabled:L.length===0,children:["Revoke Selected (",L.length,")"]}),h.jsx(Oe,{size:"sm",onClick:()=>f(!0),children:"Create Key"})]}),children:[h.jsxs("div",{className:"mb-4 grid gap-3 lg:grid-cols-3",children:[h.jsxs(ms,{children:[h.jsx(ts,{children:"Type filter"}),h.jsxs(dh,{value:[e],multiple:!1,onValueChange:me=>{const Te=me.find(qe=>typeof qe=="string");(Te==="all"||Te==="relay"||Te==="proxy"||Te==="admin")&&t(Te)},children:[h.jsx(Dr,{value:"all",children:"all"}),h.jsx(Dr,{value:"relay",children:"relay"}),h.jsx(Dr,{value:"proxy",children:"proxy"}),h.jsx(Dr,{value:"admin",children:"admin"})]})]}),h.jsxs(ms,{children:[h.jsx(ts,{children:"Status filter"}),h.jsxs(dh,{value:[n],multiple:!1,onValueChange:me=>{const Te=me.find(qe=>typeof qe=="string");(Te==="all"||Te==="active"||Te==="revoked"||Te==="expiring")&&s(Te)},children:[h.jsx(Dr,{value:"all",children:"all"}),h.jsx(Dr,{value:"active",children:"active"}),h.jsx(Dr,{value:"revoked",children:"revoked"}),h.jsx(Dr,{value:"expiring",children:"expiring"})]})]}),h.jsxs(ms,{children:[h.jsx(ts,{htmlFor:"api-key-expiring-window",children:"Expiring window (days)"}),h.jsx(mc,{children:"Used when status filter is set to expiring."}),h.jsx(Gn,{id:"api-key-expiring-window",placeholder:"14",value:i,inputMode:"numeric",onChange:me=>a(me.target.value)}),H===null&&i.trim().length>0?h.jsx("p",{className:"font-mono text-[10px] text-offline",children:"Enter a positive whole number."}):null]})]}),xe?.items.length===0?h.jsx(Xb,{message:"No API keys match the current filters."}):h.jsxs(nl,{children:[h.jsx(rl,{children:h.jsxs(os,{children:[h.jsx(ht,{className:"w-[28px]",children:h.jsx($v,{checked:Be,indeterminate:!Be&&We&&Xe.length>0,onCheckedChange:me=>{j(me?Xe:[])},"aria-label":"Select all active keys"})}),h.jsx(ht,{className:"w-[100px]",children:"NAME"}),h.jsx(ht,{className:"w-[55px]",children:"TYPE"}),h.jsx(ht,{className:"w-[90px]",children:"KEY PREFIX"}),h.jsx(ht,{className:"w-[80px]",children:"ACTOR"}),h.jsx(ht,{className:"w-[100px]",children:"SCOPES"}),h.jsx(ht,{className:"w-[120px]",children:"CREATED"}),h.jsx(ht,{className:"w-[120px]",children:"LAST USED"}),h.jsx(ht,{className:"w-[120px]",children:"EXPIRES"}),h.jsx(ht,{className:"flex-1",children:"STATUS"})]})}),h.jsx(sl,{children:(xe?.items??[]).map(me=>{const Te=mX(me,W);return h.jsxs(os,{className:"group relative",children:[h.jsx(pt,{className:"w-[28px]",children:h.jsx($v,{checked:L.includes(me.keyId),onCheckedChange:qe=>{j(mt=>qe?[...new Set([...mt,me.keyId])]:mt.filter(lt=>lt!==me.keyId))},"aria-label":`Select ${me.name}`,disabled:me.revokedAt!==null})}),h.jsx(pt,{className:"w-[100px] font-medium",children:me.name}),h.jsx(pt,{className:"w-[55px]",children:h.jsx(mn,{variant:me.keyType==="admin"?"flow":me.keyType==="proxy"?"ghost":"relay",children:me.keyType})}),h.jsx(pt,{className:"w-[90px]",children:h.jsxs("code",{className:"font-mono text-[11px]",children:[me.keyPrefix,"..."]})}),h.jsx(pt,{className:"w-[80px] text-neutral-500",children:me.actorId??"-"}),h.jsx(pt,{className:"w-[100px] text-neutral-500",children:h.jsx("code",{className:"font-mono text-[10px]",children:pX(me.scopeKeys)})}),h.jsx(pt,{className:"w-[120px] text-neutral-500",children:By(me.createdAt)}),h.jsx(pt,{className:"w-[120px] text-neutral-500",children:By(me.lastUsedAt)}),h.jsx(pt,{className:"w-[120px] text-neutral-500",children:By(me.expiresAt)}),h.jsx(pt,{className:"flex-1",children:h.jsx(mn,{variant:gX(Te),children:Te})}),me.revokedAt===null&&h.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[h.jsx("button",{type:"button",onClick:()=>ee(me),className:"px-1.5 py-0.5 rounded text-[9px] font-mono text-neutral-600 hover:text-white hover:bg-white/[0.05] cursor-pointer transition-colors",children:"stage"}),h.jsx("button",{type:"button",onClick:()=>K(me.keyId),className:"px-1.5 py-0.5 rounded text-[9px] font-mono text-neutral-600 hover:text-white hover:bg-white/[0.05] cursor-pointer transition-colors",children:"rotate"}),h.jsx("button",{type:"button",onClick:()=>Q(me.keyId),className:"px-1.5 py-0.5 rounded text-[9px] font-mono text-neutral-600 hover:text-offline hover:bg-offline/10 cursor-pointer transition-colors",children:"revoke"})]})]},me.keyId)})})]})]}),h.jsx($r,{open:l,onOpenChange:f,children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Create API Key"})}),R?h.jsx(ZC,{copiedKeyId:Z,onClose:()=>{M(null),f(!1)},onCopy:Se,secretKey:R,warning:"Copy this key now. You will not be able to view it again."}):h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[h.jsxs(ms,{children:[h.jsx(ts,{htmlFor:"api-key-name",children:"Name"}),h.jsx(Gn,{id:"api-key-name",placeholder:"Backend Relay Key",value:g,onChange:me=>y(me.target.value)})]}),h.jsxs(ms,{children:[h.jsx(ts,{children:"Key type"}),h.jsxs(dh,{value:[b],multiple:!1,onValueChange:me=>{const Te=me.find(qe=>typeof qe=="string");(Te==="relay"||Te==="proxy"||Te==="admin")&&x(Te)},children:[h.jsx(Dr,{value:"relay",children:"relay"}),h.jsx(Dr,{value:"proxy",children:"proxy"}),h.jsx(Dr,{value:"admin",children:"admin"})]})]}),h.jsxs(ms,{children:[h.jsx(ts,{htmlFor:"api-key-actor-id",children:"Actor ID (optional)"}),h.jsx(mc,{children:"Pin this key to a fixed actor ID"}),h.jsx(Gn,{id:"api-key-actor-id",placeholder:"actor-123",value:S,onChange:me=>w(me.target.value)})]}),h.jsxs(ms,{children:[h.jsx(ts,{htmlFor:"api-key-scope-keys",children:"Scope keys (optional)"}),h.jsx(mc,{children:"Comma-separated list of allowed scope keys"}),h.jsx(Gn,{id:"api-key-scope-keys",placeholder:"scope-a, scope-b",value:T,onChange:me=>C(me.target.value)})]}),h.jsxs(ms,{children:[h.jsx(ts,{htmlFor:"api-key-expires-days",children:"Expires in days (optional)"}),h.jsx(mc,{children:"Leave empty to keep the key non-expiring."}),h.jsx(Gn,{id:"api-key-expires-days",placeholder:"30",value:O,inputMode:"numeric",onChange:me=>N(me.target.value)}),se?null:h.jsx("p",{className:"font-mono text-[10px] text-offline",children:"Enter a positive whole number."})]}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>f(!1),children:"Cancel"}),h.jsx(Oe,{variant:"primary",onClick:ve,disabled:_e.isPending||!g||!se,children:_e.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Creating..."]}):"Create"})]})]})]})}),h.jsx($r,{open:d,onOpenChange:me=>{p(me),me||P(null)},children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Bulk Revoke API Keys"})}),A?h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-3",children:[h.jsx(In,{variant:"destructive",children:h.jsxs(Pn,{children:["Requested ",A.requestedCount," keys. Revoked"," ",A.revokedCount,", already revoked"," ",A.alreadyRevokedCount,", not found"," ",A.notFoundCount,"."]})}),h.jsx(Nn,{children:h.jsx(Oe,{variant:"primary",onClick:()=>{p(!1),P(null)},children:"Done"})})]}):h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-3",children:[h.jsx(In,{variant:"destructive",children:h.jsx(Pn,{children:"This revokes selected keys immediately and cannot be undone."})}),h.jsxs("p",{className:"font-mono text-[10px] text-neutral-500",children:["Selected keys: ",He.slice(0,5).join(", "),He.length>5?` +${He.length-5} more`:""]})]}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>p(!1),children:"Cancel"}),h.jsx(Oe,{variant:"destructive",onClick:Ue,disabled:ne.isPending||L.length===0,children:ne.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Revoking..."]}):"Revoke Selected"})]})]})]})}),h.jsx($r,{open:Y!==null||D!==null,onOpenChange:()=>{ee(null),V(null)},children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Stage Rotate API Key"})}),D?h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[h.jsx(In,{variant:"default",children:h.jsxs(Pn,{children:["Replacement key created for ",D.oldKeyName,". The old key is still active until you revoke it."]})}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("code",{className:"flex-1 rounded-md border border-border bg-surface p-3 font-mono text-[11px] text-white break-all",children:D.secretKey}),h.jsx(Oe,{variant:"default",size:"sm",onClick:()=>Se(D.secretKey),children:Z===D.secretKey?"Copied":"Copy"})]}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>{V(null),ee(null)},children:"Keep Old Key Active"}),h.jsx(Oe,{variant:"destructive",onClick:Ee,disabled:he.isPending,children:he.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Revoking Old Key..."]}):"Finalize and Revoke Old Key"})]})]}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"px-5 py-4",children:h.jsx("p",{className:"font-mono text-[10px] text-neutral-500",children:"Staged rotation creates a replacement key now and keeps the current key active until you explicitly revoke it."})}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>ee(null),children:"Cancel"}),h.jsx(Oe,{variant:"primary",onClick:Ie,disabled:we.isPending||!Y,children:we.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Staging..."]}):"Create Replacement Key"})]})]})]})}),h.jsx($r,{open:z!==null,onOpenChange:()=>Q(null),children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Revoke API Key"})}),h.jsx("div",{className:"px-5 py-4",children:h.jsx(In,{variant:"destructive",children:h.jsx(Pn,{children:"Revoking a key immediately invalidates it for all requests."})})}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>Q(null),children:"Cancel"}),h.jsx(Oe,{variant:"destructive",onClick:ye,disabled:he.isPending,children:he.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Revoking..."]}):"Revoke"})]})]})}),h.jsx($r,{open:q!==null||U!==null,onOpenChange:()=>{K(null),I(null)},children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Rotate API Key"})}),U?h.jsx(ZC,{copiedKeyId:Z,onClose:()=>I(null),onCopy:Se,secretKey:U,warning:"The previous key has been invalidated. Store this replacement securely."}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"px-5 py-4",children:h.jsx("p",{className:"font-mono text-[10px] text-neutral-500",children:"Rotating a key invalidates the previous secret immediately."})}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>K(null),children:"Cancel"}),h.jsx(Oe,{variant:"primary",onClick:Ve,disabled:ae.isPending,children:ae.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Rotating..."]}):"Rotate"})]})]})]})})]})}function vX(){const{preferences:e,updatePreference:t,resetPreferences:n}=of(),s=[{type:"filter",label:"Auto-refresh interval",options:HY.map(i=>({id:`${i.value}`,label:i.label})),activeId:`${e.refreshInterval}`,onActiveChange:i=>t("refreshInterval",Number.parseInt(i,10))},{type:"filter",label:"Items per page",options:qY.map(i=>({id:`${i.value}`,label:i.label})),activeId:`${e.pageSize}`,onActiveChange:i=>t("pageSize",Number.parseInt(i,10))},{type:"filter",label:"Time format",options:[{id:"relative",label:"Relative"},{id:"absolute",label:"Absolute"}],activeId:e.timeFormat,onActiveChange:i=>t("timeFormat",i)},{type:"toggle",label:"Show sparklines",description:"Display mini trend charts in dashboard metric cards",checked:e.showSparklines,onCheckedChange:i=>t("showSparklines",i)}];return h.jsx(Qj,{rows:s,onResetDefaults:n})}function ZC({copiedKeyId:e,onClose:t,onCopy:n,secretKey:s,warning:i}){return h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[h.jsx(In,{variant:"destructive",children:h.jsx(Pn,{children:i})}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("code",{className:"flex-1 rounded-md border border-border bg-surface p-3 font-mono text-[11px] text-white break-all",children:s}),h.jsx(Oe,{variant:"default",size:"sm",onClick:()=>n(s),children:e===s?"Copied":"Copy"})]}),h.jsx(Nn,{children:h.jsx(Oe,{variant:"primary",onClick:t,children:"Done"})})]})}function bX(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 xX(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 SX(e,t){if(t==="absolute")return new Date(e).toLocaleString();try{const n=new Date(e),i=new Date().getTime()-n.getTime(),a=Math.floor(i/1e3),l=Math.floor(a/60),f=Math.floor(l/60),d=Math.floor(f/24);return a<60?"just now":l<60?`${l}m ago`:f<24?`${f}h ago`:`${d}d ago`}catch{return e}}function _X(e,t,n){return{id:e.clientId,type:bX(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:xX(e.clientId),scopes:Object.keys(e.effectiveScopes??{}),lastSeen:SX(e.updatedAt,n)}}function wX({emptyState:e}={}){const[t,n]=_.useState(1),[s,i]=_.useState(null),{preferences:a}=of(),{partitionId:l}=sf(),f=a.pageSize,d=a.refreshInterval*1e3,{data:p,isLoading:g}=rf({refetchIntervalMs:d,partitionId:l}),{data:y,isLoading:b,error:x}=hk({limit:f,offset:(t-1)*f,partitionId:l},{refetchIntervalMs:d}),S=jY(),w=Math.ceil((y?.total??0)/f),T=p?.maxCommitSeq??0;_.useEffect(()=>{n(1)},[]);const C=async()=>{if(s)try{await S.mutateAsync({clientId:s,partitionId:l})}finally{i(null)}};if(b||g)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsx(Pt,{size:"lg"})});if(x)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsxs("p",{className:"text-danger",children:["Failed to load clients: ",x.message]})});const O=(y?.items??[]).map(N=>_X(N,T,a.timeFormat));return h.jsxs("div",{className:"flex flex-col gap-5 px-5 py-5",children:[O.length>0&&h.jsx(Jj,{clients:O,headSeq:T}),O.length===0?e??h.jsx(J8,{children:h.jsx(Xb,{message:"No clients yet"})}):h.jsx(Kj,{clients:O,headSeq:T,onEvict:N=>{const R=y?.items.find(M=>M.clientId===N);i(R?.clientId??N)}}),w>1&&h.jsx(px,{page:t,totalPages:w,totalItems:y?.total??0,onPageChange:n}),h.jsx($r,{open:s!==null,onOpenChange:()=>i(null),children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Evict Client"})}),h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[h.jsxs("p",{className:"font-mono text-[11px] text-neutral-300",children:["Are you sure you want to evict client"," ",h.jsxs("span",{className:"font-mono text-white",children:[s?.slice(0,12),"..."]}),"?"]}),h.jsx("p",{className:"font-mono text-[10px] text-neutral-500",children:"This will force the client to re-bootstrap on their next sync."})]}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>i(null),children:"Cancel"}),h.jsx(Oe,{variant:"destructive",onClick:C,disabled:S.isPending,children:S.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Evicting..."]}):"Evict"})]})]})})]})}const EX={latencyThresholdMs:1e3,errorRateThreshold:5,clientLagThreshold:50,enabled:!1};function TX(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 CX(e){const t=e.split(",").map(n=>n.trim()).filter(n=>n.length>0);return Array.from(new Set(t))}function RX(e){switch(e){case"notify_data_change":return"Notify";case"evict_client":return"Evict";case"compact":return"Compact";default:return"Prune"}}function YC(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function NX(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function jX(e){const t=YC(e.requestPayload),n=YC(e.resultPayload);if(e.operationType==="notify_data_change"){const a=NX(t?.tables),l=n?.commitSeq;return`${a.length} table${a.length===1?"":"s"} -> commit #${typeof l=="number"?l:"?"}`}if(e.operationType==="evict_client"){const a=n?.evicted===!0?"evicted":"not found";return`client ${e.targetClientId??"?"} ${a}`}if(e.operationType==="compact")return`${typeof n?.deletedChanges=="number"?n.deletedChanges:0} changes removed`;const s=typeof n?.deletedCommits=="number"?n.deletedCommits:0,i=typeof t?.watermarkCommitSeq=="number"?` at #${t.watermarkCommitSeq}`:"";return`${s} commits removed${i}`}function AX(e){const t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function kX(){const{partitionId:e}=sf();return h.jsxs("div",{className:"flex flex-col gap-4 px-5 py-5",children:[h.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[h.jsx(OX,{}),h.jsx(zX,{})]}),h.jsxs("div",{className:"grid gap-4 xl:grid-cols-3",children:[h.jsx(MX,{partitionId:e}),h.jsx(IX,{partitionId:e}),h.jsx(PX,{partitionId:e})]}),h.jsx(DX,{partitionId:e})]})}function OX(){const{data:e,isLoading:t,error:n}=CY();if(t)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsx(Pt,{size:"lg"})});if(n)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsxs("p",{className:"text-danger",children:["Failed to load handlers: ",n.message]})});const s=(e?.items??[]).map(i=>({table:i.table,dependsOn:i.dependsOn?.join(", ")??null,chunkTtl:i.snapshotChunkTtlMs?TX(i.snapshotChunkTtlMs):"default"}));return h.jsx(Gj,{handlers:s,tableCount:e?.items.length??0})}function MX({partitionId:e}){const[t,n]=_.useState(!1),[s,i]=_.useState(null),{data:a,isLoading:l}=rf({partitionId:e}),{data:f,isLoading:d,refetch:p}=RY({enabled:!1}),g=AY(),y=async()=>{n(!0),i(null),await p()},b=async()=>{const S=await g.mutateAsync();i(S.deletedCommits)};if(l)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsx(Pt,{size:"lg"})});const x=[{label:"Total commits",value:a?.commitCount??0},{label:"Commit range",value:`${a?.minCommitSeq??0} - ${a?.maxCommitSeq??0}`},{label:"Min active cursor",value:a?.minActiveClientCursor??"N/A",tone:"syncing"}];return h.jsxs(h.Fragment,{children:[h.jsx(Ep,{title:"Prune",description:"Delete commits that all clients have already synced. Pruning removes commits older than the oldest active client cursor.",dotColor:"syncing",stats:x,actionLabel:"Preview Prune",actionVariant:"destructive",onAction:y}),h.jsx($r,{open:t,onOpenChange:n,children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Prune Old Commits"})}),h.jsx("div",{className:"px-5 py-4 flex flex-col gap-4",children:s!==null?h.jsxs(In,{variant:"default",children:[h.jsx(tf,{children:"Pruning Complete"}),h.jsxs(Pn,{children:["Successfully deleted ",h.jsx("strong",{children:s})," commits."]})]}):d?h.jsx("div",{className:"flex items-center justify-center py-8",children:h.jsx(Pt,{size:"sm"})}):f?h.jsxs(h.Fragment,{children:[h.jsx(In,{variant:f.commitsToDelete>0?"destructive":"default",children:h.jsx(Pn,{children:f.commitsToDelete>0?h.jsxs(h.Fragment,{children:["This will delete"," ",h.jsx("strong",{children:f.commitsToDelete})," commits up to sequence"," ",h.jsxs("code",{className:"font-mono",children:["#",f.watermarkCommitSeq]}),"."]}):"No commits are eligible for pruning."})}),h.jsxs("div",{className:"flex flex-col gap-2",children:[h.jsxs("div",{className:"flex justify-between font-mono text-[11px]",children:[h.jsx("span",{className:"text-neutral-500",children:"Watermark commit seq:"}),h.jsxs("span",{className:"text-white",children:["#",f.watermarkCommitSeq]})]}),h.jsxs("div",{className:"flex justify-between font-mono text-[11px] items-center",children:[h.jsx("span",{className:"text-neutral-500",children:"Commits to delete:"}),h.jsx(mn,{variant:f.commitsToDelete>0?"offline":"ghost",children:f.commitsToDelete})]})]})]}):null}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>n(!1),children:s!==null?"Close":"Cancel"}),s===null&&h.jsx(Oe,{variant:"destructive",onClick:b,disabled:g.isPending||d||(f?.commitsToDelete??0)===0,children:g.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Pruning..."]}):"Prune Now"})]})]})})]})}function IX({partitionId:e}){const[t,n]=_.useState(!1),[s,i]=_.useState(null),{data:a,isLoading:l}=rf({partitionId:e}),f=kY(),d=()=>{n(!0),i(null)},p=async()=>{const y=await f.mutateAsync();i(y.deletedChanges)};if(l)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsx(Pt,{size:"lg"})});const g=[{label:"Total changes",value:a?.changeCount??0},{label:"Total commits",value:a?.commitCount??0}];return h.jsxs(h.Fragment,{children:[h.jsx(Ep,{title:"Compact",description:"Merge old changes to reduce storage space. Compaction merges multiple changes to the same row into a single change.",dotColor:"flow",stats:g,actionLabel:"Run Compaction",actionVariant:"primary",onAction:d}),h.jsx($r,{open:t,onOpenChange:n,children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Compact Changes"})}),h.jsx("div",{className:"px-5 py-4 flex flex-col gap-4",children:s!==null?h.jsxs(In,{variant:"default",children:[h.jsx(tf,{children:"Compaction Complete"}),h.jsxs(Pn,{children:["Successfully removed ",h.jsx("strong",{children:s})," redundant changes."]})]}):h.jsx(In,{variant:"default",children:h.jsx(Pn,{children:"Compaction will merge multiple changes to the same row, keeping only the most recent version. This is safe and can be run at any time."})})}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>n(!1),children:s!==null?"Close":"Cancel"}),s===null&&h.jsx(Oe,{variant:"primary",onClick:p,disabled:f.isPending,children:f.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Compacting..."]}):"Compact Now"})]})]})})]})}function PX({partitionId:e}){const[t,n]=_.useState(!1),[s,i]=_.useState("tasks"),[a,l]=_.useState(e??""),[f,d]=_.useState(null),[p,g]=_.useState(null),y=OY(),b=CX(s),x=[{label:"Next tables",value:b.length,tone:"syncing"},{label:"Last commit seq",value:f?`#${f.commitSeq}`:"—",tone:"syncing"},{label:"Last chunks cleared",value:f?.deletedChunks??"—"}],S=()=>{n(!0),g(null)},w=async()=>{if(b.length===0){g("Provide at least one table name.");return}g(null);const T=await y.mutateAsync({tables:b,partitionId:a.trim()||void 0});d(T)};return h.jsxs(h.Fragment,{children:[h.jsx(Ep,{title:"Notify Data Change",description:"Create a synthetic commit after external imports or direct DB writes so clients re-bootstrap for affected tables.",dotColor:"healthy",stats:x,actionLabel:"Notify Clients",actionVariant:"primary",onAction:S}),h.jsx($r,{open:t,onOpenChange:n,children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Notify External Data Change"})}),h.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4",children:[f?h.jsxs(In,{variant:"default",children:[h.jsx(tf,{children:"Notification Sent"}),h.jsxs(Pn,{children:["Created synthetic commit"," ",h.jsxs("strong",{children:["#",f.commitSeq]})," for"," ",h.jsx("strong",{children:f.tables.length})," table",f.tables.length===1?"":"s"," and cleared"," ",h.jsx("strong",{children:f.deletedChunks})," cached chunk",f.deletedChunks===1?"":"s","."]})]}):h.jsx(In,{variant:"default",children:h.jsx(Pn,{children:"Use this when data changed outside Syncular push flow. It invalidates cached snapshot chunks and forces clients to pull fresh data."})}),p?h.jsx(In,{variant:"destructive",children:h.jsx(Pn,{children:p})}):null,h.jsxs(ms,{children:[h.jsx(ts,{children:"Tables (comma-separated)"}),h.jsx(Gn,{value:s,onChange:T=>i(T.target.value),placeholder:"tasks, notes",disabled:y.isPending}),h.jsx(mc,{children:"Enter one or more table names affected by the external change."})]}),h.jsxs(ms,{children:[h.jsx(ts,{children:"Partition ID (optional)"}),h.jsx(Gn,{value:a,onChange:T=>l(T.target.value),placeholder:"default",disabled:y.isPending})]})]}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>n(!1),children:f?"Close":"Cancel"}),f?null:h.jsx(Oe,{variant:"primary",onClick:w,disabled:y.isPending,children:y.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Notifying..."]}):"Notify Data Change"})]})]})})]})}function DX({partitionId:e}){const[t,n]=_.useState("all"),{data:s,isLoading:i,error:a}=NY({limit:20,offset:0,operationType:t==="all"?void 0:t,partitionId:e},{refetchIntervalMs:5e3});return h.jsx(Wb,{title:"Operation Audit",description:"Recent prune/compact/notify/evict actions with actor and result context.",actions:h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Oe,{variant:t==="all"?"default":"ghost",size:"sm",onClick:()=>n("all"),children:"All"}),h.jsx(Oe,{variant:t==="prune"?"default":"ghost",size:"sm",onClick:()=>n("prune"),children:"Prune"}),h.jsx(Oe,{variant:t==="compact"?"default":"ghost",size:"sm",onClick:()=>n("compact"),children:"Compact"}),h.jsx(Oe,{variant:t==="notify_data_change"?"default":"ghost",size:"sm",onClick:()=>n("notify_data_change"),children:"Notify"}),h.jsx(Oe,{variant:t==="evict_client"?"default":"ghost",size:"sm",onClick:()=>n("evict_client"),children:"Evict"})]}),contentClassName:"pt-2",children:i?h.jsx("div",{className:"flex items-center justify-center py-10",children:h.jsx(Pt,{size:"lg"})}):a?h.jsx(In,{variant:"destructive",children:h.jsxs(Pn,{children:["Failed to load operation audit events: ",a.message]})}):(s?.items.length??0)===0?h.jsx("div",{className:"px-2 py-8 text-sm text-neutral-500",children:"No operation events found for this filter."}):h.jsx("div",{className:"overflow-x-auto",children:h.jsxs(nl,{children:[h.jsx(rl,{children:h.jsxs(os,{children:[h.jsx(ht,{children:"Time"}),h.jsx(ht,{children:"Type"}),h.jsx(ht,{children:"User"}),h.jsx(ht,{children:"Target"}),h.jsx(ht,{children:"Result"})]})}),h.jsx(sl,{children:(s?.items??[]).map((l,f)=>h.jsxs(os,{children:[h.jsx(pt,{className:"whitespace-nowrap text-xs text-neutral-400",children:AX(l.createdAt)}),h.jsx(pt,{children:h.jsx(mn,{variant:"ghost",children:RX(l.operationType)})}),h.jsx(pt,{className:"font-mono text-xs",children:l.consoleUserId??"system"}),h.jsx(pt,{className:"font-mono text-xs",children:l.targetClientId??l.partitionId??(l.operationType==="notify_data_change"?"partition default":"global")}),h.jsx(pt,{className:"font-mono text-xs text-neutral-300",children:jX(l)})]},`${l.operationId}:${l.createdAt}:${f}`))})]})})})}function zX(){const[e,t]=pi("console:alert-config",EX),n={p90Latency:e.latencyThresholdMs,errorRate:e.errorRateThreshold,clientLag:e.clientLagThreshold},s=a=>{t(l=>({...l,latencyThresholdMs:a.p90Latency,errorRateThreshold:a.errorRate,clientLagThreshold:a.clientLag}))},i=a=>{t(l=>({...l,enabled:a}))};return h.jsx(Uj,{enabled:e.enabled,onEnabledChange:i,thresholds:n,onThresholdsChange:s})}function LX(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 UX(e){const t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function $X(){const[e,t]=_.useState(""),[n,s]=_.useState(void 0),[i,a]=_.useState(void 0),[l,f]=_.useState([]),[d,p]=_.useState(null),{data:g,isLoading:y,error:b}=UY({prefix:n,cursor:i,limit:100}),x=$Y(),S=BY();function w(){const M=e.trim();s(M.length>0?M:void 0),a(void 0),f([])}function T(){t(""),s(void 0),a(void 0),f([])}function C(){g?.cursor&&(f(M=>[...M,i??""]),a(g.cursor))}function O(){f(M=>{const L=[...M],j=L.pop();return a(j&&j.length>0?j:void 0),L})}function N(){d&&x.mutate(d,{onSuccess:()=>p(null)})}if(y)return h.jsx("div",{className:"flex flex-col gap-4 px-5 py-5",children:h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsx(Pt,{size:"lg"})})});if(b)return h.jsx("div",{className:"flex flex-col gap-4 px-5 py-5",children:h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsxs("p",{className:"text-danger font-mono text-[11px]",children:["Failed to load storage items: ",b.message]})})});const R=g?.items??[];return h.jsxs("div",{className:"flex flex-col gap-4 px-5 py-5",children:[h.jsx(Wb,{title:"Storage",actions:h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Gn,{placeholder:"Prefix filter...",value:e,onChange:M=>t(M.target.value),onKeyDown:M=>{M.key==="Enter"&&w()},className:"h-7 w-48 text-xs"}),h.jsx(Oe,{variant:"default",size:"sm",onClick:w,children:"Filter"}),n&&h.jsx(Oe,{variant:"ghost",size:"sm",onClick:T,children:"Clear"})]}),children:R.length===0?h.jsx(Xb,{message:n?`No storage items matching prefix "${n}".`:"No storage items found."}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"overflow-x-auto",children:h.jsxs(nl,{children:[h.jsx(rl,{children:h.jsxs(os,{children:[h.jsx(ht,{children:"Key"}),h.jsx(ht,{children:"Size"}),h.jsx(ht,{children:"Type"}),h.jsx(ht,{children:"Uploaded"}),h.jsx(ht,{children:"Actions"})]})}),h.jsx(sl,{children:R.map(M=>h.jsxs(os,{children:[h.jsx(pt,{className:"font-mono text-xs max-w-[320px]",title:M.key,children:M.key}),h.jsx(pt,{className:"font-mono text-xs text-neutral-400 whitespace-nowrap",children:LX(M.size)}),h.jsx(pt,{children:M.httpMetadata?.contentType?h.jsx(mn,{variant:"ghost",children:M.httpMetadata.contentType}):h.jsx("span",{className:"text-neutral-500 text-xs",children:"--"})}),h.jsx(pt,{className:"whitespace-nowrap text-xs text-neutral-400",children:UX(M.uploaded)}),h.jsx(pt,{children:h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx(Oe,{variant:"ghost",size:"sm",onClick:()=>{S(M.key)},children:"Download"}),h.jsx(Oe,{variant:"ghost",size:"sm",onClick:()=>p(M.key),children:"Delete"})]})})]},M.key))})]})}),h.jsxs("div",{className:"flex items-center justify-between px-2 py-2",children:[h.jsx(Oe,{variant:"ghost",size:"sm",disabled:l.length===0,onClick:O,children:"Previous"}),h.jsx(Oe,{variant:"ghost",size:"sm",disabled:!g?.truncated,onClick:C,children:"Next"})]})]})}),h.jsx($r,{open:d!==null,onOpenChange:()=>p(null),children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Delete Storage Item"})}),h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[h.jsxs("p",{className:"font-mono text-[11px] text-neutral-300",children:["Are you sure you want to delete"," ",h.jsx("span",{className:"font-mono text-white",children:d}),"?"]}),h.jsx("p",{className:"font-mono text-[10px] text-neutral-500",children:"This action cannot be undone."})]}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",onClick:()=>p(null),children:"Cancel"}),h.jsx(Oe,{variant:"destructive",onClick:N,disabled:x.isPending,children:x.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"})," Deleting..."]}):"Delete"})]})]})})]})}const BX={};function au(e,t){if(t==="absolute")return new Date(e).toLocaleString();const n=new Date(e),i=new Date().getTime()-n.getTime(),a=Math.floor(i/1e3);return a<60?`${a}s`:a<3600?`${Math.floor(a/60)}m`:a<86400?`${Math.floor(a/3600)}h`:`${Math.floor(a/86400)}d`}function FX(e){const t=e.split(/\s+/).map(i=>i.trim()).filter(i=>i.length>0),n={},s=[];for(const i of t){const[a="",...l]=i.split(":"),f=l.join(":").trim(),d=a.toLowerCase();if(!f){s.push(i);continue}if(d==="actor"){n.actorId=f;continue}if(d==="client"){n.clientId=f;continue}if(d==="table"){n.table=f;continue}if(d==="request"){n.requestId=f;continue}if(d==="trace"){n.traceId=f;continue}s.push(i)}return s.length>0&&(n.search=s.join(" ")),n}function HX(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 Gd(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function qX(e,t){return e?`#${e.federatedCommitId??(t?`${t}:${e.commitSeq}`:String(e.commitSeq))}`:"#?"}function VX(e,t){return e?`E${e.federatedEventId??(t?`${t}:${e.eventId}`:e.eventId)}`:"E?"}function KX(e,t,n){return!e||!t?null:e.replaceAll("{traceId}",encodeURIComponent(t)).replaceAll("{spanId}",encodeURIComponent(n??""))}function yx({initialSelectedEntryId:e}={}){const{preferences:t}=of(),{partitionId:n}=sf(),{range:s,setRange:i}=pk(),a=t.pageSize,l=t.refreshInterval*1e3,f=BX?.VITE_CONSOLE_TRACE_URL_TEMPLATE,[d,p]=_.useState(()=>e?.startsWith("#")?"commits":e?.startsWith("E")?"events":"all"),[g,y]=_.useState("all"),[b,x]=_.useState("all"),[S,w]=_.useState(""),[T,C]=_.useState(1),[O,N]=_.useState(!1),[R,M]=_.useState(e??null),L=_.useRef(!1),j=_.useMemo(()=>FX(S),[S]),A=_.useMemo(()=>new Date(Date.now()-HX(s)).toISOString(),[s]),{data:P,isLoading:Z,refetch:B}=wY({limit:a,offset:(T-1)*a,...n?{partitionId:n}:{},view:d,...d!=="commits"&&g!=="all"?{eventType:g}:{},...d!=="commits"&&b!=="all"?{outcome:b}:{},...j.actorId?{actorId:j.actorId}:{},...j.clientId?{clientId:j.clientId}:{},...j.requestId?{requestId:j.requestId}:{},...j.traceId?{traceId:j.traceId}:{},...j.table?{table:j.table}:{},...j.search?{search:j.search}:{},from:A},{refetchIntervalMs:l}),z=WY(),Q=R?.startsWith("#")?R.slice(1):void 0,Y=R?.startsWith("E")?R.slice(1):void 0,ee=Q&&Q!=="?"?Q:void 0,D=Y&&Y!=="?"?Y:void 0,{data:V,isLoading:q,error:K}=_Y(ee,{enabled:ee!==void 0,partitionId:n}),{data:U,isLoading:I,error:H}=EY(D,{enabled:D!==void 0,partitionId:n}),{data:W,isLoading:X,error:oe}=TY(D,{enabled:D!==void 0&&!!U?.payloadRef,partitionId:n}),se=_.useMemo(()=>KX(f,U?.traceId??null,U?.spanId??null),[U?.spanId,U?.traceId,f]);_.useEffect(()=>{C(1)},[]),_.useEffect(()=>{C(1)},[]),_.useEffect(()=>{e&&M(e)},[e]),_.useEffect(()=>{if(!L.current){L.current=!0;return}M(null)},[]),_.useEffect(()=>{C(1),M(null)},[]);const xe=_.useMemo(()=>(P?.items??[]).map(we=>{const ve=we.instanceId??we.commit?.instanceId??we.event?.instanceId,Se=ve?`[${ve}] `:"";if(we.type==="commit"&&we.commit){const Ue=we.commit;return{type:"commit",id:qX(Ue,ve),outcome:"--",duration:"--",actor:Ue.actorId,client:Ue.clientId,detail:`${Se}${Ue.changeCount} chg | ${(Ue.affectedTables??[]).join(", ")}`,time:au(we.timestamp,t.timeFormat)}}const ye=we.event;return ye?{type:ye.eventType,id:VX(ye,ve),outcome:ye.outcome,duration:`${ye.durationMs}ms`,actor:ye.actorId,client:ye.clientId,detail:`${Se}${(ye.tables??[]).join(", ")||"--"}`,time:au(we.timestamp,t.timeFormat)}:{type:"pull",id:"E?",outcome:"unknown",duration:"--",actor:"",client:"",detail:"--",time:au(we.timestamp,t.timeFormat)}}),[t.timeFormat,P?.items]),de=P?.total??0,Me=Math.max(1,Math.ceil(de/a)),_e=Z,ne=[{label:"",options:[{id:"all",label:"All"},{id:"commits",label:"Commits"},{id:"events",label:"Events"}],activeId:d,onActiveChange:ae=>{p(ae),ae==="commits"&&(y("all"),x("all")),C(1)}},{label:"Time",options:[{id:"1h",label:"1h"},{id:"6h",label:"6h"},{id:"24h",label:"24h"},{id:"7d",label:"7d"},{id:"30d",label:"30d"}],activeId:s,onActiveChange:ae=>{i(ae),C(1)}},{label:"Type",options:[{id:"all",label:"All"},{id:"push",label:"Push"},{id:"pull",label:"Pull"}],activeId:g,onActiveChange:ae=>{y(ae),C(1)}},{label:"Outcome",options:[{id:"all",label:"All"},{id:"applied",label:"Applied"},{id:"error",label:"Error"},{id:"rejected",label:"Rejected"}],activeId:b,onActiveChange:ae=>{x(ae),C(1)}}];function he(){z.mutate(void 0,{onSuccess:()=>{N(!1),B()}})}return h.jsxs("div",{className:"flex flex-col h-full",children:[_e&&xe.length===0?h.jsx("div",{className:"flex items-center justify-center py-24",children:h.jsx(Pt,{size:"lg"})}):h.jsx(Wj,{entries:xe,selectedEntryId:R,onEntryClick:ae=>M(ae.id),filterBar:h.jsx(qj,{groups:ne,searchValue:S,searchPlaceholder:"Use actor:, client:, table:, request:, trace: or free text...",onSearchChange:w,actions:h.jsxs(h.Fragment,{children:[h.jsx(Oe,{size:"sm",variant:"ghost",onClick:()=>{B()},children:"Refresh"}),h.jsx(Oe,{size:"sm",variant:"ghost",children:"Export"}),h.jsx(Oe,{size:"sm",variant:"destructive",onClick:()=>N(!0),children:"Clear"})]})}),pagination:h.jsx(px,{page:T,totalPages:Me,totalItems:de,onPageChange:C})}),h.jsx($r,{open:R!==null,onOpenChange:ae=>{ae||M(null)},children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:ee!==void 0?`Commit #${ee}`:D!==void 0?`Event E${D}`:"Entry details"})}),h.jsx("div",{className:"px-5 py-4 space-y-3 max-h-[70vh] overflow-y-auto",children:q||I?h.jsx("div",{className:"flex items-center justify-center py-8",children:h.jsx(Pt,{size:"sm"})}):K||H?h.jsx("p",{className:"font-mono text-[11px] text-offline",children:"Failed to load details."}):V?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"grid grid-cols-2 gap-3 font-mono text-[11px]",children:[h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Actor"}),h.jsx("div",{className:"text-neutral-100",children:V.actorId})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Client"}),h.jsx("div",{className:"text-neutral-100",children:V.clientId})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Instance"}),h.jsx("div",{className:"text-neutral-100",children:V.instanceId??"--"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Created"}),h.jsx("div",{className:"text-neutral-100",children:au(V.createdAt,t.timeFormat)})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Changes"}),h.jsx("div",{className:"text-neutral-100",children:V.changeCount})]})]}),h.jsxs("div",{children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2",children:"Affected Tables"}),h.jsx("p",{className:"font-mono text-[11px] text-neutral-200",children:V.affectedTables.join(", ")||"--"})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500",children:"Changes"}),V.changes.length===0?h.jsx("p",{className:"font-mono text-[11px] text-neutral-500",children:"No changes recorded."}):V.changes.map(ae=>h.jsxs("div",{className:"rounded-md border border-border p-3 space-y-2",children:[h.jsxs("div",{className:"flex items-center justify-between font-mono text-[11px]",children:[h.jsxs("span",{className:"text-neutral-300",children:[ae.table," | ",ae.op]}),h.jsxs("span",{className:"text-neutral-500",children:["#",ae.changeId]})]}),h.jsxs("div",{className:"font-mono text-[11px] text-neutral-400",children:["rowId: ",ae.rowId,ae.rowVersion!==null?` | version: ${ae.rowVersion}`:""]}),h.jsx("pre",{className:"font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200",children:Gd(ae.rowJson)})]},ae.changeId))]})]}):U?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"grid grid-cols-2 gap-3 font-mono text-[11px]",children:[h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Type"}),h.jsx("div",{className:"text-neutral-100",children:U.eventType})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Path"}),h.jsx("div",{className:"text-neutral-100",children:U.syncPath})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Instance"}),h.jsx("div",{className:"text-neutral-100",children:U.instanceId??"--"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Outcome"}),h.jsx("div",{className:"text-neutral-100",children:U.outcome})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Response Status"}),h.jsx("div",{className:"text-neutral-100",children:U.responseStatus})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Actor"}),h.jsx("div",{className:"text-neutral-100",children:U.actorId})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Client"}),h.jsx("div",{className:"text-neutral-100",children:U.clientId})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Status"}),h.jsx("div",{className:"text-neutral-100",children:U.statusCode})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Transport"}),h.jsx("div",{className:"text-neutral-100",children:U.transportPath})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Duration"}),h.jsxs("div",{className:"text-neutral-100",children:[U.durationMs,"ms"]})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Request ID"}),h.jsx("div",{className:"text-neutral-100",children:U.requestId})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Trace ID"}),h.jsx("div",{className:"text-neutral-100",children:U.traceId??"--"}),se&&h.jsx("a",{href:se,target:"_blank",rel:"noreferrer",className:"font-mono text-[10px] text-flow underline underline-offset-4",children:"Open external trace"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Span ID"}),h.jsx("div",{className:"text-neutral-100",children:U.spanId??"--"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Commit Seq"}),h.jsx("div",{className:"text-neutral-100",children:U.commitSeq??"--"}),U.commitSeq!==null&&h.jsx(Oe,{variant:"ghost",size:"sm",onClick:()=>M(`#${U.instanceId?`${U.instanceId}:`:""}${U.commitSeq}`),children:"Open linked commit"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Subscription Count"}),h.jsx("div",{className:"text-neutral-100",children:U.subscriptionCount??"--"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Error Code"}),h.jsx("div",{className:"text-neutral-100",children:U.errorCode??"--"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Payload Ref"}),h.jsx("div",{className:"text-neutral-100",children:U.payloadRef??"--"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Created"}),h.jsx("div",{className:"text-neutral-100",children:au(U.createdAt,t.timeFormat)})]})]}),h.jsxs("div",{children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2",children:"Tables"}),h.jsx("p",{className:"font-mono text-[11px] text-neutral-200",children:U.tables.join(", ")||"--"})]}),U.scopesSummary&&h.jsxs("div",{children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2",children:"Scopes Summary"}),h.jsx("pre",{className:"font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200",children:Gd(U.scopesSummary)})]}),U.payloadRef&&h.jsxs("div",{children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2",children:"Payload Snapshot"}),X?h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Pt,{size:"sm"}),h.jsx("span",{className:"font-mono text-[11px] text-neutral-400",children:"Loading payload snapshot..."})]}):oe?h.jsx("p",{className:"font-mono text-[11px] text-offline",children:"Failed to load payload snapshot."}):W?h.jsxs("div",{className:"space-y-2",children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500",children:"Request"}),h.jsx("pre",{className:"font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200",children:Gd(W.requestPayload)}),h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500",children:"Response"}),h.jsx("pre",{className:"font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200",children:Gd(W.responsePayload)})]}):h.jsx("p",{className:"font-mono text-[11px] text-neutral-500",children:"No payload snapshot available."})]}),U.errorMessage&&h.jsxs("div",{children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2",children:"Error"}),h.jsx("p",{className:"font-mono text-[11px] text-offline",children:U.errorMessage})]})]}):h.jsx("p",{className:"font-mono text-[11px] text-neutral-500",children:"No details available for this row."})}),h.jsx(Nn,{children:h.jsx(Oe,{variant:"default",size:"sm",onClick:()=>M(null),children:"Close"})})]})}),h.jsx($r,{open:O,onOpenChange:ae=>{ae||N(!1)},children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Clear all events"})}),h.jsx("div",{className:"p-4",children:h.jsx("span",{className:"font-mono text-[11px] text-neutral-400",children:"This will permanently delete all request events. Commits are not affected. Are you sure?"})}),h.jsxs(Nn,{children:[h.jsx(Oe,{variant:"default",size:"sm",onClick:()=>N(!1),children:"Cancel"}),h.jsx(Oe,{variant:"destructive",size:"sm",onClick:he,disabled:z.isPending,children:z.isPending?"Clearing...":"Clear all"})]})]})})]})}const GX=ao({getParentRoute:()=>lo,path:"/config",component:fX}),ZX=ao({getParentRoute:()=>lo,path:"/fleet",component:wX}),YX=ao({getParentRoute:()=>lo,path:"/",component:uX});function XX(){const{seq:e}=mk.useParams();return h.jsx(yx,{initialSelectedEntryId:`#${e}`})}const mk=ao({getParentRoute:()=>lo,path:"/investigate/commit/$seq",component:XX});function QX(){const{id:e}=gk.useParams();return h.jsx(yx,{initialSelectedEntryId:`E${e}`})}const gk=ao({getParentRoute:()=>lo,path:"/investigate/event/$id",component:QX}),WX=ao({getParentRoute:()=>lo,path:"/ops",component:kX}),JX=ao({getParentRoute:()=>lo,path:"/storage",component:$X}),eQ=ao({getParentRoute:()=>lo,path:"/stream",component:yx}),tQ=lo.addChildren([YX,eQ,mk,gk,ZX,WX,JX,GX]),nQ="syncular-console-basepath",rQ="syncular-console-server-url",sQ="syncular-console-token";function oQ(e){if(!e)return;const t=e.trim();return t.length>0?t:void 0}function Bv(e){const t=globalThis.document;if(!t)return;const n=t.querySelector(`meta[name="${e}"]`)?.getAttribute("content");return oQ(n)}function yk(e){return!e||e==="/"?"/":(e.startsWith("/")?e:`/${e}`).replace(/\/+$/g,"")||"/"}function iQ(){return yk(Bv(nQ))}function aQ(){const e=Bv(rQ),t=Bv(sQ);return!e||!t?null:{serverUrl:e,token:t}}function cQ(){return new A6({defaultOptions:{queries:{staleTime:5e3,retry:1}}})}function lQ(e){return yk(e??iQ())}function uQ(e){const[t]=_.useState(()=>cQ()),n=_.useMemo(()=>PH({routeTree:tQ,basepath:lQ(e.basePath)}),[e.basePath]),s=e.defaultConfig===void 0?aQ():e.defaultConfig,i=e.autoConnect??e.defaultConfig===void 0;return h.jsx(k6,{client:t,children:h.jsx(QH,{defaultConfig:s,autoConnect:i,children:h.jsx(LH,{router:n})})})}function fQ(e){return h.jsx("div",{className:gx,children:h.jsx(uQ,{...e})})}function dQ(e){const t=document.querySelector(e);if(!t)throw new Error(`Unable to mount console: ${e} not found`);return t}function hQ(e,t={}){const n=dQ(e);VY(n);const s=i6.createRoot(n),i=h.jsx(fQ,{basePath:t.basePath,defaultConfig:t.defaultConfig,autoConnect:t.autoConnect});return t.strictMode===!1?(s.render(i),s):(s.render(h.jsx(_.StrictMode,{children:i})),s)}var pQ={};const mQ="syncular-sentry-dsn",gQ="syncular-sentry-environment",yQ="syncular-sentry-release";function gu(e){if(!e)return;const t=e.trim();return t.length>0?t:void 0}function Fy(e){if(typeof document>"u")return;const t=document.querySelector(`meta[name="${e}"]`)?.getAttribute("content");return gu(t)}function Hy(e){if(!(typeof process>"u"))return gu(pQ[e])}function qy(e){for(const t of e)if(t)return t}function vQ(){const e=qy([gu(globalThis.__SYNCULAR_SENTRY_DSN__),Fy(mQ),Hy("SYNCULAR_SENTRY_DSN")]);if(!e)return null;const t=qy([gu(globalThis.__SYNCULAR_SENTRY_ENVIRONMENT__),Fy(gQ),Hy("SYNCULAR_SENTRY_ENVIRONMENT")]),n=qy([gu(globalThis.__SYNCULAR_SENTRY_RELEASE__),Fy(yQ),Hy("SYNCULAR_SENTRY_RELEASE")]);return{dsn:e,environment:t,release:n,enableLogs:!0,tracesSampleRate:.2,tracePropagationTargets:[/^https?:\/\/.*\/api\/.*/]}}const XC=vQ();XC&&QB(XC);hQ("#root");
|
package/web-dist/index.html
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<meta name="syncular-sentry-environment" content="" />
|
|
11
11
|
<meta name="syncular-sentry-release" content="" />
|
|
12
12
|
<title>@syncular Console</title>
|
|
13
|
-
<script type="module" crossorigin src="/assets/index-
|
|
13
|
+
<script type="module" crossorigin src="/assets/index-CdhynHzW.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">
|