@johpaz/hive-agents 0.0.36 → 0.0.38
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/README.md +16 -16
- package/dist/hive.js +214 -193
- package/dist/tool-worker.js +218395 -0
- package/dist/ui/assets/{AgentCreateForm-tJZv9FZC.js → AgentCreateForm-0oFbN3gj.js} +1 -1
- package/dist/ui/assets/{AgentDetailPage-Du-mRcAX.js → AgentDetailPage-BJ4L2fNJ.js} +1 -1
- package/dist/ui/assets/AgentNewPage-B3n0LUck.js +1 -0
- package/dist/ui/{dist/assets/AgentsPage-YvSgWRiw.js → assets/AgentsPage-DGNLDXjR.js} +1 -1
- package/dist/ui/assets/{CanvasPage-DtMwGvxf.js → CanvasPage-CnMO1FN8.js} +1 -1
- package/dist/ui/assets/{ChannelsPage-BdBXWHjj.js → ChannelsPage-fbF8K4MR.js} +1 -1
- package/dist/ui/{dist/assets/DashboardPage-ghl1ZguH.js → assets/DashboardPage-VyXXp3U1.js} +1 -1
- package/dist/ui/assets/{LoginPage-CAmSI9Vy.js → LoginPage-DPj2s2Qq.js} +1 -1
- package/dist/ui/{dist/assets/LogsPage-DAPBHkwK.js → assets/LogsPage-B2lY9maY.js} +1 -1
- package/dist/ui/{dist/assets/MeetingPage-WjjGOqqU.js → assets/MeetingPage-2ky_hKiG.js} +1 -1
- package/dist/ui/{dist/assets/ProvidersPage-Ct6HsAi1.js → assets/ProvidersPage-CEyUM2tD.js} +1 -1
- package/dist/ui/{dist/assets/RecoverPage-DpW3l-yv.js → assets/RecoverPage-B-hDZUM2.js} +1 -1
- package/dist/ui/{dist/assets/SettingsPage-DBJ7_E6C.js → assets/SettingsPage-eO0i3g8p.js} +1 -1
- package/dist/ui/assets/{SetupPage-DKmLVUaj.js → SetupPage-ByYqTELb.js} +1 -1
- package/dist/ui/assets/WebChatPage-BuGT2AL0.js +16 -0
- package/dist/ui/assets/{alert-C-NE-P3s.js → alert-Bq6awLlW.js} +1 -1
- package/dist/ui/{dist/assets/alert-dialog-C5mzbHdP.js → assets/alert-dialog-DQvltYmf.js} +1 -1
- package/dist/ui/assets/{badge-ChpACfWO.js → badge-DXUDdTed.js} +1 -1
- package/dist/ui/assets/{dialog-QnZ0ad8O.js → dialog-bI9jImCS.js} +1 -1
- package/dist/ui/assets/{es-NQNoaWDx.js → es-Cg8zdT52.js} +1 -1
- package/dist/ui/{dist/assets/index-DMCjjdqf.js → assets/index-CQ7fn00w.js} +2 -2
- package/dist/ui/assets/{label-D2H1IR_J.js → label-CrH0Jj3v.js} +1 -1
- package/dist/ui/assets/useProviders-CnlC_qCS.js +1 -0
- package/dist/ui/dist/assets/{AgentCreateForm-tJZv9FZC.js → AgentCreateForm-0oFbN3gj.js} +1 -1
- package/dist/ui/dist/assets/{AgentDetailPage-Du-mRcAX.js → AgentDetailPage-BJ4L2fNJ.js} +1 -1
- package/dist/ui/dist/assets/AgentNewPage-B3n0LUck.js +1 -0
- package/dist/ui/{assets/AgentsPage-YvSgWRiw.js → dist/assets/AgentsPage-DGNLDXjR.js} +1 -1
- package/dist/ui/dist/assets/{CanvasPage-DtMwGvxf.js → CanvasPage-CnMO1FN8.js} +1 -1
- package/dist/ui/dist/assets/{ChannelsPage-BdBXWHjj.js → ChannelsPage-fbF8K4MR.js} +1 -1
- package/dist/ui/{assets/DashboardPage-ghl1ZguH.js → dist/assets/DashboardPage-VyXXp3U1.js} +1 -1
- package/dist/ui/dist/assets/{LoginPage-CAmSI9Vy.js → LoginPage-DPj2s2Qq.js} +1 -1
- package/dist/ui/{assets/LogsPage-DAPBHkwK.js → dist/assets/LogsPage-B2lY9maY.js} +1 -1
- package/dist/ui/{assets/MeetingPage-WjjGOqqU.js → dist/assets/MeetingPage-2ky_hKiG.js} +1 -1
- package/dist/ui/{assets/ProvidersPage-Ct6HsAi1.js → dist/assets/ProvidersPage-CEyUM2tD.js} +1 -1
- package/dist/ui/{assets/RecoverPage-DpW3l-yv.js → dist/assets/RecoverPage-B-hDZUM2.js} +1 -1
- package/dist/ui/{assets/SettingsPage-DBJ7_E6C.js → dist/assets/SettingsPage-eO0i3g8p.js} +1 -1
- package/dist/ui/dist/assets/{SetupPage-DKmLVUaj.js → SetupPage-ByYqTELb.js} +1 -1
- package/dist/ui/dist/assets/WebChatPage-BuGT2AL0.js +16 -0
- package/dist/ui/dist/assets/{alert-C-NE-P3s.js → alert-Bq6awLlW.js} +1 -1
- package/dist/ui/{assets/alert-dialog-C5mzbHdP.js → dist/assets/alert-dialog-DQvltYmf.js} +1 -1
- package/dist/ui/dist/assets/{badge-ChpACfWO.js → badge-DXUDdTed.js} +1 -1
- package/dist/ui/dist/assets/{dialog-QnZ0ad8O.js → dialog-bI9jImCS.js} +1 -1
- package/dist/ui/dist/assets/{es-NQNoaWDx.js → es-Cg8zdT52.js} +1 -1
- package/dist/ui/{assets/index-DMCjjdqf.js → dist/assets/index-CQ7fn00w.js} +2 -2
- package/dist/ui/dist/assets/{label-D2H1IR_J.js → label-CrH0Jj3v.js} +1 -1
- package/dist/ui/dist/assets/useProviders-CnlC_qCS.js +1 -0
- package/dist/ui/dist/index.html +1 -1
- package/dist/ui/index.html +1 -1
- package/package.json +3 -2
- package/packages/cli/src/commands/gateway.ts +1 -1
- package/packages/cli/src/commands/onboard.ts +1 -1
- package/packages/core/src/agent/agent-loop.ts +4 -14
- package/packages/core/src/agent/context-compiler.ts +1 -1
- package/packages/core/src/agent/conversation-store.ts +4 -5
- package/packages/core/src/agent/providers/index.ts +3 -4
- package/packages/core/src/agent/tool-selector.ts +3 -4
- package/packages/core/src/gateway/resolver.ts +5 -1
- package/packages/core/src/gateway/routes/chat.ts +16 -16
- package/packages/core/src/gateway/server.ts +44 -45
- package/packages/core/src/storage/seed.ts +39 -33
- package/packages/core/src/tool-runtime/index.ts +49 -3
- package/dist/ui/assets/AgentNewPage-DIFYd_Ys.js +0 -1
- package/dist/ui/assets/WebChatPage-CVRcKept.js +0 -16
- package/dist/ui/assets/useProviders-C6_QHsEi.js +0 -1
- package/dist/ui/dist/assets/AgentNewPage-DIFYd_Ys.js +0 -1
- package/dist/ui/dist/assets/WebChatPage-CVRcKept.js +0 -16
- package/dist/ui/dist/assets/useProviders-C6_QHsEi.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as t}from"./vendor-charts-Bu2lyBKP.js";import{o as n}from"./vendor-query-DsWPbQdG.js";import{n as r,r as i}from"./utils-3pnRFmFe.js";import{t as a}from"./activity-c3pNngT_.js";import{n as o,t as s}from"./send-B0H5SEIE.js";import{t as c}from"./calendar-B-KZ9RQO.js";import{a as l,c as u,l as d,n as f,r as p,s as m,t as h}from"./switch-BDwN8RYV.js";import{n as g,t as _}from"./chevron-up-BYhk0K2J.js";import{t as v}from"./circle-alert-CyHDwUj8.js";import{t as y}from"./circle-check-Bb54Ebmu.js";import{t as b}from"./cpu-Cdgc_B1K.js";import{n as x,t as S}from"./eye-DqNTU_GD.js";import{t as C}from"./globe-DeCQTCDJ.js";import{t as w}from"./hexagon-DsGOUl-H.js";import{t as T}from"./history-BSG-Ypqf.js";import{t as E}from"./info-NwLoa2Mj.js";import{t as D}from"./key-3EP0dhkT.js";import{t as O}from"./loader-circle-CZNax6kS.js";import{t as k}from"./lock-Ei1_J-Nq.js";import{t as A}from"./pause-BUqah9Bi.js";import{n as j,t as M}from"./terminal-DN38Q456.js";import{t as N}from"./play-NcZ4swwL.js";import{t as P}from"./plus-CX1xyhp5.js";import{t as F}from"./refresh-cw-DaYdjQFk.js";import{n as I,t as L}from"./scroll-area-DkeyX32e.js";import{n as R,t as z}from"./textarea-CXgXWKrT.js";import{t as B}from"./sparkles-yUEb-7oH.js";import{t as ee}from"./trash-2-CNjMkoq6.js";import{t as V}from"./triangle-alert-C9Y8Ub4X.js";import{t as H}from"./zap-hlXjpSeA.js";import{l as te}from"./vendor-router-C9pIYwbJ.js";import{r as ne}from"./gateway-url-COCbW0IR.js";import{B as re,G as U,H as ie,J as ae,M as W,R as oe,U as se,V as ce,W as le,f as ue,g as G,h as K,j as q,l as de,m as J,n as fe,o as pe,p as Y,q as X,u as me,z as he}from"./index-DMCjjdqf.js";import{t as Z}from"./label-D2H1IR_J.js";import{a as ge,c as _e,i as ve,o as ye,r as be,s as xe,t as Se}from"./dialog-QnZ0ad8O.js";import{t as Ce}from"./badge-ChpACfWO.js";import{a as we,n as Te,o as Ee,r as De,t as Oe}from"./card-CNf6BS2e.js";import"./useProviders-C6_QHsEi.js";var ke=i(`Briefcase`,[[`path`,{d:`M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16`,key:`jecpp`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`6`,rx:`2`,key:`i6l2r4`}]]),Ae=i(`ChartColumn`,[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]]),je=i(`CodeXml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),Me=i(`Code`,[[`polyline`,{points:`16 18 22 12 16 6`,key:`z7tu5w`}],[`polyline`,{points:`8 6 2 12 8 18`,key:`1eg1df`}]]),Ne=i(`Copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Pe=i(`Earth`,[[`path`,{d:`M21.54 15H17a2 2 0 0 0-2 2v4.54`,key:`1djwo0`}],[`path`,{d:`M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17`,key:`1tzkfa`}],[`path`,{d:`M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05`,key:`14pb5j`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Fe=i(`Hammer`,[[`path`,{d:`m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9`,key:`eefl8a`}],[`path`,{d:`m18 15 4-4`,key:`16gjal`}],[`path`,{d:`m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172V7l-2.26-2.26a6 6 0 0 0-4.202-1.756L9 2.96l.92.82A6.18 6.18 0 0 1 12 8.4V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5`,key:`b7pghm`}]]),Ie=i(`Languages`,[[`path`,{d:`m5 8 6 6`,key:`1wu5hv`}],[`path`,{d:`m4 14 6-6 2-3`,key:`1k1g8d`}],[`path`,{d:`M2 5h12`,key:`or177f`}],[`path`,{d:`M7 2h1`,key:`1t2jsx`}],[`path`,{d:`m22 22-5-10-5 10`,key:`don7ne`}],[`path`,{d:`M14 18h6`,key:`1m8k6r`}]]),Le=i(`MessageCircle`,[[`path`,{d:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,key:`vv11sd`}]]),Re=i(`Power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),ze=i(`Settings2`,[[`path`,{d:`M20 7h-9`,key:`3s1dr2`}],[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),Be=i(`ShieldCheck`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Ve=i(`ShieldOff`,[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]),Q=e(t(),1),He=ne((e,t)=>({isLoading:!1,error:null,configs:[],conflicts:[],templates:[],setLoading:t=>e({isLoading:t}),setError:t=>e({error:t}),fetchEthics:async()=>{e({isLoading:!0,error:null});try{let t=(await Y(`/api/ethics`)).ethics||[],n=t.find(e=>e.active)||t[0];return e({configs:t,isLoading:!1}),n?.content||``}catch(t){throw e({isLoading:!1,error:t instanceof Error?t.message:`Failed to fetch ethics`}),t}},saveEthics:async n=>{e({isLoading:!0,error:null});try{let r=t(),i=r.configs.find(e=>e.active)||r.configs[0],a;return a=i?await Y(`/api/ethics/${i.id}`,{method:`PUT`,body:{content:n}}):await Y(`/api/ethics`,{method:`POST`,body:{name:`Default`,content:n,active:!0}}),e({isLoading:!1}),a.message||`Guardado correctamente`}catch(t){throw e({isLoading:!1,error:t instanceof Error?t.message:`Failed to save ethics`}),t}},fetchConfigs:async()=>{e({isLoading:!0,error:null});try{e({configs:await Y(`/api/workspace/ethics/configs`),isLoading:!1})}catch(t){e({isLoading:!1,error:t instanceof Error?t.message:`Failed to fetch configs`})}},fetchConflicts:async()=>{e({isLoading:!0,error:null});try{e({conflicts:await Y(`/api/workspace/ethics/conflicts`),isLoading:!1})}catch(t){e({isLoading:!1,error:t instanceof Error?t.message:`Failed to fetch conflicts`})}},fetchTemplates:async()=>{e({isLoading:!0,error:null});try{e({templates:await Y(`/api/workspace/ethics/templates`),isLoading:!1})}catch(t){e({isLoading:!1,error:t instanceof Error?t.message:`Failed to fetch templates`})}},updateConfig:(t,n)=>{e(e=>({configs:e.configs.map(e=>e.id===t?{...e,...n,updatedAt:new Date().toISOString(),version:e.version+1}:e)}))},addConfig:t=>{let n={...t,id:r(),version:1,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};e(e=>({configs:[...e.configs,n]}))},removeConfig:t=>{e(e=>({configs:e.configs.filter(e=>e.id!==t)}))}})),$=n();function Ue(){let{configs:e,fetchEthics:t,isLoading:n}=He(),[r,i]=(0,Q.useState)(null),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)({name:``,description:``,content:``}),[l,u]=(0,Q.useState)(!1),d=(0,Q.useRef)(null),f=()=>{let e=d.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)};(0,Q.useEffect)(()=>{a&&setTimeout(f,0)},[a,s.content]),(0,Q.useEffect)(()=>{t().catch(console.error)},[t]),(0,Q.useEffect)(()=>{if(e.length===0)return;let t=e,n=t.find(e=>e.active)||t[0];r||(i(n.id),c({name:n.name,description:n.description||``,content:n.content}))},[e,r]);let p=e.find(e=>e.id===r),m=e=>{i(e.id),c({name:e.name,description:e.description||``,content:e.content}),o(!0)},h=async n=>{G.show(`Activando registro de ética...`);let r=e;try{let e=await Promise.all(r.map(e=>Y(`/api/ethics/${e.id}`,{method:`PUT`,body:{active:+(e.id===n)}}).catch(()=>({}))));await t();let i=e.find((e,t)=>r[t].id===n);J.fire({icon:`success`,title:i?.message||`Registro de ética activado`})}catch(e){J.fire({icon:`error`,title:e instanceof Error?e.message:`Error al activar registro`})}finally{G.hide()}};return n&&e.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-20 border border-white/5 bg-zinc-950/30 rounded-2xl`,children:[(0,$.jsx)(O,{className:`h-8 w-8 animate-spin text-amber-500 mb-4 opacity-50`}),(0,$.jsx)(`span`,{className:`hive-label`,children:`Cargando lineamientos operativos...`})]}):(0,$.jsxs)(`div`,{className:`space-y-8 animate-fade-in`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,$.jsx)(`h3`,{className:`hive-title-section !text-lg`,children:`Protocolos Éticos`}),(0,$.jsxs)(`span`,{className:`hive-tag hive-tag--provider`,children:[e.length,` REGISTROS`]})]}),(0,$.jsx)(`p`,{className:`hive-subtitle !mt-0 !text-xs`,children:`Define la capa moral y los límites operacionales de tus agentes inteligentes.`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] uppercase tracking-widest font-black text-white/20 bg-white/5 px-4 py-2 rounded-xl border border-white/5`,children:[(0,$.jsx)(R,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Configuración del Núcleo`})]})]}),e.length===0?(0,$.jsx)(`div`,{className:`hive-card border-dashed border-white/10 bg-white/[0.02]`,children:(0,$.jsxs)(`div`,{className:`hive-card-body flex flex-col items-center justify-center py-16 px-4`,children:[(0,$.jsx)(`div`,{className:`h-16 w-16 rounded-2xl bg-white/5 flex items-center justify-center mb-6`,children:(0,$.jsx)(V,{className:`h-8 w-8 text-white/20`})}),(0,$.jsxs)(`div`,{className:`text-center`,children:[(0,$.jsx)(`p`,{className:`hive-title-section text-center mb-2`,children:`Sin Protocolos Base`}),(0,$.jsx)(`p`,{className:`text-xs text-white/40 mb-8 max-w-[300px] mx-auto leading-relaxed`,children:`No se han detectado lineamientos éticos en el sistema. Selecciona una de las plantillas inferiores para comenzar.`})]})]})}):(0,$.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6`,children:e.map(e=>{let t=!!e.active,n=r===e.id;return(0,$.jsxs)(`div`,{onClick:()=>m(e),className:`hive-card group transition-all duration-500 cursor-pointer ${n?`hive-card--active`:`opacity-60 grayscale-[0.8] hover:opacity-100 hover:grayscale-0`}`,children:[(0,$.jsxs)(`div`,{className:`hive-card-body relative overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between mb-6`,children:[(0,$.jsx)(`div`,{className:`hive-icon-wrap--internal ${n?`hive-icon-wrap--internal-active`:`hive-icon-wrap--internal-disabled`}`,children:(0,$.jsx)(se,{className:`h-6 w-6`})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t&&(0,$.jsx)(`span`,{className:`hive-status-label--active`,children:`ACTIVO`}),(0,$.jsx)(`div`,{className:t?`hive-status-dot--active`:`hive-status-dot--disabled`})]})]}),(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-lg font-black text-white uppercase tracking-tighter mb-1 line-clamp-1 group-hover:text-blue-400 transition-colors text-ellipsis`,children:e.name}),(0,$.jsx)(`p`,{className:`text-xs text-white/40 font-medium leading-relaxed line-clamp-1 h-4`,children:e.description||`Sin descripción adicional`})]}),(0,$.jsxs)(`div`,{className:`pt-4 border-t border-white/5 flex items-center gap-4`,children:[(0,$.jsxs)(`div`,{className:`hive-stat`,children:[(0,$.jsx)(`span`,{className:`hive-stat__label`,children:`CONFIG`}),(0,$.jsx)(`span`,{className:`hive-stat__value`,children:e.is_default?`DEFAULT`:`CUSTOM`})]}),(0,$.jsxs)(`div`,{className:`hive-stat`,children:[(0,$.jsx)(`span`,{className:`hive-stat__label`,children:`PRECEDENCIA`}),(0,$.jsx)(`span`,{className:`hive-stat__value`,children:t?`ALTA`:`NORMAL`})]})]})]}),n&&(0,$.jsx)(`div`,{className:`hive-glow-blob--card hive-glow-blob--blue -bottom-10 -right-10 h-24 w-24 opacity-20`})]}),(0,$.jsx)(`div`,{className:`hive-strip--bottom ${t?``:`opacity-20`}`})]},e.id)})}),(0,$.jsx)(Se,{open:a,onOpenChange:o,children:(0,$.jsx)(be,{className:`max-w-4xl border-white/10 !bg-[#09090b] p-0 overflow-hidden shadow-2xl`,children:p&&(0,$.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between p-6 border-b border-white/5 bg-white/5 relative overflow-hidden`,children:[(0,$.jsx)(`div`,{className:`hive-glow-blob hive-glow-blob--blue -top-10 -right-10 h-32 w-32 opacity-20`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-4 relative z-10`,children:[(0,$.jsx)(`div`,{className:`hive-icon-wrap--internal hive-icon-wrap--internal-active`,children:(0,$.jsx)(R,{className:`h-6 w-6`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(xe,{className:`hive-title-page !text-2xl uppercase tracking-tighter`,children:p.name}),(0,$.jsx)(ve,{className:`hive-subtitle !mt-0`,children:`Sintonización de la capa moral y operativa del agente.`})]})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-3 relative z-10`,children:!p.active&&(0,$.jsx)(`button`,{className:`hive-btn hive-btn--ghost px-6 text-[10px]`,onClick:()=>h(p.id),children:`ESTABLECER COMO ACTIVO`})})]}),(0,$.jsx)(`div`,{className:`p-6 space-y-4 border-b border-white/5`,children:(0,$.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{className:`hive-label uppercase !text-[10px]`,children:`Nombre del Protocolo`}),(0,$.jsx)(q,{value:s.name,onChange:e=>c(t=>({...t,name:e.target.value})),className:`bg-white/5 border-white/5 focus-visible:ring-blue-500/30 text-white font-bold`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{className:`hive-label uppercase !text-[10px]`,children:`Descripción / Meta`}),(0,$.jsx)(q,{value:s.description,onChange:e=>c(t=>({...t,description:e.target.value})),className:`bg-white/5 border-white/5 focus-visible:ring-blue-500/30 text-white/60 text-xs italic`})]})]})}),(0,$.jsxs)(`div`,{className:`p-0 bg-[#09090b]`,children:[(0,$.jsx)(`div`,{className:`px-6 pt-4`,children:(0,$.jsx)(Z,{className:`hive-label uppercase !text-[10px]`,children:`Lineamientos de Capa (Markdown)`})}),(0,$.jsx)(z,{ref:d,placeholder:`Define los lineamientos éticos del agente...`,value:s.content,onChange:e=>{c(t=>({...t,content:e.target.value})),f()},className:`hive-textarea w-full !bg-zinc-950/50 border-none focus-visible:ring-0 text-amber-50/90 font-mono text-xs leading-relaxed min-h-[400px] p-8 resize-none placeholder:text-white/10 overflow-hidden`})]}),(0,$.jsxs)(`div`,{className:`p-6 bg-white/[0.02] border-t border-white/5 flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-6`,children:[(0,$.jsxs)(`div`,{className:`hive-stat`,children:[(0,$.jsx)(`span`,{className:`hive-stat__label`,children:`IDENTIFICADOR`}),(0,$.jsx)(`span`,{className:`hive-stat__value`,children:p.id})]}),(0,$.jsxs)(`div`,{className:`hive-stat`,children:[(0,$.jsx)(`span`,{className:`hive-stat__label`,children:`ESTADO DE CAPA`}),(0,$.jsx)(`span`,{className:`hive-stat__value hive-stat__value--active`,children:p.active?`SISTEMA ACTIVO`:`PENDIENTE`})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`button`,{className:`hive-btn hive-btn--ghost px-6 text-[10px]`,onClick:()=>o(!1),children:`CANCELAR`}),(0,$.jsx)(`button`,{onClick:async()=>{if(p){u(!0),G.show(`Guardando lineamientos éticos...`);try{let e=await Y(`/api/ethics/${p.id}`,{method:`PUT`,body:s});await t(),J.fire({icon:`success`,title:e.message||`Contenido ético guardado`})}catch(e){J.fire({icon:`error`,title:e instanceof Error?e.message:`Error al guardar`})}finally{u(!1),G.hide(),o(!1)}}},disabled:l,className:`hive-btn hive-btn--primary px-8 text-[10px]`,children:l?`SINCRONIZANDO...`:`GUARDAR LINEAMIENTOS`})]})]})]})})})]})}var We={filesystem:`Sistema de archivos`,web:`Web`,cron:`Cron`,cli:`CLI`,agents:`Agentes`,canvas:`Canvas`,voice:`Voz`};function Ge(){let{tools:e,isLoading:t,fetchTools:n,toggleTool:r,updateTool:i}=me(),[a,o]=(0,Q.useState)(`all`),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{n()},[n]);let p=async(e,t)=>{if(!l){u(e);try{await r(e,t),n(),J.fire({icon:`success`,title:`Herramienta ${t?`activada`:`desactivada`}`})}catch{J.fire({icon:`error`,title:`Error al actualizar estado de la herramienta`})}finally{u(null)}}},m=async()=>{if(s){f(!0),G.show(`Guardando herramienta...`);try{await i(s.id,{name:s.name,description:s.description}),J.fire({icon:`success`,title:`Herramienta actualizada`}),n(),c(null)}catch{J.fire({icon:`error`,title:`Error al guardar cambios`})}finally{f(!1),G.hide()}}};if(t&&e.length===0)return(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-20 border border-white/5 bg-zinc-950/30 rounded-2xl`,children:[(0,$.jsx)(O,{className:`h-8 w-8 animate-spin text-violet-500 mb-4 opacity-50`}),(0,$.jsx)(`span`,{className:`text-xs uppercase font-bold tracking-[0.2em] text-zinc-500`,children:`Cargando herramientas...`})]});let g=e.filter(e=>a===`all`?!0:e.category===a);return(0,$.jsxs)(`div`,{className:`space-y-8 animate-fade-in`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,$.jsx)(`h3`,{className:`hive-title-section !text-lg !text-white/80`,children:`Herramientas`}),(0,$.jsxs)(`span`,{className:`hive-tag bg-white/5 text-white/40 border-white/10`,children:[g.length,` DISPONIBLES`]})]}),(0,$.jsx)(`p`,{className:`hive-subtitle !mt-0 !text-xs`,children:`Gestiona las capacidades externas y el arsenal tecnológico de tu agente.`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] uppercase tracking-widest font-black text-white/20 bg-white/5 px-4 py-2 rounded-xl border border-white/5`,children:[(0,$.jsx)(he,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Arsenal Operativo`})]})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-1.5 p-1 bg-white/5 rounded-2xl w-fit border border-white/5`,children:[`all`,`filesystem`,`web`,`cron`,`cli`,`agents`,`canvas`,`a2ui`,`voice`].map(e=>(0,$.jsx)(`button`,{onClick:()=>o(e),className:`px-6 py-2 rounded-xl text-[10px] font-black tracking-widest uppercase transition-all duration-300 ${a===e?`bg-blue-600 text-white shadow-btn-primary`:`text-white/20 hover:text-white/40 hover:bg-white/5`}`,children:e===`all`?`TODAS`:We[e]||e},e))}),g.length===0?(0,$.jsxs)(`div`,{className:`py-16 flex flex-col items-center justify-center border border-dashed border-white/10 rounded-2xl bg-zinc-950/20 group hover:border-violet-500/20 transition-colors`,children:[(0,$.jsx)(`div`,{className:`p-4 rounded-full bg-zinc-900 mb-4 group-hover:scale-110 transition-transform`,children:(0,$.jsx)(V,{className:`h-8 w-8 text-zinc-700 group-hover:text-violet-500/50 transition-colors`})}),(0,$.jsx)(`p`,{className:`text-xs text-zinc-500 font-medium`,children:`Sin herramientas en esta categoría.`})]}):(0,$.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6`,children:g.map(e=>{let t=e.active,n=e.core;return(0,$.jsxs)(`div`,{onClick:()=>c({...e}),className:`hive-card group cursor-pointer transition-all duration-500 ${t?`hive-card--active`:`hive-card--disabled`}`,children:[(0,$.jsxs)(`div`,{className:`hive-card-body relative overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between mb-6`,children:[(0,$.jsxs)(`div`,{className:`hive-icon-wrap--internal ${t?`hive-icon-wrap--internal-active`:`hive-icon-wrap--internal-disabled`}`,children:[e.category===`filesystem`&&(0,$.jsx)(Pe,{className:`h-6 w-6`}),e.category===`web`&&(0,$.jsx)(Pe,{className:`h-6 w-6`}),e.category===`cron`&&(0,$.jsx)(I,{className:`h-6 w-6`}),e.category===`cli`&&(0,$.jsx)(M,{className:`h-6 w-6`}),e.category===`agents`&&(0,$.jsx)(ze,{className:`h-6 w-6`}),e.category===`canvas`&&(0,$.jsx)(M,{className:`h-6 w-6`}),e.category===`voice`&&(0,$.jsx)(ze,{className:`h-6 w-6`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n&&(0,$.jsx)(`span`,{className:`hive-status-label--active`,children:`NATIVO`}),(0,$.jsx)(h,{checked:t,onCheckedChange:()=>p(e.id,!t),onClick:e=>e.stopPropagation(),className:`data-[state=checked]:bg-blue-500 scale-75 origin-right`})]})]}),(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-lg font-black text-white uppercase tracking-tighter mb-1 line-clamp-1 group-hover:text-blue-400 transition-colors`,children:e.name}),(0,$.jsx)(`p`,{className:`hive-subtitle !mt-0 !text-[11px] h-8 line-clamp-2`,children:e.description||`Sin descripción disponible`})]}),(0,$.jsxs)(`div`,{className:`pt-4 border-t border-white/5 flex items-center gap-4`,children:[(0,$.jsxs)(`div`,{className:`hive-stat`,children:[(0,$.jsx)(`span`,{className:`hive-stat__label`,children:`TIPO`}),(0,$.jsx)(`span`,{className:`hive-stat__value truncate max-w-[80px]`,children:e.category})]}),(0,$.jsxs)(`div`,{className:`hive-stat`,children:[(0,$.jsx)(`span`,{className:`hive-stat__label`,children:`ESTADO`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:t?`hive-status-dot--active`:`hive-status-dot--disabled`}),(0,$.jsx)(`span`,{className:t?`hive-status-label--active`:`hive-status-label--disabled`,children:t?`ACTIVE`:`STANDBY`})]})]})]})]}),t&&(0,$.jsx)(`div`,{className:`hive-glow-blob--card hive-glow-blob--blue -bottom-10 -right-10 h-24 w-24 opacity-20`})]}),(0,$.jsx)(`div`,{className:`hive-strip--bottom ${t?``:`opacity-20`}`})]},e.id)})}),(0,$.jsx)(Se,{open:!!s,onOpenChange:e=>!e&&c(null),children:(0,$.jsxs)(be,{className:`sm:max-w-sm bg-zinc-950 border-white/10`,children:[(0,$.jsxs)(ye,{children:[(0,$.jsxs)(xe,{className:`flex items-center gap-2 text-sm`,children:[(0,$.jsx)(`div`,{className:`p-1.5 rounded-lg bg-violet-500/10 text-violet-400`,children:(0,$.jsx)(ze,{className:`h-3.5 w-3.5`})}),`Editar herramienta`]}),(0,$.jsx)(ve,{className:`text-[10px] text-zinc-500 font-medium`,children:`Modifica los parámetros y la descripción de la herramienta seleccionada.`})]}),(0,$.jsxs)(`div`,{className:`space-y-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(Z,{className:`text-[10px] text-zinc-500 uppercase tracking-widest font-bold`,children:`Nombre`}),(0,$.jsx)(q,{value:s?.name||``,onChange:e=>c({...s,name:e.target.value}),className:`h-9 text-sm bg-white/5 border-white/10 focus:border-violet-500/50`})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(Z,{className:`text-[10px] text-zinc-500 uppercase tracking-widest font-bold`,children:`Descripción`}),(0,$.jsx)(z,{value:s?.description||``,onChange:e=>c({...s,description:e.target.value}),className:`text-sm min-h-[80px] resize-none bg-white/5 border-white/10 focus:border-violet-500/50 font-mono`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 pt-1 border-t border-white/5`,children:[(0,$.jsx)(`span`,{className:`font-mono text-[10px] bg-zinc-900 border border-white/5 text-zinc-500 px-2 py-0.5 rounded truncate max-w-[180px]`,children:s?.id}),(0,$.jsx)(Ce,{variant:`outline`,className:`text-[9px] border-zinc-800 text-zinc-500 uppercase`,children:s?.category})]})]}),(0,$.jsxs)(ge,{className:`gap-2 sm:gap-0`,children:[(0,$.jsx)(W,{variant:`outline`,size:`sm`,onClick:()=>c(null),className:`hive-btn--form-cancel h-10`,children:`Cancelar`}),(0,$.jsxs)(W,{size:`sm`,onClick:m,disabled:d,className:`hive-btn--form-submit h-10`,children:[d&&(0,$.jsx)(O,{className:`h-3.5 w-3.5 animate-spin`}),`Guardar Cambios`]})]})]})})]})}function Ke({server:e,onClick:t,isConnected:n,isLoading:r}){let i=n||e.status===`connected`,a=e.transport===`stdio`;return(0,$.jsxs)(Oe,{onClick:t,className:`group relative overflow-hidden transition-all hover:border-cyan-500/50 hover:shadow-lg hover:shadow-cyan-500/5 cursor-pointer border-white/5 bg-zinc-950/50 backdrop-blur-sm ${i?`border-cyan-500/20 bg-cyan-500/[0.02]`:`opacity-80 grayscale-[0.2]`} ${r?`pointer-events-none opacity-50`:``}`,children:[(0,$.jsx)(`div`,{className:`absolute top-0 left-0 w-1 h-full transition-colors ${i?`bg-cyan-500`:`bg-zinc-800`}`}),(0,$.jsxs)(we,{className:`pb-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between mb-2`,children:[(0,$.jsx)(`div`,{className:`p-2 rounded-lg transition-colors ${i?`bg-cyan-500/10 text-cyan-400`:`bg-zinc-800 text-zinc-500`}`,children:a?(0,$.jsx)(b,{className:`h-5 w-5`}):(0,$.jsx)(C,{className:`h-5 w-5`})}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:i?(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-0.5 rounded-full bg-cyan-500/10 border border-cyan-500/20`,children:[(0,$.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full bg-cyan-500 animate-pulse`}),(0,$.jsx)(`span`,{className:`text-[10px] font-bold text-cyan-500 uppercase tracking-wider`,children:`LIVE`})]}):(0,$.jsx)(Ce,{variant:`outline`,className:`text-[10px] border-zinc-800 text-zinc-500 uppercase tracking-tighter`,children:`OFFLINE`})})]}),(0,$.jsx)(Ee,{className:`text-sm font-bold truncate group-hover:text-cyan-400 transition-colors`,children:e.name}),(0,$.jsx)(De,{className:`text-[10px] font-mono opacity-50 truncate mt-0.5`,children:e.url||`stdio: ${e.transport}`})]}),(0,$.jsxs)(Te,{className:`pt-0 pb-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3 mt-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{className:`text-[9px] text-zinc-500 uppercase font-bold tracking-widest`,children:`Transport`}),(0,$.jsx)(`span`,{className:`text-xs font-semibold text-zinc-300`,children:e.transport})]}),(0,$.jsx)(`div`,{className:`h-4 w-px bg-white/10`}),(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{className:`text-[9px] text-zinc-500 uppercase font-bold tracking-widest`,children:`Tools`}),(0,$.jsxs)(`span`,{className:`text-xs font-semibold text-zinc-300`,children:[e.tools?.length||e.tools_count||0,` expuestas`]})]})]}),e.builtin&&(0,$.jsx)(Ce,{variant:`outline`,className:`mt-3 text-[9px] border-amber-500/20 text-amber-500/70 bg-amber-500/5`,children:`BUILTIN`})]}),i&&(0,$.jsx)(`div`,{className:`absolute -bottom-6 -right-6 w-12 h-12 bg-cyan-500/10 blur-2xl rounded-full`})]})}function qe({serverId:e,serverName:t,tools:n=[]}){let[r,i]=(0,Q.useState)(``),a=n.filter(e=>e.name.toLowerCase().includes(r.toLowerCase())||e.description.toLowerCase().includes(r.toLowerCase()));return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 relative`,children:[(0,$.jsx)(I,{className:`absolute left-2.5 top-2.5 h-3.5 w-3.5 text-zinc-500`}),(0,$.jsx)(q,{placeholder:`Buscar herramientas...`,className:`pl-8 h-8 text-[11px] bg-white/5 border-white/10 focus:border-cyan-500/30`,value:r,onChange:e=>i(e.target.value)})]}),(0,$.jsx)(`div`,{className:`space-y-2 max-h-[300px] overflow-y-auto pr-1 custom-scrollbar`,children:a.length===0?(0,$.jsx)(`div`,{className:`py-8 text-center text-[10px] text-zinc-500 italic`,children:r?`No se encontraron herramientas que coincidan.`:`Este servidor no expone herramientas actualmente.`}):a.map(e=>(0,$.jsxs)(`div`,{className:`p-3 rounded-lg bg-zinc-900/50 border border-white/5 hover:border-cyan-500/20 transition-all group`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`p-1.5 rounded bg-cyan-500/5 text-cyan-400 group-hover:bg-cyan-500/10 transition-colors`,children:(0,$.jsx)(Fe,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`h5`,{className:`text-[11px] font-bold text-zinc-200 group-hover:text-cyan-400 transition-colors`,children:e.name})]}),e.inputSchema&&(0,$.jsx)(Ce,{variant:`outline`,className:`text-[9px] border-zinc-800 text-zinc-600 h-4`,children:`JSON Schema`})]}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[10px] text-zinc-500 leading-relaxed line-clamp-2`,children:e.description})]},e.name))}),(0,$.jsxs)(`div`,{className:`p-2 rounded bg-cyan-500/5 border border-cyan-500/10 flex items-center gap-2`,children:[(0,$.jsx)(E,{className:`h-3 w-3 text-cyan-500`}),(0,$.jsxs)(`span`,{className:`text-[9px] text-cyan-200/50`,children:[`Estas herramientas son gestionadas directamente por `,(0,$.jsx)(`span`,{className:`text-cyan-400 font-mono`,children:t}),`.`]})]})]})}function Je(e){return e?e[`x-api-key`]?{authType:`api-key`,authToken:e[`x-api-key`]}:e.Authorization?.startsWith(`Bearer `)?{authType:`bearer`,authToken:e.Authorization.replace(`Bearer `,``)}:Object.keys(e).length>0?{authType:`custom`,authToken:``}:{authType:`none`,authToken:``}:{authType:`none`,authToken:``}}function Ye({server:e,onClose:t}){let{updateMCPServer:n,toggleMCPServer:r,deleteMCPServer:i,fetchMCPServers:a}=pe(),[o,s]=(0,Q.useState)(e.transport||`stdio`),[c,d]=(0,Q.useState)(e.command||``),[h,g]=(0,Q.useState)(e.args?.join(` `)||``),[_,v]=(0,Q.useState)(e.url||``),[y,b]=(0,Q.useState)(()=>Je(e.headers).authType),[x,S]=(0,Q.useState)(()=>Je(e.headers).authToken),[w,T]=(0,Q.useState)(e.headers?JSON.stringify(e.headers,null,2):``),[E,A]=(0,Q.useState)(!1),[j,N]=(0,Q.useState)(!1),[P,F]=(0,Q.useState)(!1),[I,L]=(0,Q.useState)(!0),[R,z]=(0,Q.useState)(!1),[B,V]=(0,Q.useState)(`config`),[H,te]=(0,Q.useState)(e.status),[ne,re]=(0,Q.useState)(e.active),U=H===`connected`||ne===1||ne===!0;return(0,Q.useEffect)(()=>{let t=!1;return(async()=>{L(!0);try{let n=await Y(`/api/mcp/servers/${e.id}`);if(t)return;s(n.transport||`stdio`),d(n.command||``),g(Array.isArray(n.args)?n.args.join(` `):``),v(n.url||``);let r=Je(n.headers);b(r.authType),S(r.authToken),T(n.headers?JSON.stringify(n.headers,null,2):``),te(n.status||e.status),re(+!!n.enabled)}catch{}finally{t||L(!1)}})(),()=>{t=!0}},[e.id]),(0,$.jsx)(Se,{open:!0,onOpenChange:e=>!e&&t(),children:(0,$.jsxs)(be,{className:`sm:max-w-[500px] border-cyan-500/20 bg-zinc-950/95 backdrop-blur-xl p-0 overflow-hidden`,children:[(0,$.jsx)(`div`,{className:`absolute top-0 left-0 w-full h-1 bg-gradient-to-r from-transparent via-cyan-500/50 to-transparent`}),(0,$.jsxs)(ye,{className:`p-6 pb-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`p-2 rounded-lg ${U?`bg-cyan-500/10 text-cyan-400`:`bg-zinc-800 text-zinc-500`}`,children:(0,$.jsx)(ze,{className:`h-5 w-5`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(xe,{className:`text-white flex items-center gap-2`,children:[`Configurar `,e.name,U&&(0,$.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full bg-cyan-500 animate-pulse`})]}),(0,$.jsxs)(ve,{className:`text-[10px] font-mono opacity-50 uppercase tracking-widest mt-0.5`,children:[`ID: `,e.id,` • `,e.transport]})]})]}),!e.builtin&&(0,$.jsx)(W,{variant:`ghost`,size:`icon`,onClick:()=>z(!0),disabled:j||R,className:`text-zinc-600 hover:text-red-400 hover:bg-red-400/10 h-8 w-8 transition-colors`,title:`Eliminar Servidor`,children:(0,$.jsx)(ee,{className:`h-4 w-4`})})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 mt-6 border-b border-white/5`,children:[(0,$.jsxs)(`button`,{onClick:()=>V(`config`),className:`px-4 py-2 text-[10px] uppercase font-bold tracking-widest transition-all relative ${B===`config`?`text-cyan-400`:`text-zinc-500 hover:text-zinc-300`}`,children:[`Configuración`,B===`config`&&(0,$.jsx)(`div`,{className:`absolute bottom-0 left-0 w-full h-0.5 bg-cyan-500`})]}),(0,$.jsxs)(`button`,{onClick:()=>V(`tools`),className:`px-4 py-2 text-[10px] uppercase font-bold tracking-widest transition-all relative ${B===`tools`?`text-cyan-400`:`text-zinc-500 hover:text-zinc-300`}`,children:[`Herramientas`,B===`tools`&&(0,$.jsx)(`div`,{className:`absolute bottom-0 left-0 w-full h-0.5 bg-cyan-500`})]})]})]}),R&&(0,$.jsxs)(`div`,{className:`mx-6 mt-4 p-3 rounded-lg bg-red-500/10 border border-red-500/30 animate-in fade-in slide-in-from-top-2 duration-200`,children:[(0,$.jsxs)(`p`,{className:`text-xs text-red-400 font-medium mb-3`,children:[`¿Eliminar `,(0,$.jsx)(`span`,{className:`font-bold`,children:e.name}),`? Esta acción no se puede deshacer.`]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 justify-end`,children:[(0,$.jsx)(W,{variant:`ghost`,size:`sm`,onClick:()=>z(!1),disabled:j,className:`h-7 px-3 text-[10px] font-bold uppercase tracking-wider text-zinc-400 hover:text-white`,children:`Cancelar`}),(0,$.jsx)(W,{size:`sm`,onClick:async()=>{N(!0);try{await Y(`/api/mcp/servers/${e.id}`,{method:`DELETE`,showLoader:`Eliminando servidor...`,showError:!0}),await a(),t()}catch{}finally{N(!1),z(!1)}},disabled:j,className:`h-7 px-3 text-[10px] font-bold uppercase tracking-wider bg-red-600 hover:bg-red-500 text-white`,children:j?(0,$.jsx)(O,{className:`h-3 w-3 animate-spin`}):`Sí, eliminar`})]})]}),(0,$.jsx)(`div`,{className:`p-6`,children:B===`config`?(0,$.jsxs)(`div`,{className:`space-y-4 animate-in fade-in duration-300`,children:[I&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-zinc-500`,children:[(0,$.jsx)(O,{className:`h-3 w-3 animate-spin`}),(0,$.jsx)(`span`,{children:`Cargando configuración...`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Transporte`}),(0,$.jsxs)(f,{value:o,onValueChange:s,children:[(0,$.jsx)(m,{className:`bg-white/5 border-white/10 h-9`,children:(0,$.jsx)(u,{})}),(0,$.jsxs)(p,{className:`bg-zinc-900 border-white/10`,children:[(0,$.jsx)(l,{value:`stdio`,className:`focus:bg-cyan-500/20 focus:text-cyan-400`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(M,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`stdio (Binario Local)`})]})}),(0,$.jsx)(l,{value:`sse`,className:`focus:bg-cyan-500/20 focus:text-cyan-400`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(C,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`SSE (Remote HTTP)`})]})})]})]})]}),o===`stdio`?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Comando`}),(0,$.jsx)(q,{value:c,onChange:e=>d(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 h-9`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Argumentos`}),(0,$.jsx)(q,{value:h,onChange:e=>g(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 h-9`})]})]}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Endpoint URL`}),(0,$.jsx)(q,{value:_,onChange:e=>v(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 h-9`})]}),(0,$.jsxs)(`div`,{className:`space-y-4 pt-2 border-t border-white/5`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Autenticación`}),(0,$.jsxs)(f,{value:y,onValueChange:b,children:[(0,$.jsx)(m,{className:`bg-white/5 border-white/10 focus:border-cyan-500/50 h-9`,children:(0,$.jsx)(u,{})}),(0,$.jsxs)(p,{className:`bg-zinc-900 border-white/10`,children:[(0,$.jsx)(l,{value:`none`,className:`focus:bg-cyan-500/20 focus:text-cyan-400`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(C,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Ninguna`})]})}),(0,$.jsx)(l,{value:`api-key`,className:`focus:bg-cyan-500/20 focus:text-cyan-400`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(D,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`API Key (x-api-key)`})]})}),(0,$.jsx)(l,{value:`bearer`,className:`focus:bg-cyan-500/20 focus:text-cyan-400`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Be,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Bearer Token (Authorization)`})]})}),(0,$.jsx)(l,{value:`custom`,className:`focus:bg-cyan-500/20 focus:text-cyan-400`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Me,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Custom Headers (JSON)`})]})})]})]})]}),(y===`api-key`||y===`bearer`)&&(0,$.jsxs)(`div`,{className:`space-y-2 animate-in fade-in slide-in-from-top-1 duration-200`,children:[(0,$.jsx)(Z,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:y===`api-key`?`API Key`:`Bearer Token`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(q,{type:`password`,placeholder:`sk-...`,value:x,onChange:e=>S(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 transition-all h-9 pl-9`}),(0,$.jsx)(k,{className:`absolute left-3 top-2.5 h-3.5 w-3.5 text-zinc-500`})]})]}),y===`custom`&&(0,$.jsxs)(`div`,{className:`space-y-2 animate-in fade-in slide-in-from-top-1 duration-200`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,$.jsx)(Z,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Headers JSON`})}),(0,$.jsx)(`textarea`,{value:w,onChange:e=>T(e.target.value),placeholder:`{ "x-custom-auth": "secret" }`,rows:3,className:`w-full bg-white/5 border border-white/10 rounded-md p-2 text-xs text-zinc-300 focus:outline-none focus:border-cyan-500/50 transition-all font-mono`})]})]})]}),(0,$.jsxs)(`div`,{className:`p-3 rounded-lg bg-zinc-900 border border-white/5 flex items-center justify-between mt-6`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`p-1.5 rounded-full ${U?`bg-green-500/10 text-green-400`:`bg-zinc-800 text-zinc-500`}`,children:(0,$.jsx)(Re,{className:`h-3.5 w-3.5 ${U?`animate-pulse`:``}`})}),(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{className:`text-[10px] font-bold text-zinc-300 uppercase tracking-tight`,children:`Estado del Nodo`}),(0,$.jsx)(`span`,{className:`text-[9px] font-mono ${U?`text-green-500`:`text-zinc-500`}`,children:U?`ACTIVE_CONNECTION`:`INACTIVE_NODE`})]})]}),(0,$.jsx)(W,{size:`sm`,variant:U?`outline`:`default`,onClick:async()=>{F(!0),G.show(U?`Desconectando servidor...`:`Conectando servidor...`);try{await r(e.id,!U),re(+!U),te(U?`disconnected`:`connected`),J.fire({icon:`success`,title:U?`Servidor desconectado`:`Servidor conectado`}),setTimeout(a,1500)}catch{J.fire({icon:`error`,title:`Error al cambiar estado de conexión`})}finally{F(!1),G.hide()}},disabled:P,className:`h-7 px-4 text-[10px] font-bold uppercase tracking-wider ${U?`border-zinc-800 text-zinc-400 hover:bg-zinc-800`:`bg-cyan-600 hover:bg-cyan-500 text-white`}`,children:P?(0,$.jsx)(O,{className:`h-3 w-3 animate-spin`}):U?`Desconectar`:`Conectar`})]})]}):(0,$.jsx)(`div`,{className:`animate-in fade-in duration-300`,children:(0,$.jsx)(qe,{serverId:e.id,serverName:e.name,tools:e.tools||[]})})}),(0,$.jsxs)(ge,{className:`p-6 bg-white/[0.02] border-t border-white/5`,children:[(0,$.jsx)(W,{variant:`ghost`,onClick:t,className:`text-zinc-500 hover:text-white`,children:`Cerrar`}),B===`config`&&(0,$.jsx)(W,{onClick:async()=>{A(!0),G.show(`Actualizando configuración...`);try{let t={transport:o};if(o===`stdio`){if(!c){J.fire({icon:`warning`,title:`El comando es obligatorio`});return}t.command=c;let e=h.trim();if(e.startsWith(`[`)&&e.endsWith(`]`))try{t.args=JSON.parse(e)}catch{t.args=e.match(/"[^"]*"|'[^']*'|[^\\s,]+/g)?.map(e=>e.replace(/^["']|["']$/g,``).replace(/,$/,``).trim()).filter(Boolean)||[]}else t.args=e.match(/"[^"]*"|'[^']*'|[^\\s,]+/g)?.map(e=>e.replace(/^["']|["']$/g,``).replace(/,$/,``).trim()).filter(Boolean)||[]}else if(o===`sse`){if(!_){J.fire({icon:`warning`,title:`La URL es obligatoria`});return}t.url=_;let e={};if(y===`api-key`&&x)e[`x-api-key`]=x;else if(y===`bearer`&&x)e.Authorization=`Bearer ${x}`;else if(y===`custom`&&w.trim())try{e=JSON.parse(w.trim())}catch{J.fire({icon:`error`,title:`JSON de Headers inválido`});return}Object.keys(e).length>0&&(t.headers=e)}await n(e.id,t),await a(),J.fire({icon:`success`,title:`Configuración actualizada`})}catch(e){J.fire({icon:`error`,title:e instanceof Error?e.message:`Error al actualizar configuración`})}finally{A(!1),G.hide()}},disabled:E,className:`bg-cyan-600 hover:bg-cyan-500 text-white min-w-[120px]`,children:E?(0,$.jsx)(O,{className:`h-4 w-4 animate-spin`}):`Guardar Cambios`})]})]})})}function Xe(){let{fetchMCPServers:e}=pe(),[t,n]=(0,Q.useState)(!1),[r,i]=(0,Q.useState)(``),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(``),[d,h]=(0,Q.useState)(`stdio`),[g,_]=(0,Q.useState)(``),[v,b]=(0,Q.useState)(`none`),[x,S]=(0,Q.useState)(``),[w,T]=(0,Q.useState)(``),[E,O]=(0,Q.useState)(!1);return(0,$.jsxs)(Se,{open:t,onOpenChange:n,children:[(0,$.jsx)(_e,{asChild:!0,children:(0,$.jsxs)(W,{className:`bg-cyan-600 hover:bg-cyan-500 text-white shadow-lg shadow-cyan-600/20 gap-2`,children:[(0,$.jsx)(P,{className:`h-4 w-4`}),`Añadir Servidor MCP`]})}),(0,$.jsxs)(be,{className:`sm:max-w-[425px] border-cyan-500/20 bg-zinc-950/95 backdrop-blur-xl`,children:[(0,$.jsxs)(ye,{children:[(0,$.jsxs)(xe,{className:`flex items-center gap-2 text-white`,children:[(0,$.jsx)(`div`,{className:`p-1.5 rounded-md bg-cyan-500/10 text-cyan-400`,children:(0,$.jsx)(le,{className:`h-4 w-4`})}),`Nuevo Servidor MCP`]}),(0,$.jsx)(ve,{className:`text-zinc-400`,children:`Conecta una nueva fuente de herramientas para tus agentes mediante el protocolo MCP.`})]}),(0,$.jsxs)(`div`,{className:`grid gap-4 py-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{htmlFor:`mcp-name`,className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Nombre Identificador`}),(0,$.jsx)(q,{id:`mcp-name`,placeholder:`github-tools`,value:r,onChange:e=>i(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 transition-all h-9`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Protocolo de Transporte`}),(0,$.jsxs)(f,{value:d,onValueChange:h,children:[(0,$.jsx)(m,{className:`bg-zinc-900/80 border-white/10 text-white focus:border-cyan-500/50 hover:bg-zinc-900 transition-all h-9 cursor-pointer`,children:(0,$.jsx)(u,{placeholder:`Seleccionar transporte`})}),(0,$.jsxs)(p,{position:`popper`,className:`bg-zinc-900 border-white/10 z-[99999]`,sideOffset:4,children:[(0,$.jsx)(l,{value:`stdio`,className:`focus:bg-cyan-500/20 focus:text-cyan-400 cursor-pointer`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(M,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`stdio (Binario Local)`})]})}),(0,$.jsx)(l,{value:`sse`,className:`focus:bg-cyan-500/20 focus:text-cyan-400 cursor-pointer`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(C,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`SSE (Remote HTTP)`})]})})]})]})]}),d===`stdio`?(0,$.jsxs)(`div`,{className:`space-y-4 animate-in fade-in slide-in-from-top-2 duration-300`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{htmlFor:`mcp-cmd`,className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Comando Ejecutable`}),(0,$.jsx)(q,{id:`mcp-cmd`,placeholder:`npx`,value:a,onChange:e=>o(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 transition-all h-9`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{htmlFor:`mcp-args`,className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Argumentos`}),(0,$.jsx)(q,{id:`mcp-args`,placeholder:`-y @modelcontextprotocol/server-github`,value:s,onChange:e=>c(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 transition-all h-9`})]})]}):(0,$.jsxs)(`div`,{className:`space-y-4 animate-in fade-in slide-in-from-top-2 duration-300`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{htmlFor:`mcp-url`,className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Endpoint URL`}),(0,$.jsx)(q,{id:`mcp-url`,placeholder:`https://mcp-server.com/sse`,value:g,onChange:e=>_(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 transition-all h-9`})]}),(0,$.jsxs)(`div`,{className:`space-y-4 pt-2 border-t border-white/5`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Autenticación`}),(0,$.jsxs)(f,{value:v,onValueChange:b,children:[(0,$.jsx)(m,{className:`bg-zinc-900/80 border-white/10 text-white focus:border-cyan-500/50 hover:bg-zinc-900 transition-all h-9 cursor-pointer`,children:(0,$.jsx)(u,{placeholder:`Seleccionar autenticación`})}),(0,$.jsxs)(p,{position:`popper`,className:`bg-zinc-900 border-white/10 z-[99999]`,sideOffset:4,children:[(0,$.jsx)(l,{value:`none`,className:`focus:bg-cyan-500/20 focus:text-cyan-400 cursor-pointer`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(C,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Ninguna`})]})}),(0,$.jsx)(l,{value:`api-key`,className:`focus:bg-cyan-500/20 focus:text-cyan-400 cursor-pointer`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(D,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`API Key (x-api-key)`})]})}),(0,$.jsx)(l,{value:`bearer`,className:`focus:bg-cyan-500/20 focus:text-cyan-400 cursor-pointer`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Be,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Bearer Token (Authorization)`})]})}),(0,$.jsx)(l,{value:`google-api-key`,className:`focus:bg-cyan-500/20 focus:text-cyan-400 cursor-pointer`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(D,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Google API Key (X-Goog-Api-Key)`})]})}),(0,$.jsx)(l,{value:`custom`,className:`focus:bg-cyan-500/20 focus:text-cyan-400 cursor-pointer`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Me,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Custom Headers (JSON)`})]})})]})]})]}),(v===`api-key`||v===`google-api-key`||v===`bearer`)&&(0,$.jsxs)(`div`,{className:`space-y-2 animate-in fade-in slide-in-from-top-1 duration-200`,children:[(0,$.jsx)(Z,{htmlFor:`mcp-token`,className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:v===`api-key`?`API Key`:v===`google-api-key`?`Google API Key`:`Bearer Token`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(q,{id:`mcp-token`,type:`password`,placeholder:`sk-...`,value:x,onChange:e=>S(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 transition-all h-9 pl-9`}),(0,$.jsx)(k,{className:`absolute left-3 top-2.5 h-3.5 w-3.5 text-zinc-500`})]})]}),v===`custom`&&(0,$.jsxs)(`div`,{className:`space-y-2 animate-in fade-in slide-in-from-top-1 duration-200`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,$.jsx)(Z,{htmlFor:`mcp-headers`,className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Headers JSON`})}),(0,$.jsx)(`textarea`,{id:`mcp-headers`,placeholder:`{ "x-custom-auth": "secret" }`,rows:3,value:w,onChange:e=>{let t=e.target.value;T(t);try{t.trim()&&JSON.parse(t.trim()),e.target.style.borderColor=``}catch{t.trim()?e.target.style.borderColor=`rgba(239, 68, 68, 0.5)`:e.target.style.borderColor=``}},className:`w-full bg-white/5 border border-white/10 rounded-md p-2 text-xs text-zinc-300 focus:outline-none focus:border-cyan-500/50 transition-all font-mono`})]})]})]}),(0,$.jsxs)(`div`,{className:`p-3 rounded-lg bg-cyan-500/5 border border-cyan-500/10 flex items-center gap-3`,children:[(0,$.jsx)(y,{className:`h-5 w-5 text-cyan-500 shrink-0`}),(0,$.jsx)(`div`,{className:`text-[10px] text-cyan-200/70`,children:`El servidor se inicializará y validará inmediatamente después de ser añadido.`})]})]}),(0,$.jsxs)(ge,{children:[(0,$.jsx)(W,{variant:`ghost`,onClick:()=>n(!1),className:`hover:bg-white/5 text-zinc-400 h-9 text-xs`,children:`Cancelar`}),(0,$.jsx)(W,{onClick:async()=>{if(!r){J.fire({icon:`error`,title:`El nombre es obligatorio`});return}O(!0);try{let t={transport:d};if(d===`stdio`){if(!a){J.fire({icon:`error`,title:`El comando es obligatorio para transporte stdio`}),O(!1);return}t.command=a;let e=s.trim();if(e.startsWith(`[`)&&e.endsWith(`]`))try{t.args=JSON.parse(e)}catch{t.args=e.match(/"[^"]*"|'[^']*'|[^\\s,]+/g)?.map(e=>e.replace(/^["']|["']$/g,``).replace(/,$/,``).trim()).filter(Boolean)||[]}else t.args=e.match(/"[^"]*"|'[^']*'|[^\\s,]+/g)?.map(e=>e.replace(/^["']|["']$/g,``).replace(/,$/,``).trim()).filter(Boolean)||[]}else{if(!g){J.fire({icon:`error`,title:`La URL es obligatoria para transporte SSE`}),O(!1);return}t.url=g;let e={};if(v===`api-key`&&x)e[`x-api-key`]=x;else if(v===`google-api-key`&&x)e[`X-Goog-Api-Key`]=x;else if(v===`bearer`&&x)e.Authorization=`Bearer ${x}`;else if(v===`custom`&&w.trim())try{e=JSON.parse(w.trim())}catch{K.fire(`Error`,`JSON de Headers inválido`,`error`),O(!1);return}Object.keys(e).length>0&&(t.headers=e)}await Y(`/api/mcp/servers`,{method:`POST`,body:{name:r,config:t},showLoader:`Conectando servidor MCP...`,showError:!0}),J.fire({icon:`success`,title:`Servidor "${r}" añadido correctamente`}),i(``),o(``),c(``),_(``),b(`none`),S(``),T(``),n(!1),await e()}catch{}finally{O(!1)}},disabled:E,className:`bg-cyan-600 hover:bg-cyan-500 text-white shadow-lg shadow-cyan-600/20 h-9 text-xs px-6`,children:E?`Conectando...`:`Conectar Servidor`})]})]})]})}function Ze(){let{servers:e,activeServers:t,isLoading:n,fetchMCPServers:r}=pe(),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(``);(0,Q.useEffect)(()=>{r()},[r]);let c=e.filter(e=>e.name.toLowerCase().includes(o.toLowerCase())),l=e=>{a({...e,args:typeof e.args==`string`?JSON.parse(e.args):e.args})};return(0,$.jsxs)(`div`,{className:`space-y-6`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-white/5 pb-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`p-2 rounded-lg bg-cyan-500/10 text-cyan-400`,children:(0,$.jsx)(le,{className:`h-5 w-5`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h4`,{className:`text-sm font-bold text-white uppercase tracking-wider`,children:`MCP Ecosystem`}),(0,$.jsx)(`p`,{className:`text-[10px] text-zinc-500 font-mono`,children:`Model Context Protocol Servers`})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,$.jsxs)(`div`,{className:`relative group`,children:[(0,$.jsx)(I,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-zinc-500 group-focus-within:text-cyan-400 transition-colors`}),(0,$.jsx)(q,{placeholder:`Buscar servidor...`,value:o,onChange:e=>s(e.target.value),className:`pl-9 bg-zinc-900/50 border-white/5 focus:border-cyan-500/30 transition-all h-9 w-[260px] text-xs`})]}),(0,$.jsx)(Xe,{})]})]}),c.length===0?(0,$.jsxs)(`div`,{className:`py-16 flex flex-col items-center justify-center border border-dashed border-white/10 rounded-2xl bg-zinc-950/20 group hover:border-cyan-500/20 transition-colors`,children:[(0,$.jsx)(`div`,{className:`p-4 rounded-full bg-zinc-900 mb-4 group-hover:scale-110 transition-transform`,children:(0,$.jsx)(V,{className:`h-8 w-8 text-zinc-700 group-hover:text-cyan-500/50 transition-colors`})}),(0,$.jsx)(`p`,{className:`text-xs text-zinc-500 font-medium`,children:`No se detectan servidores MCP configurados.`}),(0,$.jsx)(`p`,{className:`text-[10px] text-zinc-600 mt-1`,children:`Añade uno para expandir las capacidades de tus agentes.`})]}):(0,$.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4`,children:c.map(e=>(0,$.jsx)(Ke,{server:e,isConnected:e.status===`connected`||e.active===!0,onClick:()=>l(e)},e.id))}),i&&(0,$.jsx)(Ye,{server:i,onClose:()=>a(null)})]})}var Qe=()=>(0,$.jsxs)(`svg`,{"aria-hidden":!0,className:`absolute inset-0 w-full h-full pointer-events-none`,xmlns:`http://www.w3.org/2000/svg`,style:{opacity:.05,color:`hsl(var(--hive-amber))`},children:[(0,$.jsx)(`defs`,{children:(0,$.jsx)(`pattern`,{id:`hc-profile`,x:`0`,y:`0`,width:`30`,height:`34`,patternUnits:`userSpaceOnUse`,children:(0,$.jsx)(`polygon`,{points:`15,2 28,9.5 28,24.5 15,32 2,24.5 2,9.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`1`})})}),(0,$.jsx)(`rect`,{width:`100%`,height:`100%`,fill:`url(#hc-profile)`})]}),$e=({initials:e,size:t=`lg`})=>{let n=t===`sm`?`w-14 h-14`:`w-20 h-20`,r=t===`sm`?`text-lg`:`text-2xl`;return(0,$.jsxs)(`div`,{className:`relative ${n} flex-shrink-0`,children:[(0,$.jsx)(`div`,{className:`w-full h-full flex items-center justify-center text-white font-black ${r} tracking-tight select-none`,style:{clipPath:`polygon(50% 0%, 95% 25%, 95% 75%, 50% 100%, 5% 75%, 5% 25%)`,background:`linear-gradient(135deg, hsl(var(--hive-amber)) 0%, hsl(var(--hive-orange)) 100%)`,boxShadow:`0 0 24px hsl(var(--hive-amber) / 0.4)`},children:e}),(0,$.jsx)(`span`,{className:`absolute bottom-0.5 right-1 h-3.5 w-3.5 rounded-full border-2 animate-pulse`,style:{background:`hsl(var(--hive-green))`,borderColor:`hsl(var(--background))`,boxShadow:`0 0 8px hsl(var(--hive-green) / 0.6)`}})]})},et=({children:e})=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-2.5`,children:[(0,$.jsx)(w,{className:`h-3 w-3 flex-shrink-0`,style:{color:`hsl(var(--hive-amber))`,fill:`hsl(var(--hive-amber) / 0.2)`}}),(0,$.jsx)(`p`,{className:`text-[10px] font-black uppercase tracking-[0.18em]`,style:{color:`hsl(var(--hive-amber) / 0.85)`},children:e})]}),tt=()=>(0,$.jsx)(`div`,{className:`h-px`,style:{background:`linear-gradient(90deg,transparent,hsl(var(--hive-amber)/0.18),transparent)`}}),nt=({icon:e,label:t,colorVar:n})=>(0,$.jsxs)(`span`,{className:`flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-medium border`,style:{background:`hsl(var(${n}) / 0.08)`,borderColor:`hsl(var(${n}) / 0.2)`,color:`hsl(var(${n}))`},children:[(0,$.jsx)(e,{className:`h-2.5 w-2.5 flex-shrink-0`}),t]}),rt=({label:e,icon:t,editing:n,children:r})=>(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-1.5 text-[10px] font-bold uppercase tracking-widest transition-colors`,style:{color:n?`hsl(var(--hive-text-muted))`:`hsl(var(--hive-text-placeholder))`},children:[(0,$.jsx)(t,{className:`h-3 w-3 opacity-60`}),e]}),r]});function it(e){return e.split(` `).map(e=>e[0]).slice(0,2).join(``).toUpperCase()||`?`}function at(){let{fetchUser:e,saveUser:t,isLoading:n}=ue(),{channels:r}=fe(),[i,a]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)({name:``,occupation:``,language:``,timezone:``,preferred_cron_channel:`auto`,notes:``}),[h,g]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{e().then(e=>{if(!e)return;let t={name:e.name||``,occupation:e.occupation||``,language:e.language||``,timezone:e.timezone||``,preferred_cron_channel:e.preferred_cron_channel||`auto`,notes:e.notes||``};c(t),g(t)}).catch(console.error)},[e]);let _=(e,t)=>c(n=>({...n,[e]:t})),v=()=>{h&&c(h),a(!1)},y=async()=>{G.show(`Guardando perfil...`);try{let e=await t(s);g(s),J.fire({icon:`success`,title:e}),a(!1)}catch(e){J.fire({icon:`error`,title:e instanceof Error?e.message:`Error al guardar`})}finally{G.hide()}},b=r.filter(e=>e.active),x=s.preferred_cron_channel===`auto`?`Auto — detectar mejor canal`:b.find(e=>e.type===s.preferred_cron_channel)?.type??s.preferred_cron_channel,S=it(s.name);return(0,$.jsxs)(`div`,{className:`relative overflow-hidden rounded-2xl border flex flex-col lg:flex-row`,style:{background:`hsl(var(--hive-surface)/0.7)`,borderColor:`hsl(var(--hive-border-base))`,backdropFilter:`blur(16px)`,boxShadow:`0 0 60px hsl(var(--hive-amber)/0.05)`},children:[(0,$.jsxs)(`div`,{className:`relative overflow-hidden flex-shrink-0 lg:w-[40%] lg:flex-col lg:items-center lg:text-center
|
|
1
|
+
import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as t}from"./vendor-charts-Bu2lyBKP.js";import{o as n}from"./vendor-query-DsWPbQdG.js";import{n as r,r as i}from"./utils-3pnRFmFe.js";import{t as a}from"./activity-c3pNngT_.js";import{n as o,t as s}from"./send-B0H5SEIE.js";import{t as c}from"./calendar-B-KZ9RQO.js";import{a as l,c as u,l as d,n as f,r as p,s as m,t as h}from"./switch-BDwN8RYV.js";import{n as g,t as _}from"./chevron-up-BYhk0K2J.js";import{t as v}from"./circle-alert-CyHDwUj8.js";import{t as y}from"./circle-check-Bb54Ebmu.js";import{t as b}from"./cpu-Cdgc_B1K.js";import{n as x,t as S}from"./eye-DqNTU_GD.js";import{t as C}from"./globe-DeCQTCDJ.js";import{t as w}from"./hexagon-DsGOUl-H.js";import{t as T}from"./history-BSG-Ypqf.js";import{t as E}from"./info-NwLoa2Mj.js";import{t as D}from"./key-3EP0dhkT.js";import{t as O}from"./loader-circle-CZNax6kS.js";import{t as k}from"./lock-Ei1_J-Nq.js";import{t as A}from"./pause-BUqah9Bi.js";import{n as j,t as M}from"./terminal-DN38Q456.js";import{t as N}from"./play-NcZ4swwL.js";import{t as P}from"./plus-CX1xyhp5.js";import{t as F}from"./refresh-cw-DaYdjQFk.js";import{n as I,t as L}from"./scroll-area-DkeyX32e.js";import{n as R,t as z}from"./textarea-CXgXWKrT.js";import{t as B}from"./sparkles-yUEb-7oH.js";import{t as ee}from"./trash-2-CNjMkoq6.js";import{t as V}from"./triangle-alert-C9Y8Ub4X.js";import{t as H}from"./zap-hlXjpSeA.js";import{l as te}from"./vendor-router-C9pIYwbJ.js";import{r as ne}from"./gateway-url-COCbW0IR.js";import{B as re,G as U,H as ie,J as ae,M as W,R as oe,U as se,V as ce,W as le,f as ue,g as G,h as K,j as q,l as de,m as J,n as fe,o as pe,p as Y,q as X,u as me,z as he}from"./index-CQ7fn00w.js";import{t as Z}from"./label-CrH0Jj3v.js";import{a as ge,c as _e,i as ve,o as ye,r as be,s as xe,t as Se}from"./dialog-bI9jImCS.js";import{t as Ce}from"./badge-DXUDdTed.js";import{a as we,n as Te,o as Ee,r as De,t as Oe}from"./card-CNf6BS2e.js";import"./useProviders-CnlC_qCS.js";var ke=i(`Briefcase`,[[`path`,{d:`M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16`,key:`jecpp`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`6`,rx:`2`,key:`i6l2r4`}]]),Ae=i(`ChartColumn`,[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]]),je=i(`CodeXml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),Me=i(`Code`,[[`polyline`,{points:`16 18 22 12 16 6`,key:`z7tu5w`}],[`polyline`,{points:`8 6 2 12 8 18`,key:`1eg1df`}]]),Ne=i(`Copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Pe=i(`Earth`,[[`path`,{d:`M21.54 15H17a2 2 0 0 0-2 2v4.54`,key:`1djwo0`}],[`path`,{d:`M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17`,key:`1tzkfa`}],[`path`,{d:`M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05`,key:`14pb5j`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Fe=i(`Hammer`,[[`path`,{d:`m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9`,key:`eefl8a`}],[`path`,{d:`m18 15 4-4`,key:`16gjal`}],[`path`,{d:`m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172V7l-2.26-2.26a6 6 0 0 0-4.202-1.756L9 2.96l.92.82A6.18 6.18 0 0 1 12 8.4V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5`,key:`b7pghm`}]]),Ie=i(`Languages`,[[`path`,{d:`m5 8 6 6`,key:`1wu5hv`}],[`path`,{d:`m4 14 6-6 2-3`,key:`1k1g8d`}],[`path`,{d:`M2 5h12`,key:`or177f`}],[`path`,{d:`M7 2h1`,key:`1t2jsx`}],[`path`,{d:`m22 22-5-10-5 10`,key:`don7ne`}],[`path`,{d:`M14 18h6`,key:`1m8k6r`}]]),Le=i(`MessageCircle`,[[`path`,{d:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,key:`vv11sd`}]]),Re=i(`Power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),ze=i(`Settings2`,[[`path`,{d:`M20 7h-9`,key:`3s1dr2`}],[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),Be=i(`ShieldCheck`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Ve=i(`ShieldOff`,[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]),Q=e(t(),1),He=ne((e,t)=>({isLoading:!1,error:null,configs:[],conflicts:[],templates:[],setLoading:t=>e({isLoading:t}),setError:t=>e({error:t}),fetchEthics:async()=>{e({isLoading:!0,error:null});try{let t=(await Y(`/api/ethics`)).ethics||[],n=t.find(e=>e.active)||t[0];return e({configs:t,isLoading:!1}),n?.content||``}catch(t){throw e({isLoading:!1,error:t instanceof Error?t.message:`Failed to fetch ethics`}),t}},saveEthics:async n=>{e({isLoading:!0,error:null});try{let r=t(),i=r.configs.find(e=>e.active)||r.configs[0],a;return a=i?await Y(`/api/ethics/${i.id}`,{method:`PUT`,body:{content:n}}):await Y(`/api/ethics`,{method:`POST`,body:{name:`Default`,content:n,active:!0}}),e({isLoading:!1}),a.message||`Guardado correctamente`}catch(t){throw e({isLoading:!1,error:t instanceof Error?t.message:`Failed to save ethics`}),t}},fetchConfigs:async()=>{e({isLoading:!0,error:null});try{e({configs:await Y(`/api/workspace/ethics/configs`),isLoading:!1})}catch(t){e({isLoading:!1,error:t instanceof Error?t.message:`Failed to fetch configs`})}},fetchConflicts:async()=>{e({isLoading:!0,error:null});try{e({conflicts:await Y(`/api/workspace/ethics/conflicts`),isLoading:!1})}catch(t){e({isLoading:!1,error:t instanceof Error?t.message:`Failed to fetch conflicts`})}},fetchTemplates:async()=>{e({isLoading:!0,error:null});try{e({templates:await Y(`/api/workspace/ethics/templates`),isLoading:!1})}catch(t){e({isLoading:!1,error:t instanceof Error?t.message:`Failed to fetch templates`})}},updateConfig:(t,n)=>{e(e=>({configs:e.configs.map(e=>e.id===t?{...e,...n,updatedAt:new Date().toISOString(),version:e.version+1}:e)}))},addConfig:t=>{let n={...t,id:r(),version:1,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};e(e=>({configs:[...e.configs,n]}))},removeConfig:t=>{e(e=>({configs:e.configs.filter(e=>e.id!==t)}))}})),$=n();function Ue(){let{configs:e,fetchEthics:t,isLoading:n}=He(),[r,i]=(0,Q.useState)(null),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)({name:``,description:``,content:``}),[l,u]=(0,Q.useState)(!1),d=(0,Q.useRef)(null),f=()=>{let e=d.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)};(0,Q.useEffect)(()=>{a&&setTimeout(f,0)},[a,s.content]),(0,Q.useEffect)(()=>{t().catch(console.error)},[t]),(0,Q.useEffect)(()=>{if(e.length===0)return;let t=e,n=t.find(e=>e.active)||t[0];r||(i(n.id),c({name:n.name,description:n.description||``,content:n.content}))},[e,r]);let p=e.find(e=>e.id===r),m=e=>{i(e.id),c({name:e.name,description:e.description||``,content:e.content}),o(!0)},h=async n=>{G.show(`Activando registro de ética...`);let r=e;try{let e=await Promise.all(r.map(e=>Y(`/api/ethics/${e.id}`,{method:`PUT`,body:{active:+(e.id===n)}}).catch(()=>({}))));await t();let i=e.find((e,t)=>r[t].id===n);J.fire({icon:`success`,title:i?.message||`Registro de ética activado`})}catch(e){J.fire({icon:`error`,title:e instanceof Error?e.message:`Error al activar registro`})}finally{G.hide()}};return n&&e.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-20 border border-white/5 bg-zinc-950/30 rounded-2xl`,children:[(0,$.jsx)(O,{className:`h-8 w-8 animate-spin text-amber-500 mb-4 opacity-50`}),(0,$.jsx)(`span`,{className:`hive-label`,children:`Cargando lineamientos operativos...`})]}):(0,$.jsxs)(`div`,{className:`space-y-8 animate-fade-in`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,$.jsx)(`h3`,{className:`hive-title-section !text-lg`,children:`Protocolos Éticos`}),(0,$.jsxs)(`span`,{className:`hive-tag hive-tag--provider`,children:[e.length,` REGISTROS`]})]}),(0,$.jsx)(`p`,{className:`hive-subtitle !mt-0 !text-xs`,children:`Define la capa moral y los límites operacionales de tus agentes inteligentes.`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] uppercase tracking-widest font-black text-white/20 bg-white/5 px-4 py-2 rounded-xl border border-white/5`,children:[(0,$.jsx)(R,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Configuración del Núcleo`})]})]}),e.length===0?(0,$.jsx)(`div`,{className:`hive-card border-dashed border-white/10 bg-white/[0.02]`,children:(0,$.jsxs)(`div`,{className:`hive-card-body flex flex-col items-center justify-center py-16 px-4`,children:[(0,$.jsx)(`div`,{className:`h-16 w-16 rounded-2xl bg-white/5 flex items-center justify-center mb-6`,children:(0,$.jsx)(V,{className:`h-8 w-8 text-white/20`})}),(0,$.jsxs)(`div`,{className:`text-center`,children:[(0,$.jsx)(`p`,{className:`hive-title-section text-center mb-2`,children:`Sin Protocolos Base`}),(0,$.jsx)(`p`,{className:`text-xs text-white/40 mb-8 max-w-[300px] mx-auto leading-relaxed`,children:`No se han detectado lineamientos éticos en el sistema. Selecciona una de las plantillas inferiores para comenzar.`})]})]})}):(0,$.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6`,children:e.map(e=>{let t=!!e.active,n=r===e.id;return(0,$.jsxs)(`div`,{onClick:()=>m(e),className:`hive-card group transition-all duration-500 cursor-pointer ${n?`hive-card--active`:`opacity-60 grayscale-[0.8] hover:opacity-100 hover:grayscale-0`}`,children:[(0,$.jsxs)(`div`,{className:`hive-card-body relative overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between mb-6`,children:[(0,$.jsx)(`div`,{className:`hive-icon-wrap--internal ${n?`hive-icon-wrap--internal-active`:`hive-icon-wrap--internal-disabled`}`,children:(0,$.jsx)(se,{className:`h-6 w-6`})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t&&(0,$.jsx)(`span`,{className:`hive-status-label--active`,children:`ACTIVO`}),(0,$.jsx)(`div`,{className:t?`hive-status-dot--active`:`hive-status-dot--disabled`})]})]}),(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-lg font-black text-white uppercase tracking-tighter mb-1 line-clamp-1 group-hover:text-blue-400 transition-colors text-ellipsis`,children:e.name}),(0,$.jsx)(`p`,{className:`text-xs text-white/40 font-medium leading-relaxed line-clamp-1 h-4`,children:e.description||`Sin descripción adicional`})]}),(0,$.jsxs)(`div`,{className:`pt-4 border-t border-white/5 flex items-center gap-4`,children:[(0,$.jsxs)(`div`,{className:`hive-stat`,children:[(0,$.jsx)(`span`,{className:`hive-stat__label`,children:`CONFIG`}),(0,$.jsx)(`span`,{className:`hive-stat__value`,children:e.is_default?`DEFAULT`:`CUSTOM`})]}),(0,$.jsxs)(`div`,{className:`hive-stat`,children:[(0,$.jsx)(`span`,{className:`hive-stat__label`,children:`PRECEDENCIA`}),(0,$.jsx)(`span`,{className:`hive-stat__value`,children:t?`ALTA`:`NORMAL`})]})]})]}),n&&(0,$.jsx)(`div`,{className:`hive-glow-blob--card hive-glow-blob--blue -bottom-10 -right-10 h-24 w-24 opacity-20`})]}),(0,$.jsx)(`div`,{className:`hive-strip--bottom ${t?``:`opacity-20`}`})]},e.id)})}),(0,$.jsx)(Se,{open:a,onOpenChange:o,children:(0,$.jsx)(be,{className:`max-w-4xl border-white/10 !bg-[#09090b] p-0 overflow-hidden shadow-2xl`,children:p&&(0,$.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between p-6 border-b border-white/5 bg-white/5 relative overflow-hidden`,children:[(0,$.jsx)(`div`,{className:`hive-glow-blob hive-glow-blob--blue -top-10 -right-10 h-32 w-32 opacity-20`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-4 relative z-10`,children:[(0,$.jsx)(`div`,{className:`hive-icon-wrap--internal hive-icon-wrap--internal-active`,children:(0,$.jsx)(R,{className:`h-6 w-6`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(xe,{className:`hive-title-page !text-2xl uppercase tracking-tighter`,children:p.name}),(0,$.jsx)(ve,{className:`hive-subtitle !mt-0`,children:`Sintonización de la capa moral y operativa del agente.`})]})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-3 relative z-10`,children:!p.active&&(0,$.jsx)(`button`,{className:`hive-btn hive-btn--ghost px-6 text-[10px]`,onClick:()=>h(p.id),children:`ESTABLECER COMO ACTIVO`})})]}),(0,$.jsx)(`div`,{className:`p-6 space-y-4 border-b border-white/5`,children:(0,$.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{className:`hive-label uppercase !text-[10px]`,children:`Nombre del Protocolo`}),(0,$.jsx)(q,{value:s.name,onChange:e=>c(t=>({...t,name:e.target.value})),className:`bg-white/5 border-white/5 focus-visible:ring-blue-500/30 text-white font-bold`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{className:`hive-label uppercase !text-[10px]`,children:`Descripción / Meta`}),(0,$.jsx)(q,{value:s.description,onChange:e=>c(t=>({...t,description:e.target.value})),className:`bg-white/5 border-white/5 focus-visible:ring-blue-500/30 text-white/60 text-xs italic`})]})]})}),(0,$.jsxs)(`div`,{className:`p-0 bg-[#09090b]`,children:[(0,$.jsx)(`div`,{className:`px-6 pt-4`,children:(0,$.jsx)(Z,{className:`hive-label uppercase !text-[10px]`,children:`Lineamientos de Capa (Markdown)`})}),(0,$.jsx)(z,{ref:d,placeholder:`Define los lineamientos éticos del agente...`,value:s.content,onChange:e=>{c(t=>({...t,content:e.target.value})),f()},className:`hive-textarea w-full !bg-zinc-950/50 border-none focus-visible:ring-0 text-amber-50/90 font-mono text-xs leading-relaxed min-h-[400px] p-8 resize-none placeholder:text-white/10 overflow-hidden`})]}),(0,$.jsxs)(`div`,{className:`p-6 bg-white/[0.02] border-t border-white/5 flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-6`,children:[(0,$.jsxs)(`div`,{className:`hive-stat`,children:[(0,$.jsx)(`span`,{className:`hive-stat__label`,children:`IDENTIFICADOR`}),(0,$.jsx)(`span`,{className:`hive-stat__value`,children:p.id})]}),(0,$.jsxs)(`div`,{className:`hive-stat`,children:[(0,$.jsx)(`span`,{className:`hive-stat__label`,children:`ESTADO DE CAPA`}),(0,$.jsx)(`span`,{className:`hive-stat__value hive-stat__value--active`,children:p.active?`SISTEMA ACTIVO`:`PENDIENTE`})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`button`,{className:`hive-btn hive-btn--ghost px-6 text-[10px]`,onClick:()=>o(!1),children:`CANCELAR`}),(0,$.jsx)(`button`,{onClick:async()=>{if(p){u(!0),G.show(`Guardando lineamientos éticos...`);try{let e=await Y(`/api/ethics/${p.id}`,{method:`PUT`,body:s});await t(),J.fire({icon:`success`,title:e.message||`Contenido ético guardado`})}catch(e){J.fire({icon:`error`,title:e instanceof Error?e.message:`Error al guardar`})}finally{u(!1),G.hide(),o(!1)}}},disabled:l,className:`hive-btn hive-btn--primary px-8 text-[10px]`,children:l?`SINCRONIZANDO...`:`GUARDAR LINEAMIENTOS`})]})]})]})})})]})}var We={filesystem:`Sistema de archivos`,web:`Web`,cron:`Cron`,cli:`CLI`,agents:`Agentes`,canvas:`Canvas`,voice:`Voz`};function Ge(){let{tools:e,isLoading:t,fetchTools:n,toggleTool:r,updateTool:i}=me(),[a,o]=(0,Q.useState)(`all`),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{n()},[n]);let p=async(e,t)=>{if(!l){u(e);try{await r(e,t),n(),J.fire({icon:`success`,title:`Herramienta ${t?`activada`:`desactivada`}`})}catch{J.fire({icon:`error`,title:`Error al actualizar estado de la herramienta`})}finally{u(null)}}},m=async()=>{if(s){f(!0),G.show(`Guardando herramienta...`);try{await i(s.id,{name:s.name,description:s.description}),J.fire({icon:`success`,title:`Herramienta actualizada`}),n(),c(null)}catch{J.fire({icon:`error`,title:`Error al guardar cambios`})}finally{f(!1),G.hide()}}};if(t&&e.length===0)return(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-20 border border-white/5 bg-zinc-950/30 rounded-2xl`,children:[(0,$.jsx)(O,{className:`h-8 w-8 animate-spin text-violet-500 mb-4 opacity-50`}),(0,$.jsx)(`span`,{className:`text-xs uppercase font-bold tracking-[0.2em] text-zinc-500`,children:`Cargando herramientas...`})]});let g=e.filter(e=>a===`all`?!0:e.category===a);return(0,$.jsxs)(`div`,{className:`space-y-8 animate-fade-in`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,$.jsx)(`h3`,{className:`hive-title-section !text-lg !text-white/80`,children:`Herramientas`}),(0,$.jsxs)(`span`,{className:`hive-tag bg-white/5 text-white/40 border-white/10`,children:[g.length,` DISPONIBLES`]})]}),(0,$.jsx)(`p`,{className:`hive-subtitle !mt-0 !text-xs`,children:`Gestiona las capacidades externas y el arsenal tecnológico de tu agente.`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] uppercase tracking-widest font-black text-white/20 bg-white/5 px-4 py-2 rounded-xl border border-white/5`,children:[(0,$.jsx)(he,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Arsenal Operativo`})]})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-1.5 p-1 bg-white/5 rounded-2xl w-fit border border-white/5`,children:[`all`,`filesystem`,`web`,`cron`,`cli`,`agents`,`canvas`,`a2ui`,`voice`].map(e=>(0,$.jsx)(`button`,{onClick:()=>o(e),className:`px-6 py-2 rounded-xl text-[10px] font-black tracking-widest uppercase transition-all duration-300 ${a===e?`bg-blue-600 text-white shadow-btn-primary`:`text-white/20 hover:text-white/40 hover:bg-white/5`}`,children:e===`all`?`TODAS`:We[e]||e},e))}),g.length===0?(0,$.jsxs)(`div`,{className:`py-16 flex flex-col items-center justify-center border border-dashed border-white/10 rounded-2xl bg-zinc-950/20 group hover:border-violet-500/20 transition-colors`,children:[(0,$.jsx)(`div`,{className:`p-4 rounded-full bg-zinc-900 mb-4 group-hover:scale-110 transition-transform`,children:(0,$.jsx)(V,{className:`h-8 w-8 text-zinc-700 group-hover:text-violet-500/50 transition-colors`})}),(0,$.jsx)(`p`,{className:`text-xs text-zinc-500 font-medium`,children:`Sin herramientas en esta categoría.`})]}):(0,$.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6`,children:g.map(e=>{let t=e.active,n=e.core;return(0,$.jsxs)(`div`,{onClick:()=>c({...e}),className:`hive-card group cursor-pointer transition-all duration-500 ${t?`hive-card--active`:`hive-card--disabled`}`,children:[(0,$.jsxs)(`div`,{className:`hive-card-body relative overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between mb-6`,children:[(0,$.jsxs)(`div`,{className:`hive-icon-wrap--internal ${t?`hive-icon-wrap--internal-active`:`hive-icon-wrap--internal-disabled`}`,children:[e.category===`filesystem`&&(0,$.jsx)(Pe,{className:`h-6 w-6`}),e.category===`web`&&(0,$.jsx)(Pe,{className:`h-6 w-6`}),e.category===`cron`&&(0,$.jsx)(I,{className:`h-6 w-6`}),e.category===`cli`&&(0,$.jsx)(M,{className:`h-6 w-6`}),e.category===`agents`&&(0,$.jsx)(ze,{className:`h-6 w-6`}),e.category===`canvas`&&(0,$.jsx)(M,{className:`h-6 w-6`}),e.category===`voice`&&(0,$.jsx)(ze,{className:`h-6 w-6`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n&&(0,$.jsx)(`span`,{className:`hive-status-label--active`,children:`NATIVO`}),(0,$.jsx)(h,{checked:t,onCheckedChange:()=>p(e.id,!t),onClick:e=>e.stopPropagation(),className:`data-[state=checked]:bg-blue-500 scale-75 origin-right`})]})]}),(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-lg font-black text-white uppercase tracking-tighter mb-1 line-clamp-1 group-hover:text-blue-400 transition-colors`,children:e.name}),(0,$.jsx)(`p`,{className:`hive-subtitle !mt-0 !text-[11px] h-8 line-clamp-2`,children:e.description||`Sin descripción disponible`})]}),(0,$.jsxs)(`div`,{className:`pt-4 border-t border-white/5 flex items-center gap-4`,children:[(0,$.jsxs)(`div`,{className:`hive-stat`,children:[(0,$.jsx)(`span`,{className:`hive-stat__label`,children:`TIPO`}),(0,$.jsx)(`span`,{className:`hive-stat__value truncate max-w-[80px]`,children:e.category})]}),(0,$.jsxs)(`div`,{className:`hive-stat`,children:[(0,$.jsx)(`span`,{className:`hive-stat__label`,children:`ESTADO`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:t?`hive-status-dot--active`:`hive-status-dot--disabled`}),(0,$.jsx)(`span`,{className:t?`hive-status-label--active`:`hive-status-label--disabled`,children:t?`ACTIVE`:`STANDBY`})]})]})]})]}),t&&(0,$.jsx)(`div`,{className:`hive-glow-blob--card hive-glow-blob--blue -bottom-10 -right-10 h-24 w-24 opacity-20`})]}),(0,$.jsx)(`div`,{className:`hive-strip--bottom ${t?``:`opacity-20`}`})]},e.id)})}),(0,$.jsx)(Se,{open:!!s,onOpenChange:e=>!e&&c(null),children:(0,$.jsxs)(be,{className:`sm:max-w-sm bg-zinc-950 border-white/10`,children:[(0,$.jsxs)(ye,{children:[(0,$.jsxs)(xe,{className:`flex items-center gap-2 text-sm`,children:[(0,$.jsx)(`div`,{className:`p-1.5 rounded-lg bg-violet-500/10 text-violet-400`,children:(0,$.jsx)(ze,{className:`h-3.5 w-3.5`})}),`Editar herramienta`]}),(0,$.jsx)(ve,{className:`text-[10px] text-zinc-500 font-medium`,children:`Modifica los parámetros y la descripción de la herramienta seleccionada.`})]}),(0,$.jsxs)(`div`,{className:`space-y-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(Z,{className:`text-[10px] text-zinc-500 uppercase tracking-widest font-bold`,children:`Nombre`}),(0,$.jsx)(q,{value:s?.name||``,onChange:e=>c({...s,name:e.target.value}),className:`h-9 text-sm bg-white/5 border-white/10 focus:border-violet-500/50`})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(Z,{className:`text-[10px] text-zinc-500 uppercase tracking-widest font-bold`,children:`Descripción`}),(0,$.jsx)(z,{value:s?.description||``,onChange:e=>c({...s,description:e.target.value}),className:`text-sm min-h-[80px] resize-none bg-white/5 border-white/10 focus:border-violet-500/50 font-mono`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 pt-1 border-t border-white/5`,children:[(0,$.jsx)(`span`,{className:`font-mono text-[10px] bg-zinc-900 border border-white/5 text-zinc-500 px-2 py-0.5 rounded truncate max-w-[180px]`,children:s?.id}),(0,$.jsx)(Ce,{variant:`outline`,className:`text-[9px] border-zinc-800 text-zinc-500 uppercase`,children:s?.category})]})]}),(0,$.jsxs)(ge,{className:`gap-2 sm:gap-0`,children:[(0,$.jsx)(W,{variant:`outline`,size:`sm`,onClick:()=>c(null),className:`hive-btn--form-cancel h-10`,children:`Cancelar`}),(0,$.jsxs)(W,{size:`sm`,onClick:m,disabled:d,className:`hive-btn--form-submit h-10`,children:[d&&(0,$.jsx)(O,{className:`h-3.5 w-3.5 animate-spin`}),`Guardar Cambios`]})]})]})})]})}function Ke({server:e,onClick:t,isConnected:n,isLoading:r}){let i=n||e.status===`connected`,a=e.transport===`stdio`;return(0,$.jsxs)(Oe,{onClick:t,className:`group relative overflow-hidden transition-all hover:border-cyan-500/50 hover:shadow-lg hover:shadow-cyan-500/5 cursor-pointer border-white/5 bg-zinc-950/50 backdrop-blur-sm ${i?`border-cyan-500/20 bg-cyan-500/[0.02]`:`opacity-80 grayscale-[0.2]`} ${r?`pointer-events-none opacity-50`:``}`,children:[(0,$.jsx)(`div`,{className:`absolute top-0 left-0 w-1 h-full transition-colors ${i?`bg-cyan-500`:`bg-zinc-800`}`}),(0,$.jsxs)(we,{className:`pb-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between mb-2`,children:[(0,$.jsx)(`div`,{className:`p-2 rounded-lg transition-colors ${i?`bg-cyan-500/10 text-cyan-400`:`bg-zinc-800 text-zinc-500`}`,children:a?(0,$.jsx)(b,{className:`h-5 w-5`}):(0,$.jsx)(C,{className:`h-5 w-5`})}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:i?(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-0.5 rounded-full bg-cyan-500/10 border border-cyan-500/20`,children:[(0,$.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full bg-cyan-500 animate-pulse`}),(0,$.jsx)(`span`,{className:`text-[10px] font-bold text-cyan-500 uppercase tracking-wider`,children:`LIVE`})]}):(0,$.jsx)(Ce,{variant:`outline`,className:`text-[10px] border-zinc-800 text-zinc-500 uppercase tracking-tighter`,children:`OFFLINE`})})]}),(0,$.jsx)(Ee,{className:`text-sm font-bold truncate group-hover:text-cyan-400 transition-colors`,children:e.name}),(0,$.jsx)(De,{className:`text-[10px] font-mono opacity-50 truncate mt-0.5`,children:e.url||`stdio: ${e.transport}`})]}),(0,$.jsxs)(Te,{className:`pt-0 pb-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3 mt-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{className:`text-[9px] text-zinc-500 uppercase font-bold tracking-widest`,children:`Transport`}),(0,$.jsx)(`span`,{className:`text-xs font-semibold text-zinc-300`,children:e.transport})]}),(0,$.jsx)(`div`,{className:`h-4 w-px bg-white/10`}),(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{className:`text-[9px] text-zinc-500 uppercase font-bold tracking-widest`,children:`Tools`}),(0,$.jsxs)(`span`,{className:`text-xs font-semibold text-zinc-300`,children:[e.tools?.length||e.tools_count||0,` expuestas`]})]})]}),e.builtin&&(0,$.jsx)(Ce,{variant:`outline`,className:`mt-3 text-[9px] border-amber-500/20 text-amber-500/70 bg-amber-500/5`,children:`BUILTIN`})]}),i&&(0,$.jsx)(`div`,{className:`absolute -bottom-6 -right-6 w-12 h-12 bg-cyan-500/10 blur-2xl rounded-full`})]})}function qe({serverId:e,serverName:t,tools:n=[]}){let[r,i]=(0,Q.useState)(``),a=n.filter(e=>e.name.toLowerCase().includes(r.toLowerCase())||e.description.toLowerCase().includes(r.toLowerCase()));return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 relative`,children:[(0,$.jsx)(I,{className:`absolute left-2.5 top-2.5 h-3.5 w-3.5 text-zinc-500`}),(0,$.jsx)(q,{placeholder:`Buscar herramientas...`,className:`pl-8 h-8 text-[11px] bg-white/5 border-white/10 focus:border-cyan-500/30`,value:r,onChange:e=>i(e.target.value)})]}),(0,$.jsx)(`div`,{className:`space-y-2 max-h-[300px] overflow-y-auto pr-1 custom-scrollbar`,children:a.length===0?(0,$.jsx)(`div`,{className:`py-8 text-center text-[10px] text-zinc-500 italic`,children:r?`No se encontraron herramientas que coincidan.`:`Este servidor no expone herramientas actualmente.`}):a.map(e=>(0,$.jsxs)(`div`,{className:`p-3 rounded-lg bg-zinc-900/50 border border-white/5 hover:border-cyan-500/20 transition-all group`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`p-1.5 rounded bg-cyan-500/5 text-cyan-400 group-hover:bg-cyan-500/10 transition-colors`,children:(0,$.jsx)(Fe,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`h5`,{className:`text-[11px] font-bold text-zinc-200 group-hover:text-cyan-400 transition-colors`,children:e.name})]}),e.inputSchema&&(0,$.jsx)(Ce,{variant:`outline`,className:`text-[9px] border-zinc-800 text-zinc-600 h-4`,children:`JSON Schema`})]}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[10px] text-zinc-500 leading-relaxed line-clamp-2`,children:e.description})]},e.name))}),(0,$.jsxs)(`div`,{className:`p-2 rounded bg-cyan-500/5 border border-cyan-500/10 flex items-center gap-2`,children:[(0,$.jsx)(E,{className:`h-3 w-3 text-cyan-500`}),(0,$.jsxs)(`span`,{className:`text-[9px] text-cyan-200/50`,children:[`Estas herramientas son gestionadas directamente por `,(0,$.jsx)(`span`,{className:`text-cyan-400 font-mono`,children:t}),`.`]})]})]})}function Je(e){return e?e[`x-api-key`]?{authType:`api-key`,authToken:e[`x-api-key`]}:e.Authorization?.startsWith(`Bearer `)?{authType:`bearer`,authToken:e.Authorization.replace(`Bearer `,``)}:Object.keys(e).length>0?{authType:`custom`,authToken:``}:{authType:`none`,authToken:``}:{authType:`none`,authToken:``}}function Ye({server:e,onClose:t}){let{updateMCPServer:n,toggleMCPServer:r,deleteMCPServer:i,fetchMCPServers:a}=pe(),[o,s]=(0,Q.useState)(e.transport||`stdio`),[c,d]=(0,Q.useState)(e.command||``),[h,g]=(0,Q.useState)(e.args?.join(` `)||``),[_,v]=(0,Q.useState)(e.url||``),[y,b]=(0,Q.useState)(()=>Je(e.headers).authType),[x,S]=(0,Q.useState)(()=>Je(e.headers).authToken),[w,T]=(0,Q.useState)(e.headers?JSON.stringify(e.headers,null,2):``),[E,A]=(0,Q.useState)(!1),[j,N]=(0,Q.useState)(!1),[P,F]=(0,Q.useState)(!1),[I,L]=(0,Q.useState)(!0),[R,z]=(0,Q.useState)(!1),[B,V]=(0,Q.useState)(`config`),[H,te]=(0,Q.useState)(e.status),[ne,re]=(0,Q.useState)(e.active),U=H===`connected`||ne===1||ne===!0;return(0,Q.useEffect)(()=>{let t=!1;return(async()=>{L(!0);try{let n=await Y(`/api/mcp/servers/${e.id}`);if(t)return;s(n.transport||`stdio`),d(n.command||``),g(Array.isArray(n.args)?n.args.join(` `):``),v(n.url||``);let r=Je(n.headers);b(r.authType),S(r.authToken),T(n.headers?JSON.stringify(n.headers,null,2):``),te(n.status||e.status),re(+!!n.enabled)}catch{}finally{t||L(!1)}})(),()=>{t=!0}},[e.id]),(0,$.jsx)(Se,{open:!0,onOpenChange:e=>!e&&t(),children:(0,$.jsxs)(be,{className:`sm:max-w-[500px] border-cyan-500/20 bg-zinc-950/95 backdrop-blur-xl p-0 overflow-hidden`,children:[(0,$.jsx)(`div`,{className:`absolute top-0 left-0 w-full h-1 bg-gradient-to-r from-transparent via-cyan-500/50 to-transparent`}),(0,$.jsxs)(ye,{className:`p-6 pb-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`p-2 rounded-lg ${U?`bg-cyan-500/10 text-cyan-400`:`bg-zinc-800 text-zinc-500`}`,children:(0,$.jsx)(ze,{className:`h-5 w-5`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(xe,{className:`text-white flex items-center gap-2`,children:[`Configurar `,e.name,U&&(0,$.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full bg-cyan-500 animate-pulse`})]}),(0,$.jsxs)(ve,{className:`text-[10px] font-mono opacity-50 uppercase tracking-widest mt-0.5`,children:[`ID: `,e.id,` • `,e.transport]})]})]}),!e.builtin&&(0,$.jsx)(W,{variant:`ghost`,size:`icon`,onClick:()=>z(!0),disabled:j||R,className:`text-zinc-600 hover:text-red-400 hover:bg-red-400/10 h-8 w-8 transition-colors`,title:`Eliminar Servidor`,children:(0,$.jsx)(ee,{className:`h-4 w-4`})})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 mt-6 border-b border-white/5`,children:[(0,$.jsxs)(`button`,{onClick:()=>V(`config`),className:`px-4 py-2 text-[10px] uppercase font-bold tracking-widest transition-all relative ${B===`config`?`text-cyan-400`:`text-zinc-500 hover:text-zinc-300`}`,children:[`Configuración`,B===`config`&&(0,$.jsx)(`div`,{className:`absolute bottom-0 left-0 w-full h-0.5 bg-cyan-500`})]}),(0,$.jsxs)(`button`,{onClick:()=>V(`tools`),className:`px-4 py-2 text-[10px] uppercase font-bold tracking-widest transition-all relative ${B===`tools`?`text-cyan-400`:`text-zinc-500 hover:text-zinc-300`}`,children:[`Herramientas`,B===`tools`&&(0,$.jsx)(`div`,{className:`absolute bottom-0 left-0 w-full h-0.5 bg-cyan-500`})]})]})]}),R&&(0,$.jsxs)(`div`,{className:`mx-6 mt-4 p-3 rounded-lg bg-red-500/10 border border-red-500/30 animate-in fade-in slide-in-from-top-2 duration-200`,children:[(0,$.jsxs)(`p`,{className:`text-xs text-red-400 font-medium mb-3`,children:[`¿Eliminar `,(0,$.jsx)(`span`,{className:`font-bold`,children:e.name}),`? Esta acción no se puede deshacer.`]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 justify-end`,children:[(0,$.jsx)(W,{variant:`ghost`,size:`sm`,onClick:()=>z(!1),disabled:j,className:`h-7 px-3 text-[10px] font-bold uppercase tracking-wider text-zinc-400 hover:text-white`,children:`Cancelar`}),(0,$.jsx)(W,{size:`sm`,onClick:async()=>{N(!0);try{await Y(`/api/mcp/servers/${e.id}`,{method:`DELETE`,showLoader:`Eliminando servidor...`,showError:!0}),await a(),t()}catch{}finally{N(!1),z(!1)}},disabled:j,className:`h-7 px-3 text-[10px] font-bold uppercase tracking-wider bg-red-600 hover:bg-red-500 text-white`,children:j?(0,$.jsx)(O,{className:`h-3 w-3 animate-spin`}):`Sí, eliminar`})]})]}),(0,$.jsx)(`div`,{className:`p-6`,children:B===`config`?(0,$.jsxs)(`div`,{className:`space-y-4 animate-in fade-in duration-300`,children:[I&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-zinc-500`,children:[(0,$.jsx)(O,{className:`h-3 w-3 animate-spin`}),(0,$.jsx)(`span`,{children:`Cargando configuración...`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Transporte`}),(0,$.jsxs)(f,{value:o,onValueChange:s,children:[(0,$.jsx)(m,{className:`bg-white/5 border-white/10 h-9`,children:(0,$.jsx)(u,{})}),(0,$.jsxs)(p,{className:`bg-zinc-900 border-white/10`,children:[(0,$.jsx)(l,{value:`stdio`,className:`focus:bg-cyan-500/20 focus:text-cyan-400`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(M,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`stdio (Binario Local)`})]})}),(0,$.jsx)(l,{value:`sse`,className:`focus:bg-cyan-500/20 focus:text-cyan-400`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(C,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`SSE (Remote HTTP)`})]})})]})]})]}),o===`stdio`?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Comando`}),(0,$.jsx)(q,{value:c,onChange:e=>d(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 h-9`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Argumentos`}),(0,$.jsx)(q,{value:h,onChange:e=>g(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 h-9`})]})]}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Endpoint URL`}),(0,$.jsx)(q,{value:_,onChange:e=>v(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 h-9`})]}),(0,$.jsxs)(`div`,{className:`space-y-4 pt-2 border-t border-white/5`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Autenticación`}),(0,$.jsxs)(f,{value:y,onValueChange:b,children:[(0,$.jsx)(m,{className:`bg-white/5 border-white/10 focus:border-cyan-500/50 h-9`,children:(0,$.jsx)(u,{})}),(0,$.jsxs)(p,{className:`bg-zinc-900 border-white/10`,children:[(0,$.jsx)(l,{value:`none`,className:`focus:bg-cyan-500/20 focus:text-cyan-400`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(C,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Ninguna`})]})}),(0,$.jsx)(l,{value:`api-key`,className:`focus:bg-cyan-500/20 focus:text-cyan-400`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(D,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`API Key (x-api-key)`})]})}),(0,$.jsx)(l,{value:`bearer`,className:`focus:bg-cyan-500/20 focus:text-cyan-400`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Be,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Bearer Token (Authorization)`})]})}),(0,$.jsx)(l,{value:`custom`,className:`focus:bg-cyan-500/20 focus:text-cyan-400`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Me,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Custom Headers (JSON)`})]})})]})]})]}),(y===`api-key`||y===`bearer`)&&(0,$.jsxs)(`div`,{className:`space-y-2 animate-in fade-in slide-in-from-top-1 duration-200`,children:[(0,$.jsx)(Z,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:y===`api-key`?`API Key`:`Bearer Token`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(q,{type:`password`,placeholder:`sk-...`,value:x,onChange:e=>S(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 transition-all h-9 pl-9`}),(0,$.jsx)(k,{className:`absolute left-3 top-2.5 h-3.5 w-3.5 text-zinc-500`})]})]}),y===`custom`&&(0,$.jsxs)(`div`,{className:`space-y-2 animate-in fade-in slide-in-from-top-1 duration-200`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,$.jsx)(Z,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Headers JSON`})}),(0,$.jsx)(`textarea`,{value:w,onChange:e=>T(e.target.value),placeholder:`{ "x-custom-auth": "secret" }`,rows:3,className:`w-full bg-white/5 border border-white/10 rounded-md p-2 text-xs text-zinc-300 focus:outline-none focus:border-cyan-500/50 transition-all font-mono`})]})]})]}),(0,$.jsxs)(`div`,{className:`p-3 rounded-lg bg-zinc-900 border border-white/5 flex items-center justify-between mt-6`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`p-1.5 rounded-full ${U?`bg-green-500/10 text-green-400`:`bg-zinc-800 text-zinc-500`}`,children:(0,$.jsx)(Re,{className:`h-3.5 w-3.5 ${U?`animate-pulse`:``}`})}),(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{className:`text-[10px] font-bold text-zinc-300 uppercase tracking-tight`,children:`Estado del Nodo`}),(0,$.jsx)(`span`,{className:`text-[9px] font-mono ${U?`text-green-500`:`text-zinc-500`}`,children:U?`ACTIVE_CONNECTION`:`INACTIVE_NODE`})]})]}),(0,$.jsx)(W,{size:`sm`,variant:U?`outline`:`default`,onClick:async()=>{F(!0),G.show(U?`Desconectando servidor...`:`Conectando servidor...`);try{await r(e.id,!U),re(+!U),te(U?`disconnected`:`connected`),J.fire({icon:`success`,title:U?`Servidor desconectado`:`Servidor conectado`}),setTimeout(a,1500)}catch{J.fire({icon:`error`,title:`Error al cambiar estado de conexión`})}finally{F(!1),G.hide()}},disabled:P,className:`h-7 px-4 text-[10px] font-bold uppercase tracking-wider ${U?`border-zinc-800 text-zinc-400 hover:bg-zinc-800`:`bg-cyan-600 hover:bg-cyan-500 text-white`}`,children:P?(0,$.jsx)(O,{className:`h-3 w-3 animate-spin`}):U?`Desconectar`:`Conectar`})]})]}):(0,$.jsx)(`div`,{className:`animate-in fade-in duration-300`,children:(0,$.jsx)(qe,{serverId:e.id,serverName:e.name,tools:e.tools||[]})})}),(0,$.jsxs)(ge,{className:`p-6 bg-white/[0.02] border-t border-white/5`,children:[(0,$.jsx)(W,{variant:`ghost`,onClick:t,className:`text-zinc-500 hover:text-white`,children:`Cerrar`}),B===`config`&&(0,$.jsx)(W,{onClick:async()=>{A(!0),G.show(`Actualizando configuración...`);try{let t={transport:o};if(o===`stdio`){if(!c){J.fire({icon:`warning`,title:`El comando es obligatorio`});return}t.command=c;let e=h.trim();if(e.startsWith(`[`)&&e.endsWith(`]`))try{t.args=JSON.parse(e)}catch{t.args=e.match(/"[^"]*"|'[^']*'|[^\\s,]+/g)?.map(e=>e.replace(/^["']|["']$/g,``).replace(/,$/,``).trim()).filter(Boolean)||[]}else t.args=e.match(/"[^"]*"|'[^']*'|[^\\s,]+/g)?.map(e=>e.replace(/^["']|["']$/g,``).replace(/,$/,``).trim()).filter(Boolean)||[]}else if(o===`sse`){if(!_){J.fire({icon:`warning`,title:`La URL es obligatoria`});return}t.url=_;let e={};if(y===`api-key`&&x)e[`x-api-key`]=x;else if(y===`bearer`&&x)e.Authorization=`Bearer ${x}`;else if(y===`custom`&&w.trim())try{e=JSON.parse(w.trim())}catch{J.fire({icon:`error`,title:`JSON de Headers inválido`});return}Object.keys(e).length>0&&(t.headers=e)}await n(e.id,t),await a(),J.fire({icon:`success`,title:`Configuración actualizada`})}catch(e){J.fire({icon:`error`,title:e instanceof Error?e.message:`Error al actualizar configuración`})}finally{A(!1),G.hide()}},disabled:E,className:`bg-cyan-600 hover:bg-cyan-500 text-white min-w-[120px]`,children:E?(0,$.jsx)(O,{className:`h-4 w-4 animate-spin`}):`Guardar Cambios`})]})]})})}function Xe(){let{fetchMCPServers:e}=pe(),[t,n]=(0,Q.useState)(!1),[r,i]=(0,Q.useState)(``),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(``),[d,h]=(0,Q.useState)(`stdio`),[g,_]=(0,Q.useState)(``),[v,b]=(0,Q.useState)(`none`),[x,S]=(0,Q.useState)(``),[w,T]=(0,Q.useState)(``),[E,O]=(0,Q.useState)(!1);return(0,$.jsxs)(Se,{open:t,onOpenChange:n,children:[(0,$.jsx)(_e,{asChild:!0,children:(0,$.jsxs)(W,{className:`bg-cyan-600 hover:bg-cyan-500 text-white shadow-lg shadow-cyan-600/20 gap-2`,children:[(0,$.jsx)(P,{className:`h-4 w-4`}),`Añadir Servidor MCP`]})}),(0,$.jsxs)(be,{className:`sm:max-w-[425px] border-cyan-500/20 bg-zinc-950/95 backdrop-blur-xl`,children:[(0,$.jsxs)(ye,{children:[(0,$.jsxs)(xe,{className:`flex items-center gap-2 text-white`,children:[(0,$.jsx)(`div`,{className:`p-1.5 rounded-md bg-cyan-500/10 text-cyan-400`,children:(0,$.jsx)(le,{className:`h-4 w-4`})}),`Nuevo Servidor MCP`]}),(0,$.jsx)(ve,{className:`text-zinc-400`,children:`Conecta una nueva fuente de herramientas para tus agentes mediante el protocolo MCP.`})]}),(0,$.jsxs)(`div`,{className:`grid gap-4 py-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{htmlFor:`mcp-name`,className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Nombre Identificador`}),(0,$.jsx)(q,{id:`mcp-name`,placeholder:`github-tools`,value:r,onChange:e=>i(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 transition-all h-9`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Protocolo de Transporte`}),(0,$.jsxs)(f,{value:d,onValueChange:h,children:[(0,$.jsx)(m,{className:`bg-zinc-900/80 border-white/10 text-white focus:border-cyan-500/50 hover:bg-zinc-900 transition-all h-9 cursor-pointer`,children:(0,$.jsx)(u,{placeholder:`Seleccionar transporte`})}),(0,$.jsxs)(p,{position:`popper`,className:`bg-zinc-900 border-white/10 z-[99999]`,sideOffset:4,children:[(0,$.jsx)(l,{value:`stdio`,className:`focus:bg-cyan-500/20 focus:text-cyan-400 cursor-pointer`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(M,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`stdio (Binario Local)`})]})}),(0,$.jsx)(l,{value:`sse`,className:`focus:bg-cyan-500/20 focus:text-cyan-400 cursor-pointer`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(C,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`SSE (Remote HTTP)`})]})})]})]})]}),d===`stdio`?(0,$.jsxs)(`div`,{className:`space-y-4 animate-in fade-in slide-in-from-top-2 duration-300`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{htmlFor:`mcp-cmd`,className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Comando Ejecutable`}),(0,$.jsx)(q,{id:`mcp-cmd`,placeholder:`npx`,value:a,onChange:e=>o(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 transition-all h-9`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{htmlFor:`mcp-args`,className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Argumentos`}),(0,$.jsx)(q,{id:`mcp-args`,placeholder:`-y @modelcontextprotocol/server-github`,value:s,onChange:e=>c(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 transition-all h-9`})]})]}):(0,$.jsxs)(`div`,{className:`space-y-4 animate-in fade-in slide-in-from-top-2 duration-300`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{htmlFor:`mcp-url`,className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Endpoint URL`}),(0,$.jsx)(q,{id:`mcp-url`,placeholder:`https://mcp-server.com/sse`,value:g,onChange:e=>_(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 transition-all h-9`})]}),(0,$.jsxs)(`div`,{className:`space-y-4 pt-2 border-t border-white/5`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Autenticación`}),(0,$.jsxs)(f,{value:v,onValueChange:b,children:[(0,$.jsx)(m,{className:`bg-zinc-900/80 border-white/10 text-white focus:border-cyan-500/50 hover:bg-zinc-900 transition-all h-9 cursor-pointer`,children:(0,$.jsx)(u,{placeholder:`Seleccionar autenticación`})}),(0,$.jsxs)(p,{position:`popper`,className:`bg-zinc-900 border-white/10 z-[99999]`,sideOffset:4,children:[(0,$.jsx)(l,{value:`none`,className:`focus:bg-cyan-500/20 focus:text-cyan-400 cursor-pointer`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(C,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Ninguna`})]})}),(0,$.jsx)(l,{value:`api-key`,className:`focus:bg-cyan-500/20 focus:text-cyan-400 cursor-pointer`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(D,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`API Key (x-api-key)`})]})}),(0,$.jsx)(l,{value:`bearer`,className:`focus:bg-cyan-500/20 focus:text-cyan-400 cursor-pointer`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Be,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Bearer Token (Authorization)`})]})}),(0,$.jsx)(l,{value:`google-api-key`,className:`focus:bg-cyan-500/20 focus:text-cyan-400 cursor-pointer`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(D,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Google API Key (X-Goog-Api-Key)`})]})}),(0,$.jsx)(l,{value:`custom`,className:`focus:bg-cyan-500/20 focus:text-cyan-400 cursor-pointer`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Me,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Custom Headers (JSON)`})]})})]})]})]}),(v===`api-key`||v===`google-api-key`||v===`bearer`)&&(0,$.jsxs)(`div`,{className:`space-y-2 animate-in fade-in slide-in-from-top-1 duration-200`,children:[(0,$.jsx)(Z,{htmlFor:`mcp-token`,className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:v===`api-key`?`API Key`:v===`google-api-key`?`Google API Key`:`Bearer Token`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(q,{id:`mcp-token`,type:`password`,placeholder:`sk-...`,value:x,onChange:e=>S(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 transition-all h-9 pl-9`}),(0,$.jsx)(k,{className:`absolute left-3 top-2.5 h-3.5 w-3.5 text-zinc-500`})]})]}),v===`custom`&&(0,$.jsxs)(`div`,{className:`space-y-2 animate-in fade-in slide-in-from-top-1 duration-200`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,$.jsx)(Z,{htmlFor:`mcp-headers`,className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Headers JSON`})}),(0,$.jsx)(`textarea`,{id:`mcp-headers`,placeholder:`{ "x-custom-auth": "secret" }`,rows:3,value:w,onChange:e=>{let t=e.target.value;T(t);try{t.trim()&&JSON.parse(t.trim()),e.target.style.borderColor=``}catch{t.trim()?e.target.style.borderColor=`rgba(239, 68, 68, 0.5)`:e.target.style.borderColor=``}},className:`w-full bg-white/5 border border-white/10 rounded-md p-2 text-xs text-zinc-300 focus:outline-none focus:border-cyan-500/50 transition-all font-mono`})]})]})]}),(0,$.jsxs)(`div`,{className:`p-3 rounded-lg bg-cyan-500/5 border border-cyan-500/10 flex items-center gap-3`,children:[(0,$.jsx)(y,{className:`h-5 w-5 text-cyan-500 shrink-0`}),(0,$.jsx)(`div`,{className:`text-[10px] text-cyan-200/70`,children:`El servidor se inicializará y validará inmediatamente después de ser añadido.`})]})]}),(0,$.jsxs)(ge,{children:[(0,$.jsx)(W,{variant:`ghost`,onClick:()=>n(!1),className:`hover:bg-white/5 text-zinc-400 h-9 text-xs`,children:`Cancelar`}),(0,$.jsx)(W,{onClick:async()=>{if(!r){J.fire({icon:`error`,title:`El nombre es obligatorio`});return}O(!0);try{let t={transport:d};if(d===`stdio`){if(!a){J.fire({icon:`error`,title:`El comando es obligatorio para transporte stdio`}),O(!1);return}t.command=a;let e=s.trim();if(e.startsWith(`[`)&&e.endsWith(`]`))try{t.args=JSON.parse(e)}catch{t.args=e.match(/"[^"]*"|'[^']*'|[^\\s,]+/g)?.map(e=>e.replace(/^["']|["']$/g,``).replace(/,$/,``).trim()).filter(Boolean)||[]}else t.args=e.match(/"[^"]*"|'[^']*'|[^\\s,]+/g)?.map(e=>e.replace(/^["']|["']$/g,``).replace(/,$/,``).trim()).filter(Boolean)||[]}else{if(!g){J.fire({icon:`error`,title:`La URL es obligatoria para transporte SSE`}),O(!1);return}t.url=g;let e={};if(v===`api-key`&&x)e[`x-api-key`]=x;else if(v===`google-api-key`&&x)e[`X-Goog-Api-Key`]=x;else if(v===`bearer`&&x)e.Authorization=`Bearer ${x}`;else if(v===`custom`&&w.trim())try{e=JSON.parse(w.trim())}catch{K.fire(`Error`,`JSON de Headers inválido`,`error`),O(!1);return}Object.keys(e).length>0&&(t.headers=e)}await Y(`/api/mcp/servers`,{method:`POST`,body:{name:r,config:t},showLoader:`Conectando servidor MCP...`,showError:!0}),J.fire({icon:`success`,title:`Servidor "${r}" añadido correctamente`}),i(``),o(``),c(``),_(``),b(`none`),S(``),T(``),n(!1),await e()}catch{}finally{O(!1)}},disabled:E,className:`bg-cyan-600 hover:bg-cyan-500 text-white shadow-lg shadow-cyan-600/20 h-9 text-xs px-6`,children:E?`Conectando...`:`Conectar Servidor`})]})]})]})}function Ze(){let{servers:e,activeServers:t,isLoading:n,fetchMCPServers:r}=pe(),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(``);(0,Q.useEffect)(()=>{r()},[r]);let c=e.filter(e=>e.name.toLowerCase().includes(o.toLowerCase())),l=e=>{a({...e,args:typeof e.args==`string`?JSON.parse(e.args):e.args})};return(0,$.jsxs)(`div`,{className:`space-y-6`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-white/5 pb-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`p-2 rounded-lg bg-cyan-500/10 text-cyan-400`,children:(0,$.jsx)(le,{className:`h-5 w-5`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h4`,{className:`text-sm font-bold text-white uppercase tracking-wider`,children:`MCP Ecosystem`}),(0,$.jsx)(`p`,{className:`text-[10px] text-zinc-500 font-mono`,children:`Model Context Protocol Servers`})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,$.jsxs)(`div`,{className:`relative group`,children:[(0,$.jsx)(I,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-zinc-500 group-focus-within:text-cyan-400 transition-colors`}),(0,$.jsx)(q,{placeholder:`Buscar servidor...`,value:o,onChange:e=>s(e.target.value),className:`pl-9 bg-zinc-900/50 border-white/5 focus:border-cyan-500/30 transition-all h-9 w-[260px] text-xs`})]}),(0,$.jsx)(Xe,{})]})]}),c.length===0?(0,$.jsxs)(`div`,{className:`py-16 flex flex-col items-center justify-center border border-dashed border-white/10 rounded-2xl bg-zinc-950/20 group hover:border-cyan-500/20 transition-colors`,children:[(0,$.jsx)(`div`,{className:`p-4 rounded-full bg-zinc-900 mb-4 group-hover:scale-110 transition-transform`,children:(0,$.jsx)(V,{className:`h-8 w-8 text-zinc-700 group-hover:text-cyan-500/50 transition-colors`})}),(0,$.jsx)(`p`,{className:`text-xs text-zinc-500 font-medium`,children:`No se detectan servidores MCP configurados.`}),(0,$.jsx)(`p`,{className:`text-[10px] text-zinc-600 mt-1`,children:`Añade uno para expandir las capacidades de tus agentes.`})]}):(0,$.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4`,children:c.map(e=>(0,$.jsx)(Ke,{server:e,isConnected:e.status===`connected`||e.active===!0,onClick:()=>l(e)},e.id))}),i&&(0,$.jsx)(Ye,{server:i,onClose:()=>a(null)})]})}var Qe=()=>(0,$.jsxs)(`svg`,{"aria-hidden":!0,className:`absolute inset-0 w-full h-full pointer-events-none`,xmlns:`http://www.w3.org/2000/svg`,style:{opacity:.05,color:`hsl(var(--hive-amber))`},children:[(0,$.jsx)(`defs`,{children:(0,$.jsx)(`pattern`,{id:`hc-profile`,x:`0`,y:`0`,width:`30`,height:`34`,patternUnits:`userSpaceOnUse`,children:(0,$.jsx)(`polygon`,{points:`15,2 28,9.5 28,24.5 15,32 2,24.5 2,9.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`1`})})}),(0,$.jsx)(`rect`,{width:`100%`,height:`100%`,fill:`url(#hc-profile)`})]}),$e=({initials:e,size:t=`lg`})=>{let n=t===`sm`?`w-14 h-14`:`w-20 h-20`,r=t===`sm`?`text-lg`:`text-2xl`;return(0,$.jsxs)(`div`,{className:`relative ${n} flex-shrink-0`,children:[(0,$.jsx)(`div`,{className:`w-full h-full flex items-center justify-center text-white font-black ${r} tracking-tight select-none`,style:{clipPath:`polygon(50% 0%, 95% 25%, 95% 75%, 50% 100%, 5% 75%, 5% 25%)`,background:`linear-gradient(135deg, hsl(var(--hive-amber)) 0%, hsl(var(--hive-orange)) 100%)`,boxShadow:`0 0 24px hsl(var(--hive-amber) / 0.4)`},children:e}),(0,$.jsx)(`span`,{className:`absolute bottom-0.5 right-1 h-3.5 w-3.5 rounded-full border-2 animate-pulse`,style:{background:`hsl(var(--hive-green))`,borderColor:`hsl(var(--background))`,boxShadow:`0 0 8px hsl(var(--hive-green) / 0.6)`}})]})},et=({children:e})=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-2.5`,children:[(0,$.jsx)(w,{className:`h-3 w-3 flex-shrink-0`,style:{color:`hsl(var(--hive-amber))`,fill:`hsl(var(--hive-amber) / 0.2)`}}),(0,$.jsx)(`p`,{className:`text-[10px] font-black uppercase tracking-[0.18em]`,style:{color:`hsl(var(--hive-amber) / 0.85)`},children:e})]}),tt=()=>(0,$.jsx)(`div`,{className:`h-px`,style:{background:`linear-gradient(90deg,transparent,hsl(var(--hive-amber)/0.18),transparent)`}}),nt=({icon:e,label:t,colorVar:n})=>(0,$.jsxs)(`span`,{className:`flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-medium border`,style:{background:`hsl(var(${n}) / 0.08)`,borderColor:`hsl(var(${n}) / 0.2)`,color:`hsl(var(${n}))`},children:[(0,$.jsx)(e,{className:`h-2.5 w-2.5 flex-shrink-0`}),t]}),rt=({label:e,icon:t,editing:n,children:r})=>(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-1.5 text-[10px] font-bold uppercase tracking-widest transition-colors`,style:{color:n?`hsl(var(--hive-text-muted))`:`hsl(var(--hive-text-placeholder))`},children:[(0,$.jsx)(t,{className:`h-3 w-3 opacity-60`}),e]}),r]});function it(e){return e.split(` `).map(e=>e[0]).slice(0,2).join(``).toUpperCase()||`?`}function at(){let{fetchUser:e,saveUser:t,isLoading:n}=ue(),{channels:r}=fe(),[i,a]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)({name:``,occupation:``,language:``,timezone:``,preferred_cron_channel:`auto`,notes:``}),[h,g]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{e().then(e=>{if(!e)return;let t={name:e.name||``,occupation:e.occupation||``,language:e.language||``,timezone:e.timezone||``,preferred_cron_channel:e.preferred_cron_channel||`auto`,notes:e.notes||``};c(t),g(t)}).catch(console.error)},[e]);let _=(e,t)=>c(n=>({...n,[e]:t})),v=()=>{h&&c(h),a(!1)},y=async()=>{G.show(`Guardando perfil...`);try{let e=await t(s);g(s),J.fire({icon:`success`,title:e}),a(!1)}catch(e){J.fire({icon:`error`,title:e instanceof Error?e.message:`Error al guardar`})}finally{G.hide()}},b=r.filter(e=>e.active),x=s.preferred_cron_channel===`auto`?`Auto — detectar mejor canal`:b.find(e=>e.type===s.preferred_cron_channel)?.type??s.preferred_cron_channel,S=it(s.name);return(0,$.jsxs)(`div`,{className:`relative overflow-hidden rounded-2xl border flex flex-col lg:flex-row`,style:{background:`hsl(var(--hive-surface)/0.7)`,borderColor:`hsl(var(--hive-border-base))`,backdropFilter:`blur(16px)`,boxShadow:`0 0 60px hsl(var(--hive-amber)/0.05)`},children:[(0,$.jsxs)(`div`,{className:`relative overflow-hidden flex-shrink-0 lg:w-[40%] lg:flex-col lg:items-center lg:text-center
|
|
2
2
|
|
|
3
3
|
/* mobile: horizontal compact row */
|
|
4
4
|
flex flex-row items-center gap-4 p-4
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as t}from"./vendor-charts-Bu2lyBKP.js";import{o as n}from"./vendor-query-DsWPbQdG.js";import{t as r}from"./utils-3pnRFmFe.js";import{a as i,c as a,n as o,r as s,s as c,t as l}from"./switch-BDwN8RYV.js";import{t as u}from"./circle-check-Bb54Ebmu.js";import{a as ee,i as te,n as ne,o as d,r as re,t as f}from"./accordion-C5d5Rm5z.js";import{t as p}from"./hexagon-DsGOUl-H.js";import{t as m}from"./loader-circle-CZNax6kS.js";import{t as h}from"./sparkles-yUEb-7oH.js";import{t as ie}from"./volume-2-CeSXNDv4.js";import{c as ae}from"./vendor-router-C9pIYwbJ.js";import{t as g}from"./gateway-url-COCbW0IR.js";import{M as _,_ as oe,j as v,p as y}from"./index-DMCjjdqf.js";import{t as b}from"./label-D2H1IR_J.js";import{t as x}from"./badge-ChpACfWO.js";import{a as S,n as C,o as w,r as T,t as E}from"./card-CNf6BS2e.js";import{t as se}from"./progress-BherYzY6.js";import{n as D,t as O}from"./alert-C-NE-P3s.js";var k=e(t(),1),A=n(),ce={gemini:`🔵`,anthropic:`🟠`,openai:`🟢`,groq:`🔴`,ollama:`🟣`,openrouter:`🟡`,deepseek:`🔷`,mistral:`🔸`,kimi:`🌙`},j={gemini:`https://aistudio.google.com/app/apikey`,anthropic:`https://console.anthropic.com/keys`,openai:`https://platform.openai.com/api-keys`,groq:`https://console.groq.com/keys`,openrouter:`https://openrouter.ai/keys`,deepseek:`https://platform.deepseek.com/api_keys`,mistral:`https://console.mistral.ai/api-keys`,kimi:`https://platform.moonshot.cn/console/api-keys`},M=[{id:`webchat`,name:`WebChat`,description:`Chat web integrado`,icon:`💬`,required:!0},{id:`telegram`,name:`Telegram`,description:`Bot de Telegram`,icon:`✈️`,required:!1},{id:`discord`,name:`Discord`,description:`Bot de Discord`,icon:`🎮`,required:!1},{id:`whatsapp`,name:`WhatsApp`,description:`Bot de WhatsApp`,icon:`📱`,required:!1},{id:`slack`,name:`Slack`,description:`Bot de Slack`,icon:`💼`,required:!1}],N=`hive_setup_wizard_data`;function P(){try{let e=sessionStorage.getItem(N);if(e){let t=JSON.parse(e);return{...I(),...t}}}catch(e){console.error(`Failed to load wizard data:`,e)}return null}function le(e){try{sessionStorage.setItem(N,JSON.stringify(e))}catch(e){console.error(`Failed to save wizard data:`,e)}}function F(){try{sessionStorage.removeItem(N)}catch(e){console.error(`Failed to clear wizard data:`,e)}}function I(){return{userName:``,userLanguage:`es`,userTimezone:Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`,userOccupation:``,userNotes:``,agentName:`Bee`,agentDescription:``,agentTone:`friendly`,provider:``,apiKey:``,model:``,apiKeyVerified:!1,channels:{webchat:{enabled:!0},telegram:{enabled:!1},discord:{enabled:!1},whatsapp:{enabled:!1},slack:{enabled:!1}},voiceEnabled:!1,sttProvider:`groq-whisper`,ttsProvider:`elevenlabs`,ttsVoice:``,ethicsRules:{},customRules:[]}}function L(){let e=ae(),[t,n]=(0,k.useState)(1),[N,L]=(0,k.useState)(()=>P()||I()),[R,z]=(0,k.useState)(!1),[B,ue]=(0,k.useState)(!1),{showLoader:V,hideLoader:H}=oe(),[U,W]=(0,k.useState)(`idle`),[G,K]=(0,k.useState)(null),[q,de]=(0,k.useState)([]),[J,Y]=(0,k.useState)(null),[X,Z]=(0,k.useState)(!1),[Q,fe]=(0,k.useState)([]);(0,k.useEffect)(()=>{fetch(`${g()}/api/setup/providers`).then(e=>e.json()).then(e=>{Array.isArray(e)&&de(e)}).catch(()=>{}),fetch(`${g()}/api/setup/ethics`).then(e=>e.json()).then(e=>{Array.isArray(e)&&(fe(e),L(t=>Object.keys(t.ethicsRules).length===0?{...t,ethicsRules:Object.fromEntries(e.map(e=>[e.id,!0]))}:t))}).catch(()=>{})},[]),(0,k.useEffect)(()=>{le(N)},[N]),(0,k.useEffect)(()=>{fetch(`${g()}/api/setup/status`).then(e=>e.json()).then(t=>{t.configured&&e(`/ui`)}).catch(()=>{})},[e]);let $=e=>{K(null),L(t=>({...t,...e}))},pe=()=>{switch(t){case 1:return N.userName.trim()?N.userName.trim().length<2?`El nombre debe tener al menos 2 caracteres.`:null:`El nombre es obligatorio.`;case 2:return N.agentName.trim()?N.agentName.trim().length<2?`El nombre debe tener al menos 2 caracteres.`:null:`El nombre del agente es obligatorio.`;case 3:return N.provider?N.provider!==`ollama`&&!N.apiKey?`Ingresa tu API key.`:N.provider!==`ollama`&&!N.apiKeyVerified?`Verifica tu API key antes de continuar.`:N.model?null:`Selecciona un modelo.`:`Selecciona un proveedor LLM.`;default:return null}},me=()=>{let e=pe();if(e){K(e);return}K(null),t<8&&n(e=>e+1)},he=()=>{t>1&&n(e=>e-1)},ge=()=>{confirm(`¿Estás seguro de que quieres reiniciar la configuración? Se perderá todo el progreso.`)&&(F(),L(I()),n(1))},_e=async()=>{if(!(!N.apiKey||!N.provider)){W(`verifying`);try{(await y(`/api/setup/verify-provider`,{method:`POST`,body:{provider:N.provider,apiKey:N.apiKey},showLoader:`Verificando conexión...`,showError:!1})).success?(W(`success`),$({apiKeyVerified:!0})):(W(`error`),$({apiKeyVerified:!1}))}catch{W(`error`),$({apiKeyVerified:!1})}}},ve=async()=>{z(!0);try{let t=await y(`/api/setup/complete`,{method:`POST`,body:N,showLoader:`Finalizando configuración...`,showError:!0});if(t.success){let n=t.authToken;n&&localStorage.setItem(`hive-auth-token`,n),ue(!0),F(),(async()=>{await new Promise(e=>setTimeout(e,1500)),V(`Iniciando a ${N.agentName}... esto toma unos segundos`);for(let t=0;t<40;t++){try{let t=await fetch(`${g()}/api/setup/status`);if(t.ok){let{configured:r}=await t.json();if(r){H(),e(n?`/?token=${n}`:`/`);return}}}catch{}await new Promise(e=>setTimeout(e,1e3))}H(),e(n?`/?token=${n}`:`/`)})()}}catch{}finally{z(!1)}},ye=()=>{switch(t){case 1:return be();case 2:return xe();case 3:return Se();case 4:return Ce();case 5:return we();case 6:return Te();case 7:return Ee();case 8:return De();default:return null}},be=()=>(0,A.jsxs)(`div`,{className:`space-y-6`,children:[(0,A.jsxs)(`div`,{className:`text-center space-y-4`,children:[(0,A.jsx)(`div`,{className:`flex justify-center`,children:(0,A.jsxs)(`div`,{className:`relative`,children:[(0,A.jsx)(p,{className:`w-24 h-24 text-amber-500`,fill:`currentColor`}),(0,A.jsx)(h,{className:`w-8 h-8 text-amber-300 absolute -top-2 -right-2`})]})}),(0,A.jsx)(`h1`,{className:`text-3xl font-bold`,children:`Bienvenido a Hive`}),(0,A.jsx)(`p`,{className:`text-muted-foreground max-w-md mx-auto`,children:`Hive es tu colmena de agentes IA. Local-first. Multi-canal. Open source. En los próximos minutos configurarás tu agente personal Bee.`})]}),(0,A.jsxs)(E,{children:[(0,A.jsxs)(S,{children:[(0,A.jsx)(w,{children:`Tu información`}),(0,A.jsx)(T,{children:`Comencemos con tus datos básicos`})]}),(0,A.jsxs)(C,{className:`space-y-4`,children:[(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(b,{htmlFor:`userName`,children:`Tu nombre`}),(0,A.jsx)(v,{id:`userName`,placeholder:`¿Cómo te llamas?`,value:N.userName,onChange:e=>$({userName:e.target.value})})]}),(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(b,{htmlFor:`userLanguage`,children:`Idioma preferido`}),(0,A.jsxs)(o,{value:N.userLanguage,onValueChange:e=>$({userLanguage:e}),children:[(0,A.jsx)(c,{children:(0,A.jsx)(a,{})}),(0,A.jsxs)(s,{children:[(0,A.jsx)(i,{value:`es`,children:`Español`}),(0,A.jsx)(i,{value:`en`,children:`English`}),(0,A.jsx)(i,{value:`pt`,children:`Português`}),(0,A.jsx)(i,{value:`fr`,children:`Français`})]})]})]}),(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(b,{htmlFor:`userTimezone`,children:`Zona horaria`}),(0,A.jsx)(v,{id:`userTimezone`,value:N.userTimezone,onChange:e=>$({userTimezone:e.target.value}),placeholder:`America/Bogota`}),(0,A.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Detectada automáticamente: `,Intl.DateTimeFormat().resolvedOptions().timeZone]})]}),(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsxs)(b,{htmlFor:`userOccupation`,children:[`Ocupación `,(0,A.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(opcional)`})]}),(0,A.jsx)(v,{id:`userOccupation`,value:N.userOccupation,onChange:e=>$({userOccupation:e.target.value}),placeholder:`Ej: Desarrollador de software, diseñador, estudiante...`})]}),(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsxs)(b,{htmlFor:`userNotes`,children:[`Preferencias de comunicación `,(0,A.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(opcional)`})]}),(0,A.jsx)(`textarea`,{id:`userNotes`,className:`w-full min-h-[80px] p-3 border rounded-md bg-background resize-none text-sm`,value:N.userNotes,onChange:e=>$({userNotes:e.target.value}),placeholder:`Ej: Prefiero respuestas cortas y directas. Usa ejemplos de código cuando expliques conceptos técnicos...`})]})]})]})]}),xe=()=>(0,A.jsxs)(`div`,{className:`space-y-6`,children:[(0,A.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,A.jsx)(`h2`,{className:`text-2xl font-bold`,children:`Tu agente`}),(0,A.jsx)(`p`,{className:`text-muted-foreground`,children:`Personaliza a Bee, tu agente personal`})]}),(0,A.jsxs)(E,{children:[(0,A.jsx)(S,{children:(0,A.jsx)(w,{children:`Identidad del agente`})}),(0,A.jsxs)(C,{className:`space-y-4`,children:[(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(b,{htmlFor:`agentName`,children:`Nombre del agente`}),(0,A.jsx)(v,{id:`agentName`,value:N.agentName,onChange:e=>$({agentName:e.target.value}),placeholder:`Bee`})]}),(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(b,{htmlFor:`agentDescription`,children:`Descripción / Personalidad`}),(0,A.jsx)(`textarea`,{id:`agentDescription`,className:`w-full min-h-[100px] p-3 border rounded-md bg-background resize-none`,value:N.agentDescription,onChange:e=>$({agentDescription:e.target.value}),placeholder:`Ej: Eres un asistente útil y amable. Respondes de forma concisa pero completa. Te especializas en ayudar con tareas de programación y productividad...`})]}),(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(b,{htmlFor:`agentTone`,children:`Tono de comunicación`}),(0,A.jsxs)(o,{value:N.agentTone,onValueChange:e=>$({agentTone:e}),children:[(0,A.jsx)(c,{children:(0,A.jsx)(a,{placeholder:`Selecciona un tono`})}),(0,A.jsxs)(s,{children:[(0,A.jsx)(i,{value:`friendly`,children:`Amigable y cercano`}),(0,A.jsx)(i,{value:`professional`,children:`Profesional y formal`}),(0,A.jsx)(i,{value:`direct`,children:`Directo y conciso`}),(0,A.jsx)(i,{value:`casual`,children:`Casual y relajado`})]})]}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Define cómo se comunicará tu agente contigo`})]})]})]})]}),Se=()=>(0,A.jsxs)(`div`,{className:`space-y-6`,children:[(0,A.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,A.jsx)(`h2`,{className:`text-2xl font-bold`,children:`Proveedor LLM`}),(0,A.jsx)(`p`,{className:`text-muted-foreground`,children:`Selecciona el cerebro de tu agente`})]}),(0,A.jsx)(`div`,{className:`grid gap-3`,children:q.map(e=>(0,A.jsx)(E,{className:r(`cursor-pointer transition-all hover:shadow-md`,N.provider===e.id&&`border-amber-500 ring-2 ring-amber-500`),onClick:()=>{$({provider:e.id,model:``,apiKeyVerified:!1}),e.id===`ollama`&&Y(null)},children:(0,A.jsxs)(C,{className:`flex items-center gap-4 p-4`,children:[(0,A.jsx)(`span`,{className:`text-3xl`,children:ce[e.id]??`🤖`}),(0,A.jsxs)(`div`,{className:`flex-1`,children:[(0,A.jsx)(`h3`,{className:`font-semibold`,children:e.name}),(0,A.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[e.models.length,` modelo`,e.models.length===1?``:`s`,` disponible`,e.models.length===1?``:`s`]})]}),N.provider===e.id&&(0,A.jsx)(u,{className:`w-5 h-5 text-amber-500`})]})},e.id))}),N.provider&&(()=>{let e=q.find(e=>e.id===N.provider);return(0,A.jsxs)(E,{className:`mt-4`,children:[(0,A.jsx)(S,{children:(0,A.jsxs)(w,{children:[`Configuración de `,e?.name]})}),(0,A.jsxs)(C,{className:`space-y-4`,children:[N.provider!==`ollama`&&(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(b,{htmlFor:`apiKey`,children:`API Key`}),(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(v,{id:`apiKey`,type:`password`,value:N.apiKey,onChange:e=>$({apiKey:e.target.value,apiKeyVerified:!1}),placeholder:`sk-...`,className:r(G?.includes(`API key`)&&!N.apiKey&&`border-red-500`)}),(0,A.jsx)(_,{variant:`outline`,onClick:_e,disabled:!N.apiKey||U===`verifying`,children:U===`verifying`?(0,A.jsx)(m,{className:`w-4 h-4 animate-spin`}):U===`success`?(0,A.jsx)(u,{className:`w-4 h-4 text-green-500`}):U===`error`?(0,A.jsx)(d,{className:`w-4 h-4 text-red-500`}):`Verificar`})]}),U===`success`&&(0,A.jsxs)(`p`,{className:`text-sm text-green-600 flex items-center gap-1`,children:[(0,A.jsx)(u,{className:`w-4 h-4`}),` API key verificada correctamente`]}),U===`error`&&(0,A.jsxs)(`p`,{className:`text-sm text-red-600 flex items-center gap-1`,children:[(0,A.jsx)(d,{className:`w-4 h-4`}),` API key inválida o error de conexión`]}),j[N.provider]&&(0,A.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`¿No tienes tu API key?`,` `,(0,A.jsx)(`a`,{href:j[N.provider],target:`_blank`,rel:`noopener noreferrer`,className:`text-amber-500 hover:underline`,children:`Obtener aquí`})]})]}),N.provider===`ollama`&&(0,A.jsxs)(`div`,{className:`space-y-3`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(_,{type:`button`,variant:`outline`,size:`sm`,disabled:X,onClick:()=>{Y(null),Z(!0),$({model:``}),fetch(`${g()}/api/setup/ollama-models`).then(e=>e.json()).then(e=>{Y(e.models??[]),Z(!1)}).catch(()=>{Y([]),Z(!1)})},children:X?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(m,{className:`w-3 h-3 animate-spin mr-1`}),`Detectando...`]}):`🔍 Detectar modelos`}),!X&&J!==null&&(0,A.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:J.length>0?`${J.length} modelo${J.length===1?``:`s`} encontrado${J.length===1?``:`s`}`:`Sin modelos — instala uno con ollama pull`})]}),J&&J.length>0&&(0,A.jsxs)(`div`,{className:`space-y-1`,children:[(0,A.jsx)(b,{htmlFor:`model`,children:`Modelo`}),(0,A.jsxs)(o,{value:N.model,onValueChange:e=>$({model:e}),children:[(0,A.jsx)(c,{className:r(!N.model&&G?.includes(`modelo`)&&`border-red-500`),children:(0,A.jsx)(a,{placeholder:`Selecciona un modelo`})}),(0,A.jsx)(s,{children:J.map((e,t)=>(0,A.jsxs)(i,{value:e.id,children:[e.name,t===0?` (Recomendado)`:``]},e.id))})]})]}),!X&&J!==null&&J.length===0&&(0,A.jsxs)(`p`,{className:`text-xs text-amber-600`,children:[`Asegúrate que Ollama esté corriendo (`,(0,A.jsx)(`code`,{children:`ollama serve`}),`) y tengas modelos (`,(0,A.jsx)(`code`,{children:`ollama pull llama3.2`}),`).`]})]}),N.provider!==`ollama`&&N.apiKeyVerified&&(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(b,{htmlFor:`model`,children:`Modelo`}),(0,A.jsxs)(o,{value:N.model,onValueChange:e=>$({model:e}),children:[(0,A.jsx)(c,{className:r(!N.model&&G?.includes(`modelo`)&&`border-red-500`),children:(0,A.jsx)(a,{placeholder:`Selecciona un modelo`})}),(0,A.jsx)(s,{children:(e?.models??[]).map((e,t)=>(0,A.jsxs)(i,{value:e.id,children:[e.name||e.id,t===0?` (Recomendado)`:``]},e.id))})]})]})]})]})})()]}),Ce=()=>(0,A.jsxs)(`div`,{className:`space-y-6`,children:[(0,A.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,A.jsx)(`h2`,{className:`text-2xl font-bold`,children:`Canales`}),(0,A.jsx)(`p`,{className:`text-muted-foreground`,children:`¿Dónde quieres que Bee esté disponible?`})]}),(0,A.jsx)(`div`,{className:`grid gap-3`,children:M.map(e=>(0,A.jsx)(E,{className:r(`transition-all`,N.channels[e.id]?.enabled&&`border-amber-500`),children:(0,A.jsxs)(C,{className:`p-4`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,A.jsx)(`span`,{className:`text-2xl`,children:e.icon}),(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`h3`,{className:`font-semibold flex items-center gap-2`,children:[e.name,e.required&&(0,A.jsx)(x,{variant:`secondary`,className:`text-xs`,children:`Requerido`})]}),(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.description})]})]}),(0,A.jsx)(l,{checked:N.channels[e.id]?.enabled,onCheckedChange:t=>{e.required&&!t||$({channels:{...N.channels,[e.id]:{enabled:t}}})},disabled:e.required})]}),!e.required&&N.channels[e.id]?.enabled&&(0,A.jsx)(f,{type:`single`,collapsible:!0,className:`mt-4`,children:(0,A.jsxs)(re,{value:`config`,children:[(0,A.jsx)(te,{children:`Configuración`}),(0,A.jsx)(ne,{children:(0,A.jsxs)(`div`,{className:`space-y-3 pt-2`,children:[e.id===`telegram`&&(0,A.jsx)(A.Fragment,{children:(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(b,{htmlFor:`telegramToken`,children:`Token del Bot`}),(0,A.jsx)(v,{id:`telegramToken`,placeholder:`123456789:ABCdefGHIjklMNOpqrsTUVwxyz`,value:N.channels.telegram.config?.botToken||``,onChange:e=>$({channels:{...N.channels,telegram:{enabled:!0,config:{botToken:e.target.value}}}})}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,A.jsx)(`a`,{href:`https://t.me/BotFather`,target:`_blank`,rel:`noopener noreferrer`,className:`text-amber-500 hover:underline`,children:`Obtén tu token en BotFather`})})]})}),e.id===`discord`&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(b,{htmlFor:`discordToken`,children:`Token del Bot`}),(0,A.jsx)(v,{id:`discordToken`,placeholder:`MTIzNDU2Nzg5MDEyMzQ1Njc4OQ.GJKlMn.OpQrStUvWxYz`,value:N.channels.discord.config?.botToken||``,onChange:e=>$({channels:{...N.channels,discord:{enabled:!0,config:{botToken:e.target.value}}}})})]}),(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(b,{htmlFor:`discordClientId`,children:`Client ID`}),(0,A.jsx)(v,{id:`discordClientId`,placeholder:`1234567890123456789`,value:N.channels.discord.config?.clientId||``,onChange:e=>$({channels:{...N.channels,discord:{enabled:!0,config:{clientId:e.target.value}}}})})]})]}),e.id===`whatsapp`&&(0,A.jsx)(A.Fragment,{children:(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(b,{htmlFor:`whatsappToken`,children:`Token de la API`}),(0,A.jsx)(v,{id:`whatsappToken`,placeholder:`...`,value:N.channels.whatsapp.config?.apiToken||``,onChange:e=>$({channels:{...N.channels,whatsapp:{enabled:!0,config:{apiToken:e.target.value}}}})})]})}),e.id===`slack`&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(b,{htmlFor:`slackToken`,children:`Bot Token`}),(0,A.jsx)(v,{id:`slackToken`,placeholder:`xoxb-...`,value:N.channels.slack.config?.botToken||``,onChange:e=>$({channels:{...N.channels,slack:{enabled:!0,config:{botToken:e.target.value}}}})})]}),(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(b,{htmlFor:`slackSigningSecret`,children:`Signing Secret`}),(0,A.jsx)(v,{id:`slackSigningSecret`,placeholder:`...`,value:N.channels.slack.config?.signingSecret||``,onChange:e=>$({channels:{...N.channels,slack:{enabled:!0,config:{signingSecret:e.target.value}}}})})]})]})]})})]})})]})},e.id))})]}),we=()=>(0,A.jsxs)(`div`,{className:`space-y-6`,children:[(0,A.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,A.jsx)(`h2`,{className:`text-2xl font-bold`,children:`Voz (opcional)`}),(0,A.jsx)(`p`,{className:`text-muted-foreground`,children:`Permite que Bee hable y escuche`})]}),(0,A.jsxs)(E,{children:[(0,A.jsx)(S,{children:(0,A.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,A.jsx)(w,{children:`Activar voz`}),(0,A.jsx)(l,{checked:N.voiceEnabled,onCheckedChange:e=>$({voiceEnabled:e})})]})}),(0,A.jsx)(C,{children:N.voiceEnabled?(0,A.jsxs)(`div`,{className:`space-y-4`,children:[(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(b,{htmlFor:`sttProvider`,children:`Reconocimiento de voz (STT)`}),(0,A.jsxs)(o,{value:N.sttProvider,onValueChange:e=>$({sttProvider:e}),children:[(0,A.jsx)(c,{children:(0,A.jsx)(a,{})}),(0,A.jsxs)(s,{children:[(0,A.jsx)(i,{value:`groq-whisper`,children:`Groq Whisper (Recomendado)`}),(0,A.jsx)(i,{value:`openai-whisper`,children:`OpenAI Whisper`})]})]})]}),(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(b,{htmlFor:`ttsProvider`,children:`Síntesis de voz (TTS)`}),(0,A.jsxs)(o,{value:N.ttsProvider,onValueChange:e=>$({ttsProvider:e}),children:[(0,A.jsx)(c,{children:(0,A.jsx)(a,{})}),(0,A.jsxs)(s,{children:[(0,A.jsx)(i,{value:`elevenlabs`,children:`ElevenLabs (Recomendado)`}),(0,A.jsx)(i,{value:`openai`,children:`OpenAI TTS`}),(0,A.jsx)(i,{value:`gemini`,children:`Google Gemini`})]})]})]}),(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(b,{htmlFor:`ttsVoice`,children:`Voz`}),(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsxs)(o,{value:N.ttsVoice,onValueChange:e=>$({ttsVoice:e}),children:[(0,A.jsx)(c,{children:(0,A.jsx)(a,{placeholder:`Selecciona una voz`})}),(0,A.jsxs)(s,{children:[(0,A.jsx)(i,{value:`Rachel`,children:`Rachel (ElevenLabs)`}),(0,A.jsx)(i,{value:`Adam`,children:`Adam (ElevenLabs)`}),(0,A.jsx)(i,{value:`Antoni`,children:`Antoni (ElevenLabs)`}),(0,A.jsx)(i,{value:`Elli`,children:`Elli (ElevenLabs)`}),(0,A.jsx)(i,{value:`Josh`,children:`Josh (ElevenLabs)`}),(0,A.jsx)(i,{value:`alloy`,children:`Alloy (OpenAI)`}),(0,A.jsx)(i,{value:`echo`,children:`Echo (OpenAI)`}),(0,A.jsx)(i,{value:`fable`,children:`Fable (OpenAI)`}),(0,A.jsx)(i,{value:`onyx`,children:`Onyx (OpenAI)`}),(0,A.jsx)(i,{value:`nova`,children:`Nova (OpenAI)`}),(0,A.jsx)(i,{value:`shimmer`,children:`Shimmer (OpenAI)`})]})]}),(0,A.jsx)(_,{variant:`outline`,size:`icon`,children:(0,A.jsx)(ie,{className:`w-4 h-4`})})]})]}),(0,A.jsx)(O,{children:(0,A.jsx)(D,{className:`text-sm`,children:N.provider===N.ttsProvider&&(0,A.jsxs)(`span`,{className:`text-green-600 flex items-center gap-1`,children:[(0,A.jsx)(u,{className:`w-4 h-4`}),` Ya tienes la API key configurada`]})})})]}):(0,A.jsx)(`p`,{className:`text-muted-foreground text-center py-4`,children:`Puedes activar la voz más tarde en la configuración`})})]})]}),Te=()=>(0,A.jsxs)(`div`,{className:`space-y-6`,children:[(0,A.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,A.jsx)(`h2`,{className:`text-2xl font-bold`,children:`Reglas éticas`}),(0,A.jsx)(`p`,{className:`text-muted-foreground`,children:`Define los límites de tu agente`})]}),(0,A.jsx)(O,{children:(0,A.jsxs)(D,{className:`text-sm`,children:[`Las reglas de categoría `,(0,A.jsx)(`strong`,{className:`text-red-500`,children:`NUNCA`}),` son las protecciones más importantes. Desactivarlas puede comprometer la seguridad.`]})}),(0,A.jsxs)(`div`,{className:`space-y-3`,children:[Q.map(e=>{let t=N.ethicsRules[e.id]!==!1;return(0,A.jsx)(E,{className:r(!t&&`opacity-60`),children:(0,A.jsx)(C,{className:`p-4`,children:(0,A.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,A.jsx)(ee,{checked:t,onCheckedChange:t=>{e.isDefault&&!t&&!confirm(`¿Estás seguro de desactivar los lineamientos éticos por defecto?`)||$({ethicsRules:{...N.ethicsRules,[e.id]:t}})}}),(0,A.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`h3`,{className:`font-medium`,children:e.name}),e.isDefault&&(0,A.jsx)(x,{className:`text-xs bg-blue-500/10 text-blue-500`,children:`Por defecto`})]}),e.description&&(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:e.description}),(0,A.jsxs)(`details`,{className:`mt-2`,children:[(0,A.jsx)(`summary`,{className:`text-xs text-muted-foreground cursor-pointer hover:text-foreground`,children:`Ver contenido`}),(0,A.jsx)(`pre`,{className:`text-xs mt-2 p-2 bg-muted rounded whitespace-pre-wrap font-mono`,children:e.content})]})]})]})})},e.id)}),Q.length===0&&(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:`Cargando lineamientos éticos...`})]}),(0,A.jsx)(_,{variant:`outline`,className:`w-full`,onClick:()=>{let e=prompt(`Ingresa tu regla personalizada:`);if(e){let t=prompt(`Categoría (SIEMPRE/NUNCA/CONFIRMAR):`,`CONFIRMAR`);t&&[`SIEMPRE`,`NUNCA`,`CONFIRMAR`].includes(t.toUpperCase())&&$({customRules:[...N.customRules,{text:e,category:t.toUpperCase()}]})}},children:`+ Añadir regla personalizada`}),N.customRules.length>0&&(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(b,{children:`Reglas personalizadas`}),N.customRules.map((e,t)=>(0,A.jsx)(E,{children:(0,A.jsxs)(C,{className:`p-4 flex items-center justify-between`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`font-medium`,children:e.text}),(0,A.jsx)(x,{className:r(`text-xs mt-1`,e.category===`NUNCA`&&`text-red-500 bg-red-500/10`,e.category===`SIEMPRE`&&`text-green-500 bg-green-500/10`,e.category===`CONFIRMAR`&&`text-amber-500 bg-amber-500/10`),children:e.category})]}),(0,A.jsx)(_,{variant:`ghost`,size:`sm`,onClick:()=>{$({customRules:N.customRules.filter((e,n)=>n!==t)})},children:`Eliminar`})]})},t))]})]}),Ee=()=>(0,A.jsxs)(`div`,{className:`space-y-6`,children:[(0,A.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,A.jsx)(`h2`,{className:`text-2xl font-bold`,children:`Módulos opcionales`}),(0,A.jsx)(`p`,{className:`text-muted-foreground`,children:`Activa las funcionalidades adicionales que quieras usar`})]}),(0,A.jsx)(E,{className:`border-border`,children:(0,A.jsx)(C,{className:`p-8 text-center`,children:(0,A.jsx)(`p`,{className:`text-muted-foreground`,children:`No hay módulos opcionales disponibles en este momento.`})})})]}),De=()=>(0,A.jsxs)(`div`,{className:`space-y-6`,children:[(0,A.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,A.jsx)(`h2`,{className:`text-2xl font-bold`,children:`¡Todo listo!`}),(0,A.jsx)(`p`,{className:`text-muted-foreground`,children:`Revisa tu configuración antes de continuar`})]}),B?(0,A.jsx)(E,{className:`border-green-500 bg-green-500/10`,children:(0,A.jsxs)(C,{className:`p-8 text-center space-y-4`,children:[(0,A.jsx)(`div`,{className:`flex justify-center`,children:(0,A.jsxs)(`div`,{className:`relative`,children:[(0,A.jsx)(p,{className:`w-24 h-24 text-amber-500 animate-pulse`,fill:`currentColor`}),(0,A.jsx)(h,{className:`w-8 h-8 text-amber-300 absolute -top-2 -right-2 animate-bounce`})]})}),(0,A.jsx)(`h3`,{className:`text-xl font-bold`,children:`¡Bienvenido a Hive!`}),(0,A.jsxs)(`p`,{className:`text-muted-foreground`,children:[N.agentName,` está listo para ayudarte.`]})]})}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(E,{children:[(0,A.jsxs)(S,{children:[(0,A.jsxs)(w,{className:`flex items-center gap-3`,children:[(0,A.jsx)(`div`,{className:`w-10 h-10 rounded-lg flex items-center justify-center bg-amber-500`,children:(0,A.jsx)(p,{className:`w-6 h-6 text-white`,fill:`currentColor`})}),N.agentName]}),(0,A.jsx)(T,{children:N.agentDescription||`Sin descripción`})]}),(0,A.jsxs)(C,{className:`space-y-4`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(b,{className:`text-sm text-muted-foreground`,children:`Proveedor`}),(0,A.jsxs)(`p`,{className:`font-medium`,children:[q.find(e=>e.id===N.provider)?.name||N.provider,` — `,N.model]})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(b,{className:`text-sm text-muted-foreground`,children:`Canales activos`}),(0,A.jsx)(`div`,{className:`flex gap-2 flex-wrap mt-1`,children:Object.entries(N.channels).filter(([e,t])=>t.enabled).map(([e])=>{let t=M.find(t=>t.id===e);return(0,A.jsxs)(x,{variant:`secondary`,children:[t?.icon,` `,t?.name]},e)})})]}),N.voiceEnabled&&(0,A.jsxs)(`div`,{children:[(0,A.jsx)(b,{className:`text-sm text-muted-foreground`,children:`Voz`}),(0,A.jsxs)(`p`,{className:`font-medium`,children:[`STT: `,N.sttProvider,` | TTS: `,N.ttsProvider,N.ttsVoice&&` (${N.ttsVoice})`]})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(b,{className:`text-sm text-muted-foreground`,children:`Reglas éticas activas`}),(0,A.jsx)(`div`,{className:`flex gap-2 flex-wrap mt-1`,children:Object.entries(N.ethicsRules).filter(([e,t])=>t).map(([e])=>(0,A.jsx)(x,{variant:`outline`,children:Q.find(t=>t.id===e)?.name??e},e))})]})]})]}),(0,A.jsx)(_,{className:`w-full h-14 text-lg bg-amber-500 hover:bg-amber-600`,onClick:ve,disabled:R,children:R?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(m,{className:`w-5 h-5 mr-2 animate-spin`}),`Configurando...`]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(h,{className:`w-5 h-5 mr-2`}),`Iniciar a `,N.agentName]})})]})]});return(0,A.jsx)(`div`,{className:`min-h-screen bg-gradient-to-b from-background to-muted/20`,children:(0,A.jsxs)(`div`,{className:`container max-w-2xl mx-auto py-8 px-4`,children:[(0,A.jsxs)(`div`,{className:`mb-8 space-y-2`,children:[(0,A.jsxs)(`div`,{className:`flex justify-between text-sm text-muted-foreground`,children:[(0,A.jsxs)(`span`,{children:[`Paso `,t,` de 8`]}),(0,A.jsx)(`button`,{onClick:ge,className:`text-xs text-muted-foreground hover:text-foreground`,children:`Reiniciar configuración`})]}),(0,A.jsx)(se,{value:t/8*100,className:`h-2`})]}),ye(),G&&(0,A.jsx)(O,{variant:`destructive`,className:`mt-6`,children:(0,A.jsx)(D,{children:G})}),!B&&(0,A.jsxs)(`div`,{className:`flex justify-between mt-6 pt-6 border-t`,children:[(0,A.jsx)(_,{variant:`outline`,onClick:he,disabled:t===1,children:`← Anterior`}),t<8?(0,A.jsx)(_,{onClick:me,className:`bg-amber-500 hover:bg-amber-600`,children:`Siguiente →`}):(0,A.jsx)(`div`,{})]})]})})}export{L as default};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as t}from"./vendor-charts-Bu2lyBKP.js";import{o as n}from"./vendor-query-DsWPbQdG.js";import{t as r}from"./utils-3pnRFmFe.js";import{a as i,c as a,n as o,r as s,s as c,t as l}from"./switch-BDwN8RYV.js";import{t as u}from"./circle-check-Bb54Ebmu.js";import{a as ee,i as te,n as ne,o as d,r as re,t as f}from"./accordion-C5d5Rm5z.js";import{t as p}from"./hexagon-DsGOUl-H.js";import{t as m}from"./loader-circle-CZNax6kS.js";import{t as h}from"./sparkles-yUEb-7oH.js";import{t as ie}from"./volume-2-CeSXNDv4.js";import{c as ae}from"./vendor-router-C9pIYwbJ.js";import{t as g}from"./gateway-url-COCbW0IR.js";import{M as _,_ as oe,j as v,p as y}from"./index-CQ7fn00w.js";import{t as b}from"./label-CrH0Jj3v.js";import{t as x}from"./badge-DXUDdTed.js";import{a as S,n as C,o as w,r as T,t as E}from"./card-CNf6BS2e.js";import{t as se}from"./progress-BherYzY6.js";import{n as D,t as O}from"./alert-Bq6awLlW.js";var k=e(t(),1),A=n(),ce={gemini:`🔵`,anthropic:`🟠`,openai:`🟢`,groq:`🔴`,ollama:`🟣`,openrouter:`🟡`,deepseek:`🔷`,mistral:`🔸`,kimi:`🌙`},j={gemini:`https://aistudio.google.com/app/apikey`,anthropic:`https://console.anthropic.com/keys`,openai:`https://platform.openai.com/api-keys`,groq:`https://console.groq.com/keys`,openrouter:`https://openrouter.ai/keys`,deepseek:`https://platform.deepseek.com/api_keys`,mistral:`https://console.mistral.ai/api-keys`,kimi:`https://platform.moonshot.cn/console/api-keys`},M=[{id:`webchat`,name:`WebChat`,description:`Chat web integrado`,icon:`💬`,required:!0},{id:`telegram`,name:`Telegram`,description:`Bot de Telegram`,icon:`✈️`,required:!1},{id:`discord`,name:`Discord`,description:`Bot de Discord`,icon:`🎮`,required:!1},{id:`whatsapp`,name:`WhatsApp`,description:`Bot de WhatsApp`,icon:`📱`,required:!1},{id:`slack`,name:`Slack`,description:`Bot de Slack`,icon:`💼`,required:!1}],N=`hive_setup_wizard_data`;function P(){try{let e=sessionStorage.getItem(N);if(e){let t=JSON.parse(e);return{...I(),...t}}}catch(e){console.error(`Failed to load wizard data:`,e)}return null}function le(e){try{sessionStorage.setItem(N,JSON.stringify(e))}catch(e){console.error(`Failed to save wizard data:`,e)}}function F(){try{sessionStorage.removeItem(N)}catch(e){console.error(`Failed to clear wizard data:`,e)}}function I(){return{userName:``,userLanguage:`es`,userTimezone:Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`,userOccupation:``,userNotes:``,agentName:`Bee`,agentDescription:``,agentTone:`friendly`,provider:``,apiKey:``,model:``,apiKeyVerified:!1,channels:{webchat:{enabled:!0},telegram:{enabled:!1},discord:{enabled:!1},whatsapp:{enabled:!1},slack:{enabled:!1}},voiceEnabled:!1,sttProvider:`groq-whisper`,ttsProvider:`elevenlabs`,ttsVoice:``,ethicsRules:{},customRules:[]}}function L(){let e=ae(),[t,n]=(0,k.useState)(1),[N,L]=(0,k.useState)(()=>P()||I()),[R,z]=(0,k.useState)(!1),[B,ue]=(0,k.useState)(!1),{showLoader:V,hideLoader:H}=oe(),[U,W]=(0,k.useState)(`idle`),[G,K]=(0,k.useState)(null),[q,de]=(0,k.useState)([]),[J,Y]=(0,k.useState)(null),[X,Z]=(0,k.useState)(!1),[Q,fe]=(0,k.useState)([]);(0,k.useEffect)(()=>{fetch(`${g()}/api/setup/providers`).then(e=>e.json()).then(e=>{Array.isArray(e)&&de(e)}).catch(()=>{}),fetch(`${g()}/api/setup/ethics`).then(e=>e.json()).then(e=>{Array.isArray(e)&&(fe(e),L(t=>Object.keys(t.ethicsRules).length===0?{...t,ethicsRules:Object.fromEntries(e.map(e=>[e.id,!0]))}:t))}).catch(()=>{})},[]),(0,k.useEffect)(()=>{le(N)},[N]),(0,k.useEffect)(()=>{fetch(`${g()}/api/setup/status`).then(e=>e.json()).then(t=>{t.configured&&e(`/ui`)}).catch(()=>{})},[e]);let $=e=>{K(null),L(t=>({...t,...e}))},pe=()=>{switch(t){case 1:return N.userName.trim()?N.userName.trim().length<2?`El nombre debe tener al menos 2 caracteres.`:null:`El nombre es obligatorio.`;case 2:return N.agentName.trim()?N.agentName.trim().length<2?`El nombre debe tener al menos 2 caracteres.`:null:`El nombre del agente es obligatorio.`;case 3:return N.provider?N.provider!==`ollama`&&!N.apiKey?`Ingresa tu API key.`:N.provider!==`ollama`&&!N.apiKeyVerified?`Verifica tu API key antes de continuar.`:N.model?null:`Selecciona un modelo.`:`Selecciona un proveedor LLM.`;default:return null}},me=()=>{let e=pe();if(e){K(e);return}K(null),t<8&&n(e=>e+1)},he=()=>{t>1&&n(e=>e-1)},ge=()=>{confirm(`¿Estás seguro de que quieres reiniciar la configuración? Se perderá todo el progreso.`)&&(F(),L(I()),n(1))},_e=async()=>{if(!(!N.apiKey||!N.provider)){W(`verifying`);try{(await y(`/api/setup/verify-provider`,{method:`POST`,body:{provider:N.provider,apiKey:N.apiKey},showLoader:`Verificando conexión...`,showError:!1})).success?(W(`success`),$({apiKeyVerified:!0})):(W(`error`),$({apiKeyVerified:!1}))}catch{W(`error`),$({apiKeyVerified:!1})}}},ve=async()=>{z(!0);try{let t=await y(`/api/setup/complete`,{method:`POST`,body:N,showLoader:`Finalizando configuración...`,showError:!0});if(t.success){let n=t.authToken;n&&localStorage.setItem(`hive-auth-token`,n),ue(!0),F(),(async()=>{await new Promise(e=>setTimeout(e,1500)),V(`Iniciando a ${N.agentName}... esto toma unos segundos`);for(let t=0;t<40;t++){try{let t=await fetch(`${g()}/api/setup/status`);if(t.ok){let{configured:r}=await t.json();if(r){H(),e(n?`/?token=${n}`:`/`);return}}}catch{}await new Promise(e=>setTimeout(e,1e3))}H(),e(n?`/?token=${n}`:`/`)})()}}catch{}finally{z(!1)}},ye=()=>{switch(t){case 1:return be();case 2:return xe();case 3:return Se();case 4:return Ce();case 5:return we();case 6:return Te();case 7:return Ee();case 8:return De();default:return null}},be=()=>(0,A.jsxs)(`div`,{className:`space-y-6`,children:[(0,A.jsxs)(`div`,{className:`text-center space-y-4`,children:[(0,A.jsx)(`div`,{className:`flex justify-center`,children:(0,A.jsxs)(`div`,{className:`relative`,children:[(0,A.jsx)(p,{className:`w-24 h-24 text-amber-500`,fill:`currentColor`}),(0,A.jsx)(h,{className:`w-8 h-8 text-amber-300 absolute -top-2 -right-2`})]})}),(0,A.jsx)(`h1`,{className:`text-3xl font-bold`,children:`Bienvenido a Hive`}),(0,A.jsx)(`p`,{className:`text-muted-foreground max-w-md mx-auto`,children:`Hive es tu colmena de agentes IA. Local-first. Multi-canal. Open source. En los próximos minutos configurarás tu agente personal Bee.`})]}),(0,A.jsxs)(E,{children:[(0,A.jsxs)(S,{children:[(0,A.jsx)(w,{children:`Tu información`}),(0,A.jsx)(T,{children:`Comencemos con tus datos básicos`})]}),(0,A.jsxs)(C,{className:`space-y-4`,children:[(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(b,{htmlFor:`userName`,children:`Tu nombre`}),(0,A.jsx)(v,{id:`userName`,placeholder:`¿Cómo te llamas?`,value:N.userName,onChange:e=>$({userName:e.target.value})})]}),(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(b,{htmlFor:`userLanguage`,children:`Idioma preferido`}),(0,A.jsxs)(o,{value:N.userLanguage,onValueChange:e=>$({userLanguage:e}),children:[(0,A.jsx)(c,{children:(0,A.jsx)(a,{})}),(0,A.jsxs)(s,{children:[(0,A.jsx)(i,{value:`es`,children:`Español`}),(0,A.jsx)(i,{value:`en`,children:`English`}),(0,A.jsx)(i,{value:`pt`,children:`Português`}),(0,A.jsx)(i,{value:`fr`,children:`Français`})]})]})]}),(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(b,{htmlFor:`userTimezone`,children:`Zona horaria`}),(0,A.jsx)(v,{id:`userTimezone`,value:N.userTimezone,onChange:e=>$({userTimezone:e.target.value}),placeholder:`America/Bogota`}),(0,A.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Detectada automáticamente: `,Intl.DateTimeFormat().resolvedOptions().timeZone]})]}),(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsxs)(b,{htmlFor:`userOccupation`,children:[`Ocupación `,(0,A.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(opcional)`})]}),(0,A.jsx)(v,{id:`userOccupation`,value:N.userOccupation,onChange:e=>$({userOccupation:e.target.value}),placeholder:`Ej: Desarrollador de software, diseñador, estudiante...`})]}),(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsxs)(b,{htmlFor:`userNotes`,children:[`Preferencias de comunicación `,(0,A.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(opcional)`})]}),(0,A.jsx)(`textarea`,{id:`userNotes`,className:`w-full min-h-[80px] p-3 border rounded-md bg-background resize-none text-sm`,value:N.userNotes,onChange:e=>$({userNotes:e.target.value}),placeholder:`Ej: Prefiero respuestas cortas y directas. Usa ejemplos de código cuando expliques conceptos técnicos...`})]})]})]})]}),xe=()=>(0,A.jsxs)(`div`,{className:`space-y-6`,children:[(0,A.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,A.jsx)(`h2`,{className:`text-2xl font-bold`,children:`Tu agente`}),(0,A.jsx)(`p`,{className:`text-muted-foreground`,children:`Personaliza a Bee, tu agente personal`})]}),(0,A.jsxs)(E,{children:[(0,A.jsx)(S,{children:(0,A.jsx)(w,{children:`Identidad del agente`})}),(0,A.jsxs)(C,{className:`space-y-4`,children:[(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(b,{htmlFor:`agentName`,children:`Nombre del agente`}),(0,A.jsx)(v,{id:`agentName`,value:N.agentName,onChange:e=>$({agentName:e.target.value}),placeholder:`Bee`})]}),(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(b,{htmlFor:`agentDescription`,children:`Descripción / Personalidad`}),(0,A.jsx)(`textarea`,{id:`agentDescription`,className:`w-full min-h-[100px] p-3 border rounded-md bg-background resize-none`,value:N.agentDescription,onChange:e=>$({agentDescription:e.target.value}),placeholder:`Ej: Eres un asistente útil y amable. Respondes de forma concisa pero completa. Te especializas en ayudar con tareas de programación y productividad...`})]}),(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(b,{htmlFor:`agentTone`,children:`Tono de comunicación`}),(0,A.jsxs)(o,{value:N.agentTone,onValueChange:e=>$({agentTone:e}),children:[(0,A.jsx)(c,{children:(0,A.jsx)(a,{placeholder:`Selecciona un tono`})}),(0,A.jsxs)(s,{children:[(0,A.jsx)(i,{value:`friendly`,children:`Amigable y cercano`}),(0,A.jsx)(i,{value:`professional`,children:`Profesional y formal`}),(0,A.jsx)(i,{value:`direct`,children:`Directo y conciso`}),(0,A.jsx)(i,{value:`casual`,children:`Casual y relajado`})]})]}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Define cómo se comunicará tu agente contigo`})]})]})]})]}),Se=()=>(0,A.jsxs)(`div`,{className:`space-y-6`,children:[(0,A.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,A.jsx)(`h2`,{className:`text-2xl font-bold`,children:`Proveedor LLM`}),(0,A.jsx)(`p`,{className:`text-muted-foreground`,children:`Selecciona el cerebro de tu agente`})]}),(0,A.jsx)(`div`,{className:`grid gap-3`,children:q.map(e=>(0,A.jsx)(E,{className:r(`cursor-pointer transition-all hover:shadow-md`,N.provider===e.id&&`border-amber-500 ring-2 ring-amber-500`),onClick:()=>{$({provider:e.id,model:``,apiKeyVerified:!1}),e.id===`ollama`&&Y(null)},children:(0,A.jsxs)(C,{className:`flex items-center gap-4 p-4`,children:[(0,A.jsx)(`span`,{className:`text-3xl`,children:ce[e.id]??`🤖`}),(0,A.jsxs)(`div`,{className:`flex-1`,children:[(0,A.jsx)(`h3`,{className:`font-semibold`,children:e.name}),(0,A.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[e.models.length,` modelo`,e.models.length===1?``:`s`,` disponible`,e.models.length===1?``:`s`]})]}),N.provider===e.id&&(0,A.jsx)(u,{className:`w-5 h-5 text-amber-500`})]})},e.id))}),N.provider&&(()=>{let e=q.find(e=>e.id===N.provider);return(0,A.jsxs)(E,{className:`mt-4`,children:[(0,A.jsx)(S,{children:(0,A.jsxs)(w,{children:[`Configuración de `,e?.name]})}),(0,A.jsxs)(C,{className:`space-y-4`,children:[N.provider!==`ollama`&&(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(b,{htmlFor:`apiKey`,children:`API Key`}),(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(v,{id:`apiKey`,type:`password`,value:N.apiKey,onChange:e=>$({apiKey:e.target.value,apiKeyVerified:!1}),placeholder:`sk-...`,className:r(G?.includes(`API key`)&&!N.apiKey&&`border-red-500`)}),(0,A.jsx)(_,{variant:`outline`,onClick:_e,disabled:!N.apiKey||U===`verifying`,children:U===`verifying`?(0,A.jsx)(m,{className:`w-4 h-4 animate-spin`}):U===`success`?(0,A.jsx)(u,{className:`w-4 h-4 text-green-500`}):U===`error`?(0,A.jsx)(d,{className:`w-4 h-4 text-red-500`}):`Verificar`})]}),U===`success`&&(0,A.jsxs)(`p`,{className:`text-sm text-green-600 flex items-center gap-1`,children:[(0,A.jsx)(u,{className:`w-4 h-4`}),` API key verificada correctamente`]}),U===`error`&&(0,A.jsxs)(`p`,{className:`text-sm text-red-600 flex items-center gap-1`,children:[(0,A.jsx)(d,{className:`w-4 h-4`}),` API key inválida o error de conexión`]}),j[N.provider]&&(0,A.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`¿No tienes tu API key?`,` `,(0,A.jsx)(`a`,{href:j[N.provider],target:`_blank`,rel:`noopener noreferrer`,className:`text-amber-500 hover:underline`,children:`Obtener aquí`})]})]}),N.provider===`ollama`&&(0,A.jsxs)(`div`,{className:`space-y-3`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(_,{type:`button`,variant:`outline`,size:`sm`,disabled:X,onClick:()=>{Y(null),Z(!0),$({model:``}),fetch(`${g()}/api/setup/ollama-models`).then(e=>e.json()).then(e=>{Y(e.models??[]),Z(!1)}).catch(()=>{Y([]),Z(!1)})},children:X?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(m,{className:`w-3 h-3 animate-spin mr-1`}),`Detectando...`]}):`🔍 Detectar modelos`}),!X&&J!==null&&(0,A.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:J.length>0?`${J.length} modelo${J.length===1?``:`s`} encontrado${J.length===1?``:`s`}`:`Sin modelos — instala uno con ollama pull`})]}),J&&J.length>0&&(0,A.jsxs)(`div`,{className:`space-y-1`,children:[(0,A.jsx)(b,{htmlFor:`model`,children:`Modelo`}),(0,A.jsxs)(o,{value:N.model,onValueChange:e=>$({model:e}),children:[(0,A.jsx)(c,{className:r(!N.model&&G?.includes(`modelo`)&&`border-red-500`),children:(0,A.jsx)(a,{placeholder:`Selecciona un modelo`})}),(0,A.jsx)(s,{children:J.map((e,t)=>(0,A.jsxs)(i,{value:e.id,children:[e.name,t===0?` (Recomendado)`:``]},e.id))})]})]}),!X&&J!==null&&J.length===0&&(0,A.jsxs)(`p`,{className:`text-xs text-amber-600`,children:[`Asegúrate que Ollama esté corriendo (`,(0,A.jsx)(`code`,{children:`ollama serve`}),`) y tengas modelos (`,(0,A.jsx)(`code`,{children:`ollama pull llama3.2`}),`).`]})]}),N.provider!==`ollama`&&N.apiKeyVerified&&(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(b,{htmlFor:`model`,children:`Modelo`}),(0,A.jsxs)(o,{value:N.model,onValueChange:e=>$({model:e}),children:[(0,A.jsx)(c,{className:r(!N.model&&G?.includes(`modelo`)&&`border-red-500`),children:(0,A.jsx)(a,{placeholder:`Selecciona un modelo`})}),(0,A.jsx)(s,{children:(e?.models??[]).map((e,t)=>(0,A.jsxs)(i,{value:e.id,children:[e.name||e.id,t===0?` (Recomendado)`:``]},e.id))})]})]})]})]})})()]}),Ce=()=>(0,A.jsxs)(`div`,{className:`space-y-6`,children:[(0,A.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,A.jsx)(`h2`,{className:`text-2xl font-bold`,children:`Canales`}),(0,A.jsx)(`p`,{className:`text-muted-foreground`,children:`¿Dónde quieres que Bee esté disponible?`})]}),(0,A.jsx)(`div`,{className:`grid gap-3`,children:M.map(e=>(0,A.jsx)(E,{className:r(`transition-all`,N.channels[e.id]?.enabled&&`border-amber-500`),children:(0,A.jsxs)(C,{className:`p-4`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,A.jsx)(`span`,{className:`text-2xl`,children:e.icon}),(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`h3`,{className:`font-semibold flex items-center gap-2`,children:[e.name,e.required&&(0,A.jsx)(x,{variant:`secondary`,className:`text-xs`,children:`Requerido`})]}),(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.description})]})]}),(0,A.jsx)(l,{checked:N.channels[e.id]?.enabled,onCheckedChange:t=>{e.required&&!t||$({channels:{...N.channels,[e.id]:{enabled:t}}})},disabled:e.required})]}),!e.required&&N.channels[e.id]?.enabled&&(0,A.jsx)(f,{type:`single`,collapsible:!0,className:`mt-4`,children:(0,A.jsxs)(re,{value:`config`,children:[(0,A.jsx)(te,{children:`Configuración`}),(0,A.jsx)(ne,{children:(0,A.jsxs)(`div`,{className:`space-y-3 pt-2`,children:[e.id===`telegram`&&(0,A.jsx)(A.Fragment,{children:(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(b,{htmlFor:`telegramToken`,children:`Token del Bot`}),(0,A.jsx)(v,{id:`telegramToken`,placeholder:`123456789:ABCdefGHIjklMNOpqrsTUVwxyz`,value:N.channels.telegram.config?.botToken||``,onChange:e=>$({channels:{...N.channels,telegram:{enabled:!0,config:{botToken:e.target.value}}}})}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,A.jsx)(`a`,{href:`https://t.me/BotFather`,target:`_blank`,rel:`noopener noreferrer`,className:`text-amber-500 hover:underline`,children:`Obtén tu token en BotFather`})})]})}),e.id===`discord`&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(b,{htmlFor:`discordToken`,children:`Token del Bot`}),(0,A.jsx)(v,{id:`discordToken`,placeholder:`MTIzNDU2Nzg5MDEyMzQ1Njc4OQ.GJKlMn.OpQrStUvWxYz`,value:N.channels.discord.config?.botToken||``,onChange:e=>$({channels:{...N.channels,discord:{enabled:!0,config:{botToken:e.target.value}}}})})]}),(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(b,{htmlFor:`discordClientId`,children:`Client ID`}),(0,A.jsx)(v,{id:`discordClientId`,placeholder:`1234567890123456789`,value:N.channels.discord.config?.clientId||``,onChange:e=>$({channels:{...N.channels,discord:{enabled:!0,config:{clientId:e.target.value}}}})})]})]}),e.id===`whatsapp`&&(0,A.jsx)(A.Fragment,{children:(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(b,{htmlFor:`whatsappToken`,children:`Token de la API`}),(0,A.jsx)(v,{id:`whatsappToken`,placeholder:`...`,value:N.channels.whatsapp.config?.apiToken||``,onChange:e=>$({channels:{...N.channels,whatsapp:{enabled:!0,config:{apiToken:e.target.value}}}})})]})}),e.id===`slack`&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(b,{htmlFor:`slackToken`,children:`Bot Token`}),(0,A.jsx)(v,{id:`slackToken`,placeholder:`xoxb-...`,value:N.channels.slack.config?.botToken||``,onChange:e=>$({channels:{...N.channels,slack:{enabled:!0,config:{botToken:e.target.value}}}})})]}),(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(b,{htmlFor:`slackSigningSecret`,children:`Signing Secret`}),(0,A.jsx)(v,{id:`slackSigningSecret`,placeholder:`...`,value:N.channels.slack.config?.signingSecret||``,onChange:e=>$({channels:{...N.channels,slack:{enabled:!0,config:{signingSecret:e.target.value}}}})})]})]})]})})]})})]})},e.id))})]}),we=()=>(0,A.jsxs)(`div`,{className:`space-y-6`,children:[(0,A.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,A.jsx)(`h2`,{className:`text-2xl font-bold`,children:`Voz (opcional)`}),(0,A.jsx)(`p`,{className:`text-muted-foreground`,children:`Permite que Bee hable y escuche`})]}),(0,A.jsxs)(E,{children:[(0,A.jsx)(S,{children:(0,A.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,A.jsx)(w,{children:`Activar voz`}),(0,A.jsx)(l,{checked:N.voiceEnabled,onCheckedChange:e=>$({voiceEnabled:e})})]})}),(0,A.jsx)(C,{children:N.voiceEnabled?(0,A.jsxs)(`div`,{className:`space-y-4`,children:[(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(b,{htmlFor:`sttProvider`,children:`Reconocimiento de voz (STT)`}),(0,A.jsxs)(o,{value:N.sttProvider,onValueChange:e=>$({sttProvider:e}),children:[(0,A.jsx)(c,{children:(0,A.jsx)(a,{})}),(0,A.jsxs)(s,{children:[(0,A.jsx)(i,{value:`groq-whisper`,children:`Groq Whisper (Recomendado)`}),(0,A.jsx)(i,{value:`openai-whisper`,children:`OpenAI Whisper`})]})]})]}),(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(b,{htmlFor:`ttsProvider`,children:`Síntesis de voz (TTS)`}),(0,A.jsxs)(o,{value:N.ttsProvider,onValueChange:e=>$({ttsProvider:e}),children:[(0,A.jsx)(c,{children:(0,A.jsx)(a,{})}),(0,A.jsxs)(s,{children:[(0,A.jsx)(i,{value:`elevenlabs`,children:`ElevenLabs (Recomendado)`}),(0,A.jsx)(i,{value:`openai`,children:`OpenAI TTS`}),(0,A.jsx)(i,{value:`gemini`,children:`Google Gemini`})]})]})]}),(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(b,{htmlFor:`ttsVoice`,children:`Voz`}),(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsxs)(o,{value:N.ttsVoice,onValueChange:e=>$({ttsVoice:e}),children:[(0,A.jsx)(c,{children:(0,A.jsx)(a,{placeholder:`Selecciona una voz`})}),(0,A.jsxs)(s,{children:[(0,A.jsx)(i,{value:`Rachel`,children:`Rachel (ElevenLabs)`}),(0,A.jsx)(i,{value:`Adam`,children:`Adam (ElevenLabs)`}),(0,A.jsx)(i,{value:`Antoni`,children:`Antoni (ElevenLabs)`}),(0,A.jsx)(i,{value:`Elli`,children:`Elli (ElevenLabs)`}),(0,A.jsx)(i,{value:`Josh`,children:`Josh (ElevenLabs)`}),(0,A.jsx)(i,{value:`alloy`,children:`Alloy (OpenAI)`}),(0,A.jsx)(i,{value:`echo`,children:`Echo (OpenAI)`}),(0,A.jsx)(i,{value:`fable`,children:`Fable (OpenAI)`}),(0,A.jsx)(i,{value:`onyx`,children:`Onyx (OpenAI)`}),(0,A.jsx)(i,{value:`nova`,children:`Nova (OpenAI)`}),(0,A.jsx)(i,{value:`shimmer`,children:`Shimmer (OpenAI)`})]})]}),(0,A.jsx)(_,{variant:`outline`,size:`icon`,children:(0,A.jsx)(ie,{className:`w-4 h-4`})})]})]}),(0,A.jsx)(O,{children:(0,A.jsx)(D,{className:`text-sm`,children:N.provider===N.ttsProvider&&(0,A.jsxs)(`span`,{className:`text-green-600 flex items-center gap-1`,children:[(0,A.jsx)(u,{className:`w-4 h-4`}),` Ya tienes la API key configurada`]})})})]}):(0,A.jsx)(`p`,{className:`text-muted-foreground text-center py-4`,children:`Puedes activar la voz más tarde en la configuración`})})]})]}),Te=()=>(0,A.jsxs)(`div`,{className:`space-y-6`,children:[(0,A.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,A.jsx)(`h2`,{className:`text-2xl font-bold`,children:`Reglas éticas`}),(0,A.jsx)(`p`,{className:`text-muted-foreground`,children:`Define los límites de tu agente`})]}),(0,A.jsx)(O,{children:(0,A.jsxs)(D,{className:`text-sm`,children:[`Las reglas de categoría `,(0,A.jsx)(`strong`,{className:`text-red-500`,children:`NUNCA`}),` son las protecciones más importantes. Desactivarlas puede comprometer la seguridad.`]})}),(0,A.jsxs)(`div`,{className:`space-y-3`,children:[Q.map(e=>{let t=N.ethicsRules[e.id]!==!1;return(0,A.jsx)(E,{className:r(!t&&`opacity-60`),children:(0,A.jsx)(C,{className:`p-4`,children:(0,A.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,A.jsx)(ee,{checked:t,onCheckedChange:t=>{e.isDefault&&!t&&!confirm(`¿Estás seguro de desactivar los lineamientos éticos por defecto?`)||$({ethicsRules:{...N.ethicsRules,[e.id]:t}})}}),(0,A.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`h3`,{className:`font-medium`,children:e.name}),e.isDefault&&(0,A.jsx)(x,{className:`text-xs bg-blue-500/10 text-blue-500`,children:`Por defecto`})]}),e.description&&(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:e.description}),(0,A.jsxs)(`details`,{className:`mt-2`,children:[(0,A.jsx)(`summary`,{className:`text-xs text-muted-foreground cursor-pointer hover:text-foreground`,children:`Ver contenido`}),(0,A.jsx)(`pre`,{className:`text-xs mt-2 p-2 bg-muted rounded whitespace-pre-wrap font-mono`,children:e.content})]})]})]})})},e.id)}),Q.length===0&&(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:`Cargando lineamientos éticos...`})]}),(0,A.jsx)(_,{variant:`outline`,className:`w-full`,onClick:()=>{let e=prompt(`Ingresa tu regla personalizada:`);if(e){let t=prompt(`Categoría (SIEMPRE/NUNCA/CONFIRMAR):`,`CONFIRMAR`);t&&[`SIEMPRE`,`NUNCA`,`CONFIRMAR`].includes(t.toUpperCase())&&$({customRules:[...N.customRules,{text:e,category:t.toUpperCase()}]})}},children:`+ Añadir regla personalizada`}),N.customRules.length>0&&(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(b,{children:`Reglas personalizadas`}),N.customRules.map((e,t)=>(0,A.jsx)(E,{children:(0,A.jsxs)(C,{className:`p-4 flex items-center justify-between`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`font-medium`,children:e.text}),(0,A.jsx)(x,{className:r(`text-xs mt-1`,e.category===`NUNCA`&&`text-red-500 bg-red-500/10`,e.category===`SIEMPRE`&&`text-green-500 bg-green-500/10`,e.category===`CONFIRMAR`&&`text-amber-500 bg-amber-500/10`),children:e.category})]}),(0,A.jsx)(_,{variant:`ghost`,size:`sm`,onClick:()=>{$({customRules:N.customRules.filter((e,n)=>n!==t)})},children:`Eliminar`})]})},t))]})]}),Ee=()=>(0,A.jsxs)(`div`,{className:`space-y-6`,children:[(0,A.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,A.jsx)(`h2`,{className:`text-2xl font-bold`,children:`Módulos opcionales`}),(0,A.jsx)(`p`,{className:`text-muted-foreground`,children:`Activa las funcionalidades adicionales que quieras usar`})]}),(0,A.jsx)(E,{className:`border-border`,children:(0,A.jsx)(C,{className:`p-8 text-center`,children:(0,A.jsx)(`p`,{className:`text-muted-foreground`,children:`No hay módulos opcionales disponibles en este momento.`})})})]}),De=()=>(0,A.jsxs)(`div`,{className:`space-y-6`,children:[(0,A.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,A.jsx)(`h2`,{className:`text-2xl font-bold`,children:`¡Todo listo!`}),(0,A.jsx)(`p`,{className:`text-muted-foreground`,children:`Revisa tu configuración antes de continuar`})]}),B?(0,A.jsx)(E,{className:`border-green-500 bg-green-500/10`,children:(0,A.jsxs)(C,{className:`p-8 text-center space-y-4`,children:[(0,A.jsx)(`div`,{className:`flex justify-center`,children:(0,A.jsxs)(`div`,{className:`relative`,children:[(0,A.jsx)(p,{className:`w-24 h-24 text-amber-500 animate-pulse`,fill:`currentColor`}),(0,A.jsx)(h,{className:`w-8 h-8 text-amber-300 absolute -top-2 -right-2 animate-bounce`})]})}),(0,A.jsx)(`h3`,{className:`text-xl font-bold`,children:`¡Bienvenido a Hive!`}),(0,A.jsxs)(`p`,{className:`text-muted-foreground`,children:[N.agentName,` está listo para ayudarte.`]})]})}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(E,{children:[(0,A.jsxs)(S,{children:[(0,A.jsxs)(w,{className:`flex items-center gap-3`,children:[(0,A.jsx)(`div`,{className:`w-10 h-10 rounded-lg flex items-center justify-center bg-amber-500`,children:(0,A.jsx)(p,{className:`w-6 h-6 text-white`,fill:`currentColor`})}),N.agentName]}),(0,A.jsx)(T,{children:N.agentDescription||`Sin descripción`})]}),(0,A.jsxs)(C,{className:`space-y-4`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(b,{className:`text-sm text-muted-foreground`,children:`Proveedor`}),(0,A.jsxs)(`p`,{className:`font-medium`,children:[q.find(e=>e.id===N.provider)?.name||N.provider,` — `,N.model]})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(b,{className:`text-sm text-muted-foreground`,children:`Canales activos`}),(0,A.jsx)(`div`,{className:`flex gap-2 flex-wrap mt-1`,children:Object.entries(N.channels).filter(([e,t])=>t.enabled).map(([e])=>{let t=M.find(t=>t.id===e);return(0,A.jsxs)(x,{variant:`secondary`,children:[t?.icon,` `,t?.name]},e)})})]}),N.voiceEnabled&&(0,A.jsxs)(`div`,{children:[(0,A.jsx)(b,{className:`text-sm text-muted-foreground`,children:`Voz`}),(0,A.jsxs)(`p`,{className:`font-medium`,children:[`STT: `,N.sttProvider,` | TTS: `,N.ttsProvider,N.ttsVoice&&` (${N.ttsVoice})`]})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(b,{className:`text-sm text-muted-foreground`,children:`Reglas éticas activas`}),(0,A.jsx)(`div`,{className:`flex gap-2 flex-wrap mt-1`,children:Object.entries(N.ethicsRules).filter(([e,t])=>t).map(([e])=>(0,A.jsx)(x,{variant:`outline`,children:Q.find(t=>t.id===e)?.name??e},e))})]})]})]}),(0,A.jsx)(_,{className:`w-full h-14 text-lg bg-amber-500 hover:bg-amber-600`,onClick:ve,disabled:R,children:R?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(m,{className:`w-5 h-5 mr-2 animate-spin`}),`Configurando...`]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(h,{className:`w-5 h-5 mr-2`}),`Iniciar a `,N.agentName]})})]})]});return(0,A.jsx)(`div`,{className:`min-h-screen bg-gradient-to-b from-background to-muted/20`,children:(0,A.jsxs)(`div`,{className:`container max-w-2xl mx-auto py-8 px-4`,children:[(0,A.jsxs)(`div`,{className:`mb-8 space-y-2`,children:[(0,A.jsxs)(`div`,{className:`flex justify-between text-sm text-muted-foreground`,children:[(0,A.jsxs)(`span`,{children:[`Paso `,t,` de 8`]}),(0,A.jsx)(`button`,{onClick:ge,className:`text-xs text-muted-foreground hover:text-foreground`,children:`Reiniciar configuración`})]}),(0,A.jsx)(se,{value:t/8*100,className:`h-2`})]}),ye(),G&&(0,A.jsx)(O,{variant:`destructive`,className:`mt-6`,children:(0,A.jsx)(D,{children:G})}),!B&&(0,A.jsxs)(`div`,{className:`flex justify-between mt-6 pt-6 border-t`,children:[(0,A.jsx)(_,{variant:`outline`,onClick:he,disabled:t===1,children:`← Anterior`}),t<8?(0,A.jsx)(_,{onClick:me,className:`bg-amber-500 hover:bg-amber-600`,children:`Siguiente →`}):(0,A.jsx)(`div`,{})]})]})})}export{L as default};
|