@vibedeckx/ui-dist 0.3.2 → 0.3.4

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.
@@ -8,7 +8,7 @@ You can add a description to the \`${lC}\` by passing a \`${lT}\` component as a
8
8
 
9
9
  Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${lC}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
10
10
 
11
- For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return $.useEffect(()=>{document.getElementById(e.current?.getAttribute("aria-describedby"))||console.warn(r)},[r,e]),null};function lL({...e}){return(0,O.jsx)(lw,{"data-slot":"alert-dialog",...e})}function lz({...e}){return(0,O.jsx)(lS,{"data-slot":"alert-dialog-portal",...e})}function lO({className:e,...r}){return(0,O.jsx)(lj,{"data-slot":"alert-dialog-overlay",className:(0,ey.cn)("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...r})}function l$({className:e,...r}){return(0,O.jsxs)(lz,{children:[(0,O.jsx)(lO,{}),(0,O.jsx)(lD,{"data-slot":"alert-dialog-content",className:(0,ey.cn)("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e),...r})]})}function lW({className:e,...r}){return(0,O.jsx)("div",{"data-slot":"alert-dialog-header",className:(0,ey.cn)("flex flex-col gap-2 text-center sm:text-left",e),...r})}function lH({className:e,...r}){return(0,O.jsx)("div",{"data-slot":"alert-dialog-footer",className:(0,ey.cn)("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...r})}function lU({className:e,...r}){return(0,O.jsx)(lA,{"data-slot":"alert-dialog-title",className:(0,ey.cn)("text-lg font-semibold",e),...r})}function lq({className:e,...r}){return(0,O.jsx)(lM,{"data-slot":"alert-dialog-description",className:(0,ey.cn)("text-muted-foreground text-sm",e),...r})}function lK({className:e,...r}){return(0,O.jsx)(lF,{className:(0,ey.cn)((0,W.buttonVariants)(),e),...r})}function lV({className:e,...r}){return(0,O.jsx)(lI,{className:(0,ey.cn)((0,W.buttonVariants)({variant:"outline"}),e),...r})}let lY={task:"Task",workspace:"Workspace",agent_session:"Agent session",schedule:"Schedule",schedule_run:"Schedule run"};function lG({projectId:e,currentThreadId:r,threads:s,contextRefs:n,onNewThread:i,onSelectThread:a,onRenameThread:o,onArchiveThread:l,onDeleteThread:c,onOpenContext:d,newThreadPending:u=!1,className:h}){let[f,p]=(0,$.useState)(!0),[m,g]=(0,$.useState)(!0),[x,v]=(0,$.useState)(!1),[_,y]=(0,$.useState)(null),[b,w]=(0,$.useState)(null),[S,j]=(0,$.useState)(""),[C,k]=(0,$.useState)(null),[N,E]=(0,$.useState)(null),[D,R]=(0,$.useState)(new Set),[A,T]=(0,$.useState)(null),M=(0,$.useRef)(new Set),F=(0,$.useRef)(null),P=s.filter(e=>null===e.archived_at),I=!!b&&D.has(`rename:${b.id}`),B=!!N&&D.has(`delete:${N.id}`),L=!!C&&D.has(`archive:${C.id}`);(0,$.useEffect)(()=>{if(!_)return;F.current?.querySelector('[role="menuitem"]')?.focus();let e=e=>{"Escape"===e.key&&y(null)},r=e=>{F.current?.contains(e.target)||y(null)};return document.addEventListener("keydown",e),document.addEventListener("pointerdown",r),()=>{document.removeEventListener("keydown",e),document.removeEventListener("pointerdown",r)}},[_]);let z=async(e,r,s)=>{if(!M.current.has(e)){M.current.add(e),R(r=>new Set(r).add(e)),T(null);try{await r(),s()}catch(e){T(e instanceof Error?e.message:"Project Chat action failed")}finally{M.current.delete(e),R(r=>{let s=new Set(r);return s.delete(e),s})}}};return(0,O.jsxs)("aside",{"data-testid":"project-chat-rail","data-project-chat-column":!0,className:(0,ey.cn)("flex h-full w-[300px] shrink-0 flex-col overflow-hidden border-l border-border bg-muted/10",h),"aria-label":"Project Chat threads and context",children:[(0,O.jsxs)("section",{className:"flex min-h-0 flex-col border-b border-border/70",children:[(0,O.jsxs)("div",{className:"flex h-11 shrink-0 items-center gap-1 px-3",children:[(0,O.jsxs)("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-1.5 rounded px-1 py-1 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>p(e=>!e),"aria-expanded":f,children:[f?(0,O.jsx)(ns,{className:"size-4"}):(0,O.jsx)(a3,{className:"size-4"}),(0,O.jsx)("h2",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Chat Threads"})]}),(0,O.jsx)(W.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"New thread",disabled:u,onClick:()=>void i(),children:(0,O.jsx)(eS,{className:"size-4","aria-hidden":"true"})})]}),f?(0,O.jsxs)("div",{className:"space-y-1 px-2 pb-3",children:[P.slice(0,5).map(e=>{let s=sM(e),n=e.id===r;return(0,O.jsxs)("div",{"data-testid":"thread-row",className:(0,ey.cn)("relative flex items-center rounded-md",n?"bg-accent":"hover:bg-muted"),children:[(0,O.jsx)("button",{type:"button","aria-label":`Open thread: ${s}`,"aria-current":n?"page":void 0,onClick:()=>a(e.id),className:"min-w-0 flex-1 truncate px-2 py-2 text-left text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:s}),(0,O.jsx)(W.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":`Thread actions: ${s}`,"aria-expanded":_===e.id,"aria-haspopup":"menu","aria-controls":_===e.id?`thread-actions-${e.id}`:void 0,onClick:()=>y(r=>r===e.id?null:e.id),children:(0,O.jsx)(lx,{className:"size-4","aria-hidden":"true"})}),_===e.id?(0,O.jsxs)("div",{ref:F,id:`thread-actions-${e.id}`,role:"menu","aria-label":`Actions for ${s}`,className:"absolute right-1 top-9 z-20 w-40 rounded-md border bg-popover p-1 text-popover-foreground shadow-md",children:[(0,O.jsxs)("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-sm hover:bg-muted",onClick:()=>{y(null),T(null),w(e),j(s)},children:[(0,O.jsx)(rg,{className:"size-3.5"})," Rename thread"]}),(0,O.jsxs)("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-sm hover:bg-muted",onClick:()=>{y(null),T(null),k(e)},children:[(0,O.jsx)(sN,{className:"size-3.5"})," Archive thread"]}),(0,O.jsxs)("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-sm text-destructive hover:bg-destructive/10",onClick:()=>{y(null),T(null),E(e)},children:[(0,O.jsx)(rc,{className:"size-3.5"})," Delete thread"]})]}):null]},e.id)}),(0,O.jsx)(W.Button,{type:"button",variant:"ghost",size:"sm","aria-label":"View all threads",className:"w-full",onClick:()=>v(!0),children:"View all"})]}):null]}),(0,O.jsxs)("section",{className:"flex min-h-0 flex-1 flex-col",children:[(0,O.jsxs)("button",{type:"button",className:"flex h-11 shrink-0 items-center gap-1.5 px-4 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",onClick:()=>g(e=>!e),"aria-expanded":m,children:[m?(0,O.jsx)(ns,{className:"size-4"}):(0,O.jsx)(a3,{className:"size-4"}),(0,O.jsx)("h2",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Context"})]}),m?(0,O.jsx)("div",{className:"min-h-0 flex-1 space-y-1 overflow-y-auto px-2 pb-3",children:0===n.length?(0,O.jsx)("p",{className:"px-2 py-4 text-xs text-muted-foreground",children:"Referenced project items appear here."}):n.map(e=>{let r=lY[e.entity_type],s=!e.deleted&&(!e.navigation||!d),n=e.deleted||s,i=e.navigation?"Navigation is unavailable in this view.":"Navigation details are unavailable; refresh the thread and try again.";return(0,O.jsxs)("button",{type:"button",disabled:n,"aria-label":e.deleted?`Deleted ${r.toLocaleLowerCase()}`:s?`Unavailable ${r.toLocaleLowerCase()}`:`Open ${r}: ${e.navigation.label}`,title:s?i:void 0,onClick:()=>d?.(e),className:"flex w-full flex-col rounded-md px-2 py-2 text-left hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-55",children:[(0,O.jsx)("span",{className:"text-sm",children:e.deleted?`Deleted ${r.toLocaleLowerCase()}`:s?`Unavailable ${r.toLocaleLowerCase()}`:`${r} \xb7 ${e.navigation.label}`}),e.deleted?(0,O.jsx)("span",{className:"text-xs text-muted-foreground",children:"Deleted"}):null,s?(0,O.jsx)("span",{className:"text-xs text-muted-foreground",children:i}):null]},`${e.entity_type}:${e.entity_id}`)})}):null]}),(0,O.jsx)(sF,{open:x,onOpenChange:v,projectId:e,onSelectThread:a}),(0,O.jsx)(t8,{open:null!==b,onOpenChange:e=>{e||I||(w(null),T(null))},children:(0,O.jsxs)(rr,{children:[(0,O.jsxs)(rs,{children:[(0,O.jsx)(ri,{children:"Rename Project Chat thread"}),(0,O.jsx)(ra,{children:"Give this conversation a concise project-level title."})]}),(0,O.jsx)(ro,{autoFocus:!0,"aria-label":"Thread title",value:S,onChange:e=>j(e.target.value),onKeyDown:e=>{"Enter"===e.key&&b&&S.trim()&&z(`rename:${b.id}`,()=>o(b.id,S.trim()),()=>w(null))}}),A?(0,O.jsx)("div",{role:"alert",className:"rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:A}):null,(0,O.jsxs)(rn,{children:[(0,O.jsx)(W.Button,{type:"button",variant:"outline",disabled:I,onClick:()=>{w(null),T(null)},children:"Cancel"}),(0,O.jsx)(W.Button,{type:"button",disabled:!S.trim()||I,onClick:()=>{b&&z(`rename:${b.id}`,()=>o(b.id,S.trim()),()=>w(null))},children:"Save title"})]})]})}),(0,O.jsx)(lL,{open:null!==N,onOpenChange:e=>{e||B||(E(null),T(null))},children:(0,O.jsxs)(l$,{children:[(0,O.jsxs)(lW,{children:[(0,O.jsx)(lU,{children:"Delete this Project Chat thread?"}),(0,O.jsx)(lq,{children:"This permanently removes the thread and its persisted conversation."})]}),A?(0,O.jsx)("div",{role:"alert",className:"rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:A}):null,(0,O.jsxs)(lH,{children:[(0,O.jsx)(lV,{disabled:B,children:"Cancel"}),(0,O.jsx)(lK,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",disabled:B,onClick:e=>{e.preventDefault(),N&&z(`delete:${N.id}`,()=>c(N.id),()=>E(null))},children:"Confirm delete"})]})]})}),(0,O.jsx)(lL,{open:null!==C,onOpenChange:e=>{e||L||(k(null),T(null))},children:(0,O.jsxs)(l$,{children:[(0,O.jsxs)(lW,{children:[(0,O.jsx)(lU,{children:"Archive this Project Chat thread?"}),(0,O.jsx)(lq,{children:"The conversation leaves recent selectors but remains available in thread history."})]}),A?(0,O.jsx)("div",{role:"alert",className:"rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:A}):null,(0,O.jsxs)(lH,{children:[(0,O.jsx)(lV,{disabled:L,children:"Cancel"}),(0,O.jsx)(lK,{disabled:L,onClick:e=>{e.preventDefault(),C&&z(`archive:${C.id}`,()=>l(C.id),()=>k(null))},children:"Confirm archive"})]})]})})]})}var lX=e.i(113862);let lJ=(0,ew.default)("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);var lZ="horizontal",lQ=["horizontal","vertical"],l0=$.forwardRef((e,r)=>{var s;let{decorative:n,orientation:i=lZ,...a}=e,o=(s=i,lQ.includes(s))?i:lZ;return(0,O.jsx)(er.div,{"data-orientation":o,...n?{role:"none"}:{"aria-orientation":"vertical"===o?o:void 0,role:"separator"},...a,ref:r})});l0.displayName="Separator",e.s(["Root",()=>l0,"Separator",()=>l0],691102),e.i(691102),(0,sn.cva)("flex w-fit items-stretch [&>*]:focus-visible:z-10 [&>*]:focus-visible:relative [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md has-[>[data-slot=button-group]]:gap-2",{variants:{orientation:{horizontal:"[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",vertical:"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"}},defaultVariants:{orientation:"horizontal"}});var l1=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),l2=$.forwardRef((e,r)=>(0,O.jsx)(er.span,{...e,ref:r,style:{...l1,...e.style}}));l2.displayName="VisuallyHidden";var[l5,l3]=q("Tooltip",[iw]),l4=iw(),l6="TooltipProvider",l7="tooltip.open",[l8,l9]=l5(l6),ce=e=>{let{__scopeTooltip:r,delayDuration:s=700,skipDelayDuration:n=300,disableHoverableContent:i=!1,children:a}=e,o=$.useRef(!0),l=$.useRef(!1),c=$.useRef(0);return $.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,O.jsx)(l8,{scope:r,isOpenDelayedRef:o,delayDuration:s,onOpen:$.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:$.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,n)},[n]),isPointerInTransitRef:l,onPointerInTransitChange:$.useCallback(e=>{l.current=e},[]),disableHoverableContent:i,children:a})};ce.displayName=l6;var ct="Tooltip",[cr,cs]=l5(ct),cn=e=>{let{__scopeTooltip:r,children:s,open:n,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:l}=e,c=l9(ct,e.__scopeTooltip),d=l4(r),[u,h]=$.useState(null),f=ek(),p=$.useRef(0),m=o??c.disableHoverableContent,g=l??c.delayDuration,x=$.useRef(!1),[v,_]=G({prop:n,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(l7))):c.onClose(),a?.(e)},caller:ct}),y=$.useMemo(()=>v?x.current?"delayed-open":"instant-open":"closed",[v]),b=$.useCallback(()=>{window.clearTimeout(p.current),p.current=0,x.current=!1,_(!0)},[_]),w=$.useCallback(()=>{window.clearTimeout(p.current),p.current=0,_(!1)},[_]),S=$.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{x.current=!0,_(!0),p.current=0},g)},[g,_]);return $.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),(0,O.jsx)(iC,{...d,children:(0,O.jsx)(cr,{scope:r,contentId:f,open:v,stateAttribute:y,trigger:u,onTriggerChange:h,onTriggerEnter:$.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:$.useCallback(()=>{m?w():(window.clearTimeout(p.current),p.current=0)},[w,m]),onOpen:b,onClose:w,disableHoverableContent:m,children:s})})};cn.displayName=ct;var ci="TooltipTrigger",ca=$.forwardRef((e,r)=>{let{__scopeTooltip:s,...n}=e,i=cs(ci,s),a=l9(ci,s),o=l4(s),l=$.useRef(null),c=(0,U.useComposedRefs)(r,l,i.onTriggerChange),d=$.useRef(!1),u=$.useRef(!1),h=$.useCallback(()=>d.current=!1,[]);return $.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),(0,O.jsx)(iN,{asChild:!0,...o,children:(0,O.jsx)(er.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...n,ref:c,onPointerMove:K(e.onPointerMove,e=>{"touch"!==e.pointerType&&(u.current||a.isPointerInTransitRef.current||(i.onTriggerEnter(),u.current=!0))}),onPointerLeave:K(e.onPointerLeave,()=>{i.onTriggerLeave(),u.current=!1}),onPointerDown:K(e.onPointerDown,()=>{i.open&&i.onClose(),d.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:K(e.onFocus,()=>{d.current||i.onOpen()}),onBlur:K(e.onBlur,i.onClose),onClick:K(e.onClick,i.onClose)})})});ca.displayName=ci;var co="TooltipPortal",[cl,cc]=l5(co,{forceMount:void 0}),cd=e=>{let{__scopeTooltip:r,forceMount:s,children:n,container:i}=e,a=cs(co,r);return(0,O.jsx)(cl,{scope:r,forceMount:s,children:(0,O.jsx)(Z,{present:s||a.open,children:(0,O.jsx)(eW,{asChild:!0,container:i,children:n})})})};cd.displayName=co;var cu="TooltipContent",ch=$.forwardRef((e,r)=>{let s=cc(cu,e.__scopeTooltip),{forceMount:n=s.forceMount,side:i="top",...a}=e,o=cs(cu,e.__scopeTooltip);return(0,O.jsx)(Z,{present:n||o.open,children:o.disableHoverableContent?(0,O.jsx)(cx,{side:i,...a,ref:r}):(0,O.jsx)(cf,{side:i,...a,ref:r})})}),cf=$.forwardRef((e,r)=>{let s=cs(cu,e.__scopeTooltip),n=l9(cu,e.__scopeTooltip),i=$.useRef(null),a=(0,U.useComposedRefs)(r,i),[o,l]=$.useState(null),{trigger:c,onClose:d}=s,u=i.current,{onPointerInTransitChange:h}=n,f=$.useCallback(()=>{l(null),h(!1)},[h]),p=$.useCallback((e,r)=>{let s,n=e.currentTarget,i={x:e.clientX,y:e.clientY},a=function(e,r){let s=Math.abs(r.top-e.y),n=Math.abs(r.bottom-e.y),i=Math.abs(r.right-e.x),a=Math.abs(r.left-e.x);switch(Math.min(s,n,i,a)){case a:return"left";case i:return"right";case s:return"top";case n:return"bottom";default:throw Error("unreachable")}}(i,n.getBoundingClientRect());l(((s=[...function(e,r,s=5){let n=[];switch(r){case"top":n.push({x:e.x-s,y:e.y+s},{x:e.x+s,y:e.y+s});break;case"bottom":n.push({x:e.x-s,y:e.y-s},{x:e.x+s,y:e.y-s});break;case"left":n.push({x:e.x+s,y:e.y-s},{x:e.x+s,y:e.y+s});break;case"right":n.push({x:e.x-s,y:e.y-s},{x:e.x-s,y:e.y+s})}return n}(i,a),...function(e){let{top:r,right:s,bottom:n,left:i}=e;return[{x:i,y:r},{x:s,y:r},{x:s,y:n},{x:i,y:n}]}(r.getBoundingClientRect())].slice()).sort((e,r)=>e.x<r.x?-1:e.x>r.x?1:e.y<r.y?-1:1*!!(e.y>r.y)),function(e){if(e.length<=1)return e.slice();let r=[];for(let s=0;s<e.length;s++){let n=e[s];for(;r.length>=2;){let e=r[r.length-1],s=r[r.length-2];if((e.x-s.x)*(n.y-s.y)>=(e.y-s.y)*(n.x-s.x))r.pop();else break}r.push(n)}r.pop();let s=[];for(let r=e.length-1;r>=0;r--){let n=e[r];for(;s.length>=2;){let e=s[s.length-1],r=s[s.length-2];if((e.x-r.x)*(n.y-r.y)>=(e.y-r.y)*(n.x-r.x))s.pop();else break}s.push(n)}return(s.pop(),1===r.length&&1===s.length&&r[0].x===s[0].x&&r[0].y===s[0].y)?r:r.concat(s)}(s))),h(!0)},[h]);return $.useEffect(()=>()=>f(),[f]),$.useEffect(()=>{if(c&&u){let e=e=>p(e,u),r=e=>p(e,c);return c.addEventListener("pointerleave",e),u.addEventListener("pointerleave",r),()=>{c.removeEventListener("pointerleave",e),u.removeEventListener("pointerleave",r)}}},[c,u,p,f]),$.useEffect(()=>{if(o){let e=e=>{let r=e.target,s={x:e.clientX,y:e.clientY},n=c?.contains(r)||u?.contains(r),i=!function(e,r){let{x:s,y:n}=e,i=!1;for(let e=0,a=r.length-1;e<r.length;a=e++){let o=r[e],l=r[a],c=o.x,d=o.y,u=l.x,h=l.y;d>n!=h>n&&s<(u-c)*(n-d)/(h-d)+c&&(i=!i)}return i}(s,o);n?f():i&&(f(),d())};return document.addEventListener("pointermove",e),()=>document.removeEventListener("pointermove",e)}},[c,u,o,d,f]),(0,O.jsx)(cx,{...e,ref:a})}),[cp,cm]=l5(ct,{isInside:!1}),cg=(0,et.createSlottable)("TooltipContent"),cx=$.forwardRef((e,r)=>{let{__scopeTooltip:s,children:n,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...l}=e,c=cs(cu,s),d=l4(s),{onClose:u}=c;return $.useEffect(()=>(document.addEventListener(l7,u),()=>document.removeEventListener(l7,u)),[u]),$.useEffect(()=>{if(c.trigger){let e=e=>{let r=e.target;r?.contains(c.trigger)&&u()};return window.addEventListener("scroll",e,{capture:!0}),()=>window.removeEventListener("scroll",e,{capture:!0})}},[c.trigger,u]),(0,O.jsx)(eR,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,O.jsxs)(iA,{"data-state":c.stateAttribute,...d,...l,ref:r,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[(0,O.jsx)(cg,{children:n}),(0,O.jsx)(cp,{scope:s,isInside:!0,children:(0,O.jsx)(l2,{id:c.contentId,role:"tooltip",children:i||n})})]})})});ch.displayName=cu;var cv="TooltipArrow",c_=$.forwardRef((e,r)=>{let{__scopeTooltip:s,...n}=e,i=l4(s);return cm(cv,s).isInside?null:(0,O.jsx)(iF,{...i,...n,ref:r})});c_.displayName=cv,e.s(["Arrow",()=>c_,"Content",()=>ch,"Portal",()=>cd,"Provider",()=>ce,"Root",()=>cn,"Tooltip",()=>cn,"TooltipArrow",()=>c_,"TooltipContent",()=>ch,"TooltipPortal",()=>cd,"TooltipProvider",()=>ce,"TooltipTrigger",()=>ca,"Trigger",()=>ca,"createTooltipScope",()=>l3],517964);var cy=e.i(517964),cy=cy;function cb({delayDuration:e=0,...r}){return(0,O.jsx)(cy.Provider,{"data-slot":"tooltip-provider",delayDuration:e,...r})}function cw({...e}){return(0,O.jsx)(cy.Root,{"data-slot":"tooltip",...e})}function cS({...e}){return(0,O.jsx)(cy.Trigger,{"data-slot":"tooltip-trigger",...e})}function cj({className:e,sideOffset:r=0,children:s,...n}){return(0,O.jsx)(cy.Portal,{children:(0,O.jsxs)(cy.Content,{"data-slot":"tooltip-content",sideOffset:r,className:(0,ey.cn)("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...n,children:[s,(0,O.jsx)(cy.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}(0,ew.default)("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);var cC=e.i(94265),ck=cC;let cN=({className:e,from:r,...s})=>(0,O.jsx)("div",{className:(0,ey.cn)("group flex w-full max-w-[95%] flex-col gap-2","user"===r?"is-user ml-auto justify-end":"is-assistant",e),...s}),cE=({children:e,className:r,...s})=>(0,O.jsx)("div",{className:(0,ey.cn)("is-user:dark flex w-fit max-w-full min-w-0 flex-col gap-2 overflow-hidden text-sm","group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground","group-[.is-assistant]:text-foreground",r),...s,children:e}),cD=(0,$.memo)(({className:e,...r})=>(0,O.jsx)(ck.i,{className:(0,ey.cn)("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),...r}),(e,r)=>e.children===r.children);cD.displayName="MessageResponse";let cR=(0,ew.default)("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]),cA={damping:.7,stiffness:.05,mass:1.25},cT=1e3/60,cM=!1;function cF(e,r){let s=(0,$.useCallback)(r=>(s.current=r,e(r)),r);return s}globalThis.document?.addEventListener("mousedown",()=>{cM=!0}),globalThis.document?.addEventListener("mouseup",()=>{cM=!1}),globalThis.document?.addEventListener("click",()=>{cM=!1});let cP=new Map;function cI(...e){let r={...cA},s=!1;for(let n of e){if("instant"===n){s=!0;continue}"object"==typeof n&&(s=!1,r.damping=n.damping??r.damping,r.stiffness=n.stiffness??r.stiffness,r.mass=n.mass??r.mass)}let n=JSON.stringify(r);return cP.has(n)||cP.set(n,Object.freeze(r)),s?"instant":cP.get(n)}let cB=(0,$.createContext)(null),cL="undefined"!=typeof window?$.useLayoutEffect:$.useEffect;function cz({instance:e,children:r,resize:s,initial:n,mass:i,damping:a,stiffness:o,targetScrollTop:l,contextRef:c,...d}){let u=(0,$.useRef)(null),h=((e={})=>{let[r,s]=(0,$.useState)(!1),[n,i]=(0,$.useState)(!1!==e.initial),[a,o]=(0,$.useState)(!1),l=(0,$.useRef)(null);l.current=e;let c=(0,$.useCallback)(()=>{if(!cM)return!1;let e=window.getSelection();if(!e||!e.rangeCount)return!1;let r=e.getRangeAt(0);return r.commonAncestorContainer.contains(x.current)||x.current?.contains(r.commonAncestorContainer)},[]),d=(0,$.useCallback)(e=>{h.isAtBottom=e,i(e)},[]),u=(0,$.useCallback)(e=>{h.escapedFromLock=e,s(e)},[]),h=(0,$.useMemo)(()=>{let s;return{escapedFromLock:r,isAtBottom:n,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return x.current?.scrollTop??0},set scrollTop(scrollTop){x.current&&(x.current.scrollTop=scrollTop,h.ignoreScrollToTop=x.current.scrollTop)},get targetScrollTop(){if(!x.current||!v.current)return 0;return x.current.scrollHeight-1-x.current.clientHeight},get calculatedTargetScrollTop(){if(!x.current||!v.current)return 0;let{targetScrollTop:r}=this;if(!e.targetScrollTop)return r;if(s?.targetScrollTop===r)return s.calculatedScrollTop;let n=Math.max(Math.min(e.targetScrollTop(r,{scrollElement:x.current,contentElement:v.current}),r),0);return s={targetScrollTop:r,calculatedScrollTop:n},requestAnimationFrame(()=>{s=void 0}),n},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=70}}},[]),f=(0,$.useCallback)((e={})=>{let r;"string"==typeof e&&(e={animation:e}),e.preserveScrollPosition||d(!0);let s=Date.now()+(Number(e.wait)||0),n=cI(l.current,e.animation),{ignoreEscapes:i=!1}=e,a=h.calculatedTargetScrollTop;e.duration instanceof Promise?e.duration.finally(()=>{r=Date.now()}):r=s+(e.duration??0);let o=async()=>{let e=new Promise(requestAnimationFrame).then(()=>{if(!h.isAtBottom)return h.animation=void 0,!1;let{scrollTop:d}=h,u=performance.now(),p=(u-(h.lastTick??u))/cT;if(h.animation||(h.animation={behavior:n,promise:e,ignoreEscapes:i}),h.animation.behavior===n&&(h.lastTick=u),c()||s>Date.now())return o();if(d<Math.min(a,h.calculatedTargetScrollTop)){if(h.animation?.behavior===n){if("instant"===n)return h.scrollTop=h.calculatedTargetScrollTop,o();h.velocity=(n.damping*h.velocity+n.stiffness*h.scrollDifference)/n.mass,h.accumulated+=h.velocity*p,h.scrollTop+=h.accumulated,h.scrollTop!==d&&(h.accumulated=0)}return o()}return r>Date.now()?(a=h.calculatedTargetScrollTop,o()):(h.animation=void 0,h.scrollTop<h.calculatedTargetScrollTop)?f({animation:cI(l.current,l.current.resize),ignoreEscapes:i,duration:Math.max(0,r-Date.now())||void 0}):h.isAtBottom});return e.then(e=>(requestAnimationFrame(()=>{h.animation||(h.lastTick=void 0,h.velocity=0)}),e))};return(!0!==e.wait&&(h.animation=void 0),h.animation?.behavior===n)?h.animation.promise:o()},[d,c,h]),p=(0,$.useCallback)(()=>{u(!0),d(!1)},[u,d]),m=(0,$.useCallback)(({target:e})=>{if(e!==x.current)return;let{scrollTop:r,ignoreScrollToTop:s}=h,{lastScrollTop:n=r}=h;h.lastScrollTop=r,h.ignoreScrollToTop=void 0,s&&s>r&&(n=s),o(h.isNearBottom),setTimeout(()=>{if(h.resizeDifference||r===s)return;if(c()){u(!0),d(!1);return}let e=r>n,i=r<n;if(h.animation?.ignoreEscapes){h.scrollTop=n;return}i&&(u(!0),d(!1)),e&&u(!1),!h.escapedFromLock&&h.isNearBottom&&d(!0)},1)},[u,d,c,h]),g=(0,$.useCallback)(({target:e,deltaY:r})=>{let s=e;for(;!["scroll","auto"].includes(getComputedStyle(s).overflow);){if(!s.parentElement)return;s=s.parentElement}s===x.current&&r<0&&x.current.scrollHeight>x.current.clientHeight&&!h.animation?.ignoreEscapes&&(u(!0),d(!1))},[u,d,h]),x=cF(e=>{x.current?.removeEventListener("scroll",m),x.current?.removeEventListener("wheel",g),e?.addEventListener("scroll",m,{passive:!0}),e?.addEventListener("wheel",g,{passive:!0})},[]),v=cF(e=>{let r;h.resizeObserver?.disconnect(),e&&(h.resizeObserver=new ResizeObserver(([e])=>{let{height:s}=e.contentRect,n=s-(r??s);if(h.resizeDifference=n,h.scrollTop>h.targetScrollTop&&(h.scrollTop=h.targetScrollTop),o(h.isNearBottom),n>=0){let e=cI(l.current,r?l.current.resize:l.current.initial);f({animation:e,wait:!0,preserveScrollPosition:!0,duration:"instant"===e?void 0:350})}else h.isNearBottom&&(u(!1),d(!0));r=s,requestAnimationFrame(()=>{setTimeout(()=>{h.resizeDifference===n&&(h.resizeDifference=0)},1)})}),h.resizeObserver?.observe(e))},[]);return{contentRef:v,scrollRef:x,scrollToBottom:f,stopScroll:p,isAtBottom:n||a,isNearBottom:a,escapedFromLock:r,state:h}})({mass:i,damping:a,stiffness:o,resize:s,initial:n,targetScrollTop:$.useCallback((e,r)=>{let s=y?.targetScrollTop??l;return s?.(e,r)??e},[l])}),{scrollRef:f,contentRef:p,scrollToBottom:m,stopScroll:g,isAtBottom:x,escapedFromLock:v,state:_}=e??h,y=(0,$.useMemo)(()=>({scrollToBottom:m,stopScroll:g,scrollRef:f,isAtBottom:x,escapedFromLock:v,contentRef:p,state:_,get targetScrollTop(){return u.current},set targetScrollTop(targetScrollTop){u.current=targetScrollTop}}),[m,x,p,f,g,v,_]);return(0,$.useImperativeHandle)(c,()=>y,[y]),cL(()=>{f.current&&"visible"===getComputedStyle(f.current).overflow&&(f.current.style.overflow="auto")},[]),$.createElement(cB.Provider,{value:y},$.createElement("div",{...d},"function"==typeof r?r(y):r))}function cO(){let e=(0,$.useContext)(cB);if(!e)throw Error("use-stick-to-bottom component context must be used within a StickToBottom component");return e}(cz||(cz={})).Content=function({children:e,scrollClassName:r,...s}){let n=cO();return $.createElement("div",{ref:n.scrollRef,style:{height:"100%",width:"100%",scrollbarGutter:"stable both-edges"},className:r},$.createElement("div",{...s,ref:n.contentRef},"function"==typeof e?e(n):e))};let c$=({className:e,...r})=>(0,O.jsx)(cz,{className:(0,ey.cn)("relative flex-1 overflow-y-hidden",e),initial:"smooth",resize:"smooth",role:"log",...r}),cW=({className:e,...r})=>(0,O.jsx)(cz.Content,{className:(0,ey.cn)("flex flex-col gap-8 p-4",e),...r}),cH=({className:e,...r})=>{let{isAtBottom:s,scrollToBottom:n}=cO(),i=(0,$.useCallback)(()=>{n()},[n]);return!s&&(0,O.jsx)(W.Button,{className:(0,ey.cn)("absolute bottom-4 left-[50%] translate-x-[-50%] rounded-full",e),onClick:i,size:"icon",type:"button",variant:"outline",...r,children:(0,O.jsx)(cR,{className:"size-4"})})},cU=(0,ew.default)("circle-dot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]),cq=(0,ew.default)("clock-3",[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),cK=(0,ew.default)("message-square-more",[["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"}],["path",{d:"M12 11h.01",key:"z322tv"}],["path",{d:"M16 11h.01",key:"xkw8gn"}],["path",{d:"M8 11h.01",key:"1dfujw"}]]);function cV({operation:e,onOpenSession:r,onViewOutput:s,onRunAgain:n,pendingAction:i,actionError:a}){let{label:o,detail:l}=function(e){switch(e.kind){case"task_create":return{label:"Task created",detail:e.title??e.taskId};case"task_update":return{label:"Task updated",detail:e.title??e.taskId};case"agent_session_create":return{label:"Agent session",detail:e.branch?`${e.target??"workspace"} / ${e.branch}`:e.target??"main workspace"};case"agent_instruction":return{label:"Agent instruction",detail:e.instruction??e.sessionId};case"schedule_run":return{label:"Schedule run",detail:e.runId}}}(e),c=e.failure?.code==="timeout"?{label:"Timed out",Icon:cq,className:"text-amber-600"}:e.failure?.code==="remote_offline"?{label:"Remote offline",Icon:sy,className:"text-destructive"}:e.failure?.code==="deleted_target"?{label:"Deleted target",Icon:sy,className:"text-muted-foreground"}:"completed"===e.status?{label:"Completed",Icon:sJ,className:"text-emerald-600"}:"failed"===e.status?{label:"Failed",Icon:sy,className:"text-destructive"}:"running"===e.status||"resolving"===e.status?{label:"Running",Icon:sj,className:"text-blue-600"}:{label:"Queued",Icon:cU,className:"text-muted-foreground"},d=e.failure?.code==="deleted_target",u="agent_session_create"===e.kind&&e.sessionAvailable&&("running"===e.status||"completed"===e.status)&&!d,h="schedule_run"===e.kind&&e.runAvailable&&("running"===e.status||"completed"===e.status||"failed"===e.status)&&!d,f="schedule_run"===e.kind&&e.runAvailable&&("completed"===e.status||"failed"===e.status)&&!d,p=c.Icon;return(0,O.jsxs)("section",{className:"rounded-lg border bg-card p-3 text-card-foreground","aria-label":`${o}: ${c.label}`,children:[(0,O.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,O.jsxs)("div",{className:"min-w-0",children:[(0,O.jsx)("div",{className:"text-sm font-medium",children:o}),l?(0,O.jsx)("div",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:l}):null]}),(0,O.jsxs)("div",{"data-operation-status":e.status,className:(0,ey.cn)("flex shrink-0 items-center gap-1.5 text-xs font-medium",c.className),children:[(0,O.jsx)(p,{className:(0,ey.cn)("size-3.5",("running"===e.status||"resolving"===e.status)&&"animate-spin"),"aria-hidden":"true"}),c.label]})]}),e.failure?.message?(0,O.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:e.failure.message}):null,"agent_session_create"===e.kind&&u&&r?(0,O.jsx)("div",{className:"mt-3",children:(0,O.jsxs)(W.Button,{type:"button",size:"sm",variant:"outline","aria-busy":"open_session"===i,disabled:null!=i,onClick:()=>r(e),children:["open_session"===i?(0,O.jsx)(sj,{className:"size-3.5 animate-spin"}):(0,O.jsx)(s7,{className:"size-3.5"}),"Open Session"]})}):null,"schedule_run"===e.kind&&(h&&s||f&&n)?(0,O.jsxs)("div",{className:"mt-3 flex flex-wrap gap-2",children:[h&&s?(0,O.jsxs)(W.Button,{type:"button",size:"sm",variant:"outline","aria-busy":"view_output"===i,disabled:null!=i,onClick:()=>s(e),children:["view_output"===i?(0,O.jsx)(sj,{className:"size-3.5 animate-spin"}):(0,O.jsx)(cK,{className:"size-3.5"}),"View Output"]}):null,f&&n?(0,O.jsxs)(W.Button,{type:"button",size:"sm",variant:"outline","aria-busy":"run_again"===i,disabled:null!=i,onClick:()=>n(e),children:["run_again"===i?(0,O.jsx)(sj,{className:"size-3.5 animate-spin"}):(0,O.jsx)(s8,{className:"size-3.5"}),"run_again"===i?"Running again…":"Run Again"]}):null]}):null,a?(0,O.jsx)("p",{role:"alert",className:"mt-2 text-xs text-destructive",children:a}):null]})}let cY=(0,ew.default)("map-pin",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]]);function cG({operation:e,onSelect:r,pendingWorkspaceId:s,actionError:n}){let i="pending"!==e.status;return(0,O.jsxs)("section",{className:"rounded-lg border bg-card p-3 text-card-foreground","aria-label":"Select a workspace for the agent session",children:[(0,O.jsx)("div",{className:"text-sm font-medium",children:"Choose a workspace"}),(0,O.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"This agent session needs one of the project's offered workspaces."}),(0,O.jsx)("div",{className:"mt-3 grid gap-2",children:e.candidates.map(n=>{let a=s===n.id,o=`${n.target} / ${n.branch??"main"}`;return(0,O.jsxs)(W.Button,{type:"button",variant:"outline",className:"h-auto min-h-9 justify-start whitespace-normal text-left","aria-label":`Select workspace: ${o}`,"aria-busy":a,disabled:i||null!=s,onClick:()=>r({requestId:e.requestId,workspaceId:n.id}),children:[a?(0,O.jsx)(sj,{className:"size-3.5 animate-spin"}):(0,O.jsx)(cY,{className:"size-3.5"}),o,a?" · Selecting…":""]},n.id)})}),i?(0,O.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Workspace selection resolved."}):null,n?(0,O.jsx)("p",{role:"alert",className:"mt-2 text-xs text-destructive",children:n}):null]})}function cX(e){try{let r=JSON.parse(e);return"object"!=typeof r||null===r||Array.isArray(r)?null:r}catch{return null}}function cJ(e){if("workspace_selection"===e.kind)switch(e.status){case"pending":return"Waiting for workspace selection";case"resolving":return"Creating agent session";case"running":return"Agent session running";case"completed":return"Agent session completed";case"failed":return"Workspace selection failed"}if("agent_session_create"===e.kind){if("resolving"===e.status)return"Creating agent session";if("running"===e.status)return"Agent session running";if("completed"===e.status)return"Agent session completed"}switch(e.status){case"pending":return"Queued";case"resolving":case"running":return"Running";case"completed":return"Completed";case"failed":return"Failed"}}function cZ({messages:e,contextRefs:r,status:s,activeTurnId:n,pendingApprovalIds:i,queueLength:a,loading:o,hasEarlierMessages:l,loadingEarlierMessages:c,connected:d,error:u,initialDraft:h="",onDraftChange:f,onDraftSent:p,onSend:m,onLoadEarlierMessages:g,onStop:x,onResolveApproval:v,onSelectWorkspace:_,onOpenAgentSession:y,onOpenScheduleRun:b,onRunScheduleAgain:w}){let[S,j]=(0,$.useState)(h),[C,k]=(0,$.useState)(!1),[N,E]=(0,$.useState)(null),[D,R]=(0,$.useState)(new Set),[A,T]=(0,$.useState)(new Set),[M,F]=(0,$.useState)(null),P=(0,$.useRef)(!1),I=(0,$.useRef)(null),B=(0,$.useRef)(new Set),L=(0,$.useRef)(new Set),[z,H]=(0,$.useState)(new Map),[U,q]=(0,$.useState)(new Map),K=(0,$.useMemo)(()=>{let r=new Map,s=new Map;for(let n of e){if("operation"!==n.type)continue;let e=(0,rv.parseProjectChatOperationMessage)(n.content);e&&(r.set(n.id,e),s.set(e.operationId,n.id))}return{byMessageId:r,latestMessageIdByOperation:s}},[e]),V=async(e,r,s)=>{if(!L.current.has(e)){L.current.add(e),H(s=>new Map(s).set(e,r)),q(r=>{let s=new Map(r);return s.delete(e),s});try{await s()}catch(r){q(s=>new Map(s).set(e,r instanceof Error?r.message:"Project operation failed"))}finally{L.current.delete(e),H(r=>{let s=new Map(r);return s.delete(e),s})}}},Y=async e=>{e.preventDefault();let r=S.trim();if(r&&!P.current){P.current=!0,k(!0),F(null);try{await m(r),j(""),p?.(S)}catch(e){F(e instanceof Error?e.message:"Failed to send message")}finally{P.current=!1,k(!1)}}};(0,$.useEffect)(()=>{let e=I.current;e&&("running"!==s||n!==e)&&(I.current=null,E(null))},[n,s]);let G=async()=>{if(n&&!I.current){I.current=n,E(n),F(null);try{await x(n)}catch(e){I.current===n&&F(e instanceof Error?e.message:"Failed to stop generation")}}},X=async(e,r)=>{if(!B.current.has(e)){B.current.add(e),R(r=>new Set(r).add(e)),F(null);try{await v(e,r),T(r=>new Set(r).add(e))}catch(e){F(e instanceof Error?e.message:"Failed to resolve approval")}finally{B.current.delete(e),R(r=>{let s=new Set(r);return s.delete(e),s})}}};return(0,$.useEffect)(()=>{T(e=>{let r=new Set([...e].filter(e=>i.includes(e)));return r.size===e.size?e:r})},[i]),(0,O.jsxs)("div",{className:"flex h-full min-h-0 flex-col",children:[(0,O.jsxs)(c$,{className:"min-h-0",initial:"instant",resize:"smooth","data-testid":"project-chat-scroll",children:[(0,O.jsxs)(cW,{className:"mx-auto w-full max-w-3xl gap-4 px-4 py-5 sm:px-6",children:[l?(0,O.jsx)("div",{className:"flex justify-center",children:(0,O.jsxs)(W.Button,{type:"button",size:"sm",variant:"outline",disabled:c,onClick:()=>void g(),children:[c?(0,O.jsx)(sj,{className:"size-3.5 animate-spin"}):null,"Load earlier messages"]})}):null,o&&0===e.length?(0,O.jsx)("div",{className:"flex justify-center py-12",children:(0,O.jsx)(sj,{className:"size-5 animate-spin text-muted-foreground"})}):null,o||0!==e.length?null:(0,O.jsxs)("div",{className:"mx-auto max-w-md py-20 text-center",children:[(0,O.jsx)("h2",{className:"text-base font-semibold",children:"Start a project conversation"}),(0,O.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"Discuss tasks, schedules, sessions, and work across the whole project."})]}),(0,O.jsxs)("div",{className:"flex w-full flex-col gap-4",children:[e.map(e=>{var s;if("turn_end"===e.type)return(0,O.jsxs)("div",{"data-testid":"turn-boundary",className:"my-2 flex items-center gap-2","aria-label":"Turn complete",children:[(0,O.jsx)("span",{className:"h-px flex-1 bg-border"}),(0,O.jsx)("span",{className:"size-1 rounded-full bg-border"}),(0,O.jsx)("span",{className:"h-px flex-1 bg-border"})]},e.id);if("user"===e.type||"assistant"===e.type)return(0,O.jsx)(cN,{from:e.type,children:(0,O.jsx)(cE,{children:"assistant"===e.type?(0,O.jsx)(cD,{children:e.content}):e.content})},e.id);if("tool_use"===e.type){let r;return(0,O.jsxs)("div",{className:"flex items-center gap-2 rounded-md bg-muted/50 px-3 py-2 text-xs text-muted-foreground",children:[(0,O.jsx)(sA,{className:"size-3.5"}),"Running ",(r=cX(e.content),("string"==typeof r?.toolName?r.toolName:"string"==typeof r?.tool?r.tool:"project tool").replaceAll("_"," ")),"…"]},e.id)}if("tool_result"===e.type){let r;return(0,O.jsxs)("details",{className:"rounded-md border px-3 py-2 text-xs",children:[(0,O.jsx)("summary",{className:"cursor-pointer text-muted-foreground",children:"Tool result"}),(0,O.jsx)("pre",{className:"mt-2 overflow-x-auto whitespace-pre-wrap",children:(r=cX(s=e.content),"string"==typeof r?.output?r.output:"string"==typeof r?.error?r.error:s)})]},e.id)}if("tool_approval_request"===e.type){let r=cX(e.content);if(!r||"string"!=typeof r.approvalId)return null;let s="string"==typeof r.tool?r.tool:"project tool",n=i.includes(r.approvalId)&&!A.has(r.approvalId);return(0,O.jsxs)("div",{className:"rounded-lg border border-amber-500/40 bg-amber-500/10 p-3 text-sm",children:[(0,O.jsxs)("div",{className:"font-medium",children:["Approve ",s.replaceAll("_"," "),"?"]}),(0,O.jsx)("pre",{className:"mt-2 overflow-x-auto whitespace-pre-wrap text-xs text-muted-foreground",children:JSON.stringify(r.input??{},null,2)}),n?(0,O.jsxs)("div",{className:"mt-3 flex gap-2",children:[(0,O.jsxs)(W.Button,{size:"sm","aria-label":`Approve ${s}`,disabled:D.has(r.approvalId),onClick:()=>void X(r.approvalId,!0),children:[(0,O.jsx)(rf.Check,{className:"size-3.5"}),"Approve"]}),(0,O.jsxs)(W.Button,{size:"sm",variant:"outline","aria-label":`Deny ${s}`,disabled:D.has(r.approvalId),onClick:()=>void X(r.approvalId,!1),children:[(0,O.jsx)(t7,{className:"size-3.5"}),"Deny"]})]}):(0,O.jsx)("div",{className:"mt-3 text-xs text-muted-foreground",children:"Approval expired or resolved"})]},e.id)}if("operation"===e.type){let s,n=K.byMessageId.get(e.id);if(!n)return(0,O.jsx)("div",{className:"rounded-md border bg-card px-3 py-2 text-sm text-muted-foreground",children:"Project operation unavailable"},e.id);if(K.latestMessageIdByOperation.get(n.operationId)!==e.id)return null;let i=(s=(e,s)=>r.some(r=>r.entity_type===e&&r.entity_id===s&&r.deleted),"task_create"===n.kind||"task_update"===n.kind?s("task",n.taskId):"agent_session_create"===n.kind||"agent_instruction"===n.kind?s("agent_session",n.sessionId):"schedule_run"===n.kind&&(s("schedule",n.scheduleId)||s("schedule_run",n.runId)))?{...n,failure:{code:"deleted_target",message:"The target no longer exists or is unavailable."}}:n,a=z.get(i.operationId),o=U.get(i.operationId);if("workspace_selection"===i.kind){let e=a?.startsWith("workspace:")?a.slice(10):null;return(0,O.jsxs)("div",{"data-operation-id":i.operationId,"data-operation-kind":i.kind,children:[(0,O.jsx)("p",{role:"status","aria-live":"polite","aria-atomic":"true",className:"sr-only",children:cJ(i)}),(0,O.jsx)(cG,{operation:i,pendingWorkspaceId:e,actionError:o,onSelect:({requestId:e,workspaceId:r})=>{V(i.operationId,"select_workspace",async()=>{H(e=>new Map(e).set(i.operationId,`workspace:${r}`)),await _(e,r)})}})]},`operation:${i.operationId}`)}return(0,O.jsxs)("div",{"data-operation-id":i.operationId,"data-operation-kind":i.kind,children:[(0,O.jsx)("p",{role:"status","aria-live":"polite","aria-atomic":"true",className:"sr-only",children:cJ(i)}),(0,O.jsx)(cV,{operation:i,pendingAction:a,actionError:o,onOpenSession:"agent_session_create"===i.kind&&y?e=>{V(e.operationId,"open_session",()=>y(e.sessionId,e.target??"local",e.branch??null))}:void 0,onViewOutput:"schedule_run"===i.kind&&b?e=>{V(e.operationId,"view_output",()=>b(e.runId,e.scheduleId))}:void 0,onRunAgain:"schedule_run"===i.kind&&w?e=>{V(e.operationId,"run_again",()=>w(e.runId))}:void 0})]},`operation:${i.operationId}`)}if("error"===e.type){let r=cX(e.content),s="string"==typeof r?.message?r.message:e.content;return(0,O.jsxs)("div",{role:"alert",className:"flex gap-2 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:[(0,O.jsx)(s6,{className:"mt-0.5 size-4 shrink-0"}),s]},e.id)}return(0,O.jsx)("div",{className:"rounded-md bg-muted/40 px-3 py-2 text-xs text-muted-foreground",children:e.content},e.id)}),u?(0,O.jsx)("div",{role:"alert",className:"rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:u}):null,M?(0,O.jsx)("div",{role:"alert",className:"rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:M}):null]})]}),(0,O.jsx)(cH,{"aria-label":"Jump to latest message"})]}),(0,O.jsx)("div",{className:"shrink-0 border-t bg-background p-3 sm:px-6",children:(0,O.jsxs)("form",{onSubmit:e=>void Y(e),className:"mx-auto max-w-3xl",children:["running"===s?(0,O.jsxs)("div",{className:"mb-2 flex items-center justify-between gap-3 text-xs text-muted-foreground",children:[(0,O.jsx)("span",{children:a>0?`${a} queued`:"Project Chat is working"}),(0,O.jsxs)(W.Button,{type:"button",variant:"outline",size:"sm","aria-label":"Stop generating",disabled:!n||null!==N,onClick:()=>void G(),children:[(0,O.jsx)(lJ,{className:"size-3"}),N?"Stopping…":"Stop generating"]})]}):null,"queued"===s?(0,O.jsxs)("div",{className:"mb-2 flex items-center gap-2 text-xs text-muted-foreground",role:"status",children:[(0,O.jsx)(lX.Clock,{className:"size-3.5"}),(0,O.jsx)("span",{children:"Waiting to start…"})]}):null,(0,O.jsxs)("div",{className:"relative",children:[(0,O.jsx)(rl,{"aria-label":"Message Project Chat",value:S,onChange:e=>{j(e.target.value),f?.(e.target.value)},onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),e.currentTarget.form?.requestSubmit())},placeholder:d?"Message Project Chat…":"Reconnecting to Project Chat…",disabled:!d||C,rows:2,className:"min-h-20 resize-none pr-16"}),(0,O.jsx)(W.Button,{type:"submit",size:"sm","aria-label":"Send message",disabled:!d||C||!S.trim(),className:"absolute bottom-2 right-2",children:"Send"})]})]})})]})}function cQ({projectId:e,threadId:r,projectName:s,onBack:n,onSelectThread:i,onOpenContext:a,onOpenAgentSession:o,onOpenScheduleRun:l,onRunScheduleAgain:c}){let d=function(e,r){let s=sf(e),[n,i]=(0,$.useState)([]),[a,o]=(0,$.useState)(!1),[l,c]=(0,$.useState)(!1),[d,u]=(0,$.useState)(!1),[h,f]=(0,$.useState)(ld),[p,m]=(0,$.useState)(!1),[g,x]=(0,$.useState)(null),[v,_]=(0,$.useState)(null),[y,b]=(0,$.useState)(null),w=(0,$.useRef)(ld()),S=(0,$.useRef)(e),j=(0,$.useRef)(r),C=(0,$.useRef)(0),k=(0,$.useRef)(0),N=(0,$.useRef)(null),E=(0,$.useRef)(!1),D=(0,$.useRef)(new Map),R=(0,$.useRef)(0),A=(0,$.useRef)(null),T=(0,$.useRef)(new Map);(0,$.useEffect)(()=>(E.current=!0,()=>{E.current=!1}),[]),(0,$.useEffect)(()=>{for(let[s,n]of(S.current=e,j.current=r,T.current))e&&n.identity.projectId===e||T.current.delete(s)},[e,r]);let M=(0,$.useCallback)(async(e,r,s)=>{N.current?.abort();let n=new AbortController;N.current=n;let a=++k.current;try{let o=await rv.api.listProjectChatThreads(e,s,{signal:n.signal});if(C.current!==r||S.current!==e||k.current!==a)return;i(o),x(null)}catch(s){if(n.signal.aborted||C.current!==r||S.current!==e||k.current!==a)return;x(s instanceof Error?s.message:"Failed to list Project Chat threads")}finally{N.current===n&&(N.current=null),C.current===r&&S.current===e&&k.current===a&&o(!1)}},[]);(0,$.useEffect)(()=>{C.current+=1,k.current+=1;let r=C.current;if(N.current?.abort(),N.current=null,!e){i([]),o(!1),x(null);return}return i([]),o(!0),x(null),M(e,r,!1),()=>{k.current+=1,N.current?.abort(),N.current=null}},[M,e]);let F=(0,$.useCallback)(async(e=!1)=>{let r=S.current;r&&await M(r,C.current,e)},[M]),P=(0,$.useCallback)((e,r)=>!!E.current&&S.current===e&&C.current===r&&(k.current+=1,N.current?.abort(),N.current=null,o(!1),!0),[]);(0,$.useEffect)(()=>{R.current+=1;let s=R.current,n=!1,i=!1,a=null,o=0,l=null,d=null,h=e=>{w.current=e,f(e)};if(A.current?.close(),A.current=null,m(!1),u(!1),_(null),b(null),!e||!r){h(ld()),c(!1);return}let p=T.current.get(r);p?.identity.projectId===e?(lu(T.current,p),h({thread:p.thread,messages:p.messages,hasEarlierMessages:p.hasEarlierMessages,earliestSequence:p.earliestSequence,status:p.status,activeTurnId:p.activeTurnId,pendingApprovalIds:p.pendingApprovalIds,queueLength:p.queueLength,contextRefs:p.contextRefs})):(T.current.delete(r),h(ld())),c(!0);let g=()=>!n&&!i&&R.current===s&&S.current===e&&j.current===r,x=()=>{null!==a&&clearTimeout(a),a=null},v=e=>g()&&d===e,y=e=>{null!==e.timeout&&clearTimeout(e.timeout),e.timeout=null,d===e&&(d=null)},C=e=>{y(e),e.controller.abort();let r=e.socket;e.socket=null,r&&A.current===r&&(A.current=null),r?.close()},k=e=>{i=!0,x(),d&&C(d),e&&A.current===e&&(A.current=null,e.close()),m(!1),c(!1),_("Thread not found"),b("thread_not_found")},N=(e=!1)=>{if(!g()||(e&&x(),null!==a))return;let r=e?0:Math.min(1e3*2**o,3e4);e||(o+=1),a=setTimeout(()=>{a=null,D(!0)},r)},E=(e,r)=>{g()&&A.current===e&&(d?.socket===e?C(d):(A.current=null,e.close()),m(!1),c(!1),r&&_(r),N())};async function D(s){if(!g()||d)return;let n={controller:new AbortController,timeout:null,socket:null};d=n,n.timeout=setTimeout(()=>{v(n)&&(C(n),m(!1),c(!1),_("Project Chat connection timed out"),N())},1e4);try{let[a,u]=await Promise.all([rv.api.getProjectChatThread(r,{signal:n.controller.signal}),(0,rv.getFreshToken)(s?{skipCache:!0}:void 0)]);if(!v(n))return;let{thread:f,contextRefs:p}=a;if(f.project_id!==e||f.id!==r){i=!0,C(n),_("Project Chat stream identity mismatch"),c(!1);return}if(!Array.isArray(p)||!p.every(lm)||p.some(e=>e.thread_id!==r))throw Error("Invalid Project Chat thread context");h({...w.current,thread:f,contextRefs:p});let x=new WebSocket((0,rv.getWebSocketUrl)(`/api/project-chat/threads/${r}/stream`,u));n.socket=x,A.current=x;let S=!1;l=null,x.onopen=()=>{g()&&A.current===x&&m(!0)},x.onmessage=s=>{if(g()&&A.current===x)try{let a=JSON.parse(s.data);if(!lf(a))throw Error("invalid frame");if("type"in a&&"project_chat_snapshot"===a.type){let s=a.snapshot;if(!function(e){if(!lf(e)||!lf(e.identity)||!lf(e.thread)||!Array.isArray(e.messages)||!Array.isArray(e.contextRefs))return!1;let r=e.thread.id,s=e.thread.project_id,n=e.thread.user_id;return"string"==typeof r&&"string"==typeof s&&"string"==typeof n&&"string"==typeof e.identity.projectId&&"string"==typeof e.identity.threadId&&"string"==typeof e.identity.userId&&e.identity.threadId===r&&e.identity.projectId===s&&e.identity.userId===n&&e.messages.every(e=>lp(e)&&e.thread_id===r)&&"boolean"==typeof e.hasEarlierMessages&&(null===e.earliestSequence||Number.isSafeInteger(e.earliestSequence))&&e.contextRefs.every(e=>lm(e)&&e.thread_id===r)&&lg(e.status)&&(null===e.activeTurnId||"string"==typeof e.activeTurnId)&&Array.isArray(e.pendingApprovalIds)&&e.pendingApprovalIds.every(e=>"string"==typeof e&&e.length>0)&&Number.isSafeInteger(e.queueLength)&&e.queueLength>=0}(s))throw Error("invalid snapshot");if(s.identity.threadId!==r||s.identity.projectId!==e||s.identity.userId!==f.user_id||s.thread.id!==r||s.thread.project_id!==e||s.thread.user_id!==f.user_id){i=!0,_("Project Chat stream identity mismatch"),c(!1),d===n?C(n):(A.current=null,x.close());return}S=!0,l=Date.now(),y(n),o=0,b(null),_(null),lu(T.current,s),h({thread:s.thread,messages:w.current.thread?.id===r&&null!==w.current.earliestSequence&&null!==s.earliestSequence&&w.current.earliestSequence<s.earliestSequence?lh(w.current.messages,s.messages):s.messages,hasEarlierMessages:w.current.thread?.id===r&&null!==w.current.earliestSequence&&null!==s.earliestSequence&&w.current.earliestSequence<s.earliestSequence?w.current.hasEarlierMessages:s.hasEarlierMessages,earliestSequence:w.current.thread?.id===r&&null!==w.current.earliestSequence&&null!==s.earliestSequence&&w.current.earliestSequence<s.earliestSequence?w.current.earliestSequence:s.earliestSequence,status:s.status,activeTurnId:s.activeTurnId,pendingApprovalIds:s.pendingApprovalIds,queueLength:s.queueLength,contextRefs:s.contextRefs}),c(!1)}else if("JsonPatch"in a){if(!S||!Array.isArray(a.JsonPatch))throw Error("invalid patch frame");let s=function(e,r){let s=e;for(let e of r){if(!lf(e)||"add"!==e.op&&"replace"!==e.op||"string"!=typeof e.path||!lf(e.value))return null;let r=/^\/messages\/(0|[1-9]\d*)$/.exec(e.path);if(r&&"ENTRY"===e.value.type&&lp(e.value.content)){let n=e.value.content,i=Number(r[1]);if(!Number.isSafeInteger(i)||null!==s.thread&&n.thread_id!==s.thread.id)return null;let a=[...s.messages];if("add"===e.op){if(i>a.length||a.some(e=>e.id===n.id))return null;a.push(n),a.sort((e,r)=>e.sequence-r.sequence)}else{let e=a.findIndex(e=>e.id===n.id);if(e<0)return null;a[e]=n}s={...s,messages:a,earliestSequence:a[0]?.sequence??null}}else if("/messages"===e.path&&"MESSAGES"===e.value.type&&Array.isArray(e.value.content)&&e.value.content.every(lp)&&"boolean"==typeof e.value.hasEarlierMessages&&(null===e.value.earliestSequence||Number.isSafeInteger(e.value.earliestSequence))&&e.value.content.every(e=>null===s.thread||e.thread_id===s.thread.id)){let r=null!==s.earliestSequence&&null!==e.value.earliestSequence&&s.earliestSequence<e.value.earliestSequence,n=r?lh(s.messages,e.value.content):e.value.content;s={...s,messages:n,earliestSequence:n[0]?.sequence??null,hasEarlierMessages:r?s.hasEarlierMessages:e.value.hasEarlierMessages}}else if("/status"===e.path&&"STATUS"===e.value.type&&lg(e.value.content))s={...s,status:e.value.content};else if("/activeTurnId"===e.path&&"ACTIVE_TURN"===e.value.type&&(null===e.value.content||"string"==typeof e.value.content))s={...s,activeTurnId:e.value.content};else if("/pendingApprovalIds"===e.path&&"APPROVALS"===e.value.type&&Array.isArray(e.value.content)&&e.value.content.every(e=>"string"==typeof e&&e.length>0))s={...s,pendingApprovalIds:[...new Set(e.value.content)].sort()};else if("/queueLength"===e.path&&"QUEUE"===e.value.type&&Number.isSafeInteger(e.value.content)&&e.value.content>=0)s={...s,queueLength:e.value.content};else{if(!("/contextRefs"===e.path&&"CONTEXT"===e.value.type&&Array.isArray(e.value.content)&&e.value.content.every(lm)&&e.value.content.every(e=>null===s.thread||e.thread_id===s.thread.id)))return null;s={...s,contextRefs:e.value.content}}}return s}(w.current,a.JsonPatch);if(!s)throw Error("invalid patch frame");l=Date.now(),s.thread&&lu(T.current,{identity:{projectId:e,threadId:r,userId:s.thread.user_id},thread:s.thread,messages:s.messages,hasEarlierMessages:s.hasEarlierMessages,earliestSequence:s.earliestSequence,status:s.status,activeTurnId:s.activeTurnId,pendingApprovalIds:s.pendingApprovalIds,queueLength:s.queueLength,contextRefs:s.contextRefs}),h(s)}else if("error"in a){if("Thread not found"===a.error)return void k(x);E(x,"string"==typeof a.error?a.error:"Project Chat stream failed")}else throw Error("unknown frame")}catch{E(x,"Invalid Project Chat stream message")}},x.onerror=()=>{E(x)},x.onclose=()=>{g()&&A.current===x&&(d?.socket===x&&C(d),A.current=null,m(!1),N())}}catch(e){if(!v(n))return;if(C(n),lf(e)&&(404===e.status||e instanceof Error&&"Thread not found"===e.message))return void k();c(!1),_(e instanceof Error?e.message:"Failed to open Project Chat thread"),N()}}let M=()=>{if(!g())return;x(),d&&C(d);let e=A.current;e&&(A.current=null,e.close()),m(!1),D(!0)},F=()=>M(),P=()=>{"visible"===document.visibilityState&&(d||null!==l&&Date.now()-l>4e4)&&M()};return window.addEventListener("online",F),document.addEventListener("visibilitychange",P),D(!1),()=>{n=!0,x(),d&&C(d),window.removeEventListener("online",F),document.removeEventListener("visibilitychange",P);let e=A.current;A.current=null,e?.close()}},[e,r]);let I=(0,$.useCallback)(async e=>{let r=S.current,n=C.current;if(!r)throw Error("No project selected");let a=await s(e);return a.project_id===r&&P(r,n)&&i(e=>[a,...e.filter(e=>e.id!==a.id)]),a},[s,P]),B=(0,$.useCallback)(e=>{if(i(r=>null===e.archived_at?[e,...r.filter(r=>r.id!==e.id)]:r.filter(r=>r.id!==e.id)),w.current.thread?.id===e.id){let r={...w.current,thread:e};w.current=r,f(r)}let r=T.current.get(e.id);r&&lu(T.current,{...r,thread:e})},[]),L=(0,$.useCallback)(async(e,r)=>{let s=S.current,n=C.current,i=r.trim();if(!i)throw Error("Title is required");let a=(D.current.get(e)??0)+1;D.current.set(e,a);let o=await rv.api.updateProjectChatThread(e,{title:i});return s&&o.project_id===s&&D.current.get(e)===a&&P(s,n)&&B(o),o},[P,B]),z=(0,$.useCallback)(async(e,r=!0)=>{let s=S.current,n=C.current,i=(D.current.get(e)??0)+1;D.current.set(e,i);let a=await rv.api.updateProjectChatThread(e,{archived:r});return s&&a.project_id===s&&D.current.get(e)===i&&P(s,n)&&B(a),a},[P,B]),O=(0,$.useCallback)(async e=>{let r=S.current,s=C.current,n=(D.current.get(e)??0)+1;if(D.current.set(e,n),await rv.api.deleteProjectChatThread(e),r&&D.current.get(e)===n&&P(r,s)&&(T.current.delete(e),i(r=>r.filter(r=>r.id!==e)),j.current===e)){R.current+=1,A.current?.close(),A.current=null,m(!1),c(!1);let e=ld();w.current=e,f(e)}},[P]),W=(0,$.useCallback)(async e=>{let r=j.current;if(!r)throw Error("No Project Chat thread selected");let s=e.trim();if(!s)throw Error("Message is required");await rv.api.sendProjectChatMessage(r,s)},[]),H=(0,$.useCallback)(async e=>{let r=j.current;return!!r&&rv.api.stopProjectChatTurn(r,e)},[]),U=(0,$.useCallback)(async(e,r)=>{let s=j.current;if(!s)throw Error("No Project Chat thread selected");await rv.api.approveProjectChatTool(s,e,r)},[]),q=(0,$.useCallback)(async(e,r)=>{let s=j.current;if(!s)throw Error("No Project Chat thread selected");await rv.api.selectProjectChatWorkspace(s,e,r)},[]),K=(0,$.useCallback)(async()=>{let e=j.current,r=w.current;if(e&&r.hasEarlierMessages&&null!==r.earliestSequence){u(!0);try{let s=await rv.api.listProjectChatMessages(e,{beforeSequence:r.earliestSequence});if(j.current!==e||w.current.thread?.id!==e)return;let n=lh(w.current.messages,s.messages),i={...w.current,messages:n,hasEarlierMessages:s.hasMore,earliestSequence:n[0]?.sequence??null};w.current=i,f(i),_(null)}catch(r){j.current===e&&_(r instanceof Error?r.message:"Failed to load earlier messages")}finally{j.current===e&&u(!1)}}},[]);return{...h,threads:n,loading:a||l,threadsLoading:a,threadLoading:l,loadingEarlierMessages:d,isConnected:p,error:v??g,terminalError:y,refetchThreads:F,createThread:I,renameThread:L,archiveThread:z,deleteThread:O,sendMessage:W,stopTurn:H,resolveToolApproval:U,selectWorkspace:q,loadEarlierMessages:K}}(e,r),[u,h]=(0,$.useState)(!0),[f,p]=(0,$.useState)(!1),[m,g]=(0,$.useState)(!1),[x,v]=(0,$.useState)(!1),[_,y]=(0,$.useState)(null),b=(0,$.useRef)(!1),w=(0,$.useRef)(new Map),S=(0,$.useRef)(null),j=(0,$.useRef)(0),C=sM(d.thread),k=d.threads.filter(e=>null===e.archived_at),N=`${e}:${r}`,E=function(){let[e,r]=$.useState(void 0);return $.useEffect(()=>{let e=window.matchMedia("(max-width: 767px)"),s=()=>{r(window.innerWidth<768)};return e.addEventListener("change",s),r(window.innerWidth<768),()=>e.removeEventListener("change",s)},[]),!!e}(),D=e=>{p(e),e||requestAnimationFrame(()=>S.current?.focus())};(0,$.useEffect)(()=>{j.current+=1,b.current=!1,v(!1),y(null),g(!1),p(!1)},[N]);let R=async()=>{if(b.current)return;let r=j.current;b.current=!0,v(!0),y(null);try{let s=await d.createThread();r===j.current&&s.project_id===e&&i(s.id)}catch(e){r===j.current&&y(e instanceof Error?e.message:"Failed to create thread")}finally{r===j.current&&(b.current=!1,v(!1))}},A=e=>{if(e!==r)return;let s=k.find(r=>r.id!==e);s?i(s.id):n()},T=async e=>{let r=j.current;await d.archiveThread(e,!0),r===j.current&&A(e)},M=async e=>{let r=j.current;await d.deleteThread(e),r===j.current&&A(e)};return(0,O.jsxs)("div",{className:"flex h-full min-h-0 flex-col bg-background",children:[(0,O.jsxs)("header",{className:"flex h-12 shrink-0 items-center justify-between gap-3 border-b px-3 sm:px-4",children:[(0,O.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,O.jsx)(W.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"Back to Overview",onClick:n,children:(0,O.jsx)(o9.ArrowLeft,{className:"size-4"})}),(0,O.jsx)(sD,{className:"size-4 shrink-0 text-primary","aria-hidden":"true"}),(0,O.jsxs)("div",{className:"min-w-0",children:[(0,O.jsxs)("div",{className:"truncate text-[11px] text-muted-foreground",children:[s," / Project Chat"]}),(0,O.jsxs)(a4,{open:m,onOpenChange:g,children:[(0,O.jsx)(a6,{asChild:!0,children:(0,O.jsxs)("button",{type:"button","aria-label":`Current thread: ${C}`,className:"flex max-w-[50vw] items-center gap-1 truncate text-sm font-semibold focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,O.jsx)("span",{className:"truncate",children:C}),(0,O.jsx)(ns,{className:"size-3.5 shrink-0"})]})}),(0,O.jsxs)(a7,{align:"start",className:"w-64",children:[k.slice(0,5).map(e=>{let r=sM(e);return(0,O.jsx)(a8,{asChild:!0,children:(0,O.jsx)("button",{type:"button","aria-label":`Switch to thread: ${r}`,onClick:()=>i(e.id),className:"w-full truncate text-left",children:r})},e.id)}),(0,O.jsx)(a8,{asChild:!0,children:(0,O.jsxs)("button",{type:"button",disabled:x,onClick:()=>void R(),className:"w-full border-t",children:[(0,O.jsx)(eS,{className:"size-3.5"}),"New thread"]})})]})]})]})]}),(0,O.jsx)(W.Button,{ref:S,type:"button",variant:"ghost",size:"icon-sm","aria-label":E?"Open threads and context":u?"Hide threads and context":"Show threads and context",onClick:()=>E?p(!0):h(e=>!e),children:E?(0,O.jsx)(lt,{className:"size-4"}):u?(0,O.jsx)(le,{className:"size-4"}):(0,O.jsx)(lt,{className:"size-4"})})]}),_?(0,O.jsx)("div",{role:"alert",className:"border-b border-destructive/40 bg-destructive/10 px-4 py-2 text-sm text-destructive",children:_}):null,(0,O.jsxs)("div",{className:"flex min-h-0 flex-1","data-testid":"project-chat-workbench-columns",children:[(0,O.jsx)("main",{"data-testid":"project-chat-main","data-project-chat-column":!0,className:"min-w-0 flex-1",children:"thread_not_found"===d.terminalError?(0,O.jsx)("div",{className:"flex h-full items-center justify-center p-6 text-center",children:(0,O.jsxs)("div",{children:[(0,O.jsx)("h2",{className:"font-semibold",children:"Thread not found"}),(0,O.jsx)(W.Button,{className:"mt-3",variant:"outline",onClick:n,children:"Back to Overview"})]})}):(0,O.jsx)(cZ,{messages:d.messages,contextRefs:d.contextRefs,status:d.status,activeTurnId:d.activeTurnId,pendingApprovalIds:d.pendingApprovalIds,queueLength:d.queueLength,loading:d.threadLoading,hasEarlierMessages:d.hasEarlierMessages,loadingEarlierMessages:d.loadingEarlierMessages,connected:d.isConnected,error:d.error,initialDraft:w.current.get(N)??"",onDraftChange:e=>{e?w.current.set(N,e):w.current.delete(N)},onDraftSent:e=>{w.current.get(N)===e&&w.current.delete(N)},onSend:d.sendMessage,onLoadEarlierMessages:d.loadEarlierMessages,onStop:d.stopTurn,onResolveApproval:d.resolveToolApproval,onSelectWorkspace:d.selectWorkspace,onOpenAgentSession:o,onOpenScheduleRun:l,onRunScheduleAgain:c},N)}),!E&&u?(0,O.jsx)(lG,{projectId:e,currentThreadId:r,threads:d.threads,contextRefs:d.contextRefs,onNewThread:R,onSelectThread:i,onRenameThread:async(e,r)=>{await d.renameThread(e,r)},onArchiveThread:T,onDeleteThread:M,onOpenContext:a,newThreadPending:x},N):null]}),E?(0,O.jsx)(ls,{open:f,onOpenChange:D,children:(0,O.jsxs)(la,{side:"right","data-testid":"project-chat-mobile-drawer",className:"w-[min(90vw,360px)] gap-0 p-0","aria-label":"Project Chat threads and context",onCloseAutoFocus:e=>{e.preventDefault(),S.current?.focus()},children:[(0,O.jsxs)(lo,{className:"shrink-0 border-b px-4 py-3 pr-14 text-left",children:[(0,O.jsx)(ll,{className:"text-sm",children:"Threads and context"}),(0,O.jsx)(lc,{className:"text-xs",children:"Switch conversations and open referenced project items."})]}),(0,O.jsx)(lG,{projectId:e,className:"min-h-0 w-full flex-1 border-l-0",currentThreadId:r,threads:d.threads,contextRefs:d.contextRefs,onNewThread:R,onSelectThread:e=>{D(!1),i(e)},onRenameThread:async(e,r)=>{await d.renameThread(e,r)},onArchiveThread:T,onDeleteThread:M,onOpenContext:a?e=>{D(!1),a(e)}:void 0,newThreadPending:x},N)]})}):null]})}function c0(e){return e?"target-not-found"===e.error?e.requestedTarget:e.target:null}function c1(e){let r=[],s=`vibedeckx:mergeTarget:${e}:`;try{for(let e=0;e<localStorage.length;e+=1){let n=localStorage.key(e);if(!n?.startsWith(s))continue;let i=localStorage.getItem(n);i&&r.push({key:n,branch:n.slice(s.length),target:i})}}catch{}return r}let c2=new Map,c5=new Set(["working","main-running"]);function c3(e,r){return`vibedeckx:schedule-rerun:v2:${encodeURIComponent(e)}:${encodeURIComponent(r)}`}function c4(e){try{window.sessionStorage.removeItem(e)}catch{}}var ck=cC;let c6=(0,ew.default)("columns-3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]),c7=(0,ew.default)("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),c8={sm:{box:"size-4 rounded",text:"text-[9.5px]",icon:"size-2.5",letters:1},md:{box:"size-5 rounded-[5px]",text:"text-[9px]",icon:"size-3",letters:2}};function c9({name:e,size:r="sm",className:s}){let n=c8[r],i=s_(e,n.letters);return(0,O.jsx)("span",{"aria-hidden":"true",className:(0,ey.cn)("grid shrink-0 place-items-center bg-primary/14 font-mono font-semibold leading-none tracking-[-0.02em] text-primary",n.box,n.text,s),children:i||(0,O.jsx)(oY,{className:(0,ey.cn)(n.icon,"text-primary")})})}let de=(0,ew.default)("check-check",[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]]);function dt({info:e,repositoryLabel:r,onClick:s}){let n=function(e,r){if("target-not-found"===e.error){let s=`Target branch '${e.requestedTarget}' not found — pick a new target or reset to default`;return r?`${s} \xb7 ${r}`:s}let s=["merged"===e.status?`Merged into ${e.target}`:"no-unique-commits"===e.status?`In sync with ${e.target}`:`${e.unmergedCount} commit${1!==e.unmergedCount?"s":""} not in ${e.target}`];return e.dirty&&s.push("uncommitted changes"),r&&s.push(r),s.join(" · ")}(e,r);return(0,O.jsxs)(cw,{children:[(0,O.jsx)(cS,{asChild:!0,children:(0,O.jsxs)("button",{onClick:e=>{e.stopPropagation(),s()},"aria-label":n,className:"relative shrink-0 flex items-center justify-center h-4 min-w-4 px-0.5 rounded hover:bg-muted",children:["target-not-found"===e.error?(0,O.jsx)(s6,{className:"h-3 w-3 text-amber-500"}):"merged"===e.status?(0,O.jsx)(rf.Check,{className:"h-3 w-3 text-muted-foreground/70"}):"no-unique-commits"===e.status?(0,O.jsx)(de,{className:"h-3 w-3 text-emerald-500"}):(0,O.jsx)("span",{className:"text-[10px] font-mono leading-none text-amber-500",children:e.unmergedCount}),!e.error&&e.dirty&&(0,O.jsx)("span",{className:"absolute -top-0.5 -right-0.5 h-1.5 w-1.5 rounded-full bg-orange-400"})]})}),(0,O.jsx)(cj,{side:"right",children:n})]})}let dr=(0,ew.default)("git-merge",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]]);function ds({projectId:e,branch:r,currentTarget:s,onTargetChange:n,onTargetReset:i,onDelete:a}){let[o,l]=(0,$.useState)(null),c=async()=>{null!==o||l((await rv.api.getProjectBranches(e)).filter(e=>e!==r))};return(0,O.jsxs)(a4,{children:[(0,O.jsx)(a6,{asChild:!0,children:(0,O.jsx)("button",{onClick:e=>e.stopPropagation(),className:"shrink-0 p-0.5 rounded opacity-0 group-hover:opacity-100 data-[state=open]:opacity-100 hover:bg-muted transition-all",title:"Workspace menu",children:(0,O.jsx)(lx,{className:"h-3 w-3"})})}),(0,O.jsxs)(a7,{side:"right",align:"start",children:[(0,O.jsxs)(on,{children:[(0,O.jsxs)(oi,{onPointerEnter:c,onFocus:c,children:[(0,O.jsx)(dr,{className:"h-3.5 w-3.5 mr-1.5"}),"Compare against"]}),(0,O.jsxs)(oa,{children:[null===o?(0,O.jsx)(a8,{disabled:!0,children:"Loading…"}):0===o.length?(0,O.jsx)(a8,{disabled:!0,children:"No other branches"}):o.map(e=>(0,O.jsx)(a9,{checked:e===s,onCheckedChange:()=>n(e),children:(0,O.jsx)("span",{className:"font-mono text-xs",children:e})},e)),(0,O.jsx)(os,{}),(0,O.jsx)(a8,{onClick:i,children:(0,O.jsx)("span",{className:"text-xs",children:"Default branch (auto)"})})]})]}),(0,O.jsxs)(a8,{onClick:a,className:"text-destructive focus:text-destructive",children:[(0,O.jsx)(rc,{className:"h-3.5 w-3.5 mr-1.5"}),"Delete worktree"]})]})]})}function dn({status:e}){let r="relative h-[7px] w-[7px] rounded-full shrink-0";return e&&"idle"!==e?"working"===e?(0,O.jsx)("span",{className:(0,ey.cn)(r,"bg-blue-500"),children:(0,O.jsx)("span",{className:"absolute inset-[-2px] rounded-full bg-blue-500",style:{animation:"status-dot-pulse 1.6s ease-out infinite",opacity:.5}})}):"main-running"===e?(0,O.jsx)("span",{className:(0,ey.cn)(r,"bg-violet-500"),children:(0,O.jsx)("span",{className:"absolute inset-[-2px] rounded-full bg-violet-500",style:{animation:"status-dot-pulse 1.6s ease-out infinite",opacity:.5}})}):"main-completed"===e?(0,O.jsx)("span",{className:(0,ey.cn)(r,"bg-emerald-500")}):"stopped"===e?(0,O.jsx)("span",{className:(0,ey.cn)(r,"bg-amber-500")}):(0,O.jsx)("span",{className:(0,ey.cn)(r,"bg-lime-400")}):(0,O.jsx)("span",{className:(0,ey.cn)(r,"bg-muted-foreground/40")})}function di({status:e}){let r="relative h-[7px] w-[7px] rounded-full shrink-0";return"running"===e?(0,O.jsx)("span",{className:(0,ey.cn)(r,"bg-blue-500"),children:(0,O.jsx)("span",{className:"absolute inset-[-2px] rounded-full bg-blue-500",style:{animation:"status-dot-pulse 1.6s ease-out infinite",opacity:.5}})}):"error"===e?(0,O.jsx)("span",{className:(0,ey.cn)(r,"bg-red-500")}):(0,O.jsx)("span",{className:(0,ey.cn)(r,"bg-lime-400")})}function da({schedule:e}){let r="relative h-[7px] w-[7px] rounded-full shrink-0";if(e.running)return(0,O.jsx)("span",{className:(0,ey.cn)(r,"bg-blue-500"),children:(0,O.jsx)("span",{className:"absolute inset-[-2px] rounded-full bg-blue-500",style:{animation:"status-dot-pulse 1.6s ease-out infinite",opacity:.5}})});let s=e.last_run;return s&&"skipped"!==s.status?"completed"===s.status?(0,O.jsx)("span",{className:(0,ey.cn)(r,"bg-emerald-500")}):"failed"===s.status||"timeout"===s.status||"killed"===s.status?(0,O.jsx)("span",{className:(0,ey.cn)(r,"bg-red-500")}):(0,O.jsx)("span",{className:(0,ey.cn)(r,"bg-blue-500")}):(0,O.jsx)("span",{className:(0,ey.cn)(r,"bg-muted-foreground/40")})}function dl({children:e,className:r}){return(0,O.jsx)("div",{className:(0,ey.cn)("px-2 pt-2.5 pb-1.5 border-t border-border/50 first:border-t-0",r),children:e})}function dc({children:e,action:r}){return(0,O.jsxs)("div",{className:"flex items-center justify-between px-2 py-1 text-[10px] font-semibold uppercase tracking-[0.06em] text-muted-foreground/80",children:[(0,O.jsx)("span",{children:e}),r]})}function dd({icon:e,label:r,active:s,disabled:n,onClick:i}){return(0,O.jsxs)("button",{onClick:i,disabled:n,className:(0,ey.cn)("relative w-full flex items-center gap-[9px] rounded-md px-2 py-[5px] text-[12.5px] font-normal transition-colors",n&&"text-muted-foreground/40 cursor-not-allowed",!n&&!s&&"text-foreground/75 hover:bg-muted hover:text-foreground",s&&"bg-card text-foreground font-medium shadow-sm"),children:[s&&(0,O.jsx)("span",{className:"absolute -left-2 top-1.5 bottom-1.5 w-[2px] rounded-full bg-primary"}),(0,O.jsx)("span",{className:(0,ey.cn)("shrink-0 flex items-center justify-center",s?"text-foreground":"text-muted-foreground"),children:e}),(0,O.jsx)("span",{className:"truncate text-left",children:r})]})}function du({activeView:e,onViewChange:r,worktrees:s,selectedBranch:n,onBranchChange:i,currentProject:a,onCreateWorktreeOpen:o,onDeleteWorktree:l,mergeStatuses:c,mergeDefaultTarget:d,mergeRepositoryLabel:u,onMergeTargetChange:h,onMergeBadgeClick:f,workspaceStatuses:p,residentSessions:m,selectedSessionId:g,onResidentSessionSelect:x,hasProject:v=!0,projects:_,onSelectProject:y,onCreateProjectOpen:b,schedules:w,selectedScheduleId:S,onScheduleSelect:j,onCreateScheduleOpen:C}){let k=(0,$.useRef)(null);return(0,$.useEffect)(()=>{k.current?.scrollIntoView({block:"nearest"})},[a?.id,_]),(0,O.jsxs)("nav",{className:"w-[220px] border-r border-border bg-sidebar flex flex-col overflow-hidden",children:[(0,O.jsxs)(dl,{children:[(0,O.jsx)(dc,{action:(0,O.jsx)("button",{onClick:b,className:"p-0.5 rounded hover:bg-muted hover:text-foreground transition-colors text-muted-foreground",title:"Create new project",children:(0,O.jsx)(eS,{className:"h-3 w-3"})}),children:"Projects"}),_&&_.length>0?(0,O.jsx)(cb,{delayDuration:300,children:(0,O.jsx)("div",{className:"flex flex-col gap-0.5 max-h-40 overflow-y-auto mt-0.5",children:_.map(s=>{let n=a?.id===s.id,i=n&&("project-info"===e||"project-chat"===e);return(0,O.jsxs)(cw,{children:[(0,O.jsx)(cS,{asChild:!0,children:(0,O.jsxs)("button",{ref:n?k:void 0,onClick:()=>{y?.(s),r("project-info")},className:(0,ey.cn)("relative w-full flex items-center gap-1.5 rounded-md px-2 py-[5px] text-[12.5px] transition-colors min-w-0","hover:bg-muted hover:text-foreground",n?"text-foreground font-medium":"text-foreground/75"),children:[i&&(0,O.jsx)("span",{className:"absolute -left-2 top-1.5 bottom-1.5 w-[2px] rounded-full bg-primary"}),(0,O.jsx)(c9,{name:s.name}),(0,O.jsx)("span",{className:"truncate flex-1 text-left",children:s.name}),n&&(0,O.jsx)(r_,{className:"h-3 w-3 shrink-0 text-muted-foreground ml-auto"})]})}),(0,O.jsx)(cj,{side:"right",children:s.name})]},s.id)})})}):(0,O.jsx)("span",{className:"block px-2 mt-1 text-[11.5px] text-muted-foreground/60",children:"No projects yet"})]}),(0,O.jsxs)(dl,{children:[(0,O.jsx)(dc,{children:"Navigation"}),(0,O.jsx)("div",{className:"flex flex-col gap-0.5 mt-0.5",children:(0,O.jsx)(dd,{icon:(0,O.jsx)(sQ,{className:"h-3.5 w-3.5"}),label:"Tasks",active:"tasks"===e&&v,disabled:!v,onClick:()=>{v&&(i?.(null),r("tasks"))}})})]}),(0,O.jsxs)(dl,{children:[(0,O.jsx)(dc,{action:a?(0,O.jsx)("button",{onClick:C,className:"p-0.5 rounded hover:bg-muted hover:text-foreground transition-colors text-muted-foreground",title:"Create scheduled task",children:(0,O.jsx)(eS,{className:"h-3 w-3"})}):void 0,children:"Schedule"}),a&&w&&w.length>0&&(0,O.jsx)("div",{className:"flex flex-col gap-px",children:w.map(r=>{let s="schedules"===e&&S===r.id;return(0,O.jsxs)("button",{onClick:()=>j?.(r.id),className:(0,ey.cn)("w-full min-w-0 flex items-center gap-2 rounded-[5px] px-2 py-1 text-[11.5px] transition-colors overflow-hidden",!s&&"text-foreground/80 hover:bg-muted",s&&"bg-accent text-accent-foreground font-medium",!r.enabled&&"opacity-50"),children:[(0,O.jsx)(da,{schedule:r}),(0,O.jsx)("span",{className:"truncate text-left flex-1",children:r.name}),"local"!==r.target&&(0,O.jsx)(ry,{className:"h-2.5 w-2.5 shrink-0 text-violet-500","aria-label":"remote"})]},r.id)})}),a&&w&&0===w.length&&(0,O.jsx)("span",{className:"block px-2 mt-1 text-[11.5px] text-muted-foreground/60",children:"No scheduled tasks"})]}),(0,O.jsxs)(dl,{className:"flex-1 overflow-y-auto",children:[(0,O.jsx)(dc,{action:a?(0,O.jsx)("button",{onClick:o,className:"p-0.5 rounded hover:bg-muted hover:text-foreground transition-colors text-muted-foreground",title:"Create new worktree",children:(0,O.jsx)(eS,{className:"h-3 w-3"})}):void 0,children:"Workspace"}),a&&s&&s.length>0&&(0,O.jsx)(O.Fragment,{children:(0,O.jsx)(cb,{delayDuration:300,children:(0,O.jsx)("div",{className:"flex flex-col gap-px",children:s.map(s=>{var o;let v="workspace"===e&&n===s.branch,_=null===s.branch?"":s.branch,y=m?.get(_)??[],b=(o=p?.get(_),y.length>0&&"main-running"!==o&&"main-completed"!==o?"idle":o);return(0,O.jsxs)("div",{className:(0,ey.cn)("min-w-0 rounded-[3px]",v&&"bg-accent"),children:[(0,O.jsxs)("div",{className:"group relative flex items-center min-w-0 gap-0.5 pr-1",children:[(0,O.jsxs)(cw,{children:[(0,O.jsx)(cS,{asChild:!0,children:(0,O.jsxs)("button",{onClick:()=>{i?.(s.branch),r("workspace")},className:(0,ey.cn)("flex-1 min-w-0 flex items-center gap-2 rounded-[3px] pl-2 pr-1 py-1 font-mono text-[11.5px] transition-colors overflow-hidden",!v&&"text-foreground/80 hover:bg-muted",v&&"text-accent-foreground font-medium"),children:[(0,O.jsx)(dn,{status:b}),(0,O.jsx)("span",{className:"truncate text-left",children:s.branch??"main"})]})}),(0,O.jsx)(cj,{side:"right",children:s.branch??"main"})]}),null!==s.branch&&c?.get(s.branch)&&(0,O.jsx)(dt,{info:c.get(s.branch),repositoryLabel:u,onClick:()=>f?.(s.branch)}),null!==s.branch&&a&&(0,O.jsx)(ds,{projectId:a.id,branch:s.branch,currentTarget:c0(c?.get(s.branch))??d??null,onTargetChange:e=>h?.(s.branch,e),onTargetReset:()=>h?.(s.branch,null),onDelete:()=>l?.(s)})]}),y.length>0&&(0,O.jsx)("div",{className:"ml-4 mt-px flex flex-col gap-px",children:y.map(r=>{let s="workspace"===e&&g===r.id;return(0,O.jsxs)(cw,{children:[(0,O.jsx)(cS,{asChild:!0,children:(0,O.jsxs)("button",{onClick:()=>x?.(r),className:(0,ey.cn)("min-w-0 flex items-center gap-1.5 rounded-[3px] py-0.5 pl-1.5 pr-2 font-mono text-[11px] transition-colors",!s&&"text-foreground/70 hover:text-foreground",s&&"text-accent-foreground font-medium"),children:[(0,O.jsx)("span",{className:"shrink-0 text-muted-foreground/70",children:"└"}),(0,O.jsx)(di,{status:r.status}),(0,O.jsx)("span",{className:"truncate text-left",children:r.title})]})}),(0,O.jsx)(cj,{side:"right",children:r.title})]},r.id)})})]},s.branch??"__main__")})})})}),(!s||0===s.length)&&(0,O.jsx)("div",{className:"mt-0.5",children:(0,O.jsx)(dd,{icon:(0,O.jsx)(c6,{className:"h-3.5 w-3.5"}),label:"Workspace",active:"workspace"===e,onClick:()=>r("workspace")})})]}),(0,O.jsx)(dl,{children:(0,O.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,O.jsx)(dd,{icon:(0,O.jsx)(ry,{className:"h-3.5 w-3.5"}),label:"Remote Servers",active:"remote-servers"===e,onClick:()=>r("remote-servers")}),(0,O.jsx)(dd,{icon:(0,O.jsx)(c7,{className:"h-3.5 w-3.5"}),label:"Settings",active:"settings"===e,onClick:()=>r("settings")})]})})]})}function dh({title:e,count:r,description:s,actions:n,className:i}){return(0,O.jsxs)("div",{className:(0,ey.cn)("flex items-center justify-between gap-4 px-5 pt-[14px] pb-3 border-b border-border bg-background flex-shrink-0",i),children:[(0,O.jsxs)("div",{className:"min-w-0",children:[(0,O.jsxs)("h1",{className:"flex items-baseline gap-2.5 m-0 text-[17px] font-semibold tracking-[-0.018em] text-foreground",children:[(0,O.jsx)("span",{className:"truncate",children:e}),void 0!==r&&(0,O.jsx)("span",{className:"font-mono text-[11.5px] font-medium text-muted-foreground/80 tracking-normal",children:r})]}),s&&(0,O.jsx)("p",{className:"text-[11.5px] text-muted-foreground mt-0.5",children:s})]}),n&&(0,O.jsx)("div",{className:"flex items-center gap-2",children:n})]})}function df({children:e,className:r}){return(0,O.jsx)("div",{className:(0,ey.cn)("flex items-center gap-1.5 px-5 py-2 border-b border-border bg-background flex-shrink-0 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",r),children:e})}function dp({active:e,count:r,onClick:s,children:n}){return(0,O.jsxs)("button",{onClick:s,className:(0,ey.cn)("inline-flex items-center gap-1.5 px-2.5 py-[3px] rounded-full text-[11.5px] font-normal transition-colors whitespace-nowrap flex-shrink-0 border",e?"bg-card text-foreground font-medium border-border shadow-sm":"bg-transparent text-muted-foreground border-transparent hover:bg-muted hover:text-foreground"),children:[n,void 0!==r&&(0,O.jsx)("span",{className:(0,ey.cn)("font-mono text-[10.5px] pl-0.5",e?"text-muted-foreground":"text-muted-foreground/70"),children:r})]})}let dm=(0,ew.default)("grip-vertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]),dg=(0,$.createContext)(null);dg.displayName="PanelGroupContext";let dx="data-panel-group-direction",dv="data-panel-group-id",d_="data-resize-handle",dy="data-panel-resize-handle-id",db=$.useLayoutEffect,dw=$["useId".toString()],dS="function"==typeof dw?dw:()=>null,dj=0;function dC(e=null){let r=dS(),s=(0,$.useRef)(e||r||null);return null===s.current&&(s.current=""+dj++),null!=e?e:s.current}function dk({children:e,className:r="",collapsedSize:s,collapsible:n,defaultSize:i,forwardedRef:a,id:o,maxSize:l,minSize:c,onCollapse:d,onExpand:u,onResize:h,order:f,style:p,tagName:m="div",...g}){let x=(0,$.useContext)(dg);if(null===x)throw Error("Panel components must be rendered within a PanelGroup container");let{collapsePanel:v,expandPanel:_,getPanelSize:y,getPanelStyle:b,groupId:w,isPanelCollapsed:S,reevaluatePanelConstraints:j,registerPanel:C,resizePanel:k,unregisterPanel:N}=x,E=dC(o),D=(0,$.useRef)({callbacks:{onCollapse:d,onExpand:u,onResize:h},constraints:{collapsedSize:s,collapsible:n,defaultSize:i,maxSize:l,minSize:c},id:E,idIsFromProps:void 0!==o,order:f});(0,$.useRef)({didLogMissingDefaultSizeWarning:!1}),db(()=>{let{callbacks:e,constraints:r}=D.current,a={...r};D.current.id=E,D.current.idIsFromProps=void 0!==o,D.current.order=f,e.onCollapse=d,e.onExpand=u,e.onResize=h,r.collapsedSize=s,r.collapsible=n,r.defaultSize=i,r.maxSize=l,r.minSize=c,(a.collapsedSize!==r.collapsedSize||a.collapsible!==r.collapsible||a.maxSize!==r.maxSize||a.minSize!==r.minSize)&&j(D.current,a)}),db(()=>{let e=D.current;return C(e),()=>{N(e)}},[f,E,C,N]),(0,$.useImperativeHandle)(a,()=>({collapse:()=>{v(D.current)},expand:e=>{_(D.current,e)},getId:()=>E,getSize:()=>y(D.current),isCollapsed:()=>S(D.current),isExpanded:()=>!S(D.current),resize:e=>{k(D.current,e)}}),[v,_,y,S,E,k]);let R=b(D.current,i);return(0,$.createElement)(m,{...g,children:e,className:r,id:E,style:{...R,...p},[dv]:w,"data-panel":"","data-panel-collapsible":n||void 0,"data-panel-id":E,"data-panel-size":parseFloat(""+R.flexGrow).toFixed(1)})}let dN=(0,$.forwardRef)((e,r)=>(0,$.createElement)(dk,{...e,forwardedRef:r}));dk.displayName="Panel",dN.displayName="forwardRef(Panel)";let dE=null,dD=-1,dR=null;function dA(e,s){var n,i,a;let o=function(e,r){if(r){let e=(r&d$)!=0,s=(r&dW)!=0,n=(r&dH)!=0,i=(r&dU)!=0;if(e)if(n)return"se-resize";else if(i)return"ne-resize";else return"e-resize";if(s)if(n)return"sw-resize";else if(i)return"nw-resize";else return"w-resize";if(n)return"s-resize";else if(i)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}(e,s);dE!==o&&(dE=o,null===dR&&(dR=document.createElement("style"),r&&dR.setAttribute("nonce",r),document.head.appendChild(dR)),dD>=0&&(null==(a=dR.sheet)||a.removeRule(dD)),dD=null!=(n=null==(i=dR.sheet)?void 0:i.insertRule(`*{cursor: ${o} !important;}`))?n:-1)}function dT(e){return"keydown"===e.type}function dM(e){return e.type.startsWith("pointer")}function dF(e){return e.type.startsWith("mouse")}function dP(e){if(dM(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(dF(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}let dI=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function dB(e){let r=e.length;for(;r--;){let s=e[r];if(d6(s,"Missing node"),function(e){var r;let s,n=getComputedStyle(e);return"fixed"===n.position||!!("auto"!==n.zIndex&&("static"!==n.position||"flex"===(s=getComputedStyle(null!=(r=dO(e))?r:e).display)||"inline-flex"===s)||1>+n.opacity||"transform"in n&&"none"!==n.transform||"webkitTransform"in n&&"none"!==n.webkitTransform||"mixBlendMode"in n&&"normal"!==n.mixBlendMode||"filter"in n&&"none"!==n.filter||"webkitFilter"in n&&"none"!==n.webkitFilter||"isolation"in n&&"isolate"===n.isolation||dI.test(n.willChange))||"touch"===n.webkitOverflowScrolling}(s))return s}return null}function dL(e){return e&&Number(getComputedStyle(e).zIndex)||0}function dz(e){let r=[];for(;e;)r.push(e),e=dO(e);return r}function dO(e){let{parentNode:r}=e;return r&&r instanceof ShadowRoot?r.host:r}let d$=1,dW=2,dH=4,dU=8,dq="coarse"===function(){if("function"==typeof matchMedia)return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}(),dK=[],dV=!1,dY=new Map,dG=new Map,dX=new Set;function dJ(e){let{target:r}=e,{x:s,y:n}=dP(e);dV=!0,d1({target:r,x:s,y:n}),d3(),dK.length>0&&(d4("down",e),e.preventDefault(),d0(r)||e.stopImmediatePropagation())}function dZ(e){let{x:r,y:s}=dP(e);if(dV&&0===e.buttons&&(dV=!1,d4("up",e)),!dV){let{target:n}=e;d1({target:n,x:r,y:s})}d4("move",e),d2(),dK.length>0&&e.preventDefault()}function dQ(e){let{target:r}=e,{x:s,y:n}=dP(e);dG.clear(),dV=!1,dK.length>0&&(e.preventDefault(),d0(r)||e.stopImmediatePropagation()),d4("up",e),d1({target:r,x:s,y:n}),d2(),d3()}function d0(e){let r=e;for(;r;){if(r.hasAttribute(d_))return!0;r=r.parentElement}return!1}function d1({target:e,x:r,y:s}){dK.splice(0);let n=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(n=e),dX.forEach(e=>{let{element:i,hitAreaMargins:a}=e,o=i.getBoundingClientRect(),{bottom:l,left:c,right:d,top:u}=o,h=dq?a.coarse:a.fine;if(r>=c-h&&r<=d+h&&s>=u-h&&s<=l+h){if(null!==n&&document.contains(n)&&i!==n&&!i.contains(n)&&!n.contains(i)&&function(e,r){let s;if(e===r)throw Error("Cannot compare node with itself");let n={a:dz(e),b:dz(r)};for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),r=n.b.pop(),s=e;d6(s,"Stacking order can only be calculated for elements with a common ancestor");let i={a:dL(dB(n.a)),b:dL(dB(n.b))};if(i.a===i.b){let e=s.childNodes,r={a:n.a.at(-1),b:n.b.at(-1)},i=e.length;for(;i--;){let s=e[i];if(s===r.a)return 1;if(s===r.b)return -1}}return Math.sign(i.a-i.b)}(n,i)>0){let e=n,r=!1;for(;e;){var f;if(e.contains(i))break;if(f=e.getBoundingClientRect(),f.x<o.x+o.width&&f.x+f.width>o.x&&f.y<o.y+o.height&&f.y+f.height>o.y){r=!0;break}e=e.parentElement}if(r)return}dK.push(e)}})}function d2(){let e=!1,r=!1;dK.forEach(s=>{let{direction:n}=s;"horizontal"===n?e=!0:r=!0});let s=0;dG.forEach(e=>{s|=e}),e&&r?dA("intersection",s):e?dA("horizontal",s):r?dA("vertical",s):null!==dR&&(document.head.removeChild(dR),dE=null,dR=null,dD=-1)}let d5=new AbortController;function d3(){d5.abort();let e={capture:!0,signal:(d5=new AbortController).signal};dX.size&&(dV?(dK.length>0&&dY.forEach((r,s)=>{let{body:n}=s;r>0&&(n.addEventListener("contextmenu",dQ,e),n.addEventListener("pointerleave",dZ,e),n.addEventListener("pointermove",dZ,e))}),window.addEventListener("pointerup",dQ,e),window.addEventListener("pointercancel",dQ,e)):dY.forEach((r,s)=>{let{body:n}=s;r>0&&(n.addEventListener("pointerdown",dJ,e),n.addEventListener("pointermove",dZ,e))}))}function d4(e,r){dX.forEach(s=>{let{setResizeHandlerState:n}=s;n(e,dK.includes(s),r)})}function d6(e,r){if(!e)throw console.error(r),Error(r)}function d7(e,r,s=10){return e.toFixed(s)===r.toFixed(s)?0:e>r?1:-1}function d8(e,r,s=10){return 0===d7(e,r,s)}function d9(e,r,s){return 0===d7(e,r,s)}function ue({panelConstraints:e,panelIndex:r,size:s}){let n=e[r];d6(null!=n,`Panel constraints not found for index ${r}`);let{collapsedSize:i=0,collapsible:a,maxSize:o=100,minSize:l=0}=n;return 0>d7(s,l)&&(s=a&&0>d7(s,(i+l)/2)?i:l),s=parseFloat((s=Math.min(o,s)).toFixed(10))}function ut({delta:e,initialLayout:r,panelConstraints:s,pivotIndices:n,prevLayout:i,trigger:a}){if(d9(e,0))return r;let o=[...r],[l,c]=n;d6(null!=l,"Invalid first pivot index"),d6(null!=c,"Invalid second pivot index");let d=0;if("keyboard"===a){{let n=e<0?c:l,i=s[n];d6(i,`Panel constraints not found for index ${n}`);let{collapsedSize:a=0,collapsible:o,minSize:d=0}=i;if(o){let s=r[n];if(d6(null!=s,`Previous layout not found for panel index ${n}`),d9(s,a)){let r=d-s;d7(r,Math.abs(e))>0&&(e=e<0?0-r:r)}}}{let n=e<0?l:c,i=s[n];d6(i,`No panel constraints found for index ${n}`);let{collapsedSize:a=0,collapsible:o,minSize:d=0}=i;if(o){let s=r[n];if(d6(null!=s,`Previous layout not found for panel index ${n}`),d9(s,d)){let r=s-a;d7(r,Math.abs(e))>0&&(e=e<0?0-r:r)}}}}{let n=e<0?1:-1,i=e<0?c:l,a=0;for(;;){let e=r[i];if(d6(null!=e,`Previous layout not found for panel index ${i}`),a+=ue({panelConstraints:s,panelIndex:i,size:100})-e,(i+=n)<0||i>=s.length)break}let o=Math.min(Math.abs(e),Math.abs(a));e=e<0?0-o:o}{let n=e<0?l:c;for(;n>=0&&n<s.length;){let i=Math.abs(e)-Math.abs(d),a=r[n];d6(null!=a,`Previous layout not found for panel index ${n}`);let l=ue({panelConstraints:s,panelIndex:n,size:a-i});if(!d9(a,l)&&(d+=a-l,o[n]=l,d.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?n--:n++}}if(function(e,r,s){if(e.length!==r.length)return!1;for(let s=0;s<e.length;s++)if(!d9(e[s],r[s],void 0))return!1;return!0}(i,o))return i;{let n=e<0?c:l,i=r[n];d6(null!=i,`Previous layout not found for panel index ${n}`);let a=i+d,u=ue({panelConstraints:s,panelIndex:n,size:a});if(o[n]=u,!d9(u,a)){let r=a-u,n=e<0?c:l;for(;n>=0&&n<s.length;){let i=o[n];d6(null!=i,`Previous layout not found for panel index ${n}`);let a=ue({panelConstraints:s,panelIndex:n,size:i+r});if(d9(i,a)||(r-=a-i,o[n]=a),d9(r,0))break;e>0?n--:n++}}}return d9(o.reduce((e,r)=>r+e,0),100)?o:i}function ur(e,r=document){return Array.from(r.querySelectorAll(`[${dy}][data-panel-group-id="${e}"]`))}function us(e,r,s=document){let n=ur(e,s).findIndex(e=>e.getAttribute(dy)===r);return null!=n?n:null}function un(e,r,s){let n=us(e,r,s);return null!=n?[n,n+1]:[-1,-1]}function ui(e,r=document){var s;if(r instanceof HTMLElement&&(null==r||null==(s=r.dataset)?void 0:s.panelGroupId)==e)return r;let n=r.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function ua(e,r=document){let s=r.querySelector(`[${dy}="${e}"]`);return s||null}function uo(e,r){if(e.length!==r.length)return!1;for(let s=0;s<e.length;s++)if(e[s]!==r[s])return!1;return!0}function ul(e,r){let{x:s,y:n}=dP(r);return"horizontal"===e?s:n}function uc(e,r,s){r.forEach((r,n)=>{let i=e[n];d6(i,`Panel data not found for index ${n}`);let{callbacks:a,constraints:o,id:l}=i,{collapsedSize:c=0,collapsible:d}=o,u=s[l];if(null==u||r!==u){s[l]=r;let{onCollapse:e,onExpand:n,onResize:i}=a;i&&i(r,u),d&&(e||n)&&(n&&(null==u||d8(u,c))&&!d8(r,c)&&n(),e&&(null==u||!d8(u,c))&&d8(r,c)&&e())}})}function ud(e,r){if(e.length!==r.length)return!1;for(let s=0;s<e.length;s++)if(e[s]!=r[s])return!1;return!0}function uu(e){try{if("undefined"!=typeof localStorage)e.getItem=e=>localStorage.getItem(e),e.setItem=(e,r)=>{localStorage.setItem(e,r)};else throw Error("localStorage not supported in this environment")}catch(r){console.error(r),e.getItem=()=>null,e.setItem=()=>{}}}function uh(e){return`react-resizable-panels:${e}`}function uf(e){return e.map(e=>{let{constraints:r,id:s,idIsFromProps:n,order:i}=e;return n?s:i?`${i}:${JSON.stringify(r)}`:JSON.stringify(r)}).sort((e,r)=>e.localeCompare(r)).join(",")}function up(e,r){try{let s=uh(e),n=r.getItem(s);if(n){let e=JSON.parse(n);if("object"==typeof e&&null!=e)return e}}catch(e){}return null}function um(e,r,s,n,i){var a;let o=uh(e),l=uf(r),c=null!=(a=up(e,i))?a:{};c[l]={expandToSizes:Object.fromEntries(s.entries()),layout:n};try{i.setItem(o,JSON.stringify(c))}catch(e){console.error(e)}}function ug({layout:e,panelConstraints:r}){let s=[...e],n=s.reduce((e,r)=>e+r,0);if(s.length!==r.length)throw Error(`Invalid ${r.length} panel layout: ${s.map(e=>`${e}%`).join(", ")}`);if(!d9(n,100)&&s.length>0)for(let e=0;e<r.length;e++){let r=s[e];d6(null!=r,`No layout data found for index ${e}`);let i=100/n*r;s[e]=i}let i=0;for(let e=0;e<r.length;e++){let n=s[e];d6(null!=n,`No layout data found for index ${e}`);let a=ue({panelConstraints:r,panelIndex:e,size:n});n!=a&&(i+=n-a,s[e]=a)}if(!d9(i,0))for(let e=0;e<r.length;e++){let n=s[e];d6(null!=n,`No layout data found for index ${e}`);let a=ue({panelConstraints:r,panelIndex:e,size:n+i});if(n!==a&&(i-=a-n,s[e]=a,d9(i,0)))break}return s}let ux={getItem:e=>(uu(ux),ux.getItem(e)),setItem:(e,r)=>{uu(ux),ux.setItem(e,r)}},uv={};function u_({autoSaveId:e=null,children:r,className:s="",direction:n,forwardedRef:i,id:a=null,onLayout:o=null,keyboardResizeBy:l=null,storage:c=ux,style:d,tagName:u="div",...h}){let f=dC(a),p=(0,$.useRef)(null),[m,g]=(0,$.useState)(null),[x,v]=(0,$.useState)([]),_=function(){let[e,r]=(0,$.useState)(0);return(0,$.useCallback)(()=>r(e=>e+1),[])}(),y=(0,$.useRef)({}),b=(0,$.useRef)(new Map),w=(0,$.useRef)(0),S=(0,$.useRef)({autoSaveId:e,direction:n,dragState:m,id:f,keyboardResizeBy:l,onLayout:o,storage:c}),j=(0,$.useRef)({layout:x,panelDataArray:[],panelDataArrayChanged:!1});(0,$.useRef)({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),(0,$.useImperativeHandle)(i,()=>({getId:()=>S.current.id,getLayout:()=>{let{layout:e}=j.current;return e},setLayout:e=>{let{onLayout:r}=S.current,{layout:s,panelDataArray:n}=j.current,i=ug({layout:e,panelConstraints:n.map(e=>e.constraints)});uo(s,i)||(v(i),j.current.layout=i,r&&r(i),uc(n,i,y.current))}}),[]),db(()=>{S.current.autoSaveId=e,S.current.direction=n,S.current.dragState=m,S.current.id=f,S.current.onLayout=o,S.current.storage=c}),function({committedValuesRef:e,eagerValuesRef:r,groupId:s,layout:n,panelDataArray:i,panelGroupElement:a,setLayout:o}){(0,$.useRef)({didWarnAboutMissingResizeHandle:!1}),db(()=>{if(!a)return;let e=ur(s,a);for(let r=0;r<i.length-1;r++){let{valueMax:s,valueMin:a,valueNow:o}=function({layout:e,panelsArray:r,pivotIndices:s}){let n=0,i=100,a=0,o=0,l=s[0];return d6(null!=l,"No pivot index found"),r.forEach((e,r)=>{let{constraints:s}=e,{maxSize:c=100,minSize:d=0}=s;r===l?(n=d,i=c):(a+=d,o+=c)}),{valueMax:Math.min(i,100-a),valueMin:Math.max(n,100-o),valueNow:e[l]}}({layout:n,panelsArray:i,pivotIndices:[r,r+1]}),l=e[r];if(null==l);else{let e=i[r];d6(e,`No panel data found for index "${r}"`),l.setAttribute("aria-controls",e.id),l.setAttribute("aria-valuemax",""+Math.round(s)),l.setAttribute("aria-valuemin",""+Math.round(a)),l.setAttribute("aria-valuenow",null!=o?""+Math.round(o):"")}}return()=>{e.forEach((e,r)=>{e.removeAttribute("aria-controls"),e.removeAttribute("aria-valuemax"),e.removeAttribute("aria-valuemin"),e.removeAttribute("aria-valuenow")})}},[s,n,i,a]),(0,$.useEffect)(()=>{if(!a)return;let e=r.current;d6(e,"Eager values not found");let{panelDataArray:i}=e;d6(null!=ui(s,a),`No group found for id "${s}"`);let l=ur(s,a);d6(l,`No resize handles found for group id "${s}"`);let c=l.map(e=>{let r=e.getAttribute(dy);d6(r,"Resize handle element has no handle id attribute");let[l,c]=function(e,r,s,n=document){var i,a,o,l;let c=ua(r,n),d=ur(e,n),u=c?d.indexOf(c):-1;return[null!=(i=null==(a=s[u])?void 0:a.id)?i:null,null!=(o=null==(l=s[u+1])?void 0:l.id)?o:null]}(s,r,i,a);if(null==l||null==c)return()=>{};let d=e=>{if(!e.defaultPrevented&&"Enter"===e.key){e.preventDefault();let c=i.findIndex(e=>e.id===l);if(c>=0){let e=i[c];d6(e,`No panel data found for index ${c}`);let l=n[c],{collapsedSize:d=0,collapsible:u,minSize:h=0}=e.constraints;if(null!=l&&u){let e=ut({delta:d9(l,d)?h-d:d-l,initialLayout:n,panelConstraints:i.map(e=>e.constraints),pivotIndices:un(s,r,a),prevLayout:n,trigger:"keyboard"});n!==e&&o(e)}}}};return e.addEventListener("keydown",d),()=>{e.removeEventListener("keydown",d)}});return()=>{c.forEach(e=>e())}},[a,e,r,s,n,i,o])}({committedValuesRef:S,eagerValuesRef:j,groupId:f,layout:x,panelDataArray:j.current.panelDataArray,setLayout:v,panelGroupElement:p.current}),(0,$.useEffect)(()=>{let{panelDataArray:r}=j.current;if(e){if(0===x.length||x.length!==r.length)return;let s=uv[e];null==s&&(s=function(e,r=10){let s=null;return(...n)=>{null!==s&&clearTimeout(s),s=setTimeout(()=>{e(...n)},r)}}(um,100),uv[e]=s),s(e,[...r],new Map(b.current),x,c)}},[e,x,c]),(0,$.useEffect)(()=>{});let C=(0,$.useCallback)(e=>{let{onLayout:r}=S.current,{layout:s,panelDataArray:n}=j.current;if(e.constraints.collapsible){let i=n.map(e=>e.constraints),{collapsedSize:a=0,panelSize:o,pivotIndices:l}=uw(n,e,s);if(d6(null!=o,`Panel size not found for panel "${e.id}"`),!d8(o,a)){b.current.set(e.id,o);let c=ut({delta:ub(n,e)===n.length-1?o-a:a-o,initialLayout:s,panelConstraints:i,pivotIndices:l,prevLayout:s,trigger:"imperative-api"});ud(s,c)||(v(c),j.current.layout=c,r&&r(c),uc(n,c,y.current))}}},[]),k=(0,$.useCallback)((e,r)=>{let{onLayout:s}=S.current,{layout:n,panelDataArray:i}=j.current;if(e.constraints.collapsible){let a=i.map(e=>e.constraints),{collapsedSize:o=0,panelSize:l=0,minSize:c=0,pivotIndices:d}=uw(i,e,n),u=null!=r?r:c;if(d8(l,o)){let r=b.current.get(e.id),o=null!=r&&r>=u?r:u,c=ut({delta:ub(i,e)===i.length-1?l-o:o-l,initialLayout:n,panelConstraints:a,pivotIndices:d,prevLayout:n,trigger:"imperative-api"});ud(n,c)||(v(c),j.current.layout=c,s&&s(c),uc(i,c,y.current))}}},[]),N=(0,$.useCallback)(e=>{let{layout:r,panelDataArray:s}=j.current,{panelSize:n}=uw(s,e,r);return d6(null!=n,`Panel size not found for panel "${e.id}"`),n},[]),E=(0,$.useCallback)((e,r)=>{let{panelDataArray:s}=j.current,n=ub(s,e);return function({defaultSize:e,dragState:r,layout:s,panelData:n,panelIndex:i,precision:a=3}){let o=s[i];return{flexBasis:0,flexGrow:null==o?void 0!=e?e.toPrecision(a):"1":1===n.length?"1":o.toPrecision(a),flexShrink:1,overflow:"hidden",pointerEvents:null!==r?"none":void 0}}({defaultSize:r,dragState:m,layout:x,panelData:s,panelIndex:n})},[m,x]),D=(0,$.useCallback)(e=>{let{layout:r,panelDataArray:s}=j.current,{collapsedSize:n=0,collapsible:i,panelSize:a}=uw(s,e,r);return d6(null!=a,`Panel size not found for panel "${e.id}"`),!0===i&&d8(a,n)},[]),R=(0,$.useCallback)(e=>{let{layout:r,panelDataArray:s}=j.current,{collapsedSize:n=0,collapsible:i,panelSize:a}=uw(s,e,r);return d6(null!=a,`Panel size not found for panel "${e.id}"`),!i||d7(a,n)>0},[]),A=(0,$.useCallback)(e=>{let{panelDataArray:r}=j.current;r.push(e),r.sort((e,r)=>{let s=e.order,n=r.order;return null==s&&null==n?0:null==s?-1:null==n?1:s-n}),j.current.panelDataArrayChanged=!0,_()},[_]);db(()=>{if(j.current.panelDataArrayChanged){j.current.panelDataArrayChanged=!1;let{autoSaveId:s,onLayout:n,storage:i}=S.current,{layout:a,panelDataArray:o}=j.current,l=null;if(s){var e,r;let n=null!=(r=(null!=(e=up(s,i))?e:{})[uf(o)])?r:null;n&&(b.current=new Map(Object.entries(n.expandToSizes)),l=n.layout)}null==l&&(l=function({panelDataArray:e}){let r=Array(e.length),s=e.map(e=>e.constraints),n=0,i=100;for(let a=0;a<e.length;a++){let e=s[a];d6(e,`Panel constraints not found for index ${a}`);let{defaultSize:o}=e;null!=o&&(n++,r[a]=o,i-=o)}for(let a=0;a<e.length;a++){let o=s[a];d6(o,`Panel constraints not found for index ${a}`);let{defaultSize:l}=o;if(null!=l)continue;let c=i/(e.length-n);n++,r[a]=c,i-=c}return r}({panelDataArray:o}));let c=ug({layout:l,panelConstraints:o.map(e=>e.constraints)});uo(a,c)||(v(c),j.current.layout=c,n&&n(c),uc(o,c,y.current))}}),db(()=>{let e=j.current;return()=>{e.layout=[]}},[]);let T=(0,$.useCallback)(e=>{let r=!1,s=p.current;return s&&"rtl"===window.getComputedStyle(s,null).getPropertyValue("direction")&&(r=!0),function(s){var n,i;s.preventDefault();let a=p.current;if(!a)return()=>null;let{direction:o,dragState:l,id:c,keyboardResizeBy:d,onLayout:u}=S.current,{layout:h,panelDataArray:f}=j.current,{initialLayout:m}=null!=l?l:{},g=un(c,e,a),x=function(e,r,s,n,i,a){if(dT(e)){let r="horizontal"===s,n=0;n=e.shiftKey?100:null!=i?i:10;let a=0;switch(e.key){case"ArrowDown":a=r?0:n;break;case"ArrowLeft":a=r?-n:0;break;case"ArrowRight":a=r?n:0;break;case"ArrowUp":a=r?0:-n;break;case"End":a=100;break;case"Home":a=-100}return a}return null==n?0:function(e,r,s,n,i){let a="horizontal"===s,o=ua(r,i);d6(o,`No resize handle element found for id "${r}"`);let l=o.getAttribute(dv);d6(l,"Resize handle element has no group id attribute");let{initialCursorPosition:c}=n,d=ul(s,e),u=ui(l,i);d6(u,`No group element found for id "${l}"`);let h=u.getBoundingClientRect();return(d-c)/(a?h.width:h.height)*100}(e,r,s,n,a)}(s,e,o,l,d,a),_="horizontal"===o;_&&r&&(x=-x);let b=ut({delta:x,initialLayout:null!=m?m:h,panelConstraints:f.map(e=>e.constraints),pivotIndices:g,prevLayout:h,trigger:dT(s)?"keyboard":"mouse-or-touch"}),C=!ud(h,b);(dM(s)||dF(s))&&w.current!=x&&((w.current=x,C||0===x)?dG.set(e,0):_?(n=x<0?d$:dW,dG.set(e,n)):(i=x<0?dH:dU,dG.set(e,i))),C&&(v(b),j.current.layout=b,u&&u(b),uc(f,b,y.current))}},[]),M=(0,$.useCallback)((e,r)=>{let{onLayout:s}=S.current,{layout:n,panelDataArray:i}=j.current,a=i.map(e=>e.constraints),{panelSize:o,pivotIndices:l}=uw(i,e,n);d6(null!=o,`Panel size not found for panel "${e.id}"`);let c=ut({delta:ub(i,e)===i.length-1?o-r:r-o,initialLayout:n,panelConstraints:a,pivotIndices:l,prevLayout:n,trigger:"imperative-api"});ud(n,c)||(v(c),j.current.layout=c,s&&s(c),uc(i,c,y.current))},[]),F=(0,$.useCallback)((e,r)=>{let{layout:s,panelDataArray:n}=j.current,{collapsedSize:i=0,collapsible:a}=r,{collapsedSize:o=0,collapsible:l,maxSize:c=100,minSize:d=0}=e.constraints,{panelSize:u}=uw(n,e,s);null!=u&&(a&&l&&d8(u,i)?d8(i,o)||M(e,o):u<d?M(e,d):u>c&&M(e,c))},[M]),P=(0,$.useCallback)((e,r)=>{let{direction:s}=S.current,{layout:n}=j.current;if(!p.current)return;let i=ua(e,p.current);d6(i,`Drag handle element not found for id "${e}"`);let a=ul(s,r);g({dragHandleId:e,dragHandleRect:i.getBoundingClientRect(),initialCursorPosition:a,initialLayout:n})},[]),I=(0,$.useCallback)(()=>{g(null)},[]),B=(0,$.useCallback)(e=>{let{panelDataArray:r}=j.current,s=ub(r,e);s>=0&&(r.splice(s,1),delete y.current[e.id],j.current.panelDataArrayChanged=!0,_())},[_]),L=(0,$.useMemo)(()=>({collapsePanel:C,direction:n,dragState:m,expandPanel:k,getPanelSize:N,getPanelStyle:E,groupId:f,isPanelCollapsed:D,isPanelExpanded:R,reevaluatePanelConstraints:F,registerPanel:A,registerResizeHandle:T,resizePanel:M,startDragging:P,stopDragging:I,unregisterPanel:B,panelGroupElement:p.current}),[C,m,n,k,N,E,f,D,R,F,A,T,M,P,I,B]);return(0,$.createElement)(dg.Provider,{value:L},(0,$.createElement)(u,{...h,children:r,className:s,id:a,ref:p,style:{display:"flex",flexDirection:"horizontal"===n?"row":"column",height:"100%",overflow:"hidden",width:"100%",...d},"data-panel-group":"",[dx]:n,[dv]:f}))}let uy=(0,$.forwardRef)((e,r)=>(0,$.createElement)(u_,{...e,forwardedRef:r}));function ub(e,r){return e.findIndex(e=>e===r||e.id===r.id)}function uw(e,r,s){let n=ub(e,r),i=n===e.length-1,a=s[n];return{...r.constraints,panelSize:a,pivotIndices:i?[n-1,n]:[n,n+1]}}function uS({children:e=null,className:r="",disabled:s=!1,hitAreaMargins:n,id:i,onBlur:a,onClick:o,onDragging:l,onFocus:c,onPointerDown:d,onPointerUp:u,style:h={},tabIndex:f=0,tagName:p="div",...m}){var g,x;let v=(0,$.useRef)(null),_=(0,$.useRef)({onClick:o,onDragging:l,onPointerDown:d,onPointerUp:u});(0,$.useEffect)(()=>{_.current.onClick=o,_.current.onDragging=l,_.current.onPointerDown=d,_.current.onPointerUp=u});let y=(0,$.useContext)(dg);if(null===y)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");let{direction:b,groupId:w,registerResizeHandle:S,startDragging:j,stopDragging:C,panelGroupElement:k}=y,N=dC(i),[E,D]=(0,$.useState)("inactive"),[R,A]=(0,$.useState)(!1),[T,M]=(0,$.useState)(null),F=(0,$.useRef)({state:E});db(()=>{F.current.state=E}),(0,$.useEffect)(()=>{if(s)M(null);else{let e=S(N);M(()=>e)}},[s,N,S]);let P=null!=(g=null==n?void 0:n.coarse)?g:15,I=null!=(x=null==n?void 0:n.fine)?x:5;return(0,$.useEffect)(()=>{if(s||null==T)return;let e=v.current;d6(e,"Element ref not attached");let r=!1;return function(e,r,s,n,i){var a;let{ownerDocument:o}=r,l={direction:s,element:r,hitAreaMargins:n,setResizeHandlerState:i},c=null!=(a=dY.get(o))?a:0;return dY.set(o,c+1),dX.add(l),d3(),function(){var r;dG.delete(e),dX.delete(l);let s=null!=(r=dY.get(o))?r:1;if(dY.set(o,s-1),d3(),1===s&&dY.delete(o),dK.includes(l)){let e=dK.indexOf(l);e>=0&&dK.splice(e,1),d2(),i("up",!0,null)}}}(N,e,b,{coarse:P,fine:I},(e,s,n)=>{if(!s)return void D("inactive");switch(e){case"down":{D("drag"),r=!1,d6(n,'Expected event to be defined for "down" action'),j(N,n);let{onDragging:e,onPointerDown:s}=_.current;null==e||e(!0),null==s||s();break}case"move":{let{state:e}=F.current;r=!0,"drag"!==e&&D("hover"),d6(n,'Expected event to be defined for "move" action'),T(n);break}case"up":{D("hover"),C();let{onClick:e,onDragging:s,onPointerUp:n}=_.current;null==s||s(!1),null==n||n(),r||null==e||e()}}})},[P,b,s,I,S,N,T,j,C]),!function({disabled:e,handleId:r,resizeHandler:s,panelGroupElement:n}){(0,$.useEffect)(()=>{if(e||null==s||null==n)return;let i=ua(r,n);if(null==i)return;let a=e=>{if(!e.defaultPrevented)switch(e.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":e.preventDefault(),s(e);break;case"F6":{e.preventDefault();let s=i.getAttribute(dv);d6(s,`No group element found for id "${s}"`);let a=ur(s,n),o=us(s,r,n);d6(null!==o,`No resize element found for id "${r}"`);let l=e.shiftKey?o>0?o-1:a.length-1:o+1<a.length?o+1:0;a[l].focus()}}};return i.addEventListener("keydown",a),()=>{i.removeEventListener("keydown",a)}},[n,e,r,s])}({disabled:s,handleId:N,resizeHandler:T,panelGroupElement:k}),(0,$.createElement)(p,{...m,children:e,className:r,id:i,onBlur:()=>{A(!1),null==a||a()},onFocus:()=>{A(!0),null==c||c()},ref:v,role:"separator",style:{touchAction:"none",userSelect:"none",...h},tabIndex:f,[dx]:b,[dv]:w,[d_]:"","data-resize-handle-active":"drag"===E?"pointer":R?"keyboard":void 0,"data-panel-resize-handle-enabled":!s,[dy]:N,"data-resize-handle-state":E})}u_.displayName="PanelGroup",uy.displayName="forwardRef(PanelGroup)",uS.displayName="PanelResizeHandle";let uj=({className:e,...r})=>(0,O.jsx)(uy,{className:(0,ey.cn)("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...r}),uC=({withHandle:e,className:r,...s})=>(0,O.jsx)(uS,{className:(0,ey.cn)("relative flex w-px items-center justify-center bg-border/60 after:absolute after:inset-y-0 after:-left-1 after:-right-1 after:content-[''] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:inset-x-0 data-[panel-group-direction=vertical]:after:-top-1 data-[panel-group-direction=vertical]:after:-bottom-1 data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:right-0 [&[data-resize-handle-active]]:bg-ring",r),...s,children:e&&(0,O.jsx)("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:(0,O.jsx)(dm,{className:"h-2.5 w-2.5"})})});function uk({className:e,...r}){return(0,O.jsx)("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:(0,O.jsx)("table",{"data-slot":"table",className:(0,ey.cn)("w-full caption-bottom text-sm",e),...r})})}function uN({className:e,...r}){return(0,O.jsx)("thead",{"data-slot":"table-header",className:(0,ey.cn)("[&_tr]:border-b",e),...r})}function uE({className:e,...r}){return(0,O.jsx)("tbody",{"data-slot":"table-body",className:(0,ey.cn)("[&_tr:last-child]:border-0",e),...r})}function uD({className:e,...r}){return(0,O.jsx)("tr",{"data-slot":"table-row",className:(0,ey.cn)("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",e),...r})}function uR({className:e,...r}){return(0,O.jsx)("th",{"data-slot":"table-head",className:(0,ey.cn)("text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...r})}function uA({className:e,...r}){return(0,O.jsx)("td",{"data-slot":"table-cell",className:(0,ey.cn)("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...r})}var uT=[" ","Enter","ArrowUp","ArrowDown"],uM=[" ","Enter"],uF="Select",[uP,uI,uB]=rb(uF),[uL,uz]=q(uF,[uB,iw]),uO=iw(),[u$,uW]=uL(uF),[uH,uU]=uL(uF),uq=e=>{let{__scopeSelect:r,children:s,open:n,defaultOpen:i,onOpenChange:a,value:o,defaultValue:l,onValueChange:c,dir:d,name:u,autoComplete:h,disabled:f,required:p,form:m}=e,g=uO(r),[x,v]=$.useState(null),[_,y]=$.useState(null),[b,w]=$.useState(!1),S=rk(d),[j,C]=G({prop:n,defaultProp:i??!1,onChange:a,caller:uF}),[k,N]=G({prop:o,defaultProp:l,onChange:c,caller:uF}),E=$.useRef(null),D=!x||m||!!x.closest("form"),[R,A]=$.useState(new Set),T=Array.from(R).map(e=>e.props.value).join(";");return(0,O.jsx)(iC,{...g,children:(0,O.jsxs)(u$,{required:p,scope:r,trigger:x,onTriggerChange:v,valueNode:_,onValueNodeChange:y,valueNodeHasChildren:b,onValueNodeHasChildrenChange:w,contentId:ek(),value:k,onValueChange:N,open:j,onOpenChange:C,dir:S,triggerPointerDownPosRef:E,disabled:f,children:[(0,O.jsx)(uP.Provider,{scope:r,children:(0,O.jsx)(uH,{scope:e.__scopeSelect,onNativeOptionAdd:$.useCallback(e=>{A(r=>new Set(r).add(e))},[]),onNativeOptionRemove:$.useCallback(e=>{A(r=>{let s=new Set(r);return s.delete(e),s})},[]),children:s})}),D?(0,O.jsxs)(hv,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:h,value:k,onChange:e=>N(e.target.value),disabled:f,form:m,children:[void 0===k?(0,O.jsx)("option",{value:""}):null,Array.from(R)]},T):null]})})};uq.displayName=uF;var uK="SelectTrigger",uV=$.forwardRef((e,r)=>{let{__scopeSelect:s,disabled:n=!1,...i}=e,a=uO(s),o=uW(uK,s),l=o.disabled||n,c=(0,U.useComposedRefs)(r,o.onTriggerChange),d=uI(s),u=$.useRef("touch"),[h,f,p]=hy(e=>{let r=d().filter(e=>!e.disabled),s=r.find(e=>e.value===o.value),n=hb(r,e,s);void 0!==n&&o.onValueChange(n.value)}),m=e=>{l||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,O.jsx)(iN,{asChild:!0,...a,children:(0,O.jsx)(er.button,{type:"button",role:"combobox","aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":"none",dir:o.dir,"data-state":o.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":h_(o.value)?"":void 0,...i,ref:c,onClick:K(i.onClick,e=>{e.currentTarget.focus(),"mouse"!==u.current&&m(e)}),onPointerDown:K(i.onPointerDown,e=>{u.current=e.pointerType;let r=e.target;r.hasPointerCapture(e.pointerId)&&r.releasePointerCapture(e.pointerId),0===e.button&&!1===e.ctrlKey&&"mouse"===e.pointerType&&(m(e),e.preventDefault())}),onKeyDown:K(i.onKeyDown,e=>{let r=""!==h.current;e.ctrlKey||e.altKey||e.metaKey||1!==e.key.length||f(e.key),(!r||" "!==e.key)&&uT.includes(e.key)&&(m(),e.preventDefault())})})})});uV.displayName=uK;var uY="SelectValue",uG=$.forwardRef((e,r)=>{let{__scopeSelect:s,className:n,style:i,children:a,placeholder:o="",...l}=e,c=uW(uY,s),{onValueNodeHasChildrenChange:d}=c,u=void 0!==a,h=(0,U.useComposedRefs)(r,c.onValueNodeChange);return V(()=>{d(u)},[d,u]),(0,O.jsx)(er.span,{...l,ref:h,style:{pointerEvents:"none"},children:h_(c.value)?(0,O.jsx)(O.Fragment,{children:o}):a})});uG.displayName=uY;var uX=$.forwardRef((e,r)=>{let{__scopeSelect:s,children:n,...i}=e;return(0,O.jsx)(er.span,{"aria-hidden":!0,...i,ref:r,children:n||"▼"})});uX.displayName="SelectIcon";var uJ=e=>(0,O.jsx)(eW,{asChild:!0,...e});uJ.displayName="SelectPortal";var uZ="SelectContent",uQ=$.forwardRef((e,r)=>{let s=uW(uZ,e.__scopeSelect),[n,i]=$.useState();return(V(()=>{i(new DocumentFragment)},[]),s.open)?(0,O.jsx)(u5,{...e,ref:r}):n?ee.createPortal((0,O.jsx)(u0,{scope:e.__scopeSelect,children:(0,O.jsx)(uP.Slot,{scope:e.__scopeSelect,children:(0,O.jsx)("div",{children:e.children})})}),n):null});uQ.displayName=uZ;var[u0,u1]=uL(uZ),u2=(0,et.createSlot)("SelectContent.RemoveScroll"),u5=$.forwardRef((e,r)=>{let{__scopeSelect:s,position:n="item-aligned",onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:l,sideOffset:c,align:d,alignOffset:u,arrowPadding:h,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:g,avoidCollisions:x,...v}=e,_=uW(uZ,s),[y,b]=$.useState(null),[w,S]=$.useState(null),j=(0,U.useComposedRefs)(r,e=>b(e)),[C,k]=$.useState(null),[N,E]=$.useState(null),D=uI(s),[R,A]=$.useState(!1),T=$.useRef(!1);$.useEffect(()=>{if(y)return tN(y)},[y]),eU();let M=$.useCallback(e=>{let[r,...s]=D().map(e=>e.ref.current),[n]=s.slice(-1),i=document.activeElement;for(let s of e)if(s===i||(s?.scrollIntoView({block:"nearest"}),s===r&&w&&(w.scrollTop=0),s===n&&w&&(w.scrollTop=w.scrollHeight),s?.focus(),document.activeElement!==i))return},[D,w]),F=$.useCallback(()=>M([C,y]),[M,C,y]);$.useEffect(()=>{R&&F()},[R,F]);let{onOpenChange:P,triggerPointerDownPosRef:I}=_;$.useEffect(()=>{if(y){let e={x:0,y:0},r=r=>{e={x:Math.abs(Math.round(r.pageX)-(I.current?.x??0)),y:Math.abs(Math.round(r.pageY)-(I.current?.y??0))}},s=s=>{e.x<=10&&e.y<=10?s.preventDefault():y.contains(s.target)||P(!1),document.removeEventListener("pointermove",r),I.current=null};return null!==I.current&&(document.addEventListener("pointermove",r),document.addEventListener("pointerup",s,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",r),document.removeEventListener("pointerup",s,{capture:!0})}}},[y,P,I]),$.useEffect(()=>{let e=()=>P(!1);return window.addEventListener("blur",e),window.addEventListener("resize",e),()=>{window.removeEventListener("blur",e),window.removeEventListener("resize",e)}},[P]);let[B,L]=hy(e=>{let r=D().filter(e=>!e.disabled),s=r.find(e=>e.ref.current===document.activeElement),n=hb(r,e,s);n&&setTimeout(()=>n.ref.current.focus())}),z=$.useCallback((e,r,s)=>{let n=!T.current&&!s;(void 0!==_.value&&_.value===r||n)&&(k(e),n&&(T.current=!0))},[_.value]),W=$.useCallback(()=>y?.focus(),[y]),H=$.useCallback((e,r,s)=>{let n=!T.current&&!s;(void 0!==_.value&&_.value===r||n)&&E(e)},[_.value]),q="popper"===n?u4:u3,V=q===u4?{side:l,sideOffset:c,align:d,alignOffset:u,arrowPadding:h,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:g,avoidCollisions:x}:{};return(0,O.jsx)(u0,{scope:s,content:y,viewport:w,onViewportChange:S,itemRefCallback:z,selectedItem:C,onItemLeave:W,itemTextRefCallback:H,focusSelectedItem:F,selectedItemText:N,position:n,isPositioned:R,searchRef:B,children:(0,O.jsx)(ty,{as:u2,allowPinchZoom:!0,children:(0,O.jsx)(eI,{asChild:!0,trapped:_.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:K(i,e=>{_.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,O.jsx)(eR,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>_.onOpenChange(!1),children:(0,O.jsx)(q,{role:"listbox",id:_.contentId,"data-state":_.open?"open":"closed",dir:_.dir,onContextMenu:e=>e.preventDefault(),...v,...V,onPlaced:()=>A(!0),ref:j,style:{display:"flex",flexDirection:"column",outline:"none",...v.style},onKeyDown:K(v.onKeyDown,e=>{let r=e.ctrlKey||e.altKey||e.metaKey;if("Tab"===e.key&&e.preventDefault(),r||1!==e.key.length||L(e.key),["ArrowUp","ArrowDown","Home","End"].includes(e.key)){let r=D().filter(e=>!e.disabled).map(e=>e.ref.current);if(["ArrowUp","End"].includes(e.key)&&(r=r.slice().reverse()),["ArrowUp","ArrowDown"].includes(e.key)){let s=e.target,n=r.indexOf(s);r=r.slice(n+1)}setTimeout(()=>M(r)),e.preventDefault()}})})})})})})});u5.displayName="SelectContentImpl";var u3=$.forwardRef((e,r)=>{let{__scopeSelect:s,onPlaced:n,...i}=e,a=uW(uZ,s),o=u1(uZ,s),[l,c]=$.useState(null),[d,u]=$.useState(null),h=(0,U.useComposedRefs)(r,e=>u(e)),f=uI(s),p=$.useRef(!1),m=$.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:v,focusSelectedItem:_}=o,y=$.useCallback(()=>{if(a.trigger&&a.valueNode&&l&&d&&g&&x&&v){let e=a.trigger.getBoundingClientRect(),r=d.getBoundingClientRect(),s=a.valueNode.getBoundingClientRect(),i=v.getBoundingClientRect();if("rtl"!==a.dir){let n=i.left-r.left,a=s.left-n,o=e.left-a,c=e.width+o,d=Math.max(c,r.width),u=oh(a,[10,Math.max(10,window.innerWidth-10-d)]);l.style.minWidth=c+"px",l.style.left=u+"px"}else{let n=r.right-i.right,a=window.innerWidth-s.right-n,o=window.innerWidth-e.right-a,c=e.width+o,d=Math.max(c,r.width),u=oh(a,[10,Math.max(10,window.innerWidth-10-d)]);l.style.minWidth=c+"px",l.style.right=u+"px"}let o=f(),c=window.innerHeight-20,u=g.scrollHeight,h=window.getComputedStyle(d),m=parseInt(h.borderTopWidth,10),_=parseInt(h.paddingTop,10),y=parseInt(h.borderBottomWidth,10),b=m+_+u+parseInt(h.paddingBottom,10)+y,w=Math.min(5*x.offsetHeight,b),S=window.getComputedStyle(g),j=parseInt(S.paddingTop,10),C=parseInt(S.paddingBottom,10),k=e.top+e.height/2-10,N=x.offsetHeight/2,E=m+_+(x.offsetTop+N);if(E<=k){let e=o.length>0&&x===o[o.length-1].ref.current;l.style.bottom="0px";let r=Math.max(c-k,N+(e?C:0)+(d.clientHeight-g.offsetTop-g.offsetHeight)+y);l.style.height=E+r+"px"}else{let e=o.length>0&&x===o[0].ref.current;l.style.top="0px";let r=Math.max(k,m+g.offsetTop+(e?j:0)+N);l.style.height=r+(b-E)+"px",g.scrollTop=E-k+g.offsetTop}l.style.margin="10px 0",l.style.minHeight=w+"px",l.style.maxHeight=c+"px",n?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,l,d,g,x,v,a.dir,n]);V(()=>y(),[y]);let[b,w]=$.useState();V(()=>{d&&w(window.getComputedStyle(d).zIndex)},[d]);let S=$.useCallback(e=>{e&&!0===m.current&&(y(),_?.(),m.current=!1)},[y,_]);return(0,O.jsx)(u6,{scope:s,contentWrapper:l,shouldExpandOnScrollRef:p,onScrollButtonChange:S,children:(0,O.jsx)("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:b},children:(0,O.jsx)(er.div,{...i,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}})})})});u3.displayName="SelectItemAlignedPosition";var u4=$.forwardRef((e,r)=>{let{__scopeSelect:s,align:n="start",collisionPadding:i=10,...a}=e,o=uO(s);return(0,O.jsx)(iA,{...o,...a,ref:r,align:n,collisionPadding:i,style:{boxSizing:"border-box",...a.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});u4.displayName="SelectPopperPosition";var[u6,u7]=uL(uZ,{}),u8="SelectViewport",u9=$.forwardRef((e,r)=>{let{__scopeSelect:s,nonce:n,...i}=e,a=u1(u8,s),o=u7(u8,s),l=(0,U.useComposedRefs)(r,a.onViewportChange),c=$.useRef(0);return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:n}),(0,O.jsx)(uP.Slot,{scope:s,children:(0,O.jsx)(er.div,{"data-radix-select-viewport":"",role:"presentation",...i,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...i.style},onScroll:K(i.onScroll,e=>{let r=e.currentTarget,{contentWrapper:s,shouldExpandOnScrollRef:n}=o;if(n?.current&&s){let e=Math.abs(c.current-r.scrollTop);if(e>0){let n=window.innerHeight-20,i=Math.max(parseFloat(s.style.minHeight),parseFloat(s.style.height));if(i<n){let a=i+e,o=Math.min(n,a),l=a-o;s.style.height=o+"px","0px"===s.style.bottom&&(r.scrollTop=l>0?l:0,s.style.justifyContent="flex-end")}}}c.current=r.scrollTop})})})]})});u9.displayName=u8;var he="SelectGroup",[ht,hr]=uL(he);$.forwardRef((e,r)=>{let{__scopeSelect:s,...n}=e,i=ek();return(0,O.jsx)(ht,{scope:s,id:i,children:(0,O.jsx)(er.div,{role:"group","aria-labelledby":i,...n,ref:r})})}).displayName=he;var hs="SelectLabel";$.forwardRef((e,r)=>{let{__scopeSelect:s,...n}=e,i=hr(hs,s);return(0,O.jsx)(er.div,{id:i.id,...n,ref:r})}).displayName=hs;var hn="SelectItem",[hi,ha]=uL(hn),ho=$.forwardRef((e,r)=>{let{__scopeSelect:s,value:n,disabled:i=!1,textValue:a,...o}=e,l=uW(hn,s),c=u1(hn,s),d=l.value===n,[u,h]=$.useState(a??""),[f,p]=$.useState(!1),m=(0,U.useComposedRefs)(r,e=>c.itemRefCallback?.(e,n,i)),g=ek(),x=$.useRef("touch"),v=()=>{i||(l.onValueChange(n),l.onOpenChange(!1))};if(""===n)throw Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return(0,O.jsx)(hi,{scope:s,value:n,disabled:i,textId:g,isSelected:d,onItemTextChange:$.useCallback(e=>{h(r=>r||(e?.textContent??"").trim())},[]),children:(0,O.jsx)(uP.ItemSlot,{scope:s,value:n,disabled:i,textValue:u,children:(0,O.jsx)(er.div,{role:"option","aria-labelledby":g,"data-highlighted":f?"":void 0,"aria-selected":d&&f,"data-state":d?"checked":"unchecked","aria-disabled":i||void 0,"data-disabled":i?"":void 0,tabIndex:i?void 0:-1,...o,ref:m,onFocus:K(o.onFocus,()=>p(!0)),onBlur:K(o.onBlur,()=>p(!1)),onClick:K(o.onClick,()=>{"mouse"!==x.current&&v()}),onPointerUp:K(o.onPointerUp,()=>{"mouse"===x.current&&v()}),onPointerDown:K(o.onPointerDown,e=>{x.current=e.pointerType}),onPointerMove:K(o.onPointerMove,e=>{x.current=e.pointerType,i?c.onItemLeave?.():"mouse"===x.current&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:K(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:K(o.onKeyDown,e=>{(c.searchRef?.current===""||" "!==e.key)&&(uM.includes(e.key)&&v()," "===e.key&&e.preventDefault())})})})})});ho.displayName=hn;var hl="SelectItemText",hc=$.forwardRef((e,r)=>{let{__scopeSelect:s,className:n,style:i,...a}=e,o=uW(hl,s),l=u1(hl,s),c=ha(hl,s),d=uU(hl,s),[u,h]=$.useState(null),f=(0,U.useComposedRefs)(r,e=>h(e),c.onItemTextChange,e=>l.itemTextRefCallback?.(e,c.value,c.disabled)),p=u?.textContent,m=$.useMemo(()=>(0,O.jsx)("option",{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=d;return V(()=>(g(m),()=>x(m)),[g,x,m]),(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(er.span,{id:c.textId,...a,ref:f}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?ee.createPortal(a.children,o.valueNode):null]})});hc.displayName=hl;var hd="SelectItemIndicator",hu=$.forwardRef((e,r)=>{let{__scopeSelect:s,...n}=e;return ha(hd,s).isSelected?(0,O.jsx)(er.span,{"aria-hidden":!0,...n,ref:r}):null});hu.displayName=hd;var hh="SelectScrollUpButton",hf=$.forwardRef((e,r)=>{let s=u1(hh,e.__scopeSelect),n=u7(hh,e.__scopeSelect),[i,a]=$.useState(!1),o=(0,U.useComposedRefs)(r,n.onScrollButtonChange);return V(()=>{if(s.viewport&&s.isPositioned){let e=function(){a(r.scrollTop>0)},r=s.viewport;return e(),r.addEventListener("scroll",e),()=>r.removeEventListener("scroll",e)}},[s.viewport,s.isPositioned]),i?(0,O.jsx)(hg,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:r}=s;e&&r&&(e.scrollTop=e.scrollTop-r.offsetHeight)}}):null});hf.displayName=hh;var hp="SelectScrollDownButton",hm=$.forwardRef((e,r)=>{let s=u1(hp,e.__scopeSelect),n=u7(hp,e.__scopeSelect),[i,a]=$.useState(!1),o=(0,U.useComposedRefs)(r,n.onScrollButtonChange);return V(()=>{if(s.viewport&&s.isPositioned){let e=function(){let e=r.scrollHeight-r.clientHeight;a(Math.ceil(r.scrollTop)<e)},r=s.viewport;return e(),r.addEventListener("scroll",e),()=>r.removeEventListener("scroll",e)}},[s.viewport,s.isPositioned]),i?(0,O.jsx)(hg,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:r}=s;e&&r&&(e.scrollTop=e.scrollTop+r.offsetHeight)}}):null});hm.displayName=hp;var hg=$.forwardRef((e,r)=>{let{__scopeSelect:s,onAutoScroll:n,...i}=e,a=u1("SelectScrollButton",s),o=$.useRef(null),l=uI(s),c=$.useCallback(()=>{null!==o.current&&(window.clearInterval(o.current),o.current=null)},[]);return $.useEffect(()=>()=>c(),[c]),V(()=>{let e=l().find(e=>e.ref.current===document.activeElement);e?.ref.current?.scrollIntoView({block:"nearest"})},[l]),(0,O.jsx)(er.div,{"aria-hidden":!0,...i,ref:r,style:{flexShrink:0,...i.style},onPointerDown:K(i.onPointerDown,()=>{null===o.current&&(o.current=window.setInterval(n,50))}),onPointerMove:K(i.onPointerMove,()=>{a.onItemLeave?.(),null===o.current&&(o.current=window.setInterval(n,50))}),onPointerLeave:K(i.onPointerLeave,()=>{c()})})});$.forwardRef((e,r)=>{let{__scopeSelect:s,...n}=e;return(0,O.jsx)(er.div,{"aria-hidden":!0,...n,ref:r})}).displayName="SelectSeparator";var hx="SelectArrow";$.forwardRef((e,r)=>{let{__scopeSelect:s,...n}=e,i=uO(s),a=uW(hx,s),o=u1(hx,s);return a.open&&"popper"===o.position?(0,O.jsx)(iF,{...i,...n,ref:r}):null}).displayName=hx;var hv=$.forwardRef(({__scopeSelect:e,value:r,...s},n)=>{let i=$.useRef(null),a=(0,U.useComposedRefs)(n,i),o=X(r);return $.useEffect(()=>{let e=i.current;if(!e)return;let s=Object.getOwnPropertyDescriptor(window.HTMLSelectElement.prototype,"value").set;if(o!==r&&s){let n=new Event("change",{bubbles:!0});s.call(e,r),e.dispatchEvent(n)}},[o,r]),(0,O.jsx)(er.select,{...s,style:{...l1,...s.style},ref:a,defaultValue:r})});function h_(e){return""===e||void 0===e}function hy(e){let r=eN(e),s=$.useRef(""),n=$.useRef(0),i=$.useCallback(e=>{let i=s.current+e;r(i),function e(r){s.current=r,window.clearTimeout(n.current),""!==r&&(n.current=window.setTimeout(()=>e(""),1e3))}(i)},[r]),a=$.useCallback(()=>{s.current="",window.clearTimeout(n.current)},[]);return $.useEffect(()=>()=>window.clearTimeout(n.current),[]),[s,i,a]}function hb(e,r,s){var n,i;let a=r.length>1&&Array.from(r).every(e=>e===r[0])?r[0]:r,o=s?e.indexOf(s):-1,l=(n=e,i=Math.max(o,0),n.map((e,r)=>n[(i+r)%n.length]));1===a.length&&(l=l.filter(e=>e!==s));let c=l.find(e=>e.textValue.toLowerCase().startsWith(a.toLowerCase()));return c!==s?c:void 0}hv.displayName="SelectBubbleInput";var H=H;function hw({...e}){return(0,O.jsx)(uq,{"data-slot":"select",...e})}function hS({...e}){return(0,O.jsx)(uG,{"data-slot":"select-value",...e})}function hj({className:e,size:r="default",children:s,...n}){return(0,O.jsxs)(uV,{"data-slot":"select-trigger","data-size":r,className:(0,ey.cn)("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...n,children:[s,(0,O.jsx)(uX,{asChild:!0,children:(0,O.jsx)(ns,{className:"size-4 opacity-50"})})]})}function hC({className:e,children:r,position:s="item-aligned",align:n="center",...i}){return(0,O.jsx)(uJ,{children:(0,O.jsxs)(uQ,{"data-slot":"select-content",className:(0,ey.cn)("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md","popper"===s&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:s,align:n,...i,children:[(0,O.jsx)(hN,{}),(0,O.jsx)(u9,{className:(0,ey.cn)("p-1","popper"===s&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:r}),(0,O.jsx)(hE,{})]})})}function hk({className:e,children:r,...s}){return(0,O.jsxs)(ho,{"data-slot":"select-item",className:(0,ey.cn)("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...s,children:[(0,O.jsx)("span",{"data-slot":"select-item-indicator",className:"absolute right-2 flex size-3.5 items-center justify-center",children:(0,O.jsx)(hu,{children:(0,O.jsx)(H.default,{className:"size-4"})})}),(0,O.jsx)(hc,{children:r})]})}function hN({className:e,...r}){return(0,O.jsx)(hf,{"data-slot":"select-scroll-up-button",className:(0,ey.cn)("flex cursor-default items-center justify-center py-1",e),...r,children:(0,O.jsx)(oX,{className:"size-4"})})}function hE({className:e,...r}){return(0,O.jsx)(hm,{"data-slot":"select-scroll-down-button",className:(0,ey.cn)("flex cursor-default items-center justify-center py-1",e),...r,children:(0,O.jsx)(ns,{className:"size-4"})})}let hD="__main__";function hR({open:e,onOpenChange:r,onSubmit:s,initial:n,worktrees:i,projectId:a}){let[o,l]=(0,$.useState)(""),[c,d]=(0,$.useState)("0 9 * * *"),[u,h]=(0,$.useState)(""),[f,p]=(0,$.useState)("local"),[m,g]=(0,$.useState)([]),[x,v]=(0,$.useState)("command"),[_,y]=(0,$.useState)("claude"),[b,w]=(0,$.useState)(""),[S,j]=(0,$.useState)("branch"),[C,k]=(0,$.useState)(hD),[N,E]=(0,$.useState)(i),[D,R]=(0,$.useState)(""),[A,T]=(0,$.useState)("30"),[M,F]=(0,$.useState)(!1),[P,I]=(0,$.useState)(null);(0,$.useEffect)(()=>{e&&(I(null),l(n?.name??""),d(n?.cron_expr??"0 9 * * *"),h(n?.timezone??Intl.DateTimeFormat().resolvedOptions().timeZone),p(n?.target??"local"),v(n?.run_type??"command"),y(n?.prompt_provider??"claude"),w(n?.content??""),j(n?.cwd_mode??"branch"),k(n?.branch??hD),R(n?.directory??""),T(String(Math.round((n?.timeout_seconds??1800)/60))))},[e,n]),(0,$.useEffect)(()=>{"local"===f&&E(i)},[f,i]),(0,$.useEffect)(()=>{let r=!1;return e&&a&&rv.api.getProjectRemotes(a).then(e=>{r||g(e)}).catch(e=>console.error("Failed to load project remotes:",e)),()=>{r=!0}},[e,a]),(0,$.useEffect)(()=>{let r=!1;if(e&&a&&"local"!==f)return rv.api.getProjectWorktrees(a,f).then(e=>{r||E(e)}).catch(e=>{console.error("Failed to load target worktrees:",e),r||E([{branch:null}])}),()=>{r=!0}},[e,a,f]);let B=async()=>{if(!o.trim()||!b.trim())return void I("Name and content are required");let e=parseInt(A,10);if(!Number.isInteger(e)||e<=0)return void I("Timeout must be a positive number of minutes");if("directory"===S&&!D.trim())return void I("Directory is required");F(!0),I(null);try{await s({name:o.trim(),cron_expr:c.trim(),timezone:u.trim()||"UTC",target:f,run_type:x,prompt_provider:"prompt"===x?_:null,content:b,cwd_mode:S,branch:"branch"===S?C===hD?null:C:null,directory:"directory"===S?D.trim():null,timeout_seconds:60*e}),r(!1)}catch(e){I(e instanceof Error?e.message:"Failed to save schedule")}finally{F(!1)}};return(0,O.jsx)(t8,{open:e,onOpenChange:r,children:(0,O.jsxs)(rr,{className:"max-w-lg",children:[(0,O.jsxs)(rs,{children:[(0,O.jsx)(ri,{children:n?"Edit Scheduled Task":"New Scheduled Task"}),(0,O.jsx)(ra,{children:"Run a command or a Claude prompt on a cron schedule"})]}),(0,O.jsxs)("div",{className:"space-y-4",children:[(0,O.jsxs)("div",{className:"space-y-2",children:[(0,O.jsx)("label",{className:"text-sm font-medium",children:"Name"}),(0,O.jsx)(ro,{value:o,onChange:e=>l(e.target.value),placeholder:"Daily log analysis",disabled:M})]}),(0,O.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,O.jsxs)("div",{className:"space-y-2",children:[(0,O.jsx)("label",{className:"text-sm font-medium",children:"Cron"}),(0,O.jsx)(ro,{value:c,onChange:e=>d(e.target.value),placeholder:"0 9 * * *",className:"font-mono",disabled:M}),(0,O.jsx)("p",{className:"text-xs text-muted-foreground",children:"5-field cron — “0 9 * * *” = every day at 09:00"})]}),(0,O.jsxs)("div",{className:"space-y-2",children:[(0,O.jsx)("label",{className:"text-sm font-medium",children:"Timezone"}),(0,O.jsx)(ro,{value:u,onChange:e=>h(e.target.value),placeholder:"Asia/Shanghai",disabled:M})]})]}),(0,O.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,O.jsxs)("div",{className:"space-y-2",children:[(0,O.jsx)("label",{className:"text-sm font-medium",children:"Type"}),(0,O.jsxs)(hw,{value:x,onValueChange:e=>v(e),disabled:M,children:[(0,O.jsx)(hj,{size:"sm",children:(0,O.jsx)(hS,{})}),(0,O.jsxs)(hC,{children:[(0,O.jsx)(hk,{value:"command",children:"Command (shell)"}),(0,O.jsx)(hk,{value:"prompt",children:"Prompt"})]})]})]}),"prompt"===x&&(0,O.jsxs)("div",{className:"space-y-2",children:[(0,O.jsx)("label",{className:"text-sm font-medium",children:"Agent"}),(0,O.jsxs)(hw,{value:_,onValueChange:e=>y(e),disabled:M,children:[(0,O.jsx)(hj,{size:"sm",children:(0,O.jsx)(hS,{})}),(0,O.jsxs)(hC,{children:[(0,O.jsx)(hk,{value:"claude",children:"Claude"}),(0,O.jsx)(hk,{value:"codex",children:"Codex"})]})]})]})]}),(0,O.jsxs)("div",{className:"space-y-2",children:[(0,O.jsx)("label",{className:"text-sm font-medium",children:"command"===x?"Command":"Prompt"}),(0,O.jsx)(rl,{value:b,onChange:e=>w(e.target.value),placeholder:"command"===x?"./scripts/scan.sh --daily":"Analyze today's server logs under ./logs and summarize anomalies",className:"font-mono text-sm min-h-[80px]",disabled:M})]}),(0,O.jsxs)("div",{className:"space-y-2",children:[(0,O.jsx)("label",{className:"text-sm font-medium",children:"Target"}),(0,O.jsxs)(hw,{value:f,onValueChange:e=>{p(e),k(hD)},disabled:M,children:[(0,O.jsx)(hj,{size:"sm",children:(0,O.jsx)(hS,{placeholder:"Local"})}),(0,O.jsxs)(hC,{children:[(0,O.jsx)(hk,{value:"local",children:"Local"}),m.map(e=>(0,O.jsx)(hk,{value:e.remote_server_id,children:e.server_name??e.remote_server_id},e.remote_server_id))]})]})]}),(0,O.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,O.jsxs)("div",{className:"space-y-2",children:[(0,O.jsx)("label",{className:"text-sm font-medium",children:"Runs in"}),(0,O.jsxs)(hw,{value:S,onValueChange:e=>j(e),disabled:M,children:[(0,O.jsx)(hj,{size:"sm",children:(0,O.jsx)(hS,{})}),(0,O.jsxs)(hC,{children:[(0,O.jsx)(hk,{value:"branch",children:"Workspace (branch)"}),(0,O.jsx)(hk,{value:"directory",children:"Directory"})]})]})]}),(0,O.jsx)("div",{className:"space-y-2",children:"branch"===S?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)("label",{className:"text-sm font-medium",children:"Workspace"}),(0,O.jsxs)(hw,{value:C,onValueChange:k,disabled:M,children:[(0,O.jsx)(hj,{size:"sm",children:(0,O.jsx)(hS,{placeholder:"Select workspace"})}),(0,O.jsx)(hC,{children:N.map(e=>(0,O.jsx)(hk,{value:e.branch??hD,children:e.branch??"main"},e.branch??hD))})]})]}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)("label",{className:"text-sm font-medium",children:"Directory"}),(0,O.jsx)(ro,{value:D,onChange:e=>R(e.target.value),placeholder:"/var/log/myapp",className:"font-mono",disabled:M})]})})]}),(0,O.jsxs)("div",{className:"space-y-2",children:[(0,O.jsx)("label",{className:"text-sm font-medium",children:"Timeout (minutes)"}),(0,O.jsx)(ro,{value:A,onChange:e=>T(e.target.value),className:"w-24",disabled:M})]}),P&&(0,O.jsx)("div",{className:"text-sm text-destructive bg-destructive/10 px-3 py-2 rounded-md",children:P})]}),(0,O.jsxs)(rn,{children:[(0,O.jsx)(W.Button,{variant:"outline",onClick:()=>r(!1),disabled:M,children:"Cancel"}),(0,O.jsx)(W.Button,{onClick:B,disabled:M||!o.trim()||!b.trim(),children:M?"Saving...":n?"Save":"Create"})]})]})})}let hA={running:"bg-blue-500/15 text-blue-600",completed:"bg-emerald-500/15 text-emerald-600",failed:"bg-red-500/15 text-red-600",timeout:"bg-amber-500/15 text-amber-600",killed:"bg-amber-500/15 text-amber-600",skipped:"bg-muted text-muted-foreground"},hT=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;function hM(e){return e.replace(hT,"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")}function hF(e){return new Date(e.includes("T")?e:e.replace(" ","T")+"Z")}function hP(e){return e?hF(e).toLocaleString():"—"}function hI(e){if(!e.finished_at)return"…";let r=Math.max(0,Math.round((hF(e.finished_at).getTime()-hF(e.started_at).getTime())/1e3));return r<60?`${r}s`:`${Math.floor(r/60)}m ${r%60}s`}function hB({projectId:e,schedules:r,loading:s,selectedId:n,onSelect:i,worktrees:a,onCreate:o,onUpdate:l,onDelete:c,onRunNow:d,createOpen:u,onCreateOpenChange:h,openRunId:f,onOpenRunHandled:p}){let m=r.find(e=>e.id===n)??r[0]??null,[g,x]=(0,$.useState)([]),[v,_]=(0,$.useState)(!1),[y,b]=(0,$.useState)(null),[w,S]=(0,$.useState)(null),[j,C]=(0,$.useState)(0),[k,N]=(0,$.useState)(null),[E,D]=(0,$.useState)(null),[R,A]=(0,$.useState)(null),T=(0,$.useCallback)(async e=>{try{return await rv.api.getScheduleRuns(e)}catch(e){return console.error("Failed to fetch schedule runs:",e),null}},[]);(0,$.useEffect)(()=>{let e=m?.id,r=!1;return(e?T(e):Promise.resolve([])).then(e=>{if(r)return;let s=e??[];x(s),b(e=>e&&(e===w||s.some(r=>r.id===e&&"skipped"!==r.status))?e:s.find(e=>"skipped"!==e.status)?.id??null)}),()=>{r=!0}},[m?.id,r,T,w]);let M=g.find(e=>e.id===y&&e.schedule_id===m?.id),F=M?`${M.status}:${M.finished_at??""}`:null;(0,$.useEffect)(()=>{if(!y)return;let e=!1;return rv.api.getScheduleRun(y).then(r=>{e||N({runId:y,nonce:j,run:r,error:null})},r=>{e||N({runId:y,nonce:j,run:null,error:r instanceof Error?r.message:"Failed to load run output"})}),()=>{e=!0}},[y,j,F]);let P=async()=>{if(m){D(null);try{await d(m.id)}catch(e){D(e instanceof Error?e.message:"Failed to start run")}}};(0,$.useEffect)(()=>{f&&(S(f),b(f),p?.(f))},[f,p]);let I=m?g.filter(e=>e.schedule_id===m.id):[],B=y===w||I.some(e=>e.id===y&&"skipped"!==e.status),L=B&&k?.runId===y&&k.nonce===j?k:null;return s||0!==r.length?(0,O.jsxs)("div",{className:"flex flex-col h-full",children:[m&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(dh,{title:m.name,description:`${m.cron_expr} \xb7 ${m.timezone} \xb7 next: ${hP(m.next_run_at)}`,actions:(0,O.jsxs)("div",{className:"flex items-center gap-2",children:[(0,O.jsxs)(W.Button,{size:"sm",onClick:P,disabled:!!m.running,children:[(0,O.jsx)(rh,{className:"h-3.5 w-3.5 mr-1.5"}),m.running?"Running…":"Run now"]}),(0,O.jsxs)("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[(0,O.jsx)("input",{type:"checkbox",checked:m.enabled,onChange:e=>void l(m.id,{enabled:e.target.checked}),className:"h-4 w-4 rounded border-input accent-primary"}),(0,O.jsx)("span",{children:"Enabled"})]}),(0,O.jsx)(W.Button,{size:"sm",variant:"outline",onClick:()=>_(!0),children:(0,O.jsx)(rg,{className:"h-3.5 w-3.5"})}),(0,O.jsx)(W.Button,{size:"sm",variant:"outline",onClick:()=>{m&&A(m)},className:"hover:bg-destructive/15 hover:text-destructive",children:(0,O.jsx)(rc,{className:"h-3.5 w-3.5"})})]})}),(0,O.jsxs)("div",{className:"px-5 py-3 grid grid-cols-2 gap-x-8 gap-y-1 text-sm border-b border-border/50",children:[(0,O.jsxs)("div",{children:[(0,O.jsx)("span",{className:"text-muted-foreground",children:"Type: "}),"command"===m.run_type?"Command":`Prompt (${"codex"===m.prompt_provider?"Codex":"Claude"})`]}),(0,O.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,O.jsx)("span",{className:"text-muted-foreground",children:"Runs in: "}),"branch"===m.cwd_mode?`workspace ${m.branch??"main"}`:m.directory,"local"!==m.target&&(0,O.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-violet-500/15 text-violet-600",children:"remote"})]}),(0,O.jsx)("div",{className:"col-span-2 font-mono text-xs text-muted-foreground truncate",title:m.content,children:m.content}),(0,O.jsxs)("div",{children:[(0,O.jsx)("span",{className:"text-muted-foreground",children:"Timeout: "}),Math.round(m.timeout_seconds/60),"m"]})]}),E&&(0,O.jsx)("div",{className:"mx-5 mt-3 text-sm text-destructive bg-destructive/10 px-3 py-2 rounded-md",children:E}),(0,O.jsx)("div",{className:"flex-1 min-h-0",children:(0,O.jsxs)(uj,{direction:"horizontal",autoSaveId:"schedule-run-panels",children:[(0,O.jsx)(dN,{defaultSize:33,minSize:25,children:(0,O.jsx)("div",{className:"h-full overflow-auto px-5 py-3",children:(0,O.jsxs)(uk,{children:[(0,O.jsx)(uN,{children:(0,O.jsxs)(uD,{children:[(0,O.jsx)(uR,{children:"Started"}),(0,O.jsx)(uR,{children:"Duration"}),(0,O.jsx)(uR,{children:"Status"}),(0,O.jsx)(uR,{children:"Exit code"})]})}),(0,O.jsxs)(uE,{children:[I.map(e=>(0,O.jsxs)(uD,{onClick:()=>{"skipped"!==e.status&&(S(null),b(e.id))},"aria-disabled":"skipped"===e.status,className:(0,ey.cn)("skipped"!==e.status&&"cursor-pointer",e.id===y&&"bg-muted/50"),children:[(0,O.jsx)(uA,{children:hP(e.started_at)}),(0,O.jsx)(uA,{children:"skipped"===e.status?"—":hI(e)}),(0,O.jsx)(uA,{children:(0,O.jsx)("span",{className:(0,ey.cn)("px-1.5 py-0.5 rounded text-[11px] font-medium",hA[e.status]),children:e.status})}),(0,O.jsx)(uA,{children:e.exit_code??"—"})]},e.id)),0===I.length&&(0,O.jsx)(uD,{children:(0,O.jsx)(uA,{colSpan:4,className:"text-center text-muted-foreground",children:"No runs yet — click “Run now” to try it"})})]})]})})}),(0,O.jsx)(uC,{withHandle:!0}),(0,O.jsx)(dN,{defaultSize:67,minSize:25,children:(0,O.jsx)("div",{className:"h-full overflow-auto px-5 py-4",children:B&&!L?(0,O.jsx)("div",{className:"h-full flex items-center justify-center text-sm text-muted-foreground",children:"Loading run output…"}):L?.error?(0,O.jsxs)("div",{className:"h-full flex flex-col items-center justify-center gap-3 text-sm",children:[(0,O.jsx)("div",{className:"text-destructive",children:L.error}),(0,O.jsx)(W.Button,{size:"sm",variant:"outline",onClick:()=>C(e=>e+1),children:"Retry"})]}):L?.run?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)("div",{className:"mb-4 pb-3 border-b border-border/60",children:[(0,O.jsxs)("div",{className:"text-sm font-medium",children:[L.run.report?"Run report":"Run output"," — ",hP(L.run.started_at)]}),(0,O.jsxs)("div",{className:"mt-2 flex items-center gap-3 text-xs text-muted-foreground",children:[(0,O.jsx)("span",{className:(0,ey.cn)("px-1.5 py-0.5 rounded text-[11px] font-medium",hA[L.run.status]),children:L.run.status}),(0,O.jsx)("span",{children:hI(L.run)}),(0,O.jsxs)("span",{children:["Exit code: ",L.run.exit_code??"—"]})]})]}),L.run.report?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)("div",{className:"rounded-md border border-border/50 p-3 text-sm",children:(0,O.jsx)(ck.i,{className:"[&>*:first-child]:mt-0 [&>*:last-child]:mb-0",children:L.run.report})}),(0,O.jsxs)("details",{className:"mt-3",children:[(0,O.jsx)("summary",{className:"text-xs text-muted-foreground cursor-pointer select-none",children:"Raw output"}),(0,O.jsx)("pre",{className:"mt-2 overflow-auto rounded-md bg-muted/50 p-3 font-mono text-xs whitespace-pre-wrap",children:L.run.output?hM(L.run.output):"(no output captured)"})]})]}):(0,O.jsx)("pre",{className:"overflow-auto rounded-md bg-muted/50 p-3 font-mono text-xs whitespace-pre-wrap",children:L.run.output?hM(L.run.output):"(no output captured)"})]}):(0,O.jsx)("div",{className:"h-full flex items-center justify-center text-sm text-muted-foreground",children:"Select a run to view its output"})})})]})}),(0,O.jsx)(hR,{open:v,onOpenChange:_,initial:m,onSubmit:async e=>{await l(m.id,e)},worktrees:a,projectId:e})]}),(0,O.jsx)(hR,{open:u,onOpenChange:h,onSubmit:async e=>{i((await o(e)).id)},worktrees:a,projectId:e}),(0,O.jsx)(lL,{open:null!==R,onOpenChange:e=>{e||A(null)},children:(0,O.jsxs)(l$,{children:[(0,O.jsxs)(lW,{children:[(0,O.jsx)(lU,{children:"Delete scheduled task?"}),(0,O.jsx)(lq,{children:R?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)("span",{className:"font-medium text-foreground",children:R.name})," ","and its run history will be permanently deleted. This cannot be undone."]}):null})]}),(0,O.jsxs)(lH,{children:[(0,O.jsx)(lV,{children:"Cancel"}),(0,O.jsx)(lK,{className:(0,ey.cn)((0,W.buttonVariants)({variant:"destructive"}),"border-transparent"),onClick:()=>{A(null),R&&(D(null),c(R.id).catch(e=>{D(e instanceof Error?e.message:"Failed to delete")}))},children:"Delete"})]})]})})]}):(0,O.jsxs)("div",{className:"flex flex-col h-full items-center justify-center gap-3 text-center",children:[(0,O.jsx)(sw,{className:"h-8 w-8 text-muted-foreground/50"}),(0,O.jsx)("p",{className:"text-sm text-muted-foreground",children:"No scheduled tasks yet"}),(0,O.jsx)(W.Button,{size:"sm",onClick:()=>h(!0),children:"New Scheduled Task"}),(0,O.jsx)(hR,{open:u,onOpenChange:h,onSubmit:async e=>{await o(e)},worktrees:a,projectId:e})]})}var hL=e.i(423917);function hz({className:e}){return(0,O.jsx)("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:(0,ey.cn)("h-4 w-4",e),"aria-hidden":"true",children:(0,O.jsx)("path",{d:"M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189z"})})}function hO({inviteUrl:e}){return e?(0,O.jsx)(W.Button,{asChild:!0,variant:"ghost",size:"icon-sm",title:"Join our Discord",children:(0,O.jsx)("a",{href:e,target:"_blank",rel:"noopener noreferrer","aria-label":"Join our Discord",children:(0,O.jsx)(hz,{})})}):null}function h$({open:e,onOpenChange:r,onProjectCreated:s}){let{config:n}=(0,hL.useAppConfig)(),i=n?.localProjectsEnabled!==!1,[a,o]=(0,$.useState)(""),[l,c]=(0,$.useState)(""),[d,u]=(0,$.useState)([]),[h,f]=(0,$.useState)("closed"),[p,m]=(0,$.useState)([]),[g,x]=(0,$.useState)(null),[v,_]=(0,$.useState)(""),[y,b]=(0,$.useState)(!1),[w,S]=(0,$.useState)(""),j=()=>{o(""),c(""),u([]),C(),S("")},C=()=>{f("closed"),x(null),_("")},k=e=>{e||j(),r(e)},N=async()=>{let e=await rv.api.selectFolder();e.path&&(c(e.path),a||o(e.path.split("/").pop()||""))},E=async()=>{f("pick-server");try{let e=await rv.api.getRemoteServers();m(e)}catch{m([])}},D=l.trim().length>0,R=d.length>0,A=async()=>{if(!a.trim())return void S("Project name is required");if(!D&&!R)return void S(i?"Please provide a local folder, remote server, or both":"Please add a remote server");b(!0),S("");try{let e=await rv.api.createProject({name:a.trim(),...D?{path:l.trim()}:{},...R&&!D?{agentMode:d[0].serverId}:{}});for(let r of d)await rv.api.addProjectRemote(e.id,{remoteServerId:r.serverId,remotePath:r.remotePath});s(e),j(),r(!1)}catch(e){S(e instanceof Error?e.message:"Failed to create project")}finally{b(!1)}};return(0,O.jsx)(t8,{open:e,onOpenChange:k,children:(0,O.jsxs)(rr,{className:"max-w-lg h-[620px] max-h-[calc(100vh-4rem)] grid-rows-[auto_minmax(0,1fr)_auto]",children:[(0,O.jsx)(rs,{children:(0,O.jsx)(ri,{children:"Create New Project"})}),(0,O.jsx)("div",{className:"overflow-y-auto -mx-1 px-1",children:(0,O.jsxs)("div",{className:"space-y-5 py-2",children:[(0,O.jsxs)("div",{className:"space-y-2",children:[(0,O.jsx)("label",{className:"text-sm font-medium",children:"Project Name"}),(0,O.jsx)(ro,{value:a,onChange:e=>o(e.target.value),placeholder:"My Project"})]}),i&&(0,O.jsxs)("div",{className:"space-y-2",children:[(0,O.jsx)("label",{className:"text-sm font-medium",children:"Local Folder"}),(0,O.jsxs)("div",{className:"flex gap-2",children:[(0,O.jsx)(ro,{value:l,onChange:e=>c(e.target.value),placeholder:"/path/to/project (optional)",className:"flex-1"}),(0,O.jsx)(W.Button,{variant:"outline",onClick:N,children:(0,O.jsx)(r_,{className:"h-4 w-4"})})]})]}),(0,O.jsxs)("div",{className:"space-y-3",children:[(0,O.jsx)("label",{className:"text-sm font-medium",children:"Remote Servers"}),d.length>0&&(0,O.jsx)("div",{className:"space-y-2",children:d.map((e,r)=>(0,O.jsxs)("div",{className:"flex items-center gap-2 rounded-md border p-2 text-sm",children:[(0,O.jsx)(ry,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,O.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,O.jsx)("p",{className:"font-medium truncate",children:e.serverName}),(0,O.jsx)("p",{className:"text-xs text-muted-foreground font-mono truncate",children:e.remotePath})]}),(0,O.jsx)(W.Button,{variant:"ghost",size:"icon-sm",className:"h-7 w-7 shrink-0",onClick:()=>{u(e=>e.filter((e,s)=>s!==r))},children:(0,O.jsx)(rc,{className:"h-3.5 w-3.5 text-muted-foreground"})})]},`${e.serverId}-${e.remotePath}`))}),"closed"===h&&(0,O.jsxs)(W.Button,{variant:"outline",size:"sm",onClick:E,className:"w-full",children:[(0,O.jsx)(eS,{className:"h-4 w-4 mr-1"}),"Add Remote"]}),"pick-server"===h&&(0,O.jsxs)("div",{className:"rounded-md border p-3 space-y-3",children:[(0,O.jsxs)("div",{className:"flex items-center justify-between",children:[(0,O.jsx)("label",{className:"text-xs font-medium",children:"Select a Remote Server"}),(0,O.jsx)(W.Button,{variant:"ghost",size:"sm",onClick:C,children:(0,O.jsx)(t7,{className:"h-3.5 w-3.5"})})]}),p.length>0&&(0,O.jsx)("div",{className:"space-y-1",children:p.map(e=>(0,O.jsxs)("button",{className:"flex items-center gap-2 w-full rounded-md p-2 text-sm text-left hover:bg-muted",onClick:()=>{x(e),_(""),f("pick-path")},children:[(0,O.jsx)(od,{className:"h-4 w-4 text-muted-foreground"}),(0,O.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,O.jsx)("p",{className:"truncate",children:e.name}),(0,O.jsx)("p",{className:"text-xs text-muted-foreground truncate",children:"online"===e.status?"Connected":"Not connected"})]})]},e.id))}),(0,O.jsx)("p",{className:"text-xs text-muted-foreground",children:"Add new servers in Settings → Remote Servers, then connect the remote machine with a connect token."})]}),"pick-path"===h&&g&&(0,O.jsxs)("div",{className:"rounded-md border p-3 space-y-3",children:[(0,O.jsxs)("div",{className:"flex items-center justify-between",children:[(0,O.jsxs)("label",{className:"text-xs font-medium",children:["Select Directory on ",g.name]}),(0,O.jsx)(W.Button,{variant:"ghost",size:"sm",onClick:C,children:(0,O.jsx)(t7,{className:"h-3.5 w-3.5"})})]}),(0,O.jsx)(oJ,{serverId:g.id,onSelect:e=>{_(e)},selectedPath:v}),v&&(0,O.jsxs)("div",{className:"flex items-center justify-between",children:[(0,O.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Selected: ",(0,O.jsx)("span",{className:"font-mono",children:v})]}),(0,O.jsx)(W.Button,{size:"sm",onClick:()=>{g&&v&&(d.some(e=>e.serverId===g.id&&e.remotePath===v)||(u(e=>[...e,{serverId:g.id,serverName:g.name,remotePath:v}]),a||o(v.split("/").pop()||"")),C())},children:"Add"})]})]})]}),w&&(0,O.jsx)("p",{className:"text-sm text-red-500 pt-3",children:w})]})}),(0,O.jsxs)(rn,{children:[(0,O.jsx)(W.Button,{variant:"outline",onClick:()=>k(!1),children:"Cancel"}),(0,O.jsx)(W.Button,{onClick:A,disabled:y,children:y?"Creating...":"Create Project"})]})]})})}let hW=(0,ew.default)("network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]),hH=(0,ew.default)("palette",[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]]),hU=(0,ew.default)("sparkles",[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]]),hq=(0,ew.default)("square-terminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]),hK=(0,ew.default)("moon",[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]),hV=(0,ew.default)("sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);var hY=e.i(371263),hG=e.i(909596),hX=["PageUp","PageDown"],hJ=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],hZ={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},hQ="Slider",[h0,h1,h2]=rb(hQ),[h5,h3]=q(hQ,[h2]),[h4,h6]=h5(hQ),h7=$.forwardRef((e,r)=>{let{name:s,min:n=0,max:i=100,step:a=1,orientation:o="horizontal",disabled:l=!1,minStepsBetweenThumbs:c=0,defaultValue:d=[n],value:u,onValueChange:h=()=>{},onValueCommit:f=()=>{},inverted:p=!1,form:m,...g}=e,x=$.useRef(new Set),v=$.useRef(0),_="horizontal"===o,[y=[],b]=G({prop:u,defaultProp:d,onChange:e=>{let r=[...x.current];r[v.current]?.focus(),h(e)}}),w=$.useRef(y);function S(e,r,{commit:s}={commit:!1}){let o,l=(String(a).split(".")[1]||"").length,d=oh(Math.round((Math.round((e-n)/a)*a+n)*(o=Math.pow(10,l)))/o,[n,i]);b((e=[])=>{let n=function(e=[],r,s){let n=[...e];return n[s]=r,n.sort((e,r)=>e-r)}(e,d,r);if(!function(e,r){if(r>0)return Math.min(...e.slice(0,-1).map((r,s)=>e[s+1]-r))>=r;return!0}(n,c*a))return e;{v.current=n.indexOf(d);let r=String(n)!==String(e);return r&&s&&f(n),r?n:e}})}return(0,O.jsx)(h4,{scope:e.__scopeSlider,name:s,disabled:l,min:n,max:i,valueIndexToChangeRef:v,thumbs:x.current,values:y,orientation:o,form:m,children:(0,O.jsx)(h0.Provider,{scope:e.__scopeSlider,children:(0,O.jsx)(h0.Slot,{scope:e.__scopeSlider,children:(0,O.jsx)(_?fe:ft,{"aria-disabled":l,"data-disabled":l?"":void 0,...g,ref:r,onPointerDown:K(g.onPointerDown,()=>{l||(w.current=y)}),min:n,max:i,inverted:p,onSlideStart:l?void 0:function(e){let r=function(e,r){if(1===e.length)return 0;let s=e.map(e=>Math.abs(e-r)),n=Math.min(...s);return s.indexOf(n)}(y,e);S(e,r)},onSlideMove:l?void 0:function(e){S(e,v.current)},onSlideEnd:l?void 0:function(){let e=w.current[v.current];y[v.current]!==e&&f(y)},onHomeKeyDown:()=>!l&&S(n,0,{commit:!0}),onEndKeyDown:()=>!l&&S(i,y.length-1,{commit:!0}),onStepKeyDown:({event:e,direction:r})=>{if(!l){let s=hX.includes(e.key)||e.shiftKey&&hJ.includes(e.key),n=v.current;S(y[n]+a*(s?10:1)*r,n,{commit:!0})}}})})})})});h7.displayName=hQ;var[h8,h9]=h5(hQ,{startEdge:"left",endEdge:"right",size:"width",direction:1}),fe=$.forwardRef((e,r)=>{let{min:s,max:n,dir:i,inverted:a,onSlideStart:o,onSlideMove:l,onSlideEnd:c,onStepKeyDown:d,...u}=e,[h,f]=$.useState(null),p=(0,U.useComposedRefs)(r,e=>f(e)),m=$.useRef(void 0),g=rk(i),x="ltr"===g,v=x&&!a||!x&&a;function _(e){let r=m.current||h.getBoundingClientRect(),i=fh([0,r.width],v?[s,n]:[n,s]);return m.current=r,i(e-r.left)}return(0,O.jsx)(h8,{scope:e.__scopeSlider,startEdge:v?"left":"right",endEdge:v?"right":"left",direction:v?1:-1,size:"width",children:(0,O.jsx)(fr,{dir:g,"data-orientation":"horizontal",...u,ref:p,style:{...u.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:e=>{let r=_(e.clientX);o?.(r)},onSlideMove:e=>{let r=_(e.clientX);l?.(r)},onSlideEnd:()=>{m.current=void 0,c?.()},onStepKeyDown:e=>{let r=hZ[v?"from-left":"from-right"].includes(e.key);d?.({event:e,direction:r?-1:1})}})})}),ft=$.forwardRef((e,r)=>{let{min:s,max:n,inverted:i,onSlideStart:a,onSlideMove:o,onSlideEnd:l,onStepKeyDown:c,...d}=e,u=$.useRef(null),h=(0,U.useComposedRefs)(r,u),f=$.useRef(void 0),p=!i;function m(e){let r=f.current||u.current.getBoundingClientRect(),i=fh([0,r.height],p?[n,s]:[s,n]);return f.current=r,i(e-r.top)}return(0,O.jsx)(h8,{scope:e.__scopeSlider,startEdge:p?"bottom":"top",endEdge:p?"top":"bottom",size:"height",direction:p?1:-1,children:(0,O.jsx)(fr,{"data-orientation":"vertical",...d,ref:h,style:{...d.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:e=>{let r=m(e.clientY);a?.(r)},onSlideMove:e=>{let r=m(e.clientY);o?.(r)},onSlideEnd:()=>{f.current=void 0,l?.()},onStepKeyDown:e=>{let r=hZ[p?"from-bottom":"from-top"].includes(e.key);c?.({event:e,direction:r?-1:1})}})})}),fr=$.forwardRef((e,r)=>{let{__scopeSlider:s,onSlideStart:n,onSlideMove:i,onSlideEnd:a,onHomeKeyDown:o,onEndKeyDown:l,onStepKeyDown:c,...d}=e,u=h6(hQ,s);return(0,O.jsx)(er.span,{...d,ref:r,onKeyDown:K(e.onKeyDown,e=>{"Home"===e.key?(o(e),e.preventDefault()):"End"===e.key?(l(e),e.preventDefault()):hX.concat(hJ).includes(e.key)&&(c(e),e.preventDefault())}),onPointerDown:K(e.onPointerDown,e=>{let r=e.target;r.setPointerCapture(e.pointerId),e.preventDefault(),u.thumbs.has(r)?r.focus():n(e)}),onPointerMove:K(e.onPointerMove,e=>{e.target.hasPointerCapture(e.pointerId)&&i(e)}),onPointerUp:K(e.onPointerUp,e=>{let r=e.target;r.hasPointerCapture(e.pointerId)&&(r.releasePointerCapture(e.pointerId),a(e))})})}),fs="SliderTrack",fn=$.forwardRef((e,r)=>{let{__scopeSlider:s,...n}=e,i=h6(fs,s);return(0,O.jsx)(er.span,{"data-disabled":i.disabled?"":void 0,"data-orientation":i.orientation,...n,ref:r})});fn.displayName=fs;var fi="SliderRange",fa=$.forwardRef((e,r)=>{let{__scopeSlider:s,...n}=e,i=h6(fi,s),a=h9(fi,s),o=$.useRef(null),l=(0,U.useComposedRefs)(r,o),c=i.values.length,d=i.values.map(e=>fu(e,i.min,i.max)),u=c>1?Math.min(...d):0,h=100-Math.max(...d);return(0,O.jsx)(er.span,{"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,...n,ref:l,style:{...e.style,[a.startEdge]:u+"%",[a.endEdge]:h+"%"}})});fa.displayName=fi;var fo="SliderThumb",fl=$.forwardRef((e,r)=>{let s=h1(e.__scopeSlider),[n,i]=$.useState(null),a=(0,U.useComposedRefs)(r,e=>i(e)),o=$.useMemo(()=>n?s().findIndex(e=>e.ref.current===n):-1,[s,n]);return(0,O.jsx)(fc,{...e,ref:a,index:o})}),fc=$.forwardRef((e,r)=>{var s,n,i,a,o;let l,c,{__scopeSlider:d,index:u,name:h,...f}=e,p=h6(fo,d),m=h9(fo,d),[g,x]=$.useState(null),v=(0,U.useComposedRefs)(r,e=>x(e)),_=!g||p.form||!!g.closest("form"),y=J(g),b=p.values[u],w=void 0===b?0:fu(b,p.min,p.max),S=(s=u,(n=p.values.length)>2?`Value ${s+1} of ${n}`:2===n?["Minimum","Maximum"][s]:void 0),j=y?.[m.size],C=j?(i=j,a=w,o=m.direction,c=fh([0,50],[0,l=i/2]),(l-c(a)*o)*o):0;return $.useEffect(()=>{if(g)return p.thumbs.add(g),()=>{p.thumbs.delete(g)}},[g,p.thumbs]),(0,O.jsxs)("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[m.startEdge]:`calc(${w}% + ${C}px)`},children:[(0,O.jsx)(h0.ItemSlot,{scope:e.__scopeSlider,children:(0,O.jsx)(er.span,{role:"slider","aria-label":e["aria-label"]||S,"aria-valuemin":p.min,"aria-valuenow":b,"aria-valuemax":p.max,"aria-orientation":p.orientation,"data-orientation":p.orientation,"data-disabled":p.disabled?"":void 0,tabIndex:p.disabled?void 0:0,...f,ref:v,style:void 0===b?{display:"none"}:e.style,onFocus:K(e.onFocus,()=>{p.valueIndexToChangeRef.current=u})})}),_&&(0,O.jsx)(fd,{name:h??(p.name?p.name+(p.values.length>1?"[]":""):void 0),form:p.form,value:b},u)]})});fl.displayName=fo;var fd=$.forwardRef(({__scopeSlider:e,value:r,...s},n)=>{let i=$.useRef(null),a=(0,U.useComposedRefs)(i,n),o=X(r);return $.useEffect(()=>{let e=i.current;if(!e)return;let s=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value").set;if(o!==r&&s){let n=new Event("input",{bubbles:!0});s.call(e,r),e.dispatchEvent(n)}},[o,r]),(0,O.jsx)(er.input,{style:{display:"none"},...s,ref:a,defaultValue:r})});function fu(e,r,s){return oh(100/(s-r)*(e-r),[0,100])}function fh(e,r){return s=>{if(e[0]===e[1]||r[0]===r[1])return r[0];let n=(r[1]-r[0])/(e[1]-e[0]);return r[0]+n*(s-e[0])}}fd.displayName="RadioBubbleInput";let ff=$.forwardRef(({className:e,...r},s)=>(0,O.jsxs)(h7,{ref:s,className:(0,ey.cn)("relative flex w-full touch-none select-none items-center","data-[disabled]:opacity-50",e),...r,children:[(0,O.jsx)(fn,{className:"relative h-1.5 w-full grow overflow-hidden rounded-full bg-muted",children:(0,O.jsx)(fa,{className:"absolute h-full bg-primary"})}),(0,O.jsx)(fl,{className:(0,ey.cn)("block h-4 w-4 rounded-full border border-primary/60 bg-card shadow-[var(--shadow-sm-app)]","transition-colors hover:border-primary","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40 focus-visible:ring-offset-1 focus-visible:ring-offset-background"),"aria-label":"Value"})]}));function fp({id:e,label:r,description:s,rightSlot:n,children:i}){return(0,O.jsxs)("section",{id:e,className:"scroll-mt-6 rounded-[10px] border border-border bg-card p-5 shadow-[var(--shadow-sm-app)]",children:[(0,O.jsxs)("header",{className:"flex items-end justify-between gap-3 pb-3 mb-4 border-b border-border/70",children:[(0,O.jsxs)("div",{className:"min-w-0",children:[(0,O.jsx)("h2",{className:"text-[10.5px] font-semibold uppercase tracking-[0.08em] text-muted-foreground/80 leading-none",children:r}),s&&(0,O.jsx)("p",{className:"mt-2 text-[12px] text-muted-foreground/90 leading-snug",children:s})]}),n&&(0,O.jsx)("div",{className:"shrink-0",children:n})]}),(0,O.jsx)("div",{className:"space-y-4",children:i})]})}function fm({label:e,hint:r,htmlFor:s,mono:n,children:i}){return(0,O.jsxs)("div",{children:[(0,O.jsx)("label",{htmlFor:s,className:(0,ey.cn)("block text-[12px] font-medium text-foreground/90 mb-1.5",n&&"font-mono tracking-tight"),children:e}),i,r&&(0,O.jsx)("p",{className:"mt-1.5 text-[11px] text-muted-foreground/85 leading-relaxed",children:r})]})}function fg({name:e,value:r,options:s,onChange:n,columns:i=1}){return(0,O.jsx)("div",{className:(0,ey.cn)("grid gap-2",1===i&&"grid-cols-1",2===i&&"grid-cols-1 sm:grid-cols-2",3===i&&"grid-cols-1 sm:grid-cols-3"),role:"radiogroup",children:s.map(s=>{let i=r===s.value,a=s.Icon;return(0,O.jsxs)("label",{className:(0,ey.cn)("group relative flex items-start gap-3 px-3 py-2.5 rounded-[8px] border cursor-pointer","transition-[border-color,background-color,box-shadow] duration-150","focus-within:ring-2 focus-within:ring-ring/40 focus-within:ring-offset-1 focus-within:ring-offset-background",i?"border-primary/40 bg-[color-mix(in_oklch,var(--primary)_8%,var(--card))] shadow-[var(--shadow-sm-app)]":"border-border/70 bg-card hover:border-border hover:bg-muted/40"),children:[(0,O.jsx)("input",{type:"radio",name:e,value:s.value,checked:i,onChange:()=>n(s.value),className:"sr-only"}),(0,O.jsx)("span",{"aria-hidden":!0,className:(0,ey.cn)("mt-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",i?"border-primary bg-primary":"border-border bg-card group-hover:border-foreground/40"),children:i&&(0,O.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-primary-foreground"})}),a&&(0,O.jsx)(a,{className:(0,ey.cn)("h-4 w-4 mt-0.5 shrink-0 transition-colors",i?"text-primary":"text-muted-foreground")}),(0,O.jsxs)("span",{className:"flex-1 min-w-0",children:[(0,O.jsx)("span",{className:(0,ey.cn)("block text-[12.5px] font-medium leading-tight",i?"text-foreground":"text-foreground/90"),children:s.label}),s.description&&(0,O.jsx)("span",{className:"mt-0.5 block text-[11.5px] text-muted-foreground leading-snug",children:s.description})]}),s.meta&&(0,O.jsx)("span",{className:"ml-2 mt-0.5 shrink-0 font-mono text-[10.5px] text-muted-foreground/80",children:s.meta})]},s.value)})})}function fx({variant:e="default",icon:r,children:s}){return(0,O.jsxs)("div",{className:(0,ey.cn)("flex items-center gap-2 rounded-[6px] px-2.5 py-1.5 text-[12px]","default"===e&&"text-muted-foreground bg-muted/40","success"===e&&"text-[color:var(--chart-2)] bg-[color-mix(in_oklch,var(--chart-2)_10%,var(--card))] border border-[color-mix(in_oklch,var(--chart-2)_25%,transparent)]","error"===e&&"text-destructive bg-[color-mix(in_oklch,var(--destructive)_8%,var(--card))] border border-[color-mix(in_oklch,var(--destructive)_25%,transparent)]"),children:[r&&(0,O.jsx)("span",{className:"shrink-0",children:r}),(0,O.jsx)("span",{className:"truncate",children:s})]})}function fv({children:e}){return(0,O.jsx)("div",{className:"flex items-center justify-end gap-2 pt-1",children:e})}function f_({nav:e,children:r}){let[s,n]=(0,$.useState)(e[0]?.id??""),i=(0,$.useRef)(null);return(0,$.useEffect)(()=>{let r=i.current;if(!r)return;let s=()=>{let s=r.getBoundingClientRect(),i=s.top+.25*s.height,a=e[0]?.id??"";for(let s of e){let e=r.querySelector(`#${CSS.escape(s.id)}`);e&&e.getBoundingClientRect().top<=i&&(a=s.id)}n(a)};return s(),r.addEventListener("scroll",s,{passive:!0}),()=>r.removeEventListener("scroll",s)},[e]),(0,O.jsxs)("div",{className:"flex-1 min-h-0 grid grid-cols-[200px_minmax(0,1fr)] overflow-hidden",children:[(0,O.jsx)("aside",{className:"border-r border-border bg-[color:var(--sidebar)] overflow-y-auto",children:(0,O.jsx)("nav",{className:"p-3 flex flex-col gap-0.5",children:e.map(e=>{let r=e.Icon,a=s===e.id;return(0,O.jsxs)("button",{type:"button",onClick:()=>(e=>{let r=i.current;if(!r)return;let s=r.querySelector(`#${CSS.escape(e)}`);if(!s)return;let a=s.offsetTop-12;r.scrollTo({top:a,behavior:"smooth"}),n(e)})(e.id),className:(0,ey.cn)("group relative flex items-center gap-2.5 w-full px-2.5 py-1.5 rounded-[6px] text-[12.5px] text-left","transition-colors duration-100",a?"bg-card text-foreground font-medium shadow-[var(--shadow-sm-app)]":"text-muted-foreground hover:bg-muted/50 hover:text-foreground"),children:[a&&(0,O.jsx)("span",{"aria-hidden":!0,className:"absolute -left-3 top-1.5 bottom-1.5 w-[2px] rounded-full bg-primary"}),r&&(0,O.jsx)(r,{className:(0,ey.cn)("h-3.5 w-3.5 shrink-0",a?"text-foreground":"text-muted-foreground/80")}),(0,O.jsx)("span",{className:"truncate",children:e.label}),e.badge&&(0,O.jsx)("span",{className:"ml-auto font-mono text-[10px] text-muted-foreground/80",children:e.badge})]},e.id)})})}),(0,O.jsx)("div",{ref:i,className:"overflow-y-auto",children:(0,O.jsx)("div",{className:"mx-auto max-w-2xl px-8 py-7 space-y-6",children:r})})]})}ff.displayName="Slider";let fy=[{value:"light",label:"Light",description:"Bright surface, true-white cards",Icon:hV},{value:"dark",label:"Dark",description:"Low-light surfaces with deep neutrals",Icon:hK},{value:"system",label:"System",description:"Match your OS preference",Icon:oc}],{fontSizeMin:fb,fontSizeMax:fw}=rv.CONVERSATION_SETTINGS_LIMITS;function fS(){let{theme:e,setTheme:r}=(0,hY.useTheme)(),{settings:s,setAgentFontSize:n,setChatFontSize:i,setFilesTreeFontSize:a,setFilesContentFontSize:o}=(0,hG.useConversationSettings)();return(0,O.jsxs)("div",{className:"space-y-6",children:[(0,O.jsx)(fm,{label:"Theme",hint:"Sets the surface palette across the app. Switching is instant.",children:(0,O.jsx)(fg,{name:"theme",value:e,options:fy,onChange:r,columns:3})}),(0,O.jsx)(fm,{label:"Conversation font size",hint:"Independent typography for agent and chat views. Affects message body and tool output; chrome elements stay fixed.",children:(0,O.jsxs)("div",{className:"space-y-5",children:[(0,O.jsx)(fj,{label:"Agent conversation",value:s.agentFontSize,onChange:n}),(0,O.jsx)(fj,{label:"Chat session",value:s.chatFontSize,onChange:i})]})}),(0,O.jsx)(fm,{label:"Files font size",hint:"Independent typography for the Files tab. File tree controls the file list and search results; file content controls the preview and code.",children:(0,O.jsxs)("div",{className:"space-y-5",children:[(0,O.jsx)(fj,{label:"File tree, File search",value:s.filesTreeFontSize,onChange:a}),(0,O.jsx)(fj,{label:"File content",value:s.filesContentFontSize,onChange:o})]})}),(0,O.jsx)(fv,{children:(0,O.jsx)(W.Button,{variant:"ghost",size:"sm",onClick:()=>{n(rv.DEFAULT_CONVERSATION_SETTINGS.agentFontSize),i(rv.DEFAULT_CONVERSATION_SETTINGS.chatFontSize),a(rv.DEFAULT_CONVERSATION_SETTINGS.filesTreeFontSize),o(rv.DEFAULT_CONVERSATION_SETTINGS.filesContentFontSize)},children:"Reset"})})]})}function fj({label:e,value:r,onChange:s}){return(0,O.jsxs)("div",{children:[(0,O.jsxs)("div",{className:"flex items-baseline justify-between mb-1.5",children:[(0,O.jsx)("span",{className:"text-[12px] font-medium text-foreground/90",children:e}),(0,O.jsxs)("span",{className:"font-mono text-[11.5px] text-foreground/80 tabular-nums",children:[r," px"]})]}),(0,O.jsx)(ff,{min:fb,max:fw,step:1,value:[r],onValueChange:e=>s(e[0])}),(0,O.jsxs)("div",{className:"flex justify-between mt-1 text-[10.5px] text-muted-foreground/80 font-mono",children:[(0,O.jsx)("span",{children:fb}),(0,O.jsx)("span",{children:fw})]})]})}let fC=(0,ew.default)("waypoints",[["circle",{cx:"12",cy:"4.5",r:"2.5",key:"r5ysbb"}],["path",{d:"m10.2 6.3-3.9 3.9",key:"1nzqf6"}],["circle",{cx:"4.5",cy:"12",r:"2.5",key:"jydg6v"}],["path",{d:"M7 12h10",key:"b7w52i"}],["circle",{cx:"19.5",cy:"12",r:"2.5",key:"1piiel"}],["path",{d:"m13.8 17.7 3.9-3.9",key:"1wyg1y"}],["circle",{cx:"12",cy:"19.5",r:"2.5",key:"13o1pw"}]]),fk={deepseek:hU,openrouter:fC},fN=rv.PROVIDER_IDS.map(e=>({value:e,label:rv.PROVIDERS[e].label,description:"deepseek"===e?"Direct API access — lowest latency":"Aggregator routing — many models available",Icon:fk[e]}));function fE({name:e,value:r,onChange:s}){let n=rv.PROVIDERS[r.provider];return(0,O.jsxs)("div",{className:"space-y-3",children:[(0,O.jsx)(fg,{name:e,value:r.provider,options:fN,onChange:e=>s((0,rv.defaultModelChoice)(e)),columns:2}),n.models?(0,O.jsxs)(hw,{value:r.model,onValueChange:e=>s({...r,model:e}),children:[(0,O.jsx)(hj,{className:"w-full font-mono text-[12.5px]",children:(0,O.jsx)(hS,{})}),(0,O.jsx)(hC,{children:n.models.map(e=>(0,O.jsx)(hk,{value:e,className:"font-mono text-[12.5px]",children:n.modelLabels?.[e]??e},e))})]}):(0,O.jsx)(ro,{className:"font-mono text-[12.5px]",placeholder:n.placeholder,value:r.model,onChange:e=>s({...r,model:e.target.value})})]})}function fD(){let[e,r]=(0,$.useState)(()=>(0,rv.defaultChatProviderConfig)().apiKeys),[s,n]=(0,$.useState)(()=>({deepseek:!1,openrouter:!1})),[i,a]=(0,$.useState)(()=>(0,rv.defaultModelChoice)()),[o,l]=(0,$.useState)(()=>(0,rv.defaultModelChoice)()),[c,d]=(0,$.useState)(!0),[u,h]=(0,$.useState)(!1),[f,p]=(0,$.useState)(null);(0,$.useEffect)(()=>{d(!0),rv.api.getChatProviderSettings().then(e=>{r(e.apiKeys),a(e.main),l(e.fast),n({deepseek:!1,openrouter:!1})}).finally(()=>d(!1))},[]);let m=async()=>{h(!0),p(null);try{let c={};for(let r of rv.PROVIDER_IDS)s[r]&&(c[r]=e[r]);let d={main:i,fast:o};Object.keys(c).length>0&&(d.apiKeys=c);let u=await rv.api.updateChatProviderSettings(d);r(u.apiKeys),a(u.main),l(u.fast),n({deepseek:!1,openrouter:!1}),p("Settings saved"),setTimeout(()=>p(null),2e3)}catch(e){p(e instanceof Error?e.message:"Failed to save")}finally{h(!1)}};return c?(0,O.jsx)("div",{className:"flex items-center justify-center py-6",children:(0,O.jsx)(sj,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):(0,O.jsxs)("div",{className:"space-y-6",children:[(0,O.jsxs)("div",{className:"space-y-4",children:[(0,O.jsx)("p",{className:"text-[12px] font-medium text-foreground/70",children:"API keys"}),rv.PROVIDER_IDS.map(i=>{let a=rv.PROVIDERS[i],o=s[i],l=e[i];return(0,O.jsx)(fm,{label:`${a.label} API key`,mono:!0,hint:(0,O.jsxs)(O.Fragment,{children:["Leave empty to fall back to the"," ",(0,O.jsx)("code",{className:"font-mono text-[10.5px] bg-muted/60 border border-border/60 rounded px-1 py-px",children:a.envKey})," ","environment variable."]}),children:(0,O.jsx)(ro,{type:"password",className:"font-mono text-[12px]",placeholder:l&&!o?l:"sk-...",value:o?l:"",onChange:e=>{var s;return s=e.target.value,void(r(e=>({...e,[i]:s})),n(e=>({...e,[i]:!0})),p(null))}})},i)})]}),(0,O.jsx)(fm,{label:"Main model",hint:"Powers the chat session.",children:(0,O.jsx)(fE,{name:"main-provider",value:i,onChange:e=>{a(e),p(null)}})}),(0,O.jsx)(fm,{label:"Fast model",hint:"Powers translate and agent session titles. Can use a different provider than the main model.",children:(0,O.jsx)(fE,{name:"fast-provider",value:o,onChange:e=>{l(e),p(null)}})}),f&&(0,O.jsx)(fx,{variant:"Settings saved"===f?"success":"error",icon:"Settings saved"===f?(0,O.jsx)(sJ,{className:"h-3.5 w-3.5"}):(0,O.jsx)(s0,{className:"h-3.5 w-3.5"}),children:f}),(0,O.jsx)(fv,{children:(0,O.jsxs)(W.Button,{size:"sm",onClick:m,disabled:u,children:[u&&(0,O.jsx)(sj,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Save"]})})]})}let fR=[{value:"none",label:"Direct",description:"No proxy — connect directly to the internet",Icon:(0,ew.default)("shield-off",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71",key:"1jlk70"}],["path",{d:"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",key:"18rp1v"}]])},{value:"http",label:"HTTP / HTTPS",description:"Route through an HTTP CONNECT proxy",Icon:hW},{value:"socks5",label:"SOCKS5",description:"Route through a SOCKS5 proxy server",Icon:fC}];function fA(){let[e,r]=(0,$.useState)("none"),[s,n]=(0,$.useState)(""),[i,a]=(0,$.useState)(""),[o,l]=(0,$.useState)(!0),[c,d]=(0,$.useState)(!1),[u,h]=(0,$.useState)(!1),[f,p]=(0,$.useState)(null),[m,g]=(0,$.useState)(null);(0,$.useEffect)(()=>{l(!0),p(null),g(null),rv.api.getProxySettings().then(e=>{r(e.type),n(e.host),a(e.port?String(e.port):"")}).finally(()=>l(!1))},[]);let x=()=>({type:e,host:"none"===e?"":s.trim(),port:"none"===e?0:parseInt(i,10)||0}),v=async()=>{h(!0),p(null);try{p(await rv.api.testProxyConnection(x()))}catch(e){p({success:!1,message:e instanceof Error?e.message:"Test failed"})}finally{h(!1)}},_=async()=>{d(!0),g(null);try{await rv.api.updateProxySettings(x()),g("Settings saved"),setTimeout(()=>g(null),2e3)}catch(e){g(e instanceof Error?e.message:"Failed to save")}finally{d(!1)}},y="none"!==e;return o?(0,O.jsx)("div",{className:"flex items-center justify-center py-6",children:(0,O.jsx)(sj,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):(0,O.jsxs)("div",{className:"space-y-4",children:[(0,O.jsx)(fm,{label:"Connection mode",children:(0,O.jsx)(fg,{name:"proxyType",value:e,options:fR,onChange:e=>{r(e),p(null),g(null)}})}),y&&(0,O.jsxs)("div",{className:"grid grid-cols-[1fr_120px] gap-3",children:[(0,O.jsx)(fm,{label:"Host",mono:!0,children:(0,O.jsx)(ro,{placeholder:"127.0.0.1",value:s,className:"font-mono text-[12.5px]",onChange:e=>{n(e.target.value),p(null),g(null)}})}),(0,O.jsx)(fm,{label:"Port",mono:!0,children:(0,O.jsx)(ro,{type:"number",placeholder:"1080",value:i,className:"font-mono text-[12.5px]",onChange:e=>{a(e.target.value),p(null),g(null)},min:1,max:65535})})]}),f&&(0,O.jsx)(fx,{variant:f.success?"success":"error",icon:f.success?(0,O.jsx)(sJ,{className:"h-3.5 w-3.5"}):(0,O.jsx)(s0,{className:"h-3.5 w-3.5"}),children:f.message??(f.success?"Connection succeeded":"Connection failed")}),m&&!f&&(0,O.jsx)(fx,{variant:"Settings saved"===m?"success":"error",icon:"Settings saved"===m?(0,O.jsx)(sJ,{className:"h-3.5 w-3.5"}):(0,O.jsx)(s0,{className:"h-3.5 w-3.5"}),children:m}),(0,O.jsxs)(fv,{children:[y&&(0,O.jsxs)(W.Button,{variant:"outline",size:"sm",onClick:v,disabled:u||!s.trim()||!i,children:[u&&(0,O.jsx)(sj,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Test connection"]}),(0,O.jsxs)(W.Button,{size:"sm",onClick:_,disabled:c,children:[c&&(0,O.jsx)(sj,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Save"]})]})]})}var fT=e.i(276949);let{scrollbackMin:fM,scrollbackMax:fF,fontSizeMin:fP,fontSizeMax:fI}=rv.TERMINAL_SETTINGS_LIMITS;function fB(){let{settings:e,loaded:r,refresh:s}=(0,fT.useTerminalSettings)(),[n,i]=(0,$.useState)(String(rv.DEFAULT_TERMINAL_SETTINGS.scrollback)),[a,o]=(0,$.useState)(String(rv.DEFAULT_TERMINAL_SETTINGS.fontSize)),[l,c]=(0,$.useState)(rv.DEFAULT_TERMINAL_SETTINGS.fontFamily),[d,u]=(0,$.useState)(!1),[h,f]=(0,$.useState)(null);(0,$.useEffect)(()=>{r&&(i(String(e.scrollback)),o(String(e.fontSize)),c(e.fontFamily))},[r,e.scrollback,e.fontSize,e.fontFamily]);let p=parseInt(n,10),m=parseInt(a,10),g=Number.isFinite(p)&&p>=fM&&p<=fF,x=Number.isFinite(m)&&m>=fP&&m<=fI,v=""!==l.trim(),_=g&&x&&v,y=async()=>{if(_){u(!0),f(null);try{let e={scrollback:p,fontSize:m,fontFamily:l.trim()};await rv.api.updateTerminalSettings(e),await s(),f("Settings saved"),setTimeout(()=>f(null),2e3)}catch(e){f(e instanceof Error?e.message:"Failed to save")}finally{u(!1)}}};return r?(0,O.jsxs)("div",{className:"space-y-4",children:[(0,O.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,O.jsx)(fm,{label:"Scrollback",mono:!0,hint:(0,O.jsxs)("span",{children:["Lines kept in buffer."," ",(0,O.jsxs)("span",{className:"font-mono text-foreground/70",children:[fM,"–",fF]})," · default ",(0,O.jsx)("span",{className:"font-mono text-foreground/70",children:rv.DEFAULT_TERMINAL_SETTINGS.scrollback})]}),children:(0,O.jsx)(ro,{type:"number",min:fM,max:fF,value:n,className:"font-mono text-[12.5px]",onChange:e=>{i(e.target.value),f(null)}})}),(0,O.jsx)(fm,{label:"Font size",mono:!0,hint:(0,O.jsxs)("span",{children:["Pixels."," ",(0,O.jsxs)("span",{className:"font-mono text-foreground/70",children:[fP,"–",fI]})," · default ",(0,O.jsx)("span",{className:"font-mono text-foreground/70",children:rv.DEFAULT_TERMINAL_SETTINGS.fontSize})]}),children:(0,O.jsx)(ro,{type:"number",min:fP,max:fI,value:a,className:"font-mono text-[12.5px]",onChange:e=>{o(e.target.value),f(null)}})})]}),(0,O.jsx)(fm,{label:"Font family",mono:!0,hint:"CSS font-family list. Use monospace fonts for column alignment.",children:(0,O.jsx)(ro,{value:l,className:"font-mono text-[12px]",onChange:e=>{c(e.target.value),f(null)},placeholder:rv.DEFAULT_TERMINAL_SETTINGS.fontFamily})}),h&&(0,O.jsx)(fx,{variant:"Settings saved"===h?"success":"error",icon:"Settings saved"===h?(0,O.jsx)(sJ,{className:"h-3.5 w-3.5"}):(0,O.jsx)(s0,{className:"h-3.5 w-3.5"}),children:h}),(0,O.jsxs)(fv,{children:[(0,O.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>{i(String(rv.DEFAULT_TERMINAL_SETTINGS.scrollback)),o(String(rv.DEFAULT_TERMINAL_SETTINGS.fontSize)),c(rv.DEFAULT_TERMINAL_SETTINGS.fontFamily),f(null)},disabled:d,children:"Reset"}),(0,O.jsxs)(W.Button,{size:"sm",onClick:y,disabled:d||!_,children:[d&&(0,O.jsx)(sj,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Save"]})]})]}):(0,O.jsx)("div",{className:"flex items-center justify-center py-6",children:(0,O.jsx)(sj,{className:"h-4 w-4 animate-spin text-muted-foreground"})})}let{min:fL,max:fz}=rv.AGENT_PROCESS_SETTINGS_LIMITS;function fO(){let[e,r]=(0,$.useState)(String(rv.DEFAULT_AGENT_PROCESS_SETTINGS.maxResidentAgentProcesses)),[s,n]=(0,$.useState)(!1),[i,a]=(0,$.useState)(!1),[o,l]=(0,$.useState)(null);(0,$.useEffect)(()=>{let e=!1;return(0,rv.getAgentProcessSettings)().then(s=>{e||(r(String(s.maxResidentAgentProcesses)),n(!0))}).catch(r=>{e||(l(r instanceof Error?r.message:"Failed to load settings"),n(!0))}),()=>{e=!0}},[]);let c=parseInt(e,10),d=Number.isInteger(c)&&c>=fL&&c<=fz,u=async()=>{if(d){a(!0),l(null);try{let e=await (0,rv.updateAgentProcessSettings)({maxResidentAgentProcesses:c});r(String(e.maxResidentAgentProcesses)),l("Settings saved"),setTimeout(()=>l(null),2e3)}catch(e){l(e instanceof Error?e.message:"Failed to save")}finally{a(!1)}}};return s?(0,O.jsxs)("div",{className:"space-y-4",children:[(0,O.jsx)(fm,{label:"Resident agent processes",mono:!0,hint:(0,O.jsxs)("span",{children:["Live local or remote agent processes per server."," ",(0,O.jsxs)("span",{className:"font-mono text-foreground/70",children:[fL,"–",fz]})," · default ",(0,O.jsx)("span",{className:"font-mono text-foreground/70",children:rv.DEFAULT_AGENT_PROCESS_SETTINGS.maxResidentAgentProcesses})]}),children:(0,O.jsxs)("div",{className:"flex items-center gap-2 max-w-[220px]",children:[(0,O.jsx)(sb,{className:"h-4 w-4 text-muted-foreground"}),(0,O.jsx)(ro,{type:"number",min:fL,max:fz,value:e,className:"font-mono text-[12.5px]",onChange:e=>{r(e.target.value),l(null)}})]})}),o&&(0,O.jsx)(fx,{variant:"Settings saved"===o?"success":"error",icon:"Settings saved"===o?(0,O.jsx)(sJ,{className:"h-3.5 w-3.5"}):(0,O.jsx)(s0,{className:"h-3.5 w-3.5"}),children:o}),(0,O.jsxs)(fv,{children:[(0,O.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>{r(String(rv.DEFAULT_AGENT_PROCESS_SETTINGS.maxResidentAgentProcesses)),l(null)},disabled:i,children:"Reset"}),(0,O.jsxs)(W.Button,{size:"sm",onClick:u,disabled:i||!d,children:[i&&(0,O.jsx)(sj,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Save"]})]})]}):(0,O.jsx)("div",{className:"flex items-center justify-center py-6",children:(0,O.jsx)(sj,{className:"h-4 w-4 animate-spin text-muted-foreground"})})}let f$=[{id:"appearance",label:"Appearance",Icon:hH},{id:"ai-chat",label:"AI Chat",Icon:hU},{id:"agents",label:"Agents",Icon:sb},{id:"terminal",label:"Terminal",Icon:hq},{id:"proxy",label:"Proxy",Icon:hW}];function fW(){let{config:e}=(0,hL.useAppConfig)(),[r]=(0,$.useState)(rv.getPersistedConfig),s=(e??r)?.authEnabled!==!1,n=s?f$.filter(e=>"proxy"!==e.id):f$;return(0,O.jsxs)("div",{className:"h-full flex flex-col overflow-hidden",children:[(0,O.jsx)(dh,{title:"Settings",description:"Theme, intelligence, terminal, and network preferences."}),(0,O.jsxs)(f_,{nav:n,children:[(0,O.jsx)(fp,{id:"appearance",label:"Appearance",description:"Visual surface for the workspace. Affects every view.",children:(0,O.jsx)(fS,{})}),(0,O.jsx)(fp,{id:"ai-chat",label:"AI Chat",description:"Provider, credentials, and default model used for the orchestrator chat.",children:(0,O.jsx)(fD,{})}),(0,O.jsx)(fp,{id:"agents",label:"Agents",description:"Resident coding-agent process limits per workspace branch.",children:(0,O.jsx)(fO,{})}),(0,O.jsx)(fp,{id:"terminal",label:"Terminal",description:"Buffer size and typography for the executor terminal.",children:(0,O.jsx)(fB,{})}),!s&&(0,O.jsx)(fp,{id:"proxy",label:"Proxy",description:"Outbound network routing for AI providers and remote servers.",children:(0,O.jsx)(fA,{})})]})]})}let fH=(0,ew.default)("plug-zap",[["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m18 3-4 4h6l-4 4",key:"16psg9"}]]),fU=(0,ew.default)("key-round",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);var fq=e.i(710307);let fK=(0,ew.default)("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]),fV={name:""};function fY(){let[e,r]=(0,$.useState)([]),[s,n]=(0,$.useState)(!0),[i,a]=(0,$.useState)(""),[o,l]=(0,$.useState)(!1),[c,d]=(0,$.useState)(null),[u,h]=(0,$.useState)(fV),[f,p]=(0,$.useState)(""),[m,g]=(0,$.useState)(!1),[x,v]=(0,$.useState)(null),[_,y]=(0,$.useState)(!1),[b,w]=(0,$.useState)({}),[S,j]=(0,$.useState)({}),[C,k]=(0,$.useState)(null),[N,E]=(0,$.useState)(null),[D,R]=(0,$.useState)(null),[A,T]=(0,$.useState)(!1),[M,F]=(0,$.useState)(!1),[P,I]=(0,$.useState)(!1),[B,L]=(0,$.useState)(!1),z=(0,$.useRef)(null),H=(0,$.useCallback)(async()=>{try{let e=await rv.api.getRemoteServers();r(e),a("")}catch(e){a(e instanceof Error?e.message:"Failed to load servers")}finally{n(!1)}},[]);(0,$.useEffect)(()=>{H()},[H]),(0,$.useEffect)(()=>{let e=setInterval(H,15e3),r=()=>H();return window.addEventListener("focus",r),()=>{clearInterval(e),window.removeEventListener("focus",r)}},[H]);let U=async()=>{if(!u.name.trim())return void p("Name is required");g(!0),p("");try{c?u.name.trim()!==c.name&&await rv.api.updateRemoteServer(c.id,{name:u.name.trim()}):await rv.api.createRemoteServer({name:u.name.trim()}),l(!1),await H()}catch(e){p(e instanceof Error?e.message:"Failed to save server")}finally{g(!1)}},q=async()=>{if(x){y(!0);try{await rv.api.deleteRemoteServer(x.id),v(null),await H()}catch(e){p(e instanceof Error?e.message:"Failed to delete server")}finally{y(!1)}}},K=async e=>{w(r=>({...r,[e.id]:"testing"})),j(r=>{let s={...r};return delete s[e.id],s});try{let r=await rv.api.testRemoteServer(e.id);w(s=>({...s,[e.id]:r.success?"success":"error"})),r.success||j(r=>({...r,[e.id]:"Connection failed"}))}catch(r){w(r=>({...r,[e.id]:"error"})),j(s=>({...s,[e.id]:r instanceof Error?r.message:"Test failed"}))}},V=async e=>{z.current=e.id,k(e),E(null),R(null),F(!1),L(!1),I(!1),T(!0);try{let r=await rv.api.getRemoteServerConnectToken(e.id);if(z.current!==e.id)return;E(r.token),R(r.connectCommand)}catch(r){if(z.current!==e.id)return;z.current=null,p(r instanceof Error?r.message:"Failed to load token"),k(null)}finally{z.current===e.id&&T(!1)}},Y=async e=>{I(!0),F(!1);try{let r=await rv.api.rotateRemoteServerConnectToken(e.id);z.current===e.id&&(E(r.token),R(r.connectCommand),L(!1)),await H()}catch(e){a(e instanceof Error?e.message:"Failed to rotate token")}finally{z.current===e.id&&I(!1)}},G=async e=>{try{await rv.api.revokeRemoteServerConnectToken(e.id),await H()}catch(e){a(e instanceof Error?e.message:"Failed to revoke token")}},X=async(e,s)=>{try{let n=await rv.api.updateRemoteServer(e.id,{crossRemoteAccess:s});r(e=>e.map(e=>e.id===n.id?n:e))}catch(e){a(e instanceof Error?e.message:"Failed to update access")}};return s?(0,O.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,O.jsx)(sj,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):(0,O.jsxs)("div",{className:"space-y-4",children:[(0,O.jsxs)("div",{className:"flex items-center justify-between",children:[(0,O.jsxs)("div",{children:[(0,O.jsx)("h3",{className:"text-sm font-medium",children:"Remote Servers"}),(0,O.jsx)("p",{className:"text-xs text-muted-foreground",children:"Manage globally available remote servers"})]}),(0,O.jsxs)(W.Button,{variant:"outline",size:"sm",onClick:()=>{d(null),h(fV),p(""),l(!0)},children:[(0,O.jsx)(eS,{className:"h-4 w-4 mr-1.5"}),"Add Server"]})]}),i&&(0,O.jsx)("p",{className:"text-sm text-red-500",children:i}),0===e.length?(0,O.jsxs)("div",{className:"text-center py-8 text-sm text-muted-foreground border rounded-md",children:[(0,O.jsx)(ry,{className:"h-8 w-8 mx-auto mb-2 opacity-40"}),"No remote servers configured"]}):(0,O.jsxs)(uk,{children:[(0,O.jsx)(uN,{children:(0,O.jsxs)(uD,{children:[(0,O.jsx)(uR,{children:"Name"}),(0,O.jsx)(uR,{children:"Status"}),(0,O.jsx)(uR,{children:"Cross-remote access"}),(0,O.jsx)(uR,{className:"w-[180px] text-right",children:"Actions"})]})}),(0,O.jsx)(uE,{children:e.map(e=>{let r,s;return(0,O.jsxs)(uD,{children:[(0,O.jsx)(uA,{className:"font-medium",children:(0,O.jsxs)("div",{className:"flex items-center",children:[(r="online"===e.status,(0,O.jsx)("span",{className:`inline-block h-2.5 w-2.5 rounded-full mr-2 ${r?"bg-green-500":"bg-gray-400"}`,title:r?"Online":"Offline"})),e.name]})}),(0,O.jsx)(uA,{className:"font-mono text-xs text-muted-foreground",children:"online"===e.status?"Connected":"Waiting for connection..."}),(0,O.jsx)(uA,{children:(0,O.jsxs)(hw,{value:e.cross_remote_access,onValueChange:r=>X(e,r),children:[(0,O.jsx)(hj,{className:"w-[190px] text-[12.5px]",children:(0,O.jsx)(hS,{})}),(0,O.jsxs)(hC,{children:[(0,O.jsx)(hk,{value:"off",className:"text-[12.5px]",children:"Off"}),(0,O.jsx)(hk,{value:"read",className:"text-[12.5px]",children:"Diagnostic read"}),(0,O.jsx)(hk,{value:"exec",className:"text-[12.5px]",children:"Command execution"})]})]})}),(0,O.jsxs)(uA,{className:"text-right",children:[(0,O.jsxs)("div",{className:"flex items-center justify-end gap-1",children:[(0,O.jsx)(W.Button,{variant:"ghost",size:"icon",onClick:()=>V(e),title:"Connect token",className:"h-8 w-8",children:(0,O.jsx)(fU,{className:"h-4 w-4"})}),(s=b[e.id]||"idle",(0,O.jsx)(W.Button,{variant:"ghost",size:"icon",onClick:()=>K(e),disabled:"testing"===s,title:"Test connection",className:"h-8 w-8",children:"testing"===s?(0,O.jsx)(sj,{className:"h-4 w-4 animate-spin"}):"success"===s?(0,O.jsx)(rf.Check,{className:"h-4 w-4 text-green-500"}):"error"===s?(0,O.jsx)(t7,{className:"h-4 w-4 text-red-500"}):(0,O.jsx)(fH,{className:"h-4 w-4"})})),(0,O.jsx)(W.Button,{variant:"ghost",size:"icon",onClick:()=>{d(e),h({name:e.name}),p(""),l(!0)},title:"Edit server",className:"h-8 w-8",children:(0,O.jsx)(rg,{className:"h-4 w-4"})}),(0,O.jsx)(W.Button,{variant:"ghost",size:"icon",onClick:()=>v(e),title:"Delete server",className:"h-8 w-8 text-destructive hover:text-destructive",children:(0,O.jsx)(rc,{className:"h-4 w-4"})})]}),S[e.id]&&(0,O.jsx)("p",{className:"text-xs text-red-500 mt-1 text-right",children:S[e.id]})]})]},e.id)})})]}),(0,O.jsxs)("p",{className:"text-xs text-muted-foreground",children:["When enabled, agents running on your other machines can reach this one.",(0,O.jsx)("strong",{children:" Diagnostic read"})," exposes files, directories and the process list — including any secrets in logs and config files.",(0,O.jsx)("strong",{children:" Command execution"})," additionally allows arbitrary shell commands. Off by default."]}),(0,O.jsx)(t8,{open:o,onOpenChange:l,children:(0,O.jsxs)(rr,{className:"sm:max-w-md",children:[(0,O.jsxs)(rs,{children:[(0,O.jsx)(ri,{children:c?"Edit Server":"Add Remote Server"}),(0,O.jsx)(ra,{children:c?"Update the server name.":"Add a new remote server, then generate a connect token and run the connect command on the remote machine."})]}),(0,O.jsxs)("div",{className:"space-y-4",children:[(0,O.jsxs)("div",{className:"space-y-2",children:[(0,O.jsx)("label",{className:"text-sm font-medium",children:"Name"}),(0,O.jsx)(ro,{value:u.name,onChange:e=>{h(r=>({...r,name:e.target.value})),p("")},placeholder:"My Remote Server"})]}),f&&(0,O.jsx)("p",{className:"text-sm text-red-500",children:f})]}),(0,O.jsxs)(rn,{children:[(0,O.jsx)(W.Button,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),(0,O.jsxs)(W.Button,{onClick:U,disabled:m,children:[m&&(0,O.jsx)(sj,{className:"h-4 w-4 mr-1.5 animate-spin"}),c?"Save Changes":"Add Server"]})]})]})}),(0,O.jsx)(t8,{open:null!==C,onOpenChange:e=>{e||(z.current=null,k(null),E(null),R(null),L(!1))},children:(0,O.jsxs)(rr,{className:"sm:max-w-lg",children:[(0,O.jsxs)(rs,{children:[(0,O.jsx)(ri,{children:"Connect Token"}),(0,O.jsxs)(ra,{children:["Use this token to connect a remote node to"," ",(0,O.jsx)("span",{className:"font-semibold",children:C?.name}),". It stays the same every time you open this dialog — rotate it to issue a replacement."]})]}),A?(0,O.jsx)("div",{className:"flex items-center justify-center py-4",children:(0,O.jsx)(sj,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):N?(0,O.jsx)("div",{className:"space-y-4",children:(0,O.jsxs)("div",{className:"space-y-2",children:[(0,O.jsx)("label",{className:"text-sm font-medium",children:"Connect Command"}),(0,O.jsxs)("div",{className:"flex gap-2",children:[(0,O.jsx)(ro,{readOnly:!0,value:D||"",className:"font-mono text-xs"}),(0,O.jsx)(W.Button,{variant:"outline",size:"icon",className:"shrink-0",onClick:()=>{var e;return e=D||"",void(navigator.clipboard.writeText(e),F(!0),setTimeout(()=>F(!1),2e3))},title:"Copy command",children:M?(0,O.jsx)(rf.Check,{className:"h-4 w-4 text-green-500"}):(0,O.jsx)(fq.Copy,{className:"h-4 w-4"})})]}),(0,O.jsx)("p",{className:"text-xs text-muted-foreground",children:"Run this command on the remote machine to establish the reverse connection."}),B&&(0,O.jsx)("p",{className:"text-xs text-destructive",children:"Rotating invalidates the current token immediately. Any worker still using it will fail to reconnect until you re-run the new command."})]})}):null,(0,O.jsxs)(rn,{children:[N&&C&&(0,O.jsxs)("div",{className:"mr-auto flex items-center gap-2",children:[(0,O.jsxs)(W.Button,{variant:"outline",disabled:P,onClick:()=>{B?Y(C):L(!0)},children:[P?(0,O.jsx)(sj,{className:"mr-2 h-4 w-4 animate-spin"}):(0,O.jsx)(fK,{className:"mr-2 h-4 w-4"}),B?"Confirm rotate":"Rotate Token"]}),(0,O.jsx)(W.Button,{variant:"outline",className:"text-destructive hover:text-destructive",onClick:()=>{G(C),z.current=null,k(null),E(null)},children:"Revoke Token"})]}),(0,O.jsx)(W.Button,{variant:"outline",onClick:()=>{z.current=null,k(null),E(null),R(null),L(!1)},children:"Close"})]})]})}),(0,O.jsx)(t8,{open:null!==x,onOpenChange:e=>{e||v(null)},children:(0,O.jsxs)(rr,{className:"sm:max-w-sm",children:[(0,O.jsxs)(rs,{children:[(0,O.jsx)(ri,{children:"Delete Server"}),(0,O.jsxs)(ra,{children:["Are you sure you want to delete"," ",(0,O.jsx)("span",{className:"font-semibold",children:x?.name}),"? This will also remove it from any projects that reference it."]})]}),(0,O.jsxs)(rn,{children:[(0,O.jsx)(W.Button,{variant:"outline",onClick:()=>v(null),children:"Cancel"}),(0,O.jsxs)(W.Button,{variant:"destructive",onClick:q,disabled:_,children:[_&&(0,O.jsx)(sj,{className:"h-4 w-4 mr-1.5 animate-spin"}),"Delete"]})]})]})})]})}function fG({projectId:e,project:r,open:s,onOpenChange:n,onWorktreeCreated:i}){let[a,o]=(0,$.useState)(""),[l,c]=(0,$.useState)(!1),[d,u]=(0,$.useState)(null),[h,f]=(0,$.useState)(null),[p,m]=(0,$.useState)(!0),[g,x]=(0,$.useState)(!0),[v,_]=(0,$.useState)([]),[y,b]=(0,$.useState)([]),[w,S]=(0,$.useState)("main"),[j,C]=(0,$.useState)("main"),[k,N]=(0,$.useState)(!1),E=!!(r.path&&r.remote_path);(0,$.useEffect)(()=>{s&&(N(!0),E?Promise.all([rv.api.getProjectBranches(e,"local"),rv.api.getProjectBranches(e,"remote")]).then(([e,r])=>{_(e),b(r),S(e.includes("main")?"main":e[0]||"main"),C(r.includes("main")?"main":r[0]||"main"),N(!1)}):rv.api.getProjectBranches(e).then(e=>{_(e),S(e.includes("main")?"main":e[0]||"main"),N(!1)}))},[s,e,E]);let D=async()=>{if(a.trim()){c(!0),u(null),f(null);try{let r;E&&(r=[],p&&r.push("local"),g&&r.push("remote"));let s=await rv.api.createWorktree(e,a.trim(),r,w,E?j:void 0);if(s.partialSuccess){let e,r=s.results?.remote?.success===!1?"remote":"local",n=s.results?.[r],i=n?.error||"Unknown error",a=n?.errorCode,o=n?.requestId;switch(a){case"timeout":e="Connection to remote server timed out. The remote server may be slow or unreachable.";break;case"network_error":e="Remote server is not connected. Run the connect command on the remote machine (Settings → Remote Servers → connect token).";break;case"auth_error":e="Authentication failed with remote server. Copy the current connect command (Settings → Remote Servers → connect token) and re-run it on the remote machine; rotate the token only if you need to replace it.";break;case"server_error":e=`Remote server returned an error: ${i}`;break;default:e=`Worktree created locally, but ${r} creation failed: ${i}`}o&&(e+=` (Request ID: ${o})`),f(e)}i(s.worktree.branch),s.partialSuccess||(n(!1),o(""))}catch(e){u(e instanceof Error?e.message:"Failed to create worktree")}finally{c(!1)}}},R=e=>{e||(o(""),u(null),f(null),m(!0),x(!0),_([]),b([]),S("main"),C("main")),n(e)},A=(e,r,s,n)=>(0,O.jsxs)(hw,{value:r,onValueChange:s,disabled:n||k,children:[(0,O.jsx)(hj,{size:"sm",children:(0,O.jsx)(hS,{placeholder:k?"Loading...":"Select branch"})}),(0,O.jsx)(hC,{children:e.map(e=>(0,O.jsx)(hk,{value:e,children:e},e))})]});return(0,O.jsx)(t8,{open:s,onOpenChange:R,children:(0,O.jsxs)(rr,{children:[(0,O.jsxs)(rs,{children:[(0,O.jsx)(ri,{children:"Create New Worktree"}),(0,O.jsx)(ra,{children:"Create a new branch based on an existing branch"})]}),(0,O.jsxs)("div",{className:"space-y-4",children:[(0,O.jsxs)("div",{className:"space-y-2",children:[(0,O.jsx)("label",{htmlFor:"branch-name",className:"text-sm font-medium",children:"Branch Name"}),(0,O.jsx)(ro,{id:"branch-name",placeholder:"feature/my-feature",value:a,onChange:e=>o(e.target.value),disabled:l,onKeyDown:e=>{"Enter"===e.key&&a.trim()&&(!E||p||g)&&D()}})]}),E?(0,O.jsxs)("div",{className:"space-y-2",children:[(0,O.jsx)("label",{className:"text-sm font-medium",children:"Create On"}),(0,O.jsxs)("div",{className:"space-y-2",children:[(0,O.jsxs)("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[(0,O.jsx)("input",{type:"checkbox",checked:p,onChange:e=>{(e.target.checked||g)&&m(e.target.checked)},disabled:l,className:"h-4 w-4 rounded border-input accent-primary"}),(0,O.jsx)("span",{children:"Local"}),(0,O.jsx)("span",{className:"text-muted-foreground truncate text-xs",children:r.path})]}),p&&v.length>0&&(0,O.jsxs)("div",{className:"ml-6",children:[(0,O.jsx)("label",{className:"text-xs text-muted-foreground",children:"Base Branch"}),A(v,w,S,l)]}),(0,O.jsxs)("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[(0,O.jsx)("input",{type:"checkbox",checked:g,onChange:e=>{(e.target.checked||p)&&x(e.target.checked)},disabled:l,className:"h-4 w-4 rounded border-input accent-primary"}),(0,O.jsx)("span",{children:"Remote"}),(0,O.jsx)("span",{className:"text-muted-foreground truncate text-xs",children:r.remote_path})]}),g&&y.length>0&&(0,O.jsxs)("div",{className:"ml-6",children:[(0,O.jsx)("label",{className:"text-xs text-muted-foreground",children:"Base Branch"}),A(y,j,C,l)]})]})]}):v.length>0&&(0,O.jsxs)("div",{className:"space-y-2",children:[(0,O.jsx)("label",{className:"text-sm font-medium",children:"Base Branch"}),A(v,w,S,l)]}),h&&(0,O.jsx)("div",{className:"text-sm text-yellow-600 dark:text-yellow-500 bg-yellow-500/10 px-3 py-2 rounded-md",children:h}),d&&(0,O.jsx)("div",{className:"text-sm text-destructive bg-destructive/10 px-3 py-2 rounded-md",children:d})]}),(0,O.jsxs)(rn,{children:[(0,O.jsx)(W.Button,{variant:"outline",onClick:()=>R(!1),disabled:l,children:"Cancel"}),(0,O.jsx)(W.Button,{onClick:D,disabled:!a.trim()||l||E&&!p&&!g,children:l?"Creating...":"Create"})]})]})})}function fX({projectId:e,worktree:r,open:s,onOpenChange:n,onWorktreeDeleted:i}){let[a,o]=(0,$.useState)(!1),[l,c]=(0,$.useState)(null),[d,u]=(0,$.useState)(null),h=async()=>{if(r){o(!0),c(null),u(null);try{let s=await rv.api.deleteWorktree(e,r.branch);if(s.partialSuccess){let e=s.results?.remote?.error||"Unknown error";u(`Local worktree deleted, but remote deletion failed: ${e}`)}i(),s.partialSuccess||n(!1)}catch(e){c(e instanceof Error?e.message:"Failed to delete worktree")}finally{o(!1)}}},f=e=>{e||(c(null),u(null)),n(e)};return(0,O.jsx)(t8,{open:s,onOpenChange:f,children:(0,O.jsxs)(rr,{children:[(0,O.jsxs)(rs,{children:[(0,O.jsx)(ri,{children:"Delete Worktree"}),(0,O.jsx)(ra,{children:"Are you sure you want to delete this worktree?"})]}),r&&(0,O.jsx)("div",{className:"space-y-2",children:(0,O.jsxs)("div",{className:"text-sm",children:[(0,O.jsx)("span",{className:"font-medium",children:"Branch:"})," ",(0,O.jsx)("span",{className:"text-muted-foreground",children:r.branch})]})}),d&&(0,O.jsx)("div",{className:"text-sm text-yellow-600 dark:text-yellow-500 bg-yellow-500/10 px-3 py-2 rounded-md",children:d}),l&&(0,O.jsx)("div",{className:"text-sm text-destructive bg-destructive/10 px-3 py-2 rounded-md",children:l}),(0,O.jsxs)(rn,{children:[(0,O.jsx)(W.Button,{variant:"outline",onClick:()=>f(!1),disabled:a,children:"Cancel"}),(0,O.jsx)(W.Button,{variant:"destructive",onClick:h,disabled:a,children:a?"Deleting...":"Delete"})]})]})})}e.i(247755);var fJ=e.i(642098);function fZ(){let{config:e}=(0,hL.useAppConfig)();return e?.authEnabled?(0,O.jsx)("div",{className:"flex items-center",children:(0,O.jsx)(fJ.UserButton,{appearance:{elements:{avatarBox:"h-7 w-7 ring-1 ring-border/60"}}})}):null}var fQ=e.i(183663),f0="Collapsible",[f1,f2]=q(f0),[f5,f3]=f1(f0),f4=$.forwardRef((e,r)=>{let{__scopeCollapsible:s,open:n,defaultOpen:i,disabled:a,onOpenChange:o,...l}=e,[c,d]=G({prop:n,defaultProp:i??!1,onChange:o,caller:f0});return(0,O.jsx)(f5,{scope:s,disabled:a,contentId:ek(),open:c,onOpenToggle:$.useCallback(()=>d(e=>!e),[d]),children:(0,O.jsx)(er.div,{"data-state":pt(c),"data-disabled":a?"":void 0,...l,ref:r})})});f4.displayName=f0;var f6="CollapsibleTrigger",f7=$.forwardRef((e,r)=>{let{__scopeCollapsible:s,...n}=e,i=f3(f6,s);return(0,O.jsx)(er.button,{type:"button","aria-controls":i.contentId,"aria-expanded":i.open||!1,"data-state":pt(i.open),"data-disabled":i.disabled?"":void 0,disabled:i.disabled,...n,ref:r,onClick:K(e.onClick,i.onOpenToggle)})});f7.displayName=f6;var f8="CollapsibleContent",f9=$.forwardRef((e,r)=>{let{forceMount:s,...n}=e,i=f3(f8,e.__scopeCollapsible);return(0,O.jsx)(Z,{present:s||i.open,children:({present:e})=>(0,O.jsx)(pe,{...n,ref:r,present:e})})});f9.displayName=f8;var pe=$.forwardRef((e,r)=>{let{__scopeCollapsible:s,present:n,children:i,...a}=e,o=f3(f8,s),[l,c]=$.useState(n),d=$.useRef(null),u=(0,U.useComposedRefs)(r,d),h=$.useRef(0),f=h.current,p=$.useRef(0),m=p.current,g=o.open||l,x=$.useRef(g),v=$.useRef(void 0);return $.useEffect(()=>{let e=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(e)},[]),V(()=>{let e=d.current;if(e){v.current=v.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration="0s",e.style.animationName="none";let r=e.getBoundingClientRect();h.current=r.height,p.current=r.width,x.current||(e.style.transitionDuration=v.current.transitionDuration,e.style.animationName=v.current.animationName),c(n)}},[o.open,n]),(0,O.jsx)(er.div,{"data-state":pt(o.open),"data-disabled":o.disabled?"":void 0,id:o.contentId,hidden:!g,...a,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:g&&i})});function pt(e){return e?"open":"closed"}function pr({...e}){return(0,O.jsx)(f4,{"data-slot":"collapsible",...e})}function ps({...e}){return(0,O.jsx)(f7,{"data-slot":"collapsible-trigger",...e})}function pn({...e}){return(0,O.jsx)(f9,{"data-slot":"collapsible-content",...e})}let pi=(0,ew.default)("ellipsis-vertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]),pa=(0,ew.default)("ban",[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);var po=e.i(885101),pl=Object.defineProperty,pc=Object.getOwnPropertyDescriptor,pd=(e,r,s,n)=>{for(var i,a=n>1?void 0:n?pc(r,s):r,o=e.length-1;o>=0;o--)(i=e[o])&&(a=(n?i(r,s,a):i(a))||a);return n&&a&&pl(r,s,a),a},pu=(e,r)=>(s,n)=>r(s,n,e),ph="Terminal input",pf="Too much output to announce, navigate to rows manually to read";function pp(e,r,s,n){var i;i=e=e.replace(/\r?\n/g,"\r"),e=s.decPrivateModes.bracketedPasteMode&&!0!==n.rawOptions.ignoreBracketedPasteMode?"\x1b[200~"+i+"\x1b[201~":i,s.triggerDataEvent(e,!0),r.value=""}function pm(e,r,s){let n=s.getBoundingClientRect(),i=e.clientX-n.left-10,a=e.clientY-n.top-10;r.style.width="20px",r.style.height="20px",r.style.left=`${i}px`,r.style.top=`${a}px`,r.style.zIndex="1000",r.focus()}function pg(e,r,s,n,i){pm(e,r,s),i&&n.rightClickSelect(e),r.value=n.selectionText,r.select()}function px(e){return e>65535?String.fromCharCode(((e-=65536)>>10)+55296)+String.fromCharCode(e%1024+56320):String.fromCharCode(e)}function pv(e,r=0,s=e.length){let n="";for(let i=r;i<s;++i){let r=e[i];r>65535?(r-=65536,n+=String.fromCharCode((r>>10)+55296)+String.fromCharCode(r%1024+56320)):n+=String.fromCharCode(r)}return n}var p_=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,r){let s=e.length;if(!s)return 0;let n=0,i=0;if(this._interim){let s=e.charCodeAt(i++);56320<=s&&s<=57343?r[n++]=(this._interim-55296)*1024+s-56320+65536:(r[n++]=this._interim,r[n++]=s),this._interim=0}for(let a=i;a<s;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=s)return this._interim=i,n;let o=e.charCodeAt(a);56320<=o&&o<=57343?r[n++]=(i-55296)*1024+o-56320+65536:(r[n++]=i,r[n++]=o);continue}65279!==i&&(r[n++]=i)}return n}},py=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,r){let s=e.length;if(!s)return 0;let n=0,i,a,o,l,c=0,d=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(224&a)==192?31:(240&a)==224?15:7;let o=0,l;for(;(l=63&this.interim[++o])&&o<4;)a<<=6,a|=l;let c=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,u=c-o;for(;d<u;){if(d>=s)return 0;if((192&(l=e[d++]))!=128){d--,i=!0;break}this.interim[o++]=l,a<<=6,a|=63&l}i||(2===c?a<128?d--:r[n++]=a:3===c?a<2048||a>=55296&&a<=57343||65279===a||(r[n++]=a):a<65536||a>1114111||(r[n++]=a)),this.interim.fill(0)}let u=s-4,h=d;for(;h<s;){for(;h<u&&!(128&(i=e[h]))&&!(128&(a=e[h+1]))&&!(128&(o=e[h+2]))&&!(128&(l=e[h+3]));)r[n++]=i,r[n++]=a,r[n++]=o,r[n++]=l,h+=4;if((i=e[h++])<128)r[n++]=i;else if((224&i)==192){if(h>=s)return this.interim[0]=i,n;if((192&(a=e[h++]))!=128||(c=(31&i)<<6|63&a)<128){h--;continue}r[n++]=c}else if((240&i)==224){if(h>=s)return this.interim[0]=i,n;if((192&(a=e[h++]))!=128){h--;continue}if(h>=s)return this.interim[0]=i,this.interim[1]=a,n;if((192&(o=e[h++]))!=128){h--;continue}if((c=(15&i)<<12|(63&a)<<6|63&o)<2048||c>=55296&&c<=57343||65279===c)continue;r[n++]=c}else if((248&i)==240){if(h>=s)return this.interim[0]=i,n;if((192&(a=e[h++]))!=128){h--;continue}if(h>=s)return this.interim[0]=i,this.interim[1]=a,n;if((192&(o=e[h++]))!=128){h--;continue}if(h>=s)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,n;if((192&(l=e[h++]))!=128){h--;continue}if((c=(7&i)<<18|(63&a)<<12|(63&o)<<6|63&l)<65536||c>1114111)continue;r[n++]=c}}return n}},pb=class e{constructor(){this.fg=0,this.bg=0,this.extended=new pw}static toColorRGB(e){return[e>>>16&255,e>>>8&255,255&e]}static fromColorRGB(e){return(255&e[0])<<16|(255&e[1])<<8|255&e[2]}clone(){let r=new e;return r.fg=this.fg,r.bg=this.bg,r.extended=this.extended.clone(),r}isInverse(){return 0x4000000&this.fg}isBold(){return 0x8000000&this.fg}isUnderline(){return this.hasExtendedAttrs()&&0!==this.extended.underlineStyle?1:0x10000000&this.fg}isBlink(){return 0x20000000&this.fg}isInvisible(){return 0x40000000&this.fg}isItalic(){return 0x4000000&this.bg}isDim(){return 0x8000000&this.bg}isStrikethrough(){return 0x80000000&this.fg}isProtected(){return 0x20000000&this.bg}isOverline(){return 0x40000000&this.bg}getFgColorMode(){return 0x3000000&this.fg}getBgColorMode(){return 0x3000000&this.bg}isFgRGB(){return(0x3000000&this.fg)==0x3000000}isBgRGB(){return(0x3000000&this.bg)==0x3000000}isFgPalette(){return(0x3000000&this.fg)==0x1000000||(0x3000000&this.fg)==0x2000000}isBgPalette(){return(0x3000000&this.bg)==0x1000000||(0x3000000&this.bg)==0x2000000}isFgDefault(){return(0x3000000&this.fg)==0}isBgDefault(){return(0x3000000&this.bg)==0}isAttributeDefault(){return 0===this.fg&&0===this.bg}getFgColor(){switch(0x3000000&this.fg){case 0x1000000:case 0x2000000:return 255&this.fg;case 0x3000000:return 0xffffff&this.fg;default:return -1}}getBgColor(){switch(0x3000000&this.bg){case 0x1000000:case 0x2000000:return 255&this.bg;case 0x3000000:return 0xffffff&this.bg;default:return -1}}hasExtendedAttrs(){return 0x10000000&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-0x10000001:this.bg|=0x10000000}getUnderlineColor(){if(0x10000000&this.bg&&~this.extended.underlineColor)switch(0x3000000&this.extended.underlineColor){case 0x1000000:case 0x2000000:return 255&this.extended.underlineColor;case 0x3000000:return 0xffffff&this.extended.underlineColor}return this.getFgColor()}getUnderlineColorMode(){return 0x10000000&this.bg&&~this.extended.underlineColor?0x3000000&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 0x10000000&this.bg&&~this.extended.underlineColor?(0x3000000&this.extended.underlineColor)==0x3000000:this.isFgRGB()}isUnderlineColorPalette(){return 0x10000000&this.bg&&~this.extended.underlineColor?(0x3000000&this.extended.underlineColor)==0x1000000||(0x3000000&this.extended.underlineColor)==0x2000000:this.isFgPalette()}isUnderlineColorDefault(){return 0x10000000&this.bg&&~this.extended.underlineColor?(0x3000000&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 0x10000000&this.fg?0x10000000&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},pw=class e{constructor(e=0,r=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=r}get ext(){return this._urlId?-0x1c000001&this._ext|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(0x1c000000&this._ext)>>26}set underlineStyle(e){this._ext&=-0x1c000001,this._ext|=e<<26&0x1c000000}get underlineColor(){return 0x3ffffff&this._ext}set underlineColor(e){this._ext&=-0x4000000,this._ext|=0x3ffffff&e}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(0xe0000000&this._ext)>>29;return e<0?0xfffffff8^e:e}set underlineVariantOffset(e){this._ext&=0x1fffffff,this._ext|=e<<29&0xe0000000}clone(){return new e(this._ext,this._urlId)}isEmpty(){return 0===this.underlineStyle&&0===this._urlId}},pS=class e extends pb{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new pw,this.combinedData=""}static fromCharData(r){let s=new e;return s.setFromCharData(r),s}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?px(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(e){this.fg=e[0],this.bg=0;let r=!1;if(e[1].length>2)r=!0;else if(2===e[1].length){let s=e[1].charCodeAt(0);if(55296<=s&&s<=56319){let n=e[1].charCodeAt(1);56320<=n&&n<=57343?this.content=(s-55296)*1024+n-56320+65536|e[2]<<22:r=!0}else r=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;r&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},pj="di$target",pC="di$dependencies",pk=new Map;function pN(e){if(pk.has(e))return pk.get(e);let r=function(e,s,n){var i,a,o;if(3!=arguments.length)throw Error("@IServiceName-decorator can only be used to decorate a parameter");i=r,a=e,o=n,a[pj]===a?a[pC].push({id:i,index:o}):(a[pC]=[{id:i,index:o}],a[pj]=a)};return r._id=e,pk.set(e,r),r}var pE=pN("BufferService"),pD=pN("CoreMouseService"),pR=pN("CoreService"),pA=pN("CharsetService"),pT=pN("InstantiationService"),pM=pN("LogService"),pF=pN("OptionsService"),pP=pN("OscLinkService"),pI=pN("UnicodeService"),pB=pN("DecorationService"),pL=class{constructor(e,r,s){this._bufferService=e,this._optionsService=r,this._oscLinkService=s}provideLinks(e,r){let s=this._bufferService.buffer.lines.get(e-1);if(!s)return void r(void 0);let n=[],i=this._optionsService.rawOptions.linkHandler,a=new pS,o=s.getTrimmedLength(),l=-1,c=-1,d=!1;for(let r=0;r<o;r++)if(!(-1===c&&!s.hasContent(r))){if(s.loadCell(r,a),a.hasExtendedAttrs()&&a.extended.urlId)if(-1===c){c=r,l=a.extended.urlId;continue}else d=a.extended.urlId!==l;else -1!==c&&(d=!0);if(d||-1!==c&&r===o-1){let s=this._oscLinkService.getLinkData(l)?.uri;if(s){let a={start:{x:c+1,y:e},end:{x:r+ +(!d&&r===o-1),y:e}},l=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(s);["http:","https:"].includes(e.protocol)||(l=!0)}catch{l=!0}l||n.push({text:s,range:a,activate:(e,r)=>i?i.activate(e,r,a):function(e,r){if(confirm(`Do you want to navigate to ${r}?
11
+ For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return $.useEffect(()=>{document.getElementById(e.current?.getAttribute("aria-describedby"))||console.warn(r)},[r,e]),null};function lL({...e}){return(0,O.jsx)(lw,{"data-slot":"alert-dialog",...e})}function lz({...e}){return(0,O.jsx)(lS,{"data-slot":"alert-dialog-portal",...e})}function lO({className:e,...r}){return(0,O.jsx)(lj,{"data-slot":"alert-dialog-overlay",className:(0,ey.cn)("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...r})}function l$({className:e,...r}){return(0,O.jsxs)(lz,{children:[(0,O.jsx)(lO,{}),(0,O.jsx)(lD,{"data-slot":"alert-dialog-content",className:(0,ey.cn)("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e),...r})]})}function lW({className:e,...r}){return(0,O.jsx)("div",{"data-slot":"alert-dialog-header",className:(0,ey.cn)("flex flex-col gap-2 text-center sm:text-left",e),...r})}function lH({className:e,...r}){return(0,O.jsx)("div",{"data-slot":"alert-dialog-footer",className:(0,ey.cn)("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...r})}function lU({className:e,...r}){return(0,O.jsx)(lA,{"data-slot":"alert-dialog-title",className:(0,ey.cn)("text-lg font-semibold",e),...r})}function lq({className:e,...r}){return(0,O.jsx)(lM,{"data-slot":"alert-dialog-description",className:(0,ey.cn)("text-muted-foreground text-sm",e),...r})}function lK({className:e,...r}){return(0,O.jsx)(lF,{className:(0,ey.cn)((0,W.buttonVariants)(),e),...r})}function lV({className:e,...r}){return(0,O.jsx)(lI,{className:(0,ey.cn)((0,W.buttonVariants)({variant:"outline"}),e),...r})}let lY={task:"Task",workspace:"Workspace",agent_session:"Agent session",schedule:"Schedule",schedule_run:"Schedule run"};function lG({projectId:e,currentThreadId:r,threads:s,contextRefs:n,onNewThread:i,onSelectThread:a,onRenameThread:o,onArchiveThread:l,onDeleteThread:c,onOpenContext:d,newThreadPending:u=!1,className:h}){let[f,p]=(0,$.useState)(!0),[m,g]=(0,$.useState)(!0),[x,v]=(0,$.useState)(!1),[_,y]=(0,$.useState)(null),[b,w]=(0,$.useState)(null),[S,j]=(0,$.useState)(""),[C,k]=(0,$.useState)(null),[N,E]=(0,$.useState)(null),[D,R]=(0,$.useState)(new Set),[A,T]=(0,$.useState)(null),M=(0,$.useRef)(new Set),F=(0,$.useRef)(null),P=s.filter(e=>null===e.archived_at),I=!!b&&D.has(`rename:${b.id}`),B=!!N&&D.has(`delete:${N.id}`),L=!!C&&D.has(`archive:${C.id}`);(0,$.useEffect)(()=>{if(!_)return;F.current?.querySelector('[role="menuitem"]')?.focus();let e=e=>{"Escape"===e.key&&y(null)},r=e=>{F.current?.contains(e.target)||y(null)};return document.addEventListener("keydown",e),document.addEventListener("pointerdown",r),()=>{document.removeEventListener("keydown",e),document.removeEventListener("pointerdown",r)}},[_]);let z=async(e,r,s)=>{if(!M.current.has(e)){M.current.add(e),R(r=>new Set(r).add(e)),T(null);try{await r(),s()}catch(e){T(e instanceof Error?e.message:"Project Chat action failed")}finally{M.current.delete(e),R(r=>{let s=new Set(r);return s.delete(e),s})}}};return(0,O.jsxs)("aside",{"data-testid":"project-chat-rail","data-project-chat-column":!0,className:(0,ey.cn)("flex h-full w-[300px] shrink-0 flex-col overflow-hidden border-l border-border bg-muted/10",h),"aria-label":"Project Chat threads and context",children:[(0,O.jsxs)("section",{className:"flex min-h-0 flex-col border-b border-border/70",children:[(0,O.jsxs)("div",{className:"flex h-11 shrink-0 items-center gap-1 px-3",children:[(0,O.jsxs)("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-1.5 rounded px-1 py-1 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>p(e=>!e),"aria-expanded":f,children:[f?(0,O.jsx)(ns,{className:"size-4"}):(0,O.jsx)(a3,{className:"size-4"}),(0,O.jsx)("h2",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Chat Threads"})]}),(0,O.jsx)(W.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"New thread",disabled:u,onClick:()=>void i(),children:(0,O.jsx)(eS,{className:"size-4","aria-hidden":"true"})})]}),f?(0,O.jsxs)("div",{className:"space-y-1 px-2 pb-3",children:[P.slice(0,5).map(e=>{let s=sM(e),n=e.id===r;return(0,O.jsxs)("div",{"data-testid":"thread-row",className:(0,ey.cn)("relative flex items-center rounded-md",n?"bg-accent":"hover:bg-muted"),children:[(0,O.jsx)("button",{type:"button","aria-label":`Open thread: ${s}`,"aria-current":n?"page":void 0,onClick:()=>a(e.id),className:"min-w-0 flex-1 truncate px-2 py-2 text-left text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:s}),(0,O.jsx)(W.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":`Thread actions: ${s}`,"aria-expanded":_===e.id,"aria-haspopup":"menu","aria-controls":_===e.id?`thread-actions-${e.id}`:void 0,onClick:()=>y(r=>r===e.id?null:e.id),children:(0,O.jsx)(lx,{className:"size-4","aria-hidden":"true"})}),_===e.id?(0,O.jsxs)("div",{ref:F,id:`thread-actions-${e.id}`,role:"menu","aria-label":`Actions for ${s}`,className:"absolute right-1 top-9 z-20 w-40 rounded-md border bg-popover p-1 text-popover-foreground shadow-md",children:[(0,O.jsxs)("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-sm hover:bg-muted",onClick:()=>{y(null),T(null),w(e),j(s)},children:[(0,O.jsx)(rg,{className:"size-3.5"})," Rename thread"]}),(0,O.jsxs)("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-sm hover:bg-muted",onClick:()=>{y(null),T(null),k(e)},children:[(0,O.jsx)(sN,{className:"size-3.5"})," Archive thread"]}),(0,O.jsxs)("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-sm text-destructive hover:bg-destructive/10",onClick:()=>{y(null),T(null),E(e)},children:[(0,O.jsx)(rc,{className:"size-3.5"})," Delete thread"]})]}):null]},e.id)}),(0,O.jsx)(W.Button,{type:"button",variant:"ghost",size:"sm","aria-label":"View all threads",className:"w-full",onClick:()=>v(!0),children:"View all"})]}):null]}),(0,O.jsxs)("section",{className:"flex min-h-0 flex-1 flex-col",children:[(0,O.jsxs)("button",{type:"button",className:"flex h-11 shrink-0 items-center gap-1.5 px-4 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",onClick:()=>g(e=>!e),"aria-expanded":m,children:[m?(0,O.jsx)(ns,{className:"size-4"}):(0,O.jsx)(a3,{className:"size-4"}),(0,O.jsx)("h2",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Context"})]}),m?(0,O.jsx)("div",{className:"min-h-0 flex-1 space-y-1 overflow-y-auto px-2 pb-3",children:0===n.length?(0,O.jsx)("p",{className:"px-2 py-4 text-xs text-muted-foreground",children:"Referenced project items appear here."}):n.map(e=>{let r=lY[e.entity_type],s=!e.deleted&&(!e.navigation||!d),n=e.deleted||s,i=e.navigation?"Navigation is unavailable in this view.":"Navigation details are unavailable; refresh the thread and try again.";return(0,O.jsxs)("button",{type:"button",disabled:n,"aria-label":e.deleted?`Deleted ${r.toLocaleLowerCase()}`:s?`Unavailable ${r.toLocaleLowerCase()}`:`Open ${r}: ${e.navigation.label}`,title:s?i:void 0,onClick:()=>d?.(e),className:"flex w-full flex-col rounded-md px-2 py-2 text-left hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-55",children:[(0,O.jsx)("span",{className:"text-sm",children:e.deleted?`Deleted ${r.toLocaleLowerCase()}`:s?`Unavailable ${r.toLocaleLowerCase()}`:`${r} \xb7 ${e.navigation.label}`}),e.deleted?(0,O.jsx)("span",{className:"text-xs text-muted-foreground",children:"Deleted"}):null,s?(0,O.jsx)("span",{className:"text-xs text-muted-foreground",children:i}):null]},`${e.entity_type}:${e.entity_id}`)})}):null]}),(0,O.jsx)(sF,{open:x,onOpenChange:v,projectId:e,onSelectThread:a}),(0,O.jsx)(t8,{open:null!==b,onOpenChange:e=>{e||I||(w(null),T(null))},children:(0,O.jsxs)(rr,{children:[(0,O.jsxs)(rs,{children:[(0,O.jsx)(ri,{children:"Rename Project Chat thread"}),(0,O.jsx)(ra,{children:"Give this conversation a concise project-level title."})]}),(0,O.jsx)(ro,{autoFocus:!0,"aria-label":"Thread title",value:S,onChange:e=>j(e.target.value),onKeyDown:e=>{"Enter"===e.key&&b&&S.trim()&&z(`rename:${b.id}`,()=>o(b.id,S.trim()),()=>w(null))}}),A?(0,O.jsx)("div",{role:"alert",className:"rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:A}):null,(0,O.jsxs)(rn,{children:[(0,O.jsx)(W.Button,{type:"button",variant:"outline",disabled:I,onClick:()=>{w(null),T(null)},children:"Cancel"}),(0,O.jsx)(W.Button,{type:"button",disabled:!S.trim()||I,onClick:()=>{b&&z(`rename:${b.id}`,()=>o(b.id,S.trim()),()=>w(null))},children:"Save title"})]})]})}),(0,O.jsx)(lL,{open:null!==N,onOpenChange:e=>{e||B||(E(null),T(null))},children:(0,O.jsxs)(l$,{children:[(0,O.jsxs)(lW,{children:[(0,O.jsx)(lU,{children:"Delete this Project Chat thread?"}),(0,O.jsx)(lq,{children:"This permanently removes the thread and its persisted conversation."})]}),A?(0,O.jsx)("div",{role:"alert",className:"rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:A}):null,(0,O.jsxs)(lH,{children:[(0,O.jsx)(lV,{disabled:B,children:"Cancel"}),(0,O.jsx)(lK,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",disabled:B,onClick:e=>{e.preventDefault(),N&&z(`delete:${N.id}`,()=>c(N.id),()=>E(null))},children:"Confirm delete"})]})]})}),(0,O.jsx)(lL,{open:null!==C,onOpenChange:e=>{e||L||(k(null),T(null))},children:(0,O.jsxs)(l$,{children:[(0,O.jsxs)(lW,{children:[(0,O.jsx)(lU,{children:"Archive this Project Chat thread?"}),(0,O.jsx)(lq,{children:"The conversation leaves recent selectors but remains available in thread history."})]}),A?(0,O.jsx)("div",{role:"alert",className:"rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:A}):null,(0,O.jsxs)(lH,{children:[(0,O.jsx)(lV,{disabled:L,children:"Cancel"}),(0,O.jsx)(lK,{disabled:L,onClick:e=>{e.preventDefault(),C&&z(`archive:${C.id}`,()=>l(C.id),()=>k(null))},children:"Confirm archive"})]})]})})]})}var lX=e.i(113862);let lJ=(0,ew.default)("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);var lZ="horizontal",lQ=["horizontal","vertical"],l0=$.forwardRef((e,r)=>{var s;let{decorative:n,orientation:i=lZ,...a}=e,o=(s=i,lQ.includes(s))?i:lZ;return(0,O.jsx)(er.div,{"data-orientation":o,...n?{role:"none"}:{"aria-orientation":"vertical"===o?o:void 0,role:"separator"},...a,ref:r})});l0.displayName="Separator",e.s(["Root",()=>l0,"Separator",()=>l0],691102),e.i(691102),(0,sn.cva)("flex w-fit items-stretch [&>*]:focus-visible:z-10 [&>*]:focus-visible:relative [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md has-[>[data-slot=button-group]]:gap-2",{variants:{orientation:{horizontal:"[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",vertical:"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"}},defaultVariants:{orientation:"horizontal"}});var l1=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),l2=$.forwardRef((e,r)=>(0,O.jsx)(er.span,{...e,ref:r,style:{...l1,...e.style}}));l2.displayName="VisuallyHidden";var[l5,l3]=q("Tooltip",[iw]),l4=iw(),l6="TooltipProvider",l7="tooltip.open",[l8,l9]=l5(l6),ce=e=>{let{__scopeTooltip:r,delayDuration:s=700,skipDelayDuration:n=300,disableHoverableContent:i=!1,children:a}=e,o=$.useRef(!0),l=$.useRef(!1),c=$.useRef(0);return $.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,O.jsx)(l8,{scope:r,isOpenDelayedRef:o,delayDuration:s,onOpen:$.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:$.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,n)},[n]),isPointerInTransitRef:l,onPointerInTransitChange:$.useCallback(e=>{l.current=e},[]),disableHoverableContent:i,children:a})};ce.displayName=l6;var ct="Tooltip",[cr,cs]=l5(ct),cn=e=>{let{__scopeTooltip:r,children:s,open:n,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:l}=e,c=l9(ct,e.__scopeTooltip),d=l4(r),[u,h]=$.useState(null),f=ek(),p=$.useRef(0),m=o??c.disableHoverableContent,g=l??c.delayDuration,x=$.useRef(!1),[v,_]=G({prop:n,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(l7))):c.onClose(),a?.(e)},caller:ct}),y=$.useMemo(()=>v?x.current?"delayed-open":"instant-open":"closed",[v]),b=$.useCallback(()=>{window.clearTimeout(p.current),p.current=0,x.current=!1,_(!0)},[_]),w=$.useCallback(()=>{window.clearTimeout(p.current),p.current=0,_(!1)},[_]),S=$.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{x.current=!0,_(!0),p.current=0},g)},[g,_]);return $.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),(0,O.jsx)(iC,{...d,children:(0,O.jsx)(cr,{scope:r,contentId:f,open:v,stateAttribute:y,trigger:u,onTriggerChange:h,onTriggerEnter:$.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:$.useCallback(()=>{m?w():(window.clearTimeout(p.current),p.current=0)},[w,m]),onOpen:b,onClose:w,disableHoverableContent:m,children:s})})};cn.displayName=ct;var ci="TooltipTrigger",ca=$.forwardRef((e,r)=>{let{__scopeTooltip:s,...n}=e,i=cs(ci,s),a=l9(ci,s),o=l4(s),l=$.useRef(null),c=(0,U.useComposedRefs)(r,l,i.onTriggerChange),d=$.useRef(!1),u=$.useRef(!1),h=$.useCallback(()=>d.current=!1,[]);return $.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),(0,O.jsx)(iN,{asChild:!0,...o,children:(0,O.jsx)(er.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...n,ref:c,onPointerMove:K(e.onPointerMove,e=>{"touch"!==e.pointerType&&(u.current||a.isPointerInTransitRef.current||(i.onTriggerEnter(),u.current=!0))}),onPointerLeave:K(e.onPointerLeave,()=>{i.onTriggerLeave(),u.current=!1}),onPointerDown:K(e.onPointerDown,()=>{i.open&&i.onClose(),d.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:K(e.onFocus,()=>{d.current||i.onOpen()}),onBlur:K(e.onBlur,i.onClose),onClick:K(e.onClick,i.onClose)})})});ca.displayName=ci;var co="TooltipPortal",[cl,cc]=l5(co,{forceMount:void 0}),cd=e=>{let{__scopeTooltip:r,forceMount:s,children:n,container:i}=e,a=cs(co,r);return(0,O.jsx)(cl,{scope:r,forceMount:s,children:(0,O.jsx)(Z,{present:s||a.open,children:(0,O.jsx)(eW,{asChild:!0,container:i,children:n})})})};cd.displayName=co;var cu="TooltipContent",ch=$.forwardRef((e,r)=>{let s=cc(cu,e.__scopeTooltip),{forceMount:n=s.forceMount,side:i="top",...a}=e,o=cs(cu,e.__scopeTooltip);return(0,O.jsx)(Z,{present:n||o.open,children:o.disableHoverableContent?(0,O.jsx)(cx,{side:i,...a,ref:r}):(0,O.jsx)(cf,{side:i,...a,ref:r})})}),cf=$.forwardRef((e,r)=>{let s=cs(cu,e.__scopeTooltip),n=l9(cu,e.__scopeTooltip),i=$.useRef(null),a=(0,U.useComposedRefs)(r,i),[o,l]=$.useState(null),{trigger:c,onClose:d}=s,u=i.current,{onPointerInTransitChange:h}=n,f=$.useCallback(()=>{l(null),h(!1)},[h]),p=$.useCallback((e,r)=>{let s,n=e.currentTarget,i={x:e.clientX,y:e.clientY},a=function(e,r){let s=Math.abs(r.top-e.y),n=Math.abs(r.bottom-e.y),i=Math.abs(r.right-e.x),a=Math.abs(r.left-e.x);switch(Math.min(s,n,i,a)){case a:return"left";case i:return"right";case s:return"top";case n:return"bottom";default:throw Error("unreachable")}}(i,n.getBoundingClientRect());l(((s=[...function(e,r,s=5){let n=[];switch(r){case"top":n.push({x:e.x-s,y:e.y+s},{x:e.x+s,y:e.y+s});break;case"bottom":n.push({x:e.x-s,y:e.y-s},{x:e.x+s,y:e.y-s});break;case"left":n.push({x:e.x+s,y:e.y-s},{x:e.x+s,y:e.y+s});break;case"right":n.push({x:e.x-s,y:e.y-s},{x:e.x-s,y:e.y+s})}return n}(i,a),...function(e){let{top:r,right:s,bottom:n,left:i}=e;return[{x:i,y:r},{x:s,y:r},{x:s,y:n},{x:i,y:n}]}(r.getBoundingClientRect())].slice()).sort((e,r)=>e.x<r.x?-1:e.x>r.x?1:e.y<r.y?-1:1*!!(e.y>r.y)),function(e){if(e.length<=1)return e.slice();let r=[];for(let s=0;s<e.length;s++){let n=e[s];for(;r.length>=2;){let e=r[r.length-1],s=r[r.length-2];if((e.x-s.x)*(n.y-s.y)>=(e.y-s.y)*(n.x-s.x))r.pop();else break}r.push(n)}r.pop();let s=[];for(let r=e.length-1;r>=0;r--){let n=e[r];for(;s.length>=2;){let e=s[s.length-1],r=s[s.length-2];if((e.x-r.x)*(n.y-r.y)>=(e.y-r.y)*(n.x-r.x))s.pop();else break}s.push(n)}return(s.pop(),1===r.length&&1===s.length&&r[0].x===s[0].x&&r[0].y===s[0].y)?r:r.concat(s)}(s))),h(!0)},[h]);return $.useEffect(()=>()=>f(),[f]),$.useEffect(()=>{if(c&&u){let e=e=>p(e,u),r=e=>p(e,c);return c.addEventListener("pointerleave",e),u.addEventListener("pointerleave",r),()=>{c.removeEventListener("pointerleave",e),u.removeEventListener("pointerleave",r)}}},[c,u,p,f]),$.useEffect(()=>{if(o){let e=e=>{let r=e.target,s={x:e.clientX,y:e.clientY},n=c?.contains(r)||u?.contains(r),i=!function(e,r){let{x:s,y:n}=e,i=!1;for(let e=0,a=r.length-1;e<r.length;a=e++){let o=r[e],l=r[a],c=o.x,d=o.y,u=l.x,h=l.y;d>n!=h>n&&s<(u-c)*(n-d)/(h-d)+c&&(i=!i)}return i}(s,o);n?f():i&&(f(),d())};return document.addEventListener("pointermove",e),()=>document.removeEventListener("pointermove",e)}},[c,u,o,d,f]),(0,O.jsx)(cx,{...e,ref:a})}),[cp,cm]=l5(ct,{isInside:!1}),cg=(0,et.createSlottable)("TooltipContent"),cx=$.forwardRef((e,r)=>{let{__scopeTooltip:s,children:n,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...l}=e,c=cs(cu,s),d=l4(s),{onClose:u}=c;return $.useEffect(()=>(document.addEventListener(l7,u),()=>document.removeEventListener(l7,u)),[u]),$.useEffect(()=>{if(c.trigger){let e=e=>{let r=e.target;r?.contains(c.trigger)&&u()};return window.addEventListener("scroll",e,{capture:!0}),()=>window.removeEventListener("scroll",e,{capture:!0})}},[c.trigger,u]),(0,O.jsx)(eR,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,O.jsxs)(iA,{"data-state":c.stateAttribute,...d,...l,ref:r,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[(0,O.jsx)(cg,{children:n}),(0,O.jsx)(cp,{scope:s,isInside:!0,children:(0,O.jsx)(l2,{id:c.contentId,role:"tooltip",children:i||n})})]})})});ch.displayName=cu;var cv="TooltipArrow",c_=$.forwardRef((e,r)=>{let{__scopeTooltip:s,...n}=e,i=l4(s);return cm(cv,s).isInside?null:(0,O.jsx)(iF,{...i,...n,ref:r})});c_.displayName=cv,e.s(["Arrow",()=>c_,"Content",()=>ch,"Portal",()=>cd,"Provider",()=>ce,"Root",()=>cn,"Tooltip",()=>cn,"TooltipArrow",()=>c_,"TooltipContent",()=>ch,"TooltipPortal",()=>cd,"TooltipProvider",()=>ce,"TooltipTrigger",()=>ca,"Trigger",()=>ca,"createTooltipScope",()=>l3],517964);var cy=e.i(517964),cy=cy;function cb({delayDuration:e=0,...r}){return(0,O.jsx)(cy.Provider,{"data-slot":"tooltip-provider",delayDuration:e,...r})}function cw({...e}){return(0,O.jsx)(cy.Root,{"data-slot":"tooltip",...e})}function cS({...e}){return(0,O.jsx)(cy.Trigger,{"data-slot":"tooltip-trigger",...e})}function cj({className:e,sideOffset:r=0,children:s,...n}){return(0,O.jsx)(cy.Portal,{children:(0,O.jsxs)(cy.Content,{"data-slot":"tooltip-content",sideOffset:r,className:(0,ey.cn)("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...n,children:[s,(0,O.jsx)(cy.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}(0,ew.default)("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);var cC=e.i(94265),ck=cC;let cN=({className:e,from:r,...s})=>(0,O.jsx)("div",{className:(0,ey.cn)("group flex w-full max-w-[95%] flex-col gap-2","user"===r?"is-user ml-auto justify-end":"is-assistant",e),...s}),cE=({children:e,className:r,...s})=>(0,O.jsx)("div",{className:(0,ey.cn)("is-user:dark flex w-fit max-w-full min-w-0 flex-col gap-2 overflow-hidden text-sm","group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground","group-[.is-assistant]:text-foreground",r),...s,children:e}),cD=(0,$.memo)(({className:e,...r})=>(0,O.jsx)(ck.i,{className:(0,ey.cn)("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),...r}),(e,r)=>e.children===r.children);cD.displayName="MessageResponse";let cR=(0,ew.default)("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]),cA={damping:.7,stiffness:.05,mass:1.25},cT=1e3/60,cM=!1;function cF(e,r){let s=(0,$.useCallback)(r=>(s.current=r,e(r)),r);return s}globalThis.document?.addEventListener("mousedown",()=>{cM=!0}),globalThis.document?.addEventListener("mouseup",()=>{cM=!1}),globalThis.document?.addEventListener("click",()=>{cM=!1});let cP=new Map;function cI(...e){let r={...cA},s=!1;for(let n of e){if("instant"===n){s=!0;continue}"object"==typeof n&&(s=!1,r.damping=n.damping??r.damping,r.stiffness=n.stiffness??r.stiffness,r.mass=n.mass??r.mass)}let n=JSON.stringify(r);return cP.has(n)||cP.set(n,Object.freeze(r)),s?"instant":cP.get(n)}let cB=(0,$.createContext)(null),cL="undefined"!=typeof window?$.useLayoutEffect:$.useEffect;function cz({instance:e,children:r,resize:s,initial:n,mass:i,damping:a,stiffness:o,targetScrollTop:l,contextRef:c,...d}){let u=(0,$.useRef)(null),h=((e={})=>{let[r,s]=(0,$.useState)(!1),[n,i]=(0,$.useState)(!1!==e.initial),[a,o]=(0,$.useState)(!1),l=(0,$.useRef)(null);l.current=e;let c=(0,$.useCallback)(()=>{if(!cM)return!1;let e=window.getSelection();if(!e||!e.rangeCount)return!1;let r=e.getRangeAt(0);return r.commonAncestorContainer.contains(x.current)||x.current?.contains(r.commonAncestorContainer)},[]),d=(0,$.useCallback)(e=>{h.isAtBottom=e,i(e)},[]),u=(0,$.useCallback)(e=>{h.escapedFromLock=e,s(e)},[]),h=(0,$.useMemo)(()=>{let s;return{escapedFromLock:r,isAtBottom:n,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return x.current?.scrollTop??0},set scrollTop(scrollTop){x.current&&(x.current.scrollTop=scrollTop,h.ignoreScrollToTop=x.current.scrollTop)},get targetScrollTop(){if(!x.current||!v.current)return 0;return x.current.scrollHeight-1-x.current.clientHeight},get calculatedTargetScrollTop(){if(!x.current||!v.current)return 0;let{targetScrollTop:r}=this;if(!e.targetScrollTop)return r;if(s?.targetScrollTop===r)return s.calculatedScrollTop;let n=Math.max(Math.min(e.targetScrollTop(r,{scrollElement:x.current,contentElement:v.current}),r),0);return s={targetScrollTop:r,calculatedScrollTop:n},requestAnimationFrame(()=>{s=void 0}),n},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=70}}},[]),f=(0,$.useCallback)((e={})=>{let r;"string"==typeof e&&(e={animation:e}),e.preserveScrollPosition||d(!0);let s=Date.now()+(Number(e.wait)||0),n=cI(l.current,e.animation),{ignoreEscapes:i=!1}=e,a=h.calculatedTargetScrollTop;e.duration instanceof Promise?e.duration.finally(()=>{r=Date.now()}):r=s+(e.duration??0);let o=async()=>{let e=new Promise(requestAnimationFrame).then(()=>{if(!h.isAtBottom)return h.animation=void 0,!1;let{scrollTop:d}=h,u=performance.now(),p=(u-(h.lastTick??u))/cT;if(h.animation||(h.animation={behavior:n,promise:e,ignoreEscapes:i}),h.animation.behavior===n&&(h.lastTick=u),c()||s>Date.now())return o();if(d<Math.min(a,h.calculatedTargetScrollTop)){if(h.animation?.behavior===n){if("instant"===n)return h.scrollTop=h.calculatedTargetScrollTop,o();h.velocity=(n.damping*h.velocity+n.stiffness*h.scrollDifference)/n.mass,h.accumulated+=h.velocity*p,h.scrollTop+=h.accumulated,h.scrollTop!==d&&(h.accumulated=0)}return o()}return r>Date.now()?(a=h.calculatedTargetScrollTop,o()):(h.animation=void 0,h.scrollTop<h.calculatedTargetScrollTop)?f({animation:cI(l.current,l.current.resize),ignoreEscapes:i,duration:Math.max(0,r-Date.now())||void 0}):h.isAtBottom});return e.then(e=>(requestAnimationFrame(()=>{h.animation||(h.lastTick=void 0,h.velocity=0)}),e))};return(!0!==e.wait&&(h.animation=void 0),h.animation?.behavior===n)?h.animation.promise:o()},[d,c,h]),p=(0,$.useCallback)(()=>{u(!0),d(!1)},[u,d]),m=(0,$.useCallback)(({target:e})=>{if(e!==x.current)return;let{scrollTop:r,ignoreScrollToTop:s}=h,{lastScrollTop:n=r}=h;h.lastScrollTop=r,h.ignoreScrollToTop=void 0,s&&s>r&&(n=s),o(h.isNearBottom),setTimeout(()=>{if(h.resizeDifference||r===s)return;if(c()){u(!0),d(!1);return}let e=r>n,i=r<n;if(h.animation?.ignoreEscapes){h.scrollTop=n;return}i&&(u(!0),d(!1)),e&&u(!1),!h.escapedFromLock&&h.isNearBottom&&d(!0)},1)},[u,d,c,h]),g=(0,$.useCallback)(({target:e,deltaY:r})=>{let s=e;for(;!["scroll","auto"].includes(getComputedStyle(s).overflow);){if(!s.parentElement)return;s=s.parentElement}s===x.current&&r<0&&x.current.scrollHeight>x.current.clientHeight&&!h.animation?.ignoreEscapes&&(u(!0),d(!1))},[u,d,h]),x=cF(e=>{x.current?.removeEventListener("scroll",m),x.current?.removeEventListener("wheel",g),e?.addEventListener("scroll",m,{passive:!0}),e?.addEventListener("wheel",g,{passive:!0})},[]),v=cF(e=>{let r;h.resizeObserver?.disconnect(),e&&(h.resizeObserver=new ResizeObserver(([e])=>{let{height:s}=e.contentRect,n=s-(r??s);if(h.resizeDifference=n,h.scrollTop>h.targetScrollTop&&(h.scrollTop=h.targetScrollTop),o(h.isNearBottom),n>=0){let e=cI(l.current,r?l.current.resize:l.current.initial);f({animation:e,wait:!0,preserveScrollPosition:!0,duration:"instant"===e?void 0:350})}else h.isNearBottom&&(u(!1),d(!0));r=s,requestAnimationFrame(()=>{setTimeout(()=>{h.resizeDifference===n&&(h.resizeDifference=0)},1)})}),h.resizeObserver?.observe(e))},[]);return{contentRef:v,scrollRef:x,scrollToBottom:f,stopScroll:p,isAtBottom:n||a,isNearBottom:a,escapedFromLock:r,state:h}})({mass:i,damping:a,stiffness:o,resize:s,initial:n,targetScrollTop:$.useCallback((e,r)=>{let s=y?.targetScrollTop??l;return s?.(e,r)??e},[l])}),{scrollRef:f,contentRef:p,scrollToBottom:m,stopScroll:g,isAtBottom:x,escapedFromLock:v,state:_}=e??h,y=(0,$.useMemo)(()=>({scrollToBottom:m,stopScroll:g,scrollRef:f,isAtBottom:x,escapedFromLock:v,contentRef:p,state:_,get targetScrollTop(){return u.current},set targetScrollTop(targetScrollTop){u.current=targetScrollTop}}),[m,x,p,f,g,v,_]);return(0,$.useImperativeHandle)(c,()=>y,[y]),cL(()=>{f.current&&"visible"===getComputedStyle(f.current).overflow&&(f.current.style.overflow="auto")},[]),$.createElement(cB.Provider,{value:y},$.createElement("div",{...d},"function"==typeof r?r(y):r))}function cO(){let e=(0,$.useContext)(cB);if(!e)throw Error("use-stick-to-bottom component context must be used within a StickToBottom component");return e}(cz||(cz={})).Content=function({children:e,scrollClassName:r,...s}){let n=cO();return $.createElement("div",{ref:n.scrollRef,style:{height:"100%",width:"100%",scrollbarGutter:"stable both-edges"},className:r},$.createElement("div",{...s,ref:n.contentRef},"function"==typeof e?e(n):e))};let c$=({className:e,...r})=>(0,O.jsx)(cz,{className:(0,ey.cn)("relative flex-1 overflow-y-hidden",e),initial:"smooth",resize:"smooth",role:"log",...r}),cW=({className:e,...r})=>(0,O.jsx)(cz.Content,{className:(0,ey.cn)("flex flex-col gap-8 p-4",e),...r}),cH=({className:e,...r})=>{let{isAtBottom:s,scrollToBottom:n}=cO(),i=(0,$.useCallback)(()=>{n()},[n]);return!s&&(0,O.jsx)(W.Button,{className:(0,ey.cn)("absolute bottom-4 left-[50%] translate-x-[-50%] rounded-full",e),onClick:i,size:"icon",type:"button",variant:"outline",...r,children:(0,O.jsx)(cR,{className:"size-4"})})},cU=(0,ew.default)("circle-dot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]),cq=(0,ew.default)("clock-3",[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),cK=(0,ew.default)("message-square-more",[["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"}],["path",{d:"M12 11h.01",key:"z322tv"}],["path",{d:"M16 11h.01",key:"xkw8gn"}],["path",{d:"M8 11h.01",key:"1dfujw"}]]);function cV({operation:e,onOpenSession:r,onViewOutput:s,onRunAgain:n,pendingAction:i,actionError:a}){let{label:o,detail:l}=function(e){switch(e.kind){case"task_create":return{label:"Task created",detail:e.title??e.taskId};case"task_update":return{label:"Task updated",detail:e.title??e.taskId};case"agent_session_create":return{label:"Agent session",detail:e.branch?`${e.target??"workspace"} / ${e.branch}`:e.target??"main workspace"};case"agent_instruction":return{label:"Agent instruction",detail:e.instruction??e.sessionId};case"schedule_run":return{label:"Schedule run",detail:e.runId}}}(e),c=e.failure?.code==="timeout"?{label:"Timed out",Icon:cq,className:"text-amber-600"}:e.failure?.code==="remote_offline"?{label:"Remote offline",Icon:sy,className:"text-destructive"}:e.failure?.code==="deleted_target"?{label:"Deleted target",Icon:sy,className:"text-muted-foreground"}:"completed"===e.status?{label:"Completed",Icon:sJ,className:"text-emerald-600"}:"failed"===e.status?{label:"Failed",Icon:sy,className:"text-destructive"}:"running"===e.status||"resolving"===e.status?{label:"Running",Icon:sj,className:"text-blue-600"}:{label:"Queued",Icon:cU,className:"text-muted-foreground"},d=e.failure?.code==="deleted_target",u="agent_session_create"===e.kind&&e.sessionAvailable&&("running"===e.status||"completed"===e.status)&&!d,h="schedule_run"===e.kind&&e.runAvailable&&("running"===e.status||"completed"===e.status||"failed"===e.status)&&!d,f="schedule_run"===e.kind&&e.runAvailable&&("completed"===e.status||"failed"===e.status)&&!d,p=c.Icon;return(0,O.jsxs)("section",{className:"rounded-lg border bg-card p-3 text-card-foreground","aria-label":`${o}: ${c.label}`,children:[(0,O.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,O.jsxs)("div",{className:"min-w-0",children:[(0,O.jsx)("div",{className:"text-sm font-medium",children:o}),l?(0,O.jsx)("div",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:l}):null]}),(0,O.jsxs)("div",{"data-operation-status":e.status,className:(0,ey.cn)("flex shrink-0 items-center gap-1.5 text-xs font-medium",c.className),children:[(0,O.jsx)(p,{className:(0,ey.cn)("size-3.5",("running"===e.status||"resolving"===e.status)&&"animate-spin"),"aria-hidden":"true"}),c.label]})]}),e.failure?.message?(0,O.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:e.failure.message}):null,"agent_session_create"===e.kind&&u&&r?(0,O.jsx)("div",{className:"mt-3",children:(0,O.jsxs)(W.Button,{type:"button",size:"sm",variant:"outline","aria-busy":"open_session"===i,disabled:null!=i,onClick:()=>r(e),children:["open_session"===i?(0,O.jsx)(sj,{className:"size-3.5 animate-spin"}):(0,O.jsx)(s7,{className:"size-3.5"}),"Open Session"]})}):null,"schedule_run"===e.kind&&(h&&s||f&&n)?(0,O.jsxs)("div",{className:"mt-3 flex flex-wrap gap-2",children:[h&&s?(0,O.jsxs)(W.Button,{type:"button",size:"sm",variant:"outline","aria-busy":"view_output"===i,disabled:null!=i,onClick:()=>s(e),children:["view_output"===i?(0,O.jsx)(sj,{className:"size-3.5 animate-spin"}):(0,O.jsx)(cK,{className:"size-3.5"}),"View Output"]}):null,f&&n?(0,O.jsxs)(W.Button,{type:"button",size:"sm",variant:"outline","aria-busy":"run_again"===i,disabled:null!=i,onClick:()=>n(e),children:["run_again"===i?(0,O.jsx)(sj,{className:"size-3.5 animate-spin"}):(0,O.jsx)(s8,{className:"size-3.5"}),"run_again"===i?"Running again…":"Run Again"]}):null]}):null,a?(0,O.jsx)("p",{role:"alert",className:"mt-2 text-xs text-destructive",children:a}):null]})}let cY=(0,ew.default)("map-pin",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]]);function cG({operation:e,onSelect:r,pendingWorkspaceId:s,actionError:n}){let i="pending"!==e.status;return(0,O.jsxs)("section",{className:"rounded-lg border bg-card p-3 text-card-foreground","aria-label":"Select a workspace for the agent session",children:[(0,O.jsx)("div",{className:"text-sm font-medium",children:"Choose a workspace"}),(0,O.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"This agent session needs one of the project's offered workspaces."}),(0,O.jsx)("div",{className:"mt-3 grid gap-2",children:e.candidates.map(n=>{let a=s===n.id,o=`${n.target} / ${n.branch??"main"}`;return(0,O.jsxs)(W.Button,{type:"button",variant:"outline",className:"h-auto min-h-9 justify-start whitespace-normal text-left","aria-label":`Select workspace: ${o}`,"aria-busy":a,disabled:i||null!=s,onClick:()=>r({requestId:e.requestId,workspaceId:n.id}),children:[a?(0,O.jsx)(sj,{className:"size-3.5 animate-spin"}):(0,O.jsx)(cY,{className:"size-3.5"}),o,a?" · Selecting…":""]},n.id)})}),i?(0,O.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Workspace selection resolved."}):null,n?(0,O.jsx)("p",{role:"alert",className:"mt-2 text-xs text-destructive",children:n}):null]})}function cX(e){try{let r=JSON.parse(e);return"object"!=typeof r||null===r||Array.isArray(r)?null:r}catch{return null}}function cJ(e){if("workspace_selection"===e.kind)switch(e.status){case"pending":return"Waiting for workspace selection";case"resolving":return"Creating agent session";case"running":return"Agent session running";case"completed":return"Agent session completed";case"failed":return"Workspace selection failed"}if("agent_session_create"===e.kind){if("resolving"===e.status)return"Creating agent session";if("running"===e.status)return"Agent session running";if("completed"===e.status)return"Agent session completed"}switch(e.status){case"pending":return"Queued";case"resolving":case"running":return"Running";case"completed":return"Completed";case"failed":return"Failed"}}function cZ({messages:e,contextRefs:r,status:s,activeTurnId:n,pendingApprovalIds:i,queueLength:a,loading:o,hasEarlierMessages:l,loadingEarlierMessages:c,connected:d,error:u,initialDraft:h="",onDraftChange:f,onDraftSent:p,onSend:m,onLoadEarlierMessages:g,onStop:x,onResolveApproval:v,onSelectWorkspace:_,onOpenAgentSession:y,onOpenScheduleRun:b,onRunScheduleAgain:w}){let[S,j]=(0,$.useState)(h),[C,k]=(0,$.useState)(!1),[N,E]=(0,$.useState)(null),[D,R]=(0,$.useState)(new Set),[A,T]=(0,$.useState)(new Set),[M,F]=(0,$.useState)(null),P=(0,$.useRef)(!1),I=(0,$.useRef)(null),B=(0,$.useRef)(new Set),L=(0,$.useRef)(new Set),[z,H]=(0,$.useState)(new Map),[U,q]=(0,$.useState)(new Map),K=(0,$.useMemo)(()=>{let r=new Map,s=new Map;for(let n of e){if("operation"!==n.type)continue;let e=(0,rv.parseProjectChatOperationMessage)(n.content);e&&(r.set(n.id,e),s.set(e.operationId,n.id))}return{byMessageId:r,latestMessageIdByOperation:s}},[e]),V=async(e,r,s)=>{if(!L.current.has(e)){L.current.add(e),H(s=>new Map(s).set(e,r)),q(r=>{let s=new Map(r);return s.delete(e),s});try{await s()}catch(r){q(s=>new Map(s).set(e,r instanceof Error?r.message:"Project operation failed"))}finally{L.current.delete(e),H(r=>{let s=new Map(r);return s.delete(e),s})}}},Y=async e=>{e.preventDefault();let r=S.trim();if(r&&!P.current){P.current=!0,k(!0),F(null);try{await m(r),j(""),p?.(S)}catch(e){F(e instanceof Error?e.message:"Failed to send message")}finally{P.current=!1,k(!1)}}};(0,$.useEffect)(()=>{let e=I.current;e&&("running"!==s||n!==e)&&(I.current=null,E(null))},[n,s]);let G=async()=>{if(n&&!I.current){I.current=n,E(n),F(null);try{await x(n)}catch(e){I.current===n&&F(e instanceof Error?e.message:"Failed to stop generation")}}},X=async(e,r)=>{if(!B.current.has(e)){B.current.add(e),R(r=>new Set(r).add(e)),F(null);try{await v(e,r),T(r=>new Set(r).add(e))}catch(e){F(e instanceof Error?e.message:"Failed to resolve approval")}finally{B.current.delete(e),R(r=>{let s=new Set(r);return s.delete(e),s})}}};return(0,$.useEffect)(()=>{T(e=>{let r=new Set([...e].filter(e=>i.includes(e)));return r.size===e.size?e:r})},[i]),(0,O.jsxs)("div",{className:"flex h-full min-h-0 flex-col",children:[(0,O.jsxs)(c$,{className:"min-h-0",initial:"instant",resize:"smooth","data-testid":"project-chat-scroll",children:[(0,O.jsxs)(cW,{className:"mx-auto w-full max-w-3xl gap-4 px-4 py-5 sm:px-6",children:[l?(0,O.jsx)("div",{className:"flex justify-center",children:(0,O.jsxs)(W.Button,{type:"button",size:"sm",variant:"outline",disabled:c,onClick:()=>void g(),children:[c?(0,O.jsx)(sj,{className:"size-3.5 animate-spin"}):null,"Load earlier messages"]})}):null,o&&0===e.length?(0,O.jsx)("div",{className:"flex justify-center py-12",children:(0,O.jsx)(sj,{className:"size-5 animate-spin text-muted-foreground"})}):null,o||0!==e.length?null:(0,O.jsxs)("div",{className:"mx-auto max-w-md py-20 text-center",children:[(0,O.jsx)("h2",{className:"text-base font-semibold",children:"Start a project conversation"}),(0,O.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"Discuss tasks, schedules, sessions, and work across the whole project."})]}),(0,O.jsxs)("div",{className:"flex w-full flex-col gap-4",children:[e.map(e=>{var s;if("turn_end"===e.type)return(0,O.jsxs)("div",{"data-testid":"turn-boundary",className:"my-2 flex items-center gap-2","aria-label":"Turn complete",children:[(0,O.jsx)("span",{className:"h-px flex-1 bg-border"}),(0,O.jsx)("span",{className:"size-1 rounded-full bg-border"}),(0,O.jsx)("span",{className:"h-px flex-1 bg-border"})]},e.id);if("user"===e.type||"assistant"===e.type)return(0,O.jsx)(cN,{from:e.type,children:(0,O.jsx)(cE,{children:"assistant"===e.type?(0,O.jsx)(cD,{children:e.content}):e.content})},e.id);if("tool_use"===e.type){let r;return(0,O.jsxs)("div",{className:"flex items-center gap-2 rounded-md bg-muted/50 px-3 py-2 text-xs text-muted-foreground",children:[(0,O.jsx)(sA,{className:"size-3.5"}),"Running ",(r=cX(e.content),("string"==typeof r?.toolName?r.toolName:"string"==typeof r?.tool?r.tool:"project tool").replaceAll("_"," ")),"…"]},e.id)}if("tool_result"===e.type){let r;return(0,O.jsxs)("details",{className:"rounded-md border px-3 py-2 text-xs",children:[(0,O.jsx)("summary",{className:"cursor-pointer text-muted-foreground",children:"Tool result"}),(0,O.jsx)("pre",{className:"mt-2 overflow-x-auto whitespace-pre-wrap",children:(r=cX(s=e.content),"string"==typeof r?.output?r.output:"string"==typeof r?.error?r.error:s)})]},e.id)}if("tool_approval_request"===e.type){let r=cX(e.content);if(!r||"string"!=typeof r.approvalId)return null;let s="string"==typeof r.tool?r.tool:"project tool",n=i.includes(r.approvalId)&&!A.has(r.approvalId);return(0,O.jsxs)("div",{className:"rounded-lg border border-amber-500/40 bg-amber-500/10 p-3 text-sm",children:[(0,O.jsxs)("div",{className:"font-medium",children:["Approve ",s.replaceAll("_"," "),"?"]}),(0,O.jsx)("pre",{className:"mt-2 overflow-x-auto whitespace-pre-wrap text-xs text-muted-foreground",children:JSON.stringify(r.input??{},null,2)}),n?(0,O.jsxs)("div",{className:"mt-3 flex gap-2",children:[(0,O.jsxs)(W.Button,{size:"sm","aria-label":`Approve ${s}`,disabled:D.has(r.approvalId),onClick:()=>void X(r.approvalId,!0),children:[(0,O.jsx)(rf.Check,{className:"size-3.5"}),"Approve"]}),(0,O.jsxs)(W.Button,{size:"sm",variant:"outline","aria-label":`Deny ${s}`,disabled:D.has(r.approvalId),onClick:()=>void X(r.approvalId,!1),children:[(0,O.jsx)(t7,{className:"size-3.5"}),"Deny"]})]}):(0,O.jsx)("div",{className:"mt-3 text-xs text-muted-foreground",children:"Approval expired or resolved"})]},e.id)}if("operation"===e.type){let s,n=K.byMessageId.get(e.id);if(!n)return(0,O.jsx)("div",{className:"rounded-md border bg-card px-3 py-2 text-sm text-muted-foreground",children:"Project operation unavailable"},e.id);if(K.latestMessageIdByOperation.get(n.operationId)!==e.id)return null;let i=(s=(e,s)=>r.some(r=>r.entity_type===e&&r.entity_id===s&&r.deleted),"task_create"===n.kind||"task_update"===n.kind?s("task",n.taskId):"agent_session_create"===n.kind||"agent_instruction"===n.kind?s("agent_session",n.sessionId):"schedule_run"===n.kind&&(s("schedule",n.scheduleId)||s("schedule_run",n.runId)))?{...n,failure:{code:"deleted_target",message:"The target no longer exists or is unavailable."}}:n,a=z.get(i.operationId),o=U.get(i.operationId);if("workspace_selection"===i.kind){let e=a?.startsWith("workspace:")?a.slice(10):null;return(0,O.jsxs)("div",{"data-operation-id":i.operationId,"data-operation-kind":i.kind,children:[(0,O.jsx)("p",{role:"status","aria-live":"polite","aria-atomic":"true",className:"sr-only",children:cJ(i)}),(0,O.jsx)(cG,{operation:i,pendingWorkspaceId:e,actionError:o,onSelect:({requestId:e,workspaceId:r})=>{V(i.operationId,"select_workspace",async()=>{H(e=>new Map(e).set(i.operationId,`workspace:${r}`)),await _(e,r)})}})]},`operation:${i.operationId}`)}return(0,O.jsxs)("div",{"data-operation-id":i.operationId,"data-operation-kind":i.kind,children:[(0,O.jsx)("p",{role:"status","aria-live":"polite","aria-atomic":"true",className:"sr-only",children:cJ(i)}),(0,O.jsx)(cV,{operation:i,pendingAction:a,actionError:o,onOpenSession:"agent_session_create"===i.kind&&y?e=>{V(e.operationId,"open_session",()=>y(e.sessionId,e.target??"local",e.branch??null))}:void 0,onViewOutput:"schedule_run"===i.kind&&b?e=>{V(e.operationId,"view_output",()=>b(e.runId,e.scheduleId))}:void 0,onRunAgain:"schedule_run"===i.kind&&w?e=>{V(e.operationId,"run_again",()=>w(e.runId))}:void 0})]},`operation:${i.operationId}`)}if("error"===e.type){let r=cX(e.content),s="string"==typeof r?.message?r.message:e.content;return(0,O.jsxs)("div",{role:"alert",className:"flex gap-2 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:[(0,O.jsx)(s6,{className:"mt-0.5 size-4 shrink-0"}),s]},e.id)}return(0,O.jsx)("div",{className:"rounded-md bg-muted/40 px-3 py-2 text-xs text-muted-foreground",children:e.content},e.id)}),u?(0,O.jsx)("div",{role:"alert",className:"rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:u}):null,M?(0,O.jsx)("div",{role:"alert",className:"rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:M}):null]})]}),(0,O.jsx)(cH,{"aria-label":"Jump to latest message"})]}),(0,O.jsx)("div",{className:"shrink-0 border-t bg-background p-3 sm:px-6",children:(0,O.jsxs)("form",{onSubmit:e=>void Y(e),className:"mx-auto max-w-3xl",children:["running"===s?(0,O.jsxs)("div",{className:"mb-2 flex items-center justify-between gap-3 text-xs text-muted-foreground",children:[(0,O.jsx)("span",{children:a>0?`${a} queued`:"Project Chat is working"}),(0,O.jsxs)(W.Button,{type:"button",variant:"outline",size:"sm","aria-label":"Stop generating",disabled:!n||null!==N,onClick:()=>void G(),children:[(0,O.jsx)(lJ,{className:"size-3"}),N?"Stopping…":"Stop generating"]})]}):null,"queued"===s?(0,O.jsxs)("div",{className:"mb-2 flex items-center gap-2 text-xs text-muted-foreground",role:"status",children:[(0,O.jsx)(lX.Clock,{className:"size-3.5"}),(0,O.jsx)("span",{children:"Waiting to start…"})]}):null,(0,O.jsxs)("div",{className:"relative",children:[(0,O.jsx)(rl,{"aria-label":"Message Project Chat",value:S,onChange:e=>{j(e.target.value),f?.(e.target.value)},onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),e.currentTarget.form?.requestSubmit())},placeholder:d?"Message Project Chat…":"Reconnecting to Project Chat…",disabled:!d||C,rows:2,className:"min-h-20 resize-none pr-16"}),(0,O.jsx)(W.Button,{type:"submit",size:"sm","aria-label":"Send message",disabled:!d||C||!S.trim(),className:"absolute bottom-2 right-2",children:"Send"})]})]})})]})}function cQ({projectId:e,threadId:r,projectName:s,onBack:n,onSelectThread:i,onOpenContext:a,onOpenAgentSession:o,onOpenScheduleRun:l,onRunScheduleAgain:c}){let d=function(e,r){let s=sf(e),[n,i]=(0,$.useState)([]),[a,o]=(0,$.useState)(!1),[l,c]=(0,$.useState)(!1),[d,u]=(0,$.useState)(!1),[h,f]=(0,$.useState)(ld),[p,m]=(0,$.useState)(!1),[g,x]=(0,$.useState)(null),[v,_]=(0,$.useState)(null),[y,b]=(0,$.useState)(null),w=(0,$.useRef)(ld()),S=(0,$.useRef)(e),j=(0,$.useRef)(r),C=(0,$.useRef)(0),k=(0,$.useRef)(0),N=(0,$.useRef)(null),E=(0,$.useRef)(!1),D=(0,$.useRef)(new Map),R=(0,$.useRef)(0),A=(0,$.useRef)(null),T=(0,$.useRef)(new Map);(0,$.useEffect)(()=>(E.current=!0,()=>{E.current=!1}),[]),(0,$.useEffect)(()=>{for(let[s,n]of(S.current=e,j.current=r,T.current))e&&n.identity.projectId===e||T.current.delete(s)},[e,r]);let M=(0,$.useCallback)(async(e,r,s)=>{N.current?.abort();let n=new AbortController;N.current=n;let a=++k.current;try{let o=await rv.api.listProjectChatThreads(e,s,{signal:n.signal});if(C.current!==r||S.current!==e||k.current!==a)return;i(o),x(null)}catch(s){if(n.signal.aborted||C.current!==r||S.current!==e||k.current!==a)return;x(s instanceof Error?s.message:"Failed to list Project Chat threads")}finally{N.current===n&&(N.current=null),C.current===r&&S.current===e&&k.current===a&&o(!1)}},[]);(0,$.useEffect)(()=>{C.current+=1,k.current+=1;let r=C.current;if(N.current?.abort(),N.current=null,!e){i([]),o(!1),x(null);return}return i([]),o(!0),x(null),M(e,r,!1),()=>{k.current+=1,N.current?.abort(),N.current=null}},[M,e]);let F=(0,$.useCallback)(async(e=!1)=>{let r=S.current;r&&await M(r,C.current,e)},[M]),P=(0,$.useCallback)((e,r)=>!!E.current&&S.current===e&&C.current===r&&(k.current+=1,N.current?.abort(),N.current=null,o(!1),!0),[]);(0,$.useEffect)(()=>{R.current+=1;let s=R.current,n=!1,i=!1,a=null,o=0,l=null,d=null,h=e=>{w.current=e,f(e)};if(A.current?.close(),A.current=null,m(!1),u(!1),_(null),b(null),!e||!r){h(ld()),c(!1);return}let p=T.current.get(r);p?.identity.projectId===e?(lu(T.current,p),h({thread:p.thread,messages:p.messages,hasEarlierMessages:p.hasEarlierMessages,earliestSequence:p.earliestSequence,status:p.status,activeTurnId:p.activeTurnId,pendingApprovalIds:p.pendingApprovalIds,queueLength:p.queueLength,contextRefs:p.contextRefs})):(T.current.delete(r),h(ld())),c(!0);let g=()=>!n&&!i&&R.current===s&&S.current===e&&j.current===r,x=()=>{null!==a&&clearTimeout(a),a=null},v=e=>g()&&d===e,y=e=>{null!==e.timeout&&clearTimeout(e.timeout),e.timeout=null,d===e&&(d=null)},C=e=>{y(e),e.controller.abort();let r=e.socket;e.socket=null,r&&A.current===r&&(A.current=null),r?.close()},k=e=>{i=!0,x(),d&&C(d),e&&A.current===e&&(A.current=null,e.close()),m(!1),c(!1),_("Thread not found"),b("thread_not_found")},N=(e=!1)=>{if(!g()||(e&&x(),null!==a))return;let r=e?0:Math.min(1e3*2**o,3e4);e||(o+=1),a=setTimeout(()=>{a=null,D(!0)},r)},E=(e,r)=>{g()&&A.current===e&&(d?.socket===e?C(d):(A.current=null,e.close()),m(!1),c(!1),r&&_(r),N())};async function D(s){if(!g()||d)return;let n={controller:new AbortController,timeout:null,socket:null};d=n,n.timeout=setTimeout(()=>{v(n)&&(C(n),m(!1),c(!1),_("Project Chat connection timed out"),N())},1e4);try{let[a,u]=await Promise.all([rv.api.getProjectChatThread(r,{signal:n.controller.signal}),(0,rv.getFreshToken)(s?{skipCache:!0}:void 0)]);if(!v(n))return;let{thread:f,contextRefs:p}=a;if(f.project_id!==e||f.id!==r){i=!0,C(n),_("Project Chat stream identity mismatch"),c(!1);return}if(!Array.isArray(p)||!p.every(lm)||p.some(e=>e.thread_id!==r))throw Error("Invalid Project Chat thread context");h({...w.current,thread:f,contextRefs:p});let x=new WebSocket((0,rv.getWebSocketUrl)(`/api/project-chat/threads/${r}/stream`,u));n.socket=x,A.current=x;let S=!1;l=null,x.onopen=()=>{g()&&A.current===x&&m(!0)},x.onmessage=s=>{if(g()&&A.current===x)try{let a=JSON.parse(s.data);if(!lf(a))throw Error("invalid frame");if("type"in a&&"project_chat_snapshot"===a.type){let s=a.snapshot;if(!function(e){if(!lf(e)||!lf(e.identity)||!lf(e.thread)||!Array.isArray(e.messages)||!Array.isArray(e.contextRefs))return!1;let r=e.thread.id,s=e.thread.project_id,n=e.thread.user_id;return"string"==typeof r&&"string"==typeof s&&"string"==typeof n&&"string"==typeof e.identity.projectId&&"string"==typeof e.identity.threadId&&"string"==typeof e.identity.userId&&e.identity.threadId===r&&e.identity.projectId===s&&e.identity.userId===n&&e.messages.every(e=>lp(e)&&e.thread_id===r)&&"boolean"==typeof e.hasEarlierMessages&&(null===e.earliestSequence||Number.isSafeInteger(e.earliestSequence))&&e.contextRefs.every(e=>lm(e)&&e.thread_id===r)&&lg(e.status)&&(null===e.activeTurnId||"string"==typeof e.activeTurnId)&&Array.isArray(e.pendingApprovalIds)&&e.pendingApprovalIds.every(e=>"string"==typeof e&&e.length>0)&&Number.isSafeInteger(e.queueLength)&&e.queueLength>=0}(s))throw Error("invalid snapshot");if(s.identity.threadId!==r||s.identity.projectId!==e||s.identity.userId!==f.user_id||s.thread.id!==r||s.thread.project_id!==e||s.thread.user_id!==f.user_id){i=!0,_("Project Chat stream identity mismatch"),c(!1),d===n?C(n):(A.current=null,x.close());return}S=!0,l=Date.now(),y(n),o=0,b(null),_(null),lu(T.current,s),h({thread:s.thread,messages:w.current.thread?.id===r&&null!==w.current.earliestSequence&&null!==s.earliestSequence&&w.current.earliestSequence<s.earliestSequence?lh(w.current.messages,s.messages):s.messages,hasEarlierMessages:w.current.thread?.id===r&&null!==w.current.earliestSequence&&null!==s.earliestSequence&&w.current.earliestSequence<s.earliestSequence?w.current.hasEarlierMessages:s.hasEarlierMessages,earliestSequence:w.current.thread?.id===r&&null!==w.current.earliestSequence&&null!==s.earliestSequence&&w.current.earliestSequence<s.earliestSequence?w.current.earliestSequence:s.earliestSequence,status:s.status,activeTurnId:s.activeTurnId,pendingApprovalIds:s.pendingApprovalIds,queueLength:s.queueLength,contextRefs:s.contextRefs}),c(!1)}else if("JsonPatch"in a){if(!S||!Array.isArray(a.JsonPatch))throw Error("invalid patch frame");let s=function(e,r){let s=e;for(let e of r){if(!lf(e)||"add"!==e.op&&"replace"!==e.op||"string"!=typeof e.path||!lf(e.value))return null;let r=/^\/messages\/(0|[1-9]\d*)$/.exec(e.path);if(r&&"ENTRY"===e.value.type&&lp(e.value.content)){let n=e.value.content,i=Number(r[1]);if(!Number.isSafeInteger(i)||null!==s.thread&&n.thread_id!==s.thread.id)return null;let a=[...s.messages];if("add"===e.op){if(i>a.length||a.some(e=>e.id===n.id))return null;a.push(n),a.sort((e,r)=>e.sequence-r.sequence)}else{let e=a.findIndex(e=>e.id===n.id);if(e<0)return null;a[e]=n}s={...s,messages:a,earliestSequence:a[0]?.sequence??null}}else if("/messages"===e.path&&"MESSAGES"===e.value.type&&Array.isArray(e.value.content)&&e.value.content.every(lp)&&"boolean"==typeof e.value.hasEarlierMessages&&(null===e.value.earliestSequence||Number.isSafeInteger(e.value.earliestSequence))&&e.value.content.every(e=>null===s.thread||e.thread_id===s.thread.id)){let r=null!==s.earliestSequence&&null!==e.value.earliestSequence&&s.earliestSequence<e.value.earliestSequence,n=r?lh(s.messages,e.value.content):e.value.content;s={...s,messages:n,earliestSequence:n[0]?.sequence??null,hasEarlierMessages:r?s.hasEarlierMessages:e.value.hasEarlierMessages}}else if("/status"===e.path&&"STATUS"===e.value.type&&lg(e.value.content))s={...s,status:e.value.content};else if("/activeTurnId"===e.path&&"ACTIVE_TURN"===e.value.type&&(null===e.value.content||"string"==typeof e.value.content))s={...s,activeTurnId:e.value.content};else if("/pendingApprovalIds"===e.path&&"APPROVALS"===e.value.type&&Array.isArray(e.value.content)&&e.value.content.every(e=>"string"==typeof e&&e.length>0))s={...s,pendingApprovalIds:[...new Set(e.value.content)].sort()};else if("/queueLength"===e.path&&"QUEUE"===e.value.type&&Number.isSafeInteger(e.value.content)&&e.value.content>=0)s={...s,queueLength:e.value.content};else{if(!("/contextRefs"===e.path&&"CONTEXT"===e.value.type&&Array.isArray(e.value.content)&&e.value.content.every(lm)&&e.value.content.every(e=>null===s.thread||e.thread_id===s.thread.id)))return null;s={...s,contextRefs:e.value.content}}}return s}(w.current,a.JsonPatch);if(!s)throw Error("invalid patch frame");l=Date.now(),s.thread&&lu(T.current,{identity:{projectId:e,threadId:r,userId:s.thread.user_id},thread:s.thread,messages:s.messages,hasEarlierMessages:s.hasEarlierMessages,earliestSequence:s.earliestSequence,status:s.status,activeTurnId:s.activeTurnId,pendingApprovalIds:s.pendingApprovalIds,queueLength:s.queueLength,contextRefs:s.contextRefs}),h(s)}else if("error"in a){if("Thread not found"===a.error)return void k(x);E(x,"string"==typeof a.error?a.error:"Project Chat stream failed")}else throw Error("unknown frame")}catch{E(x,"Invalid Project Chat stream message")}},x.onerror=()=>{E(x)},x.onclose=()=>{g()&&A.current===x&&(d?.socket===x&&C(d),A.current=null,m(!1),N())}}catch(e){if(!v(n))return;if(C(n),lf(e)&&(404===e.status||e instanceof Error&&"Thread not found"===e.message))return void k();c(!1),_(e instanceof Error?e.message:"Failed to open Project Chat thread"),N()}}let M=()=>{if(!g())return;x(),d&&C(d);let e=A.current;e&&(A.current=null,e.close()),m(!1),D(!0)},F=()=>M(),P=()=>{"visible"===document.visibilityState&&(d||null!==l&&Date.now()-l>4e4)&&M()};return window.addEventListener("online",F),document.addEventListener("visibilitychange",P),D(!1),()=>{n=!0,x(),d&&C(d),window.removeEventListener("online",F),document.removeEventListener("visibilitychange",P);let e=A.current;A.current=null,e?.close()}},[e,r]);let I=(0,$.useCallback)(async e=>{let r=S.current,n=C.current;if(!r)throw Error("No project selected");let a=await s(e);return a.project_id===r&&P(r,n)&&i(e=>[a,...e.filter(e=>e.id!==a.id)]),a},[s,P]),B=(0,$.useCallback)(e=>{if(i(r=>null===e.archived_at?[e,...r.filter(r=>r.id!==e.id)]:r.filter(r=>r.id!==e.id)),w.current.thread?.id===e.id){let r={...w.current,thread:e};w.current=r,f(r)}let r=T.current.get(e.id);r&&lu(T.current,{...r,thread:e})},[]),L=(0,$.useCallback)(async(e,r)=>{let s=S.current,n=C.current,i=r.trim();if(!i)throw Error("Title is required");let a=(D.current.get(e)??0)+1;D.current.set(e,a);let o=await rv.api.updateProjectChatThread(e,{title:i});return s&&o.project_id===s&&D.current.get(e)===a&&P(s,n)&&B(o),o},[P,B]),z=(0,$.useCallback)(async(e,r=!0)=>{let s=S.current,n=C.current,i=(D.current.get(e)??0)+1;D.current.set(e,i);let a=await rv.api.updateProjectChatThread(e,{archived:r});return s&&a.project_id===s&&D.current.get(e)===i&&P(s,n)&&B(a),a},[P,B]),O=(0,$.useCallback)(async e=>{let r=S.current,s=C.current,n=(D.current.get(e)??0)+1;if(D.current.set(e,n),await rv.api.deleteProjectChatThread(e),r&&D.current.get(e)===n&&P(r,s)&&(T.current.delete(e),i(r=>r.filter(r=>r.id!==e)),j.current===e)){R.current+=1,A.current?.close(),A.current=null,m(!1),c(!1);let e=ld();w.current=e,f(e)}},[P]),W=(0,$.useCallback)(async e=>{let r=j.current;if(!r)throw Error("No Project Chat thread selected");let s=e.trim();if(!s)throw Error("Message is required");await rv.api.sendProjectChatMessage(r,s)},[]),H=(0,$.useCallback)(async e=>{let r=j.current;return!!r&&rv.api.stopProjectChatTurn(r,e)},[]),U=(0,$.useCallback)(async(e,r)=>{let s=j.current;if(!s)throw Error("No Project Chat thread selected");await rv.api.approveProjectChatTool(s,e,r)},[]),q=(0,$.useCallback)(async(e,r)=>{let s=j.current;if(!s)throw Error("No Project Chat thread selected");await rv.api.selectProjectChatWorkspace(s,e,r)},[]),K=(0,$.useCallback)(async()=>{let e=j.current,r=w.current;if(e&&r.hasEarlierMessages&&null!==r.earliestSequence){u(!0);try{let s=await rv.api.listProjectChatMessages(e,{beforeSequence:r.earliestSequence});if(j.current!==e||w.current.thread?.id!==e)return;let n=lh(w.current.messages,s.messages),i={...w.current,messages:n,hasEarlierMessages:s.hasMore,earliestSequence:n[0]?.sequence??null};w.current=i,f(i),_(null)}catch(r){j.current===e&&_(r instanceof Error?r.message:"Failed to load earlier messages")}finally{j.current===e&&u(!1)}}},[]);return{...h,threads:n,loading:a||l,threadsLoading:a,threadLoading:l,loadingEarlierMessages:d,isConnected:p,error:v??g,terminalError:y,refetchThreads:F,createThread:I,renameThread:L,archiveThread:z,deleteThread:O,sendMessage:W,stopTurn:H,resolveToolApproval:U,selectWorkspace:q,loadEarlierMessages:K}}(e,r),[u,h]=(0,$.useState)(!0),[f,p]=(0,$.useState)(!1),[m,g]=(0,$.useState)(!1),[x,v]=(0,$.useState)(!1),[_,y]=(0,$.useState)(null),b=(0,$.useRef)(!1),w=(0,$.useRef)(new Map),S=(0,$.useRef)(null),j=(0,$.useRef)(0),C=sM(d.thread),k=d.threads.filter(e=>null===e.archived_at),N=`${e}:${r}`,E=function(){let[e,r]=$.useState(void 0);return $.useEffect(()=>{let e=window.matchMedia("(max-width: 767px)"),s=()=>{r(window.innerWidth<768)};return e.addEventListener("change",s),r(window.innerWidth<768),()=>e.removeEventListener("change",s)},[]),!!e}(),D=e=>{p(e),e||requestAnimationFrame(()=>S.current?.focus())};(0,$.useEffect)(()=>{j.current+=1,b.current=!1,v(!1),y(null),g(!1),p(!1)},[N]);let R=async()=>{if(b.current)return;let r=j.current;b.current=!0,v(!0),y(null);try{let s=await d.createThread();r===j.current&&s.project_id===e&&i(s.id)}catch(e){r===j.current&&y(e instanceof Error?e.message:"Failed to create thread")}finally{r===j.current&&(b.current=!1,v(!1))}},A=e=>{if(e!==r)return;let s=k.find(r=>r.id!==e);s?i(s.id):n()},T=async e=>{let r=j.current;await d.archiveThread(e,!0),r===j.current&&A(e)},M=async e=>{let r=j.current;await d.deleteThread(e),r===j.current&&A(e)};return(0,O.jsxs)("div",{className:"flex h-full min-h-0 flex-col bg-background",children:[(0,O.jsxs)("header",{className:"flex h-12 shrink-0 items-center justify-between gap-3 border-b px-3 sm:px-4",children:[(0,O.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,O.jsx)(W.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"Back to Overview",onClick:n,children:(0,O.jsx)(o9.ArrowLeft,{className:"size-4"})}),(0,O.jsx)(sD,{className:"size-4 shrink-0 text-primary","aria-hidden":"true"}),(0,O.jsxs)("div",{className:"min-w-0",children:[(0,O.jsxs)("div",{className:"truncate text-[11px] text-muted-foreground",children:[s," / Project Chat"]}),(0,O.jsxs)(a4,{open:m,onOpenChange:g,children:[(0,O.jsx)(a6,{asChild:!0,children:(0,O.jsxs)("button",{type:"button","aria-label":`Current thread: ${C}`,className:"flex max-w-[50vw] items-center gap-1 truncate text-sm font-semibold focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,O.jsx)("span",{className:"truncate",children:C}),(0,O.jsx)(ns,{className:"size-3.5 shrink-0"})]})}),(0,O.jsxs)(a7,{align:"start",className:"w-64",children:[k.slice(0,5).map(e=>{let r=sM(e);return(0,O.jsx)(a8,{asChild:!0,children:(0,O.jsx)("button",{type:"button","aria-label":`Switch to thread: ${r}`,onClick:()=>i(e.id),className:"w-full truncate text-left",children:r})},e.id)}),(0,O.jsx)(a8,{asChild:!0,children:(0,O.jsxs)("button",{type:"button",disabled:x,onClick:()=>void R(),className:"w-full border-t",children:[(0,O.jsx)(eS,{className:"size-3.5"}),"New thread"]})})]})]})]})]}),(0,O.jsx)(W.Button,{ref:S,type:"button",variant:"ghost",size:"icon-sm","aria-label":E?"Open threads and context":u?"Hide threads and context":"Show threads and context",onClick:()=>E?p(!0):h(e=>!e),children:E?(0,O.jsx)(lt,{className:"size-4"}):u?(0,O.jsx)(le,{className:"size-4"}):(0,O.jsx)(lt,{className:"size-4"})})]}),_?(0,O.jsx)("div",{role:"alert",className:"border-b border-destructive/40 bg-destructive/10 px-4 py-2 text-sm text-destructive",children:_}):null,(0,O.jsxs)("div",{className:"flex min-h-0 flex-1","data-testid":"project-chat-workbench-columns",children:[(0,O.jsx)("main",{"data-testid":"project-chat-main","data-project-chat-column":!0,className:"min-w-0 flex-1",children:"thread_not_found"===d.terminalError?(0,O.jsx)("div",{className:"flex h-full items-center justify-center p-6 text-center",children:(0,O.jsxs)("div",{children:[(0,O.jsx)("h2",{className:"font-semibold",children:"Thread not found"}),(0,O.jsx)(W.Button,{className:"mt-3",variant:"outline",onClick:n,children:"Back to Overview"})]})}):(0,O.jsx)(cZ,{messages:d.messages,contextRefs:d.contextRefs,status:d.status,activeTurnId:d.activeTurnId,pendingApprovalIds:d.pendingApprovalIds,queueLength:d.queueLength,loading:d.threadLoading,hasEarlierMessages:d.hasEarlierMessages,loadingEarlierMessages:d.loadingEarlierMessages,connected:d.isConnected,error:d.error,initialDraft:w.current.get(N)??"",onDraftChange:e=>{e?w.current.set(N,e):w.current.delete(N)},onDraftSent:e=>{w.current.get(N)===e&&w.current.delete(N)},onSend:d.sendMessage,onLoadEarlierMessages:d.loadEarlierMessages,onStop:d.stopTurn,onResolveApproval:d.resolveToolApproval,onSelectWorkspace:d.selectWorkspace,onOpenAgentSession:o,onOpenScheduleRun:l,onRunScheduleAgain:c},N)}),!E&&u?(0,O.jsx)(lG,{projectId:e,currentThreadId:r,threads:d.threads,contextRefs:d.contextRefs,onNewThread:R,onSelectThread:i,onRenameThread:async(e,r)=>{await d.renameThread(e,r)},onArchiveThread:T,onDeleteThread:M,onOpenContext:a,newThreadPending:x},N):null]}),E?(0,O.jsx)(ls,{open:f,onOpenChange:D,children:(0,O.jsxs)(la,{side:"right","data-testid":"project-chat-mobile-drawer",className:"w-[min(90vw,360px)] gap-0 p-0","aria-label":"Project Chat threads and context",onCloseAutoFocus:e=>{e.preventDefault(),S.current?.focus()},children:[(0,O.jsxs)(lo,{className:"shrink-0 border-b px-4 py-3 pr-14 text-left",children:[(0,O.jsx)(ll,{className:"text-sm",children:"Threads and context"}),(0,O.jsx)(lc,{className:"text-xs",children:"Switch conversations and open referenced project items."})]}),(0,O.jsx)(lG,{projectId:e,className:"min-h-0 w-full flex-1 border-l-0",currentThreadId:r,threads:d.threads,contextRefs:d.contextRefs,onNewThread:R,onSelectThread:e=>{D(!1),i(e)},onRenameThread:async(e,r)=>{await d.renameThread(e,r)},onArchiveThread:T,onDeleteThread:M,onOpenContext:a?e=>{D(!1),a(e)}:void 0,newThreadPending:x},N)]})}):null]})}function c0(e){return e?"target-not-found"===e.error?e.requestedTarget:e.target:null}function c1(e){let r=[],s=`vibedeckx:mergeTarget:${e}:`;try{for(let e=0;e<localStorage.length;e+=1){let n=localStorage.key(e);if(!n?.startsWith(s))continue;let i=localStorage.getItem(n);i&&r.push({key:n,branch:n.slice(s.length),target:i})}}catch{}return r}let c2=new Map,c5=new Set(["working","main-running"]);function c3(e,r){return`vibedeckx:schedule-rerun:v2:${encodeURIComponent(e)}:${encodeURIComponent(r)}`}function c4(e){try{window.sessionStorage.removeItem(e)}catch{}}var ck=cC;let c6=(0,ew.default)("columns-3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]),c7=(0,ew.default)("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),c8={sm:{box:"size-4 rounded",text:"text-[9.5px]",icon:"size-2.5",letters:1},md:{box:"size-5 rounded-[5px]",text:"text-[9px]",icon:"size-3",letters:2}};function c9({name:e,size:r="sm",className:s}){let n=c8[r],i=s_(e,n.letters);return(0,O.jsx)("span",{"aria-hidden":"true",className:(0,ey.cn)("grid shrink-0 place-items-center bg-primary/14 font-mono font-semibold leading-none tracking-[-0.02em] text-primary",n.box,n.text,s),children:i||(0,O.jsx)(oY,{className:(0,ey.cn)(n.icon,"text-primary")})})}let de=(0,ew.default)("check-check",[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]]);function dt({info:e,repositoryLabel:r,onClick:s}){let n=function(e,r){if("target-not-found"===e.error){let s=`Target branch '${e.requestedTarget}' not found — pick a new target or reset to default`;return r?`${s} \xb7 ${r}`:s}let s=["merged"===e.status?`Merged into ${e.target}`:"no-unique-commits"===e.status?`In sync with ${e.target}`:`${e.unmergedCount} commit${1!==e.unmergedCount?"s":""} not in ${e.target}`];return e.dirty&&s.push("uncommitted changes"),r&&s.push(r),s.join(" · ")}(e,r);return(0,O.jsxs)(cw,{children:[(0,O.jsx)(cS,{asChild:!0,children:(0,O.jsxs)("button",{onClick:e=>{e.stopPropagation(),s()},"aria-label":n,className:"relative shrink-0 flex items-center justify-center h-4 min-w-4 px-0.5 rounded hover:bg-muted",children:["target-not-found"===e.error?(0,O.jsx)(s6,{className:"h-3 w-3 text-amber-500"}):"merged"===e.status?(0,O.jsx)(rf.Check,{className:"h-3 w-3 text-muted-foreground/70"}):"no-unique-commits"===e.status?(0,O.jsx)(de,{className:"h-3 w-3 text-emerald-500"}):(0,O.jsx)("span",{className:"text-[10px] font-mono leading-none text-amber-500",children:e.unmergedCount}),!e.error&&e.dirty&&(0,O.jsx)("span",{className:"absolute -top-0.5 -right-0.5 h-1.5 w-1.5 rounded-full bg-orange-400"})]})}),(0,O.jsx)(cj,{side:"right",children:n})]})}let dr=(0,ew.default)("git-merge",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]]);function ds({projectId:e,branch:r,currentTarget:s,onTargetChange:n,onTargetReset:i,onDelete:a}){let[o,l]=(0,$.useState)(null),c=async()=>{null!==o||l((await rv.api.getProjectBranches(e)).filter(e=>e!==r))};return(0,O.jsxs)(a4,{children:[(0,O.jsx)(a6,{asChild:!0,children:(0,O.jsx)("button",{onClick:e=>e.stopPropagation(),className:"shrink-0 p-0.5 rounded opacity-0 group-hover:opacity-100 data-[state=open]:opacity-100 hover:bg-muted transition-all",title:"Workspace menu",children:(0,O.jsx)(lx,{className:"h-3 w-3"})})}),(0,O.jsxs)(a7,{side:"right",align:"start",children:[(0,O.jsxs)(on,{children:[(0,O.jsxs)(oi,{onPointerEnter:c,onFocus:c,children:[(0,O.jsx)(dr,{className:"h-3.5 w-3.5 mr-1.5"}),"Compare against"]}),(0,O.jsxs)(oa,{children:[null===o?(0,O.jsx)(a8,{disabled:!0,children:"Loading…"}):0===o.length?(0,O.jsx)(a8,{disabled:!0,children:"No other branches"}):o.map(e=>(0,O.jsx)(a9,{checked:e===s,onCheckedChange:()=>n(e),children:(0,O.jsx)("span",{className:"font-mono text-xs",children:e})},e)),(0,O.jsx)(os,{}),(0,O.jsx)(a8,{onClick:i,children:(0,O.jsx)("span",{className:"text-xs",children:"Default branch (auto)"})})]})]}),(0,O.jsxs)(a8,{onClick:a,className:"text-destructive focus:text-destructive",children:[(0,O.jsx)(rc,{className:"h-3.5 w-3.5 mr-1.5"}),"Delete worktree"]})]})]})}function dn({status:e}){let r="relative h-[7px] w-[7px] rounded-full shrink-0";return e&&"idle"!==e?"working"===e?(0,O.jsx)("span",{className:(0,ey.cn)(r,"bg-blue-500"),children:(0,O.jsx)("span",{className:"absolute inset-[-2px] rounded-full bg-blue-500",style:{animation:"status-dot-pulse 1.6s ease-out infinite",opacity:.5}})}):"main-running"===e?(0,O.jsx)("span",{className:(0,ey.cn)(r,"bg-violet-500"),children:(0,O.jsx)("span",{className:"absolute inset-[-2px] rounded-full bg-violet-500",style:{animation:"status-dot-pulse 1.6s ease-out infinite",opacity:.5}})}):"main-completed"===e?(0,O.jsx)("span",{className:(0,ey.cn)(r,"bg-emerald-500")}):"stopped"===e?(0,O.jsx)("span",{className:(0,ey.cn)(r,"bg-amber-500")}):(0,O.jsx)("span",{className:(0,ey.cn)(r,"bg-lime-400")}):(0,O.jsx)("span",{className:(0,ey.cn)(r,"bg-muted-foreground/40")})}function di({status:e}){let r="relative h-[7px] w-[7px] rounded-full shrink-0";return"running"===e?(0,O.jsx)("span",{className:(0,ey.cn)(r,"bg-blue-500"),children:(0,O.jsx)("span",{className:"absolute inset-[-2px] rounded-full bg-blue-500",style:{animation:"status-dot-pulse 1.6s ease-out infinite",opacity:.5}})}):"error"===e?(0,O.jsx)("span",{className:(0,ey.cn)(r,"bg-red-500")}):(0,O.jsx)("span",{className:(0,ey.cn)(r,"bg-lime-400")})}function da({schedule:e}){let r="relative h-[7px] w-[7px] rounded-full shrink-0";if(e.running)return(0,O.jsx)("span",{className:(0,ey.cn)(r,"bg-blue-500"),children:(0,O.jsx)("span",{className:"absolute inset-[-2px] rounded-full bg-blue-500",style:{animation:"status-dot-pulse 1.6s ease-out infinite",opacity:.5}})});let s=e.last_run;return s&&"skipped"!==s.status?"completed"===s.status?(0,O.jsx)("span",{className:(0,ey.cn)(r,"bg-emerald-500")}):"failed"===s.status||"timeout"===s.status||"killed"===s.status?(0,O.jsx)("span",{className:(0,ey.cn)(r,"bg-red-500")}):(0,O.jsx)("span",{className:(0,ey.cn)(r,"bg-blue-500")}):(0,O.jsx)("span",{className:(0,ey.cn)(r,"bg-muted-foreground/40")})}function dl({children:e,className:r}){return(0,O.jsx)("div",{className:(0,ey.cn)("px-2 pt-2.5 pb-1.5 border-t border-border/50 first:border-t-0",r),children:e})}function dc({children:e,action:r}){return(0,O.jsxs)("div",{className:"flex items-center justify-between px-2 py-1 text-[10px] font-semibold uppercase tracking-[0.06em] text-muted-foreground/80",children:[(0,O.jsx)("span",{children:e}),r]})}function dd({icon:e,label:r,active:s,disabled:n,onClick:i}){return(0,O.jsxs)("button",{onClick:i,disabled:n,className:(0,ey.cn)("relative w-full flex items-center gap-[9px] rounded-md px-2 py-[5px] text-[12.5px] font-normal transition-colors",n&&"text-muted-foreground/40 cursor-not-allowed",!n&&!s&&"text-foreground/75 hover:bg-muted hover:text-foreground",s&&"bg-card text-foreground font-medium shadow-sm"),children:[s&&(0,O.jsx)("span",{className:"absolute -left-2 top-1.5 bottom-1.5 w-[2px] rounded-full bg-primary"}),(0,O.jsx)("span",{className:(0,ey.cn)("shrink-0 flex items-center justify-center",s?"text-foreground":"text-muted-foreground"),children:e}),(0,O.jsx)("span",{className:"truncate text-left",children:r})]})}function du({activeView:e,onViewChange:r,worktrees:s,selectedBranch:n,onBranchChange:i,currentProject:a,onCreateWorktreeOpen:o,onDeleteWorktree:l,mergeStatuses:c,mergeDefaultTarget:d,mergeRepositoryLabel:u,onMergeTargetChange:h,onMergeBadgeClick:f,workspaceStatuses:p,residentSessions:m,selectedSessionId:g,onResidentSessionSelect:x,hasProject:v=!0,projects:_,onSelectProject:y,onCreateProjectOpen:b,schedules:w,selectedScheduleId:S,onScheduleSelect:j,onCreateScheduleOpen:C}){let k=(0,$.useRef)(null);return(0,$.useEffect)(()=>{k.current?.scrollIntoView({block:"nearest"})},[a?.id,_]),(0,O.jsxs)("nav",{className:"w-[220px] border-r border-border bg-sidebar flex flex-col overflow-hidden",children:[(0,O.jsxs)(dl,{children:[(0,O.jsx)(dc,{action:(0,O.jsx)("button",{onClick:b,className:"p-0.5 rounded hover:bg-muted hover:text-foreground transition-colors text-muted-foreground",title:"Create new project",children:(0,O.jsx)(eS,{className:"h-3 w-3"})}),children:"Projects"}),_&&_.length>0?(0,O.jsx)(cb,{delayDuration:300,children:(0,O.jsx)("div",{className:"flex flex-col gap-0.5 max-h-40 overflow-y-auto mt-0.5",children:_.map(s=>{let n=a?.id===s.id,i=n&&("project-info"===e||"project-chat"===e);return(0,O.jsxs)(cw,{children:[(0,O.jsx)(cS,{asChild:!0,children:(0,O.jsxs)("button",{ref:n?k:void 0,onClick:()=>{y?.(s),r("project-info")},className:(0,ey.cn)("relative w-full flex items-center gap-1.5 rounded-md px-2 py-[5px] text-[12.5px] transition-colors min-w-0","hover:bg-muted hover:text-foreground",n?"text-foreground font-medium":"text-foreground/75"),children:[i&&(0,O.jsx)("span",{className:"absolute -left-2 top-1.5 bottom-1.5 w-[2px] rounded-full bg-primary"}),(0,O.jsx)(c9,{name:s.name}),(0,O.jsx)("span",{className:"truncate flex-1 text-left",children:s.name}),n&&(0,O.jsx)(r_,{className:"h-3 w-3 shrink-0 text-muted-foreground ml-auto"})]})}),(0,O.jsx)(cj,{side:"right",children:s.name})]},s.id)})})}):(0,O.jsx)("span",{className:"block px-2 mt-1 text-[11.5px] text-muted-foreground/60",children:"No projects yet"})]}),(0,O.jsxs)(dl,{children:[(0,O.jsx)(dc,{children:"Navigation"}),(0,O.jsx)("div",{className:"flex flex-col gap-0.5 mt-0.5",children:(0,O.jsx)(dd,{icon:(0,O.jsx)(sQ,{className:"h-3.5 w-3.5"}),label:"Tasks",active:"tasks"===e&&v,disabled:!v,onClick:()=>{v&&(i?.(null),r("tasks"))}})})]}),(0,O.jsxs)(dl,{children:[(0,O.jsx)(dc,{action:a?(0,O.jsx)("button",{onClick:C,className:"p-0.5 rounded hover:bg-muted hover:text-foreground transition-colors text-muted-foreground",title:"Create scheduled task",children:(0,O.jsx)(eS,{className:"h-3 w-3"})}):void 0,children:"Schedule"}),a&&w&&w.length>0&&(0,O.jsx)("div",{className:"flex flex-col gap-px",children:w.map(r=>{let s="schedules"===e&&S===r.id;return(0,O.jsxs)("button",{onClick:()=>j?.(r.id),className:(0,ey.cn)("w-full min-w-0 flex items-center gap-2 rounded-[5px] px-2 py-1 text-[11.5px] transition-colors overflow-hidden",!s&&"text-foreground/80 hover:bg-muted",s&&"bg-accent text-accent-foreground font-medium",!r.enabled&&"opacity-50"),children:[(0,O.jsx)(da,{schedule:r}),(0,O.jsx)("span",{className:"truncate text-left flex-1",children:r.name}),"local"!==r.target&&(0,O.jsx)(ry,{className:"h-2.5 w-2.5 shrink-0 text-violet-500","aria-label":"remote"})]},r.id)})}),a&&w&&0===w.length&&(0,O.jsx)("span",{className:"block px-2 mt-1 text-[11.5px] text-muted-foreground/60",children:"No scheduled tasks"})]}),(0,O.jsxs)(dl,{className:"flex-1 overflow-y-auto",children:[(0,O.jsx)(dc,{action:a?(0,O.jsx)("button",{onClick:o,className:"p-0.5 rounded hover:bg-muted hover:text-foreground transition-colors text-muted-foreground",title:"Create new worktree",children:(0,O.jsx)(eS,{className:"h-3 w-3"})}):void 0,children:"Workspace"}),a&&s&&s.length>0&&(0,O.jsx)(O.Fragment,{children:(0,O.jsx)(cb,{delayDuration:300,children:(0,O.jsx)("div",{className:"flex flex-col gap-px",children:s.map(s=>{var o;let v="workspace"===e&&n===s.branch,_=null===s.branch?"":s.branch,y=m?.get(_)??[],b=(o=p?.get(_),y.length>0&&"main-running"!==o&&"main-completed"!==o?"idle":o);return(0,O.jsxs)("div",{className:(0,ey.cn)("min-w-0 rounded-[3px]",v&&"bg-accent"),children:[(0,O.jsxs)("div",{className:"group relative flex items-center min-w-0 gap-0.5 pr-1",children:[(0,O.jsxs)(cw,{children:[(0,O.jsx)(cS,{asChild:!0,children:(0,O.jsxs)("button",{onClick:()=>{i?.(s.branch),r("workspace")},className:(0,ey.cn)("flex-1 min-w-0 flex items-center gap-2 rounded-[3px] pl-2 pr-1 py-1 font-mono text-[11.5px] transition-colors overflow-hidden",!v&&"text-foreground/80 hover:bg-muted",v&&"text-accent-foreground font-medium"),children:[(0,O.jsx)(dn,{status:b}),(0,O.jsx)("span",{className:"truncate text-left",children:s.branch??"main"})]})}),(0,O.jsx)(cj,{side:"right",children:s.branch??"main"})]}),null!==s.branch&&c?.get(s.branch)&&(0,O.jsx)(dt,{info:c.get(s.branch),repositoryLabel:u,onClick:()=>f?.(s.branch)}),null!==s.branch&&a&&(0,O.jsx)(ds,{projectId:a.id,branch:s.branch,currentTarget:c0(c?.get(s.branch))??d??null,onTargetChange:e=>h?.(s.branch,e),onTargetReset:()=>h?.(s.branch,null),onDelete:()=>l?.(s)})]}),y.length>0&&(0,O.jsx)("div",{className:"ml-4 mt-px flex flex-col gap-px",children:y.map(r=>{let s="workspace"===e&&g===r.id;return(0,O.jsxs)(cw,{children:[(0,O.jsx)(cS,{asChild:!0,children:(0,O.jsxs)("button",{onClick:()=>x?.(r),className:(0,ey.cn)("min-w-0 flex items-center gap-1.5 rounded-[3px] py-0.5 pl-1.5 pr-2 font-mono text-[11px] transition-colors",!s&&"text-foreground/70 hover:text-foreground",s&&"text-accent-foreground font-medium"),children:[(0,O.jsx)("span",{className:"shrink-0 text-muted-foreground/70",children:"└"}),(0,O.jsx)(di,{status:r.status}),(0,O.jsx)("span",{className:"truncate text-left",children:r.title})]})}),(0,O.jsx)(cj,{side:"right",children:r.title})]},r.id)})})]},s.branch??"__main__")})})})}),(!s||0===s.length)&&(0,O.jsx)("div",{className:"mt-0.5",children:(0,O.jsx)(dd,{icon:(0,O.jsx)(c6,{className:"h-3.5 w-3.5"}),label:"Workspace",active:"workspace"===e,onClick:()=>r("workspace")})})]}),(0,O.jsx)(dl,{children:(0,O.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,O.jsx)(dd,{icon:(0,O.jsx)(ry,{className:"h-3.5 w-3.5"}),label:"Remote Servers",active:"remote-servers"===e,onClick:()=>r("remote-servers")}),(0,O.jsx)(dd,{icon:(0,O.jsx)(c7,{className:"h-3.5 w-3.5"}),label:"Settings",active:"settings"===e,onClick:()=>r("settings")})]})})]})}function dh({title:e,count:r,description:s,actions:n,className:i}){return(0,O.jsxs)("div",{className:(0,ey.cn)("flex items-center justify-between gap-4 px-5 pt-[14px] pb-3 border-b border-border bg-background flex-shrink-0",i),children:[(0,O.jsxs)("div",{className:"min-w-0",children:[(0,O.jsxs)("h1",{className:"flex items-baseline gap-2.5 m-0 text-[17px] font-semibold tracking-[-0.018em] text-foreground",children:[(0,O.jsx)("span",{className:"truncate",children:e}),void 0!==r&&(0,O.jsx)("span",{className:"font-mono text-[11.5px] font-medium text-muted-foreground/80 tracking-normal",children:r})]}),s&&(0,O.jsx)("p",{className:"text-[11.5px] text-muted-foreground mt-0.5",children:s})]}),n&&(0,O.jsx)("div",{className:"flex items-center gap-2",children:n})]})}function df({children:e,className:r}){return(0,O.jsx)("div",{className:(0,ey.cn)("flex items-center gap-1.5 px-5 py-2 border-b border-border bg-background flex-shrink-0 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",r),children:e})}function dp({active:e,count:r,onClick:s,children:n}){return(0,O.jsxs)("button",{onClick:s,className:(0,ey.cn)("inline-flex items-center gap-1.5 px-2.5 py-[3px] rounded-full text-[11.5px] font-normal transition-colors whitespace-nowrap flex-shrink-0 border",e?"bg-card text-foreground font-medium border-border shadow-sm":"bg-transparent text-muted-foreground border-transparent hover:bg-muted hover:text-foreground"),children:[n,void 0!==r&&(0,O.jsx)("span",{className:(0,ey.cn)("font-mono text-[10.5px] pl-0.5",e?"text-muted-foreground":"text-muted-foreground/70"),children:r})]})}let dm=(0,ew.default)("grip-vertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]),dg=(0,$.createContext)(null);dg.displayName="PanelGroupContext";let dx="data-panel-group-direction",dv="data-panel-group-id",d_="data-resize-handle",dy="data-panel-resize-handle-id",db=$.useLayoutEffect,dw=$["useId".toString()],dS="function"==typeof dw?dw:()=>null,dj=0;function dC(e=null){let r=dS(),s=(0,$.useRef)(e||r||null);return null===s.current&&(s.current=""+dj++),null!=e?e:s.current}function dk({children:e,className:r="",collapsedSize:s,collapsible:n,defaultSize:i,forwardedRef:a,id:o,maxSize:l,minSize:c,onCollapse:d,onExpand:u,onResize:h,order:f,style:p,tagName:m="div",...g}){let x=(0,$.useContext)(dg);if(null===x)throw Error("Panel components must be rendered within a PanelGroup container");let{collapsePanel:v,expandPanel:_,getPanelSize:y,getPanelStyle:b,groupId:w,isPanelCollapsed:S,reevaluatePanelConstraints:j,registerPanel:C,resizePanel:k,unregisterPanel:N}=x,E=dC(o),D=(0,$.useRef)({callbacks:{onCollapse:d,onExpand:u,onResize:h},constraints:{collapsedSize:s,collapsible:n,defaultSize:i,maxSize:l,minSize:c},id:E,idIsFromProps:void 0!==o,order:f});(0,$.useRef)({didLogMissingDefaultSizeWarning:!1}),db(()=>{let{callbacks:e,constraints:r}=D.current,a={...r};D.current.id=E,D.current.idIsFromProps=void 0!==o,D.current.order=f,e.onCollapse=d,e.onExpand=u,e.onResize=h,r.collapsedSize=s,r.collapsible=n,r.defaultSize=i,r.maxSize=l,r.minSize=c,(a.collapsedSize!==r.collapsedSize||a.collapsible!==r.collapsible||a.maxSize!==r.maxSize||a.minSize!==r.minSize)&&j(D.current,a)}),db(()=>{let e=D.current;return C(e),()=>{N(e)}},[f,E,C,N]),(0,$.useImperativeHandle)(a,()=>({collapse:()=>{v(D.current)},expand:e=>{_(D.current,e)},getId:()=>E,getSize:()=>y(D.current),isCollapsed:()=>S(D.current),isExpanded:()=>!S(D.current),resize:e=>{k(D.current,e)}}),[v,_,y,S,E,k]);let R=b(D.current,i);return(0,$.createElement)(m,{...g,children:e,className:r,id:E,style:{...R,...p},[dv]:w,"data-panel":"","data-panel-collapsible":n||void 0,"data-panel-id":E,"data-panel-size":parseFloat(""+R.flexGrow).toFixed(1)})}let dN=(0,$.forwardRef)((e,r)=>(0,$.createElement)(dk,{...e,forwardedRef:r}));dk.displayName="Panel",dN.displayName="forwardRef(Panel)";let dE=null,dD=-1,dR=null;function dA(e,s){var n,i,a;let o=function(e,r){if(r){let e=(r&d$)!=0,s=(r&dW)!=0,n=(r&dH)!=0,i=(r&dU)!=0;if(e)if(n)return"se-resize";else if(i)return"ne-resize";else return"e-resize";if(s)if(n)return"sw-resize";else if(i)return"nw-resize";else return"w-resize";if(n)return"s-resize";else if(i)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}(e,s);dE!==o&&(dE=o,null===dR&&(dR=document.createElement("style"),r&&dR.setAttribute("nonce",r),document.head.appendChild(dR)),dD>=0&&(null==(a=dR.sheet)||a.removeRule(dD)),dD=null!=(n=null==(i=dR.sheet)?void 0:i.insertRule(`*{cursor: ${o} !important;}`))?n:-1)}function dT(e){return"keydown"===e.type}function dM(e){return e.type.startsWith("pointer")}function dF(e){return e.type.startsWith("mouse")}function dP(e){if(dM(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(dF(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}let dI=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function dB(e){let r=e.length;for(;r--;){let s=e[r];if(d6(s,"Missing node"),function(e){var r;let s,n=getComputedStyle(e);return"fixed"===n.position||!!("auto"!==n.zIndex&&("static"!==n.position||"flex"===(s=getComputedStyle(null!=(r=dO(e))?r:e).display)||"inline-flex"===s)||1>+n.opacity||"transform"in n&&"none"!==n.transform||"webkitTransform"in n&&"none"!==n.webkitTransform||"mixBlendMode"in n&&"normal"!==n.mixBlendMode||"filter"in n&&"none"!==n.filter||"webkitFilter"in n&&"none"!==n.webkitFilter||"isolation"in n&&"isolate"===n.isolation||dI.test(n.willChange))||"touch"===n.webkitOverflowScrolling}(s))return s}return null}function dL(e){return e&&Number(getComputedStyle(e).zIndex)||0}function dz(e){let r=[];for(;e;)r.push(e),e=dO(e);return r}function dO(e){let{parentNode:r}=e;return r&&r instanceof ShadowRoot?r.host:r}let d$=1,dW=2,dH=4,dU=8,dq="coarse"===function(){if("function"==typeof matchMedia)return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}(),dK=[],dV=!1,dY=new Map,dG=new Map,dX=new Set;function dJ(e){let{target:r}=e,{x:s,y:n}=dP(e);dV=!0,d1({target:r,x:s,y:n}),d3(),dK.length>0&&(d4("down",e),e.preventDefault(),d0(r)||e.stopImmediatePropagation())}function dZ(e){let{x:r,y:s}=dP(e);if(dV&&0===e.buttons&&(dV=!1,d4("up",e)),!dV){let{target:n}=e;d1({target:n,x:r,y:s})}d4("move",e),d2(),dK.length>0&&e.preventDefault()}function dQ(e){let{target:r}=e,{x:s,y:n}=dP(e);dG.clear(),dV=!1,dK.length>0&&(e.preventDefault(),d0(r)||e.stopImmediatePropagation()),d4("up",e),d1({target:r,x:s,y:n}),d2(),d3()}function d0(e){let r=e;for(;r;){if(r.hasAttribute(d_))return!0;r=r.parentElement}return!1}function d1({target:e,x:r,y:s}){dK.splice(0);let n=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(n=e),dX.forEach(e=>{let{element:i,hitAreaMargins:a}=e,o=i.getBoundingClientRect(),{bottom:l,left:c,right:d,top:u}=o,h=dq?a.coarse:a.fine;if(r>=c-h&&r<=d+h&&s>=u-h&&s<=l+h){if(null!==n&&document.contains(n)&&i!==n&&!i.contains(n)&&!n.contains(i)&&function(e,r){let s;if(e===r)throw Error("Cannot compare node with itself");let n={a:dz(e),b:dz(r)};for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),r=n.b.pop(),s=e;d6(s,"Stacking order can only be calculated for elements with a common ancestor");let i={a:dL(dB(n.a)),b:dL(dB(n.b))};if(i.a===i.b){let e=s.childNodes,r={a:n.a.at(-1),b:n.b.at(-1)},i=e.length;for(;i--;){let s=e[i];if(s===r.a)return 1;if(s===r.b)return -1}}return Math.sign(i.a-i.b)}(n,i)>0){let e=n,r=!1;for(;e;){var f;if(e.contains(i))break;if(f=e.getBoundingClientRect(),f.x<o.x+o.width&&f.x+f.width>o.x&&f.y<o.y+o.height&&f.y+f.height>o.y){r=!0;break}e=e.parentElement}if(r)return}dK.push(e)}})}function d2(){let e=!1,r=!1;dK.forEach(s=>{let{direction:n}=s;"horizontal"===n?e=!0:r=!0});let s=0;dG.forEach(e=>{s|=e}),e&&r?dA("intersection",s):e?dA("horizontal",s):r?dA("vertical",s):null!==dR&&(document.head.removeChild(dR),dE=null,dR=null,dD=-1)}let d5=new AbortController;function d3(){d5.abort();let e={capture:!0,signal:(d5=new AbortController).signal};dX.size&&(dV?(dK.length>0&&dY.forEach((r,s)=>{let{body:n}=s;r>0&&(n.addEventListener("contextmenu",dQ,e),n.addEventListener("pointerleave",dZ,e),n.addEventListener("pointermove",dZ,e))}),window.addEventListener("pointerup",dQ,e),window.addEventListener("pointercancel",dQ,e)):dY.forEach((r,s)=>{let{body:n}=s;r>0&&(n.addEventListener("pointerdown",dJ,e),n.addEventListener("pointermove",dZ,e))}))}function d4(e,r){dX.forEach(s=>{let{setResizeHandlerState:n}=s;n(e,dK.includes(s),r)})}function d6(e,r){if(!e)throw console.error(r),Error(r)}function d7(e,r,s=10){return e.toFixed(s)===r.toFixed(s)?0:e>r?1:-1}function d8(e,r,s=10){return 0===d7(e,r,s)}function d9(e,r,s){return 0===d7(e,r,s)}function ue({panelConstraints:e,panelIndex:r,size:s}){let n=e[r];d6(null!=n,`Panel constraints not found for index ${r}`);let{collapsedSize:i=0,collapsible:a,maxSize:o=100,minSize:l=0}=n;return 0>d7(s,l)&&(s=a&&0>d7(s,(i+l)/2)?i:l),s=parseFloat((s=Math.min(o,s)).toFixed(10))}function ut({delta:e,initialLayout:r,panelConstraints:s,pivotIndices:n,prevLayout:i,trigger:a}){if(d9(e,0))return r;let o=[...r],[l,c]=n;d6(null!=l,"Invalid first pivot index"),d6(null!=c,"Invalid second pivot index");let d=0;if("keyboard"===a){{let n=e<0?c:l,i=s[n];d6(i,`Panel constraints not found for index ${n}`);let{collapsedSize:a=0,collapsible:o,minSize:d=0}=i;if(o){let s=r[n];if(d6(null!=s,`Previous layout not found for panel index ${n}`),d9(s,a)){let r=d-s;d7(r,Math.abs(e))>0&&(e=e<0?0-r:r)}}}{let n=e<0?l:c,i=s[n];d6(i,`No panel constraints found for index ${n}`);let{collapsedSize:a=0,collapsible:o,minSize:d=0}=i;if(o){let s=r[n];if(d6(null!=s,`Previous layout not found for panel index ${n}`),d9(s,d)){let r=s-a;d7(r,Math.abs(e))>0&&(e=e<0?0-r:r)}}}}{let n=e<0?1:-1,i=e<0?c:l,a=0;for(;;){let e=r[i];if(d6(null!=e,`Previous layout not found for panel index ${i}`),a+=ue({panelConstraints:s,panelIndex:i,size:100})-e,(i+=n)<0||i>=s.length)break}let o=Math.min(Math.abs(e),Math.abs(a));e=e<0?0-o:o}{let n=e<0?l:c;for(;n>=0&&n<s.length;){let i=Math.abs(e)-Math.abs(d),a=r[n];d6(null!=a,`Previous layout not found for panel index ${n}`);let l=ue({panelConstraints:s,panelIndex:n,size:a-i});if(!d9(a,l)&&(d+=a-l,o[n]=l,d.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?n--:n++}}if(function(e,r,s){if(e.length!==r.length)return!1;for(let s=0;s<e.length;s++)if(!d9(e[s],r[s],void 0))return!1;return!0}(i,o))return i;{let n=e<0?c:l,i=r[n];d6(null!=i,`Previous layout not found for panel index ${n}`);let a=i+d,u=ue({panelConstraints:s,panelIndex:n,size:a});if(o[n]=u,!d9(u,a)){let r=a-u,n=e<0?c:l;for(;n>=0&&n<s.length;){let i=o[n];d6(null!=i,`Previous layout not found for panel index ${n}`);let a=ue({panelConstraints:s,panelIndex:n,size:i+r});if(d9(i,a)||(r-=a-i,o[n]=a),d9(r,0))break;e>0?n--:n++}}}return d9(o.reduce((e,r)=>r+e,0),100)?o:i}function ur(e,r=document){return Array.from(r.querySelectorAll(`[${dy}][data-panel-group-id="${e}"]`))}function us(e,r,s=document){let n=ur(e,s).findIndex(e=>e.getAttribute(dy)===r);return null!=n?n:null}function un(e,r,s){let n=us(e,r,s);return null!=n?[n,n+1]:[-1,-1]}function ui(e,r=document){var s;if(r instanceof HTMLElement&&(null==r||null==(s=r.dataset)?void 0:s.panelGroupId)==e)return r;let n=r.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function ua(e,r=document){let s=r.querySelector(`[${dy}="${e}"]`);return s||null}function uo(e,r){if(e.length!==r.length)return!1;for(let s=0;s<e.length;s++)if(e[s]!==r[s])return!1;return!0}function ul(e,r){let{x:s,y:n}=dP(r);return"horizontal"===e?s:n}function uc(e,r,s){r.forEach((r,n)=>{let i=e[n];d6(i,`Panel data not found for index ${n}`);let{callbacks:a,constraints:o,id:l}=i,{collapsedSize:c=0,collapsible:d}=o,u=s[l];if(null==u||r!==u){s[l]=r;let{onCollapse:e,onExpand:n,onResize:i}=a;i&&i(r,u),d&&(e||n)&&(n&&(null==u||d8(u,c))&&!d8(r,c)&&n(),e&&(null==u||!d8(u,c))&&d8(r,c)&&e())}})}function ud(e,r){if(e.length!==r.length)return!1;for(let s=0;s<e.length;s++)if(e[s]!=r[s])return!1;return!0}function uu(e){try{if("undefined"!=typeof localStorage)e.getItem=e=>localStorage.getItem(e),e.setItem=(e,r)=>{localStorage.setItem(e,r)};else throw Error("localStorage not supported in this environment")}catch(r){console.error(r),e.getItem=()=>null,e.setItem=()=>{}}}function uh(e){return`react-resizable-panels:${e}`}function uf(e){return e.map(e=>{let{constraints:r,id:s,idIsFromProps:n,order:i}=e;return n?s:i?`${i}:${JSON.stringify(r)}`:JSON.stringify(r)}).sort((e,r)=>e.localeCompare(r)).join(",")}function up(e,r){try{let s=uh(e),n=r.getItem(s);if(n){let e=JSON.parse(n);if("object"==typeof e&&null!=e)return e}}catch(e){}return null}function um(e,r,s,n,i){var a;let o=uh(e),l=uf(r),c=null!=(a=up(e,i))?a:{};c[l]={expandToSizes:Object.fromEntries(s.entries()),layout:n};try{i.setItem(o,JSON.stringify(c))}catch(e){console.error(e)}}function ug({layout:e,panelConstraints:r}){let s=[...e],n=s.reduce((e,r)=>e+r,0);if(s.length!==r.length)throw Error(`Invalid ${r.length} panel layout: ${s.map(e=>`${e}%`).join(", ")}`);if(!d9(n,100)&&s.length>0)for(let e=0;e<r.length;e++){let r=s[e];d6(null!=r,`No layout data found for index ${e}`);let i=100/n*r;s[e]=i}let i=0;for(let e=0;e<r.length;e++){let n=s[e];d6(null!=n,`No layout data found for index ${e}`);let a=ue({panelConstraints:r,panelIndex:e,size:n});n!=a&&(i+=n-a,s[e]=a)}if(!d9(i,0))for(let e=0;e<r.length;e++){let n=s[e];d6(null!=n,`No layout data found for index ${e}`);let a=ue({panelConstraints:r,panelIndex:e,size:n+i});if(n!==a&&(i-=a-n,s[e]=a,d9(i,0)))break}return s}let ux={getItem:e=>(uu(ux),ux.getItem(e)),setItem:(e,r)=>{uu(ux),ux.setItem(e,r)}},uv={};function u_({autoSaveId:e=null,children:r,className:s="",direction:n,forwardedRef:i,id:a=null,onLayout:o=null,keyboardResizeBy:l=null,storage:c=ux,style:d,tagName:u="div",...h}){let f=dC(a),p=(0,$.useRef)(null),[m,g]=(0,$.useState)(null),[x,v]=(0,$.useState)([]),_=function(){let[e,r]=(0,$.useState)(0);return(0,$.useCallback)(()=>r(e=>e+1),[])}(),y=(0,$.useRef)({}),b=(0,$.useRef)(new Map),w=(0,$.useRef)(0),S=(0,$.useRef)({autoSaveId:e,direction:n,dragState:m,id:f,keyboardResizeBy:l,onLayout:o,storage:c}),j=(0,$.useRef)({layout:x,panelDataArray:[],panelDataArrayChanged:!1});(0,$.useRef)({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),(0,$.useImperativeHandle)(i,()=>({getId:()=>S.current.id,getLayout:()=>{let{layout:e}=j.current;return e},setLayout:e=>{let{onLayout:r}=S.current,{layout:s,panelDataArray:n}=j.current,i=ug({layout:e,panelConstraints:n.map(e=>e.constraints)});uo(s,i)||(v(i),j.current.layout=i,r&&r(i),uc(n,i,y.current))}}),[]),db(()=>{S.current.autoSaveId=e,S.current.direction=n,S.current.dragState=m,S.current.id=f,S.current.onLayout=o,S.current.storage=c}),function({committedValuesRef:e,eagerValuesRef:r,groupId:s,layout:n,panelDataArray:i,panelGroupElement:a,setLayout:o}){(0,$.useRef)({didWarnAboutMissingResizeHandle:!1}),db(()=>{if(!a)return;let e=ur(s,a);for(let r=0;r<i.length-1;r++){let{valueMax:s,valueMin:a,valueNow:o}=function({layout:e,panelsArray:r,pivotIndices:s}){let n=0,i=100,a=0,o=0,l=s[0];return d6(null!=l,"No pivot index found"),r.forEach((e,r)=>{let{constraints:s}=e,{maxSize:c=100,minSize:d=0}=s;r===l?(n=d,i=c):(a+=d,o+=c)}),{valueMax:Math.min(i,100-a),valueMin:Math.max(n,100-o),valueNow:e[l]}}({layout:n,panelsArray:i,pivotIndices:[r,r+1]}),l=e[r];if(null==l);else{let e=i[r];d6(e,`No panel data found for index "${r}"`),l.setAttribute("aria-controls",e.id),l.setAttribute("aria-valuemax",""+Math.round(s)),l.setAttribute("aria-valuemin",""+Math.round(a)),l.setAttribute("aria-valuenow",null!=o?""+Math.round(o):"")}}return()=>{e.forEach((e,r)=>{e.removeAttribute("aria-controls"),e.removeAttribute("aria-valuemax"),e.removeAttribute("aria-valuemin"),e.removeAttribute("aria-valuenow")})}},[s,n,i,a]),(0,$.useEffect)(()=>{if(!a)return;let e=r.current;d6(e,"Eager values not found");let{panelDataArray:i}=e;d6(null!=ui(s,a),`No group found for id "${s}"`);let l=ur(s,a);d6(l,`No resize handles found for group id "${s}"`);let c=l.map(e=>{let r=e.getAttribute(dy);d6(r,"Resize handle element has no handle id attribute");let[l,c]=function(e,r,s,n=document){var i,a,o,l;let c=ua(r,n),d=ur(e,n),u=c?d.indexOf(c):-1;return[null!=(i=null==(a=s[u])?void 0:a.id)?i:null,null!=(o=null==(l=s[u+1])?void 0:l.id)?o:null]}(s,r,i,a);if(null==l||null==c)return()=>{};let d=e=>{if(!e.defaultPrevented&&"Enter"===e.key){e.preventDefault();let c=i.findIndex(e=>e.id===l);if(c>=0){let e=i[c];d6(e,`No panel data found for index ${c}`);let l=n[c],{collapsedSize:d=0,collapsible:u,minSize:h=0}=e.constraints;if(null!=l&&u){let e=ut({delta:d9(l,d)?h-d:d-l,initialLayout:n,panelConstraints:i.map(e=>e.constraints),pivotIndices:un(s,r,a),prevLayout:n,trigger:"keyboard"});n!==e&&o(e)}}}};return e.addEventListener("keydown",d),()=>{e.removeEventListener("keydown",d)}});return()=>{c.forEach(e=>e())}},[a,e,r,s,n,i,o])}({committedValuesRef:S,eagerValuesRef:j,groupId:f,layout:x,panelDataArray:j.current.panelDataArray,setLayout:v,panelGroupElement:p.current}),(0,$.useEffect)(()=>{let{panelDataArray:r}=j.current;if(e){if(0===x.length||x.length!==r.length)return;let s=uv[e];null==s&&(s=function(e,r=10){let s=null;return(...n)=>{null!==s&&clearTimeout(s),s=setTimeout(()=>{e(...n)},r)}}(um,100),uv[e]=s),s(e,[...r],new Map(b.current),x,c)}},[e,x,c]),(0,$.useEffect)(()=>{});let C=(0,$.useCallback)(e=>{let{onLayout:r}=S.current,{layout:s,panelDataArray:n}=j.current;if(e.constraints.collapsible){let i=n.map(e=>e.constraints),{collapsedSize:a=0,panelSize:o,pivotIndices:l}=uw(n,e,s);if(d6(null!=o,`Panel size not found for panel "${e.id}"`),!d8(o,a)){b.current.set(e.id,o);let c=ut({delta:ub(n,e)===n.length-1?o-a:a-o,initialLayout:s,panelConstraints:i,pivotIndices:l,prevLayout:s,trigger:"imperative-api"});ud(s,c)||(v(c),j.current.layout=c,r&&r(c),uc(n,c,y.current))}}},[]),k=(0,$.useCallback)((e,r)=>{let{onLayout:s}=S.current,{layout:n,panelDataArray:i}=j.current;if(e.constraints.collapsible){let a=i.map(e=>e.constraints),{collapsedSize:o=0,panelSize:l=0,minSize:c=0,pivotIndices:d}=uw(i,e,n),u=null!=r?r:c;if(d8(l,o)){let r=b.current.get(e.id),o=null!=r&&r>=u?r:u,c=ut({delta:ub(i,e)===i.length-1?l-o:o-l,initialLayout:n,panelConstraints:a,pivotIndices:d,prevLayout:n,trigger:"imperative-api"});ud(n,c)||(v(c),j.current.layout=c,s&&s(c),uc(i,c,y.current))}}},[]),N=(0,$.useCallback)(e=>{let{layout:r,panelDataArray:s}=j.current,{panelSize:n}=uw(s,e,r);return d6(null!=n,`Panel size not found for panel "${e.id}"`),n},[]),E=(0,$.useCallback)((e,r)=>{let{panelDataArray:s}=j.current,n=ub(s,e);return function({defaultSize:e,dragState:r,layout:s,panelData:n,panelIndex:i,precision:a=3}){let o=s[i];return{flexBasis:0,flexGrow:null==o?void 0!=e?e.toPrecision(a):"1":1===n.length?"1":o.toPrecision(a),flexShrink:1,overflow:"hidden",pointerEvents:null!==r?"none":void 0}}({defaultSize:r,dragState:m,layout:x,panelData:s,panelIndex:n})},[m,x]),D=(0,$.useCallback)(e=>{let{layout:r,panelDataArray:s}=j.current,{collapsedSize:n=0,collapsible:i,panelSize:a}=uw(s,e,r);return d6(null!=a,`Panel size not found for panel "${e.id}"`),!0===i&&d8(a,n)},[]),R=(0,$.useCallback)(e=>{let{layout:r,panelDataArray:s}=j.current,{collapsedSize:n=0,collapsible:i,panelSize:a}=uw(s,e,r);return d6(null!=a,`Panel size not found for panel "${e.id}"`),!i||d7(a,n)>0},[]),A=(0,$.useCallback)(e=>{let{panelDataArray:r}=j.current;r.push(e),r.sort((e,r)=>{let s=e.order,n=r.order;return null==s&&null==n?0:null==s?-1:null==n?1:s-n}),j.current.panelDataArrayChanged=!0,_()},[_]);db(()=>{if(j.current.panelDataArrayChanged){j.current.panelDataArrayChanged=!1;let{autoSaveId:s,onLayout:n,storage:i}=S.current,{layout:a,panelDataArray:o}=j.current,l=null;if(s){var e,r;let n=null!=(r=(null!=(e=up(s,i))?e:{})[uf(o)])?r:null;n&&(b.current=new Map(Object.entries(n.expandToSizes)),l=n.layout)}null==l&&(l=function({panelDataArray:e}){let r=Array(e.length),s=e.map(e=>e.constraints),n=0,i=100;for(let a=0;a<e.length;a++){let e=s[a];d6(e,`Panel constraints not found for index ${a}`);let{defaultSize:o}=e;null!=o&&(n++,r[a]=o,i-=o)}for(let a=0;a<e.length;a++){let o=s[a];d6(o,`Panel constraints not found for index ${a}`);let{defaultSize:l}=o;if(null!=l)continue;let c=i/(e.length-n);n++,r[a]=c,i-=c}return r}({panelDataArray:o}));let c=ug({layout:l,panelConstraints:o.map(e=>e.constraints)});uo(a,c)||(v(c),j.current.layout=c,n&&n(c),uc(o,c,y.current))}}),db(()=>{let e=j.current;return()=>{e.layout=[]}},[]);let T=(0,$.useCallback)(e=>{let r=!1,s=p.current;return s&&"rtl"===window.getComputedStyle(s,null).getPropertyValue("direction")&&(r=!0),function(s){var n,i;s.preventDefault();let a=p.current;if(!a)return()=>null;let{direction:o,dragState:l,id:c,keyboardResizeBy:d,onLayout:u}=S.current,{layout:h,panelDataArray:f}=j.current,{initialLayout:m}=null!=l?l:{},g=un(c,e,a),x=function(e,r,s,n,i,a){if(dT(e)){let r="horizontal"===s,n=0;n=e.shiftKey?100:null!=i?i:10;let a=0;switch(e.key){case"ArrowDown":a=r?0:n;break;case"ArrowLeft":a=r?-n:0;break;case"ArrowRight":a=r?n:0;break;case"ArrowUp":a=r?0:-n;break;case"End":a=100;break;case"Home":a=-100}return a}return null==n?0:function(e,r,s,n,i){let a="horizontal"===s,o=ua(r,i);d6(o,`No resize handle element found for id "${r}"`);let l=o.getAttribute(dv);d6(l,"Resize handle element has no group id attribute");let{initialCursorPosition:c}=n,d=ul(s,e),u=ui(l,i);d6(u,`No group element found for id "${l}"`);let h=u.getBoundingClientRect();return(d-c)/(a?h.width:h.height)*100}(e,r,s,n,a)}(s,e,o,l,d,a),_="horizontal"===o;_&&r&&(x=-x);let b=ut({delta:x,initialLayout:null!=m?m:h,panelConstraints:f.map(e=>e.constraints),pivotIndices:g,prevLayout:h,trigger:dT(s)?"keyboard":"mouse-or-touch"}),C=!ud(h,b);(dM(s)||dF(s))&&w.current!=x&&((w.current=x,C||0===x)?dG.set(e,0):_?(n=x<0?d$:dW,dG.set(e,n)):(i=x<0?dH:dU,dG.set(e,i))),C&&(v(b),j.current.layout=b,u&&u(b),uc(f,b,y.current))}},[]),M=(0,$.useCallback)((e,r)=>{let{onLayout:s}=S.current,{layout:n,panelDataArray:i}=j.current,a=i.map(e=>e.constraints),{panelSize:o,pivotIndices:l}=uw(i,e,n);d6(null!=o,`Panel size not found for panel "${e.id}"`);let c=ut({delta:ub(i,e)===i.length-1?o-r:r-o,initialLayout:n,panelConstraints:a,pivotIndices:l,prevLayout:n,trigger:"imperative-api"});ud(n,c)||(v(c),j.current.layout=c,s&&s(c),uc(i,c,y.current))},[]),F=(0,$.useCallback)((e,r)=>{let{layout:s,panelDataArray:n}=j.current,{collapsedSize:i=0,collapsible:a}=r,{collapsedSize:o=0,collapsible:l,maxSize:c=100,minSize:d=0}=e.constraints,{panelSize:u}=uw(n,e,s);null!=u&&(a&&l&&d8(u,i)?d8(i,o)||M(e,o):u<d?M(e,d):u>c&&M(e,c))},[M]),P=(0,$.useCallback)((e,r)=>{let{direction:s}=S.current,{layout:n}=j.current;if(!p.current)return;let i=ua(e,p.current);d6(i,`Drag handle element not found for id "${e}"`);let a=ul(s,r);g({dragHandleId:e,dragHandleRect:i.getBoundingClientRect(),initialCursorPosition:a,initialLayout:n})},[]),I=(0,$.useCallback)(()=>{g(null)},[]),B=(0,$.useCallback)(e=>{let{panelDataArray:r}=j.current,s=ub(r,e);s>=0&&(r.splice(s,1),delete y.current[e.id],j.current.panelDataArrayChanged=!0,_())},[_]),L=(0,$.useMemo)(()=>({collapsePanel:C,direction:n,dragState:m,expandPanel:k,getPanelSize:N,getPanelStyle:E,groupId:f,isPanelCollapsed:D,isPanelExpanded:R,reevaluatePanelConstraints:F,registerPanel:A,registerResizeHandle:T,resizePanel:M,startDragging:P,stopDragging:I,unregisterPanel:B,panelGroupElement:p.current}),[C,m,n,k,N,E,f,D,R,F,A,T,M,P,I,B]);return(0,$.createElement)(dg.Provider,{value:L},(0,$.createElement)(u,{...h,children:r,className:s,id:a,ref:p,style:{display:"flex",flexDirection:"horizontal"===n?"row":"column",height:"100%",overflow:"hidden",width:"100%",...d},"data-panel-group":"",[dx]:n,[dv]:f}))}let uy=(0,$.forwardRef)((e,r)=>(0,$.createElement)(u_,{...e,forwardedRef:r}));function ub(e,r){return e.findIndex(e=>e===r||e.id===r.id)}function uw(e,r,s){let n=ub(e,r),i=n===e.length-1,a=s[n];return{...r.constraints,panelSize:a,pivotIndices:i?[n-1,n]:[n,n+1]}}function uS({children:e=null,className:r="",disabled:s=!1,hitAreaMargins:n,id:i,onBlur:a,onClick:o,onDragging:l,onFocus:c,onPointerDown:d,onPointerUp:u,style:h={},tabIndex:f=0,tagName:p="div",...m}){var g,x;let v=(0,$.useRef)(null),_=(0,$.useRef)({onClick:o,onDragging:l,onPointerDown:d,onPointerUp:u});(0,$.useEffect)(()=>{_.current.onClick=o,_.current.onDragging=l,_.current.onPointerDown=d,_.current.onPointerUp=u});let y=(0,$.useContext)(dg);if(null===y)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");let{direction:b,groupId:w,registerResizeHandle:S,startDragging:j,stopDragging:C,panelGroupElement:k}=y,N=dC(i),[E,D]=(0,$.useState)("inactive"),[R,A]=(0,$.useState)(!1),[T,M]=(0,$.useState)(null),F=(0,$.useRef)({state:E});db(()=>{F.current.state=E}),(0,$.useEffect)(()=>{if(s)M(null);else{let e=S(N);M(()=>e)}},[s,N,S]);let P=null!=(g=null==n?void 0:n.coarse)?g:15,I=null!=(x=null==n?void 0:n.fine)?x:5;return(0,$.useEffect)(()=>{if(s||null==T)return;let e=v.current;d6(e,"Element ref not attached");let r=!1;return function(e,r,s,n,i){var a;let{ownerDocument:o}=r,l={direction:s,element:r,hitAreaMargins:n,setResizeHandlerState:i},c=null!=(a=dY.get(o))?a:0;return dY.set(o,c+1),dX.add(l),d3(),function(){var r;dG.delete(e),dX.delete(l);let s=null!=(r=dY.get(o))?r:1;if(dY.set(o,s-1),d3(),1===s&&dY.delete(o),dK.includes(l)){let e=dK.indexOf(l);e>=0&&dK.splice(e,1),d2(),i("up",!0,null)}}}(N,e,b,{coarse:P,fine:I},(e,s,n)=>{if(!s)return void D("inactive");switch(e){case"down":{D("drag"),r=!1,d6(n,'Expected event to be defined for "down" action'),j(N,n);let{onDragging:e,onPointerDown:s}=_.current;null==e||e(!0),null==s||s();break}case"move":{let{state:e}=F.current;r=!0,"drag"!==e&&D("hover"),d6(n,'Expected event to be defined for "move" action'),T(n);break}case"up":{D("hover"),C();let{onClick:e,onDragging:s,onPointerUp:n}=_.current;null==s||s(!1),null==n||n(),r||null==e||e()}}})},[P,b,s,I,S,N,T,j,C]),!function({disabled:e,handleId:r,resizeHandler:s,panelGroupElement:n}){(0,$.useEffect)(()=>{if(e||null==s||null==n)return;let i=ua(r,n);if(null==i)return;let a=e=>{if(!e.defaultPrevented)switch(e.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":e.preventDefault(),s(e);break;case"F6":{e.preventDefault();let s=i.getAttribute(dv);d6(s,`No group element found for id "${s}"`);let a=ur(s,n),o=us(s,r,n);d6(null!==o,`No resize element found for id "${r}"`);let l=e.shiftKey?o>0?o-1:a.length-1:o+1<a.length?o+1:0;a[l].focus()}}};return i.addEventListener("keydown",a),()=>{i.removeEventListener("keydown",a)}},[n,e,r,s])}({disabled:s,handleId:N,resizeHandler:T,panelGroupElement:k}),(0,$.createElement)(p,{...m,children:e,className:r,id:i,onBlur:()=>{A(!1),null==a||a()},onFocus:()=>{A(!0),null==c||c()},ref:v,role:"separator",style:{touchAction:"none",userSelect:"none",...h},tabIndex:f,[dx]:b,[dv]:w,[d_]:"","data-resize-handle-active":"drag"===E?"pointer":R?"keyboard":void 0,"data-panel-resize-handle-enabled":!s,[dy]:N,"data-resize-handle-state":E})}u_.displayName="PanelGroup",uy.displayName="forwardRef(PanelGroup)",uS.displayName="PanelResizeHandle";let uj=({className:e,...r})=>(0,O.jsx)(uy,{className:(0,ey.cn)("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...r}),uC=({withHandle:e,className:r,...s})=>(0,O.jsx)(uS,{className:(0,ey.cn)("relative flex w-px items-center justify-center bg-border/60 after:absolute after:inset-y-0 after:-left-1 after:-right-1 after:content-[''] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:inset-x-0 data-[panel-group-direction=vertical]:after:-top-1 data-[panel-group-direction=vertical]:after:-bottom-1 data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:right-0 [&[data-resize-handle-active]]:bg-ring",r),...s,children:e&&(0,O.jsx)("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:(0,O.jsx)(dm,{className:"h-2.5 w-2.5"})})});function uk({className:e,...r}){return(0,O.jsx)("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:(0,O.jsx)("table",{"data-slot":"table",className:(0,ey.cn)("w-full caption-bottom text-sm",e),...r})})}function uN({className:e,...r}){return(0,O.jsx)("thead",{"data-slot":"table-header",className:(0,ey.cn)("[&_tr]:border-b",e),...r})}function uE({className:e,...r}){return(0,O.jsx)("tbody",{"data-slot":"table-body",className:(0,ey.cn)("[&_tr:last-child]:border-0",e),...r})}function uD({className:e,...r}){return(0,O.jsx)("tr",{"data-slot":"table-row",className:(0,ey.cn)("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",e),...r})}function uR({className:e,...r}){return(0,O.jsx)("th",{"data-slot":"table-head",className:(0,ey.cn)("text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...r})}function uA({className:e,...r}){return(0,O.jsx)("td",{"data-slot":"table-cell",className:(0,ey.cn)("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...r})}var uT=[" ","Enter","ArrowUp","ArrowDown"],uM=[" ","Enter"],uF="Select",[uP,uI,uB]=rb(uF),[uL,uz]=q(uF,[uB,iw]),uO=iw(),[u$,uW]=uL(uF),[uH,uU]=uL(uF),uq=e=>{let{__scopeSelect:r,children:s,open:n,defaultOpen:i,onOpenChange:a,value:o,defaultValue:l,onValueChange:c,dir:d,name:u,autoComplete:h,disabled:f,required:p,form:m}=e,g=uO(r),[x,v]=$.useState(null),[_,y]=$.useState(null),[b,w]=$.useState(!1),S=rk(d),[j,C]=G({prop:n,defaultProp:i??!1,onChange:a,caller:uF}),[k,N]=G({prop:o,defaultProp:l,onChange:c,caller:uF}),E=$.useRef(null),D=!x||m||!!x.closest("form"),[R,A]=$.useState(new Set),T=Array.from(R).map(e=>e.props.value).join(";");return(0,O.jsx)(iC,{...g,children:(0,O.jsxs)(u$,{required:p,scope:r,trigger:x,onTriggerChange:v,valueNode:_,onValueNodeChange:y,valueNodeHasChildren:b,onValueNodeHasChildrenChange:w,contentId:ek(),value:k,onValueChange:N,open:j,onOpenChange:C,dir:S,triggerPointerDownPosRef:E,disabled:f,children:[(0,O.jsx)(uP.Provider,{scope:r,children:(0,O.jsx)(uH,{scope:e.__scopeSelect,onNativeOptionAdd:$.useCallback(e=>{A(r=>new Set(r).add(e))},[]),onNativeOptionRemove:$.useCallback(e=>{A(r=>{let s=new Set(r);return s.delete(e),s})},[]),children:s})}),D?(0,O.jsxs)(hv,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:h,value:k,onChange:e=>N(e.target.value),disabled:f,form:m,children:[void 0===k?(0,O.jsx)("option",{value:""}):null,Array.from(R)]},T):null]})})};uq.displayName=uF;var uK="SelectTrigger",uV=$.forwardRef((e,r)=>{let{__scopeSelect:s,disabled:n=!1,...i}=e,a=uO(s),o=uW(uK,s),l=o.disabled||n,c=(0,U.useComposedRefs)(r,o.onTriggerChange),d=uI(s),u=$.useRef("touch"),[h,f,p]=hy(e=>{let r=d().filter(e=>!e.disabled),s=r.find(e=>e.value===o.value),n=hb(r,e,s);void 0!==n&&o.onValueChange(n.value)}),m=e=>{l||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,O.jsx)(iN,{asChild:!0,...a,children:(0,O.jsx)(er.button,{type:"button",role:"combobox","aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":"none",dir:o.dir,"data-state":o.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":h_(o.value)?"":void 0,...i,ref:c,onClick:K(i.onClick,e=>{e.currentTarget.focus(),"mouse"!==u.current&&m(e)}),onPointerDown:K(i.onPointerDown,e=>{u.current=e.pointerType;let r=e.target;r.hasPointerCapture(e.pointerId)&&r.releasePointerCapture(e.pointerId),0===e.button&&!1===e.ctrlKey&&"mouse"===e.pointerType&&(m(e),e.preventDefault())}),onKeyDown:K(i.onKeyDown,e=>{let r=""!==h.current;e.ctrlKey||e.altKey||e.metaKey||1!==e.key.length||f(e.key),(!r||" "!==e.key)&&uT.includes(e.key)&&(m(),e.preventDefault())})})})});uV.displayName=uK;var uY="SelectValue",uG=$.forwardRef((e,r)=>{let{__scopeSelect:s,className:n,style:i,children:a,placeholder:o="",...l}=e,c=uW(uY,s),{onValueNodeHasChildrenChange:d}=c,u=void 0!==a,h=(0,U.useComposedRefs)(r,c.onValueNodeChange);return V(()=>{d(u)},[d,u]),(0,O.jsx)(er.span,{...l,ref:h,style:{pointerEvents:"none"},children:h_(c.value)?(0,O.jsx)(O.Fragment,{children:o}):a})});uG.displayName=uY;var uX=$.forwardRef((e,r)=>{let{__scopeSelect:s,children:n,...i}=e;return(0,O.jsx)(er.span,{"aria-hidden":!0,...i,ref:r,children:n||"▼"})});uX.displayName="SelectIcon";var uJ=e=>(0,O.jsx)(eW,{asChild:!0,...e});uJ.displayName="SelectPortal";var uZ="SelectContent",uQ=$.forwardRef((e,r)=>{let s=uW(uZ,e.__scopeSelect),[n,i]=$.useState();return(V(()=>{i(new DocumentFragment)},[]),s.open)?(0,O.jsx)(u5,{...e,ref:r}):n?ee.createPortal((0,O.jsx)(u0,{scope:e.__scopeSelect,children:(0,O.jsx)(uP.Slot,{scope:e.__scopeSelect,children:(0,O.jsx)("div",{children:e.children})})}),n):null});uQ.displayName=uZ;var[u0,u1]=uL(uZ),u2=(0,et.createSlot)("SelectContent.RemoveScroll"),u5=$.forwardRef((e,r)=>{let{__scopeSelect:s,position:n="item-aligned",onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:l,sideOffset:c,align:d,alignOffset:u,arrowPadding:h,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:g,avoidCollisions:x,...v}=e,_=uW(uZ,s),[y,b]=$.useState(null),[w,S]=$.useState(null),j=(0,U.useComposedRefs)(r,e=>b(e)),[C,k]=$.useState(null),[N,E]=$.useState(null),D=uI(s),[R,A]=$.useState(!1),T=$.useRef(!1);$.useEffect(()=>{if(y)return tN(y)},[y]),eU();let M=$.useCallback(e=>{let[r,...s]=D().map(e=>e.ref.current),[n]=s.slice(-1),i=document.activeElement;for(let s of e)if(s===i||(s?.scrollIntoView({block:"nearest"}),s===r&&w&&(w.scrollTop=0),s===n&&w&&(w.scrollTop=w.scrollHeight),s?.focus(),document.activeElement!==i))return},[D,w]),F=$.useCallback(()=>M([C,y]),[M,C,y]);$.useEffect(()=>{R&&F()},[R,F]);let{onOpenChange:P,triggerPointerDownPosRef:I}=_;$.useEffect(()=>{if(y){let e={x:0,y:0},r=r=>{e={x:Math.abs(Math.round(r.pageX)-(I.current?.x??0)),y:Math.abs(Math.round(r.pageY)-(I.current?.y??0))}},s=s=>{e.x<=10&&e.y<=10?s.preventDefault():y.contains(s.target)||P(!1),document.removeEventListener("pointermove",r),I.current=null};return null!==I.current&&(document.addEventListener("pointermove",r),document.addEventListener("pointerup",s,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",r),document.removeEventListener("pointerup",s,{capture:!0})}}},[y,P,I]),$.useEffect(()=>{let e=()=>P(!1);return window.addEventListener("blur",e),window.addEventListener("resize",e),()=>{window.removeEventListener("blur",e),window.removeEventListener("resize",e)}},[P]);let[B,L]=hy(e=>{let r=D().filter(e=>!e.disabled),s=r.find(e=>e.ref.current===document.activeElement),n=hb(r,e,s);n&&setTimeout(()=>n.ref.current.focus())}),z=$.useCallback((e,r,s)=>{let n=!T.current&&!s;(void 0!==_.value&&_.value===r||n)&&(k(e),n&&(T.current=!0))},[_.value]),W=$.useCallback(()=>y?.focus(),[y]),H=$.useCallback((e,r,s)=>{let n=!T.current&&!s;(void 0!==_.value&&_.value===r||n)&&E(e)},[_.value]),q="popper"===n?u4:u3,V=q===u4?{side:l,sideOffset:c,align:d,alignOffset:u,arrowPadding:h,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:g,avoidCollisions:x}:{};return(0,O.jsx)(u0,{scope:s,content:y,viewport:w,onViewportChange:S,itemRefCallback:z,selectedItem:C,onItemLeave:W,itemTextRefCallback:H,focusSelectedItem:F,selectedItemText:N,position:n,isPositioned:R,searchRef:B,children:(0,O.jsx)(ty,{as:u2,allowPinchZoom:!0,children:(0,O.jsx)(eI,{asChild:!0,trapped:_.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:K(i,e=>{_.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,O.jsx)(eR,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>_.onOpenChange(!1),children:(0,O.jsx)(q,{role:"listbox",id:_.contentId,"data-state":_.open?"open":"closed",dir:_.dir,onContextMenu:e=>e.preventDefault(),...v,...V,onPlaced:()=>A(!0),ref:j,style:{display:"flex",flexDirection:"column",outline:"none",...v.style},onKeyDown:K(v.onKeyDown,e=>{let r=e.ctrlKey||e.altKey||e.metaKey;if("Tab"===e.key&&e.preventDefault(),r||1!==e.key.length||L(e.key),["ArrowUp","ArrowDown","Home","End"].includes(e.key)){let r=D().filter(e=>!e.disabled).map(e=>e.ref.current);if(["ArrowUp","End"].includes(e.key)&&(r=r.slice().reverse()),["ArrowUp","ArrowDown"].includes(e.key)){let s=e.target,n=r.indexOf(s);r=r.slice(n+1)}setTimeout(()=>M(r)),e.preventDefault()}})})})})})})});u5.displayName="SelectContentImpl";var u3=$.forwardRef((e,r)=>{let{__scopeSelect:s,onPlaced:n,...i}=e,a=uW(uZ,s),o=u1(uZ,s),[l,c]=$.useState(null),[d,u]=$.useState(null),h=(0,U.useComposedRefs)(r,e=>u(e)),f=uI(s),p=$.useRef(!1),m=$.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:v,focusSelectedItem:_}=o,y=$.useCallback(()=>{if(a.trigger&&a.valueNode&&l&&d&&g&&x&&v){let e=a.trigger.getBoundingClientRect(),r=d.getBoundingClientRect(),s=a.valueNode.getBoundingClientRect(),i=v.getBoundingClientRect();if("rtl"!==a.dir){let n=i.left-r.left,a=s.left-n,o=e.left-a,c=e.width+o,d=Math.max(c,r.width),u=oh(a,[10,Math.max(10,window.innerWidth-10-d)]);l.style.minWidth=c+"px",l.style.left=u+"px"}else{let n=r.right-i.right,a=window.innerWidth-s.right-n,o=window.innerWidth-e.right-a,c=e.width+o,d=Math.max(c,r.width),u=oh(a,[10,Math.max(10,window.innerWidth-10-d)]);l.style.minWidth=c+"px",l.style.right=u+"px"}let o=f(),c=window.innerHeight-20,u=g.scrollHeight,h=window.getComputedStyle(d),m=parseInt(h.borderTopWidth,10),_=parseInt(h.paddingTop,10),y=parseInt(h.borderBottomWidth,10),b=m+_+u+parseInt(h.paddingBottom,10)+y,w=Math.min(5*x.offsetHeight,b),S=window.getComputedStyle(g),j=parseInt(S.paddingTop,10),C=parseInt(S.paddingBottom,10),k=e.top+e.height/2-10,N=x.offsetHeight/2,E=m+_+(x.offsetTop+N);if(E<=k){let e=o.length>0&&x===o[o.length-1].ref.current;l.style.bottom="0px";let r=Math.max(c-k,N+(e?C:0)+(d.clientHeight-g.offsetTop-g.offsetHeight)+y);l.style.height=E+r+"px"}else{let e=o.length>0&&x===o[0].ref.current;l.style.top="0px";let r=Math.max(k,m+g.offsetTop+(e?j:0)+N);l.style.height=r+(b-E)+"px",g.scrollTop=E-k+g.offsetTop}l.style.margin="10px 0",l.style.minHeight=w+"px",l.style.maxHeight=c+"px",n?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,l,d,g,x,v,a.dir,n]);V(()=>y(),[y]);let[b,w]=$.useState();V(()=>{d&&w(window.getComputedStyle(d).zIndex)},[d]);let S=$.useCallback(e=>{e&&!0===m.current&&(y(),_?.(),m.current=!1)},[y,_]);return(0,O.jsx)(u6,{scope:s,contentWrapper:l,shouldExpandOnScrollRef:p,onScrollButtonChange:S,children:(0,O.jsx)("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:b},children:(0,O.jsx)(er.div,{...i,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}})})})});u3.displayName="SelectItemAlignedPosition";var u4=$.forwardRef((e,r)=>{let{__scopeSelect:s,align:n="start",collisionPadding:i=10,...a}=e,o=uO(s);return(0,O.jsx)(iA,{...o,...a,ref:r,align:n,collisionPadding:i,style:{boxSizing:"border-box",...a.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});u4.displayName="SelectPopperPosition";var[u6,u7]=uL(uZ,{}),u8="SelectViewport",u9=$.forwardRef((e,r)=>{let{__scopeSelect:s,nonce:n,...i}=e,a=u1(u8,s),o=u7(u8,s),l=(0,U.useComposedRefs)(r,a.onViewportChange),c=$.useRef(0);return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:n}),(0,O.jsx)(uP.Slot,{scope:s,children:(0,O.jsx)(er.div,{"data-radix-select-viewport":"",role:"presentation",...i,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...i.style},onScroll:K(i.onScroll,e=>{let r=e.currentTarget,{contentWrapper:s,shouldExpandOnScrollRef:n}=o;if(n?.current&&s){let e=Math.abs(c.current-r.scrollTop);if(e>0){let n=window.innerHeight-20,i=Math.max(parseFloat(s.style.minHeight),parseFloat(s.style.height));if(i<n){let a=i+e,o=Math.min(n,a),l=a-o;s.style.height=o+"px","0px"===s.style.bottom&&(r.scrollTop=l>0?l:0,s.style.justifyContent="flex-end")}}}c.current=r.scrollTop})})})]})});u9.displayName=u8;var he="SelectGroup",[ht,hr]=uL(he);$.forwardRef((e,r)=>{let{__scopeSelect:s,...n}=e,i=ek();return(0,O.jsx)(ht,{scope:s,id:i,children:(0,O.jsx)(er.div,{role:"group","aria-labelledby":i,...n,ref:r})})}).displayName=he;var hs="SelectLabel";$.forwardRef((e,r)=>{let{__scopeSelect:s,...n}=e,i=hr(hs,s);return(0,O.jsx)(er.div,{id:i.id,...n,ref:r})}).displayName=hs;var hn="SelectItem",[hi,ha]=uL(hn),ho=$.forwardRef((e,r)=>{let{__scopeSelect:s,value:n,disabled:i=!1,textValue:a,...o}=e,l=uW(hn,s),c=u1(hn,s),d=l.value===n,[u,h]=$.useState(a??""),[f,p]=$.useState(!1),m=(0,U.useComposedRefs)(r,e=>c.itemRefCallback?.(e,n,i)),g=ek(),x=$.useRef("touch"),v=()=>{i||(l.onValueChange(n),l.onOpenChange(!1))};if(""===n)throw Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return(0,O.jsx)(hi,{scope:s,value:n,disabled:i,textId:g,isSelected:d,onItemTextChange:$.useCallback(e=>{h(r=>r||(e?.textContent??"").trim())},[]),children:(0,O.jsx)(uP.ItemSlot,{scope:s,value:n,disabled:i,textValue:u,children:(0,O.jsx)(er.div,{role:"option","aria-labelledby":g,"data-highlighted":f?"":void 0,"aria-selected":d&&f,"data-state":d?"checked":"unchecked","aria-disabled":i||void 0,"data-disabled":i?"":void 0,tabIndex:i?void 0:-1,...o,ref:m,onFocus:K(o.onFocus,()=>p(!0)),onBlur:K(o.onBlur,()=>p(!1)),onClick:K(o.onClick,()=>{"mouse"!==x.current&&v()}),onPointerUp:K(o.onPointerUp,()=>{"mouse"===x.current&&v()}),onPointerDown:K(o.onPointerDown,e=>{x.current=e.pointerType}),onPointerMove:K(o.onPointerMove,e=>{x.current=e.pointerType,i?c.onItemLeave?.():"mouse"===x.current&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:K(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:K(o.onKeyDown,e=>{(c.searchRef?.current===""||" "!==e.key)&&(uM.includes(e.key)&&v()," "===e.key&&e.preventDefault())})})})})});ho.displayName=hn;var hl="SelectItemText",hc=$.forwardRef((e,r)=>{let{__scopeSelect:s,className:n,style:i,...a}=e,o=uW(hl,s),l=u1(hl,s),c=ha(hl,s),d=uU(hl,s),[u,h]=$.useState(null),f=(0,U.useComposedRefs)(r,e=>h(e),c.onItemTextChange,e=>l.itemTextRefCallback?.(e,c.value,c.disabled)),p=u?.textContent,m=$.useMemo(()=>(0,O.jsx)("option",{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=d;return V(()=>(g(m),()=>x(m)),[g,x,m]),(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(er.span,{id:c.textId,...a,ref:f}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?ee.createPortal(a.children,o.valueNode):null]})});hc.displayName=hl;var hd="SelectItemIndicator",hu=$.forwardRef((e,r)=>{let{__scopeSelect:s,...n}=e;return ha(hd,s).isSelected?(0,O.jsx)(er.span,{"aria-hidden":!0,...n,ref:r}):null});hu.displayName=hd;var hh="SelectScrollUpButton",hf=$.forwardRef((e,r)=>{let s=u1(hh,e.__scopeSelect),n=u7(hh,e.__scopeSelect),[i,a]=$.useState(!1),o=(0,U.useComposedRefs)(r,n.onScrollButtonChange);return V(()=>{if(s.viewport&&s.isPositioned){let e=function(){a(r.scrollTop>0)},r=s.viewport;return e(),r.addEventListener("scroll",e),()=>r.removeEventListener("scroll",e)}},[s.viewport,s.isPositioned]),i?(0,O.jsx)(hg,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:r}=s;e&&r&&(e.scrollTop=e.scrollTop-r.offsetHeight)}}):null});hf.displayName=hh;var hp="SelectScrollDownButton",hm=$.forwardRef((e,r)=>{let s=u1(hp,e.__scopeSelect),n=u7(hp,e.__scopeSelect),[i,a]=$.useState(!1),o=(0,U.useComposedRefs)(r,n.onScrollButtonChange);return V(()=>{if(s.viewport&&s.isPositioned){let e=function(){let e=r.scrollHeight-r.clientHeight;a(Math.ceil(r.scrollTop)<e)},r=s.viewport;return e(),r.addEventListener("scroll",e),()=>r.removeEventListener("scroll",e)}},[s.viewport,s.isPositioned]),i?(0,O.jsx)(hg,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:r}=s;e&&r&&(e.scrollTop=e.scrollTop+r.offsetHeight)}}):null});hm.displayName=hp;var hg=$.forwardRef((e,r)=>{let{__scopeSelect:s,onAutoScroll:n,...i}=e,a=u1("SelectScrollButton",s),o=$.useRef(null),l=uI(s),c=$.useCallback(()=>{null!==o.current&&(window.clearInterval(o.current),o.current=null)},[]);return $.useEffect(()=>()=>c(),[c]),V(()=>{let e=l().find(e=>e.ref.current===document.activeElement);e?.ref.current?.scrollIntoView({block:"nearest"})},[l]),(0,O.jsx)(er.div,{"aria-hidden":!0,...i,ref:r,style:{flexShrink:0,...i.style},onPointerDown:K(i.onPointerDown,()=>{null===o.current&&(o.current=window.setInterval(n,50))}),onPointerMove:K(i.onPointerMove,()=>{a.onItemLeave?.(),null===o.current&&(o.current=window.setInterval(n,50))}),onPointerLeave:K(i.onPointerLeave,()=>{c()})})});$.forwardRef((e,r)=>{let{__scopeSelect:s,...n}=e;return(0,O.jsx)(er.div,{"aria-hidden":!0,...n,ref:r})}).displayName="SelectSeparator";var hx="SelectArrow";$.forwardRef((e,r)=>{let{__scopeSelect:s,...n}=e,i=uO(s),a=uW(hx,s),o=u1(hx,s);return a.open&&"popper"===o.position?(0,O.jsx)(iF,{...i,...n,ref:r}):null}).displayName=hx;var hv=$.forwardRef(({__scopeSelect:e,value:r,...s},n)=>{let i=$.useRef(null),a=(0,U.useComposedRefs)(n,i),o=X(r);return $.useEffect(()=>{let e=i.current;if(!e)return;let s=Object.getOwnPropertyDescriptor(window.HTMLSelectElement.prototype,"value").set;if(o!==r&&s){let n=new Event("change",{bubbles:!0});s.call(e,r),e.dispatchEvent(n)}},[o,r]),(0,O.jsx)(er.select,{...s,style:{...l1,...s.style},ref:a,defaultValue:r})});function h_(e){return""===e||void 0===e}function hy(e){let r=eN(e),s=$.useRef(""),n=$.useRef(0),i=$.useCallback(e=>{let i=s.current+e;r(i),function e(r){s.current=r,window.clearTimeout(n.current),""!==r&&(n.current=window.setTimeout(()=>e(""),1e3))}(i)},[r]),a=$.useCallback(()=>{s.current="",window.clearTimeout(n.current)},[]);return $.useEffect(()=>()=>window.clearTimeout(n.current),[]),[s,i,a]}function hb(e,r,s){var n,i;let a=r.length>1&&Array.from(r).every(e=>e===r[0])?r[0]:r,o=s?e.indexOf(s):-1,l=(n=e,i=Math.max(o,0),n.map((e,r)=>n[(i+r)%n.length]));1===a.length&&(l=l.filter(e=>e!==s));let c=l.find(e=>e.textValue.toLowerCase().startsWith(a.toLowerCase()));return c!==s?c:void 0}hv.displayName="SelectBubbleInput";var H=H;function hw({...e}){return(0,O.jsx)(uq,{"data-slot":"select",...e})}function hS({...e}){return(0,O.jsx)(uG,{"data-slot":"select-value",...e})}function hj({className:e,size:r="default",children:s,...n}){return(0,O.jsxs)(uV,{"data-slot":"select-trigger","data-size":r,className:(0,ey.cn)("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...n,children:[s,(0,O.jsx)(uX,{asChild:!0,children:(0,O.jsx)(ns,{className:"size-4 opacity-50"})})]})}function hC({className:e,children:r,position:s="item-aligned",align:n="center",...i}){return(0,O.jsx)(uJ,{children:(0,O.jsxs)(uQ,{"data-slot":"select-content",className:(0,ey.cn)("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md","popper"===s&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:s,align:n,...i,children:[(0,O.jsx)(hN,{}),(0,O.jsx)(u9,{className:(0,ey.cn)("p-1","popper"===s&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:r}),(0,O.jsx)(hE,{})]})})}function hk({className:e,children:r,...s}){return(0,O.jsxs)(ho,{"data-slot":"select-item",className:(0,ey.cn)("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...s,children:[(0,O.jsx)("span",{"data-slot":"select-item-indicator",className:"absolute right-2 flex size-3.5 items-center justify-center",children:(0,O.jsx)(hu,{children:(0,O.jsx)(H.default,{className:"size-4"})})}),(0,O.jsx)(hc,{children:r})]})}function hN({className:e,...r}){return(0,O.jsx)(hf,{"data-slot":"select-scroll-up-button",className:(0,ey.cn)("flex cursor-default items-center justify-center py-1",e),...r,children:(0,O.jsx)(oX,{className:"size-4"})})}function hE({className:e,...r}){return(0,O.jsx)(hm,{"data-slot":"select-scroll-down-button",className:(0,ey.cn)("flex cursor-default items-center justify-center py-1",e),...r,children:(0,O.jsx)(ns,{className:"size-4"})})}let hD="__main__";function hR({open:e,onOpenChange:r,onSubmit:s,initial:n,worktrees:i,projectId:a}){let[o,l]=(0,$.useState)(""),[c,d]=(0,$.useState)("0 9 * * *"),[u,h]=(0,$.useState)(""),[f,p]=(0,$.useState)("local"),[m,g]=(0,$.useState)([]),[x,v]=(0,$.useState)("command"),[_,y]=(0,$.useState)("claude"),[b,w]=(0,$.useState)(""),[S,j]=(0,$.useState)("branch"),[C,k]=(0,$.useState)(hD),[N,E]=(0,$.useState)(i),[D,R]=(0,$.useState)(""),[A,T]=(0,$.useState)("30"),[M,F]=(0,$.useState)(!1),[P,I]=(0,$.useState)(null);(0,$.useEffect)(()=>{e&&(I(null),l(n?.name??""),d(n?.cron_expr??"0 9 * * *"),h(n?.timezone??Intl.DateTimeFormat().resolvedOptions().timeZone),p(n?.target??"local"),v(n?.run_type??"command"),y(n?.prompt_provider??"claude"),w(n?.content??""),j(n?.cwd_mode??"branch"),k(n?.branch??hD),R(n?.directory??""),T(String(Math.round((n?.timeout_seconds??1800)/60))))},[e,n]),(0,$.useEffect)(()=>{"local"===f&&E(i)},[f,i]),(0,$.useEffect)(()=>{let r=!1;return e&&a&&rv.api.getProjectRemotes(a).then(e=>{r||g(e)}).catch(e=>console.error("Failed to load project remotes:",e)),()=>{r=!0}},[e,a]),(0,$.useEffect)(()=>{let r=!1;if(e&&a&&"local"!==f)return rv.api.getProjectWorktrees(a,f).then(e=>{r||E(e)}).catch(e=>{console.error("Failed to load target worktrees:",e),r||E([{branch:null}])}),()=>{r=!0}},[e,a,f]);let B=async()=>{if(!o.trim()||!b.trim())return void I("Name and content are required");let e=parseInt(A,10);if(!Number.isInteger(e)||e<=0)return void I("Timeout must be a positive number of minutes");if("directory"===S&&!D.trim())return void I("Directory is required");F(!0),I(null);try{await s({name:o.trim(),cron_expr:c.trim(),timezone:u.trim()||"UTC",target:f,run_type:x,prompt_provider:"prompt"===x?_:null,content:b,cwd_mode:S,branch:"branch"===S?C===hD?null:C:null,directory:"directory"===S?D.trim():null,timeout_seconds:60*e}),r(!1)}catch(e){I(e instanceof Error?e.message:"Failed to save schedule")}finally{F(!1)}};return(0,O.jsx)(t8,{open:e,onOpenChange:r,children:(0,O.jsxs)(rr,{className:"max-w-lg",children:[(0,O.jsxs)(rs,{children:[(0,O.jsx)(ri,{children:n?"Edit Scheduled Task":"New Scheduled Task"}),(0,O.jsx)(ra,{children:"Run a command or a Claude prompt on a cron schedule"})]}),(0,O.jsxs)("div",{className:"space-y-4",children:[(0,O.jsxs)("div",{className:"space-y-2",children:[(0,O.jsx)("label",{className:"text-sm font-medium",children:"Name"}),(0,O.jsx)(ro,{value:o,onChange:e=>l(e.target.value),placeholder:"Daily log analysis",disabled:M})]}),(0,O.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,O.jsxs)("div",{className:"space-y-2",children:[(0,O.jsx)("label",{className:"text-sm font-medium",children:"Cron"}),(0,O.jsx)(ro,{value:c,onChange:e=>d(e.target.value),placeholder:"0 9 * * *",className:"font-mono",disabled:M}),(0,O.jsx)("p",{className:"text-xs text-muted-foreground",children:"5-field cron — “0 9 * * *” = every day at 09:00"})]}),(0,O.jsxs)("div",{className:"space-y-2",children:[(0,O.jsx)("label",{className:"text-sm font-medium",children:"Timezone"}),(0,O.jsx)(ro,{value:u,onChange:e=>h(e.target.value),placeholder:"Asia/Shanghai",disabled:M})]})]}),(0,O.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,O.jsxs)("div",{className:"space-y-2",children:[(0,O.jsx)("label",{className:"text-sm font-medium",children:"Type"}),(0,O.jsxs)(hw,{value:x,onValueChange:e=>v(e),disabled:M,children:[(0,O.jsx)(hj,{size:"sm",children:(0,O.jsx)(hS,{})}),(0,O.jsxs)(hC,{children:[(0,O.jsx)(hk,{value:"command",children:"Command (shell)"}),(0,O.jsx)(hk,{value:"prompt",children:"Prompt"})]})]})]}),"prompt"===x&&(0,O.jsxs)("div",{className:"space-y-2",children:[(0,O.jsx)("label",{className:"text-sm font-medium",children:"Agent"}),(0,O.jsxs)(hw,{value:_,onValueChange:e=>y(e),disabled:M,children:[(0,O.jsx)(hj,{size:"sm",children:(0,O.jsx)(hS,{})}),(0,O.jsxs)(hC,{children:[(0,O.jsx)(hk,{value:"claude",children:"Claude"}),(0,O.jsx)(hk,{value:"codex",children:"Codex"})]})]})]})]}),(0,O.jsxs)("div",{className:"space-y-2",children:[(0,O.jsx)("label",{className:"text-sm font-medium",children:"command"===x?"Command":"Prompt"}),(0,O.jsx)(rl,{value:b,onChange:e=>w(e.target.value),placeholder:"command"===x?"./scripts/scan.sh --daily":"Analyze today's server logs under ./logs and summarize anomalies",className:"font-mono text-sm min-h-[80px]",disabled:M})]}),(0,O.jsxs)("div",{className:"space-y-2",children:[(0,O.jsx)("label",{className:"text-sm font-medium",children:"Target"}),(0,O.jsxs)(hw,{value:f,onValueChange:e=>{p(e),k(hD)},disabled:M,children:[(0,O.jsx)(hj,{size:"sm",children:(0,O.jsx)(hS,{placeholder:"Local"})}),(0,O.jsxs)(hC,{children:[(0,O.jsx)(hk,{value:"local",children:"Local"}),m.map(e=>(0,O.jsx)(hk,{value:e.remote_server_id,children:e.server_name??e.remote_server_id},e.remote_server_id))]})]})]}),(0,O.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,O.jsxs)("div",{className:"space-y-2",children:[(0,O.jsx)("label",{className:"text-sm font-medium",children:"Runs in"}),(0,O.jsxs)(hw,{value:S,onValueChange:e=>j(e),disabled:M,children:[(0,O.jsx)(hj,{size:"sm",children:(0,O.jsx)(hS,{})}),(0,O.jsxs)(hC,{children:[(0,O.jsx)(hk,{value:"branch",children:"Workspace (branch)"}),(0,O.jsx)(hk,{value:"directory",children:"Directory"})]})]})]}),(0,O.jsx)("div",{className:"space-y-2",children:"branch"===S?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)("label",{className:"text-sm font-medium",children:"Workspace"}),(0,O.jsxs)(hw,{value:C,onValueChange:k,disabled:M,children:[(0,O.jsx)(hj,{size:"sm",children:(0,O.jsx)(hS,{placeholder:"Select workspace"})}),(0,O.jsx)(hC,{children:N.map(e=>(0,O.jsx)(hk,{value:e.branch??hD,children:e.branch??"main"},e.branch??hD))})]})]}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)("label",{className:"text-sm font-medium",children:"Directory"}),(0,O.jsx)(ro,{value:D,onChange:e=>R(e.target.value),placeholder:"/var/log/myapp",className:"font-mono",disabled:M})]})})]}),(0,O.jsxs)("div",{className:"space-y-2",children:[(0,O.jsx)("label",{className:"text-sm font-medium",children:"Timeout (minutes)"}),(0,O.jsx)(ro,{value:A,onChange:e=>T(e.target.value),className:"w-24",disabled:M})]}),P&&(0,O.jsx)("div",{className:"text-sm text-destructive bg-destructive/10 px-3 py-2 rounded-md",children:P})]}),(0,O.jsxs)(rn,{children:[(0,O.jsx)(W.Button,{variant:"outline",onClick:()=>r(!1),disabled:M,children:"Cancel"}),(0,O.jsx)(W.Button,{onClick:B,disabled:M||!o.trim()||!b.trim(),children:M?"Saving...":n?"Save":"Create"})]})]})})}let hA={running:"bg-blue-500/15 text-blue-600",completed:"bg-emerald-500/15 text-emerald-600",failed:"bg-red-500/15 text-red-600",timeout:"bg-amber-500/15 text-amber-600",killed:"bg-amber-500/15 text-amber-600",skipped:"bg-muted text-muted-foreground"},hT=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;function hM(e){return e.replace(hT,"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")}function hF(e){return new Date(e.includes("T")?e:e.replace(" ","T")+"Z")}function hP(e){return e?hF(e).toLocaleString():"—"}function hI(e){if(!e.finished_at)return"…";let r=Math.max(0,Math.round((hF(e.finished_at).getTime()-hF(e.started_at).getTime())/1e3));return r<60?`${r}s`:`${Math.floor(r/60)}m ${r%60}s`}function hB({projectId:e,schedules:r,loading:s,selectedId:n,onSelect:i,worktrees:a,onCreate:o,onUpdate:l,onDelete:c,onRunNow:d,createOpen:u,onCreateOpenChange:h,openRunId:f,onOpenRunHandled:p}){let m=r.find(e=>e.id===n)??r[0]??null,[g,x]=(0,$.useState)([]),[v,_]=(0,$.useState)(!1),[y,b]=(0,$.useState)(null),[w,S]=(0,$.useState)(null),[j,C]=(0,$.useState)(0),[k,N]=(0,$.useState)(null),[E,D]=(0,$.useState)(null),[R,A]=(0,$.useState)(null),T=(0,$.useCallback)(async e=>{try{return await rv.api.getScheduleRuns(e)}catch(e){return console.error("Failed to fetch schedule runs:",e),null}},[]);(0,$.useEffect)(()=>{let e=m?.id,r=!1;return(e?T(e):Promise.resolve([])).then(e=>{if(r)return;let s=e??[];x(s),b(e=>e&&(e===w||s.some(r=>r.id===e&&"skipped"!==r.status))?e:s.find(e=>"skipped"!==e.status)?.id??null)}),()=>{r=!0}},[m?.id,r,T,w]);let M=g.find(e=>e.id===y&&e.schedule_id===m?.id),F=M?`${M.status}:${M.finished_at??""}`:null;(0,$.useEffect)(()=>{if(!y)return;let e=!1;return rv.api.getScheduleRun(y).then(r=>{e||N({runId:y,nonce:j,run:r,error:null})},r=>{e||N({runId:y,nonce:j,run:null,error:r instanceof Error?r.message:"Failed to load run output"})}),()=>{e=!0}},[y,j,F]);let P=async()=>{if(m){D(null);try{await d(m.id)}catch(e){D(e instanceof Error?e.message:"Failed to start run")}}};(0,$.useEffect)(()=>{f&&(S(f),b(f),p?.(f))},[f,p]);let I=m?g.filter(e=>e.schedule_id===m.id):[],B=y===w||I.some(e=>e.id===y&&"skipped"!==e.status),L=B&&k?.runId===y&&k.nonce===j?k:null;return s||0!==r.length?(0,O.jsxs)("div",{className:"flex flex-col h-full",children:[m&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(dh,{title:m.name,description:`${m.cron_expr} \xb7 ${m.timezone} \xb7 next: ${hP(m.next_run_at)}`,actions:(0,O.jsxs)("div",{className:"flex items-center gap-2",children:[(0,O.jsxs)(W.Button,{size:"sm",onClick:P,disabled:!!m.running,children:[(0,O.jsx)(rh,{className:"h-3.5 w-3.5 mr-1.5"}),m.running?"Running…":"Run now"]}),(0,O.jsxs)("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[(0,O.jsx)("input",{type:"checkbox",checked:m.enabled,onChange:e=>void l(m.id,{enabled:e.target.checked}),className:"h-4 w-4 rounded border-input accent-primary"}),(0,O.jsx)("span",{children:"Enabled"})]}),(0,O.jsx)(W.Button,{size:"sm",variant:"outline",onClick:()=>_(!0),children:(0,O.jsx)(rg,{className:"h-3.5 w-3.5"})}),(0,O.jsx)(W.Button,{size:"sm",variant:"outline",onClick:()=>{m&&A(m)},className:"hover:bg-destructive/15 hover:text-destructive",children:(0,O.jsx)(rc,{className:"h-3.5 w-3.5"})})]})}),(0,O.jsxs)("div",{className:"px-5 py-3 grid grid-cols-2 gap-x-8 gap-y-1 text-sm border-b border-border/50",children:[(0,O.jsxs)("div",{children:[(0,O.jsx)("span",{className:"text-muted-foreground",children:"Type: "}),"command"===m.run_type?"Command":`Prompt (${"codex"===m.prompt_provider?"Codex":"Claude"})`]}),(0,O.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,O.jsx)("span",{className:"text-muted-foreground",children:"Runs in: "}),"branch"===m.cwd_mode?`workspace ${m.branch??"main"}`:m.directory,"local"!==m.target&&(0,O.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-violet-500/15 text-violet-600",children:"remote"})]}),(0,O.jsx)("div",{className:"col-span-2 font-mono text-xs text-muted-foreground truncate",title:m.content,children:m.content}),(0,O.jsxs)("div",{children:[(0,O.jsx)("span",{className:"text-muted-foreground",children:"Timeout: "}),Math.round(m.timeout_seconds/60),"m"]})]}),E&&(0,O.jsx)("div",{className:"mx-5 mt-3 text-sm text-destructive bg-destructive/10 px-3 py-2 rounded-md",children:E}),(0,O.jsx)("div",{className:"flex-1 min-h-0",children:(0,O.jsxs)(uj,{direction:"horizontal",autoSaveId:"schedule-run-panels",children:[(0,O.jsx)(dN,{defaultSize:33,minSize:25,children:(0,O.jsx)("div",{className:"h-full overflow-auto px-5 py-3",children:(0,O.jsxs)(uk,{children:[(0,O.jsx)(uN,{children:(0,O.jsxs)(uD,{children:[(0,O.jsx)(uR,{children:"Started"}),(0,O.jsx)(uR,{children:"Duration"}),(0,O.jsx)(uR,{children:"Status"}),(0,O.jsx)(uR,{children:"Exit code"})]})}),(0,O.jsxs)(uE,{children:[I.map(e=>(0,O.jsxs)(uD,{onClick:()=>{"skipped"!==e.status&&(S(null),b(e.id))},"aria-disabled":"skipped"===e.status,className:(0,ey.cn)("skipped"!==e.status&&"cursor-pointer",e.id===y&&"bg-muted/50"),children:[(0,O.jsx)(uA,{children:hP(e.started_at)}),(0,O.jsx)(uA,{children:"skipped"===e.status?"—":hI(e)}),(0,O.jsx)(uA,{children:(0,O.jsx)("span",{className:(0,ey.cn)("px-1.5 py-0.5 rounded text-[11px] font-medium",hA[e.status]),children:e.status})}),(0,O.jsx)(uA,{children:e.exit_code??"—"})]},e.id)),0===I.length&&(0,O.jsx)(uD,{children:(0,O.jsx)(uA,{colSpan:4,className:"text-center text-muted-foreground",children:"No runs yet — click “Run now” to try it"})})]})]})})}),(0,O.jsx)(uC,{withHandle:!0}),(0,O.jsx)(dN,{defaultSize:67,minSize:25,children:(0,O.jsx)("div",{className:"h-full overflow-auto px-5 py-4",children:B&&!L?(0,O.jsx)("div",{className:"h-full flex items-center justify-center text-sm text-muted-foreground",children:"Loading run output…"}):L?.error?(0,O.jsxs)("div",{className:"h-full flex flex-col items-center justify-center gap-3 text-sm",children:[(0,O.jsx)("div",{className:"text-destructive",children:L.error}),(0,O.jsx)(W.Button,{size:"sm",variant:"outline",onClick:()=>C(e=>e+1),children:"Retry"})]}):L?.run?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)("div",{className:"mb-4 pb-3 border-b border-border/60",children:[(0,O.jsxs)("div",{className:"text-sm font-medium",children:[L.run.report?"Run report":"Run output"," — ",hP(L.run.started_at)]}),(0,O.jsxs)("div",{className:"mt-2 flex items-center gap-3 text-xs text-muted-foreground",children:[(0,O.jsx)("span",{className:(0,ey.cn)("px-1.5 py-0.5 rounded text-[11px] font-medium",hA[L.run.status]),children:L.run.status}),(0,O.jsx)("span",{children:hI(L.run)}),(0,O.jsxs)("span",{children:["Exit code: ",L.run.exit_code??"—"]})]})]}),L.run.report?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)("div",{className:"rounded-md border border-border/50 p-3 text-sm",children:(0,O.jsx)(ck.i,{className:"[&>*:first-child]:mt-0 [&>*:last-child]:mb-0",children:L.run.report})}),(0,O.jsxs)("details",{className:"mt-3",children:[(0,O.jsx)("summary",{className:"text-xs text-muted-foreground cursor-pointer select-none",children:"Raw output"}),(0,O.jsx)("pre",{className:"mt-2 overflow-auto rounded-md bg-muted/50 p-3 font-mono text-xs whitespace-pre-wrap",children:L.run.output?hM(L.run.output):"(no output captured)"})]})]}):(0,O.jsx)("pre",{className:"overflow-auto rounded-md bg-muted/50 p-3 font-mono text-xs whitespace-pre-wrap",children:L.run.output?hM(L.run.output):"(no output captured)"})]}):(0,O.jsx)("div",{className:"h-full flex items-center justify-center text-sm text-muted-foreground",children:"Select a run to view its output"})})})]})}),(0,O.jsx)(hR,{open:v,onOpenChange:_,initial:m,onSubmit:async e=>{await l(m.id,e)},worktrees:a,projectId:e})]}),(0,O.jsx)(hR,{open:u,onOpenChange:h,onSubmit:async e=>{i((await o(e)).id)},worktrees:a,projectId:e}),(0,O.jsx)(lL,{open:null!==R,onOpenChange:e=>{e||A(null)},children:(0,O.jsxs)(l$,{children:[(0,O.jsxs)(lW,{children:[(0,O.jsx)(lU,{children:"Delete scheduled task?"}),(0,O.jsx)(lq,{children:R?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)("span",{className:"font-medium text-foreground",children:R.name})," ","and its run history will be permanently deleted. This cannot be undone."]}):null})]}),(0,O.jsxs)(lH,{children:[(0,O.jsx)(lV,{children:"Cancel"}),(0,O.jsx)(lK,{className:(0,ey.cn)((0,W.buttonVariants)({variant:"destructive"}),"border-transparent"),onClick:()=>{A(null),R&&(D(null),c(R.id).catch(e=>{D(e instanceof Error?e.message:"Failed to delete")}))},children:"Delete"})]})]})})]}):(0,O.jsxs)("div",{className:"flex flex-col h-full items-center justify-center gap-3 text-center",children:[(0,O.jsx)(sw,{className:"h-8 w-8 text-muted-foreground/50"}),(0,O.jsx)("p",{className:"text-sm text-muted-foreground",children:"No scheduled tasks yet"}),(0,O.jsx)(W.Button,{size:"sm",onClick:()=>h(!0),children:"New Scheduled Task"}),(0,O.jsx)(hR,{open:u,onOpenChange:h,onSubmit:async e=>{await o(e)},worktrees:a,projectId:e})]})}var hL=e.i(423917);function hz({className:e}){return(0,O.jsx)("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:(0,ey.cn)("h-4 w-4",e),"aria-hidden":"true",children:(0,O.jsx)("path",{d:"M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189z"})})}function hO({inviteUrl:e}){return e?(0,O.jsx)(W.Button,{asChild:!0,variant:"ghost",size:"icon-sm",title:"Join our Discord",children:(0,O.jsx)("a",{href:e,target:"_blank",rel:"noopener noreferrer","aria-label":"Join our Discord",children:(0,O.jsx)(hz,{})})}):null}function h$({open:e,onOpenChange:r,onProjectCreated:s}){let{config:n}=(0,hL.useAppConfig)(),i=n?.localProjectsEnabled!==!1,[a,o]=(0,$.useState)(""),[l,c]=(0,$.useState)(""),[d,u]=(0,$.useState)([]),[h,f]=(0,$.useState)("closed"),[p,m]=(0,$.useState)([]),[g,x]=(0,$.useState)(null),[v,_]=(0,$.useState)(""),[y,b]=(0,$.useState)(!1),[w,S]=(0,$.useState)(""),j=()=>{o(""),c(""),u([]),C(),S("")},C=()=>{f("closed"),x(null),_("")},k=e=>{e||j(),r(e)},N=async()=>{let e=await rv.api.selectFolder();e.path&&(c(e.path),a||o(e.path.split("/").pop()||""))},E=async()=>{f("pick-server");try{let e=await rv.api.getRemoteServers();m(e)}catch{m([])}},D=l.trim().length>0,R=d.length>0,A=async()=>{if(!a.trim())return void S("Project name is required");if(!D&&!R)return void S(i?"Please provide a local folder, remote server, or both":"Please add a remote server");b(!0),S("");try{let e=await rv.api.createProject({name:a.trim(),...D?{path:l.trim()}:{},...R&&!D?{agentMode:d[0].serverId}:{}});for(let r of d)await rv.api.addProjectRemote(e.id,{remoteServerId:r.serverId,remotePath:r.remotePath});s(e),j(),r(!1)}catch(e){S(e instanceof Error?e.message:"Failed to create project")}finally{b(!1)}};return(0,O.jsx)(t8,{open:e,onOpenChange:k,children:(0,O.jsxs)(rr,{className:"max-w-lg h-[620px] max-h-[calc(100vh-4rem)] grid-rows-[auto_minmax(0,1fr)_auto]",children:[(0,O.jsx)(rs,{children:(0,O.jsx)(ri,{children:"Create New Project"})}),(0,O.jsx)("div",{className:"overflow-y-auto -mx-1 px-1",children:(0,O.jsxs)("div",{className:"space-y-5 py-2",children:[(0,O.jsxs)("div",{className:"space-y-2",children:[(0,O.jsx)("label",{className:"text-sm font-medium",children:"Project Name"}),(0,O.jsx)(ro,{value:a,onChange:e=>o(e.target.value),placeholder:"My Project"})]}),i&&(0,O.jsxs)("div",{className:"space-y-2",children:[(0,O.jsx)("label",{className:"text-sm font-medium",children:"Local Folder"}),(0,O.jsxs)("div",{className:"flex gap-2",children:[(0,O.jsx)(ro,{value:l,onChange:e=>c(e.target.value),placeholder:"/path/to/project (optional)",className:"flex-1"}),(0,O.jsx)(W.Button,{variant:"outline",onClick:N,children:(0,O.jsx)(r_,{className:"h-4 w-4"})})]})]}),(0,O.jsxs)("div",{className:"space-y-3",children:[(0,O.jsx)("label",{className:"text-sm font-medium",children:"Remote Servers"}),d.length>0&&(0,O.jsx)("div",{className:"space-y-2",children:d.map((e,r)=>(0,O.jsxs)("div",{className:"flex items-center gap-2 rounded-md border p-2 text-sm",children:[(0,O.jsx)(ry,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,O.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,O.jsx)("p",{className:"font-medium truncate",children:e.serverName}),(0,O.jsx)("p",{className:"text-xs text-muted-foreground font-mono truncate",children:e.remotePath})]}),(0,O.jsx)(W.Button,{variant:"ghost",size:"icon-sm",className:"h-7 w-7 shrink-0",onClick:()=>{u(e=>e.filter((e,s)=>s!==r))},children:(0,O.jsx)(rc,{className:"h-3.5 w-3.5 text-muted-foreground"})})]},`${e.serverId}-${e.remotePath}`))}),"closed"===h&&(0,O.jsxs)(W.Button,{variant:"outline",size:"sm",onClick:E,className:"w-full",children:[(0,O.jsx)(eS,{className:"h-4 w-4 mr-1"}),"Add Remote"]}),"pick-server"===h&&(0,O.jsxs)("div",{className:"rounded-md border p-3 space-y-3",children:[(0,O.jsxs)("div",{className:"flex items-center justify-between",children:[(0,O.jsx)("label",{className:"text-xs font-medium",children:"Select a Remote Server"}),(0,O.jsx)(W.Button,{variant:"ghost",size:"sm",onClick:C,children:(0,O.jsx)(t7,{className:"h-3.5 w-3.5"})})]}),p.length>0&&(0,O.jsx)("div",{className:"space-y-1",children:p.map(e=>(0,O.jsxs)("button",{className:"flex items-center gap-2 w-full rounded-md p-2 text-sm text-left hover:bg-muted",onClick:()=>{x(e),_(""),f("pick-path")},children:[(0,O.jsx)(od,{className:"h-4 w-4 text-muted-foreground"}),(0,O.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,O.jsx)("p",{className:"truncate",children:e.name}),(0,O.jsx)("p",{className:"text-xs text-muted-foreground truncate",children:"online"===e.status?"Connected":"Not connected"})]})]},e.id))}),(0,O.jsx)("p",{className:"text-xs text-muted-foreground",children:"Add new servers in Settings → Remote Servers, then connect the remote machine with a connect token."})]}),"pick-path"===h&&g&&(0,O.jsxs)("div",{className:"rounded-md border p-3 space-y-3",children:[(0,O.jsxs)("div",{className:"flex items-center justify-between",children:[(0,O.jsxs)("label",{className:"text-xs font-medium",children:["Select Directory on ",g.name]}),(0,O.jsx)(W.Button,{variant:"ghost",size:"sm",onClick:C,children:(0,O.jsx)(t7,{className:"h-3.5 w-3.5"})})]}),(0,O.jsx)(oJ,{serverId:g.id,onSelect:e=>{_(e)},selectedPath:v}),v&&(0,O.jsxs)("div",{className:"flex items-center justify-between",children:[(0,O.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Selected: ",(0,O.jsx)("span",{className:"font-mono",children:v})]}),(0,O.jsx)(W.Button,{size:"sm",onClick:()=>{g&&v&&(d.some(e=>e.serverId===g.id&&e.remotePath===v)||(u(e=>[...e,{serverId:g.id,serverName:g.name,remotePath:v}]),a||o(v.split("/").pop()||"")),C())},children:"Add"})]})]})]}),w&&(0,O.jsx)("p",{className:"text-sm text-red-500 pt-3",children:w})]})}),(0,O.jsxs)(rn,{children:[(0,O.jsx)(W.Button,{variant:"outline",onClick:()=>k(!1),children:"Cancel"}),(0,O.jsx)(W.Button,{onClick:A,disabled:y,children:y?"Creating...":"Create Project"})]})]})})}let hW=(0,ew.default)("network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]),hH=(0,ew.default)("palette",[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]]),hU=(0,ew.default)("sparkles",[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]]),hq=(0,ew.default)("square-terminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]),hK=(0,ew.default)("moon",[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]),hV=(0,ew.default)("sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);var hY=e.i(371263),hG=e.i(909596),hX=["PageUp","PageDown"],hJ=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],hZ={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},hQ="Slider",[h0,h1,h2]=rb(hQ),[h5,h3]=q(hQ,[h2]),[h4,h6]=h5(hQ),h7=$.forwardRef((e,r)=>{let{name:s,min:n=0,max:i=100,step:a=1,orientation:o="horizontal",disabled:l=!1,minStepsBetweenThumbs:c=0,defaultValue:d=[n],value:u,onValueChange:h=()=>{},onValueCommit:f=()=>{},inverted:p=!1,form:m,...g}=e,x=$.useRef(new Set),v=$.useRef(0),_="horizontal"===o,[y=[],b]=G({prop:u,defaultProp:d,onChange:e=>{let r=[...x.current];r[v.current]?.focus(),h(e)}}),w=$.useRef(y);function S(e,r,{commit:s}={commit:!1}){let o,l=(String(a).split(".")[1]||"").length,d=oh(Math.round((Math.round((e-n)/a)*a+n)*(o=Math.pow(10,l)))/o,[n,i]);b((e=[])=>{let n=function(e=[],r,s){let n=[...e];return n[s]=r,n.sort((e,r)=>e-r)}(e,d,r);if(!function(e,r){if(r>0)return Math.min(...e.slice(0,-1).map((r,s)=>e[s+1]-r))>=r;return!0}(n,c*a))return e;{v.current=n.indexOf(d);let r=String(n)!==String(e);return r&&s&&f(n),r?n:e}})}return(0,O.jsx)(h4,{scope:e.__scopeSlider,name:s,disabled:l,min:n,max:i,valueIndexToChangeRef:v,thumbs:x.current,values:y,orientation:o,form:m,children:(0,O.jsx)(h0.Provider,{scope:e.__scopeSlider,children:(0,O.jsx)(h0.Slot,{scope:e.__scopeSlider,children:(0,O.jsx)(_?fe:ft,{"aria-disabled":l,"data-disabled":l?"":void 0,...g,ref:r,onPointerDown:K(g.onPointerDown,()=>{l||(w.current=y)}),min:n,max:i,inverted:p,onSlideStart:l?void 0:function(e){let r=function(e,r){if(1===e.length)return 0;let s=e.map(e=>Math.abs(e-r)),n=Math.min(...s);return s.indexOf(n)}(y,e);S(e,r)},onSlideMove:l?void 0:function(e){S(e,v.current)},onSlideEnd:l?void 0:function(){let e=w.current[v.current];y[v.current]!==e&&f(y)},onHomeKeyDown:()=>!l&&S(n,0,{commit:!0}),onEndKeyDown:()=>!l&&S(i,y.length-1,{commit:!0}),onStepKeyDown:({event:e,direction:r})=>{if(!l){let s=hX.includes(e.key)||e.shiftKey&&hJ.includes(e.key),n=v.current;S(y[n]+a*(s?10:1)*r,n,{commit:!0})}}})})})})});h7.displayName=hQ;var[h8,h9]=h5(hQ,{startEdge:"left",endEdge:"right",size:"width",direction:1}),fe=$.forwardRef((e,r)=>{let{min:s,max:n,dir:i,inverted:a,onSlideStart:o,onSlideMove:l,onSlideEnd:c,onStepKeyDown:d,...u}=e,[h,f]=$.useState(null),p=(0,U.useComposedRefs)(r,e=>f(e)),m=$.useRef(void 0),g=rk(i),x="ltr"===g,v=x&&!a||!x&&a;function _(e){let r=m.current||h.getBoundingClientRect(),i=fh([0,r.width],v?[s,n]:[n,s]);return m.current=r,i(e-r.left)}return(0,O.jsx)(h8,{scope:e.__scopeSlider,startEdge:v?"left":"right",endEdge:v?"right":"left",direction:v?1:-1,size:"width",children:(0,O.jsx)(fr,{dir:g,"data-orientation":"horizontal",...u,ref:p,style:{...u.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:e=>{let r=_(e.clientX);o?.(r)},onSlideMove:e=>{let r=_(e.clientX);l?.(r)},onSlideEnd:()=>{m.current=void 0,c?.()},onStepKeyDown:e=>{let r=hZ[v?"from-left":"from-right"].includes(e.key);d?.({event:e,direction:r?-1:1})}})})}),ft=$.forwardRef((e,r)=>{let{min:s,max:n,inverted:i,onSlideStart:a,onSlideMove:o,onSlideEnd:l,onStepKeyDown:c,...d}=e,u=$.useRef(null),h=(0,U.useComposedRefs)(r,u),f=$.useRef(void 0),p=!i;function m(e){let r=f.current||u.current.getBoundingClientRect(),i=fh([0,r.height],p?[n,s]:[s,n]);return f.current=r,i(e-r.top)}return(0,O.jsx)(h8,{scope:e.__scopeSlider,startEdge:p?"bottom":"top",endEdge:p?"top":"bottom",size:"height",direction:p?1:-1,children:(0,O.jsx)(fr,{"data-orientation":"vertical",...d,ref:h,style:{...d.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:e=>{let r=m(e.clientY);a?.(r)},onSlideMove:e=>{let r=m(e.clientY);o?.(r)},onSlideEnd:()=>{f.current=void 0,l?.()},onStepKeyDown:e=>{let r=hZ[p?"from-bottom":"from-top"].includes(e.key);c?.({event:e,direction:r?-1:1})}})})}),fr=$.forwardRef((e,r)=>{let{__scopeSlider:s,onSlideStart:n,onSlideMove:i,onSlideEnd:a,onHomeKeyDown:o,onEndKeyDown:l,onStepKeyDown:c,...d}=e,u=h6(hQ,s);return(0,O.jsx)(er.span,{...d,ref:r,onKeyDown:K(e.onKeyDown,e=>{"Home"===e.key?(o(e),e.preventDefault()):"End"===e.key?(l(e),e.preventDefault()):hX.concat(hJ).includes(e.key)&&(c(e),e.preventDefault())}),onPointerDown:K(e.onPointerDown,e=>{let r=e.target;r.setPointerCapture(e.pointerId),e.preventDefault(),u.thumbs.has(r)?r.focus():n(e)}),onPointerMove:K(e.onPointerMove,e=>{e.target.hasPointerCapture(e.pointerId)&&i(e)}),onPointerUp:K(e.onPointerUp,e=>{let r=e.target;r.hasPointerCapture(e.pointerId)&&(r.releasePointerCapture(e.pointerId),a(e))})})}),fs="SliderTrack",fn=$.forwardRef((e,r)=>{let{__scopeSlider:s,...n}=e,i=h6(fs,s);return(0,O.jsx)(er.span,{"data-disabled":i.disabled?"":void 0,"data-orientation":i.orientation,...n,ref:r})});fn.displayName=fs;var fi="SliderRange",fa=$.forwardRef((e,r)=>{let{__scopeSlider:s,...n}=e,i=h6(fi,s),a=h9(fi,s),o=$.useRef(null),l=(0,U.useComposedRefs)(r,o),c=i.values.length,d=i.values.map(e=>fu(e,i.min,i.max)),u=c>1?Math.min(...d):0,h=100-Math.max(...d);return(0,O.jsx)(er.span,{"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,...n,ref:l,style:{...e.style,[a.startEdge]:u+"%",[a.endEdge]:h+"%"}})});fa.displayName=fi;var fo="SliderThumb",fl=$.forwardRef((e,r)=>{let s=h1(e.__scopeSlider),[n,i]=$.useState(null),a=(0,U.useComposedRefs)(r,e=>i(e)),o=$.useMemo(()=>n?s().findIndex(e=>e.ref.current===n):-1,[s,n]);return(0,O.jsx)(fc,{...e,ref:a,index:o})}),fc=$.forwardRef((e,r)=>{var s,n,i,a,o;let l,c,{__scopeSlider:d,index:u,name:h,...f}=e,p=h6(fo,d),m=h9(fo,d),[g,x]=$.useState(null),v=(0,U.useComposedRefs)(r,e=>x(e)),_=!g||p.form||!!g.closest("form"),y=J(g),b=p.values[u],w=void 0===b?0:fu(b,p.min,p.max),S=(s=u,(n=p.values.length)>2?`Value ${s+1} of ${n}`:2===n?["Minimum","Maximum"][s]:void 0),j=y?.[m.size],C=j?(i=j,a=w,o=m.direction,c=fh([0,50],[0,l=i/2]),(l-c(a)*o)*o):0;return $.useEffect(()=>{if(g)return p.thumbs.add(g),()=>{p.thumbs.delete(g)}},[g,p.thumbs]),(0,O.jsxs)("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[m.startEdge]:`calc(${w}% + ${C}px)`},children:[(0,O.jsx)(h0.ItemSlot,{scope:e.__scopeSlider,children:(0,O.jsx)(er.span,{role:"slider","aria-label":e["aria-label"]||S,"aria-valuemin":p.min,"aria-valuenow":b,"aria-valuemax":p.max,"aria-orientation":p.orientation,"data-orientation":p.orientation,"data-disabled":p.disabled?"":void 0,tabIndex:p.disabled?void 0:0,...f,ref:v,style:void 0===b?{display:"none"}:e.style,onFocus:K(e.onFocus,()=>{p.valueIndexToChangeRef.current=u})})}),_&&(0,O.jsx)(fd,{name:h??(p.name?p.name+(p.values.length>1?"[]":""):void 0),form:p.form,value:b},u)]})});fl.displayName=fo;var fd=$.forwardRef(({__scopeSlider:e,value:r,...s},n)=>{let i=$.useRef(null),a=(0,U.useComposedRefs)(i,n),o=X(r);return $.useEffect(()=>{let e=i.current;if(!e)return;let s=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value").set;if(o!==r&&s){let n=new Event("input",{bubbles:!0});s.call(e,r),e.dispatchEvent(n)}},[o,r]),(0,O.jsx)(er.input,{style:{display:"none"},...s,ref:a,defaultValue:r})});function fu(e,r,s){return oh(100/(s-r)*(e-r),[0,100])}function fh(e,r){return s=>{if(e[0]===e[1]||r[0]===r[1])return r[0];let n=(r[1]-r[0])/(e[1]-e[0]);return r[0]+n*(s-e[0])}}fd.displayName="RadioBubbleInput";let ff=$.forwardRef(({className:e,...r},s)=>(0,O.jsxs)(h7,{ref:s,className:(0,ey.cn)("relative flex w-full touch-none select-none items-center","data-[disabled]:opacity-50",e),...r,children:[(0,O.jsx)(fn,{className:"relative h-1.5 w-full grow overflow-hidden rounded-full bg-muted",children:(0,O.jsx)(fa,{className:"absolute h-full bg-primary"})}),(0,O.jsx)(fl,{className:(0,ey.cn)("block h-4 w-4 rounded-full border border-primary/60 bg-card shadow-[var(--shadow-sm-app)]","transition-colors hover:border-primary","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40 focus-visible:ring-offset-1 focus-visible:ring-offset-background"),"aria-label":"Value"})]}));function fp({id:e,label:r,description:s,rightSlot:n,children:i}){return(0,O.jsxs)("section",{id:e,className:"scroll-mt-6 rounded-[10px] border border-border bg-card p-5 shadow-[var(--shadow-sm-app)]",children:[(0,O.jsxs)("header",{className:"flex items-end justify-between gap-3 pb-3 mb-4 border-b border-border/70",children:[(0,O.jsxs)("div",{className:"min-w-0",children:[(0,O.jsx)("h2",{className:"text-[10.5px] font-semibold uppercase tracking-[0.08em] text-muted-foreground/80 leading-none",children:r}),s&&(0,O.jsx)("p",{className:"mt-2 text-[12px] text-muted-foreground/90 leading-snug",children:s})]}),n&&(0,O.jsx)("div",{className:"shrink-0",children:n})]}),(0,O.jsx)("div",{className:"space-y-4",children:i})]})}function fm({label:e,hint:r,htmlFor:s,mono:n,children:i}){return(0,O.jsxs)("div",{children:[(0,O.jsx)("label",{htmlFor:s,className:(0,ey.cn)("block text-[12px] font-medium text-foreground/90 mb-1.5",n&&"font-mono tracking-tight"),children:e}),i,r&&(0,O.jsx)("p",{className:"mt-1.5 text-[11px] text-muted-foreground/85 leading-relaxed",children:r})]})}function fg({name:e,value:r,options:s,onChange:n,columns:i=1}){return(0,O.jsx)("div",{className:(0,ey.cn)("grid gap-2",1===i&&"grid-cols-1",2===i&&"grid-cols-1 sm:grid-cols-2",3===i&&"grid-cols-1 sm:grid-cols-3"),role:"radiogroup",children:s.map(s=>{let i=r===s.value,a=s.Icon;return(0,O.jsxs)("label",{className:(0,ey.cn)("group relative flex items-start gap-3 px-3 py-2.5 rounded-[8px] border cursor-pointer","transition-[border-color,background-color,box-shadow] duration-150","focus-within:ring-2 focus-within:ring-ring/40 focus-within:ring-offset-1 focus-within:ring-offset-background",i?"border-primary/40 bg-[color-mix(in_oklch,var(--primary)_8%,var(--card))] shadow-[var(--shadow-sm-app)]":"border-border/70 bg-card hover:border-border hover:bg-muted/40"),children:[(0,O.jsx)("input",{type:"radio",name:e,value:s.value,checked:i,onChange:()=>n(s.value),className:"sr-only"}),(0,O.jsx)("span",{"aria-hidden":!0,className:(0,ey.cn)("mt-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",i?"border-primary bg-primary":"border-border bg-card group-hover:border-foreground/40"),children:i&&(0,O.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-primary-foreground"})}),a&&(0,O.jsx)(a,{className:(0,ey.cn)("h-4 w-4 mt-0.5 shrink-0 transition-colors",i?"text-primary":"text-muted-foreground")}),(0,O.jsxs)("span",{className:"flex-1 min-w-0",children:[(0,O.jsx)("span",{className:(0,ey.cn)("block text-[12.5px] font-medium leading-tight",i?"text-foreground":"text-foreground/90"),children:s.label}),s.description&&(0,O.jsx)("span",{className:"mt-0.5 block text-[11.5px] text-muted-foreground leading-snug",children:s.description})]}),s.meta&&(0,O.jsx)("span",{className:"ml-2 mt-0.5 shrink-0 font-mono text-[10.5px] text-muted-foreground/80",children:s.meta})]},s.value)})})}function fx({variant:e="default",icon:r,children:s}){return(0,O.jsxs)("div",{className:(0,ey.cn)("flex items-center gap-2 rounded-[6px] px-2.5 py-1.5 text-[12px]","default"===e&&"text-muted-foreground bg-muted/40","success"===e&&"text-[color:var(--chart-2)] bg-[color-mix(in_oklch,var(--chart-2)_10%,var(--card))] border border-[color-mix(in_oklch,var(--chart-2)_25%,transparent)]","error"===e&&"text-destructive bg-[color-mix(in_oklch,var(--destructive)_8%,var(--card))] border border-[color-mix(in_oklch,var(--destructive)_25%,transparent)]"),children:[r&&(0,O.jsx)("span",{className:"shrink-0",children:r}),(0,O.jsx)("span",{className:"truncate",children:s})]})}function fv({children:e}){return(0,O.jsx)("div",{className:"flex items-center justify-end gap-2 pt-1",children:e})}function f_({nav:e,children:r}){let[s,n]=(0,$.useState)(e[0]?.id??""),i=(0,$.useRef)(null);return(0,$.useEffect)(()=>{let r=i.current;if(!r)return;let s=()=>{let s=r.getBoundingClientRect(),i=s.top+.25*s.height,a=e[0]?.id??"";for(let s of e){let e=r.querySelector(`#${CSS.escape(s.id)}`);e&&e.getBoundingClientRect().top<=i&&(a=s.id)}n(a)};return s(),r.addEventListener("scroll",s,{passive:!0}),()=>r.removeEventListener("scroll",s)},[e]),(0,O.jsxs)("div",{className:"flex-1 min-h-0 grid grid-cols-[200px_minmax(0,1fr)] overflow-hidden",children:[(0,O.jsx)("aside",{className:"border-r border-border bg-[color:var(--sidebar)] overflow-y-auto",children:(0,O.jsx)("nav",{className:"p-3 flex flex-col gap-0.5",children:e.map(e=>{let r=e.Icon,a=s===e.id;return(0,O.jsxs)("button",{type:"button",onClick:()=>(e=>{let r=i.current;if(!r)return;let s=r.querySelector(`#${CSS.escape(e)}`);if(!s)return;let a=s.offsetTop-12;r.scrollTo({top:a,behavior:"smooth"}),n(e)})(e.id),className:(0,ey.cn)("group relative flex items-center gap-2.5 w-full px-2.5 py-1.5 rounded-[6px] text-[12.5px] text-left","transition-colors duration-100",a?"bg-card text-foreground font-medium shadow-[var(--shadow-sm-app)]":"text-muted-foreground hover:bg-muted/50 hover:text-foreground"),children:[a&&(0,O.jsx)("span",{"aria-hidden":!0,className:"absolute -left-3 top-1.5 bottom-1.5 w-[2px] rounded-full bg-primary"}),r&&(0,O.jsx)(r,{className:(0,ey.cn)("h-3.5 w-3.5 shrink-0",a?"text-foreground":"text-muted-foreground/80")}),(0,O.jsx)("span",{className:"truncate",children:e.label}),e.badge&&(0,O.jsx)("span",{className:"ml-auto font-mono text-[10px] text-muted-foreground/80",children:e.badge})]},e.id)})})}),(0,O.jsx)("div",{ref:i,className:"overflow-y-auto",children:(0,O.jsx)("div",{className:"mx-auto max-w-2xl px-8 py-7 space-y-6",children:r})})]})}ff.displayName="Slider";let fy=[{value:"light",label:"Light",description:"Bright surface, true-white cards",Icon:hV},{value:"dark",label:"Dark",description:"Low-light surfaces with deep neutrals",Icon:hK},{value:"system",label:"System",description:"Match your OS preference",Icon:oc}],{fontSizeMin:fb,fontSizeMax:fw}=rv.CONVERSATION_SETTINGS_LIMITS;function fS(){let{theme:e,setTheme:r}=(0,hY.useTheme)(),{settings:s,setAgentFontSize:n,setChatFontSize:i,setFilesTreeFontSize:a,setFilesContentFontSize:o}=(0,hG.useConversationSettings)();return(0,O.jsxs)("div",{className:"space-y-6",children:[(0,O.jsx)(fm,{label:"Theme",hint:"Sets the surface palette across the app. Switching is instant.",children:(0,O.jsx)(fg,{name:"theme",value:e,options:fy,onChange:r,columns:3})}),(0,O.jsx)(fm,{label:"Conversation font size",hint:"Independent typography for agent and chat views. Affects message body and tool output; chrome elements stay fixed.",children:(0,O.jsxs)("div",{className:"space-y-5",children:[(0,O.jsx)(fj,{label:"Agent conversation",value:s.agentFontSize,onChange:n}),(0,O.jsx)(fj,{label:"Chat session",value:s.chatFontSize,onChange:i})]})}),(0,O.jsx)(fm,{label:"Files font size",hint:"Independent typography for the Files tab. File tree controls the file list and search results; file content controls the preview and code.",children:(0,O.jsxs)("div",{className:"space-y-5",children:[(0,O.jsx)(fj,{label:"File tree, File search",value:s.filesTreeFontSize,onChange:a}),(0,O.jsx)(fj,{label:"File content",value:s.filesContentFontSize,onChange:o})]})}),(0,O.jsx)(fv,{children:(0,O.jsx)(W.Button,{variant:"ghost",size:"sm",onClick:()=>{n(rv.DEFAULT_CONVERSATION_SETTINGS.agentFontSize),i(rv.DEFAULT_CONVERSATION_SETTINGS.chatFontSize),a(rv.DEFAULT_CONVERSATION_SETTINGS.filesTreeFontSize),o(rv.DEFAULT_CONVERSATION_SETTINGS.filesContentFontSize)},children:"Reset"})})]})}function fj({label:e,value:r,onChange:s}){return(0,O.jsxs)("div",{children:[(0,O.jsxs)("div",{className:"flex items-baseline justify-between mb-1.5",children:[(0,O.jsx)("span",{className:"text-[12px] font-medium text-foreground/90",children:e}),(0,O.jsxs)("span",{className:"font-mono text-[11.5px] text-foreground/80 tabular-nums",children:[r," px"]})]}),(0,O.jsx)(ff,{min:fb,max:fw,step:1,value:[r],onValueChange:e=>s(e[0])}),(0,O.jsxs)("div",{className:"flex justify-between mt-1 text-[10.5px] text-muted-foreground/80 font-mono",children:[(0,O.jsx)("span",{children:fb}),(0,O.jsx)("span",{children:fw})]})]})}let fC=(0,ew.default)("waypoints",[["circle",{cx:"12",cy:"4.5",r:"2.5",key:"r5ysbb"}],["path",{d:"m10.2 6.3-3.9 3.9",key:"1nzqf6"}],["circle",{cx:"4.5",cy:"12",r:"2.5",key:"jydg6v"}],["path",{d:"M7 12h10",key:"b7w52i"}],["circle",{cx:"19.5",cy:"12",r:"2.5",key:"1piiel"}],["path",{d:"m13.8 17.7 3.9-3.9",key:"1wyg1y"}],["circle",{cx:"12",cy:"19.5",r:"2.5",key:"13o1pw"}]]),fk={deepseek:hU,openrouter:fC},fN=rv.PROVIDER_IDS.map(e=>({value:e,label:rv.PROVIDERS[e].label,description:"deepseek"===e?"Direct API access — lowest latency":"Aggregator routing — many models available",Icon:fk[e]}));function fE({name:e,value:r,onChange:s}){let n=rv.PROVIDERS[r.provider];return(0,O.jsxs)("div",{className:"space-y-3",children:[(0,O.jsx)(fg,{name:e,value:r.provider,options:fN,onChange:e=>s((0,rv.defaultModelChoice)(e)),columns:2}),n.models?(0,O.jsxs)(hw,{value:r.model,onValueChange:e=>s({...r,model:e}),children:[(0,O.jsx)(hj,{className:"w-full font-mono text-[12.5px]",children:(0,O.jsx)(hS,{})}),(0,O.jsx)(hC,{children:n.models.map(e=>(0,O.jsx)(hk,{value:e,className:"font-mono text-[12.5px]",children:n.modelLabels?.[e]??e},e))})]}):(0,O.jsx)(ro,{className:"font-mono text-[12.5px]",placeholder:n.placeholder,value:r.model,onChange:e=>s({...r,model:e.target.value})})]})}function fD(){let[e,r]=(0,$.useState)(()=>(0,rv.defaultChatProviderConfig)().apiKeys),[s,n]=(0,$.useState)(()=>({deepseek:!1,openrouter:!1})),[i,a]=(0,$.useState)(()=>(0,rv.defaultModelChoice)()),[o,l]=(0,$.useState)(()=>(0,rv.defaultModelChoice)()),[c,d]=(0,$.useState)(!0),[u,h]=(0,$.useState)(!1),[f,p]=(0,$.useState)(null);(0,$.useEffect)(()=>{d(!0),rv.api.getChatProviderSettings().then(e=>{r(e.apiKeys),a(e.main),l(e.fast),n({deepseek:!1,openrouter:!1})}).finally(()=>d(!1))},[]);let m=async()=>{h(!0),p(null);try{let c={};for(let r of rv.PROVIDER_IDS)s[r]&&(c[r]=e[r]);let d={main:i,fast:o};Object.keys(c).length>0&&(d.apiKeys=c);let u=await rv.api.updateChatProviderSettings(d);r(u.apiKeys),a(u.main),l(u.fast),n({deepseek:!1,openrouter:!1}),p("Settings saved"),setTimeout(()=>p(null),2e3)}catch(e){p(e instanceof Error?e.message:"Failed to save")}finally{h(!1)}};return c?(0,O.jsx)("div",{className:"flex items-center justify-center py-6",children:(0,O.jsx)(sj,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):(0,O.jsxs)("div",{className:"space-y-6",children:[(0,O.jsxs)("div",{className:"space-y-4",children:[(0,O.jsx)("p",{className:"text-[12px] font-medium text-foreground/70",children:"API keys"}),rv.PROVIDER_IDS.map(i=>{let a=rv.PROVIDERS[i],o=s[i],l=e[i];return(0,O.jsx)(fm,{label:`${a.label} API key`,mono:!0,hint:(0,O.jsxs)(O.Fragment,{children:["Leave empty to fall back to the"," ",(0,O.jsx)("code",{className:"font-mono text-[10.5px] bg-muted/60 border border-border/60 rounded px-1 py-px",children:a.envKey})," ","environment variable."]}),children:(0,O.jsx)(ro,{type:"password",className:"font-mono text-[12px]",placeholder:l&&!o?l:"sk-...",value:o?l:"",onChange:e=>{var s;return s=e.target.value,void(r(e=>({...e,[i]:s})),n(e=>({...e,[i]:!0})),p(null))}})},i)})]}),(0,O.jsx)(fm,{label:"Main model",hint:"Powers the chat session.",children:(0,O.jsx)(fE,{name:"main-provider",value:i,onChange:e=>{a(e),p(null)}})}),(0,O.jsx)(fm,{label:"Fast model",hint:"Powers translate and agent session titles. Can use a different provider than the main model.",children:(0,O.jsx)(fE,{name:"fast-provider",value:o,onChange:e=>{l(e),p(null)}})}),f&&(0,O.jsx)(fx,{variant:"Settings saved"===f?"success":"error",icon:"Settings saved"===f?(0,O.jsx)(sJ,{className:"h-3.5 w-3.5"}):(0,O.jsx)(s0,{className:"h-3.5 w-3.5"}),children:f}),(0,O.jsx)(fv,{children:(0,O.jsxs)(W.Button,{size:"sm",onClick:m,disabled:u,children:[u&&(0,O.jsx)(sj,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Save"]})})]})}let fR=[{value:"none",label:"Direct",description:"No proxy — connect directly to the internet",Icon:(0,ew.default)("shield-off",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71",key:"1jlk70"}],["path",{d:"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",key:"18rp1v"}]])},{value:"http",label:"HTTP / HTTPS",description:"Route through an HTTP CONNECT proxy",Icon:hW},{value:"socks5",label:"SOCKS5",description:"Route through a SOCKS5 proxy server",Icon:fC}];function fA(){let[e,r]=(0,$.useState)("none"),[s,n]=(0,$.useState)(""),[i,a]=(0,$.useState)(""),[o,l]=(0,$.useState)(!0),[c,d]=(0,$.useState)(!1),[u,h]=(0,$.useState)(!1),[f,p]=(0,$.useState)(null),[m,g]=(0,$.useState)(null);(0,$.useEffect)(()=>{l(!0),p(null),g(null),rv.api.getProxySettings().then(e=>{r(e.type),n(e.host),a(e.port?String(e.port):"")}).finally(()=>l(!1))},[]);let x=()=>({type:e,host:"none"===e?"":s.trim(),port:"none"===e?0:parseInt(i,10)||0}),v=async()=>{h(!0),p(null);try{p(await rv.api.testProxyConnection(x()))}catch(e){p({success:!1,message:e instanceof Error?e.message:"Test failed"})}finally{h(!1)}},_=async()=>{d(!0),g(null);try{await rv.api.updateProxySettings(x()),g("Settings saved"),setTimeout(()=>g(null),2e3)}catch(e){g(e instanceof Error?e.message:"Failed to save")}finally{d(!1)}},y="none"!==e;return o?(0,O.jsx)("div",{className:"flex items-center justify-center py-6",children:(0,O.jsx)(sj,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):(0,O.jsxs)("div",{className:"space-y-4",children:[(0,O.jsx)(fm,{label:"Connection mode",children:(0,O.jsx)(fg,{name:"proxyType",value:e,options:fR,onChange:e=>{r(e),p(null),g(null)}})}),y&&(0,O.jsxs)("div",{className:"grid grid-cols-[1fr_120px] gap-3",children:[(0,O.jsx)(fm,{label:"Host",mono:!0,children:(0,O.jsx)(ro,{placeholder:"127.0.0.1",value:s,className:"font-mono text-[12.5px]",onChange:e=>{n(e.target.value),p(null),g(null)}})}),(0,O.jsx)(fm,{label:"Port",mono:!0,children:(0,O.jsx)(ro,{type:"number",placeholder:"1080",value:i,className:"font-mono text-[12.5px]",onChange:e=>{a(e.target.value),p(null),g(null)},min:1,max:65535})})]}),f&&(0,O.jsx)(fx,{variant:f.success?"success":"error",icon:f.success?(0,O.jsx)(sJ,{className:"h-3.5 w-3.5"}):(0,O.jsx)(s0,{className:"h-3.5 w-3.5"}),children:f.message??(f.success?"Connection succeeded":"Connection failed")}),m&&!f&&(0,O.jsx)(fx,{variant:"Settings saved"===m?"success":"error",icon:"Settings saved"===m?(0,O.jsx)(sJ,{className:"h-3.5 w-3.5"}):(0,O.jsx)(s0,{className:"h-3.5 w-3.5"}),children:m}),(0,O.jsxs)(fv,{children:[y&&(0,O.jsxs)(W.Button,{variant:"outline",size:"sm",onClick:v,disabled:u||!s.trim()||!i,children:[u&&(0,O.jsx)(sj,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Test connection"]}),(0,O.jsxs)(W.Button,{size:"sm",onClick:_,disabled:c,children:[c&&(0,O.jsx)(sj,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Save"]})]})]})}var fT=e.i(276949);let{scrollbackMin:fM,scrollbackMax:fF,fontSizeMin:fP,fontSizeMax:fI}=rv.TERMINAL_SETTINGS_LIMITS;function fB(){let{settings:e,loaded:r,refresh:s}=(0,fT.useTerminalSettings)(),[n,i]=(0,$.useState)(String(rv.DEFAULT_TERMINAL_SETTINGS.scrollback)),[a,o]=(0,$.useState)(String(rv.DEFAULT_TERMINAL_SETTINGS.fontSize)),[l,c]=(0,$.useState)(rv.DEFAULT_TERMINAL_SETTINGS.fontFamily),[d,u]=(0,$.useState)(!1),[h,f]=(0,$.useState)(null);(0,$.useEffect)(()=>{r&&(i(String(e.scrollback)),o(String(e.fontSize)),c(e.fontFamily))},[r,e.scrollback,e.fontSize,e.fontFamily]);let p=parseInt(n,10),m=parseInt(a,10),g=Number.isFinite(p)&&p>=fM&&p<=fF,x=Number.isFinite(m)&&m>=fP&&m<=fI,v=""!==l.trim(),_=g&&x&&v,y=async()=>{if(_){u(!0),f(null);try{let e={scrollback:p,fontSize:m,fontFamily:l.trim()};await rv.api.updateTerminalSettings(e),await s(),f("Settings saved"),setTimeout(()=>f(null),2e3)}catch(e){f(e instanceof Error?e.message:"Failed to save")}finally{u(!1)}}};return r?(0,O.jsxs)("div",{className:"space-y-4",children:[(0,O.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,O.jsx)(fm,{label:"Scrollback",mono:!0,hint:(0,O.jsxs)("span",{children:["Lines kept in buffer."," ",(0,O.jsxs)("span",{className:"font-mono text-foreground/70",children:[fM,"–",fF]})," · default ",(0,O.jsx)("span",{className:"font-mono text-foreground/70",children:rv.DEFAULT_TERMINAL_SETTINGS.scrollback})]}),children:(0,O.jsx)(ro,{type:"number",min:fM,max:fF,value:n,className:"font-mono text-[12.5px]",onChange:e=>{i(e.target.value),f(null)}})}),(0,O.jsx)(fm,{label:"Font size",mono:!0,hint:(0,O.jsxs)("span",{children:["Pixels."," ",(0,O.jsxs)("span",{className:"font-mono text-foreground/70",children:[fP,"–",fI]})," · default ",(0,O.jsx)("span",{className:"font-mono text-foreground/70",children:rv.DEFAULT_TERMINAL_SETTINGS.fontSize})]}),children:(0,O.jsx)(ro,{type:"number",min:fP,max:fI,value:a,className:"font-mono text-[12.5px]",onChange:e=>{o(e.target.value),f(null)}})})]}),(0,O.jsx)(fm,{label:"Font family",mono:!0,hint:"CSS font-family list. Use monospace fonts for column alignment.",children:(0,O.jsx)(ro,{value:l,className:"font-mono text-[12px]",onChange:e=>{c(e.target.value),f(null)},placeholder:rv.DEFAULT_TERMINAL_SETTINGS.fontFamily})}),h&&(0,O.jsx)(fx,{variant:"Settings saved"===h?"success":"error",icon:"Settings saved"===h?(0,O.jsx)(sJ,{className:"h-3.5 w-3.5"}):(0,O.jsx)(s0,{className:"h-3.5 w-3.5"}),children:h}),(0,O.jsxs)(fv,{children:[(0,O.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>{i(String(rv.DEFAULT_TERMINAL_SETTINGS.scrollback)),o(String(rv.DEFAULT_TERMINAL_SETTINGS.fontSize)),c(rv.DEFAULT_TERMINAL_SETTINGS.fontFamily),f(null)},disabled:d,children:"Reset"}),(0,O.jsxs)(W.Button,{size:"sm",onClick:y,disabled:d||!_,children:[d&&(0,O.jsx)(sj,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Save"]})]})]}):(0,O.jsx)("div",{className:"flex items-center justify-center py-6",children:(0,O.jsx)(sj,{className:"h-4 w-4 animate-spin text-muted-foreground"})})}let{min:fL,max:fz}=rv.AGENT_PROCESS_SETTINGS_LIMITS;function fO(){let[e,r]=(0,$.useState)(String(rv.DEFAULT_AGENT_PROCESS_SETTINGS.maxResidentAgentProcesses)),[s,n]=(0,$.useState)(!1),[i,a]=(0,$.useState)(!1),[o,l]=(0,$.useState)(null);(0,$.useEffect)(()=>{let e=!1;return(0,rv.getAgentProcessSettings)().then(s=>{e||(r(String(s.maxResidentAgentProcesses)),n(!0))}).catch(r=>{e||(l(r instanceof Error?r.message:"Failed to load settings"),n(!0))}),()=>{e=!0}},[]);let c=parseInt(e,10),d=Number.isInteger(c)&&c>=fL&&c<=fz,u=async()=>{if(d){a(!0),l(null);try{let e=await (0,rv.updateAgentProcessSettings)({maxResidentAgentProcesses:c});r(String(e.maxResidentAgentProcesses)),l("Settings saved"),setTimeout(()=>l(null),2e3)}catch(e){l(e instanceof Error?e.message:"Failed to save")}finally{a(!1)}}};return s?(0,O.jsxs)("div",{className:"space-y-4",children:[(0,O.jsx)(fm,{label:"Resident agent processes",mono:!0,hint:(0,O.jsxs)("span",{children:["Live local or remote agent processes per server."," ",(0,O.jsxs)("span",{className:"font-mono text-foreground/70",children:[fL,"–",fz]})," · default ",(0,O.jsx)("span",{className:"font-mono text-foreground/70",children:rv.DEFAULT_AGENT_PROCESS_SETTINGS.maxResidentAgentProcesses})]}),children:(0,O.jsxs)("div",{className:"flex items-center gap-2 max-w-[220px]",children:[(0,O.jsx)(sb,{className:"h-4 w-4 text-muted-foreground"}),(0,O.jsx)(ro,{type:"number",min:fL,max:fz,value:e,className:"font-mono text-[12.5px]",onChange:e=>{r(e.target.value),l(null)}})]})}),o&&(0,O.jsx)(fx,{variant:"Settings saved"===o?"success":"error",icon:"Settings saved"===o?(0,O.jsx)(sJ,{className:"h-3.5 w-3.5"}):(0,O.jsx)(s0,{className:"h-3.5 w-3.5"}),children:o}),(0,O.jsxs)(fv,{children:[(0,O.jsx)(W.Button,{variant:"outline",size:"sm",onClick:()=>{r(String(rv.DEFAULT_AGENT_PROCESS_SETTINGS.maxResidentAgentProcesses)),l(null)},disabled:i,children:"Reset"}),(0,O.jsxs)(W.Button,{size:"sm",onClick:u,disabled:i||!d,children:[i&&(0,O.jsx)(sj,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Save"]})]})]}):(0,O.jsx)("div",{className:"flex items-center justify-center py-6",children:(0,O.jsx)(sj,{className:"h-4 w-4 animate-spin text-muted-foreground"})})}let f$=[{id:"appearance",label:"Appearance",Icon:hH},{id:"ai-chat",label:"AI Chat",Icon:hU},{id:"agents",label:"Agents",Icon:sb},{id:"terminal",label:"Terminal",Icon:hq},{id:"proxy",label:"Proxy",Icon:hW}];function fW(){let{config:e}=(0,hL.useAppConfig)(),[r]=(0,$.useState)(rv.getPersistedConfig),s=(e??r)?.authEnabled!==!1,n=s?f$.filter(e=>"proxy"!==e.id):f$;return(0,O.jsxs)("div",{className:"h-full flex flex-col overflow-hidden",children:[(0,O.jsx)(dh,{title:"Settings",description:"Theme, intelligence, terminal, and network preferences."}),(0,O.jsxs)(f_,{nav:n,children:[(0,O.jsx)(fp,{id:"appearance",label:"Appearance",description:"Visual surface for the workspace. Affects every view.",children:(0,O.jsx)(fS,{})}),(0,O.jsx)(fp,{id:"ai-chat",label:"AI Chat",description:"Provider, credentials, and default model used for the orchestrator chat.",children:(0,O.jsx)(fD,{})}),(0,O.jsx)(fp,{id:"agents",label:"Agents",description:"Resident coding-agent process limits per workspace branch.",children:(0,O.jsx)(fO,{})}),(0,O.jsx)(fp,{id:"terminal",label:"Terminal",description:"Buffer size and typography for the executor terminal.",children:(0,O.jsx)(fB,{})}),!s&&(0,O.jsx)(fp,{id:"proxy",label:"Proxy",description:"Outbound network routing for AI providers and remote servers.",children:(0,O.jsx)(fA,{})})]})]})}let fH=(0,ew.default)("plug-zap",[["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m18 3-4 4h6l-4 4",key:"16psg9"}]]),fU=(0,ew.default)("key-round",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);var fq=e.i(710307);let fK=(0,ew.default)("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]),fV={name:""};function fY(){let[e,r]=(0,$.useState)([]),[s,n]=(0,$.useState)(!0),[i,a]=(0,$.useState)(""),[o,l]=(0,$.useState)(!1),[c,d]=(0,$.useState)(null),[u,h]=(0,$.useState)(fV),[f,p]=(0,$.useState)(""),[m,g]=(0,$.useState)(!1),[x,v]=(0,$.useState)(null),[_,y]=(0,$.useState)(!1),[b,w]=(0,$.useState)({}),[S,j]=(0,$.useState)({}),[C,k]=(0,$.useState)(null),[N,E]=(0,$.useState)(null),[D,R]=(0,$.useState)(null),[A,T]=(0,$.useState)(!1),[M,F]=(0,$.useState)(!1),[P,I]=(0,$.useState)(!1),[B,L]=(0,$.useState)(!1),z=(0,$.useRef)(null),H=(0,$.useCallback)(async()=>{try{let e=await rv.api.getRemoteServers();r(e),a("")}catch(e){a(e instanceof Error?e.message:"Failed to load servers")}finally{n(!1)}},[]);(0,$.useEffect)(()=>{H()},[H]),(0,$.useEffect)(()=>{let e=setInterval(H,15e3),r=()=>H();return window.addEventListener("focus",r),()=>{clearInterval(e),window.removeEventListener("focus",r)}},[H]);let U=async()=>{if(!u.name.trim())return void p("Name is required");g(!0),p("");try{c?u.name.trim()!==c.name&&await rv.api.updateRemoteServer(c.id,{name:u.name.trim()}):await rv.api.createRemoteServer({name:u.name.trim()}),l(!1),await H()}catch(e){p(e instanceof Error?e.message:"Failed to save server")}finally{g(!1)}},q=async()=>{if(x){y(!0);try{await rv.api.deleteRemoteServer(x.id),v(null),await H()}catch(e){p(e instanceof Error?e.message:"Failed to delete server")}finally{y(!1)}}},K=async e=>{w(r=>({...r,[e.id]:"testing"})),j(r=>{let s={...r};return delete s[e.id],s});try{let r=await rv.api.testRemoteServer(e.id);w(s=>({...s,[e.id]:r.success?"success":"error"})),r.success||j(r=>({...r,[e.id]:"Connection failed"}))}catch(r){w(r=>({...r,[e.id]:"error"})),j(s=>({...s,[e.id]:r instanceof Error?r.message:"Test failed"}))}},V=async e=>{z.current=e.id,k(e),E(null),R(null),F(!1),L(!1),I(!1),T(!0);try{let r=await rv.api.getRemoteServerConnectToken(e.id);if(z.current!==e.id)return;E(r.token),R(r.connectCommand)}catch(r){if(z.current!==e.id)return;z.current=null,p(r instanceof Error?r.message:"Failed to load token"),k(null)}finally{z.current===e.id&&T(!1)}},Y=async e=>{I(!0),F(!1);try{let r=await rv.api.rotateRemoteServerConnectToken(e.id);z.current===e.id&&(E(r.token),R(r.connectCommand),L(!1)),await H()}catch(e){a(e instanceof Error?e.message:"Failed to rotate token")}finally{z.current===e.id&&I(!1)}},G=async e=>{try{await rv.api.revokeRemoteServerConnectToken(e.id),await H()}catch(e){a(e instanceof Error?e.message:"Failed to revoke token")}},X=async(e,s)=>{try{let n=await rv.api.updateRemoteServer(e.id,{crossRemoteAccess:s});r(e=>e.map(e=>e.id===n.id?n:e))}catch(e){a(e instanceof Error?e.message:"Failed to update access")}},J="Update the vibedeckx package on the worker machine, then restart `vibedeckx connect`.";return s?(0,O.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,O.jsx)(sj,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):(0,O.jsxs)("div",{className:"space-y-4",children:[(0,O.jsxs)("div",{className:"flex items-center justify-between",children:[(0,O.jsxs)("div",{children:[(0,O.jsx)("h3",{className:"text-sm font-medium",children:"Remote Servers"}),(0,O.jsx)("p",{className:"text-xs text-muted-foreground",children:"Manage globally available remote servers"})]}),(0,O.jsxs)(W.Button,{variant:"outline",size:"sm",onClick:()=>{d(null),h(fV),p(""),l(!0)},children:[(0,O.jsx)(eS,{className:"h-4 w-4 mr-1.5"}),"Add Server"]})]}),i&&(0,O.jsx)("p",{className:"text-sm text-red-500",children:i}),0===e.length?(0,O.jsxs)("div",{className:"text-center py-8 text-sm text-muted-foreground border rounded-md",children:[(0,O.jsx)(ry,{className:"h-8 w-8 mx-auto mb-2 opacity-40"}),"No remote servers configured"]}):(0,O.jsxs)(uk,{children:[(0,O.jsx)(uN,{children:(0,O.jsxs)(uD,{children:[(0,O.jsx)(uR,{children:"Name"}),(0,O.jsx)(uR,{children:"Status"}),(0,O.jsx)(uR,{children:"Cross-remote access"}),(0,O.jsx)(uR,{className:"w-[180px] text-right",children:"Actions"})]})}),(0,O.jsx)(uE,{children:e.map(e=>{let r,s;return(0,O.jsxs)(uD,{children:[(0,O.jsx)(uA,{className:"font-medium",children:(0,O.jsxs)("div",{className:"flex items-center",children:[(r="online"===e.status,(0,O.jsx)("span",{className:`inline-block h-2.5 w-2.5 rounded-full mr-2 ${r?"bg-green-500":"bg-gray-400"}`,title:r?"Online":"Offline"})),e.name]})}),(0,O.jsxs)(uA,{className:"font-mono text-xs text-muted-foreground",children:[(0,O.jsx)("div",{children:"online"===e.status?"Connected":"Waiting for connection..."}),(e=>{if(!e.worker_version)return e.last_connected_at?(0,O.jsx)("div",{className:"mt-0.5 text-[11px] text-muted-foreground",title:J,children:"version unknown · upgrade recommended"}):null;let r="behind-min"===e.worker_update_status?(0,O.jsx)("span",{className:"text-red-500",title:J,children:"upgrade required"}):"behind-latest"===e.worker_update_status?(0,O.jsxs)("span",{className:"text-amber-500",title:J,children:["update available → v",e.latest_worker_version]}):null;return(0,O.jsxs)("div",{className:"mt-0.5 text-[11px]",children:[(0,O.jsxs)("span",{className:"text-muted-foreground",children:["v",e.worker_version]}),r&&(0,O.jsx)("span",{className:"ml-1.5",children:r})]})})(e)]}),(0,O.jsx)(uA,{children:(0,O.jsxs)(hw,{value:e.cross_remote_access,onValueChange:r=>X(e,r),children:[(0,O.jsx)(hj,{className:"w-[190px] text-[12.5px]",children:(0,O.jsx)(hS,{})}),(0,O.jsxs)(hC,{children:[(0,O.jsx)(hk,{value:"off",className:"text-[12.5px]",children:"Off"}),(0,O.jsx)(hk,{value:"read",className:"text-[12.5px]",children:"Diagnostic read"}),(0,O.jsx)(hk,{value:"exec",className:"text-[12.5px]",children:"Command execution"})]})]})}),(0,O.jsxs)(uA,{className:"text-right",children:[(0,O.jsxs)("div",{className:"flex items-center justify-end gap-1",children:[(0,O.jsx)(W.Button,{variant:"ghost",size:"icon",onClick:()=>V(e),title:"Connect token",className:"h-8 w-8",children:(0,O.jsx)(fU,{className:"h-4 w-4"})}),(s=b[e.id]||"idle",(0,O.jsx)(W.Button,{variant:"ghost",size:"icon",onClick:()=>K(e),disabled:"testing"===s,title:"Test connection",className:"h-8 w-8",children:"testing"===s?(0,O.jsx)(sj,{className:"h-4 w-4 animate-spin"}):"success"===s?(0,O.jsx)(rf.Check,{className:"h-4 w-4 text-green-500"}):"error"===s?(0,O.jsx)(t7,{className:"h-4 w-4 text-red-500"}):(0,O.jsx)(fH,{className:"h-4 w-4"})})),(0,O.jsx)(W.Button,{variant:"ghost",size:"icon",onClick:()=>{d(e),h({name:e.name}),p(""),l(!0)},title:"Edit server",className:"h-8 w-8",children:(0,O.jsx)(rg,{className:"h-4 w-4"})}),(0,O.jsx)(W.Button,{variant:"ghost",size:"icon",onClick:()=>v(e),title:"Delete server",className:"h-8 w-8 text-destructive hover:text-destructive",children:(0,O.jsx)(rc,{className:"h-4 w-4"})})]}),S[e.id]&&(0,O.jsx)("p",{className:"text-xs text-red-500 mt-1 text-right",children:S[e.id]})]})]},e.id)})})]}),(0,O.jsxs)("p",{className:"text-xs text-muted-foreground",children:["When enabled, agents running on your other machines can reach this one.",(0,O.jsx)("strong",{children:" Diagnostic read"})," exposes files, directories and the process list — including any secrets in logs and config files.",(0,O.jsx)("strong",{children:" Command execution"})," additionally allows arbitrary shell commands. Off by default."]}),(0,O.jsx)(t8,{open:o,onOpenChange:l,children:(0,O.jsxs)(rr,{className:"sm:max-w-md",children:[(0,O.jsxs)(rs,{children:[(0,O.jsx)(ri,{children:c?"Edit Server":"Add Remote Server"}),(0,O.jsx)(ra,{children:c?"Update the server name.":"Add a new remote server, then generate a connect token and run the connect command on the remote machine."})]}),(0,O.jsxs)("div",{className:"space-y-4",children:[(0,O.jsxs)("div",{className:"space-y-2",children:[(0,O.jsx)("label",{className:"text-sm font-medium",children:"Name"}),(0,O.jsx)(ro,{value:u.name,onChange:e=>{h(r=>({...r,name:e.target.value})),p("")},placeholder:"My Remote Server"})]}),f&&(0,O.jsx)("p",{className:"text-sm text-red-500",children:f})]}),(0,O.jsxs)(rn,{children:[(0,O.jsx)(W.Button,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),(0,O.jsxs)(W.Button,{onClick:U,disabled:m,children:[m&&(0,O.jsx)(sj,{className:"h-4 w-4 mr-1.5 animate-spin"}),c?"Save Changes":"Add Server"]})]})]})}),(0,O.jsx)(t8,{open:null!==C,onOpenChange:e=>{e||(z.current=null,k(null),E(null),R(null),L(!1))},children:(0,O.jsxs)(rr,{className:"sm:max-w-lg",children:[(0,O.jsxs)(rs,{children:[(0,O.jsx)(ri,{children:"Connect Token"}),(0,O.jsxs)(ra,{children:["Use this token to connect a remote node to"," ",(0,O.jsx)("span",{className:"font-semibold",children:C?.name}),". It stays the same every time you open this dialog — rotate it to issue a replacement."]})]}),A?(0,O.jsx)("div",{className:"flex items-center justify-center py-4",children:(0,O.jsx)(sj,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):N?(0,O.jsx)("div",{className:"space-y-4",children:(0,O.jsxs)("div",{className:"space-y-2",children:[(0,O.jsx)("label",{className:"text-sm font-medium",children:"Connect Command"}),(0,O.jsxs)("div",{className:"flex gap-2",children:[(0,O.jsx)(ro,{readOnly:!0,value:D||"",className:"font-mono text-xs"}),(0,O.jsx)(W.Button,{variant:"outline",size:"icon",className:"shrink-0",onClick:()=>{var e;return e=D||"",void(navigator.clipboard.writeText(e),F(!0),setTimeout(()=>F(!1),2e3))},title:"Copy command",children:M?(0,O.jsx)(rf.Check,{className:"h-4 w-4 text-green-500"}):(0,O.jsx)(fq.Copy,{className:"h-4 w-4"})})]}),(0,O.jsx)("p",{className:"text-xs text-muted-foreground",children:"Run this command on the remote machine to establish the reverse connection."}),B&&(0,O.jsx)("p",{className:"text-xs text-destructive",children:"Rotating invalidates the current token immediately. Any worker still using it will fail to reconnect until you re-run the new command."})]})}):null,(0,O.jsxs)(rn,{children:[N&&C&&(0,O.jsxs)("div",{className:"mr-auto flex items-center gap-2",children:[(0,O.jsxs)(W.Button,{variant:"outline",disabled:P,onClick:()=>{B?Y(C):L(!0)},children:[P?(0,O.jsx)(sj,{className:"mr-2 h-4 w-4 animate-spin"}):(0,O.jsx)(fK,{className:"mr-2 h-4 w-4"}),B?"Confirm rotate":"Rotate Token"]}),(0,O.jsx)(W.Button,{variant:"outline",className:"text-destructive hover:text-destructive",onClick:()=>{G(C),z.current=null,k(null),E(null)},children:"Revoke Token"})]}),(0,O.jsx)(W.Button,{variant:"outline",onClick:()=>{z.current=null,k(null),E(null),R(null),L(!1)},children:"Close"})]})]})}),(0,O.jsx)(t8,{open:null!==x,onOpenChange:e=>{e||v(null)},children:(0,O.jsxs)(rr,{className:"sm:max-w-sm",children:[(0,O.jsxs)(rs,{children:[(0,O.jsx)(ri,{children:"Delete Server"}),(0,O.jsxs)(ra,{children:["Are you sure you want to delete"," ",(0,O.jsx)("span",{className:"font-semibold",children:x?.name}),"? This will also remove it from any projects that reference it."]})]}),(0,O.jsxs)(rn,{children:[(0,O.jsx)(W.Button,{variant:"outline",onClick:()=>v(null),children:"Cancel"}),(0,O.jsxs)(W.Button,{variant:"destructive",onClick:q,disabled:_,children:[_&&(0,O.jsx)(sj,{className:"h-4 w-4 mr-1.5 animate-spin"}),"Delete"]})]})]})})]})}function fG({projectId:e,project:r,open:s,onOpenChange:n,onWorktreeCreated:i}){let[a,o]=(0,$.useState)(""),[l,c]=(0,$.useState)(!1),[d,u]=(0,$.useState)(null),[h,f]=(0,$.useState)(null),[p,m]=(0,$.useState)(!0),[g,x]=(0,$.useState)(!0),[v,_]=(0,$.useState)([]),[y,b]=(0,$.useState)([]),[w,S]=(0,$.useState)("main"),[j,C]=(0,$.useState)("main"),[k,N]=(0,$.useState)(!1),E=!!(r.path&&r.remote_path);(0,$.useEffect)(()=>{s&&(N(!0),E?Promise.all([rv.api.getProjectBranches(e,"local"),rv.api.getProjectBranches(e,"remote")]).then(([e,r])=>{_(e),b(r),S(e.includes("main")?"main":e[0]||"main"),C(r.includes("main")?"main":r[0]||"main"),N(!1)}):rv.api.getProjectBranches(e).then(e=>{_(e),S(e.includes("main")?"main":e[0]||"main"),N(!1)}))},[s,e,E]);let D=async()=>{if(a.trim()){c(!0),u(null),f(null);try{let r;E&&(r=[],p&&r.push("local"),g&&r.push("remote"));let s=await rv.api.createWorktree(e,a.trim(),r,w,E?j:void 0);if(s.partialSuccess){let e,r=s.results?.remote?.success===!1?"remote":"local",n=s.results?.[r],i=n?.error||"Unknown error",a=n?.errorCode,o=n?.requestId;switch(a){case"timeout":e="Connection to remote server timed out. The remote server may be slow or unreachable.";break;case"network_error":e="Remote server is not connected. Run the connect command on the remote machine (Settings → Remote Servers → connect token).";break;case"auth_error":e="Authentication failed with remote server. Copy the current connect command (Settings → Remote Servers → connect token) and re-run it on the remote machine; rotate the token only if you need to replace it.";break;case"server_error":e=`Remote server returned an error: ${i}`;break;default:e=`Worktree created locally, but ${r} creation failed: ${i}`}o&&(e+=` (Request ID: ${o})`),f(e)}i(s.worktree.branch),s.partialSuccess||(n(!1),o(""))}catch(e){u(e instanceof Error?e.message:"Failed to create worktree")}finally{c(!1)}}},R=e=>{e||(o(""),u(null),f(null),m(!0),x(!0),_([]),b([]),S("main"),C("main")),n(e)},A=(e,r,s,n)=>(0,O.jsxs)(hw,{value:r,onValueChange:s,disabled:n||k,children:[(0,O.jsx)(hj,{size:"sm",children:(0,O.jsx)(hS,{placeholder:k?"Loading...":"Select branch"})}),(0,O.jsx)(hC,{children:e.map(e=>(0,O.jsx)(hk,{value:e,children:e},e))})]});return(0,O.jsx)(t8,{open:s,onOpenChange:R,children:(0,O.jsxs)(rr,{children:[(0,O.jsxs)(rs,{children:[(0,O.jsx)(ri,{children:"Create New Worktree"}),(0,O.jsx)(ra,{children:"Create a new branch based on an existing branch"})]}),(0,O.jsxs)("div",{className:"space-y-4",children:[(0,O.jsxs)("div",{className:"space-y-2",children:[(0,O.jsx)("label",{htmlFor:"branch-name",className:"text-sm font-medium",children:"Branch Name"}),(0,O.jsx)(ro,{id:"branch-name",placeholder:"feature/my-feature",value:a,onChange:e=>o(e.target.value),disabled:l,onKeyDown:e=>{"Enter"===e.key&&a.trim()&&(!E||p||g)&&D()}})]}),E?(0,O.jsxs)("div",{className:"space-y-2",children:[(0,O.jsx)("label",{className:"text-sm font-medium",children:"Create On"}),(0,O.jsxs)("div",{className:"space-y-2",children:[(0,O.jsxs)("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[(0,O.jsx)("input",{type:"checkbox",checked:p,onChange:e=>{(e.target.checked||g)&&m(e.target.checked)},disabled:l,className:"h-4 w-4 rounded border-input accent-primary"}),(0,O.jsx)("span",{children:"Local"}),(0,O.jsx)("span",{className:"text-muted-foreground truncate text-xs",children:r.path})]}),p&&v.length>0&&(0,O.jsxs)("div",{className:"ml-6",children:[(0,O.jsx)("label",{className:"text-xs text-muted-foreground",children:"Base Branch"}),A(v,w,S,l)]}),(0,O.jsxs)("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[(0,O.jsx)("input",{type:"checkbox",checked:g,onChange:e=>{(e.target.checked||p)&&x(e.target.checked)},disabled:l,className:"h-4 w-4 rounded border-input accent-primary"}),(0,O.jsx)("span",{children:"Remote"}),(0,O.jsx)("span",{className:"text-muted-foreground truncate text-xs",children:r.remote_path})]}),g&&y.length>0&&(0,O.jsxs)("div",{className:"ml-6",children:[(0,O.jsx)("label",{className:"text-xs text-muted-foreground",children:"Base Branch"}),A(y,j,C,l)]})]})]}):v.length>0&&(0,O.jsxs)("div",{className:"space-y-2",children:[(0,O.jsx)("label",{className:"text-sm font-medium",children:"Base Branch"}),A(v,w,S,l)]}),h&&(0,O.jsx)("div",{className:"text-sm text-yellow-600 dark:text-yellow-500 bg-yellow-500/10 px-3 py-2 rounded-md",children:h}),d&&(0,O.jsx)("div",{className:"text-sm text-destructive bg-destructive/10 px-3 py-2 rounded-md",children:d})]}),(0,O.jsxs)(rn,{children:[(0,O.jsx)(W.Button,{variant:"outline",onClick:()=>R(!1),disabled:l,children:"Cancel"}),(0,O.jsx)(W.Button,{onClick:D,disabled:!a.trim()||l||E&&!p&&!g,children:l?"Creating...":"Create"})]})]})})}function fX({projectId:e,worktree:r,open:s,onOpenChange:n,onWorktreeDeleted:i}){let[a,o]=(0,$.useState)(!1),[l,c]=(0,$.useState)(null),[d,u]=(0,$.useState)(null),h=async()=>{if(r){o(!0),c(null),u(null);try{let s=await rv.api.deleteWorktree(e,r.branch);if(s.partialSuccess){let e=s.results?.remote?.error||"Unknown error";u(`Local worktree deleted, but remote deletion failed: ${e}`)}i(),s.partialSuccess||n(!1)}catch(e){c(e instanceof Error?e.message:"Failed to delete worktree")}finally{o(!1)}}},f=e=>{e||(c(null),u(null)),n(e)};return(0,O.jsx)(t8,{open:s,onOpenChange:f,children:(0,O.jsxs)(rr,{children:[(0,O.jsxs)(rs,{children:[(0,O.jsx)(ri,{children:"Delete Worktree"}),(0,O.jsx)(ra,{children:"Are you sure you want to delete this worktree?"})]}),r&&(0,O.jsx)("div",{className:"space-y-2",children:(0,O.jsxs)("div",{className:"text-sm",children:[(0,O.jsx)("span",{className:"font-medium",children:"Branch:"})," ",(0,O.jsx)("span",{className:"text-muted-foreground",children:r.branch})]})}),d&&(0,O.jsx)("div",{className:"text-sm text-yellow-600 dark:text-yellow-500 bg-yellow-500/10 px-3 py-2 rounded-md",children:d}),l&&(0,O.jsx)("div",{className:"text-sm text-destructive bg-destructive/10 px-3 py-2 rounded-md",children:l}),(0,O.jsxs)(rn,{children:[(0,O.jsx)(W.Button,{variant:"outline",onClick:()=>f(!1),disabled:a,children:"Cancel"}),(0,O.jsx)(W.Button,{variant:"destructive",onClick:h,disabled:a,children:a?"Deleting...":"Delete"})]})]})})}e.i(247755);var fJ=e.i(642098);function fZ(){let{config:e}=(0,hL.useAppConfig)();return e?.authEnabled?(0,O.jsx)("div",{className:"flex items-center",children:(0,O.jsx)(fJ.UserButton,{appearance:{elements:{avatarBox:"h-7 w-7 ring-1 ring-border/60"}}})}):null}var fQ=e.i(183663),f0="Collapsible",[f1,f2]=q(f0),[f5,f3]=f1(f0),f4=$.forwardRef((e,r)=>{let{__scopeCollapsible:s,open:n,defaultOpen:i,disabled:a,onOpenChange:o,...l}=e,[c,d]=G({prop:n,defaultProp:i??!1,onChange:o,caller:f0});return(0,O.jsx)(f5,{scope:s,disabled:a,contentId:ek(),open:c,onOpenToggle:$.useCallback(()=>d(e=>!e),[d]),children:(0,O.jsx)(er.div,{"data-state":pt(c),"data-disabled":a?"":void 0,...l,ref:r})})});f4.displayName=f0;var f6="CollapsibleTrigger",f7=$.forwardRef((e,r)=>{let{__scopeCollapsible:s,...n}=e,i=f3(f6,s);return(0,O.jsx)(er.button,{type:"button","aria-controls":i.contentId,"aria-expanded":i.open||!1,"data-state":pt(i.open),"data-disabled":i.disabled?"":void 0,disabled:i.disabled,...n,ref:r,onClick:K(e.onClick,i.onOpenToggle)})});f7.displayName=f6;var f8="CollapsibleContent",f9=$.forwardRef((e,r)=>{let{forceMount:s,...n}=e,i=f3(f8,e.__scopeCollapsible);return(0,O.jsx)(Z,{present:s||i.open,children:({present:e})=>(0,O.jsx)(pe,{...n,ref:r,present:e})})});f9.displayName=f8;var pe=$.forwardRef((e,r)=>{let{__scopeCollapsible:s,present:n,children:i,...a}=e,o=f3(f8,s),[l,c]=$.useState(n),d=$.useRef(null),u=(0,U.useComposedRefs)(r,d),h=$.useRef(0),f=h.current,p=$.useRef(0),m=p.current,g=o.open||l,x=$.useRef(g),v=$.useRef(void 0);return $.useEffect(()=>{let e=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(e)},[]),V(()=>{let e=d.current;if(e){v.current=v.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration="0s",e.style.animationName="none";let r=e.getBoundingClientRect();h.current=r.height,p.current=r.width,x.current||(e.style.transitionDuration=v.current.transitionDuration,e.style.animationName=v.current.animationName),c(n)}},[o.open,n]),(0,O.jsx)(er.div,{"data-state":pt(o.open),"data-disabled":o.disabled?"":void 0,id:o.contentId,hidden:!g,...a,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:g&&i})});function pt(e){return e?"open":"closed"}function pr({...e}){return(0,O.jsx)(f4,{"data-slot":"collapsible",...e})}function ps({...e}){return(0,O.jsx)(f7,{"data-slot":"collapsible-trigger",...e})}function pn({...e}){return(0,O.jsx)(f9,{"data-slot":"collapsible-content",...e})}let pi=(0,ew.default)("ellipsis-vertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]),pa=(0,ew.default)("ban",[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);var po=e.i(885101),pl=Object.defineProperty,pc=Object.getOwnPropertyDescriptor,pd=(e,r,s,n)=>{for(var i,a=n>1?void 0:n?pc(r,s):r,o=e.length-1;o>=0;o--)(i=e[o])&&(a=(n?i(r,s,a):i(a))||a);return n&&a&&pl(r,s,a),a},pu=(e,r)=>(s,n)=>r(s,n,e),ph="Terminal input",pf="Too much output to announce, navigate to rows manually to read";function pp(e,r,s,n){var i;i=e=e.replace(/\r?\n/g,"\r"),e=s.decPrivateModes.bracketedPasteMode&&!0!==n.rawOptions.ignoreBracketedPasteMode?"\x1b[200~"+i+"\x1b[201~":i,s.triggerDataEvent(e,!0),r.value=""}function pm(e,r,s){let n=s.getBoundingClientRect(),i=e.clientX-n.left-10,a=e.clientY-n.top-10;r.style.width="20px",r.style.height="20px",r.style.left=`${i}px`,r.style.top=`${a}px`,r.style.zIndex="1000",r.focus()}function pg(e,r,s,n,i){pm(e,r,s),i&&n.rightClickSelect(e),r.value=n.selectionText,r.select()}function px(e){return e>65535?String.fromCharCode(((e-=65536)>>10)+55296)+String.fromCharCode(e%1024+56320):String.fromCharCode(e)}function pv(e,r=0,s=e.length){let n="";for(let i=r;i<s;++i){let r=e[i];r>65535?(r-=65536,n+=String.fromCharCode((r>>10)+55296)+String.fromCharCode(r%1024+56320)):n+=String.fromCharCode(r)}return n}var p_=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,r){let s=e.length;if(!s)return 0;let n=0,i=0;if(this._interim){let s=e.charCodeAt(i++);56320<=s&&s<=57343?r[n++]=(this._interim-55296)*1024+s-56320+65536:(r[n++]=this._interim,r[n++]=s),this._interim=0}for(let a=i;a<s;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=s)return this._interim=i,n;let o=e.charCodeAt(a);56320<=o&&o<=57343?r[n++]=(i-55296)*1024+o-56320+65536:(r[n++]=i,r[n++]=o);continue}65279!==i&&(r[n++]=i)}return n}},py=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,r){let s=e.length;if(!s)return 0;let n=0,i,a,o,l,c=0,d=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(224&a)==192?31:(240&a)==224?15:7;let o=0,l;for(;(l=63&this.interim[++o])&&o<4;)a<<=6,a|=l;let c=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,u=c-o;for(;d<u;){if(d>=s)return 0;if((192&(l=e[d++]))!=128){d--,i=!0;break}this.interim[o++]=l,a<<=6,a|=63&l}i||(2===c?a<128?d--:r[n++]=a:3===c?a<2048||a>=55296&&a<=57343||65279===a||(r[n++]=a):a<65536||a>1114111||(r[n++]=a)),this.interim.fill(0)}let u=s-4,h=d;for(;h<s;){for(;h<u&&!(128&(i=e[h]))&&!(128&(a=e[h+1]))&&!(128&(o=e[h+2]))&&!(128&(l=e[h+3]));)r[n++]=i,r[n++]=a,r[n++]=o,r[n++]=l,h+=4;if((i=e[h++])<128)r[n++]=i;else if((224&i)==192){if(h>=s)return this.interim[0]=i,n;if((192&(a=e[h++]))!=128||(c=(31&i)<<6|63&a)<128){h--;continue}r[n++]=c}else if((240&i)==224){if(h>=s)return this.interim[0]=i,n;if((192&(a=e[h++]))!=128){h--;continue}if(h>=s)return this.interim[0]=i,this.interim[1]=a,n;if((192&(o=e[h++]))!=128){h--;continue}if((c=(15&i)<<12|(63&a)<<6|63&o)<2048||c>=55296&&c<=57343||65279===c)continue;r[n++]=c}else if((248&i)==240){if(h>=s)return this.interim[0]=i,n;if((192&(a=e[h++]))!=128){h--;continue}if(h>=s)return this.interim[0]=i,this.interim[1]=a,n;if((192&(o=e[h++]))!=128){h--;continue}if(h>=s)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,n;if((192&(l=e[h++]))!=128){h--;continue}if((c=(7&i)<<18|(63&a)<<12|(63&o)<<6|63&l)<65536||c>1114111)continue;r[n++]=c}}return n}},pb=class e{constructor(){this.fg=0,this.bg=0,this.extended=new pw}static toColorRGB(e){return[e>>>16&255,e>>>8&255,255&e]}static fromColorRGB(e){return(255&e[0])<<16|(255&e[1])<<8|255&e[2]}clone(){let r=new e;return r.fg=this.fg,r.bg=this.bg,r.extended=this.extended.clone(),r}isInverse(){return 0x4000000&this.fg}isBold(){return 0x8000000&this.fg}isUnderline(){return this.hasExtendedAttrs()&&0!==this.extended.underlineStyle?1:0x10000000&this.fg}isBlink(){return 0x20000000&this.fg}isInvisible(){return 0x40000000&this.fg}isItalic(){return 0x4000000&this.bg}isDim(){return 0x8000000&this.bg}isStrikethrough(){return 0x80000000&this.fg}isProtected(){return 0x20000000&this.bg}isOverline(){return 0x40000000&this.bg}getFgColorMode(){return 0x3000000&this.fg}getBgColorMode(){return 0x3000000&this.bg}isFgRGB(){return(0x3000000&this.fg)==0x3000000}isBgRGB(){return(0x3000000&this.bg)==0x3000000}isFgPalette(){return(0x3000000&this.fg)==0x1000000||(0x3000000&this.fg)==0x2000000}isBgPalette(){return(0x3000000&this.bg)==0x1000000||(0x3000000&this.bg)==0x2000000}isFgDefault(){return(0x3000000&this.fg)==0}isBgDefault(){return(0x3000000&this.bg)==0}isAttributeDefault(){return 0===this.fg&&0===this.bg}getFgColor(){switch(0x3000000&this.fg){case 0x1000000:case 0x2000000:return 255&this.fg;case 0x3000000:return 0xffffff&this.fg;default:return -1}}getBgColor(){switch(0x3000000&this.bg){case 0x1000000:case 0x2000000:return 255&this.bg;case 0x3000000:return 0xffffff&this.bg;default:return -1}}hasExtendedAttrs(){return 0x10000000&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-0x10000001:this.bg|=0x10000000}getUnderlineColor(){if(0x10000000&this.bg&&~this.extended.underlineColor)switch(0x3000000&this.extended.underlineColor){case 0x1000000:case 0x2000000:return 255&this.extended.underlineColor;case 0x3000000:return 0xffffff&this.extended.underlineColor}return this.getFgColor()}getUnderlineColorMode(){return 0x10000000&this.bg&&~this.extended.underlineColor?0x3000000&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 0x10000000&this.bg&&~this.extended.underlineColor?(0x3000000&this.extended.underlineColor)==0x3000000:this.isFgRGB()}isUnderlineColorPalette(){return 0x10000000&this.bg&&~this.extended.underlineColor?(0x3000000&this.extended.underlineColor)==0x1000000||(0x3000000&this.extended.underlineColor)==0x2000000:this.isFgPalette()}isUnderlineColorDefault(){return 0x10000000&this.bg&&~this.extended.underlineColor?(0x3000000&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 0x10000000&this.fg?0x10000000&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},pw=class e{constructor(e=0,r=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=r}get ext(){return this._urlId?-0x1c000001&this._ext|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(0x1c000000&this._ext)>>26}set underlineStyle(e){this._ext&=-0x1c000001,this._ext|=e<<26&0x1c000000}get underlineColor(){return 0x3ffffff&this._ext}set underlineColor(e){this._ext&=-0x4000000,this._ext|=0x3ffffff&e}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(0xe0000000&this._ext)>>29;return e<0?0xfffffff8^e:e}set underlineVariantOffset(e){this._ext&=0x1fffffff,this._ext|=e<<29&0xe0000000}clone(){return new e(this._ext,this._urlId)}isEmpty(){return 0===this.underlineStyle&&0===this._urlId}},pS=class e extends pb{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new pw,this.combinedData=""}static fromCharData(r){let s=new e;return s.setFromCharData(r),s}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?px(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(e){this.fg=e[0],this.bg=0;let r=!1;if(e[1].length>2)r=!0;else if(2===e[1].length){let s=e[1].charCodeAt(0);if(55296<=s&&s<=56319){let n=e[1].charCodeAt(1);56320<=n&&n<=57343?this.content=(s-55296)*1024+n-56320+65536|e[2]<<22:r=!0}else r=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;r&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},pj="di$target",pC="di$dependencies",pk=new Map;function pN(e){if(pk.has(e))return pk.get(e);let r=function(e,s,n){var i,a,o;if(3!=arguments.length)throw Error("@IServiceName-decorator can only be used to decorate a parameter");i=r,a=e,o=n,a[pj]===a?a[pC].push({id:i,index:o}):(a[pC]=[{id:i,index:o}],a[pj]=a)};return r._id=e,pk.set(e,r),r}var pE=pN("BufferService"),pD=pN("CoreMouseService"),pR=pN("CoreService"),pA=pN("CharsetService"),pT=pN("InstantiationService"),pM=pN("LogService"),pF=pN("OptionsService"),pP=pN("OscLinkService"),pI=pN("UnicodeService"),pB=pN("DecorationService"),pL=class{constructor(e,r,s){this._bufferService=e,this._optionsService=r,this._oscLinkService=s}provideLinks(e,r){let s=this._bufferService.buffer.lines.get(e-1);if(!s)return void r(void 0);let n=[],i=this._optionsService.rawOptions.linkHandler,a=new pS,o=s.getTrimmedLength(),l=-1,c=-1,d=!1;for(let r=0;r<o;r++)if(!(-1===c&&!s.hasContent(r))){if(s.loadCell(r,a),a.hasExtendedAttrs()&&a.extended.urlId)if(-1===c){c=r,l=a.extended.urlId;continue}else d=a.extended.urlId!==l;else -1!==c&&(d=!0);if(d||-1!==c&&r===o-1){let s=this._oscLinkService.getLinkData(l)?.uri;if(s){let a={start:{x:c+1,y:e},end:{x:r+ +(!d&&r===o-1),y:e}},l=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(s);["http:","https:"].includes(e.protocol)||(l=!0)}catch{l=!0}l||n.push({text:s,range:a,activate:(e,r)=>i?i.activate(e,r,a):function(e,r){if(confirm(`Do you want to navigate to ${r}?
12
12
 
13
13
  WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=r}else console.warn("Opening link blocked as opener could not be cleared")}}(0,r),hover:(e,r)=>i?.hover?.(e,r,a),leave:(e,r)=>i?.leave?.(e,r,a)})}d=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=r,l=a.extended.urlId):(c=-1,l=-1)}}r(n)}};pL=pd([pu(0,pE),pu(1,pF),pu(2,pP)],pL);var pz=pN("CharSizeService"),pO=pN("CoreBrowserService"),p$=pN("MouseService"),pW=pN("RenderService"),pH=pN("SelectionService"),pU=pN("CharacterJoinerService"),pq=pN("ThemeService"),pK=pN("LinkProviderService"),pV=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?pJ.isErrorNoTelemetry(e)?new pJ(e.message+`
14
14