shraga 0.1.145 → 0.1.147
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`),_n=we,St=Ue),ft===void
|
|
|
1904
1904
|
`)},zM=function(){var e=parseInt(document.body.getAttribute(xd)||"0",10);return isFinite(e)?e:0},Goe=function(){w.useEffect(function(){return document.body.setAttribute(xd,(zM()+1).toString()),function(){var e=zM()-1;e<=0?document.body.removeAttribute(xd):document.body.setAttribute(xd,e.toString())}},[])},Woe=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?"margin":r;Goe();var a=w.useMemo(function(){return Hoe(i)},[i]);return w.createElement(qoe,{styles:Koe(a,!t,i,n?"":"!important")})},Y_=!1;if(typeof window<"u")try{var bg=Object.defineProperty({},"passive",{get:function(){return Y_=!0,!0}});window.addEventListener("test",bg,bg),window.removeEventListener("test",bg,bg)}catch{Y_=!1}var Ku=Y_?{passive:!1}:!1,Voe=function(e){return e.tagName==="TEXTAREA"},SU=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Voe(e)&&n[t]==="visible")},Yoe=function(e){return SU(e,"overflowY")},Xoe=function(e){return SU(e,"overflowX")},BM=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var i=kU(e,r);if(i){var a=AU(e,r),o=a[1],l=a[2];if(o>l)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Zoe=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Qoe=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},kU=function(e,t){return e==="v"?Yoe(t):Xoe(t)},AU=function(e,t){return e==="v"?Zoe(t):Qoe(t)},Joe=function(e,t){return e==="h"&&t==="rtl"?-1:1},ese=function(e,t,n,r,i){var a=Joe(e,window.getComputedStyle(t).direction),o=a*r,l=n.target,u=t.contains(l),d=!1,f=o>0,h=0,m=0;do{if(!l)break;var g=AU(e,l),x=g[0],y=g[1],E=g[2],_=y-E-a*x;(x||_)&&kU(e,l)&&(h+=_,m+=x);var A=l.parentNode;l=A&&A.nodeType===Node.DOCUMENT_FRAGMENT_NODE?A.host:A}while(!u&&l!==document.body||u&&(t.contains(l)||t===l));return(f&&Math.abs(h)<1||!f&&Math.abs(m)<1)&&(d=!0),d},vg=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},tse=function(e,t){return e[0]===t[0]&&e[1]===t[1]},nse=function(e){return`
|
|
1905
1905
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
1906
1906
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
1907
|
-
`)},rse=0,Gu=[];function ise(e){var t=w.useRef([]),n=w.useRef([0,0]),r=w.useRef(),i=w.useState(rse++)[0],a=w.useState(_U)[0],o=w.useRef(e);w.useEffect(function(){o.current=e},[e]),w.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var y=fW([e.lockRef.current],(e.shards||[]).map(FM),!0).filter(Boolean);return y.forEach(function(E){return E.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),y.forEach(function(E){return E.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var l=w.useCallback(function(y,E){if("touches"in y&&y.touches.length===2||y.type==="wheel"&&y.ctrlKey)return!o.current.allowPinchZoom;var _=vg(y),A=n.current,N="deltaX"in y?y.deltaX:A[0]-_[0],T="deltaY"in y?y.deltaY:A[1]-_[1],O,C=y.target,R=Math.abs(N)>Math.abs(T)?"h":"v";if("touches"in y&&R==="h"&&C.type==="range")return!1;var M=window.getSelection(),P=M&&M.anchorNode,D=P?P===C||P.contains(C):!1;if(D)return!1;var F=BM(R,C);if(!F)return!0;if(F?O=R:(O=R==="v"?"h":"v",F=BM(R,C)),!F)return!1;if(!r.current&&"changedTouches"in y&&(N||T)&&(r.current=O),!O)return!0;var L=r.current||O;return ese(L,E,y,L==="h"?N:T)},[]),u=w.useCallback(function(y){var E=y;if(!(!Gu.length||Gu[Gu.length-1]!==a)){var _="deltaY"in E?UM(E):vg(E),A=t.current.filter(function(O){return O.name===E.type&&(O.target===E.target||E.target===O.shadowParent)&&tse(O.delta,_)})[0];if(A&&A.should){E.cancelable&&E.preventDefault();return}if(!A){var N=(o.current.shards||[]).map(FM).filter(Boolean).filter(function(O){return O.contains(E.target)}),T=N.length>0?l(E,N[0]):!o.current.noIsolation;T&&E.cancelable&&E.preventDefault()}}},[]),d=w.useCallback(function(y,E,_,A){var N={name:y,delta:E,target:_,should:A,shadowParent:ase(_)};t.current.push(N),setTimeout(function(){t.current=t.current.filter(function(T){return T!==N})},1)},[]),f=w.useCallback(function(y){n.current=vg(y),r.current=void 0},[]),h=w.useCallback(function(y){d(y.type,UM(y),y.target,l(y,e.lockRef.current))},[]),m=w.useCallback(function(y){d(y.type,vg(y),y.target,l(y,e.lockRef.current))},[]);w.useEffect(function(){return Gu.push(a),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:m}),document.addEventListener("wheel",u,Ku),document.addEventListener("touchmove",u,Ku),document.addEventListener("touchstart",f,Ku),function(){Gu=Gu.filter(function(y){return y!==a}),document.removeEventListener("wheel",u,Ku),document.removeEventListener("touchmove",u,Ku),document.removeEventListener("touchstart",f,Ku)}},[]);var g=e.removeScrollBar,x=e.inert;return w.createElement(w.Fragment,null,x?w.createElement(a,{styles:nse(i)}):null,g?w.createElement(Woe,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function ase(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const ose=Doe(EU,ise);var ck=w.forwardRef(function(e,t){return w.createElement(Wv,lo({},e,{ref:t,sideCar:ose}))});ck.classNames=Wv.classNames;var sse=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Wu=new WeakMap,yg=new WeakMap,xg={},jw=0,NU=function(e){return e&&(e.host||NU(e.parentNode))},lse=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=NU(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})},cse=function(e,t,n,r){var i=lse(t,Array.isArray(e)?e:[e]);xg[n]||(xg[n]=new WeakMap);var a=xg[n],o=[],l=new Set,u=new Set(i),d=function(h){!h||l.has(h)||(l.add(h),d(h.parentNode))};i.forEach(d);var f=function(h){!h||u.has(h)||Array.prototype.forEach.call(h.children,function(m){if(l.has(m))f(m);else try{var g=m.getAttribute(r),x=g!==null&&g!=="false",y=(Wu.get(m)||0)+1,E=(a.get(m)||0)+1;Wu.set(m,y),a.set(m,E),o.push(m),y===1&&x&&yg.set(m,!0),E===1&&m.setAttribute(n,"true"),x||m.setAttribute(r,"true")}catch(_){console.error("aria-hidden: cannot operate on ",m,_)}})};return f(t),l.clear(),jw++,function(){o.forEach(function(h){var m=Wu.get(h)-1,g=a.get(h)-1;Wu.set(h,m),a.set(h,g),m||(yg.has(h)||h.removeAttribute(r),yg.delete(h)),g||h.removeAttribute(n)}),jw--,jw||(Wu=new WeakMap,Wu=new WeakMap,yg=new WeakMap,xg={})}},TU=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=sse(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),cse(r,i,n,"aria-hidden")):function(){return null}},Vv="Dialog",[OU]=N3(Vv),[use,ja]=OU(Vv),CU=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,l=w.useRef(null),u=w.useRef(null),[d,f]=aoe({prop:r,defaultProp:i??!1,onChange:a,caller:Vv});return v.jsx(use,{scope:t,triggerRef:l,contentRef:u,contentId:Rw(),titleId:Rw(),descriptionId:Rw(),open:d,onOpenChange:f,onOpenToggle:w.useCallback(()=>f(h=>!h),[f]),modal:o,children:n})};CU.displayName=Vv;var RU="DialogTrigger",IU=w.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=ja(RU,n),a=Gi(t,i.triggerRef);return v.jsx(vi.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":pk(i.open),...r,ref:a,onClick:ti(e.onClick,i.onOpenToggle)})});IU.displayName=RU;var uk="DialogPortal",[dse,MU]=OU(uk,{forceMount:void 0}),DU=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=ja(uk,t);return v.jsx(dse,{scope:t,forceMount:n,children:w.Children.map(r,o=>v.jsx(Ll,{present:n||a.open,children:v.jsx(xU,{asChild:!0,container:i,children:o})}))})};DU.displayName=uk;var Ob="DialogOverlay",dk=w.forwardRef((e,t)=>{const n=MU(Ob,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=ja(Ob,e.__scopeDialog);return a.modal?v.jsx(Ll,{present:r||a.open,children:v.jsx(hse,{...i,ref:t})}):null});dk.displayName=Ob;var fse=$1("DialogOverlay.RemoveScroll"),hse=w.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=ja(Ob,n),a=hoe(),o=Gi(t,a);return v.jsx(ck,{as:fse,allowPinchZoom:!0,shards:[i.contentRef],children:v.jsx(vi.div,{"data-state":pk(i.open),...r,ref:o,style:{pointerEvents:"auto",...r.style}})})}),Md="DialogContent",fk=w.forwardRef((e,t)=>{const n=MU(Md,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=ja(Md,e.__scopeDialog);return v.jsx(Ll,{present:r||a.open,children:a.modal?v.jsx(pse,{...i,ref:t}):v.jsx(mse,{...i,ref:t})})});fk.displayName=Md;var pse=w.forwardRef((e,t)=>{const n=ja(Md,e.__scopeDialog),r=w.useRef(null),i=Gi(t,n.contentRef,r);return w.useEffect(()=>{const a=r.current;if(a)return TU(a)},[]),v.jsx(PU,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:ti(e.onCloseAutoFocus,a=>{var o;a.preventDefault(),(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:ti(e.onPointerDownOutside,a=>{const o=a.detail.originalEvent,l=o.button===0&&o.ctrlKey===!0;(o.button===2||l)&&a.preventDefault()}),onFocusOutside:ti(e.onFocusOutside,a=>a.preventDefault())})}),mse=w.forwardRef((e,t)=>{const n=ja(Md,e.__scopeDialog),r=w.useRef(!1),i=w.useRef(!1);return v.jsx(PU,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var o,l;(o=e.onCloseAutoFocus)==null||o.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 o=a.target;((d=n.triggerRef.current)==null?void 0:d.contains(o))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&i.current&&a.preventDefault()}})}),PU=w.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,l=ja(Md,n);return koe(),v.jsx(v.Fragment,{children:v.jsx(vU,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:v.jsx(gU,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":pk(l.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>l.onOpenChange(!1)})})})}),LU="DialogTitle",hk=w.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=ja(LU,n);return v.jsx(vi.h2,{id:i.titleId,...r,ref:t})});hk.displayName=LU;var jU="DialogDescription",gse=w.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=ja(jU,n);return v.jsx(vi.p,{id:i.descriptionId,...r,ref:t})});gse.displayName=jU;var $U="DialogClose",zU=w.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=ja($U,n);return v.jsx(vi.button,{type:"button",...r,ref:t,onClick:ti(e.onClick,()=>i.onOpenChange(!1))})});zU.displayName=$U;function pk(e){return e?"open":"closed"}const ps=CU,Yd=IU,bse=DU,BU=w.forwardRef(({className:e,...t},n)=>v.jsx(dk,{ref:n,className:Ge("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}));BU.displayName=dk.displayName;const vo=w.forwardRef(({className:e,children:t,...n},r)=>v.jsxs(bse,{children:[v.jsx(BU,{}),v.jsxs(fk,{ref:r,className:Ge("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,v.jsxs(zU,{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:[v.jsx(kl,{className:"h-4 w-4"}),v.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));vo.displayName=fk.displayName;function Al({className:e,...t}){return v.jsx("div",{className:Ge("shrink-0 flex flex-col space-y-1.5 text-center sm:text-left",e),...t})}function UU({className:e,...t}){return v.jsx("div",{"data-dialog-body":!0,className:Ge("flex-1 min-h-0 overflow-y-auto -mx-4 px-4 sm:-mx-6 sm:px-6",e),...t})}function FU({className:e,...t}){return v.jsx("div",{className:Ge("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 ms=w.forwardRef(({className:e,...t},n)=>v.jsx(hk,{ref:n,className:Ge("text-lg font-semibold leading-none tracking-tight",e),...t}));ms.displayName=hk.displayName;const vse=new Set(["png","jpg","jpeg","gif","webp","svg","ico","bmp","avif"]),yse=new Set(["pdf","mp4","webm","mp3","ogg","wav"]);async function xse(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 wse({getToken:e,onRefresh:t,refreshKey:n}){const[r,i]=w.useState(new Map),[a,o]=w.useState(()=>new Set),[l,u]=w.useState(null),[d,f]=w.useState(!1),[h,m]=w.useState("fit"),[g,x]=w.useState(null),[y,E]=w.useState(null),_=w.useRef(null),[A,N]=w.useState(null),[T,O]=w.useState(!1),[C,R]=w.useState([]),M=w.useCallback(async B=>{const q=await xse(B,e);i(H=>new Map(H).set(B,q))},[e]);w.useEffect(()=>{M(""),a.forEach(B=>M(B))},[M,n]);const P=r.get("")??[],D=w.useCallback(B=>{try{const q=B.contentDocument;if(!(q!=null&&q.body))return;const H=Math.max(q.body.offsetWidth,q.body.scrollWidth),V=Math.max(q.body.offsetHeight,q.body.scrollHeight);H&&V&&E({w:H,h:V})}catch{}},[]),F=w.useCallback(()=>{const B=_.current,q=y;if(!B||!q)return;const H=16,V=B.clientWidth-H,z=B.clientHeight-H,j=Math.min(V/q.w,z/q.h,1);x({scale:j,w:q.w,h:q.h})},[y]);w.useEffect(()=>{if(!(l!=null&&l.html)||h!=="fit"){x(null);return}const B=_.current;if(!B)return;const q=new ResizeObserver(()=>requestAnimationFrame(F));return q.observe(B),()=>q.disconnect()},[l==null?void 0:l.html,d,h,F]),w.useEffect(()=>{T&&e().then(B=>{B&&fetch("/api/data-sync/log",{headers:{Authorization:`Bearer ${B}`}}).then(q=>q.json()).then(R).catch(()=>{})})},[T]);const L=B=>{o(q=>{const H=new Set(q);return H.has(B)?H.delete(B):(H.add(B),r.has(B)||M(B)),H})},G=(B,q)=>{const H=new URLSearchParams({path:B});return A&&H.set("token",A),q&&H.set("dl","1"),`/api/workspace/raw?${H}`},W=async B=>{var V;const q=await e();if(!q)return;N(q);const H=((V=B.split(".").pop())==null?void 0:V.toLowerCase())??"";if(H==="html"||H==="htm"){u({path:B,content:"",binary:!1,html:!0});return}if(vse.has(H)){u({path:B,content:"",binary:!1,image:!0});return}if(yse.has(H)){u({path:B,content:"",binary:!1,html:!0});return}try{const z=await fetch(`/api/workspace/file?path=${encodeURIComponent(B)}`,{headers:{Authorization:`Bearer ${q}`}});if(!z.ok)return;const j=await z.json();u({path:B,content:j.content,binary:!!j.binary})}catch{}},X=(B,q)=>v.jsx(v.Fragment,{children:B.map(H=>{const V=H.path.split("/").pop();return v.jsxs("div",{children:[H.type==="dir"?v.jsxs("button",{onClick:()=>L(H.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+q*12},children:[v.jsx(Pl,{className:Ge("w-3 h-3 shrink-0 transition-transform",a.has(H.path)&&"rotate-90")}),v.jsx(IX,{className:"w-3.5 h-3.5 shrink-0 text-muted-foreground"}),v.jsx("span",{className:"truncate",children:V})]}):v.jsxs("button",{onClick:()=>W(H.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+q*12+12},title:H.oneLiner||H.path,children:[v.jsx(M1,{className:"w-3.5 h-3.5 shrink-0 text-muted-foreground"}),v.jsx("span",{className:"truncate",children:V})]}),H.type==="dir"&&a.has(H.path)&&X(r.get(H.path)??[],q+1)]},H.path)})});return v.jsxs(v.Fragment,{children:[v.jsxs("div",{className:"flex items-center justify-between px-3 pt-2 pb-1 shrink-0",children:[v.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Workspace"}),v.jsxs("div",{className:"flex items-center gap-0.5",children:[v.jsx("button",{onClick:()=>O(!0),className:"p-0.5 rounded hover:bg-accent text-muted-foreground",title:"Activity log",children:v.jsx(DX,{className:"w-3 h-3"})}),v.jsx("button",{onClick:()=>{M(""),a.forEach(B=>M(B)),t==null||t()},className:"p-0.5 rounded hover:bg-accent text-muted-foreground",title:"Refresh",children:v.jsx(Gd,{className:"w-3 h-3"})})]})]}),v.jsx("div",{className:"px-1 pb-2 overflow-y-auto min-h-0",children:P.length===0?v.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(P,0)}),v.jsx(ps,{open:!!l,onOpenChange:B=>{B||(u(null),f(!1),m("fit"),E(null))},children:v.jsxs(vo,{className:Ge(l!=null&&l.html?Ge("!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:[v.jsxs("div",{className:"absolute right-12 top-4 flex items-center gap-1.5 z-10",children:[(l==null?void 0:l.html)&&v.jsxs(v.Fragment,{children:[v.jsx("button",{onClick:()=>m(B=>B==="fit"?"scroll":"fit"),className:"rounded-sm opacity-70 hover:opacity-100 text-muted-foreground",title:h==="fit"?"Switch to scrollable (1:1)":"Switch to scale-to-fit",children:h==="fit"?v.jsx(zX,{className:"w-4 h-4"}):v.jsx(KX,{className:"w-4 h-4"})}),v.jsx("button",{onClick:()=>f(B=>!B),className:"rounded-sm opacity-70 hover:opacity-100 text-muted-foreground",title:d?"Restore":"Maximize",children:d?v.jsx(P1,{className:"w-4 h-4"}):v.jsx(D1,{className:"w-4 h-4"})})]}),l&&v.jsx("a",{href:G(l.path,!0),download:!0,className:"rounded-sm opacity-70 hover:opacity-100 text-muted-foreground",title:"Download",children:v.jsx(E3,{className:"w-4 h-4"})})]}),v.jsx(Al,{className:Ge((l==null?void 0:l.html)&&"px-4 py-3 shrink-0 border-b"),children:v.jsx(ms,{className:"font-mono text-sm truncate pr-16",children:l==null?void 0:l.path})}),v.jsx("div",{ref:l!=null&&l.html?_:void 0,className:Ge(l!=null&&l.html?Ge("flex-1 min-h-0 bg-muted/10",h==="fit"?"overflow-hidden flex items-center justify-center":"overflow-auto"):"flex-1 min-h-0 overflow-y-auto"),children:l!=null&&l.html?h==="fit"?v.jsx("div",{style:g?{width:g.w*g.scale,height:g.h*g.scale}:{width:"100%",height:"100%"},children:v.jsx("iframe",{src:G(l.path),className:"border-0 bg-white origin-top-left",title:l.path,onLoad:B=>{D(B.currentTarget),F()},style:g?{width:g.w,height:g.h,transform:`scale(${g.scale})`}:{width:"100%",height:"100%"}})}):v.jsx("iframe",{src:G(l.path),className:"border-0 bg-white mx-auto block",title:l.path,onLoad:B=>D(B.currentTarget),style:{width:(y==null?void 0:y.w)||"100%",height:(y==null?void 0:y.h)||"100%"}}):l!=null&&l.image?v.jsx("div",{className:"flex items-center justify-center p-4",children:v.jsx("img",{src:G(l.path),alt:l.path,className:"max-w-full max-h-[70vh] object-contain"})}):l!=null&&l.binary?v.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")?v.jsx("div",{className:"text-sm",children:v.jsx(ene,{remarkPlugins:[hie],rehypePlugins:[eoe],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})}):v.jsx("pre",{className:"text-xs whitespace-pre-wrap break-all",children:l==null?void 0:l.content})})]})}),v.jsx(ps,{open:T,onOpenChange:O,children:v.jsxs(vo,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col",children:[v.jsx(Al,{children:v.jsx(ms,{className:"text-sm",children:"Activity Log"})}),v.jsxs("div",{className:"overflow-y-auto flex-1 space-y-2",children:[C.map(B=>v.jsxs("div",{className:"border-b border-border/50 pb-2 last:border-0",children:[v.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[v.jsx("span",{className:"text-sm text-foreground",children:B.message}),v.jsx("span",{className:"text-[10px] text-muted-foreground shrink-0",children:Ese(B.date)})]}),B.files.length>0&&v.jsx("div",{className:"text-[11px] text-muted-foreground mt-0.5",children:B.files.map(q=>v.jsx("span",{className:"inline-block mr-2 font-mono",children:q},q))})]},B.hash)),C.length===0&&v.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No activity yet"})]})]})})]})}function Ese(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 eb(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 o=Math.floor(i/24),l=i%24;return l?`${o}d ${l}h`:`${o}d`}const _se=/resets\s+(\d{1,2})(?::(\d{2}))?\s*(am|pm)?\s*\(UTC\)/i;function Sse(e,t=Date.now(),n=Date.now()){var h;const r=e.match(_se);if(!r)return e;let i=Number(r[1]);const a=r[2]?Number(r[2]):0,o=(h=r[3])==null?void 0:h.toLowerCase();if(o==="pm"&&i<12&&(i+=12),o==="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"}),f=eb(u.toISOString(),n);return e.replace(r[0],`resets ${d}${f?` (in ${f})`:""}`)}var kse=Object.defineProperty,Xd=(e,t)=>kse(e,"name",{value:t,configurable:!0}),HU=!!(typeof window<"u"&&window.document&&window.document.createElement);function xl(e,t,{checkForDefaultPrevented:n=!0}={}){return Xd(function(i){if(e==null||e(i),n===!1||!i||!i.defaultPrevented)return t==null?void 0:t(i)},"handleEvent")}Xd(xl,"composeEventHandlers");function Ase(e){var t;if(!HU)throw new Error("Cannot access window outside of the DOM");return((t=e==null?void 0:e.ownerDocument)==null?void 0:t.defaultView)??window}Xd(Ase,"getOwnerWindow");function X_(e){if(!HU)throw new Error("Cannot access document outside of the DOM");return(e==null?void 0:e.ownerDocument)??document}Xd(X_,"getOwnerDocument");function qU(e,t=!1){const{activeElement:n}=X_(e);if(!(n!=null&&n.nodeName))return null;if(KU(n)&&n.contentDocument)return qU(n.contentDocument.body,t);if(t){const r=n.getAttribute("aria-activedescendant");if(r){const i=X_(n).getElementById(r);if(i)return i}}return n}Xd(qU,"getActiveElement");function KU(e){return e.tagName==="IFRAME"}Xd(KU,"isFrame");var Nse=Object.defineProperty,mk=(e,t)=>Nse(e,"name",{value:t,configurable:!0});function Z_(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}mk(Z_,"setRef");function GU(...e){return t=>{let n=!1;const r=e.map(i=>{const a=Z_(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():Z_(e[i],null)}}}}mk(GU,"composeRefs");function Zd(...e){return w.useCallback(GU(...e),e)}mk(Zd,"useComposedRefs");var Tse=Object.defineProperty,da=(e,t)=>Tse(e,"name",{value:t,configurable:!0});function Ose(e,t){const n=w.createContext(t);n.displayName=e+"Context";const r=da(a=>{const{children:o,...l}=a,u=w.useMemo(()=>l,Object.values(l));return v.jsx(n.Provider,{value:u,children:o})},"Provider");r.displayName=e+"Provider";function i(a,o={}){const{optional:l=!1}=o,u=w.useContext(n);if(u)return u;if(t!==void 0)return t;if(!l)throw new Error(`\`${a}\` must be used within \`${e}\``)}return da(i,"useContext"),[r,i]}da(Ose,"createContext");function WU(e,t=[]){let n=[];function r(a,o){const l=w.createContext(o);l.displayName=a+"Context";const u=n.length;n=[...n,o];const d=da(h=>{var _;const{scope:m,children:g,...x}=h,y=((_=m==null?void 0:m[e])==null?void 0:_[u])||l,E=w.useMemo(()=>x,Object.values(x));return v.jsx(y.Provider,{value:E,children:g})},"Provider");d.displayName=a+"Provider";function f(h,m,g={}){var _;const{optional:x=!1}=g,y=((_=m==null?void 0:m[e])==null?void 0:_[u])||l,E=w.useContext(y);if(E)return E;if(o!==void 0)return o;if(!x)throw new Error(`\`${h}\` must be used within \`${a}\``)}return da(f,"useContext"),[d,f]}da(r,"createContext");const i=da(()=>{const a=n.map(o=>w.createContext(o));return da(function(l){const u=(l==null?void 0:l[e])||a;return w.useMemo(()=>({[`__scope${e}`]:{...l,[e]:u}}),[l,u])},"useScope")},"createScope");return i.scopeName=e,[r,VU(i,...t)]}da(WU,"createContextScope");function VU(...e){const t=e[0];if(e.length===1)return t;const n=da(()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return da(function(a){const o=r.reduce((l,{useScope:u,scopeName:d})=>{const h=u(a)[`__scope${d}`];return{...l,...h}},{});return w.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])},"useComposedScopes")},"createScope");return n.scopeName=t.scopeName,n}da(VU,"composeContextScopes");var Cse=Object.defineProperty,$a=(e,t)=>Cse(e,"name",{value:t,configurable:!0});function gk(e){const t=w.forwardRef((n,r)=>{let{children:i,...a}=n,o=null,l=!1;const u=[];Q_(i)&&typeof wg=="function"&&(i=wg(i._payload)),w.Children.forEach(i,m=>{var g;if(QU(m)){l=!0;const x=m;let y="child"in x.props?x.props.child:x.props.children;Q_(y)&&typeof wg=="function"&&(y=wg(y._payload)),o=Ise(x,y),u.push((g=o==null?void 0:o.props)==null?void 0:g.children)}else u.push(m)}),o?o=w.cloneElement(o,void 0,u):!l&&w.Children.count(i)===1&&w.isValidElement(i)&&(o=i);const d=o?ZU(o):void 0,f=Zd(r,d);if(!o){if(i||i===0)throw new Error(l?Pse(e):Dse(e));return i}const h=XU(a,o.props??{});return o.type!==w.Fragment&&(h.ref=r?f:d),w.cloneElement(o,h)});return t.displayName=`${e}.Slot`,t}$a(gk,"createSlot");var YU=Symbol.for("radix.slottable");function Rse(e){const t=$a(n=>"child"in n?n.children(n.child):n.children,"Slottable");return t.displayName=`${e}.Slottable`,t.__radixId=YU,t}$a(Rse,"createSlottable");var Ise=$a((e,t)=>{if("child"in e.props){const n=e.props.child;return w.isValidElement(n)?w.cloneElement(n,void 0,e.props.children(n.props.children)):null}return w.isValidElement(t)?t:null},"getSlottableElementFromSlottable");function XU(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}}$a(XU,"mergeProps");function ZU(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)}$a(ZU,"getElementRef");function QU(e){return w.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===YU}$a(QU,"isSlottable");var Mse=Symbol.for("react.lazy");function Q_(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Mse&&"_payload"in e&&JU(e._payload)}$a(Q_,"isLazyComponent");function JU(e){return typeof e=="object"&&e!==null&&"then"in e}$a(JU,"isPromiseLike");var Dse=$a(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),Pse=$a(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),wg=Ao[" use ".trim().toString()],Lse=Object.defineProperty,jse=(e,t)=>Lse(e,"name",{value:t,configurable:!0}),$se=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Yv=$se.reduce((e,t)=>{const n=gk(`Primitive.${t}`),r=w.forwardRef((i,a)=>{const{asChild:o,...l}=i,u=o?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),v.jsx(u,{...l,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function e5(e,t){e&&No.flushSync(()=>e.dispatchEvent(t))}jse(e5,"dispatchDiscreteCustomEvent");var zse=Object.defineProperty,Bse=(e,t)=>zse(e,"name",{value:t,configurable:!0});function Xv(e){const t=w.useRef(e);return w.useEffect(()=>{t.current=e}),w.useMemo(()=>((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)}),[])}Bse(Xv,"useCallbackRef");var Use=Object.defineProperty,br=(e,t)=>Use(e,"name",{value:t,configurable:!0}),J_="dismissableLayer.update",Fse="dismissableLayer.pointerDownOutside",Hse="dismissableLayer.focusOutside",HM,t5=w.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),qse=w.forwardRef(br(function(t,n){const{disableOutsidePointerEvents:r=!1,deferPointerDownOutside:i=!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:l,onInteractOutside:u,onDismiss:d,...f}=t,h=w.useContext(t5),[m,g]=w.useState(null),x=(m==null?void 0:m.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,y]=w.useState({}),E=Zd(n,g),_=Array.from(h.layers),[A]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),N=A?_.indexOf(A):-1,T=m?_.indexOf(m):-1,O=h.layersWithOutsidePointerEventsDisabled.size>0,C=T>=N,R=w.useRef(!1),M=n5(L=>{o==null||o(L),u==null||u(L),L.defaultPrevented||d==null||d()},{ownerDocument:x,deferPointerDownOutside:i,isDeferredPointerDownOutsideRef:R,dismissableSurfaces:h.dismissableSurfaces,shouldHandlePointerDownOutside:w.useCallback(L=>{if(!(L instanceof Node))return!1;const G=[...h.branches].some(W=>W.contains(L));return C&&!G},[h.branches,C])}),P=r5(L=>{if(i&&R.current)return;const G=L.target;[...h.branches].some(X=>X.contains(G))||(l==null||l(L),u==null||u(L),L.defaultPrevented||d==null||d())},x),D=m?T===_.length-1:!1,F=Xv(L=>{L.key==="Escape"&&(a==null||a(L),!L.defaultPrevented&&d&&(L.preventDefault(),d()))});return w.useEffect(()=>{if(D)return x.addEventListener("keydown",F,{capture:!0}),()=>x.removeEventListener("keydown",F,{capture:!0})},[x,D,F]),w.useEffect(()=>{if(m)return r&&(h.layersWithOutsidePointerEventsDisabled.size===0&&(HM=x.body.style.pointerEvents,x.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(m)),h.layers.add(m),eS(),()=>{r&&(h.layersWithOutsidePointerEventsDisabled.delete(m),h.layersWithOutsidePointerEventsDisabled.size===0&&(x.body.style.pointerEvents=HM))}},[m,x,r,h]),w.useEffect(()=>()=>{m&&(h.layers.delete(m),h.layersWithOutsidePointerEventsDisabled.delete(m),eS())},[m,h]),w.useEffect(()=>{const L=br(()=>y({}),"handleUpdate");return document.addEventListener(J_,L),()=>document.removeEventListener(J_,L)},[]),v.jsx(Yv.div,{...f,ref:E,style:{pointerEvents:O?C?"auto":"none":void 0,...t.style},onFocusCapture:xl(t.onFocusCapture,P.onFocusCapture),onBlurCapture:xl(t.onBlurCapture,P.onBlurCapture),onPointerDownCapture:xl(t.onPointerDownCapture,M.onPointerDownCapture)})},"DismissableLayer"));function Kse(){const e=w.useContext(t5),[t,n]=w.useState(null);return w.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}br(Kse,"useDismissableLayerSurface");var Gse=br(()=>!0,"IS_TRUE");function n5(e,t){const{ownerDocument:n=globalThis==null?void 0:globalThis.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:o=Gse}=t,l=Xv(e),u=w.useRef(!1),d=w.useRef(!1),f=w.useRef(new Map),h=w.useRef(()=>{});return w.useEffect(()=>{function m(){d.current=!1,i.current=!1,f.current.clear()}br(m,"resetOutsideInteraction");function g(){return Array.from(f.current.values()).some(Boolean)}br(g,"isOutsideInteractionIntercepted");function x(N){if(!d.current)return;const T=N.target;T instanceof Node&&[...a].some(C=>C.contains(T))||f.current.set(N.type,!0),N.type==="click"&&window.setTimeout(()=>{d.current&&h.current()},0)}br(x,"handleInteractionCapture");function y(N){d.current&&f.current.set(N.type,!1)}br(y,"handleInteractionBubble");const E=br(N=>{if(N.target&&!u.current){let T=function(){n.removeEventListener("click",h.current);const C=g();m(),C||bk(Fse,l,O,{discrete:!0})};if(br(T,"handleAndDispatchPointerDownOutsideEvent"),!o(N.target)){n.removeEventListener("click",h.current),m(),u.current=!1;return}const O={originalEvent:N};d.current=!0,i.current=r&&N.button===0,f.current.clear(),!r||N.button!==0?T():(n.removeEventListener("click",h.current),h.current=T,n.addEventListener("click",h.current,{once:!0}))}else n.removeEventListener("click",h.current),m();u.current=!1},"handlePointerDown"),_=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const N of _)n.addEventListener(N,x,!0),n.addEventListener(N,y);const A=window.setTimeout(()=>{n.addEventListener("pointerdown",E)},0);return()=>{window.clearTimeout(A),n.removeEventListener("pointerdown",E),n.removeEventListener("click",h.current);for(const N of _)n.removeEventListener(N,x,!0),n.removeEventListener(N,y)}},[n,l,r,i,a,o]),{onPointerDownCapture:br(()=>u.current=!0,"onPointerDownCapture")}}br(n5,"usePointerDownOutside");function r5(e,t=globalThis==null?void 0:globalThis.document){const n=Xv(e),r=w.useRef(!1);return w.useEffect(()=>{const i=br(a=>{a.target&&!r.current&&bk(Hse,n,{originalEvent:a},{discrete:!1})},"handleFocus");return t.addEventListener("focusin",i),()=>t.removeEventListener("focusin",i)},[t,n]),{onFocusCapture:br(()=>r.current=!0,"onFocusCapture"),onBlurCapture:br(()=>r.current=!1,"onBlurCapture")}}br(r5,"useFocusOutside");function eS(){const e=new CustomEvent(J_);document.dispatchEvent(e)}br(eS,"dispatchUpdate");function bk(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?e5(i,a):i.dispatchEvent(a)}br(bk,"handleAndDispatchCustomEvent");var Wse=Object.defineProperty,vk=(e,t)=>Wse(e,"name",{value:t,configurable:!0}),Eg=0,Ja=null;function Vse(e){return yk(),e.children}vk(Vse,"FocusGuards");function yk(){w.useEffect(()=>{Ja||(Ja={start:tS(),end:tS()});const{start:e,end:t}=Ja;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),Eg++,()=>{Eg===1&&(Ja==null||Ja.start.remove(),Ja==null||Ja.end.remove(),Ja=null),Eg=Math.max(0,Eg-1)}},[])}vk(yk,"useFocusGuards");function tS(){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}vk(tS,"createFocusGuard");var Yse=Object.defineProperty,Xse=(e,t)=>Yse(e,"name",{value:t,configurable:!0});function nS(e){const t=w.useRef(e);return w.useEffect(()=>{t.current=e}),w.useMemo(()=>((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)}),[])}Xse(nS,"useCallbackRef");var Zse=Object.defineProperty,Qr=(e,t)=>Zse(e,"name",{value:t,configurable:!0}),$w="focusScope.autoFocusOnMount",zw="focusScope.autoFocusOnUnmount",qM={bubbles:!1,cancelable:!0},Qse=w.forwardRef(Qr(function(t,n){const{loop:r=!1,trapped:i=!1,onMountAutoFocus:a,onUnmountAutoFocus:o,...l}=t,[u,d]=w.useState(null),f=nS(a),h=nS(o),m=w.useRef(null),g=Zd(n,d),x=w.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;w.useEffect(()=>{if(i){let E=function(T){if(x.paused||!u)return;const O=T.target;u.contains(O)?m.current=O:Qo(m.current,{select:!0})},_=function(T){if(x.paused||!u)return;const O=T.relatedTarget;O!==null&&(u.contains(O)||Qo(m.current,{select:!0}))},A=function(T){if(document.activeElement===document.body)for(const C of T)C.removedNodes.length>0&&Qo(u)};Qr(E,"handleFocusIn"),Qr(_,"handleFocusOut"),Qr(A,"handleMutations"),document.addEventListener("focusin",E),document.addEventListener("focusout",_);const N=new MutationObserver(A);return u&&N.observe(u,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",E),document.removeEventListener("focusout",_),N.disconnect()}}},[i,u,x.paused]),w.useEffect(()=>{if(u){KM.add(x);const E=document.activeElement;if(!u.contains(E)){const A=new CustomEvent($w,qM);u.addEventListener($w,f),u.dispatchEvent(A),A.defaultPrevented||(i5(c5(xk(u)),{select:!0}),document.activeElement===E&&Qo(u))}return()=>{u.removeEventListener($w,f),setTimeout(()=>{const A=new CustomEvent(zw,qM);u.addEventListener(zw,h),u.dispatchEvent(A),A.defaultPrevented||Qo(E??document.body,{select:!0}),u.removeEventListener(zw,h),KM.remove(x)},0)}}},[u,f,h,x]);const y=w.useCallback(E=>{if(!r&&!i||x.paused)return;const _=E.key==="Tab"&&!E.altKey&&!E.ctrlKey&&!E.metaKey,A=document.activeElement;if(_&&A){const N=E.currentTarget,[T,O]=a5(N);T&&O?!E.shiftKey&&A===O?(E.preventDefault(),r&&Qo(T,{select:!0})):E.shiftKey&&A===T&&(E.preventDefault(),r&&Qo(O,{select:!0})):A===N&&E.preventDefault()}},[r,i,x.paused]);return v.jsx(Yv.div,{tabIndex:-1,...l,ref:g,onKeyDown:y})},"FocusScope"));function i5(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Qo(r,{select:t}),document.activeElement!==n)return}Qr(i5,"focusFirst");function a5(e){const t=xk(e),n=rS(t,e),r=rS(t.reverse(),e);return[n,r]}Qr(a5,"getTabbableEdges");function xk(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:Qr(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}Qr(xk,"getTabbableCandidates");function rS(e,t){const n=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):o5(r,{upTo:t})))return r}Qr(rS,"findVisible");function o5(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}Qr(o5,"isHidden");function s5(e){return e instanceof HTMLInputElement&&"select"in e}Qr(s5,"isSelectableInput");function Qo(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&s5(e)&&t&&e.select()}}Qr(Qo,"focus");var KM=l5();function l5(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=iS(e,t),e.unshift(t)},remove(t){var n;e=iS(e,t),(n=e[0])==null||n.resume()}}}Qr(l5,"createFocusScopesStack");function iS(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}Qr(iS,"arrayRemove");function c5(e){return e.filter(t=>t.tagName!=="A")}Qr(c5,"removeLinks");var Jse=globalThis!=null&&globalThis.document?w.useLayoutEffect:()=>{},ele=Object.defineProperty,tle=(e,t)=>ele(e,"name",{value:t,configurable:!0}),nle=Ao[" useId ".trim().toString()]||(()=>{}),rle=0;function u5(e){const[t,n]=w.useState(nle());return Jse(()=>{e||n(r=>r??String(rle++))},[e]),e||(t?`radix-${t}`:"")}tle(u5,"useId");const ile=["top","right","bottom","left"],Nl=Math.min,ss=Math.max,Cb=Math.round,_g=Math.floor,ls=e=>({x:e,y:e}),ale={left:"right",right:"left",bottom:"top",top:"bottom"};function d5(e,t,n){return ss(e,Nl(t,n))}function gs(e,t){return typeof e=="function"?e(t):e}function Tl(e){return e.split("-")[0]}function Qd(e){return e.split("-")[1]}function wk(e){return e==="x"?"y":"x"}function Ek(e){return e==="y"?"height":"width"}function co(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function _k(e){return wk(co(e))}function ole(e,t,n){n===void 0&&(n=!1);const r=Qd(e),i=_k(e),a=Ek(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(o=Rb(o)),[o,Rb(o)]}function sle(e){const t=Rb(e);return[aS(e),t,aS(t)]}function aS(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const GM=["left","right"],WM=["right","left"],lle=["top","bottom"],cle=["bottom","top"];function ule(e,t,n){switch(e){case"top":case"bottom":return n?t?WM:GM:t?GM:WM;case"left":case"right":return t?lle:cle;default:return[]}}function dle(e,t,n,r){const i=Qd(e);let a=ule(Tl(e),n==="start",r);return i&&(a=a.map(o=>o+"-"+i),t&&(a=a.concat(a.map(aS)))),a}function Rb(e){const t=Tl(e);return ale[t]+e.slice(t.length)}function fle(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 f5(e){return typeof e!="number"?fle(e):{top:e,right:e,bottom:e,left:e}}function Ib(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 VM(e,t,n){let{reference:r,floating:i}=e;const a=co(t),o=_k(t),l=Ek(o),u=Tl(t),d=a==="y",f=r.x+r.width/2-i.width/2,h=r.y+r.height/2-i.height/2,m=r[l]/2-i[l]/2;let g;switch(u){case"top":g={x:f,y:r.y-i.height};break;case"bottom":g={x:f,y:r.y+r.height};break;case"right":g={x:r.x+r.width,y:h};break;case"left":g={x:r.x-i.width,y:h};break;default:g={x:r.x,y:r.y}}const x=Qd(t);return x&&(g[o]+=m*(x==="end"?1:-1)*(n&&d?-1:1)),g}async function hle(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:a,rects:o,elements:l,strategy:u}=e,{boundary:d="clippingAncestors",rootBoundary:f="viewport",elementContext:h="floating",altBoundary:m=!1,padding:g=0}=gs(t,e),x=f5(g),E=l[m?h==="floating"?"reference":"floating":h],_=Ib(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:f,strategy:u})),A=h==="floating"?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,N=await(a.getOffsetParent==null?void 0:a.getOffsetParent(l.floating)),T=await(a.isElement==null?void 0:a.isElement(N))&&await(a.getScale==null?void 0:a.getScale(N))||{x:1,y:1},O=Ib(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:A,offsetParent:N,strategy:u}):A);return{top:(_.top-O.top+x.top)/T.y,bottom:(O.bottom-_.bottom+x.bottom)/T.y,left:(_.left-O.left+x.left)/T.x,right:(O.right-_.right+x.right)/T.x}}const ple=50,mle=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:a=[],platform:o}=n,l=o.detectOverflow?o:{...o,detectOverflow:hle},u=await(o.isRTL==null?void 0:o.isRTL(t));let d=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:f,y:h}=VM(d,r,u),m=r,g=0;const x={};for(let y=0;y<a.length;y++){const E=a[y];if(!E)continue;const{name:_,fn:A}=E,{x:N,y:T,data:O,reset:C}=await A({x:f,y:h,initialPlacement:r,placement:m,strategy:i,middlewareData:x,rects:d,platform:l,elements:{reference:e,floating:t}});f=N??f,h=T??h,x[_]={...x[_],...O},C&&g<ple&&(g++,typeof C=="object"&&(C.placement&&(m=C.placement),C.rects&&(d=C.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):C.rects),{x:f,y:h}=VM(d,m,u)),y=-1)}return{x:f,y:h,placement:m,strategy:i,middlewareData:x}},gle=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:a,platform:o,elements:l,middlewareData:u}=t,{element:d,padding:f=0}=gs(e,t)||{};if(d==null)return{};const h=f5(f),m={x:n,y:r},g=_k(i),x=Ek(g),y=await o.getDimensions(d),E=g==="y",_=E?"top":"left",A=E?"bottom":"right",N=E?"clientHeight":"clientWidth",T=a.reference[x]+a.reference[g]-m[g]-a.floating[x],O=m[g]-a.reference[g],C=await(o.getOffsetParent==null?void 0:o.getOffsetParent(d));let R=C?C[N]:0;(!R||!await(o.isElement==null?void 0:o.isElement(C)))&&(R=l.floating[N]||a.floating[x]);const M=T/2-O/2,P=R/2-y[x]/2-1,D=Nl(h[_],P),F=Nl(h[A],P),L=R-y[x]-F,G=R/2-y[x]/2+M,W=d5(D,G,L),X=!u.arrow&&Qd(i)!=null&&G!==W&&a.reference[x]/2-(G<D?D:F)-y[x]/2<0,B=X?G<D?G-D:G-L:0;return{[g]:m[g]+B,data:{[g]:W,centerOffset:G-W-B,...X&&{alignmentOffset:B}},reset:X}}}),ble=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:a,rects:o,initialPlacement:l,platform:u,elements:d}=t,{mainAxis:f=!0,crossAxis:h=!0,fallbackPlacements:m,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:y=!0,...E}=gs(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const _=Tl(i),A=co(l),N=Tl(l)===l,T=await(u.isRTL==null?void 0:u.isRTL(d.floating)),O=m||(N||!y?[Rb(l)]:sle(l)),C=x!=="none";!m&&C&&O.push(...dle(l,y,x,T));const R=[l,...O],M=await u.detectOverflow(t,E),P=[];let D=((r=a.flip)==null?void 0:r.overflows)||[];if(f&&P.push(M[_]),h){const W=ole(i,o,T);P.push(M[W[0]],M[W[1]])}if(D=[...D,{placement:i,overflows:P}],!P.every(W=>W<=0)){var F,L;const W=(((F=a.flip)==null?void 0:F.index)||0)+1,X=R[W];if(X&&(!(h==="alignment"?A!==co(X):!1)||D.every(H=>co(H.placement)===A?H.overflows[0]>0:!0)))return{data:{index:W,overflows:D},reset:{placement:X}};let B=(L=D.filter(q=>q.overflows[0]<=0).sort((q,H)=>q.overflows[1]-H.overflows[1])[0])==null?void 0:L.placement;if(!B)switch(g){case"bestFit":{var G;const q=(G=D.filter(H=>{if(C){const V=co(H.placement);return V===A||V==="y"}return!0}).map(H=>[H.placement,H.overflows.filter(V=>V>0).reduce((V,z)=>V+z,0)]).sort((H,V)=>H[1]-V[1])[0])==null?void 0:G[0];q&&(B=q);break}case"initialPlacement":B=l;break}if(i!==B)return{reset:{placement:B}}}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 ile.some(t=>e[t]>=0)}const vle=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:i="referenceHidden",...a}=gs(e,t);switch(i){case"referenceHidden":{const o=await r.detectOverflow(t,{...a,elementContext:"reference"}),l=YM(o,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:XM(l)}}}case"escaped":{const o=await r.detectOverflow(t,{...a,altBoundary:!0}),l=YM(o,n.floating);return{data:{escapedOffsets:l,escaped:XM(l)}}}default:return{}}}}},h5=new Set(["left","top"]);async function yle(e,t){const{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Tl(n),l=Qd(n),u=co(n)==="y",d=h5.has(o)?-1:1,f=a&&u?-1:1,h=gs(t,e);let{mainAxis:m,crossAxis:g,alignmentAxis:x}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return l&&typeof x=="number"&&(g=l==="end"?x*-1:x),u?{x:g*f,y:m*d}:{x:m*d,y:g*f}}const xle=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:a,placement:o,middlewareData:l}=t,u=await yle(t,e);return o===((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:o}}}}},wle=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:o=!0,crossAxis:l=!1,limiter:u={fn:A=>{let{x:N,y:T}=A;return{x:N,y:T}}},...d}=gs(e,t),f={x:n,y:r},h=await a.detectOverflow(t,d),m=co(i),g=wk(m);let x=f[g],y=f[m];const E=(A,N)=>d5(N+h[A==="y"?"top":"left"],N,N-h[A==="y"?"bottom":"right"]);o&&(x=E(g,x)),l&&(y=E(m,y));const _=u.fn({...t,[g]:x,[m]:y});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[g]:o,[m]:l}}}}}},Ele=function(e){return e===void 0&&(e={}),{options:e,fn(t){var n,r;const{x:i,y:a,placement:o,rects:l,middlewareData:u}=t,{offset:d=0,mainAxis:f=!0,crossAxis:h=!0}=gs(e,t),m={x:i,y:a},g=co(o),x=wk(g);let y=m[x],E=m[g];const _=gs(d,t),A=typeof _=="number"?{mainAxis:_,crossAxis:0}:{mainAxis:(n=_.mainAxis)!=null?n:0,crossAxis:(r=_.crossAxis)!=null?r:0};if(f){const O=x==="y"?"height":"width",C=l.reference[x]-l.floating[O]+A.mainAxis,R=l.reference[x]+l.reference[O]-A.mainAxis;y<C?y=C:y>R&&(y=R)}if(h){var N,T;const O=x==="y"?"width":"height",C=h5.has(Tl(o)),R=l.reference[g]-l.floating[O]+(C&&((N=u.offset)==null?void 0:N[g])||0)+(C?0:A.crossAxis),M=l.reference[g]+l.reference[O]+(C?0:((T=u.offset)==null?void 0:T[g])||0)-(C?A.crossAxis:0);E<R?E=R:E>M&&(E=M)}return{[x]:y,[g]:E}}}},_le=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:o=()=>{},...l}=gs(e,t),u=await i.detectOverflow(t,l),d=Tl(n),f=Qd(n),h=co(n)==="y",{width:m,height:g}=r.floating;let x,y;d==="top"||d==="bottom"?(x=d,y=f===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=d,x=f==="end"?"top":"bottom");const E=g-u.top-u.bottom,_=m-u.left-u.right,A=Nl(g-u[x],E),N=Nl(m-u[y],_),T=t.middlewareData.shift,O=!T;let C=A,R=N;T!=null&&T.enabled.x&&(R=_),T!=null&&T.enabled.y&&(C=E),O&&!f&&(h?R=m-2*ss(u.left,u.right):C=g-2*ss(u.top,u.bottom)),await o({...t,availableWidth:R,availableHeight:C});const M=await i.getDimensions(a.floating);return m!==M.width||g!==M.height?{reset:{rects:!0}}:{}}}};function Zv(){return typeof window<"u"}function Jd(e){return p5(e)?(e.nodeName||"").toLowerCase():"#document"}function bi(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function _s(e){var t;return(t=(p5(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function p5(e){return Zv()?e instanceof Node||e instanceof bi(e).Node:!1}function yo(e){return Zv()?e instanceof Element||e instanceof bi(e).Element:!1}function $l(e){return Zv()?e instanceof HTMLElement||e instanceof bi(e).HTMLElement:!1}function ZM(e){return!Zv()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof bi(e).ShadowRoot}function Qv(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=xo(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function Sle(e){return/^(table|td|th)$/.test(Jd(e))}function Jv(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const kle=/transform|translate|scale|rotate|perspective|filter/,Ale=/paint|layout|strict|content/,dc=e=>!!e&&e!=="none";let Bw;function Sk(e){const t=yo(e)?xo(e):e;return dc(t.transform)||dc(t.translate)||dc(t.scale)||dc(t.rotate)||dc(t.perspective)||!kk()&&(dc(t.backdropFilter)||dc(t.filter))||kle.test(t.willChange||"")||Ale.test(t.contain||"")}function Nle(e){let t=Hc(e);for(;$l(t)&&!Vh(t);){if(Sk(t))return t;if(Jv(t))return null;t=Hc(t)}return null}function kk(){return Bw==null&&(Bw=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Bw}function Vh(e){return/^(html|body|#document)$/.test(Jd(e))}function xo(e){return bi(e).getComputedStyle(e)}function ey(e){return yo(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Hc(e){if(Jd(e)==="html")return e;const t=e.assignedSlot||e.parentNode||ZM(e)&&e.host||_s(e);return ZM(t)?t.host:t}function m5(e){const t=Hc(e);return Vh(t)?(e.ownerDocument||e).body:$l(t)&&Qv(t)?t:m5(t)}function Yh(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=m5(e),a=i===((r=e.ownerDocument)==null?void 0:r.body),o=bi(i);if(a){const l=oS(o);return t.concat(o,o.visualViewport||[],Qv(i)?i:[],l&&n?Yh(l):[])}else return t.concat(i,Yh(i,[],n))}function oS(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function g5(e){const t=xo(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=$l(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,l=Cb(n)!==a||Cb(r)!==o;return l&&(n=a,r=o),{width:n,height:r,$:l}}function Ak(e){return yo(e)?e:e.contextElement}function wd(e){const t=Ak(e);if(!$l(t))return ls(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:a}=g5(t);let o=(a?Cb(n.width):n.width)/r,l=(a?Cb(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const Tle=ls(0);function b5(e){const t=bi(e);return!kk()||!t.visualViewport?Tle:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ole(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===bi(e)}function qc(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),a=Ak(e);let o=ls(1);t&&(r?yo(r)&&(o=wd(r)):o=wd(e));const l=Ole(a,n,r)?b5(a):ls(0);let u=(i.left+l.x)/o.x,d=(i.top+l.y)/o.y,f=i.width/o.x,h=i.height/o.y;if(a&&r){const m=bi(a),g=yo(r)?bi(r):r;let x=m,y=oS(x);for(;y&&g!==x;){const E=wd(y),_=y.getBoundingClientRect(),A=xo(y),N=_.left+(y.clientLeft+parseFloat(A.paddingLeft))*E.x,T=_.top+(y.clientTop+parseFloat(A.paddingTop))*E.y;u*=E.x,d*=E.y,f*=E.x,h*=E.y,u+=N,d+=T,x=bi(y),y=oS(x)}}return Ib({width:f,height:h,x:u,y:d})}function ty(e,t){const n=ey(e).scrollLeft;return t?t.left+n:qc(_s(e)).left+n}function v5(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-ty(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function Cle(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const a=i==="fixed",o=_s(r),l=t?Jv(t.floating):!1;if(r===o||l&&a)return n;let u={scrollLeft:0,scrollTop:0},d=ls(1);const f=ls(0),h=$l(r);if((h||!a)&&((Jd(r)!=="body"||Qv(o))&&(u=ey(r)),h)){const g=qc(r);d=wd(r),f.x=g.x+r.clientLeft,f.y=g.y+r.clientTop}const m=o&&!h&&!a?v5(o,u):ls(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-u.scrollLeft*d.x+f.x+m.x,y:n.y*d.y-u.scrollTop*d.y+f.y+m.y}}function Rle(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function Ile(e){const t=ey(e),n=e.ownerDocument.body,r=ss(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=ss(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let a=-t.scrollLeft+ty(e);const o=-t.scrollTop;return xo(n).direction==="rtl"&&(a+=ss(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}const Mle=25;function Dle(e,t,n){n===void 0&&(n="viewport");const r=n==="layoutViewport",i=bi(e),a=_s(e),o=i.visualViewport;let l=a.clientWidth,u=a.clientHeight,d=0,f=0;if(o){const m=!kk()||t==="fixed";r?m||(d=-o.offsetLeft,f=-o.offsetTop):(l=o.width,u=o.height,m&&(d=o.offsetLeft,f=o.offsetTop))}if(ty(a)<=0){const m=a.ownerDocument,g=m.body,x=getComputedStyle(g),y=m.compatMode==="CSS1Compat"&&parseFloat(x.marginLeft)+parseFloat(x.marginRight)||0,E=Math.abs(a.clientWidth-g.clientWidth-y),_=getComputedStyle(a).scrollbarGutter==="stable both-edges"?E/2:E;_<=Mle&&(l-=_)}return{width:l,height:u,x:d,y:f}}function Ple(e,t){const n=qc(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=wd(e),o=e.clientWidth*a.x,l=e.clientHeight*a.y,u=i*a.x,d=r*a.y;return{width:o,height:l,x:u,y:d}}function QM(e,t,n){let r;if(t==="viewport"||t==="layoutViewport")r=Dle(e,n,t);else if(t==="document")r=Ile(_s(e));else if(yo(t))r=Ple(t,n);else{const i=b5(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return Ib(r)}function Lle(e,t){const n=t.get(e);if(n)return n;let r=Yh(e,[],!1).filter(l=>yo(l)&&Jd(l)!=="body"),i=null;const a=xo(e).position==="fixed";let o=a?Hc(e):e;for(;yo(o)&&!Vh(o);){const l=xo(o),u=Sk(o),d=i?i.position:a?"fixed":"";!u&&(d==="fixed"||d==="absolute"&&l.position==="static")?r=r.filter(h=>h!==o):i=l,o=Hc(o)}return t.set(e,r),r}function jle(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const o=[...n==="clippingAncestors"?Jv(t)?[]:Lle(t,this._c):[].concat(n),r],l=QM(t,o[0],i);let u=l.top,d=l.right,f=l.bottom,h=l.left;for(let m=1;m<o.length;m++){const g=QM(t,o[m],i);u=ss(g.top,u),d=Nl(g.right,d),f=Nl(g.bottom,f),h=ss(g.left,h)}return{width:d-h,height:f-u,x:h,y:u}}function $le(e){const{width:t,height:n}=g5(e);return{width:t,height:n}}function zle(e,t,n){const r=$l(t),i=_s(t),a=n==="fixed",o=qc(e,!0,a,t);let l={scrollLeft:0,scrollTop:0};const u=ls(0);if((r||!a)&&((Jd(t)!=="body"||Qv(i))&&(l=ey(t)),r)){const m=qc(t,!0,a,t);u.x=m.x+t.clientLeft,u.y=m.y+t.clientTop}!r&&i&&(u.x=ty(i));const d=i&&!r&&!a?v5(i,l):ls(0),f=o.left+l.scrollLeft-u.x-d.x,h=o.top+l.scrollTop-u.y-d.y;return{x:f,y:h,width:o.width,height:o.height}}function Uw(e){return xo(e).position==="static"}function JM(e,t){if(!$l(e)||xo(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return _s(e)===n&&(n=n.ownerDocument.body),n}function y5(e,t){const n=bi(e);if(Jv(e))return n;if(!$l(e)){let i=Hc(e);for(;i&&!Vh(i);){if(yo(i)&&!Uw(i))return i;i=Hc(i)}return n}let r=JM(e,t);for(;r&&Sle(r)&&Uw(r);)r=JM(r,t);return r&&Vh(r)&&Uw(r)&&!Sk(r)?n:r||Nle(e)||n}const Ble=async function(e){const t=this.getOffsetParent||y5,n=this.getDimensions,r=await n(e.floating);return{reference:zle(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Ule(e){return xo(e).direction==="rtl"}const Fle={convertOffsetParentRelativeRectToViewportRelativeRect:Cle,getDocumentElement:_s,getClippingRect:jle,getOffsetParent:y5,getElementRects:Ble,getClientRects:Rle,getDimensions:$le,getScale:wd,isElement:yo,isRTL:Ule};function x5(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Hle(e,t,n){let r=null,i;const a=_s(e);function o(){var f;clearTimeout(i),(f=r)==null||f.disconnect(),r=null}function l(f,h){f===void 0&&(f=!1),h===void 0&&(h=1),o();const m=e.getBoundingClientRect(),{left:g,top:x,width:y,height:E}=m;if(f||t(),!y||!E)return;const _=_g(x),A=_g(a.clientWidth-(g+y)),N=_g(a.clientHeight-(x+E)),T=_g(g),C={rootMargin:-_+"px "+-A+"px "+-N+"px "+-T+"px",threshold:ss(0,Nl(1,h))||1};let R=!0;function M(P){const D=P[0].intersectionRatio;if(!x5(m,e.getBoundingClientRect()))return l();if(D!==h){if(!R)return l();D?l(!1,D):i=setTimeout(()=>{l(!1,1e-7)},1e3)}R=!1}try{r=new IntersectionObserver(M,{...C,root:a.ownerDocument})}catch{r=new IntersectionObserver(M,C)}r.observe(e)}const u=bi(e),d=()=>l(n);return u.addEventListener("resize",d),l(!0),()=>{u.removeEventListener("resize",d),o()}}function qle(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,d=Ak(e),f=i||a?[...d?Yh(d):[],...t?Yh(t):[]]:[];f.forEach(_=>{i&&_.addEventListener("scroll",n),a&&_.addEventListener("resize",n)});const h=d&&l?Hle(d,n,a):null;let m=-1,g=null;o&&(g=new ResizeObserver(_=>{let[A]=_;A&&A.target===d&&g&&t&&(g.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var N;(N=g)==null||N.observe(t)})),n()}),d&&!u&&g.observe(d),t&&g.observe(t));let x,y=u?qc(e):null;u&&E();function E(){const _=qc(e);y&&!x5(y,_)&&n(),y=_,x=requestAnimationFrame(E)}return n(),()=>{var _;f.forEach(A=>{i&&A.removeEventListener("scroll",n),a&&A.removeEventListener("resize",n)}),h==null||h(),(_=g)==null||_.disconnect(),g=null,u&&cancelAnimationFrame(x)}}const Kle=xle,Gle=wle,Wle=ble,Vle=_le,Yle=vle,eD=gle,Xle=Ele,Zle=(e,t,n)=>{const r=new Map,i=n??{},a={...Fle,...i.platform,_c:r};return mle(e,t,{...i,platform:a})};var Qle=typeof document<"u",Jle=function(){},tb=Qle?w.useLayoutEffect:Jle;function Mb(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(!Mb(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)&&!Mb(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function w5(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function tD(e,t){const n=w5(e);return Math.round(t*n)/n}function Fw(e){const t=w.useRef(e);return tb(()=>{t.current=e}),t}function ece(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:l=!0,whileElementsMounted:u,open:d}=e,[f,h]=w.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,g]=w.useState(r);Mb(m,r)||g(r);const[x,y]=w.useState(null),[E,_]=w.useState(null),A=w.useCallback(H=>{H!==C.current&&(C.current=H,y(H))},[]),N=w.useCallback(H=>{H!==R.current&&(R.current=H,_(H))},[]),T=a||x,O=o||E,C=w.useRef(null),R=w.useRef(null),M=w.useRef(f),P=u!=null,D=Fw(u),F=Fw(i),L=Fw(d),G=w.useCallback(()=>{if(!C.current||!R.current)return;const H={placement:t,strategy:n,middleware:m};F.current&&(H.platform=F.current),Zle(C.current,R.current,H).then(V=>{const z={...V,isPositioned:L.current!==!1};W.current&&!Mb(M.current,z)&&(M.current=z,No.flushSync(()=>{h(z)}))})},[m,t,n,F,L]);tb(()=>{d===!1&&M.current.isPositioned&&(M.current.isPositioned=!1,h(H=>({...H,isPositioned:!1})))},[d]);const W=w.useRef(!1);tb(()=>(W.current=!0,()=>{W.current=!1}),[]),tb(()=>{if(T&&(C.current=T),O&&(R.current=O),T&&O){if(D.current)return D.current(T,O,G);G()}},[T,O,G,D,P]);const X=w.useMemo(()=>({reference:C,floating:R,setReference:A,setFloating:N}),[A,N]),B=w.useMemo(()=>({reference:T,floating:O}),[T,O]),q=w.useMemo(()=>{const H={position:n,left:0,top:0};if(!B.floating)return H;const V=tD(B.floating,f.x),z=tD(B.floating,f.y);return l?{...H,transform:"translate("+V+"px, "+z+"px)",...w5(B.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:V,top:z}},[n,l,B.floating,f.x,f.y]);return w.useMemo(()=>({...f,update:G,refs:X,elements:B,floatingStyles:q}),[f,G,X,B,q])}const tce=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?eD({element:r.current,padding:i}).fn(n):{}:r?eD({element:r,padding:i}).fn(n):{}}}},nce=(e,t)=>{const n=Kle(e);return{name:n.name,fn:n.fn,options:[e,t]}},rce=(e,t)=>{const n=Gle(e);return{name:n.name,fn:n.fn,options:[e,t]}},ice=(e,t)=>({fn:Xle(e).fn,options:[e,t]}),ace=(e,t)=>{const n=Wle(e);return{name:n.name,fn:n.fn,options:[e,t]}},oce=(e,t)=>{const n=Vle(e);return{name:n.name,fn:n.fn,options:[e,t]}},sce=(e,t)=>{const n=Yle(e);return{name:n.name,fn:n.fn,options:[e,t]}},lce=(e,t)=>{const n=tce(e);return{name:n.name,fn:n.fn,options:[e,t]}};var cce=Object.defineProperty,Nk=(e,t)=>cce(e,"name",{value:t,configurable:!0});function sS(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}Nk(sS,"setRef");function E5(...e){return t=>{let n=!1;const r=e.map(i=>{const a=sS(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():sS(e[i],null)}}}}Nk(E5,"composeRefs");function ny(...e){return w.useCallback(E5(...e),e)}Nk(ny,"useComposedRefs");var uce=Object.defineProperty,fa=(e,t)=>uce(e,"name",{value:t,configurable:!0});function dce(e,t){const n=w.createContext(t);n.displayName=e+"Context";const r=fa(a=>{const{children:o,...l}=a,u=w.useMemo(()=>l,Object.values(l));return v.jsx(n.Provider,{value:u,children:o})},"Provider");r.displayName=e+"Provider";function i(a,o={}){const{optional:l=!1}=o,u=w.useContext(n);if(u)return u;if(t!==void 0)return t;if(!l)throw new Error(`\`${a}\` must be used within \`${e}\``)}return fa(i,"useContext"),[r,i]}fa(dce,"createContext");function _5(e,t=[]){let n=[];function r(a,o){const l=w.createContext(o);l.displayName=a+"Context";const u=n.length;n=[...n,o];const d=fa(h=>{var _;const{scope:m,children:g,...x}=h,y=((_=m==null?void 0:m[e])==null?void 0:_[u])||l,E=w.useMemo(()=>x,Object.values(x));return v.jsx(y.Provider,{value:E,children:g})},"Provider");d.displayName=a+"Provider";function f(h,m,g={}){var _;const{optional:x=!1}=g,y=((_=m==null?void 0:m[e])==null?void 0:_[u])||l,E=w.useContext(y);if(E)return E;if(o!==void 0)return o;if(!x)throw new Error(`\`${h}\` must be used within \`${a}\``)}return fa(f,"useContext"),[d,f]}fa(r,"createContext");const i=fa(()=>{const a=n.map(o=>w.createContext(o));return fa(function(l){const u=(l==null?void 0:l[e])||a;return w.useMemo(()=>({[`__scope${e}`]:{...l,[e]:u}}),[l,u])},"useScope")},"createScope");return i.scopeName=e,[r,S5(i,...t)]}fa(_5,"createContextScope");function S5(...e){const t=e[0];if(e.length===1)return t;const n=fa(()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return fa(function(a){const o=r.reduce((l,{useScope:u,scopeName:d})=>{const h=u(a)[`__scope${d}`];return{...l,...h}},{});return w.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])},"useComposedScopes")},"createScope");return n.scopeName=t.scopeName,n}fa(S5,"composeContextScopes");var fce=Object.defineProperty,za=(e,t)=>fce(e,"name",{value:t,configurable:!0});function k5(e){const t=w.forwardRef((n,r)=>{let{children:i,...a}=n,o=null,l=!1;const u=[];lS(i)&&typeof Sg=="function"&&(i=Sg(i._payload)),w.Children.forEach(i,m=>{var g;if(O5(m)){l=!0;const x=m;let y="child"in x.props?x.props.child:x.props.children;lS(y)&&typeof Sg=="function"&&(y=Sg(y._payload)),o=pce(x,y),u.push((g=o==null?void 0:o.props)==null?void 0:g.children)}else u.push(m)}),o?o=w.cloneElement(o,void 0,u):!l&&w.Children.count(i)===1&&w.isValidElement(i)&&(o=i);const d=o?T5(o):void 0,f=ny(r,d);if(!o){if(i||i===0)throw new Error(l?bce(e):gce(e));return i}const h=N5(a,o.props??{});return o.type!==w.Fragment&&(h.ref=r?f:d),w.cloneElement(o,h)});return t.displayName=`${e}.Slot`,t}za(k5,"createSlot");var A5=Symbol.for("radix.slottable");function hce(e){const t=za(n=>"child"in n?n.children(n.child):n.children,"Slottable");return t.displayName=`${e}.Slottable`,t.__radixId=A5,t}za(hce,"createSlottable");var pce=za((e,t)=>{if("child"in e.props){const n=e.props.child;return w.isValidElement(n)?w.cloneElement(n,void 0,e.props.children(n.props.children)):null}return w.isValidElement(t)?t:null},"getSlottableElementFromSlottable");function N5(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}}za(N5,"mergeProps");function T5(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)}za(T5,"getElementRef");function O5(e){return w.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===A5}za(O5,"isSlottable");var mce=Symbol.for("react.lazy");function lS(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===mce&&"_payload"in e&&C5(e._payload)}za(lS,"isLazyComponent");function C5(e){return typeof e=="object"&&e!==null&&"then"in e}za(C5,"isPromiseLike");var gce=za(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),bce=za(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),Sg=Ao[" use ".trim().toString()],vce=Object.defineProperty,yce=(e,t)=>vce(e,"name",{value:t,configurable:!0}),xce=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],R5=xce.reduce((e,t)=>{const n=k5(`Primitive.${t}`),r=w.forwardRef((i,a)=>{const{asChild:o,...l}=i,u=o?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),v.jsx(u,{...l,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function wce(e,t){e&&No.flushSync(()=>e.dispatchEvent(t))}yce(wce,"dispatchDiscreteCustomEvent");var Ece=Object.defineProperty,_ce=(e,t)=>Ece(e,"name",{value:t,configurable:!0});function I5(e){const t=w.useRef(e);return w.useEffect(()=>{t.current=e}),w.useMemo(()=>((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)}),[])}_ce(I5,"useCallbackRef");var Hw=globalThis!=null&&globalThis.document?w.useLayoutEffect:()=>{},Sce=globalThis!=null&&globalThis.document?w.useLayoutEffect:()=>{},kce=Object.defineProperty,Ace=(e,t)=>kce(e,"name",{value:t,configurable:!0});function M5(e){const[t,n]=w.useState(void 0);return Sce(()=>{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 o,l;if("borderBoxSize"in a){const u=a.borderBoxSize,d=Array.isArray(u)?u[0]:u;o=d.inlineSize,l=d.blockSize}else o=e.offsetWidth,l=e.offsetHeight;n({width:o,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}Ace(M5,"useSize");var Nce=Object.defineProperty,wl=(e,t)=>Nce(e,"name",{value:t,configurable:!0}),D5="Popper",[P5,L5]=_5(D5),[Tce,j5]=P5(D5),Oce=wl(e=>{const{__scopePopper:t,children:n}=e,[r,i]=w.useState(null),[a,o]=w.useState(void 0);return v.jsx(Tce,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})},"Popper"),Cce="PopperAnchor",Rce=w.forwardRef(wl(function(t,n){const{__scopePopper:r,virtualRef:i,...a}=t,o=j5(Cce,r),l=w.useRef(null),u=o.onAnchorChange,d=w.useCallback(y=>{l.current=y,y&&u(y)},[u]),f=ny(n,d),h=w.useRef(null);w.useEffect(()=>{if(!i)return;const y=h.current;h.current=i.current,y!==h.current&&u(h.current)});const m=o.placementState&&ry(o.placementState),g=m==null?void 0:m[0],x=m==null?void 0:m[1];return i?null:v.jsx(R5.div,{"data-radix-popper-side":g,"data-radix-popper-align":x,...a,ref:f})},"PopperAnchor")),$5="PopperContent",[Ice,yPe]=P5($5),Mce=w.forwardRef(wl(function(t,n){var fe,Ae,Te,pe,Ze,Re,De;const{__scopePopper:r,side:i="bottom",sideOffset:a=0,align:o="center",alignOffset:l=0,arrowPadding:u=0,avoidCollisions:d=!0,collisionBoundary:f=[],collisionPadding:h=0,sticky:m="partial",hideWhenDetached:g=!1,updatePositionStrategy:x="optimized",onPlaced:y,...E}=t,_=j5($5,r),[A,N]=w.useState(null),T=ny(n,N),[O,C]=w.useState(null),R=M5(O),M=(R==null?void 0:R.width)??0,P=(R==null?void 0:R.height)??0,D=i+(o!=="center"?"-"+o:""),F=typeof h=="number"?h:{top:0,right:0,bottom:0,left:0,...h},L=Array.isArray(f)?f:[f],G=L.length>0,W={padding:F,boundary:L.filter(z5),altBoundary:G},{refs:X,floatingStyles:B,placement:q,isPositioned:H,middlewareData:V}=ece({strategy:"fixed",placement:D,whileElementsMounted:wl((...Ne)=>qle(...Ne,{animationFrame:x==="always"}),"whileElementsMounted"),elements:{reference:_.anchor},middleware:[nce({mainAxis:a+P,alignmentAxis:l}),d&&rce({mainAxis:!0,crossAxis:!1,limiter:m==="partial"?ice():void 0,...W}),d&&ace({...W}),oce({...W,apply:wl(({elements:Ne,rects:At,availableWidth:bt,availableHeight:hn})=>{const{width:Jn,height:wn}=At.reference,$n=Ne.floating.style;$n.setProperty("--radix-popper-available-width",`${bt}px`),$n.setProperty("--radix-popper-available-height",`${hn}px`),$n.setProperty("--radix-popper-anchor-width",`${Jn}px`),$n.setProperty("--radix-popper-anchor-height",`${wn}px`)},"apply")}),O&&lce({element:O,padding:u}),Dce({arrowWidth:M,arrowHeight:P}),g&&sce({strategy:"referenceHidden",...W,boundary:G?W.boundary:void 0})]}),z=_.setPlacementState;Hw(()=>(z(q),()=>{z(void 0)}),[q,z]);const[j,Z]=ry(q),$=I5(y);Hw(()=>{H&&($==null||$())},[H,$]);const ne=(fe=V.arrow)==null?void 0:fe.x,be=(Ae=V.arrow)==null?void 0:Ae.y,ye=((Te=V.arrow)==null?void 0:Te.centerOffset)!==0,[_e,Ce]=w.useState();return Hw(()=>{A&&Ce(window.getComputedStyle(A).zIndex)},[A]),v.jsx("div",{ref:X.setFloating,"data-radix-popper-content-wrapper":"",style:{...B,transform:H?B.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:_e,"--radix-popper-transform-origin":[(pe=V.transformOrigin)==null?void 0:pe.x,(Ze=V.transformOrigin)==null?void 0:Ze.y].join(" "),...((Re=V.hide)==null?void 0:Re.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:v.jsx(Ice,{scope:r,placedSide:j,placedAlign:Z,onArrowChange:C,arrowX:ne,arrowY:be,shouldHideArrow:ye,children:v.jsx(R5.div,{"data-side":j,"data-align":Z,...E,ref:T,style:{...E.style,animation:H?(De=E.style)==null?void 0:De.animation:"none"}})})})},"PopperContent"));function z5(e){return e!==null}wl(z5,"isNotNull");var Dce=wl(e=>({name:"transformOrigin",options:e,fn(t){var E,_,A;const{placement:n,rects:r,middlewareData:i}=t,o=((E=i.arrow)==null?void 0:E.centerOffset)!==0,l=o?0:e.arrowWidth,u=o?0:e.arrowHeight,[d,f]=ry(n),h={start:"0%",center:"50%",end:"100%"}[f],m=(((_=i.arrow)==null?void 0:_.x)??0)+l/2,g=(((A=i.arrow)==null?void 0:A.y)??0)+u/2;let x="",y="";return d==="bottom"?(x=o?h:`${m}px`,y=`${-u}px`):d==="top"?(x=o?h:`${m}px`,y=`${r.floating.height+u}px`):d==="right"?(x=`${-u}px`,y=o?h:`${g}px`):d==="left"&&(x=`${r.floating.width+u}px`,y=o?h:`${g}px`),{data:{x,y}}}}),"transformOrigin");function ry(e){const[t,n="center"]=e.split("-");return[t,n]}wl(ry,"getSideAndAlignFromPlacement");var Pce=Oce,Lce=Rce,jce=Mce,$ce=globalThis!=null&&globalThis.document?w.useLayoutEffect:()=>{},zce=Object.defineProperty,Bce=(e,t)=>zce(e,"name",{value:t,configurable:!0}),Uce=w.forwardRef(Bce(function(t,n){var u;const{container:r,...i}=t,[a,o]=w.useState(!1);$ce(()=>o(!0),[]);const l=r||a&&((u=globalThis==null?void 0:globalThis.document)==null?void 0:u.body);return l?No.createPortal(v.jsx(Yv.div,{...i,ref:n}),l):null},"Portal")),nD=globalThis!=null&&globalThis.document?w.useLayoutEffect:()=>{},Fce=Object.defineProperty,bs=(e,t)=>Fce(e,"name",{value:t,configurable:!0});function B5(e,t){return w.useReducer((n,r)=>t[n][r]??n,e)}bs(B5,"useStateMachine");var U5=bs(e=>{const{present:t,children:n}=e,r=F5(t),i=typeof n=="function"?n({present:r.isPresent}):w.Children.only(n),a=H5(r.ref,q5(i));return typeof n=="function"||r.isPresent?w.cloneElement(i,{ref:a}):null},"Presence");function F5(e){const[t,n]=w.useState(),r=w.useRef(null),i=w.useRef(e),a=w.useRef("none"),o=w.useRef(void 0),l=e?"mounted":"unmounted",[u,d]=B5(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return w.useEffect(()=>{u==="mounted"?(a.current=o.current??cd(r.current),o.current=void 0):a.current="none"},[u]),nD(()=>{const f=r.current,h=i.current;if(h!==e){const g=a.current,x=cd(f);e?(o.current=x,d("MOUNT")):x==="none"||(f==null?void 0:f.display)==="none"?d("UNMOUNT"):d(h&&g!==x?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,d]),nD(()=>{if(t){let f;const h=t.ownerDocument.defaultView??window,m=bs(x=>{const E=cd(r.current).includes(CSS.escape(x.animationName));if(x.target===t&&E&&(d("ANIMATION_END"),!i.current)){const _=t.style.animationFillMode;t.style.animationFillMode="forwards",f=h.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=_)})}},"handleAnimationEnd"),g=bs(x=>{x.target===t&&(a.current=cd(r.current))},"handleAnimationStart");return t.addEventListener("animationstart",g),t.addEventListener("animationcancel",m),t.addEventListener("animationend",m),()=>{h.clearTimeout(f),t.removeEventListener("animationstart",g),t.removeEventListener("animationcancel",m),t.removeEventListener("animationend",m)}}else d("ANIMATION_END")},[t,d]),{isPresent:["mounted","unmountSuspended"].includes(u),ref:w.useCallback(f=>{if(f){const h=getComputedStyle(f);r.current=h,o.current=cd(h)}else r.current=null;n(f)},[])}}bs(F5,"usePresence");function cS(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}bs(cS,"setRef");function H5(...e){const t=w.useRef(e);return t.current=e,w.useCallback(n=>{const r=t.current;let i=!1;const a=r.map(o=>{const l=cS(o,n);return!i&&typeof l=="function"&&(i=!0),l});if(i)return()=>{for(let o=0;o<a.length;o++){const l=a[o];typeof l=="function"?l():cS(r[o],null)}}},[])}bs(H5,"useStableComposedRefs");function cd(e){return(e==null?void 0:e.animationName)||"none"}bs(cd,"getAnimationName");function q5(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)}bs(q5,"getElementRef");var K5=globalThis!=null&&globalThis.document?w.useLayoutEffect:()=>{},Hce=Object.defineProperty,qce=(e,t)=>Hce(e,"name",{value:t,configurable:!0}),rD=Ao[" useEffectEvent ".trim().toString()],iD=Ao[" useInsertionEffect ".trim().toString()];function G5(e){if(typeof rD=="function")return rD(e);const t=w.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof iD=="function"?iD(()=>{t.current=e}):K5(()=>{t.current=e}),w.useMemo(()=>((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)}),[])}qce(G5,"useEffectEvent");var Kce=Object.defineProperty,_p=(e,t)=>Kce(e,"name",{value:t,configurable:!0}),Gce=Ao[" useInsertionEffect ".trim().toString()]||K5;function W5({prop:e,defaultProp:t,onChange:n=_p(()=>{},"onChange"),caller:r}){const[i,a,o]=V5({defaultProp:t,onChange:n}),l=e!==void 0,u=l?e:i,d=w.useCallback(f=>{var h;if(l){const m=Y5(f)?f(e):f;m!==e&&((h=o.current)==null||h.call(o,m))}else a(f)},[l,e,a,o]);return[u,d]}_p(W5,"useControllableState");function V5({defaultProp:e,onChange:t}){const[n,r]=w.useState(e),i=w.useRef(n),a=w.useRef(t);return Gce(()=>{a.current=t},[t]),w.useEffect(()=>{var o;i.current!==n&&((o=a.current)==null||o.call(a,n),i.current=n)},[n,i]),[n,r,a]}_p(V5,"useUncontrolledState");function Y5(e){return typeof e=="function"}_p(Y5,"isFunction");var aD=Symbol("RADIX:SYNC_STATE");function Wce(e,t,n,r){const{prop:i,defaultProp:a,onChange:o,caller:l}=t,u=i!==void 0,d=G5(o),f=[{...n,state:a}];r&&f.push(r);const[h,m]=w.useReducer((E,_)=>{if(_.type===aD)return{...E,state:_.state};const A=e(E,_);return u&&!Object.is(A.state,E.state)&&d(A.state),A},...f),g=h.state,x=w.useRef(g);w.useEffect(()=>{x.current!==g&&(x.current=g,u||d(g))},[g,x,u]);const y=w.useMemo(()=>i!==void 0?{...h,state:i}:h,[h,i]);return w.useEffect(()=>{u&&!Object.is(i,h.state)&&m({type:aD,state:i})},[i,h.state,u]),[y,m]}_p(Wce,"useControllableStateReducer");var Vce=Object.defineProperty,zl=(e,t)=>Vce(e,"name",{value:t,configurable:!0}),Tk="Popover",[X5,xPe]=WU(Tk,[L5]),Ok=L5(),[Yce,ef]=X5(Tk),Xce=zl(e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,l=Ok(t),u=w.useRef(null),[d,f]=w.useState(!1),[h,m]=W5({prop:r,defaultProp:i??!1,onChange:a,caller:Tk});return v.jsx(Pce,{...l,children:v.jsx(Yce,{scope:t,contentId:u5(),triggerRef:u,open:h,onOpenChange:m,onOpenToggle:w.useCallback(()=>m(g=>!g),[m]),hasCustomAnchor:d,onCustomAnchorAdd:w.useCallback(()=>f(!0),[]),onCustomAnchorRemove:w.useCallback(()=>f(!1),[]),modal:o,children:n})})},"Popover"),Zce="PopoverTrigger",Qce=w.forwardRef(zl(function(t,n){const{__scopePopover:r,...i}=t,a=ef(Zce,r),o=Ok(r),l=Zd(n,a.triggerRef),u=v.jsx(Yv.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":Ck(a.open),...i,ref:l,onClick:xl(t.onClick,a.onOpenToggle)});return a.hasCustomAnchor?u:v.jsx(Lce,{asChild:!0,...o,children:u})},"PopoverTrigger")),Z5="PopoverPortal",[Jce,eue]=X5(Z5,{forceMount:void 0}),tue=zl(e=>{const{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=ef(Z5,t);return v.jsx(Jce,{scope:t,forceMount:n,children:v.jsx(U5,{present:n||a.open,children:v.jsx(Uce,{asChild:!0,container:i,children:r})})})},"PopoverPortal"),Xh="PopoverContent",nue=w.forwardRef(zl(function(t,n){const r=eue(Xh,t.__scopePopover),{forceMount:i=r.forceMount,...a}=t,o=ef(Xh,t.__scopePopover);return v.jsx(U5,{present:i||o.open,children:o.modal?v.jsx(iue,{...a,ref:n}):v.jsx(aue,{...a,ref:n})})},"PopoverContent")),rue=gk("PopoverContent.RemoveScroll"),iue=w.forwardRef(zl(function(t,n){const r=ef(Xh,t.__scopePopover),i=w.useRef(null),a=Zd(n,i),o=w.useRef(!1);return w.useEffect(()=>{const l=i.current;if(l)return TU(l)},[]),v.jsx(ck,{as:rue,allowPinchZoom:!0,children:v.jsx(Q5,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:xl(t.onCloseAutoFocus,l=>{var u;l.preventDefault(),o.current||(u=r.triggerRef.current)==null||u.focus()}),onPointerDownOutside:xl(t.onPointerDownOutside,l=>{const u=l.detail.originalEvent,d=u.button===0&&u.ctrlKey===!0,f=u.button===2||d;o.current=f},{checkForDefaultPrevented:!1}),onFocusOutside:xl(t.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1})})})},"PopoverContentModal")),aue=w.forwardRef(zl(function(t,n){const r=ef(Xh,t.__scopePopover),i=w.useRef(!1),a=w.useRef(!1);return v.jsx(Q5,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var l,u;(l=t.onCloseAutoFocus)==null||l.call(t,o),o.defaultPrevented||(i.current||(u=r.triggerRef.current)==null||u.focus(),o.preventDefault()),i.current=!1,a.current=!1},onInteractOutside:o=>{var d,f;(d=t.onInteractOutside)==null||d.call(t,o),o.defaultPrevented||(i.current=!0,o.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const l=o.target;((f=r.triggerRef.current)==null?void 0:f.contains(l))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&a.current&&o.preventDefault()}})},"PopoverContentNonModal")),Q5=w.forwardRef(zl(function(t,n){const{__scopePopover:r,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,...m}=t,g=ef(Xh,r),x=Ok(r);return yk(),v.jsx(Qse,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:a,onUnmountAutoFocus:o,children:v.jsx(qse,{asChild:!0,disableOutsidePointerEvents:l,onInteractOutside:h,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onDismiss:()=>g.onOpenChange(!1),deferPointerDownOutside:!0,children:v.jsx(jce,{"data-state":Ck(g.open),role:"dialog",id:g.contentId,...x,...m,ref:n,style:{...m.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 Ck(e){return e?"open":"closed"}zl(Ck,"getState");var oue=Xce,sue=Qce,lue=tue,J5=nue;const cue=oue,uue=sue,e4=w.forwardRef(({className:e,align:t="start",side:n="top",sideOffset:r=8,collisionPadding:i=8,...a},o)=>v.jsx(lue,{children:v.jsx(J5,{ref:o,align:t,side:n,sideOffset:r,collisionPadding:i,className:Ge("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})}));e4.displayName=J5.displayName;const t4=92,n4=96;function qw(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 oD=3e5;function due({socket:e,getToken:t}){const[n,r]=w.useState([]);if(w.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]),w.useEffect(()=>{if(!e)return;const a=e.on(o=>{o.type==="stats"&&r(l=>[...l,o.sample].slice(-120))});return()=>{a()}},[e]),!n.length)return null;const i=n[n.length-1];return v.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:[v.jsx(nb,{label:"cpu",value:i.cpu,series:n.map(a=>a.cpu)}),v.jsx(nb,{label:"mem",value:i.mem,series:n.map(a=>a.mem)}),i.disk>=0&&v.jsx(nb,{label:"disk",value:i.disk,severity:vue(i.disk),title:xue(i)}),v.jsx(fue,{getToken:t})]})}function fue({getToken:e}){const[t,n]=w.useState(null);return w.useEffect(()=>{let r=!0,i=0;const a=async()=>{var d;try{const f=await e();if(!f)return;i=Date.now();const h=await fetch("/api/claude-usage",{headers:{Authorization:`Bearer ${f}`}});if(!r)return;if(h.status===204){n(null);return}if(h.status!==200)return;const m=await h.json();if(!r||!((d=m==null?void 0:m.limits)!=null&&d.length))return;n(m)}catch(f){console.warn("[MachineStats] claude usage poll failed",f)}},o=()=>{document.visibilityState==="visible"&&a()},l=()=>{document.visibilityState==="visible"&&Date.now()-i>=oD&&a()};o();const u=setInterval(o,oD);return document.addEventListener("visibilitychange",l),()=>{r=!1,clearInterval(u),document.removeEventListener("visibilitychange",l)}},[e]),v.jsx(r4,{usage:t})}function r4({usage:e,compact:t}){const n=e&&i4(e.limits),[r,i]=w.useState(uS),a=w.useRef(null),o=()=>{a.current&&(clearTimeout(a.current),a.current=null)},l=w.useCallback((u,d=0)=>{if(o(),!d){i(f=>lD(f,u));return}a.current=setTimeout(()=>{a.current=null,i(f=>lD(f,u))},d)},[]);return w.useEffect(()=>o,[]),!e||!n?null:v.jsxs(cue,{open:r.open,onOpenChange:u=>l(u?{type:"activate"}:{type:"dismiss"}),children:[v.jsx(uue,{asChild:!0,children:v.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},hue),onPointerLeave:u=>l({type:"pointerleave",pointerType:u.pointerType},sD),children:t?v.jsxs("span",{className:Ge("tabular-nums",Db(n.percent,n.severity)),children:[n.percent,"% used"]}):v.jsx(nb,{label:"usage",value:n.percent,severity:n.severity})})}),v.jsx(e4,{onOpenAutoFocus:u=>u.preventDefault(),onPointerEnter:()=>o(),onPointerLeave:u=>l({type:"pointerleave",pointerType:u.pointerType},sD),children:v.jsx(pue,{usage:e})})]})}const hue=120,sD=80,uS={open:!1,byHover:!1};function lD(e,t){switch(t.type){case"pointerenter":return cD(t.pointerType)?{open:!0,byHover:!0}:e;case"pointerleave":return cD(t.pointerType)&&e.byHover?uS:e;case"activate":return{open:!0,byHover:!1};case"dismiss":return uS}}const cD=e=>e==="mouse"||e==="";function pue({usage:e}){const t=i4(e.limits);return v.jsxs("div",{className:"text-[11px] leading-tight",children:[v.jsxs("div",{className:"flex items-baseline justify-between gap-2 pb-2 text-muted-foreground",children:[v.jsx("span",{className:"uppercase tracking-wide",children:"claude usage"}),e.subscriptionType&&v.jsxs("span",{className:"tabular-nums",children:[e.subscriptionType," plan"]})]}),v.jsxs("div",{className:"-mt-1 flex items-baseline justify-between gap-2 pb-2 text-[10px] text-muted-foreground",children:[e.account&&v.jsx("span",{className:"truncate",title:e.account,children:e.account}),v.jsx("span",{className:Ge("shrink-0",e.stale&&"text-amber-500"),children:gue(e)})]}),e.stale&&e.error&&v.jsxs("div",{"data-refresh-error":!0,className:"-mt-1 pb-2 text-[10px] text-amber-500 break-words",children:[e.error,eb(e.retryAt??null)&&` · retrying in ${eb(e.retryAt??null)}`]}),v.jsx("div",{className:"flex flex-col gap-3",children:e.limits.map((n,r)=>{const i=eb(n.resetsAt),a=n===t;return v.jsxs("div",{"data-headline":a||void 0,className:Ge("flex flex-col gap-1",!a&&"opacity-60"),children:[v.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[v.jsxs("span",{className:Ge("truncate",a&&"font-medium"),children:[a&&v.jsx("span",{className:"mr-1 text-muted-foreground","aria-hidden":!0,children:"▸"}),mue(n)]}),v.jsxs("span",{className:Ge("tabular-nums shrink-0",Db(n.percent,n.severity)),children:[n.percent,"%"]})]}),v.jsx(a4,{value:n.percent,className:Ge("w-full",Db(n.percent,n.severity))}),v.jsx("span",{className:"text-[10px] text-muted-foreground",children:i?`resets in ${i}`:"no reset reported"})]},`${n.kind}-${r}`)})}),v.jsx("div",{className:"mt-3 border-t pt-2 text-[10px] text-muted-foreground",children:"▸ is the window the strip is showing"})]})}function mue(e){return e.scopeLabel?`${e.scopeLabel} window`:e.kind==="session"?"current session":e.kind==="weekly_all"?"all models":e.kind.replace(/_/g," ")}function i4(e){return e.reduce((t,n)=>!t||n.percent>t.percent?n:t,null)}function gue(e){const t=bue(e.fetchedAt);return t?e.stale?`${t} old — refresh failed`:`updated ${t} ago`:e.stale?"last reading — refresh failed":"updated just now"}function bue(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 vue(e){return e>=n4?"critical":e>=t4?"warning":"ok"}const yue={critical:"text-red-500",exceeded:"text-red-500",warning:"text-amber-500",warn:"text-amber-500",ok:"text-emerald-500"};function Db(e,t){const n=t?yue[t]:void 0;return n||(e>=90?"text-red-500":e>=75?"text-amber-500":"text-emerald-500")}function xue(e){const t=`warn at ${t4}%, critical at ${n4}%`;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 — ${qw(e.diskUsedBytes)} of ${qw(e.diskTotalBytes)}, ${qw(n)} free — ${t}`}function nb({label:e,value:t,series:n,title:r,severity:i}){const a=Db(t,i),o=r??(n?`${e} ${t}% — last ${n.length} samples`:void 0);return v.jsxs("span",{className:"flex items-center gap-1",title:o,children:[v.jsx("span",{className:"uppercase tracking-wide",children:e}),n?v.jsx(wue,{series:n,className:a}):v.jsx(a4,{value:t,className:a}),v.jsxs("span",{className:Ge("tabular-nums",a),children:[t,"%"]})]})}function a4({value:e,className:t}){const i=Math.max(0,Math.min(100,e))/100*40;return v.jsxs("svg",{width:40,height:12,viewBox:"0 0 40 12",className:Ge("overflow-visible",t),preserveAspectRatio:"none",children:[v.jsx("rect",{x:0,y:12/2-2,width:40,height:4,rx:2,fill:"currentColor",opacity:.2}),i>0&&v.jsx("rect",{x:0,y:12/2-2,width:i,height:4,rx:2,fill:"currentColor"})]})}function wue({series:e,className:t}){const i=e.length;if(i<2)return null;const a=e.map((o,l)=>{const u=i>1?l/(i-1)*40:0,d=12-Math.max(0,Math.min(100,o))/100*12;return`${u.toFixed(1)},${d.toFixed(1)}`}).join(" ");return v.jsx("svg",{width:40,height:12,viewBox:"0 0 40 12",className:Ge("overflow-visible",t),preserveAspectRatio:"none",children:v.jsx("polyline",{points:a,fill:"none",stroke:"currentColor",strokeWidth:1,strokeLinejoin:"round",strokeLinecap:"round"})})}const fh=50;function Eue({getToken:e,filter:t,refreshKey:n,hydrateIds:r}){const[i,a]=w.useState([]),[o,l]=w.useState(null),[u,d]=w.useState(!1),[f,h]=w.useState({}),m=w.useRef(new Set),g=w.useRef(null),x=w.useRef(null),y=w.useRef(t);y.current=t;const E=w.useRef(fh),_=w.useRef(t);_.current!==t&&(_.current=t,E.current=fh);const A=w.useCallback(async(R,M)=>{const P=await e();if(!P||M!=null&&M.aborted)return null;const D=await fetch(`/api/sessions?${new URLSearchParams(R)}`,{signal:M,headers:{Authorization:`Bearer ${P}`}});if(!D.ok)return null;const F=await D.json();return Array.isArray(F==null?void 0:F.sessions)?F:null},[e]),N=w.useCallback(async(R,M,P)=>{const D=[];let F,L=null;for(;D.length<R;){const G={filter:M,limit:String(Math.min(fh,R-D.length))};F&&(G.before=F);const W=await A(G,P);if(!W)return null;if(D.push(...W.sessions),L=W.nextCursor,!L||!W.sessions.length)break;F=L}return{sessions:D,nextCursor:L}},[A]);w.useEffect(()=>{var M,P;(M=g.current)==null||M.abort(),(P=x.current)==null||P.abort();const R=new AbortController;return g.current=R,d(!0),m.current.clear(),h({}),N(E.current,t,R.signal).then(D=>{!D||R.signal.aborted||(a(D.sessions),l(D.nextCursor))}).catch(()=>{}).finally(()=>{R.signal.aborted||d(!1)}),()=>R.abort()},[N,t,n]);const T=w.useCallback(()=>{var P;if(!o||u)return;(P=x.current)==null||P.abort();const R=new AbortController;x.current=R;const M=y.current;d(!0),A({filter:M,limit:String(fh),before:o},R.signal).then(D=>{!D||R.signal.aborted||M!==y.current||(a(F=>{const L=new Set(F.map(W=>W.sessionId)),G=[...F,...D.sessions.filter(W=>!L.has(W.sessionId))];return E.current=Math.max(fh,G.length),G}),l(D.nextCursor))}).catch(()=>{}).finally(()=>{R.signal.aborted||d(!1)})},[o,u,A]),O=w.useMemo(()=>{const R=new Map;for(const M of Object.values(f))R.set(M.sessionId,M);for(const M of i)R.set(M.sessionId,M);return R},[i,f]),C=r.join(",");return w.useEffect(()=>{const R=r.filter(P=>!!P&&!O.has(P)&&!m.current.has(P)).slice(0,200);if(!R.length)return;for(const P of R)m.current.add(P);let M=!1;return A({ids:R.join(",")}).then(P=>{!P||M||h(D=>{const F={...D};for(const L of P.sessions)F[L.sessionId]=L;return F})}).catch(()=>{}),()=>{M=!0}},[C,O,A]),{sessions:i,cursor:o,loading:u,byId:O,loadMore:T}}const hh="0.1.145";function _ue(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 ph="w-4 h-4 mt-0.5 shrink-0";function Sue(e){const t=e.slackContext;return(t==null?void 0:t.type)==="dm"?v.jsx($X,{className:`${ph} text-purple-400`}):(t==null?void 0:t.type)==="mention"?v.jsx(SX,{className:`${ph} text-blue-400`}):(t==null?void 0:t.type)==="channel"?v.jsx(MX,{className:`${ph} text-green-400`}):e.sessionId.startsWith("slack-")?v.jsx(P_,{className:`${ph} text-yellow-400`}):v.jsx(P_,{className:`${ph} text-muted-foreground`})}function kue(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 Aue(e,t,n){return Object.keys(e).map(r=>t.get(r)).filter(r=>!!r&&(n==="all"||r.mine!==!1))}const uD="chats-filter",dD="chats-unread-filter";function Nue({getToken:e,activeSessionId:t,onSelect:n,onNew:r,refreshKey:i,workspaceRefreshKey:a,onRefreshWorkspace:o,unreads:l={},busySessions:u=new Set,socket:d}){var H;const f=To(),[h,m]=w.useState(()=>localStorage.getItem(uD)||"mine"),[g,x]=w.useState(()=>localStorage.getItem(dD)==="true"),[y,E]=w.useState(""),_=w.useRef(null);function A(V){m(V),localStorage.setItem(uD,V)}function N(){const V=!g;x(V),localStorage.setItem(dD,String(V))}const T=w.useMemo(()=>[t,...Object.keys(l)].filter(V=>!!V),[t,l]),{sessions:O,cursor:C,loading:R,byId:M,loadMore:P}=Eue({getToken:e,filter:h,refreshKey:i,hydrateIds:T}),D=w.useMemo(()=>Aue(l,M,h),[l,M,h]),F=D.length,L=w.useMemo(()=>g?[...D].sort((V,z)=>z.lastModified-V.lastModified):O,[g,D,O]),G=t&&!L.some(V=>V.sessionId===t)?M.get(t):void 0;w.useEffect(()=>{_.current&&_.current.scrollIntoView({block:"nearest"})},[t,L,G]);const W=w.useRef(null),X=w.useRef(P);X.current=P,w.useEffect(()=>{const V=W.current;if(!V||!C||g)return;const z=new IntersectionObserver(j=>{j.some(Z=>Z.isIntersecting)&&X.current()},{rootMargin:"300px"});return z.observe(V),()=>z.disconnect()},[C,R,g]),w.useEffect(()=>{e().then(V=>V?fetch("/api/version",{headers:{Authorization:`Bearer ${V}`}}):null).then(V=>V==null?void 0:V.json()).then(V=>V&&E(V.version)).catch(()=>{})},[]);const B=!!y&&y!=="unknown"&&hh!=="dev"&&y!==hh;w.useEffect(()=>{B&&console.warn(`[shraga] stale client bundle: built from v${hh}, server runs v${y} — rebuild dist/client`)},[B,y]);function q(V){const z=l[V.sessionId],j=u.has(V.sessionId)||V.runStatus==="running"||V.scheduleRunStatus==="running",Z=!j&&(!!V.lastStopReason||V.scheduleRunStatus==="error"||V.scheduleRunStatus==="aborted"),$=j?"border-amber-500":Z?"border-red-500":z?"border-blue-500":"",ne=!!(j||Z||z);return v.jsx("button",{ref:V.sessionId===t?_:void 0,onClick:()=>n(V.sessionId,V.title),className:Ge("w-full text-left px-3 py-2.5 text-sm transition-colors hover:bg-accent/50 group",ne?`rounded-r-lg border-l-[3px] ${$}`:"rounded-lg",t===V.sessionId&&"bg-accent"),children:v.jsxs("div",{className:"flex items-start gap-2",children:[Sue(V),v.jsxs("div",{className:"min-w-0 flex-1",children:[v.jsx("span",{className:Ge("block truncate text-sm leading-snug",z&&"font-semibold"),children:V.title||"New session"}),v.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[v.jsx("span",{className:"text-[10px] text-muted-foreground font-medium",children:kue(V)||V.userName}),v.jsx("span",{className:"text-[10px] text-muted-foreground/50",children:"·"}),v.jsx("span",{className:"text-[10px] text-muted-foreground",children:_ue(V.lastModified)})]})]})]})},V.sessionId)}return v.jsxs("div",{className:"flex flex-col h-full bg-muted/30",children:[v.jsx("div",{className:"p-3",children:v.jsxs(Ie,{variant:"outline",size:"sm",className:"w-full gap-2 justify-start",onClick:r,title:"New Chat (Ctrl+N)",children:[v.jsx(hs,{className:"w-4 h-4"})," New Chat",v.jsx("span",{className:"ml-auto flex items-center gap-0.5 text-[10px] text-muted-foreground/50 font-mono",children:"⌃N"})]})}),v.jsx("div",{className:"border-b shrink-0 flex flex-col max-h-[40vh]",children:v.jsx(wse,{getToken:e,onRefresh:o,refreshKey:a})}),v.jsxs("div",{className:"flex items-center justify-between px-3 pt-2 pb-1",children:[v.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Chats"}),v.jsxs("div",{className:"flex gap-0.5",children:[["mine","all"].map(V=>v.jsx("button",{onClick:()=>A(V),className:Ge("text-[10px] px-1.5 rounded-full transition-colors capitalize leading-none",h===V?"text-foreground font-medium":"text-muted-foreground/60 hover:text-muted-foreground"),children:V},V)),v.jsxs("button",{onClick:N,className:Ge("text-[10px] px-1.5 rounded-full transition-colors leading-none",g?"text-blue-600 dark:text-blue-400 font-medium":"text-muted-foreground/60 hover:text-muted-foreground"),children:["unread",F>0&&v.jsx("span",{className:"inline-block w-1.5 h-1.5 ml-1 rounded-full bg-blue-500 align-middle"})]})]})]}),v.jsx(U3,{className:"flex-1",children:v.jsxs("div",{className:"px-2 pb-2 space-y-0.5",children:[L.length===0&&!G&&v.jsx("p",{className:"text-xs text-muted-foreground px-3 py-6 text-center",children:R?"Loading…":g?"No unread conversations":"No conversations yet"}),G&&q(G),L.map(q),!g&&C&&v.jsx("div",{ref:W,className:"py-3 text-center text-[11px] text-muted-foreground/60",children:R?"Loading older…":"···"})]})}),v.jsxs("div",{className:"px-4 py-2 flex flex-col items-center gap-1",children:[v.jsx(due,{socket:d??null,getToken:e}),(H=f.sidebarExtras)==null?void 0:H.call(f),y&&(B?v.jsxs("button",{onClick:()=>location.reload(),title:`This page was built from v${hh}, the server runs v${y} — reload to update`,className:"text-[10px] text-amber-400 hover:text-amber-300 text-center underline decoration-dotted",children:["⚠️ stale page (v",hh," → v",y,") · reload"]}):v.jsxs("div",{className:"text-[10px] text-muted-foreground/50 text-center",children:["v",y]}))]})]})}function $i(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:gl(),role:"assistant",blocks:[t]}]}function fD(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:gl(),role:"assistant",blocks:[i]}]}function o4(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 o=[...i.blocks];return o[a]={...o[a],input:n},[...e.slice(0,r),{...i,blocks:o},...e.slice(r+1)]}return e}function Tue(e,t){const[n,r]=w.useState([]),[i,a]=w.useState(!1),[o,l]=w.useState([]),u=w.useRef(t.initialSessionId),d=w.useRef(!1),f=w.useRef(o);f.current=o;const h=w.useRef(t.getToken);h.current=t.getToken;const m=w.useRef(t.onNewSession);m.current=t.onNewSession;const g=w.useRef(t.onDirectivesChanged);g.current=t.onDirectivesChanged;const x=w.useRef(t.onParticipantsChanged);x.current=t.onParticipantsChanged;const y=w.useRef(t.onEvent);y.current=t.onEvent;const E=w.useRef(e);E.current=e;const _=w.useCallback(L=>L!=null&&L===u.current,[]),A=w.useCallback(async()=>{var G;const L=u.current;if(L)try{const X=await(await kc(`/api/sessions/${L}/messages`,h.current)).json();r(g3(X)),a(!!X.busy),(G=x.current)==null||G.call(x,Array.isArray(X.participants)&&X.participants.length>1)}catch{}},[]);w.useEffect(()=>{if(!e)return;const L=e.on(G=>{var X,B,q,H,V,z;(X=y.current)==null||X.call(y,G);const W=G;if(W.type==="compact_marker")return _(W.sessionId)?r(j=>[...j,{id:gl(),role:"assistant",blocks:[{type:"compact_marker",summary:W.summary??"",compactedCount:W.compactedCount??0}]}]):void 0;switch(G.type){case"thinking_delta":return _(G.sessionId)?r(j=>$i(j,{type:"thinking",text:G.text})):void 0;case"text_delta":return _(G.sessionId)?r(j=>$i(j,{type:"text",text:G.text})):void 0;case"tool_use":return _(G.sessionId)?r(j=>$i(j,{type:"tool_use",tool:G.tool,toolUseId:G.toolUseId,input:G.input})):void 0;case"tool_use_input":return _(G.sessionId)?r(j=>o4(j,G.toolUseId,G.input)):void 0;case"tool_result":return _(G.sessionId)?r(j=>$i(j,{type:"tool_result",toolUseId:G.toolUseId,output:G.output})):void 0;case"tool_result_image":return _(G.sessionId)?r(j=>$i(j,{type:"image",src:G.dataUrl})):void 0;case"permission_request":return _(G.sessionId)?r(j=>$i(j,{type:"permission_request",id:G.id,tool:G.tool,input:G.input})):void 0;case"question_request":return _(G.sessionId)?r(j=>$i(j,{type:"question_request",id:G.id,questions:G.questions})):void 0;case"directives":return d.current?(B=g.current)==null?void 0:B.call(g,G.directives):void 0;case"session_id":return!d.current||u.current?void 0:(u.current=G.sessionId,(q=m.current)==null?void 0:q.call(m,G.sessionId));case"forked":return G.sourceSessionId!==u.current?void 0:(u.current=G.sessionId,(H=m.current)==null?void 0:H.call(m,G.sessionId));case"session_busy":G.sessionId===u.current&&a(G.busy);return;case"session_stream":return G.sessionId!==u.current?void 0:Oue(r,G.event);case"session_messages_changed":G.sessionId===u.current&&A();return;case"done":{if(G.sessionId!==u.current)return;G.stopReason==="max_turns_reached"&&r(Z=>$i(Z,{type:"text",text:`
|
|
1907
|
+
`)},rse=0,Gu=[];function ise(e){var t=w.useRef([]),n=w.useRef([0,0]),r=w.useRef(),i=w.useState(rse++)[0],a=w.useState(_U)[0],o=w.useRef(e);w.useEffect(function(){o.current=e},[e]),w.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var y=fW([e.lockRef.current],(e.shards||[]).map(FM),!0).filter(Boolean);return y.forEach(function(E){return E.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),y.forEach(function(E){return E.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var l=w.useCallback(function(y,E){if("touches"in y&&y.touches.length===2||y.type==="wheel"&&y.ctrlKey)return!o.current.allowPinchZoom;var _=vg(y),A=n.current,N="deltaX"in y?y.deltaX:A[0]-_[0],T="deltaY"in y?y.deltaY:A[1]-_[1],O,C=y.target,R=Math.abs(N)>Math.abs(T)?"h":"v";if("touches"in y&&R==="h"&&C.type==="range")return!1;var M=window.getSelection(),P=M&&M.anchorNode,D=P?P===C||P.contains(C):!1;if(D)return!1;var F=BM(R,C);if(!F)return!0;if(F?O=R:(O=R==="v"?"h":"v",F=BM(R,C)),!F)return!1;if(!r.current&&"changedTouches"in y&&(N||T)&&(r.current=O),!O)return!0;var L=r.current||O;return ese(L,E,y,L==="h"?N:T)},[]),u=w.useCallback(function(y){var E=y;if(!(!Gu.length||Gu[Gu.length-1]!==a)){var _="deltaY"in E?UM(E):vg(E),A=t.current.filter(function(O){return O.name===E.type&&(O.target===E.target||E.target===O.shadowParent)&&tse(O.delta,_)})[0];if(A&&A.should){E.cancelable&&E.preventDefault();return}if(!A){var N=(o.current.shards||[]).map(FM).filter(Boolean).filter(function(O){return O.contains(E.target)}),T=N.length>0?l(E,N[0]):!o.current.noIsolation;T&&E.cancelable&&E.preventDefault()}}},[]),d=w.useCallback(function(y,E,_,A){var N={name:y,delta:E,target:_,should:A,shadowParent:ase(_)};t.current.push(N),setTimeout(function(){t.current=t.current.filter(function(T){return T!==N})},1)},[]),f=w.useCallback(function(y){n.current=vg(y),r.current=void 0},[]),h=w.useCallback(function(y){d(y.type,UM(y),y.target,l(y,e.lockRef.current))},[]),m=w.useCallback(function(y){d(y.type,vg(y),y.target,l(y,e.lockRef.current))},[]);w.useEffect(function(){return Gu.push(a),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:m}),document.addEventListener("wheel",u,Ku),document.addEventListener("touchmove",u,Ku),document.addEventListener("touchstart",f,Ku),function(){Gu=Gu.filter(function(y){return y!==a}),document.removeEventListener("wheel",u,Ku),document.removeEventListener("touchmove",u,Ku),document.removeEventListener("touchstart",f,Ku)}},[]);var g=e.removeScrollBar,x=e.inert;return w.createElement(w.Fragment,null,x?w.createElement(a,{styles:nse(i)}):null,g?w.createElement(Woe,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function ase(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const ose=Doe(EU,ise);var ck=w.forwardRef(function(e,t){return w.createElement(Wv,lo({},e,{ref:t,sideCar:ose}))});ck.classNames=Wv.classNames;var sse=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Wu=new WeakMap,yg=new WeakMap,xg={},jw=0,NU=function(e){return e&&(e.host||NU(e.parentNode))},lse=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=NU(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})},cse=function(e,t,n,r){var i=lse(t,Array.isArray(e)?e:[e]);xg[n]||(xg[n]=new WeakMap);var a=xg[n],o=[],l=new Set,u=new Set(i),d=function(h){!h||l.has(h)||(l.add(h),d(h.parentNode))};i.forEach(d);var f=function(h){!h||u.has(h)||Array.prototype.forEach.call(h.children,function(m){if(l.has(m))f(m);else try{var g=m.getAttribute(r),x=g!==null&&g!=="false",y=(Wu.get(m)||0)+1,E=(a.get(m)||0)+1;Wu.set(m,y),a.set(m,E),o.push(m),y===1&&x&&yg.set(m,!0),E===1&&m.setAttribute(n,"true"),x||m.setAttribute(r,"true")}catch(_){console.error("aria-hidden: cannot operate on ",m,_)}})};return f(t),l.clear(),jw++,function(){o.forEach(function(h){var m=Wu.get(h)-1,g=a.get(h)-1;Wu.set(h,m),a.set(h,g),m||(yg.has(h)||h.removeAttribute(r),yg.delete(h)),g||h.removeAttribute(n)}),jw--,jw||(Wu=new WeakMap,Wu=new WeakMap,yg=new WeakMap,xg={})}},TU=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=sse(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),cse(r,i,n,"aria-hidden")):function(){return null}},Vv="Dialog",[OU]=N3(Vv),[use,ja]=OU(Vv),CU=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,l=w.useRef(null),u=w.useRef(null),[d,f]=aoe({prop:r,defaultProp:i??!1,onChange:a,caller:Vv});return v.jsx(use,{scope:t,triggerRef:l,contentRef:u,contentId:Rw(),titleId:Rw(),descriptionId:Rw(),open:d,onOpenChange:f,onOpenToggle:w.useCallback(()=>f(h=>!h),[f]),modal:o,children:n})};CU.displayName=Vv;var RU="DialogTrigger",IU=w.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=ja(RU,n),a=Gi(t,i.triggerRef);return v.jsx(vi.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":pk(i.open),...r,ref:a,onClick:ti(e.onClick,i.onOpenToggle)})});IU.displayName=RU;var uk="DialogPortal",[dse,MU]=OU(uk,{forceMount:void 0}),DU=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=ja(uk,t);return v.jsx(dse,{scope:t,forceMount:n,children:w.Children.map(r,o=>v.jsx(Ll,{present:n||a.open,children:v.jsx(xU,{asChild:!0,container:i,children:o})}))})};DU.displayName=uk;var Ob="DialogOverlay",dk=w.forwardRef((e,t)=>{const n=MU(Ob,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=ja(Ob,e.__scopeDialog);return a.modal?v.jsx(Ll,{present:r||a.open,children:v.jsx(hse,{...i,ref:t})}):null});dk.displayName=Ob;var fse=$1("DialogOverlay.RemoveScroll"),hse=w.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=ja(Ob,n),a=hoe(),o=Gi(t,a);return v.jsx(ck,{as:fse,allowPinchZoom:!0,shards:[i.contentRef],children:v.jsx(vi.div,{"data-state":pk(i.open),...r,ref:o,style:{pointerEvents:"auto",...r.style}})})}),Md="DialogContent",fk=w.forwardRef((e,t)=>{const n=MU(Md,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=ja(Md,e.__scopeDialog);return v.jsx(Ll,{present:r||a.open,children:a.modal?v.jsx(pse,{...i,ref:t}):v.jsx(mse,{...i,ref:t})})});fk.displayName=Md;var pse=w.forwardRef((e,t)=>{const n=ja(Md,e.__scopeDialog),r=w.useRef(null),i=Gi(t,n.contentRef,r);return w.useEffect(()=>{const a=r.current;if(a)return TU(a)},[]),v.jsx(PU,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:ti(e.onCloseAutoFocus,a=>{var o;a.preventDefault(),(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:ti(e.onPointerDownOutside,a=>{const o=a.detail.originalEvent,l=o.button===0&&o.ctrlKey===!0;(o.button===2||l)&&a.preventDefault()}),onFocusOutside:ti(e.onFocusOutside,a=>a.preventDefault())})}),mse=w.forwardRef((e,t)=>{const n=ja(Md,e.__scopeDialog),r=w.useRef(!1),i=w.useRef(!1);return v.jsx(PU,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var o,l;(o=e.onCloseAutoFocus)==null||o.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 o=a.target;((d=n.triggerRef.current)==null?void 0:d.contains(o))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&i.current&&a.preventDefault()}})}),PU=w.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,l=ja(Md,n);return koe(),v.jsx(v.Fragment,{children:v.jsx(vU,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:v.jsx(gU,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":pk(l.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>l.onOpenChange(!1)})})})}),LU="DialogTitle",hk=w.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=ja(LU,n);return v.jsx(vi.h2,{id:i.titleId,...r,ref:t})});hk.displayName=LU;var jU="DialogDescription",gse=w.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=ja(jU,n);return v.jsx(vi.p,{id:i.descriptionId,...r,ref:t})});gse.displayName=jU;var $U="DialogClose",zU=w.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=ja($U,n);return v.jsx(vi.button,{type:"button",...r,ref:t,onClick:ti(e.onClick,()=>i.onOpenChange(!1))})});zU.displayName=$U;function pk(e){return e?"open":"closed"}const ps=CU,Yd=IU,bse=DU,BU=w.forwardRef(({className:e,...t},n)=>v.jsx(dk,{ref:n,className:Ge("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}));BU.displayName=dk.displayName;const vo=w.forwardRef(({className:e,children:t,...n},r)=>v.jsxs(bse,{children:[v.jsx(BU,{}),v.jsxs(fk,{ref:r,className:Ge("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,v.jsxs(zU,{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:[v.jsx(kl,{className:"h-4 w-4"}),v.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));vo.displayName=fk.displayName;function Al({className:e,...t}){return v.jsx("div",{className:Ge("shrink-0 flex flex-col space-y-1.5 text-center sm:text-left",e),...t})}function UU({className:e,...t}){return v.jsx("div",{"data-dialog-body":!0,className:Ge("flex-1 min-h-0 overflow-y-auto -mx-4 px-4 sm:-mx-6 sm:px-6",e),...t})}function FU({className:e,...t}){return v.jsx("div",{className:Ge("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 ms=w.forwardRef(({className:e,...t},n)=>v.jsx(hk,{ref:n,className:Ge("text-lg font-semibold leading-none tracking-tight",e),...t}));ms.displayName=hk.displayName;const vse=new Set(["png","jpg","jpeg","gif","webp","svg","ico","bmp","avif"]),yse=new Set(["pdf","mp4","webm","mp3","ogg","wav"]);async function xse(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 wse({getToken:e,onRefresh:t,refreshKey:n}){const[r,i]=w.useState(new Map),[a,o]=w.useState(()=>new Set),[l,u]=w.useState(null),[d,f]=w.useState(!1),[h,m]=w.useState("fit"),[g,x]=w.useState(null),[y,E]=w.useState(null),_=w.useRef(null),[A,N]=w.useState(null),[T,O]=w.useState(!1),[C,R]=w.useState([]),M=w.useCallback(async B=>{const q=await xse(B,e);i(H=>new Map(H).set(B,q))},[e]);w.useEffect(()=>{M(""),a.forEach(B=>M(B))},[M,n]);const P=r.get("")??[],D=w.useCallback(B=>{try{const q=B.contentDocument;if(!(q!=null&&q.body))return;const H=Math.max(q.body.offsetWidth,q.body.scrollWidth),V=Math.max(q.body.offsetHeight,q.body.scrollHeight);H&&V&&E({w:H,h:V})}catch{}},[]),F=w.useCallback(()=>{const B=_.current,q=y;if(!B||!q)return;const H=16,V=B.clientWidth-H,z=B.clientHeight-H,j=Math.min(V/q.w,z/q.h,1);x({scale:j,w:q.w,h:q.h})},[y]);w.useEffect(()=>{if(!(l!=null&&l.html)||h!=="fit"){x(null);return}const B=_.current;if(!B)return;const q=new ResizeObserver(()=>requestAnimationFrame(F));return q.observe(B),()=>q.disconnect()},[l==null?void 0:l.html,d,h,F]),w.useEffect(()=>{T&&e().then(B=>{B&&fetch("/api/data-sync/log",{headers:{Authorization:`Bearer ${B}`}}).then(q=>q.json()).then(R).catch(()=>{})})},[T]);const L=B=>{o(q=>{const H=new Set(q);return H.has(B)?H.delete(B):(H.add(B),r.has(B)||M(B)),H})},G=(B,q)=>{const H=new URLSearchParams({path:B});return A&&H.set("token",A),q&&H.set("dl","1"),`/api/workspace/raw?${H}`},W=async B=>{var V;const q=await e();if(!q)return;N(q);const H=((V=B.split(".").pop())==null?void 0:V.toLowerCase())??"";if(H==="html"||H==="htm"){u({path:B,content:"",binary:!1,html:!0});return}if(vse.has(H)){u({path:B,content:"",binary:!1,image:!0});return}if(yse.has(H)){u({path:B,content:"",binary:!1,html:!0});return}try{const z=await fetch(`/api/workspace/file?path=${encodeURIComponent(B)}`,{headers:{Authorization:`Bearer ${q}`}});if(!z.ok)return;const j=await z.json();u({path:B,content:j.content,binary:!!j.binary})}catch{}},X=(B,q)=>v.jsx(v.Fragment,{children:B.map(H=>{const V=H.path.split("/").pop();return v.jsxs("div",{children:[H.type==="dir"?v.jsxs("button",{onClick:()=>L(H.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+q*12},children:[v.jsx(Pl,{className:Ge("w-3 h-3 shrink-0 transition-transform",a.has(H.path)&&"rotate-90")}),v.jsx(IX,{className:"w-3.5 h-3.5 shrink-0 text-muted-foreground"}),v.jsx("span",{className:"truncate",children:V})]}):v.jsxs("button",{onClick:()=>W(H.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+q*12+12},title:H.oneLiner||H.path,children:[v.jsx(M1,{className:"w-3.5 h-3.5 shrink-0 text-muted-foreground"}),v.jsx("span",{className:"truncate",children:V})]}),H.type==="dir"&&a.has(H.path)&&X(r.get(H.path)??[],q+1)]},H.path)})});return v.jsxs(v.Fragment,{children:[v.jsxs("div",{className:"flex items-center justify-between px-3 pt-2 pb-1 shrink-0",children:[v.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Workspace"}),v.jsxs("div",{className:"flex items-center gap-0.5",children:[v.jsx("button",{onClick:()=>O(!0),className:"p-0.5 rounded hover:bg-accent text-muted-foreground",title:"Activity log",children:v.jsx(DX,{className:"w-3 h-3"})}),v.jsx("button",{onClick:()=>{M(""),a.forEach(B=>M(B)),t==null||t()},className:"p-0.5 rounded hover:bg-accent text-muted-foreground",title:"Refresh",children:v.jsx(Gd,{className:"w-3 h-3"})})]})]}),v.jsx("div",{className:"px-1 pb-2 overflow-y-auto min-h-0",children:P.length===0?v.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(P,0)}),v.jsx(ps,{open:!!l,onOpenChange:B=>{B||(u(null),f(!1),m("fit"),E(null))},children:v.jsxs(vo,{className:Ge(l!=null&&l.html?Ge("!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:[v.jsxs("div",{className:"absolute right-12 top-4 flex items-center gap-1.5 z-10",children:[(l==null?void 0:l.html)&&v.jsxs(v.Fragment,{children:[v.jsx("button",{onClick:()=>m(B=>B==="fit"?"scroll":"fit"),className:"rounded-sm opacity-70 hover:opacity-100 text-muted-foreground",title:h==="fit"?"Switch to scrollable (1:1)":"Switch to scale-to-fit",children:h==="fit"?v.jsx(zX,{className:"w-4 h-4"}):v.jsx(KX,{className:"w-4 h-4"})}),v.jsx("button",{onClick:()=>f(B=>!B),className:"rounded-sm opacity-70 hover:opacity-100 text-muted-foreground",title:d?"Restore":"Maximize",children:d?v.jsx(P1,{className:"w-4 h-4"}):v.jsx(D1,{className:"w-4 h-4"})})]}),l&&v.jsx("a",{href:G(l.path,!0),download:!0,className:"rounded-sm opacity-70 hover:opacity-100 text-muted-foreground",title:"Download",children:v.jsx(E3,{className:"w-4 h-4"})})]}),v.jsx(Al,{className:Ge((l==null?void 0:l.html)&&"px-4 py-3 shrink-0 border-b"),children:v.jsx(ms,{className:"font-mono text-sm truncate pr-16",children:l==null?void 0:l.path})}),v.jsx("div",{ref:l!=null&&l.html?_:void 0,className:Ge(l!=null&&l.html?Ge("flex-1 min-h-0 bg-muted/10",h==="fit"?"overflow-hidden flex items-center justify-center":"overflow-auto"):"flex-1 min-h-0 overflow-y-auto"),children:l!=null&&l.html?h==="fit"?v.jsx("div",{style:g?{width:g.w*g.scale,height:g.h*g.scale}:{width:"100%",height:"100%"},children:v.jsx("iframe",{src:G(l.path),className:"border-0 bg-white origin-top-left",title:l.path,onLoad:B=>{D(B.currentTarget),F()},style:g?{width:g.w,height:g.h,transform:`scale(${g.scale})`}:{width:"100%",height:"100%"}})}):v.jsx("iframe",{src:G(l.path),className:"border-0 bg-white mx-auto block",title:l.path,onLoad:B=>D(B.currentTarget),style:{width:(y==null?void 0:y.w)||"100%",height:(y==null?void 0:y.h)||"100%"}}):l!=null&&l.image?v.jsx("div",{className:"flex items-center justify-center p-4",children:v.jsx("img",{src:G(l.path),alt:l.path,className:"max-w-full max-h-[70vh] object-contain"})}):l!=null&&l.binary?v.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")?v.jsx("div",{className:"text-sm",children:v.jsx(ene,{remarkPlugins:[hie],rehypePlugins:[eoe],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})}):v.jsx("pre",{className:"text-xs whitespace-pre-wrap break-all",children:l==null?void 0:l.content})})]})}),v.jsx(ps,{open:T,onOpenChange:O,children:v.jsxs(vo,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col",children:[v.jsx(Al,{children:v.jsx(ms,{className:"text-sm",children:"Activity Log"})}),v.jsxs("div",{className:"overflow-y-auto flex-1 space-y-2",children:[C.map(B=>v.jsxs("div",{className:"border-b border-border/50 pb-2 last:border-0",children:[v.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[v.jsx("span",{className:"text-sm text-foreground",children:B.message}),v.jsx("span",{className:"text-[10px] text-muted-foreground shrink-0",children:Ese(B.date)})]}),B.files.length>0&&v.jsx("div",{className:"text-[11px] text-muted-foreground mt-0.5",children:B.files.map(q=>v.jsx("span",{className:"inline-block mr-2 font-mono",children:q},q))})]},B.hash)),C.length===0&&v.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No activity yet"})]})]})})]})}function Ese(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 eb(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 o=Math.floor(i/24),l=i%24;return l?`${o}d ${l}h`:`${o}d`}const _se=/resets\s+(\d{1,2})(?::(\d{2}))?\s*(am|pm)?\s*\(UTC\)/i;function Sse(e,t=Date.now(),n=Date.now()){var h;const r=e.match(_se);if(!r)return e;let i=Number(r[1]);const a=r[2]?Number(r[2]):0,o=(h=r[3])==null?void 0:h.toLowerCase();if(o==="pm"&&i<12&&(i+=12),o==="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"}),f=eb(u.toISOString(),n);return e.replace(r[0],`resets ${d}${f?` (in ${f})`:""}`)}var kse=Object.defineProperty,Xd=(e,t)=>kse(e,"name",{value:t,configurable:!0}),HU=!!(typeof window<"u"&&window.document&&window.document.createElement);function xl(e,t,{checkForDefaultPrevented:n=!0}={}){return Xd(function(i){if(e==null||e(i),n===!1||!i||!i.defaultPrevented)return t==null?void 0:t(i)},"handleEvent")}Xd(xl,"composeEventHandlers");function Ase(e){var t;if(!HU)throw new Error("Cannot access window outside of the DOM");return((t=e==null?void 0:e.ownerDocument)==null?void 0:t.defaultView)??window}Xd(Ase,"getOwnerWindow");function X_(e){if(!HU)throw new Error("Cannot access document outside of the DOM");return(e==null?void 0:e.ownerDocument)??document}Xd(X_,"getOwnerDocument");function qU(e,t=!1){const{activeElement:n}=X_(e);if(!(n!=null&&n.nodeName))return null;if(KU(n)&&n.contentDocument)return qU(n.contentDocument.body,t);if(t){const r=n.getAttribute("aria-activedescendant");if(r){const i=X_(n).getElementById(r);if(i)return i}}return n}Xd(qU,"getActiveElement");function KU(e){return e.tagName==="IFRAME"}Xd(KU,"isFrame");var Nse=Object.defineProperty,mk=(e,t)=>Nse(e,"name",{value:t,configurable:!0});function Z_(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}mk(Z_,"setRef");function GU(...e){return t=>{let n=!1;const r=e.map(i=>{const a=Z_(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():Z_(e[i],null)}}}}mk(GU,"composeRefs");function Zd(...e){return w.useCallback(GU(...e),e)}mk(Zd,"useComposedRefs");var Tse=Object.defineProperty,da=(e,t)=>Tse(e,"name",{value:t,configurable:!0});function Ose(e,t){const n=w.createContext(t);n.displayName=e+"Context";const r=da(a=>{const{children:o,...l}=a,u=w.useMemo(()=>l,Object.values(l));return v.jsx(n.Provider,{value:u,children:o})},"Provider");r.displayName=e+"Provider";function i(a,o={}){const{optional:l=!1}=o,u=w.useContext(n);if(u)return u;if(t!==void 0)return t;if(!l)throw new Error(`\`${a}\` must be used within \`${e}\``)}return da(i,"useContext"),[r,i]}da(Ose,"createContext");function WU(e,t=[]){let n=[];function r(a,o){const l=w.createContext(o);l.displayName=a+"Context";const u=n.length;n=[...n,o];const d=da(h=>{var _;const{scope:m,children:g,...x}=h,y=((_=m==null?void 0:m[e])==null?void 0:_[u])||l,E=w.useMemo(()=>x,Object.values(x));return v.jsx(y.Provider,{value:E,children:g})},"Provider");d.displayName=a+"Provider";function f(h,m,g={}){var _;const{optional:x=!1}=g,y=((_=m==null?void 0:m[e])==null?void 0:_[u])||l,E=w.useContext(y);if(E)return E;if(o!==void 0)return o;if(!x)throw new Error(`\`${h}\` must be used within \`${a}\``)}return da(f,"useContext"),[d,f]}da(r,"createContext");const i=da(()=>{const a=n.map(o=>w.createContext(o));return da(function(l){const u=(l==null?void 0:l[e])||a;return w.useMemo(()=>({[`__scope${e}`]:{...l,[e]:u}}),[l,u])},"useScope")},"createScope");return i.scopeName=e,[r,VU(i,...t)]}da(WU,"createContextScope");function VU(...e){const t=e[0];if(e.length===1)return t;const n=da(()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return da(function(a){const o=r.reduce((l,{useScope:u,scopeName:d})=>{const h=u(a)[`__scope${d}`];return{...l,...h}},{});return w.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])},"useComposedScopes")},"createScope");return n.scopeName=t.scopeName,n}da(VU,"composeContextScopes");var Cse=Object.defineProperty,$a=(e,t)=>Cse(e,"name",{value:t,configurable:!0});function gk(e){const t=w.forwardRef((n,r)=>{let{children:i,...a}=n,o=null,l=!1;const u=[];Q_(i)&&typeof wg=="function"&&(i=wg(i._payload)),w.Children.forEach(i,m=>{var g;if(QU(m)){l=!0;const x=m;let y="child"in x.props?x.props.child:x.props.children;Q_(y)&&typeof wg=="function"&&(y=wg(y._payload)),o=Ise(x,y),u.push((g=o==null?void 0:o.props)==null?void 0:g.children)}else u.push(m)}),o?o=w.cloneElement(o,void 0,u):!l&&w.Children.count(i)===1&&w.isValidElement(i)&&(o=i);const d=o?ZU(o):void 0,f=Zd(r,d);if(!o){if(i||i===0)throw new Error(l?Pse(e):Dse(e));return i}const h=XU(a,o.props??{});return o.type!==w.Fragment&&(h.ref=r?f:d),w.cloneElement(o,h)});return t.displayName=`${e}.Slot`,t}$a(gk,"createSlot");var YU=Symbol.for("radix.slottable");function Rse(e){const t=$a(n=>"child"in n?n.children(n.child):n.children,"Slottable");return t.displayName=`${e}.Slottable`,t.__radixId=YU,t}$a(Rse,"createSlottable");var Ise=$a((e,t)=>{if("child"in e.props){const n=e.props.child;return w.isValidElement(n)?w.cloneElement(n,void 0,e.props.children(n.props.children)):null}return w.isValidElement(t)?t:null},"getSlottableElementFromSlottable");function XU(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}}$a(XU,"mergeProps");function ZU(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)}$a(ZU,"getElementRef");function QU(e){return w.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===YU}$a(QU,"isSlottable");var Mse=Symbol.for("react.lazy");function Q_(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Mse&&"_payload"in e&&JU(e._payload)}$a(Q_,"isLazyComponent");function JU(e){return typeof e=="object"&&e!==null&&"then"in e}$a(JU,"isPromiseLike");var Dse=$a(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),Pse=$a(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),wg=Ao[" use ".trim().toString()],Lse=Object.defineProperty,jse=(e,t)=>Lse(e,"name",{value:t,configurable:!0}),$se=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Yv=$se.reduce((e,t)=>{const n=gk(`Primitive.${t}`),r=w.forwardRef((i,a)=>{const{asChild:o,...l}=i,u=o?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),v.jsx(u,{...l,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function e5(e,t){e&&No.flushSync(()=>e.dispatchEvent(t))}jse(e5,"dispatchDiscreteCustomEvent");var zse=Object.defineProperty,Bse=(e,t)=>zse(e,"name",{value:t,configurable:!0});function Xv(e){const t=w.useRef(e);return w.useEffect(()=>{t.current=e}),w.useMemo(()=>((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)}),[])}Bse(Xv,"useCallbackRef");var Use=Object.defineProperty,br=(e,t)=>Use(e,"name",{value:t,configurable:!0}),J_="dismissableLayer.update",Fse="dismissableLayer.pointerDownOutside",Hse="dismissableLayer.focusOutside",HM,t5=w.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),qse=w.forwardRef(br(function(t,n){const{disableOutsidePointerEvents:r=!1,deferPointerDownOutside:i=!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:l,onInteractOutside:u,onDismiss:d,...f}=t,h=w.useContext(t5),[m,g]=w.useState(null),x=(m==null?void 0:m.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,y]=w.useState({}),E=Zd(n,g),_=Array.from(h.layers),[A]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),N=A?_.indexOf(A):-1,T=m?_.indexOf(m):-1,O=h.layersWithOutsidePointerEventsDisabled.size>0,C=T>=N,R=w.useRef(!1),M=n5(L=>{o==null||o(L),u==null||u(L),L.defaultPrevented||d==null||d()},{ownerDocument:x,deferPointerDownOutside:i,isDeferredPointerDownOutsideRef:R,dismissableSurfaces:h.dismissableSurfaces,shouldHandlePointerDownOutside:w.useCallback(L=>{if(!(L instanceof Node))return!1;const G=[...h.branches].some(W=>W.contains(L));return C&&!G},[h.branches,C])}),P=r5(L=>{if(i&&R.current)return;const G=L.target;[...h.branches].some(X=>X.contains(G))||(l==null||l(L),u==null||u(L),L.defaultPrevented||d==null||d())},x),D=m?T===_.length-1:!1,F=Xv(L=>{L.key==="Escape"&&(a==null||a(L),!L.defaultPrevented&&d&&(L.preventDefault(),d()))});return w.useEffect(()=>{if(D)return x.addEventListener("keydown",F,{capture:!0}),()=>x.removeEventListener("keydown",F,{capture:!0})},[x,D,F]),w.useEffect(()=>{if(m)return r&&(h.layersWithOutsidePointerEventsDisabled.size===0&&(HM=x.body.style.pointerEvents,x.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(m)),h.layers.add(m),eS(),()=>{r&&(h.layersWithOutsidePointerEventsDisabled.delete(m),h.layersWithOutsidePointerEventsDisabled.size===0&&(x.body.style.pointerEvents=HM))}},[m,x,r,h]),w.useEffect(()=>()=>{m&&(h.layers.delete(m),h.layersWithOutsidePointerEventsDisabled.delete(m),eS())},[m,h]),w.useEffect(()=>{const L=br(()=>y({}),"handleUpdate");return document.addEventListener(J_,L),()=>document.removeEventListener(J_,L)},[]),v.jsx(Yv.div,{...f,ref:E,style:{pointerEvents:O?C?"auto":"none":void 0,...t.style},onFocusCapture:xl(t.onFocusCapture,P.onFocusCapture),onBlurCapture:xl(t.onBlurCapture,P.onBlurCapture),onPointerDownCapture:xl(t.onPointerDownCapture,M.onPointerDownCapture)})},"DismissableLayer"));function Kse(){const e=w.useContext(t5),[t,n]=w.useState(null);return w.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}br(Kse,"useDismissableLayerSurface");var Gse=br(()=>!0,"IS_TRUE");function n5(e,t){const{ownerDocument:n=globalThis==null?void 0:globalThis.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:o=Gse}=t,l=Xv(e),u=w.useRef(!1),d=w.useRef(!1),f=w.useRef(new Map),h=w.useRef(()=>{});return w.useEffect(()=>{function m(){d.current=!1,i.current=!1,f.current.clear()}br(m,"resetOutsideInteraction");function g(){return Array.from(f.current.values()).some(Boolean)}br(g,"isOutsideInteractionIntercepted");function x(N){if(!d.current)return;const T=N.target;T instanceof Node&&[...a].some(C=>C.contains(T))||f.current.set(N.type,!0),N.type==="click"&&window.setTimeout(()=>{d.current&&h.current()},0)}br(x,"handleInteractionCapture");function y(N){d.current&&f.current.set(N.type,!1)}br(y,"handleInteractionBubble");const E=br(N=>{if(N.target&&!u.current){let T=function(){n.removeEventListener("click",h.current);const C=g();m(),C||bk(Fse,l,O,{discrete:!0})};if(br(T,"handleAndDispatchPointerDownOutsideEvent"),!o(N.target)){n.removeEventListener("click",h.current),m(),u.current=!1;return}const O={originalEvent:N};d.current=!0,i.current=r&&N.button===0,f.current.clear(),!r||N.button!==0?T():(n.removeEventListener("click",h.current),h.current=T,n.addEventListener("click",h.current,{once:!0}))}else n.removeEventListener("click",h.current),m();u.current=!1},"handlePointerDown"),_=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const N of _)n.addEventListener(N,x,!0),n.addEventListener(N,y);const A=window.setTimeout(()=>{n.addEventListener("pointerdown",E)},0);return()=>{window.clearTimeout(A),n.removeEventListener("pointerdown",E),n.removeEventListener("click",h.current);for(const N of _)n.removeEventListener(N,x,!0),n.removeEventListener(N,y)}},[n,l,r,i,a,o]),{onPointerDownCapture:br(()=>u.current=!0,"onPointerDownCapture")}}br(n5,"usePointerDownOutside");function r5(e,t=globalThis==null?void 0:globalThis.document){const n=Xv(e),r=w.useRef(!1);return w.useEffect(()=>{const i=br(a=>{a.target&&!r.current&&bk(Hse,n,{originalEvent:a},{discrete:!1})},"handleFocus");return t.addEventListener("focusin",i),()=>t.removeEventListener("focusin",i)},[t,n]),{onFocusCapture:br(()=>r.current=!0,"onFocusCapture"),onBlurCapture:br(()=>r.current=!1,"onBlurCapture")}}br(r5,"useFocusOutside");function eS(){const e=new CustomEvent(J_);document.dispatchEvent(e)}br(eS,"dispatchUpdate");function bk(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?e5(i,a):i.dispatchEvent(a)}br(bk,"handleAndDispatchCustomEvent");var Wse=Object.defineProperty,vk=(e,t)=>Wse(e,"name",{value:t,configurable:!0}),Eg=0,Ja=null;function Vse(e){return yk(),e.children}vk(Vse,"FocusGuards");function yk(){w.useEffect(()=>{Ja||(Ja={start:tS(),end:tS()});const{start:e,end:t}=Ja;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),Eg++,()=>{Eg===1&&(Ja==null||Ja.start.remove(),Ja==null||Ja.end.remove(),Ja=null),Eg=Math.max(0,Eg-1)}},[])}vk(yk,"useFocusGuards");function tS(){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}vk(tS,"createFocusGuard");var Yse=Object.defineProperty,Xse=(e,t)=>Yse(e,"name",{value:t,configurable:!0});function nS(e){const t=w.useRef(e);return w.useEffect(()=>{t.current=e}),w.useMemo(()=>((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)}),[])}Xse(nS,"useCallbackRef");var Zse=Object.defineProperty,Qr=(e,t)=>Zse(e,"name",{value:t,configurable:!0}),$w="focusScope.autoFocusOnMount",zw="focusScope.autoFocusOnUnmount",qM={bubbles:!1,cancelable:!0},Qse=w.forwardRef(Qr(function(t,n){const{loop:r=!1,trapped:i=!1,onMountAutoFocus:a,onUnmountAutoFocus:o,...l}=t,[u,d]=w.useState(null),f=nS(a),h=nS(o),m=w.useRef(null),g=Zd(n,d),x=w.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;w.useEffect(()=>{if(i){let E=function(T){if(x.paused||!u)return;const O=T.target;u.contains(O)?m.current=O:Qo(m.current,{select:!0})},_=function(T){if(x.paused||!u)return;const O=T.relatedTarget;O!==null&&(u.contains(O)||Qo(m.current,{select:!0}))},A=function(T){if(document.activeElement===document.body)for(const C of T)C.removedNodes.length>0&&Qo(u)};Qr(E,"handleFocusIn"),Qr(_,"handleFocusOut"),Qr(A,"handleMutations"),document.addEventListener("focusin",E),document.addEventListener("focusout",_);const N=new MutationObserver(A);return u&&N.observe(u,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",E),document.removeEventListener("focusout",_),N.disconnect()}}},[i,u,x.paused]),w.useEffect(()=>{if(u){KM.add(x);const E=document.activeElement;if(!u.contains(E)){const A=new CustomEvent($w,qM);u.addEventListener($w,f),u.dispatchEvent(A),A.defaultPrevented||(i5(c5(xk(u)),{select:!0}),document.activeElement===E&&Qo(u))}return()=>{u.removeEventListener($w,f),setTimeout(()=>{const A=new CustomEvent(zw,qM);u.addEventListener(zw,h),u.dispatchEvent(A),A.defaultPrevented||Qo(E??document.body,{select:!0}),u.removeEventListener(zw,h),KM.remove(x)},0)}}},[u,f,h,x]);const y=w.useCallback(E=>{if(!r&&!i||x.paused)return;const _=E.key==="Tab"&&!E.altKey&&!E.ctrlKey&&!E.metaKey,A=document.activeElement;if(_&&A){const N=E.currentTarget,[T,O]=a5(N);T&&O?!E.shiftKey&&A===O?(E.preventDefault(),r&&Qo(T,{select:!0})):E.shiftKey&&A===T&&(E.preventDefault(),r&&Qo(O,{select:!0})):A===N&&E.preventDefault()}},[r,i,x.paused]);return v.jsx(Yv.div,{tabIndex:-1,...l,ref:g,onKeyDown:y})},"FocusScope"));function i5(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Qo(r,{select:t}),document.activeElement!==n)return}Qr(i5,"focusFirst");function a5(e){const t=xk(e),n=rS(t,e),r=rS(t.reverse(),e);return[n,r]}Qr(a5,"getTabbableEdges");function xk(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:Qr(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}Qr(xk,"getTabbableCandidates");function rS(e,t){const n=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):o5(r,{upTo:t})))return r}Qr(rS,"findVisible");function o5(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}Qr(o5,"isHidden");function s5(e){return e instanceof HTMLInputElement&&"select"in e}Qr(s5,"isSelectableInput");function Qo(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&s5(e)&&t&&e.select()}}Qr(Qo,"focus");var KM=l5();function l5(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=iS(e,t),e.unshift(t)},remove(t){var n;e=iS(e,t),(n=e[0])==null||n.resume()}}}Qr(l5,"createFocusScopesStack");function iS(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}Qr(iS,"arrayRemove");function c5(e){return e.filter(t=>t.tagName!=="A")}Qr(c5,"removeLinks");var Jse=globalThis!=null&&globalThis.document?w.useLayoutEffect:()=>{},ele=Object.defineProperty,tle=(e,t)=>ele(e,"name",{value:t,configurable:!0}),nle=Ao[" useId ".trim().toString()]||(()=>{}),rle=0;function u5(e){const[t,n]=w.useState(nle());return Jse(()=>{e||n(r=>r??String(rle++))},[e]),e||(t?`radix-${t}`:"")}tle(u5,"useId");const ile=["top","right","bottom","left"],Nl=Math.min,ss=Math.max,Cb=Math.round,_g=Math.floor,ls=e=>({x:e,y:e}),ale={left:"right",right:"left",bottom:"top",top:"bottom"};function d5(e,t,n){return ss(e,Nl(t,n))}function gs(e,t){return typeof e=="function"?e(t):e}function Tl(e){return e.split("-")[0]}function Qd(e){return e.split("-")[1]}function wk(e){return e==="x"?"y":"x"}function Ek(e){return e==="y"?"height":"width"}function co(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function _k(e){return wk(co(e))}function ole(e,t,n){n===void 0&&(n=!1);const r=Qd(e),i=_k(e),a=Ek(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(o=Rb(o)),[o,Rb(o)]}function sle(e){const t=Rb(e);return[aS(e),t,aS(t)]}function aS(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const GM=["left","right"],WM=["right","left"],lle=["top","bottom"],cle=["bottom","top"];function ule(e,t,n){switch(e){case"top":case"bottom":return n?t?WM:GM:t?GM:WM;case"left":case"right":return t?lle:cle;default:return[]}}function dle(e,t,n,r){const i=Qd(e);let a=ule(Tl(e),n==="start",r);return i&&(a=a.map(o=>o+"-"+i),t&&(a=a.concat(a.map(aS)))),a}function Rb(e){const t=Tl(e);return ale[t]+e.slice(t.length)}function fle(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 f5(e){return typeof e!="number"?fle(e):{top:e,right:e,bottom:e,left:e}}function Ib(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 VM(e,t,n){let{reference:r,floating:i}=e;const a=co(t),o=_k(t),l=Ek(o),u=Tl(t),d=a==="y",f=r.x+r.width/2-i.width/2,h=r.y+r.height/2-i.height/2,m=r[l]/2-i[l]/2;let g;switch(u){case"top":g={x:f,y:r.y-i.height};break;case"bottom":g={x:f,y:r.y+r.height};break;case"right":g={x:r.x+r.width,y:h};break;case"left":g={x:r.x-i.width,y:h};break;default:g={x:r.x,y:r.y}}const x=Qd(t);return x&&(g[o]+=m*(x==="end"?1:-1)*(n&&d?-1:1)),g}async function hle(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:a,rects:o,elements:l,strategy:u}=e,{boundary:d="clippingAncestors",rootBoundary:f="viewport",elementContext:h="floating",altBoundary:m=!1,padding:g=0}=gs(t,e),x=f5(g),E=l[m?h==="floating"?"reference":"floating":h],_=Ib(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:f,strategy:u})),A=h==="floating"?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,N=await(a.getOffsetParent==null?void 0:a.getOffsetParent(l.floating)),T=await(a.isElement==null?void 0:a.isElement(N))&&await(a.getScale==null?void 0:a.getScale(N))||{x:1,y:1},O=Ib(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:A,offsetParent:N,strategy:u}):A);return{top:(_.top-O.top+x.top)/T.y,bottom:(O.bottom-_.bottom+x.bottom)/T.y,left:(_.left-O.left+x.left)/T.x,right:(O.right-_.right+x.right)/T.x}}const ple=50,mle=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:a=[],platform:o}=n,l=o.detectOverflow?o:{...o,detectOverflow:hle},u=await(o.isRTL==null?void 0:o.isRTL(t));let d=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:f,y:h}=VM(d,r,u),m=r,g=0;const x={};for(let y=0;y<a.length;y++){const E=a[y];if(!E)continue;const{name:_,fn:A}=E,{x:N,y:T,data:O,reset:C}=await A({x:f,y:h,initialPlacement:r,placement:m,strategy:i,middlewareData:x,rects:d,platform:l,elements:{reference:e,floating:t}});f=N??f,h=T??h,x[_]={...x[_],...O},C&&g<ple&&(g++,typeof C=="object"&&(C.placement&&(m=C.placement),C.rects&&(d=C.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):C.rects),{x:f,y:h}=VM(d,m,u)),y=-1)}return{x:f,y:h,placement:m,strategy:i,middlewareData:x}},gle=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:a,platform:o,elements:l,middlewareData:u}=t,{element:d,padding:f=0}=gs(e,t)||{};if(d==null)return{};const h=f5(f),m={x:n,y:r},g=_k(i),x=Ek(g),y=await o.getDimensions(d),E=g==="y",_=E?"top":"left",A=E?"bottom":"right",N=E?"clientHeight":"clientWidth",T=a.reference[x]+a.reference[g]-m[g]-a.floating[x],O=m[g]-a.reference[g],C=await(o.getOffsetParent==null?void 0:o.getOffsetParent(d));let R=C?C[N]:0;(!R||!await(o.isElement==null?void 0:o.isElement(C)))&&(R=l.floating[N]||a.floating[x]);const M=T/2-O/2,P=R/2-y[x]/2-1,D=Nl(h[_],P),F=Nl(h[A],P),L=R-y[x]-F,G=R/2-y[x]/2+M,W=d5(D,G,L),X=!u.arrow&&Qd(i)!=null&&G!==W&&a.reference[x]/2-(G<D?D:F)-y[x]/2<0,B=X?G<D?G-D:G-L:0;return{[g]:m[g]+B,data:{[g]:W,centerOffset:G-W-B,...X&&{alignmentOffset:B}},reset:X}}}),ble=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:a,rects:o,initialPlacement:l,platform:u,elements:d}=t,{mainAxis:f=!0,crossAxis:h=!0,fallbackPlacements:m,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:y=!0,...E}=gs(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const _=Tl(i),A=co(l),N=Tl(l)===l,T=await(u.isRTL==null?void 0:u.isRTL(d.floating)),O=m||(N||!y?[Rb(l)]:sle(l)),C=x!=="none";!m&&C&&O.push(...dle(l,y,x,T));const R=[l,...O],M=await u.detectOverflow(t,E),P=[];let D=((r=a.flip)==null?void 0:r.overflows)||[];if(f&&P.push(M[_]),h){const W=ole(i,o,T);P.push(M[W[0]],M[W[1]])}if(D=[...D,{placement:i,overflows:P}],!P.every(W=>W<=0)){var F,L;const W=(((F=a.flip)==null?void 0:F.index)||0)+1,X=R[W];if(X&&(!(h==="alignment"?A!==co(X):!1)||D.every(H=>co(H.placement)===A?H.overflows[0]>0:!0)))return{data:{index:W,overflows:D},reset:{placement:X}};let B=(L=D.filter(q=>q.overflows[0]<=0).sort((q,H)=>q.overflows[1]-H.overflows[1])[0])==null?void 0:L.placement;if(!B)switch(g){case"bestFit":{var G;const q=(G=D.filter(H=>{if(C){const V=co(H.placement);return V===A||V==="y"}return!0}).map(H=>[H.placement,H.overflows.filter(V=>V>0).reduce((V,z)=>V+z,0)]).sort((H,V)=>H[1]-V[1])[0])==null?void 0:G[0];q&&(B=q);break}case"initialPlacement":B=l;break}if(i!==B)return{reset:{placement:B}}}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 ile.some(t=>e[t]>=0)}const vle=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:i="referenceHidden",...a}=gs(e,t);switch(i){case"referenceHidden":{const o=await r.detectOverflow(t,{...a,elementContext:"reference"}),l=YM(o,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:XM(l)}}}case"escaped":{const o=await r.detectOverflow(t,{...a,altBoundary:!0}),l=YM(o,n.floating);return{data:{escapedOffsets:l,escaped:XM(l)}}}default:return{}}}}},h5=new Set(["left","top"]);async function yle(e,t){const{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Tl(n),l=Qd(n),u=co(n)==="y",d=h5.has(o)?-1:1,f=a&&u?-1:1,h=gs(t,e);let{mainAxis:m,crossAxis:g,alignmentAxis:x}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return l&&typeof x=="number"&&(g=l==="end"?x*-1:x),u?{x:g*f,y:m*d}:{x:m*d,y:g*f}}const xle=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:a,placement:o,middlewareData:l}=t,u=await yle(t,e);return o===((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:o}}}}},wle=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:o=!0,crossAxis:l=!1,limiter:u={fn:A=>{let{x:N,y:T}=A;return{x:N,y:T}}},...d}=gs(e,t),f={x:n,y:r},h=await a.detectOverflow(t,d),m=co(i),g=wk(m);let x=f[g],y=f[m];const E=(A,N)=>d5(N+h[A==="y"?"top":"left"],N,N-h[A==="y"?"bottom":"right"]);o&&(x=E(g,x)),l&&(y=E(m,y));const _=u.fn({...t,[g]:x,[m]:y});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[g]:o,[m]:l}}}}}},Ele=function(e){return e===void 0&&(e={}),{options:e,fn(t){var n,r;const{x:i,y:a,placement:o,rects:l,middlewareData:u}=t,{offset:d=0,mainAxis:f=!0,crossAxis:h=!0}=gs(e,t),m={x:i,y:a},g=co(o),x=wk(g);let y=m[x],E=m[g];const _=gs(d,t),A=typeof _=="number"?{mainAxis:_,crossAxis:0}:{mainAxis:(n=_.mainAxis)!=null?n:0,crossAxis:(r=_.crossAxis)!=null?r:0};if(f){const O=x==="y"?"height":"width",C=l.reference[x]-l.floating[O]+A.mainAxis,R=l.reference[x]+l.reference[O]-A.mainAxis;y<C?y=C:y>R&&(y=R)}if(h){var N,T;const O=x==="y"?"width":"height",C=h5.has(Tl(o)),R=l.reference[g]-l.floating[O]+(C&&((N=u.offset)==null?void 0:N[g])||0)+(C?0:A.crossAxis),M=l.reference[g]+l.reference[O]+(C?0:((T=u.offset)==null?void 0:T[g])||0)-(C?A.crossAxis:0);E<R?E=R:E>M&&(E=M)}return{[x]:y,[g]:E}}}},_le=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:o=()=>{},...l}=gs(e,t),u=await i.detectOverflow(t,l),d=Tl(n),f=Qd(n),h=co(n)==="y",{width:m,height:g}=r.floating;let x,y;d==="top"||d==="bottom"?(x=d,y=f===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=d,x=f==="end"?"top":"bottom");const E=g-u.top-u.bottom,_=m-u.left-u.right,A=Nl(g-u[x],E),N=Nl(m-u[y],_),T=t.middlewareData.shift,O=!T;let C=A,R=N;T!=null&&T.enabled.x&&(R=_),T!=null&&T.enabled.y&&(C=E),O&&!f&&(h?R=m-2*ss(u.left,u.right):C=g-2*ss(u.top,u.bottom)),await o({...t,availableWidth:R,availableHeight:C});const M=await i.getDimensions(a.floating);return m!==M.width||g!==M.height?{reset:{rects:!0}}:{}}}};function Zv(){return typeof window<"u"}function Jd(e){return p5(e)?(e.nodeName||"").toLowerCase():"#document"}function bi(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function _s(e){var t;return(t=(p5(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function p5(e){return Zv()?e instanceof Node||e instanceof bi(e).Node:!1}function yo(e){return Zv()?e instanceof Element||e instanceof bi(e).Element:!1}function $l(e){return Zv()?e instanceof HTMLElement||e instanceof bi(e).HTMLElement:!1}function ZM(e){return!Zv()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof bi(e).ShadowRoot}function Qv(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=xo(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function Sle(e){return/^(table|td|th)$/.test(Jd(e))}function Jv(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const kle=/transform|translate|scale|rotate|perspective|filter/,Ale=/paint|layout|strict|content/,dc=e=>!!e&&e!=="none";let Bw;function Sk(e){const t=yo(e)?xo(e):e;return dc(t.transform)||dc(t.translate)||dc(t.scale)||dc(t.rotate)||dc(t.perspective)||!kk()&&(dc(t.backdropFilter)||dc(t.filter))||kle.test(t.willChange||"")||Ale.test(t.contain||"")}function Nle(e){let t=Hc(e);for(;$l(t)&&!Vh(t);){if(Sk(t))return t;if(Jv(t))return null;t=Hc(t)}return null}function kk(){return Bw==null&&(Bw=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Bw}function Vh(e){return/^(html|body|#document)$/.test(Jd(e))}function xo(e){return bi(e).getComputedStyle(e)}function ey(e){return yo(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Hc(e){if(Jd(e)==="html")return e;const t=e.assignedSlot||e.parentNode||ZM(e)&&e.host||_s(e);return ZM(t)?t.host:t}function m5(e){const t=Hc(e);return Vh(t)?(e.ownerDocument||e).body:$l(t)&&Qv(t)?t:m5(t)}function Yh(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=m5(e),a=i===((r=e.ownerDocument)==null?void 0:r.body),o=bi(i);if(a){const l=oS(o);return t.concat(o,o.visualViewport||[],Qv(i)?i:[],l&&n?Yh(l):[])}else return t.concat(i,Yh(i,[],n))}function oS(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function g5(e){const t=xo(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=$l(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,l=Cb(n)!==a||Cb(r)!==o;return l&&(n=a,r=o),{width:n,height:r,$:l}}function Ak(e){return yo(e)?e:e.contextElement}function wd(e){const t=Ak(e);if(!$l(t))return ls(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:a}=g5(t);let o=(a?Cb(n.width):n.width)/r,l=(a?Cb(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const Tle=ls(0);function b5(e){const t=bi(e);return!kk()||!t.visualViewport?Tle:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ole(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===bi(e)}function qc(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),a=Ak(e);let o=ls(1);t&&(r?yo(r)&&(o=wd(r)):o=wd(e));const l=Ole(a,n,r)?b5(a):ls(0);let u=(i.left+l.x)/o.x,d=(i.top+l.y)/o.y,f=i.width/o.x,h=i.height/o.y;if(a&&r){const m=bi(a),g=yo(r)?bi(r):r;let x=m,y=oS(x);for(;y&&g!==x;){const E=wd(y),_=y.getBoundingClientRect(),A=xo(y),N=_.left+(y.clientLeft+parseFloat(A.paddingLeft))*E.x,T=_.top+(y.clientTop+parseFloat(A.paddingTop))*E.y;u*=E.x,d*=E.y,f*=E.x,h*=E.y,u+=N,d+=T,x=bi(y),y=oS(x)}}return Ib({width:f,height:h,x:u,y:d})}function ty(e,t){const n=ey(e).scrollLeft;return t?t.left+n:qc(_s(e)).left+n}function v5(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-ty(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function Cle(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const a=i==="fixed",o=_s(r),l=t?Jv(t.floating):!1;if(r===o||l&&a)return n;let u={scrollLeft:0,scrollTop:0},d=ls(1);const f=ls(0),h=$l(r);if((h||!a)&&((Jd(r)!=="body"||Qv(o))&&(u=ey(r)),h)){const g=qc(r);d=wd(r),f.x=g.x+r.clientLeft,f.y=g.y+r.clientTop}const m=o&&!h&&!a?v5(o,u):ls(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-u.scrollLeft*d.x+f.x+m.x,y:n.y*d.y-u.scrollTop*d.y+f.y+m.y}}function Rle(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function Ile(e){const t=ey(e),n=e.ownerDocument.body,r=ss(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=ss(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let a=-t.scrollLeft+ty(e);const o=-t.scrollTop;return xo(n).direction==="rtl"&&(a+=ss(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}const Mle=25;function Dle(e,t,n){n===void 0&&(n="viewport");const r=n==="layoutViewport",i=bi(e),a=_s(e),o=i.visualViewport;let l=a.clientWidth,u=a.clientHeight,d=0,f=0;if(o){const m=!kk()||t==="fixed";r?m||(d=-o.offsetLeft,f=-o.offsetTop):(l=o.width,u=o.height,m&&(d=o.offsetLeft,f=o.offsetTop))}if(ty(a)<=0){const m=a.ownerDocument,g=m.body,x=getComputedStyle(g),y=m.compatMode==="CSS1Compat"&&parseFloat(x.marginLeft)+parseFloat(x.marginRight)||0,E=Math.abs(a.clientWidth-g.clientWidth-y),_=getComputedStyle(a).scrollbarGutter==="stable both-edges"?E/2:E;_<=Mle&&(l-=_)}return{width:l,height:u,x:d,y:f}}function Ple(e,t){const n=qc(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=wd(e),o=e.clientWidth*a.x,l=e.clientHeight*a.y,u=i*a.x,d=r*a.y;return{width:o,height:l,x:u,y:d}}function QM(e,t,n){let r;if(t==="viewport"||t==="layoutViewport")r=Dle(e,n,t);else if(t==="document")r=Ile(_s(e));else if(yo(t))r=Ple(t,n);else{const i=b5(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return Ib(r)}function Lle(e,t){const n=t.get(e);if(n)return n;let r=Yh(e,[],!1).filter(l=>yo(l)&&Jd(l)!=="body"),i=null;const a=xo(e).position==="fixed";let o=a?Hc(e):e;for(;yo(o)&&!Vh(o);){const l=xo(o),u=Sk(o),d=i?i.position:a?"fixed":"";!u&&(d==="fixed"||d==="absolute"&&l.position==="static")?r=r.filter(h=>h!==o):i=l,o=Hc(o)}return t.set(e,r),r}function jle(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const o=[...n==="clippingAncestors"?Jv(t)?[]:Lle(t,this._c):[].concat(n),r],l=QM(t,o[0],i);let u=l.top,d=l.right,f=l.bottom,h=l.left;for(let m=1;m<o.length;m++){const g=QM(t,o[m],i);u=ss(g.top,u),d=Nl(g.right,d),f=Nl(g.bottom,f),h=ss(g.left,h)}return{width:d-h,height:f-u,x:h,y:u}}function $le(e){const{width:t,height:n}=g5(e);return{width:t,height:n}}function zle(e,t,n){const r=$l(t),i=_s(t),a=n==="fixed",o=qc(e,!0,a,t);let l={scrollLeft:0,scrollTop:0};const u=ls(0);if((r||!a)&&((Jd(t)!=="body"||Qv(i))&&(l=ey(t)),r)){const m=qc(t,!0,a,t);u.x=m.x+t.clientLeft,u.y=m.y+t.clientTop}!r&&i&&(u.x=ty(i));const d=i&&!r&&!a?v5(i,l):ls(0),f=o.left+l.scrollLeft-u.x-d.x,h=o.top+l.scrollTop-u.y-d.y;return{x:f,y:h,width:o.width,height:o.height}}function Uw(e){return xo(e).position==="static"}function JM(e,t){if(!$l(e)||xo(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return _s(e)===n&&(n=n.ownerDocument.body),n}function y5(e,t){const n=bi(e);if(Jv(e))return n;if(!$l(e)){let i=Hc(e);for(;i&&!Vh(i);){if(yo(i)&&!Uw(i))return i;i=Hc(i)}return n}let r=JM(e,t);for(;r&&Sle(r)&&Uw(r);)r=JM(r,t);return r&&Vh(r)&&Uw(r)&&!Sk(r)?n:r||Nle(e)||n}const Ble=async function(e){const t=this.getOffsetParent||y5,n=this.getDimensions,r=await n(e.floating);return{reference:zle(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Ule(e){return xo(e).direction==="rtl"}const Fle={convertOffsetParentRelativeRectToViewportRelativeRect:Cle,getDocumentElement:_s,getClippingRect:jle,getOffsetParent:y5,getElementRects:Ble,getClientRects:Rle,getDimensions:$le,getScale:wd,isElement:yo,isRTL:Ule};function x5(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Hle(e,t,n){let r=null,i;const a=_s(e);function o(){var f;clearTimeout(i),(f=r)==null||f.disconnect(),r=null}function l(f,h){f===void 0&&(f=!1),h===void 0&&(h=1),o();const m=e.getBoundingClientRect(),{left:g,top:x,width:y,height:E}=m;if(f||t(),!y||!E)return;const _=_g(x),A=_g(a.clientWidth-(g+y)),N=_g(a.clientHeight-(x+E)),T=_g(g),C={rootMargin:-_+"px "+-A+"px "+-N+"px "+-T+"px",threshold:ss(0,Nl(1,h))||1};let R=!0;function M(P){const D=P[0].intersectionRatio;if(!x5(m,e.getBoundingClientRect()))return l();if(D!==h){if(!R)return l();D?l(!1,D):i=setTimeout(()=>{l(!1,1e-7)},1e3)}R=!1}try{r=new IntersectionObserver(M,{...C,root:a.ownerDocument})}catch{r=new IntersectionObserver(M,C)}r.observe(e)}const u=bi(e),d=()=>l(n);return u.addEventListener("resize",d),l(!0),()=>{u.removeEventListener("resize",d),o()}}function qle(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,d=Ak(e),f=i||a?[...d?Yh(d):[],...t?Yh(t):[]]:[];f.forEach(_=>{i&&_.addEventListener("scroll",n),a&&_.addEventListener("resize",n)});const h=d&&l?Hle(d,n,a):null;let m=-1,g=null;o&&(g=new ResizeObserver(_=>{let[A]=_;A&&A.target===d&&g&&t&&(g.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var N;(N=g)==null||N.observe(t)})),n()}),d&&!u&&g.observe(d),t&&g.observe(t));let x,y=u?qc(e):null;u&&E();function E(){const _=qc(e);y&&!x5(y,_)&&n(),y=_,x=requestAnimationFrame(E)}return n(),()=>{var _;f.forEach(A=>{i&&A.removeEventListener("scroll",n),a&&A.removeEventListener("resize",n)}),h==null||h(),(_=g)==null||_.disconnect(),g=null,u&&cancelAnimationFrame(x)}}const Kle=xle,Gle=wle,Wle=ble,Vle=_le,Yle=vle,eD=gle,Xle=Ele,Zle=(e,t,n)=>{const r=new Map,i=n??{},a={...Fle,...i.platform,_c:r};return mle(e,t,{...i,platform:a})};var Qle=typeof document<"u",Jle=function(){},tb=Qle?w.useLayoutEffect:Jle;function Mb(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(!Mb(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)&&!Mb(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function w5(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function tD(e,t){const n=w5(e);return Math.round(t*n)/n}function Fw(e){const t=w.useRef(e);return tb(()=>{t.current=e}),t}function ece(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:l=!0,whileElementsMounted:u,open:d}=e,[f,h]=w.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,g]=w.useState(r);Mb(m,r)||g(r);const[x,y]=w.useState(null),[E,_]=w.useState(null),A=w.useCallback(H=>{H!==C.current&&(C.current=H,y(H))},[]),N=w.useCallback(H=>{H!==R.current&&(R.current=H,_(H))},[]),T=a||x,O=o||E,C=w.useRef(null),R=w.useRef(null),M=w.useRef(f),P=u!=null,D=Fw(u),F=Fw(i),L=Fw(d),G=w.useCallback(()=>{if(!C.current||!R.current)return;const H={placement:t,strategy:n,middleware:m};F.current&&(H.platform=F.current),Zle(C.current,R.current,H).then(V=>{const z={...V,isPositioned:L.current!==!1};W.current&&!Mb(M.current,z)&&(M.current=z,No.flushSync(()=>{h(z)}))})},[m,t,n,F,L]);tb(()=>{d===!1&&M.current.isPositioned&&(M.current.isPositioned=!1,h(H=>({...H,isPositioned:!1})))},[d]);const W=w.useRef(!1);tb(()=>(W.current=!0,()=>{W.current=!1}),[]),tb(()=>{if(T&&(C.current=T),O&&(R.current=O),T&&O){if(D.current)return D.current(T,O,G);G()}},[T,O,G,D,P]);const X=w.useMemo(()=>({reference:C,floating:R,setReference:A,setFloating:N}),[A,N]),B=w.useMemo(()=>({reference:T,floating:O}),[T,O]),q=w.useMemo(()=>{const H={position:n,left:0,top:0};if(!B.floating)return H;const V=tD(B.floating,f.x),z=tD(B.floating,f.y);return l?{...H,transform:"translate("+V+"px, "+z+"px)",...w5(B.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:V,top:z}},[n,l,B.floating,f.x,f.y]);return w.useMemo(()=>({...f,update:G,refs:X,elements:B,floatingStyles:q}),[f,G,X,B,q])}const tce=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?eD({element:r.current,padding:i}).fn(n):{}:r?eD({element:r,padding:i}).fn(n):{}}}},nce=(e,t)=>{const n=Kle(e);return{name:n.name,fn:n.fn,options:[e,t]}},rce=(e,t)=>{const n=Gle(e);return{name:n.name,fn:n.fn,options:[e,t]}},ice=(e,t)=>({fn:Xle(e).fn,options:[e,t]}),ace=(e,t)=>{const n=Wle(e);return{name:n.name,fn:n.fn,options:[e,t]}},oce=(e,t)=>{const n=Vle(e);return{name:n.name,fn:n.fn,options:[e,t]}},sce=(e,t)=>{const n=Yle(e);return{name:n.name,fn:n.fn,options:[e,t]}},lce=(e,t)=>{const n=tce(e);return{name:n.name,fn:n.fn,options:[e,t]}};var cce=Object.defineProperty,Nk=(e,t)=>cce(e,"name",{value:t,configurable:!0});function sS(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}Nk(sS,"setRef");function E5(...e){return t=>{let n=!1;const r=e.map(i=>{const a=sS(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():sS(e[i],null)}}}}Nk(E5,"composeRefs");function ny(...e){return w.useCallback(E5(...e),e)}Nk(ny,"useComposedRefs");var uce=Object.defineProperty,fa=(e,t)=>uce(e,"name",{value:t,configurable:!0});function dce(e,t){const n=w.createContext(t);n.displayName=e+"Context";const r=fa(a=>{const{children:o,...l}=a,u=w.useMemo(()=>l,Object.values(l));return v.jsx(n.Provider,{value:u,children:o})},"Provider");r.displayName=e+"Provider";function i(a,o={}){const{optional:l=!1}=o,u=w.useContext(n);if(u)return u;if(t!==void 0)return t;if(!l)throw new Error(`\`${a}\` must be used within \`${e}\``)}return fa(i,"useContext"),[r,i]}fa(dce,"createContext");function _5(e,t=[]){let n=[];function r(a,o){const l=w.createContext(o);l.displayName=a+"Context";const u=n.length;n=[...n,o];const d=fa(h=>{var _;const{scope:m,children:g,...x}=h,y=((_=m==null?void 0:m[e])==null?void 0:_[u])||l,E=w.useMemo(()=>x,Object.values(x));return v.jsx(y.Provider,{value:E,children:g})},"Provider");d.displayName=a+"Provider";function f(h,m,g={}){var _;const{optional:x=!1}=g,y=((_=m==null?void 0:m[e])==null?void 0:_[u])||l,E=w.useContext(y);if(E)return E;if(o!==void 0)return o;if(!x)throw new Error(`\`${h}\` must be used within \`${a}\``)}return fa(f,"useContext"),[d,f]}fa(r,"createContext");const i=fa(()=>{const a=n.map(o=>w.createContext(o));return fa(function(l){const u=(l==null?void 0:l[e])||a;return w.useMemo(()=>({[`__scope${e}`]:{...l,[e]:u}}),[l,u])},"useScope")},"createScope");return i.scopeName=e,[r,S5(i,...t)]}fa(_5,"createContextScope");function S5(...e){const t=e[0];if(e.length===1)return t;const n=fa(()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return fa(function(a){const o=r.reduce((l,{useScope:u,scopeName:d})=>{const h=u(a)[`__scope${d}`];return{...l,...h}},{});return w.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])},"useComposedScopes")},"createScope");return n.scopeName=t.scopeName,n}fa(S5,"composeContextScopes");var fce=Object.defineProperty,za=(e,t)=>fce(e,"name",{value:t,configurable:!0});function k5(e){const t=w.forwardRef((n,r)=>{let{children:i,...a}=n,o=null,l=!1;const u=[];lS(i)&&typeof Sg=="function"&&(i=Sg(i._payload)),w.Children.forEach(i,m=>{var g;if(O5(m)){l=!0;const x=m;let y="child"in x.props?x.props.child:x.props.children;lS(y)&&typeof Sg=="function"&&(y=Sg(y._payload)),o=pce(x,y),u.push((g=o==null?void 0:o.props)==null?void 0:g.children)}else u.push(m)}),o?o=w.cloneElement(o,void 0,u):!l&&w.Children.count(i)===1&&w.isValidElement(i)&&(o=i);const d=o?T5(o):void 0,f=ny(r,d);if(!o){if(i||i===0)throw new Error(l?bce(e):gce(e));return i}const h=N5(a,o.props??{});return o.type!==w.Fragment&&(h.ref=r?f:d),w.cloneElement(o,h)});return t.displayName=`${e}.Slot`,t}za(k5,"createSlot");var A5=Symbol.for("radix.slottable");function hce(e){const t=za(n=>"child"in n?n.children(n.child):n.children,"Slottable");return t.displayName=`${e}.Slottable`,t.__radixId=A5,t}za(hce,"createSlottable");var pce=za((e,t)=>{if("child"in e.props){const n=e.props.child;return w.isValidElement(n)?w.cloneElement(n,void 0,e.props.children(n.props.children)):null}return w.isValidElement(t)?t:null},"getSlottableElementFromSlottable");function N5(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}}za(N5,"mergeProps");function T5(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)}za(T5,"getElementRef");function O5(e){return w.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===A5}za(O5,"isSlottable");var mce=Symbol.for("react.lazy");function lS(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===mce&&"_payload"in e&&C5(e._payload)}za(lS,"isLazyComponent");function C5(e){return typeof e=="object"&&e!==null&&"then"in e}za(C5,"isPromiseLike");var gce=za(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),bce=za(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),Sg=Ao[" use ".trim().toString()],vce=Object.defineProperty,yce=(e,t)=>vce(e,"name",{value:t,configurable:!0}),xce=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],R5=xce.reduce((e,t)=>{const n=k5(`Primitive.${t}`),r=w.forwardRef((i,a)=>{const{asChild:o,...l}=i,u=o?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),v.jsx(u,{...l,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function wce(e,t){e&&No.flushSync(()=>e.dispatchEvent(t))}yce(wce,"dispatchDiscreteCustomEvent");var Ece=Object.defineProperty,_ce=(e,t)=>Ece(e,"name",{value:t,configurable:!0});function I5(e){const t=w.useRef(e);return w.useEffect(()=>{t.current=e}),w.useMemo(()=>((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)}),[])}_ce(I5,"useCallbackRef");var Hw=globalThis!=null&&globalThis.document?w.useLayoutEffect:()=>{},Sce=globalThis!=null&&globalThis.document?w.useLayoutEffect:()=>{},kce=Object.defineProperty,Ace=(e,t)=>kce(e,"name",{value:t,configurable:!0});function M5(e){const[t,n]=w.useState(void 0);return Sce(()=>{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 o,l;if("borderBoxSize"in a){const u=a.borderBoxSize,d=Array.isArray(u)?u[0]:u;o=d.inlineSize,l=d.blockSize}else o=e.offsetWidth,l=e.offsetHeight;n({width:o,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}Ace(M5,"useSize");var Nce=Object.defineProperty,wl=(e,t)=>Nce(e,"name",{value:t,configurable:!0}),D5="Popper",[P5,L5]=_5(D5),[Tce,j5]=P5(D5),Oce=wl(e=>{const{__scopePopper:t,children:n}=e,[r,i]=w.useState(null),[a,o]=w.useState(void 0);return v.jsx(Tce,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})},"Popper"),Cce="PopperAnchor",Rce=w.forwardRef(wl(function(t,n){const{__scopePopper:r,virtualRef:i,...a}=t,o=j5(Cce,r),l=w.useRef(null),u=o.onAnchorChange,d=w.useCallback(y=>{l.current=y,y&&u(y)},[u]),f=ny(n,d),h=w.useRef(null);w.useEffect(()=>{if(!i)return;const y=h.current;h.current=i.current,y!==h.current&&u(h.current)});const m=o.placementState&&ry(o.placementState),g=m==null?void 0:m[0],x=m==null?void 0:m[1];return i?null:v.jsx(R5.div,{"data-radix-popper-side":g,"data-radix-popper-align":x,...a,ref:f})},"PopperAnchor")),$5="PopperContent",[Ice,yPe]=P5($5),Mce=w.forwardRef(wl(function(t,n){var fe,Ae,Te,pe,Ze,Re,De;const{__scopePopper:r,side:i="bottom",sideOffset:a=0,align:o="center",alignOffset:l=0,arrowPadding:u=0,avoidCollisions:d=!0,collisionBoundary:f=[],collisionPadding:h=0,sticky:m="partial",hideWhenDetached:g=!1,updatePositionStrategy:x="optimized",onPlaced:y,...E}=t,_=j5($5,r),[A,N]=w.useState(null),T=ny(n,N),[O,C]=w.useState(null),R=M5(O),M=(R==null?void 0:R.width)??0,P=(R==null?void 0:R.height)??0,D=i+(o!=="center"?"-"+o:""),F=typeof h=="number"?h:{top:0,right:0,bottom:0,left:0,...h},L=Array.isArray(f)?f:[f],G=L.length>0,W={padding:F,boundary:L.filter(z5),altBoundary:G},{refs:X,floatingStyles:B,placement:q,isPositioned:H,middlewareData:V}=ece({strategy:"fixed",placement:D,whileElementsMounted:wl((...Ne)=>qle(...Ne,{animationFrame:x==="always"}),"whileElementsMounted"),elements:{reference:_.anchor},middleware:[nce({mainAxis:a+P,alignmentAxis:l}),d&&rce({mainAxis:!0,crossAxis:!1,limiter:m==="partial"?ice():void 0,...W}),d&&ace({...W}),oce({...W,apply:wl(({elements:Ne,rects:At,availableWidth:bt,availableHeight:hn})=>{const{width:Jn,height:wn}=At.reference,$n=Ne.floating.style;$n.setProperty("--radix-popper-available-width",`${bt}px`),$n.setProperty("--radix-popper-available-height",`${hn}px`),$n.setProperty("--radix-popper-anchor-width",`${Jn}px`),$n.setProperty("--radix-popper-anchor-height",`${wn}px`)},"apply")}),O&&lce({element:O,padding:u}),Dce({arrowWidth:M,arrowHeight:P}),g&&sce({strategy:"referenceHidden",...W,boundary:G?W.boundary:void 0})]}),z=_.setPlacementState;Hw(()=>(z(q),()=>{z(void 0)}),[q,z]);const[j,Z]=ry(q),$=I5(y);Hw(()=>{H&&($==null||$())},[H,$]);const ne=(fe=V.arrow)==null?void 0:fe.x,be=(Ae=V.arrow)==null?void 0:Ae.y,ye=((Te=V.arrow)==null?void 0:Te.centerOffset)!==0,[_e,Ce]=w.useState();return Hw(()=>{A&&Ce(window.getComputedStyle(A).zIndex)},[A]),v.jsx("div",{ref:X.setFloating,"data-radix-popper-content-wrapper":"",style:{...B,transform:H?B.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:_e,"--radix-popper-transform-origin":[(pe=V.transformOrigin)==null?void 0:pe.x,(Ze=V.transformOrigin)==null?void 0:Ze.y].join(" "),...((Re=V.hide)==null?void 0:Re.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:v.jsx(Ice,{scope:r,placedSide:j,placedAlign:Z,onArrowChange:C,arrowX:ne,arrowY:be,shouldHideArrow:ye,children:v.jsx(R5.div,{"data-side":j,"data-align":Z,...E,ref:T,style:{...E.style,animation:H?(De=E.style)==null?void 0:De.animation:"none"}})})})},"PopperContent"));function z5(e){return e!==null}wl(z5,"isNotNull");var Dce=wl(e=>({name:"transformOrigin",options:e,fn(t){var E,_,A;const{placement:n,rects:r,middlewareData:i}=t,o=((E=i.arrow)==null?void 0:E.centerOffset)!==0,l=o?0:e.arrowWidth,u=o?0:e.arrowHeight,[d,f]=ry(n),h={start:"0%",center:"50%",end:"100%"}[f],m=(((_=i.arrow)==null?void 0:_.x)??0)+l/2,g=(((A=i.arrow)==null?void 0:A.y)??0)+u/2;let x="",y="";return d==="bottom"?(x=o?h:`${m}px`,y=`${-u}px`):d==="top"?(x=o?h:`${m}px`,y=`${r.floating.height+u}px`):d==="right"?(x=`${-u}px`,y=o?h:`${g}px`):d==="left"&&(x=`${r.floating.width+u}px`,y=o?h:`${g}px`),{data:{x,y}}}}),"transformOrigin");function ry(e){const[t,n="center"]=e.split("-");return[t,n]}wl(ry,"getSideAndAlignFromPlacement");var Pce=Oce,Lce=Rce,jce=Mce,$ce=globalThis!=null&&globalThis.document?w.useLayoutEffect:()=>{},zce=Object.defineProperty,Bce=(e,t)=>zce(e,"name",{value:t,configurable:!0}),Uce=w.forwardRef(Bce(function(t,n){var u;const{container:r,...i}=t,[a,o]=w.useState(!1);$ce(()=>o(!0),[]);const l=r||a&&((u=globalThis==null?void 0:globalThis.document)==null?void 0:u.body);return l?No.createPortal(v.jsx(Yv.div,{...i,ref:n}),l):null},"Portal")),nD=globalThis!=null&&globalThis.document?w.useLayoutEffect:()=>{},Fce=Object.defineProperty,bs=(e,t)=>Fce(e,"name",{value:t,configurable:!0});function B5(e,t){return w.useReducer((n,r)=>t[n][r]??n,e)}bs(B5,"useStateMachine");var U5=bs(e=>{const{present:t,children:n}=e,r=F5(t),i=typeof n=="function"?n({present:r.isPresent}):w.Children.only(n),a=H5(r.ref,q5(i));return typeof n=="function"||r.isPresent?w.cloneElement(i,{ref:a}):null},"Presence");function F5(e){const[t,n]=w.useState(),r=w.useRef(null),i=w.useRef(e),a=w.useRef("none"),o=w.useRef(void 0),l=e?"mounted":"unmounted",[u,d]=B5(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return w.useEffect(()=>{u==="mounted"?(a.current=o.current??cd(r.current),o.current=void 0):a.current="none"},[u]),nD(()=>{const f=r.current,h=i.current;if(h!==e){const g=a.current,x=cd(f);e?(o.current=x,d("MOUNT")):x==="none"||(f==null?void 0:f.display)==="none"?d("UNMOUNT"):d(h&&g!==x?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,d]),nD(()=>{if(t){let f;const h=t.ownerDocument.defaultView??window,m=bs(x=>{const E=cd(r.current).includes(CSS.escape(x.animationName));if(x.target===t&&E&&(d("ANIMATION_END"),!i.current)){const _=t.style.animationFillMode;t.style.animationFillMode="forwards",f=h.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=_)})}},"handleAnimationEnd"),g=bs(x=>{x.target===t&&(a.current=cd(r.current))},"handleAnimationStart");return t.addEventListener("animationstart",g),t.addEventListener("animationcancel",m),t.addEventListener("animationend",m),()=>{h.clearTimeout(f),t.removeEventListener("animationstart",g),t.removeEventListener("animationcancel",m),t.removeEventListener("animationend",m)}}else d("ANIMATION_END")},[t,d]),{isPresent:["mounted","unmountSuspended"].includes(u),ref:w.useCallback(f=>{if(f){const h=getComputedStyle(f);r.current=h,o.current=cd(h)}else r.current=null;n(f)},[])}}bs(F5,"usePresence");function cS(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}bs(cS,"setRef");function H5(...e){const t=w.useRef(e);return t.current=e,w.useCallback(n=>{const r=t.current;let i=!1;const a=r.map(o=>{const l=cS(o,n);return!i&&typeof l=="function"&&(i=!0),l});if(i)return()=>{for(let o=0;o<a.length;o++){const l=a[o];typeof l=="function"?l():cS(r[o],null)}}},[])}bs(H5,"useStableComposedRefs");function cd(e){return(e==null?void 0:e.animationName)||"none"}bs(cd,"getAnimationName");function q5(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)}bs(q5,"getElementRef");var K5=globalThis!=null&&globalThis.document?w.useLayoutEffect:()=>{},Hce=Object.defineProperty,qce=(e,t)=>Hce(e,"name",{value:t,configurable:!0}),rD=Ao[" useEffectEvent ".trim().toString()],iD=Ao[" useInsertionEffect ".trim().toString()];function G5(e){if(typeof rD=="function")return rD(e);const t=w.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof iD=="function"?iD(()=>{t.current=e}):K5(()=>{t.current=e}),w.useMemo(()=>((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)}),[])}qce(G5,"useEffectEvent");var Kce=Object.defineProperty,_p=(e,t)=>Kce(e,"name",{value:t,configurable:!0}),Gce=Ao[" useInsertionEffect ".trim().toString()]||K5;function W5({prop:e,defaultProp:t,onChange:n=_p(()=>{},"onChange"),caller:r}){const[i,a,o]=V5({defaultProp:t,onChange:n}),l=e!==void 0,u=l?e:i,d=w.useCallback(f=>{var h;if(l){const m=Y5(f)?f(e):f;m!==e&&((h=o.current)==null||h.call(o,m))}else a(f)},[l,e,a,o]);return[u,d]}_p(W5,"useControllableState");function V5({defaultProp:e,onChange:t}){const[n,r]=w.useState(e),i=w.useRef(n),a=w.useRef(t);return Gce(()=>{a.current=t},[t]),w.useEffect(()=>{var o;i.current!==n&&((o=a.current)==null||o.call(a,n),i.current=n)},[n,i]),[n,r,a]}_p(V5,"useUncontrolledState");function Y5(e){return typeof e=="function"}_p(Y5,"isFunction");var aD=Symbol("RADIX:SYNC_STATE");function Wce(e,t,n,r){const{prop:i,defaultProp:a,onChange:o,caller:l}=t,u=i!==void 0,d=G5(o),f=[{...n,state:a}];r&&f.push(r);const[h,m]=w.useReducer((E,_)=>{if(_.type===aD)return{...E,state:_.state};const A=e(E,_);return u&&!Object.is(A.state,E.state)&&d(A.state),A},...f),g=h.state,x=w.useRef(g);w.useEffect(()=>{x.current!==g&&(x.current=g,u||d(g))},[g,x,u]);const y=w.useMemo(()=>i!==void 0?{...h,state:i}:h,[h,i]);return w.useEffect(()=>{u&&!Object.is(i,h.state)&&m({type:aD,state:i})},[i,h.state,u]),[y,m]}_p(Wce,"useControllableStateReducer");var Vce=Object.defineProperty,zl=(e,t)=>Vce(e,"name",{value:t,configurable:!0}),Tk="Popover",[X5,xPe]=WU(Tk,[L5]),Ok=L5(),[Yce,ef]=X5(Tk),Xce=zl(e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,l=Ok(t),u=w.useRef(null),[d,f]=w.useState(!1),[h,m]=W5({prop:r,defaultProp:i??!1,onChange:a,caller:Tk});return v.jsx(Pce,{...l,children:v.jsx(Yce,{scope:t,contentId:u5(),triggerRef:u,open:h,onOpenChange:m,onOpenToggle:w.useCallback(()=>m(g=>!g),[m]),hasCustomAnchor:d,onCustomAnchorAdd:w.useCallback(()=>f(!0),[]),onCustomAnchorRemove:w.useCallback(()=>f(!1),[]),modal:o,children:n})})},"Popover"),Zce="PopoverTrigger",Qce=w.forwardRef(zl(function(t,n){const{__scopePopover:r,...i}=t,a=ef(Zce,r),o=Ok(r),l=Zd(n,a.triggerRef),u=v.jsx(Yv.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":Ck(a.open),...i,ref:l,onClick:xl(t.onClick,a.onOpenToggle)});return a.hasCustomAnchor?u:v.jsx(Lce,{asChild:!0,...o,children:u})},"PopoverTrigger")),Z5="PopoverPortal",[Jce,eue]=X5(Z5,{forceMount:void 0}),tue=zl(e=>{const{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=ef(Z5,t);return v.jsx(Jce,{scope:t,forceMount:n,children:v.jsx(U5,{present:n||a.open,children:v.jsx(Uce,{asChild:!0,container:i,children:r})})})},"PopoverPortal"),Xh="PopoverContent",nue=w.forwardRef(zl(function(t,n){const r=eue(Xh,t.__scopePopover),{forceMount:i=r.forceMount,...a}=t,o=ef(Xh,t.__scopePopover);return v.jsx(U5,{present:i||o.open,children:o.modal?v.jsx(iue,{...a,ref:n}):v.jsx(aue,{...a,ref:n})})},"PopoverContent")),rue=gk("PopoverContent.RemoveScroll"),iue=w.forwardRef(zl(function(t,n){const r=ef(Xh,t.__scopePopover),i=w.useRef(null),a=Zd(n,i),o=w.useRef(!1);return w.useEffect(()=>{const l=i.current;if(l)return TU(l)},[]),v.jsx(ck,{as:rue,allowPinchZoom:!0,children:v.jsx(Q5,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:xl(t.onCloseAutoFocus,l=>{var u;l.preventDefault(),o.current||(u=r.triggerRef.current)==null||u.focus()}),onPointerDownOutside:xl(t.onPointerDownOutside,l=>{const u=l.detail.originalEvent,d=u.button===0&&u.ctrlKey===!0,f=u.button===2||d;o.current=f},{checkForDefaultPrevented:!1}),onFocusOutside:xl(t.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1})})})},"PopoverContentModal")),aue=w.forwardRef(zl(function(t,n){const r=ef(Xh,t.__scopePopover),i=w.useRef(!1),a=w.useRef(!1);return v.jsx(Q5,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var l,u;(l=t.onCloseAutoFocus)==null||l.call(t,o),o.defaultPrevented||(i.current||(u=r.triggerRef.current)==null||u.focus(),o.preventDefault()),i.current=!1,a.current=!1},onInteractOutside:o=>{var d,f;(d=t.onInteractOutside)==null||d.call(t,o),o.defaultPrevented||(i.current=!0,o.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const l=o.target;((f=r.triggerRef.current)==null?void 0:f.contains(l))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&a.current&&o.preventDefault()}})},"PopoverContentNonModal")),Q5=w.forwardRef(zl(function(t,n){const{__scopePopover:r,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,...m}=t,g=ef(Xh,r),x=Ok(r);return yk(),v.jsx(Qse,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:a,onUnmountAutoFocus:o,children:v.jsx(qse,{asChild:!0,disableOutsidePointerEvents:l,onInteractOutside:h,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onDismiss:()=>g.onOpenChange(!1),deferPointerDownOutside:!0,children:v.jsx(jce,{"data-state":Ck(g.open),role:"dialog",id:g.contentId,...x,...m,ref:n,style:{...m.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 Ck(e){return e?"open":"closed"}zl(Ck,"getState");var oue=Xce,sue=Qce,lue=tue,J5=nue;const cue=oue,uue=sue,e4=w.forwardRef(({className:e,align:t="start",side:n="top",sideOffset:r=8,collisionPadding:i=8,...a},o)=>v.jsx(lue,{children:v.jsx(J5,{ref:o,align:t,side:n,sideOffset:r,collisionPadding:i,className:Ge("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})}));e4.displayName=J5.displayName;const t4=92,n4=96;function qw(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 oD=3e5;function due({socket:e,getToken:t}){const[n,r]=w.useState([]);if(w.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]),w.useEffect(()=>{if(!e)return;const a=e.on(o=>{o.type==="stats"&&r(l=>[...l,o.sample].slice(-120))});return()=>{a()}},[e]),!n.length)return null;const i=n[n.length-1];return v.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:[v.jsx(nb,{label:"cpu",value:i.cpu,series:n.map(a=>a.cpu)}),v.jsx(nb,{label:"mem",value:i.mem,series:n.map(a=>a.mem)}),i.disk>=0&&v.jsx(nb,{label:"disk",value:i.disk,severity:vue(i.disk),title:xue(i)}),v.jsx(fue,{getToken:t})]})}function fue({getToken:e}){const[t,n]=w.useState(null);return w.useEffect(()=>{let r=!0,i=0;const a=async()=>{var d;try{const f=await e();if(!f)return;i=Date.now();const h=await fetch("/api/claude-usage",{headers:{Authorization:`Bearer ${f}`}});if(!r)return;if(h.status===204){n(null);return}if(h.status!==200)return;const m=await h.json();if(!r||!((d=m==null?void 0:m.limits)!=null&&d.length))return;n(m)}catch(f){console.warn("[MachineStats] claude usage poll failed",f)}},o=()=>{document.visibilityState==="visible"&&a()},l=()=>{document.visibilityState==="visible"&&Date.now()-i>=oD&&a()};o();const u=setInterval(o,oD);return document.addEventListener("visibilitychange",l),()=>{r=!1,clearInterval(u),document.removeEventListener("visibilitychange",l)}},[e]),v.jsx(r4,{usage:t})}function r4({usage:e,compact:t}){const n=e&&i4(e.limits),[r,i]=w.useState(uS),a=w.useRef(null),o=()=>{a.current&&(clearTimeout(a.current),a.current=null)},l=w.useCallback((u,d=0)=>{if(o(),!d){i(f=>lD(f,u));return}a.current=setTimeout(()=>{a.current=null,i(f=>lD(f,u))},d)},[]);return w.useEffect(()=>o,[]),!e||!n?null:v.jsxs(cue,{open:r.open,onOpenChange:u=>l(u?{type:"activate"}:{type:"dismiss"}),children:[v.jsx(uue,{asChild:!0,children:v.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},hue),onPointerLeave:u=>l({type:"pointerleave",pointerType:u.pointerType},sD),children:t?v.jsxs("span",{className:Ge("tabular-nums",Db(n.percent,n.severity)),children:[n.percent,"% used"]}):v.jsx(nb,{label:"usage",value:n.percent,severity:n.severity})})}),v.jsx(e4,{onOpenAutoFocus:u=>u.preventDefault(),onPointerEnter:()=>o(),onPointerLeave:u=>l({type:"pointerleave",pointerType:u.pointerType},sD),children:v.jsx(pue,{usage:e})})]})}const hue=120,sD=80,uS={open:!1,byHover:!1};function lD(e,t){switch(t.type){case"pointerenter":return cD(t.pointerType)?{open:!0,byHover:!0}:e;case"pointerleave":return cD(t.pointerType)&&e.byHover?uS:e;case"activate":return{open:!0,byHover:!1};case"dismiss":return uS}}const cD=e=>e==="mouse"||e==="";function pue({usage:e}){const t=i4(e.limits);return v.jsxs("div",{className:"text-[11px] leading-tight",children:[v.jsxs("div",{className:"flex items-baseline justify-between gap-2 pb-2 text-muted-foreground",children:[v.jsx("span",{className:"uppercase tracking-wide",children:"claude usage"}),e.subscriptionType&&v.jsxs("span",{className:"tabular-nums",children:[e.subscriptionType," plan"]})]}),v.jsxs("div",{className:"-mt-1 flex items-baseline justify-between gap-2 pb-2 text-[10px] text-muted-foreground",children:[e.account&&v.jsx("span",{className:"truncate",title:e.account,children:e.account}),v.jsx("span",{className:Ge("shrink-0",e.stale&&"text-amber-500"),children:gue(e)})]}),e.stale&&e.error&&v.jsxs("div",{"data-refresh-error":!0,className:"-mt-1 pb-2 text-[10px] text-amber-500 break-words",children:[e.error,eb(e.retryAt??null)&&` · retrying in ${eb(e.retryAt??null)}`]}),v.jsx("div",{className:"flex flex-col gap-3",children:e.limits.map((n,r)=>{const i=eb(n.resetsAt),a=n===t;return v.jsxs("div",{"data-headline":a||void 0,className:Ge("flex flex-col gap-1",!a&&"opacity-60"),children:[v.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[v.jsxs("span",{className:Ge("truncate",a&&"font-medium"),children:[a&&v.jsx("span",{className:"mr-1 text-muted-foreground","aria-hidden":!0,children:"▸"}),mue(n)]}),v.jsxs("span",{className:Ge("tabular-nums shrink-0",Db(n.percent,n.severity)),children:[n.percent,"%"]})]}),v.jsx(a4,{value:n.percent,className:Ge("w-full",Db(n.percent,n.severity))}),v.jsx("span",{className:"text-[10px] text-muted-foreground",children:i?`resets in ${i}`:"no reset reported"})]},`${n.kind}-${r}`)})}),v.jsx("div",{className:"mt-3 border-t pt-2 text-[10px] text-muted-foreground",children:"▸ is the window the strip is showing"})]})}function mue(e){return e.scopeLabel?`${e.scopeLabel} window`:e.kind==="session"?"current session":e.kind==="weekly_all"?"all models":e.kind.replace(/_/g," ")}function i4(e){return e.reduce((t,n)=>!t||n.percent>t.percent?n:t,null)}function gue(e){const t=bue(e.fetchedAt);return t?e.stale?`${t} old — refresh failed`:`updated ${t} ago`:e.stale?"last reading — refresh failed":"updated just now"}function bue(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 vue(e){return e>=n4?"critical":e>=t4?"warning":"ok"}const yue={critical:"text-red-500",exceeded:"text-red-500",warning:"text-amber-500",warn:"text-amber-500",ok:"text-emerald-500"};function Db(e,t){const n=t?yue[t]:void 0;return n||(e>=90?"text-red-500":e>=75?"text-amber-500":"text-emerald-500")}function xue(e){const t=`warn at ${t4}%, critical at ${n4}%`;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 — ${qw(e.diskUsedBytes)} of ${qw(e.diskTotalBytes)}, ${qw(n)} free — ${t}`}function nb({label:e,value:t,series:n,title:r,severity:i}){const a=Db(t,i),o=r??(n?`${e} ${t}% — last ${n.length} samples`:void 0);return v.jsxs("span",{className:"flex items-center gap-1",title:o,children:[v.jsx("span",{className:"uppercase tracking-wide",children:e}),n?v.jsx(wue,{series:n,className:a}):v.jsx(a4,{value:t,className:a}),v.jsxs("span",{className:Ge("tabular-nums",a),children:[t,"%"]})]})}function a4({value:e,className:t}){const i=Math.max(0,Math.min(100,e))/100*40;return v.jsxs("svg",{width:40,height:12,viewBox:"0 0 40 12",className:Ge("overflow-visible",t),preserveAspectRatio:"none",children:[v.jsx("rect",{x:0,y:12/2-2,width:40,height:4,rx:2,fill:"currentColor",opacity:.2}),i>0&&v.jsx("rect",{x:0,y:12/2-2,width:i,height:4,rx:2,fill:"currentColor"})]})}function wue({series:e,className:t}){const i=e.length;if(i<2)return null;const a=e.map((o,l)=>{const u=i>1?l/(i-1)*40:0,d=12-Math.max(0,Math.min(100,o))/100*12;return`${u.toFixed(1)},${d.toFixed(1)}`}).join(" ");return v.jsx("svg",{width:40,height:12,viewBox:"0 0 40 12",className:Ge("overflow-visible",t),preserveAspectRatio:"none",children:v.jsx("polyline",{points:a,fill:"none",stroke:"currentColor",strokeWidth:1,strokeLinejoin:"round",strokeLinecap:"round"})})}const fh=50;function Eue({getToken:e,filter:t,refreshKey:n,hydrateIds:r}){const[i,a]=w.useState([]),[o,l]=w.useState(null),[u,d]=w.useState(!1),[f,h]=w.useState({}),m=w.useRef(new Set),g=w.useRef(null),x=w.useRef(null),y=w.useRef(t);y.current=t;const E=w.useRef(fh),_=w.useRef(t);_.current!==t&&(_.current=t,E.current=fh);const A=w.useCallback(async(R,M)=>{const P=await e();if(!P||M!=null&&M.aborted)return null;const D=await fetch(`/api/sessions?${new URLSearchParams(R)}`,{signal:M,headers:{Authorization:`Bearer ${P}`}});if(!D.ok)return null;const F=await D.json();return Array.isArray(F==null?void 0:F.sessions)?F:null},[e]),N=w.useCallback(async(R,M,P)=>{const D=[];let F,L=null;for(;D.length<R;){const G={filter:M,limit:String(Math.min(fh,R-D.length))};F&&(G.before=F);const W=await A(G,P);if(!W)return null;if(D.push(...W.sessions),L=W.nextCursor,!L||!W.sessions.length)break;F=L}return{sessions:D,nextCursor:L}},[A]);w.useEffect(()=>{var M,P;(M=g.current)==null||M.abort(),(P=x.current)==null||P.abort();const R=new AbortController;return g.current=R,d(!0),m.current.clear(),h({}),N(E.current,t,R.signal).then(D=>{!D||R.signal.aborted||(a(D.sessions),l(D.nextCursor))}).catch(()=>{}).finally(()=>{R.signal.aborted||d(!1)}),()=>R.abort()},[N,t,n]);const T=w.useCallback(()=>{var P;if(!o||u)return;(P=x.current)==null||P.abort();const R=new AbortController;x.current=R;const M=y.current;d(!0),A({filter:M,limit:String(fh),before:o},R.signal).then(D=>{!D||R.signal.aborted||M!==y.current||(a(F=>{const L=new Set(F.map(W=>W.sessionId)),G=[...F,...D.sessions.filter(W=>!L.has(W.sessionId))];return E.current=Math.max(fh,G.length),G}),l(D.nextCursor))}).catch(()=>{}).finally(()=>{R.signal.aborted||d(!1)})},[o,u,A]),O=w.useMemo(()=>{const R=new Map;for(const M of Object.values(f))R.set(M.sessionId,M);for(const M of i)R.set(M.sessionId,M);return R},[i,f]),C=r.join(",");return w.useEffect(()=>{const R=r.filter(P=>!!P&&!O.has(P)&&!m.current.has(P)).slice(0,200);if(!R.length)return;for(const P of R)m.current.add(P);let M=!1;return A({ids:R.join(",")}).then(P=>{!P||M||h(D=>{const F={...D};for(const L of P.sessions)F[L.sessionId]=L;return F})}).catch(()=>{}),()=>{M=!0}},[C,O,A]),{sessions:i,cursor:o,loading:u,byId:O,loadMore:T}}const hh="0.1.147";function _ue(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 ph="w-4 h-4 mt-0.5 shrink-0";function Sue(e){const t=e.slackContext;return(t==null?void 0:t.type)==="dm"?v.jsx($X,{className:`${ph} text-purple-400`}):(t==null?void 0:t.type)==="mention"?v.jsx(SX,{className:`${ph} text-blue-400`}):(t==null?void 0:t.type)==="channel"?v.jsx(MX,{className:`${ph} text-green-400`}):e.sessionId.startsWith("slack-")?v.jsx(P_,{className:`${ph} text-yellow-400`}):v.jsx(P_,{className:`${ph} text-muted-foreground`})}function kue(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 Aue(e,t,n){return Object.keys(e).map(r=>t.get(r)).filter(r=>!!r&&(n==="all"||r.mine!==!1))}const uD="chats-filter",dD="chats-unread-filter";function Nue({getToken:e,activeSessionId:t,onSelect:n,onNew:r,refreshKey:i,workspaceRefreshKey:a,onRefreshWorkspace:o,unreads:l={},busySessions:u=new Set,socket:d}){var H;const f=To(),[h,m]=w.useState(()=>localStorage.getItem(uD)||"mine"),[g,x]=w.useState(()=>localStorage.getItem(dD)==="true"),[y,E]=w.useState(""),_=w.useRef(null);function A(V){m(V),localStorage.setItem(uD,V)}function N(){const V=!g;x(V),localStorage.setItem(dD,String(V))}const T=w.useMemo(()=>[t,...Object.keys(l)].filter(V=>!!V),[t,l]),{sessions:O,cursor:C,loading:R,byId:M,loadMore:P}=Eue({getToken:e,filter:h,refreshKey:i,hydrateIds:T}),D=w.useMemo(()=>Aue(l,M,h),[l,M,h]),F=D.length,L=w.useMemo(()=>g?[...D].sort((V,z)=>z.lastModified-V.lastModified):O,[g,D,O]),G=t&&!L.some(V=>V.sessionId===t)?M.get(t):void 0;w.useEffect(()=>{_.current&&_.current.scrollIntoView({block:"nearest"})},[t,L,G]);const W=w.useRef(null),X=w.useRef(P);X.current=P,w.useEffect(()=>{const V=W.current;if(!V||!C||g)return;const z=new IntersectionObserver(j=>{j.some(Z=>Z.isIntersecting)&&X.current()},{rootMargin:"300px"});return z.observe(V),()=>z.disconnect()},[C,R,g]),w.useEffect(()=>{e().then(V=>V?fetch("/api/version",{headers:{Authorization:`Bearer ${V}`}}):null).then(V=>V==null?void 0:V.json()).then(V=>V&&E(V.version)).catch(()=>{})},[]);const B=!!y&&y!=="unknown"&&hh!=="dev"&&y!==hh;w.useEffect(()=>{B&&console.warn(`[shraga] stale client bundle: built from v${hh}, server runs v${y} — rebuild dist/client`)},[B,y]);function q(V){const z=l[V.sessionId],j=u.has(V.sessionId)||V.runStatus==="running"||V.scheduleRunStatus==="running",Z=!j&&(!!V.lastStopReason||V.scheduleRunStatus==="error"||V.scheduleRunStatus==="aborted"),$=j?"border-amber-500":Z?"border-red-500":z?"border-blue-500":"",ne=!!(j||Z||z);return v.jsx("button",{ref:V.sessionId===t?_:void 0,onClick:()=>n(V.sessionId,V.title),className:Ge("w-full text-left px-3 py-2.5 text-sm transition-colors hover:bg-accent/50 group",ne?`rounded-r-lg border-l-[3px] ${$}`:"rounded-lg",t===V.sessionId&&"bg-accent"),children:v.jsxs("div",{className:"flex items-start gap-2",children:[Sue(V),v.jsxs("div",{className:"min-w-0 flex-1",children:[v.jsx("span",{className:Ge("block truncate text-sm leading-snug",z&&"font-semibold"),children:V.title||"New session"}),v.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[v.jsx("span",{className:"text-[10px] text-muted-foreground font-medium",children:kue(V)||V.userName}),v.jsx("span",{className:"text-[10px] text-muted-foreground/50",children:"·"}),v.jsx("span",{className:"text-[10px] text-muted-foreground",children:_ue(V.lastModified)})]})]})]})},V.sessionId)}return v.jsxs("div",{className:"flex flex-col h-full bg-muted/30",children:[v.jsx("div",{className:"p-3",children:v.jsxs(Ie,{variant:"outline",size:"sm",className:"w-full gap-2 justify-start",onClick:r,title:"New Chat (Ctrl+N)",children:[v.jsx(hs,{className:"w-4 h-4"})," New Chat",v.jsx("span",{className:"ml-auto flex items-center gap-0.5 text-[10px] text-muted-foreground/50 font-mono",children:"⌃N"})]})}),v.jsx("div",{className:"border-b shrink-0 flex flex-col max-h-[40vh]",children:v.jsx(wse,{getToken:e,onRefresh:o,refreshKey:a})}),v.jsxs("div",{className:"flex items-center justify-between px-3 pt-2 pb-1",children:[v.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Chats"}),v.jsxs("div",{className:"flex gap-0.5",children:[["mine","all"].map(V=>v.jsx("button",{onClick:()=>A(V),className:Ge("text-[10px] px-1.5 rounded-full transition-colors capitalize leading-none",h===V?"text-foreground font-medium":"text-muted-foreground/60 hover:text-muted-foreground"),children:V},V)),v.jsxs("button",{onClick:N,className:Ge("text-[10px] px-1.5 rounded-full transition-colors leading-none",g?"text-blue-600 dark:text-blue-400 font-medium":"text-muted-foreground/60 hover:text-muted-foreground"),children:["unread",F>0&&v.jsx("span",{className:"inline-block w-1.5 h-1.5 ml-1 rounded-full bg-blue-500 align-middle"})]})]})]}),v.jsx(U3,{className:"flex-1",children:v.jsxs("div",{className:"px-2 pb-2 space-y-0.5",children:[L.length===0&&!G&&v.jsx("p",{className:"text-xs text-muted-foreground px-3 py-6 text-center",children:R?"Loading…":g?"No unread conversations":"No conversations yet"}),G&&q(G),L.map(q),!g&&C&&v.jsx("div",{ref:W,className:"py-3 text-center text-[11px] text-muted-foreground/60",children:R?"Loading older…":"···"})]})}),v.jsxs("div",{className:"px-4 py-2 flex flex-col items-center gap-1",children:[v.jsx(due,{socket:d??null,getToken:e}),(H=f.sidebarExtras)==null?void 0:H.call(f),y&&(B?v.jsxs("button",{onClick:()=>location.reload(),title:`This page was built from v${hh}, the server runs v${y} — reload to update`,className:"text-[10px] text-amber-400 hover:text-amber-300 text-center underline decoration-dotted",children:["⚠️ stale page (v",hh," → v",y,") · reload"]}):v.jsxs("div",{className:"text-[10px] text-muted-foreground/50 text-center",children:["v",y]}))]})]})}function $i(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:gl(),role:"assistant",blocks:[t]}]}function fD(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:gl(),role:"assistant",blocks:[i]}]}function o4(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 o=[...i.blocks];return o[a]={...o[a],input:n},[...e.slice(0,r),{...i,blocks:o},...e.slice(r+1)]}return e}function Tue(e,t){const[n,r]=w.useState([]),[i,a]=w.useState(!1),[o,l]=w.useState([]),u=w.useRef(t.initialSessionId),d=w.useRef(!1),f=w.useRef(o);f.current=o;const h=w.useRef(t.getToken);h.current=t.getToken;const m=w.useRef(t.onNewSession);m.current=t.onNewSession;const g=w.useRef(t.onDirectivesChanged);g.current=t.onDirectivesChanged;const x=w.useRef(t.onParticipantsChanged);x.current=t.onParticipantsChanged;const y=w.useRef(t.onEvent);y.current=t.onEvent;const E=w.useRef(e);E.current=e;const _=w.useCallback(L=>L!=null&&L===u.current,[]),A=w.useCallback(async()=>{var G;const L=u.current;if(L)try{const X=await(await kc(`/api/sessions/${L}/messages`,h.current)).json();r(g3(X)),a(!!X.busy),(G=x.current)==null||G.call(x,Array.isArray(X.participants)&&X.participants.length>1)}catch{}},[]);w.useEffect(()=>{if(!e)return;const L=e.on(G=>{var X,B,q,H,V,z;(X=y.current)==null||X.call(y,G);const W=G;if(W.type==="compact_marker")return _(W.sessionId)?r(j=>[...j,{id:gl(),role:"assistant",blocks:[{type:"compact_marker",summary:W.summary??"",compactedCount:W.compactedCount??0}]}]):void 0;switch(G.type){case"thinking_delta":return _(G.sessionId)?r(j=>$i(j,{type:"thinking",text:G.text})):void 0;case"text_delta":return _(G.sessionId)?r(j=>$i(j,{type:"text",text:G.text})):void 0;case"tool_use":return _(G.sessionId)?r(j=>$i(j,{type:"tool_use",tool:G.tool,toolUseId:G.toolUseId,input:G.input})):void 0;case"tool_use_input":return _(G.sessionId)?r(j=>o4(j,G.toolUseId,G.input)):void 0;case"tool_result":return _(G.sessionId)?r(j=>$i(j,{type:"tool_result",toolUseId:G.toolUseId,output:G.output})):void 0;case"tool_result_image":return _(G.sessionId)?r(j=>$i(j,{type:"image",src:G.dataUrl})):void 0;case"permission_request":return _(G.sessionId)?r(j=>$i(j,{type:"permission_request",id:G.id,tool:G.tool,input:G.input})):void 0;case"question_request":return _(G.sessionId)?r(j=>$i(j,{type:"question_request",id:G.id,questions:G.questions})):void 0;case"directives":return d.current?(B=g.current)==null?void 0:B.call(g,G.directives):void 0;case"session_id":return!d.current||u.current?void 0:(u.current=G.sessionId,(q=m.current)==null?void 0:q.call(m,G.sessionId));case"forked":return G.sourceSessionId!==u.current?void 0:(u.current=G.sessionId,(H=m.current)==null?void 0:H.call(m,G.sessionId));case"session_busy":G.sessionId===u.current&&a(G.busy);return;case"session_stream":return G.sessionId!==u.current?void 0:Oue(r,G.event);case"session_messages_changed":G.sessionId===u.current&&A();return;case"done":{if(G.sessionId!==u.current)return;G.stopReason==="max_turns_reached"&&r(Z=>$i(Z,{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.`})),(V=m.current)==null||V.call(m,G.sessionId);const j=f.current;if(j.length>0){const Z=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-C50rEoAa.js"></script>
|
|
17
17
|
<link rel="stylesheet" crossorigin href="/assets/index-DzxOqQtK.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.147",
|
|
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",
|
|
@@ -202,7 +202,7 @@ function pidAgeSeconds(pid: number): number | null {
|
|
|
202
202
|
const SECRET_ENV_RE = /(API_KEY|_TOKEN|_SECRET|_PASSWORD|_PRIVATE_KEY|^AWS_|^GITHUB_TOKEN$|^OPENAI_|^ANTHROPIC_|^GOOGLE_|^GEMINI_|^GROQ_|^NPM_TOKEN$|^SLACK_)/i;
|
|
203
203
|
function childEnv(): Record<string, string | undefined> {
|
|
204
204
|
const out: Record<string, string | undefined> = {};
|
|
205
|
-
for (const [k, v] of Object.entries(process.env)) if (!SECRET_ENV_RE.test(k)) out[k] = v;
|
|
205
|
+
for (const [k, v] of Object.entries(process.env)) if (!SECRET_ENV_RE.test(k) && k !== 'PORT') out[k] = v; // PORT = the server's own port; a job honouring it would shadow us
|
|
206
206
|
return out;
|
|
207
207
|
}
|
|
208
208
|
|
package/src/server/data-sync.ts
CHANGED
|
@@ -19,6 +19,9 @@ const CONFLICT_MARKER = /^(<{7}|>{7}) /m;
|
|
|
19
19
|
const COMMIT_MSG_TIMEOUT_MS = 60_000;
|
|
20
20
|
/** Warn if the push latch has been held longer than this — the 2026-08 outage's signature was silence. */
|
|
21
21
|
const PUSHING_STUCK_MS = 5 * 60_000;
|
|
22
|
+
/** Largest file sync will commit. GitHub rejects >100MB, and packing multi-GB blobs OOM-killed the
|
|
23
|
+
* Circles box in a restart loop (2026-09-27: 8GB of raw Mixpanel exports auto-committed from workspace/). */
|
|
24
|
+
const MAX_FILE_BYTES = 50 * 1024 * 1024;
|
|
22
25
|
|
|
23
26
|
/**
|
|
24
27
|
* Reject after `ms` so a hung subprocess can't hold the push latch forever.
|
|
@@ -183,7 +186,7 @@ export class DataSync {
|
|
|
183
186
|
await this.git('add', '-A');
|
|
184
187
|
const status = await this.git('status', '--porcelain');
|
|
185
188
|
if (status.trim()) {
|
|
186
|
-
if (await this.guardMassDeletions('init merge')) {
|
|
189
|
+
if (await this.guardMassDeletions('init merge') || await this.guardOversized()) {
|
|
187
190
|
console.error(`${TAG} Init merge aborted — mass deletion blocked`);
|
|
188
191
|
} else {
|
|
189
192
|
await this.git('commit', '-m', 'data-sync: merge local state');
|
|
@@ -559,6 +562,7 @@ export class DataSync {
|
|
|
559
562
|
|
|
560
563
|
if (await this.guardMassDeletions('flush')) return;
|
|
561
564
|
if (await this.guardConflictMarkers()) return;
|
|
565
|
+
if (await this.guardOversized()) return;
|
|
562
566
|
const msg = await this.generateCommitMessage(files);
|
|
563
567
|
await this.git('commit', '-m', auditHead ? `${msg}\n\naudit-head: ${auditHead}` : msg).catch(err =>
|
|
564
568
|
console.error(`${TAG} Commit failed — nothing from this flush is synced:`, (err as Error).message));
|
|
@@ -879,6 +883,19 @@ export class DataSync {
|
|
|
879
883
|
/** Never commit a conflict marker: unstage marked files (they stay on disk for repair) and alert.
|
|
880
884
|
* An unmerged index blocks the whole commit, so that case is reported rather than committed around.
|
|
881
885
|
* Returns true when nothing is left to commit. */
|
|
886
|
+
/** Unstage files over MAX_FILE_BYTES (left on disk, unsynced). Returns true when nothing is left to commit. */
|
|
887
|
+
private async guardOversized(): Promise<boolean> {
|
|
888
|
+
const changed = (await this.git('diff', '--cached', '--name-only', '-z', '--diff-filter=AM').catch(() => '')).split('\0').filter(Boolean);
|
|
889
|
+
const big = changed.filter(f => { try { return statSync(path.join(DATA_DIR, f)).size > MAX_FILE_BYTES; } catch { return false; } });
|
|
890
|
+
if (!big.length) { this.clearAlert('oversized'); return false; }
|
|
891
|
+
console.error(`${TAG} 🚫 Oversized file(s) staged — unstaged, not committed: ${big.join(', ')}`);
|
|
892
|
+
await this.git('reset', '-q', 'HEAD', '--', ...big).catch(e => console.error(`${TAG} Unstaging oversized files failed:`, (e as Error).message));
|
|
893
|
+
await this.alertOnce('oversized', big.join('\n'),
|
|
894
|
+
`🚫 Data sync refused file(s) over ${MAX_FILE_BYTES / 1024 / 1024}MB: ${big.join(', ')}. Left on disk unsynced — move them out of data/ or gitignore them.`,
|
|
895
|
+
).catch(e => console.warn(`${TAG} Oversized notify failed:`, (e as Error).message));
|
|
896
|
+
return !(await this.git('diff', '--cached', '--name-only').catch(() => '')).trim();
|
|
897
|
+
}
|
|
898
|
+
|
|
882
899
|
private async guardConflictMarkers(): Promise<boolean> {
|
|
883
900
|
const unmerged = await this.getConflictedFiles().catch(() => [] as string[]);
|
|
884
901
|
if (unmerged.length) {
|