cogpit 3.5.4 → 3.5.5
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.
- package/README.md +11 -5
- package/dist/cli-runtime.js +2916 -2294
- package/dist/cli.js +1 -1
- package/dist/instance-worker.js +510 -254
- package/dist/web/assets/AgentCheckDialog-DdcPaEtO.js +1 -0
- package/dist/web/assets/{AutomationsPanel-DTiDsq54.js → AutomationsPanel-DHA6W_CZ.js} +1 -1
- package/dist/web/assets/{CogpitBlock-Hk57z10V.js → CogpitBlock-CN0s_qTc.js} +15 -15
- package/dist/web/assets/CommandPaletteHost-D5mRzqIm.js +1 -0
- package/dist/web/assets/{ConfigBrowser-C77Ydij0.js → ConfigBrowser-CXxrxWWl.js} +1 -1
- package/dist/web/assets/{CrewPanel-BzEJLKMd.js → CrewPanel-DJM6YaDN.js} +1 -1
- package/dist/web/assets/{HighlightedEditor-D1S-wotA.js → HighlightedEditor-G-YJnadM.js} +1 -1
- package/dist/web/assets/KeyboardShortcutsDialog-CcyskXfr.js +1 -0
- package/dist/web/assets/MissionHome-o1MjTkAZ.js +2 -0
- package/dist/web/assets/{MobileFileChanges-DovO__Ap.js → MobileFileChanges-SeyE4VAV.js} +1 -1
- package/dist/web/assets/{PluginsDialog-o6ySRFLf.js → PluginsDialog-BPHFbLGS.js} +1 -1
- package/dist/web/assets/{PreviewPanel-kD79kXYD.js → PreviewPanel-Cb6P4TQ0.js} +1 -1
- package/dist/web/assets/{ProjectFilesPanel-CwEqOA2q.js → ProjectFilesPanel-BIEcyM9w.js} +3 -3
- package/dist/web/assets/{ProjectSwitcherModal-BnWbJWEX.js → ProjectSwitcherModal-CXI-isj1.js} +1 -1
- package/dist/web/assets/{TerminalOutput-DsK-7nR8.js → TerminalOutput-Cmf1kDEH.js} +1 -1
- package/dist/web/assets/{ThemeSelectorModal-D5SBWDm5.js → ThemeSelectorModal-DKvI2x91.js} +1 -1
- package/dist/web/assets/{WorkflowsPanel-NU49178V.js → WorkflowsPanel-B7bJ_vvB.js} +1 -1
- package/dist/web/assets/WorktreePanel-Bu2NThZy.js +1 -0
- package/dist/web/assets/{edition-ui-7WkqSCbs.js → edition-ui-CpK32xJF.js} +1 -1
- package/dist/web/assets/index-BYVl1VlW.js +515 -0
- package/dist/web/assets/{index-BgZ8qUzM.js → index-DUyjpORE.js} +2 -2
- package/dist/web/assets/index-N7rDyHyl.js +2 -0
- package/dist/web/assets/index-RGkLLDnk.css +1 -0
- package/dist/web/assets/{index-CevokSRq.js → index-TyUw7tBu.js} +2 -2
- package/dist/web/assets/index-lC5dVkKa.js +1 -0
- package/dist/web/assets/session-parser.worker-tdry_1oJ.js +43 -0
- package/dist/web/assets/{switch-DI9dp0Ya.js → switch-DFZA-ROd.js} +1 -1
- package/dist/web/assets/{vendor-ui-Dc_kJXxz.js → vendor-ui-B0az9ATE.js} +220 -200
- package/dist/web/index.html +4 -4
- package/package.json +1 -1
- package/dist/web/assets/CommandPaletteHost-BYfieK7H.js +0 -1
- package/dist/web/assets/KeyboardShortcutsDialog-B_DSi5JO.js +0 -1
- package/dist/web/assets/MissionHome-B3uYgylE.js +0 -2
- package/dist/web/assets/WorktreePanel-DPk5b1Os.js +0 -1
- package/dist/web/assets/index-Bg4A-xl7.js +0 -510
- package/dist/web/assets/index-C2tUYo8z.js +0 -1
- package/dist/web/assets/index-DIuobrPN.js +0 -2
- package/dist/web/assets/index-DMO9bL9w.css +0 -1
- package/dist/web/assets/session-parser.worker-DCsmYUeX.js +0 -41
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as G,j as t,r as o}from"./vendor-react-gGw_S5I_.js";import{by as ye,bN as Ce,c as F,aC as ke,ae as X,ac as q,aB as ve,aA as Z,au as ae,B as I,F as A,bO as Ne,bP as Se,bQ as we,bR as De,bS as Te,bT as Ee,bU as _,bV as Re,bW as ee,bX as Oe,k as te,aa as le,bY as Ie,a9 as ie,a5 as re,a3 as oe,a4 as ce,a7 as de,a6 as ue,a8 as me,x as ze,E as Ae,f as Le,U as Be,h as $e,i as Fe,b7 as Ge,az as Me,ax as ne,aw as Pe,ay as Ue,m as Ve,bZ as _e}from"./index-Bg4A-xl7.js";import{c0 as Ke,a3 as Qe,a5 as He,bt as Ye,dn as Je,U as We,dp as xe,aB as fe,dq as Xe,dr as qe,ds as K,X as Q,bg as Ze,cV as he,dt as et,b0 as tt,bQ as nt,ak as st,cN as at}from"./vendor-ui-Dc_kJXxz.js";import{H as lt}from"./HighlightedEditor-D1S-wotA.js";import"./vendor-markdown-BEJ8yVzA.js";const it={agent:"bg-muted text-muted-foreground",skill:"bg-muted text-muted-foreground",command:"bg-muted text-muted-foreground",instructions:"bg-muted text-muted-foreground",settings:"bg-muted text-muted-foreground"},rt={agents:{subdir:"agents",fileType:"agent"},skills:{subdir:"skills",fileType:"skill"},commands:{subdir:"commands",fileType:"command"}},se=["instructions","agents","skills","commands","settings"],ot={instructions:{label:"Instructions",icon:Je,color:"text-muted-foreground"},agents:{label:"Agents",icon:Ye,color:"text-muted-foreground"},skills:{label:"Skills",icon:He,color:"text-muted-foreground"},commands:{label:"Commands",icon:Qe,color:"text-muted-foreground"},settings:{label:"Settings",icon:Ke,color:"text-muted-foreground"}};function H(l,e,i){const n=[];for(const s of l)s.type==="directory"&&s.children?n.push(...H(s.children,e,i)):s.type==="file"&&n.push({name:s.name,path:s.path,fileType:s.fileType||"unknown",description:s.description||"",scope:e,pluginName:i,readOnly:s.readOnly??e==="plugin",cli:s.cli,linkTarget:s.linkTarget});return n}function ct(l){const e={instructions:[],agents:[],skills:[],commands:[],settings:[]};for(const i of l){const n=H(i.items,i.scope,i.pluginName);for(const s of n)switch(s.fileType){case"instructions":e.instructions.push(s);break;case"agent":e.agents.push(s);break;case"skill":e.skills.push(s);break;case"command":e.commands.push(s);break;case"settings":default:e.settings.push(s)}}return e}function ge(l){const e=G.c(5),{scope:i,pluginName:n}=l;if(i==="plugin"&&n){let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx(We,{"data-icon":"inline-start",className:"size-3"}),e[0]=r):r=e[0];let u;return e[1]!==n?(u=t.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-muted-foreground",children:[r,n]}),e[1]=n,e[2]=u):u=e[2],u}if(i==="project"){let r;return e[3]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-muted-foreground",children:[t.jsx(xe,{"data-icon":"inline-start",className:"size-3"}),"project"]}),e[3]=r):r=e[3],r}let s;return e[4]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-muted-foreground",children:[t.jsx(fe,{"data-icon":"inline-start",className:"size-3"}),"global"]}),e[4]=s):s=e[4],s}const dt=Object.fromEntries(ye().map(l=>[l.kind,Ce(l.kind)]));function pe(l){const e=G.c(10),{cli:i,variant:n}=l,s=n===void 0?"compact":n;if(!i)return null;if(i.length===0){let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx(Xe,{"data-icon":"inline-start",className:"size-3"}),e[0]=m):m=e[0];const c=s==="full"&&"unlinked";let d;return e[1]!==c?(d=t.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-warning",title:"Present in the shared source directory but not linked into any CLI",children:[m,c]}),e[1]=c,e[2]=d):d=e[2],d}let r;if(e[3]!==i||e[4]!==s){let m;e[6]!==s?(m=c=>{const d=dt[c];return t.jsx("span",{title:d.label,className:s==="full"?"flex h-5 items-center justify-center rounded border bg-muted px-1.5 text-xs font-medium text-muted-foreground":"flex size-5 items-center justify-center rounded border bg-muted text-xs font-medium text-muted-foreground",children:s==="full"?c:d.letter},c)},e[6]=s,e[7]=m):m=e[7],r=i.map(m),e[3]=i,e[4]=s,e[5]=r}else r=e[5];let u;return e[8]!==r?(u=t.jsx("span",{className:"flex items-center gap-0.5 shrink-0",children:r}),e[8]=r,e[9]=u):u=e[9],u}function je(l){const e=G.c(10),{linkTarget:i,variant:n,className:s}=l,r=n===void 0?"compact":n;if(!i)return null;let u;e[0]!==s?(u=F("flex min-w-0 shrink-0 items-center gap-1 text-info",s),e[0]=s,e[1]=u):u=e[1];const m=`Symlink → ${i}`;let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=t.jsx(qe,{"data-icon":"inline-start",className:"size-3 shrink-0"}),e[2]=c):c=e[2];let d;e[3]!==i||e[4]!==r?(d=r==="full"&&t.jsxs("span",{className:"truncate font-mono text-xs",children:["→ ",i]}),e[3]=i,e[4]=r,e[5]=d):d=e[5];let p;return e[6]!==u||e[7]!==m||e[8]!==d?(p=t.jsxs("span",{className:u,title:m,children:[c,d]}),e[6]=u,e[7]=m,e[8]=d,e[9]=p):p=e[9],p}function ut({globalDir:l,projectDir:e,fileType:i,onCreated:n,onCancel:s}){const[r,u]=o.useState(""),[m,c]=o.useState(e?"project":"global"),[d,p]=o.useState(!1),w=o.useRef(null),y=o.useId();o.useEffect(()=>{var x;(x=w.current)==null||x.focus()},[]);const k=m==="project"&&e?e:l,b=!!l&&!!e;async function S(){if(!(!r.trim()||!k)){p(!0);try{const x=await A("/api/config-browser/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dir:k,fileType:i,name:r.trim()})});if(x.ok){const g=await x.json();n(g.path,i,m)}}finally{p(!1)}}}return t.jsxs(ke,{className:"gap-3 px-3 py-2",children:[b&&t.jsxs(X,{children:[t.jsx(q,{children:"Scope"}),t.jsxs(ve,{"aria-label":"File scope",value:[m],onValueChange:x=>{const g=x[0];(g==="global"||g==="project")&&c(g)},variant:"outline",size:"sm",spacing:0,className:"w-full",children:[t.jsxs(Z,{value:"global",className:"flex-1",children:[t.jsx(fe,{"data-icon":"inline-start"}),"Global"]}),t.jsxs(Z,{value:"project",className:"flex-1",children:[t.jsx(xe,{"data-icon":"inline-start"}),"Project"]})]})]}),t.jsxs(X,{children:[t.jsxs(q,{htmlFor:y,children:[i.charAt(0).toUpperCase()+i.slice(1)," name"]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(ae,{id:y,ref:w,type:"text",value:r,onChange:x=>u(x.target.value),onKeyDown:x=>{x.key==="Enter"&&S(),x.key==="Escape"&&s()},placeholder:`${i} name...`,className:"h-7 min-w-0 flex-1 text-xs",disabled:d}),t.jsx(I,{variant:"ghost",size:"icon-xs","aria-label":`Create ${i}`,onClick:()=>void S(),disabled:d||!r.trim()||!k,children:t.jsx(K,{"data-icon":"inline-start"})}),t.jsx(I,{variant:"ghost",size:"icon-xs","aria-label":"Cancel create",onClick:s,children:t.jsx(Q,{"data-icon":"inline-start"})})]})]})]})}function mt(l){const e=G.c(50),{category:i,items:n,selectedPath:s,onSelect:r,onNewFile:u,onDeleteItem:m,onRenameItem:c,renamingPath:d,renameValue:p,onRenameValueChange:w,onRenameSubmit:y,onRenameCancel:k,creatingInCategory:b,onCreated:S,onCancelCreate:x}=l,g=ot[i],C=g.icon;if(n.length===0&&!u)return null;let N;e[0]!==g.color?(N=F("size-3.5",g.color),e[0]=g.color,e[1]=N):N=e[1];let v;e[2]!==C||e[3]!==N?(v=t.jsx(C,{"data-icon":"inline-start",className:N}),e[2]=C,e[3]=N,e[4]=v):v=e[4];let T;e[5]!==g.label?(T=t.jsx("span",{className:"flex-1 text-xs font-medium text-muted-foreground",children:g.label}),e[5]=g.label,e[6]=T):T=e[6];let E;e[7]!==n.length?(E=t.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:n.length}),e[7]=n.length,e[8]=E):E=e[8];let f;e[9]!==i||e[10]!==u?(f=u&&t.jsxs(Ne,{children:[t.jsx(Se,{render:t.jsx(I,{variant:"ghost",size:"icon-xs",className:"opacity-0 transition-opacity group-hover:opacity-100","aria-label":`New ${i.slice(0,-1)}`,onClick:u}),children:t.jsx(Ze,{"data-icon":"inline-start"})}),t.jsxs(we,{children:["New ",i.slice(0,-1)]})]}),e[9]=i,e[10]=u,e[11]=f):f=e[11];let D;e[12]!==v||e[13]!==T||e[14]!==E||e[15]!==f?(D=t.jsxs("div",{className:"group flex h-8 items-center gap-1.5 px-3",children:[v,T,E,f]}),e[12]=v,e[13]=T,e[14]=E,e[15]=f,e[16]=D):D=e[16];let z;if(e[17]!==n||e[18]!==m||e[19]!==k||e[20]!==c||e[21]!==y||e[22]!==w||e[23]!==r||e[24]!==p||e[25]!==d||e[26]!==s){let B;e[28]!==m||e[29]!==k||e[30]!==c||e[31]!==y||e[32]!==w||e[33]!==r||e[34]!==p||e[35]!==d||e[36]!==s?(B=j=>{const U=s===j.path;if(d===j.path)return t.jsxs("div",{className:"flex items-center gap-1 border-l-2 border-foreground/30 bg-accent px-3 py-1",children:[t.jsx(ae,{value:p,onChange:$=>w($.target.value),onKeyDown:$=>{$.key==="Enter"&&y(),$.key==="Escape"&&k()},autoFocus:!0,className:"h-7 min-w-0 flex-1 text-xs"}),t.jsx(I,{variant:"ghost",size:"icon-xs","aria-label":"Save name",onClick:y,disabled:!p.trim(),children:t.jsx(K,{"data-icon":"inline-start"})}),t.jsx(I,{variant:"ghost",size:"icon-xs","aria-label":"Cancel rename",onClick:k,children:t.jsx(Q,{"data-icon":"inline-start"})})]},j.path);const M=t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-sm",children:j.name}),t.jsx(je,{linkTarget:j.linkTarget}),j.readOnly&&t.jsx(he,{className:"size-2.5 shrink-0 text-muted-foreground/40"})]}),j.description&&t.jsx("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:j.description})]}),t.jsx(pe,{cli:j.cli}),t.jsx(ge,{scope:j.scope,pluginName:j.pluginName})]}),P=F("flex w-full items-center gap-2 border-l-2 px-3 py-2 text-left text-sm transition-colors",U?"border-foreground/30 bg-accent text-accent-foreground":"border-transparent text-muted-foreground hover:bg-accent hover:text-foreground");return!m||!c?t.jsx("button",{type:"button",className:P,onClick:()=>r(j),children:M},j.path):t.jsxs(De,{children:[t.jsx(Te,{render:t.jsx("button",{type:"button",className:P,onClick:()=>r(j)}),children:M}),t.jsx(Ee,{className:"min-w-36",children:j.readOnly?t.jsx(_,{children:t.jsx(Re,{children:"Read-only file"})}):t.jsxs(t.Fragment,{children:[t.jsx(_,{children:t.jsx(ee,{onClick:()=>c(j),children:"Rename"})}),t.jsx(Oe,{}),t.jsx(_,{children:t.jsx(ee,{variant:"destructive",onClick:()=>m(j),children:"Delete"})})]})})]},j.path)},e[28]=m,e[29]=k,e[30]=c,e[31]=y,e[32]=w,e[33]=r,e[34]=p,e[35]=d,e[36]=s,e[37]=B):B=e[37],z=n.map(B),e[17]=n,e[18]=m,e[19]=k,e[20]=c,e[21]=y,e[22]=w,e[23]=r,e[24]=p,e[25]=d,e[26]=s,e[27]=z}else z=e[27];let R;e[38]!==b||e[39]!==n.length?(R=n.length===0&&!b&&t.jsx("p",{className:"px-3 py-1 text-xs text-muted-foreground",children:"None configured"}),e[38]=b,e[39]=n.length,e[40]=R):R=e[40];let O;e[41]!==b||e[42]!==x||e[43]!==S?(O=b&&t.jsx(ut,{globalDir:b.globalDir,projectDir:b.projectDir,fileType:b.fileType,onCreated:S,onCancel:x}),e[41]=b,e[42]=x,e[43]=S,e[44]=O):O=e[44];let L;return e[45]!==D||e[46]!==z||e[47]!==R||e[48]!==O?(L=t.jsxs("section",{children:[D,z,R,O]}),e[45]=D,e[46]=z,e[47]=R,e[48]=O,e[49]=L):L=e[49],L}function xt({file:l,onDeleted:e,readOnly:i=!1}){const[n,s]=o.useState(null),[r,u]=o.useState(null),[m,c]=o.useState(!0),[d,p]=o.useState(!1),[w,y]=o.useState(!1),[k,b]=o.useState(!1),[S,x]=o.useState(!1),g=n!==null&&n!==r,C=i||l.readOnly;o.useEffect(()=>{c(!0),s(null),u(null),y(!1),b(!1),A(`/api/config-browser/file?path=${encodeURIComponent(l.path)}`).then(f=>f.json()).then(f=>{s(f.content??""),u(f.content??"")}).catch(()=>{s(""),u("")}).finally(()=>c(!1))},[l.path]);const N=o.useCallback(async()=>{if(!(!g||C)){p(!0);try{(await A("/api/config-browser/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:l.path,content:n})})).ok&&(u(n),y(!0),setTimeout(()=>y(!1),2e3))}finally{p(!1)}}},[n,l.path,g,C]),v=o.useCallback(()=>{s(r)},[r]),T=o.useCallback(async()=>{if(!C){x(!0);try{(await A(`/api/config-browser/file?path=${encodeURIComponent(l.path)}`,{method:"DELETE"})).ok&&(b(!1),e())}catch{}finally{x(!1)}}},[l.path,C,e]);o.useEffect(()=>{function f(D){!C&&(D.metaKey||D.ctrlKey)&&D.key==="s"&&(D.preventDefault(),N())}return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[N,C]);function E(){return w?"Saved!":d?"Saving...":"Save"}return t.jsxs("div",{className:"flex flex-1 flex-col min-h-0 min-w-0",children:[t.jsxs("div",{className:"flex min-h-11 shrink-0 items-center gap-2 border-b bg-card px-4 py-2",children:[t.jsx(te,{variant:"outline",className:F("h-5 text-xs",it[l.fileType]||"bg-muted text-muted-foreground"),children:l.fileType}),t.jsx(ge,{scope:l.scope,pluginName:l.pluginName}),t.jsx(pe,{cli:l.cli,variant:"full"}),C&&t.jsxs(te,{variant:"outline",className:"h-5 bg-muted text-xs text-muted-foreground",children:[t.jsx(he,{"data-icon":"inline-start",className:"size-3"})," read-only"]}),g&&t.jsx("span",{className:"size-2 shrink-0 rounded-full bg-warning",title:"Unsaved changes"}),t.jsxs("div",{className:"flex items-center gap-2 ml-auto min-w-0",children:[t.jsx(je,{linkTarget:l.linkTarget,variant:"full"}),t.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",title:l.path,children:l.path})]})]}),m?t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:"Loading..."}):t.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden flex flex-col",children:[t.jsx(lt,{value:n??"",onChange:s,readOnly:C,filePath:l.path}),!C&&t.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-t bg-card px-4 py-2",children:[t.jsxs(I,{size:"xs",onClick:N,disabled:!g||d,children:[t.jsx(K,{"data-icon":"inline-start"}),E()]}),t.jsxs(I,{variant:"outline",size:"xs",onClick:v,disabled:!g,children:[t.jsx(et,{"data-icon":"inline-start"}),"Discard"]}),t.jsx("div",{className:"flex-1"}),t.jsxs(le,{open:k,onOpenChange:b,children:[t.jsxs(Ie,{render:t.jsx(I,{variant:"outline",size:"xs"}),children:[t.jsx(tt,{"data-icon":"inline-start"}),"Delete"]}),t.jsxs(ie,{size:"sm",children:[t.jsxs(re,{children:[t.jsx(oe,{children:"Delete configuration file?"}),t.jsxs(ce,{children:['Delete "',l.name,'" permanently? This action cannot be undone.']})]}),t.jsxs(de,{children:[t.jsx(ue,{size:"sm",disabled:S,children:"Cancel"}),t.jsxs(me,{variant:"destructive",size:"sm",disabled:S,onClick:()=>void T(),children:[S&&t.jsx(ze,{"data-icon":"inline-start"}),S?"Deleting...":"Delete file"]})]})]})]})]})]})]})}function ft(){const l=G.c(1);let e;return l[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(Ae,{className:"border-0",children:t.jsxs(Le,{children:[t.jsx(Be,{variant:"icon",children:t.jsx(nt,{})}),t.jsx($e,{children:"Select a configuration file"}),t.jsx(Fe,{children:"Browse instructions, agents, skills, commands, and settings from the sidebar."})]})}),l[0]=e):e=l[0],e}function ht(l){return l.cli?l.cli.length>0?l.cli.join(" "):"unlinked":""}function gt(l,e){if(!e)return l;const i=e.toLowerCase();return l.filter(n=>[n.name,n.description,n.path,n.linkTarget??"",ht(n)].some(r=>r.toLowerCase().includes(i)))}const kt=o.memo(function({projectPath:e,initialFilePath:i}){var J,W;const n=Ge("configWrite"),[s,r]=o.useState([]),[u,m]=o.useState(!0),[c,d]=o.useState(null),[p,w]=o.useState(!1),[y,k]=o.useState(null),[b,S]=o.useState(""),[x,g]=o.useState(null),[C,N]=o.useState(""),[v,T]=o.useState(null),E=o.useRef(!1),f=o.useCallback(async()=>{if(!n){r([]),d(null),m(!1);return}m(!0);try{const a=e?`/api/config-browser/tree?cwd=${encodeURIComponent(e)}`:"/api/config-browser/tree",h=await A(a);if(h.ok){const V=await h.json();r(V.sections||[])}}finally{m(!1)}},[n,e]);o.useEffect(()=>{f()},[f]),o.useEffect(()=>{if(!i||u||E.current)return;const a=s.flatMap(h=>H(h.items,h.scope,h.pluginName)).find(h=>h.path===i);a&&(d(a),E.current=!0)},[i,u,s]);const D=ct(s),z=Object.fromEntries(se.map(a=>[a,gt(D[a],b)])),R=(J=s.find(a=>a.scope==="global"))==null?void 0:J.baseDir,O=(W=s.find(a=>a.scope==="project"))==null?void 0:W.baseDir,L=o.useCallback(a=>{d(a),w(!1),k(null)},[]),B=o.useCallback((a,h,V)=>{k(null),f(),d({path:a,name:a.split("/").pop()||"",fileType:h,readOnly:!1,scope:V,description:""})},[f]),j=o.useCallback(()=>{d(null),f()},[f]),U=o.useCallback(a=>{if(!n||!R&&!O)return;const h=rt[a];h&&k({category:a,globalDir:R?`${R}/${h.subdir}`:null,projectDir:O?`${O}/${h.subdir}`:null,fileType:h.fileType})},[n,R,O]),Y=o.useCallback(a=>{!n||a.readOnly||T(a)},[n]),M=o.useCallback(async()=>{if(!n||!v||v.readOnly)return;const a=v;T(null);try{(await A(`/api/config-browser/file?path=${encodeURIComponent(a.path)}`,{method:"DELETE"})).ok&&((c==null?void 0:c.path)===a.path&&d(null),f())}catch{}},[n,f,v,c]),P=o.useCallback(a=>{if(!n||a.readOnly)return;const h=a.name==="SKILL.md"?a.path.split("/").slice(-2,-1)[0]||a.name:a.name.replace(/\.[^.]+$/,"");g(a),N(h)},[n]),$=o.useCallback(async()=>{if(!(!n||!x||!C.trim()))try{const a=await A("/api/config-browser/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldPath:x.path,newName:C.trim()})});if(a.ok){const h=await a.json();g(null),N(""),await f(),h.newPath&&d({...x,path:h.newPath,name:h.newPath.split("/").pop()||x.name})}}catch{}},[n,x,C,f]),be=o.useCallback(()=>{g(null),N("")},[]);return n?t.jsxs("div",{className:"flex flex-1 min-h-0 min-w-0",children:[t.jsxs("div",{className:F("min-h-0 shrink-0 flex-col border-r bg-sidebar md:flex md:w-80",c&&!p?"hidden":"flex w-full"),children:[t.jsxs("div",{className:"flex h-11 items-center gap-2 border-b px-3",children:[t.jsx("span",{className:"text-sm font-medium text-foreground",children:"Configuration"}),e&&t.jsx("span",{className:"ml-auto truncate text-xs text-muted-foreground",title:e,children:e.split("/").pop()})]}),t.jsx("div",{className:"border-b p-2",children:t.jsxs(Me,{children:[t.jsx(ne,{children:t.jsx(st,{"data-icon":"inline-start"})}),t.jsx(Pe,{value:b,onChange:a=>S(a.target.value),placeholder:"Search configuration"}),b&&t.jsx(ne,{align:"inline-end",children:t.jsx(Ue,{size:"icon-xs","aria-label":"Clear search",onClick:()=>S(""),children:t.jsx(Q,{"data-icon":"inline-start"})})})]})}),t.jsx(Ve,{className:"flex-1",children:t.jsx("div",{className:"flex flex-col gap-1 py-2",children:u?t.jsx("div",{className:"flex flex-col gap-2 px-3 py-2","aria-label":"Loading configuration",children:Array.from({length:6},(a,h)=>t.jsx(_e,{className:"h-8 w-full"},h))}):se.map(a=>{const h=a==="agents"||a==="skills"||a==="commands";return t.jsx(mt,{category:a,items:z[a],selectedPath:(c==null?void 0:c.path)??null,onSelect:L,onNewFile:n&&h?()=>U(a):void 0,onDeleteItem:n?Y:void 0,onRenameItem:n?P:void 0,renamingPath:(x==null?void 0:x.path)??null,renameValue:C,onRenameValueChange:N,onRenameSubmit:$,onRenameCancel:be,creatingInCategory:n&&(y==null?void 0:y.category)===a?y:null,onCreated:B,onCancelCreate:()=>k(null)},a)})})})]}),t.jsx("div",{className:F("min-h-0 min-w-0 flex-1 flex-col md:flex",c&&!p?"flex":"hidden"),children:c?t.jsxs(t.Fragment,{children:[t.jsxs(I,{variant:"ghost",className:"min-h-11 shrink-0 justify-start md:hidden",onClick:()=>w(!0),children:[t.jsx(at,{"data-icon":"inline-start"}),"All configuration files"]}),t.jsx(xt,{file:c,onDeleted:j,readOnly:!n})]}):t.jsx(ft,{})}),t.jsx(le,{open:v!==null,onOpenChange:a=>{a||T(null)},children:t.jsxs(ie,{size:"sm",children:[t.jsxs(re,{children:[t.jsx(oe,{children:"Delete configuration file?"}),t.jsxs(ce,{children:['Delete "',v==null?void 0:v.name,'" permanently? This action cannot be undone.']})]}),t.jsxs(de,{children:[t.jsx(ue,{size:"sm",children:"Cancel"}),t.jsx(me,{variant:"destructive",size:"sm",onClick:()=>void M(),children:"Delete file"})]})]})})]}):t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:"Server configuration is available to administrators only."})});export{kt as ConfigBrowser};
|
|
1
|
+
import{c as G,j as t,r as o}from"./vendor-react-gGw_S5I_.js";import{bG as ye,bV as Ce,c as F,aC as ke,ae as X,ac as Z,aB as ve,aA as q,au as ae,B as O,F as A,bW as Ne,bX as Se,bY as we,bZ as De,b_ as Te,b$ as Ee,c0 as V,c1 as Re,c2 as ee,c3 as Ie,k as te,aa as le,c4 as Oe,a9 as ie,a5 as re,a3 as oe,a4 as ce,a7 as de,a6 as ue,a8 as me,x as ze,E as Ae,f as Le,U as Be,h as $e,i as Fe,b7 as Ge,az as Me,ax as ne,aw as Pe,ay as Ue,m as _e,c5 as Ve}from"./index-BYVl1VlW.js";import{c1 as Ke,a3 as He,a5 as Ye,bv as Je,cB as Qe,U as We,dt as xe,aF as fe,du as Xe,dv as Ze,dw as K,X as H,bl as qe,c_ as he,dx as et,b6 as tt,bR as nt,ao as st,cR as at}from"./vendor-ui-B0az9ATE.js";import{H as lt}from"./HighlightedEditor-G-YJnadM.js";import"./vendor-markdown-BEJ8yVzA.js";const it={agent:"bg-muted text-muted-foreground",skill:"bg-muted text-muted-foreground",command:"bg-muted text-muted-foreground",instructions:"bg-muted text-muted-foreground",settings:"bg-muted text-muted-foreground"},rt={agents:{subdir:"agents",fileType:"agent"},skills:{subdir:"skills",fileType:"skill"},commands:{subdir:"commands",fileType:"command"}},se=["instructions","agents","skills","commands","settings"],ot={instructions:{label:"Instructions",icon:Qe,color:"text-muted-foreground"},agents:{label:"Agents",icon:Je,color:"text-muted-foreground"},skills:{label:"Skills",icon:Ye,color:"text-muted-foreground"},commands:{label:"Commands",icon:He,color:"text-muted-foreground"},settings:{label:"Settings",icon:Ke,color:"text-muted-foreground"}};function Y(l,e,i){const n=[];for(const s of l)s.type==="directory"&&s.children?n.push(...Y(s.children,e,i)):s.type==="file"&&n.push({name:s.name,path:s.path,fileType:s.fileType||"unknown",description:s.description||"",scope:e,pluginName:i,readOnly:s.readOnly??e==="plugin",cli:s.cli,linkTarget:s.linkTarget});return n}function ct(l){const e={instructions:[],agents:[],skills:[],commands:[],settings:[]};for(const i of l){const n=Y(i.items,i.scope,i.pluginName);for(const s of n)switch(s.fileType){case"instructions":e.instructions.push(s);break;case"agent":e.agents.push(s);break;case"skill":e.skills.push(s);break;case"command":e.commands.push(s);break;case"settings":default:e.settings.push(s)}}return e}function ge(l){const e=G.c(5),{scope:i,pluginName:n}=l;if(i==="plugin"&&n){let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx(We,{"data-icon":"inline-start",className:"size-3"}),e[0]=r):r=e[0];let u;return e[1]!==n?(u=t.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-muted-foreground",children:[r,n]}),e[1]=n,e[2]=u):u=e[2],u}if(i==="project"){let r;return e[3]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-muted-foreground",children:[t.jsx(xe,{"data-icon":"inline-start",className:"size-3"}),"project"]}),e[3]=r):r=e[3],r}let s;return e[4]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-muted-foreground",children:[t.jsx(fe,{"data-icon":"inline-start",className:"size-3"}),"global"]}),e[4]=s):s=e[4],s}const dt=Object.fromEntries(ye().map(l=>[l.kind,Ce(l.kind)]));function pe(l){const e=G.c(10),{cli:i,variant:n}=l,s=n===void 0?"compact":n;if(!i)return null;if(i.length===0){let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx(Xe,{"data-icon":"inline-start",className:"size-3"}),e[0]=m):m=e[0];const c=s==="full"&&"unlinked";let d;return e[1]!==c?(d=t.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-warning",title:"Present in the shared source directory but not linked into any CLI",children:[m,c]}),e[1]=c,e[2]=d):d=e[2],d}let r;if(e[3]!==i||e[4]!==s){let m;e[6]!==s?(m=c=>{const d=dt[c];return t.jsx("span",{title:d.label,className:s==="full"?"flex h-5 items-center justify-center rounded border bg-muted px-1.5 text-xs font-medium text-muted-foreground":"flex size-5 items-center justify-center rounded border bg-muted text-xs font-medium text-muted-foreground",children:s==="full"?c:d.letter},c)},e[6]=s,e[7]=m):m=e[7],r=i.map(m),e[3]=i,e[4]=s,e[5]=r}else r=e[5];let u;return e[8]!==r?(u=t.jsx("span",{className:"flex items-center gap-0.5 shrink-0",children:r}),e[8]=r,e[9]=u):u=e[9],u}function je(l){const e=G.c(10),{linkTarget:i,variant:n,className:s}=l,r=n===void 0?"compact":n;if(!i)return null;let u;e[0]!==s?(u=F("flex min-w-0 shrink-0 items-center gap-1 text-info",s),e[0]=s,e[1]=u):u=e[1];const m=`Symlink → ${i}`;let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=t.jsx(Ze,{"data-icon":"inline-start",className:"size-3 shrink-0"}),e[2]=c):c=e[2];let d;e[3]!==i||e[4]!==r?(d=r==="full"&&t.jsxs("span",{className:"truncate font-mono text-xs",children:["→ ",i]}),e[3]=i,e[4]=r,e[5]=d):d=e[5];let p;return e[6]!==u||e[7]!==m||e[8]!==d?(p=t.jsxs("span",{className:u,title:m,children:[c,d]}),e[6]=u,e[7]=m,e[8]=d,e[9]=p):p=e[9],p}function ut({globalDir:l,projectDir:e,fileType:i,onCreated:n,onCancel:s}){const[r,u]=o.useState(""),[m,c]=o.useState(e?"project":"global"),[d,p]=o.useState(!1),w=o.useRef(null),y=o.useId();o.useEffect(()=>{var x;(x=w.current)==null||x.focus()},[]);const k=m==="project"&&e?e:l,b=!!l&&!!e;async function S(){if(!(!r.trim()||!k)){p(!0);try{const x=await A("/api/config-browser/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dir:k,fileType:i,name:r.trim()})});if(x.ok){const g=await x.json();n(g.path,i,m)}}finally{p(!1)}}}return t.jsxs(ke,{className:"gap-3 px-3 py-2",children:[b&&t.jsxs(X,{children:[t.jsx(Z,{children:"Scope"}),t.jsxs(ve,{"aria-label":"File scope",value:[m],onValueChange:x=>{const g=x[0];(g==="global"||g==="project")&&c(g)},variant:"outline",size:"sm",spacing:0,className:"w-full",children:[t.jsxs(q,{value:"global",className:"flex-1",children:[t.jsx(fe,{"data-icon":"inline-start"}),"Global"]}),t.jsxs(q,{value:"project",className:"flex-1",children:[t.jsx(xe,{"data-icon":"inline-start"}),"Project"]})]})]}),t.jsxs(X,{children:[t.jsxs(Z,{htmlFor:y,children:[i.charAt(0).toUpperCase()+i.slice(1)," name"]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(ae,{id:y,ref:w,type:"text",value:r,onChange:x=>u(x.target.value),onKeyDown:x=>{x.key==="Enter"&&S(),x.key==="Escape"&&s()},placeholder:`${i} name...`,className:"h-7 min-w-0 flex-1 text-xs",disabled:d}),t.jsx(O,{variant:"ghost",size:"icon-xs","aria-label":`Create ${i}`,onClick:()=>void S(),disabled:d||!r.trim()||!k,children:t.jsx(K,{"data-icon":"inline-start"})}),t.jsx(O,{variant:"ghost",size:"icon-xs","aria-label":"Cancel create",onClick:s,children:t.jsx(H,{"data-icon":"inline-start"})})]})]})]})}function mt(l){const e=G.c(50),{category:i,items:n,selectedPath:s,onSelect:r,onNewFile:u,onDeleteItem:m,onRenameItem:c,renamingPath:d,renameValue:p,onRenameValueChange:w,onRenameSubmit:y,onRenameCancel:k,creatingInCategory:b,onCreated:S,onCancelCreate:x}=l,g=ot[i],C=g.icon;if(n.length===0&&!u)return null;let N;e[0]!==g.color?(N=F("size-3.5",g.color),e[0]=g.color,e[1]=N):N=e[1];let v;e[2]!==C||e[3]!==N?(v=t.jsx(C,{"data-icon":"inline-start",className:N}),e[2]=C,e[3]=N,e[4]=v):v=e[4];let T;e[5]!==g.label?(T=t.jsx("span",{className:"flex-1 text-xs font-medium text-muted-foreground",children:g.label}),e[5]=g.label,e[6]=T):T=e[6];let E;e[7]!==n.length?(E=t.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:n.length}),e[7]=n.length,e[8]=E):E=e[8];let f;e[9]!==i||e[10]!==u?(f=u&&t.jsxs(Ne,{children:[t.jsx(Se,{render:t.jsx(O,{variant:"ghost",size:"icon-xs",className:"opacity-0 transition-opacity group-hover:opacity-100","aria-label":`New ${i.slice(0,-1)}`,onClick:u}),children:t.jsx(qe,{"data-icon":"inline-start"})}),t.jsxs(we,{children:["New ",i.slice(0,-1)]})]}),e[9]=i,e[10]=u,e[11]=f):f=e[11];let D;e[12]!==v||e[13]!==T||e[14]!==E||e[15]!==f?(D=t.jsxs("div",{className:"group flex h-8 items-center gap-1.5 px-3",children:[v,T,E,f]}),e[12]=v,e[13]=T,e[14]=E,e[15]=f,e[16]=D):D=e[16];let z;if(e[17]!==n||e[18]!==m||e[19]!==k||e[20]!==c||e[21]!==y||e[22]!==w||e[23]!==r||e[24]!==p||e[25]!==d||e[26]!==s){let B;e[28]!==m||e[29]!==k||e[30]!==c||e[31]!==y||e[32]!==w||e[33]!==r||e[34]!==p||e[35]!==d||e[36]!==s?(B=j=>{const U=s===j.path;if(d===j.path)return t.jsxs("div",{className:"flex items-center gap-1 border-l-2 border-foreground/30 bg-accent px-3 py-1",children:[t.jsx(ae,{value:p,onChange:$=>w($.target.value),onKeyDown:$=>{$.key==="Enter"&&y(),$.key==="Escape"&&k()},autoFocus:!0,className:"h-7 min-w-0 flex-1 text-xs"}),t.jsx(O,{variant:"ghost",size:"icon-xs","aria-label":"Save name",onClick:y,disabled:!p.trim(),children:t.jsx(K,{"data-icon":"inline-start"})}),t.jsx(O,{variant:"ghost",size:"icon-xs","aria-label":"Cancel rename",onClick:k,children:t.jsx(H,{"data-icon":"inline-start"})})]},j.path);const M=t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-sm",children:j.name}),t.jsx(je,{linkTarget:j.linkTarget}),j.readOnly&&t.jsx(he,{className:"size-2.5 shrink-0 text-muted-foreground/40"})]}),j.description&&t.jsx("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:j.description})]}),t.jsx(pe,{cli:j.cli}),t.jsx(ge,{scope:j.scope,pluginName:j.pluginName})]}),P=F("flex w-full items-center gap-2 border-l-2 px-3 py-2 text-left text-sm transition-colors",U?"border-foreground/30 bg-accent text-accent-foreground":"border-transparent text-muted-foreground hover:bg-accent hover:text-foreground");return!m||!c?t.jsx("button",{type:"button",className:P,onClick:()=>r(j),children:M},j.path):t.jsxs(De,{children:[t.jsx(Te,{render:t.jsx("button",{type:"button",className:P,onClick:()=>r(j)}),children:M}),t.jsx(Ee,{className:"min-w-36",children:j.readOnly?t.jsx(V,{children:t.jsx(Re,{children:"Read-only file"})}):t.jsxs(t.Fragment,{children:[t.jsx(V,{children:t.jsx(ee,{onClick:()=>c(j),children:"Rename"})}),t.jsx(Ie,{}),t.jsx(V,{children:t.jsx(ee,{variant:"destructive",onClick:()=>m(j),children:"Delete"})})]})})]},j.path)},e[28]=m,e[29]=k,e[30]=c,e[31]=y,e[32]=w,e[33]=r,e[34]=p,e[35]=d,e[36]=s,e[37]=B):B=e[37],z=n.map(B),e[17]=n,e[18]=m,e[19]=k,e[20]=c,e[21]=y,e[22]=w,e[23]=r,e[24]=p,e[25]=d,e[26]=s,e[27]=z}else z=e[27];let R;e[38]!==b||e[39]!==n.length?(R=n.length===0&&!b&&t.jsx("p",{className:"px-3 py-1 text-xs text-muted-foreground",children:"None configured"}),e[38]=b,e[39]=n.length,e[40]=R):R=e[40];let I;e[41]!==b||e[42]!==x||e[43]!==S?(I=b&&t.jsx(ut,{globalDir:b.globalDir,projectDir:b.projectDir,fileType:b.fileType,onCreated:S,onCancel:x}),e[41]=b,e[42]=x,e[43]=S,e[44]=I):I=e[44];let L;return e[45]!==D||e[46]!==z||e[47]!==R||e[48]!==I?(L=t.jsxs("section",{children:[D,z,R,I]}),e[45]=D,e[46]=z,e[47]=R,e[48]=I,e[49]=L):L=e[49],L}function xt({file:l,onDeleted:e,readOnly:i=!1}){const[n,s]=o.useState(null),[r,u]=o.useState(null),[m,c]=o.useState(!0),[d,p]=o.useState(!1),[w,y]=o.useState(!1),[k,b]=o.useState(!1),[S,x]=o.useState(!1),g=n!==null&&n!==r,C=i||l.readOnly;o.useEffect(()=>{c(!0),s(null),u(null),y(!1),b(!1),A(`/api/config-browser/file?path=${encodeURIComponent(l.path)}`).then(f=>f.json()).then(f=>{s(f.content??""),u(f.content??"")}).catch(()=>{s(""),u("")}).finally(()=>c(!1))},[l.path]);const N=o.useCallback(async()=>{if(!(!g||C)){p(!0);try{(await A("/api/config-browser/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:l.path,content:n})})).ok&&(u(n),y(!0),setTimeout(()=>y(!1),2e3))}finally{p(!1)}}},[n,l.path,g,C]),v=o.useCallback(()=>{s(r)},[r]),T=o.useCallback(async()=>{if(!C){x(!0);try{(await A(`/api/config-browser/file?path=${encodeURIComponent(l.path)}`,{method:"DELETE"})).ok&&(b(!1),e())}catch{}finally{x(!1)}}},[l.path,C,e]);o.useEffect(()=>{function f(D){!C&&(D.metaKey||D.ctrlKey)&&D.key==="s"&&(D.preventDefault(),N())}return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[N,C]);function E(){return w?"Saved!":d?"Saving...":"Save"}return t.jsxs("div",{className:"flex flex-1 flex-col min-h-0 min-w-0",children:[t.jsxs("div",{className:"flex min-h-11 shrink-0 items-center gap-2 border-b bg-card px-4 py-2",children:[t.jsx(te,{variant:"outline",className:F("h-5 text-xs",it[l.fileType]||"bg-muted text-muted-foreground"),children:l.fileType}),t.jsx(ge,{scope:l.scope,pluginName:l.pluginName}),t.jsx(pe,{cli:l.cli,variant:"full"}),C&&t.jsxs(te,{variant:"outline",className:"h-5 bg-muted text-xs text-muted-foreground",children:[t.jsx(he,{"data-icon":"inline-start",className:"size-3"})," read-only"]}),g&&t.jsx("span",{className:"size-2 shrink-0 rounded-full bg-warning",title:"Unsaved changes"}),t.jsxs("div",{className:"flex items-center gap-2 ml-auto min-w-0",children:[t.jsx(je,{linkTarget:l.linkTarget,variant:"full"}),t.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",title:l.path,children:l.path})]})]}),m?t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:"Loading..."}):t.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden flex flex-col",children:[t.jsx(lt,{value:n??"",onChange:s,readOnly:C,filePath:l.path}),!C&&t.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-t bg-card px-4 py-2",children:[t.jsxs(O,{size:"xs",onClick:N,disabled:!g||d,children:[t.jsx(K,{"data-icon":"inline-start"}),E()]}),t.jsxs(O,{variant:"outline",size:"xs",onClick:v,disabled:!g,children:[t.jsx(et,{"data-icon":"inline-start"}),"Discard"]}),t.jsx("div",{className:"flex-1"}),t.jsxs(le,{open:k,onOpenChange:b,children:[t.jsxs(Oe,{render:t.jsx(O,{variant:"outline",size:"xs"}),children:[t.jsx(tt,{"data-icon":"inline-start"}),"Delete"]}),t.jsxs(ie,{size:"sm",children:[t.jsxs(re,{children:[t.jsx(oe,{children:"Delete configuration file?"}),t.jsxs(ce,{children:['Delete "',l.name,'" permanently? This action cannot be undone.']})]}),t.jsxs(de,{children:[t.jsx(ue,{size:"sm",disabled:S,children:"Cancel"}),t.jsxs(me,{variant:"destructive",size:"sm",disabled:S,onClick:()=>void T(),children:[S&&t.jsx(ze,{"data-icon":"inline-start"}),S?"Deleting...":"Delete file"]})]})]})]})]})]})]})}function ft(){const l=G.c(1);let e;return l[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(Ae,{className:"border-0",children:t.jsxs(Le,{children:[t.jsx(Be,{variant:"icon",children:t.jsx(nt,{})}),t.jsx($e,{children:"Select a configuration file"}),t.jsx(Fe,{children:"Browse instructions, agents, skills, commands, and settings from the sidebar."})]})}),l[0]=e):e=l[0],e}function ht(l){return l.cli?l.cli.length>0?l.cli.join(" "):"unlinked":""}function gt(l,e){if(!e)return l;const i=e.toLowerCase();return l.filter(n=>[n.name,n.description,n.path,n.linkTarget??"",ht(n)].some(r=>r.toLowerCase().includes(i)))}const kt=o.memo(function({projectPath:e,initialFilePath:i}){var Q,W;const n=Ge("configWrite"),[s,r]=o.useState([]),[u,m]=o.useState(!0),[c,d]=o.useState(null),[p,w]=o.useState(!1),[y,k]=o.useState(null),[b,S]=o.useState(""),[x,g]=o.useState(null),[C,N]=o.useState(""),[v,T]=o.useState(null),E=o.useRef(!1),f=o.useCallback(async()=>{if(!n){r([]),d(null),m(!1);return}m(!0);try{const a=e?`/api/config-browser/tree?cwd=${encodeURIComponent(e)}`:"/api/config-browser/tree",h=await A(a);if(h.ok){const _=await h.json();r(_.sections||[])}}finally{m(!1)}},[n,e]);o.useEffect(()=>{f()},[f]),o.useEffect(()=>{if(!i||u||E.current)return;const a=s.flatMap(h=>Y(h.items,h.scope,h.pluginName)).find(h=>h.path===i);a&&(d(a),E.current=!0)},[i,u,s]);const D=ct(s),z=Object.fromEntries(se.map(a=>[a,gt(D[a],b)])),R=(Q=s.find(a=>a.scope==="global"))==null?void 0:Q.baseDir,I=(W=s.find(a=>a.scope==="project"))==null?void 0:W.baseDir,L=o.useCallback(a=>{d(a),w(!1),k(null)},[]),B=o.useCallback((a,h,_)=>{k(null),f(),d({path:a,name:a.split("/").pop()||"",fileType:h,readOnly:!1,scope:_,description:""})},[f]),j=o.useCallback(()=>{d(null),f()},[f]),U=o.useCallback(a=>{if(!n||!R&&!I)return;const h=rt[a];h&&k({category:a,globalDir:R?`${R}/${h.subdir}`:null,projectDir:I?`${I}/${h.subdir}`:null,fileType:h.fileType})},[n,R,I]),J=o.useCallback(a=>{!n||a.readOnly||T(a)},[n]),M=o.useCallback(async()=>{if(!n||!v||v.readOnly)return;const a=v;T(null);try{(await A(`/api/config-browser/file?path=${encodeURIComponent(a.path)}`,{method:"DELETE"})).ok&&((c==null?void 0:c.path)===a.path&&d(null),f())}catch{}},[n,f,v,c]),P=o.useCallback(a=>{if(!n||a.readOnly)return;const h=a.name==="SKILL.md"?a.path.split("/").slice(-2,-1)[0]||a.name:a.name.replace(/\.[^.]+$/,"");g(a),N(h)},[n]),$=o.useCallback(async()=>{if(!(!n||!x||!C.trim()))try{const a=await A("/api/config-browser/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldPath:x.path,newName:C.trim()})});if(a.ok){const h=await a.json();g(null),N(""),await f(),h.newPath&&d({...x,path:h.newPath,name:h.newPath.split("/").pop()||x.name})}}catch{}},[n,x,C,f]),be=o.useCallback(()=>{g(null),N("")},[]);return n?t.jsxs("div",{className:"flex flex-1 min-h-0 min-w-0",children:[t.jsxs("div",{className:F("min-h-0 shrink-0 flex-col border-r bg-sidebar md:flex md:w-80",c&&!p?"hidden":"flex w-full"),children:[t.jsxs("div",{className:"flex h-11 items-center gap-2 border-b px-3",children:[t.jsx("span",{className:"text-sm font-medium text-foreground",children:"Configuration"}),e&&t.jsx("span",{className:"ml-auto truncate text-xs text-muted-foreground",title:e,children:e.split("/").pop()})]}),t.jsx("div",{className:"border-b p-2",children:t.jsxs(Me,{children:[t.jsx(ne,{children:t.jsx(st,{"data-icon":"inline-start"})}),t.jsx(Pe,{value:b,onChange:a=>S(a.target.value),placeholder:"Search configuration"}),b&&t.jsx(ne,{align:"inline-end",children:t.jsx(Ue,{size:"icon-xs","aria-label":"Clear search",onClick:()=>S(""),children:t.jsx(H,{"data-icon":"inline-start"})})})]})}),t.jsx(_e,{className:"flex-1",children:t.jsx("div",{className:"flex flex-col gap-1 py-2",children:u?t.jsx("div",{className:"flex flex-col gap-2 px-3 py-2","aria-label":"Loading configuration",children:Array.from({length:6},(a,h)=>t.jsx(Ve,{className:"h-8 w-full"},h))}):se.map(a=>{const h=a==="agents"||a==="skills"||a==="commands";return t.jsx(mt,{category:a,items:z[a],selectedPath:(c==null?void 0:c.path)??null,onSelect:L,onNewFile:n&&h?()=>U(a):void 0,onDeleteItem:n?J:void 0,onRenameItem:n?P:void 0,renamingPath:(x==null?void 0:x.path)??null,renameValue:C,onRenameValueChange:N,onRenameSubmit:$,onRenameCancel:be,creatingInCategory:n&&(y==null?void 0:y.category)===a?y:null,onCreated:B,onCancelCreate:()=>k(null)},a)})})})]}),t.jsx("div",{className:F("min-h-0 min-w-0 flex-1 flex-col md:flex",c&&!p?"flex":"hidden"),children:c?t.jsxs(t.Fragment,{children:[t.jsxs(O,{variant:"ghost",className:"min-h-11 shrink-0 justify-start md:hidden",onClick:()=>w(!0),children:[t.jsx(at,{"data-icon":"inline-start"}),"All configuration files"]}),t.jsx(xt,{file:c,onDeleted:j,readOnly:!n})]}):t.jsx(ft,{})}),t.jsx(le,{open:v!==null,onOpenChange:a=>{a||T(null)},children:t.jsxs(ie,{size:"sm",children:[t.jsxs(re,{children:[t.jsx(oe,{children:"Delete configuration file?"}),t.jsxs(ce,{children:['Delete "',v==null?void 0:v.name,'" permanently? This action cannot be undone.']})]}),t.jsxs(de,{children:[t.jsx(ue,{size:"sm",children:"Cancel"}),t.jsx(me,{variant:"destructive",size:"sm",onClick:()=>void M(),children:"Delete file"})]})]})})]}):t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:"Server configuration is available to administrators only."})});export{kt as ConfigBrowser};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as k,c as ue,j as n}from"./vendor-react-gGw_S5I_.js";import{F as _e,da as it,a0 as je,db as jt,dc as yt,dd as Nt,B as J,E as rt,f as ct,U as It,h as dt,i as ut,ae as Je,de as kt,ac as Qe,aC as et,df as Ct,dg as St,m as ft,ad as Mt,dh as $t,av as Rt,cB as Tt,di as At,c_ as Ot,aZ as Et,o as Lt,n as _t,D as zt,j as Dt,c as oe,dj as Ft,bP as Pt,bQ as Yt,bO as qt,dk as Ye,V as qe,dl as Wt,cz as Ht,c9 as Bt,ca as Ut,cb as Te,cc as Ae,al as Gt,k as Kt,dm as Vt,dn as Xt,dp as Zt,b8 as Jt}from"./index-Bg4A-xl7.js";import{S as Qt}from"./switch-DI9dp0Ya.js";import{bT as es,dy as ts,aP as ss,bq as ns,N as ht,bo as mt,bg as as,bt as os,bp as ls,A as ze,dz as is,aO as rs,X as cs}from"./vendor-ui-Dc_kJXxz.js";import"./vendor-markdown-BEJ8yVzA.js";async function ke(t){if(t.ok)return t;const e=await t.json().catch(()=>null);throw new Error((e==null?void 0:e.error)||"Couldn't update crew chat.")}function Oe(t,e){return[...new Map([...t,...e].map(s=>[s.sequence,s])).values()].sort((s,i)=>s.sequence-i.sequence)}function ds(t){const[e,s]=k.useState(null),[i,l]=k.useState([]),[o,c]=k.useState(null),[a,f]=k.useState(!1),[g,h]=k.useState(!1),[r,w]=k.useState(!1),[u,x]=k.useState(new Set),d=k.useRef(0),p=k.useRef(null),N=k.useRef(!1),C=k.useRef(!1),b=k.useRef(new Set),S=k.useRef(!1),y=k.useRef(null),M=k.useCallback(async v=>{const _=++d.current;try{const I=y.current,R=await(await ke(await _e(`/api/crew-chat/${encodeURIComponent(t)}${I===null?"":`?after=${I}&limit=100`}`))).json();if(!v()||_!==d.current)return;s(T=>T&&JSON.stringify(T.members)===JSON.stringify(R.members)?{...R,members:T.members}:R),l(T=>Oe(T,R.messages)),y.current=R.nextCursor,S.current||(S.current=!0,w(R.hasMore)),c(null)}catch(I){v()&&_===d.current&&c(I instanceof Error?I.message:"Couldn't load crew chat.")}},[t]);it(M,2e3);const L=k.useCallback(async v=>{var _;if(N.current)return!1;N.current=!0,f(!0),((_=p.current)==null?void 0:_.text)!==v&&(p.current={text:v,id:crypto.randomUUID()});try{const E=await(await ke(await je(`/api/crew-chat/${encodeURIComponent(t)}`,{text:v,commandId:p.current.id}))).json();return d.current++,l(R=>Oe(R,[E.message])),p.current=null,c(E.pending.length?"Message saved. Some members are unavailable; delivery will retry.":null),!0}catch(I){return c(I instanceof Error?I.message:"Couldn't send the message."),!1}finally{N.current=!1,f(!1)}},[t]),A=k.useCallback(async(v,_)=>{if(!b.current.has(v)){b.current.add(v),x(I=>new Set(I).add(v));try{await ke(await je(`/api/crew-chat/${encodeURIComponent(t)}`,{sessionId:v,listening:_},{method:"PATCH"})),d.current++,s(I=>I&&{...I,members:I.members.map(E=>E.sessionId===v?{...E,listening:_}:E)}),c(null)}catch(I){c(I instanceof Error?I.message:"Couldn't change listening.")}finally{b.current.delete(v),x(I=>{const E=new Set(I);return E.delete(v),E})}}},[t]),O=k.useCallback(async()=>{if(!(!i.length||C.current)){C.current=!0,h(!0);try{const _=await(await ke(await _e(`/api/crew-chat/${encodeURIComponent(t)}?before=${i[0].sequence}`))).json();l(I=>Oe(I,_.messages)),w(_.hasMore)}catch(v){c(v instanceof Error?v.message:"Couldn't load older messages.")}finally{C.current=!1,h(!1)}}},[i,t]);return{page:e,messages:i,error:o,posting:a,busyMembers:u,hasOlder:r,loadingOlder:g,post:L,setListening:A,older:O}}const us=[],fs=new Map;function hs(t){var He,Be,Ue,Ge,Ke,Ve,Xe;const e=ue.c(111),{rootId:s,kinds:i,active:l}=t,o=i===void 0?fs:i,c=l===void 0?!0:l,a=ds(s),[f,g]=k.useState(""),h=k.useRef(null),r=k.useRef(!0);let w;e[0]!==a.messages?(w=(He=a.messages.at(-1))==null?void 0:He.sequence,e[0]=a.messages,e[1]=w):w=e[1];const u=w,x=((Be=a.page)==null?void 0:Be.members)??us;let d;e[2]!==x?(d=jt(x),e[2]=x,e[3]=d):d=e[3];const p=d;let N;e[4]!==x||e[5]!==s?(N=yt(x,s),e[4]=x,e[5]=s,e[6]=N):N=e[6];const C=N;let b;e[7]!==x?(b=new Map(x.map(ps)),e[7]=x,e[8]=b):b=e[8];const S=b;let y;e[9]!==a.messages||e[10]!==s?(y=Nt(a.messages,s),e[9]=a.messages,e[10]=s,e[11]=y):y=e[11];const M=y;let L;e[12]!==c?(L=()=>{var U,H;c&&r.current&&((H=(U=h.current)==null?void 0:U.scrollIntoView)==null||H.call(U,{block:"end"}))},e[12]=c,e[13]=L):L=e[13];let A;e[14]!==c||e[15]!==u?(A=[c,u],e[14]=c,e[15]=u,e[16]=A):A=e[16],k.useEffect(L,A);let O;e[17]!==a||e[18]!==f?(O=async()=>{const U=f.trim();!U||a.posting||await a.post(U)&&(g(H=>H.trim()===U?"":H),r.current=!0)},e[17]=a,e[18]=f,e[19]=O):O=e[19];const v=O;let _;e[20]!==a.page||e[21]!==x?(_=a.page?`${x.filter(ms).length} listening · Members & mentions`:"Loading chat…",e[20]=a.page,e[21]=x,e[22]=_):_=e[22];let I;e[23]!==_?(I=n.jsx("summary",{className:"cursor-pointer text-xs text-muted-foreground",children:_}),e[23]=_,e[24]=I):I=e[24];let E;if(e[25]!==a||e[26]!==o||e[27]!==x||e[28]!==s||e[29]!==C){let U;e[31]!==a||e[32]!==o||e[33]!==s||e[34]!==C?(U=H=>{var Ze;return n.jsxs(Je,{orientation:"horizontal",className:"items-center gap-2",children:[n.jsx(kt,{role:H.sessionId===s?"lead":"agent",sessionId:H.sessionId,kinds:o,tints:C,className:"size-5"}),n.jsxs(Qe,{className:"min-w-0 flex-1 items-baseline gap-1.5",htmlFor:`listen-${H.sessionId}`,"aria-label":`Listen for ${H.name}`,children:[n.jsx("span",{className:"truncate",children:H.name}),n.jsxs("span",{className:"truncate text-xs font-normal text-muted-foreground",children:["@",H.handle]})]}),n.jsx(J,{variant:"ghost",size:"icon-xs",disabled:!((Ze=a.page)!=null&&Ze.canPost)||!H.canInteract,onClick:()=>g(ye=>`${ye}${ye&&!/\s$/.test(ye)?" ":""}@${H.handle} `),"aria-label":`Mention ${H.name}`,title:`Mention @${H.handle}`,className:"text-muted-foreground",children:n.jsx(ts,{"data-icon":"inline-start"})}),n.jsx(Qt,{id:`listen-${H.sessionId}`,size:"sm",checked:H.listening,disabled:!H.canInteract||a.busyMembers.has(H.sessionId),onCheckedChange:ye=>void a.setListening(H.sessionId,ye)})]},H.sessionId)},e[31]=a,e[32]=o,e[33]=s,e[34]=C,e[35]=U):U=e[35],E=x.map(U),e[25]=a,e[26]=o,e[27]=x,e[28]=s,e[29]=C,e[30]=E}else E=e[30];let R;e[36]!==E?(R=n.jsx(et,{className:"max-h-48 gap-2 overflow-y-auto py-2",children:E}),e[36]=E,e[37]=R):R=e[37];let T;e[38]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsx("p",{className:"pb-1 text-xs text-muted-foreground",children:"Listening sends short notices while an agent works. @mentions send the full message, even when listening is off."}),e[38]=T):T=e[38];let z;e[39]!==I||e[40]!==R?(z=n.jsxs("details",{className:"shrink-0 border-b px-3 py-2",children:[I,R,T]}),e[39]=I,e[40]=R,e[41]=z):z=e[41];let D;e[42]===Symbol.for("react.memo_cache_sentinel")?(D=U=>{const H=U.target;r.current=H.scrollHeight-H.scrollTop-H.clientHeight<80},e[42]=D):D=e[42];let Y;e[43]!==a?(Y=a.hasOlder&&n.jsx("div",{className:"flex justify-center py-2",children:n.jsx(J,{variant:"ghost",size:"xs",disabled:a.loadingOlder,onClick:()=>void a.older(),children:a.loadingOlder?"Loading…":"Load earlier messages"})}),e[43]=a,e[44]=Y):Y=e[44];let F;e[45]!==a.messages.length||e[46]!==a.page?(F=a.page&&a.messages.length===0&&n.jsx(rt,{children:n.jsxs(ct,{children:[n.jsx(It,{variant:"icon",children:n.jsx(es,{})}),n.jsx(dt,{children:"Talk to the crew"}),n.jsx(ut,{children:"Share a discovery, ask a question, or tag someone for their input."})]})}),e[45]=a.messages.length,e[46]=a.page,e[47]=F):F=e[47];let q;if(e[48]!==S||e[49]!==p||e[50]!==o||e[51]!==s||e[52]!==M||e[53]!==C){let U;e[55]!==S||e[56]!==p||e[57]!==o||e[58]!==s||e[59]!==C?(U=H=>n.jsxs(k.Fragment,{children:[H.day!==void 0&&n.jsx(Ct,{day:H.day}),n.jsx(St,{run:H,members:S,handles:p,kinds:o,tints:C,rootId:s})]},H.messages[0].sequence),e[55]=S,e[56]=p,e[57]=o,e[58]=s,e[59]=C,e[60]=U):U=e[60],q=M.map(U),e[48]=S,e[49]=p,e[50]=o,e[51]=s,e[52]=M,e[53]=C,e[54]=q}else q=e[54];let P;e[61]===Symbol.for("react.memo_cache_sentinel")?(P=n.jsx("div",{ref:h}),e[61]=P):P=e[61];let W;e[62]!==q?(W=n.jsxs("div",{role:"log","aria-label":"Shared messages","aria-live":"polite","aria-relevant":"additions",className:"flex flex-col gap-4 px-3 py-3",children:[q,P]}),e[62]=q,e[63]=W):W=e[63];let B;e[64]!==Y||e[65]!==F||e[66]!==W?(B=n.jsxs(ft,{className:"min-h-0 flex-1",onScrollCapture:D,children:[Y,F,W]}),e[64]=Y,e[65]=F,e[66]=W,e[67]=B):B=e[67];let G;e[68]!==v?(G=U=>{U.preventDefault(),v()},e[68]=v,e[69]=G):G=e[69];const K=!!a.error,X=`crew-chat-${s}`;let m;e[70]!==X?(m=n.jsx(Qe,{htmlFor:X,className:"sr-only",children:"Message the crew"}),e[70]=X,e[71]=m):m=e[71];const j=`crew-chat-${s}`,$=!((Ue=a.page)!=null&&Ue.canPost),V=!!a.error;let ae;e[72]===Symbol.for("react.memo_cache_sentinel")?(ae=U=>g(U.target.value),e[72]=ae):ae=e[72];let Q;e[73]!==v?(Q=U=>{U.key==="Enter"&&(U.metaKey||U.ctrlKey)&&!U.nativeEvent.isComposing&&(U.preventDefault(),v())},e[73]=v,e[74]=Q):Q=e[74];let ee;e[75]!==f||e[76]!==j||e[77]!==$||e[78]!==V||e[79]!==Q?(ee=n.jsx(Mt,{id:j,value:f,rows:3,maxLength:$t,placeholder:"Message the crew… use @ to tag an agent",disabled:$,"aria-invalid":V,onChange:ae,onKeyDown:Q}),e[75]=f,e[76]=j,e[77]=$,e[78]=V,e[79]=Q,e[80]=ee):ee=e[80];let te;e[81]!==a.error?(te=a.error&&n.jsx("p",{role:"alert",className:"text-xs text-destructive",children:a.error}),e[81]=a.error,e[82]=te):te=e[82];let se;e[83]!==K||e[84]!==m||e[85]!==ee||e[86]!==te?(se=n.jsxs(Je,{"data-invalid":K,children:[m,ee,te]}),e[83]=K,e[84]=m,e[85]=ee,e[86]=te,e[87]=se):se=e[87];const re=((Ge=a.page)==null?void 0:Ge.canPost)===!1?"You have read access to this crew.":"⌘ / Ctrl + Enter to send";let Z;e[88]!==re?(Z=n.jsx(Rt,{className:"flex-1",children:re}),e[88]=re,e[89]=Z):Z=e[89];let ce;e[90]!==((Ke=a.page)==null?void 0:Ke.canPost)||e[91]!==a.posting||e[92]!==f?(ce=!((Ve=a.page)!=null&&Ve.canPost)||!f.trim()||a.posting,e[90]=(Xe=a.page)==null?void 0:Xe.canPost,e[91]=a.posting,e[92]=f,e[93]=ce):ce=e[93];let me;e[94]===Symbol.for("react.memo_cache_sentinel")?(me=n.jsx(ss,{"data-icon":"inline-start"}),e[94]=me):me=e[94];const Re=a.posting?"Sending…":"Send";let ge;e[95]!==ce||e[96]!==Re?(ge=n.jsxs(J,{type:"submit",size:"sm",disabled:ce,children:[me,Re]}),e[95]=ce,e[96]=Re,e[97]=ge):ge=e[97];let xe;e[98]!==Z||e[99]!==ge?(xe=n.jsxs("div",{className:"flex items-center gap-2",children:[Z,ge]}),e[98]=Z,e[99]=ge,e[100]=xe):xe=e[100];let we;e[101]!==se||e[102]!==xe?(we=n.jsxs(et,{className:"gap-2",children:[se,xe]}),e[101]=se,e[102]=xe,e[103]=we):we=e[103];let be;e[104]!==G||e[105]!==we?(be=n.jsx("form",{className:"shrink-0 border-t p-3",onSubmit:G,children:we}),e[104]=G,e[105]=we,e[106]=be):be=e[106];let Ie;return e[107]!==z||e[108]!==B||e[109]!==be?(Ie=n.jsxs("section",{"aria-label":"Crew chat",className:"flex h-full min-h-0 flex-col",children:[z,B,be]}),e[107]=z,e[108]=B,e[109]=be,e[110]=Ie):Ie=e[110],Ie}function ms(t){return t.listening}function ps(t){return[t.sessionId,t]}const fe={working:"bg-success ring-2 ring-success/30","needs-you":"bg-warning",done:"bg-muted-foreground/50",failed:"bg-destructive",unreachable:"border border-muted-foreground/60"};function pt(t){const e=new Date(t),s=e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return e.toDateString()===new Date().toDateString()?s:`${e.toLocaleDateString([],{month:"short",day:"numeric"})}, ${s}`}function he(t){if(t.status==="deferred")return"needs-you";switch(t.outcome){case"needs_input":return"needs-you";case"running":return"working";case"error":return"failed";case"unreachable":case"not_found":return"unreachable";default:return"done"}}function tt(t,e){var s,i;return{sessionId:t.sessionId,dirName:((s=t.address)==null?void 0:s.dirName)??"",fileName:((i=t.address)==null?void 0:i.fileName)??"",projectShortName:"",lastModified:t.lastActivityAt??"",lastActivityAt:t.lastActivityAt,size:0,cwd:t.cwd,customTitle:t.customTitle,aiTitle:t.aiTitle,firstUserMessage:t.firstUserMessage,...t.parentId&&{crew:{rootId:e,parentId:t.parentId,startedAt:t.startedAt??0,...t.name&&{name:t.name}}}}}function gs(t,e,s){var a;const i=((a=[...e.values()].find(f=>f.parentId===null))==null?void 0:a.sessionId)??t.sessionId,l=s[t.sessionId],o=tt(t,i);if(!t.parentId)return Tt(o,l);const c=e.get(t.parentId);return At(o,{customName:l,parent:c&&tt(c,i)})}function xs(t){const e=new Map;for(const o of t.members){if(!o.parentId)continue;const c=e.get(o.parentId);c?c.push(o):e.set(o.parentId,[o])}const s=[],i=new Set,l=(o,c)=>{var f;const a=[...e.get(o)??[]].sort((g,h)=>(g.startedAt??0)-(h.startedAt??0));for(const g of a)i.has(g.sessionId)||(i.add(g.sessionId),s.push({member:g,depth:c,children:((f=e.get(g.sessionId))==null?void 0:f.length)??0}),l(g.sessionId,c+1))};l(t.rootId,0);for(const o of t.members)o.parentId&&!i.has(o.sessionId)&&(i.add(o.sessionId),s.push({member:o,depth:0,children:0}));return s}function ws(t){const e=({member:s,pending:i})=>i.askedAt??(Date.parse(s.lastActivityAt??"")||0);return t.members.flatMap(s=>s.waiting.map(i=>({member:s,pending:i}))).sort((s,i)=>e(s)-e(i))}function bs(t){const e={size:0,working:0,needsYou:0,done:0,failed:0,unreachable:0,unreadResults:0};for(const s of t.members){if(!s.parentId)continue;e.size++;const i=he(s);i==="working"?e.working++:i==="needs-you"?e.needsYou++:i==="failed"?e.failed++:i==="unreachable"?e.unreachable++:e.done++,$e(s)&&e.unreadResults++}return e}function $e(t){return!!(t.result&&t.result.state!=="running"&&!t.result.acknowledged)}function We(t){const[e]=t.waiting;switch(he(t)){case"needs-you":return(e==null?void 0:e.kind)==="permission"?`Waiting on a permission · ${e.toolName}`:(e==null?void 0:e.kind)==="question"?"Asked a question":!e&&t.status==="deferred"?"Awaiting permission review":"Plan to review";case"working":return t.status==="tool_use"&&t.toolName?t.toolName:t.status==="thinking"?"Thinking":t.status==="compacting"?"Compacting":t.status==="awaiting_agents"?"Waiting on its agents":"Working";case"failed":return t.error?`Failed · ${t.error}`:"Failed";case"unreachable":return t.device?`${t.device.name} is not answering`:"Not found";default:return $e(t)?"Finished · result unread":"Finished"}}const le=196,ne=86,de=40,ve=12,vs=28,Se=6,st=8,pe=10,js=6,Me=28,De=36;function gt(t){const e=he(t);return e==="working"||e==="needs-you"}function ys(t){const e={all:t.members.length,active:0,working:0,needsYou:0};for(const s of t.members){const i=he(s);i==="working"?e.working++:i==="needs-you"&&e.needsYou++}return e.active=e.working+e.needsYou,e}const nt=(t,e)=>(t.startedAt??0)-(e.startedAt??0)||t.sessionId.localeCompare(e.sessionId);function xt(t){const e=new Map(t.members.map(l=>[l.sessionId,l])),s=new Map,i=[];for(const l of t.members){const o=l.parentId&&l.sessionId!==t.rootId?e.get(l.parentId):void 0;if(!o){i.push(l);continue}const c=s.get(o.sessionId);c?c.push(l):s.set(o.sessionId,[l])}for(const l of s.values())l.sort(nt);return i.sort((l,o)=>+(o.sessionId===t.rootId)-+(l.sessionId===t.rootId)||nt(l,o)),{roots:i,childrenOf:s}}function Ns(t,e){if(e==="all")return new Set(t.members.map(l=>l.sessionId));const s=new Map(t.members.map(l=>[l.sessionId,l])),i=new Set;for(const l of t.members){if(!gt(l))continue;let o=l;for(;o&&!i.has(o.sessionId);)i.add(o.sessionId),o=o.sessionId===t.rootId||!o.parentId?void 0:s.get(o.parentId)}return i}function Is(t){const{roots:e,childrenOf:s}=xt(t),i=new Set;let l=0;const o=e.map(c=>({member:c,depth:0}));for(;o.length>0;){const{member:c,depth:a}=o.pop();if(!i.has(c.sessionId)){i.add(c.sessionId),l=Math.max(l,a);for(const f of s.get(c.sessionId)??[])o.push({member:f,depth:a+1})}}return l}function ks(t){return(t+1)*le+t*de}function Cs(t,e,s,{group:i=!1,stacked:l}={}){const{roots:o,childrenOf:c}=xt(t),a=Ns(t,e),f=y=>(c.get(y)??[]).filter(M=>a.has(M.sessionId)),g=(l==null?void 0:l.cardWidth)??le,h=[],r=[],w=[],u=new Set;let x=0,d=0;const p=y=>{const M={count:0,working:0,needsYou:0},L=new Set(u),A=[...f(y)];for(;A.length>0;){const O=A.pop();if(L.has(O.sessionId))continue;L.add(O.sessionId),M.count++;const v=he(O);v==="working"?M.working++:v==="needs-you"&&M.needsYou++,A.push(...f(O.sessionId))}return M},N=y=>f(y).filter(M=>!u.has(M.sessionId)),C=y=>N(y.sessionId).length===0||s.has(y.sessionId),b=(y,M,L)=>{u.add(y.sessionId);const A=N(y.sessionId),O=A.length>0&&s.has(y.sessionId),v=O?[]:A,_=i&&!l&&v.length>=st?v.filter(C):[],I=_.length>=st?_:[],E=new Set(I),R=v.filter(D=>!E.has(D)),T={member:y,depth:M,x:(L==null?void 0:L.x)??M*(l?Me:le+de),y:(L==null?void 0:L.y)??x+(R.length===0&&I.length>0?pe:0),childCount:A.length,collapsed:O,hidden:O?p(y.sessionId):{count:0,working:0,needsYou:0},context:e==="active"&&!gt(y),grouped:!!L};if(h.push(T),d=Math.max(d,T.x+g+(l&&A.length>0?De:0)),l){x+=ne+ve;const D=v.map(Y=>b(Y,M+1));return D.length>0&&r.push({parentId:y.sessionId,path:Ms(T.x,T.y,D)}),T.y}if(O){const D=T.y+ne/2;r.push({parentId:y.sessionId,path:`M${T.x+le} ${D}H${T.x+le+de/2}`})}if(L)return T.y;if(v.length===0)return x+=ne+ve,T.y;const z=R.map(D=>b(D,M+1));return I.length>0&&z.push(S(y.sessionId,I,M+1)+pe),r.push({parentId:y.sessionId,path:Ss(T.x+le,T.y,z)}),T.y},S=(y,M,L)=>{const A=Math.min(js,Math.max(2,Math.ceil(Math.sqrt(M.length/1.5)))),O=Math.ceil(M.length/A),v={parentId:y,x:L*(le+de),y:x,width:A*le+(A-1)*de+2*pe,height:O*ne+(O-1)*ve+2*pe};return w.push(v),M.forEach((_,I)=>b(_,L,{x:v.x+pe+I%A*(le+de),y:v.y+pe+Math.floor(I/A)*(ne+ve)})),d=Math.max(d,v.x+v.width),x+=v.height+ve,v.y};for(const y of o)!a.has(y.sessionId)||u.has(y.sessionId)||(h.length>0&&(x+=vs),b(y,0));return{orientation:l?"stacked":"across",cardWidth:g,nodes:h,edges:r,groups:w,width:d,height:Math.max(0,x-ve)}}function Ss(t,e,s){const i=e+ne/2,l=[`M${t} ${i}H${t+de}`];for(const o of s)o!==e&&l.push(wt(t,i,o+ne/2));return l.join("")}function wt(t,e,s){const i=t+de/2;return`M${i} ${e}V${s-Se}Q${i} ${s} ${i+Se} ${s}H${t+de}`}function Ms(t,e,s){return s.map(i=>bt(t,e,i)).join("")}function bt(t,e,s){const i=t+Me/2,l=s+ne/2;return`M${i} ${e+ne}V${l-Se}Q${i} ${l} ${i+Se} ${l}H${t+Me}`}function $s(t,e){const s=new Map(t.nodes.map(c=>[c.member.sessionId,c])),i=new Map(t.groups.map(c=>[c.parentId,c]));let l=e?s.get(e):void 0;const o=[];for(;l!=null&&l.member.parentId;){const c=l.member.parentId,a=s.get(c);if(!a||a.depth!==l.depth-1)break;if(t.orientation==="stacked"){o.unshift(bt(a.x,a.y,l.y)),l=a;continue}const f=a.x+le,g=a.y+ne/2,h=l.grouped?i.get(c):void 0,r=(h?h.y+pe:l.y)+ne/2;o.unshift(r===g?`M${f} ${g}H${f+de}`:`M${f} ${g}H${f+de/2}${wt(f,g,r)}`),l=a}return o.length>0?o.join(""):null}const ie=14,Fe=.25,at=1.5,Rs=.7,Ce=1.2,Ts=56,As=900,Os=.85,Es=320,Ee={all:new Set,active:new Set};function Ls(t){const[e,s]=Ot(Et("crew-map-filter"),"all"),i=e==="active"?"active":"all",[l,o]=k.useState({rootId:t,folds:Ee}),c=k.useRef(new Map),a=l.rootId===t?l.folds:Ee,f=k.useCallback(h=>o(r=>{const w=r.rootId===t?r.folds:Ee,u=new Set(w[i]);return u.delete(h)||u.add(h),{rootId:t,folds:{...w,[i]:u}}}),[i,t]),g=k.useMemo(()=>({get current(){return c.current.get(t)??null},set current(h){c.current.set(t,h)}}),[t]);return{filter:i,setFilter:s,collapsed:a[i],toggle:f,viewport:g}}function _s(t){const e=ue.c(86),{crew:s,hereId:i,controls:l,kinds:o,nameOf:c,onOpen:a}=t,[f,g]=k.useState(!1),{filter:h,collapsed:r,toggle:w}=l;let u,x,d,p,N,C,b,S,y,M,L,A,O,v,_,I;if(e[0]!==r||e[1]!==l||e[2]!==s||e[3]!==f||e[4]!==h||e[5]!==i||e[6]!==o||e[7]!==c||e[8]!==a||e[9]!==w){let W;e[26]!==s.rootId?(W=j=>j.sessionId===s.rootId,e[26]=s.rootId,e[27]=W):W=e[27];const B=s.members.find(W);let G;e[28]!==r||e[29]!==l||e[30]!==s||e[31]!==h||e[32]!==i||e[33]!==o||e[34]!==c||e[35]!==w?(G=(j,$)=>n.jsx(Ps,{crew:s,collapsed:r,groups:!j,filter:h,hereId:i,kinds:o,nameOf:c,memory:j,onOpen:$,onToggle:w,onShowAll:()=>l.setFilter("all")}),e[28]=r,e[29]=l,e[30]=s,e[31]=h,e[32]=i,e[33]=o,e[34]=c,e[35]=w,e[36]=G):G=e[36],d=G,C="flex h-full min-h-0 flex-col";let K;e[37]!==l||e[38]!==s?(K=n.jsx(ot,{crew:s,controls:l}),e[37]=l,e[38]=s,e[39]=K):K=e[39];let X;e[40]===Symbol.for("react.memo_cache_sentinel")?(X=n.jsx("span",{className:"flex-1"}),e[40]=X):X=e[40];let m;e[41]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(J,{variant:"ghost",size:"icon-xs","aria-label":"Expand the map",title:"Expand the map",onClick:()=>g(!0),children:n.jsx(ns,{"data-icon":"inline-start"})}),e[41]=m):m=e[41],e[42]!==K?(b=n.jsxs("div",{className:"flex shrink-0 items-center gap-2 px-3 pb-2",children:[K,X,m]}),e[42]=K,e[43]=b):b=e[43],e[44]!==d||e[45]!==l.viewport||e[46]!==a?(S=d(l.viewport,a),e[44]=d,e[45]=l.viewport,e[46]=a,e[47]=S):S=e[47],x=Lt,I=f,N=g,u=_t,A=!0,O="flex h-[calc(100dvh-1rem)] w-[calc(100vw-1rem)] max-w-none flex-col gap-0 overflow-hidden p-0 sm:h-[calc(100dvh-4rem)] sm:w-[calc(100vw-4rem)] sm:max-w-none",e[48]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx(zt,{className:"sr-only",children:"Crew map"}),_=n.jsx(Dt,{className:"sr-only",children:"Every session in this crew, from the one that started it."}),e[48]=v,e[49]=_):(v=e[48],_=e[49]),M="flex h-12 shrink-0 items-center gap-3 pl-4 pr-14",e[50]===Symbol.for("react.memo_cache_sentinel")?(L=n.jsx(ht,{"aria-hidden":"true",className:"size-4 shrink-0 text-muted-foreground"}),e[50]=L):L=e[50],p="min-w-0 truncate text-sm font-medium",y=B?c(B):"Crew",e[0]=r,e[1]=l,e[2]=s,e[3]=f,e[4]=h,e[5]=i,e[6]=o,e[7]=c,e[8]=a,e[9]=w,e[10]=u,e[11]=x,e[12]=d,e[13]=p,e[14]=N,e[15]=C,e[16]=b,e[17]=S,e[18]=y,e[19]=M,e[20]=L,e[21]=A,e[22]=O,e[23]=v,e[24]=_,e[25]=I}else u=e[10],x=e[11],d=e[12],p=e[13],N=e[14],C=e[15],b=e[16],S=e[17],y=e[18],M=e[19],L=e[20],A=e[21],O=e[22],v=e[23],_=e[24],I=e[25];let E;e[51]!==p||e[52]!==y?(E=n.jsx("span",{className:p,children:y}),e[51]=p,e[52]=y,e[53]=E):E=e[53];let R;e[54]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx("span",{className:"flex-1"}),e[54]=R):R=e[54];let T;e[55]!==l||e[56]!==s?(T=n.jsx(ot,{crew:s,controls:l}),e[55]=l,e[56]=s,e[57]=T):T=e[57];let z;e[58]!==E||e[59]!==T||e[60]!==M||e[61]!==L?(z=n.jsxs("header",{className:M,children:[L,E,R,T]}),e[58]=E,e[59]=T,e[60]=M,e[61]=L,e[62]=z):z=e[62];let D;e[63]!==a?(D=W=>{g(!1),a(W)},e[63]=a,e[64]=D):D=e[64];let Y;e[65]!==d||e[66]!==D?(Y=d(null,D),e[65]=d,e[66]=D,e[67]=Y):Y=e[67];let F;e[68]!==u||e[69]!==z||e[70]!==Y||e[71]!==A||e[72]!==O||e[73]!==v||e[74]!==_?(F=n.jsxs(u,{showCloseButton:A,className:O,children:[v,_,z,Y]}),e[68]=u,e[69]=z,e[70]=Y,e[71]=A,e[72]=O,e[73]=v,e[74]=_,e[75]=F):F=e[75];let q;e[76]!==x||e[77]!==N||e[78]!==F||e[79]!==I?(q=n.jsx(x,{open:I,onOpenChange:N,children:F}),e[76]=x,e[77]=N,e[78]=F,e[79]=I,e[80]=q):q=e[80];let P;return e[81]!==C||e[82]!==b||e[83]!==S||e[84]!==q?(P=n.jsxs("div",{className:C,children:[b,S,q]}),e[81]=C,e[82]=b,e[83]=S,e[84]=q,e[85]=P):P=e[85],P}function ot(t){const e=ue.c(3),{crew:s,controls:i}=t;let l;if(e[0]!==i||e[1]!==s){const o=ys(s),c=[{id:"all",label:"All",count:o.all,hint:"Every session in the crew"},{id:"active",label:"Active",count:o.active,hint:"Sessions working or waiting on you, and the sessions that started them"}];l=n.jsx("div",{role:"radiogroup","aria-label":"Show on the map",className:"flex shrink-0 gap-0.5 rounded-full border bg-background p-0.5",children:c.map(a=>{const{id:f,label:g,count:h,hint:r}=a;return n.jsxs("button",{type:"button",role:"radio","aria-checked":i.filter===f,"aria-label":`${g}, ${vt(h)}`,title:r,onClick:()=>i.setFilter(f),className:oe("inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",i.filter===f&&"bg-accent text-foreground"),children:[g,n.jsx("span",{className:"tabular-nums text-muted-foreground",children:h})]},f)})}),e[0]=i,e[1]=s,e[2]=l}else l=e[2];return l}function vt(t){return`${t} ${t===1?"session":"sessions"}`}function Le(t,e,s){return t.orientation==="stacked"?{scale:e,left:ie,top:ie}:{scale:e,left:Math.max(ie,(s.width-t.width*e)/2),top:Math.max(ie,Math.min((s.height-t.height*e)/2,s.height*.12))}}function zs(t,e,s){return{width:Math.max(s.width,e.left+t.width*e.scale+ie),height:Math.max(s.height,e.top+t.height*e.scale+Ts)}}function lt(t,e,{widthOnly:s=!1}={}){if(t.width===0||e.width===0)return 1;const i=(e.width-2*ie)/t.width,l=s?i:Math.min(i,(e.height-2*ie)/t.height);return Pe(l,Fe,1)}const Pe=(t,e,s)=>Math.min(s,Math.max(e,t));function Ds(t,e,s,i,l){var w;const o=new Map(e.layout.nodes.map(u=>[u.member.sessionId,u])),c=new Map(s.nodes.map(u=>[u.member.sessionId,u]));if(e.frame===i&&o.size===c.size&&s.nodes.every(u=>{const x=o.get(u.member.sessionId);return x!==void 0&&x.x===u.x&&x.y===u.y}))return null;const f=u=>({x:e.frame.left+u.x*e.frame.scale-t.left,y:e.frame.top+u.y*e.frame.scale-t.top}),g=l&&o.has(l)&&c.has(l)?l:(w=e.layout.nodes.filter(u=>c.has(u.member.sessionId)).map(u=>({node:u,screen:f(u)})).filter(({screen:u})=>u.y+ne*e.frame.scale>0&&u.x+e.layout.cardWidth*e.frame.scale>0).sort((u,x)=>u.screen.y-x.screen.y||u.screen.x-x.screen.x)[0])==null?void 0:w.node.member.sessionId;if(!g)return null;const h=f(o.get(g)),r=c.get(g);return{left:i.left+r.x*i.scale-h.x,top:i.top+r.y*i.scale-h.y}}function Fs(t,e,s,i){const l=new Map(t.nodes.map(x=>[x.member.sessionId,x])),o=e?l.get(e):void 0;if(!o)return{left:0,top:0};const{scale:c}=s,a=s.left+o.x*c,f=s.top+o.y*c,g=a+t.cardWidth*c,h=f+ne*c;if(g<=i.clientWidth&&h<=i.clientHeight)return{left:0,top:0};const r=o.member.parentId&&l.get(o.member.parentId)||o;let w=s.left+Math.min(r.x,o.x)*c-ie,u=s.top+Math.min(r.y,o.y)*c-ie;return g-w>i.clientWidth&&(w=a-ie),h-u>i.clientHeight&&(u=f-i.clientHeight/3),{left:Math.max(0,w),top:Math.max(0,u)}}function Ps({crew:t,collapsed:e,groups:s,filter:i,hereId:l,kinds:o,nameOf:c,memory:a,onOpen:f,onToggle:g,onShowAll:h}){const r=k.useRef(null),[w,u]=k.useState({width:0,height:0}),x=s&&w.width>=As,d=k.useMemo(()=>Is(t),[t]),p=w.width-2*ie,N=!s&&w.width>0&&ks(d)*Os>p,C=N?Pe(p-d*Me-De,le,Es):le,b=k.useMemo(()=>Cs(t,i,e,{group:x,...N&&{stacked:{cardWidth:C}}}),[t,i,e,x,N,C]),[S,y]=k.useState(()=>{var m;return((m=a==null?void 0:a.current)==null?void 0:m.frame)??{scale:1,left:ie,top:ie}}),[M,L]=k.useState(!1),A=k.useRef(null),O=k.useRef(null),v=k.useRef({left:0,top:0}),_=k.useRef(null),I=k.useRef(null),E=zs(b,S,w),{scale:R}=S;k.useLayoutEffect(()=>{const m=r.current;if(!m)return;const j=()=>u(V=>V.width===m.clientWidth&&V.height===m.clientHeight?V:{width:m.clientWidth,height:m.clientHeight});j();const $=new ResizeObserver(j);return $.observe(m),()=>$.disconnect()},[]);const T=k.useCallback(m=>{const j=r.current;a&&j&&(a.current={frame:m,left:j.scrollLeft,top:j.scrollTop})},[a]),z=k.useCallback((m,j)=>{A.current={frame:m,scroll:j},y(m)},[]),D=k.useCallback(m=>{const j=Le(m,Math.max(lt(m,w,{widthOnly:!0}),Rs),w);z(j,()=>{const $=r.current;return $?Fs(m,l,j,$):{left:0,top:0}})},[z,l,w]);k.useLayoutEffect(()=>{const m=r.current;if(w.width===0||!m)return;const j=_.current;if(j){if(j.filter!==i||j.layout.orientation!==b.orientation)D(b);else if(j.layout!==b){const $=Ds(v.current,j,b,S,O.current);$&&(m.scrollLeft=$.left,m.scrollTop=$.top,v.current={left:m.scrollLeft,top:m.scrollTop})}}else{const $=a==null?void 0:a.current;$?z($.frame,()=>({left:$.left,top:$.top})):D(b)}O.current=null,_.current={layout:b,filter:i,frame:S}}),k.useLayoutEffect(()=>{const m=A.current,j=r.current;if(!m||!j||m.frame!==S)return;A.current=null;const{left:$,top:V}=m.scroll();j.scrollLeft=$,j.scrollTop=V,v.current={left:j.scrollLeft,top:j.scrollTop},T(S)});const Y=k.useRef(l);k.useEffect(()=>{var m,j;Y.current!==l&&(Y.current=l,l&&((j=(m=r.current)==null?void 0:m.querySelector(`[data-crew-map-card="${CSS.escape(l)}"]`))==null||j.scrollIntoView({block:"nearest",inline:"nearest",behavior:"smooth"})))},[l]);const F=k.useCallback((m,j)=>{var ce;const $=r.current,V=((ce=A.current)==null?void 0:ce.frame.scale)??R,ae=Pe(V*m,Fe,at);if(!$||ae===V)return;const Q=$.getBoundingClientRect(),ee=j?j.clientX-Q.left:$.clientWidth/2,te=j?j.clientY-Q.top:$.clientHeight/2,se=($.scrollLeft+ee-S.left)/R,re=($.scrollTop+te-S.top)/R,Z=Le(b,ae,w);z(Z,()=>({left:Z.left+se*Z.scale-ee,top:Z.top+re*Z.scale-te}))},[z,S.left,S.top,b,R,w]),q=k.useRef(F);k.useLayoutEffect(()=>{q.current=F}),k.useEffect(()=>{const m=r.current;if(!m)return;const j=$=>{!$.ctrlKey&&!$.metaKey||($.preventDefault(),q.current(Math.exp(-$.deltaY*.01),$))};return m.addEventListener("wheel",j,{passive:!1}),()=>m.removeEventListener("wheel",j)},[]);const P=m=>{const j=r.current;!j||m.pointerType!=="mouse"||m.button!==0||m.target.closest("button")||(I.current={pointerId:m.pointerId,x:m.clientX,y:m.clientY,left:j.scrollLeft,top:j.scrollTop},j.setPointerCapture(m.pointerId),L(!0))},W=m=>{const j=I.current,$=r.current;!j||!$||j.pointerId!==m.pointerId||($.scrollLeft=j.left-(m.clientX-j.x),$.scrollTop=j.top-(m.clientY-j.y))},B=m=>{var j,$;((j=I.current)==null?void 0:j.pointerId)===m.pointerId&&(I.current=null,($=r.current)==null||$.releasePointerCapture(m.pointerId),L(!1))},G=k.useMemo(()=>$s(b,l),[b,l]),K=b.nodes.length===0,X=b.orientation==="stacked"?b.cardWidth+De/2:le+de/2;return n.jsxs("div",{className:"relative min-h-0 flex-1 border-t",children:[n.jsx("div",{ref:r,role:"region","aria-label":"Crew map","data-crew-map-layout":b.orientation,onScroll:m=>{v.current={left:m.currentTarget.scrollLeft,top:m.currentTarget.scrollTop},A.current||T(S)},onPointerDown:P,onPointerMove:W,onPointerUp:B,onPointerCancel:B,onKeyDown:m=>{m.target===m.currentTarget&&(m.key==="+"||m.key==="="?F(Ce):m.key==="-"&&F(1/Ce))},tabIndex:-1,className:oe("absolute inset-0 overflow-auto overscroll-contain outline-none [touch-action:pan-x_pan-y]","bg-muted/30 bg-local bg-[radial-gradient(circle,var(--border)_1px,transparent_1px)] bg-size-[18px_18px]",M?"cursor-grabbing select-none":"cursor-grab"),children:K?n.jsxs(rt,{className:"h-full",children:[n.jsxs(ct,{children:[n.jsx(dt,{children:"Nothing is active"}),n.jsx(ut,{className:"text-xs",children:"No session in this crew is working or waiting on you."})]}),n.jsx(J,{variant:"outline",size:"xs",onClick:h,children:"Show all sessions"})]}):n.jsx("div",{className:"relative",style:{width:E.width,height:E.height},children:n.jsxs("div",{className:"absolute origin-top-left",style:{left:S.left,top:S.top,width:b.width,height:b.height,transform:`scale(${R})`},children:[b.groups.map(m=>n.jsx("div",{"aria-hidden":"true",className:"absolute rounded-xl border border-dashed border-muted-foreground/25 bg-muted/25",style:{left:m.x,top:m.y,width:m.width,height:m.height}},m.parentId)),n.jsxs("svg",{"aria-hidden":"true",width:b.width,height:b.height,className:"pointer-events-none absolute inset-0 overflow-visible",fill:"none",children:[b.edges.map(m=>n.jsx("path",{d:m.path,className:"stroke-muted-foreground/35",strokeWidth:1.25},m.parentId)),G&&n.jsx("path",{d:G,className:"stroke-foreground/55",strokeWidth:1.5})]}),n.jsx("ul",{"aria-label":"Sessions",className:"absolute inset-0",children:b.nodes.map(m=>n.jsx(Hs,{node:m,width:b.cardWidth,toggleLeft:X,here:m.member.sessionId===l,kind:o.get(m.member.sessionId),name:c(m.member),onOpen:f,onToggle:j=>{O.current=j,g(j)}},m.member.sessionId))})]})})}),!K&&n.jsxs("div",{className:"absolute bottom-2.5 right-2.5 flex items-center gap-0.5 rounded-lg border bg-popover p-0.5 shadow-sm",children:[n.jsx(J,{variant:"ghost",size:"icon-xs","aria-label":"Zoom out",title:"Zoom out",disabled:R<=Fe,onClick:()=>F(1/Ce),children:n.jsx(mt,{"data-icon":"inline-start"})}),n.jsxs(J,{variant:"ghost",size:"xs","aria-label":"Actual size",title:"Actual size",className:"min-w-11 px-1 tabular-nums text-muted-foreground",onClick:()=>F(1/R),children:[Math.round(R*100),"%"]}),n.jsx(J,{variant:"ghost",size:"icon-xs","aria-label":"Zoom in",title:"Zoom in",disabled:R>=at,onClick:()=>F(Ce),children:n.jsx(as,{"data-icon":"inline-start"})}),n.jsx("span",{className:"mx-0.5 h-4 w-px bg-border","aria-hidden":"true"}),n.jsx(J,{variant:"ghost",size:"xs",title:"Fit the whole crew on screen",className:"px-1.5 text-muted-foreground",onClick:()=>z(Le(b,lt(b,w),w),()=>({left:0,top:0})),children:"Fit"})]})]})}const Ys={"needs-you":"border-warning/60 bg-[color-mix(in_oklch,var(--warning)_7%,var(--card))]",failed:"border-destructive/45",unreachable:"border-dashed"},qs={"needs-you":"text-warning",failed:"text-destructive"};function Ws(t){var s,i;const e=(s=t.pullRequests)==null?void 0:s.at(-1);return[t.model&&Ye(t.model),(i=t.device)==null?void 0:i.name,e&&`#${e.number}`,t.lastActivityAt&&qe(t.lastActivityAt)].filter(Boolean).join(" · ")}function Hs(t){const e=ue.c(75),{node:s,width:i,toggleLeft:l,here:o,kind:c,name:a,onOpen:f,onToggle:g}=t,{member:h}=s;let r;e[0]!==h?(r=he(h),e[0]=h,e[1]=r):r=e[1];const w=r;let u;e[2]!==h?(u=We(h),e[2]=h,e[3]=u):u=e[3];const x=u;let d;e[4]!==c?(d=c?Ft(c):os,e[4]=c,e[5]=d):d=e[5];const p=d;let N;e[6]!==h?(N=Ws(h),e[6]=h,e[7]=N):N=e[7];const C=N,b=s.context&&"shown because a session it started is active";let S;e[8]!==x||e[9]!==a||e[10]!==b?(S=[a,x,b].filter(Boolean),e[8]=x,e[9]=a,e[10]=b,e[11]=S):S=e[11];const y=S.join(", ");let M;e[12]!==s.x||e[13]!==s.y||e[14]!==i?(M={left:s.x,top:s.y,width:i,height:ne},e[12]=s.x,e[13]=s.y,e[14]=i,e[15]=M):M=e[15];const L=h.sessionId,A=o?"true":void 0;let O;e[16]!==h||e[17]!==f?(O=()=>f(h),e[16]=h,e[17]=f,e[18]=O):O=e[18];const v=Ys[w],_=o&&"outline-solid outline-[1.5px] outline-offset-2 outline-foreground/70",I=s.context&&"opacity-60 hover:opacity-100 focus-visible:opacity-100";let E;e[19]!==v||e[20]!==_||e[21]!==I?(E=oe("flex size-full cursor-pointer flex-col justify-center gap-1 rounded-lg border bg-card px-2.5 py-2 text-left shadow-xs outline-none","transition-[border-color,opacity,box-shadow] hover:border-foreground/25 hover:shadow-sm focus-visible:ring-2 focus-visible:ring-ring",v,_,I),e[19]=v,e[20]=_,e[21]=I,e[22]=E):E=e[22];let R;e[23]!==y||e[24]!==h.sessionId||e[25]!==w||e[26]!==O||e[27]!==E||e[28]!==A?(R=n.jsx("button",{type:"button","data-crew-map-card":L,"data-crew-map-state":w,"aria-current":A,"aria-label":y,onClick:O,className:E}),e[23]=y,e[24]=h.sessionId,e[25]=w,e[26]=O,e[27]=E,e[28]=A,e[29]=R):R=e[29];let T;e[30]!==p?(T=n.jsx(p,{"aria-hidden":"true",className:"mt-[3px] size-3.5 shrink-0 text-muted-foreground"}),e[30]=p,e[31]=T):T=e[31];let z;e[32]!==a?(z=n.jsx("span",{className:"line-clamp-2 min-w-0 flex-1 text-[13px]/[18px] font-medium",children:a}),e[32]=a,e[33]=z):z=e[33];let D;e[34]!==T||e[35]!==z?(D=n.jsxs("span",{className:"flex min-w-0 items-start gap-1.5",children:[T,z]}),e[34]=T,e[35]=z,e[36]=D):D=e[36];const Y=fe[w];let F;e[37]!==Y?(F=oe("size-1.5 shrink-0 rounded-full",Y),e[37]=Y,e[38]=F):F=e[38];let q;e[39]!==F?(q=n.jsx("span",{className:F,"aria-hidden":"true"}),e[39]=F,e[40]=q):q=e[40];let P;e[41]!==h||e[42]!==w?(P=$e(h)?"text-warning":qs[w],e[41]=h,e[42]=w,e[43]=P):P=e[43];let W;e[44]!==P?(W=oe("min-w-0 truncate text-muted-foreground",P),e[44]=P,e[45]=W):W=e[45];let B;e[46]!==x||e[47]!==W?(B=n.jsx("span",{className:W,children:x}),e[46]=x,e[47]=W,e[48]=B):B=e[48];let G;e[49]!==q||e[50]!==B?(G=n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-xs",children:[q,B]}),e[49]=q,e[50]=B,e[51]=G):G=e[51];let K;e[52]!==o||e[53]!==C?(K=(C||o)&&n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-[11.5px] tabular-nums text-muted-foreground/75",children:[n.jsx("span",{className:"min-w-0 flex-1 truncate",children:C}),o&&n.jsx("span",{className:"shrink-0 font-medium text-foreground/70",children:"You are here"})]}),e[52]=o,e[53]=C,e[54]=K):K=e[54];let X;e[55]!==R||e[56]!==D||e[57]!==G||e[58]!==K?(X=n.jsxs(Pt,{delay:700,render:R,children:[D,G,K]}),e[55]=R,e[56]=D,e[57]=G,e[58]=K,e[59]=X):X=e[59];let m;e[60]!==h||e[61]!==a?(m=n.jsx(Yt,{side:"left",align:"start",className:"max-w-72",children:n.jsx(Us,{member:h,name:a})}),e[60]=h,e[61]=a,e[62]=m):m=e[62];let j;e[63]!==X||e[64]!==m?(j=n.jsxs(qt,{children:[X,m]}),e[63]=X,e[64]=m,e[65]=j):j=e[65];let $;e[66]!==a||e[67]!==s||e[68]!==g||e[69]!==l?($=s.childCount>0&&n.jsx(Bs,{node:s,name:a,left:l,onToggle:g}),e[66]=a,e[67]=s,e[68]=g,e[69]=l,e[70]=$):$=e[70];let V;return e[71]!==j||e[72]!==$||e[73]!==M?(V=n.jsxs("li",{className:"group/node absolute",style:M,children:[j,$]}),e[71]=j,e[72]=$,e[73]=M,e[74]=V):V=e[74],V}function Bs(t){const e=ue.c(25),{node:s,name:i,left:l,onToggle:o}=t,{collapsed:c,hidden:a}=s;let f=null;a.needsYou>0?f="needs-you":a.working>0&&(f="working");let g;e[0]!==c||e[1]!==a.count||e[2]!==a.needsYou||e[3]!==a.working||e[4]!==i?(g=c?[`Show the ${vt(a.count)} under ${i}`,a.needsYou>0&&`${a.needsYou} waiting on you`,a.working>0&&`${a.working} working`].filter(Boolean).join(", "):`Fold the sessions under ${i}`,e[0]=c,e[1]=a.count,e[2]=a.needsYou,e[3]=a.working,e[4]=i,e[5]=g):g=e[5];const h=g,r=!c,w=c?void 0:"Fold";let u;e[6]!==s.member.sessionId||e[7]!==o?(u=()=>o(s.member.sessionId),e[6]=s.member.sessionId,e[7]=o,e[8]=u):u=e[8];const x=!c&&"opacity-0 group-hover/node:opacity-100 focus-visible:opacity-100 [@media(hover:none)]:opacity-100";let d;e[9]!==x?(d=oe("absolute z-10 flex h-5 min-w-5 -translate-x-1/2 -translate-y-1/2 cursor-pointer items-center justify-center gap-1 rounded-full border bg-card px-1.5 text-[11px] font-medium tabular-nums text-muted-foreground shadow-xs outline-none","transition-opacity hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",x),e[9]=x,e[10]=d):d=e[10];let p;e[11]!==l?(p={left:l,top:ne/2},e[11]=l,e[12]=p):p=e[12];let N;e[13]!==f||e[14]!==c||e[15]!==a.count?(N=c?n.jsxs(n.Fragment,{children:[f&&n.jsx("span",{className:oe("size-1.5 rounded-full",fe[f]),"aria-hidden":"true"}),"+",a.count]}):n.jsx(mt,{"aria-hidden":"true",className:"size-3"}),e[13]=f,e[14]=c,e[15]=a.count,e[16]=N):N=e[16];let C;return e[17]!==h||e[18]!==r||e[19]!==w||e[20]!==u||e[21]!==d||e[22]!==p||e[23]!==N?(C=n.jsx("button",{type:"button","aria-expanded":r,"aria-label":h,title:w,onClick:u,className:d,style:p,children:N}),e[17]=h,e[18]=r,e[19]=w,e[20]=u,e[21]=d,e[22]=p,e[23]=N,e[24]=C):C=e[24],C}function Us(t){var u,x;const e=ue.c(35),{member:s,name:i}=t;let l;e[0]!==s.firstUserMessage?(l=(u=s.firstUserMessage)==null?void 0:u.replace(/\s+/g," ").trim(),e[0]=s.firstUserMessage,e[1]=l):l=e[1];const o=l;let c;e[2]!==s.cwd?(c=(x=s.cwd)==null?void 0:x.split(/[\\/]/).filter(Boolean).at(-1),e[2]=s.cwd,e[3]=c):c=e[3];const a=c;let f;if(e[4]!==a||e[5]!==s.device||e[6]!==s.model||e[7]!==s.startedAt||e[8]!==s.turnCount){if(f=[],s.model){let d;e[10]!==s.model?(d=Ye(s.model),e[10]=s.model,e[11]=d):d=e[11];let p;e[12]!==d?(p=["Model",d],e[12]=d,e[13]=p):p=e[13],f.push(p)}if(s.device){let d;e[14]!==s.device.name?(d=["Device",s.device.name],e[14]=s.device.name,e[15]=d):d=e[15],f.push(d)}if(a){let d;e[16]!==a?(d=["Folder",a],e[16]=a,e[17]=d):d=e[17],f.push(d)}if(s.startedAt){let d;e[18]!==s.startedAt?(d=pt(s.startedAt),e[18]=s.startedAt,e[19]=d):d=e[19];let p;e[20]!==d?(p=["Started",d],e[20]=d,e[21]=p):p=e[21],f.push(p)}if(s.turnCount){const d=String(s.turnCount);let p;e[22]!==d?(p=["Turns",d],e[22]=d,e[23]=p):p=e[23],f.push(p)}e[4]=a,e[5]=s.device,e[6]=s.model,e[7]=s.startedAt,e[8]=s.turnCount,e[9]=f}else f=e[9];let g;e[24]!==i?(g=n.jsx("p",{className:"font-medium",children:i}),e[24]=i,e[25]=g):g=e[25];let h;e[26]!==i||e[27]!==o?(h=o&&o!==i&&n.jsx("p",{className:"line-clamp-3 text-muted-foreground",children:o}),e[26]=i,e[27]=o,e[28]=h):h=e[28];let r;e[29]!==f?(r=f.length>0&&n.jsx("dl",{className:"grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-0.5",children:f.map(Gs)}),e[29]=f,e[30]=r):r=e[30];let w;return e[31]!==g||e[32]!==h||e[33]!==r?(w=n.jsxs("div",{className:"flex flex-col gap-1.5 py-0.5",children:[g,h,r]}),e[31]=g,e[32]=h,e[33]=r,e[34]=w):w=e[34],w}function Gs(t){const[e,s]=t;return n.jsxs("div",{className:"contents",children:[n.jsx("dt",{className:"text-muted-foreground",children:e}),n.jsx("dd",{className:"truncate tabular-nums",children:s})]},e)}const Ks=4e3;function Vs(t){var d;const[e,s]=k.useState(null),[i,l]=k.useState(null),[o,c]=k.useState(new Set),a=(d=Wt())==null?void 0:d.refresh,f=k.useRef(t),g=k.useRef(new Set);k.useLayoutEffect(()=>(f.current=t,()=>{f.current=null}),[t]);const h=k.useCallback(async p=>{if(t)try{const N=await _e(`/api/session-crew/${encodeURIComponent(t)}`);if(!p())return;if(!N.ok){l(N.status===404?"This session is no longer available.":"Couldn't load the crew.");return}const C=await N.json();if(!p())return;s(b=>JSON.stringify(b)===JSON.stringify(C)?b:C),l(null)}catch{p()&&l("Couldn't load the crew.")}},[t]);it(t?h:null,Ks),k.useEffect(()=>{s(p=>p!=null&&p.members.some(N=>N.sessionId===t)?p:null),l(null),c(new Set)},[t]);const r=k.useCallback(async(p,N,C)=>{const b=`${t}:${p}`;if(g.current.has(b))return;const S=()=>f.current===t;g.current.add(b),c(y=>new Set(y).add(p));try{const y=await N();if(!S())return;if(!y.ok&&y.status!==404){l(C);return}a==null||a(),await h(S)}catch{S()&&l(C)}finally{g.current.delete(b),S()&&c(y=>{const M=new Set(y);return M.delete(p),M})}},[h,a,t]),w=k.useCallback((p,N,C)=>r(N,()=>je("/api/session-respond",{sessionId:p,requestId:N,...C}),"Couldn't send the answer."),[r]),u=k.useCallback((p,N)=>r(N,()=>je("/api/delegated-tasks",{sessionId:p,taskId:N,action:"ack"}),"Couldn't mark the result read."),[r]),x=k.useCallback(p=>r(p.sessionId,()=>{var N;return((N=p.result)==null?void 0:N.state)==="running"&&p.parentId?je("/api/delegated-tasks",{sessionId:p.parentId,taskId:p.result.taskId,action:"cancel"}):je("/api/stop-session",{sessionId:p.sessionId,cancelQueued:!0})},"Couldn't stop the session."),[r]);return{crew:e,error:i,busy:o,respond:w,markRead:u,stop:x}}const Xs=[{id:"all",label:"All"},{id:"working",label:"Working"},{id:"needs-you",label:"Need you"},{id:"done",label:"Done"}];function dn(t){var q;const e=ue.c(37),{context:s,closePanel:i}=t,l=((q=s.session)==null?void 0:q.sessionId)??null,{crew:o,error:c,busy:a,respond:f,markRead:g,stop:h}=Vs(l),{names:r}=Ht(),[w,u]=k.useState("overview");let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=new Set,e[0]=x):x=e[0];const[d,p]=k.useState(x),N=Ls((o==null?void 0:o.rootId)??"");let C;e[1]!==(o==null?void 0:o.members)?(C=new Map(((o==null?void 0:o.members)??[]).map(Js)),e[1]=o==null?void 0:o.members,e[2]=C):C=e[2];const b=C;let S;e[3]!==(o==null?void 0:o.members)?(S=new Map(((o==null?void 0:o.members)??[]).flatMap(Zs)),e[3]=o==null?void 0:o.members,e[4]=S):S=e[4];const y=S;let M;e[5]!==b||e[6]!==r?(M=P=>gs(P,b,r),e[5]=b,e[6]=r,e[7]=M):M=e[7];const L=M;let A;e[8]!==s?(A=P=>{P.address&&P.device?Xt(Zt(P.address.dirName,P.address.fileName,P.device.id)):P.address&&s.openSession?s.openSession(P.address.dirName,P.address.fileName):Jt(P.sessionId)},e[8]=s,e[9]=A):A=e[9];const O=A;let v;e[10]===Symbol.for("react.memo_cache_sentinel")?(v=P=>p(W=>{const B=new Set(W);return B.delete(P)||B.add(P),B}),e[10]=v):v=e[10];const _=v;let I,E,R;e[11]===Symbol.for("react.memo_cache_sentinel")?(I=n.jsx(ht,{"aria-hidden":"true",className:"size-4 text-muted-foreground"}),E=n.jsx("h2",{className:"text-sm font-medium",children:"Crew"}),R=n.jsx("div",{className:"flex-1"}),e[11]=I,e[12]=E,e[13]=R):(I=e[11],E=e[12],R=e[13]);let T;e[14]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsx(cs,{"data-icon":"inline-start"}),e[14]=T):T=e[14];let z;e[15]!==i?(z=n.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-2 px-3",children:[I,E,R,n.jsx(J,{variant:"ghost",size:"icon-sm",onClick:i,"aria-label":"Close crew",children:T})]}),e[15]=i,e[16]=z):z=e[16];let D;e[17]!==c?(D=c&&n.jsx("p",{role:"alert",className:"px-3 pb-2 text-xs text-destructive",children:c}),e[17]=c,e[18]=D):D=e[18];let Y;e[19]!==a||e[20]!==d||e[21]!==o||e[22]!==c||e[23]!==y||e[24]!==N||e[25]!==g||e[26]!==L||e[27]!==O||e[28]!==f||e[29]!==l||e[30]!==h||e[31]!==w?(Y=o?n.jsxs(Bt,{value:w,onValueChange:u,className:"min-h-0 flex-1 grid-rows-[auto_minmax(0,1fr)]",children:[n.jsxs(Ut,{variant:"line",className:"mx-3 mb-1",children:[n.jsx(Te,{value:"overview",children:"Overview"}),n.jsx(Te,{value:"map",children:"Map"}),n.jsx(Te,{value:"chat",children:"Chat"})]}),n.jsx(Ae,{value:"overview",className:"min-h-0",children:n.jsxs(ft,{className:"h-full min-h-0",children:[n.jsx(Qs,{crew:o,hereId:l,nameOf:L,onOpen:O}),n.jsx(tn,{crew:o,busy:a,nameOf:L,onOpen:O,onRespond:f}),n.jsx(sn,{crew:o,hereId:l,busy:a,nameOf:L,onOpen:O,onMarkRead:g,onStop:h,collapsed:d,onToggle:_})]})}),n.jsx(Ae,{value:"map",className:"min-h-0",children:n.jsx(_s,{crew:o,hereId:l,controls:N,kinds:y,nameOf:L,onOpen:O})}),n.jsx(Ae,{value:"chat",keepMounted:!0,className:"min-h-0",children:n.jsx(hs,{rootId:o.rootId,kinds:y,active:w==="chat"},o.rootId)})]}):!c&&n.jsx("p",{className:"px-3 py-6 text-center text-sm text-muted-foreground",children:"Loading the crew…"}),e[19]=a,e[20]=d,e[21]=o,e[22]=c,e[23]=y,e[24]=N,e[25]=g,e[26]=L,e[27]=O,e[28]=f,e[29]=l,e[30]=h,e[31]=w,e[32]=Y):Y=e[32];let F;return e[33]!==z||e[34]!==D||e[35]!==Y?(F=n.jsxs("aside",{"aria-label":"Crew",className:"flex size-full min-h-0 flex-col bg-canvas",children:[z,D,Y]}),e[33]=z,e[34]=D,e[35]=Y,e[36]=F):F=e[36],F}function Zs(t){return t.address?[[t.sessionId,Gt(t.address.dirName)]]:[]}function Js(t){return[t.sessionId,t]}function Qs(t){var v;const e=ue.c(52),{crew:s,hereId:i,nameOf:l,onOpen:o}=t;let c,a,f,g,h,r,w,u,x,d;if(e[0]!==s||e[1]!==i||e[2]!==l||e[3]!==o){let _;e[14]!==s.rootId?(_=T=>T.sessionId===s.rootId,e[14]=s.rootId,e[15]=_):_=e[15];const I=s.members.find(_);let E;e[16]!==s?(E=bs(s),e[16]=s,e[17]=E):E=e[17],d=E;const R=(v=s.members.find(en))==null?void 0:v.startedAt;u="Crew summary",x="border-b px-3 pb-3 pt-1",r="flex items-baseline gap-2",w=I&&n.jsx("button",{type:"button",onClick:()=>o(I),"aria-current":I.sessionId===i?"true":void 0,className:"min-w-0 flex-1 truncate rounded-sm text-left text-sm font-medium outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring",children:l(I)}),c="shrink-0 text-xs tabular-nums text-muted-foreground",a=d.size,f=" ",g=d.size===1?"session":"sessions",h=R?` · since ${pt(R)}`:"",e[0]=s,e[1]=i,e[2]=l,e[3]=o,e[4]=c,e[5]=a,e[6]=f,e[7]=g,e[8]=h,e[9]=r,e[10]=w,e[11]=u,e[12]=x,e[13]=d}else c=e[4],a=e[5],f=e[6],g=e[7],h=e[8],r=e[9],w=e[10],u=e[11],x=e[12],d=e[13];let p;e[18]!==c||e[19]!==a||e[20]!==f||e[21]!==g||e[22]!==h?(p=n.jsxs("span",{className:c,children:[a,f,g,h]}),e[18]=c,e[19]=a,e[20]=f,e[21]=g,e[22]=h,e[23]=p):p=e[23];let N;e[24]!==p||e[25]!==r||e[26]!==w?(N=n.jsxs("div",{className:r,children:[w,p]}),e[24]=p,e[25]=r,e[26]=w,e[27]=N):N=e[27];let C;e[28]!==d.working?(C=d.working>0&&n.jsx(Ne,{dot:fe.working,value:d.working,label:"working"}),e[28]=d.working,e[29]=C):C=e[29];let b;e[30]!==d.needsYou?(b=d.needsYou>0&&n.jsx(Ne,{dot:fe["needs-you"],value:d.needsYou,label:d.needsYou===1?"needs you":"need you"}),e[30]=d.needsYou,e[31]=b):b=e[31];let S;e[32]!==d.done?(S=d.done>0&&n.jsx(Ne,{dot:fe.done,value:d.done,label:"done"}),e[32]=d.done,e[33]=S):S=e[33];let y;e[34]!==d.failed?(y=d.failed>0&&n.jsx(Ne,{dot:fe.failed,value:d.failed,label:"failed"}),e[34]=d.failed,e[35]=y):y=e[35];let M;e[36]!==d.unreachable?(M=d.unreachable>0&&n.jsx(Ne,{dot:fe.unreachable,value:d.unreachable,label:"away"}),e[36]=d.unreachable,e[37]=M):M=e[37];let L;e[38]!==d.unreadResults?(L=d.unreadResults>0&&n.jsxs("span",{className:"ml-auto text-warning",children:[n.jsx("span",{className:"font-medium tabular-nums",children:d.unreadResults})," ",d.unreadResults===1?"result":"results"," unread"]}),e[38]=d.unreadResults,e[39]=L):L=e[39];let A;e[40]!==C||e[41]!==b||e[42]!==S||e[43]!==y||e[44]!==M||e[45]!==L?(A=n.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3.5 gap-y-1 text-xs text-muted-foreground",children:[C,b,S,y,M,L]}),e[40]=C,e[41]=b,e[42]=S,e[43]=y,e[44]=M,e[45]=L,e[46]=A):A=e[46];let O;return e[47]!==N||e[48]!==A||e[49]!==u||e[50]!==x?(O=n.jsxs("section",{"aria-label":u,className:x,children:[N,A]}),e[47]=N,e[48]=A,e[49]=u,e[50]=x,e[51]=O):O=e[51],O}function en(t){return t.parentId!==null}function Ne(t){const e=ue.c(10),{dot:s,value:i,label:l}=t;let o;e[0]!==s?(o=oe("size-1.5 rounded-full",s),e[0]=s,e[1]=o):o=e[1];let c;e[2]!==o?(c=n.jsx("span",{className:o,"aria-hidden":"true"}),e[2]=o,e[3]=c):c=e[3];let a;e[4]!==i?(a=n.jsx("span",{className:"font-medium tabular-nums text-foreground",children:i}),e[4]=i,e[5]=a):a=e[5];let f;return e[6]!==l||e[7]!==c||e[8]!==a?(f=n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[c,a," ",l]}),e[6]=l,e[7]=c,e[8]=a,e[9]=f):f=e[9],f}function tn(t){const e=ue.c(6),{crew:s,busy:i,nameOf:l,onOpen:o,onRespond:c}=t,a=ws(s),[f,g]=k.useState(0);if(a.length===0)return null;const h=Math.min(f,a.length-1),{member:r,pending:w}=a[h],u=a[h+1];let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx("h3",{className:"text-sm font-medium text-foreground",children:"Needs you"}),e[0]=x):x=e[0];let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx("span",{className:"flex-1"}),e[1]=d):d=e[1];let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx("span",{className:oe("size-1.5 shrink-0 rounded-full",fe["needs-you"]),"aria-hidden":"true"}),e[2]=p):p=e[2];const N=w.askedAt?`waiting ${qe(new Date(w.askedAt).toISOString())}`:"waiting";let C;e[3]!==N?(C=n.jsx("span",{className:"ml-auto shrink-0 tabular-nums text-warning",children:N}),e[3]=N,e[4]=C):C=e[4];let b;return e[5]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(ze,{"data-icon":"inline-end"}),e[5]=b):b=e[5],n.jsxs("section",{"aria-label":"Needs you",className:"border-b px-3 py-2.5",children:[n.jsxs("div",{className:"mb-2 flex items-center gap-2 text-xs text-muted-foreground",children:[x,n.jsx("span",{className:"tabular-nums",children:a.length}),d,a.length>1&&n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"tabular-nums",children:[h+1," of ",a.length]}),n.jsx(J,{variant:"ghost",size:"icon-xs","aria-label":"Previous request",disabled:h===0,onClick:()=>g(h-1),children:n.jsx(ls,{"data-icon":"inline-start"})}),n.jsx(J,{variant:"ghost",size:"icon-xs","aria-label":"Next request",disabled:h===a.length-1,onClick:()=>g(h+1),children:n.jsx(ze,{"data-icon":"inline-start"})})]})]}),n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsxs("div",{className:"flex items-center gap-2 px-0.5 text-xs",children:[p,n.jsx("span",{className:"min-w-0 truncate font-medium text-foreground",children:l(r)}),r.device&&n.jsx(Kt,{variant:"outline",children:r.device.name}),C]}),n.jsx(Vt,{sessionId:r.sessionId,pending:w,queued:0,responding:i.has(w.requestId),onRespond:(S,y)=>void c(r.sessionId,S,y),onOpen:()=>o(r)},w.requestId),n.jsxs(J,{variant:"ghost",size:"xs",className:"self-end text-muted-foreground",onClick:()=>o(r),children:["Open session",b]})]}),u&&n.jsxs("p",{className:"mt-2 truncate text-xs text-muted-foreground",children:["Next: ",n.jsx("span",{className:"font-medium text-foreground",children:l(u.member)})," ",We(u.member).toLowerCase()]})]})}function sn({crew:t,hereId:e,busy:s,nameOf:i,onOpen:l,onMarkRead:o,onStop:c,collapsed:a,onToggle:f}){const[g,h]=k.useState("working");let r=null;const w=xs(t).filter(({member:u,depth:x})=>{if(g!=="all"){const d=he(u);return g==="done"?d!=="working"&&d!=="needs-you":d===g}return r!==null&&x>r?!1:(r=a.has(u.sessionId)?x:null,!0)});return n.jsxs("section",{"aria-label":"Sessions",className:"px-1.5 py-2.5",children:[n.jsxs("div",{className:"mb-1.5 flex items-center gap-2 px-1.5",children:[n.jsx("h3",{className:"text-sm font-medium",children:"Sessions"}),n.jsx("span",{className:"flex-1"}),n.jsx("div",{role:"radiogroup","aria-label":"Show sessions",className:"flex gap-0.5",children:Xs.map(({id:u,label:x})=>n.jsx("button",{type:"button",role:"radio","aria-checked":g===u,onClick:()=>h(u),className:oe("rounded-full px-2 py-0.5 text-[11px] text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",g===u&&"bg-accent text-foreground"),children:x},u))})]}),w.length===0?n.jsxs("div",{className:"flex flex-col items-center gap-1 px-1.5 py-4 text-xs text-muted-foreground",children:[n.jsx("p",{children:g==="working"?"Nothing is working right now.":"No sessions here."}),g!=="all"&&n.jsx(J,{variant:"ghost",size:"xs",onClick:()=>h("all"),children:"Show all"})]}):n.jsx("ul",{className:"flex flex-col",children:w.map(u=>n.jsx(nn,{row:u,here:u.member.sessionId===e,busy:s,name:i(u.member),onOpen:l,onMarkRead:o,onStop:c,collapsed:g==="all"?a.has(u.member.sessionId):void 0,onToggle:()=>f(u.member.sessionId)},u.member.sessionId))})]})}function nn(t){var ce,me;const e=ue.c(81),{row:s,here:i,busy:l,name:o,onOpen:c,onMarkRead:a,onStop:f,collapsed:g,onToggle:h}=t,{member:r,depth:w,children:u}=s;let x;e[0]!==r?(x=he(r),e[0]=r,e[1]=x):x=e[1];const d=x;let p;e[2]!==r?(p=We(r),e[2]=r,e[3]=p):p=e[3];const N=p;let C;e[4]!==r.pullRequests?(C=(ce=r.pullRequests)==null?void 0:ce.at(-1),e[4]=r.pullRequests,e[5]=C):C=e[5];const b=C;let S;e[6]!==r?(S=$e(r)&&r.result&&r.parentId,e[6]=r,e[7]=S):S=e[7];const y=S,M=(d==="working"||d==="needs-you")&&(!r.device||((me=r.result)==null?void 0:me.state)==="running"&&r.parentId!==null),L=r.sessionId,A=i?"bg-accent":"hover:bg-accent/60",O=w>0&&"border-l border-border/70";let v;e[8]!==A||e[9]!==O?(v=oe("group/crew relative flex items-start rounded-md",A,O),e[8]=A,e[9]=O,e[10]=v):v=e[10];const _=w>0?6+(w-1)*14:0;let I;e[11]!==_?(I={marginLeft:_},e[11]=_,e[12]=I):I=e[12];let E;e[13]!==u||e[14]!==g||e[15]!==o||e[16]!==h?(E=u>0&&g!==void 0&&n.jsx(J,{variant:"ghost",size:"icon-xs","aria-label":`${g?"Expand":"Collapse"} ${o}'s child sessions`,"aria-expanded":!g,onClick:h,children:n.jsx(ze,{"data-icon":"inline-start",className:oe("transition-transform",!g&&"rotate-90")})}),e[13]=u,e[14]=g,e[15]=o,e[16]=h,e[17]=E):E=e[17];let R;e[18]!==E?(R=n.jsx("span",{className:"mt-1.5 flex w-6 shrink-0 justify-center",children:E}),e[18]=E,e[19]=R):R=e[19];let T;e[20]!==r||e[21]!==c?(T=()=>c(r),e[20]=r,e[21]=c,e[22]=T):T=e[22];const z=i?"true":void 0,D=`${o}, ${N}`,Y=fe[d];let F;e[23]!==Y?(F=oe("size-1.5 justify-self-center rounded-full",Y),e[23]=Y,e[24]=F):F=e[24];let q;e[25]!==F?(q=n.jsx("span",{className:F,"aria-hidden":"true"}),e[25]=F,e[26]=q):q=e[26];let P;e[27]!==o?(P=n.jsx("span",{className:"truncate",children:o}),e[27]=o,e[28]=P):P=e[28];let W;e[29]!==i?(W=i&&n.jsx("span",{className:"shrink-0 rounded-full border px-1.5 text-[10.5px] font-normal text-muted-foreground",children:"you are here"}),e[29]=i,e[30]=W):W=e[30];let B;e[31]!==P||e[32]!==W?(B=n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-[12.5px] font-medium",children:[P,W]}),e[31]=P,e[32]=W,e[33]=B):B=e[33];let G;e[34]!==r.lastActivityAt?(G=r.lastActivityAt?qe(r.lastActivityAt):"",e[34]=r.lastActivityAt,e[35]=G):G=e[35];let K;e[36]!==G?(K=n.jsx("span",{className:"text-[11px] tabular-nums text-muted-foreground/80",children:G}),e[36]=G,e[37]=K):K=e[37];const X=(d==="needs-you"||y)&&"text-warning",m=d==="failed"&&"text-destructive";let j;e[38]!==X||e[39]!==m?(j=oe("min-w-0 flex-1 truncate",X,m),e[38]=X,e[39]=m,e[40]=j):j=e[40];let $;e[41]!==N||e[42]!==j?($=n.jsx("span",{className:j,children:N}),e[41]=N,e[42]=j,e[43]=$):$=e[43];let V;e[44]!==b?(V=b&&n.jsxs("span",{className:"shrink-0 rounded-full border px-1.5 text-[11px]",children:["#",b.number]}),e[44]=b,e[45]=V):V=e[45];let ae;e[46]!==r.device?(ae=r.device&&n.jsx("span",{className:"shrink-0",children:r.device.name}),e[46]=r.device,e[47]=ae):ae=e[47];let Q;e[48]!==u?(Q=u>0&&n.jsxs("span",{className:"shrink-0",children:[u," ",u===1?"session":"sessions"]}),e[48]=u,e[49]=Q):Q=e[49];let ee;e[50]!==r.model?(ee=r.model&&n.jsx("span",{className:"shrink-0 text-muted-foreground/70",children:Ye(r.model)}),e[50]=r.model,e[51]=ee):ee=e[51];let te;e[52]!==$||e[53]!==V||e[54]!==ae||e[55]!==Q||e[56]!==ee?(te=n.jsxs("span",{className:"col-start-2 col-end-4 flex min-w-0 items-center gap-2 text-[11.5px] text-muted-foreground",children:[$,V,ae,Q,ee]}),e[52]=$,e[53]=V,e[54]=ae,e[55]=Q,e[56]=ee,e[57]=te):te=e[57];let se;e[58]!==T||e[59]!==z||e[60]!==D||e[61]!==q||e[62]!==B||e[63]!==K||e[64]!==te?(se=n.jsxs("button",{type:"button",onClick:T,"aria-current":z,"aria-label":D,className:"grid min-w-0 flex-1 grid-cols-[14px_minmax(0,1fr)_auto] items-center gap-x-2 gap-y-0.5 rounded-md px-2 py-1.5 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[q,B,K,te]}),e[58]=T,e[59]=z,e[60]=D,e[61]=q,e[62]=B,e[63]=K,e[64]=te,e[65]=se):se=e[65];let re;e[66]!==l||e[67]!==M||e[68]!==r||e[69]!==o||e[70]!==a||e[71]!==f||e[72]!==y?(re=(y||M)&&n.jsxs("div",{className:"absolute right-1.5 top-1 hidden gap-1 group-focus-within/crew:flex group-hover/crew:flex",children:[y&&r.result&&r.parentId&&n.jsx(J,{variant:"outline",size:"icon-xs",className:"bg-popover","aria-label":`Mark ${o}'s result read`,title:"Mark the result read",disabled:l.has(r.result.taskId),onClick:()=>void a(r.parentId,r.result.taskId),children:n.jsx(is,{"data-icon":"inline-start"})}),M&&n.jsx(J,{variant:"outline",size:"icon-xs",className:"bg-popover text-destructive","aria-label":`Stop ${o}`,title:"Stop this session",disabled:l.has(r.sessionId),onClick:()=>void f(r),children:n.jsx(rs,{"data-icon":"inline-start"})})]}),e[66]=l,e[67]=M,e[68]=r,e[69]=o,e[70]=a,e[71]=f,e[72]=y,e[73]=re):re=e[73];let Z;return e[74]!==r.sessionId||e[75]!==I||e[76]!==R||e[77]!==se||e[78]!==re||e[79]!==v?(Z=n.jsxs("li",{"data-crew-row":L,className:v,style:I,children:[R,se,re]}),e[74]=r.sessionId,e[75]=I,e[76]=R,e[77]=se,e[78]=re,e[79]=v,e[80]=Z):Z=e[80],Z}export{dn as CrewPanel};
|
|
1
|
+
import{r as C,c as ue,j as n}from"./vendor-react-gGw_S5I_.js";import{F as _e,dn as it,a0 as je,dp as jt,dq as yt,dr as Nt,B as J,E as rt,f as ct,U as It,h as dt,i as ut,ae as Je,ds as Ct,ac as Qe,aC as et,dt as kt,du as St,m as ft,ad as Mt,dv as $t,av as Rt,cN as Tt,dw as At,db as Ot,aZ as Et,o as Lt,n as _t,D as zt,j as Dt,c as oe,dx as Ft,bX as Pt,bY as Yt,bW as qt,dy as Ye,V as qe,dz as Wt,cL as Ht,ch as Ut,ci as Bt,cj as Te,ck as Ae,al as Gt,k as Kt,dA as Vt,dB as Xt,dC as Zt,b8 as Jt}from"./index-BYVl1VlW.js";import{S as Qt}from"./switch-DFZA-ROd.js";import{bU as es,dC as ts,aT as ss,bs as ns,N as ht,bq as mt,bl as as,bv as os,br as ls,A as ze,dD as is,aS as rs,X as cs}from"./vendor-ui-B0az9ATE.js";import"./vendor-markdown-BEJ8yVzA.js";async function Ce(t){if(t.ok)return t;const e=await t.json().catch(()=>null);throw new Error((e==null?void 0:e.error)||"Couldn't update crew chat.")}function Oe(t,e){return[...new Map([...t,...e].map(s=>[s.sequence,s])).values()].sort((s,i)=>s.sequence-i.sequence)}function ds(t){const[e,s]=C.useState(null),[i,l]=C.useState([]),[o,c]=C.useState(null),[a,f]=C.useState(!1),[x,h]=C.useState(!1),[r,w]=C.useState(!1),[u,g]=C.useState(new Set),d=C.useRef(0),p=C.useRef(null),N=C.useRef(!1),k=C.useRef(!1),b=C.useRef(new Set),S=C.useRef(!1),y=C.useRef(null),M=C.useCallback(async v=>{const _=++d.current;try{const I=y.current,R=await(await Ce(await _e(`/api/crew-chat/${encodeURIComponent(t)}${I===null?"":`?after=${I}&limit=100`}`))).json();if(!v()||_!==d.current)return;s(T=>T&&JSON.stringify(T.members)===JSON.stringify(R.members)?{...R,members:T.members}:R),l(T=>Oe(T,R.messages)),y.current=R.nextCursor,S.current||(S.current=!0,w(R.hasMore)),c(null)}catch(I){v()&&_===d.current&&c(I instanceof Error?I.message:"Couldn't load crew chat.")}},[t]);it(M,2e3);const L=C.useCallback(async v=>{var _;if(N.current)return!1;N.current=!0,f(!0),((_=p.current)==null?void 0:_.text)!==v&&(p.current={text:v,id:crypto.randomUUID()});try{const E=await(await Ce(await je(`/api/crew-chat/${encodeURIComponent(t)}`,{text:v,commandId:p.current.id}))).json();return d.current++,l(R=>Oe(R,[E.message])),p.current=null,c(E.pending.length?"Message saved. Some members are unavailable; delivery will retry.":null),!0}catch(I){return c(I instanceof Error?I.message:"Couldn't send the message."),!1}finally{N.current=!1,f(!1)}},[t]),A=C.useCallback(async(v,_)=>{if(!b.current.has(v)){b.current.add(v),g(I=>new Set(I).add(v));try{await Ce(await je(`/api/crew-chat/${encodeURIComponent(t)}`,{sessionId:v,listening:_},{method:"PATCH"})),d.current++,s(I=>I&&{...I,members:I.members.map(E=>E.sessionId===v?{...E,listening:_}:E)}),c(null)}catch(I){c(I instanceof Error?I.message:"Couldn't change listening.")}finally{b.current.delete(v),g(I=>{const E=new Set(I);return E.delete(v),E})}}},[t]),O=C.useCallback(async()=>{if(!(!i.length||k.current)){k.current=!0,h(!0);try{const _=await(await Ce(await _e(`/api/crew-chat/${encodeURIComponent(t)}?before=${i[0].sequence}`))).json();l(I=>Oe(I,_.messages)),w(_.hasMore)}catch(v){c(v instanceof Error?v.message:"Couldn't load older messages.")}finally{k.current=!1,h(!1)}}},[i,t]);return{page:e,messages:i,error:o,posting:a,busyMembers:u,hasOlder:r,loadingOlder:x,post:L,setListening:A,older:O}}const us=[],fs=new Map;function hs(t){var He,Ue,Be,Ge,Ke,Ve,Xe;const e=ue.c(111),{rootId:s,kinds:i,active:l}=t,o=i===void 0?fs:i,c=l===void 0?!0:l,a=ds(s),[f,x]=C.useState(""),h=C.useRef(null),r=C.useRef(!0);let w;e[0]!==a.messages?(w=(He=a.messages.at(-1))==null?void 0:He.sequence,e[0]=a.messages,e[1]=w):w=e[1];const u=w,g=((Ue=a.page)==null?void 0:Ue.members)??us;let d;e[2]!==g?(d=jt(g),e[2]=g,e[3]=d):d=e[3];const p=d;let N;e[4]!==g||e[5]!==s?(N=yt(g,s),e[4]=g,e[5]=s,e[6]=N):N=e[6];const k=N;let b;e[7]!==g?(b=new Map(g.map(ps)),e[7]=g,e[8]=b):b=e[8];const S=b;let y;e[9]!==a.messages||e[10]!==s?(y=Nt(a.messages,s),e[9]=a.messages,e[10]=s,e[11]=y):y=e[11];const M=y;let L;e[12]!==c?(L=()=>{var B,H;c&&r.current&&((H=(B=h.current)==null?void 0:B.scrollIntoView)==null||H.call(B,{block:"end"}))},e[12]=c,e[13]=L):L=e[13];let A;e[14]!==c||e[15]!==u?(A=[c,u],e[14]=c,e[15]=u,e[16]=A):A=e[16],C.useEffect(L,A);let O;e[17]!==a||e[18]!==f?(O=async()=>{const B=f.trim();!B||a.posting||await a.post(B)&&(x(H=>H.trim()===B?"":H),r.current=!0)},e[17]=a,e[18]=f,e[19]=O):O=e[19];const v=O;let _;e[20]!==a.page||e[21]!==g?(_=a.page?`${g.filter(ms).length} listening · Members & mentions`:"Loading chat…",e[20]=a.page,e[21]=g,e[22]=_):_=e[22];let I;e[23]!==_?(I=n.jsx("summary",{className:"cursor-pointer text-xs text-muted-foreground",children:_}),e[23]=_,e[24]=I):I=e[24];let E;if(e[25]!==a||e[26]!==o||e[27]!==g||e[28]!==s||e[29]!==k){let B;e[31]!==a||e[32]!==o||e[33]!==s||e[34]!==k?(B=H=>{var Ze;return n.jsxs(Je,{orientation:"horizontal",className:"items-center gap-2",children:[n.jsx(Ct,{role:H.sessionId===s?"lead":"agent",sessionId:H.sessionId,kinds:o,tints:k,className:"size-5"}),n.jsxs(Qe,{className:"min-w-0 flex-1 items-baseline gap-1.5",htmlFor:`listen-${H.sessionId}`,"aria-label":`Listen for ${H.name}`,children:[n.jsx("span",{className:"truncate",children:H.name}),n.jsxs("span",{className:"truncate text-xs font-normal text-muted-foreground",children:["@",H.handle]})]}),n.jsx(J,{variant:"ghost",size:"icon-xs",disabled:!((Ze=a.page)!=null&&Ze.canPost)||!H.canInteract,onClick:()=>x(ye=>`${ye}${ye&&!/\s$/.test(ye)?" ":""}@${H.handle} `),"aria-label":`Mention ${H.name}`,title:`Mention @${H.handle}`,className:"text-muted-foreground",children:n.jsx(ts,{"data-icon":"inline-start"})}),n.jsx(Qt,{id:`listen-${H.sessionId}`,size:"sm",checked:H.listening,disabled:!H.canInteract||a.busyMembers.has(H.sessionId),onCheckedChange:ye=>void a.setListening(H.sessionId,ye)})]},H.sessionId)},e[31]=a,e[32]=o,e[33]=s,e[34]=k,e[35]=B):B=e[35],E=g.map(B),e[25]=a,e[26]=o,e[27]=g,e[28]=s,e[29]=k,e[30]=E}else E=e[30];let R;e[36]!==E?(R=n.jsx(et,{className:"max-h-48 gap-2 overflow-y-auto py-2",children:E}),e[36]=E,e[37]=R):R=e[37];let T;e[38]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsx("p",{className:"pb-1 text-xs text-muted-foreground",children:"Listening sends short notices while an agent works. @mentions send the full message, even when listening is off."}),e[38]=T):T=e[38];let z;e[39]!==I||e[40]!==R?(z=n.jsxs("details",{className:"shrink-0 border-b px-3 py-2",children:[I,R,T]}),e[39]=I,e[40]=R,e[41]=z):z=e[41];let D;e[42]===Symbol.for("react.memo_cache_sentinel")?(D=B=>{const H=B.target;r.current=H.scrollHeight-H.scrollTop-H.clientHeight<80},e[42]=D):D=e[42];let Y;e[43]!==a?(Y=a.hasOlder&&n.jsx("div",{className:"flex justify-center py-2",children:n.jsx(J,{variant:"ghost",size:"xs",disabled:a.loadingOlder,onClick:()=>void a.older(),children:a.loadingOlder?"Loading…":"Load earlier messages"})}),e[43]=a,e[44]=Y):Y=e[44];let F;e[45]!==a.messages.length||e[46]!==a.page?(F=a.page&&a.messages.length===0&&n.jsx(rt,{children:n.jsxs(ct,{children:[n.jsx(It,{variant:"icon",children:n.jsx(es,{})}),n.jsx(dt,{children:"Talk to the crew"}),n.jsx(ut,{children:"Share a discovery, ask a question, or tag someone for their input."})]})}),e[45]=a.messages.length,e[46]=a.page,e[47]=F):F=e[47];let q;if(e[48]!==S||e[49]!==p||e[50]!==o||e[51]!==s||e[52]!==M||e[53]!==k){let B;e[55]!==S||e[56]!==p||e[57]!==o||e[58]!==s||e[59]!==k?(B=H=>n.jsxs(C.Fragment,{children:[H.day!==void 0&&n.jsx(kt,{day:H.day}),n.jsx(St,{run:H,members:S,handles:p,kinds:o,tints:k,rootId:s})]},H.messages[0].sequence),e[55]=S,e[56]=p,e[57]=o,e[58]=s,e[59]=k,e[60]=B):B=e[60],q=M.map(B),e[48]=S,e[49]=p,e[50]=o,e[51]=s,e[52]=M,e[53]=k,e[54]=q}else q=e[54];let P;e[61]===Symbol.for("react.memo_cache_sentinel")?(P=n.jsx("div",{ref:h}),e[61]=P):P=e[61];let W;e[62]!==q?(W=n.jsxs("div",{role:"log","aria-label":"Shared messages","aria-live":"polite","aria-relevant":"additions",className:"flex flex-col gap-4 px-3 py-3",children:[q,P]}),e[62]=q,e[63]=W):W=e[63];let U;e[64]!==Y||e[65]!==F||e[66]!==W?(U=n.jsxs(ft,{className:"min-h-0 flex-1",onScrollCapture:D,children:[Y,F,W]}),e[64]=Y,e[65]=F,e[66]=W,e[67]=U):U=e[67];let G;e[68]!==v?(G=B=>{B.preventDefault(),v()},e[68]=v,e[69]=G):G=e[69];const K=!!a.error,X=`crew-chat-${s}`;let m;e[70]!==X?(m=n.jsx(Qe,{htmlFor:X,className:"sr-only",children:"Message the crew"}),e[70]=X,e[71]=m):m=e[71];const j=`crew-chat-${s}`,$=!((Be=a.page)!=null&&Be.canPost),V=!!a.error;let ae;e[72]===Symbol.for("react.memo_cache_sentinel")?(ae=B=>x(B.target.value),e[72]=ae):ae=e[72];let Q;e[73]!==v?(Q=B=>{B.key==="Enter"&&(B.metaKey||B.ctrlKey)&&!B.nativeEvent.isComposing&&(B.preventDefault(),v())},e[73]=v,e[74]=Q):Q=e[74];let ee;e[75]!==f||e[76]!==j||e[77]!==$||e[78]!==V||e[79]!==Q?(ee=n.jsx(Mt,{id:j,value:f,rows:3,maxLength:$t,placeholder:"Message the crew… use @ to tag an agent",disabled:$,"aria-invalid":V,onChange:ae,onKeyDown:Q}),e[75]=f,e[76]=j,e[77]=$,e[78]=V,e[79]=Q,e[80]=ee):ee=e[80];let te;e[81]!==a.error?(te=a.error&&n.jsx("p",{role:"alert",className:"text-xs text-destructive",children:a.error}),e[81]=a.error,e[82]=te):te=e[82];let se;e[83]!==K||e[84]!==m||e[85]!==ee||e[86]!==te?(se=n.jsxs(Je,{"data-invalid":K,children:[m,ee,te]}),e[83]=K,e[84]=m,e[85]=ee,e[86]=te,e[87]=se):se=e[87];const re=((Ge=a.page)==null?void 0:Ge.canPost)===!1?"You have read access to this crew.":"⌘ / Ctrl + Enter to send";let Z;e[88]!==re?(Z=n.jsx(Rt,{className:"flex-1",children:re}),e[88]=re,e[89]=Z):Z=e[89];let ce;e[90]!==((Ke=a.page)==null?void 0:Ke.canPost)||e[91]!==a.posting||e[92]!==f?(ce=!((Ve=a.page)!=null&&Ve.canPost)||!f.trim()||a.posting,e[90]=(Xe=a.page)==null?void 0:Xe.canPost,e[91]=a.posting,e[92]=f,e[93]=ce):ce=e[93];let me;e[94]===Symbol.for("react.memo_cache_sentinel")?(me=n.jsx(ss,{"data-icon":"inline-start"}),e[94]=me):me=e[94];const Re=a.posting?"Sending…":"Send";let xe;e[95]!==ce||e[96]!==Re?(xe=n.jsxs(J,{type:"submit",size:"sm",disabled:ce,children:[me,Re]}),e[95]=ce,e[96]=Re,e[97]=xe):xe=e[97];let ge;e[98]!==Z||e[99]!==xe?(ge=n.jsxs("div",{className:"flex items-center gap-2",children:[Z,xe]}),e[98]=Z,e[99]=xe,e[100]=ge):ge=e[100];let we;e[101]!==se||e[102]!==ge?(we=n.jsxs(et,{className:"gap-2",children:[se,ge]}),e[101]=se,e[102]=ge,e[103]=we):we=e[103];let be;e[104]!==G||e[105]!==we?(be=n.jsx("form",{className:"shrink-0 border-t p-3",onSubmit:G,children:we}),e[104]=G,e[105]=we,e[106]=be):be=e[106];let Ie;return e[107]!==z||e[108]!==U||e[109]!==be?(Ie=n.jsxs("section",{"aria-label":"Crew chat",className:"flex h-full min-h-0 flex-col",children:[z,U,be]}),e[107]=z,e[108]=U,e[109]=be,e[110]=Ie):Ie=e[110],Ie}function ms(t){return t.listening}function ps(t){return[t.sessionId,t]}const fe={working:"bg-success ring-2 ring-success/30","needs-you":"bg-warning",done:"bg-muted-foreground/50",failed:"bg-destructive",unreachable:"border border-muted-foreground/60"};function pt(t){const e=new Date(t),s=e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return e.toDateString()===new Date().toDateString()?s:`${e.toLocaleDateString([],{month:"short",day:"numeric"})}, ${s}`}function he(t){if(t.status==="deferred")return"needs-you";switch(t.outcome){case"needs_input":return"needs-you";case"running":return"working";case"error":return"failed";case"unreachable":case"not_found":return"unreachable";default:return"done"}}function tt(t,e){var s,i;return{sessionId:t.sessionId,dirName:((s=t.address)==null?void 0:s.dirName)??"",fileName:((i=t.address)==null?void 0:i.fileName)??"",projectShortName:"",lastModified:t.lastActivityAt??"",lastActivityAt:t.lastActivityAt,size:0,cwd:t.cwd,customTitle:t.customTitle,aiTitle:t.aiTitle,firstUserMessage:t.firstUserMessage,...t.parentId&&{crew:{rootId:e,parentId:t.parentId,startedAt:t.startedAt??0,...t.name&&{name:t.name}}}}}function xs(t,e,s){var a;const i=((a=[...e.values()].find(f=>f.parentId===null))==null?void 0:a.sessionId)??t.sessionId,l=s[t.sessionId],o=tt(t,i);if(!t.parentId)return Tt(o,l);const c=e.get(t.parentId);return At(o,{customName:l,parent:c&&tt(c,i)})}function gs(t){const e=new Map;for(const o of t.members){if(!o.parentId)continue;const c=e.get(o.parentId);c?c.push(o):e.set(o.parentId,[o])}const s=[],i=new Set,l=(o,c)=>{var f;const a=[...e.get(o)??[]].sort((x,h)=>(x.startedAt??0)-(h.startedAt??0));for(const x of a)i.has(x.sessionId)||(i.add(x.sessionId),s.push({member:x,depth:c,children:((f=e.get(x.sessionId))==null?void 0:f.length)??0}),l(x.sessionId,c+1))};l(t.rootId,0);for(const o of t.members)o.parentId&&!i.has(o.sessionId)&&(i.add(o.sessionId),s.push({member:o,depth:0,children:0}));return s}function ws(t){const e=({member:s,pending:i})=>i.askedAt??(Date.parse(s.lastActivityAt??"")||0);return t.members.flatMap(s=>s.waiting.map(i=>({member:s,pending:i}))).sort((s,i)=>e(s)-e(i))}function bs(t){const e={size:0,working:0,needsYou:0,done:0,failed:0,unreachable:0,unreadResults:0};for(const s of t.members){if(!s.parentId)continue;e.size++;const i=he(s);i==="working"?e.working++:i==="needs-you"?e.needsYou++:i==="failed"?e.failed++:i==="unreachable"?e.unreachable++:e.done++,$e(s)&&e.unreadResults++}return e}function $e(t){return!!(t.result&&t.result.state!=="running"&&!t.result.acknowledged)}function We(t){const[e]=t.waiting;switch(he(t)){case"needs-you":return(e==null?void 0:e.kind)==="permission"?`Waiting on a permission · ${e.toolName}`:(e==null?void 0:e.kind)==="question"?"Asked a question":!e&&t.status==="deferred"?"Awaiting permission review":"Plan to review";case"working":return t.status==="tool_use"&&t.toolName?t.toolName:t.status==="thinking"?"Thinking":t.status==="compacting"?"Compacting":t.status==="awaiting_agents"?"Waiting on its agents":"Working";case"failed":return t.error?`Failed · ${t.error}`:"Failed";case"unreachable":return t.device?`${t.device.name} is not answering`:"Not found";default:return $e(t)?"Finished · result unread":"Finished"}}const le=196,ne=86,de=40,ve=12,vs=28,Se=6,st=8,pe=10,js=6,Me=28,De=36;function xt(t){const e=he(t);return e==="working"||e==="needs-you"}function ys(t){const e={all:t.members.length,active:0,working:0,needsYou:0};for(const s of t.members){const i=he(s);i==="working"?e.working++:i==="needs-you"&&e.needsYou++}return e.active=e.working+e.needsYou,e}const nt=(t,e)=>(t.startedAt??0)-(e.startedAt??0)||t.sessionId.localeCompare(e.sessionId);function gt(t){const e=new Map(t.members.map(l=>[l.sessionId,l])),s=new Map,i=[];for(const l of t.members){const o=l.parentId&&l.sessionId!==t.rootId?e.get(l.parentId):void 0;if(!o){i.push(l);continue}const c=s.get(o.sessionId);c?c.push(l):s.set(o.sessionId,[l])}for(const l of s.values())l.sort(nt);return i.sort((l,o)=>+(o.sessionId===t.rootId)-+(l.sessionId===t.rootId)||nt(l,o)),{roots:i,childrenOf:s}}function Ns(t,e){if(e==="all")return new Set(t.members.map(l=>l.sessionId));const s=new Map(t.members.map(l=>[l.sessionId,l])),i=new Set;for(const l of t.members){if(!xt(l))continue;let o=l;for(;o&&!i.has(o.sessionId);)i.add(o.sessionId),o=o.sessionId===t.rootId||!o.parentId?void 0:s.get(o.parentId)}return i}function Is(t){const{roots:e,childrenOf:s}=gt(t),i=new Set;let l=0;const o=e.map(c=>({member:c,depth:0}));for(;o.length>0;){const{member:c,depth:a}=o.pop();if(!i.has(c.sessionId)){i.add(c.sessionId),l=Math.max(l,a);for(const f of s.get(c.sessionId)??[])o.push({member:f,depth:a+1})}}return l}function Cs(t){return(t+1)*le+t*de}function ks(t,e,s,{group:i=!1,stacked:l}={}){const{roots:o,childrenOf:c}=gt(t),a=Ns(t,e),f=y=>(c.get(y)??[]).filter(M=>a.has(M.sessionId)),x=(l==null?void 0:l.cardWidth)??le,h=[],r=[],w=[],u=new Set;let g=0,d=0;const p=y=>{const M={count:0,working:0,needsYou:0},L=new Set(u),A=[...f(y)];for(;A.length>0;){const O=A.pop();if(L.has(O.sessionId))continue;L.add(O.sessionId),M.count++;const v=he(O);v==="working"?M.working++:v==="needs-you"&&M.needsYou++,A.push(...f(O.sessionId))}return M},N=y=>f(y).filter(M=>!u.has(M.sessionId)),k=y=>N(y.sessionId).length===0||s.has(y.sessionId),b=(y,M,L)=>{u.add(y.sessionId);const A=N(y.sessionId),O=A.length>0&&s.has(y.sessionId),v=O?[]:A,_=i&&!l&&v.length>=st?v.filter(k):[],I=_.length>=st?_:[],E=new Set(I),R=v.filter(D=>!E.has(D)),T={member:y,depth:M,x:(L==null?void 0:L.x)??M*(l?Me:le+de),y:(L==null?void 0:L.y)??g+(R.length===0&&I.length>0?pe:0),childCount:A.length,collapsed:O,hidden:O?p(y.sessionId):{count:0,working:0,needsYou:0},context:e==="active"&&!xt(y),grouped:!!L};if(h.push(T),d=Math.max(d,T.x+x+(l&&A.length>0?De:0)),l){g+=ne+ve;const D=v.map(Y=>b(Y,M+1));return D.length>0&&r.push({parentId:y.sessionId,path:Ms(T.x,T.y,D)}),T.y}if(O){const D=T.y+ne/2;r.push({parentId:y.sessionId,path:`M${T.x+le} ${D}H${T.x+le+de/2}`})}if(L)return T.y;if(v.length===0)return g+=ne+ve,T.y;const z=R.map(D=>b(D,M+1));return I.length>0&&z.push(S(y.sessionId,I,M+1)+pe),r.push({parentId:y.sessionId,path:Ss(T.x+le,T.y,z)}),T.y},S=(y,M,L)=>{const A=Math.min(js,Math.max(2,Math.ceil(Math.sqrt(M.length/1.5)))),O=Math.ceil(M.length/A),v={parentId:y,x:L*(le+de),y:g,width:A*le+(A-1)*de+2*pe,height:O*ne+(O-1)*ve+2*pe};return w.push(v),M.forEach((_,I)=>b(_,L,{x:v.x+pe+I%A*(le+de),y:v.y+pe+Math.floor(I/A)*(ne+ve)})),d=Math.max(d,v.x+v.width),g+=v.height+ve,v.y};for(const y of o)!a.has(y.sessionId)||u.has(y.sessionId)||(h.length>0&&(g+=vs),b(y,0));return{orientation:l?"stacked":"across",cardWidth:x,nodes:h,edges:r,groups:w,width:d,height:Math.max(0,g-ve)}}function Ss(t,e,s){const i=e+ne/2,l=[`M${t} ${i}H${t+de}`];for(const o of s)o!==e&&l.push(wt(t,i,o+ne/2));return l.join("")}function wt(t,e,s){const i=t+de/2;return`M${i} ${e}V${s-Se}Q${i} ${s} ${i+Se} ${s}H${t+de}`}function Ms(t,e,s){return s.map(i=>bt(t,e,i)).join("")}function bt(t,e,s){const i=t+Me/2,l=s+ne/2;return`M${i} ${e+ne}V${l-Se}Q${i} ${l} ${i+Se} ${l}H${t+Me}`}function $s(t,e){const s=new Map(t.nodes.map(c=>[c.member.sessionId,c])),i=new Map(t.groups.map(c=>[c.parentId,c]));let l=e?s.get(e):void 0;const o=[];for(;l!=null&&l.member.parentId;){const c=l.member.parentId,a=s.get(c);if(!a||a.depth!==l.depth-1)break;if(t.orientation==="stacked"){o.unshift(bt(a.x,a.y,l.y)),l=a;continue}const f=a.x+le,x=a.y+ne/2,h=l.grouped?i.get(c):void 0,r=(h?h.y+pe:l.y)+ne/2;o.unshift(r===x?`M${f} ${x}H${f+de}`:`M${f} ${x}H${f+de/2}${wt(f,x,r)}`),l=a}return o.length>0?o.join(""):null}const ie=14,Fe=.25,at=1.5,Rs=.7,ke=1.2,Ts=56,As=900,Os=.85,Es=320,Ee={all:new Set,active:new Set};function Ls(t){const[e,s]=Ot(Et("crew-map-filter"),"all"),i=e==="active"?"active":"all",[l,o]=C.useState({rootId:t,folds:Ee}),c=C.useRef(new Map),a=l.rootId===t?l.folds:Ee,f=C.useCallback(h=>o(r=>{const w=r.rootId===t?r.folds:Ee,u=new Set(w[i]);return u.delete(h)||u.add(h),{rootId:t,folds:{...w,[i]:u}}}),[i,t]),x=C.useMemo(()=>({get current(){return c.current.get(t)??null},set current(h){c.current.set(t,h)}}),[t]);return{filter:i,setFilter:s,collapsed:a[i],toggle:f,viewport:x}}function _s(t){const e=ue.c(86),{crew:s,hereId:i,controls:l,kinds:o,nameOf:c,onOpen:a}=t,[f,x]=C.useState(!1),{filter:h,collapsed:r,toggle:w}=l;let u,g,d,p,N,k,b,S,y,M,L,A,O,v,_,I;if(e[0]!==r||e[1]!==l||e[2]!==s||e[3]!==f||e[4]!==h||e[5]!==i||e[6]!==o||e[7]!==c||e[8]!==a||e[9]!==w){let W;e[26]!==s.rootId?(W=j=>j.sessionId===s.rootId,e[26]=s.rootId,e[27]=W):W=e[27];const U=s.members.find(W);let G;e[28]!==r||e[29]!==l||e[30]!==s||e[31]!==h||e[32]!==i||e[33]!==o||e[34]!==c||e[35]!==w?(G=(j,$)=>n.jsx(Ps,{crew:s,collapsed:r,groups:!j,filter:h,hereId:i,kinds:o,nameOf:c,memory:j,onOpen:$,onToggle:w,onShowAll:()=>l.setFilter("all")}),e[28]=r,e[29]=l,e[30]=s,e[31]=h,e[32]=i,e[33]=o,e[34]=c,e[35]=w,e[36]=G):G=e[36],d=G,k="flex h-full min-h-0 flex-col";let K;e[37]!==l||e[38]!==s?(K=n.jsx(ot,{crew:s,controls:l}),e[37]=l,e[38]=s,e[39]=K):K=e[39];let X;e[40]===Symbol.for("react.memo_cache_sentinel")?(X=n.jsx("span",{className:"flex-1"}),e[40]=X):X=e[40];let m;e[41]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(J,{variant:"ghost",size:"icon-xs","aria-label":"Expand the map",title:"Expand the map",onClick:()=>x(!0),children:n.jsx(ns,{"data-icon":"inline-start"})}),e[41]=m):m=e[41],e[42]!==K?(b=n.jsxs("div",{className:"flex shrink-0 items-center gap-2 px-3 pb-2",children:[K,X,m]}),e[42]=K,e[43]=b):b=e[43],e[44]!==d||e[45]!==l.viewport||e[46]!==a?(S=d(l.viewport,a),e[44]=d,e[45]=l.viewport,e[46]=a,e[47]=S):S=e[47],g=Lt,I=f,N=x,u=_t,A=!0,O="flex h-[calc(100dvh-1rem)] w-[calc(100vw-1rem)] max-w-none flex-col gap-0 overflow-hidden p-0 sm:h-[calc(100dvh-4rem)] sm:w-[calc(100vw-4rem)] sm:max-w-none",e[48]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx(zt,{className:"sr-only",children:"Crew map"}),_=n.jsx(Dt,{className:"sr-only",children:"Every session in this crew, from the one that started it."}),e[48]=v,e[49]=_):(v=e[48],_=e[49]),M="flex h-12 shrink-0 items-center gap-3 pl-4 pr-14",e[50]===Symbol.for("react.memo_cache_sentinel")?(L=n.jsx(ht,{"aria-hidden":"true",className:"size-4 shrink-0 text-muted-foreground"}),e[50]=L):L=e[50],p="min-w-0 truncate text-sm font-medium",y=U?c(U):"Crew",e[0]=r,e[1]=l,e[2]=s,e[3]=f,e[4]=h,e[5]=i,e[6]=o,e[7]=c,e[8]=a,e[9]=w,e[10]=u,e[11]=g,e[12]=d,e[13]=p,e[14]=N,e[15]=k,e[16]=b,e[17]=S,e[18]=y,e[19]=M,e[20]=L,e[21]=A,e[22]=O,e[23]=v,e[24]=_,e[25]=I}else u=e[10],g=e[11],d=e[12],p=e[13],N=e[14],k=e[15],b=e[16],S=e[17],y=e[18],M=e[19],L=e[20],A=e[21],O=e[22],v=e[23],_=e[24],I=e[25];let E;e[51]!==p||e[52]!==y?(E=n.jsx("span",{className:p,children:y}),e[51]=p,e[52]=y,e[53]=E):E=e[53];let R;e[54]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx("span",{className:"flex-1"}),e[54]=R):R=e[54];let T;e[55]!==l||e[56]!==s?(T=n.jsx(ot,{crew:s,controls:l}),e[55]=l,e[56]=s,e[57]=T):T=e[57];let z;e[58]!==E||e[59]!==T||e[60]!==M||e[61]!==L?(z=n.jsxs("header",{className:M,children:[L,E,R,T]}),e[58]=E,e[59]=T,e[60]=M,e[61]=L,e[62]=z):z=e[62];let D;e[63]!==a?(D=W=>{x(!1),a(W)},e[63]=a,e[64]=D):D=e[64];let Y;e[65]!==d||e[66]!==D?(Y=d(null,D),e[65]=d,e[66]=D,e[67]=Y):Y=e[67];let F;e[68]!==u||e[69]!==z||e[70]!==Y||e[71]!==A||e[72]!==O||e[73]!==v||e[74]!==_?(F=n.jsxs(u,{showCloseButton:A,className:O,children:[v,_,z,Y]}),e[68]=u,e[69]=z,e[70]=Y,e[71]=A,e[72]=O,e[73]=v,e[74]=_,e[75]=F):F=e[75];let q;e[76]!==g||e[77]!==N||e[78]!==F||e[79]!==I?(q=n.jsx(g,{open:I,onOpenChange:N,children:F}),e[76]=g,e[77]=N,e[78]=F,e[79]=I,e[80]=q):q=e[80];let P;return e[81]!==k||e[82]!==b||e[83]!==S||e[84]!==q?(P=n.jsxs("div",{className:k,children:[b,S,q]}),e[81]=k,e[82]=b,e[83]=S,e[84]=q,e[85]=P):P=e[85],P}function ot(t){const e=ue.c(3),{crew:s,controls:i}=t;let l;if(e[0]!==i||e[1]!==s){const o=ys(s),c=[{id:"all",label:"All",count:o.all,hint:"Every session in the crew"},{id:"active",label:"Active",count:o.active,hint:"Sessions working or waiting on you, and the sessions that started them"}];l=n.jsx("div",{role:"radiogroup","aria-label":"Show on the map",className:"flex shrink-0 gap-0.5 rounded-full border bg-background p-0.5",children:c.map(a=>{const{id:f,label:x,count:h,hint:r}=a;return n.jsxs("button",{type:"button",role:"radio","aria-checked":i.filter===f,"aria-label":`${x}, ${vt(h)}`,title:r,onClick:()=>i.setFilter(f),className:oe("inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",i.filter===f&&"bg-accent text-foreground"),children:[x,n.jsx("span",{className:"tabular-nums text-muted-foreground",children:h})]},f)})}),e[0]=i,e[1]=s,e[2]=l}else l=e[2];return l}function vt(t){return`${t} ${t===1?"session":"sessions"}`}function Le(t,e,s){return t.orientation==="stacked"?{scale:e,left:ie,top:ie}:{scale:e,left:Math.max(ie,(s.width-t.width*e)/2),top:Math.max(ie,Math.min((s.height-t.height*e)/2,s.height*.12))}}function zs(t,e,s){return{width:Math.max(s.width,e.left+t.width*e.scale+ie),height:Math.max(s.height,e.top+t.height*e.scale+Ts)}}function lt(t,e,{widthOnly:s=!1}={}){if(t.width===0||e.width===0)return 1;const i=(e.width-2*ie)/t.width,l=s?i:Math.min(i,(e.height-2*ie)/t.height);return Pe(l,Fe,1)}const Pe=(t,e,s)=>Math.min(s,Math.max(e,t));function Ds(t,e,s,i,l){var w;const o=new Map(e.layout.nodes.map(u=>[u.member.sessionId,u])),c=new Map(s.nodes.map(u=>[u.member.sessionId,u]));if(e.frame===i&&o.size===c.size&&s.nodes.every(u=>{const g=o.get(u.member.sessionId);return g!==void 0&&g.x===u.x&&g.y===u.y}))return null;const f=u=>({x:e.frame.left+u.x*e.frame.scale-t.left,y:e.frame.top+u.y*e.frame.scale-t.top}),x=l&&o.has(l)&&c.has(l)?l:(w=e.layout.nodes.filter(u=>c.has(u.member.sessionId)).map(u=>({node:u,screen:f(u)})).filter(({screen:u})=>u.y+ne*e.frame.scale>0&&u.x+e.layout.cardWidth*e.frame.scale>0).sort((u,g)=>u.screen.y-g.screen.y||u.screen.x-g.screen.x)[0])==null?void 0:w.node.member.sessionId;if(!x)return null;const h=f(o.get(x)),r=c.get(x);return{left:i.left+r.x*i.scale-h.x,top:i.top+r.y*i.scale-h.y}}function Fs(t,e,s,i){const l=new Map(t.nodes.map(g=>[g.member.sessionId,g])),o=e?l.get(e):void 0;if(!o)return{left:0,top:0};const{scale:c}=s,a=s.left+o.x*c,f=s.top+o.y*c,x=a+t.cardWidth*c,h=f+ne*c;if(x<=i.clientWidth&&h<=i.clientHeight)return{left:0,top:0};const r=o.member.parentId&&l.get(o.member.parentId)||o;let w=s.left+Math.min(r.x,o.x)*c-ie,u=s.top+Math.min(r.y,o.y)*c-ie;return x-w>i.clientWidth&&(w=a-ie),h-u>i.clientHeight&&(u=f-i.clientHeight/3),{left:Math.max(0,w),top:Math.max(0,u)}}function Ps({crew:t,collapsed:e,groups:s,filter:i,hereId:l,kinds:o,nameOf:c,memory:a,onOpen:f,onToggle:x,onShowAll:h}){const r=C.useRef(null),[w,u]=C.useState({width:0,height:0}),g=s&&w.width>=As,d=C.useMemo(()=>Is(t),[t]),p=w.width-2*ie,N=!s&&w.width>0&&Cs(d)*Os>p,k=N?Pe(p-d*Me-De,le,Es):le,b=C.useMemo(()=>ks(t,i,e,{group:g,...N&&{stacked:{cardWidth:k}}}),[t,i,e,g,N,k]),[S,y]=C.useState(()=>{var m;return((m=a==null?void 0:a.current)==null?void 0:m.frame)??{scale:1,left:ie,top:ie}}),[M,L]=C.useState(!1),A=C.useRef(null),O=C.useRef(null),v=C.useRef({left:0,top:0}),_=C.useRef(null),I=C.useRef(null),E=zs(b,S,w),{scale:R}=S;C.useLayoutEffect(()=>{const m=r.current;if(!m)return;const j=()=>u(V=>V.width===m.clientWidth&&V.height===m.clientHeight?V:{width:m.clientWidth,height:m.clientHeight});j();const $=new ResizeObserver(j);return $.observe(m),()=>$.disconnect()},[]);const T=C.useCallback(m=>{const j=r.current;a&&j&&(a.current={frame:m,left:j.scrollLeft,top:j.scrollTop})},[a]),z=C.useCallback((m,j)=>{A.current={frame:m,scroll:j},y(m)},[]),D=C.useCallback(m=>{const j=Le(m,Math.max(lt(m,w,{widthOnly:!0}),Rs),w);z(j,()=>{const $=r.current;return $?Fs(m,l,j,$):{left:0,top:0}})},[z,l,w]);C.useLayoutEffect(()=>{const m=r.current;if(w.width===0||!m)return;const j=_.current;if(j){if(j.filter!==i||j.layout.orientation!==b.orientation)D(b);else if(j.layout!==b){const $=Ds(v.current,j,b,S,O.current);$&&(m.scrollLeft=$.left,m.scrollTop=$.top,v.current={left:m.scrollLeft,top:m.scrollTop})}}else{const $=a==null?void 0:a.current;$?z($.frame,()=>({left:$.left,top:$.top})):D(b)}O.current=null,_.current={layout:b,filter:i,frame:S}}),C.useLayoutEffect(()=>{const m=A.current,j=r.current;if(!m||!j||m.frame!==S)return;A.current=null;const{left:$,top:V}=m.scroll();j.scrollLeft=$,j.scrollTop=V,v.current={left:j.scrollLeft,top:j.scrollTop},T(S)});const Y=C.useRef(l);C.useEffect(()=>{var m,j;Y.current!==l&&(Y.current=l,l&&((j=(m=r.current)==null?void 0:m.querySelector(`[data-crew-map-card="${CSS.escape(l)}"]`))==null||j.scrollIntoView({block:"nearest",inline:"nearest",behavior:"smooth"})))},[l]);const F=C.useCallback((m,j)=>{var ce;const $=r.current,V=((ce=A.current)==null?void 0:ce.frame.scale)??R,ae=Pe(V*m,Fe,at);if(!$||ae===V)return;const Q=$.getBoundingClientRect(),ee=j?j.clientX-Q.left:$.clientWidth/2,te=j?j.clientY-Q.top:$.clientHeight/2,se=($.scrollLeft+ee-S.left)/R,re=($.scrollTop+te-S.top)/R,Z=Le(b,ae,w);z(Z,()=>({left:Z.left+se*Z.scale-ee,top:Z.top+re*Z.scale-te}))},[z,S.left,S.top,b,R,w]),q=C.useRef(F);C.useLayoutEffect(()=>{q.current=F}),C.useEffect(()=>{const m=r.current;if(!m)return;const j=$=>{!$.ctrlKey&&!$.metaKey||($.preventDefault(),q.current(Math.exp(-$.deltaY*.01),$))};return m.addEventListener("wheel",j,{passive:!1}),()=>m.removeEventListener("wheel",j)},[]);const P=m=>{const j=r.current;!j||m.pointerType!=="mouse"||m.button!==0||m.target.closest("button")||(I.current={pointerId:m.pointerId,x:m.clientX,y:m.clientY,left:j.scrollLeft,top:j.scrollTop},j.setPointerCapture(m.pointerId),L(!0))},W=m=>{const j=I.current,$=r.current;!j||!$||j.pointerId!==m.pointerId||($.scrollLeft=j.left-(m.clientX-j.x),$.scrollTop=j.top-(m.clientY-j.y))},U=m=>{var j,$;((j=I.current)==null?void 0:j.pointerId)===m.pointerId&&(I.current=null,($=r.current)==null||$.releasePointerCapture(m.pointerId),L(!1))},G=C.useMemo(()=>$s(b,l),[b,l]),K=b.nodes.length===0,X=b.orientation==="stacked"?b.cardWidth+De/2:le+de/2;return n.jsxs("div",{className:"relative min-h-0 flex-1 border-t",children:[n.jsx("div",{ref:r,role:"region","aria-label":"Crew map","data-crew-map-layout":b.orientation,onScroll:m=>{v.current={left:m.currentTarget.scrollLeft,top:m.currentTarget.scrollTop},A.current||T(S)},onPointerDown:P,onPointerMove:W,onPointerUp:U,onPointerCancel:U,onKeyDown:m=>{m.target===m.currentTarget&&(m.key==="+"||m.key==="="?F(ke):m.key==="-"&&F(1/ke))},tabIndex:-1,className:oe("absolute inset-0 overflow-auto overscroll-contain outline-none [touch-action:pan-x_pan-y]","bg-muted/30 bg-local bg-[radial-gradient(circle,var(--border)_1px,transparent_1px)] bg-size-[18px_18px]",M?"cursor-grabbing select-none":"cursor-grab"),children:K?n.jsxs(rt,{className:"h-full",children:[n.jsxs(ct,{children:[n.jsx(dt,{children:"Nothing is active"}),n.jsx(ut,{className:"text-xs",children:"No session in this crew is working or waiting on you."})]}),n.jsx(J,{variant:"outline",size:"xs",onClick:h,children:"Show all sessions"})]}):n.jsx("div",{className:"relative",style:{width:E.width,height:E.height},children:n.jsxs("div",{className:"absolute origin-top-left",style:{left:S.left,top:S.top,width:b.width,height:b.height,transform:`scale(${R})`},children:[b.groups.map(m=>n.jsx("div",{"aria-hidden":"true",className:"absolute rounded-xl border border-dashed border-muted-foreground/25 bg-muted/25",style:{left:m.x,top:m.y,width:m.width,height:m.height}},m.parentId)),n.jsxs("svg",{"aria-hidden":"true",width:b.width,height:b.height,className:"pointer-events-none absolute inset-0 overflow-visible",fill:"none",children:[b.edges.map(m=>n.jsx("path",{d:m.path,className:"stroke-muted-foreground/35",strokeWidth:1.25},m.parentId)),G&&n.jsx("path",{d:G,className:"stroke-foreground/55",strokeWidth:1.5})]}),n.jsx("ul",{"aria-label":"Sessions",className:"absolute inset-0",children:b.nodes.map(m=>n.jsx(Hs,{node:m,width:b.cardWidth,toggleLeft:X,here:m.member.sessionId===l,kind:o.get(m.member.sessionId),name:c(m.member),onOpen:f,onToggle:j=>{O.current=j,x(j)}},m.member.sessionId))})]})})}),!K&&n.jsxs("div",{className:"absolute bottom-2.5 right-2.5 flex items-center gap-0.5 rounded-lg border bg-popover p-0.5 shadow-sm",children:[n.jsx(J,{variant:"ghost",size:"icon-xs","aria-label":"Zoom out",title:"Zoom out",disabled:R<=Fe,onClick:()=>F(1/ke),children:n.jsx(mt,{"data-icon":"inline-start"})}),n.jsxs(J,{variant:"ghost",size:"xs","aria-label":"Actual size",title:"Actual size",className:"min-w-11 px-1 tabular-nums text-muted-foreground",onClick:()=>F(1/R),children:[Math.round(R*100),"%"]}),n.jsx(J,{variant:"ghost",size:"icon-xs","aria-label":"Zoom in",title:"Zoom in",disabled:R>=at,onClick:()=>F(ke),children:n.jsx(as,{"data-icon":"inline-start"})}),n.jsx("span",{className:"mx-0.5 h-4 w-px bg-border","aria-hidden":"true"}),n.jsx(J,{variant:"ghost",size:"xs",title:"Fit the whole crew on screen",className:"px-1.5 text-muted-foreground",onClick:()=>z(Le(b,lt(b,w),w),()=>({left:0,top:0})),children:"Fit"})]})]})}const Ys={"needs-you":"border-warning/60 bg-[color-mix(in_oklch,var(--warning)_7%,var(--card))]",failed:"border-destructive/45",unreachable:"border-dashed"},qs={"needs-you":"text-warning",failed:"text-destructive"};function Ws(t){var s,i;const e=(s=t.pullRequests)==null?void 0:s.at(-1);return[t.model&&Ye(t.model),(i=t.device)==null?void 0:i.name,e&&`#${e.number}`,t.lastActivityAt&&qe(t.lastActivityAt)].filter(Boolean).join(" · ")}function Hs(t){const e=ue.c(75),{node:s,width:i,toggleLeft:l,here:o,kind:c,name:a,onOpen:f,onToggle:x}=t,{member:h}=s;let r;e[0]!==h?(r=he(h),e[0]=h,e[1]=r):r=e[1];const w=r;let u;e[2]!==h?(u=We(h),e[2]=h,e[3]=u):u=e[3];const g=u;let d;e[4]!==c?(d=c?Ft(c):os,e[4]=c,e[5]=d):d=e[5];const p=d;let N;e[6]!==h?(N=Ws(h),e[6]=h,e[7]=N):N=e[7];const k=N,b=s.context&&"shown because a session it started is active";let S;e[8]!==g||e[9]!==a||e[10]!==b?(S=[a,g,b].filter(Boolean),e[8]=g,e[9]=a,e[10]=b,e[11]=S):S=e[11];const y=S.join(", ");let M;e[12]!==s.x||e[13]!==s.y||e[14]!==i?(M={left:s.x,top:s.y,width:i,height:ne},e[12]=s.x,e[13]=s.y,e[14]=i,e[15]=M):M=e[15];const L=h.sessionId,A=o?"true":void 0;let O;e[16]!==h||e[17]!==f?(O=()=>f(h),e[16]=h,e[17]=f,e[18]=O):O=e[18];const v=Ys[w],_=o&&"outline-solid outline-[1.5px] outline-offset-2 outline-foreground/70",I=s.context&&"opacity-60 hover:opacity-100 focus-visible:opacity-100";let E;e[19]!==v||e[20]!==_||e[21]!==I?(E=oe("flex size-full cursor-pointer flex-col justify-center gap-1 rounded-lg border bg-card px-2.5 py-2 text-left shadow-xs outline-none","transition-[border-color,opacity,box-shadow] hover:border-foreground/25 hover:shadow-sm focus-visible:ring-2 focus-visible:ring-ring",v,_,I),e[19]=v,e[20]=_,e[21]=I,e[22]=E):E=e[22];let R;e[23]!==y||e[24]!==h.sessionId||e[25]!==w||e[26]!==O||e[27]!==E||e[28]!==A?(R=n.jsx("button",{type:"button","data-crew-map-card":L,"data-crew-map-state":w,"aria-current":A,"aria-label":y,onClick:O,className:E}),e[23]=y,e[24]=h.sessionId,e[25]=w,e[26]=O,e[27]=E,e[28]=A,e[29]=R):R=e[29];let T;e[30]!==p?(T=n.jsx(p,{"aria-hidden":"true",className:"mt-[3px] size-3.5 shrink-0 text-muted-foreground"}),e[30]=p,e[31]=T):T=e[31];let z;e[32]!==a?(z=n.jsx("span",{className:"line-clamp-2 min-w-0 flex-1 text-[13px]/[18px] font-medium",children:a}),e[32]=a,e[33]=z):z=e[33];let D;e[34]!==T||e[35]!==z?(D=n.jsxs("span",{className:"flex min-w-0 items-start gap-1.5",children:[T,z]}),e[34]=T,e[35]=z,e[36]=D):D=e[36];const Y=fe[w];let F;e[37]!==Y?(F=oe("size-1.5 shrink-0 rounded-full",Y),e[37]=Y,e[38]=F):F=e[38];let q;e[39]!==F?(q=n.jsx("span",{className:F,"aria-hidden":"true"}),e[39]=F,e[40]=q):q=e[40];let P;e[41]!==h||e[42]!==w?(P=$e(h)?"text-warning":qs[w],e[41]=h,e[42]=w,e[43]=P):P=e[43];let W;e[44]!==P?(W=oe("min-w-0 truncate text-muted-foreground",P),e[44]=P,e[45]=W):W=e[45];let U;e[46]!==g||e[47]!==W?(U=n.jsx("span",{className:W,children:g}),e[46]=g,e[47]=W,e[48]=U):U=e[48];let G;e[49]!==q||e[50]!==U?(G=n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-xs",children:[q,U]}),e[49]=q,e[50]=U,e[51]=G):G=e[51];let K;e[52]!==o||e[53]!==k?(K=(k||o)&&n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-[11.5px] tabular-nums text-muted-foreground/75",children:[n.jsx("span",{className:"min-w-0 flex-1 truncate",children:k}),o&&n.jsx("span",{className:"shrink-0 font-medium text-foreground/70",children:"You are here"})]}),e[52]=o,e[53]=k,e[54]=K):K=e[54];let X;e[55]!==R||e[56]!==D||e[57]!==G||e[58]!==K?(X=n.jsxs(Pt,{delay:700,render:R,children:[D,G,K]}),e[55]=R,e[56]=D,e[57]=G,e[58]=K,e[59]=X):X=e[59];let m;e[60]!==h||e[61]!==a?(m=n.jsx(Yt,{side:"left",align:"start",className:"max-w-72",children:n.jsx(Bs,{member:h,name:a})}),e[60]=h,e[61]=a,e[62]=m):m=e[62];let j;e[63]!==X||e[64]!==m?(j=n.jsxs(qt,{children:[X,m]}),e[63]=X,e[64]=m,e[65]=j):j=e[65];let $;e[66]!==a||e[67]!==s||e[68]!==x||e[69]!==l?($=s.childCount>0&&n.jsx(Us,{node:s,name:a,left:l,onToggle:x}),e[66]=a,e[67]=s,e[68]=x,e[69]=l,e[70]=$):$=e[70];let V;return e[71]!==j||e[72]!==$||e[73]!==M?(V=n.jsxs("li",{className:"group/node absolute",style:M,children:[j,$]}),e[71]=j,e[72]=$,e[73]=M,e[74]=V):V=e[74],V}function Us(t){const e=ue.c(25),{node:s,name:i,left:l,onToggle:o}=t,{collapsed:c,hidden:a}=s;let f=null;a.needsYou>0?f="needs-you":a.working>0&&(f="working");let x;e[0]!==c||e[1]!==a.count||e[2]!==a.needsYou||e[3]!==a.working||e[4]!==i?(x=c?[`Show the ${vt(a.count)} under ${i}`,a.needsYou>0&&`${a.needsYou} waiting on you`,a.working>0&&`${a.working} working`].filter(Boolean).join(", "):`Fold the sessions under ${i}`,e[0]=c,e[1]=a.count,e[2]=a.needsYou,e[3]=a.working,e[4]=i,e[5]=x):x=e[5];const h=x,r=!c,w=c?void 0:"Fold";let u;e[6]!==s.member.sessionId||e[7]!==o?(u=()=>o(s.member.sessionId),e[6]=s.member.sessionId,e[7]=o,e[8]=u):u=e[8];const g=!c&&"opacity-0 group-hover/node:opacity-100 focus-visible:opacity-100 [@media(hover:none)]:opacity-100";let d;e[9]!==g?(d=oe("absolute z-10 flex h-5 min-w-5 -translate-x-1/2 -translate-y-1/2 cursor-pointer items-center justify-center gap-1 rounded-full border bg-card px-1.5 text-[11px] font-medium tabular-nums text-muted-foreground shadow-xs outline-none","transition-opacity hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",g),e[9]=g,e[10]=d):d=e[10];let p;e[11]!==l?(p={left:l,top:ne/2},e[11]=l,e[12]=p):p=e[12];let N;e[13]!==f||e[14]!==c||e[15]!==a.count?(N=c?n.jsxs(n.Fragment,{children:[f&&n.jsx("span",{className:oe("size-1.5 rounded-full",fe[f]),"aria-hidden":"true"}),"+",a.count]}):n.jsx(mt,{"aria-hidden":"true",className:"size-3"}),e[13]=f,e[14]=c,e[15]=a.count,e[16]=N):N=e[16];let k;return e[17]!==h||e[18]!==r||e[19]!==w||e[20]!==u||e[21]!==d||e[22]!==p||e[23]!==N?(k=n.jsx("button",{type:"button","aria-expanded":r,"aria-label":h,title:w,onClick:u,className:d,style:p,children:N}),e[17]=h,e[18]=r,e[19]=w,e[20]=u,e[21]=d,e[22]=p,e[23]=N,e[24]=k):k=e[24],k}function Bs(t){var u,g;const e=ue.c(35),{member:s,name:i}=t;let l;e[0]!==s.firstUserMessage?(l=(u=s.firstUserMessage)==null?void 0:u.replace(/\s+/g," ").trim(),e[0]=s.firstUserMessage,e[1]=l):l=e[1];const o=l;let c;e[2]!==s.cwd?(c=(g=s.cwd)==null?void 0:g.split(/[\\/]/).filter(Boolean).at(-1),e[2]=s.cwd,e[3]=c):c=e[3];const a=c;let f;if(e[4]!==a||e[5]!==s.device||e[6]!==s.model||e[7]!==s.startedAt||e[8]!==s.turnCount){if(f=[],s.model){let d;e[10]!==s.model?(d=Ye(s.model),e[10]=s.model,e[11]=d):d=e[11];let p;e[12]!==d?(p=["Model",d],e[12]=d,e[13]=p):p=e[13],f.push(p)}if(s.device){let d;e[14]!==s.device.name?(d=["Device",s.device.name],e[14]=s.device.name,e[15]=d):d=e[15],f.push(d)}if(a){let d;e[16]!==a?(d=["Folder",a],e[16]=a,e[17]=d):d=e[17],f.push(d)}if(s.startedAt){let d;e[18]!==s.startedAt?(d=pt(s.startedAt),e[18]=s.startedAt,e[19]=d):d=e[19];let p;e[20]!==d?(p=["Started",d],e[20]=d,e[21]=p):p=e[21],f.push(p)}if(s.turnCount){const d=String(s.turnCount);let p;e[22]!==d?(p=["Turns",d],e[22]=d,e[23]=p):p=e[23],f.push(p)}e[4]=a,e[5]=s.device,e[6]=s.model,e[7]=s.startedAt,e[8]=s.turnCount,e[9]=f}else f=e[9];let x;e[24]!==i?(x=n.jsx("p",{className:"font-medium",children:i}),e[24]=i,e[25]=x):x=e[25];let h;e[26]!==i||e[27]!==o?(h=o&&o!==i&&n.jsx("p",{className:"line-clamp-3 text-muted-foreground",children:o}),e[26]=i,e[27]=o,e[28]=h):h=e[28];let r;e[29]!==f?(r=f.length>0&&n.jsx("dl",{className:"grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-0.5",children:f.map(Gs)}),e[29]=f,e[30]=r):r=e[30];let w;return e[31]!==x||e[32]!==h||e[33]!==r?(w=n.jsxs("div",{className:"flex flex-col gap-1.5 py-0.5",children:[x,h,r]}),e[31]=x,e[32]=h,e[33]=r,e[34]=w):w=e[34],w}function Gs(t){const[e,s]=t;return n.jsxs("div",{className:"contents",children:[n.jsx("dt",{className:"text-muted-foreground",children:e}),n.jsx("dd",{className:"truncate tabular-nums",children:s})]},e)}const Ks=4e3;function Vs(t){var d;const[e,s]=C.useState(null),[i,l]=C.useState(null),[o,c]=C.useState(new Set),a=(d=Wt())==null?void 0:d.refresh,f=C.useRef(t),x=C.useRef(new Set);C.useLayoutEffect(()=>(f.current=t,()=>{f.current=null}),[t]);const h=C.useCallback(async p=>{if(t)try{const N=await _e(`/api/session-crew/${encodeURIComponent(t)}`);if(!p())return;if(!N.ok){l(N.status===404?"This session is no longer available.":"Couldn't load the crew.");return}const k=await N.json();if(!p())return;s(b=>JSON.stringify(b)===JSON.stringify(k)?b:k),l(null)}catch{p()&&l("Couldn't load the crew.")}},[t]);it(t?h:null,Ks),C.useEffect(()=>{s(p=>p!=null&&p.members.some(N=>N.sessionId===t)?p:null),l(null),c(new Set)},[t]);const r=C.useCallback(async(p,N,k)=>{const b=`${t}:${p}`;if(x.current.has(b))return;const S=()=>f.current===t;x.current.add(b),c(y=>new Set(y).add(p));try{const y=await N();if(!S())return;if(!y.ok&&y.status!==404){l(k);return}a==null||a(),await h(S)}catch{S()&&l(k)}finally{x.current.delete(b),S()&&c(y=>{const M=new Set(y);return M.delete(p),M})}},[h,a,t]),w=C.useCallback((p,N,k)=>r(N,()=>je("/api/session-respond",{sessionId:p,requestId:N,...k}),"Couldn't send the answer."),[r]),u=C.useCallback((p,N)=>r(N,()=>je("/api/delegated-tasks",{sessionId:p,taskId:N,action:"ack"}),"Couldn't mark the result read."),[r]),g=C.useCallback(p=>r(p.sessionId,()=>{var N;return((N=p.result)==null?void 0:N.state)==="running"&&p.parentId?je("/api/delegated-tasks",{sessionId:p.parentId,taskId:p.result.taskId,action:"cancel"}):je("/api/stop-session",{sessionId:p.sessionId,cancelQueued:!0})},"Couldn't stop the session."),[r]);return{crew:e,error:i,busy:o,respond:w,markRead:u,stop:g}}const Xs=[{id:"all",label:"All"},{id:"working",label:"Working"},{id:"needs-you",label:"Need you"},{id:"done",label:"Done"}];function dn(t){var q;const e=ue.c(37),{context:s,closePanel:i}=t,l=((q=s.session)==null?void 0:q.sessionId)??null,{crew:o,error:c,busy:a,respond:f,markRead:x,stop:h}=Vs(l),{names:r}=Ht(),[w,u]=C.useState("overview");let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=new Set,e[0]=g):g=e[0];const[d,p]=C.useState(g),N=Ls((o==null?void 0:o.rootId)??"");let k;e[1]!==(o==null?void 0:o.members)?(k=new Map(((o==null?void 0:o.members)??[]).map(Js)),e[1]=o==null?void 0:o.members,e[2]=k):k=e[2];const b=k;let S;e[3]!==(o==null?void 0:o.members)?(S=new Map(((o==null?void 0:o.members)??[]).flatMap(Zs)),e[3]=o==null?void 0:o.members,e[4]=S):S=e[4];const y=S;let M;e[5]!==b||e[6]!==r?(M=P=>xs(P,b,r),e[5]=b,e[6]=r,e[7]=M):M=e[7];const L=M;let A;e[8]!==s?(A=P=>{P.address&&P.device?Xt(Zt(P.address.dirName,P.address.fileName,P.device.id)):P.address&&s.openSession?s.openSession(P.address.dirName,P.address.fileName):Jt(P.sessionId)},e[8]=s,e[9]=A):A=e[9];const O=A;let v;e[10]===Symbol.for("react.memo_cache_sentinel")?(v=P=>p(W=>{const U=new Set(W);return U.delete(P)||U.add(P),U}),e[10]=v):v=e[10];const _=v;let I,E,R;e[11]===Symbol.for("react.memo_cache_sentinel")?(I=n.jsx(ht,{"aria-hidden":"true",className:"size-4 text-muted-foreground"}),E=n.jsx("h2",{className:"text-sm font-medium",children:"Crew"}),R=n.jsx("div",{className:"flex-1"}),e[11]=I,e[12]=E,e[13]=R):(I=e[11],E=e[12],R=e[13]);let T;e[14]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsx(cs,{"data-icon":"inline-start"}),e[14]=T):T=e[14];let z;e[15]!==i?(z=n.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-2 px-3",children:[I,E,R,n.jsx(J,{variant:"ghost",size:"icon-sm",onClick:i,"aria-label":"Close crew",children:T})]}),e[15]=i,e[16]=z):z=e[16];let D;e[17]!==c?(D=c&&n.jsx("p",{role:"alert",className:"px-3 pb-2 text-xs text-destructive",children:c}),e[17]=c,e[18]=D):D=e[18];let Y;e[19]!==a||e[20]!==d||e[21]!==o||e[22]!==c||e[23]!==y||e[24]!==N||e[25]!==x||e[26]!==L||e[27]!==O||e[28]!==f||e[29]!==l||e[30]!==h||e[31]!==w?(Y=o?n.jsxs(Ut,{value:w,onValueChange:u,className:"min-h-0 flex-1 grid-rows-[auto_minmax(0,1fr)]",children:[n.jsxs(Bt,{variant:"line",className:"mx-3 mb-1",children:[n.jsx(Te,{value:"overview",children:"Overview"}),n.jsx(Te,{value:"map",children:"Map"}),n.jsx(Te,{value:"chat",children:"Chat"})]}),n.jsx(Ae,{value:"overview",className:"min-h-0",children:n.jsxs(ft,{className:"h-full min-h-0",children:[n.jsx(Qs,{crew:o,hereId:l,nameOf:L,onOpen:O}),n.jsx(tn,{crew:o,busy:a,nameOf:L,onOpen:O,onRespond:f}),n.jsx(sn,{crew:o,hereId:l,busy:a,nameOf:L,onOpen:O,onMarkRead:x,onStop:h,collapsed:d,onToggle:_})]})}),n.jsx(Ae,{value:"map",className:"min-h-0",children:n.jsx(_s,{crew:o,hereId:l,controls:N,kinds:y,nameOf:L,onOpen:O})}),n.jsx(Ae,{value:"chat",keepMounted:!0,className:"min-h-0",children:n.jsx(hs,{rootId:o.rootId,kinds:y,active:w==="chat"},o.rootId)})]}):!c&&n.jsx("p",{className:"px-3 py-6 text-center text-sm text-muted-foreground",children:"Loading the crew…"}),e[19]=a,e[20]=d,e[21]=o,e[22]=c,e[23]=y,e[24]=N,e[25]=x,e[26]=L,e[27]=O,e[28]=f,e[29]=l,e[30]=h,e[31]=w,e[32]=Y):Y=e[32];let F;return e[33]!==z||e[34]!==D||e[35]!==Y?(F=n.jsxs("aside",{"aria-label":"Crew",className:"flex size-full min-h-0 flex-col bg-canvas",children:[z,D,Y]}),e[33]=z,e[34]=D,e[35]=Y,e[36]=F):F=e[36],F}function Zs(t){return t.address?[[t.sessionId,Gt(t.address.dirName)]]:[]}function Js(t){return[t.sessionId,t]}function Qs(t){var v;const e=ue.c(52),{crew:s,hereId:i,nameOf:l,onOpen:o}=t;let c,a,f,x,h,r,w,u,g,d;if(e[0]!==s||e[1]!==i||e[2]!==l||e[3]!==o){let _;e[14]!==s.rootId?(_=T=>T.sessionId===s.rootId,e[14]=s.rootId,e[15]=_):_=e[15];const I=s.members.find(_);let E;e[16]!==s?(E=bs(s),e[16]=s,e[17]=E):E=e[17],d=E;const R=(v=s.members.find(en))==null?void 0:v.startedAt;u="Crew summary",g="border-b px-3 pb-3 pt-1",r="flex items-baseline gap-2",w=I&&n.jsx("button",{type:"button",onClick:()=>o(I),"aria-current":I.sessionId===i?"true":void 0,className:"min-w-0 flex-1 truncate rounded-sm text-left text-sm font-medium outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring",children:l(I)}),c="shrink-0 text-xs tabular-nums text-muted-foreground",a=d.size,f=" ",x=d.size===1?"session":"sessions",h=R?` · since ${pt(R)}`:"",e[0]=s,e[1]=i,e[2]=l,e[3]=o,e[4]=c,e[5]=a,e[6]=f,e[7]=x,e[8]=h,e[9]=r,e[10]=w,e[11]=u,e[12]=g,e[13]=d}else c=e[4],a=e[5],f=e[6],x=e[7],h=e[8],r=e[9],w=e[10],u=e[11],g=e[12],d=e[13];let p;e[18]!==c||e[19]!==a||e[20]!==f||e[21]!==x||e[22]!==h?(p=n.jsxs("span",{className:c,children:[a,f,x,h]}),e[18]=c,e[19]=a,e[20]=f,e[21]=x,e[22]=h,e[23]=p):p=e[23];let N;e[24]!==p||e[25]!==r||e[26]!==w?(N=n.jsxs("div",{className:r,children:[w,p]}),e[24]=p,e[25]=r,e[26]=w,e[27]=N):N=e[27];let k;e[28]!==d.working?(k=d.working>0&&n.jsx(Ne,{dot:fe.working,value:d.working,label:"working"}),e[28]=d.working,e[29]=k):k=e[29];let b;e[30]!==d.needsYou?(b=d.needsYou>0&&n.jsx(Ne,{dot:fe["needs-you"],value:d.needsYou,label:d.needsYou===1?"needs you":"need you"}),e[30]=d.needsYou,e[31]=b):b=e[31];let S;e[32]!==d.done?(S=d.done>0&&n.jsx(Ne,{dot:fe.done,value:d.done,label:"done"}),e[32]=d.done,e[33]=S):S=e[33];let y;e[34]!==d.failed?(y=d.failed>0&&n.jsx(Ne,{dot:fe.failed,value:d.failed,label:"failed"}),e[34]=d.failed,e[35]=y):y=e[35];let M;e[36]!==d.unreachable?(M=d.unreachable>0&&n.jsx(Ne,{dot:fe.unreachable,value:d.unreachable,label:"away"}),e[36]=d.unreachable,e[37]=M):M=e[37];let L;e[38]!==d.unreadResults?(L=d.unreadResults>0&&n.jsxs("span",{className:"ml-auto text-warning",children:[n.jsx("span",{className:"font-medium tabular-nums",children:d.unreadResults})," ",d.unreadResults===1?"result":"results"," unread"]}),e[38]=d.unreadResults,e[39]=L):L=e[39];let A;e[40]!==k||e[41]!==b||e[42]!==S||e[43]!==y||e[44]!==M||e[45]!==L?(A=n.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3.5 gap-y-1 text-xs text-muted-foreground",children:[k,b,S,y,M,L]}),e[40]=k,e[41]=b,e[42]=S,e[43]=y,e[44]=M,e[45]=L,e[46]=A):A=e[46];let O;return e[47]!==N||e[48]!==A||e[49]!==u||e[50]!==g?(O=n.jsxs("section",{"aria-label":u,className:g,children:[N,A]}),e[47]=N,e[48]=A,e[49]=u,e[50]=g,e[51]=O):O=e[51],O}function en(t){return t.parentId!==null}function Ne(t){const e=ue.c(10),{dot:s,value:i,label:l}=t;let o;e[0]!==s?(o=oe("size-1.5 rounded-full",s),e[0]=s,e[1]=o):o=e[1];let c;e[2]!==o?(c=n.jsx("span",{className:o,"aria-hidden":"true"}),e[2]=o,e[3]=c):c=e[3];let a;e[4]!==i?(a=n.jsx("span",{className:"font-medium tabular-nums text-foreground",children:i}),e[4]=i,e[5]=a):a=e[5];let f;return e[6]!==l||e[7]!==c||e[8]!==a?(f=n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[c,a," ",l]}),e[6]=l,e[7]=c,e[8]=a,e[9]=f):f=e[9],f}function tn(t){const e=ue.c(6),{crew:s,busy:i,nameOf:l,onOpen:o,onRespond:c}=t,a=ws(s),[f,x]=C.useState(0);if(a.length===0)return null;const h=Math.min(f,a.length-1),{member:r,pending:w}=a[h],u=a[h+1];let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx("h3",{className:"text-sm font-medium text-foreground",children:"Needs you"}),e[0]=g):g=e[0];let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx("span",{className:"flex-1"}),e[1]=d):d=e[1];let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx("span",{className:oe("size-1.5 shrink-0 rounded-full",fe["needs-you"]),"aria-hidden":"true"}),e[2]=p):p=e[2];const N=w.askedAt?`waiting ${qe(new Date(w.askedAt).toISOString())}`:"waiting";let k;e[3]!==N?(k=n.jsx("span",{className:"ml-auto shrink-0 tabular-nums text-warning",children:N}),e[3]=N,e[4]=k):k=e[4];let b;return e[5]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(ze,{"data-icon":"inline-end"}),e[5]=b):b=e[5],n.jsxs("section",{"aria-label":"Needs you",className:"border-b px-3 py-2.5",children:[n.jsxs("div",{className:"mb-2 flex items-center gap-2 text-xs text-muted-foreground",children:[g,n.jsx("span",{className:"tabular-nums",children:a.length}),d,a.length>1&&n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"tabular-nums",children:[h+1," of ",a.length]}),n.jsx(J,{variant:"ghost",size:"icon-xs","aria-label":"Previous request",disabled:h===0,onClick:()=>x(h-1),children:n.jsx(ls,{"data-icon":"inline-start"})}),n.jsx(J,{variant:"ghost",size:"icon-xs","aria-label":"Next request",disabled:h===a.length-1,onClick:()=>x(h+1),children:n.jsx(ze,{"data-icon":"inline-start"})})]})]}),n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsxs("div",{className:"flex items-center gap-2 px-0.5 text-xs",children:[p,n.jsx("span",{className:"min-w-0 truncate font-medium text-foreground",children:l(r)}),r.device&&n.jsx(Kt,{variant:"outline",children:r.device.name}),k]}),n.jsx(Vt,{sessionId:r.sessionId,pending:w,queued:0,responding:i.has(w.requestId),onRespond:(S,y)=>void c(r.sessionId,S,y),onOpen:()=>o(r)},w.requestId),n.jsxs(J,{variant:"ghost",size:"xs",className:"self-end text-muted-foreground",onClick:()=>o(r),children:["Open session",b]})]}),u&&n.jsxs("p",{className:"mt-2 truncate text-xs text-muted-foreground",children:["Next: ",n.jsx("span",{className:"font-medium text-foreground",children:l(u.member)})," ",We(u.member).toLowerCase()]})]})}function sn({crew:t,hereId:e,busy:s,nameOf:i,onOpen:l,onMarkRead:o,onStop:c,collapsed:a,onToggle:f}){const[x,h]=C.useState("working");let r=null;const w=gs(t).filter(({member:u,depth:g})=>{if(x!=="all"){const d=he(u);return x==="done"?d!=="working"&&d!=="needs-you":d===x}return r!==null&&g>r?!1:(r=a.has(u.sessionId)?g:null,!0)});return n.jsxs("section",{"aria-label":"Sessions",className:"px-1.5 py-2.5",children:[n.jsxs("div",{className:"mb-1.5 flex items-center gap-2 px-1.5",children:[n.jsx("h3",{className:"text-sm font-medium",children:"Sessions"}),n.jsx("span",{className:"flex-1"}),n.jsx("div",{role:"radiogroup","aria-label":"Show sessions",className:"flex gap-0.5",children:Xs.map(({id:u,label:g})=>n.jsx("button",{type:"button",role:"radio","aria-checked":x===u,onClick:()=>h(u),className:oe("rounded-full px-2 py-0.5 text-[11px] text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",x===u&&"bg-accent text-foreground"),children:g},u))})]}),w.length===0?n.jsxs("div",{className:"flex flex-col items-center gap-1 px-1.5 py-4 text-xs text-muted-foreground",children:[n.jsx("p",{children:x==="working"?"Nothing is working right now.":"No sessions here."}),x!=="all"&&n.jsx(J,{variant:"ghost",size:"xs",onClick:()=>h("all"),children:"Show all"})]}):n.jsx("ul",{className:"flex flex-col",children:w.map(u=>n.jsx(nn,{row:u,here:u.member.sessionId===e,busy:s,name:i(u.member),onOpen:l,onMarkRead:o,onStop:c,collapsed:x==="all"?a.has(u.member.sessionId):void 0,onToggle:()=>f(u.member.sessionId)},u.member.sessionId))})]})}function nn(t){var ce,me;const e=ue.c(81),{row:s,here:i,busy:l,name:o,onOpen:c,onMarkRead:a,onStop:f,collapsed:x,onToggle:h}=t,{member:r,depth:w,children:u}=s;let g;e[0]!==r?(g=he(r),e[0]=r,e[1]=g):g=e[1];const d=g;let p;e[2]!==r?(p=We(r),e[2]=r,e[3]=p):p=e[3];const N=p;let k;e[4]!==r.pullRequests?(k=(ce=r.pullRequests)==null?void 0:ce.at(-1),e[4]=r.pullRequests,e[5]=k):k=e[5];const b=k;let S;e[6]!==r?(S=$e(r)&&r.result&&r.parentId,e[6]=r,e[7]=S):S=e[7];const y=S,M=(d==="working"||d==="needs-you")&&(!r.device||((me=r.result)==null?void 0:me.state)==="running"&&r.parentId!==null),L=r.sessionId,A=i?"bg-accent":"hover:bg-accent/60",O=w>0&&"border-l border-border/70";let v;e[8]!==A||e[9]!==O?(v=oe("group/crew relative flex items-start rounded-md",A,O),e[8]=A,e[9]=O,e[10]=v):v=e[10];const _=w>0?6+(w-1)*14:0;let I;e[11]!==_?(I={marginLeft:_},e[11]=_,e[12]=I):I=e[12];let E;e[13]!==u||e[14]!==x||e[15]!==o||e[16]!==h?(E=u>0&&x!==void 0&&n.jsx(J,{variant:"ghost",size:"icon-xs","aria-label":`${x?"Expand":"Collapse"} ${o}'s child sessions`,"aria-expanded":!x,onClick:h,children:n.jsx(ze,{"data-icon":"inline-start",className:oe("transition-transform",!x&&"rotate-90")})}),e[13]=u,e[14]=x,e[15]=o,e[16]=h,e[17]=E):E=e[17];let R;e[18]!==E?(R=n.jsx("span",{className:"mt-1.5 flex w-6 shrink-0 justify-center",children:E}),e[18]=E,e[19]=R):R=e[19];let T;e[20]!==r||e[21]!==c?(T=()=>c(r),e[20]=r,e[21]=c,e[22]=T):T=e[22];const z=i?"true":void 0,D=`${o}, ${N}`,Y=fe[d];let F;e[23]!==Y?(F=oe("size-1.5 justify-self-center rounded-full",Y),e[23]=Y,e[24]=F):F=e[24];let q;e[25]!==F?(q=n.jsx("span",{className:F,"aria-hidden":"true"}),e[25]=F,e[26]=q):q=e[26];let P;e[27]!==o?(P=n.jsx("span",{className:"truncate",children:o}),e[27]=o,e[28]=P):P=e[28];let W;e[29]!==i?(W=i&&n.jsx("span",{className:"shrink-0 rounded-full border px-1.5 text-[10.5px] font-normal text-muted-foreground",children:"you are here"}),e[29]=i,e[30]=W):W=e[30];let U;e[31]!==P||e[32]!==W?(U=n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-[12.5px] font-medium",children:[P,W]}),e[31]=P,e[32]=W,e[33]=U):U=e[33];let G;e[34]!==r.lastActivityAt?(G=r.lastActivityAt?qe(r.lastActivityAt):"",e[34]=r.lastActivityAt,e[35]=G):G=e[35];let K;e[36]!==G?(K=n.jsx("span",{className:"text-[11px] tabular-nums text-muted-foreground/80",children:G}),e[36]=G,e[37]=K):K=e[37];const X=(d==="needs-you"||y)&&"text-warning",m=d==="failed"&&"text-destructive";let j;e[38]!==X||e[39]!==m?(j=oe("min-w-0 flex-1 truncate",X,m),e[38]=X,e[39]=m,e[40]=j):j=e[40];let $;e[41]!==N||e[42]!==j?($=n.jsx("span",{className:j,children:N}),e[41]=N,e[42]=j,e[43]=$):$=e[43];let V;e[44]!==b?(V=b&&n.jsxs("span",{className:"shrink-0 rounded-full border px-1.5 text-[11px]",children:["#",b.number]}),e[44]=b,e[45]=V):V=e[45];let ae;e[46]!==r.device?(ae=r.device&&n.jsx("span",{className:"shrink-0",children:r.device.name}),e[46]=r.device,e[47]=ae):ae=e[47];let Q;e[48]!==u?(Q=u>0&&n.jsxs("span",{className:"shrink-0",children:[u," ",u===1?"session":"sessions"]}),e[48]=u,e[49]=Q):Q=e[49];let ee;e[50]!==r.model?(ee=r.model&&n.jsx("span",{className:"shrink-0 text-muted-foreground/70",children:Ye(r.model)}),e[50]=r.model,e[51]=ee):ee=e[51];let te;e[52]!==$||e[53]!==V||e[54]!==ae||e[55]!==Q||e[56]!==ee?(te=n.jsxs("span",{className:"col-start-2 col-end-4 flex min-w-0 items-center gap-2 text-[11.5px] text-muted-foreground",children:[$,V,ae,Q,ee]}),e[52]=$,e[53]=V,e[54]=ae,e[55]=Q,e[56]=ee,e[57]=te):te=e[57];let se;e[58]!==T||e[59]!==z||e[60]!==D||e[61]!==q||e[62]!==U||e[63]!==K||e[64]!==te?(se=n.jsxs("button",{type:"button",onClick:T,"aria-current":z,"aria-label":D,className:"grid min-w-0 flex-1 grid-cols-[14px_minmax(0,1fr)_auto] items-center gap-x-2 gap-y-0.5 rounded-md px-2 py-1.5 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[q,U,K,te]}),e[58]=T,e[59]=z,e[60]=D,e[61]=q,e[62]=U,e[63]=K,e[64]=te,e[65]=se):se=e[65];let re;e[66]!==l||e[67]!==M||e[68]!==r||e[69]!==o||e[70]!==a||e[71]!==f||e[72]!==y?(re=(y||M)&&n.jsxs("div",{className:"absolute right-1.5 top-1 hidden gap-1 group-focus-within/crew:flex group-hover/crew:flex",children:[y&&r.result&&r.parentId&&n.jsx(J,{variant:"outline",size:"icon-xs",className:"bg-popover","aria-label":`Mark ${o}'s result read`,title:"Mark the result read",disabled:l.has(r.result.taskId),onClick:()=>void a(r.parentId,r.result.taskId),children:n.jsx(is,{"data-icon":"inline-start"})}),M&&n.jsx(J,{variant:"outline",size:"icon-xs",className:"bg-popover text-destructive","aria-label":`Stop ${o}`,title:"Stop this session",disabled:l.has(r.sessionId),onClick:()=>void f(r),children:n.jsx(rs,{"data-icon":"inline-start"})})]}),e[66]=l,e[67]=M,e[68]=r,e[69]=o,e[70]=a,e[71]=f,e[72]=y,e[73]=re):re=e[73];let Z;return e[74]!==r.sessionId||e[75]!==I||e[76]!==R||e[77]!==se||e[78]!==re||e[79]!==v?(Z=n.jsxs("li",{"data-crew-row":L,className:v,style:I,children:[R,se,re]}),e[74]=r.sessionId,e[75]=I,e[76]=R,e[77]=se,e[78]=re,e[79]=v,e[80]=Z):Z=e[80],Z}export{dn as CrewPanel};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as T,r as L,j as c}from"./vendor-react-gGw_S5I_.js";import{
|
|
1
|
+
import{c as T,r as L,j as c}from"./vendor-react-gGw_S5I_.js";import{di as _,dj as C,dk as D,c as H}from"./index-BYVl1VlW.js";function M(r){const e=T.c(26),{value:t,onChange:j,readOnly:i,filePath:k,ariaLabel:R,textareaRef:f,onKeyDown:v,onSelect:w}=r,N=_(),u=L.useRef(null),p=L.useRef(null);let d;e[0]!==k?(d=C(k),e[0]=k,e[1]=d):d=e[1];const h=D(t,d,N,80);let m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{u.current&&p.current&&(p.current.scrollTop=u.current.scrollTop,p.current.scrollLeft=u.current.scrollLeft)},e[2]=m):m=e[2];const S=m;let x;e[3]!==f?(x=b=>{u.current=b,f&&(f.current=b)},e[3]=f,e[4]=x):x=e[4];const y=x;let l;e[5]!==h||e[6]!==t?(l=h?h.map(P):c.jsx("code",{className:"text-foreground",children:t}),e[5]=h,e[6]=t,e[7]=l):l=e[7];let n;e[8]!==l?(n=c.jsx("pre",{ref:p,"aria-hidden":!0,className:"absolute inset-0 overflow-hidden font-mono text-[13px] leading-relaxed p-4 m-0 pointer-events-none whitespace-pre-wrap break-words",children:l}),e[8]=l,e[9]=n):n=e[9];let s;e[10]!==j?(s=b=>j(b.target.value),e[10]=j,e[11]=s):s=e[11];const E=i&&"cursor-default";let a;e[12]!==E?(a=H("absolute inset-0 w-full h-full resize-none bg-transparent font-mono text-[13px] leading-relaxed p-4 outline-none","text-transparent caret-foreground selection:bg-selection","scrollbar-thin scrollbar-track-transparent scrollbar-thumb-border",E),e[12]=E,e[13]=a):a=e[13];let o;e[14]!==R||e[15]!==y||e[16]!==v||e[17]!==w||e[18]!==i||e[19]!==s||e[20]!==a||e[21]!==t?(o=c.jsx("textarea",{ref:y,"aria-label":R,value:t,onChange:s,onScroll:S,onKeyDown:v,onSelect:w,readOnly:i,spellCheck:!1,className:a,placeholder:"Empty file"}),e[14]=R,e[15]=y,e[16]=v,e[17]=w,e[18]=i,e[19]=s,e[20]=a,e[21]=t,e[22]=o):o=e[22];let g;return e[23]!==n||e[24]!==o?(g=c.jsxs("div",{className:"relative min-h-0 flex-1 bg-background",children:[n,o]}),e[23]=n,e[24]=o,e[25]=g):g=e[25],g}function P(r,e){return c.jsxs("span",{children:[r.map(z),`
|
|
2
2
|
`]},e)}function z(r,e){return c.jsx("span",{style:{color:r.color},children:r.content},e)}export{M as H};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as Q,j as t,r as E}from"./vendor-react-gGw_S5I_.js";import{o as F,bJ as A,bK as O,bL as M,B as L,bM as Y,bN as _,n as q,l as H,D as J,j as U,S as V,ax as W,az as X,aw as Z,bO as ee,G as te,I as se,m as ae,bP as le,bQ as ne,bR as re}from"./index-BYVl1VlW.js";import{bL as T,cC as oe,ao as ce}from"./vendor-ui-B0az9ATE.js";import"./vendor-markdown-BEJ8yVzA.js";const ie=new Set(["Alt","Control","Meta","Shift"]);function pe(e){const s=Q.c(6),{open:f,onOpenChange:l}=e,x=f?"open":"closed";let a;s[0]!==x?(a=t.jsx(de,{},x),s[0]=x,s[1]=a):a=s[1];let r;return s[2]!==l||s[3]!==f||s[4]!==a?(r=t.jsx(F,{open:f,onOpenChange:l,children:a}),s[2]=l,s[3]=f,s[4]=a,s[5]=r):r=s[5],r}function de(){const e=Q.c(45),[s,f]=E.useState(""),[l,x]=E.useState(null),[a,r]=E.useState(null),[G,z]=E.useState(A);let I,k;e[0]!==l?(I=()=>{if(!l)return;const D=l,$=function(n){if(n.key==="Escape"){n.preventDefault(),n.stopPropagation(),x(null),r(null);return}if(ie.has(n.key))return;n.preventDefault(),n.stopPropagation();const c=le(n),p=ne(c,D);if(p){r(`Already assigned to “${p.label}”.`);return}re(D,c),z(A()),x(null),r(null)};return window.addEventListener("keydown",$,!0),()=>window.removeEventListener("keydown",$,!0)},k=[l],e[0]=l,e[1]=I,e[2]=k):(I=e[1],k=e[2]),E.useEffect(I,k);let b,g,d,j,y,N,S,w,m,u,h;if(e[3]!==G||e[4]!==a||e[5]!==s||e[6]!==l){const D=s.trim().toLowerCase(),$=D?O.filter(i=>`${i.label} ${i.description} ${i.group}`.toLowerCase().includes(D)):O;g=q,S="max-w-2xl gap-0 overflow-hidden p-0",w=!1,e[18]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsxs(H,{className:"p-4 pb-3",children:[t.jsxs(J,{className:"flex items-center gap-2",children:[t.jsx(oe,{"data-icon":"inline-start","aria-hidden":"true",className:"size-4"}),"Keyboard shortcuts"]}),t.jsx(U,{children:"Click a shortcut, then press a new key combination. Changes are saved on this device."})]}),u=t.jsx(V,{}),e[18]=m,e[19]=u):(m=e[18],u=e[19]);let K;e[20]===Symbol.for("react.memo_cache_sentinel")?(K=t.jsx(W,{children:t.jsx(ce,{"data-icon":"inline-start","aria-hidden":"true"})}),e[20]=K):K=e[20];let n;e[21]===Symbol.for("react.memo_cache_sentinel")?(n=i=>f(i.target.value),e[21]=n):n=e[21];let c;e[22]!==s?(c=t.jsxs(X,{className:"flex-1",children:[K,t.jsx(Z,{"aria-label":"Search keyboard shortcuts",value:s,onChange:n,placeholder:"Search shortcuts…"})]}),e[22]=s,e[23]=c):c=e[23];let p;e[24]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsxs(L,{variant:"outline",size:"sm",onClick:()=>{ee(),z(A()),r(null)},children:[t.jsx(T,{"data-icon":"inline-start"}),"Reset all"]}),e[24]=p):p=e[24],e[25]!==c?(h=t.jsxs("div",{className:"flex items-center gap-2 p-3",children:[c,p]}),e[25]=c,e[26]=h):h=e[26],e[27]!==a?(d=a&&t.jsx(te,{variant:"destructive",className:"mx-3 mb-2 w-auto",children:t.jsxs(se,{children:[a," Press another shortcut or Esc to cancel."]})}),e[27]=a,e[28]=d):d=e[28],b=ae,N="h-[min(28rem,60vh)]",j="flex flex-col gap-4 px-3 pb-4",y=M.map(i=>{const P=$.filter(o=>o.group===i);return P.length===0?null:t.jsxs("section",{className:"flex flex-col gap-1",children:[t.jsx("h3",{className:"px-2 py-1 text-xs font-medium text-muted-foreground",children:i}),P.map(o=>{const B=l===o.command;return t.jsxs("div",{className:"flex min-h-12 items-center gap-3 rounded-md px-2 py-1.5 hover:bg-accent",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"truncate text-sm",children:o.label}),t.jsx("p",{className:"truncate text-xs text-muted-foreground",children:o.description})]}),t.jsx(L,{variant:B?"secondary":"outline",size:"sm",className:"min-w-28 font-mono text-xs",onClick:()=>{r(null),x(B?null:o.command)},"aria-label":`Change shortcut for ${o.label}`,children:B?"Press keys…":Y(G[o.command])}),t.jsx(L,{variant:"ghost",size:"icon-sm",onClick:()=>{_(o.command),z(A()),r(null)},"aria-label":`Reset shortcut for ${o.label}`,children:t.jsx(T,{"data-icon":"inline-start"})})]},o.command)})]},i)}),e[3]=G,e[4]=a,e[5]=s,e[6]=l,e[7]=b,e[8]=g,e[9]=d,e[10]=j,e[11]=y,e[12]=N,e[13]=S,e[14]=w,e[15]=m,e[16]=u,e[17]=h}else b=e[7],g=e[8],d=e[9],j=e[10],y=e[11],N=e[12],S=e[13],w=e[14],m=e[15],u=e[16],h=e[17];let C;e[29]!==j||e[30]!==y?(C=t.jsx("div",{className:j,children:y}),e[29]=j,e[30]=y,e[31]=C):C=e[31];let v;e[32]!==b||e[33]!==C||e[34]!==N?(v=t.jsx(b,{className:N,children:C}),e[32]=b,e[33]=C,e[34]=N,e[35]=v):v=e[35];let R;return e[36]!==g||e[37]!==d||e[38]!==v||e[39]!==S||e[40]!==w||e[41]!==m||e[42]!==u||e[43]!==h?(R=t.jsxs(g,{className:S,showCloseButton:w,children:[m,u,h,d,v]}),e[36]=g,e[37]=d,e[38]=v,e[39]=S,e[40]=w,e[41]=m,e[42]=u,e[43]=h,e[44]=R):R=e[44],R}export{pe as KeyboardShortcutsDialog};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{c as F,j as t,r as H}from"./vendor-react-gGw_S5I_.js";import{bB as cs,c as le,B as $,cl as ds,al as ts,cm as us,cn as fs,co as ms,cp as xs,cq as gs,cr as hs,cs as ps,ag as bs,ct as ns,cu as Le,cv as ws,cw as js,cx as ys,cy as Ns,ad as vs,cz as Is,cA as ks,bS as Ss,cB as qs,au as Ue,H as He,G as Qe,bI as Cs,cC as ze,aA as Ds,aB as As,cD as Es,cE as _s,cF as Ps,cG as Ms,cH as Rs,cI as Fe,cJ as Os,cK as Ts,cL as zs,ah as $s,cM as Bs,bb as Ve,V as Ae,E as Ks,f as Ls,i as Fs,cN as Us,k as Hs,cO as Pe,cP as Qs,cQ as Gs,cR as Vs,b8 as Ys,bA as Xs,cS as Ws,cT as Js}from"./index-BYVl1VlW.js";import{a6 as ls,X as is,F as Zs,bH as et,bo as Ge,aT as st,U as tt,a7 as nt,b9 as lt,dA as it,A as os,br as ot,ao as rt,ap as at,C as ct}from"./vendor-ui-B0az9ATE.js";import"./vendor-markdown-BEJ8yVzA.js";const rs="cogpit:get-started-dismissed",dt=["Explain what this project does and how its files are organized.","Look for bugs or problems and list them. Don't change any files.","Suggest three small improvements I could make first."];function ut(){try{return localStorage.getItem(rs)==="1"}catch{return!1}}function ft(){try{localStorage.setItem(rs,"1")}catch{}}function mt({freshInstall:m,sessionCount:e,dismissed:s}){return m&&e===0&&!s}function xt(m,e){if(!m)return{ready:!1,text:e?"Couldn't check your agents.":"Checking your agents…"};const s=l=>{var d;return(d=m.find(a=>cs(a)===l))==null?void 0:d.displayName},n=s("ready");if(n)return{ready:!0,text:`${n} is ready.`};const i=s("signed-out");if(i)return{ready:!1,text:`${i} is installed. Sign in to use it.`};const o=s("unknown");return o?{ready:!1,text:`${o} is installed. Make sure you're signed in.`}:{ready:!1,text:"No coding agent found on this computer yet."}}function gt(m){const e=F.c(22),{agent:s,projectName:n,folderButton:i,onCheckAgents:o,onDismiss:l}=m;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("h2",{id:"get-started-title",className:"text-sm font-medium",children:"Get started"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Cogpit lets an AI coding agent work on a project folder on your computer, and shows you everything it does."})]}),e[0]=d):d=e[0];let a;e[1]!==o?(a=t.jsx($,{variant:"link",size:"xs",className:"h-auto px-0",onClick:o,children:"Check agent setup"}),e[1]=o,e[2]=a):a=e[2];let f;e[3]!==s.ready||e[4]!==s.text||e[5]!==a?(f=t.jsx($e,{done:s.ready,title:"Connect a coding agent",detail:s.text,children:a}),e[3]=s.ready,e[4]=s.text,e[5]=a,e[6]=f):f=e[6];const h=n!==null,c=n??"The agent works only inside the folder you choose.",x=n===null&&i;let r;e[7]!==h||e[8]!==c||e[9]!==x?(r=t.jsx($e,{done:h,title:"Choose your project folder",detail:c,children:x}),e[7]=h,e[8]=c,e[9]=x,e[10]=r):r=e[10];let u;e[11]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx($e,{done:!1,title:"Send your first task",detail:"Describe it below, or start with an example."}),e[11]=u):u=e[11];let p;e[12]!==f||e[13]!==r?(p=t.jsxs("ol",{className:"flex flex-col gap-2.5",children:[f,r,u]}),e[12]=f,e[13]=r,e[14]=p):p=e[14];let w;e[15]===Symbol.for("react.memo_cache_sentinel")?(w=t.jsxs("a",{href:ds,target:"_blank",rel:"noopener noreferrer",className:"flex w-fit items-center gap-1 text-xs text-muted-foreground underline-offset-4 hover:text-foreground hover:underline",children:["Read the first-session guide",t.jsx(ls,{className:"size-3","aria-hidden":"true"})]}),e[15]=w):w=e[15];let b;e[16]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx(is,{"data-icon":"icon"}),e[16]=b):b=e[16];let j;e[17]!==l?(j=t.jsx($,{variant:"ghost",size:"icon-xs","aria-label":"Dismiss getting started",title:"Dismiss",onClick:l,className:"absolute right-2 top-2 text-muted-foreground",children:b}),e[17]=l,e[18]=j):j=e[18];let g;return e[19]!==j||e[20]!==p?(g=t.jsxs("section",{"aria-labelledby":"get-started-title",className:"relative flex flex-col gap-3 rounded-xl border bg-card/40 p-4 pr-10",children:[d,p,w,j]}),e[19]=j,e[20]=p,e[21]=g):g=e[21],g}function $e(m){const e=F.c(18),{done:s,title:n,detail:i,children:o}=m;let l;e[0]!==s?(l=s?t.jsx(Zs,{className:"mt-0.5 size-4 shrink-0 text-success","aria-label":"Done"}):t.jsx(et,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground/60","aria-label":"To do"}),e[0]=s,e[1]=l):l=e[1];const d=s&&"text-muted-foreground";let a;e[2]!==d?(a=le("text-[13px] font-medium",d),e[2]=d,e[3]=a):a=e[3];let f;e[4]!==a||e[5]!==n?(f=t.jsx("span",{className:a,children:n}),e[4]=a,e[5]=n,e[6]=f):f=e[6];let h;e[7]!==i?(h=t.jsx("span",{className:"truncate text-xs text-muted-foreground",children:i}),e[7]=i,e[8]=h):h=e[8];let c;e[9]!==f||e[10]!==h?(c=t.jsxs("div",{className:"flex min-w-0 flex-col",children:[f,h]}),e[9]=f,e[10]=h,e[11]=c):c=e[11];let x;e[12]!==o||e[13]!==c?(x=t.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-x-3 gap-y-1.5",children:[c,o]}),e[12]=o,e[13]=c,e[14]=x):x=e[14];let r;return e[15]!==l||e[16]!==x?(r=t.jsxs("li",{className:"flex items-start gap-2.5",children:[l,x]}),e[15]=l,e[16]=x,e[17]=r):r=e[17],r}const ht=6;function pt(m){const e=F.c(103),{recent:s,start:n,guide:i,examples:o}=m,[l,d]=H.useState(null),[a,f]=H.useState("");let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h={},e[0]=h):h=e[0];const[c,x]=H.useState(h),r=H.useRef(null),u=l??s[0]??null,p=(l&&!s.some(q=>Ye(q,l))?[l,...s]:[...s]).slice(0,ht);let w;e[1]!==a?(w=a.trim(),e[1]=a,e[2]=w):w=e[2];const b=w;let j;e[3]!==u||e[4]!==n.defaultAgentKind?(j=u?ts(u.dirName):n.defaultAgentKind,e[3]=u,e[4]=n.defaultAgentKind,e[5]=j):j=e[5];const g=j,y=us();let N;e[6]!==g||e[7]!==y?(N=fs(y,g),e[6]=g,e[7]=y,e[8]=N):N=e[8];const v=N,k=n.model.selectedModel,S=u==null?void 0:u.dirName;let D;e[9]!==S?(D=ms(S),e[9]=S,e[10]=D):D=e[10];const{imageInput:E}=xs(g,k,D.instanceId),{images:I,uploading:A,isDragOver:_,imageError:P,hasUnsupportedAttachments:B,dismissImageError:M,removeImage:z,clearImages:Q,handleDragOver:K,handleDragLeave:J,handleDrop:V,handlePaste:C}=gs(E),U=!!(u&&(b||I.length>0))&&!A&&!B;let Y;e[11]===Symbol.for("react.memo_cache_sentinel")?(Y=(q,G)=>{d({dirName:q,cwd:G,name:G?ns(G):q})},e[11]=Y):Y=e[11];const Z=Y;let he;e[12]!==n.defaultAgentKind?(he=q=>Z(Le(n.defaultAgentKind,q),q),e[12]=n.defaultAgentKind,e[13]=he):he=e[13];const pe=he,ie=u==null?void 0:u.cwd;let oe;e[14]!==ie||e[15]!==u?(oe=u&&ie?q=>d({...u,dirName:Le(q,ie)}):void 0,e[14]=ie,e[15]=u,e[16]=oe):oe=e[16];const ce=oe;let re;e[17]!==l||e[18]!==u?(re=()=>{!l&&u&&d(u)},e[17]=l,e[18]=u,e[19]=re):re=e[19];const L=re;let ee;e[20]!==c||e[21]!==g||e[22]!==U||e[23]!==Q||e[24]!==I||e[25]!==b||e[26]!==u||e[27]!==n?(ee=async q=>{q==null||q.preventDefault(),!(!u||!U||!await n.onStart(u.dirName,u.cwd,b,I.length>0?I.map(bt):void 0,c[g]))&&(f(""),Q())},e[20]=c,e[21]=g,e[22]=U,e[23]=Q,e[24]=I,e[25]=b,e[26]=u,e[27]=n,e[28]=ee):ee=e[28];const X=ee,W=n.model.permissionModeFor,be=q=>{var G;L(),f(q),(G=r.current)==null||G.focus()};let se;e[29]!==X?(se=q=>{q.key==="Enter"&&!q.shiftKey&&!q.nativeEvent.isComposing&&(q.preventDefault(),X())},e[29]=X,e[30]=se):se=e[30];const ge=se,te=q=>t.jsx(wt,{defaultAgentKind:n.defaultAgentKind,onChoose:Z,onChooseFolder:pe,anyListed:p.length>0,primary:q}),de=!i||p.length>0,ue="Start a session",fe="flex min-w-0 flex-col gap-3";let ne;e[31]!==i||e[32]!==te||e[33]!==u?(ne=i==null?void 0:i({project:u,folderButton:te(!0)}),e[31]=i,e[32]=te,e[33]=u,e[34]=ne):ne=e[34];const R=de&&t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",role:"group","aria-label":"Projects",children:[p.map(q=>{const G=u!==null&&Ye(q,u);return t.jsxs("button",{type:"button","aria-pressed":G,title:q.cwd??q.name,onClick:()=>d(q),className:le("flex max-w-48 items-center gap-1.5 rounded-full border py-1 pl-1.5 pr-3 text-xs outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring",G?"border-foreground/80 bg-foreground text-background":"border-border/70 text-muted-foreground hover:border-foreground/40 hover:text-foreground"),children:[t.jsx(hs,{projectPath:q.cwd??null,fallback:t.jsx(Ge,{className:"size-3.5","aria-hidden":"true"}),className:"size-4"}),t.jsx("span",{className:"truncate",children:q.name})]},q.cwd??q.dirName)}),te(!1)]});let O;e[35]!==v||e[36]!==g||e[37]!==u?(O=u&&!v&&t.jsx(ws,{kind:g}),e[35]=v,e[36]=g,e[37]=u,e[38]=O):O=e[38];let T;e[39]!==V||e[40]!==L?(T=q=>{L(),V(q)},e[39]=V,e[40]=L,e[41]=T):T=e[41];let ae;e[42]!==_?(ae=_&&t.jsx(js,{}),e[42]=_,e[43]=ae):ae=e[43];let me;e[44]!==z?(me=(q,G)=>z(G),e[44]=z,e[45]=me):me=e[45];let xe;e[46]!==I||e[47]!==me?(xe=t.jsx(ys,{images:I,onRemove:me}),e[46]=I,e[47]=me,e[48]=xe):xe=e[48];const Me=B?void 0:M;let we;e[49]!==P||e[50]!==Me?(we=t.jsx(Ns,{message:P,onDismiss:Me}),e[49]=P,e[50]=Me,e[51]=we):we=e[51];let je;e[52]!==L?(je=q=>{L(),f(q.target.value)},e[52]=L,e[53]=je):je=e[53];let ye;e[54]!==C||e[55]!==L?(ye=q=>{L(),C(q)},e[54]=C,e[55]=L,e[56]=ye):ye=e[56];const Re=u?`Describe the task for ${u.name}`:"Open a folder, then describe the task";let Ne;e[57]!==ge||e[58]!==je||e[59]!==ye||e[60]!==Re||e[61]!==a?(Ne=t.jsx(vs,{ref:r,"aria-label":"First message",value:a,onChange:je,onPaste:ye,onKeyDown:ge,placeholder:Re,rows:1,className:"max-h-48 min-h-9 flex-1 resize-none rounded-none border-0 bg-transparent px-0 py-2 shadow-none focus-visible:border-transparent focus-visible:ring-0"}),e[57]=ge,e[58]=je,e[59]=ye,e[60]=Re,e[61]=a,e[62]=Ne):Ne=e[62];let ve;e[63]!==c||e[64]!==g||e[65]!==W?(ve=c[g]??(W==null?void 0:W(g)),e[63]=c,e[64]=g,e[65]=W,e[66]=ve):ve=e[66];let Ie;e[67]!==g||e[68]!==W?(Ie=W&&(q=>x(G=>({...G,[g]:q}))),e[67]=g,e[68]=W,e[69]=Ie):Ie=e[69];let ke;e[70]!==g||e[71]!==n.model.onEffortChange||e[72]!==n.model.onModelChange||e[73]!==n.model.selectedEffort||e[74]!==n.model.selectedModel||e[75]!==ce||e[76]!==ve||e[77]!==Ie?(ke=t.jsx(ps,{isNewSession:!0,agentKind:g,onAgentKindChange:ce,selectedModel:n.model.selectedModel,onModelChange:n.model.onModelChange,selectedEffort:n.model.selectedEffort,onEffortChange:n.model.onEffortChange,permissionMode:ve,onPermissionModeChange:Ie}),e[70]=g,e[71]=n.model.onEffortChange,e[72]=n.model.onModelChange,e[73]=n.model.selectedEffort,e[74]=n.model.selectedModel,e[75]=ce,e[76]=ve,e[77]=Ie,e[78]=ke):ke=e[78];const Oe=!U;let Ee;e[79]===Symbol.for("react.memo_cache_sentinel")?(Ee=t.jsx(st,{"data-icon":"icon"}),e[79]=Ee):Ee=e[79];let Se;e[80]!==Oe?(Se=t.jsx($,{type:"submit",size:"icon-xs",disabled:Oe,"aria-label":"Start session",title:"Start session (Enter)",children:Ee}),e[80]=Oe,e[81]=Se):Se=e[81];let qe;e[82]!==ke||e[83]!==Se?(qe=t.jsxs("div",{className:"flex shrink-0 items-center gap-1 pb-0.5",children:[ke,Se]}),e[82]=ke,e[83]=Se,e[84]=qe):qe=e[84];let Ce;e[85]!==Ne||e[86]!==qe?(Ce=t.jsxs("div",{className:"flex items-end gap-2 rounded-xl border bg-popover py-2 pl-4 pr-2 shadow-lg shadow-black/5 transition-[border-color,box-shadow] duration-150 focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50",children:[Ne,qe]}),e[85]=Ne,e[86]=qe,e[87]=Ce):Ce=e[87];let De;e[88]!==J||e[89]!==K||e[90]!==X||e[91]!==T||e[92]!==ae||e[93]!==xe||e[94]!==we||e[95]!==Ce?(De=t.jsxs("form",{onSubmit:X,onDragOver:K,onDragLeave:J,onDrop:T,className:"relative min-w-0",children:[ae,xe,we,Ce]}),e[88]=J,e[89]=K,e[90]=X,e[91]=T,e[92]=ae,e[93]=xe,e[94]=we,e[95]=Ce,e[96]=De):De=e[96];const Te=o&&o.length>0&&t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",role:"group","aria-label":"Example tasks",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:"Try:"}),o.map(q=>t.jsx($,{type:"button",variant:"outline",size:"xs",className:"rounded-full font-normal text-muted-foreground",onClick:()=>be(q),children:q},q))]});let _e;return e[97]!==ne||e[98]!==R||e[99]!==O||e[100]!==De||e[101]!==Te?(_e=t.jsxs("section",{"aria-label":ue,className:fe,children:[ne,R,O,De,Te]}),e[97]=ne,e[98]=R,e[99]=O,e[100]=De,e[101]=Te,e[102]=_e):_e=e[102],_e}function bt(m){const{data:e,mediaType:s}=m;return{data:e,mediaType:s}}function Ye(m,e){return m.cwd&&e.cwd?m.cwd===e.cwd:m.dirName===e.dirName}function wt(m){const e=F.c(21),{defaultAgentKind:s,onChoose:n,onChooseFolder:i,anyListed:o,primary:l}=m,[d,a]=H.useState(!1),f=bs(d),h=o?"projects":"folders";let c;e[0]!==o||e[1]!==l?(c=l?t.jsx($,{size:"xs"}):t.jsx($,{variant:o?"ghost":"outline",size:"xs",className:"rounded-full text-muted-foreground"}),e[0]=o,e[1]=l,e[2]=c):c=e[2];let x;e[3]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx(Ge,{"data-icon":"inline-start"}),e[3]=x):x=e[3];const r=o?"Other project":"Open a folder…";let u;e[4]!==c||e[5]!==r?(u=t.jsxs(Is,{render:c,children:[x,r]}),e[4]=c,e[5]=r,e[6]=u):u=e[6];let p;e[7]!==n?(p=(g,y)=>{a(!1),n(g,y)},e[7]=n,e[8]=p):p=e[8];let w;e[9]!==i?(w=g=>{a(!1),i(g)},e[9]=i,e[10]=w):w=e[10];let b;e[11]!==s||e[12]!==h||e[13]!==f||e[14]!==p||e[15]!==w?(b=t.jsx(ks,{align:"start",className:"w-96 max-w-[calc(100vw-2rem)] p-0",children:t.jsx(Ss,{projects:f,defaultAgentKind:s,initialView:h,selectsOnly:!0,onNewSession:p,onNewFolder:w})}),e[11]=s,e[12]=h,e[13]=f,e[14]=p,e[15]=w,e[16]=b):b=e[16];let j;return e[17]!==d||e[18]!==u||e[19]!==b?(j=t.jsxs(qs,{open:d,onOpenChange:a,children:[u,b]}),e[17]=d,e[18]=u,e[19]=b,e[20]=j):j=e[20],j}function jt(m){const e={};for(const s of m)s.type==="boolean"?e[s.name]=s.defaultValue===!0:s.defaultValue!==void 0?e[s.name]=String(s.defaultValue):e[s.name]="";return e}function yt(m,e){const s={};for(const n of m){const i=e[n.name];if(typeof i=="boolean"){s[n.name]=i;continue}i!==""&&(s[n.name]=n.type==="number"||n.type==="integer"?Number(i):i)}return s}function Nt(m,e){return m.every(s=>{if(!s.required)return!0;const n=e[s.name];return typeof n=="boolean"?!0:n===""?!1:s.type==="number"||s.type==="integer"?Number.isFinite(Number(n)):!0})}function vt(m){const e=F.c(52),{request:s,responding:n,onAnswer:i}=m;let o;e[0]!==s.fields?(o=()=>jt(s.fields),e[0]=s.fields,e[1]=o):o=e[1];const[l,d]=H.useState(o);let a;e[2]!==s.fields||e[3]!==l?(a=Nt(s.fields,l),e[2]=s.fields,e[3]=l,e[4]=a):a=e[4];const f=a,h=s.displayName||s.title||s.serverName;let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=(y,N)=>{d(v=>({...v,[y]:N}))},e[5]=c):c=e[5];const x=c;let r;e[6]!==i||e[7]!==s.requestId?(r=()=>i==null?void 0:i(s.requestId,{action:"decline"}),e[6]=i,e[7]=s.requestId,e[8]=r):r=e[8];const u=r;if(s.mode==="url"&&s.url){const y=s.url;let N;e[9]!==s.message?(N=t.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:s.message}),e[9]=s.message,e[10]=N):N=e[10];let v;e[11]!==y?(v=t.jsx("p",{className:"mt-1 truncate font-mono text-xs text-muted-foreground",title:y,children:y}),e[11]=y,e[12]=v):v=e[12];let k;e[13]!==u||e[14]!==i||e[15]!==s.requestId||e[16]!==n||e[17]!==y?(k=i&&t.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[t.jsxs($,{size:"sm",disabled:n,onClick:()=>{window.open(y,"_blank","noopener,noreferrer"),i(s.requestId,{action:"accept"})},children:["Open link",t.jsx(ls,{"data-icon":"inline-end"})]}),t.jsx($,{variant:"ghost",size:"sm",disabled:n,onClick:u,children:"Decline"})]}),e[13]=u,e[14]=i,e[15]=s.requestId,e[16]=n,e[17]=y,e[18]=k):k=e[18];let S;return e[19]!==h||e[20]!==N||e[21]!==v||e[22]!==k?(S=t.jsxs(Xe,{server:h,children:[N,v,k]}),e[19]=h,e[20]=N,e[21]=v,e[22]=k,e[23]=S):S=e[23],S}let p;e[24]!==s.message?(p=t.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:s.message}),e[24]=s.message,e[25]=p):p=e[25];let w;if(e[26]!==i||e[27]!==s.fields||e[28]!==s.requestId||e[29]!==n||e[30]!==l){let y;e[32]!==i||e[33]!==s.requestId||e[34]!==n||e[35]!==l?(y=N=>t.jsx(It,{id:`elicit-${s.requestId}-${N.name}`,field:N,value:l[N.name],disabled:n||!i,onChange:v=>x(N.name,v)},N.name),e[32]=i,e[33]=s.requestId,e[34]=n,e[35]=l,e[36]=y):y=e[36],w=s.fields.map(y),e[26]=i,e[27]=s.fields,e[28]=s.requestId,e[29]=n,e[30]=l,e[31]=w}else w=e[31];let b;e[37]!==w?(b=t.jsx("div",{className:"mt-3 flex flex-col gap-3",children:w}),e[37]=w,e[38]=b):b=e[38];let j;e[39]!==f||e[40]!==u||e[41]!==i||e[42]!==s.fields||e[43]!==s.requestId||e[44]!==n||e[45]!==l?(j=i&&t.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[t.jsx($,{size:"sm",disabled:n||!f,onClick:()=>i(s.requestId,{action:"accept",content:yt(s.fields,l)}),children:"Send"}),t.jsx($,{variant:"ghost",size:"sm",disabled:n,onClick:u,children:"Decline"})]}),e[39]=f,e[40]=u,e[41]=i,e[42]=s.fields,e[43]=s.requestId,e[44]=n,e[45]=l,e[46]=j):j=e[46];let g;return e[47]!==h||e[48]!==p||e[49]!==b||e[50]!==j?(g=t.jsxs(Xe,{server:h,children:[p,b,j]}),e[47]=h,e[48]=p,e[49]=b,e[50]=j,e[51]=g):g=e[51],g}function It(m){const e=F.c(55),{id:s,field:n,value:i,disabled:o,onChange:l}=m;if(n.type==="boolean"){const u=i===!0;let p;e[0]!==l?(p=g=>l(g===!0),e[0]=l,e[1]=p):p=e[1];let w;e[2]!==o||e[3]!==s||e[4]!==u||e[5]!==p?(w=t.jsx(Cs,{id:s,checked:u,disabled:o,onCheckedChange:p}),e[2]=o,e[3]=s,e[4]=u,e[5]=p,e[6]=w):w=e[6];let b;e[7]!==n?(b=t.jsx(Be,{field:n}),e[7]=n,e[8]=b):b=e[8];let j;return e[9]!==s||e[10]!==w||e[11]!==b?(j=t.jsxs(ze,{htmlFor:s,className:"items-start gap-2 font-normal",children:[w,b]}),e[9]=s,e[10]=w,e[11]=b,e[12]=j):j=e[12],j}if(n.type==="enum"){let u;e[13]!==n?(u=t.jsx(Be,{field:n}),e[13]=n,e[14]=u):u=e[14];let p;e[15]!==s||e[16]!==u?(p=t.jsx(ze,{htmlFor:s,children:u}),e[15]=s,e[16]=u,e[17]=p):p=e[17];let w;e[18]!==i?(w=typeof i=="string"&&i?[i]:[],e[18]=i,e[19]=w):w=e[19];let b;e[20]!==l?(b=k=>{k[0]&&l(k[0])},e[20]=l,e[21]=b):b=e[21];const j=n.label;let g;e[22]!==n.options?(g=n.options??[],e[22]=n.options,e[23]=g):g=e[23];let y;if(e[24]!==o||e[25]!==g){let k;e[27]!==o?(k=S=>t.jsx(Ds,{value:S.value,disabled:o,className:"w-full justify-start px-3",children:S.label},S.value),e[27]=o,e[28]=k):k=e[28],y=g.map(k),e[24]=o,e[25]=g,e[26]=y}else y=e[26];let N;e[29]!==n.label||e[30]!==s||e[31]!==w||e[32]!==b||e[33]!==y?(N=t.jsx(As,{id:s,value:w,onValueChange:b,orientation:"vertical",variant:"outline",size:"sm",className:"w-full items-stretch","aria-label":j,children:y}),e[29]=n.label,e[30]=s,e[31]=w,e[32]=b,e[33]=y,e[34]=N):N=e[34];let v;return e[35]!==p||e[36]!==N?(v=t.jsxs("div",{className:"flex flex-col gap-1.5",children:[p,N]}),e[35]=p,e[36]=N,e[37]=v):v=e[37],v}let d;e[38]!==n?(d=t.jsx(Be,{field:n}),e[38]=n,e[39]=d):d=e[39];let a;e[40]!==s||e[41]!==d?(a=t.jsx(ze,{htmlFor:s,children:d}),e[40]=s,e[41]=d,e[42]=a):a=e[42];const f=n.type==="string"?"text":"number",h=typeof i=="string"?i:"";let c;e[43]!==l?(c=u=>l(u.target.value),e[43]=l,e[44]=c):c=e[44];let x;e[45]!==o||e[46]!==n.label||e[47]!==s||e[48]!==f||e[49]!==h||e[50]!==c?(x=t.jsx(Ue,{id:s,"aria-label":n.label,type:f,value:h,disabled:o,onChange:c}),e[45]=o,e[46]=n.label,e[47]=s,e[48]=f,e[49]=h,e[50]=c,e[51]=x):x=e[51];let r;return e[52]!==a||e[53]!==x?(r=t.jsxs("div",{className:"flex flex-col gap-1.5",children:[a,x]}),e[52]=a,e[53]=x,e[54]=r):r=e[54],r}function Be(m){const e=F.c(8),{field:s}=m;let n;e[0]!==s.required?(n=s.required&&t.jsx("span",{className:"ml-0.5 text-warning",children:"*"}),e[0]=s.required,e[1]=n):n=e[1];let i;e[2]!==s.description?(i=s.description&&t.jsx("span",{className:"block text-xs font-normal text-muted-foreground",children:s.description}),e[2]=s.description,e[3]=i):i=e[3];let o;return e[4]!==s.label||e[5]!==n||e[6]!==i?(o=t.jsxs("span",{className:"min-w-0",children:[s.label,n,i]}),e[4]=s.label,e[5]=n,e[6]=i,e[7]=o):o=e[7],o}function Xe(m){const e=F.c(8),{server:s,children:n}=m;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(tt,{className:"text-info"}),e[0]=i):i=e[0];let o;e[1]!==s?(o=t.jsxs(He,{children:[s," needs input"]}),e[1]=s,e[2]=o):o=e[2];let l;e[3]!==n?(l=t.jsx("div",{className:"col-start-2 mt-1 min-w-0",children:n}),e[3]=n,e[4]=l):l=e[4];let d;return e[5]!==o||e[6]!==l?(d=t.jsxs(Qe,{className:"border-info/40 bg-info/5",children:[i,o,l]}),e[5]=o,e[6]=l,e[7]=d):d=e[7],d}function kt(m){const e=F.c(15),{request:s,responding:n,onChoose:i}=m;let o,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx(nt,{className:"text-warning"}),l=t.jsx(He,{children:"The agent declined this request"}),e[0]=o,e[1]=l):(o=e[0],l=e[1]);let d;e[2]!==s.originalModel?(d=t.jsxs("p",{className:"text-sm leading-relaxed text-foreground",children:[s.originalModel," would not answer. Retrying on a fallback model may work."]}),e[2]=s.originalModel,e[3]=d):d=e[3];let a;e[4]!==s.guidanceText?(a=s.guidanceText&&t.jsx("p",{className:"mt-1 text-sm leading-relaxed text-muted-foreground",children:s.guidanceText}),e[4]=s.guidanceText,e[5]=a):a=e[5];let f;e[6]!==i||e[7]!==s.fallbackModel||e[8]!==s.requestId||e[9]!==n?(f=i&&t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[t.jsxs($,{size:"sm",disabled:n,onClick:()=>i(s.requestId,"retry_fallback"),children:["Retry on ",s.fallbackModel]}),t.jsx($,{variant:"outline",size:"sm",disabled:n,onClick:()=>i(s.requestId,"edit_prompt"),children:"Edit prompt"}),t.jsx($,{variant:"ghost",size:"sm",disabled:n,className:"ml-auto text-muted-foreground",onClick:()=>i(s.requestId,"cancelled"),children:"Dismiss"})]}),e[6]=i,e[7]=s.fallbackModel,e[8]=s.requestId,e[9]=n,e[10]=f):f=e[10];let h;return e[11]!==d||e[12]!==a||e[13]!==f?(h=t.jsxs(Qe,{className:"border-warning/40 bg-warning/5",children:[o,l,t.jsxs("div",{className:"col-start-2 mt-1 min-w-0",children:[d,a,f]})]}),e[11]=d,e[12]=a,e[13]=f,e[14]=h):h=e[14],h}function St(m){const e=F.c(64),{request:s,input:n,canAnswer:i,onOpen:o}=m;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=new Set,e[0]=l):l=e[0];const[d,a]=H.useState(l),{sessionId:f}=s;switch(s.kind){case"permission":{const h=s.request;let c;e[1]!==n.responding||e[2]!==s.request.requestId?(c=n.responding.has(s.request.requestId),e[1]=n.responding,e[2]=s.request.requestId,e[3]=c):c=e[3];let x;e[4]!==i||e[5]!==n||e[6]!==f?(x=i?(u,p)=>void n.respond(f,u,p):void 0,e[4]=i,e[5]=n,e[6]=f,e[7]=x):x=e[7];let r;return e[8]!==s.request||e[9]!==c||e[10]!==x?(r=t.jsx(_s,{request:h,queued:0,responding:c,onRespond:x}),e[8]=s.request,e[9]=c,e[10]=x,e[11]=r):r=e[11],r}case"question":{const h=s.request;let c;e[12]!==n.responding||e[13]!==s.request.toolUseId?(c=n.responding.has(s.request.toolUseId),e[12]=n.responding,e[13]=s.request.toolUseId,e[14]=c):c=e[14];let x;e[15]!==d||e[16]!==s.request.toolUseId?(x=d.has(s.request.toolUseId),e[15]=d,e[16]=s.request.toolUseId,e[17]=x):x=e[17];let r;e[18]!==i||e[19]!==n||e[20]!==f?(r=i?async(p,w)=>{(await n.answerQuestion(f,p,w)).gone&&a(j=>new Set(j).add(p))}:void 0,e[18]=i,e[19]=n,e[20]=f,e[21]=r):r=e[21];let u;return e[22]!==o||e[23]!==s.request||e[24]!==c||e[25]!==x||e[26]!==r?(u=t.jsx(Es,{request:h,responding:c,gone:x,onAnswer:r,onOpenSession:o}),e[22]=o,e[23]=s.request,e[24]=c,e[25]=x,e[26]=r,e[27]=u):u=e[27],u}case"elicitation":{const h=s.request;let c;e[28]!==n.responding||e[29]!==s.request.requestId?(c=n.responding.has(s.request.requestId),e[28]=n.responding,e[29]=s.request.requestId,e[30]=c):c=e[30];let x;e[31]!==i||e[32]!==n||e[33]!==f?(x=i?(u,p)=>void n.answerElicitation(f,u,p):void 0,e[31]=i,e[32]=n,e[33]=f,e[34]=x):x=e[34];let r;return e[35]!==s.request||e[36]!==c||e[37]!==x?(r=t.jsx(vt,{request:h,responding:c,onAnswer:x}),e[35]=s.request,e[36]=c,e[37]=x,e[38]=r):r=e[38],r}case"dialog":{const h=s.request;let c;e[39]!==n.responding||e[40]!==s.request.requestId?(c=n.responding.has(s.request.requestId),e[39]=n.responding,e[40]=s.request.requestId,e[41]=c):c=e[41];let x;e[42]!==i||e[43]!==n||e[44]!==f?(x=i?(u,p)=>void n.answerDialog(f,u,p):void 0,e[42]=i,e[43]=n,e[44]=f,e[45]=x):x=e[45];let r;return e[46]!==s.request||e[47]!==c||e[48]!==x?(r=t.jsx(kt,{request:h,responding:c,onChoose:x}),e[46]=s.request,e[47]=c,e[48]=x,e[49]=r):r=e[49],r}case"plan":case"deferred":{let h;e[50]!==s.kind?(h=s.kind==="plan"?t.jsx(lt,{className:"text-warning"}):t.jsx(it,{className:"text-warning"}),e[50]=s.kind,e[51]=h):h=e[51];const c=s.kind==="plan"?"A plan is waiting for review":"A permission was deferred";let x;e[52]!==c?(x=t.jsx(He,{children:c}),e[52]=c,e[53]=x):x=e[53];const r=s.kind==="plan"?"Review it in its session.":"Open the session and resume it to answer.";let u;e[54]!==r?(u=t.jsx("p",{className:"col-start-2 mt-1 text-sm text-muted-foreground",children:r}),e[54]=r,e[55]=u):u=e[55];let p;e[56]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx(os,{"data-icon":"inline-end"}),e[56]=p):p=e[56];let w;e[57]!==o?(w=t.jsx("div",{className:"col-start-2 mt-2",children:t.jsxs($,{size:"xs",onClick:o,children:["Open session",p]})}),e[57]=o,e[58]=w):w=e[58];let b;return e[59]!==h||e[60]!==x||e[61]!==u||e[62]!==w?(b=t.jsxs(Qe,{className:"border-warning/40 bg-warning/5",children:[h,x,u,w]}),e[59]=h,e[60]=x,e[61]=u,e[62]=w,e[63]=b):b=e[63],b}}}function qt(m,e,s=()=>!0){const n=new Map(e.map(l=>[l.sessionId,l])),i=l=>{const d=n.get(l);return d?Fe(d):Date.now()},o=[];for(const[l,d]of m.permissionsBySession)for(const a of d)o.push({kind:"permission",sessionId:l,since:a.timestamp,request:a});for(const[l,d]of m.questionsBySession)for(const a of d)o.push({kind:"question",sessionId:l,since:a.askedAt,request:a});for(const[l,d]of m.elicitationsBySession)for(const a of d)o.push({kind:"elicitation",sessionId:l,since:a.askedAt,request:a});for(const[l,d]of m.dialogsBySession)for(const a of d)o.push({kind:"dialog",sessionId:l,since:a.askedAt,request:a});for(const l of m.awaitingPlan)o.push({kind:"plan",sessionId:l,since:i(l)});for(const l of e)l.agentStatus==="deferred"&&!l.archived&&o.push({kind:"deferred",sessionId:l.sessionId,since:i(l.sessionId)});return o.filter(l=>s(l.sessionId)).sort((l,d)=>l.since-d.since)}function We(m){switch(m.kind){case"permission":return m.request.requestId;case"question":return m.request.toolUseId;case"elicitation":case"dialog":return m.request.requestId;default:return`${m.kind}:${m.sessionId}`}}const Ct=7*864e5,Je=3,Dt=30,At=50,Ze={"needs-you":0,working:1,done:2};function Et(m,e){const s=m.filter(o=>!o.archived&&!(o.teamName&&o.agentName)),{topLevel:n,crewOf:i}=Ps(s);return n.map(o=>{const l=i.get(o.sessionId)??[],d=l.length?Ms(o,l):o.lastActivityAt||o.lastModified,a=[o,...l].flatMap(f=>(f.pullRequests??[]).map(h=>({pullRequest:h,by:f}))).sort((f,h)=>Date.parse(h.pullRequest.timestamp)-Date.parse(f.pullRequest.timestamp))[0];return{session:o,state:e(o).state,crew:l.map(f=>({member:f,state:e(f).state})).sort((f,h)=>Ze[f.state]-Ze[h.state]||Fe(h.member)-Fe(f.member)),counts:l.length?Rs(l,e):null,activityAt:d,...a&&{landed:{number:a.pullRequest.number,title:a.pullRequest.title,url:a.pullRequest.url,by:a.by}}}}).sort((o,l)=>Date.parse(l.activityAt)-Date.parse(o.activityAt))}function _t(m,e=Date.now()){const s=m.filter(n=>e-Date.parse(n.activityAt)<Ct);return(s.length>=Je?s:m.slice(0,Je)).slice(0,Dt)}function Pt(m,e,s=6){const n=[],i=new Set;for(const o of m){const l=e(o.session);if(!(!l.cwd||i.has(l.cwd))&&(i.add(l.cwd),n.push(l),n.length===s))break}return n}function Mt(m,e,s){const n=e.toLowerCase().split(/\s+/).filter(Boolean);return n.length===0?[]:m.filter(i=>{const o=s(i).filter(Boolean).join(`
|
|
2
|
+
`).toLowerCase();return n.every(l=>o.includes(l))}).slice(0,At)}const es={"needs-you":Pe.attention,working:Pe.working,done:"bg-muted-foreground/40"},Rt={"needs-you":"needs you",working:"working",done:"done"},Ot=3;function Tt(m,e){const s=m.cwd?Js(m.cwd):null,n=(s==null?void 0:s.parentPath)??m.cwd,i=s?Le(ts(m.dirName),s.parentPath):m.dirName;return{dirName:i,cwd:n,name:e[i]??(n?ns(n):m.projectShortName)}}function zt(m){const e=m.target instanceof HTMLElement&&m.target.closest("input,textarea,select,[contenteditable=true]");return!m.metaKey&&!m.ctrlKey&&!m.altKey&&!e}function Zt(m){const e=F.c(92),{onOpenSession:s,onBrowseProjects:n,start:i,freshInstall:o}=m,l=o===void 0?!1:o,d=Os(),a=Ts(),{names:f,rename:h}=zs(),{names:c}=$s(),x=Bs(),[r,u]=H.useState(""),p=H.useRef(null);let w;e[0]!==d.sessions?(w=d.sessions.filter(Bt),e[0]=d.sessions,e[1]=w):w=e[1];const b=w;let j;e[2]!==b?(j=new Map(b.map($t)),e[2]=b,e[3]=j):j=e[3];const g=j;let y;e[4]!==a.awaitingDialog||e[5]!==a.awaitingElicitation?(y=new Set([...a.awaitingElicitation,...a.awaitingDialog]),e[4]=a.awaitingDialog,e[5]=a.awaitingElicitation,e[6]=y):y=e[6];let N;e[7]!==a.awaitingPermission||e[8]!==a.awaitingPlan||e[9]!==a.awaitingQuestion||e[10]!==y?(N={awaitingPermission:a.awaitingPermission,awaitingQuestion:a.awaitingQuestion,awaitingPrompt:y,awaitingPlan:a.awaitingPlan},e[7]=a.awaitingPermission,e[8]=a.awaitingPlan,e[9]=a.awaitingQuestion,e[10]=y,e[11]=N):N=e[11];const v=N;let k;e[12]!==d.procBySession||e[13]!==v?(k=R=>Qs(R,d.procBySession,v),e[12]=d.procBySession,e[13]=v,e[14]=k):k=e[14];const S=k;let D;e[15]!==g||e[16]!==x?(D=R=>{const O=g.get(R);return x(O==null?void 0:O.access).canInteract},e[15]=g,e[16]=x,e[17]=D):D=e[17];const E=D;let I;e[18]!==E||e[19]!==a||e[20]!==b?(I=qt(a,b,E),e[18]=E,e[19]=a,e[20]=b,e[21]=I):I=e[21];const A=I;let _;e[22]!==g||e[23]!==f?(_=R=>Gs(R,g,f),e[22]=g,e[23]=f,e[24]=_):_=e[24];const P=_;let B;e[25]!==c?(B=R=>c[R.dirName]??Vs(R),e[25]=c,e[26]=B):B=e[26];const M=B;let z,Q,K;if(e[27]!==P||e[28]!==M||e[29]!==c||e[30]!==r||e[31]!==b||e[32]!==S){z=Et(b,S),K=r.trim().length>0?Mt(z,r,T=>{var ae;return[P(T.session.sessionId),M(T.session),T.session.gitBranch,T.session.cwd,T.session.lastUserMessage,T.session.firstUserMessage,(ae=T.landed)==null?void 0:ae.title,T.landed&&`#${T.landed.number}`,...T.crew.map(me=>{const{member:xe}=me;return P(xe.sessionId)})]}):_t(z);let O;e[36]!==c?(O=T=>Tt(T,c),e[36]=c,e[37]=O):O=e[37],Q=Pt(z,O),e[27]=P,e[28]=M,e[29]=c,e[30]=r,e[31]=b,e[32]=S,e[33]=z,e[34]=Q,e[35]=K}else z=e[33],Q=e[34],K=e[35];const J=Q;let V;e[38]!==g||e[39]!==s?(V=R=>{const O=g.get(R);O?s(O.dirName,O.fileName):Ys(R)},e[38]=g,e[39]=s,e[40]=V):V=e[40];const C=V;let U;if(e[41]!==g||e[42]!==d.processes){let R;e[44]!==g?(R=O=>O.sessionId&&g.has(O.sessionId),e[44]=g,e[45]=R):R=e[45],U=d.processes.filter(R),e[41]=g,e[42]=d.processes,e[43]=U}else U=e[43];const Y=U.length,[Z,he]=H.useState(ut);let pe;e[46]!==l||e[47]!==Z||e[48]!==d.sessions.length||e[49]!==i?(pe=!!i&&mt({freshInstall:l,sessionCount:d.sessions.length,dismissed:Z}),e[46]=l,e[47]=Z,e[48]=d.sessions.length,e[49]=i,e[50]=pe):pe=e[50];const ie=pe;let oe,ce;e[51]===Symbol.for("react.memo_cache_sentinel")?(oe=()=>{const R=O=>{var T;O.key==="/"&&zt(O)&&(O.preventDefault(),(T=p.current)==null||T.focus())};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},ce=[],e[51]=oe,e[52]=ce):(oe=e[51],ce=e[52]),H.useEffect(oe,ce);let re;e[53]===Symbol.for("react.memo_cache_sentinel")?(re=t.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[t.jsx("h1",{className:"text-xl font-semibold tracking-tight",children:"Mission Control"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Start a task here, and answer anything your agents are waiting on."})]}),e[53]=re):re=e[53];let L;e[54]!==Y?(L=Y>0&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:[Y," ",Y===1?"agent":"agents"," running"]}),e[54]=Y,e[55]=L):L=e[55];let ee;e[56]!==L?(ee=t.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1",children:[re,L]}),e[56]=L,e[57]=ee):ee=e[57];let X;e[58]!==ie||e[59]!==J||e[60]!==i?(X=i&&t.jsx(pt,{recent:J,start:i,guide:ie?R=>t.jsx(Kt,{controls:R,onDismiss:()=>{ft(),he(!0)}}):void 0,examples:ie?dt:void 0}),e[58]=ie,e[59]=J,e[60]=i,e[61]=X):X=e[61];let W;e[62]===Symbol.for("react.memo_cache_sentinel")?(W=t.jsx("kbd",{className:"font-sans",children:Ve("keyboardShortcuts")}),e[62]=W):W=e[62];let be;e[63]===Symbol.for("react.memo_cache_sentinel")?(be=t.jsxs("p",{className:"-mt-4 hidden text-right text-[11px] text-muted-foreground/70 sm:block",children:["Press ",W," for shortcuts · ",t.jsx("kbd",{className:"font-sans",children:Ve("commandPalette")})," for commands"]}),e[63]=be):be=e[63];let se;e[64]!==ee||e[65]!==X?(se=t.jsxs("div",{className:"mx-auto flex w-full max-w-6xl shrink-0 flex-col gap-8 px-6 pt-16 lg:px-10",children:[ee,X,be]}),e[64]=ee,e[65]=X,e[66]=se):se=e[66];const ge=A.length>0&&"lg:grid lg:grid-cols-[minmax(0,380px)_minmax(0,1fr)] lg:grid-rows-[minmax(0,1fr)]";let te;e[67]!==ge?(te=le("mx-auto flex w-full max-w-6xl flex-col gap-8 px-6 pb-10 pt-10 lg:h-full lg:px-10",ge),e[67]=ge,e[68]=te):te=e[68];let de;e[69]!==g||e[70]!==E||e[71]!==a||e[72]!==P||e[73]!==C||e[74]!==A?(de=A.length>0?t.jsx(Lt,{queue:A,input:a,byId:g,nameOf:P,onOpen:C,canAnswer:E}):t.jsxs("p",{className:"flex shrink-0 items-center gap-2 text-xs text-muted-foreground",children:[t.jsx("span",{className:"size-1.5 rounded-full bg-success/40","aria-hidden":"true"}),"Nothing is waiting on you."]}),e[69]=g,e[70]=E,e[71]=a,e[72]=P,e[73]=C,e[74]=A,e[75]=de):de=e[75];let ue;e[76]!==P||e[77]!==n||e[78]!==C||e[79]!==M||e[80]!==r||e[81]!==h||e[82]!==z.length||e[83]!==K?(ue=t.jsx(Ut,{sessions:K,total:z.length,query:r,onQueryChange:u,searchRef:p,nameOf:P,projectLabel:M,onOpen:C,onRename:h,onBrowseProjects:n}),e[76]=P,e[77]=n,e[78]=C,e[79]=M,e[80]=r,e[81]=h,e[82]=z.length,e[83]=K,e[84]=ue):ue=e[84];let fe;e[85]!==te||e[86]!==de||e[87]!==ue?(fe=t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto lg:overflow-hidden",children:t.jsxs("div",{className:te,children:[de,ue]})}),e[85]=te,e[86]=de,e[87]=ue,e[88]=fe):fe=e[88];let ne;return e[89]!==se||e[90]!==fe?(ne=t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[se,fe]}),e[89]=se,e[90]=fe,e[91]=ne):ne=e[91],ne}function $t(m){return[m.sessionId,m]}function Bt(m){return!m.archived}function Kt(m){var x;const e=F.c(12),{controls:s,onDismiss:n}=m,i=Xs();let o;e[0]!==i.agents||e[1]!==i.error?(o=xt(i.agents,i.error),e[0]=i.agents,e[1]=i.error,e[2]=o):o=e[2];const l=o,{recheck:d}=i;let a,f;e[3]!==l.ready||e[4]!==d?(a=()=>{if(!l.ready)return window.addEventListener("focus",d),()=>window.removeEventListener("focus",d)},f=[l.ready,d],e[3]=l.ready,e[4]=d,e[5]=a,e[6]=f):(a=e[5],f=e[6]),H.useEffect(a,f);const h=((x=s.project)==null?void 0:x.name)??null;let c;return e[7]!==l||e[8]!==s.folderButton||e[9]!==n||e[10]!==h?(c=t.jsx(gt,{agent:l,projectName:h,folderButton:s.folderButton,onCheckAgents:Ws,onDismiss:n}),e[7]=l,e[8]=s.folderButton,e[9]=n,e[10]=h,e[11]=c):c=e[11],c}function as(m){const e=F.c(9),{title:s,count:n,children:i}=m;let o;e[0]!==s?(o=t.jsx("h2",{className:"text-sm font-medium",children:s}),e[0]=s,e[1]=o):o=e[1];let l;e[2]!==n?(l=n!==void 0&&t.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:n}),e[2]=n,e[3]=l):l=e[3];let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx("span",{className:"flex-1"}),e[4]=d):d=e[4];let a;return e[5]!==i||e[6]!==o||e[7]!==l?(a=t.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[o,l,d,i]}),e[5]=i,e[6]=o,e[7]=l,e[8]=a):a=e[8],a}function Ke(m,e){const s=m==null?void 0:m.crew;return s?e(s.rootId)??s.rootTitle??null:null}const ss={permission:"asked a permission",question:"asked a question",elicitation:"asked for input",dialog:"needs a choice",plan:"has a plan to review",deferred:"has a deferred permission"};function Lt(m){const e=F.c(71),{queue:s,input:n,byId:i,nameOf:o,onOpen:l,canAnswer:d}=m,[a,f]=H.useState(0);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=new Set,e[0]=h):h=e[0];const c=H.useRef(h),x=Math.min(a,s.length-1),r=s[x];let u;if(e[1]!==i||e[2]!==o||e[3]!==r.sessionId){const C=i.get(r.sessionId);u=Ke(C,o),e[1]=i,e[2]=o,e[3]=r.sessionId,e[4]=u}else u=e[4];const p=u;let w;e[5]!==x||e[6]!==d||e[7]!==n||e[8]!==l||e[9]!==s.length||e[10]!==r.kind||e[11]!==r.request||e[12]!==r.sessionId?(w=C=>{const U=C.target;if(!(U.closest("input,textarea,select,[contenteditable=true]")||C.metaKey||C.ctrlKey||C.altKey)&&((C.key==="j"||C.key==="n"||C.key==="ArrowDown")&&(C.preventDefault(),f(Math.min(s.length-1,x+1))),(C.key==="k"||C.key==="ArrowUp")&&(C.preventDefault(),f(Math.max(0,x-1))),C.key==="o"&&(C.preventDefault(),l(r.sessionId)),(C.key==="Enter"||C.key==="d")&&U===C.currentTarget&&d(r.sessionId))){if(r.kind!=="permission")return;const Y=C.key==="d"||r.request.defaultToNo?"deny":"allow",Z=r.request.requestId;if(r.request.availableDecisions&&!r.request.availableDecisions.includes(Y)||(C.preventDefault(),c.current.has(Z)||n.responding.has(Z)))return;c.current.add(Z),n.respond(r.sessionId,Z,Y).finally(()=>c.current.delete(Z))}},e[5]=x,e[6]=d,e[7]=n,e[8]=l,e[9]=s.length,e[10]=r.kind,e[11]=r.request,e[12]=r.sessionId,e[13]=w):w=e[13];const b=w;let j;e[14]!==x||e[15]!==s.length?(j=s.length>1&&t.jsxs("span",{className:"flex items-center gap-1 text-xs tabular-nums text-muted-foreground",children:[x+1," of ",s.length,t.jsx($,{variant:"ghost",size:"icon-xs","aria-label":"Previous request",disabled:x===0,onClick:()=>f(x-1),children:t.jsx(ot,{"data-icon":"inline-start"})}),t.jsx($,{variant:"ghost",size:"icon-xs","aria-label":"Next request",disabled:x===s.length-1,onClick:()=>f(x+1),children:t.jsx(os,{"data-icon":"inline-start"})})]}),e[14]=x,e[15]=s.length,e[16]=j):j=e[16];let g;e[17]!==s.length||e[18]!==j?(g=t.jsx(as,{title:"Needs you",count:s.length,children:j}),e[17]=s.length,e[18]=j,e[19]=g):g=e[19];let y;e[20]===Symbol.for("react.memo_cache_sentinel")?(y=t.jsx("span",{className:"size-1.5 shrink-0 rounded-full bg-warning","aria-hidden":"true"}),e[20]=y):y=e[20];let N;e[21]!==l||e[22]!==r.sessionId?(N=()=>l(r.sessionId),e[21]=l,e[22]=r.sessionId,e[23]=N):N=e[23];let v;e[24]!==o||e[25]!==r.sessionId?(v=o(r.sessionId)??"A session",e[24]=o,e[25]=r.sessionId,e[26]=v):v=e[26];let k;e[27]!==N||e[28]!==v?(k=t.jsx("button",{type:"button",onClick:N,className:"min-w-0 truncate rounded-sm font-medium outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring",children:v}),e[27]=N,e[28]=v,e[29]=k):k=e[29];let S;e[30]!==p?(S=p&&t.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:["· ",p]}),e[30]=p,e[31]=S):S=e[31];let D;e[32]!==r.since?(D=Ae(new Date(r.since).toISOString()),e[32]=r.since,e[33]=D):D=e[33];let E;e[34]!==D?(E=t.jsxs("span",{className:"ml-auto shrink-0 text-xs tabular-nums text-warning",children:["waiting ",D]}),e[34]=D,e[35]=E):E=e[35];let I;e[36]!==S||e[37]!==E||e[38]!==k?(I=t.jsxs("div",{className:"flex items-center gap-2 px-0.5 text-[13px]",children:[y,k,S,E]}),e[36]=S,e[37]=E,e[38]=k,e[39]=I):I=e[39];const A=ss[r.kind];let _;e[40]!==A?(_=t.jsx("p",{className:"px-0.5 text-xs text-muted-foreground",children:A}),e[40]=A,e[41]=_):_=e[41];let P;e[42]!==r?(P=We(r),e[42]=r,e[43]=P):P=e[43];let B;e[44]!==d||e[45]!==r.sessionId?(B=d(r.sessionId),e[44]=d,e[45]=r.sessionId,e[46]=B):B=e[46];let M;e[47]!==l||e[48]!==r.sessionId?(M=()=>l(r.sessionId),e[47]=l,e[48]=r.sessionId,e[49]=M):M=e[49];let z;e[50]!==n||e[51]!==r||e[52]!==P||e[53]!==B||e[54]!==M?(z=t.jsx(St,{request:r,input:n,canAnswer:B,onOpen:M},P),e[50]=n,e[51]=r,e[52]=P,e[53]=B,e[54]=M,e[55]=z):z=e[55];let Q;e[56]!==I||e[57]!==_||e[58]!==z?(Q=t.jsxs("div",{className:"flex flex-col gap-2",children:[I,_,z]}),e[56]=I,e[57]=_,e[58]=z,e[59]=Q):Q=e[59];let K;e[60]!==x||e[61]!==i||e[62]!==o||e[63]!==s?(K=s.length>1&&t.jsx("ol",{className:"mt-3 flex flex-col","aria-label":"Also waiting",children:s.map((C,U)=>U===x?null:t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>f(U),className:"grid w-full grid-cols-[18px_minmax(0,1fr)_auto] items-center gap-2.5 rounded-lg px-2 py-2 text-left text-[12.5px] outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring",children:[t.jsx("span",{className:"text-right text-[11px] tabular-nums text-muted-foreground/80",children:U+1}),t.jsxs("span",{className:"flex min-w-0 flex-col",children:[t.jsxs("span",{className:"truncate font-medium",children:[o(C.sessionId)??"A session",Ke(i.get(C.sessionId),o)&&t.jsxs("span",{className:"font-normal text-muted-foreground",children:[" · ",Ke(i.get(C.sessionId),o)]})]}),t.jsx("span",{className:"truncate text-[11.5px] text-muted-foreground",children:ss[C.kind]})]}),t.jsx("span",{className:"text-[11px] tabular-nums text-warning",children:Ae(new Date(C.since).toISOString())})]})},We(C)))}),e[60]=x,e[61]=i,e[62]=o,e[63]=s,e[64]=K):K=e[64];let J;e[65]===Symbol.for("react.memo_cache_sentinel")?(J=t.jsx("p",{className:"mt-2 px-0.5 text-[11px] text-muted-foreground/80",children:"J / K move · Enter answers · D denies · O opens"}),e[65]=J):J=e[65];let V;return e[66]!==b||e[67]!==Q||e[68]!==K||e[69]!==g?(V=t.jsxs("section",{"aria-label":"Needs you",tabIndex:0,onKeyDown:b,className:"min-w-0 rounded-xl outline-none focus-visible:ring-2 focus-visible:ring-ring lg:min-h-0 lg:overflow-y-auto",children:[g,Q,K,J]}),e[66]=b,e[67]=Q,e[68]=K,e[69]=g,e[70]=V):V=e[70],V}function Ft(m){var e,s;return m.state==="needs-you"||(((e=m.counts)==null?void 0:e.needsYou)??0)>0?Pe.attention:m.state==="working"||(((s=m.counts)==null?void 0:s.working)??0)>0?Pe.working:null}function Ut(m){const e=F.c(39),{sessions:s,total:n,query:i,onQueryChange:o,searchRef:l,nameOf:d,projectLabel:a,onOpen:f,onRename:h,onBrowseProjects:c}=m;let x;e[0]!==i?(x=i.trim(),e[0]=i,e[1]=x):x=e[1];const r=x.length>0;let u;e[2]!==o||e[3]!==l?(u=()=>{var I;o(""),(I=l.current)==null||I.focus()},e[2]=o,e[3]=l,e[4]=u):u=e[4];const p=u,w=r?s.length:n;let b;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx(rt,{className:"pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground","aria-hidden":"true"}),e[5]=b):b=e[5];let j;e[6]!==o?(j=I=>o(I.target.value),e[6]=o,e[7]=j):j=e[7];let g;e[8]!==p||e[9]!==l?(g=I=>{var A;I.key==="Escape"&&(I.preventDefault(),p(),(A=l.current)==null||A.blur())},e[8]=p,e[9]=l,e[10]=g):g=e[10];let y;e[11]!==i||e[12]!==l||e[13]!==j||e[14]!==g?(y=t.jsx(Ue,{ref:l,type:"search","aria-label":"Search sessions",placeholder:"Search sessions",value:i,onChange:j,onKeyDown:g,className:"h-7 pl-8 pr-7 text-xs [&::-webkit-search-cancel-button]:hidden"}),e[11]=i,e[12]=l,e[13]=j,e[14]=g,e[15]=y):y=e[15];let N;e[16]!==p||e[17]!==r?(N=r?t.jsx("button",{type:"button","aria-label":"Clear search",onClick:p,className:"absolute right-1.5 top-1/2 flex size-4 -translate-y-1/2 items-center justify-center rounded-sm text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:t.jsx(is,{className:"size-3"})}):t.jsx("kbd",{className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 font-mono text-[10px] text-muted-foreground/70","aria-hidden":"true",children:"/"}),e[16]=p,e[17]=r,e[18]=N):N=e[18];let v;e[19]!==y||e[20]!==N?(v=t.jsxs("div",{className:"relative w-full max-w-64",children:[b,y,N]}),e[19]=y,e[20]=N,e[21]=v):v=e[21];let k;e[22]!==c?(k=c&&t.jsxs($,{variant:"ghost",size:"xs",className:"text-muted-foreground",onClick:c,children:[t.jsx(Ge,{"data-icon":"inline-start"}),"All projects"]}),e[22]=c,e[23]=k):k=e[23];let S;e[24]!==k||e[25]!==w||e[26]!==v?(S=t.jsxs(as,{title:"Your sessions",count:w,children:[v,k]}),e[24]=k,e[25]=w,e[26]=v,e[27]=S):S=e[27];let D;e[28]!==d||e[29]!==f||e[30]!==h||e[31]!==a||e[32]!==i||e[33]!==r||e[34]!==s?(D=s.length===0?t.jsx(Ks,{children:t.jsx(Ls,{children:t.jsx(Fs,{children:r?`No session matches “${i.trim()}”.`:"Start a session and it shows up here, with every session it starts."})})}):t.jsx("ul",{className:"flex flex-col lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:s.map(I=>t.jsx(Ht,{entry:I,nameOf:d,projectLabel:a,onOpen:f,onRename:h},I.session.sessionId))}),e[28]=d,e[29]=f,e[30]=h,e[31]=a,e[32]=i,e[33]=r,e[34]=s,e[35]=D):D=e[35];let E;return e[36]!==S||e[37]!==D?(E=t.jsxs("section",{"aria-label":"Your sessions",className:"flex min-w-0 flex-col lg:min-h-0 lg:flex-1",children:[S,D]}),e[36]=S,e[37]=D,e[38]=E):E=e[38],E}function Ht(m){const e=F.c(60),{entry:s,nameOf:n,projectLabel:i,onOpen:o,onRename:l}=m,[d,a]=H.useState(null),{session:f}=s;let h;e[0]!==n||e[1]!==f.sessionId?(h=n(f.sessionId)??"Untitled session",e[0]=n,e[1]=f.sessionId,e[2]=h):h=e[2];const c=h;let x;e[3]!==f?(x=Us(f),e[3]=f,e[4]=x):x=e[4];const r=x;let u,p;if(e[5]!==d||e[6]!==s||e[7]!==n||e[8]!==o||e[9]!==l||e[10]!==r||e[11]!==i||e[12]!==f||e[13]!==c){const g=Ft(s);let y;e[16]!==d||e[17]!==l||e[18]!==r||e[19]!==f.sessionId||e[20]!==c?(y=()=>{if(d===null)return;const M=d.trim();a(null),M!==c&&l(f.sessionId,M===r?"":M)},e[16]=d,e[17]=l,e[18]=r,e[19]=f.sessionId,e[20]=c,e[21]=y):y=e[21];const N=y;let v;e[22]!==s.counts||e[23]!==f.isActive?(v=s.counts?t.jsxs(t.Fragment,{children:[s.counts.working>0&&t.jsxs("span",{children:[t.jsx("span",{className:"font-medium text-foreground tabular-nums",children:s.counts.working})," working"]}),s.counts.needsYou>0&&t.jsxs("span",{className:"text-warning",children:[t.jsx("span",{className:"font-medium tabular-nums",children:s.counts.needsYou})," need you"]}),t.jsxs("span",{children:[t.jsx("span",{className:"font-medium text-foreground tabular-nums",children:s.counts.size})," in crew"]})]}):f.isActive&&t.jsx("span",{children:"working"}),e[22]=s.counts,e[23]=f.isActive,e[24]=v):v=e[24];let k;e[25]!==v?(k=t.jsx("span",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:v}),e[25]=v,e[26]=k):k=e[26];let S;e[27]!==s.landed?(S=s.landed&&t.jsxs(Hs,{variant:"outline",className:"shrink-0",children:["#",s.landed.number]}),e[27]=s.landed,e[28]=S):S=e[28];let D;e[29]!==s.landed||e[30]!==n||e[31]!==f.lastUserMessage?(D=s.landed?`${s.landed.title??"Pull request"} · ${n(s.landed.by.sessionId)??""}`:f.lastUserMessage??"",e[29]=s.landed,e[30]=n,e[31]=f.lastUserMessage,e[32]=D):D=e[32];let E;e[33]!==D?(E=t.jsx("span",{className:"truncate",children:D}),e[33]=D,e[34]=E):E=e[34];let I;e[35]!==E||e[36]!==S?(I=t.jsxs("span",{className:"flex min-w-0 items-center gap-2 text-xs text-muted-foreground",children:[S,E]}),e[35]=E,e[36]=S,e[37]=I):I=e[37];let A;e[38]!==s.activityAt||e[39]!==s.counts?(A=s.counts?`crew active ${Ae(s.activityAt)}`:Ae(s.activityAt),e[38]=s.activityAt,e[39]=s.counts,e[40]=A):A=e[40];let _;e[41]!==A?(_=t.jsx("span",{className:"text-[11px] tabular-nums text-muted-foreground/80",children:A}),e[41]=A,e[42]=_):_=e[42];let P;e[43]!==I||e[44]!==_||e[45]!==k?(P=t.jsxs(t.Fragment,{children:[k,I,_]}),e[43]=I,e[44]=_,e[45]=k,e[46]=P):P=e[46];const B=P;u="group/row relative border-t border-border/70 first:border-t-0",p=d===null?t.jsxs("button",{type:"button",onClick:()=>o(f.sessionId),className:le("grid w-full grid-cols-1 items-center gap-x-4 gap-y-1 rounded-lg py-3 pl-3 pr-10 text-left xl:grid-cols-[minmax(0,1fr)_auto]","outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring"),children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-2.5",children:[g&&t.jsx("span",{className:le("size-1.5 shrink-0 rounded-full",g),"aria-hidden":"true"}),t.jsx("span",{className:"truncate text-[13.5px] font-medium",children:c}),t.jsx("span",{className:"hidden min-w-0 truncate text-xs text-muted-foreground sm:inline",children:i(f)})]}),B]}):t.jsxs("div",{className:"grid w-full grid-cols-1 items-center gap-x-4 gap-y-1 rounded-lg py-3 pl-3 pr-10 text-left xl:grid-cols-[minmax(0,1fr)_auto]",children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-2.5",children:[g&&t.jsx("span",{className:le("size-1.5 shrink-0 rounded-full",g),"aria-hidden":"true"}),t.jsx(Ue,{autoFocus:!0,"aria-label":"Session name",value:d,placeholder:r,onChange:M=>a(M.target.value),onFocus:Qt,onBlur:N,onKeyDown:M=>{M.key==="Enter"&&(M.preventDefault(),N()),M.key==="Escape"&&(M.preventDefault(),a(null))},className:"h-7 max-w-md text-[13.5px] font-medium"}),t.jsx("span",{className:"hidden min-w-0 truncate text-xs text-muted-foreground sm:inline",children:i(f)})]}),B]}),e[5]=d,e[6]=s,e[7]=n,e[8]=o,e[9]=l,e[10]=r,e[11]=i,e[12]=f,e[13]=c,e[14]=u,e[15]=p}else u=e[14],p=e[15];let w;e[47]!==s||e[48]!==n||e[49]!==o||e[50]!==c?(w=s.crew.length>0&&t.jsx(Gt,{entry:s,title:c,nameOf:n,onOpen:o}),e[47]=s,e[48]=n,e[49]=o,e[50]=c,e[51]=w):w=e[51];let b;e[52]!==d||e[53]!==c?(b=d===null&&t.jsx($,{variant:"ghost",size:"icon-xs","aria-label":`Rename ${c}`,title:"Rename",onClick:()=>a(c),className:"absolute right-2 top-2.5 text-muted-foreground opacity-0 transition-opacity group-hover/row:opacity-100 focus-visible:opacity-100",children:t.jsx(at,{"data-icon":"icon"})}),e[52]=d,e[53]=c,e[54]=b):b=e[54];let j;return e[55]!==u||e[56]!==p||e[57]!==w||e[58]!==b?(j=t.jsxs("li",{className:u,children:[p,w,b]}),e[55]=u,e[56]=p,e[57]=w,e[58]=b,e[59]=j):j=e[59],j}function Qt(m){return m.target.select()}function Gt(m){const e=F.c(50),{entry:s,title:n,nameOf:i,onOpen:o}=m,[l,d]=H.useState(!1);let a,f,h,c,x,r,u,p;if(e[0]!==s.crew||e[1]!==s.session||e[2]!==l||e[3]!==i||e[4]!==o||e[5]!==n){a=s.crew.filter(Vt),f=a.slice(0,Ot);let E;e[14]!==s.session||e[15]!==i?(E=I=>{var _;const A=(_=I.crew)==null?void 0:_.parentId;return A&&A!==s.session.sessionId?i(A):void 0},e[14]=s.session,e[15]=i,e[16]=E):E=e[16],p=E,u="-mt-1.5 flex flex-col gap-1.5 px-3 pb-3",h="group",c=`${n} crew`,x="flex min-w-0 flex-wrap items-center gap-1.5",r=!l&&f.map(I=>{const{member:A,state:_}=I;return t.jsxs("button",{type:"button","aria-label":`Open ${i(A.sessionId)??"crew member"}`,onClick:()=>o(A.sessionId),className:"flex max-w-56 items-center gap-1.5 rounded-md border border-border/70 px-2 py-0.5 text-xs outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring",children:[t.jsx("span",{className:le("size-1.5 shrink-0 rounded-full",es[_]),"aria-hidden":"true"}),t.jsx("span",{className:"truncate",children:i(A.sessionId)??"Crew member"})]},A.sessionId)}),e[0]=s.crew,e[1]=s.session,e[2]=l,e[3]=i,e[4]=o,e[5]=n,e[6]=a,e[7]=f,e[8]=h,e[9]=c,e[10]=x,e[11]=r,e[12]=u,e[13]=p}else a=e[6],f=e[7],h=e[8],c=e[9],x=e[10],r=e[11],u=e[12],p=e[13];let w;e[17]!==l||e[18]!==a||e[19]!==f?(w=!l&&a.length>f.length&&t.jsxs("span",{className:"text-xs tabular-nums text-muted-foreground",children:["+",a.length-f.length," more"]}),e[17]=l,e[18]=a,e[19]=f,e[20]=w):w=e[20];let b;e[21]!==l?(b=()=>d(!l),e[21]=l,e[22]=b):b=e[22];const j=l&&"rotate-180";let g;e[23]!==j?(g=le("transition-transform",j),e[23]=j,e[24]=g):g=e[24];let y;e[25]!==g?(y=t.jsx(ct,{"data-icon":"inline-start",className:g}),e[25]=g,e[26]=y):y=e[26];const N=l?"Hide crew":`Show crew (${s.crew.length})`;let v;e[27]!==l||e[28]!==y||e[29]!==N||e[30]!==b?(v=t.jsxs($,{variant:"ghost",size:"xs","aria-expanded":l,onClick:b,className:"text-muted-foreground",children:[y,N]}),e[27]=l,e[28]=y,e[29]=N,e[30]=b,e[31]=v):v=e[31];let k;e[32]!==h||e[33]!==v||e[34]!==c||e[35]!==x||e[36]!==r||e[37]!==w?(k=t.jsxs("div",{role:h,"aria-label":c,className:x,children:[r,w,v]}),e[32]=h,e[33]=v,e[34]=c,e[35]=x,e[36]=r,e[37]=w,e[38]=k):k=e[38];let S;e[39]!==s.crew||e[40]!==l||e[41]!==i||e[42]!==o||e[43]!==n||e[44]!==p?(S=l&&t.jsx("ul",{"aria-label":`${n} crew members`,className:"flex max-h-72 flex-col overflow-y-auto rounded-md border border-border/70",children:s.crew.map(E=>{const{member:I,state:A}=E;return t.jsx("li",{children:t.jsxs("button",{type:"button","aria-label":`Open ${i(I.sessionId)??"crew member"}`,onClick:()=>o(I.sessionId),className:"grid w-full grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-2.5 px-2.5 py-1.5 text-left text-xs outline-none hover:bg-accent focus-visible:bg-accent",children:[t.jsx("span",{className:le("size-1.5 rounded-full",es[A]),"aria-hidden":"true"}),t.jsxs("span",{className:"truncate",children:[i(I.sessionId)??"Crew member",p(I)&&t.jsxs("span",{className:"text-muted-foreground",children:[" · via ",p(I)]})]}),t.jsx("span",{className:le("tabular-nums text-muted-foreground",A==="needs-you"&&"text-warning"),children:A==="done"?Ae(I.lastActivityAt||I.lastModified):Rt[A]})]})},I.sessionId)})}),e[39]=s.crew,e[40]=l,e[41]=i,e[42]=o,e[43]=n,e[44]=p,e[45]=S):S=e[45];let D;return e[46]!==k||e[47]!==S||e[48]!==u?(D=t.jsxs("div",{className:u,children:[k,S]}),e[46]=k,e[47]=S,e[48]=u,e[49]=D):D=e[49],D}function Vt(m){const{state:e}=m;return e!=="done"}export{Zt as MissionHome};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as x,c as d,j as s}from"./vendor-react-gGw_S5I_.js";import{O as p,Q as f,T as j,N as g,Y as C,M as S}from"./index-
|
|
1
|
+
import{r as x,c as d,j as s}from"./vendor-react-gGw_S5I_.js";import{O as p,Q as f,T as j,N as g,Y as C,M as S}from"./index-BYVl1VlW.js";import"./vendor-ui-B0az9ATE.js";import"./vendor-markdown-BEJ8yVzA.js";const F=x.memo(function(c){const e=d.c(10),{open:l,onClose:a,session:r,sessionChangeKey:h}=c;let i;e[0]!==a?(i=m=>{m||a()},e[0]=a,e[1]=i):i=e[1];let t;e[2]===Symbol.for("react.memo_cache_sentinel")?(t=s.jsxs(p,{className:"shrink-0 px-4 py-3",children:[s.jsx(f,{children:"File changes"}),s.jsx(j,{className:"sr-only",children:"Review files changed in this session."})]}),e[2]=t):t=e[2];let n;e[3]!==r||e[4]!==h?(n=s.jsxs(g,{side:"bottom",className:"h-[72svh] max-h-[92svh] rounded-t-xl",children:[t,s.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:s.jsx(C,{session:r,sessionChangeKey:h})})]}),e[3]=r,e[4]=h,e[5]=n):n=e[5];let o;return e[6]!==l||e[7]!==i||e[8]!==n?(o=s.jsx(S,{open:l,onOpenChange:i,children:n}),e[6]=l,e[7]=i,e[8]=n,e[9]=o):o=e[9],o});export{F as MobileFileChanges};
|