@adhdev/daemon-standalone 0.6.69 → 0.6.71
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/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/public/assets/index-BclTJlv0.js +71 -0
- package/public/assets/index-BqANfffS.css +1 -0
- package/public/index.html +2 -2
- package/public/assets/index-D4nMTfLt.js +0 -71
- package/public/assets/index-DDmTF03T.css +0 -1
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
var Hs=Object.defineProperty;var zs=(t,s,r)=>s in t?Hs(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r;var Ee=(t,s,r)=>zs(t,typeof s!="symbol"?s+"":s,r);import{r as n,j as e,M as Gt,a as Jt,b as Us,c as Ys,u as vt,t as Vs,d as Xs,e as qs,f as bs,R as Gs,g as ys,h as Js,B as Zs,i as Qs,k as qe,N as St,l as en}from"./vendor-tc3018Wt.js";import{D as tn,o as sn,L as nn}from"./terminal-Dm9LBRva.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))a(i);new MutationObserver(i=>{for(const c of i)if(c.type==="childList")for(const o of c.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&a(o)}).observe(document,{childList:!0,subtree:!0});function r(i){const c={};return i.integrity&&(c.integrity=i.integrity),i.referrerPolicy&&(c.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?c.credentials="include":i.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function a(i){if(i.ep)return;i.ep=!0;const c=r(i);fetch(i.href,c)}})();const js=n.createContext({ides:[],updateIdeChats:()=>{},screenshotMap:{},setScreenshotMap:()=>{},initialLoaded:!1,toasts:[],setToasts:()=>{},wsStatus:"connected",isConnected:!0,connectionStates:{},connectionTransports:{},showReconnected:!1,userName:void 0,setUserName:()=>{},isP2PActive:!1,p2pStates:{},userRole:void 0}),vs=n.createContext({injectEntries:()=>{},markLoaded:()=>{},getIdes:()=>[]});function Zt(t){var r,a;let s=0;return"activeChat"in t&&(s+=4),(r=t.agentStreams)!=null&&r.length&&(s+=2),t.workspace&&(s+=1),t.machine&&(s+=1),(a=t.agents)!=null&&a.length&&(s+=1),s}function rn(t,s){var o,x,d,p,u,l,g;const r=Date.now();if(s.length===0)return t.map(h=>({...h,_lastUpdate:r}));const a=new Map;for(const h of s)a.set(h.id,h);for(const h of t){const m=a.get(h.id);if(!m){a.set(h.id,{...h,_lastUpdate:r});continue}const A=Zt(h),_=Zt(m);if(A>_){const j=(o=h.chats)!=null&&o.length?h.chats:m.chats;a.set(h.id,{...m,...h,chats:j,_lastUpdate:r})}else if(A<_){const j={};h.status&&h.status!==m.status&&(j.status=h.status),h.cdpConnected!==void 0&&(j.cdpConnected=h.cdpConnected),(x=h.chats)!=null&&x.length&&!((d=m.chats)!=null&&d.length)&&(j.chats=h.chats),h.machineNickname!==void 0&&h.machineNickname!==m.machineNickname&&(j.machineNickname=h.machineNickname),Object.keys(j).length>0&&a.set(h.id,{...m,...j,_lastUpdate:m._lastUpdate})}else{const j=h.timestamp||r,w=m._lastUpdate||m.timestamp||0;if(j>=w){const O=(p=h.chats)!=null&&p.length?h.chats:m.chats;a.set(h.id,{...m,...h,chats:O,_lastUpdate:r})}else(u=h.chats)!=null&&u.length&&!((l=m.chats)!=null&&l.length)&&a.set(h.id,{...m,chats:h.chats})}}const i=new Set(t.map(h=>h.id)),c=new Set;for(const h of t){const m=h.daemonId||((g=h.id)==null?void 0:g.split(":")[0]);m&&c.add(m)}for(const[h,m]of a){const A=m.daemonId||h.split(":")[0];if(!c.has(A))continue;const _=r-(m._lastUpdate||m.timestamp||0);(h.includes(":cli:")&&!i.has(h)&&_>1e4||h.includes(":acp:")&&!i.has(h)&&_>1e4||h.includes(":ide:")&&!i.has(h)&&_>3e4)&&a.delete(h)}for(const[h,m]of a)r-(m._lastUpdate||m.timestamp||0)>3e5&&m.status!=="online"&&a.delete(h);return Array.from(a.values())}function an({children:t,connectionOverrides:s}){const[r,a]=n.useState([]),[i,c]=n.useState({}),[o,x]=n.useState(!1),[d,p]=n.useState([]),[u,l]=n.useState(void 0),g=n.useCallback((A,_)=>{a(j=>j.map(w=>w.id===A?{...w,chats:_}:w))},[]),h={injectEntries:A=>{a(_=>_.length===0?A:rn(A,_))},markLoaded:()=>x(!0),getIdes:()=>r},m=s;return e.jsx(vs.Provider,{value:h,children:e.jsx(js.Provider,{value:{ides:r,updateIdeChats:g,screenshotMap:i,setScreenshotMap:c,initialLoaded:o,toasts:d,setToasts:p,wsStatus:(m==null?void 0:m.wsStatus)??"connected",isConnected:(m==null?void 0:m.isConnected)??!0,connectionStates:(m==null?void 0:m.connectionStates)??{},connectionTransports:(m==null?void 0:m.connectionTransports)??{},showReconnected:(m==null?void 0:m.showReconnected)??!1,retryConnection:m==null?void 0:m.retryConnection,isP2PActive:(m==null?void 0:m.isP2PActive)??!1,p2pStates:(m==null?void 0:m.p2pStates)??{},userRole:m==null?void 0:m.userRole,userName:u,setUserName:l},children:t})})}function gt(){return n.useContext(js)}function Qt(){return n.useContext(vs)}function on(t){const{baseUrl:s,getToken:r,onUnauthorized:a}=t;async function i(c,o={}){const x={"Content-Type":"application/json",...o.headers||{}},d=r==null?void 0:r();d&&(x.Authorization=`Bearer ${d}`);const p=c.startsWith("http")?c:`${s}${c.startsWith("/")?"":"/"}${c}`,u=await fetch(p,{...o,headers:x});if(u.status===401)throw a==null||a(),new Error("Unauthorized");if(!u.ok){const l=await u.json().catch(()=>({error:u.statusText}));throw new Error(l.error||`API Error: ${u.status}`)}return u.json()}return{getDaemons:()=>i("/api/v1/daemons"),getDaemonStatus:c=>i(`/api/v1/daemons/${c}/status`),sendCommand:(c,o,x={})=>i(`/api/v1/daemons/${c}/command`,{method:"POST",body:JSON.stringify({type:o,payload:x})}),execTerminal:(c,o,x)=>i(`/api/v1/daemons/${c}/terminal`,{method:"POST",body:JSON.stringify({command:o,name:x})}),sendAgentMessage:(c,o,x)=>i(`/api/v1/shortcuts/${c}/chat`,{method:"POST",body:JSON.stringify({agentType:o,message:x})}),getAgentStatus:c=>i(`/api/v1/shortcuts/${c}/status`),approveAgent:(c,o,x)=>i(`/api/v1/shortcuts/${c}/approve`,{method:"POST",body:JSON.stringify({agentType:o,action:x?"approve":"reject"})}),request:i}}const cn=on({baseUrl:"http://localhost:3847"});n.createContext(cn);const ln={sendCommand:async()=>{throw new Error("TransportContext not initialized")}},ws=n.createContext(ln);function dn({value:t,children:s}){return e.jsx(ws.Provider,{value:t,children:s})}function st(){return n.useContext(ws)}const ke={size:18};function un({size:t=ke.size,className:s}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:s,children:[e.jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),e.jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),e.jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),e.jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1"})]})}function xn({size:t=ke.size,className:s}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:s,children:[e.jsx("rect",{x:"2",y:"2",width:"20",height:"8",rx:"2"}),e.jsx("rect",{x:"2",y:"14",width:"20",height:"8",rx:"2"}),e.jsx("circle",{cx:"6",cy:"6",r:"1",fill:"currentColor",stroke:"none"}),e.jsx("circle",{cx:"6",cy:"18",r:"1",fill:"currentColor",stroke:"none"}),e.jsx("line",{x1:"10",y1:"6",x2:"18",y2:"6"}),e.jsx("line",{x1:"10",y1:"18",x2:"18",y2:"18"})]})}function mn({size:t=ke.size,className:s}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:s,children:[e.jsx("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),e.jsx("circle",{cx:"12",cy:"7",r:"4"})]})}function Ns({size:t=ke.size,className:s}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:s,children:[e.jsx("path",{d:"M4 19.5A2.5 2.5 0 0 1 6.5 17H20"}),e.jsx("path",{d:"M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z"}),e.jsx("line",{x1:"9",y1:"7",x2:"16",y2:"7"}),e.jsx("line",{x1:"9",y1:"11",x2:"14",y2:"11"})]})}function pn({size:t=ke.size,className:s}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:s,children:[e.jsx("path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"}),e.jsx("rect",{x:"8",y:"2",width:"8",height:"4",rx:"1"}),e.jsx("line",{x1:"8",y1:"10",x2:"16",y2:"10"}),e.jsx("line",{x1:"8",y1:"14",x2:"14",y2:"14"}),e.jsx("line",{x1:"8",y1:"18",x2:"12",y2:"18"})]})}function Vt({size:t=ke.size,className:s}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:s,children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}function hn({size:t=ke.size,className:s}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:s,children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]})}function fn({size:t=ke.size,className:s}){return e.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:s,children:e.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"})})}function Et({size:t=ke.size,className:s}){return e.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:s,children:e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function ot({size:t=ke.size,className:s}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:s,children:[e.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),e.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"}),e.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"21"})]})}function gn({size:t=ke.size,className:s}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:s,children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"}),e.jsx("line",{x1:"8",y1:"13",x2:"16",y2:"13"}),e.jsx("line",{x1:"8",y1:"17",x2:"13",y2:"17"})]})}function bn({size:t=ke.size,className:s}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:s,children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function Ot({size:t=ke.size,className:s}){return e.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:s,children:e.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}function ks({size:t=ke.size,className:s}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:s,children:[e.jsx("polyline",{points:"23 4 23 10 17 10"}),e.jsx("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})]})}function Xt({size:t=ke.size,className:s}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:s,children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]})}function bt({size:t=ke.size,className:s}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:s,children:[e.jsx("path",{d:"M12 22v-5"}),e.jsx("path",{d:"M9 8V2"}),e.jsx("path",{d:"M15 8V2"}),e.jsx("path",{d:"M18 8v5a6 6 0 0 1-12 0V8z"})]})}function yn({size:t=ke.size,className:s}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:s,children:[e.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}function Ss({size:t=ke.size,className:s}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:s,children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]})}function jn({size:t=ke.size,className:s}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:s,children:[e.jsx("line",{x1:"18",y1:"20",x2:"18",y2:"10"}),e.jsx("line",{x1:"12",y1:"20",x2:"12",y2:"4"}),e.jsx("line",{x1:"6",y1:"20",x2:"6",y2:"14"})]})}function qt({size:t=ke.size,className:s}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:s,children:[e.jsx("polyline",{points:"4 17 10 11 4 5"}),e.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}function vn({size:t=ke.size,className:s}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:s,children:[e.jsx("path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z"}),e.jsx("path",{d:"M12 15l-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z"}),e.jsx("path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0"}),e.jsx("path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5"})]})}function Cs({size:t=ke.size,className:s}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:s,children:[e.jsx("rect",{x:"3",y:"8",width:"18",height:"12",rx:"2"}),e.jsx("path",{d:"M12 2v6"}),e.jsx("circle",{cx:"8.5",cy:"14",r:"1.5",fill:"currentColor",stroke:"none"}),e.jsx("circle",{cx:"15.5",cy:"14",r:"1.5",fill:"currentColor",stroke:"none"})]})}function wn({size:t=ke.size,className:s}){return e.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:s,children:e.jsx("path",{d:"M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z"})})}function Nn({size:t=ke.size,className:s}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:s,children:[e.jsx("rect",{x:"9",y:"10",width:"6",height:"12",rx:"1"}),e.jsx("path",{d:"M12 2c-1.5 2-3 3.5-3 5a3 3 0 0 0 6 0c0-1.5-1.5-3-3-5z"})]})}function kn({size:t=ke.size,className:s}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:s,children:[e.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),e.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]})}function Sn({size:t=ke.size,className:s}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:s,children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]})}function Cn({size:t=ke.size,className:s}){return e.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:s,children:e.jsx("polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2"})})}function In({size:t=ke.size,className:s}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:s,children:[e.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),e.jsx("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07"})]})}function Mn(t){const r=t.split(`
|
|
2
|
-
`).map(x=>{if(!x.includes("\r"))return x;const d=x.split("\r").map(l=>l.trim()).filter(Boolean);if(d.length===0)return"";const p=d.filter(l=>l.startsWith("⏺"));if(p.length>0)return p[p.length-1];const u=d.filter(l=>!(/^[❯›>]\s*$/.test(l)||/^[^a-zA-Z0-9\s]\s*\S+[…\.]{1,3}\s*$/.test(l)&&l.length<40||/^[╭╰│├╮╯─═]+$/.test(l)));return u.length>0?u[u.length-1]:d[d.length-1]}).join(`
|
|
3
|
-
`).split(`
|
|
4
|
-
`),a={},i=[];let c=!1;for(const x of r){const d=x.trim();if(d===""){c=!1,i.push("");continue}if(/^❯\s*$/.test(d)||/^>\s*$/.test(d)||/^[✡-✩✪-✿⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏◆◇◐◑◒◓]\s*\S+[…\.]{1,3}\s*$/.test(d)||/^◐\s/.test(d)||/\/effort/.test(d)||/^⎿\s+(Tip|Note|Hint):/.test(d)||/^\?\s*(for\s*shortcuts|shortcuts)/.test(d)||/esc\s+to\s+interrupt|shift\+tab\s+to\s+cycle|accept\s+edits\s+on/i.test(d)||/Brewing[…\.]{0,3}\s*\d*$/i.test(d)||/^[✢✳✶✻⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏◆◇✦\s]+$/.test(d)||/^Auto-updating/i.test(d))continue;if(/^[⏺●·⏵]/.test(x)){const u=x.match(/^[⏺●·]\s*([A-Za-z][A-Za-z0-9_]*)\s*[\(\[]/);if(u)a[u[1]]=(a[u[1]]||0)+1;else{const l=x.replace(/^[⏺●·⏵]\s*/,"").trim().slice(0,40);l&&(a[l]=(a[l]||0)+1)}c=!0;continue}if(/^[\s]*[╭╰│├╮╯]/.test(x)||/^[╭╰│├╮╯─]+/.test(d)||/^\s+[⊙✓✗○◎▸►✦]/.test(x)||c&&/^\s{2,}/.test(x))continue;c=!1;const p=x.replace(/^❯\s+/,"");i.push(p)}const o=i.join(`
|
|
5
|
-
`).replace(/\n{3,}/g,`
|
|
6
|
-
|
|
7
|
-
`).trim();return{toolCounts:a,textContent:o,hasTools:Object.keys(a).length>0}}function Rt(t){return t?new Date(t).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0}):""}const Tn=n.forwardRef(function({messages:s,actionLogs:r,agentName:a="Agent",userName:i,isCliMode:c=!1,isWorking:o=!1,contextKey:x="",receivedAtMap:d={},emptyState:p,onLoadMore:u,isLoadingMore:l,hasMoreHistory:g,loadError:h},m){var pe;const A=n.useRef(null),_=n.useRef(null),j=n.useRef(0),w=n.useRef(""),O=n.useRef(!1),[B,$]=n.useState(new Set),[C,W]=n.useState(new Set),S=n.useRef(!1),y=()=>{const q=A.current;return q?q.scrollHeight-q.scrollTop-q.clientHeight<200:!0},se=s.length>0?`${s.length}:${(((pe=s[s.length-1])==null?void 0:pe.content)||"").length}`:"0:0";n.useEffect(()=>{var oe,J;const q=!O.current,G=w.current!==x;if(w.current=x,q||G){O.current=!0,S.current=!1;const ie=()=>{var ce;(ce=_.current)==null||ce.scrollIntoView({behavior:"instant"})};requestAnimationFrame(()=>requestAnimationFrame(ie)),setTimeout(ie,100),setTimeout(ie,300),j.current=s.length;return}s.length>j.current?S.current||(oe=_.current)==null||oe.scrollIntoView({behavior:"instant"}):y()&&!S.current&&((J=_.current)==null||J.scrollIntoView({behavior:"instant"})),j.current=s.length},[se,x,o]),n.useImperativeHandle(m,()=>({scrollToBottom:(q="smooth")=>{var G;(G=_.current)==null||G.scrollIntoView({behavior:q})}})),n.useEffect(()=>{const q=A.current;if(!q)return;let G;const H=()=>{clearTimeout(G),G=setTimeout(()=>{S.current=!y()},50)};return q.addEventListener("scroll",H,{passive:!0}),()=>{q.removeEventListener("scroll",H),clearTimeout(G)}},[]);const R=n.useRef(0),z=n.useRef(!1);n.useEffect(()=>{const q=A.current;if(!q||!z.current||R.current===0)return;const G=q.scrollHeight-R.current;G>0&&(q.scrollTop=G),R.current=0,z.current=!1},[s.length]);const U=()=>{const q=A.current;q&&(R.current=q.scrollHeight),z.current=!0,u==null||u()},v=(()=>{const q=s.map((J,ie)=>({type:"message",data:J,index:ie,ts:J.receivedAt||d[J.id??`i-${ie}`]||0}));if(!r||r.length===0)return q;const G=[...r].sort((J,ie)=>J.timestamp-ie.timestamp).map((J,ie)=>({type:"action",data:J,index:ie,ts:J.timestamp})),H=[];let oe=0;for(const J of q){for(;oe<G.length&&J.ts>0&&G[oe].ts<J.ts;)H.push(G[oe++]);H.push(J)}for(;oe<G.length;)H.push(G[oe++]);return H})(),ne=700;return e.jsxs("div",{ref:A,"data-chat-scroll":!0,className:"chat-container",children:[l&&e.jsx("div",{className:"text-center py-3 text-text-muted text-xs opacity-60 animate-pulse",children:"Loading older messages..."}),g&&!l&&e.jsx("div",{className:"text-center py-2",children:e.jsx("button",{onClick:U,className:`text-[11px] rounded-xl px-4 py-1.5 cursor-pointer border transition-all ${h?"bg-transparent border-yellow-500/30 text-yellow-400 opacity-80 hover:opacity-100":"bg-transparent border-border-subtle text-text-muted opacity-70 hover:opacity-100 hover:border-accent/40"}`,children:h?`↻ ${h}`:"↑ Load older messages"})}),v.length===0&&!g&&(p||e.jsx("div",{className:"text-center mt-16 opacity-20 text-[13px]",children:"Waiting for messages..."})),v.map(q=>{var je;if(q.type==="action"){const me=q.data;return e.jsxs("div",{className:"self-center chat-msg-action",children:[e.jsx(Gt,{remarkPlugins:[Jt],children:me.text}),e.jsx("span",{className:"action-time",children:Rt(me.timestamp)})]},`action-${q.index}`)}const G=q.data,H=q.index,oe=(G.role||"").toLowerCase(),J=oe==="user"||oe==="human",ie=G.kind||(oe==="tool"?"tool":"standard"),ce=G.receivedAt||d[G.id??`i-${H}`],D=`${x}-${H}`,b=B.has(D),P=C.has(D),f=typeof G.content=="string"?G.content:(G.content||[]).map(me=>me.text||"").join(`
|
|
8
|
-
`);if(ie==="thought"){const me=((je=G.meta)==null?void 0:je.label)||"Thought";return e.jsxs("div",{className:"self-start chat-msg-thought",children:[e.jsxs("div",{className:"chat-msg-header",children:[e.jsx(wn,{size:13}),e.jsx("span",{children:me})]}),e.jsx("div",{className:"chat-msg-body",children:f})]},`msg-${H}`)}if(ie==="tool")return e.jsxs("div",{className:"self-start chat-msg-tool",children:[e.jsx("span",{className:"tool-icon",children:"⏺"}),e.jsx("span",{className:"tool-text",children:f.split(`
|
|
9
|
-
`)[0].slice(0,80)})]},`msg-${H}`);if(ie==="terminal"){const me=G.meta||{},de=me.isRunning?"⏳":"✅",F=me.label||"Ran command";return e.jsxs("div",{className:"self-start chat-msg-terminal",children:[e.jsxs("div",{className:"chat-msg-header",children:[e.jsx("span",{children:de}),e.jsx("span",{children:F})]}),e.jsx("pre",{className:"chat-msg-body",children:f})]},`msg-${H}`)}if(ie==="system")return e.jsx("div",{className:"self-center chat-msg-system",children:f.slice(0,100)},`msg-${H}`);const K=!J&&c?Mn(f):null,Y=K?K.textContent:f,te=K?Object.entries(K.toolCounts):[],Se=c&&!J&&!b&&Y.length>ne,Ne=b?f:Se&&!P?Y.slice(0,ne):Y;return e.jsxs("div",{className:`max-w-[88%] min-w-0 flex flex-col gap-1 ${J?"self-end":"self-start"}`,children:[te.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1 items-center mb-0.5",children:[te.map(([me,de])=>e.jsxs("span",{className:"chat-tool-badge",children:["⏺ ",me,de>1?` ×${de}`:""]},me)),(K==null?void 0:K.hasTools)&&e.jsx("button",{onClick:()=>$(me=>{const de=new Set(me);return b?de.delete(D):de.add(D),de}),className:"text-[10px] text-text-muted px-1 py-px opacity-50",children:b?"Collapse":"Original"}),!Y&&ce!=null&&e.jsx("span",{className:"text-[10px] opacity-35 ml-0.5",children:Rt(ce)})]}),(Y||J)&&e.jsxs("div",{className:`chat-bubble ${J?"chat-bubble-user":"chat-bubble-assistant"}`,children:[e.jsxs("div",{className:`chat-bubble-header ${Y?"mb-1.5":"mb-0"}`,children:[e.jsx("span",{className:"chat-sender",children:J?i||"You":a}),ce!=null&&e.jsx("span",{className:"chat-time",children:Rt(ce)})]}),Y&&e.jsx("div",{className:"chat-markdown",children:e.jsx(Gt,{remarkPlugins:[Jt,Us,Ys],children:Ne})}),Se&&e.jsx("button",{onClick:()=>W(me=>{const de=new Set(me);return P?de.delete(D):de.add(D),de}),className:"mt-1.5 text-[11px] font-semibold text-[var(--accent-primary)] p-0 opacity-80",children:P?"Collapse ↑":`Show more (${Math.round(Y.length/100)*100} chars) ↓`})]})]},`msg-${H}`)}),o&&e.jsx("div",{className:"self-start chat-typing-wrapper",children:e.jsxs("div",{className:"typing-indicator",children:[e.jsx("div",{className:"dot"}),e.jsx("div",{className:"dot"}),e.jsx("div",{className:"dot"}),e.jsx("span",{className:"text-[11px] text-text-muted ml-1",children:"Agent working..."})]})}),e.jsx("div",{className:"min-h-10",ref:_})]})}),es={background:"#0f1117",foreground:"#cdd6f4",cursor:"#f38ba8",cursorAccent:"#0f1117",selectionBackground:"rgba(166, 227, 161, 0.3)",selectionForeground:"#cdd6f4",black:"#45475a",red:"#f38ba8",green:"#a6e3a1",yellow:"#f9e2af",blue:"#89b4fa",magenta:"#cba6f7",cyan:"#94e2d5",white:"#bac2de",brightBlack:"#585b70",brightRed:"#f38ba8",brightGreen:"#a6e3a1",brightYellow:"#f9e2af",brightBlue:"#89b4fa",brightMagenta:"#cba6f7",brightCyan:"#94e2d5",brightWhite:"#a6adc8"},Is=n.forwardRef(({onInput:t,onResize:s,fontSize:r=13},a)=>{const i=n.useRef(null),c=n.useRef(null),o=n.useRef(null),[x,d]=n.useState(!1);return n.useImperativeHandle(a,()=>({write:p=>{var u;(u=c.current)==null||u.write(p)},clear:()=>{var p;(p=c.current)==null||p.clear()},fit:()=>{var p;try{(p=o.current)==null||p.fit(),c.current&&(s==null||s(c.current.cols,c.current.rows))}catch{}},bumpResize:()=>{var p;try{(p=o.current)==null||p.fit();const u=c.current;if(!u)return;const l=u.cols,g=u.rows;s==null||s(l+5,g),setTimeout(()=>{s==null||s(l,g)},100)}catch{}}})),n.useEffect(()=>{if(!i.current)return;const p=new tn({cursorBlink:!0,cursorStyle:"bar",fontSize:r,fontFamily:"'JetBrains Mono', 'Fira Code', 'SF Mono', 'Menlo', monospace",fontWeight:"400",letterSpacing:0,lineHeight:1.2,theme:es,allowTransparency:!0,scrollback:5e3,convertEol:!1}),u=new sn,l=new nn;p.loadAddon(u),p.loadAddon(l),p.open(i.current),requestAnimationFrame(()=>{u.fit(),s==null||s(p.cols,p.rows),d(!0)});const g=p.onData(m=>{t(m)}),h=new ResizeObserver(()=>{requestAnimationFrame(()=>{try{u.fit(),s==null||s(p.cols,p.rows)}catch{}})});return h.observe(i.current),c.current=p,o.current=u,()=>{g.dispose(),h.disconnect(),p.dispose(),c.current=null,o.current=null}},[r]),e.jsx("div",{ref:i,className:"w-full h-full rounded-lg overflow-hidden transition-opacity duration-200",style:{background:es.background,opacity:x?1:0}})});Is.displayName="CliTerminal";function wt({label:t,value:s,sub:r,icon:a}){return e.jsxs("div",{className:"px-4 py-3.5 rounded-xl bg-bg-secondary border border-border-subtle",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsx("span",{className:"text-base flex items-center",children:a}),e.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wide font-semibold",children:t})]}),e.jsx("div",{className:"text-[22px] font-bold text-text-primary tracking-tight",children:s}),r&&e.jsx("div",{className:"text-[11px] text-text-muted mt-0.5",children:r})]})}function ts({value:t,max:s,label:r,color:a="#8b5cf6",detail:i,compact:c=!1}){const o=s>0?Math.min(Math.round(t/s*100),100):0,x=o>85?"#ef4444":o>60?"#f59e0b":a;return c?e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex justify-between mb-0.5",children:[e.jsx("span",{className:"text-[9px] text-text-muted uppercase tracking-wide font-semibold",children:r}),e.jsxs("span",{className:"text-[10px] text-text-secondary font-semibold",children:[o,"%"]})]}),e.jsx("div",{className:"h-1 bg-white/[0.04] rounded-sm overflow-hidden",children:e.jsx("div",{className:"h-full rounded-sm transition-[width] duration-500",style:{width:`${o}%`,background:x}})})]}):e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex justify-between mb-1.5",children:[e.jsx("span",{className:"text-[11px] text-text-secondary font-medium",children:r}),e.jsxs("span",{className:"text-[13px] text-text-primary font-bold",children:[o,"%"]})]}),e.jsx("div",{className:"h-1.5 bg-white/[0.04] rounded-sm overflow-hidden",children:e.jsx("div",{className:"h-full rounded-sm transition-[width] duration-[600ms]",style:{width:`${o}%`,background:`linear-gradient(90deg, ${x}, ${x}cc)`}})}),i&&e.jsx("div",{className:"text-[10px] text-text-muted mt-0.5",children:i})]})}function En({onAction:t,addLog:s,connState:r,connScreenshot:a,screenshotUsage:i,transportType:c}){const o=n.useRef(null),x=n.useRef(null),d=n.useRef(null),[p,u]=n.useState(null),[l,g]=n.useState(""),[,h]=n.useState(!1),[m,A]=n.useState([]),_=n.useRef(0),[j,w]=n.useState(!1),[O,B]=n.useState(!1),$=typeof window<"u"&&window.matchMedia("(max-width: 768px)").matches,[C,W]=n.useState($?"mouse":"touch"),[S,y]=n.useState(1),se=n.useRef(!1),[R,z]=n.useState(1),[U,v]=n.useState(0),[ne,pe]=n.useState(0),q=n.useRef(0),G=n.useRef(t),H=n.useRef(null),oe=n.useRef(null),J=n.useRef(!1),ie=n.useRef(null),ce=n.useRef(0),D=n.useRef(null),b=n.useRef(1),P=n.useRef({x:0,y:0}),f=n.useRef(!1),K=n.useRef(R),Y=n.useRef(U),te=n.useRef(ne),Se=n.useRef(C);n.useEffect(()=>{K.current=R},[R]),n.useEffect(()=>{Y.current=U},[U]),n.useEffect(()=>{te.current=ne},[ne]),n.useEffect(()=>{G.current=t},[t]),n.useEffect(()=>{Se.current=C},[C]),n.useEffect(()=>{var M;(M=o.current)==null||M.focus()},[]);const Ne=r==="connected",je=a,me=Ne?"Connected. Waiting for first frame...":r==="connecting"?"Connecting to Host...":"Reconnecting to Host...",de=Ne?"The remote stream is warming up":"Waiting for the remote stream to catch up";n.useEffect(()=>{if(!$||se.current||!je)return;const M=d.current,re=x.current;if(!M||!re)return;const Q=()=>{const ge=re.clientWidth,we=re.clientHeight,N=M.naturalWidth,Z=M.naturalHeight;if(!N||!Z||!ge||!we)return;const L=Math.min(ge/N,we/Z),V=Math.max(ge/N,we/Z)/L;V>1.01&&(y(V),z(V),K.current=V),se.current=!0};M.complete&&M.naturalWidth?Q():M.addEventListener("load",Q,{once:!0})},[je,$]);const F=.5;n.useEffect(()=>{R<=F&&(v(0),pe(0))},[R,F]);const he=(M,re,Q)=>{if(Q<=F)return{x:0,y:0};const ge=(Q-1)/(2*Q)*100,we=(Q-1)/(2*Q)*100;return{x:Math.max(-ge,Math.min(ge,M)),y:Math.max(-we,Math.min(we,re))}},be=(M,re)=>{if(!d.current)return null;const Q=d.current.getBoundingClientRect();return!Q.width||!Q.height?null:{nx:Math.max(0,Math.min(1,(M-Q.left)/Q.width)),ny:Math.max(0,Math.min(1,(re-Q.top)/Q.height))}},ye=(M,re,Q)=>{const ge=x.current;if(!ge)return;const we=ge.getBoundingClientRect(),N=++_.current;A(Z=>[...Z,{id:N,x:M-we.left,y:re-we.top,type:Q}]),setTimeout(()=>A(Z=>Z.filter(L=>L.id!==N)),600)},Me=(M,re,Q)=>{const ge=d.current,we=x.current;if(!ge||!we)return;const N=ge.getBoundingClientRect(),Z=we.getBoundingClientRect(),L=ge.naturalWidth||N.width,xe=ge.naturalHeight||N.height,V=L/xe,ee=N.width/N.height;let ue,X,fe,Ce;V>ee?(ue=N.width,X=N.width/V,fe=0,Ce=(N.height-X)/2):(X=N.height,ue=N.height*V,fe=(N.width-ue)/2,Ce=0);const Ie=N.left-Z.left+fe+ue*M,$e=N.top-Z.top+Ce+X*re,Be=++_.current;A(_e=>[..._e,{id:Be,x:Ie,y:$e,type:Q}]),setTimeout(()=>A(_e=>_e.filter(k=>k.id!==Be)),600)},Ue=async M=>{var Q;const re=be(M.clientX,M.clientY);if(re){u(`Click: ${Math.round(re.nx*100)}%, ${Math.round(re.ny*100)}%`),ye(M.clientX,M.clientY,"left"),(Q=o.current)==null||Q.focus();try{const ge=await t("input_click",{nx:re.nx,ny:re.ny});ge!=null&&ge.success||s(`❌ Click failed: ${ge==null?void 0:ge.error}`)}catch(ge){s(`❌ Click error: ${ge.message||ge}`)}}},Ke=async(M,re,Q,ge=0)=>{try{await t("input_key",{type:Q?"char":"keyDown",key:M,code:re,text:Q?M:void 0,unmodifiedText:Q?M:void 0,modifiers:ge})}catch(we){s(`❌ Key error: ${we.message||we}`)}},Pe=async M=>{if(M.target.tagName==="INPUT")return;["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Backspace","Tab","Enter","Escape"].includes(M.key)&&M.preventDefault();let Q=0;M.altKey&&(Q|=1),M.ctrlKey&&(Q|=2),M.metaKey&&(Q|=4),M.shiftKey&&(Q|=8),u(`Key: ${M.key}`),await Ke(M.key,M.code,M.key.length===1,Q)},dt=async M=>{if(M.key==="Enter"){if(M.nativeEvent.isComposing)return;if(l){const re=l;g(""),u(`IME Sent: ${re}`);try{const Q=await t("input_type",{text:re});Q!=null&&Q.success||s(`❌ IME error: ${Q==null?void 0:Q.error}`)}catch(Q){s(`❌ IME error: ${Q.message}`)}}else u("Key: Enter"),await Ke("Enter","Enter",!1)}};n.useEffect(()=>{const M=o.current;if(!M)return;const re=Q=>{var ge;if((ge=d.current)!=null&&ge.contains(Q.target)){Q.preventDefault();const we=Date.now();if(we-q.current<40)return;q.current=we;const N=be(Q.clientX,Q.clientY);if(!N)return;u(`Scroll: ${Math.round(Q.deltaY)}`),t("input_wheel",{nx:N.nx,ny:N.ny,deltaX:Math.round(Q.deltaX),deltaY:Math.round(Q.deltaY)}).catch(()=>{})}};return M.addEventListener("wheel",re,{passive:!1}),()=>M.removeEventListener("wheel",re)},[t]);const[Oe,Ye]=n.useState(null),Ae=n.useRef(null);return n.useEffect(()=>{if(C==="mouse"&&!Ae.current){const M={nx:.5,ny:.5};Ae.current=M,Ye(M)}},[C]),n.useEffect(()=>{const M=o.current;if(!M)return;const re=L=>{if(!d.current)return null;const xe=d.current.getBoundingClientRect();return!xe.width||!xe.height?null:{nx:Math.max(0,Math.min(1,(L.clientX-xe.left)/xe.width)),ny:Math.max(0,Math.min(1,(L.clientY-xe.top)/xe.height))}},Q=(L,xe)=>{if(!d.current)return{dnx:0,dny:0};const V=d.current,ee=V.getBoundingClientRect(),ue=V.naturalWidth||ee.width,X=V.naturalHeight||ee.height,fe=ue/X,Ce=ee.width/ee.height;let Ie,$e;return fe>Ce?(Ie=ee.width,$e=ee.width/fe):($e=ee.height,Ie=ee.height*fe),{dnx:L/Ie,dny:xe/$e}},ge=(L,xe,V)=>{if(V<=1.05)return;const ee=-(L-.5)*100,ue=-(xe-.5)*100,X=he(ee,ue,V);(Math.abs(X.x-Y.current)>.1||Math.abs(X.y-te.current)>.1)&&(v(X.x),pe(X.y),Y.current=X.x,te.current=X.y)},we=L=>{const xe=x.current;if(xe&&L.target instanceof Node&&xe.contains(L.target))L.preventDefault();else return;if(L.touches.length===1){const V=L.touches[0];H.current={x:V.clientX,y:V.clientY,time:Date.now()},oe.current={x:V.clientX,y:V.clientY},f.current||(J.current=!1),ie.current=setTimeout(()=>{if(!J.current&&!f.current)if(J.current=!0,Se.current==="mouse"){const ee=Ae.current||{nx:.5,ny:.5};u("Right Click"),Me(ee.nx,ee.ny,"right"),G.current("input_click",{...ee,button:"right"}).catch(()=>{})}else{const ee=re(V);ee&&(u("Right Click"),Me(ee.nx,ee.ny,"right"),G.current("input_click",{...ee,button:"right"}).catch(()=>{}))}},500)}else if(L.touches.length===2){clearTimeout(ie.current),J.current=!0,f.current=!0;const V=L.touches[1].clientX-L.touches[0].clientX,ee=L.touches[1].clientY-L.touches[0].clientY;D.current=Math.sqrt(V*V+ee*ee),b.current=K.current,P.current={x:(L.touches[0].clientX+L.touches[1].clientX)/2,y:(L.touches[0].clientY+L.touches[1].clientY)/2}}},N=L=>{const xe=x.current;if(xe&&L.target instanceof Node&&xe.contains(L.target)&&L.preventDefault(),L.touches.length===1&&oe.current){const V=L.touches[0],ee=V.clientX-oe.current.x,ue=V.clientY-oe.current.y;if(!J.current&&H.current){const X=V.clientX-H.current.x,fe=V.clientY-H.current.y;Math.sqrt(X*X+fe*fe)>8&&(J.current=!0,clearTimeout(ie.current))}if(J.current)if(Se.current==="mouse"){const X=Q(ee,ue),fe=Ae.current||{nx:.5,ny:.5},Ce=Math.max(0,Math.min(1,fe.nx+X.dnx)),Ie=Math.max(0,Math.min(1,fe.ny+X.dny));Ae.current={nx:Ce,ny:Ie},Ye({nx:Ce,ny:Ie}),u(`Cursor: ${Math.round(Ce*100)}%, ${Math.round(Ie*100)}%`),ge(Ce,Ie,K.current);const $e=Date.now();$e-q.current>=30&&(q.current=$e,G.current("input_mouseMoved",{nx:Ce,ny:Ie}).catch(()=>{}))}else if(K.current>1){const X=x.current;if(X){const fe=X.clientWidth,Ce=X.clientHeight,Ie=Y.current+ee/fe*100,$e=te.current+ue/Ce*100,Be=he(Ie,$e,K.current);v(Be.x),pe(Be.y),Y.current=Be.x,te.current=Be.y}}else{const X=re(V);if(X){const fe=Date.now();fe-q.current>=40&&(q.current=fe,u("Scroll"),G.current("input_wheel",{nx:X.nx,ny:X.ny,deltaX:Math.round(-ee*2.5),deltaY:Math.round(-ue*2.5)}).catch(()=>{}))}}oe.current={x:V.clientX,y:V.clientY}}else if(L.touches.length===2&&D.current!==null){const V=L.touches[1].clientX-L.touches[0].clientX,ee=L.touches[1].clientY-L.touches[0].clientY,X=Math.sqrt(V*V+ee*ee)/D.current,fe=(L.touches[0].clientX+L.touches[1].clientX)/2,Ce=(L.touches[0].clientY+L.touches[1].clientY)/2,Ie=fe-P.current.x,$e=Ce-P.current.y,Be=Math.abs(X-1)>.03;if(Se.current==="mouse"){if(Be){const _e=Math.max(F,Math.min(5,b.current*X));z(_e),K.current=_e}else if(Math.abs(Ie)>2||Math.abs($e)>2){const _e=Ae.current||{nx:.5,ny:.5},k=Date.now();k-q.current>=30&&(q.current=k,u("Scroll"),G.current("input_wheel",{nx:_e.nx,ny:_e.ny,deltaX:Math.round(-Ie*3),deltaY:Math.round(-$e*3)}).catch(()=>{}))}}else{const _e=Math.max(F,Math.min(5,b.current*X));z(_e),K.current=_e;const k=x.current;if(k&&_e>1){const I=k.clientWidth,T=k.clientHeight,E=Y.current+Ie/I*100,ae=te.current+$e/T*100,le=he(E,ae,_e);v(le.x),pe(le.y),Y.current=le.x,te.current=le.y}}P.current={x:fe,y:Ce}}},Z=L=>{var xe;if(clearTimeout(ie.current),D.current=null,L.touches.length===1&&f.current){const V=L.touches[0];H.current={x:V.clientX,y:V.clientY,time:Date.now()},oe.current={x:V.clientX,y:V.clientY},J.current=!0;return}if(L.touches.length===0){if(f.current){f.current=!1,J.current=!1;return}if(L.changedTouches.length===1&&!J.current){const V=L.changedTouches[0],ee=Date.now(),ue=ee-(((xe=H.current)==null?void 0:xe.time)||0);if(ue<60||ue>400){J.current=!1;return}if(H.current){const X=V.clientX-H.current.x,fe=V.clientY-H.current.y;if(Math.sqrt(X*X+fe*fe)>12){J.current=!1;return}}if(Se.current==="mouse"){const X=Ae.current||re(V);X&&(u(`Click: ${Math.round(X.nx*100)}%, ${Math.round(X.ny*100)}%`),Me(X.nx,X.ny,"left"),G.current("input_click",{...X}).catch(()=>{}))}else{const X=re(V);if(!X)return;ee-ce.current<300?(u("Double tap"),Me(X.nx,X.ny,"double"),G.current("input_click",{...X,clickCount:2}).catch(()=>{}),ce.current=0):(u(`Tap: ${Math.round(X.nx*100)}%, ${Math.round(X.ny*100)}%`),Me(X.nx,X.ny,"left"),G.current("input_click",{...X}).catch(()=>{}),ce.current=ee)}}J.current=!1}};return M.addEventListener("touchstart",we,{passive:!1}),M.addEventListener("touchmove",N,{passive:!1}),M.addEventListener("touchend",Z,{passive:!1}),()=>{M.removeEventListener("touchstart",we),M.removeEventListener("touchmove",N),M.removeEventListener("touchend",Z),clearTimeout(ie.current)}},[]),e.jsxs("div",{ref:o,className:"flex-1 flex flex-col bg-black relative overflow-hidden outline-none touch-none",onKeyDown:Pe,onContextMenu:M=>M.preventDefault(),onFocus:()=>h(!0),onBlur:()=>h(!1),tabIndex:0,children:[e.jsxs("div",{ref:x,className:"flex-1 relative overflow-hidden flex items-center justify-center bg-black",children:[je?e.jsx("img",{ref:d,src:je,alt:"Remote View",style:{display:"block",maxWidth:"100%",maxHeight:"100%",width:"auto",height:"auto",transform:`scale(${R}) translate(${U}%, ${ne}%)`,transformOrigin:"center center",cursor:C==="mouse"?"default":"crosshair",userSelect:"none",WebkitTouchCallout:"none"},onClick:Ue,onContextMenu:M=>M.preventDefault(),onDragStart:M=>M.preventDefault()}):e.jsxs("div",{className:"text-center flex flex-col items-center gap-3 px-6",children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl flex items-center justify-center border border-white/10 bg-white/[0.04] shadow-[0_10px_30px_rgba(0,0,0,0.35)]",style:{animation:"remote-float 2.8s ease-in-out infinite"},children:e.jsx("img",{src:"/otter-logo.png",alt:"",className:"w-8 h-8 opacity-90"})}),e.jsx("div",{className:"text-white/85 text-[13px] font-semibold tracking-wide",children:me}),e.jsx("div",{className:"text-[11px] text-white/40",children:de}),c==="relay"&&e.jsx("div",{className:"text-[10px] text-amber-300/80",children:"TURN relay active"})]}),C==="mouse"&&Oe&&je&&d.current&&(()=>{var Ie;const M=d.current,re=M.getBoundingClientRect(),Q=(Ie=x.current)==null?void 0:Ie.getBoundingClientRect();if(!Q)return null;const ge=M.naturalWidth||re.width,we=M.naturalHeight||re.height,N=ge/we,Z=re.width/re.height;let L,xe,V,ee;N>Z?(L=re.width,xe=re.width/N,V=0,ee=(re.height-xe)/2):(xe=re.height,L=re.height*N,V=(re.width-L)/2,ee=0);const ue=re.left-Q.left+V+L*Oe.nx,X=re.top-Q.top+ee+xe*Oe.ny,fe=Math.max(8,Math.min(Q.width-8,ue)),Ce=Math.max(8,Math.min(Q.height-8,X));return e.jsxs("div",{style:{position:"absolute",left:fe-8,top:Ce-8,width:16,height:16,pointerEvents:"none",zIndex:100},children:[e.jsx("div",{style:{position:"absolute",left:7,top:0,width:2,height:16,background:"rgba(59,130,246,0.8)"}}),e.jsx("div",{style:{position:"absolute",left:0,top:7,width:16,height:2,background:"rgba(59,130,246,0.8)"}}),e.jsx("div",{style:{position:"absolute",left:5,top:5,width:6,height:6,borderRadius:"50%",background:"#3b82f6",boxShadow:"0 0 8px rgba(59,130,246,0.6)"}})]})})(),m.map(M=>{const Q={left:"59,130,246",right:"239,68,68",double:"34,197,94"}[M.type];return e.jsxs("div",{style:{position:"absolute",left:M.x,top:M.y,pointerEvents:"none",zIndex:200,transform:"translate(-50%, -50%)"},children:[e.jsx("div",{style:{width:40,height:40,borderRadius:"50%",border:`2px solid rgba(${Q}, 0.8)`,animation:"click-ripple-ring 0.5s ease-out forwards",position:"absolute",left:-20,top:-20}}),e.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:`rgba(${Q}, 0.9)`,boxShadow:`0 0 12px rgba(${Q}, 0.6)`,animation:"click-ripple-dot 0.4s ease-out forwards",position:"absolute",left:-4,top:-4}})]},M.id)})]}),e.jsxs("div",{onTouchStart:M=>M.stopPropagation(),className:"absolute bottom-0 left-0 right-0 z-20 flex items-center justify-center gap-1.5 px-3 py-2 bg-black/75 backdrop-blur-xl border-t border-white/[0.08] touch-none",children:[e.jsxs("div",{onClick:()=>{W(M=>{const re=M==="touch"?"mouse":"touch";if(re==="mouse"&&!Ae.current){const Q={nx:.5,ny:.5};Ae.current=Q,Ye(Q)}return re})},className:`h-8 px-2.5 rounded-lg flex items-center gap-[5px] cursor-pointer ${C==="mouse"?"bg-blue-500/25 border border-blue-500/40":"bg-white/[0.08] border border-white/10"}`,children:[e.jsx("span",{className:"text-sm",children:C==="mouse"?"🖱️":"👆"}),e.jsx("span",{className:`text-[10px] font-bold ${C==="mouse"?"text-blue-400":"text-slate-400"}`,children:C==="mouse"?"Mouse":"Touch"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{onClick:()=>{B(!O),w(!1)},className:`w-8 h-8 rounded-lg flex items-center justify-center cursor-pointer ${O?"bg-emerald-500/25 border border-emerald-500/40":"bg-white/[0.08] border border-white/10"}`,children:e.jsx("span",{className:"text-sm",children:"⌨️"})}),O&&e.jsx("div",{className:"absolute bottom-10 left-1/2 -translate-x-1/2 w-[220px] bg-neutral-950/[0.98] backdrop-blur-[30px] rounded-xl border border-white/20 p-[10px_12px] shadow-[0_10px_30px_rgba(0,0,0,0.8)] flex flex-col gap-2 z-20",style:{animation:"slideUp 0.15s ease-out"},children:e.jsx("input",{type:"text",placeholder:"Type & Enter...",value:l,autoFocus:!0,onTouchStart:M=>M.stopPropagation(),onChange:M=>g(M.target.value),onKeyDown:dt,className:"w-full bg-black/60 border border-white/15 rounded-lg px-2.5 py-2 text-white text-[13px] outline-none"})})]}),e.jsx("div",{className:"relative",children:e.jsx("div",{onClick:()=>{w(!j),B(!1)},className:`w-8 h-8 rounded-lg flex items-center justify-center cursor-pointer ${j?"bg-blue-500/25 border border-blue-500/40":"bg-white/[0.08] border border-white/10"}`,children:e.jsx("span",{className:"text-sm",children:"⚙️"})})}),e.jsx("div",{className:"w-px h-[18px] bg-white/10"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("div",{className:"flex items-center gap-0.5 px-1.5 py-0.5 rounded-md",style:{background:Ne?"rgba(34,197,94,0.12)":"rgba(234,179,8,0.12)"},children:[e.jsx("div",{className:"w-1 h-1 rounded-full",style:{background:Ne?"#22c55e":"#eab308",boxShadow:Ne?"0 0 4px #22c55e80":"0 0 4px #eab30880"}}),e.jsx("span",{className:"text-[8px] font-extrabold",style:{color:Ne?"#22c55e":"#eab308"},children:Ne?"Connected":"WS"})]}),R>1&&e.jsxs("span",{className:"text-[8px] font-bold text-indigo-400",children:[Math.round(R*100),"%"]}),c==="direct"&&e.jsx("span",{className:"text-[8px] font-bold px-1 py-0.5 rounded",style:{color:"#22c55e",background:"rgba(34,197,94,0.12)"},title:"Direct P2P connection",children:"Direct"}),c==="relay"&&e.jsx("span",{className:"text-[8px] font-bold px-1 py-0.5 rounded",style:{color:"#f59e0b",background:"rgba(245,158,11,0.12)"},title:"TURN relay in use",children:"Relay"}),i&&i.dailyBudgetMinutes>0&&e.jsx("span",{className:"text-[8px] font-bold px-1 py-0.5 rounded",style:{color:i.budgetExhausted?"#ef4444":"#c4b5fd",background:i.budgetExhausted?"rgba(239,68,68,0.1)":"rgba(139,92,246,0.14)"},title:"Daily TURN relay usage",children:i.budgetExhausted?"TURN blocked":`TURN ${i.dailyUsedMinutes}/${i.dailyBudgetMinutes}m`}),p&&e.jsx("span",{className:"text-[8px] text-neutral-500 font-semibold max-w-[100px] overflow-hidden text-ellipsis whitespace-nowrap",children:p})]})]}),j&&e.jsxs("div",{onTouchStart:M=>M.stopPropagation(),style:{position:"absolute",bottom:56,left:"50%",transform:"translateX(-50%)",width:220,background:"rgba(23, 23, 23, 0.95)",backdropFilter:"blur(25px)",borderRadius:14,border:"1px solid rgba(255,255,255,0.1)",padding:14,boxShadow:"0 12px 40px rgba(0,0,0,0.6)",display:"flex",flexDirection:"column",gap:12,zIndex:20,touchAction:"none",animation:"slideUpSidebar 0.15s ease-out"},children:[e.jsx("div",{style:{fontSize:9,fontWeight:900,color:"#3b82f6",letterSpacing:1.5},children:"SETTINGS"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsxs("div",{style:{fontSize:10,color:"#888",fontWeight:700},children:["ZOOM: ",R<=($?S:1)+.01?$?"FILL":"FIT":`${Math.round(R*100)}%`]}),e.jsxs("div",{style:{display:"flex",gap:4},children:[e.jsx("button",{onClick:M=>{M.stopPropagation(),z(re=>Math.max(.5,re-.25))},style:{flex:1,background:"rgba(255,255,255,0.1)",color:"#fff",border:"none",padding:"6px",borderRadius:6,fontSize:12,fontWeight:800,cursor:"pointer"},children:"−"}),e.jsx("button",{onClick:M=>{M.stopPropagation();const re=$?S:1;z(re),K.current=re,v(0),pe(0)},style:{flex:1,background:"rgba(255,255,255,0.1)",color:"#fff",border:"none",padding:"6px",borderRadius:6,fontSize:9,fontWeight:800,cursor:"pointer"},children:$?"FILL":"FIT"}),e.jsx("button",{onClick:M=>{M.stopPropagation(),z(re=>Math.min(5,re+.25))},style:{flex:1,background:"rgba(255,255,255,0.1)",color:"#fff",border:"none",padding:"6px",borderRadius:6,fontSize:12,fontWeight:800,cursor:"pointer"},children:"+"})]})]})]}),e.jsx("style",{children:`
|
|
10
|
-
@keyframes slideUp {
|
|
11
|
-
from { opacity: 0; transform: translateY(6px); }
|
|
12
|
-
to { opacity: 1; transform: translateY(0); }
|
|
13
|
-
}
|
|
14
|
-
@keyframes slideUpSidebar {
|
|
15
|
-
from { opacity: 0; transform: translateY(6px); }
|
|
16
|
-
to { opacity: 1; transform: translateY(0); }
|
|
17
|
-
}
|
|
18
|
-
@keyframes click-ripple-ring {
|
|
19
|
-
0% { transform: scale(0.3); opacity: 1; }
|
|
20
|
-
100% { transform: scale(2.2); opacity: 0; }
|
|
21
|
-
}
|
|
22
|
-
@keyframes click-ripple-dot {
|
|
23
|
-
0% { transform: scale(1); opacity: 0.9; }
|
|
24
|
-
50% { transform: scale(1.8); opacity: 0.6; }
|
|
25
|
-
100% { transform: scale(0.5); opacity: 0; }
|
|
26
|
-
}
|
|
27
|
-
@keyframes remote-float {
|
|
28
|
-
0% { transform: translateY(0px); }
|
|
29
|
-
50% { transform: translateY(-7px); }
|
|
30
|
-
100% { transform: translateY(0px); }
|
|
31
|
-
}
|
|
32
|
-
`})]})}function An({screenshotUrl:t,mode:s="preview",zoom:r=100,interactive:a=!1,connectionState:i,onDismiss:c,onClickAt:o,onKeyDown:x,badge:d,emptyMessage:p,aspectRatio:u,className:l,style:g}){const h=n.useRef(null),m=n.useCallback(A=>{if(!a||!o||!h.current)return;const _=h.current,j=_.getBoundingClientRect(),w=(A.clientX-j.left)/j.width*_.naturalWidth,O=(A.clientY-j.top)/j.height*_.naturalHeight;o(w,O,_.naturalWidth,_.naturalHeight)},[a,o]);return s==="preview"?t?e.jsxs("div",{className:`relative rounded-xl overflow-hidden border border-border-subtle bg-bg-secondary ${l||""}`,style:{aspectRatio:u||"16/9",...g},children:[e.jsx("img",{ref:h,src:t,alt:"IDE Screenshot",className:"w-full h-full object-cover"}),c&&e.jsx("button",{onClick:c,className:"absolute top-2.5 right-2.5 bg-black/50 border-none text-white w-5 h-5 rounded-full text-[10px] z-10 cursor-pointer flex items-center justify-center",children:"✕"})]}):null:t?e.jsxs("div",{className:`${a?"screenshot-interactive":""} ${l||""} relative h-full flex items-center justify-center overflow-auto`,tabIndex:a?0:void 0,onKeyDown:a?x:void 0,style:g,children:[e.jsx("img",{ref:h,src:t,alt:"IDE Screenshot",onClick:a?m:void 0,className:"max-w-full max-h-full object-contain",style:{...a?{cursor:"crosshair"}:{},...r!==100?{transform:`scale(${r/100})`,transformOrigin:"center center"}:{}}}),d&&e.jsx("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 bg-black/70 text-white px-3.5 py-1.5 rounded-[20px] text-xs font-semibold backdrop-blur-sm",children:d})]}):e.jsxs("div",{className:`flex items-center justify-center flex-col gap-2 h-full text-text-muted ${l||""}`,style:g,children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl flex items-center justify-center border border-white/10 bg-white/[0.04] shadow-[0_10px_30px_rgba(0,0,0,0.22)] mb-1",style:{animation:"remote-float 2.8s ease-in-out infinite"},children:e.jsx("img",{src:"/otter-logo.png",alt:"",className:"w-8 h-8 opacity-90"})}),e.jsx("p",{className:"text-base",children:p||"Waiting for screenshot stream..."}),i&&e.jsxs("p",{className:"text-[13px] mt-2 opacity-50",children:["P2P: ",i]}),e.jsx("style",{children:`
|
|
33
|
-
@keyframes remote-float {
|
|
34
|
-
0% { transform: translateY(0px); }
|
|
35
|
-
50% { transform: translateY(-7px); }
|
|
36
|
-
100% { transform: translateY(0px); }
|
|
37
|
-
}
|
|
38
|
-
`})]})}function $n({activeConv:t,onModalButton:s}){const[r,a]=n.useState(null);if(n.useEffect(()=>{a(null)},[t.modalMessage,t.status]),t.status!=="waiting_approval"||!t.modalButtons)return null;const i=o=>{r||(a(o),s(o))},c=o=>o.replace(/[⌥⏎⇧⌫⌘⌃↵]/g,"").replace(/\s*(Alt|Ctrl|Shift|Cmd|Enter|Return|Esc|Tab|Backspace)(\+\s*\w+)*/gi,"").trim();return e.jsxs("div",{className:"bg-gradient-to-br from-amber-600 to-amber-700 text-white py-2.5 px-4 shrink-0 z-[5]",children:[t.modalMessage&&e.jsx("div",{className:"text-[11px] opacity-85 mb-1.5 whitespace-nowrap overflow-hidden text-ellipsis max-w-full",children:t.modalMessage.replace(/[\n\r]+/g," ").slice(0,120)}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"font-black text-xs flex items-center gap-2",children:[e.jsx(Xt,{size:14})," ",r?"PROCESSING...":"ACTION REQUIRED"]}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:t.modalButtons.map((o,x)=>{const d=c(o).toLowerCase(),p=/^(run|approve|accept|yes|allow|always)/.test(d),u=/^(reject|deny|delete|remove|abort)/.test(d),l=r===o,g=r!==null;return e.jsx("button",{onClick:()=>i(o),disabled:g,className:`btn btn-sm border-none rounded-md text-xs px-3 py-1 ${p?"bg-white text-amber-700 font-extrabold":u?"bg-red-500/30 text-white font-semibold":"bg-white/15 text-white font-semibold"} ${g&&!l?"opacity-40":"opacity-100"} ${g?"cursor-not-allowed":"cursor-pointer"}`,children:l?"⏳ ...":c(o)},x)})})]})]})}const Fe=new Map;function _n({ideId:t,ideType:s,agentType:r,agentName:a,serverModel:i,serverMode:c,acpConfigOptions:o,acpModes:x}){var D;const{sendCommand:d}=st(),p=!!(o||x),u=`${t}:${r}`,l=Fe.get(u),[g,h]=n.useState(!1),[m,A]=n.useState(!1),[_,j]=n.useState((l==null?void 0:l.models)||[]),[w,O]=n.useState((l==null?void 0:l.modes)||[]),B=b=>b?typeof b=="string"?b:typeof b=="object"?b.name||b.id||JSON.stringify(b):String(b):"",[$,C]=n.useState(B(i)),[W,S]=n.useState(B(c)),[y,se]=n.useState(!1),[R,z]=n.useState(!1),U=n.useRef(0),v=b=>b.map(P=>typeof P=="string"?P:(P==null?void 0:P.name)||(P==null?void 0:P.id)||String(P));n.useEffect(()=>{if(o){const b=o.find(P=>P.category==="model");if(b){const P=v(b.options.map(K=>K.value));j(P),b.currentValue&&C(B(b.currentValue));const f=Fe.get(u)||{models:[],modes:[]};Fe.set(u,{...f,models:P})}}if(x&&x.length>0){const b=v(x.map(f=>f.id));O(b);const P=Fe.get(u)||{models:[],modes:[]};Fe.set(u,{...P,modes:b})}else if(o){const b=o.find(P=>P.category!=="model");if(b){const P=v(b.options.map(K=>K.value));O(P),b.currentValue&&S(B(b.currentValue));const f=Fe.get(u)||{models:[],modes:[]};Fe.set(u,{...f,modes:P})}}},[o,x,u]),n.useEffect(()=>{h(!1),A(!1),C(B(i)),S(B(c));const b=Fe.get(u);b?(j(b.models),O(b.modes)):(j([]),O([]))},[t,r]),n.useEffect(()=>{i&&Date.now()>U.current&&C(B(i))},[i]),n.useEffect(()=>{c&&Date.now()>U.current&&S(B(c))},[c]);const ne=n.useCallback(async(b,P={})=>{const f={...P},K=t.split(":");return K.length>=3&&(K[1]==="ide"||K[1]==="cli"||K[1]==="acp")&&(f._targetInstance=K.slice(2).join(":"),f._targetType=K[1]),await d(t,b,f)},[t]),pe=async()=>{var b,P;if(_.length>0){h(!g);return}if(p){h(!0);return}se(!0);try{const f=await ne("list_extension_models",{agentType:r,ideType:s}),K=(f==null?void 0:f.models)||((b=f==null?void 0:f.result)==null?void 0:b.models)||[],Y=v(K);j(Y),f!=null&&f.current&&C(B(f.current)),(P=f==null?void 0:f.result)!=null&&P.current&&C(B(f.result.current));const te=Fe.get(u)||{models:[],modes:[]};Fe.set(u,{...te,models:Y}),h(!0)}catch{}finally{se(!1)}},q=async()=>{var b,P;if(w.length>0){A(!m);return}if(p){A(!0);return}z(!0);try{const f=await ne("list_extension_modes",{agentType:r,ideType:s}),K=(f==null?void 0:f.modes)||((b=f==null?void 0:f.result)==null?void 0:b.modes)||[],Y=v(K);O(Y),f!=null&&f.current&&S(B(f.current)),(P=f==null?void 0:f.result)!=null&&P.current&&S(B(f.result.current));const te=Fe.get(u)||{models:[],modes:[]};Fe.set(u,{...te,modes:Y}),A(!0)}catch{}finally{z(!1)}},G=async b=>{h(!1),C(b),U.current=Date.now()+5e3;try{p?await ne("change_model",{agentType:r,ideType:s,model:b}):await ne("set_extension_model",{agentType:r,ideType:s,model:b})}catch{}},H=p&&!(x&&x.length>0)&&(o==null?void 0:o.some(b=>b.category!=="model")),oe=H?(D=o==null?void 0:o.find(b=>b.category!=="model"))==null?void 0:D.configId:void 0,J=async b=>{A(!1),S(b),U.current=Date.now()+5e3;try{p&&H&&oe?await ne("set_thought_level",{agentType:r,ideType:s,configId:oe,value:b}):p?await ne("set_mode",{agentType:r,ideType:s,mode:b}):await ne("set_extension_mode",{agentType:r,ideType:s,mode:b})}catch{}},ce={cline:"#22d3ee","roo-code":"#a78bfa",cursor:"#60a5fa",antigravity:"#f97316",windsurf:"#34d399"}[r]||"#94a3b8";return e.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1 flex-wrap text-[10px] border-t border-border-subtle bg-[var(--surface-primary)]",children:[e.jsx("span",{className:"text-[9px] font-bold tracking-wide uppercase opacity-70",style:{color:ce},children:a}),e.jsx("span",{className:"text-border-subtle text-[10px]",children:"│"}),e.jsxs("div",{className:"relative",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-xl text-[10px] font-medium cursor-pointer transition-all bg-[var(--surface-tertiary)] whitespace-nowrap max-w-40 overflow-hidden text-ellipsis",style:{borderColor:g?`${ce}55`:"transparent",border:"1px solid",color:$?"var(--text-primary)":"var(--text-muted)"},onClick:pe,children:[e.jsx("span",{className:"text-[9px] opacity-60",children:"🤖"}),y?"...":$||"Model",e.jsx("span",{className:"text-[7px] opacity-50",children:"▼"})]}),g&&_.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-[59]",onClick:()=>h(!1)}),e.jsxs("div",{className:"absolute bottom-full left-0 z-[60] bg-[var(--surface-primary)] border border-border-subtle rounded-lg mb-1 max-h-[220px] overflow-y-auto min-w-40 shadow-[0_-4px_16px_rgba(0,0,0,0.3)]",children:[e.jsx("div",{className:"px-3 py-1.5 text-[9px] font-bold text-text-muted tracking-wider border-b border-border-subtle",children:"SELECT MODEL"}),_.map(b=>e.jsx("div",{className:"px-3 py-[7px] text-[11px] cursor-pointer whitespace-nowrap overflow-hidden text-ellipsis",style:{background:b===$?`${ce}18`:"transparent",color:b===$?ce:"var(--text-secondary)",fontWeight:b===$?600:400,borderLeft:b===$?`2px solid ${ce}`:"2px solid transparent"},onMouseEnter:P=>{P.currentTarget.style.background=`${ce}12`},onMouseLeave:P=>{P.currentTarget.style.background=b===$?`${ce}18`:"transparent"},onClick:()=>G(b),children:b},b))]})]})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-xl text-[10px] font-medium cursor-pointer transition-all bg-[var(--surface-tertiary)] whitespace-nowrap max-w-40 overflow-hidden text-ellipsis",style:{borderColor:m?`${ce}55`:"transparent",border:"1px solid",color:W?"var(--text-primary)":"var(--text-muted)"},onClick:q,children:[e.jsx("span",{className:"text-[9px] opacity-60",children:H?"🧠":"⚡"}),R?"...":W||(H?"Thinking":"Mode"),e.jsx("span",{className:"text-[7px] opacity-50",children:"▼"})]}),m&&w.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-[59]",onClick:()=>A(!1)}),e.jsxs("div",{className:"absolute bottom-full left-0 z-[60] bg-[var(--surface-primary)] border border-border-subtle rounded-lg mb-1 max-h-[220px] overflow-y-auto min-w-40 shadow-[0_-4px_16px_rgba(0,0,0,0.3)]",children:[e.jsx("div",{className:"px-3 py-1.5 text-[9px] font-bold text-text-muted tracking-wider border-b border-border-subtle",children:H?"SELECT THINKING LEVEL":"SELECT MODE"}),w.map(b=>e.jsx("div",{className:"px-3 py-[7px] text-[11px] cursor-pointer whitespace-nowrap overflow-hidden text-ellipsis",style:{background:b===W?`${ce}18`:"transparent",color:b===W?ce:"var(--text-secondary)",fontWeight:b===W?600:400,borderLeft:b===W?`2px solid ${ce}`:"2px solid transparent"},onMouseEnter:P=>{P.currentTarget.style.background=`${ce}12`},onMouseLeave:P=>{P.currentTarget.style.background=b===W?`${ce}18`:"transparent"},onClick:()=>J(b),children:b},b))]})]})]})]})}const We=t=>(t.ideId||t.tabKey||t.id||"").includes(":cli:"),Re=t=>(t.ideId||t.tabKey||t.id||"").includes(":acp:");function Ms({activeConv:t,ides:s,agentInput:r,setAgentInput:a,handleSendChat:i,handleFocusAgent:c,isFocusingAgent:o,messageReceivedAt:x,actionLogs:d,userName:p}){const u=n.useRef(null),{sendCommand:l}=st(),g=n.useRef(new Map),h=n.useCallback(y=>(g.current.has(y)||g.current.set(y,{messages:[],offset:0,hasMore:!0,error:null}),g.current.get(y)),[]),m=n.useCallback((y,se)=>{const R=h(y);g.current.set(y,{...R,...se}),A(z=>z+1)},[h]),[,A]=n.useState(0),_=t.tabKey,j=h(_),w=j.messages,O=j.hasMore,B=j.error,[$,C]=n.useState(!1),W=n.useCallback(async()=>{var R,z;if($)return;const y=t.tabKey,se=h(y);C(!0),m(y,{error:null});try{const U=s.find(oe=>oe.id===t.ideId),v=(U==null?void 0:U.daemonId)||((R=t.ideId)==null?void 0:R.split(":")[0])||"";if(!v){m(y,{hasMore:!1});return}const ne=t.ideType||t.agentType||"",pe=(t.ideId||"").split(":"),q=pe.length>=3?pe.slice(2).join(":"):void 0,G=await l(v,"chat_history",{agentType:ne,offset:se.offset,limit:30,instanceId:q}),H=(G==null?void 0:G.result)??G;if(((z=H.messages)==null?void 0:z.length)>0){const oe=h(y);m(y,{messages:[...H.messages,...oe.messages],offset:oe.offset+H.messages.length,hasMore:!!H.hasMore})}else m(y,{hasMore:!!H.hasMore})}catch(U){const v=(U==null?void 0:U.message)||"";v.includes("P2P not available")||v.includes("channel not open")||v.includes("P2P not connected")||v.includes("timeout")?m(y,{error:"Connection not ready — tap to retry"}):m(y,{hasMore:!1,error:"Failed to load history"})}finally{C(!1)}},[$,s,t,l,h,m]),S=(()=>{const y=t.messages.map((z,U)=>{const v=`${t.ideId}-${z.id??`i-${U}`}`;return{...z,receivedAt:z.receivedAt||x[v]||0}});if(w.length===0)return y;const se=new Set(y.map(z=>`${z.role}:${(z.content||"").slice(0,100)}`));return[...w.filter(z=>!se.has(`${z.role}:${(z.content||"").slice(0,100)}`)),...y]})();return e.jsxs(e.Fragment,{children:[e.jsx(Tn,{messages:S,actionLogs:d.filter(y=>y.ideId===t.tabKey).sort((y,se)=>y.timestamp-se.timestamp),agentName:t.agentName||t.displayPrimary||"Agent",userName:p,isCliMode:We(t)||Re(t),isWorking:t.status==="working",contextKey:t.tabKey,onLoadMore:W,isLoadingMore:$,hasMoreHistory:O,loadError:B??void 0,emptyState:t.messages.length===0?t.connectionState==="connecting"||t.connectionState==="new"?e.jsxs("div",{className:"text-center mt-16 flex flex-col items-center gap-4",children:[e.jsx("div",{className:"connecting-logo-float",children:e.jsx("div",{style:{width:64,height:64,borderRadius:"50%",background:"radial-gradient(circle, rgba(96,165,250,0.12), transparent 70%)",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 0 40px rgba(96,165,250,0.08)"},children:e.jsx("img",{src:"/otter-logo.png",alt:"ADHDev",style:{width:40,height:40,borderRadius:"50%",opacity:.85}})})}),e.jsxs("div",{className:"flex flex-col items-center gap-1.5",children:[e.jsxs("div",{className:"text-[13px] text-blue-400 font-medium",children:["Connecting to your machine",e.jsx("span",{className:"connecting-dots"})]}),e.jsx("div",{className:"text-[11px] opacity-35",children:"Establishing P2P connection"})]})]}):t.status==="not_monitored"?e.jsxs("div",{className:"text-center mt-16 flex flex-col items-center gap-3",children:[e.jsx("div",{className:"text-3xl opacity-60",children:e.jsx(bt,{size:28})}),e.jsx("div",{className:"text-[13px] opacity-50",children:"Agent not monitored"}),e.jsx("button",{onClick:c,disabled:o,className:"btn btn-primary",children:o?"⌛ Switching...":e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Ot,{size:14})," Open ",t.displayPrimary," Panel"]})}),e.jsx("div",{className:"text-[11px] opacity-35 max-w-[280px]",children:"Click to switch monitoring to this agent"})]}):t.status==="panel_hidden"?e.jsxs("div",{className:"text-center mt-16 flex flex-col items-center gap-3",children:[e.jsx("div",{className:"text-3xl opacity-60",children:e.jsx(yn,{size:28})}),e.jsx("div",{className:"text-[13px] opacity-50",children:"Agent panel is not visible yet"}),e.jsx("button",{onClick:c,disabled:o,className:"btn btn-primary",children:o?"⌛ Opening...":e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Ot,{size:14})," Open ",t.displayPrimary," Panel"]})}),e.jsx("div",{className:"text-[11px] opacity-35 max-w-[280px]",children:"Open the agent panel or chat view in the app you are using to start viewing messages"})]}):t.status==="idle"&&!$?e.jsxs("div",{className:"text-center mt-16 flex flex-col items-center gap-3",children:[e.jsx("div",{className:"text-2xl opacity-40 animate-pulse",children:"💬"}),e.jsx("div",{className:"text-[13px] opacity-40",children:"Loading chat..."})]}):void 0:void 0}),!We(t)&&(()=>{var se,R,z,U;const y=s.find(v=>v.id===t.ideId);return e.jsx(_n,{ideId:t.ideId,ideType:t.ideType,agentType:t.streamSource==="agent-stream"?t.agentType:((R=(se=y==null?void 0:y.agents)==null?void 0:se[0])==null?void 0:R.type)||t.ideType,agentName:t.streamSource==="agent-stream"?t.agentName:((U=(z=y==null?void 0:y.agents)==null?void 0:z[0])==null?void 0:U.name)||t.agentName,serverModel:(y==null?void 0:y.currentModel)||void 0,serverMode:(y==null?void 0:y.currentPlan)||void 0,acpConfigOptions:Re(t)?y==null?void 0:y.acpConfigOptions:void 0,acpModes:Re(t)?y==null?void 0:y.acpModes:void 0})})(),e.jsx("div",{className:"dashboard-input-area px-3 py-2.5 bg-[var(--surface-primary)] border-t border-border-subtle shrink-0",children:e.jsxs("div",{className:"flex gap-2.5 items-center",children:[e.jsx("div",{className:"flex-1 relative",children:e.jsx("input",{ref:u,type:"text",placeholder:`Send message to ${t.displayPrimary}...`,value:r,onChange:y=>a(y.target.value),onPaste:y=>{const se=y.clipboardData.getData("text");se&&a(R=>R+se),y.preventDefault()},onKeyDown:y=>{if(y.key==="Enter"){if(y.nativeEvent.isComposing){y.preventDefault();return}y.preventDefault(),i()}},onBlur:y=>{if(window.innerWidth<768){const se=y.relatedTarget;if((se==null?void 0:se.tagName)==="BUTTON")return;setTimeout(()=>{document.documentElement.scrollTop=0},300)}},className:"w-full h-10 rounded-[20px] px-4 bg-bg-secondary text-sm text-text-primary",style:{border:"1px solid var(--chat-input-border, var(--border-subtle))"}})}),e.jsx("button",{onClick:i,disabled:!r.trim(),className:`w-10 h-10 rounded-full flex items-center justify-center border-none shrink-0 transition-all duration-300 ${r.trim()?"cursor-pointer":"bg-bg-secondary cursor-default"}`,style:r.trim()?{background:"var(--chat-send-bg, var(--accent-primary))"}:void 0,children:e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:r.trim()?"text-white":"text-text-muted",children:e.jsx("path",{d:"M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z"})})})]})})]})}const Pt=new Set,Ts={emit(t,s){for(const r of Pt)r(t,s)},on(t){return Pt.add(t),()=>{Pt.delete(t)}}};function Rn({activeConv:t,ptyBuffers:s,terminalRef:r,agentInput:a,setAgentInput:i,handleSendChat:c}){var g;const o=n.useRef(null),{sendCommand:x,sendData:d}=st(),p=(g=t.ideId)!=null&&g.includes(":cli:")?t.ideId.split(":cli:")[1]:"",u=t.tabKey,l=t.ideType||t.agentType||"";return n.useEffect(()=>{const h=s.current.get(u);if(h&&h.length>0){const m=setTimeout(()=>{var A;for(const _ of h)(A=r.current)==null||A.write(_);requestAnimationFrame(()=>{var _;(_=r.current)==null||_.bumpResize()})},100);return()=>clearTimeout(m)}},[u]),n.useEffect(()=>{const h=Ts.on((m,A)=>{var j;if(!A)return;(m===p||m===l||m===t.ideId||m===t.tabKey)&&((j=r.current)==null||j.write(A))});return()=>{h()}},[p,l]),e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex-1 min-h-0 p-2 bg-[#0f1117]",children:e.jsx(Is,{ref:r,onInput:h=>{var _;const m=t.ideId||t.daemonId||"",A=(_=t.ideId)!=null&&_.includes(":cli:")?t.ideId.split(":cli:")[1]:t.ideType||t.agentType||"";d!=null&&d(m,{type:"pty_input",cliType:A,data:h})||x(m,"pty_input",{cliType:A,data:h}).catch(console.error)},onResize:(h,m)=>{var j;const A=t.ideId||t.daemonId||"",_=(j=t.ideId)!=null&&j.includes(":cli:")?t.ideId.split(":cli:")[1]:t.ideType||t.agentType||"";d!=null&&d(A,{type:"pty_resize",cliType:_,cols:h,rows:m})||x(A,"pty_resize",{cliType:_,cols:h,rows:m,force:!0}).catch(()=>{})}},t.tabKey)}),e.jsx("div",{className:"px-3 py-2 bg-[var(--surface-primary)] border-t border-border-subtle shrink-0",children:e.jsxs("div",{className:"flex gap-2.5 items-center",children:[e.jsx("div",{className:"flex-1 relative",children:e.jsx("input",{ref:o,type:"text",placeholder:`Send message to ${t.displayPrimary}...`,value:a,onChange:h=>i(h.target.value),onPaste:h=>{const m=h.clipboardData.getData("text");m&&i(A=>A+m),h.preventDefault()},onKeyDown:h=>{if(h.key==="Enter"){if(h.nativeEvent.isComposing){h.preventDefault();return}h.preventDefault(),c()}},className:"w-full h-9 rounded-[18px] px-4 bg-bg-secondary text-[13px] text-text-primary",style:{border:"1px solid var(--chat-input-border, var(--border-subtle))"}})}),e.jsx("button",{onClick:c,disabled:!a.trim(),className:`w-9 h-9 rounded-full flex items-center justify-center border-none shrink-0 transition-all duration-300 ${a.trim()?"cursor-pointer":"bg-bg-secondary cursor-default"}`,style:a.trim()?{background:"var(--chat-send-bg, var(--accent-primary))"}:void 0,children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:a.trim()?"text-white":"text-text-muted",children:e.jsx("path",{d:"M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z"})})})]})})]})}function Pn({wsStatus:t,showReconnected:s,loginUrl:r}){const a=t==="disconnected"||t==="reconnecting"||t==="offline"||t==="auth_failed",i=t==="auth_failed"?"red":t==="offline"?"orange":"violet",c={red:"linear-gradient(90deg, rgba(239,68,68,0.12), rgba(239,68,68,0.04))",orange:"linear-gradient(90deg, rgba(255,107,53,0.12), rgba(255,107,53,0.04))",violet:"linear-gradient(90deg, rgba(139,92,246,0.12), rgba(139,92,246,0.04))"},o={red:"1px solid rgba(239,68,68,0.2)",orange:"1px solid rgba(255,107,53,0.2)",violet:"1px solid rgba(139,92,246,0.2)"},x={red:"#ef4444",orange:"#ff6b35",violet:"#a78bfa"};return e.jsxs(e.Fragment,{children:[a&&e.jsxs("div",{className:"py-2.5 px-5 text-[13px] font-semibold flex items-center gap-2.5 justify-center",style:{background:c[i],borderBottom:o[i],color:x[i]},children:[e.jsx("img",{src:"/otter-logo.png",alt:"",className:"w-5 h-5",style:{opacity:t==="auth_failed"?.6:1,animation:t==="auth_failed"?void 0:"pulse 2s ease-in-out infinite",filter:t==="auth_failed"?"grayscale(1)":void 0}}),t==="offline"&&"Network offline — waiting for connection...",t==="disconnected"&&"Reconnecting to server...",t==="reconnecting"&&"Reconnecting to server...",t==="auth_failed"&&(r?e.jsxs(e.Fragment,{children:["Session expired."," ",e.jsx("a",{href:r,className:"text-inherit underline",children:"Log in again"})]}):"Connection failed — please restart the server.")]}),s&&t==="connected"&&e.jsxs("div",{className:"py-2 px-4 text-xs font-semibold flex items-center gap-2 justify-center bg-gradient-to-r from-green-500/[0.12] to-green-500/[0.04] text-green-400 border-b border-green-500/15 animate-[fadeIn_0.3s_ease]",children:[e.jsx("img",{src:"/otter-logo.png",alt:"",className:"w-4 h-4"}),"Connected"]})]})}let Es=gt;function $t(){return Es()}class Ln{constructor(){Ee(this,"listeners",new Map)}send(s){}isConnected(){return!1}on(s,r){return this.listeners.has(s)||this.listeners.set(s,new Set),this.listeners.get(s).add(r),()=>{var a;(a=this.listeners.get(s))==null||a.delete(r)}}emit(s,...r){var a;(a=this.listeners.get(s))==null||a.forEach(i=>i(...r))}}let As=new Ln;class Dn{constructor(){Ee(this,"ptyCallbacks",new Set)}sendPtyInput(s,r,a){return!1}sendPtyResize(s,r,a,i){return!1}async requestChatHistory(s,r,a,i,c){return{messages:[],hasMore:!1}}retryConnection(s){}getState(s){return"disconnected"}sendData(s,r){return!1}get(s){}onScreenshot(s,r){return()=>{}}onPtyOutput(s){return this.ptyCallbacks.add(s),()=>{this.ptyCallbacks.delete(s)}}emitPtyOutput(s,r){this.ptyCallbacks.forEach(a=>a(s,r))}}let et=new Dn,Kt=et;function Bn(t){t.dashboardWS&&(As=t.dashboardWS),t.connectionManager&&(et=t.connectionManager,Kt=t.connectionManager),t.p2pManager&&(Kt=t.p2pManager),t.useDaemonsHook&&(Es=t.useDaemonsHook)}function Wn({activeConv:t,agentCount:s,wsStatus:r,isConnected:a,onOpenHistory:i,cliViewMode:c,onSetCliViewMode:o,onStopCli:x}){const d=vt(),p=$t(),u=p.p2pStates||{},l=p.ides||[],g=!!t&&We(t)&&!Re(t),h=a?"#22c55e":r==="connected"?"#eab308":"#ef4444",m=a?"0 0 4px #22c55e80":r==="connected"?"0 0 4px #eab30880":"0 0 4px #ef444480",A=l.filter($=>$.type==="adhdev-daemon"),_=Object.values(u),j=_.filter($=>$==="connected").length,w=_.filter($=>$==="connecting"||$==="new"||$==="checking").length,B=r!=="connected"||A.length===0?null:w>0&&j===0?"P2P connecting...":j>0&&s===0?"Waiting for IDE...":null;return e.jsxs("div",{className:"dashboard-header",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{className:"leading-tight",children:[e.jsxs("h1",{className:"header-title m-0 flex items-center gap-1.5",children:[e.jsx(Et,{size:18}),e.jsx("span",{className:"header-title-desktop",children:"Dashboard"}),e.jsx("span",{className:"header-title-mobile",children:(t==null?void 0:t.displayPrimary)||"Dashboard"}),e.jsx("span",{className:"header-count-mobile text-[10px] font-semibold opacity-60 ml-2 tracking-wide",children:e.jsx("span",{className:"inline-block w-[6px] h-[6px] rounded-full align-middle",style:{background:h,boxShadow:m}})})]}),e.jsxs("div",{className:"header-subtitle text-xs items-center gap-1",children:[s," agent",s!==1?"s":""," active",e.jsx("span",{title:a?"Connected":r==="connected"?"Partial":"Disconnected",className:"inline-block w-1.5 h-1.5 rounded-full shrink-0",style:{background:h,boxShadow:m}}),B&&e.jsxs("span",{className:"text-[10px] text-text-muted animate-pulse ml-1",children:["· ",B]})]})]})}),e.jsxs("div",{className:"flex gap-2 items-center",children:[g&&c&&o&&e.jsxs("div",{className:"flex items-center rounded-lg border border-border-subtle bg-bg-secondary p-0.5",children:[e.jsx("button",{onClick:()=>o("chat"),className:`px-2.5 py-1 text-[11px] font-medium rounded-md transition-colors ${c==="chat"?"bg-bg-primary text-text-primary shadow-sm":"text-text-muted hover:text-text-primary"}`,title:"Chat mode",children:"Chat"}),e.jsx("button",{onClick:()=>o("terminal"),className:`px-2.5 py-1 text-[11px] font-medium rounded-md transition-colors ${c==="terminal"?"bg-bg-primary text-text-primary shadow-sm":"text-text-muted hover:text-text-primary"}`,title:"Terminal mode",children:"Terminal"})]}),g&&x&&e.jsx("button",{onClick:x,className:"btn btn-secondary btn-sm text-red-400 border-red-500/25 hover:bg-red-500/10",title:"Stop CLI process",children:"Stop"}),t&&!g&&!Re(t)&&e.jsxs("button",{onClick:()=>d(`/ide/${t.ideId}`),className:"btn btn-primary btn-sm",title:"IDE View",children:[e.jsx(qt,{size:14})," IDE"]}),t&&!g&&!Re(t)&&e.jsx("button",{onClick:i,className:"btn btn-secondary btn-sm",title:"Chat History",children:e.jsx(gn,{size:16})}),t&&!g&&!Re(t)&&e.jsx("button",{onClick:()=>d(`/ide/${t.ideId}?view=remote`),className:"btn btn-secondary btn-sm",title:"Remote Control",children:e.jsx(ot,{size:16})})]})]})}function He(t){return t?t.charAt(0).toUpperCase()+t.slice(1).toLowerCase():"IDE"}function On(t){if(t<60)return`${Math.round(t)}s`;const s=Math.floor(t/60);if(s<60)return`${s}m`;const r=Math.floor(s/60),a=s%60;if(r<24)return a>0?`${r}h ${a}m`:`${r}h`;const i=Math.floor(r/24),c=r%24;return`${i}d ${c}h`}function ss(t){return t<1024*1024*1024?`${(t/(1024*1024)).toFixed(0)} MB`:`${(t/(1024*1024*1024)).toFixed(1)} GB`}function ns(t){return(t.id||"").includes(":cli:")}function rs(t){return(t.id||"").includes(":acp:")}function Ft(t,s){return He(t)}function Kn(t){if(!Array.isArray(t)||t.length<=1)return t;const s=new Map,r=["generating","streaming","active","connected","idle","panel_hidden"];for(const a of t){const i=(a.name||a.id||"").toLowerCase().replace(/\s+/g,"-"),c=s.get(i);if(!c){s.set(i,a);continue}const o=r.indexOf(c.status||"idle"),x=r.indexOf(a.status||"idle");x>=0&&(o<0||x<o)&&s.set(i,a)}return Array.from(s.values())}function Fn({activeConv:t,ides:s,isCreatingChat:r,isRefreshingHistory:a,onClose:i,onNewChat:c,onSwitchSession:o,onRefreshHistory:x}){var l;const d=s.find(g=>g.id===t.ideId),p=(d==null?void 0:d.chats)||[],u=(l=d==null?void 0:d.activeChat)==null?void 0:l.id;return e.jsxs("div",{className:"fixed inset-0 z-[1000] flex items-center justify-center",children:[e.jsx("div",{onClick:i,className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),e.jsxs("div",{className:"card fade-in relative w-[90%] max-w-[500px] max-h-[80vh] flex flex-col p-0 overflow-hidden shadow-[0_20px_40px_rgba(0,0,0,0.4)] rounded-[20px]",children:[e.jsxs("div",{className:"px-6 py-5 border-b border-border-subtle flex justify-between items-center bg-[var(--surface-primary)]",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"m-0 text-lg font-extrabold",children:"Chat History"}),e.jsxs("div",{className:"text-xs text-text-muted mt-0.5",children:[t.displayPrimary," — ",He(t.ideType)]})]}),e.jsx("button",{onClick:i,className:"bg-transparent border-none text-xl text-text-muted cursor-pointer",children:"✕"})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-3 bg-bg-primary",children:[e.jsx("button",{onClick:c,disabled:r,className:"w-full p-3.5 rounded-xl mb-3 bg-indigo-500/10 border border-dashed border-accent text-accent font-bold text-sm cursor-pointer",children:r?"⌛ Creating...":"+ Start New Chat Session"}),p.map(g=>e.jsxs("div",{onClick:()=>{o(t.ideId,g.id),i()},className:`p-4 rounded-xl mb-2 cursor-pointer border transition-all ${u===g.id?"bg-[var(--bg-glass-hover)] border-accent":"bg-[var(--surface-secondary)] border-border-subtle"}`,children:[e.jsx("div",{className:`font-bold text-sm mb-1 ${u===g.id?"text-[var(--accent-primary-light)]":"text-text-primary"}`,children:g.title||"Untitled Session"}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"text-[11px] text-text-muted font-mono",children:[g.id.substring(0,12),"..."]}),u===g.id&&e.jsx("span",{className:"text-[10px] bg-accent text-white px-2 py-0.5 rounded-[10px] font-extrabold",children:"ACTIVE"})]})]},g.id)),p.length===0&&e.jsxs("div",{className:"py-10 px-5 text-center text-text-muted",children:[e.jsx("div",{className:"text-3xl mb-3 opacity-60",children:e.jsx(Nn,{size:32})}),e.jsx("div",{className:"text-[13px]",children:"No recent chat sessions found."})]})]}),e.jsx("div",{className:"px-5 py-4 bg-[var(--surface-tertiary)] border-t border-border-subtle text-right",children:e.jsx("button",{onClick:x,disabled:a,className:"btn btn-secondary btn-sm rounded-[10px]",children:a?"⌛ Refreshing...":e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(ks,{size:13})," Refresh History"]})})})]})]})}const as={success:"rgba(16, 185, 129, 0.95)",warning:"rgba(245, 158, 11, 0.95)",info:"rgba(99, 102, 241, 0.95)"};function Hn({toasts:t,onDismiss:s,onClickToast:r}){return e.jsx("div",{className:"fixed right-4 z-[9999] flex flex-col gap-2 pointer-events-none",style:{top:"calc(env(safe-area-inset-top, 0px) + 16px)"},children:t.map(a=>e.jsxs("div",{className:"fade-in text-white px-5 py-3 rounded-xl text-[13px] font-semibold shadow-[0_8px_32px_rgba(0,0,0,0.3)] backdrop-blur-lg pointer-events-auto cursor-pointer animate-[toast-in_0.3s_ease-out] max-w-[360px] relative group",style:{background:as[a.type]||as.info},onClick:()=>{var i;(i=a.actions)!=null&&i.length||(r&&r(a),s(a.id))},children:[e.jsx("button",{className:"absolute top-1.5 right-1.5 w-5 h-5 rounded-full flex items-center justify-center text-white/50 hover:text-white hover:bg-white/20 transition-all text-[11px] leading-none opacity-0 group-hover:opacity-100 cursor-pointer",onClick:i=>{i.stopPropagation(),s(a.id)},"aria-label":"Dismiss",children:"×"}),e.jsx("div",{className:"pr-4",children:a.message}),a.actions&&a.actions.length>0&&e.jsx("div",{className:"flex gap-2 mt-2",children:a.actions.map((i,c)=>e.jsx("button",{className:`text-xs px-3 py-1 rounded-md font-bold transition-all cursor-pointer ${i.variant==="primary"?"bg-white text-amber-700 hover:bg-gray-100":i.variant==="danger"?"bg-red-500/30 text-white hover:bg-red-500/50":"bg-white/20 text-white hover:bg-white/30"}`,onClick:o=>{o.stopPropagation(),i.onClick(),s(a.id)},children:i.label},c))})]},a.id))})}const zn=t=>(t.id||"").includes(":cli:")||(t.id||"").includes(":acp:")||(t.id||"").includes(":ide:")?!0:t.daemonId!==t.id;function Un(t){const s=t.workspace||"";if(!s)return"";const r=s.split(/[/\\]/).filter(Boolean);return r.length>0?r[r.length-1]:s}function Yn(t,s,r,a){var c;const i={};if(r)for(const o of r){const x=o;if(x.type==="adhdev-daemon"||x.daemonMode){const d=x.machine||{},p=x.machineNickname,u=d.hostname||((c=x.system)==null?void 0:c.hostname)||"",l=p||(u&&u!=="Unknown"?u.replace(/\.local$/,""):null)||`Machine ${(x.id||"").substring(0,6)}`;i[x.id]=l}}return t.flatMap(o=>{var w,O,B,$,C;const x=[],d=o.daemonId&&i[o.daemonId]||void 0,p=o.daemonId||((w=o.id)==null?void 0:w.split(":")[0])||o.id,u=a?a[p]||"new":void 0,l=Un(o),g=He(o.type),h=o.agentStreams,m=Array.isArray(h)?h.map(W=>({...W,activeModal:W.activeModal??void 0})):[],A=zn(o),_=o.activeChat||{title:""},j=_.title&&String(_.title).trim()?String(_.title).trim():"";if(A){const W=Ft(o.type),S=(O=o.agents)==null?void 0:O[0],y=(B=o.activeChat)==null?void 0:B.activeModal,se=y&&Array.isArray(y.buttons)&&y.buttons.length>0,R=($=o.activeChat)==null?void 0:$.status,z=R==="generating"||R==="loading"||R&&R.toLowerCase()==="thinking",v=se||R==="waiting_approval"?"waiting_approval":z?"working":(S==null?void 0:S.status)||"idle",ne=o.activeChat||{title:"",messages:[]};let pe=ne.title&&String(ne.title).trim()?String(ne.title).trim():"";const q=(C=o.activeChat)==null?void 0:C.id,G=o.chats;if(q&&Array.isArray(G)&&G.length>0){const ce=G.find(D=>D.id===q||D.id&&String(D.id)===String(q));ce!=null&&ce.title&&String(ce.title).trim()&&(pe=String(ce.title).trim())}const H=ne.messages||[],oe=s[o.id]||[],J=new Map;H.filter(ce=>ce.role==="user").forEach(ce=>{J.set(ce.content,(J.get(ce.content)||0)+1)});const ie=oe.filter(ce=>{const D=J.get(ce.content)||0;return D>0?(J.set(ce.content,D-1),!1):!0});x.push({ideId:o.id,daemonId:o.daemonId||void 0,mode:We(o)?o.mode||"terminal":"chat",agentName:W,agentType:We(o)||Re(o)?o.cliType||o.acpType||o.type:(S==null?void 0:S.type)||"ide-native",status:v,title:pe,messages:[...H,...ie],ideType:o.cliType||o.acpType||o.type,workspaceName:l,displayPrimary:pe||l||(We(o)||Re(o)?"Terminal":W),displaySecondary:g,cdpConnected:o.cdpConnected,modalButtons:se?y.buttons:void 0,modalMessage:se?y.message:void 0,streamSource:"native",tabKey:o.id,machineName:d,connectionState:u})}if(A&&(We(o)||Re(o)))return x;for(const W of m){const S=W.activeModal&&Array.isArray(W.activeModal.buttons)&&W.activeModal.buttons.length>0,y=S?"waiting_approval":W.status==="streaming"?"working":W.status,se=`${o.id}:${W.agentType}`,R=W.messages||[],z=s[se]||[],U=new Map;R.filter(ne=>ne.role==="user").forEach(ne=>{U.set(ne.content,(U.get(ne.content)||0)+1)});const v=z.filter(ne=>{const pe=U.get(ne.content)||0;return pe>0?(U.set(ne.content,pe-1),!1):!0});x.push({ideId:o.id,daemonId:o.daemonId||void 0,mode:"chat",agentName:W.agentName,agentType:W.agentType,status:y,title:"",messages:[...R,...v],ideType:W.agentType,workspaceName:l,displayPrimary:j||l||W.agentName,displaySecondary:`${g}·${W.agentName}`,cdpConnected:o.cdpConnected,modalButtons:S?W.activeModal.buttons:void 0,modalMessage:S?W.activeModal.message:void 0,streamSource:"agent-stream",tabKey:se,machineName:d,connectionState:u})}return x.length===0&&x.push({ideId:o.id,daemonId:o.daemonId||void 0,mode:"chat",agentName:Ft(o.type),agentType:"ide-native",status:"idle",title:"",messages:[],ideType:o.type,workspaceName:l,displayPrimary:l||g,displaySecondary:g,cdpConnected:o.cdpConnected,streamSource:"native",tabKey:o.id,connectionState:u}),x})}function Vn(t,s){var x,d,p,u;const r=[],{daemonId:a,existingDaemon:i,timestamp:c}=s,o=c||t.timestamp||Date.now();r.push({...i||{},id:a,type:"adhdev-daemon",status:"online",daemonMode:!0,timestamp:o,...t.version&&{version:t.version},...t.machine&&{machine:t.machine,platform:t.machine.platform},...t.instanceId&&{instanceId:t.instanceId},...t.machineNickname!==void 0&&{machineNickname:t.machineNickname},...t.p2p&&{p2p:t.p2p},..."system"in t&&{system:t.system},..."hostname"in t&&{hostname:t.hostname},...t.workspaces&&{workspaces:t.workspaces},...t.defaultWorkspaceId!==void 0&&{defaultWorkspaceId:t.defaultWorkspaceId},...t.defaultWorkspacePath!==void 0&&{defaultWorkspacePath:t.defaultWorkspacePath},...t.workspaceActivity&&{workspaceActivity:t.workspaceActivity},...t.detectedIdes&&{detectedIdes:t.detectedIdes},..."availableProviders"in t&&{availableProviders:t.availableProviders},cdpConnected:t.managedIdes.some(l=>l.cdpConnected),managedIdeIds:t.managedIdes.map(l=>`${a}:ide:${l.instanceId}`),managedCliIds:t.managedClis.map(l=>l.id?`${a}:cli:${l.id}`:`${a}:cli:${l.cliType}`),managedAcpIds:t.managedAcps.map(l=>l.id?`${a}:acp:${l.id}`:`${a}:acp:${l.acpType}`)});for(const l of t.managedIdes)r.push({id:`${a}:ide:${l.instanceId}`,type:l.ideType,ideType:l.ideType,version:l.ideVersion,status:l.cdpConnected?"online":"detected",daemonId:a,instanceId:l.instanceId,workspace:l.workspace,terminals:l.terminals,agents:l.aiAgents,activeChat:l.activeChat,chats:l.chats,agentStreams:l.agentStreams,cdpConnected:l.cdpConnected,currentModel:l.currentModel,currentPlan:l.currentPlan,currentAutoApprove:l.currentAutoApprove,timestamp:o});for(const l of t.managedClis){const g=l.id?`${a}:cli:${l.id}`:`${a}:cli:${l.cliType}`;r.push({id:g,type:l.cliType,ideType:l.cliType,agentType:l.cliType,status:l.status||"running",daemonId:a,instanceId:l.id,cliName:l.cliName,mode:l.mode||"terminal",workspace:l.workspace,activeChat:l.activeChat,agentStreams:[{agentType:l.cliType,agentName:l.cliName,extensionId:"cli-agent",status:l.status==="generating"?"streaming":l.status==="waiting_approval"?"waiting_approval":"idle",messages:((x=l.activeChat)==null?void 0:x.messages)||[],inputContent:"",activeModal:(d=l.activeChat)==null?void 0:d.activeModal}],timestamp:o,_isCli:!0})}for(const l of t.managedAcps){const g=l.id?`${a}:acp:${l.id}`:`${a}:acp:${l.acpType}`;r.push({id:g,type:l.acpType,ideType:l.acpType,agentType:l.acpType,status:l.status||"running",daemonId:a,instanceId:l.id,cliName:l.acpName,mode:"chat",workspace:l.workspace,activeChat:l.activeChat,currentModel:l.currentModel,currentPlan:l.currentPlan,acpConfigOptions:l.acpConfigOptions,acpModes:l.acpModes,agentStreams:[{agentType:l.acpType,agentName:l.acpName,extensionId:"acp-agent",status:l.status==="generating"?"streaming":l.status==="waiting_approval"?"waiting_approval":"idle",messages:((p=l.activeChat)==null?void 0:p.messages)||[],inputContent:"",activeModal:(u=l.activeChat)==null?void 0:u.activeModal}],timestamp:o,_isAcp:!0})}return r}const $s=[{id:"vscode",name:"VS Code",icon:"💙"},{id:"cursor",name:"Cursor",icon:"⚡"},{id:"windsurf",name:"Windsurf",icon:"🏄"},{id:"antigravity",name:"Antigravity",icon:"🌀"},{id:"trae",name:"Trae",icon:"🔮"},{id:"kiro",name:"Kiro",icon:"🎯"},{id:"pearai",name:"PearAI",icon:"🍐"},{id:"vscodium",name:"VSCodium",icon:"💚"}],_s=[{id:"claude-cli",name:"Claude Code",icon:"🟠"},{id:"gemini-cli",name:"Gemini CLI",icon:"✨"},{id:"codex-cli",name:"Codex CLI",icon:"📦"}],Rs=[{id:"copilot",name:"GitHub Copilot",icon:"🤖"},{id:"cline",name:"Cline",icon:"🧠"},{id:"roo-code",name:"Roo Code",icon:"🦘"},{id:"continue",name:"Continue",icon:"▶️"}],Ps="adhdev_notification_prefs",os={globalEnabled:!0,disconnectAlert:!0,browserNotifications:!0,completionAlert:!0,approvalAlert:!0};function Xn(){try{const t=localStorage.getItem(Ps);if(t){const s=JSON.parse(t);return{...os,...s}}}catch{}return{...os}}function qn(t){try{localStorage.setItem(Ps,JSON.stringify(t))}catch{}}let Qe=Xn(),Ct=[];function Gn(){Ct.forEach(t=>t())}function Jn(t){Qe={...Qe,...t},qn(Qe),Gn()}function Zn(){const[,t]=n.useState(0);n.useEffect(()=>{const r=()=>t(a=>a+1);return Ct.push(r),()=>{Ct=Ct.filter(a=>a!==r)}},[]);const s=n.useCallback(r=>{Jn(r)},[]);return[{...Qe},s]}function pt(t){if(!Qe.globalEnabled)return!1;switch(t){case"disconnect":return Qe.disconnectAlert;case"completion":return Qe.completionAlert;case"approval":return Qe.approvalAlert;case"browser":return Qe.browserNotifications;default:return!0}}const Qn={enabled:!0,onApproval:!0,onComplete:!0,onError:!0,throttleMs:5e3};async function er(){return"Notification"in window?Notification.permission==="granted"?"granted":Notification.permission==="denied"?"denied":Notification.requestPermission():"denied"}function Ls(){return"Notification"in window&&Notification.permission==="granted"}let nt=null;async function tr(){if(nt!==null)return nt;try{if(!("serviceWorker"in navigator)||!("PushManager"in window))return nt=!1,!1;const t=await navigator.serviceWorker.getRegistration();return t?(nt=!!await t.pushManager.getSubscription(),nt):(nt=!1,!1)}catch{return nt=!1,!1}}function Ht(t,s,r){if(Ls())try{const a=new Notification(t,{body:s,icon:"/otter-logo.png",tag:r||`adhdev-${Date.now()}`,silent:!1});setTimeout(()=>a.close(),8e3),a.onclick=()=>{window.focus(),a.close()}}catch{}}function sr(t,s={}){const r={...Qn,...s},a=n.useRef(new Map),i=n.useRef(0),c=n.useRef(null);n.useEffect(()=>{tr().then(x=>{c.current=x})},[]);const o=n.useCallback((x,d,p)=>{const u=Date.now();u-i.current<r.throttleMs||(i.current=u,Ht(x,d,p))},[r.throttleMs]);n.useEffect(()=>{var x;if(!(!r.enabled||!Ls())&&pt("browser")&&c.current!==!0){if(document.hasFocus()){for(const d of t)a.current.set(d.id,d.status||"idle");return}for(const d of t){const p=a.current.get(d.id),u=d.status||"idle",l=d.name||d.id;if(r.onApproval&&pt("approval")&&u==="waiting_approval"&&p!=="waiting_approval"){const g=((x=d.activeModal)==null?void 0:x.message)||"Action requires your approval";o(`🔔 ${l} — Approval needed`,g.slice(0,120),`approval-${d.id}`)}r.onComplete&&pt("completion")&&p==="generating"&&u==="idle"&&o(`✅ ${l} — Task complete`,"Agent has finished working",`complete-${d.id}`),r.onError&&u==="error"&&p!=="error"&&o(`⚠️ ${l} — Error`,"Agent encountered an error",`error-${d.id}`),a.current.set(d.id,u)}}},[t,r.enabled,r.onApproval,r.onComplete,r.onError,o])}class nr{constructor(){Ee(this,"dedupMap",new Map);Ee(this,"DEDUP_WINDOW_MS",5e3);Ee(this,"DEDUP_MAX_SIZE",50);Ee(this,"DEDUP_CLEANUP_AGE_MS",1e4);Ee(this,"toastCallbacks",[]);Ee(this,"systemMessageCallbacks",[]);Ee(this,"clearSystemMessageCallbacks",[]);Ee(this,"resolveActionFn",null);Ee(this,"viewRequestRespondFn",null);Ee(this,"ides",[])}onToast(s){return this.toastCallbacks.push(s),()=>{this.toastCallbacks=this.toastCallbacks.filter(r=>r!==s)}}onSystemMessage(s){return this.systemMessageCallbacks.push(s),()=>{this.systemMessageCallbacks=this.systemMessageCallbacks.filter(r=>r!==s)}}onClearSystemMessage(s){return this.clearSystemMessageCallbacks.push(s),()=>{this.clearSystemMessageCallbacks=this.clearSystemMessageCallbacks.filter(r=>r!==s)}}setResolveAction(s){this.resolveActionFn=s}setIdes(s){this.ides=s}setViewRequestRespond(s){this.viewRequestRespondFn=s}emitToast(s){for(const r of this.toastCallbacks)r(s)}emitSystemMessage(s,r){for(const a of this.systemMessageCallbacks)a(s,r)}emitClearSystemMessage(s,r){for(const a of this.clearSystemMessageCallbacks)a(s,r)}isDuplicate(s){const r=Date.now(),a=this.dedupMap.get(s)||0;if(r-a<this.DEDUP_WINDOW_MS)return!0;if(this.dedupMap.set(s,r),this.dedupMap.size>this.DEDUP_MAX_SIZE)for(const[i,c]of this.dedupMap)r-c>this.DEDUP_CLEANUP_AGE_MS&&this.dedupMap.delete(i);return!1}resolveOwningDaemon(s){if(s.ideType==="adhdev-daemon"&&s.ideId){const i=this.ides.find(c=>c.id===s.ideId&&c.type==="adhdev-daemon");if(i)return i}let r;if(s.ideId&&(r=this.ides.find(i=>i.id===s.ideId)),!r&&s.instanceId&&(r=this.ides.find(i=>i.id.endsWith(`:ide:${s.instanceId}`)||i.id.endsWith(`:cli:${s.instanceId}`))),r){const i=r.daemonId;if(i){const c=this.ides.find(o=>o.id===i&&o.type==="adhdev-daemon");if(c)return c}}const a=this.ides.filter(i=>i.type==="adhdev-daemon");return a.length===1?a[0]:null}resolveRouteId(s,r){for(const a of this.ides)if(a.id.startsWith(s)&&(!r||r===a.type))return a.id;return s}handleRawEvent(s,r){var d,p,u;const a=`${s.ideType||s.providerType||""}:${s.event}:${s.chatTitle||""}`;if(this.isDuplicate(a))return;if(!s.ideId&&s.instanceId){for(const l of this.ides)if(l.id.endsWith(`:ide:${s.instanceId}`)||l.id.endsWith(`:cli:${s.instanceId}`)){s.ideId=l.id;break}}let i=He(s.ideType||"");const c=this.resolveOwningDaemon(s);if(c){const l=c.machineNickname||((d=c.machine)==null?void 0:d.hostname);l&&(i=s.ideType==="adhdev-daemon"?l:`${l}/${i}`)}let o="",x="info";if(s.event==="agent:generating_completed"){const l=s.duration?` (${s.duration}s)`:"";o=`✅ ${i} agent task completed${l}`,x="success";try{new Audio("data:audio/wav;base64,UklGRigAAABXQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgAZGF0YQQAAAB/f39/").play().catch(()=>{})}catch{}s.ideId&&this.emitSystemMessage(s.ideId,{role:"system",timestamp:Date.now(),content:`✅ Task completed${l}`,_localId:`sys_complete_${Date.now()}`})}else if(s.event==="agent:generating_started")s.ideId&&this.emitClearSystemMessage(s.ideId,"sys_complete_");else if(s.event==="agent:waiting_approval"){if(o=`⚡ ${i} approval needed`,x="warning",s.ideId){const l=s.modalMessage||"Approval requested",g=(p=s.modalButtons)!=null&&p.length?s.modalButtons.map(h=>`[${h}]`).join(" "):"[Approve] [Reject]";this.emitSystemMessage(s.ideId,{role:"system",timestamp:Date.now(),content:`⚡ Approval requested: ${l}
|
|
39
|
-
${g}`,_localId:`sys_approval_${Date.now()}`})}if(s.ideId&&((u=s.modalButtons)!=null&&u.length)&&this.resolveActionFn){const l=s.ideId,g=s.agentType||s.ideType||"",h=s.ideType||"",m=s.modalButtons,A=B=>B.replace(/[⌥⏎⇧⌫⌘⌃↵]/g,"").replace(/\s*(Alt|Ctrl|Shift|Cmd|Enter|Return|Esc|Tab|Backspace)(\+\s*\w+)*/gi,"").trim(),_=this.resolveActionFn,j=m.map((B,$)=>{const C=A(B).toLowerCase(),W=/^(run|approve|accept|yes|allow|always)/.test(C),S=/^(reject|deny|delete|remove|abort|cancel|no)/.test(C);return{label:A(B),variant:W?"primary":S?"danger":"default",onClick:()=>{const y=this.resolveRouteId(l,g),se=/^(run|approve|accept|yes|allow|always|proceed|save)/.test(C);_(y,"resolve_action",{action:se?"approve":"reject",button:B,buttonIndex:$,agentType:g,ideType:h})}}}),w=s.modalMessage?`⚡ ${i}: ${s.modalMessage.replace(/[\n\r]+/g," ").slice(0,80)}`:o,O=Date.now();this.emitToast({id:O,message:w,type:x,timestamp:O,ideId:l,actions:j,duration:15e3}),o=""}}else if(s.event==="monitor:long_generating"){const l=s.elapsedSec?` (${Math.round(s.elapsedSec/60)}m)`:"";o=`⚠️ ${i} agent is taking a long time${l}`,x="warning",pt("browser")&&!document.hasFocus()&&Ht(`⚠️ ${i} — Long Running`,`Agent has been generating for over ${l.replace(/[()]/g,"")}`,`long-${s.ideId||s.agentType}`)}else if(s.event==="team:view_request"){const l=s.requesterName||"A team member",g=s.requestId,h=s.orgId;if(o=`👁️ ${l} wants to view your session`,x="warning",g&&h&&this.viewRequestRespondFn){const m=this.viewRequestRespondFn,A=Date.now(),_=[{label:"Approve",variant:"primary",onClick:()=>{m(h,g,"approve").catch(j=>console.error("[EventManager] approve view request failed:",j))}},{label:"Decline",variant:"danger",onClick:()=>{m(h,g,"reject").catch(j=>console.error("[EventManager] reject view request failed:",j))}}];this.emitToast({id:A,message:o,type:x,timestamp:A,actions:_,duration:3e4}),o=""}pt("browser")&&!document.hasFocus()&&Ht("👁️ View Request",`${l} wants to view your session`,`view-request-${g}`)}else s.event==="team:view_request_approved"?(o="✅ View request approved",x="success"):s.event==="team:view_request_rejected"&&(o=`❌ ${s.targetName||"Team member"} declined your view request`,x="warning");if(o){const l=Date.now();this.emitToast({id:l,message:o,type:x,timestamp:l,ideId:s.ideId,duration:5e3})}}}const it=new nr;function yt(...t){return Vs(Xs(t))}function Ds({icon:t,title:s,subtitle:r,badge:a,actions:i,className:c}){return e.jsxs("div",{className:yt("dashboard-header",c),children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"header-title flex items-center gap-2",children:[e.jsx("span",{className:"flex items-center text-lg",children:t})," ",s,a&&e.jsxs("span",{className:"text-[10px] font-semibold px-1.5 py-px rounded-full bg-accent/10 text-accent-light",children:[a.count!==void 0?a.count:""," ",a.text]})]}),r&&e.jsx("div",{className:"header-subtitle mt-1 text-xs text-text-muted",children:r})]}),i&&e.jsx("div",{className:"flex gap-2",children:i})]})}function ct({title:t,icon:s,description:r,accentColor:a,className:i,children:c}){return e.jsxs("div",{className:yt("bg-bg-card border border-border-subtle rounded-2xl p-5 backdrop-blur-xl transition-all","hover:border-border-default hover:shadow-glow",a&&"border-l-[3px]",i),style:a?{borderLeftColor:a}:void 0,children:[(t||r)&&e.jsxs("div",{className:"mb-4",children:[t&&e.jsxs("h3",{className:"text-base font-semibold text-text-primary",children:[s&&e.jsx("span",{className:"mr-1.5",children:s}),t]}),r&&e.jsx("p",{className:"text-[13px] text-text-muted mt-1",children:r})]}),c]})}function rr({icon:t,title:s,description:r,action:a,className:i}){return e.jsxs("div",{className:yt("py-16 px-5 text-center bg-bg-glass border-2 border-dashed border-border-subtle rounded-2xl",i),children:[e.jsx("div",{className:"text-5xl mb-4 opacity-50",children:t}),e.jsx("h3",{className:"text-lg font-bold text-text-secondary mb-2",children:s}),e.jsx("p",{className:"text-sm text-text-muted max-w-sm mx-auto mb-5 leading-relaxed",children:r}),a]})}const ar={online:"bg-green-500/10 text-green-400 border-green-500/30",idle:"bg-yellow-500/10 text-yellow-400 border-yellow-500/30",busy:"bg-orange-500/10 text-orange-400 border-orange-500/30",error:"bg-red-500/10 text-red-400 border-red-500/30",offline:"bg-gray-500/10 text-text-secondary border-gray-500/30"},or={online:"bg-green-500",idle:"bg-yellow-500",busy:"bg-orange-500",error:"bg-red-500",offline:"bg-gray-500"};function ir({status:t,label:s,className:r}){const a=s||t;return e.jsxs("span",{className:yt("inline-flex items-center gap-1.5 text-xs font-medium px-2.5 py-1 rounded-full border",ar[t],r),children:[e.jsx("span",{className:yt("w-2 h-2 rounded-full animate-[pulse-dot_2s_ease-in-out_infinite]",or[t])}),a]})}function cr(){return typeof window>"u"?"dark":window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark"}function is(){try{const t=localStorage.getItem("theme");if(t==="dark"||t==="light"||t==="system")return t}catch{}return"system"}function Lt(t){return t==="system"?cr():t}function lr(){const[t,s]=n.useState(is),[r,a]=n.useState(()=>Lt(is()));n.useEffect(()=>{document.documentElement.setAttribute("data-theme",r)},[r]),n.useEffect(()=>{const o=window.matchMedia("(prefers-color-scheme: light)"),x=d=>{t==="system"&&a(d.matches?"light":"dark")};return o.addEventListener("change",x),()=>o.removeEventListener("change",x)},[t]);const i=n.useCallback(o=>{s(o),a(Lt(o));try{localStorage.setItem("theme",o)}catch{}},[]),c=n.useCallback(()=>{s(o=>{const x=o==="dark"?"light":o==="light"?"system":"dark";a(Lt(x));try{localStorage.setItem("theme",x)}catch{}return x})},[]);return{theme:r,preference:t,setPreference:i,cycleTheme:c,isDark:r==="dark"}}function lt({label:t,description:s,checked:r,disabled:a,onChange:i,extra:c}){return e.jsxs("label",{className:"flex justify-between items-center cursor-pointer",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:t}),e.jsx("div",{className:"text-[11px] text-text-muted",children:s})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[c,e.jsx("input",{type:"checkbox",checked:r,disabled:a,onChange:o=>i(o.target.checked),className:"w-5 h-5 accent-accent"})]})]})}function dr({onPrefChange:t}){const[s,r]=Zn(),a=(i,c)=>{r({[i]:c}),t==null||t(i,c)};return e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(lt,{label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(kn,{size:15})," Notifications"]}),description:"Master toggle for all alerts",checked:s.globalEnabled,onChange:i=>a("globalEnabled",i)}),s.globalEnabled&&e.jsx("div",{className:"border-t border-border-subtle my-0.5"}),s.globalEnabled&&e.jsx(lt,{label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(ot,{size:15})," Browser Notifications"]}),description:"Desktop alerts when tab is inactive",checked:s.browserNotifications,onChange:i=>a("browserNotifications",i)}),s.globalEnabled&&s.browserNotifications&&e.jsxs("div",{className:"ml-5 pl-3 border-l-2 border-border-subtle flex flex-col gap-2",children:[e.jsx(lt,{label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Sn,{size:15})," Completion Alerts"]}),description:"Notify when agent finishes a task",checked:s.completionAlert,onChange:i=>a("completionAlert",i)}),e.jsx(lt,{label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Cn,{size:15})," Approval Alerts"]}),description:"Notify when agent needs approval",checked:s.approvalAlert,onChange:i=>a("approvalAlert",i)}),e.jsx(lt,{label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(bt,{size:15})," Connection Alerts"]}),description:"Alert when a daemon disconnects",checked:s.disconnectAlert,onChange:i=>a("disconnectAlert",i)})]}),!s.globalEnabled&&e.jsx("p",{className:"text-[11px] text-text-muted italic",children:"All notifications are disabled. Enable the master toggle to configure individual alerts."})]})}function ur({ides:t,emptyMessage:s,sendDaemonCommand:r,onDisconnect:a,onRevokeToken:i}){const c=t.filter(o=>o.type==="adhdev-daemon");return c.length===0?e.jsx(rr,{icon:e.jsx("img",{src:"/otter-logo.png",alt:"ADHDev",className:"w-12 h-12 object-contain mx-auto opacity-90"}),title:"No machines connected",description:s||"Run 'adhdev-standalone' to connect a local daemon instance."}):e.jsx("div",{className:"flex flex-col gap-2",children:c.map(o=>e.jsx(mr,{ide:o,allIdes:t,sendDaemonCommand:r,onDisconnect:a,onRevokeToken:i},o.id))})}function cs({title:t,message:s,confirmLabel:r,confirmColor:a,onConfirm:i,onCancel:c}){const o=a==="red"?"bg-red-500/20 text-red-400 border-red-500/30 hover:bg-red-500/30":"bg-amber-500/20 text-amber-400 border-amber-500/30 hover:bg-amber-500/30";return qs.createPortal(e.jsx("div",{className:"fixed inset-0 flex items-center justify-center bg-black/60 backdrop-blur-sm",style:{zIndex:9999},onClick:c,children:e.jsxs("div",{className:"bg-bg-primary border border-border-subtle rounded-xl p-5 max-w-sm w-full mx-4 shadow-2xl",onClick:x=>x.stopPropagation(),children:[e.jsx("div",{className:"font-semibold text-sm mb-3",children:t}),e.jsx("div",{className:"text-xs text-text-muted leading-relaxed mb-5 whitespace-pre-line",children:s}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{onClick:c,className:"text-xs px-3 py-1.5 rounded-lg font-medium bg-bg-secondary text-text-secondary border border-border-subtle hover:bg-bg-glass transition-colors",children:"Cancel"}),e.jsx("button",{onClick:i,className:`text-xs px-3 py-1.5 rounded-lg font-medium border transition-colors ${o}`,children:r})]})]})}),document.body)}function xr(t){const s=t.replace(/^ide-/,"").replace(/-provider$/,"").toLowerCase(),a=[...$s,..._s,...Rs].find(i=>i.id===s||s.includes(i.id)||i.id.includes(s));return a?{icon:a.icon,name:a.name}:{icon:"📝",name:t}}function mr({ide:t,allIdes:s,sendDaemonCommand:r,onDisconnect:a,onRevokeToken:i}){var ne,pe,q,G;const[c,o]=n.useState("idle"),[x,d]=n.useState(""),[p,u]=n.useState(null),[l,g]=n.useState("idle"),[h,m]=n.useState(""),A=t,_=A.version||A.daemonVersion||null,j=((ne=A.machine)==null?void 0:ne.hostname)||((pe=A.system)==null?void 0:pe.hostname)||"",w=((q=A.machine)==null?void 0:q.platform)||((G=A.system)==null?void 0:G.platform)||"",O=A.machineNickname||(j==null?void 0:j.replace(/\.local$/,""))||"Machine",B=w==="win32"?"🪟":w==="darwin"?"🍎":"🐧",$=s.filter(H=>H.daemonId===t.id&&H.id.includes(":ide:")),C=s.filter(H=>H.daemonId===t.id&&H.id.includes(":cli:")),W=s.filter(H=>H.daemonId===t.id&&H.id.includes(":acp:")),S=A.p2p,y=async()=>{var H,oe,J;if(r){o("upgrading"),d("Installing latest version...");try{const ie=await r(t.id,"daemon_upgrade",{});(H=ie==null?void 0:ie.result)!=null&&H.upgraded||(oe=ie==null?void 0:ie.result)!=null&&oe.success?(o("done"),d(`Upgraded to v${ie.result.version||"latest"}. Daemon is restarting...`)):(o("error"),d(((J=ie==null?void 0:ie.result)==null?void 0:J.error)||"Upgrade failed"))}catch(ie){o("error"),d((ie==null?void 0:ie.message)||"Connection lost during upgrade")}}},se=async()=>{if(u(null),!!a){g("loading");try{await a(t.id),g("done"),m("Machine disconnected.")}catch(H){g("error"),m((H==null?void 0:H.message)||"Failed to disconnect")}}},R=async()=>{if(u(null),!!i){g("loading");try{await i(t.id),g("done"),m('Token revoked. Machine must restart "adhdev-standalone" to reconnect.')}catch(H){g("error"),m((H==null?void 0:H.message)||"Failed to revoke token")}}},z="0.6.69",U=!_||_!==z,v=$.length+C.length+W.length;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-bg-glass rounded-lg px-4 py-3 border border-border-subtle",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xl",children:B}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:O}),e.jsxs("div",{className:"text-xs text-text-muted font-mono flex items-center gap-2",children:[e.jsxs("span",{children:[t.id.substring(0,12),"…"]}),_&&e.jsxs("span",{className:`px-1.5 py-0.5 rounded text-[10px] ${U?"bg-amber-500/15 text-amber-400":"bg-bg-secondary"}`,children:["v",_,!U&&" ✓"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[r&&U&&e.jsx("button",{onClick:y,disabled:c==="upgrading"||c==="done",className:"btn btn-sm btn-primary disabled:opacity-50 disabled:cursor-not-allowed",title:`Update to v${z}`,children:c==="upgrading"?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"animate-spin",children:"⟳"})," Upgrading..."]}):c==="done"?"✓ Updated":`↑ Update${` to v${z}`}`}),a&&e.jsx("button",{onClick:()=>u("disconnect"),disabled:l==="loading",className:"btn btn-sm btn-warning disabled:opacity-50 disabled:cursor-not-allowed",title:"Disconnect this machine",children:"Disconnect"}),i&&e.jsx("button",{onClick:()=>u("revoke"),disabled:l==="loading",className:"btn btn-sm btn-danger disabled:opacity-50 disabled:cursor-not-allowed",title:"Remove machine (requires re-setup)",children:"Remove"}),e.jsx(ir,{status:t.status==="online"?"online":"error"})]})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-2.5 pt-2.5 border-t border-border-subtle/50",children:[S&&e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${S.state==="connected"?"bg-green-400":S.state==="connecting"||S.state==="new"?"bg-amber-400 animate-pulse":"bg-text-muted/30"}`}),e.jsxs("span",{className:"text-text-muted",children:["P2P ",S.state==="connected"?"connected":S.state==="connecting"||S.state==="new"?"connecting...":S.state||"off"]}),S.peers!==void 0&&S.peers>0&&e.jsxs("span",{className:"text-text-muted/60",children:["(",S.peers," peer",S.peers!==1?"s":"",")"]})]}),S&&v>0&&e.jsx("span",{className:"text-border-subtle",children:"·"}),v>0?e.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-text-muted",children:[$.map(H=>{const oe=xr(H.type),J=H.cdpConnected;return e.jsxs("span",{className:"flex items-center gap-1 bg-bg-secondary px-1.5 py-0.5 rounded",children:[e.jsx("span",{children:oe.icon}),e.jsx("span",{children:oe.name}),J!==void 0&&e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${J?"bg-green-400":"bg-amber-400 animate-pulse"}`,title:J?"CDP connected":"CDP connecting..."})]},H.id)}),C.map(H=>e.jsxs("span",{className:"flex items-center gap-1 bg-bg-secondary px-1.5 py-0.5 rounded",children:[e.jsx("span",{children:"⌨️"}),e.jsx("span",{children:H.cliName||"CLI"})]},H.id)),W.map(H=>e.jsxs("span",{className:"flex items-center gap-1 bg-bg-secondary px-1.5 py-0.5 rounded",children:[e.jsx("span",{children:"🔗"}),e.jsx("span",{children:H.cliName||"ACP"})]},H.id))]}):e.jsx("span",{className:"text-[11px] text-text-muted/60 italic",children:"No IDEs connected"})]}),(x||h)&&e.jsx("div",{className:`text-xs mt-2 px-1 ${c==="error"||l==="error"?"text-red-400":c==="done"||l==="done"?"text-green-400":"text-text-muted"}`,children:h||x})]}),p==="disconnect"&&e.jsx(cs,{title:"🔌 Disconnect Machine",message:`Disconnect "${O}" from ADHDev?
|
|
40
|
-
|
|
41
|
-
This will close the server connection. The daemon process will continue running on the machine and will automatically reconnect.
|
|
42
|
-
|
|
43
|
-
Use this if you want to temporarily stop remote control.`,confirmLabel:"Disconnect",confirmColor:"amber",onConfirm:se,onCancel:()=>u(null)}),p==="revoke"&&e.jsx(cs,{title:"⚠️ Remove Machine",message:`Remove "${O}" from your dashboard?
|
|
44
|
-
|
|
45
|
-
This will:
|
|
46
|
-
• Immediately disconnect the machine
|
|
47
|
-
• Delete the machine registration
|
|
48
|
-
• Require restarting "adhdev-standalone" on that machine
|
|
49
|
-
|
|
50
|
-
Use this if you want to permanently remove a machine.`,confirmLabel:"Remove Machine",confirmColor:"red",onConfirm:R,onCancel:()=>u(null)})]})}const pr=[{id:"dark",label:"Dark",icon:"🌙"},{id:"light",label:"Light",icon:"☀️"},{id:"system",label:"System",icon:"💻"}];function hr(){const{preference:t,setPreference:s}=lr();return e.jsx("div",{className:"flex gap-2",children:pr.map(r=>e.jsxs("button",{onClick:()=>s(r.id),className:`px-3 py-1.5 rounded-lg border text-sm font-medium transition-colors flex items-center gap-1.5 ${t===r.id?"bg-accent border-accent text-white":"bg-bg-glass border-border-subtle hover:bg-bg-secondary text-text-muted hover:text-text-primary"}`,children:[e.jsx("span",{children:r.icon}),r.label]},r.id))})}const zt={bgPrimary:"#0f0f13",bgSecondary:"#18181d",surfacePrimary:"#111116",textPrimary:"#fafafa",textSecondary:"#a8a8b3",textMuted:"#7e7e8a",borderSubtle:"#1a1a22",borderDefault:"#2a2a35",accentColor:"#8b5cf6",userBubble:"#6366f1",userText:"#ffffff",assistantBubble:"#1e1e24",assistantText:"#e0e0e0",containerBg:"#111114",sendButton:"#6366f1",inputBorder:"#2a2a35",bubbleRadius:16},Ut={bgPrimary:"#f0f1f5",bgSecondary:"#e8eaf0",surfacePrimary:"#ffffff",textPrimary:"#1a1a2e",textSecondary:"#3f3f50",textMuted:"#5c5c6e",borderSubtle:"#d8d8e0",borderDefault:"#c0c0cc",accentColor:"#7c3aed",userBubble:"#6366f1",userText:"#ffffff",assistantBubble:"#f3f4f6",assistantText:"#1f2937",containerBg:"#f0f1f5",sendButton:"#6366f1",inputBorder:"#d1d5db",bubbleRadius:16},fr=[{id:"midnight",name:"Midnight",description:"Default violet theme",preview:{dark:{userBubble:"linear-gradient(135deg, #8b5cf6, #4f46e5)",assistantBubble:"#18181d",assistantBorder:"1px solid rgba(255,255,255,0.08)",containerBg:"#0f0f13",textColor:"rgba(255,255,255,0.7)"},light:{userBubble:"linear-gradient(135deg, #7c3aed, #0ea5e9)",assistantBubble:"#ffffff",assistantBorder:"1px solid rgba(0,0,0,0.08)",containerBg:"#f0f1f5",textColor:"#52525b"}}},{id:"aurora",name:"Aurora",description:"Pink-orange gradient",preview:{dark:{userBubble:"linear-gradient(135deg, #ec4899, #f97316)",assistantBubble:"#1e1b2e",assistantBorder:"1px solid rgba(236,72,153,0.12)",containerBg:"#0f0d17",textColor:"rgba(255,255,255,0.7)"},light:{userBubble:"linear-gradient(135deg, #ec4899, #f97316)",assistantBubble:"#fef2f8",assistantBorder:"1px solid rgba(236,72,153,0.15)",containerBg:"#f0f1f5",textColor:"#1a1a2e"}}},{id:"honey",name:"Honey",description:"Warm yellow accents",preview:{dark:{userBubble:"#fbbf24",assistantBubble:"#1c1c1e",assistantBorder:"1px solid rgba(255,255,255,0.06)",containerBg:"#111113",textColor:"rgba(255,255,255,0.7)"},light:{userBubble:"#fbbf24",assistantBubble:"#fffbeb",assistantBorder:"1px solid rgba(251,191,36,0.15)",containerBg:"#f0f1f5",textColor:"#1a1a2e"}}}],Bs="adhdev-chat-theme",Ws="adhdev-chat-theme-custom";function It(){return typeof window>"u"?"midnight":localStorage.getItem(Bs)||"midnight"}function ze(t){try{const s=localStorage.getItem(Ws);if(s){const r=JSON.parse(s);return{...t==="dark"?zt:Ut,...r[t]}}}catch{}return t==="dark"?zt:Ut}function Nt(t,s){localStorage.setItem(Ws,JSON.stringify({dark:t,light:s}))}function Ge(t,s){const r=parseInt(t.slice(1,3),16),a=parseInt(t.slice(3,5),16),i=parseInt(t.slice(5,7),16);return`rgba(${r}, ${a}, ${i}, ${s})`}function ls(t,s){const r=Math.min(255,parseInt(t.slice(1,3),16)+s),a=Math.min(255,parseInt(t.slice(3,5),16)+s),i=Math.min(255,parseInt(t.slice(5,7),16)+s);return`#${r.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`}function at(t){const s=document.documentElement;s.style.setProperty("--bg-primary",t.bgPrimary),s.style.setProperty("--bg-secondary",t.bgSecondary),s.style.setProperty("--bg-card",Ge(t.surfacePrimary,.92)),s.style.setProperty("--surface-primary",t.surfacePrimary),s.style.setProperty("--surface-secondary",t.bgSecondary),s.style.setProperty("--bg-glass",Ge(t.borderSubtle,.15)),s.style.setProperty("--bg-glass-hover",Ge(t.borderSubtle,.25)),s.style.setProperty("--text-primary",t.textPrimary),s.style.setProperty("--text-secondary",t.textSecondary),s.style.setProperty("--text-muted",t.textMuted),s.style.setProperty("--border-subtle",Ge(t.borderSubtle,.5)),s.style.setProperty("--border-default",Ge(t.borderDefault,.5)),s.style.setProperty("--accent-primary",t.accentColor),s.style.setProperty("--accent-primary-light",ls(t.accentColor,30)),s.style.setProperty("--accent-gradient",`linear-gradient(135deg, ${t.accentColor}, ${ls(t.accentColor,40)})`),s.style.setProperty("--border-accent",Ge(t.accentColor,.35)),s.style.setProperty("--nav-active-bg",Ge(t.accentColor,.1)),s.style.setProperty("--nav-active-shadow",`inset 3px 0 0 ${t.accentColor}, 0 0 12px ${Ge(t.accentColor,.06)}`),s.style.setProperty("--chat-user-bg",t.userBubble),s.style.setProperty("--chat-user-color",t.userText),s.style.setProperty("--chat-user-radius",`${t.bubbleRadius}px ${t.bubbleRadius}px 4px ${t.bubbleRadius}px`),s.style.setProperty("--chat-assistant-bg",t.assistantBubble),s.style.setProperty("--chat-assistant-color",t.assistantText),s.style.setProperty("--chat-assistant-radius",`${t.bubbleRadius}px ${t.bubbleRadius}px ${t.bubbleRadius}px 4px`),s.style.setProperty("--chat-assistant-border",`1px solid ${Ge(t.accentColor,.12)}`),s.style.setProperty("--chat-container-bg",t.containerBg),s.style.setProperty("--chat-thought-accent",t.accentColor),s.style.setProperty("--chat-tool-accent",t.accentColor),s.style.setProperty("--chat-action-color",t.accentColor),s.style.setProperty("--chat-send-bg",t.sendButton),s.style.setProperty("--chat-input-border",t.inputBorder)}function gr(){const t=document.documentElement;["--bg-primary","--bg-secondary","--bg-card","--surface-primary","--surface-secondary","--bg-glass","--bg-glass-hover","--text-primary","--text-secondary","--text-muted","--border-subtle","--border-default","--accent-primary","--accent-primary-light","--accent-gradient","--border-accent","--nav-active-bg","--nav-active-shadow","--chat-user-bg","--chat-user-color","--chat-user-radius","--chat-assistant-bg","--chat-assistant-color","--chat-assistant-radius","--chat-assistant-border","--chat-container-bg","--chat-thought-accent","--chat-tool-accent","--chat-action-color","--chat-send-bg","--chat-input-border"].forEach(r=>t.style.removeProperty(r))}function br(t){if(localStorage.setItem(Bs,t),document.documentElement.setAttribute("data-chat-theme",t),t==="custom"){const s=ht()?"dark":"light";at(ze(s))}else gr()}function yr(){const t=It();if(t!=="midnight"&&document.documentElement.setAttribute("data-chat-theme",t),t==="custom"){const s=ht()?"dark":"light";at(ze(s))}}function ht(){const t=document.documentElement.getAttribute("data-theme");return t?t==="dark":window.matchMedia("(prefers-color-scheme: dark)").matches}function Le({label:t,value:s,onChange:r}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[e.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",minWidth:110},children:t}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("input",{type:"color",value:s,onChange:a=>r(a.target.value),style:{width:28,height:28,border:"none",borderRadius:6,cursor:"pointer",background:"transparent",padding:0}}),e.jsx("input",{type:"text",value:s,onChange:a=>{/^#[0-9a-fA-F]{0,6}$/.test(a.target.value)&&r(a.target.value)},style:{width:72,fontSize:"0.7rem",fontFamily:"monospace",background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:4,padding:"3px 6px",color:"var(--text-primary)"}})]})]})}function xt({title:t,children:s}){return e.jsxs("div",{style:{marginBottom:14},children:[e.jsx("div",{style:{fontSize:"0.65rem",fontWeight:700,textTransform:"uppercase",color:"var(--text-muted)",letterSpacing:"0.08em",marginBottom:8,borderBottom:"1px solid var(--border-subtle)",paddingBottom:4},children:t}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:s})]})}function jr({dark:t,onColorsChange:s}){const r=t?"dark":"light",[a,i]=n.useState(()=>ze(r));n.useEffect(()=>{i(ze(r))},[r]);const c=n.useCallback((o,x)=>{i(d=>{const p={...d,[o]:x},l=ze(r==="dark"?"light":"dark");return r==="dark"?Nt(p,l):Nt(l,p),at(p),s(p),p})},[r,s]);return e.jsxs("div",{style:{marginTop:12,padding:"16px 18px",background:"var(--bg-glass)",border:"1px solid var(--border-subtle)",borderRadius:12},children:[e.jsxs("div",{style:{fontSize:"0.75rem",fontWeight:700,color:"var(--text-primary)",marginBottom:14,display:"flex",alignItems:"center",gap:8},children:["🎨 Custom Theme Editor",e.jsxs("span",{style:{fontSize:"0.65rem",fontWeight:500,color:"var(--text-muted)",background:"var(--bg-glass)",padding:"2px 8px",borderRadius:4},children:[t?"🌙 Dark":"☀️ Light"," mode"]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[e.jsxs("div",{children:[e.jsxs(xt,{title:"App Background",children:[e.jsx(Le,{label:"Background",value:a.bgPrimary,onChange:o=>c("bgPrimary",o)}),e.jsx(Le,{label:"Surface",value:a.bgSecondary,onChange:o=>c("bgSecondary",o)}),e.jsx(Le,{label:"Card",value:a.surfacePrimary,onChange:o=>c("surfacePrimary",o)})]}),e.jsxs(xt,{title:"App Text",children:[e.jsx(Le,{label:"Primary",value:a.textPrimary,onChange:o=>c("textPrimary",o)}),e.jsx(Le,{label:"Secondary",value:a.textSecondary,onChange:o=>c("textSecondary",o)}),e.jsx(Le,{label:"Muted",value:a.textMuted,onChange:o=>c("textMuted",o)})]}),e.jsxs(xt,{title:"Borders & Accent",children:[e.jsx(Le,{label:"Border subtle",value:a.borderSubtle,onChange:o=>c("borderSubtle",o)}),e.jsx(Le,{label:"Border default",value:a.borderDefault,onChange:o=>c("borderDefault",o)}),e.jsx(Le,{label:"Accent",value:a.accentColor,onChange:o=>c("accentColor",o)})]})]}),e.jsxs("div",{children:[e.jsxs(xt,{title:"Chat Bubbles",children:[e.jsx(Le,{label:"User bubble",value:a.userBubble,onChange:o=>c("userBubble",o)}),e.jsx(Le,{label:"User text",value:a.userText,onChange:o=>c("userText",o)}),e.jsx(Le,{label:"Agent bubble",value:a.assistantBubble,onChange:o=>c("assistantBubble",o)}),e.jsx(Le,{label:"Agent text",value:a.assistantText,onChange:o=>c("assistantText",o)})]}),e.jsxs(xt,{title:"Chat Layout",children:[e.jsx(Le,{label:"Chat BG",value:a.containerBg,onChange:o=>c("containerBg",o)}),e.jsx(Le,{label:"Send button",value:a.sendButton,onChange:o=>c("sendButton",o)}),e.jsx(Le,{label:"Input border",value:a.inputBorder,onChange:o=>c("inputBorder",o)}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[e.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",minWidth:110},children:"Bubble radius"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flex:1},children:[e.jsx("input",{type:"range",min:4,max:24,value:a.bubbleRadius,onChange:o=>c("bubbleRadius",Number(o.target.value)),style:{flex:1,accentColor:"var(--accent-primary)"}}),e.jsxs("span",{style:{fontSize:"0.7rem",color:"var(--text-muted)",width:28,textAlign:"right"},children:[a.bubbleRadius,"px"]})]})]})]})]})]}),e.jsx("button",{onClick:()=>{const o=t?zt:Ut,d=ze(t?"light":"dark");t?Nt(o,d):Nt(d,o),i(o),at(o),s(o)},style:{marginTop:10,fontSize:"0.7rem",color:"var(--text-muted)",background:"transparent",border:"1px solid var(--border-subtle)",borderRadius:6,padding:"4px 10px",cursor:"pointer"},children:"Reset to defaults"})]})}function vr(){const[t,s]=n.useState(It),[r,a]=n.useState(!0),[i,c]=n.useState(()=>ze("dark"));n.useEffect(()=>{a(ht());const d=new MutationObserver(()=>{const l=ht();a(l),It()==="custom"&&at(ze(l?"dark":"light"))});d.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});const p=window.matchMedia("(prefers-color-scheme: dark)"),u=()=>{const l=ht();a(l),It()==="custom"&&at(ze(l?"dark":"light"))};return p.addEventListener("change",u),()=>{d.disconnect(),p.removeEventListener("change",u)}},[]),n.useEffect(()=>{t!=="midnight"&&document.documentElement.setAttribute("data-chat-theme",t),t==="custom"&&at(ze(r?"dark":"light"))},[]),n.useEffect(()=>{c(ze(r?"dark":"light"))},[r]);const o=d=>{s(d),br(d),d==="midnight"&&document.documentElement.removeAttribute("data-chat-theme")},x=[...fr,{id:"custom",name:"Custom",description:"Full app + chat customization",preview:{dark:{userBubble:i.userBubble,assistantBubble:i.assistantBubble,assistantBorder:`1px solid ${i.accentColor}22`,containerBg:i.containerBg,textColor:i.assistantText},light:{userBubble:i.userBubble,assistantBubble:i.assistantBubble,assistantBorder:`1px solid ${i.accentColor}22`,containerBg:i.containerBg,textColor:i.assistantText}}}];return e.jsxs("div",{children:[e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-4 gap-3",children:x.map(d=>{const p=t===d.id,u=r?d.preview.dark:d.preview.light,l=d.id==="honey"?"#1a1a1a":d.id==="custom"?i.userText:"#fff";return e.jsxs("button",{onClick:()=>o(d.id),className:"text-left rounded-xl p-3 transition-all",style:{background:p?"var(--bg-glass-hover)":"var(--bg-glass)",border:p?"2px solid var(--accent-primary)":"2px solid var(--border-subtle)",opacity:p?1:.75},children:[e.jsxs("div",{className:"rounded-lg p-3 mb-2.5 flex flex-col gap-1.5",style:{background:u.containerBg},children:[e.jsx("div",{className:"self-start rounded-xl px-3 py-1.5 text-[10px] max-w-[75%]",style:{background:u.assistantBubble,border:u.assistantBorder,color:u.textColor},children:"Hello! How can I help?"}),e.jsx("div",{className:"self-end rounded-xl px-3 py-1.5 text-[10px] max-w-[75%]",style:{background:u.userBubble,color:l},children:"Fix the bug please"}),e.jsx("div",{className:"self-start rounded-xl px-3 py-1.5 text-[10px] max-w-[75%]",style:{background:u.assistantBubble,border:u.assistantBorder,color:u.textColor},children:"On it! ✨"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[p&&e.jsx("span",{className:"w-2 h-2 rounded-full bg-accent shrink-0"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-bold text-text-primary",children:d.id==="custom"?"🎨 Custom":d.name}),e.jsx("div",{className:"text-[10px] text-text-muted",children:d.description})]})]})]},d.id)})}),t==="custom"&&e.jsx(jr,{dark:r,onColorsChange:d=>c(d)})]})}const Yt="adhdev-accent-color",wr=[{name:"Violet",color:"#8b5cf6"},{name:"Indigo",color:"#6366f1"},{name:"Blue",color:"#3b82f6"},{name:"Cyan",color:"#06b6d4"},{name:"Emerald",color:"#10b981"},{name:"Rose",color:"#f43f5e"},{name:"Orange",color:"#f97316"},{name:"Amber",color:"#f59e0b"}],jt="#8b5cf6";function Nr(t){const s=parseInt(t.slice(1,3),16)/255,r=parseInt(t.slice(3,5),16)/255,a=parseInt(t.slice(5,7),16)/255,i=Math.max(s,r,a),c=Math.min(s,r,a);let o=0,x=0;const d=(i+c)/2;if(i!==c){const p=i-c;switch(x=d>.5?p/(2-i-c):p/(i+c),i){case s:o=((r-a)/p+(r<a?6:0))/6;break;case r:o=((a-s)/p+2)/6;break;case a:o=((s-r)/p+4)/6;break}}return{h:Math.round(o*360),s:Math.round(x*100),l:Math.round(d*100)}}function ds(t,s){const{h:r,s:a,l:i}=Nr(t),c=Math.min(100,i+s);return`hsl(${r}, ${a}%, ${c}%)`}function Mt(t,s){const r=parseInt(t.slice(1,3),16),a=parseInt(t.slice(3,5),16),i=parseInt(t.slice(5,7),16);return`rgba(${r}, ${a}, ${i}, ${s})`}function us(){return typeof window>"u"?jt:localStorage.getItem(Yt)||jt}function kr(t){const s=document.documentElement;s.style.setProperty("--accent-primary",t),s.style.setProperty("--accent-primary-light",ds(t,15)),s.style.setProperty("--accent-gradient",`linear-gradient(135deg, ${t}, ${ds(t,20)})`),s.style.setProperty("--border-accent",Mt(t,.4)),s.style.setProperty("--nav-active-bg",Mt(t,.1)),s.style.setProperty("--nav-active-shadow",`inset 3px 0 0 ${t}, 0 0 12px ${Mt(t,.06)}`)}function Sr(){const t=document.documentElement;["--accent-primary","--accent-primary-light","--accent-gradient","--border-accent","--nav-active-bg","--nav-active-shadow"].forEach(r=>t.style.removeProperty(r))}function Cr(t){t===jt?(localStorage.removeItem(Yt),Sr()):(localStorage.setItem(Yt,t),kr(t))}function Ir(){const[t,s]=n.useState(us),[r,a]=n.useState("");n.useEffect(()=>{s(us())},[]);const i=c=>{s(c),Cr(c)};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:wr.map(c=>{const o=t===c.color;return e.jsx("button",{onClick:()=>i(c.color),title:c.name,style:{width:36,height:36,borderRadius:10,background:c.color,border:o?"3px solid var(--text-primary)":"3px solid transparent",cursor:"pointer",position:"relative",transition:"transform 0.15s, border-color 0.15s",transform:o?"scale(1.1)":"scale(1)",boxShadow:o?`0 0 12px ${Mt(c.color,.4)}`:"none"},children:o&&e.jsx("span",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontSize:14,fontWeight:700,textShadow:"0 1px 2px rgba(0,0,0,0.5)"},children:"✓"})},c.color)})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Custom:"}),e.jsx("input",{type:"color",value:t,onChange:c=>i(c.target.value),style:{width:28,height:28,border:"none",borderRadius:6,cursor:"pointer",background:"transparent",padding:0}}),e.jsx("input",{type:"text",value:r||t,onChange:c=>{a(c.target.value),/^#[0-9a-fA-F]{6}$/.test(c.target.value)&&i(c.target.value)},onBlur:()=>a(""),style:{width:80,fontSize:"0.7rem",fontFamily:"monospace",background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:4,padding:"3px 6px",color:"var(--text-primary)"}}),t!==jt&&e.jsx("button",{onClick:()=>i(jt),style:{fontSize:"0.7rem",color:"var(--text-muted)",background:"transparent",border:"1px solid var(--border-subtle)",borderRadius:5,padding:"3px 8px",cursor:"pointer"},children:"Reset"})]})]})}const Os="adhdev_hiddenTabs";function Mr(){try{const t=localStorage.getItem(Os);if(t)return new Set(JSON.parse(t))}catch{}return new Set}function mt(t){try{localStorage.setItem(Os,JSON.stringify([...t]))}catch{}}function Tr(){const[t,s]=n.useState(Mr),r=n.useCallback(d=>{s(p=>{const u=new Set(p);return u.has(d)?u.delete(d):u.add(d),mt(u),u})},[]),a=n.useCallback(d=>{s(p=>{if(p.has(d))return p;const u=new Set(p);return u.add(d),mt(u),u})},[]),i=n.useCallback(d=>{s(p=>{if(!p.has(d))return p;const u=new Set(p);return u.delete(d),mt(u),u})},[]),c=n.useCallback((d,p)=>{s(u=>{const l=new Set(u);for(const g of p)l.add(g);return mt(l),l})},[]),o=n.useCallback((d,p)=>{s(u=>{const l=new Set(u);for(const g of p)l.delete(g);return mt(l),l})},[]),x=n.useCallback(d=>t.has(d),[t]);return{hiddenTabs:t,toggleTab:r,hideTab:a,showTab:i,hideAllForDaemon:c,showAllForDaemon:o,isHidden:x}}function Ks({sendDaemonCommand:t,activeConv:s,ides:r,updateIdeChats:a,setToasts:i,setLocalUserMessages:c,setClearedTabs:o,setActionLogs:x,pinTab:d,isStandalone:p}){const[u,l]=n.useState(""),[g,h]=n.useState(!1),[m,A]=n.useState(!1),[_,j]=n.useState(!1),w=n.useCallback(R=>R?We(R)||Re(R)?{agentType:R.agentType||R.ideType}:R.streamSource==="agent-stream"?{agentType:R.agentType}:{}:{},[]),O=n.useCallback(async()=>{if(!s)return;const R=u.trim();if(!R)return;const z=s.ideId,U=s.tabKey;l(""),d(U,[100,500,1500,3e3]);const v=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,ne={role:"user",content:R,timestamp:Date.now(),_localId:v};c(pe=>({...pe,[U]:[...pe[U]||[],ne]}));try{const pe=z||s.daemonId||"";if(!pe)return;await t(pe,"send_chat",{message:R,text:R,...w(s)}),setTimeout(()=>{const q=Date.now()-6e4;c(G=>{const H=G[U];if(!H)return G;const oe=H.filter(J=>J.timestamp>q);return oe.length===H.length?G:{...G,[U]:oe}})},6e4)}catch(pe){console.error("Send failed",pe),l(R),c(q=>({...q,[U]:(q[U]||[]).filter(G=>G._localId!==v)}))}},[s,u,t,c,d,w]),B=n.useCallback(async()=>{if(s)try{p?await t(s.ideId,"launch_ide",{ideType:s.ideType,enableCdp:!0}):await t(s.ideId,"vscode_command_exec",{commandId:"adhdev.relaunchWithCdp",args:[{force:!0}]})}catch(R){console.error("Relaunch failed",R)}},[s,p,t]),$=n.useCallback(async R=>{try{await t("standalone","launch_ide",{ideType:R,enableCdp:!0})}catch(z){console.error("Launch failed",z)}},[t]),C=n.useCallback(async R=>{if(s){console.log("[ModalButton] ideId:",s.ideId,"button:",R),x(z=>[...z,{ideId:s.tabKey,text:`🖱️ **${R}** clicked`,timestamp:Date.now()}]);try{const U=(s.modalButtons||[]).indexOf(R),v=R.replace(/[⌥⏎⇧⌫⌘⌃]/g,"").trim().toLowerCase(),ne=/^(run|approve|accept|yes|allow|always|proceed|save)/.test(v),pe=s.ideId||s.daemonId||"";(await t(pe,"resolve_action",{button:R,action:ne?"approve":"reject",...U>=0&&{buttonIndex:U},...w(s)})).success||x(G=>[...G,{ideId:s.tabKey,text:`⚠️ **${R}** failed — button not found`,timestamp:Date.now()}])}catch(z){console.error("[ModalButton] Error:",z),x(U=>[...U,{ideId:s.tabKey,text:`❌ **${R}** error`,timestamp:Date.now()}])}}},[s,t,x,w]),W=n.useCallback(async(R,z)=>{try{const U=R||(s==null?void 0:s.daemonId)||"",v=await t(U,"switch_chat",{id:z,sessionId:z,...w(s)}),ne=v==null?void 0:v.result;(v==null?void 0:v.success)===!0||ne==="switched"||ne==="switched-by-title"||(ne===!1||ne==="not_found"?i(q=>[...q,{id:Date.now(),message:"⚠️ Session tab not found — try refreshing history",type:"warning",timestamp:Date.now()}]):typeof ne=="string"&&ne.startsWith("error:")?i(q=>[...q,{id:Date.now(),message:`⚠️ Switch error: ${ne}`,type:"warning",timestamp:Date.now()}]):i(q=>[...q,{id:Date.now(),message:"⚠️ Session switch failed",type:"warning",timestamp:Date.now()}]))}catch(U){console.error("Switch failed",U),i(v=>[...v,{id:Date.now(),message:`❌ Switch failed: ${U.message||"connection error"}`,type:"warning",timestamp:Date.now()}])}},[s,t,i,w]),S=n.useCallback(async()=>{if(!(!s||g)){h(!0);try{const R=s.ideId||s.daemonId||"";await t(R,"new_chat",{...w(s)}),o(z=>({...z,[s.tabKey]:Date.now()})),c(z=>({...z,[s.tabKey]:[]}))}catch(R){console.error("New chat failed",R)}finally{h(!1)}}},[s,g,t,o,c,w]),y=n.useCallback(async()=>{if(!s||_)return;j(!0);const R=s.tabKey;try{await t(s.ideId,"agent_stream_focus",{agentType:s.agentType}),d(R,[200,1500,3e3])}catch(z){console.error("Focus agent failed",z)}finally{j(!1)}},[s,_,t,d]),se=n.useCallback(async()=>{var R;if(!(!s||m)){A(!0);try{const z=s.ideId||s.daemonId||"",U=await t(z,"list_chats",{forceExpand:!0,...w(s)}),v=(U==null?void 0:U.chats)||((R=U==null?void 0:U.result)==null?void 0:R.chats);U!=null&&U.success&&Array.isArray(v)&&a(s.ideId,v)}catch(z){console.error("Refresh history failed",z)}finally{A(!1)}}},[s,m,t,a,w]);return{agentInput:u,setAgentInput:l,isCreatingChat:g,isRefreshingHistory:m,isFocusingAgent:_,handleSendChat:O,handleRelaunch:B,handleLaunchIde:$,handleModalButton:C,handleSwitchSession:W,handleNewChat:S,handleFocusAgent:y,handleRefreshHistory:se}}const Dt={unix:{cmd:"curl -fsSL https://adhf.dev/install | sh",shell:"Terminal",prompt:"$ "},powershell:{cmd:"irm https://adhf.dev/install.ps1 | iex",shell:"PowerShell",prompt:"PS> "},cmd:{cmd:"curl -fsSL https://adhf.dev/install.cmd -o %TEMP%\\adhdev.cmd && %TEMP%\\adhdev.cmd",shell:"CMD",prompt:"> "}};function Er(){return typeof navigator>"u"?"unix":navigator.userAgent.toLowerCase().includes("win")?"windows":"unix"}function Ar(){const[t,s]=n.useState("unix"),[r,a]=n.useState("powershell"),[i,c]=n.useState(!1),o=t==="unix"?"unix":r;n.useEffect(()=>{s(Er())},[]);const x=n.useCallback(()=>{navigator.clipboard.writeText(Dt[o].cmd).catch(()=>{}),c(!0),setTimeout(()=>c(!1),2e3)},[o]);return e.jsxs("div",{className:"text-left bg-bg-secondary border border-border-subtle rounded-xl p-4 font-mono text-[13px] shadow-lg w-full mx-auto leading-relaxed relative select-all",children:[e.jsxs("div",{className:"flex gap-1 mb-3 font-sans",children:[e.jsx("button",{className:`text-[10px] px-2.5 py-1 rounded-md font-bold transition-all cursor-pointer ${t==="unix"?"bg-accent/15 text-accent border border-accent/25":"bg-transparent text-text-muted border border-transparent hover:text-text-secondary"}`,onClick:()=>s("unix"),children:"🍎🐧 macOS / Linux"}),e.jsx("button",{className:`text-[10px] px-2.5 py-1 rounded-md font-bold transition-all cursor-pointer ${t==="windows"?"bg-accent/15 text-accent border border-accent/25":"bg-transparent text-text-muted border border-transparent hover:text-text-secondary"}`,onClick:()=>s("windows"),children:"🪟 Windows"})]}),t==="windows"&&e.jsxs("div",{className:"flex gap-1 mb-3 font-sans",children:[e.jsx("button",{className:`text-[9px] px-2 py-0.5 rounded font-semibold cursor-pointer transition-all ${r==="powershell"?"bg-accent/10 text-accent":"text-text-muted hover:text-text-secondary"}`,onClick:()=>a("powershell"),children:"⚡ PowerShell"}),e.jsx("button",{className:`text-[9px] px-2 py-0.5 rounded font-semibold cursor-pointer transition-all ${r==="cmd"?"bg-accent/10 text-accent":"text-text-muted hover:text-text-secondary"}`,onClick:()=>a("cmd"),children:">_ CMD"})]}),e.jsxs("div",{className:"flex items-center gap-3 text-accent cursor-pointer group",onClick:x,title:"Click to copy",children:[e.jsx("span",{className:"text-text-muted select-none",children:Dt[o].prompt}),e.jsx("span",{className:"flex-1 break-all",children:Dt[o].cmd}),e.jsx("span",{className:"text-[9px] font-sans text-text-muted opacity-0 group-hover:opacity-100 transition-opacity shrink-0 select-none",children:i?"✓":"📋"})]}),e.jsxs("div",{className:"text-text-muted text-[10px] font-sans mt-2",children:["Or via npm: ",e.jsx("span",{className:"text-text-secondary font-mono",children:"npm i -g @adhdev/daemon-standalone && adhdev-standalone"})]})]})}function $r({conversations:t,ides:s,messageReceivedAt:r,actionLogs:a,ptyBuffers:i,screenshotMap:c,setScreenshotMap:o,sendDaemonCommand:x,updateIdeChats:d,setToasts:p,setLocalUserMessages:u,setClearedTabs:l,setActionLogs:g,pinTab:h,isStandalone:m,userName:A,groupIndex:_,isFocused:j,onFocus:w,isSplitMode:O,numGroups:B,onMoveTab:$,onClose:C,onReceiveTab:W,style:S,detectedIdes:y,handleLaunchIde:se,onActiveTabChange:R,initialActiveTabId:z,initialTabOrder:U,onTabOrderChange:v,onHideTab:ne,cliViewModes:pe}){const{sendCommand:q}=st(),G=n.useRef(null),[H,oe]=n.useState(!1),[J,ie]=n.useState(null),ce=n.useRef(0),D=n.useRef(null),[b,P]=n.useState(z??null);n.useEffect(()=>{z&&z!==b&&P(z)},[z]);const[f,K]=n.useState(U??[]),[Y,te]=n.useState(null),Se=n.useRef(null),Ne=n.useRef(null);n.useEffect(()=>{const N=new Set(t.map(Z=>Z.tabKey));K(Z=>{const L=Z.filter(ee=>N.has(ee)),xe=t.filter(ee=>!Z.includes(ee.tabKey)).map(ee=>ee.tabKey),V=[...L,...xe];return V.length===Z.length&&V.every((ee,ue)=>ee===Z[ue])?Z:V})},[t]);const je=Y??f,me=n.useMemo(()=>{if(je.length===0)return t;const N=new Map(je.map((Z,L)=>[Z,L]));return[...t].sort((Z,L)=>{const xe=N.get(Z.tabKey)??999,V=N.get(L.tabKey)??999;return xe-V})},[t,je]);n.useEffect(()=>{if(me.length===0){P(null),R==null||R(null);return}b&&me.some(N=>N.tabKey===b)||(P(me[0].tabKey),R==null||R(me[0].tabKey))},[me,b]);const de=me.find(N=>N.tabKey===b),F=n.useCallback((N,Z,L)=>{K(xe=>{const V=xe.filter(X=>X!==N),ee=V.indexOf(Z);if(ee<0)return xe;const ue=L==="left"?ee:ee+1;return V.splice(ue,0,N),v==null||v(V),V}),te(null)},[v]),he=n.useCallback((N,Z,L)=>{const V=(f.length>0?f:t.map(X=>X.tabKey)).filter(X=>X!==N),ee=V.indexOf(Z);if(ee<0)return;const ue=L==="left"?ee:ee+1;V.splice(ue,0,N),Se.current=V,te(V)},[f,t]),be=Ks({sendDaemonCommand:x,activeConv:de,ides:s,updateIdeChats:d,setToasts:p,setLocalUserMessages:u,setClearedTabs:l,setActionLogs:g,pinTab:h,isStandalone:m}),[ye,Me]=n.useState(null);n.useEffect(()=>{if(!ye)return;const N=Z=>{const L=document.querySelector("[data-pane-context-menu]");L&&L.contains(Z.target)||Me(null)};return window.addEventListener("mousedown",N,!0),()=>window.removeEventListener("mousedown",N,!0)},[ye]);const Ue="adhdev-tab-shortcuts",Ke=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.userAgent),[Pe,dt]=n.useState(()=>{try{return JSON.parse(localStorage.getItem(Ue)||"{}")}catch{return{}}}),[Oe,Ye]=n.useState(null),Ae=n.useCallback(N=>{const Z=[];N.metaKey&&Z.push(Ke?"⌘":"Meta"),N.ctrlKey&&Z.push("Ctrl"),N.altKey&&Z.push(Ke?"⌥":"Alt"),N.shiftKey&&Z.push(Ke?"⇧":"Shift");const L=N.key;if(["Control","Alt","Shift","Meta"].includes(L))return null;const xe=L.length===1?L.toUpperCase():L;return Z.push(xe),Z.join("+")},[Ke]),M=n.useCallback((N,Z)=>Ae(N)===Z,[Ae]),re=n.useCallback(N=>{dt(N),localStorage.setItem(Ue,JSON.stringify(N))},[]);n.useEffect(()=>{if(!Oe)return;const N=Z=>{if(Z.preventDefault(),Z.stopPropagation(),Z.key==="Escape"){Ye(null);return}const L=Ae(Z);if(!L)return;const xe={...Pe};for(const[V,ee]of Object.entries(xe))ee===L&&delete xe[V];xe[Oe]=L,re(xe),Ye(null)};return window.addEventListener("keydown",N,!0),()=>window.removeEventListener("keydown",N,!0)},[Oe,Pe,re,Ae]),n.useEffect(()=>{const N=Z=>{if(!(!Z.ctrlKey&&!Z.metaKey&&!Z.altKey)){for(const[L,xe]of Object.entries(Pe))if(M(Z,xe)&&me.some(V=>V.tabKey===L)){Z.preventDefault(),w(),P(L),R==null||R(L);return}}};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[Pe,me,w,R,M]);const Q=de&&We(de)&&!Re(de),ge=Q?pe[de.tabKey]??de.mode??"terminal":"chat";n.useEffect(()=>{const N=()=>{ce.current=0,oe(!1),ie(null)};return window.addEventListener("dragend",N),window.addEventListener("drop",N),()=>{window.removeEventListener("dragend",N),window.removeEventListener("drop",N)}},[]);const we=n.useRef(null);return n.useEffect(()=>{const N=we.current;if(!N)return;const Z=L=>{Math.abs(L.deltaY)>Math.abs(L.deltaX)&&(L.preventDefault(),N.scrollLeft+=L.deltaY)};return N.addEventListener("wheel",Z,{passive:!1}),()=>N.removeEventListener("wheel",Z)},[]),e.jsxs("div",{className:"flex flex-col min-h-0 min-w-0 flex-1 overflow-hidden",onClick:w,style:{...S,outline:H?"2px dashed var(--accent-primary)":"none",outlineOffset:"-2px",transition:"outline 0.15s ease"},children:[e.jsx("div",{className:"flex items-center bg-bg-secondary border-b border-border-subtle shrink-0 gap-0",children:e.jsxs("div",{ref:we,className:"flex-1 flex overflow-x-auto overflow-y-visible pt-1.5 pb-0 gap-1 select-none",style:{paddingLeft:8,paddingRight:4,scrollbarWidth:"none"},children:[me.map((N,Z)=>{const L=b===N.tabKey,xe=N.status==="working"?"agent-tab-working":N.status==="waiting_approval"?"agent-tab-waiting":"",V=N.connectionState==="failed"||N.connectionState==="closed",ee=Ne.current===N.tabKey;return e.jsxs("div",{"data-tabkey":N.tabKey,className:`${xe} shrink-0 px-2.5 py-1.5 rounded-t-lg cursor-pointer flex items-center gap-2 relative`,draggable:!0,onDragStart:ue=>{Ne.current=N.tabKey,ue.dataTransfer.setData("text/tab-key",N.tabKey),ue.dataTransfer.effectAllowed="move"},onDragEnd:()=>{Ne.current=null;const ue=Se.current;ue&&(K(ue),v==null||v(ue)),Se.current=null,te(null),ce.current=0,oe(!1)},onDragOver:ue=>{const X=Ne.current;if(!(!X||X===N.tabKey)&&ue.dataTransfer.types.includes("text/tab-key")){ue.preventDefault(),ue.stopPropagation();const fe=ue.currentTarget.getBoundingClientRect(),Ce=fe.left+fe.width/2,Ie=ue.clientX<Ce?"left":"right";he(X,N.tabKey,Ie)}},onDrop:ue=>{ue.preventDefault(),ue.stopPropagation();const X=ue.dataTransfer.getData("text/tab-key");if(X&&X!==N.tabKey){const fe=ue.currentTarget.getBoundingClientRect(),Ce=fe.left+fe.width/2,Ie=ue.clientX<Ce?"left":"right";me.some($e=>$e.tabKey===X)?F(X,N.tabKey,Ie):W&&W(X)}te(null)},onClick:ue=>{ue.stopPropagation(),w(),P(N.tabKey),R==null||R(N.tabKey),N.streamSource==="agent-stream"&&N.agentType&&q(N.ideId,"agent_stream_focus",{agentType:N.agentType}).catch(()=>{}),We(N)&&setTimeout(()=>{var X,fe;return(fe=(X=G.current)==null?void 0:X.bumpResize)==null?void 0:fe.call(X)},100)},onContextMenu:ue=>{ue.preventDefault(),Me({x:ue.clientX,y:ue.clientY,tabKey:N.tabKey})},onTouchStart:ue=>{const X=ue.touches[0],fe=X.clientX,Ce=X.clientY;D.current=setTimeout(()=>{Me({x:fe,y:Ce,tabKey:N.tabKey})},600)},onTouchEnd:()=>{D.current&&clearTimeout(D.current)},onTouchMove:()=>{D.current&&clearTimeout(D.current)},style:{background:L?"var(--bg-primary)":"var(--bg-glass)",borderTop:L?"1px solid var(--border-subtle)":"1px solid transparent",borderLeft:L?"1px solid var(--border-subtle)":"1px solid transparent",borderRight:L?"1px solid var(--border-subtle)":"1px solid transparent",opacity:ee?.4:V?L?.6:.3:L?1:.65,transition:"transform 0.2s ease, opacity 0.15s ease"},children:[N.status==="working"?e.jsx("div",{className:"tab-spinner"}):N.status==="waiting_approval"?e.jsx("span",{className:"text-[8px] px-[5px] py-px text-yellow-400",children:"▲"}):V?e.jsx("span",{className:"text-[8px] px-[5px] py-px text-yellow-400 animate-pulse",children:"○"}):N.connectionState==="connecting"||N.connectionState==="new"?e.jsx("div",{className:"tab-connecting-spinner"}):N.connectionState==="connected"?e.jsx("span",{className:"text-[8px] px-[5px] py-px text-green-400",children:"●"}):e.jsx("span",{className:"text-[8px] px-[5px] py-px text-text-muted animate-pulse",children:"○"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-xs font-bold whitespace-nowrap overflow-hidden text-ellipsis",style:{maxWidth:"10ch"},title:N.displayPrimary,children:N.displayPrimary}),e.jsx("div",{className:"text-[8px] opacity-50 flex gap-1 items-center",children:V?e.jsx("span",{className:"text-yellow-400 opacity-100",children:"Reconnecting…"}):N.connectionState==="connecting"||N.connectionState==="new"?e.jsxs("span",{className:"text-blue-400 opacity-100",children:["Connecting",e.jsx("span",{className:"connecting-dots"})]}):e.jsxs(e.Fragment,{children:[N.displaySecondary,N.machineName&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"opacity-40",children:"·"}),e.jsxs("span",{className:"opacity-70",children:["🖥 ",N.machineName]})]})]})})]}),Pe[N.tabKey]&&e.jsx("span",{className:"text-[9px] opacity-50 font-mono ml-0.5 shrink-0 bg-bg-secondary px-1 rounded",title:`Ctrl+${Pe[N.tabKey]}`,children:Pe[N.tabKey]})]},N.tabKey)}),t.length===0&&e.jsx("div",{className:"p-2 text-xs opacity-40",children:"No tabs in this group"})]})}),e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden relative",onDragEnter:N=>{N.dataTransfer.types.includes("text/tab-key")&&(ce.current++,oe(!0))},onDragOver:N=>{if(!N.dataTransfer.types.includes("text/tab-key"))return;N.preventDefault();const Z=N.currentTarget.getBoundingClientRect(),L=N.clientX-Z.left;if(B<4&&$){const xe=Z.width/3;L<xe?ie("split-left"):L>xe*2?ie("split-right"):ie("merge");return}ie("merge")},onDragLeave:()=>{ce.current--,ce.current<=0&&(ce.current=0,oe(!1),ie(null))},onDrop:N=>{ce.current=0,oe(!1);const Z=N.dataTransfer.getData("text/tab-key"),L=Z?t.some(V=>V.tabKey===Z):!1,xe=J;if(ie(null),te(null),!!Z){if(N.preventDefault(),xe==="split-left"&&$&&B<4){$(Z,"split-left");return}if(xe==="split-right"&&$&&B<4){$(Z,"split-right");return}L?K(V=>{const ee=V.filter(ue=>ue!==Z);return ee.push(Z),v==null||v(ee),ee}):W&&W(Z)}},children:[H&&e.jsxs("div",{className:"absolute inset-0 z-10 pointer-events-none flex",children:[e.jsx("div",{className:"flex-1 border-r border-white/10 transition-all duration-150 flex items-center justify-center",style:{background:J==="split-left"?"rgba(255,255,255,0.1)":"rgba(255,255,255,0.04)",boxShadow:J==="split-left"?"inset 0 0 0 2px var(--accent-primary)":"inset 0 0 0 1px rgba(255,255,255,0.05)",opacity:B<4&&$?1:.45},children:e.jsx("div",{className:"px-3 py-1.5 rounded-full text-[11px] font-semibold text-white bg-black/45 backdrop-blur-sm",children:"Split Left"})}),e.jsx("div",{className:"flex-1 border-r border-white/10 transition-all duration-150 flex items-center justify-center",style:{background:J==="merge"?"rgba(255,255,255,0.1)":"rgba(255,255,255,0.04)",boxShadow:J==="merge"?"inset 0 0 0 2px var(--accent-primary)":"inset 0 0 0 1px rgba(255,255,255,0.05)"},children:e.jsx("div",{className:"px-3 py-1.5 rounded-full text-[11px] font-semibold text-white bg-black/45 backdrop-blur-sm",children:"Move Here"})}),e.jsx("div",{className:"flex-1 transition-all duration-150 flex items-center justify-center",style:{background:J==="split-right"?"rgba(255,255,255,0.1)":"rgba(255,255,255,0.04)",boxShadow:J==="split-right"?"inset 0 0 0 2px var(--accent-primary)":"inset 0 0 0 1px rgba(255,255,255,0.05)",opacity:B<4&&$?1:.45},children:e.jsx("div",{className:"px-3 py-1.5 rounded-full text-[11px] font-semibold text-white bg-black/45 backdrop-blur-sm",children:"Split Right"})})]}),de?e.jsxs(e.Fragment,{children:[e.jsx($n,{activeConv:de,onModalButton:be.handleModalButton}),e.jsx("div",{className:"desktop-only px-3 pt-1 pb-2",children:!Q&&!Re(de)&&c[de.ideId]?e.jsx(An,{screenshotUrl:c[de.ideId],mode:"preview",onDismiss:()=>{const N={...c};delete N[de.ideId],o(N)}}):!Q&&!Re(de)&&de.cdpConnected===!1?e.jsxs("div",{className:"flex items-center gap-2.5 px-3.5 py-2 bg-yellow-500/[0.08] border border-yellow-500/20 rounded-lg text-xs text-text-secondary",children:[e.jsx("span",{className:"text-sm",children:e.jsx(Xt,{size:14})}),e.jsx("span",{className:"flex-1",children:"CDP not connected — chat history & screenshots unavailable."}),e.jsx("button",{className:"btn btn-sm bg-yellow-500/15 text-yellow-500 border border-yellow-500/30 text-[10px] whitespace-nowrap shrink-0",onClick:be.handleRelaunch,children:"Relaunch with CDP"})]}):null}),ge==="terminal"?e.jsx(Rn,{activeConv:de,ptyBuffers:i,terminalRef:G,agentInput:be.agentInput,setAgentInput:be.setAgentInput,handleSendChat:be.handleSendChat}):e.jsx(Ms,{activeConv:de,ides:s,agentInput:be.agentInput,setAgentInput:be.setAgentInput,handleSendChat:be.handleSendChat,handleFocusAgent:be.handleFocusAgent,isFocusingAgent:be.isFocusingAgent,messageReceivedAt:r,actionLogs:a,userName:A})]}):e.jsx("div",{className:"flex-1 flex flex-col items-center justify-center",children:t.length===0&&!O&&y&&se?e.jsxs("div",{className:"empty-dashboard flex-1 flex flex-col items-center justify-center -mt-8",children:[e.jsx("div",{className:"glow-orb mb-6 opacity-90 animate-bounce",style:{animationDuration:"3s"},children:e.jsx("img",{src:"/otter-logo.png",alt:"ADHDev",className:"w-16 h-16 object-contain"})}),e.jsxs("div",{className:"text-center max-w-lg",children:[e.jsx("h2",{className:"font-bold text-2xl mb-2.5 tracking-tight text-text-primary",children:"Waiting for your IDE"}),e.jsx("p",{className:"text-[14px] text-text-secondary mb-8 leading-relaxed max-w-md mx-auto",children:m?"Launch any supported IDE or CLI agent to start monitoring automatically.":"Install the ADHDev daemon and link your dashboard to start."}),!m&&e.jsx(Ar,{}),m&&y&&y.length>0&&e.jsxs("div",{className:"flex flex-col gap-3 items-center",children:[e.jsx("div",{className:"text-xs font-semibold uppercase tracking-wider text-text-muted",children:"Fast Launch"}),e.jsx("div",{className:"flex flex-wrap gap-2.5 justify-center mt-1",children:y.map(N=>e.jsxs("button",{className:"btn btn-sm bg-accent/10 border border-accent/25 text-accent text-xs font-medium px-4 py-2.5 rounded-lg cursor-pointer flex items-center gap-2 transition-all hover:bg-accent/20 hover:scale-105 active:scale-95",onClick:()=>se&&se(N.type),children:[e.jsx(vn,{size:14,className:"opacity-70"})," Launch ",N.name]},N.type))})]}),!m&&e.jsx("div",{className:"mt-8",children:e.jsx("a",{href:"https://docs.adhf.dev",target:"_blank",rel:"noopener noreferrer",className:"text-sm font-medium text-accent hover:opacity-80 transition-colors flex items-center justify-center gap-1.5",children:"📚 Read the documentation →"})})]})]}):e.jsx("div",{className:"text-sm text-text-muted opacity-50",children:O?"Move a tab here to view":"No active agent"})})]}),ye&&e.jsxs("div",{"data-pane-context-menu":!0,className:"fixed z-50 bg-bg-primary border border-border-subtle rounded-lg shadow-lg py-1 min-w-[160px]",style:{left:ye.x,top:ye.y},children:[$&&_>0&&e.jsx("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors ",onClick:()=>{$(ye.tabKey,"left"),Me(null)},children:"← Move to Left Group"}),$&&_<B-1&&e.jsx("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors ",onClick:()=>{$(ye.tabKey,"right"),Me(null)},children:"Move to Right Group →"}),$&&B<4&&e.jsx("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors ",onClick:()=>{$(ye.tabKey,"split-left"),Me(null)},children:"⇤ Split Left"}),$&&B<4&&e.jsx("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors ",onClick:()=>{$(ye.tabKey,"split-right"),Me(null)},children:"Split Right ⇥"}),e.jsx("div",{className:"border-t border-border-subtle my-1 "}),e.jsxs("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors ",onClick:N=>{N.stopPropagation(),Ye(ye.tabKey),Me(null)},children:["⌨ ",Pe[ye.tabKey]?`Change shortcut (${Pe[ye.tabKey]})`:"Set shortcut"]}),Pe[ye.tabKey]&&e.jsx("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors text-text-muted ",onClick:()=>{const N={...Pe};delete N[ye.tabKey],re(N),Me(null)},children:"✕ Remove shortcut"}),ne&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border-t border-border-subtle my-1"}),e.jsx("button",{className:"w-full text-left px-3 py-1.5 text-xs hover:bg-bg-secondary transition-colors text-text-muted",onClick:()=>{ne(ye.tabKey),Me(null)},children:"🚫 Hide from Dashboard"})]}),!$&&!ne&&e.jsx("div",{className:"px-3 py-1.5 text-[11px] text-text-muted opacity-50 italic",children:"No actions available"})]}),Oe&&e.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)",backdropFilter:"blur(2px)"},onClick:()=>Ye(null),children:e.jsxs("div",{className:"bg-bg-primary border border-border-subtle rounded-xl px-8 py-6 text-center shadow-xl",onClick:N=>N.stopPropagation(),children:[e.jsx("div",{className:"text-sm font-bold text-text-primary mb-2",children:"⌨ Set shortcut"}),e.jsxs("div",{className:"text-xs text-text-secondary mb-4",children:["Press a key combo (e.g. ",Ke?"⌘+1":"Ctrl+1",", ",Ke?"⌥+A":"Alt+A",")"]}),e.jsx("div",{className:"text-lg font-mono text-accent animate-pulse",children:"Listening..."}),e.jsx("div",{className:"text-[10px] text-text-muted mt-3",children:"Press Esc to cancel"})]})})]})}const Bt=[{icon:"🦦",title:"Welcome to ADHDev",desc:"Monitor and control your AI coding agents from anywhere — web, mobile, or CLI.",visual:"🎉"},{icon:"💬",title:"Real-time chat",desc:"See what your AI agent is doing in real-time. Send messages, approve or reject actions — all from your browser or phone.",visual:"📱"},{icon:"🖥️",title:"Remote desktop",desc:"View and control your IDE screen via P2P connection. Click, type, scroll — just like being there.",visual:"🖱️"},{icon:"🚀",title:"Get started",desc:"Install the daemon and link it to your dashboard. It connects automatically.",code:"npm install -g @adhdev/daemon-standalone && adhdev-standalone"}];function _r({onClose:t}){const[s,r]=n.useState(0),a=Bt[s],i=s===Bt.length-1;return e.jsxs("div",{className:"onboarding-overlay",style:{position:"fixed",inset:0,zIndex:9999,background:"rgba(0,0,0,0.65)",backdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center",animation:"fadeIn 0.3s ease-out"},onClick:c=>{c.target===c.currentTarget&&t()},children:[e.jsxs("div",{style:{background:"var(--bg-secondary, #1a1a2e)",border:"1px solid var(--border-subtle, #333)",borderRadius:"1.25rem",width:"min(440px, 92vw)",padding:"2.5rem 2rem 2rem",position:"relative",animation:"slideUp 0.3s ease-out"},children:[e.jsx("button",{onClick:t,style:{position:"absolute",top:12,right:16,background:"transparent",border:"none",color:"var(--text-muted)",fontSize:"1.2rem",cursor:"pointer"},children:"✕"}),e.jsx("div",{style:{display:"flex",justifyContent:"center",gap:6,marginBottom:"1.5rem"},children:Bt.map((c,o)=>e.jsx("div",{style:{width:o===s?24:8,height:8,borderRadius:4,background:o===s?"var(--accent, #7c3aed)":"var(--border-subtle, #444)",transition:"all 0.3s ease"}},o))}),e.jsx("div",{style:{textAlign:"center",fontSize:"3rem",marginBottom:"1rem"},children:a.visual||a.icon}),e.jsxs("div",{style:{textAlign:"center"},children:[e.jsxs("h2",{style:{fontSize:"1.35rem",fontWeight:700,color:"var(--text-primary)",marginBottom:"0.75rem",display:"flex",alignItems:"center",justifyContent:"center",gap:8},children:[e.jsx("span",{children:a.icon})," ",a.title]}),e.jsx("p",{style:{fontSize:"0.9rem",color:"var(--text-secondary)",lineHeight:1.6,marginBottom:"1.25rem"},children:a.desc}),a.code&&e.jsxs("div",{style:{background:"var(--bg-primary, #111)",border:"1px solid var(--border-subtle, #333)",borderRadius:"0.5rem",padding:"0.75rem 1rem",fontFamily:"monospace",fontSize:"0.8rem",color:"var(--accent, #a78bfa)",textAlign:"left",overflowX:"auto",marginBottom:"0.5rem"},children:[e.jsx("span",{style:{color:"var(--text-muted)",marginRight:8},children:"$"}),a.code]}),i&&e.jsx("a",{href:"https://docs.adhf.dev",target:"_blank",rel:"noopener noreferrer",style:{fontSize:"0.75rem",color:"var(--accent, #a78bfa)",textDecoration:"none"},children:"📚 Learn more in the docs →"})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginTop:"1.5rem"},children:[e.jsx("button",{onClick:t,style:{background:"transparent",border:"none",color:"var(--text-muted)",fontSize:"0.85rem",cursor:"pointer"},children:"Skip"}),e.jsx("button",{onClick:()=>i?t():r(c=>c+1),className:"transition-opacity hover:opacity-90",style:{background:"linear-gradient(135deg, #7c3aed, #6366f1)",color:"#fff",border:"none",borderRadius:"0.5rem",padding:"0.55rem 1.5rem",fontSize:"0.9rem",fontWeight:600,cursor:"pointer"},children:i?"Get Started →":"Next →"})]})]}),e.jsx("style",{children:`
|
|
51
|
-
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
|
|
52
|
-
@keyframes slideUp { from { opacity: 0; transform: translateY(20px) } to { opacity: 1; transform: translateY(0) } }
|
|
53
|
-
`})]})}function Rr(t,s){if(t.size!==s.size)return!1;for(const[r,a]of t)if(s.get(r)!==a)return!1;return!0}function Pr(t,s){return t.length!==s.length?!1:t.every((r,a)=>r===s[a])}function xs(t,s){const r=Object.keys(t),a=Object.keys(s);return r.length!==a.length?!1:r.every(i=>s[i]===t[i])}function kt(t,s){const r=new Set(s),a=s.length>0?[0]:[];for(const[o,x]of t)!r.has(o)||x<=0||a.includes(x)||a.push(x);a.sort((o,x)=>o-x);const i={};a.forEach((o,x)=>{i[o]=x}),a.length===0&&(i[0]=0);const c=new Map;for(const[o,x]of t){if(!r.has(o)||x<=0)continue;const d=i[x];typeof d=="number"&&d>0&&c.set(o,d)}return{assignments:c,groupCount:Math.max(1,a.length),mapping:i,usedGroups:a}}function ms(t,s){const r={};for(const[a,i]of Object.entries(t)){const c=s[Number(a)];typeof c=="number"&&(r[c]=i)}return r}function Lr(t,s,r){if(s.length===0)return 0;if(typeof r[t]=="number")return r[t];const a=[...s].reverse().find(i=>i<t)??s[0];return r[a]??0}function Dr(t,s,r){if(s.length<=1)return[];const a=s.map(o=>t[o]).filter(o=>Number.isFinite(o)),i=a.length===s.length?a:Array(r).fill(100/r),c=i.reduce((o,x)=>o+x,0);return c>0?i.map(o=>o/c*100):Array(r).fill(100/r)}function Br(){const{sendCommand:t}=st(),[s,r]=bs(),a=s.get("activeTab"),i=$t(),{updateIdeChats:c,screenshotMap:o,setScreenshotMap:x}=i,d=i.ides||[],[p,u]=n.useState(()=>{try{return!localStorage.getItem("adhdev_onboarding_v1")}catch{return!1}}),l=i.toasts||[],g=i.setToasts||(()=>{}),h=i.wsStatus||"connected",m=i.isConnected??!0,A=i.connectionStates||{};i.retryConnection;const _=i.showReconnected||!1,[j,w]=n.useState(()=>{try{const k=localStorage.getItem("adhdev_splitGroups");if(k){const I=JSON.parse(k);return new Map(I)}}catch{}return new Map}),[O,B]=n.useState(()=>{try{const k=localStorage.getItem("adhdev_focusedGroup");if(k)return parseInt(k,10)||0}catch{}return 0}),[$,C]=n.useState(()=>{try{const k=localStorage.getItem("adhdev_groupActiveTabs");if(k)return JSON.parse(k)}catch{}return{}}),W=n.useRef(!1),[S,y]=n.useState(()=>{try{const k=localStorage.getItem("adhdev_groupTabOrders");if(k)return JSON.parse(k)}catch{}return{}}),[se,R]=n.useState(()=>{try{const k=localStorage.getItem("adhdev_splitSizes");if(k)return JSON.parse(k)}catch{}return[]});n.useEffect(()=>{try{j.size===0?localStorage.removeItem("adhdev_splitGroups"):localStorage.setItem("adhdev_splitGroups",JSON.stringify([...j.entries()]))}catch{}},[j]),n.useEffect(()=>{try{se.length>0?localStorage.setItem("adhdev_splitSizes",JSON.stringify(se)):localStorage.removeItem("adhdev_splitSizes")}catch{}},[se]),n.useEffect(()=>{try{localStorage.setItem("adhdev_focusedGroup",String(O))}catch{}},[O]),n.useEffect(()=>{try{localStorage.setItem("adhdev_groupActiveTabs",JSON.stringify($))}catch{}},[$]),n.useEffect(()=>{try{localStorage.setItem("adhdev_groupTabOrders",JSON.stringify(S))}catch{}},[S]);const[z,U]=n.useState(()=>typeof window<"u"&&window.innerWidth<768);n.useEffect(()=>{const k=window.matchMedia("(max-width: 767px)"),I=T=>U(T.matches);return k.addEventListener("change",I),()=>k.removeEventListener("change",I)},[]);const[v,ne]=n.useState({}),[pe,q]=n.useState(!1),[G,H]=n.useState([]),[oe,J]=n.useState({}),[ie,ce]=n.useState({}),[D,b]=n.useState({}),P=d.find(k=>k.type==="adhdev-daemon"),f=(P==null?void 0:P.detectedIdes)||[],K=!!P,Y=n.useMemo(()=>{const k=d.filter(T=>T.type!=="adhdev-daemon"),I=new Map;for(const T of k){const E=I.get(T.id);if(!E)I.set(T.id,T);else{const ae=(E.workspace?1:0)+(E.activeChat?1:0);((T.workspace?1:0)+(T.activeChat?1:0)>ae||(T.timestamp||0)>(E.timestamp||0))&&I.set(T.id,T)}}return Array.from(I.values())},[d]),te=n.useMemo(()=>{const k=Yn(Y,oe,d,A),I=Date.now();return k.map(T=>{const E=ie[T.tabKey];return E&&I-E<5e3?{...T,messages:[],title:""}:T})},[Y,oe,ie,d]),{hiddenTabs:Se,toggleTab:Ne}=Tr(),je=n.useMemo(()=>te.filter(k=>!Se.has(k.tabKey)),[te,Se]),me=n.useMemo(()=>je.map(k=>k.tabKey),[je]),de=n.useMemo(()=>kt(j,me),[j,me]),F=de.assignments,he=n.useMemo(()=>z?1:de.groupCount,[de.groupCount,z]),be=he>1,ye=n.useCallback((k,I)=>{const T={};for(const[E,ae]of Object.entries(k)){const le=Number(E);T[le>=I?le+1:le]=ae}return T},[]),Me=n.useCallback(k=>Array(k).fill(100/k),[]),Ue=n.useCallback((k,I)=>{w(T=>{const E=new Map(kt(T,me).assignments);return I===0?E.delete(k):E.set(k,I),E}),C(T=>({...T,[I]:k})),B(I)},[me]),Ke=n.useCallback(k=>{w(I=>{const T=kt(I,me).assignments,E=new Map;for(const[ae,le]of T)le!==k&&(le>k?E.set(ae,le-1):E.set(ae,le));return E}),R(I=>{if(I.length<=1)return[];const T=[...I];T.splice(k,1);const E=T.reduce((ae,le)=>ae+le,0);return E>0?T.map(ae=>ae/E*100):[]}),B(0)},[me]),Pe=n.useRef(null),dt=n.useCallback((k,I)=>{I.preventDefault();const T=Pe.current;if(!T)return;const E=I.clientX,ae=T.offsetWidth,le=se.length===he?[...se]:Array(he).fill(100/he),ve=De=>{const Ve=(De.clientX-E)/ae*100,ut=[...le];ut[k]=Math.max(15,le[k]+Ve),ut[k+1]=Math.max(15,le[k+1]-Ve),R(ut)},Te=()=>{document.removeEventListener("mousemove",ve),document.removeEventListener("mouseup",Te),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",ve),document.addEventListener("mouseup",Te)},[se,he]),Oe=n.useCallback((k,I,T)=>{const E=he;if(E>=4)return;const ae=T==="left"?I:I+1;w(le=>{const ve=kt(le,me).assignments,Te=new Map;for(const De of je){const Xe=ve.get(De.tabKey)??0,Ve=Xe>=ae?Xe+1:Xe;Ve>0&&Te.set(De.tabKey,Ve)}return ae>0&&Te.set(k,ae),Te}),R(le=>{const ve=le.length===E?[...le]:Me(E),Te=ve[I]??100/E,De=Math.max(15,Te/2),Xe=Math.max(15,Te/2),Ve=[...ve];Ve[I]=De,Ve.splice(ae,0,Xe);const ut=Ve.reduce((_t,Fs)=>_t+Fs,0);return Ve.map(_t=>_t/ut*100)}),C(le=>{const ve=ye(le,ae);return ve[ae]=k,ve}),y(le=>{const ve=ye(le,ae);return ve[ae]=[k],ve}),B(ae)},[he,je,me,Me,ye]);n.useEffect(()=>{er()},[]);const Ye=n.useMemo(()=>je.map(k=>({id:k.tabKey,name:k.title||k.agentName||k.ideId,status:k.status,activeModal:k.modalMessage?{message:k.modalMessage,buttons:k.modalButtons}:null})),[je]);sr(Ye),n.useEffect(()=>{Rr(j,F)||w(F)},[j,F]),n.useEffect(()=>{const{mapping:k,usedGroups:I}=de;C(T=>{const E=ms(T,k);return xs(T,E)?T:E}),y(T=>{const E=ms(T,k);return xs(T,E)?T:E}),B(T=>{const E=z?0:Lr(T,I,k);return T===E?T:E}),R(T=>{const E=z?[]:Dr(T,I,de.groupCount);return Pr(T,E)?T:E})},[de,z]);const Ae=n.useMemo(()=>{const k=Array.from({length:he},()=>[]);for(const I of je){const T=F.get(I.tabKey)??0,E=Math.min(T,he-1);k[E].push(I)}return k},[je,F,he]);n.useEffect(()=>{if(!a||W.current||te.length===0)return;const k=te.find(I=>I.tabKey===a)||te.find(I=>I.ideId===a)||te.find(I=>I.ideType===a||I.agentType===a);if(k){const I=F.get(k.tabKey)??0;C(T=>({...T,[I]:k.tabKey})),B(I),W.current=!0,r(T=>{const E=new URLSearchParams(T);return E.delete("activeTab"),E},{replace:!0})}},[a,te,F]),n.useEffect(()=>{if(Object.keys(ie).length===0)return;const I=setTimeout(()=>{ce(T=>{const E=Date.now(),ae={};for(const[le,ve]of Object.entries(T))E-ve<5e3&&(ae[le]=ve);return Object.keys(ae).length===Object.keys(T).length?T:ae})},5500);return()=>clearTimeout(I)},[ie]);const M=n.useMemo(()=>{var I,T;const k=$[O];if(k){const E=te.find(ae=>ae.tabKey===k);if(E)return E}return((I=Ae[O])==null?void 0:I[0])||((T=Ae[0])==null?void 0:T[0])},[$,O,te,Ae]),re=n.useMemo(()=>!M||!We(M)||Re(M)?null:D[M.tabKey]??M.mode??"terminal",[M,D]),Q=n.useCallback((k,I)=>{},[]);n.useEffect(()=>{const k=new Set(te.map(I=>I.tabKey));b(I=>{const T=Object.fromEntries(Object.entries(I).filter(([E])=>k.has(E)));return Object.keys(T).length===Object.keys(I).length?I:T})},[te]),n.useEffect(()=>{var E;const k=Date.now();let I=!1;const T={...v};for(const ae of te)(E=ae.messages)!=null&&E.length&&ae.messages.forEach((le,ve)=>{const Te=`${ae.ideId}-${le.id??`i-${ve}`}`;T[Te]==null&&(T[Te]=k,I=!0)});I&&ne(T)},[te]);const ge=n.useRef(!1);n.useEffect(()=>{if(!pe){ge.current=!1;return}if(!M||ge.current||Z)return;const k=d.find(I=>I.id===M.ideId);k&&(!k.chats||k.chats.length===0)&&(ge.current=!0,ee())},[pe,M==null?void 0:M.ideId]),n.useEffect(()=>{const k=setInterval(()=>{const I=Date.now()-3e5;H(T=>{const E=T.filter(ae=>ae.timestamp>I).slice(-100);return E.length===T.length?T:E})},6e4);return()=>clearInterval(k)},[]);const we=n.useRef(new Map);n.useEffect(()=>{const k=(T,E)=>{var ae;if(E){Ts.emit(T,E);for(const le of te){if(!We(le))continue;const ve=(ae=le.ideId)!=null&&ae.includes(":cli:")?le.ideId.split(":cli:")[1]:"";if(T===ve||T===le.agentType||T===le.ideType||T===le.ideId||T===le.tabKey){const De=we.current.get(le.tabKey)||[];De.push(E),De.length>1e4&&De.splice(0,De.length-5e3),we.current.set(le.tabKey,De)}}}},I=Kt.onPtyOutput(k);return()=>{I()}},[te]),n.useEffect(()=>{const k=I=>{if(I.ctrlKey&&I.key==="\\"){if(I.preventDefault(),be)w(new Map),B(0);else{const T=te[1];T&&Oe(T.tabKey,0,"right")}return}I.ctrlKey&&(I.key==="["||I.key==="]")&&be&&(I.preventDefault(),B(T=>I.key==="]"?Math.min(T+1,he-1):Math.max(T-1,0)))};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[be,te,Oe,he]),n.useEffect(()=>{it.setIdes(d)},[d]),n.useEffect(()=>{it.setResolveAction((k,I,T)=>{t(k,I,T).catch(()=>{})})},[t]),n.useEffect(()=>{const k=it.onToast(E=>{g(le=>le.some(Te=>Te.message===E.message&&E.timestamp-Te.timestamp<3e3)?le:[...le.slice(-4),{id:E.id,message:E.message,type:E.type,timestamp:E.timestamp,ideId:E.ideId,actions:E.actions}]);const ae=E.duration||5e3;setTimeout(()=>g(le=>le.filter(ve=>ve.id!==E.id)),ae)}),I=it.onSystemMessage((E,ae)=>{J(le=>{for(const ve of Object.keys(le))if(ve.includes(E))return{...le,[ve]:[...le[ve]||[],ae]};return le})}),T=it.onClearSystemMessage((E,ae)=>{J(le=>{const ve={...le};for(const Te of Object.keys(ve))Te.includes(E)&&(ve[Te]=(ve[Te]||[]).filter(De=>{var Xe;return!(De.role==="system"&&((Xe=De._localId)!=null&&Xe.startsWith(ae)))}));return ve})});return()=>{k(),I(),T()}},[]),n.useEffect(()=>{const k=As.on("status_event",I=>it.handleRawEvent(I,"ws"));return()=>{k()}},[]),n.useEffect(()=>{var I;const k=T=>{const E=T.data;(E==null?void 0:E.type)==="notification_action"&&E.action==="approve"&&E.ideId&&t(E.ideId,"resolve_action",{action:"approve",button:"Approve"}).catch(ae=>console.error("[SW Action] approve failed:",ae))};return(I=navigator.serviceWorker)==null||I.addEventListener("message",k),()=>{var T;return(T=navigator.serviceWorker)==null?void 0:T.removeEventListener("message",k)}},[]);const{isCreatingChat:N,isRefreshingHistory:Z,handleLaunchIde:L,handleSwitchSession:xe,handleNewChat:V,handleRefreshHistory:ee}=Ks({sendDaemonCommand:t,activeConv:M,ides:d,updateIdeChats:c,setToasts:g,setLocalUserMessages:J,setClearedTabs:ce,setActionLogs:H,pinTab:Q,isStandalone:K}),ue=n.useCallback(k=>{!M||!We(M)||Re(M)||b(I=>({...I,[M.tabKey]:k}))},[M]),X=n.useCallback(async()=>{var T;if(!M||!We(M)||Re(M))return;const k=(T=M.ideId)!=null&&T.includes(":cli:")?M.ideId.split(":cli:")[1]:M.ideType||M.agentType||"";if(!window.confirm(`Stop ${k}?
|
|
54
|
-
This will terminate the CLI process.`))return;const I=M.ideId||M.daemonId||"";try{await t(I,"stop_cli",{cliType:k})}catch(E){console.error("Stop CLI failed:",E)}},[M,t]),fe=n.useMemo(()=>d.filter(k=>k.type==="adhdev-daemon"&&k.versionMismatch),[d]),[Ce,Ie]=n.useState(!1),[$e,Be]=n.useState({}),_e=n.useCallback(async k=>{var I,T;Be(E=>({...E,[k]:"upgrading"}));try{const E=await t(k,"daemon_upgrade",{});(I=E==null?void 0:E.result)!=null&&I.upgraded||(T=E==null?void 0:E.result)!=null&&T.success?Be(ae=>({...ae,[k]:"done"})):Be(ae=>({...ae,[k]:"error"}))}catch{Be(E=>({...E,[k]:"error"}))}},[t]);return e.jsxs("div",{className:"page-dashboard flex-1 min-h-0 bg-bg-primary text-text-primary flex flex-col overflow-hidden",children:[e.jsx(Pn,{wsStatus:h,showReconnected:_}),fe.length>0&&!Ce&&e.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-2 bg-amber-500/[0.08] border-b border-amber-500/20 text-xs text-text-secondary shrink-0 flex-wrap",children:[e.jsx("span",{className:"text-sm shrink-0 mt-0.5",children:e.jsx(ks,{size:14,className:"text-amber-500"})}),e.jsxs("span",{className:"flex-1 flex items-center gap-2 flex-wrap min-w-0",children:[e.jsxs("span",{children:["Update available: ",e.jsxs("strong",{children:["v",fe[0].version]})," → ",e.jsxs("strong",{children:["v",fe[0].serverVersion]})]}),fe.map(k=>{var E;const I=k.machineNickname||((E=k.machine)==null?void 0:E.hostname)||k.hostname||"Machine",T=$e[k.id];return e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-md bg-amber-500/[0.08] border border-amber-500/15",children:[e.jsx("span",{className:"font-medium text-text-primary",children:I}),e.jsxs("span",{className:"text-[10px] text-text-muted",children:["v",k.version]}),T==="upgrading"?e.jsx("span",{className:"text-[10px] text-amber-400 animate-pulse",children:"upgrading…"}):T==="done"?e.jsx("span",{className:"text-[10px] text-green-400",children:"✓ restarting"}):T==="error"?e.jsx("button",{className:"text-[10px] text-red-400 hover:text-red-300 underline cursor-pointer",onClick:()=>_e(k.id),children:"retry"}):e.jsx("button",{className:"text-[10px] font-semibold text-amber-400 hover:text-amber-300 cursor-pointer px-1.5 py-px rounded bg-amber-500/10 border border-amber-500/20 transition-colors",onClick:()=>_e(k.id),children:"Upgrade"})]},k.id)})]}),e.jsx("button",{className:"text-text-muted hover:text-text-primary transition-colors text-sm px-1 shrink-0",onClick:()=>Ie(!0),title:"Dismiss",children:"✕"})]}),e.jsx(Wn,{activeConv:M,agentCount:Y.length,wsStatus:h,isConnected:m,onOpenHistory:()=>q(!0),cliViewMode:re,onSetCliViewMode:ue,onStopCli:X}),e.jsx("div",{ref:Pe,className:`flex-1 min-h-0 flex ${be?"flex-row":"flex-col"} overflow-hidden`,children:Ae.map((k,I)=>{const T=be&&se.length===he?`${se[I]}%`:void 0;return e.jsxs(Gs.Fragment,{children:[be&&I>0&&e.jsx("div",{className:"shrink-0 w-1 cursor-col-resize hover:bg-accent/30 transition-colors relative group",style:{background:"var(--border-subtle)"},onMouseDown:E=>dt(I-1,E),onDoubleClick:()=>Ke(I),title:"Drag to resize · Double-click to merge",children:e.jsx("div",{className:"absolute inset-y-0 -left-1 -right-1 group-hover:bg-accent/10"})}),e.jsx($r,{style:be?{flexBasis:T??`${100/he}%`,flexGrow:T?0:1,flexShrink:T?0:1}:void 0,conversations:k,ides:d,messageReceivedAt:v,actionLogs:G,ptyBuffers:we,screenshotMap:o,setScreenshotMap:x,sendDaemonCommand:t,updateIdeChats:c,setToasts:g,setLocalUserMessages:J,setClearedTabs:ce,setActionLogs:H,pinTab:Q,isStandalone:K,userName:i.userName,groupIndex:I,isFocused:O===I,onFocus:()=>B(I),isSplitMode:be,numGroups:he,onMoveTab:(E,ae)=>{ae==="left"&&I>0?Ue(E,I-1):ae==="right"&&I<he-1?Ue(E,I+1):ae==="split-left"&&he<4?Oe(E,I,"left"):ae==="split-right"&&he<4&&Oe(E,I,"right")},onClose:be?()=>Ke(I):void 0,onReceiveTab:E=>Ue(E,I),detectedIdes:I===0?f:void 0,handleLaunchIde:I===0?L:void 0,onActiveTabChange:E=>C(ae=>({...ae,[I]:E})),initialActiveTabId:$[I],initialTabOrder:S[I],onTabOrderChange:E=>y(ae=>({...ae,[I]:E})),onHideTab:Ne,cliViewModes:D})]},I)})}),pe&&M&&e.jsx(Fn,{activeConv:M,ides:d,isCreatingChat:N,isRefreshingHistory:Z,onClose:()=>q(!1),onNewChat:V,onSwitchSession:xe,onRefreshHistory:ee}),e.jsx("style",{children:`
|
|
55
|
-
body { overflow: hidden; overscroll-behavior: none; }
|
|
56
|
-
.pulse-amber { animation: pulse-amber 2s infinite ease-in-out; }
|
|
57
|
-
@keyframes pulse-amber {
|
|
58
|
-
0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); }
|
|
59
|
-
70% { transform: scale(1.1); box-shadow: 0 0 0 10px rgba(245, 158, 11, 0); }
|
|
60
|
-
100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
|
|
61
|
-
}
|
|
62
|
-
`}),e.jsx(Hn,{toasts:l,onDismiss:k=>g(I=>I.filter(T=>T.id!==k)),onClickToast:k=>{if(k.ideId){const I=te.find(T=>T.ideId===k.ideId||T.tabKey===k.ideId);I&&B(F.get(I.tabKey)??0)}}}),e.jsx("style",{children:`
|
|
63
|
-
@keyframes toast -in {
|
|
64
|
-
from { opacity: 0; transform: translateX(40px); }
|
|
65
|
-
to { opacity: 1; transform: translateX(0); }
|
|
66
|
-
}
|
|
67
|
-
`}),p&&e.jsx(_r,{onClose:()=>{try{localStorage.setItem("adhdev_onboarding_v1","done")}catch{}u(!1)}})]})}function Wr(t){return t.split(":")[0]||""}function Or({renderHeaderActions:t}={}){var Ne,je,me,de;const{id:s}=ys(),r=vt(),a=$t(),i=a.ides||[],c=a.connectionStates||{},{sendCommand:o}=st(),x=n.useMemo(()=>Wr(s||""),[s]),d=n.useMemo(()=>i.find(F=>F.id===s),[i,s]),p=(d==null?void 0:d.type)||void 0,u=p?p.charAt(0).toUpperCase()+p.slice(1):"IDE",l=(d==null?void 0:d.activeChat)||null,g=(d==null?void 0:d.agentStreams)||[],h=a.isConnected??!0,m=c[x]||(h?"connected":"new"),A=((Ne=a.connectionTransports)==null?void 0:Ne[x])||"unknown",_=n.useMemo(()=>i.find(F=>F.id===x||F.daemonId===x),[i,x]),j=(_==null?void 0:_.machineNickname)||((je=_==null?void 0:_.machine)==null?void 0:je.hostname)||"",w=(d==null?void 0:d.workspace)||"",[O]=bs(),B=typeof window<"u"&&window.innerWidth<=768,$=O.get("view")||(B?"chat":"split"),[C,W]=n.useState($),[S,y]=n.useState("native"),[se,R]=n.useState(""),[z,U]=n.useState(!1),[v,ne]=n.useState(null),[pe,q]=n.useState(null),[G,H]=n.useState([]),oe=l==null?void 0:l.status,J=(((de=(me=l==null?void 0:l.activeModal)==null?void 0:me.buttons)==null?void 0:de.length)??0)>0,ie=oe==="generating"||oe==="loading"||oe&&oe.toLowerCase()==="thinking",D=J||oe==="waiting_approval"?"waiting_approval":ie?"working":oe||"idle",b=n.useMemo(()=>{var F,he;return{ideId:s||"",daemonId:x,agentName:Ft(p||""),agentType:p||"",status:D,title:(l==null?void 0:l.title)||"",messages:(l==null?void 0:l.messages)||[],ideType:p||"",workspaceName:(d==null?void 0:d.workspaceName)||"",displayPrimary:u,displaySecondary:(d==null?void 0:d.workspaceName)||"",cdpConnected:!0,modalButtons:(F=l==null?void 0:l.activeModal)==null?void 0:F.buttons,modalMessage:(he=l==null?void 0:l.activeModal)==null?void 0:he.message,streamSource:"native",tabKey:`ide-${s}`}},[s,x,p,l,d,u,D]),P=n.useMemo(()=>g.map(F=>{var be,ye;const he=F.activeModal?"waiting_approval":F.status==="streaming"?"working":F.status||"idle";return{ideId:s||"",daemonId:x,agentName:F.agentName,agentType:F.agentType,status:he,title:"",messages:F.messages.map((Me,Ue)=>({role:Me.role,content:Me.content,kind:Me.kind,id:`${F.agentType}-${Ue}`,receivedAt:Me.timestamp})),ideType:F.agentType,workspaceName:"",displayPrimary:F.agentName,displaySecondary:"",cdpConnected:!0,modalButtons:(be=F.activeModal)==null?void 0:be.buttons,modalMessage:(ye=F.activeModal)==null?void 0:ye.message,streamSource:"agent-stream",tabKey:`agent-stream-${F.agentType}`}}),[g,s,x]),f=n.useMemo(()=>S==="native"?b:P.find(F=>F.agentType===S)||b,[S,b,P]);n.useEffect(()=>x?et.onScreenshot("ide-page",(he,be)=>{if(he!==x)return;const ye=new FileReader;ye.onload=()=>ne(ye.result),ye.readAsDataURL(be)}):void 0,[x]),n.useEffect(()=>{m!=="connected"&&ne(null)},[m]),n.useEffect(()=>{var he;return x?((he=et.onStatus)==null?void 0:he.call(et,(be,ye)=>{be===x&&ye!=null&&ye.screenshotUsage&&q(ye.screenshotUsage)}))||(()=>{}):void 0},[x]);const K=n.useMemo(()=>{if(!s)return p;const F=s.split(":");return F.length>=3&&F[1]==="ide"?F.slice(2).join(":"):p},[s,p]);n.useEffect(()=>{ne(null)},[x,s,K]),n.useEffect(()=>{const F=x?et.get(x):null;!F||!(m==="connected")||(C!=="chat"&&K?F.startScreenshots(K):F.stopScreenshots(K))},[C,m,K,x]);const Y=n.useCallback(async(F,he={})=>{if(!s)throw new Error("No IDE ID");return await o(s,F,he)},[s]),te=async()=>{const F=se.trim();if(!(!F||!s||z)){R(""),U(!0);try{await Y("send_chat",{message:F,text:F,waitForResponse:!0,...S!=="native"&&{agentType:S}})}catch(he){console.error("[IDE] Send failed:",he)}finally{U(!1)}}},Se=g.length>0;return s?e.jsxs("div",{className:"ide-page",children:[e.jsxs("header",{className:"ide-header",children:[e.jsxs("div",{className:"ide-header-left",children:[e.jsxs("div",{className:"ide-title",children:[e.jsx(Et,{size:16}),e.jsx("span",{className:"ide-name",children:u}),e.jsx("span",{className:"ide-name-mobile",children:"IDE"}),w&&e.jsx("span",{className:"ide-workspace",children:w}),e.jsx("span",{className:"ide-badge",children:"REMOTE"})]}),e.jsxs("div",{className:"ide-status-pill",children:[e.jsx("span",{className:`ide-dot ${m==="connected"?"online":"connecting"}`}),e.jsx("span",{className:"ide-status-text",children:m==="connected"?"Connected":m==="connecting"?"Connecting":"WS"})]}),j&&e.jsx("span",{className:"ide-machine-label",children:j})]}),e.jsxs("div",{className:"ide-header-right",children:[["chat","split","remote"].map(F=>e.jsx("button",{className:"btn btn-secondary btn-sm",style:{border:C===F?"1px solid var(--accent-primary)":"none",background:C===F?"rgba(99,102,241,0.12)":"var(--bg-secondary)",padding:"6px 10px",color:C===F?"var(--accent-primary)":void 0},onClick:()=>W(F),children:F==="chat"?e.jsx(Et,{size:14}):F==="split"?"⊞":e.jsx(ot,{size:14})},F)),t&&t({daemonId:x,ideInstanceId:s||""}),e.jsxs("button",{className:"btn btn-primary btn-sm flex items-center justify-center shrink-0",onClick:()=>r(-1),children:["←",e.jsx("span",{className:"hidden md:inline ml-1",children:"Back"})]})]})]}),e.jsxs("div",{className:"ide-content",children:[e.jsxs("div",{className:`ide-chat-panel ${C==="chat"?"full":""} ${C==="remote"?"hidden":""}`,children:[Se&&e.jsxs("div",{className:"ide-chat-tabs",children:[e.jsx("button",{className:`ide-chat-tab ${S==="native"?"active":""}`,onClick:()=>y("native"),children:u}),g.map(F=>{const he=S===F.agentType,be=F.status==="waiting_approval"||!!F.activeModal,ye=F.status==="streaming";return e.jsxs("button",{className:`ide-chat-tab ${he?"active":""}`,onClick:()=>y(F.agentType),children:[e.jsx("span",{style:{display:"inline-block",width:6,height:6,borderRadius:"50%",marginRight:5,background:be?"#f59e0b":ye?"var(--accent-primary)":"#64748b",boxShadow:ye?"0 0 6px var(--accent-primary)":"none"}}),F.agentName,be&&e.jsx("span",{className:"ide-ext-badge",style:{background:"#f59e0b22",color:"#f59e0b",marginLeft:4},children:"!"})]},F.agentType)})]}),e.jsx(Ms,{activeConv:f,ides:i,agentInput:se,setAgentInput:R,handleSendChat:te,handleFocusAgent:()=>{},isFocusingAgent:!1,messageReceivedAt:{},actionLogs:[],userName:a.userName})]}),e.jsx("div",{className:`ide-remote-panel ${C==="remote"?"full":""} ${C==="chat"?"hidden":""}`,children:e.jsx(En,{addLog:()=>{},connState:m,connScreenshot:v,screenshotUsage:pe,transportType:A,onAction:async(F,he)=>{const be=x?et.get(x):null;if(!be||m!=="connected")return console.warn("[RemoteInput] P2P not connected"),{success:!1,error:"P2P not connected"};const ye=(d==null?void 0:d.instanceId)||K;return await be.sendInput(F,he,ye)}})})]}),G.length>0&&e.jsx("div",{className:"ide-toasts",children:G.map(F=>e.jsx("div",{className:`ide-toast ${F.type}`,onClick:()=>H(he=>he.filter(be=>be.id!==F.id)),children:F.message},F.id))})]}):e.jsx("div",{className:"ide-empty",children:"No IDE selected"})}function Kr({machineId:t,sendDaemonCommand:s,logsEndRef:r}){const[a,i]=n.useState([]),[c,o]=n.useState(null),[x,d]=n.useState(!1),[p,u]=n.useState(!1),[l,g]=n.useState(!1),[h,m]=n.useState([]),[A,_]=n.useState([]),[j,w]=n.useState(null),[O,B]=n.useState(!1),[$,C]=n.useState(""),W=n.useRef(null),S=n.useCallback(D=>{W.current=D},[]),y=n.useCallback((D,b)=>{i(P=>[...P.slice(-100),{timestamp:Date.now(),level:D,message:b}]),setTimeout(()=>{var P;return(P=r.current)==null?void 0:P.scrollIntoView({behavior:"smooth"})},100)},[r]),se=n.useCallback(async(D,b)=>{var P;if(!(!t||c)){o(D),y("info",`Launching ${He(D)}${b!=null&&b.workspace?` in ${b.workspace}`:""}...`);try{const f={ideType:D,enableCdp:!0};(P=b==null?void 0:b.workspace)!=null&&P.trim()?f.workspace=b.workspace.trim():b!=null&&b.useDefaultWorkspace&&(f.useDefaultWorkspace=!0);const K=await s(t,"launch_ide",f);y(K!=null&&K.success?"info":"error",K!=null&&K.success?`${He(D)} launched`:`Failed: ${K==null?void 0:K.error}`)}catch(f){y("error",`Launch error: ${f.message}`)}finally{o(null)}}},[t,c,y,s]),R=n.useCallback(async D=>{if(!t)return;const{cliType:b,dir:P,workspaceId:f,useDefaultWorkspace:K,useHome:Y,argsStr:te,model:Se}=D;if(!b){y("warn","Select a CLI or ACP provider first");return}const Ne=te?te.split(/\s+/).filter(Boolean):void 0,je=(P==null?void 0:P.trim())||(f?"(saved id)":K?"(default workspace)":Y?"(home)":"");y("info",`Launching ${b}${je?` in ${je}`:""}${Se?` (model: ${Se})`:""}...`);try{const me={cliType:b,cliArgs:Ne,initialModel:Se||void 0};P!=null&&P.trim()?me.dir=P.trim():f?me.workspaceId=f:K?me.useDefaultWorkspace=!0:Y&&(me.useHome=!0);const de=await s(t,"launch_cli",me),F=(de==null?void 0:de.result)||de;de!=null&&de.success?(y("info",`${b} launched`),(F==null?void 0:F.launchSource)==="home"?y("info","📂 Running in home directory (explicit choice)"):(F==null?void 0:F.launchSource)==="defaultWorkspace"&&y("info","📂 Using default workspace (explicit choice)")):(y("error",`Failed: ${(de==null?void 0:de.error)||(F==null?void 0:F.error)}`),(de==null?void 0:de.code)==="WORKSPACE_LAUNCH_CONTEXT_REQUIRED"&&w({cliType:b,argsStr:te,model:Se}))}catch(me){y("error",`Launch error: ${me.message}`)}},[t,y,s]),z=n.useCallback((D,b,P,f)=>{if(t){if(!D){y("warn","Select a provider");return}if(!b.trim()){w({cliType:D,argsStr:P,model:f});return}R({cliType:D,dir:b,argsStr:P,model:f})}},[t,y,R]),U=n.useCallback(async(D,b,P)=>{if(t&&window.confirm(`Stop ${D}?
|
|
68
|
-
This will terminate the process.`))try{const f=await s(t,"stop_cli",{cliType:D,dir:b,_targetInstance:P});f!=null&&f.success?y("info",`${D} stopped`):y("error",`Stop failed: ${(f==null?void 0:f.error)||"Unknown error"}`)}catch(f){y("error",`Stop failed: ${f.message}`)}},[t,y,s]),v=n.useCallback(async D=>{try{await s(D.daemonId,"restart_ide",{ideType:D.type}),y("info",`${He(D.type)} restart initiated`)}catch(b){y("error",`Restart failed: ${b.message}`)}},[y,s]),ne=n.useCallback(async D=>{if(window.confirm(`Stop ${He(D.type)}?
|
|
69
|
-
This will disconnect CDP and optionally kill the process.`))try{const b=await s(D.daemonId,"stop_ide",{ideType:D.type,killProcess:!0});b!=null&&b.success?y("info",`${He(D.type)} stopped`):y("error",`Stop failed: ${(b==null?void 0:b.error)||"Unknown error"}`)}catch(b){y("error",`Stop failed: ${b.message}`)}},[y,s]),pe=n.useCallback(async()=>{if(t)try{const D=await s(t,"detect_ides",{});y("info",`Found ${((D==null?void 0:D.result)||[]).length} IDE(s)`)}catch(D){y("error",`Detection failed: ${D.message}`)}},[t,y,s]),q=n.useCallback(async()=>{if(t){d(!0);try{const D=await s(t,"get_recent_workspaces",{});D!=null&&D.success&&Array.isArray(D==null?void 0:D.result)&&_(D.result)}catch(D){y("error",`Failed: ${D.message}`)}finally{d(!1)}}},[t,y,s]),G=n.useCallback(async D=>{if(!(!t||!D.trim())){u(!0);try{const b=await s(t,"workspace_add",{path:D.trim()});b!=null&&b.success?y("info",`Workspace added: ${D.trim()}`):y("error",(b==null?void 0:b.error)||"workspace_add failed")}catch(b){y("error",b.message)}finally{u(!1)}return!0}},[t,y,s]),H=n.useCallback(async D=>{if(!(!t||!window.confirm("Remove this workspace from the list?"))){u(!0);try{const b=await s(t,"workspace_remove",{id:D});b!=null&&b.success?y("info","Workspace removed"):y("error",(b==null?void 0:b.error)||"workspace_remove failed")}catch(b){y("error",b.message)}finally{u(!1)}}},[t,y,s]),oe=n.useCallback(async D=>{var b;if(t){u(!0);try{const P=await s(t,"workspace_set_default",D===null?{clear:!0}:{id:D});if(P!=null&&P.success){y("info",D?"Default workspace updated":"Default workspace cleared");const f=typeof P.defaultWorkspacePath=="string"?P.defaultWorkspacePath:"";f&&((b=W.current)==null||b.call(W,f))}else y("error",(P==null?void 0:P.error)||"workspace_set_default failed")}catch(P){y("error",P.message)}finally{u(!1)}}},[t,y,s]),J=n.useCallback(async D=>{var P;if(!t||!D.trim())return;const b=D.trim();u(!0);try{const f=await s(t,"workspace_set_default",{path:b});f!=null&&f.success?(y("info","Default workspace set from history"),(P=W.current)==null||P.call(W,b)):y("error",(f==null?void 0:f.error)||"Could not set default (path missing on disk?)")}catch(f){y("error",f.message)}finally{u(!1)}},[t,y,s]),ie=n.useCallback(async()=>{var D;if(t){g(!0);try{const b=await s(t,"get_cli_history",{}),P=(b==null?void 0:b.history)??((D=b==null?void 0:b.result)==null?void 0:D.history);b!=null&&b.success&&Array.isArray(P)&&m(P)}catch{}g(!1)}},[t,s]),ce=n.useCallback(async()=>{if(t)try{await s(t,"set_machine_nickname",{nickname:$}),y("info",`Nickname set to "${$||"(cleared)"}"`),B(!1)}catch(D){y("error",`Failed: ${D.message}`)}},[t,$,y,s]);return{logs:a,launchingIde:c,loadingWorkspaces:x,workspaceBusy:p,loadingHistory:l,cliHistory:h,recentWorkspaces:A,launchPick:j,setLaunchPick:w,editingNickname:O,setEditingNickname:B,nicknameInput:$,setNicknameInput:C,addLog:y,handleLaunchIde:se,runLaunchCliCore:R,handleLaunchCli:z,handleStopCli:U,handleRestartIde:v,handleStopIde:ne,handleDetectIdes:pe,handleLoadRecentWorkspaces:q,handleWorkspaceAdd:G,handleWorkspaceRemove:H,handleWorkspaceSetDefault:oe,handleWorkspaceResumePath:J,loadCliHistory:ie,handleSaveNickname:ce,setOnDefaultWorkspaceChanged:S}}function Fr({machine:t,managedIdes:s,managedClis:r,managedAcps:a,actions:i}){const{workspaceBusy:c,handleWorkspaceAdd:o,handleWorkspaceRemove:x,handleWorkspaceSetDefault:d}=i,[p,u]=n.useState(""),l=t.availableMem??t.freeMem,g=t.totalMem>0?Math.min(100,Math.max(0,Math.round((t.totalMem-l)/t.totalMem*100))):0,h=t.loadavg[0]||0;return e.jsxs("div",{children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2.5 mb-5",children:[e.jsx(wt,{icon:e.jsx(Ss,{size:16}),label:"Uptime",value:On(t.uptime)}),e.jsx(wt,{icon:e.jsx(ot,{size:16}),label:"IDEs",value:`${s.length}`}),e.jsx(wt,{icon:e.jsx(qt,{size:16}),label:"CLIs",value:`${r.length}`}),e.jsx(wt,{icon:e.jsx(Cs,{size:16}),label:"ACPs",value:`${a.length}`})]}),e.jsxs("div",{className:"px-5 py-4 rounded-xl mb-5 bg-bg-secondary border border-border-subtle",children:[e.jsx("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-3",children:"Resource Usage"}),e.jsxs("div",{className:"flex gap-6",children:[e.jsx(ts,{value:Math.min(Math.round(h/t.cpus*100),100),max:100,label:"CPU Load",color:"#8b5cf6",detail:`${h.toFixed(2)} avg / ${t.cpus} cores`}),e.jsx(ts,{value:g,max:100,label:"Memory",color:"#3b82f6",detail:`${ss(t.totalMem-l)} / ${ss(t.totalMem)}${t.platform==="darwin"?" (approx.)":""}`})]})]}),e.jsxs("div",{className:"px-5 py-4 rounded-xl mb-5 bg-bg-secondary border border-border-subtle",children:[e.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider flex items-center gap-1.5 mb-3",children:[e.jsx(Ot,{size:14})," Workspaces"]}),e.jsxs("div",{className:"flex flex-wrap gap-2 items-center mb-3",children:[e.jsx("span",{className:"text-[10px] text-text-muted",children:"Default:"}),e.jsxs("select",{className:"text-xs bg-bg-primary border border-border-subtle rounded-lg px-2 py-1 max-w-[min(100%,420px)]",disabled:c,value:t.defaultWorkspaceId||"",onChange:m=>void d(m.target.value===""?null:m.target.value),children:[e.jsx("option",{value:"",children:"(none)"}),(t.workspaces||[]).map(m=>e.jsx("option",{value:m.id,children:m.label||m.path},m.id))]}),t.defaultWorkspacePath&&e.jsx("span",{className:"text-[10px] text-text-muted font-mono truncate max-w-[min(100%,360px)]",title:t.defaultWorkspacePath,children:t.defaultWorkspacePath})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 items-end",children:[e.jsx("input",{className:"flex-1 min-w-[200px] text-xs bg-bg-primary border border-border-subtle rounded-lg px-2.5 py-1.5",placeholder:"Add workspace path…",value:p,disabled:c,onChange:m=>u(m.target.value),onKeyDown:m=>m.key==="Enter"&&void(async()=>{await o(p)&&u("")})()}),e.jsx("button",{type:"button",className:"machine-btn text-xs px-3 py-1.5",disabled:c,onClick:async()=>{await o(p)&&u("")},children:"Add"})]}),(t.workspaces||[]).length>0&&e.jsx("ul",{className:"mt-3 space-y-1 max-h-32 overflow-y-auto",children:(t.workspaces||[]).map(m=>e.jsxs("li",{className:"flex items-center gap-2 text-[11px] text-text-muted",children:[m.id===t.defaultWorkspaceId&&e.jsx("span",{className:"text-[10px]",children:"⭐"}),e.jsx("span",{className:"font-mono truncate flex-1",title:m.path,children:m.path}),e.jsx("button",{type:"button",className:"text-[10px] text-red-400/90 hover:underline",disabled:c,onClick:()=>void x(m.id),children:"Remove"})]},m.id))})]})]})}const Hr={ide:{label:"IDE",plural:"IDEs",accent:"border-blue-500/[0.12]"},cli:{label:"CLI",plural:"CLIs",accent:"border-violet-500/[0.12]"},acp:{label:"ACP Agent",plural:"ACP agents",accent:"border-emerald-500/[0.12]"}};function Wt({category:t,machine:s,machineId:r,providers:a,managedEntries:i,getIcon:c,actions:o,sendDaemonCommand:x}){const d=vt(),{handleLaunchIde:p,handleLaunchCli:u,handleStopCli:l,handleRestartIde:g,handleStopIde:h,handleDetectIdes:m,cliHistory:A,loadingHistory:_,loadCliHistory:j,launchingIde:w}=o,O=Hr[t],B=t==="ide",$=t==="acp",C=a.filter(f=>f.category===t),[W,S]=n.useState(""),[y,se]=n.useState(""),[R,z]=n.useState(""),[U,v]=n.useState(s.defaultWorkspaceId||""),[ne,pe]=n.useState("");n.useEffect(()=>{!W&&C.length>0&&S(C[0].type)},[W,C.length]),n.useEffect(()=>{s.defaultWorkspaceId&&!U&&v(s.defaultWorkspaceId)},[s.defaultWorkspaceId]);const q=(()=>{if(U==="__custom__")return ne.trim();if(!U)return"";const f=(s.workspaces||[]).find(K=>K.id===U);return(f==null?void 0:f.path)||""})(),[G,H]=n.useState({}),[oe,J]=n.useState(null);n.useEffect(()=>{if(!B||!r||!x)return;(async()=>{try{const K=await x(r,"get_ide_extensions",{}),Y=(K==null?void 0:K.result)||K;Y!=null&&Y.success&&(Y!=null&&Y.ides)&&H(Y.ides)}catch{}})()},[B,r,x]);const ie=f=>B?He(f.type):t==="cli"?f.cliName:f.acpName,ce=B?s.detectedIdes||[]:[],D=()=>{B?p(W,q?{workspace:q}:void 0):u(W,q,y||void 0,$&&R||void 0)},b=f=>{B?h(f):l(f.type,f.workspace,f.id)},P=e.jsxs("div",{className:"flex gap-2 items-center flex-wrap mb-3",children:[e.jsx("select",{value:U,onChange:f=>{v(f.target.value),f.target.value!=="__custom__"&&pe("")},className:"machine-input min-w-[200px] flex-1",children:(s.workspaces||[]).length>0?e.jsxs(e.Fragment,{children:[e.jsx("option",{value:"",children:"(no workspace — launch in home)"}),(s.workspaces||[]).map(f=>e.jsxs("option",{value:f.id,children:[f.id===s.defaultWorkspaceId?"⭐ ":"",f.label||f.path.split("/").filter(Boolean).pop()||f.path," — ",f.path]},f.id)),e.jsx("option",{value:"__custom__",children:"✏️ Custom path…"})]}):e.jsxs(e.Fragment,{children:[e.jsx("option",{value:"",children:"(no workspaces saved — add in Overview tab)"}),e.jsx("option",{value:"__custom__",children:"✏️ Custom path…"})]})}),U==="__custom__"&&e.jsx("input",{type:"text",placeholder:"Enter absolute path…",value:ne,onChange:f=>pe(f.target.value),className:"machine-input flex-1 min-w-[200px]",autoFocus:!0})]});return e.jsxs("div",{children:[e.jsxs("div",{className:`px-5 py-4 rounded-xl mb-5 bg-bg-secondary border ${O.accent}`,children:[e.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-2.5",children:["Launch ",O.label]}),P,B?e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[ce.map(f=>{const K=f.running||i.some(Y=>(Y.type||"").toLowerCase()===(f.type||"").toLowerCase());return e.jsxs("button",{onClick:()=>p(f.type||f.id||"",q?{workspace:q}:void 0),disabled:!!w,className:`machine-btn-primary flex items-center gap-1.5 ${K?"!border-green-500/30":""}`,style:{opacity:w&&w!==f.type?.4:1},children:[e.jsx("span",{children:c(f.type)}),K&&e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500 shadow-[0_0_4px_rgba(34,197,94,0.4)]"}),w===f.type?"⏳ Launching...":`▶ ${f.name||He(f.type)}`,K&&e.jsx("span",{className:"text-[9px] text-green-400 font-normal",children:"+ window"})]},f.type)}),ce.length===0&&e.jsxs("div",{className:"text-xs text-text-muted italic",children:["No IDEs detected.",e.jsxs("button",{onClick:m,className:"machine-btn ml-2 flex items-center gap-1",children:[e.jsx(bn,{size:12})," Scan"]})]})]})}):e.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[e.jsx("select",{value:W,onChange:f=>S(f.target.value),className:"machine-input",children:C.length>0?C.map(f=>e.jsxs("option",{value:f.type,children:[f.icon," ",f.displayName]},f.type)):e.jsxs("option",{value:"",disabled:!0,children:["No ",t.toUpperCase()," providers available"]})}),$&&e.jsx("input",{type:"text",placeholder:"Model (default)",value:R,onChange:f=>z(f.target.value),className:"machine-input min-w-[120px]"}),e.jsx("input",{type:"text",placeholder:"Args (optional)",value:y,onChange:f=>se(f.target.value),className:"machine-input min-w-[120px]"}),e.jsx("button",{onClick:D,className:"machine-btn-primary",children:"▶ Launch"})]})]}),e.jsxs("div",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-2.5",children:["Running (",i.length,")"]}),i.length===0?e.jsxs("div",{className:"py-7.5 px-5 text-center rounded-xl bg-bg-secondary border border-dashed border-border-subtle text-text-muted text-[13px] mb-5",children:["No ",O.plural," running"]}):e.jsx("div",{className:"flex flex-col gap-2.5 mb-5",children:i.map(f=>{const K=B?f:null,Y=$?f:null;return e.jsxs("div",{className:"px-4.5 py-3.5 rounded-xl bg-bg-secondary border border-border-subtle",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"text-lg",children:c(f.type)}),e.jsxs("div",{children:[e.jsxs("div",{className:"font-semibold text-[13px] text-text-primary",children:[ie(f),(K==null?void 0:K.version)&&e.jsxs("span",{className:"text-[10px] text-text-muted ml-1.5",children:["v",K.version]})]}),e.jsxs("div",{className:"text-[11px] text-text-muted flex gap-2",children:[e.jsx("span",{children:f.workspace||"—"}),(Y==null?void 0:Y.currentModel)&&e.jsxs("span",{className:"text-cyan-500",children:["🤖 ",Y.currentModel]}),(Y==null?void 0:Y.currentPlan)&&e.jsxs("span",{className:"text-amber-500",children:["📋 ",Y.currentPlan]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`px-2 py-0.5 rounded-md text-[10px] font-semibold ${f.status==="stopped"?"bg-red-500/[0.08] text-red-500":f.status==="generating"?"bg-orange-500/[0.08] text-orange-400":"bg-green-500/[0.08] text-green-500"}`,children:f.status}),B&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>d(`/ide/${f.id}`),className:"machine-btn flex items-center gap-1",children:[e.jsx(ot,{size:13})," Control"]}),e.jsx("button",{onClick:()=>g(f),className:"machine-btn text-amber-500 border-amber-500/30",children:"↻"})]}),$&&e.jsx("button",{onClick:()=>d(`/ide/${f.id}`),className:"machine-btn",title:"View chat",children:e.jsx(Et,{size:14})}),f.status==="stopped"?e.jsx("button",{onClick:()=>B?p(f.type,f.workspace?{workspace:f.workspace}:void 0):u(f.type,f.workspace),className:"machine-btn text-green-500 border-green-500/30",children:"▶"}):e.jsx("button",{onClick:()=>b(f),className:"machine-btn text-red-500 border-red-500/30",children:"■"})]})]}),K&&K.aiAgents.length>0&&e.jsx("div",{className:"flex gap-1 mb-2 flex-wrap",children:K.aiAgents.map(te=>e.jsxs("span",{className:`px-2 py-0.5 rounded-md text-[10px] ${te.status==="generating"||te.status==="streaming"?"bg-orange-500/[0.08] text-orange-400":"bg-indigo-500/[0.06] text-indigo-400"}`,children:[te.name," · ",te.status]},te.id))}),K&&(G[K.type]||[]).length>0&&x&&e.jsxs("div",{className:"mt-2 pt-2 border-t border-border-subtle",children:[e.jsx("div",{className:"text-[10px] text-text-muted font-semibold uppercase tracking-wider mb-1.5",children:"Extensions"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:(G[K.type]||[]).map(te=>e.jsxs("button",{disabled:oe===`${K.type}.${te.type}`,onClick:async()=>{const Se=`${K.type}.${te.type}`;J(Se);try{await x(r,"set_ide_extension",{ideType:K.type,extensionType:te.type,enabled:!te.enabled}),H(Ne=>({...Ne,[K.type]:(Ne[K.type]||[]).map(je=>je.type===te.type?{...je,enabled:!je.enabled}:je)}))}catch(Ne){console.error("Extension toggle failed:",Ne)}finally{J(null)}},className:`flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-[11px] font-medium border transition-colors duration-150 cursor-pointer ${te.enabled?"bg-violet-500/[0.08] border-violet-500/20 text-violet-400":"bg-bg-glass border-border-subtle text-text-muted"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${te.enabled?"bg-violet-400 shadow-[0_0_4px_rgba(139,92,246,0.4)]":"bg-zinc-600"}`}),te.name,e.jsx("span",{className:"text-[9px] font-normal",children:te.enabled?"ON":"OFF"})]},te.type))})]})]},f.id)})}),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[e.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider",children:"History"}),e.jsx("button",{onClick:j,disabled:_,className:"machine-btn",children:_?"⏳":"↻ Load"})]}),(()=>{const f=new Set(C.map(Y=>Y.type)),K=A.filter(Y=>(Y.category||"cli")!==t?!1:t==="ide"?!0:f.has(Y.cliType));return K.length>0?e.jsx("div",{className:"flex flex-col gap-1 max-h-[200px] overflow-y-auto",children:K.map((Y,te)=>{var Se,Ne;return e.jsxs("div",{onClick:()=>{S(Y.cliType),(Y.workspace||Y.dir)&&(v("__custom__"),pe(Y.workspace||Y.dir)),se((Y.cliArgs||[]).join(" ")),z(Y.model||""),B&&p(Y.cliType,Y.workspace?{workspace:Y.workspace}:void 0)},className:"flex justify-between items-center px-2.5 py-1.5 rounded-md cursor-pointer bg-bg-glass border border-border-subtle text-xs transition-colors duration-150 hover:bg-bg-glass-hover",children:[e.jsxs("div",{className:"flex gap-1.5 items-center text-text-secondary",children:[e.jsx("span",{children:c(Y.cliType)}),e.jsx("span",{children:((Se=Y.workspace||Y.dir)==null?void 0:Se.split("/").filter(Boolean).pop())||Y.cliType||"root"}),Y.model&&e.jsxs("span",{className:"text-cyan-500 text-[10px]",children:["model=",Y.model]}),Y.newWindow&&e.jsx("span",{className:"text-text-muted text-[10px]",children:"new window"}),((Ne=Y.cliArgs)==null?void 0:Ne.length)>0&&e.jsx("span",{className:"text-text-muted text-[10px]",children:Y.cliArgs.join(" ")})]}),e.jsx("span",{className:"text-text-muted text-[10px]",children:Y.timestamp?new Date(Y.timestamp).toLocaleDateString():""})]},te)})}):e.jsxs("div",{className:"text-[11px] text-text-muted italic mb-2",children:["No ",O.label," launch history yet."]})})()]})]})}const ps=["openPanel","sendMessage","readChat","newSession","listSessions","switchSession","resolveAction","listModels","setModel","listModes","setMode","focusEditor"],zr=[{value:"codex-cli",label:"Codex CLI",desc:"OpenAI o3/gpt-5.4",color:"#22c55e"},{value:"claude-cli",label:"Claude Code",desc:"Anthropic Claude",color:"#a855f7"},{value:"gemini-cli",label:"Gemini CLI",desc:"Google Gemini",color:"#3b82f6"}];function Ur({machineId:t,provider:s,sendDaemonCommand:r,onClose:a}){const[i,c]=n.useState("config"),[o,x]=n.useState("codex-cli"),[d,p]=n.useState([]),[u,l]=n.useState(""),[g,h]=n.useState([]),[m,A]=n.useState(""),_=n.useRef(null),j=n.useRef(null),w=S=>{p(y=>y.includes(S)?y.filter(se=>se!==S):[...y,S])},O=()=>p([...ps]),B=()=>p([]);n.useEffect(()=>{var S;(S=_.current)==null||S.scrollIntoView({behavior:"smooth"})},[g]),n.useEffect(()=>()=>{j.current&&clearInterval(j.current)},[]);const $=n.useCallback(()=>{j.current&&clearInterval(j.current),j.current=setInterval(async()=>{try{const S=await r(t,"provider_auto_fix_status",{providerType:s.type});(S==null?void 0:S.running)===!1&&i==="running"&&(c("done"),h(y=>[...y,`
|
|
70
|
-
✅ Auto-fix completed!`]),j.current&&clearInterval(j.current))}catch{}},3e3)},[t,s.type,r,i]),C=async()=>{if(d.length!==0){c("running"),h(["🚀 Starting auto-fix...",`Agent: ${o}`,`Scripts: ${d.join(", ")}`,u?`💬 Comment: ${u}`:"",""]),A("");try{const S=await r(t,"provider_auto_fix",{providerType:s.type,functions:d,agent:o,...u?{comment:u}:{}});S!=null&&S.success&&(S!=null&&S.started||S!=null&&S.running)?(h(y=>[...y,"✅ Agent started. Monitoring progress..."]),$()):(c("error"),A((S==null?void 0:S.error)||"Failed to start auto-fix"))}catch(S){c("error"),A((S==null?void 0:S.message)||"Connection failed")}}},W=async()=>{try{await r(t,"provider_auto_fix_cancel",{providerType:s.type}),h(S=>[...S,`
|
|
71
|
-
⚠️ Auto-fix cancelled.`]),c("done"),j.current&&clearInterval(j.current)}catch{}};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:a,children:e.jsxs("div",{className:"w-full max-w-[560px] max-h-[85vh] overflow-hidden rounded-2xl bg-bg-primary border border-border-subtle shadow-2xl flex flex-col",onClick:S=>S.stopPropagation(),children:[e.jsxs("div",{className:"px-5 py-4 border-b border-border-subtle flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"text-lg",children:s.icon||"🔧"}),e.jsxs("div",{children:[e.jsxs("h2",{className:"text-[15px] font-semibold text-text-primary",children:["Auto-Fix: ",s.displayName]}),e.jsx("p",{className:"text-[11px] text-text-muted mt-0.5",children:"AI agent will implement provider scripts"})]})]}),e.jsx("button",{onClick:a,className:"text-text-muted hover:text-text-primary text-lg leading-none",children:"×"})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4",children:[i==="config"&&e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1.5 block",children:"AI Agent"}),e.jsx("div",{className:"flex gap-2",children:zr.map(S=>e.jsxs("button",{onClick:()=>x(S.value),className:"flex-1 px-3 py-2 rounded-lg border text-left transition-all",style:{borderColor:o===S.value?S.color+"66":"var(--border-subtle)",background:o===S.value?S.color+"0d":"transparent"},children:[e.jsx("div",{className:"text-[12px] font-semibold",style:{color:o===S.value?S.color:"var(--text-primary)"},children:S.label}),e.jsx("div",{className:"text-[10px] text-text-muted",children:S.desc})]},S.value))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsx("label",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider",children:"Scripts to Fix"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("button",{onClick:O,className:"text-[10px] text-violet-400 hover:text-violet-300",children:"All"}),e.jsx("span",{className:"text-[10px] text-text-muted",children:"|"}),e.jsx("button",{onClick:B,className:"text-[10px] text-text-muted hover:text-text-secondary",children:"None"})]})]}),e.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:ps.map(S=>e.jsxs("button",{onClick:()=>w(S),className:"px-2.5 py-1.5 rounded-md border text-[11px] font-medium text-left transition-all",style:{borderColor:d.includes(S)?"rgba(139,92,246,0.4)":"var(--border-subtle)",background:d.includes(S)?"rgba(139,92,246,0.08)":"transparent",color:d.includes(S)?"#a78bfa":"var(--text-secondary)"},children:[d.includes(S)?"☑ ":"☐ ",S]},S))})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1.5 block",children:["Additional Instructions ",e.jsx("span",{className:"text-text-muted font-normal",children:"(optional)"})]}),e.jsx("textarea",{value:u,onChange:S=>l(S.target.value),placeholder:"e.g. Also search buttons inside Shadow DOM, preserve code block formatting in readChat...",rows:2,className:"w-full px-3 py-2 rounded-lg border border-border-subtle bg-bg-secondary text-text-primary text-[12px] resize-none placeholder:text-text-muted/50 focus:outline-none focus:border-violet-500/40"})]})]}),(i==="running"||i==="done"||i==="error")&&e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1.5 block",children:"Agent Output"}),e.jsxs("div",{className:"rounded-lg border border-border-subtle bg-[#0d0d0d] p-3 font-mono text-[11px] leading-relaxed text-text-secondary overflow-y-auto",style:{maxHeight:320,minHeight:200},children:[g.map((S,y)=>e.jsx("div",{className:S.startsWith("✅")?"text-green-400":S.startsWith("❌")||S.startsWith("⚠")?"text-amber-400":"",children:S},y)),i==="running"&&e.jsx("div",{className:"text-violet-400 animate-pulse mt-1",children:"● Running..."}),e.jsx("div",{ref:_})]}),m&&e.jsx("div",{className:"mt-2 px-3 py-2 rounded-lg bg-red-500/[0.06] border border-red-500/20 text-red-400 text-[11px]",children:m})]})]}),e.jsxs("div",{className:"px-5 py-3.5 border-t border-border-subtle flex justify-between items-center",children:[e.jsxs("div",{className:"text-[10px] text-text-muted",children:[i==="config"&&d.length>0&&`${d.length} script(s) selected`,i==="running"&&"Agent is working...",i==="done"&&"Run `adhdev provider verify` to validate"]}),e.jsxs("div",{className:"flex gap-2",children:[i==="config"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:a,className:"machine-btn",children:"Cancel"}),e.jsx("button",{onClick:C,disabled:d.length===0,className:"machine-btn",style:{background:d.length>0?"rgba(139,92,246,0.15)":void 0,borderColor:d.length>0?"rgba(139,92,246,0.4)":void 0,color:d.length>0?"#a78bfa":void 0,opacity:d.length===0?.4:1},children:"🚀 Start Fix"})]}),i==="running"&&e.jsx("button",{onClick:W,className:"machine-btn text-red-400 border-red-500/30",children:"⬛ Cancel"}),(i==="done"||i==="error")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{c("config"),h([]),A("")},className:"machine-btn",children:"← Back"}),e.jsx("button",{onClick:a,className:"machine-btn",children:"Close"})]})]})]})]})})}function Yr({machineId:t,providers:s,sendDaemonCommand:r,onClose:a,onCreated:i}){var $;const c=s.filter(C=>C.category==="ide"),[o,x]=n.useState((($=c[0])==null?void 0:$.type)||""),[d,p]=n.useState(""),[u,l]=n.useState(""),[g,h]=n.useState(!1),[m,A]=n.useState(""),[_,j]=n.useState(!1),w=C=>{const W=C.toLowerCase().replace(/[^a-z0-9-]/g,"");p(W),(!u||u===O(d))&&l(O(W))},O=C=>C.split("-").map(W=>W.charAt(0).toUpperCase()+W.slice(1)).join(" "),B=async()=>{if(!(!d||!u||!o)){h(!0),A("");try{const C=await r(t,"provider_clone",{type:d,name:u,category:"ide",location:"user",cloneFrom:o});C!=null&&C.success||C!=null&&C.created?(j(!0),i==null||i(d)):A((C==null?void 0:C.error)||"Failed to create provider")}catch(C){A((C==null?void 0:C.message)||"Connection failed")}h(!1)}};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:a,children:e.jsxs("div",{className:"w-full max-w-[480px] rounded-2xl bg-bg-primary border border-border-subtle shadow-2xl flex flex-col",onClick:C=>C.stopPropagation(),children:[e.jsxs("div",{className:"px-5 py-4 border-b border-border-subtle",children:[e.jsx("h2",{className:"text-[15px] font-semibold text-text-primary",children:"✨ Create User Provider"}),e.jsx("p",{className:"text-[11px] text-text-muted mt-0.5",children:"Clone an upstream IDE provider to customize"})]}),e.jsx("div",{className:"px-5 py-4 flex flex-col gap-4",children:_?e.jsxs("div",{className:"text-center py-6",children:[e.jsx("div",{className:"text-3xl mb-2",children:"🎉"}),e.jsx("h3",{className:"text-[14px] font-semibold text-text-primary",children:"Provider Created!"}),e.jsxs("p",{className:"text-[11px] text-text-muted mt-1",children:[e.jsx("code",{className:"text-violet-400",children:d})," has been created at ",e.jsxs("code",{className:"text-green-400",children:["~/.adhdev/providers/",d,"/"]})]}),e.jsxs("p",{className:"text-[11px] text-text-muted mt-2",children:["Run ",e.jsxs("code",{className:"text-violet-400",children:["adhdev provider fix ",d]})," or use Auto-Fix to implement scripts."]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1.5 block",children:"Base Provider"}),e.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:c.map(C=>e.jsxs("button",{onClick:()=>x(C.type),className:"px-2.5 py-2 rounded-lg border text-center transition-all",style:{borderColor:o===C.type?"rgba(139,92,246,0.4)":"var(--border-subtle)",background:o===C.type?"rgba(139,92,246,0.08)":"transparent"},children:[e.jsx("div",{className:"text-lg",children:C.icon}),e.jsx("div",{className:"text-[10px] font-medium mt-0.5",style:{color:o===C.type?"#a78bfa":"var(--text-secondary)"},children:C.displayName})]},C.type))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1.5 block",children:"Provider Type (ID)"}),e.jsx("input",{value:d,onChange:C=>w(C.target.value),placeholder:"my-cursor, custom-windsurf...",className:"w-full px-3 py-2 rounded-lg border border-border-subtle bg-bg-secondary text-text-primary text-[12px] placeholder:text-text-muted/50 focus:outline-none focus:border-violet-500/40"}),e.jsxs("p",{className:"text-[10px] text-text-muted mt-1",children:["Lowercase, alphanumeric + hyphens only. Will be created at ",e.jsxs("code",{className:"text-violet-400",children:["~/.adhdev/providers/",d||"...","/"]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mb-1.5 block",children:"Display Name"}),e.jsx("input",{value:u,onChange:C=>l(C.target.value),placeholder:"My Custom IDE",className:"w-full px-3 py-2 rounded-lg border border-border-subtle bg-bg-secondary text-text-primary text-[12px] placeholder:text-text-muted/50 focus:outline-none focus:border-violet-500/40"})]}),m&&e.jsx("div",{className:"px-3 py-2 rounded-lg bg-red-500/[0.06] border border-red-500/20 text-red-400 text-[11px]",children:m})]})}),e.jsx("div",{className:"px-5 py-3.5 border-t border-border-subtle flex justify-end gap-2",children:_?e.jsx("button",{onClick:a,className:"machine-btn",children:"Close"}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:a,className:"machine-btn",children:"Cancel"}),e.jsx("button",{onClick:B,disabled:!d||!u||g,className:"machine-btn",style:{background:d&&u?"rgba(34,197,94,0.12)":void 0,borderColor:d&&u?"rgba(34,197,94,0.3)":void 0,color:d&&u?"#86efac":void 0,opacity:!d||!u||g?.4:1},children:g?"⏳ Creating...":"✨ Create Provider"})]})})]})})}function Vr({machineId:t,providers:s,sendDaemonCommand:r}){const[a,i]=n.useState([]),[c,o]=n.useState(!1),[x,d]=n.useState(null),[p,u]=n.useState("all"),[l,g]=n.useState(null),[h,m]=n.useState(!1),A=n.useCallback(async()=>{var j;if(t){o(!0);try{const w=await r(t,"get_provider_settings",{}),O=(w==null?void 0:w.result)||w;if(w!=null&&w.success&&(O!=null&&O.settings)){const B=[];for(const[$,C]of Object.entries(O.settings)){const W=s.find(S=>S.type===$);B.push({type:$,displayName:(W==null?void 0:W.displayName)||$,icon:(W==null?void 0:W.icon)||"",category:(W==null?void 0:W.category)||"unknown",schema:C,values:((j=O.values)==null?void 0:j[$])||{}})}B.sort(($,C)=>$.category.localeCompare(C.category)||$.displayName.localeCompare(C.displayName)),i(B)}}catch{}o(!1)}},[t,s,r]);n.useEffect(()=>{a.length===0&&A()},[]);const _=async(j,w,O)=>{d(`${j}.${w}`),i(B=>B.map($=>$.type===j?{...$,values:{...$.values,[w]:O}}:$));try{const B=await r(t,"set_provider_setting",{providerType:j,key:w,value:O});B!=null&&B.success||A()}catch{A()}d(null)};return e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center mb-4",children:[e.jsxs("div",{className:"flex gap-1 items-center",children:[e.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mr-2",children:"Filter"}),["all","acp","cli","ide","extension"].map(j=>e.jsx("button",{onClick:()=>u(j),className:`machine-btn text-[10px] px-2 py-0.5 ${p===j?"bg-violet-500/15 border-violet-500/40 text-violet-400":""}`,children:j.toUpperCase()},j))]}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("button",{onClick:()=>m(!0),className:"machine-btn text-[10px] bg-green-500/[0.06] border-green-500/20 text-green-400 hover:bg-green-500/[0.12]",children:"✨ Create Provider"}),e.jsx("button",{onClick:A,disabled:c,className:"machine-btn",children:c?"⏳ Loading...":"↻ Refresh"})]})]}),p!=="all"&&a.filter(j=>j.category===p).length>1&&(()=>{const j=a.filter($=>$.category===p),w=new Map;for(const $ of j)for(const C of $.schema){if(C.type!=="boolean")continue;const W=w.get(C.key),S=!!($.values[C.key]??C.default);W?(W.onCount+=S?1:0,W.total+=1):w.set(C.key,{label:C.label||C.key,onCount:S?1:0,total:1})}const O=[...w.entries()].filter(([,$])=>$.total===j.length);if(O.length===0)return null;const B=async($,C)=>{for(const W of j)await _(W.type,$,C)};return e.jsxs("div",{className:"px-4 py-3 rounded-xl bg-violet-500/[0.04] border border-violet-500/10 mb-4",children:[e.jsxs("div",{className:"text-[10px] text-violet-400 font-semibold uppercase tracking-wider mb-2",children:["Bulk — Apply to all ",p.toUpperCase()," providers (",j.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:O.map(([$,C])=>{const W=C.onCount===C.total,S=C.onCount===0;return e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",children:[e.jsx("span",{className:"text-text-secondary font-medium",children:C.label}),e.jsxs("span",{className:"text-[9px] text-text-muted",children:["(",C.onCount,"/",C.total,")"]}),e.jsx("button",{onClick:()=>void B($,!0),disabled:W,className:`machine-btn text-[9px] px-1.5 py-px ${W?"opacity-40":"text-green-400 border-green-500/30"}`,children:"All ON"}),e.jsx("button",{onClick:()=>void B($,!1),disabled:S,className:`machine-btn text-[9px] px-1.5 py-px ${S?"opacity-40":"text-red-400 border-red-500/30"}`,children:"All OFF"})]},$)})})]})})(),c&&a.length===0?e.jsx("div",{className:"p-10 text-center text-text-muted",children:"Loading provider settings..."}):e.jsx("div",{className:"flex flex-col gap-2",children:a.filter(j=>p==="all"||j.category===p).map(j=>e.jsxs("div",{className:"px-4.5 py-3.5 rounded-xl bg-bg-secondary border border-border-subtle",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[e.jsx("span",{className:"text-lg",children:j.icon}),e.jsx("span",{className:"font-semibold text-[13px] text-text-primary",children:j.displayName}),e.jsx("span",{className:"px-1.5 py-px rounded text-[9px] font-semibold",style:{background:j.category==="acp"?"rgba(139,92,246,0.08)":j.category==="cli"?"rgba(59,130,246,0.08)":j.category==="ide"?"rgba(34,197,94,0.08)":"rgba(245,158,11,0.08)",color:j.category==="acp"?"#a78bfa":j.category==="cli"?"#60a5fa":j.category==="ide"?"#86efac":"#fbbf24"},children:j.category}),j.category==="ide"&&e.jsx("button",{onClick:()=>g(s.find(w=>w.type===j.type)||{type:j.type,displayName:j.displayName,icon:j.icon,category:j.category}),className:"ml-auto machine-btn text-[9px] px-2 py-0.5 bg-violet-500/[0.06] border-violet-500/20 text-violet-400 hover:bg-violet-500/[0.12]",children:"🔧 Auto-Fix"})]}),e.jsx("div",{className:"flex flex-col gap-2",children:j.schema.map(w=>e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"text-xs font-medium text-text-primary",children:[w.label||w.key,x===`${j.type}.${w.key}`&&e.jsx("span",{className:"ml-1.5 text-[9px] text-violet-500",children:"saving..."})]}),w.description&&e.jsx("div",{className:"text-[10px] text-text-muted mt-px",children:w.description})]}),e.jsx("div",{className:"shrink-0",children:w.type==="boolean"?e.jsx("button",{onClick:()=>_(j.type,w.key,!(j.values[w.key]??w.default)),className:"w-10 h-[22px] rounded-[11px] border-none relative cursor-pointer transition-colors duration-200",style:{background:j.values[w.key]??w.default?"#8b5cf6":"var(--border-subtle)"},children:e.jsx("div",{className:"w-4 h-4 rounded-full bg-white absolute top-[3px] transition-[left] duration-200 shadow-[0_1px_3px_rgba(0,0,0,0.3)]",style:{left:j.values[w.key]??w.default?21:3}})}):w.type==="number"?e.jsx("input",{type:"number",value:j.values[w.key]??w.default??0,min:w.min,max:w.max,onChange:O=>{const B=parseInt(O.target.value)||0;w.min!==void 0&&B<w.min||w.max!==void 0&&B>w.max||_(j.type,w.key,B)},className:"machine-input w-20 text-center text-[11px]"}):w.type==="select"&&w.options?e.jsx("select",{value:j.values[w.key]??w.default??"",onChange:O=>_(j.type,w.key,O.target.value),className:"machine-input text-[11px]",children:w.options.map(O=>e.jsx("option",{value:O,children:O},O))}):e.jsx("input",{type:"text",value:j.values[w.key]??w.default??"",onBlur:O=>_(j.type,w.key,O.target.value),className:"machine-input w-[120px] text-[11px]"})})]},w.key))})]},j.type))}),l&&e.jsx(Ur,{machineId:t,provider:l,sendDaemonCommand:r,onClose:()=>g(null)}),h&&e.jsx(Yr,{machineId:t,providers:s,sendDaemonCommand:r,onClose:()=>m(!1),onCreated:()=>{m(!1),A()}})]})}function Xr({machineId:t,sendDaemonCommand:s}){const[r,a]=n.useState([]),[i,c]=n.useState(0),[o,x]=n.useState(!0),[d,p]=n.useState("debug"),u=n.useRef(null),l=n.useRef(!1);return n.useEffect(()=>{if(!t||!o)return;const g=async()=>{try{const m=await s(t,"get_logs",{count:200,minLevel:d,since:i}),A=(m==null?void 0:m.result)||m;if(m!=null&&m.success&&Array.isArray(A==null?void 0:A.logs)&&A.logs.length>0){a(j=>[...j,...A.logs.map(O=>({timestamp:O.ts,level:O.level,message:`[${O.category}] ${O.message}`}))].slice(-300));const _=Math.max(...A.logs.map(j=>j.ts));c(_)}}catch{}};g();const h=setInterval(g,3e3);return()=>clearInterval(h)},[t,o,i,d,s]),n.useEffect(()=>{if(o&&r.length>0){const g=l.current?"smooth":"instant";setTimeout(()=>{var h;(h=u.current)==null||h.scrollIntoView({behavior:g}),l.current=!0},50)}},[r.length,o]),e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center mb-3",children:[e.jsxs("div",{className:"flex gap-1 items-center",children:[e.jsx("span",{className:"text-[11px] text-text-muted font-semibold uppercase tracking-wider mr-2",children:"Level"}),["debug","info","warn","error"].map(g=>e.jsx("button",{onClick:()=>{p(g),a([]),c(0)},className:`machine-btn text-[10px] px-2 py-0.5 ${d===g?"bg-violet-500/15 border-violet-500/40 text-violet-400":""}`,children:g.toUpperCase()},g))]}),e.jsxs("div",{className:"flex gap-1.5 items-center",children:[e.jsxs("span",{className:"text-[10px] text-text-muted",children:[r.length," entries"]}),e.jsx("button",{onClick:()=>x(!o),className:`machine-btn ${o?"text-green-500 border-green-500/30":""}`,children:o?"⏸ Pause":"▶ Resume"}),e.jsx("button",{onClick:()=>{a([]),c(0)},className:"machine-btn",children:"Clear"})]})]}),e.jsxs("div",{className:"bg-bg-secondary border border-border-subtle rounded-xl p-3 min-h-[200px] max-h-[500px] overflow-y-auto font-mono text-[11px] leading-relaxed",children:[r.length===0&&e.jsx("div",{className:"p-10 text-center text-text-muted",children:"Loading daemon logs..."}),r.map((g,h)=>e.jsxs("div",{className:"flex gap-2 py-px",style:{color:g.level==="error"?"#ef4444":g.level==="warn"?"#f59e0b":g.level==="debug"?"#64748b":"#94a3b8"},children:[e.jsx("span",{className:"text-text-muted min-w-[75px] shrink-0",children:new Date(g.timestamp).toLocaleTimeString()}),e.jsx("span",{className:"font-semibold min-w-[32px] shrink-0 text-[9px]",style:{color:g.level==="error"?"#ef4444":g.level==="warn"?"#f59e0b":g.level==="debug"?"#475569":"#8b5cf6"},children:g.level==="error"?"ERR":g.level==="warn"?"WRN":g.level==="debug"?"DBG":"INF"}),e.jsx("span",{children:g.message})]},h)),e.jsx("div",{ref:u})]})]})}function qr({machine:t,launchPick:s,actions:r}){const{runLaunchCliCore:a,setLaunchPick:i}=r;return e.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center p-4 bg-black/55 backdrop-blur-[2px]",role:"dialog","aria-modal":"true","aria-labelledby":"launch-pick-title",children:e.jsxs("div",{className:"w-full max-w-md rounded-xl border border-border-subtle bg-bg-secondary shadow-xl p-5",children:[e.jsx("h2",{id:"launch-pick-title",className:"text-sm font-semibold text-text-primary m-0 mb-1",children:"Where should this run?"}),e.jsx("p",{className:"text-[11px] text-text-muted m-0 mb-4",children:"Nothing is assumed. Pick a saved workspace, your default workspace, or home — or cancel and type a path."}),e.jsx("div",{className:"flex flex-col gap-2 mb-4 max-h-48 overflow-y-auto",children:(t.workspaces||[]).length===0?e.jsx("span",{className:"text-[11px] text-text-muted",children:"No saved workspaces yet. Add one in Overview or type a path above."}):(t.workspaces||[]).map(c=>e.jsxs("button",{type:"button",className:"text-left text-xs px-3 py-2 rounded-lg border border-border-subtle bg-bg-primary hover:bg-violet-500/10 transition-colors",onClick:()=>{i(null),a({cliType:s.cliType,workspaceId:c.id,argsStr:s.argsStr,model:s.model})},children:[e.jsx("span",{className:"font-medium text-text-primary block truncate",children:c.label||c.path}),e.jsx("span",{className:"text-[10px] text-text-muted font-mono truncate block",children:c.path})]},c.id))}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",className:"machine-btn text-[11px] flex-1 min-w-[120px]",disabled:!t.defaultWorkspacePath,onClick:()=>{i(null),a({cliType:s.cliType,useDefaultWorkspace:!0,argsStr:s.argsStr,model:s.model})},children:"Default workspace"}),e.jsx("button",{type:"button",className:"machine-btn text-[11px] flex-1 min-w-[120px]",onClick:()=>{i(null),a({cliType:s.cliType,useHome:!0,argsStr:s.argsStr,model:s.model})},children:"Home directory"}),e.jsx("button",{type:"button",className:"machine-btn text-[11px] flex-1 min-w-[80px]",onClick:()=>i(null),children:"Cancel"})]})]})})}function Gr(){var B,$,C,W,S,y,se,R,z,U;const{id:t}=ys(),s=vt(),{sendCommand:r}=st(),a=$t(),i=a.ides||[],c=a.initialLoaded??!0,[o,x]=n.useState("overview"),d=n.useRef(null),p=Kr({machineId:t,sendDaemonCommand:r,logsEndRef:d}),u=i.find(v=>v.id===t&&v.daemonMode),l=((u==null?void 0:u.availableProviders)||[]).map(v=>({type:v.type,displayName:v.displayName,icon:v.icon,category:v.category})),g={};for(const v of l)g[v.type]=v.icon;const h=v=>g[v]||"",m=u?{id:u.id,hostname:((B=u.machine)==null?void 0:B.hostname)||u.id,platform:(($=u.machine)==null?void 0:$.platform)||"unknown",arch:((C=u.machine)==null?void 0:C.arch)||"",cpus:((W=u.machine)==null?void 0:W.cpus)||0,totalMem:((S=u.machine)==null?void 0:S.totalMem)||0,freeMem:((y=u.machine)==null?void 0:y.freeMem)||0,availableMem:(se=u.machine)==null?void 0:se.availableMem,loadavg:((R=u.machine)==null?void 0:R.loadavg)||[],uptime:((z=u.machine)==null?void 0:z.uptime)||0,release:((U=u.machine)==null?void 0:U.release)||"",cdpConnected:!!(u.ides||[]).some(v=>v.cdpConnected),machineNickname:u.machineNickname||null,p2p:u.p2p||{available:!1,state:"unavailable",peers:0,screenshotActive:!1},detectedIdes:u.detectedIdes||[],managedIdeIds:u.managedIdeIds||[],managedCliIds:u.managedCliIds||[],workspaces:u.workspaces||[],defaultWorkspaceId:u.defaultWorkspaceId??u.activeWorkspaceId??null,defaultWorkspacePath:u.defaultWorkspacePath??u.activeWorkspacePath??null,workspaceActivity:u.workspaceActivity||[]}:null,A=i.filter(v=>v.daemonId===t&&!v.daemonMode).filter(v=>!ns(v)&&!rs(v)).map(v=>({id:v.id,type:v.type,version:v.version||"",instanceId:v.instanceId||"",status:v.status,workspace:v.workspace||null,terminals:v.terminals||0,aiAgents:Kn(v.aiAgents||v.agents||[]),activeChat:v.activeChat||null,chats:v.chats||[],agentStreams:v.agentStreams||[],cdpConnected:v.cdpConnected||!1,daemonId:t})),_=i.filter(v=>v.daemonId===t&&ns(v)).map(v=>({id:v.id,type:v.type,cliName:v.cliName||v.type,status:v.status,workspace:v.workspace||"",activeChat:v.activeChat||null,daemonId:t})),j=i.filter(v=>v.daemonId===t&&rs(v)).map(v=>({id:v.id,type:v.type,acpName:v.cliName||v.type,status:v.status,workspace:v.workspace||"",activeChat:v.activeChat||null,currentModel:v.currentModel,currentPlan:v.currentPlan,daemonId:t}));if(!m)return c?e.jsxs("div",{className:"p-10 text-center text-text-muted",children:[e.jsx("h2",{className:"text-text-primary",children:"Machine not found"}),e.jsx("p",{className:"mt-3",children:"The machine may be offline or not yet connected."}),e.jsx("button",{onClick:()=>s("/machines"),className:"machine-btn-back",children:"← Back to Burrows"})]}):e.jsx("div",{className:"p-10 text-center text-text-muted",children:e.jsx("p",{children:"⏳ Loading machine..."})});const w=m.machineNickname||m.hostname,O=[{id:"overview",label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(jn,{size:14})," Overview"]})},{id:"ides",label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(ot,{size:14})," IDEs"]}),count:A.length},{id:"clis",label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(bt,{size:14})," CLIs"]}),count:_.length},{id:"acps",label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Cs,{size:14})," ACP Agents"]}),count:j.length},{id:"providers",label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Vt,{size:14})," Providers"]})},{id:"logs",label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(pn,{size:14})," Logs"]})}];return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"dashboard-header !flex-col !items-stretch",children:[e.jsx("div",{className:"flex items-center justify-between w-full",children:e.jsxs("div",{className:"flex items-center gap-2 md:gap-3.5 w-full min-w-0",children:[e.jsx("button",{onClick:()=>s("/machines"),className:"machine-btn-back flex shrink-0",children:"←"}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[p.editingNickname?e.jsxs("div",{className:"flex gap-1.5 items-center",children:[e.jsx("input",{autoFocus:!0,value:p.nicknameInput,onChange:v=>p.setNicknameInput(v.target.value),onKeyDown:v=>{v.key==="Enter"&&p.handleSaveNickname(),v.key==="Escape"&&p.setEditingNickname(!1)},placeholder:"Machine nickname...",className:"px-2.5 py-1 rounded-md border border-violet-500/30 bg-bg-secondary text-text-primary text-sm font-semibold w-[140px] md:w-[200px]"}),e.jsx("button",{onClick:p.handleSaveNickname,className:"machine-btn text-green-500 border-green-500/30 shrink-0",children:"✓"}),e.jsx("button",{onClick:()=>p.setEditingNickname(!1),className:"machine-btn shrink-0",children:"✕"})]}):e.jsx("h1",{className:"header-title cursor-pointer truncate",onClick:()=>{p.setEditingNickname(!0),p.setNicknameInput(m.machineNickname||"")},title:"Click to set nickname",children:w}),e.jsx("span",{className:"status-dot-md online shrink-0"})]}),e.jsxs("div",{className:"header-subtitle mt-1 flex-wrap gap-1 md:gap-2 items-center display-none-mobile",children:[e.jsxs("span",{children:[m.platform," · ",m.arch," · ",m.cpus," cores"]}),(u==null?void 0:u.version)&&e.jsxs("span",{className:"px-1.5 py-px rounded text-[9px] font-semibold bg-bg-glass border border-border-subtle text-text-muted shrink-0",children:["v",u.version]}),(u==null?void 0:u.versionMismatch)&&e.jsxs("button",{className:"px-1.5 py-px rounded text-[9px] font-semibold bg-amber-500/[0.08] border border-amber-500/20 text-amber-400 cursor-pointer hover:bg-amber-500/[0.15] transition-colors shrink-0",onClick:async()=>{try{await r(t,"daemon_upgrade",{})}catch{}},children:["🔄 Update to v",u.serverVersion]}),m.p2p.available&&e.jsxs("span",{className:"px-1.5 py-px rounded text-[9px] font-semibold",style:{background:m.p2p.state==="connected"?"rgba(34,197,94,0.08)":"rgba(234,179,8,0.08)",color:m.p2p.state==="connected"?"#22c55e":"#eab308"},children:["P2P ",m.p2p.state==="connected"?`● ${m.p2p.peers}`:"○"]}),m.cdpConnected&&e.jsx("span",{className:"px-1.5 py-px rounded text-[9px] font-semibold bg-green-500/[0.08] text-green-500 shrink-0",children:"CDP ●"}),m.machineNickname&&e.jsxs("span",{className:"text-text-muted opacity-80 shrink-0",children:["(",m.hostname,")"]})]})]})]})}),e.jsx("div",{className:"machine-tabs w-full overflow-x-auto overflow-y-hidden pb-1 -mb-1 mt-2",children:O.map(v=>e.jsxs("button",{onClick:()=>x(v.id),className:`machine-tab shrink-0${o===v.id?" active":""}`,children:[v.label,v.count!==void 0&&e.jsx("span",{className:"tab-count",children:v.count})]},v.id))})]}),e.jsxs("div",{className:"page-content",children:[o==="overview"&&e.jsx(Fr,{machine:m,managedIdes:A,managedClis:_,managedAcps:j,actions:p}),o==="ides"&&e.jsx(Wt,{category:"ide",machine:m,machineId:t,providers:l,managedEntries:A,getIcon:h,actions:p,sendDaemonCommand:r}),o==="clis"&&e.jsx(Wt,{category:"cli",machine:m,machineId:t,providers:l,managedEntries:_,getIcon:h,actions:p}),o==="acps"&&e.jsx(Wt,{category:"acp",machine:m,machineId:t,providers:l,managedEntries:j,getIcon:h,actions:p}),o==="providers"&&e.jsx(Vr,{machineId:t,providers:l,sendDaemonCommand:r}),o==="logs"&&e.jsx(Xr,{machineId:t,sendDaemonCommand:r})]}),p.launchPick&&m&&e.jsx(qr,{machine:m,launchPick:p.launchPick,actions:p})]})}function Jr(){const[t,s]=n.useState({ide:[],cli:[],ext:[],acp:[]}),[r,a]=n.useState(!0);n.useEffect(()=>{fetch("https://raw.githubusercontent.com/vilmire/adhdev-providers/main/registry.json").then(o=>o.json()).then(o=>{const x=[],d=[],p=[],u=[];Object.values(o.providers||{}).forEach(g=>{const h={name:g.name||"Unknown",status:g.status||"Stable",details:g.details||"Community Provider"};g.category==="ide"?x.push(h):g.category==="cli"?d.push(h):g.category==="extension"?p.push(h):g.category==="acp"&&u.push(h)});const l=(g,h)=>{const m={Stable:1,Beta:2,WIP:3},A=m[g.status]||99,_=m[h.status]||99;return A!==_?A-_:g.name.localeCompare(h.name)};s({ide:x.sort(l),cli:d.sort(l),ext:p.sort(l),acp:u.sort(l)})}).catch(o=>console.error("Failed to load capabilities:",o)).finally(()=>a(!1))},[]);const i=o=>o==="Stable"?e.jsxs("div",{className:"flex items-center gap-1.5 text-success",children:[e.jsx(fn,{className:"w-4 h-4"})," ",e.jsx("span",{children:"Stable"})]}):o==="Beta"?e.jsxs("div",{className:"flex items-center gap-1.5 text-warning",children:[e.jsx(Xt,{className:"w-4 h-4"})," ",e.jsx("span",{children:"Beta"})]}):e.jsxs("div",{className:"flex items-center gap-1.5 text-text-muted",children:[e.jsx(Ss,{className:"w-4 h-4"})," ",e.jsx("span",{children:o})]}),c=o=>e.jsx("div",{className:"bg-bg-panel border border-border-card rounded-md overflow-hidden",children:e.jsxs("table",{className:"w-full text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-bg-subtle border-b border-border-card text-xs uppercase text-text-muted font-medium tracking-wider",children:[e.jsx("th",{className:"py-3 px-4 w-1/3",children:"Target"}),e.jsx("th",{className:"py-3 px-4 w-1/4",children:"Status"}),e.jsx("th",{className:"py-3 px-4",children:"Details"})]})}),e.jsx("tbody",{className:"divide-y divide-border-card text-sm",children:o.map((x,d)=>e.jsxs("tr",{className:"hover:bg-bg-subtle/50 transition-colors",children:[e.jsx("td",{className:"py-3 px-4 font-medium text-text-main",children:x.name}),e.jsx("td",{className:"py-3 px-4",children:i(x.status)}),e.jsx("td",{className:"py-3 px-4 text-text-muted",children:x.details})]},d))})]})});return r?e.jsxs("div",{className:"p-8 max-w-4xl mx-auto flex flex-col items-center justify-center min-h-[50vh]",children:[e.jsx("div",{className:"w-8 h-8 border-4 border-accent border-t-transparent rounded-full animate-spin mb-4"}),e.jsx("p",{className:"text-text-muted",children:"Loading providers registry..."})]}):e.jsxs("div",{className:"p-8 max-w-4xl mx-auto animate-fade-in pb-20",children:[e.jsx(Ds,{title:"Capabilities & Provider Status",subtitle:"Support matrix for IDEs, CLI Agents, and AI Extensions",icon:e.jsx(Ns,{})}),e.jsxs("div",{className:"space-y-12 mt-8",children:[e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("div",{className:"p-2 rounded-md bg-blue-500/10 text-blue-400",children:e.jsx(ot,{className:"w-5 h-5"})}),e.jsx("h2",{className:"text-xl font-semibold text-text-main tracking-tight",children:"IDE Support"})]}),c(t.ide)]}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("div",{className:"p-2 rounded-md bg-purple-500/10 text-purple-400",children:e.jsx(qt,{className:"w-5 h-5"})}),e.jsx("h2",{className:"text-xl font-semibold text-text-main tracking-tight",children:"Standalone CLI Agents"})]}),c(t.cli)]}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("div",{className:"p-2 rounded-md bg-green-500/10 text-green-400",children:e.jsx(bt,{className:"w-5 h-5"})}),e.jsx("h2",{className:"text-xl font-semibold text-text-main tracking-tight",children:"AI Extensions"})]}),c(t.ext)]}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("div",{className:"p-2 rounded-md bg-orange-500/10 text-orange-400",children:e.jsx(bt,{className:"w-5 h-5"})}),e.jsxs("h2",{className:"text-xl font-semibold text-text-main tracking-tight",children:["ACP Agents (",t.acp.length," loaded)"]})]}),c(t.acp)]})]})]})}class Zr{constructor(){Ee(this,"adapters",new Map);Ee(this,"states",new Map);Ee(this,"ptyCallbacks",new Set);Ee(this,"screenshotCallbacks",new Map);Ee(this,"statusCallbacks",new Set)}resolveDaemonId(s){if(this.adapters.has(s))return s;if(s.startsWith("standalone")){for(const r of this.adapters.keys())if(r.startsWith("standalone"))return r}return null}register(s,r){this.adapters.set(s,r),this.states.set(s,r.connectionState)}unregister(s){this.adapters.delete(s),this.states.delete(s)}setState(s,r){this.states.set(s,r)}retryConnection(s){}get(s){const r=this.resolveDaemonId(s);return r?this.adapters.get(r):void 0}getState(s){const r=this.resolveDaemonId(s);return r&&this.states.get(r)||"disconnected"}sendData(s,r){return!1}sendPtyInput(s,r,a){return!1}sendPtyResize(s,r,a,i){return!1}async requestChatHistory(s,r,a,i,c){return{messages:[],hasMore:!1}}onScreenshot(s,r){return this.screenshotCallbacks.set(s,r),()=>{this.screenshotCallbacks.delete(s)}}emitScreenshot(s,r){this.screenshotCallbacks.forEach(a=>a(s,r))}onStatus(s){return this.statusCallbacks.add(s),()=>{this.statusCallbacks.delete(s)}}emitStatus(s,r){this.statusCallbacks.forEach(a=>a(s,r))}onPtyOutput(s){return this.ptyCallbacks.add(s),()=>{this.ptyCallbacks.delete(s)}}emitPtyOutput(s,r){this.ptyCallbacks.forEach(a=>a(s,r))}}const Je=new Zr;function Qr(){if(typeof window>"u")return"ws://localhost:3847/ws";const s=`${window.location.protocol==="https:"?"wss":"ws"}://${window.location.host}/ws`,a=new URLSearchParams(window.location.search).get("token");return a?`${s}?token=${encodeURIComponent(a)}`:s}const hs=Qr(),fs=3e3,ea=3e4;let Ze=null,ta=0;const At=new Map;let rt=null,ft=null;async function Tt(t,s,r){const a=Ze;if(a&&a.readyState===WebSocket.OPEN){const c=`req_${++ta}_${Date.now()}`;return new Promise((o,x)=>{const d=setTimeout(()=>{At.delete(c),x(new Error(`WS command timeout: ${s}`))},3e4);At.set(c,{resolve:p=>{clearTimeout(d),o(p)},reject:p=>{clearTimeout(d),x(p)}}),a.send(JSON.stringify({type:"command",requestId:c,data:{type:s,payload:r||{},target:t}}))})}const i=await fetch("/api/v1/command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:s,payload:r||{},target:t})});if(!i.ok)throw new Error(`HTTP ${i.status}`);return i.json()}class sa{constructor(s){Ee(this,"daemonId");Ee(this,"screenshotIdeType",null);this.daemonId=s}get hasCommandChannel(){return(Ze==null?void 0:Ze.readyState)===WebSocket.OPEN}get connectionState(){return(Ze==null?void 0:Ze.readyState)===WebSocket.OPEN?"connected":"disconnected"}async sendCommand(s,r){return Tt(this.daemonId,s,r)}async sendInput(s,r){const a=this.screenshotIdeType?`${this.daemonId}:ide:${this.screenshotIdeType}`:this.daemonId;return Tt(a,"cdp_remote_action",{action:s,params:r})}startScreenshots(s){this.screenshotIdeType=s||null,rt&&(clearInterval(rt),rt=null);const r=async()=>{if(this.hasCommandChannel)try{const a=this.screenshotIdeType?`${this.daemonId}:ide:${this.screenshotIdeType}`:this.daemonId,i=await Tt(a,"screenshot",{width:1280});if(i!=null&&i.success&&(i!=null&&i.base64)){const c=await fetch(`data:image/jpeg;base64,${i.base64}`).then(o=>o.blob());Je.emitScreenshot(this.daemonId,c)}}catch{}};r(),rt=setInterval(r,2e3)}stopScreenshots(s){rt&&(clearInterval(rt),rt=null)}}let tt=null;function na(t){return(!tt||tt.daemonId!==t)&&(tt=new sa(t)),tt}function ra({children:t}){const s=n.useRef(Qt()),r=Qt();s.current=r;const{setUserName:a}=gt(),i=n.useRef(a);i.current=a;const[,c]=n.useState("disconnected"),o=n.useCallback((l,g)=>{c(l),ft==null||ft(l,g)},[]),x=n.useRef(null),d=n.useRef(),p=n.useRef(fs),u=n.useRef(!0);return n.useEffect(()=>{u.current=!0;function l(){var m,A;if(!u.current||((m=x.current)==null?void 0:m.readyState)===WebSocket.OPEN||((A=x.current)==null?void 0:A.readyState)===WebSocket.CONNECTING)return;o("connecting"),console.log(`[Standalone WS] Connecting to ${hs}...`);let h;try{h=new WebSocket(hs)}catch(_){console.error("[Standalone WS] Failed to create WebSocket:",_),g();return}x.current=h,h.onopen=()=>{if(!u.current){h.close();return}o("connected"),p.current=fs,console.log("[Standalone WS] Connected")},Ze=h,h.onmessage=_=>{var j;try{const w=JSON.parse(_.data);if((w.type==="command_result"||w.type==="error")&&w.requestId){const O=At.get(w.requestId);O&&(At.delete(w.requestId),w.type==="error"?O.reject(new Error(((j=w.data)==null?void 0:j.message)||"Command failed")):O.resolve(w.data));return}if(w.type==="pty_output"){Je.emitPtyOutput(w.cliId,w.data);return}if(w.type==="status"||w.type==="initial_state"){const O=w.data;if(!O)return;const{injectEntries:B,markLoaded:$}=s.current,C=O.id||"standalone",W=na(C);Je.register(C,W),Je.setState(C,"connected"),o("connected",C),Je.emitStatus(C,O);const S=Vn(O,{daemonId:C});S.length>0&&B(S),$(),O.userName&&i.current&&i.current(O.userName)}}catch(w){console.error("[Standalone WS] Parse error:",w)}},h.onclose=()=>{u.current&&(tt&&Je.setState(tt.daemonId,"disconnected"),o("disconnected"),x.current=null,g())},h.onerror=_=>{console.warn("[Standalone WS] Error, will reconnect:",_)}}function g(){if(!u.current)return;clearTimeout(d.current);const h=p.current;console.log(`[Standalone WS] Reconnecting in ${h}ms...`),d.current=setTimeout(()=>{p.current=Math.min(p.current*1.5,ea),l()},h)}return l(),()=>{u.current=!1,clearTimeout(d.current),x.current&&(x.current.onclose=null,x.current.close(),x.current=null,Ze=null),tt&&Je.unregister(tt.daemonId)}},[]),e.jsx(e.Fragment,{children:t})}function aa({children:t}){const[s,r]=n.useState("disconnected"),[a,i]=n.useState(null);n.useEffect(()=>(ft=(o,x)=>{r(o),x&&i(x)},()=>{ft=null}),[]);const c=n.useMemo(()=>{const o=s==="connected",x={};return a&&(x[a]=o?"connected":"connecting"),x.standalone=o?"connected":"connecting",{wsStatus:s,isConnected:o,connectionStates:x}},[s,a]);return e.jsx(an,{connectionOverrides:c,children:e.jsx(ra,{children:t})})}const oa=[{id:"dashboard",path:"/dashboard",icon:e.jsx(un,{}),label:"Dashboard"},{id:"capabilities",path:"/capabilities",icon:e.jsx(Ns,{}),label:"Capabilities"},{id:"machine",path:"/machines",icon:e.jsx(xn,{}),label:"Burrow"},{id:"settings",path:"/settings",icon:e.jsx(Vt,{}),label:"Settings"}];function ia({children:t}){const s=vt(),r=Js(),[a,i]=n.useState(!1),[c,o]=n.useState(()=>{try{return localStorage.getItem("sidebar-collapsed")==="1"}catch{return!1}}),x=u=>{s(u),i(!1)},d=()=>{o(u=>{const l=!u;try{localStorage.setItem("sidebar-collapsed",l?"1":"0")}catch{}return l})},p=u=>`nav-item${r.pathname.startsWith(u)?" active":""} cursor-pointer ${c?"justify-center py-2.5 px-0":""}`;return e.jsxs("div",{className:`app-layout${a?" mobile-menu-open":""}${c?" sidebar-collapsed":""}`,children:[e.jsxs("button",{type:"button",className:"mobile-menu-btn","aria-label":"Open menu",onClick:()=>i(!0),children:[e.jsx("span",{className:"mobile-menu-icon"}),e.jsx("span",{className:"mobile-menu-icon"}),e.jsx("span",{className:"mobile-menu-icon"})]}),a&&e.jsx("div",{className:"sidebar-overlay",role:"button",tabIndex:0,"aria-label":"Close menu",onClick:()=>i(!1),onKeyDown:u=>u.key==="Escape"&&i(!1)}),e.jsxs("aside",{className:`sidebar ${a?"sidebar-open":""}`,children:[e.jsxs("div",{className:"sidebar-header",children:[e.jsxs("div",{className:`sidebar-logo ${c?"justify-center gap-0":""}`,children:[e.jsx("img",{src:"/otter-logo.png",alt:"ADHDev",className:"w-7 h-7"}),!c&&e.jsx("span",{children:"ADHDev"})]}),e.jsx("button",{type:"button",className:"sidebar-close-btn","aria-label":"Close menu",onClick:()=>i(!1),children:"✕"})]}),e.jsx("nav",{className:"sidebar-nav",children:oa.map(u=>e.jsxs("div",{className:p(u.path),id:`nav-${u.id}`,onClick:()=>x(u.path),title:c?u.label:void 0,children:[e.jsx("span",{className:"nav-icon",children:u.icon}),!c&&u.label]},u.id))}),e.jsxs("div",{className:"border-t border-border-subtle pt-4 mt-2",children:[e.jsxs("div",{className:`nav-item cursor-pointer${r.pathname==="/about"?" active":""} ${c?"justify-center py-2.5 px-0":""}`,id:"nav-about",onClick:()=>s("/about"),title:c?"About":void 0,children:[e.jsx("span",{className:"nav-icon",children:e.jsx(hn,{})}),!c&&"About"]}),!c&&e.jsxs("div",{className:"px-3 py-2 text-xs text-text-muted",children:["Selfhost v","0.6.69"]}),e.jsxs("div",{className:`nav-item cursor-pointer ${c?"justify-center py-2.5 px-0":"mt-1"}`,onClick:d,title:c?"Expand sidebar":"Collapse sidebar",children:[e.jsx("span",{className:"nav-icon text-base",children:c?"›":"‹"}),!c&&e.jsx("span",{className:"text-xs",children:"Collapse"})]})]})]}),e.jsx("main",{className:"main-content relative",children:e.jsx("div",{className:"main-content-inner",children:t})})]})}const ca=[{icon:"🏠",title:"Local-first",desc:"Everything runs on your machine. No data leaves your network. Full privacy by design."},{icon:"💬",title:"Agent chat relay",desc:"Read and respond to AI conversations in real-time across all connected IDEs."},{icon:"📸",title:"Live screenshots",desc:"View your IDE screens directly in the browser via local WebSocket streaming."},{icon:"🎛️",title:"Remote control",desc:"Click, type, and interact with your IDE from the dashboard — no window switching."},{icon:"🔌",title:"Multi-IDE support",desc:"Monitor and control multiple IDEs simultaneously — VS Code, Cursor, Windsurf, and more."},{icon:"⚡",title:"Extension agents",desc:"Manage extension-based agents like Cline and Roo Code alongside native IDE agents."}],la=[{icon:"🌍",title:"Access from anywhere",desc:"Control your agents from any device, any network. No VPN or port forwarding needed."},{icon:"🔗",title:"WebRTC P2P streaming",desc:"End-to-end encrypted peer-to-peer connection for zero-latency remote screenshots and control."},{icon:"📱",title:"Mobile notifications",desc:"Get push notifications when agents need approval. Quick approve/reject from your phone."},{icon:"📡",title:"REST API access",desc:"Integrate with Slack, CI/CD pipelines, or custom tools. Scoped API keys with granular permissions."},{icon:"👥",title:"Team dashboard",desc:"Share a unified view across your team. See who's running what, where, in real time."},{icon:"🔐",title:"Enterprise security",desc:"SSO, RBAC, audit logs, and SLA guarantees for production teams."}],da=[{feature:"Agent chat relay",selfhost:!0,cloud:!0},{feature:"Live IDE screenshots",selfhost:!0,cloud:!0},{feature:"Remote IDE control",selfhost:!0,cloud:!0},{feature:"Multi-IDE monitoring",selfhost:!0,cloud:!0},{feature:"Extension agent support",selfhost:!0,cloud:!0},{feature:"CLI agent support",selfhost:!0,cloud:!0},{feature:"Access from any network",selfhost:!1,cloud:!0},{feature:"WebRTC P2P streaming",selfhost:!1,cloud:!0},{feature:"Mobile push notifications",selfhost:!1,cloud:!0},{feature:"REST API & webhooks",selfhost:!1,cloud:!0},{feature:"Team collaboration",selfhost:!1,cloud:!0},{feature:"Multi-machine (Burrows)",selfhost:!1,cloud:!0},{feature:"SSO / RBAC / Audit logs",selfhost:!1,cloud:!0}];function ua(){return e.jsxs("div",{className:"py-8 px-6 max-w-[860px] mx-auto text-text-primary",children:[e.jsxs("div",{className:"text-center mb-10",children:[e.jsx("img",{src:"/otter-logo.png",alt:"ADHDev",className:"w-14 h-14 mb-3 mx-auto"}),e.jsx("h1",{className:"text-[26px] font-extrabold mb-1.5 text-text-primary",children:"ADHDev"}),e.jsx("p",{className:"text-[13px] text-text-muted",children:"Agent Dashboard Hub for Dev — Self-hosted Edition"}),e.jsxs("div",{className:"inline-block mt-3 px-3 py-1 text-[11px] font-semibold tracking-wide rounded-full bg-emerald-500/10 text-emerald-500 border border-emerald-500/20",children:["SELFHOST v","0.6.69"]})]}),e.jsxs("section",{className:"mb-10",children:[e.jsxs("h2",{className:"text-lg font-bold mb-4 flex items-center gap-2",children:[e.jsx("span",{className:"text-base",children:"✅"})," What's included"]}),e.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(250px,1fr))] gap-3",children:ca.map(t=>e.jsxs("div",{className:"bg-bg-glass border border-border-subtle rounded-xl px-4 py-4 transition-colors hover:border-border-default",children:[e.jsx("div",{className:"text-xl mb-1.5",children:t.icon}),e.jsx("div",{className:"font-semibold text-[13px] mb-1",children:t.title}),e.jsx("div",{className:"text-[12px] text-text-muted leading-relaxed",children:t.desc})]},t.title))})]}),e.jsxs("section",{className:"mb-10",children:[e.jsx("h2",{className:"text-lg font-bold mb-4",children:"Compatible with"}),e.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(180px,1fr))] gap-5",children:[{label:"IDEs",items:$s.map(t=>t.name)},{label:"Extension agents",items:Rs.map(t=>t.name)},{label:"CLI agents",items:_s.map(t=>t.name)}].map(t=>e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] font-bold tracking-wider text-text-muted mb-2 uppercase",children:t.label}),e.jsx("div",{className:"flex flex-col gap-1",children:t.items.map(s=>e.jsx("div",{className:"text-[12px] px-2.5 py-1.5 bg-bg-glass rounded-md border border-border-subtle",children:s},s))})]},t.label))})]}),e.jsxs("section",{className:"mb-10",children:[e.jsxs("h2",{className:"text-lg font-bold mb-4 flex items-center gap-2",children:[e.jsx("span",{className:"text-base",children:"⚖️"})," Self-hosted vs Cloud"]}),e.jsx("div",{className:"rounded-xl border border-border-subtle overflow-hidden",children:e.jsxs("table",{className:"w-full text-[13px]",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-bg-secondary",children:[e.jsx("th",{className:"text-left px-4 py-2.5 font-semibold text-text-muted text-[11px] uppercase tracking-wider",children:"Feature"}),e.jsx("th",{className:"text-center px-4 py-2.5 font-semibold text-text-muted text-[11px] uppercase tracking-wider w-[100px]",children:"Selfhost"}),e.jsx("th",{className:"text-center px-4 py-2.5 font-semibold text-[11px] uppercase tracking-wider w-[100px] text-violet-500",children:"Cloud"})]})}),e.jsx("tbody",{children:da.map((t,s)=>e.jsxs("tr",{className:s%2===0?"bg-bg-glass":"",children:[e.jsx("td",{className:"px-4 py-2 text-text-secondary",children:t.feature}),e.jsx("td",{className:"text-center px-4 py-2",children:t.selfhost?e.jsx("span",{className:"text-emerald-500",children:"✓"}):e.jsx("span",{className:"text-text-muted opacity-40",children:"—"})}),e.jsx("td",{className:"text-center px-4 py-2",children:e.jsx("span",{className:"text-emerald-500",children:"✓"})})]},t.feature))})]})})]}),e.jsx("section",{className:"mb-10",children:e.jsx("div",{className:"rounded-2xl border border-violet-500/20 bg-violet-500/[0.04] px-6 py-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"text-3xl shrink-0",children:"🚀"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-bold text-[15px] mb-1.5",children:"Unlock more with ADHDev Cloud"}),e.jsx("p",{className:"text-[13px] text-text-muted leading-relaxed mb-4",children:"Access your agents from anywhere — your phone, another laptop, or a coffee shop. Cloud adds WebRTC P2P streaming, mobile push notifications, REST API, team collaboration, and multi-machine support. Your local setup stays exactly the same."}),e.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(220px,1fr))] gap-2.5 mb-5",children:la.map(t=>e.jsxs("div",{className:"flex gap-2.5 items-start",children:[e.jsx("span",{className:"text-base shrink-0 mt-0.5",children:t.icon}),e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-[12px]",children:t.title}),e.jsx("div",{className:"text-[11px] text-text-muted leading-snug",children:t.desc})]})]},t.title))}),e.jsxs("div",{className:"flex gap-3 flex-wrap",children:[e.jsx("a",{href:"https://adhf.dev",target:"_blank",rel:"noopener noreferrer",className:"btn btn-primary btn-sm inline-flex items-center gap-1.5 no-underline",children:"Try ADHDev Cloud →"}),e.jsx("a",{href:"https://github.com/vilmire/adhdev",target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm inline-flex items-center gap-1.5 no-underline",children:"GitHub"}),e.jsx("a",{href:"https://discord.gg/WJD3tCfBzk",target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm inline-flex items-center gap-1.5 no-underline",children:"Discord"})]})]})]})})}),e.jsxs("div",{className:"text-center text-xs text-text-muted pt-4 border-t border-border-subtle",children:[e.jsx("p",{children:"© 2026 RacoLab · ADHDev, Your AI sidekick otter 🦦"}),e.jsx("p",{className:"mt-1 opacity-60",children:"Self-hosted edition — all data stays on your machine"})]})]})}function xa(){const{ides:t}=gt(),s=t.find(l=>l.type==="adhdev-daemon"),r=(s==null?void 0:s.detectedIdes)||[],{sendCommand:a}=st(),{userName:i}=gt(),[c,o]=n.useState(i||"");n.useEffect(()=>{i!==void 0&&o(i)},[i]);const x=l=>{const g=l.target.value.trim();s!=null&&s.id&&g!==i&&a(s.id,"set_user_name",{userName:g}).catch(console.error)},[d,p]=n.useState(()=>{try{return localStorage.getItem("adhdev_sound")!=="0"}catch{return!0}}),u=l=>{p(l);try{localStorage.setItem("adhdev_sound",l?"1":"0")}catch{}};return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx(Ds,{icon:e.jsx(Vt,{className:"text-text-primary"}),title:"Settings",subtitle:"Local daemon configuration & preferences"}),e.jsxs("div",{className:"page-content",children:[e.jsx(ct,{title:"Daemon",className:"mb-4",children:e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-x-4 gap-y-2.5 text-sm",children:[e.jsx("span",{className:"text-text-muted",children:"Version"}),e.jsxs("span",{className:"font-mono text-xs",children:["v","0.6.69"]}),e.jsx("span",{className:"text-text-muted",children:"Status"}),e.jsx("span",{className:s?"text-green-400":"text-yellow-400",children:s?"● Running":"○ Not connected"}),e.jsx("span",{className:"text-text-muted",children:"WebSocket"}),e.jsx("span",{className:"font-mono text-xs",children:"ws://localhost:19222"}),e.jsx("span",{className:"text-text-muted",children:"HTTP"}),e.jsx("span",{className:"font-mono text-xs",children:"http://localhost:19280"})]})}),e.jsx(ct,{title:"Detected IDEs",className:"mb-4",children:r.length===0?e.jsx("p",{className:"text-sm text-text-muted",children:"No IDEs detected. Start an IDE to see it here."}):e.jsx("div",{className:"flex flex-col gap-1.5",children:r.map(l=>e.jsxs("div",{className:"flex justify-between items-center bg-bg-glass rounded-lg px-3.5 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${l.running?"bg-green-400":"bg-text-muted/30"}`}),e.jsx("span",{className:"text-sm font-medium",children:l.name})]}),e.jsx("span",{className:"text-[11px] text-text-muted font-mono",children:l.type})]},l.type))})}),e.jsx(ct,{title:"Machine",className:"mb-4",children:e.jsx(ur,{ides:t,emptyMessage:"Daemon not connected. Run 'adhdev-standalone' to start."})}),e.jsx(ct,{title:"Theme",className:"mb-4",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-text-muted mb-2 font-medium",children:"Site theme"}),e.jsx(hr,{})]}),e.jsxs("div",{className:"border-t border-border-subtle pt-4",children:[e.jsx("div",{className:"text-xs text-text-muted mb-2 font-medium",children:"Chat theme"}),e.jsx(vr,{})]}),e.jsxs("div",{className:"border-t border-border-subtle pt-4",children:[e.jsx("div",{className:"text-xs text-text-muted mb-2 font-medium",children:"Accent color"}),e.jsx(Ir,{})]})]})}),e.jsx(ct,{title:"Notifications",className:"mb-4",children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(dr,{}),e.jsx(lt,{label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(In,{size:15})," Sound Effects"]}),description:"Play a sound when agent completes or needs approval",checked:d,onChange:u})]})}),e.jsx(ct,{title:"Preferences",className:"mb-4",children:e.jsx("div",{className:"flex flex-col gap-3",children:e.jsxs("div",{className:"flex items-center justify-between px-3.5 py-4 bg-bg-glass rounded-xl border border-border-subtle hover:border-border-default transition-colors",children:[e.jsxs("div",{className:"flex flex-col gap-1 pr-4 max-w-[500px]",children:[e.jsxs("span",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(mn,{size:16,className:"text-text-secondary"})," Display Name"]}),e.jsx("span",{className:"text-[12px] text-text-muted leading-relaxed",children:"Your name shown in chat threads and on the team dashboard."})]}),e.jsx("input",{type:"text",className:"bg-bg-primary border border-border-strong rounded-lg px-3 py-1.5 text-sm w-48 text-right focus:border-accent focus:outline-none transition-colors",placeholder:"Anonymous",value:c,onChange:l=>o(l.target.value),onBlur:x,onKeyDown:l=>{l.key==="Enter"&&l.currentTarget.blur()}})]})})})]})]})}yr();function gs(){const{ides:t}=gt(),s=t.find(r=>{var a;return r.daemonMode||((a=r.id)==null?void 0:a.startsWith("standalone"))});return s?e.jsx(St,{to:`/machines/${s.id}`,replace:!0}):t.length>0?e.jsx(St,{to:`/machines/${t[0].id}`,replace:!0}):e.jsx(St,{to:"/dashboard",replace:!0})}function ma(){return e.jsx(Zs,{children:e.jsx(aa,{children:e.jsx(dn,{value:{sendCommand:Tt,sendData:()=>!1},children:e.jsx(ia,{children:e.jsxs(Qs,{children:[e.jsx(qe,{path:"/dashboard",element:e.jsx(Br,{})}),e.jsx(qe,{path:"/ide/:id",element:e.jsx(Or,{})}),e.jsx(qe,{path:"/machine",element:e.jsx(gs,{})}),e.jsx(qe,{path:"/machines/:id",element:e.jsx(Gr,{})}),e.jsx(qe,{path:"/machines",element:e.jsx(gs,{})}),e.jsx(qe,{path:"/capabilities",element:e.jsx(Jr,{})}),e.jsx(qe,{path:"/about",element:e.jsx(ua,{})}),e.jsx(qe,{path:"/settings",element:e.jsx(xa,{})}),e.jsx(qe,{path:"*",element:e.jsx(St,{to:"/dashboard",replace:!0})})]})})})})})}Bn({connectionManager:Je,p2pManager:Je});en(document.getElementById("root")).render(e.jsx(n.StrictMode,{children:e.jsx(ma,{})}));
|