import{r as o,j as e}from"./index-O10mMXon.js";import{S as h}from"./StatusPill-BQDH7DOd.js";import{m as g}from"./proxy-f2AL6wTO.js";function f({agents:t,className:u=""}){var p;const[a,l]=o.useState(((p=t[0])==null?void 0:p.id)??"");o.useEffect(()=>{if(!t.length){l("");return}t.find(s=>s.id===a)||l(t[0].id)},[t,a]);const{roots:x,byParent:j}=o.useMemo(()=>{const s=new Map;for(const d of t){const i=d.parentId??"__root__",c=s.get(i)??[];c.push(d),s.set(i,c)}return{roots:s.get("__root__")??[],byParent:s}},[t]),n=t.find(s=>s.id===a)??t[0],r=(n==null?void 0:n.work)??{done:[],doing:[],todo:[]},m=(s,d)=>{const i=s.id===a,c=j.get(s.id)??[];return e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>l(s.id),className:`flex w-full items-center justify-between rounded-xl border px-3 py-2 text-left text-xs transition ${i?"border-neon-cyan/60 bg-neon-cyan/10":"border-neon-cyan/15 bg-bg-800/60 hover:border-neon-cyan/35"}`,style:{marginLeft:d*14},children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] uppercase tracking-[0.3em] text-neon-cyan/70",children:s.name}),e.jsx("div",{className:"text-[10px] text-muted",children:s.role||"Agent"})]}),e.jsx(h,{label:s.status,status:s.status})]}),c.length>0&&e.jsx("div",{className:"mt-2 space-y-2 border-l border-neon-cyan/15 pl-3",children:c.map(b=>m(b,d+1))})]},s.id)};return e.jsxs(g.section,{className:`hud-panel rounded-2xl p-4 ${u}`,initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.6,delay:.1},children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"font-display text-base text-neon-cyan",children:"Agent Tree"}),e.jsx("span",{className:"text-xs uppercase tracking-[0.3em] text-neon-cyan/60",children:"Hierarchy"})]}),e.jsxs("div",{className:"mt-4 grid gap-3 lg:grid-cols-[0.9fr_1.1fr]",children:[e.jsx("div",{className:"space-y-2",children:x.length>0?x.map(s=>m(s,0)):e.jsx("div",{className:"rounded-xl border border-neon-cyan/15 bg-bg-800/60 p-3 text-xs text-muted",children:"Aucun agent détecté."})}),e.jsx("div",{className:"rounded-2xl border border-neon-cyan/15 bg-bg-800/60 p-3",children:n?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.3em] text-neon-cyan/70",children:n.name}),e.jsx("div",{className:"text-[10px] text-muted",children:n.role||"Agent"})]}),e.jsx(h,{label:n.status,status:n.status})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-[10px] uppercase tracking-[0.3em] text-neon-cyan/60",children:[e.jsxs("div",{className:"rounded-lg border border-emerald-400/20 bg-emerald-500/10 p-2 text-center",children:["Déjà fait",e.jsx("div",{className:"mt-1 text-sm text-emerald-200",children:r.done.length})]}),e.jsxs("div",{className:"rounded-lg border border-amber-400/20 bg-amber-500/10 p-2 text-center",children:["En cours",e.jsx("div",{className:"mt-1 text-sm text-amber-200",children:r.doing.length})]}),e.jsxs("div",{className:"rounded-lg border border-sky-400/20 bg-sky-500/10 p-2 text-center",children:["À faire",e.jsx("div",{className:"mt-1 text-sm text-sky-200",children:r.todo.length})]})]}),e.jsxs("div",{className:"grid gap-2 md:grid-cols-3",children:[e.jsxs("div",{className:"rounded-lg border border-neon-cyan/10 bg-bg-900/40 p-2",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-[0.3em] text-neon-cyan/50",children:"Déjà fait"}),e.jsx("ul",{className:"mt-2 space-y-1 text-[11px] text-muted",children:r.done.length?r.done.map(s=>e.jsxs("li",{children:["• ",s]},s)):e.jsx("li",{children:"—"})})]}),e.jsxs("div",{className:"rounded-lg border border-neon-cyan/10 bg-bg-900/40 p-2",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-[0.3em] text-neon-cyan/50",children:"En cours"}),e.jsx("ul",{className:"mt-2 space-y-1 text-[11px] text-muted",children:r.doing.length?r.doing.map(s=>e.jsxs("li",{children:["• ",s]},s)):e.jsx("li",{children:"—"})})]}),e.jsxs("div",{className:"rounded-lg border border-neon-cyan/10 bg-bg-900/40 p-2",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-[0.3em] text-neon-cyan/50",children:"À faire"}),e.jsx("ul",{className:"mt-2 space-y-1 text-[11px] text-muted",children:r.todo.length?r.todo.map(s=>e.jsxs("li",{children:["• ",s]},s)):e.jsx("li",{children:"—"})})]})]}),e.jsxs("div",{className:"text-[10px] text-muted",children:["Last seen: ",n.lastSeen]})]}):e.jsx("div",{className:"text-xs text-muted",children:"Sélectionnez un agent."})})]})]})}export{f as AgentMonitor};
