import{a6 as Ae,bd as Le,be as Ue,bf as Fe,r as l,ab as $e,bg as Ge,bh as Ke,bi as qe,bj as ke,bk as Se,bl as Ye,bm as We,bn as Qe,bo as Ze,bp as Je,bq as Xe,br as et,bs as tt,bt as nt,bu as st,bv as K,bw as at,bx as it,by as ot,bz as rt,bA as lt,i as te,k as ne,an as se,bB as Te,bC as ct,bD as U,f as q,bE as ut,bF as dt,bG as mt,j as e,bH as ht,bI as ft,B as I,bJ as pt,d as R,bK as gt,bL as we,bM as Ee,bN as Me,bO as de,bP as xt,bQ as bt,bR as yt,bS as Y,bT as W,Z as De,bU as vt,t as G,bV as jt,bW as Nt,ar as Re,bX as Ct,bY as At,ac as j,bZ as z,b_ as kt,b$ as St,c0 as Tt,c1 as wt,c2 as Et,X as Pe,T as me,c as he,e as fe,c3 as Mt,c4 as Dt,c5 as Rt,c6 as Pt,c7 as It,u as pe,c8 as Ot,c9 as zt,ca as Ht,cb as Vt,cc as H}from"./index-tKq6NBmA.js";import{cd as qn}from"./index-tKq6NBmA.js";import{R as Ie}from"./RightPanelHeader-CT8w2lx-.js";/**
 * @license lucide-react v1.8.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Bt=[["path",{d:"m19 5 3-3",key:"yk6iyv"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z",key:"1snsnr"}]],_t=Ae("unplug",Bt);/**
 * @license lucide-react v1.8.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Lt=[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]],Ut=Ae("wand-sparkles",Lt),Ft=(t,n,s)=>{const a=n-t;return((s-t)%a+a)%a+t};function Oe(t,n){return Le(t)?t[Ft(0,t.length,n)]:t}class $t{constructor(n){this.stop=()=>this.runAll("stop"),this.animations=n.filter(Boolean)}get finished(){return Promise.all(this.animations.map(n=>n.finished))}getAll(n){return this.animations[0][n]}setAll(n,s){for(let a=0;a<this.animations.length;a++)this.animations[a][n]=s}attachTimeline(n){const s=this.animations.map(a=>a.attachTimeline(n));return()=>{s.forEach((a,o)=>{a&&a(),this.animations[o].stop()})}}get time(){return this.getAll("time")}set time(n){this.setAll("time",n)}get speed(){return this.getAll("speed")}set speed(n){this.setAll("speed",n)}get state(){return this.getAll("state")}get startTime(){return this.getAll("startTime")}get duration(){return ge(this.animations,"duration")}get iterationDuration(){return ge(this.animations,"iterationDuration")}runAll(n){this.animations.forEach(s=>s[n]())}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}function ge(t,n){let s=0;for(let a=0;a<t.length;a++){const o=t[a][n];o!==null&&o>s&&(s=o)}return s}class Gt extends $t{then(n,s){return this.finished.finally(n).then(()=>{})}}function Kt(t,n){return t in n}class qt extends Ue{constructor(){super(...arguments),this.type="object"}readValueFromInstance(n,s){if(Kt(s,n)){const a=n[s];if(typeof a=="string"||typeof a=="number")return a}}getBaseTargetFromProps(){}removeValueFromRenderState(n,s){delete s.output[n]}measureInstanceViewportBox(){return Fe()}build(n,s){Object.assign(n.output,s)}renderInstance(n,{output:s}){Object.assign(n,s)}sortInstanceNodePosition(){return 0}}function Yt(t){return l.useEffect(()=>()=>t(),[])}function Wt(){const t=$e(),{reducedMotion:n}=l.useContext(Ge);return n==="never"?!1:n==="always"?!0:t}function ae(t){return typeof t=="object"&&!Array.isArray(t)}function ze(t,n,s,a){return t==null?[]:typeof t=="string"&&ae(n)?Ke(t,s,a):t instanceof NodeList?Array.from(t):Array.isArray(t)?t.filter(o=>o!=null):[t]}function Qt(t,n,s){return t*(n+1)}function xe(t,n,s,a){return typeof n=="number"?n:n.startsWith("-")||n.startsWith("+")?Math.max(0,t+parseFloat(n)):n==="<"?s:n.startsWith("<")?Math.max(0,s+parseFloat(n.slice(1))):a.get(n)??t}function Zt(t,n,s){for(let a=0;a<t.length;a++){const o=t[a];o.at>n&&o.at<s&&(ke(t,o),a--)}}function Jt(t,n,s,a,o,d){Zt(t,o,d);for(let i=0;i<n.length;i++)t.push({value:n[i],at:qe(o,d,a[i]),easing:Oe(s,i)})}function Xt(t,n){for(let s=0;s<t.length;s++)t[s]=t[s]/(n+1)}function en(t,n){return t.at===n.at?t.value===null?1:n.value===null?-1:0:t.at-n.at}const tn="easeInOut";function nn(t,{defaultTransition:n={},...s}={},a,o){const d=n.duration||.3,i=new Map,h=new Map,c={},b=new Map;let f=0,u=0,C=0;for(let S=0;S<t.length;S++){const g=t[S];if(typeof g=="string"){b.set(g,u);continue}else if(!Array.isArray(g)){b.set(g.name,xe(u,g.at,f,b));continue}let[p,x,y={}]=g;y.at!==void 0&&(u=xe(u,y.at,f,b));let N=0;const A=(m,w,E,r=0,k=0)=>{const v=sn(m),{delay:M=0,times:D=Ye(v),type:V=n.type||"keyframes",repeat:T,repeatType:_n,repeatDelay:Ln=0,..._e}=w;let{ease:O=n.ease||"easeOut",duration:P}=w;const ie=typeof M=="function"?M(r,k):M,oe=v.length,re=Ze(V)?V:o==null?void 0:o[V||"keyframes"];if(oe<=2&&re){let B=100;if(oe===2&&rn(v)){const _=v[1]-v[0];B=Math.abs(_)}const F={...n,..._e};P!==void 0&&(F.duration=Je(P));const $=We(F,B,re);O=$.ease,P=$.duration}P??(P=d);const le=u+ie;D.length===1&&D[0]===0&&(D[1]=1);const ce=D.length-v.length;if(ce>0&&Qe(D,ce),v.length===1&&v.unshift(null),T){P=Qt(P,T);const B=[...v],F=[...D];O=Array.isArray(O)?[...O]:[O];const $=[...O];for(let _=0;_<T;_++){v.push(...B);for(let L=0;L<B.length;L++)D.push(F[L]+(_+1)),O.push(L===0?"linear":Oe($,L-1))}Xt(D,T)}const ue=le+P;Jt(E,v,O,D,le,ue),N=Math.max(ie+P,N),C=Math.max(ue,C)};if(Se(p)){const m=be(p,h);A(x,y,ye("default",m))}else{const m=ze(p,x,a,c),w=m.length;for(let E=0;E<w;E++){x=x,y=y;const r=m[E],k=be(r,h);for(const v in x)A(x[v],an(y,v),ye(v,k),E,w)}}f=u,u+=N}return h.forEach((S,g)=>{for(const p in S){const x=S[p];x.sort(en);const y=[],N=[],A=[];for(let r=0;r<x.length;r++){const{at:k,value:v,easing:M}=x[r];y.push(v),N.push(Xe(0,C,k)),A.push(M||"easeOut")}N[0]!==0&&(N.unshift(0),y.unshift(y[0]),A.unshift(tn)),N[N.length-1]!==1&&(N.push(1),y.push(null)),i.has(g)||i.set(g,{keyframes:{},transition:{}});const m=i.get(g);m.keyframes[p]=y;const{type:w,...E}=n;m.transition[p]={...E,duration:C,ease:A,times:N,...s}}}),i}function be(t,n){return!n.has(t)&&n.set(t,{}),n.get(t)}function ye(t,n){return n[t]||(n[t]=[]),n[t]}function sn(t){return Array.isArray(t)?t:[t]}function an(t,n){return t&&t[n]?{...t,...t[n]}:{...t}}const on=t=>typeof t=="number",rn=t=>t.every(on);function ln(t){const n={presenceContext:null,props:{},visualState:{renderState:{transform:{},transformOrigin:{},style:{},vars:{},attrs:{}},latestValues:{}}},s=et(t)&&!tt(t)?new nt(n):new st(n);s.mount(t),K.set(t,s)}function cn(t){const n={presenceContext:null,props:{},visualState:{renderState:{output:{}},latestValues:{}}},s=new qt(n);s.mount(t),K.set(t,s)}function un(t,n){return Se(t)||typeof t=="number"||typeof t=="string"&&!ae(n)}function He(t,n,s,a){const o=[];if(un(t,n))o.push(at(t,ae(n)&&n.default||n,s&&(s.default||s)));else{if(t==null)return o;const d=ze(t,n,a),i=d.length;for(let h=0;h<i;h++){const c=d[h],b=c instanceof Element?ln:cn;K.has(c)||b(c);const f=K.get(c),u={...s};"delay"in u&&typeof u.delay=="function"&&(u.delay=u.delay(h,i)),o.push(...it(f,{...n,transition:u},{}))}}return o}function dn(t,n,s){const a=[],o=t.map(i=>{if(Array.isArray(i)&&typeof i[0]=="function"){const h=i[0],c=ot(0);return c.on("change",h),i.length===1?[c,[0,1]]:i.length===2?[c,[0,1],i[1]]:[c,i[1],i[2]]}return i});return nn(o,n,s,{spring:rt}).forEach(({keyframes:i,transition:h},c)=>{a.push(...He(c,i,h))}),a}function mn(t){return Array.isArray(t)&&t.some(Array.isArray)}function Ve(t={}){const{scope:n,reduceMotion:s}=t;function a(o,d,i){let h=[],c;if(mn(o)){const{onComplete:f,...u}=d||{};typeof f=="function"&&(c=f),h=dn(o,s!==void 0?{reduceMotion:s,...u}:u,n)}else{const{onComplete:f,...u}=i||{};typeof f=="function"&&(c=f),h=He(o,d,s!==void 0?{reduceMotion:s,...u}:u,n)}const b=new Gt(h);return c&&b.finished.then(c),n&&(n.animations.push(b),b.finished.then(()=>{ke(n.animations,b)})),b}return a}Ve();function hn(){const t=lt(()=>({current:null,animations:[]})),n=Wt()??void 0,s=l.useMemo(()=>Ve({scope:t,reduceMotion:n}),[t,n]);return Yt(()=>{t.animations.forEach(a=>a.stop()),t.animations.length=0}),[t,s]}function fn(){const t=te(),n=ne();return se({mutationFn:s=>t.unregisterMeshAgent(s),onSuccess:()=>{n.invalidateQueries({queryKey:["mesh","agents"]})}})}function pn(){const t=te(),n=ne();return se({mutationFn:s=>t.deleteAgentData(s),onSuccess:()=>{n.invalidateQueries({queryKey:["mesh","agents"]}),n.invalidateQueries({queryKey:["mesh","topology"]})}})}function gn(){const t=te(),n=ne();return se({mutationFn:s=>t.clearMeshDenial(s),onSuccess:()=>{n.invalidateQueries({queryKey:["mesh","denied"]})}})}const Be="agent-hub",xn=new Set(["sessions","config"]),bn={overview:"sessions",profile:"sessions",personality:"config",sessions:"sessions",channels:"config",tasks:"sessions",tools:"config"},yn={identity:"sessions",personality:"config",channels:"config",tools:"config"};function vn(t){return t?xn.has(t)?t:bn[t]??"sessions":"sessions"}function jn(){const t=Te({strict:!1}),n=U(d=>d.openHub),s=t.panel===Be,a=vn(t.hubTab),o=t.agentPath??null;l.useEffect(()=>{s&&(o?n(o,a):U.getState().setActiveTab(a))},[s,a,o,n])}function Nn(){const t=Te({strict:!1}),n=ct(),s=!!t.agent,a=t.dialog==="agent",o=s||a;l.useEffect(()=>{if(!o)return;const d=(t.agent?yn[t.agent]:void 0)??"sessions";n({search:h=>{const c={...h};return delete c.agent,delete c.dialog,c.panel=Be,c.hubTab=d,h.agentPath&&(c.agentPath=h.agentPath),c},replace:!0})},[o,t.agent,t.agentPath,t.dialog,n])}function Q({icon:t,title:n,description:s,variant:a="default",onClick:o}){const d=a==="destructive";return e.jsxs("button",{type:"button",onClick:o,className:R("flex w-full items-start gap-3 rounded-lg p-3 text-left transition-colors",d?"hover:bg-destructive/10":"hover:bg-accent"),children:[e.jsx("div",{className:R("flex size-9 shrink-0 items-center justify-center rounded-full",d?"bg-destructive/10":"bg-muted"),children:e.jsx(t,{className:R("size-4",d?"text-destructive":"text-muted-foreground")})}),e.jsxs("div",{className:"min-w-0 pt-0.5",children:[e.jsx("div",{className:R("text-sm font-medium",d&&"text-destructive"),children:n}),e.jsx("div",{className:"text-muted-foreground text-xs leading-relaxed",children:s})]})]})}function Z({title:t,description:n,onBack:s}){return e.jsxs(we,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:s,className:"text-muted-foreground hover:text-foreground -ml-1 rounded-md p-1 transition-colors","aria-label":"Back to actions",children:e.jsx(vt,{className:"size-4"})}),e.jsx(Ee,{children:t})]}),e.jsx(Me,{children:n})]})}function Cn({className:t}){var r;const{agent:n,projectPath:s}=q(),a=fn(),o=ut(),d=dt(),i=gn(),h=pn(),{data:c}=mt(),b=n.isSystem===!0,f=((r=c==null?void 0:c.denied)==null?void 0:r.some(k=>k.path===s))??!1,u=n.displayName??n.name,[C,S]=l.useState(!1),[g,p]=l.useState("actions"),[x,y]=l.useState("");function N(k){S(k),k||(p("actions"),y(""))}function A(){S(!1)}function m(){f?i.mutate(s,{onSuccess:()=>{G.success("Agent unblocked"),A()}}):d.mutate({path:s,reason:"Blocked via Agent Hub"},{onSuccess:()=>{G.success("Agent blocked"),A()}})}function w(){a.mutate(n.id,{onSuccess:()=>{G(`Agent ${u} unregistered`,{action:{label:"Undo",onClick:()=>o.mutate({path:s})},duration:5e3}),A()}})}function E(){h.mutate(n.id,{onSuccess:()=>{G.error(`Deleted ${u} and all data`),A()}})}return e.jsxs(ht,{open:C,onOpenChange:N,children:[e.jsx(ft,{asChild:!0,children:e.jsx(I,{variant:"ghost",size:"sm",className:R("size-7 p-0",t),"aria-label":"Agent management actions",children:e.jsx(pt,{className:"size-4"})})}),e.jsxs(gt,{className:"min-h-0 sm:max-w-md",children:[g==="actions"&&e.jsxs(e.Fragment,{children:[e.jsxs(we,{children:[e.jsxs(Ee,{children:["Manage ",u]}),e.jsx(Me,{className:b?void 0:"sr-only",children:b?"System agents are managed automatically.":"Choose a management action for this agent."})]}),e.jsx(de,{className:"pb-6",children:b?e.jsx("p",{className:"text-muted-foreground py-6 text-center text-sm",children:"System agents cannot be blocked, unregistered, or deleted."}):e.jsxs("div",{className:"space-y-1",children:[e.jsx(Q,{icon:f?xt:bt,title:f?"Unblock":"Block",description:f?"Allow this agent to be discovered again in future scans.":"Hide this agent from future scans. If you remove it later, it won’t be automatically rediscovered.",onClick:()=>p("confirm-block")}),e.jsx(Q,{icon:_t,title:"Unregister",description:"Remove this agent from your list. Your project files stay untouched and you can bring it back by re-scanning.",onClick:()=>p("confirm-unregister")}),e.jsx("div",{className:"mx-3 border-t"}),e.jsx(Q,{icon:yt,title:"Delete Agent & Data",description:"Permanently erase this agent's personality, settings, and custom rules. Your project files are not affected.",variant:"destructive",onClick:()=>p("confirm-delete")})]})})]}),g==="confirm-block"&&e.jsxs(e.Fragment,{children:[e.jsx(Z,{title:`${f?"Unblock":"Block"} ${u}?`,description:f?"This agent’s location will be eligible for discovery again in future scans.":"This agent’s location will be hidden from future scans. If you unregister it later, it won’t be automatically rediscovered. You can unblock it at any time.",onBack:()=>p("actions")}),e.jsxs(Y,{children:[e.jsx(W,{asChild:!0,children:e.jsx(I,{variant:"outline",children:"Cancel"})}),e.jsx(I,{variant:f?"default":"destructive",onClick:m,children:f?"Unblock":"Block"})]})]}),g==="confirm-unregister"&&e.jsxs(e.Fragment,{children:[e.jsx(Z,{title:`Unregister ${u}?`,description:"This agent will disappear from your list and any scheduled tasks will be paused. Your project files stay exactly as they are.",onBack:()=>p("actions")}),e.jsxs(Y,{children:[e.jsx(W,{asChild:!0,children:e.jsx(I,{variant:"outline",children:"Cancel"})}),e.jsx(I,{onClick:w,children:"Unregister"})]})]}),g==="confirm-delete"&&e.jsxs(e.Fragment,{children:[e.jsx(Z,{title:`Delete ${u}?`,description:`This will permanently erase this agent's personality, custom rules, and all settings. Your project files at ${s} are not affected. This cannot be undone.`,onBack:()=>p("actions")}),e.jsx(de,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{htmlFor:"delete-confirm-input",className:"text-sm font-medium",children:["Type ",e.jsx("strong",{children:u})," to confirm"]}),e.jsx(De,{id:"delete-confirm-input","data-testid":"delete-confirm-input",value:x,onChange:k=>y(k.target.value),placeholder:u,autoComplete:"off"})]})}),e.jsxs(Y,{children:[e.jsx(W,{asChild:!0,children:e.jsx(I,{variant:"outline",children:"Cancel"})}),e.jsx(I,{variant:"destructive",disabled:x!==u,onClick:E,children:"Delete Agent & Data"})]})]})]})]})}const An={hidden:{},visible:{transition:{staggerChildren:.06}}},ve={hidden:{opacity:0,y:6},visible:{opacity:1,y:0,transition:{duration:.25,ease:"easeOut"}}},je={hidden:{opacity:0,scale:.85},visible:{opacity:1,scale:1,transition:{type:"spring",stiffness:400,damping:20}}},kn={scale:[1,1.04,1]},Sn={duration:2,repeat:1/0,ease:"easeInOut"};function Tn(t){return t.healthStatus==="active"?{label:"Online",dotClass:"bg-emerald-500"}:{label:"Offline",dotClass:"bg-muted-foreground/40"}}function wn({color:t}){return e.jsx(j.span,{className:"pointer-events-none absolute inset-0 rounded-full",style:{border:`2px solid ${t}`},initial:{scale:1,opacity:.6},animate:{scale:2.4,opacity:0},exit:{opacity:0},transition:{duration:.55,ease:"easeOut"},"aria-hidden":!0})}function En({onAvatarClick:t,onPersonalityClick:n}){const{agent:s,onUpdate:a,previewColor:o,isPickerOpen:d}=q(),i=jt(s),h=o??i.color,c=s,b=Tn(c),f=Nt(),u=l.useRef(h),C=u.current;h!==C&&(u.current=h);const[S,g]=hn(),p=l.useRef({color:i.color,emoji:i.emoji});l.useEffect(()=>{const T=p.current;(T.color!==i.color||T.emoji!==i.emoji)&&(p.current={color:i.color,emoji:i.emoji},g(S.current,{scale:[1,.85,1.08,1],rotate:[0,-3,1,0]},{duration:.4,ease:[.34,1.56,.64,1]}))},[i.color,i.emoji,g,S]);const[x,y]=l.useState(0),N=l.useRef(i.color);l.useEffect(()=>{N.current!==i.color&&(N.current=i.color,y(T=>T+1))},[i.color]);const A=s.traits??Re,m=Ct(A),w=(m==null?void 0:m.colors)??At,[E,r]=l.useState(!1),[k,v]=l.useState(""),M=s.displayName??s.name,D=l.useCallback(()=>{v(M),r(!0)},[M]),V=l.useCallback(()=>{const T=k.trim();T&&T!==M&&a({displayName:T}),r(!1)},[k,M,a]);return e.jsxs(j.div,{"data-slot":"agent-hub-hero",className:"relative flex flex-col items-center gap-1 border-b pb-0",style:{overflow:"hidden"},variants:An,initial:"hidden",animate:"visible",children:[e.jsxs("div",{className:"pointer-events-none absolute inset-0","aria-hidden":!0,children:[e.jsx("div",{className:"absolute inset-0",style:{background:`radial-gradient(ellipse at 50% 40%, ${C}${f.heroGlow} 0%, ${C}${f.heroGlowOuter} 40%, transparent 70%)`}}),e.jsx(z,{mode:"sync",children:e.jsx(j.div,{className:"absolute inset-0",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.5,ease:"easeInOut"},style:{background:`radial-gradient(ellipse at 50% 40%, ${h}${f.heroGlow} 0%, ${h}${f.heroGlowOuter} 40%, transparent 70%)`}},h)})]}),e.jsx("div",{className:"relative z-10 w-full",children:e.jsx(Ie,{actions:e.jsx(Cn,{})})}),e.jsx(j.div,{variants:je,className:"relative z-[1]",children:e.jsxs(j.button,{ref:S,type:"button",className:"group relative cursor-pointer",onClick:t,"aria-label":"Change agent color and icon","data-testid":"avatar-picker-trigger",animate:d?kn:void 0,transition:d?Sn:void 0,children:[e.jsx(kt,{color:h,emoji:i.emoji,size:"lg",healthStatus:c.healthStatus}),e.jsx(z,{children:x>0&&e.jsx(wn,{color:i.color},x)}),e.jsx("span",{className:"bg-background border-background absolute -right-0.5 -bottom-0.5 flex size-6 items-center justify-center rounded-full border-2 opacity-0 shadow-sm transition-opacity group-hover:opacity-100",children:e.jsx(St,{className:"text-muted-foreground size-3"})})]})}),e.jsx(j.div,{className:"relative z-[1] mt-1",variants:ve,children:E?e.jsx(De,{autoFocus:!0,value:k,onChange:T=>v(T.target.value),onBlur:V,onKeyDown:T=>{T.key==="Enter"&&V(),T.key==="Escape"&&r(!1)},className:"h-7 w-40 text-center text-[15px] font-semibold","data-testid":"name-input"}):e.jsx("button",{type:"button",onClick:D,className:R("text-[15px] font-semibold transition-colors","hover:text-muted-foreground cursor-text"),"data-testid":"agent-name",children:M})}),e.jsxs(j.div,{className:"text-muted-foreground relative z-[1] flex items-center gap-1.5 text-[10px]",variants:ve,children:[e.jsx("span",{className:R("size-1.5 rounded-full",b.dotClass)}),e.jsx("span",{children:b.label})]}),e.jsx(j.div,{variants:je,children:e.jsx(Tt,{emoji:(m==null?void 0:m.emoji)??"✨",name:(m==null?void 0:m.name)??"Custom",colors:w,active:!0,gradientText:!0,glow:!0,className:"hover:bg-accent/80 relative z-[1] mt-1 cursor-pointer",onClick:n,"aria-label":"Change personality","data-testid":"personality-picker-trigger"})}),e.jsx("div",{className:"h-2"})]})}const Mn=[{id:"sessions",label:"Sessions"},{id:"config",label:"Config"},{id:"toolkit",label:"Toolkit"}],Dn={type:"spring",stiffness:500,damping:32};function Rn(){const t=U(s=>s.activeTab),n=U(s=>s.setActiveTab);return e.jsx("div",{"data-slot":"agent-hub-tab-bar",role:"tablist","aria-label":"Agent hub tabs",className:"flex border-b",children:Mn.map(s=>e.jsxs("button",{type:"button",role:"tab","aria-selected":t===s.id,onClick:()=>n(s.id),className:R("relative flex-1 py-2 text-xs font-medium transition-colors",t===s.id?"text-foreground font-semibold":"text-muted-foreground hover:text-foreground"),children:[s.label,t===s.id&&e.jsx(j.div,{layoutId:"agent-hub-tab-indicator",className:"bg-primary absolute right-0 bottom-0 left-0 h-0.5",transition:Dn})]},s.id))})}const Ne="dorkos:avatar-first-customization",Pn=[{hex:"#ef4444",name:"Red"},{hex:"#f97316",name:"Orange"},{hex:"#eab308",name:"Yellow"},{hex:"#22c55e",name:"Green"},{hex:"#06b6d4",name:"Cyan"},{hex:"#3b82f6",name:"Blue"},{hex:"#6366f1",name:"Indigo"},{hex:"#a855f7",name:"Purple"},{hex:"#ec4899",name:"Pink"},{hex:"#78716c",name:"Stone"}],J={hidden:{},visible:{transition:{staggerChildren:.04}}},X={hidden:{opacity:0,scale:.5},visible:{opacity:1,scale:1,transition:{type:"spring",stiffness:500,damping:25}}},Ce={hidden:{opacity:0,y:4},visible:{opacity:1,y:0,transition:{duration:.2,ease:"easeOut"}}};function In(){const t=l.useMemo(()=>Array.from({length:14},(s,a)=>{const o=Math.PI*2*a/14,d=28+Math.random()*20,i=360*a/14;return{x:Math.cos(o)*d,y:Math.sin(o)*d,size:3+Math.random()*3,hue:i,delay:a*.02}}),[]);return e.jsx("div",{className:"pointer-events-none absolute inset-0 z-50 overflow-visible","aria-hidden":!0,children:t.map((n,s)=>e.jsx(j.span,{className:"absolute top-1/2 left-1/2 rounded-full",style:{width:n.size,height:n.size,background:`hsl(${n.hue}, 80%, 70%)`,boxShadow:`0 0 6px hsl(${n.hue}, 80%, 70%)`},initial:{x:"-50%",y:"-50%",scale:0,opacity:1},animate:{x:n.x,y:n.y,scale:1,opacity:0},transition:{duration:.6,ease:"easeOut",delay:n.delay}},s))})}function ee(){return e.jsx(j.span,{className:"pointer-events-none absolute inset-0 flex items-center justify-center",initial:{scale:0,opacity:1},animate:{scale:1,opacity:0},transition:{duration:.6,ease:[.34,1.56,.64,1]},"aria-hidden":!0,children:e.jsx(Dt,{className:"size-4 text-white drop-shadow-md",strokeWidth:3})})}function On({onClose:t}){const{agent:n,onUpdate:s,onPreviewColor:a}=q(),o=l.useMemo(()=>wt(n.id),[n.id]),d=l.useMemo(()=>Et(n.id),[n.id]),i=n.icon??d,h=n.color!=null,c=n.icon!=null,b=h||c,[f,u]=l.useState(null),C=l.useRef(null),[S,g]=l.useState(!1),p=l.useRef(!1);l.useEffect(()=>()=>{C.current&&clearTimeout(C.current)},[]);const x=l.useCallback(()=>{if(!p.current){try{if(localStorage.getItem(Ne))return;localStorage.setItem(Ne,"true")}catch{return}p.current=!0,g(!0),setTimeout(()=>g(!1),800)}},[]),y=l.useCallback(r=>{C.current&&clearTimeout(C.current),u(r),C.current=setTimeout(()=>u(null),600)},[]),N=l.useCallback(()=>{s({color:null,icon:null})},[s]),A=l.useCallback(r=>{s({color:r}),a(null),y(r??"auto"),x()},[s,a,y,x]),m=l.useCallback(r=>{s({icon:r===d?null:r}),y(`emoji-${r}`),x()},[s,d,y,x]),w=l.useCallback(r=>{a(r)},[a]),E=l.useCallback(()=>{a(null)},[a]);return e.jsxs("div",{className:"flex flex-1 flex-col overflow-auto","data-testid":"avatar-picker-panel",children:[e.jsxs("div",{className:"flex items-center justify-between border-b px-4 py-2",children:[e.jsx("span",{className:"text-xs font-semibold",children:"Appearance"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(z,{children:b&&e.jsx(j.button,{type:"button",onClick:N,className:"text-muted-foreground hover:text-foreground text-[10px] transition-colors",initial:{opacity:0,x:8},animate:{opacity:1,x:0},exit:{opacity:0,x:8},transition:{duration:.2},children:"Reset to defaults"})}),e.jsx(I,{variant:"ghost",size:"icon",className:"size-6",onClick:t,"aria-label":"Close appearance picker",children:e.jsx(Pe,{className:"size-3.5"})})]})]}),e.jsxs(j.div,{className:"space-y-5 p-4",variants:J,initial:"hidden",animate:"visible",children:[e.jsxs(j.div,{variants:Ce,children:[e.jsx("div",{className:"text-muted-foreground mb-2 text-[10px] font-medium tracking-wider uppercase",children:"Color"}),e.jsxs(j.div,{className:"flex flex-wrap items-center gap-2",variants:J,initial:"hidden",animate:"visible",children:[e.jsx(j.div,{variants:X,children:e.jsxs(me,{children:[e.jsx(he,{asChild:!0,children:e.jsxs("button",{type:"button",onClick:()=>A(null),onMouseEnter:()=>w(o),onMouseLeave:E,className:R("group/swatch relative size-8 rounded-full transition-all duration-150",h?"hover:scale-110":"ring-muted-foreground/50 ring-2 ring-offset-2"),style:{backgroundColor:o},"aria-label":"Select unique auto-generated color",children:[e.jsx("span",{className:"bg-background/80 text-foreground absolute inset-0 flex items-center justify-center rounded-full",children:e.jsx(Ut,{className:"size-3"})}),e.jsx("span",{className:"absolute inset-[-4px] -z-10 rounded-full opacity-0 blur-md transition-opacity duration-200 group-hover/swatch:opacity-50",style:{backgroundColor:o},"aria-hidden":!0}),e.jsx(z,{children:f==="auto"&&e.jsx(ee,{})})]})}),e.jsx(fe,{side:"bottom",className:"text-[10px]",children:"Unique — derived from agent name"})]})}),e.jsx("div",{className:"bg-border mx-0.5 h-5 w-px"}),Pn.map(r=>e.jsx(j.div,{variants:X,children:e.jsxs(me,{children:[e.jsx(he,{asChild:!0,children:e.jsxs("button",{type:"button",onClick:()=>A(r.hex),onMouseEnter:()=>w(r.hex),onMouseLeave:E,className:R("group/swatch relative size-8 rounded-full transition-all duration-150",n.color===r.hex?"ring-foreground ring-2 ring-offset-2":"hover:scale-110"),style:{backgroundColor:r.hex},"aria-label":`Select ${r.name}`,children:[e.jsx("span",{className:"absolute inset-[-4px] -z-10 rounded-full opacity-0 blur-md transition-opacity duration-200 group-hover/swatch:opacity-50",style:{backgroundColor:r.hex},"aria-hidden":!0}),e.jsx(z,{children:f===r.hex&&e.jsx(ee,{})})]})}),e.jsx(fe,{side:"bottom",className:"text-[10px]",children:r.name})]})},r.hex))]})]}),e.jsxs(j.div,{variants:Ce,children:[e.jsx("div",{className:"text-muted-foreground mb-2 text-[10px] font-medium tracking-wider uppercase",children:"Icon"}),e.jsx(j.div,{className:"grid grid-cols-6 gap-1.5",variants:J,initial:"hidden",animate:"visible",children:Mt.map(r=>{const k=r===i,v=r===d&&!n.icon;return e.jsxs(j.button,{type:"button",onClick:()=>m(r),className:R("relative flex size-9 items-center justify-center rounded-md text-lg","transition-colors duration-150",k?v?"bg-accent ring-muted-foreground/50 ring-1":"bg-accent ring-foreground ring-1":"hover:bg-accent/50 active:scale-90"),"aria-label":`Select icon ${r}`,variants:X,whileHover:{scale:1.25},whileTap:{scale:.85},transition:{type:"spring",stiffness:500,damping:20},children:[r,e.jsx(z,{children:f===`emoji-${r}`&&e.jsx(ee,{})})]},r)})})]})]}),e.jsx(z,{children:S&&e.jsx(In,{})})]})}function zn({onClose:t}){const{agent:n,onPersonalityUpdate:s}=q(),a=n.traits??Re,o=l.useCallback(d=>{s({traits:d})},[s]);return e.jsxs("div",{className:"flex flex-1 flex-col overflow-auto","data-testid":"personality-picker-panel",children:[e.jsxs("div",{className:"flex items-center justify-between border-b px-4 py-2",children:[e.jsx("span",{className:"text-xs font-semibold",children:"Personality"}),e.jsx(I,{variant:"ghost",size:"icon",className:"size-6",onClick:t,"aria-label":"Close personality picker",children:e.jsx(Pe,{className:"size-3.5"})})]}),e.jsx(Rt,{traits:a,onTraitsChange:o,compact:!0,className:"p-4"})]})}function Hn(){return e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[e.jsx("div",{className:"bg-muted flex size-12 items-center justify-center rounded-full",children:e.jsx(Pt,{className:"text-muted-foreground size-5"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"No agent selected"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Select an agent to view its profile."})]})]})}function Vn({agentPath:t}){return e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[e.jsx("div",{className:"bg-destructive/10 flex size-12 items-center justify-center rounded-full",children:e.jsx(It,{className:"text-destructive size-5"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"Agent not found"}),e.jsx("p",{className:"text-muted-foreground font-mono text-xs break-all",children:t}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"The agent at this path could not be loaded."})]})]})}function Bn(){return e.jsxs("div",{"data-slot":"agent-hub",className:"flex h-full flex-col overflow-hidden",children:[e.jsxs("div",{className:"relative flex flex-col items-center gap-1 border-b pb-0",children:[e.jsx("div",{className:"relative z-10 w-full",children:e.jsx(Ie,{})}),e.jsx(H,{className:"size-14 rounded-full"}),e.jsx(H,{className:"mt-1 h-4 w-24 rounded"}),e.jsx(H,{className:"h-3 w-12 rounded"}),e.jsx(H,{className:"mt-1 h-6 w-20 rounded-full"}),e.jsx("div",{className:"h-2"})]}),e.jsx("div",{className:"flex border-b",children:["w-16","w-14","w-16"].map((t,n)=>e.jsx("div",{className:"flex flex-1 justify-center py-2",children:e.jsx(H,{className:`h-3 ${t} rounded`})},n))}),e.jsxs("div",{className:"flex-1 space-y-3 p-4",children:[e.jsx(H,{className:"h-16 w-full rounded-lg"}),e.jsx(H,{className:"h-16 w-full rounded-lg"})]})]})}function $n(){var N,A;jn(),Nn();const[t,n]=l.useState(null),[s,a]=l.useState(null),o=U(m=>m.agentPath),d=pe(m=>m.selectedCwd),i=o??d,h=pe(m=>m.rightPanelOpen),{data:c,isLoading:b}=Ot(i),f=zt(),u=l.useRef(null);c&&i&&(u.current={agent:c,path:i});const C=l.useCallback(m=>{n(w=>w===m?(a(null),null):m)},[]),S=l.useCallback(()=>{n(null),a(null)},[]),g=i?c??((N=u.current)==null?void 0:N.agent):void 0,p=i?c?i:(A=u.current)==null?void 0:A.path:void 0,x=l.useMemo(()=>g&&p?{agent:g,projectPath:p,onUpdate:m=>f.mutate({path:p,updates:m}),onPersonalityUpdate:m=>{const{soulContent:w,nopeContent:E,...r}=m;Object.keys(r).length>0&&f.mutate({path:p,updates:r})},previewColor:s,onPreviewColor:a,isPickerOpen:t==="avatar"}:null,[g,p,f,s,t]);return i?b&&!g?e.jsx(Bn,{}):x?e.jsx(Ht,{value:x,children:e.jsxs(j.div,{"data-slot":"agent-hub",className:"flex h-full flex-col overflow-hidden",animate:{opacity:h?1:0},transition:{duration:.15,ease:"easeOut"},children:[e.jsx(En,{onAvatarClick:()=>C("avatar"),onPersonalityClick:()=>C("personality")}),t===null?e.jsxs(e.Fragment,{children:[e.jsx(Rn,{}),e.jsx(z,{mode:"wait",children:e.jsx(j.div,{className:"flex min-h-0 flex-1 flex-col",initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15,ease:"easeInOut"},children:e.jsx(Vt,{})},p)})]}):t==="avatar"?e.jsx(On,{onClose:S}):e.jsx(zn,{onClose:S})]})}):e.jsx(Vn,{agentPath:i}):e.jsx(Hn,{})}export{$n as AgentHub,En as AgentHubHero,Ht as AgentHubProvider,Rn as AgentHubTabBar,Vt as AgentHubTabContent,Cn as AgentManagementMenu,Vn as AgentNotFound,At as DEFAULT_PRESET_COLORS,Hn as NoAgentSelected,qn as PERSONALITY_PRESETS,Rt as PersonalityPicker,Ct as findMatchingPreset,Nn as useAgentDialogRedirect,q as useAgentHubContext,jn as useAgentHubDeepLink,U as useAgentHubStore};
