@jean2/client 0.8.2 → 0.8.3

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.
Files changed (25) hide show
  1. package/dist/assets/SessionContent-DAoBLNGO.js +9 -0
  2. package/dist/assets/{SessionMenuButton-DsDEHbLS.js → SessionMenuButton-BRiMfAN5.js} +1 -1
  3. package/dist/assets/{_serverId-DGlEu8Js.js → _serverId-Bd-hxE5e.js} +2 -2
  4. package/dist/assets/{_serverId-C6rV90xS.js → _serverId-CsnPjy9K.js} +2 -2
  5. package/dist/assets/{_serverId-9odzanEM.js → _serverId-XYC72_6_.js} +1 -1
  6. package/dist/assets/_sessionId-C96NK5UN.js +1 -0
  7. package/dist/assets/_sessionId-DdW2fnoe.js +1 -0
  8. package/dist/assets/{alert-DI_4Lgs2.js → alert-DeW1kArF.js} +1 -1
  9. package/dist/assets/{badge-Dpu7ORAu.js → badge-DUoauaaV.js} +1 -1
  10. package/dist/assets/{confirmation-dialog-CdeOkc9q.js → confirmation-dialog-DeIbHoOu.js} +1 -1
  11. package/dist/assets/{dropdown-menu-BJDf5ta_.js → dropdown-menu-kSrbs3Xk.js} +1 -1
  12. package/dist/assets/{index-CgtwzRvf.js → index-0foRHKn1.js} +3 -3
  13. package/dist/assets/index-Bv9FJWM6.css +2 -0
  14. package/dist/assets/{overview-BhzPeIBE.js → overview-b6wqapV-.js} +1 -1
  15. package/dist/assets/{popover-BTq6RtKc.js → popover-DqniPNsl.js} +1 -1
  16. package/dist/assets/{scroll-area-CdXB1yRx.js → scroll-area-DVew28V6.js} +1 -1
  17. package/dist/assets/src-w2G0llvL.js +1 -0
  18. package/dist/assets/{workspace-6up_4yL-.js → workspace-BfFnK9TP.js} +1 -1
  19. package/dist/index.html +4 -4
  20. package/package.json +1 -1
  21. package/dist/assets/SessionContent-Jo9ZEids.js +0 -8
  22. package/dist/assets/_sessionId-64IyNquX.js +0 -1
  23. package/dist/assets/_sessionId-Dr4YSGzN.js +0 -1
  24. package/dist/assets/index-D36xySN9.css +0 -2
  25. package/dist/assets/src-BF-fktl3.js +0 -1
@@ -1 +1 @@
1
- import{i as e,t}from"./jsx-runtime-D-oznMWL.js";import{t as n}from"./react-DcCgrBX5.js";import{B as r,F as i,H as a,L as o,V as s,p as c,q as l,z as u}from"./badge-Dpu7ORAu.js";import{t as d}from"./createLucideIcon-BaO6wACO.js";import{A as f}from"./dropdown-menu-BJDf5ta_.js";var p=d(`star`,[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`,key:`r04s7s`}]]),m=e(n(),1);function h(e,[t,n]){return Math.min(n,Math.max(t,e))}var g=t();function _(e,t){return m.useReducer((e,n)=>{let r=t[e][n];return r==null?e:r},e)}var v=`ScrollArea`,[y,b]=s(v),[x,S]=y(v),C=m.forwardRef((e,t)=>{let{__scopeScrollArea:n,type:r=`hover`,dir:i,scrollHideDelay:o=600,...s}=e,[c,u]=m.useState(null),[d,p]=m.useState(null),[h,_]=m.useState(null),[v,y]=m.useState(null),[b,S]=m.useState(null),[C,w]=m.useState(0),[T,E]=m.useState(0),[D,O]=m.useState(!1),[k,A]=m.useState(!1),j=l(t,e=>u(e)),M=f(i);return(0,g.jsx)(x,{scope:n,type:r,dir:M,scrollHideDelay:o,scrollArea:c,viewport:d,onViewportChange:p,content:h,onContentChange:_,scrollbarX:v,onScrollbarXChange:y,scrollbarXEnabled:D,onScrollbarXEnabledChange:O,scrollbarY:b,onScrollbarYChange:S,scrollbarYEnabled:k,onScrollbarYEnabledChange:A,onCornerWidthChange:w,onCornerHeightChange:E,children:(0,g.jsx)(a.div,{dir:M,...s,ref:j,style:{position:`relative`,"--radix-scroll-area-corner-width":C+`px`,"--radix-scroll-area-corner-height":T+`px`,...e.style}})})});C.displayName=v;var w=`ScrollAreaViewport`,T=m.forwardRef((e,t)=>{let{__scopeScrollArea:n,children:r,nonce:i,...o}=e,s=S(w,n),c=l(t,m.useRef(null),s.onViewportChange);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}`},nonce:i}),(0,g.jsx)(a.div,{"data-radix-scroll-area-viewport":``,...o,ref:c,style:{overflowX:s.scrollbarXEnabled?`scroll`:`hidden`,overflowY:s.scrollbarYEnabled?`scroll`:`hidden`,...e.style},children:(0,g.jsx)(`div`,{ref:s.onContentChange,style:{minWidth:`100%`,display:`table`},children:r})})]})});T.displayName=w;var E=`ScrollAreaScrollbar`,D=m.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=S(E,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:o}=i,s=e.orientation===`horizontal`;return m.useEffect(()=>(s?a(!0):o(!0),()=>{s?a(!1):o(!1)}),[s,a,o]),i.type===`hover`?(0,g.jsx)(O,{...r,ref:t,forceMount:n}):i.type===`scroll`?(0,g.jsx)(k,{...r,ref:t,forceMount:n}):i.type===`auto`?(0,g.jsx)(A,{...r,ref:t,forceMount:n}):i.type===`always`?(0,g.jsx)(j,{...r,ref:t}):null});D.displayName=E;var O=m.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=S(E,e.__scopeScrollArea),[a,s]=m.useState(!1);return m.useEffect(()=>{let e=i.scrollArea,t=0;if(e){let n=()=>{window.clearTimeout(t),s(!0)},r=()=>{t=window.setTimeout(()=>s(!1),i.scrollHideDelay)};return e.addEventListener(`pointerenter`,n),e.addEventListener(`pointerleave`,r),()=>{window.clearTimeout(t),e.removeEventListener(`pointerenter`,n),e.removeEventListener(`pointerleave`,r)}}},[i.scrollArea,i.scrollHideDelay]),(0,g.jsx)(o,{present:n||a,children:(0,g.jsx)(A,{"data-state":a?`visible`:`hidden`,...r,ref:t})})}),k=m.forwardRef((e,t)=>{let{forceMount:n,...i}=e,a=S(E,e.__scopeScrollArea),s=e.orientation===`horizontal`,c=Z(()=>u(`SCROLL_END`),100),[l,u]=_(`hidden`,{hidden:{SCROLL:`scrolling`},scrolling:{SCROLL_END:`idle`,POINTER_ENTER:`interacting`},interacting:{SCROLL:`interacting`,POINTER_LEAVE:`idle`},idle:{HIDE:`hidden`,SCROLL:`scrolling`,POINTER_ENTER:`interacting`}});return m.useEffect(()=>{if(l===`idle`){let e=window.setTimeout(()=>u(`HIDE`),a.scrollHideDelay);return()=>window.clearTimeout(e)}},[l,a.scrollHideDelay,u]),m.useEffect(()=>{let e=a.viewport,t=s?`scrollLeft`:`scrollTop`;if(e){let n=e[t],r=()=>{let r=e[t];n!==r&&(u(`SCROLL`),c()),n=r};return e.addEventListener(`scroll`,r),()=>e.removeEventListener(`scroll`,r)}},[a.viewport,s,u,c]),(0,g.jsx)(o,{present:n||l!==`hidden`,children:(0,g.jsx)(j,{"data-state":l===`hidden`?`hidden`:`visible`,...i,ref:t,onPointerEnter:r(e.onPointerEnter,()=>u(`POINTER_ENTER`)),onPointerLeave:r(e.onPointerLeave,()=>u(`POINTER_LEAVE`))})})}),A=m.forwardRef((e,t)=>{let n=S(E,e.__scopeScrollArea),{forceMount:r,...i}=e,[a,s]=m.useState(!1),c=e.orientation===`horizontal`,l=Z(()=>{if(n.viewport){let e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;s(c?e:t)}},10);return Q(n.viewport,l),Q(n.content,l),(0,g.jsx)(o,{present:r||a,children:(0,g.jsx)(j,{"data-state":a?`visible`:`hidden`,...i,ref:t})})}),j=m.forwardRef((e,t)=>{let{orientation:n=`vertical`,...r}=e,i=S(E,e.__scopeScrollArea),a=m.useRef(null),o=m.useRef(0),[s,c]=m.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),l=W(s.viewport,s.content),u={...r,sizes:s,onSizesChange:c,hasThumb:l>0&&l<1,onThumbChange:e=>a.current=e,onThumbPointerUp:()=>o.current=0,onThumbPointerDown:e=>o.current=e};function d(e,t){return K(e,o.current,s,t)}return n===`horizontal`?(0,g.jsx)(M,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollLeft,t=q(e,s,i.dir);a.current.style.transform=`translate3d(${t}px, 0, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollLeft=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollLeft=d(e,i.dir))}}):n===`vertical`?(0,g.jsx)(N,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollTop,t=q(e,s);a.current.style.transform=`translate3d(0, ${t}px, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollTop=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollTop=d(e))}}):null}),M=m.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=S(E,e.__scopeScrollArea),[o,s]=m.useState(),c=m.useRef(null),u=l(t,c,a.onScrollbarXChange);return m.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,g.jsx)(I,{"data-orientation":`horizontal`,...i,ref:u,sizes:n,style:{bottom:0,left:a.dir===`rtl`?`var(--radix-scroll-area-corner-width)`:0,right:a.dir===`ltr`?`var(--radix-scroll-area-corner-width)`:0,"--radix-scroll-area-thumb-width":G(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollLeft+t.deltaX;e.onWheelScroll(r),Y(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:U(o.paddingLeft),paddingEnd:U(o.paddingRight)}})}})}),N=m.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=S(E,e.__scopeScrollArea),[o,s]=m.useState(),c=m.useRef(null),u=l(t,c,a.onScrollbarYChange);return m.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,g.jsx)(I,{"data-orientation":`vertical`,...i,ref:u,sizes:n,style:{top:0,right:a.dir===`ltr`?0:void 0,left:a.dir===`rtl`?0:void 0,bottom:`var(--radix-scroll-area-corner-height)`,"--radix-scroll-area-thumb-height":G(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollTop+t.deltaY;e.onWheelScroll(r),Y(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:U(o.paddingTop),paddingEnd:U(o.paddingBottom)}})}})}),[P,F]=y(E),I=m.forwardRef((e,t)=>{let{__scopeScrollArea:n,sizes:o,hasThumb:s,onThumbChange:c,onThumbPointerUp:u,onThumbPointerDown:d,onThumbPositionChange:f,onDragScroll:p,onWheelScroll:h,onResize:_,...v}=e,y=S(E,n),[b,x]=m.useState(null),C=l(t,e=>x(e)),w=m.useRef(null),T=m.useRef(``),D=y.viewport,O=o.content-o.viewport,k=i(h),A=i(f),j=Z(_,10);function M(e){w.current&&p({x:e.clientX-w.current.left,y:e.clientY-w.current.top})}return m.useEffect(()=>{let e=e=>{let t=e.target;b!=null&&b.contains(t)&&k(e,O)};return document.addEventListener(`wheel`,e,{passive:!1}),()=>document.removeEventListener(`wheel`,e,{passive:!1})},[D,b,O,k]),m.useEffect(A,[o,A]),Q(b,j),Q(y.content,j),(0,g.jsx)(P,{scope:n,scrollbar:b,hasThumb:s,onThumbChange:i(c),onThumbPointerUp:i(u),onThumbPositionChange:A,onThumbPointerDown:i(d),children:(0,g.jsx)(a.div,{...v,ref:C,style:{position:`absolute`,...v.style},onPointerDown:r(e.onPointerDown,e=>{e.button===0&&(e.target.setPointerCapture(e.pointerId),w.current=b.getBoundingClientRect(),T.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect=`none`,y.viewport&&(y.viewport.style.scrollBehavior=`auto`),M(e))}),onPointerMove:r(e.onPointerMove,M),onPointerUp:r(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=T.current,y.viewport&&(y.viewport.style.scrollBehavior=``),w.current=null})})})}),L=`ScrollAreaThumb`,R=m.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=F(L,e.__scopeScrollArea);return(0,g.jsx)(o,{present:n||i.hasThumb,children:(0,g.jsx)(z,{ref:t,...r})})}),z=m.forwardRef((e,t)=>{let{__scopeScrollArea:n,style:i,...o}=e,s=S(L,n),c=F(L,n),{onThumbPositionChange:u}=c,d=l(t,e=>c.onThumbChange(e)),f=m.useRef(void 0),p=Z(()=>{f.current&&(f.current(),f.current=void 0)},100);return m.useEffect(()=>{let e=s.viewport;if(e){let t=()=>{p(),f.current||(f.current=X(e,u),u())};return u(),e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)}},[s.viewport,p,u]),(0,g.jsx)(a.div,{"data-state":c.hasThumb?`visible`:`hidden`,...o,ref:d,style:{width:`var(--radix-scroll-area-thumb-width)`,height:`var(--radix-scroll-area-thumb-height)`,...i},onPointerDownCapture:r(e.onPointerDownCapture,e=>{let t=e.target.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;c.onThumbPointerDown({x:n,y:r})}),onPointerUp:r(e.onPointerUp,c.onThumbPointerUp)})});R.displayName=L;var B=`ScrollAreaCorner`,V=m.forwardRef((e,t)=>{let n=S(B,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!==`scroll`&&r?(0,g.jsx)(H,{...e,ref:t}):null});V.displayName=B;var H=m.forwardRef((e,t)=>{let{__scopeScrollArea:n,...r}=e,i=S(B,n),[o,s]=m.useState(0),[c,l]=m.useState(0),u=!!(o&&c);return Q(i.scrollbarX,()=>{var e;let t=((e=i.scrollbarX)==null?void 0:e.offsetHeight)||0;i.onCornerHeightChange(t),l(t)}),Q(i.scrollbarY,()=>{var e;let t=((e=i.scrollbarY)==null?void 0:e.offsetWidth)||0;i.onCornerWidthChange(t),s(t)}),u?(0,g.jsx)(a.div,{...r,ref:t,style:{width:o,height:c,position:`absolute`,right:i.dir===`ltr`?0:void 0,left:i.dir===`rtl`?0:void 0,bottom:0,...e.style}}):null});function U(e){return e?parseInt(e,10):0}function W(e,t){let n=e/t;return isNaN(n)?0:n}function G(e){let t=W(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function K(e,t,n,r=`ltr`){let i=G(n),a=i/2,o=t||a,s=i-o,c=n.scrollbar.paddingStart+o,l=n.scrollbar.size-n.scrollbar.paddingEnd-s,u=n.content-n.viewport,d=r===`ltr`?[0,u]:[u*-1,0];return J([c,l],d)(e)}function q(e,t,n=`ltr`){let r=G(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-i,o=t.content-t.viewport,s=a-r,c=h(e,n===`ltr`?[0,o]:[o*-1,0]);return J([0,o],[0,s])(c)}function J(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function Y(e,t){return e>0&&e<t}var X=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return(function i(){let a={left:e.scrollLeft,top:e.scrollTop},o=n.left!==a.left,s=n.top!==a.top;(o||s)&&t(),n=a,r=window.requestAnimationFrame(i)})(),()=>window.cancelAnimationFrame(r)};function Z(e,t){let n=i(e),r=m.useRef(0);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),m.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Q(e,t){let n=i(t);u(()=>{let t=0;if(e){let r=new ResizeObserver(()=>{cancelAnimationFrame(t),t=window.requestAnimationFrame(n)});return r.observe(e),()=>{window.cancelAnimationFrame(t),r.unobserve(e)}}},[e,n])}var ee=C,te=T,ne=V,$=m.forwardRef(({className:e,children:t,...n},r)=>(0,g.jsxs)(ee,{"data-slot":`scroll-area`,className:c(`relative overflow-hidden`,e),...n,children:[(0,g.jsx)(te,{ref:r,"data-slot":`scroll-area-viewport`,className:`size-full min-w-0 rounded-[inherit] outline-none`,style:{WebkitOverflowScrolling:`touch`},children:t}),(0,g.jsx)(re,{}),(0,g.jsx)(ne,{})]}));$.displayName=`ScrollArea`;function re({className:e,orientation:t=`vertical`,...n}){return(0,g.jsx)(D,{"data-slot":`scroll-area-scrollbar`,"data-orientation":t,orientation:t,className:c(`flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent`,e),...n,children:(0,g.jsx)(R,{"data-slot":`scroll-area-thumb`,className:`relative flex-1 rounded-full bg-border`})})}export{p as n,$ as t};
1
+ import{i as e,t}from"./jsx-runtime-D-oznMWL.js";import{t as n}from"./react-DcCgrBX5.js";import{B as r,F as i,H as a,L as o,V as s,p as c,q as l,z as u}from"./badge-DUoauaaV.js";import{t as d}from"./createLucideIcon-BaO6wACO.js";import{A as f}from"./dropdown-menu-kSrbs3Xk.js";var p=d(`star`,[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`,key:`r04s7s`}]]),m=e(n(),1);function h(e,[t,n]){return Math.min(n,Math.max(t,e))}var g=t();function _(e,t){return m.useReducer((e,n)=>{let r=t[e][n];return r==null?e:r},e)}var v=`ScrollArea`,[y,b]=s(v),[x,S]=y(v),C=m.forwardRef((e,t)=>{let{__scopeScrollArea:n,type:r=`hover`,dir:i,scrollHideDelay:o=600,...s}=e,[c,u]=m.useState(null),[d,p]=m.useState(null),[h,_]=m.useState(null),[v,y]=m.useState(null),[b,S]=m.useState(null),[C,w]=m.useState(0),[T,E]=m.useState(0),[D,O]=m.useState(!1),[k,A]=m.useState(!1),j=l(t,e=>u(e)),M=f(i);return(0,g.jsx)(x,{scope:n,type:r,dir:M,scrollHideDelay:o,scrollArea:c,viewport:d,onViewportChange:p,content:h,onContentChange:_,scrollbarX:v,onScrollbarXChange:y,scrollbarXEnabled:D,onScrollbarXEnabledChange:O,scrollbarY:b,onScrollbarYChange:S,scrollbarYEnabled:k,onScrollbarYEnabledChange:A,onCornerWidthChange:w,onCornerHeightChange:E,children:(0,g.jsx)(a.div,{dir:M,...s,ref:j,style:{position:`relative`,"--radix-scroll-area-corner-width":C+`px`,"--radix-scroll-area-corner-height":T+`px`,...e.style}})})});C.displayName=v;var w=`ScrollAreaViewport`,T=m.forwardRef((e,t)=>{let{__scopeScrollArea:n,children:r,nonce:i,...o}=e,s=S(w,n),c=l(t,m.useRef(null),s.onViewportChange);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}`},nonce:i}),(0,g.jsx)(a.div,{"data-radix-scroll-area-viewport":``,...o,ref:c,style:{overflowX:s.scrollbarXEnabled?`scroll`:`hidden`,overflowY:s.scrollbarYEnabled?`scroll`:`hidden`,...e.style},children:(0,g.jsx)(`div`,{ref:s.onContentChange,style:{minWidth:`100%`,display:`table`},children:r})})]})});T.displayName=w;var E=`ScrollAreaScrollbar`,D=m.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=S(E,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:o}=i,s=e.orientation===`horizontal`;return m.useEffect(()=>(s?a(!0):o(!0),()=>{s?a(!1):o(!1)}),[s,a,o]),i.type===`hover`?(0,g.jsx)(O,{...r,ref:t,forceMount:n}):i.type===`scroll`?(0,g.jsx)(k,{...r,ref:t,forceMount:n}):i.type===`auto`?(0,g.jsx)(A,{...r,ref:t,forceMount:n}):i.type===`always`?(0,g.jsx)(j,{...r,ref:t}):null});D.displayName=E;var O=m.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=S(E,e.__scopeScrollArea),[a,s]=m.useState(!1);return m.useEffect(()=>{let e=i.scrollArea,t=0;if(e){let n=()=>{window.clearTimeout(t),s(!0)},r=()=>{t=window.setTimeout(()=>s(!1),i.scrollHideDelay)};return e.addEventListener(`pointerenter`,n),e.addEventListener(`pointerleave`,r),()=>{window.clearTimeout(t),e.removeEventListener(`pointerenter`,n),e.removeEventListener(`pointerleave`,r)}}},[i.scrollArea,i.scrollHideDelay]),(0,g.jsx)(o,{present:n||a,children:(0,g.jsx)(A,{"data-state":a?`visible`:`hidden`,...r,ref:t})})}),k=m.forwardRef((e,t)=>{let{forceMount:n,...i}=e,a=S(E,e.__scopeScrollArea),s=e.orientation===`horizontal`,c=Z(()=>u(`SCROLL_END`),100),[l,u]=_(`hidden`,{hidden:{SCROLL:`scrolling`},scrolling:{SCROLL_END:`idle`,POINTER_ENTER:`interacting`},interacting:{SCROLL:`interacting`,POINTER_LEAVE:`idle`},idle:{HIDE:`hidden`,SCROLL:`scrolling`,POINTER_ENTER:`interacting`}});return m.useEffect(()=>{if(l===`idle`){let e=window.setTimeout(()=>u(`HIDE`),a.scrollHideDelay);return()=>window.clearTimeout(e)}},[l,a.scrollHideDelay,u]),m.useEffect(()=>{let e=a.viewport,t=s?`scrollLeft`:`scrollTop`;if(e){let n=e[t],r=()=>{let r=e[t];n!==r&&(u(`SCROLL`),c()),n=r};return e.addEventListener(`scroll`,r),()=>e.removeEventListener(`scroll`,r)}},[a.viewport,s,u,c]),(0,g.jsx)(o,{present:n||l!==`hidden`,children:(0,g.jsx)(j,{"data-state":l===`hidden`?`hidden`:`visible`,...i,ref:t,onPointerEnter:r(e.onPointerEnter,()=>u(`POINTER_ENTER`)),onPointerLeave:r(e.onPointerLeave,()=>u(`POINTER_LEAVE`))})})}),A=m.forwardRef((e,t)=>{let n=S(E,e.__scopeScrollArea),{forceMount:r,...i}=e,[a,s]=m.useState(!1),c=e.orientation===`horizontal`,l=Z(()=>{if(n.viewport){let e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;s(c?e:t)}},10);return Q(n.viewport,l),Q(n.content,l),(0,g.jsx)(o,{present:r||a,children:(0,g.jsx)(j,{"data-state":a?`visible`:`hidden`,...i,ref:t})})}),j=m.forwardRef((e,t)=>{let{orientation:n=`vertical`,...r}=e,i=S(E,e.__scopeScrollArea),a=m.useRef(null),o=m.useRef(0),[s,c]=m.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),l=W(s.viewport,s.content),u={...r,sizes:s,onSizesChange:c,hasThumb:l>0&&l<1,onThumbChange:e=>a.current=e,onThumbPointerUp:()=>o.current=0,onThumbPointerDown:e=>o.current=e};function d(e,t){return K(e,o.current,s,t)}return n===`horizontal`?(0,g.jsx)(M,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollLeft,t=q(e,s,i.dir);a.current.style.transform=`translate3d(${t}px, 0, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollLeft=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollLeft=d(e,i.dir))}}):n===`vertical`?(0,g.jsx)(N,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollTop,t=q(e,s);a.current.style.transform=`translate3d(0, ${t}px, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollTop=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollTop=d(e))}}):null}),M=m.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=S(E,e.__scopeScrollArea),[o,s]=m.useState(),c=m.useRef(null),u=l(t,c,a.onScrollbarXChange);return m.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,g.jsx)(I,{"data-orientation":`horizontal`,...i,ref:u,sizes:n,style:{bottom:0,left:a.dir===`rtl`?`var(--radix-scroll-area-corner-width)`:0,right:a.dir===`ltr`?`var(--radix-scroll-area-corner-width)`:0,"--radix-scroll-area-thumb-width":G(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollLeft+t.deltaX;e.onWheelScroll(r),Y(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:U(o.paddingLeft),paddingEnd:U(o.paddingRight)}})}})}),N=m.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=S(E,e.__scopeScrollArea),[o,s]=m.useState(),c=m.useRef(null),u=l(t,c,a.onScrollbarYChange);return m.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,g.jsx)(I,{"data-orientation":`vertical`,...i,ref:u,sizes:n,style:{top:0,right:a.dir===`ltr`?0:void 0,left:a.dir===`rtl`?0:void 0,bottom:`var(--radix-scroll-area-corner-height)`,"--radix-scroll-area-thumb-height":G(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollTop+t.deltaY;e.onWheelScroll(r),Y(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:U(o.paddingTop),paddingEnd:U(o.paddingBottom)}})}})}),[P,F]=y(E),I=m.forwardRef((e,t)=>{let{__scopeScrollArea:n,sizes:o,hasThumb:s,onThumbChange:c,onThumbPointerUp:u,onThumbPointerDown:d,onThumbPositionChange:f,onDragScroll:p,onWheelScroll:h,onResize:_,...v}=e,y=S(E,n),[b,x]=m.useState(null),C=l(t,e=>x(e)),w=m.useRef(null),T=m.useRef(``),D=y.viewport,O=o.content-o.viewport,k=i(h),A=i(f),j=Z(_,10);function M(e){w.current&&p({x:e.clientX-w.current.left,y:e.clientY-w.current.top})}return m.useEffect(()=>{let e=e=>{let t=e.target;b!=null&&b.contains(t)&&k(e,O)};return document.addEventListener(`wheel`,e,{passive:!1}),()=>document.removeEventListener(`wheel`,e,{passive:!1})},[D,b,O,k]),m.useEffect(A,[o,A]),Q(b,j),Q(y.content,j),(0,g.jsx)(P,{scope:n,scrollbar:b,hasThumb:s,onThumbChange:i(c),onThumbPointerUp:i(u),onThumbPositionChange:A,onThumbPointerDown:i(d),children:(0,g.jsx)(a.div,{...v,ref:C,style:{position:`absolute`,...v.style},onPointerDown:r(e.onPointerDown,e=>{e.button===0&&(e.target.setPointerCapture(e.pointerId),w.current=b.getBoundingClientRect(),T.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect=`none`,y.viewport&&(y.viewport.style.scrollBehavior=`auto`),M(e))}),onPointerMove:r(e.onPointerMove,M),onPointerUp:r(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=T.current,y.viewport&&(y.viewport.style.scrollBehavior=``),w.current=null})})})}),L=`ScrollAreaThumb`,R=m.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=F(L,e.__scopeScrollArea);return(0,g.jsx)(o,{present:n||i.hasThumb,children:(0,g.jsx)(z,{ref:t,...r})})}),z=m.forwardRef((e,t)=>{let{__scopeScrollArea:n,style:i,...o}=e,s=S(L,n),c=F(L,n),{onThumbPositionChange:u}=c,d=l(t,e=>c.onThumbChange(e)),f=m.useRef(void 0),p=Z(()=>{f.current&&(f.current(),f.current=void 0)},100);return m.useEffect(()=>{let e=s.viewport;if(e){let t=()=>{p(),f.current||(f.current=X(e,u),u())};return u(),e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)}},[s.viewport,p,u]),(0,g.jsx)(a.div,{"data-state":c.hasThumb?`visible`:`hidden`,...o,ref:d,style:{width:`var(--radix-scroll-area-thumb-width)`,height:`var(--radix-scroll-area-thumb-height)`,...i},onPointerDownCapture:r(e.onPointerDownCapture,e=>{let t=e.target.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;c.onThumbPointerDown({x:n,y:r})}),onPointerUp:r(e.onPointerUp,c.onThumbPointerUp)})});R.displayName=L;var B=`ScrollAreaCorner`,V=m.forwardRef((e,t)=>{let n=S(B,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!==`scroll`&&r?(0,g.jsx)(H,{...e,ref:t}):null});V.displayName=B;var H=m.forwardRef((e,t)=>{let{__scopeScrollArea:n,...r}=e,i=S(B,n),[o,s]=m.useState(0),[c,l]=m.useState(0),u=!!(o&&c);return Q(i.scrollbarX,()=>{var e;let t=((e=i.scrollbarX)==null?void 0:e.offsetHeight)||0;i.onCornerHeightChange(t),l(t)}),Q(i.scrollbarY,()=>{var e;let t=((e=i.scrollbarY)==null?void 0:e.offsetWidth)||0;i.onCornerWidthChange(t),s(t)}),u?(0,g.jsx)(a.div,{...r,ref:t,style:{width:o,height:c,position:`absolute`,right:i.dir===`ltr`?0:void 0,left:i.dir===`rtl`?0:void 0,bottom:0,...e.style}}):null});function U(e){return e?parseInt(e,10):0}function W(e,t){let n=e/t;return isNaN(n)?0:n}function G(e){let t=W(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function K(e,t,n,r=`ltr`){let i=G(n),a=i/2,o=t||a,s=i-o,c=n.scrollbar.paddingStart+o,l=n.scrollbar.size-n.scrollbar.paddingEnd-s,u=n.content-n.viewport,d=r===`ltr`?[0,u]:[u*-1,0];return J([c,l],d)(e)}function q(e,t,n=`ltr`){let r=G(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-i,o=t.content-t.viewport,s=a-r,c=h(e,n===`ltr`?[0,o]:[o*-1,0]);return J([0,o],[0,s])(c)}function J(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function Y(e,t){return e>0&&e<t}var X=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return(function i(){let a={left:e.scrollLeft,top:e.scrollTop},o=n.left!==a.left,s=n.top!==a.top;(o||s)&&t(),n=a,r=window.requestAnimationFrame(i)})(),()=>window.cancelAnimationFrame(r)};function Z(e,t){let n=i(e),r=m.useRef(0);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),m.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Q(e,t){let n=i(t);u(()=>{let t=0;if(e){let r=new ResizeObserver(()=>{cancelAnimationFrame(t),t=window.requestAnimationFrame(n)});return r.observe(e),()=>{window.cancelAnimationFrame(t),r.unobserve(e)}}},[e,n])}var ee=C,te=T,ne=V,$=m.forwardRef(({className:e,children:t,...n},r)=>(0,g.jsxs)(ee,{"data-slot":`scroll-area`,className:c(`relative overflow-hidden`,e),...n,children:[(0,g.jsx)(te,{ref:r,"data-slot":`scroll-area-viewport`,className:`size-full min-w-0 rounded-[inherit] outline-none`,style:{WebkitOverflowScrolling:`touch`},children:t}),(0,g.jsx)(re,{}),(0,g.jsx)(ne,{})]}));$.displayName=`ScrollArea`;function re({className:e,orientation:t=`vertical`,...n}){return(0,g.jsx)(D,{"data-slot":`scroll-area-scrollbar`,"data-orientation":t,orientation:t,className:c(`flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent`,e),...n,children:(0,g.jsx)(R,{"data-slot":`scroll-area-thumb`,className:`relative flex-1 rounded-full bg-border`})})}export{p as n,$ as t};
@@ -0,0 +1 @@
1
+ import{n as e}from"./jsx-runtime-D-oznMWL.js";import{t}from"./react-DcCgrBX5.js";var n=e((e=>{var n=t();function r(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function i(){}var a={d:{f:i,r:function(){throw Error(r(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},o=Symbol.for(`react.portal`);function s(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var c=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function l(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,e.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(r(299));return s(e,t,null,n)},e.flushSync=function(e){var t=c.T,n=a.p;try{if(c.T=null,a.p=2,e)return e()}finally{c.T=t,a.p=n,a.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,a.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&a.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin),i=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?a.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:i,fetchPriority:o}):n===`script`&&a.d.X(e,{crossOrigin:r,integrity:i,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=l(t.as,t.crossOrigin);a.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t==null&&a.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin);a.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=l(t.as,t.crossOrigin);a.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else a.d.m(e)},e.requestFormReset=function(e){a.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return c.H.useFormState(e,t,n)},e.useFormStatus=function(){return c.H.useHostTransitionStatus()},e.version=`19.2.4`})),r=e(((e,t)=>{function r(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(r)}catch(e){console.error(e)}}r(),t.exports=n()}));function i(e){"@babel/helpers - typeof";return i=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},i(e)}function a(e,t){if(i(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(i(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function o(e){var t=a(e,`string`);return i(t)==`symbol`?t:t+``}function s(e,t,n){return(t=o(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var c=class{constructor(){s(this,`listeners`,new Map)}on(e,t){let n=this.listeners.get(e);return n||(n=new Set,this.listeners.set(e,n)),n.add(t),this}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};return this.on(e,n)}off(e,t){let n=this.listeners.get(e);return n&&(n.delete(t),n.size===0&&this.listeners.delete(e)),this}emit(e,...t){let n=this.listeners.get(e);if(!n||n.size===0)return!1;for(let r of n)try{r(...t)}catch(t){console.error(`Error in event handler for "${e}":`,t)}return!0}removeAllListeners(e){return e===void 0?this.listeners.clear():this.listeners.delete(e),this}listenerCount(e){var t,n;return(t=(n=this.listeners.get(e))==null?void 0:n.size)==null?0:t}eventNames(){return Array.from(this.listeners.keys())}};function l(e,t){switch(t.type){case`session.created`:e.emit(`session.created`,t.session);break;case`session.resumed`:e.emit(`session.resumed`,t.session,t.messages,t.usage,t.isRunning);break;case`session.closed`:e.emit(`session.closed`,t.sessionId);break;case`session.reopened`:e.emit(`session.reopened`,t.session);break;case`session.deleted`:e.emit(`session.deleted`,t.sessionId);break;case`session.updated`:e.emit(`session.updated`,t.session);break;case`session.renamed`:e.emit(`session.renamed`,t.session);break;case`session.interrupted`:e.emit(`session.interrupted`,t.sessionId,t.result);break;case`session.reverted`:e.emit(`session.reverted`,t.sessionId,t.revertedTo,t.removed);break;case`session.forked`:e.emit(`session.forked`,t.originalSessionId,t.forkedSession,t.messages);break;case`session.state`:e.emit(`session.state`,t.sessionId,t.messages);break;case`message.created`:e.emit(`message.created`,t.message);break;case`message.updated`:e.emit(`message.updated`,t.message);break;case`part.created`:e.emit(`part.created`,t.sessionId,t.part);break;case`part.updated`:e.emit(`part.updated`,t.sessionId,t.part);break;case`part.append`:e.emit(`part.append`,t.sessionId,t.partId,t.field,t.delta);break;case`chat.usage`:e.emit(`chat.usage`,t.sessionId,t.usage,t.model,t.variant);break;case`compaction.complete`:e.emit(`compaction.complete`,t.sessionId,t.tokensUsed);break;case`permission.request`:e.emit(`permission.request`,t.sessionId,t.childSessionId,t.subagentName,t.toolCallId,t.toolName,t.args,t.permissionType,t.permissionKey,t.message,t.details,t.dangerous);break;case`permission.granted`:e.emit(`permission.granted`,t.toolCallId,t.cached);break;case`permission.list`:e.emit(`permission.list`,t.workspaceId,t.permissions);break;case`permission.revoked`:e.emit(`permission.revoked`,t.permissionId);break;case`permission.all_revoked`:e.emit(`permission.all_revoked`,t.workspaceId,t.count);break;case`permissions.sync`:e.emit(`permissions.sync`,t.approvals);break;case`queue.list`:e.emit(`queue.list`,t.sessionId,t.messages);break;case`queue.added`:e.emit(`queue.added`,t.sessionId,t.message);break;case`queue.removed`:e.emit(`queue.removed`,t.sessionId,t.queueId);break;case`queue.sending`:e.emit(`queue.sending`,t.sessionId,t.queueId);break;case`provider.status`:e.emit(`provider.status`,t.provider,t.connected,t.authorizationUrl,t.error);break;case`provider.connected`:e.emit(`provider.connected`,t.provider,t.connected,t.connectedAt,t.accountId);break;case`error`:e.emit(`error`,t.code,t.message);break;case`error.rate_limit`:e.emit(`error.rate_limit`,t.code,t.message,t.retryAfterMs),e.emit(`error`,t.code,t.message);break;case`error.server`:e.emit(`error.server`,t.code,t.message,t.retryAfterMs),e.emit(`error`,t.code,t.message);break;case`error.timeout`:e.emit(`error.timeout`,t.code,t.message,t.retryAfterMs),e.emit(`error`,t.code,t.message);break;case`error.auth`:e.emit(`error.auth`,t.code,t.message),e.emit(`error`,t.code,t.message);break;case`error.invalid_request`:e.emit(`error.invalid_request`,t.code,t.message),e.emit(`error`,t.code,t.message);break;case`error.context_overflow`:e.emit(`error.context_overflow`,t.code,t.message),e.emit(`error`,t.code,t.message);break;case`ping`:return;default:console.warn(`Unknown server message type: ${t.type}`);break}e.emit(`*`,{source:`server`,type:t.type,raw:t})}var u=class extends Error{constructor(e,t){super(e,t),this.name=`Jean2Error`}},d=class extends u{constructor(e,t){super(e,t),this.name=`ConnectionError`}},f=class extends u{constructor(e,t){super(e,t),this.name=`AuthError`}},p=class extends u{constructor(e,t,n){super(e,n),s(this,`retryAfterMs`,void 0),this.name=`RateLimitError`,this.retryAfterMs=t}},m=class extends u{constructor(e,t,n){super(e,n),s(this,`statusCode`,void 0),this.name=`ServerError`,this.statusCode=t}},h=class extends u{constructor(e,t=400,n){super(e,n),s(this,`statusCode`,void 0),this.name=`ValidationError`,this.statusCode=t}},g=class e{constructor(e){s(this,`_ws`,null),s(this,`config`,void 0),s(this,`_state`,`disconnected`),s(this,`onOpen`,null),s(this,`onMessage`,null),s(this,`onClose`,null),s(this,`onError`,null),s(this,`heartbeatTimer`,null),s(this,`missedHeartbeats`,0),this.config=e}async connect(){return new Promise((e,t)=>{var n,r;let i=(n=this.config.wsConstructor)==null?globalThis.WebSocket:n,a=this.buildWsUrl();this._state=`connecting`,this._ws=new i(a);let o=(r=this.config.connectionTimeout)==null?1e4:r,s=setTimeout(()=>{var e;(e=this._ws)==null||e.close(1001,`Connection timeout`),t(new d(`Connection timeout (${o}ms)`))},o);this._ws.onopen=()=>{var t;clearTimeout(s),this._state=`connected`,this.startHeartbeatMonitor(),(t=this.onOpen)==null||t.call(this),e()},this._ws.onmessage=e=>{try{var t;let n=JSON.parse(String(e.data));if(n.type===`ping`){this.resetHeartbeat(),this.send({type:`pong`});return}this.resetHeartbeat(),(t=this.onMessage)==null||t.call(this,n)}catch(e){var n;let t=e instanceof Error?e.message:String(e);(n=this.onError)==null||n.call(this,Error(`Failed to parse WebSocket message: ${t}`))}},this._ws.onclose=e=>{var n;clearTimeout(s),this.stopHeartbeatMonitor(),this._state=`disconnected`,this._ws!==null&&t(new d(`Connection closed before open: code=${e.code}, reason=${e.reason}`)),this._ws=null,(n=this.onClose)==null||n.call(this,e.code,e.reason,e.wasClean)},this._ws.onerror=()=>{var e;clearTimeout(s),(e=this.onError)==null||e.call(this,Error(`WebSocket error`)),t(new d(`WebSocket error`))}})}send(e){if(!this._ws||this._ws.readyState!==WebSocket.OPEN)throw new d(`WebSocket is not connected`);this._ws.send(JSON.stringify(e))}async disconnect(){if(!this._ws)return;let e=this._ws;if(e.readyState===WebSocket.CLOSING||e.readyState===WebSocket.CLOSED){this._state=`disconnected`,this._ws=null;return}return new Promise(t=>{this._state=`disconnecting`;let n=()=>{e.removeEventListener(`close`,n),t()};e.addEventListener(`close`,n),e.close(1e3,`Client disconnect`)})}dispose(){this.stopHeartbeatMonitor(),this.onOpen=null,this.onMessage=null,this.onClose=null,this.onError=null,this._ws&&(this._ws.onopen=null,this._ws.onmessage=null,this._ws.onclose=null,this._ws.onerror=null,this._ws.close(),this._ws=null),this._state=`disconnected`}get connected(){return this._state===`connected`}get readyState(){var e,t;return(e=(t=this._ws)==null?void 0:t.readyState)==null?WebSocket.CLOSED:e}get ws(){return this._ws}resetHeartbeat(){this.missedHeartbeats=0}startHeartbeatMonitor(){this.stopHeartbeatMonitor(),this.missedHeartbeats=0,this.heartbeatTimer=setInterval(()=>{this.missedHeartbeats++,this.missedHeartbeats>=4&&(this.stopHeartbeatMonitor(),this._ws&&this._ws.close(1e3,`Heartbeat timeout`))},e.HEARTBEAT_TIMEOUT_MS)}stopHeartbeatMonitor(){this.heartbeatTimer!==null&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=null)}buildWsUrl(){return`${this.config.url.startsWith(`https`)?`wss`:`ws`}://${this.config.url.replace(/^https?:\/\//,``)}/ws?token=${encodeURIComponent(this.config.token)}`}};s(g,`HEARTBEAT_TIMEOUT_MS`,12e4);var _=class{constructor(e){s(this,`baseUrl`,void 0),s(this,`token`,void 0);let t=e.apiBase||`/api`;this.baseUrl=`${e.url.startsWith(`https`)?`https`:`http`}://${e.url.replace(/^https?:\/\//,``)}${t}`,this.token=e.token}async request(e,t={}){let{method:n=`GET`,body:r,headers:i={},signal:a,params:o}=t,s=`${this.baseUrl}${e}`;if(o){let e=new URLSearchParams(o);s+=`?${e.toString()}`}let c={...i};r!==void 0&&!(r instanceof FormData)&&(c[`Content-Type`]=`application/json`),c.Authorization=`Bearer ${this.token}`;let l=await fetch(s,{method:n,headers:c,body:r instanceof FormData?r:r?JSON.stringify(r):void 0,signal:a});if(l.status===401)throw new f(`Authentication failed. Your token may be invalid or expired.`);if(l.status===429){let e=l.headers.get(`Retry-After`);throw new p(`Too many requests`,e?parseInt(e,10)*1e3:void 0)}if(!l.ok){let e=`HTTP ${l.status}`;try{let t=await l.json();t.message&&(e=t.message)}catch{}throw l.status>=500?new m(e,l.status):new h(e,l.status)}let u=l.headers.get(`Content-Type`);return u!=null&&u.includes(`application/json`)?l.json():l}get(e,t){return this.request(e,{...t,method:`GET`})}post(e,t,n){return this.request(e,{...n,method:`POST`,body:t})}put(e,t,n){return this.request(e,{...n,method:`PUT`,body:t})}patch(e,t,n){return this.request(e,{...n,method:`PATCH`,body:t})}delete(e,t){return this.request(e,{...t,method:`DELETE`})}},v=class{constructor(e){this.send=e}create(e){this.send({type:`session.create`,...e})}resume(e){this.send({type:`session.resume`,sessionId:e})}close(e){this.send({type:`session.close`,sessionId:e})}update(e,t){this.send({type:`session.update`,sessionId:e,...t})}updateModel(e,t){this.send({type:`session.update_model`,sessionId:e,...t})}reopen(e){this.send({type:`session.reopen`,sessionId:e})}delete(e){this.send({type:`session.delete`,sessionId:e})}rename(e,t){this.send({type:`session.rename`,sessionId:e,title:t})}compact(e){this.send({type:`session.compact`,sessionId:e})}revert(e,t){this.send({type:`session.revert`,sessionId:e,messageId:t})}fork(e,t,n){this.send({type:`session.fork`,sessionId:e,messageId:t,title:n})}interrupt(e,t){this.send({type:`session.interrupt`,sessionId:e,reason:t})}},y=class{constructor(e){this._send=e}send(e,t,n){let r={type:`chat.message`,sessionId:e,content:t};n!=null&&n.attachments&&n.attachments.length>0&&(r.attachments=n.attachments),this._send(r)}},b=class{constructor(e){this.send=e}respond(e,t,n){this.send({type:`permission.response`,toolCallId:e,allowed:t,alwaysAllow:n})}list(e,t){this.send({type:`permission.list`,workspaceId:e,includeRevoked:t})}revoke(e){this.send({type:`permission.revoke`,permissionId:e})}revokeAll(e){this.send({type:`permission.revoke_all`,workspaceId:e})}sync(){this.send({type:`permissions.sync`})}},x=class{constructor(e){this.send=e}add(e,t,n){let r=n;this.send({type:`queue.add`,sessionId:e,content:t,...r&&r.length>0?{attachments:r}:{}})}remove(e){this.send({type:`queue.remove`,queueId:e})}},S=class{constructor(e){this.send=e}connect(e){this.send({type:`provider.connect`,provider:e})}disconnect(e){this.send({type:`provider.disconnect`,provider:e})}},C={INPUT:1,RESIZE:2,CLOSE:3,OUTPUT:4,EXIT:5,ERROR:6,INIT_ACK:7,TITLE:8};function w(e,t){let n=new Uint8Array(1+t.length);return n[0]=e,n.set(t,1),n}var T=class extends c{constructor(e,t,n){super(),s(this,`ws`,void 0),s(this,`_session`,void 0),s(this,`_closed`,!1),s(this,`_disposed`,!1),s(this,`_preInitOutput`,[]),this.ws=e,this._session=t,n&&(this._preInitOutput=n),this.ws.binaryType=`arraybuffer`,this.ws.onmessage=this.handleMessage.bind(this),this.ws.onclose=this.handleClose.bind(this),this.ws.onerror=this.handleError.bind(this)}on(e,t){let n=super.on(e,t);return e===`output`&&this.flushPreInitOutput(),n}flushPreInitOutput(){if(this._preInitOutput.length===0)return;let e=this._preInitOutput;this._preInitOutput=[];for(let t of e){if(this._closed)break;this.emit(`output`,t)}}handleMessage(e){if(this._closed)return;let t=new Uint8Array(e.data);if(t.length<1)return;let n=t[0],r=t.slice(1);switch(n){case C.OUTPUT:this.emit(`output`,r);break;case C.EXIT:{let e=0;if(r.length>0)try{let t=JSON.parse(new TextDecoder().decode(r));e=typeof t.exitCode==`number`?t.exitCode:0}catch{e=0}this._session={...this._session,status:`exited`,exitCode:e},this.emit(`exit`,e);break}case C.TITLE:{let e=`Terminal`;if(r.length>0)try{let t=JSON.parse(new TextDecoder().decode(r));e=typeof t.title==`string`?t.title:`Terminal`}catch{e=`Terminal`}this._session={...this._session,title:e},this.emit(`title`,e);break}case C.ERROR:{let e=new TextDecoder().decode(r),t=Error(e||`Terminal error`);this.emit(`error`,t);break}case C.CLOSE:this.doClose();break;default:break}}handleClose(e){this._closed||(this._closed=!0,this.emit(`close`))}handleError(){if(!this._closed){let e=Error(`WebSocket error`);this.emit(`error`,e)}}doClose(){if(!this._closed){this._closed=!0;try{this.ws.close(1e3,`Client close`)}catch{}this.emit(`close`),this.cleanupHandlers()}}cleanupHandlers(){this._disposed||(this._disposed=!0,this.ws.onmessage=null,this.ws.onclose=null,this.ws.onerror=null)}dispatchFrame(e){this.handleMessage({data:e.buffer})}write(e){if(this._closed||this.ws.readyState!==WebSocket.OPEN)return;let t;t=typeof e==`string`?new TextEncoder().encode(e):e,this.ws.send(w(C.INPUT,t))}resize(e,t){if(this._closed||this.ws.readyState!==WebSocket.OPEN)return;let n=JSON.stringify({cols:e,rows:t}),r=new TextEncoder().encode(n);this.ws.send(w(C.RESIZE,r))}close(){this._closed||(this.ws.readyState===WebSocket.OPEN&&this.ws.send(w(C.CLOSE,new Uint8Array)),this.doClose())}dispose(){if(this.cleanupHandlers(),!this._closed){this._closed=!0;try{this.ws.close(1e3,`Disposed`)}catch{}}this.removeAllListeners()}get session(){return this._session}get sessionId(){return this._session.sessionId}get pid(){return this._session.pid}get cwd(){return this._session.cwd}get shell(){return this._session.shell}get cols(){return this._session.cols}get rows(){return this._session.rows}get title(){return this._session.title}get status(){return this._session.status}get exitCode(){return this._session.exitCode}get isReconnect(){return this._session.isReconnect}get closed(){return this._closed}},E=class extends c{constructor(e){super(),s(this,`ws`,void 0),s(this,`_closed`,!1),s(this,`_disposed`,!1),this.ws=e,this.ws.onmessage=this.handleMessage.bind(this),this.ws.onclose=this.handleClose.bind(this),this.ws.onerror=this.handleError.bind(this)}handleMessage(e){if(this._closed)return;let t=e.data;if(typeof t!=`string`)return;let n;try{n=JSON.parse(t)}catch{return}switch(n.type){case`snapshot`:this.emit(`snapshot`,n.sessions);break;case`created`:this.emit(`created`,n.session);break;case`destroyed`:this.emit(`destroyed`,n.sessionId);break;case`exited`:this.emit(`exited`,n.sessionId,n.exitCode);break;case`title_changed`:this.emit(`title_changed`,n.sessionId,n.title);break;case`status_changed`:this.emit(`status_changed`,n.sessionId,n.status);break}}handleClose(e){this._closed||(this._closed=!0,this.emit(`close`))}handleError(){if(!this._closed){let e=Error(`WebSocket error`);this.emit(`error`,e)}}close(){if(!this._closed){this._closed=!0;try{this.ws.close(1e3,`Client close`)}catch{}this.cleanupHandlers()}}dispose(){if(this.cleanupHandlers(),this.ws.readyState===WebSocket.OPEN||this.ws.readyState===WebSocket.CONNECTING)try{this.ws.close(1e3,`Disposed`)}catch{}this._closed||(this._closed=!0,this.emit(`close`)),this.removeAllListeners()}cleanupHandlers(){this._disposed||(this._disposed=!0,this.ws.onmessage=null,this.ws.onclose=null,this.ws.onerror=null)}get closed(){return this._closed}},D=class{constructor(e){s(this,`config`,void 0),this.config={connectTimeout:1e4,...e}}async connect(e){var t;let n=(t=this.config.wsConstructor)==null?globalThis.WebSocket:t,r=this.config.url.startsWith(`https`)?`wss`:`ws`,i=this.config.url.replace(/^https?:\/\//,``),a=new URLSearchParams({token:this.config.token,cwd:e.cwd,workspaceId:e.workspaceId});e.shell&&a.set(`shell`,e.shell),e.sessionId&&a.set(`sessionId`,e.sessionId);let o=`${r}://${i}/ws/terminal?${a.toString()}`;return new Promise((e,t)=>{var r;let i=new n(o);i.binaryType=`arraybuffer`;let a=(r=this.config.connectTimeout)==null?1e4:r,s=!1,c=t=>{s||(s=!0,clearTimeout(u),e(t))},l=e=>{s||(s=!0,clearTimeout(u),t(e))},u=setTimeout(()=>{i.close(),l(new d(`Terminal connection timeout (${a}ms)`))},a);i.onopen=()=>{};let f=[];i.onmessage=e=>{let t=new Uint8Array(e.data);if(t.length<1)return;let n=t[0],r=t.slice(1);if(n===C.INIT_ACK)try{let e=new T(i,JSON.parse(new TextDecoder().decode(r)),f.filter(e=>e.opcode===C.OUTPUT).map(e=>e.data));for(let t of f)t.opcode!==C.OUTPUT&&e.dispatchFrame(t.data);c(e)}catch(e){i.close(),l(new d(`Failed to parse terminal init: ${e instanceof Error?e.message:String(e)}`))}else if(n===C.ERROR){i.close();let e=`Terminal connection failed`;try{e=JSON.parse(new TextDecoder().decode(r)).message||e}catch{}l(new d(e))}else f.push({opcode:n,data:t})},i.onerror=()=>{i.close(),l(new d(`Terminal WebSocket error`))},i.onclose=()=>{l(new d(`Terminal connection closed before init`))}})}async subscribeEvents(e){var t;let n=(t=this.config.wsConstructor)==null?globalThis.WebSocket:t,r=`${this.config.url.startsWith(`https`)?`wss`:`ws`}://${this.config.url.replace(/^https?:\/\//,``)}/ws/terminal/events?${new URLSearchParams({token:this.config.token,workspaceId:e}).toString()}`;return new Promise((e,t)=>{var i;let a=new n(r),o=(i=this.config.connectTimeout)==null?1e4:i,s=!1,c=t=>{s||(s=!0,clearTimeout(u),e(t))},l=e=>{s||(s=!0,clearTimeout(u),t(e))},u=setTimeout(()=>{a.close(),l(new d(`Terminal events subscription timeout (${o}ms)`))},o);a.onopen=()=>{};let f=null;a.onmessage=e=>{if(s)return;let t=e.data;if(typeof t!=`string`)return;let n;try{n=JSON.parse(t)}catch{return}n.type===`snapshot`&&(f||(f=new E(a)),c({conn:f,initialSessions:n.sessions}))},a.onerror=()=>{a.close(),l(new d(`Terminal events WebSocket error`))},a.onclose=()=>{s||l(new d(`Terminal events connection closed before snapshot`))}})}},O=class{constructor(e){this.http=e}async list(e){return this.http.get(`/sessions`,{params:e!=null&&e.status?{status:e.status}:void 0,signal:e==null?void 0:e.signal})}async create(e){let{signal:t,...n}=e==null?{}:e;return this.http.post(`/sessions`,n,{signal:t})}async get(e,t){return this.http.get(`/sessions/${encodeURIComponent(e)}`,{signal:t==null?void 0:t.signal})}async update(e,t,n){return this.http.put(`/sessions/${encodeURIComponent(e)}`,t,{signal:n==null?void 0:n.signal})}async delete(e,t){return this.http.delete(`/sessions/${encodeURIComponent(e)}`,{signal:t==null?void 0:t.signal})}async listMessages(e,t){return this.http.get(`/sessions/${encodeURIComponent(e)}/messages`,{signal:t==null?void 0:t.signal})}async listGrouped(e){let t={workspaceIds:e.workspaceIds.join(`,`)};return e.status&&(t.status=e.status),e.rootOnly&&(t.rootOnly=`true`),this.http.get(`/sessions/grouped`,{params:t,signal:e.signal})}async listByWorkspace(e){let t={};return e.status&&(t.status=e.status),e.rootOnly&&(t.rootOnly=`true`),this.http.get(`/workspaces/${encodeURIComponent(e.workspaceId)}/sessions`,{params:t,signal:e.signal})}},k=class{constructor(e){this.http=e}async list(e){return this.http.get(`/workspaces`,{signal:e==null?void 0:e.signal})}async create(e){let{signal:t,...n}=e==null?{}:e;return this.http.post(`/workspaces`,n,{signal:t})}async get(e,t){return this.http.get(`/workspaces/${encodeURIComponent(e)}`,{signal:t==null?void 0:t.signal})}async update(e,t,n){return this.http.patch(`/workspaces/${encodeURIComponent(e)}`,t,{signal:n==null?void 0:n.signal})}async delete(e,t){return this.http.delete(`/workspaces/${encodeURIComponent(e)}`,{signal:t==null?void 0:t.signal})}async listSessions(e,t){return this.http.get(`/workspaces/${encodeURIComponent(e)}/sessions`,{signal:t==null?void 0:t.signal})}},A=class{constructor(e){this.http=e}async list(e){return this.http.get(`/models`,{signal:e==null?void 0:e.signal})}},j=class{constructor(e){this.http=e}async list(e){return this.http.get(`/tools`,{signal:e==null?void 0:e.signal})}async get(e,t){return this.http.get(`/tools/${encodeURIComponent(e)}`,{signal:t==null?void 0:t.signal})}},M=class{constructor(e){this.http=e}async list(e){return this.http.get(`/providers`,{signal:e==null?void 0:e.signal})}async getStatus(e,t){return this.http.get(`/providers/${encodeURIComponent(e)}/status`,{signal:t==null?void 0:t.signal})}async connect(e,t){return this.http.post(`/providers/${encodeURIComponent(e)}/connect`,void 0,{signal:t==null?void 0:t.signal})}async disconnect(e,t){return this.http.delete(`/providers/${encodeURIComponent(e)}`,{signal:t==null?void 0:t.signal})}async listCredentials(e){return this.http.get(`/config/providers`,{signal:e==null?void 0:e.signal})}async setCredential(e,t,n){return this.http.put(`/config/providers/${encodeURIComponent(e)}`,t,{signal:n==null?void 0:n.signal})}async clearCredential(e,t){return this.http.delete(`/config/providers/${encodeURIComponent(e)}`,{signal:t==null?void 0:t.signal})}},N=class{constructor(e){this.http=e}async list(e){return this.http.get(`/preconfigs`,{signal:e==null?void 0:e.signal})}async create(e){let{signal:t,...n}=e==null?{}:e;return this.http.post(`/preconfigs`,n,{signal:t})}async get(e,t){return this.http.get(`/preconfigs/${encodeURIComponent(e)}`,{signal:t==null?void 0:t.signal})}async update(e,t,n){return this.http.put(`/preconfigs/${encodeURIComponent(e)}`,t,{signal:n==null?void 0:n.signal})}async delete(e,t){return this.http.delete(`/preconfigs/${encodeURIComponent(e)}`,{signal:t==null?void 0:t.signal})}},P=class{constructor(e){this.http=e}async list(e){return this.http.get(`/prompts`,{signal:e==null?void 0:e.signal})}},F=class{constructor(e){this.http=e}async browse(e,t,n){let r={};return t!==void 0&&(r.path=t),(n==null?void 0:n.showHidden)!==void 0&&(r.showHidden=String(n.showHidden)),(n==null?void 0:n.limit)!==void 0&&(r.limit=String(n.limit)),this.http.get(`/workspaces/${encodeURIComponent(e)}/files`,{params:Object.keys(r).length>0?r:void 0,signal:n==null?void 0:n.signal})}async search(e,t,n){let r={search:t};return(n==null?void 0:n.limit)!==void 0&&(r.limit=String(n.limit)),(n==null?void 0:n.showHidden)!==void 0&&(r.showHidden=String(n.showHidden)),this.http.get(`/workspaces/${encodeURIComponent(e)}/files`,{params:r,signal:n==null?void 0:n.signal})}async preview(e,t,n){return this.http.get(`/workspaces/${encodeURIComponent(e)}/file-preview`,{params:{path:t},signal:n==null?void 0:n.signal})}async browseFs(e,t){return this.http.get(`/fs/browse`,{params:e===void 0?void 0:{path:e},signal:t==null?void 0:t.signal})}async parent(e,t){return this.http.get(`/fs/parent`,{params:{path:e},signal:t==null?void 0:t.signal})}async drives(e){return this.http.get(`/fs/drives`,{signal:e==null?void 0:e.signal})}},I=class{constructor(e){this.http=e}async list(e,t){return this.http.get(`/sessions/${encodeURIComponent(e)}/attachments`,{signal:t==null?void 0:t.signal})}async upload(e,t,n){let r=new FormData;r.append(`file`,t);let{signal:i}=n==null?{}:n;return this.http.post(`/sessions/${encodeURIComponent(e)}/attachments`,r,{signal:i})}getUrl(e,t,n){return`/api/sessions/${encodeURIComponent(e)}/attachments/${encodeURIComponent(t)}/content?key=${encodeURIComponent(n)}`}},L=class{constructor(e){this.http=e}async list(e,t){return this.http.get(`/workspaces/${encodeURIComponent(e)}/terminals`,{signal:t==null?void 0:t.signal})}async create(e,t){let{signal:n,body:r}=t==null?{}:t;return this.http.post(`/workspaces/${encodeURIComponent(e)}/terminals`,r==null?{}:r,{signal:n})}async get(e,t,n){return this.http.get(`/workspaces/${encodeURIComponent(e)}/terminals/${encodeURIComponent(t)}`,{signal:n==null?void 0:n.signal})}async delete(e,t,n){return this.http.delete(`/workspaces/${encodeURIComponent(e)}/terminals/${encodeURIComponent(t)}`,{signal:n==null?void 0:n.signal})}},R=class{constructor(e){this.http=e}async getStatus(e,t){return this.http.get(`/workspaces/${encodeURIComponent(e)}/mcp/status`,{signal:t==null?void 0:t.signal})}async connect(e,t,n){let{signal:r}=n==null?{}:n;return this.http.post(`/workspaces/${encodeURIComponent(e)}/mcp/connect`,{name:t},{signal:r})}async disconnect(e,t,n){let{signal:r}=n==null?{}:n;return this.http.post(`/workspaces/${encodeURIComponent(e)}/mcp/disconnect`,{name:t},{signal:r})}async startAuth(e,t,n){let{signal:r}=n==null?{}:n;return this.http.post(`/workspaces/${encodeURIComponent(e)}/mcp/auth`,{name:t},{signal:r})}async finishAuth(e,t,n,r){let{signal:i}=r==null?{}:r;return this.http.post(`/workspaces/${encodeURIComponent(e)}/mcp/auth/callback`,{name:t,code:n},{signal:i})}},z=class{constructor(e){this.http=e}async get(e){return this.http.get(`/config/models`,{signal:e==null?void 0:e.signal})}async createProvider(e,t){return this.http.post(`/config/models/providers`,e,{signal:t==null?void 0:t.signal})}async updateProvider(e,t,n){return this.http.put(`/config/models/providers/${encodeURIComponent(e)}`,t,{signal:n==null?void 0:n.signal})}async deleteProvider(e,t){return this.http.delete(`/config/models/providers/${encodeURIComponent(e)}`,{signal:t==null?void 0:t.signal})}async createModel(e,t,n){return this.http.post(`/config/models/providers/${encodeURIComponent(e)}/models`,t,{signal:n==null?void 0:n.signal})}async updateModel(e,t,n,r){return this.http.put(`/config/models/providers/${encodeURIComponent(e)}/models/${encodeURIComponent(t)}`,n,{signal:r==null?void 0:r.signal})}async deleteModel(e,t,n){return this.http.delete(`/config/models/providers/${encodeURIComponent(e)}/models/${encodeURIComponent(t)}`,{signal:n==null?void 0:n.signal})}async setDefaults(e,t){return this.http.put(`/config/models/defaults`,e,{signal:t==null?void 0:t.signal})}},B=class{constructor(e){this.http=e}async list(e){return this.http.get(`/config/prompts`,{signal:e==null?void 0:e.signal})}async get(e,t){return this.http.get(`/config/prompts/${encodeURIComponent(e)}`,{signal:t==null?void 0:t.signal})}async create(e,t){return this.http.post(`/config/prompts`,e,{signal:t==null?void 0:t.signal})}async update(e,t,n){return this.http.put(`/config/prompts/${encodeURIComponent(e)}`,t,{signal:n==null?void 0:n.signal})}async delete(e,t){return this.http.delete(`/config/prompts/${encodeURIComponent(e)}`,{signal:t==null?void 0:t.signal})}},V=class{constructor(e){s(this,`models`,void 0),s(this,`prompts`,void 0),this.models=new z(e),this.prompts=new B(e)}},H=class{constructor(e){s(this,`sessions`,void 0),s(this,`workspaces`,void 0),s(this,`models`,void 0),s(this,`tools`,void 0),s(this,`providers`,void 0),s(this,`preconfigs`,void 0),s(this,`prompts`,void 0),s(this,`files`,void 0),s(this,`attachments`,void 0),s(this,`terminals`,void 0),s(this,`mcp`,void 0),s(this,`config`,void 0),this.sessions=new O(e),this.workspaces=new k(e),this.models=new A(e),this.tools=new j(e),this.providers=new M(e),this.preconfigs=new N(e),this.prompts=new P(e),this.files=new F(e),this.attachments=new I(e),this.terminals=new L(e),this.mcp=new R(e),this.config=new V(e)}async loadAll(e){let[t,n,r,i,a]=await Promise.all([this.workspaces.list(e),this.preconfigs.list(e),this.prompts.list(e),this.models.list(e),this.providers.list(e)]);return{workspaces:t.workspaces,preconfigs:n.preconfigs,prompts:r.prompts,models:i.models,defaultModel:i.defaultModel,defaultProvider:i.defaultProvider,providers:a.providers}}},U=class extends c{constructor(e){super(),s(this,`config`,void 0),s(this,`transport`,void 0),s(this,`_httpClient`,void 0),s(this,`_state`,`disconnected`),s(this,`sessions`,void 0),s(this,`chat`,void 0),s(this,`permissions`,void 0),s(this,`queue`,void 0),s(this,`providers`,void 0),s(this,`http`,void 0),s(this,`terminal`,void 0),this.config=e,this.transport=new g({url:e.url,token:e.token,wsConstructor:e.wsConstructor,connectionTimeout:e.connectionTimeout}),this._httpClient=new _({url:e.url,token:e.token,apiBase:e.apiBase});let t=this.transport.send.bind(this.transport);this.sessions=new v(t),this.chat=new y(t),this.permissions=new b(t),this.queue=new x(t),this.providers=new S(t),this.http=new H(this._httpClient),this.terminal=new D({url:e.url,token:e.token,wsConstructor:e.wsConstructor}),this.transport.onOpen=()=>{this._state=`connected`,this.emit(`connected`),this.emit(`*`,{source:`lifecycle`,type:`connected`,payload:void 0})},this.transport.onMessage=e=>{l(this,e)},this.transport.onClose=(e,t,n)=>{let r=this._state;this._state=`disconnected`,r!==`disconnected`&&(this.emit(`disconnected`,{code:e,reason:t,wasClean:n}),this.emit(`*`,{source:`lifecycle`,type:`disconnected`,payload:{code:e,reason:t,wasClean:n}}))},this.transport.onError=e=>{this.emit(`error.connection`,e),this.emit(`*`,{source:`lifecycle`,type:`error.connection`,payload:e})}}async connect(){this._state=`connecting`,await this.transport.connect(),this.config.autoSyncPermissions!==!1&&this.permissions.sync()}async disconnect(){this._state=`disconnecting`,await this.transport.disconnect()}async dispose(){await this.disconnect(),this.transport.dispose(),this.removeAllListeners()}get state(){return this._state}get connected(){return this._state===`connected`}get ws(){return this.transport.ws}get httpClient(){return this._httpClient}send(e){this.transport.send(e)}};export{r as i,H as n,_ as r,U as t};
@@ -1 +1 @@
1
- import{i as e,t}from"./jsx-runtime-D-oznMWL.js";import{t as n}from"./react-DcCgrBX5.js";import{a as r}from"./platform-Bn4qAxt4.js";import{at as i,ct as a,d as o,dt as s,et as c,f as l,ht as u,i as d,lt as f,mt as p,n as m,nt as h,p as g,r as _,st as v,t as y,ut as b}from"./badge-Dpu7ORAu.js";import{t as x}from"./createLucideIcon-BaO6wACO.js";import{n as S,t as C}from"./confirmation-dialog-CdeOkc9q.js";import{a as w,i as T,n as E,o as D,r as O,s as k,t as A}from"./SessionMenuButton-DsDEHbLS.js";import{_ as j,a as M,b as N,c as P,d as F,h as I,i as L,l as R,o as z,p as ee,r as B,s as V,t as H,u as te,v as ne,x as U,y as re}from"./popover-BTq6RtKc.js";import{I as W,R as G,_ as K,d as ie,f as ae,h as q,i as J,m as oe,o as Y,p as se,r as X,t as Z,v as ce}from"./dropdown-menu-BJDf5ta_.js";import{n as le,t as ue}from"./scroll-area-CdXB1yRx.js";var de=x(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),fe=x(`hard-drive`,[[`path`,{d:`M10 16h.01`,key:`1bzywj`}],[`path`,{d:`M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`18tbho`}],[`path`,{d:`M21.946 12.013H2.054`,key:`zqlbp7`}],[`path`,{d:`M6 16h.01`,key:`1pmjb7`}]]),Q=e(n(),1);function pe({sdkClient:e,workspaceId:t,connected:n}){let[r,a]=(0,Q.useState)(!0),[o,s]=(0,Q.useState)(null),c=i(e=>e.setSessions);return(0,Q.useEffect)(()=>{if(!e||!n||!t){c([]),a(!1);return}let r=!1;return a(!0),s(null),e.http.sessions.listByWorkspace({workspaceId:t}).then(e=>{r||(c(e.sessions),a(!1))}).catch(e=>{if(r)return;let t=e instanceof Error?e.message:String(e);console.error(`Failed to load workspace sessions:`,t),s(t),a(!1)}),()=>{r=!0}},[e,n,t,c]),{isLoading:r,error:o}}function me(...e){return e.map((e,t)=>t===0?e.replace(/\/+$/,``):e.replace(/^\/+|\/+$/g,``)).filter(Boolean).join(`/`)}var $=t();function he({open:e,onOpenChange:t,onSelect:n,initialPath:r,title:i=`Select Folder`,sdkClient:a}){var c;let[d,f]=(0,Q.useState)(r||``),[p,m]=(0,Q.useState)([]),[h,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(0),[x,S]=(0,Q.useState)(null),[C,w]=(0,Q.useState)(``),[T,E]=(0,Q.useState)(!1),[D,O]=(0,Q.useState)([]),[k,A]=(0,Q.useState)(!1),M=(0,Q.useRef)(null),P=(0,Q.useRef)(null),F=(0,Q.useCallback)(async e=>{if(a){_(!0),S(null),y(0),w(``),A(!1);try{var t;let n=await a.http.files.browseFs(e);m(n.files.filter(e=>e.type===`directory`)),f(n.currentPath),E((t=n.isRoot)==null?!1:t)}catch(e){S(e instanceof Error?e.message:`Failed to load directory`),m([])}finally{_(!1)}}},[a]),L=(0,Q.useCallback)(async()=>{if(a)try{O((await a.http.files.drives()).drives||[])}catch{}},[a]);(0,Q.useEffect)(()=>{e&&(F(r||``),L())},[e,r,F,L]),(0,Q.useEffect)(()=>{y(0)},[C]);let R=p.filter(e=>e.name.toLowerCase().includes(C.toLowerCase())),z=(c=R[v])==null?null:c,B=(0,Q.useCallback)(e=>me(d,e.name),[d]),V=z?B(z):d,H=!z,te=async()=>{if(a){_(!0),S(null);try{var e;let t=await a.http.files.parent(d);m(t.files.filter(e=>e.type===`directory`)),f(t.currentPath),E((e=t.isRoot)==null?!1:e),y(0),w(``)}catch(e){S(e instanceof Error?e.message:`Failed to navigate up`)}finally{_(!1)}}},U=()=>{V&&(n(V),t(!1))},W=e=>{F(B(e))},G=e=>{if(R.length!==0)switch(e.key){case`ArrowDown`:e.preventDefault(),y(e=>Math.min(e+1,R.length-1));break;case`ArrowRight`:R[v]&&(e.preventDefault(),W(R[v]));break;case`ArrowUp`:e.preventDefault(),y(e=>Math.max(e-1,0));break;case`Enter`:e.preventDefault(),U();break;case`Escape`:C&&(e.preventDefault(),w(``));break}};(0,Q.useEffect)(()=>{if(P.current&&R.length>0){let e=P.current.children[v];e&&e.scrollIntoView({block:`nearest`})}},[v,R.length]),(0,Q.useEffect)(()=>{e&&setTimeout(()=>{var e;return(e=M.current)==null?void 0:e.focus()},100)},[e]),(0,Q.useEffect)(()=>{A(!1)},[d]);let K=(e,t=50)=>{if(e.length<=t)return e;let n=e.split(/[/\\]/);return n.length<=2?e:`.../`+n.slice(-2).join(`/`)};return(0,$.jsx)(ee,{open:e,onOpenChange:t,children:(0,$.jsxs)(I,{className:`sm:max-w-lg`,onKeyDown:G,children:[(0,$.jsx)(ne,{children:(0,$.jsx)(re,{children:i})}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 p-2 bg-muted rounded-md`,children:[(0,$.jsx)(l,{variant:`ghost`,size:`icon`,className:`h-7 w-7 flex-shrink-0`,onClick:te,disabled:h||!d||T,children:(0,$.jsx)(de,{className:`w-4 h-4`})}),D.length>1&&(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(l,{variant:`ghost`,size:`icon`,className:`h-7 w-7 flex-shrink-0`,onClick:()=>A(e=>!e),disabled:h,children:(0,$.jsx)(fe,{className:`w-4 h-4`})}),k&&(0,$.jsx)(`div`,{className:`absolute top-full left-0 mt-1 bg-popover border rounded-md shadow-md z-50 min-w-[120px]`,children:D.map(e=>(0,$.jsxs)(`button`,{onClick:()=>{F(e),A(!1)},className:g(`flex items-center gap-2 w-full px-3 py-1.5 text-sm text-left hover:bg-muted`,d===e&&`bg-primary/20 text-primary font-medium`),children:[(0,$.jsx)(s,{className:`w-3.5 h-3.5 text-amber-500`}),e]},e))})]}),(0,$.jsx)(`span`,{className:`flex-1 text-sm font-mono truncate`,title:V,children:z?(0,$.jsx)(`span`,{className:`text-primary`,children:K(B(z),45)}):K(d)||`Home`})]}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(N,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground`}),(0,$.jsx)(o,{ref:M,placeholder:`Filter folders...`,value:C,onChange:e=>w(e.target.value),className:`pl-8`})]}),(0,$.jsx)(ue,{className:`h-64 border rounded-md`,children:h?(0,$.jsxs)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground`,children:[(0,$.jsx)(b,{className:`w-4 h-4 animate-spin mr-2`}),`Loading...`]}):x?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`text-destructive`,children:x}),(0,$.jsx)(l,{variant:`ghost`,size:`sm`,onClick:()=>F(d),className:`mt-2`,children:`Retry`})]}):R.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full text-muted-foreground text-sm`,children:[(0,$.jsx)(s,{className:`w-8 h-8 mb-2 opacity-50`}),C?`No matching folders`:`No folders in this directory`]}):(0,$.jsx)(`div`,{className:`p-1`,ref:P,children:R.map((e,t)=>(0,$.jsxs)(`button`,{onClick:()=>y(t),onDoubleClick:()=>W(e),className:g(`flex items-center gap-2 w-full px-2 py-1.5 rounded text-sm text-left`,`hover:bg-muted`,t===v&&`bg-primary/20 text-primary font-medium ring-1 ring-primary/50`),children:[(0,$.jsx)(s,{className:`w-4 h-4 text-amber-500 flex-shrink-0`}),(0,$.jsx)(`span`,{className:`truncate flex-1`,children:e.name}),t===v&&(0,$.jsx)(u,{className:`w-4 h-4 text-primary`})]},e.path))})}),x&&(0,$.jsx)(`p`,{className:`text-xs text-destructive`,children:x})]}),(0,$.jsxs)(j,{children:[(0,$.jsx)(l,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,$.jsx)(l,{onClick:U,disabled:!V||h,children:H?`Use This Folder`:`Add Selected Folder`})]})]})})}function ge({workspaces:e,activeWorkspace:t,onSelectWorkspace:n,onCreateVirtualWorkspace:r,onCreatePhysicalWorkspace:i,isWorkspaceFavorited:o,onToggleFavorite:c,onDeleteWorkspace:d,onRenameWorkspace:p,sdkClient:m}){let[h,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(null),[S,w]=(0,Q.useState)(null),[T,E]=(0,Q.useState)(``),D=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{S&&D.current&&(D.current.focus(),D.current.select())},[S]);let O=e=>{E(e.name),w(e.id)},A=()=>{let e=T.trim();e&&S&&p(S,e),w(null)},j=()=>{w(null)};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(H,{open:h,onOpenChange:_,children:[(0,$.jsx)(L,{asChild:!0,children:(0,$.jsxs)(l,{variant:`outline`,role:`combobox`,"aria-expanded":h,"aria-label":`Select workspace`,className:`w-full justify-between h-9`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 overflow-hidden`,children:[t!=null&&t.isVirtual?(0,$.jsx)(k,{className:`size-4 flex-shrink-0 text-muted-foreground`}):(0,$.jsx)(s,{className:`size-4 flex-shrink-0 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`truncate`,children:(t==null?void 0:t.name)||`Select workspace`})]}),(0,$.jsx)(U,{className:`ml-auto size-4 shrink-0 opacity-50`})]})}),(0,$.jsx)(B,{className:`w-[240px] p-0 max-h-[80vh]`,children:(0,$.jsxs)(M,{children:[(0,$.jsx)(P,{placeholder:`Search workspace...`}),(0,$.jsxs)(te,{className:`max-h-[50vh] overflow-y-auto`,children:[(0,$.jsx)(z,{children:`No workspace found.`}),(0,$.jsx)(V,{heading:`Workspaces`,children:e.map(e=>(0,$.jsxs)(R,{showCheck:!1,onSelect:()=>{S!==e.id&&(n(e),_(!1))},children:[(0,$.jsx)(`div`,{className:`flex-1 min-w-0 flex items-center gap-2`,children:S===e.id?(0,$.jsx)(`input`,{ref:D,type:`text`,value:T,onChange:e=>E(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),A()):e.key===`Escape`?(e.preventDefault(),j()):[`ArrowUp`,`ArrowDown`].includes(e.key)&&e.stopPropagation()},onBlur:A,onClick:e=>e.stopPropagation(),className:`flex-1 min-w-0 h-6 px-1 text-sm bg-background border border-input rounded focus:outline-none focus:ring-2 focus:ring-ring`}):(0,$.jsxs)($.Fragment,{children:[e.isVirtual?(0,$.jsx)(k,{className:`size-4 flex-shrink-0 text-muted-foreground`}):(0,$.jsx)(s,{className:`size-4 flex-shrink-0 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.name})]})}),(0,$.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,$.jsx)(`button`,{className:`p-1 rounded hover:bg-secondary transition-colors`,onClick:t=>{t.stopPropagation(),c(e.id,e.name)},title:o(e.id)?`Remove from favorites`:`Add to favorites`,children:o(e.id)?(0,$.jsx)(le,{className:`size-4 fill-primary text-primary`}):(0,$.jsx)(le,{className:`size-4 text-muted-foreground`})}),(0,$.jsx)(u,{className:g(`size-4`,(t==null?void 0:t.id)===e.id?`opacity-100`:`opacity-0`)}),(0,$.jsxs)(Z,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(`button`,{className:`p-1 rounded hover:bg-secondary transition-colors`,onClick:e=>e.stopPropagation(),children:[(0,$.jsx)(G,{className:`size-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Workspace actions`})]})}),(0,$.jsxs)(X,{align:`end`,children:[(0,$.jsxs)(J,{onClick:t=>{t.stopPropagation(),O(e)},children:[(0,$.jsx)(W,{className:`size-4`}),`Rename`]}),(0,$.jsxs)(J,{onClick:t=>{t.stopPropagation(),x(e)},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(a,{className:`size-4`}),`Delete`]})]})]})]})]},e.id))}),(0,$.jsx)(F,{}),(0,$.jsxs)(V,{children:[(0,$.jsxs)(R,{onSelect:()=>{r(),_(!1)},children:[(0,$.jsx)(f,{className:`size-4`,"data-icon":`inline-start`}),`Create virtual workspace`]}),(0,$.jsxs)(R,{onSelect:()=>{_(!1),y(!0)},children:[(0,$.jsx)(s,{className:`size-4`,"data-icon":`inline-start`}),`Add existing folder`]})]})]})]})})]}),(0,$.jsx)(he,{open:v,onOpenChange:y,onSelect:e=>{i(e),y(!1)},title:`Select Workspace Folder`,sdkClient:m}),(0,$.jsx)(C,{open:b!==null,onOpenChange:e=>!e&&x(null),title:`Delete Workspace`,description:b?`Are you sure you want to delete "${b.name}"? This will permanently remove the workspace and all associated Jean data, including sessions, messages, and temporary files. The actual files in "${b.name}" on disk will not be deleted.`:``,confirmLabel:`Delete`,variant:`destructive`,onConfirm:()=>{b&&(d(b.id),x(null))}})]})}function _e({activeSessions:e,archivedSessions:t,childrenMap:n,sessionDerivedValues:r,currentSessionId:i,onResumeSession:o,onCloseSession:s,onReopenSession:c,onDeleteSession:u,onRenameSession:f,onBulkCloseSessions:h,onBulkDeleteSessions:g}){let[b,x]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(new Set),[E,O]=(0,Q.useState)(!1),k=(0,Q.useCallback)(e=>{T(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),j=(0,Q.useCallback)(()=>{x(e=>!e),T(new Set)},[]),M=(0,Q.useCallback)(()=>{T(new Set(e.map(e=>e.id)))},[e]),N=(0,Q.useCallback)(()=>{T(new Set)},[]),P=(0,Q.useCallback)(()=>{w.size>0&&(h(w),T(new Set),x(!1))},[w,h]),F=(0,Q.useCallback)(()=>{x(!1),T(new Set)},[]),I=(0,Q.useCallback)(()=>{let e=new Set(t.map(e=>e.id));e.size>0&&g(e),O(!1)},[t,g]);return(0,Q.useEffect)(()=>{if(!b)return;let e=e=>{e.key===`Escape`&&F()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[b,F]),(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(m,{defaultOpen:!0,className:`group/collapsible`,children:(0,$.jsxs)(ie,{children:[(0,$.jsx)(se,{asChild:!0,children:(0,$.jsx)(d,{asChild:!0,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between w-full`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(p,{className:`size-3 transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90`}),`Active`]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[b&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:w.size>0?(0,$.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),w.size===e.length?N():M()},className:`hover:underline cursor-pointer`,children:w.size===e.length?`Deselect all`:`Select all`}):(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),M()},className:`hover:underline cursor-pointer`,children:`Select all`})}),(0,$.jsx)(y,{variant:`secondary`,children:e.length}),(0,$.jsxs)(Z,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:e=>e.stopPropagation(),className:`p-1 rounded-md hover:bg-sidebar-accent hover:text-sidebar-accent-foreground transition-colors`,title:`Session actions`,children:(0,$.jsx)(G,{className:`size-4`})})}),(0,$.jsx)(X,{align:`end`,className:`min-w-48`,children:b?(0,$.jsxs)(J,{onClick:e=>{e.stopPropagation(),F()},children:[(0,$.jsx)(v,{className:`size-4`}),`Cancel selection`]}):(0,$.jsxs)(J,{onClick:e=>{e.stopPropagation(),j()},children:[(0,$.jsx)(D,{className:`size-4`}),`Select to archive`]})})]})]})]})})}),(0,$.jsx)(_,{children:(0,$.jsx)(ae,{children:(0,$.jsx)(q,{children:e.map(e=>(0,$.jsx)(A,{session:e,childrenMap:n,sessionDerivedValues:r,isActive:i===e.id,currentSessionId:i,onResumeSession:o,onCloseSession:s,onReopenSession:c,onDeleteSession:u,onRename:f,selectionMode:b,selected:w.has(e.id),onToggleSelect:k},e.id))})})})]})}),t.length>0&&(0,$.jsx)(m,{defaultOpen:!0,className:`group/collapsible`,children:(0,$.jsxs)(ie,{children:[(0,$.jsx)(se,{asChild:!0,children:(0,$.jsx)(d,{asChild:!0,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between w-full`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(p,{className:`size-3 transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90`}),`Archived`]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(y,{variant:`secondary`,children:t.length}),(0,$.jsxs)(Z,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:e=>e.stopPropagation(),className:`p-1 rounded-md hover:bg-sidebar-accent hover:text-sidebar-accent-foreground transition-colors`,title:`Archived actions`,children:(0,$.jsx)(G,{className:`size-4`})})}),(0,$.jsx)(X,{align:`end`,className:`min-w-48`,children:(0,$.jsxs)(J,{onClick:e=>{e.stopPropagation(),O(!0)},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(a,{className:`size-4`}),`Delete all`]})})]})]})]})})}),(0,$.jsx)(_,{children:(0,$.jsx)(ae,{children:(0,$.jsx)(q,{children:t.map(e=>(0,$.jsx)(A,{session:e,childrenMap:n,sessionDerivedValues:r,isActive:i===e.id,currentSessionId:i,onResumeSession:o,onCloseSession:s,onReopenSession:c,onDeleteSession:u,onRename:f},e.id))})})})]})}),e.length===0&&t.length===0&&(0,$.jsxs)(`div`,{className:`p-4 text-center text-sm text-muted-foreground`,children:[`No sessions yet.`,(0,$.jsx)(`br`,{}),`Start a new chat to begin.`]}),b&&w.size>0&&(0,$.jsxs)(`div`,{className:`sticky bottom-0 bg-sidebar border-t p-2 flex items-center justify-between`,children:[(0,$.jsxs)(`span`,{className:`text-sm text-muted-foreground`,children:[w.size,` selected`]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(l,{variant:`outline`,size:`sm`,onClick:P,children:[(0,$.jsx)(S,{className:`size-4 mr-1`}),`Archive`]}),(0,$.jsxs)(l,{variant:`ghost`,size:`sm`,onClick:F,children:[(0,$.jsx)(v,{className:`size-4 mr-1`}),`Cancel`]})]})]}),(0,$.jsx)(C,{open:E,onOpenChange:O,title:`Delete all archived sessions?`,description:`This will permanently delete ${t.length} archived session${t.length===1?``:`s`}. This action cannot be undone.`,confirmLabel:`Delete all`,variant:`destructive`,onConfirm:I})]})}function ve(){var e,t;let n=c(),i=E(),{sidebarRef:a,chatInputRef:o,terminalPanelRef:s}=h(),{sdkClient:l,primaryPreconfigs:u,createSession:d,resumeSession:p,closeSession:m,reopenSession:g,permanentlyDeleteSession:_,handleRenameSession:v,selectWorkspace:y,handleCreateVirtualWorkspace:b,handleCreatePhysicalWorkspace:x,deleteWorkspace:S,renameWorkspace:C}=n;pe({sdkClient:l,workspaceId:(e=(t=i.activeWorkspace)==null?void 0:t.id)==null?null:e,connected:i.connected});let D=i.activeSessions,k=i.archivedSessions,A=(0,$.jsxs)(oe,{children:[(0,$.jsx)(`div`,{className:`p-2 space-y-2`,children:(0,$.jsx)(ge,{workspaces:i.workspaces,activeWorkspace:i.activeWorkspace,onSelectWorkspace:y,onCreateVirtualWorkspace:b,onCreatePhysicalWorkspace:x,isWorkspaceFavorited:i.isWorkspaceFavorited,onToggleFavorite:i.handleToggleWorkspaceFavorite,onDeleteWorkspace:S,onRenameWorkspace:C,sdkClient:l})}),(0,$.jsx)(q,{children:(0,$.jsx)(ce,{children:(0,$.jsxs)(K,{onClick:()=>{var e;return d((e=u[0])==null?void 0:e.id)},disabled:!i.connected,className:`w-full`,children:[(0,$.jsx)(f,{className:`size-4`,"data-icon":`inline-start`}),(0,$.jsx)(`span`,{children:`New Chat`})]})})})]}),j=(0,Q.useCallback)(e=>{e.forEach(e=>m(e))},[m]),M=(0,Q.useCallback)(e=>{e.forEach(e=>_(e))},[_]),N=(0,$.jsx)(_e,{activeSessions:D,archivedSessions:k,childrenMap:i.childrenMap,sessionDerivedValues:i.sessionDerivedValues,currentSessionId:i.currentSessionId,onResumeSession:p,onCloseSession:m,onReopenSession:g,onDeleteSession:_,onRenameSession:v,onBulkCloseSessions:j,onBulkDeleteSessions:M});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(w,{ref:a,header:A,currentSessionId:i.currentSessionId,onEscape:()=>{if(i.currentSessionId){var e;(e=o.current)==null||e.focus()}},children:N}),(0,$.jsxs)(`main`,{className:`flex-1 flex flex-col overflow-hidden min-h-0`,style:{paddingTop:`env(safe-area-inset-top, 0)`,paddingBottom:`env(safe-area-inset-bottom, 0)`},children:[(0,$.jsx)(T,{}),(0,$.jsx)(r,{}),(0,$.jsx)(O,{sdkClient:l,terminalPanelRef:s})]})]})}var ye=ve;export{ye as component};
1
+ import{i as e,t}from"./jsx-runtime-D-oznMWL.js";import{t as n}from"./react-DcCgrBX5.js";import{a as r}from"./platform-Bn4qAxt4.js";import{at as i,ct as a,d as o,dt as s,et as c,f as l,ht as u,i as d,lt as f,mt as p,n as m,nt as h,p as g,r as _,st as v,t as y,ut as b}from"./badge-DUoauaaV.js";import{t as x}from"./createLucideIcon-BaO6wACO.js";import{n as S,t as C}from"./confirmation-dialog-DeIbHoOu.js";import{a as w,i as T,n as E,o as D,r as O,s as k,t as A}from"./SessionMenuButton-BRiMfAN5.js";import{_ as j,a as M,b as N,c as P,d as F,h as I,i as L,l as R,o as z,p as ee,r as B,s as V,t as H,u as te,v as ne,x as U,y as re}from"./popover-DqniPNsl.js";import{I as W,R as G,_ as K,d as ie,f as ae,h as q,i as J,m as oe,o as Y,p as se,r as X,t as Z,v as ce}from"./dropdown-menu-kSrbs3Xk.js";import{n as le,t as ue}from"./scroll-area-DVew28V6.js";var de=x(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),fe=x(`hard-drive`,[[`path`,{d:`M10 16h.01`,key:`1bzywj`}],[`path`,{d:`M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`18tbho`}],[`path`,{d:`M21.946 12.013H2.054`,key:`zqlbp7`}],[`path`,{d:`M6 16h.01`,key:`1pmjb7`}]]),Q=e(n(),1);function pe({sdkClient:e,workspaceId:t,connected:n}){let[r,a]=(0,Q.useState)(!0),[o,s]=(0,Q.useState)(null),c=i(e=>e.setSessions);return(0,Q.useEffect)(()=>{if(!e||!n||!t){c([]),a(!1);return}let r=!1;return a(!0),s(null),e.http.sessions.listByWorkspace({workspaceId:t}).then(e=>{r||(c(e.sessions),a(!1))}).catch(e=>{if(r)return;let t=e instanceof Error?e.message:String(e);console.error(`Failed to load workspace sessions:`,t),s(t),a(!1)}),()=>{r=!0}},[e,n,t,c]),{isLoading:r,error:o}}function me(...e){return e.map((e,t)=>t===0?e.replace(/\/+$/,``):e.replace(/^\/+|\/+$/g,``)).filter(Boolean).join(`/`)}var $=t();function he({open:e,onOpenChange:t,onSelect:n,initialPath:r,title:i=`Select Folder`,sdkClient:a}){var c;let[d,f]=(0,Q.useState)(r||``),[p,m]=(0,Q.useState)([]),[h,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(0),[x,S]=(0,Q.useState)(null),[C,w]=(0,Q.useState)(``),[T,E]=(0,Q.useState)(!1),[D,O]=(0,Q.useState)([]),[k,A]=(0,Q.useState)(!1),M=(0,Q.useRef)(null),P=(0,Q.useRef)(null),F=(0,Q.useCallback)(async e=>{if(a){_(!0),S(null),y(0),w(``),A(!1);try{var t;let n=await a.http.files.browseFs(e);m(n.files.filter(e=>e.type===`directory`)),f(n.currentPath),E((t=n.isRoot)==null?!1:t)}catch(e){S(e instanceof Error?e.message:`Failed to load directory`),m([])}finally{_(!1)}}},[a]),L=(0,Q.useCallback)(async()=>{if(a)try{O((await a.http.files.drives()).drives||[])}catch{}},[a]);(0,Q.useEffect)(()=>{e&&(F(r||``),L())},[e,r,F,L]),(0,Q.useEffect)(()=>{y(0)},[C]);let R=p.filter(e=>e.name.toLowerCase().includes(C.toLowerCase())),z=(c=R[v])==null?null:c,B=(0,Q.useCallback)(e=>me(d,e.name),[d]),V=z?B(z):d,H=!z,te=async()=>{if(a){_(!0),S(null);try{var e;let t=await a.http.files.parent(d);m(t.files.filter(e=>e.type===`directory`)),f(t.currentPath),E((e=t.isRoot)==null?!1:e),y(0),w(``)}catch(e){S(e instanceof Error?e.message:`Failed to navigate up`)}finally{_(!1)}}},U=()=>{V&&(n(V),t(!1))},W=e=>{F(B(e))},G=e=>{if(R.length!==0)switch(e.key){case`ArrowDown`:e.preventDefault(),y(e=>Math.min(e+1,R.length-1));break;case`ArrowRight`:R[v]&&(e.preventDefault(),W(R[v]));break;case`ArrowUp`:e.preventDefault(),y(e=>Math.max(e-1,0));break;case`Enter`:e.preventDefault(),U();break;case`Escape`:C&&(e.preventDefault(),w(``));break}};(0,Q.useEffect)(()=>{if(P.current&&R.length>0){let e=P.current.children[v];e&&e.scrollIntoView({block:`nearest`})}},[v,R.length]),(0,Q.useEffect)(()=>{e&&setTimeout(()=>{var e;return(e=M.current)==null?void 0:e.focus()},100)},[e]),(0,Q.useEffect)(()=>{A(!1)},[d]);let K=(e,t=50)=>{if(e.length<=t)return e;let n=e.split(/[/\\]/);return n.length<=2?e:`.../`+n.slice(-2).join(`/`)};return(0,$.jsx)(ee,{open:e,onOpenChange:t,children:(0,$.jsxs)(I,{className:`sm:max-w-lg`,onKeyDown:G,children:[(0,$.jsx)(ne,{children:(0,$.jsx)(re,{children:i})}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 p-2 bg-muted rounded-md`,children:[(0,$.jsx)(l,{variant:`ghost`,size:`icon`,className:`h-7 w-7 flex-shrink-0`,onClick:te,disabled:h||!d||T,children:(0,$.jsx)(de,{className:`w-4 h-4`})}),D.length>1&&(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(l,{variant:`ghost`,size:`icon`,className:`h-7 w-7 flex-shrink-0`,onClick:()=>A(e=>!e),disabled:h,children:(0,$.jsx)(fe,{className:`w-4 h-4`})}),k&&(0,$.jsx)(`div`,{className:`absolute top-full left-0 mt-1 bg-popover border rounded-md shadow-md z-50 min-w-[120px]`,children:D.map(e=>(0,$.jsxs)(`button`,{onClick:()=>{F(e),A(!1)},className:g(`flex items-center gap-2 w-full px-3 py-1.5 text-sm text-left hover:bg-muted`,d===e&&`bg-primary/20 text-primary font-medium`),children:[(0,$.jsx)(s,{className:`w-3.5 h-3.5 text-amber-500`}),e]},e))})]}),(0,$.jsx)(`span`,{className:`flex-1 text-sm font-mono truncate`,title:V,children:z?(0,$.jsx)(`span`,{className:`text-primary`,children:K(B(z),45)}):K(d)||`Home`})]}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(N,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground`}),(0,$.jsx)(o,{ref:M,placeholder:`Filter folders...`,value:C,onChange:e=>w(e.target.value),className:`pl-8`})]}),(0,$.jsx)(ue,{className:`h-64 border rounded-md`,children:h?(0,$.jsxs)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground`,children:[(0,$.jsx)(b,{className:`w-4 h-4 animate-spin mr-2`}),`Loading...`]}):x?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`text-destructive`,children:x}),(0,$.jsx)(l,{variant:`ghost`,size:`sm`,onClick:()=>F(d),className:`mt-2`,children:`Retry`})]}):R.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full text-muted-foreground text-sm`,children:[(0,$.jsx)(s,{className:`w-8 h-8 mb-2 opacity-50`}),C?`No matching folders`:`No folders in this directory`]}):(0,$.jsx)(`div`,{className:`p-1`,ref:P,children:R.map((e,t)=>(0,$.jsxs)(`button`,{onClick:()=>y(t),onDoubleClick:()=>W(e),className:g(`flex items-center gap-2 w-full px-2 py-1.5 rounded text-sm text-left`,`hover:bg-muted`,t===v&&`bg-primary/20 text-primary font-medium ring-1 ring-primary/50`),children:[(0,$.jsx)(s,{className:`w-4 h-4 text-amber-500 flex-shrink-0`}),(0,$.jsx)(`span`,{className:`truncate flex-1`,children:e.name}),t===v&&(0,$.jsx)(u,{className:`w-4 h-4 text-primary`})]},e.path))})}),x&&(0,$.jsx)(`p`,{className:`text-xs text-destructive`,children:x})]}),(0,$.jsxs)(j,{children:[(0,$.jsx)(l,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,$.jsx)(l,{onClick:U,disabled:!V||h,children:H?`Use This Folder`:`Add Selected Folder`})]})]})})}function ge({workspaces:e,activeWorkspace:t,onSelectWorkspace:n,onCreateVirtualWorkspace:r,onCreatePhysicalWorkspace:i,isWorkspaceFavorited:o,onToggleFavorite:c,onDeleteWorkspace:d,onRenameWorkspace:p,sdkClient:m}){let[h,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(null),[S,w]=(0,Q.useState)(null),[T,E]=(0,Q.useState)(``),D=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{S&&D.current&&(D.current.focus(),D.current.select())},[S]);let O=e=>{E(e.name),w(e.id)},A=()=>{let e=T.trim();e&&S&&p(S,e),w(null)},j=()=>{w(null)};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(H,{open:h,onOpenChange:_,children:[(0,$.jsx)(L,{asChild:!0,children:(0,$.jsxs)(l,{variant:`outline`,role:`combobox`,"aria-expanded":h,"aria-label":`Select workspace`,className:`w-full justify-between h-9`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 overflow-hidden`,children:[t!=null&&t.isVirtual?(0,$.jsx)(k,{className:`size-4 flex-shrink-0 text-muted-foreground`}):(0,$.jsx)(s,{className:`size-4 flex-shrink-0 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`truncate`,children:(t==null?void 0:t.name)||`Select workspace`})]}),(0,$.jsx)(U,{className:`ml-auto size-4 shrink-0 opacity-50`})]})}),(0,$.jsx)(B,{className:`w-[240px] p-0 max-h-[80vh]`,children:(0,$.jsxs)(M,{children:[(0,$.jsx)(P,{placeholder:`Search workspace...`}),(0,$.jsxs)(te,{className:`max-h-[50vh] overflow-y-auto`,children:[(0,$.jsx)(z,{children:`No workspace found.`}),(0,$.jsx)(V,{heading:`Workspaces`,children:e.map(e=>(0,$.jsxs)(R,{showCheck:!1,onSelect:()=>{S!==e.id&&(n(e),_(!1))},children:[(0,$.jsx)(`div`,{className:`flex-1 min-w-0 flex items-center gap-2`,children:S===e.id?(0,$.jsx)(`input`,{ref:D,type:`text`,value:T,onChange:e=>E(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),A()):e.key===`Escape`?(e.preventDefault(),j()):[`ArrowUp`,`ArrowDown`].includes(e.key)&&e.stopPropagation()},onBlur:A,onClick:e=>e.stopPropagation(),className:`flex-1 min-w-0 h-6 px-1 text-sm bg-background border border-input rounded focus:outline-none focus:ring-2 focus:ring-ring`}):(0,$.jsxs)($.Fragment,{children:[e.isVirtual?(0,$.jsx)(k,{className:`size-4 flex-shrink-0 text-muted-foreground`}):(0,$.jsx)(s,{className:`size-4 flex-shrink-0 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.name})]})}),(0,$.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,$.jsx)(`button`,{className:`p-1 rounded hover:bg-secondary transition-colors`,onClick:t=>{t.stopPropagation(),c(e.id,e.name)},title:o(e.id)?`Remove from favorites`:`Add to favorites`,children:o(e.id)?(0,$.jsx)(le,{className:`size-4 fill-primary text-primary`}):(0,$.jsx)(le,{className:`size-4 text-muted-foreground`})}),(0,$.jsx)(u,{className:g(`size-4`,(t==null?void 0:t.id)===e.id?`opacity-100`:`opacity-0`)}),(0,$.jsxs)(Z,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsxs)(`button`,{className:`p-1 rounded hover:bg-secondary transition-colors`,onClick:e=>e.stopPropagation(),children:[(0,$.jsx)(G,{className:`size-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Workspace actions`})]})}),(0,$.jsxs)(X,{align:`end`,children:[(0,$.jsxs)(J,{onClick:t=>{t.stopPropagation(),O(e)},children:[(0,$.jsx)(W,{className:`size-4`}),`Rename`]}),(0,$.jsxs)(J,{onClick:t=>{t.stopPropagation(),x(e)},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(a,{className:`size-4`}),`Delete`]})]})]})]})]},e.id))}),(0,$.jsx)(F,{}),(0,$.jsxs)(V,{children:[(0,$.jsxs)(R,{onSelect:()=>{r(),_(!1)},children:[(0,$.jsx)(f,{className:`size-4`,"data-icon":`inline-start`}),`Create virtual workspace`]}),(0,$.jsxs)(R,{onSelect:()=>{_(!1),y(!0)},children:[(0,$.jsx)(s,{className:`size-4`,"data-icon":`inline-start`}),`Add existing folder`]})]})]})]})})]}),(0,$.jsx)(he,{open:v,onOpenChange:y,onSelect:e=>{i(e),y(!1)},title:`Select Workspace Folder`,sdkClient:m}),(0,$.jsx)(C,{open:b!==null,onOpenChange:e=>!e&&x(null),title:`Delete Workspace`,description:b?`Are you sure you want to delete "${b.name}"? This will permanently remove the workspace and all associated Jean data, including sessions, messages, and temporary files. The actual files in "${b.name}" on disk will not be deleted.`:``,confirmLabel:`Delete`,variant:`destructive`,onConfirm:()=>{b&&(d(b.id),x(null))}})]})}function _e({activeSessions:e,archivedSessions:t,childrenMap:n,sessionDerivedValues:r,currentSessionId:i,onResumeSession:o,onCloseSession:s,onReopenSession:c,onDeleteSession:u,onRenameSession:f,onBulkCloseSessions:h,onBulkDeleteSessions:g}){let[b,x]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(new Set),[E,O]=(0,Q.useState)(!1),k=(0,Q.useCallback)(e=>{T(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),j=(0,Q.useCallback)(()=>{x(e=>!e),T(new Set)},[]),M=(0,Q.useCallback)(()=>{T(new Set(e.map(e=>e.id)))},[e]),N=(0,Q.useCallback)(()=>{T(new Set)},[]),P=(0,Q.useCallback)(()=>{w.size>0&&(h(w),T(new Set),x(!1))},[w,h]),F=(0,Q.useCallback)(()=>{x(!1),T(new Set)},[]),I=(0,Q.useCallback)(()=>{let e=new Set(t.map(e=>e.id));e.size>0&&g(e),O(!1)},[t,g]);return(0,Q.useEffect)(()=>{if(!b)return;let e=e=>{e.key===`Escape`&&F()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[b,F]),(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(m,{defaultOpen:!0,className:`group/collapsible`,children:(0,$.jsxs)(ie,{children:[(0,$.jsx)(se,{asChild:!0,children:(0,$.jsx)(d,{asChild:!0,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between w-full`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(p,{className:`size-3 transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90`}),`Active`]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[b&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:w.size>0?(0,$.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),w.size===e.length?N():M()},className:`hover:underline cursor-pointer`,children:w.size===e.length?`Deselect all`:`Select all`}):(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),M()},className:`hover:underline cursor-pointer`,children:`Select all`})}),(0,$.jsx)(y,{variant:`secondary`,children:e.length}),(0,$.jsxs)(Z,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:e=>e.stopPropagation(),className:`p-1 rounded-md hover:bg-sidebar-accent hover:text-sidebar-accent-foreground transition-colors`,title:`Session actions`,children:(0,$.jsx)(G,{className:`size-4`})})}),(0,$.jsx)(X,{align:`end`,className:`min-w-48`,children:b?(0,$.jsxs)(J,{onClick:e=>{e.stopPropagation(),F()},children:[(0,$.jsx)(v,{className:`size-4`}),`Cancel selection`]}):(0,$.jsxs)(J,{onClick:e=>{e.stopPropagation(),j()},children:[(0,$.jsx)(D,{className:`size-4`}),`Select to archive`]})})]})]})]})})}),(0,$.jsx)(_,{children:(0,$.jsx)(ae,{children:(0,$.jsx)(q,{children:e.map(e=>(0,$.jsx)(A,{session:e,childrenMap:n,sessionDerivedValues:r,isActive:i===e.id,currentSessionId:i,onResumeSession:o,onCloseSession:s,onReopenSession:c,onDeleteSession:u,onRename:f,selectionMode:b,selected:w.has(e.id),onToggleSelect:k},e.id))})})})]})}),t.length>0&&(0,$.jsx)(m,{defaultOpen:!0,className:`group/collapsible`,children:(0,$.jsxs)(ie,{children:[(0,$.jsx)(se,{asChild:!0,children:(0,$.jsx)(d,{asChild:!0,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between w-full`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(p,{className:`size-3 transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90`}),`Archived`]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(y,{variant:`secondary`,children:t.length}),(0,$.jsxs)(Z,{children:[(0,$.jsx)(Y,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:e=>e.stopPropagation(),className:`p-1 rounded-md hover:bg-sidebar-accent hover:text-sidebar-accent-foreground transition-colors`,title:`Archived actions`,children:(0,$.jsx)(G,{className:`size-4`})})}),(0,$.jsx)(X,{align:`end`,className:`min-w-48`,children:(0,$.jsxs)(J,{onClick:e=>{e.stopPropagation(),O(!0)},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(a,{className:`size-4`}),`Delete all`]})})]})]})]})})}),(0,$.jsx)(_,{children:(0,$.jsx)(ae,{children:(0,$.jsx)(q,{children:t.map(e=>(0,$.jsx)(A,{session:e,childrenMap:n,sessionDerivedValues:r,isActive:i===e.id,currentSessionId:i,onResumeSession:o,onCloseSession:s,onReopenSession:c,onDeleteSession:u,onRename:f},e.id))})})})]})}),e.length===0&&t.length===0&&(0,$.jsxs)(`div`,{className:`p-4 text-center text-sm text-muted-foreground`,children:[`No sessions yet.`,(0,$.jsx)(`br`,{}),`Start a new chat to begin.`]}),b&&w.size>0&&(0,$.jsxs)(`div`,{className:`sticky bottom-0 bg-sidebar border-t px-2 py-1.5 flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground truncate min-w-0`,children:[w.size,` selected`]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,$.jsx)(l,{variant:`outline`,size:`icon`,onClick:P,title:`Archive`,className:`size-7`,children:(0,$.jsx)(S,{className:`size-4`})}),(0,$.jsx)(l,{variant:`ghost`,size:`icon`,onClick:F,title:`Cancel`,className:`size-7`,children:(0,$.jsx)(v,{className:`size-4`})})]})]}),(0,$.jsx)(C,{open:E,onOpenChange:O,title:`Delete all archived sessions?`,description:`This will permanently delete ${t.length} archived session${t.length===1?``:`s`}. This action cannot be undone.`,confirmLabel:`Delete all`,variant:`destructive`,onConfirm:I})]})}function ve(){var e,t;let n=c(),i=E(),{sidebarRef:a,chatInputRef:o,terminalPanelRef:s}=h(),{sdkClient:l,primaryPreconfigs:u,createSession:d,resumeSession:p,closeSession:m,reopenSession:g,permanentlyDeleteSession:_,handleRenameSession:v,selectWorkspace:y,handleCreateVirtualWorkspace:b,handleCreatePhysicalWorkspace:x,deleteWorkspace:S,renameWorkspace:C}=n;pe({sdkClient:l,workspaceId:(e=(t=i.activeWorkspace)==null?void 0:t.id)==null?null:e,connected:i.connected});let D=i.activeSessions,k=i.archivedSessions,A=(0,$.jsxs)(oe,{children:[(0,$.jsx)(`div`,{className:`p-2 space-y-2`,children:(0,$.jsx)(ge,{workspaces:i.workspaces,activeWorkspace:i.activeWorkspace,onSelectWorkspace:y,onCreateVirtualWorkspace:b,onCreatePhysicalWorkspace:x,isWorkspaceFavorited:i.isWorkspaceFavorited,onToggleFavorite:i.handleToggleWorkspaceFavorite,onDeleteWorkspace:S,onRenameWorkspace:C,sdkClient:l})}),(0,$.jsx)(q,{children:(0,$.jsx)(ce,{children:(0,$.jsxs)(K,{onClick:()=>{var e;return d((e=u[0])==null?void 0:e.id)},disabled:!i.connected,className:`w-full`,children:[(0,$.jsx)(f,{className:`size-4`,"data-icon":`inline-start`}),(0,$.jsx)(`span`,{children:`New Chat`})]})})})]}),j=(0,Q.useCallback)(e=>{e.forEach(e=>m(e))},[m]),M=(0,Q.useCallback)(e=>{e.forEach(e=>_(e))},[_]),N=(0,$.jsx)(_e,{activeSessions:D,archivedSessions:k,childrenMap:i.childrenMap,sessionDerivedValues:i.sessionDerivedValues,currentSessionId:i.currentSessionId,onResumeSession:p,onCloseSession:m,onReopenSession:g,onDeleteSession:_,onRenameSession:v,onBulkCloseSessions:j,onBulkDeleteSessions:M});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(w,{ref:a,header:A,currentSessionId:i.currentSessionId,onEscape:()=>{if(i.currentSessionId){var e;(e=o.current)==null||e.focus()}},children:N}),(0,$.jsxs)(`main`,{className:`flex-1 flex flex-col overflow-hidden min-h-0`,style:{paddingTop:`env(safe-area-inset-top, 0)`,paddingBottom:`env(safe-area-inset-bottom, 0)`},children:[(0,$.jsx)(T,{}),(0,$.jsx)(r,{}),(0,$.jsx)(O,{sdkClient:l,terminalPanelRef:s})]})]})}var ye=ve;export{ye as component};
package/dist/index.html CHANGED
@@ -38,19 +38,19 @@
38
38
  root.classList.add(mode, scheme);
39
39
  })();
40
40
  </script>
41
- <script type="module" crossorigin src="./assets/index-CgtwzRvf.js"></script>
41
+ <script type="module" crossorigin src="./assets/index-0foRHKn1.js"></script>
42
42
  <link rel="modulepreload" crossorigin href="./assets/jsx-runtime-D-oznMWL.js">
43
43
  <link rel="modulepreload" crossorigin href="./assets/react-DcCgrBX5.js">
44
- <link rel="modulepreload" crossorigin href="./assets/src-BF-fktl3.js">
44
+ <link rel="modulepreload" crossorigin href="./assets/src-w2G0llvL.js">
45
45
  <link rel="modulepreload" crossorigin href="./assets/servers-CGl9kUR2.js">
46
46
  <link rel="modulepreload" crossorigin href="./assets/useParams-BODsv_8k.js">
47
47
  <link rel="modulepreload" crossorigin href="./assets/preload-helper-CYlqXMwt.js">
48
48
  <link rel="modulepreload" crossorigin href="./assets/platform-Bn4qAxt4.js">
49
49
  <link rel="modulepreload" crossorigin href="./assets/useNavigate-5b_LZg00.js">
50
- <link rel="modulepreload" crossorigin href="./assets/_serverId-DGlEu8Js.js">
50
+ <link rel="modulepreload" crossorigin href="./assets/_serverId-Bd-hxE5e.js">
51
51
  <link rel="modulepreload" crossorigin href="./assets/ThemeProvider-JPllbGvS.js">
52
52
  <link rel="modulepreload" crossorigin href="./assets/ServerContext-D9RfmQC6.js">
53
- <link rel="stylesheet" crossorigin href="./assets/index-D36xySN9.css">
53
+ <link rel="stylesheet" crossorigin href="./assets/index-Bv9FJWM6.css">
54
54
  </head>
55
55
  <body>
56
56
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jean2/client",
3
- "version": "0.8.2",
3
+ "version": "0.8.3",
4
4
  "description": "Jean2 AI Agent Client - Run the Jean2 web UI locally via npx",
5
5
  "private": false,
6
6
  "type": "module",
@@ -1,8 +0,0 @@
1
- import{i as e,t}from"./jsx-runtime-D-oznMWL.js";import{t as n}from"./react-DcCgrBX5.js";import{i as r}from"./src-BF-fktl3.js";import{Q as i,X as a,Z as o,a as s,at as c,bt as l,c as u,ct as d,et as f,f as p,ft as m,gt as h,h as g,ht as _,i as v,lt as y,m as b,mt as x,n as S,nt as C,o as w,p as T,pt as E,r as D,rt as O,s as k,st as A,t as j,u as M,ut as N}from"./badge-Dpu7ORAu.js";import{t as P}from"./createLucideIcon-BaO6wACO.js";import{n as ee,t as F}from"./confirmation-dialog-CdeOkc9q.js";import{_ as I,a as L,c as R,d as z,f as te,g as ne,h as B,i as V,l as re,m as H,n as ie,o as ae,p as U,r as oe,s as se,t as ce,u as le}from"./alert-DI_4Lgs2.js";import{a as W,b as ue,c as G,f as de,i as K,l as q,n as fe,o as pe,r as J,s as me,t as Y,u as X,x as Z}from"./popover-BTq6RtKc.js";import{i as he,n as ge,r as _e,t as ve}from"./triangle-alert-DxjucLze.js";function ye(e){return e.role===`assistant`}var be=P(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),xe=P(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),Se=P(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),Ce=P(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),we=P(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Te=P(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Ee=P(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),De=P(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),Oe=P(`file-pen`,[[`path`,{d:`M12.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v9.34`,key:`o6klzx`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10.378 12.622a1 1 0 0 1 3 3.003L8.36 20.637a2 2 0 0 1-.854.506l-2.867.837a.5.5 0 0 1-.62-.62l.836-2.869a2 2 0 0 1 .506-.853z`,key:`zhnas1`}]]),ke=P(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]),Ae=P(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),je=P(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),Me=P(`message-square`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]),Ne=P(`minimize-2`,[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]),Pe=P(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),Fe=P(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),Ie=P(`undo-2`,[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]),Le=P(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Re=P(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),Q=t();function ze(){return(0,Q.jsxs)(`div`,{className:`flex flex-col h-full items-center justify-center gap-4 text-muted-foreground`,children:[(0,Q.jsx)(N,{className:`size-8 animate-spin`}),(0,Q.jsx)(`p`,{className:`text-sm`,children:`Loading conversation...`})]})}function Be({message:e=`Connecting to server...`}){return(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-4 text-muted-foreground`,children:[(0,Q.jsx)(N,{className:`size-8 animate-spin`}),(0,Q.jsx)(`p`,{className:`text-sm`,children:e})]})}var Ve=({serverUrl:e,authError:t,retryCount:n,nextRetryIn:r,onRetry:i,onLogout:a})=>(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center min-h-[400px] px-4 text-center`,children:[(0,Q.jsx)(Le,{className:`size-12 text-destructive mb-4`}),(0,Q.jsx)(`h2`,{className:`text-xl font-semibold text-foreground mb-2`,children:`Unable to connect to server`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground mb-4 max-w-[400px]`,children:t||`Please check that the server is running.`}),e&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mb-6 font-mono bg-muted px-3 py-1.5 rounded`,children:e}),(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[(0,Q.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Retrying in `,r,`s...`]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(p,{onClick:i,variant:`default`,children:[(0,Q.jsx)(re,{className:`size-4 mr-2`,"data-icon":`inline-start`}),`Retry Now`]}),(0,Q.jsx)(p,{onClick:a,variant:`ghost`,children:`Change Server`})]}),n>0&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Retry attempt: `,n]})]})]}),$=e(n(),1);function He(e){return e>=1e6?(e/1e6).toFixed(1)+`M`:e>=1e3?(e/1e3).toFixed(1)+`k`:e.toString()}function Ue(e){return e>=60?`critical`:e>=40?`warning`:`normal`}function We({totalTokens:e=0,contextWindow:t=0,modelName:n,compact:r}){let[i,a]=(0,$.useState)(!1),o=e===0?0:t,s=o===0?0:Math.min(100,Math.round(e/o*100)),c=Ue(s),l=2*Math.PI*8,u=l*(1-s/100);return(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 cursor-pointer select-none`,onClick:()=>a(!i),children:[(0,Q.jsxs)(`svg`,{viewBox:`0 0 20 20`,className:`size-5`,fill:`none`,children:[(0,Q.jsx)(`circle`,{cx:`10`,cy:`10`,r:8,stroke:`currentColor`,className:`text-muted-foreground/20`,strokeWidth:`3`}),(0,Q.jsx)(`circle`,{cx:`10`,cy:`10`,r:8,stroke:`currentColor`,className:s===0?`text-muted-foreground/30`:c===`critical`?`text-destructive`:c===`warning`?`text-warning`:`text-primary`,strokeWidth:`3`,strokeDasharray:l,strokeDashoffset:u,strokeLinecap:`round`,transform:`rotate(-90 10 10)`,style:{transition:`stroke-dashoffset 0.3s ease`}})]}),(0,Q.jsx)(`span`,{className:`text-xs font-mono text-muted-foreground`,children:i?`${He(e)}/${He(o)}`:`${s}%`})]})}function Ge(e){switch(e){case`budget`:return`$`;case`standard`:return`$$`;case`premium`:return`$$$`;default:return``}}function Ke({models:e,selectedModelId:t,onChangeModel:n,disabled:r,compact:i=!1,iconOnly:a=!1}){let[o,s]=(0,$.useState)(!1),c=e.reduce((e,t)=>(e[t.providerName]||(e[t.providerName]=[]),e[t.providerName].push(t),e),{}),l=t=>{let r=e.find(e=>e.id===t);r&&(n(t,r.providerId),s(!1))},u=e.find(e=>e.id===t);return a?(0,Q.jsxs)(Y,{open:o,onOpenChange:s,children:[(0,Q.jsx)(K,{asChild:!0,children:(0,Q.jsx)(p,{variant:`ghost`,size:`icon-sm`,role:`combobox`,"aria-expanded":o,"aria-label":`Select model`,disabled:r,children:(0,Q.jsx)(H,{className:`size-4 text-muted-foreground`})})}),(0,Q.jsx)(J,{className:`w-[240px] p-0`,children:(0,Q.jsxs)(W,{children:[(0,Q.jsx)(G,{placeholder:`Search model...`}),(0,Q.jsxs)(X,{className:`max-h-[50vh] overflow-y-auto`,children:[(0,Q.jsx)(pe,{children:`No model found.`}),Object.entries(c).map(([e,n])=>(0,Q.jsx)(me,{heading:e,children:n.map(e=>(0,Q.jsxs)(q,{value:e.id,onSelect:()=>l(e.id),className:`justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{children:e.name}),(0,Q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:Ge(e.tier)})]}),(0,Q.jsx)(_,{className:T(`size-4`,t===e.id?`opacity-100`:`opacity-0`)})]},e.id))},e))]})]})})]}):i?(0,Q.jsxs)(Y,{open:o,onOpenChange:s,children:[(0,Q.jsx)(K,{asChild:!0,children:(0,Q.jsxs)(p,{variant:`ghost`,size:`sm`,role:`combobox`,"aria-expanded":o,"aria-label":`Select model`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,disabled:r,children:[(0,Q.jsx)(H,{className:`size-4 flex-shrink-0 text-muted-foreground`}),(0,Q.jsx)(Z,{className:`size-3 shrink-0 opacity-50`})]})}),(0,Q.jsx)(J,{className:`w-[240px] p-0`,children:(0,Q.jsxs)(W,{children:[(0,Q.jsx)(G,{placeholder:`Search model...`}),(0,Q.jsxs)(X,{className:`max-h-[50vh] overflow-y-auto`,children:[(0,Q.jsx)(pe,{children:`No model found.`}),Object.entries(c).map(([e,n])=>(0,Q.jsx)(me,{heading:e,children:n.map(e=>(0,Q.jsxs)(q,{value:e.id,onSelect:()=>l(e.id),className:`justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{children:e.name}),(0,Q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:Ge(e.tier)})]}),(0,Q.jsx)(_,{className:T(`size-4`,t===e.id?`opacity-100`:`opacity-0`)})]},e.id))},e))]})]})})]}):(0,Q.jsxs)(Y,{open:o,onOpenChange:s,children:[(0,Q.jsx)(K,{asChild:!0,children:(0,Q.jsxs)(p,{variant:`ghost`,size:`sm`,role:`combobox`,"aria-expanded":o,"aria-label":`Select model`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,disabled:r,children:[(0,Q.jsx)(H,{className:`size-4 flex-shrink-0 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`truncate`,children:(u==null?void 0:u.name)||`Select model`}),(0,Q.jsx)(Z,{className:`size-3 shrink-0 opacity-50`})]})}),(0,Q.jsx)(J,{className:`w-[240px] p-0`,children:(0,Q.jsxs)(W,{children:[(0,Q.jsx)(G,{placeholder:`Search model...`}),(0,Q.jsxs)(X,{className:`max-h-[50vh] overflow-y-auto`,children:[(0,Q.jsx)(pe,{children:`No model found.`}),Object.entries(c).map(([e,n])=>(0,Q.jsx)(me,{heading:e,children:n.map(e=>(0,Q.jsxs)(q,{value:e.id,onSelect:()=>l(e.id),className:`justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{children:e.name}),(0,Q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:Ge(e.tier)})]}),(0,Q.jsx)(_,{className:T(`size-4`,t===e.id?`opacity-100`:`opacity-0`)})]},e.id))},e))]})]})})]})}var qe={low:`Low`,medium:`Medium`,high:`High`,xhigh:`X-High`,minimal:`Minimal`,max:`Max`};function Je(e){return qe[e]||e.charAt(0).toUpperCase()+e.slice(1)}function Ye({variants:e,selectedVariant:t,onChangeVariant:n,disabled:r,compact:i=!1,iconOnly:a=!1}){let[o,s]=(0,$.useState)(!1);if(!e||Object.keys(e).length===0)return null;let c=Object.keys(e),l=e=>{n(e===`__none__`?null:e),s(!1)},u=t?Je(t):`Default`,d=(0,Q.jsxs)(W,{children:[(0,Q.jsx)(G,{placeholder:`Search...`}),(0,Q.jsxs)(X,{className:`max-h-[50vh] overflow-y-auto`,children:[(0,Q.jsxs)(q,{value:`__none__`,onSelect:()=>l(`__none__`),className:`justify-between`,children:[(0,Q.jsx)(`span`,{children:`Default`}),(0,Q.jsx)(_,{className:T(`size-4`,t===null?`opacity-100`:`opacity-0`)})]},`__none__`),c.map(e=>(0,Q.jsxs)(q,{value:e,onSelect:()=>l(e),className:`justify-between`,children:[(0,Q.jsx)(`span`,{children:Je(e)}),(0,Q.jsx)(_,{className:T(`size-4`,t===e?`opacity-100`:`opacity-0`)})]},e))]})]});return a?(0,Q.jsxs)(Y,{open:o,onOpenChange:s,children:[(0,Q.jsx)(K,{asChild:!0,children:(0,Q.jsx)(p,{variant:`ghost`,size:`icon-sm`,role:`combobox`,"aria-expanded":o,"aria-label":`Select variant`,disabled:r,children:(0,Q.jsx)(Se,{className:`size-4 text-muted-foreground`})})}),(0,Q.jsx)(J,{className:`w-[240px] p-0`,children:d})]}):i?(0,Q.jsxs)(Y,{open:o,onOpenChange:s,children:[(0,Q.jsx)(K,{asChild:!0,children:(0,Q.jsxs)(p,{variant:`ghost`,size:`sm`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,role:`combobox`,"aria-expanded":o,"aria-label":`Select variant`,disabled:r,children:[(0,Q.jsx)(Se,{className:`size-4 flex-shrink-0 text-muted-foreground`}),(0,Q.jsx)(Z,{className:`size-3 shrink-0 opacity-50`})]})}),(0,Q.jsx)(J,{className:`w-[240px] p-0`,children:d})]}):(0,Q.jsxs)(Y,{open:o,onOpenChange:s,children:[(0,Q.jsx)(K,{asChild:!0,children:(0,Q.jsxs)(p,{variant:`ghost`,size:`sm`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,role:`combobox`,"aria-expanded":o,"aria-label":`Select variant`,disabled:r,children:[(0,Q.jsx)(Se,{className:`size-4 flex-shrink-0 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`truncate`,children:u}),(0,Q.jsx)(Z,{className:`size-3 shrink-0 opacity-50`})]})}),(0,Q.jsx)(J,{className:`w-[240px] p-0`,children:d})]})}function Xe({preconfigs:e,selectedPreconfigId:t,onChangePreconfig:n,disabled:r,compact:i=!1,iconOnly:a=!1}){let[o,s]=(0,$.useState)(!1),c=e.find(e=>e.id===t),l=e=>{n(e),s(!1)};return a?(0,Q.jsxs)(Y,{open:o,onOpenChange:s,children:[(0,Q.jsx)(K,{asChild:!0,children:(0,Q.jsx)(p,{variant:`ghost`,size:`icon-sm`,role:`combobox`,"aria-expanded":o,"aria-label":`Select config`,disabled:r,children:(0,Q.jsx)(R,{className:`size-4 text-muted-foreground`})})}),(0,Q.jsx)(J,{className:`w-[240px] p-0`,children:(0,Q.jsxs)(W,{children:[(0,Q.jsx)(G,{placeholder:`Search config...`}),(0,Q.jsx)(X,{className:`max-h-[50vh] overflow-y-auto`,children:e.map(e=>(0,Q.jsxs)(q,{onSelect:()=>l(e.id),className:`justify-between`,children:[(0,Q.jsxs)(`span`,{children:[e.name,e.isDefault&&(0,Q.jsx)(`span`,{className:`ml-1 text-muted-foreground text-xs`,children:`(default)`})]}),(0,Q.jsx)(_,{className:T(`size-4`,t===e.id?`opacity-100`:`opacity-0`)})]},e.id))})]})})]}):i?(0,Q.jsxs)(Y,{open:o,onOpenChange:s,children:[(0,Q.jsx)(K,{asChild:!0,children:(0,Q.jsxs)(p,{variant:`ghost`,size:`sm`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,role:`combobox`,"aria-expanded":o,"aria-label":`Select config`,disabled:r,children:[(0,Q.jsx)(R,{className:`size-4 flex-shrink-0 text-muted-foreground`}),(0,Q.jsx)(Z,{className:`size-3 shrink-0 opacity-50`})]})}),(0,Q.jsx)(J,{className:`w-[240px] p-0`,children:(0,Q.jsxs)(W,{children:[(0,Q.jsx)(G,{placeholder:`Search config...`}),(0,Q.jsx)(X,{className:`max-h-[50vh] overflow-y-auto`,children:e.map(e=>(0,Q.jsxs)(q,{onSelect:()=>l(e.id),className:`justify-between`,children:[(0,Q.jsxs)(`span`,{children:[e.name,e.isDefault&&(0,Q.jsx)(`span`,{className:`ml-1 text-muted-foreground text-xs`,children:`(default)`})]}),(0,Q.jsx)(_,{className:T(`size-4`,t===e.id?`opacity-100`:`opacity-0`)})]},e.id))})]})})]}):(0,Q.jsxs)(Y,{open:o,onOpenChange:s,children:[(0,Q.jsx)(K,{asChild:!0,children:(0,Q.jsxs)(p,{variant:`ghost`,size:`sm`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,role:`combobox`,"aria-expanded":o,"aria-label":`Select config`,disabled:r,children:[(0,Q.jsx)(R,{className:`size-4 flex-shrink-0 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`truncate`,children:(c==null?void 0:c.name)||`Select config`}),(0,Q.jsx)(Z,{className:`size-3 shrink-0 opacity-50`})]})}),(0,Q.jsx)(J,{className:`w-[240px] p-0`,children:(0,Q.jsxs)(W,{children:[(0,Q.jsx)(G,{placeholder:`Search config...`}),(0,Q.jsx)(X,{className:`max-h-[50vh] overflow-y-auto`,children:e.map(e=>(0,Q.jsxs)(q,{onSelect:()=>l(e.id),className:`justify-between`,children:[(0,Q.jsxs)(`span`,{children:[e.name,e.isDefault&&(0,Q.jsx)(`span`,{className:`ml-1 text-muted-foreground text-xs`,children:`(default)`})]}),(0,Q.jsx)(_,{className:T(`size-4`,t===e.id?`opacity-100`:`opacity-0`)})]},e.id))})]})})]})}function Ze({session:e,preconfigs:t,models:n,usage:r,modelName:i,onChangePreconfig:a,onChangeModel:o,onChangeVariant:c,onRename:l,onNavigateBack:d,isStreaming:f,onInterrupt:m,onCompact:h,isCompacting:_,canCompact:v,selectedVariant:y,variants:x}){var S;let[C,T]=(0,$.useState)(!1),[E,D]=(0,$.useState)(e.title||``),O=(0,$.useRef)(null),A=g(),N=b();(0,$.useEffect)(()=>{C&&O.current&&(O.current.focus(),O.current.select())},[C]);let P=()=>{D(e.title||``),T(!0)},F=()=>{let t=E.trim();t&&t!==e.title&&l(e.id,t),T(!1)},L=t=>{t.key===`Enter`?F():t.key===`Escape`&&(D(e.title||``),T(!1))},R=e.selectedModel||((S=t.find(t=>t.id===e.preconfigId))==null?void 0:S.model)||i,z=n.find(e=>e.id===R),te=z==null?void 0:z.contextWindow;return(0,Q.jsx)(`header`,{className:`flex flex-col border-b border-border bg-card`,children:(0,Q.jsx)(k,{delayDuration:300,children:(0,Q.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center md:justify-between px-4 py-1 gap-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[e.parentId&&d&&(0,Q.jsxs)(p,{variant:`ghost`,size:`sm`,onClick:d,className:`h-7`,children:[(0,Q.jsx)(I,{className:`size-4`,"data-icon":`inline-start`}),`Back`]}),C?(0,Q.jsx)(`input`,{ref:O,type:`text`,value:E,onChange:e=>D(e.target.value),onBlur:F,onKeyDown:L,className:`text-base font-semibold bg-background border border-primary rounded px-2 py-0.5 outline-none min-w-0 flex-1`,autoFocus:!0}):(0,Q.jsx)(`h2`,{className:`text-base font-semibold cursor-pointer px-2 py-0.5 -mx-2 rounded hover:bg-accent transition-colors truncate min-w-0`,onDoubleClick:P,children:e.title||`Untitled Session`}),(0,Q.jsx)(We,{promptTokens:r.promptTokens,completionTokens:r.completionTokens,totalTokens:r.totalTokens,contextWindow:te,modelName:i,compact:A}),e.status===`closed`&&(0,Q.jsxs)(j,{variant:`secondary`,children:[(0,Q.jsx)(ee,{className:`size-3`,"data-icon":`inline-start`}),`Archived`]})]}),(0,Q.jsx)(M,{className:`md:hidden`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 sm:gap-4 flex-wrap md:flex-nowrap shrink-0`,children:[(0,Q.jsx)(Ke,{models:n,selectedModelId:R,onChangeModel:o,disabled:e.status===`closed`||!!e.parentId,iconOnly:A,compact:N}),(0,Q.jsx)(Ye,{variants:x,selectedVariant:y,onChangeVariant:c,disabled:e.status===`closed`||!!e.parentId,iconOnly:A,compact:N}),(0,Q.jsx)(Xe,{preconfigs:t,selectedPreconfigId:e.preconfigId,onChangePreconfig:a,disabled:e.status===`closed`||!!e.parentId,iconOnly:A,compact:N}),(0,Q.jsx)(M,{orientation:`vertical`,className:`hidden md:block`}),h&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(s,{children:[(0,Q.jsx)(u,{asChild:!0,children:(0,Q.jsx)(p,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0 text-muted-foreground hover:bg-accent`,onClick:h,disabled:f||_||!v,children:(0,Q.jsx)(Ne,{className:`size-4`})})}),(0,Q.jsx)(w,{children:_?`Compacting...`:`Compact older messages`})]}),(0,Q.jsx)(M,{orientation:`vertical`,className:`hidden md:block`})]}),(0,Q.jsxs)(s,{children:[(0,Q.jsx)(u,{asChild:!0,children:(0,Q.jsx)(p,{variant:f?`destructive`:`ghost`,size:`sm`,className:`h-8 w-8 p-0 hover:bg-accent${f?``:` text-muted-foreground opacity-60 hover:opacity-100`}`,onClick:m,disabled:!m,children:(0,Q.jsx)(ge,{className:`size-4`})})}),(0,Q.jsx)(w,{children:f?`Interrupt operation`:`Interrupt`})]})]})]})})})}function Qe({prompts:e,query:t,selectedIndex:n,onSelect:r}){let i=e.filter(e=>e.name.toLowerCase().includes(t.toLowerCase()));return i.length===0?(0,Q.jsxs)(`div`,{className:`p-2 text-xs text-muted-foreground`,children:[`No prompts matching "/`,t,`"`]}):(0,Q.jsxs)(`div`,{className:`p-1`,children:[i.map((e,t)=>(0,Q.jsxs)(`button`,{onClick:()=>r(e),className:T(`flex items-center gap-2 w-full px-2 py-1.5 rounded text-sm text-left`,`hover:bg-muted`,t===n&&`bg-primary/20 text-primary font-medium ring-1 ring-primary/50`),children:[(0,Q.jsx)(Me,{className:`w-4 h-4 text-muted-foreground flex-shrink-0`}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`font-mono text-xs`,children:[`/`,e.name]}),(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:e.description})]})]},e.name)),(0,Q.jsxs)(`div`,{className:`mt-1 pt-1 border-t text-xs text-muted-foreground px-2`,children:[i.length,` prompt`,i.length===1?``:`s`,` •`,(0,Q.jsx)(`kbd`,{className:`ml-1 px-1 py-0.5 bg-muted rounded text-[10px]`,children:`↑↓`}),` navigate`,(0,Q.jsx)(`kbd`,{className:`ml-1 px-1 py-0.5 bg-muted rounded text-[10px]`,children:`↵`}),` select`,(0,Q.jsx)(`kbd`,{className:`ml-1 px-1 py-0.5 bg-muted rounded text-[10px]`,children:`esc`}),` close`]})]})}function $e({id:e,kind:t,filename:n,size:r,previewUrl:i,isUploading:a,onRemove:o}){return(0,Q.jsxs)(`div`,{className:T(`flex items-center gap-2 px-2 py-1.5 bg-muted rounded-lg border border-border max-w-[180px]`,a&&`opacity-50`),children:[t===`image`&&i?(0,Q.jsx)(`img`,{src:i,alt:n,className:`size-8 rounded object-cover shrink-0`}):t===`image`?(0,Q.jsx)(Ae,{className:`size-4 text-muted-foreground shrink-0`}):(0,Q.jsx)(le,{className:`size-4 text-muted-foreground shrink-0`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`text-xs truncate`,children:n}),(0,Q.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:et(r)})]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>o(e),className:`shrink-0 p-0.5 hover:bg-accent rounded`,children:(0,Q.jsx)(A,{className:`size-3 text-muted-foreground`})})]})}function et(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function tt({content:e,mentions:t,textareaRef:n}){let r=(0,$.useRef)(null),i=(0,$.useMemo)(()=>{if(!e)return[];let n=new Set(t),r=/@([^\s@]+)/g,i=[],a=0,o;for(;(o=r.exec(e))!==null;){let t=o[1];n.has(t)&&(o.index>a&&i.push({type:`text`,value:e.slice(a,o.index)}),i.push({type:`mention`,value:o[0],path:t}),a=o.index+o[0].length)}return a<e.length&&i.push({type:`text`,value:e.slice(a)}),i},[e,t]);return(0,$.useEffect)(()=>{let e=n.current,t=r.current;if(!e||!t)return;let i=()=>{t.style.height=`${e.offsetHeight}px`,t.scrollTop=e.scrollTop,t.scrollLeft=e.scrollLeft};i(),e.addEventListener(`scroll`,i);let a=new ResizeObserver(i);return a.observe(e),()=>{e.removeEventListener(`scroll`,i),a.disconnect()}},[n]),(0,Q.jsx)(`div`,{ref:r,className:`mirror-textarea`,"aria-hidden":`true`,style:{position:`absolute`,top:0,left:0,right:0,bottom:0,pointerEvents:`none`,zIndex:0,color:`var(--foreground)`,fontFamily:`inherit`,fontSize:`0.875rem`,lineHeight:`1.25rem`,letterSpacing:`normal`,padding:`0.5rem 0.625rem`,paddingRight:`3rem`,minHeight:`44px`,border:`1px solid transparent`,borderRadius:`0.5rem`,maxHeight:`150px`,overflow:`hidden`,whiteSpace:`pre-wrap`,wordWrap:`break-word`,wordBreak:`break-word`,boxSizing:`border-box`,backgroundColor:`transparent`},children:i.map((e,t)=>e.type===`mention`&&e.path?(0,Q.jsx)(`span`,{className:`mention-highlight`,"data-mention-path":e.path,children:e.value},t):(0,Q.jsx)(`span`,{children:e.value},t))})}function nt({path:e,onRemove:t,onPreview:n}){let r=e.split(`/`).pop()||e,i=e.slice(0,e.lastIndexOf(`/`)+1);return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 bg-primary/15 rounded-lg border border-primary/30 max-w-[220px]`,children:[(0,Q.jsx)(le,{className:`size-4 text-primary shrink-0`}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>n==null?void 0:n(e),className:`min-w-0 flex-1 text-left cursor-pointer`,children:(0,Q.jsxs)(`div`,{className:`text-xs truncate`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:i}),(0,Q.jsx)(`span`,{children:r})]})}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>t(e),"aria-label":`Remove ${r}`,className:`shrink-0 p-0.5 hover:bg-accent rounded`,children:(0,Q.jsx)(A,{className:`size-3 text-muted-foreground`})})]})}function rt({workspaceId:e,debounceMs:t=150}){let[n,r]=(0,$.useState)(``),[i,a]=(0,$.useState)(!1),[o,s]=(0,$.useState)([]);return{query:n,setQuery:r,showAutocomplete:i,setShowAutocomplete:a,mentions:o,handleFileSelect:(0,$.useCallback)(e=>{let t={type:`file`,path:e.path,display:e.name};return s(e=>[...e,t]),a(!1),r(``),t},[]),insertMention:(0,$.useCallback)((e,t,n)=>{let r=e.lastIndexOf(`@`,t);return r===-1?{text:e,cursorPos:t}:{text:e.slice(0,r)+`@${n.path}`+e.slice(t),cursorPos:r+n.path.length+1}},[]),extractMentions:(0,$.useCallback)(e=>{let t=/@([^\s@]+)/g,n=[],r;for(;(r=t.exec(e))!==null;){let e=r[1];o.some(t=>t.path===e)&&!n.some(t=>t.path===e)&&n.push({type:`file`,path:e,display:e.split(`/`).pop()||e})}return n},[o]),clearMentions:(0,$.useCallback)(()=>s([]),[]),removeMention:(0,$.useCallback)(e=>{s(t=>t.filter(t=>t.path!==e))},[])}}function it(e){return`${h}${e}`}function at(e,t){if(!(typeof window>`u`))try{localStorage.setItem(it(e),JSON.stringify({text:t,updatedAt:Date.now()}))}catch(e){console.warn(`Error saving draft:`,e)}}function ot(e){if(typeof window>`u`)return``;try{let t=localStorage.getItem(it(e));if(t===null)return``;let n=JSON.parse(t);return typeof n.text!=`string`||typeof n.updatedAt!=`number`||Date.now()-n.updatedAt>2592e6?(localStorage.removeItem(it(e)),``):n.text}catch{return``}}function st(e){if(!(typeof window>`u`))try{localStorage.removeItem(it(e))}catch(e){console.warn(`Error clearing draft:`,e)}}function ct(){l()}function lt(e){let[t,n]=(0,$.useState)(``),r=(0,$.useRef)(void 0),i=(0,$.useRef)(``);(0,$.useEffect)(()=>{ct()},[]);let a=(0,$.useCallback)(t=>{n(t),i.current=t,e!==void 0&&(t===``?st(e):at(e,t))},[e]),o=(0,$.useCallback)(()=>{n(``),i.current=``,e!==void 0&&st(e)},[e]);return(0,$.useEffect)(()=>{let t=r.current;if(t!==void 0&&t!==e){let e=i.current;e!==``&&at(t,e)}if(e!==void 0){let t=ot(e);i.current=t,n(t)}else i.current=``,n(``);r.current=e},[e]),{input:t,setInput:a,clearInput:o}}function ut(e,t){return t?e.content.includes(`ARG`)?e.content.replace(`ARG`,t):`${e.content}\n${t}`:e.content}function dt(e){let t=e.trimStart();if(!t.startsWith(`/`))return null;let n=t.indexOf(` `);return n===-1?{command:t.slice(1),rest:``}:{command:t.slice(1,n),rest:t.slice(n+1).trim()}}var ft=(0,$.forwardRef)(function({onSendMessage:e,disabled:t,isStreaming:n,onStopStreaming:r,placeholder:i=`Type a message...`,workspaceId:a,sdkClient:s,prompts:c=[],sessionId:l,modelSupportsImage:u},d){let{input:f,setInput:m,clearInput:h}=lt(l),[g,_]=(0,$.useState)(0),[v,y]=(0,$.useState)([]),[b,x]=(0,$.useState)(0),[S,C]=(0,$.useState)(`none`),[w,E]=(0,$.useState)(``),[D,k]=(0,$.useState)([]),[A,j]=(0,$.useState)(!1),M=(0,$.useRef)(null),N=(0,$.useRef)(null);(0,$.useImperativeHandle)(d,()=>({focus:()=>{var e;return(e=M.current)==null?void 0:e.focus()}}),[]);let{query:P,setQuery:ee,showAutocomplete:F,setShowAutocomplete:I,mentions:L,handleFileSelect:R,insertMention:z,clearMentions:te,removeMention:ne}=rt({workspaceId:a||``}),B=o(e=>e.openFilePreview),V=O(e=>e.activeWorkspace),re=(0,$.useMemo)(()=>L.map(e=>e.path),[L]);(0,$.useEffect)(()=>{if(L.length===0)return;let e=new Set(L.map(e=>e.path)),t=/@([^\s@]+)/g,n,r=new Set;for(;(n=t.exec(f))!==null;)e.has(n[1])&&r.add(n[1]);for(let e of L)r.has(e.path)||ne(e.path)},[f,L,ne]),(0,$.useEffect)(()=>{x(0)},[v,w,c]),(0,$.useEffect)(()=>{let e=M.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,150)}px`)},[f]);let H=c.filter(e=>e.name.toLowerCase().includes(w.toLowerCase())),ie=S===`prompts`&&c.length>0,U=S===`files`&&F&&!!a,oe=(0,$.useCallback)(e=>{let t=e.target.value,n=e.target.selectionStart||0;m(t),_(n);let r=t.lastIndexOf(`/`,n);if(r!==-1){let e=r>0?t[r-1]:`
2
- `,i=t.slice(r+1,n);if((e===`
3
- `||e===` `||e===``)&&!i.includes(` `)){E(i),C(`prompts`);return}}let i=t.lastIndexOf(`@`,n);if(i!==-1){let e=t.slice(i+1,n);if(!e.includes(` `)){ee(e),I(!0),C(`files`);return}}C(`none`),I(!1)},[ee,I,m]),se=(0,$.useCallback)(e=>{let t=z(f,g,R(e));m(t.text),C(`none`),I(!1),y([]),setTimeout(()=>{M.current&&(M.current.focus(),M.current.setSelectionRange(t.cursorPos,t.cursorPos))},0)},[f,g,R,z,I,m]),ce=(0,$.useCallback)(e=>{let t=f.lastIndexOf(`/`,g),n=f.slice(0,t),r=f.slice(t+1),i=r.indexOf(` `),a=i===-1?``:r.slice(i),o=`${n}/${e.name}${a}`,s=t+1+e.name.length+0;m(o),C(`none`),setTimeout(()=>{M.current&&(M.current.focus(),M.current.setSelectionRange(s,s))},0)},[f,g,m]),le=(0,$.useCallback)(()=>{for(let e of D)e.previewUrl&&URL.revokeObjectURL(e.previewUrl);k([]),h(),te()},[D,h,te]),W=(0,$.useCallback)(async e=>{if(!s||!l)return null;try{let t=await(s==null?void 0:s.http.attachments.upload(l,e));return{id:crypto.randomUUID(),kind:t.kind,filename:t.filename,size:t.size,previewUrl:e.type.startsWith(`image/`)?URL.createObjectURL(e):void 0,uploadedId:t.id,uploadedKind:t.kind}}catch(e){return console.error(`Upload error:`,e),null}},[s,l]),ue=(0,$.useCallback)(e=>{k(t=>{let n=t.find(t=>t.id===e);return n!=null&&n.previewUrl&&URL.revokeObjectURL(n.previewUrl),t.filter(t=>t.id!==e)})},[]),G=(0,$.useCallback)(e=>{let t=e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),n=RegExp(`@${t}`,`g`);m(f.replace(n,``).replace(/\s+/g,` `).trim()),ne(e)},[f,m,ne]),K=(0,$.useCallback)(e=>{V!=null&&V.id&&B({workspaceId:V.id,path:e,name:e.split(`/`).pop()||e})},[V==null?void 0:V.id,B]),q=(0,$.useCallback)(async e=>{let t=Array.from(e);for(let e of t){if(e.size>20*1024*1024)continue;let t=e.type.startsWith(`image/`)?`image`:e.type.startsWith(`video/`)?`video`:`file`,n={id:crypto.randomUUID(),kind:t,filename:e.name,size:e.size,previewUrl:e.type.startsWith(`image/`)?URL.createObjectURL(e):void 0,isUploading:!0};k(e=>[...e,n]);let r=await W(e);k(r?e=>e.map(e=>e.id===n.id?(e.previewUrl&&e.previewUrl!==r.previewUrl&&URL.revokeObjectURL(e.previewUrl),{...r,isUploading:!1}):e):e=>e.filter(e=>e.id!==n.id))}},[W]),pe=(0,$.useCallback)(e=>{var t;let n=(t=e.clipboardData)==null?void 0:t.files;n&&n.length>0&&(e.preventDefault(),q(n))},[q]),me=(0,$.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),j(!0)},[]),X=(0,$.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),j(!1)},[]),Z=(0,$.useCallback)(e=>{var t;e.preventDefault(),e.stopPropagation(),j(!1);let n=(t=e.dataTransfer)==null?void 0:t.files;n&&n.length>0&&q(n)},[q]),he=async n=>{n==null||n.preventDefault();let r=f.trim();if(!r&&D.length===0||t)return;let i=dt(f);if(i){let t=c.find(e=>e.name===i.command);if(t){let n=ut(t,i.rest),r=D.filter(e=>e.uploadedId).map(e=>({id:e.uploadedId,kind:e.uploadedKind}));e(n,r.length>0?r:void 0),le();return}}let a=D.filter(e=>e.uploadedId).map(e=>({id:e.uploadedId,kind:e.uploadedKind}));e(r||``,a.length>0?a:void 0),le()},_e=e=>{if(!e.nativeEvent.isComposing){if(ie&&H.length>0)switch(e.key){case`ArrowDown`:e.preventDefault(),x(e=>Math.min(e+1,H.length-1));return;case`ArrowUp`:e.preventDefault(),x(e=>Math.max(e-1,0));return;case`Enter`:if(e.shiftKey)return;e.preventDefault(),H[b]&&ce(H[b]);return;case`Tab`:e.preventDefault(),H[b]&&ce(H[b]);return;case`Escape`:e.preventDefault(),C(`none`);return}if(U&&v.length>0)switch(e.key){case`ArrowDown`:e.preventDefault(),x(e=>Math.min(e+1,v.length-1));return;case`ArrowUp`:e.preventDefault(),x(e=>Math.max(e-1,0));return;case`Enter`:e.preventDefault(),v[b]&&se(v[b]);return;case`Escape`:e.preventDefault(),I(!1),C(`none`);return;case`Tab`:e.preventDefault(),v[b]&&se(v[b]);return}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),he())}},ye=(0,$.useCallback)(e=>{y(e)},[]);if(n&&r)return(0,Q.jsx)(`div`,{className:`p-4 border-t border-border bg-card`,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-center gap-3`,children:[(0,Q.jsxs)(`div`,{className:`animate-pulse flex items-center gap-2 text-muted-foreground`,children:[(0,Q.jsx)(`div`,{className:`size-2 rounded-full bg-primary animate-bounce`}),(0,Q.jsx)(`div`,{className:`size-2 rounded-full bg-primary animate-bounce [animation-delay:0.1s]`}),(0,Q.jsx)(`div`,{className:`size-2 rounded-full bg-primary animate-bounce [animation-delay:0.2s]`}),(0,Q.jsx)(`span`,{className:`text-sm ml-2`,children:`Generating...`})]}),(0,Q.jsxs)(p,{variant:`outline`,size:`sm`,onClick:r,children:[(0,Q.jsx)(ge,{className:`size-4`,"data-icon":`inline-start`}),`Stop`]})]})});let be=f.trim(),xe=D.some(e=>e.isUploading),Se=!(be||D.length>0)||t||xe;return(0,Q.jsxs)(`form`,{onSubmit:he,onDragOver:me,onDragLeave:X,onDrop:Z,className:T(`p-4 border-t border-border bg-card`,A&&`ring-2 ring-primary`),children:[(D.length>0||!n)&&(0,Q.jsx)(`div`,{className:`flex gap-2 flex-wrap mb-2`,children:D.map(e=>(0,Q.jsx)($e,{id:e.id,kind:e.kind,filename:e.filename,size:e.size,previewUrl:e.previewUrl,isUploading:e.isUploading,onRemove:ue},e.id))}),D.length>0&&u===!1&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-2 text-xs text-amber-600 dark:text-amber-400`,children:[(0,Q.jsx)(ve,{className:`size-3 shrink-0`}),(0,Q.jsx)(`span`,{children:`This model will not inspect images directly. They will be sent as file paths instead.`})]}),L.length>0&&(0,Q.jsx)(`div`,{className:`flex gap-2 flex-wrap mb-2`,children:L.map(e=>(0,Q.jsx)(nt,{path:e.path,onRemove:G,onPreview:K},e.path))}),(0,Q.jsxs)(`div`,{className:`flex gap-3 items-end`,children:[(0,Q.jsxs)(`div`,{className:`flex-1 relative`,children:[(0,Q.jsx)(tt,{content:f,mentions:re,textareaRef:M}),(0,Q.jsxs)(Y,{open:ie||U,onOpenChange:e=>{e||(C(`none`),I(!1))},children:[(0,Q.jsx)(fe,{asChild:!0,children:(0,Q.jsx)(de,{ref:M,value:f,onChange:oe,onKeyDown:_e,onPaste:pe,placeholder:i,disabled:t,className:T(`min-h-[44px] max-h-[150px] resize-none pr-12 chat-input-scrollbar`,`focus-visible:ring-1`,`relative z-[1] text-transparent caret-foreground placeholder:text-muted-foreground`),rows:1,"data-chat-input":`true`})}),(0,Q.jsx)(J,{className:`w-72 p-0`,align:`start`,side:`top`,sideOffset:8,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),children:U?(0,Q.jsx)(ae,{workspaceId:a||``,searchQuery:P,selectedIndex:b,onSelect:se,onFilesChange:ye,sdkClient:s}):(0,Q.jsx)(Qe,{prompts:c,query:w,selectedIndex:b,onSelect:ce})})]})]}),(0,Q.jsx)(`button`,{type:`button`,className:`flex items-center justify-center size-11 rounded-md text-muted-foreground hover:text-foreground hover:bg-accent transition-colors disabled:opacity-50 disabled:pointer-events-none`,onClick:()=>{var e;return(e=N.current)==null?void 0:e.click()},disabled:t,children:(0,Q.jsx)(Pe,{className:`size-4`})}),(0,Q.jsx)(`input`,{ref:N,type:`file`,accept:`image/*,video/*,.pdf,.doc,.docx,.txt,.csv,.json,.xml,.md`,multiple:!0,className:`hidden`,onChange:e=>{e.target.files&&q(e.target.files),e.target.value=``}}),(0,Q.jsx)(p,{type:`submit`,disabled:Se,size:`default`,className:`h-11`,children:(0,Q.jsx)(Fe,{className:`size-4`})})]}),(0,Q.jsxs)(`div`,{className:`mt-2 text-xs text-muted-foreground text-center hidden sm:flex items-center justify-center gap-1`,children:[(0,Q.jsx)(`kbd`,{className:`px-1.5 py-0.5 bg-muted rounded text-[10px]`,children:`/`}),(0,Q.jsx)(`span`,{children:`prompts`}),(0,Q.jsx)(`span`,{className:`mx-2`,children:`•`}),(0,Q.jsx)(`kbd`,{className:`px-1.5 py-0.5 bg-muted rounded text-[10px]`,children:`@`}),(0,Q.jsx)(`span`,{children:`files`}),(0,Q.jsx)(`span`,{className:`mx-2`,children:`•`}),(0,Q.jsx)(`kbd`,{className:`px-1.5 py-0.5 bg-muted rounded text-[10px]`,children:`Enter`}),(0,Q.jsx)(`span`,{children:`to send`}),(0,Q.jsx)(`span`,{className:`mx-2`,children:`•`}),(0,Q.jsx)(`kbd`,{className:`px-1.5 py-0.5 bg-muted rounded text-[10px]`,children:`Shift + Enter`}),(0,Q.jsx)(`span`,{children:`for new line`})]})]})});function pt(e){return e.startsWith(`https://`)?`https`:`http`}function mt(e,t){return`${pt(e)}://${e.replace(/^https?:\/\//,``)}${t}`}function ht(e){let t=(0,$.useRef)(e);return(0,$.useLayoutEffect)(()=>{t.current=e}),(0,$.useCallback)((...e)=>t.current(...e),[])}var gt=e(r(),1);function _t(e,t,n){var r;let i=(r=n.initialDeps)==null?[]:r,a,o=!0;function s(){var r,s,c;let l;n.key&&(r=n.debug)!=null&&r.call(n)&&(l=Date.now());let u=e();if(!(u.length!==i.length||u.some((e,t)=>i[t]!==e)))return a;i=u;let d;if(n.key&&(s=n.debug)!=null&&s.call(n)&&(d=Date.now()),a=t(...u),n.key&&(c=n.debug)!=null&&c.call(n)){let e=Math.round((Date.now()-l)*100)/100,t=Math.round((Date.now()-d)*100)/100,r=t/16,i=(e,t)=>{for(e=String(e);e.length<t;)e=` `+e;return e};console.info(`%c⏱ ${i(t,5)} /${i(e,5)} ms`,`
4
- font-size: .6rem;
5
- font-weight: bold;
6
- color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n==null?void 0:n.key)}return n!=null&&n.onChange&&!(o&&n.skipInitialOnChange)&&n.onChange(a),o=!1,a}return s.updateDeps=e=>{i=e},s}function vt(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var yt=(e,t)=>Math.abs(e-t)<1.01,bt=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},xt=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},St=e=>e,Ct=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let e=t;e<=n;e++)r.push(e);return r},wt=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(xt(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e!=null&&e.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(xt(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},Tt={passive:!0},Et=typeof window>`u`?!0:`onscrollend`in window,Dt=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=0,a=e.options.useScrollendEvent&&Et?()=>void 0:bt(r,()=>{t(i,!1)},e.options.isScrollingResetDelay),o=r=>()=>{let{horizontal:o,isRtl:s}=e.options;i=o?n.scrollLeft*(s&&-1||1):n.scrollTop,a(),t(i,r)},s=o(!0),c=o(!1);n.addEventListener(`scroll`,s,Tt);let l=e.options.useScrollendEvent&&Et;return l&&n.addEventListener(`scrollend`,c,Tt),()=>{n.removeEventListener(`scroll`,s),l&&n.removeEventListener(`scrollend`,c)}},Ot=(e,t,n)=>{if(t!=null&&t.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},kt=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;let o=e+t;(a=(i=r.scrollElement)==null?void 0:i.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:o,behavior:n})},At=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var e,t,n,r;return(e=(r=(n=(t=this.targetWindow)==null?void 0:t.performance)==null?void 0:n.now)==null?void 0:r.call(n))==null?Date.now():e},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>{var n;return(n=t())==null?void 0:n.observe(e,{box:`border-box`})},unobserve:e=>{var n;return(n=t())==null?void 0:n.unobserve(e)}}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([t,n])=>{n===void 0&&delete e[t]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:St,rangeExtractor:Ct,onChange:()=>{},measureElement:Ot,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...e}},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=_t(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var e;let t=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==t){if(this.cleanup(),!t){this.maybeNotify();return}if(this.scrollElement=t,this.scrollElement&&`ownerDocument`in this.scrollElement)this.targetWindow=this.scrollElement.ownerDocument.defaultView;else{var n;this.targetWindow=(n=(e=this.scrollElement)==null?void 0:e.window)==null?null:n}this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>{var e;return this.options.enabled?(this.scrollRect=(e=this.scrollRect)==null?this.options.initialRect:e,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0)},this.getScrollOffset=()=>{var e;return this.options.enabled?(this.scrollOffset=(e=this.scrollOffset)==null?typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset:e,this.scrollOffset):(this.scrollOffset=null,0)},this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=_t(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(e,t,n,r,i,a)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a}),{key:!1}),this.getMeasurements=_t(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a},o)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let s=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1);let c=this.measurementsCache.slice(0,s),l=Array(a).fill(void 0);for(let e=0;e<s;e++){let t=c[e];t&&(l[t.lane]=e)}for(let i=s;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),s,u;if(a!==void 0&&this.options.lanes>1){s=a;let e=l[s],r=e===void 0?void 0:c[e];u=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?c[i-1]:this.getFurthestMeasurement(c,i);u=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(i,s)}let d=o.get(e),f=typeof d==`number`?d:this.options.estimateSize(i),p=u+f;c[i]={index:i,start:u,size:f,end:p,key:e,lane:s},l[s]=i}return this.measurementsCache=c,c},{key:!1,debug:()=>this.options.debug}),this.calculateRange=_t(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?Mt({measurements:e,outerSize:t,scrollOffset:n,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=_t(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{var t,n;if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let r=(t=this.scrollState.index)==null?(n=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:n.index:t;if(r!==void 0&&this.range){let t=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),n=Math.max(0,r-t),i=Math.min(this.options.count-1,r+t);return e>=n&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{var n,r;let i=this.measurementsCache[e];if(!i)return;let a=t-((n=this.itemSizeCache.get(i.key))==null?i.size:n);a!==0&&(((r=this.scrollState)==null?void 0:r.behavior)!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?i.start<this.getScrollOffset()+this.scrollAdjustments:this.shouldAdjustScrollPositionOnItemSizeChange(i,a,this))&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=a,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(i.index),this.itemSizeCache=new Map(this.itemSizeCache.set(i.key,t)),this.notify(!1))},this.getVirtualItems=_t(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length!==0)return vt(t[jt(0,t.length-1,e=>vt(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t);this.scrollState={index:null,align:t,behavior:n,startedAt:this.now(),lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e;this.scrollState={index:null,align:`start`,behavior:t,startedAt:this.now(),lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{var e;let t=this.getMeasurements(),n;if(t.length===0)n=this.options.paddingStart;else if(this.options.lanes===1){var r;n=(r=(e=t[t.length-1])==null?void 0:e.end)==null?0:r}else{let e=Array(this.options.lanes).fill(null),r=t.length-1;for(;r>=0&&e.some(e=>e===null);){let n=t[r];e[n.lane]===null&&(e[n.lane]=n.end),r--}n=Math.max(...e.filter(e=>e!==null))}return Math.max(n-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&yt(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.scrollState=null;return}}else this.scrollState.stableFrames=0,n&&(this.scrollState.lastTargetOffset=t,this.scrollState.behavior=`auto`,this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}));this.scheduleScrollReconcile()}},jt=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function Mt({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){let i=e.length-1,a=t=>e[t].start;if(e.length<=r)return{startIndex:0,endIndex:i};let o=jt(0,i,a,n),s=o;if(r===1)for(;s<i&&e[s].end<n+t;)s++;else if(r>1){let a=Array(r).fill(0);for(;s<i&&a.some(e=>e<n+t);){let t=e[s];a[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(i,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var Nt=typeof document<`u`?$.useLayoutEffect:$.useEffect;function Pt({useFlushSync:e=!0,...t}){let n=$.useReducer(()=>({}),{})[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,gt.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=$.useState(()=>new At(r));return i.setOptions(r),Nt(()=>i._didMount(),[]),Nt(()=>i._willUpdate()),i}function Ft(e){return Pt({observeElementRect:wt,observeElementOffset:Dt,scrollToFn:kt,...e})}function It({message:e,textContent:t,children:n,isQueued:r=!1,onRemove:i,onRevert:a,canRevert:o=!1,onFork:s,canFork:c=!1,isClearAll:l=!1}){let[u,d]=(0,$.useState)(!1),[f,m]=(0,$.useState)(!1),[h,g]=(0,$.useState)(!1),v=e.role===`user`,y=async()=>{let e=t||``;await navigator.clipboard.writeText(e),d(!0),setTimeout(()=>d(!1),2e3)};return(0,Q.jsxs)(`div`,{className:T(`flex flex-col gap-1 animate-slide-up min-w-0`,v?`items-end`:`items-start`),children:[(0,Q.jsx)(`div`,{className:T(`flex items-center gap-1.5 text-xs uppercase tracking-wide text-muted-foreground`,v?`mr-3`:`ml-3`),children:v?(0,Q.jsxs)(Q.Fragment,{children:[!r&&(0,Q.jsxs)(Q.Fragment,{children:[o&&a&&(0,Q.jsx)(p,{variant:`ghost`,size:`icon`,onClick:()=>m(!0),className:`size-5 text-muted-foreground hover:text-foreground`,title:`Revert to this point`,children:(0,Q.jsx)(Ie,{className:`size-3`})}),c&&s&&(0,Q.jsx)(p,{variant:`ghost`,size:`icon`,onClick:()=>g(!0),className:`size-5 text-muted-foreground hover:text-foreground`,title:`Fork from this point`,children:(0,Q.jsx)(ke,{className:`size-3`})}),(0,Q.jsx)(p,{variant:`ghost`,size:`icon`,onClick:y,className:`size-5 text-muted-foreground hover:text-foreground`,children:u?(0,Q.jsx)(_,{className:`size-3`}):(0,Q.jsx)(B,{className:`size-3`})})]}),(0,Q.jsx)(se,{className:`size-3`}),e.role]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(xe,{className:`size-3`}),e.role,(0,Q.jsx)(p,{variant:`ghost`,size:`icon`,onClick:y,className:`size-5 text-muted-foreground hover:text-foreground`,children:u?(0,Q.jsx)(_,{className:`size-3`}):(0,Q.jsx)(B,{className:`size-3`})})]})}),(0,Q.jsxs)(`div`,{className:T(`rounded-2xl px-4 py-3 relative group min-w-0 overflow-hidden`,v?`max-w-[90%]`:`max-w-full`,r?`bg-muted border-2 border-dashed border-muted-foreground/30 opacity-80`:v?`bg-primary text-primary-foreground rounded-br-md`:`bg-card text-card-foreground border border-border rounded-bl-md`),children:[r&&(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-2 pb-2 border-b border-muted-foreground/20`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(Ee,{className:`size-3 animate-pulse`}),(0,Q.jsx)(`span`,{children:`Pending`})]}),i&&(0,Q.jsx)(p,{variant:`ghost`,size:`icon`,onClick:i,className:`size-6 text-muted-foreground hover:text-destructive hover:bg-destructive/10`,title:`Remove from queue`,children:(0,Q.jsx)(A,{className:`size-3`})})]}),(0,Q.jsx)(`div`,{className:`min-w-0`,children:n})]}),(0,Q.jsx)(F,{open:f,onOpenChange:m,title:l?`Clear Conversation`:`Revert Conversation`,description:l?`This will delete all messages in this session, leaving it completely empty. Are you sure you want to continue?`:`This will delete this message and all messages after it. Are you sure you want to continue?`,confirmLabel:l?`Clear All`:`Revert`,cancelLabel:`Cancel`,onConfirm:()=>{a==null||a()},variant:`destructive`}),(0,Q.jsx)(F,{open:h,onOpenChange:g,title:`Fork Conversation`,description:`This will create a new session with messages up to and including this point. The original session will be unchanged.`,confirmLabel:`Fork`,cancelLabel:`Cancel`,onConfirm:()=>{s==null||s()}})]})}var Lt=L.oneDark;function Rt(e){var t;let n=(t=e.split(`.`).pop())==null?void 0:t.toLowerCase();return{ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,json:`json`,md:`markdown`,css:`css`,html:`html`,py:`python`,go:`go`,rs:`rust`,sh:`bash`,yaml:`yaml`,yml:`yaml`}[n||``]||n||`text`}var zt=(0,$.memo)(function({type:e,content:t,lineNumber:n,newLineNumber:r,language:i}){let a=T(`flex font-mono text-xs`,e===`added`&&`bg-green-500/20`,e===`removed`&&`bg-red-500/20`,e===`context`&&`bg-muted/30`),o=T(`font-bold w-4 select-none`,e===`added`&&`text-green-400`,e===`removed`&&`text-red-400`,e===`context`&&`text-muted-foreground/50`);return(0,Q.jsxs)(`div`,{className:a,children:[(0,Q.jsx)(`span`,{className:`w-10 text-right pr-2 text-muted-foreground select-none border-r border-white/10`,children:n==null?``:n}),(0,Q.jsx)(`span`,{className:`w-10 text-right pr-2 text-muted-foreground select-none border-r border-white/10`,children:r==null?``:r}),(0,Q.jsxs)(`span`,{className:`pl-2 flex-1 whitespace-pre flex`,children:[(0,Q.jsxs)(`span`,{className:o,children:[e===`added`&&`+`,e===`removed`&&`-`,e===`context`&&` `]}),(0,Q.jsx)(V,{theme:Lt,code:t,language:i,children:({tokens:e,getTokenProps:t})=>(0,Q.jsx)(Q.Fragment,{children:e.map((e,n)=>(0,Q.jsx)(`span`,{children:e.map((e,n)=>(0,Q.jsx)(`span`,{...t({token:e})},n))},n))})})]})]})}),Bt=(0,$.memo)(function({hunks:e,path:t,language:n,additions:r,deletions:i}){let[a,s]=(0,$.useState)(!0),c=n||Rt(t),l=o(e=>e.openFilePreview),u=O(e=>e.activeWorkspace);return(0,Q.jsx)(`div`,{className:`visualization-container overflow-x-auto border border-white/10 rounded-md`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`group/path flex items-center gap-2 px-1 bg-muted/50 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`button`,{onClick:()=>s(!a),className:`px-1 py-1 hover:bg-muted rounded`,children:a?(0,Q.jsx)(Ce,{className:`size-3`}):(0,Q.jsx)(x,{className:`size-3`})}),(0,Q.jsx)(z,{className:`size-3`}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{u&&l({workspaceId:u.id,path:t,name:t.split(`/`).pop()||t})},className:`flex items-center gap-1 font-mono pr-2 hover:text-foreground transition-colors cursor-pointer rounded px-1 py-0.5 -mx-1 hover:bg-muted`,title:`Open file preview`,children:[t,(0,Q.jsx)(U,{className:`size-2.5 opacity-0 group-hover/path:opacity-100 transition-opacity`})]}),r!==void 0&&i!==void 0&&(0,Q.jsxs)(`span`,{className:`ml-auto mr-2 text-muted-foreground`,children:[`+`,r,` -`,i]})]}),a&&(0,Q.jsx)(`div`,{style:{backgroundColor:`#282c34`},children:e.map((e,t)=>(0,Q.jsx)(`div`,{className:`divide-y divide-white/5`,children:e.changes.map((e,t)=>(0,Q.jsx)(zt,{...e,language:c},t))},t))})]})})}),Vt=L.oneDark,Ht=20;function Ut(e){var t;let n=(t=e.split(`.`).pop())==null?void 0:t.toLowerCase();return{ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,json:`json`,md:`markdown`,css:`css`,html:`html`,py:`python`,go:`go`,rs:`rust`,sh:`bash`,yaml:`yaml`,yml:`yaml`}[n||``]||n||`text`}var Wt=(0,$.memo)(({content:e,path:t,language:n,created:r,highlightLines:i=[]})=>{let[a,s]=(0,$.useState)(!1),c=o(e=>e.openFilePreview),l=O(e=>e.activeWorkspace),u=()=>{l&&c({workspaceId:l.id,path:t,name:t.split(`/`).pop()||t})},d=n||Ut(t),f=(0,$.useMemo)(()=>new Set(i),[i]),p=(0,$.useMemo)(()=>e.split(`
7
- `).length,[e]);return(0,Q.jsx)(`div`,{className:`visualization-container overflow-x-auto border border-white/10 rounded-md`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`group/path flex items-center gap-2 px-1 bg-muted/50 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`button`,{onClick:()=>s(!a),className:`flex items-center gap-2 px-2 py-1 hover:bg-muted`,children:a?(0,Q.jsx)(Ce,{className:`size-3`}):(0,Q.jsx)(x,{className:`size-3`})}),(0,Q.jsx)(z,{className:`size-3`}),(0,Q.jsxs)(`button`,{type:`button`,onClick:u,className:`flex items-center gap-1 font-mono pr-2 hover:text-foreground transition-colors cursor-pointer rounded px-1 py-0.5 -mx-1 hover:bg-muted`,title:`Open file preview`,children:[t,(0,Q.jsx)(U,{className:`size-2.5 opacity-0 group-hover/path:opacity-100 transition-opacity`})]}),!a&&(0,Q.jsxs)(`span`,{className:`text-xs text-muted-foreground/70`,children:[p,` lines`]}),r===!1?(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 text-warning ml-auto mr-2`,children:[(0,Q.jsx)(ne,{className:`size-3`}),`Overwrote`]}):(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 text-success ml-auto mr-2`,children:[(0,Q.jsx)(_,{className:`size-3`}),`Created`]})]}),(0,Q.jsx)(`div`,{style:{backgroundColor:`#282c34`},children:(0,Q.jsx)(V,{theme:Vt,code:e,language:d,children:({tokens:e,getTokenProps:t})=>(0,Q.jsx)(Q.Fragment,{children:(a?e:e.slice(0,Ht)).map((e,n)=>(0,Q.jsxs)(`div`,{className:`flex font-mono text-xs ${f.has(n+1)?`bg-yellow-500/20`:``}`,children:[(0,Q.jsx)(`span`,{className:`w-10 text-right pr-2 text-muted-foreground select-none border-r border-white/10`,children:n+1}),(0,Q.jsx)(`span`,{className:`pl-2 flex-1 whitespace-pre`,children:e.map((e,n)=>(0,Q.jsx)(`span`,{...t({token:e})},n))})]},n))})})})]})})});function Gt({message:e=`Success`}){return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,Q.jsx)(E,{className:`size-4`}),(0,Q.jsx)(`span`,{className:`break-all`,children:e})]})}var Kt={edit:Oe,plus:y,trash:d,search:ue};function qt({text:e}){let[t,n]=(0,$.useState)(!1);return(0,Q.jsx)(`button`,{onClick:async()=>{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)},className:`text-muted-foreground hover:text-foreground transition-colors`,title:`Copy path`,children:t?(0,Q.jsx)(`span`,{className:`text-success text-xs`,children:`Copied!`}):(0,Q.jsx)(B,{className:`size-3`})})}function Jt({title:e,groups:t,files:n,total:r}){let i=t||(n?[{label:`Files`,files:n||[],icon:void 0}]:[]);return i.length===0?null:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[e&&(0,Q.jsxs)(`div`,{className:`text-sm font-medium text-foreground`,children:[e,r!==void 0&&(0,Q.jsxs)(`span`,{className:`ml-2 text-muted-foreground`,children:[`(`,r,` files)`]})]}),i.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[e.icon&&(0,Q.jsx)(`span`,{className:`flex items-center`,children:(()=>{let t=Kt[e.icon];return(0,Q.jsx)(t,{className:`size-3`})})()}),(0,Q.jsx)(`span`,{children:e.label}),(0,Q.jsxs)(`span`,{className:`text-muted-foreground/50`,children:[`(`,e.files.length,`)`]})]}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-0.5 pl-5`,children:e.files.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs group`,children:[(0,Q.jsx)(z,{className:`size-3 text-muted-foreground shrink-0`}),(0,Q.jsx)(`span`,{className:`font-mono text-foreground/80 truncate`,children:e.path}),e.line!==void 0&&(0,Q.jsxs)(`span`,{className:`text-muted-foreground shrink-0`,children:[`:`,e.line]}),e.action&&(0,Q.jsx)(`span`,{className:T(`text-xs px-1 rounded shrink-0`,e.action===`created`&&`bg-success/20 text-success`,e.action===`modified`&&`bg-warning/20 text-warning`,e.action===`deleted`&&`bg-destructive/20 text-destructive`),children:e.action}),(0,Q.jsx)(qt,{text:e.path})]},t))})]},t))]})}function Yt({command:e,stdout:t,stderr:n,exitCode:r}){return(0,Q.jsxs)(`div`,{className:`visualization-container border border-white/10 rounded-md overflow-hidden`,children:[(0,Q.jsxs)(`div`,{className:`bg-muted px-3 py-2 flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{className:`font-mono text-xs text-muted-foreground truncate flex-1 mr-2`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`$ `}),(0,Q.jsx)(`span`,{className:`text-foreground`,children:e})]}),(0,Q.jsxs)(`span`,{className:`text-xs font-mono px-2 py-0.5 rounded ${r===0?`bg-muted text-muted-foreground`:`bg-red-500/20 text-red-400`}`,children:[`[`,r,`]`]})]}),(t||n)&&(0,Q.jsxs)(`div`,{className:`bg-black px-3 py-2 font-mono text-xs overflow-x-auto`,children:[t&&(0,Q.jsx)(`pre`,{className:`text-gray-300 whitespace-pre-wrap`,children:t}),n&&(0,Q.jsx)(`pre`,{className:`text-red-400 whitespace-pre-wrap mt-1`,children:n})]})]})}var Xt={pending:{icon:Te,color:`text-muted-foreground`},in_progress:{icon:N,color:`text-warning`,animate:!0},completed:{icon:E,color:`text-success`},cancelled:{icon:m,color:`text-destructive`}},Zt={high:{label:`high`,className:`bg-destructive/20 text-destructive`},medium:{label:``,className:``},low:{label:`low`,className:`text-muted-foreground`}};function Qt({title:e,items:t}){if(t.length===0)return null;let n=t.filter(e=>e.status===`completed`).length;return t.filter(e=>e.status===`in_progress`).length,t.filter(e=>e.status===`pending`).length,(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 w-full overflow-hidden`,children:[(e||t.length>0)&&(0,Q.jsxs)(`div`,{className:`text-sm font-medium text-foreground`,children:[e||`Todo List`,(0,Q.jsxs)(`span`,{className:`ml-2 text-muted-foreground`,children:[`(`,t.length,`)`]}),n>0&&(0,Q.jsxs)(`span`,{className:`ml-2 text-success text-xs`,children:[n,` completed`]})]}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-1 w-full`,children:t.map((e,t)=>{let n=Xt[e.status],r=n.icon,i=Zt[e.priority];return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm min-w-0`,children:[(0,Q.jsx)(r,{className:T(`size-4 shrink-0`,n.color,n.animate&&`animate-spin`)}),(0,Q.jsx)(`span`,{className:T(`flex-1 break-all`,e.status===`completed`&&`line-through text-muted-foreground`,e.status===`cancelled`&&`text-muted-foreground`),children:e.content}),i.label&&e.priority===`high`&&(0,Q.jsx)(`span`,{className:T(`text-xs px-1.5 py-0.5 rounded shrink-0`,i.className),children:i.label}),e.priority===`low`&&e.status!==`completed`&&e.status!==`cancelled`&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground shrink-0`,children:i.label})]},t)})})]})}var $t=(0,$.memo)(function({visualization:e}){if(!e)return null;switch(e.type){case`diff`:return(0,Q.jsx)(Bt,{path:e.path,hunks:e.hunks,language:e.language,additions:e.additions,deletions:e.deletions,matchInfo:e.matchInfo});case`diffs`:return(0,Q.jsx)(`div`,{className:`space-y-3`,children:e.items.map((e,t)=>(0,Q.jsx)(Bt,{path:e.path,hunks:e.hunks,language:e.language,additions:e.additions,deletions:e.deletions,matchInfo:e.matchInfo},`${e.path}-${t}`))});case`code`:return(0,Q.jsx)(Wt,{path:e.path,content:e.content,language:e.language,created:e.created,highlightLines:e.highlightLines});case`file-list`:return(0,Q.jsx)(Jt,{title:e.title,groups:e.groups,files:e.files,total:e.total});case`table`:return(0,Q.jsx)(`pre`,{className:`text-xs bg-muted/50 border rounded-md p-2 overflow-x-auto`,children:JSON.stringify(e.rows,null,2)});case`markdown`:return(0,Q.jsx)(`div`,{className:`prose prose-sm dark:prose-invert`,children:e.content});case`none`:return(0,Q.jsx)(Gt,{message:e.message});case`shell-output`:return(0,Q.jsx)(Yt,{command:e.command,stdout:e.stdout,stderr:e.stderr,exitCode:e.exitCode});case`todo-list`:return(0,Q.jsx)(Qt,{title:e.title,items:e.items});default:return null}}),en=1536,tn=(0,$.memo)(function({content:e,className:t}){let[n,r]=(0,$.useState)(!1),i=new Blob([e]).size,a=i>en,o=a?e.slice(0,en)+`
8
- ...`:null;if(!a)return(0,Q.jsx)(`pre`,{className:t,children:e});let s=i>1024*1024?`${(i/(1024*1024)).toFixed(1)} MB`:i>1024?`${(i/1024).toFixed(1)} KB`:`${i} bytes`;return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`pre`,{className:t,children:n?e:o}),(0,Q.jsx)(`button`,{type:`button`,className:`text-xs text-muted-foreground hover:text-foreground mt-1 transition-colors cursor-pointer`,onClick:()=>r(e=>!e),children:n?`Show less`:`Show full output (${s})`})]})});function nn(e){switch(e){case`pending`:return(0,Q.jsx)(Ee,{className:`size-3 text-warning`});case`running`:return(0,Q.jsx)(N,{className:`size-3 text-warning animate-spin`});case`completed`:return(0,Q.jsx)(E,{className:`size-3 text-success`});case`error`:return(0,Q.jsx)(m,{className:`size-3 text-destructive`});case`interrupted`:return(0,Q.jsx)(he,{className:`size-3 text-warning`});default:return null}}function rn(e){if(e&&typeof e==`object`&&`_visualization`in e)return e._visualization}var an=(0,$.memo)(function({part:e,pendingPermissions:t,onPermissionResponse:n,onNavigateToSubagent:r}){var i;let[a,o]=(0,$.useState)(!1),[s,c]=(0,$.useState)(!1),l=e.state,u=l.status,d=(0,$.useMemo)(()=>{if(!a)return``;try{return JSON.stringify(l.input,null,2)}catch{return String(l.input)}},[l.input,a]),f=(0,$.useMemo)(()=>!a||u!==`completed`||!(`output`in l)?null:typeof l.output==`string`?l.output:JSON.stringify(l.output,null,2),[u,l,a]),m=u===`completed`&&`output`in l?rn(l.output):void 0,h=u===`pending`?t.find(t=>t.toolCallId===e.callId):void 0,g=h?typeof((i=h.args)==null?void 0:i.command)==`string`?h.args.command:JSON.stringify(h.args,null,2):null,y=null;if(e.name===`task`){if(`childSessionId`in l&&l.childSessionId)y=l.childSessionId;else if(u===`completed`&&`output`in l){let e=(typeof l.output==`string`?l.output:``).match(/task_id:\s*([a-f0-9-]{36})/i);e&&(y=e[1])}}let b=async()=>{if(`output`in l){let e=typeof l.output==`string`?l.output:JSON.stringify(l.output,null,2);await navigator.clipboard.writeText(e),c(!0),setTimeout(()=>c(!1),2e3)}},C=(()=>{try{let e=JSON.stringify(l.input);return e.length>50?e.slice(0,47)+`...`:e}catch{return String(l.input)}})();return(0,Q.jsxs)(`div`,{className:`my-1`,children:[(0,Q.jsxs)(S,{open:a,onOpenChange:o,children:[(0,Q.jsx)(v,{asChild:!0,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 py-1 cursor-pointer hover:text-foreground transition-colors text-muted-foreground`,children:[a?(0,Q.jsx)(Ce,{className:`size-4 text-muted-foreground`}):(0,Q.jsx)(x,{className:`size-4 text-muted-foreground`}),(0,Q.jsx)(Re,{className:`size-3`}),(0,Q.jsx)(`span`,{className:`text-xs truncate max-w-[120px] sm:max-w-none`,children:e.name}),!a&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground font-mono truncate flex-1 min-w-0 sm:max-w-[200px] hidden sm:block`,children:C}),(0,Q.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[nn(u),y&&r&&(0,Q.jsxs)(p,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 sm:w-auto sm:px-2`,onClick:e=>{e.stopPropagation(),r(y)},title:`View session`,children:[(0,Q.jsx)(U,{className:`size-3`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline ml-1`,children:`View`})]})]})]})}),a&&(0,Q.jsx)(D,{children:(0,Q.jsxs)(`div`,{className:`pl-5 pb-2 flex flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground mb-1`,children:`Input`}),(0,Q.jsx)(tn,{content:d,className:`text-xs bg-background border rounded-md p-2 overflow-x-auto whitespace-pre-wrap break-words`})]}),(u===`running`||u===`completed`)&&y&&r&&(0,Q.jsxs)(p,{variant:`outline`,className:`w-full`,size:`sm`,onClick:()=>r(y),children:[(0,Q.jsx)(U,{className:`size-4`,"data-icon":`inline-start`}),u===`running`?`Watch Subagent`:`View Session`]}),u===`completed`&&f!==null&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,Q.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground`,children:`Output`}),(0,Q.jsx)(p,{variant:`ghost`,size:`icon`,onClick:b,className:`size-6`,children:s?(0,Q.jsx)(_,{className:`size-3 text-success`}):(0,Q.jsx)(B,{className:`size-3`})})]}),(0,Q.jsx)(tn,{content:f,className:`text-xs bg-success/10 border border-success/20 rounded-md p-2 overflow-x-auto whitespace-pre-wrap break-words`})]}),u===`error`&&`error`in l&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground mb-1`,children:`Error`}),(0,Q.jsx)(`pre`,{className:`text-xs bg-destructive/10 border border-destructive/20 rounded-md p-2 overflow-x-auto whitespace-pre-wrap break-words text-destructive`,children:l.error})]})]})})]}),u===`pending`&&h&&(0,Q.jsxs)(`div`,{className:`border border-warning/50 bg-warning/10 rounded-md p-3 flex flex-col gap-3 mt-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(ve,{className:`size-4 text-warning`}),(0,Q.jsx)(`span`,{className:`text-sm font-medium`,children:`Permission Required`})]}),h.message&&(0,Q.jsx)(`p`,{className:`text-sm`,children:h.message}),h.dangerous&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-destructive font-medium`,children:[(0,Q.jsx)(ve,{className:`size-4`}),`This operation is marked as dangerous`]}),g&&(0,Q.jsxs)(S,{children:[(0,Q.jsx)(v,{asChild:!0,children:(0,Q.jsxs)(`button`,{className:`flex items-center gap-2 text-xs text-muted-foreground hover:text-foreground transition-colors w-full text-left`,children:[(0,Q.jsx)(x,{className:`size-3`}),(0,Q.jsx)(`span`,{className:`uppercase tracking-wide`,children:`Command`})]})}),(0,Q.jsx)(D,{children:(0,Q.jsx)(`pre`,{className:`text-xs bg-background border rounded-md p-2 mt-1 overflow-x-auto whitespace-pre-wrap break-words overflow-wrap-break`,children:g})})]}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2 flex-wrap`,children:[(0,Q.jsx)(p,{variant:`outline`,size:`sm`,onClick:()=>n(e.callId,!1,!1),children:`Deny`}),(0,Q.jsx)(p,{variant:`secondary`,size:`sm`,onClick:()=>n(e.callId,!0,!1),children:`Approve`}),(0,Q.jsx)(p,{size:`sm`,onClick:()=>n(e.callId,!0,!0),children:`Always Allow`})]})]}),u===`completed`&&m&&(0,Q.jsx)(`div`,{className:`mt-2`,children:(0,Q.jsx)($t,{visualization:m})})]})},(e,t)=>e.part!==t.part||e.onNavigateToSubagent!==t.onNavigateToSubagent?!1:e.part.state.status===`pending`?e.pendingPermissions.find(t=>t.toolCallId===e.part.callId)===t.pendingPermissions.find(e=>e.toolCallId===t.part.callId):!0),on=60,sn=300,cn=16;function ln(e){if(e.length===0)return!1;let t=e[e.length-1];return ye(t.message)&&t.message.status===`streaming`}function un(e){return e.filter(e=>e.type===`text`).map(e=>e.text).join(``)}function dn(e,t){let n=t.findIndex(t=>t.message.id===e);if(n<0)return null;if(n===0)return e;for(let e=n-1;e>=0;e--){let n=t[e];if(n.message.role===`assistant`&&n.message.status!==`streaming`)return n.message.id}return null}function fn(){return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-foreground bg-muted rounded-lg px-3 py-2 border border-border shadow-sm`,children:[(0,Q.jsx)(Ne,{className:`size-4 animate-pulse`}),(0,Q.jsx)(`span`,{children:`Compacting conversation...`})]})}function pn(){return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-green-700 dark:text-green-400 bg-green-500/15 rounded-lg px-3 py-2 border border-green-500/30 shadow-sm`,children:[(0,Q.jsx)(we,{className:`size-4`}),(0,Q.jsx)(`span`,{children:`Compaction complete`})]})}function mn({message:e,textContent:t,onRetry:n}){return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs uppercase tracking-wide text-destructive ml-3`,children:[(0,Q.jsx)(ve,{className:`size-3`}),`Compaction Failed`]}),(0,Q.jsxs)(`div`,{className:`rounded-2xl px-4 py-3 max-w-full bg-destructive/10 border border-destructive/30 rounded-bl-md`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-destructive/90`,children:t||e.error||`Compaction failed. The conversation could not be summarized.`}),n&&(0,Q.jsxs)(p,{variant:`outline`,size:`sm`,onClick:n,className:`mt-2 h-7 text-xs gap-1.5`,children:[(0,Q.jsx)(_e,{className:`size-3`}),`Retry`]})]})]})}function hn(e,t){var n;return(e==null?void 0:e.split(`/`).pop())||(t==null||(n=t.split(`.`).pop())==null?void 0:n.toLowerCase())||``}function gn({part:e}){let[t,n]=(0,$.useState)(!1),r=e.overflow?`overflow`:e.auto?`auto`:`manual`;return(0,Q.jsxs)(`div`,{className:`flex flex-col items-center py-3`,children:[(0,Q.jsxs)(`button`,{onClick:()=>n(!t),className:`flex items-center gap-2 text-xs text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,children:[t?(0,Q.jsx)(Ce,{className:`size-3`}):(0,Q.jsx)(x,{className:`size-3`}),(0,Q.jsxs)(`span`,{className:`border-b border-dashed border-muted-foreground/40 pb-px`,children:[r===`overflow`?`Context overflow`:r===`auto`?`Auto`:`Manual`,` compaction`]})]}),t&&(0,Q.jsx)(`div`,{className:`mt-2 text-xs text-muted-foreground italic`,children:`Summary available in the assistant message below`})]})}var _n=(0,$.memo)(function({parts:e,pendingPermissions:t,onPermissionResponse:n,onNavigateToSubagent:r,inverted:i=!1,serverUrl:a}){return(0,Q.jsx)(Q.Fragment,{children:[...e].sort((e,t)=>e.createdAt-t.createdAt).map(e=>{switch(e.type){case`text`:return(0,Q.jsx)(`div`,{className:`min-w-0`,children:(0,Q.jsx)(oe,{inverted:i,children:e.text||`...`})},e.id);case`reasoning`:return(0,Q.jsx)(`div`,{className:`visualization-container text-muted-foreground text-sm italic border-l-2 border-muted-foreground/30 pl-3 my-2 wrap-break-word`,children:e.text},e.id);case`tool`:return(0,Q.jsx)(an,{part:e,pendingPermissions:t,onPermissionResponse:n,onNavigateToSubagent:r},e.id);case`image`:return(0,Q.jsx)(`img`,{src:a?mt(a,e.url):e.url,alt:``,className:T(`max-w-full max-h-64 rounded-xl mt-2 object-contain`,i&&`ring-2 ring-white/20`)},e.id);case`file`:{let t=a?mt(a,e.url):e.url,n=hn(e.mimeType,e.filename),r=e.filename||``,o=r.length>30?r.slice(0,27)+`...`:r||`unnamed`;return(0,Q.jsxs)(`a`,{href:t,className:T(`mt-2 p-2 rounded-lg text-sm flex items-center gap-2 transition-colors`,i?`bg-white/15 hover:bg-white/25 text-primary-foreground`:`bg-muted hover:bg-accent`),target:`_blank`,rel:`noopener noreferrer`,children:[(0,Q.jsx)(le,{className:`size-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`truncate`,children:o}),n&&(0,Q.jsx)(`span`,{className:T(`px-1.5 py-0.5 rounded text-[10px] font-semibold uppercase tracking-wide ml-auto shrink-0`,i?`bg-white/25 text-primary-foreground`:`bg-secondary text-secondary-foreground`),children:n}),(0,Q.jsx)(De,{className:`size-3.5 shrink-0 opacity-60`})]},e.id)}default:return null}})})},(e,t)=>{if(e.parts!==t.parts||e.inverted!==t.inverted||e.onPermissionResponse!==t.onPermissionResponse||e.onNavigateToSubagent!==t.onNavigateToSubagent||e.serverUrl!==t.serverUrl)return!1;if(!e.parts.some(e=>e.type===`tool`&&e.state.status===`pending`))return!0;let n=new Set(e.parts.filter(e=>e.type===`tool`).map(e=>e.callId)),r=e.pendingPermissions.filter(e=>n.has(e.toolCallId)),i=t.pendingPermissions.filter(e=>n.has(e.toolCallId));if(r.length!==i.length)return!1;for(let e=0;e<r.length;e++)if(r[e].toolCallId!==i[e].toolCallId)return!1;return!0}),vn=(0,$.memo)(function({item:e,messagesWithParts:t,sessionId:n,pendingPermissions:r,onPermissionResponse:i,onNavigateToSubagent:a,onRemoveFromQueue:o,onRevert:s,onFork:c,isMainActiveSession:l=!1,isCompacting:u=!1,onCompact:d,serverUrl:f}){let p=e.parts.find(e=>e.type===`compaction`);if(ye(e.message)&&e.message.mode===`compact_failed`)return(0,Q.jsx)(mn,{message:e.message,textContent:un(e.parts),onRetry:l&&!u?d:void 0});if(p)return(0,Q.jsx)(gn,{part:p});let m=!e.isQueued&&e.message.role===`user`,h=m?dn(e.message.id,t):null,g=h===e.message.id;return(0,Q.jsx)(It,{message:e.message,textContent:un(e.parts),isQueued:e.isQueued,onRemove:e.isQueued?()=>o(e.queueId):void 0,canRevert:m&&h!==null,onRevert:h?()=>s==null?void 0:s(n,h):void 0,canFork:m&&h!==null,onFork:h?()=>c==null?void 0:c(n,e.message.id):void 0,isClearAll:g,children:e.parts.length===0?(0,Q.jsx)(`span`,{className:`opacity-50`,children:`...`}):(0,Q.jsx)(_n,{parts:e.parts,pendingPermissions:r,onPermissionResponse:i,onNavigateToSubagent:a,inverted:e.message.role===`user`,serverUrl:f})})});function yn({displayItems:e,messagesWithParts:t,sessionId:n,sessionStatus:r,pendingPermissions:i,isCompacting:a=!1,compactionSuccess:o=!1,onClearCompactionSuccess:s,onPermissionResponse:c,onNavigateToSubagent:l,onRemoveFromQueue:u,onRevert:d,onFork:f,onCompact:p,isMainActiveSession:m=!1,autoFollow:h=!0,onAutoScrollChange:g,scrollToBottomRef:_,serverUrl:v}){var y,b;let x=(0,$.useRef)(null),[S,C]=(0,$.useState)(!1),w=(0,$.useRef)(h),T=(0,$.useRef)(e.length),E=(0,$.useRef)(0),D=(0,$.useRef)(!1),O=(0,$.useRef)(!1),k=(0,$.useRef)(``),A=(0,$.useCallback)(e=>{if(e.length===0)return``;let t=e[e.length-1],n=t.parts.filter(e=>e.type===`text`).reduce((e,t)=>e+t.text.length,0);return`${t.message.id}:${ye(t.message)?t.message.status:`n/a`}:${t.parts.length}:${n}`},[]),j=(0,$.useRef)(null),M=(0,$.useRef)(null),N=(0,$.useRef)(new Map),P=(0,$.useRef)(e);P.current=e;let ee=(0,$.useCallback)(e=>{let t=P.current[e];if(!t)return on+cn;if(t.message.role===`assistant`){let e=100;return t.parts.some(e=>{var t,n;return e.type===`text`&&((t=e.text)==null?void 0:t.includes("```"))||e.type===`tool`&&((n=e.state.input)==null?void 0:n.command)})&&(e=180),t.parts.some(e=>e.type===`tool`)&&(e=Math.max(e,150)),t.parts.some(e=>e.type===`compaction`)&&(e=60),t.message.mode===`compact_failed`&&(e=100),Math.min(Math.max(e+cn,on+cn),sn+cn)}let n=t.parts.length>1?80:60;return Math.min(Math.max(n+cn,on+cn),sn+cn)},[]);(0,$.useLayoutEffect)(()=>{let e=x.current;if(!e)return;let t=requestAnimationFrame(()=>{e.querySelectorAll(`[data-index]`).forEach(e=>{let t=e.getAttribute(`data-index`);if(t===null)return;let n=parseInt(t,10);N.current.set(n,e.offsetHeight)})});return()=>cancelAnimationFrame(t)},[e.length]);let F=(0,$.useRef)(null);(0,$.useLayoutEffect)(()=>{let e=x.current;if(!e)return;F.current&&F.current.disconnect();let t=new ResizeObserver(e=>{e.forEach(e=>{let t=e.target,n=t.getAttribute(`data-index`);if(n===null)return;let r=parseInt(n,10),i=t.offsetHeight;N.current.set(r,i)})});return F.current=t,e.querySelectorAll(`[data-index]`).forEach(e=>t.observe(e)),()=>t.disconnect()},[e.length]);let I=Ft({count:e.length,getScrollElement:()=>x.current,estimateSize:ee,overscan:5,getItemKey:t=>{var n,r;let i=e[t];return(n=i==null||(r=i.message)==null?void 0:r.id)==null?`fallback-${t}`:n}});(0,$.useLayoutEffect)(()=>{w.current=h,T.current=e.length,E.current=0,D.current=!1,k.current=``,e.length!==0&&(I.scrollToIndex(e.length-1,{align:`end`}),D.current=!0)},[n]),(0,$.useEffect)(()=>{let e=x.current;if(!e)return;let t=e=>{w.current&&e.deltaY<0&&(w.current=!1,g==null||g(!1))};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[g]);let L=ht(()=>{if(O.current)return;let e=x.current;if(e)if(w.current){let{scrollTop:t,scrollHeight:n,clientHeight:r}=e;n-t-r>0&&(O.current=!0,e.scrollTop=n,requestAnimationFrame(()=>{O.current=!1}))}else{let{scrollTop:t,scrollHeight:n,clientHeight:r}=e;n-t-r<=5&&(w.current=!0,g==null||g(!0))}});(0,$.useLayoutEffect)(()=>{C(a)},[a]);let R=A(e);(0,$.useLayoutEffect)(()=>{let t=e.length,n=T.current,r=t!==n,i=R,a=i!==k.current;k.current=i;let o=t-1,s=0;if(o>=0){var c;s=(c=N.current.get(o))==null?0:c}let l=E.current,u=o>=0&&s>l&&l>0;if(T.current=t,E.current=s,!(t===0||!r&&!a&&!u)){if(n===0&&t>0&&l===0&&!D.current){I.scrollToIndex(t-1,{align:`end`}),D.current=!0;return}w.current&&(x.current.scrollTop=x.current.scrollHeight)}},[e.length,R,I]),(0,$.useEffect)(()=>{var t;let n=I.getVirtualItems(),r=n.length-1;if(r<0)return;let i=n[r],a=(t=x.current)==null?void 0:t.querySelector(`[data-index="${i.index}"]`);if(j.current&&j.current.disconnect(),a&&(M.current=a,!(!ln(e)||!w.current)))return j.current=new ResizeObserver(t=>{w.current&&ln(e)&&requestAnimationFrame(()=>{w.current&&(x.current.scrollTop=x.current.scrollHeight)})}),j.current.observe(a),()=>{j.current&&(j.current.disconnect(),j.current=null)}},[e,I]),(0,$.useEffect)(()=>{if(o){let e=setTimeout(()=>{s==null||s()},3e3);return()=>clearTimeout(e)}},[o,s]),(0,$.useLayoutEffect)(()=>{_&&(_.current=()=>{w.current=!0,O.current=!0,x.current.scrollTop=x.current.scrollHeight,requestAnimationFrame(()=>{O.current=!1})})},[_]),(0,$.useLayoutEffect)(()=>{w.current=h},[h]);let z=I.getVirtualItems();return(0,Q.jsxs)(`div`,{ref:x,className:`flex-1 min-h-0 overflow-y-auto relative chat-transcript-scrollbar`,style:{WebkitOverflowScrolling:`touch`},onScroll:L,children:[S&&(0,Q.jsx)(`div`,{className:`sticky top-0 z-10 px-4 pt-4 pb-1 bg-gradient-to-b from-background via-background/95 to-transparent`,children:(0,Q.jsx)(fn,{})}),o&&(0,Q.jsx)(`div`,{className:`sticky top-0 z-10 px-4 pt-4 pb-1 bg-gradient-to-b from-background via-background/95 to-transparent`,children:(0,Q.jsx)(pn,{})}),r===`closed`&&(0,Q.jsx)(ce,{className:`mx-4 mt-4`,children:(0,Q.jsx)(ie,{children:`This session is archived. You can reopen it from the sidebar.`})}),(0,Q.jsx)(`div`,{className:`relative w-full`,style:{height:`${I.getTotalSize()}px`},children:e.length===0?(0,Q.jsxs)(`div`,{className:`text-center py-16 text-muted-foreground px-4`,children:[(0,Q.jsx)(`p`,{className:`text-lg mb-2`,children:`Start a conversation`}),(0,Q.jsx)(`p`,{className:`text-sm`,children:`Send a message below to begin.`})]}):(0,Q.jsx)(`div`,{className:`absolute top-0 left-0 w-full`,style:{transform:`translateY(${(y=(b=z[0])==null?void 0:b.start)==null?0:y}px)`},children:z.map(r=>{let o=e[r.index];return(0,Q.jsx)(`div`,{"data-index":r.index,ref:I.measureElement,className:`px-4 py-4`,children:(0,Q.jsx)(vn,{item:o,messagesWithParts:t,sessionId:n,pendingPermissions:i,onPermissionResponse:c,onNavigateToSubagent:l,onRemoveFromQueue:u,onRevert:d,onFork:f,isMainActiveSession:m,isCompacting:a,onCompact:p,serverUrl:v})},o.message.id)})})})]})}function bn(e,t,n){let r=e.map(e=>({message:e.message,parts:e.parts,isQueued:!1})),i=t.map(e=>{let t=(e.attachments||[]).map(t=>{var r;let i=n(e.sessionId,t.id,(r=t.accessKey)==null?``:r);return t.kind===`image`?{id:`${e.id}-att-${t.id}`,messageId:e.id,createdAt:e.createdAt,type:`image`,url:i,mimeType:t.mimeType}:{id:`${e.id}-att-${t.id}`,messageId:e.id,createdAt:e.createdAt,type:`file`,url:i,mimeType:t.mimeType||``,filename:t.filename}});return{message:{id:e.id,role:`user`,sessionId:e.sessionId,createdAt:e.createdAt},parts:[...t,...e.content.trim()?[{id:`${e.id}-part`,messageId:e.id,createdAt:e.createdAt,type:`text`,text:e.content}]:[]],isQueued:!0,queueId:e.id}}),a=[...r].sort((e,t)=>e.message.createdAt-t.message.createdAt),o=[...i].sort((e,t)=>e.message.createdAt-t.message.createdAt);return[...a,...o]}function xn({permissions:e,onPermissionResponse:t}){return e.length===0?null:(0,Q.jsxs)(`div`,{className:`border-t border-border bg-muted/30 flex flex-col gap-2 p-4`,style:{overflow:`overlay`},children:[(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground uppercase tracking-wide font-medium`,children:`Pending Requests`}),e.map(e=>{var n;let r=typeof((n=e.args)==null?void 0:n.command)==`string`?e.args.command:JSON.stringify(e.args,null,2);return(0,Q.jsxs)(`div`,{className:`p-3 bg-warning/10 border border-warning/30 rounded-lg flex flex-col gap-2`,children:[(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Q.jsx)(`span`,{className:`text-sm font-medium`,children:e.toolName})}),(0,Q.jsx)(`p`,{className:`text-sm`,children:e.message}),(0,Q.jsxs)(S,{children:[(0,Q.jsx)(v,{asChild:!0,children:(0,Q.jsxs)(`button`,{className:`flex items-center gap-2 text-xs text-muted-foreground hover:text-foreground transition-colors w-full text-left`,children:[(0,Q.jsx)(x,{className:`size-3`}),(0,Q.jsx)(`span`,{className:`uppercase tracking-wide`,children:`Command`})]})}),(0,Q.jsx)(D,{children:(0,Q.jsx)(`pre`,{className:`text-xs bg-background border rounded-md p-2 mt-1 overflow-x-auto whitespace-pre-wrap break-words`,children:r})})]}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2 flex-wrap`,children:[(0,Q.jsx)(p,{variant:`outline`,size:`sm`,onClick:()=>t(e.toolCallId,!1,!1),children:`Deny`}),(0,Q.jsx)(p,{variant:`secondary`,size:`sm`,onClick:()=>t(e.toolCallId,!0,!1),children:`Approve`}),(0,Q.jsx)(p,{size:`sm`,onClick:()=>t(e.toolCallId,!0,!0),children:`Always Allow`})]})]},e.toolCallId)})]})}function Sn({session:e,messagesWithParts:t,queuedMessages:n,preconfigs:r,prompts:i,models:a,defaultModel:o,onSendMessage:s,onRemoveFromQueue:c,onChangePreconfig:l,onChangeModel:u,onChangeVariant:d,pendingPermissions:f,onPermissionResponse:p,onRename:m,usage:h,modelName:g,modelSupportsImage:_,onNavigateToSubagent:v,onNavigateBack:y,isStreaming:b,onInterrupt:x,onRevert:S,onFork:C,onCompact:w,isCompacting:T,compactionSuccess:E,onClearCompactionSuccess:D,serverUrl:O,sdkClient:k,selectedVariant:A,variants:j,inputRef:M,scrollToBottomRef:N,autoFollowToggleRef:P}){let ee=!e.parentId&&e.status===`active`,[F,I]=(0,$.useState)(!0),L=(0,$.useCallback)(()=>{I(e=>{let t=!e;if(t){var n;N==null||(n=N.current)==null||n.call(N)}return t})},[N]);(0,$.useEffect)(()=>{P&&(P.current={toggle:()=>{L()}})},[P,L]);let R=(0,$.useMemo)(()=>{var e;return bn(t,n,(e=k==null?void 0:k.http.attachments.getUrl)==null?((e,t,n)=>`/api/sessions/${encodeURIComponent(e)}/attachments/${encodeURIComponent(t)}/content?key=${encodeURIComponent(n)}`):e)},[t,n,k]),z=(0,$.useMemo)(()=>f.filter(n=>n.sessionId===e.id?!t.some(e=>e.parts.some(e=>e.type===`tool`&&e.callId===n.toolCallId)):!1),[f,e.id,t]);return(0,Q.jsxs)(`div`,{className:`flex flex-col flex-1 min-h-0 relative`,children:[(0,Q.jsx)(Ze,{session:e,preconfigs:r,models:a,defaultModel:o,usage:h,modelName:g,onChangePreconfig:l,onChangeModel:u,onChangeVariant:d,onRename:m,onNavigateBack:y,isStreaming:b,onInterrupt:x,onCompact:w,isCompacting:T,canCompact:t.length>=2,selectedVariant:A,variants:j}),(0,Q.jsxs)(`div`,{className:`relative flex flex-col flex-1 min-h-0`,children:[(0,Q.jsx)(yn,{displayItems:R,messagesWithParts:t,sessionId:e.id,sessionStatus:e.status,pendingPermissions:f,isCompacting:T,compactionSuccess:E,onClearCompactionSuccess:D,onPermissionResponse:p,onNavigateToSubagent:v,onRemoveFromQueue:c,onRevert:S,onFork:C,onCompact:w,isMainActiveSession:ee,autoFollow:F,onAutoScrollChange:I,scrollToBottomRef:N,serverUrl:O}),(0,Q.jsx)(`button`,{onClick:L,className:`absolute bottom-4 right-4 z-50 flex items-center p-1.5 text-xs rounded-full transition-colors cursor-pointer bg-background/80 backdrop-blur-sm hover:bg-background border border-border/50 shadow-sm pointer-events-auto`,title:F?`Auto-follow enabled (Cmd+Shift+F)`:`Auto-follow disabled (Cmd+Shift+F)`,children:F?(0,Q.jsx)(be,{className:`size-3.5`}):(0,Q.jsx)(te,{className:`size-3.5`})})]}),z.length>0&&(0,Q.jsx)(xn,{permissions:z,onPermissionResponse:p}),e.status===`active`&&!e.parentId&&(0,Q.jsx)(ft,{ref:M,onSendMessage:s,disabled:T,workspaceId:e.workspaceId,sdkClient:k,prompts:i,sessionId:e.id,modelSupportsImage:_}),e.parentId&&(0,Q.jsxs)(`div`,{className:`p-4 border-t border-border bg-muted/50 text-center flex items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,Q.jsx)(je,{className:`size-4`}),`This is a subagent session (read-only)`]})]})}function Cn({serverUrl:e,messagesWithParts:t,inputRef:n,sdkClient:r,onRetry:o,onLogout:s,onSendMessage:l,onRemoveFromQueue:u,onChangePreconfig:d,onChangeModel:f,onChangeVariant:m,onPermissionResponse:h,onRename:g,onNavigateToSubagent:_,onNavigateBack:v,onInterrupt:y,onRevert:b,onFork:x,onCompact:S,onClearCompactionSuccess:C,scrollToBottomRef:w,autoFollowToggleRef:T}){var E,D,k;let A=a(e=>e.connected),j=a(e=>e.authError),M=a(e=>e.connectionTimedOut),N=a(e=>e.retryCount),P=a(e=>e.nextRetryIn),ee=a(e=>e.streamingSessionIds),F=c(e=>e.currentSession),I=c(e=>e.queuedMessages),L=c(e=>e.sessionUsage),R=c(e=>e.currentModel),z=c(e=>e.selectedVariant),te=c(e=>e.compactionSuccess),ne=O(e=>e.preconfigs),B=O(e=>e.prompts),V=O(e=>e.models),re=O(e=>e.defaultModel),H=i(e=>e.pendingPermissions),ie=ne.filter(e=>e.mode!==`subagent`),ae=!(F!=null&&F.parentId),U=(E=F==null?void 0:F.compacting)==null?!1:E,oe=e=>{d(e)},se=e=>{m(e)},ce=()=>{y()};if(!A)return M?(0,Q.jsx)(`div`,{className:`flex w-full h-full items-center justify-center bg-background`,children:(0,Q.jsx)(Ve,{serverUrl:e,authError:j,retryCount:N,nextRetryIn:P,onRetry:o,onLogout:s})}):(0,Q.jsxs)(`div`,{className:`flex flex-col w-full h-full items-center justify-center bg-background gap-4`,children:[(0,Q.jsx)(Be,{}),(0,Q.jsx)(p,{variant:`ghost`,size:`sm`,onClick:s,className:`text-muted-foreground`,children:`Change Server`})]});if(!F)return(0,Q.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-center text-muted-foreground px-6`,children:[(0,Q.jsx)(`h2`,{className:`mb-2`,children:`Select or create a session`}),(0,Q.jsx)(`p`,{children:`Choose a session from the sidebar or create a new one to start chatting.`})]});let le=t.filter(e=>e.message.role!==`system`).length>=2,W=V.find(e=>e.id===R);return(0,Q.jsx)(Sn,{inputRef:n,session:F,messagesWithParts:t,queuedMessages:I[F.id]||[],preconfigs:ae?ie:ne,prompts:B,models:V,defaultModel:re,onSendMessage:l,onRemoveFromQueue:u,onChangePreconfig:oe,onChangeModel:f,onChangeVariant:se,selectedVariant:z,variants:W==null?void 0:W.variants,pendingPermissions:H,onPermissionResponse:h,onRename:g,usage:L,modelName:R,modelSupportsImage:(D=W==null||(k=W.capabilities)==null||(k=k.input)==null?void 0:k.image)==null?!1:D,onNavigateToSubagent:_,onNavigateBack:v,isStreaming:ee.has(F.id)||!!F.runningAt,onInterrupt:ce,onRevert:b,onFork:x,onCompact:le?()=>S(F.id):void 0,isCompacting:U,compactionSuccess:te,onClearCompactionSuccess:C,serverUrl:e==null?void 0:e,sdkClient:r,scrollToBottomRef:w,autoFollowToggleRef:T})}function wn(){let e=f(),{chatInputRef:t,scrollToBottomRef:n,autoFollowToggleRef:r}=C(),{sdkClient:i,messagesWithParts:a,serverUrl:o,currentSession:s,isSessionLoading:c,resumeSession:l,revertSession:u,forkSession:d,compactSession:p,removeFromQueue:m,sendChatMessage:h,handlePermissionResponse:g,handleInterruptSession:_,updateSessionPreconfig:v,updateSessionModel:y,updateSessionVariant:b,handleNavigateBack:x,handleRenameSession:S,setCompactionSuccess:w}=e;return c?(0,Q.jsx)(ze,{}):s?(0,Q.jsx)(Cn,{sdkClient:i,inputRef:t,messagesWithParts:a,serverUrl:o,onRetry:e.handleRetry,onLogout:e.handleLogout,onSendMessage:h,onRemoveFromQueue:m,onChangePreconfig:v,onChangeModel:y,onChangeVariant:b,onPermissionResponse:g,onRename:S,onNavigateToSubagent:l,onNavigateBack:x,onInterrupt:_,onRevert:u,onFork:d,onCompact:p,onClearCompactionSuccess:()=>w(!1),scrollToBottomRef:n,autoFollowToggleRef:r}):null}export{wn as t};
@@ -1 +0,0 @@
1
- import{t as e}from"./SessionContent-Jo9ZEids.js";var t=e;export{t as component};
@@ -1 +0,0 @@
1
- import{t as e}from"./SessionContent-Jo9ZEids.js";var t=e;export{t as component};