@syncular/console 0.0.6-73 → 0.0.6-80
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.
|
@@ -71,8 +71,8 @@ Error generating stack: `+u.message+`
|
|
|
71
71
|
`);return`${i} [data-chart='${t}'] {
|
|
72
72
|
${a}
|
|
73
73
|
}`}).join(`
|
|
74
|
-
`)}})}const j9=_.forwardRef(({active:e,className:t,color:n,formatter:s,hideIndicator:i=!1,hideLabel:a=!1,indicator:l="dot",label:f,labelClassName:d,labelFormatter:p,labelKey:g,nameKey:y,payload:b},x)=>{const{config:S}=C9(),w=_.useMemo(()=>{if(a||!b?.length)return null;const C=b[0];if(!C)return null;const O=`${g||C.dataKey||C.name||"value"}`,N=XT(S,C,O),R=!g&&typeof f=="string"?S[f]?.label??f:N?.label;return p?h.jsx("div",{className:ge("font-medium",d),children:p(R??"",b)}):R?h.jsx("div",{className:ge("font-medium",d),children:R}):null},[S,a,f,d,p,g,b]);if(!e||!b?.length)return null;const T=b.length===1&&l!=="dot";return h.jsxs("div",{className:ge("grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-surface px-2.5 py-1.5 text-xs shadow-xl",t),ref:x,children:[T?null:w,h.jsx("div",{className:"grid gap-1.5",children:b.map((C,O)=>{const N=`${y||C.name||C.dataKey||"value"}`,R=XT(S,C,N),M=n||C.payload?.fill||C.color;return h.jsx("div",{className:ge("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-neutral-500",l==="dot"?"items-center":null),children:s&&C.value!==void 0&&C.name?s(C.value,C.name,C,O,C.payload??{}):h.jsxs(h.Fragment,{children:[R?.icon?h.jsx(R.icon,{}):i?null:h.jsx("div",{className:ge("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",l==="dot"?"h-2.5 w-2.5":null,l==="line"?"w-1":null,l==="dashed"?"w-0 border-[1.5px] border-dashed bg-transparent":null,T&&l==="dashed"?"my-0.5":null),style:{"--color-bg":M,"--color-border":M}}),h.jsxs("div",{className:ge("flex flex-1 justify-between leading-none",T?"items-end":"items-center"),children:[h.jsxs("div",{className:"grid gap-1.5",children:[T?w:null,h.jsx("span",{className:"text-neutral-500",children:R?.label||C.name})]}),C.value!==void 0?h.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:typeof C.value=="number"?C.value.toLocaleString():C.value}):null]})]})},N)})})]})});j9.displayName="ChartTooltipContent";function XT(e,t,n){const s=t.payload?.[n],i=typeof s=="string"?s:null,a=typeof t.dataKey=="string"?t.dataKey:null,l=typeof t.name=="string"?t.name:null;return e[i??a??l??n]}const A9=["1h","6h","24h","7d"],Sj=_.forwardRef(({className:e,bars:t,activeRange:n="1h",onRangeChange:s,startLabel:i="-1h",midLabel:a="-30m",endLabel:l="now",...f},d)=>h.jsxs("div",{ref:d,className:ge("px-5 pt-4 pb-3 border-b border-border",e),...f,children:[h.jsxs("div",{className:"flex items-center justify-between mb-3",children:[h.jsx("span",{className:"font-mono text-[10px] text-neutral-500 uppercase tracking-widest",children:"Activity"}),h.jsxs("div",{className:"flex items-center gap-4",children:[h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("span",{className:"w-2 h-2 rounded-sm bg-healthy/70"}),h.jsx("span",{className:"font-mono text-[9px] text-neutral-500",children:"Push"})]}),h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("span",{className:"w-2 h-2 rounded-sm bg-flow/70"}),h.jsx("span",{className:"font-mono text-[9px] text-neutral-500",children:"Pull"})]}),h.jsx("div",{className:"flex gap-0.5 ml-2",children:A9.map(p=>h.jsx("button",{type:"button",onClick:()=>s?.(p),className:ge("font-mono text-[9px] border rounded-sm px-1.5 py-0.5 cursor-pointer transition-all",p===n?"text-white border-border-bright bg-white/[0.03]":"text-neutral-500 border-transparent hover:text-neutral-300"),children:p},p))})]})]}),h.jsx("div",{className:"flex items-end gap-[2px] h-16",children:t.map((p,g)=>h.jsxs("div",{className:"flex-1 flex flex-col gap-[1px] h-16 justify-end",children:[h.jsx("div",{className:"bg-flow/60 rounded-t-sm min-h-[2px]",style:{height:`${p.pullPercent}%`}}),h.jsx("div",{className:"bg-healthy/60 rounded-t-sm min-h-[2px]",style:{height:`${p.pushPercent}%`}})]},g))}),h.jsxs("div",{className:"flex justify-between mt-1.5",children:[h.jsx("span",{className:"font-mono text-[8px] text-neutral-600",children:i}),h.jsx("span",{className:"font-mono text-[8px] text-neutral-600",children:a}),h.jsx("span",{className:"font-mono text-[8px] text-neutral-600",children:l})]})]}));Sj.displayName="ActivityBars";const QT=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,WT=Hb,gi=(e,t)=>n=>{var s;if(t?.variants==null)return WT(e,n?.class,n?.className);const{variants:i,defaultVariants:a}=t,l=Object.keys(i).map(p=>{const g=n?.[p],y=a?.[p];if(g===null)return null;const b=QT(g)||QT(y);return i[p][b]}),f=n&&Object.entries(n).reduce((p,g)=>{let[y,b]=g;return b===void 0||(p[y]=b),p},{}),d=t==null||(s=t.compoundVariants)===null||s===void 0?void 0:s.reduce((p,g)=>{let{class:y,className:b,...x}=g;return Object.entries(x).every(S=>{let[w,T]=S;return Array.isArray(T)?T.includes({...a,...f}[w]):{...a,...f}[w]===T})?[...p,y,b]:p},[]);return WT(e,l,d,n?.class,n?.className)},k9=gi("bg-surface border border-border rounded-md px-3 py-1.5 text-foreground outline-none w-full transition focus:border-flow placeholder:text-neutral-600",{variants:{variant:{default:"font-sans text-[13px]",mono:"font-mono text-[12px]"}},defaultVariants:{variant:"default"}}),Gn=_.forwardRef(({className:e,variant:t,...n},s)=>h.jsx("input",{ref:s,className:ge(k9({variant:t,className:e})),...n}));Gn.displayName="Input";function pp({controlled:e,default:t,name:n,state:s="value"}){const{current:i}=_.useRef(e!==void 0),[a,l]=_.useState(t),f=i?e:a,d=_.useCallback(p=>{i||l(p)},[]);return[f,d]}const JT={};function zn(e,t){const n=_.useRef(JT);return n.current===JT&&(n.current=e(t)),n}const Ty=P1[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0,-3)],O9=Ty&&Ty!==_.useLayoutEffect?Ty:e=>e();function Ae(e){const t=zn(M9).current;return t.next=e,O9(t.effect),t.trampoline}function M9(){const e={next:void 0,callback:I9,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function I9(){}function oo(e,t,n,s){const i=zn(_j).current;return D9(i,e,t,n,s)&&wj(i,[e,t,n,s]),i.callback}function P9(e){const t=zn(_j).current;return z9(t,e)&&wj(t,e),t.callback}function _j(){return{callback:null,cleanup:null,refs:[]}}function D9(e,t,n,s,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==s||e.refs[3]!==i}function z9(e,t){return e.refs.length!==t.length||e.refs.some((n,s)=>n!==t[s])}function wj(e,t){if(e.refs=t,t.every(n=>n==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&(e.cleanup(),e.cleanup=null),n!=null){const s=Array(t.length).fill(null);for(let i=0;i<t.length;i+=1){const a=t[i];if(a!=null)switch(typeof a){case"function":{const l=a(n);typeof l=="function"&&(s[i]=l);break}case"object":{a.current=n;break}}}e.cleanup=()=>{for(let i=0;i<t.length;i+=1){const a=t[i];if(a!=null)switch(typeof a){case"function":{const l=s[i];typeof l=="function"?l():a(null);break}case"object":{a.current=null;break}}}}}}}const L9=()=>{},Le=typeof document<"u"?_.useLayoutEffect:L9,Ej={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1},mp={...Ej,position:"fixed",top:0,left:0},Tj={...Ej,position:"absolute"};function jn(){}const Ru=Object.freeze([]),an=Object.freeze({});function yn(e,...t){const n=new URL("https://base-ui.com/production-error");return n.searchParams.set("code",e.toString()),t.forEach(s=>n.searchParams.append("args[]",s)),`Base UI error #${e}; visit ${n} for the full message.`}const U9=parseInt(_.version,10);function Kb(e){return U9>=e}function eC(e){if(!_.isValidElement(e))return null;const t=e,n=t.props;return(Kb(19)?n?.ref:t.ref)??null}function Cv(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function $9(e,t){const n={};for(const s in e){const i=e[s];if(t?.hasOwnProperty(s)){const a=t[s](i);a!=null&&Object.assign(n,a);continue}i===!0?n[`data-${s.toLowerCase()}`]="":i&&(n[`data-${s.toLowerCase()}`]=i.toString())}return n}function B9(e,t){return typeof e=="function"?e(t):e}function F9(e,t){return typeof e=="function"?e(t):e}const hu={};function oi(e,t,n,s,i){let a={...Rv(e,hu)};return t&&(a=lu(a,t)),n&&(a=lu(a,n)),s&&(a=lu(a,s)),i&&(a=lu(a,i)),a}function H9(e){if(e.length===0)return hu;if(e.length===1)return Rv(e[0],hu);let t={...Rv(e[0],hu)};for(let n=1;n<e.length;n+=1)t=lu(t,e[n]);return t}function lu(e,t){return Cj(t)?t(e):q9(e,t)}function q9(e,t){if(!t)return e;for(const n in t){const s=t[n];switch(n){case"style":{e[n]=Cv(e.style,s);break}case"className":{e[n]=Rj(e.className,s);break}default:V9(n,s)?e[n]=K9(e[n],s):e[n]=s}}return e}function V9(e,t){const n=e.charCodeAt(0),s=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&s===110&&i>=65&&i<=90&&(typeof t=="function"||typeof t>"u")}function Cj(e){return typeof e=="function"}function Rv(e,t){return Cj(e)?e(t):e??hu}function K9(e,t){return t?e?n=>{if(G9(n)){const i=n;Nv(i);const a=t(i);return i.baseUIHandlerPrevented||e?.(i),a}const s=t(n);return e?.(n),s}:t:e}function Nv(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function Rj(e,t){return t?e?t+" "+e:t:e}function G9(e){return e!=null&&typeof e=="object"&&"nativeEvent"in e}const Z9={style:{transition:"none"}},Y9="data-base-ui-click-trigger",X9={fallbackAxisSide:"none"},Q9={fallbackAxisSide:"end"},W9={clipPath:"inset(50%)",position:"fixed",top:0,left:0};function zt(e,t,n={}){const s=t.render,i=J9(t,n);if(n.enabled===!1)return null;const a=n.state??an;return t8(e,s,i,a)}function J9(e,t={}){const{className:n,style:s,render:i}=e,{state:a=an,ref:l,props:f,stateAttributesMapping:d,enabled:p=!0}=t,g=p?B9(n,a):void 0,y=p?F9(s,a):void 0,b=p?$9(a,d):an,x=p?Cv(b,Array.isArray(f)?H9(f):f)??an:an;return typeof document<"u"&&(p?Array.isArray(l)?x.ref=P9([x.ref,eC(i),...l]):x.ref=oo(x.ref,eC(i),l):oo(null,null)),p?(g!==void 0&&(x.className=Rj(x.className,g)),y!==void 0&&(x.style=Cv(x.style,y)),x):an}const e8=Symbol.for("react.lazy");function t8(e,t,n,s){if(t){if(typeof t=="function")return t(n,s);const i=oi(n,t.props);i.ref=n.ref;let a=t;return a?.$$typeof===e8&&(a=_.Children.toArray(t)[0]),_.cloneElement(a,i)}if(e&&typeof e=="string")return n8(e,n);throw new Error(yn(8))}function n8(e,t){return e==="button"?_.createElement("button",{type:"button",...t,key:t.key}):e==="img"?_.createElement("img",{alt:"",...t,key:t.key}):_.createElement(e,t)}const r8={...P1};let tC=0;function s8(e,t="mui"){const[n,s]=_.useState(e),i=e||n;return _.useEffect(()=>{n==null&&(tC+=1,s(`${t}-${tC}`))},[n,t]),i}const nC=r8.useId;function Xu(e,t){if(nC!==void 0){const n=nC();return e??(t?`${t}-${n}`:n)}return s8(e,t)}function br(e){return Xu(e,"base-ui")}function gp(){return typeof window<"u"}function yi(e){return Gb(e)?(e.nodeName||"").toLowerCase():"#document"}function un(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function _s(e){var t;return(t=(Gb(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Gb(e){return gp()?e instanceof Node||e instanceof un(e).Node:!1}function jt(e){return gp()?e instanceof Element||e instanceof un(e).Element:!1}function Zt(e){return gp()?e instanceof HTMLElement||e instanceof un(e).HTMLElement:!1}function jv(e){return!gp()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof un(e).ShadowRoot}const o8=new Set(["inline","contents"]);function vi(e){const{overflow:t,overflowX:n,overflowY:s,display:i}=xr(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+n)&&!o8.has(i)}const i8=new Set(["table","td","th"]);function a8(e){return i8.has(yi(e))}const c8=[":popover-open",":modal"];function yp(e){return c8.some(t=>{try{return e.matches(t)}catch{return!1}})}const l8=["transform","translate","scale","rotate","perspective"],u8=["transform","translate","scale","rotate","perspective","filter"],f8=["paint","layout","strict","content"];function Zb(e){const t=vp(),n=jt(e)?xr(e):e;return l8.some(s=>n[s]?n[s]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||u8.some(s=>(n.willChange||"").includes(s))||f8.some(s=>(n.contain||"").includes(s))}function d8(e){let t=io(e);for(;Zt(t)&&!Xs(t);){if(Zb(t))return t;if(yp(t))return null;t=io(t)}return null}function vp(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const h8=new Set(["html","body","#document"]);function Xs(e){return h8.has(yi(e))}function xr(e){return un(e).getComputedStyle(e)}function bp(e){return jt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function io(e){if(yi(e)==="html")return e;const t=e.assignedSlot||e.parentNode||jv(e)&&e.host||_s(e);return jv(t)?t.host:t}function Nj(e){const t=io(e);return Xs(t)?e.ownerDocument?e.ownerDocument.body:e.body:Zt(t)&&vi(t)?t:Nj(t)}function Wo(e,t,n){var s;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=Nj(e),a=i===((s=e.ownerDocument)==null?void 0:s.body),l=un(i);if(a){const f=Av(l);return t.concat(l,l.visualViewport||[],vi(i)?i:[],f&&n?Wo(f):[])}return t.concat(i,Wo(i,[],n))}function Av(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}const jj=_.createContext(void 0);function Aj(e=!1){const t=_.useContext(jj);if(t===void 0&&!e)throw new Error(yn(16));return t}function p8(e){const{focusableWhenDisabled:t,disabled:n,composite:s=!1,tabIndex:i=0,isNativeButton:a}=e,l=s&&t!==!1,f=s&&t===!1;return{props:_.useMemo(()=>{const p={onKeyDown(g){n&&t&&g.key!=="Tab"&&g.preventDefault()}};return s||(p.tabIndex=i,!a&&n&&(p.tabIndex=t?i:-1)),(a&&(t||l)||!a&&n)&&(p["aria-disabled"]=n),a&&(!t||f)&&(p.disabled=n),p},[s,n,t,l,f,a,i])}}function Jc(e={}){const{disabled:t=!1,focusableWhenDisabled:n,tabIndex:s=0,native:i=!0}=e,a=_.useRef(null),l=Aj(!0)!==void 0,f=Ae(()=>{const b=a.current;return!!(b?.tagName==="A"&&b?.href)}),{props:d}=p8({focusableWhenDisabled:n,disabled:t,composite:l,tabIndex:s,isNativeButton:i}),p=_.useCallback(()=>{const b=a.current;m8(b)&&l&&t&&d.disabled===void 0&&b.disabled&&(b.disabled=!1)},[t,d.disabled,l]);Le(p,[p]);const g=_.useCallback((b={})=>{const{onClick:x,onMouseDown:S,onKeyUp:w,onKeyDown:T,onPointerDown:C,...O}=b;return oi({type:i?"button":void 0,onClick(R){if(t){R.preventDefault();return}x?.(R)},onMouseDown(R){t||S?.(R)},onKeyDown(R){if(t||(Nv(R),T?.(R)),R.baseUIHandlerPrevented)return;const M=R.target===R.currentTarget&&!i&&!f()&&!t,z=R.key==="Enter",j=R.key===" ";M&&((j||z)&&R.preventDefault(),z&&x?.(R))},onKeyUp(R){t||(Nv(R),w?.(R)),!R.baseUIHandlerPrevented&&R.target===R.currentTarget&&!i&&!t&&R.key===" "&&x?.(R)},onPointerDown(R){if(t){R.preventDefault();return}C?.(R)}},i?void 0:{role:"button"},d,O)},[t,d,i,f]),y=Ae(b=>{a.current=b,p()});return{getButtonProps:g,buttonRef:y}}function m8(e){return Zt(e)&&e.tagName==="BUTTON"}const kj=_.createContext(void 0);function g8(){const e=_.useContext(kj);if(e===void 0)throw new Error(yn(63));return e}let rC=(function(e){return e.disabled="data-disabled",e.valid="data-valid",e.invalid="data-invalid",e.touched="data-touched",e.dirty="data-dirty",e.filled="data-filled",e.focused="data-focused",e})({});const xp={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},bi={valid(e){return e===null?null:e?{[rC.valid]:""}:{[rC.invalid]:""}}};let sC=(function(e){return e.checked="data-checked",e.unchecked="data-unchecked",e.disabled="data-disabled",e.readonly="data-readonly",e.required="data-required",e.valid="data-valid",e.invalid="data-invalid",e.touched="data-touched",e.dirty="data-dirty",e.filled="data-filled",e.focused="data-focused",e})({});const Oj={...bi,checked(e){return e?{[sC.checked]:""}:{[sC.unchecked]:""}}};function kv(e,t){return{...e,state:{...e.state,valid:!t&&e.state.valid}}}const y8=_.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:jn,validationMode:"onSubmit",submitAttemptedRef:{current:!1}});function el(){return _.useContext(y8)}const Mj=_.createContext({invalid:void 0,name:void 0,validityData:{state:xp,errors:[],error:"",value:"",initialValue:null},setValidityData:jn,disabled:void 0,touched:!1,setTouched:jn,dirty:!1,setDirty:jn,filled:!1,setFilled:jn,focused:!1,setFocused:jn,validate:()=>null,validationMode:"onSubmit",validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:{disabled:!1,valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},markedDirtyRef:{current:!1},validation:{getValidationProps:(e=an)=>e,getInputValidationProps:(e=an)=>e,inputRef:{current:null},commit:async()=>{}}});function xi(e=!0){const t=_.useContext(Mj);if(t.setValidityData===jn&&!e)throw new Error(yn(28));return t}function Ij(e){const{enabled:t=!0,value:n,id:s,name:i,controlRef:a,commit:l}=e,{formRef:f}=el(),{invalid:d,markedDirtyRef:p,validityData:g,setValidityData:y}=xi(),b=Ae(e.getValue);Le(()=>{if(!t)return;let x=n;x===void 0&&(x=b()),g.initialValue===null&&x!==null&&y(S=>({...S,initialValue:x}))},[t,y,n,g.initialValue,b]),Le(()=>{!t||!s||f.current.fields.set(s,{getValue:b,name:i,controlRef:a,validityData:kv(g,d),validate(x=!0){let S=n;S===void 0&&(S=b()),p.current=!0,x?hi.flushSync(()=>l(S)):l(S)}})},[l,a,t,f,b,s,d,p,i,g,n]),Le(()=>{const x=f.current.fields;return()=>{s&&x.delete(s)}},[f,s])}const Pj=_.createContext({controlId:void 0,registerControlId:jn,labelId:void 0,setLabelId:jn,messageIds:[],setMessageIds:jn,getDescriptionProps:e=>e});function lo(){return _.useContext(Pj)}function Dj(e={}){const{id:t,implicit:n=!1,controlRef:s}=e,{controlId:i,registerControlId:a}=lo(),l=br(t),f=n?i:void 0,d=zn(()=>Symbol("labelable-control")),p=_.useRef(!1),g=_.useRef(t!=null),y=Ae(()=>{!p.current||a===jn||(p.current=!1,a(d.current,void 0))});return Le(()=>{if(a===jn)return;let b;if(n){const x=s?.current;jt(x)&&x.closest("label")!=null?b=t??null:b=f??l}else if(t!=null)g.current=!0,b=t;else if(g.current)b=l;else{y();return}if(b===void 0){y();return}p.current=!0,a(d.current,b)},[t,s,f,a,n,l,d,y]),_.useEffect(()=>y,[y]),i??l}const ii="none",oC="trigger-press",Ov="trigger-hover",zj="outside-press",Cy="item-press",Lj="focus-out",v8="escape-key",b8="cancel-open",x8="imperative-action",S8="window-resize";function Yt(e,t,n,s){let i=!1,a=!1;const l=s??an;return{reason:e,event:t??new Event("base-ui"),cancel(){i=!0},allowPropagation(){a=!0},get isCanceled(){return i},get isPropagationAllowed(){return a},trigger:n,...l}}function Uj(e,t){const n=_.useRef(e),s=Ae(t);Le(()=>{n.current!==e&&s(n.current)},[e,s]),Le(()=>{n.current=e},[e])}const _8=_.forwardRef(function(t,n){const{checked:s,className:i,defaultChecked:a,id:l,inputRef:f,name:d,nativeButton:p=!1,onCheckedChange:g,readOnly:y=!1,required:b=!1,disabled:x=!1,render:S,uncheckedValue:w,value:T,...C}=t,{clearErrors:O}=el(),{state:N,setTouched:R,setDirty:M,validityData:z,setFilled:j,setFocused:A,shouldValidateOnChange:P,validationMode:Q,disabled:B,name:U,validation:Z}=xi(),{labelId:K}=lo(),ee=B||x,D=U??d,G=Ae(g),q=_.useRef(null),V=oo(q,f,Z.inputRef),L=_.useRef(null),I=br(),H=Dj({id:l,implicit:!1,controlRef:L}),W=p?void 0:H,[Y,ae]=pp({controlled:s,default:!!a,name:"Switch",state:"checked"});Ij({id:I,commit:Z.commit,value:Y,controlRef:L,name:D,getValue:()=>Y}),Le(()=>{q.current&&j(q.current.checked)},[q,j]),Uj(Y,()=>{O(D),M(Y!==z.initialValue),j(Y),P()?Z.commit(Y):Z.commit(Y,!0)});const{getButtonProps:se,buttonRef:fe}=Jc({disabled:ee,native:p}),Se={id:p?H:I,role:"switch","aria-checked":Y,"aria-readonly":y||void 0,"aria-required":b||void 0,"aria-labelledby":K,onFocus(){ee||A(!0)},onBlur(){const re=q.current;!re||ee||(R(!0),A(!1),Q==="onBlur"&&Z.commit(re.checked))},onClick(re){y||ee||(re.preventDefault(),q.current?.dispatchEvent(new PointerEvent("click",{bubbles:!0,shiftKey:re.shiftKey,ctrlKey:re.ctrlKey,altKey:re.altKey,metaKey:re.metaKey})))}},pe=_.useMemo(()=>oi({checked:Y,disabled:ee,id:W,name:D,required:b,style:D?Tj:mp,tabIndex:-1,type:"checkbox","aria-hidden":!0,ref:V,onChange(re){if(re.nativeEvent.defaultPrevented)return;const he=re.target.checked,ie=Yt(ii,re.nativeEvent);G?.(he,ie),!ie.isCanceled&&ae(he)},onFocus(){L.current?.focus()}},Z.getInputValidationProps,T!==void 0?{value:T}:an),[Y,ee,V,W,D,G,b,ae,Z,T]),Oe=_.useMemo(()=>({...N,checked:Y,disabled:ee,readOnly:y,required:b}),[N,Y,ee,y,b]),_e=zt("span",t,{state:Oe,ref:[n,L,fe],props:[Se,Z.getValidationProps,C,se],stateAttributesMapping:Oj});return h.jsxs(kj.Provider,{value:Oe,children:[_e,!Y&&D&&w!==void 0&&h.jsx("input",{type:"hidden",name:D,value:w}),h.jsx("input",{...pe})]})}),w8=_.forwardRef(function(t,n){const{render:s,className:i,...a}=t,{state:l}=xi(),f=g8(),d={...l,...f};return zt("span",t,{state:d,ref:n,stateAttributesMapping:Oj,props:a})}),Sp=_.forwardRef(({className:e,...t},n)=>h.jsx(_8,{ref:n,className:ge("relative w-[34px] h-[18px] bg-border-bright rounded-full cursor-pointer transition data-[checked]:bg-healthy",e),...t,children:h.jsx(w8,{className:"block w-[14px] h-[14px] bg-white rounded-full transition-transform data-[checked]:translate-x-4 absolute top-0.5 left-0.5"})}));Sp.displayName="Switch";const $j=_.forwardRef(({className:e,enabled:t=!0,onEnabledChange:n,thresholds:s,onThresholdsChange:i,...a},l)=>{function f(d,p){const g=Number(p);Number.isFinite(g)&&i?.({...s,[d]:g})}return h.jsxs("div",{ref:l,className:ge("bg-panel border border-border rounded-lg hover:border-border-bright transition",e),...a,children:[h.jsxs("div",{className:"px-4 py-2.5 border-b border-border flex items-center justify-between",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-offline"}),h.jsx("span",{className:"font-mono text-[10px] text-neutral-500 uppercase tracking-widest",children:"Alerts"})]}),h.jsx(Sp,{checked:t,onCheckedChange:d=>n?.(d)})]}),h.jsxs("div",{className:"p-4 space-y-3",children:[h.jsx(Ry,{label:"P90 latency threshold",value:s.p90Latency,onChange:d=>f("p90Latency",d)}),h.jsx(Ry,{label:"Error rate threshold",value:s.errorRate,onChange:d=>f("errorRate",d)}),h.jsx(Ry,{label:"Client lag threshold",value:s.clientLag,onChange:d=>f("clientLag",d)})]})]})});$j.displayName="AlertsConfig";function Ry({label:e,value:t,onChange:n}){return h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("span",{className:"font-mono text-[10px] text-neutral-500",children:e}),h.jsx(Gn,{variant:"mono",type:"number",value:t,onChange:s=>n(s.target.value),className:"w-[100px] text-[11px] px-2 py-1 text-right"})]})}const E8=gi("inline-flex items-center gap-1 px-2 py-0.5 rounded-sm font-mono text-[9px] leading-normal uppercase tracking-wider",{variants:{variant:{default:"bg-white/[0.05] text-neutral-300 border border-border-bright",destructive:"bg-offline/10 text-offline border border-offline/20",ghost:"bg-transparent text-neutral-500 border border-border-bright",outline:"bg-transparent text-neutral-400 border border-border-bright",secondary:"bg-panel text-neutral-400 border border-border",healthy:"bg-healthy/10 text-healthy border border-healthy/20",syncing:"bg-syncing/10 text-syncing border border-syncing/20",offline:"bg-offline/10 text-offline border border-offline/20",flow:"bg-flow/10 text-flow border border-flow/20",relay:"bg-relay/10 text-relay border border-relay/20"}},defaultVariants:{variant:"default"}}),mn=_.forwardRef(({className:e,variant:t,style:n,...s},i)=>h.jsx("span",{ref:i,className:ge(E8({variant:t,className:e})),style:{lineHeight:1,...n},...s}));mn.displayName="Badge";const tl=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,role:"table",className:ge("w-full",e),...t}));tl.displayName="Table";const nl=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,role:"rowgroup",className:ge(e),...t}));nl.displayName="TableHeader";const rl=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,role:"rowgroup",className:ge(e),...t}));rl.displayName="TableBody";const ss=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,role:"row",className:ge("font-mono text-[11px] leading-6 px-4 flex items-center gap-4 border-b border-[#141414] hover:bg-white/[0.015] transition-colors cursor-default",e),...t}));ss.displayName="TableRow";const ht=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,role:"columnheader",className:ge("min-w-0 font-mono text-[9px] text-neutral-600 uppercase tracking-wider leading-6 bg-white/[0.01] text-left truncate",e),...t}));ht.displayName="TableHead";const pt=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,role:"cell",className:ge("min-w-0 whitespace-nowrap overflow-hidden text-ellipsis",e),...t}));pt.displayName="TableCell";const T8={relay:"relay",admin:"flow",proxy:"ghost"},C8=_.forwardRef(({className:e,keys:t,onCreateKey:n,onRotateKey:s,onRevokeKey:i,...a},l)=>h.jsx("div",{ref:l,className:ge("w-full",e),...a,children:h.jsxs(tl,{children:[h.jsx(nl,{children:h.jsxs(ss,{children:[h.jsx(ht,{children:"Name"}),h.jsx(ht,{children:"Type"}),h.jsx(ht,{children:"Prefix"}),h.jsx(ht,{children:"Created"})]})}),h.jsx(rl,{children:t.map((f,d)=>h.jsxs(ss,{className:"group relative",children:[h.jsx(pt,{children:h.jsx("span",{className:"text-white truncate",children:f.name})}),h.jsx(pt,{children:h.jsx(mn,{variant:T8[f.type]??"ghost",children:f.type})}),h.jsx(pt,{children:h.jsx("span",{className:"text-neutral-500 truncate",children:f.prefix})}),h.jsx(pt,{children:h.jsx("span",{className:"text-neutral-600 truncate",children:f.created})}),(s||i)&&h.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[s&&h.jsx("button",{type:"button",onClick:()=>s(f.name),className:"flex items-center gap-1 px-1.5 py-0.5 rounded text-[9px] text-neutral-600 hover:text-white hover:bg-white/[0.05] cursor-pointer transition-colors",children:"rotate"}),i&&h.jsx("button",{type:"button",onClick:()=>i(f.name),className:"flex items-center gap-1 px-1.5 py-0.5 rounded text-[9px] text-neutral-600 hover:text-offline hover:bg-offline/10 cursor-pointer transition-colors",children:"revoke"})]})]},`${f.name}:${f.prefix}:${d}`))})]})}));C8.displayName="ApiKeysTable";const Bj=_.forwardRef(({className:e,metrics:t=[],uptime:n,isLive:s=!0,...i},a)=>h.jsxs("div",{ref:a,className:ge("fixed bottom-0 left-0 right-0 z-100 h-8 border-t border-border bg-surface/92 backdrop-blur-lg flex items-center justify-between px-5",e),...i,children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx("div",{className:"flex items-center gap-[2px]",children:[0,.1,.2,.3,.4].map(l=>h.jsx("div",{className:"w-0.5 h-1.5 bg-healthy rounded-sm animate-[heartbeat_1.2s_ease-in-out_infinite]",style:{animationDelay:`${l}s`}},l))}),s&&h.jsx("span",{className:"font-mono text-[9px] text-healthy uppercase tracking-widest",children:"Live"})]}),h.jsx("div",{className:"flex items-center gap-6",children:t.map(l=>h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("span",{className:"font-mono text-[9px] text-neutral-600",children:l.label}),h.jsx("span",{className:"font-mono text-[10px] text-neutral-300",children:l.value})]},l.label))}),n!=null&&h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"font-mono text-[9px] text-neutral-600",children:"UPTIME"}),h.jsx("span",{className:"font-mono text-[10px] text-neutral-400",children:n})]})]}));Bj.displayName="BottomBar";const Fj=_.forwardRef(({className:e,commits:t,onViewAll:n,...s},i)=>h.jsxs("div",{ref:i,className:ge("px-5 pt-3 pb-2",e),...s,children:[h.jsxs("div",{className:"flex items-center justify-between mb-2",children:[h.jsx("span",{className:"font-mono text-[10px] text-neutral-500 uppercase tracking-widest",children:"Recent Commits"}),n&&h.jsx("button",{type:"button",onClick:n,className:"inline-flex items-center gap-1.5 rounded-md font-mono text-[9px] px-2 py-0.5 border border-border-bright bg-transparent text-neutral-400 hover:text-white hover:bg-white/[0.03] cursor-pointer transition-all",children:"View all →"})]}),h.jsxs("div",{className:"font-mono text-[9px] tracking-wider uppercase text-neutral-600 flex items-center gap-4 px-4 leading-[22px] border-b border-border",children:[h.jsx("span",{className:"w-[60px] truncate",children:"Seq"}),h.jsx("span",{className:"w-[100px] truncate",children:"Actor"}),h.jsx("span",{className:"w-[50px] truncate",children:"Chg"}),h.jsx("span",{className:"flex-1 truncate",children:"Tables"}),h.jsx("span",{className:"w-[70px] text-right truncate",children:"Time"})]}),t.map(a=>h.jsxs("div",{className:"font-mono text-[11px] leading-7 px-4 flex items-center gap-4 border-b border-[#141414] hover:bg-white/[0.015] transition-colors cursor-default",children:[h.jsxs("span",{className:"w-[60px] text-flow font-medium truncate",children:["#",a.seq]}),h.jsx("span",{className:"w-[100px] text-neutral-400 truncate",children:a.actor}),h.jsx("span",{className:"w-[50px] text-white truncate",children:a.changes}),h.jsx("span",{className:"flex-1 truncate",children:h.jsx("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-sm font-mono text-[9px] uppercase tracking-wider bg-transparent text-neutral-500 border border-border-bright",children:a.tables})}),h.jsx("span",{className:"w-[70px] text-right text-neutral-600 truncate",children:a.time})]},a.seq))]}));Fj.displayName="CommitTable";const Hj=gi("inline-flex items-center justify-center gap-1.5 rounded-md font-mono transition-all cursor-pointer disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"border border-border-bright bg-transparent text-neutral-400 hover:text-white hover:bg-white/[0.03]",primary:"border border-flow bg-flow/10 text-flow hover:bg-flow/20",destructive:"border border-offline bg-offline/10 text-offline hover:bg-offline/20",ghost:"border border-transparent bg-transparent text-neutral-400 hover:text-white hover:bg-white/[0.03]",link:"border border-transparent bg-transparent text-neutral-400 underline underline-offset-4 hover:text-white",secondary:"border border-border bg-panel text-neutral-400 hover:text-white hover:bg-white/[0.03]"},size:{sm:"text-[10px] px-2.5 py-1",md:"text-[11px] px-3.5 py-1.5",icon:"h-8 w-8"}},defaultVariants:{variant:"default",size:"md"}}),Me=_.forwardRef(({className:e,variant:t,size:n,...s},i)=>h.jsx("button",{ref:i,className:ge(Hj({variant:t,size:n,className:e})),...s}));Me.displayName="Button";const qj=_.forwardRef(({className:e,isConnected:t=!1,isConnecting:n=!1,isTestingConnection:s=!1,serverUrl:i,onServerUrlChange:a,consoleToken:l,onConsoleTokenChange:f,onSaveAndConnect:d,onDisconnect:p,onTestConnection:g,statusMessage:y,...b},x)=>h.jsxs("div",{ref:x,className:ge("bg-panel border border-border rounded-lg hover:border-border-bright transition",e),...b,children:[h.jsxs("div",{className:"px-4 py-2.5 border-b border-border flex items-center justify-between",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:ge("w-1.5 h-1.5 rounded-full",t?"bg-healthy":"bg-offline"),style:t?{boxShadow:"0 0 4px #22c55e"}:void 0}),h.jsx("span",{className:"font-mono text-[10px] text-neutral-500 uppercase tracking-widest",children:"Connection"})]}),h.jsx(mn,{variant:t?"healthy":"offline",children:t?"Connected":"Disconnected"})]}),h.jsxs("div",{className:"p-5 space-y-4",children:[h.jsx("p",{className:"font-mono text-[10px] text-neutral-500",children:"Configure the server endpoint and authentication token."}),h.jsxs("div",{children:[h.jsx("label",{htmlFor:"console-server-url",className:"font-mono text-[9px] text-neutral-500 uppercase tracking-wider block mb-1.5",children:"Server URL"}),h.jsx(Gn,{id:"console-server-url",variant:"mono",value:i,onChange:S=>a?.(S.target.value)})]}),h.jsxs("div",{children:[h.jsx("label",{htmlFor:"console-token",className:"font-mono text-[9px] text-neutral-500 uppercase tracking-wider block mb-1.5",children:"Console Token"}),h.jsx(Gn,{id:"console-token",variant:"mono",type:"password",value:l,onChange:S=>f?.(S.target.value)})]}),h.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[h.jsx(Me,{variant:"primary",size:"md",onClick:d,disabled:n,children:n?"Connecting...":"Save + Connect"}),h.jsx(Me,{variant:"default",size:"md",onClick:g,disabled:n||s,children:s?"Testing...":"Test Connection"}),h.jsx(Me,{variant:"destructive",size:"md",onClick:p,disabled:!t,children:"Disconnect"})]}),y&&h.jsx("div",{className:ge("font-mono text-[10px]",t?"text-healthy":"text-offline"),children:y})]})]}));qj.displayName="ConnectionForm";const R8=gi("animate-spin text-neutral-500",{variants:{size:{sm:"h-3 w-3",md:"h-5 w-5",lg:"h-8 w-8"}},defaultVariants:{size:"md"}}),Pt=_.forwardRef(({className:e,size:t,...n},s)=>h.jsxs("svg",{ref:s,className:ge(R8({size:t,className:e})),xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",...n,children:[h.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),h.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}));Pt.displayName="Spinner";function N8({className:e,state:t}){switch(t){case"connected":return h.jsx(mn,{variant:"healthy",className:e,children:"Connected"});case"disconnected":return h.jsx(mn,{variant:"destructive",className:e,children:"Disconnected"});case"connecting":return h.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs text-neutral-400",children:[h.jsx(Pt,{size:"sm"}),"Connecting"]});case"not-configured":return h.jsx(mn,{variant:"ghost",className:e,children:"Not configured"})}}const Yb=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("bg-panel border border-border rounded-lg hover:border-border-bright transition",e),...t}));Yb.displayName="Card";const j8=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("px-4 py-2.5 border-b border-border flex items-center justify-between",e),...t}));j8.displayName="CardHeader";const A8=_.forwardRef(({className:e,...t},n)=>h.jsx("h3",{ref:n,className:ge("font-mono text-[10px] text-neutral-500 uppercase tracking-widest",e),...t}));A8.displayName="CardTitle";const Xb=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("p-4",e),...t}));Xb.displayName="CardContent";const k8=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("px-4 py-2.5 border-t border-border",e),...t}));k8.displayName="CardFooter";function Qb({action:e,className:t,icon:n,message:s}){return h.jsxs("div",{className:ge("flex flex-col items-center justify-center gap-3 py-12",t),children:[n?h.jsx("div",{className:"text-neutral-500",children:n}):null,h.jsx("p",{className:"font-mono text-[10px] text-neutral-500",children:s}),e?h.jsx("div",{children:e}):null]})}const Vj=_.forwardRef(({className:e,groups:t,searchValue:n,searchPlaceholder:s="Filter by client or actor...",onSearchChange:i,actions:a,...l},f)=>h.jsxs("div",{ref:f,className:ge("px-5 py-3 border-b border-border flex items-center gap-4 flex-wrap",e),...l,children:[t.map((d,p)=>h.jsx(O8,{group:d,showDivider:p>0},p)),i!==void 0&&h.jsx("input",{className:"bg-surface border border-border rounded-md font-mono text-[10px] text-foreground outline-none transition focus:border-flow placeholder:text-neutral-600 max-w-[200px] px-2.5 py-1",placeholder:s,value:n,onChange:d=>i(d.target.value)}),a&&h.jsx("div",{className:"ml-auto flex items-center gap-2",children:a})]}));Vj.displayName="FilterBar";function O8({group:e,showDivider:t}){return h.jsxs(h.Fragment,{children:[t&&h.jsx("div",{className:"w-px h-4 bg-border"}),h.jsxs("div",{className:"flex items-center gap-1",children:[e.label&&h.jsx("span",{className:"font-mono text-[9px] text-neutral-500 mr-1",children:e.label}),e.options.map(n=>h.jsx("button",{type:"button",onClick:()=>e.onActiveChange(n.id),className:ge("font-mono text-[10px] border rounded-sm px-2.5 py-0.5 cursor-pointer transition-all",n.id===e.activeId?"text-white border-border-bright bg-white/[0.03]":"text-neutral-500 border-transparent hover:text-neutral-300"),children:n.label},n.id))]})]})}function M8(e){return e===0?"#22c55e":e<10?"#f59e0b":e<50?"#f97316":"#ef4444"}const I8={online:"healthy",syncing:"syncing",offline:"offline"},P8={realtime:"flow",polling:"ghost"},D8=_.forwardRef(({className:e,client:t,headSeq:n,onEvict:s,...i},a)=>{const l=Math.max(0,n-t.cursor),f=Math.min(100,t.cursor/n*100),d=M8(l);return h.jsxs("div",{ref:a,className:ge("bg-panel border border-border rounded-lg hover:border-border-bright transition",e),style:{borderLeft:`3px solid ${d}`},...i,children:[h.jsxs("div",{className:"px-3.5 py-2 border-b border-border flex items-center justify-between",children:[h.jsx("div",{className:"flex items-center gap-2 min-w-0",children:h.jsx("span",{className:"font-mono text-[11px] text-white truncate",title:t.id,children:t.id.length>14?`${t.id.substring(0,14)}…`:t.id})}),h.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[h.jsx(mn,{variant:I8[t.status],children:t.status}),h.jsx(mn,{variant:P8[t.mode],children:t.mode})]})]}),h.jsxs("div",{className:"p-3 space-y-3",children:[h.jsxs("div",{children:[h.jsxs("div",{className:"flex items-center justify-between mb-1",children:[h.jsxs("span",{className:"font-mono text-[9px] text-neutral-600",children:["#",t.cursor.toLocaleString()]}),h.jsxs("span",{className:"font-mono text-[9px] text-neutral-600",children:["#",n.toLocaleString()]})]}),h.jsx("div",{className:"h-1 rounded-full bg-surface",children:h.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${f}%`,background:d}})}),h.jsx("div",{className:"font-mono text-[9px] mt-1",style:{color:d},children:l===0?"Caught up":`${l} behind`})]}),h.jsxs("div",{className:"space-y-1",children:[h.jsx(Ny,{label:"Actor",value:t.actor}),h.jsx(Ny,{label:"Dialect",value:t.dialect}),h.jsx(Ny,{label:"Last seen",value:t.lastSeen}),h.jsxs("div",{className:"flex justify-between items-start",children:[h.jsx("span",{className:"font-mono text-[9px] text-neutral-600",children:"Scopes"}),h.jsxs("div",{className:"flex gap-1 flex-wrap justify-end",children:[t.scopes.slice(0,2).map(p=>h.jsx(mn,{variant:"ghost",children:p},p)),t.scopes.length>2&&h.jsxs("span",{className:"font-mono text-[9px] text-neutral-600",children:["+",t.scopes.length-2]})]})]})]}),s&&h.jsxs("button",{type:"button",onClick:s,className:"w-full inline-flex items-center justify-center gap-1.5 rounded-md font-mono text-[9px] px-2 py-1 border border-offline/25 bg-offline/[0.04] text-offline hover:border-offline hover:bg-offline/[0.08] cursor-pointer transition-all",children:[h.jsxs("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:[h.jsx("path",{d:"M18.36 6.64a9 9 0 11-12.73 0"}),h.jsx("line",{x1:"12",y1:"2",x2:"12",y2:"12"})]}),"Evict"]})]})]})});D8.displayName="FleetCard";function Ny({label:e,value:t}){return h.jsxs("div",{className:"flex justify-between",children:[h.jsx("span",{className:"font-mono text-[9px] text-neutral-600",children:e}),h.jsx("span",{className:"font-mono text-[10px] text-neutral-400",children:t})]})}const Kj=(...e)=>e.filter((t,n,s)=>!!t&&t.trim()!==""&&s.indexOf(t)===n).join(" ").trim();const z8=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const L8=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,s)=>s?s.toUpperCase():n.toLowerCase());const iC=e=>{const t=L8(e);return t.charAt(0).toUpperCase()+t.slice(1)};var U8={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const $8=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};const B8=_.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:s,className:i="",children:a,iconNode:l,...f},d)=>_.createElement("svg",{ref:d,...U8,width:t,height:t,stroke:e,strokeWidth:s?Number(n)*24/Number(t):n,className:Kj("lucide",i),...!a&&!$8(f)&&{"aria-hidden":"true"},...f},[...l.map(([p,g])=>_.createElement(p,g)),...Array.isArray(a)?a:[a]]));const Wb=(e,t)=>{const n=_.forwardRef(({className:s,...i},a)=>_.createElement(B8,{ref:a,iconNode:t,className:Kj(`lucide-${z8(iC(e))}`,`lucide-${e}`,s),...i}));return n.displayName=iC(e),n};const F8=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],H8=Wb("arrow-left",F8);const q8=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],V8=Wb("settings",q8);const K8=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]],G8=Wb("user-x",K8);function Z8(e){return e===0?"#22c55e":e<10?"#f59e0b":e<50?"#f97316":"#ef4444"}const Y8={online:"healthy",syncing:"syncing",offline:"offline"},Gj=_.forwardRef(({className:e,clients:t,headSeq:n,onEvict:s,...i},a)=>h.jsx("div",{ref:a,className:ge("w-full",e),...i,children:h.jsxs(tl,{children:[h.jsx(nl,{children:h.jsxs(ss,{children:[h.jsx(ht,{className:"w-[160px]",children:"Client"}),h.jsx(ht,{className:"w-[70px]",children:"Status"}),h.jsx(ht,{className:"w-[60px]",children:"Type"}),h.jsx(ht,{className:"w-[80px]",children:"Cursor"}),h.jsx(ht,{className:"w-[110px]",children:"Lag"}),h.jsx(ht,{className:"w-[60px]",children:"Dialect"}),h.jsx(ht,{className:"flex-1",children:"Mode"})]})}),h.jsx(rl,{children:t.map(l=>{const f=Math.max(0,n-l.cursor),d=n>0?Math.min(100,l.cursor/n*100):100,p=Z8(f);return h.jsxs(ss,{className:"group relative",children:[h.jsx(pt,{className:"w-[160px]",children:h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{background:p,boxShadow:`0 0 4px ${p}`}}),h.jsx("span",{className:"font-mono text-[11px] text-white truncate",title:l.id,children:l.id.length>18?`${l.id.substring(0,18)}…`:l.id})]})}),h.jsx(pt,{className:"w-[70px]",children:h.jsx(mn,{variant:Y8[l.status],children:l.status})}),h.jsx(pt,{className:"w-[60px]",children:h.jsx("span",{className:"font-mono text-[10px] text-neutral-400",children:l.type})}),h.jsx(pt,{className:"w-[80px]",children:h.jsxs("span",{className:"font-mono text-[11px] text-white font-medium",children:["#",l.cursor.toLocaleString()]})}),h.jsx(pt,{className:"w-[110px]",children:h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("div",{className:"w-[60px] h-[3px] rounded-full bg-surface overflow-hidden",children:h.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${d}%`,background:p}})}),h.jsx("span",{className:"font-mono text-[10px] font-medium",style:{color:p},children:f===0?"0":`${f}`})]})}),h.jsx(pt,{className:"w-[60px]",children:h.jsx("span",{className:"font-mono text-[10px] text-neutral-400",children:l.dialect})}),h.jsx(pt,{className:"flex-1",children:h.jsx(mn,{variant:l.mode==="realtime"?"flow":"ghost",children:l.mode})}),s&&h.jsxs("button",{type:"button",title:"Evict client",onClick:()=>s(l.id),className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1 px-1.5 py-0.5 rounded text-[9px] text-neutral-600 hover:text-offline hover:bg-offline/10 cursor-pointer transition-colors opacity-0 group-hover:opacity-100",children:[h.jsx(G8,{size:10}),"evict"]})]},l.id)})})]})}));Gj.displayName="FleetTable";const Zj=_.forwardRef(({className:e,handlers:t,tableCount:n,...s},i)=>{const a=n??t.length;return h.jsxs("div",{ref:i,className:ge("bg-panel border border-border rounded-lg hover:border-border-bright transition",e),...s,children:[h.jsxs("div",{className:"px-4 py-2.5 border-b border-border flex items-center justify-between",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-flow"}),h.jsx("span",{className:"font-mono text-[10px] text-neutral-500 uppercase tracking-widest",children:"Handlers"})]}),h.jsxs("span",{className:"font-mono text-[10px] text-neutral-600",children:[a," tables"]})]}),h.jsxs("div",{className:"font-mono text-[9px] tracking-wider uppercase text-neutral-600 flex items-center gap-4 px-4 leading-6 border-b border-border",children:[h.jsx("span",{className:"flex-1",children:"Table"}),h.jsx("span",{className:"w-[100px]",children:"Depends On"}),h.jsx("span",{className:"w-[70px] text-right",children:"Chunk TTL"})]}),t.map((l,f)=>h.jsxs("div",{className:ge("font-mono text-[11px] leading-7 px-4 flex items-center gap-4 hover:bg-white/[0.015] transition-colors cursor-default",f<t.length-1&&"border-b border-[#141414]"),children:[h.jsx("span",{className:"flex-1 text-white truncate",children:l.table}),h.jsx("span",{className:"w-[100px] truncate",children:l.dependsOn?h.jsx(mn,{variant:"ghost",children:l.dependsOn}):h.jsx("span",{className:"text-neutral-600",children:"—"})}),h.jsx("span",{className:"w-[70px] text-right text-neutral-500 truncate",children:l.chunkTtl})]},`${l.table}:${f}`))]})});Zj.displayName="HandlersTable";const X8={flow:"bg-flow",healthy:"bg-healthy",syncing:"bg-syncing",offline:"bg-offline",relay:"bg-relay",muted:"bg-neutral-500"},Yj=_.forwardRef(({className:e,items:t,...n},s)=>h.jsx("div",{ref:s,className:ge("border-b border-border px-6 py-3 flex items-center justify-between flex-wrap gap-4","bg-[linear-gradient(to_bottom,rgba(17,17,17,0.8),#0c0c0c)]",e),...n,children:t.map((i,a)=>h.jsx(Q8,{item:i,showDivider:a>0},i.label))}));Yj.displayName="KpiStrip";function Q8({item:e,showDivider:t}){const n=X8[e.color??"muted"]??"bg-neutral-500";return h.jsxs(h.Fragment,{children:[t&&h.jsx("div",{className:"w-px h-4 bg-border"}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:ge("w-1.5 h-1.5 rounded-full",n)}),h.jsx("span",{className:"font-mono text-[10px] text-neutral-500 uppercase",children:e.label}),h.jsxs("span",{className:"font-mono text-sm text-white font-semibold",children:[e.value,e.unit&&h.jsx("span",{className:"text-xs text-neutral-600",children:e.unit})]}),e.trend&&h.jsx("span",{className:ge("font-mono text-[10px]",e.trend.startsWith("+")?"text-healthy":"text-offline"),children:e.trend})]})]})}const Xj=_.forwardRef(({className:e,buckets:t,successRate:n=99.6,successLabel:s="success",...i},a)=>{const l=n/100*88,f=88-l;return h.jsxs("div",{ref:a,className:ge("px-5 py-3 border-b border-border flex items-center gap-8",e),...i,children:[h.jsx("span",{className:"font-mono text-[10px] text-neutral-500 uppercase tracking-widest",children:"Latency"}),h.jsx("div",{className:"flex items-center gap-6",children:t.map(d=>h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"font-mono text-[9px] text-neutral-500",children:d.label}),h.jsxs("div",{className:"flex gap-1 items-end h-5",children:[h.jsx("div",{className:"w-3 rounded-t bg-healthy/60",style:{height:`${d.pushBarPercent}%`}}),h.jsx("div",{className:"w-3 rounded-t bg-flow/60",style:{height:`${d.pullBarPercent}%`}})]}),h.jsxs("span",{className:"font-mono text-[10px] text-neutral-400",children:[d.pushMs," / ",d.pullMs,"ms"]})]},d.label))}),h.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[h.jsxs("svg",{viewBox:"0 0 36 36",className:"w-7 h-7",children:[h.jsx("circle",{cx:18,cy:18,r:14,fill:"none",stroke:"#1e1e1e",strokeWidth:4}),h.jsx("circle",{cx:18,cy:18,r:14,fill:"none",stroke:"#22c55e",strokeWidth:4,strokeDasharray:`${l} ${f}`,transform:"rotate(-90 18 18)",strokeLinecap:"round"})]}),h.jsxs("span",{className:"font-mono text-[10px] text-neutral-400",children:[n,"%"," ",h.jsx("span",{className:"text-neutral-600",children:s})]})]})]})});Xj.displayName="LatencyPercentilesBar";const W8={PUSH:"syncing",PULL:"healthy",ACK:"flow"},Qj=_.forwardRef(({className:e,entries:t,isConnected:n=!0,maxVisible:s=20,maxHeight:i,...a},l)=>{const f=t.slice(0,s);return h.jsxs("div",{ref:l,className:ge("flex-shrink-0",e),style:{width:360},...a,children:[h.jsxs("div",{className:"px-4 py-2.5 border-b border-border flex items-center justify-between",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"font-mono text-[10px] text-neutral-500 uppercase tracking-widest",children:"Live Feed"}),h.jsx("span",{className:ge("w-1.5 h-1.5 rounded-full",n?"bg-healthy animate-[dotPulse_1.5s_ease-in-out_infinite]":"bg-neutral-600")})]}),h.jsx("span",{className:"font-mono text-[9px] text-neutral-600",children:n?"WebSocket":"Disconnected"})]}),h.jsx("div",{className:"px-3 py-2 space-y-0.5 overflow-y-auto",style:i?{maxHeight:i}:void 0,children:f.length===0?h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsx("p",{className:"text-neutral-500 text-sm font-mono",children:n?"Waiting for activity...":"Connect to see live activity"})}):f.map((d,p)=>h.jsxs("div",{className:"flex items-center gap-2 py-1 animate-[streamSlide_0.35s_ease-out]",children:[h.jsx(mn,{variant:W8[d.type]??"ghost",className:"text-[8px] px-1.5 py-0",children:d.type}),h.jsxs("span",{className:"font-mono text-[10px] text-neutral-400 truncate flex-1",children:[d.actor," · ",d.table]}),h.jsx("span",{className:"font-mono text-[9px] text-neutral-600",children:d.time})]},`${d.time}-${p}`))})]})});Qj.displayName="LiveActivityFeed";const J8={syncing:"bg-syncing",flow:"bg-flow",healthy:"bg-healthy",offline:"bg-offline"},_p=_.forwardRef(({className:e,title:t,description:n,dotColor:s="syncing",stats:i,actionLabel:a,actionVariant:l="default",actionIcon:f,onAction:d,...p},g)=>h.jsxs("div",{ref:g,className:ge("bg-panel border border-border rounded-lg hover:border-border-bright transition",e),...p,children:[h.jsxs("div",{className:"px-4 py-2.5 border-b border-border flex items-center gap-2",children:[h.jsx("span",{className:ge("w-1.5 h-1.5 rounded-full",J8[s])}),h.jsx("span",{className:"font-mono text-[10px] text-neutral-500 uppercase tracking-widest",children:t})]}),h.jsxs("div",{className:"p-4",children:[h.jsx("p",{className:"font-mono text-[10px] text-neutral-500 leading-relaxed mb-4",children:n}),h.jsx("div",{className:ge("grid gap-3 mb-4",i.length<=2?"grid-cols-2":"grid-cols-3"),children:i.map(y=>h.jsxs("div",{children:[h.jsx("div",{className:"font-mono text-[9px] text-neutral-600 uppercase tracking-wider mb-1",children:y.label}),h.jsx("div",{className:ge("font-mono font-semibold",y.tone==="syncing"?"text-sm text-syncing":"text-lg text-white"),children:y.value})]},y.label))}),h.jsxs(Me,{variant:l,size:"md",onClick:d,children:[f,a]})]})]}));_p.displayName="MaintenanceCard";function eV({actions:e,children:t,className:n,contentClassName:s,description:i,title:a}){return h.jsxs(Yb,{className:ge("border-border",n),children:[a||e?h.jsxs("div",{className:"flex items-start justify-between px-4 pt-4",children:[h.jsxs("div",{children:[a?h.jsx("h3",{className:"font-mono text-[10px] text-neutral-500 uppercase tracking-widest",children:a}):null,i?h.jsx("p",{className:"mt-1 font-mono text-[10px] text-neutral-500",children:i}):null]}),e?h.jsx("div",{className:"flex items-center gap-2",children:e}):null]}):null,h.jsx(Xb,{className:s,children:t})]})}const Wj=_.forwardRef(({className:e,rows:t,onResetDefaults:n,...s},i)=>h.jsxs("div",{ref:i,className:ge("bg-panel border border-border rounded-lg hover:border-border-bright transition",e),...s,children:[h.jsxs("div",{className:"px-4 py-2.5 border-b border-border flex items-center justify-between",children:[h.jsx("span",{className:"font-mono text-[10px] text-neutral-500 uppercase tracking-widest",children:"Preferences"}),n&&h.jsx(Me,{variant:"default",size:"sm",onClick:n,children:"Reset defaults"})]}),h.jsx("div",{className:"p-4 space-y-4",children:t.map((a,l)=>h.jsx(tV,{row:a,showDivider:l>0},a.label))})]}));Wj.displayName="PreferencesPanel";function tV({row:e,showDivider:t}){return h.jsxs(h.Fragment,{children:[t&&h.jsx("div",{className:"border-t border-border"}),h.jsx("div",{className:"flex items-center justify-between",children:e.type==="filter"?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"font-mono text-[11px] text-neutral-400",children:e.label}),h.jsx("div",{className:"flex gap-0.5",children:e.options.map(n=>h.jsx("button",{type:"button",onClick:()=>e.onActiveChange(n.id),className:ge("font-mono text-[10px] border rounded-sm px-2.5 py-0.5 cursor-pointer transition-all",n.id===e.activeId?"text-white border-border-bright bg-white/[0.03]":"text-neutral-500 border-transparent hover:text-neutral-300"),children:n.label},n.id))})]}):h.jsxs(h.Fragment,{children:[h.jsxs("div",{children:[h.jsx("span",{className:"font-mono text-[11px] text-neutral-400",children:e.label}),e.description&&h.jsx("p",{className:"font-mono text-[9px] text-neutral-600 mt-0.5",children:e.description})]}),h.jsx(Sp,{checked:e.checked,onCheckedChange:n=>e.onCheckedChange(n)})]})})]})}function Jb({actions:e,children:t,className:n,contentClassName:s,description:i,title:a}){return h.jsxs(Yb,{className:n,children:[a||e?h.jsxs("div",{className:"flex items-start justify-between px-4 pt-4",children:[h.jsxs("div",{children:[a?h.jsx("h3",{className:"font-mono text-[10px] text-neutral-500 uppercase tracking-widest",children:a}):null,i?h.jsx("p",{className:"mt-1 font-mono text-[10px] text-neutral-500",children:i}):null]}),e?h.jsx("div",{className:"flex items-center gap-2",children:e}):null]}):null,h.jsx(Xb,{className:s,children:t})]})}const nV={commit:"text-flow",push:"text-syncing",pull:"text-healthy"},rV={applied:"text-healthy",error:"text-offline",cached:"text-syncing"},Jj=_.forwardRef(({className:e,entries:t,filterBar:n,pagination:s,onEntryClick:i,selectedEntryId:a,...l},f)=>h.jsxs("div",{ref:f,className:ge("h-full flex flex-col",e),...l,children:[n,h.jsxs("div",{className:"font-mono text-[9px] tracking-wider uppercase text-neutral-600 flex items-center gap-4 px-4 leading-6 border-b border-border bg-white/[0.01]",children:[h.jsx("span",{className:"w-[50px] truncate",children:"Time"}),h.jsx("span",{className:"w-[65px] truncate",children:"Type"}),h.jsx("span",{className:"w-[55px] truncate",children:"ID"}),h.jsx("span",{className:"w-[65px] truncate",children:"Outcome"}),h.jsx("span",{className:"w-[50px] truncate",children:"Dur"}),h.jsx("span",{className:"w-[100px] truncate",children:"Actor"}),h.jsx("span",{className:"w-[120px] truncate",children:"Client"}),h.jsx("span",{className:"flex-1 truncate",children:"Detail"})]}),h.jsx("div",{className:"flex-1 overflow-y-auto",children:t.map((d,p)=>h.jsx(sV,{entry:d,isSelected:a===d.id,onClick:i},`${d.id}-${p}`))}),s]}));Jj.displayName="StreamLog";function sV({entry:e,isSelected:t,onClick:n}){const s=nV[e.type]??"text-neutral-500",i=rV[e.outcome]??"text-neutral-600",a=ge("font-mono text-[11px] leading-7 px-4 flex items-center gap-4 border-b border-[#141414] hover:bg-white/[0.015] transition-colors",n?"cursor-pointer":"cursor-default",t&&"bg-white/[0.05]"),l=h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"w-[50px] text-neutral-600 truncate",children:e.time}),h.jsx("span",{className:ge("w-[65px] font-medium truncate",s),children:e.type.toUpperCase()}),h.jsx("span",{className:"w-[55px] text-flow truncate",children:e.id}),h.jsx("span",{className:ge("w-[65px] truncate",i),children:e.outcome}),h.jsx("span",{className:"w-[50px] text-neutral-500 truncate",children:e.duration}),h.jsx("span",{className:"w-[100px] text-neutral-400 truncate",children:e.actor}),h.jsx("span",{className:"w-[120px] text-neutral-600 truncate",title:e.client,children:e.client.length>14?`${e.client.substring(0,14)}…`:e.client}),h.jsx("span",{className:"flex-1 text-neutral-500 truncate",children:e.detail})]});return n?h.jsx("button",{type:"button",className:ge(a,"w-full bg-transparent text-left"),onClick:()=>n(e),children:l}):h.jsx("div",{className:a,children:l})}function oV(e){return e==="online"?"#22c55e":e==="syncing"?"#f59e0b":"#ef4444"}const eA=_.forwardRef(({className:e,clients:t,headSeq:n,maxLag:s,minSeq:i,...a},l)=>{const f=t.map(b=>b.cursor),d=i??Math.min(...f,n)-10,p=s??Math.max(...t.map(b=>n-b.cursor),0),g=n-d,y=[d,Math.round(d+g*.33),Math.round(d+g*.66),n];return h.jsxs("div",{ref:l,className:ge("bg-panel border border-border rounded-lg hover:border-border-bright transition",e),...a,children:[h.jsxs("div",{className:"px-4 py-2.5 border-b border-border flex items-center justify-between",children:[h.jsx("span",{className:"font-mono text-[10px] text-neutral-500 uppercase tracking-widest",children:"Sync Horizon"}),h.jsxs("div",{className:"flex items-center gap-4",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"font-mono text-[10px] text-neutral-500",children:"Head"}),h.jsxs("span",{className:"font-mono text-xs text-white font-semibold",children:["#",n.toLocaleString()]})]}),h.jsx("div",{className:"w-px h-3 bg-border"}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"font-mono text-[10px] text-neutral-500",children:"Max lag"}),h.jsx("span",{className:"font-mono text-xs text-syncing font-semibold",children:p})]})]})]}),h.jsxs("div",{className:"p-4",children:[h.jsxs("div",{className:"relative h-8 mb-3 rounded bg-surface",children:[h.jsx("div",{className:"absolute inset-0 flex items-center justify-between px-2",children:y.map(b=>h.jsxs("span",{className:"font-mono text-[8px] text-neutral-700",children:["#",b.toLocaleString()]},b))}),h.jsx("div",{className:"absolute top-0 bottom-0 w-px bg-flow/40",style:{right:"2%"}}),t.map(b=>{const x=g>0?(b.cursor-d)/g*96+2:50,S=oV(b.status),w=b.status==="offline"?.4:1;return h.jsx("div",{className:"absolute",style:{left:`${x}%`,top:"50%",transform:"translate(-50%,-50%)",opacity:w},title:`${b.id} → #${b.cursor}`,children:h.jsx("div",{className:"w-2.5 h-2.5 rounded-full",style:{background:S,boxShadow:`0 0 4px ${S}`}})},b.id)})]}),h.jsxs("div",{className:"flex items-center gap-4",children:[h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("span",{className:"w-2 h-2 rounded-full bg-healthy"}),h.jsx("span",{className:"font-mono text-[9px] text-neutral-500",children:"Caught up"})]}),h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("span",{className:"w-2 h-2 rounded-full bg-syncing"}),h.jsx("span",{className:"font-mono text-[9px] text-neutral-500",children:"Behind"})]}),h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("span",{className:"w-2 h-2 rounded-full bg-offline opacity-50"}),h.jsx("span",{className:"font-mono text-[9px] text-neutral-500",children:"Offline"})]})]})]})]})});eA.displayName="SyncHorizon";function iV(e){const t=_.useRef(!0);t.current&&(t.current=!1,e())}const aV=_.createContext(void 0);function ex(e){const t=_.useContext(aV);if(t===void 0)throw new Error(yn(72));return t}const cV=[];function tx(e){_.useEffect(e,cV)}const iu=0;class ai{static create(){return new ai}currentId=iu;start(t,n){this.clear(),this.currentId=setTimeout(()=>{this.currentId=iu,n()},t)}isStarted(){return this.currentId!==iu}clear=()=>{this.currentId!==iu&&(clearTimeout(this.currentId),this.currentId=iu)};disposeEffect=()=>this.clear}function ns(){const e=zn(ai.create).current;return tx(e.disposeEffect),e}function Jo(e){const t=zn(lV,e).current;return t.next=e,Le(t.effect),t}function lV(e){const t={current:e,next:e,effect:()=>{t.current=t.next}};return t}function Rt(e){return e?.ownerDocument||document}const sl=typeof navigator<"u",jy=dV(),tA=pV(),nA=hV(),nx=typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter:none"),rA=jy.platform==="MacIntel"&&jy.maxTouchPoints>1?!0:/iP(hone|ad|od)|iOS/.test(jy.platform),uV=sl&&/apple/i.test(navigator.vendor),Mv=sl&&/android/i.test(tA)||/android/i.test(nA);sl&&tA.toLowerCase().startsWith("mac")&&navigator.maxTouchPoints;const fV=nA.includes("jsdom/");function dV(){if(!sl)return{platform:"",maxTouchPoints:-1};const e=navigator.userAgentData;return e?.platform?{platform:e.platform,maxTouchPoints:navigator.maxTouchPoints}:{platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??-1}}function hV(){if(!sl)return"";const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(({brand:t,version:n})=>`${t}/${n}`).join(" "):navigator.userAgent}function pV(){if(!sl)return"";const e=navigator.userAgentData;return e?.platform?e.platform:navigator.platform??""}const Iv="data-base-ui-focusable",sA="active",oA="selected",iA="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])",Ay="ArrowLeft",ky="ArrowRight",mV="ArrowUp",gV="ArrowDown";function Fo(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function Ot(e,t){if(!e||!t)return!1;const n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&jv(n)){let s=t;for(;s;){if(e===s)return!0;s=s.parentNode||s.host}}return!1}function yV(e,t){if(!jt(e))return!1;const n=e;if(t.hasElement(n))return!n.hasAttribute("data-trigger-disabled");for(const[,s]of t.entries())if(Ot(s,n))return!s.hasAttribute("data-trigger-disabled");return!1}function Ur(e){return"composedPath"in e?e.composedPath()[0]:e.target}function Jr(e,t){if(t==null)return!1;if("composedPath"in e)return e.composedPath().includes(t);const n=e;return n.target!=null&&t.contains(n.target)}function vV(e){return e.matches("html,body")}function aA(e){return Zt(e)&&e.matches(iA)}function aC(e){return e?e.getAttribute("role")==="combobox"&&aA(e):!1}function Bh(e){return e?e.hasAttribute(Iv)?e:e.querySelector(`[${Iv}]`)||e:null}function xc(e,t,n=!0){return e.filter(i=>i.parentId===t&&(!n||i.context?.open)).flatMap(i=>[i,...xc(e,i.id,n)])}function cC(e,t){let n=[],s=e.find(i=>i.id===t)?.parentId;for(;s;){const i=e.find(a=>a.id===s);s=i?.parentId,i&&(n=n.concat(i))}return n}function Ki(e){e.preventDefault(),e.stopPropagation()}function bV(e){return"nativeEvent"in e}function xV(e){return e.pointerType===""&&e.isTrusted?!0:Mv&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function SV(e){return fV?!1:!Mv&&e.width===0&&e.height===0||Mv&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType==="mouse"||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType==="touch"}function _V(e,t){const n=["mouse","pen"];return n.push("",void 0),n.includes(e)}function wV(e){const t=e.type;return t==="click"||t==="mousedown"||t==="keydown"||t==="keyup"}const EV=["top","right","bottom","left"],Lc=Math.min,dr=Math.max,Fh=Math.round,hc=Math.floor,xs=e=>({x:e,y:e}),TV={left:"right",right:"left",bottom:"top",top:"bottom"},CV={start:"end",end:"start"};function Pv(e,t,n){return dr(e,Lc(t,n))}function ao(e,t){return typeof e=="function"?e(t):e}function Zn(e){return e.split("-")[0]}function Si(e){return e.split("-")[1]}function rx(e){return e==="x"?"y":"x"}function sx(e){return e==="y"?"height":"width"}const RV=new Set(["top","bottom"]);function Fr(e){return RV.has(Zn(e))?"y":"x"}function ox(e){return rx(Fr(e))}function NV(e,t,n){n===void 0&&(n=!1);const s=Si(e),i=ox(e),a=sx(i);let l=i==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(l=Hh(l)),[l,Hh(l)]}function jV(e){const t=Hh(e);return[Dv(e),t,Dv(t)]}function Dv(e){return e.replace(/start|end/g,t=>CV[t])}const lC=["left","right"],uC=["right","left"],AV=["top","bottom"],kV=["bottom","top"];function OV(e,t,n){switch(e){case"top":case"bottom":return n?t?uC:lC:t?lC:uC;case"left":case"right":return t?AV:kV;default:return[]}}function MV(e,t,n,s){const i=Si(e);let a=OV(Zn(e),n==="start",s);return i&&(a=a.map(l=>l+"-"+i),t&&(a=a.concat(a.map(Dv)))),a}function Hh(e){return e.replace(/left|right|bottom|top/g,t=>TV[t])}function IV(e){return{top:0,right:0,bottom:0,left:0,...e}}function cA(e){return typeof e!="number"?IV(e):{top:e,right:e,bottom:e,left:e}}function qh(e){const{x:t,y:n,width:s,height:i}=e;return{width:s,height:i,top:n,left:t,right:t+s,bottom:n+i,x:t,y:n}}function zd(e,t,n){return Math.floor(e/t)!==n}function ch(e,t){return t<0||t>=e.current.length}function PV(e,t){return fr(e,{disabledIndices:t})}function DV(e,t){return fr(e,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function fr(e,{startingIndex:t=-1,decrement:n=!1,disabledIndices:s,amount:i=1}={}){let a=t;do a+=n?-i:i;while(a>=0&&a<=e.current.length-1&&pu(e,a,s));return a}function zV(e,{event:t,orientation:n,loopFocus:s,rtl:i,cols:a,disabledIndices:l,minIndex:f,maxIndex:d,prevIndex:p,stopEvent:g=!1}){let y=p;const b=[],x={};let S=!1;{let C=null,O=-1;e.current.forEach((N,R)=>{if(N==null)return;const M=N.closest('[role="row"]');M&&(S=!0),(M!==C||O===-1)&&(C=M,O+=1,b[O]=[]),b[O].push(R),x[R]=O})}const w=S&&b.length>0&&b.some(C=>C.length!==a);function T(C){if(!w||p===-1)return;const O=x[p];if(O==null)return;const N=b[O].indexOf(p);let R=C==="up"?O-1:O+1;s&&(R<0?R=b.length-1:R>=b.length&&(R=0));const M=new Set;for(;R>=0&&R<b.length&&!M.has(R);){M.add(R);const z=b[R];if(z.length===0){R=C==="up"?R-1:R+1;continue}const j=Math.min(N,z.length-1);for(let A=j;A>=0;A-=1){const P=z[A];if(!pu(e,P,l))return P}R=C==="up"?R-1:R+1,s&&(R<0?R=b.length-1:R>=b.length&&(R=0))}}if(t.key===mV){const C=T("up");if(C!==void 0)g&&Ki(t),y=C;else{if(g&&Ki(t),p===-1)y=d;else if(y=fr(e,{startingIndex:y,amount:a,decrement:!0,disabledIndices:l}),s&&(p-a<f||y<0)){const O=p%a,N=d%a,R=d-(N-O);N===O?y=d:y=N>O?R:R-a}ch(e,y)&&(y=p)}}if(t.key===gV){const C=T("down");C!==void 0?(g&&Ki(t),y=C):(g&&Ki(t),p===-1?y=f:(y=fr(e,{startingIndex:p,amount:a,disabledIndices:l}),s&&p+a>d&&(y=fr(e,{startingIndex:p%a-a,amount:a,disabledIndices:l}))),ch(e,y)&&(y=p))}if(n==="both"){const C=hc(p/a);t.key===(i?Ay:ky)&&(g&&Ki(t),p%a!==a-1?(y=fr(e,{startingIndex:p,disabledIndices:l}),s&&zd(y,a,C)&&(y=fr(e,{startingIndex:p-p%a-1,disabledIndices:l}))):s&&(y=fr(e,{startingIndex:p-p%a-1,disabledIndices:l})),zd(y,a,C)&&(y=p)),t.key===(i?ky:Ay)&&(g&&Ki(t),p%a!==0?(y=fr(e,{startingIndex:p,decrement:!0,disabledIndices:l}),s&&zd(y,a,C)&&(y=fr(e,{startingIndex:p+(a-p%a),decrement:!0,disabledIndices:l}))):s&&(y=fr(e,{startingIndex:p+(a-p%a),decrement:!0,disabledIndices:l})),zd(y,a,C)&&(y=p));const O=hc(d/a)===C;ch(e,y)&&(s&&O?y=t.key===(i?ky:Ay)?d:fr(e,{startingIndex:p-p%a-1,disabledIndices:l}):y=p)}return y}function LV(e,t,n){const s=[];let i=0;return e.forEach(({width:a,height:l},f)=>{let d=!1;for(n&&(i=0);!d;){const p=[];for(let g=0;g<a;g+=1)for(let y=0;y<l;y+=1)p.push(i+g+y*t);i%t+a<=t&&p.every(g=>s[g]==null)?(p.forEach(g=>{s[g]=f}),d=!0):i+=1}}),[...s]}function UV(e,t,n,s,i){if(e===-1)return-1;const a=n.indexOf(e),l=t[e];switch(i){case"tl":return a;case"tr":return l?a+l.width-1:a;case"bl":return l?a+(l.height-1)*s:a;case"br":return n.lastIndexOf(e);default:return-1}}function $V(e,t){return t.flatMap((n,s)=>e.includes(n)?[s]:[])}function pu(e,t,n){if(typeof n=="function")return n(t);if(n)return n.includes(t);const s=e.current[t];return s?s.hasAttribute("disabled")||s.getAttribute("aria-disabled")==="true":!1}var BV=["input:not([inert]):not([inert] *)","select:not([inert]):not([inert] *)","textarea:not([inert]):not([inert] *)","a[href]:not([inert]):not([inert] *)","button:not([inert]):not([inert] *)","[tabindex]:not(slot):not([inert]):not([inert] *)","audio[controls]:not([inert]):not([inert] *)","video[controls]:not([inert]):not([inert] *)",'[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)',"details>summary:first-of-type:not([inert]):not([inert] *)","details:not([inert]):not([inert] *)"],Vh=BV.join(","),lA=typeof Element>"u",Uc=lA?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,Kh=!lA&&Element.prototype.getRootNode?function(e){var t;return e==null||(t=e.getRootNode)===null||t===void 0?void 0:t.call(e)}:function(e){return e?.ownerDocument},Gh=function(t,n){var s;n===void 0&&(n=!0);var i=t==null||(s=t.getAttribute)===null||s===void 0?void 0:s.call(t,"inert"),a=i===""||i==="true",l=a||n&&t&&(typeof t.closest=="function"?t.closest("[inert]"):Gh(t.parentNode));return l},FV=function(t){var n,s=t==null||(n=t.getAttribute)===null||n===void 0?void 0:n.call(t,"contenteditable");return s===""||s==="true"},uA=function(t,n,s){if(Gh(t))return[];var i=Array.prototype.slice.apply(t.querySelectorAll(Vh));return n&&Uc.call(t,Vh)&&i.unshift(t),i=i.filter(s),i},Zh=function(t,n,s){for(var i=[],a=Array.from(t);a.length;){var l=a.shift();if(!Gh(l,!1))if(l.tagName==="SLOT"){var f=l.assignedElements(),d=f.length?f:l.children,p=Zh(d,!0,s);s.flatten?i.push.apply(i,p):i.push({scopeParent:l,candidates:p})}else{var g=Uc.call(l,Vh);g&&s.filter(l)&&(n||!t.includes(l))&&i.push(l);var y=l.shadowRoot||typeof s.getShadowRoot=="function"&&s.getShadowRoot(l),b=!Gh(y,!1)&&(!s.shadowRootFilter||s.shadowRootFilter(l));if(y&&b){var x=Zh(y===!0?l.children:y.children,!0,s);s.flatten?i.push.apply(i,x):i.push({scopeParent:l,candidates:x})}else a.unshift.apply(a,l.children)}}return i},fA=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},dA=function(t){if(!t)throw new Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||FV(t))&&!fA(t)?0:t.tabIndex},HV=function(t,n){var s=dA(t);return s<0&&n&&!fA(t)?0:s},qV=function(t,n){return t.tabIndex===n.tabIndex?t.documentOrder-n.documentOrder:t.tabIndex-n.tabIndex},hA=function(t){return t.tagName==="INPUT"},VV=function(t){return hA(t)&&t.type==="hidden"},KV=function(t){var n=t.tagName==="DETAILS"&&Array.prototype.slice.apply(t.children).some(function(s){return s.tagName==="SUMMARY"});return n},GV=function(t,n){for(var s=0;s<t.length;s++)if(t[s].checked&&t[s].form===n)return t[s]},ZV=function(t){if(!t.name)return!0;var n=t.form||Kh(t),s=function(f){return n.querySelectorAll('input[type="radio"][name="'+f+'"]')},i;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")i=s(window.CSS.escape(t.name));else try{i=s(t.name)}catch(l){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",l.message),!1}var a=GV(i,t.form);return!a||a===t},YV=function(t){return hA(t)&&t.type==="radio"},XV=function(t){return YV(t)&&!ZV(t)},QV=function(t){var n,s=t&&Kh(t),i=(n=s)===null||n===void 0?void 0:n.host,a=!1;if(s&&s!==t){var l,f,d;for(a=!!((l=i)!==null&&l!==void 0&&(f=l.ownerDocument)!==null&&f!==void 0&&f.contains(i)||t!=null&&(d=t.ownerDocument)!==null&&d!==void 0&&d.contains(t));!a&&i;){var p,g,y;s=Kh(i),i=(p=s)===null||p===void 0?void 0:p.host,a=!!((g=i)!==null&&g!==void 0&&(y=g.ownerDocument)!==null&&y!==void 0&&y.contains(i))}}return a},fC=function(t){var n=t.getBoundingClientRect(),s=n.width,i=n.height;return s===0&&i===0},WV=function(t,n){var s=n.displayCheck,i=n.getShadowRoot;if(s==="full-native"&&"checkVisibility"in t){var a=t.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!a}if(getComputedStyle(t).visibility==="hidden")return!0;var l=Uc.call(t,"details>summary:first-of-type"),f=l?t.parentElement:t;if(Uc.call(f,"details:not([open]) *"))return!0;if(!s||s==="full"||s==="full-native"||s==="legacy-full"){if(typeof i=="function"){for(var d=t;t;){var p=t.parentElement,g=Kh(t);if(p&&!p.shadowRoot&&i(p)===!0)return fC(t);t.assignedSlot?t=t.assignedSlot:!p&&g!==t.ownerDocument?t=g.host:t=p}t=d}if(QV(t))return!t.getClientRects().length;if(s!=="legacy-full")return!0}else if(s==="non-zero-area")return fC(t);return!1},JV=function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var n=t.parentElement;n;){if(n.tagName==="FIELDSET"&&n.disabled){for(var s=0;s<n.children.length;s++){var i=n.children.item(s);if(i.tagName==="LEGEND")return Uc.call(n,"fieldset[disabled] *")?!0:!i.contains(t)}return!0}n=n.parentElement}return!1},zv=function(t,n){return!(n.disabled||VV(n)||WV(n,t)||KV(n)||JV(n))},Lv=function(t,n){return!(XV(n)||dA(n)<0||!zv(t,n))},e7=function(t){var n=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(n)||n>=0)},pA=function(t){var n=[],s=[];return t.forEach(function(i,a){var l=!!i.scopeParent,f=l?i.scopeParent:i,d=HV(f,l),p=l?pA(i.candidates):f;d===0?l?n.push.apply(n,p):n.push(f):s.push({documentOrder:a,tabIndex:d,item:i,isScope:l,content:p})}),s.sort(qV).reduce(function(i,a){return a.isScope?i.push.apply(i,a.content):i.push(a.content),i},[]).concat(n)},wp=function(t,n){n=n||{};var s;return n.getShadowRoot?s=Zh([t],n.includeContainer,{filter:Lv.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:e7}):s=uA(t,n.includeContainer,Lv.bind(null,n)),pA(s)},t7=function(t,n){n=n||{};var s;return n.getShadowRoot?s=Zh([t],n.includeContainer,{filter:zv.bind(null,n),flatten:!0,getShadowRoot:n.getShadowRoot}):s=uA(t,n.includeContainer,zv.bind(null,n)),s},mA=function(t,n){if(n=n||{},!t)throw new Error("No node provided");return Uc.call(t,Vh)===!1?!1:Lv(n,t)};const Qu=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function gA(e,t){const n=wp(e,Qu()),s=n.length;if(s===0)return;const i=Fo(Rt(e)),a=n.indexOf(i),l=a===-1?t===1?0:s-1:a+t;return n[l]}function yA(e){return gA(Rt(e).body,1)||e}function vA(e){return gA(Rt(e).body,-1)||e}function mu(e,t){const n=t||e.currentTarget,s=e.relatedTarget;return!s||!Ot(n,s)}function n7(e){wp(e,Qu()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function dC(e){e.querySelectorAll("[data-tabindex]").forEach(n=>{const s=n.dataset.tabindex;delete n.dataset.tabindex,s?n.setAttribute("tabindex",s):n.removeAttribute("tabindex")})}function r7(){const e=new Map;return{emit(t,n){e.get(t)?.forEach(s=>s(n))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){e.get(t)?.delete(n)}}}const s7=_.createContext(null),o7=_.createContext(null),Ep=()=>_.useContext(s7)?.id||null,Tp=e=>{const t=_.useContext(o7);return e??t};function Nu(e){return`data-base-ui-${e}`}const Ld=null;class i7{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=t=>{this.isScheduled=!1;const n=this.callbacks,s=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,s>0)for(let i=0;i<n.length;i+=1)n[i]?.(t)};request(t){const n=this.nextId;return this.nextId+=1,this.callbacks.push(t),this.callbacksCount+=1,!this.isScheduled&&(requestAnimationFrame(this.tick),this.isScheduled=!0),n}cancel(t){const n=t-this.startId;n<0||n>=this.callbacks.length||(this.callbacks[n]=null,this.callbacksCount-=1)}}const Ud=new i7;class ys{static create(){return new ys}static request(t){return Ud.request(t)}static cancel(t){return Ud.cancel(t)}currentId=Ld;request(t){this.cancel(),this.currentId=Ud.request(()=>{this.currentId=Ld,t()})}cancel=()=>{this.currentId!==Ld&&(Ud.cancel(this.currentId),this.currentId=Ld)};disposeEffect=()=>this.cancel}function ix(){const e=zn(ys.create).current;return tx(e.disposeEffect),e}const Yh=_.forwardRef(function(t,n){const[s,i]=_.useState();Le(()=>{uV&&i("button")},[]);const a={tabIndex:0,role:s};return h.jsx("span",{...t,ref:n,style:mp,"aria-hidden":s?void 0:!0,...a,"data-base-ui-focus-guard":""})});let hC=0;function Oy(e,t={}){const{preventScroll:n=!1,cancelPrevious:s=!0,sync:i=!1}=t;s&&cancelAnimationFrame(hC);const a=()=>e?.focus({preventScroll:n});i?a():hC=requestAnimationFrame(a)}const Sc={inert:new WeakMap,"aria-hidden":new WeakMap,none:new WeakMap};function pC(e){return e==="inert"?Sc.inert:e==="aria-hidden"?Sc["aria-hidden"]:Sc.none}let $d=new WeakSet,Bd={},My=0;const bA=e=>e&&(e.host||bA(e.parentNode)),a7=(e,t)=>t.map(n=>{if(e.contains(n))return n;const s=bA(n);return e.contains(s)?s:null}).filter(n=>n!=null);function c7(e,t,n,s){const i="data-base-ui-inert",a=s?"inert":n?"aria-hidden":null,l=a7(t,e),f=new Set,d=new Set(l),p=[];Bd[i]||(Bd[i]=new WeakMap);const g=Bd[i];l.forEach(y),b(t),f.clear();function y(x){!x||f.has(x)||(f.add(x),x.parentNode&&y(x.parentNode))}function b(x){!x||d.has(x)||[].forEach.call(x.children,S=>{if(yi(S)!=="script")if(f.has(S))b(S);else{const w=a?S.getAttribute(a):null,T=w!==null&&w!=="false",C=pC(a),O=(C.get(S)||0)+1,N=(g.get(S)||0)+1;C.set(S,O),g.set(S,N),p.push(S),O===1&&T&&$d.add(S),N===1&&S.setAttribute(i,""),!T&&a&&S.setAttribute(a,a==="inert"?"":"true")}})}return My+=1,()=>{p.forEach(x=>{const S=pC(a),T=(S.get(x)||0)-1,C=(g.get(x)||0)-1;S.set(x,T),g.set(x,C),T||(!$d.has(x)&&a&&x.removeAttribute(a),$d.delete(x)),C||x.removeAttribute(i)}),My-=1,My||(Sc.inert=new WeakMap,Sc["aria-hidden"]=new WeakMap,Sc.none=new WeakMap,$d=new WeakSet,Bd={})}}function l7(e,t=!1,n=!1){const s=Rt(e[0]).body;return c7(e.concat(Array.from(s.querySelectorAll("[aria-live]"))),s,t,n)}const xA=_.createContext(null),SA=()=>_.useContext(xA),u7=Nu("portal");function _A(e={}){const{ref:t,container:n,componentProps:s=an,elementProps:i}=e,a=Xu(),f=SA()?.portalNode,[d,p]=_.useState(null),[g,y]=_.useState(null),b=Ae(T=>{T!==null&&y(T)}),x=_.useRef(null);Le(()=>{if(n===null){x.current&&(x.current=null,y(null),p(null));return}if(a==null)return;const T=(n&&(Gb(n)?n:n.current))??f??document.body;if(T==null){x.current&&(x.current=null,y(null),p(null));return}x.current!==T&&(x.current=T,y(null),p(T))},[n,f,a]);const S=zt("div",s,{ref:[t,b],props:[{id:a,[u7]:""},i]});return{portalNode:g,portalSubtree:d&&S?hi.createPortal(S,d):null}}const wA=_.forwardRef(function(t,n){const{children:s,container:i,className:a,render:l,renderGuards:f,...d}=t,{portalNode:p,portalSubtree:g}=_A({container:i,ref:n,componentProps:t,elementProps:d}),y=_.useRef(null),b=_.useRef(null),x=_.useRef(null),S=_.useRef(null),[w,T]=_.useState(null),C=w?.modal,O=w?.open,N=typeof f=="boolean"?f:!!w&&!w.modal&&w.open&&!!p;_.useEffect(()=>{if(!p||C)return;function M(z){p&&z.relatedTarget&&mu(z)&&(z.type==="focusin"?dC:n7)(p)}return p.addEventListener("focusin",M,!0),p.addEventListener("focusout",M,!0),()=>{p.removeEventListener("focusin",M,!0),p.removeEventListener("focusout",M,!0)}},[p,C]),_.useEffect(()=>{!p||O||dC(p)},[O,p]);const R=_.useMemo(()=>({beforeOutsideRef:y,afterOutsideRef:b,beforeInsideRef:x,afterInsideRef:S,portalNode:p,setFocusManagerState:T}),[p]);return h.jsxs(_.Fragment,{children:[g,h.jsxs(xA.Provider,{value:R,children:[N&&p&&h.jsx(Yh,{"data-type":"outside",ref:y,onFocus:M=>{if(mu(M,p))x.current?.focus();else{const z=w?w.domReference:null;vA(z)?.focus()}}}),N&&p&&h.jsx("span",{"aria-owns":p.id,style:W9}),p&&hi.createPortal(s,p),N&&p&&h.jsx(Yh,{"data-type":"outside",ref:b,onFocus:M=>{if(mu(M,p))S.current?.focus();else{const z=w?w.domReference:null;yA(z)?.focus(),w?.closeOnFocusOut&&w?.onOpenChange(!1,Yt(Lj,M.nativeEvent))}}})]})]})});function qs(e){return e==null?e:"current"in e?e.current:e}function f7(e,t){const n=un(e.target);return e instanceof n.KeyboardEvent?"keyboard":e instanceof n.FocusEvent?t||"keyboard":"pointerType"in e?e.pointerType||"keyboard":"touches"in e?"touch":e instanceof n.MouseEvent?t||(e.detail===0?"keyboard":"mouse"):""}const mC=20;let Vo=[];function ax(){Vo=Vo.filter(e=>e.deref()?.isConnected)}function d7(e){ax(),e&&yi(e)!=="body"&&(Vo.push(new WeakRef(e)),Vo.length>mC&&(Vo=Vo.slice(-mC)))}function Iy(){return ax(),Vo[Vo.length-1]?.deref()}function h7(e){if(!e)return null;const t=Qu();return mA(e,t)?e:wp(e,t)[0]||e}function p7(e){return!e||!e.isConnected?!1:typeof e.checkVisibility=="function"?e.checkVisibility():xr(e).display!=="none"}function gC(e,t){if(!t.current.includes("floating")&&!e.getAttribute("role")?.includes("dialog"))return;const n=Qu(),i=t7(e,n).filter(l=>{const f=l.getAttribute("data-tabindex")||"";return mA(l,n)||l.hasAttribute("data-tabindex")&&!f.startsWith("-")}),a=e.getAttribute("tabindex");t.current.includes("floating")||i.length===0?a!=="0"&&e.setAttribute("tabindex","0"):(a!=="-1"||e.hasAttribute("data-tabindex")&&e.getAttribute("data-tabindex")!=="-1")&&(e.setAttribute("tabindex","-1"),e.setAttribute("data-tabindex","-1"))}function EA(e){const{context:t,children:n,disabled:s=!1,initialFocus:i=!0,returnFocus:a=!0,restoreFocus:l=!1,modal:f=!0,closeOnFocusOut:d=!0,openInteractionType:p="",nextFocusableElement:g,previousFocusableElement:y,beforeContentFocusGuardRef:b,externalTree:x}=e,S="rootStore"in t?t.rootStore:t,w=S.useState("open"),T=S.useState("domReferenceElement"),C=S.useState("floatingElement"),{events:O,dataRef:N}=S.context,R=Ae(()=>N.current.floatingContext?.nodeId),M=i===!1,z=aC(T)&&M,j=_.useRef(["content"]),A=Jo(i),P=Jo(a),Q=Jo(p),B=Tp(x),U=SA(),Z=_.useRef(null),K=_.useRef(null),ee=_.useRef(!1),D=_.useRef(!1),G=_.useRef(!1),q=_.useRef(-1),V=_.useRef(""),L=_.useRef(""),I=_.useRef(null),H=_.useRef(null),W=oo(I,b,U?.beforeInsideRef),Y=oo(H,U?.afterInsideRef),ae=ns(),se=ns(),fe=ix(),Se=U!=null,pe=Bh(C),Oe=Ae((he=pe)=>he?wp(he,Qu()):[]),_e=Ae(he=>{const ie=Oe(he);return j.current.map(()=>ie).filter(Boolean).flat()});_.useEffect(()=>{if(s||!f)return;function he(we){we.key==="Tab"&&Ot(pe,Fo(Rt(pe)))&&Oe().length===0&&!z&&Ki(we)}const ie=Rt(pe);return ie.addEventListener("keydown",he),()=>{ie.removeEventListener("keydown",he)}},[s,T,pe,f,j,z,Oe,_e]),_.useEffect(()=>{if(s||!w)return;const he=Rt(pe);function ie(){G.current=!1}function we(xe){const ve=Ur(xe),Ie=Ot(C,ve)||Ot(T,ve)||Ot(U?.portalNode,ve);G.current=!Ie,L.current=xe.pointerType||"keyboard",ve?.closest(`[${Y9}]`)&&(D.current=!0)}function ye(){L.current="keyboard"}return he.addEventListener("pointerdown",we,!0),he.addEventListener("pointerup",ie,!0),he.addEventListener("pointercancel",ie,!0),he.addEventListener("keydown",ye,!0),()=>{he.removeEventListener("pointerdown",we,!0),he.removeEventListener("pointerup",ie,!0),he.removeEventListener("pointercancel",ie,!0),he.removeEventListener("keydown",ye,!0)}},[s,C,T,pe,w,U]),_.useEffect(()=>{if(s||!d)return;const he=Rt(pe);function ie(){D.current=!0,se.start(0,()=>{D.current=!1})}function we(Ue){const Ee=Ur(Ue),Qe=Oe().indexOf(Ee);Qe!==-1&&(q.current=Qe)}function ye(Ue){const Ee=Ue.relatedTarget,Ve=Ue.currentTarget,Qe=Ur(Ue);queueMicrotask(()=>{const Be=R(),We=S.context.triggerElements,He=Ee?.hasAttribute(Nu("focus-guard"))&&[I.current,H.current,U?.beforeInsideRef.current,U?.afterInsideRef.current,U?.beforeOutsideRef.current,U?.afterOutsideRef.current,qs(y),qs(g)].includes(Ee),me=!(Ot(T,Ee)||Ot(C,Ee)||Ot(Ee,C)||Ot(U?.portalNode,Ee)||Ee!=null&&We.hasElement(Ee)||We.hasMatchingElement(Te=>Ot(Te,Ee))||He||B&&(xc(B.nodesRef.current,Be).find(Te=>Ot(Te.context?.elements.floating,Ee)||Ot(Te.context?.elements.domReference,Ee))||cC(B.nodesRef.current,Be).find(Te=>[Te.context?.elements.floating,Bh(Te.context?.elements.floating)].includes(Ee)||Te.context?.elements.domReference===Ee)));if(Ve===T&&pe&&gC(pe,j),l&&Ve!==T&&!p7(Qe)&&Fo(he)===he.body){if(Zt(pe)&&(pe.focus(),l==="popup")){fe.request(()=>{pe.focus()});return}const Te=q.current,qe=Oe(),mt=qe[Te]||qe[qe.length-1]||pe;Zt(mt)&&mt.focus()}if(N.current.insideReactTree){N.current.insideReactTree=!1;return}(z||!f)&&Ee&&me&&!D.current&&(z||Ee!==Iy())&&(ee.current=!0,S.setOpen(!1,Yt(Lj,Ue)))})}function xe(){G.current||(N.current.insideReactTree=!0,ae.start(0,()=>{N.current.insideReactTree=!1}))}const ve=Zt(T)?T:null,Ie=[];if(!(!C&&!ve))return ve&&(ve.addEventListener("focusout",ye),ve.addEventListener("pointerdown",ie),Ie.push(()=>{ve.removeEventListener("focusout",ye),ve.removeEventListener("pointerdown",ie)})),C&&(C.addEventListener("focusin",we),C.addEventListener("focusout",ye),U&&(C.addEventListener("focusout",xe,!0),Ie.push(()=>{C.removeEventListener("focusout",xe,!0)})),Ie.push(()=>{C.removeEventListener("focusin",we),C.removeEventListener("focusout",ye)})),()=>{Ie.forEach(Ue=>{Ue()})}},[s,T,C,pe,f,B,U,S,d,l,Oe,z,R,j,N,ae,se,fe,g,y]),_.useEffect(()=>{if(s||!C||!w)return;const he=Array.from(U?.portalNode?.querySelectorAll(`[${Nu("portal")}]`)||[]),we=(B?cC(B.nodesRef.current,R()):[]).find(xe=>aC(xe.context?.elements.domReference||null))?.context?.elements.domReference,ye=[C,we,...he,Z.current,K.current,I.current,H.current,U?.beforeOutsideRef.current,U?.afterOutsideRef.current,qs(y),qs(g),z?T:null].filter(xe=>xe!=null);return l7(ye,f||z)},[w,s,T,C,f,j,U,z,B,R,g,y]),Le(()=>{if(!w||s||!Zt(pe))return;const he=Rt(pe),ie=Fo(he);queueMicrotask(()=>{const we=_e(pe),ye=A.current,xe=typeof ye=="function"?ye(Q.current||""):ye;if(xe===void 0||xe===!1)return;let ve;xe===!0||xe===null?ve=we[0]||pe:ve=qs(xe),ve=ve||we[0]||pe,!Ot(pe,ie)&&Oy(ve,{preventScroll:ve===pe})})},[s,w,pe,M,_e,A,Q]),Le(()=>{if(s||!pe)return;const he=Rt(pe),ie=Fo(he);d7(ie);function we(ve){if(ve.open||(V.current=f7(ve.nativeEvent,L.current)),ve.reason===Ov&&ve.nativeEvent.type==="mouseleave"&&(ee.current=!0),ve.reason===zj)if(ve.nested)ee.current=!1;else if(xV(ve.nativeEvent)||SV(ve.nativeEvent))ee.current=!1;else{let Ie=!1;document.createElement("div").focus({get preventScroll(){return Ie=!0,!1}}),Ie?ee.current=!1:ee.current=!0}}O.on("openchange",we);const ye=he.createElement("span");ye.setAttribute("tabindex","-1"),ye.setAttribute("aria-hidden","true"),Object.assign(ye.style,mp),Se&&T&&T.insertAdjacentElement("afterend",ye);function xe(){const ve=P.current;let Ie=typeof ve=="function"?ve(V.current):ve;if(Ie===void 0||Ie===!1)return null;if(Ie===null&&(Ie=!0),typeof Ie=="boolean"){const Ee=T||Iy();return Ee&&Ee.isConnected?Ee:ye}const Ue=T||Iy()||ye;return qs(Ie)||Ue}return()=>{O.off("openchange",we);const ve=Fo(he),Ie=Ot(C,ve)||B&&xc(B.nodesRef.current,R(),!1).some(Ee=>Ot(Ee.context?.elements.floating,ve)),Ue=xe();queueMicrotask(()=>{const Ee=h7(Ue),Ve=typeof P.current!="boolean";P.current&&!ee.current&&Zt(Ee)&&(!(!Ve&&Ee!==ve&&ve!==he.body)||Ie)&&Ee.focus({preventScroll:!0}),ye.remove(),ee.current=!1})}},[s,C,pe,P,N,O,B,Se,T,R]),Le(()=>{if(!nx||w||!C)return;const he=Fo(Rt(C));!Zt(he)||!aA(he)||Ot(C,he)&&he.blur()},[w,C]),Le(()=>{if(!(s||!U))return U.setFocusManagerState({modal:f,closeOnFocusOut:d,open:w,onOpenChange:S.setOpen,domReference:T}),()=>{U.setFocusManagerState(null)}},[s,U,f,w,S,d,T]),Le(()=>{if(!(s||!pe))return gC(pe,j),()=>{queueMicrotask(ax)}},[s,pe,j]);const re=!s&&(f?!z:!0)&&(Se||f);return h.jsxs(_.Fragment,{children:[re&&h.jsx(Yh,{"data-type":"inside",ref:W,onFocus:he=>{if(f){const ie=_e();Oy(ie[ie.length-1])}else U?.portalNode&&(ee.current=!1,mu(he,U.portalNode)?yA(T)?.focus():qs(y??U.beforeOutsideRef)?.focus())}}),n,re&&h.jsx(Yh,{"data-type":"inside",ref:Y,onFocus:he=>{f?Oy(_e()[0]):U?.portalNode&&(d&&(ee.current=!0),mu(he,U.portalNode)?vA(T)?.focus():qs(g??U.afterOutsideRef)?.focus())}})]})}function yC(e,t,n){let{reference:s,floating:i}=e;const a=Fr(t),l=ox(t),f=sx(l),d=Zn(t),p=a==="y",g=s.x+s.width/2-i.width/2,y=s.y+s.height/2-i.height/2,b=s[f]/2-i[f]/2;let x;switch(d){case"top":x={x:g,y:s.y-i.height};break;case"bottom":x={x:g,y:s.y+s.height};break;case"right":x={x:s.x+s.width,y};break;case"left":x={x:s.x-i.width,y};break;default:x={x:s.x,y:s.y}}switch(Si(t)){case"start":x[l]-=b*(n&&p?-1:1);break;case"end":x[l]+=b*(n&&p?-1:1);break}return x}async function m7(e,t){var n;t===void 0&&(t={});const{x:s,y:i,platform:a,rects:l,elements:f,strategy:d}=e,{boundary:p="clippingAncestors",rootBoundary:g="viewport",elementContext:y="floating",altBoundary:b=!1,padding:x=0}=ao(t,e),S=cA(x),T=f[b?y==="floating"?"reference":"floating":y],C=qh(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(T)))==null||n?T:T.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(f.floating)),boundary:p,rootBoundary:g,strategy:d})),O=y==="floating"?{x:s,y:i,width:l.floating.width,height:l.floating.height}:l.reference,N=await(a.getOffsetParent==null?void 0:a.getOffsetParent(f.floating)),R=await(a.isElement==null?void 0:a.isElement(N))?await(a.getScale==null?void 0:a.getScale(N))||{x:1,y:1}:{x:1,y:1},M=qh(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:f,rect:O,offsetParent:N,strategy:d}):O);return{top:(C.top-M.top+S.top)/R.y,bottom:(M.bottom-C.bottom+S.bottom)/R.y,left:(C.left-M.left+S.left)/R.x,right:(M.right-C.right+S.right)/R.x}}const g7=async(e,t,n)=>{const{placement:s="bottom",strategy:i="absolute",middleware:a=[],platform:l}=n,f=a.filter(Boolean),d=await(l.isRTL==null?void 0:l.isRTL(t));let p=await l.getElementRects({reference:e,floating:t,strategy:i}),{x:g,y}=yC(p,s,d),b=s,x={},S=0;for(let T=0;T<f.length;T++){var w;const{name:C,fn:O}=f[T],{x:N,y:R,data:M,reset:z}=await O({x:g,y,initialPlacement:s,placement:b,strategy:i,middlewareData:x,rects:p,platform:{...l,detectOverflow:(w=l.detectOverflow)!=null?w:m7},elements:{reference:e,floating:t}});g=N??g,y=R??y,x={...x,[C]:{...x[C],...M}},z&&S<=50&&(S++,typeof z=="object"&&(z.placement&&(b=z.placement),z.rects&&(p=z.rects===!0?await l.getElementRects({reference:e,floating:t,strategy:i}):z.rects),{x:g,y}=yC(p,b,d)),T=-1)}return{x:g,y,placement:b,strategy:i,middlewareData:x}},y7=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,s;const{placement:i,middlewareData:a,rects:l,initialPlacement:f,platform:d,elements:p}=t,{mainAxis:g=!0,crossAxis:y=!0,fallbackPlacements:b,fallbackStrategy:x="bestFit",fallbackAxisSideDirection:S="none",flipAlignment:w=!0,...T}=ao(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const C=Zn(i),O=Fr(f),N=Zn(f)===f,R=await(d.isRTL==null?void 0:d.isRTL(p.floating)),M=b||(N||!w?[Hh(f)]:jV(f)),z=S!=="none";!b&&z&&M.push(...MV(f,w,S,R));const j=[f,...M],A=await d.detectOverflow(t,T),P=[];let Q=((s=a.flip)==null?void 0:s.overflows)||[];if(g&&P.push(A[C]),y){const K=NV(i,l,R);P.push(A[K[0]],A[K[1]])}if(Q=[...Q,{placement:i,overflows:P}],!P.every(K=>K<=0)){var B,U;const K=(((B=a.flip)==null?void 0:B.index)||0)+1,ee=j[K];if(ee&&(!(y==="alignment"?O!==Fr(ee):!1)||Q.every(q=>Fr(q.placement)===O?q.overflows[0]>0:!0)))return{data:{index:K,overflows:Q},reset:{placement:ee}};let D=(U=Q.filter(G=>G.overflows[0]<=0).sort((G,q)=>G.overflows[1]-q.overflows[1])[0])==null?void 0:U.placement;if(!D)switch(x){case"bestFit":{var Z;const G=(Z=Q.filter(q=>{if(z){const V=Fr(q.placement);return V===O||V==="y"}return!0}).map(q=>[q.placement,q.overflows.filter(V=>V>0).reduce((V,L)=>V+L,0)]).sort((q,V)=>q[1]-V[1])[0])==null?void 0:Z[0];G&&(D=G);break}case"initialPlacement":D=f;break}if(i!==D)return{reset:{placement:D}}}return{}}}};function vC(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function bC(e){return EV.some(t=>e[t]>=0)}const v7=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:s}=t,{strategy:i="referenceHidden",...a}=ao(e,t);switch(i){case"referenceHidden":{const l=await s.detectOverflow(t,{...a,elementContext:"reference"}),f=vC(l,n.reference);return{data:{referenceHiddenOffsets:f,referenceHidden:bC(f)}}}case"escaped":{const l=await s.detectOverflow(t,{...a,altBoundary:!0}),f=vC(l,n.floating);return{data:{escapedOffsets:f,escaped:bC(f)}}}default:return{}}}}},TA=new Set(["left","top"]);async function b7(e,t){const{placement:n,platform:s,elements:i}=e,a=await(s.isRTL==null?void 0:s.isRTL(i.floating)),l=Zn(n),f=Si(n),d=Fr(n)==="y",p=TA.has(l)?-1:1,g=a&&d?-1:1,y=ao(t,e);let{mainAxis:b,crossAxis:x,alignmentAxis:S}=typeof y=="number"?{mainAxis:y,crossAxis:0,alignmentAxis:null}:{mainAxis:y.mainAxis||0,crossAxis:y.crossAxis||0,alignmentAxis:y.alignmentAxis};return f&&typeof S=="number"&&(x=f==="end"?S*-1:S),d?{x:x*g,y:b*p}:{x:b*p,y:x*g}}const x7=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,s;const{x:i,y:a,placement:l,middlewareData:f}=t,d=await b7(t,e);return l===((n=f.offset)==null?void 0:n.placement)&&(s=f.arrow)!=null&&s.alignmentOffset?{}:{x:i+d.x,y:a+d.y,data:{...d,placement:l}}}}},S7=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:s,placement:i,platform:a}=t,{mainAxis:l=!0,crossAxis:f=!1,limiter:d={fn:C=>{let{x:O,y:N}=C;return{x:O,y:N}}},...p}=ao(e,t),g={x:n,y:s},y=await a.detectOverflow(t,p),b=Fr(Zn(i)),x=rx(b);let S=g[x],w=g[b];if(l){const C=x==="y"?"top":"left",O=x==="y"?"bottom":"right",N=S+y[C],R=S-y[O];S=Pv(N,S,R)}if(f){const C=b==="y"?"top":"left",O=b==="y"?"bottom":"right",N=w+y[C],R=w-y[O];w=Pv(N,w,R)}const T=d.fn({...t,[x]:S,[b]:w});return{...T,data:{x:T.x-n,y:T.y-s,enabled:{[x]:l,[b]:f}}}}}},_7=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:s,placement:i,rects:a,middlewareData:l}=t,{offset:f=0,mainAxis:d=!0,crossAxis:p=!0}=ao(e,t),g={x:n,y:s},y=Fr(i),b=rx(y);let x=g[b],S=g[y];const w=ao(f,t),T=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(d){const N=b==="y"?"height":"width",R=a.reference[b]-a.floating[N]+T.mainAxis,M=a.reference[b]+a.reference[N]-T.mainAxis;x<R?x=R:x>M&&(x=M)}if(p){var C,O;const N=b==="y"?"width":"height",R=TA.has(Zn(i)),M=a.reference[y]-a.floating[N]+(R&&((C=l.offset)==null?void 0:C[y])||0)+(R?0:T.crossAxis),z=a.reference[y]+a.reference[N]+(R?0:((O=l.offset)==null?void 0:O[y])||0)-(R?T.crossAxis:0);S<M?S=M:S>z&&(S=z)}return{[b]:x,[y]:S}}}},w7=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,s;const{placement:i,rects:a,platform:l,elements:f}=t,{apply:d=()=>{},...p}=ao(e,t),g=await l.detectOverflow(t,p),y=Zn(i),b=Si(i),x=Fr(i)==="y",{width:S,height:w}=a.floating;let T,C;y==="top"||y==="bottom"?(T=y,C=b===(await(l.isRTL==null?void 0:l.isRTL(f.floating))?"start":"end")?"left":"right"):(C=y,T=b==="end"?"top":"bottom");const O=w-g.top-g.bottom,N=S-g.left-g.right,R=Lc(w-g[T],O),M=Lc(S-g[C],N),z=!t.middlewareData.shift;let j=R,A=M;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=N),(s=t.middlewareData.shift)!=null&&s.enabled.y&&(j=O),z&&!b){const Q=dr(g.left,0),B=dr(g.right,0),U=dr(g.top,0),Z=dr(g.bottom,0);x?A=S-2*(Q!==0||B!==0?Q+B:dr(g.left,g.right)):j=w-2*(U!==0||Z!==0?U+Z:dr(g.top,g.bottom))}await d({...t,availableWidth:A,availableHeight:j});const P=await l.getDimensions(f.floating);return S!==P.width||w!==P.height?{reset:{rects:!0}}:{}}}};function CA(e){const t=xr(e);let n=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const i=Zt(e),a=i?e.offsetWidth:n,l=i?e.offsetHeight:s,f=Fh(n)!==a||Fh(s)!==l;return f&&(n=a,s=l),{width:n,height:s,$:f}}function cx(e){return jt(e)?e:e.contextElement}function _c(e){const t=cx(e);if(!Zt(t))return xs(1);const n=t.getBoundingClientRect(),{width:s,height:i,$:a}=CA(t);let l=(a?Fh(n.width):n.width)/s,f=(a?Fh(n.height):n.height)/i;return(!l||!Number.isFinite(l))&&(l=1),(!f||!Number.isFinite(f))&&(f=1),{x:l,y:f}}const E7=xs(0);function RA(e){const t=un(e);return!vp()||!t.visualViewport?E7:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function T7(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==un(e)?!1:t}function da(e,t,n,s){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),a=cx(e);let l=xs(1);t&&(s?jt(s)&&(l=_c(s)):l=_c(e));const f=T7(a,n,s)?RA(a):xs(0);let d=(i.left+f.x)/l.x,p=(i.top+f.y)/l.y,g=i.width/l.x,y=i.height/l.y;if(a){const b=un(a),x=s&&jt(s)?un(s):s;let S=b,w=Av(S);for(;w&&s&&x!==S;){const T=_c(w),C=w.getBoundingClientRect(),O=xr(w),N=C.left+(w.clientLeft+parseFloat(O.paddingLeft))*T.x,R=C.top+(w.clientTop+parseFloat(O.paddingTop))*T.y;d*=T.x,p*=T.y,g*=T.x,y*=T.y,d+=N,p+=R,S=un(w),w=Av(S)}}return qh({width:g,height:y,x:d,y:p})}function Cp(e,t){const n=bp(e).scrollLeft;return t?t.left+n:da(_s(e)).left+n}function NA(e,t){const n=e.getBoundingClientRect(),s=n.left+t.scrollLeft-Cp(e,n),i=n.top+t.scrollTop;return{x:s,y:i}}function C7(e){let{elements:t,rect:n,offsetParent:s,strategy:i}=e;const a=i==="fixed",l=_s(s),f=t?yp(t.floating):!1;if(s===l||f&&a)return n;let d={scrollLeft:0,scrollTop:0},p=xs(1);const g=xs(0),y=Zt(s);if((y||!y&&!a)&&((yi(s)!=="body"||vi(l))&&(d=bp(s)),Zt(s))){const x=da(s);p=_c(s),g.x=x.x+s.clientLeft,g.y=x.y+s.clientTop}const b=l&&!y&&!a?NA(l,d):xs(0);return{width:n.width*p.x,height:n.height*p.y,x:n.x*p.x-d.scrollLeft*p.x+g.x+b.x,y:n.y*p.y-d.scrollTop*p.y+g.y+b.y}}function R7(e){return Array.from(e.getClientRects())}function N7(e){const t=_s(e),n=bp(e),s=e.ownerDocument.body,i=dr(t.scrollWidth,t.clientWidth,s.scrollWidth,s.clientWidth),a=dr(t.scrollHeight,t.clientHeight,s.scrollHeight,s.clientHeight);let l=-n.scrollLeft+Cp(e);const f=-n.scrollTop;return xr(s).direction==="rtl"&&(l+=dr(t.clientWidth,s.clientWidth)-i),{width:i,height:a,x:l,y:f}}const xC=25;function j7(e,t){const n=un(e),s=_s(e),i=n.visualViewport;let a=s.clientWidth,l=s.clientHeight,f=0,d=0;if(i){a=i.width,l=i.height;const g=vp();(!g||g&&t==="fixed")&&(f=i.offsetLeft,d=i.offsetTop)}const p=Cp(s);if(p<=0){const g=s.ownerDocument,y=g.body,b=getComputedStyle(y),x=g.compatMode==="CSS1Compat"&&parseFloat(b.marginLeft)+parseFloat(b.marginRight)||0,S=Math.abs(s.clientWidth-y.clientWidth-x);S<=xC&&(a-=S)}else p<=xC&&(a+=p);return{width:a,height:l,x:f,y:d}}const A7=new Set(["absolute","fixed"]);function k7(e,t){const n=da(e,!0,t==="fixed"),s=n.top+e.clientTop,i=n.left+e.clientLeft,a=Zt(e)?_c(e):xs(1),l=e.clientWidth*a.x,f=e.clientHeight*a.y,d=i*a.x,p=s*a.y;return{width:l,height:f,x:d,y:p}}function SC(e,t,n){let s;if(t==="viewport")s=j7(e,n);else if(t==="document")s=N7(_s(e));else if(jt(t))s=k7(t,n);else{const i=RA(e);s={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return qh(s)}function jA(e,t){const n=io(e);return n===t||!jt(n)||Xs(n)?!1:xr(n).position==="fixed"||jA(n,t)}function O7(e,t){const n=t.get(e);if(n)return n;let s=Wo(e,[],!1).filter(f=>jt(f)&&yi(f)!=="body"),i=null;const a=xr(e).position==="fixed";let l=a?io(e):e;for(;jt(l)&&!Xs(l);){const f=xr(l),d=Zb(l);!d&&f.position==="fixed"&&(i=null),(a?!d&&!i:!d&&f.position==="static"&&!!i&&A7.has(i.position)||vi(l)&&!d&&jA(e,l))?s=s.filter(g=>g!==l):i=f,l=io(l)}return t.set(e,s),s}function M7(e){let{element:t,boundary:n,rootBoundary:s,strategy:i}=e;const l=[...n==="clippingAncestors"?yp(t)?[]:O7(t,this._c):[].concat(n),s],f=l[0],d=l.reduce((p,g)=>{const y=SC(t,g,i);return p.top=dr(y.top,p.top),p.right=Lc(y.right,p.right),p.bottom=Lc(y.bottom,p.bottom),p.left=dr(y.left,p.left),p},SC(t,f,i));return{width:d.right-d.left,height:d.bottom-d.top,x:d.left,y:d.top}}function I7(e){const{width:t,height:n}=CA(e);return{width:t,height:n}}function P7(e,t,n){const s=Zt(t),i=_s(t),a=n==="fixed",l=da(e,!0,a,t);let f={scrollLeft:0,scrollTop:0};const d=xs(0);function p(){d.x=Cp(i)}if(s||!s&&!a)if((yi(t)!=="body"||vi(i))&&(f=bp(t)),s){const x=da(t,!0,a,t);d.x=x.x+t.clientLeft,d.y=x.y+t.clientTop}else i&&p();a&&!s&&i&&p();const g=i&&!s&&!a?NA(i,f):xs(0),y=l.left+f.scrollLeft-d.x-g.x,b=l.top+f.scrollTop-d.y-g.y;return{x:y,y:b,width:l.width,height:l.height}}function Py(e){return xr(e).position==="static"}function _C(e,t){if(!Zt(e)||xr(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return _s(e)===n&&(n=n.ownerDocument.body),n}function AA(e,t){const n=un(e);if(yp(e))return n;if(!Zt(e)){let i=io(e);for(;i&&!Xs(i);){if(jt(i)&&!Py(i))return i;i=io(i)}return n}let s=_C(e,t);for(;s&&a8(s)&&Py(s);)s=_C(s,t);return s&&Xs(s)&&Py(s)&&!Zb(s)?n:s||d8(e)||n}const D7=async function(e){const t=this.getOffsetParent||AA,n=this.getDimensions,s=await n(e.floating);return{reference:P7(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function z7(e){return xr(e).direction==="rtl"}const L7={convertOffsetParentRelativeRectToViewportRelativeRect:C7,getDocumentElement:_s,getClippingRect:M7,getOffsetParent:AA,getElementRects:D7,getClientRects:R7,getDimensions:I7,getScale:_c,isElement:jt,isRTL:z7};function kA(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function U7(e,t){let n=null,s;const i=_s(e);function a(){var f;clearTimeout(s),(f=n)==null||f.disconnect(),n=null}function l(f,d){f===void 0&&(f=!1),d===void 0&&(d=1),a();const p=e.getBoundingClientRect(),{left:g,top:y,width:b,height:x}=p;if(f||t(),!b||!x)return;const S=hc(y),w=hc(i.clientWidth-(g+b)),T=hc(i.clientHeight-(y+x)),C=hc(g),N={rootMargin:-S+"px "+-w+"px "+-T+"px "+-C+"px",threshold:dr(0,Lc(1,d))||1};let R=!0;function M(z){const j=z[0].intersectionRatio;if(j!==d){if(!R)return l();j?l(!1,j):s=setTimeout(()=>{l(!1,1e-7)},1e3)}j===1&&!kA(p,e.getBoundingClientRect())&&l(),R=!1}try{n=new IntersectionObserver(M,{...N,root:i.ownerDocument})}catch{n=new IntersectionObserver(M,N)}n.observe(e)}return l(!0),a}function wC(e,t,n,s){s===void 0&&(s={});const{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:l=typeof ResizeObserver=="function",layoutShift:f=typeof IntersectionObserver=="function",animationFrame:d=!1}=s,p=cx(e),g=i||a?[...p?Wo(p):[],...Wo(t)]:[];g.forEach(C=>{i&&C.addEventListener("scroll",n,{passive:!0}),a&&C.addEventListener("resize",n)});const y=p&&f?U7(p,n):null;let b=-1,x=null;l&&(x=new ResizeObserver(C=>{let[O]=C;O&&O.target===p&&x&&(x.unobserve(t),cancelAnimationFrame(b),b=requestAnimationFrame(()=>{var N;(N=x)==null||N.observe(t)})),n()}),p&&!d&&x.observe(p),x.observe(t));let S,w=d?da(e):null;d&&T();function T(){const C=da(e);w&&!kA(w,C)&&n(),w=C,S=requestAnimationFrame(T)}return n(),()=>{var C;g.forEach(O=>{i&&O.removeEventListener("scroll",n),a&&O.removeEventListener("resize",n)}),y?.(),(C=x)==null||C.disconnect(),x=null,d&&cancelAnimationFrame(S)}}const $7=x7,B7=S7,F7=y7,H7=w7,q7=v7,V7=_7,K7=(e,t,n)=>{const s=new Map,i={platform:L7,...n},a={...i.platform,_c:s};return g7(e,t,{...i,platform:a})};var G7=typeof document<"u",Z7=function(){},lh=G7?_.useLayoutEffect:Z7;function Xh(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,s,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(s=n;s--!==0;)if(!Xh(e[s],t[s]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(s=n;s--!==0;)if(!{}.hasOwnProperty.call(t,i[s]))return!1;for(s=n;s--!==0;){const a=i[s];if(!(a==="_owner"&&e.$$typeof)&&!Xh(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function OA(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function EC(e,t){const n=OA(e);return Math.round(t*n)/n}function Dy(e){const t=_.useRef(e);return lh(()=>{t.current=e}),t}function Y7(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:s=[],platform:i,elements:{reference:a,floating:l}={},transform:f=!0,whileElementsMounted:d,open:p}=e,[g,y]=_.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[b,x]=_.useState(s);Xh(b,s)||x(s);const[S,w]=_.useState(null),[T,C]=_.useState(null),O=_.useCallback(q=>{q!==z.current&&(z.current=q,w(q))},[]),N=_.useCallback(q=>{q!==j.current&&(j.current=q,C(q))},[]),R=a||S,M=l||T,z=_.useRef(null),j=_.useRef(null),A=_.useRef(g),P=d!=null,Q=Dy(d),B=Dy(i),U=Dy(p),Z=_.useCallback(()=>{if(!z.current||!j.current)return;const q={placement:t,strategy:n,middleware:b};B.current&&(q.platform=B.current),K7(z.current,j.current,q).then(V=>{const L={...V,isPositioned:U.current!==!1};K.current&&!Xh(A.current,L)&&(A.current=L,hi.flushSync(()=>{y(L)}))})},[b,t,n,B,U]);lh(()=>{p===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,y(q=>({...q,isPositioned:!1})))},[p]);const K=_.useRef(!1);lh(()=>(K.current=!0,()=>{K.current=!1}),[]),lh(()=>{if(R&&(z.current=R),M&&(j.current=M),R&&M){if(Q.current)return Q.current(R,M,Z);Z()}},[R,M,Z,Q,P]);const ee=_.useMemo(()=>({reference:z,floating:j,setReference:O,setFloating:N}),[O,N]),D=_.useMemo(()=>({reference:R,floating:M}),[R,M]),G=_.useMemo(()=>{const q={position:n,left:0,top:0};if(!D.floating)return q;const V=EC(D.floating,g.x),L=EC(D.floating,g.y);return f?{...q,transform:"translate("+V+"px, "+L+"px)",...OA(D.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:V,top:L}},[n,f,D.floating,g.x,g.y]);return _.useMemo(()=>({...g,update:Z,refs:ee,elements:D,floatingStyles:G}),[g,Z,ee,D,G])}const X7=(e,t)=>({...$7(e),options:[e,t]}),Q7=(e,t)=>({...B7(e),options:[e,t]}),W7=(e,t)=>({...V7(e),options:[e,t]}),J7=(e,t)=>({...F7(e),options:[e,t]}),eK=(e,t)=>({...H7(e),options:[e,t]}),tK=(e,t)=>({...q7(e),options:[e,t]}),nK={intentional:"onClick",sloppy:"onPointerDown"};function rK(e){return{escapeKey:typeof e=="boolean"?e:e?.escapeKey??!1,outsidePress:typeof e=="boolean"?e:e?.outsidePress??!0}}function sK(e,t={}){const n="rootStore"in e?e.rootStore:e,s=n.useState("open"),i=n.useState("floatingElement"),a=n.useState("referenceElement"),l=n.useState("domReferenceElement"),{onOpenChange:f,dataRef:d}=n.context,{enabled:p=!0,escapeKey:g=!0,outsidePress:y=!0,outsidePressEvent:b="sloppy",referencePress:x=!1,referencePressEvent:S="sloppy",ancestorScroll:w=!1,bubbles:T,externalTree:C}=t,O=Tp(C),N=Ae(typeof y=="function"?y:()=>!1),R=typeof y=="function"?N:y,M=_.useRef(!1),{escapeKey:z,outsidePress:j}=rK(T),A=_.useRef(null),P=ns(),Q=ns(),B=Ae(()=>{Q.clear(),d.current.insideReactTree=!1}),U=_.useRef(!1),Z=_.useRef(""),K=Ae(re=>{Z.current=re.pointerType}),ee=Ae(()=>{const re=Z.current,he=re==="pen"||!re?"mouse":re,ie=typeof b=="function"?b():b;return typeof ie=="string"?ie:ie[he]}),D=Ae(re=>{if(!s||!p||!g||re.key!=="Escape"||U.current)return;const he=d.current.floatingContext?.nodeId,ie=O?xc(O.nodesRef.current,he):[];if(!z&&ie.length>0){let xe=!0;if(ie.forEach(ve=>{ve.context?.open&&!ve.context.dataRef.current.__escapeKeyBubbles&&(xe=!1)}),!xe)return}const we=bV(re)?re.nativeEvent:re,ye=Yt(v8,we);n.setOpen(!1,ye),!z&&!ye.isPropagationAllowed&&re.stopPropagation()}),G=Ae(re=>{const he=ee();return he==="intentional"&&re.type!=="click"||he==="sloppy"&&re.type==="click"}),q=Ae(()=>{d.current.insideReactTree=!0,Q.start(0,B)}),V=Ae((re,he=!1)=>{if(G(re)){B();return}if(d.current.insideReactTree){B();return}if(ee()==="intentional"&&he||typeof R=="function"&&!R(re))return;const ie=Ur(re),we=`[${Nu("inert")}]`,ye=Rt(n.select("floatingElement")).querySelectorAll(we),xe=n.context.triggerElements;if(ie&&(xe.hasElement(ie)||xe.hasMatchingElement(Ve=>Ot(Ve,ie))))return;let ve=jt(ie)?ie:null;for(;ve&&!Xs(ve);){const Ve=io(ve);if(Xs(Ve)||!jt(Ve))break;ve=Ve}if(ye.length&&jt(ie)&&!vV(ie)&&!Ot(ie,n.select("floatingElement"))&&Array.from(ye).every(Ve=>!Ot(ve,Ve)))return;if(Zt(ie)&&!("touches"in re)){const Ve=Xs(ie),Qe=xr(ie),Be=/auto|scroll/,We=Ve||Be.test(Qe.overflowX),He=Ve||Be.test(Qe.overflowY),me=We&&ie.clientWidth>0&&ie.scrollWidth>ie.clientWidth,Te=He&&ie.clientHeight>0&&ie.scrollHeight>ie.clientHeight,qe=Qe.direction==="rtl",mt=Te&&(qe?re.offsetX<=ie.offsetWidth-ie.clientWidth:re.offsetX>ie.clientWidth),lt=me&&re.offsetY>ie.clientHeight;if(mt||lt)return}const Ie=d.current.floatingContext?.nodeId,Ue=O&&xc(O.nodesRef.current,Ie).some(Ve=>Jr(re,Ve.context?.elements.floating));if(Jr(re,n.select("floatingElement"))||Jr(re,n.select("domReferenceElement"))||Ue)return;const Ee=O?xc(O.nodesRef.current,Ie):[];if(Ee.length>0){let Ve=!0;if(Ee.forEach(Qe=>{Qe.context?.open&&!Qe.context.dataRef.current.__outsidePressBubbles&&(Ve=!1)}),!Ve)return}n.setOpen(!1,Yt(zj,re)),B()}),L=Ae(re=>{ee()!=="sloppy"||re.pointerType==="touch"||!n.select("open")||!p||Jr(re,n.select("floatingElement"))||Jr(re,n.select("domReferenceElement"))||V(re)}),I=Ae(re=>{if(ee()!=="sloppy"||!n.select("open")||!p||Jr(re,n.select("floatingElement"))||Jr(re,n.select("domReferenceElement")))return;const he=re.touches[0];he&&(A.current={startTime:Date.now(),startX:he.clientX,startY:he.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},P.start(1e3,()=>{A.current&&(A.current.dismissOnTouchEnd=!1,A.current.dismissOnMouseDown=!1)}))}),H=Ae(re=>{const he=Ur(re);function ie(){I(re),he?.removeEventListener(re.type,ie)}he?.addEventListener(re.type,ie)}),W=Ae(re=>{const he=M.current;if(M.current=!1,P.clear(),re.type==="mousedown"&&A.current&&!A.current.dismissOnMouseDown)return;const ie=Ur(re);function we(){re.type==="pointerdown"?L(re):V(re,he),ie?.removeEventListener(re.type,we)}ie?.addEventListener(re.type,we)}),Y=Ae(re=>{if(ee()!=="sloppy"||!A.current||Jr(re,n.select("floatingElement"))||Jr(re,n.select("domReferenceElement")))return;const he=re.touches[0];if(!he)return;const ie=Math.abs(he.clientX-A.current.startX),we=Math.abs(he.clientY-A.current.startY),ye=Math.sqrt(ie*ie+we*we);ye>5&&(A.current.dismissOnTouchEnd=!0),ye>10&&(V(re),P.clear(),A.current=null)}),ae=Ae(re=>{const he=Ur(re);function ie(){Y(re),he?.removeEventListener(re.type,ie)}he?.addEventListener(re.type,ie)}),se=Ae(re=>{ee()!=="sloppy"||!A.current||Jr(re,n.select("floatingElement"))||Jr(re,n.select("domReferenceElement"))||(A.current.dismissOnTouchEnd&&V(re),P.clear(),A.current=null)}),fe=Ae(re=>{const he=Ur(re);function ie(){se(re),he?.removeEventListener(re.type,ie)}he?.addEventListener(re.type,ie)});_.useEffect(()=>{if(!s||!p)return;d.current.__escapeKeyBubbles=z,d.current.__outsidePressBubbles=j;const re=new ai;function he(ve){n.setOpen(!1,Yt(ii,ve))}function ie(){re.clear(),U.current=!0}function we(){re.start(vp()?5:0,()=>{U.current=!1})}const ye=Rt(i);ye.addEventListener("pointerdown",K,!0),g&&(ye.addEventListener("keydown",D),ye.addEventListener("compositionstart",ie),ye.addEventListener("compositionend",we)),R&&(ye.addEventListener("click",W,!0),ye.addEventListener("pointerdown",W,!0),ye.addEventListener("touchstart",H,!0),ye.addEventListener("touchmove",ae,!0),ye.addEventListener("touchend",fe,!0),ye.addEventListener("mousedown",W,!0));let xe=[];return w&&(jt(l)&&(xe=Wo(l)),jt(i)&&(xe=xe.concat(Wo(i))),!jt(a)&&a&&a.contextElement&&(xe=xe.concat(Wo(a.contextElement)))),xe=xe.filter(ve=>ve!==ye.defaultView?.visualViewport),xe.forEach(ve=>{ve.addEventListener("scroll",he,{passive:!0})}),()=>{ye.removeEventListener("pointerdown",K,!0),g&&(ye.removeEventListener("keydown",D),ye.removeEventListener("compositionstart",ie),ye.removeEventListener("compositionend",we)),R&&(ye.removeEventListener("click",W,!0),ye.removeEventListener("pointerdown",W,!0),ye.removeEventListener("touchstart",H,!0),ye.removeEventListener("touchmove",ae,!0),ye.removeEventListener("touchend",fe,!0),ye.removeEventListener("mousedown",W,!0)),xe.forEach(ve=>{ve.removeEventListener("scroll",he)}),re.clear(),M.current=!1}},[d,i,a,l,g,R,s,f,w,p,z,j,D,V,W,L,H,ae,fe,K,n]),_.useEffect(B,[R,B]);const Se=_.useMemo(()=>({onKeyDown:D,...x&&{[nK[S]]:re=>{n.setOpen(!1,Yt(oC,re.nativeEvent))},...S!=="intentional"&&{onClick(re){n.setOpen(!1,Yt(oC,re.nativeEvent))}}}}),[D,n,x,S]),pe=Ae(re=>{const he=Ur(re.nativeEvent);!Ot(n.select("floatingElement"),he)||re.button!==0||(M.current=!0)}),Oe=Ae(re=>{!s||!p||re.button!==0||(M.current=!0)}),_e=_.useMemo(()=>({onKeyDown:D,onPointerDown:pe,onMouseDown:pe,onMouseUp:pe,onClickCapture:q,onMouseDownCapture(re){q(),Oe(re)},onPointerDownCapture(re){q(),Oe(re)},onMouseUpCapture:q,onTouchEndCapture:q,onTouchMoveCapture:q}),[D,pe,q,Oe]);return _.useMemo(()=>p?{reference:Se,floating:_e,trigger:Se}:{},[p,Se,_e])}nj({memoize:fq,memoizeOptions:{maxSize:1,equalityCheck:Object.is}});const Pe=(e,t,n,s,i,a,...l)=>{if(l.length>0)throw new Error(yn(1));let f;if(e)f=e;else throw new Error("Missing arguments");return f};var oK=VN();const iK=Kb(19),aK=iK?lK:uK;function at(e,t,n,s,i){return aK(e,t,n,s,i)}function cK(e,t,n,s,i){const a=_.useCallback(()=>t(e.getSnapshot(),n,s,i),[e,t,n,s,i]);return oK.useSyncExternalStore(e.subscribe,a,a)}function lK(e,t,n,s,i){return cK(e,t,n,s,i)}function uK(e,t,n,s,i){return KN.useSyncExternalStoreWithSelector(e.subscribe,e.getSnapshot,e.getSnapshot,a=>t(a,n,s,i))}class fK{constructor(t){this.state=t,this.listeners=new Set,this.updateTick=0}subscribe=t=>(this.listeners.add(t),()=>{this.listeners.delete(t)});getSnapshot=()=>this.state;setState(t){if(this.state===t)return;this.state=t,this.updateTick+=1;const n=this.updateTick;for(const s of this.listeners){if(n!==this.updateTick)return;s(t)}}update(t){for(const n in t)if(!Object.is(this.state[n],t[n])){this.setState({...this.state,...t});return}}set(t,n){Object.is(this.state[t],n)||this.setState({...this.state,[t]:n})}notifyAll(){const t={...this.state};this.setState(t)}use(t,n,s,i){return at(this,t,n,s,i)}}class MA extends fK{constructor(t,n={},s){super(t),this.context=n,this.selectors=s}useSyncedValue(t,n){_.useDebugValue(t),Le(()=>{this.state[t]!==n&&this.set(t,n)},[t,n])}useSyncedValueWithCleanup(t,n){const s=this;Le(()=>(s.state[t]!==n&&s.set(t,n),()=>{s.set(t,void 0)}),[s,t,n])}useSyncedValues(t){const n=this,s=Object.values(t);Le(()=>{n.update(t)},[n,...s])}useControlledProp(t,n){_.useDebugValue(t);const s=n!==void 0;Le(()=>{s&&!Object.is(this.state[t],n)&&super.setState({...this.state,[t]:n})},[t,n,s])}select(t,n,s,i){const a=this.selectors[t];return a(this.state,n,s,i)}useState(t,n,s,i){return _.useDebugValue(t),at(this,this.selectors[t],n,s,i)}useContextCallback(t,n){_.useDebugValue(t);const s=Ae(n??jn);this.context[t]=s}useStateSetter(t){const n=_.useRef(void 0);return n.current===void 0&&(n.current=s=>{this.set(t,s)}),n.current}observe(t,n){let s;typeof t=="function"?s=t:s=this.selectors[t];let i=s(this.state);return n(i,i,this),this.subscribe(a=>{const l=s(a);if(!Object.is(i,l)){const f=i;i=l,n(l,f,this)}})}}const dK={open:Pe(e=>e.open),domReferenceElement:Pe(e=>e.domReferenceElement),referenceElement:Pe(e=>e.positionReference??e.referenceElement),floatingElement:Pe(e=>e.floatingElement),floatingId:Pe(e=>e.floatingId)};class lx extends MA{constructor(t){const{nested:n,noEmit:s,onOpenChange:i,triggerElements:a,...l}=t;super({...l,positionReference:l.referenceElement,domReferenceElement:l.referenceElement},{onOpenChange:i,dataRef:{current:{}},events:r7(),nested:n,noEmit:s,triggerElements:a},dK)}setOpen=(t,n)=>{if((!t||!this.state.open||wV(n.event))&&(this.context.dataRef.current.openEvent=t?n.event:void 0),!this.context.noEmit){const s={open:t,reason:n.reason,nativeEvent:n.event,nested:this.context.nested,triggerElement:n.trigger};this.context.events.emit("openchange",s)}this.context.onOpenChange?.(t,n)}}function Rp(e,t=!1,n=!1){const[s,i]=_.useState(e&&t?"idle":void 0),[a,l]=_.useState(e);return e&&!a&&(l(!0),i("starting")),!e&&a&&s!=="ending"&&!n&&i("ending"),!e&&!a&&s==="ending"&&i(void 0),Le(()=>{if(!e&&a&&s!=="ending"&&n){const f=ys.request(()=>{i("ending")});return()=>{ys.cancel(f)}}},[e,a,s,n]),Le(()=>{if(!e||t)return;const f=ys.request(()=>{i(void 0)});return()=>{ys.cancel(f)}},[t,e]),Le(()=>{if(!e||!t)return;e&&a&&s!=="idle"&&i("starting");const f=ys.request(()=>{i("idle")});return()=>{ys.cancel(f)}},[t,e,a,i,s]),_.useMemo(()=>({mounted:a,setMounted:l,transitionStatus:s}),[a,s])}let ju=(function(e){return e.startingStyle="data-starting-style",e.endingStyle="data-ending-style",e})({});const hK={[ju.startingStyle]:""},pK={[ju.endingStyle]:""},ba={transitionStatus(e){return e==="starting"?hK:e==="ending"?pK:null}};function mK(e,t=!1,n=!0){const s=ix();return Ae((i,a=null)=>{s.cancel();function l(){hi.flushSync(i)}const f=qs(e);if(f==null)return;const d=f;if(typeof d.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED)i();else{let y=function(){const x=ju.startingStyle;if(!d.hasAttribute(x)){s.request(b);return}const S=new MutationObserver(()=>{d.hasAttribute(x)||(S.disconnect(),b())});S.observe(d,{attributes:!0,attributeFilter:[x]}),a?.addEventListener("abort",()=>S.disconnect(),{once:!0})},b=function(){Promise.all(d.getAnimations().map(x=>x.finished)).then(()=>{a?.aborted||l()}).catch(()=>{const x=d.getAnimations();if(n){if(a?.aborted)return;l()}else x.length>0&&x.some(S=>S.pending||S.playState!=="finished")&&b()})};var p=y,g=b;if(t){y();return}s.request(b)}})}function xa(e){const{enabled:t=!0,open:n,ref:s,onComplete:i}=e,a=Ae(i),l=mK(s,n,!1);_.useEffect(()=>{if(!t)return;const f=new AbortController;return l(a,f.signal),()=>{f.abort()}},[t,n,a,l])}function gK(e){const t=e.useState("open");Le(()=>{if(t&&!e.select("activeTriggerId")&&e.context.triggerElements.size===1){const n=e.context.triggerElements.entries().next();if(!n.done){const[s,i]=n.value;e.update({activeTriggerId:s,activeTriggerElement:i})}}},[t,e])}function yK(e,t,n){const{mounted:s,setMounted:i,transitionStatus:a}=Rp(e);t.useSyncedValues({mounted:s,transitionStatus:a});const l=Ae(()=>{i(!1),t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)}),f=t.useState("preventUnmountingOnClose");return xa({enabled:!f,open:e,ref:t.context.popupRef,onComplete(){e||l()}}),{forceUnmount:l,transitionStatus:a}}class ux{constructor(){this.elementsSet=new Set,this.idMap=new Map}add(t,n){const s=this.idMap.get(t);s!==n&&(s!==void 0&&this.elementsSet.delete(s),this.elementsSet.add(n),this.idMap.set(t,n))}delete(t){const n=this.idMap.get(t);n&&(this.elementsSet.delete(n),this.idMap.delete(t))}hasElement(t){return this.elementsSet.has(t)}hasMatchingElement(t){for(const n of this.elementsSet)if(t(n))return!0;return!1}getById(t){return this.idMap.get(t)}entries(){return this.idMap.entries()}elements(){return this.elementsSet.values()}get size(){return this.idMap.size}}function vK(){return new lx({open:!1,floatingElement:null,referenceElement:null,triggerElements:new ux,floatingId:"",nested:!1,noEmit:!1,onOpenChange:void 0})}function bK(){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:"idle",floatingRootContext:vK(),preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:an,inactiveTriggerProps:an,popupProps:an}}const Fd=Pe(e=>e.triggerIdProp??e.activeTriggerId),xK={open:Pe(e=>e.openProp??e.open),mounted:Pe(e=>e.mounted),transitionStatus:Pe(e=>e.transitionStatus),floatingRootContext:Pe(e=>e.floatingRootContext),preventUnmountingOnClose:Pe(e=>e.preventUnmountingOnClose),payload:Pe(e=>e.payload),activeTriggerId:Fd,activeTriggerElement:Pe(e=>e.mounted?e.activeTriggerElement:null),isTriggerActive:Pe((e,t)=>t!==void 0&&Fd(e)===t),isOpenedByTrigger:Pe((e,t)=>t!==void 0&&Fd(e)===t&&e.open),isMountedByTrigger:Pe((e,t)=>t!==void 0&&Fd(e)===t&&e.mounted),triggerProps:Pe((e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps),popupProps:Pe(e=>e.popupProps),popupElement:Pe(e=>e.popupElement),positionerElement:Pe(e=>e.positionerElement)};function SK(e){const{open:t=!1,onOpenChange:n,elements:s={}}=e,i=Xu(),a=Ep()!=null,l=zn(()=>new lx({open:t,onOpenChange:n,referenceElement:s.reference??null,floatingElement:s.floating??null,triggerElements:new ux,floatingId:i,nested:a,noEmit:!1})).current;return Le(()=>{const f={open:t,floatingId:i};s.reference!==void 0&&(f.referenceElement=s.reference,f.domReferenceElement=jt(s.reference)?s.reference:null),s.floating!==void 0&&(f.floatingElement=s.floating),l.update(f)},[t,i,s.reference,s.floating,l]),l.context.onOpenChange=n,l.context.nested=a,l.context.noEmit=!1,l}function _K(e={}){const{nodeId:t,externalTree:n}=e,s=SK(e),i=e.rootContext||s,a={reference:i.useState("referenceElement"),floating:i.useState("floatingElement"),domReference:i.useState("domReferenceElement")},[l,f]=_.useState(null),d=_.useRef(null),p=Tp(n);Le(()=>{a.domReference&&(d.current=a.domReference)},[a.domReference]);const g=Y7({...e,elements:{...a,...l&&{reference:l}}}),y=_.useCallback(j=>{const A=jt(j)?{getBoundingClientRect:()=>j.getBoundingClientRect(),getClientRects:()=>j.getClientRects(),contextElement:j}:j;f(A),g.refs.setReference(A)},[g.refs]),[b,x]=_.useState(null),[S,w]=_.useState(null);i.useSyncedValue("referenceElement",b),i.useSyncedValue("domReferenceElement",jt(b)?b:null),i.useSyncedValue("floatingElement",S);const T=_.useCallback(j=>{(jt(j)||j===null)&&(d.current=j,x(j)),(jt(g.refs.reference.current)||g.refs.reference.current===null||j!==null&&!jt(j))&&g.refs.setReference(j)},[g.refs,x]),C=_.useCallback(j=>{w(j),g.refs.setFloating(j)},[g.refs]),O=_.useMemo(()=>({...g.refs,setReference:T,setFloating:C,setPositionReference:y,domReference:d}),[g.refs,T,C,y]),N=_.useMemo(()=>({...g.elements,domReference:a.domReference}),[g.elements,a.domReference]),R=i.useState("open"),M=i.useState("floatingId"),z=_.useMemo(()=>({...g,dataRef:i.context.dataRef,open:R,onOpenChange:i.setOpen,events:i.context.events,floatingId:M,refs:O,elements:N,nodeId:t,rootStore:i}),[g,O,N,t,i,R,M]);return Le(()=>{i.context.dataRef.current.floatingContext=z;const j=p?.nodesRef.current.find(A=>A.id===t);j&&(j.context=z)}),_.useMemo(()=>({...g,context:z,refs:O,elements:N,rootStore:i}),[g,O,N,z,i])}function wK(e){const{popupStore:t,noEmit:n=!1,treatPopupAsFloatingElement:s=!1,onOpenChange:i}=e,a=Xu(),l=Ep()!=null,f=t.useState("open"),d=t.useState("activeTriggerElement"),p=t.useState(s?"popupElement":"positionerElement"),g=t.context.triggerElements,y=zn(()=>new lx({open:f,referenceElement:d,floatingElement:p,triggerElements:g,onOpenChange:i,floatingId:a,nested:l,noEmit:n})).current;return Le(()=>{const b={open:f,floatingId:a,referenceElement:d,floatingElement:p};jt(d)&&(b.domReferenceElement=d),y.state.positionReference===y.state.referenceElement&&(b.positionReference=d),y.update(b)},[f,a,d,p,y]),y.context.onOpenChange=i,y.context.nested=l,y.context.noEmit=n,y}const TC=Nu("safe-polygon"),EK=`button,a,[role="button"],select,[tabindex]:not([tabindex="-1"]),${iA}`;function TK(e){return e?!!e.closest(EK):!1}class fx{constructor(){this.pointerType=void 0,this.interactedInside=!1,this.handler=void 0,this.blockMouseMove=!0,this.performedPointerEventsMutation=!1,this.unbindMouseMove=()=>{},this.restTimeoutPending=!1,this.openChangeTimeout=new ai,this.restTimeout=new ai,this.handleCloseOptions=void 0}static create(){return new fx}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose}function CK(e){const t=zn(fx.create).current,n=e.context.dataRef.current;return n.hoverInteractionState||(n.hoverInteractionState=t),tx(n.hoverInteractionState.disposeEffect),n.hoverInteractionState}const RK=new Set(["click","mousedown"]);function NK(e,t={}){const n="rootStore"in e?e.rootStore:e,s=n.useState("open"),i=n.useState("floatingElement"),a=n.useState("domReferenceElement"),{dataRef:l}=n.context,{enabled:f=!0,closeDelay:d=0}=t,p=CK(n),g=Tp(),y=Ep(),b=Ae(()=>p.interactedInside?!0:l.current.openEvent?RK.has(l.current.openEvent.type):!1),x=Ae(()=>{const N=l.current.openEvent?.type;return N?.includes("mouse")&&N!=="mousedown"}),S=Ae(N=>yV(N,n.context.triggerElements)),w=_.useCallback((N,R=!0)=>{const M=jK(d,p.pointerType);M&&!p.handler?p.openChangeTimeout.start(M,()=>n.setOpen(!1,Yt(Ov,N))):R&&(p.openChangeTimeout.clear(),n.setOpen(!1,Yt(Ov,N)))},[d,n,p]),T=Ae(()=>{p.unbindMouseMove(),p.handler=void 0}),C=Ae(()=>{if(p.performedPointerEventsMutation){const N=Rt(i).body;N.style.pointerEvents="",N.removeAttribute(TC),p.performedPointerEventsMutation=!1}}),O=Ae(N=>{const R=Ur(N);if(!TK(R)){p.interactedInside=!1;return}p.interactedInside=!0});Le(()=>{s||(p.pointerType=void 0,p.restTimeoutPending=!1,p.interactedInside=!1,T(),C())},[s,p,T,C]),_.useEffect(()=>()=>{T()},[T]),_.useEffect(()=>C,[C]),Le(()=>{if(f&&s&&p.handleCloseOptions?.blockPointerEvents&&x()&&jt(a)&&i){p.performedPointerEventsMutation=!0;const N=Rt(i).body;N.setAttribute(TC,"");const R=a,M=i,z=g?.nodesRef.current.find(j=>j.id===y)?.context?.elements.floating;return z&&(z.style.pointerEvents=""),N.style.pointerEvents="none",R.style.pointerEvents="auto",M.style.pointerEvents="auto",()=>{N.style.pointerEvents="",R.style.pointerEvents="",M.style.pointerEvents=""}}},[f,s,a,i,p,x,g,y]),_.useEffect(()=>{if(!f)return;function N(j){b()||!l.current.floatingContext||!n.select("open")||S(j.relatedTarget)||(C(),T(),b()||w(j))}function R(j){p.openChangeTimeout.clear(),C(),p.handler?.(j),T()}function M(j){b()||w(j,!1)}const z=i;return z&&(z.addEventListener("mouseleave",N),z.addEventListener("mouseenter",R),z.addEventListener("mouseleave",M),z.addEventListener("pointerdown",O,!0)),()=>{z&&(z.removeEventListener("mouseleave",N),z.removeEventListener("mouseenter",R),z.removeEventListener("mouseleave",M),z.removeEventListener("pointerdown",O,!0))}},[f,i,n,l,b,S,w,C,T,O,p])}function jK(e,t){return t&&!_V(t)?0:typeof e=="function"?e():e}function AK(e=[]){const t=e.map(p=>p?.reference),n=e.map(p=>p?.floating),s=e.map(p=>p?.item),i=e.map(p=>p?.trigger),a=_.useCallback(p=>Hd(p,e,"reference"),t),l=_.useCallback(p=>Hd(p,e,"floating"),n),f=_.useCallback(p=>Hd(p,e,"item"),s),d=_.useCallback(p=>Hd(p,e,"trigger"),i);return _.useMemo(()=>({getReferenceProps:a,getFloatingProps:l,getItemProps:f,getTriggerProps:d}),[a,l,f,d])}function Hd(e,t,n){const s=new Map,i=n==="item",a={};n==="floating"&&(a.tabIndex=-1,a[Iv]="");for(const l in e)i&&e&&(l===sA||l===oA)||(a[l]=e[l]);for(let l=0;l<t.length;l+=1){let f;const d=t[l]?.[n];typeof d=="function"?f=e?d(e):null:f=d,f&&CC(a,f,i,s)}return CC(a,e,i,s),a}function CC(e,t,n,s){for(const i in t){const a=t[i];n&&(i===sA||i===oA)||(i.startsWith("on")?(s.has(i)||s.set(i,[]),typeof a=="function"&&(s.get(i)?.push(a),e[i]=(...l)=>s.get(i)?.map(f=>f(...l)).find(f=>f!==void 0))):e[i]=a)}}const kK=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function OK(e,t={}){const n="rootStore"in e?e.rootStore:e,s=n.useState("open"),i=n.useState("floatingId"),a=n.useState("domReferenceElement"),l=n.useState("floatingElement"),{role:f="dialog"}=t,d=Xu(),p=a?.id||d,g=_.useMemo(()=>Bh(l)?.id||i,[l,i]),y=kK.get(f)??f,x=Ep()!=null,S=_.useMemo(()=>y==="tooltip"||f==="label"?an:{"aria-haspopup":y==="alertdialog"?"dialog":y,"aria-expanded":"false",...y==="listbox"&&{role:"combobox"},...y==="menu"&&x&&{role:"menuitem"},...f==="select"&&{"aria-autocomplete":"none"},...f==="combobox"&&{"aria-autocomplete":"list"}},[y,x,f]),w=_.useMemo(()=>y==="tooltip"||f==="label"?{[`aria-${f==="label"?"labelledby":"describedby"}`]:s?g:void 0}:{...S,"aria-expanded":s?"true":"false","aria-controls":s?g:void 0,...y==="menu"&&{id:p}},[y,g,s,p,f,S]),T=_.useMemo(()=>{const O={id:g,...y&&{role:y}};return y==="tooltip"||f==="label"?O:{...O,...y==="menu"&&{"aria-labelledby":p}}},[y,g,p,f]),C=_.useCallback(({active:O,selected:N})=>{const R={role:"option",...O&&{id:`${g}-fui-option`}};switch(f){case"select":case"combobox":return{...R,"aria-selected":N}}return{}},[g,f]);return _.useMemo(()=>({reference:w,floating:T,item:C,trigger:S}),[w,T,S,C])}let Qi=(function(e){return e.open="data-open",e.closed="data-closed",e[e.startingStyle=ju.startingStyle]="startingStyle",e[e.endingStyle=ju.endingStyle]="endingStyle",e.anchorHidden="data-anchor-hidden",e.side="data-side",e.align="data-align",e})({}),RC=(function(e){return e.popupOpen="data-popup-open",e.pressed="data-pressed",e})({});const MK={[RC.popupOpen]:"",[RC.pressed]:""},IK={[Qi.open]:""},PK={[Qi.closed]:""},DK={[Qi.anchorHidden]:""},zK={open(e){return e?MK:null}},ol={open(e){return e?IK:PK},anchorHidden(e){return e?DK:null}},IA=_.createContext(void 0);function LK(){const e=_.useContext(IA);if(e===void 0)throw new Error(yn(70));return e}const UK=_.forwardRef(function(t,n){const{children:s,container:i,className:a,render:l,...f}=t,{portalNode:d,portalSubtree:p}=_A({container:i,ref:n,componentProps:t,elementProps:f});return!p&&!d?null:h.jsxs(_.Fragment,{children:[p,d&&hi.createPortal(s,d)]})}),$K=_.forwardRef(function(t,n){const{keepMounted:s=!1,...i}=t;return ex().useState("mounted")||s?h.jsx(IA.Provider,{value:s,children:h.jsx(UK,{ref:n,...i})}):null}),PA=_.createContext(void 0);function BK(){const e=_.useContext(PA);if(e===void 0)throw new Error(yn(71));return e}const FK=_.createContext(void 0);function DA(){return _.useContext(FK)?.direction??"ltr"}const HK=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:s,placement:i,rects:a,platform:l,elements:f,middlewareData:d}=t,{element:p,padding:g=0,offsetParent:y="real"}=ao(e,t)||{};if(p==null)return{};const b=cA(g),x={x:n,y:s},S=ox(i),w=sx(S),T=await l.getDimensions(p),C=S==="y",O=C?"top":"left",N=C?"bottom":"right",R=C?"clientHeight":"clientWidth",M=a.reference[w]+a.reference[S]-x[S]-a.floating[w],z=x[S]-a.reference[S],j=y==="real"?await l.getOffsetParent?.(p):f.floating;let A=f.floating[R]||a.floating[w];(!A||!await l.isElement?.(j))&&(A=f.floating[R]||a.floating[w]);const P=M/2-z/2,Q=A/2-T[w]/2-1,B=Math.min(b[O],Q),U=Math.min(b[N],Q),Z=B,K=A-T[w]-U,ee=A/2-T[w]/2+P,D=Pv(Z,ee,K),G=!d.arrow&&Si(i)!=null&&ee!==D&&a.reference[w]/2-(ee<Z?B:U)-T[w]/2<0,q=G?ee<Z?ee-Z:ee-K:0;return{[S]:x[S]+q,data:{[S]:D,centerOffset:ee-D-q,...G&&{alignmentOffset:q}},reset:G}}}),qK=(e,t)=>({...HK(e),options:[e,t]}),VK={name:"hide",async fn(e){const{width:t,height:n,x:s,y:i}=e.rects.reference,a=t===0&&n===0&&s===0&&i===0;return{data:{referenceHidden:(await tK().fn(e)).data?.referenceHidden||a}}}},uh={sideX:"left",sideY:"top"},KK={name:"adaptiveOrigin",async fn(e){const{x:t,y:n,rects:{floating:s},elements:{floating:i},platform:a,strategy:l,placement:f}=e,d=un(i),p=d.getComputedStyle(i);if(!(p.transitionDuration!=="0s"&&p.transitionDuration!==""))return{x:t,y:n,data:uh};const y=await a.getOffsetParent?.(i);let b={width:0,height:0};if(l==="fixed"&&d?.visualViewport)b={width:d.visualViewport.width,height:d.visualViewport.height};else if(y===d){const O=Rt(i);b={width:O.documentElement.clientWidth,height:O.documentElement.clientHeight}}else await a.isElement?.(y)&&(b=await a.getDimensions(y));const x=Zn(f);let S=t,w=n;x==="left"&&(S=b.width-(t+s.width)),x==="top"&&(w=b.height-(n+s.height));const T=x==="left"?"right":uh.sideX,C=x==="top"?"bottom":uh.sideY;return{x:S,y:w,data:{sideX:T,sideY:C}}}};function zA(e,t,n){const s=e==="inline-start"||e==="inline-end";return{top:"top",right:s?n?"inline-start":"inline-end":"right",bottom:"bottom",left:s?n?"inline-end":"inline-start":"left"}[t]}function NC(e,t,n){const{rects:s,placement:i}=e;return{side:zA(t,Zn(i),n),align:Si(i)||"center",anchor:{width:s.reference.width,height:s.reference.height},positioner:{width:s.floating.width,height:s.floating.height}}}function LA(e){const{anchor:t,positionMethod:n="absolute",side:s="bottom",sideOffset:i=0,align:a="center",alignOffset:l=0,collisionBoundary:f,collisionPadding:d=5,sticky:p=!1,arrowPadding:g=5,disableAnchorTracking:y=!1,keepMounted:b=!1,floatingRootContext:x,mounted:S,collisionAvoidance:w,shiftCrossAxis:T=!1,nodeId:C,adaptiveOrigin:O,lazyFlip:N=!1,externalTree:R}=e,[M,z]=_.useState(null);!S&&M!==null&&z(null);const j=w.side||"flip",A=w.align||"flip",P=w.fallbackAxisSide||"end",Q=typeof t=="function"?t:void 0,B=Ae(Q),U=Q?B:t,Z=Jo(t),ee=DA()==="rtl",D=M||{top:"top",right:"right",bottom:"bottom",left:"left","inline-end":ee?"left":"right","inline-start":ee?"right":"left"}[s],G=a==="center"?D:`${D}-${a}`;let q=d;const V=1,L=s==="bottom"?V:0,I=s==="top"?V:0,H=s==="right"?V:0,W=s==="left"?V:0;typeof q=="number"?q={top:q+L,right:q+W,bottom:q+I,left:q+H}:q&&(q={top:(q.top||0)+L,right:(q.right||0)+W,bottom:(q.bottom||0)+I,left:(q.left||0)+H});const Y={boundary:f==="clipping-ancestors"?"clippingAncestors":f,padding:q},ae=_.useRef(null),se=Jo(i),fe=Jo(l),Oe=[X7(ot=>{const Wt=NC(ot,s,ee),vn=typeof se.current=="function"?se.current(Wt):se.current,kt=typeof fe.current=="function"?fe.current(Wt):fe.current;return{mainAxis:vn,crossAxis:kt,alignmentAxis:kt}},[typeof i!="function"?i:0,typeof l!="function"?l:0,ee,s])],_e=A==="none"&&j!=="shift",re=!_e&&(p||T||j==="shift"),he=j==="none"?null:J7({...Y,padding:{top:q.top+V,right:q.right+V,bottom:q.bottom+V,left:q.left+V},mainAxis:!T&&j==="flip",crossAxis:A==="flip"?"alignment":!1,fallbackAxisSideDirection:P}),ie=_e?null:Q7(ot=>{const Wt=Rt(ot.elements.floating).documentElement;return{...Y,rootBoundary:T?{x:0,y:0,width:Wt.clientWidth,height:Wt.clientHeight}:void 0,mainAxis:A!=="none",crossAxis:re,limiter:p||T?void 0:W7(vn=>{if(!ae.current)return{};const{width:kt,height:Cn}=ae.current.getBoundingClientRect(),er=Fr(Zn(vn.placement)),An=er==="y"?kt:Cn,as=er==="y"?q.left+q.right:q.top+q.bottom;return{offset:An/2+as/2}})}},[Y,p,T,q,A]);j==="shift"||A==="shift"||a==="center"?Oe.push(ie,he):Oe.push(he,ie),Oe.push(eK({...Y,apply({elements:{floating:ot},rects:{reference:Wt},availableWidth:vn,availableHeight:kt}){const Cn=ot.style;Cn.setProperty("--available-width",`${vn}px`),Cn.setProperty("--available-height",`${kt}px`),Cn.setProperty("--anchor-width",`${Wt.width}px`),Cn.setProperty("--anchor-height",`${Wt.height}px`)}}),qK(()=>({element:ae.current||document.createElement("div"),padding:g,offsetParent:"floating"}),[g]),{name:"transformOrigin",fn(ot){const{elements:Wt,middlewareData:vn,placement:kt,rects:Cn,y:er}=ot,An=Zn(kt),as=Fr(An),cs=ae.current,_a=vn.arrow?.x||0,wi=vn.arrow?.y||0,Ei=cs?.clientWidth||0,ws=cs?.clientHeight||0,tr=_a+Ei/2,ls=wi+ws/2,fo=Math.abs(vn.shift?.y||0),ho=Cn.reference.height/2,nr=typeof i=="function"?i(NC(ot,s,ee)):i,al=fo>nr,af={top:`${tr}px calc(100% + ${nr}px)`,bottom:`${tr}px ${-nr}px`,left:`calc(100% + ${nr}px) ${ls}px`,right:`${-nr}px ${ls}px`}[An],cf=`${tr}px ${Cn.reference.y+ho-er}px`;return Wt.floating.style.setProperty("--transform-origin",re&&as==="y"&&al?cf:af),{}}},VK,O),Le(()=>{!S&&x&&x.update({referenceElement:null,floatingElement:null,domReferenceElement:null})},[S,x]);const we=_.useMemo(()=>({elementResize:!y&&typeof ResizeObserver<"u",layoutShift:!y&&typeof IntersectionObserver<"u"}),[y]),{refs:ye,elements:xe,x:ve,y:Ie,middlewareData:Ue,update:Ee,placement:Ve,context:Qe,isPositioned:Be,floatingStyles:We}=_K({rootContext:x,placement:G,middleware:Oe,strategy:n,whileElementsMounted:b?void 0:(...ot)=>wC(...ot,we),nodeId:C,externalTree:R}),{sideX:He,sideY:me}=Ue.adaptiveOrigin||uh,Te=Be?n:"fixed",qe=_.useMemo(()=>{const ot=O?{position:Te,[He]:ve,[me]:Ie}:{position:Te,...We};return Be||(ot.opacity=0),ot},[O,Te,He,ve,me,Ie,We,Be]),mt=_.useRef(null);Le(()=>{if(!S)return;const ot=Z.current,Wt=typeof ot=="function"?ot():ot,kt=(jC(Wt)?Wt.current:Wt)||null||null;kt!==mt.current&&(ye.setPositionReference(kt),mt.current=kt)},[S,ye,U,Z]),_.useEffect(()=>{if(!S)return;const ot=Z.current;typeof ot!="function"&&jC(ot)&&ot.current!==mt.current&&(ye.setPositionReference(ot.current),mt.current=ot.current)},[S,ye,U,Z]),_.useEffect(()=>{if(b&&S&&xe.domReference&&xe.floating)return wC(xe.domReference,xe.floating,Ee,we)},[b,S,xe,Ee,we]);const lt=Zn(Ve),wr=zA(s,lt,ee),Er=Si(Ve)||"center",Qt=!!Ue.hide?.referenceHidden;Le(()=>{N&&S&&Be&&z(lt)},[N,S,Be,lt]);const ut=_.useMemo(()=>({position:"absolute",top:Ue.arrow?.y,left:Ue.arrow?.x}),[Ue.arrow]),xt=Ue.arrow?.centerOffset!==0;return _.useMemo(()=>({positionerStyles:qe,arrowStyles:ut,arrowRef:ae,arrowUncentered:xt,side:wr,align:Er,physicalSide:lt,anchorHidden:Qt,refs:ye,context:Qe,isPositioned:Be,update:Ee}),[qe,ut,ae,xt,wr,Er,lt,Qt,ye,Qe,Be,Ee])}function jC(e){return e!=null&&"current"in e}function Np(e){return e==="starting"?Z9:an}const GK=_.forwardRef(function(t,n){const{render:s,className:i,anchor:a,positionMethod:l="absolute",side:f="top",align:d="center",sideOffset:p=0,alignOffset:g=0,collisionBoundary:y="clipping-ancestors",collisionPadding:b=5,arrowPadding:x=5,sticky:S=!1,disableAnchorTracking:w=!1,collisionAvoidance:T=Q9,...C}=t,O=ex(),N=LK(),R=O.useState("open"),M=O.useState("mounted"),z=O.useState("trackCursorAxis"),j=O.useState("disableHoverablePopup"),A=O.useState("floatingRootContext"),P=O.useState("instantType"),Q=O.useState("transitionStatus"),B=O.useState("hasViewport"),U=LA({anchor:a,positionMethod:l,floatingRootContext:A,mounted:M,side:f,sideOffset:p,align:d,alignOffset:g,collisionBoundary:y,collisionPadding:b,sticky:S,arrowPadding:x,disableAnchorTracking:w,keepMounted:N,collisionAvoidance:T,adaptiveOrigin:B?KK:void 0}),Z=_.useMemo(()=>{const G={};return(!R||z==="both"||j)&&(G.pointerEvents="none"),{role:"presentation",hidden:!M,style:{...U.positionerStyles,...G}}},[R,z,j,M,U.positionerStyles]),K=_.useMemo(()=>({open:R,side:U.side,align:U.align,anchorHidden:U.anchorHidden,instant:z!=="none"?"tracking-cursor":P}),[R,U.side,U.align,U.anchorHidden,z,P]),ee=_.useMemo(()=>({...K,arrowRef:U.arrowRef,arrowStyles:U.arrowStyles,arrowUncentered:U.arrowUncentered}),[K,U.arrowRef,U.arrowStyles,U.arrowUncentered]),D=zt("div",t,{state:K,props:[Z,Np(Q),C],ref:[n,O.useStateSetter("positionerElement")],stateAttributesMapping:ol});return h.jsx(PA.Provider,{value:ee,children:D})}),ZK={...ol,...ba},YK=_.forwardRef(function(t,n){const{className:s,render:i,...a}=t,l=ex(),{side:f,align:d}=BK(),p=l.useState("open"),g=l.useState("instantType"),y=l.useState("transitionStatus"),b=l.useState("popupProps"),x=l.useState("floatingRootContext");xa({open:p,ref:l.context.popupRef,onComplete(){p&&l.context.onOpenChangeComplete?.(!0)}});const S=l.useState("disabled"),w=l.useState("closeDelay");return NK(x,{enabled:!S,closeDelay:w}),zt("div",t,{state:{open:p,side:f,align:d,instant:g,transitionStatus:y},ref:[n,l.context.popupRef,l.useStateSetter("popupElement")],props:[b,Np(y),a],stateAttributesMapping:ZK})});function dx(e){return Kb(19)?e:e?"true":void 0}const XK=_.forwardRef(({className:e,sideOffset:t=4,children:n,...s},i)=>h.jsx($K,{children:h.jsx(GK,{sideOffset:t,children:h.jsx(YK,{ref:i,className:ge("bg-[#1e1e1e] border border-neutral-700 rounded-md px-2.5 py-1.5 text-xs text-neutral-300 font-mono shadow-lg",e),...s,children:n})})}));XK.displayName="TooltipContent";function AC(e){return e==="online"?"#22c55e":e==="syncing"?"#f59e0b":"#ef4444"}const UA=_.forwardRef(({className:e,clients:t,positions:n,relayClientIds:s=[],serverPosition:i={x:420,y:190},relayPosition:a={x:780,y:190},viewBox:l={width:1200,height:380},totalNodes:f,onlineCount:d,offlineCount:p,...g},y)=>{const b=i.x,x=i.y,S=a.x,w=a.y,T={},C=2*Math.PI/Math.max(t.length,1);t.forEach((j,A)=>{const P=s.includes(j.id),Q=P?S:b,B=P?w:x,U=P?240:260,Z=P?130:150,K=C*A-Math.PI/2;T[j.id]={x:Q+U*Math.cos(K),y:B+Z*Math.sin(K)}});const O={};if(n)for(const j of n)O[j.clientId]={x:j.x,y:j.y};function N(j){return O[j]??T[j]??{x:600,y:190}}const R=f??t.length+2,M=d??t.filter(j=>j.status!=="offline").length,z=p??t.filter(j=>j.status==="offline").length;return h.jsxs("div",{ref:y,className:ge("relative overflow-hidden","bg-[radial-gradient(ellipse_at_35%_50%,rgba(59,130,246,0.06)_0%,transparent_50%),radial-gradient(ellipse_at_68%_50%,rgba(139,92,246,0.04)_0%,transparent_40%),#0c0c0c]","bg-[image:radial-gradient(circle_at_1px_1px,#1a1a1a_1px,transparent_0)] bg-[size:24px_24px]",e),style:{height:420},...g,children:[h.jsx("div",{className:"absolute left-0 right-0 h-px bg-[linear-gradient(90deg,transparent,rgba(59,130,246,0.3),transparent)] animate-[scanSweep_6s_ease-in-out_infinite] pointer-events-none"}),h.jsx("div",{className:"absolute top-4 left-5 z-10",children:h.jsx("span",{className:"font-mono text-[10px] text-neutral-500 uppercase tracking-widest",children:"Sync Topology"})}),h.jsxs("div",{className:"absolute top-4 right-5 z-10 flex items-center gap-3",children:[h.jsxs("span",{className:"font-mono text-[10px] text-neutral-600",children:[R," nodes"]}),h.jsx("span",{className:"font-mono text-[10px] text-neutral-600",children:"·"}),h.jsxs("span",{className:"font-mono text-[10px] text-healthy",children:[M," online"]}),h.jsx("span",{className:"font-mono text-[10px] text-neutral-600",children:"·"}),h.jsxs("span",{className:"font-mono text-[10px] text-offline",children:[z," offline"]})]}),h.jsxs("svg",{viewBox:`0 0 ${l.width} ${l.height}`,className:"w-full h-full",preserveAspectRatio:"xMidYMid meet",children:[h.jsx("ellipse",{cx:b,cy:x,rx:280,ry:160,fill:"none",stroke:"#1a1a1a",strokeWidth:.5,strokeDasharray:"6 10"}),h.jsx("ellipse",{cx:S,cy:w,rx:260,ry:140,fill:"none",stroke:"#1a1a1a",strokeWidth:.5,strokeDasharray:"6 10"}),h.jsx("line",{x1:b,y1:x,x2:S,y2:w,stroke:"#8b5cf6",strokeWidth:2,opacity:.3}),h.jsx("line",{x1:b,y1:x,x2:S,y2:w,stroke:"#8b5cf6",strokeWidth:1,strokeDasharray:"4 2",opacity:.6,children:h.jsx("animate",{attributeName:"stroke-dashoffset",from:"20",to:"0",dur:"1s",repeatCount:"indefinite"})}),h.jsxs("circle",{r:3,fill:"#8b5cf6",opacity:.8,children:[h.jsx("animateMotion",{dur:"2.5s",repeatCount:"indefinite",path:`M${b},${x} L${S},${w}`}),h.jsx("animate",{attributeName:"opacity",values:"0;0.8;0.8;0",dur:"2.5s",repeatCount:"indefinite"})]}),h.jsxs("circle",{r:3,fill:"#8b5cf6",opacity:.8,children:[h.jsx("animateMotion",{dur:"2.5s",begin:"1.25s",repeatCount:"indefinite",path:`M${S},${w} L${b},${x}`}),h.jsx("animate",{attributeName:"opacity",values:"0;0.8;0.8;0",dur:"2.5s",begin:"1.25s",repeatCount:"indefinite"})]}),h.jsx("text",{x:(b+S)/2,y:x-20,textAnchor:"middle",fill:"#8b5cf6",fontFamily:"JetBrains Mono, monospace",fontSize:8,opacity:.4,letterSpacing:2,children:"BACKBONE"}),t.map(j=>{const A=N(j.id),P=s.includes(j.id),Q=P?S:b,B=P?w:x,U=AC(j.status),Z=j.status==="syncing"?2.5:1.5;if(j.status==="offline")return h.jsx("line",{x1:Q,y1:B,x2:A.x,y2:A.y,stroke:U,strokeWidth:1,strokeDasharray:"3 6",opacity:.2},`line-${j.id}`);const K=j.status==="syncing"?"1.2s":"2.8s",ee=`${Number.parseFloat(K)/2}s`;return h.jsxs("g",{children:[h.jsx("line",{x1:Q,y1:B,x2:A.x,y2:A.y,stroke:U,strokeWidth:Z,strokeDasharray:"4 2",children:h.jsx("animate",{attributeName:"stroke-dashoffset",from:"20",to:"0",dur:"1s",repeatCount:"indefinite"})}),h.jsxs("circle",{r:2.5,fill:U,opacity:.7,children:[h.jsx("animateMotion",{dur:K,repeatCount:"indefinite",path:`M${Q},${B} L${A.x},${A.y}`}),h.jsx("animate",{attributeName:"opacity",values:"0;0.7;0.7;0",dur:K,repeatCount:"indefinite"})]}),h.jsxs("circle",{r:2,fill:U,opacity:.5,children:[h.jsx("animateMotion",{dur:K,begin:ee,repeatCount:"indefinite",path:`M${A.x},${A.y} L${Q},${B}`}),h.jsx("animate",{attributeName:"opacity",values:"0;0.5;0.5;0",dur:K,begin:ee,repeatCount:"indefinite"})]})]},`line-${j.id}`)}),h.jsxs("circle",{cx:b,cy:x,r:50,fill:"none",stroke:"#3b82f6",strokeWidth:.5,opacity:.15,children:[h.jsx("animate",{attributeName:"r",from:"32",to:"60",dur:"3s",repeatCount:"indefinite"}),h.jsx("animate",{attributeName:"opacity",from:"0.25",to:"0",dur:"3s",repeatCount:"indefinite"})]}),h.jsxs("circle",{cx:b,cy:x,r:50,fill:"none",stroke:"#3b82f6",strokeWidth:.5,opacity:.15,children:[h.jsx("animate",{attributeName:"r",from:"32",to:"60",dur:"3s",begin:"1.5s",repeatCount:"indefinite"}),h.jsx("animate",{attributeName:"opacity",from:"0.25",to:"0",dur:"3s",begin:"1.5s",repeatCount:"indefinite"})]}),h.jsx("circle",{cx:b,cy:x,r:32,fill:"#0c0c0c",stroke:"#3b82f6",strokeWidth:2,style:{filter:"drop-shadow(0 0 12px rgba(59,130,246,0.4))"}}),h.jsx("circle",{cx:b,cy:x,r:16,fill:"rgba(59,130,246,0.12)",stroke:"#3b82f6",strokeWidth:.8}),h.jsx("circle",{cx:b,cy:x,r:6,fill:"#3b82f6"}),h.jsx("text",{x:b,y:x+48,textAnchor:"middle",fill:"#444",fontFamily:"JetBrains Mono, monospace",fontSize:9,letterSpacing:2.5,children:"SERVER"}),h.jsxs("circle",{cx:S,cy:w,r:40,fill:"none",stroke:"#8b5cf6",strokeWidth:.5,opacity:.15,children:[h.jsx("animate",{attributeName:"r",from:"26",to:"48",dur:"3.5s",repeatCount:"indefinite"}),h.jsx("animate",{attributeName:"opacity",from:"0.2",to:"0",dur:"3.5s",repeatCount:"indefinite"})]}),h.jsx("circle",{cx:S,cy:w,r:26,fill:"#0c0c0c",stroke:"#8b5cf6",strokeWidth:2,style:{filter:"drop-shadow(0 0 10px rgba(139,92,246,0.35))"}}),h.jsx("circle",{cx:S,cy:w,r:13,fill:"rgba(139,92,246,0.12)",stroke:"#8b5cf6",strokeWidth:.8}),h.jsx("circle",{cx:S,cy:w,r:5,fill:"#8b5cf6"}),h.jsx("text",{x:S,y:w+42,textAnchor:"middle",fill:"#444",fontFamily:"JetBrains Mono, monospace",fontSize:9,letterSpacing:2.5,children:"RELAY"}),t.map(j=>{const A=N(j.id),P=AC(j.status),Q=j.status==="offline"?.25:1,B=j.actor.replace("user-","").replace("svc-",""),U=s.includes(j.id);return h.jsxs("g",{opacity:Q,children:[h.jsx("circle",{cx:A.x,cy:A.y,r:20,fill:"#0c0c0c",stroke:P,strokeWidth:1.5}),h.jsx("circle",{cx:A.x,cy:A.y,r:5,fill:P}),h.jsx("text",{x:A.x,y:A.y+32,textAnchor:"middle",fill:"#555",fontFamily:"JetBrains Mono, monospace",fontSize:9,children:B}),h.jsxs("text",{x:A.x,y:A.y+42,textAnchor:"middle",fill:"#333",fontFamily:"JetBrains Mono, monospace",fontSize:7,children:[j.type,U?" · relay":""]})]},`node-${j.id}`)})]})]})});UA.displayName="TopologyHero";let kC=(function(e){return e.checked="data-checked",e.unchecked="data-unchecked",e.indeterminate="data-indeterminate",e.disabled="data-disabled",e.readonly="data-readonly",e.required="data-required",e.valid="data-valid",e.invalid="data-invalid",e.touched="data-touched",e.dirty="data-dirty",e.filled="data-filled",e.focused="data-focused",e})({});function $A(e){return _.useMemo(()=>({checked(t){return e.indeterminate?{}:t?{[kC.checked]:""}:{[kC.unchecked]:""}},...bi}),[e.indeterminate])}const QK=_.createContext({disabled:!1});function WK(){return _.useContext(QK)}const JK=_.createContext(void 0);function eG(e=!0){const t=_.useContext(JK);if(t===void 0&&!e)throw new Error(yn(3));return t}const BA=_.createContext(void 0);function tG(){const e=_.useContext(BA);if(e===void 0)throw new Error(yn(14));return e}const nG="data-parent",rG=_.forwardRef(function(t,n){const{checked:s,className:i,defaultChecked:a=!1,disabled:l=!1,id:f,indeterminate:d=!1,inputRef:p,name:g,onCheckedChange:y,parent:b=!1,readOnly:x=!1,render:S,required:w=!1,uncheckedValue:T,value:C,nativeButton:O=!1,...N}=t,{clearErrors:R}=el(),{disabled:M,name:z,setDirty:j,setFilled:A,setFocused:P,setTouched:Q,state:B,validationMode:U,validityData:Z,shouldValidateOnChange:K,validation:ee}=xi(),D=WK(),{labelId:G,controlId:q,registerControlId:V,getDescriptionProps:L}=lo(),I=eG(),H=I?.parent,W=H&&I.allValues,Y=M||D.disabled||I?.disabled||l,ae=z??g,se=C??ae,fe=br(),Se=br();let pe=q;W?pe=b?Se:`${H.id}-${se}`:f&&(pe=f);let Oe={};W&&(b?Oe=I.parent.getParentProps():se&&(Oe=I.parent.getChildProps(se)));const _e=Ae(y),{checked:re=s,indeterminate:he=d,onCheckedChange:ie,...we}=Oe,ye=I?.value,xe=I?.setValue,ve=I?.defaultValue,Ie=_.useRef(null),Ue=zn(()=>Symbol("checkbox-control")),Ee=_.useRef(!1),{getButtonProps:Ve,buttonRef:Qe}=Jc({disabled:Y,native:O}),Be=I?.validation??ee,[We,He]=pp({controlled:se&&ye&&!b?ye.includes(se):re,default:se&&ve&&!b?ve.includes(se):a,name:"Checkbox",state:"checked"});Le(()=>{V!==jn&&(Ee.current=!0,V(Ue.current,pe))},[pe,I,V,b,Ue]),_.useEffect(()=>{const ut=Ue.current;return()=>{!Ee.current||V===jn||(Ee.current=!1,V(ut,void 0))}},[V,Ue]),Ij({enabled:!I,id:fe,commit:Be.commit,value:We,controlRef:Ie,name:ae,getValue:()=>We});const me=_.useRef(null),Te=oo(p,me,Be.inputRef);Le(()=>{me.current&&(me.current.indeterminate=he,We&&A(!0))},[We,he,A]),Uj(We,()=>{I&&!b||(R(ae),A(We),j(We!==Z.initialValue),K()?Be.commit(We):Be.commit(We,!0))});const qe=oi({checked:We,disabled:Y,name:b?void 0:ae,id:O?void 0:pe??void 0,required:w,ref:Te,style:ae?Tj:mp,tabIndex:-1,type:"checkbox","aria-hidden":!0,onChange(ut){if(ut.nativeEvent.defaultPrevented)return;const xt=ut.target.checked,ot=Yt(ii,ut.nativeEvent);if(ie?.(xt,ot),_e(xt,ot),!ot.isCanceled&&(He(xt),se&&ye&&xe&&!b)){const Wt=xt?[...ye,se]:ye.filter(vn=>vn!==se);xe(Wt,ot)}},onFocus(){Ie.current?.focus()}},C!==void 0?{value:(I?We&&C:C)||""}:an,L,I?Be.getValidationProps:Be.getInputValidationProps),mt=W?!!re:We,lt=W&&he||d;_.useEffect(()=>{if(!H||!se)return;const ut=H.disabledStatesRef.current;return ut.set(se,Y),()=>{ut.delete(se)}},[H,Y,se]);const wr=_.useMemo(()=>({...B,checked:mt,disabled:Y,readOnly:x,required:w,indeterminate:lt}),[B,mt,Y,x,w,lt]),Er=$A(wr),Qt=zt("span",t,{state:wr,ref:[Qe,Ie,n,I?.registerControlRef],props:[{id:O?pe??void 0:fe,role:"checkbox","aria-checked":he?"mixed":We,"aria-readonly":x||void 0,"aria-required":w||void 0,"aria-labelledby":G,[nG]:b?"":void 0,onFocus(){P(!0)},onBlur(){const ut=me.current;ut&&(Q(!0),P(!1),U==="onBlur"&&Be.commit(I?ye:ut.checked))},onClick(ut){x||Y||(ut.preventDefault(),me.current?.dispatchEvent(new PointerEvent("click",{bubbles:!0,shiftKey:ut.shiftKey,ctrlKey:ut.ctrlKey,altKey:ut.altKey,metaKey:ut.metaKey})))}},L,Be.getValidationProps,N,we,Ve],stateAttributesMapping:Er});return h.jsxs(BA.Provider,{value:wr,children:[Qt,!We&&!I&&ae&&!b&&T!==void 0&&h.jsx("input",{type:"hidden",name:ae,value:T}),h.jsx("input",{...qe})]})}),sG=_.forwardRef(function(t,n){const{render:s,className:i,keepMounted:a=!1,...l}=t,f=tG(),d=f.checked||f.indeterminate,{mounted:p,transitionStatus:g,setMounted:y}=Rp(d),b=_.useRef(null),x={...f,transitionStatus:g};xa({open:d,ref:b,onComplete(){d||y(!1)}});const S=$A(f),w=_.useMemo(()=>({...S,...ba,...bi}),[S]),T=a||p,C=zt("span",t,{ref:[n,b],state:x,stateAttributesMapping:w,props:l});return T?C:null}),Uv=_.forwardRef(({className:e,label:t,...n},s)=>{const i=h.jsx(rG,{ref:s,className:ge("w-[15px] h-[15px] border-[1.5px] border-neutral-700 rounded-full flex items-center justify-center cursor-pointer transition-all duration-200","data-[checked]:bg-healthy data-[checked]:border-healthy data-[checked]:shadow-[0_0_6px_rgba(34,197,94,0.3)]",e),...n,children:h.jsx(sG,{className:"flex items-center justify-center text-white",children:h.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:h.jsx("path",{d:"M1.5 4L3.25 5.75L6.5 2.25",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})});return t?h.jsxs("span",{className:"inline-flex items-center gap-2 cursor-pointer font-mono text-[11px] text-neutral-400",children:[i,h.jsx("span",{children:t})]}):i});Uv.displayName="Checkbox";const oG=_.createContext({legendId:void 0,setLegendId:()=>{},disabled:void 0});function iG(e=!1){const t=_.useContext(oG);if(!t&&!e)throw new Error(yn(86));return t}const aG=function(t){const n=br(),[s,i]=_.useState(t.initialControlId===void 0?n:t.initialControlId),[a,l]=_.useState(void 0),[f,d]=_.useState([]),p=zn(()=>new Map),{messageIds:g}=lo(),y=Ae((S,w)=>{const T=p.current;if(w===void 0){T.delete(S);return}T.set(S,w),i(C=>{if(T.size===0)return;let O;for(const N of T.values()){if(C!==void 0&&N===C)return C;O===void 0&&(O=N)}return O})}),b=_.useCallback(S=>oi({"aria-describedby":g.concat(f).join(" ")||void 0},S),[g,f]),x=_.useMemo(()=>({controlId:s,registerControlId:y,labelId:a,setLabelId:l,messageIds:f,setMessageIds:d,getDescriptionProps:b}),[s,y,a,l,f,d,b]);return h.jsx(Pj.Provider,{value:x,children:t.children})},fh=Object.keys(xp);function cG(e){if(!e||e.valid||!e.valueMissing)return!1;let t=!1;for(const n of fh)n!=="valid"&&(n==="valueMissing"&&(t=e[n]),e[n]&&(t=!1));return t}function lG(e){const{formRef:t,clearErrors:n}=el(),{setValidityData:s,validate:i,validityData:a,validationDebounceTime:l,invalid:f,markedDirtyRef:d,state:p,name:g,shouldValidateOnChange:y}=e,{controlId:b,getDescriptionProps:x}=lo(),S=ns(),w=_.useRef(null),T=Ae(async(N,R=!1)=>{const M=w.current;if(!M)return;if(R){if(p.valid!==!1)return;const Z=M.validity;if(!Z.valueMissing){const ee={value:N,state:{...xp,valid:!0},error:"",errors:[],initialValue:a.initialValue};if(M.setCustomValidity(""),b){const D=t.current.fields.get(b);D&&t.current.fields.set(b,{...D,...kv(ee,!1)})}s(ee);return}const K=fh.reduce((ee,D)=>(ee[D]=Z[D],ee),{});if(!K.valid&&!cG(K))return}function z(Z){const K=fh.reduce((D,G)=>(D[G]=Z.validity[G],D),{});let ee=!1;for(const D of fh)if(D!=="valid"){if(D==="valueMissing"&&K[D])ee=!0;else if(K[D])return K}return ee&&!d.current&&(K.valid=!0,K.valueMissing=!1),K}S.clear();let j=null,A=[];const P=z(M);let Q;const B=y();if(M.validationMessage&&!B)Q=M.validationMessage,A=[M.validationMessage];else{const Z=Array.from(t.current.fields.values()).reduce((ee,D)=>(D.name&&(ee[D.name]=D.getValue()),ee),{}),K=i(N,Z);typeof K=="object"&&K!==null&&"then"in K?j=await K:j=K,j!==null?(P.valid=!1,P.customError=!0,Array.isArray(j)?(A=j,M.setCustomValidity(j.join(`
|
|
75
|
-
`))):j&&(A=[j],M.setCustomValidity(j))):B&&(M.setCustomValidity(""),P.customError=!1,M.validationMessage?(Q=M.validationMessage,A=[M.validationMessage]):M.validity.valid&&!P.valid&&(P.valid=!0))}const U={value:N,state:P,error:Q??(Array.isArray(j)?j[0]:j??""),errors:A,initialValue:a.initialValue};if(b){const Z=t.current.fields.get(b);Z&&t.current.fields.set(b,{...Z,...kv(U,f)})}s(U)}),C=_.useCallback((N={})=>oi(x,p.valid===!1?{"aria-invalid":!0}:an,N),[x,p.valid]),O=_.useCallback((N={})=>oi({onChange(R){if(R.nativeEvent.defaultPrevented)return;if(n(g),!y()){T(R.currentTarget.value,!0);return}if(f)return;const M=R.currentTarget;if(M.value===""){T(M.value);return}S.clear(),l?S.start(l,()=>{T(M.value)}):T(M.value)}},C(N)),[C,n,g,S,T,f,l,y]);return _.useMemo(()=>({getValidationProps:C,getInputValidationProps:O,inputRef:w,commit:T}),[C,O,T])}const uG=_.forwardRef(function(t,n){const{errors:s,validationMode:i,submitAttemptedRef:a}=el(),{render:l,className:f,validate:d,validationDebounceTime:p=0,validationMode:g=i,name:y,disabled:b=!1,invalid:x,dirty:S,touched:w,actionsRef:T,...C}=t,{disabled:O}=iG(),N=Ae(d||(()=>null)),R=O||b,[M,z]=_.useState(!1),[j,A]=_.useState(!1),[P,Q]=_.useState(!1),[B,U]=_.useState(!1),Z=S??j,K=w??M,ee=_.useRef(!1),D=Ae(Se=>{S===void 0&&(Se&&(ee.current=!0),A(Se))}),G=Ae(Se=>{w===void 0&&z(Se)}),q=Ae(()=>g==="onChange"||g==="onSubmit"&&a.current),V=!!(x||y&&{}.hasOwnProperty.call(s,y)&&s[y]!==void 0),[L,I]=_.useState({state:xp,error:"",errors:[],value:null,initialValue:null}),H=!V&&L.state.valid,W=_.useMemo(()=>({disabled:R,touched:K,dirty:Z,valid:H,filled:P,focused:B}),[R,K,Z,H,P,B]),Y=lG({setValidityData:I,validate:N,validityData:L,validationDebounceTime:p,invalid:V,markedDirtyRef:ee,state:W,name:y,shouldValidateOnChange:q}),ae=_.useCallback(()=>{ee.current=!0,Y.commit(L.value)},[Y,L]);_.useImperativeHandle(T,()=>({validate:ae}),[ae]);const se=_.useMemo(()=>({invalid:V,name:y,validityData:L,setValidityData:I,disabled:R,touched:K,setTouched:G,dirty:Z,setDirty:D,filled:P,setFilled:Q,focused:B,setFocused:U,validate:N,validationMode:g,validationDebounceTime:p,shouldValidateOnChange:q,state:W,markedDirtyRef:ee,validation:Y}),[V,y,L,R,K,G,Z,D,P,Q,B,U,N,g,p,q,W,Y]),fe=zt("div",t,{ref:n,state:W,props:C,stateAttributesMapping:bi});return h.jsx(Mj.Provider,{value:se,children:fe})}),fG=_.forwardRef(function(t,n){return h.jsx(aG,{children:h.jsx(uG,{...t,ref:n})})}),dG=_.forwardRef(function(t,n){const{render:s,className:i,id:a,nativeLabel:l=!0,...f}=t,d=xi(!1),{controlId:p,setLabelId:g,labelId:y}=lo(),b=br(a),x=_.useRef(null),S=Ae(T=>{if(Ur(T.nativeEvent)?.closest("button,input,select,textarea")||(!T.defaultPrevented&&T.detail>1&&T.preventDefault(),l||!p))return;const O=Rt(T.currentTarget).getElementById(p);Zt(O)&&O.focus({focusVisible:!0})});return Le(()=>(b&&g(b),()=>{g(void 0)}),[b,g]),zt("label",t,{ref:[n,x],state:d.state,props:[{id:y},l?{htmlFor:p??void 0,onMouseDown:S}:{onClick:S,onPointerDown(T){T.preventDefault()}},f],stateAttributesMapping:bi})}),hG={...bi,...ba},pG=_.forwardRef(function(t,n){const{render:s,id:i,className:a,match:l,...f}=t,d=br(i),{validityData:p,state:g,name:y}=xi(!1),{setMessageIds:b}=lo(),{errors:x}=el(),S=y?x[y]:null;let w=!1;S||l===!0?w=!0:l?w=!!p.state[l]:w=p.state.valid===!1;const{mounted:T,transitionStatus:C,setMounted:O}=Rp(w);Le(()=>{if(!(!w||!d))return b(U=>U.concat(d)),()=>{b(U=>U.filter(Z=>Z!==d))}},[w,d,b]);const N=_.useRef(null),[R,M]=_.useState(null),[z,j]=_.useState(null),A=S||(p.errors.length>1?h.jsx("ul",{children:p.errors.map(U=>h.jsx("li",{children:U},U))}):p.error);let P=p.error;S!=null?P=Array.isArray(S)?JSON.stringify(S):S:p.errors.length>1&&(P=JSON.stringify(p.errors)),w&&P!==z&&(j(P),M(A)),xa({open:w,ref:N,onComplete(){w||O(!1)}});const Q={...g,transitionStatus:C},B=zt("div",t,{ref:[n,N],state:Q,props:[{id:d,children:w?A:R},f],stateAttributesMapping:hG,enabled:T});return T?B:null}),mG=_.forwardRef(function(t,n){const{render:s,id:i,className:a,...l}=t,f=br(i),d=xi(!1),{setMessageIds:p}=lo();return Le(()=>{if(f)return p(y=>y.concat(f)),()=>{p(y=>y.filter(b=>b!==f))}},[f,p]),zt("p",t,{ref:n,state:d.state,props:[{id:f},l],stateAttributesMapping:bi})}),ms=fG,es=_.forwardRef(({className:e,...t},n)=>h.jsx(dG,{ref:n,className:ge("font-mono text-[9px] text-neutral-500 uppercase tracking-wider block mb-1.5",e),...t}));es.displayName="FieldLabel";const pc=_.forwardRef(({className:e,...t},n)=>h.jsx(mG,{ref:n,className:ge("font-mono text-[9px] text-neutral-600 mt-0.5",e),...t}));pc.displayName="FieldDescription";const gG=_.forwardRef(({className:e,...t},n)=>h.jsx(pG,{ref:n,className:ge("font-mono text-[10px] text-offline mt-1",e),...t}));gG.displayName="FieldError";const yG=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge(e),...t}));yG.displayName="FieldContent";const vG=_.createContext(null),bG=_.createContext(null);function Wu(){const e=_.useContext(vG);if(e===null)throw new Error(yn(60));return e}function FA(){const e=_.useContext(bG);if(e===null)throw new Error(yn(61));return e}function $c(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function xG(e,t,n){return!e||e.length===0?!1:e.some(s=>s===void 0?!1:$c(t,s,n))}function zy(e,t,n){return!e||e.length===0?-1:e.findIndex(s=>s===void 0?!1:$c(s,t,n))}function SG(e,t,n){return e.filter(s=>!$c(t,s,n))}function OC(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function _G(e){return e!=null&&e.length>0&&typeof e[0]=="object"&&e[0]!=null&&"items"in e[0]}function wG(e){if(!Array.isArray(e))return e!=null&&!("null"in e);if(_G(e)){for(const t of e)for(const n of t.items)if(n&&n.value==null&&n.label!=null)return!0;return!1}for(const t of e)if(t&&t.value==null&&t.label!=null)return!0;return!1}function EG(e,t){return t&&e!=null?t(e)??"":e&&typeof e=="object"&&"value"in e&&"label"in e?OC(e.value):OC(e)}const it={id:Pe(e=>e.id),modal:Pe(e=>e.modal),multiple:Pe(e=>e.multiple),items:Pe(e=>e.items),itemToStringLabel:Pe(e=>e.itemToStringLabel),itemToStringValue:Pe(e=>e.itemToStringValue),isItemEqualToValue:Pe(e=>e.isItemEqualToValue),value:Pe(e=>e.value),hasSelectedValue:Pe(e=>{const{value:t,multiple:n,itemToStringValue:s}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:EG(t,s)!==""}),hasNullItemLabel:Pe((e,t)=>t?wG(e.items):!1),open:Pe(e=>e.open),mounted:Pe(e=>e.mounted),forceMount:Pe(e=>e.forceMount),transitionStatus:Pe(e=>e.transitionStatus),openMethod:Pe(e=>e.openMethod),activeIndex:Pe(e=>e.activeIndex),selectedIndex:Pe(e=>e.selectedIndex),isActive:Pe((e,t)=>e.activeIndex===t),isSelected:Pe((e,t,n)=>{const s=e.isItemEqualToValue,i=e.value;return e.multiple?Array.isArray(i)&&i.some(a=>$c(n,a,s)):e.selectedIndex===t&&e.selectedIndex!==null?!0:$c(n,i,s)}),isSelectedByFocus:Pe((e,t)=>e.selectedIndex===t),popupProps:Pe(e=>e.popupProps),triggerProps:Pe(e=>e.triggerProps),triggerElement:Pe(e=>e.triggerElement),positionerElement:Pe(e=>e.positionerElement),listElement:Pe(e=>e.listElement),scrollUpArrowVisible:Pe(e=>e.scrollUpArrowVisible),scrollDownArrowVisible:Pe(e=>e.scrollDownArrowVisible),hasScrollArrows:Pe(e=>e.hasScrollArrows)};function TG(e){const t=_.useRef(""),n=_.useCallback(i=>{i.defaultPrevented||(t.current=i.pointerType,e(i,i.pointerType))},[e]);return{onClick:_.useCallback(i=>{if(i.detail===0){e(i,"keyboard");return}"pointerType"in i?e(i,i.pointerType):e(i,t.current),t.current=""},[e]),onPointerDown:n}}function CG(e){const[t,n]=_.useState(null),s=Ae((f,d)=>{e||n(d||(rA?"touch":""))}),i=_.useCallback(()=>{n(null)},[]),{onClick:a,onPointerDown:l}=TG(s);return _.useMemo(()=>({openMethod:t,reset:i,triggerProps:{onClick:a,onPointerDown:l}}),[t,i,a,l])}function RG(e){const t=e.getBoundingClientRect(),n=window.getComputedStyle(e,"::before"),s=window.getComputedStyle(e,"::after");if(!(n.content!=="none"||s.content!=="none"))return t;const a=parseFloat(n.width)||0,l=parseFloat(n.height)||0,f=parseFloat(s.width)||0,d=parseFloat(s.height)||0,p=Math.max(t.width,a,f),g=Math.max(t.height,l,d),y=p-t.width,b=g-t.height;return{left:t.left-y/2,right:t.right+y/2,top:t.top-b/2,bottom:t.bottom+b/2}}const qd=2,NG=400,MC=200,jG={...zK,...bi,value:()=>null},AG=_.forwardRef(function(t,n){const{render:s,className:i,id:a,disabled:l=!1,nativeButton:f=!0,...d}=t,{setTouched:p,setFocused:g,validationMode:y,state:b,disabled:x}=xi(),{labelId:S}=lo(),{store:w,setOpen:T,selectionRef:C,validation:O,readOnly:N,required:R,alignItemWithTriggerActiveRef:M,disabled:z,keyboardActiveRef:j}=Wu(),A=x||z||l,P=at(w,it.open),Q=at(w,it.value),B=at(w,it.triggerProps),U=at(w,it.positionerElement),Z=at(w,it.listElement),K=at(w,it.id),ee=at(w,it.hasSelectedValue),D=!ee&&P,G=at(w,it.hasNullItemLabel,D),q=a??K;Dj({id:q});const V=Jo(U),L=_.useRef(null),{getButtonProps:I,buttonRef:H}=Jc({disabled:A,native:f}),W=Ae(re=>{w.set("triggerElement",re)}),Y=oo(n,L,H,W),ae=ns(),se=ns(),fe=ns(),Se=ns();_.useEffect(()=>{if(P)return!(ee||G)?fe.start(NG,()=>{C.current.allowUnselectedMouseUp=!0,C.current.allowSelectedMouseUp=!0}):Se.start(MC,()=>{C.current.allowUnselectedMouseUp=!0,fe.start(MC,()=>{C.current.allowSelectedMouseUp=!0})}),()=>{fe.clear(),Se.clear()};C.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1},se.clear()},[P,ee,G,C,se,fe,Se]);const pe=_.useMemo(()=>Z?.id??Bh(U)?.id,[Z,U]),Oe=oi(B,{id:q,role:"combobox","aria-expanded":P?"true":"false","aria-haspopup":"listbox","aria-controls":P?pe:void 0,"aria-labelledby":S,"aria-readonly":N||void 0,"aria-required":R||void 0,tabIndex:A?-1:0,ref:Y,onFocus(re){g(!0),P&&M.current&&T(!1,Yt(ii,re.nativeEvent)),ae.start(0,()=>{w.set("forceMount",!0)})},onBlur(re){Ot(U,re.relatedTarget)||(p(!0),g(!1),y==="onBlur"&&O.commit(Q))},onPointerMove(){j.current=!1},onKeyDown(){j.current=!0},onMouseDown(re){if(P)return;const he=Rt(re.currentTarget);function ie(we){if(!L.current)return;const ye=we.target;if(Ot(L.current,ye)||Ot(V.current,ye)||ye===L.current)return;const xe=RG(L.current);we.clientX>=xe.left-qd&&we.clientX<=xe.right+qd&&we.clientY>=xe.top-qd&&we.clientY<=xe.bottom+qd||T(!1,Yt(b8,we))}se.start(0,()=>{he.addEventListener("mouseup",ie,{once:!0})})}},O.getValidationProps,d,I);Oe.role="combobox";const _e={...b,open:P,disabled:A,value:Q,readOnly:N,placeholder:!ee};return zt("button",t,{ref:[n,L],state:_e,stateAttributesMapping:jG,props:Oe})}),kG=_.createContext(void 0),OG=_.forwardRef(function(t,n){const{store:s}=Wu(),i=at(s,it.mounted),a=at(s,it.forceMount);return i||a?h.jsx(kG.Provider,{value:!0,children:h.jsx(wA,{ref:n,...t})}):null});let IC={},PC={},DC="";function MG(e){if(typeof document>"u")return!1;const t=Rt(e);return un(t).innerWidth-t.documentElement.clientWidth>0}function IG(e){if(!(typeof CSS<"u"&&CSS.supports&&CSS.supports("scrollbar-gutter","stable"))||typeof document>"u")return!1;const n=Rt(e),s=n.documentElement,i=n.body,a=vi(s)?s:i,l=a.style.overflowY,f=s.style.scrollbarGutter;s.style.scrollbarGutter="stable",a.style.overflowY="scroll";const d=a.offsetWidth;a.style.overflowY="hidden";const p=a.offsetWidth;return a.style.overflowY=l,s.style.scrollbarGutter=f,d===p}function PG(e){const t=Rt(e),n=t.documentElement,s=t.body,i=vi(n)?n:s,a={overflowY:i.style.overflowY,overflowX:i.style.overflowX};return Object.assign(i.style,{overflowY:"hidden",overflowX:"hidden"}),()=>{Object.assign(i.style,a)}}function DG(e){const t=Rt(e),n=t.documentElement,s=t.body,i=un(n);let a=0,l=0,f=!1;const d=ys.create();if(nx&&(i.visualViewport?.scale??1)!==1)return()=>{};function p(){const b=i.getComputedStyle(n),x=i.getComputedStyle(s),T=(b.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";a=n.scrollTop,l=n.scrollLeft,IC={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},DC=n.style.scrollBehavior,PC={position:s.style.position,height:s.style.height,width:s.style.width,boxSizing:s.style.boxSizing,overflowY:s.style.overflowY,overflowX:s.style.overflowX,scrollBehavior:s.style.scrollBehavior};const C=n.scrollHeight>n.clientHeight,O=n.scrollWidth>n.clientWidth,N=b.overflowY==="scroll"||x.overflowY==="scroll",R=b.overflowX==="scroll"||x.overflowX==="scroll",M=Math.max(0,i.innerWidth-s.clientWidth),z=Math.max(0,i.innerHeight-s.clientHeight),j=parseFloat(x.marginTop)+parseFloat(x.marginBottom),A=parseFloat(x.marginLeft)+parseFloat(x.marginRight),P=vi(n)?n:s;if(f=IG(e),f){n.style.scrollbarGutter=T,P.style.overflowY="hidden",P.style.overflowX="hidden";return}Object.assign(n.style,{scrollbarGutter:T,overflowY:"hidden",overflowX:"hidden"}),(C||N)&&(n.style.overflowY="scroll"),(O||R)&&(n.style.overflowX="scroll"),Object.assign(s.style,{position:"relative",height:j||z?`calc(100dvh - ${j+z}px)`:"100dvh",width:A||M?`calc(100vw - ${A+M}px)`:"100vw",boxSizing:"border-box",overflow:"hidden",scrollBehavior:"unset"}),s.scrollTop=a,s.scrollLeft=l,n.setAttribute("data-base-ui-scroll-locked",""),n.style.scrollBehavior="unset"}function g(){Object.assign(n.style,IC),Object.assign(s.style,PC),f||(n.scrollTop=a,n.scrollLeft=l,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=DC)}function y(){g(),d.request(p)}return p(),i.addEventListener("resize",y),()=>{d.cancel(),g(),typeof i.removeEventListener=="function"&&i.removeEventListener("resize",y)}}class zG{lockCount=0;restore=null;timeoutLock=ai.create();timeoutUnlock=ai.create();acquire(t){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(t)),this.release}release=()=>{this.lockCount-=1,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(t){if(this.lockCount===0||this.restore!==null)return;const s=Rt(t).documentElement,i=un(s).getComputedStyle(s).overflowY;if(i==="hidden"||i==="clip"){this.restore=jn;return}const a=rA||!MG(t);this.restore=a?PG(t):DG(t)}}const LG=new zG;function HA(e=!0,t=null){Le(()=>{if(e)return LG.acquire(t)},[e,t])}const qA=_.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}});function UG(){return _.useContext(qA)}function VA(e){const{children:t,elementsRef:n,labelsRef:s,onMapChange:i}=e,a=Ae(i),l=_.useRef(0),f=zn(BG).current,d=zn($G).current,[p,g]=_.useState(0),y=_.useRef(p),b=Ae((C,O)=>{d.set(C,O??null),y.current+=1,g(y.current)}),x=Ae(C=>{d.delete(C),y.current+=1,g(y.current)}),S=_.useMemo(()=>{const C=new Map;return Array.from(d.keys()).filter(N=>N.isConnected).sort(FG).forEach((N,R)=>{const M=d.get(N)??{};C.set(N,{...M,index:R})}),C},[d,p]);Le(()=>{if(typeof MutationObserver!="function"||S.size===0)return;const C=new MutationObserver(O=>{const N=new Set,R=M=>N.has(M)?N.delete(M):N.add(M);O.forEach(M=>{M.removedNodes.forEach(R),M.addedNodes.forEach(R)}),N.size===0&&(y.current+=1,g(y.current))});return S.forEach((O,N)=>{N.parentElement&&C.observe(N.parentElement,{childList:!0})}),()=>{C.disconnect()}},[S]),Le(()=>{y.current===p&&(n.current.length!==S.size&&(n.current.length=S.size),s&&s.current.length!==S.size&&(s.current.length=S.size),l.current=S.size),a(S)},[a,S,n,s,p]),Le(()=>()=>{n.current=[]},[n]),Le(()=>()=>{s&&(s.current=[])},[s]);const w=Ae(C=>(f.add(C),()=>{f.delete(C)}));Le(()=>{f.forEach(C=>C(S))},[f,S]);const T=_.useMemo(()=>({register:b,unregister:x,subscribeMapChange:w,elementsRef:n,labelsRef:s,nextIndexRef:l}),[b,x,w,n,s,l]);return h.jsx(qA.Provider,{value:T,children:t})}function $G(){return new Map}function BG(){return new Set}function FG(e,t){const n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING||n&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:n&Node.DOCUMENT_POSITION_PRECEDING||n&Node.DOCUMENT_POSITION_CONTAINS?1:0}const KA=_.createContext(void 0);function HG(){const e=_.useContext(KA);if(!e)throw new Error(yn(59));return e}const GA=_.forwardRef(function(t,n){const{cutout:s,...i}=t;let a;if(s){const l=s?.getBoundingClientRect();a=`polygon(
|
|
74
|
+
`)}})}const j9=_.forwardRef(({active:e,className:t,color:n,formatter:s,hideIndicator:i=!1,hideLabel:a=!1,indicator:l="dot",label:f,labelClassName:d,labelFormatter:p,labelKey:g,nameKey:y,payload:b},x)=>{const{config:S}=C9(),w=_.useMemo(()=>{if(a||!b?.length)return null;const C=b[0];if(!C)return null;const O=`${g||C.dataKey||C.name||"value"}`,N=XT(S,C,O),R=!g&&typeof f=="string"?S[f]?.label??f:N?.label;return p?h.jsx("div",{className:ge("font-medium",d),children:p(R??"",b)}):R?h.jsx("div",{className:ge("font-medium",d),children:R}):null},[S,a,f,d,p,g,b]);if(!e||!b?.length)return null;const T=b.length===1&&l!=="dot";return h.jsxs("div",{className:ge("grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-surface px-2.5 py-1.5 text-xs shadow-xl",t),ref:x,children:[T?null:w,h.jsx("div",{className:"grid gap-1.5",children:b.map((C,O)=>{const N=`${y||C.name||C.dataKey||"value"}`,R=XT(S,C,N),M=n||C.payload?.fill||C.color;return h.jsx("div",{className:ge("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-neutral-500",l==="dot"?"items-center":null),children:s&&C.value!==void 0&&C.name?s(C.value,C.name,C,O,C.payload??{}):h.jsxs(h.Fragment,{children:[R?.icon?h.jsx(R.icon,{}):i?null:h.jsx("div",{className:ge("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",l==="dot"?"h-2.5 w-2.5":null,l==="line"?"w-1":null,l==="dashed"?"w-0 border-[1.5px] border-dashed bg-transparent":null,T&&l==="dashed"?"my-0.5":null),style:{"--color-bg":M,"--color-border":M}}),h.jsxs("div",{className:ge("flex flex-1 justify-between leading-none",T?"items-end":"items-center"),children:[h.jsxs("div",{className:"grid gap-1.5",children:[T?w:null,h.jsx("span",{className:"text-neutral-500",children:R?.label||C.name})]}),C.value!==void 0?h.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:typeof C.value=="number"?C.value.toLocaleString():C.value}):null]})]})},N)})})]})});j9.displayName="ChartTooltipContent";function XT(e,t,n){const s=t.payload?.[n],i=typeof s=="string"?s:null,a=typeof t.dataKey=="string"?t.dataKey:null,l=typeof t.name=="string"?t.name:null;return e[i??a??l??n]}const A9=["1h","6h","24h","7d"],Sj=_.forwardRef(({className:e,bars:t,activeRange:n="1h",onRangeChange:s,startLabel:i="-1h",midLabel:a="-30m",endLabel:l="now",...f},d)=>h.jsxs("div",{ref:d,className:ge("px-5 pt-4 pb-3 border-b border-border",e),...f,children:[h.jsxs("div",{className:"flex items-center justify-between mb-3",children:[h.jsx("span",{className:"font-mono text-[10px] text-neutral-500 uppercase tracking-widest",children:"Activity"}),h.jsxs("div",{className:"flex items-center gap-4",children:[h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("span",{className:"w-2 h-2 rounded-sm bg-healthy/70"}),h.jsx("span",{className:"font-mono text-[9px] text-neutral-500",children:"Push"})]}),h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("span",{className:"w-2 h-2 rounded-sm bg-flow/70"}),h.jsx("span",{className:"font-mono text-[9px] text-neutral-500",children:"Pull"})]}),h.jsx("div",{className:"flex gap-0.5 ml-2",children:A9.map(p=>h.jsx("button",{type:"button",onClick:()=>s?.(p),className:ge("font-mono text-[9px] border rounded-sm px-1.5 py-0.5 cursor-pointer transition-all",p===n?"text-white border-border-bright bg-white/[0.03]":"text-neutral-500 border-transparent hover:text-neutral-300"),children:p},p))})]})]}),h.jsx("div",{className:"flex items-end gap-[2px] h-16",children:t.map((p,g)=>h.jsxs("div",{className:"flex-1 flex flex-col gap-[1px] h-16 justify-end",children:[h.jsx("div",{className:"bg-flow/60 rounded-t-sm min-h-[2px]",style:{height:`${p.pullPercent}%`}}),h.jsx("div",{className:"bg-healthy/60 rounded-t-sm min-h-[2px]",style:{height:`${p.pushPercent}%`}})]},g))}),h.jsxs("div",{className:"flex justify-between mt-1.5",children:[h.jsx("span",{className:"font-mono text-[8px] text-neutral-600",children:i}),h.jsx("span",{className:"font-mono text-[8px] text-neutral-600",children:a}),h.jsx("span",{className:"font-mono text-[8px] text-neutral-600",children:l})]})]}));Sj.displayName="ActivityBars";const QT=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,WT=Hb,gi=(e,t)=>n=>{var s;if(t?.variants==null)return WT(e,n?.class,n?.className);const{variants:i,defaultVariants:a}=t,l=Object.keys(i).map(p=>{const g=n?.[p],y=a?.[p];if(g===null)return null;const b=QT(g)||QT(y);return i[p][b]}),f=n&&Object.entries(n).reduce((p,g)=>{let[y,b]=g;return b===void 0||(p[y]=b),p},{}),d=t==null||(s=t.compoundVariants)===null||s===void 0?void 0:s.reduce((p,g)=>{let{class:y,className:b,...x}=g;return Object.entries(x).every(S=>{let[w,T]=S;return Array.isArray(T)?T.includes({...a,...f}[w]):{...a,...f}[w]===T})?[...p,y,b]:p},[]);return WT(e,l,d,n?.class,n?.className)},k9=gi("bg-surface border border-border rounded-md px-3 py-1.5 text-foreground outline-none w-full transition focus:border-flow placeholder:text-neutral-600",{variants:{variant:{default:"font-sans text-[13px]",mono:"font-mono text-[12px]"}},defaultVariants:{variant:"default"}}),Gn=_.forwardRef(({className:e,variant:t,...n},s)=>h.jsx("input",{ref:s,className:ge(k9({variant:t,className:e})),...n}));Gn.displayName="Input";function pp({controlled:e,default:t,name:n,state:s="value"}){const{current:i}=_.useRef(e!==void 0),[a,l]=_.useState(t),f=i?e:a,d=_.useCallback(p=>{i||l(p)},[]);return[f,d]}const JT={};function zn(e,t){const n=_.useRef(JT);return n.current===JT&&(n.current=e(t)),n}const Ty=P1[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0,-3)],O9=Ty&&Ty!==_.useLayoutEffect?Ty:e=>e();function Ae(e){const t=zn(M9).current;return t.next=e,O9(t.effect),t.trampoline}function M9(){const e={next:void 0,callback:I9,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function I9(){}function oo(e,t,n,s){const i=zn(_j).current;return D9(i,e,t,n,s)&&wj(i,[e,t,n,s]),i.callback}function P9(e){const t=zn(_j).current;return z9(t,e)&&wj(t,e),t.callback}function _j(){return{callback:null,cleanup:null,refs:[]}}function D9(e,t,n,s,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==s||e.refs[3]!==i}function z9(e,t){return e.refs.length!==t.length||e.refs.some((n,s)=>n!==t[s])}function wj(e,t){if(e.refs=t,t.every(n=>n==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&(e.cleanup(),e.cleanup=null),n!=null){const s=Array(t.length).fill(null);for(let i=0;i<t.length;i+=1){const a=t[i];if(a!=null)switch(typeof a){case"function":{const l=a(n);typeof l=="function"&&(s[i]=l);break}case"object":{a.current=n;break}}}e.cleanup=()=>{for(let i=0;i<t.length;i+=1){const a=t[i];if(a!=null)switch(typeof a){case"function":{const l=s[i];typeof l=="function"?l():a(null);break}case"object":{a.current=null;break}}}}}}}const L9=()=>{},Le=typeof document<"u"?_.useLayoutEffect:L9,Ej={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1},mp={...Ej,position:"fixed",top:0,left:0},Tj={...Ej,position:"absolute"};function jn(){}const Ru=Object.freeze([]),an=Object.freeze({});function yn(e,...t){const n=new URL("https://base-ui.com/production-error");return n.searchParams.set("code",e.toString()),t.forEach(s=>n.searchParams.append("args[]",s)),`Base UI error #${e}; visit ${n} for the full message.`}const U9=parseInt(_.version,10);function Kb(e){return U9>=e}function eC(e){if(!_.isValidElement(e))return null;const t=e,n=t.props;return(Kb(19)?n?.ref:t.ref)??null}function Cv(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function $9(e,t){const n={};for(const s in e){const i=e[s];if(t?.hasOwnProperty(s)){const a=t[s](i);a!=null&&Object.assign(n,a);continue}i===!0?n[`data-${s.toLowerCase()}`]="":i&&(n[`data-${s.toLowerCase()}`]=i.toString())}return n}function B9(e,t){return typeof e=="function"?e(t):e}function F9(e,t){return typeof e=="function"?e(t):e}const hu={};function oi(e,t,n,s,i){let a={...Rv(e,hu)};return t&&(a=lu(a,t)),n&&(a=lu(a,n)),s&&(a=lu(a,s)),i&&(a=lu(a,i)),a}function H9(e){if(e.length===0)return hu;if(e.length===1)return Rv(e[0],hu);let t={...Rv(e[0],hu)};for(let n=1;n<e.length;n+=1)t=lu(t,e[n]);return t}function lu(e,t){return Cj(t)?t(e):q9(e,t)}function q9(e,t){if(!t)return e;for(const n in t){const s=t[n];switch(n){case"style":{e[n]=Cv(e.style,s);break}case"className":{e[n]=Rj(e.className,s);break}default:V9(n,s)?e[n]=K9(e[n],s):e[n]=s}}return e}function V9(e,t){const n=e.charCodeAt(0),s=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&s===110&&i>=65&&i<=90&&(typeof t=="function"||typeof t>"u")}function Cj(e){return typeof e=="function"}function Rv(e,t){return Cj(e)?e(t):e??hu}function K9(e,t){return t?e?n=>{if(G9(n)){const i=n;Nv(i);const a=t(i);return i.baseUIHandlerPrevented||e?.(i),a}const s=t(n);return e?.(n),s}:t:e}function Nv(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function Rj(e,t){return t?e?t+" "+e:t:e}function G9(e){return e!=null&&typeof e=="object"&&"nativeEvent"in e}const Z9={style:{transition:"none"}},Y9="data-base-ui-click-trigger",X9={fallbackAxisSide:"none"},Q9={fallbackAxisSide:"end"},W9={clipPath:"inset(50%)",position:"fixed",top:0,left:0};function zt(e,t,n={}){const s=t.render,i=J9(t,n);if(n.enabled===!1)return null;const a=n.state??an;return t8(e,s,i,a)}function J9(e,t={}){const{className:n,style:s,render:i}=e,{state:a=an,ref:l,props:f,stateAttributesMapping:d,enabled:p=!0}=t,g=p?B9(n,a):void 0,y=p?F9(s,a):void 0,b=p?$9(a,d):an,x=p?Cv(b,Array.isArray(f)?H9(f):f)??an:an;return typeof document<"u"&&(p?Array.isArray(l)?x.ref=P9([x.ref,eC(i),...l]):x.ref=oo(x.ref,eC(i),l):oo(null,null)),p?(g!==void 0&&(x.className=Rj(x.className,g)),y!==void 0&&(x.style=Cv(x.style,y)),x):an}const e8=Symbol.for("react.lazy");function t8(e,t,n,s){if(t){if(typeof t=="function")return t(n,s);const i=oi(n,t.props);i.ref=n.ref;let a=t;return a?.$$typeof===e8&&(a=_.Children.toArray(t)[0]),_.cloneElement(a,i)}if(e&&typeof e=="string")return n8(e,n);throw new Error(yn(8))}function n8(e,t){return e==="button"?_.createElement("button",{type:"button",...t,key:t.key}):e==="img"?_.createElement("img",{alt:"",...t,key:t.key}):_.createElement(e,t)}const r8={...P1};let tC=0;function s8(e,t="mui"){const[n,s]=_.useState(e),i=e||n;return _.useEffect(()=>{n==null&&(tC+=1,s(`${t}-${tC}`))},[n,t]),i}const nC=r8.useId;function Xu(e,t){if(nC!==void 0){const n=nC();return e??(t?`${t}-${n}`:n)}return s8(e,t)}function br(e){return Xu(e,"base-ui")}function gp(){return typeof window<"u"}function yi(e){return Gb(e)?(e.nodeName||"").toLowerCase():"#document"}function un(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function _s(e){var t;return(t=(Gb(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Gb(e){return gp()?e instanceof Node||e instanceof un(e).Node:!1}function jt(e){return gp()?e instanceof Element||e instanceof un(e).Element:!1}function Zt(e){return gp()?e instanceof HTMLElement||e instanceof un(e).HTMLElement:!1}function jv(e){return!gp()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof un(e).ShadowRoot}const o8=new Set(["inline","contents"]);function vi(e){const{overflow:t,overflowX:n,overflowY:s,display:i}=xr(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+n)&&!o8.has(i)}const i8=new Set(["table","td","th"]);function a8(e){return i8.has(yi(e))}const c8=[":popover-open",":modal"];function yp(e){return c8.some(t=>{try{return e.matches(t)}catch{return!1}})}const l8=["transform","translate","scale","rotate","perspective"],u8=["transform","translate","scale","rotate","perspective","filter"],f8=["paint","layout","strict","content"];function Zb(e){const t=vp(),n=jt(e)?xr(e):e;return l8.some(s=>n[s]?n[s]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||u8.some(s=>(n.willChange||"").includes(s))||f8.some(s=>(n.contain||"").includes(s))}function d8(e){let t=io(e);for(;Zt(t)&&!Xs(t);){if(Zb(t))return t;if(yp(t))return null;t=io(t)}return null}function vp(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const h8=new Set(["html","body","#document"]);function Xs(e){return h8.has(yi(e))}function xr(e){return un(e).getComputedStyle(e)}function bp(e){return jt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function io(e){if(yi(e)==="html")return e;const t=e.assignedSlot||e.parentNode||jv(e)&&e.host||_s(e);return jv(t)?t.host:t}function Nj(e){const t=io(e);return Xs(t)?e.ownerDocument?e.ownerDocument.body:e.body:Zt(t)&&vi(t)?t:Nj(t)}function Wo(e,t,n){var s;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=Nj(e),a=i===((s=e.ownerDocument)==null?void 0:s.body),l=un(i);if(a){const f=Av(l);return t.concat(l,l.visualViewport||[],vi(i)?i:[],f&&n?Wo(f):[])}return t.concat(i,Wo(i,[],n))}function Av(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}const jj=_.createContext(void 0);function Aj(e=!1){const t=_.useContext(jj);if(t===void 0&&!e)throw new Error(yn(16));return t}function p8(e){const{focusableWhenDisabled:t,disabled:n,composite:s=!1,tabIndex:i=0,isNativeButton:a}=e,l=s&&t!==!1,f=s&&t===!1;return{props:_.useMemo(()=>{const p={onKeyDown(g){n&&t&&g.key!=="Tab"&&g.preventDefault()}};return s||(p.tabIndex=i,!a&&n&&(p.tabIndex=t?i:-1)),(a&&(t||l)||!a&&n)&&(p["aria-disabled"]=n),a&&(!t||f)&&(p.disabled=n),p},[s,n,t,l,f,a,i])}}function Jc(e={}){const{disabled:t=!1,focusableWhenDisabled:n,tabIndex:s=0,native:i=!0}=e,a=_.useRef(null),l=Aj(!0)!==void 0,f=Ae(()=>{const b=a.current;return!!(b?.tagName==="A"&&b?.href)}),{props:d}=p8({focusableWhenDisabled:n,disabled:t,composite:l,tabIndex:s,isNativeButton:i}),p=_.useCallback(()=>{const b=a.current;m8(b)&&l&&t&&d.disabled===void 0&&b.disabled&&(b.disabled=!1)},[t,d.disabled,l]);Le(p,[p]);const g=_.useCallback((b={})=>{const{onClick:x,onMouseDown:S,onKeyUp:w,onKeyDown:T,onPointerDown:C,...O}=b;return oi({type:i?"button":void 0,onClick(R){if(t){R.preventDefault();return}x?.(R)},onMouseDown(R){t||S?.(R)},onKeyDown(R){if(t||(Nv(R),T?.(R)),R.baseUIHandlerPrevented)return;const M=R.target===R.currentTarget&&!i&&!f()&&!t,z=R.key==="Enter",j=R.key===" ";M&&((j||z)&&R.preventDefault(),z&&x?.(R))},onKeyUp(R){t||(Nv(R),w?.(R)),!R.baseUIHandlerPrevented&&R.target===R.currentTarget&&!i&&!t&&R.key===" "&&x?.(R)},onPointerDown(R){if(t){R.preventDefault();return}C?.(R)}},i?void 0:{role:"button"},d,O)},[t,d,i,f]),y=Ae(b=>{a.current=b,p()});return{getButtonProps:g,buttonRef:y}}function m8(e){return Zt(e)&&e.tagName==="BUTTON"}const kj=_.createContext(void 0);function g8(){const e=_.useContext(kj);if(e===void 0)throw new Error(yn(63));return e}let rC=(function(e){return e.disabled="data-disabled",e.valid="data-valid",e.invalid="data-invalid",e.touched="data-touched",e.dirty="data-dirty",e.filled="data-filled",e.focused="data-focused",e})({});const xp={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},bi={valid(e){return e===null?null:e?{[rC.valid]:""}:{[rC.invalid]:""}}};let sC=(function(e){return e.checked="data-checked",e.unchecked="data-unchecked",e.disabled="data-disabled",e.readonly="data-readonly",e.required="data-required",e.valid="data-valid",e.invalid="data-invalid",e.touched="data-touched",e.dirty="data-dirty",e.filled="data-filled",e.focused="data-focused",e})({});const Oj={...bi,checked(e){return e?{[sC.checked]:""}:{[sC.unchecked]:""}}};function kv(e,t){return{...e,state:{...e.state,valid:!t&&e.state.valid}}}const y8=_.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:jn,validationMode:"onSubmit",submitAttemptedRef:{current:!1}});function el(){return _.useContext(y8)}const Mj=_.createContext({invalid:void 0,name:void 0,validityData:{state:xp,errors:[],error:"",value:"",initialValue:null},setValidityData:jn,disabled:void 0,touched:!1,setTouched:jn,dirty:!1,setDirty:jn,filled:!1,setFilled:jn,focused:!1,setFocused:jn,validate:()=>null,validationMode:"onSubmit",validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:{disabled:!1,valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},markedDirtyRef:{current:!1},validation:{getValidationProps:(e=an)=>e,getInputValidationProps:(e=an)=>e,inputRef:{current:null},commit:async()=>{}}});function xi(e=!0){const t=_.useContext(Mj);if(t.setValidityData===jn&&!e)throw new Error(yn(28));return t}function Ij(e){const{enabled:t=!0,value:n,id:s,name:i,controlRef:a,commit:l}=e,{formRef:f}=el(),{invalid:d,markedDirtyRef:p,validityData:g,setValidityData:y}=xi(),b=Ae(e.getValue);Le(()=>{if(!t)return;let x=n;x===void 0&&(x=b()),g.initialValue===null&&x!==null&&y(S=>({...S,initialValue:x}))},[t,y,n,g.initialValue,b]),Le(()=>{!t||!s||f.current.fields.set(s,{getValue:b,name:i,controlRef:a,validityData:kv(g,d),validate(x=!0){let S=n;S===void 0&&(S=b()),p.current=!0,x?hi.flushSync(()=>l(S)):l(S)}})},[l,a,t,f,b,s,d,p,i,g,n]),Le(()=>{const x=f.current.fields;return()=>{s&&x.delete(s)}},[f,s])}const Pj=_.createContext({controlId:void 0,registerControlId:jn,labelId:void 0,setLabelId:jn,messageIds:[],setMessageIds:jn,getDescriptionProps:e=>e});function lo(){return _.useContext(Pj)}function Dj(e={}){const{id:t,implicit:n=!1,controlRef:s}=e,{controlId:i,registerControlId:a}=lo(),l=br(t),f=n?i:void 0,d=zn(()=>Symbol("labelable-control")),p=_.useRef(!1),g=_.useRef(t!=null),y=Ae(()=>{!p.current||a===jn||(p.current=!1,a(d.current,void 0))});return Le(()=>{if(a===jn)return;let b;if(n){const x=s?.current;jt(x)&&x.closest("label")!=null?b=t??null:b=f??l}else if(t!=null)g.current=!0,b=t;else if(g.current)b=l;else{y();return}if(b===void 0){y();return}p.current=!0,a(d.current,b)},[t,s,f,a,n,l,d,y]),_.useEffect(()=>y,[y]),i??l}const ii="none",oC="trigger-press",Ov="trigger-hover",zj="outside-press",Cy="item-press",Lj="focus-out",v8="escape-key",b8="cancel-open",x8="imperative-action",S8="window-resize";function Yt(e,t,n,s){let i=!1,a=!1;const l=s??an;return{reason:e,event:t??new Event("base-ui"),cancel(){i=!0},allowPropagation(){a=!0},get isCanceled(){return i},get isPropagationAllowed(){return a},trigger:n,...l}}function Uj(e,t){const n=_.useRef(e),s=Ae(t);Le(()=>{n.current!==e&&s(n.current)},[e,s]),Le(()=>{n.current=e},[e])}const _8=_.forwardRef(function(t,n){const{checked:s,className:i,defaultChecked:a,id:l,inputRef:f,name:d,nativeButton:p=!1,onCheckedChange:g,readOnly:y=!1,required:b=!1,disabled:x=!1,render:S,uncheckedValue:w,value:T,...C}=t,{clearErrors:O}=el(),{state:N,setTouched:R,setDirty:M,validityData:z,setFilled:j,setFocused:A,shouldValidateOnChange:P,validationMode:Q,disabled:B,name:U,validation:Z}=xi(),{labelId:K}=lo(),ee=B||x,D=U??d,G=Ae(g),q=_.useRef(null),V=oo(q,f,Z.inputRef),L=_.useRef(null),I=br(),H=Dj({id:l,implicit:!1,controlRef:L}),W=p?void 0:H,[Y,ae]=pp({controlled:s,default:!!a,name:"Switch",state:"checked"});Ij({id:I,commit:Z.commit,value:Y,controlRef:L,name:D,getValue:()=>Y}),Le(()=>{q.current&&j(q.current.checked)},[q,j]),Uj(Y,()=>{O(D),M(Y!==z.initialValue),j(Y),P()?Z.commit(Y):Z.commit(Y,!0)});const{getButtonProps:se,buttonRef:fe}=Jc({disabled:ee,native:p}),Se={id:p?H:I,role:"switch","aria-checked":Y,"aria-readonly":y||void 0,"aria-required":b||void 0,"aria-labelledby":K,onFocus(){ee||A(!0)},onBlur(){const re=q.current;!re||ee||(R(!0),A(!1),Q==="onBlur"&&Z.commit(re.checked))},onClick(re){y||ee||(re.preventDefault(),q.current?.dispatchEvent(new PointerEvent("click",{bubbles:!0,shiftKey:re.shiftKey,ctrlKey:re.ctrlKey,altKey:re.altKey,metaKey:re.metaKey})))}},pe=_.useMemo(()=>oi({checked:Y,disabled:ee,id:W,name:D,required:b,style:D?Tj:mp,tabIndex:-1,type:"checkbox","aria-hidden":!0,ref:V,onChange(re){if(re.nativeEvent.defaultPrevented)return;const he=re.target.checked,ie=Yt(ii,re.nativeEvent);G?.(he,ie),!ie.isCanceled&&ae(he)},onFocus(){L.current?.focus()}},Z.getInputValidationProps,T!==void 0?{value:T}:an),[Y,ee,V,W,D,G,b,ae,Z,T]),Oe=_.useMemo(()=>({...N,checked:Y,disabled:ee,readOnly:y,required:b}),[N,Y,ee,y,b]),_e=zt("span",t,{state:Oe,ref:[n,L,fe],props:[Se,Z.getValidationProps,C,se],stateAttributesMapping:Oj});return h.jsxs(kj.Provider,{value:Oe,children:[_e,!Y&&D&&w!==void 0&&h.jsx("input",{type:"hidden",name:D,value:w}),h.jsx("input",{...pe})]})}),w8=_.forwardRef(function(t,n){const{render:s,className:i,...a}=t,{state:l}=xi(),f=g8(),d={...l,...f};return zt("span",t,{state:d,ref:n,stateAttributesMapping:Oj,props:a})}),Sp=_.forwardRef(({className:e,...t},n)=>h.jsx(_8,{ref:n,className:ge("relative w-[34px] h-[18px] bg-border-bright rounded-full cursor-pointer transition data-[checked]:bg-healthy",e),...t,children:h.jsx(w8,{className:"block w-[14px] h-[14px] bg-white rounded-full transition-transform data-[checked]:translate-x-4 absolute top-0.5 left-0.5"})}));Sp.displayName="Switch";const $j=_.forwardRef(({className:e,enabled:t=!0,onEnabledChange:n,thresholds:s,onThresholdsChange:i,...a},l)=>{function f(d,p){const g=Number(p);Number.isFinite(g)&&i?.({...s,[d]:g})}return h.jsxs("div",{ref:l,className:ge("bg-panel border border-border rounded-lg hover:border-border-bright transition",e),...a,children:[h.jsxs("div",{className:"px-4 py-2.5 border-b border-border flex items-center justify-between",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-offline"}),h.jsx("span",{className:"font-mono text-[10px] text-neutral-500 uppercase tracking-widest",children:"Alerts"})]}),h.jsx(Sp,{checked:t,onCheckedChange:d=>n?.(d)})]}),h.jsxs("div",{className:"p-4 space-y-3",children:[h.jsx(Ry,{label:"P90 latency threshold",value:s.p90Latency,onChange:d=>f("p90Latency",d)}),h.jsx(Ry,{label:"Error rate threshold",value:s.errorRate,onChange:d=>f("errorRate",d)}),h.jsx(Ry,{label:"Client lag threshold",value:s.clientLag,onChange:d=>f("clientLag",d)})]})]})});$j.displayName="AlertsConfig";function Ry({label:e,value:t,onChange:n}){return h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("span",{className:"font-mono text-[10px] text-neutral-500",children:e}),h.jsx(Gn,{variant:"mono",type:"number",value:t,onChange:s=>n(s.target.value),className:"w-[100px] text-[11px] px-2 py-1 text-right"})]})}const E8=gi("inline-flex items-center gap-1 px-2 py-0.5 rounded-sm font-mono text-[9px] leading-normal uppercase tracking-wider",{variants:{variant:{default:"bg-white/[0.05] text-neutral-300 border border-border-bright",destructive:"bg-offline/10 text-offline border border-offline/20",ghost:"bg-transparent text-neutral-500 border border-border-bright",outline:"bg-transparent text-neutral-400 border border-border-bright",secondary:"bg-panel text-neutral-400 border border-border",healthy:"bg-healthy/10 text-healthy border border-healthy/20",syncing:"bg-syncing/10 text-syncing border border-syncing/20",offline:"bg-offline/10 text-offline border border-offline/20",flow:"bg-flow/10 text-flow border border-flow/20",relay:"bg-relay/10 text-relay border border-relay/20"}},defaultVariants:{variant:"default"}}),mn=_.forwardRef(({className:e,variant:t,style:n,...s},i)=>h.jsx("span",{ref:i,className:ge(E8({variant:t,className:e})),style:{lineHeight:1,...n},...s}));mn.displayName="Badge";const tl=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,role:"table",className:ge("w-full",e),...t}));tl.displayName="Table";const nl=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,role:"rowgroup",className:ge(e),...t}));nl.displayName="TableHeader";const rl=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,role:"rowgroup",className:ge(e),...t}));rl.displayName="TableBody";const ss=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,role:"row",className:ge("font-mono text-[11px] leading-6 px-4 flex items-center gap-4 border-b border-[#141414] hover:bg-white/[0.015] transition-colors cursor-default",e),...t}));ss.displayName="TableRow";const ht=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,role:"columnheader",className:ge("min-w-0 font-mono text-[9px] text-neutral-600 uppercase tracking-wider leading-6 bg-white/[0.01] text-left truncate",e),...t}));ht.displayName="TableHead";const pt=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,role:"cell",className:ge("min-w-0 whitespace-nowrap overflow-hidden text-ellipsis",e),...t}));pt.displayName="TableCell";const T8={relay:"relay",admin:"flow",proxy:"ghost"},C8=_.forwardRef(({className:e,keys:t,onCreateKey:n,onRotateKey:s,onRevokeKey:i,...a},l)=>h.jsx("div",{ref:l,className:ge("w-full",e),...a,children:h.jsxs(tl,{children:[h.jsx(nl,{children:h.jsxs(ss,{children:[h.jsx(ht,{children:"Name"}),h.jsx(ht,{children:"Type"}),h.jsx(ht,{children:"Prefix"}),h.jsx(ht,{children:"Created"})]})}),h.jsx(rl,{children:t.map((f,d)=>h.jsxs(ss,{className:"group relative",children:[h.jsx(pt,{children:h.jsx("span",{className:"text-white truncate",children:f.name})}),h.jsx(pt,{children:h.jsx(mn,{variant:T8[f.type]??"ghost",children:f.type})}),h.jsx(pt,{children:h.jsx("span",{className:"text-neutral-500 truncate",children:f.prefix})}),h.jsx(pt,{children:h.jsx("span",{className:"text-neutral-600 truncate",children:f.created})}),(s||i)&&h.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[s&&h.jsx("button",{type:"button",onClick:()=>s(f.name),className:"flex items-center gap-1 px-1.5 py-0.5 rounded text-[9px] text-neutral-600 hover:text-white hover:bg-white/[0.05] cursor-pointer transition-colors",children:"rotate"}),i&&h.jsx("button",{type:"button",onClick:()=>i(f.name),className:"flex items-center gap-1 px-1.5 py-0.5 rounded text-[9px] text-neutral-600 hover:text-offline hover:bg-offline/10 cursor-pointer transition-colors",children:"revoke"})]})]},`${f.name}:${f.prefix}:${d}`))})]})}));C8.displayName="ApiKeysTable";const Bj=_.forwardRef(({className:e,metrics:t=[],uptime:n,isLive:s=!0,...i},a)=>h.jsxs("div",{ref:a,className:ge("fixed bottom-0 left-0 right-0 z-100 h-8 border-t border-border bg-surface/92 backdrop-blur-lg flex items-center justify-between px-5",e),...i,children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx("div",{className:"flex items-center gap-[2px]",children:[0,.1,.2,.3,.4].map(l=>h.jsx("div",{className:"w-0.5 h-1.5 bg-healthy rounded-sm animate-[heartbeat_1.2s_ease-in-out_infinite]",style:{animationDelay:`${l}s`}},l))}),s&&h.jsx("span",{className:"font-mono text-[9px] text-healthy uppercase tracking-widest",children:"Live"})]}),h.jsx("div",{className:"flex items-center gap-6",children:t.map(l=>h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("span",{className:"font-mono text-[9px] text-neutral-600",children:l.label}),h.jsx("span",{className:"font-mono text-[10px] text-neutral-300",children:l.value})]},l.label))}),n!=null&&h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"font-mono text-[9px] text-neutral-600",children:"UPTIME"}),h.jsx("span",{className:"font-mono text-[10px] text-neutral-400",children:n})]})]}));Bj.displayName="BottomBar";const Fj=_.forwardRef(({className:e,commits:t,onViewAll:n,...s},i)=>h.jsxs("div",{ref:i,className:ge("px-5 pt-3 pb-2",e),...s,children:[h.jsxs("div",{className:"flex items-center justify-between mb-2",children:[h.jsx("span",{className:"font-mono text-[10px] text-neutral-500 uppercase tracking-widest",children:"Recent Commits"}),n&&h.jsx("button",{type:"button",onClick:n,className:"inline-flex items-center gap-1.5 rounded-md font-mono text-[9px] px-2 py-0.5 border border-border-bright bg-transparent text-neutral-400 hover:text-white hover:bg-white/[0.03] cursor-pointer transition-all",children:"View all →"})]}),h.jsxs("div",{className:"font-mono text-[9px] tracking-wider uppercase text-neutral-600 flex items-center gap-4 px-4 leading-[22px] border-b border-border",children:[h.jsx("span",{className:"w-[60px] truncate",children:"Seq"}),h.jsx("span",{className:"w-[100px] truncate",children:"Actor"}),h.jsx("span",{className:"w-[50px] truncate",children:"Chg"}),h.jsx("span",{className:"flex-1 truncate",children:"Tables"}),h.jsx("span",{className:"w-[70px] text-right truncate",children:"Time"})]}),t.map(a=>h.jsxs("div",{className:"font-mono text-[11px] leading-7 px-4 flex items-center gap-4 border-b border-[#141414] hover:bg-white/[0.015] transition-colors cursor-default",children:[h.jsxs("span",{className:"w-[60px] text-flow font-medium truncate",children:["#",a.seq]}),h.jsx("span",{className:"w-[100px] text-neutral-400 truncate",children:a.actor}),h.jsx("span",{className:"w-[50px] text-white truncate",children:a.changes}),h.jsx("span",{className:"flex-1 truncate",children:h.jsx("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-sm font-mono text-[9px] uppercase tracking-wider bg-transparent text-neutral-500 border border-border-bright",children:a.tables})}),h.jsx("span",{className:"w-[70px] text-right text-neutral-600 truncate",children:a.time})]},a.seq))]}));Fj.displayName="CommitTable";const Hj=gi("inline-flex items-center justify-center gap-1.5 rounded-md font-mono transition-all cursor-pointer disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"border border-border-bright bg-transparent text-neutral-400 hover:text-white hover:bg-white/[0.03]",primary:"border border-flow bg-flow/10 text-flow hover:bg-flow/20",destructive:"border border-offline bg-offline/10 text-offline hover:bg-offline/20",ghost:"border border-transparent bg-transparent text-neutral-400 hover:text-white hover:bg-white/[0.03]",link:"border border-transparent bg-transparent text-neutral-400 underline underline-offset-4 hover:text-white",secondary:"border border-border bg-panel text-neutral-400 hover:text-white hover:bg-white/[0.03]"},size:{sm:"text-[10px] px-2.5 py-1",md:"text-[11px] px-3.5 py-1.5",icon:"h-8 w-8"}},defaultVariants:{variant:"default",size:"md"}}),Me=_.forwardRef(({className:e,variant:t,size:n,...s},i)=>h.jsx("button",{ref:i,className:ge(Hj({variant:t,size:n,className:e})),...s}));Me.displayName="Button";const qj=_.forwardRef(({className:e,isConnected:t=!1,isConnecting:n=!1,isTestingConnection:s=!1,serverUrl:i,onServerUrlChange:a,consoleToken:l,onConsoleTokenChange:f,onSaveAndConnect:d,onDisconnect:p,onTestConnection:g,statusMessage:y,...b},x)=>h.jsxs("div",{ref:x,className:ge("bg-panel border border-border rounded-lg hover:border-border-bright transition",e),...b,children:[h.jsxs("div",{className:"px-4 py-2.5 border-b border-border flex items-center justify-between",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:ge("w-1.5 h-1.5 rounded-full",t?"bg-healthy":"bg-offline"),style:t?{boxShadow:"0 0 4px #22c55e"}:void 0}),h.jsx("span",{className:"font-mono text-[10px] text-neutral-500 uppercase tracking-widest",children:"Connection"})]}),h.jsx(mn,{variant:t?"healthy":"offline",children:t?"Connected":"Disconnected"})]}),h.jsxs("div",{className:"p-5 space-y-4",children:[h.jsx("p",{className:"font-mono text-[10px] text-neutral-500",children:"Configure the server endpoint and authentication token."}),h.jsxs("div",{children:[h.jsx("label",{htmlFor:"console-server-url",className:"font-mono text-[9px] text-neutral-500 uppercase tracking-wider block mb-1.5",children:"Server URL"}),h.jsx(Gn,{id:"console-server-url",variant:"mono",value:i,onChange:S=>a?.(S.target.value)})]}),h.jsxs("div",{children:[h.jsx("label",{htmlFor:"console-token",className:"font-mono text-[9px] text-neutral-500 uppercase tracking-wider block mb-1.5",children:"Console Token"}),h.jsx(Gn,{id:"console-token",variant:"mono",type:"password",value:l,onChange:S=>f?.(S.target.value)})]}),h.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[h.jsx(Me,{variant:"primary",size:"md",onClick:d,disabled:n,children:n?"Connecting...":"Save + Connect"}),h.jsx(Me,{variant:"default",size:"md",onClick:g,disabled:n||s,children:s?"Testing...":"Test Connection"}),h.jsx(Me,{variant:"destructive",size:"md",onClick:p,disabled:!t,children:"Disconnect"})]}),y&&h.jsx("div",{className:ge("font-mono text-[10px]",t?"text-healthy":"text-offline"),children:y})]})]}));qj.displayName="ConnectionForm";const R8=gi("animate-spin text-neutral-500",{variants:{size:{sm:"h-3 w-3",md:"h-5 w-5",lg:"h-8 w-8"}},defaultVariants:{size:"md"}}),Pt=_.forwardRef(({className:e,size:t,...n},s)=>h.jsxs("svg",{ref:s,className:ge(R8({size:t,className:e})),xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",...n,children:[h.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),h.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}));Pt.displayName="Spinner";function N8({className:e,state:t}){switch(t){case"connected":return h.jsx(mn,{variant:"healthy",className:e,children:"Connected"});case"disconnected":return h.jsx(mn,{variant:"destructive",className:e,children:"Disconnected"});case"connecting":return h.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs text-neutral-400",children:[h.jsx(Pt,{size:"sm"}),"Connecting"]});case"not-configured":return h.jsx(mn,{variant:"ghost",className:e,children:"Not configured"})}}const Yb=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("bg-panel border border-border rounded-lg hover:border-border-bright transition",e),...t}));Yb.displayName="Card";const j8=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("px-4 py-2.5 border-b border-border flex items-center justify-between",e),...t}));j8.displayName="CardHeader";const A8=_.forwardRef(({className:e,...t},n)=>h.jsx("h3",{ref:n,className:ge("font-mono text-[10px] text-neutral-500 uppercase tracking-widest",e),...t}));A8.displayName="CardTitle";const Xb=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("p-4",e),...t}));Xb.displayName="CardContent";const k8=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("px-4 py-2.5 border-t border-border",e),...t}));k8.displayName="CardFooter";function Qb({action:e,className:t,icon:n,message:s}){return h.jsxs("div",{className:ge("flex flex-col items-center justify-center gap-3 py-12",t),children:[n?h.jsx("div",{className:"text-neutral-500",children:n}):null,h.jsx("p",{className:"font-mono text-[10px] text-neutral-500",children:s}),e?h.jsx("div",{children:e}):null]})}const Vj=_.forwardRef(({className:e,groups:t,searchValue:n,searchPlaceholder:s="Filter by client or actor...",onSearchChange:i,actions:a,...l},f)=>h.jsxs("div",{ref:f,className:ge("px-5 py-3 border-b border-border flex items-center gap-4 flex-wrap",e),...l,children:[t.map((d,p)=>h.jsx(O8,{group:d,showDivider:p>0},p)),i!==void 0&&h.jsx("input",{className:"bg-surface border border-border rounded-md font-mono text-[10px] text-foreground outline-none transition focus:border-flow placeholder:text-neutral-600 max-w-[200px] px-2.5 py-1",placeholder:s,value:n,onChange:d=>i(d.target.value)}),a&&h.jsx("div",{className:"ml-auto flex items-center gap-2",children:a})]}));Vj.displayName="FilterBar";function O8({group:e,showDivider:t}){return h.jsxs(h.Fragment,{children:[t&&h.jsx("div",{className:"w-px h-4 bg-border"}),h.jsxs("div",{className:"flex items-center gap-1",children:[e.label&&h.jsx("span",{className:"font-mono text-[9px] text-neutral-500 mr-1",children:e.label}),e.options.map(n=>h.jsx("button",{type:"button",onClick:()=>e.onActiveChange(n.id),className:ge("font-mono text-[10px] border rounded-sm px-2.5 py-0.5 cursor-pointer transition-all",n.id===e.activeId?"text-white border-border-bright bg-white/[0.03]":"text-neutral-500 border-transparent hover:text-neutral-300"),children:n.label},n.id))]})]})}function M8(e){return e===0?"#22c55e":e<10?"#f59e0b":e<50?"#f97316":"#ef4444"}const I8={online:"healthy",syncing:"syncing",offline:"offline"},P8={realtime:"flow",polling:"ghost"},D8=_.forwardRef(({className:e,client:t,headSeq:n,onEvict:s,...i},a)=>{const l=Math.max(0,n-t.cursor),f=Math.min(100,t.cursor/n*100),d=M8(l);return h.jsxs("div",{ref:a,className:ge("bg-panel border border-border rounded-lg hover:border-border-bright transition",e),style:{borderLeft:`3px solid ${d}`},...i,children:[h.jsxs("div",{className:"px-3.5 py-2 border-b border-border flex items-center justify-between",children:[h.jsx("div",{className:"flex items-center gap-2 min-w-0",children:h.jsx("span",{className:"font-mono text-[11px] text-white truncate",title:t.id,children:t.id.length>14?`${t.id.substring(0,14)}…`:t.id})}),h.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[h.jsx(mn,{variant:I8[t.status],children:t.status}),h.jsx(mn,{variant:P8[t.mode],children:t.mode})]})]}),h.jsxs("div",{className:"p-3 space-y-3",children:[h.jsxs("div",{children:[h.jsxs("div",{className:"flex items-center justify-between mb-1",children:[h.jsxs("span",{className:"font-mono text-[9px] text-neutral-600",children:["#",t.cursor.toLocaleString()]}),h.jsxs("span",{className:"font-mono text-[9px] text-neutral-600",children:["#",n.toLocaleString()]})]}),h.jsx("div",{className:"h-1 rounded-full bg-surface",children:h.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${f}%`,background:d}})}),h.jsx("div",{className:"font-mono text-[9px] mt-1",style:{color:d},children:l===0?"Caught up":`${l} behind`})]}),h.jsxs("div",{className:"space-y-1",children:[h.jsx(Ny,{label:"Actor",value:t.actor}),h.jsx(Ny,{label:"Dialect",value:t.dialect}),h.jsx(Ny,{label:"Last seen",value:t.lastSeen}),h.jsxs("div",{className:"flex justify-between items-start",children:[h.jsx("span",{className:"font-mono text-[9px] text-neutral-600",children:"Scopes"}),h.jsxs("div",{className:"flex gap-1 flex-wrap justify-end",children:[t.scopes.slice(0,2).map(p=>h.jsx(mn,{variant:"ghost",children:p},p)),t.scopes.length>2&&h.jsxs("span",{className:"font-mono text-[9px] text-neutral-600",children:["+",t.scopes.length-2]})]})]})]}),s&&h.jsxs("button",{type:"button",onClick:s,className:"w-full inline-flex items-center justify-center gap-1.5 rounded-md font-mono text-[9px] px-2 py-1 border border-offline/25 bg-offline/[0.04] text-offline hover:border-offline hover:bg-offline/[0.08] cursor-pointer transition-all",children:[h.jsxs("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:[h.jsx("path",{d:"M18.36 6.64a9 9 0 11-12.73 0"}),h.jsx("line",{x1:"12",y1:"2",x2:"12",y2:"12"})]}),"Evict"]})]})]})});D8.displayName="FleetCard";function Ny({label:e,value:t}){return h.jsxs("div",{className:"flex justify-between",children:[h.jsx("span",{className:"font-mono text-[9px] text-neutral-600",children:e}),h.jsx("span",{className:"font-mono text-[10px] text-neutral-400",children:t})]})}const Kj=(...e)=>e.filter((t,n,s)=>!!t&&t.trim()!==""&&s.indexOf(t)===n).join(" ").trim();const z8=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const L8=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,s)=>s?s.toUpperCase():n.toLowerCase());const iC=e=>{const t=L8(e);return t.charAt(0).toUpperCase()+t.slice(1)};var U8={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const $8=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};const B8=_.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:s,className:i="",children:a,iconNode:l,...f},d)=>_.createElement("svg",{ref:d,...U8,width:t,height:t,stroke:e,strokeWidth:s?Number(n)*24/Number(t):n,className:Kj("lucide",i),...!a&&!$8(f)&&{"aria-hidden":"true"},...f},[...l.map(([p,g])=>_.createElement(p,g)),...Array.isArray(a)?a:[a]]));const Wb=(e,t)=>{const n=_.forwardRef(({className:s,...i},a)=>_.createElement(B8,{ref:a,iconNode:t,className:Kj(`lucide-${z8(iC(e))}`,`lucide-${e}`,s),...i}));return n.displayName=iC(e),n};const F8=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],H8=Wb("arrow-left",F8);const q8=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],V8=Wb("settings",q8);const K8=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]],G8=Wb("user-x",K8);function Z8(e){return e===0?"#22c55e":e<10?"#f59e0b":e<50?"#f97316":"#ef4444"}const Y8={online:"healthy",syncing:"syncing",offline:"offline"},Gj=_.forwardRef(({className:e,clients:t,headSeq:n,onEvict:s,...i},a)=>h.jsx("div",{ref:a,className:ge("w-full",e),...i,children:h.jsxs(tl,{children:[h.jsx(nl,{children:h.jsxs(ss,{children:[h.jsx(ht,{className:"w-[160px]",children:"Client"}),h.jsx(ht,{className:"w-[70px]",children:"Status"}),h.jsx(ht,{className:"w-[60px]",children:"Type"}),h.jsx(ht,{className:"w-[80px]",children:"Cursor"}),h.jsx(ht,{className:"w-[110px]",children:"Lag"}),h.jsx(ht,{className:"w-[60px]",children:"Dialect"}),h.jsx(ht,{className:"flex-1",children:"Mode"})]})}),h.jsx(rl,{children:t.map(l=>{const f=Math.max(0,n-l.cursor),d=n>0?Math.min(100,l.cursor/n*100):100,p=Z8(f);return h.jsxs(ss,{className:"group relative",children:[h.jsx(pt,{className:"w-[160px]",children:h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{background:p,boxShadow:`0 0 4px ${p}`}}),h.jsx("span",{className:"font-mono text-[11px] text-white truncate",title:l.id,children:l.id.length>18?`${l.id.substring(0,18)}…`:l.id})]})}),h.jsx(pt,{className:"w-[70px]",children:h.jsx(mn,{variant:Y8[l.status],children:l.status})}),h.jsx(pt,{className:"w-[60px]",children:h.jsx("span",{className:"font-mono text-[10px] text-neutral-400",children:l.type})}),h.jsx(pt,{className:"w-[80px]",children:h.jsxs("span",{className:"font-mono text-[11px] text-white font-medium",children:["#",l.cursor.toLocaleString()]})}),h.jsx(pt,{className:"w-[110px]",children:h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("div",{className:"w-[60px] h-[3px] rounded-full bg-surface overflow-hidden",children:h.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${d}%`,background:p}})}),h.jsx("span",{className:"font-mono text-[10px] font-medium",style:{color:p},children:f===0?"0":`${f}`})]})}),h.jsx(pt,{className:"w-[60px]",children:h.jsx("span",{className:"font-mono text-[10px] text-neutral-400",children:l.dialect})}),h.jsx(pt,{className:"flex-1",children:h.jsx(mn,{variant:l.mode==="realtime"?"flow":"ghost",children:l.mode})}),s&&h.jsxs("button",{type:"button",title:"Evict client",onClick:()=>s(l.id),className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1 px-1.5 py-0.5 rounded text-[9px] text-neutral-600 hover:text-offline hover:bg-offline/10 cursor-pointer transition-colors opacity-0 group-hover:opacity-100",children:[h.jsx(G8,{size:10}),"evict"]})]},l.id)})})]})}));Gj.displayName="FleetTable";const Zj=_.forwardRef(({className:e,handlers:t,tableCount:n,...s},i)=>{const a=n??t.length;return h.jsxs("div",{ref:i,className:ge("bg-panel border border-border rounded-lg hover:border-border-bright transition",e),...s,children:[h.jsxs("div",{className:"px-4 py-2.5 border-b border-border flex items-center justify-between",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-flow"}),h.jsx("span",{className:"font-mono text-[10px] text-neutral-500 uppercase tracking-widest",children:"Handlers"})]}),h.jsxs("span",{className:"font-mono text-[10px] text-neutral-600",children:[a," tables"]})]}),h.jsxs("div",{className:"font-mono text-[9px] tracking-wider uppercase text-neutral-600 flex items-center gap-4 px-4 leading-6 border-b border-border",children:[h.jsx("span",{className:"flex-1",children:"Table"}),h.jsx("span",{className:"w-[100px]",children:"Depends On"}),h.jsx("span",{className:"w-[70px] text-right",children:"Chunk TTL"})]}),t.map((l,f)=>h.jsxs("div",{className:ge("font-mono text-[11px] leading-7 px-4 flex items-center gap-4 hover:bg-white/[0.015] transition-colors cursor-default",f<t.length-1&&"border-b border-[#141414]"),children:[h.jsx("span",{className:"flex-1 text-white truncate",children:l.table}),h.jsx("span",{className:"w-[100px] truncate",children:l.dependsOn?h.jsx(mn,{variant:"ghost",children:l.dependsOn}):h.jsx("span",{className:"text-neutral-600",children:"—"})}),h.jsx("span",{className:"w-[70px] text-right text-neutral-500 truncate",children:l.chunkTtl})]},`${l.table}:${f}`))]})});Zj.displayName="HandlersTable";const X8={flow:"bg-flow",healthy:"bg-healthy",syncing:"bg-syncing",offline:"bg-offline",relay:"bg-relay",muted:"bg-neutral-500"},Yj=_.forwardRef(({className:e,items:t,...n},s)=>h.jsx("div",{ref:s,className:ge("border-b border-border px-6 py-3 flex items-center justify-between flex-wrap gap-4","bg-[linear-gradient(to_bottom,rgba(17,17,17,0.8),#0c0c0c)]",e),...n,children:t.map((i,a)=>h.jsx(Q8,{item:i,showDivider:a>0},i.label))}));Yj.displayName="KpiStrip";function Q8({item:e,showDivider:t}){const n=X8[e.color??"muted"]??"bg-neutral-500";return h.jsxs(h.Fragment,{children:[t&&h.jsx("div",{className:"w-px h-4 bg-border"}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:ge("w-1.5 h-1.5 rounded-full",n)}),h.jsx("span",{className:"font-mono text-[10px] text-neutral-500 uppercase",children:e.label}),h.jsxs("span",{className:"font-mono text-sm text-white font-semibold",children:[e.value,e.unit&&h.jsx("span",{className:"text-xs text-neutral-600",children:e.unit})]}),e.trend&&h.jsx("span",{className:ge("font-mono text-[10px]",e.trend.startsWith("+")?"text-healthy":"text-offline"),children:e.trend})]})]})}const Xj=_.forwardRef(({className:e,buckets:t,successRate:n=99.6,successLabel:s="success",...i},a)=>{const l=n/100*88,f=88-l;return h.jsxs("div",{ref:a,className:ge("px-5 py-3 border-b border-border flex items-center gap-8",e),...i,children:[h.jsx("span",{className:"font-mono text-[10px] text-neutral-500 uppercase tracking-widest",children:"Latency"}),h.jsx("div",{className:"flex items-center gap-6",children:t.map(d=>h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"font-mono text-[9px] text-neutral-500",children:d.label}),h.jsxs("div",{className:"flex gap-1 items-end h-5",children:[h.jsx("div",{className:"w-3 rounded-t bg-healthy/60",style:{height:`${d.pushBarPercent}%`}}),h.jsx("div",{className:"w-3 rounded-t bg-flow/60",style:{height:`${d.pullBarPercent}%`}})]}),h.jsxs("span",{className:"font-mono text-[10px] text-neutral-400",children:[d.pushMs," / ",d.pullMs,"ms"]})]},d.label))}),h.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[h.jsxs("svg",{viewBox:"0 0 36 36",className:"w-7 h-7",children:[h.jsx("circle",{cx:18,cy:18,r:14,fill:"none",stroke:"#1e1e1e",strokeWidth:4}),h.jsx("circle",{cx:18,cy:18,r:14,fill:"none",stroke:"#22c55e",strokeWidth:4,strokeDasharray:`${l} ${f}`,transform:"rotate(-90 18 18)",strokeLinecap:"round"})]}),h.jsxs("span",{className:"font-mono text-[10px] text-neutral-400",children:[n,"%"," ",h.jsx("span",{className:"text-neutral-600",children:s})]})]})]})});Xj.displayName="LatencyPercentilesBar";const W8={PUSH:"syncing",PULL:"healthy",ACK:"flow"},Qj=_.forwardRef(({className:e,entries:t,isConnected:n=!0,maxVisible:s=20,maxHeight:i,...a},l)=>{const f=t.slice(0,s);return h.jsxs("div",{ref:l,className:ge("flex-shrink-0",e),style:{width:360},...a,children:[h.jsxs("div",{className:"px-4 py-2.5 border-b border-border flex items-center justify-between",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"font-mono text-[10px] text-neutral-500 uppercase tracking-widest",children:"Live Feed"}),h.jsx("span",{className:ge("w-1.5 h-1.5 rounded-full",n?"bg-healthy animate-[dotPulse_1.5s_ease-in-out_infinite]":"bg-neutral-600")})]}),h.jsx("span",{className:"font-mono text-[9px] text-neutral-600",children:n?"WebSocket":"Disconnected"})]}),h.jsx("div",{className:"px-3 py-2 space-y-0.5 overflow-y-auto",style:i?{maxHeight:i}:void 0,children:f.length===0?h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsx("p",{className:"text-neutral-500 text-sm font-mono",children:n?"Waiting for activity...":"Connect to see live activity"})}):f.map((d,p)=>h.jsxs("div",{className:"flex items-center gap-2 py-1 animate-[streamSlide_0.35s_ease-out]",children:[h.jsx(mn,{variant:W8[d.type]??"ghost",className:"text-[8px] px-1.5 py-0",children:d.type}),h.jsxs("span",{className:"font-mono text-[10px] text-neutral-400 truncate flex-1",children:[d.actor," · ",d.table]}),h.jsx("span",{className:"font-mono text-[9px] text-neutral-600",children:d.time})]},`${d.time}-${p}`))})]})});Qj.displayName="LiveActivityFeed";const J8={syncing:"bg-syncing",flow:"bg-flow",healthy:"bg-healthy",offline:"bg-offline"},_p=_.forwardRef(({className:e,title:t,description:n,dotColor:s="syncing",stats:i,actionLabel:a,actionVariant:l="default",actionIcon:f,onAction:d,...p},g)=>h.jsxs("div",{ref:g,className:ge("bg-panel border border-border rounded-lg hover:border-border-bright transition",e),...p,children:[h.jsxs("div",{className:"px-4 py-2.5 border-b border-border flex items-center gap-2",children:[h.jsx("span",{className:ge("w-1.5 h-1.5 rounded-full",J8[s])}),h.jsx("span",{className:"font-mono text-[10px] text-neutral-500 uppercase tracking-widest",children:t})]}),h.jsxs("div",{className:"p-4",children:[h.jsx("p",{className:"font-mono text-[10px] text-neutral-500 leading-relaxed mb-4",children:n}),h.jsx("div",{className:ge("grid gap-3 mb-4",i.length<=2?"grid-cols-2":"grid-cols-3"),children:i.map(y=>h.jsxs("div",{children:[h.jsx("div",{className:"font-mono text-[9px] text-neutral-600 uppercase tracking-wider mb-1",children:y.label}),h.jsx("div",{className:ge("font-mono font-semibold",y.tone==="syncing"?"text-sm text-syncing":"text-lg text-white"),children:y.value})]},y.label))}),h.jsxs(Me,{variant:l,size:"md",onClick:d,children:[f,a]})]})]}));_p.displayName="MaintenanceCard";function eV({actions:e,children:t,className:n,contentClassName:s,description:i,title:a}){return h.jsxs(Yb,{className:ge("border-border",n),children:[a||e?h.jsxs("div",{className:"flex items-start justify-between px-4 pt-4",children:[h.jsxs("div",{children:[a?h.jsx("h3",{className:"font-mono text-[10px] text-neutral-500 uppercase tracking-widest",children:a}):null,i?h.jsx("p",{className:"mt-1 font-mono text-[10px] text-neutral-500",children:i}):null]}),e?h.jsx("div",{className:"flex items-center gap-2",children:e}):null]}):null,h.jsx(Xb,{className:s,children:t})]})}const Wj=_.forwardRef(({className:e,rows:t,onResetDefaults:n,...s},i)=>h.jsxs("div",{ref:i,className:ge("bg-panel border border-border rounded-lg hover:border-border-bright transition",e),...s,children:[h.jsxs("div",{className:"px-4 py-2.5 border-b border-border flex items-center justify-between",children:[h.jsx("span",{className:"font-mono text-[10px] text-neutral-500 uppercase tracking-widest",children:"Preferences"}),n&&h.jsx(Me,{variant:"default",size:"sm",onClick:n,children:"Reset defaults"})]}),h.jsx("div",{className:"p-4 space-y-4",children:t.map((a,l)=>h.jsx(tV,{row:a,showDivider:l>0},a.label))})]}));Wj.displayName="PreferencesPanel";function tV({row:e,showDivider:t}){return h.jsxs(h.Fragment,{children:[t&&h.jsx("div",{className:"border-t border-border"}),h.jsx("div",{className:"flex items-center justify-between",children:e.type==="filter"?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"font-mono text-[11px] text-neutral-400",children:e.label}),h.jsx("div",{className:"flex gap-0.5",children:e.options.map(n=>h.jsx("button",{type:"button",onClick:()=>e.onActiveChange(n.id),className:ge("font-mono text-[10px] border rounded-sm px-2.5 py-0.5 cursor-pointer transition-all",n.id===e.activeId?"text-white border-border-bright bg-white/[0.03]":"text-neutral-500 border-transparent hover:text-neutral-300"),children:n.label},n.id))})]}):h.jsxs(h.Fragment,{children:[h.jsxs("div",{children:[h.jsx("span",{className:"font-mono text-[11px] text-neutral-400",children:e.label}),e.description&&h.jsx("p",{className:"font-mono text-[9px] text-neutral-600 mt-0.5",children:e.description})]}),h.jsx(Sp,{checked:e.checked,onCheckedChange:n=>e.onCheckedChange(n)})]})})]})}function Jb({actions:e,children:t,className:n,contentClassName:s,description:i,title:a}){return h.jsxs(Yb,{className:n,children:[a||e?h.jsxs("div",{className:"flex items-start justify-between px-4 pt-4",children:[h.jsxs("div",{children:[a?h.jsx("h3",{className:"font-mono text-[10px] text-neutral-500 uppercase tracking-widest",children:a}):null,i?h.jsx("p",{className:"mt-1 font-mono text-[10px] text-neutral-500",children:i}):null]}),e?h.jsx("div",{className:"flex items-center gap-2",children:e}):null]}):null,h.jsx(Xb,{className:s,children:t})]})}const nV={commit:"text-flow",push:"text-syncing",pull:"text-healthy"},rV={applied:"text-healthy",error:"text-offline",cached:"text-syncing"},Jj=_.forwardRef(({className:e,entries:t,filterBar:n,pagination:s,onEntryClick:i,selectedEntryId:a,...l},f)=>h.jsxs("div",{ref:f,className:ge("h-full flex flex-col",e),...l,children:[n,h.jsxs("div",{className:"font-mono text-[9px] tracking-wider uppercase text-neutral-600 flex items-center gap-4 px-4 leading-6 border-b border-border bg-white/[0.01]",children:[h.jsx("span",{className:"w-[50px] truncate",children:"Time"}),h.jsx("span",{className:"w-[65px] truncate",children:"Type"}),h.jsx("span",{className:"w-[55px] truncate",children:"ID"}),h.jsx("span",{className:"w-[65px] truncate",children:"Outcome"}),h.jsx("span",{className:"w-[50px] truncate",children:"Dur"}),h.jsx("span",{className:"w-[100px] truncate",children:"Actor"}),h.jsx("span",{className:"w-[120px] truncate",children:"Client"}),h.jsx("span",{className:"flex-1 truncate",children:"Detail"})]}),h.jsx("div",{className:"flex-1 overflow-y-auto",children:t.map((d,p)=>h.jsx(sV,{entry:d,isSelected:a===d.id,onClick:i},`${d.id}-${p}`))}),s]}));Jj.displayName="StreamLog";function sV({entry:e,isSelected:t,onClick:n}){const s=nV[e.type]??"text-neutral-500",i=rV[e.outcome]??"text-neutral-600",a=ge("font-mono text-[11px] leading-7 px-4 flex items-center gap-4 border-b border-[#141414] hover:bg-white/[0.015] transition-colors",n?"cursor-pointer":"cursor-default",t&&"bg-white/[0.05]"),l=h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"w-[50px] text-neutral-600 truncate",children:e.time}),h.jsx("span",{className:ge("w-[65px] font-medium truncate",s),children:e.type.toUpperCase()}),h.jsx("span",{className:"w-[55px] text-flow truncate",children:e.id}),h.jsx("span",{className:ge("w-[65px] truncate",i),children:e.outcome}),h.jsx("span",{className:"w-[50px] text-neutral-500 truncate",children:e.duration}),h.jsx("span",{className:"w-[100px] text-neutral-400 truncate",children:e.actor}),h.jsx("span",{className:"w-[120px] text-neutral-600 truncate",title:e.client,children:e.client.length>14?`${e.client.substring(0,14)}…`:e.client}),h.jsx("span",{className:"flex-1 text-neutral-500 truncate",children:e.detail})]});return n?h.jsx("button",{type:"button",className:ge(a,"w-full bg-transparent text-left"),onClick:()=>n(e),children:l}):h.jsx("div",{className:a,children:l})}function oV(e){return e==="online"?"#22c55e":e==="syncing"?"#f59e0b":"#ef4444"}const eA=_.forwardRef(({className:e,clients:t,headSeq:n,maxLag:s,minSeq:i,...a},l)=>{const f=t.map(b=>b.cursor),d=i??Math.min(...f,n)-10,p=s??Math.max(...t.map(b=>n-b.cursor),0),g=n-d,y=[d,Math.round(d+g*.33),Math.round(d+g*.66),n];return h.jsxs("div",{ref:l,className:ge("bg-panel border border-border rounded-lg hover:border-border-bright transition",e),...a,children:[h.jsxs("div",{className:"px-4 py-2.5 border-b border-border flex items-center justify-between",children:[h.jsx("span",{className:"font-mono text-[10px] text-neutral-500 uppercase tracking-widest",children:"Sync Horizon"}),h.jsxs("div",{className:"flex items-center gap-4",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"font-mono text-[10px] text-neutral-500",children:"Head"}),h.jsxs("span",{className:"font-mono text-xs text-white font-semibold",children:["#",n.toLocaleString()]})]}),h.jsx("div",{className:"w-px h-3 bg-border"}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"font-mono text-[10px] text-neutral-500",children:"Max lag"}),h.jsx("span",{className:"font-mono text-xs text-syncing font-semibold",children:p})]})]})]}),h.jsxs("div",{className:"p-4",children:[h.jsxs("div",{className:"relative h-8 mb-3 rounded bg-surface",children:[h.jsx("div",{className:"absolute inset-0 flex items-center justify-between px-2",children:y.map(b=>h.jsxs("span",{className:"font-mono text-[8px] text-neutral-700",children:["#",b.toLocaleString()]},b))}),h.jsx("div",{className:"absolute top-0 bottom-0 w-px bg-flow/40",style:{right:"2%"}}),t.map(b=>{const x=g>0?(b.cursor-d)/g*96+2:50,S=oV(b.status),w=b.status==="offline"?.4:1;return h.jsx("div",{className:"absolute",style:{left:`${x}%`,top:"50%",transform:"translate(-50%,-50%)",opacity:w},title:`${b.id} → #${b.cursor}`,children:h.jsx("div",{className:"w-2.5 h-2.5 rounded-full",style:{background:S,boxShadow:`0 0 4px ${S}`}})},b.id)})]}),h.jsxs("div",{className:"flex items-center gap-4",children:[h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("span",{className:"w-2 h-2 rounded-full bg-healthy"}),h.jsx("span",{className:"font-mono text-[9px] text-neutral-500",children:"Caught up"})]}),h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("span",{className:"w-2 h-2 rounded-full bg-syncing"}),h.jsx("span",{className:"font-mono text-[9px] text-neutral-500",children:"Behind"})]}),h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("span",{className:"w-2 h-2 rounded-full bg-offline opacity-50"}),h.jsx("span",{className:"font-mono text-[9px] text-neutral-500",children:"Offline"})]})]})]})]})});eA.displayName="SyncHorizon";function iV(e){const t=_.useRef(!0);t.current&&(t.current=!1,e())}const aV=_.createContext(void 0);function ex(e){const t=_.useContext(aV);if(t===void 0)throw new Error(yn(72));return t}const cV=[];function tx(e){_.useEffect(e,cV)}const iu=0;class ai{static create(){return new ai}currentId=iu;start(t,n){this.clear(),this.currentId=setTimeout(()=>{this.currentId=iu,n()},t)}isStarted(){return this.currentId!==iu}clear=()=>{this.currentId!==iu&&(clearTimeout(this.currentId),this.currentId=iu)};disposeEffect=()=>this.clear}function ns(){const e=zn(ai.create).current;return tx(e.disposeEffect),e}function Jo(e){const t=zn(lV,e).current;return t.next=e,Le(t.effect),t}function lV(e){const t={current:e,next:e,effect:()=>{t.current=t.next}};return t}function Rt(e){return e?.ownerDocument||document}const sl=typeof navigator<"u",jy=dV(),tA=pV(),nA=hV(),nx=typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter:none"),rA=jy.platform==="MacIntel"&&jy.maxTouchPoints>1?!0:/iP(hone|ad|od)|iOS/.test(jy.platform),uV=sl&&/apple/i.test(navigator.vendor),Mv=sl&&/android/i.test(tA)||/android/i.test(nA);sl&&tA.toLowerCase().startsWith("mac")&&navigator.maxTouchPoints;const fV=nA.includes("jsdom/");function dV(){if(!sl)return{platform:"",maxTouchPoints:-1};const e=navigator.userAgentData;return e?.platform?{platform:e.platform,maxTouchPoints:navigator.maxTouchPoints}:{platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??-1}}function hV(){if(!sl)return"";const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(({brand:t,version:n})=>`${t}/${n}`).join(" "):navigator.userAgent}function pV(){if(!sl)return"";const e=navigator.userAgentData;return e?.platform?e.platform:navigator.platform??""}const Iv="data-base-ui-focusable",sA="active",oA="selected",iA="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])",Ay="ArrowLeft",ky="ArrowRight",mV="ArrowUp",gV="ArrowDown";function Fo(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function Ot(e,t){if(!e||!t)return!1;const n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&jv(n)){let s=t;for(;s;){if(e===s)return!0;s=s.parentNode||s.host}}return!1}function yV(e,t){if(!jt(e))return!1;const n=e;if(t.hasElement(n))return!n.hasAttribute("data-trigger-disabled");for(const[,s]of t.entries())if(Ot(s,n))return!s.hasAttribute("data-trigger-disabled");return!1}function Ur(e){return"composedPath"in e?e.composedPath()[0]:e.target}function Jr(e,t){if(t==null)return!1;if("composedPath"in e)return e.composedPath().includes(t);const n=e;return n.target!=null&&t.contains(n.target)}function vV(e){return e.matches("html,body")}function aA(e){return Zt(e)&&e.matches(iA)}function aC(e){return e?e.getAttribute("role")==="combobox"&&aA(e):!1}function Bh(e){return e?e.hasAttribute(Iv)?e:e.querySelector(`[${Iv}]`)||e:null}function xc(e,t,n=!0){return e.filter(i=>i.parentId===t&&(!n||i.context?.open)).flatMap(i=>[i,...xc(e,i.id,n)])}function cC(e,t){let n=[],s=e.find(i=>i.id===t)?.parentId;for(;s;){const i=e.find(a=>a.id===s);s=i?.parentId,i&&(n=n.concat(i))}return n}function Ki(e){e.preventDefault(),e.stopPropagation()}function bV(e){return"nativeEvent"in e}function xV(e){return e.pointerType===""&&e.isTrusted?!0:Mv&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function SV(e){return fV?!1:!Mv&&e.width===0&&e.height===0||Mv&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType==="mouse"||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType==="touch"}function _V(e,t){const n=["mouse","pen"];return n.push("",void 0),n.includes(e)}function wV(e){const t=e.type;return t==="click"||t==="mousedown"||t==="keydown"||t==="keyup"}const EV=["top","right","bottom","left"],Lc=Math.min,dr=Math.max,Fh=Math.round,hc=Math.floor,xs=e=>({x:e,y:e}),TV={left:"right",right:"left",bottom:"top",top:"bottom"},CV={start:"end",end:"start"};function Pv(e,t,n){return dr(e,Lc(t,n))}function ao(e,t){return typeof e=="function"?e(t):e}function Zn(e){return e.split("-")[0]}function Si(e){return e.split("-")[1]}function rx(e){return e==="x"?"y":"x"}function sx(e){return e==="y"?"height":"width"}const RV=new Set(["top","bottom"]);function Fr(e){return RV.has(Zn(e))?"y":"x"}function ox(e){return rx(Fr(e))}function NV(e,t,n){n===void 0&&(n=!1);const s=Si(e),i=ox(e),a=sx(i);let l=i==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(l=Hh(l)),[l,Hh(l)]}function jV(e){const t=Hh(e);return[Dv(e),t,Dv(t)]}function Dv(e){return e.replace(/start|end/g,t=>CV[t])}const lC=["left","right"],uC=["right","left"],AV=["top","bottom"],kV=["bottom","top"];function OV(e,t,n){switch(e){case"top":case"bottom":return n?t?uC:lC:t?lC:uC;case"left":case"right":return t?AV:kV;default:return[]}}function MV(e,t,n,s){const i=Si(e);let a=OV(Zn(e),n==="start",s);return i&&(a=a.map(l=>l+"-"+i),t&&(a=a.concat(a.map(Dv)))),a}function Hh(e){return e.replace(/left|right|bottom|top/g,t=>TV[t])}function IV(e){return{top:0,right:0,bottom:0,left:0,...e}}function cA(e){return typeof e!="number"?IV(e):{top:e,right:e,bottom:e,left:e}}function qh(e){const{x:t,y:n,width:s,height:i}=e;return{width:s,height:i,top:n,left:t,right:t+s,bottom:n+i,x:t,y:n}}function zd(e,t,n){return Math.floor(e/t)!==n}function ch(e,t){return t<0||t>=e.current.length}function PV(e,t){return fr(e,{disabledIndices:t})}function DV(e,t){return fr(e,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function fr(e,{startingIndex:t=-1,decrement:n=!1,disabledIndices:s,amount:i=1}={}){let a=t;do a+=n?-i:i;while(a>=0&&a<=e.current.length-1&&pu(e,a,s));return a}function zV(e,{event:t,orientation:n,loopFocus:s,rtl:i,cols:a,disabledIndices:l,minIndex:f,maxIndex:d,prevIndex:p,stopEvent:g=!1}){let y=p;const b=[],x={};let S=!1;{let C=null,O=-1;e.current.forEach((N,R)=>{if(N==null)return;const M=N.closest('[role="row"]');M&&(S=!0),(M!==C||O===-1)&&(C=M,O+=1,b[O]=[]),b[O].push(R),x[R]=O})}const w=S&&b.length>0&&b.some(C=>C.length!==a);function T(C){if(!w||p===-1)return;const O=x[p];if(O==null)return;const N=b[O].indexOf(p);let R=C==="up"?O-1:O+1;s&&(R<0?R=b.length-1:R>=b.length&&(R=0));const M=new Set;for(;R>=0&&R<b.length&&!M.has(R);){M.add(R);const z=b[R];if(z.length===0){R=C==="up"?R-1:R+1;continue}const j=Math.min(N,z.length-1);for(let A=j;A>=0;A-=1){const P=z[A];if(!pu(e,P,l))return P}R=C==="up"?R-1:R+1,s&&(R<0?R=b.length-1:R>=b.length&&(R=0))}}if(t.key===mV){const C=T("up");if(C!==void 0)g&&Ki(t),y=C;else{if(g&&Ki(t),p===-1)y=d;else if(y=fr(e,{startingIndex:y,amount:a,decrement:!0,disabledIndices:l}),s&&(p-a<f||y<0)){const O=p%a,N=d%a,R=d-(N-O);N===O?y=d:y=N>O?R:R-a}ch(e,y)&&(y=p)}}if(t.key===gV){const C=T("down");C!==void 0?(g&&Ki(t),y=C):(g&&Ki(t),p===-1?y=f:(y=fr(e,{startingIndex:p,amount:a,disabledIndices:l}),s&&p+a>d&&(y=fr(e,{startingIndex:p%a-a,amount:a,disabledIndices:l}))),ch(e,y)&&(y=p))}if(n==="both"){const C=hc(p/a);t.key===(i?Ay:ky)&&(g&&Ki(t),p%a!==a-1?(y=fr(e,{startingIndex:p,disabledIndices:l}),s&&zd(y,a,C)&&(y=fr(e,{startingIndex:p-p%a-1,disabledIndices:l}))):s&&(y=fr(e,{startingIndex:p-p%a-1,disabledIndices:l})),zd(y,a,C)&&(y=p)),t.key===(i?ky:Ay)&&(g&&Ki(t),p%a!==0?(y=fr(e,{startingIndex:p,decrement:!0,disabledIndices:l}),s&&zd(y,a,C)&&(y=fr(e,{startingIndex:p+(a-p%a),decrement:!0,disabledIndices:l}))):s&&(y=fr(e,{startingIndex:p+(a-p%a),decrement:!0,disabledIndices:l})),zd(y,a,C)&&(y=p));const O=hc(d/a)===C;ch(e,y)&&(s&&O?y=t.key===(i?ky:Ay)?d:fr(e,{startingIndex:p-p%a-1,disabledIndices:l}):y=p)}return y}function LV(e,t,n){const s=[];let i=0;return e.forEach(({width:a,height:l},f)=>{let d=!1;for(n&&(i=0);!d;){const p=[];for(let g=0;g<a;g+=1)for(let y=0;y<l;y+=1)p.push(i+g+y*t);i%t+a<=t&&p.every(g=>s[g]==null)?(p.forEach(g=>{s[g]=f}),d=!0):i+=1}}),[...s]}function UV(e,t,n,s,i){if(e===-1)return-1;const a=n.indexOf(e),l=t[e];switch(i){case"tl":return a;case"tr":return l?a+l.width-1:a;case"bl":return l?a+(l.height-1)*s:a;case"br":return n.lastIndexOf(e);default:return-1}}function $V(e,t){return t.flatMap((n,s)=>e.includes(n)?[s]:[])}function pu(e,t,n){if(typeof n=="function")return n(t);if(n)return n.includes(t);const s=e.current[t];return s?s.hasAttribute("disabled")||s.getAttribute("aria-disabled")==="true":!1}var BV=["input:not([inert]):not([inert] *)","select:not([inert]):not([inert] *)","textarea:not([inert]):not([inert] *)","a[href]:not([inert]):not([inert] *)","button:not([inert]):not([inert] *)","[tabindex]:not(slot):not([inert]):not([inert] *)","audio[controls]:not([inert]):not([inert] *)","video[controls]:not([inert]):not([inert] *)",'[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)',"details>summary:first-of-type:not([inert]):not([inert] *)","details:not([inert]):not([inert] *)"],Vh=BV.join(","),lA=typeof Element>"u",Uc=lA?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,Kh=!lA&&Element.prototype.getRootNode?function(e){var t;return e==null||(t=e.getRootNode)===null||t===void 0?void 0:t.call(e)}:function(e){return e?.ownerDocument},Gh=function(t,n){var s;n===void 0&&(n=!0);var i=t==null||(s=t.getAttribute)===null||s===void 0?void 0:s.call(t,"inert"),a=i===""||i==="true",l=a||n&&t&&(typeof t.closest=="function"?t.closest("[inert]"):Gh(t.parentNode));return l},FV=function(t){var n,s=t==null||(n=t.getAttribute)===null||n===void 0?void 0:n.call(t,"contenteditable");return s===""||s==="true"},uA=function(t,n,s){if(Gh(t))return[];var i=Array.prototype.slice.apply(t.querySelectorAll(Vh));return n&&Uc.call(t,Vh)&&i.unshift(t),i=i.filter(s),i},Zh=function(t,n,s){for(var i=[],a=Array.from(t);a.length;){var l=a.shift();if(!Gh(l,!1))if(l.tagName==="SLOT"){var f=l.assignedElements(),d=f.length?f:l.children,p=Zh(d,!0,s);s.flatten?i.push.apply(i,p):i.push({scopeParent:l,candidates:p})}else{var g=Uc.call(l,Vh);g&&s.filter(l)&&(n||!t.includes(l))&&i.push(l);var y=l.shadowRoot||typeof s.getShadowRoot=="function"&&s.getShadowRoot(l),b=!Gh(y,!1)&&(!s.shadowRootFilter||s.shadowRootFilter(l));if(y&&b){var x=Zh(y===!0?l.children:y.children,!0,s);s.flatten?i.push.apply(i,x):i.push({scopeParent:l,candidates:x})}else a.unshift.apply(a,l.children)}}return i},fA=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},dA=function(t){if(!t)throw new Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||FV(t))&&!fA(t)?0:t.tabIndex},HV=function(t,n){var s=dA(t);return s<0&&n&&!fA(t)?0:s},qV=function(t,n){return t.tabIndex===n.tabIndex?t.documentOrder-n.documentOrder:t.tabIndex-n.tabIndex},hA=function(t){return t.tagName==="INPUT"},VV=function(t){return hA(t)&&t.type==="hidden"},KV=function(t){var n=t.tagName==="DETAILS"&&Array.prototype.slice.apply(t.children).some(function(s){return s.tagName==="SUMMARY"});return n},GV=function(t,n){for(var s=0;s<t.length;s++)if(t[s].checked&&t[s].form===n)return t[s]},ZV=function(t){if(!t.name)return!0;var n=t.form||Kh(t),s=function(f){return n.querySelectorAll('input[type="radio"][name="'+f+'"]')},i;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")i=s(window.CSS.escape(t.name));else try{i=s(t.name)}catch(l){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",l.message),!1}var a=GV(i,t.form);return!a||a===t},YV=function(t){return hA(t)&&t.type==="radio"},XV=function(t){return YV(t)&&!ZV(t)},QV=function(t){var n,s=t&&Kh(t),i=(n=s)===null||n===void 0?void 0:n.host,a=!1;if(s&&s!==t){var l,f,d;for(a=!!((l=i)!==null&&l!==void 0&&(f=l.ownerDocument)!==null&&f!==void 0&&f.contains(i)||t!=null&&(d=t.ownerDocument)!==null&&d!==void 0&&d.contains(t));!a&&i;){var p,g,y;s=Kh(i),i=(p=s)===null||p===void 0?void 0:p.host,a=!!((g=i)!==null&&g!==void 0&&(y=g.ownerDocument)!==null&&y!==void 0&&y.contains(i))}}return a},fC=function(t){var n=t.getBoundingClientRect(),s=n.width,i=n.height;return s===0&&i===0},WV=function(t,n){var s=n.displayCheck,i=n.getShadowRoot;if(s==="full-native"&&"checkVisibility"in t){var a=t.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!a}if(getComputedStyle(t).visibility==="hidden")return!0;var l=Uc.call(t,"details>summary:first-of-type"),f=l?t.parentElement:t;if(Uc.call(f,"details:not([open]) *"))return!0;if(!s||s==="full"||s==="full-native"||s==="legacy-full"){if(typeof i=="function"){for(var d=t;t;){var p=t.parentElement,g=Kh(t);if(p&&!p.shadowRoot&&i(p)===!0)return fC(t);t.assignedSlot?t=t.assignedSlot:!p&&g!==t.ownerDocument?t=g.host:t=p}t=d}if(QV(t))return!t.getClientRects().length;if(s!=="legacy-full")return!0}else if(s==="non-zero-area")return fC(t);return!1},JV=function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var n=t.parentElement;n;){if(n.tagName==="FIELDSET"&&n.disabled){for(var s=0;s<n.children.length;s++){var i=n.children.item(s);if(i.tagName==="LEGEND")return Uc.call(n,"fieldset[disabled] *")?!0:!i.contains(t)}return!0}n=n.parentElement}return!1},zv=function(t,n){return!(n.disabled||VV(n)||WV(n,t)||KV(n)||JV(n))},Lv=function(t,n){return!(XV(n)||dA(n)<0||!zv(t,n))},eK=function(t){var n=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(n)||n>=0)},pA=function(t){var n=[],s=[];return t.forEach(function(i,a){var l=!!i.scopeParent,f=l?i.scopeParent:i,d=HV(f,l),p=l?pA(i.candidates):f;d===0?l?n.push.apply(n,p):n.push(f):s.push({documentOrder:a,tabIndex:d,item:i,isScope:l,content:p})}),s.sort(qV).reduce(function(i,a){return a.isScope?i.push.apply(i,a.content):i.push(a.content),i},[]).concat(n)},wp=function(t,n){n=n||{};var s;return n.getShadowRoot?s=Zh([t],n.includeContainer,{filter:Lv.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:eK}):s=uA(t,n.includeContainer,Lv.bind(null,n)),pA(s)},tK=function(t,n){n=n||{};var s;return n.getShadowRoot?s=Zh([t],n.includeContainer,{filter:zv.bind(null,n),flatten:!0,getShadowRoot:n.getShadowRoot}):s=uA(t,n.includeContainer,zv.bind(null,n)),s},mA=function(t,n){if(n=n||{},!t)throw new Error("No node provided");return Uc.call(t,Vh)===!1?!1:Lv(n,t)};const Qu=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function gA(e,t){const n=wp(e,Qu()),s=n.length;if(s===0)return;const i=Fo(Rt(e)),a=n.indexOf(i),l=a===-1?t===1?0:s-1:a+t;return n[l]}function yA(e){return gA(Rt(e).body,1)||e}function vA(e){return gA(Rt(e).body,-1)||e}function mu(e,t){const n=t||e.currentTarget,s=e.relatedTarget;return!s||!Ot(n,s)}function nK(e){wp(e,Qu()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function dC(e){e.querySelectorAll("[data-tabindex]").forEach(n=>{const s=n.dataset.tabindex;delete n.dataset.tabindex,s?n.setAttribute("tabindex",s):n.removeAttribute("tabindex")})}function rK(){const e=new Map;return{emit(t,n){e.get(t)?.forEach(s=>s(n))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){e.get(t)?.delete(n)}}}const sK=_.createContext(null),oK=_.createContext(null),Ep=()=>_.useContext(sK)?.id||null,Tp=e=>{const t=_.useContext(oK);return e??t};function Nu(e){return`data-base-ui-${e}`}const Ld=null;class iK{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=t=>{this.isScheduled=!1;const n=this.callbacks,s=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,s>0)for(let i=0;i<n.length;i+=1)n[i]?.(t)};request(t){const n=this.nextId;return this.nextId+=1,this.callbacks.push(t),this.callbacksCount+=1,!this.isScheduled&&(requestAnimationFrame(this.tick),this.isScheduled=!0),n}cancel(t){const n=t-this.startId;n<0||n>=this.callbacks.length||(this.callbacks[n]=null,this.callbacksCount-=1)}}const Ud=new iK;class ys{static create(){return new ys}static request(t){return Ud.request(t)}static cancel(t){return Ud.cancel(t)}currentId=Ld;request(t){this.cancel(),this.currentId=Ud.request(()=>{this.currentId=Ld,t()})}cancel=()=>{this.currentId!==Ld&&(Ud.cancel(this.currentId),this.currentId=Ld)};disposeEffect=()=>this.cancel}function ix(){const e=zn(ys.create).current;return tx(e.disposeEffect),e}const Yh=_.forwardRef(function(t,n){const[s,i]=_.useState();Le(()=>{uV&&i("button")},[]);const a={tabIndex:0,role:s};return h.jsx("span",{...t,ref:n,style:mp,"aria-hidden":s?void 0:!0,...a,"data-base-ui-focus-guard":""})});let hC=0;function Oy(e,t={}){const{preventScroll:n=!1,cancelPrevious:s=!0,sync:i=!1}=t;s&&cancelAnimationFrame(hC);const a=()=>e?.focus({preventScroll:n});i?a():hC=requestAnimationFrame(a)}const Sc={inert:new WeakMap,"aria-hidden":new WeakMap,none:new WeakMap};function pC(e){return e==="inert"?Sc.inert:e==="aria-hidden"?Sc["aria-hidden"]:Sc.none}let $d=new WeakSet,Bd={},My=0;const bA=e=>e&&(e.host||bA(e.parentNode)),aK=(e,t)=>t.map(n=>{if(e.contains(n))return n;const s=bA(n);return e.contains(s)?s:null}).filter(n=>n!=null);function cK(e,t,n,s){const i="data-base-ui-inert",a=s?"inert":n?"aria-hidden":null,l=aK(t,e),f=new Set,d=new Set(l),p=[];Bd[i]||(Bd[i]=new WeakMap);const g=Bd[i];l.forEach(y),b(t),f.clear();function y(x){!x||f.has(x)||(f.add(x),x.parentNode&&y(x.parentNode))}function b(x){!x||d.has(x)||[].forEach.call(x.children,S=>{if(yi(S)!=="script")if(f.has(S))b(S);else{const w=a?S.getAttribute(a):null,T=w!==null&&w!=="false",C=pC(a),O=(C.get(S)||0)+1,N=(g.get(S)||0)+1;C.set(S,O),g.set(S,N),p.push(S),O===1&&T&&$d.add(S),N===1&&S.setAttribute(i,""),!T&&a&&S.setAttribute(a,a==="inert"?"":"true")}})}return My+=1,()=>{p.forEach(x=>{const S=pC(a),T=(S.get(x)||0)-1,C=(g.get(x)||0)-1;S.set(x,T),g.set(x,C),T||(!$d.has(x)&&a&&x.removeAttribute(a),$d.delete(x)),C||x.removeAttribute(i)}),My-=1,My||(Sc.inert=new WeakMap,Sc["aria-hidden"]=new WeakMap,Sc.none=new WeakMap,$d=new WeakSet,Bd={})}}function lK(e,t=!1,n=!1){const s=Rt(e[0]).body;return cK(e.concat(Array.from(s.querySelectorAll("[aria-live]"))),s,t,n)}const xA=_.createContext(null),SA=()=>_.useContext(xA),uK=Nu("portal");function _A(e={}){const{ref:t,container:n,componentProps:s=an,elementProps:i}=e,a=Xu(),f=SA()?.portalNode,[d,p]=_.useState(null),[g,y]=_.useState(null),b=Ae(T=>{T!==null&&y(T)}),x=_.useRef(null);Le(()=>{if(n===null){x.current&&(x.current=null,y(null),p(null));return}if(a==null)return;const T=(n&&(Gb(n)?n:n.current))??f??document.body;if(T==null){x.current&&(x.current=null,y(null),p(null));return}x.current!==T&&(x.current=T,y(null),p(T))},[n,f,a]);const S=zt("div",s,{ref:[t,b],props:[{id:a,[uK]:""},i]});return{portalNode:g,portalSubtree:d&&S?hi.createPortal(S,d):null}}const wA=_.forwardRef(function(t,n){const{children:s,container:i,className:a,render:l,renderGuards:f,...d}=t,{portalNode:p,portalSubtree:g}=_A({container:i,ref:n,componentProps:t,elementProps:d}),y=_.useRef(null),b=_.useRef(null),x=_.useRef(null),S=_.useRef(null),[w,T]=_.useState(null),C=w?.modal,O=w?.open,N=typeof f=="boolean"?f:!!w&&!w.modal&&w.open&&!!p;_.useEffect(()=>{if(!p||C)return;function M(z){p&&z.relatedTarget&&mu(z)&&(z.type==="focusin"?dC:nK)(p)}return p.addEventListener("focusin",M,!0),p.addEventListener("focusout",M,!0),()=>{p.removeEventListener("focusin",M,!0),p.removeEventListener("focusout",M,!0)}},[p,C]),_.useEffect(()=>{!p||O||dC(p)},[O,p]);const R=_.useMemo(()=>({beforeOutsideRef:y,afterOutsideRef:b,beforeInsideRef:x,afterInsideRef:S,portalNode:p,setFocusManagerState:T}),[p]);return h.jsxs(_.Fragment,{children:[g,h.jsxs(xA.Provider,{value:R,children:[N&&p&&h.jsx(Yh,{"data-type":"outside",ref:y,onFocus:M=>{if(mu(M,p))x.current?.focus();else{const z=w?w.domReference:null;vA(z)?.focus()}}}),N&&p&&h.jsx("span",{"aria-owns":p.id,style:W9}),p&&hi.createPortal(s,p),N&&p&&h.jsx(Yh,{"data-type":"outside",ref:b,onFocus:M=>{if(mu(M,p))S.current?.focus();else{const z=w?w.domReference:null;yA(z)?.focus(),w?.closeOnFocusOut&&w?.onOpenChange(!1,Yt(Lj,M.nativeEvent))}}})]})]})});function qs(e){return e==null?e:"current"in e?e.current:e}function fK(e,t){const n=un(e.target);return e instanceof n.KeyboardEvent?"keyboard":e instanceof n.FocusEvent?t||"keyboard":"pointerType"in e?e.pointerType||"keyboard":"touches"in e?"touch":e instanceof n.MouseEvent?t||(e.detail===0?"keyboard":"mouse"):""}const mC=20;let Vo=[];function ax(){Vo=Vo.filter(e=>e.deref()?.isConnected)}function dK(e){ax(),e&&yi(e)!=="body"&&(Vo.push(new WeakRef(e)),Vo.length>mC&&(Vo=Vo.slice(-mC)))}function Iy(){return ax(),Vo[Vo.length-1]?.deref()}function hK(e){if(!e)return null;const t=Qu();return mA(e,t)?e:wp(e,t)[0]||e}function pK(e){return!e||!e.isConnected?!1:typeof e.checkVisibility=="function"?e.checkVisibility():xr(e).display!=="none"}function gC(e,t){if(!t.current.includes("floating")&&!e.getAttribute("role")?.includes("dialog"))return;const n=Qu(),i=tK(e,n).filter(l=>{const f=l.getAttribute("data-tabindex")||"";return mA(l,n)||l.hasAttribute("data-tabindex")&&!f.startsWith("-")}),a=e.getAttribute("tabindex");t.current.includes("floating")||i.length===0?a!=="0"&&e.setAttribute("tabindex","0"):(a!=="-1"||e.hasAttribute("data-tabindex")&&e.getAttribute("data-tabindex")!=="-1")&&(e.setAttribute("tabindex","-1"),e.setAttribute("data-tabindex","-1"))}function EA(e){const{context:t,children:n,disabled:s=!1,initialFocus:i=!0,returnFocus:a=!0,restoreFocus:l=!1,modal:f=!0,closeOnFocusOut:d=!0,openInteractionType:p="",nextFocusableElement:g,previousFocusableElement:y,beforeContentFocusGuardRef:b,externalTree:x}=e,S="rootStore"in t?t.rootStore:t,w=S.useState("open"),T=S.useState("domReferenceElement"),C=S.useState("floatingElement"),{events:O,dataRef:N}=S.context,R=Ae(()=>N.current.floatingContext?.nodeId),M=i===!1,z=aC(T)&&M,j=_.useRef(["content"]),A=Jo(i),P=Jo(a),Q=Jo(p),B=Tp(x),U=SA(),Z=_.useRef(null),K=_.useRef(null),ee=_.useRef(!1),D=_.useRef(!1),G=_.useRef(!1),q=_.useRef(-1),V=_.useRef(""),L=_.useRef(""),I=_.useRef(null),H=_.useRef(null),W=oo(I,b,U?.beforeInsideRef),Y=oo(H,U?.afterInsideRef),ae=ns(),se=ns(),fe=ix(),Se=U!=null,pe=Bh(C),Oe=Ae((he=pe)=>he?wp(he,Qu()):[]),_e=Ae(he=>{const ie=Oe(he);return j.current.map(()=>ie).filter(Boolean).flat()});_.useEffect(()=>{if(s||!f)return;function he(we){we.key==="Tab"&&Ot(pe,Fo(Rt(pe)))&&Oe().length===0&&!z&&Ki(we)}const ie=Rt(pe);return ie.addEventListener("keydown",he),()=>{ie.removeEventListener("keydown",he)}},[s,T,pe,f,j,z,Oe,_e]),_.useEffect(()=>{if(s||!w)return;const he=Rt(pe);function ie(){G.current=!1}function we(xe){const ve=Ur(xe),Ie=Ot(C,ve)||Ot(T,ve)||Ot(U?.portalNode,ve);G.current=!Ie,L.current=xe.pointerType||"keyboard",ve?.closest(`[${Y9}]`)&&(D.current=!0)}function ye(){L.current="keyboard"}return he.addEventListener("pointerdown",we,!0),he.addEventListener("pointerup",ie,!0),he.addEventListener("pointercancel",ie,!0),he.addEventListener("keydown",ye,!0),()=>{he.removeEventListener("pointerdown",we,!0),he.removeEventListener("pointerup",ie,!0),he.removeEventListener("pointercancel",ie,!0),he.removeEventListener("keydown",ye,!0)}},[s,C,T,pe,w,U]),_.useEffect(()=>{if(s||!d)return;const he=Rt(pe);function ie(){D.current=!0,se.start(0,()=>{D.current=!1})}function we(Ue){const Ee=Ur(Ue),Qe=Oe().indexOf(Ee);Qe!==-1&&(q.current=Qe)}function ye(Ue){const Ee=Ue.relatedTarget,Ve=Ue.currentTarget,Qe=Ur(Ue);queueMicrotask(()=>{const Be=R(),We=S.context.triggerElements,He=Ee?.hasAttribute(Nu("focus-guard"))&&[I.current,H.current,U?.beforeInsideRef.current,U?.afterInsideRef.current,U?.beforeOutsideRef.current,U?.afterOutsideRef.current,qs(y),qs(g)].includes(Ee),me=!(Ot(T,Ee)||Ot(C,Ee)||Ot(Ee,C)||Ot(U?.portalNode,Ee)||Ee!=null&&We.hasElement(Ee)||We.hasMatchingElement(Te=>Ot(Te,Ee))||He||B&&(xc(B.nodesRef.current,Be).find(Te=>Ot(Te.context?.elements.floating,Ee)||Ot(Te.context?.elements.domReference,Ee))||cC(B.nodesRef.current,Be).find(Te=>[Te.context?.elements.floating,Bh(Te.context?.elements.floating)].includes(Ee)||Te.context?.elements.domReference===Ee)));if(Ve===T&&pe&&gC(pe,j),l&&Ve!==T&&!pK(Qe)&&Fo(he)===he.body){if(Zt(pe)&&(pe.focus(),l==="popup")){fe.request(()=>{pe.focus()});return}const Te=q.current,qe=Oe(),mt=qe[Te]||qe[qe.length-1]||pe;Zt(mt)&&mt.focus()}if(N.current.insideReactTree){N.current.insideReactTree=!1;return}(z||!f)&&Ee&&me&&!D.current&&(z||Ee!==Iy())&&(ee.current=!0,S.setOpen(!1,Yt(Lj,Ue)))})}function xe(){G.current||(N.current.insideReactTree=!0,ae.start(0,()=>{N.current.insideReactTree=!1}))}const ve=Zt(T)?T:null,Ie=[];if(!(!C&&!ve))return ve&&(ve.addEventListener("focusout",ye),ve.addEventListener("pointerdown",ie),Ie.push(()=>{ve.removeEventListener("focusout",ye),ve.removeEventListener("pointerdown",ie)})),C&&(C.addEventListener("focusin",we),C.addEventListener("focusout",ye),U&&(C.addEventListener("focusout",xe,!0),Ie.push(()=>{C.removeEventListener("focusout",xe,!0)})),Ie.push(()=>{C.removeEventListener("focusin",we),C.removeEventListener("focusout",ye)})),()=>{Ie.forEach(Ue=>{Ue()})}},[s,T,C,pe,f,B,U,S,d,l,Oe,z,R,j,N,ae,se,fe,g,y]),_.useEffect(()=>{if(s||!C||!w)return;const he=Array.from(U?.portalNode?.querySelectorAll(`[${Nu("portal")}]`)||[]),we=(B?cC(B.nodesRef.current,R()):[]).find(xe=>aC(xe.context?.elements.domReference||null))?.context?.elements.domReference,ye=[C,we,...he,Z.current,K.current,I.current,H.current,U?.beforeOutsideRef.current,U?.afterOutsideRef.current,qs(y),qs(g),z?T:null].filter(xe=>xe!=null);return lK(ye,f||z)},[w,s,T,C,f,j,U,z,B,R,g,y]),Le(()=>{if(!w||s||!Zt(pe))return;const he=Rt(pe),ie=Fo(he);queueMicrotask(()=>{const we=_e(pe),ye=A.current,xe=typeof ye=="function"?ye(Q.current||""):ye;if(xe===void 0||xe===!1)return;let ve;xe===!0||xe===null?ve=we[0]||pe:ve=qs(xe),ve=ve||we[0]||pe,!Ot(pe,ie)&&Oy(ve,{preventScroll:ve===pe})})},[s,w,pe,M,_e,A,Q]),Le(()=>{if(s||!pe)return;const he=Rt(pe),ie=Fo(he);dK(ie);function we(ve){if(ve.open||(V.current=fK(ve.nativeEvent,L.current)),ve.reason===Ov&&ve.nativeEvent.type==="mouseleave"&&(ee.current=!0),ve.reason===zj)if(ve.nested)ee.current=!1;else if(xV(ve.nativeEvent)||SV(ve.nativeEvent))ee.current=!1;else{let Ie=!1;document.createElement("div").focus({get preventScroll(){return Ie=!0,!1}}),Ie?ee.current=!1:ee.current=!0}}O.on("openchange",we);const ye=he.createElement("span");ye.setAttribute("tabindex","-1"),ye.setAttribute("aria-hidden","true"),Object.assign(ye.style,mp),Se&&T&&T.insertAdjacentElement("afterend",ye);function xe(){const ve=P.current;let Ie=typeof ve=="function"?ve(V.current):ve;if(Ie===void 0||Ie===!1)return null;if(Ie===null&&(Ie=!0),typeof Ie=="boolean"){const Ee=T||Iy();return Ee&&Ee.isConnected?Ee:ye}const Ue=T||Iy()||ye;return qs(Ie)||Ue}return()=>{O.off("openchange",we);const ve=Fo(he),Ie=Ot(C,ve)||B&&xc(B.nodesRef.current,R(),!1).some(Ee=>Ot(Ee.context?.elements.floating,ve)),Ue=xe();queueMicrotask(()=>{const Ee=hK(Ue),Ve=typeof P.current!="boolean";P.current&&!ee.current&&Zt(Ee)&&(!(!Ve&&Ee!==ve&&ve!==he.body)||Ie)&&Ee.focus({preventScroll:!0}),ye.remove(),ee.current=!1})}},[s,C,pe,P,N,O,B,Se,T,R]),Le(()=>{if(!nx||w||!C)return;const he=Fo(Rt(C));!Zt(he)||!aA(he)||Ot(C,he)&&he.blur()},[w,C]),Le(()=>{if(!(s||!U))return U.setFocusManagerState({modal:f,closeOnFocusOut:d,open:w,onOpenChange:S.setOpen,domReference:T}),()=>{U.setFocusManagerState(null)}},[s,U,f,w,S,d,T]),Le(()=>{if(!(s||!pe))return gC(pe,j),()=>{queueMicrotask(ax)}},[s,pe,j]);const re=!s&&(f?!z:!0)&&(Se||f);return h.jsxs(_.Fragment,{children:[re&&h.jsx(Yh,{"data-type":"inside",ref:W,onFocus:he=>{if(f){const ie=_e();Oy(ie[ie.length-1])}else U?.portalNode&&(ee.current=!1,mu(he,U.portalNode)?yA(T)?.focus():qs(y??U.beforeOutsideRef)?.focus())}}),n,re&&h.jsx(Yh,{"data-type":"inside",ref:Y,onFocus:he=>{f?Oy(_e()[0]):U?.portalNode&&(d&&(ee.current=!0),mu(he,U.portalNode)?vA(T)?.focus():qs(g??U.afterOutsideRef)?.focus())}})]})}function yC(e,t,n){let{reference:s,floating:i}=e;const a=Fr(t),l=ox(t),f=sx(l),d=Zn(t),p=a==="y",g=s.x+s.width/2-i.width/2,y=s.y+s.height/2-i.height/2,b=s[f]/2-i[f]/2;let x;switch(d){case"top":x={x:g,y:s.y-i.height};break;case"bottom":x={x:g,y:s.y+s.height};break;case"right":x={x:s.x+s.width,y};break;case"left":x={x:s.x-i.width,y};break;default:x={x:s.x,y:s.y}}switch(Si(t)){case"start":x[l]-=b*(n&&p?-1:1);break;case"end":x[l]+=b*(n&&p?-1:1);break}return x}async function mK(e,t){var n;t===void 0&&(t={});const{x:s,y:i,platform:a,rects:l,elements:f,strategy:d}=e,{boundary:p="clippingAncestors",rootBoundary:g="viewport",elementContext:y="floating",altBoundary:b=!1,padding:x=0}=ao(t,e),S=cA(x),T=f[b?y==="floating"?"reference":"floating":y],C=qh(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(T)))==null||n?T:T.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(f.floating)),boundary:p,rootBoundary:g,strategy:d})),O=y==="floating"?{x:s,y:i,width:l.floating.width,height:l.floating.height}:l.reference,N=await(a.getOffsetParent==null?void 0:a.getOffsetParent(f.floating)),R=await(a.isElement==null?void 0:a.isElement(N))?await(a.getScale==null?void 0:a.getScale(N))||{x:1,y:1}:{x:1,y:1},M=qh(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:f,rect:O,offsetParent:N,strategy:d}):O);return{top:(C.top-M.top+S.top)/R.y,bottom:(M.bottom-C.bottom+S.bottom)/R.y,left:(C.left-M.left+S.left)/R.x,right:(M.right-C.right+S.right)/R.x}}const gK=async(e,t,n)=>{const{placement:s="bottom",strategy:i="absolute",middleware:a=[],platform:l}=n,f=a.filter(Boolean),d=await(l.isRTL==null?void 0:l.isRTL(t));let p=await l.getElementRects({reference:e,floating:t,strategy:i}),{x:g,y}=yC(p,s,d),b=s,x={},S=0;for(let T=0;T<f.length;T++){var w;const{name:C,fn:O}=f[T],{x:N,y:R,data:M,reset:z}=await O({x:g,y,initialPlacement:s,placement:b,strategy:i,middlewareData:x,rects:p,platform:{...l,detectOverflow:(w=l.detectOverflow)!=null?w:mK},elements:{reference:e,floating:t}});g=N??g,y=R??y,x={...x,[C]:{...x[C],...M}},z&&S<=50&&(S++,typeof z=="object"&&(z.placement&&(b=z.placement),z.rects&&(p=z.rects===!0?await l.getElementRects({reference:e,floating:t,strategy:i}):z.rects),{x:g,y}=yC(p,b,d)),T=-1)}return{x:g,y,placement:b,strategy:i,middlewareData:x}},yK=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,s;const{placement:i,middlewareData:a,rects:l,initialPlacement:f,platform:d,elements:p}=t,{mainAxis:g=!0,crossAxis:y=!0,fallbackPlacements:b,fallbackStrategy:x="bestFit",fallbackAxisSideDirection:S="none",flipAlignment:w=!0,...T}=ao(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const C=Zn(i),O=Fr(f),N=Zn(f)===f,R=await(d.isRTL==null?void 0:d.isRTL(p.floating)),M=b||(N||!w?[Hh(f)]:jV(f)),z=S!=="none";!b&&z&&M.push(...MV(f,w,S,R));const j=[f,...M],A=await d.detectOverflow(t,T),P=[];let Q=((s=a.flip)==null?void 0:s.overflows)||[];if(g&&P.push(A[C]),y){const K=NV(i,l,R);P.push(A[K[0]],A[K[1]])}if(Q=[...Q,{placement:i,overflows:P}],!P.every(K=>K<=0)){var B,U;const K=(((B=a.flip)==null?void 0:B.index)||0)+1,ee=j[K];if(ee&&(!(y==="alignment"?O!==Fr(ee):!1)||Q.every(q=>Fr(q.placement)===O?q.overflows[0]>0:!0)))return{data:{index:K,overflows:Q},reset:{placement:ee}};let D=(U=Q.filter(G=>G.overflows[0]<=0).sort((G,q)=>G.overflows[1]-q.overflows[1])[0])==null?void 0:U.placement;if(!D)switch(x){case"bestFit":{var Z;const G=(Z=Q.filter(q=>{if(z){const V=Fr(q.placement);return V===O||V==="y"}return!0}).map(q=>[q.placement,q.overflows.filter(V=>V>0).reduce((V,L)=>V+L,0)]).sort((q,V)=>q[1]-V[1])[0])==null?void 0:Z[0];G&&(D=G);break}case"initialPlacement":D=f;break}if(i!==D)return{reset:{placement:D}}}return{}}}};function vC(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function bC(e){return EV.some(t=>e[t]>=0)}const vK=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:s}=t,{strategy:i="referenceHidden",...a}=ao(e,t);switch(i){case"referenceHidden":{const l=await s.detectOverflow(t,{...a,elementContext:"reference"}),f=vC(l,n.reference);return{data:{referenceHiddenOffsets:f,referenceHidden:bC(f)}}}case"escaped":{const l=await s.detectOverflow(t,{...a,altBoundary:!0}),f=vC(l,n.floating);return{data:{escapedOffsets:f,escaped:bC(f)}}}default:return{}}}}},TA=new Set(["left","top"]);async function bK(e,t){const{placement:n,platform:s,elements:i}=e,a=await(s.isRTL==null?void 0:s.isRTL(i.floating)),l=Zn(n),f=Si(n),d=Fr(n)==="y",p=TA.has(l)?-1:1,g=a&&d?-1:1,y=ao(t,e);let{mainAxis:b,crossAxis:x,alignmentAxis:S}=typeof y=="number"?{mainAxis:y,crossAxis:0,alignmentAxis:null}:{mainAxis:y.mainAxis||0,crossAxis:y.crossAxis||0,alignmentAxis:y.alignmentAxis};return f&&typeof S=="number"&&(x=f==="end"?S*-1:S),d?{x:x*g,y:b*p}:{x:b*p,y:x*g}}const xK=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,s;const{x:i,y:a,placement:l,middlewareData:f}=t,d=await bK(t,e);return l===((n=f.offset)==null?void 0:n.placement)&&(s=f.arrow)!=null&&s.alignmentOffset?{}:{x:i+d.x,y:a+d.y,data:{...d,placement:l}}}}},SK=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:s,placement:i,platform:a}=t,{mainAxis:l=!0,crossAxis:f=!1,limiter:d={fn:C=>{let{x:O,y:N}=C;return{x:O,y:N}}},...p}=ao(e,t),g={x:n,y:s},y=await a.detectOverflow(t,p),b=Fr(Zn(i)),x=rx(b);let S=g[x],w=g[b];if(l){const C=x==="y"?"top":"left",O=x==="y"?"bottom":"right",N=S+y[C],R=S-y[O];S=Pv(N,S,R)}if(f){const C=b==="y"?"top":"left",O=b==="y"?"bottom":"right",N=w+y[C],R=w-y[O];w=Pv(N,w,R)}const T=d.fn({...t,[x]:S,[b]:w});return{...T,data:{x:T.x-n,y:T.y-s,enabled:{[x]:l,[b]:f}}}}}},_K=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:s,placement:i,rects:a,middlewareData:l}=t,{offset:f=0,mainAxis:d=!0,crossAxis:p=!0}=ao(e,t),g={x:n,y:s},y=Fr(i),b=rx(y);let x=g[b],S=g[y];const w=ao(f,t),T=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(d){const N=b==="y"?"height":"width",R=a.reference[b]-a.floating[N]+T.mainAxis,M=a.reference[b]+a.reference[N]-T.mainAxis;x<R?x=R:x>M&&(x=M)}if(p){var C,O;const N=b==="y"?"width":"height",R=TA.has(Zn(i)),M=a.reference[y]-a.floating[N]+(R&&((C=l.offset)==null?void 0:C[y])||0)+(R?0:T.crossAxis),z=a.reference[y]+a.reference[N]+(R?0:((O=l.offset)==null?void 0:O[y])||0)-(R?T.crossAxis:0);S<M?S=M:S>z&&(S=z)}return{[b]:x,[y]:S}}}},wK=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,s;const{placement:i,rects:a,platform:l,elements:f}=t,{apply:d=()=>{},...p}=ao(e,t),g=await l.detectOverflow(t,p),y=Zn(i),b=Si(i),x=Fr(i)==="y",{width:S,height:w}=a.floating;let T,C;y==="top"||y==="bottom"?(T=y,C=b===(await(l.isRTL==null?void 0:l.isRTL(f.floating))?"start":"end")?"left":"right"):(C=y,T=b==="end"?"top":"bottom");const O=w-g.top-g.bottom,N=S-g.left-g.right,R=Lc(w-g[T],O),M=Lc(S-g[C],N),z=!t.middlewareData.shift;let j=R,A=M;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=N),(s=t.middlewareData.shift)!=null&&s.enabled.y&&(j=O),z&&!b){const Q=dr(g.left,0),B=dr(g.right,0),U=dr(g.top,0),Z=dr(g.bottom,0);x?A=S-2*(Q!==0||B!==0?Q+B:dr(g.left,g.right)):j=w-2*(U!==0||Z!==0?U+Z:dr(g.top,g.bottom))}await d({...t,availableWidth:A,availableHeight:j});const P=await l.getDimensions(f.floating);return S!==P.width||w!==P.height?{reset:{rects:!0}}:{}}}};function CA(e){const t=xr(e);let n=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const i=Zt(e),a=i?e.offsetWidth:n,l=i?e.offsetHeight:s,f=Fh(n)!==a||Fh(s)!==l;return f&&(n=a,s=l),{width:n,height:s,$:f}}function cx(e){return jt(e)?e:e.contextElement}function _c(e){const t=cx(e);if(!Zt(t))return xs(1);const n=t.getBoundingClientRect(),{width:s,height:i,$:a}=CA(t);let l=(a?Fh(n.width):n.width)/s,f=(a?Fh(n.height):n.height)/i;return(!l||!Number.isFinite(l))&&(l=1),(!f||!Number.isFinite(f))&&(f=1),{x:l,y:f}}const EK=xs(0);function RA(e){const t=un(e);return!vp()||!t.visualViewport?EK:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function TK(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==un(e)?!1:t}function da(e,t,n,s){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),a=cx(e);let l=xs(1);t&&(s?jt(s)&&(l=_c(s)):l=_c(e));const f=TK(a,n,s)?RA(a):xs(0);let d=(i.left+f.x)/l.x,p=(i.top+f.y)/l.y,g=i.width/l.x,y=i.height/l.y;if(a){const b=un(a),x=s&&jt(s)?un(s):s;let S=b,w=Av(S);for(;w&&s&&x!==S;){const T=_c(w),C=w.getBoundingClientRect(),O=xr(w),N=C.left+(w.clientLeft+parseFloat(O.paddingLeft))*T.x,R=C.top+(w.clientTop+parseFloat(O.paddingTop))*T.y;d*=T.x,p*=T.y,g*=T.x,y*=T.y,d+=N,p+=R,S=un(w),w=Av(S)}}return qh({width:g,height:y,x:d,y:p})}function Cp(e,t){const n=bp(e).scrollLeft;return t?t.left+n:da(_s(e)).left+n}function NA(e,t){const n=e.getBoundingClientRect(),s=n.left+t.scrollLeft-Cp(e,n),i=n.top+t.scrollTop;return{x:s,y:i}}function CK(e){let{elements:t,rect:n,offsetParent:s,strategy:i}=e;const a=i==="fixed",l=_s(s),f=t?yp(t.floating):!1;if(s===l||f&&a)return n;let d={scrollLeft:0,scrollTop:0},p=xs(1);const g=xs(0),y=Zt(s);if((y||!y&&!a)&&((yi(s)!=="body"||vi(l))&&(d=bp(s)),Zt(s))){const x=da(s);p=_c(s),g.x=x.x+s.clientLeft,g.y=x.y+s.clientTop}const b=l&&!y&&!a?NA(l,d):xs(0);return{width:n.width*p.x,height:n.height*p.y,x:n.x*p.x-d.scrollLeft*p.x+g.x+b.x,y:n.y*p.y-d.scrollTop*p.y+g.y+b.y}}function RK(e){return Array.from(e.getClientRects())}function NK(e){const t=_s(e),n=bp(e),s=e.ownerDocument.body,i=dr(t.scrollWidth,t.clientWidth,s.scrollWidth,s.clientWidth),a=dr(t.scrollHeight,t.clientHeight,s.scrollHeight,s.clientHeight);let l=-n.scrollLeft+Cp(e);const f=-n.scrollTop;return xr(s).direction==="rtl"&&(l+=dr(t.clientWidth,s.clientWidth)-i),{width:i,height:a,x:l,y:f}}const xC=25;function jK(e,t){const n=un(e),s=_s(e),i=n.visualViewport;let a=s.clientWidth,l=s.clientHeight,f=0,d=0;if(i){a=i.width,l=i.height;const g=vp();(!g||g&&t==="fixed")&&(f=i.offsetLeft,d=i.offsetTop)}const p=Cp(s);if(p<=0){const g=s.ownerDocument,y=g.body,b=getComputedStyle(y),x=g.compatMode==="CSS1Compat"&&parseFloat(b.marginLeft)+parseFloat(b.marginRight)||0,S=Math.abs(s.clientWidth-y.clientWidth-x);S<=xC&&(a-=S)}else p<=xC&&(a+=p);return{width:a,height:l,x:f,y:d}}const AK=new Set(["absolute","fixed"]);function kK(e,t){const n=da(e,!0,t==="fixed"),s=n.top+e.clientTop,i=n.left+e.clientLeft,a=Zt(e)?_c(e):xs(1),l=e.clientWidth*a.x,f=e.clientHeight*a.y,d=i*a.x,p=s*a.y;return{width:l,height:f,x:d,y:p}}function SC(e,t,n){let s;if(t==="viewport")s=jK(e,n);else if(t==="document")s=NK(_s(e));else if(jt(t))s=kK(t,n);else{const i=RA(e);s={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return qh(s)}function jA(e,t){const n=io(e);return n===t||!jt(n)||Xs(n)?!1:xr(n).position==="fixed"||jA(n,t)}function OK(e,t){const n=t.get(e);if(n)return n;let s=Wo(e,[],!1).filter(f=>jt(f)&&yi(f)!=="body"),i=null;const a=xr(e).position==="fixed";let l=a?io(e):e;for(;jt(l)&&!Xs(l);){const f=xr(l),d=Zb(l);!d&&f.position==="fixed"&&(i=null),(a?!d&&!i:!d&&f.position==="static"&&!!i&&AK.has(i.position)||vi(l)&&!d&&jA(e,l))?s=s.filter(g=>g!==l):i=f,l=io(l)}return t.set(e,s),s}function MK(e){let{element:t,boundary:n,rootBoundary:s,strategy:i}=e;const l=[...n==="clippingAncestors"?yp(t)?[]:OK(t,this._c):[].concat(n),s],f=l[0],d=l.reduce((p,g)=>{const y=SC(t,g,i);return p.top=dr(y.top,p.top),p.right=Lc(y.right,p.right),p.bottom=Lc(y.bottom,p.bottom),p.left=dr(y.left,p.left),p},SC(t,f,i));return{width:d.right-d.left,height:d.bottom-d.top,x:d.left,y:d.top}}function IK(e){const{width:t,height:n}=CA(e);return{width:t,height:n}}function PK(e,t,n){const s=Zt(t),i=_s(t),a=n==="fixed",l=da(e,!0,a,t);let f={scrollLeft:0,scrollTop:0};const d=xs(0);function p(){d.x=Cp(i)}if(s||!s&&!a)if((yi(t)!=="body"||vi(i))&&(f=bp(t)),s){const x=da(t,!0,a,t);d.x=x.x+t.clientLeft,d.y=x.y+t.clientTop}else i&&p();a&&!s&&i&&p();const g=i&&!s&&!a?NA(i,f):xs(0),y=l.left+f.scrollLeft-d.x-g.x,b=l.top+f.scrollTop-d.y-g.y;return{x:y,y:b,width:l.width,height:l.height}}function Py(e){return xr(e).position==="static"}function _C(e,t){if(!Zt(e)||xr(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return _s(e)===n&&(n=n.ownerDocument.body),n}function AA(e,t){const n=un(e);if(yp(e))return n;if(!Zt(e)){let i=io(e);for(;i&&!Xs(i);){if(jt(i)&&!Py(i))return i;i=io(i)}return n}let s=_C(e,t);for(;s&&a8(s)&&Py(s);)s=_C(s,t);return s&&Xs(s)&&Py(s)&&!Zb(s)?n:s||d8(e)||n}const DK=async function(e){const t=this.getOffsetParent||AA,n=this.getDimensions,s=await n(e.floating);return{reference:PK(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function zK(e){return xr(e).direction==="rtl"}const LK={convertOffsetParentRelativeRectToViewportRelativeRect:CK,getDocumentElement:_s,getClippingRect:MK,getOffsetParent:AA,getElementRects:DK,getClientRects:RK,getDimensions:IK,getScale:_c,isElement:jt,isRTL:zK};function kA(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function UK(e,t){let n=null,s;const i=_s(e);function a(){var f;clearTimeout(s),(f=n)==null||f.disconnect(),n=null}function l(f,d){f===void 0&&(f=!1),d===void 0&&(d=1),a();const p=e.getBoundingClientRect(),{left:g,top:y,width:b,height:x}=p;if(f||t(),!b||!x)return;const S=hc(y),w=hc(i.clientWidth-(g+b)),T=hc(i.clientHeight-(y+x)),C=hc(g),N={rootMargin:-S+"px "+-w+"px "+-T+"px "+-C+"px",threshold:dr(0,Lc(1,d))||1};let R=!0;function M(z){const j=z[0].intersectionRatio;if(j!==d){if(!R)return l();j?l(!1,j):s=setTimeout(()=>{l(!1,1e-7)},1e3)}j===1&&!kA(p,e.getBoundingClientRect())&&l(),R=!1}try{n=new IntersectionObserver(M,{...N,root:i.ownerDocument})}catch{n=new IntersectionObserver(M,N)}n.observe(e)}return l(!0),a}function wC(e,t,n,s){s===void 0&&(s={});const{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:l=typeof ResizeObserver=="function",layoutShift:f=typeof IntersectionObserver=="function",animationFrame:d=!1}=s,p=cx(e),g=i||a?[...p?Wo(p):[],...Wo(t)]:[];g.forEach(C=>{i&&C.addEventListener("scroll",n,{passive:!0}),a&&C.addEventListener("resize",n)});const y=p&&f?UK(p,n):null;let b=-1,x=null;l&&(x=new ResizeObserver(C=>{let[O]=C;O&&O.target===p&&x&&(x.unobserve(t),cancelAnimationFrame(b),b=requestAnimationFrame(()=>{var N;(N=x)==null||N.observe(t)})),n()}),p&&!d&&x.observe(p),x.observe(t));let S,w=d?da(e):null;d&&T();function T(){const C=da(e);w&&!kA(w,C)&&n(),w=C,S=requestAnimationFrame(T)}return n(),()=>{var C;g.forEach(O=>{i&&O.removeEventListener("scroll",n),a&&O.removeEventListener("resize",n)}),y?.(),(C=x)==null||C.disconnect(),x=null,d&&cancelAnimationFrame(S)}}const $K=xK,BK=SK,FK=yK,HK=wK,qK=vK,VK=_K,KK=(e,t,n)=>{const s=new Map,i={platform:LK,...n},a={...i.platform,_c:s};return gK(e,t,{...i,platform:a})};var GK=typeof document<"u",ZK=function(){},lh=GK?_.useLayoutEffect:ZK;function Xh(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,s,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(s=n;s--!==0;)if(!Xh(e[s],t[s]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(s=n;s--!==0;)if(!{}.hasOwnProperty.call(t,i[s]))return!1;for(s=n;s--!==0;){const a=i[s];if(!(a==="_owner"&&e.$$typeof)&&!Xh(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function OA(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function EC(e,t){const n=OA(e);return Math.round(t*n)/n}function Dy(e){const t=_.useRef(e);return lh(()=>{t.current=e}),t}function YK(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:s=[],platform:i,elements:{reference:a,floating:l}={},transform:f=!0,whileElementsMounted:d,open:p}=e,[g,y]=_.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[b,x]=_.useState(s);Xh(b,s)||x(s);const[S,w]=_.useState(null),[T,C]=_.useState(null),O=_.useCallback(q=>{q!==z.current&&(z.current=q,w(q))},[]),N=_.useCallback(q=>{q!==j.current&&(j.current=q,C(q))},[]),R=a||S,M=l||T,z=_.useRef(null),j=_.useRef(null),A=_.useRef(g),P=d!=null,Q=Dy(d),B=Dy(i),U=Dy(p),Z=_.useCallback(()=>{if(!z.current||!j.current)return;const q={placement:t,strategy:n,middleware:b};B.current&&(q.platform=B.current),KK(z.current,j.current,q).then(V=>{const L={...V,isPositioned:U.current!==!1};K.current&&!Xh(A.current,L)&&(A.current=L,hi.flushSync(()=>{y(L)}))})},[b,t,n,B,U]);lh(()=>{p===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,y(q=>({...q,isPositioned:!1})))},[p]);const K=_.useRef(!1);lh(()=>(K.current=!0,()=>{K.current=!1}),[]),lh(()=>{if(R&&(z.current=R),M&&(j.current=M),R&&M){if(Q.current)return Q.current(R,M,Z);Z()}},[R,M,Z,Q,P]);const ee=_.useMemo(()=>({reference:z,floating:j,setReference:O,setFloating:N}),[O,N]),D=_.useMemo(()=>({reference:R,floating:M}),[R,M]),G=_.useMemo(()=>{const q={position:n,left:0,top:0};if(!D.floating)return q;const V=EC(D.floating,g.x),L=EC(D.floating,g.y);return f?{...q,transform:"translate("+V+"px, "+L+"px)",...OA(D.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:V,top:L}},[n,f,D.floating,g.x,g.y]);return _.useMemo(()=>({...g,update:Z,refs:ee,elements:D,floatingStyles:G}),[g,Z,ee,D,G])}const XK=(e,t)=>({...$K(e),options:[e,t]}),QK=(e,t)=>({...BK(e),options:[e,t]}),WK=(e,t)=>({...VK(e),options:[e,t]}),JK=(e,t)=>({...FK(e),options:[e,t]}),e7=(e,t)=>({...HK(e),options:[e,t]}),t7=(e,t)=>({...qK(e),options:[e,t]}),n7={intentional:"onClick",sloppy:"onPointerDown"};function r7(e){return{escapeKey:typeof e=="boolean"?e:e?.escapeKey??!1,outsidePress:typeof e=="boolean"?e:e?.outsidePress??!0}}function s7(e,t={}){const n="rootStore"in e?e.rootStore:e,s=n.useState("open"),i=n.useState("floatingElement"),a=n.useState("referenceElement"),l=n.useState("domReferenceElement"),{onOpenChange:f,dataRef:d}=n.context,{enabled:p=!0,escapeKey:g=!0,outsidePress:y=!0,outsidePressEvent:b="sloppy",referencePress:x=!1,referencePressEvent:S="sloppy",ancestorScroll:w=!1,bubbles:T,externalTree:C}=t,O=Tp(C),N=Ae(typeof y=="function"?y:()=>!1),R=typeof y=="function"?N:y,M=_.useRef(!1),{escapeKey:z,outsidePress:j}=r7(T),A=_.useRef(null),P=ns(),Q=ns(),B=Ae(()=>{Q.clear(),d.current.insideReactTree=!1}),U=_.useRef(!1),Z=_.useRef(""),K=Ae(re=>{Z.current=re.pointerType}),ee=Ae(()=>{const re=Z.current,he=re==="pen"||!re?"mouse":re,ie=typeof b=="function"?b():b;return typeof ie=="string"?ie:ie[he]}),D=Ae(re=>{if(!s||!p||!g||re.key!=="Escape"||U.current)return;const he=d.current.floatingContext?.nodeId,ie=O?xc(O.nodesRef.current,he):[];if(!z&&ie.length>0){let xe=!0;if(ie.forEach(ve=>{ve.context?.open&&!ve.context.dataRef.current.__escapeKeyBubbles&&(xe=!1)}),!xe)return}const we=bV(re)?re.nativeEvent:re,ye=Yt(v8,we);n.setOpen(!1,ye),!z&&!ye.isPropagationAllowed&&re.stopPropagation()}),G=Ae(re=>{const he=ee();return he==="intentional"&&re.type!=="click"||he==="sloppy"&&re.type==="click"}),q=Ae(()=>{d.current.insideReactTree=!0,Q.start(0,B)}),V=Ae((re,he=!1)=>{if(G(re)){B();return}if(d.current.insideReactTree){B();return}if(ee()==="intentional"&&he||typeof R=="function"&&!R(re))return;const ie=Ur(re),we=`[${Nu("inert")}]`,ye=Rt(n.select("floatingElement")).querySelectorAll(we),xe=n.context.triggerElements;if(ie&&(xe.hasElement(ie)||xe.hasMatchingElement(Ve=>Ot(Ve,ie))))return;let ve=jt(ie)?ie:null;for(;ve&&!Xs(ve);){const Ve=io(ve);if(Xs(Ve)||!jt(Ve))break;ve=Ve}if(ye.length&&jt(ie)&&!vV(ie)&&!Ot(ie,n.select("floatingElement"))&&Array.from(ye).every(Ve=>!Ot(ve,Ve)))return;if(Zt(ie)&&!("touches"in re)){const Ve=Xs(ie),Qe=xr(ie),Be=/auto|scroll/,We=Ve||Be.test(Qe.overflowX),He=Ve||Be.test(Qe.overflowY),me=We&&ie.clientWidth>0&&ie.scrollWidth>ie.clientWidth,Te=He&&ie.clientHeight>0&&ie.scrollHeight>ie.clientHeight,qe=Qe.direction==="rtl",mt=Te&&(qe?re.offsetX<=ie.offsetWidth-ie.clientWidth:re.offsetX>ie.clientWidth),lt=me&&re.offsetY>ie.clientHeight;if(mt||lt)return}const Ie=d.current.floatingContext?.nodeId,Ue=O&&xc(O.nodesRef.current,Ie).some(Ve=>Jr(re,Ve.context?.elements.floating));if(Jr(re,n.select("floatingElement"))||Jr(re,n.select("domReferenceElement"))||Ue)return;const Ee=O?xc(O.nodesRef.current,Ie):[];if(Ee.length>0){let Ve=!0;if(Ee.forEach(Qe=>{Qe.context?.open&&!Qe.context.dataRef.current.__outsidePressBubbles&&(Ve=!1)}),!Ve)return}n.setOpen(!1,Yt(zj,re)),B()}),L=Ae(re=>{ee()!=="sloppy"||re.pointerType==="touch"||!n.select("open")||!p||Jr(re,n.select("floatingElement"))||Jr(re,n.select("domReferenceElement"))||V(re)}),I=Ae(re=>{if(ee()!=="sloppy"||!n.select("open")||!p||Jr(re,n.select("floatingElement"))||Jr(re,n.select("domReferenceElement")))return;const he=re.touches[0];he&&(A.current={startTime:Date.now(),startX:he.clientX,startY:he.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},P.start(1e3,()=>{A.current&&(A.current.dismissOnTouchEnd=!1,A.current.dismissOnMouseDown=!1)}))}),H=Ae(re=>{const he=Ur(re);function ie(){I(re),he?.removeEventListener(re.type,ie)}he?.addEventListener(re.type,ie)}),W=Ae(re=>{const he=M.current;if(M.current=!1,P.clear(),re.type==="mousedown"&&A.current&&!A.current.dismissOnMouseDown)return;const ie=Ur(re);function we(){re.type==="pointerdown"?L(re):V(re,he),ie?.removeEventListener(re.type,we)}ie?.addEventListener(re.type,we)}),Y=Ae(re=>{if(ee()!=="sloppy"||!A.current||Jr(re,n.select("floatingElement"))||Jr(re,n.select("domReferenceElement")))return;const he=re.touches[0];if(!he)return;const ie=Math.abs(he.clientX-A.current.startX),we=Math.abs(he.clientY-A.current.startY),ye=Math.sqrt(ie*ie+we*we);ye>5&&(A.current.dismissOnTouchEnd=!0),ye>10&&(V(re),P.clear(),A.current=null)}),ae=Ae(re=>{const he=Ur(re);function ie(){Y(re),he?.removeEventListener(re.type,ie)}he?.addEventListener(re.type,ie)}),se=Ae(re=>{ee()!=="sloppy"||!A.current||Jr(re,n.select("floatingElement"))||Jr(re,n.select("domReferenceElement"))||(A.current.dismissOnTouchEnd&&V(re),P.clear(),A.current=null)}),fe=Ae(re=>{const he=Ur(re);function ie(){se(re),he?.removeEventListener(re.type,ie)}he?.addEventListener(re.type,ie)});_.useEffect(()=>{if(!s||!p)return;d.current.__escapeKeyBubbles=z,d.current.__outsidePressBubbles=j;const re=new ai;function he(ve){n.setOpen(!1,Yt(ii,ve))}function ie(){re.clear(),U.current=!0}function we(){re.start(vp()?5:0,()=>{U.current=!1})}const ye=Rt(i);ye.addEventListener("pointerdown",K,!0),g&&(ye.addEventListener("keydown",D),ye.addEventListener("compositionstart",ie),ye.addEventListener("compositionend",we)),R&&(ye.addEventListener("click",W,!0),ye.addEventListener("pointerdown",W,!0),ye.addEventListener("touchstart",H,!0),ye.addEventListener("touchmove",ae,!0),ye.addEventListener("touchend",fe,!0),ye.addEventListener("mousedown",W,!0));let xe=[];return w&&(jt(l)&&(xe=Wo(l)),jt(i)&&(xe=xe.concat(Wo(i))),!jt(a)&&a&&a.contextElement&&(xe=xe.concat(Wo(a.contextElement)))),xe=xe.filter(ve=>ve!==ye.defaultView?.visualViewport),xe.forEach(ve=>{ve.addEventListener("scroll",he,{passive:!0})}),()=>{ye.removeEventListener("pointerdown",K,!0),g&&(ye.removeEventListener("keydown",D),ye.removeEventListener("compositionstart",ie),ye.removeEventListener("compositionend",we)),R&&(ye.removeEventListener("click",W,!0),ye.removeEventListener("pointerdown",W,!0),ye.removeEventListener("touchstart",H,!0),ye.removeEventListener("touchmove",ae,!0),ye.removeEventListener("touchend",fe,!0),ye.removeEventListener("mousedown",W,!0)),xe.forEach(ve=>{ve.removeEventListener("scroll",he)}),re.clear(),M.current=!1}},[d,i,a,l,g,R,s,f,w,p,z,j,D,V,W,L,H,ae,fe,K,n]),_.useEffect(B,[R,B]);const Se=_.useMemo(()=>({onKeyDown:D,...x&&{[n7[S]]:re=>{n.setOpen(!1,Yt(oC,re.nativeEvent))},...S!=="intentional"&&{onClick(re){n.setOpen(!1,Yt(oC,re.nativeEvent))}}}}),[D,n,x,S]),pe=Ae(re=>{const he=Ur(re.nativeEvent);!Ot(n.select("floatingElement"),he)||re.button!==0||(M.current=!0)}),Oe=Ae(re=>{!s||!p||re.button!==0||(M.current=!0)}),_e=_.useMemo(()=>({onKeyDown:D,onPointerDown:pe,onMouseDown:pe,onMouseUp:pe,onClickCapture:q,onMouseDownCapture(re){q(),Oe(re)},onPointerDownCapture(re){q(),Oe(re)},onMouseUpCapture:q,onTouchEndCapture:q,onTouchMoveCapture:q}),[D,pe,q,Oe]);return _.useMemo(()=>p?{reference:Se,floating:_e,trigger:Se}:{},[p,Se,_e])}nj({memoize:fq,memoizeOptions:{maxSize:1,equalityCheck:Object.is}});const Pe=(e,t,n,s,i,a,...l)=>{if(l.length>0)throw new Error(yn(1));let f;if(e)f=e;else throw new Error("Missing arguments");return f};var o7=VN();const i7=Kb(19),a7=i7?l7:u7;function at(e,t,n,s,i){return a7(e,t,n,s,i)}function c7(e,t,n,s,i){const a=_.useCallback(()=>t(e.getSnapshot(),n,s,i),[e,t,n,s,i]);return o7.useSyncExternalStore(e.subscribe,a,a)}function l7(e,t,n,s,i){return c7(e,t,n,s,i)}function u7(e,t,n,s,i){return KN.useSyncExternalStoreWithSelector(e.subscribe,e.getSnapshot,e.getSnapshot,a=>t(a,n,s,i))}class f7{constructor(t){this.state=t,this.listeners=new Set,this.updateTick=0}subscribe=t=>(this.listeners.add(t),()=>{this.listeners.delete(t)});getSnapshot=()=>this.state;setState(t){if(this.state===t)return;this.state=t,this.updateTick+=1;const n=this.updateTick;for(const s of this.listeners){if(n!==this.updateTick)return;s(t)}}update(t){for(const n in t)if(!Object.is(this.state[n],t[n])){this.setState({...this.state,...t});return}}set(t,n){Object.is(this.state[t],n)||this.setState({...this.state,[t]:n})}notifyAll(){const t={...this.state};this.setState(t)}use(t,n,s,i){return at(this,t,n,s,i)}}class MA extends f7{constructor(t,n={},s){super(t),this.context=n,this.selectors=s}useSyncedValue(t,n){_.useDebugValue(t),Le(()=>{this.state[t]!==n&&this.set(t,n)},[t,n])}useSyncedValueWithCleanup(t,n){const s=this;Le(()=>(s.state[t]!==n&&s.set(t,n),()=>{s.set(t,void 0)}),[s,t,n])}useSyncedValues(t){const n=this,s=Object.values(t);Le(()=>{n.update(t)},[n,...s])}useControlledProp(t,n){_.useDebugValue(t);const s=n!==void 0;Le(()=>{s&&!Object.is(this.state[t],n)&&super.setState({...this.state,[t]:n})},[t,n,s])}select(t,n,s,i){const a=this.selectors[t];return a(this.state,n,s,i)}useState(t,n,s,i){return _.useDebugValue(t),at(this,this.selectors[t],n,s,i)}useContextCallback(t,n){_.useDebugValue(t);const s=Ae(n??jn);this.context[t]=s}useStateSetter(t){const n=_.useRef(void 0);return n.current===void 0&&(n.current=s=>{this.set(t,s)}),n.current}observe(t,n){let s;typeof t=="function"?s=t:s=this.selectors[t];let i=s(this.state);return n(i,i,this),this.subscribe(a=>{const l=s(a);if(!Object.is(i,l)){const f=i;i=l,n(l,f,this)}})}}const d7={open:Pe(e=>e.open),domReferenceElement:Pe(e=>e.domReferenceElement),referenceElement:Pe(e=>e.positionReference??e.referenceElement),floatingElement:Pe(e=>e.floatingElement),floatingId:Pe(e=>e.floatingId)};class lx extends MA{constructor(t){const{nested:n,noEmit:s,onOpenChange:i,triggerElements:a,...l}=t;super({...l,positionReference:l.referenceElement,domReferenceElement:l.referenceElement},{onOpenChange:i,dataRef:{current:{}},events:rK(),nested:n,noEmit:s,triggerElements:a},d7)}setOpen=(t,n)=>{if((!t||!this.state.open||wV(n.event))&&(this.context.dataRef.current.openEvent=t?n.event:void 0),!this.context.noEmit){const s={open:t,reason:n.reason,nativeEvent:n.event,nested:this.context.nested,triggerElement:n.trigger};this.context.events.emit("openchange",s)}this.context.onOpenChange?.(t,n)}}function Rp(e,t=!1,n=!1){const[s,i]=_.useState(e&&t?"idle":void 0),[a,l]=_.useState(e);return e&&!a&&(l(!0),i("starting")),!e&&a&&s!=="ending"&&!n&&i("ending"),!e&&!a&&s==="ending"&&i(void 0),Le(()=>{if(!e&&a&&s!=="ending"&&n){const f=ys.request(()=>{i("ending")});return()=>{ys.cancel(f)}}},[e,a,s,n]),Le(()=>{if(!e||t)return;const f=ys.request(()=>{i(void 0)});return()=>{ys.cancel(f)}},[t,e]),Le(()=>{if(!e||!t)return;e&&a&&s!=="idle"&&i("starting");const f=ys.request(()=>{i("idle")});return()=>{ys.cancel(f)}},[t,e,a,i,s]),_.useMemo(()=>({mounted:a,setMounted:l,transitionStatus:s}),[a,s])}let ju=(function(e){return e.startingStyle="data-starting-style",e.endingStyle="data-ending-style",e})({});const h7={[ju.startingStyle]:""},p7={[ju.endingStyle]:""},ba={transitionStatus(e){return e==="starting"?h7:e==="ending"?p7:null}};function m7(e,t=!1,n=!0){const s=ix();return Ae((i,a=null)=>{s.cancel();function l(){hi.flushSync(i)}const f=qs(e);if(f==null)return;const d=f;if(typeof d.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED)i();else{let y=function(){const x=ju.startingStyle;if(!d.hasAttribute(x)){s.request(b);return}const S=new MutationObserver(()=>{d.hasAttribute(x)||(S.disconnect(),b())});S.observe(d,{attributes:!0,attributeFilter:[x]}),a?.addEventListener("abort",()=>S.disconnect(),{once:!0})},b=function(){Promise.all(d.getAnimations().map(x=>x.finished)).then(()=>{a?.aborted||l()}).catch(()=>{const x=d.getAnimations();if(n){if(a?.aborted)return;l()}else x.length>0&&x.some(S=>S.pending||S.playState!=="finished")&&b()})};var p=y,g=b;if(t){y();return}s.request(b)}})}function xa(e){const{enabled:t=!0,open:n,ref:s,onComplete:i}=e,a=Ae(i),l=m7(s,n,!1);_.useEffect(()=>{if(!t)return;const f=new AbortController;return l(a,f.signal),()=>{f.abort()}},[t,n,a,l])}function g7(e){const t=e.useState("open");Le(()=>{if(t&&!e.select("activeTriggerId")&&e.context.triggerElements.size===1){const n=e.context.triggerElements.entries().next();if(!n.done){const[s,i]=n.value;e.update({activeTriggerId:s,activeTriggerElement:i})}}},[t,e])}function y7(e,t,n){const{mounted:s,setMounted:i,transitionStatus:a}=Rp(e);t.useSyncedValues({mounted:s,transitionStatus:a});const l=Ae(()=>{i(!1),t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)}),f=t.useState("preventUnmountingOnClose");return xa({enabled:!f,open:e,ref:t.context.popupRef,onComplete(){e||l()}}),{forceUnmount:l,transitionStatus:a}}class ux{constructor(){this.elementsSet=new Set,this.idMap=new Map}add(t,n){const s=this.idMap.get(t);s!==n&&(s!==void 0&&this.elementsSet.delete(s),this.elementsSet.add(n),this.idMap.set(t,n))}delete(t){const n=this.idMap.get(t);n&&(this.elementsSet.delete(n),this.idMap.delete(t))}hasElement(t){return this.elementsSet.has(t)}hasMatchingElement(t){for(const n of this.elementsSet)if(t(n))return!0;return!1}getById(t){return this.idMap.get(t)}entries(){return this.idMap.entries()}elements(){return this.elementsSet.values()}get size(){return this.idMap.size}}function v7(){return new lx({open:!1,floatingElement:null,referenceElement:null,triggerElements:new ux,floatingId:"",nested:!1,noEmit:!1,onOpenChange:void 0})}function b7(){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:"idle",floatingRootContext:v7(),preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:an,inactiveTriggerProps:an,popupProps:an}}const Fd=Pe(e=>e.triggerIdProp??e.activeTriggerId),x7={open:Pe(e=>e.openProp??e.open),mounted:Pe(e=>e.mounted),transitionStatus:Pe(e=>e.transitionStatus),floatingRootContext:Pe(e=>e.floatingRootContext),preventUnmountingOnClose:Pe(e=>e.preventUnmountingOnClose),payload:Pe(e=>e.payload),activeTriggerId:Fd,activeTriggerElement:Pe(e=>e.mounted?e.activeTriggerElement:null),isTriggerActive:Pe((e,t)=>t!==void 0&&Fd(e)===t),isOpenedByTrigger:Pe((e,t)=>t!==void 0&&Fd(e)===t&&e.open),isMountedByTrigger:Pe((e,t)=>t!==void 0&&Fd(e)===t&&e.mounted),triggerProps:Pe((e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps),popupProps:Pe(e=>e.popupProps),popupElement:Pe(e=>e.popupElement),positionerElement:Pe(e=>e.positionerElement)};function S7(e){const{open:t=!1,onOpenChange:n,elements:s={}}=e,i=Xu(),a=Ep()!=null,l=zn(()=>new lx({open:t,onOpenChange:n,referenceElement:s.reference??null,floatingElement:s.floating??null,triggerElements:new ux,floatingId:i,nested:a,noEmit:!1})).current;return Le(()=>{const f={open:t,floatingId:i};s.reference!==void 0&&(f.referenceElement=s.reference,f.domReferenceElement=jt(s.reference)?s.reference:null),s.floating!==void 0&&(f.floatingElement=s.floating),l.update(f)},[t,i,s.reference,s.floating,l]),l.context.onOpenChange=n,l.context.nested=a,l.context.noEmit=!1,l}function _7(e={}){const{nodeId:t,externalTree:n}=e,s=S7(e),i=e.rootContext||s,a={reference:i.useState("referenceElement"),floating:i.useState("floatingElement"),domReference:i.useState("domReferenceElement")},[l,f]=_.useState(null),d=_.useRef(null),p=Tp(n);Le(()=>{a.domReference&&(d.current=a.domReference)},[a.domReference]);const g=YK({...e,elements:{...a,...l&&{reference:l}}}),y=_.useCallback(j=>{const A=jt(j)?{getBoundingClientRect:()=>j.getBoundingClientRect(),getClientRects:()=>j.getClientRects(),contextElement:j}:j;f(A),g.refs.setReference(A)},[g.refs]),[b,x]=_.useState(null),[S,w]=_.useState(null);i.useSyncedValue("referenceElement",b),i.useSyncedValue("domReferenceElement",jt(b)?b:null),i.useSyncedValue("floatingElement",S);const T=_.useCallback(j=>{(jt(j)||j===null)&&(d.current=j,x(j)),(jt(g.refs.reference.current)||g.refs.reference.current===null||j!==null&&!jt(j))&&g.refs.setReference(j)},[g.refs,x]),C=_.useCallback(j=>{w(j),g.refs.setFloating(j)},[g.refs]),O=_.useMemo(()=>({...g.refs,setReference:T,setFloating:C,setPositionReference:y,domReference:d}),[g.refs,T,C,y]),N=_.useMemo(()=>({...g.elements,domReference:a.domReference}),[g.elements,a.domReference]),R=i.useState("open"),M=i.useState("floatingId"),z=_.useMemo(()=>({...g,dataRef:i.context.dataRef,open:R,onOpenChange:i.setOpen,events:i.context.events,floatingId:M,refs:O,elements:N,nodeId:t,rootStore:i}),[g,O,N,t,i,R,M]);return Le(()=>{i.context.dataRef.current.floatingContext=z;const j=p?.nodesRef.current.find(A=>A.id===t);j&&(j.context=z)}),_.useMemo(()=>({...g,context:z,refs:O,elements:N,rootStore:i}),[g,O,N,z,i])}function w7(e){const{popupStore:t,noEmit:n=!1,treatPopupAsFloatingElement:s=!1,onOpenChange:i}=e,a=Xu(),l=Ep()!=null,f=t.useState("open"),d=t.useState("activeTriggerElement"),p=t.useState(s?"popupElement":"positionerElement"),g=t.context.triggerElements,y=zn(()=>new lx({open:f,referenceElement:d,floatingElement:p,triggerElements:g,onOpenChange:i,floatingId:a,nested:l,noEmit:n})).current;return Le(()=>{const b={open:f,floatingId:a,referenceElement:d,floatingElement:p};jt(d)&&(b.domReferenceElement=d),y.state.positionReference===y.state.referenceElement&&(b.positionReference=d),y.update(b)},[f,a,d,p,y]),y.context.onOpenChange=i,y.context.nested=l,y.context.noEmit=n,y}const TC=Nu("safe-polygon"),E7=`button,a,[role="button"],select,[tabindex]:not([tabindex="-1"]),${iA}`;function T7(e){return e?!!e.closest(E7):!1}class fx{constructor(){this.pointerType=void 0,this.interactedInside=!1,this.handler=void 0,this.blockMouseMove=!0,this.performedPointerEventsMutation=!1,this.unbindMouseMove=()=>{},this.restTimeoutPending=!1,this.openChangeTimeout=new ai,this.restTimeout=new ai,this.handleCloseOptions=void 0}static create(){return new fx}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose}function C7(e){const t=zn(fx.create).current,n=e.context.dataRef.current;return n.hoverInteractionState||(n.hoverInteractionState=t),tx(n.hoverInteractionState.disposeEffect),n.hoverInteractionState}const R7=new Set(["click","mousedown"]);function N7(e,t={}){const n="rootStore"in e?e.rootStore:e,s=n.useState("open"),i=n.useState("floatingElement"),a=n.useState("domReferenceElement"),{dataRef:l}=n.context,{enabled:f=!0,closeDelay:d=0}=t,p=C7(n),g=Tp(),y=Ep(),b=Ae(()=>p.interactedInside?!0:l.current.openEvent?R7.has(l.current.openEvent.type):!1),x=Ae(()=>{const N=l.current.openEvent?.type;return N?.includes("mouse")&&N!=="mousedown"}),S=Ae(N=>yV(N,n.context.triggerElements)),w=_.useCallback((N,R=!0)=>{const M=j7(d,p.pointerType);M&&!p.handler?p.openChangeTimeout.start(M,()=>n.setOpen(!1,Yt(Ov,N))):R&&(p.openChangeTimeout.clear(),n.setOpen(!1,Yt(Ov,N)))},[d,n,p]),T=Ae(()=>{p.unbindMouseMove(),p.handler=void 0}),C=Ae(()=>{if(p.performedPointerEventsMutation){const N=Rt(i).body;N.style.pointerEvents="",N.removeAttribute(TC),p.performedPointerEventsMutation=!1}}),O=Ae(N=>{const R=Ur(N);if(!T7(R)){p.interactedInside=!1;return}p.interactedInside=!0});Le(()=>{s||(p.pointerType=void 0,p.restTimeoutPending=!1,p.interactedInside=!1,T(),C())},[s,p,T,C]),_.useEffect(()=>()=>{T()},[T]),_.useEffect(()=>C,[C]),Le(()=>{if(f&&s&&p.handleCloseOptions?.blockPointerEvents&&x()&&jt(a)&&i){p.performedPointerEventsMutation=!0;const N=Rt(i).body;N.setAttribute(TC,"");const R=a,M=i,z=g?.nodesRef.current.find(j=>j.id===y)?.context?.elements.floating;return z&&(z.style.pointerEvents=""),N.style.pointerEvents="none",R.style.pointerEvents="auto",M.style.pointerEvents="auto",()=>{N.style.pointerEvents="",R.style.pointerEvents="",M.style.pointerEvents=""}}},[f,s,a,i,p,x,g,y]),_.useEffect(()=>{if(!f)return;function N(j){b()||!l.current.floatingContext||!n.select("open")||S(j.relatedTarget)||(C(),T(),b()||w(j))}function R(j){p.openChangeTimeout.clear(),C(),p.handler?.(j),T()}function M(j){b()||w(j,!1)}const z=i;return z&&(z.addEventListener("mouseleave",N),z.addEventListener("mouseenter",R),z.addEventListener("mouseleave",M),z.addEventListener("pointerdown",O,!0)),()=>{z&&(z.removeEventListener("mouseleave",N),z.removeEventListener("mouseenter",R),z.removeEventListener("mouseleave",M),z.removeEventListener("pointerdown",O,!0))}},[f,i,n,l,b,S,w,C,T,O,p])}function j7(e,t){return t&&!_V(t)?0:typeof e=="function"?e():e}function A7(e=[]){const t=e.map(p=>p?.reference),n=e.map(p=>p?.floating),s=e.map(p=>p?.item),i=e.map(p=>p?.trigger),a=_.useCallback(p=>Hd(p,e,"reference"),t),l=_.useCallback(p=>Hd(p,e,"floating"),n),f=_.useCallback(p=>Hd(p,e,"item"),s),d=_.useCallback(p=>Hd(p,e,"trigger"),i);return _.useMemo(()=>({getReferenceProps:a,getFloatingProps:l,getItemProps:f,getTriggerProps:d}),[a,l,f,d])}function Hd(e,t,n){const s=new Map,i=n==="item",a={};n==="floating"&&(a.tabIndex=-1,a[Iv]="");for(const l in e)i&&e&&(l===sA||l===oA)||(a[l]=e[l]);for(let l=0;l<t.length;l+=1){let f;const d=t[l]?.[n];typeof d=="function"?f=e?d(e):null:f=d,f&&CC(a,f,i,s)}return CC(a,e,i,s),a}function CC(e,t,n,s){for(const i in t){const a=t[i];n&&(i===sA||i===oA)||(i.startsWith("on")?(s.has(i)||s.set(i,[]),typeof a=="function"&&(s.get(i)?.push(a),e[i]=(...l)=>s.get(i)?.map(f=>f(...l)).find(f=>f!==void 0))):e[i]=a)}}const k7=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function O7(e,t={}){const n="rootStore"in e?e.rootStore:e,s=n.useState("open"),i=n.useState("floatingId"),a=n.useState("domReferenceElement"),l=n.useState("floatingElement"),{role:f="dialog"}=t,d=Xu(),p=a?.id||d,g=_.useMemo(()=>Bh(l)?.id||i,[l,i]),y=k7.get(f)??f,x=Ep()!=null,S=_.useMemo(()=>y==="tooltip"||f==="label"?an:{"aria-haspopup":y==="alertdialog"?"dialog":y,"aria-expanded":"false",...y==="listbox"&&{role:"combobox"},...y==="menu"&&x&&{role:"menuitem"},...f==="select"&&{"aria-autocomplete":"none"},...f==="combobox"&&{"aria-autocomplete":"list"}},[y,x,f]),w=_.useMemo(()=>y==="tooltip"||f==="label"?{[`aria-${f==="label"?"labelledby":"describedby"}`]:s?g:void 0}:{...S,"aria-expanded":s?"true":"false","aria-controls":s?g:void 0,...y==="menu"&&{id:p}},[y,g,s,p,f,S]),T=_.useMemo(()=>{const O={id:g,...y&&{role:y}};return y==="tooltip"||f==="label"?O:{...O,...y==="menu"&&{"aria-labelledby":p}}},[y,g,p,f]),C=_.useCallback(({active:O,selected:N})=>{const R={role:"option",...O&&{id:`${g}-fui-option`}};switch(f){case"select":case"combobox":return{...R,"aria-selected":N}}return{}},[g,f]);return _.useMemo(()=>({reference:w,floating:T,item:C,trigger:S}),[w,T,S,C])}let Qi=(function(e){return e.open="data-open",e.closed="data-closed",e[e.startingStyle=ju.startingStyle]="startingStyle",e[e.endingStyle=ju.endingStyle]="endingStyle",e.anchorHidden="data-anchor-hidden",e.side="data-side",e.align="data-align",e})({}),RC=(function(e){return e.popupOpen="data-popup-open",e.pressed="data-pressed",e})({});const M7={[RC.popupOpen]:"",[RC.pressed]:""},I7={[Qi.open]:""},P7={[Qi.closed]:""},D7={[Qi.anchorHidden]:""},z7={open(e){return e?M7:null}},ol={open(e){return e?I7:P7},anchorHidden(e){return e?D7:null}},IA=_.createContext(void 0);function L7(){const e=_.useContext(IA);if(e===void 0)throw new Error(yn(70));return e}const U7=_.forwardRef(function(t,n){const{children:s,container:i,className:a,render:l,...f}=t,{portalNode:d,portalSubtree:p}=_A({container:i,ref:n,componentProps:t,elementProps:f});return!p&&!d?null:h.jsxs(_.Fragment,{children:[p,d&&hi.createPortal(s,d)]})}),$7=_.forwardRef(function(t,n){const{keepMounted:s=!1,...i}=t;return ex().useState("mounted")||s?h.jsx(IA.Provider,{value:s,children:h.jsx(U7,{ref:n,...i})}):null}),PA=_.createContext(void 0);function B7(){const e=_.useContext(PA);if(e===void 0)throw new Error(yn(71));return e}const F7=_.createContext(void 0);function DA(){return _.useContext(F7)?.direction??"ltr"}const H7=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:s,placement:i,rects:a,platform:l,elements:f,middlewareData:d}=t,{element:p,padding:g=0,offsetParent:y="real"}=ao(e,t)||{};if(p==null)return{};const b=cA(g),x={x:n,y:s},S=ox(i),w=sx(S),T=await l.getDimensions(p),C=S==="y",O=C?"top":"left",N=C?"bottom":"right",R=C?"clientHeight":"clientWidth",M=a.reference[w]+a.reference[S]-x[S]-a.floating[w],z=x[S]-a.reference[S],j=y==="real"?await l.getOffsetParent?.(p):f.floating;let A=f.floating[R]||a.floating[w];(!A||!await l.isElement?.(j))&&(A=f.floating[R]||a.floating[w]);const P=M/2-z/2,Q=A/2-T[w]/2-1,B=Math.min(b[O],Q),U=Math.min(b[N],Q),Z=B,K=A-T[w]-U,ee=A/2-T[w]/2+P,D=Pv(Z,ee,K),G=!d.arrow&&Si(i)!=null&&ee!==D&&a.reference[w]/2-(ee<Z?B:U)-T[w]/2<0,q=G?ee<Z?ee-Z:ee-K:0;return{[S]:x[S]+q,data:{[S]:D,centerOffset:ee-D-q,...G&&{alignmentOffset:q}},reset:G}}}),q7=(e,t)=>({...H7(e),options:[e,t]}),V7={name:"hide",async fn(e){const{width:t,height:n,x:s,y:i}=e.rects.reference,a=t===0&&n===0&&s===0&&i===0;return{data:{referenceHidden:(await t7().fn(e)).data?.referenceHidden||a}}}},uh={sideX:"left",sideY:"top"},K7={name:"adaptiveOrigin",async fn(e){const{x:t,y:n,rects:{floating:s},elements:{floating:i},platform:a,strategy:l,placement:f}=e,d=un(i),p=d.getComputedStyle(i);if(!(p.transitionDuration!=="0s"&&p.transitionDuration!==""))return{x:t,y:n,data:uh};const y=await a.getOffsetParent?.(i);let b={width:0,height:0};if(l==="fixed"&&d?.visualViewport)b={width:d.visualViewport.width,height:d.visualViewport.height};else if(y===d){const O=Rt(i);b={width:O.documentElement.clientWidth,height:O.documentElement.clientHeight}}else await a.isElement?.(y)&&(b=await a.getDimensions(y));const x=Zn(f);let S=t,w=n;x==="left"&&(S=b.width-(t+s.width)),x==="top"&&(w=b.height-(n+s.height));const T=x==="left"?"right":uh.sideX,C=x==="top"?"bottom":uh.sideY;return{x:S,y:w,data:{sideX:T,sideY:C}}}};function zA(e,t,n){const s=e==="inline-start"||e==="inline-end";return{top:"top",right:s?n?"inline-start":"inline-end":"right",bottom:"bottom",left:s?n?"inline-end":"inline-start":"left"}[t]}function NC(e,t,n){const{rects:s,placement:i}=e;return{side:zA(t,Zn(i),n),align:Si(i)||"center",anchor:{width:s.reference.width,height:s.reference.height},positioner:{width:s.floating.width,height:s.floating.height}}}function LA(e){const{anchor:t,positionMethod:n="absolute",side:s="bottom",sideOffset:i=0,align:a="center",alignOffset:l=0,collisionBoundary:f,collisionPadding:d=5,sticky:p=!1,arrowPadding:g=5,disableAnchorTracking:y=!1,keepMounted:b=!1,floatingRootContext:x,mounted:S,collisionAvoidance:w,shiftCrossAxis:T=!1,nodeId:C,adaptiveOrigin:O,lazyFlip:N=!1,externalTree:R}=e,[M,z]=_.useState(null);!S&&M!==null&&z(null);const j=w.side||"flip",A=w.align||"flip",P=w.fallbackAxisSide||"end",Q=typeof t=="function"?t:void 0,B=Ae(Q),U=Q?B:t,Z=Jo(t),ee=DA()==="rtl",D=M||{top:"top",right:"right",bottom:"bottom",left:"left","inline-end":ee?"left":"right","inline-start":ee?"right":"left"}[s],G=a==="center"?D:`${D}-${a}`;let q=d;const V=1,L=s==="bottom"?V:0,I=s==="top"?V:0,H=s==="right"?V:0,W=s==="left"?V:0;typeof q=="number"?q={top:q+L,right:q+W,bottom:q+I,left:q+H}:q&&(q={top:(q.top||0)+L,right:(q.right||0)+W,bottom:(q.bottom||0)+I,left:(q.left||0)+H});const Y={boundary:f==="clipping-ancestors"?"clippingAncestors":f,padding:q},ae=_.useRef(null),se=Jo(i),fe=Jo(l),Oe=[XK(ot=>{const Wt=NC(ot,s,ee),vn=typeof se.current=="function"?se.current(Wt):se.current,kt=typeof fe.current=="function"?fe.current(Wt):fe.current;return{mainAxis:vn,crossAxis:kt,alignmentAxis:kt}},[typeof i!="function"?i:0,typeof l!="function"?l:0,ee,s])],_e=A==="none"&&j!=="shift",re=!_e&&(p||T||j==="shift"),he=j==="none"?null:JK({...Y,padding:{top:q.top+V,right:q.right+V,bottom:q.bottom+V,left:q.left+V},mainAxis:!T&&j==="flip",crossAxis:A==="flip"?"alignment":!1,fallbackAxisSideDirection:P}),ie=_e?null:QK(ot=>{const Wt=Rt(ot.elements.floating).documentElement;return{...Y,rootBoundary:T?{x:0,y:0,width:Wt.clientWidth,height:Wt.clientHeight}:void 0,mainAxis:A!=="none",crossAxis:re,limiter:p||T?void 0:WK(vn=>{if(!ae.current)return{};const{width:kt,height:Cn}=ae.current.getBoundingClientRect(),er=Fr(Zn(vn.placement)),An=er==="y"?kt:Cn,as=er==="y"?q.left+q.right:q.top+q.bottom;return{offset:An/2+as/2}})}},[Y,p,T,q,A]);j==="shift"||A==="shift"||a==="center"?Oe.push(ie,he):Oe.push(he,ie),Oe.push(e7({...Y,apply({elements:{floating:ot},rects:{reference:Wt},availableWidth:vn,availableHeight:kt}){const Cn=ot.style;Cn.setProperty("--available-width",`${vn}px`),Cn.setProperty("--available-height",`${kt}px`),Cn.setProperty("--anchor-width",`${Wt.width}px`),Cn.setProperty("--anchor-height",`${Wt.height}px`)}}),q7(()=>({element:ae.current||document.createElement("div"),padding:g,offsetParent:"floating"}),[g]),{name:"transformOrigin",fn(ot){const{elements:Wt,middlewareData:vn,placement:kt,rects:Cn,y:er}=ot,An=Zn(kt),as=Fr(An),cs=ae.current,_a=vn.arrow?.x||0,wi=vn.arrow?.y||0,Ei=cs?.clientWidth||0,ws=cs?.clientHeight||0,tr=_a+Ei/2,ls=wi+ws/2,fo=Math.abs(vn.shift?.y||0),ho=Cn.reference.height/2,nr=typeof i=="function"?i(NC(ot,s,ee)):i,al=fo>nr,af={top:`${tr}px calc(100% + ${nr}px)`,bottom:`${tr}px ${-nr}px`,left:`calc(100% + ${nr}px) ${ls}px`,right:`${-nr}px ${ls}px`}[An],cf=`${tr}px ${Cn.reference.y+ho-er}px`;return Wt.floating.style.setProperty("--transform-origin",re&&as==="y"&&al?cf:af),{}}},V7,O),Le(()=>{!S&&x&&x.update({referenceElement:null,floatingElement:null,domReferenceElement:null})},[S,x]);const we=_.useMemo(()=>({elementResize:!y&&typeof ResizeObserver<"u",layoutShift:!y&&typeof IntersectionObserver<"u"}),[y]),{refs:ye,elements:xe,x:ve,y:Ie,middlewareData:Ue,update:Ee,placement:Ve,context:Qe,isPositioned:Be,floatingStyles:We}=_7({rootContext:x,placement:G,middleware:Oe,strategy:n,whileElementsMounted:b?void 0:(...ot)=>wC(...ot,we),nodeId:C,externalTree:R}),{sideX:He,sideY:me}=Ue.adaptiveOrigin||uh,Te=Be?n:"fixed",qe=_.useMemo(()=>{const ot=O?{position:Te,[He]:ve,[me]:Ie}:{position:Te,...We};return Be||(ot.opacity=0),ot},[O,Te,He,ve,me,Ie,We,Be]),mt=_.useRef(null);Le(()=>{if(!S)return;const ot=Z.current,Wt=typeof ot=="function"?ot():ot,kt=(jC(Wt)?Wt.current:Wt)||null||null;kt!==mt.current&&(ye.setPositionReference(kt),mt.current=kt)},[S,ye,U,Z]),_.useEffect(()=>{if(!S)return;const ot=Z.current;typeof ot!="function"&&jC(ot)&&ot.current!==mt.current&&(ye.setPositionReference(ot.current),mt.current=ot.current)},[S,ye,U,Z]),_.useEffect(()=>{if(b&&S&&xe.domReference&&xe.floating)return wC(xe.domReference,xe.floating,Ee,we)},[b,S,xe,Ee,we]);const lt=Zn(Ve),wr=zA(s,lt,ee),Er=Si(Ve)||"center",Qt=!!Ue.hide?.referenceHidden;Le(()=>{N&&S&&Be&&z(lt)},[N,S,Be,lt]);const ut=_.useMemo(()=>({position:"absolute",top:Ue.arrow?.y,left:Ue.arrow?.x}),[Ue.arrow]),xt=Ue.arrow?.centerOffset!==0;return _.useMemo(()=>({positionerStyles:qe,arrowStyles:ut,arrowRef:ae,arrowUncentered:xt,side:wr,align:Er,physicalSide:lt,anchorHidden:Qt,refs:ye,context:Qe,isPositioned:Be,update:Ee}),[qe,ut,ae,xt,wr,Er,lt,Qt,ye,Qe,Be,Ee])}function jC(e){return e!=null&&"current"in e}function Np(e){return e==="starting"?Z9:an}const G7=_.forwardRef(function(t,n){const{render:s,className:i,anchor:a,positionMethod:l="absolute",side:f="top",align:d="center",sideOffset:p=0,alignOffset:g=0,collisionBoundary:y="clipping-ancestors",collisionPadding:b=5,arrowPadding:x=5,sticky:S=!1,disableAnchorTracking:w=!1,collisionAvoidance:T=Q9,...C}=t,O=ex(),N=L7(),R=O.useState("open"),M=O.useState("mounted"),z=O.useState("trackCursorAxis"),j=O.useState("disableHoverablePopup"),A=O.useState("floatingRootContext"),P=O.useState("instantType"),Q=O.useState("transitionStatus"),B=O.useState("hasViewport"),U=LA({anchor:a,positionMethod:l,floatingRootContext:A,mounted:M,side:f,sideOffset:p,align:d,alignOffset:g,collisionBoundary:y,collisionPadding:b,sticky:S,arrowPadding:x,disableAnchorTracking:w,keepMounted:N,collisionAvoidance:T,adaptiveOrigin:B?K7:void 0}),Z=_.useMemo(()=>{const G={};return(!R||z==="both"||j)&&(G.pointerEvents="none"),{role:"presentation",hidden:!M,style:{...U.positionerStyles,...G}}},[R,z,j,M,U.positionerStyles]),K=_.useMemo(()=>({open:R,side:U.side,align:U.align,anchorHidden:U.anchorHidden,instant:z!=="none"?"tracking-cursor":P}),[R,U.side,U.align,U.anchorHidden,z,P]),ee=_.useMemo(()=>({...K,arrowRef:U.arrowRef,arrowStyles:U.arrowStyles,arrowUncentered:U.arrowUncentered}),[K,U.arrowRef,U.arrowStyles,U.arrowUncentered]),D=zt("div",t,{state:K,props:[Z,Np(Q),C],ref:[n,O.useStateSetter("positionerElement")],stateAttributesMapping:ol});return h.jsx(PA.Provider,{value:ee,children:D})}),Z7={...ol,...ba},Y7=_.forwardRef(function(t,n){const{className:s,render:i,...a}=t,l=ex(),{side:f,align:d}=B7(),p=l.useState("open"),g=l.useState("instantType"),y=l.useState("transitionStatus"),b=l.useState("popupProps"),x=l.useState("floatingRootContext");xa({open:p,ref:l.context.popupRef,onComplete(){p&&l.context.onOpenChangeComplete?.(!0)}});const S=l.useState("disabled"),w=l.useState("closeDelay");return N7(x,{enabled:!S,closeDelay:w}),zt("div",t,{state:{open:p,side:f,align:d,instant:g,transitionStatus:y},ref:[n,l.context.popupRef,l.useStateSetter("popupElement")],props:[b,Np(y),a],stateAttributesMapping:Z7})});function dx(e){return Kb(19)?e:e?"true":void 0}const X7=_.forwardRef(({className:e,sideOffset:t=4,children:n,...s},i)=>h.jsx($7,{children:h.jsx(G7,{sideOffset:t,children:h.jsx(Y7,{ref:i,className:ge("bg-[#1e1e1e] border border-neutral-700 rounded-md px-2.5 py-1.5 text-xs text-neutral-300 font-mono shadow-lg",e),...s,children:n})})}));X7.displayName="TooltipContent";function AC(e){return e==="online"?"#22c55e":e==="syncing"?"#f59e0b":"#ef4444"}const UA=_.forwardRef(({className:e,clients:t,positions:n,relayClientIds:s=[],serverPosition:i={x:420,y:190},relayPosition:a={x:780,y:190},viewBox:l={width:1200,height:380},totalNodes:f,onlineCount:d,offlineCount:p,...g},y)=>{const b=i.x,x=i.y,S=a.x,w=a.y,T={},C=2*Math.PI/Math.max(t.length,1);t.forEach((j,A)=>{const P=s.includes(j.id),Q=P?S:b,B=P?w:x,U=P?240:260,Z=P?130:150,K=C*A-Math.PI/2;T[j.id]={x:Q+U*Math.cos(K),y:B+Z*Math.sin(K)}});const O={};if(n)for(const j of n)O[j.clientId]={x:j.x,y:j.y};function N(j){return O[j]??T[j]??{x:600,y:190}}const R=f??t.length+2,M=d??t.filter(j=>j.status!=="offline").length,z=p??t.filter(j=>j.status==="offline").length;return h.jsxs("div",{ref:y,className:ge("relative overflow-hidden","bg-[radial-gradient(ellipse_at_35%_50%,rgba(59,130,246,0.06)_0%,transparent_50%),radial-gradient(ellipse_at_68%_50%,rgba(139,92,246,0.04)_0%,transparent_40%),#0c0c0c]","bg-[image:radial-gradient(circle_at_1px_1px,#1a1a1a_1px,transparent_0)] bg-[size:24px_24px]",e),style:{height:420},...g,children:[h.jsx("div",{className:"absolute left-0 right-0 h-px bg-[linear-gradient(90deg,transparent,rgba(59,130,246,0.3),transparent)] animate-[scanSweep_6s_ease-in-out_infinite] pointer-events-none"}),h.jsx("div",{className:"absolute top-4 left-5 z-10",children:h.jsx("span",{className:"font-mono text-[10px] text-neutral-500 uppercase tracking-widest",children:"Sync Topology"})}),h.jsxs("div",{className:"absolute top-4 right-5 z-10 flex items-center gap-3",children:[h.jsxs("span",{className:"font-mono text-[10px] text-neutral-600",children:[R," nodes"]}),h.jsx("span",{className:"font-mono text-[10px] text-neutral-600",children:"·"}),h.jsxs("span",{className:"font-mono text-[10px] text-healthy",children:[M," online"]}),h.jsx("span",{className:"font-mono text-[10px] text-neutral-600",children:"·"}),h.jsxs("span",{className:"font-mono text-[10px] text-offline",children:[z," offline"]})]}),h.jsxs("svg",{viewBox:`0 0 ${l.width} ${l.height}`,className:"w-full h-full",preserveAspectRatio:"xMidYMid meet",children:[h.jsx("ellipse",{cx:b,cy:x,rx:280,ry:160,fill:"none",stroke:"#1a1a1a",strokeWidth:.5,strokeDasharray:"6 10"}),h.jsx("ellipse",{cx:S,cy:w,rx:260,ry:140,fill:"none",stroke:"#1a1a1a",strokeWidth:.5,strokeDasharray:"6 10"}),h.jsx("line",{x1:b,y1:x,x2:S,y2:w,stroke:"#8b5cf6",strokeWidth:2,opacity:.3}),h.jsx("line",{x1:b,y1:x,x2:S,y2:w,stroke:"#8b5cf6",strokeWidth:1,strokeDasharray:"4 2",opacity:.6,children:h.jsx("animate",{attributeName:"stroke-dashoffset",from:"20",to:"0",dur:"1s",repeatCount:"indefinite"})}),h.jsxs("circle",{r:3,fill:"#8b5cf6",opacity:.8,children:[h.jsx("animateMotion",{dur:"2.5s",repeatCount:"indefinite",path:`M${b},${x} L${S},${w}`}),h.jsx("animate",{attributeName:"opacity",values:"0;0.8;0.8;0",dur:"2.5s",repeatCount:"indefinite"})]}),h.jsxs("circle",{r:3,fill:"#8b5cf6",opacity:.8,children:[h.jsx("animateMotion",{dur:"2.5s",begin:"1.25s",repeatCount:"indefinite",path:`M${S},${w} L${b},${x}`}),h.jsx("animate",{attributeName:"opacity",values:"0;0.8;0.8;0",dur:"2.5s",begin:"1.25s",repeatCount:"indefinite"})]}),h.jsx("text",{x:(b+S)/2,y:x-20,textAnchor:"middle",fill:"#8b5cf6",fontFamily:"JetBrains Mono, monospace",fontSize:8,opacity:.4,letterSpacing:2,children:"BACKBONE"}),t.map(j=>{const A=N(j.id),P=s.includes(j.id),Q=P?S:b,B=P?w:x,U=AC(j.status),Z=j.status==="syncing"?2.5:1.5;if(j.status==="offline")return h.jsx("line",{x1:Q,y1:B,x2:A.x,y2:A.y,stroke:U,strokeWidth:1,strokeDasharray:"3 6",opacity:.2},`line-${j.id}`);const K=j.status==="syncing"?"1.2s":"2.8s",ee=`${Number.parseFloat(K)/2}s`;return h.jsxs("g",{children:[h.jsx("line",{x1:Q,y1:B,x2:A.x,y2:A.y,stroke:U,strokeWidth:Z,strokeDasharray:"4 2",children:h.jsx("animate",{attributeName:"stroke-dashoffset",from:"20",to:"0",dur:"1s",repeatCount:"indefinite"})}),h.jsxs("circle",{r:2.5,fill:U,opacity:.7,children:[h.jsx("animateMotion",{dur:K,repeatCount:"indefinite",path:`M${Q},${B} L${A.x},${A.y}`}),h.jsx("animate",{attributeName:"opacity",values:"0;0.7;0.7;0",dur:K,repeatCount:"indefinite"})]}),h.jsxs("circle",{r:2,fill:U,opacity:.5,children:[h.jsx("animateMotion",{dur:K,begin:ee,repeatCount:"indefinite",path:`M${A.x},${A.y} L${Q},${B}`}),h.jsx("animate",{attributeName:"opacity",values:"0;0.5;0.5;0",dur:K,begin:ee,repeatCount:"indefinite"})]})]},`line-${j.id}`)}),h.jsxs("circle",{cx:b,cy:x,r:50,fill:"none",stroke:"#3b82f6",strokeWidth:.5,opacity:.15,children:[h.jsx("animate",{attributeName:"r",from:"32",to:"60",dur:"3s",repeatCount:"indefinite"}),h.jsx("animate",{attributeName:"opacity",from:"0.25",to:"0",dur:"3s",repeatCount:"indefinite"})]}),h.jsxs("circle",{cx:b,cy:x,r:50,fill:"none",stroke:"#3b82f6",strokeWidth:.5,opacity:.15,children:[h.jsx("animate",{attributeName:"r",from:"32",to:"60",dur:"3s",begin:"1.5s",repeatCount:"indefinite"}),h.jsx("animate",{attributeName:"opacity",from:"0.25",to:"0",dur:"3s",begin:"1.5s",repeatCount:"indefinite"})]}),h.jsx("circle",{cx:b,cy:x,r:32,fill:"#0c0c0c",stroke:"#3b82f6",strokeWidth:2,style:{filter:"drop-shadow(0 0 12px rgba(59,130,246,0.4))"}}),h.jsx("circle",{cx:b,cy:x,r:16,fill:"rgba(59,130,246,0.12)",stroke:"#3b82f6",strokeWidth:.8}),h.jsx("circle",{cx:b,cy:x,r:6,fill:"#3b82f6"}),h.jsx("text",{x:b,y:x+48,textAnchor:"middle",fill:"#444",fontFamily:"JetBrains Mono, monospace",fontSize:9,letterSpacing:2.5,children:"SERVER"}),h.jsxs("circle",{cx:S,cy:w,r:40,fill:"none",stroke:"#8b5cf6",strokeWidth:.5,opacity:.15,children:[h.jsx("animate",{attributeName:"r",from:"26",to:"48",dur:"3.5s",repeatCount:"indefinite"}),h.jsx("animate",{attributeName:"opacity",from:"0.2",to:"0",dur:"3.5s",repeatCount:"indefinite"})]}),h.jsx("circle",{cx:S,cy:w,r:26,fill:"#0c0c0c",stroke:"#8b5cf6",strokeWidth:2,style:{filter:"drop-shadow(0 0 10px rgba(139,92,246,0.35))"}}),h.jsx("circle",{cx:S,cy:w,r:13,fill:"rgba(139,92,246,0.12)",stroke:"#8b5cf6",strokeWidth:.8}),h.jsx("circle",{cx:S,cy:w,r:5,fill:"#8b5cf6"}),h.jsx("text",{x:S,y:w+42,textAnchor:"middle",fill:"#444",fontFamily:"JetBrains Mono, monospace",fontSize:9,letterSpacing:2.5,children:"RELAY"}),t.map(j=>{const A=N(j.id),P=AC(j.status),Q=j.status==="offline"?.25:1,B=j.actor.replace("user-","").replace("svc-",""),U=s.includes(j.id);return h.jsxs("g",{opacity:Q,children:[h.jsx("circle",{cx:A.x,cy:A.y,r:20,fill:"#0c0c0c",stroke:P,strokeWidth:1.5}),h.jsx("circle",{cx:A.x,cy:A.y,r:5,fill:P}),h.jsx("text",{x:A.x,y:A.y+32,textAnchor:"middle",fill:"#555",fontFamily:"JetBrains Mono, monospace",fontSize:9,children:B}),h.jsxs("text",{x:A.x,y:A.y+42,textAnchor:"middle",fill:"#333",fontFamily:"JetBrains Mono, monospace",fontSize:7,children:[j.type,U?" · relay":""]})]},`node-${j.id}`)})]})]})});UA.displayName="TopologyHero";let kC=(function(e){return e.checked="data-checked",e.unchecked="data-unchecked",e.indeterminate="data-indeterminate",e.disabled="data-disabled",e.readonly="data-readonly",e.required="data-required",e.valid="data-valid",e.invalid="data-invalid",e.touched="data-touched",e.dirty="data-dirty",e.filled="data-filled",e.focused="data-focused",e})({});function $A(e){return _.useMemo(()=>({checked(t){return e.indeterminate?{}:t?{[kC.checked]:""}:{[kC.unchecked]:""}},...bi}),[e.indeterminate])}const Q7=_.createContext({disabled:!1});function W7(){return _.useContext(Q7)}const J7=_.createContext(void 0);function eG(e=!0){const t=_.useContext(J7);if(t===void 0&&!e)throw new Error(yn(3));return t}const BA=_.createContext(void 0);function tG(){const e=_.useContext(BA);if(e===void 0)throw new Error(yn(14));return e}const nG="data-parent",rG=_.forwardRef(function(t,n){const{checked:s,className:i,defaultChecked:a=!1,disabled:l=!1,id:f,indeterminate:d=!1,inputRef:p,name:g,onCheckedChange:y,parent:b=!1,readOnly:x=!1,render:S,required:w=!1,uncheckedValue:T,value:C,nativeButton:O=!1,...N}=t,{clearErrors:R}=el(),{disabled:M,name:z,setDirty:j,setFilled:A,setFocused:P,setTouched:Q,state:B,validationMode:U,validityData:Z,shouldValidateOnChange:K,validation:ee}=xi(),D=W7(),{labelId:G,controlId:q,registerControlId:V,getDescriptionProps:L}=lo(),I=eG(),H=I?.parent,W=H&&I.allValues,Y=M||D.disabled||I?.disabled||l,ae=z??g,se=C??ae,fe=br(),Se=br();let pe=q;W?pe=b?Se:`${H.id}-${se}`:f&&(pe=f);let Oe={};W&&(b?Oe=I.parent.getParentProps():se&&(Oe=I.parent.getChildProps(se)));const _e=Ae(y),{checked:re=s,indeterminate:he=d,onCheckedChange:ie,...we}=Oe,ye=I?.value,xe=I?.setValue,ve=I?.defaultValue,Ie=_.useRef(null),Ue=zn(()=>Symbol("checkbox-control")),Ee=_.useRef(!1),{getButtonProps:Ve,buttonRef:Qe}=Jc({disabled:Y,native:O}),Be=I?.validation??ee,[We,He]=pp({controlled:se&&ye&&!b?ye.includes(se):re,default:se&&ve&&!b?ve.includes(se):a,name:"Checkbox",state:"checked"});Le(()=>{V!==jn&&(Ee.current=!0,V(Ue.current,pe))},[pe,I,V,b,Ue]),_.useEffect(()=>{const ut=Ue.current;return()=>{!Ee.current||V===jn||(Ee.current=!1,V(ut,void 0))}},[V,Ue]),Ij({enabled:!I,id:fe,commit:Be.commit,value:We,controlRef:Ie,name:ae,getValue:()=>We});const me=_.useRef(null),Te=oo(p,me,Be.inputRef);Le(()=>{me.current&&(me.current.indeterminate=he,We&&A(!0))},[We,he,A]),Uj(We,()=>{I&&!b||(R(ae),A(We),j(We!==Z.initialValue),K()?Be.commit(We):Be.commit(We,!0))});const qe=oi({checked:We,disabled:Y,name:b?void 0:ae,id:O?void 0:pe??void 0,required:w,ref:Te,style:ae?Tj:mp,tabIndex:-1,type:"checkbox","aria-hidden":!0,onChange(ut){if(ut.nativeEvent.defaultPrevented)return;const xt=ut.target.checked,ot=Yt(ii,ut.nativeEvent);if(ie?.(xt,ot),_e(xt,ot),!ot.isCanceled&&(He(xt),se&&ye&&xe&&!b)){const Wt=xt?[...ye,se]:ye.filter(vn=>vn!==se);xe(Wt,ot)}},onFocus(){Ie.current?.focus()}},C!==void 0?{value:(I?We&&C:C)||""}:an,L,I?Be.getValidationProps:Be.getInputValidationProps),mt=W?!!re:We,lt=W&&he||d;_.useEffect(()=>{if(!H||!se)return;const ut=H.disabledStatesRef.current;return ut.set(se,Y),()=>{ut.delete(se)}},[H,Y,se]);const wr=_.useMemo(()=>({...B,checked:mt,disabled:Y,readOnly:x,required:w,indeterminate:lt}),[B,mt,Y,x,w,lt]),Er=$A(wr),Qt=zt("span",t,{state:wr,ref:[Qe,Ie,n,I?.registerControlRef],props:[{id:O?pe??void 0:fe,role:"checkbox","aria-checked":he?"mixed":We,"aria-readonly":x||void 0,"aria-required":w||void 0,"aria-labelledby":G,[nG]:b?"":void 0,onFocus(){P(!0)},onBlur(){const ut=me.current;ut&&(Q(!0),P(!1),U==="onBlur"&&Be.commit(I?ye:ut.checked))},onClick(ut){x||Y||(ut.preventDefault(),me.current?.dispatchEvent(new PointerEvent("click",{bubbles:!0,shiftKey:ut.shiftKey,ctrlKey:ut.ctrlKey,altKey:ut.altKey,metaKey:ut.metaKey})))}},L,Be.getValidationProps,N,we,Ve],stateAttributesMapping:Er});return h.jsxs(BA.Provider,{value:wr,children:[Qt,!We&&!I&&ae&&!b&&T!==void 0&&h.jsx("input",{type:"hidden",name:ae,value:T}),h.jsx("input",{...qe})]})}),sG=_.forwardRef(function(t,n){const{render:s,className:i,keepMounted:a=!1,...l}=t,f=tG(),d=f.checked||f.indeterminate,{mounted:p,transitionStatus:g,setMounted:y}=Rp(d),b=_.useRef(null),x={...f,transitionStatus:g};xa({open:d,ref:b,onComplete(){d||y(!1)}});const S=$A(f),w=_.useMemo(()=>({...S,...ba,...bi}),[S]),T=a||p,C=zt("span",t,{ref:[n,b],state:x,stateAttributesMapping:w,props:l});return T?C:null}),Uv=_.forwardRef(({className:e,label:t,...n},s)=>{const i=h.jsx(rG,{ref:s,className:ge("w-[15px] h-[15px] border-[1.5px] border-neutral-700 rounded-full flex items-center justify-center cursor-pointer transition-all duration-200","data-[checked]:bg-healthy data-[checked]:border-healthy data-[checked]:shadow-[0_0_6px_rgba(34,197,94,0.3)]",e),...n,children:h.jsx(sG,{className:"flex items-center justify-center text-white",children:h.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:h.jsx("path",{d:"M1.5 4L3.25 5.75L6.5 2.25",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})});return t?h.jsxs("span",{className:"inline-flex items-center gap-2 cursor-pointer font-mono text-[11px] text-neutral-400",children:[i,h.jsx("span",{children:t})]}):i});Uv.displayName="Checkbox";const oG=_.createContext({legendId:void 0,setLegendId:()=>{},disabled:void 0});function iG(e=!1){const t=_.useContext(oG);if(!t&&!e)throw new Error(yn(86));return t}const aG=function(t){const n=br(),[s,i]=_.useState(t.initialControlId===void 0?n:t.initialControlId),[a,l]=_.useState(void 0),[f,d]=_.useState([]),p=zn(()=>new Map),{messageIds:g}=lo(),y=Ae((S,w)=>{const T=p.current;if(w===void 0){T.delete(S);return}T.set(S,w),i(C=>{if(T.size===0)return;let O;for(const N of T.values()){if(C!==void 0&&N===C)return C;O===void 0&&(O=N)}return O})}),b=_.useCallback(S=>oi({"aria-describedby":g.concat(f).join(" ")||void 0},S),[g,f]),x=_.useMemo(()=>({controlId:s,registerControlId:y,labelId:a,setLabelId:l,messageIds:f,setMessageIds:d,getDescriptionProps:b}),[s,y,a,l,f,d,b]);return h.jsx(Pj.Provider,{value:x,children:t.children})},fh=Object.keys(xp);function cG(e){if(!e||e.valid||!e.valueMissing)return!1;let t=!1;for(const n of fh)n!=="valid"&&(n==="valueMissing"&&(t=e[n]),e[n]&&(t=!1));return t}function lG(e){const{formRef:t,clearErrors:n}=el(),{setValidityData:s,validate:i,validityData:a,validationDebounceTime:l,invalid:f,markedDirtyRef:d,state:p,name:g,shouldValidateOnChange:y}=e,{controlId:b,getDescriptionProps:x}=lo(),S=ns(),w=_.useRef(null),T=Ae(async(N,R=!1)=>{const M=w.current;if(!M)return;if(R){if(p.valid!==!1)return;const Z=M.validity;if(!Z.valueMissing){const ee={value:N,state:{...xp,valid:!0},error:"",errors:[],initialValue:a.initialValue};if(M.setCustomValidity(""),b){const D=t.current.fields.get(b);D&&t.current.fields.set(b,{...D,...kv(ee,!1)})}s(ee);return}const K=fh.reduce((ee,D)=>(ee[D]=Z[D],ee),{});if(!K.valid&&!cG(K))return}function z(Z){const K=fh.reduce((D,G)=>(D[G]=Z.validity[G],D),{});let ee=!1;for(const D of fh)if(D!=="valid"){if(D==="valueMissing"&&K[D])ee=!0;else if(K[D])return K}return ee&&!d.current&&(K.valid=!0,K.valueMissing=!1),K}S.clear();let j=null,A=[];const P=z(M);let Q;const B=y();if(M.validationMessage&&!B)Q=M.validationMessage,A=[M.validationMessage];else{const Z=Array.from(t.current.fields.values()).reduce((ee,D)=>(D.name&&(ee[D.name]=D.getValue()),ee),{}),K=i(N,Z);typeof K=="object"&&K!==null&&"then"in K?j=await K:j=K,j!==null?(P.valid=!1,P.customError=!0,Array.isArray(j)?(A=j,M.setCustomValidity(j.join(`
|
|
75
|
+
`))):j&&(A=[j],M.setCustomValidity(j))):B&&(M.setCustomValidity(""),P.customError=!1,M.validationMessage?(Q=M.validationMessage,A=[M.validationMessage]):M.validity.valid&&!P.valid&&(P.valid=!0))}const U={value:N,state:P,error:Q??(Array.isArray(j)?j[0]:j??""),errors:A,initialValue:a.initialValue};if(b){const Z=t.current.fields.get(b);Z&&t.current.fields.set(b,{...Z,...kv(U,f)})}s(U)}),C=_.useCallback((N={})=>oi(x,p.valid===!1?{"aria-invalid":!0}:an,N),[x,p.valid]),O=_.useCallback((N={})=>oi({onChange(R){if(R.nativeEvent.defaultPrevented)return;if(n(g),!y()){T(R.currentTarget.value,!0);return}if(f)return;const M=R.currentTarget;if(M.value===""){T(M.value);return}S.clear(),l?S.start(l,()=>{T(M.value)}):T(M.value)}},C(N)),[C,n,g,S,T,f,l,y]);return _.useMemo(()=>({getValidationProps:C,getInputValidationProps:O,inputRef:w,commit:T}),[C,O,T])}const uG=_.forwardRef(function(t,n){const{errors:s,validationMode:i,submitAttemptedRef:a}=el(),{render:l,className:f,validate:d,validationDebounceTime:p=0,validationMode:g=i,name:y,disabled:b=!1,invalid:x,dirty:S,touched:w,actionsRef:T,...C}=t,{disabled:O}=iG(),N=Ae(d||(()=>null)),R=O||b,[M,z]=_.useState(!1),[j,A]=_.useState(!1),[P,Q]=_.useState(!1),[B,U]=_.useState(!1),Z=S??j,K=w??M,ee=_.useRef(!1),D=Ae(Se=>{S===void 0&&(Se&&(ee.current=!0),A(Se))}),G=Ae(Se=>{w===void 0&&z(Se)}),q=Ae(()=>g==="onChange"||g==="onSubmit"&&a.current),V=!!(x||y&&{}.hasOwnProperty.call(s,y)&&s[y]!==void 0),[L,I]=_.useState({state:xp,error:"",errors:[],value:null,initialValue:null}),H=!V&&L.state.valid,W=_.useMemo(()=>({disabled:R,touched:K,dirty:Z,valid:H,filled:P,focused:B}),[R,K,Z,H,P,B]),Y=lG({setValidityData:I,validate:N,validityData:L,validationDebounceTime:p,invalid:V,markedDirtyRef:ee,state:W,name:y,shouldValidateOnChange:q}),ae=_.useCallback(()=>{ee.current=!0,Y.commit(L.value)},[Y,L]);_.useImperativeHandle(T,()=>({validate:ae}),[ae]);const se=_.useMemo(()=>({invalid:V,name:y,validityData:L,setValidityData:I,disabled:R,touched:K,setTouched:G,dirty:Z,setDirty:D,filled:P,setFilled:Q,focused:B,setFocused:U,validate:N,validationMode:g,validationDebounceTime:p,shouldValidateOnChange:q,state:W,markedDirtyRef:ee,validation:Y}),[V,y,L,R,K,G,Z,D,P,Q,B,U,N,g,p,q,W,Y]),fe=zt("div",t,{ref:n,state:W,props:C,stateAttributesMapping:bi});return h.jsx(Mj.Provider,{value:se,children:fe})}),fG=_.forwardRef(function(t,n){return h.jsx(aG,{children:h.jsx(uG,{...t,ref:n})})}),dG=_.forwardRef(function(t,n){const{render:s,className:i,id:a,nativeLabel:l=!0,...f}=t,d=xi(!1),{controlId:p,setLabelId:g,labelId:y}=lo(),b=br(a),x=_.useRef(null),S=Ae(T=>{if(Ur(T.nativeEvent)?.closest("button,input,select,textarea")||(!T.defaultPrevented&&T.detail>1&&T.preventDefault(),l||!p))return;const O=Rt(T.currentTarget).getElementById(p);Zt(O)&&O.focus({focusVisible:!0})});return Le(()=>(b&&g(b),()=>{g(void 0)}),[b,g]),zt("label",t,{ref:[n,x],state:d.state,props:[{id:y},l?{htmlFor:p??void 0,onMouseDown:S}:{onClick:S,onPointerDown(T){T.preventDefault()}},f],stateAttributesMapping:bi})}),hG={...bi,...ba},pG=_.forwardRef(function(t,n){const{render:s,id:i,className:a,match:l,...f}=t,d=br(i),{validityData:p,state:g,name:y}=xi(!1),{setMessageIds:b}=lo(),{errors:x}=el(),S=y?x[y]:null;let w=!1;S||l===!0?w=!0:l?w=!!p.state[l]:w=p.state.valid===!1;const{mounted:T,transitionStatus:C,setMounted:O}=Rp(w);Le(()=>{if(!(!w||!d))return b(U=>U.concat(d)),()=>{b(U=>U.filter(Z=>Z!==d))}},[w,d,b]);const N=_.useRef(null),[R,M]=_.useState(null),[z,j]=_.useState(null),A=S||(p.errors.length>1?h.jsx("ul",{children:p.errors.map(U=>h.jsx("li",{children:U},U))}):p.error);let P=p.error;S!=null?P=Array.isArray(S)?JSON.stringify(S):S:p.errors.length>1&&(P=JSON.stringify(p.errors)),w&&P!==z&&(j(P),M(A)),xa({open:w,ref:N,onComplete(){w||O(!1)}});const Q={...g,transitionStatus:C},B=zt("div",t,{ref:[n,N],state:Q,props:[{id:d,children:w?A:R},f],stateAttributesMapping:hG,enabled:T});return T?B:null}),mG=_.forwardRef(function(t,n){const{render:s,id:i,className:a,...l}=t,f=br(i),d=xi(!1),{setMessageIds:p}=lo();return Le(()=>{if(f)return p(y=>y.concat(f)),()=>{p(y=>y.filter(b=>b!==f))}},[f,p]),zt("p",t,{ref:n,state:d.state,props:[{id:f},l],stateAttributesMapping:bi})}),ms=fG,es=_.forwardRef(({className:e,...t},n)=>h.jsx(dG,{ref:n,className:ge("font-mono text-[9px] text-neutral-500 uppercase tracking-wider block mb-1.5",e),...t}));es.displayName="FieldLabel";const pc=_.forwardRef(({className:e,...t},n)=>h.jsx(mG,{ref:n,className:ge("font-mono text-[9px] text-neutral-600 mt-0.5",e),...t}));pc.displayName="FieldDescription";const gG=_.forwardRef(({className:e,...t},n)=>h.jsx(pG,{ref:n,className:ge("font-mono text-[10px] text-offline mt-1",e),...t}));gG.displayName="FieldError";const yG=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge(e),...t}));yG.displayName="FieldContent";const vG=_.createContext(null),bG=_.createContext(null);function Wu(){const e=_.useContext(vG);if(e===null)throw new Error(yn(60));return e}function FA(){const e=_.useContext(bG);if(e===null)throw new Error(yn(61));return e}function $c(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function xG(e,t,n){return!e||e.length===0?!1:e.some(s=>s===void 0?!1:$c(t,s,n))}function zy(e,t,n){return!e||e.length===0?-1:e.findIndex(s=>s===void 0?!1:$c(s,t,n))}function SG(e,t,n){return e.filter(s=>!$c(t,s,n))}function OC(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function _G(e){return e!=null&&e.length>0&&typeof e[0]=="object"&&e[0]!=null&&"items"in e[0]}function wG(e){if(!Array.isArray(e))return e!=null&&!("null"in e);if(_G(e)){for(const t of e)for(const n of t.items)if(n&&n.value==null&&n.label!=null)return!0;return!1}for(const t of e)if(t&&t.value==null&&t.label!=null)return!0;return!1}function EG(e,t){return t&&e!=null?t(e)??"":e&&typeof e=="object"&&"value"in e&&"label"in e?OC(e.value):OC(e)}const it={id:Pe(e=>e.id),modal:Pe(e=>e.modal),multiple:Pe(e=>e.multiple),items:Pe(e=>e.items),itemToStringLabel:Pe(e=>e.itemToStringLabel),itemToStringValue:Pe(e=>e.itemToStringValue),isItemEqualToValue:Pe(e=>e.isItemEqualToValue),value:Pe(e=>e.value),hasSelectedValue:Pe(e=>{const{value:t,multiple:n,itemToStringValue:s}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:EG(t,s)!==""}),hasNullItemLabel:Pe((e,t)=>t?wG(e.items):!1),open:Pe(e=>e.open),mounted:Pe(e=>e.mounted),forceMount:Pe(e=>e.forceMount),transitionStatus:Pe(e=>e.transitionStatus),openMethod:Pe(e=>e.openMethod),activeIndex:Pe(e=>e.activeIndex),selectedIndex:Pe(e=>e.selectedIndex),isActive:Pe((e,t)=>e.activeIndex===t),isSelected:Pe((e,t,n)=>{const s=e.isItemEqualToValue,i=e.value;return e.multiple?Array.isArray(i)&&i.some(a=>$c(n,a,s)):e.selectedIndex===t&&e.selectedIndex!==null?!0:$c(n,i,s)}),isSelectedByFocus:Pe((e,t)=>e.selectedIndex===t),popupProps:Pe(e=>e.popupProps),triggerProps:Pe(e=>e.triggerProps),triggerElement:Pe(e=>e.triggerElement),positionerElement:Pe(e=>e.positionerElement),listElement:Pe(e=>e.listElement),scrollUpArrowVisible:Pe(e=>e.scrollUpArrowVisible),scrollDownArrowVisible:Pe(e=>e.scrollDownArrowVisible),hasScrollArrows:Pe(e=>e.hasScrollArrows)};function TG(e){const t=_.useRef(""),n=_.useCallback(i=>{i.defaultPrevented||(t.current=i.pointerType,e(i,i.pointerType))},[e]);return{onClick:_.useCallback(i=>{if(i.detail===0){e(i,"keyboard");return}"pointerType"in i?e(i,i.pointerType):e(i,t.current),t.current=""},[e]),onPointerDown:n}}function CG(e){const[t,n]=_.useState(null),s=Ae((f,d)=>{e||n(d||(rA?"touch":""))}),i=_.useCallback(()=>{n(null)},[]),{onClick:a,onPointerDown:l}=TG(s);return _.useMemo(()=>({openMethod:t,reset:i,triggerProps:{onClick:a,onPointerDown:l}}),[t,i,a,l])}function RG(e){const t=e.getBoundingClientRect(),n=window.getComputedStyle(e,"::before"),s=window.getComputedStyle(e,"::after");if(!(n.content!=="none"||s.content!=="none"))return t;const a=parseFloat(n.width)||0,l=parseFloat(n.height)||0,f=parseFloat(s.width)||0,d=parseFloat(s.height)||0,p=Math.max(t.width,a,f),g=Math.max(t.height,l,d),y=p-t.width,b=g-t.height;return{left:t.left-y/2,right:t.right+y/2,top:t.top-b/2,bottom:t.bottom+b/2}}const qd=2,NG=400,MC=200,jG={...z7,...bi,value:()=>null},AG=_.forwardRef(function(t,n){const{render:s,className:i,id:a,disabled:l=!1,nativeButton:f=!0,...d}=t,{setTouched:p,setFocused:g,validationMode:y,state:b,disabled:x}=xi(),{labelId:S}=lo(),{store:w,setOpen:T,selectionRef:C,validation:O,readOnly:N,required:R,alignItemWithTriggerActiveRef:M,disabled:z,keyboardActiveRef:j}=Wu(),A=x||z||l,P=at(w,it.open),Q=at(w,it.value),B=at(w,it.triggerProps),U=at(w,it.positionerElement),Z=at(w,it.listElement),K=at(w,it.id),ee=at(w,it.hasSelectedValue),D=!ee&&P,G=at(w,it.hasNullItemLabel,D),q=a??K;Dj({id:q});const V=Jo(U),L=_.useRef(null),{getButtonProps:I,buttonRef:H}=Jc({disabled:A,native:f}),W=Ae(re=>{w.set("triggerElement",re)}),Y=oo(n,L,H,W),ae=ns(),se=ns(),fe=ns(),Se=ns();_.useEffect(()=>{if(P)return!(ee||G)?fe.start(NG,()=>{C.current.allowUnselectedMouseUp=!0,C.current.allowSelectedMouseUp=!0}):Se.start(MC,()=>{C.current.allowUnselectedMouseUp=!0,fe.start(MC,()=>{C.current.allowSelectedMouseUp=!0})}),()=>{fe.clear(),Se.clear()};C.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1},se.clear()},[P,ee,G,C,se,fe,Se]);const pe=_.useMemo(()=>Z?.id??Bh(U)?.id,[Z,U]),Oe=oi(B,{id:q,role:"combobox","aria-expanded":P?"true":"false","aria-haspopup":"listbox","aria-controls":P?pe:void 0,"aria-labelledby":S,"aria-readonly":N||void 0,"aria-required":R||void 0,tabIndex:A?-1:0,ref:Y,onFocus(re){g(!0),P&&M.current&&T(!1,Yt(ii,re.nativeEvent)),ae.start(0,()=>{w.set("forceMount",!0)})},onBlur(re){Ot(U,re.relatedTarget)||(p(!0),g(!1),y==="onBlur"&&O.commit(Q))},onPointerMove(){j.current=!1},onKeyDown(){j.current=!0},onMouseDown(re){if(P)return;const he=Rt(re.currentTarget);function ie(we){if(!L.current)return;const ye=we.target;if(Ot(L.current,ye)||Ot(V.current,ye)||ye===L.current)return;const xe=RG(L.current);we.clientX>=xe.left-qd&&we.clientX<=xe.right+qd&&we.clientY>=xe.top-qd&&we.clientY<=xe.bottom+qd||T(!1,Yt(b8,we))}se.start(0,()=>{he.addEventListener("mouseup",ie,{once:!0})})}},O.getValidationProps,d,I);Oe.role="combobox";const _e={...b,open:P,disabled:A,value:Q,readOnly:N,placeholder:!ee};return zt("button",t,{ref:[n,L],state:_e,stateAttributesMapping:jG,props:Oe})}),kG=_.createContext(void 0),OG=_.forwardRef(function(t,n){const{store:s}=Wu(),i=at(s,it.mounted),a=at(s,it.forceMount);return i||a?h.jsx(kG.Provider,{value:!0,children:h.jsx(wA,{ref:n,...t})}):null});let IC={},PC={},DC="";function MG(e){if(typeof document>"u")return!1;const t=Rt(e);return un(t).innerWidth-t.documentElement.clientWidth>0}function IG(e){if(!(typeof CSS<"u"&&CSS.supports&&CSS.supports("scrollbar-gutter","stable"))||typeof document>"u")return!1;const n=Rt(e),s=n.documentElement,i=n.body,a=vi(s)?s:i,l=a.style.overflowY,f=s.style.scrollbarGutter;s.style.scrollbarGutter="stable",a.style.overflowY="scroll";const d=a.offsetWidth;a.style.overflowY="hidden";const p=a.offsetWidth;return a.style.overflowY=l,s.style.scrollbarGutter=f,d===p}function PG(e){const t=Rt(e),n=t.documentElement,s=t.body,i=vi(n)?n:s,a={overflowY:i.style.overflowY,overflowX:i.style.overflowX};return Object.assign(i.style,{overflowY:"hidden",overflowX:"hidden"}),()=>{Object.assign(i.style,a)}}function DG(e){const t=Rt(e),n=t.documentElement,s=t.body,i=un(n);let a=0,l=0,f=!1;const d=ys.create();if(nx&&(i.visualViewport?.scale??1)!==1)return()=>{};function p(){const b=i.getComputedStyle(n),x=i.getComputedStyle(s),T=(b.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";a=n.scrollTop,l=n.scrollLeft,IC={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},DC=n.style.scrollBehavior,PC={position:s.style.position,height:s.style.height,width:s.style.width,boxSizing:s.style.boxSizing,overflowY:s.style.overflowY,overflowX:s.style.overflowX,scrollBehavior:s.style.scrollBehavior};const C=n.scrollHeight>n.clientHeight,O=n.scrollWidth>n.clientWidth,N=b.overflowY==="scroll"||x.overflowY==="scroll",R=b.overflowX==="scroll"||x.overflowX==="scroll",M=Math.max(0,i.innerWidth-s.clientWidth),z=Math.max(0,i.innerHeight-s.clientHeight),j=parseFloat(x.marginTop)+parseFloat(x.marginBottom),A=parseFloat(x.marginLeft)+parseFloat(x.marginRight),P=vi(n)?n:s;if(f=IG(e),f){n.style.scrollbarGutter=T,P.style.overflowY="hidden",P.style.overflowX="hidden";return}Object.assign(n.style,{scrollbarGutter:T,overflowY:"hidden",overflowX:"hidden"}),(C||N)&&(n.style.overflowY="scroll"),(O||R)&&(n.style.overflowX="scroll"),Object.assign(s.style,{position:"relative",height:j||z?`calc(100dvh - ${j+z}px)`:"100dvh",width:A||M?`calc(100vw - ${A+M}px)`:"100vw",boxSizing:"border-box",overflow:"hidden",scrollBehavior:"unset"}),s.scrollTop=a,s.scrollLeft=l,n.setAttribute("data-base-ui-scroll-locked",""),n.style.scrollBehavior="unset"}function g(){Object.assign(n.style,IC),Object.assign(s.style,PC),f||(n.scrollTop=a,n.scrollLeft=l,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=DC)}function y(){g(),d.request(p)}return p(),i.addEventListener("resize",y),()=>{d.cancel(),g(),typeof i.removeEventListener=="function"&&i.removeEventListener("resize",y)}}class zG{lockCount=0;restore=null;timeoutLock=ai.create();timeoutUnlock=ai.create();acquire(t){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(t)),this.release}release=()=>{this.lockCount-=1,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(t){if(this.lockCount===0||this.restore!==null)return;const s=Rt(t).documentElement,i=un(s).getComputedStyle(s).overflowY;if(i==="hidden"||i==="clip"){this.restore=jn;return}const a=rA||!MG(t);this.restore=a?PG(t):DG(t)}}const LG=new zG;function HA(e=!0,t=null){Le(()=>{if(e)return LG.acquire(t)},[e,t])}const qA=_.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}});function UG(){return _.useContext(qA)}function VA(e){const{children:t,elementsRef:n,labelsRef:s,onMapChange:i}=e,a=Ae(i),l=_.useRef(0),f=zn(BG).current,d=zn($G).current,[p,g]=_.useState(0),y=_.useRef(p),b=Ae((C,O)=>{d.set(C,O??null),y.current+=1,g(y.current)}),x=Ae(C=>{d.delete(C),y.current+=1,g(y.current)}),S=_.useMemo(()=>{const C=new Map;return Array.from(d.keys()).filter(N=>N.isConnected).sort(FG).forEach((N,R)=>{const M=d.get(N)??{};C.set(N,{...M,index:R})}),C},[d,p]);Le(()=>{if(typeof MutationObserver!="function"||S.size===0)return;const C=new MutationObserver(O=>{const N=new Set,R=M=>N.has(M)?N.delete(M):N.add(M);O.forEach(M=>{M.removedNodes.forEach(R),M.addedNodes.forEach(R)}),N.size===0&&(y.current+=1,g(y.current))});return S.forEach((O,N)=>{N.parentElement&&C.observe(N.parentElement,{childList:!0})}),()=>{C.disconnect()}},[S]),Le(()=>{y.current===p&&(n.current.length!==S.size&&(n.current.length=S.size),s&&s.current.length!==S.size&&(s.current.length=S.size),l.current=S.size),a(S)},[a,S,n,s,p]),Le(()=>()=>{n.current=[]},[n]),Le(()=>()=>{s&&(s.current=[])},[s]);const w=Ae(C=>(f.add(C),()=>{f.delete(C)}));Le(()=>{f.forEach(C=>C(S))},[f,S]);const T=_.useMemo(()=>({register:b,unregister:x,subscribeMapChange:w,elementsRef:n,labelsRef:s,nextIndexRef:l}),[b,x,w,n,s,l]);return h.jsx(qA.Provider,{value:T,children:t})}function $G(){return new Map}function BG(){return new Set}function FG(e,t){const n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING||n&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:n&Node.DOCUMENT_POSITION_PRECEDING||n&Node.DOCUMENT_POSITION_CONTAINS?1:0}const KA=_.createContext(void 0);function HG(){const e=_.useContext(KA);if(!e)throw new Error(yn(59));return e}const GA=_.forwardRef(function(t,n){const{cutout:s,...i}=t;let a;if(s){const l=s?.getBoundingClientRect();a=`polygon(
|
|
76
76
|
0% 0%,
|
|
77
77
|
100% 0%,
|
|
78
78
|
100% 100%,
|
|
@@ -83,4 +83,4 @@ ${a}
|
|
|
83
83
|
${l.right}px ${l.bottom}px,
|
|
84
84
|
${l.right}px ${l.top}px,
|
|
85
85
|
${l.left}px ${l.top}px
|
|
86
|
-
)`}return h.jsx("div",{ref:n,role:"presentation","data-base-ui-inert":"",...i,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:a}})});function Qh(e,t){e&&Object.assign(e.style,t)}const qG={position:"relative",maxHeight:"100%",overflowX:"hidden",overflowY:"auto"},VG={position:"fixed"},KG=_.forwardRef(function(t,n){const{anchor:s,positionMethod:i="absolute",className:a,render:l,side:f="bottom",align:d="center",sideOffset:p=0,alignOffset:g=0,collisionBoundary:y="clipping-ancestors",collisionPadding:b,arrowPadding:x=5,sticky:S=!1,disableAnchorTracking:w,alignItemWithTrigger:T=!0,collisionAvoidance:C=X9,...O}=t,{store:N,listRef:R,labelsRef:M,alignItemWithTriggerActiveRef:z,selectedItemTextRef:j,valuesRef:A,initialValueRef:P,popupRef:Q,setValue:B}=Wu(),U=FA(),Z=at(N,it.open),K=at(N,it.mounted),ee=at(N,it.modal),D=at(N,it.value),G=at(N,it.openMethod),q=at(N,it.positionerElement),V=at(N,it.triggerElement),L=at(N,it.isItemEqualToValue),I=at(N,it.transitionStatus),H=_.useRef(null),W=_.useRef(null),[Y,ae]=_.useState(T),se=K&&Y&&G!=="touch";!K&&Y!==T&&ae(T),Le(()=>{K||(it.scrollUpArrowVisible(N.state)&&N.set("scrollUpArrowVisible",!1),it.scrollDownArrowVisible(N.state)&&N.set("scrollDownArrowVisible",!1))},[N,K]),_.useImperativeHandle(z,()=>se),HA((se||ee)&&Z&&G!=="touch",V);const fe=LA({anchor:s,floatingRootContext:U,positionMethod:i,mounted:K,side:f,sideOffset:p,align:d,alignOffset:g,arrowPadding:x,collisionBoundary:y,collisionPadding:b,sticky:S,disableAnchorTracking:w??se,collisionAvoidance:C,keepMounted:!0}),Se=se?"none":fe.side,pe=se?VG:fe.positionerStyles,Oe=_.useMemo(()=>{const xe={};return Z||(xe.pointerEvents="none"),{role:"presentation",hidden:!K,style:{...pe,...xe}}},[Z,K,pe]),_e={open:Z,side:Se,align:fe.align,anchorHidden:fe.anchorHidden},re=Ae(xe=>{N.set("positionerElement",xe)}),he=zt("div",t,{ref:[n,re],state:_e,stateAttributesMapping:ol,props:[Oe,Np(I),O]}),ie=_.useRef(0),we=Ae(xe=>{if(xe.size===0&&ie.current===0||A.current.length===0)return;const ve=ie.current;if(ie.current=xe.size,xe.size===ve)return;const Ie=Yt(ii);if(ve!==0&&!N.state.multiple&&D!==null&&zy(A.current,D,L)===-1){const Ee=P.current,Qe=Ee!=null&&zy(A.current,Ee,L)!==-1?Ee:null;B(Qe,Ie),Qe===null&&(N.set("selectedIndex",null),j.current=null)}if(ve!==0&&N.state.multiple&&Array.isArray(D)){const Ue=Ve=>zy(A.current,Ve,L)!==-1,Ee=D.filter(Ve=>Ue(Ve));(Ee.length!==D.length||Ee.some(Ve=>!xG(D,Ve,L)))&&(B(Ee,Ie),Ee.length===0&&(N.set("selectedIndex",null),j.current=null))}if(Z&&se){N.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});const Ue={height:""};Qh(q,Ue),Qh(Q.current,Ue)}}),ye=_.useMemo(()=>({...fe,side:Se,alignItemWithTriggerActive:se,setControlledAlignItemWithTrigger:ae,scrollUpArrowRef:H,scrollDownArrowRef:W}),[fe,Se,se,ae]);return h.jsx(VA,{elementsRef:R,labelsRef:M,onMapChange:we,children:h.jsxs(KA.Provider,{value:ye,children:[K&&ee&&h.jsx(GA,{inert:dx(!Z),cutout:V}),he]})})});function ZA(e){const t=e.currentTarget.getBoundingClientRect();return t.top+1<=e.clientY&&e.clientY<=t.bottom-1&&t.left+1<=e.clientX&&e.clientX<=t.right-1}const Vd="base-ui-disable-scrollbar",zC={className:Vd,getElement(e){return h.jsx("style",{nonce:e,href:Vd,precedence:"base-ui:low",children:`.${Vd}{scrollbar-width:none}.${Vd}::-webkit-scrollbar{display:none}`})}},GG=_.createContext(void 0);function YA(e){return _.useContext(GG)}const wc="ArrowUp",Wi="ArrowDown",Au="ArrowLeft",Ec="ArrowRight",Ju="Home",ef="End",XA=new Set([Au,Ec]),ZG=new Set([Au,Ec,Ju,ef]),QA=new Set([wc,Wi]),YG=new Set([wc,Wi,Ju,ef]),WA=new Set([...XA,...QA]),XG=new Set([...WA,Ju,ef]),JA=new Set([wc,Wi,Au,Ec,Ju,ef]),QG="Shift",WG="Control",JG="Alt",eZ="Meta",tZ=new Set([QG,WG,JG,eZ]);function nZ(e){return Zt(e)&&e.tagName==="INPUT"}function LC(e){return!!(nZ(e)&&e.selectionStart!=null||Zt(e)&&e.tagName==="TEXTAREA")}function UC(e,t,n,s){if(!e||!t||!t.scrollTo)return;let i=e.scrollLeft,a=e.scrollTop;const l=e.clientWidth<e.scrollWidth,f=e.clientHeight<e.scrollHeight;if(l&&s!=="vertical"){const d=$C(e,t,"left"),p=Kd(e),g=Kd(t);n==="ltr"&&(d+t.offsetWidth+g.scrollMarginRight>e.scrollLeft+e.clientWidth-p.scrollPaddingRight?i=d+t.offsetWidth+g.scrollMarginRight-e.clientWidth+p.scrollPaddingRight:d-g.scrollMarginLeft<e.scrollLeft+p.scrollPaddingLeft&&(i=d-g.scrollMarginLeft-p.scrollPaddingLeft)),n==="rtl"&&(d-g.scrollMarginRight<e.scrollLeft+p.scrollPaddingLeft?i=d-g.scrollMarginLeft-p.scrollPaddingLeft:d+t.offsetWidth+g.scrollMarginRight>e.scrollLeft+e.clientWidth-p.scrollPaddingRight&&(i=d+t.offsetWidth+g.scrollMarginRight-e.clientWidth+p.scrollPaddingRight))}if(f&&s!=="horizontal"){const d=$C(e,t,"top"),p=Kd(e),g=Kd(t);d-g.scrollMarginTop<e.scrollTop+p.scrollPaddingTop?a=d-g.scrollMarginTop-p.scrollPaddingTop:d+t.offsetHeight+g.scrollMarginBottom>e.scrollTop+e.clientHeight-p.scrollPaddingBottom&&(a=d+t.offsetHeight+g.scrollMarginBottom-e.clientHeight+p.scrollPaddingBottom)}e.scrollTo({left:i,top:a,behavior:"auto"})}function $C(e,t,n){const s=n==="left"?"offsetLeft":"offsetTop";let i=0;for(;t.offsetParent&&(i+=t[s],t.offsetParent!==e);)t=t.offsetParent;return i}function Kd(e){const t=getComputedStyle(e);return{scrollMarginTop:parseFloat(t.scrollMarginTop)||0,scrollMarginRight:parseFloat(t.scrollMarginRight)||0,scrollMarginBottom:parseFloat(t.scrollMarginBottom)||0,scrollMarginLeft:parseFloat(t.scrollMarginLeft)||0,scrollPaddingTop:parseFloat(t.scrollPaddingTop)||0,scrollPaddingRight:parseFloat(t.scrollPaddingRight)||0,scrollPaddingBottom:parseFloat(t.scrollPaddingBottom)||0,scrollPaddingLeft:parseFloat(t.scrollPaddingLeft)||0}}function Ly(e,t=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(t,Math.min(e,n))}const rZ=_.createContext(void 0),sZ={disableStyleElements:!1};function oZ(){return _.useContext(rZ)??sZ}const Vi=1,iZ={...ol,...ba},aZ=_.forwardRef(function(t,n){const{render:s,className:i,finalFocus:a,...l}=t,{store:f,popupRef:d,onOpenChangeComplete:p,setOpen:g,valueRef:y,selectedItemTextRef:b,keyboardActiveRef:x,multiple:S,handleScrollArrowVisibility:w,scrollHandlerRef:T,highlightItemOnHover:C}=Wu(),{side:O,align:N,alignItemWithTriggerActive:R,setControlledAlignItemWithTrigger:M,scrollDownArrowRef:z,scrollUpArrowRef:j}=HG(),A=YA()!=null,P=FA(),{nonce:Q,disableStyleElements:B}=oZ(),U=ns(),Z=at(f,it.id),K=at(f,it.open),ee=at(f,it.mounted),D=at(f,it.popupProps),G=at(f,it.transitionStatus),q=at(f,it.triggerElement),V=at(f,it.positionerElement),L=at(f,it.listElement),I=_.useRef(0),H=_.useRef(!1),W=_.useRef(0),Y=_.useRef(!1),ae=_.useRef({}),se=ix(),fe=Ae(_e=>{if(!V||!d.current||!Y.current)return;if(H.current||!R){w();return}const re=V.style.top==="0px",he=V.style.bottom==="0px",ie=V.getBoundingClientRect().height,we=Rt(V),ye=getComputedStyle(V),xe=parseFloat(ye.marginTop),ve=parseFloat(ye.marginBottom),Ie=BC(getComputedStyle(d.current)),Ue=Math.min(we.documentElement.clientHeight-xe-ve,Ie),Ee=_e.scrollTop,Ve=FC(_e);let Qe=0,Be=null,We=!1,He=!1;const me=qe=>{V.style.height=`${qe}px`},Te=(qe,mt)=>{const lt=Ly(qe,0,Ue-ie);lt>0&&me(ie+lt),_e.scrollTop=mt,Ue-(ie+lt)<=Vi&&(H.current=!0),w()};if(re){const qe=Ve-Ee,mt=ie+qe,lt=Math.min(mt,Ue);if(Qe=lt,qe<=Vi){Te(qe,Ve);return}Ue-lt>Vi?He=!0:We=!0}else if(he){const qe=Ee,mt=ie+qe,lt=Math.min(mt,Ue),wr=mt-Ue;if(Qe=lt,qe<=Vi){Te(qe,0);return}Ue-lt>Vi?Be=0:(We=!0,Ee<Ve&&(Be=Ee-(qe-wr)))}if(Qe=Math.ceil(Qe),Qe!==0&&me(Qe),He||Be!=null){const qe=FC(_e),mt=He?qe:Ly(Be,0,qe);Math.abs(_e.scrollTop-mt)>Vi&&(_e.scrollTop=mt)}(We||Qe>=Ue-Vi)&&(H.current=!0),w()});_.useImperativeHandle(T,()=>fe,[fe]),xa({open:K,ref:d,onComplete(){K&&p?.(!0)}});const Se={open:K,transitionStatus:G,side:O,align:N};Le(()=>{!V||!d.current||Object.keys(ae.current).length||(ae.current={top:V.style.top||"0",left:V.style.left||"0",right:V.style.right,height:V.style.height,bottom:V.style.bottom,minHeight:V.style.minHeight,maxHeight:V.style.maxHeight,marginTop:V.style.marginTop,marginBottom:V.style.marginBottom})},[d,V]),Le(()=>{K||R||(Y.current=!1,H.current=!1,I.current=0,W.current=0,Qh(V,ae.current))},[K,R,V,d]),Le(()=>{const _e=d.current;if(!(!K||!q||!V||!_e||f.state.transitionStatus==="ending")){if(!R){Y.current=!0,se.request(w),_e.style.removeProperty("--transform-origin");return}queueMicrotask(()=>{const re=cZ(_e);_e.style.removeProperty("--transform-origin");try{const he=getComputedStyle(V),ie=getComputedStyle(_e),we=Rt(q),ye=un(V),xe=q.getBoundingClientRect(),ve=V.getBoundingClientRect(),Ie=xe.left,Ue=xe.height,Ee=L||_e,Ve=Ee.scrollHeight,Qe=parseFloat(ie.borderBottomWidth),Be=parseFloat(he.marginTop)||10,We=parseFloat(he.marginBottom)||10,He=parseFloat(he.minHeight)||100,me=BC(ie),Te=5,qe=5,mt=20,lt=we.documentElement.clientHeight-Be-We,wr=we.documentElement.clientWidth,Er=lt-xe.bottom+Ue,Qt=b.current,ut=y.current;let xt,ot=0,Wt=0;if(Qt&&ut){const tr=ut.getBoundingClientRect();xt=Qt.getBoundingClientRect();const ls=tr.left-Ie,fo=xt.left-ve.left,ho=tr.top-xe.top+tr.height/2,nr=xt.top-ve.top+xt.height/2;ot=ls-fo,Wt=nr-ho}const vn=Er+Wt+We+Qe;let kt=Math.min(lt,vn);const Cn=lt-Be-We,er=vn-kt,An=Math.max(Te,Ie+ot),as=wr-qe,cs=Math.max(0,An+ve.width-as);V.style.left=`${An-cs}px`,V.style.height=`${kt}px`,V.style.maxHeight="auto",V.style.marginTop=`${Be}px`,V.style.marginBottom=`${We}px`,_e.style.height="100%";const _a=Ee.scrollHeight-Ee.clientHeight,wi=er>=_a;wi&&(kt=Math.min(lt,ve.height)-(er-_a));const Ei=xe.top<mt||xe.bottom>lt-mt||kt<Math.min(Ve,He),ws=(ye.visualViewport?.scale??1)!==1&&nx;if(Ei||ws){Y.current=!0,Qh(V,ae.current),hi.flushSync(()=>M(!1));return}if(wi){const tr=Math.max(0,lt-vn);V.style.top=ve.height>=Cn?"0":`${tr}px`,V.style.height=`${kt}px`,Ee.scrollTop=Ee.scrollHeight-Ee.clientHeight,I.current=Math.max(He,kt)}else V.style.bottom="0",I.current=Math.max(He,kt),Ee.scrollTop=er;if(xt){const tr=ve.top,ls=ve.height,fo=xt.top+xt.height/2,ho=ls>0?(fo-tr)/ls*100:50,nr=Ly(ho,0,100);_e.style.setProperty("--transform-origin",`50% ${nr}%`)}(I.current===lt||kt>=me)&&(H.current=!0),w(),setTimeout(()=>{Y.current=!0})}finally{re()}})}},[f,K,V,q,y,b,d,w,R,M,se,z,j,L]),_.useEffect(()=>{if(!R||!V||!K)return;const _e=un(V);function re(he){g(!1,Yt(S8,he))}return _e.addEventListener("resize",re),()=>{_e.removeEventListener("resize",re)}},[g,R,V,K]);const pe={...L?{role:"presentation","aria-orientation":void 0}:{role:"listbox","aria-multiselectable":S||void 0,id:`${Z}-list`},onKeyDown(_e){x.current=!0,A&&JA.has(_e.key)&&_e.stopPropagation()},onMouseMove(){x.current=!1},onPointerLeave(_e){if(!C||ZA(_e)||_e.pointerType==="touch")return;const re=_e.currentTarget;U.start(0,()=>{f.set("activeIndex",null),re.focus({preventScroll:!0})})},onScroll(_e){L||fe(_e.currentTarget)},...R&&{style:L?{height:"100%"}:qG}},Oe=zt("div",t,{ref:[n,d],state:Se,stateAttributesMapping:iZ,props:[D,pe,Np(G),{className:!L&&R?zC.className:void 0},l]});return h.jsxs(_.Fragment,{children:[!B&&zC.getElement(Q),h.jsx(EA,{context:P,modal:!1,disabled:!ee,returnFocus:a,restoreFocus:!0,children:Oe})]})});function BC(e){const t=e.maxHeight||"";return t.endsWith("px")&&parseFloat(t)||1/0}function FC(e){return Math.max(0,e.scrollHeight-e.clientHeight)}const HC=[["transform","none"],["scale","1"],["translate","0 0"]];function cZ(e){const{style:t}=e,n={};for(const[s,i]of HC)n[s]=t.getPropertyValue(s),t.setProperty(s,i,"important");return()=>{for(const[s]of HC){const i=n[s];i?t.setProperty(s,i):t.removeProperty(s)}}}let ek=(function(e){return e[e.None=0]="None",e[e.GuessFromOrder=1]="GuessFromOrder",e})({});function hx(e={}){const{label:t,metadata:n,textRef:s,indexGuessBehavior:i,index:a}=e,{register:l,unregister:f,subscribeMapChange:d,elementsRef:p,labelsRef:g,nextIndexRef:y}=UG(),b=_.useRef(-1),[x,S]=_.useState(a??(i===ek.GuessFromOrder?()=>{if(b.current===-1){const C=y.current;y.current+=1,b.current=C}return b.current}:-1)),w=_.useRef(null),T=_.useCallback(C=>{if(w.current=C,x!==-1&&C!==null&&(p.current[x]=C,g)){const O=t!==void 0;g.current[x]=O?t:s?.current?.textContent??C.textContent}},[x,p,g,t,s]);return Le(()=>{if(a!=null)return;const C=w.current;if(C)return l(C,n),()=>{f(C)}},[a,l,f,n]),Le(()=>{if(a==null)return d(C=>{const O=w.current?C.get(w.current)?.index:null;O!=null&&S(O)})},[a,d,S]),_.useMemo(()=>({ref:T,index:x}),[x,T])}const lZ=_.createContext(void 0),uZ=_.memo(_.forwardRef(function(t,n){const{render:s,className:i,value:a=null,label:l,disabled:f=!1,nativeButton:d=!1,...p}=t,g=_.useRef(null),y=hx({label:l,textRef:g,indexGuessBehavior:ek.GuessFromOrder}),{store:b,getItemProps:x,setOpen:S,setValue:w,selectionRef:T,typingRef:C,valuesRef:O,keyboardActiveRef:N,multiple:R,highlightItemOnHover:M}=Wu(),z=ns(),j=at(b,it.isActive,y.index),A=at(b,it.isSelected,y.index,a),P=at(b,it.isSelectedByFocus,y.index),Q=at(b,it.isItemEqualToValue),B=y.index,U=B!==-1,Z=_.useRef(null),K=Jo(B);Le(()=>{if(!U)return;const se=O.current;return se[B]=a,()=>{delete se[B]}},[U,B,a,O]),Le(()=>{if(!U)return;const se=b.state.value;let fe=se;R&&Array.isArray(se)&&se.length>0&&(fe=se[se.length-1]),fe!==void 0&&$c(a,fe,Q)&&b.set("selectedIndex",B)},[U,B,R,Q,b,a]);const ee={disabled:f,selected:A,highlighted:j},D=x({active:j,selected:A});D.onFocus=void 0,D.id=void 0;const G=_.useRef(null),q=_.useRef("mouse"),V=_.useRef(!1),{getButtonProps:L,buttonRef:I}=Jc({disabled:f,focusableWhenDisabled:!0,native:d});function H(se){const fe=b.state.value;if(R){const Se=Array.isArray(fe)?fe:[],pe=A?SG(Se,a,Q):[...Se,a];w(pe,Yt(Cy,se))}else w(a,Yt(Cy,se)),S(!1,Yt(Cy,se))}const W={role:"option","aria-selected":A,tabIndex:j?0:-1,onFocus(){b.set("activeIndex",B)},onMouseEnter(){!N.current&&b.state.selectedIndex===null&&M&&b.set("activeIndex",B)},onMouseMove(){M&&b.set("activeIndex",B)},onMouseLeave(se){!M||N.current||ZA(se)||z.start(0,()=>{b.state.activeIndex===B&&b.set("activeIndex",null)})},onTouchStart(){T.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1}},onKeyDown(se){G.current=se.key,b.set("activeIndex",B)},onClick(se){V.current=!1,!(se.type==="keydown"&&G.current===null)&&(f||G.current===" "&&C.current||q.current!=="touch"&&!j||(G.current=null,H(se.nativeEvent)))},onPointerEnter(se){q.current=se.pointerType},onPointerDown(se){q.current=se.pointerType,V.current=!0},onMouseUp(se){if(f)return;if(V.current){V.current=!1;return}const fe=!T.current.allowSelectedMouseUp&&A,Se=!T.current.allowUnselectedMouseUp&&!A;fe||Se||q.current!=="touch"&&!j||H(se.nativeEvent)}},Y=zt("div",t,{ref:[I,n,y.ref,Z],state:ee,props:[D,W,p,L]}),ae=_.useMemo(()=>({selected:A,indexRef:K,textRef:g,selectedByFocus:P,hasRegistered:U}),[A,K,g,P,U]);return h.jsx(lZ.Provider,{value:ae,children:Y})})),fZ=_.forwardRef(({className:e,children:t,...n},s)=>h.jsx(AG,{ref:s,className:ge("inline-flex items-center justify-between bg-surface border border-border rounded-md px-3 py-1.5 font-mono text-[12px] text-foreground cursor-pointer hover:border-border-bright transition",e),...n,children:t}));fZ.displayName="SelectTrigger";const dZ=_.forwardRef(({className:e,portalProps:t,positionerProps:n,...s},i)=>h.jsx(OG,{...t,children:h.jsx(KG,{...n,children:h.jsx(aZ,{ref:i,className:ge("bg-panel border border-border rounded-md py-1 shadow-lg z-50",e),...s})})}));dZ.displayName="SelectContent";const hZ=_.forwardRef(({className:e,...t},n)=>h.jsx(uZ,{ref:n,className:ge("font-mono text-[11px] px-3 py-1.5 text-neutral-400 cursor-pointer hover:bg-white/[0.03] hover:text-white data-[highlighted]:bg-white/[0.03] data-[highlighted]:text-white outline-none",e),...t}));hZ.displayName="SelectItem";const pZ=_.forwardRef(({className:e,...t},n)=>h.jsx("textarea",{ref:n,className:ge("bg-surface border border-border rounded-md px-3 py-2 font-mono text-[12px] text-foreground outline-none w-full transition focus:border-flow placeholder:text-neutral-600 resize-none min-h-[80px]",e),...t}));pZ.displayName="Textarea";const tk=_.createContext(void 0);function mZ(e=!0){const t=_.useContext(tk);if(t===void 0&&!e)throw new Error(yn(7));return t}function nk(e={}){const{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:s}=Aj(),{ref:i,index:a}=hx(e),l=n===a,f=_.useRef(null),d=oo(i,f);return{compositeProps:_.useMemo(()=>({tabIndex:l?0:-1,onFocus(){s(a)},onMouseMove(){const g=f.current;if(!t||!g)return;const y=g.hasAttribute("disabled")||g.ariaDisabled==="true";!l&&!y&&g.focus()}}),[l,s,a,t]),compositeRef:d,index:a}}function gZ(e){const{render:t,className:n,state:s=an,props:i=Ru,refs:a=Ru,metadata:l,stateAttributesMapping:f,tag:d="div",...p}=e,{compositeProps:g,compositeRef:y}=nk({metadata:l});return zt(d,e,{state:s,ref:[...a,y],props:[g,...i,p],stateAttributesMapping:f})}const yZ=_.forwardRef(function(t,n){const{className:s,defaultPressed:i=!1,disabled:a=!1,form:l,onPressedChange:f,pressed:d,render:p,type:g,value:y,nativeButton:b=!0,...x}=t,S=br(y||void 0),w=mZ(),T=w?.value??[],C=w?void 0:i,O=(a||w?.disabled)??!1,[N,R]=pp({controlled:w?S!==void 0&&T.indexOf(S)>-1:d,default:C,name:"Toggle",state:"pressed"}),M=Ae((U,Z)=>{S&&w?.setGroupValue?.(S,U,Z),f?.(U,Z)}),{getButtonProps:z,buttonRef:j}=Jc({disabled:O,native:b}),A={disabled:O,pressed:N},P=[j,n],Q=[{"aria-pressed":N,onClick(U){const Z=!N,K=Yt(ii,U.nativeEvent);M(Z,K),!K.isCanceled&&R(Z)}},x,z],B=zt("button",t,{enabled:!w,state:A,ref:P,props:Q});return w?h.jsx(gZ,{tag:"button",render:p,className:s,state:A,refs:P,props:Q}):B}),Dr=_.forwardRef(({className:e,...t},n)=>h.jsx(yZ,{ref:n,className:ge("font-mono text-[10px] text-neutral-500 border border-transparent rounded-sm px-2.5 py-1 cursor-pointer transition-all hover:text-neutral-300 data-[pressed]:text-white data-[pressed]:border-border-bright data-[pressed]:bg-white/[0.03]",e),...t}));Dr.displayName="Toggle";function vZ(e){return e==null||e.hasAttribute("disabled")||e.getAttribute("aria-disabled")==="true"}const rk="data-composite-item-active",bZ=[];function xZ(e){const{itemSizes:t,cols:n=1,loopFocus:s=!0,dense:i=!1,orientation:a="both",direction:l,highlightedIndex:f,onHighlightedIndexChange:d,rootRef:p,enableHomeAndEndKeys:g=!1,stopEventPropagation:y=!1,disabledIndices:b,modifierKeys:x=bZ}=e,[S,w]=_.useState(0),T=n>1,C=_.useRef(null),O=oo(C,p),N=_.useRef([]),R=_.useRef(!1),M=f??S,z=Ae((P,Q=!1)=>{if((d??w)(P),Q){const B=N.current[P];UC(C.current,B,l,a)}}),j=Ae(P=>{if(P.size===0||R.current)return;R.current=!0;const Q=Array.from(P.keys()),B=Q.find(Z=>Z?.hasAttribute(rk))??null,U=B?Q.indexOf(B):-1;U!==-1&&z(U),UC(C.current,B,l,a)}),A=_.useMemo(()=>({"aria-orientation":a==="both"?void 0:a,ref:O,onFocus(P){!C.current||!LC(P.target)||P.target.setSelectionRange(0,P.target.value.length??0)},onKeyDown(P){const Q=g?XG:WA;if(!Q.has(P.key)||SZ(P,x)||!C.current)return;const U=l==="rtl",Z=U?Au:Ec,K={horizontal:Z,vertical:Wi,both:Z}[a],ee=U?Ec:Au,D={horizontal:ee,vertical:wc,both:ee}[a];if(LC(P.target)&&!vZ(P.target)){const W=P.target.selectionStart,Y=P.target.selectionEnd,ae=P.target.value??"";if(W==null||P.shiftKey||W!==Y||P.key!==D&&W<ae.length||P.key!==K&&W>0)return}let G=M;const q=PV(N,b),V=DV(N,b);if(T){const W=t||Array.from({length:N.current.length},()=>({width:1,height:1})),Y=LV(W,n,i),ae=Y.findIndex(fe=>fe!=null&&!pu(N,fe,b)),se=Y.reduce((fe,Se,pe)=>Se!=null&&!pu(N,Se,b)?pe:fe,-1);G=Y[zV({current:Y.map(fe=>fe?N.current[fe]:null)},{event:P,orientation:a,loopFocus:s,cols:n,disabledIndices:$V([...b||N.current.map((fe,Se)=>pu(N,Se)?Se:void 0),void 0],Y),minIndex:ae,maxIndex:se,prevIndex:UV(M>V?q:M,W,Y,n,P.key===Wi?"bl":P.key===Ec?"tr":"tl"),rtl:U})]}const L={horizontal:[Z],vertical:[Wi],both:[Z,Wi]}[a],I={horizontal:[ee],vertical:[wc],both:[ee,wc]}[a],H=T?Q:{horizontal:g?ZG:XA,vertical:g?YG:QA,both:Q}[a];g&&(P.key===Ju?G=q:P.key===ef&&(G=V)),G===M&&(L.includes(P.key)||I.includes(P.key))&&(s&&G===V&&L.includes(P.key)?G=q:s&&G===q&&I.includes(P.key)?G=V:G=fr(N,{startingIndex:G,decrement:I.includes(P.key),disabledIndices:b})),G!==M&&!ch(N,G)&&(y&&P.stopPropagation(),H.has(P.key)&&P.preventDefault(),z(G,!0),queueMicrotask(()=>{N.current[G]?.focus()}))}}),[n,i,l,b,N,g,M,T,t,s,O,x,z,a,y]);return _.useMemo(()=>({props:A,highlightedIndex:M,onHighlightedIndexChange:z,elementsRef:N,disabledIndices:b,onMapChange:j,relayKeyboardEvent:A.onKeyDown}),[A,M,z,N,b,j])}function SZ(e,t){for(const n of tZ.values())if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function sk(e){const{render:t,className:n,refs:s=Ru,props:i=Ru,state:a=an,stateAttributesMapping:l,highlightedIndex:f,onHighlightedIndexChange:d,orientation:p,dense:g,itemSizes:y,loopFocus:b,cols:x,enableHomeAndEndKeys:S,onMapChange:w,stopEventPropagation:T=!0,rootRef:C,disabledIndices:O,modifierKeys:N,highlightItemOnHover:R=!1,tag:M="div",...z}=e,j=DA(),{props:A,highlightedIndex:P,onHighlightedIndexChange:Q,elementsRef:B,onMapChange:U,relayKeyboardEvent:Z}=xZ({itemSizes:y,cols:x,loopFocus:b,dense:g,orientation:p,highlightedIndex:f,onHighlightedIndexChange:d,rootRef:C,stopEventPropagation:T,enableHomeAndEndKeys:S,direction:j,disabledIndices:O,modifierKeys:N}),K=zt(M,e,{state:a,ref:s,props:[A,...i,z],stateAttributesMapping:l}),ee=_.useMemo(()=>({highlightedIndex:P,onHighlightedIndexChange:Q,highlightItemOnHover:R,relayKeyboardEvent:Z}),[P,Q,R,Z]);return h.jsx(jj.Provider,{value:ee,children:h.jsx(VA,{elementsRef:B,onMapChange:D=>{w?.(D),U(D)},children:K})})}let _Z=(function(e){return e.disabled="data-disabled",e.orientation="data-orientation",e.multiple="data-multiple",e})({});const qC={multiple(e){return e?{[_Z.multiple]:""}:null}},wZ=_.forwardRef(function(t,n){const{defaultValue:s,disabled:i=!1,loopFocus:a=!0,onValueChange:l,orientation:f="horizontal",multiple:d=!1,value:p,className:g,render:y,...b}=t,x=YA(),S=_.useMemo(()=>{if(p===void 0)return s??[]},[p,s]),w=_.useMemo(()=>p!==void 0||s!==void 0,[p,s]),T=(x?.disabled??!1)||i,[C,O]=pp({controlled:p,default:S,name:"ToggleGroup",state:"value"}),N=Ae((A,P,Q)=>{let B;if(d?(B=C.slice(),P?B.push(A):B.splice(C.indexOf(A),1)):B=P?[A]:[],Array.isArray(B)){if(l?.(B,Q),Q.isCanceled)return;O(B)}}),R={disabled:T,multiple:d,orientation:f},M=_.useMemo(()=>({disabled:T,orientation:f,setGroupValue:N,value:C,isValueInitialized:w}),[T,f,N,C,w]),z={role:"group"},j=zt("div",t,{enabled:!!x,state:R,ref:n,props:[z,b],stateAttributesMapping:qC});return h.jsx(tk.Provider,{value:M,children:x?j:h.jsx(sk,{render:y,className:g,state:R,refs:[n],props:[z,b],stateAttributesMapping:qC,loopFocus:a,enableHomeAndEndKeys:!0})})}),dh=_.forwardRef(({className:e,...t},n)=>h.jsx(wZ,{ref:n,className:ge("flex items-center gap-0.5",e),...t}));dh.displayName="ToggleGroup";const EZ=ge(Hj({variant:"secondary",size:"sm"}),"h-7 whitespace-nowrap uppercase tracking-[0.08em] leading-none no-underline");function ok({active:e,onClick:t,children:n,className:s}){return h.jsxs("button",{type:"button",onClick:t,className:ge("font-mono text-[10px] tracking-[1.5px] uppercase bg-transparent border-none px-3.5 py-1 cursor-pointer relative transition-colors",e?"text-white":"text-neutral-500 hover:text-neutral-300",s),children:[n,e&&h.jsx("span",{className:"absolute -bottom-2.5 left-1/2 -translate-x-1/2 w-4 h-0.5 bg-flow rounded-sm shadow-[0_0_8px_rgba(59,130,246,0.5)]"})]})}function TZ({items:e,activeId:t,onItemChange:n,renderItem:s,className:i}){return h.jsx("div",{className:ge("flex items-center gap-0.5",i),children:e.map(a=>{const l=a.id===t,f=()=>n?.(a.id);return s?h.jsx("span",{children:s(a,{active:l,onClick:f})},a.id):h.jsx(ok,{active:l,onClick:f,children:a.label},a.id)})})}const CZ=gi("rounded-full inline-block flex-shrink-0",{variants:{color:{healthy:"bg-healthy",syncing:"bg-syncing",offline:"bg-offline",flow:"bg-flow",relay:"bg-relay",encrypt:"bg-encrypt",muted:"bg-neutral-500"},size:{sm:"w-1.5 h-1.5",md:"w-2 h-2",lg:"w-2.5 h-2.5"},glow:{true:"",false:""}},defaultVariants:{color:"healthy",size:"sm",glow:!1}}),RZ={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 NZ({color:e,size:t,glow:n,pulse:s,className:i}){return h.jsx("span",{className:ge(CZ({color:e,size:t,glow:n}),s&&"dot-pulse",i),style:n?{boxShadow:RZ[e??"healthy"]}:void 0})}const jZ="0.0.6-73",AZ={version:jZ},kZ=AZ.version;function OZ({label:e,className:t}){return h.jsxs("div",{className:ge("flex items-center gap-3",t),children:[h.jsx(NZ,{color:"healthy",size:"md",glow:!0}),h.jsx("span",{className:"font-display font-bold text-white text-sm tracking-tight",children:"syncular"}),e&&h.jsx("span",{className:"font-mono text-[9px] text-neutral-600 uppercase tracking-widest",children:e}),h.jsxs("span",{className:"font-mono text-[9px] text-neutral-600 tracking-wider",children:["v",kZ]})]})}function MZ({brand:e,center:t,right:n,className:s}){return h.jsxs(h.Fragment,{children:[h.jsx("div",{"aria-hidden":"true",className:"h-[42px] shrink-0"}),h.jsxs("nav",{className:ge("fixed top-0 left-0 right-0 z-100 h-[42px] border-b border-border bg-surface/88 backdrop-blur-lg flex items-center justify-between px-5",s),children:[h.jsx("div",{className:"flex items-center gap-3",children:e}),h.jsx("div",{className:"flex items-center gap-0.5",children:t}),h.jsx("div",{className:"flex items-center gap-2",children:n})]})]})}const IZ=gi("border rounded-lg p-3 font-mono text-[11px]",{variants:{variant:{default:"border-border bg-panel",destructive:"border-offline/20 bg-offline/5 text-offline"}},defaultVariants:{variant:"default"}}),In=_.forwardRef(({className:e,variant:t,...n},s)=>h.jsx("div",{ref:s,role:"alert",className:ge(IZ({variant:t,className:e})),...n}));In.displayName="Alert";const tf=_.forwardRef(({className:e,...t},n)=>h.jsx("h5",{ref:n,className:ge("font-medium text-white mb-1",e),...t}));tf.displayName="AlertTitle";const Pn=_.forwardRef(({className:e,...t},n)=>h.jsx("p",{ref:n,className:ge("text-neutral-400",e),...t}));Pn.displayName="AlertDescription";const ik=_.createContext(void 0);function il(e){const t=_.useContext(ik);if(e===!1&&t===void 0)throw new Error(yn(27));return t}const PZ={...ol,...ba},px=_.forwardRef(function(t,n){const{render:s,className:i,forceRender:a=!1,...l}=t,{store:f}=il(),d=f.useState("open"),p=f.useState("nested"),g=f.useState("mounted"),y=f.useState("transitionStatus");return zt("div",t,{state:{open:d,transitionStatus:y},ref:[f.context.backdropRef,n],stateAttributesMapping:PZ,props:[{role:"presentation",hidden:!g,style:{userSelect:"none",WebkitUserSelect:"none"}},l],enabled:a||!p})}),ak=_.forwardRef(function(t,n){const{render:s,className:i,id:a,...l}=t,{store:f}=il(),d=br(a);return f.useSyncedValueWithCleanup("descriptionElementId",d),zt("p",t,{ref:n,props:[{id:d},l]})});let DZ=(function(e){return e.nestedDialogs="--nested-dialogs",e})({}),zZ=(function(e){return e[e.open=Qi.open]="open",e[e.closed=Qi.closed]="closed",e[e.startingStyle=Qi.startingStyle]="startingStyle",e[e.endingStyle=Qi.endingStyle]="endingStyle",e.nested="data-nested",e.nestedDialogOpen="data-nested-dialog-open",e})({});const ck=_.createContext(void 0);function LZ(){const e=_.useContext(ck);if(e===void 0)throw new Error(yn(26));return e}const UZ={...ol,...ba,nestedDialogOpen(e){return e?{[zZ.nestedDialogOpen]:""}:null}},lk=_.forwardRef(function(t,n){const{className:s,finalFocus:i,initialFocus:a,render:l,...f}=t,{store:d}=il(),p=d.useState("descriptionElementId"),g=d.useState("disablePointerDismissal"),y=d.useState("floatingRootContext"),b=d.useState("popupProps"),x=d.useState("modal"),S=d.useState("mounted"),w=d.useState("nested"),T=d.useState("nestedOpenDialogCount"),C=d.useState("open"),O=d.useState("openMethod"),N=d.useState("titleElementId"),R=d.useState("transitionStatus"),M=d.useState("role");LZ(),xa({open:C,ref:d.context.popupRef,onComplete(){C&&d.context.onOpenChangeComplete?.(!0)}});function z(B){return B==="touch"?d.context.popupRef.current:!0}const j=a===void 0?z:a,A=T>0,Q=zt("div",t,{state:{open:C,nested:w,transitionStatus:R,nestedDialogOpen:A},props:[b,{"aria-labelledby":N??void 0,"aria-describedby":p??void 0,role:M,tabIndex:-1,hidden:!S,onKeyDown(B){JA.has(B.key)&&B.stopPropagation()},style:{[DZ.nestedDialogs]:T}},f],ref:[n,d.context.popupRef,d.useStateSetter("popupElement")],stateAttributesMapping:UZ});return h.jsx(EA,{context:y,openInteractionType:O,disabled:!S,closeOnFocusOut:!g,initialFocus:j,returnFocus:i,modal:x!==!1,restoreFocus:"popup",children:Q})}),uk=_.forwardRef(function(t,n){const{keepMounted:s=!1,...i}=t,{store:a}=il(),l=a.useState("mounted"),f=a.useState("modal"),d=a.useState("open");return l||s?h.jsx(ck.Provider,{value:s,children:h.jsxs(wA,{ref:n,...i,children:[l&&f===!0&&h.jsx(GA,{ref:a.context.internalBackdropRef,inert:dx(!d)}),t.children]})}):null});function $Z(e){const{store:t,parentContext:n,actionsRef:s}=e,i=t.useState("open"),a=t.useState("disablePointerDismissal"),l=t.useState("modal"),f=t.useState("popupElement"),{openMethod:d,triggerProps:p,reset:g}=CG(i);gK(t);const{forceUnmount:y}=yK(i,t,()=>{g()}),b=Ae(Q=>{const B=Yt(Q);return B.preventUnmountOnClose=()=>{t.set("preventUnmountingOnClose",!0)},B}),x=_.useCallback(()=>{t.setOpen(!1,b(x8))},[t,b]);_.useImperativeHandle(s,()=>({unmount:y,close:x}),[y,x]);const S=wK({popupStore:t,onOpenChange:t.setOpen,treatPopupAsFloatingElement:!0,noEmit:!0}),[w,T]=_.useState(0),C=w===0,O=OK(S),N=sK(S,{outsidePressEvent(){return t.context.internalBackdropRef.current||t.context.backdropRef.current?"intentional":{mouse:l==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}},outsidePress(Q){if(!t.context.outsidePressEnabledRef.current||"button"in Q&&Q.button!==0||"touches"in Q&&Q.touches.length!==1)return!1;const B=Ur(Q);if(C&&!a){const U=B;return l&&(t.context.internalBackdropRef.current||t.context.backdropRef.current)?t.context.internalBackdropRef.current===U||t.context.backdropRef.current===U||Ot(U,f)&&!U?.hasAttribute("data-base-ui-portal"):!0}return!1},escapeKey:C});HA(i&&l===!0,f);const{getReferenceProps:R,getFloatingProps:M,getTriggerProps:z}=AK([O,N]);t.useContextCallback("onNestedDialogOpen",Q=>{T(Q+1)}),t.useContextCallback("onNestedDialogClose",()=>{T(0)}),_.useEffect(()=>(n?.onNestedDialogOpen&&i&&n.onNestedDialogOpen(w),n?.onNestedDialogClose&&!i&&n.onNestedDialogClose(),()=>{n?.onNestedDialogClose&&i&&n.onNestedDialogClose()}),[i,n,w]);const j=_.useMemo(()=>R(p),[R,p]),A=_.useMemo(()=>z(p),[z,p]),P=_.useMemo(()=>M(),[M]);t.useSyncedValues({openMethod:d,activeTriggerProps:j,inactiveTriggerProps:A,popupProps:P,floatingRootContext:S,nestedOpenDialogCount:w})}const BZ={...xK,modal:Pe(e=>e.modal),nested:Pe(e=>e.nested),nestedOpenDialogCount:Pe(e=>e.nestedOpenDialogCount),disablePointerDismissal:Pe(e=>e.disablePointerDismissal),openMethod:Pe(e=>e.openMethod),descriptionElementId:Pe(e=>e.descriptionElementId),titleElementId:Pe(e=>e.titleElementId),viewportElement:Pe(e=>e.viewportElement),role:Pe(e=>e.role)};class FZ extends MA{constructor(t){super(HZ(t),{popupRef:_.createRef(),backdropRef:_.createRef(),internalBackdropRef:_.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:new ux,onOpenChange:void 0,onOpenChangeComplete:void 0},BZ)}setOpen=(t,n)=>{if(n.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},!t&&n.trigger==null&&this.state.activeTriggerId!=null&&(n.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(t,n),n.isCanceled)return;const s={open:t,nativeEvent:n.event,reason:n.reason,nested:this.state.nested};this.state.floatingRootContext.context.events?.emit("openchange",s);const i={open:t},a=n.trigger?.id??null;(a||t)&&(i.activeTriggerId=a,i.activeTriggerElement=n.trigger??null),this.update(i)}}function HZ(e={}){return{...bK(),modal:!0,disablePointerDismissal:!1,popupElement:null,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,role:"dialog",...e}}function qZ(e){const{children:t,open:n,defaultOpen:s=!1,onOpenChange:i,onOpenChangeComplete:a,disablePointerDismissal:l=!1,modal:f=!0,actionsRef:d,handle:p,triggerId:g,defaultTriggerId:y=null}=e,b=il(!0),x=!!b,S=zn(()=>p?.store??new FZ({open:s,openProp:n,activeTriggerId:y,triggerIdProp:g,modal:f,disablePointerDismissal:l,nested:x})).current;iV(()=>{n===void 0&&S.state.open===!1&&s===!0&&S.update({open:!0,activeTriggerId:y})}),S.useControlledProp("openProp",n),S.useControlledProp("triggerIdProp",g),S.useSyncedValues({disablePointerDismissal:l,nested:x,modal:f}),S.useContextCallback("onOpenChange",i),S.useContextCallback("onOpenChangeComplete",a);const w=S.useState("payload");$Z({store:S,actionsRef:d,parentContext:b?.store.context});const T=_.useMemo(()=>({store:S}),[S]);return h.jsx(ik.Provider,{value:T,children:typeof t=="function"?t({payload:w}):t})}const fk=_.forwardRef(function(t,n){const{render:s,className:i,id:a,...l}=t,{store:f}=il(),d=br(a);return f.useSyncedValueWithCleanup("titleElementId",d),zt("h2",t,{ref:n,props:[{id:d},l]})}),$r=qZ,VZ=_.forwardRef(({className:e,...t},n)=>h.jsx(px,{ref:n,className:ge("fixed inset-0 z-50 bg-black/60 backdrop-blur-sm",e),...t}));VZ.displayName="DialogOverlay";const hr=_.forwardRef(({className:e,children:t,...n},s)=>h.jsxs(uk,{children:[h.jsx(px,{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm"}),h.jsx(lk,{ref:s,className:ge("fixed z-50 top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-panel border border-border rounded-lg shadow-lg max-w-lg w-full p-0",e),...n,children:t})]}));hr.displayName="DialogContent";const pr=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("px-5 py-3 border-b border-border",e),...t}));pr.displayName="DialogHeader";const Nn=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("px-5 py-3 border-t border-border flex justify-end gap-2",e),...t}));Nn.displayName="DialogFooter";const mr=_.forwardRef(({className:e,...t},n)=>h.jsx(fk,{ref:n,className:ge("font-mono text-[10px] text-neutral-500 uppercase tracking-widest",e),...t}));mr.displayName="DialogTitle";const KZ=_.forwardRef(({className:e,...t},n)=>h.jsx(ak,{ref:n,className:ge("font-mono text-[10px] text-neutral-500",e),...t}));KZ.displayName="DialogDescription";const mx=_.forwardRef(({className:e,page:t,totalPages:n,totalItems:s,onPageChange:i,...a},l)=>h.jsxs("div",{ref:l,className:ge("px-5 py-2.5 border-t border-border flex items-center justify-between",e),...a,children:[h.jsxs("span",{className:"font-mono text-[10px] text-neutral-600",children:[s," items · Page ",t," of ",n]}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx(Me,{size:"sm",variant:"default",disabled:t<=1,onClick:()=>i(t-1),children:"Prev"}),h.jsx(Me,{size:"sm",variant:"default",disabled:t>=n,onClick:()=>i(t+1),children:"Next"})]})]}));mx.displayName="Pagination";const GZ=_.forwardRef(({className:e,orientation:t="horizontal",...n},s)=>h.jsx("hr",{ref:s,"aria-orientation":t==="vertical"?"vertical":void 0,className:ge("border-none m-0",t==="horizontal"?"h-px w-full bg-border":"w-px h-4 bg-border",e),...n}));GZ.displayName="Separator";const ZZ=gi("fixed z-50 bg-panel shadow-lg overflow-auto",{variants:{side:{top:"top-0 left-0 w-full h-[400px] border-b border-border",right:"right-0 top-0 h-full w-[400px] border-l border-border",bottom:"bottom-0 left-0 w-full h-[400px] border-t border-border",left:"left-0 top-0 h-full w-[400px] border-r border-border"}},defaultVariants:{side:"right"}}),YZ=_.forwardRef(({className:e,side:t,children:n,...s},i)=>h.jsxs(uk,{children:[h.jsx(px,{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm"}),h.jsx(lk,{ref:i,className:ge(ZZ({side:t,className:e})),...s,children:n})]}));YZ.displayName="SheetContent";const XZ=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("px-5 py-3 border-b border-border",e),...t}));XZ.displayName="SheetHeader";const QZ=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("px-5 py-3 border-t border-border flex justify-end gap-2",e),...t}));QZ.displayName="SheetFooter";const WZ=_.forwardRef(({className:e,...t},n)=>h.jsx(fk,{ref:n,className:ge("font-mono text-[10px] text-neutral-500 uppercase tracking-widest",e),...t}));WZ.displayName="SheetTitle";const JZ=_.forwardRef(({className:e,...t},n)=>h.jsx(ak,{ref:n,className:ge("text-sm text-neutral-400",e),...t}));JZ.displayName="SheetDescription";const eY=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("rounded-md bg-neutral-800 animate-pulse",e),...t}));eY.displayName="Skeleton";const tY=_.createContext(void 0);function gx(){const e=_.useContext(tY);if(e===void 0)throw new Error(yn(64));return e}let nY=(function(e){return e.activationDirection="data-activation-direction",e.orientation="data-orientation",e})({});const dk={tabActivationDirection:e=>({[nY.activationDirection]:e})},hk=_.createContext(void 0);function rY(){const e=_.useContext(hk);if(e===void 0)throw new Error(yn(65));return e}const sY=_.forwardRef(function(t,n){const{className:s,disabled:i=!1,render:a,value:l,id:f,nativeButton:d=!0,...p}=t,{value:g,getTabPanelIdByValue:y,orientation:b}=gx(),{activateOnFocus:x,highlightedTabIndex:S,onTabActivation:w,setHighlightedTabIndex:T,tabsListElement:C}=rY(),O=br(f),N=_.useMemo(()=>({disabled:i,id:O,value:l}),[i,O,l]),{compositeProps:R,compositeRef:M,index:z}=nk({metadata:N}),j=l===g,A=_.useRef(!1);Le(()=>{if(A.current){A.current=!1;return}if(!(j&&z>-1&&S!==z))return;const V=C;if(V!=null){const L=Fo(Rt(V));if(L&&Ot(V,L))return}i||T(z)},[j,z,S,T,i,C]);const{getButtonProps:P,buttonRef:Q}=Jc({disabled:i,native:d,focusableWhenDisabled:!0}),B=y(l),U=_.useRef(!1),Z=_.useRef(!1);function K(V){j||i||w(l,Yt(ii,V.nativeEvent,void 0,{activationDirection:"none"}))}function ee(V){j||(z>-1&&!i&&T(z),!i&&x&&(!U.current||U.current&&Z.current)&&w(l,Yt(ii,V.nativeEvent,void 0,{activationDirection:"none"})))}function D(V){if(j||i)return;U.current=!0;function L(){U.current=!1,Z.current=!1}(!V.button||V.button===0)&&(Z.current=!0,Rt(V.currentTarget).addEventListener("pointerup",L,{once:!0}))}return zt("button",t,{state:{disabled:i,active:j,orientation:b},ref:[n,Q,M],props:[R,{role:"tab","aria-controls":B,"aria-selected":j,id:O,onClick:K,onFocus:ee,onPointerDown:D,[rk]:j?"":void 0,onKeyDownCapture(){A.current=!0}},p,P]})});let oY=(function(e){return e.index="data-index",e.activationDirection="data-activation-direction",e.orientation="data-orientation",e.hidden="data-hidden",e})({});const iY={...dk,...ba},aY=_.forwardRef(function(t,n){const{className:s,value:i,render:a,keepMounted:l=!1,...f}=t,{value:d,getTabIdByPanelValue:p,orientation:g,tabActivationDirection:y,registerMountedTabPanel:b,unregisterMountedTabPanel:x}=gx(),S=br(),w=_.useMemo(()=>({id:S,value:i}),[S,i]),{ref:T,index:C}=hx({metadata:w}),O=i===d,{mounted:N,transitionStatus:R,setMounted:M}=Rp(O),z=!N,j=p(i),A={hidden:z,orientation:g,tabActivationDirection:y,transitionStatus:R},P=_.useRef(null),Q=zt("div",t,{state:A,ref:[n,T,P],props:[{"aria-labelledby":j,hidden:z,id:S,role:"tabpanel",tabIndex:O?0:-1,inert:dx(!O),[oY.index]:C},f],stateAttributesMapping:iY});return xa({open:O,ref:P,onComplete(){O||M(!1)}}),Le(()=>{if(!(z&&!l)&&S!=null)return b(i,S),()=>{x(i,S)}},[z,l,i,S,b,x]),l||N?Q:null}),cY=_.forwardRef(function(t,n){const{activateOnFocus:s=!1,className:i,loopFocus:a=!0,render:l,...f}=t,{getTabElementBySelectedValue:d,onValueChange:p,orientation:g,value:y,setTabMap:b,tabActivationDirection:x}=gx(),[S,w]=_.useState(0),[T,C]=_.useState(null),O=lY(y,g,T,d),N=Ae((j,A)=>{if(j!==y){const P=O(j);A.activationDirection=P,p(j,A)}}),R={orientation:g,tabActivationDirection:x},M={"aria-orientation":g==="vertical"?"vertical":void 0,role:"tablist"},z=_.useMemo(()=>({activateOnFocus:s,highlightedTabIndex:S,onTabActivation:N,setHighlightedTabIndex:w,tabsListElement:T,value:y}),[s,S,N,w,T,y]);return h.jsx(hk.Provider,{value:z,children:h.jsx(sk,{render:l,className:i,state:R,refs:[n,C],props:[M,f],stateAttributesMapping:dk,highlightedIndex:S,enableHomeAndEndKeys:!0,loopFocus:a,orientation:g,onHighlightedIndexChange:w,onMapChange:b,disabledIndices:Ru})})});function VC(e,t){const{left:n,top:s}=e.getBoundingClientRect(),{left:i,top:a}=t.getBoundingClientRect(),l=n-i,f=s-a;return{left:l,top:f}}function lY(e,t,n,s){const[i,a]=_.useState(null);return Le(()=>{if(e==null||n==null){a(null);return}const l=s(e);if(l==null){a(null);return}const{left:f,top:d}=VC(l,n);a(t==="horizontal"?f:d)},[t,s,n,e]),_.useCallback(l=>{if(l===e)return"none";if(l==null)return a(null),"none";if(l!=null&&n!=null){const f=s(l);if(f!=null){const{left:d,top:p}=VC(f,n);if(i==null)return a(t==="horizontal"?d:p),"none";if(t==="horizontal"){if(d<i)return a(d),"left";if(d>i)return a(d),"right"}else{if(p<i)return a(p),"up";if(p>i)return a(p),"down"}}}return"none"},[s,t,i,n,e])}const uY=_.forwardRef(({className:e,...t},n)=>h.jsx(cY,{ref:n,className:ge("flex items-center gap-0.5",e),...t}));uY.displayName="TabsList";const fY=gi("inline-flex items-center justify-center cursor-pointer transition-all outline-none",{variants:{variant:{default:"font-mono text-[10px] text-neutral-500 border border-transparent rounded-sm px-2.5 py-1 hover:text-neutral-300 data-[selected]:text-white data-[selected]:border-border-bright data-[selected]:bg-white/[0.03]",pills:"font-mono text-[10px] text-neutral-500 border border-transparent rounded-full px-3 py-1 hover:text-neutral-300 data-[selected]:text-white data-[selected]:border-border-bright data-[selected]:bg-white/[0.03]"}},defaultVariants:{variant:"default"}}),dY=_.forwardRef(({className:e,variant:t,...n},s)=>h.jsx(sY,{ref:s,className:ge(fY({variant:t,className:e})),...n}));dY.displayName="TabsTrigger";const hY=_.forwardRef(({className:e,...t},n)=>h.jsx(aY,{ref:n,className:ge("outline-none",e),...t}));hY.displayName="TabsContent";const pY=_.forwardRef(({className:e,...t},n)=>h.jsx("p",{ref:n,className:ge("font-mono text-[11px] text-neutral-300",e),...t}));pY.displayName="Text";const mY=_.forwardRef(({className:e,...t},n)=>h.jsx("p",{ref:n,className:ge("font-mono text-[10px] text-neutral-500",e),...t}));mY.displayName="TextMuted";const gY=_.forwardRef(({className:e,...t},n)=>h.jsx("code",{ref:n,className:ge("font-mono text-[11px] text-white",e),...t}));gY.displayName="TextCode";const yY=_.forwardRef(({className:e,...t},n)=>h.jsx("span",{ref:n,className:ge("font-mono text-[9px] uppercase tracking-wider text-neutral-500",e),...t}));yY.displayName="TextLabel";const vY=_.forwardRef(({className:e,...t},n)=>h.jsx("pre",{ref:n,className:ge("font-mono text-[11px] text-neutral-300 p-3 rounded border border-border bg-panel-alt overflow-x-auto",e),...t}));vY.displayName="CodeBlock";const bY="console:instance-id";function Lt(){const[e,t]=pi(bY,""),n=e.trim();return _.useMemo(()=>({instanceId:n.length>0?n:void 0,rawInstanceId:e,setInstanceId:t,clearInstanceId:()=>t("")}),[n,e,t])}const Jn={stats:e=>["console","stats",e],timeseries:e=>["console","stats","timeseries",e],latency:e=>["console","stats","latency",e],commits:e=>["console","commits",e],commitDetail:(e,t,n)=>["console","commit-detail",e,t,n],timeline:e=>["console","timeline",e],clients:e=>["console","clients",e],eventDetail:(e,t,n)=>["console","event-detail",e,t,n],eventPayload:(e,t,n)=>["console","event-payload",e,t,n],handlers:e=>["console","handlers",e],prunePreview:e=>["console","prune","preview",e],operations:e=>["console","operations",e],apiKeys:e=>["console","api-keys",e],storage:e=>["console","storage",e]};function _i(e,t){return e===0?!1:e??t}function nf(e,t){return t?{...e,instanceId:t}:e}function Sa(e){return encodeURIComponent(String(e))}function Ln(e,t,n){const s=e.endsWith("/")?e.slice(0,-1):e,i=n?.toString();return`${s}${t}${i?`?${i}`:""}`}function rf(e={}){const t=Vt(),{instanceId:n}=Lt(),s=e.instanceId??n,i=nf(e.partitionId?{partitionId:e.partitionId}:{},s);return Wn({queryKey:Jn.stats({partitionId:e.partitionId,instanceId:s}),queryFn:()=>{if(!t)throw new Error("Not connected");return Yu(t.GET("/console/stats",{params:{query:i}}))},enabled:!!t,refetchInterval:_i(e.refetchIntervalMs,5e3)})}function xY(e={},t={}){const n=Vt(),{config:s}=Dt(),{instanceId:i}=Lt(),a=e.instanceId??i;return Wn({queryKey:Jn.timeseries({...e,instanceId:a}),queryFn:async()=>{if(!n||!s)throw new Error("Not connected");const l=new URLSearchParams;e.interval&&l.set("interval",e.interval),e.range&&l.set("range",e.range),e.partitionId&&l.set("partitionId",e.partitionId),a&&l.set("instanceId",a);const f=await fetch(`${s.serverUrl}/console/stats/timeseries?${l}`,{headers:{Authorization:`Bearer ${s.token}`}});if(!f.ok)throw new Error("Failed to fetch timeseries stats");return f.json()},enabled:(t.enabled??!0)&&!!n&&!!s,refetchInterval:_i(t.refetchIntervalMs,3e4)})}function SY(e={},t={}){const n=Vt(),{config:s}=Dt(),{instanceId:i}=Lt(),a=e.instanceId??i;return Wn({queryKey:Jn.latency({...e,instanceId:a}),queryFn:async()=>{if(!n||!s)throw new Error("Not connected");const l=new URLSearchParams;e.range&&l.set("range",e.range),e.partitionId&&l.set("partitionId",e.partitionId),a&&l.set("instanceId",a);const f=await fetch(`${s.serverUrl}/console/stats/latency?${l}`,{headers:{Authorization:`Bearer ${s.token}`}});if(!f.ok)throw new Error("Failed to fetch latency stats");return f.json()},enabled:(t.enabled??!0)&&!!n&&!!s,refetchInterval:_i(t.refetchIntervalMs,3e4)})}function _Y(e={},t={}){const n=Vt(),{instanceId:s}=Lt(),i=e.instanceId??s,a=nf({limit:e.limit,offset:e.offset,partitionId:e.partitionId},i);return Wn({queryKey:Jn.commits({...e,instanceId:i}),queryFn:()=>{if(!n)throw new Error("Not connected");return Yu(n.GET("/console/commits",{params:{query:a}}))},enabled:(t.enabled??!0)&&!!n,refetchInterval:_i(t.refetchIntervalMs,1e4)})}function wY(e,t={}){const n=Vt(),{config:s}=Dt(),{instanceId:i}=Lt(),a=t.instanceId??i;return Wn({queryKey:Jn.commitDetail(e,t.partitionId,a),queryFn:async()=>{if(!n||!s)throw new Error("Not connected");if(e===void 0)throw new Error("Commit sequence is required");const l=new URLSearchParams;t.partitionId&&l.set("partitionId",t.partitionId),a&&l.set("instanceId",a);const f=l.toString(),d=await fetch(`${s.serverUrl}/console/commits/${Sa(e)}${f?`?${f}`:""}`,{headers:{Authorization:`Bearer ${s.token}`}});if(!d.ok)throw new Error("Failed to fetch commit detail");return d.json()},enabled:(t.enabled??!0)&&e!==void 0&&!!n})}function EY(e={},t={}){const n=Vt(),{instanceId:s}=Lt(),i=e.instanceId??s,a=nf({limit:e.limit,offset:e.offset,partitionId:e.partitionId,view:e.view,eventType:e.eventType,actorId:e.actorId,clientId:e.clientId,requestId:e.requestId,traceId:e.traceId,table:e.table,outcome:e.outcome,search:e.search,from:e.from,to:e.to},i);return Wn({queryKey:Jn.timeline({...e,instanceId:i}),queryFn:()=>{if(!n)throw new Error("Not connected");return Yu(n.GET("/console/timeline",{params:{query:a}}))},enabled:(t.enabled??!0)&&!!n,refetchInterval:_i(t.refetchIntervalMs,1e4)})}function pk(e={},t={}){const n=Vt(),{instanceId:s}=Lt(),i=e.instanceId??s,a=nf({limit:e.limit,offset:e.offset,partitionId:e.partitionId},i);return Wn({queryKey:Jn.clients({...e,instanceId:i}),queryFn:()=>{if(!n)throw new Error("Not connected");return Yu(n.GET("/console/clients",{params:{query:a}}))},enabled:(t.enabled??!0)&&!!n,refetchInterval:_i(t.refetchIntervalMs,1e4)})}function TY(e,t={}){const n=Vt(),{config:s}=Dt(),{instanceId:i}=Lt(),a=t.instanceId??i;return Wn({queryKey:Jn.eventDetail(e,t.partitionId,a),queryFn:async()=>{if(!n||!s)throw new Error("Not connected");if(e===void 0)throw new Error("Event id is required");const l=new URLSearchParams;t.partitionId&&l.set("partitionId",t.partitionId),a&&l.set("instanceId",a);const f=l.toString(),d=await fetch(`${s.serverUrl}/console/events/${Sa(e)}${f?`?${f}`:""}`,{headers:{Authorization:`Bearer ${s.token}`}});if(!d.ok)throw new Error("Failed to fetch event detail");return d.json()},enabled:(t.enabled??!0)&&e!==void 0&&!!n})}function CY(e,t={}){const n=Vt(),{config:s}=Dt(),{instanceId:i}=Lt(),a=t.instanceId??i;return Wn({queryKey:Jn.eventPayload(e,t.partitionId,a),queryFn:async()=>{if(!n||!s)throw new Error("Not connected");if(e===void 0)throw new Error("Event id is required");const l=new URLSearchParams;t.partitionId&&l.set("partitionId",t.partitionId),a&&l.set("instanceId",a);const f=l.toString(),d=await fetch(`${s.serverUrl}/console/events/${Sa(e)}/payload${f?`?${f}`:""}`,{headers:{Authorization:`Bearer ${s.token}`}});if(!d.ok)throw new Error("Failed to fetch event payload");return d.json()},enabled:(t.enabled??!0)&&e!==void 0&&!!n})}function RY(e={}){const t=Vt(),{config:n}=Dt(),{instanceId:s}=Lt(),i=e.instanceId??s;return Wn({queryKey:Jn.handlers(i),queryFn:async()=>{if(!t||!n)throw new Error("Not connected");const a=new URLSearchParams;i&&a.set("instanceId",i);const l=await fetch(Ln(n.serverUrl,"/console/handlers",a),{headers:{Authorization:`Bearer ${n.token}`}});if(!l.ok)throw new Error("Failed to fetch handlers");return l.json()},enabled:!!t&&!!n})}function NY(e={}){const t=Vt(),{config:n}=Dt(),{instanceId:s}=Lt(),i=e.instanceId??s;return Wn({queryKey:Jn.prunePreview(i),queryFn:async()=>{if(!t||!n)throw new Error("Not connected");const a=new URLSearchParams;i&&a.set("instanceId",i);const l=await fetch(Ln(n.serverUrl,"/console/prune/preview",a),{method:"POST",headers:{Authorization:`Bearer ${n.token}`}});if(!l.ok)throw new Error("Failed to fetch prune preview");return l.json()},enabled:!!t&&!!n&&(e.enabled??!0)})}function jY(e={},t={}){const n=Vt(),{instanceId:s}=Lt(),i=e.instanceId??s,a=nf({limit:e.limit,offset:e.offset,operationType:e.operationType,partitionId:e.partitionId},i);return Wn({queryKey:Jn.operations({...e,instanceId:i}),queryFn:()=>{if(!n)throw new Error("Not connected");return Yu(n.GET("/console/operations",{params:{query:a}}))},enabled:(t.enabled??!0)&&!!n,refetchInterval:_i(t.refetchIntervalMs,1e4)})}function AY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async({clientId:i,partitionId:a,instanceId:l})=>{if(!e||!t)throw new Error("Not connected");const f=l??n,d=new URLSearchParams;a&&d.set("partitionId",a),f&&d.set("instanceId",f);const p=await fetch(Ln(t.serverUrl,`/console/clients/${Sa(i)}`,d),{method:"DELETE",headers:{Authorization:`Bearer ${t.token}`}});if(!p.ok)throw new Error("Failed to evict client");return p.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","clients"]}),s.invalidateQueries({queryKey:["console","stats"]}),s.invalidateQueries({queryKey:["console","operations"]})}})}function kY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async()=>{if(!e||!t)throw new Error("Not connected");const i=new URLSearchParams;n&&i.set("instanceId",n);const a=await fetch(Ln(t.serverUrl,"/console/prune",i),{method:"POST",headers:{Authorization:`Bearer ${t.token}`}});if(!a.ok)throw new Error("Failed to prune");return a.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","stats"]}),s.invalidateQueries({queryKey:["console","commits"]}),s.invalidateQueries({queryKey:["console","timeline"]}),s.invalidateQueries({queryKey:["console","prune","preview"]}),s.invalidateQueries({queryKey:["console","operations"]})}})}function OY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async()=>{if(!e||!t)throw new Error("Not connected");const i=new URLSearchParams;n&&i.set("instanceId",n);const a=await fetch(Ln(t.serverUrl,"/console/compact",i),{method:"POST",headers:{Authorization:`Bearer ${t.token}`}});if(!a.ok)throw new Error("Failed to compact");return a.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","stats"]}),s.invalidateQueries({queryKey:["console","operations"]})}})}function MY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async i=>{if(!e||!t)throw new Error("Not connected");const a=i.instanceId??n,l=new URLSearchParams;a&&l.set("instanceId",a);const f=await fetch(Ln(t.serverUrl,"/console/notify-data-change",l),{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"Content-Type":"application/json"},body:JSON.stringify({tables:i.tables,partitionId:i.partitionId})});if(!f.ok)throw new Error("Failed to notify data change");return f.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","stats"]}),s.invalidateQueries({queryKey:["console","commits"]}),s.invalidateQueries({queryKey:["console","timeline"]}),s.invalidateQueries({queryKey:["console","operations"]})}})}function IY(e={}){const t=Vt(),{config:n}=Dt(),{instanceId:s}=Lt(),i=e.instanceId??s;return Wn({queryKey:Jn.apiKeys({...e,instanceId:i}),queryFn:async()=>{if(!t||!n)throw new Error("Not connected");const a=new URLSearchParams;e.limit!==void 0&&a.set("limit",String(e.limit)),e.offset!==void 0&&a.set("offset",String(e.offset)),e.type&&a.set("type",e.type),e.status&&a.set("status",e.status),e.expiresWithinDays!==void 0&&a.set("expiresWithinDays",String(e.expiresWithinDays)),i&&a.set("instanceId",i);const l=await fetch(Ln(n.serverUrl,"/console/api-keys",a),{headers:{Authorization:`Bearer ${n.token}`}});if(!l.ok)throw new Error("Failed to fetch API keys");return l.json()},enabled:!!t&&!!n})}function PY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async i=>{if(!e||!t)throw new Error("Not connected");const a=new URLSearchParams;n&&a.set("instanceId",n);const l=await fetch(Ln(t.serverUrl,"/console/api-keys",a),{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"Content-Type":"application/json"},body:JSON.stringify(i)});if(!l.ok)throw new Error("Failed to create API key");return l.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","api-keys"]})}})}function DY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async i=>{if(!e||!t)throw new Error("Not connected");const a=new URLSearchParams;n&&a.set("instanceId",n);const l=await fetch(Ln(t.serverUrl,`/console/api-keys/${Sa(i)}`,a),{method:"DELETE",headers:{Authorization:`Bearer ${t.token}`}});if(!l.ok)throw new Error("Failed to revoke API key");return l.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","api-keys"]})}})}function zY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async i=>{if(!e||!t)throw new Error("Not connected");const a=new URLSearchParams;n&&a.set("instanceId",n);const l=await fetch(Ln(t.serverUrl,"/console/api-keys/bulk-revoke",a),{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"Content-Type":"application/json"},body:JSON.stringify(i)});if(!l.ok)throw new Error("Failed to bulk revoke API keys");return l.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","api-keys"]})}})}function LY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async i=>{if(!e||!t)throw new Error("Not connected");const a=new URLSearchParams;n&&a.set("instanceId",n);const l=await fetch(Ln(t.serverUrl,`/console/api-keys/${Sa(i)}/rotate`,a),{method:"POST",headers:{Authorization:`Bearer ${t.token}`}});if(!l.ok)throw new Error("Failed to rotate API key");return l.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","api-keys"]})}})}function UY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async i=>{if(!e||!t)throw new Error("Not connected");const a=new URLSearchParams;n&&a.set("instanceId",n);const l=await fetch(Ln(t.serverUrl,`/console/api-keys/${Sa(i)}/rotate/stage`,a),{method:"POST",headers:{Authorization:`Bearer ${t.token}`}});if(!l.ok)throw new Error("Failed to stage-rotate API key");return l.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","api-keys"]})}})}function $Y(e={}){const{config:t}=Dt();return Wn({queryKey:Jn.storage({prefix:e.prefix,cursor:e.cursor,limit:e.limit}),queryFn:async()=>{if(!t)throw new Error("Not connected");const n=new URLSearchParams;e.prefix&&n.set("prefix",e.prefix),e.cursor&&n.set("cursor",e.cursor),e.limit&&n.set("limit",String(e.limit));const s=await fetch(Ln(t.serverUrl,"/console/storage",n),{method:"GET",headers:{Authorization:`Bearer ${t.token}`}});if(!s.ok)throw new Error("Failed to list blobs");return s.json()},enabled:!!t,refetchInterval:_i(e.refetchIntervalMs,3e4)})}function BY(){const{config:e}=Dt(),t=_r();return is({mutationFn:async n=>{if(!e)throw new Error("Not connected");const s=encodeURIComponent(n),i=await fetch(Ln(e.serverUrl,`/console/storage/${s}`,new URLSearchParams),{method:"DELETE",headers:{Authorization:`Bearer ${e.token}`}});if(!i.ok)throw new Error("Failed to delete blob");return i.json()},onSuccess:()=>{t.invalidateQueries({queryKey:["console","storage"]})}})}function FY(){const{config:e}=Dt();return async t=>{if(!e)throw new Error("Not connected");const n=encodeURIComponent(t),s=await fetch(Ln(e.serverUrl,`/console/storage/${n}/download`,new URLSearchParams),{method:"GET",headers:{Authorization:`Bearer ${e.token}`}});if(!s.ok)throw new Error("Failed to download blob");const i=await s.blob(),a=URL.createObjectURL(i),l=document.createElement("a");l.href=a,l.download=t.split("/").pop()||t,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(a)}}const HY="console:partition-id";function sf(){const[e,t]=pi(HY,""),n=e.trim();return _.useMemo(()=>({partitionId:n.length>0?n:void 0,rawPartitionId:e,setPartitionId:t,clearPartitionId:()=>t("")}),[n,e,t])}const KC={refreshInterval:5,timeFormat:"relative",showSparklines:!0,pageSize:20};function of(){const[e,t]=pi("console:preferences",KC);return{preferences:e,setPreferences:t,updatePreference:(i,a)=>{t(l=>({...l,[i]:a}))},resetPreferences:()=>{t(KC)}}}const qY=[{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"}],VY=[{value:10,label:"10"},{value:20,label:"20"},{value:50,label:"50"},{value:100,label:"100"}],yx="syncular-console-root";function KY(e){e.classList.add(yx)}const GY=[{suffix:"",label:"Command"},{suffix:"/stream",label:"Stream"},{suffix:"/fleet",label:"Fleet"},{suffix:"/ops",label:"Ops"},{suffix:"/storage",label:"Storage"},{suffix:"/config",label:"Config"}];function ZY(e){const t=e?.trim()??"";return!t||t==="/"?"":(t.startsWith("/")?t:`/${t}`).replace(/\/+$/g,"")}function Uy(e,t){return e?t?`${e}${t}`:e:t||"/"}function YY({basePath:e,appHref:t,modeBadge:n}){const{connect:s,config:i,isConnected:a,isConnecting:l}=Dt(),{preferences:f}=of(),{instanceId:d,rawInstanceId:p,setInstanceId:g,clearInstanceId:y}=Lt(),{partitionId:b,rawPartitionId:x,setPartitionId:S,clearPartitionId:w}=sf(),T=vr({select:P=>P.location.pathname}),{data:C}=rf({refetchIntervalMs:f.refreshInterval*1e3,partitionId:b,instanceId:d}),O=ZY(e),N=_.useMemo(()=>GY.map(P=>({...P,id:Uy(O,P.suffix)})),[O]),R=Uy(O,""),M=Uy(O,"/config"),z=l?"connecting":a?"connected":i?"disconnected":"not-configured",j=N.find(P=>P.suffix===""?T===R||T===`${R}/`:T.startsWith(P.id))?.id??R,A=C?[{label:"HEAD",value:`#${C.maxCommitSeq}`},{label:"COMMITS",value:`${C.commitCount}`},{label:"CHANGES",value:`${C.changeCount}`},{label:"CLIENTS",value:`${C.activeClientCount}/${C.clientCount}`}]:[];return h.jsxs("div",{className:`${yx} h-screen bg-background text-foreground flex flex-col`,children:[h.jsx(MZ,{brand:h.jsx(bc,{to:R,children:h.jsx(OZ,{label:"console"})}),center:h.jsx(TZ,{items:N,activeId:j,renderItem:(P,{active:Q})=>h.jsx(bc,{to:P.id,children:h.jsx(ok,{active:Q,children:P.label})},P.id)}),right:h.jsxs("div",{className:"flex items-center gap-2",children:[n?h.jsx(mn,{variant:"flow",className:"hidden md:inline-flex px-2 py-1 text-[10px]",children:n}):null,h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("span",{className:"font-mono text-[9px] text-neutral-500 uppercase tracking-wide",children:"Instance"}),h.jsx(Gn,{variant:"mono",value:p,onChange:P=>g(P.target.value),onBlur:P=>g(P.target.value.trim()),placeholder:"all",className:"h-7 w-[110px] px-2 py-1"}),d?h.jsx(Me,{variant:"ghost",size:"sm",className:"h-7 px-2 text-[10px]",onClick:y,children:"All"}):null]}),h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("span",{className:"font-mono text-[9px] text-neutral-500 uppercase tracking-wide",children:"Partition"}),h.jsx(Gn,{variant:"mono",value:x,onChange:P=>S(P.target.value),onBlur:P=>S(P.target.value.trim()),placeholder:"all",className:"h-7 w-[110px] px-2 py-1"}),b?h.jsx(Me,{variant:"ghost",size:"sm",className:"h-7 px-2 text-[10px]",onClick:w,children:"All"}):null]}),h.jsx(N8,{state:z}),h.jsx(bc,{to:M,children:h.jsx(Me,{variant:T===M?"secondary":"ghost",size:"icon",children:h.jsx(V8,{className:"h-3 w-3"})})}),t?h.jsxs("a",{href:t,className:EZ,children:[h.jsx(H8,{className:"h-3 w-3"}),"Go to app"]}):null]})}),h.jsx("main",{className:"flex-1 overflow-auto pb-[32px]",children:h.jsx("div",{className:"min-h-full",children:a||T===M?h.jsx("div",{style:{animation:"pageIn 0.3s ease-out"},children:h.jsx(XN,{})},T):h.jsx(XY,{configPath:M,hasSavedConfig:!!i,isConnecting:l,onConnect:()=>{s()}})})}),a&&h.jsx(Bj,{isLive:a,metrics:A,uptime:"--"})]})}function XY({configPath:e,hasSavedConfig:t,isConnecting:n,onConnect:s}){return h.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[h.jsx("p",{className:"mb-4 text-foreground-muted",children:"Not connected to a @syncular server"}),h.jsxs("div",{className:"flex items-center gap-2",children:[t&&h.jsx(Me,{variant:"default",onClick:s,disabled:n,children:n?"Connecting...":"Connect"}),h.jsx(bc,{to:e,children:h.jsx(Me,{variant:"link",children:"Configure connection"})})]})]})}const uo=NH({component:YY});function QY(){return typeof window>"u"?!1:new URLSearchParams(window.location.search).get("swServer")==="1"}function WY(e={}){const{maxEvents:t=100,enabled:n=!0,staleAfterMs:s=65e3,replayLimit:i=100,partitionId:a,instanceId:l}=e,{config:f,isConnected:d}=Dt(),{instanceId:p}=Lt(),g=l??p,[y,b]=_.useState([]),[x,S]=_.useState(!1),[w,T]=_.useState("disconnected"),[C,O]=_.useState(null),N=_.useRef(null),R=_.useRef(null),M=_.useRef(null),z=_.useRef(0),j=_.useRef(0),A=_.useRef(null),P=_.useRef(null),Q=_.useCallback(()=>{b([]),A.current=null,P.current=null},[]);return _.useEffect(()=>{if(!n||!d||!f?.serverUrl||!f?.token)return;let B=!1;const U=Number.isFinite(i)?Math.max(1,Math.min(500,Math.floor(i))):100;if(QY()||typeof WebSocket>"u"){T("connecting"),S(!1);let V=null,L=!1;const I=async()=>{if(!(B||L)){L=!0;try{const H=new URL(f.serverUrl,window.location.origin),W=H.pathname.endsWith("/")?H.pathname.slice(0,-1):H.pathname;H.pathname=`${W}/console/events`,H.search="",H.searchParams.set("limit",String(U)),H.searchParams.set("offset","0"),a&&H.searchParams.set("partitionId",a);const Y=await fetch(H.toString(),{headers:{Authorization:`Bearer ${f.token}`}});if(!Y.ok)throw new Error(`Live event polling failed (${Y.status})`);const ae=await Y.json(),fe=(Array.isArray(ae.items)?ae.items:[]).filter(Oe=>g?Oe.instanceId===g:!0).sort((Oe,_e)=>Oe.eventId-_e.eventId),Se=P.current??-1,pe=fe.filter(Oe=>Oe.eventId>Se);if(pe.length>0){const Oe=pe.map(re=>({type:re.eventType,timestamp:re.createdAt,data:re})).reverse();b(re=>[...Oe,...re].slice(0,t));const _e=pe[pe.length-1];P.current=_e.eventId,A.current=_e.createdAt}else if(fe.length>0){const Oe=fe[fe.length-1];P.current=Math.max(P.current??-1,Oe.eventId),A.current=Oe.createdAt}O(null),S(!0),T("connected")}catch(H){B||(S(!1),T("disconnected"),O(H instanceof Error?H:new Error("Live event polling failed")))}finally{L=!1}}};return I(),V=setInterval(()=>{I()},2e3),()=>{B=!0,V&&clearInterval(V),S(!1),T("disconnected")}}const K=()=>{R.current&&(clearTimeout(R.current),R.current=null)},ee=()=>{M.current&&(clearInterval(M.current),M.current=null)},D=()=>{if(B||R.current)return;z.current+=1;const V=Math.min(3e4,1e3*2**Math.max(0,z.current-1)),L=Math.floor(V*.2*Math.random()),I=V+L;R.current=setTimeout(()=>{R.current=null,B||q()},I)},G=()=>{j.current=Date.now(),S(!0),T("connected")},q=()=>{if(B)return;T("connecting"),K();const V=(()=>{const I=new URL(f.serverUrl,window.location.origin);I.protocol=I.protocol==="https:"?"wss:":"ws:";const H=I.pathname.endsWith("/")?I.pathname.slice(0,-1):I.pathname;return I.pathname=`${H}/console/events/live`,I.search="",I.searchParams.set("token",f.token),A.current&&I.searchParams.set("since",A.current),I.searchParams.set("replayLimit",String(U)),a&&I.searchParams.set("partitionId",a),g&&I.searchParams.set("instanceId",g),I.toString()})(),L=new WebSocket(V);N.current=L,L.onopen=()=>{if(B){L.close();return}z.current=0,G(),O(null),ee(),M.current=setInterval(()=>{const I=N.current;if(!I||I.readyState!==WebSocket.OPEN)return;const H=j.current;!H||Date.now()-H<=s||(S(!1),T("stale"),I.close())},1e3)},L.onclose=()=>{B||(S(!1),T("disconnected"),ee(),D())},L.onerror=()=>{B||O(new Error("WebSocket connection failed"))},L.onmessage=I=>{try{const H=JSON.parse(I.data),W=H.type;if(G(),W==="connected"||W==="heartbeat")return;const Y={type:W,timestamp:H.timestamp||new Date().toISOString(),data:H};if(a&&Y.data.partitionId!==a||g&&Y.data.instanceId!==g)return;const ae=Date.parse(A.current??""),se=Date.parse(Y.timestamp);Number.isFinite(se)&&(!Number.isFinite(ae)||se>ae)&&(A.current=Y.timestamp),b(fe=>[Y,...fe].slice(0,t))}catch{}}};return q(),()=>{B=!0,K(),ee(),N.current&&(N.current.close(),N.current=null),S(!1),T("disconnected")}},[n,d,f?.serverUrl,f?.token,t,a,g,i,s]),{events:y,isConnected:x,connectionState:w,error:C,clearEvents:Q}}function JY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async()=>{if(!e||!t)throw new Error("Not connected");const i=new URLSearchParams;n&&i.set("instanceId",n);const a=i.toString(),l=await fetch(`${t.serverUrl}/console/events${a?`?${a}`:""}`,{method:"DELETE",headers:{Authorization:`Bearer ${t.token}`}});if(!l.ok)throw new Error("Failed to clear events");return l.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","events"]})}})}const eX=_.createContext(null);function mk(){const[e,t]=pi("console:time-range","24h");return{range:e,setRange:t}}const tX=[{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 nX(e){const t=e.toLowerCase();for(const n of tX)if(t.includes(n.hint))return n.type;return"client"}function rX(e){const t=e.toLowerCase();return t.includes("pglite")?"PGlite":t.includes("sqlite")||t.includes("wa-sqlite")?"SQLite":t.includes("postgres")||t.includes("pg")?"PostgreSQL":"unknown"}function sX(e,t){return typeof e.lagCommitCount=="number"?Math.max(0,e.lagCommitCount):t?Math.max(0,t.maxCommitSeq-e.cursor):0}function oX(e,t){return e.activityState==="stale"?"offline":t>0?"syncing":"online"}function iX(e,t){return e.length<=16?e:`${e.slice(0,12)}-${t+1}`}function aX(e,t,n={}){const s=n.maxNodes??10;return e.slice(0,s).map((i,a)=>{const l=sX(i,t),f=oX(i,l);return{id:iX(i.clientId,a),type:nX(i.clientId),status:f,cursor:Math.max(0,i.cursor),actor:i.actorId,mode:i.connectionMode,dialect:rX(i.clientId),scopes:Object.keys(i.effectiveScopes||{}),lastSeen:i.updatedAt}})}const cX={enabled:!1,thresholds:{p90Latency:500,errorRate:5,clientLag:100}};function GC(e,t="relative"){if(t==="absolute")return new Date(e).toLocaleString();const n=new Date(e),i=new Date().getTime()-n.getTime(),a=Math.floor(i/1e3);return a<60?`${a}s ago`:a<3600?`${Math.floor(a/60)}m ago`:a<86400?`${Math.floor(a/3600)}h ago`:`${Math.floor(a/86400)}d ago`}function lX(e){const t=e.length>1&&e.endsWith("/")?e.slice(0,-1):e;return t==="/console"||t.startsWith("/console/")?"/console/stream":"/stream"}function uX(){const e=dp(),t=_.useMemo(()=>typeof window>"u"?"/stream":lX(window.location.pathname),[]),n=mk(),{range:s}=n,{preferences:i}=of(),{partitionId:a}=sf(),l=i.refreshInterval*1e3,[f]=pi("console:alert-config",cX),[d,p]=_.useState("1h"),{data:g}=rf({refetchIntervalMs:l,partitionId:a}),{data:y}=xY({range:s,partitionId:a},{refetchIntervalMs:l}),{data:b}=SY({range:s,partitionId:a},{refetchIntervalMs:l}),{data:x}=_Y({limit:5,partitionId:a},{refetchIntervalMs:l}),{data:S}=pk({limit:12,offset:0,partitionId:a},{refetchIntervalMs:l}),{events:w,isConnected:T}=WY({maxEvents:8,partitionId:a}),C=_.useMemo(()=>{const U=y?.buckets??[];let Z=0,K=0;for(const D of U)Z+=D.pushCount+D.pullCount,K+=D.errorCount;const ee=Z>0?K/Z*100:0;return{totalEvents:Z,errorRate:ee}},[y?.buckets]),O=_.useMemo(()=>S?.items?aX(S.items,g,{maxNodes:12}):[],[S?.items,g]),N=O.filter(U=>U.status!=="offline").length,R=O.filter(U=>U.status==="offline").length,M=_.useMemo(()=>g?[{label:"Ops (Range)",value:C.totalEvents,color:"flow"},{label:"P50 Latency",value:b?.push?.p50??0,unit:"ms",color:"healthy"},{label:"Error Rate",value:`${C.errorRate.toFixed(1)}%`,color:C.errorRate>0?"offline":"muted"},{label:"Active Clients",value:g.activeClientCount,color:"syncing"},{label:"Pending",value:g.maxActiveClientCursor!==null&&g.maxCommitSeq>0?g.maxCommitSeq-(g.minActiveClientCursor??0):0,color:"relay"}]:[],[g,b,C.errorRate,C.totalEvents]),z=_.useMemo(()=>w.map(U=>({type:U.type.toUpperCase(),actor:U.data?.actorId??"",table:(U.data?.tables??[])[0]??"",time:GC(U.timestamp,i.timeFormat)})),[w,i.timeFormat]),j=_.useMemo(()=>{const U=y?.buckets;if(!U?.length)return[];const Z=Math.max(...U.map(K=>Math.max(K.pushCount,K.pullCount)),1);return U.map(K=>({pushPercent:Z>0?K.pushCount/Z*100:0,pullPercent:Z>0?K.pullCount/Z*100:0}))},[y?.buckets]),A=_.useMemo(()=>{if(!b)return[];const U=Math.max(b.push.p50,b.push.p90,b.push.p99,b.pull.p50,b.pull.p90,b.pull.p99,1);return[{label:"P50",pushMs:b.push.p50,pullMs:b.pull.p50,pushBarPercent:b.push.p50/U*100,pullBarPercent:b.pull.p50/U*100},{label:"P90",pushMs:b.push.p90,pullMs:b.pull.p90,pushBarPercent:b.push.p90/U*100,pullBarPercent:b.pull.p90/U*100},{label:"P99",pushMs:b.push.p99,pullMs:b.pull.p99,pushBarPercent:b.push.p99/U*100,pullBarPercent:b.pull.p99/U*100}]},[b]),P=_.useMemo(()=>x?.items?x.items.map(U=>({seq:U.commitSeq,actor:U.actorId,changes:U.changeCount,tables:(U.affectedTables??[]).join(", "),time:GC(U.createdAt,i.timeFormat)})):[],[x?.items,i.timeFormat]),Q=_.useMemo(()=>Math.max(0,100-C.errorRate),[C.errorRate]),B=_.useMemo(()=>{if(!f.enabled||!g)return[];const U=[];return b?.push?.p90&&b.push.p90>f.thresholds.p90Latency&&U.push(`P90 push latency (${b.push.p90}ms) exceeds threshold (${f.thresholds.p90Latency}ms)`),g.minActiveClientCursor!==null&&g.maxCommitSeq-g.minActiveClientCursor>f.thresholds.clientLag&&U.push(`Client lag (${g.maxCommitSeq-g.minActiveClientCursor}) exceeds threshold (${f.thresholds.clientLag})`),C.errorRate>f.thresholds.errorRate&&U.push(`Error rate (${C.errorRate.toFixed(1)}%) exceeds threshold (${f.thresholds.errorRate}%)`),U},[f,g,b,C.errorRate]);return g?h.jsx(eX.Provider,{value:n,children:h.jsxs("div",{className:"flex flex-col",children:[B.length>0&&h.jsx("div",{className:"px-6 pb-4",children:h.jsxs(In,{variant:"destructive",children:[h.jsx(tf,{children:"Threshold Exceeded"}),h.jsx(Pn,{children:B.map((U,Z)=>h.jsx("span",{className:"block",children:U},Z))})]})}),h.jsx(UA,{clients:O,totalNodes:O.length+2,onlineCount:N,offlineCount:R,relayClientIds:[]}),h.jsx(Yj,{items:M}),h.jsxs("div",{className:"flex",children:[h.jsxs("div",{className:"flex-1 min-w-0 flex flex-col",children:[h.jsx("div",{className:"border-b border-border border-r border-border",children:h.jsx(Sj,{bars:j,activeRange:d,onRangeChange:p})}),h.jsx("div",{className:"border-b border-border border-r border-border",children:h.jsx(Xj,{buckets:A,successRate:Q})}),h.jsx("div",{className:"border-r border-border",children:h.jsx(Fj,{commits:P,onViewAll:()=>e({href:t})})})]}),h.jsx(Qj,{entries:z,isConnected:T,maxVisible:20,maxHeight:"calc(100vh - 200px)"})]})]})}):h.jsx("div",{className:"flex items-center justify-center py-24",children:h.jsx(Pt,{size:"lg"})})}function fX(){return h.jsx(uX,{})}function dX({children:e}){return h.jsxs("div",{className:"space-y-4 px-5 py-5",children:[h.jsx(hX,{}),h.jsx(vX,{}),h.jsx(bX,{}),e]})}function hX(){const{clearError:e,config:t,connect:n,disconnect:s,error:i,isConnected:a,isConnecting:l}=Dt(),[f,d]=_.useState(t?.serverUrl??"/api"),[p,g]=_.useState(t?.token??""),[y,b]=_.useState(null),[x,S]=_.useState(!1),[w,T]=_.useState(null),[C,O]=pi("console:disconnect-clear-saved-config",!1);_.useEffect(()=>{const j=new URLSearchParams(window.location.search),A=j.get("token"),P=j.get("server");A&&(g(A),window.history.replaceState({},"",window.location.pathname)),P&&d(P)},[]),_.useEffect(()=>{t?.serverUrl&&d(t.serverUrl),t?.token&&g(t.token)},[t?.serverUrl,t?.token]),_.useEffect(()=>{T(null)},[]);const N=async()=>{e(),b(null);const j=await n({serverUrl:f.trim(),token:p.trim()},{persistOverride:!0});T(j?"Connected successfully and configuration saved.":"Failed to connect with the provided settings.")},R=()=>{s({clearSavedConfig:C}),C&&(d("/api"),g("")),T(C?"Disconnected and saved credentials cleared.":"Disconnected."),b(null)},M=async()=>{S(!0),b(null),T(null);const j=performance.now();try{const A=f.trim(),P=p.trim();if(!A||!P)throw new Error("Missing server URL or token");if(!(await fetch(`${A}/console/stats`,{headers:{Authorization:`Bearer ${P}`}})).ok)throw new Error("Failed to connect");b(Math.round(performance.now()-j))}catch{b(-1)}finally{S(!1)}},z=i??w??(y!==null?y<0?"Connection failed":`Connection successful (${y}ms latency)`:void 0);return h.jsx(qj,{isConnected:a,isConnecting:l,isTestingConnection:x,serverUrl:f,onServerUrlChange:d,consoleToken:p,onConsoleTokenChange:g,onSaveAndConnect:N,onDisconnect:R,onTestConnection:M,statusMessage:z,children:h.jsx("div",{className:"px-5 pb-5 -mt-2",children:h.jsxs("div",{className:"flex items-center justify-between rounded-md border border-border px-3 py-2",children:[h.jsxs("div",{children:[h.jsx("p",{className:"font-mono text-[10px] text-neutral-400",children:"Clear saved credentials on disconnect"}),h.jsx("p",{className:"font-mono text-[9px] text-neutral-500",children:"Removes stored server URL and token from this browser."})]}),h.jsx(Sp,{checked:C,onCheckedChange:O})]})})})}const pX=1440*60*1e3;function ZC(e){const t=e.trim();if(!t)return null;const n=Number.parseInt(t,10);return!Number.isInteger(n)||n<=0?null:n}function $y(e){if(!e)return"Never";const t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():"Invalid date"}function mX(e){return e.length===0?"all scopes":e.length<=2?e.join(", "):`${e.slice(0,2).join(", ")} +${e.length-2}`}function gX(e,t){if(e.revokedAt)return"revoked";if(!e.expiresAt)return"active";const n=Date.parse(e.expiresAt);if(!Number.isFinite(n))return"active";const s=Date.now();return n<=s?"expired":n<=s+t*pX?"expiring":"active"}function yX(e){return e==="revoked"?"destructive":e==="expired"?"offline":e==="expiring"?"syncing":"healthy"}function vX(){const[e,t]=_.useState("all"),[n,s]=_.useState("all"),[i,a]=_.useState("14"),[l,f]=_.useState(!1),[d,p]=_.useState(!1),[g,y]=_.useState(""),[b,x]=_.useState("relay"),[S,w]=_.useState(""),[T,C]=_.useState(""),[O,N]=_.useState(""),[R,M]=_.useState(null),[z,j]=_.useState([]),[A,P]=_.useState(null),[Q,B]=_.useState(null),[U,Z]=_.useState(null),[K,ee]=_.useState(null),[D,G]=_.useState(null),[q,V]=_.useState(null),[L,I]=_.useState(null),H=_.useMemo(()=>ZC(i),[i]),W=H??14,Y=_.useMemo(()=>ZC(O),[O]),ae=O.trim().length>0,se=!ae||Y!==null,fe=_.useMemo(()=>({type:e==="all"?void 0:e,status:n==="all"?void 0:n,expiresWithinDays:n==="expiring"?W:void 0}),[e,n,W]),{data:Se,isLoading:pe,error:Oe}=IY(fe),_e=PY(),re=zY(),he=DY(),ie=LY(),we=UY();_.useEffect(()=>{const me=new Set((Se?.items??[]).map(Te=>Te.keyId));j(Te=>Te.filter(qe=>me.has(qe)))},[Se?.items]);const ye=async()=>{try{const me=T.split(",").map(qe=>qe.trim()).filter(qe=>qe.length>0),Te=await _e.mutateAsync({name:g,keyType:b,actorId:S||void 0,scopeKeys:me.length>0?me:void 0,expiresInDays:ae?Y??void 0:void 0});M(Te.secretKey),y(""),w(""),C(""),N("")}catch{}},xe=me=>{navigator.clipboard.writeText(me),B(me),setTimeout(()=>B(null),2e3)},ve=async()=>{if(U)try{await he.mutateAsync(U)}finally{Z(null)}},Ie=async()=>{if(z.length!==0)try{const me=await re.mutateAsync({keyIds:z});P(me),j([])}catch{}},Ue=async()=>{if(K)try{const me=await we.mutateAsync(K.keyId);G({oldKeyId:K.keyId,oldKeyName:K.name,secretKey:me.secretKey})}catch{}},Ee=async()=>{if(D)try{await he.mutateAsync(D.oldKeyId)}finally{G(null),ee(null)}},Ve=async()=>{if(q)try{const me=await ie.mutateAsync(q);I(me.secretKey)}finally{V(null)}};if(pe)return h.jsx("div",{className:"flex h-[200px] items-center justify-center",children:h.jsx(Pt,{size:"lg"})});if(Oe)return h.jsx("div",{className:"flex h-[200px] items-center justify-center",children:h.jsxs("p",{className:"text-danger",children:["Failed to load API keys: ",Oe.message]})});const Qe=(Se?.items??[]).filter(me=>me.revokedAt===null).map(me=>me.keyId),Be=Qe.length>0&&Qe.every(me=>z.includes(me)),We=z.length>0,He=(Se?.items??[]).filter(me=>z.includes(me.keyId)).map(me=>me.name);return h.jsxs(h.Fragment,{children:[h.jsxs(Jb,{title:"API Keys",description:"Issue, rotate, revoke, and audit key lifecycle state.",actions:h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs(Me,{size:"sm",variant:"destructive",onClick:()=>p(!0),disabled:z.length===0,children:["Revoke Selected (",z.length,")"]}),h.jsx(Me,{size:"sm",onClick:()=>f(!0),children:"Create Key"})]}),children:[h.jsxs("div",{className:"mb-4 grid gap-3 lg:grid-cols-3",children:[h.jsxs(ms,{children:[h.jsx(es,{children:"Type filter"}),h.jsxs(dh,{value:[e],multiple:!1,onValueChange:me=>{const Te=me.find(qe=>typeof qe=="string");(Te==="all"||Te==="relay"||Te==="proxy"||Te==="admin")&&t(Te)},children:[h.jsx(Dr,{value:"all",children:"all"}),h.jsx(Dr,{value:"relay",children:"relay"}),h.jsx(Dr,{value:"proxy",children:"proxy"}),h.jsx(Dr,{value:"admin",children:"admin"})]})]}),h.jsxs(ms,{children:[h.jsx(es,{children:"Status filter"}),h.jsxs(dh,{value:[n],multiple:!1,onValueChange:me=>{const Te=me.find(qe=>typeof qe=="string");(Te==="all"||Te==="active"||Te==="revoked"||Te==="expiring")&&s(Te)},children:[h.jsx(Dr,{value:"all",children:"all"}),h.jsx(Dr,{value:"active",children:"active"}),h.jsx(Dr,{value:"revoked",children:"revoked"}),h.jsx(Dr,{value:"expiring",children:"expiring"})]})]}),h.jsxs(ms,{children:[h.jsx(es,{htmlFor:"api-key-expiring-window",children:"Expiring window (days)"}),h.jsx(pc,{children:"Used when status filter is set to expiring."}),h.jsx(Gn,{id:"api-key-expiring-window",placeholder:"14",value:i,inputMode:"numeric",onChange:me=>a(me.target.value)}),H===null&&i.trim().length>0?h.jsx("p",{className:"font-mono text-[10px] text-offline",children:"Enter a positive whole number."}):null]})]}),Se?.items.length===0?h.jsx(Qb,{message:"No API keys match the current filters."}):h.jsxs(tl,{children:[h.jsx(nl,{children:h.jsxs(ss,{children:[h.jsx(ht,{className:"w-[28px]",children:h.jsx(Uv,{checked:Be,indeterminate:!Be&&We&&Qe.length>0,onCheckedChange:me=>{j(me?Qe:[])},"aria-label":"Select all active keys"})}),h.jsx(ht,{className:"w-[100px]",children:"NAME"}),h.jsx(ht,{className:"w-[55px]",children:"TYPE"}),h.jsx(ht,{className:"w-[90px]",children:"KEY PREFIX"}),h.jsx(ht,{className:"w-[80px]",children:"ACTOR"}),h.jsx(ht,{className:"w-[100px]",children:"SCOPES"}),h.jsx(ht,{className:"w-[120px]",children:"CREATED"}),h.jsx(ht,{className:"w-[120px]",children:"LAST USED"}),h.jsx(ht,{className:"w-[120px]",children:"EXPIRES"}),h.jsx(ht,{className:"flex-1",children:"STATUS"})]})}),h.jsx(rl,{children:(Se?.items??[]).map(me=>{const Te=gX(me,W);return h.jsxs(ss,{className:"group relative",children:[h.jsx(pt,{className:"w-[28px]",children:h.jsx(Uv,{checked:z.includes(me.keyId),onCheckedChange:qe=>{j(mt=>qe?[...new Set([...mt,me.keyId])]:mt.filter(lt=>lt!==me.keyId))},"aria-label":`Select ${me.name}`,disabled:me.revokedAt!==null})}),h.jsx(pt,{className:"w-[100px] font-medium",children:me.name}),h.jsx(pt,{className:"w-[55px]",children:h.jsx(mn,{variant:me.keyType==="admin"?"flow":me.keyType==="proxy"?"ghost":"relay",children:me.keyType})}),h.jsx(pt,{className:"w-[90px]",children:h.jsxs("code",{className:"font-mono text-[11px]",children:[me.keyPrefix,"..."]})}),h.jsx(pt,{className:"w-[80px] text-neutral-500",children:me.actorId??"-"}),h.jsx(pt,{className:"w-[100px] text-neutral-500",children:h.jsx("code",{className:"font-mono text-[10px]",children:mX(me.scopeKeys)})}),h.jsx(pt,{className:"w-[120px] text-neutral-500",children:$y(me.createdAt)}),h.jsx(pt,{className:"w-[120px] text-neutral-500",children:$y(me.lastUsedAt)}),h.jsx(pt,{className:"w-[120px] text-neutral-500",children:$y(me.expiresAt)}),h.jsx(pt,{className:"flex-1",children:h.jsx(mn,{variant:yX(Te),children:Te})}),me.revokedAt===null&&h.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[h.jsx("button",{type:"button",onClick:()=>ee(me),className:"px-1.5 py-0.5 rounded text-[9px] font-mono text-neutral-600 hover:text-white hover:bg-white/[0.05] cursor-pointer transition-colors",children:"stage"}),h.jsx("button",{type:"button",onClick:()=>V(me.keyId),className:"px-1.5 py-0.5 rounded text-[9px] font-mono text-neutral-600 hover:text-white hover:bg-white/[0.05] cursor-pointer transition-colors",children:"rotate"}),h.jsx("button",{type:"button",onClick:()=>Z(me.keyId),className:"px-1.5 py-0.5 rounded text-[9px] font-mono text-neutral-600 hover:text-offline hover:bg-offline/10 cursor-pointer transition-colors",children:"revoke"})]})]},me.keyId)})})]})]}),h.jsx($r,{open:l,onOpenChange:f,children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Create API Key"})}),R?h.jsx(YC,{copiedKeyId:Q,onClose:()=>{M(null),f(!1)},onCopy:xe,secretKey:R,warning:"Copy this key now. You will not be able to view it again."}):h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[h.jsxs(ms,{children:[h.jsx(es,{htmlFor:"api-key-name",children:"Name"}),h.jsx(Gn,{id:"api-key-name",placeholder:"Backend Relay Key",value:g,onChange:me=>y(me.target.value)})]}),h.jsxs(ms,{children:[h.jsx(es,{children:"Key type"}),h.jsxs(dh,{value:[b],multiple:!1,onValueChange:me=>{const Te=me.find(qe=>typeof qe=="string");(Te==="relay"||Te==="proxy"||Te==="admin")&&x(Te)},children:[h.jsx(Dr,{value:"relay",children:"relay"}),h.jsx(Dr,{value:"proxy",children:"proxy"}),h.jsx(Dr,{value:"admin",children:"admin"})]})]}),h.jsxs(ms,{children:[h.jsx(es,{htmlFor:"api-key-actor-id",children:"Actor ID (optional)"}),h.jsx(pc,{children:"Pin this key to a fixed actor ID"}),h.jsx(Gn,{id:"api-key-actor-id",placeholder:"actor-123",value:S,onChange:me=>w(me.target.value)})]}),h.jsxs(ms,{children:[h.jsx(es,{htmlFor:"api-key-scope-keys",children:"Scope keys (optional)"}),h.jsx(pc,{children:"Comma-separated list of allowed scope keys"}),h.jsx(Gn,{id:"api-key-scope-keys",placeholder:"scope-a, scope-b",value:T,onChange:me=>C(me.target.value)})]}),h.jsxs(ms,{children:[h.jsx(es,{htmlFor:"api-key-expires-days",children:"Expires in days (optional)"}),h.jsx(pc,{children:"Leave empty to keep the key non-expiring."}),h.jsx(Gn,{id:"api-key-expires-days",placeholder:"30",value:O,inputMode:"numeric",onChange:me=>N(me.target.value)}),se?null:h.jsx("p",{className:"font-mono text-[10px] text-offline",children:"Enter a positive whole number."})]}),h.jsxs(Nn,{children:[h.jsx(Me,{variant:"default",onClick:()=>f(!1),children:"Cancel"}),h.jsx(Me,{variant:"primary",onClick:ye,disabled:_e.isPending||!g||!se,children:_e.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Creating..."]}):"Create"})]})]})]})}),h.jsx($r,{open:d,onOpenChange:me=>{p(me),me||P(null)},children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Bulk Revoke API Keys"})}),A?h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-3",children:[h.jsx(In,{variant:"destructive",children:h.jsxs(Pn,{children:["Requested ",A.requestedCount," keys. Revoked"," ",A.revokedCount,", already revoked"," ",A.alreadyRevokedCount,", not found"," ",A.notFoundCount,"."]})}),h.jsx(Nn,{children:h.jsx(Me,{variant:"primary",onClick:()=>{p(!1),P(null)},children:"Done"})})]}):h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-3",children:[h.jsx(In,{variant:"destructive",children:h.jsx(Pn,{children:"This revokes selected keys immediately and cannot be undone."})}),h.jsxs("p",{className:"font-mono text-[10px] text-neutral-500",children:["Selected keys: ",He.slice(0,5).join(", "),He.length>5?` +${He.length-5} more`:""]})]}),h.jsxs(Nn,{children:[h.jsx(Me,{variant:"default",onClick:()=>p(!1),children:"Cancel"}),h.jsx(Me,{variant:"destructive",onClick:Ie,disabled:re.isPending||z.length===0,children:re.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Revoking..."]}):"Revoke Selected"})]})]})]})}),h.jsx($r,{open:K!==null||D!==null,onOpenChange:()=>{ee(null),G(null)},children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Stage Rotate API Key"})}),D?h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[h.jsx(In,{variant:"default",children:h.jsxs(Pn,{children:["Replacement key created for ",D.oldKeyName,". The old key is still active until you revoke it."]})}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("code",{className:"flex-1 rounded-md border border-border bg-surface p-3 font-mono text-[11px] text-white break-all",children:D.secretKey}),h.jsx(Me,{variant:"default",size:"sm",onClick:()=>xe(D.secretKey),children:Q===D.secretKey?"Copied":"Copy"})]}),h.jsxs(Nn,{children:[h.jsx(Me,{variant:"default",onClick:()=>{G(null),ee(null)},children:"Keep Old Key Active"}),h.jsx(Me,{variant:"destructive",onClick:Ee,disabled:he.isPending,children:he.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Revoking Old Key..."]}):"Finalize and Revoke Old Key"})]})]}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"px-5 py-4",children:h.jsx("p",{className:"font-mono text-[10px] text-neutral-500",children:"Staged rotation creates a replacement key now and keeps the current key active until you explicitly revoke it."})}),h.jsxs(Nn,{children:[h.jsx(Me,{variant:"default",onClick:()=>ee(null),children:"Cancel"}),h.jsx(Me,{variant:"primary",onClick:Ue,disabled:we.isPending||!K,children:we.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Staging..."]}):"Create Replacement Key"})]})]})]})}),h.jsx($r,{open:U!==null,onOpenChange:()=>Z(null),children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Revoke API Key"})}),h.jsx("div",{className:"px-5 py-4",children:h.jsx(In,{variant:"destructive",children:h.jsx(Pn,{children:"Revoking a key immediately invalidates it for all requests."})})}),h.jsxs(Nn,{children:[h.jsx(Me,{variant:"default",onClick:()=>Z(null),children:"Cancel"}),h.jsx(Me,{variant:"destructive",onClick:ve,disabled:he.isPending,children:he.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Revoking..."]}):"Revoke"})]})]})}),h.jsx($r,{open:q!==null||L!==null,onOpenChange:()=>{V(null),I(null)},children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Rotate API Key"})}),L?h.jsx(YC,{copiedKeyId:Q,onClose:()=>I(null),onCopy:xe,secretKey:L,warning:"The previous key has been invalidated. Store this replacement securely."}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"px-5 py-4",children:h.jsx("p",{className:"font-mono text-[10px] text-neutral-500",children:"Rotating a key invalidates the previous secret immediately."})}),h.jsxs(Nn,{children:[h.jsx(Me,{variant:"default",onClick:()=>V(null),children:"Cancel"}),h.jsx(Me,{variant:"primary",onClick:Ve,disabled:ie.isPending,children:ie.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Rotating..."]}):"Rotate"})]})]})]})})]})}function bX(){const{preferences:e,updatePreference:t,resetPreferences:n}=of(),s=[{type:"filter",label:"Auto-refresh interval",options:qY.map(i=>({id:`${i.value}`,label:i.label})),activeId:`${e.refreshInterval}`,onActiveChange:i=>t("refreshInterval",Number.parseInt(i,10))},{type:"filter",label:"Items per page",options:VY.map(i=>({id:`${i.value}`,label:i.label})),activeId:`${e.pageSize}`,onActiveChange:i=>t("pageSize",Number.parseInt(i,10))},{type:"filter",label:"Time format",options:[{id:"relative",label:"Relative"},{id:"absolute",label:"Absolute"}],activeId:e.timeFormat,onActiveChange:i=>t("timeFormat",i)},{type:"toggle",label:"Show sparklines",description:"Display mini trend charts in dashboard metric cards",checked:e.showSparklines,onCheckedChange:i=>t("showSparklines",i)}];return h.jsx(Wj,{rows:s,onResetDefaults:n})}function YC({copiedKeyId:e,onClose:t,onCopy:n,secretKey:s,warning:i}){return h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[h.jsx(In,{variant:"destructive",children:h.jsx(Pn,{children:i})}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("code",{className:"flex-1 rounded-md border border-border bg-surface p-3 font-mono text-[11px] text-white break-all",children:s}),h.jsx(Me,{variant:"default",size:"sm",onClick:()=>n(s),children:e===s?"Copied":"Copy"})]}),h.jsx(Nn,{children:h.jsx(Me,{variant:"primary",onClick:t,children:"Done"})})]})}function xX(e){const t=e.toLowerCase();return t.includes("mobile")||t.includes("ios")||t.includes("android")?"mobile":t.includes("tablet")?"tablet":t.includes("desktop")||t.includes("laptop")?"desktop":t.includes("edge")?"edge":t.includes("iot")?"iot":"desktop"}function SX(e){const t=e.toLowerCase();return t.includes("pglite")?"PGlite":t.includes("wa-sqlite")||t.includes("sqlite")?"SQLite":t.includes("postgres")||t.includes("pg")?"PostgreSQL":"unknown"}function _X(e,t){if(t==="absolute")return new Date(e).toLocaleString();try{const n=new Date(e),i=new Date().getTime()-n.getTime(),a=Math.floor(i/1e3),l=Math.floor(a/60),f=Math.floor(l/60),d=Math.floor(f/24);return a<60?"just now":l<60?`${l}m ago`:f<24?`${f}h ago`:`${d}d ago`}catch{return e}}function wX(e,t,n){return{id:e.clientId,type:xX(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:SX(e.clientId),scopes:Object.keys(e.effectiveScopes??{}),lastSeen:_X(e.updatedAt,n)}}function EX({emptyState:e}={}){const[t,n]=_.useState(1),[s,i]=_.useState(null),{preferences:a}=of(),{partitionId:l}=sf(),f=a.pageSize,d=a.refreshInterval*1e3,{data:p,isLoading:g}=rf({refetchIntervalMs:d,partitionId:l}),{data:y,isLoading:b,error:x}=pk({limit:f,offset:(t-1)*f,partitionId:l},{refetchIntervalMs:d}),S=AY(),w=Math.ceil((y?.total??0)/f),T=p?.maxCommitSeq??0;_.useEffect(()=>{n(1)},[]);const C=async()=>{if(s)try{await S.mutateAsync({clientId:s,partitionId:l})}finally{i(null)}};if(b||g)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsx(Pt,{size:"lg"})});if(x)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsxs("p",{className:"text-danger",children:["Failed to load clients: ",x.message]})});const O=(y?.items??[]).map(N=>wX(N,T,a.timeFormat));return h.jsxs("div",{className:"flex flex-col gap-5 px-5 py-5",children:[O.length>0&&h.jsx(eA,{clients:O,headSeq:T}),O.length===0?e??h.jsx(eV,{children:h.jsx(Qb,{message:"No clients yet"})}):h.jsx(Gj,{clients:O,headSeq:T,onEvict:N=>{const R=y?.items.find(M=>M.clientId===N);i(R?.clientId??N)}}),w>1&&h.jsx(mx,{page:t,totalPages:w,totalItems:y?.total??0,onPageChange:n}),h.jsx($r,{open:s!==null,onOpenChange:()=>i(null),children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Evict Client"})}),h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[h.jsxs("p",{className:"font-mono text-[11px] text-neutral-300",children:["Are you sure you want to evict client"," ",h.jsxs("span",{className:"font-mono text-white",children:[s?.slice(0,12),"..."]}),"?"]}),h.jsx("p",{className:"font-mono text-[10px] text-neutral-500",children:"This will force the client to re-bootstrap on their next sync."})]}),h.jsxs(Nn,{children:[h.jsx(Me,{variant:"default",onClick:()=>i(null),children:"Cancel"}),h.jsx(Me,{variant:"destructive",onClick:C,disabled:S.isPending,children:S.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Evicting..."]}):"Evict"})]})]})})]})}const TX={latencyThresholdMs:1e3,errorRateThreshold:5,clientLagThreshold:50,enabled:!1};function CX(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 RX(e){const t=e.split(",").map(n=>n.trim()).filter(n=>n.length>0);return Array.from(new Set(t))}function NX(e){switch(e){case"notify_data_change":return"Notify";case"evict_client":return"Evict";case"compact":return"Compact";default:return"Prune"}}function XC(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function jX(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function AX(e){const t=XC(e.requestPayload),n=XC(e.resultPayload);if(e.operationType==="notify_data_change"){const a=jX(t?.tables),l=n?.commitSeq;return`${a.length} table${a.length===1?"":"s"} -> commit #${typeof l=="number"?l:"?"}`}if(e.operationType==="evict_client"){const a=n?.evicted===!0?"evicted":"not found";return`client ${e.targetClientId??"?"} ${a}`}if(e.operationType==="compact")return`${typeof n?.deletedChanges=="number"?n.deletedChanges:0} changes removed`;const s=typeof n?.deletedCommits=="number"?n.deletedCommits:0,i=typeof t?.watermarkCommitSeq=="number"?` at #${t.watermarkCommitSeq}`:"";return`${s} commits removed${i}`}function kX(e){const t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function OX(){const{partitionId:e}=sf();return h.jsxs("div",{className:"flex flex-col gap-4 px-5 py-5",children:[h.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[h.jsx(MX,{}),h.jsx(LX,{})]}),h.jsxs("div",{className:"grid gap-4 xl:grid-cols-3",children:[h.jsx(IX,{partitionId:e}),h.jsx(PX,{partitionId:e}),h.jsx(DX,{partitionId:e})]}),h.jsx(zX,{partitionId:e})]})}function MX(){const{data:e,isLoading:t,error:n}=RY();if(t)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsx(Pt,{size:"lg"})});if(n)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsxs("p",{className:"text-danger",children:["Failed to load handlers: ",n.message]})});const s=(e?.items??[]).map(i=>({table:i.table,dependsOn:i.dependsOn?.join(", ")??null,chunkTtl:i.snapshotChunkTtlMs?CX(i.snapshotChunkTtlMs):"default"}));return h.jsx(Zj,{handlers:s,tableCount:e?.items.length??0})}function IX({partitionId:e}){const[t,n]=_.useState(!1),[s,i]=_.useState(null),{data:a,isLoading:l}=rf({partitionId:e}),{data:f,isLoading:d,refetch:p}=NY({enabled:!1}),g=kY(),y=async()=>{n(!0),i(null),await p()},b=async()=>{const S=await g.mutateAsync();i(S.deletedCommits)};if(l)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsx(Pt,{size:"lg"})});const x=[{label:"Total commits",value:a?.commitCount??0},{label:"Commit range",value:`${a?.minCommitSeq??0} - ${a?.maxCommitSeq??0}`},{label:"Min active cursor",value:a?.minActiveClientCursor??"N/A",tone:"syncing"}];return h.jsxs(h.Fragment,{children:[h.jsx(_p,{title:"Prune",description:"Delete commits that all clients have already synced. Pruning removes commits older than the oldest active client cursor.",dotColor:"syncing",stats:x,actionLabel:"Preview Prune",actionVariant:"destructive",onAction:y}),h.jsx($r,{open:t,onOpenChange:n,children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Prune Old Commits"})}),h.jsx("div",{className:"px-5 py-4 flex flex-col gap-4",children:s!==null?h.jsxs(In,{variant:"default",children:[h.jsx(tf,{children:"Pruning Complete"}),h.jsxs(Pn,{children:["Successfully deleted ",h.jsx("strong",{children:s})," commits."]})]}):d?h.jsx("div",{className:"flex items-center justify-center py-8",children:h.jsx(Pt,{size:"sm"})}):f?h.jsxs(h.Fragment,{children:[h.jsx(In,{variant:f.commitsToDelete>0?"destructive":"default",children:h.jsx(Pn,{children:f.commitsToDelete>0?h.jsxs(h.Fragment,{children:["This will delete"," ",h.jsx("strong",{children:f.commitsToDelete})," commits up to sequence"," ",h.jsxs("code",{className:"font-mono",children:["#",f.watermarkCommitSeq]}),"."]}):"No commits are eligible for pruning."})}),h.jsxs("div",{className:"flex flex-col gap-2",children:[h.jsxs("div",{className:"flex justify-between font-mono text-[11px]",children:[h.jsx("span",{className:"text-neutral-500",children:"Watermark commit seq:"}),h.jsxs("span",{className:"text-white",children:["#",f.watermarkCommitSeq]})]}),h.jsxs("div",{className:"flex justify-between font-mono text-[11px] items-center",children:[h.jsx("span",{className:"text-neutral-500",children:"Commits to delete:"}),h.jsx(mn,{variant:f.commitsToDelete>0?"offline":"ghost",children:f.commitsToDelete})]})]})]}):null}),h.jsxs(Nn,{children:[h.jsx(Me,{variant:"default",onClick:()=>n(!1),children:s!==null?"Close":"Cancel"}),s===null&&h.jsx(Me,{variant:"destructive",onClick:b,disabled:g.isPending||d||(f?.commitsToDelete??0)===0,children:g.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Pruning..."]}):"Prune Now"})]})]})})]})}function PX({partitionId:e}){const[t,n]=_.useState(!1),[s,i]=_.useState(null),{data:a,isLoading:l}=rf({partitionId:e}),f=OY(),d=()=>{n(!0),i(null)},p=async()=>{const y=await f.mutateAsync();i(y.deletedChanges)};if(l)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsx(Pt,{size:"lg"})});const g=[{label:"Total changes",value:a?.changeCount??0},{label:"Total commits",value:a?.commitCount??0}];return h.jsxs(h.Fragment,{children:[h.jsx(_p,{title:"Compact",description:"Merge old changes to reduce storage space. Compaction merges multiple changes to the same row into a single change.",dotColor:"flow",stats:g,actionLabel:"Run Compaction",actionVariant:"primary",onAction:d}),h.jsx($r,{open:t,onOpenChange:n,children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Compact Changes"})}),h.jsx("div",{className:"px-5 py-4 flex flex-col gap-4",children:s!==null?h.jsxs(In,{variant:"default",children:[h.jsx(tf,{children:"Compaction Complete"}),h.jsxs(Pn,{children:["Successfully removed ",h.jsx("strong",{children:s})," redundant changes."]})]}):h.jsx(In,{variant:"default",children:h.jsx(Pn,{children:"Compaction will merge multiple changes to the same row, keeping only the most recent version. This is safe and can be run at any time."})})}),h.jsxs(Nn,{children:[h.jsx(Me,{variant:"default",onClick:()=>n(!1),children:s!==null?"Close":"Cancel"}),s===null&&h.jsx(Me,{variant:"primary",onClick:p,disabled:f.isPending,children:f.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Compacting..."]}):"Compact Now"})]})]})})]})}function DX({partitionId:e}){const[t,n]=_.useState(!1),[s,i]=_.useState("tasks"),[a,l]=_.useState(e??""),[f,d]=_.useState(null),[p,g]=_.useState(null),y=MY(),b=RX(s),x=[{label:"Next tables",value:b.length,tone:"syncing"},{label:"Last commit seq",value:f?`#${f.commitSeq}`:"—",tone:"syncing"},{label:"Last chunks cleared",value:f?.deletedChunks??"—"}],S=()=>{n(!0),g(null)},w=async()=>{if(b.length===0){g("Provide at least one table name.");return}g(null);const T=await y.mutateAsync({tables:b,partitionId:a.trim()||void 0});d(T)};return h.jsxs(h.Fragment,{children:[h.jsx(_p,{title:"Notify Data Change",description:"Create a synthetic commit after external imports or direct DB writes so clients re-bootstrap for affected tables.",dotColor:"healthy",stats:x,actionLabel:"Notify Clients",actionVariant:"primary",onAction:S}),h.jsx($r,{open:t,onOpenChange:n,children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Notify External Data Change"})}),h.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4",children:[f?h.jsxs(In,{variant:"default",children:[h.jsx(tf,{children:"Notification Sent"}),h.jsxs(Pn,{children:["Created synthetic commit"," ",h.jsxs("strong",{children:["#",f.commitSeq]})," for"," ",h.jsx("strong",{children:f.tables.length})," table",f.tables.length===1?"":"s"," and cleared"," ",h.jsx("strong",{children:f.deletedChunks})," cached chunk",f.deletedChunks===1?"":"s","."]})]}):h.jsx(In,{variant:"default",children:h.jsx(Pn,{children:"Use this when data changed outside Syncular push flow. It invalidates cached snapshot chunks and forces clients to pull fresh data."})}),p?h.jsx(In,{variant:"destructive",children:h.jsx(Pn,{children:p})}):null,h.jsxs(ms,{children:[h.jsx(es,{children:"Tables (comma-separated)"}),h.jsx(Gn,{value:s,onChange:T=>i(T.target.value),placeholder:"tasks, notes",disabled:y.isPending}),h.jsx(pc,{children:"Enter one or more table names affected by the external change."})]}),h.jsxs(ms,{children:[h.jsx(es,{children:"Partition ID (optional)"}),h.jsx(Gn,{value:a,onChange:T=>l(T.target.value),placeholder:"default",disabled:y.isPending})]})]}),h.jsxs(Nn,{children:[h.jsx(Me,{variant:"default",onClick:()=>n(!1),children:f?"Close":"Cancel"}),f?null:h.jsx(Me,{variant:"primary",onClick:w,disabled:y.isPending,children:y.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Notifying..."]}):"Notify Data Change"})]})]})})]})}function zX({partitionId:e}){const[t,n]=_.useState("all"),{data:s,isLoading:i,error:a}=jY({limit:20,offset:0,operationType:t==="all"?void 0:t,partitionId:e},{refetchIntervalMs:5e3});return h.jsx(Jb,{title:"Operation Audit",description:"Recent prune/compact/notify/evict actions with actor and result context.",actions:h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Me,{variant:t==="all"?"default":"ghost",size:"sm",onClick:()=>n("all"),children:"All"}),h.jsx(Me,{variant:t==="prune"?"default":"ghost",size:"sm",onClick:()=>n("prune"),children:"Prune"}),h.jsx(Me,{variant:t==="compact"?"default":"ghost",size:"sm",onClick:()=>n("compact"),children:"Compact"}),h.jsx(Me,{variant:t==="notify_data_change"?"default":"ghost",size:"sm",onClick:()=>n("notify_data_change"),children:"Notify"}),h.jsx(Me,{variant:t==="evict_client"?"default":"ghost",size:"sm",onClick:()=>n("evict_client"),children:"Evict"})]}),contentClassName:"pt-2",children:i?h.jsx("div",{className:"flex items-center justify-center py-10",children:h.jsx(Pt,{size:"lg"})}):a?h.jsx(In,{variant:"destructive",children:h.jsxs(Pn,{children:["Failed to load operation audit events: ",a.message]})}):(s?.items.length??0)===0?h.jsx("div",{className:"px-2 py-8 text-sm text-neutral-500",children:"No operation events found for this filter."}):h.jsx("div",{className:"overflow-x-auto",children:h.jsxs(tl,{children:[h.jsx(nl,{children:h.jsxs(ss,{children:[h.jsx(ht,{children:"Time"}),h.jsx(ht,{children:"Type"}),h.jsx(ht,{children:"User"}),h.jsx(ht,{children:"Target"}),h.jsx(ht,{children:"Result"})]})}),h.jsx(rl,{children:(s?.items??[]).map((l,f)=>h.jsxs(ss,{children:[h.jsx(pt,{className:"whitespace-nowrap text-xs text-neutral-400",children:kX(l.createdAt)}),h.jsx(pt,{children:h.jsx(mn,{variant:"ghost",children:NX(l.operationType)})}),h.jsx(pt,{className:"font-mono text-xs",children:l.consoleUserId??"system"}),h.jsx(pt,{className:"font-mono text-xs",children:l.targetClientId??l.partitionId??(l.operationType==="notify_data_change"?"partition default":"global")}),h.jsx(pt,{className:"font-mono text-xs text-neutral-300",children:AX(l)})]},`${l.operationId}:${l.createdAt}:${f}`))})]})})})}function LX(){const[e,t]=pi("console:alert-config",TX),n={p90Latency:e.latencyThresholdMs,errorRate:e.errorRateThreshold,clientLag:e.clientLagThreshold},s=a=>{t(l=>({...l,latencyThresholdMs:a.p90Latency,errorRateThreshold:a.errorRate,clientLagThreshold:a.clientLag}))},i=a=>{t(l=>({...l,enabled:a}))};return h.jsx($j,{enabled:e.enabled,onEnabledChange:i,thresholds:n,onThresholdsChange:s})}function UX(e){if(e===0)return"0 B";const t=["B","KB","MB","GB","TB"],n=Math.floor(Math.log(e)/Math.log(1024));return`${(e/1024**n).toFixed(n===0?0:1)} ${t[n]}`}function $X(e){const t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function BX(){const[e,t]=_.useState(""),[n,s]=_.useState(void 0),[i,a]=_.useState(void 0),[l,f]=_.useState([]),[d,p]=_.useState(null),{data:g,isLoading:y,error:b}=$Y({prefix:n,cursor:i,limit:100}),x=BY(),S=FY();function w(){const M=e.trim();s(M.length>0?M:void 0),a(void 0),f([])}function T(){t(""),s(void 0),a(void 0),f([])}function C(){g?.cursor&&(f(M=>[...M,i??""]),a(g.cursor))}function O(){f(M=>{const z=[...M],j=z.pop();return a(j&&j.length>0?j:void 0),z})}function N(){d&&x.mutate(d,{onSuccess:()=>p(null)})}if(y)return h.jsx("div",{className:"flex flex-col gap-4 px-5 py-5",children:h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsx(Pt,{size:"lg"})})});if(b)return h.jsx("div",{className:"flex flex-col gap-4 px-5 py-5",children:h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsxs("p",{className:"text-danger font-mono text-[11px]",children:["Failed to load storage items: ",b.message]})})});const R=g?.items??[];return h.jsxs("div",{className:"flex flex-col gap-4 px-5 py-5",children:[h.jsx(Jb,{title:"Storage",actions:h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Gn,{placeholder:"Prefix filter...",value:e,onChange:M=>t(M.target.value),onKeyDown:M=>{M.key==="Enter"&&w()},className:"h-7 w-48 text-xs"}),h.jsx(Me,{variant:"default",size:"sm",onClick:w,children:"Filter"}),n&&h.jsx(Me,{variant:"ghost",size:"sm",onClick:T,children:"Clear"})]}),children:R.length===0?h.jsx(Qb,{message:n?`No storage items matching prefix "${n}".`:"No storage items found."}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"overflow-x-auto",children:h.jsxs(tl,{children:[h.jsx(nl,{children:h.jsxs(ss,{children:[h.jsx(ht,{children:"Key"}),h.jsx(ht,{children:"Size"}),h.jsx(ht,{children:"Type"}),h.jsx(ht,{children:"Uploaded"}),h.jsx(ht,{children:"Actions"})]})}),h.jsx(rl,{children:R.map(M=>h.jsxs(ss,{children:[h.jsx(pt,{className:"font-mono text-xs max-w-[320px]",title:M.key,children:M.key}),h.jsx(pt,{className:"font-mono text-xs text-neutral-400 whitespace-nowrap",children:UX(M.size)}),h.jsx(pt,{children:M.httpMetadata?.contentType?h.jsx(mn,{variant:"ghost",children:M.httpMetadata.contentType}):h.jsx("span",{className:"text-neutral-500 text-xs",children:"--"})}),h.jsx(pt,{className:"whitespace-nowrap text-xs text-neutral-400",children:$X(M.uploaded)}),h.jsx(pt,{children:h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{S(M.key)},children:"Download"}),h.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>p(M.key),children:"Delete"})]})})]},M.key))})]})}),h.jsxs("div",{className:"flex items-center justify-between px-2 py-2",children:[h.jsx(Me,{variant:"ghost",size:"sm",disabled:l.length===0,onClick:O,children:"Previous"}),h.jsx(Me,{variant:"ghost",size:"sm",disabled:!g?.truncated,onClick:C,children:"Next"})]})]})}),h.jsx($r,{open:d!==null,onOpenChange:()=>p(null),children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Delete Storage Item"})}),h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[h.jsxs("p",{className:"font-mono text-[11px] text-neutral-300",children:["Are you sure you want to delete"," ",h.jsx("span",{className:"font-mono text-white",children:d}),"?"]}),h.jsx("p",{className:"font-mono text-[10px] text-neutral-500",children:"This action cannot be undone."})]}),h.jsxs(Nn,{children:[h.jsx(Me,{variant:"default",onClick:()=>p(null),children:"Cancel"}),h.jsx(Me,{variant:"destructive",onClick:N,disabled:x.isPending,children:x.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"})," Deleting..."]}):"Delete"})]})]})})]})}const FX={};function au(e,t){if(t==="absolute")return new Date(e).toLocaleString();const n=new Date(e),i=new Date().getTime()-n.getTime(),a=Math.floor(i/1e3);return a<60?`${a}s`:a<3600?`${Math.floor(a/60)}m`:a<86400?`${Math.floor(a/3600)}h`:`${Math.floor(a/86400)}d`}function HX(e){const t=e.split(/\s+/).map(i=>i.trim()).filter(i=>i.length>0),n={},s=[];for(const i of t){const[a="",...l]=i.split(":"),f=l.join(":").trim(),d=a.toLowerCase();if(!f){s.push(i);continue}if(d==="actor"){n.actorId=f;continue}if(d==="client"){n.clientId=f;continue}if(d==="table"){n.table=f;continue}if(d==="request"){n.requestId=f;continue}if(d==="trace"){n.traceId=f;continue}s.push(i)}return s.length>0&&(n.search=s.join(" ")),n}function qX(e){return e==="1h"?3600*1e3:e==="6h"?360*60*1e3:e==="24h"?1440*60*1e3:e==="7d"?10080*60*1e3:720*60*60*1e3}function Gd(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function VX(e,t){return e?`#${e.federatedCommitId??(t?`${t}:${e.commitSeq}`:String(e.commitSeq))}`:"#?"}function KX(e,t){return e?`E${e.federatedEventId??(t?`${t}:${e.eventId}`:e.eventId)}`:"E?"}function GX(e,t,n){return!e||!t?null:e.replaceAll("{traceId}",encodeURIComponent(t)).replaceAll("{spanId}",encodeURIComponent(n??""))}function vx({initialSelectedEntryId:e}={}){const{preferences:t}=of(),{partitionId:n}=sf(),{range:s,setRange:i}=mk(),a=t.pageSize,l=t.refreshInterval*1e3,f=FX?.VITE_CONSOLE_TRACE_URL_TEMPLATE,[d,p]=_.useState(()=>e?.startsWith("#")?"commits":e?.startsWith("E")?"events":"all"),[g,y]=_.useState("all"),[b,x]=_.useState("all"),[S,w]=_.useState(""),[T,C]=_.useState(1),[O,N]=_.useState(!1),[R,M]=_.useState(e??null),z=_.useRef(!1),j=_.useMemo(()=>HX(S),[S]),A=_.useMemo(()=>new Date(Date.now()-qX(s)).toISOString(),[s]),{data:P,isLoading:Q,refetch:B}=EY({limit:a,offset:(T-1)*a,...n?{partitionId:n}:{},view:d,...d!=="commits"&&g!=="all"?{eventType:g}:{},...d!=="commits"&&b!=="all"?{outcome:b}:{},...j.actorId?{actorId:j.actorId}:{},...j.clientId?{clientId:j.clientId}:{},...j.requestId?{requestId:j.requestId}:{},...j.traceId?{traceId:j.traceId}:{},...j.table?{table:j.table}:{},...j.search?{search:j.search}:{},from:A},{refetchIntervalMs:l}),U=JY(),Z=R?.startsWith("#")?R.slice(1):void 0,K=R?.startsWith("E")?R.slice(1):void 0,ee=Z&&Z!=="?"?Z:void 0,D=K&&K!=="?"?K:void 0,{data:G,isLoading:q,error:V}=wY(ee,{enabled:ee!==void 0,partitionId:n}),{data:L,isLoading:I,error:H}=TY(D,{enabled:D!==void 0,partitionId:n}),{data:W,isLoading:Y,error:ae}=CY(D,{enabled:D!==void 0&&!!L?.payloadRef,partitionId:n}),se=_.useMemo(()=>GX(f,L?.traceId??null,L?.spanId??null),[L?.spanId,L?.traceId,f]);_.useEffect(()=>{C(1)},[]),_.useEffect(()=>{C(1)},[]),_.useEffect(()=>{e&&M(e)},[e]),_.useEffect(()=>{if(!z.current){z.current=!0;return}M(null)},[]),_.useEffect(()=>{C(1),M(null)},[]);const Se=_.useMemo(()=>(P?.items??[]).map(we=>{const ye=we.instanceId??we.commit?.instanceId??we.event?.instanceId,xe=ye?`[${ye}] `:"";if(we.type==="commit"&&we.commit){const Ie=we.commit;return{type:"commit",id:VX(Ie,ye),outcome:"--",duration:"--",actor:Ie.actorId,client:Ie.clientId,detail:`${xe}${Ie.changeCount} chg | ${(Ie.affectedTables??[]).join(", ")}`,time:au(we.timestamp,t.timeFormat)}}const ve=we.event;return ve?{type:ve.eventType,id:KX(ve,ye),outcome:ve.outcome,duration:`${ve.durationMs}ms`,actor:ve.actorId,client:ve.clientId,detail:`${xe}${(ve.tables??[]).join(", ")||"--"}`,time:au(we.timestamp,t.timeFormat)}:{type:"pull",id:"E?",outcome:"unknown",duration:"--",actor:"",client:"",detail:"--",time:au(we.timestamp,t.timeFormat)}}),[t.timeFormat,P?.items]),pe=P?.total??0,Oe=Math.max(1,Math.ceil(pe/a)),_e=Q,re=[{label:"",options:[{id:"all",label:"All"},{id:"commits",label:"Commits"},{id:"events",label:"Events"}],activeId:d,onActiveChange:ie=>{p(ie),ie==="commits"&&(y("all"),x("all")),C(1)}},{label:"Time",options:[{id:"1h",label:"1h"},{id:"6h",label:"6h"},{id:"24h",label:"24h"},{id:"7d",label:"7d"},{id:"30d",label:"30d"}],activeId:s,onActiveChange:ie=>{i(ie),C(1)}},{label:"Type",options:[{id:"all",label:"All"},{id:"push",label:"Push"},{id:"pull",label:"Pull"}],activeId:g,onActiveChange:ie=>{y(ie),C(1)}},{label:"Outcome",options:[{id:"all",label:"All"},{id:"applied",label:"Applied"},{id:"error",label:"Error"},{id:"rejected",label:"Rejected"}],activeId:b,onActiveChange:ie=>{x(ie),C(1)}}];function he(){U.mutate(void 0,{onSuccess:()=>{N(!1),B()}})}return h.jsxs("div",{className:"flex flex-col h-full",children:[_e&&Se.length===0?h.jsx("div",{className:"flex items-center justify-center py-24",children:h.jsx(Pt,{size:"lg"})}):h.jsx(Jj,{entries:Se,selectedEntryId:R,onEntryClick:ie=>M(ie.id),filterBar:h.jsx(Vj,{groups:re,searchValue:S,searchPlaceholder:"Use actor:, client:, table:, request:, trace: or free text...",onSearchChange:w,actions:h.jsxs(h.Fragment,{children:[h.jsx(Me,{size:"sm",variant:"ghost",onClick:()=>{B()},children:"Refresh"}),h.jsx(Me,{size:"sm",variant:"ghost",children:"Export"}),h.jsx(Me,{size:"sm",variant:"destructive",onClick:()=>N(!0),children:"Clear"})]})}),pagination:h.jsx(mx,{page:T,totalPages:Oe,totalItems:pe,onPageChange:C})}),h.jsx($r,{open:R!==null,onOpenChange:ie=>{ie||M(null)},children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:ee!==void 0?`Commit #${ee}`:D!==void 0?`Event E${D}`:"Entry details"})}),h.jsx("div",{className:"px-5 py-4 space-y-3 max-h-[70vh] overflow-y-auto",children:q||I?h.jsx("div",{className:"flex items-center justify-center py-8",children:h.jsx(Pt,{size:"sm"})}):V||H?h.jsx("p",{className:"font-mono text-[11px] text-offline",children:"Failed to load details."}):G?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"grid grid-cols-2 gap-3 font-mono text-[11px]",children:[h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Actor"}),h.jsx("div",{className:"text-neutral-100",children:G.actorId})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Client"}),h.jsx("div",{className:"text-neutral-100",children:G.clientId})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Instance"}),h.jsx("div",{className:"text-neutral-100",children:G.instanceId??"--"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Created"}),h.jsx("div",{className:"text-neutral-100",children:au(G.createdAt,t.timeFormat)})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Changes"}),h.jsx("div",{className:"text-neutral-100",children:G.changeCount})]})]}),h.jsxs("div",{children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2",children:"Affected Tables"}),h.jsx("p",{className:"font-mono text-[11px] text-neutral-200",children:G.affectedTables.join(", ")||"--"})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500",children:"Changes"}),G.changes.length===0?h.jsx("p",{className:"font-mono text-[11px] text-neutral-500",children:"No changes recorded."}):G.changes.map(ie=>h.jsxs("div",{className:"rounded-md border border-border p-3 space-y-2",children:[h.jsxs("div",{className:"flex items-center justify-between font-mono text-[11px]",children:[h.jsxs("span",{className:"text-neutral-300",children:[ie.table," | ",ie.op]}),h.jsxs("span",{className:"text-neutral-500",children:["#",ie.changeId]})]}),h.jsxs("div",{className:"font-mono text-[11px] text-neutral-400",children:["rowId: ",ie.rowId,ie.rowVersion!==null?` | version: ${ie.rowVersion}`:""]}),h.jsx("pre",{className:"font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200",children:Gd(ie.rowJson)})]},ie.changeId))]})]}):L?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"grid grid-cols-2 gap-3 font-mono text-[11px]",children:[h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Type"}),h.jsx("div",{className:"text-neutral-100",children:L.eventType})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Path"}),h.jsx("div",{className:"text-neutral-100",children:L.syncPath})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Instance"}),h.jsx("div",{className:"text-neutral-100",children:L.instanceId??"--"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Outcome"}),h.jsx("div",{className:"text-neutral-100",children:L.outcome})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Response Status"}),h.jsx("div",{className:"text-neutral-100",children:L.responseStatus})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Actor"}),h.jsx("div",{className:"text-neutral-100",children:L.actorId})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Client"}),h.jsx("div",{className:"text-neutral-100",children:L.clientId})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Status"}),h.jsx("div",{className:"text-neutral-100",children:L.statusCode})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Transport"}),h.jsx("div",{className:"text-neutral-100",children:L.transportPath})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Duration"}),h.jsxs("div",{className:"text-neutral-100",children:[L.durationMs,"ms"]})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Request ID"}),h.jsx("div",{className:"text-neutral-100",children:L.requestId})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Trace ID"}),h.jsx("div",{className:"text-neutral-100",children:L.traceId??"--"}),se&&h.jsx("a",{href:se,target:"_blank",rel:"noreferrer",className:"font-mono text-[10px] text-flow underline underline-offset-4",children:"Open external trace"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Span ID"}),h.jsx("div",{className:"text-neutral-100",children:L.spanId??"--"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Commit Seq"}),h.jsx("div",{className:"text-neutral-100",children:L.commitSeq??"--"}),L.commitSeq!==null&&h.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>M(`#${L.instanceId?`${L.instanceId}:`:""}${L.commitSeq}`),children:"Open linked commit"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Subscription Count"}),h.jsx("div",{className:"text-neutral-100",children:L.subscriptionCount??"--"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Error Code"}),h.jsx("div",{className:"text-neutral-100",children:L.errorCode??"--"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Payload Ref"}),h.jsx("div",{className:"text-neutral-100",children:L.payloadRef??"--"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Created"}),h.jsx("div",{className:"text-neutral-100",children:au(L.createdAt,t.timeFormat)})]})]}),h.jsxs("div",{children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2",children:"Tables"}),h.jsx("p",{className:"font-mono text-[11px] text-neutral-200",children:L.tables.join(", ")||"--"})]}),L.scopesSummary&&h.jsxs("div",{children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2",children:"Scopes Summary"}),h.jsx("pre",{className:"font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200",children:Gd(L.scopesSummary)})]}),L.payloadRef&&h.jsxs("div",{children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2",children:"Payload Snapshot"}),Y?h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Pt,{size:"sm"}),h.jsx("span",{className:"font-mono text-[11px] text-neutral-400",children:"Loading payload snapshot..."})]}):ae?h.jsx("p",{className:"font-mono text-[11px] text-offline",children:"Failed to load payload snapshot."}):W?h.jsxs("div",{className:"space-y-2",children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500",children:"Request"}),h.jsx("pre",{className:"font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200",children:Gd(W.requestPayload)}),h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500",children:"Response"}),h.jsx("pre",{className:"font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200",children:Gd(W.responsePayload)})]}):h.jsx("p",{className:"font-mono text-[11px] text-neutral-500",children:"No payload snapshot available."})]}),L.errorMessage&&h.jsxs("div",{children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2",children:"Error"}),h.jsx("p",{className:"font-mono text-[11px] text-offline",children:L.errorMessage})]})]}):h.jsx("p",{className:"font-mono text-[11px] text-neutral-500",children:"No details available for this row."})}),h.jsx(Nn,{children:h.jsx(Me,{variant:"default",size:"sm",onClick:()=>M(null),children:"Close"})})]})}),h.jsx($r,{open:O,onOpenChange:ie=>{ie||N(!1)},children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Clear all events"})}),h.jsx("div",{className:"p-4",children:h.jsx("span",{className:"font-mono text-[11px] text-neutral-400",children:"This will permanently delete all request events. Commits are not affected. Are you sure?"})}),h.jsxs(Nn,{children:[h.jsx(Me,{variant:"default",size:"sm",onClick:()=>N(!1),children:"Cancel"}),h.jsx(Me,{variant:"destructive",size:"sm",onClick:he,disabled:U.isPending,children:U.isPending?"Clearing...":"Clear all"})]})]})})]})}const ZX=co({getParentRoute:()=>uo,path:"/config",component:dX}),YX=co({getParentRoute:()=>uo,path:"/fleet",component:EX}),XX=co({getParentRoute:()=>uo,path:"/",component:fX});function QX(){const{seq:e}=gk.useParams();return h.jsx(vx,{initialSelectedEntryId:`#${e}`})}const gk=co({getParentRoute:()=>uo,path:"/investigate/commit/$seq",component:QX});function WX(){const{id:e}=yk.useParams();return h.jsx(vx,{initialSelectedEntryId:`E${e}`})}const yk=co({getParentRoute:()=>uo,path:"/investigate/event/$id",component:WX}),JX=co({getParentRoute:()=>uo,path:"/ops",component:OX}),eQ=co({getParentRoute:()=>uo,path:"/storage",component:BX}),tQ=co({getParentRoute:()=>uo,path:"/stream",component:vx}),nQ=uo.addChildren([XX,tQ,gk,yk,YX,JX,eQ,ZX]),rQ="syncular-console-basepath",sQ="syncular-console-server-url",oQ="syncular-console-token";function iQ(e){if(!e)return;const t=e.trim();return t.length>0?t:void 0}function $v(e){const t=globalThis.document;if(!t)return;const n=t.querySelector(`meta[name="${e}"]`)?.getAttribute("content");return iQ(n)}function vk(e){return!e||e==="/"?"/":(e.startsWith("/")?e:`/${e}`).replace(/\/+$/g,"")||"/"}function aQ(){return vk($v(rQ))}function cQ(){const e=$v(sQ),t=$v(oQ);return!e||!t?null:{serverUrl:e,token:t}}function lQ(){return new k6({defaultOptions:{queries:{staleTime:5e3,retry:1}}})}function uQ(e){return vk(e??aQ())}function fQ(e){const[t]=_.useState(()=>lQ()),n=_.useMemo(()=>DH({routeTree:nQ,basepath:uQ(e.basePath)}),[e.basePath]),s=e.defaultConfig===void 0?cQ():e.defaultConfig,i=e.autoConnect??e.defaultConfig===void 0;return h.jsx(O6,{client:t,children:h.jsx(WH,{defaultConfig:s,autoConnect:i,children:h.jsx(UH,{router:n})})})}function dQ(e){return h.jsx("div",{className:yx,children:h.jsx(fQ,{...e})})}function hQ(e){const t=document.querySelector(e);if(!t)throw new Error(`Unable to mount console: ${e} not found`);return t}function pQ(e,t={}){const n=hQ(e);KY(n);const s=a6.createRoot(n),i=h.jsx(dQ,{basePath:t.basePath,defaultConfig:t.defaultConfig,autoConnect:t.autoConnect});return t.strictMode===!1?(s.render(i),s):(s.render(h.jsx(_.StrictMode,{children:i})),s)}var mQ={};const gQ="syncular-sentry-dsn",yQ="syncular-sentry-environment",vQ="syncular-sentry-release";function gu(e){if(!e)return;const t=e.trim();return t.length>0?t:void 0}function By(e){if(typeof document>"u")return;const t=document.querySelector(`meta[name="${e}"]`)?.getAttribute("content");return gu(t)}function Fy(e){if(!(typeof process>"u"))return gu(mQ[e])}function Hy(e){for(const t of e)if(t)return t}function bQ(){const e=Hy([gu(globalThis.__SYNCULAR_SENTRY_DSN__),By(gQ),Fy("SYNCULAR_SENTRY_DSN")]);if(!e)return null;const t=Hy([gu(globalThis.__SYNCULAR_SENTRY_ENVIRONMENT__),By(yQ),Fy("SYNCULAR_SENTRY_ENVIRONMENT")]),n=Hy([gu(globalThis.__SYNCULAR_SENTRY_RELEASE__),By(vQ),Fy("SYNCULAR_SENTRY_RELEASE")]);return{dsn:e,environment:t,release:n,enableLogs:!0,tracesSampleRate:.2,tracePropagationTargets:[/^https?:\/\/.*\/api\/.*/]}}const QC=bQ();QC&&WB(QC);pQ("#root");
|
|
86
|
+
)`}return h.jsx("div",{ref:n,role:"presentation","data-base-ui-inert":"",...i,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:a}})});function Qh(e,t){e&&Object.assign(e.style,t)}const qG={position:"relative",maxHeight:"100%",overflowX:"hidden",overflowY:"auto"},VG={position:"fixed"},KG=_.forwardRef(function(t,n){const{anchor:s,positionMethod:i="absolute",className:a,render:l,side:f="bottom",align:d="center",sideOffset:p=0,alignOffset:g=0,collisionBoundary:y="clipping-ancestors",collisionPadding:b,arrowPadding:x=5,sticky:S=!1,disableAnchorTracking:w,alignItemWithTrigger:T=!0,collisionAvoidance:C=X9,...O}=t,{store:N,listRef:R,labelsRef:M,alignItemWithTriggerActiveRef:z,selectedItemTextRef:j,valuesRef:A,initialValueRef:P,popupRef:Q,setValue:B}=Wu(),U=FA(),Z=at(N,it.open),K=at(N,it.mounted),ee=at(N,it.modal),D=at(N,it.value),G=at(N,it.openMethod),q=at(N,it.positionerElement),V=at(N,it.triggerElement),L=at(N,it.isItemEqualToValue),I=at(N,it.transitionStatus),H=_.useRef(null),W=_.useRef(null),[Y,ae]=_.useState(T),se=K&&Y&&G!=="touch";!K&&Y!==T&&ae(T),Le(()=>{K||(it.scrollUpArrowVisible(N.state)&&N.set("scrollUpArrowVisible",!1),it.scrollDownArrowVisible(N.state)&&N.set("scrollDownArrowVisible",!1))},[N,K]),_.useImperativeHandle(z,()=>se),HA((se||ee)&&Z&&G!=="touch",V);const fe=LA({anchor:s,floatingRootContext:U,positionMethod:i,mounted:K,side:f,sideOffset:p,align:d,alignOffset:g,arrowPadding:x,collisionBoundary:y,collisionPadding:b,sticky:S,disableAnchorTracking:w??se,collisionAvoidance:C,keepMounted:!0}),Se=se?"none":fe.side,pe=se?VG:fe.positionerStyles,Oe=_.useMemo(()=>{const xe={};return Z||(xe.pointerEvents="none"),{role:"presentation",hidden:!K,style:{...pe,...xe}}},[Z,K,pe]),_e={open:Z,side:Se,align:fe.align,anchorHidden:fe.anchorHidden},re=Ae(xe=>{N.set("positionerElement",xe)}),he=zt("div",t,{ref:[n,re],state:_e,stateAttributesMapping:ol,props:[Oe,Np(I),O]}),ie=_.useRef(0),we=Ae(xe=>{if(xe.size===0&&ie.current===0||A.current.length===0)return;const ve=ie.current;if(ie.current=xe.size,xe.size===ve)return;const Ie=Yt(ii);if(ve!==0&&!N.state.multiple&&D!==null&&zy(A.current,D,L)===-1){const Ee=P.current,Qe=Ee!=null&&zy(A.current,Ee,L)!==-1?Ee:null;B(Qe,Ie),Qe===null&&(N.set("selectedIndex",null),j.current=null)}if(ve!==0&&N.state.multiple&&Array.isArray(D)){const Ue=Ve=>zy(A.current,Ve,L)!==-1,Ee=D.filter(Ve=>Ue(Ve));(Ee.length!==D.length||Ee.some(Ve=>!xG(D,Ve,L)))&&(B(Ee,Ie),Ee.length===0&&(N.set("selectedIndex",null),j.current=null))}if(Z&&se){N.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});const Ue={height:""};Qh(q,Ue),Qh(Q.current,Ue)}}),ye=_.useMemo(()=>({...fe,side:Se,alignItemWithTriggerActive:se,setControlledAlignItemWithTrigger:ae,scrollUpArrowRef:H,scrollDownArrowRef:W}),[fe,Se,se,ae]);return h.jsx(VA,{elementsRef:R,labelsRef:M,onMapChange:we,children:h.jsxs(KA.Provider,{value:ye,children:[K&&ee&&h.jsx(GA,{inert:dx(!Z),cutout:V}),he]})})});function ZA(e){const t=e.currentTarget.getBoundingClientRect();return t.top+1<=e.clientY&&e.clientY<=t.bottom-1&&t.left+1<=e.clientX&&e.clientX<=t.right-1}const Vd="base-ui-disable-scrollbar",zC={className:Vd,getElement(e){return h.jsx("style",{nonce:e,href:Vd,precedence:"base-ui:low",children:`.${Vd}{scrollbar-width:none}.${Vd}::-webkit-scrollbar{display:none}`})}},GG=_.createContext(void 0);function YA(e){return _.useContext(GG)}const wc="ArrowUp",Wi="ArrowDown",Au="ArrowLeft",Ec="ArrowRight",Ju="Home",ef="End",XA=new Set([Au,Ec]),ZG=new Set([Au,Ec,Ju,ef]),QA=new Set([wc,Wi]),YG=new Set([wc,Wi,Ju,ef]),WA=new Set([...XA,...QA]),XG=new Set([...WA,Ju,ef]),JA=new Set([wc,Wi,Au,Ec,Ju,ef]),QG="Shift",WG="Control",JG="Alt",eZ="Meta",tZ=new Set([QG,WG,JG,eZ]);function nZ(e){return Zt(e)&&e.tagName==="INPUT"}function LC(e){return!!(nZ(e)&&e.selectionStart!=null||Zt(e)&&e.tagName==="TEXTAREA")}function UC(e,t,n,s){if(!e||!t||!t.scrollTo)return;let i=e.scrollLeft,a=e.scrollTop;const l=e.clientWidth<e.scrollWidth,f=e.clientHeight<e.scrollHeight;if(l&&s!=="vertical"){const d=$C(e,t,"left"),p=Kd(e),g=Kd(t);n==="ltr"&&(d+t.offsetWidth+g.scrollMarginRight>e.scrollLeft+e.clientWidth-p.scrollPaddingRight?i=d+t.offsetWidth+g.scrollMarginRight-e.clientWidth+p.scrollPaddingRight:d-g.scrollMarginLeft<e.scrollLeft+p.scrollPaddingLeft&&(i=d-g.scrollMarginLeft-p.scrollPaddingLeft)),n==="rtl"&&(d-g.scrollMarginRight<e.scrollLeft+p.scrollPaddingLeft?i=d-g.scrollMarginLeft-p.scrollPaddingLeft:d+t.offsetWidth+g.scrollMarginRight>e.scrollLeft+e.clientWidth-p.scrollPaddingRight&&(i=d+t.offsetWidth+g.scrollMarginRight-e.clientWidth+p.scrollPaddingRight))}if(f&&s!=="horizontal"){const d=$C(e,t,"top"),p=Kd(e),g=Kd(t);d-g.scrollMarginTop<e.scrollTop+p.scrollPaddingTop?a=d-g.scrollMarginTop-p.scrollPaddingTop:d+t.offsetHeight+g.scrollMarginBottom>e.scrollTop+e.clientHeight-p.scrollPaddingBottom&&(a=d+t.offsetHeight+g.scrollMarginBottom-e.clientHeight+p.scrollPaddingBottom)}e.scrollTo({left:i,top:a,behavior:"auto"})}function $C(e,t,n){const s=n==="left"?"offsetLeft":"offsetTop";let i=0;for(;t.offsetParent&&(i+=t[s],t.offsetParent!==e);)t=t.offsetParent;return i}function Kd(e){const t=getComputedStyle(e);return{scrollMarginTop:parseFloat(t.scrollMarginTop)||0,scrollMarginRight:parseFloat(t.scrollMarginRight)||0,scrollMarginBottom:parseFloat(t.scrollMarginBottom)||0,scrollMarginLeft:parseFloat(t.scrollMarginLeft)||0,scrollPaddingTop:parseFloat(t.scrollPaddingTop)||0,scrollPaddingRight:parseFloat(t.scrollPaddingRight)||0,scrollPaddingBottom:parseFloat(t.scrollPaddingBottom)||0,scrollPaddingLeft:parseFloat(t.scrollPaddingLeft)||0}}function Ly(e,t=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(t,Math.min(e,n))}const rZ=_.createContext(void 0),sZ={disableStyleElements:!1};function oZ(){return _.useContext(rZ)??sZ}const Vi=1,iZ={...ol,...ba},aZ=_.forwardRef(function(t,n){const{render:s,className:i,finalFocus:a,...l}=t,{store:f,popupRef:d,onOpenChangeComplete:p,setOpen:g,valueRef:y,selectedItemTextRef:b,keyboardActiveRef:x,multiple:S,handleScrollArrowVisibility:w,scrollHandlerRef:T,highlightItemOnHover:C}=Wu(),{side:O,align:N,alignItemWithTriggerActive:R,setControlledAlignItemWithTrigger:M,scrollDownArrowRef:z,scrollUpArrowRef:j}=HG(),A=YA()!=null,P=FA(),{nonce:Q,disableStyleElements:B}=oZ(),U=ns(),Z=at(f,it.id),K=at(f,it.open),ee=at(f,it.mounted),D=at(f,it.popupProps),G=at(f,it.transitionStatus),q=at(f,it.triggerElement),V=at(f,it.positionerElement),L=at(f,it.listElement),I=_.useRef(0),H=_.useRef(!1),W=_.useRef(0),Y=_.useRef(!1),ae=_.useRef({}),se=ix(),fe=Ae(_e=>{if(!V||!d.current||!Y.current)return;if(H.current||!R){w();return}const re=V.style.top==="0px",he=V.style.bottom==="0px",ie=V.getBoundingClientRect().height,we=Rt(V),ye=getComputedStyle(V),xe=parseFloat(ye.marginTop),ve=parseFloat(ye.marginBottom),Ie=BC(getComputedStyle(d.current)),Ue=Math.min(we.documentElement.clientHeight-xe-ve,Ie),Ee=_e.scrollTop,Ve=FC(_e);let Qe=0,Be=null,We=!1,He=!1;const me=qe=>{V.style.height=`${qe}px`},Te=(qe,mt)=>{const lt=Ly(qe,0,Ue-ie);lt>0&&me(ie+lt),_e.scrollTop=mt,Ue-(ie+lt)<=Vi&&(H.current=!0),w()};if(re){const qe=Ve-Ee,mt=ie+qe,lt=Math.min(mt,Ue);if(Qe=lt,qe<=Vi){Te(qe,Ve);return}Ue-lt>Vi?He=!0:We=!0}else if(he){const qe=Ee,mt=ie+qe,lt=Math.min(mt,Ue),wr=mt-Ue;if(Qe=lt,qe<=Vi){Te(qe,0);return}Ue-lt>Vi?Be=0:(We=!0,Ee<Ve&&(Be=Ee-(qe-wr)))}if(Qe=Math.ceil(Qe),Qe!==0&&me(Qe),He||Be!=null){const qe=FC(_e),mt=He?qe:Ly(Be,0,qe);Math.abs(_e.scrollTop-mt)>Vi&&(_e.scrollTop=mt)}(We||Qe>=Ue-Vi)&&(H.current=!0),w()});_.useImperativeHandle(T,()=>fe,[fe]),xa({open:K,ref:d,onComplete(){K&&p?.(!0)}});const Se={open:K,transitionStatus:G,side:O,align:N};Le(()=>{!V||!d.current||Object.keys(ae.current).length||(ae.current={top:V.style.top||"0",left:V.style.left||"0",right:V.style.right,height:V.style.height,bottom:V.style.bottom,minHeight:V.style.minHeight,maxHeight:V.style.maxHeight,marginTop:V.style.marginTop,marginBottom:V.style.marginBottom})},[d,V]),Le(()=>{K||R||(Y.current=!1,H.current=!1,I.current=0,W.current=0,Qh(V,ae.current))},[K,R,V,d]),Le(()=>{const _e=d.current;if(!(!K||!q||!V||!_e||f.state.transitionStatus==="ending")){if(!R){Y.current=!0,se.request(w),_e.style.removeProperty("--transform-origin");return}queueMicrotask(()=>{const re=cZ(_e);_e.style.removeProperty("--transform-origin");try{const he=getComputedStyle(V),ie=getComputedStyle(_e),we=Rt(q),ye=un(V),xe=q.getBoundingClientRect(),ve=V.getBoundingClientRect(),Ie=xe.left,Ue=xe.height,Ee=L||_e,Ve=Ee.scrollHeight,Qe=parseFloat(ie.borderBottomWidth),Be=parseFloat(he.marginTop)||10,We=parseFloat(he.marginBottom)||10,He=parseFloat(he.minHeight)||100,me=BC(ie),Te=5,qe=5,mt=20,lt=we.documentElement.clientHeight-Be-We,wr=we.documentElement.clientWidth,Er=lt-xe.bottom+Ue,Qt=b.current,ut=y.current;let xt,ot=0,Wt=0;if(Qt&&ut){const tr=ut.getBoundingClientRect();xt=Qt.getBoundingClientRect();const ls=tr.left-Ie,fo=xt.left-ve.left,ho=tr.top-xe.top+tr.height/2,nr=xt.top-ve.top+xt.height/2;ot=ls-fo,Wt=nr-ho}const vn=Er+Wt+We+Qe;let kt=Math.min(lt,vn);const Cn=lt-Be-We,er=vn-kt,An=Math.max(Te,Ie+ot),as=wr-qe,cs=Math.max(0,An+ve.width-as);V.style.left=`${An-cs}px`,V.style.height=`${kt}px`,V.style.maxHeight="auto",V.style.marginTop=`${Be}px`,V.style.marginBottom=`${We}px`,_e.style.height="100%";const _a=Ee.scrollHeight-Ee.clientHeight,wi=er>=_a;wi&&(kt=Math.min(lt,ve.height)-(er-_a));const Ei=xe.top<mt||xe.bottom>lt-mt||kt<Math.min(Ve,He),ws=(ye.visualViewport?.scale??1)!==1&&nx;if(Ei||ws){Y.current=!0,Qh(V,ae.current),hi.flushSync(()=>M(!1));return}if(wi){const tr=Math.max(0,lt-vn);V.style.top=ve.height>=Cn?"0":`${tr}px`,V.style.height=`${kt}px`,Ee.scrollTop=Ee.scrollHeight-Ee.clientHeight,I.current=Math.max(He,kt)}else V.style.bottom="0",I.current=Math.max(He,kt),Ee.scrollTop=er;if(xt){const tr=ve.top,ls=ve.height,fo=xt.top+xt.height/2,ho=ls>0?(fo-tr)/ls*100:50,nr=Ly(ho,0,100);_e.style.setProperty("--transform-origin",`50% ${nr}%`)}(I.current===lt||kt>=me)&&(H.current=!0),w(),setTimeout(()=>{Y.current=!0})}finally{re()}})}},[f,K,V,q,y,b,d,w,R,M,se,z,j,L]),_.useEffect(()=>{if(!R||!V||!K)return;const _e=un(V);function re(he){g(!1,Yt(S8,he))}return _e.addEventListener("resize",re),()=>{_e.removeEventListener("resize",re)}},[g,R,V,K]);const pe={...L?{role:"presentation","aria-orientation":void 0}:{role:"listbox","aria-multiselectable":S||void 0,id:`${Z}-list`},onKeyDown(_e){x.current=!0,A&&JA.has(_e.key)&&_e.stopPropagation()},onMouseMove(){x.current=!1},onPointerLeave(_e){if(!C||ZA(_e)||_e.pointerType==="touch")return;const re=_e.currentTarget;U.start(0,()=>{f.set("activeIndex",null),re.focus({preventScroll:!0})})},onScroll(_e){L||fe(_e.currentTarget)},...R&&{style:L?{height:"100%"}:qG}},Oe=zt("div",t,{ref:[n,d],state:Se,stateAttributesMapping:iZ,props:[D,pe,Np(G),{className:!L&&R?zC.className:void 0},l]});return h.jsxs(_.Fragment,{children:[!B&&zC.getElement(Q),h.jsx(EA,{context:P,modal:!1,disabled:!ee,returnFocus:a,restoreFocus:!0,children:Oe})]})});function BC(e){const t=e.maxHeight||"";return t.endsWith("px")&&parseFloat(t)||1/0}function FC(e){return Math.max(0,e.scrollHeight-e.clientHeight)}const HC=[["transform","none"],["scale","1"],["translate","0 0"]];function cZ(e){const{style:t}=e,n={};for(const[s,i]of HC)n[s]=t.getPropertyValue(s),t.setProperty(s,i,"important");return()=>{for(const[s]of HC){const i=n[s];i?t.setProperty(s,i):t.removeProperty(s)}}}let ek=(function(e){return e[e.None=0]="None",e[e.GuessFromOrder=1]="GuessFromOrder",e})({});function hx(e={}){const{label:t,metadata:n,textRef:s,indexGuessBehavior:i,index:a}=e,{register:l,unregister:f,subscribeMapChange:d,elementsRef:p,labelsRef:g,nextIndexRef:y}=UG(),b=_.useRef(-1),[x,S]=_.useState(a??(i===ek.GuessFromOrder?()=>{if(b.current===-1){const C=y.current;y.current+=1,b.current=C}return b.current}:-1)),w=_.useRef(null),T=_.useCallback(C=>{if(w.current=C,x!==-1&&C!==null&&(p.current[x]=C,g)){const O=t!==void 0;g.current[x]=O?t:s?.current?.textContent??C.textContent}},[x,p,g,t,s]);return Le(()=>{if(a!=null)return;const C=w.current;if(C)return l(C,n),()=>{f(C)}},[a,l,f,n]),Le(()=>{if(a==null)return d(C=>{const O=w.current?C.get(w.current)?.index:null;O!=null&&S(O)})},[a,d,S]),_.useMemo(()=>({ref:T,index:x}),[x,T])}const lZ=_.createContext(void 0),uZ=_.memo(_.forwardRef(function(t,n){const{render:s,className:i,value:a=null,label:l,disabled:f=!1,nativeButton:d=!1,...p}=t,g=_.useRef(null),y=hx({label:l,textRef:g,indexGuessBehavior:ek.GuessFromOrder}),{store:b,getItemProps:x,setOpen:S,setValue:w,selectionRef:T,typingRef:C,valuesRef:O,keyboardActiveRef:N,multiple:R,highlightItemOnHover:M}=Wu(),z=ns(),j=at(b,it.isActive,y.index),A=at(b,it.isSelected,y.index,a),P=at(b,it.isSelectedByFocus,y.index),Q=at(b,it.isItemEqualToValue),B=y.index,U=B!==-1,Z=_.useRef(null),K=Jo(B);Le(()=>{if(!U)return;const se=O.current;return se[B]=a,()=>{delete se[B]}},[U,B,a,O]),Le(()=>{if(!U)return;const se=b.state.value;let fe=se;R&&Array.isArray(se)&&se.length>0&&(fe=se[se.length-1]),fe!==void 0&&$c(a,fe,Q)&&b.set("selectedIndex",B)},[U,B,R,Q,b,a]);const ee={disabled:f,selected:A,highlighted:j},D=x({active:j,selected:A});D.onFocus=void 0,D.id=void 0;const G=_.useRef(null),q=_.useRef("mouse"),V=_.useRef(!1),{getButtonProps:L,buttonRef:I}=Jc({disabled:f,focusableWhenDisabled:!0,native:d});function H(se){const fe=b.state.value;if(R){const Se=Array.isArray(fe)?fe:[],pe=A?SG(Se,a,Q):[...Se,a];w(pe,Yt(Cy,se))}else w(a,Yt(Cy,se)),S(!1,Yt(Cy,se))}const W={role:"option","aria-selected":A,tabIndex:j?0:-1,onFocus(){b.set("activeIndex",B)},onMouseEnter(){!N.current&&b.state.selectedIndex===null&&M&&b.set("activeIndex",B)},onMouseMove(){M&&b.set("activeIndex",B)},onMouseLeave(se){!M||N.current||ZA(se)||z.start(0,()=>{b.state.activeIndex===B&&b.set("activeIndex",null)})},onTouchStart(){T.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1}},onKeyDown(se){G.current=se.key,b.set("activeIndex",B)},onClick(se){V.current=!1,!(se.type==="keydown"&&G.current===null)&&(f||G.current===" "&&C.current||q.current!=="touch"&&!j||(G.current=null,H(se.nativeEvent)))},onPointerEnter(se){q.current=se.pointerType},onPointerDown(se){q.current=se.pointerType,V.current=!0},onMouseUp(se){if(f)return;if(V.current){V.current=!1;return}const fe=!T.current.allowSelectedMouseUp&&A,Se=!T.current.allowUnselectedMouseUp&&!A;fe||Se||q.current!=="touch"&&!j||H(se.nativeEvent)}},Y=zt("div",t,{ref:[I,n,y.ref,Z],state:ee,props:[D,W,p,L]}),ae=_.useMemo(()=>({selected:A,indexRef:K,textRef:g,selectedByFocus:P,hasRegistered:U}),[A,K,g,P,U]);return h.jsx(lZ.Provider,{value:ae,children:Y})})),fZ=_.forwardRef(({className:e,children:t,...n},s)=>h.jsx(AG,{ref:s,className:ge("inline-flex items-center justify-between bg-surface border border-border rounded-md px-3 py-1.5 font-mono text-[12px] text-foreground cursor-pointer hover:border-border-bright transition",e),...n,children:t}));fZ.displayName="SelectTrigger";const dZ=_.forwardRef(({className:e,portalProps:t,positionerProps:n,...s},i)=>h.jsx(OG,{...t,children:h.jsx(KG,{...n,children:h.jsx(aZ,{ref:i,className:ge("bg-panel border border-border rounded-md py-1 shadow-lg z-50",e),...s})})}));dZ.displayName="SelectContent";const hZ=_.forwardRef(({className:e,...t},n)=>h.jsx(uZ,{ref:n,className:ge("font-mono text-[11px] px-3 py-1.5 text-neutral-400 cursor-pointer hover:bg-white/[0.03] hover:text-white data-[highlighted]:bg-white/[0.03] data-[highlighted]:text-white outline-none",e),...t}));hZ.displayName="SelectItem";const pZ=_.forwardRef(({className:e,...t},n)=>h.jsx("textarea",{ref:n,className:ge("bg-surface border border-border rounded-md px-3 py-2 font-mono text-[12px] text-foreground outline-none w-full transition focus:border-flow placeholder:text-neutral-600 resize-none min-h-[80px]",e),...t}));pZ.displayName="Textarea";const tk=_.createContext(void 0);function mZ(e=!0){const t=_.useContext(tk);if(t===void 0&&!e)throw new Error(yn(7));return t}function nk(e={}){const{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:s}=Aj(),{ref:i,index:a}=hx(e),l=n===a,f=_.useRef(null),d=oo(i,f);return{compositeProps:_.useMemo(()=>({tabIndex:l?0:-1,onFocus(){s(a)},onMouseMove(){const g=f.current;if(!t||!g)return;const y=g.hasAttribute("disabled")||g.ariaDisabled==="true";!l&&!y&&g.focus()}}),[l,s,a,t]),compositeRef:d,index:a}}function gZ(e){const{render:t,className:n,state:s=an,props:i=Ru,refs:a=Ru,metadata:l,stateAttributesMapping:f,tag:d="div",...p}=e,{compositeProps:g,compositeRef:y}=nk({metadata:l});return zt(d,e,{state:s,ref:[...a,y],props:[g,...i,p],stateAttributesMapping:f})}const yZ=_.forwardRef(function(t,n){const{className:s,defaultPressed:i=!1,disabled:a=!1,form:l,onPressedChange:f,pressed:d,render:p,type:g,value:y,nativeButton:b=!0,...x}=t,S=br(y||void 0),w=mZ(),T=w?.value??[],C=w?void 0:i,O=(a||w?.disabled)??!1,[N,R]=pp({controlled:w?S!==void 0&&T.indexOf(S)>-1:d,default:C,name:"Toggle",state:"pressed"}),M=Ae((U,Z)=>{S&&w?.setGroupValue?.(S,U,Z),f?.(U,Z)}),{getButtonProps:z,buttonRef:j}=Jc({disabled:O,native:b}),A={disabled:O,pressed:N},P=[j,n],Q=[{"aria-pressed":N,onClick(U){const Z=!N,K=Yt(ii,U.nativeEvent);M(Z,K),!K.isCanceled&&R(Z)}},x,z],B=zt("button",t,{enabled:!w,state:A,ref:P,props:Q});return w?h.jsx(gZ,{tag:"button",render:p,className:s,state:A,refs:P,props:Q}):B}),Dr=_.forwardRef(({className:e,...t},n)=>h.jsx(yZ,{ref:n,className:ge("font-mono text-[10px] text-neutral-500 border border-transparent rounded-sm px-2.5 py-1 cursor-pointer transition-all hover:text-neutral-300 data-[pressed]:text-white data-[pressed]:border-border-bright data-[pressed]:bg-white/[0.03]",e),...t}));Dr.displayName="Toggle";function vZ(e){return e==null||e.hasAttribute("disabled")||e.getAttribute("aria-disabled")==="true"}const rk="data-composite-item-active",bZ=[];function xZ(e){const{itemSizes:t,cols:n=1,loopFocus:s=!0,dense:i=!1,orientation:a="both",direction:l,highlightedIndex:f,onHighlightedIndexChange:d,rootRef:p,enableHomeAndEndKeys:g=!1,stopEventPropagation:y=!1,disabledIndices:b,modifierKeys:x=bZ}=e,[S,w]=_.useState(0),T=n>1,C=_.useRef(null),O=oo(C,p),N=_.useRef([]),R=_.useRef(!1),M=f??S,z=Ae((P,Q=!1)=>{if((d??w)(P),Q){const B=N.current[P];UC(C.current,B,l,a)}}),j=Ae(P=>{if(P.size===0||R.current)return;R.current=!0;const Q=Array.from(P.keys()),B=Q.find(Z=>Z?.hasAttribute(rk))??null,U=B?Q.indexOf(B):-1;U!==-1&&z(U),UC(C.current,B,l,a)}),A=_.useMemo(()=>({"aria-orientation":a==="both"?void 0:a,ref:O,onFocus(P){!C.current||!LC(P.target)||P.target.setSelectionRange(0,P.target.value.length??0)},onKeyDown(P){const Q=g?XG:WA;if(!Q.has(P.key)||SZ(P,x)||!C.current)return;const U=l==="rtl",Z=U?Au:Ec,K={horizontal:Z,vertical:Wi,both:Z}[a],ee=U?Ec:Au,D={horizontal:ee,vertical:wc,both:ee}[a];if(LC(P.target)&&!vZ(P.target)){const W=P.target.selectionStart,Y=P.target.selectionEnd,ae=P.target.value??"";if(W==null||P.shiftKey||W!==Y||P.key!==D&&W<ae.length||P.key!==K&&W>0)return}let G=M;const q=PV(N,b),V=DV(N,b);if(T){const W=t||Array.from({length:N.current.length},()=>({width:1,height:1})),Y=LV(W,n,i),ae=Y.findIndex(fe=>fe!=null&&!pu(N,fe,b)),se=Y.reduce((fe,Se,pe)=>Se!=null&&!pu(N,Se,b)?pe:fe,-1);G=Y[zV({current:Y.map(fe=>fe?N.current[fe]:null)},{event:P,orientation:a,loopFocus:s,cols:n,disabledIndices:$V([...b||N.current.map((fe,Se)=>pu(N,Se)?Se:void 0),void 0],Y),minIndex:ae,maxIndex:se,prevIndex:UV(M>V?q:M,W,Y,n,P.key===Wi?"bl":P.key===Ec?"tr":"tl"),rtl:U})]}const L={horizontal:[Z],vertical:[Wi],both:[Z,Wi]}[a],I={horizontal:[ee],vertical:[wc],both:[ee,wc]}[a],H=T?Q:{horizontal:g?ZG:XA,vertical:g?YG:QA,both:Q}[a];g&&(P.key===Ju?G=q:P.key===ef&&(G=V)),G===M&&(L.includes(P.key)||I.includes(P.key))&&(s&&G===V&&L.includes(P.key)?G=q:s&&G===q&&I.includes(P.key)?G=V:G=fr(N,{startingIndex:G,decrement:I.includes(P.key),disabledIndices:b})),G!==M&&!ch(N,G)&&(y&&P.stopPropagation(),H.has(P.key)&&P.preventDefault(),z(G,!0),queueMicrotask(()=>{N.current[G]?.focus()}))}}),[n,i,l,b,N,g,M,T,t,s,O,x,z,a,y]);return _.useMemo(()=>({props:A,highlightedIndex:M,onHighlightedIndexChange:z,elementsRef:N,disabledIndices:b,onMapChange:j,relayKeyboardEvent:A.onKeyDown}),[A,M,z,N,b,j])}function SZ(e,t){for(const n of tZ.values())if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function sk(e){const{render:t,className:n,refs:s=Ru,props:i=Ru,state:a=an,stateAttributesMapping:l,highlightedIndex:f,onHighlightedIndexChange:d,orientation:p,dense:g,itemSizes:y,loopFocus:b,cols:x,enableHomeAndEndKeys:S,onMapChange:w,stopEventPropagation:T=!0,rootRef:C,disabledIndices:O,modifierKeys:N,highlightItemOnHover:R=!1,tag:M="div",...z}=e,j=DA(),{props:A,highlightedIndex:P,onHighlightedIndexChange:Q,elementsRef:B,onMapChange:U,relayKeyboardEvent:Z}=xZ({itemSizes:y,cols:x,loopFocus:b,dense:g,orientation:p,highlightedIndex:f,onHighlightedIndexChange:d,rootRef:C,stopEventPropagation:T,enableHomeAndEndKeys:S,direction:j,disabledIndices:O,modifierKeys:N}),K=zt(M,e,{state:a,ref:s,props:[A,...i,z],stateAttributesMapping:l}),ee=_.useMemo(()=>({highlightedIndex:P,onHighlightedIndexChange:Q,highlightItemOnHover:R,relayKeyboardEvent:Z}),[P,Q,R,Z]);return h.jsx(jj.Provider,{value:ee,children:h.jsx(VA,{elementsRef:B,onMapChange:D=>{w?.(D),U(D)},children:K})})}let _Z=(function(e){return e.disabled="data-disabled",e.orientation="data-orientation",e.multiple="data-multiple",e})({});const qC={multiple(e){return e?{[_Z.multiple]:""}:null}},wZ=_.forwardRef(function(t,n){const{defaultValue:s,disabled:i=!1,loopFocus:a=!0,onValueChange:l,orientation:f="horizontal",multiple:d=!1,value:p,className:g,render:y,...b}=t,x=YA(),S=_.useMemo(()=>{if(p===void 0)return s??[]},[p,s]),w=_.useMemo(()=>p!==void 0||s!==void 0,[p,s]),T=(x?.disabled??!1)||i,[C,O]=pp({controlled:p,default:S,name:"ToggleGroup",state:"value"}),N=Ae((A,P,Q)=>{let B;if(d?(B=C.slice(),P?B.push(A):B.splice(C.indexOf(A),1)):B=P?[A]:[],Array.isArray(B)){if(l?.(B,Q),Q.isCanceled)return;O(B)}}),R={disabled:T,multiple:d,orientation:f},M=_.useMemo(()=>({disabled:T,orientation:f,setGroupValue:N,value:C,isValueInitialized:w}),[T,f,N,C,w]),z={role:"group"},j=zt("div",t,{enabled:!!x,state:R,ref:n,props:[z,b],stateAttributesMapping:qC});return h.jsx(tk.Provider,{value:M,children:x?j:h.jsx(sk,{render:y,className:g,state:R,refs:[n],props:[z,b],stateAttributesMapping:qC,loopFocus:a,enableHomeAndEndKeys:!0})})}),dh=_.forwardRef(({className:e,...t},n)=>h.jsx(wZ,{ref:n,className:ge("flex items-center gap-0.5",e),...t}));dh.displayName="ToggleGroup";const EZ=ge(Hj({variant:"secondary",size:"sm"}),"h-7 whitespace-nowrap uppercase tracking-[0.08em] leading-none no-underline");function ok({active:e,onClick:t,children:n,className:s}){return h.jsxs("button",{type:"button",onClick:t,className:ge("font-mono text-[10px] tracking-[1.5px] uppercase bg-transparent border-none px-3.5 py-1 cursor-pointer relative transition-colors",e?"text-white":"text-neutral-500 hover:text-neutral-300",s),children:[n,e&&h.jsx("span",{className:"absolute -bottom-2.5 left-1/2 -translate-x-1/2 w-4 h-0.5 bg-flow rounded-sm shadow-[0_0_8px_rgba(59,130,246,0.5)]"})]})}function TZ({items:e,activeId:t,onItemChange:n,renderItem:s,className:i}){return h.jsx("div",{className:ge("flex items-center gap-0.5",i),children:e.map(a=>{const l=a.id===t,f=()=>n?.(a.id);return s?h.jsx("span",{children:s(a,{active:l,onClick:f})},a.id):h.jsx(ok,{active:l,onClick:f,children:a.label},a.id)})})}const CZ=gi("rounded-full inline-block flex-shrink-0",{variants:{color:{healthy:"bg-healthy",syncing:"bg-syncing",offline:"bg-offline",flow:"bg-flow",relay:"bg-relay",encrypt:"bg-encrypt",muted:"bg-neutral-500"},size:{sm:"w-1.5 h-1.5",md:"w-2 h-2",lg:"w-2.5 h-2.5"},glow:{true:"",false:""}},defaultVariants:{color:"healthy",size:"sm",glow:!1}}),RZ={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 NZ({color:e,size:t,glow:n,pulse:s,className:i}){return h.jsx("span",{className:ge(CZ({color:e,size:t,glow:n}),s&&"dot-pulse",i),style:n?{boxShadow:RZ[e??"healthy"]}:void 0})}const jZ="0.0.6-80",AZ={version:jZ},kZ=AZ.version;function OZ({label:e,className:t}){return h.jsxs("div",{className:ge("flex items-center gap-3",t),children:[h.jsx(NZ,{color:"healthy",size:"md",glow:!0}),h.jsx("span",{className:"font-display font-bold text-white text-sm tracking-tight",children:"syncular"}),e&&h.jsx("span",{className:"font-mono text-[9px] text-neutral-600 uppercase tracking-widest",children:e}),h.jsxs("span",{className:"font-mono text-[9px] text-neutral-600 tracking-wider",children:["v",kZ]})]})}function MZ({brand:e,center:t,right:n,className:s}){return h.jsxs(h.Fragment,{children:[h.jsx("div",{"aria-hidden":"true",className:"h-[42px] shrink-0"}),h.jsxs("nav",{className:ge("fixed top-0 left-0 right-0 z-100 h-[42px] border-b border-border bg-surface/88 backdrop-blur-lg flex items-center justify-between px-5",s),children:[h.jsx("div",{className:"flex items-center gap-3",children:e}),h.jsx("div",{className:"flex items-center gap-0.5",children:t}),h.jsx("div",{className:"flex items-center gap-2",children:n})]})]})}const IZ=gi("border rounded-lg p-3 font-mono text-[11px]",{variants:{variant:{default:"border-border bg-panel",destructive:"border-offline/20 bg-offline/5 text-offline"}},defaultVariants:{variant:"default"}}),In=_.forwardRef(({className:e,variant:t,...n},s)=>h.jsx("div",{ref:s,role:"alert",className:ge(IZ({variant:t,className:e})),...n}));In.displayName="Alert";const tf=_.forwardRef(({className:e,...t},n)=>h.jsx("h5",{ref:n,className:ge("font-medium text-white mb-1",e),...t}));tf.displayName="AlertTitle";const Pn=_.forwardRef(({className:e,...t},n)=>h.jsx("p",{ref:n,className:ge("text-neutral-400",e),...t}));Pn.displayName="AlertDescription";const ik=_.createContext(void 0);function il(e){const t=_.useContext(ik);if(e===!1&&t===void 0)throw new Error(yn(27));return t}const PZ={...ol,...ba},px=_.forwardRef(function(t,n){const{render:s,className:i,forceRender:a=!1,...l}=t,{store:f}=il(),d=f.useState("open"),p=f.useState("nested"),g=f.useState("mounted"),y=f.useState("transitionStatus");return zt("div",t,{state:{open:d,transitionStatus:y},ref:[f.context.backdropRef,n],stateAttributesMapping:PZ,props:[{role:"presentation",hidden:!g,style:{userSelect:"none",WebkitUserSelect:"none"}},l],enabled:a||!p})}),ak=_.forwardRef(function(t,n){const{render:s,className:i,id:a,...l}=t,{store:f}=il(),d=br(a);return f.useSyncedValueWithCleanup("descriptionElementId",d),zt("p",t,{ref:n,props:[{id:d},l]})});let DZ=(function(e){return e.nestedDialogs="--nested-dialogs",e})({}),zZ=(function(e){return e[e.open=Qi.open]="open",e[e.closed=Qi.closed]="closed",e[e.startingStyle=Qi.startingStyle]="startingStyle",e[e.endingStyle=Qi.endingStyle]="endingStyle",e.nested="data-nested",e.nestedDialogOpen="data-nested-dialog-open",e})({});const ck=_.createContext(void 0);function LZ(){const e=_.useContext(ck);if(e===void 0)throw new Error(yn(26));return e}const UZ={...ol,...ba,nestedDialogOpen(e){return e?{[zZ.nestedDialogOpen]:""}:null}},lk=_.forwardRef(function(t,n){const{className:s,finalFocus:i,initialFocus:a,render:l,...f}=t,{store:d}=il(),p=d.useState("descriptionElementId"),g=d.useState("disablePointerDismissal"),y=d.useState("floatingRootContext"),b=d.useState("popupProps"),x=d.useState("modal"),S=d.useState("mounted"),w=d.useState("nested"),T=d.useState("nestedOpenDialogCount"),C=d.useState("open"),O=d.useState("openMethod"),N=d.useState("titleElementId"),R=d.useState("transitionStatus"),M=d.useState("role");LZ(),xa({open:C,ref:d.context.popupRef,onComplete(){C&&d.context.onOpenChangeComplete?.(!0)}});function z(B){return B==="touch"?d.context.popupRef.current:!0}const j=a===void 0?z:a,A=T>0,Q=zt("div",t,{state:{open:C,nested:w,transitionStatus:R,nestedDialogOpen:A},props:[b,{"aria-labelledby":N??void 0,"aria-describedby":p??void 0,role:M,tabIndex:-1,hidden:!S,onKeyDown(B){JA.has(B.key)&&B.stopPropagation()},style:{[DZ.nestedDialogs]:T}},f],ref:[n,d.context.popupRef,d.useStateSetter("popupElement")],stateAttributesMapping:UZ});return h.jsx(EA,{context:y,openInteractionType:O,disabled:!S,closeOnFocusOut:!g,initialFocus:j,returnFocus:i,modal:x!==!1,restoreFocus:"popup",children:Q})}),uk=_.forwardRef(function(t,n){const{keepMounted:s=!1,...i}=t,{store:a}=il(),l=a.useState("mounted"),f=a.useState("modal"),d=a.useState("open");return l||s?h.jsx(ck.Provider,{value:s,children:h.jsxs(wA,{ref:n,...i,children:[l&&f===!0&&h.jsx(GA,{ref:a.context.internalBackdropRef,inert:dx(!d)}),t.children]})}):null});function $Z(e){const{store:t,parentContext:n,actionsRef:s}=e,i=t.useState("open"),a=t.useState("disablePointerDismissal"),l=t.useState("modal"),f=t.useState("popupElement"),{openMethod:d,triggerProps:p,reset:g}=CG(i);g7(t);const{forceUnmount:y}=y7(i,t,()=>{g()}),b=Ae(Q=>{const B=Yt(Q);return B.preventUnmountOnClose=()=>{t.set("preventUnmountingOnClose",!0)},B}),x=_.useCallback(()=>{t.setOpen(!1,b(x8))},[t,b]);_.useImperativeHandle(s,()=>({unmount:y,close:x}),[y,x]);const S=w7({popupStore:t,onOpenChange:t.setOpen,treatPopupAsFloatingElement:!0,noEmit:!0}),[w,T]=_.useState(0),C=w===0,O=O7(S),N=s7(S,{outsidePressEvent(){return t.context.internalBackdropRef.current||t.context.backdropRef.current?"intentional":{mouse:l==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}},outsidePress(Q){if(!t.context.outsidePressEnabledRef.current||"button"in Q&&Q.button!==0||"touches"in Q&&Q.touches.length!==1)return!1;const B=Ur(Q);if(C&&!a){const U=B;return l&&(t.context.internalBackdropRef.current||t.context.backdropRef.current)?t.context.internalBackdropRef.current===U||t.context.backdropRef.current===U||Ot(U,f)&&!U?.hasAttribute("data-base-ui-portal"):!0}return!1},escapeKey:C});HA(i&&l===!0,f);const{getReferenceProps:R,getFloatingProps:M,getTriggerProps:z}=A7([O,N]);t.useContextCallback("onNestedDialogOpen",Q=>{T(Q+1)}),t.useContextCallback("onNestedDialogClose",()=>{T(0)}),_.useEffect(()=>(n?.onNestedDialogOpen&&i&&n.onNestedDialogOpen(w),n?.onNestedDialogClose&&!i&&n.onNestedDialogClose(),()=>{n?.onNestedDialogClose&&i&&n.onNestedDialogClose()}),[i,n,w]);const j=_.useMemo(()=>R(p),[R,p]),A=_.useMemo(()=>z(p),[z,p]),P=_.useMemo(()=>M(),[M]);t.useSyncedValues({openMethod:d,activeTriggerProps:j,inactiveTriggerProps:A,popupProps:P,floatingRootContext:S,nestedOpenDialogCount:w})}const BZ={...x7,modal:Pe(e=>e.modal),nested:Pe(e=>e.nested),nestedOpenDialogCount:Pe(e=>e.nestedOpenDialogCount),disablePointerDismissal:Pe(e=>e.disablePointerDismissal),openMethod:Pe(e=>e.openMethod),descriptionElementId:Pe(e=>e.descriptionElementId),titleElementId:Pe(e=>e.titleElementId),viewportElement:Pe(e=>e.viewportElement),role:Pe(e=>e.role)};class FZ extends MA{constructor(t){super(HZ(t),{popupRef:_.createRef(),backdropRef:_.createRef(),internalBackdropRef:_.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:new ux,onOpenChange:void 0,onOpenChangeComplete:void 0},BZ)}setOpen=(t,n)=>{if(n.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},!t&&n.trigger==null&&this.state.activeTriggerId!=null&&(n.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(t,n),n.isCanceled)return;const s={open:t,nativeEvent:n.event,reason:n.reason,nested:this.state.nested};this.state.floatingRootContext.context.events?.emit("openchange",s);const i={open:t},a=n.trigger?.id??null;(a||t)&&(i.activeTriggerId=a,i.activeTriggerElement=n.trigger??null),this.update(i)}}function HZ(e={}){return{...b7(),modal:!0,disablePointerDismissal:!1,popupElement:null,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,role:"dialog",...e}}function qZ(e){const{children:t,open:n,defaultOpen:s=!1,onOpenChange:i,onOpenChangeComplete:a,disablePointerDismissal:l=!1,modal:f=!0,actionsRef:d,handle:p,triggerId:g,defaultTriggerId:y=null}=e,b=il(!0),x=!!b,S=zn(()=>p?.store??new FZ({open:s,openProp:n,activeTriggerId:y,triggerIdProp:g,modal:f,disablePointerDismissal:l,nested:x})).current;iV(()=>{n===void 0&&S.state.open===!1&&s===!0&&S.update({open:!0,activeTriggerId:y})}),S.useControlledProp("openProp",n),S.useControlledProp("triggerIdProp",g),S.useSyncedValues({disablePointerDismissal:l,nested:x,modal:f}),S.useContextCallback("onOpenChange",i),S.useContextCallback("onOpenChangeComplete",a);const w=S.useState("payload");$Z({store:S,actionsRef:d,parentContext:b?.store.context});const T=_.useMemo(()=>({store:S}),[S]);return h.jsx(ik.Provider,{value:T,children:typeof t=="function"?t({payload:w}):t})}const fk=_.forwardRef(function(t,n){const{render:s,className:i,id:a,...l}=t,{store:f}=il(),d=br(a);return f.useSyncedValueWithCleanup("titleElementId",d),zt("h2",t,{ref:n,props:[{id:d},l]})}),$r=qZ,VZ=_.forwardRef(({className:e,...t},n)=>h.jsx(px,{ref:n,className:ge("fixed inset-0 z-50 bg-black/60 backdrop-blur-sm",e),...t}));VZ.displayName="DialogOverlay";const hr=_.forwardRef(({className:e,children:t,...n},s)=>h.jsxs(uk,{children:[h.jsx(px,{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm"}),h.jsx(lk,{ref:s,className:ge("fixed z-50 top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-panel border border-border rounded-lg shadow-lg max-w-lg w-full p-0",e),...n,children:t})]}));hr.displayName="DialogContent";const pr=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("px-5 py-3 border-b border-border",e),...t}));pr.displayName="DialogHeader";const Nn=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("px-5 py-3 border-t border-border flex justify-end gap-2",e),...t}));Nn.displayName="DialogFooter";const mr=_.forwardRef(({className:e,...t},n)=>h.jsx(fk,{ref:n,className:ge("font-mono text-[10px] text-neutral-500 uppercase tracking-widest",e),...t}));mr.displayName="DialogTitle";const KZ=_.forwardRef(({className:e,...t},n)=>h.jsx(ak,{ref:n,className:ge("font-mono text-[10px] text-neutral-500",e),...t}));KZ.displayName="DialogDescription";const mx=_.forwardRef(({className:e,page:t,totalPages:n,totalItems:s,onPageChange:i,...a},l)=>h.jsxs("div",{ref:l,className:ge("px-5 py-2.5 border-t border-border flex items-center justify-between",e),...a,children:[h.jsxs("span",{className:"font-mono text-[10px] text-neutral-600",children:[s," items · Page ",t," of ",n]}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx(Me,{size:"sm",variant:"default",disabled:t<=1,onClick:()=>i(t-1),children:"Prev"}),h.jsx(Me,{size:"sm",variant:"default",disabled:t>=n,onClick:()=>i(t+1),children:"Next"})]})]}));mx.displayName="Pagination";const GZ=_.forwardRef(({className:e,orientation:t="horizontal",...n},s)=>h.jsx("hr",{ref:s,"aria-orientation":t==="vertical"?"vertical":void 0,className:ge("border-none m-0",t==="horizontal"?"h-px w-full bg-border":"w-px h-4 bg-border",e),...n}));GZ.displayName="Separator";const ZZ=gi("fixed z-50 bg-panel shadow-lg overflow-auto",{variants:{side:{top:"top-0 left-0 w-full h-[400px] border-b border-border",right:"right-0 top-0 h-full w-[400px] border-l border-border",bottom:"bottom-0 left-0 w-full h-[400px] border-t border-border",left:"left-0 top-0 h-full w-[400px] border-r border-border"}},defaultVariants:{side:"right"}}),YZ=_.forwardRef(({className:e,side:t,children:n,...s},i)=>h.jsxs(uk,{children:[h.jsx(px,{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm"}),h.jsx(lk,{ref:i,className:ge(ZZ({side:t,className:e})),...s,children:n})]}));YZ.displayName="SheetContent";const XZ=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("px-5 py-3 border-b border-border",e),...t}));XZ.displayName="SheetHeader";const QZ=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("px-5 py-3 border-t border-border flex justify-end gap-2",e),...t}));QZ.displayName="SheetFooter";const WZ=_.forwardRef(({className:e,...t},n)=>h.jsx(fk,{ref:n,className:ge("font-mono text-[10px] text-neutral-500 uppercase tracking-widest",e),...t}));WZ.displayName="SheetTitle";const JZ=_.forwardRef(({className:e,...t},n)=>h.jsx(ak,{ref:n,className:ge("text-sm text-neutral-400",e),...t}));JZ.displayName="SheetDescription";const eY=_.forwardRef(({className:e,...t},n)=>h.jsx("div",{ref:n,className:ge("rounded-md bg-neutral-800 animate-pulse",e),...t}));eY.displayName="Skeleton";const tY=_.createContext(void 0);function gx(){const e=_.useContext(tY);if(e===void 0)throw new Error(yn(64));return e}let nY=(function(e){return e.activationDirection="data-activation-direction",e.orientation="data-orientation",e})({});const dk={tabActivationDirection:e=>({[nY.activationDirection]:e})},hk=_.createContext(void 0);function rY(){const e=_.useContext(hk);if(e===void 0)throw new Error(yn(65));return e}const sY=_.forwardRef(function(t,n){const{className:s,disabled:i=!1,render:a,value:l,id:f,nativeButton:d=!0,...p}=t,{value:g,getTabPanelIdByValue:y,orientation:b}=gx(),{activateOnFocus:x,highlightedTabIndex:S,onTabActivation:w,setHighlightedTabIndex:T,tabsListElement:C}=rY(),O=br(f),N=_.useMemo(()=>({disabled:i,id:O,value:l}),[i,O,l]),{compositeProps:R,compositeRef:M,index:z}=nk({metadata:N}),j=l===g,A=_.useRef(!1);Le(()=>{if(A.current){A.current=!1;return}if(!(j&&z>-1&&S!==z))return;const V=C;if(V!=null){const L=Fo(Rt(V));if(L&&Ot(V,L))return}i||T(z)},[j,z,S,T,i,C]);const{getButtonProps:P,buttonRef:Q}=Jc({disabled:i,native:d,focusableWhenDisabled:!0}),B=y(l),U=_.useRef(!1),Z=_.useRef(!1);function K(V){j||i||w(l,Yt(ii,V.nativeEvent,void 0,{activationDirection:"none"}))}function ee(V){j||(z>-1&&!i&&T(z),!i&&x&&(!U.current||U.current&&Z.current)&&w(l,Yt(ii,V.nativeEvent,void 0,{activationDirection:"none"})))}function D(V){if(j||i)return;U.current=!0;function L(){U.current=!1,Z.current=!1}(!V.button||V.button===0)&&(Z.current=!0,Rt(V.currentTarget).addEventListener("pointerup",L,{once:!0}))}return zt("button",t,{state:{disabled:i,active:j,orientation:b},ref:[n,Q,M],props:[R,{role:"tab","aria-controls":B,"aria-selected":j,id:O,onClick:K,onFocus:ee,onPointerDown:D,[rk]:j?"":void 0,onKeyDownCapture(){A.current=!0}},p,P]})});let oY=(function(e){return e.index="data-index",e.activationDirection="data-activation-direction",e.orientation="data-orientation",e.hidden="data-hidden",e})({});const iY={...dk,...ba},aY=_.forwardRef(function(t,n){const{className:s,value:i,render:a,keepMounted:l=!1,...f}=t,{value:d,getTabIdByPanelValue:p,orientation:g,tabActivationDirection:y,registerMountedTabPanel:b,unregisterMountedTabPanel:x}=gx(),S=br(),w=_.useMemo(()=>({id:S,value:i}),[S,i]),{ref:T,index:C}=hx({metadata:w}),O=i===d,{mounted:N,transitionStatus:R,setMounted:M}=Rp(O),z=!N,j=p(i),A={hidden:z,orientation:g,tabActivationDirection:y,transitionStatus:R},P=_.useRef(null),Q=zt("div",t,{state:A,ref:[n,T,P],props:[{"aria-labelledby":j,hidden:z,id:S,role:"tabpanel",tabIndex:O?0:-1,inert:dx(!O),[oY.index]:C},f],stateAttributesMapping:iY});return xa({open:O,ref:P,onComplete(){O||M(!1)}}),Le(()=>{if(!(z&&!l)&&S!=null)return b(i,S),()=>{x(i,S)}},[z,l,i,S,b,x]),l||N?Q:null}),cY=_.forwardRef(function(t,n){const{activateOnFocus:s=!1,className:i,loopFocus:a=!0,render:l,...f}=t,{getTabElementBySelectedValue:d,onValueChange:p,orientation:g,value:y,setTabMap:b,tabActivationDirection:x}=gx(),[S,w]=_.useState(0),[T,C]=_.useState(null),O=lY(y,g,T,d),N=Ae((j,A)=>{if(j!==y){const P=O(j);A.activationDirection=P,p(j,A)}}),R={orientation:g,tabActivationDirection:x},M={"aria-orientation":g==="vertical"?"vertical":void 0,role:"tablist"},z=_.useMemo(()=>({activateOnFocus:s,highlightedTabIndex:S,onTabActivation:N,setHighlightedTabIndex:w,tabsListElement:T,value:y}),[s,S,N,w,T,y]);return h.jsx(hk.Provider,{value:z,children:h.jsx(sk,{render:l,className:i,state:R,refs:[n,C],props:[M,f],stateAttributesMapping:dk,highlightedIndex:S,enableHomeAndEndKeys:!0,loopFocus:a,orientation:g,onHighlightedIndexChange:w,onMapChange:b,disabledIndices:Ru})})});function VC(e,t){const{left:n,top:s}=e.getBoundingClientRect(),{left:i,top:a}=t.getBoundingClientRect(),l=n-i,f=s-a;return{left:l,top:f}}function lY(e,t,n,s){const[i,a]=_.useState(null);return Le(()=>{if(e==null||n==null){a(null);return}const l=s(e);if(l==null){a(null);return}const{left:f,top:d}=VC(l,n);a(t==="horizontal"?f:d)},[t,s,n,e]),_.useCallback(l=>{if(l===e)return"none";if(l==null)return a(null),"none";if(l!=null&&n!=null){const f=s(l);if(f!=null){const{left:d,top:p}=VC(f,n);if(i==null)return a(t==="horizontal"?d:p),"none";if(t==="horizontal"){if(d<i)return a(d),"left";if(d>i)return a(d),"right"}else{if(p<i)return a(p),"up";if(p>i)return a(p),"down"}}}return"none"},[s,t,i,n,e])}const uY=_.forwardRef(({className:e,...t},n)=>h.jsx(cY,{ref:n,className:ge("flex items-center gap-0.5",e),...t}));uY.displayName="TabsList";const fY=gi("inline-flex items-center justify-center cursor-pointer transition-all outline-none",{variants:{variant:{default:"font-mono text-[10px] text-neutral-500 border border-transparent rounded-sm px-2.5 py-1 hover:text-neutral-300 data-[selected]:text-white data-[selected]:border-border-bright data-[selected]:bg-white/[0.03]",pills:"font-mono text-[10px] text-neutral-500 border border-transparent rounded-full px-3 py-1 hover:text-neutral-300 data-[selected]:text-white data-[selected]:border-border-bright data-[selected]:bg-white/[0.03]"}},defaultVariants:{variant:"default"}}),dY=_.forwardRef(({className:e,variant:t,...n},s)=>h.jsx(sY,{ref:s,className:ge(fY({variant:t,className:e})),...n}));dY.displayName="TabsTrigger";const hY=_.forwardRef(({className:e,...t},n)=>h.jsx(aY,{ref:n,className:ge("outline-none",e),...t}));hY.displayName="TabsContent";const pY=_.forwardRef(({className:e,...t},n)=>h.jsx("p",{ref:n,className:ge("font-mono text-[11px] text-neutral-300",e),...t}));pY.displayName="Text";const mY=_.forwardRef(({className:e,...t},n)=>h.jsx("p",{ref:n,className:ge("font-mono text-[10px] text-neutral-500",e),...t}));mY.displayName="TextMuted";const gY=_.forwardRef(({className:e,...t},n)=>h.jsx("code",{ref:n,className:ge("font-mono text-[11px] text-white",e),...t}));gY.displayName="TextCode";const yY=_.forwardRef(({className:e,...t},n)=>h.jsx("span",{ref:n,className:ge("font-mono text-[9px] uppercase tracking-wider text-neutral-500",e),...t}));yY.displayName="TextLabel";const vY=_.forwardRef(({className:e,...t},n)=>h.jsx("pre",{ref:n,className:ge("font-mono text-[11px] text-neutral-300 p-3 rounded border border-border bg-panel-alt overflow-x-auto",e),...t}));vY.displayName="CodeBlock";const bY="console:instance-id";function Lt(){const[e,t]=pi(bY,""),n=e.trim();return _.useMemo(()=>({instanceId:n.length>0?n:void 0,rawInstanceId:e,setInstanceId:t,clearInstanceId:()=>t("")}),[n,e,t])}const Jn={stats:e=>["console","stats",e],timeseries:e=>["console","stats","timeseries",e],latency:e=>["console","stats","latency",e],commits:e=>["console","commits",e],commitDetail:(e,t,n)=>["console","commit-detail",e,t,n],timeline:e=>["console","timeline",e],clients:e=>["console","clients",e],eventDetail:(e,t,n)=>["console","event-detail",e,t,n],eventPayload:(e,t,n)=>["console","event-payload",e,t,n],handlers:e=>["console","handlers",e],prunePreview:e=>["console","prune","preview",e],operations:e=>["console","operations",e],apiKeys:e=>["console","api-keys",e],storage:e=>["console","storage",e]};function _i(e,t){return e===0?!1:e??t}function nf(e,t){return t?{...e,instanceId:t}:e}function Sa(e){return encodeURIComponent(String(e))}function Ln(e,t,n){const s=e.endsWith("/")?e.slice(0,-1):e,i=n?.toString();return`${s}${t}${i?`?${i}`:""}`}function rf(e={}){const t=Vt(),{instanceId:n}=Lt(),s=e.instanceId??n,i=nf(e.partitionId?{partitionId:e.partitionId}:{},s);return Wn({queryKey:Jn.stats({partitionId:e.partitionId,instanceId:s}),queryFn:()=>{if(!t)throw new Error("Not connected");return Yu(t.GET("/console/stats",{params:{query:i}}))},enabled:!!t,refetchInterval:_i(e.refetchIntervalMs,5e3)})}function xY(e={},t={}){const n=Vt(),{config:s}=Dt(),{instanceId:i}=Lt(),a=e.instanceId??i;return Wn({queryKey:Jn.timeseries({...e,instanceId:a}),queryFn:async()=>{if(!n||!s)throw new Error("Not connected");const l=new URLSearchParams;e.interval&&l.set("interval",e.interval),e.range&&l.set("range",e.range),e.partitionId&&l.set("partitionId",e.partitionId),a&&l.set("instanceId",a);const f=await fetch(`${s.serverUrl}/console/stats/timeseries?${l}`,{headers:{Authorization:`Bearer ${s.token}`}});if(!f.ok)throw new Error("Failed to fetch timeseries stats");return f.json()},enabled:(t.enabled??!0)&&!!n&&!!s,refetchInterval:_i(t.refetchIntervalMs,3e4)})}function SY(e={},t={}){const n=Vt(),{config:s}=Dt(),{instanceId:i}=Lt(),a=e.instanceId??i;return Wn({queryKey:Jn.latency({...e,instanceId:a}),queryFn:async()=>{if(!n||!s)throw new Error("Not connected");const l=new URLSearchParams;e.range&&l.set("range",e.range),e.partitionId&&l.set("partitionId",e.partitionId),a&&l.set("instanceId",a);const f=await fetch(`${s.serverUrl}/console/stats/latency?${l}`,{headers:{Authorization:`Bearer ${s.token}`}});if(!f.ok)throw new Error("Failed to fetch latency stats");return f.json()},enabled:(t.enabled??!0)&&!!n&&!!s,refetchInterval:_i(t.refetchIntervalMs,3e4)})}function _Y(e={},t={}){const n=Vt(),{instanceId:s}=Lt(),i=e.instanceId??s,a=nf({limit:e.limit,offset:e.offset,partitionId:e.partitionId},i);return Wn({queryKey:Jn.commits({...e,instanceId:i}),queryFn:()=>{if(!n)throw new Error("Not connected");return Yu(n.GET("/console/commits",{params:{query:a}}))},enabled:(t.enabled??!0)&&!!n,refetchInterval:_i(t.refetchIntervalMs,1e4)})}function wY(e,t={}){const n=Vt(),{config:s}=Dt(),{instanceId:i}=Lt(),a=t.instanceId??i;return Wn({queryKey:Jn.commitDetail(e,t.partitionId,a),queryFn:async()=>{if(!n||!s)throw new Error("Not connected");if(e===void 0)throw new Error("Commit sequence is required");const l=new URLSearchParams;t.partitionId&&l.set("partitionId",t.partitionId),a&&l.set("instanceId",a);const f=l.toString(),d=await fetch(`${s.serverUrl}/console/commits/${Sa(e)}${f?`?${f}`:""}`,{headers:{Authorization:`Bearer ${s.token}`}});if(!d.ok)throw new Error("Failed to fetch commit detail");return d.json()},enabled:(t.enabled??!0)&&e!==void 0&&!!n})}function EY(e={},t={}){const n=Vt(),{instanceId:s}=Lt(),i=e.instanceId??s,a=nf({limit:e.limit,offset:e.offset,partitionId:e.partitionId,view:e.view,eventType:e.eventType,actorId:e.actorId,clientId:e.clientId,requestId:e.requestId,traceId:e.traceId,table:e.table,outcome:e.outcome,search:e.search,from:e.from,to:e.to},i);return Wn({queryKey:Jn.timeline({...e,instanceId:i}),queryFn:()=>{if(!n)throw new Error("Not connected");return Yu(n.GET("/console/timeline",{params:{query:a}}))},enabled:(t.enabled??!0)&&!!n,refetchInterval:_i(t.refetchIntervalMs,1e4)})}function pk(e={},t={}){const n=Vt(),{instanceId:s}=Lt(),i=e.instanceId??s,a=nf({limit:e.limit,offset:e.offset,partitionId:e.partitionId},i);return Wn({queryKey:Jn.clients({...e,instanceId:i}),queryFn:()=>{if(!n)throw new Error("Not connected");return Yu(n.GET("/console/clients",{params:{query:a}}))},enabled:(t.enabled??!0)&&!!n,refetchInterval:_i(t.refetchIntervalMs,1e4)})}function TY(e,t={}){const n=Vt(),{config:s}=Dt(),{instanceId:i}=Lt(),a=t.instanceId??i;return Wn({queryKey:Jn.eventDetail(e,t.partitionId,a),queryFn:async()=>{if(!n||!s)throw new Error("Not connected");if(e===void 0)throw new Error("Event id is required");const l=new URLSearchParams;t.partitionId&&l.set("partitionId",t.partitionId),a&&l.set("instanceId",a);const f=l.toString(),d=await fetch(`${s.serverUrl}/console/events/${Sa(e)}${f?`?${f}`:""}`,{headers:{Authorization:`Bearer ${s.token}`}});if(!d.ok)throw new Error("Failed to fetch event detail");return d.json()},enabled:(t.enabled??!0)&&e!==void 0&&!!n})}function CY(e,t={}){const n=Vt(),{config:s}=Dt(),{instanceId:i}=Lt(),a=t.instanceId??i;return Wn({queryKey:Jn.eventPayload(e,t.partitionId,a),queryFn:async()=>{if(!n||!s)throw new Error("Not connected");if(e===void 0)throw new Error("Event id is required");const l=new URLSearchParams;t.partitionId&&l.set("partitionId",t.partitionId),a&&l.set("instanceId",a);const f=l.toString(),d=await fetch(`${s.serverUrl}/console/events/${Sa(e)}/payload${f?`?${f}`:""}`,{headers:{Authorization:`Bearer ${s.token}`}});if(!d.ok)throw new Error("Failed to fetch event payload");return d.json()},enabled:(t.enabled??!0)&&e!==void 0&&!!n})}function RY(e={}){const t=Vt(),{config:n}=Dt(),{instanceId:s}=Lt(),i=e.instanceId??s;return Wn({queryKey:Jn.handlers(i),queryFn:async()=>{if(!t||!n)throw new Error("Not connected");const a=new URLSearchParams;i&&a.set("instanceId",i);const l=await fetch(Ln(n.serverUrl,"/console/handlers",a),{headers:{Authorization:`Bearer ${n.token}`}});if(!l.ok)throw new Error("Failed to fetch handlers");return l.json()},enabled:!!t&&!!n})}function NY(e={}){const t=Vt(),{config:n}=Dt(),{instanceId:s}=Lt(),i=e.instanceId??s;return Wn({queryKey:Jn.prunePreview(i),queryFn:async()=>{if(!t||!n)throw new Error("Not connected");const a=new URLSearchParams;i&&a.set("instanceId",i);const l=await fetch(Ln(n.serverUrl,"/console/prune/preview",a),{method:"POST",headers:{Authorization:`Bearer ${n.token}`}});if(!l.ok)throw new Error("Failed to fetch prune preview");return l.json()},enabled:!!t&&!!n&&(e.enabled??!0)})}function jY(e={},t={}){const n=Vt(),{instanceId:s}=Lt(),i=e.instanceId??s,a=nf({limit:e.limit,offset:e.offset,operationType:e.operationType,partitionId:e.partitionId},i);return Wn({queryKey:Jn.operations({...e,instanceId:i}),queryFn:()=>{if(!n)throw new Error("Not connected");return Yu(n.GET("/console/operations",{params:{query:a}}))},enabled:(t.enabled??!0)&&!!n,refetchInterval:_i(t.refetchIntervalMs,1e4)})}function AY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async({clientId:i,partitionId:a,instanceId:l})=>{if(!e||!t)throw new Error("Not connected");const f=l??n,d=new URLSearchParams;a&&d.set("partitionId",a),f&&d.set("instanceId",f);const p=await fetch(Ln(t.serverUrl,`/console/clients/${Sa(i)}`,d),{method:"DELETE",headers:{Authorization:`Bearer ${t.token}`}});if(!p.ok)throw new Error("Failed to evict client");return p.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","clients"]}),s.invalidateQueries({queryKey:["console","stats"]}),s.invalidateQueries({queryKey:["console","operations"]})}})}function kY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async()=>{if(!e||!t)throw new Error("Not connected");const i=new URLSearchParams;n&&i.set("instanceId",n);const a=await fetch(Ln(t.serverUrl,"/console/prune",i),{method:"POST",headers:{Authorization:`Bearer ${t.token}`}});if(!a.ok)throw new Error("Failed to prune");return a.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","stats"]}),s.invalidateQueries({queryKey:["console","commits"]}),s.invalidateQueries({queryKey:["console","timeline"]}),s.invalidateQueries({queryKey:["console","prune","preview"]}),s.invalidateQueries({queryKey:["console","operations"]})}})}function OY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async()=>{if(!e||!t)throw new Error("Not connected");const i=new URLSearchParams;n&&i.set("instanceId",n);const a=await fetch(Ln(t.serverUrl,"/console/compact",i),{method:"POST",headers:{Authorization:`Bearer ${t.token}`}});if(!a.ok)throw new Error("Failed to compact");return a.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","stats"]}),s.invalidateQueries({queryKey:["console","operations"]})}})}function MY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async i=>{if(!e||!t)throw new Error("Not connected");const a=i.instanceId??n,l=new URLSearchParams;a&&l.set("instanceId",a);const f=await fetch(Ln(t.serverUrl,"/console/notify-data-change",l),{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"Content-Type":"application/json"},body:JSON.stringify({tables:i.tables,partitionId:i.partitionId})});if(!f.ok)throw new Error("Failed to notify data change");return f.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","stats"]}),s.invalidateQueries({queryKey:["console","commits"]}),s.invalidateQueries({queryKey:["console","timeline"]}),s.invalidateQueries({queryKey:["console","operations"]})}})}function IY(e={}){const t=Vt(),{config:n}=Dt(),{instanceId:s}=Lt(),i=e.instanceId??s;return Wn({queryKey:Jn.apiKeys({...e,instanceId:i}),queryFn:async()=>{if(!t||!n)throw new Error("Not connected");const a=new URLSearchParams;e.limit!==void 0&&a.set("limit",String(e.limit)),e.offset!==void 0&&a.set("offset",String(e.offset)),e.type&&a.set("type",e.type),e.status&&a.set("status",e.status),e.expiresWithinDays!==void 0&&a.set("expiresWithinDays",String(e.expiresWithinDays)),i&&a.set("instanceId",i);const l=await fetch(Ln(n.serverUrl,"/console/api-keys",a),{headers:{Authorization:`Bearer ${n.token}`}});if(!l.ok)throw new Error("Failed to fetch API keys");return l.json()},enabled:!!t&&!!n})}function PY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async i=>{if(!e||!t)throw new Error("Not connected");const a=new URLSearchParams;n&&a.set("instanceId",n);const l=await fetch(Ln(t.serverUrl,"/console/api-keys",a),{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"Content-Type":"application/json"},body:JSON.stringify(i)});if(!l.ok)throw new Error("Failed to create API key");return l.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","api-keys"]})}})}function DY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async i=>{if(!e||!t)throw new Error("Not connected");const a=new URLSearchParams;n&&a.set("instanceId",n);const l=await fetch(Ln(t.serverUrl,`/console/api-keys/${Sa(i)}`,a),{method:"DELETE",headers:{Authorization:`Bearer ${t.token}`}});if(!l.ok)throw new Error("Failed to revoke API key");return l.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","api-keys"]})}})}function zY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async i=>{if(!e||!t)throw new Error("Not connected");const a=new URLSearchParams;n&&a.set("instanceId",n);const l=await fetch(Ln(t.serverUrl,"/console/api-keys/bulk-revoke",a),{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"Content-Type":"application/json"},body:JSON.stringify(i)});if(!l.ok)throw new Error("Failed to bulk revoke API keys");return l.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","api-keys"]})}})}function LY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async i=>{if(!e||!t)throw new Error("Not connected");const a=new URLSearchParams;n&&a.set("instanceId",n);const l=await fetch(Ln(t.serverUrl,`/console/api-keys/${Sa(i)}/rotate`,a),{method:"POST",headers:{Authorization:`Bearer ${t.token}`}});if(!l.ok)throw new Error("Failed to rotate API key");return l.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","api-keys"]})}})}function UY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async i=>{if(!e||!t)throw new Error("Not connected");const a=new URLSearchParams;n&&a.set("instanceId",n);const l=await fetch(Ln(t.serverUrl,`/console/api-keys/${Sa(i)}/rotate/stage`,a),{method:"POST",headers:{Authorization:`Bearer ${t.token}`}});if(!l.ok)throw new Error("Failed to stage-rotate API key");return l.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","api-keys"]})}})}function $Y(e={}){const{config:t}=Dt();return Wn({queryKey:Jn.storage({prefix:e.prefix,cursor:e.cursor,limit:e.limit}),queryFn:async()=>{if(!t)throw new Error("Not connected");const n=new URLSearchParams;e.prefix&&n.set("prefix",e.prefix),e.cursor&&n.set("cursor",e.cursor),e.limit&&n.set("limit",String(e.limit));const s=await fetch(Ln(t.serverUrl,"/console/storage",n),{method:"GET",headers:{Authorization:`Bearer ${t.token}`}});if(!s.ok)throw new Error("Failed to list blobs");return s.json()},enabled:!!t,refetchInterval:_i(e.refetchIntervalMs,3e4)})}function BY(){const{config:e}=Dt(),t=_r();return is({mutationFn:async n=>{if(!e)throw new Error("Not connected");const s=encodeURIComponent(n),i=await fetch(Ln(e.serverUrl,`/console/storage/${s}`,new URLSearchParams),{method:"DELETE",headers:{Authorization:`Bearer ${e.token}`}});if(!i.ok)throw new Error("Failed to delete blob");return i.json()},onSuccess:()=>{t.invalidateQueries({queryKey:["console","storage"]})}})}function FY(){const{config:e}=Dt();return async t=>{if(!e)throw new Error("Not connected");const n=encodeURIComponent(t),s=await fetch(Ln(e.serverUrl,`/console/storage/${n}/download`,new URLSearchParams),{method:"GET",headers:{Authorization:`Bearer ${e.token}`}});if(!s.ok)throw new Error("Failed to download blob");const i=await s.blob(),a=URL.createObjectURL(i),l=document.createElement("a");l.href=a,l.download=t.split("/").pop()||t,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(a)}}const HY="console:partition-id";function sf(){const[e,t]=pi(HY,""),n=e.trim();return _.useMemo(()=>({partitionId:n.length>0?n:void 0,rawPartitionId:e,setPartitionId:t,clearPartitionId:()=>t("")}),[n,e,t])}const KC={refreshInterval:5,timeFormat:"relative",showSparklines:!0,pageSize:20};function of(){const[e,t]=pi("console:preferences",KC);return{preferences:e,setPreferences:t,updatePreference:(i,a)=>{t(l=>({...l,[i]:a}))},resetPreferences:()=>{t(KC)}}}const qY=[{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"}],VY=[{value:10,label:"10"},{value:20,label:"20"},{value:50,label:"50"},{value:100,label:"100"}],yx="syncular-console-root";function KY(e){e.classList.add(yx)}const GY=[{suffix:"",label:"Command"},{suffix:"/stream",label:"Stream"},{suffix:"/fleet",label:"Fleet"},{suffix:"/ops",label:"Ops"},{suffix:"/storage",label:"Storage"},{suffix:"/config",label:"Config"}];function ZY(e){const t=e?.trim()??"";return!t||t==="/"?"":(t.startsWith("/")?t:`/${t}`).replace(/\/+$/g,"")}function Uy(e,t){return e?t?`${e}${t}`:e:t||"/"}function YY({basePath:e,appHref:t,modeBadge:n}){const{connect:s,config:i,isConnected:a,isConnecting:l}=Dt(),{preferences:f}=of(),{instanceId:d,rawInstanceId:p,setInstanceId:g,clearInstanceId:y}=Lt(),{partitionId:b,rawPartitionId:x,setPartitionId:S,clearPartitionId:w}=sf(),T=vr({select:P=>P.location.pathname}),{data:C}=rf({refetchIntervalMs:f.refreshInterval*1e3,partitionId:b,instanceId:d}),O=ZY(e),N=_.useMemo(()=>GY.map(P=>({...P,id:Uy(O,P.suffix)})),[O]),R=Uy(O,""),M=Uy(O,"/config"),z=l?"connecting":a?"connected":i?"disconnected":"not-configured",j=N.find(P=>P.suffix===""?T===R||T===`${R}/`:T.startsWith(P.id))?.id??R,A=C?[{label:"HEAD",value:`#${C.maxCommitSeq}`},{label:"COMMITS",value:`${C.commitCount}`},{label:"CHANGES",value:`${C.changeCount}`},{label:"CLIENTS",value:`${C.activeClientCount}/${C.clientCount}`}]:[];return h.jsxs("div",{className:`${yx} h-screen bg-background text-foreground flex flex-col`,children:[h.jsx(MZ,{brand:h.jsx(bc,{to:R,children:h.jsx(OZ,{label:"console"})}),center:h.jsx(TZ,{items:N,activeId:j,renderItem:(P,{active:Q})=>h.jsx(bc,{to:P.id,children:h.jsx(ok,{active:Q,children:P.label})},P.id)}),right:h.jsxs("div",{className:"flex items-center gap-2",children:[n?h.jsx(mn,{variant:"flow",className:"hidden md:inline-flex px-2 py-1 text-[10px]",children:n}):null,h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("span",{className:"font-mono text-[9px] text-neutral-500 uppercase tracking-wide",children:"Instance"}),h.jsx(Gn,{variant:"mono",value:p,onChange:P=>g(P.target.value),onBlur:P=>g(P.target.value.trim()),placeholder:"all",className:"h-7 w-[110px] px-2 py-1"}),d?h.jsx(Me,{variant:"ghost",size:"sm",className:"h-7 px-2 text-[10px]",onClick:y,children:"All"}):null]}),h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("span",{className:"font-mono text-[9px] text-neutral-500 uppercase tracking-wide",children:"Partition"}),h.jsx(Gn,{variant:"mono",value:x,onChange:P=>S(P.target.value),onBlur:P=>S(P.target.value.trim()),placeholder:"all",className:"h-7 w-[110px] px-2 py-1"}),b?h.jsx(Me,{variant:"ghost",size:"sm",className:"h-7 px-2 text-[10px]",onClick:w,children:"All"}):null]}),h.jsx(N8,{state:z}),h.jsx(bc,{to:M,children:h.jsx(Me,{variant:T===M?"secondary":"ghost",size:"icon",children:h.jsx(V8,{className:"h-3 w-3"})})}),t?h.jsxs("a",{href:t,className:EZ,children:[h.jsx(H8,{className:"h-3 w-3"}),"Go to app"]}):null]})}),h.jsx("main",{className:"flex-1 overflow-auto pb-[32px]",children:h.jsx("div",{className:"min-h-full",children:a||T===M?h.jsx("div",{style:{animation:"pageIn 0.3s ease-out"},children:h.jsx(XN,{})},T):h.jsx(XY,{configPath:M,hasSavedConfig:!!i,isConnecting:l,onConnect:()=>{s()}})})}),a&&h.jsx(Bj,{isLive:a,metrics:A,uptime:"--"})]})}function XY({configPath:e,hasSavedConfig:t,isConnecting:n,onConnect:s}){return h.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[h.jsx("p",{className:"mb-4 text-foreground-muted",children:"Not connected to a @syncular server"}),h.jsxs("div",{className:"flex items-center gap-2",children:[t&&h.jsx(Me,{variant:"default",onClick:s,disabled:n,children:n?"Connecting...":"Connect"}),h.jsx(bc,{to:e,children:h.jsx(Me,{variant:"link",children:"Configure connection"})})]})]})}const uo=NH({component:YY});function QY(){return typeof window>"u"?!1:new URLSearchParams(window.location.search).get("swServer")==="1"}function WY(e={}){const{maxEvents:t=100,enabled:n=!0,staleAfterMs:s=65e3,replayLimit:i=100,partitionId:a,instanceId:l}=e,{config:f,isConnected:d}=Dt(),{instanceId:p}=Lt(),g=l??p,[y,b]=_.useState([]),[x,S]=_.useState(!1),[w,T]=_.useState("disconnected"),[C,O]=_.useState(null),N=_.useRef(null),R=_.useRef(null),M=_.useRef(null),z=_.useRef(0),j=_.useRef(0),A=_.useRef(null),P=_.useRef(null),Q=_.useCallback(()=>{b([]),A.current=null,P.current=null},[]);return _.useEffect(()=>{if(!n||!d||!f?.serverUrl||!f?.token)return;let B=!1;const U=Number.isFinite(i)?Math.max(1,Math.min(500,Math.floor(i))):100;if(QY()||typeof WebSocket>"u"){T("connecting"),S(!1);let V=null,L=!1;const I=async()=>{if(!(B||L)){L=!0;try{const H=new URL(f.serverUrl,window.location.origin),W=H.pathname.endsWith("/")?H.pathname.slice(0,-1):H.pathname;H.pathname=`${W}/console/events`,H.search="",H.searchParams.set("limit",String(U)),H.searchParams.set("offset","0"),a&&H.searchParams.set("partitionId",a);const Y=await fetch(H.toString(),{headers:{Authorization:`Bearer ${f.token}`}});if(!Y.ok)throw new Error(`Live event polling failed (${Y.status})`);const ae=await Y.json(),fe=(Array.isArray(ae.items)?ae.items:[]).filter(Oe=>g?Oe.instanceId===g:!0).sort((Oe,_e)=>Oe.eventId-_e.eventId),Se=P.current??-1,pe=fe.filter(Oe=>Oe.eventId>Se);if(pe.length>0){const Oe=pe.map(re=>({type:re.eventType,timestamp:re.createdAt,data:re})).reverse();b(re=>[...Oe,...re].slice(0,t));const _e=pe[pe.length-1];P.current=_e.eventId,A.current=_e.createdAt}else if(fe.length>0){const Oe=fe[fe.length-1];P.current=Math.max(P.current??-1,Oe.eventId),A.current=Oe.createdAt}O(null),S(!0),T("connected")}catch(H){B||(S(!1),T("disconnected"),O(H instanceof Error?H:new Error("Live event polling failed")))}finally{L=!1}}};return I(),V=setInterval(()=>{I()},2e3),()=>{B=!0,V&&clearInterval(V),S(!1),T("disconnected")}}const K=()=>{R.current&&(clearTimeout(R.current),R.current=null)},ee=()=>{M.current&&(clearInterval(M.current),M.current=null)},D=()=>{if(B||R.current)return;z.current+=1;const V=Math.min(3e4,1e3*2**Math.max(0,z.current-1)),L=Math.floor(V*.2*Math.random()),I=V+L;R.current=setTimeout(()=>{R.current=null,B||q()},I)},G=()=>{j.current=Date.now(),S(!0),T("connected")},q=()=>{if(B)return;T("connecting"),K();const V=(()=>{const I=new URL(f.serverUrl,window.location.origin);I.protocol=I.protocol==="https:"?"wss:":"ws:";const H=I.pathname.endsWith("/")?I.pathname.slice(0,-1):I.pathname;return I.pathname=`${H}/console/events/live`,I.search="",I.searchParams.set("token",f.token),A.current&&I.searchParams.set("since",A.current),I.searchParams.set("replayLimit",String(U)),a&&I.searchParams.set("partitionId",a),g&&I.searchParams.set("instanceId",g),I.toString()})(),L=new WebSocket(V);N.current=L,L.onopen=()=>{if(B){L.close();return}z.current=0,G(),O(null),ee(),M.current=setInterval(()=>{const I=N.current;if(!I||I.readyState!==WebSocket.OPEN)return;const H=j.current;!H||Date.now()-H<=s||(S(!1),T("stale"),I.close())},1e3)},L.onclose=()=>{B||(S(!1),T("disconnected"),ee(),D())},L.onerror=()=>{B||O(new Error("WebSocket connection failed"))},L.onmessage=I=>{try{const H=JSON.parse(I.data),W=H.type;if(G(),W==="connected"||W==="heartbeat")return;const Y={type:W,timestamp:H.timestamp||new Date().toISOString(),data:H};if(a&&Y.data.partitionId!==a||g&&Y.data.instanceId!==g)return;const ae=Date.parse(A.current??""),se=Date.parse(Y.timestamp);Number.isFinite(se)&&(!Number.isFinite(ae)||se>ae)&&(A.current=Y.timestamp),b(fe=>[Y,...fe].slice(0,t))}catch{}}};return q(),()=>{B=!0,K(),ee(),N.current&&(N.current.close(),N.current=null),S(!1),T("disconnected")}},[n,d,f?.serverUrl,f?.token,t,a,g,i,s]),{events:y,isConnected:x,connectionState:w,error:C,clearEvents:Q}}function JY(){const e=Vt(),{config:t}=Dt(),{instanceId:n}=Lt(),s=_r();return is({mutationFn:async()=>{if(!e||!t)throw new Error("Not connected");const i=new URLSearchParams;n&&i.set("instanceId",n);const a=i.toString(),l=await fetch(`${t.serverUrl}/console/events${a?`?${a}`:""}`,{method:"DELETE",headers:{Authorization:`Bearer ${t.token}`}});if(!l.ok)throw new Error("Failed to clear events");return l.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["console","events"]})}})}const eX=_.createContext(null);function mk(){const[e,t]=pi("console:time-range","24h");return{range:e,setRange:t}}const tX=[{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 nX(e){const t=e.toLowerCase();for(const n of tX)if(t.includes(n.hint))return n.type;return"client"}function rX(e){const t=e.toLowerCase();return t.includes("pglite")?"PGlite":t.includes("sqlite")||t.includes("wa-sqlite")?"SQLite":t.includes("postgres")||t.includes("pg")?"PostgreSQL":"unknown"}function sX(e,t){return typeof e.lagCommitCount=="number"?Math.max(0,e.lagCommitCount):t?Math.max(0,t.maxCommitSeq-e.cursor):0}function oX(e,t){return e.activityState==="stale"?"offline":t>0?"syncing":"online"}function iX(e,t){return e.length<=16?e:`${e.slice(0,12)}-${t+1}`}function aX(e,t,n={}){const s=n.maxNodes??10;return e.slice(0,s).map((i,a)=>{const l=sX(i,t),f=oX(i,l);return{id:iX(i.clientId,a),type:nX(i.clientId),status:f,cursor:Math.max(0,i.cursor),actor:i.actorId,mode:i.connectionMode,dialect:rX(i.clientId),scopes:Object.keys(i.effectiveScopes||{}),lastSeen:i.updatedAt}})}const cX={enabled:!1,thresholds:{p90Latency:500,errorRate:5,clientLag:100}};function GC(e,t="relative"){if(t==="absolute")return new Date(e).toLocaleString();const n=new Date(e),i=new Date().getTime()-n.getTime(),a=Math.floor(i/1e3);return a<60?`${a}s ago`:a<3600?`${Math.floor(a/60)}m ago`:a<86400?`${Math.floor(a/3600)}h ago`:`${Math.floor(a/86400)}d ago`}function lX(e){const t=e.length>1&&e.endsWith("/")?e.slice(0,-1):e;return t==="/console"||t.startsWith("/console/")?"/console/stream":"/stream"}function uX(){const e=dp(),t=_.useMemo(()=>typeof window>"u"?"/stream":lX(window.location.pathname),[]),n=mk(),{range:s}=n,{preferences:i}=of(),{partitionId:a}=sf(),l=i.refreshInterval*1e3,[f]=pi("console:alert-config",cX),[d,p]=_.useState("1h"),{data:g}=rf({refetchIntervalMs:l,partitionId:a}),{data:y}=xY({range:s,partitionId:a},{refetchIntervalMs:l}),{data:b}=SY({range:s,partitionId:a},{refetchIntervalMs:l}),{data:x}=_Y({limit:5,partitionId:a},{refetchIntervalMs:l}),{data:S}=pk({limit:12,offset:0,partitionId:a},{refetchIntervalMs:l}),{events:w,isConnected:T}=WY({maxEvents:8,partitionId:a}),C=_.useMemo(()=>{const U=y?.buckets??[];let Z=0,K=0;for(const D of U)Z+=D.pushCount+D.pullCount,K+=D.errorCount;const ee=Z>0?K/Z*100:0;return{totalEvents:Z,errorRate:ee}},[y?.buckets]),O=_.useMemo(()=>S?.items?aX(S.items,g,{maxNodes:12}):[],[S?.items,g]),N=O.filter(U=>U.status!=="offline").length,R=O.filter(U=>U.status==="offline").length,M=_.useMemo(()=>g?[{label:"Ops (Range)",value:C.totalEvents,color:"flow"},{label:"P50 Latency",value:b?.push?.p50??0,unit:"ms",color:"healthy"},{label:"Error Rate",value:`${C.errorRate.toFixed(1)}%`,color:C.errorRate>0?"offline":"muted"},{label:"Active Clients",value:g.activeClientCount,color:"syncing"},{label:"Pending",value:g.maxActiveClientCursor!==null&&g.maxCommitSeq>0?g.maxCommitSeq-(g.minActiveClientCursor??0):0,color:"relay"}]:[],[g,b,C.errorRate,C.totalEvents]),z=_.useMemo(()=>w.map(U=>({type:U.type.toUpperCase(),actor:U.data?.actorId??"",table:(U.data?.tables??[])[0]??"",time:GC(U.timestamp,i.timeFormat)})),[w,i.timeFormat]),j=_.useMemo(()=>{const U=y?.buckets;if(!U?.length)return[];const Z=Math.max(...U.map(K=>Math.max(K.pushCount,K.pullCount)),1);return U.map(K=>({pushPercent:Z>0?K.pushCount/Z*100:0,pullPercent:Z>0?K.pullCount/Z*100:0}))},[y?.buckets]),A=_.useMemo(()=>{if(!b)return[];const U=Math.max(b.push.p50,b.push.p90,b.push.p99,b.pull.p50,b.pull.p90,b.pull.p99,1);return[{label:"P50",pushMs:b.push.p50,pullMs:b.pull.p50,pushBarPercent:b.push.p50/U*100,pullBarPercent:b.pull.p50/U*100},{label:"P90",pushMs:b.push.p90,pullMs:b.pull.p90,pushBarPercent:b.push.p90/U*100,pullBarPercent:b.pull.p90/U*100},{label:"P99",pushMs:b.push.p99,pullMs:b.pull.p99,pushBarPercent:b.push.p99/U*100,pullBarPercent:b.pull.p99/U*100}]},[b]),P=_.useMemo(()=>x?.items?x.items.map(U=>({seq:U.commitSeq,actor:U.actorId,changes:U.changeCount,tables:(U.affectedTables??[]).join(", "),time:GC(U.createdAt,i.timeFormat)})):[],[x?.items,i.timeFormat]),Q=_.useMemo(()=>Math.max(0,100-C.errorRate),[C.errorRate]),B=_.useMemo(()=>{if(!f.enabled||!g)return[];const U=[];return b?.push?.p90&&b.push.p90>f.thresholds.p90Latency&&U.push(`P90 push latency (${b.push.p90}ms) exceeds threshold (${f.thresholds.p90Latency}ms)`),g.minActiveClientCursor!==null&&g.maxCommitSeq-g.minActiveClientCursor>f.thresholds.clientLag&&U.push(`Client lag (${g.maxCommitSeq-g.minActiveClientCursor}) exceeds threshold (${f.thresholds.clientLag})`),C.errorRate>f.thresholds.errorRate&&U.push(`Error rate (${C.errorRate.toFixed(1)}%) exceeds threshold (${f.thresholds.errorRate}%)`),U},[f,g,b,C.errorRate]);return g?h.jsx(eX.Provider,{value:n,children:h.jsxs("div",{className:"flex flex-col",children:[B.length>0&&h.jsx("div",{className:"px-6 pb-4",children:h.jsxs(In,{variant:"destructive",children:[h.jsx(tf,{children:"Threshold Exceeded"}),h.jsx(Pn,{children:B.map((U,Z)=>h.jsx("span",{className:"block",children:U},Z))})]})}),h.jsx(UA,{clients:O,totalNodes:O.length+2,onlineCount:N,offlineCount:R,relayClientIds:[]}),h.jsx(Yj,{items:M}),h.jsxs("div",{className:"flex",children:[h.jsxs("div",{className:"flex-1 min-w-0 flex flex-col",children:[h.jsx("div",{className:"border-b border-border border-r border-border",children:h.jsx(Sj,{bars:j,activeRange:d,onRangeChange:p})}),h.jsx("div",{className:"border-b border-border border-r border-border",children:h.jsx(Xj,{buckets:A,successRate:Q})}),h.jsx("div",{className:"border-r border-border",children:h.jsx(Fj,{commits:P,onViewAll:()=>e({href:t})})})]}),h.jsx(Qj,{entries:z,isConnected:T,maxVisible:20,maxHeight:"calc(100vh - 200px)"})]})]})}):h.jsx("div",{className:"flex items-center justify-center py-24",children:h.jsx(Pt,{size:"lg"})})}function fX(){return h.jsx(uX,{})}function dX({children:e}){return h.jsxs("div",{className:"space-y-4 px-5 py-5",children:[h.jsx(hX,{}),h.jsx(vX,{}),h.jsx(bX,{}),e]})}function hX(){const{clearError:e,config:t,connect:n,disconnect:s,error:i,isConnected:a,isConnecting:l}=Dt(),[f,d]=_.useState(t?.serverUrl??"/api"),[p,g]=_.useState(t?.token??""),[y,b]=_.useState(null),[x,S]=_.useState(!1),[w,T]=_.useState(null),[C,O]=pi("console:disconnect-clear-saved-config",!1);_.useEffect(()=>{const j=new URLSearchParams(window.location.search),A=j.get("token"),P=j.get("server");A&&(g(A),window.history.replaceState({},"",window.location.pathname)),P&&d(P)},[]),_.useEffect(()=>{t?.serverUrl&&d(t.serverUrl),t?.token&&g(t.token)},[t?.serverUrl,t?.token]),_.useEffect(()=>{T(null)},[]);const N=async()=>{e(),b(null);const j=await n({serverUrl:f.trim(),token:p.trim()},{persistOverride:!0});T(j?"Connected successfully and configuration saved.":"Failed to connect with the provided settings.")},R=()=>{s({clearSavedConfig:C}),C&&(d("/api"),g("")),T(C?"Disconnected and saved credentials cleared.":"Disconnected."),b(null)},M=async()=>{S(!0),b(null),T(null);const j=performance.now();try{const A=f.trim(),P=p.trim();if(!A||!P)throw new Error("Missing server URL or token");if(!(await fetch(`${A}/console/stats`,{headers:{Authorization:`Bearer ${P}`}})).ok)throw new Error("Failed to connect");b(Math.round(performance.now()-j))}catch{b(-1)}finally{S(!1)}},z=i??w??(y!==null?y<0?"Connection failed":`Connection successful (${y}ms latency)`:void 0);return h.jsx(qj,{isConnected:a,isConnecting:l,isTestingConnection:x,serverUrl:f,onServerUrlChange:d,consoleToken:p,onConsoleTokenChange:g,onSaveAndConnect:N,onDisconnect:R,onTestConnection:M,statusMessage:z,children:h.jsx("div",{className:"px-5 pb-5 -mt-2",children:h.jsxs("div",{className:"flex items-center justify-between rounded-md border border-border px-3 py-2",children:[h.jsxs("div",{children:[h.jsx("p",{className:"font-mono text-[10px] text-neutral-400",children:"Clear saved credentials on disconnect"}),h.jsx("p",{className:"font-mono text-[9px] text-neutral-500",children:"Removes stored server URL and token from this browser."})]}),h.jsx(Sp,{checked:C,onCheckedChange:O})]})})})}const pX=1440*60*1e3;function ZC(e){const t=e.trim();if(!t)return null;const n=Number.parseInt(t,10);return!Number.isInteger(n)||n<=0?null:n}function $y(e){if(!e)return"Never";const t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():"Invalid date"}function mX(e){return e.length===0?"all scopes":e.length<=2?e.join(", "):`${e.slice(0,2).join(", ")} +${e.length-2}`}function gX(e,t){if(e.revokedAt)return"revoked";if(!e.expiresAt)return"active";const n=Date.parse(e.expiresAt);if(!Number.isFinite(n))return"active";const s=Date.now();return n<=s?"expired":n<=s+t*pX?"expiring":"active"}function yX(e){return e==="revoked"?"destructive":e==="expired"?"offline":e==="expiring"?"syncing":"healthy"}function vX(){const[e,t]=_.useState("all"),[n,s]=_.useState("all"),[i,a]=_.useState("14"),[l,f]=_.useState(!1),[d,p]=_.useState(!1),[g,y]=_.useState(""),[b,x]=_.useState("relay"),[S,w]=_.useState(""),[T,C]=_.useState(""),[O,N]=_.useState(""),[R,M]=_.useState(null),[z,j]=_.useState([]),[A,P]=_.useState(null),[Q,B]=_.useState(null),[U,Z]=_.useState(null),[K,ee]=_.useState(null),[D,G]=_.useState(null),[q,V]=_.useState(null),[L,I]=_.useState(null),H=_.useMemo(()=>ZC(i),[i]),W=H??14,Y=_.useMemo(()=>ZC(O),[O]),ae=O.trim().length>0,se=!ae||Y!==null,fe=_.useMemo(()=>({type:e==="all"?void 0:e,status:n==="all"?void 0:n,expiresWithinDays:n==="expiring"?W:void 0}),[e,n,W]),{data:Se,isLoading:pe,error:Oe}=IY(fe),_e=PY(),re=zY(),he=DY(),ie=LY(),we=UY();_.useEffect(()=>{const me=new Set((Se?.items??[]).map(Te=>Te.keyId));j(Te=>Te.filter(qe=>me.has(qe)))},[Se?.items]);const ye=async()=>{try{const me=T.split(",").map(qe=>qe.trim()).filter(qe=>qe.length>0),Te=await _e.mutateAsync({name:g,keyType:b,actorId:S||void 0,scopeKeys:me.length>0?me:void 0,expiresInDays:ae?Y??void 0:void 0});M(Te.secretKey),y(""),w(""),C(""),N("")}catch{}},xe=me=>{navigator.clipboard.writeText(me),B(me),setTimeout(()=>B(null),2e3)},ve=async()=>{if(U)try{await he.mutateAsync(U)}finally{Z(null)}},Ie=async()=>{if(z.length!==0)try{const me=await re.mutateAsync({keyIds:z});P(me),j([])}catch{}},Ue=async()=>{if(K)try{const me=await we.mutateAsync(K.keyId);G({oldKeyId:K.keyId,oldKeyName:K.name,secretKey:me.secretKey})}catch{}},Ee=async()=>{if(D)try{await he.mutateAsync(D.oldKeyId)}finally{G(null),ee(null)}},Ve=async()=>{if(q)try{const me=await ie.mutateAsync(q);I(me.secretKey)}finally{V(null)}};if(pe)return h.jsx("div",{className:"flex h-[200px] items-center justify-center",children:h.jsx(Pt,{size:"lg"})});if(Oe)return h.jsx("div",{className:"flex h-[200px] items-center justify-center",children:h.jsxs("p",{className:"text-danger",children:["Failed to load API keys: ",Oe.message]})});const Qe=(Se?.items??[]).filter(me=>me.revokedAt===null).map(me=>me.keyId),Be=Qe.length>0&&Qe.every(me=>z.includes(me)),We=z.length>0,He=(Se?.items??[]).filter(me=>z.includes(me.keyId)).map(me=>me.name);return h.jsxs(h.Fragment,{children:[h.jsxs(Jb,{title:"API Keys",description:"Issue, rotate, revoke, and audit key lifecycle state.",actions:h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs(Me,{size:"sm",variant:"destructive",onClick:()=>p(!0),disabled:z.length===0,children:["Revoke Selected (",z.length,")"]}),h.jsx(Me,{size:"sm",onClick:()=>f(!0),children:"Create Key"})]}),children:[h.jsxs("div",{className:"mb-4 grid gap-3 lg:grid-cols-3",children:[h.jsxs(ms,{children:[h.jsx(es,{children:"Type filter"}),h.jsxs(dh,{value:[e],multiple:!1,onValueChange:me=>{const Te=me.find(qe=>typeof qe=="string");(Te==="all"||Te==="relay"||Te==="proxy"||Te==="admin")&&t(Te)},children:[h.jsx(Dr,{value:"all",children:"all"}),h.jsx(Dr,{value:"relay",children:"relay"}),h.jsx(Dr,{value:"proxy",children:"proxy"}),h.jsx(Dr,{value:"admin",children:"admin"})]})]}),h.jsxs(ms,{children:[h.jsx(es,{children:"Status filter"}),h.jsxs(dh,{value:[n],multiple:!1,onValueChange:me=>{const Te=me.find(qe=>typeof qe=="string");(Te==="all"||Te==="active"||Te==="revoked"||Te==="expiring")&&s(Te)},children:[h.jsx(Dr,{value:"all",children:"all"}),h.jsx(Dr,{value:"active",children:"active"}),h.jsx(Dr,{value:"revoked",children:"revoked"}),h.jsx(Dr,{value:"expiring",children:"expiring"})]})]}),h.jsxs(ms,{children:[h.jsx(es,{htmlFor:"api-key-expiring-window",children:"Expiring window (days)"}),h.jsx(pc,{children:"Used when status filter is set to expiring."}),h.jsx(Gn,{id:"api-key-expiring-window",placeholder:"14",value:i,inputMode:"numeric",onChange:me=>a(me.target.value)}),H===null&&i.trim().length>0?h.jsx("p",{className:"font-mono text-[10px] text-offline",children:"Enter a positive whole number."}):null]})]}),Se?.items.length===0?h.jsx(Qb,{message:"No API keys match the current filters."}):h.jsxs(tl,{children:[h.jsx(nl,{children:h.jsxs(ss,{children:[h.jsx(ht,{className:"w-[28px]",children:h.jsx(Uv,{checked:Be,indeterminate:!Be&&We&&Qe.length>0,onCheckedChange:me=>{j(me?Qe:[])},"aria-label":"Select all active keys"})}),h.jsx(ht,{className:"w-[100px]",children:"NAME"}),h.jsx(ht,{className:"w-[55px]",children:"TYPE"}),h.jsx(ht,{className:"w-[90px]",children:"KEY PREFIX"}),h.jsx(ht,{className:"w-[80px]",children:"ACTOR"}),h.jsx(ht,{className:"w-[100px]",children:"SCOPES"}),h.jsx(ht,{className:"w-[120px]",children:"CREATED"}),h.jsx(ht,{className:"w-[120px]",children:"LAST USED"}),h.jsx(ht,{className:"w-[120px]",children:"EXPIRES"}),h.jsx(ht,{className:"flex-1",children:"STATUS"})]})}),h.jsx(rl,{children:(Se?.items??[]).map(me=>{const Te=gX(me,W);return h.jsxs(ss,{className:"group relative",children:[h.jsx(pt,{className:"w-[28px]",children:h.jsx(Uv,{checked:z.includes(me.keyId),onCheckedChange:qe=>{j(mt=>qe?[...new Set([...mt,me.keyId])]:mt.filter(lt=>lt!==me.keyId))},"aria-label":`Select ${me.name}`,disabled:me.revokedAt!==null})}),h.jsx(pt,{className:"w-[100px] font-medium",children:me.name}),h.jsx(pt,{className:"w-[55px]",children:h.jsx(mn,{variant:me.keyType==="admin"?"flow":me.keyType==="proxy"?"ghost":"relay",children:me.keyType})}),h.jsx(pt,{className:"w-[90px]",children:h.jsxs("code",{className:"font-mono text-[11px]",children:[me.keyPrefix,"..."]})}),h.jsx(pt,{className:"w-[80px] text-neutral-500",children:me.actorId??"-"}),h.jsx(pt,{className:"w-[100px] text-neutral-500",children:h.jsx("code",{className:"font-mono text-[10px]",children:mX(me.scopeKeys)})}),h.jsx(pt,{className:"w-[120px] text-neutral-500",children:$y(me.createdAt)}),h.jsx(pt,{className:"w-[120px] text-neutral-500",children:$y(me.lastUsedAt)}),h.jsx(pt,{className:"w-[120px] text-neutral-500",children:$y(me.expiresAt)}),h.jsx(pt,{className:"flex-1",children:h.jsx(mn,{variant:yX(Te),children:Te})}),me.revokedAt===null&&h.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[h.jsx("button",{type:"button",onClick:()=>ee(me),className:"px-1.5 py-0.5 rounded text-[9px] font-mono text-neutral-600 hover:text-white hover:bg-white/[0.05] cursor-pointer transition-colors",children:"stage"}),h.jsx("button",{type:"button",onClick:()=>V(me.keyId),className:"px-1.5 py-0.5 rounded text-[9px] font-mono text-neutral-600 hover:text-white hover:bg-white/[0.05] cursor-pointer transition-colors",children:"rotate"}),h.jsx("button",{type:"button",onClick:()=>Z(me.keyId),className:"px-1.5 py-0.5 rounded text-[9px] font-mono text-neutral-600 hover:text-offline hover:bg-offline/10 cursor-pointer transition-colors",children:"revoke"})]})]},me.keyId)})})]})]}),h.jsx($r,{open:l,onOpenChange:f,children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Create API Key"})}),R?h.jsx(YC,{copiedKeyId:Q,onClose:()=>{M(null),f(!1)},onCopy:xe,secretKey:R,warning:"Copy this key now. You will not be able to view it again."}):h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[h.jsxs(ms,{children:[h.jsx(es,{htmlFor:"api-key-name",children:"Name"}),h.jsx(Gn,{id:"api-key-name",placeholder:"Backend Relay Key",value:g,onChange:me=>y(me.target.value)})]}),h.jsxs(ms,{children:[h.jsx(es,{children:"Key type"}),h.jsxs(dh,{value:[b],multiple:!1,onValueChange:me=>{const Te=me.find(qe=>typeof qe=="string");(Te==="relay"||Te==="proxy"||Te==="admin")&&x(Te)},children:[h.jsx(Dr,{value:"relay",children:"relay"}),h.jsx(Dr,{value:"proxy",children:"proxy"}),h.jsx(Dr,{value:"admin",children:"admin"})]})]}),h.jsxs(ms,{children:[h.jsx(es,{htmlFor:"api-key-actor-id",children:"Actor ID (optional)"}),h.jsx(pc,{children:"Pin this key to a fixed actor ID"}),h.jsx(Gn,{id:"api-key-actor-id",placeholder:"actor-123",value:S,onChange:me=>w(me.target.value)})]}),h.jsxs(ms,{children:[h.jsx(es,{htmlFor:"api-key-scope-keys",children:"Scope keys (optional)"}),h.jsx(pc,{children:"Comma-separated list of allowed scope keys"}),h.jsx(Gn,{id:"api-key-scope-keys",placeholder:"scope-a, scope-b",value:T,onChange:me=>C(me.target.value)})]}),h.jsxs(ms,{children:[h.jsx(es,{htmlFor:"api-key-expires-days",children:"Expires in days (optional)"}),h.jsx(pc,{children:"Leave empty to keep the key non-expiring."}),h.jsx(Gn,{id:"api-key-expires-days",placeholder:"30",value:O,inputMode:"numeric",onChange:me=>N(me.target.value)}),se?null:h.jsx("p",{className:"font-mono text-[10px] text-offline",children:"Enter a positive whole number."})]}),h.jsxs(Nn,{children:[h.jsx(Me,{variant:"default",onClick:()=>f(!1),children:"Cancel"}),h.jsx(Me,{variant:"primary",onClick:ye,disabled:_e.isPending||!g||!se,children:_e.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Creating..."]}):"Create"})]})]})]})}),h.jsx($r,{open:d,onOpenChange:me=>{p(me),me||P(null)},children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Bulk Revoke API Keys"})}),A?h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-3",children:[h.jsx(In,{variant:"destructive",children:h.jsxs(Pn,{children:["Requested ",A.requestedCount," keys. Revoked"," ",A.revokedCount,", already revoked"," ",A.alreadyRevokedCount,", not found"," ",A.notFoundCount,"."]})}),h.jsx(Nn,{children:h.jsx(Me,{variant:"primary",onClick:()=>{p(!1),P(null)},children:"Done"})})]}):h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-3",children:[h.jsx(In,{variant:"destructive",children:h.jsx(Pn,{children:"This revokes selected keys immediately and cannot be undone."})}),h.jsxs("p",{className:"font-mono text-[10px] text-neutral-500",children:["Selected keys: ",He.slice(0,5).join(", "),He.length>5?` +${He.length-5} more`:""]})]}),h.jsxs(Nn,{children:[h.jsx(Me,{variant:"default",onClick:()=>p(!1),children:"Cancel"}),h.jsx(Me,{variant:"destructive",onClick:Ie,disabled:re.isPending||z.length===0,children:re.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Revoking..."]}):"Revoke Selected"})]})]})]})}),h.jsx($r,{open:K!==null||D!==null,onOpenChange:()=>{ee(null),G(null)},children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Stage Rotate API Key"})}),D?h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[h.jsx(In,{variant:"default",children:h.jsxs(Pn,{children:["Replacement key created for ",D.oldKeyName,". The old key is still active until you revoke it."]})}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("code",{className:"flex-1 rounded-md border border-border bg-surface p-3 font-mono text-[11px] text-white break-all",children:D.secretKey}),h.jsx(Me,{variant:"default",size:"sm",onClick:()=>xe(D.secretKey),children:Q===D.secretKey?"Copied":"Copy"})]}),h.jsxs(Nn,{children:[h.jsx(Me,{variant:"default",onClick:()=>{G(null),ee(null)},children:"Keep Old Key Active"}),h.jsx(Me,{variant:"destructive",onClick:Ee,disabled:he.isPending,children:he.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Revoking Old Key..."]}):"Finalize and Revoke Old Key"})]})]}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"px-5 py-4",children:h.jsx("p",{className:"font-mono text-[10px] text-neutral-500",children:"Staged rotation creates a replacement key now and keeps the current key active until you explicitly revoke it."})}),h.jsxs(Nn,{children:[h.jsx(Me,{variant:"default",onClick:()=>ee(null),children:"Cancel"}),h.jsx(Me,{variant:"primary",onClick:Ue,disabled:we.isPending||!K,children:we.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Staging..."]}):"Create Replacement Key"})]})]})]})}),h.jsx($r,{open:U!==null,onOpenChange:()=>Z(null),children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Revoke API Key"})}),h.jsx("div",{className:"px-5 py-4",children:h.jsx(In,{variant:"destructive",children:h.jsx(Pn,{children:"Revoking a key immediately invalidates it for all requests."})})}),h.jsxs(Nn,{children:[h.jsx(Me,{variant:"default",onClick:()=>Z(null),children:"Cancel"}),h.jsx(Me,{variant:"destructive",onClick:ve,disabled:he.isPending,children:he.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Revoking..."]}):"Revoke"})]})]})}),h.jsx($r,{open:q!==null||L!==null,onOpenChange:()=>{V(null),I(null)},children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Rotate API Key"})}),L?h.jsx(YC,{copiedKeyId:Q,onClose:()=>I(null),onCopy:xe,secretKey:L,warning:"The previous key has been invalidated. Store this replacement securely."}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"px-5 py-4",children:h.jsx("p",{className:"font-mono text-[10px] text-neutral-500",children:"Rotating a key invalidates the previous secret immediately."})}),h.jsxs(Nn,{children:[h.jsx(Me,{variant:"default",onClick:()=>V(null),children:"Cancel"}),h.jsx(Me,{variant:"primary",onClick:Ve,disabled:ie.isPending,children:ie.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Rotating..."]}):"Rotate"})]})]})]})})]})}function bX(){const{preferences:e,updatePreference:t,resetPreferences:n}=of(),s=[{type:"filter",label:"Auto-refresh interval",options:qY.map(i=>({id:`${i.value}`,label:i.label})),activeId:`${e.refreshInterval}`,onActiveChange:i=>t("refreshInterval",Number.parseInt(i,10))},{type:"filter",label:"Items per page",options:VY.map(i=>({id:`${i.value}`,label:i.label})),activeId:`${e.pageSize}`,onActiveChange:i=>t("pageSize",Number.parseInt(i,10))},{type:"filter",label:"Time format",options:[{id:"relative",label:"Relative"},{id:"absolute",label:"Absolute"}],activeId:e.timeFormat,onActiveChange:i=>t("timeFormat",i)},{type:"toggle",label:"Show sparklines",description:"Display mini trend charts in dashboard metric cards",checked:e.showSparklines,onCheckedChange:i=>t("showSparklines",i)}];return h.jsx(Wj,{rows:s,onResetDefaults:n})}function YC({copiedKeyId:e,onClose:t,onCopy:n,secretKey:s,warning:i}){return h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[h.jsx(In,{variant:"destructive",children:h.jsx(Pn,{children:i})}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("code",{className:"flex-1 rounded-md border border-border bg-surface p-3 font-mono text-[11px] text-white break-all",children:s}),h.jsx(Me,{variant:"default",size:"sm",onClick:()=>n(s),children:e===s?"Copied":"Copy"})]}),h.jsx(Nn,{children:h.jsx(Me,{variant:"primary",onClick:t,children:"Done"})})]})}function xX(e){const t=e.toLowerCase();return t.includes("mobile")||t.includes("ios")||t.includes("android")?"mobile":t.includes("tablet")?"tablet":t.includes("desktop")||t.includes("laptop")?"desktop":t.includes("edge")?"edge":t.includes("iot")?"iot":"desktop"}function SX(e){const t=e.toLowerCase();return t.includes("pglite")?"PGlite":t.includes("wa-sqlite")||t.includes("sqlite")?"SQLite":t.includes("postgres")||t.includes("pg")?"PostgreSQL":"unknown"}function _X(e,t){if(t==="absolute")return new Date(e).toLocaleString();try{const n=new Date(e),i=new Date().getTime()-n.getTime(),a=Math.floor(i/1e3),l=Math.floor(a/60),f=Math.floor(l/60),d=Math.floor(f/24);return a<60?"just now":l<60?`${l}m ago`:f<24?`${f}h ago`:`${d}d ago`}catch{return e}}function wX(e,t,n){return{id:e.clientId,type:xX(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:SX(e.clientId),scopes:Object.keys(e.effectiveScopes??{}),lastSeen:_X(e.updatedAt,n)}}function EX({emptyState:e}={}){const[t,n]=_.useState(1),[s,i]=_.useState(null),{preferences:a}=of(),{partitionId:l}=sf(),f=a.pageSize,d=a.refreshInterval*1e3,{data:p,isLoading:g}=rf({refetchIntervalMs:d,partitionId:l}),{data:y,isLoading:b,error:x}=pk({limit:f,offset:(t-1)*f,partitionId:l},{refetchIntervalMs:d}),S=AY(),w=Math.ceil((y?.total??0)/f),T=p?.maxCommitSeq??0;_.useEffect(()=>{n(1)},[]);const C=async()=>{if(s)try{await S.mutateAsync({clientId:s,partitionId:l})}finally{i(null)}};if(b||g)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsx(Pt,{size:"lg"})});if(x)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsxs("p",{className:"text-danger",children:["Failed to load clients: ",x.message]})});const O=(y?.items??[]).map(N=>wX(N,T,a.timeFormat));return h.jsxs("div",{className:"flex flex-col gap-5 px-5 py-5",children:[O.length>0&&h.jsx(eA,{clients:O,headSeq:T}),O.length===0?e??h.jsx(eV,{children:h.jsx(Qb,{message:"No clients yet"})}):h.jsx(Gj,{clients:O,headSeq:T,onEvict:N=>{const R=y?.items.find(M=>M.clientId===N);i(R?.clientId??N)}}),w>1&&h.jsx(mx,{page:t,totalPages:w,totalItems:y?.total??0,onPageChange:n}),h.jsx($r,{open:s!==null,onOpenChange:()=>i(null),children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Evict Client"})}),h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[h.jsxs("p",{className:"font-mono text-[11px] text-neutral-300",children:["Are you sure you want to evict client"," ",h.jsxs("span",{className:"font-mono text-white",children:[s?.slice(0,12),"..."]}),"?"]}),h.jsx("p",{className:"font-mono text-[10px] text-neutral-500",children:"This will force the client to re-bootstrap on their next sync."})]}),h.jsxs(Nn,{children:[h.jsx(Me,{variant:"default",onClick:()=>i(null),children:"Cancel"}),h.jsx(Me,{variant:"destructive",onClick:C,disabled:S.isPending,children:S.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Evicting..."]}):"Evict"})]})]})})]})}const TX={latencyThresholdMs:1e3,errorRateThreshold:5,clientLagThreshold:50,enabled:!1};function CX(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 RX(e){const t=e.split(",").map(n=>n.trim()).filter(n=>n.length>0);return Array.from(new Set(t))}function NX(e){switch(e){case"notify_data_change":return"Notify";case"evict_client":return"Evict";case"compact":return"Compact";default:return"Prune"}}function XC(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function jX(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function AX(e){const t=XC(e.requestPayload),n=XC(e.resultPayload);if(e.operationType==="notify_data_change"){const a=jX(t?.tables),l=n?.commitSeq;return`${a.length} table${a.length===1?"":"s"} -> commit #${typeof l=="number"?l:"?"}`}if(e.operationType==="evict_client"){const a=n?.evicted===!0?"evicted":"not found";return`client ${e.targetClientId??"?"} ${a}`}if(e.operationType==="compact")return`${typeof n?.deletedChanges=="number"?n.deletedChanges:0} changes removed`;const s=typeof n?.deletedCommits=="number"?n.deletedCommits:0,i=typeof t?.watermarkCommitSeq=="number"?` at #${t.watermarkCommitSeq}`:"";return`${s} commits removed${i}`}function kX(e){const t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function OX(){const{partitionId:e}=sf();return h.jsxs("div",{className:"flex flex-col gap-4 px-5 py-5",children:[h.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[h.jsx(MX,{}),h.jsx(LX,{})]}),h.jsxs("div",{className:"grid gap-4 xl:grid-cols-3",children:[h.jsx(IX,{partitionId:e}),h.jsx(PX,{partitionId:e}),h.jsx(DX,{partitionId:e})]}),h.jsx(zX,{partitionId:e})]})}function MX(){const{data:e,isLoading:t,error:n}=RY();if(t)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsx(Pt,{size:"lg"})});if(n)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsxs("p",{className:"text-danger",children:["Failed to load handlers: ",n.message]})});const s=(e?.items??[]).map(i=>({table:i.table,dependsOn:i.dependsOn?.join(", ")??null,chunkTtl:i.snapshotChunkTtlMs?CX(i.snapshotChunkTtlMs):"default"}));return h.jsx(Zj,{handlers:s,tableCount:e?.items.length??0})}function IX({partitionId:e}){const[t,n]=_.useState(!1),[s,i]=_.useState(null),{data:a,isLoading:l}=rf({partitionId:e}),{data:f,isLoading:d,refetch:p}=NY({enabled:!1}),g=kY(),y=async()=>{n(!0),i(null),await p()},b=async()=>{const S=await g.mutateAsync();i(S.deletedCommits)};if(l)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsx(Pt,{size:"lg"})});const x=[{label:"Total commits",value:a?.commitCount??0},{label:"Commit range",value:`${a?.minCommitSeq??0} - ${a?.maxCommitSeq??0}`},{label:"Min active cursor",value:a?.minActiveClientCursor??"N/A",tone:"syncing"}];return h.jsxs(h.Fragment,{children:[h.jsx(_p,{title:"Prune",description:"Delete commits that all clients have already synced. Pruning removes commits older than the oldest active client cursor.",dotColor:"syncing",stats:x,actionLabel:"Preview Prune",actionVariant:"destructive",onAction:y}),h.jsx($r,{open:t,onOpenChange:n,children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Prune Old Commits"})}),h.jsx("div",{className:"px-5 py-4 flex flex-col gap-4",children:s!==null?h.jsxs(In,{variant:"default",children:[h.jsx(tf,{children:"Pruning Complete"}),h.jsxs(Pn,{children:["Successfully deleted ",h.jsx("strong",{children:s})," commits."]})]}):d?h.jsx("div",{className:"flex items-center justify-center py-8",children:h.jsx(Pt,{size:"sm"})}):f?h.jsxs(h.Fragment,{children:[h.jsx(In,{variant:f.commitsToDelete>0?"destructive":"default",children:h.jsx(Pn,{children:f.commitsToDelete>0?h.jsxs(h.Fragment,{children:["This will delete"," ",h.jsx("strong",{children:f.commitsToDelete})," commits up to sequence"," ",h.jsxs("code",{className:"font-mono",children:["#",f.watermarkCommitSeq]}),"."]}):"No commits are eligible for pruning."})}),h.jsxs("div",{className:"flex flex-col gap-2",children:[h.jsxs("div",{className:"flex justify-between font-mono text-[11px]",children:[h.jsx("span",{className:"text-neutral-500",children:"Watermark commit seq:"}),h.jsxs("span",{className:"text-white",children:["#",f.watermarkCommitSeq]})]}),h.jsxs("div",{className:"flex justify-between font-mono text-[11px] items-center",children:[h.jsx("span",{className:"text-neutral-500",children:"Commits to delete:"}),h.jsx(mn,{variant:f.commitsToDelete>0?"offline":"ghost",children:f.commitsToDelete})]})]})]}):null}),h.jsxs(Nn,{children:[h.jsx(Me,{variant:"default",onClick:()=>n(!1),children:s!==null?"Close":"Cancel"}),s===null&&h.jsx(Me,{variant:"destructive",onClick:b,disabled:g.isPending||d||(f?.commitsToDelete??0)===0,children:g.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Pruning..."]}):"Prune Now"})]})]})})]})}function PX({partitionId:e}){const[t,n]=_.useState(!1),[s,i]=_.useState(null),{data:a,isLoading:l}=rf({partitionId:e}),f=OY(),d=()=>{n(!0),i(null)},p=async()=>{const y=await f.mutateAsync();i(y.deletedChanges)};if(l)return h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsx(Pt,{size:"lg"})});const g=[{label:"Total changes",value:a?.changeCount??0},{label:"Total commits",value:a?.commitCount??0}];return h.jsxs(h.Fragment,{children:[h.jsx(_p,{title:"Compact",description:"Merge old changes to reduce storage space. Compaction merges multiple changes to the same row into a single change.",dotColor:"flow",stats:g,actionLabel:"Run Compaction",actionVariant:"primary",onAction:d}),h.jsx($r,{open:t,onOpenChange:n,children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Compact Changes"})}),h.jsx("div",{className:"px-5 py-4 flex flex-col gap-4",children:s!==null?h.jsxs(In,{variant:"default",children:[h.jsx(tf,{children:"Compaction Complete"}),h.jsxs(Pn,{children:["Successfully removed ",h.jsx("strong",{children:s})," redundant changes."]})]}):h.jsx(In,{variant:"default",children:h.jsx(Pn,{children:"Compaction will merge multiple changes to the same row, keeping only the most recent version. This is safe and can be run at any time."})})}),h.jsxs(Nn,{children:[h.jsx(Me,{variant:"default",onClick:()=>n(!1),children:s!==null?"Close":"Cancel"}),s===null&&h.jsx(Me,{variant:"primary",onClick:p,disabled:f.isPending,children:f.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Compacting..."]}):"Compact Now"})]})]})})]})}function DX({partitionId:e}){const[t,n]=_.useState(!1),[s,i]=_.useState("tasks"),[a,l]=_.useState(e??""),[f,d]=_.useState(null),[p,g]=_.useState(null),y=MY(),b=RX(s),x=[{label:"Next tables",value:b.length,tone:"syncing"},{label:"Last commit seq",value:f?`#${f.commitSeq}`:"—",tone:"syncing"},{label:"Last chunks cleared",value:f?.deletedChunks??"—"}],S=()=>{n(!0),g(null)},w=async()=>{if(b.length===0){g("Provide at least one table name.");return}g(null);const T=await y.mutateAsync({tables:b,partitionId:a.trim()||void 0});d(T)};return h.jsxs(h.Fragment,{children:[h.jsx(_p,{title:"Notify Data Change",description:"Create a synthetic commit after external imports or direct DB writes so clients re-bootstrap for affected tables.",dotColor:"healthy",stats:x,actionLabel:"Notify Clients",actionVariant:"primary",onAction:S}),h.jsx($r,{open:t,onOpenChange:n,children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Notify External Data Change"})}),h.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4",children:[f?h.jsxs(In,{variant:"default",children:[h.jsx(tf,{children:"Notification Sent"}),h.jsxs(Pn,{children:["Created synthetic commit"," ",h.jsxs("strong",{children:["#",f.commitSeq]})," for"," ",h.jsx("strong",{children:f.tables.length})," table",f.tables.length===1?"":"s"," and cleared"," ",h.jsx("strong",{children:f.deletedChunks})," cached chunk",f.deletedChunks===1?"":"s","."]})]}):h.jsx(In,{variant:"default",children:h.jsx(Pn,{children:"Use this when data changed outside Syncular push flow. It invalidates cached snapshot chunks and forces clients to pull fresh data."})}),p?h.jsx(In,{variant:"destructive",children:h.jsx(Pn,{children:p})}):null,h.jsxs(ms,{children:[h.jsx(es,{children:"Tables (comma-separated)"}),h.jsx(Gn,{value:s,onChange:T=>i(T.target.value),placeholder:"tasks, notes",disabled:y.isPending}),h.jsx(pc,{children:"Enter one or more table names affected by the external change."})]}),h.jsxs(ms,{children:[h.jsx(es,{children:"Partition ID (optional)"}),h.jsx(Gn,{value:a,onChange:T=>l(T.target.value),placeholder:"default",disabled:y.isPending})]})]}),h.jsxs(Nn,{children:[h.jsx(Me,{variant:"default",onClick:()=>n(!1),children:f?"Close":"Cancel"}),f?null:h.jsx(Me,{variant:"primary",onClick:w,disabled:y.isPending,children:y.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"}),"Notifying..."]}):"Notify Data Change"})]})]})})]})}function zX({partitionId:e}){const[t,n]=_.useState("all"),{data:s,isLoading:i,error:a}=jY({limit:20,offset:0,operationType:t==="all"?void 0:t,partitionId:e},{refetchIntervalMs:5e3});return h.jsx(Jb,{title:"Operation Audit",description:"Recent prune/compact/notify/evict actions with actor and result context.",actions:h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Me,{variant:t==="all"?"default":"ghost",size:"sm",onClick:()=>n("all"),children:"All"}),h.jsx(Me,{variant:t==="prune"?"default":"ghost",size:"sm",onClick:()=>n("prune"),children:"Prune"}),h.jsx(Me,{variant:t==="compact"?"default":"ghost",size:"sm",onClick:()=>n("compact"),children:"Compact"}),h.jsx(Me,{variant:t==="notify_data_change"?"default":"ghost",size:"sm",onClick:()=>n("notify_data_change"),children:"Notify"}),h.jsx(Me,{variant:t==="evict_client"?"default":"ghost",size:"sm",onClick:()=>n("evict_client"),children:"Evict"})]}),contentClassName:"pt-2",children:i?h.jsx("div",{className:"flex items-center justify-center py-10",children:h.jsx(Pt,{size:"lg"})}):a?h.jsx(In,{variant:"destructive",children:h.jsxs(Pn,{children:["Failed to load operation audit events: ",a.message]})}):(s?.items.length??0)===0?h.jsx("div",{className:"px-2 py-8 text-sm text-neutral-500",children:"No operation events found for this filter."}):h.jsx("div",{className:"overflow-x-auto",children:h.jsxs(tl,{children:[h.jsx(nl,{children:h.jsxs(ss,{children:[h.jsx(ht,{children:"Time"}),h.jsx(ht,{children:"Type"}),h.jsx(ht,{children:"User"}),h.jsx(ht,{children:"Target"}),h.jsx(ht,{children:"Result"})]})}),h.jsx(rl,{children:(s?.items??[]).map((l,f)=>h.jsxs(ss,{children:[h.jsx(pt,{className:"whitespace-nowrap text-xs text-neutral-400",children:kX(l.createdAt)}),h.jsx(pt,{children:h.jsx(mn,{variant:"ghost",children:NX(l.operationType)})}),h.jsx(pt,{className:"font-mono text-xs",children:l.consoleUserId??"system"}),h.jsx(pt,{className:"font-mono text-xs",children:l.targetClientId??l.partitionId??(l.operationType==="notify_data_change"?"partition default":"global")}),h.jsx(pt,{className:"font-mono text-xs text-neutral-300",children:AX(l)})]},`${l.operationId}:${l.createdAt}:${f}`))})]})})})}function LX(){const[e,t]=pi("console:alert-config",TX),n={p90Latency:e.latencyThresholdMs,errorRate:e.errorRateThreshold,clientLag:e.clientLagThreshold},s=a=>{t(l=>({...l,latencyThresholdMs:a.p90Latency,errorRateThreshold:a.errorRate,clientLagThreshold:a.clientLag}))},i=a=>{t(l=>({...l,enabled:a}))};return h.jsx($j,{enabled:e.enabled,onEnabledChange:i,thresholds:n,onThresholdsChange:s})}function UX(e){if(e===0)return"0 B";const t=["B","KB","MB","GB","TB"],n=Math.floor(Math.log(e)/Math.log(1024));return`${(e/1024**n).toFixed(n===0?0:1)} ${t[n]}`}function $X(e){const t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function BX(){const[e,t]=_.useState(""),[n,s]=_.useState(void 0),[i,a]=_.useState(void 0),[l,f]=_.useState([]),[d,p]=_.useState(null),{data:g,isLoading:y,error:b}=$Y({prefix:n,cursor:i,limit:100}),x=BY(),S=FY();function w(){const M=e.trim();s(M.length>0?M:void 0),a(void 0),f([])}function T(){t(""),s(void 0),a(void 0),f([])}function C(){g?.cursor&&(f(M=>[...M,i??""]),a(g.cursor))}function O(){f(M=>{const z=[...M],j=z.pop();return a(j&&j.length>0?j:void 0),z})}function N(){d&&x.mutate(d,{onSuccess:()=>p(null)})}if(y)return h.jsx("div",{className:"flex flex-col gap-4 px-5 py-5",children:h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsx(Pt,{size:"lg"})})});if(b)return h.jsx("div",{className:"flex flex-col gap-4 px-5 py-5",children:h.jsx("div",{className:"flex items-center justify-center h-[200px]",children:h.jsxs("p",{className:"text-danger font-mono text-[11px]",children:["Failed to load storage items: ",b.message]})})});const R=g?.items??[];return h.jsxs("div",{className:"flex flex-col gap-4 px-5 py-5",children:[h.jsx(Jb,{title:"Storage",actions:h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Gn,{placeholder:"Prefix filter...",value:e,onChange:M=>t(M.target.value),onKeyDown:M=>{M.key==="Enter"&&w()},className:"h-7 w-48 text-xs"}),h.jsx(Me,{variant:"default",size:"sm",onClick:w,children:"Filter"}),n&&h.jsx(Me,{variant:"ghost",size:"sm",onClick:T,children:"Clear"})]}),children:R.length===0?h.jsx(Qb,{message:n?`No storage items matching prefix "${n}".`:"No storage items found."}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"overflow-x-auto",children:h.jsxs(tl,{children:[h.jsx(nl,{children:h.jsxs(ss,{children:[h.jsx(ht,{children:"Key"}),h.jsx(ht,{children:"Size"}),h.jsx(ht,{children:"Type"}),h.jsx(ht,{children:"Uploaded"}),h.jsx(ht,{children:"Actions"})]})}),h.jsx(rl,{children:R.map(M=>h.jsxs(ss,{children:[h.jsx(pt,{className:"font-mono text-xs max-w-[320px]",title:M.key,children:M.key}),h.jsx(pt,{className:"font-mono text-xs text-neutral-400 whitespace-nowrap",children:UX(M.size)}),h.jsx(pt,{children:M.httpMetadata?.contentType?h.jsx(mn,{variant:"ghost",children:M.httpMetadata.contentType}):h.jsx("span",{className:"text-neutral-500 text-xs",children:"--"})}),h.jsx(pt,{className:"whitespace-nowrap text-xs text-neutral-400",children:$X(M.uploaded)}),h.jsx(pt,{children:h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{S(M.key)},children:"Download"}),h.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>p(M.key),children:"Delete"})]})})]},M.key))})]})}),h.jsxs("div",{className:"flex items-center justify-between px-2 py-2",children:[h.jsx(Me,{variant:"ghost",size:"sm",disabled:l.length===0,onClick:O,children:"Previous"}),h.jsx(Me,{variant:"ghost",size:"sm",disabled:!g?.truncated,onClick:C,children:"Next"})]})]})}),h.jsx($r,{open:d!==null,onOpenChange:()=>p(null),children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Delete Storage Item"})}),h.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[h.jsxs("p",{className:"font-mono text-[11px] text-neutral-300",children:["Are you sure you want to delete"," ",h.jsx("span",{className:"font-mono text-white",children:d}),"?"]}),h.jsx("p",{className:"font-mono text-[10px] text-neutral-500",children:"This action cannot be undone."})]}),h.jsxs(Nn,{children:[h.jsx(Me,{variant:"default",onClick:()=>p(null),children:"Cancel"}),h.jsx(Me,{variant:"destructive",onClick:N,disabled:x.isPending,children:x.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Pt,{size:"sm"})," Deleting..."]}):"Delete"})]})]})})]})}const FX={};function au(e,t){if(t==="absolute")return new Date(e).toLocaleString();const n=new Date(e),i=new Date().getTime()-n.getTime(),a=Math.floor(i/1e3);return a<60?`${a}s`:a<3600?`${Math.floor(a/60)}m`:a<86400?`${Math.floor(a/3600)}h`:`${Math.floor(a/86400)}d`}function HX(e){const t=e.split(/\s+/).map(i=>i.trim()).filter(i=>i.length>0),n={},s=[];for(const i of t){const[a="",...l]=i.split(":"),f=l.join(":").trim(),d=a.toLowerCase();if(!f){s.push(i);continue}if(d==="actor"){n.actorId=f;continue}if(d==="client"){n.clientId=f;continue}if(d==="table"){n.table=f;continue}if(d==="request"){n.requestId=f;continue}if(d==="trace"){n.traceId=f;continue}s.push(i)}return s.length>0&&(n.search=s.join(" ")),n}function qX(e){return e==="1h"?3600*1e3:e==="6h"?360*60*1e3:e==="24h"?1440*60*1e3:e==="7d"?10080*60*1e3:720*60*60*1e3}function Gd(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function VX(e,t){return e?`#${e.federatedCommitId??(t?`${t}:${e.commitSeq}`:String(e.commitSeq))}`:"#?"}function KX(e,t){return e?`E${e.federatedEventId??(t?`${t}:${e.eventId}`:e.eventId)}`:"E?"}function GX(e,t,n){return!e||!t?null:e.replaceAll("{traceId}",encodeURIComponent(t)).replaceAll("{spanId}",encodeURIComponent(n??""))}function vx({initialSelectedEntryId:e}={}){const{preferences:t}=of(),{partitionId:n}=sf(),{range:s,setRange:i}=mk(),a=t.pageSize,l=t.refreshInterval*1e3,f=FX?.VITE_CONSOLE_TRACE_URL_TEMPLATE,[d,p]=_.useState(()=>e?.startsWith("#")?"commits":e?.startsWith("E")?"events":"all"),[g,y]=_.useState("all"),[b,x]=_.useState("all"),[S,w]=_.useState(""),[T,C]=_.useState(1),[O,N]=_.useState(!1),[R,M]=_.useState(e??null),z=_.useRef(!1),j=_.useMemo(()=>HX(S),[S]),A=_.useMemo(()=>new Date(Date.now()-qX(s)).toISOString(),[s]),{data:P,isLoading:Q,refetch:B}=EY({limit:a,offset:(T-1)*a,...n?{partitionId:n}:{},view:d,...d!=="commits"&&g!=="all"?{eventType:g}:{},...d!=="commits"&&b!=="all"?{outcome:b}:{},...j.actorId?{actorId:j.actorId}:{},...j.clientId?{clientId:j.clientId}:{},...j.requestId?{requestId:j.requestId}:{},...j.traceId?{traceId:j.traceId}:{},...j.table?{table:j.table}:{},...j.search?{search:j.search}:{},from:A},{refetchIntervalMs:l}),U=JY(),Z=R?.startsWith("#")?R.slice(1):void 0,K=R?.startsWith("E")?R.slice(1):void 0,ee=Z&&Z!=="?"?Z:void 0,D=K&&K!=="?"?K:void 0,{data:G,isLoading:q,error:V}=wY(ee,{enabled:ee!==void 0,partitionId:n}),{data:L,isLoading:I,error:H}=TY(D,{enabled:D!==void 0,partitionId:n}),{data:W,isLoading:Y,error:ae}=CY(D,{enabled:D!==void 0&&!!L?.payloadRef,partitionId:n}),se=_.useMemo(()=>GX(f,L?.traceId??null,L?.spanId??null),[L?.spanId,L?.traceId,f]);_.useEffect(()=>{C(1)},[]),_.useEffect(()=>{C(1)},[]),_.useEffect(()=>{e&&M(e)},[e]),_.useEffect(()=>{if(!z.current){z.current=!0;return}M(null)},[]),_.useEffect(()=>{C(1),M(null)},[]);const Se=_.useMemo(()=>(P?.items??[]).map(we=>{const ye=we.instanceId??we.commit?.instanceId??we.event?.instanceId,xe=ye?`[${ye}] `:"";if(we.type==="commit"&&we.commit){const Ie=we.commit;return{type:"commit",id:VX(Ie,ye),outcome:"--",duration:"--",actor:Ie.actorId,client:Ie.clientId,detail:`${xe}${Ie.changeCount} chg | ${(Ie.affectedTables??[]).join(", ")}`,time:au(we.timestamp,t.timeFormat)}}const ve=we.event;return ve?{type:ve.eventType,id:KX(ve,ye),outcome:ve.outcome,duration:`${ve.durationMs}ms`,actor:ve.actorId,client:ve.clientId,detail:`${xe}${(ve.tables??[]).join(", ")||"--"}`,time:au(we.timestamp,t.timeFormat)}:{type:"pull",id:"E?",outcome:"unknown",duration:"--",actor:"",client:"",detail:"--",time:au(we.timestamp,t.timeFormat)}}),[t.timeFormat,P?.items]),pe=P?.total??0,Oe=Math.max(1,Math.ceil(pe/a)),_e=Q,re=[{label:"",options:[{id:"all",label:"All"},{id:"commits",label:"Commits"},{id:"events",label:"Events"}],activeId:d,onActiveChange:ie=>{p(ie),ie==="commits"&&(y("all"),x("all")),C(1)}},{label:"Time",options:[{id:"1h",label:"1h"},{id:"6h",label:"6h"},{id:"24h",label:"24h"},{id:"7d",label:"7d"},{id:"30d",label:"30d"}],activeId:s,onActiveChange:ie=>{i(ie),C(1)}},{label:"Type",options:[{id:"all",label:"All"},{id:"push",label:"Push"},{id:"pull",label:"Pull"}],activeId:g,onActiveChange:ie=>{y(ie),C(1)}},{label:"Outcome",options:[{id:"all",label:"All"},{id:"applied",label:"Applied"},{id:"error",label:"Error"},{id:"rejected",label:"Rejected"}],activeId:b,onActiveChange:ie=>{x(ie),C(1)}}];function he(){U.mutate(void 0,{onSuccess:()=>{N(!1),B()}})}return h.jsxs("div",{className:"flex flex-col h-full",children:[_e&&Se.length===0?h.jsx("div",{className:"flex items-center justify-center py-24",children:h.jsx(Pt,{size:"lg"})}):h.jsx(Jj,{entries:Se,selectedEntryId:R,onEntryClick:ie=>M(ie.id),filterBar:h.jsx(Vj,{groups:re,searchValue:S,searchPlaceholder:"Use actor:, client:, table:, request:, trace: or free text...",onSearchChange:w,actions:h.jsxs(h.Fragment,{children:[h.jsx(Me,{size:"sm",variant:"ghost",onClick:()=>{B()},children:"Refresh"}),h.jsx(Me,{size:"sm",variant:"ghost",children:"Export"}),h.jsx(Me,{size:"sm",variant:"destructive",onClick:()=>N(!0),children:"Clear"})]})}),pagination:h.jsx(mx,{page:T,totalPages:Oe,totalItems:pe,onPageChange:C})}),h.jsx($r,{open:R!==null,onOpenChange:ie=>{ie||M(null)},children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:ee!==void 0?`Commit #${ee}`:D!==void 0?`Event E${D}`:"Entry details"})}),h.jsx("div",{className:"px-5 py-4 space-y-3 max-h-[70vh] overflow-y-auto",children:q||I?h.jsx("div",{className:"flex items-center justify-center py-8",children:h.jsx(Pt,{size:"sm"})}):V||H?h.jsx("p",{className:"font-mono text-[11px] text-offline",children:"Failed to load details."}):G?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"grid grid-cols-2 gap-3 font-mono text-[11px]",children:[h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Actor"}),h.jsx("div",{className:"text-neutral-100",children:G.actorId})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Client"}),h.jsx("div",{className:"text-neutral-100",children:G.clientId})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Instance"}),h.jsx("div",{className:"text-neutral-100",children:G.instanceId??"--"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Created"}),h.jsx("div",{className:"text-neutral-100",children:au(G.createdAt,t.timeFormat)})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Changes"}),h.jsx("div",{className:"text-neutral-100",children:G.changeCount})]})]}),h.jsxs("div",{children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2",children:"Affected Tables"}),h.jsx("p",{className:"font-mono text-[11px] text-neutral-200",children:G.affectedTables.join(", ")||"--"})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500",children:"Changes"}),G.changes.length===0?h.jsx("p",{className:"font-mono text-[11px] text-neutral-500",children:"No changes recorded."}):G.changes.map(ie=>h.jsxs("div",{className:"rounded-md border border-border p-3 space-y-2",children:[h.jsxs("div",{className:"flex items-center justify-between font-mono text-[11px]",children:[h.jsxs("span",{className:"text-neutral-300",children:[ie.table," | ",ie.op]}),h.jsxs("span",{className:"text-neutral-500",children:["#",ie.changeId]})]}),h.jsxs("div",{className:"font-mono text-[11px] text-neutral-400",children:["rowId: ",ie.rowId,ie.rowVersion!==null?` | version: ${ie.rowVersion}`:""]}),h.jsx("pre",{className:"font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200",children:Gd(ie.rowJson)})]},ie.changeId))]})]}):L?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"grid grid-cols-2 gap-3 font-mono text-[11px]",children:[h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Type"}),h.jsx("div",{className:"text-neutral-100",children:L.eventType})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Path"}),h.jsx("div",{className:"text-neutral-100",children:L.syncPath})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Instance"}),h.jsx("div",{className:"text-neutral-100",children:L.instanceId??"--"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Outcome"}),h.jsx("div",{className:"text-neutral-100",children:L.outcome})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Response Status"}),h.jsx("div",{className:"text-neutral-100",children:L.responseStatus})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Actor"}),h.jsx("div",{className:"text-neutral-100",children:L.actorId})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Client"}),h.jsx("div",{className:"text-neutral-100",children:L.clientId})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Status"}),h.jsx("div",{className:"text-neutral-100",children:L.statusCode})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Transport"}),h.jsx("div",{className:"text-neutral-100",children:L.transportPath})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Duration"}),h.jsxs("div",{className:"text-neutral-100",children:[L.durationMs,"ms"]})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Request ID"}),h.jsx("div",{className:"text-neutral-100",children:L.requestId})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Trace ID"}),h.jsx("div",{className:"text-neutral-100",children:L.traceId??"--"}),se&&h.jsx("a",{href:se,target:"_blank",rel:"noreferrer",className:"font-mono text-[10px] text-flow underline underline-offset-4",children:"Open external trace"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Span ID"}),h.jsx("div",{className:"text-neutral-100",children:L.spanId??"--"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Commit Seq"}),h.jsx("div",{className:"text-neutral-100",children:L.commitSeq??"--"}),L.commitSeq!==null&&h.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>M(`#${L.instanceId?`${L.instanceId}:`:""}${L.commitSeq}`),children:"Open linked commit"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Subscription Count"}),h.jsx("div",{className:"text-neutral-100",children:L.subscriptionCount??"--"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Error Code"}),h.jsx("div",{className:"text-neutral-100",children:L.errorCode??"--"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Payload Ref"}),h.jsx("div",{className:"text-neutral-100",children:L.payloadRef??"--"})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-neutral-500",children:"Created"}),h.jsx("div",{className:"text-neutral-100",children:au(L.createdAt,t.timeFormat)})]})]}),h.jsxs("div",{children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2",children:"Tables"}),h.jsx("p",{className:"font-mono text-[11px] text-neutral-200",children:L.tables.join(", ")||"--"})]}),L.scopesSummary&&h.jsxs("div",{children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2",children:"Scopes Summary"}),h.jsx("pre",{className:"font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200",children:Gd(L.scopesSummary)})]}),L.payloadRef&&h.jsxs("div",{children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2",children:"Payload Snapshot"}),Y?h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Pt,{size:"sm"}),h.jsx("span",{className:"font-mono text-[11px] text-neutral-400",children:"Loading payload snapshot..."})]}):ae?h.jsx("p",{className:"font-mono text-[11px] text-offline",children:"Failed to load payload snapshot."}):W?h.jsxs("div",{className:"space-y-2",children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500",children:"Request"}),h.jsx("pre",{className:"font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200",children:Gd(W.requestPayload)}),h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500",children:"Response"}),h.jsx("pre",{className:"font-mono text-[10px] rounded bg-surface p-2 overflow-x-auto text-neutral-200",children:Gd(W.responsePayload)})]}):h.jsx("p",{className:"font-mono text-[11px] text-neutral-500",children:"No payload snapshot available."})]}),L.errorMessage&&h.jsxs("div",{children:[h.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-neutral-500 mb-2",children:"Error"}),h.jsx("p",{className:"font-mono text-[11px] text-offline",children:L.errorMessage})]})]}):h.jsx("p",{className:"font-mono text-[11px] text-neutral-500",children:"No details available for this row."})}),h.jsx(Nn,{children:h.jsx(Me,{variant:"default",size:"sm",onClick:()=>M(null),children:"Close"})})]})}),h.jsx($r,{open:O,onOpenChange:ie=>{ie||N(!1)},children:h.jsxs(hr,{children:[h.jsx(pr,{children:h.jsx(mr,{children:"Clear all events"})}),h.jsx("div",{className:"p-4",children:h.jsx("span",{className:"font-mono text-[11px] text-neutral-400",children:"This will permanently delete all request events. Commits are not affected. Are you sure?"})}),h.jsxs(Nn,{children:[h.jsx(Me,{variant:"default",size:"sm",onClick:()=>N(!1),children:"Cancel"}),h.jsx(Me,{variant:"destructive",size:"sm",onClick:he,disabled:U.isPending,children:U.isPending?"Clearing...":"Clear all"})]})]})})]})}const ZX=co({getParentRoute:()=>uo,path:"/config",component:dX}),YX=co({getParentRoute:()=>uo,path:"/fleet",component:EX}),XX=co({getParentRoute:()=>uo,path:"/",component:fX});function QX(){const{seq:e}=gk.useParams();return h.jsx(vx,{initialSelectedEntryId:`#${e}`})}const gk=co({getParentRoute:()=>uo,path:"/investigate/commit/$seq",component:QX});function WX(){const{id:e}=yk.useParams();return h.jsx(vx,{initialSelectedEntryId:`E${e}`})}const yk=co({getParentRoute:()=>uo,path:"/investigate/event/$id",component:WX}),JX=co({getParentRoute:()=>uo,path:"/ops",component:OX}),eQ=co({getParentRoute:()=>uo,path:"/storage",component:BX}),tQ=co({getParentRoute:()=>uo,path:"/stream",component:vx}),nQ=uo.addChildren([XX,tQ,gk,yk,YX,JX,eQ,ZX]),rQ="syncular-console-basepath",sQ="syncular-console-server-url",oQ="syncular-console-token";function iQ(e){if(!e)return;const t=e.trim();return t.length>0?t:void 0}function $v(e){const t=globalThis.document;if(!t)return;const n=t.querySelector(`meta[name="${e}"]`)?.getAttribute("content");return iQ(n)}function vk(e){return!e||e==="/"?"/":(e.startsWith("/")?e:`/${e}`).replace(/\/+$/g,"")||"/"}function aQ(){return vk($v(rQ))}function cQ(){const e=$v(sQ),t=$v(oQ);return!e||!t?null:{serverUrl:e,token:t}}function lQ(){return new k6({defaultOptions:{queries:{staleTime:5e3,retry:1}}})}function uQ(e){return vk(e??aQ())}function fQ(e){const[t]=_.useState(()=>lQ()),n=_.useMemo(()=>DH({routeTree:nQ,basepath:uQ(e.basePath)}),[e.basePath]),s=e.defaultConfig===void 0?cQ():e.defaultConfig,i=e.autoConnect??e.defaultConfig===void 0;return h.jsx(O6,{client:t,children:h.jsx(WH,{defaultConfig:s,autoConnect:i,children:h.jsx(UH,{router:n})})})}function dQ(e){return h.jsx("div",{className:yx,children:h.jsx(fQ,{...e})})}function hQ(e){const t=document.querySelector(e);if(!t)throw new Error(`Unable to mount console: ${e} not found`);return t}function pQ(e,t={}){const n=hQ(e);KY(n);const s=a6.createRoot(n),i=h.jsx(dQ,{basePath:t.basePath,defaultConfig:t.defaultConfig,autoConnect:t.autoConnect});return t.strictMode===!1?(s.render(i),s):(s.render(h.jsx(_.StrictMode,{children:i})),s)}var mQ={};const gQ="syncular-sentry-dsn",yQ="syncular-sentry-environment",vQ="syncular-sentry-release";function gu(e){if(!e)return;const t=e.trim();return t.length>0?t:void 0}function By(e){if(typeof document>"u")return;const t=document.querySelector(`meta[name="${e}"]`)?.getAttribute("content");return gu(t)}function Fy(e){if(!(typeof process>"u"))return gu(mQ[e])}function Hy(e){for(const t of e)if(t)return t}function bQ(){const e=Hy([gu(globalThis.__SYNCULAR_SENTRY_DSN__),By(gQ),Fy("SYNCULAR_SENTRY_DSN")]);if(!e)return null;const t=Hy([gu(globalThis.__SYNCULAR_SENTRY_ENVIRONMENT__),By(yQ),Fy("SYNCULAR_SENTRY_ENVIRONMENT")]),n=Hy([gu(globalThis.__SYNCULAR_SENTRY_RELEASE__),By(vQ),Fy("SYNCULAR_SENTRY_RELEASE")]);return{dsn:e,environment:t,release:n,enableLogs:!0,tracesSampleRate:.2,tracePropagationTargets:[/^https?:\/\/.*\/api\/.*/]}}const QC=bQ();QC&&WB(QC);pQ("#root");
|