@syncular/console 0.0.6-245 → 0.0.6-246
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-246",
|
|
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-246",
|
|
72
|
+
"@syncular/transport-http": "0.0.6-246",
|
|
73
|
+
"@syncular/ui": "0.0.6-246",
|
|
74
74
|
"@tanstack/react-query": "^5.96.2",
|
|
75
75
|
"@tanstack/react-router": "^1.168.10",
|
|
76
76
|
"lucide-react": "^1.7.0"
|
|
@@ -27,4 +27,4 @@ Error generating stack: `+e.message+`
|
|
|
27
27
|
${e.right}px ${e.bottom}px,
|
|
28
28
|
${e.right}px ${e.top}px,
|
|
29
29
|
${e.left}px ${e.top}px
|
|
30
|
-
)`}return(0,G.jsx)(`div`,{ref:t,role:`presentation`,"data-base-ui-inert":``,...r,style:{position:`fixed`,inset:0,userSelect:`none`,WebkitUserSelect:`none`,clipPath:i}})});function HY(e,t){e&&Object.assign(e.style,t)}var UY={position:`relative`,maxHeight:`100%`,overflowX:`hidden`,overflowY:`auto`},WY={position:`fixed`},GY=W.forwardRef(function(e,t){let{anchor:n,positionMethod:r=`absolute`,className:i,render:a,side:o=`bottom`,align:s=`center`,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m,alignItemWithTrigger:h=!0,collisionAvoidance:g=yz,..._}=e,{store:v,listRef:y,labelsRef:b,alignItemWithTriggerActiveRef:x,selectedItemTextRef:S,valuesRef:C,initialValueRef:w,popupRef:T,setValue:E}=nY(),D=rY(),O=LK(v,fY.open),k=LK(v,fY.mounted),A=LK(v,fY.modal),j=LK(v,fY.value),M=LK(v,fY.openMethod),N=LK(v,fY.positionerElement),P=LK(v,fY.triggerElement),F=LK(v,fY.isItemEqualToValue),I=LK(v,fY.transitionStatus),L=W.useRef(null),ee=W.useRef(null),[R,z]=W.useState(h),B=k&&R&&M!==`touch`;!k&&R!==h&&z(h),Z(()=>{k||(fY.scrollUpArrowVisible(v.state)&&v.set(`scrollUpArrowVisible`,!1),fY.scrollDownArrowVisible(v.state)&&v.set(`scrollDownArrowVisible`,!1))},[v,k]),W.useImperativeHandle(x,()=>B),MY((B||A)&&O&&M!==`touch`,P);let V=fJ({anchor:n,floatingRootContext:D,positionMethod:r,mounted:k,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m??B,collisionAvoidance:g,keepMounted:!0}),H=B?`none`:V.side,U=B?WY:V.positionerStyles,te=W.useMemo(()=>{let e={};return O||(e.pointerEvents=`none`),{role:`presentation`,hidden:!k,style:{...U,...e}}},[O,k,U]),ne={open:O,side:H,align:V.align,anchorHidden:V.anchorHidden},re=Sz(`div`,e,{ref:[t,X(e=>{v.set(`positionerElement`,e)})],state:ne,stateAttributesMapping:qq,props:[te,mJ(I),_]}),ie=W.useRef(0),ae=X(e=>{if(e.size===0&&ie.current===0||C.current.length===0)return;let t=ie.current;if(ie.current=e.size,e.size===t)return;let n=UB(jB);if(t!==0&&!v.state.multiple&&j!==null&&oY(C.current,j,F)===-1){let e=w.current,t=e!=null&&oY(C.current,e,F)!==-1?e:null;E(t,n),t===null&&(v.set(`selectedIndex`,null),S.current=null)}if(t!==0&&v.state.multiple&&Array.isArray(j)){let e=e=>oY(C.current,e,F)!==-1,t=j.filter(t=>e(t));(t.length!==j.length||t.some(e=>!aY(j,e,F)))&&(E(t,n),t.length===0&&(v.set(`selectedIndex`,null),S.current=null))}if(O&&B){v.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});let e={height:``};HY(N,e),HY(T.current,e)}}),oe=W.useMemo(()=>({...V,side:H,alignItemWithTriggerActive:B,setControlledAlignItemWithTrigger:z,scrollUpArrowRef:L,scrollDownArrowRef:ee}),[V,H,B,z]);return(0,G.jsx)(FY,{elementsRef:y,labelsRef:b,onMapChange:ae,children:(0,G.jsxs)(zY.Provider,{value:oe,children:[k&&A&&(0,G.jsx)(VY,{inert:vJ(!O),cutout:P}),re]})})});function KY(e){let 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}var qY=`base-ui-disable-scrollbar`,JY={className:qY,getElement(e){return(0,G.jsx)(`style`,{nonce:e,href:qY,precedence:`base-ui:low`,children:`.${qY}{scrollbar-width:none}.${qY}::-webkit-scrollbar{display:none}`})}},YY=W.createContext(void 0);function XY(e){let t=W.useContext(YY);if(t===void 0&&!e)throw Error(QR(69));return t}var ZY=`ArrowUp`,QY=`ArrowDown`,$Y=`ArrowLeft`,eX=`ArrowRight`,tX=`Home`,nX=new Set([$Y,eX]),rX=new Set([$Y,eX,tX,`End`]),iX=new Set([ZY,QY]),aX=new Set([ZY,QY,tX,`End`]),oX=new Set([...nX,...iX]),sX=new Set([...oX,tX,`End`]),cX=new Set([ZY,QY,$Y,eX,tX,`End`]),lX=new Set([`Shift`,`Control`,`Alt`,`Meta`]);function uX(e){return zz(e)&&e.tagName===`INPUT`}function dX(e){return!!(uX(e)&&e.selectionStart!=null||zz(e)&&e.tagName===`TEXTAREA`)}function fX(e,t,n,r){if(!e||!t||!t.scrollTo)return;let i=e.scrollLeft,a=e.scrollTop,o=e.clientWidth<e.scrollWidth,s=e.clientHeight<e.scrollHeight;if(o&&r!==`vertical`){let r=pX(e,t,`left`),a=mX(e),o=mX(t);n===`ltr`&&(r+t.offsetWidth+o.scrollMarginRight>e.scrollLeft+e.clientWidth-a.scrollPaddingRight?i=r+t.offsetWidth+o.scrollMarginRight-e.clientWidth+a.scrollPaddingRight:r-o.scrollMarginLeft<e.scrollLeft+a.scrollPaddingLeft&&(i=r-o.scrollMarginLeft-a.scrollPaddingLeft)),n===`rtl`&&(r-o.scrollMarginRight<e.scrollLeft+a.scrollPaddingLeft?i=r-o.scrollMarginLeft-a.scrollPaddingLeft:r+t.offsetWidth+o.scrollMarginRight>e.scrollLeft+e.clientWidth-a.scrollPaddingRight&&(i=r+t.offsetWidth+o.scrollMarginRight-e.clientWidth+a.scrollPaddingRight))}if(s&&r!==`horizontal`){let n=pX(e,t,`top`),r=mX(e),i=mX(t);n-i.scrollMarginTop<e.scrollTop+r.scrollPaddingTop?a=n-i.scrollMarginTop-r.scrollPaddingTop:n+t.offsetHeight+i.scrollMarginBottom>e.scrollTop+e.clientHeight-r.scrollPaddingBottom&&(a=n+t.offsetHeight+i.scrollMarginBottom-e.clientHeight+r.scrollPaddingBottom)}e.scrollTo({left:i,top:a,behavior:`auto`})}function pX(e,t,n){let r=n===`left`?`offsetLeft`:`offsetTop`,i=0;for(;t.offsetParent&&(i+=t[r],t.offsetParent!==e);)t=t.offsetParent;return i}function mX(e){let 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 hX(e,t=-(2**53-1),n=2**53-1){return Math.max(t,Math.min(e,n))}var gX=W.createContext(void 0),_X={disableStyleElements:!1};function vX(){return W.useContext(gX)??_X}var yX=1,bX={...qq,...YK},xX=W.forwardRef(function(e,t){let{render:n,className:r,finalFocus:i,...a}=e,{store:o,popupRef:s,onOpenChangeComplete:c,setOpen:l,valueRef:u,selectedItemTextRef:d,keyboardActiveRef:f,multiple:p,handleScrollArrowVisibility:m,scrollHandlerRef:h,highlightItemOnHover:g}=nY(),{side:_,align:v,alignItemWithTriggerActive:y,setControlledAlignItemWithTrigger:b,scrollDownArrowRef:x,scrollUpArrowRef:S}=BY(),C=XY(!0)!=null,w=rY(),{nonce:T,disableStyleElements:E}=vX(),D=xH(),O=LK(o,fY.id),k=LK(o,fY.open),A=LK(o,fY.mounted),j=LK(o,fY.popupProps),M=LK(o,fY.transitionStatus),N=LK(o,fY.triggerElement),P=LK(o,fY.positionerElement),F=LK(o,fY.listElement),I=W.useRef(0),L=W.useRef(!1),ee=W.useRef(0),R=W.useRef(!1),z=W.useRef({}),B=FW(),V=X(e=>{if(!P||!s.current||!R.current)return;if(L.current||!y){m();return}let t=P.style.top===`0px`,n=P.style.bottom===`0px`,r=P.getBoundingClientRect().height,i=gW(P),a=getComputedStyle(P),o=parseFloat(a.marginTop),c=parseFloat(a.marginBottom),l=SX(getComputedStyle(s.current)),u=Math.min(i.documentElement.clientHeight-o-c,l),d=e.scrollTop,f=CX(e),p=0,h=null,g=!1,_=!1,v=e=>{P.style.height=`${e}px`},b=(t,n)=>{let i=hX(t,0,u-r);i>0&&v(r+i),e.scrollTop=n,u-(r+i)<=yX&&(L.current=!0),m()};if(t){let e=f-d,t=r+e,n=Math.min(t,u);if(p=n,e<=yX){b(e,f);return}u-n>yX?_=!0:g=!0}else if(n){let e=d,t=r+e,n=Math.min(t,u),i=t-u;if(p=n,e<=yX){b(e,0);return}u-n>yX?h=0:(g=!0,d<f&&(h=d-(e-i)))}if(p=Math.ceil(p),p!==0&&v(p),_||h!=null){let t=CX(e),n=_?t:hX(h,0,t);Math.abs(e.scrollTop-n)>yX&&(e.scrollTop=n)}(g||p>=u-yX)&&(L.current=!0),m()});W.useImperativeHandle(h,()=>V,[V]),ZK({open:k,ref:s,onComplete(){k&&c?.(!0)}});let H={open:k,transitionStatus:M,side:_,align:v};Z(()=>{!P||!s.current||Object.keys(z.current).length||(z.current={top:P.style.top||`0`,left:P.style.left||`0`,right:P.style.right,height:P.style.height,bottom:P.style.bottom,minHeight:P.style.minHeight,maxHeight:P.style.maxHeight,marginTop:P.style.marginTop,marginBottom:P.style.marginBottom})},[s,P]),Z(()=>{k||y||(R.current=!1,L.current=!1,I.current=0,ee.current=0,HY(P,z.current))},[k,y,P,s]),Z(()=>{let e=s.current;if(!(!k||!N||!P||!e||o.state.transitionStatus===`ending`)){if(!y){R.current=!0,B.request(m),e.style.removeProperty(`--transform-origin`);return}queueMicrotask(()=>{let t=DX(e);e.style.removeProperty(`--transform-origin`);try{let t=getComputedStyle(P),n=getComputedStyle(e),r=gW(N),i=Fz(P),a=wX(N),o=TX(N.getBoundingClientRect(),a),s=TX(P.getBoundingClientRect(),a),c=o.left,l=o.height,f=F||e,p=f.scrollHeight,h=parseFloat(n.borderBottomWidth),g=parseFloat(t.marginTop)||10,_=parseFloat(t.marginBottom)||10,v=parseFloat(t.minHeight)||100,y=SX(n),x=r.documentElement.clientHeight-g-_,S=r.documentElement.clientWidth,C=x-o.bottom+l,w=d.current,T=u.current,E,D=0,O=0;if(w&&T){let e=TX(T.getBoundingClientRect(),a);E=TX(w.getBoundingClientRect(),a);let t=e.left-c,n=E.left-s.left,r=e.top-o.top+e.height/2,i=E.top-s.top+E.height/2;D=t-n,O=i-r}let k=C+O+_+h,A=Math.min(x,k),j=x-g-_,M=k-A,ee=Math.max(5,c+D),B=S-5,V=Math.max(0,ee+s.width-B);P.style.left=`${ee-V}px`,P.style.height=`${A}px`,P.style.maxHeight=`auto`,P.style.marginTop=`${g}px`,P.style.marginBottom=`${_}px`,e.style.height=`100%`;let H=CX(f),U=M>=H-yX;U&&(A=Math.min(x,s.height)-(M-H));let te=o.top<20||o.bottom>x-20||Math.ceil(A)+yX<Math.min(p,v),ne=(i.visualViewport?.scale??1)!==1&&EH;if(te||ne){R.current=!0,HY(P,z.current),Dv.flushSync(()=>b(!1));return}if(U){let e=Math.max(0,x-k);P.style.top=s.height>=j?`0`:`${e}px`,P.style.height=`${A}px`,f.scrollTop=CX(f),I.current=Math.max(v,A)}else P.style.bottom=`0`,I.current=Math.max(v,A),f.scrollTop=M;if(E){let t=s.top,n=s.height,r=E.top+E.height/2,i=hX(n>0?(r-t)/n*100:50,0,100);e.style.setProperty(`--transform-origin`,`50% ${i}%`)}(I.current===x||A>=y)&&(L.current=!0),m(),setTimeout(()=>{R.current=!0})}finally{t()}})}},[o,k,P,N,u,d,s,m,y,b,B,x,S,F]),W.useEffect(()=>{if(!y||!P||!k)return;let e=Fz(P);function t(e){l(!1,UB(HB,e))}return e.addEventListener(`resize`,t),()=>{e.removeEventListener(`resize`,t)}},[l,y,P,k]);let U={...F?{role:`presentation`,"aria-orientation":void 0}:{role:`listbox`,"aria-multiselectable":p||void 0,id:`${O}-list`},onKeyDown(e){f.current=!0,C&&cX.has(e.key)&&e.stopPropagation()},onMouseMove(){f.current=!1},onPointerLeave(e){if(!g||KY(e)||e.pointerType===`touch`)return;let t=e.currentTarget;D.start(0,()=>{o.set(`activeIndex`,null),t.focus({preventScroll:!0})})},onScroll(e){F||V(e.currentTarget)},...y&&{style:F?{height:`100%`}:UY}},te=Sz(`div`,e,{ref:[t,s],state:H,stateAttributesMapping:bX,props:[j,U,mJ(M),{className:!F&&y?JY.className:void 0},a]});return(0,G.jsxs)(W.Fragment,{children:[!E&&JY.getElement(T),(0,G.jsx)(vG,{context:w,modal:!1,disabled:!A,returnFocus:i,restoreFocus:!0,children:te})]})});function SX(e){let t=e.maxHeight||``;return t.endsWith(`px`)&&parseFloat(t)||1/0}function CX(e){return Math.max(0,e.scrollHeight-e.clientHeight)}function wX(e){return fK.getScale(e)}function TX(e,t){return OU({x:e.x/t.x,y:e.y/t.y,width:e.width/t.x,height:e.height/t.y})}var EX=[[`transform`,`none`],[`scale`,`1`],[`translate`,`0 0`]];function DX(e){let{style:t}=e,n={};for(let[e,r]of EX)n[e]=t.getPropertyValue(e),t.setProperty(e,r,`important`);return()=>{for(let[e]of EX){let r=n[e];r?t.setProperty(e,r):t.removeProperty(e)}}}var OX=function(e){return e[e.None=0]=`None`,e[e.GuessFromOrder=1]=`GuessFromOrder`,e}({});function kX(e={}){let{label:t,metadata:n,textRef:r,indexGuessBehavior:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,elementsRef:l,labelsRef:u,nextIndexRef:d}=PY(),f=W.useRef(-1),[p,m]=W.useState(a??(i===OX.GuessFromOrder?()=>{if(f.current===-1){let e=d.current;d.current+=1,f.current=e}return f.current}:-1)),h=W.useRef(null),g=W.useCallback(e=>{if(h.current=e,p!==-1&&e!==null&&(l.current[p]=e,u)){let n=t!==void 0;u.current[p]=n?t:r?.current?.textContent??e.textContent}},[p,l,u,t,r]);return Z(()=>{if(a!=null)return;let e=h.current;if(e)return o(e,n),()=>{s(e)}},[a,o,s,n]),Z(()=>{if(a==null)return c(e=>{let t=h.current?e.get(h.current)?.index:null;t!=null&&m(t)})},[a,c,m]),W.useMemo(()=>({ref:g,index:p}),[p,g])}var AX=W.createContext(void 0),jX=W.memo(W.forwardRef(function(e,t){let{render:n,className:r,value:i=null,label:a,disabled:o=!1,nativeButton:s=!1,...c}=e,l=W.useRef(null),u=kX({label:a,textRef:l,indexGuessBehavior:OX.GuessFromOrder}),{store:d,getItemProps:f,setOpen:p,setValue:m,selectionRef:h,typingRef:g,valuesRef:_,keyboardActiveRef:v,multiple:y,highlightItemOnHover:b}=nY(),x=xH(),S=LK(d,fY.isActive,u.index),C=LK(d,fY.isSelected,u.index,i),w=LK(d,fY.isSelectedByFocus,u.index),T=LK(d,fY.isItemEqualToValue),E=u.index,D=E!==-1,O=W.useRef(null),k=AW(E);Z(()=>{if(!D)return;let e=_.current;return e[E]=i,()=>{delete e[E]}},[D,E,i,_]),Z(()=>{if(!D)return;let e=d.state.value,t=e;y&&Array.isArray(e)&&e.length>0&&(t=e[e.length-1]),t!==void 0&&iY(i,t,T)&&d.set(`selectedIndex`,E)},[D,E,y,T,d,i]);let A={disabled:o,selected:C,highlighted:S},j=f({active:S,selected:C});j.onFocus=void 0,j.id=void 0;let M=W.useRef(null),N=W.useRef(`mouse`),P=W.useRef(!1),{getButtonProps:F,buttonRef:I}=sB({disabled:o,focusableWhenDisabled:!0,native:s,composite:!0});function L(e){let t=d.state.value;if(y){let n=Array.isArray(t)?t:[];m(C?sY(n,i,T):[...n,i],UB(IB,e))}else m(i,UB(IB,e)),p(!1,UB(IB,e))}let ee={role:`option`,"aria-selected":C,tabIndex:S?0:-1,onFocus(){d.set(`activeIndex`,E)},onMouseEnter(){!v.current&&d.state.selectedIndex===null&&b&&d.set(`activeIndex`,E)},onMouseMove(){b&&d.set(`activeIndex`,E)},onMouseLeave(e){!b||v.current||KY(e)||x.start(0,()=>{d.state.activeIndex===E&&d.set(`activeIndex`,null)})},onTouchStart(){h.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1}},onKeyDown(e){M.current=e.key,d.set(`activeIndex`,E),e.key===` `&&g.current&&e.preventDefault()},onClick(e){P.current=!1,!(e.type===`keydown`&&M.current===null)&&(o||e.type===`keydown`&&M.current===` `&&g.current||N.current!==`touch`&&!S||(M.current=null,L(e.nativeEvent)))},onPointerEnter(e){N.current=e.pointerType},onPointerDown(e){N.current=e.pointerType,P.current=!0},onMouseUp(){if(o)return;if(P.current){P.current=!1;return}let e=!h.current.allowSelectedMouseUp&&C,t=!h.current.allowUnselectedMouseUp&&!C;e||t||N.current!==`touch`&&!S||O.current?.click()}},R=Sz(`div`,e,{ref:[I,t,u.ref,O],state:A,props:[j,ee,c,F]}),z=W.useMemo(()=>({selected:C,indexRef:k,textRef:l,selectedByFocus:w,hasRegistered:D}),[C,k,l,w,D]);return(0,G.jsx)(AX.Provider,{value:z,children:R})})),MX=(0,W.forwardRef)(({className:e,children:t,...n},r)=>(0,G.jsx)(xY,{ref:r,className:Y(`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}));MX.displayName=`SelectTrigger`;var NX=(0,W.forwardRef)(({className:e,portalProps:t,positionerProps:n,...r},i)=>(0,G.jsx)(CY,{...t,children:(0,G.jsx)(GY,{...n,children:(0,G.jsx)(xX,{ref:i,className:Y(`bg-panel border border-border rounded-md py-1 shadow-lg z-50`,e),...r})})}));NX.displayName=`SelectContent`;var PX=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(jX,{ref:n,className:Y(`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}));PX.displayName=`SelectItem`;var FX=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(`textarea`,{ref:n,className:Y(`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}));FX.displayName=`Textarea`;var IX=W.createContext(void 0);function LX(e=!0){let t=W.useContext(IX);if(t===void 0&&!e)throw Error(QR(7));return t}function RX(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=aB(),{ref:i,index:a}=kX(e),o=n===a,s=W.useRef(null),c=zR(i,s);return{compositeProps:W.useMemo(()=>({tabIndex:o?0:-1,onFocus(){r(a)},onMouseMove(){let e=s.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!o&&!n&&e.focus()}}),[o,r,a,t]),compositeRef:c,index:a}}function zX(e){let{render:t,className:n,state:r=XR,props:i=YR,refs:a=YR,metadata:o,stateAttributesMapping:s,tag:c=`div`,...l}=e,{compositeProps:u,compositeRef:d}=RX({metadata:o});return Sz(c,e,{state:r,ref:[...a,d],props:[u,...i,l],stateAttributesMapping:s})}var BX=W.forwardRef(function(e,t){let{className:n,defaultPressed:r=!1,disabled:i=!1,form:a,onPressedChange:o,pressed:s,render:c,type:l,value:u,nativeButton:d=!0,...f}=e,p=Mz(u||void 0),m=LX(),h=m?.value??[],g=m?void 0:r,_=(i||m?.disabled)??!1,[v,y]=MR({controlled:m?p!==void 0&&h.indexOf(p)>-1:s,default:g,name:`Toggle`,state:`pressed`}),b=X((e,t)=>{p&&m?.setGroupValue?.(p,e,t),o?.(e,t)}),{getButtonProps:x,buttonRef:S}=sB({disabled:_,native:d}),C={disabled:_,pressed:v},w=[S,t],T=[{"aria-pressed":v,onClick(e){let t=!v,n=UB(jB,e.nativeEvent);b(t,n),!n.isCanceled&&y(t)}},f,x],E=Sz(`button`,e,{enabled:!m,state:C,ref:w,props:T});return m?(0,G.jsx)(zX,{tag:`button`,render:c,className:n,state:C,refs:w,props:T}):E}),VX=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(BX,{ref:n,className:Y(`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}));VX.displayName=`Toggle`;function HX(e){return e==null||e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}var UX=`data-composite-item-active`,WX=[];function GX(e){let{itemSizes:t,cols:n=1,loopFocus:r=!0,dense:i=!1,orientation:a=`both`,direction:o,highlightedIndex:s,onHighlightedIndexChange:c,rootRef:l,enableHomeAndEndKeys:u=!1,stopEventPropagation:d=!1,disabledIndices:f,modifierKeys:p=WX}=e,[m,h]=W.useState(0),g=n>1,_=W.useRef(null),v=zR(_,l),y=W.useRef([]),b=W.useRef(!1),x=s??m,S=X((e,t=!1)=>{if((c??h)(e),t){let t=y.current[e];fX(_.current,t,o,a)}}),C=X(e=>{if(e.size===0||b.current)return;b.current=!0;let t=Array.from(e.keys()),n=t.find(e=>e?.hasAttribute(`data-composite-item-active`))??null,r=n?t.indexOf(n):-1;r!==-1&&S(r),fX(_.current,n,o,a)}),w=W.useMemo(()=>({"aria-orientation":a===`both`?void 0:a,ref:v,onFocus(e){!_.current||!dX(e.target)||e.target.setSelectionRange(0,e.target.value.length??0)},onKeyDown(e){let s=u?sX:oX;if(!s.has(e.key)||KX(e,p)||!_.current)return;let c=o===`rtl`,l=c?$Y:eX,m={horizontal:l,vertical:QY,both:l}[a],h=c?eX:$Y,v={horizontal:h,vertical:ZY,both:h}[a];if(dX(e.target)&&!HX(e.target)){let t=e.target.selectionStart,n=e.target.selectionEnd,r=e.target.value??``;if(t==null||e.shiftKey||t!==n||e.key!==v&&t<r.length||e.key!==m&&t>0)return}let b=x,C=jU(y,f),w=MU(y,f);if(g){let o=t||Array.from({length:y.current.length},()=>({width:1,height:1})),s=FU(o,n,i),l=s.findIndex(e=>e!=null&&!RU(y,e,f)),u=s.reduce((e,t,n)=>t!=null&&!RU(y,t,f)?n:e,-1);b=s[PU({current:s.map(e=>e?y.current[e]:null)},{event:e,orientation:a,loopFocus:r,cols:n,disabledIndices:LU([...f||y.current.map((e,t)=>RU(y,t)?t:void 0),void 0],s),minIndex:l,maxIndex:u,prevIndex:IU(x>w?C:x,o,s,n,e.key===`ArrowDown`?`bl`:e.key===`ArrowRight`?`tr`:`tl`),rtl:c})]}let T={horizontal:[l],vertical:[QY],both:[l,QY]}[a],E={horizontal:[h],vertical:[ZY],both:[h,ZY]}[a],D=g?s:{horizontal:u?rX:nX,vertical:u?aX:iX,both:s}[a];u&&(e.key===`Home`?b=C:e.key===`End`&&(b=w)),b===x&&(T.includes(e.key)||E.includes(e.key))&&(b=r&&b===w&&T.includes(e.key)?C:r&&b===C&&E.includes(e.key)?w:NU(y,{startingIndex:b,decrement:E.includes(e.key),disabledIndices:f})),b!==x&&!AU(y,b)&&(d&&e.stopPropagation(),D.has(e.key)&&e.preventDefault(),S(b,!0),queueMicrotask(()=>{y.current[b]?.focus()}))}}),[n,i,o,f,y,u,x,g,t,r,v,p,S,a,d]);return W.useMemo(()=>({props:w,highlightedIndex:x,onHighlightedIndexChange:S,elementsRef:y,disabledIndices:f,onMapChange:C,relayKeyboardEvent:w.onKeyDown}),[w,x,S,y,f,C])}function KX(e,t){for(let n of lX.values())if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function qX(e){let{render:t,className:n,refs:r=YR,props:i=YR,state:a=XR,stateAttributesMapping:o,highlightedIndex:s,onHighlightedIndexChange:c,orientation:l,dense:u,itemSizes:d,loopFocus:f,cols:p,enableHomeAndEndKeys:m,onMapChange:h,stopEventPropagation:g=!0,rootRef:_,disabledIndices:v,modifierKeys:y,highlightItemOnHover:b=!1,tag:x=`div`,...S}=e,{props:C,highlightedIndex:w,onHighlightedIndexChange:T,elementsRef:E,onMapChange:D,relayKeyboardEvent:O}=GX({itemSizes:d,cols:p,loopFocus:f,dense:u,orientation:l,highlightedIndex:s,onHighlightedIndexChange:c,rootRef:_,stopEventPropagation:g,enableHomeAndEndKeys:m,direction:iJ(),disabledIndices:v,modifierKeys:y}),k=Sz(x,e,{state:a,ref:r,props:[C,...i,S],stateAttributesMapping:o}),A=W.useMemo(()=>({highlightedIndex:w,onHighlightedIndexChange:T,highlightItemOnHover:b,relayKeyboardEvent:O}),[w,T,b,O]);return(0,G.jsx)(iB.Provider,{value:A,children:(0,G.jsx)(FY,{elementsRef:E,onMapChange:e=>{h?.(e),D(e)},children:k})})}var JX=function(e){return e.disabled=`data-disabled`,e.orientation=`data-orientation`,e.multiple=`data-multiple`,e}({}),YX={multiple(e){return e?{[JX.multiple]:``}:null}},XX=W.forwardRef(function(e,t){let{defaultValue:n,disabled:r=!1,loopFocus:i=!0,onValueChange:a,orientation:o=`horizontal`,multiple:s=!1,value:c,className:l,render:u,...d}=e,f=XY(!0),p=W.useMemo(()=>{if(c===void 0)return n??[]},[c,n]),m=W.useMemo(()=>c!==void 0||n!==void 0,[c,n]),h=(f?.disabled??!1)||r,[g,_]=MR({controlled:c,default:p,name:`ToggleGroup`,state:`value`}),v=X((e,t,n)=>{let r;if(s?(r=g.slice(),t?r.push(e):r.splice(g.indexOf(e),1)):r=t?[e]:[],Array.isArray(r)){if(a?.(r,n),n.isCanceled)return;_(r)}}),y={disabled:h,multiple:s,orientation:o},b=W.useMemo(()=>({disabled:h,orientation:o,setGroupValue:v,value:g,isValueInitialized:m}),[h,o,v,g,m]),x={role:`group`},S=Sz(`div`,e,{enabled:!!f,state:y,ref:t,props:[x,d],stateAttributesMapping:YX});return(0,G.jsx)(IX.Provider,{value:b,children:f?S:(0,G.jsx)(qX,{render:u,className:l,state:y,refs:[t],props:[x,d],stateAttributesMapping:YX,loopFocus:i,enableHomeAndEndKeys:!0})})}),ZX=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(XX,{ref:n,className:Y(`flex items-center gap-0.5`,e),...t}));ZX.displayName=`ToggleGroup`;var QX=Y(cV({variant:`secondary`,size:`sm`}),`h-7 whitespace-nowrap uppercase tracking-[0.08em] leading-none no-underline`);function $X({active:e,onClick:t,children:n,className:r}){return(0,G.jsxs)(`button`,{type:`button`,onClick:t,className:Y(`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`,r),children:[n,e&&(0,G.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:r,className:i}){return(0,G.jsx)(`div`,{className:Y(`flex items-center gap-0.5`,i),children:e.map(e=>{let i=e.id===t,a=()=>n?.(e.id);return r?(0,G.jsx)(`span`,{children:r(e,{active:i,onClick:a})},e.id):(0,G.jsx)($X,{active:i,onClick:a,children:e.label},e.id)})})}var tZ=kR(`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}}),nZ={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:r,className:i}){return(0,G.jsx)(`span`,{className:Y(tZ({color:e,size:t,glow:n}),r&&`dot-pulse`,i),style:n?{boxShadow:nZ[e??`healthy`]}:void 0})}var iZ={name:`@syncular/ui`,version:`0.0.6-245`,description:`Reusable Syncular UI components and styles`,license:`Apache-2.0`,author:`Benjamin Kniffler`,homepage:`https://syncular.dev`,repository:{type:`git`,url:`https://github.com/syncular/syncular.git`,directory:`packages/ui`},bugs:{url:`https://github.com/syncular/syncular/issues`},keywords:[`sync`,`offline-first`,`realtime`,`ui`,`react`],publishConfig:{access:`public`},type:`module`,exports:{".":{bun:`./src/index.ts`,browser:`./src/index.ts`,import:{types:`./dist/index.d.ts`,default:`./dist/index.js`}},"./charts":{bun:`./src/charts/index.ts`,browser:`./src/charts/index.ts`,import:{types:`./dist/charts/index.d.ts`,default:`./dist/charts/index.js`}},"./console":{bun:`./src/console/index.ts`,browser:`./src/console/index.ts`,import:{types:`./dist/console/index.d.ts`,default:`./dist/console/index.js`}},"./forms":{bun:`./src/forms/index.ts`,browser:`./src/forms/index.ts`,import:{types:`./dist/forms/index.d.ts`,default:`./dist/forms/index.js`}},"./primitives":{bun:`./src/primitives/index.ts`,browser:`./src/primitives/index.ts`,import:{types:`./dist/primitives/index.d.ts`,default:`./dist/primitives/index.js`}},"./observable-universe":{bun:`./src/observable-universe/index.ts`,browser:`./src/observable-universe/index.ts`,import:{types:`./dist/observable-universe/index.d.ts`,default:`./dist/observable-universe/index.js`}},"./demo":{bun:`./src/demo/index.ts`,browser:`./src/demo/index.ts`,import:{types:`./dist/demo/index.d.ts`,default:`./dist/demo/index.js`}},"./navigation":{bun:`./src/navigation/index.ts`,browser:`./src/navigation/index.ts`,import:{types:`./dist/navigation/index.d.ts`,default:`./dist/navigation/index.js`}},"./styles.css":`./dist/styles.css`,"./styles.source.css":`./src/styles/styles.css`,"./styles/tokens.css":`./src/styles/tokens.css`,"./package.json":`./package.json`},files:[`dist`,`src`],scripts:{tsgo:`tsgo --noEmit`,"build:css":`bunx @tailwindcss/cli -i src/styles/styles.css -o dist/styles.css`,build:`tsgo && bun run build:css`,release:`bunx syncular-publish`},peerDependencies:{react:`^19.0.0`,"react-dom":`^19.0.0`},dependencies:{"@base-ui/react":`^1.3.0`,"class-variance-authority":`^0.7.1`,clsx:`^2.1.1`,"lucide-react":`^1.7.0`,recharts:`^3.8.1`,"tailwind-merge":`^3.5.0`,tailwindcss:`^4.2.2`},devDependencies:{"@syncular/config":`workspace:*`,"@tailwindcss/cli":`^4.2.2`,"@types/react":`^19.2.14`}}.version;function aZ({label:e,className:t}){return(0,G.jsxs)(`div`,{className:Y(`flex items-center gap-3`,t),children:[(0,G.jsx)(rZ,{color:`healthy`,size:`md`,glow:!0}),(0,G.jsx)(`span`,{className:`font-display font-bold text-white text-sm tracking-tight`,children:`syncular`}),e&&(0,G.jsx)(`span`,{className:`font-mono text-[9px] text-neutral-600 uppercase tracking-widest`,children:e}),(0,G.jsxs)(`span`,{className:`font-mono text-[9px] text-neutral-600 tracking-wider`,children:[`v`,iZ]})]})}function oZ({brand:e,center:t,right:n,className:r}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{"aria-hidden":`true`,className:`h-[42px] shrink-0`}),(0,G.jsxs)(`nav`,{className:Y(`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`,r),children:[(0,G.jsx)(`div`,{className:`flex items-center gap-3`,children:e}),(0,G.jsx)(`div`,{className:`flex items-center gap-0.5`,children:t}),(0,G.jsx)(`div`,{className:`flex items-center gap-2`,children:n})]})]})}var sZ=kR(`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`}}),cZ=(0,W.forwardRef)(({className:e,variant:t,...n},r)=>(0,G.jsx)(`div`,{ref:r,role:`alert`,className:Y(sZ({variant:t,className:e})),...n}));cZ.displayName=`Alert`;var lZ=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(`h5`,{ref:n,className:Y(`font-medium text-white mb-1`,e),...t}));lZ.displayName=`AlertTitle`;var uZ=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(`p`,{ref:n,className:Y(`text-neutral-400`,e),...t}));uZ.displayName=`AlertDescription`;var dZ=W.createContext(void 0);function fZ(e){let t=W.useContext(dZ);if(e===!1&&t===void 0)throw Error(QR(27));return t}var pZ={...qq,...YK},mZ=W.forwardRef(function(e,t){let{render:n,className:r,forceRender:i=!1,...a}=e,{store:o}=fZ(),s=o.useState(`open`),c=o.useState(`nested`),l=o.useState(`mounted`);return Sz(`div`,e,{state:{open:s,transitionStatus:o.useState(`transitionStatus`)},ref:[o.context.backdropRef,t],stateAttributesMapping:pZ,props:[{role:`presentation`,hidden:!l,style:{userSelect:`none`,WebkitUserSelect:`none`}},a],enabled:i||!c})}),hZ=W.forwardRef(function(e,t){let{render:n,className:r,id:i,...a}=e,{store:o}=fZ(),s=Mz(i);return o.useSyncedValueWithCleanup(`descriptionElementId`,s),Sz(`p`,e,{ref:t,props:[{id:s},a]})}),gZ=function(e){return e.nestedDialogs=`--nested-dialogs`,e}({}),_Z=function(e){return e[e.open=Rq.open]=`open`,e[e.closed=Rq.closed]=`closed`,e[e.startingStyle=Rq.startingStyle]=`startingStyle`,e[e.endingStyle=Rq.endingStyle]=`endingStyle`,e.nested=`data-nested`,e.nestedDialogOpen=`data-nested-dialog-open`,e}({}),vZ=W.createContext(void 0);function yZ(){let e=W.useContext(vZ);if(e===void 0)throw Error(QR(26));return e}var bZ={...qq,...YK,nestedDialogOpen(e){return e?{[_Z.nestedDialogOpen]:``}:null}},xZ=W.forwardRef(function(e,t){let{className:n,finalFocus:r,initialFocus:i,render:a,...o}=e,{store:s}=fZ(),c=s.useState(`descriptionElementId`),l=s.useState(`disablePointerDismissal`),u=s.useState(`floatingRootContext`),d=s.useState(`popupProps`),f=s.useState(`modal`),p=s.useState(`mounted`),m=s.useState(`nested`),h=s.useState(`nestedOpenDialogCount`),g=s.useState(`open`),_=s.useState(`openMethod`),v=s.useState(`titleElementId`),y=s.useState(`transitionStatus`),b=s.useState(`role`);yZ(),ZK({open:g,ref:s.context.popupRef,onComplete(){g&&s.context.onOpenChangeComplete?.(!0)}});function x(e){return e===`touch`?s.context.popupRef.current:!0}let S=i===void 0?x:i,C=Sz(`div`,e,{state:{open:g,nested:m,transitionStatus:y,nestedDialogOpen:h>0},props:[d,{"aria-labelledby":v??void 0,"aria-describedby":c??void 0,role:b,tabIndex:-1,hidden:!p,onKeyDown(e){cX.has(e.key)&&e.stopPropagation()},style:{[gZ.nestedDialogs]:h}},o],ref:[t,s.context.popupRef,s.useStateSetter(`popupElement`)],stateAttributesMapping:bZ});return(0,G.jsx)(vG,{context:u,openInteractionType:_,disabled:!p,closeOnFocusOut:!l,initialFocus:S,returnFocus:r,modal:f!==!1,restoreFocus:`popup`,children:C})}),SZ=W.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i}=fZ(),a=i.useState(`mounted`),o=i.useState(`modal`),s=i.useState(`open`);return a||n?(0,G.jsx)(vZ.Provider,{value:n,children:(0,G.jsxs)(nG,{ref:t,...r,children:[a&&o===!0&&(0,G.jsx)(VY,{ref:i.context.internalBackdropRef,inert:vJ(!s)}),e.children]})}):null});function CZ(e){let{store:t,parentContext:n,actionsRef:r}=e,i=t.useState(`open`),a=t.useState(`disablePointerDismissal`),o=t.useState(`modal`),s=t.useState(`popupElement`),{openMethod:c,triggerProps:l}=mY(i);eq(t);let{forceUnmount:u}=tq(i,t),d=X(e=>{let n=UB(e);return n.preventUnmountOnClose=()=>{t.set(`preventUnmountingOnClose`,!0)},n}),f=W.useCallback(()=>{t.setOpen(!1,d(VB))},[t,d]);W.useImperativeHandle(r,()=>({unmount:u,close:f}),[u,f]);let p=lq({popupStore:t,onOpenChange:t.setOpen,treatPopupAsFloatingElement:!0,noEmit:!0}),[m,h]=W.useState(0),g=m===0,_=Tq(p),v=TG(p,{outsidePressEvent(){return t.context.internalBackdropRef.current||t.context.backdropRef.current?`intentional`:{mouse:o===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}},outsidePress(e){if(!t.context.outsidePressEnabledRef.current||`button`in e&&e.button!==0||`touches`in e&&e.touches.length!==1)return!1;let n=BH(e);if(g&&!a){let e=n;return o&&(t.context.internalBackdropRef.current||t.context.backdropRef.current)?t.context.internalBackdropRef.current===e||t.context.backdropRef.current===e||RH(e,s)&&!e?.hasAttribute(`data-base-ui-portal`):!0}return!1},escapeKey:g});MY(i&&o===!0,s);let{getReferenceProps:y,getFloatingProps:b,getTriggerProps:x}=xq([_,v]);t.useContextCallback(`onNestedDialogOpen`,e=>{h(e+1)}),t.useContextCallback(`onNestedDialogClose`,()=>{h(0)}),W.useEffect(()=>(n?.onNestedDialogOpen&&i&&n.onNestedDialogOpen(m),n?.onNestedDialogClose&&!i&&n.onNestedDialogClose(),()=>{n?.onNestedDialogClose&&i&&n.onNestedDialogClose()}),[i,n,m]);let S=W.useMemo(()=>y(l),[y,l]),C=W.useMemo(()=>x(l),[x,l]),w=W.useMemo(()=>b(),[b]);t.useSyncedValues({openMethod:c,activeTriggerProps:S,inactiveTriggerProps:C,popupProps:w,floatingRootContext:p,nestedOpenDialogCount:m})}var wZ={...oq,modal:$(e=>e.modal),nested:$(e=>e.nested),nestedOpenDialogCount:$(e=>e.nestedOpenDialogCount),disablePointerDismissal:$(e=>e.disablePointerDismissal),openMethod:$(e=>e.openMethod),descriptionElementId:$(e=>e.descriptionElementId),titleElementId:$(e=>e.titleElementId),viewportElement:$(e=>e.viewportElement),role:$(e=>e.role)},TZ=class extends HK{constructor(e){super(EZ(e),{popupRef:W.createRef(),backdropRef:W.createRef(),internalBackdropRef:W.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:new nq,onOpenChange:void 0,onOpenChangeComplete:void 0},wZ)}setOpen=(e,t)=>{if(t.preventUnmountOnClose=()=>{this.set(`preventUnmountingOnClose`,!0)},!e&&t.trigger==null&&this.state.activeTriggerId!=null&&(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;let n={open:e,nativeEvent:t.event,reason:t.reason,nested:this.state.nested};this.state.floatingRootContext.context.events?.emit(`openchange`,n);let r={open:e},i=t.trigger?.id??null;(i||e)&&(r.activeTriggerId=i,r.activeTriggerElement=t.trigger??null),this.update(r)}};function EZ(e={}){return{...iq(),modal:!0,disablePointerDismissal:!1,popupElement:null,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,role:`dialog`,...e}}function DZ(e){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,disablePointerDismissal:o=!1,modal:s=!0,actionsRef:c,handle:l,triggerId:u,defaultTriggerId:d=null}=e,f=fZ(!0),p=!!f,m=PR(()=>l?.store??new TZ({open:r,openProp:n,activeTriggerId:d,triggerIdProp:u,modal:s,disablePointerDismissal:o,nested:p})).current;mH(()=>{n===void 0&&m.state.open===!1&&r===!0&&m.update({open:!0,activeTriggerId:d})}),m.useControlledProp(`openProp`,n),m.useControlledProp(`triggerIdProp`,u),m.useSyncedValues({disablePointerDismissal:o,nested:p,modal:s}),m.useContextCallback(`onOpenChange`,i),m.useContextCallback(`onOpenChangeComplete`,a);let h=m.useState(`payload`);CZ({store:m,actionsRef:c,parentContext:f?.store.context,onOpenChange:i,triggerIdProp:u});let g=W.useMemo(()=>({store:m}),[m]);return(0,G.jsx)(dZ.Provider,{value:g,children:typeof t==`function`?t({payload:h}):t})}var OZ=W.forwardRef(function(e,t){let{render:n,className:r,id:i,...a}=e,{store:o}=fZ(),s=Mz(i);return o.useSyncedValueWithCleanup(`titleElementId`,s),Sz(`h2`,e,{ref:t,props:[{id:s},a]})}),kZ=DZ,AZ=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(mZ,{ref:n,className:Y(`fixed inset-0 z-50 bg-black/60 backdrop-blur-sm`,e),...t}));AZ.displayName=`DialogOverlay`;var jZ=(0,W.forwardRef)(({className:e,children:t,...n},r)=>(0,G.jsxs)(SZ,{children:[(0,G.jsx)(mZ,{className:`fixed inset-0 z-50 bg-black/60 backdrop-blur-sm`}),(0,G.jsx)(xZ,{ref:r,className:Y(`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})]}));jZ.displayName=`DialogContent`;var MZ=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(`div`,{ref:n,className:Y(`px-5 py-3 border-b border-border`,e),...t}));MZ.displayName=`DialogHeader`;var NZ=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(`div`,{ref:n,className:Y(`px-5 py-3 border-t border-border flex justify-end gap-2`,e),...t}));NZ.displayName=`DialogFooter`;var PZ=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(OZ,{ref:n,className:Y(`font-mono text-[10px] text-neutral-500 uppercase tracking-widest`,e),...t}));PZ.displayName=`DialogTitle`;var FZ=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(hZ,{ref:n,className:Y(`font-mono text-[10px] text-neutral-500`,e),...t}));FZ.displayName=`DialogDescription`;var IZ=(0,W.forwardRef)(({className:e,page:t,totalPages:n,totalItems:r,onPageChange:i,...a},o)=>(0,G.jsxs)(`div`,{ref:o,className:Y(`px-5 py-2.5 border-t border-border flex items-center justify-between`,e),...a,children:[(0,G.jsxs)(`span`,{className:`font-mono text-[10px] text-neutral-600`,children:[r,` items · Page `,t,` of `,n]}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(Q,{size:`sm`,variant:`default`,disabled:t<=1,onClick:()=>i(t-1),children:`Prev`}),(0,G.jsx)(Q,{size:`sm`,variant:`default`,disabled:t>=n,onClick:()=>i(t+1),children:`Next`})]})]}));IZ.displayName=`Pagination`;var LZ=(0,W.forwardRef)(({className:e,orientation:t=`horizontal`,...n},r)=>(0,G.jsx)(`hr`,{ref:r,"aria-orientation":t===`vertical`?`vertical`:void 0,className:Y(`border-none m-0`,t===`horizontal`?`h-px w-full bg-border`:`w-px h-4 bg-border`,e),...n}));LZ.displayName=`Separator`;var RZ=kR(`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=(0,W.forwardRef)(({className:e,side:t,children:n,...r},i)=>(0,G.jsxs)(SZ,{children:[(0,G.jsx)(mZ,{className:`fixed inset-0 z-50 bg-black/60 backdrop-blur-sm`}),(0,G.jsx)(xZ,{ref:i,className:Y(RZ({side:t,className:e})),...r,children:n})]}));zZ.displayName=`SheetContent`;var BZ=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(`div`,{ref:n,className:Y(`px-5 py-3 border-b border-border`,e),...t}));BZ.displayName=`SheetHeader`;var VZ=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(`div`,{ref:n,className:Y(`px-5 py-3 border-t border-border flex justify-end gap-2`,e),...t}));VZ.displayName=`SheetFooter`;var HZ=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(OZ,{ref:n,className:Y(`font-mono text-[10px] text-neutral-500 uppercase tracking-widest`,e),...t}));HZ.displayName=`SheetTitle`;var UZ=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(hZ,{ref:n,className:Y(`text-sm text-neutral-400`,e),...t}));UZ.displayName=`SheetDescription`;var WZ=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(`div`,{ref:n,className:Y(`rounded-md bg-neutral-800 animate-pulse`,e),...t}));WZ.displayName=`Skeleton`;var GZ=W.createContext(void 0);function KZ(){let e=W.useContext(GZ);if(e===void 0)throw Error(QR(64));return e}var qZ=function(e){return e.activationDirection=`data-activation-direction`,e.orientation=`data-orientation`,e}({}),JZ={tabActivationDirection:e=>({[qZ.activationDirection]:e})},YZ=W.createContext(void 0);function XZ(){let e=W.useContext(YZ);if(e===void 0)throw Error(QR(65));return e}var ZZ=W.forwardRef(function(e,t){let{className:n,disabled:r=!1,render:i,value:a,id:o,nativeButton:s=!0,...c}=e,{value:l,getTabPanelIdByValue:u,orientation:d}=KZ(),{activateOnFocus:f,highlightedTabIndex:p,onTabActivation:m,registerTabResizeObserverElement:h,setHighlightedTabIndex:g,tabsListElement:_}=XZ(),v=Mz(o),{compositeProps:y,compositeRef:b,index:x}=RX({metadata:W.useMemo(()=>({disabled:r,id:v,value:a}),[r,v,a])}),S=a===l,C=W.useRef(!1),w=W.useRef(null);W.useEffect(()=>{let e=w.current;if(e)return h(e)},[h]),Z(()=>{if(C.current){C.current=!1;return}if(!(S&&x>-1&&p!==x))return;let e=_;if(e!=null){let t=LH(gW(e));if(t&&RH(e,t))return}r||g(x)},[S,x,p,g,r,_]);let{getButtonProps:T,buttonRef:E}=sB({disabled:r,native:s,focusableWhenDisabled:!0}),D=u(a),O=W.useRef(!1),k=W.useRef(!1);function A(e){S||r||m(a,UB(jB,e.nativeEvent,void 0,{activationDirection:`none`}))}function j(e){S||(x>-1&&!r&&g(x),!r&&f&&(!O.current||O.current&&k.current)&&m(a,UB(jB,e.nativeEvent,void 0,{activationDirection:`none`})))}function M(e){if(S||r)return;O.current=!0;function t(){O.current=!1,k.current=!1}(!e.button||e.button===0)&&(k.current=!0,gW(e.currentTarget).addEventListener(`pointerup`,t,{once:!0}))}return Sz(`button`,e,{state:{disabled:r,active:S,orientation:d},ref:[t,E,b,w],props:[y,{role:`tab`,"aria-controls":D,"aria-selected":S,id:v,onClick:A,onFocus:j,onPointerDown:M,[UX]:S?``:void 0,onKeyDownCapture(){C.current=!0}},c,T]})}),QZ=function(e){return e.index=`data-index`,e.activationDirection=`data-activation-direction`,e.orientation=`data-orientation`,e.hidden=`data-hidden`,e[e.startingStyle=KK.startingStyle]=`startingStyle`,e[e.endingStyle=KK.endingStyle]=`endingStyle`,e}({}),$Z={...JZ,...YK},eQ=W.forwardRef(function(e,t){let{className:n,value:r,render:i,keepMounted:a=!1,...o}=e,{value:s,getTabIdByPanelValue:c,orientation:l,tabActivationDirection:u,registerMountedTabPanel:d,unregisterMountedTabPanel:f}=KZ(),p=Mz(),{ref:m,index:h}=kX({metadata:W.useMemo(()=>({id:p,value:r}),[p,r])}),g=r===s,{mounted:_,transitionStatus:v,setMounted:y}=GK(g),b=!_,x=c(r),S={hidden:b,orientation:l,tabActivationDirection:u,transitionStatus:v},C=W.useRef(null),w=Sz(`div`,e,{state:S,ref:[t,m,C],props:[{"aria-labelledby":x,hidden:b,id:p,role:`tabpanel`,tabIndex:g?0:-1,inert:vJ(!g),[QZ.index]:h},o],stateAttributesMapping:$Z});return ZK({open:g,ref:C,onComplete(){g||y(!1)}}),Z(()=>{if(!(b&&!a)&&p!=null)return d(r,p),()=>{f(r,p)}},[b,a,r,p,d,f]),a||_?w:null}),tQ=W.forwardRef(function(e,t){let{activateOnFocus:n=!1,className:r,loopFocus:i=!0,render:a,...o}=e,{getTabElementBySelectedValue:s,onValueChange:c,orientation:l,value:u,setTabMap:d,tabActivationDirection:f}=KZ(),[p,m]=W.useState(0),[h,g]=W.useState(null),_=W.useRef(new Set),v=W.useRef(new Set),y=W.useRef(null),b=X(()=>{_.current.forEach(e=>{e()})});W.useEffect(()=>{if(typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>{_.current.size&&b()});return y.current=e,h&&e.observe(h),v.current.forEach(t=>{e.observe(t)}),()=>{e.disconnect(),y.current=null}},[h,b]);let x=X(e=>(_.current.add(e),()=>{_.current.delete(e)})),S=X(e=>(v.current.add(e),y.current?.observe(e),()=>{v.current.delete(e),y.current?.unobserve(e)})),C=rQ(u,l,h,s),w=X((e,t)=>{e!==u&&(t.activationDirection=C(e),c(e,t))}),T={orientation:l,tabActivationDirection:f},E={"aria-orientation":l===`vertical`?`vertical`:void 0,role:`tablist`},D=W.useMemo(()=>({activateOnFocus:n,highlightedTabIndex:p,registerIndicatorUpdateListener:x,registerTabResizeObserverElement:S,onTabActivation:w,setHighlightedTabIndex:m,tabsListElement:h}),[n,p,x,S,w,m,h]);return(0,G.jsx)(YZ.Provider,{value:D,children:(0,G.jsx)(qX,{render:a,className:r,state:T,refs:[t,g],props:[E,o],stateAttributesMapping:JZ,highlightedIndex:p,enableHomeAndEndKeys:!0,loopFocus:i,orientation:l,onHighlightedIndexChange:m,onMapChange:d,disabledIndices:YR})})});function nQ(e,t){let{left:n,top:r}=e.getBoundingClientRect(),{left:i,top:a}=t.getBoundingClientRect();return{left:n-i,top:r-a}}function rQ(e,t,n,r){let[i,a]=W.useState(null);return Z(()=>{if(e==null||n==null){a(null);return}let i=r(e);if(i==null){a(null);return}let{left:o,top:s}=nQ(i,n);a(t===`horizontal`?o:s)},[t,r,n,e]),W.useCallback(o=>{if(o===e)return`none`;if(o==null)return a(null),`none`;if(o!=null&&n!=null){let e=r(o);if(e!=null){let{left:r,top:o}=nQ(e,n);if(i==null)return a(t===`horizontal`?r:o),`none`;if(t===`horizontal`){if(r<i)return a(r),`left`;if(r>i)return a(r),`right`}else if(o<i)return a(o),`up`;else if(o>i)return a(o),`down`}}return`none`},[r,t,i,n,e])}var iQ=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(tQ,{ref:n,className:Y(`flex items-center gap-0.5`,e),...t}));iQ.displayName=`TabsList`;var aQ=kR(`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`}}),oQ=(0,W.forwardRef)(({className:e,variant:t,...n},r)=>(0,G.jsx)(ZZ,{ref:r,className:Y(aQ({variant:t,className:e})),...n}));oQ.displayName=`TabsTrigger`;var sQ=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(eQ,{ref:n,className:Y(`outline-none`,e),...t}));sQ.displayName=`TabsContent`;var cQ=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(`p`,{ref:n,className:Y(`font-mono text-[11px] text-neutral-300`,e),...t}));cQ.displayName=`Text`;var lQ=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(`p`,{ref:n,className:Y(`font-mono text-[10px] text-neutral-500`,e),...t}));lQ.displayName=`TextMuted`;var uQ=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(`code`,{ref:n,className:Y(`font-mono text-[11px] text-white`,e),...t}));uQ.displayName=`TextCode`;var dQ=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(`span`,{ref:n,className:Y(`font-mono text-[9px] uppercase tracking-wider text-neutral-500`,e),...t}));dQ.displayName=`TextLabel`;var fQ=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(`pre`,{ref:n,className:Y(`font-mono text-[11px] text-neutral-300 p-3 rounded border border-border bg-panel-alt overflow-x-auto`,e),...t}));fQ.displayName=`CodeBlock`;function pQ(e,t){let[n,r]=(0,W.useState)(()=>{if(typeof window>`u`)return t;try{let n=window.localStorage.getItem(e);return n===null?t:JSON.parse(n)}catch{return t}});return(0,W.useEffect)(()=>{try{n==null?window.localStorage.removeItem(e):window.localStorage.setItem(e,JSON.stringify(n))}catch{}},[e,n]),[n,(0,W.useCallback)(e=>{r(t=>typeof e==`function`?e(t):e)},[])]}var mQ=`console:instance-id`;function hQ(){let[e,t]=pQ(mQ,``),n=e.trim();return(0,W.useMemo)(()=>({instanceId:n.length>0?n:void 0,rawInstanceId:e,setInstanceId:t,clearInstanceId:()=>t(``)}),[n,e,t])}var gQ={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 _Q(e,t){return e===0?!1:e??t}function vQ(e){let t=new URLSearchParams;if(!e)return t;for(let[n,r]of Object.entries(e))r!=null&&t.set(n,String(r));return t}function yQ(e,t,n){let r=e.endsWith(`/`)?e.slice(0,-1):e,i=vQ(n)?.toString();return`${r}${t}${i?`?${i}`:``}`}function bQ(e,t){if(!t||!e)throw Error(`Not connected`);return e}async function xQ(e){let t={Authorization:`Bearer ${e.connectionConfig.token}`};e.body!==void 0&&(t[`Content-Type`]=`application/json`);let n=await fetch(yQ(e.connectionConfig.serverUrl,e.path,e.query),{method:e.method??`GET`,headers:t,body:e.body===void 0?void 0:JSON.stringify(e.body)});if(!n.ok)throw Error(e.errorMessage);return n.json()}async function SQ(e){let t=await fetch(yQ(e.connectionConfig.serverUrl,e.path,e.query),{method:`GET`,headers:{Authorization:`Bearer ${e.connectionConfig.token}`}});if(!t.ok)throw Error(e.errorMessage);return t.blob()}function CQ(e){let{config:t,isConnected:n}=Py();return ah({queryKey:e.queryKey,queryFn:()=>xQ({connectionConfig:bQ(t,n),path:e.path,query:e.query,method:e.method,errorMessage:e.errorMessage}),enabled:(e.enabled??!0)&&n&&!!t,refetchInterval:e.refetchInterval})}function wQ(e){let{config:t,isConnected:n}=Py();return ah({queryKey:e.queryKey,queryFn:()=>{if(e.id===void 0)throw Error(e.requiredMessage);return xQ({connectionConfig:bQ(t,n),path:e.path(e.id),query:e.query,errorMessage:e.errorMessage})},enabled:(e.enabled??!0)&&e.id!==void 0&&n&&!!t})}function TQ(e,t){for(let n of t)e.invalidateQueries({queryKey:n})}function EQ(e){let{instanceId:t}=hQ();return e??t}function DQ(e){let{config:t,isConnected:n}=Py(),{instanceId:r}=hQ(),i=Wm();return oh({mutationFn:i=>e.mutationFn({connectionConfig:bQ(t,n),variables:i,selectedInstanceId:r}),onSuccess:()=>{e.invalidateQueryKeys&&TQ(i,e.invalidateQueryKeys)}})}function OQ(e={}){let t=EQ(e.instanceId);return CQ({queryKey:gQ.stats({partitionId:e.partitionId,instanceId:t}),path:`/console/stats`,query:{partitionId:e.partitionId,instanceId:t},errorMessage:`Failed to fetch stats`,refetchInterval:_Q(e.refetchIntervalMs,5e3)})}function kQ(e={},t={}){let n=EQ(e.instanceId);return CQ({queryKey:gQ.timeseries({...e,instanceId:n}),path:`/console/stats/timeseries`,query:{interval:e.interval,range:e.range,partitionId:e.partitionId,instanceId:n},errorMessage:`Failed to fetch timeseries stats`,enabled:t.enabled,refetchInterval:_Q(t.refetchIntervalMs,3e4)})}function AQ(e={},t={}){let n=EQ(e.instanceId);return CQ({queryKey:gQ.latency({...e,instanceId:n}),path:`/console/stats/latency`,query:{range:e.range,partitionId:e.partitionId,instanceId:n},errorMessage:`Failed to fetch latency stats`,enabled:t.enabled,refetchInterval:_Q(t.refetchIntervalMs,3e4)})}function jQ(e={},t={}){let n=EQ(e.instanceId);return CQ({queryKey:gQ.commits({...e,instanceId:n}),path:`/console/commits`,query:{limit:e.limit,offset:e.offset,partitionId:e.partitionId,instanceId:n},errorMessage:`Failed to fetch commits`,enabled:t.enabled,refetchInterval:_Q(t.refetchIntervalMs,1e4)})}function MQ(e,t={}){let n=EQ(t.instanceId);return wQ({queryKey:gQ.commitDetail(e,t.partitionId,n),id:e,requiredMessage:`Commit sequence is required`,path:e=>`/console/commits/${encodeURIComponent(String(e))}`,query:{partitionId:t.partitionId,instanceId:n},errorMessage:`Failed to fetch commit detail`,enabled:t.enabled})}function NQ(e={},t={}){let n=EQ(e.instanceId);return CQ({queryKey:gQ.timeline({...e,instanceId:n}),path:`/console/timeline`,query:{limit:e.limit,offset:e.offset,partitionId:e.partitionId,view:e.view,eventType:e.eventType,actorId:e.actorId,clientId:e.clientId,requestId:e.requestId,traceId:e.traceId,table:e.table,outcome:e.outcome,search:e.search,from:e.from,to:e.to,instanceId:n},errorMessage:`Failed to fetch timeline`,enabled:t.enabled,refetchInterval:_Q(t.refetchIntervalMs,1e4)})}function PQ(e={},t={}){let n=EQ(e.instanceId);return CQ({queryKey:gQ.clients({...e,instanceId:n}),path:`/console/clients`,query:{limit:e.limit,offset:e.offset,partitionId:e.partitionId,instanceId:n},errorMessage:`Failed to fetch clients`,enabled:t.enabled,refetchInterval:_Q(t.refetchIntervalMs,1e4)})}function FQ(e,t={}){let n=EQ(t.instanceId);return wQ({queryKey:gQ.eventDetail(e,t.partitionId,n),id:e,requiredMessage:`Event id is required`,path:e=>`/console/events/${encodeURIComponent(String(e))}`,query:{partitionId:t.partitionId,instanceId:n},errorMessage:`Failed to fetch event detail`,enabled:t.enabled})}function IQ(e,t={}){let n=EQ(t.instanceId);return wQ({queryKey:gQ.eventPayload(e,t.partitionId,n),id:e,requiredMessage:`Event id is required`,path:e=>`/console/events/${encodeURIComponent(String(e))}/payload`,query:{partitionId:t.partitionId,instanceId:n},errorMessage:`Failed to fetch event payload`,enabled:t.enabled})}function LQ(e={}){let t=EQ(e.instanceId);return CQ({queryKey:gQ.handlers(t),path:`/console/handlers`,query:{instanceId:t},errorMessage:`Failed to fetch handlers`})}function RQ(e={}){let t=EQ(e.instanceId);return CQ({queryKey:gQ.prunePreview(t),path:`/console/prune/preview`,query:{instanceId:t},method:`POST`,errorMessage:`Failed to fetch prune preview`,enabled:e.enabled})}function zQ(e={},t={}){let n=EQ(e.instanceId);return CQ({queryKey:gQ.operations({...e,instanceId:n}),path:`/console/operations`,query:{limit:e.limit,offset:e.offset,operationType:e.operationType,partitionId:e.partitionId,instanceId:n},errorMessage:`Failed to fetch operations`,enabled:t.enabled,refetchInterval:_Q(t.refetchIntervalMs,1e4)})}function BQ(){return DQ({mutationFn:async({connectionConfig:e,selectedInstanceId:t})=>xQ({connectionConfig:e,path:`/console/events`,query:{instanceId:t},method:`DELETE`,errorMessage:`Failed to clear events`}),invalidateQueryKeys:[[`console`,`events`]]})}function VQ(){return DQ({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>{let r=t.instanceId??n;return xQ({connectionConfig:e,path:`/console/clients/${encodeURIComponent(t.clientId)}`,query:{partitionId:t.partitionId,instanceId:r},method:`DELETE`,errorMessage:`Failed to evict client`})},invalidateQueryKeys:[[`console`,`clients`],[`console`,`stats`],[`console`,`operations`]]})}function HQ(){return DQ({mutationFn:async({connectionConfig:e,selectedInstanceId:t})=>xQ({connectionConfig:e,path:`/console/prune`,query:{instanceId:t},method:`POST`,errorMessage:`Failed to prune`}),invalidateQueryKeys:[[`console`,`stats`],[`console`,`commits`],[`console`,`timeline`],[`console`,`prune`,`preview`],[`console`,`operations`]]})}function UQ(){return DQ({mutationFn:async({connectionConfig:e,selectedInstanceId:t})=>xQ({connectionConfig:e,path:`/console/compact`,query:{instanceId:t},method:`POST`,errorMessage:`Failed to compact`}),invalidateQueryKeys:[[`console`,`stats`],[`console`,`operations`]]})}function WQ(){return DQ({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>xQ({connectionConfig:e,path:`/console/notify-data-change`,query:{instanceId:t.instanceId??n},method:`POST`,body:{tables:t.tables,partitionId:t.partitionId},errorMessage:`Failed to notify data change`}),invalidateQueryKeys:[[`console`,`stats`],[`console`,`commits`],[`console`,`timeline`],[`console`,`operations`]]})}function GQ(e={}){let t=EQ(e.instanceId);return CQ({queryKey:gQ.apiKeys({...e,instanceId:t}),path:`/console/api-keys`,query:{limit:e.limit,offset:e.offset,type:e.type,status:e.status,expiresWithinDays:e.expiresWithinDays,instanceId:t},errorMessage:`Failed to fetch API keys`})}function KQ(){return DQ({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>xQ({connectionConfig:e,path:`/console/api-keys`,query:{instanceId:n},method:`POST`,body:t,errorMessage:`Failed to create API key`}),invalidateQueryKeys:[[`console`,`api-keys`]]})}function qQ(){return DQ({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>xQ({connectionConfig:e,path:`/console/api-keys/${encodeURIComponent(t)}`,query:{instanceId:n},method:`DELETE`,errorMessage:`Failed to revoke API key`}),invalidateQueryKeys:[[`console`,`api-keys`]]})}function JQ(){return DQ({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>xQ({connectionConfig:e,path:`/console/api-keys/bulk-revoke`,query:{instanceId:n},method:`POST`,body:t,errorMessage:`Failed to bulk revoke API keys`}),invalidateQueryKeys:[[`console`,`api-keys`]]})}function YQ(){return DQ({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>xQ({connectionConfig:e,path:`/console/api-keys/${encodeURIComponent(t)}/rotate`,query:{instanceId:n},method:`POST`,errorMessage:`Failed to rotate API key`}),invalidateQueryKeys:[[`console`,`api-keys`]]})}function XQ(){return DQ({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>xQ({connectionConfig:e,path:`/console/api-keys/${encodeURIComponent(t)}/rotate/stage`,query:{instanceId:n},method:`POST`,errorMessage:`Failed to stage-rotate API key`}),invalidateQueryKeys:[[`console`,`api-keys`]]})}function ZQ(e={}){return CQ({queryKey:gQ.storage({prefix:e.prefix,cursor:e.cursor,limit:e.limit}),path:`/console/storage`,query:{prefix:e.prefix,cursor:e.cursor,limit:e.limit},errorMessage:`Failed to list blobs`,refetchInterval:_Q(e.refetchIntervalMs,3e4)})}function QQ(){return DQ({mutationFn:async({connectionConfig:e,variables:t})=>xQ({connectionConfig:e,path:`/console/storage/${encodeURIComponent(t)}`,method:`DELETE`,errorMessage:`Failed to delete blob`}),invalidateQueryKeys:[[`console`,`storage`]]})}function $Q(){let{config:e,isConnected:t}=Py();return async n=>{let r=await SQ({connectionConfig:bQ(e,t),path:`/console/storage/${encodeURIComponent(n)}/download`,errorMessage:`Failed to download blob`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=n.split(`/`).pop()||n,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}}var e$=`console:partition-id`;function t$(){let[e,t]=pQ(e$,``),n=e.trim();return(0,W.useMemo)(()=>({partitionId:n.length>0?n:void 0,rawPartitionId:e,setPartitionId:t,clearPartitionId:()=>t(``)}),[n,e,t])}var n$={refreshInterval:5,timeFormat:`relative`,showSparklines:!0,pageSize:20};function r$(){let[e,t]=pQ(`console:preferences`,n$);return{preferences:e,setPreferences:t,updatePreference:(e,n)=>{t(t=>({...t,[e]:n}))},resetPreferences:()=>{t(n$)}}}var i$=[{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`}],a$=[{value:10,label:`10`},{value:20,label:`20`},{value:50,label:`50`},{value:100,label:`100`}],o$=`syncular-console-root`;function s$(e){e.classList.add(o$)}var c$=[{suffix:``,label:`Command`},{suffix:`/stream`,label:`Stream`},{suffix:`/fleet`,label:`Fleet`},{suffix:`/ops`,label:`Ops`},{suffix:`/storage`,label:`Storage`},{suffix:`/config`,label:`Config`}];function l$(e){let t=e?.trim()??``;return!t||t===`/`?``:(t.startsWith(`/`)?t:`/${t}`).replace(/\/+$/g,``)}function u$(e,t){return e?t?`${e}${t}`:e:t||`/`}function d$({basePath:e,appHref:t,modeBadge:n}){let{connect:r,config:i,isConnected:a,isConnecting:o}=Py(),{preferences:s}=r$(),{instanceId:c,rawInstanceId:l,setInstanceId:u,clearInstanceId:d}=hQ(),{partitionId:f,rawPartitionId:p,setPartitionId:m,clearPartitionId:h}=t$(),g=cy({select:e=>e.location.pathname}),{data:_}=OQ({refetchIntervalMs:s.refreshInterval*1e3,partitionId:f,instanceId:c}),v=l$(e),y=(0,W.useMemo)(()=>c$.map(e=>({...e,id:u$(v,e.suffix)})),[v]),b=u$(v,``),x=u$(v,`/config`),S=o?`connecting`:a?`connected`:i?`disconnected`:`not-configured`,C=y.find(e=>e.suffix===``?g===b||g===`${b}/`:g.startsWith(e.id))?.id??b,w=_?[{label:`HEAD`,value:`#${_.maxCommitSeq}`},{label:`COMMITS`,value:`${_.commitCount}`},{label:`CHANGES`,value:`${_.changeCount}`},{label:`CLIENTS`,value:`${_.activeClientCount}/${_.clientCount}`}]:[];return(0,G.jsxs)(`div`,{className:`${o$} h-screen bg-background text-foreground flex flex-col`,children:[(0,G.jsx)(oZ,{brand:(0,G.jsx)(zv,{to:b,children:(0,G.jsx)(aZ,{label:`console`})}),center:(0,G.jsx)(eZ,{items:y,activeId:C,renderItem:(e,{active:t})=>(0,G.jsx)(zv,{to:e.id,children:(0,G.jsx)($X,{active:t,children:e.label})},e.id)}),right:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?(0,G.jsx)(ZB,{variant:`flow`,className:`hidden md:inline-flex px-2 py-1 text-[10px]`,children:n}):null,(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`span`,{className:`font-mono text-[9px] text-neutral-500 uppercase tracking-wide`,children:`Instance`}),(0,G.jsx)(jR,{variant:`mono`,value:l,onChange:e=>u(e.target.value),onBlur:e=>u(e.target.value.trim()),placeholder:`all`,className:`h-7 w-[110px] px-2 py-1`}),c?(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-[10px]`,onClick:d,children:`All`}):null]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`span`,{className:`font-mono text-[9px] text-neutral-500 uppercase tracking-wide`,children:`Partition`}),(0,G.jsx)(jR,{variant:`mono`,value:p,onChange:e=>m(e.target.value),onBlur:e=>m(e.target.value.trim()),placeholder:`all`,className:`h-7 w-[110px] px-2 py-1`}),f?(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-[10px]`,onClick:h,children:`All`}):null]}),(0,G.jsx)(fV,{state:S}),(0,G.jsx)(zv,{to:x,children:(0,G.jsx)(Q,{variant:g===x?`secondary`:`ghost`,size:`icon`,children:(0,G.jsx)(LV,{className:`h-3 w-3`})})}),t?(0,G.jsxs)(`a`,{href:t,className:QX,children:[(0,G.jsx)(IV,{className:`h-3 w-3`}),`Go to app`]}):null]})}),(0,G.jsx)(`main`,{className:`flex-1 overflow-auto pb-[32px]`,children:(0,G.jsx)(`div`,{className:`min-h-full`,children:a||g===x?(0,G.jsx)(`div`,{style:{animation:`pageIn 0.3s ease-out`},children:(0,G.jsx)($v,{})},g):(0,G.jsx)(f$,{configPath:x,hasSavedConfig:!!i,isConnecting:o,onConnect:()=>{r()}})})}),a&&(0,G.jsx)(oV,{isLive:a,metrics:w,uptime:`--`})]})}function f$({configPath:e,hasSavedConfig:t,isConnecting:n,onConnect:r}){return(0,G.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16`,children:[(0,G.jsx)(`p`,{className:`mb-4 text-foreground-muted`,children:`Not connected to a @syncular server`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t&&(0,G.jsx)(Q,{variant:`default`,onClick:r,disabled:n,children:n?`Connecting...`:`Connect`}),(0,G.jsx)(zv,{to:e,children:(0,G.jsx)(Q,{variant:`link`,children:`Configure connection`})})]})]})}var p$=Wv({component:d$});function m$(e={}){let{maxEvents:t=100,enabled:n=!0,staleAfterMs:r=65e3,replayLimit:i=100,partitionId:a,instanceId:o}=e,{config:s,isConnected:c}=Py(),{instanceId:l}=hQ(),u=o??l,[d,f]=(0,W.useState)([]),[p,m]=(0,W.useState)(!1),[h,g]=(0,W.useState)(`disconnected`),[_,v]=(0,W.useState)(null),y=(0,W.useRef)(null),b=(0,W.useRef)(null),x=(0,W.useRef)(null),S=(0,W.useRef)(0),C=(0,W.useRef)(0),w=(0,W.useRef)(null),T=(0,W.useCallback)(()=>{f([]),w.current=null},[]);return(0,W.useEffect)(()=>{if(!n||!c||!s?.serverUrl||!s?.token)return;let e=!1,o=Number.isFinite(i)?Math.max(1,Math.min(500,Math.floor(i))):100;if(typeof WebSocket>`u`)return;let l=()=>{b.current&&=(clearTimeout(b.current),null)},d=()=>{x.current&&=(clearInterval(x.current),null)},p=()=>{if(e||b.current)return;S.current+=1;let t=Math.min(3e4,1e3*2**Math.max(0,S.current-1)),n=t+Math.floor(t*.2*Math.random());b.current=setTimeout(()=>{b.current=null,e||_()},n)},h=()=>{C.current=Date.now(),m(!0),g(`connected`)},_=()=>{if(e)return;g(`connecting`),l();let n=(()=>{let e=new URL(s.serverUrl,window.location.origin);return e.protocol=e.protocol===`https:`?`wss:`:`ws:`,e.pathname=`${e.pathname.endsWith(`/`)?e.pathname.slice(0,-1):e.pathname}/console/events/live`,e.search=``,w.current&&e.searchParams.set(`since`,w.current),e.searchParams.set(`replayLimit`,String(o)),a&&e.searchParams.set(`partitionId`,a),u&&e.searchParams.set(`instanceId`,u),e.toString()})(),i=new WebSocket(n);y.current=i,i.onopen=()=>{if(e){i.close();return}S.current=0,v(null),g(`connecting`),m(!1);try{i.send(JSON.stringify({type:`auth`,token:s.token}))}catch{i.close();return}d(),x.current=setInterval(()=>{let e=y.current;if(!e||e.readyState!==WebSocket.OPEN)return;let t=C.current;t&&(Date.now()-t<=r||(m(!1),g(`stale`),e.close()))},1e3)},i.onclose=()=>{e||(m(!1),g(`disconnected`),d(),p())},i.onerror=()=>{e||v(Error(`WebSocket connection failed`))},i.onmessage=e=>{try{let n=JSON.parse(e.data),r=n.type;if(h(),r===`connected`||r===`heartbeat`||r===`auth_required`)return;if(r===`error`){let e=typeof n.message==`string`?n.message:`Live events authentication failed`;v(Error(e));return}let i={type:r,timestamp:n.timestamp||new Date().toISOString(),data:n};if(a&&i.data.partitionId!==a||u&&i.data.instanceId!==u)return;let o=Date.parse(w.current??``),s=Date.parse(i.timestamp);Number.isFinite(s)&&(!Number.isFinite(o)||s>o)&&(w.current=i.timestamp),f(e=>[i,...e].slice(0,t))}catch{}}};return _(),()=>{e=!0,l(),d(),y.current&&=(y.current.close(),null),m(!1),g(`disconnected`)}},[n,c,s?.serverUrl,s?.token,t,a,u,i,r]),{events:d,isConnected:p,connectionState:h,error:_,clearEvents:T}}var h$=(0,W.createContext)(null);function g$(){let[e,t]=pQ(`console:time-range`,`24h`);return{range:e,setRange:t}}var _$=[{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 v$(e){let t=e.toLowerCase();for(let e of _$)if(t.includes(e.hint))return e.type;return`client`}function y$(e){let 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 b$(e,t){return typeof e.lagCommitCount==`number`?Math.max(0,e.lagCommitCount):t?Math.max(0,t.maxCommitSeq-e.cursor):0}function x$(e,t){return e.activityState===`stale`?`offline`:t>0?`syncing`:`online`}function S$(e,t){return e.length<=16?e:`${e.slice(0,12)}-${t+1}`}function C$(e,t,n={}){let r=n.maxNodes??10;return e.slice(0,r).map((e,n)=>{let r=x$(e,b$(e,t));return{id:S$(e.clientId,n),type:v$(e.clientId),status:r,cursor:Math.max(0,e.cursor),actor:e.actorId,mode:e.connectionMode,dialect:y$(e.clientId),scopes:Object.keys(e.effectiveScopes||{}),lastSeen:e.updatedAt}})}var w$={enabled:!1,thresholds:{p90Latency:500,errorRate:5,clientLag:100}};function T$(e,t=`relative`){if(t===`absolute`)return new Date(e).toLocaleString();let n=new Date(e),r=new Date().getTime()-n.getTime(),i=Math.floor(r/1e3);return i<60?`${i}s ago`:i<3600?`${Math.floor(i/60)}m ago`:i<86400?`${Math.floor(i/3600)}h ago`:`${Math.floor(i/86400)}d ago`}function E$(e){let t=e.length>1&&e.endsWith(`/`)?e.slice(0,-1):e;return t===`/console`||t.startsWith(`/console/`)?`/console/stream`:`/stream`}function D$(){let e=Tv(),t=(0,W.useMemo)(()=>typeof window>`u`?`/stream`:E$(window.location.pathname),[]),n=g$(),{range:r}=n,{preferences:i}=r$(),{partitionId:a}=t$(),o=i.refreshInterval*1e3,[s]=pQ(`console:alert-config`,w$),[c,l]=(0,W.useState)(`1h`),{data:u}=OQ({refetchIntervalMs:o,partitionId:a}),{data:d}=kQ({range:r,partitionId:a},{refetchIntervalMs:o}),{data:f}=AQ({range:r,partitionId:a},{refetchIntervalMs:o}),{data:p}=jQ({limit:5,partitionId:a},{refetchIntervalMs:o}),{data:m}=PQ({limit:12,offset:0,partitionId:a},{refetchIntervalMs:o}),{events:h,isConnected:g}=m$({maxEvents:8,partitionId:a}),_=(0,W.useMemo)(()=>{let e=d?.buckets??[],t=0,n=0;for(let r of e)t+=r.pushCount+r.pullCount,n+=r.errorCount;let r=t>0?n/t*100:0;return{totalEvents:t,errorRate:r}},[d?.buckets]),v=(0,W.useMemo)(()=>m?.items?C$(m.items,u,{maxNodes:12}):[],[m?.items,u]),y=v.filter(e=>e.status!==`offline`).length,b=v.filter(e=>e.status===`offline`).length,x=(0,W.useMemo)(()=>u?[{label:`Ops (Range)`,value:_.totalEvents,color:`flow`},{label:`P50 Latency`,value:f?.push?.p50??0,unit:`ms`,color:`healthy`},{label:`Error Rate`,value:`${_.errorRate.toFixed(1)}%`,color:_.errorRate>0?`offline`:`muted`},{label:`Active Clients`,value:u.activeClientCount,color:`syncing`},{label:`Pending`,value:u.maxActiveClientCursor!==null&&u.maxCommitSeq>0?u.maxCommitSeq-(u.minActiveClientCursor??0):0,color:`relay`}]:[],[u,f,_.errorRate,_.totalEvents]),S=(0,W.useMemo)(()=>h.map(e=>({type:e.type.toUpperCase(),actor:e.data?.actorId??``,table:(e.data?.tables??[])[0]??``,time:T$(e.timestamp,i.timeFormat)})),[h,i.timeFormat]),C=(0,W.useMemo)(()=>{let e=d?.buckets;if(!e?.length)return[];let t=Math.max(...e.map(e=>Math.max(e.pushCount,e.pullCount)),1);return e.map(e=>({pushPercent:t>0?e.pushCount/t*100:0,pullPercent:t>0?e.pullCount/t*100:0}))},[d?.buckets]),w=(0,W.useMemo)(()=>{if(!f)return[];let e=Math.max(f.push.p50,f.push.p90,f.push.p99,f.pull.p50,f.pull.p90,f.pull.p99,1);return[{label:`P50`,pushMs:f.push.p50,pullMs:f.pull.p50,pushBarPercent:f.push.p50/e*100,pullBarPercent:f.pull.p50/e*100},{label:`P90`,pushMs:f.push.p90,pullMs:f.pull.p90,pushBarPercent:f.push.p90/e*100,pullBarPercent:f.pull.p90/e*100},{label:`P99`,pushMs:f.push.p99,pullMs:f.pull.p99,pushBarPercent:f.push.p99/e*100,pullBarPercent:f.pull.p99/e*100}]},[f]),T=(0,W.useMemo)(()=>p?.items?p.items.map(e=>({seq:e.commitSeq,actor:e.actorId,changes:e.changeCount,tables:(e.affectedTables??[]).join(`, `),time:T$(e.createdAt,i.timeFormat)})):[],[p?.items,i.timeFormat]),E=(0,W.useMemo)(()=>Math.max(0,100-_.errorRate),[_.errorRate]),D=(0,W.useMemo)(()=>{if(!s.enabled||!u)return[];let e=[];return f?.push?.p90&&f.push.p90>s.thresholds.p90Latency&&e.push(`P90 push latency (${f.push.p90}ms) exceeds threshold (${s.thresholds.p90Latency}ms)`),u.minActiveClientCursor!==null&&u.maxCommitSeq-u.minActiveClientCursor>s.thresholds.clientLag&&e.push(`Client lag (${u.maxCommitSeq-u.minActiveClientCursor}) exceeds threshold (${s.thresholds.clientLag})`),_.errorRate>s.thresholds.errorRate&&e.push(`Error rate (${_.errorRate.toFixed(1)}%) exceeds threshold (${s.thresholds.errorRate}%)`),e},[s,u,f,_.errorRate]);return u?(0,G.jsx)(h$.Provider,{value:n,children:(0,G.jsxs)(`div`,{className:`flex flex-col`,children:[D.length>0&&(0,G.jsx)(`div`,{className:`px-6 pb-4`,children:(0,G.jsxs)(cZ,{variant:`destructive`,children:[(0,G.jsx)(lZ,{children:`Threshold Exceeded`}),(0,G.jsx)(uZ,{children:D.map((e,t)=>(0,G.jsx)(`span`,{className:`block`,children:e},t))})]})}),(0,G.jsx)(xJ,{clients:v,totalNodes:v.length+2,onlineCount:y,offlineCount:b,relayClientIds:[]}),(0,G.jsx)(WV,{items:x}),(0,G.jsxs)(`div`,{className:`flex`,children:[(0,G.jsxs)(`div`,{className:`flex-1 min-w-0 flex flex-col`,children:[(0,G.jsx)(`div`,{className:`border-b border-border border-r border-border`,children:(0,G.jsx)(ER,{bars:C,activeRange:c,onRangeChange:l})}),(0,G.jsx)(`div`,{className:`border-b border-border border-r border-border`,children:(0,G.jsx)(KV,{buckets:w,successRate:E})}),(0,G.jsx)(`div`,{className:`border-r border-border`,children:(0,G.jsx)(sV,{commits:T,onViewAll:()=>e({href:t})})})]}),(0,G.jsx)(JV,{entries:S,isConnected:g,maxVisible:20,maxHeight:`calc(100vh - 200px)`})]})]})}):(0,G.jsx)(`div`,{className:`flex items-center justify-center py-24`,children:(0,G.jsx)(dV,{size:`lg`})})}function O$(){return(0,G.jsx)(D$,{})}var k$=VX;function A$({children:e}){return(0,G.jsxs)(`div`,{className:`space-y-4 px-5 py-5`,children:[(0,G.jsx)(j$,{}),(0,G.jsx)(R$,{}),(0,G.jsx)(z$,{}),e]})}function j$(){let{clearError:e,config:t,connect:n,disconnect:r,error:i,isConnected:a,isConnecting:o}=Py(),[s,c]=(0,W.useState)(t?.serverUrl??`/api`),[l,u]=(0,W.useState)(t?.token??``),[d,f]=(0,W.useState)(null),[p,m]=(0,W.useState)(!1),[h,g]=(0,W.useState)(null),[_,v]=pQ(`console:disconnect-clear-saved-config`,!1);return(0,W.useEffect)(()=>{let e=new URLSearchParams(window.location.search),t=e.get(`server`),n=!1;if(t&&(c(t),e.delete(`server`),n=!0),e.has(`token`)&&(e.delete(`token`),n=!0),n){let t=e.toString(),n=t?`${window.location.pathname}?${t}`:window.location.pathname;window.history.replaceState({},``,n)}},[]),(0,W.useEffect)(()=>{t?.serverUrl&&c(t.serverUrl),t?.token&&u(t.token)},[t?.serverUrl,t?.token]),(0,W.useEffect)(()=>{g(null)},[]),(0,G.jsx)(lV,{isConnected:a,isConnecting:o,isTestingConnection:p,serverUrl:s,onServerUrlChange:c,consoleToken:l,onConsoleTokenChange:u,onSaveAndConnect:async()=>{e(),f(null),g(await n({serverUrl:s.trim(),token:l.trim()},{persistOverride:!0})?`Connected successfully and configuration saved.`:`Failed to connect with the provided settings.`)},onDisconnect:()=>{r({clearSavedConfig:_}),_&&(c(`/api`),u(``)),g(_?`Disconnected and saved credentials cleared.`:`Disconnected.`),f(null)},onTestConnection:async()=>{m(!0),f(null),g(null);let e=performance.now();try{let t=s.trim(),n=l.trim();if(!t||!n)throw Error(`Missing server URL or token`);if(!(await fetch(`${t}/console/stats`,{headers:{Authorization:`Bearer ${n}`}})).ok)throw Error(`Failed to connect`);f(Math.round(performance.now()-e))}catch{f(-1)}finally{m(!1)}},statusMessage:i??h??(d===null?void 0:d<0?`Connection failed`:`Connection successful (${d}ms latency)`),children:(0,G.jsx)(`div`,{className:`px-5 pb-5 -mt-2`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-border px-3 py-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-mono text-[10px] text-neutral-400`,children:`Clear saved credentials on disconnect`}),(0,G.jsx)(`p`,{className:`font-mono text-[9px] text-neutral-500`,children:`Removes stored server URL and token from this browser.`})]}),(0,G.jsx)(qB,{checked:_,onCheckedChange:v})]})})})}var M$=1440*60*1e3;function N$(e){let t=e.trim();if(!t)return null;let n=Number.parseInt(t,10);return!Number.isInteger(n)||n<=0?null:n}function P$(e){if(!e)return`Never`;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():`Invalid date`}function F$(e){return e.length===0?`all scopes`:e.length<=2?e.join(`, `):`${e.slice(0,2).join(`, `)} +${e.length-2}`}function I$(e,t){if(e.revokedAt)return`revoked`;if(!e.expiresAt)return`active`;let n=Date.parse(e.expiresAt);if(!Number.isFinite(n))return`active`;let r=Date.now();return n<=r?`expired`:n<=r+t*M$?`expiring`:`active`}function L$(e){return e===`revoked`?`destructive`:e===`expired`?`offline`:e===`expiring`?`syncing`:`healthy`}function R$(){let[e,t]=(0,W.useState)(`all`),[n,r]=(0,W.useState)(`all`),[i,a]=(0,W.useState)(`14`),[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(!1),[u,d]=(0,W.useState)(``),[f,p]=(0,W.useState)(`relay`),[m,h]=(0,W.useState)(``),[g,_]=(0,W.useState)(``),[v,y]=(0,W.useState)(``),[b,x]=(0,W.useState)(null),[S,C]=(0,W.useState)([]),[w,T]=(0,W.useState)(null),[E,D]=(0,W.useState)(null),[O,k]=(0,W.useState)(null),[A,j]=(0,W.useState)(null),[M,N]=(0,W.useState)(null),[P,F]=(0,W.useState)(null),[I,L]=(0,W.useState)(null),ee=(0,W.useMemo)(()=>N$(i),[i]),R=ee??14,z=(0,W.useMemo)(()=>N$(v),[v]),B=v.trim().length>0,V=!B||z!==null,{data:H,isLoading:U,error:te}=GQ((0,W.useMemo)(()=>({type:e===`all`?void 0:e,status:n===`all`?void 0:n,expiresWithinDays:n===`expiring`?R:void 0}),[e,n,R])),ne=KQ(),re=JQ(),ie=qQ(),ae=YQ(),oe=XQ();(0,W.useEffect)(()=>{let e=new Set((H?.items??[]).map(e=>e.keyId));C(t=>t.filter(t=>e.has(t)))},[H?.items]);let se=async()=>{try{let e=g.split(`,`).map(e=>e.trim()).filter(e=>e.length>0);x((await ne.mutateAsync({name:u,keyType:f,actorId:m||void 0,scopeKeys:e.length>0?e:void 0,expiresInDays:B?z??void 0:void 0})).secretKey),d(``),h(``),_(``),y(``)}catch{}},ce=e=>{navigator.clipboard.writeText(e),D(e),setTimeout(()=>D(null),2e3)},le=async()=>{if(O)try{await ie.mutateAsync(O)}finally{k(null)}},ue=async()=>{if(S.length!==0)try{T(await re.mutateAsync({keyIds:S})),C([])}catch{}},de=async()=>{if(A)try{let e=await oe.mutateAsync(A.keyId);N({oldKeyId:A.keyId,oldKeyName:A.name,secretKey:e.secretKey})}catch{}},fe=async()=>{if(M)try{await ie.mutateAsync(M.oldKeyId)}finally{N(null),j(null)}},pe=async()=>{if(P)try{L((await ae.mutateAsync(P)).secretKey)}finally{F(null)}};if(U)return(0,G.jsx)(`div`,{className:`flex h-[200px] items-center justify-center`,children:(0,G.jsx)(dV,{size:`lg`})});if(te)return(0,G.jsx)(`div`,{className:`flex h-[200px] items-center justify-center`,children:(0,G.jsxs)(`p`,{className:`text-danger`,children:[`Failed to load API keys: `,te.message]})});let me=(H?.items??[]).filter(e=>e.revokedAt===null).map(e=>e.keyId),he=me.length>0&&me.every(e=>S.includes(e)),ge=S.length>0,_e=(H?.items??[]).filter(e=>S.includes(e.keyId)).map(e=>e.name);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(eH,{title:`API Keys`,description:`Issue, rotate, revoke, and audit key lifecycle state.`,actions:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(Q,{size:`sm`,variant:`destructive`,onClick:()=>l(!0),disabled:S.length===0,children:[`Revoke Selected (`,S.length,`)`]}),(0,G.jsx)(Q,{size:`sm`,onClick:()=>s(!0),children:`Create Key`})]}),children:[(0,G.jsxs)(`div`,{className:`mb-4 grid gap-3 lg:grid-cols-3`,children:[(0,G.jsxs)(YJ,{children:[(0,G.jsx)(XJ,{children:`Type filter`}),(0,G.jsxs)(ZX,{value:[e],multiple:!1,onValueChange:e=>{let n=e.find(e=>typeof e==`string`);(n===`all`||n===`relay`||n===`proxy`||n===`admin`)&&t(n)},children:[(0,G.jsx)(k$,{value:`all`,children:`all`}),(0,G.jsx)(k$,{value:`relay`,children:`relay`}),(0,G.jsx)(k$,{value:`proxy`,children:`proxy`}),(0,G.jsx)(k$,{value:`admin`,children:`admin`})]})]}),(0,G.jsxs)(YJ,{children:[(0,G.jsx)(XJ,{children:`Status filter`}),(0,G.jsxs)(ZX,{value:[n],multiple:!1,onValueChange:e=>{let t=e.find(e=>typeof e==`string`);(t===`all`||t===`active`||t===`revoked`||t===`expiring`)&&r(t)},children:[(0,G.jsx)(k$,{value:`all`,children:`all`}),(0,G.jsx)(k$,{value:`active`,children:`active`}),(0,G.jsx)(k$,{value:`revoked`,children:`revoked`}),(0,G.jsx)(k$,{value:`expiring`,children:`expiring`})]})]}),(0,G.jsxs)(YJ,{children:[(0,G.jsx)(XJ,{htmlFor:`api-key-expiring-window`,children:`Expiring window (days)`}),(0,G.jsx)(ZJ,{children:`Used when status filter is set to expiring.`}),(0,G.jsx)(jR,{id:`api-key-expiring-window`,placeholder:`14`,value:i,inputMode:`numeric`,onChange:e=>a(e.target.value)}),ee===null&&i.trim().length>0?(0,G.jsx)(`p`,{className:`font-mono text-[10px] text-offline`,children:`Enter a positive whole number.`}):null]})]}),H?.items.length===0?(0,G.jsx)(vV,{message:`No API keys match the current filters.`}):(0,G.jsxs)(QB,{children:[(0,G.jsx)($B,{children:(0,G.jsxs)(tV,{children:[(0,G.jsx)(nV,{className:`w-[28px]`,children:(0,G.jsx)(NJ,{checked:he,indeterminate:!he&&ge&&me.length>0,onCheckedChange:e=>{C(e?me:[])},"aria-label":`Select all active keys`})}),(0,G.jsx)(nV,{className:`w-[100px]`,children:`NAME`}),(0,G.jsx)(nV,{className:`w-[55px]`,children:`TYPE`}),(0,G.jsx)(nV,{className:`w-[90px]`,children:`KEY PREFIX`}),(0,G.jsx)(nV,{className:`w-[80px]`,children:`ACTOR`}),(0,G.jsx)(nV,{className:`w-[100px]`,children:`SCOPES`}),(0,G.jsx)(nV,{className:`w-[120px]`,children:`CREATED`}),(0,G.jsx)(nV,{className:`w-[120px]`,children:`LAST USED`}),(0,G.jsx)(nV,{className:`w-[120px]`,children:`EXPIRES`}),(0,G.jsx)(nV,{className:`flex-1`,children:`STATUS`})]})}),(0,G.jsx)(eV,{children:(H?.items??[]).map(e=>{let t=I$(e,R);return(0,G.jsxs)(tV,{className:`group relative`,children:[(0,G.jsx)(rV,{className:`w-[28px]`,children:(0,G.jsx)(NJ,{checked:S.includes(e.keyId),onCheckedChange:t=>{C(n=>t?[...new Set([...n,e.keyId])]:n.filter(t=>t!==e.keyId))},"aria-label":`Select ${e.name}`,disabled:e.revokedAt!==null})}),(0,G.jsx)(rV,{className:`w-[100px] font-medium`,children:e.name}),(0,G.jsx)(rV,{className:`w-[55px]`,children:(0,G.jsx)(ZB,{variant:e.keyType===`admin`?`flow`:e.keyType===`proxy`?`ghost`:`relay`,children:e.keyType})}),(0,G.jsx)(rV,{className:`w-[90px]`,children:(0,G.jsxs)(`code`,{className:`font-mono text-[11px]`,children:[e.keyPrefix,`...`]})}),(0,G.jsx)(rV,{className:`w-[80px] text-neutral-500`,children:e.actorId??`-`}),(0,G.jsx)(rV,{className:`w-[100px] text-neutral-500`,children:(0,G.jsx)(`code`,{className:`font-mono text-[10px]`,children:F$(e.scopeKeys)})}),(0,G.jsx)(rV,{className:`w-[120px] text-neutral-500`,children:P$(e.createdAt)}),(0,G.jsx)(rV,{className:`w-[120px] text-neutral-500`,children:P$(e.lastUsedAt)}),(0,G.jsx)(rV,{className:`w-[120px] text-neutral-500`,children:P$(e.expiresAt)}),(0,G.jsx)(rV,{className:`flex-1`,children:(0,G.jsx)(ZB,{variant:L$(t),children:t})}),e.revokedAt===null&&(0,G.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:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>j(e),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`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>F(e.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`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>k(e.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`})]})]},e.keyId)})})]})]}),(0,G.jsx)(kZ,{open:o,onOpenChange:s,children:(0,G.jsxs)(jZ,{children:[(0,G.jsx)(MZ,{children:(0,G.jsx)(PZ,{children:`Create API Key`})}),b?(0,G.jsx)(B$,{copiedKeyId:E,onClose:()=>{x(null),s(!1)},onCopy:ce,secretKey:b,warning:`Copy this key now. You will not be able to view it again.`}):(0,G.jsxs)(`div`,{className:`px-5 py-4 flex flex-col gap-4`,children:[(0,G.jsxs)(YJ,{children:[(0,G.jsx)(XJ,{htmlFor:`api-key-name`,children:`Name`}),(0,G.jsx)(jR,{id:`api-key-name`,placeholder:`Backend Relay Key`,value:u,onChange:e=>d(e.target.value)})]}),(0,G.jsxs)(YJ,{children:[(0,G.jsx)(XJ,{children:`Key type`}),(0,G.jsxs)(ZX,{value:[f],multiple:!1,onValueChange:e=>{let t=e.find(e=>typeof e==`string`);(t===`relay`||t===`proxy`||t===`admin`)&&p(t)},children:[(0,G.jsx)(k$,{value:`relay`,children:`relay`}),(0,G.jsx)(k$,{value:`proxy`,children:`proxy`}),(0,G.jsx)(k$,{value:`admin`,children:`admin`})]})]}),(0,G.jsxs)(YJ,{children:[(0,G.jsx)(XJ,{htmlFor:`api-key-actor-id`,children:`Actor ID (optional)`}),(0,G.jsx)(ZJ,{children:`Pin this key to a fixed actor ID`}),(0,G.jsx)(jR,{id:`api-key-actor-id`,placeholder:`actor-123`,value:m,onChange:e=>h(e.target.value)})]}),(0,G.jsxs)(YJ,{children:[(0,G.jsx)(XJ,{htmlFor:`api-key-scope-keys`,children:`Scope keys (optional)`}),(0,G.jsx)(ZJ,{children:`Comma-separated list of allowed scope keys`}),(0,G.jsx)(jR,{id:`api-key-scope-keys`,placeholder:`scope-a, scope-b`,value:g,onChange:e=>_(e.target.value)})]}),(0,G.jsxs)(YJ,{children:[(0,G.jsx)(XJ,{htmlFor:`api-key-expires-days`,children:`Expires in days (optional)`}),(0,G.jsx)(ZJ,{children:`Leave empty to keep the key non-expiring.`}),(0,G.jsx)(jR,{id:`api-key-expires-days`,placeholder:`30`,value:v,inputMode:`numeric`,onChange:e=>y(e.target.value)}),V?null:(0,G.jsx)(`p`,{className:`font-mono text-[10px] text-offline`,children:`Enter a positive whole number.`})]}),(0,G.jsxs)(NZ,{children:[(0,G.jsx)(Q,{variant:`default`,onClick:()=>s(!1),children:`Cancel`}),(0,G.jsx)(Q,{variant:`primary`,onClick:se,disabled:ne.isPending||!u||!V,children:ne.isPending?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(dV,{size:`sm`}),`Creating...`]}):`Create`})]})]})]})}),(0,G.jsx)(kZ,{open:c,onOpenChange:e=>{l(e),e||T(null)},children:(0,G.jsxs)(jZ,{children:[(0,G.jsx)(MZ,{children:(0,G.jsx)(PZ,{children:`Bulk Revoke API Keys`})}),w?(0,G.jsxs)(`div`,{className:`px-5 py-4 flex flex-col gap-3`,children:[(0,G.jsx)(cZ,{variant:`destructive`,children:(0,G.jsxs)(uZ,{children:[`Requested `,w.requestedCount,` keys. Revoked`,` `,w.revokedCount,`, already revoked`,` `,w.alreadyRevokedCount,`, not found`,` `,w.notFoundCount,`.`]})}),(0,G.jsx)(NZ,{children:(0,G.jsx)(Q,{variant:`primary`,onClick:()=>{l(!1),T(null)},children:`Done`})})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`px-5 py-4 flex flex-col gap-3`,children:[(0,G.jsx)(cZ,{variant:`destructive`,children:(0,G.jsx)(uZ,{children:`This revokes selected keys immediately and cannot be undone.`})}),(0,G.jsxs)(`p`,{className:`font-mono text-[10px] text-neutral-500`,children:[`Selected keys: `,_e.slice(0,5).join(`, `),_e.length>5?` +${_e.length-5} more`:``]})]}),(0,G.jsxs)(NZ,{children:[(0,G.jsx)(Q,{variant:`default`,onClick:()=>l(!1),children:`Cancel`}),(0,G.jsx)(Q,{variant:`destructive`,onClick:ue,disabled:re.isPending||S.length===0,children:re.isPending?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(dV,{size:`sm`}),`Revoking...`]}):`Revoke Selected`})]})]})]})}),(0,G.jsx)(kZ,{open:A!==null||M!==null,onOpenChange:()=>{j(null),N(null)},children:(0,G.jsxs)(jZ,{children:[(0,G.jsx)(MZ,{children:(0,G.jsx)(PZ,{children:`Stage Rotate API Key`})}),M?(0,G.jsxs)(`div`,{className:`px-5 py-4 flex flex-col gap-4`,children:[(0,G.jsx)(cZ,{variant:`default`,children:(0,G.jsxs)(uZ,{children:[`Replacement key created for `,M.oldKeyName,`. The old key is still active until you revoke it.`]})}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`code`,{className:`flex-1 rounded-md border border-border bg-surface p-3 font-mono text-[11px] text-white break-all`,children:M.secretKey}),(0,G.jsx)(Q,{variant:`default`,size:`sm`,onClick:()=>ce(M.secretKey),children:E===M.secretKey?`Copied`:`Copy`})]}),(0,G.jsxs)(NZ,{children:[(0,G.jsx)(Q,{variant:`default`,onClick:()=>{N(null),j(null)},children:`Keep Old Key Active`}),(0,G.jsx)(Q,{variant:`destructive`,onClick:fe,disabled:ie.isPending,children:ie.isPending?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(dV,{size:`sm`}),`Revoking Old Key...`]}):`Finalize and Revoke Old Key`})]})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`px-5 py-4`,children:(0,G.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.`})}),(0,G.jsxs)(NZ,{children:[(0,G.jsx)(Q,{variant:`default`,onClick:()=>j(null),children:`Cancel`}),(0,G.jsx)(Q,{variant:`primary`,onClick:de,disabled:oe.isPending||!A,children:oe.isPending?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(dV,{size:`sm`}),`Staging...`]}):`Create Replacement Key`})]})]})]})}),(0,G.jsx)(kZ,{open:O!==null,onOpenChange:()=>k(null),children:(0,G.jsxs)(jZ,{children:[(0,G.jsx)(MZ,{children:(0,G.jsx)(PZ,{children:`Revoke API Key`})}),(0,G.jsx)(`div`,{className:`px-5 py-4`,children:(0,G.jsx)(cZ,{variant:`destructive`,children:(0,G.jsx)(uZ,{children:`Revoking a key immediately invalidates it for all requests.`})})}),(0,G.jsxs)(NZ,{children:[(0,G.jsx)(Q,{variant:`default`,onClick:()=>k(null),children:`Cancel`}),(0,G.jsx)(Q,{variant:`destructive`,onClick:le,disabled:ie.isPending,children:ie.isPending?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(dV,{size:`sm`}),`Revoking...`]}):`Revoke`})]})]})}),(0,G.jsx)(kZ,{open:P!==null||I!==null,onOpenChange:()=>{F(null),L(null)},children:(0,G.jsxs)(jZ,{children:[(0,G.jsx)(MZ,{children:(0,G.jsx)(PZ,{children:`Rotate API Key`})}),I?(0,G.jsx)(B$,{copiedKeyId:E,onClose:()=>L(null),onCopy:ce,secretKey:I,warning:`The previous key has been invalidated. Store this replacement securely.`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`px-5 py-4`,children:(0,G.jsx)(`p`,{className:`font-mono text-[10px] text-neutral-500`,children:`Rotating a key invalidates the previous secret immediately.`})}),(0,G.jsxs)(NZ,{children:[(0,G.jsx)(Q,{variant:`default`,onClick:()=>F(null),children:`Cancel`}),(0,G.jsx)(Q,{variant:`primary`,onClick:pe,disabled:ae.isPending,children:ae.isPending?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(dV,{size:`sm`}),`Rotating...`]}):`Rotate`})]})]})]})})]})}function z$(){let{preferences:e,updatePreference:t,resetPreferences:n}=r$();return(0,G.jsx)(QV,{rows:[{type:`filter`,label:`Auto-refresh interval`,options:i$.map(e=>({id:`${e.value}`,label:e.label})),activeId:`${e.refreshInterval}`,onActiveChange:e=>t(`refreshInterval`,Number.parseInt(e,10))},{type:`filter`,label:`Items per page`,options:a$.map(e=>({id:`${e.value}`,label:e.label})),activeId:`${e.pageSize}`,onActiveChange:e=>t(`pageSize`,Number.parseInt(e,10))},{type:`filter`,label:`Time format`,options:[{id:`relative`,label:`Relative`},{id:`absolute`,label:`Absolute`}],activeId:e.timeFormat,onActiveChange:e=>t(`timeFormat`,e)},{type:`toggle`,label:`Show sparklines`,description:`Display mini trend charts in dashboard metric cards`,checked:e.showSparklines,onCheckedChange:e=>t(`showSparklines`,e)}],onResetDefaults:n})}function B$({copiedKeyId:e,onClose:t,onCopy:n,secretKey:r,warning:i}){return(0,G.jsxs)(`div`,{className:`px-5 py-4 flex flex-col gap-4`,children:[(0,G.jsx)(cZ,{variant:`destructive`,children:(0,G.jsx)(uZ,{children:i})}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`code`,{className:`flex-1 rounded-md border border-border bg-surface p-3 font-mono text-[11px] text-white break-all`,children:r}),(0,G.jsx)(Q,{variant:`default`,size:`sm`,onClick:()=>n(r),children:e===r?`Copied`:`Copy`})]}),(0,G.jsx)(NZ,{children:(0,G.jsx)(Q,{variant:`primary`,onClick:t,children:`Done`})})]})}function V$(e){let 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 H$(e){let 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 U$(e,t){if(t===`absolute`)return new Date(e).toLocaleString();try{let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/1e3),i=Math.floor(r/60),a=Math.floor(i/60),o=Math.floor(a/24);return r<60?`just now`:i<60?`${i}m ago`:a<24?`${a}h ago`:`${o}d ago`}catch{return e}}function W$(e,t,n){return{id:e.clientId,type:V$(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:H$(e.clientId),scopes:Object.keys(e.effectiveScopes??{}),lastSeen:U$(e.updatedAt,n)}}function G$({emptyState:e}={}){let[t,n]=(0,W.useState)(1),[r,i]=(0,W.useState)(null),{preferences:a}=r$(),{partitionId:o}=t$(),s=a.pageSize,c=a.refreshInterval*1e3,{data:l,isLoading:u}=OQ({refetchIntervalMs:c,partitionId:o}),{data:d,isLoading:f,error:p}=PQ({limit:s,offset:(t-1)*s,partitionId:o},{refetchIntervalMs:c}),m=VQ(),h=Math.ceil((d?.total??0)/s),g=l?.maxCommitSeq??0;(0,W.useEffect)(()=>{n(1)},[]);let _=async()=>{if(r)try{await m.mutateAsync({clientId:r,partitionId:o})}finally{i(null)}};if(f||u)return(0,G.jsx)(`div`,{className:`flex items-center justify-center h-[200px]`,children:(0,G.jsx)(dV,{size:`lg`})});if(p)return(0,G.jsx)(`div`,{className:`flex items-center justify-center h-[200px]`,children:(0,G.jsxs)(`p`,{className:`text-danger`,children:[`Failed to load clients: `,p.message]})});let v=(d?.items??[]).map(e=>W$(e,g,a.timeFormat));return(0,G.jsxs)(`div`,{className:`flex flex-col gap-5 px-5 py-5`,children:[v.length>0&&(0,G.jsx)(oH,{clients:v,headSeq:g}),v.length===0?e??(0,G.jsx)(ZV,{children:(0,G.jsx)(vV,{message:`No clients yet`})}):(0,G.jsx)(VV,{clients:v,headSeq:g,onEvict:e=>{let t=d?.items.find(t=>t.clientId===e);i(t?.clientId??e)}}),h>1&&(0,G.jsx)(IZ,{page:t,totalPages:h,totalItems:d?.total??0,onPageChange:n}),(0,G.jsx)(kZ,{open:r!==null,onOpenChange:()=>i(null),children:(0,G.jsxs)(jZ,{children:[(0,G.jsx)(MZ,{children:(0,G.jsx)(PZ,{children:`Evict Client`})}),(0,G.jsxs)(`div`,{className:`px-5 py-4 flex flex-col gap-4`,children:[(0,G.jsxs)(`p`,{className:`font-mono text-[11px] text-neutral-300`,children:[`Are you sure you want to evict client`,` `,(0,G.jsxs)(`span`,{className:`font-mono text-white`,children:[r?.slice(0,12),`...`]}),`?`]}),(0,G.jsx)(`p`,{className:`font-mono text-[10px] text-neutral-500`,children:`This will force the client to re-bootstrap on their next sync.`})]}),(0,G.jsxs)(NZ,{children:[(0,G.jsx)(Q,{variant:`default`,onClick:()=>i(null),children:`Cancel`}),(0,G.jsx)(Q,{variant:`destructive`,onClick:_,disabled:m.isPending,children:m.isPending?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(dV,{size:`sm`}),`Evicting...`]}):`Evict`})]})]})})]})}var K$={latencyThresholdMs:1e3,errorRateThreshold:5,clientLagThreshold:50,enabled:!1};function q$(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 J$(e){let t=e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0);return Array.from(new Set(t))}function Y$(e){switch(e){case`notify_data_change`:return`Notify`;case`evict_client`:return`Evict`;case`compact`:return`Compact`;default:return`Prune`}}function X$(e){return!e||typeof e!=`object`||Array.isArray(e)?null:e}function Z$(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function Q$(e){let t=X$(e.requestPayload),n=X$(e.resultPayload);if(e.operationType===`notify_data_change`){let e=Z$(t?.tables),r=n?.commitSeq;return`${e.length} table${e.length===1?``:`s`} -> commit #${typeof r==`number`?r:`?`}`}if(e.operationType===`evict_client`){let t=n?.evicted===!0?`evicted`:`not found`;return`client ${e.targetClientId??`?`} ${t}`}return e.operationType===`compact`?`${typeof n?.deletedChanges==`number`?n.deletedChanges:0} changes removed`:`${typeof n?.deletedCommits==`number`?n.deletedCommits:0} commits removed${typeof t?.watermarkCommitSeq==`number`?` at #${t.watermarkCommitSeq}`:``}`}function $$(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function e1(){let{partitionId:e}=t$();return(0,G.jsxs)(`div`,{className:`flex flex-col gap-4 px-5 py-5`,children:[(0,G.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,G.jsx)(t1,{}),(0,G.jsx)(o1,{})]}),(0,G.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-3`,children:[(0,G.jsx)(n1,{partitionId:e}),(0,G.jsx)(r1,{partitionId:e}),(0,G.jsx)(i1,{partitionId:e})]}),(0,G.jsx)(a1,{partitionId:e})]})}function t1(){let{data:e,isLoading:t,error:n}=LQ();return t?(0,G.jsx)(`div`,{className:`flex items-center justify-center h-[200px]`,children:(0,G.jsx)(dV,{size:`lg`})}):n?(0,G.jsx)(`div`,{className:`flex items-center justify-center h-[200px]`,children:(0,G.jsxs)(`p`,{className:`text-danger`,children:[`Failed to load handlers: `,n.message]})}):(0,G.jsx)(HV,{handlers:(e?.items??[]).map(e=>({table:e.table,dependsOn:e.dependsOn?.join(`, `)??null,chunkTtl:e.snapshotChunkTtlMs?q$(e.snapshotChunkTtlMs):`default`})),tableCount:e?.items.length??0})}function n1({partitionId:e}){let[t,n]=(0,W.useState)(!1),[r,i]=(0,W.useState)(null),{data:a,isLoading:o}=OQ({partitionId:e}),{data:s,isLoading:c,refetch:l}=RQ({enabled:!1}),u=HQ();return o?(0,G.jsx)(`div`,{className:`flex items-center justify-center h-[200px]`,children:(0,G.jsx)(dV,{size:`lg`})}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(XV,{title:`Prune`,description:`Delete commits that all clients have already synced. Pruning removes commits older than the oldest active client cursor.`,dotColor:`syncing`,stats:[{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`}],actionLabel:`Preview Prune`,actionVariant:`destructive`,onAction:async()=>{n(!0),i(null),await l()}}),(0,G.jsx)(kZ,{open:t,onOpenChange:n,children:(0,G.jsxs)(jZ,{children:[(0,G.jsx)(MZ,{children:(0,G.jsx)(PZ,{children:`Prune Old Commits`})}),(0,G.jsx)(`div`,{className:`px-5 py-4 flex flex-col gap-4`,children:r===null?c?(0,G.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,G.jsx)(dV,{size:`sm`})}):s?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(cZ,{variant:s.commitsToDelete>0?`destructive`:`default`,children:(0,G.jsx)(uZ,{children:s.commitsToDelete>0?(0,G.jsxs)(G.Fragment,{children:[`This will delete`,` `,(0,G.jsx)(`strong`,{children:s.commitsToDelete}),` commits up to sequence`,` `,(0,G.jsxs)(`code`,{className:`font-mono`,children:[`#`,s.watermarkCommitSeq]}),`.`]}):`No commits are eligible for pruning.`})}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex justify-between font-mono text-[11px]`,children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Watermark commit seq:`}),(0,G.jsxs)(`span`,{className:`text-white`,children:[`#`,s.watermarkCommitSeq]})]}),(0,G.jsxs)(`div`,{className:`flex justify-between font-mono text-[11px] items-center`,children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Commits to delete:`}),(0,G.jsx)(ZB,{variant:s.commitsToDelete>0?`offline`:`ghost`,children:s.commitsToDelete})]})]})]}):null:(0,G.jsxs)(cZ,{variant:`default`,children:[(0,G.jsx)(lZ,{children:`Pruning Complete`}),(0,G.jsxs)(uZ,{children:[`Successfully deleted `,(0,G.jsx)(`strong`,{children:r}),` commits.`]})]})}),(0,G.jsxs)(NZ,{children:[(0,G.jsx)(Q,{variant:`default`,onClick:()=>n(!1),children:r===null?`Cancel`:`Close`}),r===null&&(0,G.jsx)(Q,{variant:`destructive`,onClick:async()=>{i((await u.mutateAsync()).deletedCommits)},disabled:u.isPending||c||(s?.commitsToDelete??0)===0,children:u.isPending?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(dV,{size:`sm`}),`Pruning...`]}):`Prune Now`})]})]})})]})}function r1({partitionId:e}){let[t,n]=(0,W.useState)(!1),[r,i]=(0,W.useState)(null),{data:a,isLoading:o}=OQ({partitionId:e}),s=UQ();return o?(0,G.jsx)(`div`,{className:`flex items-center justify-center h-[200px]`,children:(0,G.jsx)(dV,{size:`lg`})}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(XV,{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:[{label:`Total changes`,value:a?.changeCount??0},{label:`Total commits`,value:a?.commitCount??0}],actionLabel:`Run Compaction`,actionVariant:`primary`,onAction:()=>{n(!0),i(null)}}),(0,G.jsx)(kZ,{open:t,onOpenChange:n,children:(0,G.jsxs)(jZ,{children:[(0,G.jsx)(MZ,{children:(0,G.jsx)(PZ,{children:`Compact Changes`})}),(0,G.jsx)(`div`,{className:`px-5 py-4 flex flex-col gap-4`,children:r===null?(0,G.jsx)(cZ,{variant:`default`,children:(0,G.jsx)(uZ,{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.`})}):(0,G.jsxs)(cZ,{variant:`default`,children:[(0,G.jsx)(lZ,{children:`Compaction Complete`}),(0,G.jsxs)(uZ,{children:[`Successfully removed `,(0,G.jsx)(`strong`,{children:r}),` redundant changes.`]})]})}),(0,G.jsxs)(NZ,{children:[(0,G.jsx)(Q,{variant:`default`,onClick:()=>n(!1),children:r===null?`Cancel`:`Close`}),r===null&&(0,G.jsx)(Q,{variant:`primary`,onClick:async()=>{i((await s.mutateAsync()).deletedChanges)},disabled:s.isPending,children:s.isPending?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(dV,{size:`sm`}),`Compacting...`]}):`Compact Now`})]})]})})]})}function i1({partitionId:e}){let[t,n]=(0,W.useState)(!1),[r,i]=(0,W.useState)(`tasks`),[a,o]=(0,W.useState)(e??``),[s,c]=(0,W.useState)(null),[l,u]=(0,W.useState)(null),d=WQ(),f=J$(r),p=[{label:`Next tables`,value:f.length,tone:`syncing`},{label:`Last commit seq`,value:s?`#${s.commitSeq}`:`—`,tone:`syncing`},{label:`Last chunks cleared`,value:s?.deletedChunks??`—`}];return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(XV,{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:p,actionLabel:`Notify Clients`,actionVariant:`primary`,onAction:()=>{n(!0),u(null)}}),(0,G.jsx)(kZ,{open:t,onOpenChange:n,children:(0,G.jsxs)(jZ,{children:[(0,G.jsx)(MZ,{children:(0,G.jsx)(PZ,{children:`Notify External Data Change`})}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-4 px-5 py-4`,children:[s?(0,G.jsxs)(cZ,{variant:`default`,children:[(0,G.jsx)(lZ,{children:`Notification Sent`}),(0,G.jsxs)(uZ,{children:[`Created synthetic commit`,` `,(0,G.jsxs)(`strong`,{children:[`#`,s.commitSeq]}),` for`,` `,(0,G.jsx)(`strong`,{children:s.tables.length}),` table`,s.tables.length===1?``:`s`,` and cleared`,` `,(0,G.jsx)(`strong`,{children:s.deletedChunks}),` cached chunk`,s.deletedChunks===1?``:`s`,`.`]})]}):(0,G.jsx)(cZ,{variant:`default`,children:(0,G.jsx)(uZ,{children:`Use this when data changed outside Syncular push flow. It invalidates cached snapshot chunks and forces clients to pull fresh data.`})}),l?(0,G.jsx)(cZ,{variant:`destructive`,children:(0,G.jsx)(uZ,{children:l})}):null,(0,G.jsxs)(YJ,{children:[(0,G.jsx)(XJ,{children:`Tables (comma-separated)`}),(0,G.jsx)(jR,{value:r,onChange:e=>i(e.target.value),placeholder:`tasks, notes`,disabled:d.isPending}),(0,G.jsx)(ZJ,{children:`Enter one or more table names affected by the external change.`})]}),(0,G.jsxs)(YJ,{children:[(0,G.jsx)(XJ,{children:`Partition ID (optional)`}),(0,G.jsx)(jR,{value:a,onChange:e=>o(e.target.value),placeholder:`default`,disabled:d.isPending})]})]}),(0,G.jsxs)(NZ,{children:[(0,G.jsx)(Q,{variant:`default`,onClick:()=>n(!1),children:s?`Close`:`Cancel`}),s?null:(0,G.jsx)(Q,{variant:`primary`,onClick:async()=>{if(f.length===0){u(`Provide at least one table name.`);return}u(null),c(await d.mutateAsync({tables:f,partitionId:a.trim()||void 0}))},disabled:d.isPending,children:d.isPending?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(dV,{size:`sm`}),`Notifying...`]}):`Notify Data Change`})]})]})})]})}function a1({partitionId:e}){let[t,n]=(0,W.useState)(`all`),{data:r,isLoading:i,error:a}=zQ({limit:20,offset:0,operationType:t===`all`?void 0:t,partitionId:e},{refetchIntervalMs:5e3});return(0,G.jsx)(eH,{title:`Operation Audit`,description:`Recent prune/compact/notify/evict actions with actor and result context.`,actions:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Q,{variant:t===`all`?`default`:`ghost`,size:`sm`,onClick:()=>n(`all`),children:`All`}),(0,G.jsx)(Q,{variant:t===`prune`?`default`:`ghost`,size:`sm`,onClick:()=>n(`prune`),children:`Prune`}),(0,G.jsx)(Q,{variant:t===`compact`?`default`:`ghost`,size:`sm`,onClick:()=>n(`compact`),children:`Compact`}),(0,G.jsx)(Q,{variant:t===`notify_data_change`?`default`:`ghost`,size:`sm`,onClick:()=>n(`notify_data_change`),children:`Notify`}),(0,G.jsx)(Q,{variant:t===`evict_client`?`default`:`ghost`,size:`sm`,onClick:()=>n(`evict_client`),children:`Evict`})]}),contentClassName:`pt-2`,children:i?(0,G.jsx)(`div`,{className:`flex items-center justify-center py-10`,children:(0,G.jsx)(dV,{size:`lg`})}):a?(0,G.jsx)(cZ,{variant:`destructive`,children:(0,G.jsxs)(uZ,{children:[`Failed to load operation audit events: `,a.message]})}):(r?.items.length??0)===0?(0,G.jsx)(`div`,{className:`px-2 py-8 text-sm text-neutral-500`,children:`No operation events found for this filter.`}):(0,G.jsx)(`div`,{className:`overflow-x-auto`,children:(0,G.jsxs)(QB,{children:[(0,G.jsx)($B,{children:(0,G.jsxs)(tV,{children:[(0,G.jsx)(nV,{children:`Time`}),(0,G.jsx)(nV,{children:`Type`}),(0,G.jsx)(nV,{children:`User`}),(0,G.jsx)(nV,{children:`Target`}),(0,G.jsx)(nV,{children:`Result`})]})}),(0,G.jsx)(eV,{children:(r?.items??[]).map((e,t)=>(0,G.jsxs)(tV,{children:[(0,G.jsx)(rV,{className:`whitespace-nowrap text-xs text-neutral-400`,children:$$(e.createdAt)}),(0,G.jsx)(rV,{children:(0,G.jsx)(ZB,{variant:`ghost`,children:Y$(e.operationType)})}),(0,G.jsx)(rV,{className:`font-mono text-xs`,children:e.consoleUserId??`system`}),(0,G.jsx)(rV,{className:`font-mono text-xs`,children:e.targetClientId??e.partitionId??(e.operationType===`notify_data_change`?`partition default`:`global`)}),(0,G.jsx)(rV,{className:`font-mono text-xs text-neutral-300`,children:Q$(e)})]},`${e.operationId}:${e.createdAt}:${t}`))})]})})})}function o1(){let[e,t]=pQ(`console:alert-config`,K$),n={p90Latency:e.latencyThresholdMs,errorRate:e.errorRateThreshold,clientLag:e.clientLagThreshold};return(0,G.jsx)(JB,{enabled:e.enabled,onEnabledChange:e=>{t(t=>({...t,enabled:e}))},thresholds:n,onThresholdsChange:e=>{t(t=>({...t,latencyThresholdMs:e.p90Latency,errorRateThreshold:e.errorRate,clientLagThreshold:e.clientLag}))}})}function s1(e){if(e===0)return`0 B`;let 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 c1(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function l1(){let[e,t]=(0,W.useState)(``),[n,r]=(0,W.useState)(void 0),[i,a]=(0,W.useState)(void 0),[o,s]=(0,W.useState)([]),[c,l]=(0,W.useState)(null),{data:u,isLoading:d,error:f}=ZQ({prefix:n,cursor:i,limit:100}),p=QQ(),m=$Q();function h(){let t=e.trim();r(t.length>0?t:void 0),a(void 0),s([])}function g(){t(``),r(void 0),a(void 0),s([])}function _(){u?.cursor&&(s(e=>[...e,i??``]),a(u.cursor))}function v(){s(e=>{let t=[...e],n=t.pop();return a(n&&n.length>0?n:void 0),t})}function y(){c&&p.mutate(c,{onSuccess:()=>l(null)})}if(d)return(0,G.jsx)(`div`,{className:`flex flex-col gap-4 px-5 py-5`,children:(0,G.jsx)(`div`,{className:`flex items-center justify-center h-[200px]`,children:(0,G.jsx)(dV,{size:`lg`})})});if(f)return(0,G.jsx)(`div`,{className:`flex flex-col gap-4 px-5 py-5`,children:(0,G.jsx)(`div`,{className:`flex items-center justify-center h-[200px]`,children:(0,G.jsxs)(`p`,{className:`text-danger font-mono text-[11px]`,children:[`Failed to load storage items: `,f.message]})})});let b=u?.items??[];return(0,G.jsxs)(`div`,{className:`flex flex-col gap-4 px-5 py-5`,children:[(0,G.jsx)(eH,{title:`Storage`,actions:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(jR,{placeholder:`Prefix filter...`,value:e,onChange:e=>t(e.target.value),onKeyDown:e=>{e.key===`Enter`&&h()},className:`h-7 w-48 text-xs`}),(0,G.jsx)(Q,{variant:`default`,size:`sm`,onClick:h,children:`Filter`}),n&&(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:g,children:`Clear`})]}),children:b.length===0?(0,G.jsx)(vV,{message:n?`No storage items matching prefix "${n}".`:`No storage items found.`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`overflow-x-auto`,children:(0,G.jsxs)(QB,{children:[(0,G.jsx)($B,{children:(0,G.jsxs)(tV,{children:[(0,G.jsx)(nV,{children:`Key`}),(0,G.jsx)(nV,{children:`Size`}),(0,G.jsx)(nV,{children:`Type`}),(0,G.jsx)(nV,{children:`Uploaded`}),(0,G.jsx)(nV,{children:`Actions`})]})}),(0,G.jsx)(eV,{children:b.map(e=>(0,G.jsxs)(tV,{children:[(0,G.jsx)(rV,{className:`font-mono text-xs max-w-[320px]`,title:e.key,children:e.key}),(0,G.jsx)(rV,{className:`font-mono text-xs text-neutral-400 whitespace-nowrap`,children:s1(e.size)}),(0,G.jsx)(rV,{children:e.httpMetadata?.contentType?(0,G.jsx)(ZB,{variant:`ghost`,children:e.httpMetadata.contentType}):(0,G.jsx)(`span`,{className:`text-neutral-500 text-xs`,children:`--`})}),(0,G.jsx)(rV,{className:`whitespace-nowrap text-xs text-neutral-400`,children:c1(e.uploaded)}),(0,G.jsx)(rV,{children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:()=>void m(e.key),children:`Download`}),(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:()=>l(e.key),children:`Delete`})]})})]},e.key))})]})}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between px-2 py-2`,children:[(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,disabled:o.length===0,onClick:v,children:`Previous`}),(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,disabled:!u?.truncated,onClick:_,children:`Next`})]})]})}),(0,G.jsx)(kZ,{open:c!==null,onOpenChange:()=>l(null),children:(0,G.jsxs)(jZ,{children:[(0,G.jsx)(MZ,{children:(0,G.jsx)(PZ,{children:`Delete Storage Item`})}),(0,G.jsxs)(`div`,{className:`px-5 py-4 flex flex-col gap-4`,children:[(0,G.jsxs)(`p`,{className:`font-mono text-[11px] text-neutral-300`,children:[`Are you sure you want to delete`,` `,(0,G.jsx)(`span`,{className:`font-mono text-white`,children:c}),`?`]}),(0,G.jsx)(`p`,{className:`font-mono text-[10px] text-neutral-500`,children:`This action cannot be undone.`})]}),(0,G.jsxs)(NZ,{children:[(0,G.jsx)(Q,{variant:`default`,onClick:()=>l(null),children:`Cancel`}),(0,G.jsx)(Q,{variant:`destructive`,onClick:y,disabled:p.isPending,children:p.isPending?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(dV,{size:`sm`}),` Deleting...`]}):`Delete`})]})]})})]})}function u1(e,t){if(t===`absolute`)return new Date(e).toLocaleString();let n=new Date(e),r=new Date().getTime()-n.getTime(),i=Math.floor(r/1e3);return i<60?`${i}s`:i<3600?`${Math.floor(i/60)}m`:i<86400?`${Math.floor(i/3600)}h`:`${Math.floor(i/86400)}d`}function d1(e){let t=e.split(/\s+/).map(e=>e.trim()).filter(e=>e.length>0),n={},r=[];for(let e of t){let[t=``,...i]=e.split(`:`),a=i.join(`:`).trim(),o=t.toLowerCase();if(!a){r.push(e);continue}if(o===`actor`){n.actorId=a;continue}if(o===`client`){n.clientId=a;continue}if(o===`table`){n.table=a;continue}if(o===`request`){n.requestId=a;continue}if(o===`trace`){n.traceId=a;continue}r.push(e)}return r.length>0&&(n.search=r.join(` `)),n}function f1(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 p1(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function m1(e,t){return e?`#${e.federatedCommitId??(t?`${t}:${e.commitSeq}`:String(e.commitSeq))}`:`#?`}function h1(e,t){return e?`E${e.federatedEventId??(t?`${t}:${e.eventId}`:e.eventId)}`:`E?`}function g1(e,t,n){return!e||!t?null:e.replaceAll(`{traceId}`,encodeURIComponent(t)).replaceAll(`{spanId}`,encodeURIComponent(n??``))}function _1({initialSelectedEntryId:e}={}){let{preferences:t}=r$(),{partitionId:n}=t$(),{range:r,setRange:i}=g$(),a=t.pageSize,o=t.refreshInterval*1e3,[s,c]=(0,W.useState)(()=>e?.startsWith(`#`)?`commits`:e?.startsWith(`E`)?`events`:`all`),[l,u]=(0,W.useState)(`all`),[d,f]=(0,W.useState)(`all`),[p,m]=(0,W.useState)(``),[h,g]=(0,W.useState)(1),[_,v]=(0,W.useState)(!1),[y,b]=(0,W.useState)(e??null),x=(0,W.useRef)(!1),S=(0,W.useMemo)(()=>d1(p),[p]),C=(0,W.useMemo)(()=>new Date(Date.now()-f1(r)).toISOString(),[r]),{data:w,isLoading:T,refetch:E}=NQ({limit:a,offset:(h-1)*a,...n?{partitionId:n}:{},view:s,...s!==`commits`&&l!==`all`?{eventType:l}:{},...s!==`commits`&&d!==`all`?{outcome:d}:{},...S.actorId?{actorId:S.actorId}:{},...S.clientId?{clientId:S.clientId}:{},...S.requestId?{requestId:S.requestId}:{},...S.traceId?{traceId:S.traceId}:{},...S.table?{table:S.table}:{},...S.search?{search:S.search}:{},from:C},{refetchIntervalMs:o}),D=BQ(),O=y?.startsWith(`#`)?y.slice(1):void 0,k=y?.startsWith(`E`)?y.slice(1):void 0,A=O&&O!==`?`?O:void 0,j=k&&k!==`?`?k:void 0,{data:M,isLoading:N,error:P}=MQ(A,{enabled:A!==void 0,partitionId:n}),{data:F,isLoading:I,error:L}=FQ(j,{enabled:j!==void 0,partitionId:n}),{data:ee,isLoading:R,error:z}=IQ(j,{enabled:j!==void 0&&!!F?.payloadRef,partitionId:n}),B=(0,W.useMemo)(()=>g1(void 0,F?.traceId??null,F?.spanId??null),[F?.spanId,F?.traceId,void 0]);(0,W.useEffect)(()=>{g(1)},[]),(0,W.useEffect)(()=>{g(1)},[]),(0,W.useEffect)(()=>{e&&b(e)},[e]),(0,W.useEffect)(()=>{if(!x.current){x.current=!0;return}b(null)},[]),(0,W.useEffect)(()=>{g(1),b(null)},[]);let V=(0,W.useMemo)(()=>(w?.items??[]).map(e=>{let n=e.instanceId??e.commit?.instanceId??e.event?.instanceId,r=n?`[${n}] `:``;if(e.type===`commit`&&e.commit){let i=e.commit;return{type:`commit`,id:m1(i,n),outcome:`--`,duration:`--`,actor:i.actorId,client:i.clientId,detail:`${r}${i.changeCount} chg | ${(i.affectedTables??[]).join(`, `)}`,time:u1(e.timestamp,t.timeFormat)}}let i=e.event;return i?{type:i.eventType,id:h1(i,n),outcome:i.outcome,duration:`${i.durationMs}ms`,actor:i.actorId,client:i.clientId,detail:`${r}${(i.tables??[]).join(`, `)||`--`}`,time:u1(e.timestamp,t.timeFormat)}:{type:`pull`,id:`E?`,outcome:`unknown`,duration:`--`,actor:``,client:``,detail:`--`,time:u1(e.timestamp,t.timeFormat)}}),[t.timeFormat,w?.items]),H=w?.total??0,U=Math.max(1,Math.ceil(H/a)),te=T,ne=[{label:``,options:[{id:`all`,label:`All`},{id:`commits`,label:`Commits`},{id:`events`,label:`Events`}],activeId:s,onActiveChange:e=>{c(e),e===`commits`&&(u(`all`),f(`all`)),g(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:r,onActiveChange:e=>{i(e),g(1)}},{label:`Type`,options:[{id:`all`,label:`All`},{id:`push`,label:`Push`},{id:`pull`,label:`Pull`}],activeId:l,onActiveChange:e=>{u(e),g(1)}},{label:`Outcome`,options:[{id:`all`,label:`All`},{id:`applied`,label:`Applied`},{id:`error`,label:`Error`},{id:`rejected`,label:`Rejected`}],activeId:d,onActiveChange:e=>{f(e),g(1)}}];function re(){D.mutate(void 0,{onSuccess:()=>{v(!1),E()}})}return(0,G.jsxs)(`div`,{className:`flex flex-col h-full`,children:[te&&V.length===0?(0,G.jsx)(`div`,{className:`flex items-center justify-center py-24`,children:(0,G.jsx)(dV,{size:`lg`})}):(0,G.jsx)(rH,{entries:V,selectedEntryId:y,onEntryClick:e=>b(e.id),filterBar:(0,G.jsx)(yV,{groups:ne,searchValue:p,searchPlaceholder:`Use actor:, client:, table:, request:, trace: or free text...`,onSearchChange:m,actions:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Q,{size:`sm`,variant:`ghost`,onClick:()=>void E(),children:`Refresh`}),(0,G.jsx)(Q,{size:`sm`,variant:`ghost`,children:`Export`}),(0,G.jsx)(Q,{size:`sm`,variant:`destructive`,onClick:()=>v(!0),children:`Clear`})]})}),pagination:(0,G.jsx)(IZ,{page:h,totalPages:U,totalItems:H,onPageChange:g})}),(0,G.jsx)(kZ,{open:y!==null,onOpenChange:e=>{e||b(null)},children:(0,G.jsxs)(jZ,{children:[(0,G.jsx)(MZ,{children:(0,G.jsx)(PZ,{children:A===void 0?j===void 0?`Entry details`:`Event E${j}`:`Commit #${A}`})}),(0,G.jsx)(`div`,{className:`px-5 py-4 space-y-3 max-h-[70vh] overflow-y-auto`,children:N||I?(0,G.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,G.jsx)(dV,{size:`sm`})}):P||L?(0,G.jsx)(`p`,{className:`font-mono text-[11px] text-offline`,children:`Failed to load details.`}):M?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 font-mono text-[11px]`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Actor`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:M.actorId})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Client`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:M.clientId})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Instance`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:M.instanceId??`--`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Created`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:u1(M.createdAt,t.timeFormat)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Changes`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:M.changeCount})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2`,children:`Affected Tables`}),(0,G.jsx)(`p`,{className:`font-mono text-[11px] text-neutral-200`,children:M.affectedTables.join(`, `)||`--`})]}),(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-wider text-neutral-500`,children:`Changes`}),M.changes.length===0?(0,G.jsx)(`p`,{className:`font-mono text-[11px] text-neutral-500`,children:`No changes recorded.`}):M.changes.map(e=>(0,G.jsxs)(`div`,{className:`rounded-md border border-border p-3 space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between font-mono text-[11px]`,children:[(0,G.jsxs)(`span`,{className:`text-neutral-300`,children:[e.table,` | `,e.op]}),(0,G.jsxs)(`span`,{className:`text-neutral-500`,children:[`#`,e.changeId]})]}),(0,G.jsxs)(`div`,{className:`font-mono text-[11px] text-neutral-400`,children:[`rowId: `,e.rowId,e.rowVersion===null?``:` | version: ${e.rowVersion}`]}),(0,G.jsx)(`pre`,{className:`font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200`,children:p1(e.rowJson)})]},e.changeId))]})]}):F?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 font-mono text-[11px]`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Type`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:F.eventType})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Path`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:F.syncPath})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Instance`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:F.instanceId??`--`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Outcome`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:F.outcome})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Response Status`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:F.responseStatus})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Actor`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:F.actorId})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Client`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:F.clientId})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Status`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:F.statusCode})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Transport`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:F.transportPath})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Duration`}),(0,G.jsxs)(`div`,{className:`text-neutral-100`,children:[F.durationMs,`ms`]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Request ID`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:F.requestId})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Trace ID`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:F.traceId??`--`}),B&&(0,G.jsx)(`a`,{href:B,target:`_blank`,rel:`noreferrer`,className:`font-mono text-[10px] text-flow underline underline-offset-4`,children:`Open external trace`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Span ID`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:F.spanId??`--`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Commit Seq`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:F.commitSeq??`--`}),F.commitSeq!==null&&(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:()=>b(`#${F.instanceId?`${F.instanceId}:`:``}${F.commitSeq}`),children:`Open linked commit`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Subscription Count`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:F.subscriptionCount??`--`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Error Code`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:F.errorCode??`--`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Payload Ref`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:F.payloadRef??`--`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Created`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:u1(F.createdAt,t.timeFormat)})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2`,children:`Tables`}),(0,G.jsx)(`p`,{className:`font-mono text-[11px] text-neutral-200`,children:F.tables.join(`, `)||`--`})]}),F.scopesSummary&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2`,children:`Scopes Summary`}),(0,G.jsx)(`pre`,{className:`font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200`,children:p1(F.scopesSummary)})]}),F.payloadRef&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2`,children:`Payload Snapshot`}),R?(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(dV,{size:`sm`}),(0,G.jsx)(`span`,{className:`font-mono text-[11px] text-neutral-400`,children:`Loading payload snapshot...`})]}):z?(0,G.jsx)(`p`,{className:`font-mono text-[11px] text-offline`,children:`Failed to load payload snapshot.`}):ee?(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-wider text-neutral-500`,children:`Request`}),(0,G.jsx)(`pre`,{className:`font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200`,children:p1(ee.requestPayload)}),(0,G.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-wider text-neutral-500`,children:`Response`}),(0,G.jsx)(`pre`,{className:`font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200`,children:p1(ee.responsePayload)})]}):(0,G.jsx)(`p`,{className:`font-mono text-[11px] text-neutral-500`,children:`No payload snapshot available.`})]}),F.errorMessage&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2`,children:`Error`}),(0,G.jsx)(`p`,{className:`font-mono text-[11px] text-offline`,children:F.errorMessage})]})]}):(0,G.jsx)(`p`,{className:`font-mono text-[11px] text-neutral-500`,children:`No details available for this row.`})}),(0,G.jsx)(NZ,{children:(0,G.jsx)(Q,{variant:`default`,size:`sm`,onClick:()=>b(null),children:`Close`})})]})}),(0,G.jsx)(kZ,{open:_,onOpenChange:e=>{e||v(!1)},children:(0,G.jsxs)(jZ,{children:[(0,G.jsx)(MZ,{children:(0,G.jsx)(PZ,{children:`Clear all events`})}),(0,G.jsx)(`div`,{className:`p-4`,children:(0,G.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?`})}),(0,G.jsxs)(NZ,{children:[(0,G.jsx)(Q,{variant:`default`,size:`sm`,onClick:()=>v(!1),children:`Cancel`}),(0,G.jsx)(Q,{variant:`destructive`,size:`sm`,onClick:re,disabled:D.isPending,children:D.isPending?`Clearing...`:`Clear all`})]})]})})]})}var v1=Hv({getParentRoute:()=>p$,path:`/config`,component:A$}),y1=Hv({getParentRoute:()=>p$,path:`/fleet`,component:G$}),b1=Hv({getParentRoute:()=>p$,path:`/`,component:O$});function x1(){let{seq:e}=S1.useParams();return(0,G.jsx)(_1,{initialSelectedEntryId:`#${e}`})}var S1=Hv({getParentRoute:()=>p$,path:`/investigate/commit/$seq`,component:x1});function C1(){let{id:e}=w1.useParams();return(0,G.jsx)(_1,{initialSelectedEntryId:`E${e}`})}var w1=Hv({getParentRoute:()=>p$,path:`/investigate/event/$id`,component:C1}),T1=Hv({getParentRoute:()=>p$,path:`/ops`,component:e1}),E1=Hv({getParentRoute:()=>p$,path:`/storage`,component:l1}),D1=Hv({getParentRoute:()=>p$,path:`/stream`,component:_1}),O1=p$.addChildren([b1,D1,S1,w1,y1,T1,E1,v1]),k1=`syncular-console-basepath`,A1=`syncular-console-server-url`,j1=`syncular-console-token`;function M1(e){if(!e)return;let t=e.trim();return t.length>0?t:void 0}function N1(e){let t=globalThis.document;if(!t)return;let n=t.querySelector(`meta[name="${e}"]`)?.getAttribute(`content`);return M1(n)}function P1(e){return!e||e===`/`?`/`:(e.startsWith(`/`)?e:`/${e}`).replace(/\/+$/g,``)||`/`}function F1(){return P1(N1(k1))}function I1(){let e=N1(A1),t=N1(j1);return!e||!t?null:{serverUrl:e,token:t}}function L1(){return new Vm({defaultOptions:{queries:{staleTime:5e3,retry:1}}})}function R1(e){return P1(e??F1())}function z1(e){let[t]=(0,W.useState)(()=>L1()),n=(0,W.useMemo)(()=>iy({routeTree:O1,basepath:R1(e.basePath)}),[e.basePath]);return(0,G.jsx)(Gm,{client:t,children:(0,G.jsx)(My,{defaultConfig:e.defaultConfig===void 0?I1():e.defaultConfig,autoConnect:e.autoConnect??e.defaultConfig===void 0,storageMode:e.storageMode,children:(0,G.jsx)(sy,{router:n})})})}function B1(e){return(0,G.jsx)(`div`,{className:o$,children:(0,G.jsx)(z1,{...e})})}function V1(e){if(typeof e!=`string`)return e;let t=document.querySelector(e);if(!t)throw Error(`Unable to mount console: ${e} not found`);return t}function H1(e,t={}){let n=V1(e);s$(n);let r=(0,Cy.createRoot)(n),i=(0,G.jsx)(B1,{basePath:t.basePath,defaultConfig:t.defaultConfig,autoConnect:t.autoConnect});return t.strictMode===!1?(r.render(i),r):(r.render((0,G.jsx)(W.StrictMode,{children:i})),r)}var U1=`syncular-sentry-dsn`,W1=`syncular-sentry-environment`,G1=`syncular-sentry-release`;function K1(e){if(!e)return;let t=e.trim();return t.length>0?t:void 0}function q1(e){if(typeof document>`u`)return;let t=document.querySelector(`meta[name="${e}"]`)?.getAttribute(`content`);return K1(t)}function J1(e){if(!(typeof process>`u`))return K1({}[e])}function Y1(e){for(let t of e)if(t)return t}function X1(){let e=Y1([K1(globalThis.__SYNCULAR_SENTRY_DSN__),q1(U1),J1(`SYNCULAR_SENTRY_DSN`)]);return e?{dsn:e,environment:Y1([K1(globalThis.__SYNCULAR_SENTRY_ENVIRONMENT__),q1(W1),J1(`SYNCULAR_SENTRY_ENVIRONMENT`)]),release:Y1([K1(globalThis.__SYNCULAR_SENTRY_RELEASE__),q1(G1),J1(`SYNCULAR_SENTRY_RELEASE`)]),enableLogs:!0,tracesSampleRate:.2,tracePropagationTargets:[/^https?:\/\/.*\/api\/.*/]}:null}var Z1=X1();Z1&&Tp(Z1),H1(`#root`);
|
|
30
|
+
)`}return(0,G.jsx)(`div`,{ref:t,role:`presentation`,"data-base-ui-inert":``,...r,style:{position:`fixed`,inset:0,userSelect:`none`,WebkitUserSelect:`none`,clipPath:i}})});function HY(e,t){e&&Object.assign(e.style,t)}var UY={position:`relative`,maxHeight:`100%`,overflowX:`hidden`,overflowY:`auto`},WY={position:`fixed`},GY=W.forwardRef(function(e,t){let{anchor:n,positionMethod:r=`absolute`,className:i,render:a,side:o=`bottom`,align:s=`center`,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m,alignItemWithTrigger:h=!0,collisionAvoidance:g=yz,..._}=e,{store:v,listRef:y,labelsRef:b,alignItemWithTriggerActiveRef:x,selectedItemTextRef:S,valuesRef:C,initialValueRef:w,popupRef:T,setValue:E}=nY(),D=rY(),O=LK(v,fY.open),k=LK(v,fY.mounted),A=LK(v,fY.modal),j=LK(v,fY.value),M=LK(v,fY.openMethod),N=LK(v,fY.positionerElement),P=LK(v,fY.triggerElement),F=LK(v,fY.isItemEqualToValue),I=LK(v,fY.transitionStatus),L=W.useRef(null),ee=W.useRef(null),[R,z]=W.useState(h),B=k&&R&&M!==`touch`;!k&&R!==h&&z(h),Z(()=>{k||(fY.scrollUpArrowVisible(v.state)&&v.set(`scrollUpArrowVisible`,!1),fY.scrollDownArrowVisible(v.state)&&v.set(`scrollDownArrowVisible`,!1))},[v,k]),W.useImperativeHandle(x,()=>B),MY((B||A)&&O&&M!==`touch`,P);let V=fJ({anchor:n,floatingRootContext:D,positionMethod:r,mounted:k,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m??B,collisionAvoidance:g,keepMounted:!0}),H=B?`none`:V.side,U=B?WY:V.positionerStyles,te=W.useMemo(()=>{let e={};return O||(e.pointerEvents=`none`),{role:`presentation`,hidden:!k,style:{...U,...e}}},[O,k,U]),ne={open:O,side:H,align:V.align,anchorHidden:V.anchorHidden},re=Sz(`div`,e,{ref:[t,X(e=>{v.set(`positionerElement`,e)})],state:ne,stateAttributesMapping:qq,props:[te,mJ(I),_]}),ie=W.useRef(0),ae=X(e=>{if(e.size===0&&ie.current===0||C.current.length===0)return;let t=ie.current;if(ie.current=e.size,e.size===t)return;let n=UB(jB);if(t!==0&&!v.state.multiple&&j!==null&&oY(C.current,j,F)===-1){let e=w.current,t=e!=null&&oY(C.current,e,F)!==-1?e:null;E(t,n),t===null&&(v.set(`selectedIndex`,null),S.current=null)}if(t!==0&&v.state.multiple&&Array.isArray(j)){let e=e=>oY(C.current,e,F)!==-1,t=j.filter(t=>e(t));(t.length!==j.length||t.some(e=>!aY(j,e,F)))&&(E(t,n),t.length===0&&(v.set(`selectedIndex`,null),S.current=null))}if(O&&B){v.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});let e={height:``};HY(N,e),HY(T.current,e)}}),oe=W.useMemo(()=>({...V,side:H,alignItemWithTriggerActive:B,setControlledAlignItemWithTrigger:z,scrollUpArrowRef:L,scrollDownArrowRef:ee}),[V,H,B,z]);return(0,G.jsx)(FY,{elementsRef:y,labelsRef:b,onMapChange:ae,children:(0,G.jsxs)(zY.Provider,{value:oe,children:[k&&A&&(0,G.jsx)(VY,{inert:vJ(!O),cutout:P}),re]})})});function KY(e){let 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}var qY=`base-ui-disable-scrollbar`,JY={className:qY,getElement(e){return(0,G.jsx)(`style`,{nonce:e,href:qY,precedence:`base-ui:low`,children:`.${qY}{scrollbar-width:none}.${qY}::-webkit-scrollbar{display:none}`})}},YY=W.createContext(void 0);function XY(e){let t=W.useContext(YY);if(t===void 0&&!e)throw Error(QR(69));return t}var ZY=`ArrowUp`,QY=`ArrowDown`,$Y=`ArrowLeft`,eX=`ArrowRight`,tX=`Home`,nX=new Set([$Y,eX]),rX=new Set([$Y,eX,tX,`End`]),iX=new Set([ZY,QY]),aX=new Set([ZY,QY,tX,`End`]),oX=new Set([...nX,...iX]),sX=new Set([...oX,tX,`End`]),cX=new Set([ZY,QY,$Y,eX,tX,`End`]),lX=new Set([`Shift`,`Control`,`Alt`,`Meta`]);function uX(e){return zz(e)&&e.tagName===`INPUT`}function dX(e){return!!(uX(e)&&e.selectionStart!=null||zz(e)&&e.tagName===`TEXTAREA`)}function fX(e,t,n,r){if(!e||!t||!t.scrollTo)return;let i=e.scrollLeft,a=e.scrollTop,o=e.clientWidth<e.scrollWidth,s=e.clientHeight<e.scrollHeight;if(o&&r!==`vertical`){let r=pX(e,t,`left`),a=mX(e),o=mX(t);n===`ltr`&&(r+t.offsetWidth+o.scrollMarginRight>e.scrollLeft+e.clientWidth-a.scrollPaddingRight?i=r+t.offsetWidth+o.scrollMarginRight-e.clientWidth+a.scrollPaddingRight:r-o.scrollMarginLeft<e.scrollLeft+a.scrollPaddingLeft&&(i=r-o.scrollMarginLeft-a.scrollPaddingLeft)),n===`rtl`&&(r-o.scrollMarginRight<e.scrollLeft+a.scrollPaddingLeft?i=r-o.scrollMarginLeft-a.scrollPaddingLeft:r+t.offsetWidth+o.scrollMarginRight>e.scrollLeft+e.clientWidth-a.scrollPaddingRight&&(i=r+t.offsetWidth+o.scrollMarginRight-e.clientWidth+a.scrollPaddingRight))}if(s&&r!==`horizontal`){let n=pX(e,t,`top`),r=mX(e),i=mX(t);n-i.scrollMarginTop<e.scrollTop+r.scrollPaddingTop?a=n-i.scrollMarginTop-r.scrollPaddingTop:n+t.offsetHeight+i.scrollMarginBottom>e.scrollTop+e.clientHeight-r.scrollPaddingBottom&&(a=n+t.offsetHeight+i.scrollMarginBottom-e.clientHeight+r.scrollPaddingBottom)}e.scrollTo({left:i,top:a,behavior:`auto`})}function pX(e,t,n){let r=n===`left`?`offsetLeft`:`offsetTop`,i=0;for(;t.offsetParent&&(i+=t[r],t.offsetParent!==e);)t=t.offsetParent;return i}function mX(e){let 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 hX(e,t=-(2**53-1),n=2**53-1){return Math.max(t,Math.min(e,n))}var gX=W.createContext(void 0),_X={disableStyleElements:!1};function vX(){return W.useContext(gX)??_X}var yX=1,bX={...qq,...YK},xX=W.forwardRef(function(e,t){let{render:n,className:r,finalFocus:i,...a}=e,{store:o,popupRef:s,onOpenChangeComplete:c,setOpen:l,valueRef:u,selectedItemTextRef:d,keyboardActiveRef:f,multiple:p,handleScrollArrowVisibility:m,scrollHandlerRef:h,highlightItemOnHover:g}=nY(),{side:_,align:v,alignItemWithTriggerActive:y,setControlledAlignItemWithTrigger:b,scrollDownArrowRef:x,scrollUpArrowRef:S}=BY(),C=XY(!0)!=null,w=rY(),{nonce:T,disableStyleElements:E}=vX(),D=xH(),O=LK(o,fY.id),k=LK(o,fY.open),A=LK(o,fY.mounted),j=LK(o,fY.popupProps),M=LK(o,fY.transitionStatus),N=LK(o,fY.triggerElement),P=LK(o,fY.positionerElement),F=LK(o,fY.listElement),I=W.useRef(0),L=W.useRef(!1),ee=W.useRef(0),R=W.useRef(!1),z=W.useRef({}),B=FW(),V=X(e=>{if(!P||!s.current||!R.current)return;if(L.current||!y){m();return}let t=P.style.top===`0px`,n=P.style.bottom===`0px`,r=P.getBoundingClientRect().height,i=gW(P),a=getComputedStyle(P),o=parseFloat(a.marginTop),c=parseFloat(a.marginBottom),l=SX(getComputedStyle(s.current)),u=Math.min(i.documentElement.clientHeight-o-c,l),d=e.scrollTop,f=CX(e),p=0,h=null,g=!1,_=!1,v=e=>{P.style.height=`${e}px`},b=(t,n)=>{let i=hX(t,0,u-r);i>0&&v(r+i),e.scrollTop=n,u-(r+i)<=yX&&(L.current=!0),m()};if(t){let e=f-d,t=r+e,n=Math.min(t,u);if(p=n,e<=yX){b(e,f);return}u-n>yX?_=!0:g=!0}else if(n){let e=d,t=r+e,n=Math.min(t,u),i=t-u;if(p=n,e<=yX){b(e,0);return}u-n>yX?h=0:(g=!0,d<f&&(h=d-(e-i)))}if(p=Math.ceil(p),p!==0&&v(p),_||h!=null){let t=CX(e),n=_?t:hX(h,0,t);Math.abs(e.scrollTop-n)>yX&&(e.scrollTop=n)}(g||p>=u-yX)&&(L.current=!0),m()});W.useImperativeHandle(h,()=>V,[V]),ZK({open:k,ref:s,onComplete(){k&&c?.(!0)}});let H={open:k,transitionStatus:M,side:_,align:v};Z(()=>{!P||!s.current||Object.keys(z.current).length||(z.current={top:P.style.top||`0`,left:P.style.left||`0`,right:P.style.right,height:P.style.height,bottom:P.style.bottom,minHeight:P.style.minHeight,maxHeight:P.style.maxHeight,marginTop:P.style.marginTop,marginBottom:P.style.marginBottom})},[s,P]),Z(()=>{k||y||(R.current=!1,L.current=!1,I.current=0,ee.current=0,HY(P,z.current))},[k,y,P,s]),Z(()=>{let e=s.current;if(!(!k||!N||!P||!e||o.state.transitionStatus===`ending`)){if(!y){R.current=!0,B.request(m),e.style.removeProperty(`--transform-origin`);return}queueMicrotask(()=>{let t=DX(e);e.style.removeProperty(`--transform-origin`);try{let t=getComputedStyle(P),n=getComputedStyle(e),r=gW(N),i=Fz(P),a=wX(N),o=TX(N.getBoundingClientRect(),a),s=TX(P.getBoundingClientRect(),a),c=o.left,l=o.height,f=F||e,p=f.scrollHeight,h=parseFloat(n.borderBottomWidth),g=parseFloat(t.marginTop)||10,_=parseFloat(t.marginBottom)||10,v=parseFloat(t.minHeight)||100,y=SX(n),x=r.documentElement.clientHeight-g-_,S=r.documentElement.clientWidth,C=x-o.bottom+l,w=d.current,T=u.current,E,D=0,O=0;if(w&&T){let e=TX(T.getBoundingClientRect(),a);E=TX(w.getBoundingClientRect(),a);let t=e.left-c,n=E.left-s.left,r=e.top-o.top+e.height/2,i=E.top-s.top+E.height/2;D=t-n,O=i-r}let k=C+O+_+h,A=Math.min(x,k),j=x-g-_,M=k-A,ee=Math.max(5,c+D),B=S-5,V=Math.max(0,ee+s.width-B);P.style.left=`${ee-V}px`,P.style.height=`${A}px`,P.style.maxHeight=`auto`,P.style.marginTop=`${g}px`,P.style.marginBottom=`${_}px`,e.style.height=`100%`;let H=CX(f),U=M>=H-yX;U&&(A=Math.min(x,s.height)-(M-H));let te=o.top<20||o.bottom>x-20||Math.ceil(A)+yX<Math.min(p,v),ne=(i.visualViewport?.scale??1)!==1&&EH;if(te||ne){R.current=!0,HY(P,z.current),Dv.flushSync(()=>b(!1));return}if(U){let e=Math.max(0,x-k);P.style.top=s.height>=j?`0`:`${e}px`,P.style.height=`${A}px`,f.scrollTop=CX(f),I.current=Math.max(v,A)}else P.style.bottom=`0`,I.current=Math.max(v,A),f.scrollTop=M;if(E){let t=s.top,n=s.height,r=E.top+E.height/2,i=hX(n>0?(r-t)/n*100:50,0,100);e.style.setProperty(`--transform-origin`,`50% ${i}%`)}(I.current===x||A>=y)&&(L.current=!0),m(),setTimeout(()=>{R.current=!0})}finally{t()}})}},[o,k,P,N,u,d,s,m,y,b,B,x,S,F]),W.useEffect(()=>{if(!y||!P||!k)return;let e=Fz(P);function t(e){l(!1,UB(HB,e))}return e.addEventListener(`resize`,t),()=>{e.removeEventListener(`resize`,t)}},[l,y,P,k]);let U={...F?{role:`presentation`,"aria-orientation":void 0}:{role:`listbox`,"aria-multiselectable":p||void 0,id:`${O}-list`},onKeyDown(e){f.current=!0,C&&cX.has(e.key)&&e.stopPropagation()},onMouseMove(){f.current=!1},onPointerLeave(e){if(!g||KY(e)||e.pointerType===`touch`)return;let t=e.currentTarget;D.start(0,()=>{o.set(`activeIndex`,null),t.focus({preventScroll:!0})})},onScroll(e){F||V(e.currentTarget)},...y&&{style:F?{height:`100%`}:UY}},te=Sz(`div`,e,{ref:[t,s],state:H,stateAttributesMapping:bX,props:[j,U,mJ(M),{className:!F&&y?JY.className:void 0},a]});return(0,G.jsxs)(W.Fragment,{children:[!E&&JY.getElement(T),(0,G.jsx)(vG,{context:w,modal:!1,disabled:!A,returnFocus:i,restoreFocus:!0,children:te})]})});function SX(e){let t=e.maxHeight||``;return t.endsWith(`px`)&&parseFloat(t)||1/0}function CX(e){return Math.max(0,e.scrollHeight-e.clientHeight)}function wX(e){return fK.getScale(e)}function TX(e,t){return OU({x:e.x/t.x,y:e.y/t.y,width:e.width/t.x,height:e.height/t.y})}var EX=[[`transform`,`none`],[`scale`,`1`],[`translate`,`0 0`]];function DX(e){let{style:t}=e,n={};for(let[e,r]of EX)n[e]=t.getPropertyValue(e),t.setProperty(e,r,`important`);return()=>{for(let[e]of EX){let r=n[e];r?t.setProperty(e,r):t.removeProperty(e)}}}var OX=function(e){return e[e.None=0]=`None`,e[e.GuessFromOrder=1]=`GuessFromOrder`,e}({});function kX(e={}){let{label:t,metadata:n,textRef:r,indexGuessBehavior:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,elementsRef:l,labelsRef:u,nextIndexRef:d}=PY(),f=W.useRef(-1),[p,m]=W.useState(a??(i===OX.GuessFromOrder?()=>{if(f.current===-1){let e=d.current;d.current+=1,f.current=e}return f.current}:-1)),h=W.useRef(null),g=W.useCallback(e=>{if(h.current=e,p!==-1&&e!==null&&(l.current[p]=e,u)){let n=t!==void 0;u.current[p]=n?t:r?.current?.textContent??e.textContent}},[p,l,u,t,r]);return Z(()=>{if(a!=null)return;let e=h.current;if(e)return o(e,n),()=>{s(e)}},[a,o,s,n]),Z(()=>{if(a==null)return c(e=>{let t=h.current?e.get(h.current)?.index:null;t!=null&&m(t)})},[a,c,m]),W.useMemo(()=>({ref:g,index:p}),[p,g])}var AX=W.createContext(void 0),jX=W.memo(W.forwardRef(function(e,t){let{render:n,className:r,value:i=null,label:a,disabled:o=!1,nativeButton:s=!1,...c}=e,l=W.useRef(null),u=kX({label:a,textRef:l,indexGuessBehavior:OX.GuessFromOrder}),{store:d,getItemProps:f,setOpen:p,setValue:m,selectionRef:h,typingRef:g,valuesRef:_,keyboardActiveRef:v,multiple:y,highlightItemOnHover:b}=nY(),x=xH(),S=LK(d,fY.isActive,u.index),C=LK(d,fY.isSelected,u.index,i),w=LK(d,fY.isSelectedByFocus,u.index),T=LK(d,fY.isItemEqualToValue),E=u.index,D=E!==-1,O=W.useRef(null),k=AW(E);Z(()=>{if(!D)return;let e=_.current;return e[E]=i,()=>{delete e[E]}},[D,E,i,_]),Z(()=>{if(!D)return;let e=d.state.value,t=e;y&&Array.isArray(e)&&e.length>0&&(t=e[e.length-1]),t!==void 0&&iY(i,t,T)&&d.set(`selectedIndex`,E)},[D,E,y,T,d,i]);let A={disabled:o,selected:C,highlighted:S},j=f({active:S,selected:C});j.onFocus=void 0,j.id=void 0;let M=W.useRef(null),N=W.useRef(`mouse`),P=W.useRef(!1),{getButtonProps:F,buttonRef:I}=sB({disabled:o,focusableWhenDisabled:!0,native:s,composite:!0});function L(e){let t=d.state.value;if(y){let n=Array.isArray(t)?t:[];m(C?sY(n,i,T):[...n,i],UB(IB,e))}else m(i,UB(IB,e)),p(!1,UB(IB,e))}let ee={role:`option`,"aria-selected":C,tabIndex:S?0:-1,onFocus(){d.set(`activeIndex`,E)},onMouseEnter(){!v.current&&d.state.selectedIndex===null&&b&&d.set(`activeIndex`,E)},onMouseMove(){b&&d.set(`activeIndex`,E)},onMouseLeave(e){!b||v.current||KY(e)||x.start(0,()=>{d.state.activeIndex===E&&d.set(`activeIndex`,null)})},onTouchStart(){h.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1}},onKeyDown(e){M.current=e.key,d.set(`activeIndex`,E),e.key===` `&&g.current&&e.preventDefault()},onClick(e){P.current=!1,!(e.type===`keydown`&&M.current===null)&&(o||e.type===`keydown`&&M.current===` `&&g.current||N.current!==`touch`&&!S||(M.current=null,L(e.nativeEvent)))},onPointerEnter(e){N.current=e.pointerType},onPointerDown(e){N.current=e.pointerType,P.current=!0},onMouseUp(){if(o)return;if(P.current){P.current=!1;return}let e=!h.current.allowSelectedMouseUp&&C,t=!h.current.allowUnselectedMouseUp&&!C;e||t||N.current!==`touch`&&!S||O.current?.click()}},R=Sz(`div`,e,{ref:[I,t,u.ref,O],state:A,props:[j,ee,c,F]}),z=W.useMemo(()=>({selected:C,indexRef:k,textRef:l,selectedByFocus:w,hasRegistered:D}),[C,k,l,w,D]);return(0,G.jsx)(AX.Provider,{value:z,children:R})})),MX=(0,W.forwardRef)(({className:e,children:t,...n},r)=>(0,G.jsx)(xY,{ref:r,className:Y(`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}));MX.displayName=`SelectTrigger`;var NX=(0,W.forwardRef)(({className:e,portalProps:t,positionerProps:n,...r},i)=>(0,G.jsx)(CY,{...t,children:(0,G.jsx)(GY,{...n,children:(0,G.jsx)(xX,{ref:i,className:Y(`bg-panel border border-border rounded-md py-1 shadow-lg z-50`,e),...r})})}));NX.displayName=`SelectContent`;var PX=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(jX,{ref:n,className:Y(`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}));PX.displayName=`SelectItem`;var FX=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(`textarea`,{ref:n,className:Y(`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}));FX.displayName=`Textarea`;var IX=W.createContext(void 0);function LX(e=!0){let t=W.useContext(IX);if(t===void 0&&!e)throw Error(QR(7));return t}function RX(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=aB(),{ref:i,index:a}=kX(e),o=n===a,s=W.useRef(null),c=zR(i,s);return{compositeProps:W.useMemo(()=>({tabIndex:o?0:-1,onFocus(){r(a)},onMouseMove(){let e=s.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!o&&!n&&e.focus()}}),[o,r,a,t]),compositeRef:c,index:a}}function zX(e){let{render:t,className:n,state:r=XR,props:i=YR,refs:a=YR,metadata:o,stateAttributesMapping:s,tag:c=`div`,...l}=e,{compositeProps:u,compositeRef:d}=RX({metadata:o});return Sz(c,e,{state:r,ref:[...a,d],props:[u,...i,l],stateAttributesMapping:s})}var BX=W.forwardRef(function(e,t){let{className:n,defaultPressed:r=!1,disabled:i=!1,form:a,onPressedChange:o,pressed:s,render:c,type:l,value:u,nativeButton:d=!0,...f}=e,p=Mz(u||void 0),m=LX(),h=m?.value??[],g=m?void 0:r,_=(i||m?.disabled)??!1,[v,y]=MR({controlled:m?p!==void 0&&h.indexOf(p)>-1:s,default:g,name:`Toggle`,state:`pressed`}),b=X((e,t)=>{p&&m?.setGroupValue?.(p,e,t),o?.(e,t)}),{getButtonProps:x,buttonRef:S}=sB({disabled:_,native:d}),C={disabled:_,pressed:v},w=[S,t],T=[{"aria-pressed":v,onClick(e){let t=!v,n=UB(jB,e.nativeEvent);b(t,n),!n.isCanceled&&y(t)}},f,x],E=Sz(`button`,e,{enabled:!m,state:C,ref:w,props:T});return m?(0,G.jsx)(zX,{tag:`button`,render:c,className:n,state:C,refs:w,props:T}):E}),VX=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(BX,{ref:n,className:Y(`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}));VX.displayName=`Toggle`;function HX(e){return e==null||e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}var UX=`data-composite-item-active`,WX=[];function GX(e){let{itemSizes:t,cols:n=1,loopFocus:r=!0,dense:i=!1,orientation:a=`both`,direction:o,highlightedIndex:s,onHighlightedIndexChange:c,rootRef:l,enableHomeAndEndKeys:u=!1,stopEventPropagation:d=!1,disabledIndices:f,modifierKeys:p=WX}=e,[m,h]=W.useState(0),g=n>1,_=W.useRef(null),v=zR(_,l),y=W.useRef([]),b=W.useRef(!1),x=s??m,S=X((e,t=!1)=>{if((c??h)(e),t){let t=y.current[e];fX(_.current,t,o,a)}}),C=X(e=>{if(e.size===0||b.current)return;b.current=!0;let t=Array.from(e.keys()),n=t.find(e=>e?.hasAttribute(`data-composite-item-active`))??null,r=n?t.indexOf(n):-1;r!==-1&&S(r),fX(_.current,n,o,a)}),w=W.useMemo(()=>({"aria-orientation":a===`both`?void 0:a,ref:v,onFocus(e){!_.current||!dX(e.target)||e.target.setSelectionRange(0,e.target.value.length??0)},onKeyDown(e){let s=u?sX:oX;if(!s.has(e.key)||KX(e,p)||!_.current)return;let c=o===`rtl`,l=c?$Y:eX,m={horizontal:l,vertical:QY,both:l}[a],h=c?eX:$Y,v={horizontal:h,vertical:ZY,both:h}[a];if(dX(e.target)&&!HX(e.target)){let t=e.target.selectionStart,n=e.target.selectionEnd,r=e.target.value??``;if(t==null||e.shiftKey||t!==n||e.key!==v&&t<r.length||e.key!==m&&t>0)return}let b=x,C=jU(y,f),w=MU(y,f);if(g){let o=t||Array.from({length:y.current.length},()=>({width:1,height:1})),s=FU(o,n,i),l=s.findIndex(e=>e!=null&&!RU(y,e,f)),u=s.reduce((e,t,n)=>t!=null&&!RU(y,t,f)?n:e,-1);b=s[PU({current:s.map(e=>e?y.current[e]:null)},{event:e,orientation:a,loopFocus:r,cols:n,disabledIndices:LU([...f||y.current.map((e,t)=>RU(y,t)?t:void 0),void 0],s),minIndex:l,maxIndex:u,prevIndex:IU(x>w?C:x,o,s,n,e.key===`ArrowDown`?`bl`:e.key===`ArrowRight`?`tr`:`tl`),rtl:c})]}let T={horizontal:[l],vertical:[QY],both:[l,QY]}[a],E={horizontal:[h],vertical:[ZY],both:[h,ZY]}[a],D=g?s:{horizontal:u?rX:nX,vertical:u?aX:iX,both:s}[a];u&&(e.key===`Home`?b=C:e.key===`End`&&(b=w)),b===x&&(T.includes(e.key)||E.includes(e.key))&&(b=r&&b===w&&T.includes(e.key)?C:r&&b===C&&E.includes(e.key)?w:NU(y,{startingIndex:b,decrement:E.includes(e.key),disabledIndices:f})),b!==x&&!AU(y,b)&&(d&&e.stopPropagation(),D.has(e.key)&&e.preventDefault(),S(b,!0),queueMicrotask(()=>{y.current[b]?.focus()}))}}),[n,i,o,f,y,u,x,g,t,r,v,p,S,a,d]);return W.useMemo(()=>({props:w,highlightedIndex:x,onHighlightedIndexChange:S,elementsRef:y,disabledIndices:f,onMapChange:C,relayKeyboardEvent:w.onKeyDown}),[w,x,S,y,f,C])}function KX(e,t){for(let n of lX.values())if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function qX(e){let{render:t,className:n,refs:r=YR,props:i=YR,state:a=XR,stateAttributesMapping:o,highlightedIndex:s,onHighlightedIndexChange:c,orientation:l,dense:u,itemSizes:d,loopFocus:f,cols:p,enableHomeAndEndKeys:m,onMapChange:h,stopEventPropagation:g=!0,rootRef:_,disabledIndices:v,modifierKeys:y,highlightItemOnHover:b=!1,tag:x=`div`,...S}=e,{props:C,highlightedIndex:w,onHighlightedIndexChange:T,elementsRef:E,onMapChange:D,relayKeyboardEvent:O}=GX({itemSizes:d,cols:p,loopFocus:f,dense:u,orientation:l,highlightedIndex:s,onHighlightedIndexChange:c,rootRef:_,stopEventPropagation:g,enableHomeAndEndKeys:m,direction:iJ(),disabledIndices:v,modifierKeys:y}),k=Sz(x,e,{state:a,ref:r,props:[C,...i,S],stateAttributesMapping:o}),A=W.useMemo(()=>({highlightedIndex:w,onHighlightedIndexChange:T,highlightItemOnHover:b,relayKeyboardEvent:O}),[w,T,b,O]);return(0,G.jsx)(iB.Provider,{value:A,children:(0,G.jsx)(FY,{elementsRef:E,onMapChange:e=>{h?.(e),D(e)},children:k})})}var JX=function(e){return e.disabled=`data-disabled`,e.orientation=`data-orientation`,e.multiple=`data-multiple`,e}({}),YX={multiple(e){return e?{[JX.multiple]:``}:null}},XX=W.forwardRef(function(e,t){let{defaultValue:n,disabled:r=!1,loopFocus:i=!0,onValueChange:a,orientation:o=`horizontal`,multiple:s=!1,value:c,className:l,render:u,...d}=e,f=XY(!0),p=W.useMemo(()=>{if(c===void 0)return n??[]},[c,n]),m=W.useMemo(()=>c!==void 0||n!==void 0,[c,n]),h=(f?.disabled??!1)||r,[g,_]=MR({controlled:c,default:p,name:`ToggleGroup`,state:`value`}),v=X((e,t,n)=>{let r;if(s?(r=g.slice(),t?r.push(e):r.splice(g.indexOf(e),1)):r=t?[e]:[],Array.isArray(r)){if(a?.(r,n),n.isCanceled)return;_(r)}}),y={disabled:h,multiple:s,orientation:o},b=W.useMemo(()=>({disabled:h,orientation:o,setGroupValue:v,value:g,isValueInitialized:m}),[h,o,v,g,m]),x={role:`group`},S=Sz(`div`,e,{enabled:!!f,state:y,ref:t,props:[x,d],stateAttributesMapping:YX});return(0,G.jsx)(IX.Provider,{value:b,children:f?S:(0,G.jsx)(qX,{render:u,className:l,state:y,refs:[t],props:[x,d],stateAttributesMapping:YX,loopFocus:i,enableHomeAndEndKeys:!0})})}),ZX=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(XX,{ref:n,className:Y(`flex items-center gap-0.5`,e),...t}));ZX.displayName=`ToggleGroup`;var QX=Y(cV({variant:`secondary`,size:`sm`}),`h-7 whitespace-nowrap uppercase tracking-[0.08em] leading-none no-underline`);function $X({active:e,onClick:t,children:n,className:r}){return(0,G.jsxs)(`button`,{type:`button`,onClick:t,className:Y(`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`,r),children:[n,e&&(0,G.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:r,className:i}){return(0,G.jsx)(`div`,{className:Y(`flex items-center gap-0.5`,i),children:e.map(e=>{let i=e.id===t,a=()=>n?.(e.id);return r?(0,G.jsx)(`span`,{children:r(e,{active:i,onClick:a})},e.id):(0,G.jsx)($X,{active:i,onClick:a,children:e.label},e.id)})})}var tZ=kR(`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}}),nZ={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:r,className:i}){return(0,G.jsx)(`span`,{className:Y(tZ({color:e,size:t,glow:n}),r&&`dot-pulse`,i),style:n?{boxShadow:nZ[e??`healthy`]}:void 0})}var iZ={name:`@syncular/ui`,version:`0.0.6-246`,description:`Reusable Syncular UI components and styles`,license:`Apache-2.0`,author:`Benjamin Kniffler`,homepage:`https://syncular.dev`,repository:{type:`git`,url:`https://github.com/syncular/syncular.git`,directory:`packages/ui`},bugs:{url:`https://github.com/syncular/syncular/issues`},keywords:[`sync`,`offline-first`,`realtime`,`ui`,`react`],publishConfig:{access:`public`},type:`module`,exports:{".":{bun:`./src/index.ts`,browser:`./src/index.ts`,import:{types:`./dist/index.d.ts`,default:`./dist/index.js`}},"./charts":{bun:`./src/charts/index.ts`,browser:`./src/charts/index.ts`,import:{types:`./dist/charts/index.d.ts`,default:`./dist/charts/index.js`}},"./console":{bun:`./src/console/index.ts`,browser:`./src/console/index.ts`,import:{types:`./dist/console/index.d.ts`,default:`./dist/console/index.js`}},"./forms":{bun:`./src/forms/index.ts`,browser:`./src/forms/index.ts`,import:{types:`./dist/forms/index.d.ts`,default:`./dist/forms/index.js`}},"./primitives":{bun:`./src/primitives/index.ts`,browser:`./src/primitives/index.ts`,import:{types:`./dist/primitives/index.d.ts`,default:`./dist/primitives/index.js`}},"./observable-universe":{bun:`./src/observable-universe/index.ts`,browser:`./src/observable-universe/index.ts`,import:{types:`./dist/observable-universe/index.d.ts`,default:`./dist/observable-universe/index.js`}},"./demo":{bun:`./src/demo/index.ts`,browser:`./src/demo/index.ts`,import:{types:`./dist/demo/index.d.ts`,default:`./dist/demo/index.js`}},"./navigation":{bun:`./src/navigation/index.ts`,browser:`./src/navigation/index.ts`,import:{types:`./dist/navigation/index.d.ts`,default:`./dist/navigation/index.js`}},"./styles.css":`./dist/styles.css`,"./styles.source.css":`./src/styles/styles.css`,"./styles/tokens.css":`./src/styles/tokens.css`,"./package.json":`./package.json`},files:[`dist`,`src`],scripts:{tsgo:`tsgo --noEmit`,"build:css":`bunx @tailwindcss/cli -i src/styles/styles.css -o dist/styles.css`,build:`tsgo && bun run build:css`,release:`bunx syncular-publish`},peerDependencies:{react:`^19.0.0`,"react-dom":`^19.0.0`},dependencies:{"@base-ui/react":`^1.3.0`,"class-variance-authority":`^0.7.1`,clsx:`^2.1.1`,"lucide-react":`^1.7.0`,recharts:`^3.8.1`,"tailwind-merge":`^3.5.0`,tailwindcss:`^4.2.2`},devDependencies:{"@syncular/config":`workspace:*`,"@tailwindcss/cli":`^4.2.2`,"@types/react":`^19.2.14`}}.version;function aZ({label:e,className:t}){return(0,G.jsxs)(`div`,{className:Y(`flex items-center gap-3`,t),children:[(0,G.jsx)(rZ,{color:`healthy`,size:`md`,glow:!0}),(0,G.jsx)(`span`,{className:`font-display font-bold text-white text-sm tracking-tight`,children:`syncular`}),e&&(0,G.jsx)(`span`,{className:`font-mono text-[9px] text-neutral-600 uppercase tracking-widest`,children:e}),(0,G.jsxs)(`span`,{className:`font-mono text-[9px] text-neutral-600 tracking-wider`,children:[`v`,iZ]})]})}function oZ({brand:e,center:t,right:n,className:r}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{"aria-hidden":`true`,className:`h-[42px] shrink-0`}),(0,G.jsxs)(`nav`,{className:Y(`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`,r),children:[(0,G.jsx)(`div`,{className:`flex items-center gap-3`,children:e}),(0,G.jsx)(`div`,{className:`flex items-center gap-0.5`,children:t}),(0,G.jsx)(`div`,{className:`flex items-center gap-2`,children:n})]})]})}var sZ=kR(`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`}}),cZ=(0,W.forwardRef)(({className:e,variant:t,...n},r)=>(0,G.jsx)(`div`,{ref:r,role:`alert`,className:Y(sZ({variant:t,className:e})),...n}));cZ.displayName=`Alert`;var lZ=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(`h5`,{ref:n,className:Y(`font-medium text-white mb-1`,e),...t}));lZ.displayName=`AlertTitle`;var uZ=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(`p`,{ref:n,className:Y(`text-neutral-400`,e),...t}));uZ.displayName=`AlertDescription`;var dZ=W.createContext(void 0);function fZ(e){let t=W.useContext(dZ);if(e===!1&&t===void 0)throw Error(QR(27));return t}var pZ={...qq,...YK},mZ=W.forwardRef(function(e,t){let{render:n,className:r,forceRender:i=!1,...a}=e,{store:o}=fZ(),s=o.useState(`open`),c=o.useState(`nested`),l=o.useState(`mounted`);return Sz(`div`,e,{state:{open:s,transitionStatus:o.useState(`transitionStatus`)},ref:[o.context.backdropRef,t],stateAttributesMapping:pZ,props:[{role:`presentation`,hidden:!l,style:{userSelect:`none`,WebkitUserSelect:`none`}},a],enabled:i||!c})}),hZ=W.forwardRef(function(e,t){let{render:n,className:r,id:i,...a}=e,{store:o}=fZ(),s=Mz(i);return o.useSyncedValueWithCleanup(`descriptionElementId`,s),Sz(`p`,e,{ref:t,props:[{id:s},a]})}),gZ=function(e){return e.nestedDialogs=`--nested-dialogs`,e}({}),_Z=function(e){return e[e.open=Rq.open]=`open`,e[e.closed=Rq.closed]=`closed`,e[e.startingStyle=Rq.startingStyle]=`startingStyle`,e[e.endingStyle=Rq.endingStyle]=`endingStyle`,e.nested=`data-nested`,e.nestedDialogOpen=`data-nested-dialog-open`,e}({}),vZ=W.createContext(void 0);function yZ(){let e=W.useContext(vZ);if(e===void 0)throw Error(QR(26));return e}var bZ={...qq,...YK,nestedDialogOpen(e){return e?{[_Z.nestedDialogOpen]:``}:null}},xZ=W.forwardRef(function(e,t){let{className:n,finalFocus:r,initialFocus:i,render:a,...o}=e,{store:s}=fZ(),c=s.useState(`descriptionElementId`),l=s.useState(`disablePointerDismissal`),u=s.useState(`floatingRootContext`),d=s.useState(`popupProps`),f=s.useState(`modal`),p=s.useState(`mounted`),m=s.useState(`nested`),h=s.useState(`nestedOpenDialogCount`),g=s.useState(`open`),_=s.useState(`openMethod`),v=s.useState(`titleElementId`),y=s.useState(`transitionStatus`),b=s.useState(`role`);yZ(),ZK({open:g,ref:s.context.popupRef,onComplete(){g&&s.context.onOpenChangeComplete?.(!0)}});function x(e){return e===`touch`?s.context.popupRef.current:!0}let S=i===void 0?x:i,C=Sz(`div`,e,{state:{open:g,nested:m,transitionStatus:y,nestedDialogOpen:h>0},props:[d,{"aria-labelledby":v??void 0,"aria-describedby":c??void 0,role:b,tabIndex:-1,hidden:!p,onKeyDown(e){cX.has(e.key)&&e.stopPropagation()},style:{[gZ.nestedDialogs]:h}},o],ref:[t,s.context.popupRef,s.useStateSetter(`popupElement`)],stateAttributesMapping:bZ});return(0,G.jsx)(vG,{context:u,openInteractionType:_,disabled:!p,closeOnFocusOut:!l,initialFocus:S,returnFocus:r,modal:f!==!1,restoreFocus:`popup`,children:C})}),SZ=W.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i}=fZ(),a=i.useState(`mounted`),o=i.useState(`modal`),s=i.useState(`open`);return a||n?(0,G.jsx)(vZ.Provider,{value:n,children:(0,G.jsxs)(nG,{ref:t,...r,children:[a&&o===!0&&(0,G.jsx)(VY,{ref:i.context.internalBackdropRef,inert:vJ(!s)}),e.children]})}):null});function CZ(e){let{store:t,parentContext:n,actionsRef:r}=e,i=t.useState(`open`),a=t.useState(`disablePointerDismissal`),o=t.useState(`modal`),s=t.useState(`popupElement`),{openMethod:c,triggerProps:l}=mY(i);eq(t);let{forceUnmount:u}=tq(i,t),d=X(e=>{let n=UB(e);return n.preventUnmountOnClose=()=>{t.set(`preventUnmountingOnClose`,!0)},n}),f=W.useCallback(()=>{t.setOpen(!1,d(VB))},[t,d]);W.useImperativeHandle(r,()=>({unmount:u,close:f}),[u,f]);let p=lq({popupStore:t,onOpenChange:t.setOpen,treatPopupAsFloatingElement:!0,noEmit:!0}),[m,h]=W.useState(0),g=m===0,_=Tq(p),v=TG(p,{outsidePressEvent(){return t.context.internalBackdropRef.current||t.context.backdropRef.current?`intentional`:{mouse:o===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}},outsidePress(e){if(!t.context.outsidePressEnabledRef.current||`button`in e&&e.button!==0||`touches`in e&&e.touches.length!==1)return!1;let n=BH(e);if(g&&!a){let e=n;return o&&(t.context.internalBackdropRef.current||t.context.backdropRef.current)?t.context.internalBackdropRef.current===e||t.context.backdropRef.current===e||RH(e,s)&&!e?.hasAttribute(`data-base-ui-portal`):!0}return!1},escapeKey:g});MY(i&&o===!0,s);let{getReferenceProps:y,getFloatingProps:b,getTriggerProps:x}=xq([_,v]);t.useContextCallback(`onNestedDialogOpen`,e=>{h(e+1)}),t.useContextCallback(`onNestedDialogClose`,()=>{h(0)}),W.useEffect(()=>(n?.onNestedDialogOpen&&i&&n.onNestedDialogOpen(m),n?.onNestedDialogClose&&!i&&n.onNestedDialogClose(),()=>{n?.onNestedDialogClose&&i&&n.onNestedDialogClose()}),[i,n,m]);let S=W.useMemo(()=>y(l),[y,l]),C=W.useMemo(()=>x(l),[x,l]),w=W.useMemo(()=>b(),[b]);t.useSyncedValues({openMethod:c,activeTriggerProps:S,inactiveTriggerProps:C,popupProps:w,floatingRootContext:p,nestedOpenDialogCount:m})}var wZ={...oq,modal:$(e=>e.modal),nested:$(e=>e.nested),nestedOpenDialogCount:$(e=>e.nestedOpenDialogCount),disablePointerDismissal:$(e=>e.disablePointerDismissal),openMethod:$(e=>e.openMethod),descriptionElementId:$(e=>e.descriptionElementId),titleElementId:$(e=>e.titleElementId),viewportElement:$(e=>e.viewportElement),role:$(e=>e.role)},TZ=class extends HK{constructor(e){super(EZ(e),{popupRef:W.createRef(),backdropRef:W.createRef(),internalBackdropRef:W.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:new nq,onOpenChange:void 0,onOpenChangeComplete:void 0},wZ)}setOpen=(e,t)=>{if(t.preventUnmountOnClose=()=>{this.set(`preventUnmountingOnClose`,!0)},!e&&t.trigger==null&&this.state.activeTriggerId!=null&&(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;let n={open:e,nativeEvent:t.event,reason:t.reason,nested:this.state.nested};this.state.floatingRootContext.context.events?.emit(`openchange`,n);let r={open:e},i=t.trigger?.id??null;(i||e)&&(r.activeTriggerId=i,r.activeTriggerElement=t.trigger??null),this.update(r)}};function EZ(e={}){return{...iq(),modal:!0,disablePointerDismissal:!1,popupElement:null,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,role:`dialog`,...e}}function DZ(e){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,disablePointerDismissal:o=!1,modal:s=!0,actionsRef:c,handle:l,triggerId:u,defaultTriggerId:d=null}=e,f=fZ(!0),p=!!f,m=PR(()=>l?.store??new TZ({open:r,openProp:n,activeTriggerId:d,triggerIdProp:u,modal:s,disablePointerDismissal:o,nested:p})).current;mH(()=>{n===void 0&&m.state.open===!1&&r===!0&&m.update({open:!0,activeTriggerId:d})}),m.useControlledProp(`openProp`,n),m.useControlledProp(`triggerIdProp`,u),m.useSyncedValues({disablePointerDismissal:o,nested:p,modal:s}),m.useContextCallback(`onOpenChange`,i),m.useContextCallback(`onOpenChangeComplete`,a);let h=m.useState(`payload`);CZ({store:m,actionsRef:c,parentContext:f?.store.context,onOpenChange:i,triggerIdProp:u});let g=W.useMemo(()=>({store:m}),[m]);return(0,G.jsx)(dZ.Provider,{value:g,children:typeof t==`function`?t({payload:h}):t})}var OZ=W.forwardRef(function(e,t){let{render:n,className:r,id:i,...a}=e,{store:o}=fZ(),s=Mz(i);return o.useSyncedValueWithCleanup(`titleElementId`,s),Sz(`h2`,e,{ref:t,props:[{id:s},a]})}),kZ=DZ,AZ=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(mZ,{ref:n,className:Y(`fixed inset-0 z-50 bg-black/60 backdrop-blur-sm`,e),...t}));AZ.displayName=`DialogOverlay`;var jZ=(0,W.forwardRef)(({className:e,children:t,...n},r)=>(0,G.jsxs)(SZ,{children:[(0,G.jsx)(mZ,{className:`fixed inset-0 z-50 bg-black/60 backdrop-blur-sm`}),(0,G.jsx)(xZ,{ref:r,className:Y(`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})]}));jZ.displayName=`DialogContent`;var MZ=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(`div`,{ref:n,className:Y(`px-5 py-3 border-b border-border`,e),...t}));MZ.displayName=`DialogHeader`;var NZ=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(`div`,{ref:n,className:Y(`px-5 py-3 border-t border-border flex justify-end gap-2`,e),...t}));NZ.displayName=`DialogFooter`;var PZ=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(OZ,{ref:n,className:Y(`font-mono text-[10px] text-neutral-500 uppercase tracking-widest`,e),...t}));PZ.displayName=`DialogTitle`;var FZ=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(hZ,{ref:n,className:Y(`font-mono text-[10px] text-neutral-500`,e),...t}));FZ.displayName=`DialogDescription`;var IZ=(0,W.forwardRef)(({className:e,page:t,totalPages:n,totalItems:r,onPageChange:i,...a},o)=>(0,G.jsxs)(`div`,{ref:o,className:Y(`px-5 py-2.5 border-t border-border flex items-center justify-between`,e),...a,children:[(0,G.jsxs)(`span`,{className:`font-mono text-[10px] text-neutral-600`,children:[r,` items · Page `,t,` of `,n]}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(Q,{size:`sm`,variant:`default`,disabled:t<=1,onClick:()=>i(t-1),children:`Prev`}),(0,G.jsx)(Q,{size:`sm`,variant:`default`,disabled:t>=n,onClick:()=>i(t+1),children:`Next`})]})]}));IZ.displayName=`Pagination`;var LZ=(0,W.forwardRef)(({className:e,orientation:t=`horizontal`,...n},r)=>(0,G.jsx)(`hr`,{ref:r,"aria-orientation":t===`vertical`?`vertical`:void 0,className:Y(`border-none m-0`,t===`horizontal`?`h-px w-full bg-border`:`w-px h-4 bg-border`,e),...n}));LZ.displayName=`Separator`;var RZ=kR(`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=(0,W.forwardRef)(({className:e,side:t,children:n,...r},i)=>(0,G.jsxs)(SZ,{children:[(0,G.jsx)(mZ,{className:`fixed inset-0 z-50 bg-black/60 backdrop-blur-sm`}),(0,G.jsx)(xZ,{ref:i,className:Y(RZ({side:t,className:e})),...r,children:n})]}));zZ.displayName=`SheetContent`;var BZ=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(`div`,{ref:n,className:Y(`px-5 py-3 border-b border-border`,e),...t}));BZ.displayName=`SheetHeader`;var VZ=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(`div`,{ref:n,className:Y(`px-5 py-3 border-t border-border flex justify-end gap-2`,e),...t}));VZ.displayName=`SheetFooter`;var HZ=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(OZ,{ref:n,className:Y(`font-mono text-[10px] text-neutral-500 uppercase tracking-widest`,e),...t}));HZ.displayName=`SheetTitle`;var UZ=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(hZ,{ref:n,className:Y(`text-sm text-neutral-400`,e),...t}));UZ.displayName=`SheetDescription`;var WZ=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(`div`,{ref:n,className:Y(`rounded-md bg-neutral-800 animate-pulse`,e),...t}));WZ.displayName=`Skeleton`;var GZ=W.createContext(void 0);function KZ(){let e=W.useContext(GZ);if(e===void 0)throw Error(QR(64));return e}var qZ=function(e){return e.activationDirection=`data-activation-direction`,e.orientation=`data-orientation`,e}({}),JZ={tabActivationDirection:e=>({[qZ.activationDirection]:e})},YZ=W.createContext(void 0);function XZ(){let e=W.useContext(YZ);if(e===void 0)throw Error(QR(65));return e}var ZZ=W.forwardRef(function(e,t){let{className:n,disabled:r=!1,render:i,value:a,id:o,nativeButton:s=!0,...c}=e,{value:l,getTabPanelIdByValue:u,orientation:d}=KZ(),{activateOnFocus:f,highlightedTabIndex:p,onTabActivation:m,registerTabResizeObserverElement:h,setHighlightedTabIndex:g,tabsListElement:_}=XZ(),v=Mz(o),{compositeProps:y,compositeRef:b,index:x}=RX({metadata:W.useMemo(()=>({disabled:r,id:v,value:a}),[r,v,a])}),S=a===l,C=W.useRef(!1),w=W.useRef(null);W.useEffect(()=>{let e=w.current;if(e)return h(e)},[h]),Z(()=>{if(C.current){C.current=!1;return}if(!(S&&x>-1&&p!==x))return;let e=_;if(e!=null){let t=LH(gW(e));if(t&&RH(e,t))return}r||g(x)},[S,x,p,g,r,_]);let{getButtonProps:T,buttonRef:E}=sB({disabled:r,native:s,focusableWhenDisabled:!0}),D=u(a),O=W.useRef(!1),k=W.useRef(!1);function A(e){S||r||m(a,UB(jB,e.nativeEvent,void 0,{activationDirection:`none`}))}function j(e){S||(x>-1&&!r&&g(x),!r&&f&&(!O.current||O.current&&k.current)&&m(a,UB(jB,e.nativeEvent,void 0,{activationDirection:`none`})))}function M(e){if(S||r)return;O.current=!0;function t(){O.current=!1,k.current=!1}(!e.button||e.button===0)&&(k.current=!0,gW(e.currentTarget).addEventListener(`pointerup`,t,{once:!0}))}return Sz(`button`,e,{state:{disabled:r,active:S,orientation:d},ref:[t,E,b,w],props:[y,{role:`tab`,"aria-controls":D,"aria-selected":S,id:v,onClick:A,onFocus:j,onPointerDown:M,[UX]:S?``:void 0,onKeyDownCapture(){C.current=!0}},c,T]})}),QZ=function(e){return e.index=`data-index`,e.activationDirection=`data-activation-direction`,e.orientation=`data-orientation`,e.hidden=`data-hidden`,e[e.startingStyle=KK.startingStyle]=`startingStyle`,e[e.endingStyle=KK.endingStyle]=`endingStyle`,e}({}),$Z={...JZ,...YK},eQ=W.forwardRef(function(e,t){let{className:n,value:r,render:i,keepMounted:a=!1,...o}=e,{value:s,getTabIdByPanelValue:c,orientation:l,tabActivationDirection:u,registerMountedTabPanel:d,unregisterMountedTabPanel:f}=KZ(),p=Mz(),{ref:m,index:h}=kX({metadata:W.useMemo(()=>({id:p,value:r}),[p,r])}),g=r===s,{mounted:_,transitionStatus:v,setMounted:y}=GK(g),b=!_,x=c(r),S={hidden:b,orientation:l,tabActivationDirection:u,transitionStatus:v},C=W.useRef(null),w=Sz(`div`,e,{state:S,ref:[t,m,C],props:[{"aria-labelledby":x,hidden:b,id:p,role:`tabpanel`,tabIndex:g?0:-1,inert:vJ(!g),[QZ.index]:h},o],stateAttributesMapping:$Z});return ZK({open:g,ref:C,onComplete(){g||y(!1)}}),Z(()=>{if(!(b&&!a)&&p!=null)return d(r,p),()=>{f(r,p)}},[b,a,r,p,d,f]),a||_?w:null}),tQ=W.forwardRef(function(e,t){let{activateOnFocus:n=!1,className:r,loopFocus:i=!0,render:a,...o}=e,{getTabElementBySelectedValue:s,onValueChange:c,orientation:l,value:u,setTabMap:d,tabActivationDirection:f}=KZ(),[p,m]=W.useState(0),[h,g]=W.useState(null),_=W.useRef(new Set),v=W.useRef(new Set),y=W.useRef(null),b=X(()=>{_.current.forEach(e=>{e()})});W.useEffect(()=>{if(typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>{_.current.size&&b()});return y.current=e,h&&e.observe(h),v.current.forEach(t=>{e.observe(t)}),()=>{e.disconnect(),y.current=null}},[h,b]);let x=X(e=>(_.current.add(e),()=>{_.current.delete(e)})),S=X(e=>(v.current.add(e),y.current?.observe(e),()=>{v.current.delete(e),y.current?.unobserve(e)})),C=rQ(u,l,h,s),w=X((e,t)=>{e!==u&&(t.activationDirection=C(e),c(e,t))}),T={orientation:l,tabActivationDirection:f},E={"aria-orientation":l===`vertical`?`vertical`:void 0,role:`tablist`},D=W.useMemo(()=>({activateOnFocus:n,highlightedTabIndex:p,registerIndicatorUpdateListener:x,registerTabResizeObserverElement:S,onTabActivation:w,setHighlightedTabIndex:m,tabsListElement:h}),[n,p,x,S,w,m,h]);return(0,G.jsx)(YZ.Provider,{value:D,children:(0,G.jsx)(qX,{render:a,className:r,state:T,refs:[t,g],props:[E,o],stateAttributesMapping:JZ,highlightedIndex:p,enableHomeAndEndKeys:!0,loopFocus:i,orientation:l,onHighlightedIndexChange:m,onMapChange:d,disabledIndices:YR})})});function nQ(e,t){let{left:n,top:r}=e.getBoundingClientRect(),{left:i,top:a}=t.getBoundingClientRect();return{left:n-i,top:r-a}}function rQ(e,t,n,r){let[i,a]=W.useState(null);return Z(()=>{if(e==null||n==null){a(null);return}let i=r(e);if(i==null){a(null);return}let{left:o,top:s}=nQ(i,n);a(t===`horizontal`?o:s)},[t,r,n,e]),W.useCallback(o=>{if(o===e)return`none`;if(o==null)return a(null),`none`;if(o!=null&&n!=null){let e=r(o);if(e!=null){let{left:r,top:o}=nQ(e,n);if(i==null)return a(t===`horizontal`?r:o),`none`;if(t===`horizontal`){if(r<i)return a(r),`left`;if(r>i)return a(r),`right`}else if(o<i)return a(o),`up`;else if(o>i)return a(o),`down`}}return`none`},[r,t,i,n,e])}var iQ=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(tQ,{ref:n,className:Y(`flex items-center gap-0.5`,e),...t}));iQ.displayName=`TabsList`;var aQ=kR(`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`}}),oQ=(0,W.forwardRef)(({className:e,variant:t,...n},r)=>(0,G.jsx)(ZZ,{ref:r,className:Y(aQ({variant:t,className:e})),...n}));oQ.displayName=`TabsTrigger`;var sQ=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(eQ,{ref:n,className:Y(`outline-none`,e),...t}));sQ.displayName=`TabsContent`;var cQ=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(`p`,{ref:n,className:Y(`font-mono text-[11px] text-neutral-300`,e),...t}));cQ.displayName=`Text`;var lQ=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(`p`,{ref:n,className:Y(`font-mono text-[10px] text-neutral-500`,e),...t}));lQ.displayName=`TextMuted`;var uQ=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(`code`,{ref:n,className:Y(`font-mono text-[11px] text-white`,e),...t}));uQ.displayName=`TextCode`;var dQ=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(`span`,{ref:n,className:Y(`font-mono text-[9px] uppercase tracking-wider text-neutral-500`,e),...t}));dQ.displayName=`TextLabel`;var fQ=(0,W.forwardRef)(({className:e,...t},n)=>(0,G.jsx)(`pre`,{ref:n,className:Y(`font-mono text-[11px] text-neutral-300 p-3 rounded border border-border bg-panel-alt overflow-x-auto`,e),...t}));fQ.displayName=`CodeBlock`;function pQ(e,t){let[n,r]=(0,W.useState)(()=>{if(typeof window>`u`)return t;try{let n=window.localStorage.getItem(e);return n===null?t:JSON.parse(n)}catch{return t}});return(0,W.useEffect)(()=>{try{n==null?window.localStorage.removeItem(e):window.localStorage.setItem(e,JSON.stringify(n))}catch{}},[e,n]),[n,(0,W.useCallback)(e=>{r(t=>typeof e==`function`?e(t):e)},[])]}var mQ=`console:instance-id`;function hQ(){let[e,t]=pQ(mQ,``),n=e.trim();return(0,W.useMemo)(()=>({instanceId:n.length>0?n:void 0,rawInstanceId:e,setInstanceId:t,clearInstanceId:()=>t(``)}),[n,e,t])}var gQ={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 _Q(e,t){return e===0?!1:e??t}function vQ(e){let t=new URLSearchParams;if(!e)return t;for(let[n,r]of Object.entries(e))r!=null&&t.set(n,String(r));return t}function yQ(e,t,n){let r=e.endsWith(`/`)?e.slice(0,-1):e,i=vQ(n)?.toString();return`${r}${t}${i?`?${i}`:``}`}function bQ(e,t){if(!t||!e)throw Error(`Not connected`);return e}async function xQ(e){let t={Authorization:`Bearer ${e.connectionConfig.token}`};e.body!==void 0&&(t[`Content-Type`]=`application/json`);let n=await fetch(yQ(e.connectionConfig.serverUrl,e.path,e.query),{method:e.method??`GET`,headers:t,body:e.body===void 0?void 0:JSON.stringify(e.body)});if(!n.ok)throw Error(e.errorMessage);return n.json()}async function SQ(e){let t=await fetch(yQ(e.connectionConfig.serverUrl,e.path,e.query),{method:`GET`,headers:{Authorization:`Bearer ${e.connectionConfig.token}`}});if(!t.ok)throw Error(e.errorMessage);return t.blob()}function CQ(e){let{config:t,isConnected:n}=Py();return ah({queryKey:e.queryKey,queryFn:()=>xQ({connectionConfig:bQ(t,n),path:e.path,query:e.query,method:e.method,errorMessage:e.errorMessage}),enabled:(e.enabled??!0)&&n&&!!t,refetchInterval:e.refetchInterval})}function wQ(e){let{config:t,isConnected:n}=Py();return ah({queryKey:e.queryKey,queryFn:()=>{if(e.id===void 0)throw Error(e.requiredMessage);return xQ({connectionConfig:bQ(t,n),path:e.path(e.id),query:e.query,errorMessage:e.errorMessage})},enabled:(e.enabled??!0)&&e.id!==void 0&&n&&!!t})}function TQ(e,t){for(let n of t)e.invalidateQueries({queryKey:n})}function EQ(e){let{instanceId:t}=hQ();return e??t}function DQ(e){let{config:t,isConnected:n}=Py(),{instanceId:r}=hQ(),i=Wm();return oh({mutationFn:i=>e.mutationFn({connectionConfig:bQ(t,n),variables:i,selectedInstanceId:r}),onSuccess:()=>{e.invalidateQueryKeys&&TQ(i,e.invalidateQueryKeys)}})}function OQ(e={}){let t=EQ(e.instanceId);return CQ({queryKey:gQ.stats({partitionId:e.partitionId,instanceId:t}),path:`/console/stats`,query:{partitionId:e.partitionId,instanceId:t},errorMessage:`Failed to fetch stats`,refetchInterval:_Q(e.refetchIntervalMs,5e3)})}function kQ(e={},t={}){let n=EQ(e.instanceId);return CQ({queryKey:gQ.timeseries({...e,instanceId:n}),path:`/console/stats/timeseries`,query:{interval:e.interval,range:e.range,partitionId:e.partitionId,instanceId:n},errorMessage:`Failed to fetch timeseries stats`,enabled:t.enabled,refetchInterval:_Q(t.refetchIntervalMs,3e4)})}function AQ(e={},t={}){let n=EQ(e.instanceId);return CQ({queryKey:gQ.latency({...e,instanceId:n}),path:`/console/stats/latency`,query:{range:e.range,partitionId:e.partitionId,instanceId:n},errorMessage:`Failed to fetch latency stats`,enabled:t.enabled,refetchInterval:_Q(t.refetchIntervalMs,3e4)})}function jQ(e={},t={}){let n=EQ(e.instanceId);return CQ({queryKey:gQ.commits({...e,instanceId:n}),path:`/console/commits`,query:{limit:e.limit,offset:e.offset,partitionId:e.partitionId,instanceId:n},errorMessage:`Failed to fetch commits`,enabled:t.enabled,refetchInterval:_Q(t.refetchIntervalMs,1e4)})}function MQ(e,t={}){let n=EQ(t.instanceId);return wQ({queryKey:gQ.commitDetail(e,t.partitionId,n),id:e,requiredMessage:`Commit sequence is required`,path:e=>`/console/commits/${encodeURIComponent(String(e))}`,query:{partitionId:t.partitionId,instanceId:n},errorMessage:`Failed to fetch commit detail`,enabled:t.enabled})}function NQ(e={},t={}){let n=EQ(e.instanceId);return CQ({queryKey:gQ.timeline({...e,instanceId:n}),path:`/console/timeline`,query:{limit:e.limit,offset:e.offset,partitionId:e.partitionId,view:e.view,eventType:e.eventType,actorId:e.actorId,clientId:e.clientId,requestId:e.requestId,traceId:e.traceId,table:e.table,outcome:e.outcome,search:e.search,from:e.from,to:e.to,instanceId:n},errorMessage:`Failed to fetch timeline`,enabled:t.enabled,refetchInterval:_Q(t.refetchIntervalMs,1e4)})}function PQ(e={},t={}){let n=EQ(e.instanceId);return CQ({queryKey:gQ.clients({...e,instanceId:n}),path:`/console/clients`,query:{limit:e.limit,offset:e.offset,partitionId:e.partitionId,instanceId:n},errorMessage:`Failed to fetch clients`,enabled:t.enabled,refetchInterval:_Q(t.refetchIntervalMs,1e4)})}function FQ(e,t={}){let n=EQ(t.instanceId);return wQ({queryKey:gQ.eventDetail(e,t.partitionId,n),id:e,requiredMessage:`Event id is required`,path:e=>`/console/events/${encodeURIComponent(String(e))}`,query:{partitionId:t.partitionId,instanceId:n},errorMessage:`Failed to fetch event detail`,enabled:t.enabled})}function IQ(e,t={}){let n=EQ(t.instanceId);return wQ({queryKey:gQ.eventPayload(e,t.partitionId,n),id:e,requiredMessage:`Event id is required`,path:e=>`/console/events/${encodeURIComponent(String(e))}/payload`,query:{partitionId:t.partitionId,instanceId:n},errorMessage:`Failed to fetch event payload`,enabled:t.enabled})}function LQ(e={}){let t=EQ(e.instanceId);return CQ({queryKey:gQ.handlers(t),path:`/console/handlers`,query:{instanceId:t},errorMessage:`Failed to fetch handlers`})}function RQ(e={}){let t=EQ(e.instanceId);return CQ({queryKey:gQ.prunePreview(t),path:`/console/prune/preview`,query:{instanceId:t},method:`POST`,errorMessage:`Failed to fetch prune preview`,enabled:e.enabled})}function zQ(e={},t={}){let n=EQ(e.instanceId);return CQ({queryKey:gQ.operations({...e,instanceId:n}),path:`/console/operations`,query:{limit:e.limit,offset:e.offset,operationType:e.operationType,partitionId:e.partitionId,instanceId:n},errorMessage:`Failed to fetch operations`,enabled:t.enabled,refetchInterval:_Q(t.refetchIntervalMs,1e4)})}function BQ(){return DQ({mutationFn:async({connectionConfig:e,selectedInstanceId:t})=>xQ({connectionConfig:e,path:`/console/events`,query:{instanceId:t},method:`DELETE`,errorMessage:`Failed to clear events`}),invalidateQueryKeys:[[`console`,`events`]]})}function VQ(){return DQ({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>{let r=t.instanceId??n;return xQ({connectionConfig:e,path:`/console/clients/${encodeURIComponent(t.clientId)}`,query:{partitionId:t.partitionId,instanceId:r},method:`DELETE`,errorMessage:`Failed to evict client`})},invalidateQueryKeys:[[`console`,`clients`],[`console`,`stats`],[`console`,`operations`]]})}function HQ(){return DQ({mutationFn:async({connectionConfig:e,selectedInstanceId:t})=>xQ({connectionConfig:e,path:`/console/prune`,query:{instanceId:t},method:`POST`,errorMessage:`Failed to prune`}),invalidateQueryKeys:[[`console`,`stats`],[`console`,`commits`],[`console`,`timeline`],[`console`,`prune`,`preview`],[`console`,`operations`]]})}function UQ(){return DQ({mutationFn:async({connectionConfig:e,selectedInstanceId:t})=>xQ({connectionConfig:e,path:`/console/compact`,query:{instanceId:t},method:`POST`,errorMessage:`Failed to compact`}),invalidateQueryKeys:[[`console`,`stats`],[`console`,`operations`]]})}function WQ(){return DQ({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>xQ({connectionConfig:e,path:`/console/notify-data-change`,query:{instanceId:t.instanceId??n},method:`POST`,body:{tables:t.tables,partitionId:t.partitionId},errorMessage:`Failed to notify data change`}),invalidateQueryKeys:[[`console`,`stats`],[`console`,`commits`],[`console`,`timeline`],[`console`,`operations`]]})}function GQ(e={}){let t=EQ(e.instanceId);return CQ({queryKey:gQ.apiKeys({...e,instanceId:t}),path:`/console/api-keys`,query:{limit:e.limit,offset:e.offset,type:e.type,status:e.status,expiresWithinDays:e.expiresWithinDays,instanceId:t},errorMessage:`Failed to fetch API keys`})}function KQ(){return DQ({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>xQ({connectionConfig:e,path:`/console/api-keys`,query:{instanceId:n},method:`POST`,body:t,errorMessage:`Failed to create API key`}),invalidateQueryKeys:[[`console`,`api-keys`]]})}function qQ(){return DQ({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>xQ({connectionConfig:e,path:`/console/api-keys/${encodeURIComponent(t)}`,query:{instanceId:n},method:`DELETE`,errorMessage:`Failed to revoke API key`}),invalidateQueryKeys:[[`console`,`api-keys`]]})}function JQ(){return DQ({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>xQ({connectionConfig:e,path:`/console/api-keys/bulk-revoke`,query:{instanceId:n},method:`POST`,body:t,errorMessage:`Failed to bulk revoke API keys`}),invalidateQueryKeys:[[`console`,`api-keys`]]})}function YQ(){return DQ({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>xQ({connectionConfig:e,path:`/console/api-keys/${encodeURIComponent(t)}/rotate`,query:{instanceId:n},method:`POST`,errorMessage:`Failed to rotate API key`}),invalidateQueryKeys:[[`console`,`api-keys`]]})}function XQ(){return DQ({mutationFn:async({connectionConfig:e,variables:t,selectedInstanceId:n})=>xQ({connectionConfig:e,path:`/console/api-keys/${encodeURIComponent(t)}/rotate/stage`,query:{instanceId:n},method:`POST`,errorMessage:`Failed to stage-rotate API key`}),invalidateQueryKeys:[[`console`,`api-keys`]]})}function ZQ(e={}){return CQ({queryKey:gQ.storage({prefix:e.prefix,cursor:e.cursor,limit:e.limit}),path:`/console/storage`,query:{prefix:e.prefix,cursor:e.cursor,limit:e.limit},errorMessage:`Failed to list blobs`,refetchInterval:_Q(e.refetchIntervalMs,3e4)})}function QQ(){return DQ({mutationFn:async({connectionConfig:e,variables:t})=>xQ({connectionConfig:e,path:`/console/storage/${encodeURIComponent(t)}`,method:`DELETE`,errorMessage:`Failed to delete blob`}),invalidateQueryKeys:[[`console`,`storage`]]})}function $Q(){let{config:e,isConnected:t}=Py();return async n=>{let r=await SQ({connectionConfig:bQ(e,t),path:`/console/storage/${encodeURIComponent(n)}/download`,errorMessage:`Failed to download blob`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=n.split(`/`).pop()||n,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}}var e$=`console:partition-id`;function t$(){let[e,t]=pQ(e$,``),n=e.trim();return(0,W.useMemo)(()=>({partitionId:n.length>0?n:void 0,rawPartitionId:e,setPartitionId:t,clearPartitionId:()=>t(``)}),[n,e,t])}var n$={refreshInterval:5,timeFormat:`relative`,showSparklines:!0,pageSize:20};function r$(){let[e,t]=pQ(`console:preferences`,n$);return{preferences:e,setPreferences:t,updatePreference:(e,n)=>{t(t=>({...t,[e]:n}))},resetPreferences:()=>{t(n$)}}}var i$=[{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`}],a$=[{value:10,label:`10`},{value:20,label:`20`},{value:50,label:`50`},{value:100,label:`100`}],o$=`syncular-console-root`;function s$(e){e.classList.add(o$)}var c$=[{suffix:``,label:`Command`},{suffix:`/stream`,label:`Stream`},{suffix:`/fleet`,label:`Fleet`},{suffix:`/ops`,label:`Ops`},{suffix:`/storage`,label:`Storage`},{suffix:`/config`,label:`Config`}];function l$(e){let t=e?.trim()??``;return!t||t===`/`?``:(t.startsWith(`/`)?t:`/${t}`).replace(/\/+$/g,``)}function u$(e,t){return e?t?`${e}${t}`:e:t||`/`}function d$({basePath:e,appHref:t,modeBadge:n}){let{connect:r,config:i,isConnected:a,isConnecting:o}=Py(),{preferences:s}=r$(),{instanceId:c,rawInstanceId:l,setInstanceId:u,clearInstanceId:d}=hQ(),{partitionId:f,rawPartitionId:p,setPartitionId:m,clearPartitionId:h}=t$(),g=cy({select:e=>e.location.pathname}),{data:_}=OQ({refetchIntervalMs:s.refreshInterval*1e3,partitionId:f,instanceId:c}),v=l$(e),y=(0,W.useMemo)(()=>c$.map(e=>({...e,id:u$(v,e.suffix)})),[v]),b=u$(v,``),x=u$(v,`/config`),S=o?`connecting`:a?`connected`:i?`disconnected`:`not-configured`,C=y.find(e=>e.suffix===``?g===b||g===`${b}/`:g.startsWith(e.id))?.id??b,w=_?[{label:`HEAD`,value:`#${_.maxCommitSeq}`},{label:`COMMITS`,value:`${_.commitCount}`},{label:`CHANGES`,value:`${_.changeCount}`},{label:`CLIENTS`,value:`${_.activeClientCount}/${_.clientCount}`}]:[];return(0,G.jsxs)(`div`,{className:`${o$} h-screen bg-background text-foreground flex flex-col`,children:[(0,G.jsx)(oZ,{brand:(0,G.jsx)(zv,{to:b,children:(0,G.jsx)(aZ,{label:`console`})}),center:(0,G.jsx)(eZ,{items:y,activeId:C,renderItem:(e,{active:t})=>(0,G.jsx)(zv,{to:e.id,children:(0,G.jsx)($X,{active:t,children:e.label})},e.id)}),right:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?(0,G.jsx)(ZB,{variant:`flow`,className:`hidden md:inline-flex px-2 py-1 text-[10px]`,children:n}):null,(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`span`,{className:`font-mono text-[9px] text-neutral-500 uppercase tracking-wide`,children:`Instance`}),(0,G.jsx)(jR,{variant:`mono`,value:l,onChange:e=>u(e.target.value),onBlur:e=>u(e.target.value.trim()),placeholder:`all`,className:`h-7 w-[110px] px-2 py-1`}),c?(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-[10px]`,onClick:d,children:`All`}):null]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`span`,{className:`font-mono text-[9px] text-neutral-500 uppercase tracking-wide`,children:`Partition`}),(0,G.jsx)(jR,{variant:`mono`,value:p,onChange:e=>m(e.target.value),onBlur:e=>m(e.target.value.trim()),placeholder:`all`,className:`h-7 w-[110px] px-2 py-1`}),f?(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-[10px]`,onClick:h,children:`All`}):null]}),(0,G.jsx)(fV,{state:S}),(0,G.jsx)(zv,{to:x,children:(0,G.jsx)(Q,{variant:g===x?`secondary`:`ghost`,size:`icon`,children:(0,G.jsx)(LV,{className:`h-3 w-3`})})}),t?(0,G.jsxs)(`a`,{href:t,className:QX,children:[(0,G.jsx)(IV,{className:`h-3 w-3`}),`Go to app`]}):null]})}),(0,G.jsx)(`main`,{className:`flex-1 overflow-auto pb-[32px]`,children:(0,G.jsx)(`div`,{className:`min-h-full`,children:a||g===x?(0,G.jsx)(`div`,{style:{animation:`pageIn 0.3s ease-out`},children:(0,G.jsx)($v,{})},g):(0,G.jsx)(f$,{configPath:x,hasSavedConfig:!!i,isConnecting:o,onConnect:()=>{r()}})})}),a&&(0,G.jsx)(oV,{isLive:a,metrics:w,uptime:`--`})]})}function f$({configPath:e,hasSavedConfig:t,isConnecting:n,onConnect:r}){return(0,G.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16`,children:[(0,G.jsx)(`p`,{className:`mb-4 text-foreground-muted`,children:`Not connected to a @syncular server`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t&&(0,G.jsx)(Q,{variant:`default`,onClick:r,disabled:n,children:n?`Connecting...`:`Connect`}),(0,G.jsx)(zv,{to:e,children:(0,G.jsx)(Q,{variant:`link`,children:`Configure connection`})})]})]})}var p$=Wv({component:d$});function m$(e={}){let{maxEvents:t=100,enabled:n=!0,staleAfterMs:r=65e3,replayLimit:i=100,partitionId:a,instanceId:o}=e,{config:s,isConnected:c}=Py(),{instanceId:l}=hQ(),u=o??l,[d,f]=(0,W.useState)([]),[p,m]=(0,W.useState)(!1),[h,g]=(0,W.useState)(`disconnected`),[_,v]=(0,W.useState)(null),y=(0,W.useRef)(null),b=(0,W.useRef)(null),x=(0,W.useRef)(null),S=(0,W.useRef)(0),C=(0,W.useRef)(0),w=(0,W.useRef)(null),T=(0,W.useCallback)(()=>{f([]),w.current=null},[]);return(0,W.useEffect)(()=>{if(!n||!c||!s?.serverUrl||!s?.token)return;let e=!1,o=Number.isFinite(i)?Math.max(1,Math.min(500,Math.floor(i))):100;if(typeof WebSocket>`u`)return;let l=()=>{b.current&&=(clearTimeout(b.current),null)},d=()=>{x.current&&=(clearInterval(x.current),null)},p=()=>{if(e||b.current)return;S.current+=1;let t=Math.min(3e4,1e3*2**Math.max(0,S.current-1)),n=t+Math.floor(t*.2*Math.random());b.current=setTimeout(()=>{b.current=null,e||_()},n)},h=()=>{C.current=Date.now(),m(!0),g(`connected`)},_=()=>{if(e)return;g(`connecting`),l();let n=(()=>{let e=new URL(s.serverUrl,window.location.origin);return e.protocol=e.protocol===`https:`?`wss:`:`ws:`,e.pathname=`${e.pathname.endsWith(`/`)?e.pathname.slice(0,-1):e.pathname}/console/events/live`,e.search=``,w.current&&e.searchParams.set(`since`,w.current),e.searchParams.set(`replayLimit`,String(o)),a&&e.searchParams.set(`partitionId`,a),u&&e.searchParams.set(`instanceId`,u),e.toString()})(),i=new WebSocket(n);y.current=i,i.onopen=()=>{if(e){i.close();return}S.current=0,v(null),g(`connecting`),m(!1);try{i.send(JSON.stringify({type:`auth`,token:s.token}))}catch{i.close();return}d(),x.current=setInterval(()=>{let e=y.current;if(!e||e.readyState!==WebSocket.OPEN)return;let t=C.current;t&&(Date.now()-t<=r||(m(!1),g(`stale`),e.close()))},1e3)},i.onclose=()=>{e||(m(!1),g(`disconnected`),d(),p())},i.onerror=()=>{e||v(Error(`WebSocket connection failed`))},i.onmessage=e=>{try{let n=JSON.parse(e.data),r=n.type;if(h(),r===`connected`||r===`heartbeat`||r===`auth_required`)return;if(r===`error`){let e=typeof n.message==`string`?n.message:`Live events authentication failed`;v(Error(e));return}let i={type:r,timestamp:n.timestamp||new Date().toISOString(),data:n};if(a&&i.data.partitionId!==a||u&&i.data.instanceId!==u)return;let o=Date.parse(w.current??``),s=Date.parse(i.timestamp);Number.isFinite(s)&&(!Number.isFinite(o)||s>o)&&(w.current=i.timestamp),f(e=>[i,...e].slice(0,t))}catch{}}};return _(),()=>{e=!0,l(),d(),y.current&&=(y.current.close(),null),m(!1),g(`disconnected`)}},[n,c,s?.serverUrl,s?.token,t,a,u,i,r]),{events:d,isConnected:p,connectionState:h,error:_,clearEvents:T}}var h$=(0,W.createContext)(null);function g$(){let[e,t]=pQ(`console:time-range`,`24h`);return{range:e,setRange:t}}var _$=[{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 v$(e){let t=e.toLowerCase();for(let e of _$)if(t.includes(e.hint))return e.type;return`client`}function y$(e){let 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 b$(e,t){return typeof e.lagCommitCount==`number`?Math.max(0,e.lagCommitCount):t?Math.max(0,t.maxCommitSeq-e.cursor):0}function x$(e,t){return e.activityState===`stale`?`offline`:t>0?`syncing`:`online`}function S$(e,t){return e.length<=16?e:`${e.slice(0,12)}-${t+1}`}function C$(e,t,n={}){let r=n.maxNodes??10;return e.slice(0,r).map((e,n)=>{let r=x$(e,b$(e,t));return{id:S$(e.clientId,n),type:v$(e.clientId),status:r,cursor:Math.max(0,e.cursor),actor:e.actorId,mode:e.connectionMode,dialect:y$(e.clientId),scopes:Object.keys(e.effectiveScopes||{}),lastSeen:e.updatedAt}})}var w$={enabled:!1,thresholds:{p90Latency:500,errorRate:5,clientLag:100}};function T$(e,t=`relative`){if(t===`absolute`)return new Date(e).toLocaleString();let n=new Date(e),r=new Date().getTime()-n.getTime(),i=Math.floor(r/1e3);return i<60?`${i}s ago`:i<3600?`${Math.floor(i/60)}m ago`:i<86400?`${Math.floor(i/3600)}h ago`:`${Math.floor(i/86400)}d ago`}function E$(e){let t=e.length>1&&e.endsWith(`/`)?e.slice(0,-1):e;return t===`/console`||t.startsWith(`/console/`)?`/console/stream`:`/stream`}function D$(){let e=Tv(),t=(0,W.useMemo)(()=>typeof window>`u`?`/stream`:E$(window.location.pathname),[]),n=g$(),{range:r}=n,{preferences:i}=r$(),{partitionId:a}=t$(),o=i.refreshInterval*1e3,[s]=pQ(`console:alert-config`,w$),[c,l]=(0,W.useState)(`1h`),{data:u}=OQ({refetchIntervalMs:o,partitionId:a}),{data:d}=kQ({range:r,partitionId:a},{refetchIntervalMs:o}),{data:f}=AQ({range:r,partitionId:a},{refetchIntervalMs:o}),{data:p}=jQ({limit:5,partitionId:a},{refetchIntervalMs:o}),{data:m}=PQ({limit:12,offset:0,partitionId:a},{refetchIntervalMs:o}),{events:h,isConnected:g}=m$({maxEvents:8,partitionId:a}),_=(0,W.useMemo)(()=>{let e=d?.buckets??[],t=0,n=0;for(let r of e)t+=r.pushCount+r.pullCount,n+=r.errorCount;let r=t>0?n/t*100:0;return{totalEvents:t,errorRate:r}},[d?.buckets]),v=(0,W.useMemo)(()=>m?.items?C$(m.items,u,{maxNodes:12}):[],[m?.items,u]),y=v.filter(e=>e.status!==`offline`).length,b=v.filter(e=>e.status===`offline`).length,x=(0,W.useMemo)(()=>u?[{label:`Ops (Range)`,value:_.totalEvents,color:`flow`},{label:`P50 Latency`,value:f?.push?.p50??0,unit:`ms`,color:`healthy`},{label:`Error Rate`,value:`${_.errorRate.toFixed(1)}%`,color:_.errorRate>0?`offline`:`muted`},{label:`Active Clients`,value:u.activeClientCount,color:`syncing`},{label:`Pending`,value:u.maxActiveClientCursor!==null&&u.maxCommitSeq>0?u.maxCommitSeq-(u.minActiveClientCursor??0):0,color:`relay`}]:[],[u,f,_.errorRate,_.totalEvents]),S=(0,W.useMemo)(()=>h.map(e=>({type:e.type.toUpperCase(),actor:e.data?.actorId??``,table:(e.data?.tables??[])[0]??``,time:T$(e.timestamp,i.timeFormat)})),[h,i.timeFormat]),C=(0,W.useMemo)(()=>{let e=d?.buckets;if(!e?.length)return[];let t=Math.max(...e.map(e=>Math.max(e.pushCount,e.pullCount)),1);return e.map(e=>({pushPercent:t>0?e.pushCount/t*100:0,pullPercent:t>0?e.pullCount/t*100:0}))},[d?.buckets]),w=(0,W.useMemo)(()=>{if(!f)return[];let e=Math.max(f.push.p50,f.push.p90,f.push.p99,f.pull.p50,f.pull.p90,f.pull.p99,1);return[{label:`P50`,pushMs:f.push.p50,pullMs:f.pull.p50,pushBarPercent:f.push.p50/e*100,pullBarPercent:f.pull.p50/e*100},{label:`P90`,pushMs:f.push.p90,pullMs:f.pull.p90,pushBarPercent:f.push.p90/e*100,pullBarPercent:f.pull.p90/e*100},{label:`P99`,pushMs:f.push.p99,pullMs:f.pull.p99,pushBarPercent:f.push.p99/e*100,pullBarPercent:f.pull.p99/e*100}]},[f]),T=(0,W.useMemo)(()=>p?.items?p.items.map(e=>({seq:e.commitSeq,actor:e.actorId,changes:e.changeCount,tables:(e.affectedTables??[]).join(`, `),time:T$(e.createdAt,i.timeFormat)})):[],[p?.items,i.timeFormat]),E=(0,W.useMemo)(()=>Math.max(0,100-_.errorRate),[_.errorRate]),D=(0,W.useMemo)(()=>{if(!s.enabled||!u)return[];let e=[];return f?.push?.p90&&f.push.p90>s.thresholds.p90Latency&&e.push(`P90 push latency (${f.push.p90}ms) exceeds threshold (${s.thresholds.p90Latency}ms)`),u.minActiveClientCursor!==null&&u.maxCommitSeq-u.minActiveClientCursor>s.thresholds.clientLag&&e.push(`Client lag (${u.maxCommitSeq-u.minActiveClientCursor}) exceeds threshold (${s.thresholds.clientLag})`),_.errorRate>s.thresholds.errorRate&&e.push(`Error rate (${_.errorRate.toFixed(1)}%) exceeds threshold (${s.thresholds.errorRate}%)`),e},[s,u,f,_.errorRate]);return u?(0,G.jsx)(h$.Provider,{value:n,children:(0,G.jsxs)(`div`,{className:`flex flex-col`,children:[D.length>0&&(0,G.jsx)(`div`,{className:`px-6 pb-4`,children:(0,G.jsxs)(cZ,{variant:`destructive`,children:[(0,G.jsx)(lZ,{children:`Threshold Exceeded`}),(0,G.jsx)(uZ,{children:D.map((e,t)=>(0,G.jsx)(`span`,{className:`block`,children:e},t))})]})}),(0,G.jsx)(xJ,{clients:v,totalNodes:v.length+2,onlineCount:y,offlineCount:b,relayClientIds:[]}),(0,G.jsx)(WV,{items:x}),(0,G.jsxs)(`div`,{className:`flex`,children:[(0,G.jsxs)(`div`,{className:`flex-1 min-w-0 flex flex-col`,children:[(0,G.jsx)(`div`,{className:`border-b border-border border-r border-border`,children:(0,G.jsx)(ER,{bars:C,activeRange:c,onRangeChange:l})}),(0,G.jsx)(`div`,{className:`border-b border-border border-r border-border`,children:(0,G.jsx)(KV,{buckets:w,successRate:E})}),(0,G.jsx)(`div`,{className:`border-r border-border`,children:(0,G.jsx)(sV,{commits:T,onViewAll:()=>e({href:t})})})]}),(0,G.jsx)(JV,{entries:S,isConnected:g,maxVisible:20,maxHeight:`calc(100vh - 200px)`})]})]})}):(0,G.jsx)(`div`,{className:`flex items-center justify-center py-24`,children:(0,G.jsx)(dV,{size:`lg`})})}function O$(){return(0,G.jsx)(D$,{})}var k$=VX;function A$({children:e}){return(0,G.jsxs)(`div`,{className:`space-y-4 px-5 py-5`,children:[(0,G.jsx)(j$,{}),(0,G.jsx)(R$,{}),(0,G.jsx)(z$,{}),e]})}function j$(){let{clearError:e,config:t,connect:n,disconnect:r,error:i,isConnected:a,isConnecting:o}=Py(),[s,c]=(0,W.useState)(t?.serverUrl??`/api`),[l,u]=(0,W.useState)(t?.token??``),[d,f]=(0,W.useState)(null),[p,m]=(0,W.useState)(!1),[h,g]=(0,W.useState)(null),[_,v]=pQ(`console:disconnect-clear-saved-config`,!1);return(0,W.useEffect)(()=>{let e=new URLSearchParams(window.location.search),t=e.get(`server`),n=!1;if(t&&(c(t),e.delete(`server`),n=!0),e.has(`token`)&&(e.delete(`token`),n=!0),n){let t=e.toString(),n=t?`${window.location.pathname}?${t}`:window.location.pathname;window.history.replaceState({},``,n)}},[]),(0,W.useEffect)(()=>{t?.serverUrl&&c(t.serverUrl),t?.token&&u(t.token)},[t?.serverUrl,t?.token]),(0,W.useEffect)(()=>{g(null)},[]),(0,G.jsx)(lV,{isConnected:a,isConnecting:o,isTestingConnection:p,serverUrl:s,onServerUrlChange:c,consoleToken:l,onConsoleTokenChange:u,onSaveAndConnect:async()=>{e(),f(null),g(await n({serverUrl:s.trim(),token:l.trim()},{persistOverride:!0})?`Connected successfully and configuration saved.`:`Failed to connect with the provided settings.`)},onDisconnect:()=>{r({clearSavedConfig:_}),_&&(c(`/api`),u(``)),g(_?`Disconnected and saved credentials cleared.`:`Disconnected.`),f(null)},onTestConnection:async()=>{m(!0),f(null),g(null);let e=performance.now();try{let t=s.trim(),n=l.trim();if(!t||!n)throw Error(`Missing server URL or token`);if(!(await fetch(`${t}/console/stats`,{headers:{Authorization:`Bearer ${n}`}})).ok)throw Error(`Failed to connect`);f(Math.round(performance.now()-e))}catch{f(-1)}finally{m(!1)}},statusMessage:i??h??(d===null?void 0:d<0?`Connection failed`:`Connection successful (${d}ms latency)`),children:(0,G.jsx)(`div`,{className:`px-5 pb-5 -mt-2`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-border px-3 py-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-mono text-[10px] text-neutral-400`,children:`Clear saved credentials on disconnect`}),(0,G.jsx)(`p`,{className:`font-mono text-[9px] text-neutral-500`,children:`Removes stored server URL and token from this browser.`})]}),(0,G.jsx)(qB,{checked:_,onCheckedChange:v})]})})})}var M$=1440*60*1e3;function N$(e){let t=e.trim();if(!t)return null;let n=Number.parseInt(t,10);return!Number.isInteger(n)||n<=0?null:n}function P$(e){if(!e)return`Never`;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():`Invalid date`}function F$(e){return e.length===0?`all scopes`:e.length<=2?e.join(`, `):`${e.slice(0,2).join(`, `)} +${e.length-2}`}function I$(e,t){if(e.revokedAt)return`revoked`;if(!e.expiresAt)return`active`;let n=Date.parse(e.expiresAt);if(!Number.isFinite(n))return`active`;let r=Date.now();return n<=r?`expired`:n<=r+t*M$?`expiring`:`active`}function L$(e){return e===`revoked`?`destructive`:e===`expired`?`offline`:e===`expiring`?`syncing`:`healthy`}function R$(){let[e,t]=(0,W.useState)(`all`),[n,r]=(0,W.useState)(`all`),[i,a]=(0,W.useState)(`14`),[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(!1),[u,d]=(0,W.useState)(``),[f,p]=(0,W.useState)(`relay`),[m,h]=(0,W.useState)(``),[g,_]=(0,W.useState)(``),[v,y]=(0,W.useState)(``),[b,x]=(0,W.useState)(null),[S,C]=(0,W.useState)([]),[w,T]=(0,W.useState)(null),[E,D]=(0,W.useState)(null),[O,k]=(0,W.useState)(null),[A,j]=(0,W.useState)(null),[M,N]=(0,W.useState)(null),[P,F]=(0,W.useState)(null),[I,L]=(0,W.useState)(null),ee=(0,W.useMemo)(()=>N$(i),[i]),R=ee??14,z=(0,W.useMemo)(()=>N$(v),[v]),B=v.trim().length>0,V=!B||z!==null,{data:H,isLoading:U,error:te}=GQ((0,W.useMemo)(()=>({type:e===`all`?void 0:e,status:n===`all`?void 0:n,expiresWithinDays:n===`expiring`?R:void 0}),[e,n,R])),ne=KQ(),re=JQ(),ie=qQ(),ae=YQ(),oe=XQ();(0,W.useEffect)(()=>{let e=new Set((H?.items??[]).map(e=>e.keyId));C(t=>t.filter(t=>e.has(t)))},[H?.items]);let se=async()=>{try{let e=g.split(`,`).map(e=>e.trim()).filter(e=>e.length>0);x((await ne.mutateAsync({name:u,keyType:f,actorId:m||void 0,scopeKeys:e.length>0?e:void 0,expiresInDays:B?z??void 0:void 0})).secretKey),d(``),h(``),_(``),y(``)}catch{}},ce=e=>{navigator.clipboard.writeText(e),D(e),setTimeout(()=>D(null),2e3)},le=async()=>{if(O)try{await ie.mutateAsync(O)}finally{k(null)}},ue=async()=>{if(S.length!==0)try{T(await re.mutateAsync({keyIds:S})),C([])}catch{}},de=async()=>{if(A)try{let e=await oe.mutateAsync(A.keyId);N({oldKeyId:A.keyId,oldKeyName:A.name,secretKey:e.secretKey})}catch{}},fe=async()=>{if(M)try{await ie.mutateAsync(M.oldKeyId)}finally{N(null),j(null)}},pe=async()=>{if(P)try{L((await ae.mutateAsync(P)).secretKey)}finally{F(null)}};if(U)return(0,G.jsx)(`div`,{className:`flex h-[200px] items-center justify-center`,children:(0,G.jsx)(dV,{size:`lg`})});if(te)return(0,G.jsx)(`div`,{className:`flex h-[200px] items-center justify-center`,children:(0,G.jsxs)(`p`,{className:`text-danger`,children:[`Failed to load API keys: `,te.message]})});let me=(H?.items??[]).filter(e=>e.revokedAt===null).map(e=>e.keyId),he=me.length>0&&me.every(e=>S.includes(e)),ge=S.length>0,_e=(H?.items??[]).filter(e=>S.includes(e.keyId)).map(e=>e.name);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(eH,{title:`API Keys`,description:`Issue, rotate, revoke, and audit key lifecycle state.`,actions:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(Q,{size:`sm`,variant:`destructive`,onClick:()=>l(!0),disabled:S.length===0,children:[`Revoke Selected (`,S.length,`)`]}),(0,G.jsx)(Q,{size:`sm`,onClick:()=>s(!0),children:`Create Key`})]}),children:[(0,G.jsxs)(`div`,{className:`mb-4 grid gap-3 lg:grid-cols-3`,children:[(0,G.jsxs)(YJ,{children:[(0,G.jsx)(XJ,{children:`Type filter`}),(0,G.jsxs)(ZX,{value:[e],multiple:!1,onValueChange:e=>{let n=e.find(e=>typeof e==`string`);(n===`all`||n===`relay`||n===`proxy`||n===`admin`)&&t(n)},children:[(0,G.jsx)(k$,{value:`all`,children:`all`}),(0,G.jsx)(k$,{value:`relay`,children:`relay`}),(0,G.jsx)(k$,{value:`proxy`,children:`proxy`}),(0,G.jsx)(k$,{value:`admin`,children:`admin`})]})]}),(0,G.jsxs)(YJ,{children:[(0,G.jsx)(XJ,{children:`Status filter`}),(0,G.jsxs)(ZX,{value:[n],multiple:!1,onValueChange:e=>{let t=e.find(e=>typeof e==`string`);(t===`all`||t===`active`||t===`revoked`||t===`expiring`)&&r(t)},children:[(0,G.jsx)(k$,{value:`all`,children:`all`}),(0,G.jsx)(k$,{value:`active`,children:`active`}),(0,G.jsx)(k$,{value:`revoked`,children:`revoked`}),(0,G.jsx)(k$,{value:`expiring`,children:`expiring`})]})]}),(0,G.jsxs)(YJ,{children:[(0,G.jsx)(XJ,{htmlFor:`api-key-expiring-window`,children:`Expiring window (days)`}),(0,G.jsx)(ZJ,{children:`Used when status filter is set to expiring.`}),(0,G.jsx)(jR,{id:`api-key-expiring-window`,placeholder:`14`,value:i,inputMode:`numeric`,onChange:e=>a(e.target.value)}),ee===null&&i.trim().length>0?(0,G.jsx)(`p`,{className:`font-mono text-[10px] text-offline`,children:`Enter a positive whole number.`}):null]})]}),H?.items.length===0?(0,G.jsx)(vV,{message:`No API keys match the current filters.`}):(0,G.jsxs)(QB,{children:[(0,G.jsx)($B,{children:(0,G.jsxs)(tV,{children:[(0,G.jsx)(nV,{className:`w-[28px]`,children:(0,G.jsx)(NJ,{checked:he,indeterminate:!he&&ge&&me.length>0,onCheckedChange:e=>{C(e?me:[])},"aria-label":`Select all active keys`})}),(0,G.jsx)(nV,{className:`w-[100px]`,children:`NAME`}),(0,G.jsx)(nV,{className:`w-[55px]`,children:`TYPE`}),(0,G.jsx)(nV,{className:`w-[90px]`,children:`KEY PREFIX`}),(0,G.jsx)(nV,{className:`w-[80px]`,children:`ACTOR`}),(0,G.jsx)(nV,{className:`w-[100px]`,children:`SCOPES`}),(0,G.jsx)(nV,{className:`w-[120px]`,children:`CREATED`}),(0,G.jsx)(nV,{className:`w-[120px]`,children:`LAST USED`}),(0,G.jsx)(nV,{className:`w-[120px]`,children:`EXPIRES`}),(0,G.jsx)(nV,{className:`flex-1`,children:`STATUS`})]})}),(0,G.jsx)(eV,{children:(H?.items??[]).map(e=>{let t=I$(e,R);return(0,G.jsxs)(tV,{className:`group relative`,children:[(0,G.jsx)(rV,{className:`w-[28px]`,children:(0,G.jsx)(NJ,{checked:S.includes(e.keyId),onCheckedChange:t=>{C(n=>t?[...new Set([...n,e.keyId])]:n.filter(t=>t!==e.keyId))},"aria-label":`Select ${e.name}`,disabled:e.revokedAt!==null})}),(0,G.jsx)(rV,{className:`w-[100px] font-medium`,children:e.name}),(0,G.jsx)(rV,{className:`w-[55px]`,children:(0,G.jsx)(ZB,{variant:e.keyType===`admin`?`flow`:e.keyType===`proxy`?`ghost`:`relay`,children:e.keyType})}),(0,G.jsx)(rV,{className:`w-[90px]`,children:(0,G.jsxs)(`code`,{className:`font-mono text-[11px]`,children:[e.keyPrefix,`...`]})}),(0,G.jsx)(rV,{className:`w-[80px] text-neutral-500`,children:e.actorId??`-`}),(0,G.jsx)(rV,{className:`w-[100px] text-neutral-500`,children:(0,G.jsx)(`code`,{className:`font-mono text-[10px]`,children:F$(e.scopeKeys)})}),(0,G.jsx)(rV,{className:`w-[120px] text-neutral-500`,children:P$(e.createdAt)}),(0,G.jsx)(rV,{className:`w-[120px] text-neutral-500`,children:P$(e.lastUsedAt)}),(0,G.jsx)(rV,{className:`w-[120px] text-neutral-500`,children:P$(e.expiresAt)}),(0,G.jsx)(rV,{className:`flex-1`,children:(0,G.jsx)(ZB,{variant:L$(t),children:t})}),e.revokedAt===null&&(0,G.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:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>j(e),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`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>F(e.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`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>k(e.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`})]})]},e.keyId)})})]})]}),(0,G.jsx)(kZ,{open:o,onOpenChange:s,children:(0,G.jsxs)(jZ,{children:[(0,G.jsx)(MZ,{children:(0,G.jsx)(PZ,{children:`Create API Key`})}),b?(0,G.jsx)(B$,{copiedKeyId:E,onClose:()=>{x(null),s(!1)},onCopy:ce,secretKey:b,warning:`Copy this key now. You will not be able to view it again.`}):(0,G.jsxs)(`div`,{className:`px-5 py-4 flex flex-col gap-4`,children:[(0,G.jsxs)(YJ,{children:[(0,G.jsx)(XJ,{htmlFor:`api-key-name`,children:`Name`}),(0,G.jsx)(jR,{id:`api-key-name`,placeholder:`Backend Relay Key`,value:u,onChange:e=>d(e.target.value)})]}),(0,G.jsxs)(YJ,{children:[(0,G.jsx)(XJ,{children:`Key type`}),(0,G.jsxs)(ZX,{value:[f],multiple:!1,onValueChange:e=>{let t=e.find(e=>typeof e==`string`);(t===`relay`||t===`proxy`||t===`admin`)&&p(t)},children:[(0,G.jsx)(k$,{value:`relay`,children:`relay`}),(0,G.jsx)(k$,{value:`proxy`,children:`proxy`}),(0,G.jsx)(k$,{value:`admin`,children:`admin`})]})]}),(0,G.jsxs)(YJ,{children:[(0,G.jsx)(XJ,{htmlFor:`api-key-actor-id`,children:`Actor ID (optional)`}),(0,G.jsx)(ZJ,{children:`Pin this key to a fixed actor ID`}),(0,G.jsx)(jR,{id:`api-key-actor-id`,placeholder:`actor-123`,value:m,onChange:e=>h(e.target.value)})]}),(0,G.jsxs)(YJ,{children:[(0,G.jsx)(XJ,{htmlFor:`api-key-scope-keys`,children:`Scope keys (optional)`}),(0,G.jsx)(ZJ,{children:`Comma-separated list of allowed scope keys`}),(0,G.jsx)(jR,{id:`api-key-scope-keys`,placeholder:`scope-a, scope-b`,value:g,onChange:e=>_(e.target.value)})]}),(0,G.jsxs)(YJ,{children:[(0,G.jsx)(XJ,{htmlFor:`api-key-expires-days`,children:`Expires in days (optional)`}),(0,G.jsx)(ZJ,{children:`Leave empty to keep the key non-expiring.`}),(0,G.jsx)(jR,{id:`api-key-expires-days`,placeholder:`30`,value:v,inputMode:`numeric`,onChange:e=>y(e.target.value)}),V?null:(0,G.jsx)(`p`,{className:`font-mono text-[10px] text-offline`,children:`Enter a positive whole number.`})]}),(0,G.jsxs)(NZ,{children:[(0,G.jsx)(Q,{variant:`default`,onClick:()=>s(!1),children:`Cancel`}),(0,G.jsx)(Q,{variant:`primary`,onClick:se,disabled:ne.isPending||!u||!V,children:ne.isPending?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(dV,{size:`sm`}),`Creating...`]}):`Create`})]})]})]})}),(0,G.jsx)(kZ,{open:c,onOpenChange:e=>{l(e),e||T(null)},children:(0,G.jsxs)(jZ,{children:[(0,G.jsx)(MZ,{children:(0,G.jsx)(PZ,{children:`Bulk Revoke API Keys`})}),w?(0,G.jsxs)(`div`,{className:`px-5 py-4 flex flex-col gap-3`,children:[(0,G.jsx)(cZ,{variant:`destructive`,children:(0,G.jsxs)(uZ,{children:[`Requested `,w.requestedCount,` keys. Revoked`,` `,w.revokedCount,`, already revoked`,` `,w.alreadyRevokedCount,`, not found`,` `,w.notFoundCount,`.`]})}),(0,G.jsx)(NZ,{children:(0,G.jsx)(Q,{variant:`primary`,onClick:()=>{l(!1),T(null)},children:`Done`})})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`px-5 py-4 flex flex-col gap-3`,children:[(0,G.jsx)(cZ,{variant:`destructive`,children:(0,G.jsx)(uZ,{children:`This revokes selected keys immediately and cannot be undone.`})}),(0,G.jsxs)(`p`,{className:`font-mono text-[10px] text-neutral-500`,children:[`Selected keys: `,_e.slice(0,5).join(`, `),_e.length>5?` +${_e.length-5} more`:``]})]}),(0,G.jsxs)(NZ,{children:[(0,G.jsx)(Q,{variant:`default`,onClick:()=>l(!1),children:`Cancel`}),(0,G.jsx)(Q,{variant:`destructive`,onClick:ue,disabled:re.isPending||S.length===0,children:re.isPending?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(dV,{size:`sm`}),`Revoking...`]}):`Revoke Selected`})]})]})]})}),(0,G.jsx)(kZ,{open:A!==null||M!==null,onOpenChange:()=>{j(null),N(null)},children:(0,G.jsxs)(jZ,{children:[(0,G.jsx)(MZ,{children:(0,G.jsx)(PZ,{children:`Stage Rotate API Key`})}),M?(0,G.jsxs)(`div`,{className:`px-5 py-4 flex flex-col gap-4`,children:[(0,G.jsx)(cZ,{variant:`default`,children:(0,G.jsxs)(uZ,{children:[`Replacement key created for `,M.oldKeyName,`. The old key is still active until you revoke it.`]})}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`code`,{className:`flex-1 rounded-md border border-border bg-surface p-3 font-mono text-[11px] text-white break-all`,children:M.secretKey}),(0,G.jsx)(Q,{variant:`default`,size:`sm`,onClick:()=>ce(M.secretKey),children:E===M.secretKey?`Copied`:`Copy`})]}),(0,G.jsxs)(NZ,{children:[(0,G.jsx)(Q,{variant:`default`,onClick:()=>{N(null),j(null)},children:`Keep Old Key Active`}),(0,G.jsx)(Q,{variant:`destructive`,onClick:fe,disabled:ie.isPending,children:ie.isPending?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(dV,{size:`sm`}),`Revoking Old Key...`]}):`Finalize and Revoke Old Key`})]})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`px-5 py-4`,children:(0,G.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.`})}),(0,G.jsxs)(NZ,{children:[(0,G.jsx)(Q,{variant:`default`,onClick:()=>j(null),children:`Cancel`}),(0,G.jsx)(Q,{variant:`primary`,onClick:de,disabled:oe.isPending||!A,children:oe.isPending?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(dV,{size:`sm`}),`Staging...`]}):`Create Replacement Key`})]})]})]})}),(0,G.jsx)(kZ,{open:O!==null,onOpenChange:()=>k(null),children:(0,G.jsxs)(jZ,{children:[(0,G.jsx)(MZ,{children:(0,G.jsx)(PZ,{children:`Revoke API Key`})}),(0,G.jsx)(`div`,{className:`px-5 py-4`,children:(0,G.jsx)(cZ,{variant:`destructive`,children:(0,G.jsx)(uZ,{children:`Revoking a key immediately invalidates it for all requests.`})})}),(0,G.jsxs)(NZ,{children:[(0,G.jsx)(Q,{variant:`default`,onClick:()=>k(null),children:`Cancel`}),(0,G.jsx)(Q,{variant:`destructive`,onClick:le,disabled:ie.isPending,children:ie.isPending?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(dV,{size:`sm`}),`Revoking...`]}):`Revoke`})]})]})}),(0,G.jsx)(kZ,{open:P!==null||I!==null,onOpenChange:()=>{F(null),L(null)},children:(0,G.jsxs)(jZ,{children:[(0,G.jsx)(MZ,{children:(0,G.jsx)(PZ,{children:`Rotate API Key`})}),I?(0,G.jsx)(B$,{copiedKeyId:E,onClose:()=>L(null),onCopy:ce,secretKey:I,warning:`The previous key has been invalidated. Store this replacement securely.`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`px-5 py-4`,children:(0,G.jsx)(`p`,{className:`font-mono text-[10px] text-neutral-500`,children:`Rotating a key invalidates the previous secret immediately.`})}),(0,G.jsxs)(NZ,{children:[(0,G.jsx)(Q,{variant:`default`,onClick:()=>F(null),children:`Cancel`}),(0,G.jsx)(Q,{variant:`primary`,onClick:pe,disabled:ae.isPending,children:ae.isPending?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(dV,{size:`sm`}),`Rotating...`]}):`Rotate`})]})]})]})})]})}function z$(){let{preferences:e,updatePreference:t,resetPreferences:n}=r$();return(0,G.jsx)(QV,{rows:[{type:`filter`,label:`Auto-refresh interval`,options:i$.map(e=>({id:`${e.value}`,label:e.label})),activeId:`${e.refreshInterval}`,onActiveChange:e=>t(`refreshInterval`,Number.parseInt(e,10))},{type:`filter`,label:`Items per page`,options:a$.map(e=>({id:`${e.value}`,label:e.label})),activeId:`${e.pageSize}`,onActiveChange:e=>t(`pageSize`,Number.parseInt(e,10))},{type:`filter`,label:`Time format`,options:[{id:`relative`,label:`Relative`},{id:`absolute`,label:`Absolute`}],activeId:e.timeFormat,onActiveChange:e=>t(`timeFormat`,e)},{type:`toggle`,label:`Show sparklines`,description:`Display mini trend charts in dashboard metric cards`,checked:e.showSparklines,onCheckedChange:e=>t(`showSparklines`,e)}],onResetDefaults:n})}function B$({copiedKeyId:e,onClose:t,onCopy:n,secretKey:r,warning:i}){return(0,G.jsxs)(`div`,{className:`px-5 py-4 flex flex-col gap-4`,children:[(0,G.jsx)(cZ,{variant:`destructive`,children:(0,G.jsx)(uZ,{children:i})}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`code`,{className:`flex-1 rounded-md border border-border bg-surface p-3 font-mono text-[11px] text-white break-all`,children:r}),(0,G.jsx)(Q,{variant:`default`,size:`sm`,onClick:()=>n(r),children:e===r?`Copied`:`Copy`})]}),(0,G.jsx)(NZ,{children:(0,G.jsx)(Q,{variant:`primary`,onClick:t,children:`Done`})})]})}function V$(e){let 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 H$(e){let 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 U$(e,t){if(t===`absolute`)return new Date(e).toLocaleString();try{let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/1e3),i=Math.floor(r/60),a=Math.floor(i/60),o=Math.floor(a/24);return r<60?`just now`:i<60?`${i}m ago`:a<24?`${a}h ago`:`${o}d ago`}catch{return e}}function W$(e,t,n){return{id:e.clientId,type:V$(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:H$(e.clientId),scopes:Object.keys(e.effectiveScopes??{}),lastSeen:U$(e.updatedAt,n)}}function G$({emptyState:e}={}){let[t,n]=(0,W.useState)(1),[r,i]=(0,W.useState)(null),{preferences:a}=r$(),{partitionId:o}=t$(),s=a.pageSize,c=a.refreshInterval*1e3,{data:l,isLoading:u}=OQ({refetchIntervalMs:c,partitionId:o}),{data:d,isLoading:f,error:p}=PQ({limit:s,offset:(t-1)*s,partitionId:o},{refetchIntervalMs:c}),m=VQ(),h=Math.ceil((d?.total??0)/s),g=l?.maxCommitSeq??0;(0,W.useEffect)(()=>{n(1)},[]);let _=async()=>{if(r)try{await m.mutateAsync({clientId:r,partitionId:o})}finally{i(null)}};if(f||u)return(0,G.jsx)(`div`,{className:`flex items-center justify-center h-[200px]`,children:(0,G.jsx)(dV,{size:`lg`})});if(p)return(0,G.jsx)(`div`,{className:`flex items-center justify-center h-[200px]`,children:(0,G.jsxs)(`p`,{className:`text-danger`,children:[`Failed to load clients: `,p.message]})});let v=(d?.items??[]).map(e=>W$(e,g,a.timeFormat));return(0,G.jsxs)(`div`,{className:`flex flex-col gap-5 px-5 py-5`,children:[v.length>0&&(0,G.jsx)(oH,{clients:v,headSeq:g}),v.length===0?e??(0,G.jsx)(ZV,{children:(0,G.jsx)(vV,{message:`No clients yet`})}):(0,G.jsx)(VV,{clients:v,headSeq:g,onEvict:e=>{let t=d?.items.find(t=>t.clientId===e);i(t?.clientId??e)}}),h>1&&(0,G.jsx)(IZ,{page:t,totalPages:h,totalItems:d?.total??0,onPageChange:n}),(0,G.jsx)(kZ,{open:r!==null,onOpenChange:()=>i(null),children:(0,G.jsxs)(jZ,{children:[(0,G.jsx)(MZ,{children:(0,G.jsx)(PZ,{children:`Evict Client`})}),(0,G.jsxs)(`div`,{className:`px-5 py-4 flex flex-col gap-4`,children:[(0,G.jsxs)(`p`,{className:`font-mono text-[11px] text-neutral-300`,children:[`Are you sure you want to evict client`,` `,(0,G.jsxs)(`span`,{className:`font-mono text-white`,children:[r?.slice(0,12),`...`]}),`?`]}),(0,G.jsx)(`p`,{className:`font-mono text-[10px] text-neutral-500`,children:`This will force the client to re-bootstrap on their next sync.`})]}),(0,G.jsxs)(NZ,{children:[(0,G.jsx)(Q,{variant:`default`,onClick:()=>i(null),children:`Cancel`}),(0,G.jsx)(Q,{variant:`destructive`,onClick:_,disabled:m.isPending,children:m.isPending?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(dV,{size:`sm`}),`Evicting...`]}):`Evict`})]})]})})]})}var K$={latencyThresholdMs:1e3,errorRateThreshold:5,clientLagThreshold:50,enabled:!1};function q$(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 J$(e){let t=e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0);return Array.from(new Set(t))}function Y$(e){switch(e){case`notify_data_change`:return`Notify`;case`evict_client`:return`Evict`;case`compact`:return`Compact`;default:return`Prune`}}function X$(e){return!e||typeof e!=`object`||Array.isArray(e)?null:e}function Z$(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function Q$(e){let t=X$(e.requestPayload),n=X$(e.resultPayload);if(e.operationType===`notify_data_change`){let e=Z$(t?.tables),r=n?.commitSeq;return`${e.length} table${e.length===1?``:`s`} -> commit #${typeof r==`number`?r:`?`}`}if(e.operationType===`evict_client`){let t=n?.evicted===!0?`evicted`:`not found`;return`client ${e.targetClientId??`?`} ${t}`}return e.operationType===`compact`?`${typeof n?.deletedChanges==`number`?n.deletedChanges:0} changes removed`:`${typeof n?.deletedCommits==`number`?n.deletedCommits:0} commits removed${typeof t?.watermarkCommitSeq==`number`?` at #${t.watermarkCommitSeq}`:``}`}function $$(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function e1(){let{partitionId:e}=t$();return(0,G.jsxs)(`div`,{className:`flex flex-col gap-4 px-5 py-5`,children:[(0,G.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,G.jsx)(t1,{}),(0,G.jsx)(o1,{})]}),(0,G.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-3`,children:[(0,G.jsx)(n1,{partitionId:e}),(0,G.jsx)(r1,{partitionId:e}),(0,G.jsx)(i1,{partitionId:e})]}),(0,G.jsx)(a1,{partitionId:e})]})}function t1(){let{data:e,isLoading:t,error:n}=LQ();return t?(0,G.jsx)(`div`,{className:`flex items-center justify-center h-[200px]`,children:(0,G.jsx)(dV,{size:`lg`})}):n?(0,G.jsx)(`div`,{className:`flex items-center justify-center h-[200px]`,children:(0,G.jsxs)(`p`,{className:`text-danger`,children:[`Failed to load handlers: `,n.message]})}):(0,G.jsx)(HV,{handlers:(e?.items??[]).map(e=>({table:e.table,dependsOn:e.dependsOn?.join(`, `)??null,chunkTtl:e.snapshotChunkTtlMs?q$(e.snapshotChunkTtlMs):`default`})),tableCount:e?.items.length??0})}function n1({partitionId:e}){let[t,n]=(0,W.useState)(!1),[r,i]=(0,W.useState)(null),{data:a,isLoading:o}=OQ({partitionId:e}),{data:s,isLoading:c,refetch:l}=RQ({enabled:!1}),u=HQ();return o?(0,G.jsx)(`div`,{className:`flex items-center justify-center h-[200px]`,children:(0,G.jsx)(dV,{size:`lg`})}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(XV,{title:`Prune`,description:`Delete commits that all clients have already synced. Pruning removes commits older than the oldest active client cursor.`,dotColor:`syncing`,stats:[{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`}],actionLabel:`Preview Prune`,actionVariant:`destructive`,onAction:async()=>{n(!0),i(null),await l()}}),(0,G.jsx)(kZ,{open:t,onOpenChange:n,children:(0,G.jsxs)(jZ,{children:[(0,G.jsx)(MZ,{children:(0,G.jsx)(PZ,{children:`Prune Old Commits`})}),(0,G.jsx)(`div`,{className:`px-5 py-4 flex flex-col gap-4`,children:r===null?c?(0,G.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,G.jsx)(dV,{size:`sm`})}):s?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(cZ,{variant:s.commitsToDelete>0?`destructive`:`default`,children:(0,G.jsx)(uZ,{children:s.commitsToDelete>0?(0,G.jsxs)(G.Fragment,{children:[`This will delete`,` `,(0,G.jsx)(`strong`,{children:s.commitsToDelete}),` commits up to sequence`,` `,(0,G.jsxs)(`code`,{className:`font-mono`,children:[`#`,s.watermarkCommitSeq]}),`.`]}):`No commits are eligible for pruning.`})}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex justify-between font-mono text-[11px]`,children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Watermark commit seq:`}),(0,G.jsxs)(`span`,{className:`text-white`,children:[`#`,s.watermarkCommitSeq]})]}),(0,G.jsxs)(`div`,{className:`flex justify-between font-mono text-[11px] items-center`,children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Commits to delete:`}),(0,G.jsx)(ZB,{variant:s.commitsToDelete>0?`offline`:`ghost`,children:s.commitsToDelete})]})]})]}):null:(0,G.jsxs)(cZ,{variant:`default`,children:[(0,G.jsx)(lZ,{children:`Pruning Complete`}),(0,G.jsxs)(uZ,{children:[`Successfully deleted `,(0,G.jsx)(`strong`,{children:r}),` commits.`]})]})}),(0,G.jsxs)(NZ,{children:[(0,G.jsx)(Q,{variant:`default`,onClick:()=>n(!1),children:r===null?`Cancel`:`Close`}),r===null&&(0,G.jsx)(Q,{variant:`destructive`,onClick:async()=>{i((await u.mutateAsync()).deletedCommits)},disabled:u.isPending||c||(s?.commitsToDelete??0)===0,children:u.isPending?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(dV,{size:`sm`}),`Pruning...`]}):`Prune Now`})]})]})})]})}function r1({partitionId:e}){let[t,n]=(0,W.useState)(!1),[r,i]=(0,W.useState)(null),{data:a,isLoading:o}=OQ({partitionId:e}),s=UQ();return o?(0,G.jsx)(`div`,{className:`flex items-center justify-center h-[200px]`,children:(0,G.jsx)(dV,{size:`lg`})}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(XV,{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:[{label:`Total changes`,value:a?.changeCount??0},{label:`Total commits`,value:a?.commitCount??0}],actionLabel:`Run Compaction`,actionVariant:`primary`,onAction:()=>{n(!0),i(null)}}),(0,G.jsx)(kZ,{open:t,onOpenChange:n,children:(0,G.jsxs)(jZ,{children:[(0,G.jsx)(MZ,{children:(0,G.jsx)(PZ,{children:`Compact Changes`})}),(0,G.jsx)(`div`,{className:`px-5 py-4 flex flex-col gap-4`,children:r===null?(0,G.jsx)(cZ,{variant:`default`,children:(0,G.jsx)(uZ,{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.`})}):(0,G.jsxs)(cZ,{variant:`default`,children:[(0,G.jsx)(lZ,{children:`Compaction Complete`}),(0,G.jsxs)(uZ,{children:[`Successfully removed `,(0,G.jsx)(`strong`,{children:r}),` redundant changes.`]})]})}),(0,G.jsxs)(NZ,{children:[(0,G.jsx)(Q,{variant:`default`,onClick:()=>n(!1),children:r===null?`Cancel`:`Close`}),r===null&&(0,G.jsx)(Q,{variant:`primary`,onClick:async()=>{i((await s.mutateAsync()).deletedChanges)},disabled:s.isPending,children:s.isPending?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(dV,{size:`sm`}),`Compacting...`]}):`Compact Now`})]})]})})]})}function i1({partitionId:e}){let[t,n]=(0,W.useState)(!1),[r,i]=(0,W.useState)(`tasks`),[a,o]=(0,W.useState)(e??``),[s,c]=(0,W.useState)(null),[l,u]=(0,W.useState)(null),d=WQ(),f=J$(r),p=[{label:`Next tables`,value:f.length,tone:`syncing`},{label:`Last commit seq`,value:s?`#${s.commitSeq}`:`—`,tone:`syncing`},{label:`Last chunks cleared`,value:s?.deletedChunks??`—`}];return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(XV,{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:p,actionLabel:`Notify Clients`,actionVariant:`primary`,onAction:()=>{n(!0),u(null)}}),(0,G.jsx)(kZ,{open:t,onOpenChange:n,children:(0,G.jsxs)(jZ,{children:[(0,G.jsx)(MZ,{children:(0,G.jsx)(PZ,{children:`Notify External Data Change`})}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-4 px-5 py-4`,children:[s?(0,G.jsxs)(cZ,{variant:`default`,children:[(0,G.jsx)(lZ,{children:`Notification Sent`}),(0,G.jsxs)(uZ,{children:[`Created synthetic commit`,` `,(0,G.jsxs)(`strong`,{children:[`#`,s.commitSeq]}),` for`,` `,(0,G.jsx)(`strong`,{children:s.tables.length}),` table`,s.tables.length===1?``:`s`,` and cleared`,` `,(0,G.jsx)(`strong`,{children:s.deletedChunks}),` cached chunk`,s.deletedChunks===1?``:`s`,`.`]})]}):(0,G.jsx)(cZ,{variant:`default`,children:(0,G.jsx)(uZ,{children:`Use this when data changed outside Syncular push flow. It invalidates cached snapshot chunks and forces clients to pull fresh data.`})}),l?(0,G.jsx)(cZ,{variant:`destructive`,children:(0,G.jsx)(uZ,{children:l})}):null,(0,G.jsxs)(YJ,{children:[(0,G.jsx)(XJ,{children:`Tables (comma-separated)`}),(0,G.jsx)(jR,{value:r,onChange:e=>i(e.target.value),placeholder:`tasks, notes`,disabled:d.isPending}),(0,G.jsx)(ZJ,{children:`Enter one or more table names affected by the external change.`})]}),(0,G.jsxs)(YJ,{children:[(0,G.jsx)(XJ,{children:`Partition ID (optional)`}),(0,G.jsx)(jR,{value:a,onChange:e=>o(e.target.value),placeholder:`default`,disabled:d.isPending})]})]}),(0,G.jsxs)(NZ,{children:[(0,G.jsx)(Q,{variant:`default`,onClick:()=>n(!1),children:s?`Close`:`Cancel`}),s?null:(0,G.jsx)(Q,{variant:`primary`,onClick:async()=>{if(f.length===0){u(`Provide at least one table name.`);return}u(null),c(await d.mutateAsync({tables:f,partitionId:a.trim()||void 0}))},disabled:d.isPending,children:d.isPending?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(dV,{size:`sm`}),`Notifying...`]}):`Notify Data Change`})]})]})})]})}function a1({partitionId:e}){let[t,n]=(0,W.useState)(`all`),{data:r,isLoading:i,error:a}=zQ({limit:20,offset:0,operationType:t===`all`?void 0:t,partitionId:e},{refetchIntervalMs:5e3});return(0,G.jsx)(eH,{title:`Operation Audit`,description:`Recent prune/compact/notify/evict actions with actor and result context.`,actions:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Q,{variant:t===`all`?`default`:`ghost`,size:`sm`,onClick:()=>n(`all`),children:`All`}),(0,G.jsx)(Q,{variant:t===`prune`?`default`:`ghost`,size:`sm`,onClick:()=>n(`prune`),children:`Prune`}),(0,G.jsx)(Q,{variant:t===`compact`?`default`:`ghost`,size:`sm`,onClick:()=>n(`compact`),children:`Compact`}),(0,G.jsx)(Q,{variant:t===`notify_data_change`?`default`:`ghost`,size:`sm`,onClick:()=>n(`notify_data_change`),children:`Notify`}),(0,G.jsx)(Q,{variant:t===`evict_client`?`default`:`ghost`,size:`sm`,onClick:()=>n(`evict_client`),children:`Evict`})]}),contentClassName:`pt-2`,children:i?(0,G.jsx)(`div`,{className:`flex items-center justify-center py-10`,children:(0,G.jsx)(dV,{size:`lg`})}):a?(0,G.jsx)(cZ,{variant:`destructive`,children:(0,G.jsxs)(uZ,{children:[`Failed to load operation audit events: `,a.message]})}):(r?.items.length??0)===0?(0,G.jsx)(`div`,{className:`px-2 py-8 text-sm text-neutral-500`,children:`No operation events found for this filter.`}):(0,G.jsx)(`div`,{className:`overflow-x-auto`,children:(0,G.jsxs)(QB,{children:[(0,G.jsx)($B,{children:(0,G.jsxs)(tV,{children:[(0,G.jsx)(nV,{children:`Time`}),(0,G.jsx)(nV,{children:`Type`}),(0,G.jsx)(nV,{children:`User`}),(0,G.jsx)(nV,{children:`Target`}),(0,G.jsx)(nV,{children:`Result`})]})}),(0,G.jsx)(eV,{children:(r?.items??[]).map((e,t)=>(0,G.jsxs)(tV,{children:[(0,G.jsx)(rV,{className:`whitespace-nowrap text-xs text-neutral-400`,children:$$(e.createdAt)}),(0,G.jsx)(rV,{children:(0,G.jsx)(ZB,{variant:`ghost`,children:Y$(e.operationType)})}),(0,G.jsx)(rV,{className:`font-mono text-xs`,children:e.consoleUserId??`system`}),(0,G.jsx)(rV,{className:`font-mono text-xs`,children:e.targetClientId??e.partitionId??(e.operationType===`notify_data_change`?`partition default`:`global`)}),(0,G.jsx)(rV,{className:`font-mono text-xs text-neutral-300`,children:Q$(e)})]},`${e.operationId}:${e.createdAt}:${t}`))})]})})})}function o1(){let[e,t]=pQ(`console:alert-config`,K$),n={p90Latency:e.latencyThresholdMs,errorRate:e.errorRateThreshold,clientLag:e.clientLagThreshold};return(0,G.jsx)(JB,{enabled:e.enabled,onEnabledChange:e=>{t(t=>({...t,enabled:e}))},thresholds:n,onThresholdsChange:e=>{t(t=>({...t,latencyThresholdMs:e.p90Latency,errorRateThreshold:e.errorRate,clientLagThreshold:e.clientLag}))}})}function s1(e){if(e===0)return`0 B`;let 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 c1(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function l1(){let[e,t]=(0,W.useState)(``),[n,r]=(0,W.useState)(void 0),[i,a]=(0,W.useState)(void 0),[o,s]=(0,W.useState)([]),[c,l]=(0,W.useState)(null),{data:u,isLoading:d,error:f}=ZQ({prefix:n,cursor:i,limit:100}),p=QQ(),m=$Q();function h(){let t=e.trim();r(t.length>0?t:void 0),a(void 0),s([])}function g(){t(``),r(void 0),a(void 0),s([])}function _(){u?.cursor&&(s(e=>[...e,i??``]),a(u.cursor))}function v(){s(e=>{let t=[...e],n=t.pop();return a(n&&n.length>0?n:void 0),t})}function y(){c&&p.mutate(c,{onSuccess:()=>l(null)})}if(d)return(0,G.jsx)(`div`,{className:`flex flex-col gap-4 px-5 py-5`,children:(0,G.jsx)(`div`,{className:`flex items-center justify-center h-[200px]`,children:(0,G.jsx)(dV,{size:`lg`})})});if(f)return(0,G.jsx)(`div`,{className:`flex flex-col gap-4 px-5 py-5`,children:(0,G.jsx)(`div`,{className:`flex items-center justify-center h-[200px]`,children:(0,G.jsxs)(`p`,{className:`text-danger font-mono text-[11px]`,children:[`Failed to load storage items: `,f.message]})})});let b=u?.items??[];return(0,G.jsxs)(`div`,{className:`flex flex-col gap-4 px-5 py-5`,children:[(0,G.jsx)(eH,{title:`Storage`,actions:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(jR,{placeholder:`Prefix filter...`,value:e,onChange:e=>t(e.target.value),onKeyDown:e=>{e.key===`Enter`&&h()},className:`h-7 w-48 text-xs`}),(0,G.jsx)(Q,{variant:`default`,size:`sm`,onClick:h,children:`Filter`}),n&&(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:g,children:`Clear`})]}),children:b.length===0?(0,G.jsx)(vV,{message:n?`No storage items matching prefix "${n}".`:`No storage items found.`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`overflow-x-auto`,children:(0,G.jsxs)(QB,{children:[(0,G.jsx)($B,{children:(0,G.jsxs)(tV,{children:[(0,G.jsx)(nV,{children:`Key`}),(0,G.jsx)(nV,{children:`Size`}),(0,G.jsx)(nV,{children:`Type`}),(0,G.jsx)(nV,{children:`Uploaded`}),(0,G.jsx)(nV,{children:`Actions`})]})}),(0,G.jsx)(eV,{children:b.map(e=>(0,G.jsxs)(tV,{children:[(0,G.jsx)(rV,{className:`font-mono text-xs max-w-[320px]`,title:e.key,children:e.key}),(0,G.jsx)(rV,{className:`font-mono text-xs text-neutral-400 whitespace-nowrap`,children:s1(e.size)}),(0,G.jsx)(rV,{children:e.httpMetadata?.contentType?(0,G.jsx)(ZB,{variant:`ghost`,children:e.httpMetadata.contentType}):(0,G.jsx)(`span`,{className:`text-neutral-500 text-xs`,children:`--`})}),(0,G.jsx)(rV,{className:`whitespace-nowrap text-xs text-neutral-400`,children:c1(e.uploaded)}),(0,G.jsx)(rV,{children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:()=>void m(e.key),children:`Download`}),(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:()=>l(e.key),children:`Delete`})]})})]},e.key))})]})}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between px-2 py-2`,children:[(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,disabled:o.length===0,onClick:v,children:`Previous`}),(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,disabled:!u?.truncated,onClick:_,children:`Next`})]})]})}),(0,G.jsx)(kZ,{open:c!==null,onOpenChange:()=>l(null),children:(0,G.jsxs)(jZ,{children:[(0,G.jsx)(MZ,{children:(0,G.jsx)(PZ,{children:`Delete Storage Item`})}),(0,G.jsxs)(`div`,{className:`px-5 py-4 flex flex-col gap-4`,children:[(0,G.jsxs)(`p`,{className:`font-mono text-[11px] text-neutral-300`,children:[`Are you sure you want to delete`,` `,(0,G.jsx)(`span`,{className:`font-mono text-white`,children:c}),`?`]}),(0,G.jsx)(`p`,{className:`font-mono text-[10px] text-neutral-500`,children:`This action cannot be undone.`})]}),(0,G.jsxs)(NZ,{children:[(0,G.jsx)(Q,{variant:`default`,onClick:()=>l(null),children:`Cancel`}),(0,G.jsx)(Q,{variant:`destructive`,onClick:y,disabled:p.isPending,children:p.isPending?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(dV,{size:`sm`}),` Deleting...`]}):`Delete`})]})]})})]})}function u1(e,t){if(t===`absolute`)return new Date(e).toLocaleString();let n=new Date(e),r=new Date().getTime()-n.getTime(),i=Math.floor(r/1e3);return i<60?`${i}s`:i<3600?`${Math.floor(i/60)}m`:i<86400?`${Math.floor(i/3600)}h`:`${Math.floor(i/86400)}d`}function d1(e){let t=e.split(/\s+/).map(e=>e.trim()).filter(e=>e.length>0),n={},r=[];for(let e of t){let[t=``,...i]=e.split(`:`),a=i.join(`:`).trim(),o=t.toLowerCase();if(!a){r.push(e);continue}if(o===`actor`){n.actorId=a;continue}if(o===`client`){n.clientId=a;continue}if(o===`table`){n.table=a;continue}if(o===`request`){n.requestId=a;continue}if(o===`trace`){n.traceId=a;continue}r.push(e)}return r.length>0&&(n.search=r.join(` `)),n}function f1(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 p1(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function m1(e,t){return e?`#${e.federatedCommitId??(t?`${t}:${e.commitSeq}`:String(e.commitSeq))}`:`#?`}function h1(e,t){return e?`E${e.federatedEventId??(t?`${t}:${e.eventId}`:e.eventId)}`:`E?`}function g1(e,t,n){return!e||!t?null:e.replaceAll(`{traceId}`,encodeURIComponent(t)).replaceAll(`{spanId}`,encodeURIComponent(n??``))}function _1({initialSelectedEntryId:e}={}){let{preferences:t}=r$(),{partitionId:n}=t$(),{range:r,setRange:i}=g$(),a=t.pageSize,o=t.refreshInterval*1e3,[s,c]=(0,W.useState)(()=>e?.startsWith(`#`)?`commits`:e?.startsWith(`E`)?`events`:`all`),[l,u]=(0,W.useState)(`all`),[d,f]=(0,W.useState)(`all`),[p,m]=(0,W.useState)(``),[h,g]=(0,W.useState)(1),[_,v]=(0,W.useState)(!1),[y,b]=(0,W.useState)(e??null),x=(0,W.useRef)(!1),S=(0,W.useMemo)(()=>d1(p),[p]),C=(0,W.useMemo)(()=>new Date(Date.now()-f1(r)).toISOString(),[r]),{data:w,isLoading:T,refetch:E}=NQ({limit:a,offset:(h-1)*a,...n?{partitionId:n}:{},view:s,...s!==`commits`&&l!==`all`?{eventType:l}:{},...s!==`commits`&&d!==`all`?{outcome:d}:{},...S.actorId?{actorId:S.actorId}:{},...S.clientId?{clientId:S.clientId}:{},...S.requestId?{requestId:S.requestId}:{},...S.traceId?{traceId:S.traceId}:{},...S.table?{table:S.table}:{},...S.search?{search:S.search}:{},from:C},{refetchIntervalMs:o}),D=BQ(),O=y?.startsWith(`#`)?y.slice(1):void 0,k=y?.startsWith(`E`)?y.slice(1):void 0,A=O&&O!==`?`?O:void 0,j=k&&k!==`?`?k:void 0,{data:M,isLoading:N,error:P}=MQ(A,{enabled:A!==void 0,partitionId:n}),{data:F,isLoading:I,error:L}=FQ(j,{enabled:j!==void 0,partitionId:n}),{data:ee,isLoading:R,error:z}=IQ(j,{enabled:j!==void 0&&!!F?.payloadRef,partitionId:n}),B=(0,W.useMemo)(()=>g1(void 0,F?.traceId??null,F?.spanId??null),[F?.spanId,F?.traceId,void 0]);(0,W.useEffect)(()=>{g(1)},[]),(0,W.useEffect)(()=>{g(1)},[]),(0,W.useEffect)(()=>{e&&b(e)},[e]),(0,W.useEffect)(()=>{if(!x.current){x.current=!0;return}b(null)},[]),(0,W.useEffect)(()=>{g(1),b(null)},[]);let V=(0,W.useMemo)(()=>(w?.items??[]).map(e=>{let n=e.instanceId??e.commit?.instanceId??e.event?.instanceId,r=n?`[${n}] `:``;if(e.type===`commit`&&e.commit){let i=e.commit;return{type:`commit`,id:m1(i,n),outcome:`--`,duration:`--`,actor:i.actorId,client:i.clientId,detail:`${r}${i.changeCount} chg | ${(i.affectedTables??[]).join(`, `)}`,time:u1(e.timestamp,t.timeFormat)}}let i=e.event;return i?{type:i.eventType,id:h1(i,n),outcome:i.outcome,duration:`${i.durationMs}ms`,actor:i.actorId,client:i.clientId,detail:`${r}${(i.tables??[]).join(`, `)||`--`}`,time:u1(e.timestamp,t.timeFormat)}:{type:`pull`,id:`E?`,outcome:`unknown`,duration:`--`,actor:``,client:``,detail:`--`,time:u1(e.timestamp,t.timeFormat)}}),[t.timeFormat,w?.items]),H=w?.total??0,U=Math.max(1,Math.ceil(H/a)),te=T,ne=[{label:``,options:[{id:`all`,label:`All`},{id:`commits`,label:`Commits`},{id:`events`,label:`Events`}],activeId:s,onActiveChange:e=>{c(e),e===`commits`&&(u(`all`),f(`all`)),g(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:r,onActiveChange:e=>{i(e),g(1)}},{label:`Type`,options:[{id:`all`,label:`All`},{id:`push`,label:`Push`},{id:`pull`,label:`Pull`}],activeId:l,onActiveChange:e=>{u(e),g(1)}},{label:`Outcome`,options:[{id:`all`,label:`All`},{id:`applied`,label:`Applied`},{id:`error`,label:`Error`},{id:`rejected`,label:`Rejected`}],activeId:d,onActiveChange:e=>{f(e),g(1)}}];function re(){D.mutate(void 0,{onSuccess:()=>{v(!1),E()}})}return(0,G.jsxs)(`div`,{className:`flex flex-col h-full`,children:[te&&V.length===0?(0,G.jsx)(`div`,{className:`flex items-center justify-center py-24`,children:(0,G.jsx)(dV,{size:`lg`})}):(0,G.jsx)(rH,{entries:V,selectedEntryId:y,onEntryClick:e=>b(e.id),filterBar:(0,G.jsx)(yV,{groups:ne,searchValue:p,searchPlaceholder:`Use actor:, client:, table:, request:, trace: or free text...`,onSearchChange:m,actions:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Q,{size:`sm`,variant:`ghost`,onClick:()=>void E(),children:`Refresh`}),(0,G.jsx)(Q,{size:`sm`,variant:`ghost`,children:`Export`}),(0,G.jsx)(Q,{size:`sm`,variant:`destructive`,onClick:()=>v(!0),children:`Clear`})]})}),pagination:(0,G.jsx)(IZ,{page:h,totalPages:U,totalItems:H,onPageChange:g})}),(0,G.jsx)(kZ,{open:y!==null,onOpenChange:e=>{e||b(null)},children:(0,G.jsxs)(jZ,{children:[(0,G.jsx)(MZ,{children:(0,G.jsx)(PZ,{children:A===void 0?j===void 0?`Entry details`:`Event E${j}`:`Commit #${A}`})}),(0,G.jsx)(`div`,{className:`px-5 py-4 space-y-3 max-h-[70vh] overflow-y-auto`,children:N||I?(0,G.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,G.jsx)(dV,{size:`sm`})}):P||L?(0,G.jsx)(`p`,{className:`font-mono text-[11px] text-offline`,children:`Failed to load details.`}):M?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 font-mono text-[11px]`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Actor`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:M.actorId})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Client`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:M.clientId})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Instance`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:M.instanceId??`--`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Created`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:u1(M.createdAt,t.timeFormat)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Changes`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:M.changeCount})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2`,children:`Affected Tables`}),(0,G.jsx)(`p`,{className:`font-mono text-[11px] text-neutral-200`,children:M.affectedTables.join(`, `)||`--`})]}),(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-wider text-neutral-500`,children:`Changes`}),M.changes.length===0?(0,G.jsx)(`p`,{className:`font-mono text-[11px] text-neutral-500`,children:`No changes recorded.`}):M.changes.map(e=>(0,G.jsxs)(`div`,{className:`rounded-md border border-border p-3 space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between font-mono text-[11px]`,children:[(0,G.jsxs)(`span`,{className:`text-neutral-300`,children:[e.table,` | `,e.op]}),(0,G.jsxs)(`span`,{className:`text-neutral-500`,children:[`#`,e.changeId]})]}),(0,G.jsxs)(`div`,{className:`font-mono text-[11px] text-neutral-400`,children:[`rowId: `,e.rowId,e.rowVersion===null?``:` | version: ${e.rowVersion}`]}),(0,G.jsx)(`pre`,{className:`font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200`,children:p1(e.rowJson)})]},e.changeId))]})]}):F?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 font-mono text-[11px]`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Type`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:F.eventType})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Path`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:F.syncPath})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Instance`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:F.instanceId??`--`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Outcome`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:F.outcome})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Response Status`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:F.responseStatus})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Actor`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:F.actorId})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Client`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:F.clientId})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Status`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:F.statusCode})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Transport`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:F.transportPath})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Duration`}),(0,G.jsxs)(`div`,{className:`text-neutral-100`,children:[F.durationMs,`ms`]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Request ID`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:F.requestId})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Trace ID`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:F.traceId??`--`}),B&&(0,G.jsx)(`a`,{href:B,target:`_blank`,rel:`noreferrer`,className:`font-mono text-[10px] text-flow underline underline-offset-4`,children:`Open external trace`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Span ID`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:F.spanId??`--`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Commit Seq`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:F.commitSeq??`--`}),F.commitSeq!==null&&(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:()=>b(`#${F.instanceId?`${F.instanceId}:`:``}${F.commitSeq}`),children:`Open linked commit`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Subscription Count`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:F.subscriptionCount??`--`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Error Code`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:F.errorCode??`--`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Payload Ref`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:F.payloadRef??`--`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-neutral-500`,children:`Created`}),(0,G.jsx)(`div`,{className:`text-neutral-100`,children:u1(F.createdAt,t.timeFormat)})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2`,children:`Tables`}),(0,G.jsx)(`p`,{className:`font-mono text-[11px] text-neutral-200`,children:F.tables.join(`, `)||`--`})]}),F.scopesSummary&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2`,children:`Scopes Summary`}),(0,G.jsx)(`pre`,{className:`font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200`,children:p1(F.scopesSummary)})]}),F.payloadRef&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2`,children:`Payload Snapshot`}),R?(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(dV,{size:`sm`}),(0,G.jsx)(`span`,{className:`font-mono text-[11px] text-neutral-400`,children:`Loading payload snapshot...`})]}):z?(0,G.jsx)(`p`,{className:`font-mono text-[11px] text-offline`,children:`Failed to load payload snapshot.`}):ee?(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-wider text-neutral-500`,children:`Request`}),(0,G.jsx)(`pre`,{className:`font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200`,children:p1(ee.requestPayload)}),(0,G.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-wider text-neutral-500`,children:`Response`}),(0,G.jsx)(`pre`,{className:`font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200`,children:p1(ee.responsePayload)})]}):(0,G.jsx)(`p`,{className:`font-mono text-[11px] text-neutral-500`,children:`No payload snapshot available.`})]}),F.errorMessage&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2`,children:`Error`}),(0,G.jsx)(`p`,{className:`font-mono text-[11px] text-offline`,children:F.errorMessage})]})]}):(0,G.jsx)(`p`,{className:`font-mono text-[11px] text-neutral-500`,children:`No details available for this row.`})}),(0,G.jsx)(NZ,{children:(0,G.jsx)(Q,{variant:`default`,size:`sm`,onClick:()=>b(null),children:`Close`})})]})}),(0,G.jsx)(kZ,{open:_,onOpenChange:e=>{e||v(!1)},children:(0,G.jsxs)(jZ,{children:[(0,G.jsx)(MZ,{children:(0,G.jsx)(PZ,{children:`Clear all events`})}),(0,G.jsx)(`div`,{className:`p-4`,children:(0,G.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?`})}),(0,G.jsxs)(NZ,{children:[(0,G.jsx)(Q,{variant:`default`,size:`sm`,onClick:()=>v(!1),children:`Cancel`}),(0,G.jsx)(Q,{variant:`destructive`,size:`sm`,onClick:re,disabled:D.isPending,children:D.isPending?`Clearing...`:`Clear all`})]})]})})]})}var v1=Hv({getParentRoute:()=>p$,path:`/config`,component:A$}),y1=Hv({getParentRoute:()=>p$,path:`/fleet`,component:G$}),b1=Hv({getParentRoute:()=>p$,path:`/`,component:O$});function x1(){let{seq:e}=S1.useParams();return(0,G.jsx)(_1,{initialSelectedEntryId:`#${e}`})}var S1=Hv({getParentRoute:()=>p$,path:`/investigate/commit/$seq`,component:x1});function C1(){let{id:e}=w1.useParams();return(0,G.jsx)(_1,{initialSelectedEntryId:`E${e}`})}var w1=Hv({getParentRoute:()=>p$,path:`/investigate/event/$id`,component:C1}),T1=Hv({getParentRoute:()=>p$,path:`/ops`,component:e1}),E1=Hv({getParentRoute:()=>p$,path:`/storage`,component:l1}),D1=Hv({getParentRoute:()=>p$,path:`/stream`,component:_1}),O1=p$.addChildren([b1,D1,S1,w1,y1,T1,E1,v1]),k1=`syncular-console-basepath`,A1=`syncular-console-server-url`,j1=`syncular-console-token`;function M1(e){if(!e)return;let t=e.trim();return t.length>0?t:void 0}function N1(e){let t=globalThis.document;if(!t)return;let n=t.querySelector(`meta[name="${e}"]`)?.getAttribute(`content`);return M1(n)}function P1(e){return!e||e===`/`?`/`:(e.startsWith(`/`)?e:`/${e}`).replace(/\/+$/g,``)||`/`}function F1(){return P1(N1(k1))}function I1(){let e=N1(A1),t=N1(j1);return!e||!t?null:{serverUrl:e,token:t}}function L1(){return new Vm({defaultOptions:{queries:{staleTime:5e3,retry:1}}})}function R1(e){return P1(e??F1())}function z1(e){let[t]=(0,W.useState)(()=>L1()),n=(0,W.useMemo)(()=>iy({routeTree:O1,basepath:R1(e.basePath)}),[e.basePath]);return(0,G.jsx)(Gm,{client:t,children:(0,G.jsx)(My,{defaultConfig:e.defaultConfig===void 0?I1():e.defaultConfig,autoConnect:e.autoConnect??e.defaultConfig===void 0,storageMode:e.storageMode,children:(0,G.jsx)(sy,{router:n})})})}function B1(e){return(0,G.jsx)(`div`,{className:o$,children:(0,G.jsx)(z1,{...e})})}function V1(e){if(typeof e!=`string`)return e;let t=document.querySelector(e);if(!t)throw Error(`Unable to mount console: ${e} not found`);return t}function H1(e,t={}){let n=V1(e);s$(n);let r=(0,Cy.createRoot)(n),i=(0,G.jsx)(B1,{basePath:t.basePath,defaultConfig:t.defaultConfig,autoConnect:t.autoConnect});return t.strictMode===!1?(r.render(i),r):(r.render((0,G.jsx)(W.StrictMode,{children:i})),r)}var U1=`syncular-sentry-dsn`,W1=`syncular-sentry-environment`,G1=`syncular-sentry-release`;function K1(e){if(!e)return;let t=e.trim();return t.length>0?t:void 0}function q1(e){if(typeof document>`u`)return;let t=document.querySelector(`meta[name="${e}"]`)?.getAttribute(`content`);return K1(t)}function J1(e){if(!(typeof process>`u`))return K1({}[e])}function Y1(e){for(let t of e)if(t)return t}function X1(){let e=Y1([K1(globalThis.__SYNCULAR_SENTRY_DSN__),q1(U1),J1(`SYNCULAR_SENTRY_DSN`)]);return e?{dsn:e,environment:Y1([K1(globalThis.__SYNCULAR_SENTRY_ENVIRONMENT__),q1(W1),J1(`SYNCULAR_SENTRY_ENVIRONMENT`)]),release:Y1([K1(globalThis.__SYNCULAR_SENTRY_RELEASE__),q1(G1),J1(`SYNCULAR_SENTRY_RELEASE`)]),enableLogs:!0,tracesSampleRate:.2,tracePropagationTargets:[/^https?:\/\/.*\/api\/.*/]}:null}var Z1=X1();Z1&&Tp(Z1),H1(`#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-BTKRgafL.js"></script>
|
|
14
14
|
<link rel="stylesheet" crossorigin href="/assets/index-DDuDtRhp.css">
|
|
15
15
|
</head>
|
|
16
16
|
<body class="syncular-console-root min-h-screen bg-background text-foreground">
|