shraga 0.1.162 → 0.1.163
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.
|
@@ -1904,7 +1904,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`),bn=ve,At=je),rt===void
|
|
|
1904
1904
|
`)},$M=function(){var e=parseInt(document.body.getAttribute(Tu)||"0",10);return isFinite(e)?e:0},fre=function(){b.useEffect(function(){return document.body.setAttribute(Tu,($M()+1).toString()),function(){var e=$M()-1;e<=0?document.body.removeAttribute(Tu):document.body.setAttribute(Tu,e.toString())}},[])},hre=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?"margin":r;fre();var a=b.useMemo(function(){return cre(i)},[i]);return b.createElement(ure,{styles:dre(a,!t,i,n?"":"!important")})},d1=!1;if(typeof window<"u")try{var kp=Object.defineProperty({},"passive",{get:function(){return d1=!0,!0}});window.addEventListener("test",kp,kp),window.removeEventListener("test",kp,kp)}catch{d1=!1}var ru=d1?{passive:!1}:!1,mre=function(e){return e.tagName==="TEXTAREA"},mz=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!mre(e)&&n[t]==="visible")},pre=function(e){return mz(e,"overflowY")},gre=function(e){return mz(e,"overflowX")},BM=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var i=pz(e,r);if(i){var a=gz(e,r),s=a[1],l=a[2];if(s>l)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},vre=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},yre=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},pz=function(e,t){return e==="v"?pre(t):gre(t)},gz=function(e,t){return e==="v"?vre(t):yre(t)},bre=function(e,t){return e==="h"&&t==="rtl"?-1:1},xre=function(e,t,n,r,i){var a=bre(e,window.getComputedStyle(t).direction),s=a*r,l=n.target,u=t.contains(l),d=!1,h=s>0,m=0,p=0;do{if(!l)break;var v=gz(e,l),w=v[0],x=v[1],E=v[2],_=x-E-a*w;(w||_)&&pz(e,l)&&(m+=_,p+=w);var k=l.parentNode;l=k&&k.nodeType===Node.DOCUMENT_FRAGMENT_NODE?k.host:k}while(!u&&l!==document.body||u&&(t.contains(l)||t===l));return(h&&Math.abs(m)<1||!h&&Math.abs(p)<1)&&(d=!0),d},Op=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},UM=function(e){return[e.deltaX,e.deltaY]},FM=function(e){return e&&"current"in e?e.current:e},wre=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Ere=function(e){return`
|
|
1905
1905
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
1906
1906
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
1907
|
-
`)},Sre=0,iu=[];function _re(e){var t=b.useRef([]),n=b.useRef([0,0]),r=b.useRef(),i=b.useState(Sre++)[0],a=b.useState(hz)[0],s=b.useRef(e);b.useEffect(function(){s.current=e},[e]),b.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var x=P7([e.lockRef.current],(e.shards||[]).map(FM),!0).filter(Boolean);return x.forEach(function(E){return E.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),x.forEach(function(E){return E.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var l=b.useCallback(function(x,E){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!s.current.allowPinchZoom;var _=Op(x),k=n.current,O="deltaX"in x?x.deltaX:k[0]-_[0],N="deltaY"in x?x.deltaY:k[1]-_[1],T,C=x.target,M=Math.abs(O)>Math.abs(N)?"h":"v";if("touches"in x&&M==="h"&&C.type==="range")return!1;var D=window.getSelection(),L=D&&D.anchorNode,R=L?L===C||L.contains(C):!1;if(R)return!1;var H=BM(M,C);if(!H)return!0;if(H?T=M:(T=M==="v"?"h":"v",H=BM(M,C)),!H)return!1;if(!r.current&&"changedTouches"in x&&(O||N)&&(r.current=T),!T)return!0;var P=r.current||T;return xre(P,E,x,P==="h"?O:N)},[]),u=b.useCallback(function(x){var E=x;if(!(!iu.length||iu[iu.length-1]!==a)){var _="deltaY"in E?UM(E):Op(E),k=t.current.filter(function(T){return T.name===E.type&&(T.target===E.target||E.target===T.shadowParent)&&wre(T.delta,_)})[0];if(k&&k.should){E.cancelable&&E.preventDefault();return}if(!k){var O=(s.current.shards||[]).map(FM).filter(Boolean).filter(function(T){return T.contains(E.target)}),N=O.length>0?l(E,O[0]):!s.current.noIsolation;N&&E.cancelable&&E.preventDefault()}}},[]),d=b.useCallback(function(x,E,_,k){var O={name:x,delta:E,target:_,should:k,shadowParent:Are(_)};t.current.push(O),setTimeout(function(){t.current=t.current.filter(function(N){return N!==O})},1)},[]),h=b.useCallback(function(x){n.current=Op(x),r.current=void 0},[]),m=b.useCallback(function(x){d(x.type,UM(x),x.target,l(x,e.lockRef.current))},[]),p=b.useCallback(function(x){d(x.type,Op(x),x.target,l(x,e.lockRef.current))},[]);b.useEffect(function(){return iu.push(a),e.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:p}),document.addEventListener("wheel",u,ru),document.addEventListener("touchmove",u,ru),document.addEventListener("touchstart",h,ru),function(){iu=iu.filter(function(x){return x!==a}),document.removeEventListener("wheel",u,ru),document.removeEventListener("touchmove",u,ru),document.removeEventListener("touchstart",h,ru)}},[]);var v=e.removeScrollBar,w=e.inert;return b.createElement(b.Fragment,null,w?b.createElement(a,{styles:Ere(i)}):null,v?b.createElement(hre,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Are(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const kre=ere(fz,_re);var bS=b.forwardRef(function(e,t){return b.createElement(Qv,xa({},e,{ref:t,sideCar:kre}))});bS.classNames=Qv.classNames;var Ore=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},au=new WeakMap,Np=new WeakMap,Cp={},Fx=0,vz=function(e){return e&&(e.host||vz(e.parentNode))},Nre=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=vz(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},Cre=function(e,t,n,r){var i=Nre(t,Array.isArray(e)?e:[e]);Cp[n]||(Cp[n]=new WeakMap);var a=Cp[n],s=[],l=new Set,u=new Set(i),d=function(m){!m||l.has(m)||(l.add(m),d(m.parentNode))};i.forEach(d);var h=function(m){!m||u.has(m)||Array.prototype.forEach.call(m.children,function(p){if(l.has(p))h(p);else try{var v=p.getAttribute(r),w=v!==null&&v!=="false",x=(au.get(p)||0)+1,E=(a.get(p)||0)+1;au.set(p,x),a.set(p,E),s.push(p),x===1&&w&&Np.set(p,!0),E===1&&p.setAttribute(n,"true"),w||p.setAttribute(r,"true")}catch(_){console.error("aria-hidden: cannot operate on ",p,_)}})};return h(t),l.clear(),Fx++,function(){s.forEach(function(m){var p=au.get(m)-1,v=a.get(m)-1;au.set(m,p),a.set(m,v),p||(Np.has(m)||m.removeAttribute(r),Np.delete(m)),v||m.removeAttribute(n)}),Fx--,Fx||(au=new WeakMap,au=new WeakMap,Np=new WeakMap,Cp={})}},yz=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=Ore(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),Cre(r,i,n,"aria-hidden")):function(){return null}},Jv="Dialog",[bz]=pL(Jv),[Tre,Ji]=bz(Jv),xz=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:s=!0}=e,l=b.useRef(null),u=b.useRef(null),[d,h]=Ane({prop:r,defaultProp:i??!1,onChange:a,caller:Jv});return y.jsx(Tre,{scope:t,triggerRef:l,contentRef:u,contentId:jx(),titleId:jx(),descriptionId:jx(),open:d,onOpenChange:h,onOpenToggle:b.useCallback(()=>h(m=>!m),[h]),modal:s,children:n})};xz.displayName=Jv;var wz="DialogTrigger",Ez=b.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Ji(wz,n),a=ui(t,i.triggerRef);return y.jsx(Fr.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":_S(i.open),...r,ref:a,onClick:Sr(e.onClick,i.onOpenToggle)})});Ez.displayName=wz;var xS="DialogPortal",[Mre,Sz]=bz(xS,{forceMount:void 0}),_z=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=Ji(xS,t);return y.jsx(Mre,{scope:t,forceMount:n,children:b.Children.map(r,s=>y.jsx(Zs,{present:n||a.open,children:y.jsx(uz,{asChild:!0,container:i,children:s})}))})};_z.displayName=xS;var Dg="DialogOverlay",wS=b.forwardRef((e,t)=>{const n=Sz(Dg,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Ji(Dg,e.__scopeDialog);return a.modal?y.jsx(Zs,{present:r||a.open,children:y.jsx(Rre,{...i,ref:t})}):null});wS.displayName=Dg;var Ire=WE("DialogOverlay.RemoveScroll"),Rre=b.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Ji(Dg,n),a=Rne(),s=ui(t,a);return y.jsx(bS,{as:Ire,allowPinchZoom:!0,shards:[i.contentRef],children:y.jsx(Fr.div,{"data-state":_S(i.open),...r,ref:s,style:{pointerEvents:"auto",...r.style}})})}),Fu="DialogContent",ES=b.forwardRef((e,t)=>{const n=Sz(Fu,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Ji(Fu,e.__scopeDialog);return y.jsx(Zs,{present:r||a.open,children:a.modal?y.jsx(Pre,{...i,ref:t}):y.jsx(Dre,{...i,ref:t})})});ES.displayName=Fu;var Pre=b.forwardRef((e,t)=>{const n=Ji(Fu,e.__scopeDialog),r=b.useRef(null),i=ui(t,n.contentRef,r);return b.useEffect(()=>{const a=r.current;if(a)return yz(a)},[]),y.jsx(Az,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:Sr(e.onCloseAutoFocus,a=>{var s;a.preventDefault(),(s=n.triggerRef.current)==null||s.focus()}),onPointerDownOutside:Sr(e.onPointerDownOutside,a=>{const s=a.detail.originalEvent,l=s.button===0&&s.ctrlKey===!0;(s.button===2||l)&&a.preventDefault()}),onFocusOutside:Sr(e.onFocusOutside,a=>a.preventDefault())})}),Dre=b.forwardRef((e,t)=>{const n=Ji(Fu,e.__scopeDialog),r=b.useRef(!1),i=b.useRef(!1);return y.jsx(Az,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var s,l;(s=e.onCloseAutoFocus)==null||s.call(e,a),a.defaultPrevented||(r.current||(l=n.triggerRef.current)==null||l.focus(),a.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:a=>{var u,d;(u=e.onInteractOutside)==null||u.call(e,a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const s=a.target;((d=n.triggerRef.current)==null?void 0:d.contains(s))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&i.current&&a.preventDefault()}})}),Az=b.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...s}=e,l=Ji(Fu,n);return qne(),y.jsx(y.Fragment,{children:y.jsx(lz,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:y.jsx(oz,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":_S(l.open),...s,ref:t,deferPointerDownOutside:!0,onDismiss:()=>l.onOpenChange(!1)})})})}),kz="DialogTitle",SS=b.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Ji(kz,n);return y.jsx(Fr.h2,{id:i.titleId,...r,ref:t})});SS.displayName=kz;var Oz="DialogDescription",jre=b.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Ji(Oz,n);return y.jsx(Fr.p,{id:i.descriptionId,...r,ref:t})});jre.displayName=Oz;var Nz="DialogClose",Cz=b.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Ji(Nz,n);return y.jsx(Fr.button,{type:"button",...r,ref:t,onClick:Sr(e.onClick,()=>i.onOpenChange(!1))})});Cz.displayName=Nz;function _S(e){return e?"open":"closed"}const Oo=xz,id=Ez,Lre=_z,Tz=b.forwardRef(({className:e,...t},n)=>y.jsx(wS,{ref:n,className:ze("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));Tz.displayName=wS.displayName;const Na=b.forwardRef(({className:e,children:t,...n},r)=>y.jsxs(Lre,{children:[y.jsx(Tz,{}),y.jsxs(ES,{ref:r,className:ze("fixed left-[50%] top-[50%] z-50 flex flex-col w-[calc(100vw-2rem)] max-w-lg max-h-[85dvh] overflow-y-auto translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-4 sm:p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 sm:rounded-lg",e),...n,children:[t,y.jsxs(Cz,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[y.jsx(Bs,{className:"h-4 w-4"}),y.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Na.displayName=ES.displayName;function Us({className:e,...t}){return y.jsx("div",{className:ze("shrink-0 flex flex-col space-y-1.5 text-center sm:text-left",e),...t})}function Mz({className:e,...t}){return y.jsx("div",{"data-dialog-body":!0,className:ze("flex-1 min-h-0 overflow-y-auto -mx-4 px-4 sm:-mx-6 sm:px-6",e),...t})}function Iz({className:e,...t}){return y.jsx("div",{className:ze("shrink-0 -mx-4 px-4 pt-3 border-t sm:-mx-6 sm:px-6","flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t})}const No=b.forwardRef(({className:e,...t},n)=>y.jsx(SS,{ref:n,className:ze("text-lg font-semibold leading-none tracking-tight",e),...t}));No.displayName=SS.displayName;const zre=new Set(["png","jpg","jpeg","gif","webp","svg","ico","bmp","avif"]),$re=new Set(["pdf","mp4","webm","mp3","ogg","wav"]);async function Bre(e,t){const n=await t();if(!n)return[];const r=await fetch(`/api/workspace/ls?path=${encodeURIComponent(e)}`,{headers:{Authorization:`Bearer ${n}`}});return r.ok?(await r.json()).entries??[]:[]}function Ure({getToken:e,onRefresh:t,refreshKey:n}){const[r,i]=b.useState(new Map),[a,s]=b.useState(()=>new Set),[l,u]=b.useState(null),[d,h]=b.useState(!1),[m,p]=b.useState("fit"),[v,w]=b.useState(null),[x,E]=b.useState(null),_=b.useRef(null),[k,O]=b.useState(null),[N,T]=b.useState(!1),[C,M]=b.useState([]),D=b.useCallback(async F=>{const Y=await Bre(F,e);i(U=>new Map(U).set(F,Y))},[e]);b.useEffect(()=>{D(""),a.forEach(F=>D(F))},[D,n]);const L=r.get("")??[],R=b.useCallback(F=>{try{const Y=F.contentDocument;if(!(Y!=null&&Y.body))return;const U=Math.max(Y.body.offsetWidth,Y.body.scrollWidth),G=Math.max(Y.body.offsetHeight,Y.body.scrollHeight);U&&G&&E({w:U,h:G})}catch{}},[]),H=b.useCallback(()=>{const F=_.current,Y=x;if(!F||!Y)return;const U=16,G=F.clientWidth-U,$=F.clientHeight-U,j=Math.min(G/Y.w,$/Y.h,1);w({scale:j,w:Y.w,h:Y.h})},[x]);b.useEffect(()=>{if(!(l!=null&&l.html)||m!=="fit"){w(null);return}const F=_.current;if(!F)return;const Y=new ResizeObserver(()=>requestAnimationFrame(H));return Y.observe(F),()=>Y.disconnect()},[l==null?void 0:l.html,d,m,H]),b.useEffect(()=>{N&&e().then(F=>{F&&fetch("/api/data-sync/log",{headers:{Authorization:`Bearer ${F}`}}).then(Y=>Y.json()).then(M).catch(()=>{})})},[N]);const P=F=>{s(Y=>{const U=new Set(Y);return U.has(F)?U.delete(F):(U.add(F),r.has(F)||D(F)),U})},q=(F,Y)=>{const U=new URLSearchParams({path:F});return k&&U.set("token",k),Y&&U.set("dl","1"),`/api/workspace/raw?${U}`},K=async F=>{var G;const Y=await e();if(!Y)return;O(Y);const U=((G=F.split(".").pop())==null?void 0:G.toLowerCase())??"";if(U==="html"||U==="htm"){u({path:F,content:"",binary:!1,html:!0});return}if(zre.has(U)){u({path:F,content:"",binary:!1,image:!0});return}if($re.has(U)){u({path:F,content:"",binary:!1,html:!0});return}try{const $=await fetch(`/api/workspace/file?path=${encodeURIComponent(F)}`,{headers:{Authorization:`Bearer ${Y}`}});if(!$.ok)return;const j=await $.json();u({path:F,content:j.content,binary:!!j.binary})}catch{}},X=(F,Y)=>y.jsx(y.Fragment,{children:F.map(U=>{const G=U.path.split("/").pop();return y.jsxs("div",{children:[U.type==="dir"?y.jsxs("button",{onClick:()=>P(U.path),className:"w-full flex items-center gap-1 px-2 py-1 rounded hover:bg-accent/50 text-left text-sm",style:{paddingLeft:8+Y*12},children:[y.jsx(Xs,{className:ze("w-3 h-3 shrink-0 transition-transform",a.has(U.path)&&"rotate-90")}),y.jsx(eV,{className:"w-3.5 h-3.5 shrink-0 text-muted-foreground"}),y.jsx("span",{className:"truncate",children:G})]}):y.jsxs("button",{onClick:()=>K(U.path),className:"w-full flex items-center gap-1 px-2 py-1 rounded hover:bg-accent/50 text-left text-sm",style:{paddingLeft:8+Y*12+12},title:U.oneLiner||U.path,children:[y.jsx(HE,{className:"w-3.5 h-3.5 shrink-0 text-muted-foreground"}),y.jsx("span",{className:"truncate",children:G})]}),U.type==="dir"&&a.has(U.path)&&X(r.get(U.path)??[],Y+1)]},U.path)})});return y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex items-center justify-between px-3 pt-2 pb-1 shrink-0",children:[y.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Workspace"}),y.jsxs("div",{className:"flex items-center gap-0.5",children:[y.jsx("button",{onClick:()=>T(!0),className:"p-0.5 rounded hover:bg-accent text-muted-foreground",title:"Activity log",children:y.jsx(nV,{className:"w-3 h-3"})}),y.jsx("button",{onClick:()=>{D(""),a.forEach(F=>D(F)),t==null||t()},className:"p-0.5 rounded hover:bg-accent text-muted-foreground",title:"Refresh",children:y.jsx(td,{className:"w-3 h-3"})})]})]}),y.jsx("div",{className:"px-1 pb-2 overflow-y-auto min-h-0",children:L.length===0?y.jsx("p",{className:"text-xs text-muted-foreground px-3 py-2",children:"Empty. Drop .md files into data/workspace/ or ask the agent to create some."}):X(L,0)}),y.jsx(Oo,{open:!!l,onOpenChange:F=>{F||(u(null),h(!1),p("fit"),E(null))},children:y.jsxs(Na,{className:ze(l!=null&&l.html?ze("!flex !flex-col !p-0 !gap-0 overflow-hidden",d?"max-w-none w-[100vw] h-[100vh] rounded-none border-0":"max-w-[90vw] w-[90vw] h-[85vh]"):"max-w-3xl max-h-[80vh] !flex !flex-col overflow-hidden"),children:[y.jsxs("div",{className:"absolute right-12 top-4 flex items-center gap-1.5 z-10",children:[(l==null?void 0:l.html)&&y.jsxs(y.Fragment,{children:[y.jsx("button",{onClick:()=>p(F=>F==="fit"?"scroll":"fit"),className:"rounded-sm opacity-70 hover:opacity-100 text-muted-foreground",title:m==="fit"?"Switch to scrollable (1:1)":"Switch to scale-to-fit",children:m==="fit"?y.jsx(sV,{className:"w-4 h-4"}):y.jsx(hV,{className:"w-4 h-4"})}),y.jsx("button",{onClick:()=>h(F=>!F),className:"rounded-sm opacity-70 hover:opacity-100 text-muted-foreground",title:d?"Restore":"Maximize",children:d?y.jsx(qE,{className:"w-4 h-4"}):y.jsx(KE,{className:"w-4 h-4"})})]}),l&&y.jsx("a",{href:q(l.path,!0),download:!0,className:"rounded-sm opacity-70 hover:opacity-100 text-muted-foreground",title:"Download",children:y.jsx(uL,{className:"w-4 h-4"})})]}),y.jsx(Us,{className:ze((l==null?void 0:l.html)&&"px-4 py-3 shrink-0 border-b"),children:y.jsx(No,{className:"font-mono text-sm truncate pr-16",children:l==null?void 0:l.path})}),y.jsx("div",{ref:l!=null&&l.html?_:void 0,className:ze(l!=null&&l.html?ze("flex-1 min-h-0 bg-muted/10",m==="fit"?"overflow-hidden flex items-center justify-center":"overflow-auto"):"flex-1 min-h-0 overflow-y-auto"),children:l!=null&&l.html?m==="fit"?y.jsx("div",{style:v?{width:v.w*v.scale,height:v.h*v.scale}:{width:"100%",height:"100%"},children:y.jsx("iframe",{src:q(l.path),className:"border-0 bg-white origin-top-left",title:l.path,onLoad:F=>{R(F.currentTarget),H()},style:v?{width:v.w,height:v.h,transform:`scale(${v.scale})`}:{width:"100%",height:"100%"}})}):y.jsx("iframe",{src:q(l.path),className:"border-0 bg-white mx-auto block",title:l.path,onLoad:F=>R(F.currentTarget),style:{width:(x==null?void 0:x.w)||"100%",height:(x==null?void 0:x.h)||"100%"}}):l!=null&&l.image?y.jsx("div",{className:"flex items-center justify-center p-4",children:y.jsx("img",{src:q(l.path),alt:l.path,className:"max-w-full max-h-[70vh] object-contain"})}):l!=null&&l.binary?y.jsx("p",{className:"text-sm text-muted-foreground",children:"(binary file — preview unavailable)"}):l!=null&&l.path.toLowerCase().endsWith(".md")||l!=null&&l.path.toLowerCase().endsWith(".markdown")?y.jsx("div",{className:"text-sm",children:y.jsx(h3,{remarkPlugins:[L3],rehypePlugins:[az],className:"prose prose-sm max-w-none dark:prose-invert prose-pre:bg-muted prose-pre:border prose-code:before:content-none prose-code:after:content-none",children:l.content})}):y.jsx("pre",{className:"text-xs whitespace-pre-wrap break-all",children:l==null?void 0:l.content})})]})}),y.jsx(Oo,{open:N,onOpenChange:T,children:y.jsxs(Na,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col",children:[y.jsx(Us,{children:y.jsx(No,{className:"text-sm",children:"Activity Log"})}),y.jsxs("div",{className:"overflow-y-auto flex-1 space-y-2",children:[C.map(F=>y.jsxs("div",{className:"border-b border-border/50 pb-2 last:border-0",children:[y.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[y.jsx("span",{className:"text-sm text-foreground",children:F.message}),y.jsx("span",{className:"text-[10px] text-muted-foreground shrink-0",children:Fre(F.date)})]}),F.files.length>0&&y.jsx("div",{className:"text-[11px] text-muted-foreground mt-0.5",children:F.files.map(Y=>y.jsx("span",{className:"inline-block mr-2 font-mono",children:Y},Y))})]},F.hash)),C.length===0&&y.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No activity yet"})]})]})})]})}function Fre(e){const t=new Date(e),r=new Date().getTime()-t.getTime(),i=Math.floor(r/6e4);if(i<60)return`${i}m ago`;const a=Math.floor(i/60);return a<24?`${a}h ago`:t.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function og(e,t=Date.now()){if(!e)return null;const n=new Date(e).getTime()-t;if(!Number.isFinite(n)||n<=0)return null;const r=Math.round(n/6e4);if(r<1)return"1m";if(r<60)return`${r}m`;const i=Math.floor(r/60),a=r%60;if(i<48)return a?`${i}h ${a}m`:`${i}h`;const s=Math.floor(i/24),l=i%24;return l?`${s}d ${l}h`:`${s}d`}const Hre=/resets\s+(\d{1,2})(?::(\d{2}))?\s*(am|pm)?\s*\(UTC\)/i;function Kre(e,t=Date.now(),n=Date.now()){var m;const r=e.match(Hre);if(!r)return e;let i=Number(r[1]);const a=r[2]?Number(r[2]):0,s=(m=r[3])==null?void 0:m.toLowerCase();if(s==="pm"&&i<12&&(i+=12),s==="am"&&i===12&&(i=0),i>23||a>59)return e;const l=new Date(t),u=new Date(Date.UTC(l.getUTCFullYear(),l.getUTCMonth(),l.getUTCDate(),i,a));u.getTime()<=t&&u.setUTCDate(u.getUTCDate()+1);const d=u.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}),h=og(u.toISOString(),n);return e.replace(r[0],`resets ${d}${h?` (in ${h})`:""}`)}var qre=Object.defineProperty,ad=(e,t)=>qre(e,"name",{value:t,configurable:!0}),Rz=!!(typeof window<"u"&&window.document&&window.document.createElement);function Ds(e,t,{checkForDefaultPrevented:n=!0}={}){return ad(function(i){if(e==null||e(i),n===!1||!i||!i.defaultPrevented)return t==null?void 0:t(i)},"handleEvent")}ad(Ds,"composeEventHandlers");function Gre(e){var t;if(!Rz)throw new Error("Cannot access window outside of the DOM");return((t=e==null?void 0:e.ownerDocument)==null?void 0:t.defaultView)??window}ad(Gre,"getOwnerWindow");function f1(e){if(!Rz)throw new Error("Cannot access document outside of the DOM");return(e==null?void 0:e.ownerDocument)??document}ad(f1,"getOwnerDocument");function Pz(e,t=!1){const{activeElement:n}=f1(e);if(!(n!=null&&n.nodeName))return null;if(Dz(n)&&n.contentDocument)return Pz(n.contentDocument.body,t);if(t){const r=n.getAttribute("aria-activedescendant");if(r){const i=f1(n).getElementById(r);if(i)return i}}return n}ad(Pz,"getActiveElement");function Dz(e){return e.tagName==="IFRAME"}ad(Dz,"isFrame");var Vre=Object.defineProperty,AS=(e,t)=>Vre(e,"name",{value:t,configurable:!0});function h1(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}AS(h1,"setRef");function jz(...e){return t=>{let n=!1;const r=e.map(i=>{const a=h1(i,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let i=0;i<r.length;i++){const a=r[i];typeof a=="function"?a():h1(e[i],null)}}}}AS(jz,"composeRefs");function od(...e){return b.useCallback(jz(...e),e)}AS(od,"useComposedRefs");var Wre=Object.defineProperty,Ni=(e,t)=>Wre(e,"name",{value:t,configurable:!0});function Yre(e,t){const n=b.createContext(t);n.displayName=e+"Context";const r=Ni(a=>{const{children:s,...l}=a,u=b.useMemo(()=>l,Object.values(l));return y.jsx(n.Provider,{value:u,children:s})},"Provider");r.displayName=e+"Provider";function i(a,s={}){const{optional:l=!1}=s,u=b.useContext(n);if(u)return u;if(t!==void 0)return t;if(!l)throw new Error(`\`${a}\` must be used within \`${e}\``)}return Ni(i,"useContext"),[r,i]}Ni(Yre,"createContext");function Lz(e,t=[]){let n=[];function r(a,s){const l=b.createContext(s);l.displayName=a+"Context";const u=n.length;n=[...n,s];const d=Ni(m=>{var _;const{scope:p,children:v,...w}=m,x=((_=p==null?void 0:p[e])==null?void 0:_[u])||l,E=b.useMemo(()=>w,Object.values(w));return y.jsx(x.Provider,{value:E,children:v})},"Provider");d.displayName=a+"Provider";function h(m,p,v={}){var _;const{optional:w=!1}=v,x=((_=p==null?void 0:p[e])==null?void 0:_[u])||l,E=b.useContext(x);if(E)return E;if(s!==void 0)return s;if(!w)throw new Error(`\`${m}\` must be used within \`${a}\``)}return Ni(h,"useContext"),[d,h]}Ni(r,"createContext");const i=Ni(()=>{const a=n.map(s=>b.createContext(s));return Ni(function(l){const u=(l==null?void 0:l[e])||a;return b.useMemo(()=>({[`__scope${e}`]:{...l,[e]:u}}),[l,u])},"useScope")},"createScope");return i.scopeName=e,[r,zz(i,...t)]}Ni(Lz,"createContextScope");function zz(...e){const t=e[0];if(e.length===1)return t;const n=Ni(()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return Ni(function(a){const s=r.reduce((l,{useScope:u,scopeName:d})=>{const m=u(a)[`__scope${d}`];return{...l,...m}},{});return b.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])},"useComposedScopes")},"createScope");return n.scopeName=t.scopeName,n}Ni(zz,"composeContextScopes");var Xre=Object.defineProperty,ea=(e,t)=>Xre(e,"name",{value:t,configurable:!0});function kS(e){const t=b.forwardRef((n,r)=>{let{children:i,...a}=n,s=null,l=!1;const u=[];m1(i)&&typeof Tp=="function"&&(i=Tp(i._payload)),b.Children.forEach(i,p=>{var v;if(Fz(p)){l=!0;const w=p;let x="child"in w.props?w.props.child:w.props.children;m1(x)&&typeof Tp=="function"&&(x=Tp(x._payload)),s=Qre(w,x),u.push((v=s==null?void 0:s.props)==null?void 0:v.children)}else u.push(p)}),s?s=b.cloneElement(s,void 0,u):!l&&b.Children.count(i)===1&&b.isValidElement(i)&&(s=i);const d=s?Uz(s):void 0,h=od(r,d);if(!s){if(i||i===0)throw new Error(l?tie(e):eie(e));return i}const m=Bz(a,s.props??{});return s.type!==b.Fragment&&(m.ref=r?h:d),b.cloneElement(s,m)});return t.displayName=`${e}.Slot`,t}ea(kS,"createSlot");var $z=Symbol.for("radix.slottable");function Zre(e){const t=ea(n=>"child"in n?n.children(n.child):n.children,"Slottable");return t.displayName=`${e}.Slottable`,t.__radixId=$z,t}ea(Zre,"createSlottable");var Qre=ea((e,t)=>{if("child"in e.props){const n=e.props.child;return b.isValidElement(n)?b.cloneElement(n,void 0,e.props.children(n.props.children)):null}return b.isValidElement(t)?t:null},"getSlottableElementFromSlottable");function Bz(e,t){const n={...t};for(const r in t){const i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...l)=>{const u=a(...l);return i(...l),u}:i&&(n[r]=i):r==="style"?n[r]={...i,...a}:r==="className"&&(n[r]=[i,a].filter(Boolean).join(" "))}return{...e,...n}}ea(Bz,"mergeProps");function Uz(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}ea(Uz,"getElementRef");function Fz(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===$z}ea(Fz,"isSlottable");var Jre=Symbol.for("react.lazy");function m1(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Jre&&"_payload"in e&&Hz(e._payload)}ea(m1,"isLazyComponent");function Hz(e){return typeof e=="object"&&e!==null&&"then"in e}ea(Hz,"isPromiseLike");var eie=ea(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),tie=ea(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),Tp=ja[" use ".trim().toString()],nie=Object.defineProperty,rie=(e,t)=>nie(e,"name",{value:t,configurable:!0}),iie=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ey=iie.reduce((e,t)=>{const n=kS(`Primitive.${t}`),r=b.forwardRef((i,a)=>{const{asChild:s,...l}=i,u=s?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),y.jsx(u,{...l,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Kz(e,t){e&&La.flushSync(()=>e.dispatchEvent(t))}rie(Kz,"dispatchDiscreteCustomEvent");var aie=Object.defineProperty,oie=(e,t)=>aie(e,"name",{value:t,configurable:!0});function ty(e){const t=b.useRef(e);return b.useEffect(()=>{t.current=e}),b.useMemo(()=>((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)}),[])}oie(ty,"useCallbackRef");var sie=Object.defineProperty,qn=(e,t)=>sie(e,"name",{value:t,configurable:!0}),p1="dismissableLayer.update",lie="dismissableLayer.pointerDownOutside",cie="dismissableLayer.focusOutside",HM,qz=b.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),uie=b.forwardRef(qn(function(t,n){const{disableOutsidePointerEvents:r=!1,deferPointerDownOutside:i=!1,onEscapeKeyDown:a,onPointerDownOutside:s,onFocusOutside:l,onInteractOutside:u,onDismiss:d,...h}=t,m=b.useContext(qz),[p,v]=b.useState(null),w=(p==null?void 0:p.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,x]=b.useState({}),E=od(n,v),_=Array.from(m.layers),[k]=[...m.layersWithOutsidePointerEventsDisabled].slice(-1),O=k?_.indexOf(k):-1,N=p?_.indexOf(p):-1,T=m.layersWithOutsidePointerEventsDisabled.size>0,C=N>=O,M=b.useRef(!1),D=Gz(P=>{s==null||s(P),u==null||u(P),P.defaultPrevented||d==null||d()},{ownerDocument:w,deferPointerDownOutside:i,isDeferredPointerDownOutsideRef:M,dismissableSurfaces:m.dismissableSurfaces,shouldHandlePointerDownOutside:b.useCallback(P=>{if(!(P instanceof Node))return!1;const q=[...m.branches].some(K=>K.contains(P));return C&&!q},[m.branches,C])}),L=Vz(P=>{if(i&&M.current)return;const q=P.target;[...m.branches].some(X=>X.contains(q))||(l==null||l(P),u==null||u(P),P.defaultPrevented||d==null||d())},w),R=p?N===_.length-1:!1,H=ty(P=>{P.key==="Escape"&&(a==null||a(P),!P.defaultPrevented&&d&&(P.preventDefault(),d()))});return b.useEffect(()=>{if(R)return w.addEventListener("keydown",H,{capture:!0}),()=>w.removeEventListener("keydown",H,{capture:!0})},[w,R,H]),b.useEffect(()=>{if(p)return r&&(m.layersWithOutsidePointerEventsDisabled.size===0&&(HM=w.body.style.pointerEvents,w.body.style.pointerEvents="none"),m.layersWithOutsidePointerEventsDisabled.add(p)),m.layers.add(p),g1(),()=>{r&&(m.layersWithOutsidePointerEventsDisabled.delete(p),m.layersWithOutsidePointerEventsDisabled.size===0&&(w.body.style.pointerEvents=HM))}},[p,w,r,m]),b.useEffect(()=>()=>{p&&(m.layers.delete(p),m.layersWithOutsidePointerEventsDisabled.delete(p),g1())},[p,m]),b.useEffect(()=>{const P=qn(()=>x({}),"handleUpdate");return document.addEventListener(p1,P),()=>document.removeEventListener(p1,P)},[]),y.jsx(ey.div,{...h,ref:E,style:{pointerEvents:T?C?"auto":"none":void 0,...t.style},onFocusCapture:Ds(t.onFocusCapture,L.onFocusCapture),onBlurCapture:Ds(t.onBlurCapture,L.onBlurCapture),onPointerDownCapture:Ds(t.onPointerDownCapture,D.onPointerDownCapture)})},"DismissableLayer"));function die(){const e=b.useContext(qz),[t,n]=b.useState(null);return b.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}qn(die,"useDismissableLayerSurface");var fie=qn(()=>!0,"IS_TRUE");function Gz(e,t){const{ownerDocument:n=globalThis==null?void 0:globalThis.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:s=fie}=t,l=ty(e),u=b.useRef(!1),d=b.useRef(!1),h=b.useRef(new Map),m=b.useRef(()=>{});return b.useEffect(()=>{function p(){d.current=!1,i.current=!1,h.current.clear()}qn(p,"resetOutsideInteraction");function v(){return Array.from(h.current.values()).some(Boolean)}qn(v,"isOutsideInteractionIntercepted");function w(O){if(!d.current)return;const N=O.target;N instanceof Node&&[...a].some(C=>C.contains(N))||h.current.set(O.type,!0),O.type==="click"&&window.setTimeout(()=>{d.current&&m.current()},0)}qn(w,"handleInteractionCapture");function x(O){d.current&&h.current.set(O.type,!1)}qn(x,"handleInteractionBubble");const E=qn(O=>{if(O.target&&!u.current){let N=function(){n.removeEventListener("click",m.current);const C=v();p(),C||OS(lie,l,T,{discrete:!0})};if(qn(N,"handleAndDispatchPointerDownOutsideEvent"),!s(O.target)){n.removeEventListener("click",m.current),p(),u.current=!1;return}const T={originalEvent:O};d.current=!0,i.current=r&&O.button===0,h.current.clear(),!r||O.button!==0?N():(n.removeEventListener("click",m.current),m.current=N,n.addEventListener("click",m.current,{once:!0}))}else n.removeEventListener("click",m.current),p();u.current=!1},"handlePointerDown"),_=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const O of _)n.addEventListener(O,w,!0),n.addEventListener(O,x);const k=window.setTimeout(()=>{n.addEventListener("pointerdown",E)},0);return()=>{window.clearTimeout(k),n.removeEventListener("pointerdown",E),n.removeEventListener("click",m.current);for(const O of _)n.removeEventListener(O,w,!0),n.removeEventListener(O,x)}},[n,l,r,i,a,s]),{onPointerDownCapture:qn(()=>u.current=!0,"onPointerDownCapture")}}qn(Gz,"usePointerDownOutside");function Vz(e,t=globalThis==null?void 0:globalThis.document){const n=ty(e),r=b.useRef(!1);return b.useEffect(()=>{const i=qn(a=>{a.target&&!r.current&&OS(cie,n,{originalEvent:a},{discrete:!1})},"handleFocus");return t.addEventListener("focusin",i),()=>t.removeEventListener("focusin",i)},[t,n]),{onFocusCapture:qn(()=>r.current=!0,"onFocusCapture"),onBlurCapture:qn(()=>r.current=!1,"onBlurCapture")}}qn(Vz,"useFocusOutside");function g1(){const e=new CustomEvent(p1);document.dispatchEvent(e)}qn(g1,"dispatchUpdate");function OS(e,t,n,{discrete:r}){const i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?Kz(i,a):i.dispatchEvent(a)}qn(OS,"handleAndDispatchCustomEvent");var hie=Object.defineProperty,NS=(e,t)=>hie(e,"name",{value:t,configurable:!0}),Mp=0,da=null;function mie(e){return CS(),e.children}NS(mie,"FocusGuards");function CS(){b.useEffect(()=>{da||(da={start:v1(),end:v1()});const{start:e,end:t}=da;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),Mp++,()=>{Mp===1&&(da==null||da.start.remove(),da==null||da.end.remove(),da=null),Mp=Math.max(0,Mp-1)}},[])}NS(CS,"useFocusGuards");function v1(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}NS(v1,"createFocusGuard");var pie=Object.defineProperty,gie=(e,t)=>pie(e,"name",{value:t,configurable:!0});function y1(e){const t=b.useRef(e);return b.useEffect(()=>{t.current=e}),b.useMemo(()=>((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)}),[])}gie(y1,"useCallbackRef");var vie=Object.defineProperty,xr=(e,t)=>vie(e,"name",{value:t,configurable:!0}),Hx="focusScope.autoFocusOnMount",Kx="focusScope.autoFocusOnUnmount",KM={bubbles:!1,cancelable:!0},yie=b.forwardRef(xr(function(t,n){const{loop:r=!1,trapped:i=!1,onMountAutoFocus:a,onUnmountAutoFocus:s,...l}=t,[u,d]=b.useState(null),h=y1(a),m=y1(s),p=b.useRef(null),v=od(n,d),w=b.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;b.useEffect(()=>{if(i){let E=function(N){if(w.paused||!u)return;const T=N.target;u.contains(T)?p.current=T:uo(p.current,{select:!0})},_=function(N){if(w.paused||!u)return;const T=N.relatedTarget;T!==null&&(u.contains(T)||uo(p.current,{select:!0}))},k=function(N){if(document.activeElement===document.body)for(const C of N)C.removedNodes.length>0&&uo(u)};xr(E,"handleFocusIn"),xr(_,"handleFocusOut"),xr(k,"handleMutations"),document.addEventListener("focusin",E),document.addEventListener("focusout",_);const O=new MutationObserver(k);return u&&O.observe(u,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",E),document.removeEventListener("focusout",_),O.disconnect()}}},[i,u,w.paused]),b.useEffect(()=>{if(u){qM.add(w);const E=document.activeElement;if(!u.contains(E)){const k=new CustomEvent(Hx,KM);u.addEventListener(Hx,h),u.dispatchEvent(k),k.defaultPrevented||(Wz(Jz(TS(u)),{select:!0}),document.activeElement===E&&uo(u))}return()=>{u.removeEventListener(Hx,h),setTimeout(()=>{const k=new CustomEvent(Kx,KM);u.addEventListener(Kx,m),u.dispatchEvent(k),k.defaultPrevented||uo(E??document.body,{select:!0}),u.removeEventListener(Kx,m),qM.remove(w)},0)}}},[u,h,m,w]);const x=b.useCallback(E=>{if(!r&&!i||w.paused)return;const _=E.key==="Tab"&&!E.altKey&&!E.ctrlKey&&!E.metaKey,k=document.activeElement;if(_&&k){const O=E.currentTarget,[N,T]=Yz(O);N&&T?!E.shiftKey&&k===T?(E.preventDefault(),r&&uo(N,{select:!0})):E.shiftKey&&k===N&&(E.preventDefault(),r&&uo(T,{select:!0})):k===O&&E.preventDefault()}},[r,i,w.paused]);return y.jsx(ey.div,{tabIndex:-1,...l,ref:v,onKeyDown:x})},"FocusScope"));function Wz(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(uo(r,{select:t}),document.activeElement!==n)return}xr(Wz,"focusFirst");function Yz(e){const t=TS(e),n=b1(t,e),r=b1(t.reverse(),e);return[n,r]}xr(Yz,"getTabbableEdges");function TS(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:xr(r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;n.nextNode();)t.push(n.currentNode);return t}xr(TS,"getTabbableCandidates");function b1(e,t){const n=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):Xz(r,{upTo:t})))return r}xr(b1,"findVisible");function Xz(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}xr(Xz,"isHidden");function Zz(e){return e instanceof HTMLInputElement&&"select"in e}xr(Zz,"isSelectableInput");function uo(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Zz(e)&&t&&e.select()}}xr(uo,"focus");var qM=Qz();function Qz(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=x1(e,t),e.unshift(t)},remove(t){var n;e=x1(e,t),(n=e[0])==null||n.resume()}}}xr(Qz,"createFocusScopesStack");function x1(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}xr(x1,"arrayRemove");function Jz(e){return e.filter(t=>t.tagName!=="A")}xr(Jz,"removeLinks");var bie=globalThis!=null&&globalThis.document?b.useLayoutEffect:()=>{},xie=Object.defineProperty,wie=(e,t)=>xie(e,"name",{value:t,configurable:!0}),Eie=ja[" useId ".trim().toString()]||(()=>{}),Sie=0;function e$(e){const[t,n]=b.useState(Eie());return bie(()=>{e||n(r=>r??String(Sie++))},[e]),e||(t?`radix-${t}`:"")}wie(e$,"useId");const _ie=["top","right","bottom","left"],Fs=Math.min,xo=Math.max,jg=Math.round,Ip=Math.floor,wo=e=>({x:e,y:e}),Aie={left:"right",right:"left",bottom:"top",top:"bottom"};function t$(e,t,n){return xo(e,Fs(t,n))}function Co(e,t){return typeof e=="function"?e(t):e}function Hs(e){return e.split("-")[0]}function sd(e){return e.split("-")[1]}function MS(e){return e==="x"?"y":"x"}function IS(e){return e==="y"?"height":"width"}function wa(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function RS(e){return MS(wa(e))}function kie(e,t,n){n===void 0&&(n=!1);const r=sd(e),i=RS(e),a=IS(i);let s=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(s=Lg(s)),[s,Lg(s)]}function Oie(e){const t=Lg(e);return[w1(e),t,w1(t)]}function w1(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const GM=["left","right"],VM=["right","left"],Nie=["top","bottom"],Cie=["bottom","top"];function Tie(e,t,n){switch(e){case"top":case"bottom":return n?t?VM:GM:t?GM:VM;case"left":case"right":return t?Nie:Cie;default:return[]}}function Mie(e,t,n,r){const i=sd(e);let a=Tie(Hs(e),n==="start",r);return i&&(a=a.map(s=>s+"-"+i),t&&(a=a.concat(a.map(w1)))),a}function Lg(e){const t=Hs(e);return Aie[t]+e.slice(t.length)}function Iie(e){var t,n,r,i;return{top:(t=e.top)!=null?t:0,right:(n=e.right)!=null?n:0,bottom:(r=e.bottom)!=null?r:0,left:(i=e.left)!=null?i:0}}function n$(e){return typeof e!="number"?Iie(e):{top:e,right:e,bottom:e,left:e}}function zg(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function WM(e,t,n){let{reference:r,floating:i}=e;const a=wa(t),s=RS(t),l=IS(s),u=Hs(t),d=a==="y",h=r.x+r.width/2-i.width/2,m=r.y+r.height/2-i.height/2,p=r[l]/2-i[l]/2;let v;switch(u){case"top":v={x:h,y:r.y-i.height};break;case"bottom":v={x:h,y:r.y+r.height};break;case"right":v={x:r.x+r.width,y:m};break;case"left":v={x:r.x-i.width,y:m};break;default:v={x:r.x,y:r.y}}const w=sd(t);return w&&(v[s]+=p*(w==="end"?1:-1)*(n&&d?-1:1)),v}async function Rie(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:a,rects:s,elements:l,strategy:u}=e,{boundary:d="clippingAncestors",rootBoundary:h="viewport",elementContext:m="floating",altBoundary:p=!1,padding:v=0}=Co(t,e),w=n$(v),E=l[p?m==="floating"?"reference":"floating":m],_=zg(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(E)))==null||n?E:E.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(l.floating)),boundary:d,rootBoundary:h,strategy:u})),k=m==="floating"?{x:r,y:i,width:s.floating.width,height:s.floating.height}:s.reference,O=await(a.getOffsetParent==null?void 0:a.getOffsetParent(l.floating)),N=await(a.isElement==null?void 0:a.isElement(O))&&await(a.getScale==null?void 0:a.getScale(O))||{x:1,y:1},T=zg(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:k,offsetParent:O,strategy:u}):k);return{top:(_.top-T.top+w.top)/N.y,bottom:(T.bottom-_.bottom+w.bottom)/N.y,left:(_.left-T.left+w.left)/N.x,right:(T.right-_.right+w.right)/N.x}}const Pie=50,Die=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:a=[],platform:s}=n,l=s.detectOverflow?s:{...s,detectOverflow:Rie},u=await(s.isRTL==null?void 0:s.isRTL(t));let d=await s.getElementRects({reference:e,floating:t,strategy:i}),{x:h,y:m}=WM(d,r,u),p=r,v=0;const w={};for(let x=0;x<a.length;x++){const E=a[x];if(!E)continue;const{name:_,fn:k}=E,{x:O,y:N,data:T,reset:C}=await k({x:h,y:m,initialPlacement:r,placement:p,strategy:i,middlewareData:w,rects:d,platform:l,elements:{reference:e,floating:t}});h=O??h,m=N??m,w[_]={...w[_],...T},C&&v<Pie&&(v++,typeof C=="object"&&(C.placement&&(p=C.placement),C.rects&&(d=C.rects===!0?await s.getElementRects({reference:e,floating:t,strategy:i}):C.rects),{x:h,y:m}=WM(d,p,u)),x=-1)}return{x:h,y:m,placement:p,strategy:i,middlewareData:w}},jie=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:a,platform:s,elements:l,middlewareData:u}=t,{element:d,padding:h=0}=Co(e,t)||{};if(d==null)return{};const m=n$(h),p={x:n,y:r},v=RS(i),w=IS(v),x=await s.getDimensions(d),E=v==="y",_=E?"top":"left",k=E?"bottom":"right",O=E?"clientHeight":"clientWidth",N=a.reference[w]+a.reference[v]-p[v]-a.floating[w],T=p[v]-a.reference[v],C=await(s.getOffsetParent==null?void 0:s.getOffsetParent(d));let M=C?C[O]:0;(!M||!await(s.isElement==null?void 0:s.isElement(C)))&&(M=l.floating[O]||a.floating[w]);const D=N/2-T/2,L=M/2-x[w]/2-1,R=Fs(m[_],L),H=Fs(m[k],L),P=M-x[w]-H,q=M/2-x[w]/2+D,K=t$(R,q,P),X=!u.arrow&&sd(i)!=null&&q!==K&&a.reference[w]/2-(q<R?R:H)-x[w]/2<0,F=X?q<R?q-R:q-P:0;return{[v]:p[v]+F,data:{[v]:K,centerOffset:q-K-F,...X&&{alignmentOffset:F}},reset:X}}}),Lie=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:a,rects:s,initialPlacement:l,platform:u,elements:d}=t,{mainAxis:h=!0,crossAxis:m=!0,fallbackPlacements:p,fallbackStrategy:v="bestFit",fallbackAxisSideDirection:w="none",flipAlignment:x=!0,...E}=Co(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const _=Hs(i),k=wa(l),O=Hs(l)===l,N=await(u.isRTL==null?void 0:u.isRTL(d.floating)),T=p||(O||!x?[Lg(l)]:Oie(l)),C=w!=="none";!p&&C&&T.push(...Mie(l,x,w,N));const M=[l,...T],D=await u.detectOverflow(t,E),L=[];let R=((r=a.flip)==null?void 0:r.overflows)||[];if(h&&L.push(D[_]),m){const K=kie(i,s,N);L.push(D[K[0]],D[K[1]])}if(R=[...R,{placement:i,overflows:L}],!L.every(K=>K<=0)){var H,P;const K=(((H=a.flip)==null?void 0:H.index)||0)+1,X=M[K];if(X&&(!(m==="alignment"?k!==wa(X):!1)||R.every(U=>wa(U.placement)===k?U.overflows[0]>0:!0)))return{data:{index:K,overflows:R},reset:{placement:X}};let F=(P=R.filter(Y=>Y.overflows[0]<=0).sort((Y,U)=>Y.overflows[1]-U.overflows[1])[0])==null?void 0:P.placement;if(!F)switch(v){case"bestFit":{var q;const Y=(q=R.filter(U=>{if(C){const G=wa(U.placement);return G===k||G==="y"}return!0}).map(U=>[U.placement,U.overflows.filter(G=>G>0).reduce((G,$)=>G+$,0)]).sort((U,G)=>U[1]-G[1])[0])==null?void 0:q[0];Y&&(F=Y);break}case"initialPlacement":F=l;break}if(i!==F)return{reset:{placement:F}}}return{}}}};function YM(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function XM(e){return _ie.some(t=>e[t]>=0)}const zie=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:i="referenceHidden",...a}=Co(e,t);switch(i){case"referenceHidden":{const s=await r.detectOverflow(t,{...a,elementContext:"reference"}),l=YM(s,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:XM(l)}}}case"escaped":{const s=await r.detectOverflow(t,{...a,altBoundary:!0}),l=YM(s,n.floating);return{data:{escapedOffsets:l,escaped:XM(l)}}}default:return{}}}}},r$=new Set(["left","top"]);async function $ie(e,t){const{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),s=Hs(n),l=sd(n),u=wa(n)==="y",d=r$.has(s)?-1:1,h=a&&u?-1:1,m=Co(t,e);let{mainAxis:p,crossAxis:v,alignmentAxis:w}=typeof m=="number"?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return l&&typeof w=="number"&&(v=l==="end"?w*-1:w),u?{x:v*h,y:p*d}:{x:p*d,y:v*h}}const Bie=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:a,placement:s,middlewareData:l}=t,u=await $ie(t,e);return s===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:i+u.x,y:a+u.y,data:{...u,placement:s}}}}},Uie=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i,platform:a}=t,{mainAxis:s=!0,crossAxis:l=!1,limiter:u={fn:k=>{let{x:O,y:N}=k;return{x:O,y:N}}},...d}=Co(e,t),h={x:n,y:r},m=await a.detectOverflow(t,d),p=wa(i),v=MS(p);let w=h[v],x=h[p];const E=(k,O)=>t$(O+m[k==="y"?"top":"left"],O,O-m[k==="y"?"bottom":"right"]);s&&(w=E(v,w)),l&&(x=E(p,x));const _=u.fn({...t,[v]:w,[p]:x});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[v]:s,[p]:l}}}}}},Fie=function(e){return e===void 0&&(e={}),{options:e,fn(t){var n,r;const{x:i,y:a,placement:s,rects:l,middlewareData:u}=t,{offset:d=0,mainAxis:h=!0,crossAxis:m=!0}=Co(e,t),p={x:i,y:a},v=wa(s),w=MS(v);let x=p[w],E=p[v];const _=Co(d,t),k=typeof _=="number"?{mainAxis:_,crossAxis:0}:{mainAxis:(n=_.mainAxis)!=null?n:0,crossAxis:(r=_.crossAxis)!=null?r:0};if(h){const T=w==="y"?"height":"width",C=l.reference[w]-l.floating[T]+k.mainAxis,M=l.reference[w]+l.reference[T]-k.mainAxis;x<C?x=C:x>M&&(x=M)}if(m){var O,N;const T=w==="y"?"width":"height",C=r$.has(Hs(s)),M=l.reference[v]-l.floating[T]+(C&&((O=u.offset)==null?void 0:O[v])||0)+(C?0:k.crossAxis),D=l.reference[v]+l.reference[T]+(C?0:((N=u.offset)==null?void 0:N[v])||0)-(C?k.crossAxis:0);E<M?E=M:E>D&&(E=D)}return{[w]:x,[v]:E}}}},Hie=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:n,rects:r,platform:i,elements:a}=t,{apply:s=()=>{},...l}=Co(e,t),u=await i.detectOverflow(t,l),d=Hs(n),h=sd(n),m=wa(n)==="y",{width:p,height:v}=r.floating;let w,x;d==="top"||d==="bottom"?(w=d,x=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(x=d,w=h==="end"?"top":"bottom");const E=v-u.top-u.bottom,_=p-u.left-u.right,k=Fs(v-u[w],E),O=Fs(p-u[x],_),N=t.middlewareData.shift,T=!N;let C=k,M=O;N!=null&&N.enabled.x&&(M=_),N!=null&&N.enabled.y&&(C=E),T&&!h&&(m?M=p-2*xo(u.left,u.right):C=v-2*xo(u.top,u.bottom)),await s({...t,availableWidth:M,availableHeight:C});const D=await i.getDimensions(a.floating);return p!==D.width||v!==D.height?{reset:{rects:!0}}:{}}}};function ny(){return typeof window<"u"}function ld(e){return i$(e)?(e.nodeName||"").toLowerCase():"#document"}function Ur(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function jo(e){var t;return(t=(i$(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function i$(e){return ny()?e instanceof Node||e instanceof Ur(e).Node:!1}function Ca(e){return ny()?e instanceof Element||e instanceof Ur(e).Element:!1}function Js(e){return ny()?e instanceof HTMLElement||e instanceof Ur(e).HTMLElement:!1}function ZM(e){return!ny()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ur(e).ShadowRoot}function ry(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=Ta(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function Kie(e){return/^(table|td|th)$/.test(ld(e))}function iy(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const qie=/transform|translate|scale|rotate|perspective|filter/,Gie=/paint|layout|strict|content/,Al=e=>!!e&&e!=="none";let qx;function PS(e){const t=Ca(e)?Ta(e):e;return Al(t.transform)||Al(t.translate)||Al(t.scale)||Al(t.rotate)||Al(t.perspective)||!DS()&&(Al(t.backdropFilter)||Al(t.filter))||qie.test(t.willChange||"")||Gie.test(t.contain||"")}function Vie(e){let t=ec(e);for(;Js(t)&&!rh(t);){if(PS(t))return t;if(iy(t))return null;t=ec(t)}return null}function DS(){return qx==null&&(qx=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),qx}function rh(e){return/^(html|body|#document)$/.test(ld(e))}function Ta(e){return Ur(e).getComputedStyle(e)}function ay(e){return Ca(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ec(e){if(ld(e)==="html")return e;const t=e.assignedSlot||e.parentNode||ZM(e)&&e.host||jo(e);return ZM(t)?t.host:t}function a$(e){const t=ec(e);return rh(t)?(e.ownerDocument||e).body:Js(t)&&ry(t)?t:a$(t)}function ih(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=a$(e),a=i===((r=e.ownerDocument)==null?void 0:r.body),s=Ur(i);if(a){const l=E1(s);return t.concat(s,s.visualViewport||[],ry(i)?i:[],l&&n?ih(l):[])}else return t.concat(i,ih(i,[],n))}function E1(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function o$(e){const t=Ta(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=Js(e),a=i?e.offsetWidth:n,s=i?e.offsetHeight:r,l=jg(n)!==a||jg(r)!==s;return l&&(n=a,r=s),{width:n,height:r,$:l}}function jS(e){return Ca(e)?e:e.contextElement}function Mu(e){const t=jS(e);if(!Js(t))return wo(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:a}=o$(t);let s=(a?jg(n.width):n.width)/r,l=(a?jg(n.height):n.height)/i;return(!s||!Number.isFinite(s))&&(s=1),(!l||!Number.isFinite(l))&&(l=1),{x:s,y:l}}const Wie=wo(0);function s$(e){const t=Ur(e);return!DS()||!t.visualViewport?Wie:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Yie(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===Ur(e)}function tc(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),a=jS(e);let s=wo(1);t&&(r?Ca(r)&&(s=Mu(r)):s=Mu(e));const l=Yie(a,n,r)?s$(a):wo(0);let u=(i.left+l.x)/s.x,d=(i.top+l.y)/s.y,h=i.width/s.x,m=i.height/s.y;if(a&&r){const p=Ur(a),v=Ca(r)?Ur(r):r;let w=p,x=E1(w);for(;x&&v!==w;){const E=Mu(x),_=x.getBoundingClientRect(),k=Ta(x),O=_.left+(x.clientLeft+parseFloat(k.paddingLeft))*E.x,N=_.top+(x.clientTop+parseFloat(k.paddingTop))*E.y;u*=E.x,d*=E.y,h*=E.x,m*=E.y,u+=O,d+=N,w=Ur(x),x=E1(w)}}return zg({width:h,height:m,x:u,y:d})}function oy(e,t){const n=ay(e).scrollLeft;return t?t.left+n:tc(jo(e)).left+n}function l$(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-oy(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function Xie(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const a=i==="fixed",s=jo(r),l=t?iy(t.floating):!1;if(r===s||l&&a)return n;let u={scrollLeft:0,scrollTop:0},d=wo(1);const h=wo(0),m=Js(r);if((m||!a)&&((ld(r)!=="body"||ry(s))&&(u=ay(r)),m)){const v=tc(r);d=Mu(r),h.x=v.x+r.clientLeft,h.y=v.y+r.clientTop}const p=s&&!m&&!a?l$(s,u):wo(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-u.scrollLeft*d.x+h.x+p.x,y:n.y*d.y-u.scrollTop*d.y+h.y+p.y}}function Zie(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function Qie(e){const t=ay(e),n=e.ownerDocument.body,r=xo(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=xo(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let a=-t.scrollLeft+oy(e);const s=-t.scrollTop;return Ta(n).direction==="rtl"&&(a+=xo(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:s}}const Jie=25;function eae(e,t,n){n===void 0&&(n="viewport");const r=n==="layoutViewport",i=Ur(e),a=jo(e),s=i.visualViewport;let l=a.clientWidth,u=a.clientHeight,d=0,h=0;if(s){const p=!DS()||t==="fixed";r?p||(d=-s.offsetLeft,h=-s.offsetTop):(l=s.width,u=s.height,p&&(d=s.offsetLeft,h=s.offsetTop))}if(oy(a)<=0){const p=a.ownerDocument,v=p.body,w=getComputedStyle(v),x=p.compatMode==="CSS1Compat"&&parseFloat(w.marginLeft)+parseFloat(w.marginRight)||0,E=Math.abs(a.clientWidth-v.clientWidth-x),_=getComputedStyle(a).scrollbarGutter==="stable both-edges"?E/2:E;_<=Jie&&(l-=_)}return{width:l,height:u,x:d,y:h}}function tae(e,t){const n=tc(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Mu(e),s=e.clientWidth*a.x,l=e.clientHeight*a.y,u=i*a.x,d=r*a.y;return{width:s,height:l,x:u,y:d}}function QM(e,t,n){let r;if(t==="viewport"||t==="layoutViewport")r=eae(e,n,t);else if(t==="document")r=Qie(jo(e));else if(Ca(t))r=tae(t,n);else{const i=s$(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return zg(r)}function nae(e,t){const n=t.get(e);if(n)return n;let r=ih(e,[],!1).filter(l=>Ca(l)&&ld(l)!=="body"),i=null;const a=Ta(e).position==="fixed";let s=a?ec(e):e;for(;Ca(s)&&!rh(s);){const l=Ta(s),u=PS(s),d=i?i.position:a?"fixed":"";!u&&(d==="fixed"||d==="absolute"&&l.position==="static")?r=r.filter(m=>m!==s):i=l,s=ec(s)}return t.set(e,r),r}function rae(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const s=[...n==="clippingAncestors"?iy(t)?[]:nae(t,this._c):[].concat(n),r],l=QM(t,s[0],i);let u=l.top,d=l.right,h=l.bottom,m=l.left;for(let p=1;p<s.length;p++){const v=QM(t,s[p],i);u=xo(v.top,u),d=Fs(v.right,d),h=Fs(v.bottom,h),m=xo(v.left,m)}return{width:d-m,height:h-u,x:m,y:u}}function iae(e){const{width:t,height:n}=o$(e);return{width:t,height:n}}function aae(e,t,n){const r=Js(t),i=jo(t),a=n==="fixed",s=tc(e,!0,a,t);let l={scrollLeft:0,scrollTop:0};const u=wo(0);if((r||!a)&&((ld(t)!=="body"||ry(i))&&(l=ay(t)),r)){const p=tc(t,!0,a,t);u.x=p.x+t.clientLeft,u.y=p.y+t.clientTop}!r&&i&&(u.x=oy(i));const d=i&&!r&&!a?l$(i,l):wo(0),h=s.left+l.scrollLeft-u.x-d.x,m=s.top+l.scrollTop-u.y-d.y;return{x:h,y:m,width:s.width,height:s.height}}function Gx(e){return Ta(e).position==="static"}function JM(e,t){if(!Js(e)||Ta(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return jo(e)===n&&(n=n.ownerDocument.body),n}function c$(e,t){const n=Ur(e);if(iy(e))return n;if(!Js(e)){let i=ec(e);for(;i&&!rh(i);){if(Ca(i)&&!Gx(i))return i;i=ec(i)}return n}let r=JM(e,t);for(;r&&Kie(r)&&Gx(r);)r=JM(r,t);return r&&rh(r)&&Gx(r)&&!PS(r)?n:r||Vie(e)||n}const oae=async function(e){const t=this.getOffsetParent||c$,n=this.getDimensions,r=await n(e.floating);return{reference:aae(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function sae(e){return Ta(e).direction==="rtl"}const lae={convertOffsetParentRelativeRectToViewportRelativeRect:Xie,getDocumentElement:jo,getClippingRect:rae,getOffsetParent:c$,getElementRects:oae,getClientRects:Zie,getDimensions:iae,getScale:Mu,isElement:Ca,isRTL:sae};function u$(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function cae(e,t,n){let r=null,i;const a=jo(e);function s(){var h;clearTimeout(i),(h=r)==null||h.disconnect(),r=null}function l(h,m){h===void 0&&(h=!1),m===void 0&&(m=1),s();const p=e.getBoundingClientRect(),{left:v,top:w,width:x,height:E}=p;if(h||t(),!x||!E)return;const _=Ip(w),k=Ip(a.clientWidth-(v+x)),O=Ip(a.clientHeight-(w+E)),N=Ip(v),C={rootMargin:-_+"px "+-k+"px "+-O+"px "+-N+"px",threshold:xo(0,Fs(1,m))||1};let M=!0;function D(L){const R=L[0].intersectionRatio;if(!u$(p,e.getBoundingClientRect()))return l();if(R!==m){if(!M)return l();R?l(!1,R):i=setTimeout(()=>{l(!1,1e-7)},1e3)}M=!1}try{r=new IntersectionObserver(D,{...C,root:a.ownerDocument})}catch{r=new IntersectionObserver(D,C)}r.observe(e)}const u=Ur(e),d=()=>l(n);return u.addEventListener("resize",d),l(!0),()=>{u.removeEventListener("resize",d),s()}}function uae(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,d=jS(e),h=i||a?[...d?ih(d):[],...t?ih(t):[]]:[];h.forEach(_=>{i&&_.addEventListener("scroll",n),a&&_.addEventListener("resize",n)});const m=d&&l?cae(d,n,a):null;let p=-1,v=null;s&&(v=new ResizeObserver(_=>{let[k]=_;k&&k.target===d&&v&&t&&(v.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var O;(O=v)==null||O.observe(t)})),n()}),d&&!u&&v.observe(d),t&&v.observe(t));let w,x=u?tc(e):null;u&&E();function E(){const _=tc(e);x&&!u$(x,_)&&n(),x=_,w=requestAnimationFrame(E)}return n(),()=>{var _;h.forEach(k=>{i&&k.removeEventListener("scroll",n),a&&k.removeEventListener("resize",n)}),m==null||m(),(_=v)==null||_.disconnect(),v=null,u&&cancelAnimationFrame(w)}}const dae=Bie,fae=Uie,hae=Lie,mae=Hie,pae=zie,eI=jie,gae=Fie,vae=(e,t,n)=>{const r=new Map,i=n??{},a={...lae,...i.platform,_c:r};return Die(e,t,{...i,platform:a})};var yae=typeof document<"u",bae=function(){},sg=yae?b.useLayoutEffect:bae;function $g(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,r,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!$g(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){const a=i[r];if(!(a==="_owner"&&e.$$typeof)&&!$g(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function d$(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function tI(e,t){const n=d$(e);return Math.round(t*n)/n}function Vx(e){const t=b.useRef(e);return sg(()=>{t.current=e}),t}function xae(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:a,floating:s}={},transform:l=!0,whileElementsMounted:u,open:d}=e,[h,m]=b.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,v]=b.useState(r);$g(p,r)||v(r);const[w,x]=b.useState(null),[E,_]=b.useState(null),k=b.useCallback(U=>{U!==C.current&&(C.current=U,x(U))},[]),O=b.useCallback(U=>{U!==M.current&&(M.current=U,_(U))},[]),N=a||w,T=s||E,C=b.useRef(null),M=b.useRef(null),D=b.useRef(h),L=u!=null,R=Vx(u),H=Vx(i),P=Vx(d),q=b.useCallback(()=>{if(!C.current||!M.current)return;const U={placement:t,strategy:n,middleware:p};H.current&&(U.platform=H.current),vae(C.current,M.current,U).then(G=>{const $={...G,isPositioned:P.current!==!1};K.current&&!$g(D.current,$)&&(D.current=$,La.flushSync(()=>{m($)}))})},[p,t,n,H,P]);sg(()=>{d===!1&&D.current.isPositioned&&(D.current.isPositioned=!1,m(U=>({...U,isPositioned:!1})))},[d]);const K=b.useRef(!1);sg(()=>(K.current=!0,()=>{K.current=!1}),[]),sg(()=>{if(N&&(C.current=N),T&&(M.current=T),N&&T){if(R.current)return R.current(N,T,q);q()}},[N,T,q,R,L]);const X=b.useMemo(()=>({reference:C,floating:M,setReference:k,setFloating:O}),[k,O]),F=b.useMemo(()=>({reference:N,floating:T}),[N,T]),Y=b.useMemo(()=>{const U={position:n,left:0,top:0};if(!F.floating)return U;const G=tI(F.floating,h.x),$=tI(F.floating,h.y);return l?{...U,transform:"translate("+G+"px, "+$+"px)",...d$(F.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:G,top:$}},[n,l,F.floating,h.x,h.y]);return b.useMemo(()=>({...h,update:q,refs:X,elements:F,floatingStyles:Y}),[h,q,X,F,Y])}const wae=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:i}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?eI({element:r.current,padding:i}).fn(n):{}:r?eI({element:r,padding:i}).fn(n):{}}}},Eae=(e,t)=>{const n=dae(e);return{name:n.name,fn:n.fn,options:[e,t]}},Sae=(e,t)=>{const n=fae(e);return{name:n.name,fn:n.fn,options:[e,t]}},_ae=(e,t)=>({fn:gae(e).fn,options:[e,t]}),Aae=(e,t)=>{const n=hae(e);return{name:n.name,fn:n.fn,options:[e,t]}},kae=(e,t)=>{const n=mae(e);return{name:n.name,fn:n.fn,options:[e,t]}},Oae=(e,t)=>{const n=pae(e);return{name:n.name,fn:n.fn,options:[e,t]}},Nae=(e,t)=>{const n=wae(e);return{name:n.name,fn:n.fn,options:[e,t]}};var Cae=Object.defineProperty,LS=(e,t)=>Cae(e,"name",{value:t,configurable:!0});function S1(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}LS(S1,"setRef");function f$(...e){return t=>{let n=!1;const r=e.map(i=>{const a=S1(i,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let i=0;i<r.length;i++){const a=r[i];typeof a=="function"?a():S1(e[i],null)}}}}LS(f$,"composeRefs");function sy(...e){return b.useCallback(f$(...e),e)}LS(sy,"useComposedRefs");var Tae=Object.defineProperty,Ci=(e,t)=>Tae(e,"name",{value:t,configurable:!0});function Mae(e,t){const n=b.createContext(t);n.displayName=e+"Context";const r=Ci(a=>{const{children:s,...l}=a,u=b.useMemo(()=>l,Object.values(l));return y.jsx(n.Provider,{value:u,children:s})},"Provider");r.displayName=e+"Provider";function i(a,s={}){const{optional:l=!1}=s,u=b.useContext(n);if(u)return u;if(t!==void 0)return t;if(!l)throw new Error(`\`${a}\` must be used within \`${e}\``)}return Ci(i,"useContext"),[r,i]}Ci(Mae,"createContext");function h$(e,t=[]){let n=[];function r(a,s){const l=b.createContext(s);l.displayName=a+"Context";const u=n.length;n=[...n,s];const d=Ci(m=>{var _;const{scope:p,children:v,...w}=m,x=((_=p==null?void 0:p[e])==null?void 0:_[u])||l,E=b.useMemo(()=>w,Object.values(w));return y.jsx(x.Provider,{value:E,children:v})},"Provider");d.displayName=a+"Provider";function h(m,p,v={}){var _;const{optional:w=!1}=v,x=((_=p==null?void 0:p[e])==null?void 0:_[u])||l,E=b.useContext(x);if(E)return E;if(s!==void 0)return s;if(!w)throw new Error(`\`${m}\` must be used within \`${a}\``)}return Ci(h,"useContext"),[d,h]}Ci(r,"createContext");const i=Ci(()=>{const a=n.map(s=>b.createContext(s));return Ci(function(l){const u=(l==null?void 0:l[e])||a;return b.useMemo(()=>({[`__scope${e}`]:{...l,[e]:u}}),[l,u])},"useScope")},"createScope");return i.scopeName=e,[r,m$(i,...t)]}Ci(h$,"createContextScope");function m$(...e){const t=e[0];if(e.length===1)return t;const n=Ci(()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return Ci(function(a){const s=r.reduce((l,{useScope:u,scopeName:d})=>{const m=u(a)[`__scope${d}`];return{...l,...m}},{});return b.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])},"useComposedScopes")},"createScope");return n.scopeName=t.scopeName,n}Ci(m$,"composeContextScopes");var Iae=Object.defineProperty,ta=(e,t)=>Iae(e,"name",{value:t,configurable:!0});function p$(e){const t=b.forwardRef((n,r)=>{let{children:i,...a}=n,s=null,l=!1;const u=[];_1(i)&&typeof Rp=="function"&&(i=Rp(i._payload)),b.Children.forEach(i,p=>{var v;if(b$(p)){l=!0;const w=p;let x="child"in w.props?w.props.child:w.props.children;_1(x)&&typeof Rp=="function"&&(x=Rp(x._payload)),s=Pae(w,x),u.push((v=s==null?void 0:s.props)==null?void 0:v.children)}else u.push(p)}),s?s=b.cloneElement(s,void 0,u):!l&&b.Children.count(i)===1&&b.isValidElement(i)&&(s=i);const d=s?y$(s):void 0,h=sy(r,d);if(!s){if(i||i===0)throw new Error(l?Lae(e):jae(e));return i}const m=v$(a,s.props??{});return s.type!==b.Fragment&&(m.ref=r?h:d),b.cloneElement(s,m)});return t.displayName=`${e}.Slot`,t}ta(p$,"createSlot");var g$=Symbol.for("radix.slottable");function Rae(e){const t=ta(n=>"child"in n?n.children(n.child):n.children,"Slottable");return t.displayName=`${e}.Slottable`,t.__radixId=g$,t}ta(Rae,"createSlottable");var Pae=ta((e,t)=>{if("child"in e.props){const n=e.props.child;return b.isValidElement(n)?b.cloneElement(n,void 0,e.props.children(n.props.children)):null}return b.isValidElement(t)?t:null},"getSlottableElementFromSlottable");function v$(e,t){const n={...t};for(const r in t){const i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...l)=>{const u=a(...l);return i(...l),u}:i&&(n[r]=i):r==="style"?n[r]={...i,...a}:r==="className"&&(n[r]=[i,a].filter(Boolean).join(" "))}return{...e,...n}}ta(v$,"mergeProps");function y$(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}ta(y$,"getElementRef");function b$(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===g$}ta(b$,"isSlottable");var Dae=Symbol.for("react.lazy");function _1(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Dae&&"_payload"in e&&x$(e._payload)}ta(_1,"isLazyComponent");function x$(e){return typeof e=="object"&&e!==null&&"then"in e}ta(x$,"isPromiseLike");var jae=ta(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),Lae=ta(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),Rp=ja[" use ".trim().toString()],zae=Object.defineProperty,$ae=(e,t)=>zae(e,"name",{value:t,configurable:!0}),Bae=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],w$=Bae.reduce((e,t)=>{const n=p$(`Primitive.${t}`),r=b.forwardRef((i,a)=>{const{asChild:s,...l}=i,u=s?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),y.jsx(u,{...l,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Uae(e,t){e&&La.flushSync(()=>e.dispatchEvent(t))}$ae(Uae,"dispatchDiscreteCustomEvent");var Fae=Object.defineProperty,Hae=(e,t)=>Fae(e,"name",{value:t,configurable:!0});function E$(e){const t=b.useRef(e);return b.useEffect(()=>{t.current=e}),b.useMemo(()=>((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)}),[])}Hae(E$,"useCallbackRef");var Wx=globalThis!=null&&globalThis.document?b.useLayoutEffect:()=>{},Kae=globalThis!=null&&globalThis.document?b.useLayoutEffect:()=>{},qae=Object.defineProperty,Gae=(e,t)=>qae(e,"name",{value:t,configurable:!0});function S$(e){const[t,n]=b.useState(void 0);return Kae(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const a=i[0];let s,l;if("borderBoxSize"in a){const u=a.borderBoxSize,d=Array.isArray(u)?u[0]:u;s=d.inlineSize,l=d.blockSize}else s=e.offsetWidth,l=e.offsetHeight;n({width:s,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}Gae(S$,"useSize");var Vae=Object.defineProperty,js=(e,t)=>Vae(e,"name",{value:t,configurable:!0}),_$="Popper",[A$,k$]=h$(_$),[Wae,O$]=A$(_$),Yae=js(e=>{const{__scopePopper:t,children:n}=e,[r,i]=b.useState(null),[a,s]=b.useState(void 0);return y.jsx(Wae,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:s,children:n})},"Popper"),Xae="PopperAnchor",Zae=b.forwardRef(js(function(t,n){const{__scopePopper:r,virtualRef:i,...a}=t,s=O$(Xae,r),l=b.useRef(null),u=s.onAnchorChange,d=b.useCallback(x=>{l.current=x,x&&u(x)},[u]),h=sy(n,d),m=b.useRef(null);b.useEffect(()=>{if(!i)return;const x=m.current;m.current=i.current,x!==m.current&&u(m.current)});const p=s.placementState&&ly(s.placementState),v=p==null?void 0:p[0],w=p==null?void 0:p[1];return i?null:y.jsx(w$.div,{"data-radix-popper-side":v,"data-radix-popper-align":w,...a,ref:h})},"PopperAnchor")),N$="PopperContent",[Qae,dCe]=A$(N$),Jae=b.forwardRef(js(function(t,n){var fe,Ee,Te,de,nt,He,Ae;const{__scopePopper:r,side:i="bottom",sideOffset:a=0,align:s="center",alignOffset:l=0,arrowPadding:u=0,avoidCollisions:d=!0,collisionBoundary:h=[],collisionPadding:m=0,sticky:p="partial",hideWhenDetached:v=!1,updatePositionStrategy:w="optimized",onPlaced:x,...E}=t,_=O$(N$,r),[k,O]=b.useState(null),N=sy(n,O),[T,C]=b.useState(null),M=S$(T),D=(M==null?void 0:M.width)??0,L=(M==null?void 0:M.height)??0,R=i+(s!=="center"?"-"+s:""),H=typeof m=="number"?m:{top:0,right:0,bottom:0,left:0,...m},P=Array.isArray(h)?h:[h],q=P.length>0,K={padding:H,boundary:P.filter(C$),altBoundary:q},{refs:X,floatingStyles:F,placement:Y,isPositioned:U,middlewareData:G}=xae({strategy:"fixed",placement:R,whileElementsMounted:js((...De)=>uae(...De,{animationFrame:w==="always"}),"whileElementsMounted"),elements:{reference:_.anchor},middleware:[Eae({mainAxis:a+L,alignmentAxis:l}),d&&Sae({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?_ae():void 0,...K}),d&&Aae({...K}),kae({...K,apply:js(({elements:De,rects:Ht,availableWidth:un,availableHeight:Yn})=>{const{width:Or,height:Li}=Ht.reference,ir=De.floating.style;ir.setProperty("--radix-popper-available-width",`${un}px`),ir.setProperty("--radix-popper-available-height",`${Yn}px`),ir.setProperty("--radix-popper-anchor-width",`${Or}px`),ir.setProperty("--radix-popper-anchor-height",`${Li}px`)},"apply")}),T&&Nae({element:T,padding:u}),eoe({arrowWidth:D,arrowHeight:L}),v&&Oae({strategy:"referenceHidden",...K,boundary:q?K.boundary:void 0})]}),$=_.setPlacementState;Wx(()=>($(Y),()=>{$(void 0)}),[Y,$]);const[j,V]=ly(Y),z=E$(x);Wx(()=>{U&&(z==null||z())},[U,z]);const ie=(fe=G.arrow)==null?void 0:fe.x,he=(Ee=G.arrow)==null?void 0:Ee.y,ge=((Te=G.arrow)==null?void 0:Te.centerOffset)!==0,[Se,$e]=b.useState();return Wx(()=>{k&&$e(window.getComputedStyle(k).zIndex)},[k]),y.jsx("div",{ref:X.setFloating,"data-radix-popper-content-wrapper":"",style:{...F,transform:U?F.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Se,"--radix-popper-transform-origin":[(de=G.transformOrigin)==null?void 0:de.x,(nt=G.transformOrigin)==null?void 0:nt.y].join(" "),...((He=G.hide)==null?void 0:He.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:y.jsx(Qae,{scope:r,placedSide:j,placedAlign:V,onArrowChange:C,arrowX:ie,arrowY:he,shouldHideArrow:ge,children:y.jsx(w$.div,{"data-side":j,"data-align":V,...E,ref:N,style:{...E.style,animation:U?(Ae=E.style)==null?void 0:Ae.animation:"none"}})})})},"PopperContent"));function C$(e){return e!==null}js(C$,"isNotNull");var eoe=js(e=>({name:"transformOrigin",options:e,fn(t){var E,_,k;const{placement:n,rects:r,middlewareData:i}=t,s=((E=i.arrow)==null?void 0:E.centerOffset)!==0,l=s?0:e.arrowWidth,u=s?0:e.arrowHeight,[d,h]=ly(n),m={start:"0%",center:"50%",end:"100%"}[h],p=(((_=i.arrow)==null?void 0:_.x)??0)+l/2,v=(((k=i.arrow)==null?void 0:k.y)??0)+u/2;let w="",x="";return d==="bottom"?(w=s?m:`${p}px`,x=`${-u}px`):d==="top"?(w=s?m:`${p}px`,x=`${r.floating.height+u}px`):d==="right"?(w=`${-u}px`,x=s?m:`${v}px`):d==="left"&&(w=`${r.floating.width+u}px`,x=s?m:`${v}px`),{data:{x:w,y:x}}}}),"transformOrigin");function ly(e){const[t,n="center"]=e.split("-");return[t,n]}js(ly,"getSideAndAlignFromPlacement");var toe=Yae,noe=Zae,roe=Jae,ioe=globalThis!=null&&globalThis.document?b.useLayoutEffect:()=>{},aoe=Object.defineProperty,ooe=(e,t)=>aoe(e,"name",{value:t,configurable:!0}),soe=b.forwardRef(ooe(function(t,n){var u;const{container:r,...i}=t,[a,s]=b.useState(!1);ioe(()=>s(!0),[]);const l=r||a&&((u=globalThis==null?void 0:globalThis.document)==null?void 0:u.body);return l?La.createPortal(y.jsx(ey.div,{...i,ref:n}),l):null},"Portal")),nI=globalThis!=null&&globalThis.document?b.useLayoutEffect:()=>{},loe=Object.defineProperty,To=(e,t)=>loe(e,"name",{value:t,configurable:!0});function T$(e,t){return b.useReducer((n,r)=>t[n][r]??n,e)}To(T$,"useStateMachine");var M$=To(e=>{const{present:t,children:n}=e,r=I$(t),i=typeof n=="function"?n({present:r.isPresent}):b.Children.only(n),a=R$(r.ref,P$(i));return typeof n=="function"||r.isPresent?b.cloneElement(i,{ref:a}):null},"Presence");function I$(e){const[t,n]=b.useState(),r=b.useRef(null),i=b.useRef(e),a=b.useRef("none"),s=b.useRef(void 0),l=e?"mounted":"unmounted",[u,d]=T$(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return b.useEffect(()=>{u==="mounted"?(a.current=s.current??xu(r.current),s.current=void 0):a.current="none"},[u]),nI(()=>{const h=r.current,m=i.current;if(m!==e){const v=a.current,w=xu(h);e?(s.current=w,d("MOUNT")):w==="none"||(h==null?void 0:h.display)==="none"?d("UNMOUNT"):d(m&&v!==w?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,d]),nI(()=>{if(t){let h;const m=t.ownerDocument.defaultView??window,p=To(w=>{const E=xu(r.current).includes(CSS.escape(w.animationName));if(w.target===t&&E&&(d("ANIMATION_END"),!i.current)){const _=t.style.animationFillMode;t.style.animationFillMode="forwards",h=m.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=_)})}},"handleAnimationEnd"),v=To(w=>{w.target===t&&(a.current=xu(r.current))},"handleAnimationStart");return t.addEventListener("animationstart",v),t.addEventListener("animationcancel",p),t.addEventListener("animationend",p),()=>{m.clearTimeout(h),t.removeEventListener("animationstart",v),t.removeEventListener("animationcancel",p),t.removeEventListener("animationend",p)}}else d("ANIMATION_END")},[t,d]),{isPresent:["mounted","unmountSuspended"].includes(u),ref:b.useCallback(h=>{if(h){const m=getComputedStyle(h);r.current=m,s.current=xu(m)}else r.current=null;n(h)},[])}}To(I$,"usePresence");function A1(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}To(A1,"setRef");function R$(...e){const t=b.useRef(e);return t.current=e,b.useCallback(n=>{const r=t.current;let i=!1;const a=r.map(s=>{const l=A1(s,n);return!i&&typeof l=="function"&&(i=!0),l});if(i)return()=>{for(let s=0;s<a.length;s++){const l=a[s];typeof l=="function"?l():A1(r[s],null)}}},[])}To(R$,"useStableComposedRefs");function xu(e){return(e==null?void 0:e.animationName)||"none"}To(xu,"getAnimationName");function P$(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}To(P$,"getElementRef");var D$=globalThis!=null&&globalThis.document?b.useLayoutEffect:()=>{},coe=Object.defineProperty,uoe=(e,t)=>coe(e,"name",{value:t,configurable:!0}),rI=ja[" useEffectEvent ".trim().toString()],iI=ja[" useInsertionEffect ".trim().toString()];function j$(e){if(typeof rI=="function")return rI(e);const t=b.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof iI=="function"?iI(()=>{t.current=e}):D$(()=>{t.current=e}),b.useMemo(()=>((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)}),[])}uoe(j$,"useEffectEvent");var doe=Object.defineProperty,Ch=(e,t)=>doe(e,"name",{value:t,configurable:!0}),foe=ja[" useInsertionEffect ".trim().toString()]||D$;function L$({prop:e,defaultProp:t,onChange:n=Ch(()=>{},"onChange"),caller:r}){const[i,a,s]=z$({defaultProp:t,onChange:n}),l=e!==void 0,u=l?e:i,d=b.useCallback(h=>{var m;if(l){const p=$$(h)?h(e):h;p!==e&&((m=s.current)==null||m.call(s,p))}else a(h)},[l,e,a,s]);return[u,d]}Ch(L$,"useControllableState");function z$({defaultProp:e,onChange:t}){const[n,r]=b.useState(e),i=b.useRef(n),a=b.useRef(t);return foe(()=>{a.current=t},[t]),b.useEffect(()=>{var s;i.current!==n&&((s=a.current)==null||s.call(a,n),i.current=n)},[n,i]),[n,r,a]}Ch(z$,"useUncontrolledState");function $$(e){return typeof e=="function"}Ch($$,"isFunction");var aI=Symbol("RADIX:SYNC_STATE");function hoe(e,t,n,r){const{prop:i,defaultProp:a,onChange:s,caller:l}=t,u=i!==void 0,d=j$(s),h=[{...n,state:a}];r&&h.push(r);const[m,p]=b.useReducer((E,_)=>{if(_.type===aI)return{...E,state:_.state};const k=e(E,_);return u&&!Object.is(k.state,E.state)&&d(k.state),k},...h),v=m.state,w=b.useRef(v);b.useEffect(()=>{w.current!==v&&(w.current=v,u||d(v))},[v,w,u]);const x=b.useMemo(()=>i!==void 0?{...m,state:i}:m,[m,i]);return b.useEffect(()=>{u&&!Object.is(i,m.state)&&p({type:aI,state:i})},[i,m.state,u]),[x,p]}Ch(hoe,"useControllableStateReducer");var moe=Object.defineProperty,el=(e,t)=>moe(e,"name",{value:t,configurable:!0}),zS="Popover",[B$,fCe]=Lz(zS,[k$]),$S=k$(),[poe,cd]=B$(zS),goe=el(e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:s=!1}=e,l=$S(t),u=b.useRef(null),[d,h]=b.useState(!1),[m,p]=L$({prop:r,defaultProp:i??!1,onChange:a,caller:zS});return y.jsx(toe,{...l,children:y.jsx(poe,{scope:t,contentId:e$(),triggerRef:u,open:m,onOpenChange:p,onOpenToggle:b.useCallback(()=>p(v=>!v),[p]),hasCustomAnchor:d,onCustomAnchorAdd:b.useCallback(()=>h(!0),[]),onCustomAnchorRemove:b.useCallback(()=>h(!1),[]),modal:s,children:n})})},"Popover"),voe="PopoverTrigger",yoe=b.forwardRef(el(function(t,n){const{__scopePopover:r,...i}=t,a=cd(voe,r),s=$S(r),l=od(n,a.triggerRef),u=y.jsx(ey.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":BS(a.open),...i,ref:l,onClick:Ds(t.onClick,a.onOpenToggle)});return a.hasCustomAnchor?u:y.jsx(noe,{asChild:!0,...s,children:u})},"PopoverTrigger")),U$="PopoverPortal",[boe,xoe]=B$(U$,{forceMount:void 0}),woe=el(e=>{const{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=cd(U$,t);return y.jsx(boe,{scope:t,forceMount:n,children:y.jsx(M$,{present:n||a.open,children:y.jsx(soe,{asChild:!0,container:i,children:r})})})},"PopoverPortal"),ah="PopoverContent",Eoe=b.forwardRef(el(function(t,n){const r=xoe(ah,t.__scopePopover),{forceMount:i=r.forceMount,...a}=t,s=cd(ah,t.__scopePopover);return y.jsx(M$,{present:i||s.open,children:s.modal?y.jsx(_oe,{...a,ref:n}):y.jsx(Aoe,{...a,ref:n})})},"PopoverContent")),Soe=kS("PopoverContent.RemoveScroll"),_oe=b.forwardRef(el(function(t,n){const r=cd(ah,t.__scopePopover),i=b.useRef(null),a=od(n,i),s=b.useRef(!1);return b.useEffect(()=>{const l=i.current;if(l)return yz(l)},[]),y.jsx(bS,{as:Soe,allowPinchZoom:!0,children:y.jsx(F$,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ds(t.onCloseAutoFocus,l=>{var u;l.preventDefault(),s.current||(u=r.triggerRef.current)==null||u.focus()}),onPointerDownOutside:Ds(t.onPointerDownOutside,l=>{const u=l.detail.originalEvent,d=u.button===0&&u.ctrlKey===!0,h=u.button===2||d;s.current=h},{checkForDefaultPrevented:!1}),onFocusOutside:Ds(t.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1})})})},"PopoverContentModal")),Aoe=b.forwardRef(el(function(t,n){const r=cd(ah,t.__scopePopover),i=b.useRef(!1),a=b.useRef(!1);return y.jsx(F$,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var l,u;(l=t.onCloseAutoFocus)==null||l.call(t,s),s.defaultPrevented||(i.current||(u=r.triggerRef.current)==null||u.focus(),s.preventDefault()),i.current=!1,a.current=!1},onInteractOutside:s=>{var d,h;(d=t.onInteractOutside)==null||d.call(t,s),s.defaultPrevented||(i.current=!0,s.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const l=s.target;((h=r.triggerRef.current)==null?void 0:h.contains(l))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&a.current&&s.preventDefault()}})},"PopoverContentNonModal")),F$=b.forwardRef(el(function(t,n){const{__scopePopover:r,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:s,disableOutsidePointerEvents:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:m,...p}=t,v=cd(ah,r),w=$S(r);return CS(),y.jsx(yie,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:a,onUnmountAutoFocus:s,children:y.jsx(uie,{asChild:!0,disableOutsidePointerEvents:l,onInteractOutside:m,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:h,onDismiss:()=>v.onOpenChange(!1),deferPointerDownOutside:!0,children:y.jsx(roe,{"data-state":BS(v.open),role:"dialog",id:v.contentId,...w,...p,ref:n,style:{...p.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})},"PopoverContentImpl"));function BS(e){return e?"open":"closed"}el(BS,"getState");var koe=goe,Ooe=yoe,Noe=woe,H$=Eoe;const Coe=koe,Toe=Ooe,K$=b.forwardRef(({className:e,align:t="start",side:n="top",sideOffset:r=8,collisionPadding:i=8,...a},s)=>y.jsx(Noe,{children:y.jsx(H$,{ref:s,align:t,side:n,sideOffset:r,collisionPadding:i,className:ze("z-50 w-64 max-w-[calc(100vw-1rem)] rounded-md border bg-card p-3 text-card-foreground shadow-md outline-none","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...a})}));K$.displayName=H$.displayName;const q$=92,G$=96;function Yx(e){if(!Number.isFinite(e)||e<0)return"?";const t=["B","KB","MB","GB","TB","PB"];let n=0;for(;e>=1024&&n<t.length-1;)e/=1024,n++;return`${e<10&&n>0?e.toFixed(1):Math.round(e)} ${t[n]}`}const oI=3e5;function Moe({socket:e,getToken:t}){const[n,r]=b.useState([]);if(b.useEffect(()=>{t().then(a=>a?fetch("/api/stats",{headers:{Authorization:`Bearer ${a}`}}):null).then(a=>a==null?void 0:a.json()).then(a=>(a==null?void 0:a.samples)&&r(a.samples)).catch(a=>console.warn("[MachineStats] seed failed",a))},[t]),b.useEffect(()=>{if(!e)return;const a=e.on(s=>{s.type==="stats"&&r(l=>[...l,s.sample].slice(-120))});return()=>{a()}},[e]),!n.length)return null;const i=n[n.length-1];return y.jsxs("div",{className:"w-full flex flex-wrap items-center justify-center gap-x-2 gap-y-0.5 text-[10px] text-muted-foreground/60",children:[y.jsx(lg,{label:"cpu",value:i.cpu,series:n.map(a=>a.cpu)}),y.jsx(lg,{label:"mem",value:i.mem,series:n.map(a=>a.mem)}),i.disk>=0&&y.jsx(lg,{label:"disk",value:i.disk,severity:zoe(i.disk),title:Boe(i)}),y.jsx(Ioe,{getToken:t})]})}function Ioe({getToken:e}){const[t,n]=b.useState(null);return b.useEffect(()=>{let r=!0,i=0;const a=async()=>{var d;try{const h=await e();if(!h)return;i=Date.now();const m=await fetch("/api/claude-usage",{headers:{Authorization:`Bearer ${h}`}});if(!r)return;if(m.status===204){n(null);return}if(m.status!==200)return;const p=await m.json();if(!r||!((d=p==null?void 0:p.limits)!=null&&d.length))return;n(p)}catch(h){console.warn("[MachineStats] claude usage poll failed",h)}},s=()=>{document.visibilityState==="visible"&&a()},l=()=>{document.visibilityState==="visible"&&Date.now()-i>=oI&&a()};s();const u=setInterval(s,oI);return document.addEventListener("visibilitychange",l),()=>{r=!1,clearInterval(u),document.removeEventListener("visibilitychange",l)}},[e]),y.jsx(V$,{usage:t})}function V$({usage:e,compact:t}){const n=e&&W$(e.limits),[r,i]=b.useState(k1),a=b.useRef(null),s=()=>{a.current&&(clearTimeout(a.current),a.current=null)},l=b.useCallback((u,d=0)=>{if(s(),!d){i(h=>lI(h,u));return}a.current=setTimeout(()=>{a.current=null,i(h=>lI(h,u))},d)},[]);return b.useEffect(()=>s,[]),!e||!n?null:y.jsxs(Coe,{open:r.open,onOpenChange:u=>l(u?{type:"activate"}:{type:"dismiss"}),children:[y.jsx(Toe,{asChild:!0,children:y.jsx("button",{type:"button","aria-label":"claude usage breakdown",className:"cursor-default rounded-sm outline-none focus-visible:ring-1 focus-visible:ring-ring",onPointerEnter:u=>l({type:"pointerenter",pointerType:u.pointerType},Roe),onPointerLeave:u=>l({type:"pointerleave",pointerType:u.pointerType},sI),children:t?y.jsxs("span",{className:ze("tabular-nums",Bg(n.percent,n.severity)),children:[n.percent,"% used"]}):y.jsx(lg,{label:"usage",value:n.percent,severity:n.severity})})}),y.jsx(K$,{onOpenAutoFocus:u=>u.preventDefault(),onPointerEnter:()=>s(),onPointerLeave:u=>l({type:"pointerleave",pointerType:u.pointerType},sI),children:y.jsx(Poe,{usage:e})})]})}const Roe=120,sI=80,k1={open:!1,byHover:!1};function lI(e,t){switch(t.type){case"pointerenter":return cI(t.pointerType)?{open:!0,byHover:!0}:e;case"pointerleave":return cI(t.pointerType)&&e.byHover?k1:e;case"activate":return{open:!0,byHover:!1};case"dismiss":return k1}}const cI=e=>e==="mouse"||e==="";function Poe({usage:e}){const t=W$(e.limits);return y.jsxs("div",{className:"text-[11px] leading-tight",children:[y.jsxs("div",{className:"flex items-baseline justify-between gap-2 pb-2 text-muted-foreground",children:[y.jsx("span",{className:"uppercase tracking-wide",children:"claude usage"}),e.subscriptionType&&y.jsxs("span",{className:"tabular-nums",children:[e.subscriptionType," plan"]})]}),y.jsxs("div",{className:"-mt-1 flex items-baseline justify-between gap-2 pb-2 text-[10px] text-muted-foreground",children:[e.account&&y.jsx("span",{className:"truncate",title:e.account,children:e.account}),y.jsx("span",{className:ze("shrink-0",e.stale&&"text-amber-500"),children:joe(e)})]}),e.stale&&e.error&&y.jsxs("div",{"data-refresh-error":!0,className:"-mt-1 pb-2 text-[10px] text-amber-500 break-words",children:[e.error,og(e.retryAt??null)&&` · retrying in ${og(e.retryAt??null)}`]}),y.jsx("div",{className:"flex flex-col gap-3",children:e.limits.map((n,r)=>{const i=og(n.resetsAt),a=n===t;return y.jsxs("div",{"data-headline":a||void 0,className:ze("flex flex-col gap-1",!a&&"opacity-60"),children:[y.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[y.jsxs("span",{className:ze("truncate",a&&"font-medium"),children:[a&&y.jsx("span",{className:"mr-1 text-muted-foreground","aria-hidden":!0,children:"▸"}),Doe(n)]}),y.jsxs("span",{className:ze("tabular-nums shrink-0",Bg(n.percent,n.severity)),children:[n.percent,"%"]})]}),y.jsx(Y$,{value:n.percent,className:ze("w-full",Bg(n.percent,n.severity))}),y.jsx("span",{className:"text-[10px] text-muted-foreground",children:i?`resets in ${i}`:"no reset reported"})]},`${n.kind}-${r}`)})}),y.jsx("div",{className:"mt-3 border-t pt-2 text-[10px] text-muted-foreground",children:"▸ is the window the strip is showing"})]})}function Doe(e){return e.scopeLabel?`${e.scopeLabel} window`:e.kind==="session"?"current session":e.kind==="weekly_all"?"all models":e.kind.replace(/_/g," ")}function W$(e){return e.reduce((t,n)=>!t||n.percent>t.percent?n:t,null)}function joe(e){const t=Loe(e.fetchedAt);return t?e.stale?`${t} old — refresh failed`:`updated ${t} ago`:e.stale?"last reading — refresh failed":"updated just now"}function Loe(e){if(!e)return null;const t=Date.now()-new Date(e).getTime();if(!Number.isFinite(t))return null;const n=Math.round(Math.max(0,t)/6e4);if(n<1)return null;if(n<60)return`${n}m`;const r=Math.floor(n/60),i=n%60;return r<24?i?`${r}h ${i}m`:`${r}h`:`${Math.floor(r/24)}d`}function zoe(e){return e>=G$?"critical":e>=q$?"warning":"ok"}const $oe={critical:"text-red-500",exceeded:"text-red-500",warning:"text-amber-500",warn:"text-amber-500",ok:"text-emerald-500"};function Bg(e,t){const n=t?$oe[t]:void 0;return n||(e>=90?"text-red-500":e>=75?"text-amber-500":"text-emerald-500")}function Boe(e){const t=`warn at ${q$}%, critical at ${G$}%`;if(e.diskUsedBytes==null||e.diskTotalBytes==null)return`disk ${e.disk}% used — ${t}`;const n=Math.max(0,e.diskTotalBytes-e.diskUsedBytes);return`disk ${e.disk}% used — ${Yx(e.diskUsedBytes)} of ${Yx(e.diskTotalBytes)}, ${Yx(n)} free — ${t}`}function lg({label:e,value:t,series:n,title:r,severity:i}){const a=Bg(t,i),s=r??(n?`${e} ${t}% — last ${n.length} samples`:void 0);return y.jsxs("span",{className:"flex items-center gap-1",title:s,children:[y.jsx("span",{className:"uppercase tracking-wide",children:e}),n?y.jsx(Uoe,{series:n,className:a}):y.jsx(Y$,{value:t,className:a}),y.jsxs("span",{className:ze("tabular-nums",a),children:[t,"%"]})]})}function Y$({value:e,className:t}){const i=Math.max(0,Math.min(100,e))/100*40;return y.jsxs("svg",{width:40,height:12,viewBox:"0 0 40 12",className:ze("overflow-visible",t),preserveAspectRatio:"none",children:[y.jsx("rect",{x:0,y:12/2-2,width:40,height:4,rx:2,fill:"currentColor",opacity:.2}),i>0&&y.jsx("rect",{x:0,y:12/2-2,width:i,height:4,rx:2,fill:"currentColor"})]})}function Uoe({series:e,className:t}){const i=e.length;if(i<2)return null;const a=e.map((s,l)=>{const u=i>1?l/(i-1)*40:0,d=12-Math.max(0,Math.min(100,s))/100*12;return`${u.toFixed(1)},${d.toFixed(1)}`}).join(" ");return y.jsx("svg",{width:40,height:12,viewBox:"0 0 40 12",className:ze("overflow-visible",t),preserveAspectRatio:"none",children:y.jsx("polyline",{points:a,fill:"none",stroke:"currentColor",strokeWidth:1,strokeLinejoin:"round",strokeLinecap:"round"})})}const Of=50;function Foe({getToken:e,filter:t,refreshKey:n,hydrateIds:r}){const[i,a]=b.useState([]),[s,l]=b.useState(null),[u,d]=b.useState(!1),[h,m]=b.useState({}),p=b.useRef(new Set),v=b.useRef(null),w=b.useRef(null),x=b.useRef(t);x.current=t;const E=b.useRef(Of),_=b.useRef(t);_.current!==t&&(_.current=t,E.current=Of);const k=b.useCallback(async(M,D)=>{const L=await e();if(!L||D!=null&&D.aborted)return null;const R=await fetch(`/api/sessions?${new URLSearchParams(M)}`,{signal:D,headers:{Authorization:`Bearer ${L}`}});if(!R.ok)return null;const H=await R.json();return Array.isArray(H==null?void 0:H.sessions)?H:null},[e]),O=b.useCallback(async(M,D,L)=>{const R=[];let H,P=null;for(;R.length<M;){const q={filter:D,limit:String(Math.min(Of,M-R.length))};H&&(q.before=H);const K=await k(q,L);if(!K)return null;if(R.push(...K.sessions),P=K.nextCursor,!P||!K.sessions.length)break;H=P}return{sessions:R,nextCursor:P}},[k]);b.useEffect(()=>{var D,L;(D=v.current)==null||D.abort(),(L=w.current)==null||L.abort();const M=new AbortController;return v.current=M,d(!0),p.current.clear(),m({}),O(E.current,t,M.signal).then(R=>{!R||M.signal.aborted||(a(R.sessions),l(R.nextCursor))}).catch(()=>{}).finally(()=>{M.signal.aborted||d(!1)}),()=>M.abort()},[O,t,n]);const N=b.useCallback(()=>{var L;if(!s||u)return;(L=w.current)==null||L.abort();const M=new AbortController;w.current=M;const D=x.current;d(!0),k({filter:D,limit:String(Of),before:s},M.signal).then(R=>{!R||M.signal.aborted||D!==x.current||(a(H=>{const P=new Set(H.map(K=>K.sessionId)),q=[...H,...R.sessions.filter(K=>!P.has(K.sessionId))];return E.current=Math.max(Of,q.length),q}),l(R.nextCursor))}).catch(()=>{}).finally(()=>{M.signal.aborted||d(!1)})},[s,u,k]),T=b.useMemo(()=>{const M=new Map;for(const D of Object.values(h))M.set(D.sessionId,D);for(const D of i)M.set(D.sessionId,D);return M},[i,h]),C=r.join(",");return b.useEffect(()=>{const M=r.filter(L=>!!L&&!T.has(L)&&!p.current.has(L)).slice(0,200);if(!M.length)return;for(const L of M)p.current.add(L);let D=!1;return k({ids:M.join(",")}).then(L=>{!L||D||m(R=>{const H={...R};for(const P of L.sessions)H[P.sessionId]=P;return H})}).catch(()=>{}),()=>{D=!0}},[C,T,k]),{sessions:i,cursor:s,loading:u,byId:T,loadMore:N}}const Nf="0.1.162";function Hoe(e){const t=Date.now()-e,n=Math.floor(t/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const r=Math.floor(n/60);if(r<24)return`${r}h ago`;const i=Math.floor(r/24);return i<7?`${i}d ago`:new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"})}const Cf="w-4 h-4 mt-0.5 shrink-0";function Koe(e){const t=e.slackContext;return(t==null?void 0:t.type)==="dm"?y.jsx(oV,{className:`${Cf} text-purple-400`}):(t==null?void 0:t.type)==="mention"?y.jsx(GG,{className:`${Cf} text-blue-400`}):(t==null?void 0:t.type)==="channel"?y.jsx(tV,{className:`${Cf} text-green-400`}):e.sessionId.startsWith("slack-")?y.jsx(Zw,{className:`${Cf} text-yellow-400`}):y.jsx(Zw,{className:`${Cf} text-muted-foreground`})}function qoe(e){const t=e.slackContext;return(t==null?void 0:t.type)==="dm"?`DM${t.userName?` · ${t.userName}`:""}`:(t==null?void 0:t.type)==="mention"?`@mention${t.channelName?` · #${t.channelName}`:""}`:(t==null?void 0:t.type)==="channel"?`#${t.channelName||"channel"}`:e.sessionId.startsWith("slack-")?"Slack":null}function Goe(e,t,n){return Object.keys(e).map(r=>t.get(r)).filter(r=>!!r&&(n==="all"||r.mine!==!1))}const uI="chats-filter",dI="chats-unread-filter";function Voe({getToken:e,activeSessionId:t,onSelect:n,onNew:r,refreshKey:i,workspaceRefreshKey:a,onRefreshWorkspace:s,unreads:l={},busySessions:u=new Set,socket:d}){var U;const h=za(),[m,p]=b.useState(()=>localStorage.getItem(uI)||"mine"),[v,w]=b.useState(()=>localStorage.getItem(dI)==="true"),[x,E]=b.useState(""),_=b.useRef(null);function k(G){p(G),localStorage.setItem(uI,G)}function O(){const G=!v;w(G),localStorage.setItem(dI,String(G))}const N=b.useMemo(()=>[t,...Object.keys(l)].filter(G=>!!G),[t,l]),{sessions:T,cursor:C,loading:M,byId:D,loadMore:L}=Foe({getToken:e,filter:m,refreshKey:i,hydrateIds:N}),R=b.useMemo(()=>Goe(l,D,m),[l,D,m]),H=R.length,P=b.useMemo(()=>v?[...R].sort((G,$)=>$.lastModified-G.lastModified):T,[v,R,T]),q=t&&!P.some(G=>G.sessionId===t)?D.get(t):void 0;b.useEffect(()=>{_.current&&_.current.scrollIntoView({block:"nearest"})},[t,P,q]);const K=b.useRef(null),X=b.useRef(L);X.current=L,b.useEffect(()=>{const G=K.current;if(!G||!C||v)return;const $=new IntersectionObserver(j=>{j.some(V=>V.isIntersecting)&&X.current()},{rootMargin:"300px"});return $.observe(G),()=>$.disconnect()},[C,M,v]),b.useEffect(()=>{e().then(G=>G?fetch("/api/version",{headers:{Authorization:`Bearer ${G}`}}):null).then(G=>G==null?void 0:G.json()).then(G=>G&&E(G.version)).catch(()=>{})},[]);const F=!!x&&x!=="unknown"&&Nf!=="dev"&&x!==Nf;b.useEffect(()=>{F&&console.warn(`[shraga] stale client bundle: built from v${Nf}, server runs v${x} — rebuild dist/client`)},[F,x]);function Y(G){const $=l[G.sessionId],j=u.has(G.sessionId)||G.runStatus==="running"||G.scheduleRunStatus==="running",V=!j&&(!!G.lastStopReason||G.scheduleRunStatus==="error"||G.scheduleRunStatus==="aborted"),z=j?"border-amber-500":V?"border-red-500":$?"border-blue-500":"",ie=!!(j||V||$);return y.jsx("button",{ref:G.sessionId===t?_:void 0,onClick:()=>n(G.sessionId,G.title),className:ze("w-full text-left px-3 py-2.5 text-sm transition-colors hover:bg-accent/50 group",ie?`rounded-r-lg border-l-[3px] ${z}`:"rounded-lg",t===G.sessionId&&"bg-accent"),children:y.jsxs("div",{className:"flex items-start gap-2",children:[Koe(G),y.jsxs("div",{className:"min-w-0 flex-1",children:[y.jsx("span",{className:ze("block truncate text-sm leading-snug",$&&"font-semibold"),children:G.title||"New session"}),y.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[y.jsx("span",{className:"text-[10px] text-muted-foreground font-medium",children:qoe(G)||G.userName}),y.jsx("span",{className:"text-[10px] text-muted-foreground/50",children:"·"}),y.jsx("span",{className:"text-[10px] text-muted-foreground",children:Hoe(G.lastModified)})]})]})]})},G.sessionId)}return y.jsxs("div",{className:"flex flex-col h-full bg-muted/30",children:[y.jsx("div",{className:"p-3",children:y.jsxs(we,{variant:"outline",size:"sm",className:"w-full gap-2 justify-start",onClick:r,title:"New Chat (Ctrl+N)",children:[y.jsx(ko,{className:"w-4 h-4"})," New Chat",y.jsx("span",{className:"ml-auto flex items-center gap-0.5 text-[10px] text-muted-foreground/50 font-mono",children:"⌃N"})]})}),y.jsx("div",{className:"border-b shrink-0 flex flex-col max-h-[40vh]",children:y.jsx(Ure,{getToken:e,onRefresh:s,refreshKey:a})}),y.jsxs("div",{className:"flex items-center justify-between px-3 pt-2 pb-1",children:[y.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Chats"}),y.jsxs("div",{className:"flex gap-0.5",children:[["mine","all"].map(G=>y.jsx("button",{onClick:()=>k(G),className:ze("text-[10px] px-1.5 rounded-full transition-colors capitalize leading-none",m===G?"text-foreground font-medium":"text-muted-foreground/60 hover:text-muted-foreground"),children:G},G)),y.jsxs("button",{onClick:O,className:ze("text-[10px] px-1.5 rounded-full transition-colors leading-none",v?"text-blue-600 dark:text-blue-400 font-medium":"text-muted-foreground/60 hover:text-muted-foreground"),children:["unread",H>0&&y.jsx("span",{className:"inline-block w-1.5 h-1.5 ml-1 rounded-full bg-blue-500 align-middle"})]})]})]}),y.jsx(CL,{className:"flex-1",children:y.jsxs("div",{className:"px-2 pb-2 space-y-0.5",children:[P.length===0&&!q&&y.jsx("p",{className:"text-xs text-muted-foreground px-3 py-6 text-center",children:M?"Loading…":v?"No unread conversations":"No conversations yet"}),q&&Y(q),P.map(Y),!v&&C&&y.jsx("div",{ref:K,className:"py-3 text-center text-[11px] text-muted-foreground/60",children:M?"Loading older…":"···"})]})}),y.jsxs("div",{className:"px-4 py-2 flex flex-col items-center gap-1",children:[y.jsx(Moe,{socket:d??null,getToken:e}),(U=h.sidebarExtras)==null?void 0:U.call(h),x&&(F?y.jsxs("button",{onClick:()=>location.reload(),title:`This page was built from v${Nf}, the server runs v${x} — reload to update`,className:"text-[10px] text-amber-400 hover:text-amber-300 text-center underline decoration-dotted",children:["⚠️ stale page (v",Nf," → v",x,") · reload"]}):y.jsxs("div",{className:"text-[10px] text-muted-foreground/50 text-center",children:["v",x]}))]})]})}function ni(e,t){const n=e[e.length-1];if((n==null?void 0:n.role)==="assistant"){if(t.type==="text"||t.type==="thinking"){const r=[...n.blocks],i=r[r.length-1];return(i==null?void 0:i.type)===t.type?(r[r.length-1]={...i,text:i.text+t.text},[...e.slice(0,-1),{...n,blocks:r}]):[...e.slice(0,-1),{...n,blocks:[...r,t]}]}return[...e.slice(0,-1),{...n,blocks:[...n.blocks,t]}]}return[...e,{id:Ms(),role:"assistant",blocks:[t]}]}function fI(e,t,n="text"){const r=e[e.length-1],i={type:n,text:t};return(r==null?void 0:r.role)==="assistant"?[...e.slice(0,-1),{...r,blocks:[...r.blocks,i]}]:[...e,{id:Ms(),role:"assistant",blocks:[i]}]}function X$(e,t,n){for(let r=e.length-1;r>=0;r--){const i=e[r];if(i.role!=="assistant")continue;const a=i.blocks.findIndex(l=>l.type==="tool_use"&&l.toolUseId===t);if(a===-1)continue;const s=[...i.blocks];return s[a]={...s[a],input:n},[...e.slice(0,r),{...i,blocks:s},...e.slice(r+1)]}return e}function Woe(e,t){const[n,r]=b.useState([]),[i,a]=b.useState(!1),[s,l]=b.useState([]),u=b.useRef(t.initialSessionId),d=b.useRef(!1),h=b.useRef(s);h.current=s;const m=b.useRef(t.getToken);m.current=t.getToken;const p=b.useRef(t.onNewSession);p.current=t.onNewSession;const v=b.useRef(t.onDirectivesChanged);v.current=t.onDirectivesChanged;const w=b.useRef(t.onParticipantsChanged);w.current=t.onParticipantsChanged;const x=b.useRef(t.onEvent);x.current=t.onEvent;const E=b.useRef(e);E.current=e;const _=b.useCallback(P=>P!=null&&P===u.current,[]),k=b.useCallback(async()=>{var q;const P=u.current;if(P)try{const X=await(await Ll(`/api/sessions/${P}/messages`,m.current)).json();r(iL(X)),a(!!X.busy),(q=w.current)==null||q.call(w,Array.isArray(X.participants)&&X.participants.length>1)}catch{}},[]);b.useEffect(()=>{if(!e)return;const P=e.on(q=>{var X,F,Y,U,G,$;(X=x.current)==null||X.call(x,q);const K=q;if(K.type==="compact_marker")return _(K.sessionId)?r(j=>[...j,{id:Ms(),role:"assistant",blocks:[{type:"compact_marker",summary:K.summary??"",compactedCount:K.compactedCount??0}]}]):void 0;switch(q.type){case"thinking_delta":return _(q.sessionId)?r(j=>ni(j,{type:"thinking",text:q.text})):void 0;case"text_delta":return _(q.sessionId)?r(j=>ni(j,{type:"text",text:q.text})):void 0;case"tool_use":return _(q.sessionId)?r(j=>ni(j,{type:"tool_use",tool:q.tool,toolUseId:q.toolUseId,input:q.input})):void 0;case"tool_use_input":return _(q.sessionId)?r(j=>X$(j,q.toolUseId,q.input)):void 0;case"tool_result":return _(q.sessionId)?r(j=>ni(j,{type:"tool_result",toolUseId:q.toolUseId,output:q.output})):void 0;case"tool_result_image":return _(q.sessionId)?r(j=>ni(j,{type:"image",src:q.dataUrl})):void 0;case"permission_request":return _(q.sessionId)?r(j=>ni(j,{type:"permission_request",id:q.id,tool:q.tool,input:q.input})):void 0;case"question_request":return _(q.sessionId)?r(j=>ni(j,{type:"question_request",id:q.id,questions:q.questions})):void 0;case"directives":return d.current?(F=v.current)==null?void 0:F.call(v,q.directives):void 0;case"session_id":return!d.current||u.current?void 0:(u.current=q.sessionId,(Y=p.current)==null?void 0:Y.call(p,q.sessionId));case"forked":return q.sourceSessionId!==u.current?void 0:(u.current=q.sessionId,(U=p.current)==null?void 0:U.call(p,q.sessionId));case"session_busy":q.sessionId===u.current&&a(q.busy);return;case"session_stream":return q.sessionId!==u.current?void 0:Yoe(r,q.event);case"session_messages_changed":q.sessionId===u.current&&k();return;case"done":{if(q.sessionId!==u.current)return;q.stopReason==="max_turns_reached"&&r(V=>ni(V,{type:"text",text:`
|
|
1907
|
+
`)},Sre=0,iu=[];function _re(e){var t=b.useRef([]),n=b.useRef([0,0]),r=b.useRef(),i=b.useState(Sre++)[0],a=b.useState(hz)[0],s=b.useRef(e);b.useEffect(function(){s.current=e},[e]),b.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var x=P7([e.lockRef.current],(e.shards||[]).map(FM),!0).filter(Boolean);return x.forEach(function(E){return E.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),x.forEach(function(E){return E.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var l=b.useCallback(function(x,E){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!s.current.allowPinchZoom;var _=Op(x),k=n.current,O="deltaX"in x?x.deltaX:k[0]-_[0],N="deltaY"in x?x.deltaY:k[1]-_[1],T,C=x.target,M=Math.abs(O)>Math.abs(N)?"h":"v";if("touches"in x&&M==="h"&&C.type==="range")return!1;var D=window.getSelection(),L=D&&D.anchorNode,R=L?L===C||L.contains(C):!1;if(R)return!1;var H=BM(M,C);if(!H)return!0;if(H?T=M:(T=M==="v"?"h":"v",H=BM(M,C)),!H)return!1;if(!r.current&&"changedTouches"in x&&(O||N)&&(r.current=T),!T)return!0;var P=r.current||T;return xre(P,E,x,P==="h"?O:N)},[]),u=b.useCallback(function(x){var E=x;if(!(!iu.length||iu[iu.length-1]!==a)){var _="deltaY"in E?UM(E):Op(E),k=t.current.filter(function(T){return T.name===E.type&&(T.target===E.target||E.target===T.shadowParent)&&wre(T.delta,_)})[0];if(k&&k.should){E.cancelable&&E.preventDefault();return}if(!k){var O=(s.current.shards||[]).map(FM).filter(Boolean).filter(function(T){return T.contains(E.target)}),N=O.length>0?l(E,O[0]):!s.current.noIsolation;N&&E.cancelable&&E.preventDefault()}}},[]),d=b.useCallback(function(x,E,_,k){var O={name:x,delta:E,target:_,should:k,shadowParent:Are(_)};t.current.push(O),setTimeout(function(){t.current=t.current.filter(function(N){return N!==O})},1)},[]),h=b.useCallback(function(x){n.current=Op(x),r.current=void 0},[]),m=b.useCallback(function(x){d(x.type,UM(x),x.target,l(x,e.lockRef.current))},[]),p=b.useCallback(function(x){d(x.type,Op(x),x.target,l(x,e.lockRef.current))},[]);b.useEffect(function(){return iu.push(a),e.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:p}),document.addEventListener("wheel",u,ru),document.addEventListener("touchmove",u,ru),document.addEventListener("touchstart",h,ru),function(){iu=iu.filter(function(x){return x!==a}),document.removeEventListener("wheel",u,ru),document.removeEventListener("touchmove",u,ru),document.removeEventListener("touchstart",h,ru)}},[]);var v=e.removeScrollBar,w=e.inert;return b.createElement(b.Fragment,null,w?b.createElement(a,{styles:Ere(i)}):null,v?b.createElement(hre,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Are(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const kre=ere(fz,_re);var bS=b.forwardRef(function(e,t){return b.createElement(Qv,xa({},e,{ref:t,sideCar:kre}))});bS.classNames=Qv.classNames;var Ore=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},au=new WeakMap,Np=new WeakMap,Cp={},Fx=0,vz=function(e){return e&&(e.host||vz(e.parentNode))},Nre=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=vz(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},Cre=function(e,t,n,r){var i=Nre(t,Array.isArray(e)?e:[e]);Cp[n]||(Cp[n]=new WeakMap);var a=Cp[n],s=[],l=new Set,u=new Set(i),d=function(m){!m||l.has(m)||(l.add(m),d(m.parentNode))};i.forEach(d);var h=function(m){!m||u.has(m)||Array.prototype.forEach.call(m.children,function(p){if(l.has(p))h(p);else try{var v=p.getAttribute(r),w=v!==null&&v!=="false",x=(au.get(p)||0)+1,E=(a.get(p)||0)+1;au.set(p,x),a.set(p,E),s.push(p),x===1&&w&&Np.set(p,!0),E===1&&p.setAttribute(n,"true"),w||p.setAttribute(r,"true")}catch(_){console.error("aria-hidden: cannot operate on ",p,_)}})};return h(t),l.clear(),Fx++,function(){s.forEach(function(m){var p=au.get(m)-1,v=a.get(m)-1;au.set(m,p),a.set(m,v),p||(Np.has(m)||m.removeAttribute(r),Np.delete(m)),v||m.removeAttribute(n)}),Fx--,Fx||(au=new WeakMap,au=new WeakMap,Np=new WeakMap,Cp={})}},yz=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=Ore(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),Cre(r,i,n,"aria-hidden")):function(){return null}},Jv="Dialog",[bz]=pL(Jv),[Tre,Ji]=bz(Jv),xz=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:s=!0}=e,l=b.useRef(null),u=b.useRef(null),[d,h]=Ane({prop:r,defaultProp:i??!1,onChange:a,caller:Jv});return y.jsx(Tre,{scope:t,triggerRef:l,contentRef:u,contentId:jx(),titleId:jx(),descriptionId:jx(),open:d,onOpenChange:h,onOpenToggle:b.useCallback(()=>h(m=>!m),[h]),modal:s,children:n})};xz.displayName=Jv;var wz="DialogTrigger",Ez=b.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Ji(wz,n),a=ui(t,i.triggerRef);return y.jsx(Fr.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":_S(i.open),...r,ref:a,onClick:Sr(e.onClick,i.onOpenToggle)})});Ez.displayName=wz;var xS="DialogPortal",[Mre,Sz]=bz(xS,{forceMount:void 0}),_z=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=Ji(xS,t);return y.jsx(Mre,{scope:t,forceMount:n,children:b.Children.map(r,s=>y.jsx(Zs,{present:n||a.open,children:y.jsx(uz,{asChild:!0,container:i,children:s})}))})};_z.displayName=xS;var Dg="DialogOverlay",wS=b.forwardRef((e,t)=>{const n=Sz(Dg,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Ji(Dg,e.__scopeDialog);return a.modal?y.jsx(Zs,{present:r||a.open,children:y.jsx(Rre,{...i,ref:t})}):null});wS.displayName=Dg;var Ire=WE("DialogOverlay.RemoveScroll"),Rre=b.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Ji(Dg,n),a=Rne(),s=ui(t,a);return y.jsx(bS,{as:Ire,allowPinchZoom:!0,shards:[i.contentRef],children:y.jsx(Fr.div,{"data-state":_S(i.open),...r,ref:s,style:{pointerEvents:"auto",...r.style}})})}),Fu="DialogContent",ES=b.forwardRef((e,t)=>{const n=Sz(Fu,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Ji(Fu,e.__scopeDialog);return y.jsx(Zs,{present:r||a.open,children:a.modal?y.jsx(Pre,{...i,ref:t}):y.jsx(Dre,{...i,ref:t})})});ES.displayName=Fu;var Pre=b.forwardRef((e,t)=>{const n=Ji(Fu,e.__scopeDialog),r=b.useRef(null),i=ui(t,n.contentRef,r);return b.useEffect(()=>{const a=r.current;if(a)return yz(a)},[]),y.jsx(Az,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:Sr(e.onCloseAutoFocus,a=>{var s;a.preventDefault(),(s=n.triggerRef.current)==null||s.focus()}),onPointerDownOutside:Sr(e.onPointerDownOutside,a=>{const s=a.detail.originalEvent,l=s.button===0&&s.ctrlKey===!0;(s.button===2||l)&&a.preventDefault()}),onFocusOutside:Sr(e.onFocusOutside,a=>a.preventDefault())})}),Dre=b.forwardRef((e,t)=>{const n=Ji(Fu,e.__scopeDialog),r=b.useRef(!1),i=b.useRef(!1);return y.jsx(Az,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var s,l;(s=e.onCloseAutoFocus)==null||s.call(e,a),a.defaultPrevented||(r.current||(l=n.triggerRef.current)==null||l.focus(),a.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:a=>{var u,d;(u=e.onInteractOutside)==null||u.call(e,a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const s=a.target;((d=n.triggerRef.current)==null?void 0:d.contains(s))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&i.current&&a.preventDefault()}})}),Az=b.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...s}=e,l=Ji(Fu,n);return qne(),y.jsx(y.Fragment,{children:y.jsx(lz,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:y.jsx(oz,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":_S(l.open),...s,ref:t,deferPointerDownOutside:!0,onDismiss:()=>l.onOpenChange(!1)})})})}),kz="DialogTitle",SS=b.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Ji(kz,n);return y.jsx(Fr.h2,{id:i.titleId,...r,ref:t})});SS.displayName=kz;var Oz="DialogDescription",jre=b.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Ji(Oz,n);return y.jsx(Fr.p,{id:i.descriptionId,...r,ref:t})});jre.displayName=Oz;var Nz="DialogClose",Cz=b.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Ji(Nz,n);return y.jsx(Fr.button,{type:"button",...r,ref:t,onClick:Sr(e.onClick,()=>i.onOpenChange(!1))})});Cz.displayName=Nz;function _S(e){return e?"open":"closed"}const Oo=xz,id=Ez,Lre=_z,Tz=b.forwardRef(({className:e,...t},n)=>y.jsx(wS,{ref:n,className:ze("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));Tz.displayName=wS.displayName;const Na=b.forwardRef(({className:e,children:t,...n},r)=>y.jsxs(Lre,{children:[y.jsx(Tz,{}),y.jsxs(ES,{ref:r,className:ze("fixed left-[50%] top-[50%] z-50 flex flex-col w-[calc(100vw-2rem)] max-w-lg max-h-[85dvh] overflow-y-auto translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-4 sm:p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 sm:rounded-lg",e),...n,children:[t,y.jsxs(Cz,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[y.jsx(Bs,{className:"h-4 w-4"}),y.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Na.displayName=ES.displayName;function Us({className:e,...t}){return y.jsx("div",{className:ze("shrink-0 flex flex-col space-y-1.5 text-center sm:text-left",e),...t})}function Mz({className:e,...t}){return y.jsx("div",{"data-dialog-body":!0,className:ze("flex-1 min-h-0 overflow-y-auto -mx-4 px-4 sm:-mx-6 sm:px-6",e),...t})}function Iz({className:e,...t}){return y.jsx("div",{className:ze("shrink-0 -mx-4 px-4 pt-3 border-t sm:-mx-6 sm:px-6","flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t})}const No=b.forwardRef(({className:e,...t},n)=>y.jsx(SS,{ref:n,className:ze("text-lg font-semibold leading-none tracking-tight",e),...t}));No.displayName=SS.displayName;const zre=new Set(["png","jpg","jpeg","gif","webp","svg","ico","bmp","avif"]),$re=new Set(["pdf","mp4","webm","mp3","ogg","wav"]);async function Bre(e,t){const n=await t();if(!n)return[];const r=await fetch(`/api/workspace/ls?path=${encodeURIComponent(e)}`,{headers:{Authorization:`Bearer ${n}`}});return r.ok?(await r.json()).entries??[]:[]}function Ure({getToken:e,onRefresh:t,refreshKey:n}){const[r,i]=b.useState(new Map),[a,s]=b.useState(()=>new Set),[l,u]=b.useState(null),[d,h]=b.useState(!1),[m,p]=b.useState("fit"),[v,w]=b.useState(null),[x,E]=b.useState(null),_=b.useRef(null),[k,O]=b.useState(null),[N,T]=b.useState(!1),[C,M]=b.useState([]),D=b.useCallback(async F=>{const Y=await Bre(F,e);i(U=>new Map(U).set(F,Y))},[e]);b.useEffect(()=>{D(""),a.forEach(F=>D(F))},[D,n]);const L=r.get("")??[],R=b.useCallback(F=>{try{const Y=F.contentDocument;if(!(Y!=null&&Y.body))return;const U=Math.max(Y.body.offsetWidth,Y.body.scrollWidth),G=Math.max(Y.body.offsetHeight,Y.body.scrollHeight);U&&G&&E({w:U,h:G})}catch{}},[]),H=b.useCallback(()=>{const F=_.current,Y=x;if(!F||!Y)return;const U=16,G=F.clientWidth-U,$=F.clientHeight-U,j=Math.min(G/Y.w,$/Y.h,1);w({scale:j,w:Y.w,h:Y.h})},[x]);b.useEffect(()=>{if(!(l!=null&&l.html)||m!=="fit"){w(null);return}const F=_.current;if(!F)return;const Y=new ResizeObserver(()=>requestAnimationFrame(H));return Y.observe(F),()=>Y.disconnect()},[l==null?void 0:l.html,d,m,H]),b.useEffect(()=>{N&&e().then(F=>{F&&fetch("/api/data-sync/log",{headers:{Authorization:`Bearer ${F}`}}).then(Y=>Y.json()).then(M).catch(()=>{})})},[N]);const P=F=>{s(Y=>{const U=new Set(Y);return U.has(F)?U.delete(F):(U.add(F),r.has(F)||D(F)),U})},q=(F,Y)=>{const U=new URLSearchParams({path:F});return k&&U.set("token",k),Y&&U.set("dl","1"),`/api/workspace/raw?${U}`},K=async F=>{var G;const Y=await e();if(!Y)return;O(Y);const U=((G=F.split(".").pop())==null?void 0:G.toLowerCase())??"";if(U==="html"||U==="htm"){u({path:F,content:"",binary:!1,html:!0});return}if(zre.has(U)){u({path:F,content:"",binary:!1,image:!0});return}if($re.has(U)){u({path:F,content:"",binary:!1,html:!0});return}try{const $=await fetch(`/api/workspace/file?path=${encodeURIComponent(F)}`,{headers:{Authorization:`Bearer ${Y}`}});if(!$.ok)return;const j=await $.json();u({path:F,content:j.content,binary:!!j.binary})}catch{}},X=(F,Y)=>y.jsx(y.Fragment,{children:F.map(U=>{const G=U.path.split("/").pop();return y.jsxs("div",{children:[U.type==="dir"?y.jsxs("button",{onClick:()=>P(U.path),className:"w-full flex items-center gap-1 px-2 py-1 rounded hover:bg-accent/50 text-left text-sm",style:{paddingLeft:8+Y*12},children:[y.jsx(Xs,{className:ze("w-3 h-3 shrink-0 transition-transform",a.has(U.path)&&"rotate-90")}),y.jsx(eV,{className:"w-3.5 h-3.5 shrink-0 text-muted-foreground"}),y.jsx("span",{className:"truncate",children:G})]}):y.jsxs("button",{onClick:()=>K(U.path),className:"w-full flex items-center gap-1 px-2 py-1 rounded hover:bg-accent/50 text-left text-sm",style:{paddingLeft:8+Y*12+12},title:U.oneLiner||U.path,children:[y.jsx(HE,{className:"w-3.5 h-3.5 shrink-0 text-muted-foreground"}),y.jsx("span",{className:"truncate",children:G})]}),U.type==="dir"&&a.has(U.path)&&X(r.get(U.path)??[],Y+1)]},U.path)})});return y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex items-center justify-between px-3 pt-2 pb-1 shrink-0",children:[y.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Workspace"}),y.jsxs("div",{className:"flex items-center gap-0.5",children:[y.jsx("button",{onClick:()=>T(!0),className:"p-0.5 rounded hover:bg-accent text-muted-foreground",title:"Activity log",children:y.jsx(nV,{className:"w-3 h-3"})}),y.jsx("button",{onClick:()=>{D(""),a.forEach(F=>D(F)),t==null||t()},className:"p-0.5 rounded hover:bg-accent text-muted-foreground",title:"Refresh",children:y.jsx(td,{className:"w-3 h-3"})})]})]}),y.jsx("div",{className:"px-1 pb-2 overflow-y-auto min-h-0",children:L.length===0?y.jsx("p",{className:"text-xs text-muted-foreground px-3 py-2",children:"Empty. Drop .md files into data/workspace/ or ask the agent to create some."}):X(L,0)}),y.jsx(Oo,{open:!!l,onOpenChange:F=>{F||(u(null),h(!1),p("fit"),E(null))},children:y.jsxs(Na,{className:ze(l!=null&&l.html?ze("!flex !flex-col !p-0 !gap-0 overflow-hidden",d?"max-w-none w-[100vw] h-[100vh] rounded-none border-0":"max-w-[90vw] w-[90vw] h-[85vh]"):"max-w-3xl max-h-[80vh] !flex !flex-col overflow-hidden"),children:[y.jsxs("div",{className:"absolute right-12 top-4 flex items-center gap-1.5 z-10",children:[(l==null?void 0:l.html)&&y.jsxs(y.Fragment,{children:[y.jsx("button",{onClick:()=>p(F=>F==="fit"?"scroll":"fit"),className:"rounded-sm opacity-70 hover:opacity-100 text-muted-foreground",title:m==="fit"?"Switch to scrollable (1:1)":"Switch to scale-to-fit",children:m==="fit"?y.jsx(sV,{className:"w-4 h-4"}):y.jsx(hV,{className:"w-4 h-4"})}),y.jsx("button",{onClick:()=>h(F=>!F),className:"rounded-sm opacity-70 hover:opacity-100 text-muted-foreground",title:d?"Restore":"Maximize",children:d?y.jsx(qE,{className:"w-4 h-4"}):y.jsx(KE,{className:"w-4 h-4"})})]}),l&&y.jsx("a",{href:q(l.path,!0),download:!0,className:"rounded-sm opacity-70 hover:opacity-100 text-muted-foreground",title:"Download",children:y.jsx(uL,{className:"w-4 h-4"})})]}),y.jsx(Us,{className:ze((l==null?void 0:l.html)&&"px-4 py-3 shrink-0 border-b"),children:y.jsx(No,{className:"font-mono text-sm truncate pr-16",children:l==null?void 0:l.path})}),y.jsx("div",{ref:l!=null&&l.html?_:void 0,className:ze(l!=null&&l.html?ze("flex-1 min-h-0 bg-muted/10",m==="fit"?"overflow-hidden flex items-center justify-center":"overflow-auto"):"flex-1 min-h-0 overflow-y-auto"),children:l!=null&&l.html?m==="fit"?y.jsx("div",{style:v?{width:v.w*v.scale,height:v.h*v.scale}:{width:"100%",height:"100%"},children:y.jsx("iframe",{src:q(l.path),className:"border-0 bg-white origin-top-left",title:l.path,onLoad:F=>{R(F.currentTarget),H()},style:v?{width:v.w,height:v.h,transform:`scale(${v.scale})`}:{width:"100%",height:"100%"}})}):y.jsx("iframe",{src:q(l.path),className:"border-0 bg-white mx-auto block",title:l.path,onLoad:F=>R(F.currentTarget),style:{width:(x==null?void 0:x.w)||"100%",height:(x==null?void 0:x.h)||"100%"}}):l!=null&&l.image?y.jsx("div",{className:"flex items-center justify-center p-4",children:y.jsx("img",{src:q(l.path),alt:l.path,className:"max-w-full max-h-[70vh] object-contain"})}):l!=null&&l.binary?y.jsx("p",{className:"text-sm text-muted-foreground",children:"(binary file — preview unavailable)"}):l!=null&&l.path.toLowerCase().endsWith(".md")||l!=null&&l.path.toLowerCase().endsWith(".markdown")?y.jsx("div",{className:"text-sm",children:y.jsx(h3,{remarkPlugins:[L3],rehypePlugins:[az],className:"prose prose-sm max-w-none dark:prose-invert prose-pre:bg-muted prose-pre:border prose-code:before:content-none prose-code:after:content-none",children:l.content})}):y.jsx("pre",{className:"text-xs whitespace-pre-wrap break-all",children:l==null?void 0:l.content})})]})}),y.jsx(Oo,{open:N,onOpenChange:T,children:y.jsxs(Na,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col",children:[y.jsx(Us,{children:y.jsx(No,{className:"text-sm",children:"Activity Log"})}),y.jsxs("div",{className:"overflow-y-auto flex-1 space-y-2",children:[C.map(F=>y.jsxs("div",{className:"border-b border-border/50 pb-2 last:border-0",children:[y.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[y.jsx("span",{className:"text-sm text-foreground",children:F.message}),y.jsx("span",{className:"text-[10px] text-muted-foreground shrink-0",children:Fre(F.date)})]}),F.files.length>0&&y.jsx("div",{className:"text-[11px] text-muted-foreground mt-0.5",children:F.files.map(Y=>y.jsx("span",{className:"inline-block mr-2 font-mono",children:Y},Y))})]},F.hash)),C.length===0&&y.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No activity yet"})]})]})})]})}function Fre(e){const t=new Date(e),r=new Date().getTime()-t.getTime(),i=Math.floor(r/6e4);if(i<60)return`${i}m ago`;const a=Math.floor(i/60);return a<24?`${a}h ago`:t.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function og(e,t=Date.now()){if(!e)return null;const n=new Date(e).getTime()-t;if(!Number.isFinite(n)||n<=0)return null;const r=Math.round(n/6e4);if(r<1)return"1m";if(r<60)return`${r}m`;const i=Math.floor(r/60),a=r%60;if(i<48)return a?`${i}h ${a}m`:`${i}h`;const s=Math.floor(i/24),l=i%24;return l?`${s}d ${l}h`:`${s}d`}const Hre=/resets\s+(\d{1,2})(?::(\d{2}))?\s*(am|pm)?\s*\(UTC\)/i;function Kre(e,t=Date.now(),n=Date.now()){var m;const r=e.match(Hre);if(!r)return e;let i=Number(r[1]);const a=r[2]?Number(r[2]):0,s=(m=r[3])==null?void 0:m.toLowerCase();if(s==="pm"&&i<12&&(i+=12),s==="am"&&i===12&&(i=0),i>23||a>59)return e;const l=new Date(t),u=new Date(Date.UTC(l.getUTCFullYear(),l.getUTCMonth(),l.getUTCDate(),i,a));u.getTime()<=t&&u.setUTCDate(u.getUTCDate()+1);const d=u.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}),h=og(u.toISOString(),n);return e.replace(r[0],`resets ${d}${h?` (in ${h})`:""}`)}var qre=Object.defineProperty,ad=(e,t)=>qre(e,"name",{value:t,configurable:!0}),Rz=!!(typeof window<"u"&&window.document&&window.document.createElement);function Ds(e,t,{checkForDefaultPrevented:n=!0}={}){return ad(function(i){if(e==null||e(i),n===!1||!i||!i.defaultPrevented)return t==null?void 0:t(i)},"handleEvent")}ad(Ds,"composeEventHandlers");function Gre(e){var t;if(!Rz)throw new Error("Cannot access window outside of the DOM");return((t=e==null?void 0:e.ownerDocument)==null?void 0:t.defaultView)??window}ad(Gre,"getOwnerWindow");function f1(e){if(!Rz)throw new Error("Cannot access document outside of the DOM");return(e==null?void 0:e.ownerDocument)??document}ad(f1,"getOwnerDocument");function Pz(e,t=!1){const{activeElement:n}=f1(e);if(!(n!=null&&n.nodeName))return null;if(Dz(n)&&n.contentDocument)return Pz(n.contentDocument.body,t);if(t){const r=n.getAttribute("aria-activedescendant");if(r){const i=f1(n).getElementById(r);if(i)return i}}return n}ad(Pz,"getActiveElement");function Dz(e){return e.tagName==="IFRAME"}ad(Dz,"isFrame");var Vre=Object.defineProperty,AS=(e,t)=>Vre(e,"name",{value:t,configurable:!0});function h1(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}AS(h1,"setRef");function jz(...e){return t=>{let n=!1;const r=e.map(i=>{const a=h1(i,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let i=0;i<r.length;i++){const a=r[i];typeof a=="function"?a():h1(e[i],null)}}}}AS(jz,"composeRefs");function od(...e){return b.useCallback(jz(...e),e)}AS(od,"useComposedRefs");var Wre=Object.defineProperty,Ni=(e,t)=>Wre(e,"name",{value:t,configurable:!0});function Yre(e,t){const n=b.createContext(t);n.displayName=e+"Context";const r=Ni(a=>{const{children:s,...l}=a,u=b.useMemo(()=>l,Object.values(l));return y.jsx(n.Provider,{value:u,children:s})},"Provider");r.displayName=e+"Provider";function i(a,s={}){const{optional:l=!1}=s,u=b.useContext(n);if(u)return u;if(t!==void 0)return t;if(!l)throw new Error(`\`${a}\` must be used within \`${e}\``)}return Ni(i,"useContext"),[r,i]}Ni(Yre,"createContext");function Lz(e,t=[]){let n=[];function r(a,s){const l=b.createContext(s);l.displayName=a+"Context";const u=n.length;n=[...n,s];const d=Ni(m=>{var _;const{scope:p,children:v,...w}=m,x=((_=p==null?void 0:p[e])==null?void 0:_[u])||l,E=b.useMemo(()=>w,Object.values(w));return y.jsx(x.Provider,{value:E,children:v})},"Provider");d.displayName=a+"Provider";function h(m,p,v={}){var _;const{optional:w=!1}=v,x=((_=p==null?void 0:p[e])==null?void 0:_[u])||l,E=b.useContext(x);if(E)return E;if(s!==void 0)return s;if(!w)throw new Error(`\`${m}\` must be used within \`${a}\``)}return Ni(h,"useContext"),[d,h]}Ni(r,"createContext");const i=Ni(()=>{const a=n.map(s=>b.createContext(s));return Ni(function(l){const u=(l==null?void 0:l[e])||a;return b.useMemo(()=>({[`__scope${e}`]:{...l,[e]:u}}),[l,u])},"useScope")},"createScope");return i.scopeName=e,[r,zz(i,...t)]}Ni(Lz,"createContextScope");function zz(...e){const t=e[0];if(e.length===1)return t;const n=Ni(()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return Ni(function(a){const s=r.reduce((l,{useScope:u,scopeName:d})=>{const m=u(a)[`__scope${d}`];return{...l,...m}},{});return b.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])},"useComposedScopes")},"createScope");return n.scopeName=t.scopeName,n}Ni(zz,"composeContextScopes");var Xre=Object.defineProperty,ea=(e,t)=>Xre(e,"name",{value:t,configurable:!0});function kS(e){const t=b.forwardRef((n,r)=>{let{children:i,...a}=n,s=null,l=!1;const u=[];m1(i)&&typeof Tp=="function"&&(i=Tp(i._payload)),b.Children.forEach(i,p=>{var v;if(Fz(p)){l=!0;const w=p;let x="child"in w.props?w.props.child:w.props.children;m1(x)&&typeof Tp=="function"&&(x=Tp(x._payload)),s=Qre(w,x),u.push((v=s==null?void 0:s.props)==null?void 0:v.children)}else u.push(p)}),s?s=b.cloneElement(s,void 0,u):!l&&b.Children.count(i)===1&&b.isValidElement(i)&&(s=i);const d=s?Uz(s):void 0,h=od(r,d);if(!s){if(i||i===0)throw new Error(l?tie(e):eie(e));return i}const m=Bz(a,s.props??{});return s.type!==b.Fragment&&(m.ref=r?h:d),b.cloneElement(s,m)});return t.displayName=`${e}.Slot`,t}ea(kS,"createSlot");var $z=Symbol.for("radix.slottable");function Zre(e){const t=ea(n=>"child"in n?n.children(n.child):n.children,"Slottable");return t.displayName=`${e}.Slottable`,t.__radixId=$z,t}ea(Zre,"createSlottable");var Qre=ea((e,t)=>{if("child"in e.props){const n=e.props.child;return b.isValidElement(n)?b.cloneElement(n,void 0,e.props.children(n.props.children)):null}return b.isValidElement(t)?t:null},"getSlottableElementFromSlottable");function Bz(e,t){const n={...t};for(const r in t){const i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...l)=>{const u=a(...l);return i(...l),u}:i&&(n[r]=i):r==="style"?n[r]={...i,...a}:r==="className"&&(n[r]=[i,a].filter(Boolean).join(" "))}return{...e,...n}}ea(Bz,"mergeProps");function Uz(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}ea(Uz,"getElementRef");function Fz(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===$z}ea(Fz,"isSlottable");var Jre=Symbol.for("react.lazy");function m1(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Jre&&"_payload"in e&&Hz(e._payload)}ea(m1,"isLazyComponent");function Hz(e){return typeof e=="object"&&e!==null&&"then"in e}ea(Hz,"isPromiseLike");var eie=ea(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),tie=ea(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),Tp=ja[" use ".trim().toString()],nie=Object.defineProperty,rie=(e,t)=>nie(e,"name",{value:t,configurable:!0}),iie=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ey=iie.reduce((e,t)=>{const n=kS(`Primitive.${t}`),r=b.forwardRef((i,a)=>{const{asChild:s,...l}=i,u=s?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),y.jsx(u,{...l,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Kz(e,t){e&&La.flushSync(()=>e.dispatchEvent(t))}rie(Kz,"dispatchDiscreteCustomEvent");var aie=Object.defineProperty,oie=(e,t)=>aie(e,"name",{value:t,configurable:!0});function ty(e){const t=b.useRef(e);return b.useEffect(()=>{t.current=e}),b.useMemo(()=>((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)}),[])}oie(ty,"useCallbackRef");var sie=Object.defineProperty,qn=(e,t)=>sie(e,"name",{value:t,configurable:!0}),p1="dismissableLayer.update",lie="dismissableLayer.pointerDownOutside",cie="dismissableLayer.focusOutside",HM,qz=b.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),uie=b.forwardRef(qn(function(t,n){const{disableOutsidePointerEvents:r=!1,deferPointerDownOutside:i=!1,onEscapeKeyDown:a,onPointerDownOutside:s,onFocusOutside:l,onInteractOutside:u,onDismiss:d,...h}=t,m=b.useContext(qz),[p,v]=b.useState(null),w=(p==null?void 0:p.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,x]=b.useState({}),E=od(n,v),_=Array.from(m.layers),[k]=[...m.layersWithOutsidePointerEventsDisabled].slice(-1),O=k?_.indexOf(k):-1,N=p?_.indexOf(p):-1,T=m.layersWithOutsidePointerEventsDisabled.size>0,C=N>=O,M=b.useRef(!1),D=Gz(P=>{s==null||s(P),u==null||u(P),P.defaultPrevented||d==null||d()},{ownerDocument:w,deferPointerDownOutside:i,isDeferredPointerDownOutsideRef:M,dismissableSurfaces:m.dismissableSurfaces,shouldHandlePointerDownOutside:b.useCallback(P=>{if(!(P instanceof Node))return!1;const q=[...m.branches].some(K=>K.contains(P));return C&&!q},[m.branches,C])}),L=Vz(P=>{if(i&&M.current)return;const q=P.target;[...m.branches].some(X=>X.contains(q))||(l==null||l(P),u==null||u(P),P.defaultPrevented||d==null||d())},w),R=p?N===_.length-1:!1,H=ty(P=>{P.key==="Escape"&&(a==null||a(P),!P.defaultPrevented&&d&&(P.preventDefault(),d()))});return b.useEffect(()=>{if(R)return w.addEventListener("keydown",H,{capture:!0}),()=>w.removeEventListener("keydown",H,{capture:!0})},[w,R,H]),b.useEffect(()=>{if(p)return r&&(m.layersWithOutsidePointerEventsDisabled.size===0&&(HM=w.body.style.pointerEvents,w.body.style.pointerEvents="none"),m.layersWithOutsidePointerEventsDisabled.add(p)),m.layers.add(p),g1(),()=>{r&&(m.layersWithOutsidePointerEventsDisabled.delete(p),m.layersWithOutsidePointerEventsDisabled.size===0&&(w.body.style.pointerEvents=HM))}},[p,w,r,m]),b.useEffect(()=>()=>{p&&(m.layers.delete(p),m.layersWithOutsidePointerEventsDisabled.delete(p),g1())},[p,m]),b.useEffect(()=>{const P=qn(()=>x({}),"handleUpdate");return document.addEventListener(p1,P),()=>document.removeEventListener(p1,P)},[]),y.jsx(ey.div,{...h,ref:E,style:{pointerEvents:T?C?"auto":"none":void 0,...t.style},onFocusCapture:Ds(t.onFocusCapture,L.onFocusCapture),onBlurCapture:Ds(t.onBlurCapture,L.onBlurCapture),onPointerDownCapture:Ds(t.onPointerDownCapture,D.onPointerDownCapture)})},"DismissableLayer"));function die(){const e=b.useContext(qz),[t,n]=b.useState(null);return b.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}qn(die,"useDismissableLayerSurface");var fie=qn(()=>!0,"IS_TRUE");function Gz(e,t){const{ownerDocument:n=globalThis==null?void 0:globalThis.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:s=fie}=t,l=ty(e),u=b.useRef(!1),d=b.useRef(!1),h=b.useRef(new Map),m=b.useRef(()=>{});return b.useEffect(()=>{function p(){d.current=!1,i.current=!1,h.current.clear()}qn(p,"resetOutsideInteraction");function v(){return Array.from(h.current.values()).some(Boolean)}qn(v,"isOutsideInteractionIntercepted");function w(O){if(!d.current)return;const N=O.target;N instanceof Node&&[...a].some(C=>C.contains(N))||h.current.set(O.type,!0),O.type==="click"&&window.setTimeout(()=>{d.current&&m.current()},0)}qn(w,"handleInteractionCapture");function x(O){d.current&&h.current.set(O.type,!1)}qn(x,"handleInteractionBubble");const E=qn(O=>{if(O.target&&!u.current){let N=function(){n.removeEventListener("click",m.current);const C=v();p(),C||OS(lie,l,T,{discrete:!0})};if(qn(N,"handleAndDispatchPointerDownOutsideEvent"),!s(O.target)){n.removeEventListener("click",m.current),p(),u.current=!1;return}const T={originalEvent:O};d.current=!0,i.current=r&&O.button===0,h.current.clear(),!r||O.button!==0?N():(n.removeEventListener("click",m.current),m.current=N,n.addEventListener("click",m.current,{once:!0}))}else n.removeEventListener("click",m.current),p();u.current=!1},"handlePointerDown"),_=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const O of _)n.addEventListener(O,w,!0),n.addEventListener(O,x);const k=window.setTimeout(()=>{n.addEventListener("pointerdown",E)},0);return()=>{window.clearTimeout(k),n.removeEventListener("pointerdown",E),n.removeEventListener("click",m.current);for(const O of _)n.removeEventListener(O,w,!0),n.removeEventListener(O,x)}},[n,l,r,i,a,s]),{onPointerDownCapture:qn(()=>u.current=!0,"onPointerDownCapture")}}qn(Gz,"usePointerDownOutside");function Vz(e,t=globalThis==null?void 0:globalThis.document){const n=ty(e),r=b.useRef(!1);return b.useEffect(()=>{const i=qn(a=>{a.target&&!r.current&&OS(cie,n,{originalEvent:a},{discrete:!1})},"handleFocus");return t.addEventListener("focusin",i),()=>t.removeEventListener("focusin",i)},[t,n]),{onFocusCapture:qn(()=>r.current=!0,"onFocusCapture"),onBlurCapture:qn(()=>r.current=!1,"onBlurCapture")}}qn(Vz,"useFocusOutside");function g1(){const e=new CustomEvent(p1);document.dispatchEvent(e)}qn(g1,"dispatchUpdate");function OS(e,t,n,{discrete:r}){const i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?Kz(i,a):i.dispatchEvent(a)}qn(OS,"handleAndDispatchCustomEvent");var hie=Object.defineProperty,NS=(e,t)=>hie(e,"name",{value:t,configurable:!0}),Mp=0,da=null;function mie(e){return CS(),e.children}NS(mie,"FocusGuards");function CS(){b.useEffect(()=>{da||(da={start:v1(),end:v1()});const{start:e,end:t}=da;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),Mp++,()=>{Mp===1&&(da==null||da.start.remove(),da==null||da.end.remove(),da=null),Mp=Math.max(0,Mp-1)}},[])}NS(CS,"useFocusGuards");function v1(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}NS(v1,"createFocusGuard");var pie=Object.defineProperty,gie=(e,t)=>pie(e,"name",{value:t,configurable:!0});function y1(e){const t=b.useRef(e);return b.useEffect(()=>{t.current=e}),b.useMemo(()=>((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)}),[])}gie(y1,"useCallbackRef");var vie=Object.defineProperty,xr=(e,t)=>vie(e,"name",{value:t,configurable:!0}),Hx="focusScope.autoFocusOnMount",Kx="focusScope.autoFocusOnUnmount",KM={bubbles:!1,cancelable:!0},yie=b.forwardRef(xr(function(t,n){const{loop:r=!1,trapped:i=!1,onMountAutoFocus:a,onUnmountAutoFocus:s,...l}=t,[u,d]=b.useState(null),h=y1(a),m=y1(s),p=b.useRef(null),v=od(n,d),w=b.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;b.useEffect(()=>{if(i){let E=function(N){if(w.paused||!u)return;const T=N.target;u.contains(T)?p.current=T:uo(p.current,{select:!0})},_=function(N){if(w.paused||!u)return;const T=N.relatedTarget;T!==null&&(u.contains(T)||uo(p.current,{select:!0}))},k=function(N){if(document.activeElement===document.body)for(const C of N)C.removedNodes.length>0&&uo(u)};xr(E,"handleFocusIn"),xr(_,"handleFocusOut"),xr(k,"handleMutations"),document.addEventListener("focusin",E),document.addEventListener("focusout",_);const O=new MutationObserver(k);return u&&O.observe(u,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",E),document.removeEventListener("focusout",_),O.disconnect()}}},[i,u,w.paused]),b.useEffect(()=>{if(u){qM.add(w);const E=document.activeElement;if(!u.contains(E)){const k=new CustomEvent(Hx,KM);u.addEventListener(Hx,h),u.dispatchEvent(k),k.defaultPrevented||(Wz(Jz(TS(u)),{select:!0}),document.activeElement===E&&uo(u))}return()=>{u.removeEventListener(Hx,h),setTimeout(()=>{const k=new CustomEvent(Kx,KM);u.addEventListener(Kx,m),u.dispatchEvent(k),k.defaultPrevented||uo(E??document.body,{select:!0}),u.removeEventListener(Kx,m),qM.remove(w)},0)}}},[u,h,m,w]);const x=b.useCallback(E=>{if(!r&&!i||w.paused)return;const _=E.key==="Tab"&&!E.altKey&&!E.ctrlKey&&!E.metaKey,k=document.activeElement;if(_&&k){const O=E.currentTarget,[N,T]=Yz(O);N&&T?!E.shiftKey&&k===T?(E.preventDefault(),r&&uo(N,{select:!0})):E.shiftKey&&k===N&&(E.preventDefault(),r&&uo(T,{select:!0})):k===O&&E.preventDefault()}},[r,i,w.paused]);return y.jsx(ey.div,{tabIndex:-1,...l,ref:v,onKeyDown:x})},"FocusScope"));function Wz(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(uo(r,{select:t}),document.activeElement!==n)return}xr(Wz,"focusFirst");function Yz(e){const t=TS(e),n=b1(t,e),r=b1(t.reverse(),e);return[n,r]}xr(Yz,"getTabbableEdges");function TS(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:xr(r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;n.nextNode();)t.push(n.currentNode);return t}xr(TS,"getTabbableCandidates");function b1(e,t){const n=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):Xz(r,{upTo:t})))return r}xr(b1,"findVisible");function Xz(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}xr(Xz,"isHidden");function Zz(e){return e instanceof HTMLInputElement&&"select"in e}xr(Zz,"isSelectableInput");function uo(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Zz(e)&&t&&e.select()}}xr(uo,"focus");var qM=Qz();function Qz(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=x1(e,t),e.unshift(t)},remove(t){var n;e=x1(e,t),(n=e[0])==null||n.resume()}}}xr(Qz,"createFocusScopesStack");function x1(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}xr(x1,"arrayRemove");function Jz(e){return e.filter(t=>t.tagName!=="A")}xr(Jz,"removeLinks");var bie=globalThis!=null&&globalThis.document?b.useLayoutEffect:()=>{},xie=Object.defineProperty,wie=(e,t)=>xie(e,"name",{value:t,configurable:!0}),Eie=ja[" useId ".trim().toString()]||(()=>{}),Sie=0;function e$(e){const[t,n]=b.useState(Eie());return bie(()=>{e||n(r=>r??String(Sie++))},[e]),e||(t?`radix-${t}`:"")}wie(e$,"useId");const _ie=["top","right","bottom","left"],Fs=Math.min,xo=Math.max,jg=Math.round,Ip=Math.floor,wo=e=>({x:e,y:e}),Aie={left:"right",right:"left",bottom:"top",top:"bottom"};function t$(e,t,n){return xo(e,Fs(t,n))}function Co(e,t){return typeof e=="function"?e(t):e}function Hs(e){return e.split("-")[0]}function sd(e){return e.split("-")[1]}function MS(e){return e==="x"?"y":"x"}function IS(e){return e==="y"?"height":"width"}function wa(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function RS(e){return MS(wa(e))}function kie(e,t,n){n===void 0&&(n=!1);const r=sd(e),i=RS(e),a=IS(i);let s=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(s=Lg(s)),[s,Lg(s)]}function Oie(e){const t=Lg(e);return[w1(e),t,w1(t)]}function w1(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const GM=["left","right"],VM=["right","left"],Nie=["top","bottom"],Cie=["bottom","top"];function Tie(e,t,n){switch(e){case"top":case"bottom":return n?t?VM:GM:t?GM:VM;case"left":case"right":return t?Nie:Cie;default:return[]}}function Mie(e,t,n,r){const i=sd(e);let a=Tie(Hs(e),n==="start",r);return i&&(a=a.map(s=>s+"-"+i),t&&(a=a.concat(a.map(w1)))),a}function Lg(e){const t=Hs(e);return Aie[t]+e.slice(t.length)}function Iie(e){var t,n,r,i;return{top:(t=e.top)!=null?t:0,right:(n=e.right)!=null?n:0,bottom:(r=e.bottom)!=null?r:0,left:(i=e.left)!=null?i:0}}function n$(e){return typeof e!="number"?Iie(e):{top:e,right:e,bottom:e,left:e}}function zg(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function WM(e,t,n){let{reference:r,floating:i}=e;const a=wa(t),s=RS(t),l=IS(s),u=Hs(t),d=a==="y",h=r.x+r.width/2-i.width/2,m=r.y+r.height/2-i.height/2,p=r[l]/2-i[l]/2;let v;switch(u){case"top":v={x:h,y:r.y-i.height};break;case"bottom":v={x:h,y:r.y+r.height};break;case"right":v={x:r.x+r.width,y:m};break;case"left":v={x:r.x-i.width,y:m};break;default:v={x:r.x,y:r.y}}const w=sd(t);return w&&(v[s]+=p*(w==="end"?1:-1)*(n&&d?-1:1)),v}async function Rie(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:a,rects:s,elements:l,strategy:u}=e,{boundary:d="clippingAncestors",rootBoundary:h="viewport",elementContext:m="floating",altBoundary:p=!1,padding:v=0}=Co(t,e),w=n$(v),E=l[p?m==="floating"?"reference":"floating":m],_=zg(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(E)))==null||n?E:E.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(l.floating)),boundary:d,rootBoundary:h,strategy:u})),k=m==="floating"?{x:r,y:i,width:s.floating.width,height:s.floating.height}:s.reference,O=await(a.getOffsetParent==null?void 0:a.getOffsetParent(l.floating)),N=await(a.isElement==null?void 0:a.isElement(O))&&await(a.getScale==null?void 0:a.getScale(O))||{x:1,y:1},T=zg(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:k,offsetParent:O,strategy:u}):k);return{top:(_.top-T.top+w.top)/N.y,bottom:(T.bottom-_.bottom+w.bottom)/N.y,left:(_.left-T.left+w.left)/N.x,right:(T.right-_.right+w.right)/N.x}}const Pie=50,Die=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:a=[],platform:s}=n,l=s.detectOverflow?s:{...s,detectOverflow:Rie},u=await(s.isRTL==null?void 0:s.isRTL(t));let d=await s.getElementRects({reference:e,floating:t,strategy:i}),{x:h,y:m}=WM(d,r,u),p=r,v=0;const w={};for(let x=0;x<a.length;x++){const E=a[x];if(!E)continue;const{name:_,fn:k}=E,{x:O,y:N,data:T,reset:C}=await k({x:h,y:m,initialPlacement:r,placement:p,strategy:i,middlewareData:w,rects:d,platform:l,elements:{reference:e,floating:t}});h=O??h,m=N??m,w[_]={...w[_],...T},C&&v<Pie&&(v++,typeof C=="object"&&(C.placement&&(p=C.placement),C.rects&&(d=C.rects===!0?await s.getElementRects({reference:e,floating:t,strategy:i}):C.rects),{x:h,y:m}=WM(d,p,u)),x=-1)}return{x:h,y:m,placement:p,strategy:i,middlewareData:w}},jie=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:a,platform:s,elements:l,middlewareData:u}=t,{element:d,padding:h=0}=Co(e,t)||{};if(d==null)return{};const m=n$(h),p={x:n,y:r},v=RS(i),w=IS(v),x=await s.getDimensions(d),E=v==="y",_=E?"top":"left",k=E?"bottom":"right",O=E?"clientHeight":"clientWidth",N=a.reference[w]+a.reference[v]-p[v]-a.floating[w],T=p[v]-a.reference[v],C=await(s.getOffsetParent==null?void 0:s.getOffsetParent(d));let M=C?C[O]:0;(!M||!await(s.isElement==null?void 0:s.isElement(C)))&&(M=l.floating[O]||a.floating[w]);const D=N/2-T/2,L=M/2-x[w]/2-1,R=Fs(m[_],L),H=Fs(m[k],L),P=M-x[w]-H,q=M/2-x[w]/2+D,K=t$(R,q,P),X=!u.arrow&&sd(i)!=null&&q!==K&&a.reference[w]/2-(q<R?R:H)-x[w]/2<0,F=X?q<R?q-R:q-P:0;return{[v]:p[v]+F,data:{[v]:K,centerOffset:q-K-F,...X&&{alignmentOffset:F}},reset:X}}}),Lie=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:a,rects:s,initialPlacement:l,platform:u,elements:d}=t,{mainAxis:h=!0,crossAxis:m=!0,fallbackPlacements:p,fallbackStrategy:v="bestFit",fallbackAxisSideDirection:w="none",flipAlignment:x=!0,...E}=Co(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const _=Hs(i),k=wa(l),O=Hs(l)===l,N=await(u.isRTL==null?void 0:u.isRTL(d.floating)),T=p||(O||!x?[Lg(l)]:Oie(l)),C=w!=="none";!p&&C&&T.push(...Mie(l,x,w,N));const M=[l,...T],D=await u.detectOverflow(t,E),L=[];let R=((r=a.flip)==null?void 0:r.overflows)||[];if(h&&L.push(D[_]),m){const K=kie(i,s,N);L.push(D[K[0]],D[K[1]])}if(R=[...R,{placement:i,overflows:L}],!L.every(K=>K<=0)){var H,P;const K=(((H=a.flip)==null?void 0:H.index)||0)+1,X=M[K];if(X&&(!(m==="alignment"?k!==wa(X):!1)||R.every(U=>wa(U.placement)===k?U.overflows[0]>0:!0)))return{data:{index:K,overflows:R},reset:{placement:X}};let F=(P=R.filter(Y=>Y.overflows[0]<=0).sort((Y,U)=>Y.overflows[1]-U.overflows[1])[0])==null?void 0:P.placement;if(!F)switch(v){case"bestFit":{var q;const Y=(q=R.filter(U=>{if(C){const G=wa(U.placement);return G===k||G==="y"}return!0}).map(U=>[U.placement,U.overflows.filter(G=>G>0).reduce((G,$)=>G+$,0)]).sort((U,G)=>U[1]-G[1])[0])==null?void 0:q[0];Y&&(F=Y);break}case"initialPlacement":F=l;break}if(i!==F)return{reset:{placement:F}}}return{}}}};function YM(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function XM(e){return _ie.some(t=>e[t]>=0)}const zie=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:i="referenceHidden",...a}=Co(e,t);switch(i){case"referenceHidden":{const s=await r.detectOverflow(t,{...a,elementContext:"reference"}),l=YM(s,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:XM(l)}}}case"escaped":{const s=await r.detectOverflow(t,{...a,altBoundary:!0}),l=YM(s,n.floating);return{data:{escapedOffsets:l,escaped:XM(l)}}}default:return{}}}}},r$=new Set(["left","top"]);async function $ie(e,t){const{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),s=Hs(n),l=sd(n),u=wa(n)==="y",d=r$.has(s)?-1:1,h=a&&u?-1:1,m=Co(t,e);let{mainAxis:p,crossAxis:v,alignmentAxis:w}=typeof m=="number"?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return l&&typeof w=="number"&&(v=l==="end"?w*-1:w),u?{x:v*h,y:p*d}:{x:p*d,y:v*h}}const Bie=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:a,placement:s,middlewareData:l}=t,u=await $ie(t,e);return s===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:i+u.x,y:a+u.y,data:{...u,placement:s}}}}},Uie=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i,platform:a}=t,{mainAxis:s=!0,crossAxis:l=!1,limiter:u={fn:k=>{let{x:O,y:N}=k;return{x:O,y:N}}},...d}=Co(e,t),h={x:n,y:r},m=await a.detectOverflow(t,d),p=wa(i),v=MS(p);let w=h[v],x=h[p];const E=(k,O)=>t$(O+m[k==="y"?"top":"left"],O,O-m[k==="y"?"bottom":"right"]);s&&(w=E(v,w)),l&&(x=E(p,x));const _=u.fn({...t,[v]:w,[p]:x});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[v]:s,[p]:l}}}}}},Fie=function(e){return e===void 0&&(e={}),{options:e,fn(t){var n,r;const{x:i,y:a,placement:s,rects:l,middlewareData:u}=t,{offset:d=0,mainAxis:h=!0,crossAxis:m=!0}=Co(e,t),p={x:i,y:a},v=wa(s),w=MS(v);let x=p[w],E=p[v];const _=Co(d,t),k=typeof _=="number"?{mainAxis:_,crossAxis:0}:{mainAxis:(n=_.mainAxis)!=null?n:0,crossAxis:(r=_.crossAxis)!=null?r:0};if(h){const T=w==="y"?"height":"width",C=l.reference[w]-l.floating[T]+k.mainAxis,M=l.reference[w]+l.reference[T]-k.mainAxis;x<C?x=C:x>M&&(x=M)}if(m){var O,N;const T=w==="y"?"width":"height",C=r$.has(Hs(s)),M=l.reference[v]-l.floating[T]+(C&&((O=u.offset)==null?void 0:O[v])||0)+(C?0:k.crossAxis),D=l.reference[v]+l.reference[T]+(C?0:((N=u.offset)==null?void 0:N[v])||0)-(C?k.crossAxis:0);E<M?E=M:E>D&&(E=D)}return{[w]:x,[v]:E}}}},Hie=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:n,rects:r,platform:i,elements:a}=t,{apply:s=()=>{},...l}=Co(e,t),u=await i.detectOverflow(t,l),d=Hs(n),h=sd(n),m=wa(n)==="y",{width:p,height:v}=r.floating;let w,x;d==="top"||d==="bottom"?(w=d,x=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(x=d,w=h==="end"?"top":"bottom");const E=v-u.top-u.bottom,_=p-u.left-u.right,k=Fs(v-u[w],E),O=Fs(p-u[x],_),N=t.middlewareData.shift,T=!N;let C=k,M=O;N!=null&&N.enabled.x&&(M=_),N!=null&&N.enabled.y&&(C=E),T&&!h&&(m?M=p-2*xo(u.left,u.right):C=v-2*xo(u.top,u.bottom)),await s({...t,availableWidth:M,availableHeight:C});const D=await i.getDimensions(a.floating);return p!==D.width||v!==D.height?{reset:{rects:!0}}:{}}}};function ny(){return typeof window<"u"}function ld(e){return i$(e)?(e.nodeName||"").toLowerCase():"#document"}function Ur(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function jo(e){var t;return(t=(i$(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function i$(e){return ny()?e instanceof Node||e instanceof Ur(e).Node:!1}function Ca(e){return ny()?e instanceof Element||e instanceof Ur(e).Element:!1}function Js(e){return ny()?e instanceof HTMLElement||e instanceof Ur(e).HTMLElement:!1}function ZM(e){return!ny()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ur(e).ShadowRoot}function ry(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=Ta(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function Kie(e){return/^(table|td|th)$/.test(ld(e))}function iy(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const qie=/transform|translate|scale|rotate|perspective|filter/,Gie=/paint|layout|strict|content/,Al=e=>!!e&&e!=="none";let qx;function PS(e){const t=Ca(e)?Ta(e):e;return Al(t.transform)||Al(t.translate)||Al(t.scale)||Al(t.rotate)||Al(t.perspective)||!DS()&&(Al(t.backdropFilter)||Al(t.filter))||qie.test(t.willChange||"")||Gie.test(t.contain||"")}function Vie(e){let t=ec(e);for(;Js(t)&&!rh(t);){if(PS(t))return t;if(iy(t))return null;t=ec(t)}return null}function DS(){return qx==null&&(qx=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),qx}function rh(e){return/^(html|body|#document)$/.test(ld(e))}function Ta(e){return Ur(e).getComputedStyle(e)}function ay(e){return Ca(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ec(e){if(ld(e)==="html")return e;const t=e.assignedSlot||e.parentNode||ZM(e)&&e.host||jo(e);return ZM(t)?t.host:t}function a$(e){const t=ec(e);return rh(t)?(e.ownerDocument||e).body:Js(t)&&ry(t)?t:a$(t)}function ih(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=a$(e),a=i===((r=e.ownerDocument)==null?void 0:r.body),s=Ur(i);if(a){const l=E1(s);return t.concat(s,s.visualViewport||[],ry(i)?i:[],l&&n?ih(l):[])}else return t.concat(i,ih(i,[],n))}function E1(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function o$(e){const t=Ta(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=Js(e),a=i?e.offsetWidth:n,s=i?e.offsetHeight:r,l=jg(n)!==a||jg(r)!==s;return l&&(n=a,r=s),{width:n,height:r,$:l}}function jS(e){return Ca(e)?e:e.contextElement}function Mu(e){const t=jS(e);if(!Js(t))return wo(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:a}=o$(t);let s=(a?jg(n.width):n.width)/r,l=(a?jg(n.height):n.height)/i;return(!s||!Number.isFinite(s))&&(s=1),(!l||!Number.isFinite(l))&&(l=1),{x:s,y:l}}const Wie=wo(0);function s$(e){const t=Ur(e);return!DS()||!t.visualViewport?Wie:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Yie(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===Ur(e)}function tc(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),a=jS(e);let s=wo(1);t&&(r?Ca(r)&&(s=Mu(r)):s=Mu(e));const l=Yie(a,n,r)?s$(a):wo(0);let u=(i.left+l.x)/s.x,d=(i.top+l.y)/s.y,h=i.width/s.x,m=i.height/s.y;if(a&&r){const p=Ur(a),v=Ca(r)?Ur(r):r;let w=p,x=E1(w);for(;x&&v!==w;){const E=Mu(x),_=x.getBoundingClientRect(),k=Ta(x),O=_.left+(x.clientLeft+parseFloat(k.paddingLeft))*E.x,N=_.top+(x.clientTop+parseFloat(k.paddingTop))*E.y;u*=E.x,d*=E.y,h*=E.x,m*=E.y,u+=O,d+=N,w=Ur(x),x=E1(w)}}return zg({width:h,height:m,x:u,y:d})}function oy(e,t){const n=ay(e).scrollLeft;return t?t.left+n:tc(jo(e)).left+n}function l$(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-oy(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function Xie(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const a=i==="fixed",s=jo(r),l=t?iy(t.floating):!1;if(r===s||l&&a)return n;let u={scrollLeft:0,scrollTop:0},d=wo(1);const h=wo(0),m=Js(r);if((m||!a)&&((ld(r)!=="body"||ry(s))&&(u=ay(r)),m)){const v=tc(r);d=Mu(r),h.x=v.x+r.clientLeft,h.y=v.y+r.clientTop}const p=s&&!m&&!a?l$(s,u):wo(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-u.scrollLeft*d.x+h.x+p.x,y:n.y*d.y-u.scrollTop*d.y+h.y+p.y}}function Zie(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function Qie(e){const t=ay(e),n=e.ownerDocument.body,r=xo(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=xo(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let a=-t.scrollLeft+oy(e);const s=-t.scrollTop;return Ta(n).direction==="rtl"&&(a+=xo(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:s}}const Jie=25;function eae(e,t,n){n===void 0&&(n="viewport");const r=n==="layoutViewport",i=Ur(e),a=jo(e),s=i.visualViewport;let l=a.clientWidth,u=a.clientHeight,d=0,h=0;if(s){const p=!DS()||t==="fixed";r?p||(d=-s.offsetLeft,h=-s.offsetTop):(l=s.width,u=s.height,p&&(d=s.offsetLeft,h=s.offsetTop))}if(oy(a)<=0){const p=a.ownerDocument,v=p.body,w=getComputedStyle(v),x=p.compatMode==="CSS1Compat"&&parseFloat(w.marginLeft)+parseFloat(w.marginRight)||0,E=Math.abs(a.clientWidth-v.clientWidth-x),_=getComputedStyle(a).scrollbarGutter==="stable both-edges"?E/2:E;_<=Jie&&(l-=_)}return{width:l,height:u,x:d,y:h}}function tae(e,t){const n=tc(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Mu(e),s=e.clientWidth*a.x,l=e.clientHeight*a.y,u=i*a.x,d=r*a.y;return{width:s,height:l,x:u,y:d}}function QM(e,t,n){let r;if(t==="viewport"||t==="layoutViewport")r=eae(e,n,t);else if(t==="document")r=Qie(jo(e));else if(Ca(t))r=tae(t,n);else{const i=s$(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return zg(r)}function nae(e,t){const n=t.get(e);if(n)return n;let r=ih(e,[],!1).filter(l=>Ca(l)&&ld(l)!=="body"),i=null;const a=Ta(e).position==="fixed";let s=a?ec(e):e;for(;Ca(s)&&!rh(s);){const l=Ta(s),u=PS(s),d=i?i.position:a?"fixed":"";!u&&(d==="fixed"||d==="absolute"&&l.position==="static")?r=r.filter(m=>m!==s):i=l,s=ec(s)}return t.set(e,r),r}function rae(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const s=[...n==="clippingAncestors"?iy(t)?[]:nae(t,this._c):[].concat(n),r],l=QM(t,s[0],i);let u=l.top,d=l.right,h=l.bottom,m=l.left;for(let p=1;p<s.length;p++){const v=QM(t,s[p],i);u=xo(v.top,u),d=Fs(v.right,d),h=Fs(v.bottom,h),m=xo(v.left,m)}return{width:d-m,height:h-u,x:m,y:u}}function iae(e){const{width:t,height:n}=o$(e);return{width:t,height:n}}function aae(e,t,n){const r=Js(t),i=jo(t),a=n==="fixed",s=tc(e,!0,a,t);let l={scrollLeft:0,scrollTop:0};const u=wo(0);if((r||!a)&&((ld(t)!=="body"||ry(i))&&(l=ay(t)),r)){const p=tc(t,!0,a,t);u.x=p.x+t.clientLeft,u.y=p.y+t.clientTop}!r&&i&&(u.x=oy(i));const d=i&&!r&&!a?l$(i,l):wo(0),h=s.left+l.scrollLeft-u.x-d.x,m=s.top+l.scrollTop-u.y-d.y;return{x:h,y:m,width:s.width,height:s.height}}function Gx(e){return Ta(e).position==="static"}function JM(e,t){if(!Js(e)||Ta(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return jo(e)===n&&(n=n.ownerDocument.body),n}function c$(e,t){const n=Ur(e);if(iy(e))return n;if(!Js(e)){let i=ec(e);for(;i&&!rh(i);){if(Ca(i)&&!Gx(i))return i;i=ec(i)}return n}let r=JM(e,t);for(;r&&Kie(r)&&Gx(r);)r=JM(r,t);return r&&rh(r)&&Gx(r)&&!PS(r)?n:r||Vie(e)||n}const oae=async function(e){const t=this.getOffsetParent||c$,n=this.getDimensions,r=await n(e.floating);return{reference:aae(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function sae(e){return Ta(e).direction==="rtl"}const lae={convertOffsetParentRelativeRectToViewportRelativeRect:Xie,getDocumentElement:jo,getClippingRect:rae,getOffsetParent:c$,getElementRects:oae,getClientRects:Zie,getDimensions:iae,getScale:Mu,isElement:Ca,isRTL:sae};function u$(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function cae(e,t,n){let r=null,i;const a=jo(e);function s(){var h;clearTimeout(i),(h=r)==null||h.disconnect(),r=null}function l(h,m){h===void 0&&(h=!1),m===void 0&&(m=1),s();const p=e.getBoundingClientRect(),{left:v,top:w,width:x,height:E}=p;if(h||t(),!x||!E)return;const _=Ip(w),k=Ip(a.clientWidth-(v+x)),O=Ip(a.clientHeight-(w+E)),N=Ip(v),C={rootMargin:-_+"px "+-k+"px "+-O+"px "+-N+"px",threshold:xo(0,Fs(1,m))||1};let M=!0;function D(L){const R=L[0].intersectionRatio;if(!u$(p,e.getBoundingClientRect()))return l();if(R!==m){if(!M)return l();R?l(!1,R):i=setTimeout(()=>{l(!1,1e-7)},1e3)}M=!1}try{r=new IntersectionObserver(D,{...C,root:a.ownerDocument})}catch{r=new IntersectionObserver(D,C)}r.observe(e)}const u=Ur(e),d=()=>l(n);return u.addEventListener("resize",d),l(!0),()=>{u.removeEventListener("resize",d),s()}}function uae(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,d=jS(e),h=i||a?[...d?ih(d):[],...t?ih(t):[]]:[];h.forEach(_=>{i&&_.addEventListener("scroll",n),a&&_.addEventListener("resize",n)});const m=d&&l?cae(d,n,a):null;let p=-1,v=null;s&&(v=new ResizeObserver(_=>{let[k]=_;k&&k.target===d&&v&&t&&(v.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var O;(O=v)==null||O.observe(t)})),n()}),d&&!u&&v.observe(d),t&&v.observe(t));let w,x=u?tc(e):null;u&&E();function E(){const _=tc(e);x&&!u$(x,_)&&n(),x=_,w=requestAnimationFrame(E)}return n(),()=>{var _;h.forEach(k=>{i&&k.removeEventListener("scroll",n),a&&k.removeEventListener("resize",n)}),m==null||m(),(_=v)==null||_.disconnect(),v=null,u&&cancelAnimationFrame(w)}}const dae=Bie,fae=Uie,hae=Lie,mae=Hie,pae=zie,eI=jie,gae=Fie,vae=(e,t,n)=>{const r=new Map,i=n??{},a={...lae,...i.platform,_c:r};return Die(e,t,{...i,platform:a})};var yae=typeof document<"u",bae=function(){},sg=yae?b.useLayoutEffect:bae;function $g(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,r,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!$g(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){const a=i[r];if(!(a==="_owner"&&e.$$typeof)&&!$g(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function d$(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function tI(e,t){const n=d$(e);return Math.round(t*n)/n}function Vx(e){const t=b.useRef(e);return sg(()=>{t.current=e}),t}function xae(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:a,floating:s}={},transform:l=!0,whileElementsMounted:u,open:d}=e,[h,m]=b.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,v]=b.useState(r);$g(p,r)||v(r);const[w,x]=b.useState(null),[E,_]=b.useState(null),k=b.useCallback(U=>{U!==C.current&&(C.current=U,x(U))},[]),O=b.useCallback(U=>{U!==M.current&&(M.current=U,_(U))},[]),N=a||w,T=s||E,C=b.useRef(null),M=b.useRef(null),D=b.useRef(h),L=u!=null,R=Vx(u),H=Vx(i),P=Vx(d),q=b.useCallback(()=>{if(!C.current||!M.current)return;const U={placement:t,strategy:n,middleware:p};H.current&&(U.platform=H.current),vae(C.current,M.current,U).then(G=>{const $={...G,isPositioned:P.current!==!1};K.current&&!$g(D.current,$)&&(D.current=$,La.flushSync(()=>{m($)}))})},[p,t,n,H,P]);sg(()=>{d===!1&&D.current.isPositioned&&(D.current.isPositioned=!1,m(U=>({...U,isPositioned:!1})))},[d]);const K=b.useRef(!1);sg(()=>(K.current=!0,()=>{K.current=!1}),[]),sg(()=>{if(N&&(C.current=N),T&&(M.current=T),N&&T){if(R.current)return R.current(N,T,q);q()}},[N,T,q,R,L]);const X=b.useMemo(()=>({reference:C,floating:M,setReference:k,setFloating:O}),[k,O]),F=b.useMemo(()=>({reference:N,floating:T}),[N,T]),Y=b.useMemo(()=>{const U={position:n,left:0,top:0};if(!F.floating)return U;const G=tI(F.floating,h.x),$=tI(F.floating,h.y);return l?{...U,transform:"translate("+G+"px, "+$+"px)",...d$(F.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:G,top:$}},[n,l,F.floating,h.x,h.y]);return b.useMemo(()=>({...h,update:q,refs:X,elements:F,floatingStyles:Y}),[h,q,X,F,Y])}const wae=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:i}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?eI({element:r.current,padding:i}).fn(n):{}:r?eI({element:r,padding:i}).fn(n):{}}}},Eae=(e,t)=>{const n=dae(e);return{name:n.name,fn:n.fn,options:[e,t]}},Sae=(e,t)=>{const n=fae(e);return{name:n.name,fn:n.fn,options:[e,t]}},_ae=(e,t)=>({fn:gae(e).fn,options:[e,t]}),Aae=(e,t)=>{const n=hae(e);return{name:n.name,fn:n.fn,options:[e,t]}},kae=(e,t)=>{const n=mae(e);return{name:n.name,fn:n.fn,options:[e,t]}},Oae=(e,t)=>{const n=pae(e);return{name:n.name,fn:n.fn,options:[e,t]}},Nae=(e,t)=>{const n=wae(e);return{name:n.name,fn:n.fn,options:[e,t]}};var Cae=Object.defineProperty,LS=(e,t)=>Cae(e,"name",{value:t,configurable:!0});function S1(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}LS(S1,"setRef");function f$(...e){return t=>{let n=!1;const r=e.map(i=>{const a=S1(i,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let i=0;i<r.length;i++){const a=r[i];typeof a=="function"?a():S1(e[i],null)}}}}LS(f$,"composeRefs");function sy(...e){return b.useCallback(f$(...e),e)}LS(sy,"useComposedRefs");var Tae=Object.defineProperty,Ci=(e,t)=>Tae(e,"name",{value:t,configurable:!0});function Mae(e,t){const n=b.createContext(t);n.displayName=e+"Context";const r=Ci(a=>{const{children:s,...l}=a,u=b.useMemo(()=>l,Object.values(l));return y.jsx(n.Provider,{value:u,children:s})},"Provider");r.displayName=e+"Provider";function i(a,s={}){const{optional:l=!1}=s,u=b.useContext(n);if(u)return u;if(t!==void 0)return t;if(!l)throw new Error(`\`${a}\` must be used within \`${e}\``)}return Ci(i,"useContext"),[r,i]}Ci(Mae,"createContext");function h$(e,t=[]){let n=[];function r(a,s){const l=b.createContext(s);l.displayName=a+"Context";const u=n.length;n=[...n,s];const d=Ci(m=>{var _;const{scope:p,children:v,...w}=m,x=((_=p==null?void 0:p[e])==null?void 0:_[u])||l,E=b.useMemo(()=>w,Object.values(w));return y.jsx(x.Provider,{value:E,children:v})},"Provider");d.displayName=a+"Provider";function h(m,p,v={}){var _;const{optional:w=!1}=v,x=((_=p==null?void 0:p[e])==null?void 0:_[u])||l,E=b.useContext(x);if(E)return E;if(s!==void 0)return s;if(!w)throw new Error(`\`${m}\` must be used within \`${a}\``)}return Ci(h,"useContext"),[d,h]}Ci(r,"createContext");const i=Ci(()=>{const a=n.map(s=>b.createContext(s));return Ci(function(l){const u=(l==null?void 0:l[e])||a;return b.useMemo(()=>({[`__scope${e}`]:{...l,[e]:u}}),[l,u])},"useScope")},"createScope");return i.scopeName=e,[r,m$(i,...t)]}Ci(h$,"createContextScope");function m$(...e){const t=e[0];if(e.length===1)return t;const n=Ci(()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return Ci(function(a){const s=r.reduce((l,{useScope:u,scopeName:d})=>{const m=u(a)[`__scope${d}`];return{...l,...m}},{});return b.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])},"useComposedScopes")},"createScope");return n.scopeName=t.scopeName,n}Ci(m$,"composeContextScopes");var Iae=Object.defineProperty,ta=(e,t)=>Iae(e,"name",{value:t,configurable:!0});function p$(e){const t=b.forwardRef((n,r)=>{let{children:i,...a}=n,s=null,l=!1;const u=[];_1(i)&&typeof Rp=="function"&&(i=Rp(i._payload)),b.Children.forEach(i,p=>{var v;if(b$(p)){l=!0;const w=p;let x="child"in w.props?w.props.child:w.props.children;_1(x)&&typeof Rp=="function"&&(x=Rp(x._payload)),s=Pae(w,x),u.push((v=s==null?void 0:s.props)==null?void 0:v.children)}else u.push(p)}),s?s=b.cloneElement(s,void 0,u):!l&&b.Children.count(i)===1&&b.isValidElement(i)&&(s=i);const d=s?y$(s):void 0,h=sy(r,d);if(!s){if(i||i===0)throw new Error(l?Lae(e):jae(e));return i}const m=v$(a,s.props??{});return s.type!==b.Fragment&&(m.ref=r?h:d),b.cloneElement(s,m)});return t.displayName=`${e}.Slot`,t}ta(p$,"createSlot");var g$=Symbol.for("radix.slottable");function Rae(e){const t=ta(n=>"child"in n?n.children(n.child):n.children,"Slottable");return t.displayName=`${e}.Slottable`,t.__radixId=g$,t}ta(Rae,"createSlottable");var Pae=ta((e,t)=>{if("child"in e.props){const n=e.props.child;return b.isValidElement(n)?b.cloneElement(n,void 0,e.props.children(n.props.children)):null}return b.isValidElement(t)?t:null},"getSlottableElementFromSlottable");function v$(e,t){const n={...t};for(const r in t){const i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...l)=>{const u=a(...l);return i(...l),u}:i&&(n[r]=i):r==="style"?n[r]={...i,...a}:r==="className"&&(n[r]=[i,a].filter(Boolean).join(" "))}return{...e,...n}}ta(v$,"mergeProps");function y$(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}ta(y$,"getElementRef");function b$(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===g$}ta(b$,"isSlottable");var Dae=Symbol.for("react.lazy");function _1(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Dae&&"_payload"in e&&x$(e._payload)}ta(_1,"isLazyComponent");function x$(e){return typeof e=="object"&&e!==null&&"then"in e}ta(x$,"isPromiseLike");var jae=ta(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),Lae=ta(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),Rp=ja[" use ".trim().toString()],zae=Object.defineProperty,$ae=(e,t)=>zae(e,"name",{value:t,configurable:!0}),Bae=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],w$=Bae.reduce((e,t)=>{const n=p$(`Primitive.${t}`),r=b.forwardRef((i,a)=>{const{asChild:s,...l}=i,u=s?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),y.jsx(u,{...l,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Uae(e,t){e&&La.flushSync(()=>e.dispatchEvent(t))}$ae(Uae,"dispatchDiscreteCustomEvent");var Fae=Object.defineProperty,Hae=(e,t)=>Fae(e,"name",{value:t,configurable:!0});function E$(e){const t=b.useRef(e);return b.useEffect(()=>{t.current=e}),b.useMemo(()=>((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)}),[])}Hae(E$,"useCallbackRef");var Wx=globalThis!=null&&globalThis.document?b.useLayoutEffect:()=>{},Kae=globalThis!=null&&globalThis.document?b.useLayoutEffect:()=>{},qae=Object.defineProperty,Gae=(e,t)=>qae(e,"name",{value:t,configurable:!0});function S$(e){const[t,n]=b.useState(void 0);return Kae(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const a=i[0];let s,l;if("borderBoxSize"in a){const u=a.borderBoxSize,d=Array.isArray(u)?u[0]:u;s=d.inlineSize,l=d.blockSize}else s=e.offsetWidth,l=e.offsetHeight;n({width:s,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}Gae(S$,"useSize");var Vae=Object.defineProperty,js=(e,t)=>Vae(e,"name",{value:t,configurable:!0}),_$="Popper",[A$,k$]=h$(_$),[Wae,O$]=A$(_$),Yae=js(e=>{const{__scopePopper:t,children:n}=e,[r,i]=b.useState(null),[a,s]=b.useState(void 0);return y.jsx(Wae,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:s,children:n})},"Popper"),Xae="PopperAnchor",Zae=b.forwardRef(js(function(t,n){const{__scopePopper:r,virtualRef:i,...a}=t,s=O$(Xae,r),l=b.useRef(null),u=s.onAnchorChange,d=b.useCallback(x=>{l.current=x,x&&u(x)},[u]),h=sy(n,d),m=b.useRef(null);b.useEffect(()=>{if(!i)return;const x=m.current;m.current=i.current,x!==m.current&&u(m.current)});const p=s.placementState&&ly(s.placementState),v=p==null?void 0:p[0],w=p==null?void 0:p[1];return i?null:y.jsx(w$.div,{"data-radix-popper-side":v,"data-radix-popper-align":w,...a,ref:h})},"PopperAnchor")),N$="PopperContent",[Qae,dCe]=A$(N$),Jae=b.forwardRef(js(function(t,n){var fe,Ee,Te,de,nt,He,Ae;const{__scopePopper:r,side:i="bottom",sideOffset:a=0,align:s="center",alignOffset:l=0,arrowPadding:u=0,avoidCollisions:d=!0,collisionBoundary:h=[],collisionPadding:m=0,sticky:p="partial",hideWhenDetached:v=!1,updatePositionStrategy:w="optimized",onPlaced:x,...E}=t,_=O$(N$,r),[k,O]=b.useState(null),N=sy(n,O),[T,C]=b.useState(null),M=S$(T),D=(M==null?void 0:M.width)??0,L=(M==null?void 0:M.height)??0,R=i+(s!=="center"?"-"+s:""),H=typeof m=="number"?m:{top:0,right:0,bottom:0,left:0,...m},P=Array.isArray(h)?h:[h],q=P.length>0,K={padding:H,boundary:P.filter(C$),altBoundary:q},{refs:X,floatingStyles:F,placement:Y,isPositioned:U,middlewareData:G}=xae({strategy:"fixed",placement:R,whileElementsMounted:js((...De)=>uae(...De,{animationFrame:w==="always"}),"whileElementsMounted"),elements:{reference:_.anchor},middleware:[Eae({mainAxis:a+L,alignmentAxis:l}),d&&Sae({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?_ae():void 0,...K}),d&&Aae({...K}),kae({...K,apply:js(({elements:De,rects:Ht,availableWidth:un,availableHeight:Yn})=>{const{width:Or,height:Li}=Ht.reference,ir=De.floating.style;ir.setProperty("--radix-popper-available-width",`${un}px`),ir.setProperty("--radix-popper-available-height",`${Yn}px`),ir.setProperty("--radix-popper-anchor-width",`${Or}px`),ir.setProperty("--radix-popper-anchor-height",`${Li}px`)},"apply")}),T&&Nae({element:T,padding:u}),eoe({arrowWidth:D,arrowHeight:L}),v&&Oae({strategy:"referenceHidden",...K,boundary:q?K.boundary:void 0})]}),$=_.setPlacementState;Wx(()=>($(Y),()=>{$(void 0)}),[Y,$]);const[j,V]=ly(Y),z=E$(x);Wx(()=>{U&&(z==null||z())},[U,z]);const ie=(fe=G.arrow)==null?void 0:fe.x,he=(Ee=G.arrow)==null?void 0:Ee.y,ge=((Te=G.arrow)==null?void 0:Te.centerOffset)!==0,[Se,$e]=b.useState();return Wx(()=>{k&&$e(window.getComputedStyle(k).zIndex)},[k]),y.jsx("div",{ref:X.setFloating,"data-radix-popper-content-wrapper":"",style:{...F,transform:U?F.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Se,"--radix-popper-transform-origin":[(de=G.transformOrigin)==null?void 0:de.x,(nt=G.transformOrigin)==null?void 0:nt.y].join(" "),...((He=G.hide)==null?void 0:He.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:y.jsx(Qae,{scope:r,placedSide:j,placedAlign:V,onArrowChange:C,arrowX:ie,arrowY:he,shouldHideArrow:ge,children:y.jsx(w$.div,{"data-side":j,"data-align":V,...E,ref:N,style:{...E.style,animation:U?(Ae=E.style)==null?void 0:Ae.animation:"none"}})})})},"PopperContent"));function C$(e){return e!==null}js(C$,"isNotNull");var eoe=js(e=>({name:"transformOrigin",options:e,fn(t){var E,_,k;const{placement:n,rects:r,middlewareData:i}=t,s=((E=i.arrow)==null?void 0:E.centerOffset)!==0,l=s?0:e.arrowWidth,u=s?0:e.arrowHeight,[d,h]=ly(n),m={start:"0%",center:"50%",end:"100%"}[h],p=(((_=i.arrow)==null?void 0:_.x)??0)+l/2,v=(((k=i.arrow)==null?void 0:k.y)??0)+u/2;let w="",x="";return d==="bottom"?(w=s?m:`${p}px`,x=`${-u}px`):d==="top"?(w=s?m:`${p}px`,x=`${r.floating.height+u}px`):d==="right"?(w=`${-u}px`,x=s?m:`${v}px`):d==="left"&&(w=`${r.floating.width+u}px`,x=s?m:`${v}px`),{data:{x:w,y:x}}}}),"transformOrigin");function ly(e){const[t,n="center"]=e.split("-");return[t,n]}js(ly,"getSideAndAlignFromPlacement");var toe=Yae,noe=Zae,roe=Jae,ioe=globalThis!=null&&globalThis.document?b.useLayoutEffect:()=>{},aoe=Object.defineProperty,ooe=(e,t)=>aoe(e,"name",{value:t,configurable:!0}),soe=b.forwardRef(ooe(function(t,n){var u;const{container:r,...i}=t,[a,s]=b.useState(!1);ioe(()=>s(!0),[]);const l=r||a&&((u=globalThis==null?void 0:globalThis.document)==null?void 0:u.body);return l?La.createPortal(y.jsx(ey.div,{...i,ref:n}),l):null},"Portal")),nI=globalThis!=null&&globalThis.document?b.useLayoutEffect:()=>{},loe=Object.defineProperty,To=(e,t)=>loe(e,"name",{value:t,configurable:!0});function T$(e,t){return b.useReducer((n,r)=>t[n][r]??n,e)}To(T$,"useStateMachine");var M$=To(e=>{const{present:t,children:n}=e,r=I$(t),i=typeof n=="function"?n({present:r.isPresent}):b.Children.only(n),a=R$(r.ref,P$(i));return typeof n=="function"||r.isPresent?b.cloneElement(i,{ref:a}):null},"Presence");function I$(e){const[t,n]=b.useState(),r=b.useRef(null),i=b.useRef(e),a=b.useRef("none"),s=b.useRef(void 0),l=e?"mounted":"unmounted",[u,d]=T$(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return b.useEffect(()=>{u==="mounted"?(a.current=s.current??xu(r.current),s.current=void 0):a.current="none"},[u]),nI(()=>{const h=r.current,m=i.current;if(m!==e){const v=a.current,w=xu(h);e?(s.current=w,d("MOUNT")):w==="none"||(h==null?void 0:h.display)==="none"?d("UNMOUNT"):d(m&&v!==w?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,d]),nI(()=>{if(t){let h;const m=t.ownerDocument.defaultView??window,p=To(w=>{const E=xu(r.current).includes(CSS.escape(w.animationName));if(w.target===t&&E&&(d("ANIMATION_END"),!i.current)){const _=t.style.animationFillMode;t.style.animationFillMode="forwards",h=m.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=_)})}},"handleAnimationEnd"),v=To(w=>{w.target===t&&(a.current=xu(r.current))},"handleAnimationStart");return t.addEventListener("animationstart",v),t.addEventListener("animationcancel",p),t.addEventListener("animationend",p),()=>{m.clearTimeout(h),t.removeEventListener("animationstart",v),t.removeEventListener("animationcancel",p),t.removeEventListener("animationend",p)}}else d("ANIMATION_END")},[t,d]),{isPresent:["mounted","unmountSuspended"].includes(u),ref:b.useCallback(h=>{if(h){const m=getComputedStyle(h);r.current=m,s.current=xu(m)}else r.current=null;n(h)},[])}}To(I$,"usePresence");function A1(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}To(A1,"setRef");function R$(...e){const t=b.useRef(e);return t.current=e,b.useCallback(n=>{const r=t.current;let i=!1;const a=r.map(s=>{const l=A1(s,n);return!i&&typeof l=="function"&&(i=!0),l});if(i)return()=>{for(let s=0;s<a.length;s++){const l=a[s];typeof l=="function"?l():A1(r[s],null)}}},[])}To(R$,"useStableComposedRefs");function xu(e){return(e==null?void 0:e.animationName)||"none"}To(xu,"getAnimationName");function P$(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}To(P$,"getElementRef");var D$=globalThis!=null&&globalThis.document?b.useLayoutEffect:()=>{},coe=Object.defineProperty,uoe=(e,t)=>coe(e,"name",{value:t,configurable:!0}),rI=ja[" useEffectEvent ".trim().toString()],iI=ja[" useInsertionEffect ".trim().toString()];function j$(e){if(typeof rI=="function")return rI(e);const t=b.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof iI=="function"?iI(()=>{t.current=e}):D$(()=>{t.current=e}),b.useMemo(()=>((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)}),[])}uoe(j$,"useEffectEvent");var doe=Object.defineProperty,Ch=(e,t)=>doe(e,"name",{value:t,configurable:!0}),foe=ja[" useInsertionEffect ".trim().toString()]||D$;function L$({prop:e,defaultProp:t,onChange:n=Ch(()=>{},"onChange"),caller:r}){const[i,a,s]=z$({defaultProp:t,onChange:n}),l=e!==void 0,u=l?e:i,d=b.useCallback(h=>{var m;if(l){const p=$$(h)?h(e):h;p!==e&&((m=s.current)==null||m.call(s,p))}else a(h)},[l,e,a,s]);return[u,d]}Ch(L$,"useControllableState");function z$({defaultProp:e,onChange:t}){const[n,r]=b.useState(e),i=b.useRef(n),a=b.useRef(t);return foe(()=>{a.current=t},[t]),b.useEffect(()=>{var s;i.current!==n&&((s=a.current)==null||s.call(a,n),i.current=n)},[n,i]),[n,r,a]}Ch(z$,"useUncontrolledState");function $$(e){return typeof e=="function"}Ch($$,"isFunction");var aI=Symbol("RADIX:SYNC_STATE");function hoe(e,t,n,r){const{prop:i,defaultProp:a,onChange:s,caller:l}=t,u=i!==void 0,d=j$(s),h=[{...n,state:a}];r&&h.push(r);const[m,p]=b.useReducer((E,_)=>{if(_.type===aI)return{...E,state:_.state};const k=e(E,_);return u&&!Object.is(k.state,E.state)&&d(k.state),k},...h),v=m.state,w=b.useRef(v);b.useEffect(()=>{w.current!==v&&(w.current=v,u||d(v))},[v,w,u]);const x=b.useMemo(()=>i!==void 0?{...m,state:i}:m,[m,i]);return b.useEffect(()=>{u&&!Object.is(i,m.state)&&p({type:aI,state:i})},[i,m.state,u]),[x,p]}Ch(hoe,"useControllableStateReducer");var moe=Object.defineProperty,el=(e,t)=>moe(e,"name",{value:t,configurable:!0}),zS="Popover",[B$,fCe]=Lz(zS,[k$]),$S=k$(),[poe,cd]=B$(zS),goe=el(e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:s=!1}=e,l=$S(t),u=b.useRef(null),[d,h]=b.useState(!1),[m,p]=L$({prop:r,defaultProp:i??!1,onChange:a,caller:zS});return y.jsx(toe,{...l,children:y.jsx(poe,{scope:t,contentId:e$(),triggerRef:u,open:m,onOpenChange:p,onOpenToggle:b.useCallback(()=>p(v=>!v),[p]),hasCustomAnchor:d,onCustomAnchorAdd:b.useCallback(()=>h(!0),[]),onCustomAnchorRemove:b.useCallback(()=>h(!1),[]),modal:s,children:n})})},"Popover"),voe="PopoverTrigger",yoe=b.forwardRef(el(function(t,n){const{__scopePopover:r,...i}=t,a=cd(voe,r),s=$S(r),l=od(n,a.triggerRef),u=y.jsx(ey.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":BS(a.open),...i,ref:l,onClick:Ds(t.onClick,a.onOpenToggle)});return a.hasCustomAnchor?u:y.jsx(noe,{asChild:!0,...s,children:u})},"PopoverTrigger")),U$="PopoverPortal",[boe,xoe]=B$(U$,{forceMount:void 0}),woe=el(e=>{const{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=cd(U$,t);return y.jsx(boe,{scope:t,forceMount:n,children:y.jsx(M$,{present:n||a.open,children:y.jsx(soe,{asChild:!0,container:i,children:r})})})},"PopoverPortal"),ah="PopoverContent",Eoe=b.forwardRef(el(function(t,n){const r=xoe(ah,t.__scopePopover),{forceMount:i=r.forceMount,...a}=t,s=cd(ah,t.__scopePopover);return y.jsx(M$,{present:i||s.open,children:s.modal?y.jsx(_oe,{...a,ref:n}):y.jsx(Aoe,{...a,ref:n})})},"PopoverContent")),Soe=kS("PopoverContent.RemoveScroll"),_oe=b.forwardRef(el(function(t,n){const r=cd(ah,t.__scopePopover),i=b.useRef(null),a=od(n,i),s=b.useRef(!1);return b.useEffect(()=>{const l=i.current;if(l)return yz(l)},[]),y.jsx(bS,{as:Soe,allowPinchZoom:!0,children:y.jsx(F$,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ds(t.onCloseAutoFocus,l=>{var u;l.preventDefault(),s.current||(u=r.triggerRef.current)==null||u.focus()}),onPointerDownOutside:Ds(t.onPointerDownOutside,l=>{const u=l.detail.originalEvent,d=u.button===0&&u.ctrlKey===!0,h=u.button===2||d;s.current=h},{checkForDefaultPrevented:!1}),onFocusOutside:Ds(t.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1})})})},"PopoverContentModal")),Aoe=b.forwardRef(el(function(t,n){const r=cd(ah,t.__scopePopover),i=b.useRef(!1),a=b.useRef(!1);return y.jsx(F$,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var l,u;(l=t.onCloseAutoFocus)==null||l.call(t,s),s.defaultPrevented||(i.current||(u=r.triggerRef.current)==null||u.focus(),s.preventDefault()),i.current=!1,a.current=!1},onInteractOutside:s=>{var d,h;(d=t.onInteractOutside)==null||d.call(t,s),s.defaultPrevented||(i.current=!0,s.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const l=s.target;((h=r.triggerRef.current)==null?void 0:h.contains(l))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&a.current&&s.preventDefault()}})},"PopoverContentNonModal")),F$=b.forwardRef(el(function(t,n){const{__scopePopover:r,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:s,disableOutsidePointerEvents:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:m,...p}=t,v=cd(ah,r),w=$S(r);return CS(),y.jsx(yie,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:a,onUnmountAutoFocus:s,children:y.jsx(uie,{asChild:!0,disableOutsidePointerEvents:l,onInteractOutside:m,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:h,onDismiss:()=>v.onOpenChange(!1),deferPointerDownOutside:!0,children:y.jsx(roe,{"data-state":BS(v.open),role:"dialog",id:v.contentId,...w,...p,ref:n,style:{...p.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})},"PopoverContentImpl"));function BS(e){return e?"open":"closed"}el(BS,"getState");var koe=goe,Ooe=yoe,Noe=woe,H$=Eoe;const Coe=koe,Toe=Ooe,K$=b.forwardRef(({className:e,align:t="start",side:n="top",sideOffset:r=8,collisionPadding:i=8,...a},s)=>y.jsx(Noe,{children:y.jsx(H$,{ref:s,align:t,side:n,sideOffset:r,collisionPadding:i,className:ze("z-50 w-64 max-w-[calc(100vw-1rem)] rounded-md border bg-card p-3 text-card-foreground shadow-md outline-none","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...a})}));K$.displayName=H$.displayName;const q$=92,G$=96;function Yx(e){if(!Number.isFinite(e)||e<0)return"?";const t=["B","KB","MB","GB","TB","PB"];let n=0;for(;e>=1024&&n<t.length-1;)e/=1024,n++;return`${e<10&&n>0?e.toFixed(1):Math.round(e)} ${t[n]}`}const oI=3e5;function Moe({socket:e,getToken:t}){const[n,r]=b.useState([]);if(b.useEffect(()=>{t().then(a=>a?fetch("/api/stats",{headers:{Authorization:`Bearer ${a}`}}):null).then(a=>a==null?void 0:a.json()).then(a=>(a==null?void 0:a.samples)&&r(a.samples)).catch(a=>console.warn("[MachineStats] seed failed",a))},[t]),b.useEffect(()=>{if(!e)return;const a=e.on(s=>{s.type==="stats"&&r(l=>[...l,s.sample].slice(-120))});return()=>{a()}},[e]),!n.length)return null;const i=n[n.length-1];return y.jsxs("div",{className:"w-full flex flex-wrap items-center justify-center gap-x-2 gap-y-0.5 text-[10px] text-muted-foreground/60",children:[y.jsx(lg,{label:"cpu",value:i.cpu,series:n.map(a=>a.cpu)}),y.jsx(lg,{label:"mem",value:i.mem,series:n.map(a=>a.mem)}),i.disk>=0&&y.jsx(lg,{label:"disk",value:i.disk,severity:zoe(i.disk),title:Boe(i)}),y.jsx(Ioe,{getToken:t})]})}function Ioe({getToken:e}){const[t,n]=b.useState(null);return b.useEffect(()=>{let r=!0,i=0;const a=async()=>{var d;try{const h=await e();if(!h)return;i=Date.now();const m=await fetch("/api/claude-usage",{headers:{Authorization:`Bearer ${h}`}});if(!r)return;if(m.status===204){n(null);return}if(m.status!==200)return;const p=await m.json();if(!r||!((d=p==null?void 0:p.limits)!=null&&d.length))return;n(p)}catch(h){console.warn("[MachineStats] claude usage poll failed",h)}},s=()=>{document.visibilityState==="visible"&&a()},l=()=>{document.visibilityState==="visible"&&Date.now()-i>=oI&&a()};s();const u=setInterval(s,oI);return document.addEventListener("visibilitychange",l),()=>{r=!1,clearInterval(u),document.removeEventListener("visibilitychange",l)}},[e]),y.jsx(V$,{usage:t})}function V$({usage:e,compact:t}){const n=e&&W$(e.limits),[r,i]=b.useState(k1),a=b.useRef(null),s=()=>{a.current&&(clearTimeout(a.current),a.current=null)},l=b.useCallback((u,d=0)=>{if(s(),!d){i(h=>lI(h,u));return}a.current=setTimeout(()=>{a.current=null,i(h=>lI(h,u))},d)},[]);return b.useEffect(()=>s,[]),!e||!n?null:y.jsxs(Coe,{open:r.open,onOpenChange:u=>l(u?{type:"activate"}:{type:"dismiss"}),children:[y.jsx(Toe,{asChild:!0,children:y.jsx("button",{type:"button","aria-label":"claude usage breakdown",className:"cursor-default rounded-sm outline-none focus-visible:ring-1 focus-visible:ring-ring",onPointerEnter:u=>l({type:"pointerenter",pointerType:u.pointerType},Roe),onPointerLeave:u=>l({type:"pointerleave",pointerType:u.pointerType},sI),children:t?y.jsxs("span",{className:ze("tabular-nums",Bg(n.percent,n.severity)),children:[n.percent,"% used"]}):y.jsx(lg,{label:"usage",value:n.percent,severity:n.severity})})}),y.jsx(K$,{onOpenAutoFocus:u=>u.preventDefault(),onPointerEnter:()=>s(),onPointerLeave:u=>l({type:"pointerleave",pointerType:u.pointerType},sI),children:y.jsx(Poe,{usage:e})})]})}const Roe=120,sI=80,k1={open:!1,byHover:!1};function lI(e,t){switch(t.type){case"pointerenter":return cI(t.pointerType)?{open:!0,byHover:!0}:e;case"pointerleave":return cI(t.pointerType)&&e.byHover?k1:e;case"activate":return{open:!0,byHover:!1};case"dismiss":return k1}}const cI=e=>e==="mouse"||e==="";function Poe({usage:e}){const t=W$(e.limits);return y.jsxs("div",{className:"text-[11px] leading-tight",children:[y.jsxs("div",{className:"flex items-baseline justify-between gap-2 pb-2 text-muted-foreground",children:[y.jsx("span",{className:"uppercase tracking-wide",children:"claude usage"}),e.subscriptionType&&y.jsxs("span",{className:"tabular-nums",children:[e.subscriptionType," plan"]})]}),y.jsxs("div",{className:"-mt-1 flex items-baseline justify-between gap-2 pb-2 text-[10px] text-muted-foreground",children:[e.account&&y.jsx("span",{className:"truncate",title:e.account,children:e.account}),y.jsx("span",{className:ze("shrink-0",e.stale&&"text-amber-500"),children:joe(e)})]}),e.stale&&e.error&&y.jsxs("div",{"data-refresh-error":!0,className:"-mt-1 pb-2 text-[10px] text-amber-500 break-words",children:[e.error,og(e.retryAt??null)&&` · retrying in ${og(e.retryAt??null)}`]}),y.jsx("div",{className:"flex flex-col gap-3",children:e.limits.map((n,r)=>{const i=og(n.resetsAt),a=n===t;return y.jsxs("div",{"data-headline":a||void 0,className:ze("flex flex-col gap-1",!a&&"opacity-60"),children:[y.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[y.jsxs("span",{className:ze("truncate",a&&"font-medium"),children:[a&&y.jsx("span",{className:"mr-1 text-muted-foreground","aria-hidden":!0,children:"▸"}),Doe(n)]}),y.jsxs("span",{className:ze("tabular-nums shrink-0",Bg(n.percent,n.severity)),children:[n.percent,"%"]})]}),y.jsx(Y$,{value:n.percent,className:ze("w-full",Bg(n.percent,n.severity))}),y.jsx("span",{className:"text-[10px] text-muted-foreground",children:i?`resets in ${i}`:"no reset reported"})]},`${n.kind}-${r}`)})}),y.jsx("div",{className:"mt-3 border-t pt-2 text-[10px] text-muted-foreground",children:"▸ is the window the strip is showing"})]})}function Doe(e){return e.scopeLabel?`${e.scopeLabel} window`:e.kind==="session"?"current session":e.kind==="weekly_all"?"all models":e.kind.replace(/_/g," ")}function W$(e){return e.reduce((t,n)=>!t||n.percent>t.percent?n:t,null)}function joe(e){const t=Loe(e.fetchedAt);return t?e.stale?`${t} old — refresh failed`:`updated ${t} ago`:e.stale?"last reading — refresh failed":"updated just now"}function Loe(e){if(!e)return null;const t=Date.now()-new Date(e).getTime();if(!Number.isFinite(t))return null;const n=Math.round(Math.max(0,t)/6e4);if(n<1)return null;if(n<60)return`${n}m`;const r=Math.floor(n/60),i=n%60;return r<24?i?`${r}h ${i}m`:`${r}h`:`${Math.floor(r/24)}d`}function zoe(e){return e>=G$?"critical":e>=q$?"warning":"ok"}const $oe={critical:"text-red-500",exceeded:"text-red-500",warning:"text-amber-500",warn:"text-amber-500",ok:"text-emerald-500"};function Bg(e,t){const n=t?$oe[t]:void 0;return n||(e>=90?"text-red-500":e>=75?"text-amber-500":"text-emerald-500")}function Boe(e){const t=`warn at ${q$}%, critical at ${G$}%`;if(e.diskUsedBytes==null||e.diskTotalBytes==null)return`disk ${e.disk}% used — ${t}`;const n=Math.max(0,e.diskTotalBytes-e.diskUsedBytes);return`disk ${e.disk}% used — ${Yx(e.diskUsedBytes)} of ${Yx(e.diskTotalBytes)}, ${Yx(n)} free — ${t}`}function lg({label:e,value:t,series:n,title:r,severity:i}){const a=Bg(t,i),s=r??(n?`${e} ${t}% — last ${n.length} samples`:void 0);return y.jsxs("span",{className:"flex items-center gap-1",title:s,children:[y.jsx("span",{className:"uppercase tracking-wide",children:e}),n?y.jsx(Uoe,{series:n,className:a}):y.jsx(Y$,{value:t,className:a}),y.jsxs("span",{className:ze("tabular-nums",a),children:[t,"%"]})]})}function Y$({value:e,className:t}){const i=Math.max(0,Math.min(100,e))/100*40;return y.jsxs("svg",{width:40,height:12,viewBox:"0 0 40 12",className:ze("overflow-visible",t),preserveAspectRatio:"none",children:[y.jsx("rect",{x:0,y:12/2-2,width:40,height:4,rx:2,fill:"currentColor",opacity:.2}),i>0&&y.jsx("rect",{x:0,y:12/2-2,width:i,height:4,rx:2,fill:"currentColor"})]})}function Uoe({series:e,className:t}){const i=e.length;if(i<2)return null;const a=e.map((s,l)=>{const u=i>1?l/(i-1)*40:0,d=12-Math.max(0,Math.min(100,s))/100*12;return`${u.toFixed(1)},${d.toFixed(1)}`}).join(" ");return y.jsx("svg",{width:40,height:12,viewBox:"0 0 40 12",className:ze("overflow-visible",t),preserveAspectRatio:"none",children:y.jsx("polyline",{points:a,fill:"none",stroke:"currentColor",strokeWidth:1,strokeLinejoin:"round",strokeLinecap:"round"})})}const Of=50;function Foe({getToken:e,filter:t,refreshKey:n,hydrateIds:r}){const[i,a]=b.useState([]),[s,l]=b.useState(null),[u,d]=b.useState(!1),[h,m]=b.useState({}),p=b.useRef(new Set),v=b.useRef(null),w=b.useRef(null),x=b.useRef(t);x.current=t;const E=b.useRef(Of),_=b.useRef(t);_.current!==t&&(_.current=t,E.current=Of);const k=b.useCallback(async(M,D)=>{const L=await e();if(!L||D!=null&&D.aborted)return null;const R=await fetch(`/api/sessions?${new URLSearchParams(M)}`,{signal:D,headers:{Authorization:`Bearer ${L}`}});if(!R.ok)return null;const H=await R.json();return Array.isArray(H==null?void 0:H.sessions)?H:null},[e]),O=b.useCallback(async(M,D,L)=>{const R=[];let H,P=null;for(;R.length<M;){const q={filter:D,limit:String(Math.min(Of,M-R.length))};H&&(q.before=H);const K=await k(q,L);if(!K)return null;if(R.push(...K.sessions),P=K.nextCursor,!P||!K.sessions.length)break;H=P}return{sessions:R,nextCursor:P}},[k]);b.useEffect(()=>{var D,L;(D=v.current)==null||D.abort(),(L=w.current)==null||L.abort();const M=new AbortController;return v.current=M,d(!0),p.current.clear(),O(E.current,t,M.signal).then(R=>{!R||M.signal.aborted||(a(R.sessions),l(R.nextCursor))}).catch(()=>{}).finally(()=>{M.signal.aborted||d(!1)}),()=>M.abort()},[O,t,n]);const N=b.useCallback(()=>{var L;if(!s||u)return;(L=w.current)==null||L.abort();const M=new AbortController;w.current=M;const D=x.current;d(!0),k({filter:D,limit:String(Of),before:s},M.signal).then(R=>{!R||M.signal.aborted||D!==x.current||(a(H=>{const P=new Set(H.map(K=>K.sessionId)),q=[...H,...R.sessions.filter(K=>!P.has(K.sessionId))];return E.current=Math.max(Of,q.length),q}),l(R.nextCursor))}).catch(()=>{}).finally(()=>{M.signal.aborted||d(!1)})},[s,u,k]),T=b.useMemo(()=>{const M=new Map;for(const D of Object.values(h))M.set(D.sessionId,D);for(const D of i)M.set(D.sessionId,D);return M},[i,h]),C=r.join(",");return b.useEffect(()=>{const M=new Set(i.map(R=>R.sessionId)),D=r.filter(R=>!!R&&!M.has(R)&&!p.current.has(R)).slice(0,200);if(!D.length)return;for(const R of D)p.current.add(R);let L=!1;return k({ids:D.join(",")}).then(R=>{!R||L||m(H=>{const P={...H};for(const q of R.sessions)P[q.sessionId]=q;return P})}).catch(()=>{}),()=>{L=!0}},[C,i,k]),{sessions:i,cursor:s,loading:u,byId:T,loadMore:N}}const Nf="0.1.163";function Hoe(e){const t=Date.now()-e,n=Math.floor(t/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const r=Math.floor(n/60);if(r<24)return`${r}h ago`;const i=Math.floor(r/24);return i<7?`${i}d ago`:new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"})}const Cf="w-4 h-4 mt-0.5 shrink-0";function Koe(e){const t=e.slackContext;return(t==null?void 0:t.type)==="dm"?y.jsx(oV,{className:`${Cf} text-purple-400`}):(t==null?void 0:t.type)==="mention"?y.jsx(GG,{className:`${Cf} text-blue-400`}):(t==null?void 0:t.type)==="channel"?y.jsx(tV,{className:`${Cf} text-green-400`}):e.sessionId.startsWith("slack-")?y.jsx(Zw,{className:`${Cf} text-yellow-400`}):y.jsx(Zw,{className:`${Cf} text-muted-foreground`})}function qoe(e){const t=e.slackContext;return(t==null?void 0:t.type)==="dm"?`DM${t.userName?` · ${t.userName}`:""}`:(t==null?void 0:t.type)==="mention"?`@mention${t.channelName?` · #${t.channelName}`:""}`:(t==null?void 0:t.type)==="channel"?`#${t.channelName||"channel"}`:e.sessionId.startsWith("slack-")?"Slack":null}function Goe(e,t,n){return Object.keys(e).map(r=>t.get(r)).filter(r=>!!r&&(n==="all"||r.mine!==!1))}const uI="chats-filter",dI="chats-unread-filter";function Voe({getToken:e,activeSessionId:t,onSelect:n,onNew:r,refreshKey:i,workspaceRefreshKey:a,onRefreshWorkspace:s,unreads:l={},busySessions:u=new Set,socket:d}){var U;const h=za(),[m,p]=b.useState(()=>localStorage.getItem(uI)||"mine"),[v,w]=b.useState(()=>localStorage.getItem(dI)==="true"),[x,E]=b.useState(""),_=b.useRef(null);function k(G){p(G),localStorage.setItem(uI,G)}function O(){const G=!v;w(G),localStorage.setItem(dI,String(G))}const N=b.useMemo(()=>[t,...Object.keys(l)].filter(G=>!!G),[t,l]),{sessions:T,cursor:C,loading:M,byId:D,loadMore:L}=Foe({getToken:e,filter:m,refreshKey:i,hydrateIds:N}),R=b.useMemo(()=>Goe(l,D,m),[l,D,m]),H=R.length,P=b.useMemo(()=>v?[...R].sort((G,$)=>$.lastModified-G.lastModified):T,[v,R,T]),q=t&&!P.some(G=>G.sessionId===t)?D.get(t):void 0;b.useEffect(()=>{_.current&&_.current.scrollIntoView({block:"nearest"})},[t,P,q]);const K=b.useRef(null),X=b.useRef(L);X.current=L,b.useEffect(()=>{const G=K.current;if(!G||!C||v)return;const $=new IntersectionObserver(j=>{j.some(V=>V.isIntersecting)&&X.current()},{rootMargin:"300px"});return $.observe(G),()=>$.disconnect()},[C,M,v]),b.useEffect(()=>{e().then(G=>G?fetch("/api/version",{headers:{Authorization:`Bearer ${G}`}}):null).then(G=>G==null?void 0:G.json()).then(G=>G&&E(G.version)).catch(()=>{})},[]);const F=!!x&&x!=="unknown"&&Nf!=="dev"&&x!==Nf;b.useEffect(()=>{F&&console.warn(`[shraga] stale client bundle: built from v${Nf}, server runs v${x} — rebuild dist/client`)},[F,x]);function Y(G){const $=l[G.sessionId],j=u.has(G.sessionId)||G.runStatus==="running"||G.scheduleRunStatus==="running",V=!j&&(!!G.lastStopReason||G.scheduleRunStatus==="error"||G.scheduleRunStatus==="aborted"),z=j?"border-amber-500":V?"border-red-500":$?"border-blue-500":"",ie=!!(j||V||$);return y.jsx("button",{ref:G.sessionId===t?_:void 0,onClick:()=>n(G.sessionId,G.title),className:ze("w-full text-left px-3 py-2.5 text-sm transition-colors hover:bg-accent/50 group",ie?`rounded-r-lg border-l-[3px] ${z}`:"rounded-lg",t===G.sessionId&&"bg-accent"),children:y.jsxs("div",{className:"flex items-start gap-2",children:[Koe(G),y.jsxs("div",{className:"min-w-0 flex-1",children:[y.jsx("span",{className:ze("block truncate text-sm leading-snug",$&&"font-semibold"),children:G.title||"New session"}),y.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[y.jsx("span",{className:"text-[10px] text-muted-foreground font-medium",children:qoe(G)||G.userName}),y.jsx("span",{className:"text-[10px] text-muted-foreground/50",children:"·"}),y.jsx("span",{className:"text-[10px] text-muted-foreground",children:Hoe(G.lastModified)})]})]})]})},G.sessionId)}return y.jsxs("div",{className:"flex flex-col h-full bg-muted/30",children:[y.jsx("div",{className:"p-3",children:y.jsxs(we,{variant:"outline",size:"sm",className:"w-full gap-2 justify-start",onClick:r,title:"New Chat (Ctrl+N)",children:[y.jsx(ko,{className:"w-4 h-4"})," New Chat",y.jsx("span",{className:"ml-auto flex items-center gap-0.5 text-[10px] text-muted-foreground/50 font-mono",children:"⌃N"})]})}),y.jsx("div",{className:"border-b shrink-0 flex flex-col max-h-[40vh]",children:y.jsx(Ure,{getToken:e,onRefresh:s,refreshKey:a})}),y.jsxs("div",{className:"flex items-center justify-between px-3 pt-2 pb-1",children:[y.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Chats"}),y.jsxs("div",{className:"flex gap-0.5",children:[["mine","all"].map(G=>y.jsx("button",{onClick:()=>k(G),className:ze("text-[10px] px-1.5 rounded-full transition-colors capitalize leading-none",m===G?"text-foreground font-medium":"text-muted-foreground/60 hover:text-muted-foreground"),children:G},G)),y.jsxs("button",{onClick:O,className:ze("text-[10px] px-1.5 rounded-full transition-colors leading-none",v?"text-blue-600 dark:text-blue-400 font-medium":"text-muted-foreground/60 hover:text-muted-foreground"),children:["unread",H>0&&y.jsx("span",{className:"inline-block w-1.5 h-1.5 ml-1 rounded-full bg-blue-500 align-middle"})]})]})]}),y.jsx(CL,{className:"flex-1",children:y.jsxs("div",{className:"px-2 pb-2 space-y-0.5",children:[P.length===0&&!q&&y.jsx("p",{className:"text-xs text-muted-foreground px-3 py-6 text-center",children:M?"Loading…":v?"No unread conversations":"No conversations yet"}),q&&Y(q),P.map(Y),!v&&C&&y.jsx("div",{ref:K,className:"py-3 text-center text-[11px] text-muted-foreground/60",children:M?"Loading older…":"···"})]})}),y.jsxs("div",{className:"px-4 py-2 flex flex-col items-center gap-1",children:[y.jsx(Moe,{socket:d??null,getToken:e}),(U=h.sidebarExtras)==null?void 0:U.call(h),x&&(F?y.jsxs("button",{onClick:()=>location.reload(),title:`This page was built from v${Nf}, the server runs v${x} — reload to update`,className:"text-[10px] text-amber-400 hover:text-amber-300 text-center underline decoration-dotted",children:["⚠️ stale page (v",Nf," → v",x,") · reload"]}):y.jsxs("div",{className:"text-[10px] text-muted-foreground/50 text-center",children:["v",x]}))]})]})}function ni(e,t){const n=e[e.length-1];if((n==null?void 0:n.role)==="assistant"){if(t.type==="text"||t.type==="thinking"){const r=[...n.blocks],i=r[r.length-1];return(i==null?void 0:i.type)===t.type?(r[r.length-1]={...i,text:i.text+t.text},[...e.slice(0,-1),{...n,blocks:r}]):[...e.slice(0,-1),{...n,blocks:[...r,t]}]}return[...e.slice(0,-1),{...n,blocks:[...n.blocks,t]}]}return[...e,{id:Ms(),role:"assistant",blocks:[t]}]}function fI(e,t,n="text"){const r=e[e.length-1],i={type:n,text:t};return(r==null?void 0:r.role)==="assistant"?[...e.slice(0,-1),{...r,blocks:[...r.blocks,i]}]:[...e,{id:Ms(),role:"assistant",blocks:[i]}]}function X$(e,t,n){for(let r=e.length-1;r>=0;r--){const i=e[r];if(i.role!=="assistant")continue;const a=i.blocks.findIndex(l=>l.type==="tool_use"&&l.toolUseId===t);if(a===-1)continue;const s=[...i.blocks];return s[a]={...s[a],input:n},[...e.slice(0,r),{...i,blocks:s},...e.slice(r+1)]}return e}function Woe(e,t){const[n,r]=b.useState([]),[i,a]=b.useState(!1),[s,l]=b.useState([]),u=b.useRef(t.initialSessionId),d=b.useRef(!1),h=b.useRef(s);h.current=s;const m=b.useRef(t.getToken);m.current=t.getToken;const p=b.useRef(t.onNewSession);p.current=t.onNewSession;const v=b.useRef(t.onDirectivesChanged);v.current=t.onDirectivesChanged;const w=b.useRef(t.onParticipantsChanged);w.current=t.onParticipantsChanged;const x=b.useRef(t.onEvent);x.current=t.onEvent;const E=b.useRef(e);E.current=e;const _=b.useCallback(P=>P!=null&&P===u.current,[]),k=b.useCallback(async()=>{var q;const P=u.current;if(P)try{const X=await(await Ll(`/api/sessions/${P}/messages`,m.current)).json();r(iL(X)),a(!!X.busy),(q=w.current)==null||q.call(w,Array.isArray(X.participants)&&X.participants.length>1)}catch{}},[]);b.useEffect(()=>{if(!e)return;const P=e.on(q=>{var X,F,Y,U,G,$;(X=x.current)==null||X.call(x,q);const K=q;if(K.type==="compact_marker")return _(K.sessionId)?r(j=>[...j,{id:Ms(),role:"assistant",blocks:[{type:"compact_marker",summary:K.summary??"",compactedCount:K.compactedCount??0}]}]):void 0;switch(q.type){case"thinking_delta":return _(q.sessionId)?r(j=>ni(j,{type:"thinking",text:q.text})):void 0;case"text_delta":return _(q.sessionId)?r(j=>ni(j,{type:"text",text:q.text})):void 0;case"tool_use":return _(q.sessionId)?r(j=>ni(j,{type:"tool_use",tool:q.tool,toolUseId:q.toolUseId,input:q.input})):void 0;case"tool_use_input":return _(q.sessionId)?r(j=>X$(j,q.toolUseId,q.input)):void 0;case"tool_result":return _(q.sessionId)?r(j=>ni(j,{type:"tool_result",toolUseId:q.toolUseId,output:q.output})):void 0;case"tool_result_image":return _(q.sessionId)?r(j=>ni(j,{type:"image",src:q.dataUrl})):void 0;case"permission_request":return _(q.sessionId)?r(j=>ni(j,{type:"permission_request",id:q.id,tool:q.tool,input:q.input})):void 0;case"question_request":return _(q.sessionId)?r(j=>ni(j,{type:"question_request",id:q.id,questions:q.questions})):void 0;case"directives":return d.current?(F=v.current)==null?void 0:F.call(v,q.directives):void 0;case"session_id":return!d.current||u.current?void 0:(u.current=q.sessionId,(Y=p.current)==null?void 0:Y.call(p,q.sessionId));case"forked":return q.sourceSessionId!==u.current?void 0:(u.current=q.sessionId,(U=p.current)==null?void 0:U.call(p,q.sessionId));case"session_busy":q.sessionId===u.current&&a(q.busy);return;case"session_stream":return q.sessionId!==u.current?void 0:Yoe(r,q.event);case"session_messages_changed":q.sessionId===u.current&&k();return;case"done":{if(q.sessionId!==u.current)return;q.stopReason==="max_turns_reached"&&r(V=>ni(V,{type:"text",text:`
|
|
1908
1908
|
|
|
1909
1909
|
---
|
|
1910
1910
|
⚠️ Reached the maximum number of steps for this turn. Send "continue" to pick up where I left off.`})),(G=p.current)==null||G.call(p,q.sessionId);const j=h.current;if(j.length>0){const V=j.join(`
|
package/dist/client/index.html
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
14
14
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
15
15
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet" />
|
|
16
|
-
<script type="module" crossorigin src="/assets/index-
|
|
16
|
+
<script type="module" crossorigin src="/assets/index-8UASQgQU.js"></script>
|
|
17
17
|
<link rel="stylesheet" crossorigin href="/assets/index-NtN1I_dh.css">
|
|
18
18
|
</head>
|
|
19
19
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shraga",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.163",
|
|
4
4
|
"description": "The teammate you delegate coding to — a self-hostable, multi-user AI coding agent web UI (Claude Code, with a pluggable engine seam).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -99,11 +99,11 @@ export function useSessionList({ getToken, filter, refreshKey, hydrateIds }: Opt
|
|
|
99
99
|
acRef.current = ac;
|
|
100
100
|
setLoading(true);
|
|
101
101
|
// Hydrated rows are re-read too: `extras` is fetch-time data (title, lastModified, runStatus)
|
|
102
|
-
// and without this a by-id row keeps its first snapshot for the life of the page.
|
|
103
|
-
//
|
|
104
|
-
//
|
|
102
|
+
// and without this a by-id row keeps its first snapshot for the life of the page. Only the
|
|
103
|
+
// request ledger is reset; the rows stay until the re-read REPLACES them. Wiping `extras` here
|
|
104
|
+
// blanked the active row (rendered on top) on every global broadcast — the "top convo appears
|
|
105
|
+
// and disappears" flicker.
|
|
105
106
|
requestedRef.current.clear();
|
|
106
|
-
setExtras({});
|
|
107
107
|
fetchWindow(depthRef.current, filter, ac.signal)
|
|
108
108
|
.then((page) => {
|
|
109
109
|
if (!page || ac.signal.aborted) return;
|
|
@@ -148,7 +148,10 @@ export function useSessionList({ getToken, filter, refreshKey, hydrateIds }: Opt
|
|
|
148
148
|
// server never returns (e.g. a deleted session still in the unread map).
|
|
149
149
|
const hydrateKey = hydrateIds.join(',');
|
|
150
150
|
useEffect(() => {
|
|
151
|
-
|
|
151
|
+
// Checked against the loaded WINDOW, not `byId`: a row already in `extras` must still be re-read
|
|
152
|
+
// after a refresh reset the ledger — it is just never blanked while that happens.
|
|
153
|
+
const inWindow = new Set(sessions.map((s) => s.sessionId));
|
|
154
|
+
const want = hydrateIds.filter((id) => !!id && !inWindow.has(id) && !requestedRef.current.has(id)).slice(0, 200);
|
|
152
155
|
if (!want.length) return;
|
|
153
156
|
for (const id of want) requestedRef.current.add(id);
|
|
154
157
|
let cancelled = false;
|
|
@@ -163,7 +166,7 @@ export function useSessionList({ getToken, filter, refreshKey, hydrateIds }: Opt
|
|
|
163
166
|
})
|
|
164
167
|
.catch(() => {});
|
|
165
168
|
return () => { cancelled = true; };
|
|
166
|
-
}, [hydrateKey,
|
|
169
|
+
}, [hydrateKey, sessions, fetchSessions]);
|
|
167
170
|
|
|
168
171
|
return { sessions, cursor, loading, byId, loadMore };
|
|
169
172
|
}
|