meshy-node 0.4.8 → 0.5.1

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.
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesTab-Df2rONWU.js","assets/index-BTt-f5gu.js","assets/index-BOC8nP24.css","assets/folder-CnYt_riY.js","assets/file-poOm2y0S.js","assets/PreviewTab-DrEmvcr6.js","assets/play-BdE-NaVD.js","assets/DiffTab-F1C8JivT.js","assets/DashboardShared-CCcAFCLs.js"])))=>i.map(i=>d[i]);
2
- import{c as fe,r as t,j as e,a as Ka,b as M,d as qa,e as Wa,D as Rt,f as Ga,g as $t,B as Ae,I as Fe,h as Ja,i as O,X as He,k as Ya,l as Xa,C as es,m as Qa,n as Za,F as en,o as ss,S as ge,p as ts,q as sn,s as tn,t as pe,u as Se,v as Ce,w as Me,x as Te,y as Ws,z as Ke,T as Gs,A as Ft,E as an,G as nn,H as Ot,J as It,K as Ge,L as Bt,M as zt,N as Ut,P as rn,O as Vt,Q as ze,R as on,U as Ue,V as _s,W as Ds,Y as As,Z as Ms,_ as Ls,$ as Ps,a0 as Rs,a1 as $s,a2 as Js,a3 as ln,a4 as Ss,a5 as ht,a6 as ms,a7 as dn,a8 as cn,a9 as un,aa as xn,ab as mn,ac as hn,ad as Ht,ae as Kt,af as qt,ag as pn,ah as hs,ai as fn,aj as gn,ak as bn,al as pt,am as vn,an as jn,ao as Nn,ap as ft,aq as kn,ar as wn,as as yn,at as Sn,au as Cn,av as Tn,aw as En,ax as _n,ay as Wt,az as Dn,aA as An,aB as Mn,aC as Ln,aD as Pn,aE as Rn,aF as $n,aG as Fn,aH as On,aI as In,aJ as Bn,aK as zn,aL as Un,aM as Vn,aN as Hn,aO as Kn,aP as qn,aQ as Wn,aR as Gn,aS as Jn,aT as Yn,aU as Xn,aV as Qn}from"./index-BTt-f5gu.js";import{r as gt,e as Zn,b as Gt,t as Jt,L as be,C as bt,a as er,T as Cs,D as We,I as Re,M as Fs,c as Yt,m as Xt,d as Qt,f as sr,g as vt,h as tr,i as ar,j as Ts,k as nr,n as rr,l as or}from"./DashboardShared-CCcAFCLs.js";import{F as ir}from"./folder-CnYt_riY.js";import{P as lr}from"./play-BdE-NaVD.js";/**
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesTab-BCF4QVC7.js","assets/index-BzTROrJe.js","assets/index-BOC8nP24.css","assets/folder-CiTzsQ19.js","assets/file-CivHJbXQ.js","assets/PreviewTab-kHR8XJHu.js","assets/play-Bn74sNWK.js","assets/DiffTab-CHex6isk.js","assets/DashboardShared-CfKjChkE.js"])))=>i.map(i=>d[i]);
2
+ import{c as fe,r as t,j as e,a as Ka,b as M,d as qa,e as Wa,D as Rt,f as Ga,g as $t,B as Ae,I as Fe,h as Ja,i as O,X as He,k as Ya,l as Xa,C as es,m as Qa,n as Za,F as en,o as ss,S as ge,p as ts,q as sn,s as tn,t as pe,u as Se,v as Ce,w as Me,x as Te,y as Ws,z as Ke,T as Gs,A as Ft,E as an,G as nn,H as Ot,J as It,K as Ge,L as Bt,M as zt,N as Ut,P as rn,O as Vt,Q as ze,R as on,U as Ue,V as _s,W as Ds,Y as As,Z as Ms,_ as Ls,$ as Ps,a0 as Rs,a1 as $s,a2 as Js,a3 as ln,a4 as Ss,a5 as ht,a6 as ms,a7 as dn,a8 as cn,a9 as un,aa as xn,ab as mn,ac as hn,ad as Ht,ae as Kt,af as qt,ag as pn,ah as hs,ai as fn,aj as gn,ak as bn,al as pt,am as vn,an as jn,ao as Nn,ap as ft,aq as kn,ar as wn,as as yn,at as Sn,au as Cn,av as Tn,aw as En,ax as _n,ay as Wt,az as Dn,aA as An,aB as Mn,aC as Ln,aD as Pn,aE as Rn,aF as $n,aG as Fn,aH as On,aI as In,aJ as Bn,aK as zn,aL as Un,aM as Vn,aN as Hn,aO as Kn,aP as qn,aQ as Wn,aR as Gn,aS as Jn,aT as Yn,aU as Xn,aV as Qn}from"./index-BzTROrJe.js";import{r as gt,e as Zn,b as Gt,t as Jt,L as be,C as bt,a as er,T as Cs,D as We,I as Re,M as Fs,c as Yt,m as Xt,d as Qt,f as sr,g as vt,h as tr,i as ar,j as Ts,k as nr,n as rr,l as or}from"./DashboardShared-CfKjChkE.js";import{F as ir}from"./folder-CiTzsQ19.js";import{P as lr}from"./play-Bn74sNWK.js";/**
3
3
  * @license lucide-react v1.7.0 - ISC
4
4
  *
5
5
  * This source code is licensed under the ISC license.
@@ -121,4 +121,4 @@ import{c as fe,r as t,j as e,a as Ka,b as M,d as qa,e as Wa,D as Rt,f as Ga,g as
121
121
  * See the LICENSE file in the root directory of this source tree.
122
122
  */const Vr=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],Hr=fe("trash-2",Vr),Kr=new Set(["assigned","running"]);function qr(s,a){return s.reduce((n,o)=>o.assignedTo===a&&Kr.has(o.status)?n+1:n,0)}function Ye(s){return(s==null?void 0:s.toLowerCase())==="devtunnel"}function Wr(s){return s?Ye(s)?"DevTunnel":s.charAt(0).toUpperCase()+s.slice(1):"Direct"}function Zs(s,a){return Ye(a??s.transportType)||!!s.devtunnelEndpoint}function ta(s,a){return!Ye(a??s.transportType)}function aa(s,a){const n=a??s.transportType;return Ye(n)?"DevTunnel":s.devtunnelEndpoint?"Direct + DevTunnel":Wr(n)}function kt(s,a){return!s&&!a}function Gr({routeTaskId:s,creatingTask:a,internalSelectedTaskId:n,sortedTaskIds:o}){return s||(a?null:n??o[0]??null)}function Jr(s,a){return[a,...s.filter(n=>n.id!==a.id)]}const Yr=new Set(["completed","failed","cancelled","archived"]);function Xr(s,a){const n=new Set(a);return new Set(Array.from(s).filter(o=>n.has(o)))}function Qr(s,a){const n=new Set(a);if(n.size===0)return!1;const o=s.filter(r=>n.has(r.id));return o.length===n.size&&o.every(r=>Yr.has(r.status))}function Zr(s,a){var o;const n=new Set(a);return((o=s.find(r=>!n.has(r.id)))==null?void 0:o.id)??null}var eo=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],so=eo.reduce((s,a)=>{const n=Ka(`Primitive.${a}`),o=t.forwardRef((r,i)=>{const{asChild:x,...k}=r,y=x?n:a;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(y,{...k,ref:i})});return o.displayName=`Primitive.${a}`,{...s,[a]:o}},{}),to="Label",na=t.forwardRef((s,a)=>e.jsx(so.label,{...s,ref:a,onMouseDown:n=>{var r;n.target.closest("button, input, select, textarea")||((r=s.onMouseDown)==null||r.call(s,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));na.displayName=to;var ra=na;const ao=qa("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),_e=t.forwardRef(({className:s,...a},n)=>e.jsx(ra,{ref:n,className:M(ao(),s),...a}));_e.displayName=ra.displayName;function no({onAdded:s}){const[a,n]=t.useState(""),[o,r]=t.useState(!1),[i,x]=t.useState(null),k=t.useCallback(async y=>{if(y.preventDefault(),!!a.trim()){r(!0),x(null);try{await Wa({leaderEndpoint:a.trim(),transport:"devtunnel"}),s()}catch(N){x(N instanceof Error?N.message:"Failed to join node")}finally{r(!1)}}},[a,s]);return e.jsx(Rt,{className:"overflow-hidden border-border/60 bg-transparent p-0 shadow-none sm:max-w-xl",children:e.jsxs("div",{className:"overflow-hidden rounded-[28px] border border-border/60 bg-background/95 p-0 shadow-[0_40px_120px_-60px_rgba(0,0,0,0.88)] backdrop-blur-xl",children:[e.jsx("div",{className:"border-b border-border/60 px-6 py-5",children:e.jsxs(Ga,{className:"space-y-2 text-left",children:[e.jsx($t,{className:"text-2xl tracking-tight",children:"Join node"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Verify the remote leader's DevTunnel endpoint, sync this node's tasks to that leader, and join the cluster as a follower."})]})}),e.jsxs("form",{onSubmit:k,className:"space-y-4 px-6 py-5",children:[i&&e.jsx("div",{className:"rounded-[20px] border border-destructive/20 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:i}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(_e,{htmlFor:"leader-endpoint",children:"Leader endpoint"}),e.jsx(Ae,{variant:"outline",className:"rounded-[11px] border-border/70 bg-background/60 text-[10px] uppercase tracking-[0.16em]",children:"DevTunnel only"})]}),e.jsx(Fe,{id:"leader-endpoint",type:"url",value:a,onChange:y=>n(y.target.value),placeholder:"https://your-leader.devtunnels.ms",className:"h-11 rounded-[18px] border-border/70 bg-background/70"})]}),e.jsx("div",{className:"rounded-[20px] border border-border/60 bg-background/45 px-4 py-3 text-sm text-muted-foreground",children:"This does not switch the local node transport or auto-enable a local DevTunnel. Leaving later will detach this node from the remote leader and make it leader of its own cluster again."}),e.jsx(Ja,{className:"border-t border-border/60 pt-4",children:e.jsx(O,{type:"submit",disabled:!a.trim()||o,className:"rounded-[16px]",children:o?"Joining...":"Join node"})})]})]})})}function oa(){const[s,a]=t.useState([]),[n,o]=t.useState(null),r=t.useRef(null),i=t.useCallback(()=>{var w;(w=r.current)==null||w.click()},[]),x=t.useCallback(async w=>{const d=Array.from(w.target.files??[]);if(d.length!==0)try{const u=await gt(d);a(b=>[...b,...u]),o(null)}catch(u){o(u instanceof Error?u.message:"Failed to attach image")}finally{w.target.value=""}},[]),k=t.useCallback(async w=>{const d=Zn(w.clipboardData);if(d.length!==0){w.preventDefault();try{const u=await gt(d);a(b=>[...b,...u]),o(null)}catch(u){o(u instanceof Error?u.message:"Failed to attach image")}}},[]),y=t.useCallback(w=>{a(d=>d.filter((u,b)=>b!==w))},[]),N=t.useCallback(()=>{a([]),o(null)},[]);return{images:s,error:n,fileInputRef:r,pickImages:i,handleFileChange:x,handlePaste:k,removeImage:y,clearImages:N}}function ro({onSend:s,disabled:a,disabledReason:n="Chat is waiting on the agent.",placeholder:o="Send a follow-up message...",contextItems:r=[],running:i=!1,onStop:x}){const[k,y]=t.useState(""),N=t.useRef(null),{images:w,error:d,fileInputRef:u,pickImages:b,handleFileChange:j,handlePaste:f,removeImage:L,clearImages:_}=oa(),R=t.useCallback(()=>{N.current&&(N.current.style.height="auto")},[]),Y=t.useCallback(()=>{const A=Gt(k,w);A.length===0||a||(s(A),y(""),_(),R())},[k,w,a,s,_,R]),ee=t.useCallback(A=>{A.key==="Enter"&&!A.shiftKey&&(A.preventDefault(),Y())},[Y]),$=t.useCallback(()=>{N.current&&(N.current.style.height="auto",N.current.style.height=`${Math.min(N.current.scrollHeight,220)}px`)},[]),ue=!a&&!i&&(k.trim().length>0||w.length>0),D=i&&!!x,K=i?x?"Task is running — click to stop":"Task is running...":a?n:"Enter sends, Shift+Enter adds a line";return e.jsxs("div",{className:"animate-composer-settle border-t border-border/45 bg-background/42 px-2 py-2 backdrop-blur-xl sm:px-4 sm:py-3",children:[r.length>0&&e.jsx("div",{className:"flex flex-wrap items-center gap-1.5 px-2 pb-2.5",children:r.map(A=>e.jsxs("div",{className:"inline-flex max-w-full items-center gap-1.5 rounded-[13px] border border-border/60 bg-muted/40 px-2 py-1 text-[11px] shadow-sm",children:[e.jsx("span",{className:"shrink-0 text-[9px] font-medium uppercase tracking-[0.12em] text-muted-foreground/80",children:A.label}),e.jsx("span",{className:`truncate text-foreground/90 ${A.mono?"font-mono text-[11px]":""}`,children:A.value})]},`${A.label}:${A.value}`))}),e.jsxs("div",{className:"overflow-hidden rounded-[26px] border border-border/65 bg-card/88 shadow-[0_30px_92px_-62px_rgba(15,23,42,0.55)] backdrop-blur-xl sm:rounded-[30px] dark:shadow-[0_30px_92px_-62px_rgba(0,0,0,0.95)]",children:[e.jsx("input",{ref:u,type:"file",accept:"image/*",multiple:!0,onChange:j,className:"hidden"}),w.length>0&&e.jsx("div",{className:"px-2 pt-3 sm:px-6 sm:pt-6",children:e.jsx("div",{className:"flex flex-wrap gap-3",children:w.map((A,I)=>e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:Jt(A),alt:A.filename??`attachment ${I+1}`,className:"h-24 w-24 rounded-[22px] border border-border/70 object-cover"}),e.jsx("button",{type:"button",onClick:()=>L(I),className:"absolute -top-2 -right-2 flex h-7 w-7 items-center justify-center rounded-[12px] border border-border/70 bg-background text-muted-foreground shadow-sm transition-all hover:-translate-y-px hover:text-foreground","aria-label":`Remove ${A.filename??`image ${I+1}`}`,children:e.jsx(He,{className:"h-3.5 w-3.5"})})]},`${A.filename??"image"}-${I}`))})}),e.jsxs("div",{className:"flex items-end gap-1.5 px-2 pt-3 pb-3 sm:px-6 sm:pt-4 sm:pb-4",children:[e.jsx("textarea",{ref:N,value:k,onChange:A=>y(A.target.value),onKeyDown:ee,onPaste:f,onInput:$,placeholder:o,disabled:a,rows:1,className:"min-h-[2.5rem] flex-1 resize-none bg-transparent px-0 py-1 text-[11px] leading-7 text-foreground placeholder:text-muted-foreground/70 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"}),e.jsxs(O,{type:"button",variant:"ghost",onClick:b,disabled:a,className:"mb-0.5 h-8 shrink-0 gap-1.5 rounded-[14px] px-2.5 text-[11px] text-muted-foreground hover:text-foreground sm:px-2.5",title:"Attach images",children:[e.jsx(Is,{className:"h-4 w-4 sm:h-3.5 sm:w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Images"})]}),e.jsx("span",{title:K,children:e.jsx(O,{onClick:i?x:Y,disabled:i?!D:!ue,size:"icon","aria-label":i?"Stop running task":"Send message",className:"mb-0.5 h-8 w-10 shrink-0 rounded-[14px] bg-primary/90 text-primary-foreground shadow-[0_12px_30px_-18px_hsl(var(--primary)/0.95)] hover:bg-primary",children:i?e.jsx(be,{className:"h-4 w-4 animate-spin"}):e.jsx(sa,{className:"h-4 w-4"})})})]}),d&&e.jsx("div",{className:"border-t border-destructive/20 bg-destructive/10 px-2 py-2 text-[11px] text-destructive sm:px-6 sm:py-3",children:d})]})]})}function oo(s,a,n){return s!=="auto"?a.find(o=>o.id===s)??null:n.length===1?n[0]??null:null}function io(s){return s.trim()||"."}function lo(s){return new Promise(a=>window.setTimeout(a,s))}function co(s){return!!s&&typeof s=="object"&&typeof s.createdBranch=="string"&&typeof s.currentBranch<"u"}async function uo(s){let a=s;for(let n=0;n<60;n++){if(a.status==="succeeded"){if(co(a.result))return a.result;throw new Error("Branch creation completed without branch details")}if(a.status==="failed")throw new Error(a.error||"Branch creation failed");await lo(1e3),a=await Qa(a.id)}throw new Error("Timed out waiting for branch creation")}function wt({value:s,onChange:a,project:n,assignTo:o,nodes:r,assignableNodes:i,layout:x="default",chipClassName:k,chipActiveClassName:y,chipInactiveClassName:N,labelClassName:w,triggerClassName:d}){const[u,b]=t.useState(!1),[j,f]=t.useState(null),[L,_]=t.useState(""),[R,Y]=t.useState(!1),[ee,$]=t.useState(!1),[ue,D]=t.useState(!1),[K,A]=t.useState(null),[I,S]=t.useState(""),[U,oe]=t.useState(""),[B,C]=t.useState(""),[se,ie]=t.useState(!1),te=t.useRef(null),H=t.useRef(0),X=t.useMemo(()=>oo(o,r,i),[o,r,i]),q=X==null?void 0:X.id,ae=t.useMemo(()=>io(n),[n]),le=t.useMemo(()=>q?`${q}
123
123
  ${ae}`:"",[q,ae]),c=t.useCallback(async(m=0,T=!1)=>{const W=H.current+1,Ne=le;if(H.current=W,!q){f(null),_("");return}A(null),T||_(""),T?$(!0):Y(!0);try{const we=await Ya(q,{path:ae,limit:20,offset:m,allowAbsolute:!0});if(W!==H.current)return;_(Ne),f(g=>T&&g?{...we,branches:[...g.branches,...we.branches]}:we)}catch(we){if(W!==H.current)return;A(we instanceof Error?we.message:"Failed to load branch info"),T||(f(null),_(""))}finally{W===H.current&&(Y(!1),$(!1))}},[q,le,ae]);t.useEffect(()=>{if(!q){H.current+=1,f(null),_(""),A(null);return}c()},[q,ae,c]),t.useEffect(()=>{const m=s.trim(),T=L===le?j:null,W=T!=null&&T.available&&T.currentBranch?T.currentBranch:"";m!==W&&a(W)},[j,le,L,a,s]),t.useEffect(()=>{if(!u)return;const m=W=>{te.current&&(te.current.contains(W.target)||b(!1))},T=W=>{W.key==="Escape"&&b(!1)};return document.addEventListener("mousedown",m),document.addEventListener("keydown",T),()=>{document.removeEventListener("mousedown",m),document.removeEventListener("keydown",T)}},[u]),t.useEffect(()=>{u&&(oe(""),C(""),ie(!1))},[u,q,ae]);const P=t.useCallback(async()=>{if(!q)return;const m=I.trim(),T=se?B.trim():U.trim();if(!(!m||!T)){D(!0),A(null);try{const W=await Xa(q,{path:ae,branchName:m,startPoint:T,limit:20,offset:0,allowAbsolute:!0}),Ne=await uo(W);_(le),f(Ne),a(Ne.currentBranch??Ne.createdBranch),S(""),oe(""),C(""),ie(!1),b(!1)}catch(W){A(W instanceof Error?W.message:"Failed to create branch")}finally{D(!1)}}},[q,le,ae,se,B,I,a,U]),v=L===le?j:null,J=t.useCallback(()=>{v!=null&&v.hasMore&&c(v.branches.length,!0)},[v,c]),h=s.trim()||(v==null?void 0:v.currentBranch)||(v&&!v.available?"No git repo":"Branch"),re=se?B.trim():U.trim(),V=!!(v!=null&&v.available&&I.trim()&&re&&!ue),xe=x==="composer"?e.jsxs(O,{type:"button",variant:"ghost",onClick:()=>b(m=>!m),title:h,"aria-label":`Branch: ${h}`,className:M(k,d,"min-w-0 max-w-full",s.trim()?y:N),children:[R&&!v?e.jsx(be,{className:"h-3.5 w-3.5 shrink-0 animate-spin"}):e.jsx(jt,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:M("min-w-0 truncate",w),children:h})]}):e.jsxs(O,{type:"button",variant:"outline",onClick:()=>b(m=>!m),className:"h-11 w-full justify-between rounded-2xl border-border/70 bg-background/70 px-4",title:h,children:[e.jsx("span",{className:M("truncate",s.trim()?"font-mono text-foreground":"text-muted-foreground"),children:h}),e.jsx("span",{className:"ml-3 shrink-0 text-xs text-muted-foreground",children:X?X.name:"Manual"})]});return e.jsxs("div",{className:M("relative inline-block",x==="composer"?"min-w-0 shrink-0":"w-full"),ref:te,children:[x==="default"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Branch"}),xe]}):xe,u&&e.jsxs("div",{className:M("absolute z-50 mt-2 w-[240px] overflow-hidden rounded-2xl border border-border/60 bg-background/95 shadow-lg backdrop-blur",x==="composer"?"left-0":"left-0 right-0 w-auto min-w-[240px]"),children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-border/60 px-3 py-2",children:[e.jsx(jt,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-foreground",title:v!=null&&v.repoRoot?`${v.currentBranch??h} · ${v.repoRoot}`:(v==null?void 0:v.currentBranch)??h,children:(v==null?void 0:v.currentBranch)??h}),R?e.jsx(be,{className:"h-3 w-3 shrink-0 animate-spin text-muted-foreground"}):null]}),X?R&&!v?e.jsxs("div",{className:"flex items-center justify-center px-3 py-4 text-[11px] text-muted-foreground",children:[e.jsx(be,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Loading..."]}):v&&!v.available?e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:"Not a git repository."}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:"space-y-2 px-3 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Fe,{value:I,onChange:m=>S(m.target.value),placeholder:"New branch name",className:"h-8 flex-1 rounded-md border-border/60 bg-background/70 font-mono text-[11px]"}),e.jsx(O,{type:"button",size:"sm",onClick:()=>void P(),disabled:!V,title:V?"Create branch":"Enter a name and pick a base","aria-label":"Create branch",className:"h-8 w-8 shrink-0 rounded-md p-0",children:ue?e.jsx(be,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Lr,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Base from"}),!se&&e.jsxs("button",{type:"button",onClick:()=>ie(!0),className:"flex items-center gap-1 rounded px-1 py-0.5 text-[10px] text-muted-foreground hover:bg-background/60 hover:text-foreground",children:[e.jsx(ns,{className:"h-2.5 w-2.5"}),"Manual"]})]}),se?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Fe,{value:B,onChange:m=>C(m.target.value),placeholder:"upstream/release/1.0",className:"h-8 flex-1 rounded-md border-border/60 bg-background/70 font-mono text-[11px]"}),e.jsx("button",{type:"button",onClick:()=>{ie(!1),C("")},className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-background/60 hover:text-foreground",title:"Cancel manual input","aria-label":"Cancel manual input",children:e.jsx(He,{className:"h-3.5 w-3.5"})})]}):v!=null&&v.branches.length?e.jsxs("div",{className:"max-h-44 overflow-y-auto rounded-md border border-border/40 bg-background/40",children:[v.branches.map(m=>{const T=U===m.ref,W=m.branch==="main"||m.branch==="master";return e.jsxs("button",{type:"button",onClick:()=>oe(m.ref),className:M("flex w-full items-center gap-2 border-b border-border/20 px-2.5 py-1.5 text-left text-[11px] last:border-b-0 hover:bg-background/60",T&&"bg-background/70"),title:m.ref,children:[e.jsx("span",{className:M("shrink-0 text-[10px]",W?"text-amber-500 dark:text-amber-400":"text-muted-foreground/60"),"aria-hidden":!0,children:W?"★":"·"}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-foreground",children:m.ref}),T?e.jsx(es,{className:"h-3 w-3 shrink-0 text-primary"}):null]},m.ref)}),v.hasMore&&e.jsxs("button",{type:"button",onClick:J,disabled:ee,className:"flex w-full items-center justify-center gap-1 border-t border-border/20 py-1 text-[10px] text-muted-foreground hover:bg-background/60 hover:text-foreground disabled:opacity-50",children:[ee?e.jsx(be,{className:"h-3 w-3 animate-spin"}):e.jsx(Os,{className:"h-3 w-3"}),"Load more"]})]}):e.jsx("div",{className:"rounded-md border border-dashed border-border/40 px-2.5 py-2 text-[11px] text-muted-foreground",children:"No remote branches found."})]})]})}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:"Select a specific node first."}),K&&e.jsx("div",{className:"border-t border-destructive/20 bg-destructive/10 px-3 py-1.5 text-[11px] text-destructive",children:K})]})]})}const xo=20,mo=3,zs="meshy-working-dir-recents-by-node";function ho(s){return s.startsWith("/")||s.startsWith("\\\\")||/^[A-Za-z]:[\\/]/.test(s)}function po(s){const a=s.trim();return a||"."}function Us(s){const a=[],n=new Set;for(const o of s){const r=o.trim();if(!(!r||n.has(r))&&(n.add(r),a.push(r),a.length===mo))break}return a}function fo(s,a){const n=a.trim();return Us(n?[n,...s]:s)}function ia(s){if(!s||typeof s!="object"||Array.isArray(s))return{};const a={};for(const[n,o]of Object.entries(s)){if(!n||!Array.isArray(o))continue;const r=o.filter(x=>typeof x=="string"),i=Us(r);i.length>0&&(a[n]=i)}return a}function go(s,a,n){if(!a)return s;const o=s[a]??[],r=fo(o,n);if(r.length===0){if(!(a in s))return s;const{[a]:i,...x}=s;return x}return{...s,[a]:r}}function bo(s,a){var n;return a?((n=s[a])==null?void 0:n[0])??"":""}function la(s){if(!s||typeof window>"u")return"";try{const a=window.localStorage.getItem(zs);return a?bo(ia(JSON.parse(a)),s):""}catch{return""}}function vo(s,a,n){return s!=="auto"?a.find(o=>o.id===s)??null:n.length===1?n[0]??null:null}function jo(s,a){const n=a.trim();return n?ho(n)||!s?n:`${s.replace(/[/\\]+$/,"")}/${n}`:""}function No(s,a){return s?s.isAbsolute?s.currentPath:s.currentPath==="."||s.currentPath===""?s.rootPath||(a==null?void 0:a.workDir)||"Node root":s.currentPath:(a==null?void 0:a.workDir)??"Node root"}function ps({value:s,onChange:a,assignTo:n,nodes:o,assignableNodes:r,layout:i="default",chipClassName:x,chipActiveClassName:k,chipInactiveClassName:y,labelClassName:N,triggerClassName:w,popoverPlacement:d="bottom",popoverAlign:u="start"}){const[b,j]=t.useState(!1),[f,L]=t.useState(null),[_,R]=t.useState(!1),[Y,ee]=t.useState(!1),[$,ue]=t.useState(null),[D,K]=t.useState(""),[A,I]=t.useState(!1),[S,U]=t.useState({}),oe=t.useRef(null),B=t.useMemo(()=>vo(n,o,r),[n,o,r]),C=B==null?void 0:B.id,se=t.useMemo(()=>C?S[C]??[]:[],[S,C]),ie=t.useMemo(()=>s.trim()?jo(B==null?void 0:B.workDir,s):"Use node default",[s,B==null?void 0:B.workDir]);t.useEffect(()=>{if(!(typeof window>"u"))try{const h=window.localStorage.getItem(zs);if(!h)return;const re=JSON.parse(h);U(ia(re))}catch{}},[]);const te=t.useCallback(h=>{C&&U(re=>{const V=go(re,C,h);if(V===re)return re;if(typeof window<"u")try{window.localStorage.setItem(zs,JSON.stringify(V))}catch{}return V})},[C]),H=t.useCallback((h,re=!0)=>{const V=h.trim();a(V),re&&V&&te(V),j(!1)},[a,te]),X=t.useCallback(async(h,re=0,V=!1)=>{if(C){ue(null),V?ee(!0):R(!0);try{const xe=await Za(C,{path:h,limit:xo,offset:re,directoriesOnly:!0,allowAbsolute:!0});L(m=>V&&m?{...xe,entries:[...m.entries,...xe.entries]}:xe)}catch(xe){ue(xe instanceof Error?xe.message:"Failed to browse directories"),V||L(null)}finally{R(!1),ee(!1)}}},[C]),q=t.useRef(s);q.current=s;const ae=t.useRef(X);ae.current=X,t.useEffect(()=>{if(!b)return;const h=q.current;K(h),I(!1),L(null),ue(null),C&&ae.current(po(h))},[b,C]),t.useEffect(()=>{if(!b)return;const h=V=>{oe.current&&(oe.current.contains(V.target)||j(!1))},re=V=>{V.key==="Escape"&&j(!1)};return document.addEventListener("mousedown",h),document.addEventListener("keydown",re),()=>{document.removeEventListener("mousedown",h),document.removeEventListener("keydown",re)}},[b]);const le=t.useCallback(h=>{X(h)},[X]),c=t.useCallback(()=>{f&&X(f.currentPath,f.entries.length,!0)},[f,X]),P=i==="composer"?e.jsxs(O,{type:"button",variant:"ghost",onClick:()=>j(h=>!h),title:ie,"aria-label":`Working directory: ${ie}`,className:M(x,w,"min-w-0 max-w-full",s.trim()?k:y),children:[e.jsx(en,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:M("min-w-0 truncate",N),children:ie})]}):e.jsxs(O,{type:"button",variant:"outline",onClick:()=>j(h=>!h),className:"h-11 w-full justify-between rounded-2xl border-border/70 bg-background/70 px-4",title:ie,children:[e.jsx("span",{className:M("truncate",s.trim()?"font-mono text-foreground":"text-muted-foreground"),children:ie}),e.jsx("span",{className:"ml-3 shrink-0 text-xs text-muted-foreground",children:B?B.name:"Manual"})]}),v=No(f,B),J=!!(f!=null&&f.parentPath);return e.jsxs("div",{className:M("relative inline-block",i==="composer"?"min-w-0 max-w-[60%] shrink":"w-full"),"data-workdir-popover-placement":d,"data-workdir-popover-align":u,ref:oe,children:[i==="default"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Working directory"}),P]}):P,b&&e.jsxs("div",{className:M("absolute z-50 flex max-h-[min(28rem,calc(100vh-5rem))] w-[240px] flex-col overflow-hidden rounded-2xl border border-border/60 bg-background/95 shadow-lg backdrop-blur",d==="top"?"bottom-full mb-2":"top-full mt-2",i==="composer"?u==="end"?"right-0":"left-0":u==="end"?"right-0 w-auto min-w-[240px]":"left-0 right-0 w-auto min-w-[240px]"),children:[se.length>0&&e.jsxs("div",{className:"border-b border-border/60 px-3 py-2",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1 text-[10px] text-muted-foreground",children:[e.jsx(Os,{className:"h-2.5 w-2.5"}),"Recent"]}),e.jsx("div",{className:"flex flex-col",children:se.map(h=>e.jsx("button",{type:"button",onClick:()=>H(h),className:"truncate rounded px-1.5 py-0.5 text-left font-mono text-[11px] text-foreground hover:bg-background/60",title:h,children:h},h))})]}),e.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border/60 px-2.5 py-1.5",children:[e.jsx("button",{type:"button",onClick:()=>(f==null?void 0:f.parentPath)&&le(f.parentPath),disabled:!J||_,className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md border border-border/60 text-muted-foreground transition-colors hover:bg-background/60 hover:text-foreground disabled:opacity-40",title:"Parent directory",children:e.jsx(xr,{className:"h-3 w-3"})}),e.jsx("div",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-muted-foreground",title:v,children:v}),f&&e.jsx("button",{type:"button",onClick:()=>H(f.isAbsolute?f.currentPath:f.currentPath==="."?"":f.currentPath),className:"shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium text-foreground hover:bg-background/60",title:"Use this folder",children:"Use"})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:[B?_?e.jsxs("div",{className:"flex items-center justify-center px-3 py-4 text-[11px] text-muted-foreground",children:[e.jsx(be,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Loading..."]}):f&&f.entries.length>0?e.jsxs(e.Fragment,{children:[f.entries.map(h=>e.jsxs("div",{className:"group flex items-stretch border-b border-border/30 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>H(h.path),className:"flex min-w-0 flex-1 items-center gap-2 px-2.5 py-1.5 text-left hover:bg-background/55",title:`Use ${h.path}`,children:[e.jsx(ir,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate text-[11px] text-foreground",children:h.name})]}),e.jsx("button",{type:"button",onClick:()=>le(h.path),className:"flex w-9 shrink-0 items-center justify-center border-l border-border/30 text-muted-foreground hover:bg-background/70 hover:text-foreground",title:"Open subfolder","aria-label":`Open ${h.name}`,children:e.jsx(ss,{className:"h-3.5 w-3.5"})})]},h.path)),f.hasMore&&e.jsxs("button",{type:"button",onClick:c,disabled:Y,className:"flex w-full items-center justify-center gap-1 border-t border-border/40 py-1 text-[10px] text-muted-foreground hover:bg-background/60 hover:text-foreground disabled:opacity-50",children:[Y?e.jsx(be,{className:"h-3 w-3 animate-spin"}):e.jsx(Os,{className:"h-3 w-3"}),"Load more"]})]}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:$??"No subfolders."}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:"Select a node to browse."}),$&&f&&f.entries.length>0&&e.jsx("div",{className:"border-t border-border/60 px-3 py-1.5 text-[11px] text-destructive",children:$})]}),e.jsx("div",{className:"flex items-center gap-1 border-t border-border/60 bg-background/40 px-2.5 py-1.5",children:A?e.jsxs(e.Fragment,{children:[e.jsx(Fe,{value:D,onChange:h=>K(h.target.value),onKeyDown:h=>{h.key==="Enter"&&D.trim()?(h.preventDefault(),H(D)):h.key==="Escape"&&(h.preventDefault(),I(!1),K(s))},autoFocus:!0,placeholder:"Path (relative or absolute)",className:"h-7 flex-1 rounded-md border-border/60 bg-background/70 font-mono text-[11px]"}),e.jsx("button",{type:"button",onClick:()=>H(D),disabled:!D.trim(),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-foreground hover:bg-background/60 disabled:opacity-40",title:"Apply","aria-label":"Apply manual path",children:e.jsx(es,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>{I(!1),K(s)},className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-background/60 hover:text-foreground",title:"Cancel","aria-label":"Cancel manual path",children:e.jsx(He,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>{K(s),I(!0)},className:"flex h-7 flex-1 items-center justify-between rounded-md px-1.5 text-[11px] text-muted-foreground hover:bg-background/60 hover:text-foreground",title:"Enter a manual path",children:[e.jsx("span",{children:"Manual input"}),e.jsx(ns,{className:"h-3 w-3"})]})})]})]})}function da(s,a={}){const n=s.filter(o=>o.status==="online");return a.currentNodeRole!=="follower"||!a.leaderNodeId?n:n.filter(o=>o.id!==a.leaderNodeId)}function et({isCurrent:s}){return s?e.jsx(wr,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500 dark:text-emerald-400","aria-label":"current node"}):e.jsx(vr,{className:"h-3.5 w-3.5 shrink-0 text-sky-500 dark:text-sky-400","aria-label":"remote follower node"})}function Vs(s,a){return s.map(n=>{const o=!!a&&n.id===a;return e.jsx(ge,{value:n.id,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(et,{isCurrent:o}),e.jsx("span",{className:"truncate",children:n.name}),e.jsx("span",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:o?"current":"remote"})]})},n.id)})}function ko(s){var o;const a=s.sessionId.trim(),n=s.cwd.trim();return!a||!n||!s.assignTo?null:{title:s.title.trim()||((o=s.defaultTitle)==null?void 0:o.trim())||void 0,agent:s.agent,sessionId:a,cwd:n,assignTo:s.assignTo,priority:s.priority,mode:s.mode??ts}}function wo(){return Gs.map(s=>e.jsx(ge,{value:s.value,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{children:s.label}),s.description&&e.jsx("span",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:s.description})]})},s.value))}function yo(s){if(!s)return"unknown time";const a=Date.parse(s);return Number.isNaN(a)?s:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(a)}function So({nodes:s,currentNodeRole:a,currentNodeId:n,leaderNodeId:o,onCreated:r,onCancel:i,className:x,footerClassName:k,submitLabel:y="Load session",cancelLabel:N="Cancel",autoFocus:w=!1}){const d=t.useMemo(()=>da(s,{currentNodeRole:a,leaderNodeId:o}),[s,a,o]),u=t.useMemo(()=>{var m;return n&&d.some(T=>T.id===n)?n:((m=d[0])==null?void 0:m.id)??""},[d,n]),[b,j]=t.useState(""),[f,L]=t.useState("codex"),[_,R]=t.useState(""),[Y,ee]=t.useState(""),[$,ue]=t.useState(""),[D,K]=t.useState(u),[A,I]=t.useState("normal"),[S,U]=t.useState(ts),[oe,B]=t.useState(!1),[C,se]=t.useState([]),[ie,te]=t.useState(!1),[H,X]=t.useState(null),q=t.useMemo(()=>C.find(m=>m.sessionId===_)??null,[C,_]);t.useEffect(()=>{D&&d.some(m=>m.id===D)||K(u)},[D,d,u]),t.useEffect(()=>{R(""),ee(""),ue("")},[f,D]),t.useEffect(()=>{let m=!1;return D?(te(!0),X(null),sn(D,{agent:f,limit:50}).then(T=>{m||se(T.sessions)}).catch(T=>{m||(se([]),X(T instanceof Error?T.message:"Failed to load native sessions"))}).finally(()=>{m||te(!1)}),()=>{m=!0}):(se([]),X(null),te(!1),()=>{m=!0})},[f,D]),t.useEffect(()=>{q&&(ee(q.sessionId),ue(q.cwd))},[q]);const ae=t.useCallback(async m=>{m.preventDefault();const T=ko({title:b,defaultTitle:q==null?void 0:q.summary,agent:f,sessionId:Y,cwd:$,assignTo:D,priority:A,mode:S});if(T){B(!0);try{const W=await tn(T);r(W)}catch(W){pe.error(W instanceof Error?W.message:"Failed to load native session")}finally{B(!1)}}},[b,q,f,Y,$,D,A,S,r]),le=!!(Y.trim()&&$.trim()&&D),[c,P]=t.useState(!1),[v,J]=t.useState(""),h=d.find(m=>m.id===D)??null,re=!!(n&&(h==null?void 0:h.id)===n),V=t.useMemo(()=>{const m=v.trim().toLowerCase();return m?C.filter(T=>T.summary.toLowerCase().includes(m)||T.sessionId.toLowerCase().includes(m)||T.cwd.toLowerCase().includes(m)):C},[C,v]),xe="h-9 w-auto gap-1.5 rounded-[15px] border-border/60 bg-background/60 px-3 text-xs shadow-none transition-colors hover:bg-background/80";return e.jsxs("form",{onSubmit:ae,className:M("space-y-4",x),children:[e.jsxs("div",{className:"rounded-[26px] border border-border/60 bg-background/54 shadow-[0_24px_86px_-48px_rgba(15,23,42,0.55)] backdrop-blur-xl dark:shadow-[0_24px_86px_-48px_rgba(0,0,0,0.9)]",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b border-border/50 px-4 py-3",children:[e.jsxs(Se,{value:D,onValueChange:K,children:[e.jsx(Ce,{className:M(xe),"aria-label":"Node",children:h?e.jsxs(e.Fragment,{children:[e.jsx(et,{isCurrent:re}),e.jsx("span",{className:"max-w-[10rem] truncate",children:h.name})]}):e.jsx(Me,{placeholder:"Node"})}),e.jsx(Te,{children:Vs(d,n)})]}),e.jsxs(Se,{value:f,onValueChange:m=>L(m),children:[e.jsxs(Ce,{className:M(xe),"aria-label":"Agent",children:[e.jsx(Ws,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{children:f})]}),e.jsxs(Te,{children:[e.jsx(ge,{value:"codex",children:"codex"}),e.jsx(ge,{value:"claudecode",children:"claudecode"})]})]}),e.jsxs("div",{className:"relative ml-auto min-w-0 flex-1 sm:max-w-56",children:[e.jsx(Bs,{className:"pointer-events-none absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),e.jsx(Fe,{value:v,onChange:m=>J(m.target.value),placeholder:"Filter sessions",className:"h-9 rounded-[15px] border-border/60 bg-background/60 pl-9 text-xs shadow-none"})]})]}),e.jsxs("div",{className:"px-3 py-3",children:[e.jsx("div",{className:"flex items-center justify-between px-1 pb-2",children:e.jsx(_e,{className:"text-[10px] font-medium uppercase tracking-[0.2em] text-muted-foreground",children:ie?"Loading...":`${V.length} session${V.length===1?"":"s"}`})}),e.jsxs("div",{className:"relative h-88 overflow-hidden rounded-[20px]",children:[ie&&e.jsx("div",{className:"absolute inset-x-0 top-0 z-10 h-0.5 overflow-hidden bg-primary/10",children:e.jsx("div",{className:"h-full w-1/3 animate-indeterminate-bar bg-primary/70"})}),e.jsxs("div",{className:"h-full space-y-1.5 overflow-y-auto pr-1 pt-1",children:[!D&&e.jsx("div",{className:"rounded-[18px] border border-dashed border-border/60 bg-background/35 px-4 py-6 text-center text-xs text-muted-foreground",children:"Pick a node to load its recent sessions."}),D&&!ie&&V.length===0&&e.jsx("div",{className:"rounded-[18px] border border-dashed border-border/60 bg-background/35 px-4 py-6 text-center text-xs text-muted-foreground",children:C.length===0?"No recent sessions on this node. Use Manual session ID under More options.":"No sessions match your filter."}),V.map(m=>{const T=m.sessionId===_;return e.jsxs("button",{type:"button",onClick:()=>R(m.sessionId),className:M("flex w-full flex-col gap-1 rounded-[18px] border px-3 py-2.5 text-left transition-all duration-200 hover:-translate-y-px",T?"border-primary/45 bg-primary/9 shadow-[0_18px_60px_-44px_hsl(var(--primary)/0.95)]":"border-border/55 bg-background/40 hover:border-border hover:bg-background/65"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:M("h-2 w-2 shrink-0 rounded-full",T?"bg-primary":"bg-border")}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-foreground",children:m.summary}),e.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-[0.16em] text-muted-foreground",children:yo(m.updatedAt)})]}),e.jsxs("div",{className:"flex items-center gap-2 pl-4 text-[10px] text-muted-foreground",children:[e.jsx("span",{className:"font-mono",children:m.sessionId.slice(0,12)}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-border"}),e.jsx("span",{className:"truncate font-mono",children:m.cwd})]})]},m.sessionId)})]})]}),H&&e.jsx("p",{className:"px-1 pt-2 text-[11px] text-destructive",children:H})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("button",{type:"button",onClick:()=>P(m=>!m),className:"flex w-full items-center gap-2 text-[11px] font-medium uppercase tracking-[0.2em] text-muted-foreground transition-colors hover:text-foreground","aria-expanded":c,children:[e.jsx("span",{className:"h-px flex-1 bg-border/60","aria-hidden":!0}),e.jsx("span",{className:"shrink-0",children:c?"Less options":"More options"}),e.jsx(Ke,{className:M("h-3.5 w-3.5 shrink-0 transition-transform",c&&"rotate-180")}),e.jsx("span",{className:"h-px flex-1 bg-border/60","aria-hidden":!0})]}),c&&e.jsxs("div",{className:"space-y-4 rounded-[22px] border border-border/60 bg-background/35 p-4",children:[e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{htmlFor:"native-session-id",className:"text-xs font-medium text-muted-foreground",children:"Session ID"}),e.jsx(Fe,{id:"native-session-id",type:"text",value:Y,onChange:m=>{R(""),ee(m.target.value)},placeholder:"ses_... or thread_...",autoFocus:w,className:"h-10 rounded-[16px] border-border/70 bg-background/70 font-mono text-xs"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{htmlFor:"native-session-title",className:"text-xs font-medium text-muted-foreground",children:"Task title"}),e.jsx(Fe,{id:"native-session-title",type:"text",value:b,onChange:m=>j(m.target.value),placeholder:"Optional",className:"h-10 rounded-[16px] border-border/70 bg-background/70 text-sm"})]})]}),e.jsx(ps,{value:$,onChange:m=>{R(""),ue(m)},assignTo:D,nodes:s,assignableNodes:d}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{className:"text-xs font-medium text-muted-foreground",children:"Mode"}),e.jsxs(Se,{value:S,onValueChange:m=>U(m),children:[e.jsx(Ce,{className:"h-10 rounded-[16px] border-border/70 bg-background/70 text-sm",children:e.jsx(Me,{placeholder:"Select mode"})}),e.jsx(Te,{children:wo()})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{className:"text-xs font-medium text-muted-foreground",children:"Priority"}),e.jsxs(Se,{value:A,onValueChange:I,children:[e.jsx(Ce,{className:"h-10 rounded-[16px] border-border/70 bg-background/70 text-sm",children:e.jsx(Me,{placeholder:"Select priority"})}),e.jsxs(Te,{children:[e.jsx(ge,{value:"low",children:"Low"}),e.jsx(ge,{value:"normal",children:"Normal"}),e.jsx(ge,{value:"high",children:"High"}),e.jsx(ge,{value:"critical",children:"Critical"})]})]})]})]})]})]}),e.jsxs("div",{className:M("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",k),children:[i&&e.jsx(O,{type:"button",variant:"ghost",onClick:i,className:"rounded-[16px]",children:N}),e.jsx(O,{type:"submit",disabled:!le||oe,className:"rounded-[16px] px-5",children:oe?e.jsxs(e.Fragment,{children:[e.jsx(be,{className:"h-4 w-4 animate-spin"})," Loading..."]}):y})]})]})}function yt(){return Ft.map(s=>e.jsx(ge,{value:s.value,disabled:s.disabled,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{children:s.label}),s.description&&e.jsx("span",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:s.description})]})},s.value))}function St(){return Gs.map(s=>e.jsx(ge,{value:s.value,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{children:s.label}),s.description&&e.jsx("span",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:s.description})]})},s.value))}function Co(s){var a;return((a=Ft.find(n=>n.value===s))==null?void 0:a.label)??s}function To(s){var a;return((a=Gs.find(n=>n.value===s))==null?void 0:a.label)??s}function ca(s,a,n=!1){const o=s.trim();if(o)return o;const r=a.trim().split(`
124
- `).map(i=>i.trim()).find(Boolean);return r?r.length>72?`${r.slice(0,69).trimEnd()}...`:r:n?"Image task":""}function Eo(s){var x;const a=s.title.trim(),n=ca(s.title,s.description,s.images.length>0),o=s.description.trim()||n,r=s.mode??ts,i=Gt(s.description,s.images);return!n||!o||!s.agent?null:{title:n,description:o,agent:s.agent,project:s.project.trim()||null,branch:((x=s.branch)==null?void 0:x.trim())||null,payload:{initialMessage:i,mode:r,titleSource:a?"manual":"derived"},priority:s.priority,assignTo:s.assignTo==="auto"?void 0:s.assignTo}}function _o({nodes:s,currentNodeRole:a,currentNodeId:n,leaderNodeId:o,onCreated:r,onCancel:i,className:x,footerClassName:k,submitLabel:y="Create chat",cancelLabel:N="Cancel",autoFocus:w=!1,layout:d="default"}){const[u,b]=t.useState(""),[j,f]=t.useState(""),[L,_]=t.useState("claudecode"),[R,Y]=t.useState(ts),[ee,$]=t.useState(""),[ue,D]=t.useState(""),[K,A]=t.useState("normal"),I=t.useMemo(()=>da(s,{currentNodeRole:a,leaderNodeId:o}),[s,a,o]),S=t.useMemo(()=>{var F;return n&&I.some(z=>z.id===n)?n:((F=I[0])==null?void 0:F.id)??""},[I,n]),[U,oe]=t.useState(S),[B,C]=t.useState(!1),[se,ie]=t.useState(!1),{images:te,error:H,fileInputRef:X,pickImages:q,handleFileChange:ae,handlePaste:le,removeImage:c}=oa(),P=t.useMemo(()=>I.find(F=>F.id===U)??null,[U,I]),v=!!(n&&(P==null?void 0:P.id)===n),J=Co(L),h=To(R);t.useEffect(()=>{U&&I.some(F=>F.id===U)||oe(S)},[U,I,S]),t.useEffect(()=>{$(la(U)),D("")},[U]),t.useEffect(()=>{D("")},[ee]);const re=t.useCallback(async F=>{F.preventDefault();const z=Eo({title:u,description:j,agent:L,project:ee,branch:ue,priority:K,assignTo:U,mode:R,images:te});if(z){C(!0);try{const me=await nn(z);r(me)}catch(me){pe.error(me instanceof Error?me.message:"Failed to create task")}finally{C(!1)}}},[u,j,L,ee,ue,K,U,R,te,r]),V=ca(u,j,te.length>0),xe=!!(V&&L&&U&&(j.trim()||te.length>0)),m=t.useCallback(F=>{var z;F.nativeEvent.isComposing||F.key==="Enter"&&(F.ctrlKey||F.metaKey)&&xe&&!B&&(F.preventDefault(),(z=F.currentTarget.form)==null||z.requestSubmit())},[xe,B]),T=te.length>0&&e.jsx("div",{className:"flex flex-wrap gap-3",children:te.map((F,z)=>e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:Jt(F),alt:F.filename??`attachment ${z+1}`,className:"h-24 w-24 rounded-2xl border border-border/70 object-cover"}),e.jsx("button",{type:"button",onClick:()=>c(z),className:"absolute -top-2 -right-2 flex h-6 w-6 items-center justify-center rounded-[10px] border border-border/70 bg-background text-muted-foreground shadow-sm transition-all hover:-translate-y-px hover:text-foreground","aria-label":`Remove ${F.filename??`image ${z+1}`}`,children:e.jsx(He,{className:"h-3.5 w-3.5"})})]},`${F.filename??"image"}-${z}`))}),W=e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Assign to"}),e.jsxs(Se,{value:U,onValueChange:oe,children:[e.jsx(Ce,{className:"h-11 rounded-[18px] border-border/70 bg-background/70",children:e.jsx(Me,{placeholder:"Select node"})}),e.jsx(Te,{children:Vs(I,n)})]})]}),Ne=e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Agent"}),e.jsxs(Se,{value:L,onValueChange:_,children:[e.jsx(Ce,{className:"h-11 rounded-[18px] border-border/70 bg-background/70",children:e.jsx(Me,{placeholder:"Select agent"})}),e.jsx(Te,{children:yt()})]})]}),we=e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Mode"}),e.jsxs(Se,{value:R,onValueChange:F=>Y(F),children:[e.jsx(Ce,{className:"h-11 rounded-[18px] border-border/70 bg-background/70",children:e.jsx(Me,{placeholder:"Select mode"})}),e.jsx(Te,{children:St()})]})]}),g=e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Priority"}),e.jsxs(Se,{value:K,onValueChange:A,children:[e.jsx(Ce,{className:"h-11 rounded-[18px] border-border/70 bg-background/70",children:e.jsx(Me,{placeholder:"Select priority"})}),e.jsxs(Te,{children:[e.jsx(ge,{value:"low",children:"Low"}),e.jsx(ge,{value:"normal",children:"Normal"}),e.jsx(ge,{value:"high",children:"High"}),e.jsx(ge,{value:"critical",children:"Critical"})]})]})]}),ke=e.jsx(ps,{value:ee,onChange:$,assignTo:U,nodes:s,assignableNodes:I}),ne=e.jsx(wt,{value:ue,onChange:D,project:ee,assignTo:U,nodes:s,assignableNodes:I});return d==="composer"?e.jsxs("form",{onSubmit:re,className:M("space-y-4",x),children:[e.jsx("input",{ref:X,type:"file",accept:"image/*",multiple:!0,onChange:ae,className:"hidden"}),(()=>{const F="chat-composer__chip h-9 w-auto gap-1.5 rounded-[15px] px-3.5 text-xs shadow-none transition-colors",z="border-transparent bg-transparent text-muted-foreground hover:bg-background/40 hover:text-foreground",me="border-border/70 bg-background/55 text-foreground",Ee=L==="claudecode",Ie=R===ts;return e.jsxs("div",{className:"chat-composer space-y-2",children:[e.jsxs("div",{className:"rounded-[26px] border border-border/60 bg-background/54 shadow-[0_24px_86px_-48px_rgba(15,23,42,0.55)] backdrop-blur-xl dark:shadow-[0_24px_86px_-48px_rgba(0,0,0,0.9)]",children:[e.jsxs("div",{className:"chat-composer__header flex min-w-0 items-center justify-between gap-3 px-4 pt-3",children:[e.jsxs(Se,{value:U,onValueChange:oe,children:[e.jsx(Ce,{className:M(F,me,"chat-composer__node-trigger border-transparent bg-transparent hover:bg-background/40"),title:`Assigned node: ${(P==null?void 0:P.name)??"unassigned"}`,"aria-label":`Assigned node: ${(P==null?void 0:P.name)??"unassigned"}`,children:P?e.jsxs(e.Fragment,{children:[e.jsx(et,{isCurrent:v}),e.jsx("span",{className:"min-w-0 truncate",children:P.name}),e.jsx("span",{className:"chat-composer__header-meta shrink-0 text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:v?"current":"remote"})]}):e.jsx(Me,{placeholder:"Select node"})}),e.jsx(Te,{children:Vs(I,n)})]}),se?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Fe,{id:"task-title-composer",type:"text",value:u,onChange:G=>b(G.target.value),onKeyDown:G=>{(G.key==="Enter"||G.key==="Escape")&&(G.preventDefault(),ie(!1))},autoFocus:!0,placeholder:"Chat title",className:"h-8 w-48 min-w-0 rounded-[13px] border-border/70 bg-background/55 px-3 text-xs shadow-none"}),e.jsx(O,{type:"button",variant:"ghost",size:"icon",onClick:()=>ie(!1),"aria-label":"Save title",className:"h-8 w-8 shrink-0 rounded-[12px] text-muted-foreground hover:text-foreground",children:e.jsx(es,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>ie(!0),className:"chat-composer__title-button flex min-w-0 items-center gap-1.5 rounded-[13px] px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-background/55 hover:text-foreground",title:V||"Title","aria-label":V?`Edit title: ${V}`:"Edit title",children:[e.jsx("span",{className:"chat-composer__title-text max-w-[220px] truncate",children:V||"Title"}),e.jsx(ns,{className:"h-3 w-3 shrink-0"})]})]}),e.jsx("textarea",{id:"task-description",value:j,onChange:G=>f(G.target.value),onKeyDown:m,onPaste:le,placeholder:"Ask anything...",rows:4,autoFocus:w,"aria-label":"Opening prompt",className:"min-h-[140px] w-full resize-none rounded-[24px] bg-transparent px-5 pt-2 pb-2 text-[15px] leading-7 text-foreground ring-offset-background placeholder:text-muted-foreground/70 focus-visible:outline-none"}),e.jsxs("div",{className:"chat-composer__rail flex flex-nowrap items-center gap-2 px-3 pb-3",children:[e.jsx(O,{type:"button",variant:"ghost",size:"icon",onClick:q,"aria-label":"Add images",className:"h-9 w-9 shrink-0 rounded-[14px] text-muted-foreground hover:text-foreground",children:e.jsx(Is,{className:"h-4 w-4"})}),e.jsx("span",{className:"mx-0.5 h-5 w-px bg-border/60","aria-hidden":!0}),e.jsxs(Se,{value:L,onValueChange:_,children:[e.jsxs(Ce,{className:M(F,"chat-composer__icon-trigger",Ee?z:me),title:`Agent: ${J}`,"aria-label":`Agent: ${J}`,children:[e.jsx(Ws,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label truncate",children:J})]}),e.jsx(Te,{children:yt()})]}),e.jsxs(Se,{value:R,onValueChange:G=>Y(G),children:[e.jsxs(Ce,{className:M(F,"chat-composer__icon-trigger",Ie?z:me),title:`Mode: ${h}`,"aria-label":`Mode: ${h}`,children:[e.jsx(zr,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label truncate",children:h})]}),e.jsx(Te,{children:St()})]}),e.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:[e.jsxs(Se,{value:K,onValueChange:A,children:[e.jsx(Ce,{"aria-label":`Priority: ${K}`,title:`Priority: ${K}`,className:M("h-9 w-9 justify-center gap-0 rounded-[14px] p-0 text-xs shadow-none [&>svg:last-child]:hidden",K==="normal"?"border-transparent bg-transparent text-muted-foreground hover:bg-background/40":"border-border/70 bg-background/55",K==="critical"&&"text-destructive",K==="high"&&"text-amber-600 dark:text-amber-400",K==="low"&&"text-muted-foreground"),children:e.jsx(hr,{className:M("h-4 w-4",K==="critical"&&"fill-destructive/20")})}),e.jsxs(Te,{children:[e.jsx(ge,{value:"low",children:"Low"}),e.jsx(ge,{value:"normal",children:"Normal"}),e.jsx(ge,{value:"high",children:"High"}),e.jsx(ge,{value:"critical",children:"Critical"})]})]}),i&&e.jsxs(O,{type:"button",variant:"ghost",size:"sm",onClick:i,"aria-label":N,className:"chat-composer__cancel h-9 rounded-[14px] px-4 text-xs text-muted-foreground",children:[e.jsx(He,{className:"chat-composer__cancel-icon h-4 w-4 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label",children:N})]}),e.jsxs(O,{type:"submit",size:"icon",disabled:!xe||B,className:"h-10 w-10 rounded-[16px] shadow-[0_8px_30px_-8px_hsl(var(--primary)/0.6)]",children:[B?e.jsx(be,{className:"h-4 w-4 animate-spin"}):e.jsx(sa,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:B?"Creating chat":y})]})]})]})]}),e.jsx("div",{className:"chat-composer__location flex flex-wrap items-center gap-2 px-1",children:(()=>{const G="border-border/40 bg-muted/40 text-foreground/80 hover:bg-muted/60 hover:text-foreground";return e.jsxs(e.Fragment,{children:[e.jsx(ps,{value:ee,onChange:$,assignTo:U,nodes:s,assignableNodes:I,layout:"composer",chipClassName:F,chipActiveClassName:G,chipInactiveClassName:G,triggerClassName:"chat-composer__icon-trigger",labelClassName:"chat-composer__location-label"}),e.jsx(wt,{value:ue,onChange:D,project:ee,assignTo:U,nodes:s,assignableNodes:I,layout:"composer",chipClassName:F,chipActiveClassName:G,chipInactiveClassName:G,triggerClassName:"chat-composer__icon-trigger",labelClassName:"chat-composer__location-label"})]})})()})]})})(),(T||H)&&e.jsxs("div",{className:"space-y-3 rounded-[20px] border border-border/60 bg-background/45 p-4",children:[T,H&&e.jsx("div",{className:"text-xs text-destructive",children:H}),!H&&e.jsx("div",{className:"text-xs text-muted-foreground",children:"Ctrl/Cmd+Enter starts the chat. Enter adds a new line. Paste screenshots directly into the prompt box or use the Images button."})]})]}):e.jsxs("form",{onSubmit:re,className:M("space-y-5",x),children:[e.jsx("input",{ref:X,type:"file",accept:"image/*",multiple:!0,onChange:ae,className:"hidden"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"task-description",className:"text-sm font-medium",children:"Opening prompt"}),e.jsx("textarea",{id:"task-description",value:j,onChange:F=>f(F.target.value),onKeyDown:m,onPaste:le,placeholder:"Describe what the agent should do. This becomes the first message in the chat.",rows:6,autoFocus:w,className:"flex min-h-[144px] w-full resize-none rounded-[22px] border border-border/70 bg-background/70 px-4 py-3 text-sm leading-6 ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(O,{type:"button",variant:"outline",onClick:q,className:"rounded-[16px]",children:[e.jsx(Is,{className:"h-4 w-4"}),"Add images"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Ctrl/Cmd+Enter starts the chat. Enter adds a new line. Upload or paste screenshots and reference images with the opening prompt."})]}),T,H&&e.jsx("p",{className:"text-xs text-destructive",children:H})]}),e.jsxs("div",{className:"grid gap-5 lg:grid-cols-[minmax(0,1fr)_220px_220px]",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"task-title",className:"text-sm font-medium",children:"Chat title"}),e.jsx(Fe,{id:"task-title",type:"text",value:u,onChange:F=>b(F.target.value),placeholder:"Optional. Leave blank to derive it from the prompt.",className:"h-11 rounded-[18px] border-border/70 bg-background/70"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:V?`Will appear as: ${V}`:"A title will be generated from the first line of the prompt."})]}),Ne,we]}),ke,ne,e.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[g,W]}),e.jsxs("div",{className:M("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",k),children:[i&&e.jsx(O,{type:"button",variant:"ghost",onClick:i,className:"rounded-[16px]",children:N}),e.jsx(O,{type:"submit",disabled:!xe||B,className:"rounded-[16px] px-5",children:B?"Creating...":y})]})]})}function Do({nodes:s,currentNodeRole:a,currentNodeId:n,leaderNodeId:o,onCreated:r,onCancel:i,defaultMode:x="chat",mode:k,onModeChange:y,layout:N="default",className:w,footerClassName:d,autoFocus:u=!1}){const[b,j]=t.useState(x),f=k!==void 0,L=f?k:b,_=R=>{f||j(R),y==null||y(R)};return e.jsxs("div",{className:M("space-y-4",w),children:[!f&&e.jsxs("div",{className:"flex items-center gap-2 rounded-[20px] border border-border/60 bg-background/45 p-1",children:[e.jsxs(O,{type:"button",variant:L==="chat"?"default":"ghost",onClick:()=>_("chat"),className:"flex-1 rounded-[16px]",children:[e.jsx(an,{className:"h-4 w-4"}),"New chat"]}),e.jsxs(O,{type:"button",variant:L==="native"?"default":"ghost",onClick:()=>_("native"),className:"flex-1 rounded-[16px]",children:[e.jsx(Ys,{className:"h-4 w-4"}),"Load session"]})]}),L==="chat"?e.jsx(_o,{nodes:s,currentNodeRole:a,currentNodeId:n,leaderNodeId:o,onCreated:r,onCancel:i,footerClassName:d,submitLabel:N==="composer"?"Start chat":"Create chat",cancelLabel:"Cancel",autoFocus:u,layout:N}):e.jsx(So,{nodes:s,currentNodeRole:a,currentNodeId:n,leaderNodeId:o,onCreated:r,onCancel:i,footerClassName:d,autoFocus:u})]})}const Je="72f988bf-86f1-41af-91ab-2d7cd011db47",ua=`${Je} (MSIT)`;function Ao({open:s,onOpenChange:a,onShare:n,onStopShare:o,sharing:r,stopping:i=!1,shareResult:x}){return e.jsx(Ot,{open:s,onOpenChange:a,children:e.jsxs(Rt,{className:"max-w-md rounded-[22px] p-5",children:[e.jsx($t,{className:"sr-only",children:"Share conversation"}),e.jsx(Mo,{onOpenChange:a,onShare:n,onStopShare:o,sharing:r,stopping:i,shareResult:x})]})})}function Mo({onOpenChange:s,onShare:a,onStopShare:n,sharing:o,stopping:r=!1,shareResult:i}){const[x,k]=t.useState((i==null?void 0:i.tenant)??Je),[y,N]=t.useState((i==null?void 0:i.scope)??"chat"),w=(i==null?void 0:i.url)??null,d=o||r;return t.useEffect(()=>{k((i==null?void 0:i.tenant)??Je),N((i==null?void 0:i.scope)??"chat")},[i==null?void 0:i.shareId,i==null?void 0:i.tenant,i==null?void 0:i.scope]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h2",{className:"text-base font-semibold leading-none tracking-tight",children:"Share conversation"}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"Create a tenant-gated link for this task."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(Lo,{value:x,onChange:k,disabled:d}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium text-foreground",children:"Access"}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Ct,{active:y==="chat",title:"Chat only",description:"Conversation transcript and opening prompt.",onClick:()=>N("chat")}),e.jsx(Ct,{active:y==="filesPreview",title:"Chat, files and preview",description:"Transcript plus task output files and HTML preview.",onClick:()=>N("filesPreview")})]})]}),w&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium text-foreground",children:"Shared link"}),e.jsxs("div",{className:"flex items-center gap-2 rounded-[16px] border border-border/70 bg-muted/30 px-3 py-2",children:[e.jsx("input",{readOnly:!0,value:w,className:"min-w-0 flex-1 bg-transparent font-mono text-xs text-foreground outline-none","aria-label":"Shared link"}),e.jsx(O,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 rounded-[12px] text-muted-foreground",onClick:()=>void Ge(w,"Shared link copied"),"aria-label":"Copy shared link",title:"Copy shared link",children:e.jsx(It,{className:"h-3.5 w-3.5"})})]})]})]}),e.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[e.jsx(O,{variant:"outline",onClick:()=>s(!1),disabled:d,className:"h-8 text-xs",children:i?"Done":"Cancel"}),i&&n&&e.jsxs(O,{variant:"outline",onClick:()=>void n(),disabled:d,className:"h-8 border-destructive/30 text-xs text-destructive hover:bg-destructive/10 hover:text-destructive",children:[r&&e.jsx(be,{className:"h-3.5 w-3.5 animate-spin"}),"Stop share"]}),e.jsxs(O,{onClick:()=>void a({tenant:x,scope:y}),disabled:d,className:"h-8 text-xs",children:[o&&e.jsx(be,{className:"h-3.5 w-3.5 animate-spin"}),i?"Update link":"Share link"]})]})]})}function Lo({value:s,onChange:a,disabled:n}){const[o,r]=t.useState(!1),[i,x]=t.useState(!1),[k,y]=t.useState(s),N=t.useRef(null);t.useEffect(()=>{y(s)},[s]),t.useEffect(()=>{if(!o)return;const d=b=>{var f;const j=b.target;j instanceof Node&&((f=N.current)!=null&&f.contains(j)||(r(!1),x(!1)))},u=b=>{b.key==="Escape"&&(r(!1),x(!1))};return document.addEventListener("mousedown",d),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("keydown",u)}},[o]);const w=d=>{const u=d.trim();u&&(a(u),y(u),x(!1),r(!1))};return e.jsxs("div",{className:"space-y-2 text-xs",ref:N,children:[e.jsx("div",{className:"font-medium text-foreground",children:"Tenant"}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>!n&&r(d=>!d),disabled:n,className:"flex h-9 w-full items-center justify-between gap-2 rounded-[15px] border border-border/70 bg-background/70 px-3 text-left text-xs text-foreground shadow-sm outline-none transition-colors hover:bg-background disabled:opacity-50",children:[e.jsx("span",{className:"min-w-0 truncate font-mono",children:Po(s)}),e.jsx(Ke,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"})]}),o&&e.jsxs("div",{className:"absolute left-0 right-0 z-50 mt-2 overflow-hidden rounded-[18px] border border-border/60 bg-background/95 text-xs shadow-lg backdrop-blur",children:[e.jsxs("button",{type:"button",onClick:()=>w(Je),className:"flex w-full items-center justify-between gap-2 px-3 py-2 text-left hover:bg-background/60",children:[e.jsx("span",{className:"min-w-0 truncate font-mono text-[11px]",children:ua}),s===Je&&e.jsx(es,{className:"h-3.5 w-3.5 shrink-0 text-primary"})]}),e.jsx("div",{className:"border-t border-border/60 bg-background/40 px-2.5 py-1.5",children:i?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{value:k,onChange:d=>y(d.target.value),onKeyDown:d=>{d.key==="Enter"&&(d.preventDefault(),w(k))},autoFocus:!0,placeholder:"Tenant ID",className:"h-7 min-w-0 flex-1 rounded-[11px] border border-border/60 bg-background/70 px-2 font-mono text-[11px] outline-none focus:ring-2 focus:ring-ring"}),e.jsx("button",{type:"button",onClick:()=>w(k),className:"flex h-7 w-7 items-center justify-center rounded-[11px] hover:bg-background/60",children:e.jsx(es,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>{y(s),x(!1)},className:"flex h-7 w-7 items-center justify-center rounded-[11px] text-muted-foreground hover:bg-background/60 hover:text-foreground",children:e.jsx(He,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>x(!0),className:"flex h-7 w-full items-center justify-between rounded-[11px] px-1.5 text-[11px] text-muted-foreground hover:bg-background/60 hover:text-foreground",children:[e.jsx("span",{children:"Manual tenant ID"}),e.jsx(ns,{className:"h-3 w-3"})]})})]})]})]})}function Po(s){return s===Je?ua:s}function Ct({active:s,title:a,description:n,onClick:o}){return e.jsxs("button",{type:"button",onClick:o,className:s?"rounded-[15px] border border-primary/45 bg-primary/10 px-3 py-2 text-left shadow-sm":"rounded-[15px] border border-border/70 bg-background px-3 py-2 text-left shadow-sm hover:bg-muted/50",children:[e.jsx("div",{className:"text-xs font-medium text-foreground",children:a}),e.jsx("div",{className:"mt-1 text-[11px] leading-4 text-muted-foreground",children:n})]})}const Ro=t.lazy(async()=>({default:(await Js(()=>import("./FilesTab-Df2rONWU.js"),__vite__mapDeps([0,1,2,3,4]))).FilesTab})),$o=t.lazy(async()=>({default:(await Js(()=>import("./PreviewTab-DrEmvcr6.js"),__vite__mapDeps([5,1,2,6]))).PreviewTab})),Fo=t.lazy(async()=>({default:(await Js(()=>import("./DiffTab-F1C8JivT.js"),__vite__mapDeps([7,1,2,4,3,8,6]))).DiffTab}));function Oo({onToggleTasks:s,desktopTasksOpen:a,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,cluster:i,sseConnected:x,activeTab:k,setActiveTab:y,creatingTask:N,createMode:w,activeTask:d,assignedNode:u,taskLoading:b,taskError:j,displayEvents:f,initialPromptAlreadyInLogs:L,initialPrompt:_,supportsFollowUp:R,taskUnavailable:Y,chatDisabled:ee,chatDisabledReason:$,questionBypassEnabled:ue,isRunning:D,isStarting:K,hasPendingFollowUp:A,canCancel:I,canRetry:S,onRetry:U,onCancel:oe,onShareTask:B,onStopShareTask:C,onStartCreateTask:se,onCancelCreateTask:ie,onCreateTask:te,onSendMessage:H,onQuestionBypassChange:X,onSubmitQuestionResponse:q,messagesEndRef:ae}){const[le,c]=t.useState(!1),[P,v]=t.useState(!1),[J,h]=t.useState(!1),[re,V]=t.useState(!1),[xe,m]=t.useState(!1),[T,W]=t.useState({}),[Ne,we]=t.useState(new Set),[g,ke]=t.useState(new Set),ne=t.useRef(0),F=t.useRef(!1),z=t.useRef(null),me=t.useRef(0),Ee=t.useCallback(de=>{const ve=de.currentTarget,ye=ne.current;if(ne.current=ve.scrollTop,F.current)return;if(ve.scrollHeight-ve.scrollTop-ve.clientHeight<30){c(!1),F.current=!0,setTimeout(()=>{F.current=!1},300);return}ve.scrollTop<ye&&ye-ve.scrollTop>10&&c(!0),ve.scrollTop<=0&&c(!0)},[]),Ie=(d==null?void 0:d.effectiveProjectPath)??(d==null?void 0:d.project)??"default workspace",G=d?(u==null?void 0:u.name)??Bt(d.assignedTo,i==null?void 0:i.nodes,d.assignedNodeName):"unassigned",Be=d!=null&&d.assignedTo?e.jsxs(e.Fragment,{children:["Connecting session on node ",e.jsx("span",{className:"font-medium text-foreground",children:G}),"..."]}):"Connecting session to an available node...",rs=d?[{label:"Working dir",value:Ie,mono:!0},...d.branch?[{label:"Branch",value:d.branch,mono:!0}]:[],{label:"Agent",value:d.agent,mono:!0},{label:"Node",value:G}]:[],os=!!(_&&!L),Xe=os||f.length>0,Qe=D&&Xe,$e=(K||A||D)&&!Qe,Oe=(d==null?void 0:d.conversationKind)==="nativeSession",fs=d&&!Ne.has(d.id)?T[d.id]??d.activeShare??null:null;return N?e.jsx(Io,{onToggleTasks:s,desktopTasksOpen:a,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,cluster:i,sseConnected:x,defaultMode:w,onCancel:ie,onCreated:te}):!d&&b?e.jsxs("div",{className:"dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-[28px]",children:[e.jsx("div",{className:"shrink-0 border-b border-border/55 bg-card/28 px-3 py-3 sm:px-5",children:e.jsx(Hs,{onToggleTasks:s,desktopTasksOpen:a,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,cluster:i,sseConnected:x})}),e.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-y-auto px-6 py-10 sm:px-8",children:e.jsxs("div",{className:"space-y-4 text-center",children:[e.jsx("div",{className:"mx-auto flex h-16 w-16 items-center justify-center rounded-[22px] border border-primary/20 bg-primary/10 text-primary shadow-sm",children:e.jsx(be,{className:"h-7 w-7 animate-spin"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h2",{className:"text-2xl font-semibold tracking-tight text-foreground",children:"Loading conversation"}),e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-[11px] text-muted-foreground",children:[e.jsx(be,{className:"h-4 w-4 animate-spin"}),"Fetching the selected chat thread..."]})]})]})})]}):d?e.jsxs(zt,{value:k,onValueChange:de=>{k==="transcript"&&z.current&&(me.current=z.current.scrollTop),y(de),de==="transcript"&&requestAnimationFrame(()=>{z.current&&(z.current.scrollTop=me.current)})},className:"dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-[28px]",children:[e.jsxs("div",{className:"shrink-0 border-b border-border/55 bg-card/28 px-3 py-3 sm:px-5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(xa,{desktopTasksOpen:a,mobileTasksPanelOpen:n,onToggleTasks:s}),e.jsx("h2",{className:"min-w-0 truncate text-sm font-semibold tracking-tight text-foreground sm:text-lg",title:d.title,children:d.title}),Oe&&e.jsx(Ae,{variant:"outline",className:"shrink-0 rounded-[11px] border-sky-500/30 bg-sky-500/10 text-sky-700 dark:text-sky-300",children:"Native session"}),e.jsx(Ut,{status:d.status}),e.jsx(rn,{priority:d.priority}),e.jsx(O,{variant:"outline",size:"icon",onClick:r,title:o?"Hide cluster":"Show cluster","aria-label":o?"Hide cluster":"Show cluster",className:"ml-auto h-7 w-7 shrink-0 rounded-[12px] border-border/70 bg-background/68",children:o?e.jsx(Qs,{className:"h-4 w-4"}):e.jsx(ea,{className:"h-4 w-4"})})]}),j&&e.jsx("div",{className:"mt-2 w-fit rounded-[12px] border border-destructive/25 bg-destructive/10 px-2 py-1 text-[11px] text-destructive",children:j}),e.jsxs("div",{className:"mt-2 flex items-center gap-1.5",children:[e.jsxs(Vt,{className:"h-auto max-w-full overflow-x-auto rounded-[16px] bg-muted/70 p-0.5",children:[e.jsx(ze,{value:"transcript",className:"rounded-[12px] px-2 py-0.5 text-[11px] sm:px-2.5",children:"Transcript"}),e.jsx(ze,{value:"files",className:"rounded-[12px] px-2 py-0.5 text-[11px] sm:px-2.5",children:"Files"}),e.jsx(ze,{value:"preview",className:"rounded-[12px] px-2 py-0.5 text-[11px] sm:px-2.5",children:"Preview"}),e.jsx(ze,{value:"diff",className:"rounded-[12px] px-2 py-0.5 text-[11px] sm:px-2.5",children:"Diff"})]}),D&&e.jsx(Ae,{variant:"outline",className:"hidden rounded-[11px] border-amber-500/30 bg-amber-500/10 text-amber-700 sm:inline-flex dark:text-amber-300",children:"Working"}),Y&&e.jsx(Ae,{variant:"outline",className:"hidden rounded-[11px] border-destructive/25 bg-destructive/10 text-destructive sm:inline-flex",children:"Unavailable"}),e.jsxs("div",{className:"ml-auto flex items-center gap-2 text-[10px] text-muted-foreground",children:[e.jsxs("span",{className:"hidden sm:inline",children:["updated ",on(d.updatedAt)]}),e.jsx("span",{className:"font-mono",children:d.id.slice(0,8)}),S&&e.jsxs(O,{variant:"outline",size:"sm",onClick:U,className:"h-7 shrink-0 rounded-[12px] px-2 text-[11px]",children:[e.jsx(Rr,{className:"h-3.5 w-3.5"}),"Retry"]}),e.jsxs(O,{type:"button",variant:"outline",size:"sm",disabled:Y,title:Y?"Unavailable tasks cannot be shared.":"Share conversation",className:"h-7 shrink-0 rounded-[12px] border-primary/30 bg-primary/10 px-2 text-[11px] text-primary hover:bg-primary/15 hover:text-primary disabled:border-border/60 disabled:bg-muted/40 disabled:text-muted-foreground",onClick:()=>h(!0),children:[e.jsx(Ir,{className:"h-3.5 w-3.5"}),"Share"]})]})]})]}),e.jsx(Ue,{value:"transcript",className:"mt-0 min-h-0 flex-1",children:e.jsxs("div",{className:"relative flex h-full min-h-0 flex-col",children:[e.jsx("div",{ref:z,className:"min-h-0 flex-1 touch-pan-y overflow-x-hidden overflow-y-auto overscroll-x-none bg-gradient-to-b from-background/15 via-transparent to-background/35 px-3 py-5 sm:px-5",onScroll:Ee,children:e.jsxs("div",{className:"mx-auto flex max-w-[72rem] flex-col gap-5",children:[os&&_&&e.jsx(bt,{event:_,questionBypassEnabled:ue,onQuestionBypassChange:X,onSubmitQuestionResponse:q,questionResponseDisabled:!R||ee}),f.map((de,ve)=>e.jsx(bt,{event:de,questionBypassEnabled:ue,onQuestionBypassChange:X,onSubmitQuestionResponse:q,questionResponseDisabled:!R||ee},er("transcript",de,ve))),!Xe&&!$e&&e.jsxs("div",{className:"rounded-[28px] border border-dashed border-border/70 bg-background/35 px-5 py-8 text-center",children:[e.jsx("div",{className:"text-[11px] font-medium text-foreground",children:"Transcript is warming up"}),e.jsx("div",{className:"mt-2 text-[11px] leading-6 text-muted-foreground",children:b?"Fetching task output...":Oe?"This native session is attached. Transcript starts after the next message you send from Meshy.":"The opening prompt has been stored, but the agent has not emitted conversation output yet."})]}),(!R&&d.result||d.error)&&e.jsxs("div",{className:"space-y-3",children:[!R&&d.result&&e.jsxs("div",{className:"rounded-[26px] border border-border/70 bg-card/80 px-3 py-3",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.22em] text-muted-foreground",children:"Stored result"}),e.jsx("pre",{className:"mt-3 overflow-x-auto whitespace-pre-wrap text-[11px] leading-5 text-muted-foreground",children:JSON.stringify(d.result,null,2)})]}),d.error&&!g.has(d.id)&&e.jsxs("div",{className:"rounded-[26px] border border-destructive/20 bg-destructive/10 px-3 py-3 text-destructive",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.22em]",children:"Stored error"}),e.jsx("button",{onClick:()=>ke(de=>new Set(de).add(d.id)),className:"rounded p-0.5 hover:bg-destructive/20","aria-label":"Dismiss error",children:e.jsx(He,{className:"h-3.5 w-3.5"})})]}),e.jsx("pre",{className:"mt-3 overflow-x-auto whitespace-pre-wrap text-[11px] leading-5",children:d.error})]})]}),$e&&e.jsx(Tt,{children:Be}),Qe&&e.jsx(Tt,{children:"The agent is still working on this conversation."}),e.jsx("div",{ref:ae})]})}),R?e.jsxs(e.Fragment,{children:[le&&e.jsx(O,{size:"icon",onClick:()=>c(!1),className:"absolute bottom-4 right-4 z-10 h-12 w-12 rounded-[18px] shadow-lg",children:e.jsx(ns,{className:"h-4 w-4"})}),e.jsx("div",{className:`shrink-0 ${le?"hidden":""}`,children:e.jsx("div",{className:"mx-auto w-full max-w-[72rem]",children:e.jsx(ro,{onSend:H,disabled:ee,disabledReason:$,contextItems:rs,placeholder:ee?$:"Continue the conversation...",running:D||A,onStop:I?()=>v(!0):void 0})})})]}):e.jsx("div",{className:"shrink-0 border-t border-border/60 px-3 py-3 text-[11px] text-muted-foreground sm:px-5",children:"This task does not expose follow-up chat messages. Use Files, Preview, or Diff to inspect the result."})]})}),e.jsx(Ue,{value:"files",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(t.Suspense,{fallback:e.jsx(Cs,{label:"Loading files..."}),children:e.jsx(Ro,{taskId:d.id})})}),e.jsx(Ue,{value:"preview",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(t.Suspense,{fallback:e.jsx(Cs,{label:"Loading preview..."}),children:e.jsx($o,{taskId:d.id})})}),e.jsx(Ue,{value:"diff",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(t.Suspense,{fallback:e.jsx(Cs,{label:"Loading diff..."}),children:e.jsx(Fo,{taskId:d.id})})}),e.jsx(_s,{open:P,onOpenChange:v,children:e.jsxs(Ds,{children:[e.jsxs(As,{children:[e.jsx(Ms,{children:"Stop this task?"}),e.jsx(Ls,{children:"The task will stop and move to a cancelled state."})]}),e.jsxs(Ps,{children:[e.jsx(Rs,{children:"Keep running"}),e.jsx($s,{onClick:oe,children:"Stop task"})]})]})}),e.jsx(Ao,{open:J,onOpenChange:h,sharing:re,stopping:xe,shareResult:fs,onShare:async de=>{if(!d)return null;V(!0);try{const ve=await B(de);return ve!=null&&ve.url&&(W(ye=>({...ye,[d.id]:ve})),we(ye=>{const Ze=new Set(ye);return Ze.delete(d.id),Ze})),ve}finally{V(!1)}},onStopShare:async()=>{if(!d)return!1;m(!0);try{const de=await C();return de!==!1&&(W(ve=>{const ye={...ve};return delete ye[d.id],ye}),we(ve=>new Set(ve).add(d.id))),de}finally{m(!1)}}})]}):e.jsxs("div",{className:"dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-[28px]",children:[e.jsx("div",{className:"shrink-0 border-b border-border/55 bg-card/28 px-3 py-3 sm:px-5",children:e.jsx(Hs,{onToggleTasks:s,desktopTasksOpen:a,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,cluster:i,sseConnected:x})}),e.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-y-auto px-6 py-10 sm:px-8",children:e.jsxs("div",{className:"w-full max-w-2xl text-center",children:[e.jsx("div",{className:"mx-auto flex h-16 w-16 items-center justify-center rounded-[22px] border border-primary/20 bg-primary/10 text-primary shadow-sm",children:e.jsx(Ws,{className:"h-7 w-7"})}),e.jsx("h2",{className:"mt-5 text-xl font-semibold tracking-tight text-foreground sm:text-3xl",children:"No chat selected"}),e.jsx("p",{className:"mx-auto mt-3 max-w-xl text-[11px] leading-6 text-muted-foreground",children:"Open a task from the left sidebar to continue the conversation, or start a new task or load a native session."}),e.jsxs(O,{onClick:se,className:"mt-6 rounded-[18px] px-5",children:[e.jsx(Xs,{className:"h-4 w-4"}),"Start or load chat"]}),j&&e.jsx("div",{className:"mx-auto mt-4 max-w-lg rounded-[20px] border border-destructive/20 bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:j})]})})]})}function Tt({children:s}){return e.jsxs("div",{className:"flex items-center gap-1.5 rounded-[18px] border border-border/60 bg-background/55 px-3 py-2 text-[11px] text-muted-foreground shadow-sm",children:[e.jsx(be,{className:"h-4 w-4 shrink-0 animate-spin"}),e.jsx("div",{className:"min-w-0 leading-5",children:s})]})}function Io({onToggleTasks:s,desktopTasksOpen:a,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,cluster:i,sseConnected:x,defaultMode:k,onCancel:y,onCreated:N}){var b,j,f;const[w,d]=t.useState(k??"chat");t.useEffect(()=>{k&&d(k)},[k]);const u=e.jsx("div",{className:"flex items-center gap-1 rounded-[18px] border border-border/60 bg-background/65 p-0.5 text-[11px] font-medium shadow-sm",children:[{value:"chat",label:"New chat",icon:Xs},{value:"native",label:"Load session",icon:Ys}].map(L=>{const _=L.icon,R=L.value===w;return e.jsxs("button",{type:"button",onClick:()=>d(L.value),"aria-pressed":R,className:M("flex items-center gap-1.5 rounded-[14px] px-2 py-1 transition-all duration-200",R?"bg-primary text-primary-foreground shadow-[0_8px_24px_-12px_hsl(var(--primary)/0.7)]":"text-muted-foreground hover:bg-background/80 hover:text-foreground"),children:[e.jsx(_,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:L.label})]},L.value)})});return e.jsxs("div",{className:"dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-[28px]",children:[e.jsx("div",{className:"shrink-0 border-b border-border/55 bg-card/28 px-3 py-3 sm:px-5",children:e.jsx(Hs,{onToggleTasks:s,desktopTasksOpen:a,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,cluster:i,sseConnected:x,centerSlot:u})}),e.jsx("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center overflow-y-auto px-6 py-10 sm:px-8",children:e.jsx("div",{className:"w-full max-w-2xl",children:e.jsx(Do,{nodes:(i==null?void 0:i.nodes)??[],currentNodeRole:(b=i==null?void 0:i.self)==null?void 0:b.role,currentNodeId:((j=i==null?void 0:i.self)==null?void 0:j.id)??null,leaderNodeId:((f=i==null?void 0:i.leader)==null?void 0:f.id)??null,mode:w,onModeChange:d,onCreated:N,onCancel:y,autoFocus:!0,layout:"composer"})})})]})}function Hs({onToggleTasks:s,desktopTasksOpen:a,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,centerSlot:i}){return e.jsxs("div",{className:"relative flex w-full items-center justify-between gap-1.5",children:[e.jsx("div",{className:"flex min-w-0 items-center gap-1.5",children:e.jsx(xa,{desktopTasksOpen:a,mobileTasksPanelOpen:n,onToggleTasks:s})}),i&&e.jsx("div",{className:"pointer-events-none absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2",children:e.jsx("div",{className:"pointer-events-auto",children:i})}),e.jsx(O,{variant:"outline",size:"icon",onClick:r,title:o?"Hide cluster":"Show cluster","aria-label":o?"Hide cluster":"Show cluster",className:"h-7 w-7 shrink-0 rounded-[12px] border-border/70 bg-background/68",children:o?e.jsx(Qs,{className:"h-4 w-4"}):e.jsx(ea,{className:"h-4 w-4"})})]})}function xa({desktopTasksOpen:s,mobileTasksPanelOpen:a,onToggleTasks:n}){var r,i;const o=(i=(r=globalThis.window)==null?void 0:r.matchMedia("(min-width: 1024px)"))!=null&&i.matches?s:a;return e.jsx(O,{variant:"outline",size:"icon",onClick:n,title:o?"Hide tasks":"Show tasks","aria-label":o?"Hide tasks":"Show tasks",className:"h-7 w-7 shrink-0 rounded-[12px] border-border/70 bg-background/68",children:o?e.jsx(Zt,{className:"h-4 w-4"}):e.jsx(Er,{className:"h-4 w-4"})})}const Bo=10,Ve="__all__";function Le(s){return"session"in s}function Et(s,a){var n;return a&&s.some(o=>o.id===a)?a:((n=s[0])==null?void 0:n.id)??""}function Es(s){return s&&(la(s.id)||s.workDir)||""}function xs(s,a,n){let o=!1;const r=s.map(i=>Le(i)&&i.session.id===n.id?(o=!0,{...i,nodeName:a,session:n}):i);return Ks(o?r:[...r,{id:`session-${n.id}`,nodeName:a,session:n}])}function ma(s,a){return s.filter(Le).filter(n=>n.session.nodeId===a).sort((n,o)=>o.session.startedAt-n.session.startedAt)}function zo(s){const a=s.filter(Le).sort((n,o)=>o.session.startedAt-n.session.startedAt);return{active:a.filter(n=>n.session.status==="running"),completed:a.filter(n=>n.session.status!=="running")}}function Uo(s,a){return!!(s&&a&&!s.contains(a))}function Vo(s,a,n){var r;if(n===Ve)return n;const o=ma(s,a);return o.some(i=>i.session.id===n)?n:((r=o[0])==null?void 0:r.session.id)??Ve}function Ho(s,a,n){return n===Ve?s.filter(o=>!Le(o)||o.session.nodeId===a):s.filter(o=>Le(o)&&o.session.nodeId===a&&o.session.id===n)}function Ks(s){const a=s.map((o,r)=>({entry:o,index:r})).filter(({entry:o})=>Le(o)&&o.session.status!=="running").sort((o,r)=>!Le(o.entry)||!Le(r.entry)?0:r.entry.session.startedAt-o.entry.session.startedAt||r.index-o.index),n=new Set(a.slice(0,Bo).map(({entry:o})=>Le(o)?o.session.id:""));return s.filter(o=>!Le(o)||o.session.status==="running"||n.has(o.session.id))}function qs(s){return s.status==="running"?s.pid?`running pid ${s.pid}`:"running":s.status==="exited"?`exit ${s.exitCode??0}`:s.status==="stopped"?"stopped":s.signal?`failed ${s.signal}`:`exit ${s.exitCode??"failed"}`}function Ko(s){const a=s.session.command.length>48?`${s.session.command.slice(0,45)}...`:s.session.command;return`${s.nodeName} - ${qs(s.session)} - ${a}`}function ha(s,a=48){return s.length>a?`${s.slice(0,a-3)}...`:s}function qo(s,a){return a===Ve?"All sessions":s?ha(s.session.command,34):"Command session"}function _t(s){return s.status==="stopped"?"":s.stderr}function Wo({nodes:s,defaultNodeId:a,onClose:n,initialHistory:o=[]}){const[r,i]=t.useState(()=>Et(s,a)),x=t.useMemo(()=>s.find(c=>c.id===r)??s[0]??null,[s,r]),[k,y]=t.useState(()=>Es(x)),[N,w]=t.useState(""),[d,u]=t.useState(()=>Ks(o)),[b,j]=t.useState(Ve),[f,L]=t.useState(!1),[_,R]=t.useState(!1),[Y,ee]=t.useState(!1),[$,ue]=t.useState(!1),[D,K]=t.useState(!1),A=t.useRef(null),I=t.useRef(null),S=t.useMemo(()=>s.find(c=>c.id===r)??s[0]??null,[s,r]),U=t.useMemo(()=>ma(d,(S==null?void 0:S.id)??""),[d,S]),oe=t.useMemo(()=>zo(U),[U]),B=t.useMemo(()=>U.find(c=>c.session.id===b),[b,U]),C=t.useMemo(()=>Ho(d,(S==null?void 0:S.id)??"",b),[d,S,b]),se=t.useRef((S==null?void 0:S.id)??"");t.useEffect(()=>{r&&s.some(c=>c.id===r)||i(Et(s,a))},[a,s,r]),t.useEffect(()=>{const c=(S==null?void 0:S.id)??"";se.current!==c&&(se.current=c,y(Es(S)))},[S]),t.useEffect(()=>{j(c=>Vo(d,(S==null?void 0:S.id)??"",f?c:""))},[d,S,f]),t.useEffect(()=>{var c;(c=A.current)==null||c.scrollTo({top:A.current.scrollHeight})},[d]),t.useEffect(()=>{let c=!1;async function P(){const v=await Promise.allSettled(s.map(async J=>({node:J,response:await dn(J.id)})));c||u(J=>v.reduce((h,re)=>re.status!=="fulfilled"?h:re.value.response.sessions.reduce((V,xe)=>xs(V,re.value.node.name,xe),h),J))}return s.length>0&&P(),()=>{c=!0}},[s]),t.useEffect(()=>{const c=d.filter(Le).filter(v=>v.session.status==="running");if(c.length===0)return;const P=window.setInterval(()=>{for(const v of c)ln(v.session.nodeId,v.session.id).then(J=>u(h=>xs(h,v.nodeName,J))).catch(()=>{})},1e3);return()=>window.clearInterval(P)},[d]);const ie=t.useRef(null);async function te(c){if(c.preventDefault(),!S||!N.trim()||D)return;const P=N.trim(),v=S.name;K(!0),w("");try{const J=await un(S.id,{command:P,...k.trim()?{cwd:k.trim()}:{}});u(h=>xs(h,v,J)),j(J.id),L(!0)}catch(J){u(h=>[...h,{id:`${Date.now()}-${Math.random().toString(16).slice(2)}`,nodeName:v,command:P,error:J instanceof Error?J.message:"Command failed"}])}finally{K(!1)}}async function H(c,P){c.stopPropagation();const v=await cn(P.session.nodeId,P.session.id);u(J=>xs(J,P.nodeName,v))}function X(c){j(c),L(!0),R(!1)}function q(c){_&&Uo(I.current,c.target)&&R(!1)}function ae(c,P,v,J,h){return e.jsxs("div",{className:"border-t border-border/60 py-1",children:[e.jsxs("button",{type:"button",onClick:J,"aria-label":`Toggle ${c} sessions`,"aria-expanded":!v,className:"flex w-full items-center justify-between gap-2 px-2 pb-1 pt-0.5 text-left text-[10px] font-medium uppercase tracking-normal text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:[e.jsx("span",{children:c}),e.jsx(Ke,{className:M("h-3 w-3 transition-transform",v&&"-rotate-90")})]}),!v&&(P.length>0?P.map(le):e.jsx("div",{className:"px-2 py-1 text-[11px] text-muted-foreground",children:h}))]})}function le(c){const P=b===c.session.id,v=c.session.status==="running";return e.jsxs("div",{className:M("group flex w-full items-center gap-2 px-2 py-1.5 text-left text-[11px] transition-colors hover:bg-muted/65",P&&"bg-primary/10 text-primary"),children:[e.jsxs("button",{type:"button",onClick:()=>X(c.session.id),className:"flex min-w-0 flex-1 items-center gap-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:[e.jsx("span",{className:M("flex h-4 w-4 shrink-0 items-center justify-center",v?"text-primary":c.session.status==="exited"?"text-emerald-600 dark:text-emerald-300":"text-amber-600 dark:text-amber-300"),children:v?e.jsx(be,{className:"h-3 w-3 animate-spin"}):c.session.status==="exited"?e.jsx(ht,{className:"h-3 w-3"}):e.jsx(ms,{className:"h-3 w-3"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-foreground",children:ha(c.session.command,44)}),e.jsxs("span",{className:"block truncate text-[10px] text-muted-foreground",children:[c.nodeName," · ",qs(c.session)]})]})]}),v&&e.jsx("button",{type:"button",onClick:J=>void H(J,c),"aria-label":"Stop terminal session from selector",title:"Stop terminal session",className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:e.jsx(Nt,{className:"h-3 w-3"})})]},c.session.id)}return e.jsx("section",{className:"dashboard-panel animate-composer-settle shrink-0 overflow-visible rounded-[24px]","aria-label":"Node terminal",onClick:q,children:e.jsxs("div",{className:"flex w-full flex-col overflow-visible rounded-[inherit] bg-card/72 text-card-foreground",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b border-border/60 px-3 py-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-[11px] font-medium",children:[n?e.jsx("button",{type:"button",onClick:n,"aria-label":"Close terminal",title:"Close terminal",className:"flex h-6 w-6 items-center justify-center rounded-md text-primary transition-colors hover:bg-muted/65 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:e.jsx(Ss,{className:"h-3.5 w-3.5"})}):e.jsx(Ss,{className:"h-3.5 w-3.5 text-primary"}),e.jsx("span",{children:"Terminal"})]}),e.jsxs("div",{className:"ml-auto flex min-w-0 flex-wrap items-center justify-end gap-2",children:[e.jsxs("div",{ref:I,className:"relative min-w-0",children:[e.jsxs("button",{type:"button","aria-label":"Command session","aria-expanded":_,title:B?Ko(B):"All sessions",onClick:()=>R(c=>!c),className:"flex h-7 max-w-[14rem] list-none items-center gap-1.5 rounded-[10px] border border-border/70 bg-background/70 px-2 text-[11px] text-foreground outline-none transition-colors hover:bg-muted/65 focus-visible:ring-2 focus-visible:ring-ring/70 [&::-webkit-details-marker]:hidden",children:[e.jsx("span",{className:"min-w-0 truncate",children:qo(B,b)}),e.jsx(Ke,{className:M("h-3 w-3 shrink-0 text-muted-foreground transition-transform",_&&"rotate-180")})]}),e.jsx("div",{"aria-hidden":!_,className:M("absolute right-0 bottom-9 z-30 w-[19rem] overflow-hidden rounded-xl border border-border/70 bg-popover text-popover-foreground shadow-xl",!_&&"hidden"),children:e.jsxs("div",{className:"max-h-72 overflow-y-auto",children:[e.jsxs("button",{type:"button",onClick:()=>X(Ve),className:M("flex w-full items-center gap-2 px-2 py-1.5 text-left text-[11px] transition-colors hover:bg-muted/65 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",b===Ve&&"bg-primary/10 text-primary"),children:[e.jsx(Ss,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:"All sessions"})]}),ae("Active",oe.active,Y,()=>ee(c=>!c),"No active sessions"),ae("Completed",oe.completed,$,()=>ue(c=>!c),"No completed sessions")]})})]}),e.jsx("select",{value:(S==null?void 0:S.id)??"",onChange:c=>{i(c.target.value),L(!1),y(Es(s.find(P=>P.id===c.target.value)??null))},disabled:D||s.length===0,"aria-label":"Terminal node",className:"h-7 max-w-[11rem] rounded-[10px] border border-border/70 bg-background/70 px-2 text-[11px] text-foreground outline-none transition-colors hover:bg-muted/65 disabled:opacity-50",children:s.map(c=>e.jsx("option",{value:c.id,className:"bg-background text-foreground",children:c.name},c.id))}),e.jsx(ps,{value:k,onChange:y,assignTo:(S==null?void 0:S.id)??"",nodes:s,assignableNodes:s,layout:"composer",chipClassName:"h-7 max-w-[18rem] rounded-[10px] border border-border/70 bg-background/70 px-2 text-[11px] text-foreground hover:bg-muted/65",chipActiveClassName:"font-mono",chipInactiveClassName:"text-muted-foreground",labelClassName:"text-[11px]",triggerClassName:"terminal-workdir-trigger",popoverPlacement:"top",popoverAlign:"end"})]})]}),e.jsxs("div",{ref:A,className:"max-h-64 min-h-[8rem] overflow-y-auto bg-muted/22 px-3 py-2 font-mono text-[11px] leading-5 cursor-text",onClick:()=>{var c;return(c=ie.current)==null?void 0:c.focus()},children:[C.length===0?e.jsx("div",{className:"text-muted-foreground mb-2",children:"Commands run on the selected node and stay visible while running or after exit."}):e.jsx("div",{className:"space-y-3 mb-2",children:C.map(c=>Le(c)?e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-muted-foreground",children:[e.jsxs("span",{className:"text-primary",children:[c.nodeName,"$"]}),e.jsx("span",{className:"break-all text-foreground",children:c.session.command}),e.jsxs("span",{className:M("inline-flex items-center gap-1",c.session.status==="running"||c.session.status==="exited"?"text-primary":"text-amber-600 dark:text-amber-300"),children:[c.session.status==="running"?e.jsx(be,{className:"h-3 w-3 animate-spin"}):c.session.status==="exited"?e.jsx(ht,{className:"h-3 w-3"}):e.jsx(ms,{className:"h-3 w-3"}),qs(c.session)]}),c.session.status==="running"&&e.jsx("button",{type:"button",onClick:P=>void H(P,c),"aria-label":"Stop terminal session",title:"Stop terminal session",className:"inline-flex h-5 w-5 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted/65 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:e.jsx(Nt,{className:"h-3 w-3"})})]}),c.session.stdout&&e.jsx("pre",{className:"whitespace-pre-wrap break-words text-foreground",children:c.session.stdout}),_t(c.session)&&e.jsx("pre",{className:"whitespace-pre-wrap break-words text-destructive",children:_t(c.session)}),(c.session.stdoutTruncated||c.session.stderrTruncated)&&e.jsx("div",{className:"text-muted-foreground",children:"Output truncated to the latest output."})]},c.id):e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-muted-foreground",children:[e.jsxs("span",{className:"text-primary",children:[c.nodeName,"$"]}),e.jsx("span",{className:"break-all text-foreground",children:c.command}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-destructive",children:[e.jsx(ms,{className:"h-3 w-3"}),"error"]})]}),e.jsx("pre",{className:"whitespace-pre-wrap break-words text-destructive",children:c.error})]},c.id))}),e.jsxs("form",{onSubmit:te,className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"shrink-0 text-primary select-none",children:S?`${S.name}$`:"$"}),e.jsx("input",{ref:ie,value:N,onChange:c=>w(c.target.value),disabled:!S||D,placeholder:S?"":"No online nodes available",className:"flex-1 min-w-0 bg-transparent border-none outline-none text-foreground placeholder:text-muted-foreground font-mono text-[11px] caret-primary disabled:opacity-50",autoComplete:"off",spellCheck:!1}),e.jsx("button",{type:"submit","aria-label":"Run",title:"Run",disabled:!S||!N.trim()||D,className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-md text-primary transition-colors hover:bg-muted/65 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70 disabled:pointer-events-none disabled:text-muted-foreground disabled:opacity-50",children:D?e.jsx(be,{className:"h-3 w-3 animate-spin"}):e.jsx(lr,{className:"h-3 w-3"})})]})]})]})})}function Dt({cluster:s,systemInfo:a,nodeNameById:n,nodeBlockingTaskCounts:o,eventTypeFilter:r,onEventTypeFilterChange:i,eventTypeOptions:x,filteredEvents:k,sseConnected:y,clusterLoading:N,clusterError:w,promotePending:d,onPromote:u,onAddNode:b,leavePending:j,onLeaveCluster:f,onToggleNodeDevTunnel:L,devTunnelNodeId:_,onClose:R}){var U,oe,B;const Y=((U=s==null?void 0:s.self)==null?void 0:U.role)==="leader",ee=((oe=s==null?void 0:s.self)==null?void 0:oe.role)==="follower"&&!(s!=null&&s.leader),$=(s==null?void 0:s.self)??null,D=xn((s==null?void 0:s.nodes)??[],$==null?void 0:$.id).filter(C=>C.id!==($==null?void 0:$.id)),K=s!=null&&s.leader?s.nodes.find(C=>{var se;return C.id===((se=s.leader)==null?void 0:se.id)})??null:null,A=s!=null&&s.leader?s.leader.dashboardOrigin??(K==null?void 0:K.dashboardOrigin)??(a&&s.leader.id===(a.nodeId??a.id)?a.dashboardOrigin:void 0)??s.leader.endpoint:null,I=($==null?void 0:$.role)==="leader"&&D.length===0,S=($==null?void 0:$.role)==="follower";return e.jsx("aside",{className:"dashboard-panel dashboard-panel-muted animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-[28px]",children:e.jsxs(zt,{defaultValue:"overview",className:"flex h-full min-h-0 flex-col",children:[e.jsxs("div",{className:"shrink-0 border-b border-border/55 bg-card/24 px-3 py-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-base font-semibold tracking-tight",children:"Operations"}),e.jsx("p",{className:"mt-0.5 text-[10px] text-muted-foreground",children:"Node, cluster, and live events."})]}),e.jsx(O,{variant:"ghost",size:"icon",onClick:R,className:"h-7 w-7 rounded-[12px]",children:e.jsx(Qs,{className:"h-4 w-4"})})]}),e.jsxs(Vt,{className:"mt-2 grid h-auto w-full grid-cols-3 rounded-[16px] bg-muted/70 p-0.5",children:[e.jsx(ze,{value:"overview",className:"rounded-[12px] px-2 py-0.5 text-[11px]",children:"Overview"}),e.jsx(ze,{value:"nodes",className:"rounded-[12px] px-2 py-0.5 text-[11px]",children:"Nodes"}),e.jsx(ze,{value:"events",className:"rounded-[12px] px-2 py-0.5 text-[11px]",children:"Live events"})]})]}),e.jsx(Ue,{value:"overview",className:"mt-0 min-h-0 flex-1",children:e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-y-auto px-3 py-3",children:e.jsxs("div",{className:"space-y-4",children:[$&&e.jsx(At,{node:$,systemInfo:a,blockingTaskCount:o.get($.id)??0,devTunnelNodeId:_,onToggleNodeDevTunnel:L,showActions:!1,defaultExpanded:!1}),e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-1.5",children:[e.jsx("div",{className:"text-[11px] font-medium text-foreground",children:"Cluster snapshot"}),e.jsx(Ae,{variant:"outline",className:"rounded-[11px] border-border/70 bg-background/60",children:y?"Connected":"Reconnecting"})]}),N&&!s?e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[e.jsx(be,{className:"h-4 w-4 animate-spin"}),"Loading cluster state..."]}):w&&!s?e.jsx("div",{className:"rounded-[18px] border border-destructive/20 bg-destructive/10 px-2.5 py-2 text-[11px] text-destructive",children:w}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsx(We,{label:"Term",value:String((s==null?void 0:s.term)??0)}),e.jsx(We,{label:"Nodes",value:String((s==null?void 0:s.nodes.length)??0)}),e.jsx(We,{label:"Pending",value:String((s==null?void 0:s.taskSummary.pending)??0)}),e.jsx(We,{label:"Running",value:String((s==null?void 0:s.taskSummary.running)??0)}),e.jsx(We,{label:"Completed",value:String((s==null?void 0:s.taskSummary.completed)??0)}),e.jsx(We,{label:"Failed",value:String((s==null?void 0:s.taskSummary.failed)??0)})]}),e.jsxs("div",{className:"space-y-2 rounded-[18px] border border-border/60 bg-background/52 px-2.5 py-2.5 shadow-sm",children:[e.jsx(Re,{label:"Leader",value:((B=s==null?void 0:s.leader)==null?void 0:B.name)??"None"}),e.jsx(Re,{label:"Leader URL",value:A??"Unavailable",mono:!0,action:A?e.jsx(as,{label:"Copy leader URL",onClick:()=>void Ge(A,"Leader URL copied")}):void 0}),e.jsx(Re,{label:"Feed",value:y?"Receiving live updates":"Reconnecting to event stream"})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:ee&&e.jsxs(O,{variant:"outline",size:"sm",onClick:u,disabled:d,className:"h-7 rounded-[12px] px-2.5 text-[11px]",children:[d&&e.jsx(be,{className:"h-3.5 w-3.5 animate-spin"}),"Promote self"]})})]})]})]})})}),e.jsx(Ue,{value:"nodes",className:"mt-0 min-h-0 flex-1",children:e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-y-auto px-3 py-3",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-1.5",children:[e.jsx("div",{className:"text-[11px] font-medium text-foreground",children:"This node"}),I?e.jsx(O,{variant:"outline",size:"sm",onClick:b,className:"h-7 rounded-[12px] px-2.5 text-[11px]",children:"Join node"}):S?e.jsxs(O,{variant:"outline",size:"sm",onClick:f,disabled:j,className:"h-7 rounded-[12px] px-2.5 text-[11px]",children:[j&&e.jsx(be,{className:"h-3.5 w-3.5 animate-spin"}),"Leave cluster"]}):null]}),$&&e.jsx(At,{node:$,systemInfo:a,blockingTaskCount:o.get($.id)??0,devTunnelNodeId:_,onToggleNodeDevTunnel:L,showActions:!0,defaultExpanded:!0})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"text-[11px] font-medium text-foreground",children:["Peer nodes (",D.length,")"]}),D.length>0?e.jsx("div",{className:"space-y-2",children:D.map(C=>e.jsx(Go,{node:C,isLeader:!!Y,blockingTaskCount:o.get(C.id)??0,devTunnelNodeId:_,onToggleNodeDevTunnel:L},C.id))}):e.jsx("div",{className:"rounded-[20px] border border-dashed border-border/70 bg-background/35 px-3 py-3 text-[11px] text-muted-foreground",children:"No peer nodes are connected yet."})]})]})})}),e.jsx(Ue,{value:"events",className:"mt-0 min-h-0 flex-1",children:e.jsxs("div",{className:"flex h-full min-h-0 flex-col px-3 py-3",children:[e.jsxs("div",{className:"mb-3 space-y-2",children:[e.jsx("div",{children:e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-medium text-foreground",children:[e.jsx(mn,{className:M("h-4 w-4",y?"text-emerald-500":"text-destructive")}),"Live events"]})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsxs(Se,{value:r,onValueChange:i,children:[e.jsx(Ce,{className:"h-7 min-w-[11rem] flex-1 rounded-[13px] border-border/70 bg-background/60 text-[11px] sm:max-w-[15rem]",children:e.jsx(Me,{placeholder:"Event type"})}),e.jsx(Te,{children:x.map(C=>e.jsx(ge,{value:C,className:"text-[11px]",children:C==="all"?"All event types":C},C))})]}),e.jsx(Ae,{variant:"outline",className:"rounded-[11px] border-border/70 bg-background/60",children:y?"Connected":"Reconnecting"})]})]}),e.jsx("div",{className:"min-h-0 flex-1",children:e.jsx(hn,{events:k,maxHeight:"100%",emptyTitle:r==="all"?"No live events yet":"No matching events",emptyDescription:r==="all"?"Cluster activity appears here as it happens.":`No "${r}" events are in the current stream.`,nodeNameById:n})})]})})]})})}function At({node:s,systemInfo:a,blockingTaskCount:n,devTunnelNodeId:o,onToggleNodeDevTunnel:r,showActions:i=!0,defaultExpanded:x=!1}){const[k,y]=t.useState(x),N=(a==null?void 0:a.dashboardOrigin)??s.dashboardOrigin,w=s.devtunnelEndpoint??s.endpoint,d=N??s.endpoint,u=(a==null?void 0:a.workDir)??s.workDir,b=aa(s,a==null?void 0:a.transportType),j=Zs(s,a==null?void 0:a.transportType),f=j&&Ye((a==null?void 0:a.transportType)??s.transportType)?!0:ta(s,a==null?void 0:a.transportType),L=n>0;return e.jsxs("section",{className:"rounded-[22px] border border-primary/20 bg-primary/8 shadow-[0_24px_80px_-60px_hsl(var(--primary)/0.9)]",children:[e.jsxs("button",{type:"button",onClick:()=>y(_=>!_),className:"w-full px-3 py-2 text-left",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[k?e.jsx(Ke,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):e.jsx(ss,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx(Ht,{status:s.status}),e.jsx("span",{className:"text-[11px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:"Current node"}),e.jsx("a",{href:d,target:"_blank",rel:"noreferrer",onClick:_=>_.stopPropagation(),className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-primary",title:"Open Dashboard",children:e.jsx(Kt,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5 pl-6",children:[e.jsx("span",{className:"text-[11px] font-semibold tracking-tight text-foreground",children:s.name}),e.jsx(qt,{role:s.role}),e.jsx(Ae,{variant:"outline",className:"rounded-[11px] border-primary/30 bg-background/60 text-[10px] capitalize",children:s.status})]})]}),k&&e.jsxs("div",{className:"space-y-3 border-t border-primary/15 px-3 pb-3 pt-2.5",children:[e.jsxs("div",{className:"space-y-2 rounded-[16px] border border-primary/20 bg-background/72 px-2 py-2 shadow-sm",children:[e.jsx(Re,{label:"Node ID",value:s.id,mono:!0}),N&&e.jsx(Re,{label:"Dashboard",value:N,mono:!0,action:e.jsx(as,{label:"Copy dashboard URL",onClick:()=>void Ge(N,"Dashboard URL copied")})}),e.jsx(Re,{label:"Node URL",value:w,mono:!0,action:e.jsx(as,{label:"Copy node URL",onClick:()=>void Ge(w,"Node URL copied")})}),u&&e.jsx(Re,{label:"Workspace",value:u,mono:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-1.5",children:[e.jsx(Fs,{label:"Transport",value:b}),a&&e.jsx(Fs,{label:"Uptime",value:pn(a.uptime),mono:!0})]}),e.jsx(Yt,{capabilities:s.capabilities,action:i&&f?e.jsxs(O,{variant:"outline",size:"sm",onClick:()=>r(s),disabled:o===s.id||L,className:"h-7 rounded-[12px] px-2.5 text-[11px]",title:L?"Finish assigned or running tasks before changing remote access":void 0,children:[o===s.id&&e.jsx(be,{className:"h-3.5 w-3.5 animate-spin"}),j?"Disable Remote Access":"Enable Remote Access"]}):void 0}),i&&f&&L&&e.jsxs("div",{className:"text-[11px] text-muted-foreground",children:[n," active task",n===1?"":"s"," on this node."]})]})]})}function Go({node:s,isLeader:a,blockingTaskCount:n,devTunnelNodeId:o,onToggleNodeDevTunnel:r}){const[i,x]=t.useState(!1),k=s.dashboardOrigin,y=s.devtunnelEndpoint??s.endpoint,N=k??s.endpoint,w=aa(s),d=Zs(s),u=ta(s),b=n>0;return e.jsxs("div",{className:"rounded-[18px] border border-border/60 bg-background/50 shadow-sm",children:[e.jsxs("button",{type:"button",onClick:()=>x(j=>!j),className:"w-full px-3 py-2 text-left",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[i?e.jsx(Ke,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):e.jsx(ss,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx(Ht,{status:s.status}),e.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:"Peer node"}),e.jsx("a",{href:N,target:"_blank",rel:"noreferrer",onClick:j=>j.stopPropagation(),className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-primary",title:"Open Dashboard",children:e.jsx(Kt,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"mt-1 flex items-center gap-1.5 pl-5",children:[e.jsx("span",{className:"text-[11px] font-semibold text-foreground",children:s.name}),e.jsx(qt,{role:s.role}),e.jsx(Ae,{variant:"outline",className:"rounded-[11px] border-border/70 bg-background/60 text-[10px] capitalize",children:s.status})]})]}),i&&e.jsxs("div",{className:"space-y-3 border-t border-border/50 px-3 pb-3 pt-2.5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{label:"Node ID",value:s.id,mono:!0}),k&&e.jsx(Re,{label:"Dashboard",value:k,mono:!0,action:e.jsx(as,{label:"Copy dashboard URL",onClick:()=>void Ge(k,"Dashboard URL copied")})}),e.jsx(Re,{label:"Node URL",value:y,mono:!0,action:e.jsx(as,{label:"Copy node URL",onClick:()=>void Ge(y,"Node URL copied")})}),s.workDir&&e.jsx(Re,{label:"Workspace",value:s.workDir,mono:!0}),e.jsx(Fs,{label:"Transport",value:w})]}),e.jsx(Yt,{capabilities:s.capabilities,action:a&&u?e.jsxs(O,{variant:"outline",size:"sm",onClick:()=>r(s),disabled:o===s.id||b,className:"h-7 rounded-[12px] px-2.5 text-[11px]",title:b?"Finish assigned or running tasks before changing remote access":void 0,children:[o===s.id&&e.jsx(be,{className:"h-3.5 w-3.5 animate-spin"}),d?"Disable Remote Access":"Enable Remote Access"]}):void 0}),a&&u&&b&&e.jsxs("div",{className:"text-[11px] text-muted-foreground",children:[n," active task",n===1?"":"s"," on this node."]})]})]})}function as({label:s,onClick:a}){return e.jsx(O,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 rounded-[12px] text-muted-foreground",onClick:a,"aria-label":s,title:s,children:e.jsx(It,{className:"h-3.5 w-3.5"})})}function Jo(s,a,n,o){var x;if(!s)return{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Select a task to continue the conversation."};const r=((x=a==null?void 0:a.self)==null?void 0:x.role)==="follower";return s.assignedTo!==null&&s.assignedNodeAvailable===!1?{taskUnavailable:!0,chatDisabled:!0,chatDisabledReason:`${s.assignedNodeName??"Assigned node"} is unavailable. Leave the cluster on that node or re-run the task elsewhere.`}:r?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Follower nodes are read-only. Use the leader dashboard to manage chat, or leave the cluster first."}:n||o?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Waiting for the current turn to finish..."}:hs.has(s.status)||s.status==="archived"?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:hs.has(s.status)?"Task has not started yet...":"Archived tasks are read-only."}:{taskUnavailable:!1,chatDisabled:!1,chatDisabledReason:"Continue the conversation..."}}function Mt({toolbarTasks:s,activeTaskId:a,tasksLoading:n,tasksError:o,isLeader:r,scope:i,agentFilter:x,nodeFilter:k,taskKindFilter:y,agentOptions:N,nodeOptions:w,nodeNameById:d,nodeStatusById:u,leaderNodeId:b,searchQuery:j,selectedTaskIds:f,allVisibleTasksSelected:L,someVisibleTasksSelected:_,canBatchArchive:R,onSearchChange:Y,onScopeChange:ee,onAgentFilterChange:$,onNodeFilterChange:ue,onTaskKindFilterChange:D,onToggleTaskSelected:K,onToggleAllVisibleTasks:A,onBatchArchive:I,onBatchDelete:S,onCreateTask:U,onSelectTask:oe,onClose:B}){const[C,se]=t.useState(!!j),[ie,te]=t.useState(!1),[H,X]=t.useState(!1),q=t.useRef(null),ae=t.useRef(null),le=t.useRef(null),c=f.size,P=i!=="active"||k!=="all"||x!=="all"||y!=="all",v=j.trim().length>0,[J,h]=t.useState(new Set),[re,V]=t.useState(new Set),xe=t.useMemo(()=>fn(s,d,b),[s,d,b]),m=xe.length===1,T=!m||P||v,W=m&&(P||v),Ne=t.useCallback(g=>{h(ke=>{const ne=new Set(ke);return ne.has(g)?ne.delete(g):ne.add(g),ne})},[]),we=t.useCallback(g=>{V(ke=>{const ne=new Set(ke);return ne.has(g)?ne.delete(g):ne.add(g),ne})},[]);return t.useEffect(()=>{j&&se(!0)},[j]),t.useEffect(()=>{var g;C&&((g=q.current)==null||g.focus())},[C]),t.useEffect(()=>{if(!C)return;const g=ne=>{var z;const F=ne.target;F instanceof Node&&((z=ae.current)!=null&&z.contains(F)||se(!1))},ke=ne=>{ne.key==="Escape"&&se(!1)};return document.addEventListener("mousedown",g),document.addEventListener("keydown",ke),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",ke)}},[C]),t.useEffect(()=>{if(!H)return;const g=ne=>{var z;const F=ne.target;F instanceof Node&&((z=le.current)!=null&&z.contains(F)||X(!1))},ke=ne=>{ne.key==="Escape"&&X(!1)};return document.addEventListener("mousedown",g),document.addEventListener("keydown",ke),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",ke)}},[H]),e.jsxs("aside",{className:"dashboard-panel dashboard-panel-muted animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-[28px]",children:[e.jsxs("div",{className:"shrink-0 border-b border-border/55 bg-card/24 px-3 py-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-1.5",children:[e.jsx("div",{className:"text-lg font-semibold tracking-tight text-foreground",children:"Tasks"}),e.jsx(O,{variant:"ghost",size:"icon",onClick:B,className:"rounded-[12px]",children:e.jsx(Zt,{className:"h-4 w-4"})})]}),e.jsxs("div",{ref:ae,className:"mt-4 flex items-center gap-1.5",children:[e.jsxs("div",{ref:le,className:M("relative flex items-stretch transition-[flex] duration-200",C?"flex-[2]":"flex-1"),children:[e.jsxs(O,{onClick:()=>{X(!1),U("chat")},className:"h-11 flex-1 justify-start rounded-l-[18px] rounded-r-none px-3 text-left shadow-[0_18px_48px_-30px_hsl(var(--primary)/0.95)]",children:[e.jsx(Xs,{className:"h-4 w-4"}),"New chat"]}),e.jsx(O,{onClick:()=>X(g=>!g),"aria-label":"More chat options","aria-haspopup":"menu","aria-expanded":H,className:"h-11 w-9 rounded-l-none rounded-r-[18px] border-l border-primary-foreground/20 px-0 shadow-[0_18px_48px_-30px_hsl(var(--primary)/0.95)]",children:e.jsx(Ke,{className:M("h-3.5 w-3.5 transition-transform",H&&"rotate-180")})}),H&&e.jsx("div",{role:"menu",className:"absolute left-0 right-0 top-full z-20 mt-2 overflow-hidden rounded-[18px] border border-border/60 bg-popover/96 p-1 shadow-[0_20px_60px_-30px_rgba(0,0,0,0.45)] backdrop-blur-xl",children:e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{X(!1),U("native")},className:"flex w-full items-center gap-1.5 rounded-[13px] px-2 py-2 text-left text-[11px] font-medium text-foreground transition-colors hover:bg-muted/80",children:[e.jsx(Ys,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{className:"flex-1 truncate whitespace-nowrap",children:"Load session"}),e.jsx("span",{className:"shrink-0 text-[9px] uppercase tracking-[0.18em] text-muted-foreground",children:"native"})]})})]}),C?e.jsxs("div",{className:"flex min-w-0 flex-[3] items-center gap-1.5",children:[e.jsxs("div",{className:"relative min-w-0 flex-1",children:[e.jsx(Bs,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(Fe,{ref:q,value:j,onChange:g=>Y(g.target.value),placeholder:"Search tasks",className:"h-11 rounded-[18px] border-border/70 bg-background/68 pl-11 text-[11px]"})]}),e.jsx(O,{variant:"outline",size:"icon",onClick:()=>se(!1),className:"rounded-[14px] border-border/70 bg-background/68",children:e.jsx(ms,{className:"h-4 w-4"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(O,{variant:"outline",onClick:()=>se(!0),className:M("rounded-[14px] border-border/70 bg-background/68 px-3 text-[11px]",j&&"border-primary/40 bg-primary/8 text-primary"),children:[e.jsx(Bs,{className:"h-4 w-4"}),"Search"]}),e.jsx(O,{variant:ie||P?"secondary":"outline",size:"icon",onClick:()=>te(g=>!g),className:M("shrink-0 rounded-[14px] border-border/70 bg-background/68",P&&"border-primary/40 bg-primary/8 text-primary"),title:"Filters",children:e.jsx(fr,{className:"h-4 w-4"})})]})]}),(ie||P)&&e.jsxs("div",{className:"mt-2 grid grid-cols-1 gap-1.5 sm:grid-cols-2",children:[e.jsxs(Se,{value:i,onValueChange:g=>ee(g),children:[e.jsx(Ce,{className:"h-7 rounded-[13px] border-border/70 bg-background/60 text-[12px]",children:e.jsx(Me,{})}),e.jsx(Te,{children:gn.map(g=>e.jsx(ge,{value:g.value,className:"text-[12px]",children:g.label},g.value))})]}),e.jsxs(Se,{value:k,onValueChange:ue,children:[e.jsx(Ce,{className:"h-7 rounded-[13px] border-border/70 bg-background/60 text-[12px]",children:e.jsx(Me,{placeholder:"Node"})}),e.jsx(Te,{children:w.map(g=>e.jsx(ge,{value:g.value,className:"text-[12px]",children:g.label},g.value))})]}),e.jsxs(Se,{value:x,onValueChange:$,children:[e.jsx(Ce,{className:"h-7 rounded-[13px] border-border/70 bg-background/60 text-[12px]",children:e.jsx(Me,{placeholder:"Agent"})}),e.jsx(Te,{children:N.map(g=>e.jsx(ge,{value:g,className:"text-[12px]",children:g==="all"?"All agents":g},g))})]}),e.jsxs(Se,{value:y,onValueChange:g=>D(g),children:[e.jsx(Ce,{className:"h-7 rounded-[13px] border-border/70 bg-background/60 text-[12px]",children:e.jsx(Me,{placeholder:"Type"})}),e.jsx(Te,{children:bn.map(g=>e.jsx(ge,{value:g.value,className:"text-[12px]",children:g.label},g.value))})]})]})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-2 py-2",children:xe.length>0?e.jsxs("div",{className:"space-y-1",children:[r&&e.jsxs("div",{className:"mb-1 flex items-center justify-between px-1 py-1",children:[e.jsxs("label",{className:"flex items-center gap-1.5 text-[11px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:[e.jsx(pt,{checked:_&&!L?"indeterminate":L,onCheckedChange:g=>A(g===!0),"aria-label":"Select all visible tasks"}),e.jsx("span",{children:"Select all"})]}),c>0&&e.jsx(O,{variant:"ghost",size:"sm",onClick:()=>A(!1),className:"h-7 rounded-[12px] px-2 text-[11px]",children:"Clear"})]}),xe.map(g=>{const ke=g.nodeId??"__unassigned__",ne=T&&!W&&J.has(ke),F=g.nodeId!==null&&u.get(g.nodeId)==="offline";return e.jsxs("div",{className:"space-y-1",children:[T&&e.jsxs("button",{type:"button",onClick:()=>Ne(ke),"aria-expanded":!ne,className:"flex w-full items-center gap-1.5 rounded-[15px] bg-gradient-to-r from-primary/8 to-muted/20 px-2 py-1.5 text-left text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground transition-all duration-150 hover:from-primary/12 hover:to-muted/30 hover:text-foreground active:scale-[0.99] active:from-primary/15",children:[e.jsx(ss,{className:M("h-3.5 w-3.5 shrink-0 transition-transform duration-200",!ne&&"rotate-90")}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:g.nodeName}),e.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:[F&&e.jsx(Ae,{variant:"outline",className:"rounded-[8px] border-destructive/25 bg-destructive/10 px-1 py-0 text-[8px] font-semibold leading-3 text-destructive shadow-none",children:"offline"}),g.nodeId===b&&e.jsx(Ae,{variant:"outline",className:"rounded-[9px] border-primary/25 bg-primary/8 px-1.5 py-0 text-[9px] font-semibold leading-4 text-primary shadow-none",children:"leader"}),e.jsx("span",{className:"tabular-nums text-muted-foreground/60",children:g.dirs.reduce((z,me)=>z+me.tasks.length,0)})]})]}),e.jsx("div",{className:M("grid transition-[grid-template-rows] duration-300 ease-in-out",ne?"grid-rows-[0fr]":"grid-rows-[1fr]"),children:e.jsx("div",{className:"overflow-hidden",children:g.dirs.map(z=>{const me=`${ke}::${z.path}`,Ee=re.has(me),Ie=vn(z.path);return e.jsxs("div",{className:M("space-y-0.5 rounded-xl",T&&"pl-3"),children:[e.jsxs("button",{type:"button",onClick:()=>we(me),"aria-expanded":!Ee,title:z.path,className:"flex w-full items-center gap-1.5 rounded-[12px] bg-muted/15 px-2 py-1 text-left text-[10px] font-medium text-muted-foreground/70 transition-all duration-150 hover:bg-muted/30 hover:text-foreground active:scale-[0.98] active:bg-muted/40",children:[e.jsx(ss,{className:M("h-3 w-3 shrink-0 transition-transform duration-200",!Ee&&"rotate-90")}),e.jsx("span",{className:"truncate font-mono",children:Ie}),e.jsx("span",{className:"ml-auto shrink-0 tabular-nums text-muted-foreground/40",children:z.tasks.length})]}),e.jsx("div",{className:M("grid transition-[grid-template-rows] duration-300 ease-in-out",Ee?"grid-rows-[0fr]":"grid-rows-[1fr]"),children:e.jsx("div",{className:M("overflow-hidden",T?"pl-2":"pl-0"),children:e.jsx("div",{className:"space-y-1.5 border-l border-border/35 py-1 pl-2.5 ml-1.5",children:z.tasks.map(G=>e.jsxs("div",{className:M("flex items-center gap-1.5 rounded-[18px] border px-2.5 py-1.5 transition-all duration-200","hover:-translate-y-px",G.id===a?"border-primary/45 bg-primary/9 shadow-[0_24px_80px_-54px_hsl(var(--primary)/0.95)]":"border-border/58 bg-background/46 hover:border-border hover:bg-background/70 hover:shadow-[0_10px_28px_-18px_rgba(0,0,0,0.35)]"),children:[r&&e.jsx("div",{className:"flex shrink-0",onClick:Be=>Be.stopPropagation(),children:e.jsx(pt,{checked:f.has(G.id),onCheckedChange:Be=>K(G.id,Be===!0),"aria-label":`Select ${G.title}`})}),e.jsxs("button",{type:"button",onClick:()=>oe(G.id),className:"min-w-0 flex-1 text-left",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:M("h-1.5 w-1.5 shrink-0 rounded-full",jn(G.status),(G.status==="running"||G.status==="assigned")&&"animate-soft-status-pulse")}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:G.title}),e.jsx("span",{className:"ml-1 shrink-0 tabular-nums text-[10px] text-muted-foreground/55",children:Nn(G.updatedAt)})]}),e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-1 pl-3",children:[e.jsx(Ut,{status:G.status}),e.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/60",children:G.agent}),G.conversationKind==="nativeSession"&&e.jsx(Ae,{variant:"outline",className:"border-sky-500/25 bg-sky-500/10 text-[10px] text-sky-700 dark:text-sky-300",children:"native"}),G.activeShare&&e.jsx(Ae,{variant:"outline",className:"border-primary/25 bg-primary/10 text-[10px] text-primary",children:"shared"}),G.assignedNodeAvailable===!1&&e.jsx(Ae,{variant:"outline",className:"border-destructive/25 bg-destructive/10 text-[10px] text-destructive",children:"unavailable"})]})]})]},G.id))})})})]},me)})})})]},ke)})]}):n?e.jsx("div",{className:"space-y-2 px-1",children:[1,2,3].map(g=>e.jsx("div",{className:"rounded-[24px] border border-border/40 bg-background/30 px-3 py-3",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"mt-1 h-2.5 w-2.5 shrink-0 animate-pulse rounded-full bg-muted-foreground/20"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("div",{className:"h-2.5 animate-pulse rounded-full bg-muted-foreground/15",style:{width:`${60+g*12}%`,animationDelay:`${g*120}ms`}}),e.jsx("div",{className:"h-2 w-24 animate-pulse rounded-full bg-muted-foreground/10",style:{animationDelay:`${g*120+60}ms`}})]})]})},g))}):e.jsx("div",{className:"rounded-[24px] border border-dashed border-border/70 bg-background/35 px-3 py-5 text-[11px] text-muted-foreground",children:o||"No tasks match this view."})}),r&&c>0?e.jsxs("div",{className:"shrink-0 border-t border-border/60 px-3 py-3",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.22em] text-muted-foreground",children:"Batch actions"}),e.jsxs("div",{className:"mt-2 text-[11px] font-semibold text-foreground",children:[c," task",c!==1?"s":""," selected"]}),!R&&e.jsx("div",{className:"mt-2 text-[11px] text-muted-foreground",children:"Only completed, failed, cancelled, or archived tasks can be archived."}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-1.5",children:[e.jsxs(_s,{children:[e.jsx(ft,{asChild:!0,children:e.jsxs(O,{variant:"outline",size:"sm",disabled:!R,className:"rounded-[14px]",children:[e.jsx(cr,{className:"h-3.5 w-3.5"}),"Archive"]})}),e.jsxs(Ds,{children:[e.jsxs(As,{children:[e.jsxs(Ms,{children:["Archive ",c," task",c!==1?"s":"","?"]}),e.jsx(Ls,{children:"Archived tasks stay hidden from the default task view and can be reopened from the archived scope."})]}),e.jsxs(Ps,{children:[e.jsx(Rs,{children:"Cancel"}),e.jsx($s,{onClick:I,disabled:!R,children:"Archive"})]})]})]}),e.jsxs(_s,{children:[e.jsx(ft,{asChild:!0,children:e.jsxs(O,{variant:"destructive",size:"sm",className:"rounded-[14px]",children:[e.jsx(Hr,{className:"h-3.5 w-3.5"}),"Delete"]})}),e.jsxs(Ds,{children:[e.jsxs(As,{children:[e.jsxs(Ms,{children:["Delete ",c," task",c!==1?"s":"","?"]}),e.jsx(Ls,{children:"This removes the selected tasks and their saved logs."})]}),e.jsxs(Ps,{children:[e.jsx(Rs,{children:"Cancel"}),e.jsx($s,{onClick:S,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})]}):null]})}async function Yo(s,a){var n,o;try{const r=await kn(s,a);if((o=(n=globalThis.navigator)==null?void 0:n.clipboard)!=null&&o.writeText)try{await globalThis.navigator.clipboard.writeText(r.url),pe.success("Shared link copied")}catch{pe.success("Shared link created")}else pe.success("Shared link created");return r}catch(r){pe.error(r instanceof Error?r.message:"Failed to create shared link");return}}async function Xo(s){try{return await wn(s),pe.success("Shared link stopped"),!0}catch(a){return pe.error(a instanceof Error?a.message:"Failed to stop shared link"),!1}}function Qo(s,a,n){const o=t.useCallback(()=>{a(),n()},[a,n]),r=t.useCallback(async x=>{if(!s)return;const k=await Yo(s.id,x);return k&&o(),k},[s,o]),i=t.useCallback(async()=>{if(!s)return!1;const x=await Xo(s.id);return x&&o(),x},[s,o]);return{handleShareTask:r,handleStopShareTask:i}}function Lt(s,a,n){const o=t.useRef(a);o.current=a,t.useEffect(()=>{let x=0,k=0;const y=d=>{const u=d.touches[0];u&&(x=u.clientX,k=u.clientY)},N=d=>{var f,L,_,R;const u=d.changedTouches[0];if(!u)return;const b=u.clientX-x;Math.abs(u.clientY-k)>100||Math.abs(b)<50||(b>0?(L=(f=o.current).onSwipeRight)==null||L.call(f):(R=(_=o.current).onSwipeLeft)==null||R.call(_))},w=(s==null?void 0:s.current)??document;return w.addEventListener("touchstart",y,{passive:!0}),w.addEventListener("touchend",N,{passive:!0}),()=>{w.removeEventListener("touchstart",y),w.removeEventListener("touchend",N)}},[s,n==null?void 0:n.threshold,n==null?void 0:n.maxVertical])}const Zo="(min-width: 1024px)",ei="(min-width: 1800px)";function Pt(s){var a,n,o;return((o=(n=(a=globalThis.window)==null?void 0:a.matchMedia)==null?void 0:n.call(a,s))==null?void 0:o.matches)??!1}function si(){const[s,a]=t.useState(!0),[n,o]=t.useState(!1),[r,i]=t.useState(()=>Pt(ei)),x=t.useRef(null),k=t.useRef(null);Lt(x,{onSwipeLeft:()=>o(!1)}),Lt(k,{onSwipeRight:()=>i(!1)});const y=t.useCallback(()=>{if(Pt(Zo)){a(N=>!N);return}o(N=>!N)},[]);return{desktopTasksOpen:s,mobileTasksPanelOpen:n,mobileTasksPanelRef:x,operationsOpen:r,operationsPanelRef:k,setMobileTasksPanelOpen:o,setOperationsOpen:i,toggleTasksPanel:y}}function ti(s,a){const n=a.taskId,o=a.updates;return typeof n!="string"||!o||typeof o!="object"?s:s.map(r=>r.id===n?{...r,...o}:r)}function ai({isLeader:s,selfId:a}){return{assignedTo:!s&&a?a:void 0}}function ni({isLeader:s,selfId:a,sseConnected:n,subscribe:o}){const[r,i]=t.useState([]),[x,k]=t.useState(!0),[y,N]=t.useState(null),w=t.useRef(null),d=t.useCallback(async()=>{try{const b=await yn(ai({isLeader:s,selfId:a}));i(b),N(null)}catch(b){N(b instanceof Error?b.message:"Failed to load tasks")}finally{k(!1)}},[s,a]),u=t.useCallback(()=>{w.current===null&&(w.current=window.setTimeout(()=>{w.current=null,d()},Sn))},[d]);return Cn(d,_n(n)),t.useEffect(()=>()=>{w.current!==null&&(window.clearTimeout(w.current),w.current=null)},[]),t.useEffect(()=>{const b=[o("task.updated",j=>{i(f=>ti(f,j.data))}),o("task.status",j=>{i(f=>Tn(f,j.data))}),o("task",j=>{En(j.type)&&u()})];return()=>b.forEach(j=>j())},[o,u]),{fetchTasks:d,setTasks:i,tasks:r,tasksError:y,tasksLoading:x}}function ri(s,a){return a.data.nodeId===s.self.id||a.data.name===s.self.name||a.data.endpoint===s.self.endpoint}function oi({cluster:s,subscribe:a}){t.useEffect(()=>{var n;if(((n=s==null?void 0:s.self)==null?void 0:n.role)==="leader")return a("node",o=>{const r=String(o.data.name??o.data.nodeId??"node"),i=ri(s,o);o.type==="node.joined"&&!i&&pe.success(`${r} joined the cluster`),o.type==="node.left"&&!i&&pe.message(`${r} left the cluster`)})},[s,a])}const ii=[0,300,1e3,2e3];function li({task:s,getActiveTaskId:a,setLogs:n,setPendingMessages:o}){s.conversationKind==="nativeSession"&&(async()=>{for(const r of ii){if(r>0&&await new Promise(i=>setTimeout(i,r)),a()!==s.id)return;try{const i=await Wt(s.id);if(a()!==s.id||(n(x=>Xt(x,i.logs)),o(x=>Qt(x,i.logs)),i.total>0))return}catch{}}})()}function di(){var ot,it,lt,dt,ct,ut;const{id:s}=Dn(),a=An(),n=Mn(),o=Ln(),{cluster:r,systemInfo:i,events:x,sseConnected:k,subscribe:y,refresh:N,loading:w,error:d}=Pn(),u=t.useMemo(()=>Rn(a.state),[a.state]),[b,j]=t.useState(null),[f,L]=t.useState("active"),[_,R]=t.useState("all"),[Y,ee]=t.useState("all"),[$,ue]=t.useState("all"),[D,K]=t.useState(""),A=t.useDeferredValue(D),{desktopTasksOpen:I,mobileTasksPanelOpen:S,mobileTasksPanelRef:U,operationsOpen:oe,operationsPanelRef:B,setMobileTasksPanelOpen:C,setOperationsOpen:se,toggleTasksPanel:ie}=si(),[te,H]=t.useState(()=>!!(u!=null&&u.draftNewTask)),[X,q]=t.useState(()=>(u==null?void 0:u.createMode)??"chat"),[ae,le]=t.useState(()=>u!=null&&u.draftNewTask?{route:u.returnRoute??"/",taskId:u.returnTaskId??null}:null),[c,P]=t.useState(!1),[v,J]=t.useState("transcript"),[h,re]=t.useState("all"),[V,xe]=t.useState(!1),[m,T]=t.useState(null),[W,Ne]=t.useState([]),[we,g]=t.useState([]),[ke,ne]=t.useState(!1),[F,z]=t.useState(null),[me,Ee]=t.useState(new Set),[Ie,G]=t.useState(!1),[Be,rs]=t.useState(!1),[os,Xe]=t.useState(null),Qe=t.useRef(null),$e=t.useRef(null),Oe=((ot=r==null?void 0:r.self)==null?void 0:ot.role)==="leader",fs=(it=r==null?void 0:r.self)==null?void 0:it.id;oi({cluster:r,subscribe:y});const{fetchTasks:de,setTasks:ve,tasks:ye,tasksError:Ze,tasksLoading:gs}=ni({isLeader:Oe,selfId:fs,sseConnected:k,subscribe:y}),je=t.useMemo(()=>[...ye].sort((l,p)=>p.updatedAt-l.updatedAt),[ye]),pa=t.useMemo(()=>{const l=new Map;for(const p of(r==null?void 0:r.nodes)??[]){const E=qr(je,p.id);E>0&&l.set(p.id,E)}return l},[r==null?void 0:r.nodes,je]),Pe=t.useMemo(()=>je.filter(l=>!$n(l,r==null?void 0:r.nodes,r==null?void 0:r.self)||!Fn(l,f)||_!=="all"&&l.agent!==_||!On(l,$)||Y==="unassigned"&&l.assignedTo||Y!=="all"&&Y!=="unassigned"&&In(l.assignedTo,r==null?void 0:r.nodes,l.assignedNodeName)!==Y?!1:A.trim()?Bn(l,A):!0),[je,r==null?void 0:r.nodes,r==null?void 0:r.self,f,_,$,Y,A]);t.useEffect(()=>{Ee(l=>{const p=Xr(l,Pe.map(E=>E.id));return p.size===l.size?l:p})},[Pe]),t.useEffect(()=>{Oe||Ee(new Set)},[Oe]);const fa=t.useMemo(()=>["all",...Array.from(new Set(je.map(l=>l.agent))).sort()],[je]),ga=t.useMemo(()=>{const p=Array.from(new Set(je.map(E=>E.assignedTo).filter(E=>!!E))).map(E=>{const he=je.find(Z=>Z.assignedTo===E);return(r==null?void 0:r.nodes.find(Z=>Z.id===E))??{id:E,name:Bt(E,r==null?void 0:r.nodes,he==null?void 0:he.assignedNodeName)}}).sort((E,he)=>E.name.localeCompare(he.name));return[{value:"all",label:"All nodes"},{value:"unassigned",label:"Unassigned"},...p.map(E=>({value:E.name.toLowerCase(),label:E.name}))]},[je,r==null?void 0:r.nodes]),st=t.useMemo(()=>{const l=new Map;for(const p of(r==null?void 0:r.nodes)??[])l.set(p.id,p.name);for(const p of je)p.assignedTo&&p.assignedNodeName&&!l.has(p.assignedTo)&&l.set(p.assignedTo,p.assignedNodeName);return l},[r==null?void 0:r.nodes,je]),ba=t.useMemo(()=>{const l=new Map;for(const p of(r==null?void 0:r.nodes)??[])l.set(p.id,p.status);return r!=null&&r.self&&l.set(r.self.id,r.self.status),l},[r]),tt=t.useMemo(()=>{const l=new Map;for(const p of(r==null?void 0:r.nodes)??[])p.status!=="offline"&&l.set(p.id,p);return r!=null&&r.self&&r.self.status!=="offline"&&l.set(r.self.id,r.self),Array.from(l.values())},[r]),va=((lt=r==null?void 0:r.self)==null?void 0:lt.id)??((dt=tt[0])==null?void 0:dt.id)??null,bs=t.useMemo(()=>["all",...Array.from(new Set(x.map(l=>l.type))).sort()],[x]),ja=t.useMemo(()=>h==="all"?x:x.filter(l=>l.type===h),[x,h]),Na=Pe.length>0&&Pe.every(l=>me.has(l.id)),ka=Pe.some(l=>me.has(l.id)),wa=Qr(Pe,me);t.useEffect(()=>{u!=null&&u.draftNewTask&&(H(!0),le({route:u.returnRoute??"/",taskId:u.returnTaskId??null}))},[u]),t.useEffect(()=>{h!=="all"&&!bs.includes(h)&&re("all")},[h,bs]),t.useEffect(()=>{kt(s,te)&&!b&&je[0]&&j(je[0].id)},[s,te,b,je]),t.useEffect(()=>{var l;kt(s,te)&&(b&&ye.some(p=>p.id===b)||j(((l=je[0])==null?void 0:l.id)??null))},[s,te,b,je,ye]);const ce=Gr({routeTaskId:s,creatingTask:te,internalSelectedTaskId:b,sortedTaskIds:je.map(l=>l.id)}),qe=t.useMemo(()=>ye.find(l=>l.id===ce)??null,[ye,ce]);t.useEffect(()=>{$e.current=ce??null},[ce]);const is=t.useCallback(()=>{T(null),Ne([]),g([]),z(null)},[]),De=t.useCallback(async()=>{const l=ce;if(l)try{const p=await zn(l);if($e.current!==l)return;T(p),z(null)}catch(p){if($e.current!==l)return;T(null),Ne([]),g([]),z(p instanceof Error?p.message:"Failed to load task")}finally{$e.current===l&&ne(!1)}},[ce]),ls=t.useCallback(async()=>{const l=ce;if(l)try{const p=await Wt(l);if($e.current!==l)return;Ne(E=>Xt(E,p.logs)),g(E=>Qt(E,p.logs))}catch{}},[ce]);t.useEffect(()=>{if(!ce){T(null),Ne([]),g([]),z(null),ne(!1);return}J("transcript"),T(qe),Ne([]),g([]),z(null),ne(!0),De(),ls()},[ce,ls,De]),t.useEffect(()=>{var p;if(!ce||te||gs||ye.some(E=>E.id===ce))return;const l=((p=je[0])==null?void 0:p.id)??null;j(l),is(),t.startTransition(()=>{n(l?`/tasks/${l}`:"/",{state:null})})},[ce,is,te,n,je,ye,gs]),t.useEffect(()=>{qe&&T(l=>!l||l.id!==qe.id?l:{...l,...qe})},[qe]),t.useEffect(()=>{if(ce)return y("task",l=>{const p=l.data.taskId;if(!(typeof p!="string"||p!==ce)){if(l.type==="task.output"){const E=l.data.event;if(E){Ne(Z=>sr(Z,E));const he=vt(E);he&&g(Z=>tr(Z,he))}}l.type==="task.updated"&&De(),l.type==="task.status"&&(De(),ls())}})},[y,ce,De,ls]),t.useEffect(()=>{var l;v==="transcript"&&((l=Qe.current)==null||l.scrollIntoView({behavior:"smooth"}))},[W,we,v]);const Q=m??qe,ya=Q!=null&&Q.assignedTo?(r==null?void 0:r.nodes.find(l=>l.id===Q.assignedTo))??null:null,vs=we.length>0,Sa=Q?Un.has(Q.agent):!1,js=(Q==null?void 0:Q.status)==="running",Ca=Q?hs.has(Q.status):!1,Ta=Q?hs.has(Q.status)||Vn.has(Q.status):!1,Ea=!!(Q&&Oe&&Q.status==="failed"),Ns=t.useMemo(()=>Jo(Q,r,vs,!!js),[Q,r,vs,js]),ks=t.useMemo(()=>ar([...W,...we.map(l=>Ts(l.content,l.timestamp))]),[W,we]),ds=t.useMemo(()=>{if(!Q||Q.conversationKind==="nativeSession")return null;const l=nr(Q);if(l.length>0)return Ts(l,new Date(Q.createdAt).toISOString());if(ks.length>0)return null;const p=rr(Q.description||Q.title);return p.length>0?Ts(p,new Date(Q.createdAt).toISOString()):null},[Q,ks]),ws=t.useMemo(()=>ds?vt(ds):null,[ds]),_a=t.useMemo(()=>ws?or(W,ws):!1,[W,ws]),ys=t.useCallback((l="chat")=>{const p={route:s?`/tasks/${s}`:"/",taskId:ce};le(p),q(l),H(!0),t.startTransition(()=>{n("/",{state:{draftNewTask:!0,returnRoute:p.route,returnTaskId:p.taskId,createMode:l}})})},[s,ce,n]),Da=t.useCallback(()=>{var p;const l=(ae==null?void 0:ae.taskId)??((p=je[0])==null?void 0:p.id)??null;H(!1),le(null),j(l),t.startTransition(()=>{n((ae==null?void 0:ae.route)??"/",{state:null})})},[ae,je,n]),at=t.useCallback(l=>{H(!1),le(null),j(l),t.startTransition(()=>{n(`/tasks/${l}`,{state:null})})},[n]),Aa=t.useCallback(l=>{$e.current=l.id,H(!1),le(null),ve(p=>Jr(p,l)),T(l),Ne([]),g([]),z(null),ne(!1),J("transcript"),j(l.id),li({task:l,getActiveTaskId:()=>$e.current,setLogs:Ne,setPendingMessages:g}),de(),t.startTransition(()=>{n(`/tasks/${l.id}`,{state:null})})},[de,n]),cs=t.useCallback(async l=>{if(!ce)return!1;const p=`local-${Date.now()}-${Math.random().toString(16).slice(2)}`;g(E=>[...E,{id:p,content:l,timestamp:new Date().toISOString()}]);try{return await Hn(ce,l),De(),!0}catch(E){return g(he=>he.filter(Z=>Z.id!==p)),pe.error(E instanceof Error?E.message:"Failed to send message"),!1}},[ce,De]),Ma=t.useCallback(l=>{cs(l)},[cs]),La=t.useCallback(l=>cs(l),[cs]),Pa=t.useCallback(async()=>{if(Q)try{await Kn(Q.id),De(),de()}catch(l){pe.error(l instanceof Error?l.message:"Failed to cancel task")}},[Q,De,de]),{handleShareTask:Ra,handleStopShareTask:$a}=Qo(Q,De,de),Fa=t.useCallback(async()=>{if(Q)try{await qn(Q.id),De(),de()}catch(l){pe.error(l instanceof Error?l.message:"Failed to retry task")}},[Q,De,de]),us=t.useCallback((l,p=!1)=>{const E=Zr(Pe,l);return j(E),(p||!E)&&is(),t.startTransition(()=>{n(E?`/tasks/${E}`:"/",{state:null})}),E},[is,Pe,n]),Oa=t.useCallback((l,p)=>{Ee(E=>{const he=new Set(E);return p?he.add(l):he.delete(l),he})},[]),Ia=t.useCallback(l=>{if(!l){Ee(new Set);return}Ee(new Set(Pe.map(p=>p.id)))},[Pe]),Ba=t.useCallback(async()=>{const l=Array.from(me);if(l.length!==0)try{const{results:p}=await Wn(l),E=p.filter(Z=>!Z.ok),he=p.filter(Z=>Z.ok).map(Z=>Z.id);ce&&he.includes(ce)&&us(he),E.length>0?pe.error(`Failed to archive ${E.length} task(s): ${E.map(Z=>Z.error??Z.id).join(", ")}`):pe.success(`Archived ${he.length} task(s)`),Ee(new Set(E.map(Z=>Z.id))),de()}catch(p){pe.error(p instanceof Error?p.message:"Failed to archive tasks")}},[ce,de,us,me]),za=t.useCallback(async()=>{const l=Array.from(me);if(l.length!==0)try{const{results:p}=await Gn(l),E=p.filter(Z=>!Z.ok),he=p.filter(Z=>Z.ok).map(Z=>Z.id);ce&&he.includes(ce)&&us(he,!0),E.length>0?pe.error(`Failed to delete ${E.length} task(s): ${E.map(Z=>Z.error??Z.id).join(", ")}`):pe.success(`Deleted ${he.length} task(s)`),Ee(new Set(E.map(Z=>Z.id))),de()}catch(p){pe.error(p instanceof Error?p.message:"Failed to delete tasks")}},[ce,de,us,me]),Ua=t.useCallback(async()=>{G(!0);try{await Jn(),N()}catch(l){pe.error(l instanceof Error?l.message:"Failed to promote node")}finally{G(!1)}},[N]),Va=t.useCallback(async()=>{rs(!0);try{await Yn(),pe.success("This node left the remote cluster and is leading itself again."),de(),De(),N()}catch(l){pe.error(l instanceof Error?l.message:"Failed to leave cluster")}finally{rs(!1)}},[De,de,N]),Ha=t.useCallback(async l=>{var xt;const p=!Zs(l),E=l.id===((xt=r==null?void 0:r.self)==null?void 0:xt.id),he=E?(i==null?void 0:i.transportType)??l.transportType:l.transportType,Z=E&&!p&&Ye(he);Xe(l.id);try{Z?await Xn("direct"):await Qn(l.id,p),pe.success(p?`Enabled remote access on ${l.name}`:`Disabled remote access on ${l.name}`),N()}catch(mt){pe.error(mt instanceof Error?mt.message:"Failed to update remote access")}finally{Xe(null)}},[(ct=r==null?void 0:r.self)==null?void 0:ct.id,N,i==null?void 0:i.transportType]),nt={toolbarTasks:Pe,activeTaskId:ce,tasksLoading:gs,tasksError:Ze,isLeader:Oe,scope:f,agentFilter:_,nodeFilter:Y,taskKindFilter:$,agentOptions:fa,nodeOptions:ga,nodeNameById:st,nodeStatusById:ba,leaderNodeId:((ut=r==null?void 0:r.leader)==null?void 0:ut.id)??null,searchQuery:D,selectedTaskIds:me,allVisibleTasksSelected:Na,someVisibleTasksSelected:ka,canBatchArchive:wa,onSearchChange:K,onScopeChange:L,onAgentFilterChange:R,onNodeFilterChange:ee,onTaskKindFilterChange:ue,onToggleTaskSelected:Oa,onToggleAllVisibleTasks:Ia,onBatchArchive:Ba,onBatchDelete:za,onCreateTask:ys,onSelectTask:at,onClose:ie},rt={cluster:r,systemInfo:i,nodeNameById:st,nodeBlockingTaskCounts:pa,eventTypeFilter:h,onEventTypeFilterChange:re,eventTypeOptions:bs,filteredEvents:ja,sseConnected:k,clusterLoading:w,clusterError:d,promotePending:Ie,onPromote:Ua,onAddNode:()=>P(!0),leavePending:Be,onLeaveCluster:Va,onToggleNodeDevTunnel:Ha,devTunnelNodeId:os,onClose:()=>se(!1)};return e.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden pb-2",children:[e.jsxs("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:[e.jsx("div",{className:M("hidden lg:block lg:shrink-0 lg:transition-all lg:duration-300",I?"lg:mr-3 lg:w-[24rem]":"lg:w-0 lg:overflow-hidden"),children:I&&e.jsx(Mt,{...nt})}),e.jsxs("section",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-3",children:[e.jsx("div",{className:"min-h-0 flex-1",children:e.jsx(Oo,{onToggleTasks:ie,desktopTasksOpen:I,mobileTasksPanelOpen:S,operationsOpen:oe,onToggleOperations:()=>se(l=>!l),cluster:r,sseConnected:k,activeTab:v,setActiveTab:J,creatingTask:te,createMode:X,activeTask:Q,assignedNode:ya,taskLoading:ke,taskError:F,displayEvents:ks,initialPromptAlreadyInLogs:_a,initialPrompt:ds,supportsFollowUp:Sa,taskUnavailable:Ns.taskUnavailable,chatDisabled:Ns.chatDisabled,chatDisabledReason:Ns.chatDisabledReason,questionBypassEnabled:V,isRunning:!!js,isStarting:Ca,hasPendingFollowUp:vs,canCancel:!!Ta,canRetry:!!Ea,onRetry:Fa,onCancel:Pa,onShareTask:Ra,onStopShareTask:$a,onStartCreateTask:ys,onCancelCreateTask:Da,onCreateTask:Aa,onSendMessage:Ma,onQuestionBypassChange:xe,onSubmitQuestionResponse:La,messagesEndRef:Qe})}),(o==null?void 0:o.terminalOpen)&&e.jsx(Wo,{nodes:tt,defaultNodeId:va,onClose:()=>o==null?void 0:o.setTerminalOpen(!1)})]}),e.jsx("div",{className:M("hidden xl:block xl:shrink-0 xl:transition-all xl:duration-300",oe?"xl:ml-3 xl:w-[26rem]":"xl:w-0 xl:overflow-hidden"),children:oe&&e.jsx(Dt,{...rt})})]}),oe&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button","aria-label":"Close operations panel",onClick:()=>se(!1),className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm xl:hidden"}),e.jsx("div",{ref:B,className:"fixed inset-y-0 right-0 z-40 w-full p-2 sm:max-w-sm sm:p-3 xl:hidden",children:e.jsx(Dt,{...rt})})]}),S&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button","aria-label":"Close task list",onClick:()=>C(!1),className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm lg:hidden"}),e.jsx("div",{ref:U,className:"fixed inset-y-0 left-0 z-40 w-full p-2 sm:max-w-sm sm:p-3 lg:hidden",children:e.jsx(Mt,{...nt,onCreateTask:l=>{C(!1),ys(l)},onSelectTask:l=>{C(!1),at(l)},onClose:()=>C(!1)})})]}),e.jsx(Ot,{open:c,onOpenChange:P,children:e.jsx(no,{onAdded:()=>{P(!1),N()}})})]})}const hi=Object.freeze(Object.defineProperty({__proto__:null,DashboardPage:di},Symbol.toStringTag,{value:"Module"}));export{hi as D,jt as G};
124
+ `).map(i=>i.trim()).find(Boolean);return r?r.length>72?`${r.slice(0,69).trimEnd()}...`:r:n?"Image task":""}function Eo(s){var x;const a=s.title.trim(),n=ca(s.title,s.description,s.images.length>0),o=s.description.trim()||n,r=s.mode??ts,i=Gt(s.description,s.images);return!n||!o||!s.agent?null:{title:n,description:o,agent:s.agent,project:s.project.trim()||null,branch:((x=s.branch)==null?void 0:x.trim())||null,payload:{initialMessage:i,mode:r,titleSource:a?"manual":"derived"},priority:s.priority,assignTo:s.assignTo==="auto"?void 0:s.assignTo}}function _o({nodes:s,currentNodeRole:a,currentNodeId:n,leaderNodeId:o,onCreated:r,onCancel:i,className:x,footerClassName:k,submitLabel:y="Create chat",cancelLabel:N="Cancel",autoFocus:w=!1,layout:d="default"}){const[u,b]=t.useState(""),[j,f]=t.useState(""),[L,_]=t.useState("claudecode"),[R,Y]=t.useState(ts),[ee,$]=t.useState(""),[ue,D]=t.useState(""),[K,A]=t.useState("normal"),I=t.useMemo(()=>da(s,{currentNodeRole:a,leaderNodeId:o}),[s,a,o]),S=t.useMemo(()=>{var F;return n&&I.some(z=>z.id===n)?n:((F=I[0])==null?void 0:F.id)??""},[I,n]),[U,oe]=t.useState(S),[B,C]=t.useState(!1),[se,ie]=t.useState(!1),{images:te,error:H,fileInputRef:X,pickImages:q,handleFileChange:ae,handlePaste:le,removeImage:c}=oa(),P=t.useMemo(()=>I.find(F=>F.id===U)??null,[U,I]),v=!!(n&&(P==null?void 0:P.id)===n),J=Co(L),h=To(R);t.useEffect(()=>{U&&I.some(F=>F.id===U)||oe(S)},[U,I,S]),t.useEffect(()=>{$(la(U)),D("")},[U]),t.useEffect(()=>{D("")},[ee]);const re=t.useCallback(async F=>{F.preventDefault();const z=Eo({title:u,description:j,agent:L,project:ee,branch:ue,priority:K,assignTo:U,mode:R,images:te});if(z){C(!0);try{const me=await nn(z);r(me)}catch(me){pe.error(me instanceof Error?me.message:"Failed to create task")}finally{C(!1)}}},[u,j,L,ee,ue,K,U,R,te,r]),V=ca(u,j,te.length>0),xe=!!(V&&L&&U&&(j.trim()||te.length>0)),m=t.useCallback(F=>{var z;F.nativeEvent.isComposing||F.key==="Enter"&&(F.ctrlKey||F.metaKey)&&xe&&!B&&(F.preventDefault(),(z=F.currentTarget.form)==null||z.requestSubmit())},[xe,B]),T=te.length>0&&e.jsx("div",{className:"flex flex-wrap gap-3",children:te.map((F,z)=>e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:Jt(F),alt:F.filename??`attachment ${z+1}`,className:"h-24 w-24 rounded-2xl border border-border/70 object-cover"}),e.jsx("button",{type:"button",onClick:()=>c(z),className:"absolute -top-2 -right-2 flex h-6 w-6 items-center justify-center rounded-[10px] border border-border/70 bg-background text-muted-foreground shadow-sm transition-all hover:-translate-y-px hover:text-foreground","aria-label":`Remove ${F.filename??`image ${z+1}`}`,children:e.jsx(He,{className:"h-3.5 w-3.5"})})]},`${F.filename??"image"}-${z}`))}),W=e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Assign to"}),e.jsxs(Se,{value:U,onValueChange:oe,children:[e.jsx(Ce,{className:"h-11 rounded-[18px] border-border/70 bg-background/70",children:e.jsx(Me,{placeholder:"Select node"})}),e.jsx(Te,{children:Vs(I,n)})]})]}),Ne=e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Agent"}),e.jsxs(Se,{value:L,onValueChange:_,children:[e.jsx(Ce,{className:"h-11 rounded-[18px] border-border/70 bg-background/70",children:e.jsx(Me,{placeholder:"Select agent"})}),e.jsx(Te,{children:yt()})]})]}),we=e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Mode"}),e.jsxs(Se,{value:R,onValueChange:F=>Y(F),children:[e.jsx(Ce,{className:"h-11 rounded-[18px] border-border/70 bg-background/70",children:e.jsx(Me,{placeholder:"Select mode"})}),e.jsx(Te,{children:St()})]})]}),g=e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Priority"}),e.jsxs(Se,{value:K,onValueChange:A,children:[e.jsx(Ce,{className:"h-11 rounded-[18px] border-border/70 bg-background/70",children:e.jsx(Me,{placeholder:"Select priority"})}),e.jsxs(Te,{children:[e.jsx(ge,{value:"low",children:"Low"}),e.jsx(ge,{value:"normal",children:"Normal"}),e.jsx(ge,{value:"high",children:"High"}),e.jsx(ge,{value:"critical",children:"Critical"})]})]})]}),ke=e.jsx(ps,{value:ee,onChange:$,assignTo:U,nodes:s,assignableNodes:I}),ne=e.jsx(wt,{value:ue,onChange:D,project:ee,assignTo:U,nodes:s,assignableNodes:I});return d==="composer"?e.jsxs("form",{onSubmit:re,className:M("space-y-4",x),children:[e.jsx("input",{ref:X,type:"file",accept:"image/*",multiple:!0,onChange:ae,className:"hidden"}),(()=>{const F="chat-composer__chip h-9 w-auto gap-1.5 rounded-[15px] px-3.5 text-xs shadow-none transition-colors",z="border-transparent bg-transparent text-muted-foreground hover:bg-background/40 hover:text-foreground",me="border-border/70 bg-background/55 text-foreground",Ee=L==="claudecode",Ie=R===ts;return e.jsxs("div",{className:"chat-composer space-y-2",children:[e.jsxs("div",{className:"rounded-[26px] border border-border/60 bg-background/54 shadow-[0_24px_86px_-48px_rgba(15,23,42,0.55)] backdrop-blur-xl dark:shadow-[0_24px_86px_-48px_rgba(0,0,0,0.9)]",children:[e.jsxs("div",{className:"chat-composer__header flex min-w-0 items-center justify-between gap-3 px-4 pt-3",children:[e.jsxs(Se,{value:U,onValueChange:oe,children:[e.jsx(Ce,{className:M(F,me,"chat-composer__node-trigger border-transparent bg-transparent hover:bg-background/40"),title:`Assigned node: ${(P==null?void 0:P.name)??"unassigned"}`,"aria-label":`Assigned node: ${(P==null?void 0:P.name)??"unassigned"}`,children:P?e.jsxs(e.Fragment,{children:[e.jsx(et,{isCurrent:v}),e.jsx("span",{className:"min-w-0 truncate",children:P.name}),e.jsx("span",{className:"chat-composer__header-meta shrink-0 text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:v?"current":"remote"})]}):e.jsx(Me,{placeholder:"Select node"})}),e.jsx(Te,{children:Vs(I,n)})]}),se?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Fe,{id:"task-title-composer",type:"text",value:u,onChange:G=>b(G.target.value),onKeyDown:G=>{(G.key==="Enter"||G.key==="Escape")&&(G.preventDefault(),ie(!1))},autoFocus:!0,placeholder:"Chat title",className:"h-8 w-48 min-w-0 rounded-[13px] border-border/70 bg-background/55 px-3 text-xs shadow-none"}),e.jsx(O,{type:"button",variant:"ghost",size:"icon",onClick:()=>ie(!1),"aria-label":"Save title",className:"h-8 w-8 shrink-0 rounded-[12px] text-muted-foreground hover:text-foreground",children:e.jsx(es,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>ie(!0),className:"chat-composer__title-button flex min-w-0 items-center gap-1.5 rounded-[13px] px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-background/55 hover:text-foreground",title:V||"Title","aria-label":V?`Edit title: ${V}`:"Edit title",children:[e.jsx("span",{className:"chat-composer__title-text max-w-[220px] truncate",children:V||"Title"}),e.jsx(ns,{className:"h-3 w-3 shrink-0"})]})]}),e.jsx("textarea",{id:"task-description",value:j,onChange:G=>f(G.target.value),onKeyDown:m,onPaste:le,placeholder:"Ask anything...",rows:4,autoFocus:w,"aria-label":"Opening prompt",className:"min-h-[140px] w-full resize-none rounded-[24px] bg-transparent px-5 pt-2 pb-2 text-[15px] leading-7 text-foreground ring-offset-background placeholder:text-muted-foreground/70 focus-visible:outline-none"}),e.jsxs("div",{className:"chat-composer__rail flex flex-nowrap items-center gap-2 px-3 pb-3",children:[e.jsx(O,{type:"button",variant:"ghost",size:"icon",onClick:q,"aria-label":"Add images",className:"h-9 w-9 shrink-0 rounded-[14px] text-muted-foreground hover:text-foreground",children:e.jsx(Is,{className:"h-4 w-4"})}),e.jsx("span",{className:"mx-0.5 h-5 w-px bg-border/60","aria-hidden":!0}),e.jsxs(Se,{value:L,onValueChange:_,children:[e.jsxs(Ce,{className:M(F,"chat-composer__icon-trigger",Ee?z:me),title:`Agent: ${J}`,"aria-label":`Agent: ${J}`,children:[e.jsx(Ws,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label truncate",children:J})]}),e.jsx(Te,{children:yt()})]}),e.jsxs(Se,{value:R,onValueChange:G=>Y(G),children:[e.jsxs(Ce,{className:M(F,"chat-composer__icon-trigger",Ie?z:me),title:`Mode: ${h}`,"aria-label":`Mode: ${h}`,children:[e.jsx(zr,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label truncate",children:h})]}),e.jsx(Te,{children:St()})]}),e.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:[e.jsxs(Se,{value:K,onValueChange:A,children:[e.jsx(Ce,{"aria-label":`Priority: ${K}`,title:`Priority: ${K}`,className:M("h-9 w-9 justify-center gap-0 rounded-[14px] p-0 text-xs shadow-none [&>svg:last-child]:hidden",K==="normal"?"border-transparent bg-transparent text-muted-foreground hover:bg-background/40":"border-border/70 bg-background/55",K==="critical"&&"text-destructive",K==="high"&&"text-amber-600 dark:text-amber-400",K==="low"&&"text-muted-foreground"),children:e.jsx(hr,{className:M("h-4 w-4",K==="critical"&&"fill-destructive/20")})}),e.jsxs(Te,{children:[e.jsx(ge,{value:"low",children:"Low"}),e.jsx(ge,{value:"normal",children:"Normal"}),e.jsx(ge,{value:"high",children:"High"}),e.jsx(ge,{value:"critical",children:"Critical"})]})]}),i&&e.jsxs(O,{type:"button",variant:"ghost",size:"sm",onClick:i,"aria-label":N,className:"chat-composer__cancel h-9 rounded-[14px] px-4 text-xs text-muted-foreground",children:[e.jsx(He,{className:"chat-composer__cancel-icon h-4 w-4 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label",children:N})]}),e.jsxs(O,{type:"submit",size:"icon",disabled:!xe||B,className:"h-10 w-10 rounded-[16px] shadow-[0_8px_30px_-8px_hsl(var(--primary)/0.6)]",children:[B?e.jsx(be,{className:"h-4 w-4 animate-spin"}):e.jsx(sa,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:B?"Creating chat":y})]})]})]})]}),e.jsx("div",{className:"chat-composer__location flex flex-wrap items-center gap-2 px-1",children:(()=>{const G="border-border/40 bg-muted/40 text-foreground/80 hover:bg-muted/60 hover:text-foreground";return e.jsxs(e.Fragment,{children:[e.jsx(ps,{value:ee,onChange:$,assignTo:U,nodes:s,assignableNodes:I,layout:"composer",chipClassName:F,chipActiveClassName:G,chipInactiveClassName:G,triggerClassName:"chat-composer__icon-trigger",labelClassName:"chat-composer__location-label"}),e.jsx(wt,{value:ue,onChange:D,project:ee,assignTo:U,nodes:s,assignableNodes:I,layout:"composer",chipClassName:F,chipActiveClassName:G,chipInactiveClassName:G,triggerClassName:"chat-composer__icon-trigger",labelClassName:"chat-composer__location-label"})]})})()})]})})(),(T||H)&&e.jsxs("div",{className:"space-y-3 rounded-[20px] border border-border/60 bg-background/45 p-4",children:[T,H&&e.jsx("div",{className:"text-xs text-destructive",children:H}),!H&&e.jsx("div",{className:"text-xs text-muted-foreground",children:"Ctrl/Cmd+Enter starts the chat. Enter adds a new line. Paste screenshots directly into the prompt box or use the Images button."})]})]}):e.jsxs("form",{onSubmit:re,className:M("space-y-5",x),children:[e.jsx("input",{ref:X,type:"file",accept:"image/*",multiple:!0,onChange:ae,className:"hidden"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"task-description",className:"text-sm font-medium",children:"Opening prompt"}),e.jsx("textarea",{id:"task-description",value:j,onChange:F=>f(F.target.value),onKeyDown:m,onPaste:le,placeholder:"Describe what the agent should do. This becomes the first message in the chat.",rows:6,autoFocus:w,className:"flex min-h-[144px] w-full resize-none rounded-[22px] border border-border/70 bg-background/70 px-4 py-3 text-sm leading-6 ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(O,{type:"button",variant:"outline",onClick:q,className:"rounded-[16px]",children:[e.jsx(Is,{className:"h-4 w-4"}),"Add images"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Ctrl/Cmd+Enter starts the chat. Enter adds a new line. Upload or paste screenshots and reference images with the opening prompt."})]}),T,H&&e.jsx("p",{className:"text-xs text-destructive",children:H})]}),e.jsxs("div",{className:"grid gap-5 lg:grid-cols-[minmax(0,1fr)_220px_220px]",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"task-title",className:"text-sm font-medium",children:"Chat title"}),e.jsx(Fe,{id:"task-title",type:"text",value:u,onChange:F=>b(F.target.value),placeholder:"Optional. Leave blank to derive it from the prompt.",className:"h-11 rounded-[18px] border-border/70 bg-background/70"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:V?`Will appear as: ${V}`:"A title will be generated from the first line of the prompt."})]}),Ne,we]}),ke,ne,e.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[g,W]}),e.jsxs("div",{className:M("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",k),children:[i&&e.jsx(O,{type:"button",variant:"ghost",onClick:i,className:"rounded-[16px]",children:N}),e.jsx(O,{type:"submit",disabled:!xe||B,className:"rounded-[16px] px-5",children:B?"Creating...":y})]})]})}function Do({nodes:s,currentNodeRole:a,currentNodeId:n,leaderNodeId:o,onCreated:r,onCancel:i,defaultMode:x="chat",mode:k,onModeChange:y,layout:N="default",className:w,footerClassName:d,autoFocus:u=!1}){const[b,j]=t.useState(x),f=k!==void 0,L=f?k:b,_=R=>{f||j(R),y==null||y(R)};return e.jsxs("div",{className:M("space-y-4",w),children:[!f&&e.jsxs("div",{className:"flex items-center gap-2 rounded-[20px] border border-border/60 bg-background/45 p-1",children:[e.jsxs(O,{type:"button",variant:L==="chat"?"default":"ghost",onClick:()=>_("chat"),className:"flex-1 rounded-[16px]",children:[e.jsx(an,{className:"h-4 w-4"}),"New chat"]}),e.jsxs(O,{type:"button",variant:L==="native"?"default":"ghost",onClick:()=>_("native"),className:"flex-1 rounded-[16px]",children:[e.jsx(Ys,{className:"h-4 w-4"}),"Load session"]})]}),L==="chat"?e.jsx(_o,{nodes:s,currentNodeRole:a,currentNodeId:n,leaderNodeId:o,onCreated:r,onCancel:i,footerClassName:d,submitLabel:N==="composer"?"Start chat":"Create chat",cancelLabel:"Cancel",autoFocus:u,layout:N}):e.jsx(So,{nodes:s,currentNodeRole:a,currentNodeId:n,leaderNodeId:o,onCreated:r,onCancel:i,footerClassName:d,autoFocus:u})]})}const Je="72f988bf-86f1-41af-91ab-2d7cd011db47",ua=`${Je} (MSIT)`;function Ao({open:s,onOpenChange:a,onShare:n,onStopShare:o,sharing:r,stopping:i=!1,shareResult:x}){return e.jsx(Ot,{open:s,onOpenChange:a,children:e.jsxs(Rt,{className:"max-w-md rounded-[22px] p-5",children:[e.jsx($t,{className:"sr-only",children:"Share conversation"}),e.jsx(Mo,{onOpenChange:a,onShare:n,onStopShare:o,sharing:r,stopping:i,shareResult:x})]})})}function Mo({onOpenChange:s,onShare:a,onStopShare:n,sharing:o,stopping:r=!1,shareResult:i}){const[x,k]=t.useState((i==null?void 0:i.tenant)??Je),[y,N]=t.useState((i==null?void 0:i.scope)??"chat"),w=(i==null?void 0:i.url)??null,d=o||r;return t.useEffect(()=>{k((i==null?void 0:i.tenant)??Je),N((i==null?void 0:i.scope)??"chat")},[i==null?void 0:i.shareId,i==null?void 0:i.tenant,i==null?void 0:i.scope]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h2",{className:"text-base font-semibold leading-none tracking-tight",children:"Share conversation"}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"Create a tenant-gated link for this task."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(Lo,{value:x,onChange:k,disabled:d}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium text-foreground",children:"Access"}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Ct,{active:y==="chat",title:"Chat only",description:"Conversation transcript and opening prompt.",onClick:()=>N("chat")}),e.jsx(Ct,{active:y==="filesPreview",title:"Chat, files and preview",description:"Transcript plus task output files and HTML preview.",onClick:()=>N("filesPreview")})]})]}),w&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium text-foreground",children:"Shared link"}),e.jsxs("div",{className:"flex items-center gap-2 rounded-[16px] border border-border/70 bg-muted/30 px-3 py-2",children:[e.jsx("input",{readOnly:!0,value:w,className:"min-w-0 flex-1 bg-transparent font-mono text-xs text-foreground outline-none","aria-label":"Shared link"}),e.jsx(O,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 rounded-[12px] text-muted-foreground",onClick:()=>void Ge(w,"Shared link copied"),"aria-label":"Copy shared link",title:"Copy shared link",children:e.jsx(It,{className:"h-3.5 w-3.5"})})]})]})]}),e.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[e.jsx(O,{variant:"outline",onClick:()=>s(!1),disabled:d,className:"h-8 text-xs",children:i?"Done":"Cancel"}),i&&n&&e.jsxs(O,{variant:"outline",onClick:()=>void n(),disabled:d,className:"h-8 border-destructive/30 text-xs text-destructive hover:bg-destructive/10 hover:text-destructive",children:[r&&e.jsx(be,{className:"h-3.5 w-3.5 animate-spin"}),"Stop share"]}),e.jsxs(O,{onClick:()=>void a({tenant:x,scope:y}),disabled:d,className:"h-8 text-xs",children:[o&&e.jsx(be,{className:"h-3.5 w-3.5 animate-spin"}),i?"Update link":"Share link"]})]})]})}function Lo({value:s,onChange:a,disabled:n}){const[o,r]=t.useState(!1),[i,x]=t.useState(!1),[k,y]=t.useState(s),N=t.useRef(null);t.useEffect(()=>{y(s)},[s]),t.useEffect(()=>{if(!o)return;const d=b=>{var f;const j=b.target;j instanceof Node&&((f=N.current)!=null&&f.contains(j)||(r(!1),x(!1)))},u=b=>{b.key==="Escape"&&(r(!1),x(!1))};return document.addEventListener("mousedown",d),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("keydown",u)}},[o]);const w=d=>{const u=d.trim();u&&(a(u),y(u),x(!1),r(!1))};return e.jsxs("div",{className:"space-y-2 text-xs",ref:N,children:[e.jsx("div",{className:"font-medium text-foreground",children:"Tenant"}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>!n&&r(d=>!d),disabled:n,className:"flex h-9 w-full items-center justify-between gap-2 rounded-[15px] border border-border/70 bg-background/70 px-3 text-left text-xs text-foreground shadow-sm outline-none transition-colors hover:bg-background disabled:opacity-50",children:[e.jsx("span",{className:"min-w-0 truncate font-mono",children:Po(s)}),e.jsx(Ke,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"})]}),o&&e.jsxs("div",{className:"absolute left-0 right-0 z-50 mt-2 overflow-hidden rounded-[18px] border border-border/60 bg-background/95 text-xs shadow-lg backdrop-blur",children:[e.jsxs("button",{type:"button",onClick:()=>w(Je),className:"flex w-full items-center justify-between gap-2 px-3 py-2 text-left hover:bg-background/60",children:[e.jsx("span",{className:"min-w-0 truncate font-mono text-[11px]",children:ua}),s===Je&&e.jsx(es,{className:"h-3.5 w-3.5 shrink-0 text-primary"})]}),e.jsx("div",{className:"border-t border-border/60 bg-background/40 px-2.5 py-1.5",children:i?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{value:k,onChange:d=>y(d.target.value),onKeyDown:d=>{d.key==="Enter"&&(d.preventDefault(),w(k))},autoFocus:!0,placeholder:"Tenant ID",className:"h-7 min-w-0 flex-1 rounded-[11px] border border-border/60 bg-background/70 px-2 font-mono text-[11px] outline-none focus:ring-2 focus:ring-ring"}),e.jsx("button",{type:"button",onClick:()=>w(k),className:"flex h-7 w-7 items-center justify-center rounded-[11px] hover:bg-background/60",children:e.jsx(es,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>{y(s),x(!1)},className:"flex h-7 w-7 items-center justify-center rounded-[11px] text-muted-foreground hover:bg-background/60 hover:text-foreground",children:e.jsx(He,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>x(!0),className:"flex h-7 w-full items-center justify-between rounded-[11px] px-1.5 text-[11px] text-muted-foreground hover:bg-background/60 hover:text-foreground",children:[e.jsx("span",{children:"Manual tenant ID"}),e.jsx(ns,{className:"h-3 w-3"})]})})]})]})]})}function Po(s){return s===Je?ua:s}function Ct({active:s,title:a,description:n,onClick:o}){return e.jsxs("button",{type:"button",onClick:o,className:s?"rounded-[15px] border border-primary/45 bg-primary/10 px-3 py-2 text-left shadow-sm":"rounded-[15px] border border-border/70 bg-background px-3 py-2 text-left shadow-sm hover:bg-muted/50",children:[e.jsx("div",{className:"text-xs font-medium text-foreground",children:a}),e.jsx("div",{className:"mt-1 text-[11px] leading-4 text-muted-foreground",children:n})]})}const Ro=t.lazy(async()=>({default:(await Js(()=>import("./FilesTab-BCF4QVC7.js"),__vite__mapDeps([0,1,2,3,4]))).FilesTab})),$o=t.lazy(async()=>({default:(await Js(()=>import("./PreviewTab-kHR8XJHu.js"),__vite__mapDeps([5,1,2,6]))).PreviewTab})),Fo=t.lazy(async()=>({default:(await Js(()=>import("./DiffTab-CHex6isk.js"),__vite__mapDeps([7,1,2,4,3,8,6]))).DiffTab}));function Oo({onToggleTasks:s,desktopTasksOpen:a,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,cluster:i,sseConnected:x,activeTab:k,setActiveTab:y,creatingTask:N,createMode:w,activeTask:d,assignedNode:u,taskLoading:b,taskError:j,displayEvents:f,initialPromptAlreadyInLogs:L,initialPrompt:_,supportsFollowUp:R,taskUnavailable:Y,chatDisabled:ee,chatDisabledReason:$,questionBypassEnabled:ue,isRunning:D,isStarting:K,hasPendingFollowUp:A,canCancel:I,canRetry:S,onRetry:U,onCancel:oe,onShareTask:B,onStopShareTask:C,onStartCreateTask:se,onCancelCreateTask:ie,onCreateTask:te,onSendMessage:H,onQuestionBypassChange:X,onSubmitQuestionResponse:q,messagesEndRef:ae}){const[le,c]=t.useState(!1),[P,v]=t.useState(!1),[J,h]=t.useState(!1),[re,V]=t.useState(!1),[xe,m]=t.useState(!1),[T,W]=t.useState({}),[Ne,we]=t.useState(new Set),[g,ke]=t.useState(new Set),ne=t.useRef(0),F=t.useRef(!1),z=t.useRef(null),me=t.useRef(0),Ee=t.useCallback(de=>{const ve=de.currentTarget,ye=ne.current;if(ne.current=ve.scrollTop,F.current)return;if(ve.scrollHeight-ve.scrollTop-ve.clientHeight<30){c(!1),F.current=!0,setTimeout(()=>{F.current=!1},300);return}ve.scrollTop<ye&&ye-ve.scrollTop>10&&c(!0),ve.scrollTop<=0&&c(!0)},[]),Ie=(d==null?void 0:d.effectiveProjectPath)??(d==null?void 0:d.project)??"default workspace",G=d?(u==null?void 0:u.name)??Bt(d.assignedTo,i==null?void 0:i.nodes,d.assignedNodeName):"unassigned",Be=d!=null&&d.assignedTo?e.jsxs(e.Fragment,{children:["Connecting session on node ",e.jsx("span",{className:"font-medium text-foreground",children:G}),"..."]}):"Connecting session to an available node...",rs=d?[{label:"Working dir",value:Ie,mono:!0},...d.branch?[{label:"Branch",value:d.branch,mono:!0}]:[],{label:"Agent",value:d.agent,mono:!0},{label:"Node",value:G}]:[],os=!!(_&&!L),Xe=os||f.length>0,Qe=D&&Xe,$e=(K||A||D)&&!Qe,Oe=(d==null?void 0:d.conversationKind)==="nativeSession",fs=d&&!Ne.has(d.id)?T[d.id]??d.activeShare??null:null;return N?e.jsx(Io,{onToggleTasks:s,desktopTasksOpen:a,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,cluster:i,sseConnected:x,defaultMode:w,onCancel:ie,onCreated:te}):!d&&b?e.jsxs("div",{className:"dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-[28px]",children:[e.jsx("div",{className:"shrink-0 border-b border-border/55 bg-card/28 px-3 py-3 sm:px-5",children:e.jsx(Hs,{onToggleTasks:s,desktopTasksOpen:a,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,cluster:i,sseConnected:x})}),e.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-y-auto px-6 py-10 sm:px-8",children:e.jsxs("div",{className:"space-y-4 text-center",children:[e.jsx("div",{className:"mx-auto flex h-16 w-16 items-center justify-center rounded-[22px] border border-primary/20 bg-primary/10 text-primary shadow-sm",children:e.jsx(be,{className:"h-7 w-7 animate-spin"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h2",{className:"text-2xl font-semibold tracking-tight text-foreground",children:"Loading conversation"}),e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-[11px] text-muted-foreground",children:[e.jsx(be,{className:"h-4 w-4 animate-spin"}),"Fetching the selected chat thread..."]})]})]})})]}):d?e.jsxs(zt,{value:k,onValueChange:de=>{k==="transcript"&&z.current&&(me.current=z.current.scrollTop),y(de),de==="transcript"&&requestAnimationFrame(()=>{z.current&&(z.current.scrollTop=me.current)})},className:"dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-[28px]",children:[e.jsxs("div",{className:"shrink-0 border-b border-border/55 bg-card/28 px-3 py-3 sm:px-5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(xa,{desktopTasksOpen:a,mobileTasksPanelOpen:n,onToggleTasks:s}),e.jsx("h2",{className:"min-w-0 truncate text-sm font-semibold tracking-tight text-foreground sm:text-lg",title:d.title,children:d.title}),Oe&&e.jsx(Ae,{variant:"outline",className:"shrink-0 rounded-[11px] border-sky-500/30 bg-sky-500/10 text-sky-700 dark:text-sky-300",children:"Native session"}),e.jsx(Ut,{status:d.status}),e.jsx(rn,{priority:d.priority}),e.jsx(O,{variant:"outline",size:"icon",onClick:r,title:o?"Hide cluster":"Show cluster","aria-label":o?"Hide cluster":"Show cluster",className:"ml-auto h-7 w-7 shrink-0 rounded-[12px] border-border/70 bg-background/68",children:o?e.jsx(Qs,{className:"h-4 w-4"}):e.jsx(ea,{className:"h-4 w-4"})})]}),j&&e.jsx("div",{className:"mt-2 w-fit rounded-[12px] border border-destructive/25 bg-destructive/10 px-2 py-1 text-[11px] text-destructive",children:j}),e.jsxs("div",{className:"mt-2 flex items-center gap-1.5",children:[e.jsxs(Vt,{className:"h-auto max-w-full overflow-x-auto rounded-[16px] bg-muted/70 p-0.5",children:[e.jsx(ze,{value:"transcript",className:"rounded-[12px] px-2 py-0.5 text-[11px] sm:px-2.5",children:"Transcript"}),e.jsx(ze,{value:"files",className:"rounded-[12px] px-2 py-0.5 text-[11px] sm:px-2.5",children:"Files"}),e.jsx(ze,{value:"preview",className:"rounded-[12px] px-2 py-0.5 text-[11px] sm:px-2.5",children:"Preview"}),e.jsx(ze,{value:"diff",className:"rounded-[12px] px-2 py-0.5 text-[11px] sm:px-2.5",children:"Diff"})]}),D&&e.jsx(Ae,{variant:"outline",className:"hidden rounded-[11px] border-amber-500/30 bg-amber-500/10 text-amber-700 sm:inline-flex dark:text-amber-300",children:"Working"}),Y&&e.jsx(Ae,{variant:"outline",className:"hidden rounded-[11px] border-destructive/25 bg-destructive/10 text-destructive sm:inline-flex",children:"Unavailable"}),e.jsxs("div",{className:"ml-auto flex items-center gap-2 text-[10px] text-muted-foreground",children:[e.jsxs("span",{className:"hidden sm:inline",children:["updated ",on(d.updatedAt)]}),e.jsx("span",{className:"font-mono",children:d.id.slice(0,8)}),S&&e.jsxs(O,{variant:"outline",size:"sm",onClick:U,className:"h-7 shrink-0 rounded-[12px] px-2 text-[11px]",children:[e.jsx(Rr,{className:"h-3.5 w-3.5"}),"Retry"]}),e.jsxs(O,{type:"button",variant:"outline",size:"sm",disabled:Y,title:Y?"Unavailable tasks cannot be shared.":"Share conversation",className:"h-7 shrink-0 rounded-[12px] border-primary/30 bg-primary/10 px-2 text-[11px] text-primary hover:bg-primary/15 hover:text-primary disabled:border-border/60 disabled:bg-muted/40 disabled:text-muted-foreground",onClick:()=>h(!0),children:[e.jsx(Ir,{className:"h-3.5 w-3.5"}),"Share"]})]})]})]}),e.jsx(Ue,{value:"transcript",className:"mt-0 min-h-0 flex-1",children:e.jsxs("div",{className:"relative flex h-full min-h-0 flex-col",children:[e.jsx("div",{ref:z,className:"min-h-0 flex-1 touch-pan-y overflow-x-hidden overflow-y-auto overscroll-x-none bg-gradient-to-b from-background/15 via-transparent to-background/35 px-3 py-5 sm:px-5",onScroll:Ee,children:e.jsxs("div",{className:"mx-auto flex max-w-[72rem] flex-col gap-5",children:[os&&_&&e.jsx(bt,{event:_,questionBypassEnabled:ue,onQuestionBypassChange:X,onSubmitQuestionResponse:q,questionResponseDisabled:!R||ee}),f.map((de,ve)=>e.jsx(bt,{event:de,questionBypassEnabled:ue,onQuestionBypassChange:X,onSubmitQuestionResponse:q,questionResponseDisabled:!R||ee},er("transcript",de,ve))),!Xe&&!$e&&e.jsxs("div",{className:"rounded-[28px] border border-dashed border-border/70 bg-background/35 px-5 py-8 text-center",children:[e.jsx("div",{className:"text-[11px] font-medium text-foreground",children:"Transcript is warming up"}),e.jsx("div",{className:"mt-2 text-[11px] leading-6 text-muted-foreground",children:b?"Fetching task output...":Oe?"This native session is attached. Transcript starts after the next message you send from Meshy.":"The opening prompt has been stored, but the agent has not emitted conversation output yet."})]}),(!R&&d.result||d.error)&&e.jsxs("div",{className:"space-y-3",children:[!R&&d.result&&e.jsxs("div",{className:"rounded-[26px] border border-border/70 bg-card/80 px-3 py-3",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.22em] text-muted-foreground",children:"Stored result"}),e.jsx("pre",{className:"mt-3 overflow-x-auto whitespace-pre-wrap text-[11px] leading-5 text-muted-foreground",children:JSON.stringify(d.result,null,2)})]}),d.error&&!g.has(d.id)&&e.jsxs("div",{className:"rounded-[26px] border border-destructive/20 bg-destructive/10 px-3 py-3 text-destructive",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.22em]",children:"Stored error"}),e.jsx("button",{onClick:()=>ke(de=>new Set(de).add(d.id)),className:"rounded p-0.5 hover:bg-destructive/20","aria-label":"Dismiss error",children:e.jsx(He,{className:"h-3.5 w-3.5"})})]}),e.jsx("pre",{className:"mt-3 overflow-x-auto whitespace-pre-wrap text-[11px] leading-5",children:d.error})]})]}),$e&&e.jsx(Tt,{children:Be}),Qe&&e.jsx(Tt,{children:"The agent is still working on this conversation."}),e.jsx("div",{ref:ae})]})}),R?e.jsxs(e.Fragment,{children:[le&&e.jsx(O,{size:"icon",onClick:()=>c(!1),className:"absolute bottom-4 right-4 z-10 h-12 w-12 rounded-[18px] shadow-lg",children:e.jsx(ns,{className:"h-4 w-4"})}),e.jsx("div",{className:`shrink-0 ${le?"hidden":""}`,children:e.jsx("div",{className:"mx-auto w-full max-w-[72rem]",children:e.jsx(ro,{onSend:H,disabled:ee,disabledReason:$,contextItems:rs,placeholder:ee?$:"Continue the conversation...",running:D||A,onStop:I?()=>v(!0):void 0})})})]}):e.jsx("div",{className:"shrink-0 border-t border-border/60 px-3 py-3 text-[11px] text-muted-foreground sm:px-5",children:"This task does not expose follow-up chat messages. Use Files, Preview, or Diff to inspect the result."})]})}),e.jsx(Ue,{value:"files",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(t.Suspense,{fallback:e.jsx(Cs,{label:"Loading files..."}),children:e.jsx(Ro,{taskId:d.id})})}),e.jsx(Ue,{value:"preview",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(t.Suspense,{fallback:e.jsx(Cs,{label:"Loading preview..."}),children:e.jsx($o,{taskId:d.id})})}),e.jsx(Ue,{value:"diff",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(t.Suspense,{fallback:e.jsx(Cs,{label:"Loading diff..."}),children:e.jsx(Fo,{taskId:d.id})})}),e.jsx(_s,{open:P,onOpenChange:v,children:e.jsxs(Ds,{children:[e.jsxs(As,{children:[e.jsx(Ms,{children:"Stop this task?"}),e.jsx(Ls,{children:"The task will stop and move to a cancelled state."})]}),e.jsxs(Ps,{children:[e.jsx(Rs,{children:"Keep running"}),e.jsx($s,{onClick:oe,children:"Stop task"})]})]})}),e.jsx(Ao,{open:J,onOpenChange:h,sharing:re,stopping:xe,shareResult:fs,onShare:async de=>{if(!d)return null;V(!0);try{const ve=await B(de);return ve!=null&&ve.url&&(W(ye=>({...ye,[d.id]:ve})),we(ye=>{const Ze=new Set(ye);return Ze.delete(d.id),Ze})),ve}finally{V(!1)}},onStopShare:async()=>{if(!d)return!1;m(!0);try{const de=await C();return de!==!1&&(W(ve=>{const ye={...ve};return delete ye[d.id],ye}),we(ve=>new Set(ve).add(d.id))),de}finally{m(!1)}}})]}):e.jsxs("div",{className:"dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-[28px]",children:[e.jsx("div",{className:"shrink-0 border-b border-border/55 bg-card/28 px-3 py-3 sm:px-5",children:e.jsx(Hs,{onToggleTasks:s,desktopTasksOpen:a,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,cluster:i,sseConnected:x})}),e.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-y-auto px-6 py-10 sm:px-8",children:e.jsxs("div",{className:"w-full max-w-2xl text-center",children:[e.jsx("div",{className:"mx-auto flex h-16 w-16 items-center justify-center rounded-[22px] border border-primary/20 bg-primary/10 text-primary shadow-sm",children:e.jsx(Ws,{className:"h-7 w-7"})}),e.jsx("h2",{className:"mt-5 text-xl font-semibold tracking-tight text-foreground sm:text-3xl",children:"No chat selected"}),e.jsx("p",{className:"mx-auto mt-3 max-w-xl text-[11px] leading-6 text-muted-foreground",children:"Open a task from the left sidebar to continue the conversation, or start a new task or load a native session."}),e.jsxs(O,{onClick:se,className:"mt-6 rounded-[18px] px-5",children:[e.jsx(Xs,{className:"h-4 w-4"}),"Start or load chat"]}),j&&e.jsx("div",{className:"mx-auto mt-4 max-w-lg rounded-[20px] border border-destructive/20 bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:j})]})})]})}function Tt({children:s}){return e.jsxs("div",{className:"flex items-center gap-1.5 rounded-[18px] border border-border/60 bg-background/55 px-3 py-2 text-[11px] text-muted-foreground shadow-sm",children:[e.jsx(be,{className:"h-4 w-4 shrink-0 animate-spin"}),e.jsx("div",{className:"min-w-0 leading-5",children:s})]})}function Io({onToggleTasks:s,desktopTasksOpen:a,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,cluster:i,sseConnected:x,defaultMode:k,onCancel:y,onCreated:N}){var b,j,f;const[w,d]=t.useState(k??"chat");t.useEffect(()=>{k&&d(k)},[k]);const u=e.jsx("div",{className:"flex items-center gap-1 rounded-[18px] border border-border/60 bg-background/65 p-0.5 text-[11px] font-medium shadow-sm",children:[{value:"chat",label:"New chat",icon:Xs},{value:"native",label:"Load session",icon:Ys}].map(L=>{const _=L.icon,R=L.value===w;return e.jsxs("button",{type:"button",onClick:()=>d(L.value),"aria-pressed":R,className:M("flex items-center gap-1.5 rounded-[14px] px-2 py-1 transition-all duration-200",R?"bg-primary text-primary-foreground shadow-[0_8px_24px_-12px_hsl(var(--primary)/0.7)]":"text-muted-foreground hover:bg-background/80 hover:text-foreground"),children:[e.jsx(_,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:L.label})]},L.value)})});return e.jsxs("div",{className:"dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-[28px]",children:[e.jsx("div",{className:"shrink-0 border-b border-border/55 bg-card/28 px-3 py-3 sm:px-5",children:e.jsx(Hs,{onToggleTasks:s,desktopTasksOpen:a,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,cluster:i,sseConnected:x,centerSlot:u})}),e.jsx("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center overflow-y-auto px-6 py-10 sm:px-8",children:e.jsx("div",{className:"w-full max-w-2xl",children:e.jsx(Do,{nodes:(i==null?void 0:i.nodes)??[],currentNodeRole:(b=i==null?void 0:i.self)==null?void 0:b.role,currentNodeId:((j=i==null?void 0:i.self)==null?void 0:j.id)??null,leaderNodeId:((f=i==null?void 0:i.leader)==null?void 0:f.id)??null,mode:w,onModeChange:d,onCreated:N,onCancel:y,autoFocus:!0,layout:"composer"})})})]})}function Hs({onToggleTasks:s,desktopTasksOpen:a,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,centerSlot:i}){return e.jsxs("div",{className:"relative flex w-full items-center justify-between gap-1.5",children:[e.jsx("div",{className:"flex min-w-0 items-center gap-1.5",children:e.jsx(xa,{desktopTasksOpen:a,mobileTasksPanelOpen:n,onToggleTasks:s})}),i&&e.jsx("div",{className:"pointer-events-none absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2",children:e.jsx("div",{className:"pointer-events-auto",children:i})}),e.jsx(O,{variant:"outline",size:"icon",onClick:r,title:o?"Hide cluster":"Show cluster","aria-label":o?"Hide cluster":"Show cluster",className:"h-7 w-7 shrink-0 rounded-[12px] border-border/70 bg-background/68",children:o?e.jsx(Qs,{className:"h-4 w-4"}):e.jsx(ea,{className:"h-4 w-4"})})]})}function xa({desktopTasksOpen:s,mobileTasksPanelOpen:a,onToggleTasks:n}){var r,i;const o=(i=(r=globalThis.window)==null?void 0:r.matchMedia("(min-width: 1024px)"))!=null&&i.matches?s:a;return e.jsx(O,{variant:"outline",size:"icon",onClick:n,title:o?"Hide tasks":"Show tasks","aria-label":o?"Hide tasks":"Show tasks",className:"h-7 w-7 shrink-0 rounded-[12px] border-border/70 bg-background/68",children:o?e.jsx(Zt,{className:"h-4 w-4"}):e.jsx(Er,{className:"h-4 w-4"})})}const Bo=10,Ve="__all__";function Le(s){return"session"in s}function Et(s,a){var n;return a&&s.some(o=>o.id===a)?a:((n=s[0])==null?void 0:n.id)??""}function Es(s){return s&&(la(s.id)||s.workDir)||""}function xs(s,a,n){let o=!1;const r=s.map(i=>Le(i)&&i.session.id===n.id?(o=!0,{...i,nodeName:a,session:n}):i);return Ks(o?r:[...r,{id:`session-${n.id}`,nodeName:a,session:n}])}function ma(s,a){return s.filter(Le).filter(n=>n.session.nodeId===a).sort((n,o)=>o.session.startedAt-n.session.startedAt)}function zo(s){const a=s.filter(Le).sort((n,o)=>o.session.startedAt-n.session.startedAt);return{active:a.filter(n=>n.session.status==="running"),completed:a.filter(n=>n.session.status!=="running")}}function Uo(s,a){return!!(s&&a&&!s.contains(a))}function Vo(s,a,n){var r;if(n===Ve)return n;const o=ma(s,a);return o.some(i=>i.session.id===n)?n:((r=o[0])==null?void 0:r.session.id)??Ve}function Ho(s,a,n){return n===Ve?s.filter(o=>!Le(o)||o.session.nodeId===a):s.filter(o=>Le(o)&&o.session.nodeId===a&&o.session.id===n)}function Ks(s){const a=s.map((o,r)=>({entry:o,index:r})).filter(({entry:o})=>Le(o)&&o.session.status!=="running").sort((o,r)=>!Le(o.entry)||!Le(r.entry)?0:r.entry.session.startedAt-o.entry.session.startedAt||r.index-o.index),n=new Set(a.slice(0,Bo).map(({entry:o})=>Le(o)?o.session.id:""));return s.filter(o=>!Le(o)||o.session.status==="running"||n.has(o.session.id))}function qs(s){return s.status==="running"?s.pid?`running pid ${s.pid}`:"running":s.status==="exited"?`exit ${s.exitCode??0}`:s.status==="stopped"?"stopped":s.signal?`failed ${s.signal}`:`exit ${s.exitCode??"failed"}`}function Ko(s){const a=s.session.command.length>48?`${s.session.command.slice(0,45)}...`:s.session.command;return`${s.nodeName} - ${qs(s.session)} - ${a}`}function ha(s,a=48){return s.length>a?`${s.slice(0,a-3)}...`:s}function qo(s,a){return a===Ve?"All sessions":s?ha(s.session.command,34):"Command session"}function _t(s){return s.status==="stopped"?"":s.stderr}function Wo({nodes:s,defaultNodeId:a,onClose:n,initialHistory:o=[]}){const[r,i]=t.useState(()=>Et(s,a)),x=t.useMemo(()=>s.find(c=>c.id===r)??s[0]??null,[s,r]),[k,y]=t.useState(()=>Es(x)),[N,w]=t.useState(""),[d,u]=t.useState(()=>Ks(o)),[b,j]=t.useState(Ve),[f,L]=t.useState(!1),[_,R]=t.useState(!1),[Y,ee]=t.useState(!1),[$,ue]=t.useState(!1),[D,K]=t.useState(!1),A=t.useRef(null),I=t.useRef(null),S=t.useMemo(()=>s.find(c=>c.id===r)??s[0]??null,[s,r]),U=t.useMemo(()=>ma(d,(S==null?void 0:S.id)??""),[d,S]),oe=t.useMemo(()=>zo(U),[U]),B=t.useMemo(()=>U.find(c=>c.session.id===b),[b,U]),C=t.useMemo(()=>Ho(d,(S==null?void 0:S.id)??"",b),[d,S,b]),se=t.useRef((S==null?void 0:S.id)??"");t.useEffect(()=>{r&&s.some(c=>c.id===r)||i(Et(s,a))},[a,s,r]),t.useEffect(()=>{const c=(S==null?void 0:S.id)??"";se.current!==c&&(se.current=c,y(Es(S)))},[S]),t.useEffect(()=>{j(c=>Vo(d,(S==null?void 0:S.id)??"",f?c:""))},[d,S,f]),t.useEffect(()=>{var c;(c=A.current)==null||c.scrollTo({top:A.current.scrollHeight})},[d]),t.useEffect(()=>{let c=!1;async function P(){const v=await Promise.allSettled(s.map(async J=>({node:J,response:await dn(J.id)})));c||u(J=>v.reduce((h,re)=>re.status!=="fulfilled"?h:re.value.response.sessions.reduce((V,xe)=>xs(V,re.value.node.name,xe),h),J))}return s.length>0&&P(),()=>{c=!0}},[s]),t.useEffect(()=>{const c=d.filter(Le).filter(v=>v.session.status==="running");if(c.length===0)return;const P=window.setInterval(()=>{for(const v of c)ln(v.session.nodeId,v.session.id).then(J=>u(h=>xs(h,v.nodeName,J))).catch(()=>{})},1e3);return()=>window.clearInterval(P)},[d]);const ie=t.useRef(null);async function te(c){if(c.preventDefault(),!S||!N.trim()||D)return;const P=N.trim(),v=S.name;K(!0),w("");try{const J=await un(S.id,{command:P,...k.trim()?{cwd:k.trim()}:{}});u(h=>xs(h,v,J)),j(J.id),L(!0)}catch(J){u(h=>[...h,{id:`${Date.now()}-${Math.random().toString(16).slice(2)}`,nodeName:v,command:P,error:J instanceof Error?J.message:"Command failed"}])}finally{K(!1)}}async function H(c,P){c.stopPropagation();const v=await cn(P.session.nodeId,P.session.id);u(J=>xs(J,P.nodeName,v))}function X(c){j(c),L(!0),R(!1)}function q(c){_&&Uo(I.current,c.target)&&R(!1)}function ae(c,P,v,J,h){return e.jsxs("div",{className:"border-t border-border/60 py-1",children:[e.jsxs("button",{type:"button",onClick:J,"aria-label":`Toggle ${c} sessions`,"aria-expanded":!v,className:"flex w-full items-center justify-between gap-2 px-2 pb-1 pt-0.5 text-left text-[10px] font-medium uppercase tracking-normal text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:[e.jsx("span",{children:c}),e.jsx(Ke,{className:M("h-3 w-3 transition-transform",v&&"-rotate-90")})]}),!v&&(P.length>0?P.map(le):e.jsx("div",{className:"px-2 py-1 text-[11px] text-muted-foreground",children:h}))]})}function le(c){const P=b===c.session.id,v=c.session.status==="running";return e.jsxs("div",{className:M("group flex w-full items-center gap-2 px-2 py-1.5 text-left text-[11px] transition-colors hover:bg-muted/65",P&&"bg-primary/10 text-primary"),children:[e.jsxs("button",{type:"button",onClick:()=>X(c.session.id),className:"flex min-w-0 flex-1 items-center gap-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:[e.jsx("span",{className:M("flex h-4 w-4 shrink-0 items-center justify-center",v?"text-primary":c.session.status==="exited"?"text-emerald-600 dark:text-emerald-300":"text-amber-600 dark:text-amber-300"),children:v?e.jsx(be,{className:"h-3 w-3 animate-spin"}):c.session.status==="exited"?e.jsx(ht,{className:"h-3 w-3"}):e.jsx(ms,{className:"h-3 w-3"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-foreground",children:ha(c.session.command,44)}),e.jsxs("span",{className:"block truncate text-[10px] text-muted-foreground",children:[c.nodeName," · ",qs(c.session)]})]})]}),v&&e.jsx("button",{type:"button",onClick:J=>void H(J,c),"aria-label":"Stop terminal session from selector",title:"Stop terminal session",className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:e.jsx(Nt,{className:"h-3 w-3"})})]},c.session.id)}return e.jsx("section",{className:"dashboard-panel animate-composer-settle shrink-0 overflow-visible rounded-[24px]","aria-label":"Node terminal",onClick:q,children:e.jsxs("div",{className:"flex w-full flex-col overflow-visible rounded-[inherit] bg-card/72 text-card-foreground",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b border-border/60 px-3 py-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-[11px] font-medium",children:[n?e.jsx("button",{type:"button",onClick:n,"aria-label":"Close terminal",title:"Close terminal",className:"flex h-6 w-6 items-center justify-center rounded-md text-primary transition-colors hover:bg-muted/65 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:e.jsx(Ss,{className:"h-3.5 w-3.5"})}):e.jsx(Ss,{className:"h-3.5 w-3.5 text-primary"}),e.jsx("span",{children:"Terminal"})]}),e.jsxs("div",{className:"ml-auto flex min-w-0 flex-wrap items-center justify-end gap-2",children:[e.jsxs("div",{ref:I,className:"relative min-w-0",children:[e.jsxs("button",{type:"button","aria-label":"Command session","aria-expanded":_,title:B?Ko(B):"All sessions",onClick:()=>R(c=>!c),className:"flex h-7 max-w-[14rem] list-none items-center gap-1.5 rounded-[10px] border border-border/70 bg-background/70 px-2 text-[11px] text-foreground outline-none transition-colors hover:bg-muted/65 focus-visible:ring-2 focus-visible:ring-ring/70 [&::-webkit-details-marker]:hidden",children:[e.jsx("span",{className:"min-w-0 truncate",children:qo(B,b)}),e.jsx(Ke,{className:M("h-3 w-3 shrink-0 text-muted-foreground transition-transform",_&&"rotate-180")})]}),e.jsx("div",{"aria-hidden":!_,className:M("absolute right-0 bottom-9 z-30 w-[19rem] overflow-hidden rounded-xl border border-border/70 bg-popover text-popover-foreground shadow-xl",!_&&"hidden"),children:e.jsxs("div",{className:"max-h-72 overflow-y-auto",children:[e.jsxs("button",{type:"button",onClick:()=>X(Ve),className:M("flex w-full items-center gap-2 px-2 py-1.5 text-left text-[11px] transition-colors hover:bg-muted/65 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",b===Ve&&"bg-primary/10 text-primary"),children:[e.jsx(Ss,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:"All sessions"})]}),ae("Active",oe.active,Y,()=>ee(c=>!c),"No active sessions"),ae("Completed",oe.completed,$,()=>ue(c=>!c),"No completed sessions")]})})]}),e.jsx("select",{value:(S==null?void 0:S.id)??"",onChange:c=>{i(c.target.value),L(!1),y(Es(s.find(P=>P.id===c.target.value)??null))},disabled:D||s.length===0,"aria-label":"Terminal node",className:"h-7 max-w-[11rem] rounded-[10px] border border-border/70 bg-background/70 px-2 text-[11px] text-foreground outline-none transition-colors hover:bg-muted/65 disabled:opacity-50",children:s.map(c=>e.jsx("option",{value:c.id,className:"bg-background text-foreground",children:c.name},c.id))}),e.jsx(ps,{value:k,onChange:y,assignTo:(S==null?void 0:S.id)??"",nodes:s,assignableNodes:s,layout:"composer",chipClassName:"h-7 max-w-[18rem] rounded-[10px] border border-border/70 bg-background/70 px-2 text-[11px] text-foreground hover:bg-muted/65",chipActiveClassName:"font-mono",chipInactiveClassName:"text-muted-foreground",labelClassName:"text-[11px]",triggerClassName:"terminal-workdir-trigger",popoverPlacement:"top",popoverAlign:"end"})]})]}),e.jsxs("div",{ref:A,className:"max-h-64 min-h-[8rem] overflow-y-auto bg-muted/22 px-3 py-2 font-mono text-[11px] leading-5 cursor-text",onClick:()=>{var c;return(c=ie.current)==null?void 0:c.focus()},children:[C.length===0?e.jsx("div",{className:"text-muted-foreground mb-2",children:"Commands run on the selected node and stay visible while running or after exit."}):e.jsx("div",{className:"space-y-3 mb-2",children:C.map(c=>Le(c)?e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-muted-foreground",children:[e.jsxs("span",{className:"text-primary",children:[c.nodeName,"$"]}),e.jsx("span",{className:"break-all text-foreground",children:c.session.command}),e.jsxs("span",{className:M("inline-flex items-center gap-1",c.session.status==="running"||c.session.status==="exited"?"text-primary":"text-amber-600 dark:text-amber-300"),children:[c.session.status==="running"?e.jsx(be,{className:"h-3 w-3 animate-spin"}):c.session.status==="exited"?e.jsx(ht,{className:"h-3 w-3"}):e.jsx(ms,{className:"h-3 w-3"}),qs(c.session)]}),c.session.status==="running"&&e.jsx("button",{type:"button",onClick:P=>void H(P,c),"aria-label":"Stop terminal session",title:"Stop terminal session",className:"inline-flex h-5 w-5 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted/65 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:e.jsx(Nt,{className:"h-3 w-3"})})]}),c.session.stdout&&e.jsx("pre",{className:"whitespace-pre-wrap break-words text-foreground",children:c.session.stdout}),_t(c.session)&&e.jsx("pre",{className:"whitespace-pre-wrap break-words text-destructive",children:_t(c.session)}),(c.session.stdoutTruncated||c.session.stderrTruncated)&&e.jsx("div",{className:"text-muted-foreground",children:"Output truncated to the latest output."})]},c.id):e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-muted-foreground",children:[e.jsxs("span",{className:"text-primary",children:[c.nodeName,"$"]}),e.jsx("span",{className:"break-all text-foreground",children:c.command}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-destructive",children:[e.jsx(ms,{className:"h-3 w-3"}),"error"]})]}),e.jsx("pre",{className:"whitespace-pre-wrap break-words text-destructive",children:c.error})]},c.id))}),e.jsxs("form",{onSubmit:te,className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"shrink-0 text-primary select-none",children:S?`${S.name}$`:"$"}),e.jsx("input",{ref:ie,value:N,onChange:c=>w(c.target.value),disabled:!S||D,placeholder:S?"":"No online nodes available",className:"flex-1 min-w-0 bg-transparent border-none outline-none text-foreground placeholder:text-muted-foreground font-mono text-[11px] caret-primary disabled:opacity-50",autoComplete:"off",spellCheck:!1}),e.jsx("button",{type:"submit","aria-label":"Run",title:"Run",disabled:!S||!N.trim()||D,className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-md text-primary transition-colors hover:bg-muted/65 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70 disabled:pointer-events-none disabled:text-muted-foreground disabled:opacity-50",children:D?e.jsx(be,{className:"h-3 w-3 animate-spin"}):e.jsx(lr,{className:"h-3 w-3"})})]})]})]})})}function Dt({cluster:s,systemInfo:a,nodeNameById:n,nodeBlockingTaskCounts:o,eventTypeFilter:r,onEventTypeFilterChange:i,eventTypeOptions:x,filteredEvents:k,sseConnected:y,clusterLoading:N,clusterError:w,promotePending:d,onPromote:u,onAddNode:b,leavePending:j,onLeaveCluster:f,onToggleNodeDevTunnel:L,devTunnelNodeId:_,onClose:R}){var U,oe,B;const Y=((U=s==null?void 0:s.self)==null?void 0:U.role)==="leader",ee=((oe=s==null?void 0:s.self)==null?void 0:oe.role)==="follower"&&!(s!=null&&s.leader),$=(s==null?void 0:s.self)??null,D=xn((s==null?void 0:s.nodes)??[],$==null?void 0:$.id).filter(C=>C.id!==($==null?void 0:$.id)),K=s!=null&&s.leader?s.nodes.find(C=>{var se;return C.id===((se=s.leader)==null?void 0:se.id)})??null:null,A=s!=null&&s.leader?s.leader.dashboardOrigin??(K==null?void 0:K.dashboardOrigin)??(a&&s.leader.id===(a.nodeId??a.id)?a.dashboardOrigin:void 0)??s.leader.endpoint:null,I=($==null?void 0:$.role)==="leader"&&D.length===0,S=($==null?void 0:$.role)==="follower";return e.jsx("aside",{className:"dashboard-panel dashboard-panel-muted animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-[28px]",children:e.jsxs(zt,{defaultValue:"overview",className:"flex h-full min-h-0 flex-col",children:[e.jsxs("div",{className:"shrink-0 border-b border-border/55 bg-card/24 px-3 py-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-base font-semibold tracking-tight",children:"Operations"}),e.jsx("p",{className:"mt-0.5 text-[10px] text-muted-foreground",children:"Node, cluster, and live events."})]}),e.jsx(O,{variant:"ghost",size:"icon",onClick:R,className:"h-7 w-7 rounded-[12px]",children:e.jsx(Qs,{className:"h-4 w-4"})})]}),e.jsxs(Vt,{className:"mt-2 grid h-auto w-full grid-cols-3 rounded-[16px] bg-muted/70 p-0.5",children:[e.jsx(ze,{value:"overview",className:"rounded-[12px] px-2 py-0.5 text-[11px]",children:"Overview"}),e.jsx(ze,{value:"nodes",className:"rounded-[12px] px-2 py-0.5 text-[11px]",children:"Nodes"}),e.jsx(ze,{value:"events",className:"rounded-[12px] px-2 py-0.5 text-[11px]",children:"Live events"})]})]}),e.jsx(Ue,{value:"overview",className:"mt-0 min-h-0 flex-1",children:e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-y-auto px-3 py-3",children:e.jsxs("div",{className:"space-y-4",children:[$&&e.jsx(At,{node:$,systemInfo:a,blockingTaskCount:o.get($.id)??0,devTunnelNodeId:_,onToggleNodeDevTunnel:L,showActions:!1,defaultExpanded:!1}),e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-1.5",children:[e.jsx("div",{className:"text-[11px] font-medium text-foreground",children:"Cluster snapshot"}),e.jsx(Ae,{variant:"outline",className:"rounded-[11px] border-border/70 bg-background/60",children:y?"Connected":"Reconnecting"})]}),N&&!s?e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[e.jsx(be,{className:"h-4 w-4 animate-spin"}),"Loading cluster state..."]}):w&&!s?e.jsx("div",{className:"rounded-[18px] border border-destructive/20 bg-destructive/10 px-2.5 py-2 text-[11px] text-destructive",children:w}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsx(We,{label:"Term",value:String((s==null?void 0:s.term)??0)}),e.jsx(We,{label:"Nodes",value:String((s==null?void 0:s.nodes.length)??0)}),e.jsx(We,{label:"Pending",value:String((s==null?void 0:s.taskSummary.pending)??0)}),e.jsx(We,{label:"Running",value:String((s==null?void 0:s.taskSummary.running)??0)}),e.jsx(We,{label:"Completed",value:String((s==null?void 0:s.taskSummary.completed)??0)}),e.jsx(We,{label:"Failed",value:String((s==null?void 0:s.taskSummary.failed)??0)})]}),e.jsxs("div",{className:"space-y-2 rounded-[18px] border border-border/60 bg-background/52 px-2.5 py-2.5 shadow-sm",children:[e.jsx(Re,{label:"Leader",value:((B=s==null?void 0:s.leader)==null?void 0:B.name)??"None"}),e.jsx(Re,{label:"Leader URL",value:A??"Unavailable",mono:!0,action:A?e.jsx(as,{label:"Copy leader URL",onClick:()=>void Ge(A,"Leader URL copied")}):void 0}),e.jsx(Re,{label:"Feed",value:y?"Receiving live updates":"Reconnecting to event stream"})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:ee&&e.jsxs(O,{variant:"outline",size:"sm",onClick:u,disabled:d,className:"h-7 rounded-[12px] px-2.5 text-[11px]",children:[d&&e.jsx(be,{className:"h-3.5 w-3.5 animate-spin"}),"Promote self"]})})]})]})]})})}),e.jsx(Ue,{value:"nodes",className:"mt-0 min-h-0 flex-1",children:e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-y-auto px-3 py-3",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-1.5",children:[e.jsx("div",{className:"text-[11px] font-medium text-foreground",children:"This node"}),I?e.jsx(O,{variant:"outline",size:"sm",onClick:b,className:"h-7 rounded-[12px] px-2.5 text-[11px]",children:"Join node"}):S?e.jsxs(O,{variant:"outline",size:"sm",onClick:f,disabled:j,className:"h-7 rounded-[12px] px-2.5 text-[11px]",children:[j&&e.jsx(be,{className:"h-3.5 w-3.5 animate-spin"}),"Leave cluster"]}):null]}),$&&e.jsx(At,{node:$,systemInfo:a,blockingTaskCount:o.get($.id)??0,devTunnelNodeId:_,onToggleNodeDevTunnel:L,showActions:!0,defaultExpanded:!0})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"text-[11px] font-medium text-foreground",children:["Peer nodes (",D.length,")"]}),D.length>0?e.jsx("div",{className:"space-y-2",children:D.map(C=>e.jsx(Go,{node:C,isLeader:!!Y,blockingTaskCount:o.get(C.id)??0,devTunnelNodeId:_,onToggleNodeDevTunnel:L},C.id))}):e.jsx("div",{className:"rounded-[20px] border border-dashed border-border/70 bg-background/35 px-3 py-3 text-[11px] text-muted-foreground",children:"No peer nodes are connected yet."})]})]})})}),e.jsx(Ue,{value:"events",className:"mt-0 min-h-0 flex-1",children:e.jsxs("div",{className:"flex h-full min-h-0 flex-col px-3 py-3",children:[e.jsxs("div",{className:"mb-3 space-y-2",children:[e.jsx("div",{children:e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-medium text-foreground",children:[e.jsx(mn,{className:M("h-4 w-4",y?"text-emerald-500":"text-destructive")}),"Live events"]})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsxs(Se,{value:r,onValueChange:i,children:[e.jsx(Ce,{className:"h-7 min-w-[11rem] flex-1 rounded-[13px] border-border/70 bg-background/60 text-[11px] sm:max-w-[15rem]",children:e.jsx(Me,{placeholder:"Event type"})}),e.jsx(Te,{children:x.map(C=>e.jsx(ge,{value:C,className:"text-[11px]",children:C==="all"?"All event types":C},C))})]}),e.jsx(Ae,{variant:"outline",className:"rounded-[11px] border-border/70 bg-background/60",children:y?"Connected":"Reconnecting"})]})]}),e.jsx("div",{className:"min-h-0 flex-1",children:e.jsx(hn,{events:k,maxHeight:"100%",emptyTitle:r==="all"?"No live events yet":"No matching events",emptyDescription:r==="all"?"Cluster activity appears here as it happens.":`No "${r}" events are in the current stream.`,nodeNameById:n})})]})})]})})}function At({node:s,systemInfo:a,blockingTaskCount:n,devTunnelNodeId:o,onToggleNodeDevTunnel:r,showActions:i=!0,defaultExpanded:x=!1}){const[k,y]=t.useState(x),N=(a==null?void 0:a.dashboardOrigin)??s.dashboardOrigin,w=s.devtunnelEndpoint??s.endpoint,d=N??s.endpoint,u=(a==null?void 0:a.workDir)??s.workDir,b=aa(s,a==null?void 0:a.transportType),j=Zs(s,a==null?void 0:a.transportType),f=j&&Ye((a==null?void 0:a.transportType)??s.transportType)?!0:ta(s,a==null?void 0:a.transportType),L=n>0;return e.jsxs("section",{className:"rounded-[22px] border border-primary/20 bg-primary/8 shadow-[0_24px_80px_-60px_hsl(var(--primary)/0.9)]",children:[e.jsxs("button",{type:"button",onClick:()=>y(_=>!_),className:"w-full px-3 py-2 text-left",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[k?e.jsx(Ke,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):e.jsx(ss,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx(Ht,{status:s.status}),e.jsx("span",{className:"text-[11px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:"Current node"}),e.jsx("a",{href:d,target:"_blank",rel:"noreferrer",onClick:_=>_.stopPropagation(),className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-primary",title:"Open Dashboard",children:e.jsx(Kt,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5 pl-6",children:[e.jsx("span",{className:"text-[11px] font-semibold tracking-tight text-foreground",children:s.name}),e.jsx(qt,{role:s.role}),e.jsx(Ae,{variant:"outline",className:"rounded-[11px] border-primary/30 bg-background/60 text-[10px] capitalize",children:s.status})]})]}),k&&e.jsxs("div",{className:"space-y-3 border-t border-primary/15 px-3 pb-3 pt-2.5",children:[e.jsxs("div",{className:"space-y-2 rounded-[16px] border border-primary/20 bg-background/72 px-2 py-2 shadow-sm",children:[e.jsx(Re,{label:"Node ID",value:s.id,mono:!0}),N&&e.jsx(Re,{label:"Dashboard",value:N,mono:!0,action:e.jsx(as,{label:"Copy dashboard URL",onClick:()=>void Ge(N,"Dashboard URL copied")})}),e.jsx(Re,{label:"Node URL",value:w,mono:!0,action:e.jsx(as,{label:"Copy node URL",onClick:()=>void Ge(w,"Node URL copied")})}),u&&e.jsx(Re,{label:"Workspace",value:u,mono:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-1.5",children:[e.jsx(Fs,{label:"Transport",value:b}),a&&e.jsx(Fs,{label:"Uptime",value:pn(a.uptime),mono:!0})]}),e.jsx(Yt,{capabilities:s.capabilities,action:i&&f?e.jsxs(O,{variant:"outline",size:"sm",onClick:()=>r(s),disabled:o===s.id||L,className:"h-7 rounded-[12px] px-2.5 text-[11px]",title:L?"Finish assigned or running tasks before changing remote access":void 0,children:[o===s.id&&e.jsx(be,{className:"h-3.5 w-3.5 animate-spin"}),j?"Disable Remote Access":"Enable Remote Access"]}):void 0}),i&&f&&L&&e.jsxs("div",{className:"text-[11px] text-muted-foreground",children:[n," active task",n===1?"":"s"," on this node."]})]})]})}function Go({node:s,isLeader:a,blockingTaskCount:n,devTunnelNodeId:o,onToggleNodeDevTunnel:r}){const[i,x]=t.useState(!1),k=s.dashboardOrigin,y=s.devtunnelEndpoint??s.endpoint,N=k??s.endpoint,w=aa(s),d=Zs(s),u=ta(s),b=n>0;return e.jsxs("div",{className:"rounded-[18px] border border-border/60 bg-background/50 shadow-sm",children:[e.jsxs("button",{type:"button",onClick:()=>x(j=>!j),className:"w-full px-3 py-2 text-left",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[i?e.jsx(Ke,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):e.jsx(ss,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx(Ht,{status:s.status}),e.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:"Peer node"}),e.jsx("a",{href:N,target:"_blank",rel:"noreferrer",onClick:j=>j.stopPropagation(),className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-primary",title:"Open Dashboard",children:e.jsx(Kt,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"mt-1 flex items-center gap-1.5 pl-5",children:[e.jsx("span",{className:"text-[11px] font-semibold text-foreground",children:s.name}),e.jsx(qt,{role:s.role}),e.jsx(Ae,{variant:"outline",className:"rounded-[11px] border-border/70 bg-background/60 text-[10px] capitalize",children:s.status})]})]}),i&&e.jsxs("div",{className:"space-y-3 border-t border-border/50 px-3 pb-3 pt-2.5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{label:"Node ID",value:s.id,mono:!0}),k&&e.jsx(Re,{label:"Dashboard",value:k,mono:!0,action:e.jsx(as,{label:"Copy dashboard URL",onClick:()=>void Ge(k,"Dashboard URL copied")})}),e.jsx(Re,{label:"Node URL",value:y,mono:!0,action:e.jsx(as,{label:"Copy node URL",onClick:()=>void Ge(y,"Node URL copied")})}),s.workDir&&e.jsx(Re,{label:"Workspace",value:s.workDir,mono:!0}),e.jsx(Fs,{label:"Transport",value:w})]}),e.jsx(Yt,{capabilities:s.capabilities,action:a&&u?e.jsxs(O,{variant:"outline",size:"sm",onClick:()=>r(s),disabled:o===s.id||b,className:"h-7 rounded-[12px] px-2.5 text-[11px]",title:b?"Finish assigned or running tasks before changing remote access":void 0,children:[o===s.id&&e.jsx(be,{className:"h-3.5 w-3.5 animate-spin"}),d?"Disable Remote Access":"Enable Remote Access"]}):void 0}),a&&u&&b&&e.jsxs("div",{className:"text-[11px] text-muted-foreground",children:[n," active task",n===1?"":"s"," on this node."]})]})]})}function as({label:s,onClick:a}){return e.jsx(O,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 rounded-[12px] text-muted-foreground",onClick:a,"aria-label":s,title:s,children:e.jsx(It,{className:"h-3.5 w-3.5"})})}function Jo(s,a,n,o){var x;if(!s)return{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Select a task to continue the conversation."};const r=((x=a==null?void 0:a.self)==null?void 0:x.role)==="follower";return s.assignedTo!==null&&s.assignedNodeAvailable===!1?{taskUnavailable:!0,chatDisabled:!0,chatDisabledReason:`${s.assignedNodeName??"Assigned node"} is unavailable. Leave the cluster on that node or re-run the task elsewhere.`}:r?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Follower nodes are read-only. Use the leader dashboard to manage chat, or leave the cluster first."}:n||o?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Waiting for the current turn to finish..."}:hs.has(s.status)||s.status==="archived"?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:hs.has(s.status)?"Task has not started yet...":"Archived tasks are read-only."}:{taskUnavailable:!1,chatDisabled:!1,chatDisabledReason:"Continue the conversation..."}}function Mt({toolbarTasks:s,activeTaskId:a,tasksLoading:n,tasksError:o,isLeader:r,scope:i,agentFilter:x,nodeFilter:k,taskKindFilter:y,agentOptions:N,nodeOptions:w,nodeNameById:d,nodeStatusById:u,leaderNodeId:b,searchQuery:j,selectedTaskIds:f,allVisibleTasksSelected:L,someVisibleTasksSelected:_,canBatchArchive:R,onSearchChange:Y,onScopeChange:ee,onAgentFilterChange:$,onNodeFilterChange:ue,onTaskKindFilterChange:D,onToggleTaskSelected:K,onToggleAllVisibleTasks:A,onBatchArchive:I,onBatchDelete:S,onCreateTask:U,onSelectTask:oe,onClose:B}){const[C,se]=t.useState(!!j),[ie,te]=t.useState(!1),[H,X]=t.useState(!1),q=t.useRef(null),ae=t.useRef(null),le=t.useRef(null),c=f.size,P=i!=="active"||k!=="all"||x!=="all"||y!=="all",v=j.trim().length>0,[J,h]=t.useState(new Set),[re,V]=t.useState(new Set),xe=t.useMemo(()=>fn(s,d,b),[s,d,b]),m=xe.length===1,T=!m||P||v,W=m&&(P||v),Ne=t.useCallback(g=>{h(ke=>{const ne=new Set(ke);return ne.has(g)?ne.delete(g):ne.add(g),ne})},[]),we=t.useCallback(g=>{V(ke=>{const ne=new Set(ke);return ne.has(g)?ne.delete(g):ne.add(g),ne})},[]);return t.useEffect(()=>{j&&se(!0)},[j]),t.useEffect(()=>{var g;C&&((g=q.current)==null||g.focus())},[C]),t.useEffect(()=>{if(!C)return;const g=ne=>{var z;const F=ne.target;F instanceof Node&&((z=ae.current)!=null&&z.contains(F)||se(!1))},ke=ne=>{ne.key==="Escape"&&se(!1)};return document.addEventListener("mousedown",g),document.addEventListener("keydown",ke),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",ke)}},[C]),t.useEffect(()=>{if(!H)return;const g=ne=>{var z;const F=ne.target;F instanceof Node&&((z=le.current)!=null&&z.contains(F)||X(!1))},ke=ne=>{ne.key==="Escape"&&X(!1)};return document.addEventListener("mousedown",g),document.addEventListener("keydown",ke),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",ke)}},[H]),e.jsxs("aside",{className:"dashboard-panel dashboard-panel-muted animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-[28px]",children:[e.jsxs("div",{className:"shrink-0 border-b border-border/55 bg-card/24 px-3 py-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-1.5",children:[e.jsx("div",{className:"text-lg font-semibold tracking-tight text-foreground",children:"Tasks"}),e.jsx(O,{variant:"ghost",size:"icon",onClick:B,className:"rounded-[12px]",children:e.jsx(Zt,{className:"h-4 w-4"})})]}),e.jsxs("div",{ref:ae,className:"mt-4 flex items-center gap-1.5",children:[e.jsxs("div",{ref:le,className:M("relative flex items-stretch transition-[flex] duration-200",C?"flex-[2]":"flex-1"),children:[e.jsxs(O,{onClick:()=>{X(!1),U("chat")},className:"h-11 flex-1 justify-start rounded-l-[18px] rounded-r-none px-3 text-left shadow-[0_18px_48px_-30px_hsl(var(--primary)/0.95)]",children:[e.jsx(Xs,{className:"h-4 w-4"}),"New chat"]}),e.jsx(O,{onClick:()=>X(g=>!g),"aria-label":"More chat options","aria-haspopup":"menu","aria-expanded":H,className:"h-11 w-9 rounded-l-none rounded-r-[18px] border-l border-primary-foreground/20 px-0 shadow-[0_18px_48px_-30px_hsl(var(--primary)/0.95)]",children:e.jsx(Ke,{className:M("h-3.5 w-3.5 transition-transform",H&&"rotate-180")})}),H&&e.jsx("div",{role:"menu",className:"absolute left-0 right-0 top-full z-20 mt-2 overflow-hidden rounded-[18px] border border-border/60 bg-popover/96 p-1 shadow-[0_20px_60px_-30px_rgba(0,0,0,0.45)] backdrop-blur-xl",children:e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{X(!1),U("native")},className:"flex w-full items-center gap-1.5 rounded-[13px] px-2 py-2 text-left text-[11px] font-medium text-foreground transition-colors hover:bg-muted/80",children:[e.jsx(Ys,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{className:"flex-1 truncate whitespace-nowrap",children:"Load session"}),e.jsx("span",{className:"shrink-0 text-[9px] uppercase tracking-[0.18em] text-muted-foreground",children:"native"})]})})]}),C?e.jsxs("div",{className:"flex min-w-0 flex-[3] items-center gap-1.5",children:[e.jsxs("div",{className:"relative min-w-0 flex-1",children:[e.jsx(Bs,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(Fe,{ref:q,value:j,onChange:g=>Y(g.target.value),placeholder:"Search tasks",className:"h-11 rounded-[18px] border-border/70 bg-background/68 pl-11 text-[11px]"})]}),e.jsx(O,{variant:"outline",size:"icon",onClick:()=>se(!1),className:"rounded-[14px] border-border/70 bg-background/68",children:e.jsx(ms,{className:"h-4 w-4"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(O,{variant:"outline",onClick:()=>se(!0),className:M("rounded-[14px] border-border/70 bg-background/68 px-3 text-[11px]",j&&"border-primary/40 bg-primary/8 text-primary"),children:[e.jsx(Bs,{className:"h-4 w-4"}),"Search"]}),e.jsx(O,{variant:ie||P?"secondary":"outline",size:"icon",onClick:()=>te(g=>!g),className:M("shrink-0 rounded-[14px] border-border/70 bg-background/68",P&&"border-primary/40 bg-primary/8 text-primary"),title:"Filters",children:e.jsx(fr,{className:"h-4 w-4"})})]})]}),(ie||P)&&e.jsxs("div",{className:"mt-2 grid grid-cols-1 gap-1.5 sm:grid-cols-2",children:[e.jsxs(Se,{value:i,onValueChange:g=>ee(g),children:[e.jsx(Ce,{className:"h-7 rounded-[13px] border-border/70 bg-background/60 text-[12px]",children:e.jsx(Me,{})}),e.jsx(Te,{children:gn.map(g=>e.jsx(ge,{value:g.value,className:"text-[12px]",children:g.label},g.value))})]}),e.jsxs(Se,{value:k,onValueChange:ue,children:[e.jsx(Ce,{className:"h-7 rounded-[13px] border-border/70 bg-background/60 text-[12px]",children:e.jsx(Me,{placeholder:"Node"})}),e.jsx(Te,{children:w.map(g=>e.jsx(ge,{value:g.value,className:"text-[12px]",children:g.label},g.value))})]}),e.jsxs(Se,{value:x,onValueChange:$,children:[e.jsx(Ce,{className:"h-7 rounded-[13px] border-border/70 bg-background/60 text-[12px]",children:e.jsx(Me,{placeholder:"Agent"})}),e.jsx(Te,{children:N.map(g=>e.jsx(ge,{value:g,className:"text-[12px]",children:g==="all"?"All agents":g},g))})]}),e.jsxs(Se,{value:y,onValueChange:g=>D(g),children:[e.jsx(Ce,{className:"h-7 rounded-[13px] border-border/70 bg-background/60 text-[12px]",children:e.jsx(Me,{placeholder:"Type"})}),e.jsx(Te,{children:bn.map(g=>e.jsx(ge,{value:g.value,className:"text-[12px]",children:g.label},g.value))})]})]})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-2 py-2",children:xe.length>0?e.jsxs("div",{className:"space-y-1",children:[r&&e.jsxs("div",{className:"mb-1 flex items-center justify-between px-1 py-1",children:[e.jsxs("label",{className:"flex items-center gap-1.5 text-[11px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:[e.jsx(pt,{checked:_&&!L?"indeterminate":L,onCheckedChange:g=>A(g===!0),"aria-label":"Select all visible tasks"}),e.jsx("span",{children:"Select all"})]}),c>0&&e.jsx(O,{variant:"ghost",size:"sm",onClick:()=>A(!1),className:"h-7 rounded-[12px] px-2 text-[11px]",children:"Clear"})]}),xe.map(g=>{const ke=g.nodeId??"__unassigned__",ne=T&&!W&&J.has(ke),F=g.nodeId!==null&&u.get(g.nodeId)==="offline";return e.jsxs("div",{className:"space-y-1",children:[T&&e.jsxs("button",{type:"button",onClick:()=>Ne(ke),"aria-expanded":!ne,className:"flex w-full items-center gap-1.5 rounded-[15px] bg-gradient-to-r from-primary/8 to-muted/20 px-2 py-1.5 text-left text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground transition-all duration-150 hover:from-primary/12 hover:to-muted/30 hover:text-foreground active:scale-[0.99] active:from-primary/15",children:[e.jsx(ss,{className:M("h-3.5 w-3.5 shrink-0 transition-transform duration-200",!ne&&"rotate-90")}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:g.nodeName}),e.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:[F&&e.jsx(Ae,{variant:"outline",className:"rounded-[8px] border-destructive/25 bg-destructive/10 px-1 py-0 text-[8px] font-semibold leading-3 text-destructive shadow-none",children:"offline"}),g.nodeId===b&&e.jsx(Ae,{variant:"outline",className:"rounded-[9px] border-primary/25 bg-primary/8 px-1.5 py-0 text-[9px] font-semibold leading-4 text-primary shadow-none",children:"leader"}),e.jsx("span",{className:"tabular-nums text-muted-foreground/60",children:g.dirs.reduce((z,me)=>z+me.tasks.length,0)})]})]}),e.jsx("div",{className:M("grid transition-[grid-template-rows] duration-300 ease-in-out",ne?"grid-rows-[0fr]":"grid-rows-[1fr]"),children:e.jsx("div",{className:"overflow-hidden",children:g.dirs.map(z=>{const me=`${ke}::${z.path}`,Ee=re.has(me),Ie=vn(z.path);return e.jsxs("div",{className:M("space-y-0.5 rounded-xl",T&&"pl-3"),children:[e.jsxs("button",{type:"button",onClick:()=>we(me),"aria-expanded":!Ee,title:z.path,className:"flex w-full items-center gap-1.5 rounded-[12px] bg-muted/15 px-2 py-1 text-left text-[10px] font-medium text-muted-foreground/70 transition-all duration-150 hover:bg-muted/30 hover:text-foreground active:scale-[0.98] active:bg-muted/40",children:[e.jsx(ss,{className:M("h-3 w-3 shrink-0 transition-transform duration-200",!Ee&&"rotate-90")}),e.jsx("span",{className:"truncate font-mono",children:Ie}),e.jsx("span",{className:"ml-auto shrink-0 tabular-nums text-muted-foreground/40",children:z.tasks.length})]}),e.jsx("div",{className:M("grid transition-[grid-template-rows] duration-300 ease-in-out",Ee?"grid-rows-[0fr]":"grid-rows-[1fr]"),children:e.jsx("div",{className:M("overflow-hidden",T?"pl-2":"pl-0"),children:e.jsx("div",{className:"space-y-1.5 border-l border-border/35 py-1 pl-2.5 ml-1.5",children:z.tasks.map(G=>e.jsxs("div",{className:M("flex items-center gap-1.5 rounded-[18px] border px-2.5 py-1.5 transition-all duration-200","hover:-translate-y-px",G.id===a?"border-primary/45 bg-primary/9 shadow-[0_24px_80px_-54px_hsl(var(--primary)/0.95)]":"border-border/58 bg-background/46 hover:border-border hover:bg-background/70 hover:shadow-[0_10px_28px_-18px_rgba(0,0,0,0.35)]"),children:[r&&e.jsx("div",{className:"flex shrink-0",onClick:Be=>Be.stopPropagation(),children:e.jsx(pt,{checked:f.has(G.id),onCheckedChange:Be=>K(G.id,Be===!0),"aria-label":`Select ${G.title}`})}),e.jsxs("button",{type:"button",onClick:()=>oe(G.id),className:"min-w-0 flex-1 text-left",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:M("h-1.5 w-1.5 shrink-0 rounded-full",jn(G.status),(G.status==="running"||G.status==="assigned")&&"animate-soft-status-pulse")}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:G.title}),e.jsx("span",{className:"ml-1 shrink-0 tabular-nums text-[10px] text-muted-foreground/55",children:Nn(G.updatedAt)})]}),e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-1 pl-3",children:[e.jsx(Ut,{status:G.status}),e.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/60",children:G.agent}),G.conversationKind==="nativeSession"&&e.jsx(Ae,{variant:"outline",className:"border-sky-500/25 bg-sky-500/10 text-[10px] text-sky-700 dark:text-sky-300",children:"native"}),G.activeShare&&e.jsx(Ae,{variant:"outline",className:"border-primary/25 bg-primary/10 text-[10px] text-primary",children:"shared"}),G.assignedNodeAvailable===!1&&e.jsx(Ae,{variant:"outline",className:"border-destructive/25 bg-destructive/10 text-[10px] text-destructive",children:"unavailable"})]})]})]},G.id))})})})]},me)})})})]},ke)})]}):n?e.jsx("div",{className:"space-y-2 px-1",children:[1,2,3].map(g=>e.jsx("div",{className:"rounded-[24px] border border-border/40 bg-background/30 px-3 py-3",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"mt-1 h-2.5 w-2.5 shrink-0 animate-pulse rounded-full bg-muted-foreground/20"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("div",{className:"h-2.5 animate-pulse rounded-full bg-muted-foreground/15",style:{width:`${60+g*12}%`,animationDelay:`${g*120}ms`}}),e.jsx("div",{className:"h-2 w-24 animate-pulse rounded-full bg-muted-foreground/10",style:{animationDelay:`${g*120+60}ms`}})]})]})},g))}):e.jsx("div",{className:"rounded-[24px] border border-dashed border-border/70 bg-background/35 px-3 py-5 text-[11px] text-muted-foreground",children:o||"No tasks match this view."})}),r&&c>0?e.jsxs("div",{className:"shrink-0 border-t border-border/60 px-3 py-3",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.22em] text-muted-foreground",children:"Batch actions"}),e.jsxs("div",{className:"mt-2 text-[11px] font-semibold text-foreground",children:[c," task",c!==1?"s":""," selected"]}),!R&&e.jsx("div",{className:"mt-2 text-[11px] text-muted-foreground",children:"Only completed, failed, cancelled, or archived tasks can be archived."}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-1.5",children:[e.jsxs(_s,{children:[e.jsx(ft,{asChild:!0,children:e.jsxs(O,{variant:"outline",size:"sm",disabled:!R,className:"rounded-[14px]",children:[e.jsx(cr,{className:"h-3.5 w-3.5"}),"Archive"]})}),e.jsxs(Ds,{children:[e.jsxs(As,{children:[e.jsxs(Ms,{children:["Archive ",c," task",c!==1?"s":"","?"]}),e.jsx(Ls,{children:"Archived tasks stay hidden from the default task view and can be reopened from the archived scope."})]}),e.jsxs(Ps,{children:[e.jsx(Rs,{children:"Cancel"}),e.jsx($s,{onClick:I,disabled:!R,children:"Archive"})]})]})]}),e.jsxs(_s,{children:[e.jsx(ft,{asChild:!0,children:e.jsxs(O,{variant:"destructive",size:"sm",className:"rounded-[14px]",children:[e.jsx(Hr,{className:"h-3.5 w-3.5"}),"Delete"]})}),e.jsxs(Ds,{children:[e.jsxs(As,{children:[e.jsxs(Ms,{children:["Delete ",c," task",c!==1?"s":"","?"]}),e.jsx(Ls,{children:"This removes the selected tasks and their saved logs."})]}),e.jsxs(Ps,{children:[e.jsx(Rs,{children:"Cancel"}),e.jsx($s,{onClick:S,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})]}):null]})}async function Yo(s,a){var n,o;try{const r=await kn(s,a);if((o=(n=globalThis.navigator)==null?void 0:n.clipboard)!=null&&o.writeText)try{await globalThis.navigator.clipboard.writeText(r.url),pe.success("Shared link copied")}catch{pe.success("Shared link created")}else pe.success("Shared link created");return r}catch(r){pe.error(r instanceof Error?r.message:"Failed to create shared link");return}}async function Xo(s){try{return await wn(s),pe.success("Shared link stopped"),!0}catch(a){return pe.error(a instanceof Error?a.message:"Failed to stop shared link"),!1}}function Qo(s,a,n){const o=t.useCallback(()=>{a(),n()},[a,n]),r=t.useCallback(async x=>{if(!s)return;const k=await Yo(s.id,x);return k&&o(),k},[s,o]),i=t.useCallback(async()=>{if(!s)return!1;const x=await Xo(s.id);return x&&o(),x},[s,o]);return{handleShareTask:r,handleStopShareTask:i}}function Lt(s,a,n){const o=t.useRef(a);o.current=a,t.useEffect(()=>{let x=0,k=0;const y=d=>{const u=d.touches[0];u&&(x=u.clientX,k=u.clientY)},N=d=>{var f,L,_,R;const u=d.changedTouches[0];if(!u)return;const b=u.clientX-x;Math.abs(u.clientY-k)>100||Math.abs(b)<50||(b>0?(L=(f=o.current).onSwipeRight)==null||L.call(f):(R=(_=o.current).onSwipeLeft)==null||R.call(_))},w=(s==null?void 0:s.current)??document;return w.addEventListener("touchstart",y,{passive:!0}),w.addEventListener("touchend",N,{passive:!0}),()=>{w.removeEventListener("touchstart",y),w.removeEventListener("touchend",N)}},[s,n==null?void 0:n.threshold,n==null?void 0:n.maxVertical])}const Zo="(min-width: 1024px)",ei="(min-width: 1800px)";function Pt(s){var a,n,o;return((o=(n=(a=globalThis.window)==null?void 0:a.matchMedia)==null?void 0:n.call(a,s))==null?void 0:o.matches)??!1}function si(){const[s,a]=t.useState(!0),[n,o]=t.useState(!1),[r,i]=t.useState(()=>Pt(ei)),x=t.useRef(null),k=t.useRef(null);Lt(x,{onSwipeLeft:()=>o(!1)}),Lt(k,{onSwipeRight:()=>i(!1)});const y=t.useCallback(()=>{if(Pt(Zo)){a(N=>!N);return}o(N=>!N)},[]);return{desktopTasksOpen:s,mobileTasksPanelOpen:n,mobileTasksPanelRef:x,operationsOpen:r,operationsPanelRef:k,setMobileTasksPanelOpen:o,setOperationsOpen:i,toggleTasksPanel:y}}function ti(s,a){const n=a.taskId,o=a.updates;return typeof n!="string"||!o||typeof o!="object"?s:s.map(r=>r.id===n?{...r,...o}:r)}function ai({isLeader:s,selfId:a}){return{assignedTo:!s&&a?a:void 0}}function ni({isLeader:s,selfId:a,sseConnected:n,subscribe:o}){const[r,i]=t.useState([]),[x,k]=t.useState(!0),[y,N]=t.useState(null),w=t.useRef(null),d=t.useCallback(async()=>{try{const b=await yn(ai({isLeader:s,selfId:a}));i(b),N(null)}catch(b){N(b instanceof Error?b.message:"Failed to load tasks")}finally{k(!1)}},[s,a]),u=t.useCallback(()=>{w.current===null&&(w.current=window.setTimeout(()=>{w.current=null,d()},Sn))},[d]);return Cn(d,_n(n)),t.useEffect(()=>()=>{w.current!==null&&(window.clearTimeout(w.current),w.current=null)},[]),t.useEffect(()=>{const b=[o("task.updated",j=>{i(f=>ti(f,j.data))}),o("task.status",j=>{i(f=>Tn(f,j.data))}),o("task",j=>{En(j.type)&&u()})];return()=>b.forEach(j=>j())},[o,u]),{fetchTasks:d,setTasks:i,tasks:r,tasksError:y,tasksLoading:x}}function ri(s,a){return a.data.nodeId===s.self.id||a.data.name===s.self.name||a.data.endpoint===s.self.endpoint}function oi({cluster:s,subscribe:a}){t.useEffect(()=>{var n;if(((n=s==null?void 0:s.self)==null?void 0:n.role)==="leader")return a("node",o=>{const r=String(o.data.name??o.data.nodeId??"node"),i=ri(s,o);o.type==="node.joined"&&!i&&pe.success(`${r} joined the cluster`),o.type==="node.left"&&!i&&pe.message(`${r} left the cluster`)})},[s,a])}const ii=[0,300,1e3,2e3];function li({task:s,getActiveTaskId:a,setLogs:n,setPendingMessages:o}){s.conversationKind==="nativeSession"&&(async()=>{for(const r of ii){if(r>0&&await new Promise(i=>setTimeout(i,r)),a()!==s.id)return;try{const i=await Wt(s.id);if(a()!==s.id||(n(x=>Xt(x,i.logs)),o(x=>Qt(x,i.logs)),i.total>0))return}catch{}}})()}function di(){var ot,it,lt,dt,ct,ut;const{id:s}=Dn(),a=An(),n=Mn(),o=Ln(),{cluster:r,systemInfo:i,events:x,sseConnected:k,subscribe:y,refresh:N,loading:w,error:d}=Pn(),u=t.useMemo(()=>Rn(a.state),[a.state]),[b,j]=t.useState(null),[f,L]=t.useState("active"),[_,R]=t.useState("all"),[Y,ee]=t.useState("all"),[$,ue]=t.useState("all"),[D,K]=t.useState(""),A=t.useDeferredValue(D),{desktopTasksOpen:I,mobileTasksPanelOpen:S,mobileTasksPanelRef:U,operationsOpen:oe,operationsPanelRef:B,setMobileTasksPanelOpen:C,setOperationsOpen:se,toggleTasksPanel:ie}=si(),[te,H]=t.useState(()=>!!(u!=null&&u.draftNewTask)),[X,q]=t.useState(()=>(u==null?void 0:u.createMode)??"chat"),[ae,le]=t.useState(()=>u!=null&&u.draftNewTask?{route:u.returnRoute??"/",taskId:u.returnTaskId??null}:null),[c,P]=t.useState(!1),[v,J]=t.useState("transcript"),[h,re]=t.useState("all"),[V,xe]=t.useState(!1),[m,T]=t.useState(null),[W,Ne]=t.useState([]),[we,g]=t.useState([]),[ke,ne]=t.useState(!1),[F,z]=t.useState(null),[me,Ee]=t.useState(new Set),[Ie,G]=t.useState(!1),[Be,rs]=t.useState(!1),[os,Xe]=t.useState(null),Qe=t.useRef(null),$e=t.useRef(null),Oe=((ot=r==null?void 0:r.self)==null?void 0:ot.role)==="leader",fs=(it=r==null?void 0:r.self)==null?void 0:it.id;oi({cluster:r,subscribe:y});const{fetchTasks:de,setTasks:ve,tasks:ye,tasksError:Ze,tasksLoading:gs}=ni({isLeader:Oe,selfId:fs,sseConnected:k,subscribe:y}),je=t.useMemo(()=>[...ye].sort((l,p)=>p.updatedAt-l.updatedAt),[ye]),pa=t.useMemo(()=>{const l=new Map;for(const p of(r==null?void 0:r.nodes)??[]){const E=qr(je,p.id);E>0&&l.set(p.id,E)}return l},[r==null?void 0:r.nodes,je]),Pe=t.useMemo(()=>je.filter(l=>!$n(l,r==null?void 0:r.nodes,r==null?void 0:r.self)||!Fn(l,f)||_!=="all"&&l.agent!==_||!On(l,$)||Y==="unassigned"&&l.assignedTo||Y!=="all"&&Y!=="unassigned"&&In(l.assignedTo,r==null?void 0:r.nodes,l.assignedNodeName)!==Y?!1:A.trim()?Bn(l,A):!0),[je,r==null?void 0:r.nodes,r==null?void 0:r.self,f,_,$,Y,A]);t.useEffect(()=>{Ee(l=>{const p=Xr(l,Pe.map(E=>E.id));return p.size===l.size?l:p})},[Pe]),t.useEffect(()=>{Oe||Ee(new Set)},[Oe]);const fa=t.useMemo(()=>["all",...Array.from(new Set(je.map(l=>l.agent))).sort()],[je]),ga=t.useMemo(()=>{const p=Array.from(new Set(je.map(E=>E.assignedTo).filter(E=>!!E))).map(E=>{const he=je.find(Z=>Z.assignedTo===E);return(r==null?void 0:r.nodes.find(Z=>Z.id===E))??{id:E,name:Bt(E,r==null?void 0:r.nodes,he==null?void 0:he.assignedNodeName)}}).sort((E,he)=>E.name.localeCompare(he.name));return[{value:"all",label:"All nodes"},{value:"unassigned",label:"Unassigned"},...p.map(E=>({value:E.name.toLowerCase(),label:E.name}))]},[je,r==null?void 0:r.nodes]),st=t.useMemo(()=>{const l=new Map;for(const p of(r==null?void 0:r.nodes)??[])l.set(p.id,p.name);for(const p of je)p.assignedTo&&p.assignedNodeName&&!l.has(p.assignedTo)&&l.set(p.assignedTo,p.assignedNodeName);return l},[r==null?void 0:r.nodes,je]),ba=t.useMemo(()=>{const l=new Map;for(const p of(r==null?void 0:r.nodes)??[])l.set(p.id,p.status);return r!=null&&r.self&&l.set(r.self.id,r.self.status),l},[r]),tt=t.useMemo(()=>{const l=new Map;for(const p of(r==null?void 0:r.nodes)??[])p.status!=="offline"&&l.set(p.id,p);return r!=null&&r.self&&r.self.status!=="offline"&&l.set(r.self.id,r.self),Array.from(l.values())},[r]),va=((lt=r==null?void 0:r.self)==null?void 0:lt.id)??((dt=tt[0])==null?void 0:dt.id)??null,bs=t.useMemo(()=>["all",...Array.from(new Set(x.map(l=>l.type))).sort()],[x]),ja=t.useMemo(()=>h==="all"?x:x.filter(l=>l.type===h),[x,h]),Na=Pe.length>0&&Pe.every(l=>me.has(l.id)),ka=Pe.some(l=>me.has(l.id)),wa=Qr(Pe,me);t.useEffect(()=>{u!=null&&u.draftNewTask&&(H(!0),le({route:u.returnRoute??"/",taskId:u.returnTaskId??null}))},[u]),t.useEffect(()=>{h!=="all"&&!bs.includes(h)&&re("all")},[h,bs]),t.useEffect(()=>{kt(s,te)&&!b&&je[0]&&j(je[0].id)},[s,te,b,je]),t.useEffect(()=>{var l;kt(s,te)&&(b&&ye.some(p=>p.id===b)||j(((l=je[0])==null?void 0:l.id)??null))},[s,te,b,je,ye]);const ce=Gr({routeTaskId:s,creatingTask:te,internalSelectedTaskId:b,sortedTaskIds:je.map(l=>l.id)}),qe=t.useMemo(()=>ye.find(l=>l.id===ce)??null,[ye,ce]);t.useEffect(()=>{$e.current=ce??null},[ce]);const is=t.useCallback(()=>{T(null),Ne([]),g([]),z(null)},[]),De=t.useCallback(async()=>{const l=ce;if(l)try{const p=await zn(l);if($e.current!==l)return;T(p),z(null)}catch(p){if($e.current!==l)return;T(null),Ne([]),g([]),z(p instanceof Error?p.message:"Failed to load task")}finally{$e.current===l&&ne(!1)}},[ce]),ls=t.useCallback(async()=>{const l=ce;if(l)try{const p=await Wt(l);if($e.current!==l)return;Ne(E=>Xt(E,p.logs)),g(E=>Qt(E,p.logs))}catch{}},[ce]);t.useEffect(()=>{if(!ce){T(null),Ne([]),g([]),z(null),ne(!1);return}J("transcript"),T(qe),Ne([]),g([]),z(null),ne(!0),De(),ls()},[ce,ls,De]),t.useEffect(()=>{var p;if(!ce||te||gs||ye.some(E=>E.id===ce))return;const l=((p=je[0])==null?void 0:p.id)??null;j(l),is(),t.startTransition(()=>{n(l?`/tasks/${l}`:"/",{state:null})})},[ce,is,te,n,je,ye,gs]),t.useEffect(()=>{qe&&T(l=>!l||l.id!==qe.id?l:{...l,...qe})},[qe]),t.useEffect(()=>{if(ce)return y("task",l=>{const p=l.data.taskId;if(!(typeof p!="string"||p!==ce)){if(l.type==="task.output"){const E=l.data.event;if(E){Ne(Z=>sr(Z,E));const he=vt(E);he&&g(Z=>tr(Z,he))}}l.type==="task.updated"&&De(),l.type==="task.status"&&(De(),ls())}})},[y,ce,De,ls]),t.useEffect(()=>{var l;v==="transcript"&&((l=Qe.current)==null||l.scrollIntoView({behavior:"smooth"}))},[W,we,v]);const Q=m??qe,ya=Q!=null&&Q.assignedTo?(r==null?void 0:r.nodes.find(l=>l.id===Q.assignedTo))??null:null,vs=we.length>0,Sa=Q?Un.has(Q.agent):!1,js=(Q==null?void 0:Q.status)==="running",Ca=Q?hs.has(Q.status):!1,Ta=Q?hs.has(Q.status)||Vn.has(Q.status):!1,Ea=!!(Q&&Oe&&Q.status==="failed"),Ns=t.useMemo(()=>Jo(Q,r,vs,!!js),[Q,r,vs,js]),ks=t.useMemo(()=>ar([...W,...we.map(l=>Ts(l.content,l.timestamp))]),[W,we]),ds=t.useMemo(()=>{if(!Q||Q.conversationKind==="nativeSession")return null;const l=nr(Q);if(l.length>0)return Ts(l,new Date(Q.createdAt).toISOString());if(ks.length>0)return null;const p=rr(Q.description||Q.title);return p.length>0?Ts(p,new Date(Q.createdAt).toISOString()):null},[Q,ks]),ws=t.useMemo(()=>ds?vt(ds):null,[ds]),_a=t.useMemo(()=>ws?or(W,ws):!1,[W,ws]),ys=t.useCallback((l="chat")=>{const p={route:s?`/tasks/${s}`:"/",taskId:ce};le(p),q(l),H(!0),t.startTransition(()=>{n("/",{state:{draftNewTask:!0,returnRoute:p.route,returnTaskId:p.taskId,createMode:l}})})},[s,ce,n]),Da=t.useCallback(()=>{var p;const l=(ae==null?void 0:ae.taskId)??((p=je[0])==null?void 0:p.id)??null;H(!1),le(null),j(l),t.startTransition(()=>{n((ae==null?void 0:ae.route)??"/",{state:null})})},[ae,je,n]),at=t.useCallback(l=>{H(!1),le(null),j(l),t.startTransition(()=>{n(`/tasks/${l}`,{state:null})})},[n]),Aa=t.useCallback(l=>{$e.current=l.id,H(!1),le(null),ve(p=>Jr(p,l)),T(l),Ne([]),g([]),z(null),ne(!1),J("transcript"),j(l.id),li({task:l,getActiveTaskId:()=>$e.current,setLogs:Ne,setPendingMessages:g}),de(),t.startTransition(()=>{n(`/tasks/${l.id}`,{state:null})})},[de,n]),cs=t.useCallback(async l=>{if(!ce)return!1;const p=`local-${Date.now()}-${Math.random().toString(16).slice(2)}`;g(E=>[...E,{id:p,content:l,timestamp:new Date().toISOString()}]);try{return await Hn(ce,l),De(),!0}catch(E){return g(he=>he.filter(Z=>Z.id!==p)),pe.error(E instanceof Error?E.message:"Failed to send message"),!1}},[ce,De]),Ma=t.useCallback(l=>{cs(l)},[cs]),La=t.useCallback(l=>cs(l),[cs]),Pa=t.useCallback(async()=>{if(Q)try{await Kn(Q.id),De(),de()}catch(l){pe.error(l instanceof Error?l.message:"Failed to cancel task")}},[Q,De,de]),{handleShareTask:Ra,handleStopShareTask:$a}=Qo(Q,De,de),Fa=t.useCallback(async()=>{if(Q)try{await qn(Q.id),De(),de()}catch(l){pe.error(l instanceof Error?l.message:"Failed to retry task")}},[Q,De,de]),us=t.useCallback((l,p=!1)=>{const E=Zr(Pe,l);return j(E),(p||!E)&&is(),t.startTransition(()=>{n(E?`/tasks/${E}`:"/",{state:null})}),E},[is,Pe,n]),Oa=t.useCallback((l,p)=>{Ee(E=>{const he=new Set(E);return p?he.add(l):he.delete(l),he})},[]),Ia=t.useCallback(l=>{if(!l){Ee(new Set);return}Ee(new Set(Pe.map(p=>p.id)))},[Pe]),Ba=t.useCallback(async()=>{const l=Array.from(me);if(l.length!==0)try{const{results:p}=await Wn(l),E=p.filter(Z=>!Z.ok),he=p.filter(Z=>Z.ok).map(Z=>Z.id);ce&&he.includes(ce)&&us(he),E.length>0?pe.error(`Failed to archive ${E.length} task(s): ${E.map(Z=>Z.error??Z.id).join(", ")}`):pe.success(`Archived ${he.length} task(s)`),Ee(new Set(E.map(Z=>Z.id))),de()}catch(p){pe.error(p instanceof Error?p.message:"Failed to archive tasks")}},[ce,de,us,me]),za=t.useCallback(async()=>{const l=Array.from(me);if(l.length!==0)try{const{results:p}=await Gn(l),E=p.filter(Z=>!Z.ok),he=p.filter(Z=>Z.ok).map(Z=>Z.id);ce&&he.includes(ce)&&us(he,!0),E.length>0?pe.error(`Failed to delete ${E.length} task(s): ${E.map(Z=>Z.error??Z.id).join(", ")}`):pe.success(`Deleted ${he.length} task(s)`),Ee(new Set(E.map(Z=>Z.id))),de()}catch(p){pe.error(p instanceof Error?p.message:"Failed to delete tasks")}},[ce,de,us,me]),Ua=t.useCallback(async()=>{G(!0);try{await Jn(),N()}catch(l){pe.error(l instanceof Error?l.message:"Failed to promote node")}finally{G(!1)}},[N]),Va=t.useCallback(async()=>{rs(!0);try{await Yn(),pe.success("This node left the remote cluster and is leading itself again."),de(),De(),N()}catch(l){pe.error(l instanceof Error?l.message:"Failed to leave cluster")}finally{rs(!1)}},[De,de,N]),Ha=t.useCallback(async l=>{var xt;const p=!Zs(l),E=l.id===((xt=r==null?void 0:r.self)==null?void 0:xt.id),he=E?(i==null?void 0:i.transportType)??l.transportType:l.transportType,Z=E&&!p&&Ye(he);Xe(l.id);try{Z?await Xn("direct"):await Qn(l.id,p),pe.success(p?`Enabled remote access on ${l.name}`:`Disabled remote access on ${l.name}`),N()}catch(mt){pe.error(mt instanceof Error?mt.message:"Failed to update remote access")}finally{Xe(null)}},[(ct=r==null?void 0:r.self)==null?void 0:ct.id,N,i==null?void 0:i.transportType]),nt={toolbarTasks:Pe,activeTaskId:ce,tasksLoading:gs,tasksError:Ze,isLeader:Oe,scope:f,agentFilter:_,nodeFilter:Y,taskKindFilter:$,agentOptions:fa,nodeOptions:ga,nodeNameById:st,nodeStatusById:ba,leaderNodeId:((ut=r==null?void 0:r.leader)==null?void 0:ut.id)??null,searchQuery:D,selectedTaskIds:me,allVisibleTasksSelected:Na,someVisibleTasksSelected:ka,canBatchArchive:wa,onSearchChange:K,onScopeChange:L,onAgentFilterChange:R,onNodeFilterChange:ee,onTaskKindFilterChange:ue,onToggleTaskSelected:Oa,onToggleAllVisibleTasks:Ia,onBatchArchive:Ba,onBatchDelete:za,onCreateTask:ys,onSelectTask:at,onClose:ie},rt={cluster:r,systemInfo:i,nodeNameById:st,nodeBlockingTaskCounts:pa,eventTypeFilter:h,onEventTypeFilterChange:re,eventTypeOptions:bs,filteredEvents:ja,sseConnected:k,clusterLoading:w,clusterError:d,promotePending:Ie,onPromote:Ua,onAddNode:()=>P(!0),leavePending:Be,onLeaveCluster:Va,onToggleNodeDevTunnel:Ha,devTunnelNodeId:os,onClose:()=>se(!1)};return e.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden pb-2",children:[e.jsxs("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:[e.jsx("div",{className:M("hidden lg:block lg:shrink-0 lg:transition-all lg:duration-300",I?"lg:mr-3 lg:w-[24rem]":"lg:w-0 lg:overflow-hidden"),children:I&&e.jsx(Mt,{...nt})}),e.jsxs("section",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-3",children:[e.jsx("div",{className:"min-h-0 flex-1",children:e.jsx(Oo,{onToggleTasks:ie,desktopTasksOpen:I,mobileTasksPanelOpen:S,operationsOpen:oe,onToggleOperations:()=>se(l=>!l),cluster:r,sseConnected:k,activeTab:v,setActiveTab:J,creatingTask:te,createMode:X,activeTask:Q,assignedNode:ya,taskLoading:ke,taskError:F,displayEvents:ks,initialPromptAlreadyInLogs:_a,initialPrompt:ds,supportsFollowUp:Sa,taskUnavailable:Ns.taskUnavailable,chatDisabled:Ns.chatDisabled,chatDisabledReason:Ns.chatDisabledReason,questionBypassEnabled:V,isRunning:!!js,isStarting:Ca,hasPendingFollowUp:vs,canCancel:!!Ta,canRetry:!!Ea,onRetry:Fa,onCancel:Pa,onShareTask:Ra,onStopShareTask:$a,onStartCreateTask:ys,onCancelCreateTask:Da,onCreateTask:Aa,onSendMessage:Ma,onQuestionBypassChange:xe,onSubmitQuestionResponse:La,messagesEndRef:Qe})}),(o==null?void 0:o.terminalOpen)&&e.jsx(Wo,{nodes:tt,defaultNodeId:va,onClose:()=>o==null?void 0:o.setTerminalOpen(!1)})]}),e.jsx("div",{className:M("hidden xl:block xl:shrink-0 xl:transition-all xl:duration-300",oe?"xl:ml-3 xl:w-[26rem]":"xl:w-0 xl:overflow-hidden"),children:oe&&e.jsx(Dt,{...rt})})]}),oe&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button","aria-label":"Close operations panel",onClick:()=>se(!1),className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm xl:hidden"}),e.jsx("div",{ref:B,className:"fixed inset-y-0 right-0 z-40 w-full p-2 sm:max-w-sm sm:p-3 xl:hidden",children:e.jsx(Dt,{...rt})})]}),S&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button","aria-label":"Close task list",onClick:()=>C(!1),className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm lg:hidden"}),e.jsx("div",{ref:U,className:"fixed inset-y-0 left-0 z-40 w-full p-2 sm:max-w-sm sm:p-3 lg:hidden",children:e.jsx(Mt,{...nt,onCreateTask:l=>{C(!1),ys(l)},onSelectTask:l=>{C(!1),at(l)},onClose:()=>C(!1)})})]}),e.jsx(Ot,{open:c,onOpenChange:P,children:e.jsx(no,{onAdded:()=>{P(!1),N()}})})]})}const hi=Object.freeze(Object.defineProperty({__proto__:null,DashboardPage:di},Symbol.toStringTag,{value:"Module"}));export{hi as D,jt as G};