import{a6 as te,r as n,i as fe,an as je,j as e,U as F,V as L,ao as ne,ap as ae,v as re,d as R,aq as z,ar as I,q as ie,a2 as oe,as as G,at as be,B,au as ve,av as ye,Y as Ne,aw as ce,ax as le,ay as de,az as ue,aA as P,aB as me,aC as Ce,aD as Te,aE as V,aF as $,s as U,T as ke,c as Se,e as we,aG as Ie,aH as Re,aI as Ae,aJ as Ee,aK as M,aL as De,aM as Y,aN as Be,aO as ze,aP as Pe,aQ as _e,aR as Me,aS as Oe,aT as Fe,aU as Le,aV as $e,aW as Ke,aX as qe,aY as He,aZ as xe,a_ as Ve,a$ as We,M as Xe,b0 as Ge,b1 as Ue,b2 as Ye,b3 as Ze,b4 as Je,u as Qe,t as T,b5 as es,b6 as ss,b7 as ts,b8 as W,f as ns,b9 as as,ba as rs,bb as is,X as os,Z as cs,bc as ls}from"./index-BkPfLH67.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 ds=[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]],us=te("flask-conical",ds);/**
 * @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 ms=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]],xs=te("pause",ms),hs=500;function Z(s,l,m,d=hs){const[u,h]=n.useState(s),i=n.useRef(null);n.useEffect(()=>{h(s)},[l]),n.useEffect(()=>()=>{i.current&&clearTimeout(i.current)},[]);const p=n.useCallback(r=>{h(r),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>m(r),d)},[m,d]),j=n.useCallback(()=>{i.current&&clearTimeout(i.current),u!==s&&m(u)},[u,s,m]);return{value:u,onChange:p,onBlur:j}}function ps(){const s=fe();return je({mutationFn:l=>s.testBinding(l)})}const gs=4e3,fs=2e3,he="<!-- TRAITS:START -->",X="<!-- TRAITS:END -->";function _(s,l){const m=[he,`## Personality Traits
`,s,X];return l.trim()&&m.push("",l.trim()),m.join(`
`)}function pe(s){const l=s.indexOf(X);return l===-1?s:s.slice(l+X.length).trim()}function J({title:s,content:l,enabled:m,maxChars:d,charCount:u,disclaimer:h,onChange:i,onBlur:p,onToggle:j}){const r=n.useCallback(f=>{i(f.target.value)},[i]);return e.jsx(F,{className:R(!m&&"opacity-60"),children:e.jsxs(L,{children:[e.jsxs(ne,{orientation:"horizontal",className:"items-center justify-between",children:[e.jsx(ae,{className:"text-sm font-medium",children:s}),e.jsx(re,{checked:m,onCheckedChange:j,"aria-label":`Toggle ${s}`})]}),h&&e.jsx("p",{className:"text-muted-foreground text-xs italic",children:h}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("textarea",{value:l,onChange:r,onBlur:p,rows:8,maxLength:d,className:"border-border bg-background text-foreground placeholder:text-muted-foreground focus-visible:ring-ring w-full resize-none rounded-md border px-3 py-2 font-mono text-sm focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",placeholder:m?"Write markdown content...":"Toggle on to enable injection"}),e.jsxs("p",{className:"text-muted-foreground text-right text-xs",children:[u??l.length," / ",d.toLocaleString()]})]})]})})}function js({agentName:s,agentId:l,agentDescription:m,agentCapabilities:d,traits:u,conventions:h,soulContent:i,nopeContent:p}){const[j,r]=n.useState(!1),f=n.useMemo(()=>{const a=[`<agent_identity>
${[`Name: ${s}`,`ID: ${l}`,m&&`Description: ${m}`,(d==null?void 0:d.length)&&`Capabilities: ${d.join(", ")}`].filter(Boolean).join(`
`)}
</agent_identity>`];if(h.soul){let g=i;if(i.includes(he)){const v=pe(i),N=z({...I,...u});g=_(N,v)}else i.trim()&&(g=i);g.trim()&&a.push(`<agent_persona>
${g}
</agent_persona>`)}return h.nope&&p.trim()&&a.push(`<agent_safety_boundaries>
${p}
</agent_safety_boundaries>`),a.join(`

`)},[s,l,m,d,u,h,i,p]);return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("button",{type:"button",onClick:()=>r(!j),className:"flex items-center gap-1.5 text-sm font-medium","aria-expanded":j,children:[j?e.jsx(ie,{className:"size-4"}):e.jsx(oe,{className:"size-4"}),"Preview injected prompt"]}),j&&e.jsx("pre",{className:"bg-muted max-h-64 overflow-auto rounded-md p-3",children:e.jsx("code",{className:"text-xs",children:f})})]})}const bs="These boundaries guide agent behavior but are not enforced at the tool level. They serve as strong instructions, not hard blocks.";function vs({agent:s,soulContent:l,nopeContent:m,onUpdate:d}){var k;const[u,h]=n.useState(s.traits??I),[i,p]=n.useState(s.conventions??{soul:!0,nope:!0,dorkosKnowledge:!0}),j=n.useRef(u);n.useEffect(()=>{j.current=u},[u]);const r=Z(pe(l??""),s.id,o=>{const C=z({...I,...j.current});d({soulContent:_(C,o)})}),f=Z(m??"",s.id,o=>{d({nopeContent:o})}),b=n.useMemo(()=>{const o=z({...I,...u});return _(o,r.value)},[u,r.value]),a=n.useCallback(o=>{h(o);const C=z({...I,...o});d({traits:o,soulContent:_(C,r.value)})},[r.value,d]),g=n.useCallback(()=>{const o={...I};h(o);const C=z(o);d({traits:o,soulContent:_(C,r.value)})},[r.value,d]),v=n.useCallback((o,C)=>{const c={...i,[o]:C};p(c),d({conventions:c})},[i,d]),N=G.map(o=>be[o][u[o]??3]).join(" "),y=G.every(o=>u[o]===I[o]);return e.jsxs("div",{className:"space-y-6",children:[e.jsx("p",{className:"text-muted-foreground text-sm leading-relaxed",children:N}),e.jsx(F,{children:e.jsxs(L,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Traits"}),!y&&e.jsx(B,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:g,children:"Reset to defaults"})]}),e.jsx(ve,{traits:u,onChange:a,onSliderChange:()=>ye()})]})}),e.jsx(J,{title:"Custom Instructions (SOUL.md)",content:r.value,enabled:i.soul,maxChars:gs,charCount:b.length,onChange:o=>r.onChange(o),onBlur:r.onBlur,onToggle:o=>v("soul",o)}),e.jsx(J,{title:"Safety Boundaries (NOPE.md)",content:f.value,enabled:i.nope,maxChars:fs,disclaimer:bs,onChange:o=>f.onChange(o),onBlur:f.onBlur,onToggle:o=>v("nope",o)}),e.jsx(F,{children:e.jsx(L,{children:e.jsxs(ne,{orientation:"horizontal",className:"items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ae,{className:"text-sm font-medium",children:"DorkOS Knowledge Base"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Inject DorkOS platform documentation into the agent's context"})]}),e.jsx(re,{checked:i.dorkosKnowledge,onCheckedChange:o=>v("dorkosKnowledge",o),"aria-label":"Toggle DorkOS knowledge base injection"})]})})}),e.jsx(F,{children:e.jsx(L,{children:e.jsx(Ne,{label:"Response Mode",description:"Controls when this agent responds to messages automatically",children:e.jsxs(ce,{value:((k=s.behavior)==null?void 0:k.responseMode)??"always",onValueChange:o=>d({behavior:{...s.behavior,responseMode:o}}),children:[e.jsx(le,{className:"w-48",children:e.jsx(de,{})}),e.jsxs(ue,{children:[e.jsx(P,{value:"always",children:"Always respond"}),e.jsx(P,{value:"direct-only",children:"Direct messages only"}),e.jsx(P,{value:"mention-only",children:"Only when mentioned"}),e.jsx(P,{value:"silent",children:"Never respond automatically"})]})]})})})}),e.jsx(js,{agentName:me(s),agentId:s.id,agentDescription:s.description,agentCapabilities:s.capabilities,traits:u,conventions:i,soulContent:b,nopeContent:f.value})]})}const ys={connected:$.connected,disconnected:"bg-amber-500",error:$.error,connecting:$.starting};function Ns(s){const l=[];return s.canInitiate&&l.push("Can start conversations"),s.canReply||l.push("Cannot reply"),s.canReceive||l.push("Cannot receive"),l.join(" · ")}function Cs({binding:s,channelName:l,channelIconId:m,channelAdapterType:d,adapterState:u,errorMessage:h,chatDisplayName:i,lastMessageAt:p,onTogglePause:j,onTest:r,onEdit:f,onRemove:b}){const[a,g]=n.useState(!1),[v,N]=n.useState(!1),y=s.enabled===!1,[,k]=n.useState(0);n.useEffect(()=>{if(!p||y)return;const q=setInterval(()=>k(E=>E+1),6e4);return()=>clearInterval(q)},[p,y]);const o=i?`${l} — ${i}`:l,C=Ce({sessionStrategy:s.sessionStrategy,chatDisplayName:i,channelType:s.channelType}),c=s.canInitiate||!s.canReply||!s.canReceive,S=c?Ns(s):"",A=n.useMemo(()=>y?"Paused — no messages routing":p?`Last received ${Te(p).toLowerCase()}`:"No recent activity",[y,p]),K=async()=>{N(!0);try{await r()}finally{N(!1)}};return e.jsxs("div",{className:R("relative rounded-xl border px-4 py-3 transition-colors",u==="error"&&!y&&"border-red-500/50 bg-red-500/[0.02]",y&&"opacity-60"),children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("div",{className:"relative shrink-0",children:[e.jsx(V,{iconId:m,adapterType:d,size:32}),e.jsx("span",{className:R("ring-background absolute -right-0.5 -bottom-0.5 size-2.5 rounded-full ring-2",y?"bg-muted-foreground/40":ys[u])})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:o}),y&&e.jsx(U,{variant:"secondary",className:"text-xs",children:"Paused"})]}),y?e.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:A}):u==="error"&&h?e.jsx("p",{className:"text-xs text-red-600 dark:text-red-400",children:h}):e.jsxs(e.Fragment,{children:[C&&e.jsx("p",{className:"text-muted-foreground truncate text-xs italic",children:C}),e.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:A})]})]}),c&&e.jsxs(ke,{children:[e.jsx(Se,{asChild:!0,children:e.jsx(U,{variant:"outline",className:"text-xs",children:"Restricted"})}),e.jsx(we,{children:S})]}),e.jsxs(Ie,{children:[e.jsx(Re,{asChild:!0,children:e.jsxs(B,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",children:[e.jsx(Ae,{className:"size-4"}),e.jsx("span",{className:"sr-only",children:"Actions"})]})}),e.jsxs(Ee,{align:"end",children:[e.jsxs(M,{onClick:K,disabled:v||y,children:[v?e.jsx(De,{className:"mr-2 size-4 animate-spin"}):e.jsx(us,{className:"mr-2 size-4"}),"Send test"]}),e.jsx(Y,{}),e.jsx(M,{onClick:()=>j(!s.enabled),children:y?e.jsxs(e.Fragment,{children:[e.jsx(Be,{className:"mr-2 size-4"}),"Resume"]}):e.jsxs(e.Fragment,{children:[e.jsx(xs,{className:"mr-2 size-4"}),"Pause"]})}),e.jsx(Y,{}),e.jsx(M,{onClick:f,children:"Edit"}),e.jsx(M,{onClick:()=>g(!0),className:"text-destructive focus:text-destructive",children:"Remove"})]})]})]}),e.jsx(ze,{open:a,onOpenChange:g,children:e.jsxs(Pe,{children:[e.jsxs(_e,{children:[e.jsx(Me,{children:"Remove channel binding"}),e.jsxs(Oe,{children:["Remove the binding to ",l,"? The agent will no longer receive messages from this channel."]})]}),e.jsxs(Fe,{children:[e.jsx(Le,{children:"Cancel"}),e.jsx($e,{onClick:()=>{b(),g(!1)},className:"bg-red-600 hover:bg-red-700",children:"Remove"})]})]})})]})}function Ts({binding:s,channelName:l,channelIconId:m,channelAdapterType:d,adapterState:u,errorMessage:h,onTogglePause:i,onTest:p,onEdit:j,onRemove:r}){const{data:f=[]}=Ke(s.adapterId),b=s.chatId?f.find(v=>v.chatId===s.chatId):void 0,a=(b==null?void 0:b.displayName)??(s.chatId?`#${s.chatId.slice(-4)}`:void 0),g=n.useMemo(()=>{if(b)return b.lastMessageAt;if(f.length!==0)return f.reduce((v,N)=>N.lastMessageAt>v?N.lastMessageAt:v,f[0].lastMessageAt)},[b,f]);return e.jsx(Cs,{binding:s,channelName:l,channelIconId:m,channelAdapterType:d,adapterState:u,errorMessage:h,chatDisplayName:a,lastMessageAt:g,onTogglePause:i,onTest:p,onEdit:j,onRemove:r})}function Q({catalog:s,boundAdapterIds:l,onSelectChannel:m,onRequestSetup:d,disabled:u}){const[h,i]=n.useState(!1),p=n.useMemo(()=>s.flatMap(a=>a.instances.map(g=>({id:g.id,displayName:g.status.displayName??a.manifest.displayName,label:g.label,state:g.status.state,isDisabled:g.status.state==="error"||!g.enabled,alreadyBound:l.has(g.id),iconId:a.manifest.iconId,adapterType:a.manifest.type}))),[s,l]),j=n.useMemo(()=>s.filter(a=>!a.manifest.deprecated&&(a.instances.length===0||a.manifest.multiInstance)),[s]);function r(a){m(a),i(!1)}function f(a){i(!1),d(a)}const b=p.length===0&&j.length===0;return e.jsxs(qe,{open:h,onOpenChange:i,children:[e.jsx(He,{asChild:!0,children:e.jsxs(B,{variant:"outline",size:"sm",disabled:u,children:[e.jsx(xe,{className:"mr-1.5 size-3.5"}),"Connect to Channel"]})}),e.jsx(Ve,{className:"w-72 p-0",align:"start",children:e.jsx("div",{className:"max-h-64 overflow-y-auto",children:b?e.jsx("div",{className:"px-3 py-4 text-center",children:e.jsx("p",{className:"text-muted-foreground text-sm",children:"No channels available"})}):e.jsxs(e.Fragment,{children:[p.length>0&&e.jsx("div",{className:"py-1",children:p.map(a=>e.jsxs("button",{disabled:a.isDisabled||a.alreadyBound,onClick:()=>r(a.id),className:R("flex w-full items-center gap-3 px-3 py-2 text-left text-sm transition-colors","hover:bg-accent disabled:cursor-not-allowed disabled:opacity-50"),children:[e.jsxs("div",{className:"relative shrink-0",children:[e.jsx(V,{iconId:a.iconId,adapterType:a.adapterType,size:20,className:"text-muted-foreground"}),e.jsx("span",{className:R("ring-background absolute -right-0.5 -bottom-0.5 size-1.5 rounded-full ring-[1.5px]",$[a.state])})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate font-medium",children:a.displayName}),a.label&&e.jsx("p",{className:"text-muted-foreground truncate text-xs",children:a.label})]}),e.jsx("span",{className:"text-muted-foreground/60 text-xs",children:a.alreadyBound?"Connected":We[a.state]})]},a.id))}),j.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border-t"}),e.jsxs("div",{className:"py-1",children:[e.jsx("p",{className:"text-muted-foreground px-3 py-1 text-xs font-medium",children:"Available to set up"}),j.map(a=>e.jsxs("button",{onClick:()=>f(a.manifest),className:R("flex w-full items-center gap-3 px-3 py-2 text-left text-sm transition-colors","hover:bg-accent"),children:[e.jsx(V,{iconId:a.manifest.iconId,adapterType:a.manifest.type,size:14,className:"text-muted-foreground shrink-0"}),e.jsx("span",{className:"truncate font-medium",children:a.manifest.displayName})]},a.manifest.type))]})]})]})})})]})}const O={open:!1,binding:null,adapterName:""},ee={open:!1};function ks({agent:s}){const l=Xe(),{data:m=[]}=Ge(),{data:d=[]}=Ue(l),u=Ye(),h=Ze(),i=ps(),p=Je(),j=Qe(t=>t.openSettingsToTab),[r,f]=n.useState(O),[b,a]=n.useState(ee),g=m.filter(t=>t.agentId===s.id),v=n.useMemo(()=>{const t=new Map;for(const x of d)for(const w of x.instances){const D=w.status.state,ge=D==="connected"||D==="error"?D:D==="starting"||D==="stopping"||D==="reconnecting"?"connecting":"disconnected";t.set(w.id,{state:ge,name:w.status.displayName??x.manifest.displayName,iconId:x.manifest.iconId,adapterType:x.manifest.type,errorMessage:w.status.lastError??void 0})}return t},[d]),N=n.useCallback(t=>v.get(t)??{state:"disconnected",name:t,adapterType:t},[v]),y=n.useMemo(()=>new Set(g.map(t=>t.adapterId)),[g]),k=n.useCallback(async t=>{try{await u.mutateAsync({adapterId:t,agentId:s.id,sessionStrategy:"per-chat",label:"",canInitiate:!1,canReply:!0,canReceive:!0}),T.success("Channel connected")}catch(x){T.error(x instanceof Error?x.message:"Failed to connect channel")}},[s.id,u]),o=n.useCallback(t=>{a({open:!0,manifest:t})},[]),C=n.useCallback(t=>{f({open:!0,binding:t,adapterName:N(t.adapterId).name})},[N]),c=n.useCallback(async t=>{try{await h.mutateAsync(t),T.success("Channel removed")}catch(x){T.error(x instanceof Error?x.message:"Failed to remove channel")}},[h]),S=n.useCallback(async(t,x)=>{try{await p.mutateAsync({id:t,updates:{enabled:x}}),T.success(x?"Channel resumed":"Channel paused")}catch(w){T.error(w instanceof Error?w.message:"Failed to update channel")}},[p]),A=n.useCallback(async t=>{try{const x=await i.mutateAsync(t);return x.ok?T.success(`Test OK — routed in ${x.latencyMs}ms`):T.error(`Test failed: ${x.reason??"unknown error"}`),x}catch(x){throw T.error(x instanceof Error?x.message:"Test failed"),x}},[i]),K=n.useCallback(async t=>{if(r.binding)try{await p.mutateAsync({id:r.binding.id,updates:{sessionStrategy:t.sessionStrategy,label:t.label,chatId:t.chatId,channelType:t.channelType,canInitiate:t.canInitiate,canReply:t.canReply,canReceive:t.canReceive}}),T.success("Binding updated"),f(O)}catch(x){T.error(x instanceof Error?x.message:"Failed to update binding")}},[r.binding,p]),q=n.useCallback(async t=>{try{await h.mutateAsync(t),T.success("Channel removed"),f(O)}catch(x){T.error(x instanceof Error?x.message:"Failed to remove channel")}},[h]),E=e.jsxs(e.Fragment,{children:[r.binding&&e.jsx(es,{open:r.open,onOpenChange:t=>{t||f(O)},mode:"edit",initialValues:{adapterId:r.binding.adapterId,agentId:r.binding.agentId,sessionStrategy:r.binding.sessionStrategy,label:r.binding.label,chatId:r.binding.chatId,channelType:r.binding.channelType,canInitiate:r.binding.canInitiate,canReply:r.binding.canReply,canReceive:r.binding.canReceive},adapterName:r.adapterName,agentName:me(s),bindingId:r.binding.id,onConfirm:K,onDelete:q,isPending:p.isPending||h.isPending}),b.manifest&&e.jsx(ss,{open:b.open,onOpenChange:t=>{t||a(ee)},manifest:b.manifest,existingAdapterIds:d.flatMap(t=>t.instances.map(x=>x.id))})]});return l?d.length===0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-xl border border-dashed px-6 py-10",children:[e.jsx(W,{className:"text-muted-foreground/40 size-8"}),e.jsxs("div",{className:"space-y-1 text-center",children:[e.jsx("p",{className:"text-sm font-medium",children:"No channels available"}),e.jsx("p",{className:"text-muted-foreground max-w-xs text-xs leading-relaxed",children:"To connect this agent to Telegram, Slack, or a webhook, first configure a channel in Settings. It will appear here as soon as it's ready."})]}),e.jsx(B,{variant:"outline",size:"sm",onClick:()=>j("channels"),children:"Configure a channel"})]}),E]}):g.length===0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-xl border border-dashed px-6 py-10",children:[e.jsx(W,{className:"text-muted-foreground/40 size-8"}),e.jsxs("div",{className:"space-y-1 text-center",children:[e.jsx("p",{className:"text-sm font-medium",children:"Let this agent reach the outside world"}),e.jsx("p",{className:"text-muted-foreground max-w-xs text-xs leading-relaxed",children:"Connect Telegram, Slack, or a webhook so this agent can send and receive messages while you are away."})]}),e.jsx(Q,{catalog:d,boundAdapterIds:y,onSelectChannel:k,onRequestSetup:o,disabled:u.isPending})]}),E]}):e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"space-y-2",children:g.map(t=>{const x=N(t.adapterId);return e.jsx(Ts,{binding:t,channelName:x.name,channelIconId:x.iconId,channelAdapterType:x.adapterType,adapterState:x.state,errorMessage:x.errorMessage,onTogglePause:w=>S(t.id,w),onTest:()=>A(t.id),onEdit:()=>C(t),onRemove:()=>c(t.id)},t.id)})}),e.jsx(Q,{catalog:d,boundAdapterIds:y,onSelectChannel:k,onRequestSetup:o,disabled:u.isPending}),E]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-xl border border-dashed px-6 py-10",children:[e.jsx(ts,{className:"text-muted-foreground/40 size-8"}),e.jsxs("div",{className:"space-y-1 text-center",children:[e.jsx("p",{className:"text-sm font-medium",children:"The Relay message bus is off"}),e.jsx("p",{className:"text-muted-foreground max-w-xs text-xs leading-relaxed",children:"Channels connect this agent to external messaging platforms. Enable Relay in Settings to get started."})]}),e.jsx(B,{variant:"outline",size:"sm",onClick:()=>j("advanced"),children:"Open Relay settings"})]}),E]})}const Ss={"claude-code":"Claude Code",cursor:"Cursor",codex:"Codex",windsurf:"Windsurf",gemini:"Gemini",cline:"Cline","roo-code":"Roo Code",copilot:"Copilot","amazon-q":"Amazon Q",continue:"Continue",augment:"Augment","jetbrains-ai":"JetBrains AI","kilo-code":"Kilo Code",trae:"Trae",other:"Other",mock:"Mock Runtime"};function se({title:s,icon:l,meta:m,defaultOpen:d=!1,children:u}){const[h,i]=n.useState(d);return e.jsxs("div",{className:"border-b last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>i(!h),className:R("hover:bg-accent/50 flex w-full items-center gap-2 px-4 py-2.5 text-left transition-colors"),"aria-expanded":h,children:[h?e.jsx(ie,{className:"text-muted-foreground size-3.5 shrink-0"}):e.jsx(oe,{className:"text-muted-foreground size-3.5 shrink-0"}),e.jsx(l,{className:"text-muted-foreground size-3.5 shrink-0"}),e.jsx("span",{className:"text-[11px] font-semibold",children:s}),m&&e.jsx("span",{className:"text-muted-foreground ml-auto text-[9px]",children:m})]}),h&&e.jsx("div",{className:"px-4 pb-4",children:u})]})}function H(s){return s.tags??[]}function Is(){const{agent:s,projectPath:l,onUpdate:m,onPersonalityUpdate:d}=ns(),u=s,{data:h}=as(),i=h?Object.keys(h.capabilities):[s.runtime],[p,j]=n.useState(null),[r,f]=n.useState(""),[b,a]=n.useState(""),[g,v]=n.useState(!1),N=n.useCallback((c,S)=>{j(c),f(S)},[]),y=n.useCallback(c=>{r.trim()&&m({[c]:r.trim()}),j(null)},[r,m]),k=n.useCallback(()=>{const c=b.trim();if(!c)return;const S=H(s);S.includes(c)||m({tags:[...S,c]}),a(""),v(!1)},[b,s,m]),o=n.useCallback(c=>{const S=H(s);m({tags:S.filter(A=>A!==c)})},[s,m]),C=H(s);return e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:"space-y-4 border-b p-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-muted-foreground text-[10px] font-medium tracking-wider uppercase",children:"Description"}),p==="description"?e.jsx("textarea",{autoFocus:!0,value:r,onChange:c=>f(c.target.value),onBlur:()=>y("description"),onKeyDown:c=>{c.key==="Enter"&&!c.shiftKey&&y("description")},className:"border-input bg-background ring-offset-background placeholder:text-muted-foreground focus-visible:ring-ring w-full rounded-md border px-3 py-2 text-sm focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",rows:3}):e.jsx("button",{type:"button",className:"hover:bg-accent text-muted-foreground w-full rounded-md px-2 py-1 text-left text-sm transition-colors",onClick:()=>N("description",s.description??""),"data-testid":"description-field",children:s.description||"Add a description..."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-muted-foreground text-[10px] font-medium tracking-wider uppercase",children:"Runtime"}),e.jsxs(ce,{value:s.runtime??"claude-code",onValueChange:c=>m({runtime:c}),children:[e.jsx(le,{className:"h-8 text-sm",responsive:!1,children:e.jsx(de,{})}),e.jsx(ue,{children:i.map(c=>e.jsx(P,{value:c,responsive:!1,children:Ss[c]??c},c))})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-muted-foreground text-[10px] font-medium tracking-wider uppercase",children:"Directory"}),e.jsxs("div",{className:"text-muted-foreground flex items-center gap-1.5 rounded-md px-2 py-1.5",children:[e.jsx(rs,{className:"size-3.5 shrink-0"}),e.jsx("span",{className:"truncate font-mono text-xs",children:is(l)})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-muted-foreground text-[10px] font-medium tracking-wider uppercase",children:"Tags"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[C.map(c=>e.jsxs("span",{className:"bg-accent text-accent-foreground inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs",children:[c,e.jsx("button",{type:"button",onClick:()=>o(c),className:"hover:text-destructive transition-colors","aria-label":`Remove tag ${c}`,children:e.jsx(os,{className:"size-3"})})]},c)),g?e.jsx(cs,{autoFocus:!0,value:b,onChange:c=>a(c.target.value),onBlur:k,onKeyDown:c=>{c.key==="Enter"&&k(),c.key==="Escape"&&v(!1)},className:"h-6 w-24 text-xs",placeholder:"tag name"}):e.jsxs(B,{type:"button",variant:"ghost",size:"sm",onClick:()=>v(!0),className:"text-muted-foreground hover:text-foreground h-auto gap-0.5 px-1 py-0 text-xs",children:[e.jsx(xe,{className:"size-3"})," Add"]})]})]})]}),e.jsx(se,{title:"Channels",icon:W,children:e.jsx(ks,{agent:s})}),e.jsx(se,{title:"Advanced",icon:ls,children:e.jsx(vs,{agent:s,soulContent:u.soulContent??null,nopeContent:u.nopeContent??null,onUpdate:d})})]})}export{Is as ConfigTab};
