groove-dev 0.27.120 → 0.27.121
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/node_modules/@groove-dev/cli/package.json +1 -1
- package/node_modules/@groove-dev/daemon/package.json +1 -1
- package/node_modules/@groove-dev/daemon/src/index.js +1 -2
- package/node_modules/@groove-dev/gui/dist/assets/{index-oKbzuMnX.js → index-bmkBX18f.js} +1 -1
- package/node_modules/@groove-dev/gui/dist/index.html +1 -1
- package/node_modules/@groove-dev/gui/package.json +1 -1
- package/node_modules/@groove-dev/gui/src/components/layout/status-bar.jsx +8 -10
- package/package.json +1 -1
- package/packages/cli/package.json +1 -1
- package/packages/daemon/package.json +1 -1
- package/packages/daemon/src/index.js +1 -2
- package/packages/gui/dist/assets/{index-oKbzuMnX.js → index-bmkBX18f.js} +1 -1
- package/packages/gui/dist/index.html +1 -1
- package/packages/gui/package.json +1 -1
- package/packages/gui/src/components/layout/status-bar.jsx +8 -10
|
@@ -5,7 +5,6 @@ import { createServer as createHttpServer, request as httpProxyRequest } from 'h
|
|
|
5
5
|
import { createServer as createNetServer } from 'net';
|
|
6
6
|
import { execFileSync } from 'child_process';
|
|
7
7
|
import { resolve } from 'path';
|
|
8
|
-
import { homedir } from 'os';
|
|
9
8
|
import { readFileSync, writeFileSync, unlinkSync, existsSync, mkdirSync, readdirSync, rmdirSync, rmSync, statSync } from 'fs';
|
|
10
9
|
import express from 'express';
|
|
11
10
|
import { WebSocketServer } from 'ws';
|
|
@@ -95,7 +94,7 @@ export class Daemon {
|
|
|
95
94
|
this.port = options.port !== undefined ? options.port : (parseInt(process.env.GROOVE_PORT, 10) || DEFAULT_PORT);
|
|
96
95
|
this.host = resolveHost(options.host);
|
|
97
96
|
this.projectDir = options.projectDir || process.cwd();
|
|
98
|
-
this.grooveDir = options.grooveDir || resolve(
|
|
97
|
+
this.grooveDir = options.grooveDir || resolve(this.projectDir, '.groove');
|
|
99
98
|
this.pidFile = resolve(this.grooveDir, 'daemon.pid');
|
|
100
99
|
|
|
101
100
|
// Ensure .groove directories exist
|
|
@@ -8611,7 +8611,7 @@ ${s}`);const c={chatHistory:[...a().chatHistory[n]||[]],activityLog:[...a().acti
|
|
|
8611
8611
|
|
|
8612
8612
|
If you want to hide the \`${a.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
8613
8613
|
|
|
8614
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${a.docsSlug}`;return g.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},iQe="DialogDescriptionWarning",cQe=({contentRef:e,descriptionId:a})=>{const s=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${wG(iQe).contentName}}.`;return g.useEffect(()=>{var c;const o=(c=e.current)==null?void 0:c.getAttribute("aria-describedby");a&&o&&(document.getElementById(a)||console.warn(s))},[s,e,a]),null},jG=AG,lQe=uG,CG=pG,MG=fG,SG=xG,yT=gG,NG=vG,qE=OG;function Rt({children:e,...a}){return t.jsx(jG,{...a,children:e})}const QG=lQe;function Ht({children:e,className:a,title:n,description:s,...o}){return t.jsxs(CG,{children:[t.jsx(MG,{className:"fixed inset-0 z-50 bg-black/50 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"}),t.jsxs(SG,{className:G("fixed left-1/2 top-1/2 z-50 -translate-x-1/2 -translate-y-1/2","w-full max-w-lg max-h-[85vh] overflow-y-auto","bg-surface-1 border border-border rounded-lg shadow-2xl","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",a),...o,children:[n&&t.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-border-subtle",children:[t.jsx(yT,{className:"text-base font-semibold text-text-0 font-sans",children:n}),t.jsx(qE,{className:"p-1 rounded-md text-text-3 hover:text-text-0 hover:bg-surface-5 transition-colors",children:t.jsx(Ge,{size:16})})]}),s&&t.jsx(NG,{className:"sr-only",children:s}),e]})]})}const AQe={primary:"bg-accent/20 text-accent border border-accent/25 hover:bg-accent/30 font-medium",secondary:"bg-surface-5/40 text-text-1 border border-border-subtle hover:bg-surface-5/70 hover:text-text-0",ghost:"bg-transparent text-text-2 border border-transparent hover:bg-surface-5/50 hover:text-text-0",danger:"bg-danger/12 text-danger border border-danger/15 hover:bg-danger/20",info:"bg-info/12 text-info border border-info/15 hover:bg-info/20",outline:"bg-transparent text-accent border border-accent/30 hover:bg-accent/10"},dQe={sm:"h-7 px-2.5 text-xs gap-1.5 rounded",md:"h-8 px-3 text-sm gap-2 rounded",lg:"h-9 px-4 text-sm gap-2 rounded",icon:"h-8 w-8 rounded"},pe=g.forwardRef(({className:e,variant:a="secondary",size:n="md",children:s,...o},c)=>t.jsx("button",{ref:c,className:G("inline-flex items-center justify-center font-sans transition-colors duration-100","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent","disabled:opacity-40 disabled:pointer-events-none","cursor-pointer select-none",AQe[a],dQe[n],e),...o,children:s}));pe.displayName="Button";function uQe(){const e=$(h=>h.updateModalOpen),a=$(h=>h.setUpdateModalOpen),n=$(h=>h.version),s=$(h=>h.updateReady),o=$(h=>h.updateProgress),c=$(h=>h.installUpdate),l=o&&!s,d=l?Math.max(0,Math.min(100,o.percent||0)):100;return t.jsx(Rt,{open:e,onOpenChange:a,children:t.jsxs(Ht,{title:"Update Available",description:"Desktop app update",children:[t.jsxs("div",{className:"px-5 py-4 flex flex-col gap-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"flex items-center justify-center w-10 h-10 rounded-lg bg-accent/12",children:t.jsx(Ta,{size:20,className:"text-accent"})}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-text-1 font-sans font-medium",children:l?"Downloading update…":"Ready to update"}),t.jsxs("p",{className:"text-xs text-text-3 font-sans mt-0.5",children:[n&&t.jsx("span",{className:"font-mono",children:n}),n&&s&&" → ",s&&t.jsx("span",{className:"font-mono text-accent",children:s})]})]})]}),l&&t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[t.jsx(ze,{size:12,className:"animate-spin text-accent flex-shrink-0"}),t.jsx("div",{className:"flex-1 h-1.5 rounded-full bg-surface-3 overflow-hidden",children:t.jsx("div",{className:"h-full rounded-full bg-accent transition-all duration-500 ease-out",style:{width:`${d}%`}})}),t.jsxs("span",{className:"text-2xs font-mono text-text-3 tabular-nums",children:[d,"%"]})]}),!l&&t.jsx("p",{className:"text-xs text-text-3 font-sans leading-relaxed",children:"The app will restart to apply the update. Your work is saved automatically."})]}),t.jsxs("div",{className:"flex items-center justify-end gap-2 px-5 py-3 border-t border-border-subtle bg-surface-0",children:[t.jsx(pe,{variant:"ghost",size:"sm",onClick:()=>a(!1),children:"Later"}),t.jsxs(pe,{variant:"primary",size:"sm",disabled:l,onClick:()=>{c(),a(!1)},children:[t.jsx(Ta,{size:12}),"Update & Restart"]})]})]})})}function hQe({connected:e,agentCount:a,runningCount:n,uptime:s,terminalVisible:o,onToggleTerminal:c}){const l=$(w=>w.savedTunnels),d=$(w=>w.tunneled),h=$(w=>w.version),f=$(w=>w.updateReady),x=$(w=>w.updateProgress),m=$(w=>w.setUpdateModalOpen),y=$(w=>w.setActiveView),k=l.filter(w=>w.active),O=K0();return t.jsxs("footer",{className:"h-6 flex-shrink-0 flex items-center px-3 bg-surface-3 border-t border-border text-2xs font-sans select-none",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(aa,{status:e?"running":"crashed",size:"sm"}),t.jsx("span",{className:e?"text-text-2":"text-danger",children:e?O?"Desktop":"Connected":"Offline"})]}),O&&e&&t.jsxs("button",{onClick:()=>gP(window.location.href),className:"flex items-center gap-1 text-text-4 hover:text-text-1 cursor-pointer transition-colors",title:"Open this workspace in your browser",children:[t.jsx(ea,{size:10}),t.jsx("span",{children:"Browser"})]}),e&&s>0&&t.jsxs("span",{className:"text-text-4",children:["Up ",Ud(s)]}),e&&a>0&&t.jsxs("span",{className:"text-text-4",children:[n,"/",a," agents"]}),d?t.jsxs("button",{onClick:()=>{var w,C,j;return((j=(C=(w=window.groove)==null?void 0:w.remote)==null?void 0:C.close)==null?void 0:j.call(C))||window.close()},className:"flex items-center gap-1.5 text-text-3 hover:text-danger cursor-pointer transition-colors",title:"Close remote connection",children:[t.jsx(Fo,{size:10}),t.jsx("span",{children:"Disconnect"})]}):t.jsxs(t.Fragment,{children:[k.map(w=>t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsxs("button",{onClick:()=>{const C=w.localPort,j=encodeURIComponent(w.name);gP(`http://localhost:${C}?instance=${j}`)},className:"flex items-center gap-1.5 text-text-3 hover:text-text-1 cursor-pointer transition-colors",title:"Open remote GUI",children:[t.jsx(Fn,{size:10,className:"text-success"}),t.jsx("span",{children:w.name}),t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-success"}),w.latencyMs!=null&&t.jsxs("span",{className:"text-text-4",children:[w.latencyMs,"ms"]})]}),t.jsx("button",{onClick:()=>$.getState().disconnectTunnel(w.id),className:"p-0.5 text-text-4 hover:text-danger cursor-pointer transition-colors rounded",title:"Disconnect",children:t.jsx(Ge,{size:10})})]},w.id)),l.length>0&&t.jsxs("button",{onClick:()=>$.getState().toggleQuickConnect(),className:"flex items-center gap-1.5 text-text-4 hover:text-text-1 cursor-pointer transition-colors",title:"Quick Connect to remote server",children:[t.jsx(ra,{size:10}),t.jsx("span",{children:"Connect"})]})]}),e&&t.jsxs("button",{onClick:()=>y("federation"),className:"flex items-center gap-1.5 text-text-4 hover:text-text-1 cursor-pointer transition-colors",title:"Federation",children:[t.jsx(ea,{size:10}),t.jsx("span",{children:"Federation"})]})]}),t.jsx("div",{className:"flex-1"}),f||x?t.jsx("button",{onClick:()=>m(!0),className:"flex items-center gap-1 px-2 h-full cursor-pointer",title:f?`Update to v${f}`:"Downloading update…",children:t.jsxs(we,{variant:"warning",className:"cursor-pointer",children:[t.jsx(Ta,{size:10}),f?"Update Available":"Downloading…"]})}):h?t.jsxs("span",{className:"text-text-4 px-2",children:["v",h]}):null,!O&&t.jsxs("a",{href:"https://docs.groovedev.ai",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 px-2 h-full text-text-3 hover:text-text-1 hover:bg-surface-5 transition-colors no-underline",children:[t.jsx(_o,{size:12}),t.jsx("span",{children:"Docs"})]}),t.jsxs("button",{onClick:c,className:G("flex items-center gap-1.5 px-2 h-full transition-colors cursor-pointer",o?"text-accent bg-accent/8 hover:bg-accent/12":"text-text-3 hover:text-text-1 hover:bg-surface-5"),children:[t.jsx(cs,{size:12}),t.jsx("span",{children:"Terminal"}),t.jsx("kbd",{className:"font-mono text-text-4 ml-0.5",children:"Cmd+J"})]}),t.jsx(uQe,{})]})}function pQe({children:e,width:a,onWidthChange:n,onClose:s,className:o}){const c=g.useRef(!1),l=g.useRef(0),d=g.useRef(0),h=g.useCallback(f=>{f.preventDefault(),c.current=!0,l.current=f.clientX,d.current=a;function x(y){if(!c.current)return;const k=l.current-y.clientX,O=Math.min(Math.max(d.current+k,380),window.innerWidth*.65);n(O)}function m(){c.current=!1,document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",m)}document.addEventListener("mousemove",x),document.addEventListener("mouseup",m)},[a,n]);return t.jsxs("aside",{className:G("flex-shrink-0 flex bg-surface-1 border-l border-border relative",o),style:{width:a},children:[t.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1 cursor-col-resize hover:bg-accent/30 transition-colors z-10",onMouseDown:h}),t.jsx("button",{onClick:s,className:"absolute top-3 right-3 z-10 p-1 rounded-md text-text-3 hover:text-text-0 hover:bg-surface-5 transition-colors cursor-pointer",children:t.jsx(Ge,{size:14})}),t.jsx("div",{className:"flex-1 overflow-y-auto overflow-x-hidden",children:e})]})}const fQe=[{id:"nav:agents",label:"Go to Agents",icon:ru,category:"Navigation",action:e=>{e.setActiveView("agents")}},{id:"nav:editor",label:"Go to Editor",icon:Ft,category:"Navigation",action:e=>{e.setActiveView("editor")}},{id:"nav:dashboard",label:"Go to Dashboard",icon:G1,category:"Navigation",action:e=>{e.setActiveView("dashboard")}},{id:"nav:marketplace",label:"Go to Marketplace",icon:Au,category:"Navigation",action:e=>{e.setActiveView("marketplace")}},{id:"nav:teams",label:"Go to Teams",icon:Ba,category:"Navigation",action:e=>{e.setActiveView("teams")}},{id:"nav:federation",label:"Go to Federation",icon:ea,category:"Navigation",action:e=>{e.setActiveView("federation")}},{id:"action:whitelist",label:"Add to Federation Whitelist",icon:wa,category:"Federation",action:e=>{e.setActiveView("federation")}},{id:"action:spawn",label:"Spawn Agent",icon:gt,category:"Actions",action:e=>{e.openDetail({type:"spawn"})}},{id:"action:terminal",label:"Toggle Terminal",icon:cs,category:"Actions",action:e=>{e.setTerminalVisible(!e.terminalVisible)},shortcut:"Cmd+J"},{id:"action:journalist",label:"Toggle Journalist",icon:Uo,category:"Actions",action:e=>{var a;((a=e.detailPanel)==null?void 0:a.type)==="journalist"?e.closeDetail():e.openDetail({type:"journalist"})}}];function xQe(){const e=$(O=>O.commandPaletteOpen),a=$(O=>O.toggleCommandPalette),n=$(O=>O.agents),s=$(O=>O.savedTunnels),o=$,[c,l]=g.useState(""),[d,h]=g.useState(0),f=g.useRef(null),x=g.useMemo(()=>{var j;const O=n.flatMap(S=>[{id:`chat:${S.id}`,label:`Chat with ${S.name}`,icon:mn,category:"Agents",action:Q=>{Q.selectAgent(S.id)}},...S.status==="running"?[{id:`rotate:${S.id}`,label:`Rotate ${S.name}`,icon:Sr,category:"Agents",action:Q=>{Q.rotateAgent(S.id)}},{id:`kill:${S.id}`,label:`Kill ${S.name}`,icon:vd,category:"Agents",action:Q=>{Q.killAgent(S.id)}}]:[]]),w=[{id:"action:quickconnect",label:"Quick Connect",icon:Fn,category:"Remote",action:S=>{S.toggleQuickConnect()}},...s.map(S=>S.active?{id:`tunnel:open:${S.id}`,label:`Open ${S.name}`,icon:ha,category:"Remote",action:()=>{window.open(`http://localhost:${S.localPort}?instance=${encodeURIComponent(S.name)}`,"_blank")}}:{id:`tunnel:connect:${S.id}`,label:`Connect to ${S.name}`,icon:Fn,category:"Remote",action:Q=>{Q.connectTunnel(S.id)}})],C=(j=window.groove)!=null&&j.openFolder?[{id:"action:openfolder",label:"Open Folder",icon:pa,category:"Window",shortcut:"Cmd+O",action:()=>window.groove.openFolder()}]:[];return[...fQe,...C,...O,...w]},[n,s]),m=g.useMemo(()=>{if(!c.trim())return x.slice(0,12);const O=c.toLowerCase();return x.filter(w=>w.label.toLowerCase().includes(O)||w.category.toLowerCase().includes(O)).slice(0,12)},[x,c]);g.useEffect(()=>{e&&(l(""),h(0),setTimeout(()=>{var O;return(O=f.current)==null?void 0:O.focus()},50))},[e]),g.useEffect(()=>{d>=m.length&&h(Math.max(0,m.length-1))},[m.length,d]);function y(O){O.action(o.getState()),a()}function k(O){O.key==="ArrowDown"?(O.preventDefault(),h(w=>Math.min(w+1,m.length-1))):O.key==="ArrowUp"?(O.preventDefault(),h(w=>Math.max(w-1,0))):O.key==="Enter"&&m[d]?(O.preventDefault(),y(m[d])):O.key==="Escape"&&a()}return e?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-50 bg-black/40 backdrop-blur-sm",onClick:a}),t.jsx(Su,{children:t.jsxs(Hn.div,{initial:{opacity:0,y:-20,scale:.96},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-10,scale:.98},transition:{duration:.15},className:"fixed top-[15%] left-1/2 -translate-x-1/2 z-50 w-[480px] max-h-[400px] bg-surface-1 border border-border rounded-lg shadow-2xl overflow-hidden",onKeyDown:k,children:[t.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border-subtle",children:[t.jsx(ta,{size:16,className:"text-text-3 flex-shrink-0"}),t.jsx("input",{ref:f,value:c,onChange:O=>{l(O.target.value),h(0)},placeholder:"Type a command...",className:"flex-1 bg-transparent text-xs text-text-0 font-sans placeholder:text-text-4 focus:outline-none"})]}),t.jsxs("div",{className:"overflow-y-auto max-h-[320px] py-1",children:[m.length===0&&t.jsx("div",{className:"px-4 py-6 text-sm text-text-3 text-center font-sans",children:"No results"}),m.map((O,w)=>t.jsxs("button",{onClick:()=>y(O),onMouseEnter:()=>h(w),className:G("w-full flex items-center gap-3 px-4 py-2 text-sm font-sans cursor-pointer",w===d?"bg-surface-5 text-text-0":"text-text-1 hover:bg-surface-4"),children:[t.jsx(O.icon,{size:16,className:"text-text-3 flex-shrink-0"}),t.jsx("span",{className:"flex-1 text-left",children:O.label}),t.jsx("span",{className:"text-2xs text-text-4",children:O.category}),O.shortcut&&t.jsx("kbd",{className:"text-2xs font-mono bg-surface-4 px-1 py-0.5 rounded text-text-3 ml-1",children:O.shortcut})]},O.id))]})]})})]}):null}function mQe(){const e=$(s=>s.pendingApprovals),a=$(s=>s.approveRequest),n=$(s=>s.rejectRequest);return e!=null&&e.length?t.jsx("div",{className:"fixed bottom-10 left-1/2 -translate-x-1/2 z-50 w-full max-w-md flex flex-col gap-2 px-4",children:t.jsx(Su,{children:e.map(s=>{var o;return t.jsxs(Hn.div,{initial:{y:20,opacity:0},animate:{y:0,opacity:1},exit:{y:20,opacity:0},transition:{duration:.2},className:"rounded-lg border border-accent/30 bg-surface-2/95 backdrop-blur-md shadow-xl shadow-accent/5 overflow-hidden",children:[t.jsxs("div",{className:"px-4 py-3 flex items-start gap-3",children:[t.jsx(oa,{size:16,className:"text-warning shrink-0 mt-0.5"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("p",{className:"text-sm font-semibold text-text-0 font-sans truncate",children:[s.agentName||"Agent"," needs approval"]}),((o=s.action)==null?void 0:o.description)&&t.jsx("p",{className:"text-2xs text-text-3 font-sans mt-0.5 line-clamp-2",children:s.action.description})]})]}),t.jsxs("div",{className:"px-4 py-2.5 border-t border-border-subtle flex items-center justify-end gap-2",children:[t.jsxs(pe,{size:"sm",variant:"ghost",className:"text-danger hover:bg-danger/10",onClick:()=>n(s.id),children:[t.jsx(vr,{size:14,className:"mr-1"}),"Reject"]}),t.jsxs(pe,{size:"sm",variant:"accent",onClick:()=>a(s.id),children:[t.jsx(du,{size:14,className:"mr-1"}),"Approve"]})]})]},s.id)})})}):null}function gQe({path:e,onNavigate:a}){const n=e.split("/").filter(Boolean);return t.jsxs("div",{className:"flex items-center gap-0.5 min-w-0 overflow-x-auto py-1.5 scrollbar-none",children:[t.jsx("button",{onClick:()=>a("/"),className:"flex-shrink-0 p-1 rounded hover:bg-surface-5 cursor-pointer text-text-3 hover:text-text-0 transition-colors",children:t.jsx(jr,{size:13})}),n.map((s,o)=>{const c="/"+n.slice(0,o+1).join("/"),l=o===n.length-1;return t.jsxs("div",{className:"flex items-center gap-0.5 flex-shrink-0",children:[t.jsx(Yt,{size:11,className:"text-text-4"}),t.jsx("button",{onClick:()=>a(c),className:G("px-1.5 py-0.5 rounded text-xs font-mono cursor-pointer transition-colors",l?"text-text-0 bg-surface-4 font-medium":"text-text-3 hover:text-text-0 hover:bg-surface-5"),children:s})]},o)})]})}function Lu({open:e,onOpenChange:a,currentPath:n,onSelect:s,homePath:o,mandatory:c=!1,title:l}){const d=o||"/home",[h,f]=g.useState(n||d),[x,m]=g.useState([]),[y,k]=g.useState(!1),[O,w]=g.useState(null);g.useEffect(()=>{e&&C(n||d)},[e]);async function C(B){k(!0),w(null);try{const M=await D.get(`/browse-system?path=${encodeURIComponent(B)}`);f(M.current||B),m(M.dirs||[])}catch(M){w(M.message),m([])}k(!1)}function j(){const B=h==="/"?"/":h.split("/").slice(0,-1).join("/")||"/";C(B)}function S(){C(d)}function Q(){s(h),c||a(!1)}const N=l||(c?"Select Project Directory":"Select Working Directory"),L=c?{onEscapeKeyDown:B=>B.preventDefault(),onInteractOutside:B=>B.preventDefault(),onPointerDownOutside:B=>B.preventDefault()}:{};return t.jsx(Rt,{open:e,onOpenChange:c?()=>{}:a,children:t.jsxs(Ht,{title:c?void 0:N,description:"Choose a directory for this agent to work in",className:"max-w-[520px]",...L,children:[c&&t.jsxs("div",{className:"px-5 py-4 border-b border-border-subtle",children:[t.jsx("div",{className:"text-base font-semibold text-text-0 font-sans",children:N}),t.jsx("div",{className:"text-xs text-text-3 font-sans mt-1",children:"Pick a directory on this remote machine to get started."})]}),t.jsxs("div",{className:"px-5 py-4 space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:j,disabled:h==="/",className:"p-1.5 rounded-md bg-surface-4 border border-border text-text-2 hover:text-text-0 hover:bg-surface-5 transition-colors cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed",children:t.jsx(D1,{size:14})}),t.jsx("button",{onClick:S,className:"p-1.5 rounded-md bg-surface-4 border border-border text-text-2 hover:text-text-0 hover:bg-surface-5 transition-colors cursor-pointer",children:t.jsx(mo,{size:14})}),t.jsx("div",{className:"flex-1 min-w-0 bg-surface-0 rounded-md border border-border-subtle px-2",children:t.jsx(gQe,{path:h,onNavigate:C})})]}),t.jsx("div",{className:"bg-surface-0 rounded-lg border border-border-subtle overflow-hidden",children:t.jsxs("div",{className:"max-h-[340px] overflow-y-auto",children:[y&&t.jsx("div",{className:"flex items-center justify-center py-8",children:t.jsx(ze,{size:18,className:"text-text-3 animate-spin"})}),O&&t.jsx("div",{className:"px-4 py-6 text-center",children:t.jsx("p",{className:"text-xs text-danger font-sans",children:O})}),!y&&!O&&x.length===0&&t.jsx("div",{className:"px-4 py-6 text-center",children:t.jsx("p",{className:"text-xs text-text-3 font-sans",children:"No subdirectories"})}),!y&&!O&&x.map(B=>t.jsxs("button",{onClick:()=>C(B.path),className:G("w-full flex items-center gap-2.5 px-3.5 py-2 text-left cursor-pointer","hover:bg-surface-4 transition-colors border-b border-border-subtle last:border-0"),children:[B.hasChildren?t.jsx(r0,{size:15,className:"text-warning flex-shrink-0"}):t.jsx(pa,{size:15,className:"text-text-3 flex-shrink-0"}),t.jsx("span",{className:"text-sm text-text-0 font-sans truncate flex-1",children:B.name}),B.hasChildren&&t.jsx(Yt,{size:12,className:"text-text-4 flex-shrink-0"})]},B.path))]})}),t.jsxs("div",{className:"flex items-center gap-3 bg-surface-4/50 rounded-lg px-3.5 py-2.5 border border-border-subtle",children:[t.jsx(pa,{size:16,className:"text-accent flex-shrink-0"}),t.jsx("span",{className:"text-xs font-mono text-text-1 truncate flex-1",children:h})]}),t.jsxs("div",{className:"flex justify-end gap-2",children:[!c&&t.jsx(pe,{variant:"ghost",size:"md",onClick:()=>a(!1),children:"Cancel"}),t.jsxs(pe,{variant:"primary",size:"md",onClick:Q,className:"gap-1.5",children:[t.jsx(Re,{size:14})," Select Folder"]})]})]})]})})}const gD=[{id:"details",label:"Server Details",icon:Kt},{id:"auth",label:"Authentication",icon:nu},{id:"setup",label:"Setup",icon:Nr},{id:"connected",label:"Connected",icon:ra}];function yQe({steps:e,currentStep:a,completedSteps:n,onStepClick:s}){return t.jsx("div",{className:"flex items-center gap-1 mb-4",children:e.map((o,c)=>{const l=a===c,d=n.includes(c),h=d||c<a;return o.icon,t.jsxs("div",{className:"flex items-center gap-1 flex-1",children:[t.jsxs("button",{onClick:()=>h&&s(c),disabled:!h,className:G("flex items-center gap-1.5 px-2 py-1 rounded-md transition-colors text-2xs font-sans font-medium",l?"bg-accent/12 text-accent":d?"text-success cursor-pointer hover:bg-surface-3":"text-text-4",h&&!l&&"cursor-pointer"),children:[t.jsx("div",{className:G("w-5 h-5 rounded-full flex items-center justify-center text-2xs font-semibold border transition-colors",l?"border-accent bg-accent/15 text-accent":d?"border-success/40 bg-success/10 text-success":"border-border-subtle bg-surface-3 text-text-4"),children:d?t.jsx(Re,{size:10}):c+1}),t.jsx("span",{className:"hidden sm:inline",children:o.label})]}),c<e.length-1&&t.jsx("div",{className:G("flex-1 h-px mx-1",d?"bg-success/30":"bg-border-subtle")})]},o.id)})})}function yD({value:e,onChange:a}){return t.jsx("button",{onClick:()=>a(!e),className:G("w-9 h-5 rounded-full p-0.5 transition-colors cursor-pointer",e?"bg-accent":"bg-surface-5"),children:t.jsx("div",{className:G("w-4 h-4 rounded-full bg-white shadow-sm transition-transform",e?"translate-x-4":"translate-x-0")})})}function Lp({icon:e,title:a,children:n}){return t.jsxs("div",{className:"rounded-lg border border-border-subtle bg-surface-1 px-4 py-3.5 flex flex-col gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-6 h-6 rounded bg-accent/8 flex items-center justify-center flex-shrink-0",children:t.jsx(e,{size:12,className:"text-accent"})}),t.jsx("span",{className:"text-[13px] font-medium text-text-0 font-sans leading-tight",children:a})]}),t.jsx("div",{className:"mt-1",children:n})]})}function vQe({server:e,onSave:a,onTest:n,onConnect:s,onCancel:o}){const c=$(Ae=>Ae.remoteHomedir),[l,d]=g.useState(0),[h,f]=g.useState([]),[x,m]=g.useState(""),[y,k]=g.useState(""),[O,w]=g.useState(""),[C,j]=g.useState(22),[S,Q]=g.useState(""),[N,L]=g.useState(!1),[B,M]=g.useState(!1),[I,F]=g.useState(!1),[E,V]=g.useState(!1),[Z,X]=g.useState(null),[q,H]=g.useState(!1),[T,R]=g.useState(!1);g.useEffect(()=>{e?(m(e.name||""),k(e.host||""),w(e.user||""),j(e.port||22),Q(e.sshKeyPath||""),L(e.autoStart||!1),M(e.autoConnect||!1),f([0,1]),d(2)):(m(""),k(""),w(""),j(22),Q(""),L(!1),M(!1),f([]),d(0))},[e]);function U(){const Ae={name:x.trim(),host:y.trim(),user:O.trim(),port:C,sshKeyPath:S.trim(),autoStart:N,autoConnect:B};return e!=null&&e.id&&(Ae.id=e.id),Ae}function z(){return x.trim()&&y.trim()&&O.trim()}function Y(){l===0&&!z()||(f(Ae=>Ae.includes(l)?Ae:[...Ae,l]),d(Ae=>Math.min(Ae+1,gD.length-1)))}function ue(){d(Ae=>Math.max(Ae-1,0))}async function W(){V(!0),X(null);try{const Ae=U();H(!0),await a(Ae),H(!1);const Qe=await n();X(Qe)}catch(Ae){X({error:Ae.message||"Test failed"}),H(!1)}V(!1)}async function re(){H(!0);try{const Ae=U();await a(Ae),f(Qe=>Qe.includes(l)?Qe:[...Qe,l]),d(2)}catch(Ae){X({error:Ae.message||"Save failed"})}H(!1)}async function xe(){var Ae;R(!0);try{const Qe=U();await a(Qe),await s(),f(ee=>[...new Set([...ee,2])]),d(3)}catch(Qe){let ee=((Ae=Qe==null?void 0:Qe.body)==null?void 0:Ae.error)||(Qe==null?void 0:Qe.message)||"Connection failed";ee.toLowerCase().includes("port forward")&&(ee+=" — Check that the remote server is reachable and SSH port forwarding is allowed."),X({error:ee})}R(!1)}const ve="h-8 px-2.5 text-xs bg-surface-0 border border-border-subtle rounded-md text-text-0 font-sans placeholder:text-text-4 focus:outline-none focus:ring-1 focus:ring-accent",ie="h-8 px-2.5 text-xs bg-surface-0 border border-border-subtle rounded-md text-text-0 font-mono placeholder:text-text-4 focus:outline-none focus:ring-1 focus:ring-accent";return t.jsxs("div",{className:"p-4",children:[t.jsx(yQe,{steps:gD,currentStep:l,completedSteps:h,onStepClick:d}),l===0&&t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsx(Lp,{icon:Kt,title:"Server Info",children:t.jsxs("div",{className:"space-y-2.5",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-2xs font-semibold text-text-2 font-sans mb-1 block",children:"Name"}),t.jsx("input",{value:x,onChange:Ae=>m(Ae.target.value),placeholder:"api-vps",className:G(ve,"w-full"),autoFocus:!0})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-2xs font-semibold text-text-2 font-sans mb-1 block",children:"Host"}),t.jsx("input",{value:y,onChange:Ae=>k(Ae.target.value),placeholder:"165.22.180.45",className:G(ie,"w-full")})]})]})}),t.jsx(Lp,{icon:Nr,title:"Connection",children:t.jsxs("div",{className:"space-y-2.5",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-2xs font-semibold text-text-2 font-sans mb-1 block",children:"User"}),t.jsx("input",{value:O,onChange:Ae=>w(Ae.target.value),placeholder:"root",className:G(ie,"w-full")})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-2xs font-semibold text-text-2 font-sans mb-1 block",children:"SSH Port"}),t.jsx("input",{value:C,onChange:Ae=>j(Number(Ae.target.value)||22),type:"number",className:G(ie,"w-24")})]})]})})]}),l===1&&t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsx(Lp,{icon:nu,title:"SSH Key",children:t.jsxs("div",{className:"space-y-2.5",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-2xs font-semibold text-text-2 font-sans mb-1 block",children:"Key Path"}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("input",{value:S,onChange:Ae=>Q(Ae.target.value),placeholder:"~/.ssh/id_ed25519",className:G(ie,"flex-1 min-w-0"),autoFocus:!0}),t.jsx(pe,{variant:"secondary",size:"sm",onClick:()=>F(!0),className:"h-8 px-2 flex-shrink-0",children:t.jsx(pd,{size:12})})]}),t.jsx("p",{className:"text-2xs text-text-4 font-sans mt-1",children:"Leave blank to use default SSH agent."})]}),t.jsxs(pe,{variant:"secondary",size:"sm",onClick:W,disabled:E,className:"h-7 text-2xs gap-1.5",children:[E?t.jsx(ze,{size:11,className:"animate-spin"}):t.jsx(ra,{size:11}),"Test Connection"]})]})}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"rounded-lg border border-border-subtle bg-surface-1 px-4 py-3.5",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("div",{className:"w-6 h-6 rounded bg-accent/8 flex items-center justify-center flex-shrink-0",children:t.jsx(Kt,{size:12,className:"text-accent"})}),t.jsx("span",{className:"text-[13px] font-medium text-text-0 font-sans",children:"Target"})]}),t.jsxs("div",{className:"space-y-1.5 text-2xs font-sans",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-text-3",children:"Host"}),t.jsx("span",{className:"text-text-1 font-mono",children:y||"—"})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-text-3",children:"User"}),t.jsx("span",{className:"text-text-1 font-mono",children:O||"—"})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-text-3",children:"Port"}),t.jsx("span",{className:"text-text-1 font-mono",children:C})]})]})]}),Z&&t.jsx("div",{className:G("px-3 py-2.5 rounded-lg text-2xs font-sans flex items-start gap-2",Z.error?"bg-danger/8 border border-danger/20 text-danger":Z.reachable?"bg-success/8 border border-success/20 text-success":"bg-warning/8 border border-warning/20 text-warning"),children:Z.error?t.jsxs(t.Fragment,{children:[t.jsx(Ge,{size:11,className:"mt-0.5 flex-shrink-0"})," ",Z.error]}):Z.reachable?t.jsxs(t.Fragment,{children:[t.jsx(Re,{size:11,className:"mt-0.5 flex-shrink-0"})," Server reachable"]}):t.jsxs(t.Fragment,{children:[t.jsx(oa,{size:11,className:"mt-0.5 flex-shrink-0"})," Host unreachable"]})})]}),t.jsx(Lu,{open:I,onOpenChange:F,currentPath:S||"~/.ssh",homePath:c,onSelect:Ae=>Q(Ae)})]}),l===2&&t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsx(Lp,{icon:Nr,title:"Behavior",children:t.jsxs("div",{className:"space-y-3",children:[t.jsxs("label",{className:"flex items-center justify-between cursor-pointer",children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-xs text-text-1 font-sans block",children:"Auto-start daemon"}),t.jsx("span",{className:"text-2xs text-text-4 font-sans",children:"Start Groove on the remote when connecting"})]}),t.jsx(yD,{value:N,onChange:L})]}),t.jsxs("label",{className:"flex items-center justify-between cursor-pointer",children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-xs text-text-1 font-sans block",children:"Auto-connect on launch"}),t.jsx("span",{className:"text-2xs text-text-4 font-sans",children:"Connect when Groove starts"})]}),t.jsx(yD,{value:B,onChange:M})]})]})}),Z&&!Z.error&&t.jsxs("div",{className:"rounded-lg border border-border-subtle bg-surface-1 px-4 py-3.5",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[t.jsx("div",{className:"w-6 h-6 rounded bg-success/10 flex items-center justify-center flex-shrink-0",children:t.jsx(Re,{size:12,className:"text-success"})}),t.jsx("span",{className:"text-[13px] font-medium text-text-0 font-sans",children:"Test Results"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2 text-2xs font-sans",children:[t.jsx(aa,{status:Z.reachable?"running":"crashed",size:"sm"}),t.jsx("span",{className:"text-text-1",children:"Reachable"})]}),t.jsxs("div",{className:"flex items-center gap-2 text-2xs font-sans",children:[t.jsx(aa,{status:Z.grooveInstalled?"running":"stopped",size:"sm"}),t.jsx("span",{className:"text-text-1",children:"Groove Installed"})]}),t.jsxs("div",{className:"flex items-center gap-2 text-2xs font-sans",children:[t.jsx(aa,{status:Z.daemonRunning?"running":"stopped",size:"sm"}),t.jsx("span",{className:"text-text-1",children:"Daemon Running"})]})]})]}),(!Z||Z.error)&&t.jsxs("div",{className:"rounded-lg border border-border-subtle bg-surface-1 px-4 py-3.5",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("div",{className:"w-6 h-6 rounded bg-accent/8 flex items-center justify-center flex-shrink-0",children:t.jsx(Kt,{size:12,className:"text-accent"})}),t.jsx("span",{className:"text-[13px] font-medium text-text-0 font-sans",children:x||"Server"})]}),t.jsxs("div",{className:"space-y-1.5 text-2xs font-sans",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-text-3",children:"Connection"}),t.jsxs("span",{className:"text-text-1 font-mono",children:[O,"@",y,":",C]})]}),S&&t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-text-3",children:"SSH Key"}),t.jsx("span",{className:"text-text-1 font-mono truncate max-w-40",children:S})]})]})]})]}),l===3&&t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{className:"rounded-lg border border-success/30 bg-success/5 px-4 py-5 text-center",children:[t.jsx("div",{className:"w-10 h-10 rounded-full bg-success/15 flex items-center justify-center mx-auto mb-3",children:t.jsx(Re,{size:20,className:"text-success"})}),t.jsx("h3",{className:"text-sm font-semibold text-text-0 font-sans mb-1",children:"Connected"}),t.jsxs("p",{className:"text-2xs text-text-3 font-sans",children:["Successfully connected to ",t.jsx("span",{className:"font-mono text-text-1",children:x})]}),t.jsxs(pe,{variant:"primary",size:"sm",onClick:()=>{const Ae=e==null?void 0:e.localPort,Qe=encodeURIComponent(x);window.open(`http://localhost:${Ae}?instance=${Qe}`,"_blank")},className:"h-8 text-xs gap-1.5 mt-4",children:[t.jsx(ha,{size:12}),"Open Remote GUI"]})]}),t.jsxs("div",{className:"rounded-lg border border-border-subtle bg-surface-1 px-4 py-3.5",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[t.jsx("div",{className:"w-6 h-6 rounded bg-accent/8 flex items-center justify-center flex-shrink-0",children:t.jsx(Kt,{size:12,className:"text-accent"})}),t.jsx("span",{className:"text-[13px] font-medium text-text-0 font-sans",children:"Connection Info"})]}),t.jsxs("div",{className:"space-y-1.5 text-2xs font-sans",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-text-3",children:"Connection"}),t.jsxs("span",{className:"text-text-1 font-mono",children:[O,"@",y,":",C]})]}),S&&t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-text-3",children:"SSH Key"}),t.jsx("span",{className:"text-text-1 font-mono truncate max-w-40",children:S})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-text-3",children:"Auto-start"}),t.jsx("span",{className:"text-text-1",children:N?"On":"Off"})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-text-3",children:"Auto-connect"}),t.jsx("span",{className:"text-text-1",children:B?"On":"Off"})]}),(e==null?void 0:e.remoteVersion)&&t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-text-3",children:"Version"}),t.jsxs("span",{className:G("text-text-1 font-mono",e.versionMatch===!1&&"text-warning"),children:["v",e.remoteVersion,e.versionMatch===!1&&" (update available)"]})]})]})]})]}),t.jsxs("div",{className:"flex items-center justify-between mt-4",children:[t.jsx(pe,{variant:"ghost",size:"sm",onClick:l===0||l===3?o:ue,className:"h-8 text-xs px-4 text-text-3",children:l===0?"Cancel":l===3?"Done":"Back"}),l<3&&t.jsx("div",{className:"flex gap-2",children:l===2?t.jsxs(pe,{variant:"primary",size:"sm",onClick:xe,disabled:T||q,className:"h-8 text-xs px-4 gap-1.5",children:[T?t.jsx(ze,{size:12,className:"animate-spin"}):t.jsx(ra,{size:12}),T?"Connecting...":"Connect"]}):l===1?t.jsx(pe,{variant:"primary",size:"sm",onClick:re,disabled:q,className:"h-8 text-xs px-4",children:q?"Saving...":"Next"}):t.jsx(pe,{variant:"primary",size:"sm",onClick:Y,disabled:!z(),className:"h-8 text-xs px-4",children:"Next"})})]})]})}function BG(){const e=$(y=>y.quickConnectOpen),a=$(y=>y.toggleQuickConnect),n=$(y=>y.savedTunnels),s=$(y=>y.addToast),[o,c]=g.useState(null),[l,d]=g.useState(!1),h=g.useRef(null);if(!e)return null;async function f(y){c(y);try{await $.getState().connectTunnel(y);const k=n.find(O=>O.id===y);k!=null&&k.host&&s("info",`Add ${k.host} to Federation Whitelist?`,"",{label:"Add",onClick:()=>$.getState().addToWhitelist(k.host)}),c(null);return}catch(k){let O=(k==null?void 0:k.message)||"Unknown error";O.toLowerCase().includes("port forward")&&(O+=" — Try testing the connection first, or check your SSH key configuration."),s("error","Connection failed",O)}c(null)}function x(y){var k,O;if((O=(k=window.groove)==null?void 0:k.remote)!=null&&O.openWindow)window.groove.remote.openWindow(y.localPort,y.name);else{const w=encodeURIComponent(y.name);window.open(`http://localhost:${y.localPort}?instance=${w}`,"_blank")}a()}function m(){d(!1),a()}return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-50 bg-black/40 backdrop-blur-sm",onClick:m}),t.jsx(Su,{children:t.jsxs(Hn.div,{initial:{opacity:0,y:-20,scale:.96},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-10,scale:.98},transition:{duration:.15},className:G("fixed top-[15%] left-1/2 -translate-x-1/2 z-50 bg-surface-1 border border-border rounded-lg shadow-2xl overflow-hidden",l?"w-[520px]":"w-[400px]"),children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border-subtle",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[l&&t.jsx("button",{onClick:()=>d(!1),className:"p-1 -ml-1 text-text-4 hover:text-text-1 cursor-pointer transition-colors",children:t.jsx(q1,{size:14})}),t.jsx(Fn,{size:15,className:"text-accent"}),t.jsx("span",{className:"text-sm font-semibold text-text-0 font-sans",children:l?"Add Connection":"Quick Connect"})]}),t.jsx("button",{onClick:m,className:"p-1 text-text-4 hover:text-text-1 cursor-pointer transition-colors",children:t.jsx(Ge,{size:14})})]}),l?t.jsx(vQe,{server:null,onSave:async y=>{const k=y.id||h.current;if(k)await $.getState().updateTunnel(k,y),s("success","Server updated");else{const O=await $.getState().saveTunnel(y);O!=null&&O.id&&(h.current=O.id),s("success","Server added")}},onTest:()=>{const y=h.current;if(y)return $.getState().testTunnel(y)},onConnect:()=>{const y=h.current;if(y)return $.getState().connectTunnel(y)},onCancel:()=>{h.current=null,d(!1)}}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"overflow-y-auto max-h-[320px] py-1",children:n.length===0?t.jsxs("div",{className:"px-4 py-8 text-center",children:[t.jsx(Kt,{size:24,className:"text-text-4 mx-auto mb-2"}),t.jsx("p",{className:"text-sm text-text-3 font-sans",children:"No saved servers"}),t.jsx("p",{className:"text-2xs text-text-4 font-sans mt-1",children:"Add a connection to get started."}),t.jsxs(pe,{variant:"primary",size:"sm",onClick:()=>{h.current=null,d(!0)},className:"h-8 text-xs gap-1.5 mt-3",children:[t.jsx(gt,{size:12})," Add Connection"]})]}):n.map(y=>t.jsxs("div",{className:G("w-full flex items-center gap-3 px-4 py-2.5 transition-colors","hover:bg-surface-5",o===y.id&&"opacity-60 pointer-events-none"),children:[t.jsx(Kt,{size:15,className:y.active?"text-success":"text-text-4"}),t.jsxs("button",{onClick:()=>y.active?x(y):f(y.id),disabled:o===y.id,className:"flex-1 min-w-0 text-left cursor-pointer",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-medium text-text-0 font-sans truncate",children:y.name}),y.active&&t.jsx(aa,{status:"running",size:"sm"}),y.remoteVersion&&t.jsxs("span",{className:"text-2xs font-mono text-text-4 ml-1",children:["v",y.remoteVersion]})]}),t.jsxs("span",{className:"text-2xs text-text-4 font-mono",children:[y.user,"@",y.host]})]}),t.jsx("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:o===y.id?t.jsx(ze,{size:14,className:"text-text-3 animate-spin"}):y.active?t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:()=>x(y),className:"flex items-center gap-1 text-2xs text-success font-sans hover:text-success/80 cursor-pointer transition-colors",children:[t.jsx(ha,{size:11})," Open"]}),y.versionMatch===!1&&t.jsxs("button",{onClick:async()=>{try{await $.getState().upgradeTunnel(y.id),s("success","Upgrade started")}catch(k){s("error","Upgrade failed",k.message)}},className:"flex items-center gap-1 text-2xs text-warning font-sans hover:text-warning/80 cursor-pointer transition-colors",title:`Update remote from v${y.remoteVersion} to v${y.localVersion}`,children:[t.jsx(Ta,{size:11})," Update"]}),t.jsx("button",{onClick:async()=>{await $.getState().disconnectTunnel(y.id),s("info","Disconnected",y.name)},className:"p-1 text-text-4 hover:text-danger cursor-pointer transition-colors rounded",title:"Disconnect",children:t.jsx(Fo,{size:12})}),t.jsx("button",{onClick:k=>{k.stopPropagation(),$.getState().deleteTunnel(y.id)},className:"p-1 text-text-4 hover:text-danger cursor-pointer transition-colors rounded",title:"Delete connection",children:t.jsx(ht,{size:12})})]}):t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>f(y.id),className:"text-2xs text-text-3 font-sans hover:text-text-1 cursor-pointer transition-colors",children:"Connect"}),t.jsx("button",{onClick:k=>{k.stopPropagation(),$.getState().deleteTunnel(y.id)},className:"p-1 text-text-4 hover:text-danger cursor-pointer transition-colors rounded",title:"Delete connection",children:t.jsx(ht,{size:12})})]})})]},y.id))}),t.jsx("div",{className:"px-4 py-2.5 border-t border-border-subtle",children:t.jsxs("button",{onClick:()=>{h.current=null,d(!0)},className:"flex items-center gap-1.5 text-2xs text-accent hover:text-accent/80 font-sans font-medium cursor-pointer transition-colors",children:[t.jsx(gt,{size:10})," Add new connection"]})})]})]})})]})}const vD=[],kQe=/error|crash|fail/i,Tp="rgba(51, 175, 188, 0.15)",$p="h-[2px]";function OQe(e){if(!e||e==="auto")return"auto";const a=e.match(/^claude-(opus|sonnet|haiku)-(\d+)-(\d+)(?:-\d+)?$/);return a?`${a[1][0].toUpperCase()+a[1].slice(1)} ${a[2]}.${a[3]}`:e.startsWith("gemini-")?e.replace("gemini-","Gemini ").replace("-preview","").replace("-flash-lite"," Flash Lite").replace("-flash"," Flash").replace("-pro"," Pro"):e.startsWith("gpt-")?e.toUpperCase().replace("GPT-","GPT-"):e}function bQe(e){if(!e||e.length<2)return null;const a=e.slice(-10),n=(a[a.length-1].t-a[0].t)/6e4;return n<=0?null:(a[a.length-1].v-a[0].v)/n}function wQe(e){return e>=70?"var(--color-success)":e>=40?"var(--color-warning)":"var(--color-danger)"}function jQe(e){return e>=60?"var(--color-success)":e>=30?"var(--color-warning)":"var(--color-danger)"}const CQe={running:"LIVE",starting:"INIT",stopped:"IDLE",crashed:"ERR",completed:"DONE",killed:"KILL",rotating:"ROT"},_G=g.memo(({data:e,selected:a})=>{const{agent:n}=e,s=n.status==="running"||n.status==="starting",o=Math.round((n.contextUsage||0)*100),c=PE(n.status),l=n.tokensUsed||0,d=g.useRef(null),h=$(N=>!!N.expandedNodes[n.id]),f=$(N=>N.toggleNodeExpanded);g.useEffect(()=>{var L;const N=(L=d.current)==null?void 0:L.closest(".react-flow__node");N&&(N.style.zIndex=h?"1000":"")},[h]);const x=$(N=>N.activityLog[n.id])||vD,m=$(N=>N.tokenTimeline[n.id])||vD,y=bQe(m),k=g.useMemo(()=>x.filter(N=>kQe.test(N.text)).length,[x]),O=o>75?"var(--color-danger)":o>50?"var(--color-warning)":"var(--color-success)",w=n.qualityScore!=null?Math.round(n.qualityScore):null,C=w!=null?wQe(w):null,j=n.efficiency!=null?n.efficiency:null,S=j!=null?jQe(j):null,Q=n.durationMs?n.durationMs/1e3:n.spawnedAt?(Date.now()-new Date(n.spawnedAt).getTime())/1e3:n.createdAt?(Date.now()-new Date(n.createdAt).getTime())/1e3:0;return t.jsx("div",{ref:d,children:t.jsxs("div",{className:`w-[220px] overflow-hidden rounded-[4px] transition-all duration-200 ease-out bg-[#1c1f26] hover:bg-[#141720] border border-solid ${a?"border-[#2e323a]":"border-[#262a32]"} hover:border-[#2e3640]`,children:[t.jsx(Oo,{id:"top",type:"target",position:bo.Top,className:"!w-1 !h-1 !bg-transparent !border-0"}),t.jsx(Oo,{id:"bottom",type:"target",position:bo.Bottom,className:"!w-1 !h-1 !bg-transparent !border-0"}),t.jsx(Oo,{id:"left",type:"target",position:bo.Left,className:"!w-1 !h-1 !bg-transparent !border-0"}),t.jsx(Oo,{id:"right",type:"target",position:bo.Right,className:"!w-1 !h-1 !bg-transparent !border-0"}),s&&t.jsx("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",style:{borderRadius:3},children:t.jsx("div",{className:"absolute left-0 right-0 h-px",style:{background:"linear-gradient(90deg, transparent 0%, rgba(97,175,239,0.25) 50%, transparent 100%)",animation:"node-scan 3s ease-in-out infinite"}})}),t.jsxs("div",{className:"px-3 pt-2.5 pb-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{className:"relative flex-shrink-0 w-[6px] h-[6px]",children:[t.jsx("span",{className:"absolute inset-0 rounded-sm",style:{background:c}}),s&&t.jsx("span",{className:"absolute inset-[-2px] rounded-sm",style:{background:c,opacity:.15,animation:"node-pulse-bar 2s ease-in-out infinite"}})]}),t.jsx("span",{className:"text-[12px] font-semibold text-[#e6e6e6] font-sans truncate flex-1 leading-none",children:n.name}),t.jsx("span",{className:"text-[7px] font-mono font-bold uppercase tracking-wider px-1 py-px rounded-sm",style:{color:c,background:c+"12"},children:CQe[n.status]||n.status}),t.jsx("button",{className:"text-[#505862] hover:text-[#8b929e] cursor-pointer transition-colors flex-shrink-0",onClick:N=>{N.stopPropagation(),f(n.id)},children:h?t.jsx(Ge,{size:10}):t.jsx(xd,{size:10})})]}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-1.5",children:[t.jsx("span",{className:"text-[9px] font-mono text-[#505862] uppercase tracking-[0.05em]",children:n.role}),t.jsx("span",{className:"text-[9px] text-[#2a2e36]",children:"/"}),t.jsx("span",{className:"text-[9px] font-mono text-[#505862]",children:OQe(n.model)})]})]}),t.jsxs("div",{className:"px-3 pt-1 pb-2",children:[t.jsxs("div",{className:"flex items-baseline gap-1.5",children:[t.jsx("span",{className:"text-[14px] font-mono font-medium text-[#bcc2cd] leading-none",children:At(l)}),t.jsx("span",{className:"text-[8px] font-mono text-[#505862]",children:"tok"}),t.jsx("span",{className:"flex-1"}),t.jsxs("span",{className:"text-[9px] font-mono text-[#505862]",children:[o,"%"]})]}),t.jsx("div",{className:`mt-1.5 ${$p} rounded-sm overflow-hidden`,style:{background:Tp},children:t.jsx("div",{className:"h-full rounded-sm transition-all duration-700",style:{width:`${Math.max(o,1)}%`,background:o>80?"var(--color-danger)":o>60?"var(--color-warning)":"var(--color-accent)"}})})]}),t.jsx("div",{className:"grid transition-[grid-template-rows] duration-200 ease-out",style:{gridTemplateRows:h?"1fr":"0fr"},children:t.jsxs("div",{className:"overflow-hidden",children:[t.jsx("div",{className:"mx-3 border-t border-white/[0.04]"}),t.jsxs("div",{className:"px-3 pt-1.5 pb-1",children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("span",{className:"text-[9px] font-mono text-[#505862] uppercase tracking-wider",children:"Context"}),(n.rotations||0)>0&&t.jsxs("span",{className:"text-[8px] font-mono text-[#606878] bg-white/[0.04] rounded px-1 py-px",children:[n.rotations,"x rot"]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:`flex-1 ${$p} rounded-sm overflow-hidden`,style:{background:Tp},children:t.jsx("div",{className:"h-full rounded-sm transition-all duration-500",style:{width:`${Math.max(o,1)}%`,background:O}})}),t.jsxs("span",{className:"text-[9px] font-mono font-medium",style:{color:O},children:[o,"%"]})]})]}),t.jsxs("div",{className:"px-3 pt-1 pb-1",children:[t.jsx("span",{className:"text-[9px] font-mono text-[#505862] uppercase tracking-wider",children:"Quality"}),t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[t.jsx("div",{className:`flex-1 ${$p} rounded-sm overflow-hidden`,style:{background:Tp},children:t.jsx("div",{className:"h-full rounded-sm transition-all duration-500",style:{width:`${w!=null?Math.max(w,1):0}%`,background:C||"#505862"}})}),t.jsx("span",{className:"text-[9px] font-mono font-medium",style:{color:C||"#505862"},children:w??"—"})]})]}),t.jsxs("div",{className:"px-3 pt-1 pb-1",children:[t.jsx("span",{className:"text-[9px] font-mono text-[#505862] uppercase tracking-wider",children:"Efficiency"}),t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[t.jsx("div",{className:`flex-1 ${$p} rounded-sm overflow-hidden`,style:{background:Tp},children:t.jsx("div",{className:"h-full rounded-sm transition-all duration-500",style:{width:`${j!=null?Math.max(j,1):0}%`,background:S||"#505862"}})}),t.jsx("span",{className:"text-[9px] font-mono font-medium",style:{color:S||"#505862"},children:j!=null?`${j}%`:"—"})]})]}),t.jsx("div",{className:"px-3 pt-1 pb-1",children:t.jsxs("div",{className:"grid grid-cols-3 gap-1",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-[9px] font-mono font-medium text-[#bcc2cd]",children:Go(n.costUsd||0)}),t.jsx("div",{className:"text-[7px] font-mono text-[#505862]",children:"cost"})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-[9px] font-mono font-medium text-[#bcc2cd]",children:y?At(Math.round(y)):"—"}),t.jsx("div",{className:"text-[7px] font-mono text-[#505862]",children:"tok/m"})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-[9px] font-mono font-medium text-[#bcc2cd]",children:n.turns||0}),t.jsx("div",{className:"text-[7px] font-mono text-[#505862]",children:"turns"})]})]})}),t.jsx("div",{className:"px-3 pt-1 pb-2",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"text-[9px] font-mono text-[#8b929e]",children:Ud(Math.max(0,Math.floor(Q)))}),t.jsx("span",{className:"text-[7px] font-mono text-[#505862]",children:"up"})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[k>0?t.jsx("span",{className:"text-[9px] font-mono text-[var(--color-danger)]",children:k}):t.jsx("span",{className:"text-[9px] font-mono text-[#505862]",children:"0"}),t.jsx("span",{className:"text-[7px] font-mono text-[#505862]",children:"err"})]})]})})]})})]})})});_G.displayName="AgentNode";const LG=g.memo(({data:e})=>{const{agentCount:a,runningCount:n}=e,s=n>0,o={background:"transparent",border:0,width:2,height:2};return t.jsxs("div",{className:"relative flex items-center justify-center",style:{width:84,height:84},children:[t.jsx("div",{className:G("absolute inset-0 rounded-full transition-all duration-500",s&&"animate-[spin-slow_30s_linear_infinite]"),style:{border:`1px dashed ${s?"rgba(97,175,239,0.5)":"rgba(97,175,239,0.25)"}`}}),t.jsx("div",{className:"absolute inset-[10px] rounded-full",style:{background:s?"radial-gradient(circle, rgba(97,175,239,0.15) 0%, transparent 70%)":"radial-gradient(circle, rgba(97,175,239,0.05) 0%, transparent 70%)",animation:s?"node-pulse-bar 2.5s ease-in-out infinite":"none"}}),t.jsx("div",{className:G("w-14 h-14 rounded-full flex items-center justify-center relative z-10 transition-all duration-300",s?"bg-[#1c1f26] border-2 border-[#61afef]/35 shadow-[0_0_28px_rgba(97,175,239,0.15)]":"bg-[#1c1f26] border border-[#61afef]/20"),children:t.jsx("img",{src:"/favicon.png",alt:"G",className:G("h-7 w-7 rounded-full transition-opacity",s?"opacity-90":"opacity-60")})}),a>0&&t.jsx("div",{className:G("absolute z-20 min-w-[20px] h-[20px] rounded-sm flex items-center justify-center","text-[10px] font-mono font-bold px-1 transition-all duration-300",s?"bg-[#1c1f26] text-[#61afef] border border-[#61afef]/40":"bg-[#1c1f26] text-[#61afef]/60 border border-[#61afef]/20"),style:{bottom:2,right:2},children:a}),t.jsx(Oo,{id:"bottom",type:"source",position:bo.Bottom,style:o}),t.jsx(Oo,{id:"right",type:"source",position:bo.Right,style:o}),t.jsx(Oo,{id:"left",type:"source",position:bo.Left,style:o}),t.jsx(Oo,{id:"top",type:"source",position:bo.Top,style:o})]})});LG.displayName="RootNode";const MQe=[{id:"desktop",icon:Cr,label:"Desktop",width:"100%"},{id:"tablet",icon:j0,label:"Tablet (768px)",width:"768px"},{id:"mobile",icon:w0,label:"Mobile (375px)",width:"375px"}];function SQe({onRefresh:e}){const a=$(x=>x.previewState),n=$(x=>x.setPreviewDevice),s=$(x=>x.toggleScreenshotMode),o=$(x=>x.closePreview),[c,l]=g.useState(!1),d=g.useRef(null);g.useEffect(()=>()=>{d.current&&clearTimeout(d.current)},[]);function h(){c?(d.current&&clearTimeout(d.current),l(!1),o()):(l(!0),d.current=setTimeout(()=>l(!1),2e3))}const f=a.teamId?`${window.location.origin}/api/preview/${a.teamId}/proxy/`:a.url;return t.jsxs("div",{className:"h-10 flex items-center gap-2 px-3 bg-surface-3 border-b border-border flex-shrink-0",children:[t.jsx("div",{className:"flex-1 min-w-0 h-7 flex items-center px-3 rounded-md bg-surface-1 border border-border-subtle",children:t.jsx("span",{className:"text-2xs font-mono text-text-3 truncate",children:f||"No URL"})}),t.jsx("button",{onClick:e,className:"w-7 h-7 flex items-center justify-center rounded-md text-text-3 hover:text-accent hover:bg-accent/10 transition-colors cursor-pointer",title:"Refresh",children:t.jsx(ca,{size:14})}),t.jsx("div",{className:"flex items-center gap-0.5 px-1 py-0.5 rounded-md bg-surface-1 border border-border-subtle",children:MQe.map(x=>t.jsx("button",{onClick:()=>n(x.id),className:G("w-7 h-6 flex items-center justify-center rounded transition-colors cursor-pointer",a.deviceSize===x.id?"text-accent bg-accent/10":"text-text-3 hover:text-text-1"),title:x.label,children:t.jsx(x.icon,{size:13})},x.id))}),t.jsx("button",{onClick:s,className:G("w-7 h-7 flex items-center justify-center rounded-md transition-colors cursor-pointer",a.screenshotMode?"text-accent bg-accent/10":"text-text-3 hover:text-accent hover:bg-accent/10"),title:"Screenshot",children:t.jsx(Z1,{size:14})}),t.jsx("button",{onClick:h,className:G("h-7 flex items-center justify-center rounded-md transition-all cursor-pointer",c?"px-2 gap-1.5 bg-danger/15 text-danger border border-danger/25":"w-7 text-text-3 hover:text-danger hover:bg-danger/10"),title:"Close Preview",children:c?t.jsx("span",{className:"text-2xs font-semibold font-sans whitespace-nowrap",children:"Close?"}):t.jsx(Ge,{size:14})})]})}/*!
|
|
8614
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${a.docsSlug}`;return g.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},iQe="DialogDescriptionWarning",cQe=({contentRef:e,descriptionId:a})=>{const s=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${wG(iQe).contentName}}.`;return g.useEffect(()=>{var c;const o=(c=e.current)==null?void 0:c.getAttribute("aria-describedby");a&&o&&(document.getElementById(a)||console.warn(s))},[s,e,a]),null},jG=AG,lQe=uG,CG=pG,MG=fG,SG=xG,yT=gG,NG=vG,qE=OG;function Rt({children:e,...a}){return t.jsx(jG,{...a,children:e})}const QG=lQe;function Ht({children:e,className:a,title:n,description:s,...o}){return t.jsxs(CG,{children:[t.jsx(MG,{className:"fixed inset-0 z-50 bg-black/50 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"}),t.jsxs(SG,{className:G("fixed left-1/2 top-1/2 z-50 -translate-x-1/2 -translate-y-1/2","w-full max-w-lg max-h-[85vh] overflow-y-auto","bg-surface-1 border border-border rounded-lg shadow-2xl","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",a),...o,children:[n&&t.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-border-subtle",children:[t.jsx(yT,{className:"text-base font-semibold text-text-0 font-sans",children:n}),t.jsx(qE,{className:"p-1 rounded-md text-text-3 hover:text-text-0 hover:bg-surface-5 transition-colors",children:t.jsx(Ge,{size:16})})]}),s&&t.jsx(NG,{className:"sr-only",children:s}),e]})]})}const AQe={primary:"bg-accent/20 text-accent border border-accent/25 hover:bg-accent/30 font-medium",secondary:"bg-surface-5/40 text-text-1 border border-border-subtle hover:bg-surface-5/70 hover:text-text-0",ghost:"bg-transparent text-text-2 border border-transparent hover:bg-surface-5/50 hover:text-text-0",danger:"bg-danger/12 text-danger border border-danger/15 hover:bg-danger/20",info:"bg-info/12 text-info border border-info/15 hover:bg-info/20",outline:"bg-transparent text-accent border border-accent/30 hover:bg-accent/10"},dQe={sm:"h-7 px-2.5 text-xs gap-1.5 rounded",md:"h-8 px-3 text-sm gap-2 rounded",lg:"h-9 px-4 text-sm gap-2 rounded",icon:"h-8 w-8 rounded"},pe=g.forwardRef(({className:e,variant:a="secondary",size:n="md",children:s,...o},c)=>t.jsx("button",{ref:c,className:G("inline-flex items-center justify-center font-sans transition-colors duration-100","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent","disabled:opacity-40 disabled:pointer-events-none","cursor-pointer select-none",AQe[a],dQe[n],e),...o,children:s}));pe.displayName="Button";function uQe(){const e=$(h=>h.updateModalOpen),a=$(h=>h.setUpdateModalOpen),n=$(h=>h.version),s=$(h=>h.updateReady),o=$(h=>h.updateProgress),c=$(h=>h.installUpdate),l=o&&!s,d=l?Math.max(0,Math.min(100,o.percent||0)):100;return t.jsx(Rt,{open:e,onOpenChange:a,children:t.jsxs(Ht,{title:"Update Available",description:"Desktop app update",children:[t.jsxs("div",{className:"px-5 py-4 flex flex-col gap-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"flex items-center justify-center w-10 h-10 rounded-lg bg-accent/12",children:t.jsx(Ta,{size:20,className:"text-accent"})}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-text-1 font-sans font-medium",children:l?"Downloading update…":"Ready to update"}),t.jsxs("p",{className:"text-xs text-text-3 font-sans mt-0.5",children:[n&&t.jsx("span",{className:"font-mono",children:n}),n&&s&&" → ",s&&t.jsx("span",{className:"font-mono text-accent",children:s})]})]})]}),l&&t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[t.jsx(ze,{size:12,className:"animate-spin text-accent flex-shrink-0"}),t.jsx("div",{className:"flex-1 h-1.5 rounded-full bg-surface-3 overflow-hidden",children:t.jsx("div",{className:"h-full rounded-full bg-accent transition-all duration-500 ease-out",style:{width:`${d}%`}})}),t.jsxs("span",{className:"text-2xs font-mono text-text-3 tabular-nums",children:[d,"%"]})]}),!l&&t.jsx("p",{className:"text-xs text-text-3 font-sans leading-relaxed",children:"The app will restart to apply the update. Your work is saved automatically."})]}),t.jsxs("div",{className:"flex items-center justify-end gap-2 px-5 py-3 border-t border-border-subtle bg-surface-0",children:[t.jsx(pe,{variant:"ghost",size:"sm",onClick:()=>a(!1),children:"Later"}),t.jsxs(pe,{variant:"primary",size:"sm",disabled:l,onClick:()=>{c(),a(!1)},children:[t.jsx(Ta,{size:12}),"Update & Restart"]})]})]})})}function hQe({connected:e,agentCount:a,runningCount:n,uptime:s,terminalVisible:o,onToggleTerminal:c}){const l=$(w=>w.savedTunnels),d=$(w=>w.tunneled),h=$(w=>w.version),f=$(w=>w.updateReady),x=$(w=>w.updateProgress),m=$(w=>w.setUpdateModalOpen),y=$(w=>w.setActiveView),k=l.filter(w=>w.active),O=K0();return t.jsxs("footer",{className:"h-6 flex-shrink-0 flex items-center px-3 bg-surface-3 border-t border-border text-2xs font-sans select-none",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(aa,{status:e?"running":"crashed",size:"sm"}),t.jsx("span",{className:e?"text-text-2":"text-danger",children:e?O?"Desktop":"Connected":"Offline"})]}),O&&e&&t.jsxs("button",{onClick:()=>gP(window.location.href),className:"flex items-center gap-1 text-text-4 hover:text-text-1 cursor-pointer transition-colors",title:"Open this workspace in your browser",children:[t.jsx(ea,{size:10}),t.jsx("span",{children:"Browser"})]}),e&&s>0&&t.jsxs("span",{className:"text-text-4",children:["Up ",Ud(s)]}),e&&a>0&&t.jsxs("span",{className:"text-text-4",children:[n,"/",a," agents"]}),d?t.jsxs("button",{onClick:()=>{var w,C,j;return((j=(C=(w=window.groove)==null?void 0:w.remote)==null?void 0:C.close)==null?void 0:j.call(C))||window.close()},className:"flex items-center gap-1.5 text-text-3 hover:text-danger cursor-pointer transition-colors",title:"Close remote connection",children:[t.jsx(Fo,{size:10}),t.jsx("span",{children:"Disconnect"})]}):t.jsxs(t.Fragment,{children:[k.map(w=>t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsxs("button",{onClick:()=>{const C=w.localPort,j=encodeURIComponent(w.name);gP(`http://localhost:${C}?instance=${j}`)},className:"flex items-center gap-1.5 text-text-3 hover:text-text-1 cursor-pointer transition-colors",title:"Open remote GUI",children:[t.jsx(Fn,{size:10,className:"text-success"}),t.jsx("span",{children:w.name}),t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-success"}),w.latencyMs!=null&&t.jsxs("span",{className:"text-text-4",children:[w.latencyMs,"ms"]})]}),t.jsx("button",{onClick:()=>$.getState().disconnectTunnel(w.id),className:"p-0.5 text-text-4 hover:text-danger cursor-pointer transition-colors rounded",title:"Disconnect",children:t.jsx(Ge,{size:10})})]},w.id)),t.jsxs("button",{onClick:()=>$.getState().toggleQuickConnect(),className:"flex items-center gap-1.5 text-text-4 hover:text-text-1 cursor-pointer transition-colors",title:"Quick Connect to remote server",children:[t.jsx(ra,{size:10}),t.jsx("span",{children:"Connect"})]})]}),e&&t.jsxs("button",{onClick:()=>y("federation"),className:"flex items-center gap-1.5 text-text-4 hover:text-text-1 cursor-pointer transition-colors",title:"Federation",children:[t.jsx(ea,{size:10}),t.jsx("span",{children:"Federation"})]})]}),t.jsx("div",{className:"flex-1"}),f||x?t.jsx("button",{onClick:()=>m(!0),className:"flex items-center gap-1 px-2 h-full cursor-pointer",title:f?`Update to v${f}`:"Downloading update…",children:t.jsxs(we,{variant:"warning",className:"cursor-pointer",children:[t.jsx(Ta,{size:10}),f?"Update Available":"Downloading…"]})}):h?t.jsxs("span",{className:"text-text-4 px-2",children:["v",h]}):null,!O&&t.jsxs("a",{href:"https://docs.groovedev.ai",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 px-2 h-full text-text-3 hover:text-text-1 hover:bg-surface-5 transition-colors no-underline",children:[t.jsx(_o,{size:12}),t.jsx("span",{children:"Docs"})]}),t.jsxs("button",{onClick:c,className:G("flex items-center gap-1.5 px-2 h-full transition-colors cursor-pointer",o?"text-accent bg-accent/8 hover:bg-accent/12":"text-text-3 hover:text-text-1 hover:bg-surface-5"),children:[t.jsx(cs,{size:12}),t.jsx("span",{children:"Terminal"}),t.jsx("kbd",{className:"font-mono text-text-4 ml-0.5",children:"Cmd+J"})]}),t.jsx(uQe,{})]})}function pQe({children:e,width:a,onWidthChange:n,onClose:s,className:o}){const c=g.useRef(!1),l=g.useRef(0),d=g.useRef(0),h=g.useCallback(f=>{f.preventDefault(),c.current=!0,l.current=f.clientX,d.current=a;function x(y){if(!c.current)return;const k=l.current-y.clientX,O=Math.min(Math.max(d.current+k,380),window.innerWidth*.65);n(O)}function m(){c.current=!1,document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",m)}document.addEventListener("mousemove",x),document.addEventListener("mouseup",m)},[a,n]);return t.jsxs("aside",{className:G("flex-shrink-0 flex bg-surface-1 border-l border-border relative",o),style:{width:a},children:[t.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1 cursor-col-resize hover:bg-accent/30 transition-colors z-10",onMouseDown:h}),t.jsx("button",{onClick:s,className:"absolute top-3 right-3 z-10 p-1 rounded-md text-text-3 hover:text-text-0 hover:bg-surface-5 transition-colors cursor-pointer",children:t.jsx(Ge,{size:14})}),t.jsx("div",{className:"flex-1 overflow-y-auto overflow-x-hidden",children:e})]})}const fQe=[{id:"nav:agents",label:"Go to Agents",icon:ru,category:"Navigation",action:e=>{e.setActiveView("agents")}},{id:"nav:editor",label:"Go to Editor",icon:Ft,category:"Navigation",action:e=>{e.setActiveView("editor")}},{id:"nav:dashboard",label:"Go to Dashboard",icon:G1,category:"Navigation",action:e=>{e.setActiveView("dashboard")}},{id:"nav:marketplace",label:"Go to Marketplace",icon:Au,category:"Navigation",action:e=>{e.setActiveView("marketplace")}},{id:"nav:teams",label:"Go to Teams",icon:Ba,category:"Navigation",action:e=>{e.setActiveView("teams")}},{id:"nav:federation",label:"Go to Federation",icon:ea,category:"Navigation",action:e=>{e.setActiveView("federation")}},{id:"action:whitelist",label:"Add to Federation Whitelist",icon:wa,category:"Federation",action:e=>{e.setActiveView("federation")}},{id:"action:spawn",label:"Spawn Agent",icon:gt,category:"Actions",action:e=>{e.openDetail({type:"spawn"})}},{id:"action:terminal",label:"Toggle Terminal",icon:cs,category:"Actions",action:e=>{e.setTerminalVisible(!e.terminalVisible)},shortcut:"Cmd+J"},{id:"action:journalist",label:"Toggle Journalist",icon:Uo,category:"Actions",action:e=>{var a;((a=e.detailPanel)==null?void 0:a.type)==="journalist"?e.closeDetail():e.openDetail({type:"journalist"})}}];function xQe(){const e=$(O=>O.commandPaletteOpen),a=$(O=>O.toggleCommandPalette),n=$(O=>O.agents),s=$(O=>O.savedTunnels),o=$,[c,l]=g.useState(""),[d,h]=g.useState(0),f=g.useRef(null),x=g.useMemo(()=>{var j;const O=n.flatMap(S=>[{id:`chat:${S.id}`,label:`Chat with ${S.name}`,icon:mn,category:"Agents",action:Q=>{Q.selectAgent(S.id)}},...S.status==="running"?[{id:`rotate:${S.id}`,label:`Rotate ${S.name}`,icon:Sr,category:"Agents",action:Q=>{Q.rotateAgent(S.id)}},{id:`kill:${S.id}`,label:`Kill ${S.name}`,icon:vd,category:"Agents",action:Q=>{Q.killAgent(S.id)}}]:[]]),w=[{id:"action:quickconnect",label:"Quick Connect",icon:Fn,category:"Remote",action:S=>{S.toggleQuickConnect()}},...s.map(S=>S.active?{id:`tunnel:open:${S.id}`,label:`Open ${S.name}`,icon:ha,category:"Remote",action:()=>{window.open(`http://localhost:${S.localPort}?instance=${encodeURIComponent(S.name)}`,"_blank")}}:{id:`tunnel:connect:${S.id}`,label:`Connect to ${S.name}`,icon:Fn,category:"Remote",action:Q=>{Q.connectTunnel(S.id)}})],C=(j=window.groove)!=null&&j.openFolder?[{id:"action:openfolder",label:"Open Folder",icon:pa,category:"Window",shortcut:"Cmd+O",action:()=>window.groove.openFolder()}]:[];return[...fQe,...C,...O,...w]},[n,s]),m=g.useMemo(()=>{if(!c.trim())return x.slice(0,12);const O=c.toLowerCase();return x.filter(w=>w.label.toLowerCase().includes(O)||w.category.toLowerCase().includes(O)).slice(0,12)},[x,c]);g.useEffect(()=>{e&&(l(""),h(0),setTimeout(()=>{var O;return(O=f.current)==null?void 0:O.focus()},50))},[e]),g.useEffect(()=>{d>=m.length&&h(Math.max(0,m.length-1))},[m.length,d]);function y(O){O.action(o.getState()),a()}function k(O){O.key==="ArrowDown"?(O.preventDefault(),h(w=>Math.min(w+1,m.length-1))):O.key==="ArrowUp"?(O.preventDefault(),h(w=>Math.max(w-1,0))):O.key==="Enter"&&m[d]?(O.preventDefault(),y(m[d])):O.key==="Escape"&&a()}return e?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-50 bg-black/40 backdrop-blur-sm",onClick:a}),t.jsx(Su,{children:t.jsxs(Hn.div,{initial:{opacity:0,y:-20,scale:.96},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-10,scale:.98},transition:{duration:.15},className:"fixed top-[15%] left-1/2 -translate-x-1/2 z-50 w-[480px] max-h-[400px] bg-surface-1 border border-border rounded-lg shadow-2xl overflow-hidden",onKeyDown:k,children:[t.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border-subtle",children:[t.jsx(ta,{size:16,className:"text-text-3 flex-shrink-0"}),t.jsx("input",{ref:f,value:c,onChange:O=>{l(O.target.value),h(0)},placeholder:"Type a command...",className:"flex-1 bg-transparent text-xs text-text-0 font-sans placeholder:text-text-4 focus:outline-none"})]}),t.jsxs("div",{className:"overflow-y-auto max-h-[320px] py-1",children:[m.length===0&&t.jsx("div",{className:"px-4 py-6 text-sm text-text-3 text-center font-sans",children:"No results"}),m.map((O,w)=>t.jsxs("button",{onClick:()=>y(O),onMouseEnter:()=>h(w),className:G("w-full flex items-center gap-3 px-4 py-2 text-sm font-sans cursor-pointer",w===d?"bg-surface-5 text-text-0":"text-text-1 hover:bg-surface-4"),children:[t.jsx(O.icon,{size:16,className:"text-text-3 flex-shrink-0"}),t.jsx("span",{className:"flex-1 text-left",children:O.label}),t.jsx("span",{className:"text-2xs text-text-4",children:O.category}),O.shortcut&&t.jsx("kbd",{className:"text-2xs font-mono bg-surface-4 px-1 py-0.5 rounded text-text-3 ml-1",children:O.shortcut})]},O.id))]})]})})]}):null}function mQe(){const e=$(s=>s.pendingApprovals),a=$(s=>s.approveRequest),n=$(s=>s.rejectRequest);return e!=null&&e.length?t.jsx("div",{className:"fixed bottom-10 left-1/2 -translate-x-1/2 z-50 w-full max-w-md flex flex-col gap-2 px-4",children:t.jsx(Su,{children:e.map(s=>{var o;return t.jsxs(Hn.div,{initial:{y:20,opacity:0},animate:{y:0,opacity:1},exit:{y:20,opacity:0},transition:{duration:.2},className:"rounded-lg border border-accent/30 bg-surface-2/95 backdrop-blur-md shadow-xl shadow-accent/5 overflow-hidden",children:[t.jsxs("div",{className:"px-4 py-3 flex items-start gap-3",children:[t.jsx(oa,{size:16,className:"text-warning shrink-0 mt-0.5"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("p",{className:"text-sm font-semibold text-text-0 font-sans truncate",children:[s.agentName||"Agent"," needs approval"]}),((o=s.action)==null?void 0:o.description)&&t.jsx("p",{className:"text-2xs text-text-3 font-sans mt-0.5 line-clamp-2",children:s.action.description})]})]}),t.jsxs("div",{className:"px-4 py-2.5 border-t border-border-subtle flex items-center justify-end gap-2",children:[t.jsxs(pe,{size:"sm",variant:"ghost",className:"text-danger hover:bg-danger/10",onClick:()=>n(s.id),children:[t.jsx(vr,{size:14,className:"mr-1"}),"Reject"]}),t.jsxs(pe,{size:"sm",variant:"accent",onClick:()=>a(s.id),children:[t.jsx(du,{size:14,className:"mr-1"}),"Approve"]})]})]},s.id)})})}):null}function gQe({path:e,onNavigate:a}){const n=e.split("/").filter(Boolean);return t.jsxs("div",{className:"flex items-center gap-0.5 min-w-0 overflow-x-auto py-1.5 scrollbar-none",children:[t.jsx("button",{onClick:()=>a("/"),className:"flex-shrink-0 p-1 rounded hover:bg-surface-5 cursor-pointer text-text-3 hover:text-text-0 transition-colors",children:t.jsx(jr,{size:13})}),n.map((s,o)=>{const c="/"+n.slice(0,o+1).join("/"),l=o===n.length-1;return t.jsxs("div",{className:"flex items-center gap-0.5 flex-shrink-0",children:[t.jsx(Yt,{size:11,className:"text-text-4"}),t.jsx("button",{onClick:()=>a(c),className:G("px-1.5 py-0.5 rounded text-xs font-mono cursor-pointer transition-colors",l?"text-text-0 bg-surface-4 font-medium":"text-text-3 hover:text-text-0 hover:bg-surface-5"),children:s})]},o)})]})}function Lu({open:e,onOpenChange:a,currentPath:n,onSelect:s,homePath:o,mandatory:c=!1,title:l}){const d=o||"/home",[h,f]=g.useState(n||d),[x,m]=g.useState([]),[y,k]=g.useState(!1),[O,w]=g.useState(null);g.useEffect(()=>{e&&C(n||d)},[e]);async function C(B){k(!0),w(null);try{const M=await D.get(`/browse-system?path=${encodeURIComponent(B)}`);f(M.current||B),m(M.dirs||[])}catch(M){w(M.message),m([])}k(!1)}function j(){const B=h==="/"?"/":h.split("/").slice(0,-1).join("/")||"/";C(B)}function S(){C(d)}function Q(){s(h),c||a(!1)}const N=l||(c?"Select Project Directory":"Select Working Directory"),L=c?{onEscapeKeyDown:B=>B.preventDefault(),onInteractOutside:B=>B.preventDefault(),onPointerDownOutside:B=>B.preventDefault()}:{};return t.jsx(Rt,{open:e,onOpenChange:c?()=>{}:a,children:t.jsxs(Ht,{title:c?void 0:N,description:"Choose a directory for this agent to work in",className:"max-w-[520px]",...L,children:[c&&t.jsxs("div",{className:"px-5 py-4 border-b border-border-subtle",children:[t.jsx("div",{className:"text-base font-semibold text-text-0 font-sans",children:N}),t.jsx("div",{className:"text-xs text-text-3 font-sans mt-1",children:"Pick a directory on this remote machine to get started."})]}),t.jsxs("div",{className:"px-5 py-4 space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:j,disabled:h==="/",className:"p-1.5 rounded-md bg-surface-4 border border-border text-text-2 hover:text-text-0 hover:bg-surface-5 transition-colors cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed",children:t.jsx(D1,{size:14})}),t.jsx("button",{onClick:S,className:"p-1.5 rounded-md bg-surface-4 border border-border text-text-2 hover:text-text-0 hover:bg-surface-5 transition-colors cursor-pointer",children:t.jsx(mo,{size:14})}),t.jsx("div",{className:"flex-1 min-w-0 bg-surface-0 rounded-md border border-border-subtle px-2",children:t.jsx(gQe,{path:h,onNavigate:C})})]}),t.jsx("div",{className:"bg-surface-0 rounded-lg border border-border-subtle overflow-hidden",children:t.jsxs("div",{className:"max-h-[340px] overflow-y-auto",children:[y&&t.jsx("div",{className:"flex items-center justify-center py-8",children:t.jsx(ze,{size:18,className:"text-text-3 animate-spin"})}),O&&t.jsx("div",{className:"px-4 py-6 text-center",children:t.jsx("p",{className:"text-xs text-danger font-sans",children:O})}),!y&&!O&&x.length===0&&t.jsx("div",{className:"px-4 py-6 text-center",children:t.jsx("p",{className:"text-xs text-text-3 font-sans",children:"No subdirectories"})}),!y&&!O&&x.map(B=>t.jsxs("button",{onClick:()=>C(B.path),className:G("w-full flex items-center gap-2.5 px-3.5 py-2 text-left cursor-pointer","hover:bg-surface-4 transition-colors border-b border-border-subtle last:border-0"),children:[B.hasChildren?t.jsx(r0,{size:15,className:"text-warning flex-shrink-0"}):t.jsx(pa,{size:15,className:"text-text-3 flex-shrink-0"}),t.jsx("span",{className:"text-sm text-text-0 font-sans truncate flex-1",children:B.name}),B.hasChildren&&t.jsx(Yt,{size:12,className:"text-text-4 flex-shrink-0"})]},B.path))]})}),t.jsxs("div",{className:"flex items-center gap-3 bg-surface-4/50 rounded-lg px-3.5 py-2.5 border border-border-subtle",children:[t.jsx(pa,{size:16,className:"text-accent flex-shrink-0"}),t.jsx("span",{className:"text-xs font-mono text-text-1 truncate flex-1",children:h})]}),t.jsxs("div",{className:"flex justify-end gap-2",children:[!c&&t.jsx(pe,{variant:"ghost",size:"md",onClick:()=>a(!1),children:"Cancel"}),t.jsxs(pe,{variant:"primary",size:"md",onClick:Q,className:"gap-1.5",children:[t.jsx(Re,{size:14})," Select Folder"]})]})]})]})})}const gD=[{id:"details",label:"Server Details",icon:Kt},{id:"auth",label:"Authentication",icon:nu},{id:"setup",label:"Setup",icon:Nr},{id:"connected",label:"Connected",icon:ra}];function yQe({steps:e,currentStep:a,completedSteps:n,onStepClick:s}){return t.jsx("div",{className:"flex items-center gap-1 mb-4",children:e.map((o,c)=>{const l=a===c,d=n.includes(c),h=d||c<a;return o.icon,t.jsxs("div",{className:"flex items-center gap-1 flex-1",children:[t.jsxs("button",{onClick:()=>h&&s(c),disabled:!h,className:G("flex items-center gap-1.5 px-2 py-1 rounded-md transition-colors text-2xs font-sans font-medium",l?"bg-accent/12 text-accent":d?"text-success cursor-pointer hover:bg-surface-3":"text-text-4",h&&!l&&"cursor-pointer"),children:[t.jsx("div",{className:G("w-5 h-5 rounded-full flex items-center justify-center text-2xs font-semibold border transition-colors",l?"border-accent bg-accent/15 text-accent":d?"border-success/40 bg-success/10 text-success":"border-border-subtle bg-surface-3 text-text-4"),children:d?t.jsx(Re,{size:10}):c+1}),t.jsx("span",{className:"hidden sm:inline",children:o.label})]}),c<e.length-1&&t.jsx("div",{className:G("flex-1 h-px mx-1",d?"bg-success/30":"bg-border-subtle")})]},o.id)})})}function yD({value:e,onChange:a}){return t.jsx("button",{onClick:()=>a(!e),className:G("w-9 h-5 rounded-full p-0.5 transition-colors cursor-pointer",e?"bg-accent":"bg-surface-5"),children:t.jsx("div",{className:G("w-4 h-4 rounded-full bg-white shadow-sm transition-transform",e?"translate-x-4":"translate-x-0")})})}function Lp({icon:e,title:a,children:n}){return t.jsxs("div",{className:"rounded-lg border border-border-subtle bg-surface-1 px-4 py-3.5 flex flex-col gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-6 h-6 rounded bg-accent/8 flex items-center justify-center flex-shrink-0",children:t.jsx(e,{size:12,className:"text-accent"})}),t.jsx("span",{className:"text-[13px] font-medium text-text-0 font-sans leading-tight",children:a})]}),t.jsx("div",{className:"mt-1",children:n})]})}function vQe({server:e,onSave:a,onTest:n,onConnect:s,onCancel:o}){const c=$(Ae=>Ae.remoteHomedir),[l,d]=g.useState(0),[h,f]=g.useState([]),[x,m]=g.useState(""),[y,k]=g.useState(""),[O,w]=g.useState(""),[C,j]=g.useState(22),[S,Q]=g.useState(""),[N,L]=g.useState(!1),[B,M]=g.useState(!1),[I,F]=g.useState(!1),[E,V]=g.useState(!1),[Z,X]=g.useState(null),[q,H]=g.useState(!1),[T,R]=g.useState(!1);g.useEffect(()=>{e?(m(e.name||""),k(e.host||""),w(e.user||""),j(e.port||22),Q(e.sshKeyPath||""),L(e.autoStart||!1),M(e.autoConnect||!1),f([0,1]),d(2)):(m(""),k(""),w(""),j(22),Q(""),L(!1),M(!1),f([]),d(0))},[e]);function U(){const Ae={name:x.trim(),host:y.trim(),user:O.trim(),port:C,sshKeyPath:S.trim(),autoStart:N,autoConnect:B};return e!=null&&e.id&&(Ae.id=e.id),Ae}function z(){return x.trim()&&y.trim()&&O.trim()}function Y(){l===0&&!z()||(f(Ae=>Ae.includes(l)?Ae:[...Ae,l]),d(Ae=>Math.min(Ae+1,gD.length-1)))}function ue(){d(Ae=>Math.max(Ae-1,0))}async function W(){V(!0),X(null);try{const Ae=U();H(!0),await a(Ae),H(!1);const Qe=await n();X(Qe)}catch(Ae){X({error:Ae.message||"Test failed"}),H(!1)}V(!1)}async function re(){H(!0);try{const Ae=U();await a(Ae),f(Qe=>Qe.includes(l)?Qe:[...Qe,l]),d(2)}catch(Ae){X({error:Ae.message||"Save failed"})}H(!1)}async function xe(){var Ae;R(!0);try{const Qe=U();await a(Qe),await s(),f(ee=>[...new Set([...ee,2])]),d(3)}catch(Qe){let ee=((Ae=Qe==null?void 0:Qe.body)==null?void 0:Ae.error)||(Qe==null?void 0:Qe.message)||"Connection failed";ee.toLowerCase().includes("port forward")&&(ee+=" — Check that the remote server is reachable and SSH port forwarding is allowed."),X({error:ee})}R(!1)}const ve="h-8 px-2.5 text-xs bg-surface-0 border border-border-subtle rounded-md text-text-0 font-sans placeholder:text-text-4 focus:outline-none focus:ring-1 focus:ring-accent",ie="h-8 px-2.5 text-xs bg-surface-0 border border-border-subtle rounded-md text-text-0 font-mono placeholder:text-text-4 focus:outline-none focus:ring-1 focus:ring-accent";return t.jsxs("div",{className:"p-4",children:[t.jsx(yQe,{steps:gD,currentStep:l,completedSteps:h,onStepClick:d}),l===0&&t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsx(Lp,{icon:Kt,title:"Server Info",children:t.jsxs("div",{className:"space-y-2.5",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-2xs font-semibold text-text-2 font-sans mb-1 block",children:"Name"}),t.jsx("input",{value:x,onChange:Ae=>m(Ae.target.value),placeholder:"api-vps",className:G(ve,"w-full"),autoFocus:!0})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-2xs font-semibold text-text-2 font-sans mb-1 block",children:"Host"}),t.jsx("input",{value:y,onChange:Ae=>k(Ae.target.value),placeholder:"165.22.180.45",className:G(ie,"w-full")})]})]})}),t.jsx(Lp,{icon:Nr,title:"Connection",children:t.jsxs("div",{className:"space-y-2.5",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-2xs font-semibold text-text-2 font-sans mb-1 block",children:"User"}),t.jsx("input",{value:O,onChange:Ae=>w(Ae.target.value),placeholder:"root",className:G(ie,"w-full")})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-2xs font-semibold text-text-2 font-sans mb-1 block",children:"SSH Port"}),t.jsx("input",{value:C,onChange:Ae=>j(Number(Ae.target.value)||22),type:"number",className:G(ie,"w-24")})]})]})})]}),l===1&&t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsx(Lp,{icon:nu,title:"SSH Key",children:t.jsxs("div",{className:"space-y-2.5",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-2xs font-semibold text-text-2 font-sans mb-1 block",children:"Key Path"}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("input",{value:S,onChange:Ae=>Q(Ae.target.value),placeholder:"~/.ssh/id_ed25519",className:G(ie,"flex-1 min-w-0"),autoFocus:!0}),t.jsx(pe,{variant:"secondary",size:"sm",onClick:()=>F(!0),className:"h-8 px-2 flex-shrink-0",children:t.jsx(pd,{size:12})})]}),t.jsx("p",{className:"text-2xs text-text-4 font-sans mt-1",children:"Leave blank to use default SSH agent."})]}),t.jsxs(pe,{variant:"secondary",size:"sm",onClick:W,disabled:E,className:"h-7 text-2xs gap-1.5",children:[E?t.jsx(ze,{size:11,className:"animate-spin"}):t.jsx(ra,{size:11}),"Test Connection"]})]})}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"rounded-lg border border-border-subtle bg-surface-1 px-4 py-3.5",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("div",{className:"w-6 h-6 rounded bg-accent/8 flex items-center justify-center flex-shrink-0",children:t.jsx(Kt,{size:12,className:"text-accent"})}),t.jsx("span",{className:"text-[13px] font-medium text-text-0 font-sans",children:"Target"})]}),t.jsxs("div",{className:"space-y-1.5 text-2xs font-sans",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-text-3",children:"Host"}),t.jsx("span",{className:"text-text-1 font-mono",children:y||"—"})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-text-3",children:"User"}),t.jsx("span",{className:"text-text-1 font-mono",children:O||"—"})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-text-3",children:"Port"}),t.jsx("span",{className:"text-text-1 font-mono",children:C})]})]})]}),Z&&t.jsx("div",{className:G("px-3 py-2.5 rounded-lg text-2xs font-sans flex items-start gap-2",Z.error?"bg-danger/8 border border-danger/20 text-danger":Z.reachable?"bg-success/8 border border-success/20 text-success":"bg-warning/8 border border-warning/20 text-warning"),children:Z.error?t.jsxs(t.Fragment,{children:[t.jsx(Ge,{size:11,className:"mt-0.5 flex-shrink-0"})," ",Z.error]}):Z.reachable?t.jsxs(t.Fragment,{children:[t.jsx(Re,{size:11,className:"mt-0.5 flex-shrink-0"})," Server reachable"]}):t.jsxs(t.Fragment,{children:[t.jsx(oa,{size:11,className:"mt-0.5 flex-shrink-0"})," Host unreachable"]})})]}),t.jsx(Lu,{open:I,onOpenChange:F,currentPath:S||"~/.ssh",homePath:c,onSelect:Ae=>Q(Ae)})]}),l===2&&t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsx(Lp,{icon:Nr,title:"Behavior",children:t.jsxs("div",{className:"space-y-3",children:[t.jsxs("label",{className:"flex items-center justify-between cursor-pointer",children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-xs text-text-1 font-sans block",children:"Auto-start daemon"}),t.jsx("span",{className:"text-2xs text-text-4 font-sans",children:"Start Groove on the remote when connecting"})]}),t.jsx(yD,{value:N,onChange:L})]}),t.jsxs("label",{className:"flex items-center justify-between cursor-pointer",children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-xs text-text-1 font-sans block",children:"Auto-connect on launch"}),t.jsx("span",{className:"text-2xs text-text-4 font-sans",children:"Connect when Groove starts"})]}),t.jsx(yD,{value:B,onChange:M})]})]})}),Z&&!Z.error&&t.jsxs("div",{className:"rounded-lg border border-border-subtle bg-surface-1 px-4 py-3.5",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[t.jsx("div",{className:"w-6 h-6 rounded bg-success/10 flex items-center justify-center flex-shrink-0",children:t.jsx(Re,{size:12,className:"text-success"})}),t.jsx("span",{className:"text-[13px] font-medium text-text-0 font-sans",children:"Test Results"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2 text-2xs font-sans",children:[t.jsx(aa,{status:Z.reachable?"running":"crashed",size:"sm"}),t.jsx("span",{className:"text-text-1",children:"Reachable"})]}),t.jsxs("div",{className:"flex items-center gap-2 text-2xs font-sans",children:[t.jsx(aa,{status:Z.grooveInstalled?"running":"stopped",size:"sm"}),t.jsx("span",{className:"text-text-1",children:"Groove Installed"})]}),t.jsxs("div",{className:"flex items-center gap-2 text-2xs font-sans",children:[t.jsx(aa,{status:Z.daemonRunning?"running":"stopped",size:"sm"}),t.jsx("span",{className:"text-text-1",children:"Daemon Running"})]})]})]}),(!Z||Z.error)&&t.jsxs("div",{className:"rounded-lg border border-border-subtle bg-surface-1 px-4 py-3.5",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("div",{className:"w-6 h-6 rounded bg-accent/8 flex items-center justify-center flex-shrink-0",children:t.jsx(Kt,{size:12,className:"text-accent"})}),t.jsx("span",{className:"text-[13px] font-medium text-text-0 font-sans",children:x||"Server"})]}),t.jsxs("div",{className:"space-y-1.5 text-2xs font-sans",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-text-3",children:"Connection"}),t.jsxs("span",{className:"text-text-1 font-mono",children:[O,"@",y,":",C]})]}),S&&t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-text-3",children:"SSH Key"}),t.jsx("span",{className:"text-text-1 font-mono truncate max-w-40",children:S})]})]})]})]}),l===3&&t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{className:"rounded-lg border border-success/30 bg-success/5 px-4 py-5 text-center",children:[t.jsx("div",{className:"w-10 h-10 rounded-full bg-success/15 flex items-center justify-center mx-auto mb-3",children:t.jsx(Re,{size:20,className:"text-success"})}),t.jsx("h3",{className:"text-sm font-semibold text-text-0 font-sans mb-1",children:"Connected"}),t.jsxs("p",{className:"text-2xs text-text-3 font-sans",children:["Successfully connected to ",t.jsx("span",{className:"font-mono text-text-1",children:x})]}),t.jsxs(pe,{variant:"primary",size:"sm",onClick:()=>{const Ae=e==null?void 0:e.localPort,Qe=encodeURIComponent(x);window.open(`http://localhost:${Ae}?instance=${Qe}`,"_blank")},className:"h-8 text-xs gap-1.5 mt-4",children:[t.jsx(ha,{size:12}),"Open Remote GUI"]})]}),t.jsxs("div",{className:"rounded-lg border border-border-subtle bg-surface-1 px-4 py-3.5",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[t.jsx("div",{className:"w-6 h-6 rounded bg-accent/8 flex items-center justify-center flex-shrink-0",children:t.jsx(Kt,{size:12,className:"text-accent"})}),t.jsx("span",{className:"text-[13px] font-medium text-text-0 font-sans",children:"Connection Info"})]}),t.jsxs("div",{className:"space-y-1.5 text-2xs font-sans",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-text-3",children:"Connection"}),t.jsxs("span",{className:"text-text-1 font-mono",children:[O,"@",y,":",C]})]}),S&&t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-text-3",children:"SSH Key"}),t.jsx("span",{className:"text-text-1 font-mono truncate max-w-40",children:S})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-text-3",children:"Auto-start"}),t.jsx("span",{className:"text-text-1",children:N?"On":"Off"})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-text-3",children:"Auto-connect"}),t.jsx("span",{className:"text-text-1",children:B?"On":"Off"})]}),(e==null?void 0:e.remoteVersion)&&t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-text-3",children:"Version"}),t.jsxs("span",{className:G("text-text-1 font-mono",e.versionMatch===!1&&"text-warning"),children:["v",e.remoteVersion,e.versionMatch===!1&&" (update available)"]})]})]})]})]}),t.jsxs("div",{className:"flex items-center justify-between mt-4",children:[t.jsx(pe,{variant:"ghost",size:"sm",onClick:l===0||l===3?o:ue,className:"h-8 text-xs px-4 text-text-3",children:l===0?"Cancel":l===3?"Done":"Back"}),l<3&&t.jsx("div",{className:"flex gap-2",children:l===2?t.jsxs(pe,{variant:"primary",size:"sm",onClick:xe,disabled:T||q,className:"h-8 text-xs px-4 gap-1.5",children:[T?t.jsx(ze,{size:12,className:"animate-spin"}):t.jsx(ra,{size:12}),T?"Connecting...":"Connect"]}):l===1?t.jsx(pe,{variant:"primary",size:"sm",onClick:re,disabled:q,className:"h-8 text-xs px-4",children:q?"Saving...":"Next"}):t.jsx(pe,{variant:"primary",size:"sm",onClick:Y,disabled:!z(),className:"h-8 text-xs px-4",children:"Next"})})]})]})}function BG(){const e=$(y=>y.quickConnectOpen),a=$(y=>y.toggleQuickConnect),n=$(y=>y.savedTunnels),s=$(y=>y.addToast),[o,c]=g.useState(null),[l,d]=g.useState(!1),h=g.useRef(null);if(!e)return null;async function f(y){c(y);try{await $.getState().connectTunnel(y);const k=n.find(O=>O.id===y);k!=null&&k.host&&s("info",`Add ${k.host} to Federation Whitelist?`,"",{label:"Add",onClick:()=>$.getState().addToWhitelist(k.host)}),c(null);return}catch(k){let O=(k==null?void 0:k.message)||"Unknown error";O.toLowerCase().includes("port forward")&&(O+=" — Try testing the connection first, or check your SSH key configuration."),s("error","Connection failed",O)}c(null)}function x(y){var k,O;if((O=(k=window.groove)==null?void 0:k.remote)!=null&&O.openWindow)window.groove.remote.openWindow(y.localPort,y.name);else{const w=encodeURIComponent(y.name);window.open(`http://localhost:${y.localPort}?instance=${w}`,"_blank")}a()}function m(){d(!1),a()}return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-50 bg-black/40 backdrop-blur-sm",onClick:m}),t.jsx(Su,{children:t.jsxs(Hn.div,{initial:{opacity:0,y:-20,scale:.96},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-10,scale:.98},transition:{duration:.15},className:G("fixed top-[15%] left-1/2 -translate-x-1/2 z-50 bg-surface-1 border border-border rounded-lg shadow-2xl overflow-hidden",l?"w-[520px]":"w-[400px]"),children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border-subtle",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[l&&t.jsx("button",{onClick:()=>d(!1),className:"p-1 -ml-1 text-text-4 hover:text-text-1 cursor-pointer transition-colors",children:t.jsx(q1,{size:14})}),t.jsx(Fn,{size:15,className:"text-accent"}),t.jsx("span",{className:"text-sm font-semibold text-text-0 font-sans",children:l?"Add Connection":"Quick Connect"})]}),t.jsx("button",{onClick:m,className:"p-1 text-text-4 hover:text-text-1 cursor-pointer transition-colors",children:t.jsx(Ge,{size:14})})]}),l?t.jsx(vQe,{server:null,onSave:async y=>{const k=y.id||h.current;if(k)await $.getState().updateTunnel(k,y),s("success","Server updated");else{const O=await $.getState().saveTunnel(y);O!=null&&O.id&&(h.current=O.id),s("success","Server added")}},onTest:()=>{const y=h.current;if(y)return $.getState().testTunnel(y)},onConnect:()=>{const y=h.current;if(y)return $.getState().connectTunnel(y)},onCancel:()=>{h.current=null,d(!1)}}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"overflow-y-auto max-h-[320px] py-1",children:n.length===0?t.jsxs("div",{className:"px-4 py-8 text-center",children:[t.jsx(Kt,{size:24,className:"text-text-4 mx-auto mb-2"}),t.jsx("p",{className:"text-sm text-text-3 font-sans",children:"No saved servers"}),t.jsx("p",{className:"text-2xs text-text-4 font-sans mt-1",children:"Add a connection to get started."}),t.jsxs(pe,{variant:"primary",size:"sm",onClick:()=>{h.current=null,d(!0)},className:"h-8 text-xs gap-1.5 mt-3",children:[t.jsx(gt,{size:12})," Add Connection"]})]}):n.map(y=>t.jsxs("div",{className:G("w-full flex items-center gap-3 px-4 py-2.5 transition-colors","hover:bg-surface-5",o===y.id&&"opacity-60 pointer-events-none"),children:[t.jsx(Kt,{size:15,className:y.active?"text-success":"text-text-4"}),t.jsxs("button",{onClick:()=>y.active?x(y):f(y.id),disabled:o===y.id,className:"flex-1 min-w-0 text-left cursor-pointer",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-medium text-text-0 font-sans truncate",children:y.name}),y.active&&t.jsx(aa,{status:"running",size:"sm"}),y.remoteVersion&&t.jsxs("span",{className:"text-2xs font-mono text-text-4 ml-1",children:["v",y.remoteVersion]})]}),t.jsxs("span",{className:"text-2xs text-text-4 font-mono",children:[y.user,"@",y.host]})]}),t.jsx("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:o===y.id?t.jsx(ze,{size:14,className:"text-text-3 animate-spin"}):y.active?t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:()=>x(y),className:"flex items-center gap-1 text-2xs text-success font-sans hover:text-success/80 cursor-pointer transition-colors",children:[t.jsx(ha,{size:11})," Open"]}),y.versionMatch===!1&&t.jsxs("button",{onClick:async()=>{try{await $.getState().upgradeTunnel(y.id),s("success","Upgrade started")}catch(k){s("error","Upgrade failed",k.message)}},className:"flex items-center gap-1 text-2xs text-warning font-sans hover:text-warning/80 cursor-pointer transition-colors",title:`Update remote from v${y.remoteVersion} to v${y.localVersion}`,children:[t.jsx(Ta,{size:11})," Update"]}),t.jsx("button",{onClick:async()=>{await $.getState().disconnectTunnel(y.id),s("info","Disconnected",y.name)},className:"p-1 text-text-4 hover:text-danger cursor-pointer transition-colors rounded",title:"Disconnect",children:t.jsx(Fo,{size:12})}),t.jsx("button",{onClick:k=>{k.stopPropagation(),$.getState().deleteTunnel(y.id)},className:"p-1 text-text-4 hover:text-danger cursor-pointer transition-colors rounded",title:"Delete connection",children:t.jsx(ht,{size:12})})]}):t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>f(y.id),className:"text-2xs text-text-3 font-sans hover:text-text-1 cursor-pointer transition-colors",children:"Connect"}),t.jsx("button",{onClick:k=>{k.stopPropagation(),$.getState().deleteTunnel(y.id)},className:"p-1 text-text-4 hover:text-danger cursor-pointer transition-colors rounded",title:"Delete connection",children:t.jsx(ht,{size:12})})]})})]},y.id))}),t.jsx("div",{className:"px-4 py-2.5 border-t border-border-subtle",children:t.jsxs("button",{onClick:()=>{h.current=null,d(!0)},className:"flex items-center gap-1.5 text-2xs text-accent hover:text-accent/80 font-sans font-medium cursor-pointer transition-colors",children:[t.jsx(gt,{size:10})," Add new connection"]})})]})]})})]})}const vD=[],kQe=/error|crash|fail/i,Tp="rgba(51, 175, 188, 0.15)",$p="h-[2px]";function OQe(e){if(!e||e==="auto")return"auto";const a=e.match(/^claude-(opus|sonnet|haiku)-(\d+)-(\d+)(?:-\d+)?$/);return a?`${a[1][0].toUpperCase()+a[1].slice(1)} ${a[2]}.${a[3]}`:e.startsWith("gemini-")?e.replace("gemini-","Gemini ").replace("-preview","").replace("-flash-lite"," Flash Lite").replace("-flash"," Flash").replace("-pro"," Pro"):e.startsWith("gpt-")?e.toUpperCase().replace("GPT-","GPT-"):e}function bQe(e){if(!e||e.length<2)return null;const a=e.slice(-10),n=(a[a.length-1].t-a[0].t)/6e4;return n<=0?null:(a[a.length-1].v-a[0].v)/n}function wQe(e){return e>=70?"var(--color-success)":e>=40?"var(--color-warning)":"var(--color-danger)"}function jQe(e){return e>=60?"var(--color-success)":e>=30?"var(--color-warning)":"var(--color-danger)"}const CQe={running:"LIVE",starting:"INIT",stopped:"IDLE",crashed:"ERR",completed:"DONE",killed:"KILL",rotating:"ROT"},_G=g.memo(({data:e,selected:a})=>{const{agent:n}=e,s=n.status==="running"||n.status==="starting",o=Math.round((n.contextUsage||0)*100),c=PE(n.status),l=n.tokensUsed||0,d=g.useRef(null),h=$(N=>!!N.expandedNodes[n.id]),f=$(N=>N.toggleNodeExpanded);g.useEffect(()=>{var L;const N=(L=d.current)==null?void 0:L.closest(".react-flow__node");N&&(N.style.zIndex=h?"1000":"")},[h]);const x=$(N=>N.activityLog[n.id])||vD,m=$(N=>N.tokenTimeline[n.id])||vD,y=bQe(m),k=g.useMemo(()=>x.filter(N=>kQe.test(N.text)).length,[x]),O=o>75?"var(--color-danger)":o>50?"var(--color-warning)":"var(--color-success)",w=n.qualityScore!=null?Math.round(n.qualityScore):null,C=w!=null?wQe(w):null,j=n.efficiency!=null?n.efficiency:null,S=j!=null?jQe(j):null,Q=n.durationMs?n.durationMs/1e3:n.spawnedAt?(Date.now()-new Date(n.spawnedAt).getTime())/1e3:n.createdAt?(Date.now()-new Date(n.createdAt).getTime())/1e3:0;return t.jsx("div",{ref:d,children:t.jsxs("div",{className:`w-[220px] overflow-hidden rounded-[4px] transition-all duration-200 ease-out bg-[#1c1f26] hover:bg-[#141720] border border-solid ${a?"border-[#2e323a]":"border-[#262a32]"} hover:border-[#2e3640]`,children:[t.jsx(Oo,{id:"top",type:"target",position:bo.Top,className:"!w-1 !h-1 !bg-transparent !border-0"}),t.jsx(Oo,{id:"bottom",type:"target",position:bo.Bottom,className:"!w-1 !h-1 !bg-transparent !border-0"}),t.jsx(Oo,{id:"left",type:"target",position:bo.Left,className:"!w-1 !h-1 !bg-transparent !border-0"}),t.jsx(Oo,{id:"right",type:"target",position:bo.Right,className:"!w-1 !h-1 !bg-transparent !border-0"}),s&&t.jsx("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",style:{borderRadius:3},children:t.jsx("div",{className:"absolute left-0 right-0 h-px",style:{background:"linear-gradient(90deg, transparent 0%, rgba(97,175,239,0.25) 50%, transparent 100%)",animation:"node-scan 3s ease-in-out infinite"}})}),t.jsxs("div",{className:"px-3 pt-2.5 pb-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{className:"relative flex-shrink-0 w-[6px] h-[6px]",children:[t.jsx("span",{className:"absolute inset-0 rounded-sm",style:{background:c}}),s&&t.jsx("span",{className:"absolute inset-[-2px] rounded-sm",style:{background:c,opacity:.15,animation:"node-pulse-bar 2s ease-in-out infinite"}})]}),t.jsx("span",{className:"text-[12px] font-semibold text-[#e6e6e6] font-sans truncate flex-1 leading-none",children:n.name}),t.jsx("span",{className:"text-[7px] font-mono font-bold uppercase tracking-wider px-1 py-px rounded-sm",style:{color:c,background:c+"12"},children:CQe[n.status]||n.status}),t.jsx("button",{className:"text-[#505862] hover:text-[#8b929e] cursor-pointer transition-colors flex-shrink-0",onClick:N=>{N.stopPropagation(),f(n.id)},children:h?t.jsx(Ge,{size:10}):t.jsx(xd,{size:10})})]}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-1.5",children:[t.jsx("span",{className:"text-[9px] font-mono text-[#505862] uppercase tracking-[0.05em]",children:n.role}),t.jsx("span",{className:"text-[9px] text-[#2a2e36]",children:"/"}),t.jsx("span",{className:"text-[9px] font-mono text-[#505862]",children:OQe(n.model)})]})]}),t.jsxs("div",{className:"px-3 pt-1 pb-2",children:[t.jsxs("div",{className:"flex items-baseline gap-1.5",children:[t.jsx("span",{className:"text-[14px] font-mono font-medium text-[#bcc2cd] leading-none",children:At(l)}),t.jsx("span",{className:"text-[8px] font-mono text-[#505862]",children:"tok"}),t.jsx("span",{className:"flex-1"}),t.jsxs("span",{className:"text-[9px] font-mono text-[#505862]",children:[o,"%"]})]}),t.jsx("div",{className:`mt-1.5 ${$p} rounded-sm overflow-hidden`,style:{background:Tp},children:t.jsx("div",{className:"h-full rounded-sm transition-all duration-700",style:{width:`${Math.max(o,1)}%`,background:o>80?"var(--color-danger)":o>60?"var(--color-warning)":"var(--color-accent)"}})})]}),t.jsx("div",{className:"grid transition-[grid-template-rows] duration-200 ease-out",style:{gridTemplateRows:h?"1fr":"0fr"},children:t.jsxs("div",{className:"overflow-hidden",children:[t.jsx("div",{className:"mx-3 border-t border-white/[0.04]"}),t.jsxs("div",{className:"px-3 pt-1.5 pb-1",children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("span",{className:"text-[9px] font-mono text-[#505862] uppercase tracking-wider",children:"Context"}),(n.rotations||0)>0&&t.jsxs("span",{className:"text-[8px] font-mono text-[#606878] bg-white/[0.04] rounded px-1 py-px",children:[n.rotations,"x rot"]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:`flex-1 ${$p} rounded-sm overflow-hidden`,style:{background:Tp},children:t.jsx("div",{className:"h-full rounded-sm transition-all duration-500",style:{width:`${Math.max(o,1)}%`,background:O}})}),t.jsxs("span",{className:"text-[9px] font-mono font-medium",style:{color:O},children:[o,"%"]})]})]}),t.jsxs("div",{className:"px-3 pt-1 pb-1",children:[t.jsx("span",{className:"text-[9px] font-mono text-[#505862] uppercase tracking-wider",children:"Quality"}),t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[t.jsx("div",{className:`flex-1 ${$p} rounded-sm overflow-hidden`,style:{background:Tp},children:t.jsx("div",{className:"h-full rounded-sm transition-all duration-500",style:{width:`${w!=null?Math.max(w,1):0}%`,background:C||"#505862"}})}),t.jsx("span",{className:"text-[9px] font-mono font-medium",style:{color:C||"#505862"},children:w??"—"})]})]}),t.jsxs("div",{className:"px-3 pt-1 pb-1",children:[t.jsx("span",{className:"text-[9px] font-mono text-[#505862] uppercase tracking-wider",children:"Efficiency"}),t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[t.jsx("div",{className:`flex-1 ${$p} rounded-sm overflow-hidden`,style:{background:Tp},children:t.jsx("div",{className:"h-full rounded-sm transition-all duration-500",style:{width:`${j!=null?Math.max(j,1):0}%`,background:S||"#505862"}})}),t.jsx("span",{className:"text-[9px] font-mono font-medium",style:{color:S||"#505862"},children:j!=null?`${j}%`:"—"})]})]}),t.jsx("div",{className:"px-3 pt-1 pb-1",children:t.jsxs("div",{className:"grid grid-cols-3 gap-1",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-[9px] font-mono font-medium text-[#bcc2cd]",children:Go(n.costUsd||0)}),t.jsx("div",{className:"text-[7px] font-mono text-[#505862]",children:"cost"})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-[9px] font-mono font-medium text-[#bcc2cd]",children:y?At(Math.round(y)):"—"}),t.jsx("div",{className:"text-[7px] font-mono text-[#505862]",children:"tok/m"})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-[9px] font-mono font-medium text-[#bcc2cd]",children:n.turns||0}),t.jsx("div",{className:"text-[7px] font-mono text-[#505862]",children:"turns"})]})]})}),t.jsx("div",{className:"px-3 pt-1 pb-2",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"text-[9px] font-mono text-[#8b929e]",children:Ud(Math.max(0,Math.floor(Q)))}),t.jsx("span",{className:"text-[7px] font-mono text-[#505862]",children:"up"})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[k>0?t.jsx("span",{className:"text-[9px] font-mono text-[var(--color-danger)]",children:k}):t.jsx("span",{className:"text-[9px] font-mono text-[#505862]",children:"0"}),t.jsx("span",{className:"text-[7px] font-mono text-[#505862]",children:"err"})]})]})})]})})]})})});_G.displayName="AgentNode";const LG=g.memo(({data:e})=>{const{agentCount:a,runningCount:n}=e,s=n>0,o={background:"transparent",border:0,width:2,height:2};return t.jsxs("div",{className:"relative flex items-center justify-center",style:{width:84,height:84},children:[t.jsx("div",{className:G("absolute inset-0 rounded-full transition-all duration-500",s&&"animate-[spin-slow_30s_linear_infinite]"),style:{border:`1px dashed ${s?"rgba(97,175,239,0.5)":"rgba(97,175,239,0.25)"}`}}),t.jsx("div",{className:"absolute inset-[10px] rounded-full",style:{background:s?"radial-gradient(circle, rgba(97,175,239,0.15) 0%, transparent 70%)":"radial-gradient(circle, rgba(97,175,239,0.05) 0%, transparent 70%)",animation:s?"node-pulse-bar 2.5s ease-in-out infinite":"none"}}),t.jsx("div",{className:G("w-14 h-14 rounded-full flex items-center justify-center relative z-10 transition-all duration-300",s?"bg-[#1c1f26] border-2 border-[#61afef]/35 shadow-[0_0_28px_rgba(97,175,239,0.15)]":"bg-[#1c1f26] border border-[#61afef]/20"),children:t.jsx("img",{src:"/favicon.png",alt:"G",className:G("h-7 w-7 rounded-full transition-opacity",s?"opacity-90":"opacity-60")})}),a>0&&t.jsx("div",{className:G("absolute z-20 min-w-[20px] h-[20px] rounded-sm flex items-center justify-center","text-[10px] font-mono font-bold px-1 transition-all duration-300",s?"bg-[#1c1f26] text-[#61afef] border border-[#61afef]/40":"bg-[#1c1f26] text-[#61afef]/60 border border-[#61afef]/20"),style:{bottom:2,right:2},children:a}),t.jsx(Oo,{id:"bottom",type:"source",position:bo.Bottom,style:o}),t.jsx(Oo,{id:"right",type:"source",position:bo.Right,style:o}),t.jsx(Oo,{id:"left",type:"source",position:bo.Left,style:o}),t.jsx(Oo,{id:"top",type:"source",position:bo.Top,style:o})]})});LG.displayName="RootNode";const MQe=[{id:"desktop",icon:Cr,label:"Desktop",width:"100%"},{id:"tablet",icon:j0,label:"Tablet (768px)",width:"768px"},{id:"mobile",icon:w0,label:"Mobile (375px)",width:"375px"}];function SQe({onRefresh:e}){const a=$(x=>x.previewState),n=$(x=>x.setPreviewDevice),s=$(x=>x.toggleScreenshotMode),o=$(x=>x.closePreview),[c,l]=g.useState(!1),d=g.useRef(null);g.useEffect(()=>()=>{d.current&&clearTimeout(d.current)},[]);function h(){c?(d.current&&clearTimeout(d.current),l(!1),o()):(l(!0),d.current=setTimeout(()=>l(!1),2e3))}const f=a.teamId?`${window.location.origin}/api/preview/${a.teamId}/proxy/`:a.url;return t.jsxs("div",{className:"h-10 flex items-center gap-2 px-3 bg-surface-3 border-b border-border flex-shrink-0",children:[t.jsx("div",{className:"flex-1 min-w-0 h-7 flex items-center px-3 rounded-md bg-surface-1 border border-border-subtle",children:t.jsx("span",{className:"text-2xs font-mono text-text-3 truncate",children:f||"No URL"})}),t.jsx("button",{onClick:e,className:"w-7 h-7 flex items-center justify-center rounded-md text-text-3 hover:text-accent hover:bg-accent/10 transition-colors cursor-pointer",title:"Refresh",children:t.jsx(ca,{size:14})}),t.jsx("div",{className:"flex items-center gap-0.5 px-1 py-0.5 rounded-md bg-surface-1 border border-border-subtle",children:MQe.map(x=>t.jsx("button",{onClick:()=>n(x.id),className:G("w-7 h-6 flex items-center justify-center rounded transition-colors cursor-pointer",a.deviceSize===x.id?"text-accent bg-accent/10":"text-text-3 hover:text-text-1"),title:x.label,children:t.jsx(x.icon,{size:13})},x.id))}),t.jsx("button",{onClick:s,className:G("w-7 h-7 flex items-center justify-center rounded-md transition-colors cursor-pointer",a.screenshotMode?"text-accent bg-accent/10":"text-text-3 hover:text-accent hover:bg-accent/10"),title:"Screenshot",children:t.jsx(Z1,{size:14})}),t.jsx("button",{onClick:h,className:G("h-7 flex items-center justify-center rounded-md transition-all cursor-pointer",c?"px-2 gap-1.5 bg-danger/15 text-danger border border-danger/25":"w-7 text-text-3 hover:text-danger hover:bg-danger/10"),title:"Close Preview",children:c?t.jsx("span",{className:"text-2xs font-semibold font-sans whitespace-nowrap",children:"Close?"}):t.jsx(Ge,{size:14})})]})}/*!
|
|
8615
8615
|
* html2canvas 1.4.1 <https://html2canvas.hertzen.com>
|
|
8616
8616
|
* Copyright (c) 2022 Niklas von Hertzen <https://hertzen.com>
|
|
8617
8617
|
* Released under MIT License
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<link rel="icon" type="image/png" href="/favicon.png" />
|
|
8
8
|
<title>Groove GUI</title>
|
|
9
|
-
<script type="module" crossorigin src="/assets/index-
|
|
9
|
+
<script type="module" crossorigin src="/assets/index-bmkBX18f.js"></script>
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/assets/vendor-26L3JoZv.js">
|
|
11
11
|
<link rel="modulepreload" crossorigin href="/assets/reactflow-DoBZjiHE.js">
|
|
12
12
|
<link rel="modulepreload" crossorigin href="/assets/codemirror-CFF1Lrnz.js">
|
|
@@ -90,16 +90,14 @@ export function StatusBar({
|
|
|
90
90
|
</button>
|
|
91
91
|
</div>
|
|
92
92
|
))}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
</button>
|
|
102
|
-
)}
|
|
93
|
+
<button
|
|
94
|
+
onClick={() => useGrooveStore.getState().toggleQuickConnect()}
|
|
95
|
+
className="flex items-center gap-1.5 text-text-4 hover:text-text-1 cursor-pointer transition-colors"
|
|
96
|
+
title="Quick Connect to remote server"
|
|
97
|
+
>
|
|
98
|
+
<Plug size={10} />
|
|
99
|
+
<span>Connect</span>
|
|
100
|
+
</button>
|
|
103
101
|
</>
|
|
104
102
|
)}
|
|
105
103
|
{connected && (
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "groove-dev",
|
|
3
|
-
"version": "0.27.
|
|
3
|
+
"version": "0.27.121",
|
|
4
4
|
"description": "Open-source agent orchestration layer — the AI company OS. Local model agent engine (GGUF/Ollama/llama-server), HuggingFace model browser, MCP integrations (Slack, Gmail, Stripe, 15+), agent scheduling (cron), business roles (CMO, CFO, EA). GUI dashboard, multi-agent coordination, zero cold-start, infinite sessions. Works with Claude Code, Codex, Gemini CLI, Ollama, any local model.",
|
|
5
5
|
"license": "FSL-1.1-Apache-2.0",
|
|
6
6
|
"author": "Groove Dev <hello@groovedev.ai> (https://groovedev.ai)",
|
|
@@ -5,7 +5,6 @@ import { createServer as createHttpServer, request as httpProxyRequest } from 'h
|
|
|
5
5
|
import { createServer as createNetServer } from 'net';
|
|
6
6
|
import { execFileSync } from 'child_process';
|
|
7
7
|
import { resolve } from 'path';
|
|
8
|
-
import { homedir } from 'os';
|
|
9
8
|
import { readFileSync, writeFileSync, unlinkSync, existsSync, mkdirSync, readdirSync, rmdirSync, rmSync, statSync } from 'fs';
|
|
10
9
|
import express from 'express';
|
|
11
10
|
import { WebSocketServer } from 'ws';
|
|
@@ -95,7 +94,7 @@ export class Daemon {
|
|
|
95
94
|
this.port = options.port !== undefined ? options.port : (parseInt(process.env.GROOVE_PORT, 10) || DEFAULT_PORT);
|
|
96
95
|
this.host = resolveHost(options.host);
|
|
97
96
|
this.projectDir = options.projectDir || process.cwd();
|
|
98
|
-
this.grooveDir = options.grooveDir || resolve(
|
|
97
|
+
this.grooveDir = options.grooveDir || resolve(this.projectDir, '.groove');
|
|
99
98
|
this.pidFile = resolve(this.grooveDir, 'daemon.pid');
|
|
100
99
|
|
|
101
100
|
// Ensure .groove directories exist
|
|
@@ -8611,7 +8611,7 @@ ${s}`);const c={chatHistory:[...a().chatHistory[n]||[]],activityLog:[...a().acti
|
|
|
8611
8611
|
|
|
8612
8612
|
If you want to hide the \`${a.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
8613
8613
|
|
|
8614
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${a.docsSlug}`;return g.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},iQe="DialogDescriptionWarning",cQe=({contentRef:e,descriptionId:a})=>{const s=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${wG(iQe).contentName}}.`;return g.useEffect(()=>{var c;const o=(c=e.current)==null?void 0:c.getAttribute("aria-describedby");a&&o&&(document.getElementById(a)||console.warn(s))},[s,e,a]),null},jG=AG,lQe=uG,CG=pG,MG=fG,SG=xG,yT=gG,NG=vG,qE=OG;function Rt({children:e,...a}){return t.jsx(jG,{...a,children:e})}const QG=lQe;function Ht({children:e,className:a,title:n,description:s,...o}){return t.jsxs(CG,{children:[t.jsx(MG,{className:"fixed inset-0 z-50 bg-black/50 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"}),t.jsxs(SG,{className:G("fixed left-1/2 top-1/2 z-50 -translate-x-1/2 -translate-y-1/2","w-full max-w-lg max-h-[85vh] overflow-y-auto","bg-surface-1 border border-border rounded-lg shadow-2xl","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",a),...o,children:[n&&t.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-border-subtle",children:[t.jsx(yT,{className:"text-base font-semibold text-text-0 font-sans",children:n}),t.jsx(qE,{className:"p-1 rounded-md text-text-3 hover:text-text-0 hover:bg-surface-5 transition-colors",children:t.jsx(Ge,{size:16})})]}),s&&t.jsx(NG,{className:"sr-only",children:s}),e]})]})}const AQe={primary:"bg-accent/20 text-accent border border-accent/25 hover:bg-accent/30 font-medium",secondary:"bg-surface-5/40 text-text-1 border border-border-subtle hover:bg-surface-5/70 hover:text-text-0",ghost:"bg-transparent text-text-2 border border-transparent hover:bg-surface-5/50 hover:text-text-0",danger:"bg-danger/12 text-danger border border-danger/15 hover:bg-danger/20",info:"bg-info/12 text-info border border-info/15 hover:bg-info/20",outline:"bg-transparent text-accent border border-accent/30 hover:bg-accent/10"},dQe={sm:"h-7 px-2.5 text-xs gap-1.5 rounded",md:"h-8 px-3 text-sm gap-2 rounded",lg:"h-9 px-4 text-sm gap-2 rounded",icon:"h-8 w-8 rounded"},pe=g.forwardRef(({className:e,variant:a="secondary",size:n="md",children:s,...o},c)=>t.jsx("button",{ref:c,className:G("inline-flex items-center justify-center font-sans transition-colors duration-100","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent","disabled:opacity-40 disabled:pointer-events-none","cursor-pointer select-none",AQe[a],dQe[n],e),...o,children:s}));pe.displayName="Button";function uQe(){const e=$(h=>h.updateModalOpen),a=$(h=>h.setUpdateModalOpen),n=$(h=>h.version),s=$(h=>h.updateReady),o=$(h=>h.updateProgress),c=$(h=>h.installUpdate),l=o&&!s,d=l?Math.max(0,Math.min(100,o.percent||0)):100;return t.jsx(Rt,{open:e,onOpenChange:a,children:t.jsxs(Ht,{title:"Update Available",description:"Desktop app update",children:[t.jsxs("div",{className:"px-5 py-4 flex flex-col gap-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"flex items-center justify-center w-10 h-10 rounded-lg bg-accent/12",children:t.jsx(Ta,{size:20,className:"text-accent"})}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-text-1 font-sans font-medium",children:l?"Downloading update…":"Ready to update"}),t.jsxs("p",{className:"text-xs text-text-3 font-sans mt-0.5",children:[n&&t.jsx("span",{className:"font-mono",children:n}),n&&s&&" → ",s&&t.jsx("span",{className:"font-mono text-accent",children:s})]})]})]}),l&&t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[t.jsx(ze,{size:12,className:"animate-spin text-accent flex-shrink-0"}),t.jsx("div",{className:"flex-1 h-1.5 rounded-full bg-surface-3 overflow-hidden",children:t.jsx("div",{className:"h-full rounded-full bg-accent transition-all duration-500 ease-out",style:{width:`${d}%`}})}),t.jsxs("span",{className:"text-2xs font-mono text-text-3 tabular-nums",children:[d,"%"]})]}),!l&&t.jsx("p",{className:"text-xs text-text-3 font-sans leading-relaxed",children:"The app will restart to apply the update. Your work is saved automatically."})]}),t.jsxs("div",{className:"flex items-center justify-end gap-2 px-5 py-3 border-t border-border-subtle bg-surface-0",children:[t.jsx(pe,{variant:"ghost",size:"sm",onClick:()=>a(!1),children:"Later"}),t.jsxs(pe,{variant:"primary",size:"sm",disabled:l,onClick:()=>{c(),a(!1)},children:[t.jsx(Ta,{size:12}),"Update & Restart"]})]})]})})}function hQe({connected:e,agentCount:a,runningCount:n,uptime:s,terminalVisible:o,onToggleTerminal:c}){const l=$(w=>w.savedTunnels),d=$(w=>w.tunneled),h=$(w=>w.version),f=$(w=>w.updateReady),x=$(w=>w.updateProgress),m=$(w=>w.setUpdateModalOpen),y=$(w=>w.setActiveView),k=l.filter(w=>w.active),O=K0();return t.jsxs("footer",{className:"h-6 flex-shrink-0 flex items-center px-3 bg-surface-3 border-t border-border text-2xs font-sans select-none",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(aa,{status:e?"running":"crashed",size:"sm"}),t.jsx("span",{className:e?"text-text-2":"text-danger",children:e?O?"Desktop":"Connected":"Offline"})]}),O&&e&&t.jsxs("button",{onClick:()=>gP(window.location.href),className:"flex items-center gap-1 text-text-4 hover:text-text-1 cursor-pointer transition-colors",title:"Open this workspace in your browser",children:[t.jsx(ea,{size:10}),t.jsx("span",{children:"Browser"})]}),e&&s>0&&t.jsxs("span",{className:"text-text-4",children:["Up ",Ud(s)]}),e&&a>0&&t.jsxs("span",{className:"text-text-4",children:[n,"/",a," agents"]}),d?t.jsxs("button",{onClick:()=>{var w,C,j;return((j=(C=(w=window.groove)==null?void 0:w.remote)==null?void 0:C.close)==null?void 0:j.call(C))||window.close()},className:"flex items-center gap-1.5 text-text-3 hover:text-danger cursor-pointer transition-colors",title:"Close remote connection",children:[t.jsx(Fo,{size:10}),t.jsx("span",{children:"Disconnect"})]}):t.jsxs(t.Fragment,{children:[k.map(w=>t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsxs("button",{onClick:()=>{const C=w.localPort,j=encodeURIComponent(w.name);gP(`http://localhost:${C}?instance=${j}`)},className:"flex items-center gap-1.5 text-text-3 hover:text-text-1 cursor-pointer transition-colors",title:"Open remote GUI",children:[t.jsx(Fn,{size:10,className:"text-success"}),t.jsx("span",{children:w.name}),t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-success"}),w.latencyMs!=null&&t.jsxs("span",{className:"text-text-4",children:[w.latencyMs,"ms"]})]}),t.jsx("button",{onClick:()=>$.getState().disconnectTunnel(w.id),className:"p-0.5 text-text-4 hover:text-danger cursor-pointer transition-colors rounded",title:"Disconnect",children:t.jsx(Ge,{size:10})})]},w.id)),l.length>0&&t.jsxs("button",{onClick:()=>$.getState().toggleQuickConnect(),className:"flex items-center gap-1.5 text-text-4 hover:text-text-1 cursor-pointer transition-colors",title:"Quick Connect to remote server",children:[t.jsx(ra,{size:10}),t.jsx("span",{children:"Connect"})]})]}),e&&t.jsxs("button",{onClick:()=>y("federation"),className:"flex items-center gap-1.5 text-text-4 hover:text-text-1 cursor-pointer transition-colors",title:"Federation",children:[t.jsx(ea,{size:10}),t.jsx("span",{children:"Federation"})]})]}),t.jsx("div",{className:"flex-1"}),f||x?t.jsx("button",{onClick:()=>m(!0),className:"flex items-center gap-1 px-2 h-full cursor-pointer",title:f?`Update to v${f}`:"Downloading update…",children:t.jsxs(we,{variant:"warning",className:"cursor-pointer",children:[t.jsx(Ta,{size:10}),f?"Update Available":"Downloading…"]})}):h?t.jsxs("span",{className:"text-text-4 px-2",children:["v",h]}):null,!O&&t.jsxs("a",{href:"https://docs.groovedev.ai",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 px-2 h-full text-text-3 hover:text-text-1 hover:bg-surface-5 transition-colors no-underline",children:[t.jsx(_o,{size:12}),t.jsx("span",{children:"Docs"})]}),t.jsxs("button",{onClick:c,className:G("flex items-center gap-1.5 px-2 h-full transition-colors cursor-pointer",o?"text-accent bg-accent/8 hover:bg-accent/12":"text-text-3 hover:text-text-1 hover:bg-surface-5"),children:[t.jsx(cs,{size:12}),t.jsx("span",{children:"Terminal"}),t.jsx("kbd",{className:"font-mono text-text-4 ml-0.5",children:"Cmd+J"})]}),t.jsx(uQe,{})]})}function pQe({children:e,width:a,onWidthChange:n,onClose:s,className:o}){const c=g.useRef(!1),l=g.useRef(0),d=g.useRef(0),h=g.useCallback(f=>{f.preventDefault(),c.current=!0,l.current=f.clientX,d.current=a;function x(y){if(!c.current)return;const k=l.current-y.clientX,O=Math.min(Math.max(d.current+k,380),window.innerWidth*.65);n(O)}function m(){c.current=!1,document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",m)}document.addEventListener("mousemove",x),document.addEventListener("mouseup",m)},[a,n]);return t.jsxs("aside",{className:G("flex-shrink-0 flex bg-surface-1 border-l border-border relative",o),style:{width:a},children:[t.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1 cursor-col-resize hover:bg-accent/30 transition-colors z-10",onMouseDown:h}),t.jsx("button",{onClick:s,className:"absolute top-3 right-3 z-10 p-1 rounded-md text-text-3 hover:text-text-0 hover:bg-surface-5 transition-colors cursor-pointer",children:t.jsx(Ge,{size:14})}),t.jsx("div",{className:"flex-1 overflow-y-auto overflow-x-hidden",children:e})]})}const fQe=[{id:"nav:agents",label:"Go to Agents",icon:ru,category:"Navigation",action:e=>{e.setActiveView("agents")}},{id:"nav:editor",label:"Go to Editor",icon:Ft,category:"Navigation",action:e=>{e.setActiveView("editor")}},{id:"nav:dashboard",label:"Go to Dashboard",icon:G1,category:"Navigation",action:e=>{e.setActiveView("dashboard")}},{id:"nav:marketplace",label:"Go to Marketplace",icon:Au,category:"Navigation",action:e=>{e.setActiveView("marketplace")}},{id:"nav:teams",label:"Go to Teams",icon:Ba,category:"Navigation",action:e=>{e.setActiveView("teams")}},{id:"nav:federation",label:"Go to Federation",icon:ea,category:"Navigation",action:e=>{e.setActiveView("federation")}},{id:"action:whitelist",label:"Add to Federation Whitelist",icon:wa,category:"Federation",action:e=>{e.setActiveView("federation")}},{id:"action:spawn",label:"Spawn Agent",icon:gt,category:"Actions",action:e=>{e.openDetail({type:"spawn"})}},{id:"action:terminal",label:"Toggle Terminal",icon:cs,category:"Actions",action:e=>{e.setTerminalVisible(!e.terminalVisible)},shortcut:"Cmd+J"},{id:"action:journalist",label:"Toggle Journalist",icon:Uo,category:"Actions",action:e=>{var a;((a=e.detailPanel)==null?void 0:a.type)==="journalist"?e.closeDetail():e.openDetail({type:"journalist"})}}];function xQe(){const e=$(O=>O.commandPaletteOpen),a=$(O=>O.toggleCommandPalette),n=$(O=>O.agents),s=$(O=>O.savedTunnels),o=$,[c,l]=g.useState(""),[d,h]=g.useState(0),f=g.useRef(null),x=g.useMemo(()=>{var j;const O=n.flatMap(S=>[{id:`chat:${S.id}`,label:`Chat with ${S.name}`,icon:mn,category:"Agents",action:Q=>{Q.selectAgent(S.id)}},...S.status==="running"?[{id:`rotate:${S.id}`,label:`Rotate ${S.name}`,icon:Sr,category:"Agents",action:Q=>{Q.rotateAgent(S.id)}},{id:`kill:${S.id}`,label:`Kill ${S.name}`,icon:vd,category:"Agents",action:Q=>{Q.killAgent(S.id)}}]:[]]),w=[{id:"action:quickconnect",label:"Quick Connect",icon:Fn,category:"Remote",action:S=>{S.toggleQuickConnect()}},...s.map(S=>S.active?{id:`tunnel:open:${S.id}`,label:`Open ${S.name}`,icon:ha,category:"Remote",action:()=>{window.open(`http://localhost:${S.localPort}?instance=${encodeURIComponent(S.name)}`,"_blank")}}:{id:`tunnel:connect:${S.id}`,label:`Connect to ${S.name}`,icon:Fn,category:"Remote",action:Q=>{Q.connectTunnel(S.id)}})],C=(j=window.groove)!=null&&j.openFolder?[{id:"action:openfolder",label:"Open Folder",icon:pa,category:"Window",shortcut:"Cmd+O",action:()=>window.groove.openFolder()}]:[];return[...fQe,...C,...O,...w]},[n,s]),m=g.useMemo(()=>{if(!c.trim())return x.slice(0,12);const O=c.toLowerCase();return x.filter(w=>w.label.toLowerCase().includes(O)||w.category.toLowerCase().includes(O)).slice(0,12)},[x,c]);g.useEffect(()=>{e&&(l(""),h(0),setTimeout(()=>{var O;return(O=f.current)==null?void 0:O.focus()},50))},[e]),g.useEffect(()=>{d>=m.length&&h(Math.max(0,m.length-1))},[m.length,d]);function y(O){O.action(o.getState()),a()}function k(O){O.key==="ArrowDown"?(O.preventDefault(),h(w=>Math.min(w+1,m.length-1))):O.key==="ArrowUp"?(O.preventDefault(),h(w=>Math.max(w-1,0))):O.key==="Enter"&&m[d]?(O.preventDefault(),y(m[d])):O.key==="Escape"&&a()}return e?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-50 bg-black/40 backdrop-blur-sm",onClick:a}),t.jsx(Su,{children:t.jsxs(Hn.div,{initial:{opacity:0,y:-20,scale:.96},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-10,scale:.98},transition:{duration:.15},className:"fixed top-[15%] left-1/2 -translate-x-1/2 z-50 w-[480px] max-h-[400px] bg-surface-1 border border-border rounded-lg shadow-2xl overflow-hidden",onKeyDown:k,children:[t.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border-subtle",children:[t.jsx(ta,{size:16,className:"text-text-3 flex-shrink-0"}),t.jsx("input",{ref:f,value:c,onChange:O=>{l(O.target.value),h(0)},placeholder:"Type a command...",className:"flex-1 bg-transparent text-xs text-text-0 font-sans placeholder:text-text-4 focus:outline-none"})]}),t.jsxs("div",{className:"overflow-y-auto max-h-[320px] py-1",children:[m.length===0&&t.jsx("div",{className:"px-4 py-6 text-sm text-text-3 text-center font-sans",children:"No results"}),m.map((O,w)=>t.jsxs("button",{onClick:()=>y(O),onMouseEnter:()=>h(w),className:G("w-full flex items-center gap-3 px-4 py-2 text-sm font-sans cursor-pointer",w===d?"bg-surface-5 text-text-0":"text-text-1 hover:bg-surface-4"),children:[t.jsx(O.icon,{size:16,className:"text-text-3 flex-shrink-0"}),t.jsx("span",{className:"flex-1 text-left",children:O.label}),t.jsx("span",{className:"text-2xs text-text-4",children:O.category}),O.shortcut&&t.jsx("kbd",{className:"text-2xs font-mono bg-surface-4 px-1 py-0.5 rounded text-text-3 ml-1",children:O.shortcut})]},O.id))]})]})})]}):null}function mQe(){const e=$(s=>s.pendingApprovals),a=$(s=>s.approveRequest),n=$(s=>s.rejectRequest);return e!=null&&e.length?t.jsx("div",{className:"fixed bottom-10 left-1/2 -translate-x-1/2 z-50 w-full max-w-md flex flex-col gap-2 px-4",children:t.jsx(Su,{children:e.map(s=>{var o;return t.jsxs(Hn.div,{initial:{y:20,opacity:0},animate:{y:0,opacity:1},exit:{y:20,opacity:0},transition:{duration:.2},className:"rounded-lg border border-accent/30 bg-surface-2/95 backdrop-blur-md shadow-xl shadow-accent/5 overflow-hidden",children:[t.jsxs("div",{className:"px-4 py-3 flex items-start gap-3",children:[t.jsx(oa,{size:16,className:"text-warning shrink-0 mt-0.5"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("p",{className:"text-sm font-semibold text-text-0 font-sans truncate",children:[s.agentName||"Agent"," needs approval"]}),((o=s.action)==null?void 0:o.description)&&t.jsx("p",{className:"text-2xs text-text-3 font-sans mt-0.5 line-clamp-2",children:s.action.description})]})]}),t.jsxs("div",{className:"px-4 py-2.5 border-t border-border-subtle flex items-center justify-end gap-2",children:[t.jsxs(pe,{size:"sm",variant:"ghost",className:"text-danger hover:bg-danger/10",onClick:()=>n(s.id),children:[t.jsx(vr,{size:14,className:"mr-1"}),"Reject"]}),t.jsxs(pe,{size:"sm",variant:"accent",onClick:()=>a(s.id),children:[t.jsx(du,{size:14,className:"mr-1"}),"Approve"]})]})]},s.id)})})}):null}function gQe({path:e,onNavigate:a}){const n=e.split("/").filter(Boolean);return t.jsxs("div",{className:"flex items-center gap-0.5 min-w-0 overflow-x-auto py-1.5 scrollbar-none",children:[t.jsx("button",{onClick:()=>a("/"),className:"flex-shrink-0 p-1 rounded hover:bg-surface-5 cursor-pointer text-text-3 hover:text-text-0 transition-colors",children:t.jsx(jr,{size:13})}),n.map((s,o)=>{const c="/"+n.slice(0,o+1).join("/"),l=o===n.length-1;return t.jsxs("div",{className:"flex items-center gap-0.5 flex-shrink-0",children:[t.jsx(Yt,{size:11,className:"text-text-4"}),t.jsx("button",{onClick:()=>a(c),className:G("px-1.5 py-0.5 rounded text-xs font-mono cursor-pointer transition-colors",l?"text-text-0 bg-surface-4 font-medium":"text-text-3 hover:text-text-0 hover:bg-surface-5"),children:s})]},o)})]})}function Lu({open:e,onOpenChange:a,currentPath:n,onSelect:s,homePath:o,mandatory:c=!1,title:l}){const d=o||"/home",[h,f]=g.useState(n||d),[x,m]=g.useState([]),[y,k]=g.useState(!1),[O,w]=g.useState(null);g.useEffect(()=>{e&&C(n||d)},[e]);async function C(B){k(!0),w(null);try{const M=await D.get(`/browse-system?path=${encodeURIComponent(B)}`);f(M.current||B),m(M.dirs||[])}catch(M){w(M.message),m([])}k(!1)}function j(){const B=h==="/"?"/":h.split("/").slice(0,-1).join("/")||"/";C(B)}function S(){C(d)}function Q(){s(h),c||a(!1)}const N=l||(c?"Select Project Directory":"Select Working Directory"),L=c?{onEscapeKeyDown:B=>B.preventDefault(),onInteractOutside:B=>B.preventDefault(),onPointerDownOutside:B=>B.preventDefault()}:{};return t.jsx(Rt,{open:e,onOpenChange:c?()=>{}:a,children:t.jsxs(Ht,{title:c?void 0:N,description:"Choose a directory for this agent to work in",className:"max-w-[520px]",...L,children:[c&&t.jsxs("div",{className:"px-5 py-4 border-b border-border-subtle",children:[t.jsx("div",{className:"text-base font-semibold text-text-0 font-sans",children:N}),t.jsx("div",{className:"text-xs text-text-3 font-sans mt-1",children:"Pick a directory on this remote machine to get started."})]}),t.jsxs("div",{className:"px-5 py-4 space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:j,disabled:h==="/",className:"p-1.5 rounded-md bg-surface-4 border border-border text-text-2 hover:text-text-0 hover:bg-surface-5 transition-colors cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed",children:t.jsx(D1,{size:14})}),t.jsx("button",{onClick:S,className:"p-1.5 rounded-md bg-surface-4 border border-border text-text-2 hover:text-text-0 hover:bg-surface-5 transition-colors cursor-pointer",children:t.jsx(mo,{size:14})}),t.jsx("div",{className:"flex-1 min-w-0 bg-surface-0 rounded-md border border-border-subtle px-2",children:t.jsx(gQe,{path:h,onNavigate:C})})]}),t.jsx("div",{className:"bg-surface-0 rounded-lg border border-border-subtle overflow-hidden",children:t.jsxs("div",{className:"max-h-[340px] overflow-y-auto",children:[y&&t.jsx("div",{className:"flex items-center justify-center py-8",children:t.jsx(ze,{size:18,className:"text-text-3 animate-spin"})}),O&&t.jsx("div",{className:"px-4 py-6 text-center",children:t.jsx("p",{className:"text-xs text-danger font-sans",children:O})}),!y&&!O&&x.length===0&&t.jsx("div",{className:"px-4 py-6 text-center",children:t.jsx("p",{className:"text-xs text-text-3 font-sans",children:"No subdirectories"})}),!y&&!O&&x.map(B=>t.jsxs("button",{onClick:()=>C(B.path),className:G("w-full flex items-center gap-2.5 px-3.5 py-2 text-left cursor-pointer","hover:bg-surface-4 transition-colors border-b border-border-subtle last:border-0"),children:[B.hasChildren?t.jsx(r0,{size:15,className:"text-warning flex-shrink-0"}):t.jsx(pa,{size:15,className:"text-text-3 flex-shrink-0"}),t.jsx("span",{className:"text-sm text-text-0 font-sans truncate flex-1",children:B.name}),B.hasChildren&&t.jsx(Yt,{size:12,className:"text-text-4 flex-shrink-0"})]},B.path))]})}),t.jsxs("div",{className:"flex items-center gap-3 bg-surface-4/50 rounded-lg px-3.5 py-2.5 border border-border-subtle",children:[t.jsx(pa,{size:16,className:"text-accent flex-shrink-0"}),t.jsx("span",{className:"text-xs font-mono text-text-1 truncate flex-1",children:h})]}),t.jsxs("div",{className:"flex justify-end gap-2",children:[!c&&t.jsx(pe,{variant:"ghost",size:"md",onClick:()=>a(!1),children:"Cancel"}),t.jsxs(pe,{variant:"primary",size:"md",onClick:Q,className:"gap-1.5",children:[t.jsx(Re,{size:14})," Select Folder"]})]})]})]})})}const gD=[{id:"details",label:"Server Details",icon:Kt},{id:"auth",label:"Authentication",icon:nu},{id:"setup",label:"Setup",icon:Nr},{id:"connected",label:"Connected",icon:ra}];function yQe({steps:e,currentStep:a,completedSteps:n,onStepClick:s}){return t.jsx("div",{className:"flex items-center gap-1 mb-4",children:e.map((o,c)=>{const l=a===c,d=n.includes(c),h=d||c<a;return o.icon,t.jsxs("div",{className:"flex items-center gap-1 flex-1",children:[t.jsxs("button",{onClick:()=>h&&s(c),disabled:!h,className:G("flex items-center gap-1.5 px-2 py-1 rounded-md transition-colors text-2xs font-sans font-medium",l?"bg-accent/12 text-accent":d?"text-success cursor-pointer hover:bg-surface-3":"text-text-4",h&&!l&&"cursor-pointer"),children:[t.jsx("div",{className:G("w-5 h-5 rounded-full flex items-center justify-center text-2xs font-semibold border transition-colors",l?"border-accent bg-accent/15 text-accent":d?"border-success/40 bg-success/10 text-success":"border-border-subtle bg-surface-3 text-text-4"),children:d?t.jsx(Re,{size:10}):c+1}),t.jsx("span",{className:"hidden sm:inline",children:o.label})]}),c<e.length-1&&t.jsx("div",{className:G("flex-1 h-px mx-1",d?"bg-success/30":"bg-border-subtle")})]},o.id)})})}function yD({value:e,onChange:a}){return t.jsx("button",{onClick:()=>a(!e),className:G("w-9 h-5 rounded-full p-0.5 transition-colors cursor-pointer",e?"bg-accent":"bg-surface-5"),children:t.jsx("div",{className:G("w-4 h-4 rounded-full bg-white shadow-sm transition-transform",e?"translate-x-4":"translate-x-0")})})}function Lp({icon:e,title:a,children:n}){return t.jsxs("div",{className:"rounded-lg border border-border-subtle bg-surface-1 px-4 py-3.5 flex flex-col gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-6 h-6 rounded bg-accent/8 flex items-center justify-center flex-shrink-0",children:t.jsx(e,{size:12,className:"text-accent"})}),t.jsx("span",{className:"text-[13px] font-medium text-text-0 font-sans leading-tight",children:a})]}),t.jsx("div",{className:"mt-1",children:n})]})}function vQe({server:e,onSave:a,onTest:n,onConnect:s,onCancel:o}){const c=$(Ae=>Ae.remoteHomedir),[l,d]=g.useState(0),[h,f]=g.useState([]),[x,m]=g.useState(""),[y,k]=g.useState(""),[O,w]=g.useState(""),[C,j]=g.useState(22),[S,Q]=g.useState(""),[N,L]=g.useState(!1),[B,M]=g.useState(!1),[I,F]=g.useState(!1),[E,V]=g.useState(!1),[Z,X]=g.useState(null),[q,H]=g.useState(!1),[T,R]=g.useState(!1);g.useEffect(()=>{e?(m(e.name||""),k(e.host||""),w(e.user||""),j(e.port||22),Q(e.sshKeyPath||""),L(e.autoStart||!1),M(e.autoConnect||!1),f([0,1]),d(2)):(m(""),k(""),w(""),j(22),Q(""),L(!1),M(!1),f([]),d(0))},[e]);function U(){const Ae={name:x.trim(),host:y.trim(),user:O.trim(),port:C,sshKeyPath:S.trim(),autoStart:N,autoConnect:B};return e!=null&&e.id&&(Ae.id=e.id),Ae}function z(){return x.trim()&&y.trim()&&O.trim()}function Y(){l===0&&!z()||(f(Ae=>Ae.includes(l)?Ae:[...Ae,l]),d(Ae=>Math.min(Ae+1,gD.length-1)))}function ue(){d(Ae=>Math.max(Ae-1,0))}async function W(){V(!0),X(null);try{const Ae=U();H(!0),await a(Ae),H(!1);const Qe=await n();X(Qe)}catch(Ae){X({error:Ae.message||"Test failed"}),H(!1)}V(!1)}async function re(){H(!0);try{const Ae=U();await a(Ae),f(Qe=>Qe.includes(l)?Qe:[...Qe,l]),d(2)}catch(Ae){X({error:Ae.message||"Save failed"})}H(!1)}async function xe(){var Ae;R(!0);try{const Qe=U();await a(Qe),await s(),f(ee=>[...new Set([...ee,2])]),d(3)}catch(Qe){let ee=((Ae=Qe==null?void 0:Qe.body)==null?void 0:Ae.error)||(Qe==null?void 0:Qe.message)||"Connection failed";ee.toLowerCase().includes("port forward")&&(ee+=" — Check that the remote server is reachable and SSH port forwarding is allowed."),X({error:ee})}R(!1)}const ve="h-8 px-2.5 text-xs bg-surface-0 border border-border-subtle rounded-md text-text-0 font-sans placeholder:text-text-4 focus:outline-none focus:ring-1 focus:ring-accent",ie="h-8 px-2.5 text-xs bg-surface-0 border border-border-subtle rounded-md text-text-0 font-mono placeholder:text-text-4 focus:outline-none focus:ring-1 focus:ring-accent";return t.jsxs("div",{className:"p-4",children:[t.jsx(yQe,{steps:gD,currentStep:l,completedSteps:h,onStepClick:d}),l===0&&t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsx(Lp,{icon:Kt,title:"Server Info",children:t.jsxs("div",{className:"space-y-2.5",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-2xs font-semibold text-text-2 font-sans mb-1 block",children:"Name"}),t.jsx("input",{value:x,onChange:Ae=>m(Ae.target.value),placeholder:"api-vps",className:G(ve,"w-full"),autoFocus:!0})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-2xs font-semibold text-text-2 font-sans mb-1 block",children:"Host"}),t.jsx("input",{value:y,onChange:Ae=>k(Ae.target.value),placeholder:"165.22.180.45",className:G(ie,"w-full")})]})]})}),t.jsx(Lp,{icon:Nr,title:"Connection",children:t.jsxs("div",{className:"space-y-2.5",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-2xs font-semibold text-text-2 font-sans mb-1 block",children:"User"}),t.jsx("input",{value:O,onChange:Ae=>w(Ae.target.value),placeholder:"root",className:G(ie,"w-full")})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-2xs font-semibold text-text-2 font-sans mb-1 block",children:"SSH Port"}),t.jsx("input",{value:C,onChange:Ae=>j(Number(Ae.target.value)||22),type:"number",className:G(ie,"w-24")})]})]})})]}),l===1&&t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsx(Lp,{icon:nu,title:"SSH Key",children:t.jsxs("div",{className:"space-y-2.5",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-2xs font-semibold text-text-2 font-sans mb-1 block",children:"Key Path"}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("input",{value:S,onChange:Ae=>Q(Ae.target.value),placeholder:"~/.ssh/id_ed25519",className:G(ie,"flex-1 min-w-0"),autoFocus:!0}),t.jsx(pe,{variant:"secondary",size:"sm",onClick:()=>F(!0),className:"h-8 px-2 flex-shrink-0",children:t.jsx(pd,{size:12})})]}),t.jsx("p",{className:"text-2xs text-text-4 font-sans mt-1",children:"Leave blank to use default SSH agent."})]}),t.jsxs(pe,{variant:"secondary",size:"sm",onClick:W,disabled:E,className:"h-7 text-2xs gap-1.5",children:[E?t.jsx(ze,{size:11,className:"animate-spin"}):t.jsx(ra,{size:11}),"Test Connection"]})]})}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"rounded-lg border border-border-subtle bg-surface-1 px-4 py-3.5",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("div",{className:"w-6 h-6 rounded bg-accent/8 flex items-center justify-center flex-shrink-0",children:t.jsx(Kt,{size:12,className:"text-accent"})}),t.jsx("span",{className:"text-[13px] font-medium text-text-0 font-sans",children:"Target"})]}),t.jsxs("div",{className:"space-y-1.5 text-2xs font-sans",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-text-3",children:"Host"}),t.jsx("span",{className:"text-text-1 font-mono",children:y||"—"})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-text-3",children:"User"}),t.jsx("span",{className:"text-text-1 font-mono",children:O||"—"})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-text-3",children:"Port"}),t.jsx("span",{className:"text-text-1 font-mono",children:C})]})]})]}),Z&&t.jsx("div",{className:G("px-3 py-2.5 rounded-lg text-2xs font-sans flex items-start gap-2",Z.error?"bg-danger/8 border border-danger/20 text-danger":Z.reachable?"bg-success/8 border border-success/20 text-success":"bg-warning/8 border border-warning/20 text-warning"),children:Z.error?t.jsxs(t.Fragment,{children:[t.jsx(Ge,{size:11,className:"mt-0.5 flex-shrink-0"})," ",Z.error]}):Z.reachable?t.jsxs(t.Fragment,{children:[t.jsx(Re,{size:11,className:"mt-0.5 flex-shrink-0"})," Server reachable"]}):t.jsxs(t.Fragment,{children:[t.jsx(oa,{size:11,className:"mt-0.5 flex-shrink-0"})," Host unreachable"]})})]}),t.jsx(Lu,{open:I,onOpenChange:F,currentPath:S||"~/.ssh",homePath:c,onSelect:Ae=>Q(Ae)})]}),l===2&&t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsx(Lp,{icon:Nr,title:"Behavior",children:t.jsxs("div",{className:"space-y-3",children:[t.jsxs("label",{className:"flex items-center justify-between cursor-pointer",children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-xs text-text-1 font-sans block",children:"Auto-start daemon"}),t.jsx("span",{className:"text-2xs text-text-4 font-sans",children:"Start Groove on the remote when connecting"})]}),t.jsx(yD,{value:N,onChange:L})]}),t.jsxs("label",{className:"flex items-center justify-between cursor-pointer",children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-xs text-text-1 font-sans block",children:"Auto-connect on launch"}),t.jsx("span",{className:"text-2xs text-text-4 font-sans",children:"Connect when Groove starts"})]}),t.jsx(yD,{value:B,onChange:M})]})]})}),Z&&!Z.error&&t.jsxs("div",{className:"rounded-lg border border-border-subtle bg-surface-1 px-4 py-3.5",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[t.jsx("div",{className:"w-6 h-6 rounded bg-success/10 flex items-center justify-center flex-shrink-0",children:t.jsx(Re,{size:12,className:"text-success"})}),t.jsx("span",{className:"text-[13px] font-medium text-text-0 font-sans",children:"Test Results"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2 text-2xs font-sans",children:[t.jsx(aa,{status:Z.reachable?"running":"crashed",size:"sm"}),t.jsx("span",{className:"text-text-1",children:"Reachable"})]}),t.jsxs("div",{className:"flex items-center gap-2 text-2xs font-sans",children:[t.jsx(aa,{status:Z.grooveInstalled?"running":"stopped",size:"sm"}),t.jsx("span",{className:"text-text-1",children:"Groove Installed"})]}),t.jsxs("div",{className:"flex items-center gap-2 text-2xs font-sans",children:[t.jsx(aa,{status:Z.daemonRunning?"running":"stopped",size:"sm"}),t.jsx("span",{className:"text-text-1",children:"Daemon Running"})]})]})]}),(!Z||Z.error)&&t.jsxs("div",{className:"rounded-lg border border-border-subtle bg-surface-1 px-4 py-3.5",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("div",{className:"w-6 h-6 rounded bg-accent/8 flex items-center justify-center flex-shrink-0",children:t.jsx(Kt,{size:12,className:"text-accent"})}),t.jsx("span",{className:"text-[13px] font-medium text-text-0 font-sans",children:x||"Server"})]}),t.jsxs("div",{className:"space-y-1.5 text-2xs font-sans",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-text-3",children:"Connection"}),t.jsxs("span",{className:"text-text-1 font-mono",children:[O,"@",y,":",C]})]}),S&&t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-text-3",children:"SSH Key"}),t.jsx("span",{className:"text-text-1 font-mono truncate max-w-40",children:S})]})]})]})]}),l===3&&t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{className:"rounded-lg border border-success/30 bg-success/5 px-4 py-5 text-center",children:[t.jsx("div",{className:"w-10 h-10 rounded-full bg-success/15 flex items-center justify-center mx-auto mb-3",children:t.jsx(Re,{size:20,className:"text-success"})}),t.jsx("h3",{className:"text-sm font-semibold text-text-0 font-sans mb-1",children:"Connected"}),t.jsxs("p",{className:"text-2xs text-text-3 font-sans",children:["Successfully connected to ",t.jsx("span",{className:"font-mono text-text-1",children:x})]}),t.jsxs(pe,{variant:"primary",size:"sm",onClick:()=>{const Ae=e==null?void 0:e.localPort,Qe=encodeURIComponent(x);window.open(`http://localhost:${Ae}?instance=${Qe}`,"_blank")},className:"h-8 text-xs gap-1.5 mt-4",children:[t.jsx(ha,{size:12}),"Open Remote GUI"]})]}),t.jsxs("div",{className:"rounded-lg border border-border-subtle bg-surface-1 px-4 py-3.5",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[t.jsx("div",{className:"w-6 h-6 rounded bg-accent/8 flex items-center justify-center flex-shrink-0",children:t.jsx(Kt,{size:12,className:"text-accent"})}),t.jsx("span",{className:"text-[13px] font-medium text-text-0 font-sans",children:"Connection Info"})]}),t.jsxs("div",{className:"space-y-1.5 text-2xs font-sans",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-text-3",children:"Connection"}),t.jsxs("span",{className:"text-text-1 font-mono",children:[O,"@",y,":",C]})]}),S&&t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-text-3",children:"SSH Key"}),t.jsx("span",{className:"text-text-1 font-mono truncate max-w-40",children:S})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-text-3",children:"Auto-start"}),t.jsx("span",{className:"text-text-1",children:N?"On":"Off"})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-text-3",children:"Auto-connect"}),t.jsx("span",{className:"text-text-1",children:B?"On":"Off"})]}),(e==null?void 0:e.remoteVersion)&&t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-text-3",children:"Version"}),t.jsxs("span",{className:G("text-text-1 font-mono",e.versionMatch===!1&&"text-warning"),children:["v",e.remoteVersion,e.versionMatch===!1&&" (update available)"]})]})]})]})]}),t.jsxs("div",{className:"flex items-center justify-between mt-4",children:[t.jsx(pe,{variant:"ghost",size:"sm",onClick:l===0||l===3?o:ue,className:"h-8 text-xs px-4 text-text-3",children:l===0?"Cancel":l===3?"Done":"Back"}),l<3&&t.jsx("div",{className:"flex gap-2",children:l===2?t.jsxs(pe,{variant:"primary",size:"sm",onClick:xe,disabled:T||q,className:"h-8 text-xs px-4 gap-1.5",children:[T?t.jsx(ze,{size:12,className:"animate-spin"}):t.jsx(ra,{size:12}),T?"Connecting...":"Connect"]}):l===1?t.jsx(pe,{variant:"primary",size:"sm",onClick:re,disabled:q,className:"h-8 text-xs px-4",children:q?"Saving...":"Next"}):t.jsx(pe,{variant:"primary",size:"sm",onClick:Y,disabled:!z(),className:"h-8 text-xs px-4",children:"Next"})})]})]})}function BG(){const e=$(y=>y.quickConnectOpen),a=$(y=>y.toggleQuickConnect),n=$(y=>y.savedTunnels),s=$(y=>y.addToast),[o,c]=g.useState(null),[l,d]=g.useState(!1),h=g.useRef(null);if(!e)return null;async function f(y){c(y);try{await $.getState().connectTunnel(y);const k=n.find(O=>O.id===y);k!=null&&k.host&&s("info",`Add ${k.host} to Federation Whitelist?`,"",{label:"Add",onClick:()=>$.getState().addToWhitelist(k.host)}),c(null);return}catch(k){let O=(k==null?void 0:k.message)||"Unknown error";O.toLowerCase().includes("port forward")&&(O+=" — Try testing the connection first, or check your SSH key configuration."),s("error","Connection failed",O)}c(null)}function x(y){var k,O;if((O=(k=window.groove)==null?void 0:k.remote)!=null&&O.openWindow)window.groove.remote.openWindow(y.localPort,y.name);else{const w=encodeURIComponent(y.name);window.open(`http://localhost:${y.localPort}?instance=${w}`,"_blank")}a()}function m(){d(!1),a()}return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-50 bg-black/40 backdrop-blur-sm",onClick:m}),t.jsx(Su,{children:t.jsxs(Hn.div,{initial:{opacity:0,y:-20,scale:.96},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-10,scale:.98},transition:{duration:.15},className:G("fixed top-[15%] left-1/2 -translate-x-1/2 z-50 bg-surface-1 border border-border rounded-lg shadow-2xl overflow-hidden",l?"w-[520px]":"w-[400px]"),children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border-subtle",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[l&&t.jsx("button",{onClick:()=>d(!1),className:"p-1 -ml-1 text-text-4 hover:text-text-1 cursor-pointer transition-colors",children:t.jsx(q1,{size:14})}),t.jsx(Fn,{size:15,className:"text-accent"}),t.jsx("span",{className:"text-sm font-semibold text-text-0 font-sans",children:l?"Add Connection":"Quick Connect"})]}),t.jsx("button",{onClick:m,className:"p-1 text-text-4 hover:text-text-1 cursor-pointer transition-colors",children:t.jsx(Ge,{size:14})})]}),l?t.jsx(vQe,{server:null,onSave:async y=>{const k=y.id||h.current;if(k)await $.getState().updateTunnel(k,y),s("success","Server updated");else{const O=await $.getState().saveTunnel(y);O!=null&&O.id&&(h.current=O.id),s("success","Server added")}},onTest:()=>{const y=h.current;if(y)return $.getState().testTunnel(y)},onConnect:()=>{const y=h.current;if(y)return $.getState().connectTunnel(y)},onCancel:()=>{h.current=null,d(!1)}}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"overflow-y-auto max-h-[320px] py-1",children:n.length===0?t.jsxs("div",{className:"px-4 py-8 text-center",children:[t.jsx(Kt,{size:24,className:"text-text-4 mx-auto mb-2"}),t.jsx("p",{className:"text-sm text-text-3 font-sans",children:"No saved servers"}),t.jsx("p",{className:"text-2xs text-text-4 font-sans mt-1",children:"Add a connection to get started."}),t.jsxs(pe,{variant:"primary",size:"sm",onClick:()=>{h.current=null,d(!0)},className:"h-8 text-xs gap-1.5 mt-3",children:[t.jsx(gt,{size:12})," Add Connection"]})]}):n.map(y=>t.jsxs("div",{className:G("w-full flex items-center gap-3 px-4 py-2.5 transition-colors","hover:bg-surface-5",o===y.id&&"opacity-60 pointer-events-none"),children:[t.jsx(Kt,{size:15,className:y.active?"text-success":"text-text-4"}),t.jsxs("button",{onClick:()=>y.active?x(y):f(y.id),disabled:o===y.id,className:"flex-1 min-w-0 text-left cursor-pointer",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-medium text-text-0 font-sans truncate",children:y.name}),y.active&&t.jsx(aa,{status:"running",size:"sm"}),y.remoteVersion&&t.jsxs("span",{className:"text-2xs font-mono text-text-4 ml-1",children:["v",y.remoteVersion]})]}),t.jsxs("span",{className:"text-2xs text-text-4 font-mono",children:[y.user,"@",y.host]})]}),t.jsx("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:o===y.id?t.jsx(ze,{size:14,className:"text-text-3 animate-spin"}):y.active?t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:()=>x(y),className:"flex items-center gap-1 text-2xs text-success font-sans hover:text-success/80 cursor-pointer transition-colors",children:[t.jsx(ha,{size:11})," Open"]}),y.versionMatch===!1&&t.jsxs("button",{onClick:async()=>{try{await $.getState().upgradeTunnel(y.id),s("success","Upgrade started")}catch(k){s("error","Upgrade failed",k.message)}},className:"flex items-center gap-1 text-2xs text-warning font-sans hover:text-warning/80 cursor-pointer transition-colors",title:`Update remote from v${y.remoteVersion} to v${y.localVersion}`,children:[t.jsx(Ta,{size:11})," Update"]}),t.jsx("button",{onClick:async()=>{await $.getState().disconnectTunnel(y.id),s("info","Disconnected",y.name)},className:"p-1 text-text-4 hover:text-danger cursor-pointer transition-colors rounded",title:"Disconnect",children:t.jsx(Fo,{size:12})}),t.jsx("button",{onClick:k=>{k.stopPropagation(),$.getState().deleteTunnel(y.id)},className:"p-1 text-text-4 hover:text-danger cursor-pointer transition-colors rounded",title:"Delete connection",children:t.jsx(ht,{size:12})})]}):t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>f(y.id),className:"text-2xs text-text-3 font-sans hover:text-text-1 cursor-pointer transition-colors",children:"Connect"}),t.jsx("button",{onClick:k=>{k.stopPropagation(),$.getState().deleteTunnel(y.id)},className:"p-1 text-text-4 hover:text-danger cursor-pointer transition-colors rounded",title:"Delete connection",children:t.jsx(ht,{size:12})})]})})]},y.id))}),t.jsx("div",{className:"px-4 py-2.5 border-t border-border-subtle",children:t.jsxs("button",{onClick:()=>{h.current=null,d(!0)},className:"flex items-center gap-1.5 text-2xs text-accent hover:text-accent/80 font-sans font-medium cursor-pointer transition-colors",children:[t.jsx(gt,{size:10})," Add new connection"]})})]})]})})]})}const vD=[],kQe=/error|crash|fail/i,Tp="rgba(51, 175, 188, 0.15)",$p="h-[2px]";function OQe(e){if(!e||e==="auto")return"auto";const a=e.match(/^claude-(opus|sonnet|haiku)-(\d+)-(\d+)(?:-\d+)?$/);return a?`${a[1][0].toUpperCase()+a[1].slice(1)} ${a[2]}.${a[3]}`:e.startsWith("gemini-")?e.replace("gemini-","Gemini ").replace("-preview","").replace("-flash-lite"," Flash Lite").replace("-flash"," Flash").replace("-pro"," Pro"):e.startsWith("gpt-")?e.toUpperCase().replace("GPT-","GPT-"):e}function bQe(e){if(!e||e.length<2)return null;const a=e.slice(-10),n=(a[a.length-1].t-a[0].t)/6e4;return n<=0?null:(a[a.length-1].v-a[0].v)/n}function wQe(e){return e>=70?"var(--color-success)":e>=40?"var(--color-warning)":"var(--color-danger)"}function jQe(e){return e>=60?"var(--color-success)":e>=30?"var(--color-warning)":"var(--color-danger)"}const CQe={running:"LIVE",starting:"INIT",stopped:"IDLE",crashed:"ERR",completed:"DONE",killed:"KILL",rotating:"ROT"},_G=g.memo(({data:e,selected:a})=>{const{agent:n}=e,s=n.status==="running"||n.status==="starting",o=Math.round((n.contextUsage||0)*100),c=PE(n.status),l=n.tokensUsed||0,d=g.useRef(null),h=$(N=>!!N.expandedNodes[n.id]),f=$(N=>N.toggleNodeExpanded);g.useEffect(()=>{var L;const N=(L=d.current)==null?void 0:L.closest(".react-flow__node");N&&(N.style.zIndex=h?"1000":"")},[h]);const x=$(N=>N.activityLog[n.id])||vD,m=$(N=>N.tokenTimeline[n.id])||vD,y=bQe(m),k=g.useMemo(()=>x.filter(N=>kQe.test(N.text)).length,[x]),O=o>75?"var(--color-danger)":o>50?"var(--color-warning)":"var(--color-success)",w=n.qualityScore!=null?Math.round(n.qualityScore):null,C=w!=null?wQe(w):null,j=n.efficiency!=null?n.efficiency:null,S=j!=null?jQe(j):null,Q=n.durationMs?n.durationMs/1e3:n.spawnedAt?(Date.now()-new Date(n.spawnedAt).getTime())/1e3:n.createdAt?(Date.now()-new Date(n.createdAt).getTime())/1e3:0;return t.jsx("div",{ref:d,children:t.jsxs("div",{className:`w-[220px] overflow-hidden rounded-[4px] transition-all duration-200 ease-out bg-[#1c1f26] hover:bg-[#141720] border border-solid ${a?"border-[#2e323a]":"border-[#262a32]"} hover:border-[#2e3640]`,children:[t.jsx(Oo,{id:"top",type:"target",position:bo.Top,className:"!w-1 !h-1 !bg-transparent !border-0"}),t.jsx(Oo,{id:"bottom",type:"target",position:bo.Bottom,className:"!w-1 !h-1 !bg-transparent !border-0"}),t.jsx(Oo,{id:"left",type:"target",position:bo.Left,className:"!w-1 !h-1 !bg-transparent !border-0"}),t.jsx(Oo,{id:"right",type:"target",position:bo.Right,className:"!w-1 !h-1 !bg-transparent !border-0"}),s&&t.jsx("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",style:{borderRadius:3},children:t.jsx("div",{className:"absolute left-0 right-0 h-px",style:{background:"linear-gradient(90deg, transparent 0%, rgba(97,175,239,0.25) 50%, transparent 100%)",animation:"node-scan 3s ease-in-out infinite"}})}),t.jsxs("div",{className:"px-3 pt-2.5 pb-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{className:"relative flex-shrink-0 w-[6px] h-[6px]",children:[t.jsx("span",{className:"absolute inset-0 rounded-sm",style:{background:c}}),s&&t.jsx("span",{className:"absolute inset-[-2px] rounded-sm",style:{background:c,opacity:.15,animation:"node-pulse-bar 2s ease-in-out infinite"}})]}),t.jsx("span",{className:"text-[12px] font-semibold text-[#e6e6e6] font-sans truncate flex-1 leading-none",children:n.name}),t.jsx("span",{className:"text-[7px] font-mono font-bold uppercase tracking-wider px-1 py-px rounded-sm",style:{color:c,background:c+"12"},children:CQe[n.status]||n.status}),t.jsx("button",{className:"text-[#505862] hover:text-[#8b929e] cursor-pointer transition-colors flex-shrink-0",onClick:N=>{N.stopPropagation(),f(n.id)},children:h?t.jsx(Ge,{size:10}):t.jsx(xd,{size:10})})]}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-1.5",children:[t.jsx("span",{className:"text-[9px] font-mono text-[#505862] uppercase tracking-[0.05em]",children:n.role}),t.jsx("span",{className:"text-[9px] text-[#2a2e36]",children:"/"}),t.jsx("span",{className:"text-[9px] font-mono text-[#505862]",children:OQe(n.model)})]})]}),t.jsxs("div",{className:"px-3 pt-1 pb-2",children:[t.jsxs("div",{className:"flex items-baseline gap-1.5",children:[t.jsx("span",{className:"text-[14px] font-mono font-medium text-[#bcc2cd] leading-none",children:At(l)}),t.jsx("span",{className:"text-[8px] font-mono text-[#505862]",children:"tok"}),t.jsx("span",{className:"flex-1"}),t.jsxs("span",{className:"text-[9px] font-mono text-[#505862]",children:[o,"%"]})]}),t.jsx("div",{className:`mt-1.5 ${$p} rounded-sm overflow-hidden`,style:{background:Tp},children:t.jsx("div",{className:"h-full rounded-sm transition-all duration-700",style:{width:`${Math.max(o,1)}%`,background:o>80?"var(--color-danger)":o>60?"var(--color-warning)":"var(--color-accent)"}})})]}),t.jsx("div",{className:"grid transition-[grid-template-rows] duration-200 ease-out",style:{gridTemplateRows:h?"1fr":"0fr"},children:t.jsxs("div",{className:"overflow-hidden",children:[t.jsx("div",{className:"mx-3 border-t border-white/[0.04]"}),t.jsxs("div",{className:"px-3 pt-1.5 pb-1",children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("span",{className:"text-[9px] font-mono text-[#505862] uppercase tracking-wider",children:"Context"}),(n.rotations||0)>0&&t.jsxs("span",{className:"text-[8px] font-mono text-[#606878] bg-white/[0.04] rounded px-1 py-px",children:[n.rotations,"x rot"]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:`flex-1 ${$p} rounded-sm overflow-hidden`,style:{background:Tp},children:t.jsx("div",{className:"h-full rounded-sm transition-all duration-500",style:{width:`${Math.max(o,1)}%`,background:O}})}),t.jsxs("span",{className:"text-[9px] font-mono font-medium",style:{color:O},children:[o,"%"]})]})]}),t.jsxs("div",{className:"px-3 pt-1 pb-1",children:[t.jsx("span",{className:"text-[9px] font-mono text-[#505862] uppercase tracking-wider",children:"Quality"}),t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[t.jsx("div",{className:`flex-1 ${$p} rounded-sm overflow-hidden`,style:{background:Tp},children:t.jsx("div",{className:"h-full rounded-sm transition-all duration-500",style:{width:`${w!=null?Math.max(w,1):0}%`,background:C||"#505862"}})}),t.jsx("span",{className:"text-[9px] font-mono font-medium",style:{color:C||"#505862"},children:w??"—"})]})]}),t.jsxs("div",{className:"px-3 pt-1 pb-1",children:[t.jsx("span",{className:"text-[9px] font-mono text-[#505862] uppercase tracking-wider",children:"Efficiency"}),t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[t.jsx("div",{className:`flex-1 ${$p} rounded-sm overflow-hidden`,style:{background:Tp},children:t.jsx("div",{className:"h-full rounded-sm transition-all duration-500",style:{width:`${j!=null?Math.max(j,1):0}%`,background:S||"#505862"}})}),t.jsx("span",{className:"text-[9px] font-mono font-medium",style:{color:S||"#505862"},children:j!=null?`${j}%`:"—"})]})]}),t.jsx("div",{className:"px-3 pt-1 pb-1",children:t.jsxs("div",{className:"grid grid-cols-3 gap-1",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-[9px] font-mono font-medium text-[#bcc2cd]",children:Go(n.costUsd||0)}),t.jsx("div",{className:"text-[7px] font-mono text-[#505862]",children:"cost"})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-[9px] font-mono font-medium text-[#bcc2cd]",children:y?At(Math.round(y)):"—"}),t.jsx("div",{className:"text-[7px] font-mono text-[#505862]",children:"tok/m"})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-[9px] font-mono font-medium text-[#bcc2cd]",children:n.turns||0}),t.jsx("div",{className:"text-[7px] font-mono text-[#505862]",children:"turns"})]})]})}),t.jsx("div",{className:"px-3 pt-1 pb-2",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"text-[9px] font-mono text-[#8b929e]",children:Ud(Math.max(0,Math.floor(Q)))}),t.jsx("span",{className:"text-[7px] font-mono text-[#505862]",children:"up"})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[k>0?t.jsx("span",{className:"text-[9px] font-mono text-[var(--color-danger)]",children:k}):t.jsx("span",{className:"text-[9px] font-mono text-[#505862]",children:"0"}),t.jsx("span",{className:"text-[7px] font-mono text-[#505862]",children:"err"})]})]})})]})})]})})});_G.displayName="AgentNode";const LG=g.memo(({data:e})=>{const{agentCount:a,runningCount:n}=e,s=n>0,o={background:"transparent",border:0,width:2,height:2};return t.jsxs("div",{className:"relative flex items-center justify-center",style:{width:84,height:84},children:[t.jsx("div",{className:G("absolute inset-0 rounded-full transition-all duration-500",s&&"animate-[spin-slow_30s_linear_infinite]"),style:{border:`1px dashed ${s?"rgba(97,175,239,0.5)":"rgba(97,175,239,0.25)"}`}}),t.jsx("div",{className:"absolute inset-[10px] rounded-full",style:{background:s?"radial-gradient(circle, rgba(97,175,239,0.15) 0%, transparent 70%)":"radial-gradient(circle, rgba(97,175,239,0.05) 0%, transparent 70%)",animation:s?"node-pulse-bar 2.5s ease-in-out infinite":"none"}}),t.jsx("div",{className:G("w-14 h-14 rounded-full flex items-center justify-center relative z-10 transition-all duration-300",s?"bg-[#1c1f26] border-2 border-[#61afef]/35 shadow-[0_0_28px_rgba(97,175,239,0.15)]":"bg-[#1c1f26] border border-[#61afef]/20"),children:t.jsx("img",{src:"/favicon.png",alt:"G",className:G("h-7 w-7 rounded-full transition-opacity",s?"opacity-90":"opacity-60")})}),a>0&&t.jsx("div",{className:G("absolute z-20 min-w-[20px] h-[20px] rounded-sm flex items-center justify-center","text-[10px] font-mono font-bold px-1 transition-all duration-300",s?"bg-[#1c1f26] text-[#61afef] border border-[#61afef]/40":"bg-[#1c1f26] text-[#61afef]/60 border border-[#61afef]/20"),style:{bottom:2,right:2},children:a}),t.jsx(Oo,{id:"bottom",type:"source",position:bo.Bottom,style:o}),t.jsx(Oo,{id:"right",type:"source",position:bo.Right,style:o}),t.jsx(Oo,{id:"left",type:"source",position:bo.Left,style:o}),t.jsx(Oo,{id:"top",type:"source",position:bo.Top,style:o})]})});LG.displayName="RootNode";const MQe=[{id:"desktop",icon:Cr,label:"Desktop",width:"100%"},{id:"tablet",icon:j0,label:"Tablet (768px)",width:"768px"},{id:"mobile",icon:w0,label:"Mobile (375px)",width:"375px"}];function SQe({onRefresh:e}){const a=$(x=>x.previewState),n=$(x=>x.setPreviewDevice),s=$(x=>x.toggleScreenshotMode),o=$(x=>x.closePreview),[c,l]=g.useState(!1),d=g.useRef(null);g.useEffect(()=>()=>{d.current&&clearTimeout(d.current)},[]);function h(){c?(d.current&&clearTimeout(d.current),l(!1),o()):(l(!0),d.current=setTimeout(()=>l(!1),2e3))}const f=a.teamId?`${window.location.origin}/api/preview/${a.teamId}/proxy/`:a.url;return t.jsxs("div",{className:"h-10 flex items-center gap-2 px-3 bg-surface-3 border-b border-border flex-shrink-0",children:[t.jsx("div",{className:"flex-1 min-w-0 h-7 flex items-center px-3 rounded-md bg-surface-1 border border-border-subtle",children:t.jsx("span",{className:"text-2xs font-mono text-text-3 truncate",children:f||"No URL"})}),t.jsx("button",{onClick:e,className:"w-7 h-7 flex items-center justify-center rounded-md text-text-3 hover:text-accent hover:bg-accent/10 transition-colors cursor-pointer",title:"Refresh",children:t.jsx(ca,{size:14})}),t.jsx("div",{className:"flex items-center gap-0.5 px-1 py-0.5 rounded-md bg-surface-1 border border-border-subtle",children:MQe.map(x=>t.jsx("button",{onClick:()=>n(x.id),className:G("w-7 h-6 flex items-center justify-center rounded transition-colors cursor-pointer",a.deviceSize===x.id?"text-accent bg-accent/10":"text-text-3 hover:text-text-1"),title:x.label,children:t.jsx(x.icon,{size:13})},x.id))}),t.jsx("button",{onClick:s,className:G("w-7 h-7 flex items-center justify-center rounded-md transition-colors cursor-pointer",a.screenshotMode?"text-accent bg-accent/10":"text-text-3 hover:text-accent hover:bg-accent/10"),title:"Screenshot",children:t.jsx(Z1,{size:14})}),t.jsx("button",{onClick:h,className:G("h-7 flex items-center justify-center rounded-md transition-all cursor-pointer",c?"px-2 gap-1.5 bg-danger/15 text-danger border border-danger/25":"w-7 text-text-3 hover:text-danger hover:bg-danger/10"),title:"Close Preview",children:c?t.jsx("span",{className:"text-2xs font-semibold font-sans whitespace-nowrap",children:"Close?"}):t.jsx(Ge,{size:14})})]})}/*!
|
|
8614
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${a.docsSlug}`;return g.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},iQe="DialogDescriptionWarning",cQe=({contentRef:e,descriptionId:a})=>{const s=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${wG(iQe).contentName}}.`;return g.useEffect(()=>{var c;const o=(c=e.current)==null?void 0:c.getAttribute("aria-describedby");a&&o&&(document.getElementById(a)||console.warn(s))},[s,e,a]),null},jG=AG,lQe=uG,CG=pG,MG=fG,SG=xG,yT=gG,NG=vG,qE=OG;function Rt({children:e,...a}){return t.jsx(jG,{...a,children:e})}const QG=lQe;function Ht({children:e,className:a,title:n,description:s,...o}){return t.jsxs(CG,{children:[t.jsx(MG,{className:"fixed inset-0 z-50 bg-black/50 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"}),t.jsxs(SG,{className:G("fixed left-1/2 top-1/2 z-50 -translate-x-1/2 -translate-y-1/2","w-full max-w-lg max-h-[85vh] overflow-y-auto","bg-surface-1 border border-border rounded-lg shadow-2xl","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",a),...o,children:[n&&t.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-border-subtle",children:[t.jsx(yT,{className:"text-base font-semibold text-text-0 font-sans",children:n}),t.jsx(qE,{className:"p-1 rounded-md text-text-3 hover:text-text-0 hover:bg-surface-5 transition-colors",children:t.jsx(Ge,{size:16})})]}),s&&t.jsx(NG,{className:"sr-only",children:s}),e]})]})}const AQe={primary:"bg-accent/20 text-accent border border-accent/25 hover:bg-accent/30 font-medium",secondary:"bg-surface-5/40 text-text-1 border border-border-subtle hover:bg-surface-5/70 hover:text-text-0",ghost:"bg-transparent text-text-2 border border-transparent hover:bg-surface-5/50 hover:text-text-0",danger:"bg-danger/12 text-danger border border-danger/15 hover:bg-danger/20",info:"bg-info/12 text-info border border-info/15 hover:bg-info/20",outline:"bg-transparent text-accent border border-accent/30 hover:bg-accent/10"},dQe={sm:"h-7 px-2.5 text-xs gap-1.5 rounded",md:"h-8 px-3 text-sm gap-2 rounded",lg:"h-9 px-4 text-sm gap-2 rounded",icon:"h-8 w-8 rounded"},pe=g.forwardRef(({className:e,variant:a="secondary",size:n="md",children:s,...o},c)=>t.jsx("button",{ref:c,className:G("inline-flex items-center justify-center font-sans transition-colors duration-100","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent","disabled:opacity-40 disabled:pointer-events-none","cursor-pointer select-none",AQe[a],dQe[n],e),...o,children:s}));pe.displayName="Button";function uQe(){const e=$(h=>h.updateModalOpen),a=$(h=>h.setUpdateModalOpen),n=$(h=>h.version),s=$(h=>h.updateReady),o=$(h=>h.updateProgress),c=$(h=>h.installUpdate),l=o&&!s,d=l?Math.max(0,Math.min(100,o.percent||0)):100;return t.jsx(Rt,{open:e,onOpenChange:a,children:t.jsxs(Ht,{title:"Update Available",description:"Desktop app update",children:[t.jsxs("div",{className:"px-5 py-4 flex flex-col gap-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"flex items-center justify-center w-10 h-10 rounded-lg bg-accent/12",children:t.jsx(Ta,{size:20,className:"text-accent"})}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-text-1 font-sans font-medium",children:l?"Downloading update…":"Ready to update"}),t.jsxs("p",{className:"text-xs text-text-3 font-sans mt-0.5",children:[n&&t.jsx("span",{className:"font-mono",children:n}),n&&s&&" → ",s&&t.jsx("span",{className:"font-mono text-accent",children:s})]})]})]}),l&&t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[t.jsx(ze,{size:12,className:"animate-spin text-accent flex-shrink-0"}),t.jsx("div",{className:"flex-1 h-1.5 rounded-full bg-surface-3 overflow-hidden",children:t.jsx("div",{className:"h-full rounded-full bg-accent transition-all duration-500 ease-out",style:{width:`${d}%`}})}),t.jsxs("span",{className:"text-2xs font-mono text-text-3 tabular-nums",children:[d,"%"]})]}),!l&&t.jsx("p",{className:"text-xs text-text-3 font-sans leading-relaxed",children:"The app will restart to apply the update. Your work is saved automatically."})]}),t.jsxs("div",{className:"flex items-center justify-end gap-2 px-5 py-3 border-t border-border-subtle bg-surface-0",children:[t.jsx(pe,{variant:"ghost",size:"sm",onClick:()=>a(!1),children:"Later"}),t.jsxs(pe,{variant:"primary",size:"sm",disabled:l,onClick:()=>{c(),a(!1)},children:[t.jsx(Ta,{size:12}),"Update & Restart"]})]})]})})}function hQe({connected:e,agentCount:a,runningCount:n,uptime:s,terminalVisible:o,onToggleTerminal:c}){const l=$(w=>w.savedTunnels),d=$(w=>w.tunneled),h=$(w=>w.version),f=$(w=>w.updateReady),x=$(w=>w.updateProgress),m=$(w=>w.setUpdateModalOpen),y=$(w=>w.setActiveView),k=l.filter(w=>w.active),O=K0();return t.jsxs("footer",{className:"h-6 flex-shrink-0 flex items-center px-3 bg-surface-3 border-t border-border text-2xs font-sans select-none",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(aa,{status:e?"running":"crashed",size:"sm"}),t.jsx("span",{className:e?"text-text-2":"text-danger",children:e?O?"Desktop":"Connected":"Offline"})]}),O&&e&&t.jsxs("button",{onClick:()=>gP(window.location.href),className:"flex items-center gap-1 text-text-4 hover:text-text-1 cursor-pointer transition-colors",title:"Open this workspace in your browser",children:[t.jsx(ea,{size:10}),t.jsx("span",{children:"Browser"})]}),e&&s>0&&t.jsxs("span",{className:"text-text-4",children:["Up ",Ud(s)]}),e&&a>0&&t.jsxs("span",{className:"text-text-4",children:[n,"/",a," agents"]}),d?t.jsxs("button",{onClick:()=>{var w,C,j;return((j=(C=(w=window.groove)==null?void 0:w.remote)==null?void 0:C.close)==null?void 0:j.call(C))||window.close()},className:"flex items-center gap-1.5 text-text-3 hover:text-danger cursor-pointer transition-colors",title:"Close remote connection",children:[t.jsx(Fo,{size:10}),t.jsx("span",{children:"Disconnect"})]}):t.jsxs(t.Fragment,{children:[k.map(w=>t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsxs("button",{onClick:()=>{const C=w.localPort,j=encodeURIComponent(w.name);gP(`http://localhost:${C}?instance=${j}`)},className:"flex items-center gap-1.5 text-text-3 hover:text-text-1 cursor-pointer transition-colors",title:"Open remote GUI",children:[t.jsx(Fn,{size:10,className:"text-success"}),t.jsx("span",{children:w.name}),t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-success"}),w.latencyMs!=null&&t.jsxs("span",{className:"text-text-4",children:[w.latencyMs,"ms"]})]}),t.jsx("button",{onClick:()=>$.getState().disconnectTunnel(w.id),className:"p-0.5 text-text-4 hover:text-danger cursor-pointer transition-colors rounded",title:"Disconnect",children:t.jsx(Ge,{size:10})})]},w.id)),t.jsxs("button",{onClick:()=>$.getState().toggleQuickConnect(),className:"flex items-center gap-1.5 text-text-4 hover:text-text-1 cursor-pointer transition-colors",title:"Quick Connect to remote server",children:[t.jsx(ra,{size:10}),t.jsx("span",{children:"Connect"})]})]}),e&&t.jsxs("button",{onClick:()=>y("federation"),className:"flex items-center gap-1.5 text-text-4 hover:text-text-1 cursor-pointer transition-colors",title:"Federation",children:[t.jsx(ea,{size:10}),t.jsx("span",{children:"Federation"})]})]}),t.jsx("div",{className:"flex-1"}),f||x?t.jsx("button",{onClick:()=>m(!0),className:"flex items-center gap-1 px-2 h-full cursor-pointer",title:f?`Update to v${f}`:"Downloading update…",children:t.jsxs(we,{variant:"warning",className:"cursor-pointer",children:[t.jsx(Ta,{size:10}),f?"Update Available":"Downloading…"]})}):h?t.jsxs("span",{className:"text-text-4 px-2",children:["v",h]}):null,!O&&t.jsxs("a",{href:"https://docs.groovedev.ai",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 px-2 h-full text-text-3 hover:text-text-1 hover:bg-surface-5 transition-colors no-underline",children:[t.jsx(_o,{size:12}),t.jsx("span",{children:"Docs"})]}),t.jsxs("button",{onClick:c,className:G("flex items-center gap-1.5 px-2 h-full transition-colors cursor-pointer",o?"text-accent bg-accent/8 hover:bg-accent/12":"text-text-3 hover:text-text-1 hover:bg-surface-5"),children:[t.jsx(cs,{size:12}),t.jsx("span",{children:"Terminal"}),t.jsx("kbd",{className:"font-mono text-text-4 ml-0.5",children:"Cmd+J"})]}),t.jsx(uQe,{})]})}function pQe({children:e,width:a,onWidthChange:n,onClose:s,className:o}){const c=g.useRef(!1),l=g.useRef(0),d=g.useRef(0),h=g.useCallback(f=>{f.preventDefault(),c.current=!0,l.current=f.clientX,d.current=a;function x(y){if(!c.current)return;const k=l.current-y.clientX,O=Math.min(Math.max(d.current+k,380),window.innerWidth*.65);n(O)}function m(){c.current=!1,document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",m)}document.addEventListener("mousemove",x),document.addEventListener("mouseup",m)},[a,n]);return t.jsxs("aside",{className:G("flex-shrink-0 flex bg-surface-1 border-l border-border relative",o),style:{width:a},children:[t.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1 cursor-col-resize hover:bg-accent/30 transition-colors z-10",onMouseDown:h}),t.jsx("button",{onClick:s,className:"absolute top-3 right-3 z-10 p-1 rounded-md text-text-3 hover:text-text-0 hover:bg-surface-5 transition-colors cursor-pointer",children:t.jsx(Ge,{size:14})}),t.jsx("div",{className:"flex-1 overflow-y-auto overflow-x-hidden",children:e})]})}const fQe=[{id:"nav:agents",label:"Go to Agents",icon:ru,category:"Navigation",action:e=>{e.setActiveView("agents")}},{id:"nav:editor",label:"Go to Editor",icon:Ft,category:"Navigation",action:e=>{e.setActiveView("editor")}},{id:"nav:dashboard",label:"Go to Dashboard",icon:G1,category:"Navigation",action:e=>{e.setActiveView("dashboard")}},{id:"nav:marketplace",label:"Go to Marketplace",icon:Au,category:"Navigation",action:e=>{e.setActiveView("marketplace")}},{id:"nav:teams",label:"Go to Teams",icon:Ba,category:"Navigation",action:e=>{e.setActiveView("teams")}},{id:"nav:federation",label:"Go to Federation",icon:ea,category:"Navigation",action:e=>{e.setActiveView("federation")}},{id:"action:whitelist",label:"Add to Federation Whitelist",icon:wa,category:"Federation",action:e=>{e.setActiveView("federation")}},{id:"action:spawn",label:"Spawn Agent",icon:gt,category:"Actions",action:e=>{e.openDetail({type:"spawn"})}},{id:"action:terminal",label:"Toggle Terminal",icon:cs,category:"Actions",action:e=>{e.setTerminalVisible(!e.terminalVisible)},shortcut:"Cmd+J"},{id:"action:journalist",label:"Toggle Journalist",icon:Uo,category:"Actions",action:e=>{var a;((a=e.detailPanel)==null?void 0:a.type)==="journalist"?e.closeDetail():e.openDetail({type:"journalist"})}}];function xQe(){const e=$(O=>O.commandPaletteOpen),a=$(O=>O.toggleCommandPalette),n=$(O=>O.agents),s=$(O=>O.savedTunnels),o=$,[c,l]=g.useState(""),[d,h]=g.useState(0),f=g.useRef(null),x=g.useMemo(()=>{var j;const O=n.flatMap(S=>[{id:`chat:${S.id}`,label:`Chat with ${S.name}`,icon:mn,category:"Agents",action:Q=>{Q.selectAgent(S.id)}},...S.status==="running"?[{id:`rotate:${S.id}`,label:`Rotate ${S.name}`,icon:Sr,category:"Agents",action:Q=>{Q.rotateAgent(S.id)}},{id:`kill:${S.id}`,label:`Kill ${S.name}`,icon:vd,category:"Agents",action:Q=>{Q.killAgent(S.id)}}]:[]]),w=[{id:"action:quickconnect",label:"Quick Connect",icon:Fn,category:"Remote",action:S=>{S.toggleQuickConnect()}},...s.map(S=>S.active?{id:`tunnel:open:${S.id}`,label:`Open ${S.name}`,icon:ha,category:"Remote",action:()=>{window.open(`http://localhost:${S.localPort}?instance=${encodeURIComponent(S.name)}`,"_blank")}}:{id:`tunnel:connect:${S.id}`,label:`Connect to ${S.name}`,icon:Fn,category:"Remote",action:Q=>{Q.connectTunnel(S.id)}})],C=(j=window.groove)!=null&&j.openFolder?[{id:"action:openfolder",label:"Open Folder",icon:pa,category:"Window",shortcut:"Cmd+O",action:()=>window.groove.openFolder()}]:[];return[...fQe,...C,...O,...w]},[n,s]),m=g.useMemo(()=>{if(!c.trim())return x.slice(0,12);const O=c.toLowerCase();return x.filter(w=>w.label.toLowerCase().includes(O)||w.category.toLowerCase().includes(O)).slice(0,12)},[x,c]);g.useEffect(()=>{e&&(l(""),h(0),setTimeout(()=>{var O;return(O=f.current)==null?void 0:O.focus()},50))},[e]),g.useEffect(()=>{d>=m.length&&h(Math.max(0,m.length-1))},[m.length,d]);function y(O){O.action(o.getState()),a()}function k(O){O.key==="ArrowDown"?(O.preventDefault(),h(w=>Math.min(w+1,m.length-1))):O.key==="ArrowUp"?(O.preventDefault(),h(w=>Math.max(w-1,0))):O.key==="Enter"&&m[d]?(O.preventDefault(),y(m[d])):O.key==="Escape"&&a()}return e?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-50 bg-black/40 backdrop-blur-sm",onClick:a}),t.jsx(Su,{children:t.jsxs(Hn.div,{initial:{opacity:0,y:-20,scale:.96},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-10,scale:.98},transition:{duration:.15},className:"fixed top-[15%] left-1/2 -translate-x-1/2 z-50 w-[480px] max-h-[400px] bg-surface-1 border border-border rounded-lg shadow-2xl overflow-hidden",onKeyDown:k,children:[t.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border-subtle",children:[t.jsx(ta,{size:16,className:"text-text-3 flex-shrink-0"}),t.jsx("input",{ref:f,value:c,onChange:O=>{l(O.target.value),h(0)},placeholder:"Type a command...",className:"flex-1 bg-transparent text-xs text-text-0 font-sans placeholder:text-text-4 focus:outline-none"})]}),t.jsxs("div",{className:"overflow-y-auto max-h-[320px] py-1",children:[m.length===0&&t.jsx("div",{className:"px-4 py-6 text-sm text-text-3 text-center font-sans",children:"No results"}),m.map((O,w)=>t.jsxs("button",{onClick:()=>y(O),onMouseEnter:()=>h(w),className:G("w-full flex items-center gap-3 px-4 py-2 text-sm font-sans cursor-pointer",w===d?"bg-surface-5 text-text-0":"text-text-1 hover:bg-surface-4"),children:[t.jsx(O.icon,{size:16,className:"text-text-3 flex-shrink-0"}),t.jsx("span",{className:"flex-1 text-left",children:O.label}),t.jsx("span",{className:"text-2xs text-text-4",children:O.category}),O.shortcut&&t.jsx("kbd",{className:"text-2xs font-mono bg-surface-4 px-1 py-0.5 rounded text-text-3 ml-1",children:O.shortcut})]},O.id))]})]})})]}):null}function mQe(){const e=$(s=>s.pendingApprovals),a=$(s=>s.approveRequest),n=$(s=>s.rejectRequest);return e!=null&&e.length?t.jsx("div",{className:"fixed bottom-10 left-1/2 -translate-x-1/2 z-50 w-full max-w-md flex flex-col gap-2 px-4",children:t.jsx(Su,{children:e.map(s=>{var o;return t.jsxs(Hn.div,{initial:{y:20,opacity:0},animate:{y:0,opacity:1},exit:{y:20,opacity:0},transition:{duration:.2},className:"rounded-lg border border-accent/30 bg-surface-2/95 backdrop-blur-md shadow-xl shadow-accent/5 overflow-hidden",children:[t.jsxs("div",{className:"px-4 py-3 flex items-start gap-3",children:[t.jsx(oa,{size:16,className:"text-warning shrink-0 mt-0.5"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("p",{className:"text-sm font-semibold text-text-0 font-sans truncate",children:[s.agentName||"Agent"," needs approval"]}),((o=s.action)==null?void 0:o.description)&&t.jsx("p",{className:"text-2xs text-text-3 font-sans mt-0.5 line-clamp-2",children:s.action.description})]})]}),t.jsxs("div",{className:"px-4 py-2.5 border-t border-border-subtle flex items-center justify-end gap-2",children:[t.jsxs(pe,{size:"sm",variant:"ghost",className:"text-danger hover:bg-danger/10",onClick:()=>n(s.id),children:[t.jsx(vr,{size:14,className:"mr-1"}),"Reject"]}),t.jsxs(pe,{size:"sm",variant:"accent",onClick:()=>a(s.id),children:[t.jsx(du,{size:14,className:"mr-1"}),"Approve"]})]})]},s.id)})})}):null}function gQe({path:e,onNavigate:a}){const n=e.split("/").filter(Boolean);return t.jsxs("div",{className:"flex items-center gap-0.5 min-w-0 overflow-x-auto py-1.5 scrollbar-none",children:[t.jsx("button",{onClick:()=>a("/"),className:"flex-shrink-0 p-1 rounded hover:bg-surface-5 cursor-pointer text-text-3 hover:text-text-0 transition-colors",children:t.jsx(jr,{size:13})}),n.map((s,o)=>{const c="/"+n.slice(0,o+1).join("/"),l=o===n.length-1;return t.jsxs("div",{className:"flex items-center gap-0.5 flex-shrink-0",children:[t.jsx(Yt,{size:11,className:"text-text-4"}),t.jsx("button",{onClick:()=>a(c),className:G("px-1.5 py-0.5 rounded text-xs font-mono cursor-pointer transition-colors",l?"text-text-0 bg-surface-4 font-medium":"text-text-3 hover:text-text-0 hover:bg-surface-5"),children:s})]},o)})]})}function Lu({open:e,onOpenChange:a,currentPath:n,onSelect:s,homePath:o,mandatory:c=!1,title:l}){const d=o||"/home",[h,f]=g.useState(n||d),[x,m]=g.useState([]),[y,k]=g.useState(!1),[O,w]=g.useState(null);g.useEffect(()=>{e&&C(n||d)},[e]);async function C(B){k(!0),w(null);try{const M=await D.get(`/browse-system?path=${encodeURIComponent(B)}`);f(M.current||B),m(M.dirs||[])}catch(M){w(M.message),m([])}k(!1)}function j(){const B=h==="/"?"/":h.split("/").slice(0,-1).join("/")||"/";C(B)}function S(){C(d)}function Q(){s(h),c||a(!1)}const N=l||(c?"Select Project Directory":"Select Working Directory"),L=c?{onEscapeKeyDown:B=>B.preventDefault(),onInteractOutside:B=>B.preventDefault(),onPointerDownOutside:B=>B.preventDefault()}:{};return t.jsx(Rt,{open:e,onOpenChange:c?()=>{}:a,children:t.jsxs(Ht,{title:c?void 0:N,description:"Choose a directory for this agent to work in",className:"max-w-[520px]",...L,children:[c&&t.jsxs("div",{className:"px-5 py-4 border-b border-border-subtle",children:[t.jsx("div",{className:"text-base font-semibold text-text-0 font-sans",children:N}),t.jsx("div",{className:"text-xs text-text-3 font-sans mt-1",children:"Pick a directory on this remote machine to get started."})]}),t.jsxs("div",{className:"px-5 py-4 space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:j,disabled:h==="/",className:"p-1.5 rounded-md bg-surface-4 border border-border text-text-2 hover:text-text-0 hover:bg-surface-5 transition-colors cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed",children:t.jsx(D1,{size:14})}),t.jsx("button",{onClick:S,className:"p-1.5 rounded-md bg-surface-4 border border-border text-text-2 hover:text-text-0 hover:bg-surface-5 transition-colors cursor-pointer",children:t.jsx(mo,{size:14})}),t.jsx("div",{className:"flex-1 min-w-0 bg-surface-0 rounded-md border border-border-subtle px-2",children:t.jsx(gQe,{path:h,onNavigate:C})})]}),t.jsx("div",{className:"bg-surface-0 rounded-lg border border-border-subtle overflow-hidden",children:t.jsxs("div",{className:"max-h-[340px] overflow-y-auto",children:[y&&t.jsx("div",{className:"flex items-center justify-center py-8",children:t.jsx(ze,{size:18,className:"text-text-3 animate-spin"})}),O&&t.jsx("div",{className:"px-4 py-6 text-center",children:t.jsx("p",{className:"text-xs text-danger font-sans",children:O})}),!y&&!O&&x.length===0&&t.jsx("div",{className:"px-4 py-6 text-center",children:t.jsx("p",{className:"text-xs text-text-3 font-sans",children:"No subdirectories"})}),!y&&!O&&x.map(B=>t.jsxs("button",{onClick:()=>C(B.path),className:G("w-full flex items-center gap-2.5 px-3.5 py-2 text-left cursor-pointer","hover:bg-surface-4 transition-colors border-b border-border-subtle last:border-0"),children:[B.hasChildren?t.jsx(r0,{size:15,className:"text-warning flex-shrink-0"}):t.jsx(pa,{size:15,className:"text-text-3 flex-shrink-0"}),t.jsx("span",{className:"text-sm text-text-0 font-sans truncate flex-1",children:B.name}),B.hasChildren&&t.jsx(Yt,{size:12,className:"text-text-4 flex-shrink-0"})]},B.path))]})}),t.jsxs("div",{className:"flex items-center gap-3 bg-surface-4/50 rounded-lg px-3.5 py-2.5 border border-border-subtle",children:[t.jsx(pa,{size:16,className:"text-accent flex-shrink-0"}),t.jsx("span",{className:"text-xs font-mono text-text-1 truncate flex-1",children:h})]}),t.jsxs("div",{className:"flex justify-end gap-2",children:[!c&&t.jsx(pe,{variant:"ghost",size:"md",onClick:()=>a(!1),children:"Cancel"}),t.jsxs(pe,{variant:"primary",size:"md",onClick:Q,className:"gap-1.5",children:[t.jsx(Re,{size:14})," Select Folder"]})]})]})]})})}const gD=[{id:"details",label:"Server Details",icon:Kt},{id:"auth",label:"Authentication",icon:nu},{id:"setup",label:"Setup",icon:Nr},{id:"connected",label:"Connected",icon:ra}];function yQe({steps:e,currentStep:a,completedSteps:n,onStepClick:s}){return t.jsx("div",{className:"flex items-center gap-1 mb-4",children:e.map((o,c)=>{const l=a===c,d=n.includes(c),h=d||c<a;return o.icon,t.jsxs("div",{className:"flex items-center gap-1 flex-1",children:[t.jsxs("button",{onClick:()=>h&&s(c),disabled:!h,className:G("flex items-center gap-1.5 px-2 py-1 rounded-md transition-colors text-2xs font-sans font-medium",l?"bg-accent/12 text-accent":d?"text-success cursor-pointer hover:bg-surface-3":"text-text-4",h&&!l&&"cursor-pointer"),children:[t.jsx("div",{className:G("w-5 h-5 rounded-full flex items-center justify-center text-2xs font-semibold border transition-colors",l?"border-accent bg-accent/15 text-accent":d?"border-success/40 bg-success/10 text-success":"border-border-subtle bg-surface-3 text-text-4"),children:d?t.jsx(Re,{size:10}):c+1}),t.jsx("span",{className:"hidden sm:inline",children:o.label})]}),c<e.length-1&&t.jsx("div",{className:G("flex-1 h-px mx-1",d?"bg-success/30":"bg-border-subtle")})]},o.id)})})}function yD({value:e,onChange:a}){return t.jsx("button",{onClick:()=>a(!e),className:G("w-9 h-5 rounded-full p-0.5 transition-colors cursor-pointer",e?"bg-accent":"bg-surface-5"),children:t.jsx("div",{className:G("w-4 h-4 rounded-full bg-white shadow-sm transition-transform",e?"translate-x-4":"translate-x-0")})})}function Lp({icon:e,title:a,children:n}){return t.jsxs("div",{className:"rounded-lg border border-border-subtle bg-surface-1 px-4 py-3.5 flex flex-col gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-6 h-6 rounded bg-accent/8 flex items-center justify-center flex-shrink-0",children:t.jsx(e,{size:12,className:"text-accent"})}),t.jsx("span",{className:"text-[13px] font-medium text-text-0 font-sans leading-tight",children:a})]}),t.jsx("div",{className:"mt-1",children:n})]})}function vQe({server:e,onSave:a,onTest:n,onConnect:s,onCancel:o}){const c=$(Ae=>Ae.remoteHomedir),[l,d]=g.useState(0),[h,f]=g.useState([]),[x,m]=g.useState(""),[y,k]=g.useState(""),[O,w]=g.useState(""),[C,j]=g.useState(22),[S,Q]=g.useState(""),[N,L]=g.useState(!1),[B,M]=g.useState(!1),[I,F]=g.useState(!1),[E,V]=g.useState(!1),[Z,X]=g.useState(null),[q,H]=g.useState(!1),[T,R]=g.useState(!1);g.useEffect(()=>{e?(m(e.name||""),k(e.host||""),w(e.user||""),j(e.port||22),Q(e.sshKeyPath||""),L(e.autoStart||!1),M(e.autoConnect||!1),f([0,1]),d(2)):(m(""),k(""),w(""),j(22),Q(""),L(!1),M(!1),f([]),d(0))},[e]);function U(){const Ae={name:x.trim(),host:y.trim(),user:O.trim(),port:C,sshKeyPath:S.trim(),autoStart:N,autoConnect:B};return e!=null&&e.id&&(Ae.id=e.id),Ae}function z(){return x.trim()&&y.trim()&&O.trim()}function Y(){l===0&&!z()||(f(Ae=>Ae.includes(l)?Ae:[...Ae,l]),d(Ae=>Math.min(Ae+1,gD.length-1)))}function ue(){d(Ae=>Math.max(Ae-1,0))}async function W(){V(!0),X(null);try{const Ae=U();H(!0),await a(Ae),H(!1);const Qe=await n();X(Qe)}catch(Ae){X({error:Ae.message||"Test failed"}),H(!1)}V(!1)}async function re(){H(!0);try{const Ae=U();await a(Ae),f(Qe=>Qe.includes(l)?Qe:[...Qe,l]),d(2)}catch(Ae){X({error:Ae.message||"Save failed"})}H(!1)}async function xe(){var Ae;R(!0);try{const Qe=U();await a(Qe),await s(),f(ee=>[...new Set([...ee,2])]),d(3)}catch(Qe){let ee=((Ae=Qe==null?void 0:Qe.body)==null?void 0:Ae.error)||(Qe==null?void 0:Qe.message)||"Connection failed";ee.toLowerCase().includes("port forward")&&(ee+=" — Check that the remote server is reachable and SSH port forwarding is allowed."),X({error:ee})}R(!1)}const ve="h-8 px-2.5 text-xs bg-surface-0 border border-border-subtle rounded-md text-text-0 font-sans placeholder:text-text-4 focus:outline-none focus:ring-1 focus:ring-accent",ie="h-8 px-2.5 text-xs bg-surface-0 border border-border-subtle rounded-md text-text-0 font-mono placeholder:text-text-4 focus:outline-none focus:ring-1 focus:ring-accent";return t.jsxs("div",{className:"p-4",children:[t.jsx(yQe,{steps:gD,currentStep:l,completedSteps:h,onStepClick:d}),l===0&&t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsx(Lp,{icon:Kt,title:"Server Info",children:t.jsxs("div",{className:"space-y-2.5",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-2xs font-semibold text-text-2 font-sans mb-1 block",children:"Name"}),t.jsx("input",{value:x,onChange:Ae=>m(Ae.target.value),placeholder:"api-vps",className:G(ve,"w-full"),autoFocus:!0})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-2xs font-semibold text-text-2 font-sans mb-1 block",children:"Host"}),t.jsx("input",{value:y,onChange:Ae=>k(Ae.target.value),placeholder:"165.22.180.45",className:G(ie,"w-full")})]})]})}),t.jsx(Lp,{icon:Nr,title:"Connection",children:t.jsxs("div",{className:"space-y-2.5",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-2xs font-semibold text-text-2 font-sans mb-1 block",children:"User"}),t.jsx("input",{value:O,onChange:Ae=>w(Ae.target.value),placeholder:"root",className:G(ie,"w-full")})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-2xs font-semibold text-text-2 font-sans mb-1 block",children:"SSH Port"}),t.jsx("input",{value:C,onChange:Ae=>j(Number(Ae.target.value)||22),type:"number",className:G(ie,"w-24")})]})]})})]}),l===1&&t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsx(Lp,{icon:nu,title:"SSH Key",children:t.jsxs("div",{className:"space-y-2.5",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-2xs font-semibold text-text-2 font-sans mb-1 block",children:"Key Path"}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("input",{value:S,onChange:Ae=>Q(Ae.target.value),placeholder:"~/.ssh/id_ed25519",className:G(ie,"flex-1 min-w-0"),autoFocus:!0}),t.jsx(pe,{variant:"secondary",size:"sm",onClick:()=>F(!0),className:"h-8 px-2 flex-shrink-0",children:t.jsx(pd,{size:12})})]}),t.jsx("p",{className:"text-2xs text-text-4 font-sans mt-1",children:"Leave blank to use default SSH agent."})]}),t.jsxs(pe,{variant:"secondary",size:"sm",onClick:W,disabled:E,className:"h-7 text-2xs gap-1.5",children:[E?t.jsx(ze,{size:11,className:"animate-spin"}):t.jsx(ra,{size:11}),"Test Connection"]})]})}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"rounded-lg border border-border-subtle bg-surface-1 px-4 py-3.5",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("div",{className:"w-6 h-6 rounded bg-accent/8 flex items-center justify-center flex-shrink-0",children:t.jsx(Kt,{size:12,className:"text-accent"})}),t.jsx("span",{className:"text-[13px] font-medium text-text-0 font-sans",children:"Target"})]}),t.jsxs("div",{className:"space-y-1.5 text-2xs font-sans",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-text-3",children:"Host"}),t.jsx("span",{className:"text-text-1 font-mono",children:y||"—"})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-text-3",children:"User"}),t.jsx("span",{className:"text-text-1 font-mono",children:O||"—"})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-text-3",children:"Port"}),t.jsx("span",{className:"text-text-1 font-mono",children:C})]})]})]}),Z&&t.jsx("div",{className:G("px-3 py-2.5 rounded-lg text-2xs font-sans flex items-start gap-2",Z.error?"bg-danger/8 border border-danger/20 text-danger":Z.reachable?"bg-success/8 border border-success/20 text-success":"bg-warning/8 border border-warning/20 text-warning"),children:Z.error?t.jsxs(t.Fragment,{children:[t.jsx(Ge,{size:11,className:"mt-0.5 flex-shrink-0"})," ",Z.error]}):Z.reachable?t.jsxs(t.Fragment,{children:[t.jsx(Re,{size:11,className:"mt-0.5 flex-shrink-0"})," Server reachable"]}):t.jsxs(t.Fragment,{children:[t.jsx(oa,{size:11,className:"mt-0.5 flex-shrink-0"})," Host unreachable"]})})]}),t.jsx(Lu,{open:I,onOpenChange:F,currentPath:S||"~/.ssh",homePath:c,onSelect:Ae=>Q(Ae)})]}),l===2&&t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsx(Lp,{icon:Nr,title:"Behavior",children:t.jsxs("div",{className:"space-y-3",children:[t.jsxs("label",{className:"flex items-center justify-between cursor-pointer",children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-xs text-text-1 font-sans block",children:"Auto-start daemon"}),t.jsx("span",{className:"text-2xs text-text-4 font-sans",children:"Start Groove on the remote when connecting"})]}),t.jsx(yD,{value:N,onChange:L})]}),t.jsxs("label",{className:"flex items-center justify-between cursor-pointer",children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-xs text-text-1 font-sans block",children:"Auto-connect on launch"}),t.jsx("span",{className:"text-2xs text-text-4 font-sans",children:"Connect when Groove starts"})]}),t.jsx(yD,{value:B,onChange:M})]})]})}),Z&&!Z.error&&t.jsxs("div",{className:"rounded-lg border border-border-subtle bg-surface-1 px-4 py-3.5",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[t.jsx("div",{className:"w-6 h-6 rounded bg-success/10 flex items-center justify-center flex-shrink-0",children:t.jsx(Re,{size:12,className:"text-success"})}),t.jsx("span",{className:"text-[13px] font-medium text-text-0 font-sans",children:"Test Results"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2 text-2xs font-sans",children:[t.jsx(aa,{status:Z.reachable?"running":"crashed",size:"sm"}),t.jsx("span",{className:"text-text-1",children:"Reachable"})]}),t.jsxs("div",{className:"flex items-center gap-2 text-2xs font-sans",children:[t.jsx(aa,{status:Z.grooveInstalled?"running":"stopped",size:"sm"}),t.jsx("span",{className:"text-text-1",children:"Groove Installed"})]}),t.jsxs("div",{className:"flex items-center gap-2 text-2xs font-sans",children:[t.jsx(aa,{status:Z.daemonRunning?"running":"stopped",size:"sm"}),t.jsx("span",{className:"text-text-1",children:"Daemon Running"})]})]})]}),(!Z||Z.error)&&t.jsxs("div",{className:"rounded-lg border border-border-subtle bg-surface-1 px-4 py-3.5",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("div",{className:"w-6 h-6 rounded bg-accent/8 flex items-center justify-center flex-shrink-0",children:t.jsx(Kt,{size:12,className:"text-accent"})}),t.jsx("span",{className:"text-[13px] font-medium text-text-0 font-sans",children:x||"Server"})]}),t.jsxs("div",{className:"space-y-1.5 text-2xs font-sans",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-text-3",children:"Connection"}),t.jsxs("span",{className:"text-text-1 font-mono",children:[O,"@",y,":",C]})]}),S&&t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-text-3",children:"SSH Key"}),t.jsx("span",{className:"text-text-1 font-mono truncate max-w-40",children:S})]})]})]})]}),l===3&&t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{className:"rounded-lg border border-success/30 bg-success/5 px-4 py-5 text-center",children:[t.jsx("div",{className:"w-10 h-10 rounded-full bg-success/15 flex items-center justify-center mx-auto mb-3",children:t.jsx(Re,{size:20,className:"text-success"})}),t.jsx("h3",{className:"text-sm font-semibold text-text-0 font-sans mb-1",children:"Connected"}),t.jsxs("p",{className:"text-2xs text-text-3 font-sans",children:["Successfully connected to ",t.jsx("span",{className:"font-mono text-text-1",children:x})]}),t.jsxs(pe,{variant:"primary",size:"sm",onClick:()=>{const Ae=e==null?void 0:e.localPort,Qe=encodeURIComponent(x);window.open(`http://localhost:${Ae}?instance=${Qe}`,"_blank")},className:"h-8 text-xs gap-1.5 mt-4",children:[t.jsx(ha,{size:12}),"Open Remote GUI"]})]}),t.jsxs("div",{className:"rounded-lg border border-border-subtle bg-surface-1 px-4 py-3.5",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[t.jsx("div",{className:"w-6 h-6 rounded bg-accent/8 flex items-center justify-center flex-shrink-0",children:t.jsx(Kt,{size:12,className:"text-accent"})}),t.jsx("span",{className:"text-[13px] font-medium text-text-0 font-sans",children:"Connection Info"})]}),t.jsxs("div",{className:"space-y-1.5 text-2xs font-sans",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-text-3",children:"Connection"}),t.jsxs("span",{className:"text-text-1 font-mono",children:[O,"@",y,":",C]})]}),S&&t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-text-3",children:"SSH Key"}),t.jsx("span",{className:"text-text-1 font-mono truncate max-w-40",children:S})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-text-3",children:"Auto-start"}),t.jsx("span",{className:"text-text-1",children:N?"On":"Off"})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-text-3",children:"Auto-connect"}),t.jsx("span",{className:"text-text-1",children:B?"On":"Off"})]}),(e==null?void 0:e.remoteVersion)&&t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-text-3",children:"Version"}),t.jsxs("span",{className:G("text-text-1 font-mono",e.versionMatch===!1&&"text-warning"),children:["v",e.remoteVersion,e.versionMatch===!1&&" (update available)"]})]})]})]})]}),t.jsxs("div",{className:"flex items-center justify-between mt-4",children:[t.jsx(pe,{variant:"ghost",size:"sm",onClick:l===0||l===3?o:ue,className:"h-8 text-xs px-4 text-text-3",children:l===0?"Cancel":l===3?"Done":"Back"}),l<3&&t.jsx("div",{className:"flex gap-2",children:l===2?t.jsxs(pe,{variant:"primary",size:"sm",onClick:xe,disabled:T||q,className:"h-8 text-xs px-4 gap-1.5",children:[T?t.jsx(ze,{size:12,className:"animate-spin"}):t.jsx(ra,{size:12}),T?"Connecting...":"Connect"]}):l===1?t.jsx(pe,{variant:"primary",size:"sm",onClick:re,disabled:q,className:"h-8 text-xs px-4",children:q?"Saving...":"Next"}):t.jsx(pe,{variant:"primary",size:"sm",onClick:Y,disabled:!z(),className:"h-8 text-xs px-4",children:"Next"})})]})]})}function BG(){const e=$(y=>y.quickConnectOpen),a=$(y=>y.toggleQuickConnect),n=$(y=>y.savedTunnels),s=$(y=>y.addToast),[o,c]=g.useState(null),[l,d]=g.useState(!1),h=g.useRef(null);if(!e)return null;async function f(y){c(y);try{await $.getState().connectTunnel(y);const k=n.find(O=>O.id===y);k!=null&&k.host&&s("info",`Add ${k.host} to Federation Whitelist?`,"",{label:"Add",onClick:()=>$.getState().addToWhitelist(k.host)}),c(null);return}catch(k){let O=(k==null?void 0:k.message)||"Unknown error";O.toLowerCase().includes("port forward")&&(O+=" — Try testing the connection first, or check your SSH key configuration."),s("error","Connection failed",O)}c(null)}function x(y){var k,O;if((O=(k=window.groove)==null?void 0:k.remote)!=null&&O.openWindow)window.groove.remote.openWindow(y.localPort,y.name);else{const w=encodeURIComponent(y.name);window.open(`http://localhost:${y.localPort}?instance=${w}`,"_blank")}a()}function m(){d(!1),a()}return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-50 bg-black/40 backdrop-blur-sm",onClick:m}),t.jsx(Su,{children:t.jsxs(Hn.div,{initial:{opacity:0,y:-20,scale:.96},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-10,scale:.98},transition:{duration:.15},className:G("fixed top-[15%] left-1/2 -translate-x-1/2 z-50 bg-surface-1 border border-border rounded-lg shadow-2xl overflow-hidden",l?"w-[520px]":"w-[400px]"),children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border-subtle",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[l&&t.jsx("button",{onClick:()=>d(!1),className:"p-1 -ml-1 text-text-4 hover:text-text-1 cursor-pointer transition-colors",children:t.jsx(q1,{size:14})}),t.jsx(Fn,{size:15,className:"text-accent"}),t.jsx("span",{className:"text-sm font-semibold text-text-0 font-sans",children:l?"Add Connection":"Quick Connect"})]}),t.jsx("button",{onClick:m,className:"p-1 text-text-4 hover:text-text-1 cursor-pointer transition-colors",children:t.jsx(Ge,{size:14})})]}),l?t.jsx(vQe,{server:null,onSave:async y=>{const k=y.id||h.current;if(k)await $.getState().updateTunnel(k,y),s("success","Server updated");else{const O=await $.getState().saveTunnel(y);O!=null&&O.id&&(h.current=O.id),s("success","Server added")}},onTest:()=>{const y=h.current;if(y)return $.getState().testTunnel(y)},onConnect:()=>{const y=h.current;if(y)return $.getState().connectTunnel(y)},onCancel:()=>{h.current=null,d(!1)}}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"overflow-y-auto max-h-[320px] py-1",children:n.length===0?t.jsxs("div",{className:"px-4 py-8 text-center",children:[t.jsx(Kt,{size:24,className:"text-text-4 mx-auto mb-2"}),t.jsx("p",{className:"text-sm text-text-3 font-sans",children:"No saved servers"}),t.jsx("p",{className:"text-2xs text-text-4 font-sans mt-1",children:"Add a connection to get started."}),t.jsxs(pe,{variant:"primary",size:"sm",onClick:()=>{h.current=null,d(!0)},className:"h-8 text-xs gap-1.5 mt-3",children:[t.jsx(gt,{size:12})," Add Connection"]})]}):n.map(y=>t.jsxs("div",{className:G("w-full flex items-center gap-3 px-4 py-2.5 transition-colors","hover:bg-surface-5",o===y.id&&"opacity-60 pointer-events-none"),children:[t.jsx(Kt,{size:15,className:y.active?"text-success":"text-text-4"}),t.jsxs("button",{onClick:()=>y.active?x(y):f(y.id),disabled:o===y.id,className:"flex-1 min-w-0 text-left cursor-pointer",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-medium text-text-0 font-sans truncate",children:y.name}),y.active&&t.jsx(aa,{status:"running",size:"sm"}),y.remoteVersion&&t.jsxs("span",{className:"text-2xs font-mono text-text-4 ml-1",children:["v",y.remoteVersion]})]}),t.jsxs("span",{className:"text-2xs text-text-4 font-mono",children:[y.user,"@",y.host]})]}),t.jsx("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:o===y.id?t.jsx(ze,{size:14,className:"text-text-3 animate-spin"}):y.active?t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:()=>x(y),className:"flex items-center gap-1 text-2xs text-success font-sans hover:text-success/80 cursor-pointer transition-colors",children:[t.jsx(ha,{size:11})," Open"]}),y.versionMatch===!1&&t.jsxs("button",{onClick:async()=>{try{await $.getState().upgradeTunnel(y.id),s("success","Upgrade started")}catch(k){s("error","Upgrade failed",k.message)}},className:"flex items-center gap-1 text-2xs text-warning font-sans hover:text-warning/80 cursor-pointer transition-colors",title:`Update remote from v${y.remoteVersion} to v${y.localVersion}`,children:[t.jsx(Ta,{size:11})," Update"]}),t.jsx("button",{onClick:async()=>{await $.getState().disconnectTunnel(y.id),s("info","Disconnected",y.name)},className:"p-1 text-text-4 hover:text-danger cursor-pointer transition-colors rounded",title:"Disconnect",children:t.jsx(Fo,{size:12})}),t.jsx("button",{onClick:k=>{k.stopPropagation(),$.getState().deleteTunnel(y.id)},className:"p-1 text-text-4 hover:text-danger cursor-pointer transition-colors rounded",title:"Delete connection",children:t.jsx(ht,{size:12})})]}):t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>f(y.id),className:"text-2xs text-text-3 font-sans hover:text-text-1 cursor-pointer transition-colors",children:"Connect"}),t.jsx("button",{onClick:k=>{k.stopPropagation(),$.getState().deleteTunnel(y.id)},className:"p-1 text-text-4 hover:text-danger cursor-pointer transition-colors rounded",title:"Delete connection",children:t.jsx(ht,{size:12})})]})})]},y.id))}),t.jsx("div",{className:"px-4 py-2.5 border-t border-border-subtle",children:t.jsxs("button",{onClick:()=>{h.current=null,d(!0)},className:"flex items-center gap-1.5 text-2xs text-accent hover:text-accent/80 font-sans font-medium cursor-pointer transition-colors",children:[t.jsx(gt,{size:10})," Add new connection"]})})]})]})})]})}const vD=[],kQe=/error|crash|fail/i,Tp="rgba(51, 175, 188, 0.15)",$p="h-[2px]";function OQe(e){if(!e||e==="auto")return"auto";const a=e.match(/^claude-(opus|sonnet|haiku)-(\d+)-(\d+)(?:-\d+)?$/);return a?`${a[1][0].toUpperCase()+a[1].slice(1)} ${a[2]}.${a[3]}`:e.startsWith("gemini-")?e.replace("gemini-","Gemini ").replace("-preview","").replace("-flash-lite"," Flash Lite").replace("-flash"," Flash").replace("-pro"," Pro"):e.startsWith("gpt-")?e.toUpperCase().replace("GPT-","GPT-"):e}function bQe(e){if(!e||e.length<2)return null;const a=e.slice(-10),n=(a[a.length-1].t-a[0].t)/6e4;return n<=0?null:(a[a.length-1].v-a[0].v)/n}function wQe(e){return e>=70?"var(--color-success)":e>=40?"var(--color-warning)":"var(--color-danger)"}function jQe(e){return e>=60?"var(--color-success)":e>=30?"var(--color-warning)":"var(--color-danger)"}const CQe={running:"LIVE",starting:"INIT",stopped:"IDLE",crashed:"ERR",completed:"DONE",killed:"KILL",rotating:"ROT"},_G=g.memo(({data:e,selected:a})=>{const{agent:n}=e,s=n.status==="running"||n.status==="starting",o=Math.round((n.contextUsage||0)*100),c=PE(n.status),l=n.tokensUsed||0,d=g.useRef(null),h=$(N=>!!N.expandedNodes[n.id]),f=$(N=>N.toggleNodeExpanded);g.useEffect(()=>{var L;const N=(L=d.current)==null?void 0:L.closest(".react-flow__node");N&&(N.style.zIndex=h?"1000":"")},[h]);const x=$(N=>N.activityLog[n.id])||vD,m=$(N=>N.tokenTimeline[n.id])||vD,y=bQe(m),k=g.useMemo(()=>x.filter(N=>kQe.test(N.text)).length,[x]),O=o>75?"var(--color-danger)":o>50?"var(--color-warning)":"var(--color-success)",w=n.qualityScore!=null?Math.round(n.qualityScore):null,C=w!=null?wQe(w):null,j=n.efficiency!=null?n.efficiency:null,S=j!=null?jQe(j):null,Q=n.durationMs?n.durationMs/1e3:n.spawnedAt?(Date.now()-new Date(n.spawnedAt).getTime())/1e3:n.createdAt?(Date.now()-new Date(n.createdAt).getTime())/1e3:0;return t.jsx("div",{ref:d,children:t.jsxs("div",{className:`w-[220px] overflow-hidden rounded-[4px] transition-all duration-200 ease-out bg-[#1c1f26] hover:bg-[#141720] border border-solid ${a?"border-[#2e323a]":"border-[#262a32]"} hover:border-[#2e3640]`,children:[t.jsx(Oo,{id:"top",type:"target",position:bo.Top,className:"!w-1 !h-1 !bg-transparent !border-0"}),t.jsx(Oo,{id:"bottom",type:"target",position:bo.Bottom,className:"!w-1 !h-1 !bg-transparent !border-0"}),t.jsx(Oo,{id:"left",type:"target",position:bo.Left,className:"!w-1 !h-1 !bg-transparent !border-0"}),t.jsx(Oo,{id:"right",type:"target",position:bo.Right,className:"!w-1 !h-1 !bg-transparent !border-0"}),s&&t.jsx("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",style:{borderRadius:3},children:t.jsx("div",{className:"absolute left-0 right-0 h-px",style:{background:"linear-gradient(90deg, transparent 0%, rgba(97,175,239,0.25) 50%, transparent 100%)",animation:"node-scan 3s ease-in-out infinite"}})}),t.jsxs("div",{className:"px-3 pt-2.5 pb-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{className:"relative flex-shrink-0 w-[6px] h-[6px]",children:[t.jsx("span",{className:"absolute inset-0 rounded-sm",style:{background:c}}),s&&t.jsx("span",{className:"absolute inset-[-2px] rounded-sm",style:{background:c,opacity:.15,animation:"node-pulse-bar 2s ease-in-out infinite"}})]}),t.jsx("span",{className:"text-[12px] font-semibold text-[#e6e6e6] font-sans truncate flex-1 leading-none",children:n.name}),t.jsx("span",{className:"text-[7px] font-mono font-bold uppercase tracking-wider px-1 py-px rounded-sm",style:{color:c,background:c+"12"},children:CQe[n.status]||n.status}),t.jsx("button",{className:"text-[#505862] hover:text-[#8b929e] cursor-pointer transition-colors flex-shrink-0",onClick:N=>{N.stopPropagation(),f(n.id)},children:h?t.jsx(Ge,{size:10}):t.jsx(xd,{size:10})})]}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-1.5",children:[t.jsx("span",{className:"text-[9px] font-mono text-[#505862] uppercase tracking-[0.05em]",children:n.role}),t.jsx("span",{className:"text-[9px] text-[#2a2e36]",children:"/"}),t.jsx("span",{className:"text-[9px] font-mono text-[#505862]",children:OQe(n.model)})]})]}),t.jsxs("div",{className:"px-3 pt-1 pb-2",children:[t.jsxs("div",{className:"flex items-baseline gap-1.5",children:[t.jsx("span",{className:"text-[14px] font-mono font-medium text-[#bcc2cd] leading-none",children:At(l)}),t.jsx("span",{className:"text-[8px] font-mono text-[#505862]",children:"tok"}),t.jsx("span",{className:"flex-1"}),t.jsxs("span",{className:"text-[9px] font-mono text-[#505862]",children:[o,"%"]})]}),t.jsx("div",{className:`mt-1.5 ${$p} rounded-sm overflow-hidden`,style:{background:Tp},children:t.jsx("div",{className:"h-full rounded-sm transition-all duration-700",style:{width:`${Math.max(o,1)}%`,background:o>80?"var(--color-danger)":o>60?"var(--color-warning)":"var(--color-accent)"}})})]}),t.jsx("div",{className:"grid transition-[grid-template-rows] duration-200 ease-out",style:{gridTemplateRows:h?"1fr":"0fr"},children:t.jsxs("div",{className:"overflow-hidden",children:[t.jsx("div",{className:"mx-3 border-t border-white/[0.04]"}),t.jsxs("div",{className:"px-3 pt-1.5 pb-1",children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("span",{className:"text-[9px] font-mono text-[#505862] uppercase tracking-wider",children:"Context"}),(n.rotations||0)>0&&t.jsxs("span",{className:"text-[8px] font-mono text-[#606878] bg-white/[0.04] rounded px-1 py-px",children:[n.rotations,"x rot"]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:`flex-1 ${$p} rounded-sm overflow-hidden`,style:{background:Tp},children:t.jsx("div",{className:"h-full rounded-sm transition-all duration-500",style:{width:`${Math.max(o,1)}%`,background:O}})}),t.jsxs("span",{className:"text-[9px] font-mono font-medium",style:{color:O},children:[o,"%"]})]})]}),t.jsxs("div",{className:"px-3 pt-1 pb-1",children:[t.jsx("span",{className:"text-[9px] font-mono text-[#505862] uppercase tracking-wider",children:"Quality"}),t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[t.jsx("div",{className:`flex-1 ${$p} rounded-sm overflow-hidden`,style:{background:Tp},children:t.jsx("div",{className:"h-full rounded-sm transition-all duration-500",style:{width:`${w!=null?Math.max(w,1):0}%`,background:C||"#505862"}})}),t.jsx("span",{className:"text-[9px] font-mono font-medium",style:{color:C||"#505862"},children:w??"—"})]})]}),t.jsxs("div",{className:"px-3 pt-1 pb-1",children:[t.jsx("span",{className:"text-[9px] font-mono text-[#505862] uppercase tracking-wider",children:"Efficiency"}),t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[t.jsx("div",{className:`flex-1 ${$p} rounded-sm overflow-hidden`,style:{background:Tp},children:t.jsx("div",{className:"h-full rounded-sm transition-all duration-500",style:{width:`${j!=null?Math.max(j,1):0}%`,background:S||"#505862"}})}),t.jsx("span",{className:"text-[9px] font-mono font-medium",style:{color:S||"#505862"},children:j!=null?`${j}%`:"—"})]})]}),t.jsx("div",{className:"px-3 pt-1 pb-1",children:t.jsxs("div",{className:"grid grid-cols-3 gap-1",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-[9px] font-mono font-medium text-[#bcc2cd]",children:Go(n.costUsd||0)}),t.jsx("div",{className:"text-[7px] font-mono text-[#505862]",children:"cost"})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-[9px] font-mono font-medium text-[#bcc2cd]",children:y?At(Math.round(y)):"—"}),t.jsx("div",{className:"text-[7px] font-mono text-[#505862]",children:"tok/m"})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-[9px] font-mono font-medium text-[#bcc2cd]",children:n.turns||0}),t.jsx("div",{className:"text-[7px] font-mono text-[#505862]",children:"turns"})]})]})}),t.jsx("div",{className:"px-3 pt-1 pb-2",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"text-[9px] font-mono text-[#8b929e]",children:Ud(Math.max(0,Math.floor(Q)))}),t.jsx("span",{className:"text-[7px] font-mono text-[#505862]",children:"up"})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[k>0?t.jsx("span",{className:"text-[9px] font-mono text-[var(--color-danger)]",children:k}):t.jsx("span",{className:"text-[9px] font-mono text-[#505862]",children:"0"}),t.jsx("span",{className:"text-[7px] font-mono text-[#505862]",children:"err"})]})]})})]})})]})})});_G.displayName="AgentNode";const LG=g.memo(({data:e})=>{const{agentCount:a,runningCount:n}=e,s=n>0,o={background:"transparent",border:0,width:2,height:2};return t.jsxs("div",{className:"relative flex items-center justify-center",style:{width:84,height:84},children:[t.jsx("div",{className:G("absolute inset-0 rounded-full transition-all duration-500",s&&"animate-[spin-slow_30s_linear_infinite]"),style:{border:`1px dashed ${s?"rgba(97,175,239,0.5)":"rgba(97,175,239,0.25)"}`}}),t.jsx("div",{className:"absolute inset-[10px] rounded-full",style:{background:s?"radial-gradient(circle, rgba(97,175,239,0.15) 0%, transparent 70%)":"radial-gradient(circle, rgba(97,175,239,0.05) 0%, transparent 70%)",animation:s?"node-pulse-bar 2.5s ease-in-out infinite":"none"}}),t.jsx("div",{className:G("w-14 h-14 rounded-full flex items-center justify-center relative z-10 transition-all duration-300",s?"bg-[#1c1f26] border-2 border-[#61afef]/35 shadow-[0_0_28px_rgba(97,175,239,0.15)]":"bg-[#1c1f26] border border-[#61afef]/20"),children:t.jsx("img",{src:"/favicon.png",alt:"G",className:G("h-7 w-7 rounded-full transition-opacity",s?"opacity-90":"opacity-60")})}),a>0&&t.jsx("div",{className:G("absolute z-20 min-w-[20px] h-[20px] rounded-sm flex items-center justify-center","text-[10px] font-mono font-bold px-1 transition-all duration-300",s?"bg-[#1c1f26] text-[#61afef] border border-[#61afef]/40":"bg-[#1c1f26] text-[#61afef]/60 border border-[#61afef]/20"),style:{bottom:2,right:2},children:a}),t.jsx(Oo,{id:"bottom",type:"source",position:bo.Bottom,style:o}),t.jsx(Oo,{id:"right",type:"source",position:bo.Right,style:o}),t.jsx(Oo,{id:"left",type:"source",position:bo.Left,style:o}),t.jsx(Oo,{id:"top",type:"source",position:bo.Top,style:o})]})});LG.displayName="RootNode";const MQe=[{id:"desktop",icon:Cr,label:"Desktop",width:"100%"},{id:"tablet",icon:j0,label:"Tablet (768px)",width:"768px"},{id:"mobile",icon:w0,label:"Mobile (375px)",width:"375px"}];function SQe({onRefresh:e}){const a=$(x=>x.previewState),n=$(x=>x.setPreviewDevice),s=$(x=>x.toggleScreenshotMode),o=$(x=>x.closePreview),[c,l]=g.useState(!1),d=g.useRef(null);g.useEffect(()=>()=>{d.current&&clearTimeout(d.current)},[]);function h(){c?(d.current&&clearTimeout(d.current),l(!1),o()):(l(!0),d.current=setTimeout(()=>l(!1),2e3))}const f=a.teamId?`${window.location.origin}/api/preview/${a.teamId}/proxy/`:a.url;return t.jsxs("div",{className:"h-10 flex items-center gap-2 px-3 bg-surface-3 border-b border-border flex-shrink-0",children:[t.jsx("div",{className:"flex-1 min-w-0 h-7 flex items-center px-3 rounded-md bg-surface-1 border border-border-subtle",children:t.jsx("span",{className:"text-2xs font-mono text-text-3 truncate",children:f||"No URL"})}),t.jsx("button",{onClick:e,className:"w-7 h-7 flex items-center justify-center rounded-md text-text-3 hover:text-accent hover:bg-accent/10 transition-colors cursor-pointer",title:"Refresh",children:t.jsx(ca,{size:14})}),t.jsx("div",{className:"flex items-center gap-0.5 px-1 py-0.5 rounded-md bg-surface-1 border border-border-subtle",children:MQe.map(x=>t.jsx("button",{onClick:()=>n(x.id),className:G("w-7 h-6 flex items-center justify-center rounded transition-colors cursor-pointer",a.deviceSize===x.id?"text-accent bg-accent/10":"text-text-3 hover:text-text-1"),title:x.label,children:t.jsx(x.icon,{size:13})},x.id))}),t.jsx("button",{onClick:s,className:G("w-7 h-7 flex items-center justify-center rounded-md transition-colors cursor-pointer",a.screenshotMode?"text-accent bg-accent/10":"text-text-3 hover:text-accent hover:bg-accent/10"),title:"Screenshot",children:t.jsx(Z1,{size:14})}),t.jsx("button",{onClick:h,className:G("h-7 flex items-center justify-center rounded-md transition-all cursor-pointer",c?"px-2 gap-1.5 bg-danger/15 text-danger border border-danger/25":"w-7 text-text-3 hover:text-danger hover:bg-danger/10"),title:"Close Preview",children:c?t.jsx("span",{className:"text-2xs font-semibold font-sans whitespace-nowrap",children:"Close?"}):t.jsx(Ge,{size:14})})]})}/*!
|
|
8615
8615
|
* html2canvas 1.4.1 <https://html2canvas.hertzen.com>
|
|
8616
8616
|
* Copyright (c) 2022 Niklas von Hertzen <https://hertzen.com>
|
|
8617
8617
|
* Released under MIT License
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<link rel="icon" type="image/png" href="/favicon.png" />
|
|
8
8
|
<title>Groove GUI</title>
|
|
9
|
-
<script type="module" crossorigin src="/assets/index-
|
|
9
|
+
<script type="module" crossorigin src="/assets/index-bmkBX18f.js"></script>
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/assets/vendor-26L3JoZv.js">
|
|
11
11
|
<link rel="modulepreload" crossorigin href="/assets/reactflow-DoBZjiHE.js">
|
|
12
12
|
<link rel="modulepreload" crossorigin href="/assets/codemirror-CFF1Lrnz.js">
|
|
@@ -90,16 +90,14 @@ export function StatusBar({
|
|
|
90
90
|
</button>
|
|
91
91
|
</div>
|
|
92
92
|
))}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
</button>
|
|
102
|
-
)}
|
|
93
|
+
<button
|
|
94
|
+
onClick={() => useGrooveStore.getState().toggleQuickConnect()}
|
|
95
|
+
className="flex items-center gap-1.5 text-text-4 hover:text-text-1 cursor-pointer transition-colors"
|
|
96
|
+
title="Quick Connect to remote server"
|
|
97
|
+
>
|
|
98
|
+
<Plug size={10} />
|
|
99
|
+
<span>Connect</span>
|
|
100
|
+
</button>
|
|
103
101
|
</>
|
|
104
102
|
)}
|
|
105
103
|
{connected && (
|