cogpit 3.5.4 → 3.6.0
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 +3084 -2382
- package/dist/cli.js +1 -1
- package/dist/instance-worker.js +625 -276
- package/dist/web/assets/AgentCheckDialog-DeSKJqG3.js +1 -0
- package/dist/web/assets/{AutomationsPanel-DTiDsq54.js → AutomationsPanel-BWjD657g.js} +1 -1
- package/dist/web/assets/{CogpitBlock-Hk57z10V.js → CogpitBlock-DEl4Kxl9.js} +15 -15
- package/dist/web/assets/CogpitView-BYDVcso1.js +85 -0
- package/dist/web/assets/CommandPaletteHost-BWee2Tov.js +1 -0
- package/dist/web/assets/{ConfigBrowser-C77Ydij0.js → ConfigBrowser-CQOlu4Gg.js} +1 -1
- package/dist/web/assets/{CrewPanel-BzEJLKMd.js → CrewPanel-Dzyxoj46.js} +1 -1
- package/dist/web/assets/{HighlightedEditor-D1S-wotA.js → HighlightedEditor-B-bjFcyU.js} +1 -1
- package/dist/web/assets/KeyboardShortcutsDialog-9k4clgVv.js +1 -0
- package/dist/web/assets/MissionHome-CIwnHTXt.js +2 -0
- package/dist/web/assets/{MobileFileChanges-DovO__Ap.js → MobileFileChanges-B8RaPAmX.js} +1 -1
- package/dist/web/assets/OrbitControls-CcXenNM0.js +1861 -0
- package/dist/web/assets/{PluginsDialog-o6ySRFLf.js → PluginsDialog-CYiiMArh.js} +1 -1
- package/dist/web/assets/{PreviewPanel-kD79kXYD.js → PreviewPanel-CZazqeGT.js} +1 -1
- package/dist/web/assets/{ProjectFilesPanel-CwEqOA2q.js → ProjectFilesPanel-oFw09UPd.js} +3 -3
- package/dist/web/assets/{ProjectSwitcherModal-BnWbJWEX.js → ProjectSwitcherModal-Bq7zI10J.js} +1 -1
- package/dist/web/assets/{TerminalOutput-DsK-7nR8.js → TerminalOutput-BDmdqvpJ.js} +1 -1
- package/dist/web/assets/{ThemeSelectorModal-D5SBWDm5.js → ThemeSelectorModal-Crb0YaTK.js} +1 -1
- package/dist/web/assets/{WorkflowsPanel-NU49178V.js → WorkflowsPanel-HqdzMBXP.js} +1 -1
- package/dist/web/assets/WorktreePanel-DHW4Agwj.js +1 -0
- package/dist/web/assets/auto-render.min-BCDUXXLr.js +1 -0
- package/dist/web/assets/d3.min-DhuWnDrq.js +1 -0
- package/dist/web/assets/{edition-ui-7WkqSCbs.js → edition-ui-Cm-dw9e0.js} +1 -1
- package/dist/web/assets/index-BtF9zrz_.css +1 -0
- package/dist/web/assets/index-C3zvtMTl.js +1 -0
- package/dist/web/assets/{index-BgZ8qUzM.js → index-DGG5ZuyK.js} +2 -2
- package/dist/web/assets/{index-CevokSRq.js → index-DUeulx0e.js} +2 -2
- package/dist/web/assets/index-Dn2vHUyS.js +2 -0
- package/dist/web/assets/index-Dv2TZ38C.js +521 -0
- package/dist/web/assets/katex.min-C_ZjXvJu.js +1 -0
- package/dist/web/assets/session-parser.worker-tdry_1oJ.js +43 -0
- package/dist/web/assets/{switch-DI9dp0Ya.js → switch-mgfHveYR.js} +1 -1
- package/dist/web/assets/three.core.min-D_80lYGt.js +1 -0
- package/dist/web/assets/three.module.min-CXftPEfC.js +1 -0
- package/dist/web/assets/{vendor-ui-Dc_kJXxz.js → vendor-ui-ClPj6-Gu.js} +230 -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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as p,j as u,r as U}from"./vendor-react-gGw_S5I_.js";import{bb as w,bc as ae,x as he,bd as ue,be as fe,bf as we,bg as ve,bh as Ce,bi as be,bj as Se,bk as je,bl as Te,bm as ke,bn as ye,bo as Fe,W as Pe,bp as xe,bq as Oe,aH as se,aY as Q,br as Ne,a$ as Re,bs as Ae,bt as Ie,bu as Ee,bv as $e,bw as De,F as Be}from"./index-Dv2TZ38C.js";import{bl as We,di as Me,bU as ie,ao as He,cX as Le,cS as _e,bo as Ue,cm as Ge,ba as le,cy as Ke,cJ as qe,aF as ze,c2 as Xe,a9 as Je,dj as Ve,cv as Ye,bQ as Qe,c8 as ce,dk as Ze,dl as pe,cA as et,cY as tt,dm as nt,aJ as ot,a3 as at,aX as re,cp as st,c3 as it,cC as lt,ae as ct,cD as rt,cB as dt}from"./vendor-ui-ClPj6-Gu.js";import"./vendor-markdown-BEJ8yVzA.js";function o(t,e,a,l,i,r,h){return{id:t,label:e,icon:l,run:i,shortcut:r,description:h,value:`${e} ${a}`}}function X(...t){return t.filter(e=>e!==!1&&e!==void 0)}function Z(t,e,a,l,i){const r=o(t,e,a,l,i);return{...r,value:`Help ${r.value}`}}function mt(t){const e=p.c(94);let a;e[0]!==t.canFocusComposer||e[1]!==t.extraActions||e[2]!==t.onDuplicateSession||e[3]!==t.onFindInConversation||e[4]!==t.onFocusComposer||e[5]!==t.onGoHome||e[6]!==t.onNewSession||e[7]!==t.onToggleMissionControl||e[8]!==t.showMission?(a=X(o("home","Go to Mission Control","home overview dashboard",_e,t.onGoHome),o("mission-control",t.showMission?"Exit Mission Control":"Open Mission Control","live sessions blocked waiting answer everything at once",Le,t.onToggleMissionControl,w("missionControl")),...(t.extraActions??[]).map(ut),o("new-session","Start a new session","project agent chat create",We,t.onNewSession,w("newSession")),t.onDuplicateSession&&o("duplicate-session","Duplicate this session","copy fork clone branch thread",Me,t.onDuplicateSession),t.canFocusComposer&&o("focus-composer","Focus message composer","chat prompt input",ie,t.onFocusComposer,w("focusComposer")),t.onFindInConversation&&o("find-in-conversation","Find in conversation","search text transcript turns matches",He,t.onFindInConversation,w("findInConversation"))),e[0]=t.canFocusComposer,e[1]=t.extraActions,e[2]=t.onDuplicateSession,e[3]=t.onFindInConversation,e[4]=t.onFocusComposer,e[5]=t.onGoHome,e[6]=t.onNewSession,e[7]=t.onToggleMissionControl,e[8]=t.showMission,e[9]=a):a=e[9];const l=a;let i;e[10]!==t?(i=(t.projects??[]).slice(0,8).map(n=>o(`project-${n.dirName}`,n.shortName,`${n.path} ${n.dirName} project workspace`,Ue,()=>{var c;return(c=t.onOpenProject)==null?void 0:c.call(t,n.dirName)},void 0,`${n.path} · ${n.sessionCount} session${n.sessionCount===1?"":"s"}`)),e[10]=t,e[11]=i):i=e[11];const r=i;let h;e[12]!==t?(h=(t.recentSessions??[]).slice(0,10).map(n=>{const N=(n.aiTitle||n.name||n.slug||n.lastUserMessage||n.firstUserMessage||n.sessionId).replace(/\s+/g," ").trim().slice(0,160)||n.sessionId,P=[n.projectShortName,n.gitBranch].filter(Boolean).join(" · ");return o(`session-${n.dirName}-${n.fileName}`,N,`${n.projectShortName} ${n.cwd??""} ${n.gitBranch??""} ${n.sessionId} recent thread conversation`,ie,()=>{var $;return($=t.onOpenSession)==null?void 0:$.call(t,n.dirName,n.fileName)},void 0,P)}),e[12]=t,e[13]=h):h=e[13];const f=h;let g;if(e[14]!==t){const n=t.devices??[];g=n.length>1&&t.onSwitchDevice?n.slice(0,ae.length).map((c,N)=>o(`device-${c.id}`,c.isActive?`${c.name} (current)`:`Switch to ${c.name}`,`device machine host remote ${c.id}`,c.isLocal?Ge:le,()=>{var P;return(P=t.onSwitchDevice)==null?void 0:P.call(t,c.id)},w(ae[N]))):[],e[14]=t,e[15]=g}else g=e[15];const d=g;let m;if(e[16]!==t.canOpenTerminal||e[17]!==t.hasFileChanges||e[18]!==t.hasSession||e[19]!==t.onToggleBrowser||e[20]!==t.onToggleFileChanges||e[21]!==t.onToggleProjectFiles||e[22]!==t.onToggleSidebar||e[23]!==t.onToggleStats||e[24]!==t.onToggleWorktrees||e[25]!==t.showBrowser||e[26]!==t.showFileChanges||e[27]!==t.showProjectFiles||e[28]!==t.showSidebar||e[29]!==t.showStats||e[30]!==t.showWorktrees||e[31]!==t.supportsWorktrees){let n;e[33]!==t.hasSession||e[34]!==t.onToggleStats||e[35]!==t.showStats?(n=t.hasSession&&o("toggle-stats",t.showStats?"Hide session details":"Show session details","stats tokens usage panel",Ke,t.onToggleStats,w("toggleStats")),e[33]=t.hasSession,e[34]=t.onToggleStats,e[35]=t.showStats,e[36]=n):n=e[36];let c;e[37]!==t.onToggleProjectFiles||e[38]!==t.showProjectFiles?(c=t.onToggleProjectFiles&&o("project-files",t.showProjectFiles?"Close project files":"Open project files","browse edit save workspace source code",qe,t.onToggleProjectFiles,w("projectFiles")),e[37]=t.onToggleProjectFiles,e[38]=t.showProjectFiles,e[39]=c):c=e[39];let N;e[40]!==t.onToggleBrowser||e[41]!==t.showBrowser?(N=t.onToggleBrowser&&o("toggle-browser",t.showBrowser?"Hide browser":"Show browser","web page live view browse panel",ze,t.onToggleBrowser),e[40]=t.onToggleBrowser,e[41]=t.showBrowser,e[42]=N):N=e[42];let P;e[43]!==t.hasFileChanges||e[44]!==t.onToggleFileChanges||e[45]!==t.showFileChanges?(P=t.hasFileChanges&&o("toggle-file-changes",t.showFileChanges?"Hide file changes":"Show file changes","diff edits review panel",Xe,t.onToggleFileChanges),e[43]=t.hasFileChanges,e[44]=t.onToggleFileChanges,e[45]=t.showFileChanges,e[46]=P):P=e[46];let $;e[47]!==t.canOpenTerminal||e[48]!==t.onToggleWorktrees||e[49]!==t.showWorktrees||e[50]!==t.supportsWorktrees?($=t.supportsWorktrees&&t.canOpenTerminal&&o("toggle-worktrees",t.showWorktrees?"Hide worktrees":"Show worktrees","git branches panel",Je,t.onToggleWorktrees),e[47]=t.canOpenTerminal,e[48]=t.onToggleWorktrees,e[49]=t.showWorktrees,e[50]=t.supportsWorktrees,e[51]=$):$=e[51],m=X(o("toggle-sidebar",t.showSidebar?"Hide session sidebar":"Show session sidebar","projects navigation panel",Ve,t.onToggleSidebar,w("toggleSidebar")),n,c,N,P,$),e[16]=t.canOpenTerminal,e[17]=t.hasFileChanges,e[18]=t.hasSession,e[19]=t.onToggleBrowser,e[20]=t.onToggleFileChanges,e[21]=t.onToggleProjectFiles,e[22]=t.onToggleSidebar,e[23]=t.onToggleStats,e[24]=t.onToggleWorktrees,e[25]=t.showBrowser,e[26]=t.showFileChanges,e[27]=t.showProjectFiles,e[28]=t.showSidebar,e[29]=t.showStats,e[30]=t.showWorktrees,e[31]=t.supportsWorktrees,e[32]=m}else m=e[32];const C=m;let L;e[52]!==t?(L=X(t.onOpenProjectInEditor&&o("open-project-editor","Open project in editor","code cursor vscode zed workspace",it,t.onOpenProjectInEditor),t.onRevealProject&&o("reveal-project","Reveal project in file manager","finder explorer folder directory",st,t.onRevealProject),t.onCopyResumeCommand&&o("copy-resume-command","Copy resume command","cli claude codex copilot terminal clipboard continue session",re,t.onCopyResumeCommand),t.onCopyProjectPath&&o("copy-project-path","Copy project path","workspace directory clipboard",re,t.onCopyProjectPath),t.onOpenIntegratedTerminal&&o("integrated-terminal","New integrated terminal","embedded shell command line process panel",at,t.onOpenIntegratedTerminal,w("newIntegratedTerminal")),t.canOpenTerminal&&o("terminal","Open in system terminal","external shell command line app",ot,t.onOpenTerminal,w("systemTerminal")),t.onTogglePreview&&o("preview","Toggle development preview","browser localhost dev server website",nt,t.onTogglePreview,w("preview")),t.onOpenConfig&&o("config",t.showConfig?"Close agent configuration":"Open agent configuration","skills commands claude settings files",tt,t.onOpenConfig),o("settings","Open Cogpit settings","preferences network",et,t.onOpenSettings),t.onCheckAgents&&o("check-agents","Check agent setup","install sign in login doctor environment agents cli",pe,t.onCheckAgents),o("theme","Change theme & chat width","appearance light dark oled width narrow wide",Ze,t.onOpenTheme,w("themeSelector")),o("expand","Expand all groups","conversation details",ce,t.onExpandAll,w("expandAll")),o("expand-payloads","Expand all tool payloads","raw input result diff conversation details",ce,t.onExpandToolPayloads,w("expandToolPayloads")),o("collapse","Collapse all","conversation groups payloads details",Qe,t.onCollapseAll),t.onKillAll&&o("kill-all","Kill all agent processes","stop terminate halt everything runaway",Ye,t.onKillAll),t.onOpenDevices&&o("manage-devices","Manage devices…","remote machines hub hosts edit rename remove switch",ct,()=>{var n;return(n=t.onOpenDevices)==null?void 0:n.call(t,"manage")}),t.onOpenDevices&&o("add-device","Add device…","remote machine hub host connect pair new",le,()=>{var n;return(n=t.onOpenDevices)==null?void 0:n.call(t,"add")})),e[52]=t,e[53]=L):L=e[53];const D=L;let B;e[54]!==t.onOpenKeyboardShortcuts?(B=X(Z("documentation","Documentation","docs guide manual readme getting started learn how to",dt,ht),t.onOpenKeyboardShortcuts&&Z("keyboard-shortcuts","Keyboard shortcuts","keys hotkeys keybindings cheat sheet customize",lt,t.onOpenKeyboardShortcuts),Z("report-issue","Report an issue","bug problem feedback support github",rt,gt)),e[54]=t.onOpenKeyboardShortcuts,e[55]=B):B=e[55];const G=B;let O;e[56]!==l?(O={value:"Navigation",items:l},e[56]=l,e[57]=O):O=e[57];let R;e[58]!==f?(R=f.length>0?[{value:"Recent sessions",items:f}]:[],e[58]=f,e[59]=R):R=e[59];let A;e[60]!==r?(A=r.length>0?[{value:"Projects",items:r}]:[],e[60]=r,e[61]=A):A=e[61];let S;e[62]!==d?(S=d.length>0?[{value:"Devices",items:d}]:[],e[62]=d,e[63]=S):S=e[63];let j;e[64]!==C?(j={value:"View",items:C},e[64]=C,e[65]=j):j=e[65];let T;e[66]!==D?(T={value:"Tools",items:D},e[66]=D,e[67]=T):T=e[67];let k;e[68]!==G?(k={value:"Help & docs",items:G},e[68]=G,e[69]=k):k=e[69];let W;e[70]!==S||e[71]!==j||e[72]!==T||e[73]!==k||e[74]!==O||e[75]!==R||e[76]!==A?(W=[O,...R,...A,...S,j,T,k],e[70]=S,e[71]=j,e[72]=T,e[73]=k,e[74]=O,e[75]=R,e[76]=A,e[77]=W):W=e[77];const M=W;let s;e[78]!==t?(s=function(c){t.onOpenChange(!1),c.run()},e[78]=t,e[79]=s):s=e[79];const H=s;let b;e[80]===Symbol.for("react.memo_cache_sentinel")?(b=u.jsx(fe,{"aria-label":"Search commands",autoFocus:!0,placeholder:"Search commands..."}),e[80]=b):b=e[80];let y;e[81]!==t.loadingNavigation?(y=t.loadingNavigation&&u.jsxs("div",{className:"motion-enter flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",role:"status",children:[u.jsx(he,{className:"size-3.5"}),"Loading projects and sessions..."]}),e[81]=t.loadingNavigation,e[82]=y):y=e[82];let I;e[83]===Symbol.for("react.memo_cache_sentinel")?(I=u.jsx(we,{children:"No matching actions."}),e[83]=I):I=e[83];let F;e[84]!==M||e[85]!==H?(F=u.jsxs(ve,{className:"max-h-[min(26rem,60vh)]",children:[I,u.jsx(ft,{groups:M,onRun:H})]}),e[84]=M,e[85]=H,e[86]=F):F=e[86];let v;e[87]!==y||e[88]!==F?(v=u.jsxs(Ce,{label:"Search commands",loop:!0,children:[b,y,F]}),e[87]=y,e[88]=F,e[89]=v):v=e[89];let E;return e[90]!==t.onOpenChange||e[91]!==t.open||e[92]!==v?(E=u.jsx(ue,{open:t.open,onOpenChange:t.onOpenChange,title:"Command palette",description:"Search for a Cogpit action to run.",className:"max-w-xl",children:v}),e[90]=t.onOpenChange,e[91]=t.open,e[92]=v,e[93]=E):E=e[93],E}function gt(){return window.open(be,"_blank","noopener,noreferrer")}function ht(){return window.open(Se,"_blank","noopener,noreferrer")}function ut(t){return o(t.id,t.label,t.keywords,t.icon,t.onSelect)}function ft(t){const e=p.c(8),{groups:a,onRun:l}=t,i=je(Ct);let r;e[0]!==a||e[1]!==i?(r=i?a.map(g=>({group:g,score:Math.max(0,...g.items.map(d=>Te(d.value,i)))})).sort(vt).map(wt):a,e[0]=a,e[1]=i,e[2]=r):r=e[2];const h=r;let f;if(e[3]!==l||e[4]!==h){let g;e[6]!==l?(g=d=>u.jsx(ke,{heading:d.value,children:d.items.map(m=>{const C=m.icon;return u.jsxs(ye,{value:m.value,onSelect:()=>l(m),children:[u.jsx(C,{"aria-hidden":"true"}),u.jsxs("span",{className:"min-w-0 flex-1",children:[u.jsx("span",{className:"block truncate",children:m.label}),m.description&&u.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:m.description})]}),m.shortcut&&u.jsx(Fe,{children:m.shortcut})]},m.id)})},d.value),e[6]=l,e[7]=g):g=e[7],f=h.map(g),e[3]=l,e[4]=h,e[5]=f}else f=e[5];return f}function wt(t){const{group:e}=t;return e}function vt(t,e){return e.score-t.score}function Ct(t){return t.search}async function de(t,e){const a=await Be(t,{signal:e});if(!a.ok)throw new Error(`Request failed (${a.status})`);const l=await a.json();return Array.isArray(l)?l:[]}function kt(t){var ee;const e=p.c(51);let a,l,i,r,h,f;e[0]!==t?({open:i,currentProjectDirName:a,projectCwd:h,onProcessStarted:l,launchTerminalRequest:f,...r}=t,e[0]=t,e[1]=a,e[2]=l,e[3]=i,e[4]=r,e[5]=h,e[6]=f):(a=e[1],l=e[2],i=e[3],r=e[4],h=e[5],f=e[6]);const g=f===void 0?0:f,d=Pe();let m;e[7]===Symbol.for("react.memo_cache_sentinel")?(m=[],e[7]=m):m=e[7];const[C,L]=U.useState(m);let D;e[8]===Symbol.for("react.memo_cache_sentinel")?(D=[],e[8]=D):D=e[8];const[B,G]=U.useState(D),[O,R]=U.useState(!1),A=U.useRef(0),S=xe();let j,T;e[9]!==S||e[10]!==i?(j=()=>{if(!i)return;const x=new AbortController,K=Re();return R(!0),Promise.allSettled([de("/api/projects",x.signal),de(Ae({limit:"12",perProject:"3"},S),x.signal)]).then(ge=>{const[te,ne]=ge;if(x.signal.aborted)return;const oe=ne.status==="fulfilled"?ne.value:[];Ie(oe,K),L(te.status==="fulfilled"?te.value:[]),G(oe),R(!1)}),()=>x.abort()},T=[i,S],e[9]=S,e[10]=i,e[11]=j,e[12]=T):(j=e[11],T=e[12]),U.useEffect(j,T);let k;e[13]!==C?(k=Oe(C),e[13]=C,e[14]=k):k=e[14];const W=k;let M;e:{if(h){M=h;break e}if(!a){M=null;break e}let x;e[15]!==a||e[16]!==C?(x=((ee=C.find(K=>K.dirName===a))==null?void 0:ee.path)??null,e[15]=a,e[16]=C,e[17]=x):x=e[17],M=x}const s=M;let H;e[18]!==l||e[19]!==d||e[20]!==s?(H=()=>{if(!s)return;const x=d.spawnTerminal({cwd:s}),K=s.replace(/\/+$/,"").split("/").at(-1)||"Terminal";l({id:x,name:K,type:"terminal",status:"running",source:s})},e[18]=l,e[19]=d,e[20]=s,e[21]=H):H=e[21];const b=H;let y,I;e[22]!==b||e[23]!==g||e[24]!==d.status||e[25]!==s?(I=()=>{g<=A.current||!s||d.status!=="connected"||(A.current=g,b())},y=[b,g,d.status,s],e[22]=b,e[23]=g,e[24]=d.status,e[25]=s,e[26]=y,e[27]=I):(y=e[26],I=e[27]),U.useEffect(I,y);let F;e[28]!==a||e[29]!==s?(F={path:s,dirName:a},e[28]=a,e[29]=s,e[30]=F):F=e[30];const v=F;let E;e[31]!==v?(E=()=>Ee(v),e[31]=v,e[32]=E):E=e[32];const n=E;let c;e[33]!==v?(c=()=>$e(v),e[33]=v,e[34]=c):c=e[34];const N=c,P=!se()&&Q("hostFiles"),$=Q("hostFiles")&&(!se()||Ne());let q;e[35]!==s?(q=()=>{s&&De(s)},e[35]=s,e[36]=q):q=e[36];const me=q;let _;e[37]!==b||e[38]!==d.status||e[39]!==s?(_=s&&d.status==="connected"&&Q("terminal")?b:void 0,e[37]=b,e[38]=d.status,e[39]=s,e[40]=_):_=e[40];const J=s&&$?n:void 0,V=s&&P?N:void 0,Y=s?me:void 0;let z;return e[41]!==O||e[42]!==i||e[43]!==r||e[44]!==B||e[45]!==W||e[46]!==_||e[47]!==J||e[48]!==V||e[49]!==Y?(z=u.jsx(mt,{...r,open:i,projects:W,recentSessions:B,loadingNavigation:O,onOpenIntegratedTerminal:_,onOpenProjectInEditor:J,onRevealProject:V,onCopyProjectPath:Y}),e[41]=O,e[42]=i,e[43]=r,e[44]=B,e[45]=W,e[46]=_,e[47]=J,e[48]=V,e[49]=Y,e[50]=z):z=e[50],z}export{kt as CommandPaletteHost};
|
|
@@ -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-Dv2TZ38C.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-ClPj6-Gu.js";import{H as lt}from"./HighlightedEditor-B-bjFcyU.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 k,c as ue,j as n}from"./vendor-react-gGw_S5I_.js";import{F as _e,dp as it,a0 as je,dq as jt,dr as yt,ds as Nt,B as J,E as rt,f as ct,U as It,h as dt,i as ut,ae as Je,dt as kt,ac as Qe,aC as et,du as Ct,dv as St,m as ft,ad as Mt,dw as $t,av as Rt,cN as Tt,dx as At,db as Et,aZ as Ot,o as Lt,n as _t,D as zt,j as Dt,c as oe,dy as Ft,bX as Pt,bY as Yt,bW as qt,dz as Ye,V as qe,dA as Wt,cL as Ht,ch as Ut,ci as Bt,cj as Te,ck as Ae,al as Gt,k as Kt,dB as Vt,dC as Xt,dD as Zt,b8 as Jt}from"./index-Dv2TZ38C.js";import{S as Qt}from"./switch-mgfHveYR.js";import{bU as es,dE 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,dF as is,aS as rs,X as cs}from"./vendor-ui-ClPj6-Gu.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 Ee(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),[x,h]=k.useState(!1),[r,w]=k.useState(!1),[u,g]=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=>Ee(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 O=await(await ke(await je(`/api/crew-chat/${encodeURIComponent(t)}`,{text:v,commandId:p.current.id}))).json();return d.current++,l(R=>Ee(R,[O.message])),p.current=null,c(O.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),g(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(O=>O.sessionId===v?{...O,listening:_}:O)}),c(null)}catch(I){c(I instanceof Error?I.message:"Couldn't change listening.")}finally{b.current.delete(v),g(I=>{const O=new Set(I);return O.delete(v),O})}}},[t]),E=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=>Ee(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:x,post:L,setListening:A,older:E}}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]=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,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 C=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],k.useEffect(L,A);let E;e[17]!==a||e[18]!==f?(E=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]=E):E=e[19];const v=E;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 O;if(e[25]!==a||e[26]!==o||e[27]!==g||e[28]!==s||e[29]!==C){let B;e[31]!==a||e[32]!==o||e[33]!==s||e[34]!==C?(B=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:()=>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]=C,e[35]=B):B=e[35],O=g.map(B),e[25]=a,e[26]=o,e[27]=g,e[28]=s,e[29]=C,e[30]=O}else O=e[30];let R;e[36]!==O?(R=n.jsx(et,{className:"max-h-48 gap-2 overflow-y-auto py-2",children:O}),e[36]=O,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]!==C){let B;e[55]!==S||e[56]!==p||e[57]!==o||e[58]!==s||e[59]!==C?(B=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]=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]=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 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 ks(t){return(t+1)*le+t*de}function Cs(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 E=A.pop();if(L.has(E.sessionId))continue;L.add(E.sessionId),M.count++;const v=he(E);v==="working"?M.working++:v==="needs-you"&&M.needsYou++,A.push(...f(E.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),E=A.length>0&&s.has(y.sessionId),v=E?[]:A,_=i&&!l&&v.length>=st?v.filter(C):[],I=_.length>=st?_:[],O=new Set(I),R=v.filter(D=>!O.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:E,hidden:E?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(E){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)))),E=Math.ceil(M.length/A),v={parentId:y,x:L*(le+de),y:g,width:A*le+(A-1)*de+2*pe,height:E*ne+(E-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,Ce=1.2,Ts=56,As=900,Es=.85,Os=320,Oe={all:new Set,active:new Set};function Ls(t){const[e,s]=Et(Ot("crew-map-filter"),"all"),i=e==="active"?"active":"all",[l,o]=k.useState({rootId:t,folds:Oe}),c=k.useRef(new Map),a=l.rootId===t?l.folds:Oe,f=k.useCallback(h=>o(r=>{const w=r.rootId===t?r.folds:Oe,u=new Set(w[i]);return u.delete(h)||u.add(h),{rootId:t,folds:{...w,[i]:u}}}),[i,t]),x=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:x}}function _s(t){const e=ue.c(86),{crew:s,hereId:i,controls:l,kinds:o,nameOf:c,onOpen:a}=t,[f,x]=k.useState(!1),{filter:h,collapsed:r,toggle:w}=l;let u,g,d,p,N,C,b,S,y,M,L,A,E,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,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:()=>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,E="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]=C,e[16]=b,e[17]=S,e[18]=y,e[19]=M,e[20]=L,e[21]=A,e[22]=E,e[23]=v,e[24]=_,e[25]=I}else u=e[10],g=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],E=e[22],v=e[23],_=e[24],I=e[25];let O;e[51]!==p||e[52]!==y?(O=n.jsx("span",{className:p,children:y}),e[51]=p,e[52]=y,e[53]=O):O=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]!==O||e[59]!==T||e[60]!==M||e[61]!==L?(z=n.jsxs("header",{className:M,children:[L,O,R,T]}),e[58]=O,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]!==E||e[73]!==v||e[74]!==_?(F=n.jsxs(u,{showCloseButton:A,className:E,children:[v,_,z,Y]}),e[68]=u,e[69]=z,e[70]=Y,e[71]=A,e[72]=E,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]!==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: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=k.useRef(null),[w,u]=k.useState({width:0,height:0}),g=s&&w.width>=As,d=k.useMemo(()=>Is(t),[t]),p=w.width-2*ie,N=!s&&w.width>0&&ks(d)*Es>p,C=N?Pe(p-d*Me-De,le,Os):le,b=k.useMemo(()=>Cs(t,i,e,{group:g,...N&&{stacked:{cardWidth:C}}}),[t,i,e,g,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),E=k.useRef(null),v=k.useRef({left:0,top:0}),_=k.useRef(null),I=k.useRef(null),O=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,E.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)}E.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))},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=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:U,onPointerCancel:U,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:O.width,height:O.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=>{E.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/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: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 C=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 E;e[16]!==h||e[17]!==f?(E=()=>f(h),e[16]=h,e[17]=f,e[18]=E):E=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 O;e[19]!==v||e[20]!==_||e[21]!==I?(O=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]=O):O=e[22];let R;e[23]!==y||e[24]!==h.sessionId||e[25]!==w||e[26]!==E||e[27]!==O||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:E,className:O}),e[23]=y,e[24]=h.sessionId,e[25]=w,e[26]=E,e[27]=O,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]!==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(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 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 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]=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),x=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(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(C);return}a==null||a(),await h(S)}catch{S()&&l(C)}finally{x.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]),g=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: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]=k.useState("overview");let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=new Set,e[0]=g):g=e[0];const[d,p]=k.useState(g),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=>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 E=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,O,R;e[11]===Symbol.for("react.memo_cache_sentinel")?(I=n.jsx(ht,{"aria-hidden":"true",className:"size-4 text-muted-foreground"}),O=n.jsx("h2",{className:"text-sm font-medium",children:"Crew"}),R=n.jsx("div",{className:"flex-1"}),e[11]=I,e[12]=O,e[13]=R):(I=e[11],O=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,O,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]!==E||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:E}),n.jsx(tn,{crew:o,busy:a,nameOf:L,onOpen:E,onRespond:f}),n.jsx(sn,{crew:o,hereId:l,busy:a,nameOf:L,onOpen:E,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:E})}),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]=E,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 O;e[16]!==s?(O=bs(s),e[16]=s,e[17]=O):O=e[17],d=O;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 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 E;return e[47]!==N||e[48]!==A||e[49]!==u||e[50]!==g?(E=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]=E):E=e[51],E}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]=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 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 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:[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}),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[x,h]=k.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 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",E=w>0&&"border-l border-border/70";let v;e[8]!==A||e[9]!==E?(v=oe("group/crew relative flex items-start rounded-md",A,E),e[8]=A,e[9]=E,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 O;e[13]!==u||e[14]!==x||e[15]!==o||e[16]!==h?(O=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]=O):O=e[17];let R;e[18]!==O?(R=n.jsx("span",{className:"mt-1.5 flex w-6 shrink-0 justify-center",children:O}),e[18]=O,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{dj as _,dk as C,dl as D,c as H}from"./index-Dv2TZ38C.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-Dv2TZ38C.js";import{bL as T,cC as oe,ao as ce}from"./vendor-ui-ClPj6-Gu.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};
|