@johpaz/hive-agents 1.1.2 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hive.js +3741 -3150
- package/dist/tool-worker.js +25 -2
- package/dist/ui/assets/{A2UIPage-BOR7GzYi.js → A2UIPage-EDS7lN-K.js} +4 -4
- package/dist/ui/assets/{AgentCreateForm-Btza1Kiv.js → AgentCreateForm-KvhVhAFP.js} +1 -1
- package/dist/ui/assets/AgentDetailPage-B2dCpO92.js +1 -0
- package/dist/ui/assets/{AgentNewPage-DvP05Ap5.js → AgentNewPage-CF2B4dbu.js} +1 -1
- package/dist/ui/assets/AgentsPage-CMvz-CtA.js +10 -0
- package/dist/ui/assets/{ApiClientPage-Cmo0XBwk.js → ApiClientPage-tzzL3rZC.js} +1 -1
- package/dist/ui/assets/{ChannelsPage-C53NCtXi.js → ChannelsPage-fE2vRwup.js} +2 -2
- package/dist/ui/assets/DashboardPage-57SaHnBL.js +6 -0
- package/dist/ui/assets/{LoginPage-CTc-MbtG.js → LoginPage-Fag9Bp5h.js} +1 -1
- package/dist/ui/assets/{LogsPage-D-2DgTQh.js → LogsPage-GVJd_a65.js} +1 -1
- package/dist/ui/assets/{MeetingPage-B8Xb1z_0.js → MeetingPage-TKQu8Nr-.js} +1 -1
- package/dist/ui/assets/{ModelSelector-BcaASPWF.js → ModelSelector-DciHLo7R.js} +1 -1
- package/dist/ui/assets/{NotFound-PUg3gEO0.js → NotFound-D4ZlDVg9.js} +1 -1
- package/dist/ui/assets/{Office3DPage-6bDnybWI.js → Office3DPage-CQnO522l.js} +2 -2
- package/dist/ui/assets/ProvidersPage-BsWFvzqz.js +1 -0
- package/dist/ui/assets/{RecoverPage-UL782VIG.js → RecoverPage-BkdOyljs.js} +1 -1
- package/dist/ui/assets/SettingsPage-D_43Rc2I.js +9 -0
- package/dist/ui/assets/{SetupPage-B_fXVcuJ.js → SetupPage-D6Z3SYZu.js} +1 -1
- package/dist/ui/assets/VoicePage-CCE2EOE9.js +307 -0
- package/dist/ui/assets/{WebChatPage-D8KsJqMf.js → WebChatPage-Dzk3FhiR.js} +4 -4
- package/dist/ui/assets/{conversationsStore-8WwqUOpe.js → conversationsStore-5hf5grlP.js} +1 -1
- package/dist/ui/assets/{core-B_5cyOSV.js → core-p4c5dns5.js} +1 -1
- package/dist/ui/assets/{dialog-DcgGvP2g.js → dialog-DKnsGLwr.js} +1 -1
- package/dist/ui/assets/{dist-js-q7C_AB0j.js → dist-js-CkNhvsFc.js} +1 -1
- package/dist/ui/assets/dist-js-jWCEHSkB.js +1 -0
- package/dist/ui/assets/{index-C5Hhusqq.js → index-mBw9Tl7u.js} +44 -4
- package/dist/ui/assets/useAudioDevices-BYFaA0X-.js +1 -0
- package/dist/ui/assets/{useHiveAgentsModelLoad-IOqfYcrC.js → useHiveAgentsModelLoad-RRQ6-ANC.js} +1 -1
- package/dist/ui/assets/{useProviders-DsFqfiyM.js → useProviders-DXr4pJ57.js} +1 -1
- package/dist/ui/assets/{vendor-router-DP84b3LQ.js → vendor-router-DSMCk-Ka.js} +1 -1
- package/dist/ui/index.html +2 -2
- package/package.json +5 -3
- package/packages/core/src/agent/compaction.ts +162 -25
- package/packages/core/src/agent/context-compiler.ts +121 -8
- package/packages/core/src/agent/conversation-store.ts +43 -2
- package/packages/core/src/agent/handoff.ts +129 -0
- package/packages/core/src/agent/history-timeline.ts +133 -0
- package/packages/core/src/agent/message-memory.ts +148 -0
- package/packages/core/src/agent/summary-memory.ts +152 -0
- package/packages/core/src/agent/thread-store.ts +4 -0
- package/packages/core/src/config/loader.ts +37 -1
- package/packages/core/src/gateway/realtime/voice-session.ts +19 -0
- package/packages/core/src/storage/collections.ts +3 -0
- package/packages/core/src/tools/core/index.ts +19 -6
- package/packages/skills/src/bundled-data.generated.ts +756 -756
- package/dist/ui/assets/AgentDetailPage-D435IX8G.js +0 -1
- package/dist/ui/assets/AgentsPage-BT9CssIN.js +0 -10
- package/dist/ui/assets/DashboardPage-DpI54Ot0.js +0 -6
- package/dist/ui/assets/ProvidersPage-CVK-nKxE.js +0 -1
- package/dist/ui/assets/SettingsPage-CHJfutPk.js +0 -9
- package/dist/ui/assets/VoicePage-CdBZrLAm.js +0 -307
- package/dist/ui/assets/dist-js-Dh18rcg9.js +0 -1
- package/dist/ui/assets/useAudioDevices-BO-kUbtK.js +0 -41
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{f as t}from"./vendor-charts-K3xcRl0X.js";import{t as n}from"./vendor-react-kUOwxn0g.js";import{n as r,o as i}from"./vendor-query-Dj8xYhQD.js";import{t as a}from"./createLucideIcon-BRaPSYgN.js";import{t as o}from"./activity-C_GS5wrG.js";import{t as s}from"./calendar-B6x9cw-q.js";import{t as c}from"./check-C8pw-7Fx.js";import{t as l}from"./chevron-down-8GjmTjLR.js";import{t as u}from"./chevron-up-DZrzJIW8.js";import{t as d}from"./circle-alert-CtDbK2nl.js";import{t as f}from"./circle-check-BKNT2_q6.js";import{n as p,t as m}from"./earth-BJRGJbVn.js";import{t as h}from"./copy-wR7o7Ly8.js";import{t as g}from"./useProviders-DsFqfiyM.js";import{n as _,t as v}from"./eye-CxvxtQT5.js";import{t as y}from"./history-DLK5rTlP.js";import{t as b}from"./info-8ReWzubE.js";import{n as x,t as S}from"./key-DPkOY-J0.js";import{t as C}from"./lock-3IApZyVy.js";import{t as w}from"./mail-vwCEHyhQ.js";import{t as T}from"./mic-CpDU_2as.js";import{d as E,g as D,h as O,m as k,n as A,t as j}from"./useAudioDevices-BO-kUbtK.js";import{t as M}from"./pause-BAMsNQkh.js";import{t as N}from"./pencil-CKritjT_.js";import{t as ee}from"./play-Cwpe4tp6.js";import{t as P}from"./plus-RD44ce15.js";import{t as F}from"./refresh-cw-DtJMHRHO.js";import{t as I}from"./rotate-ccw-b3E_4PoX.js";import{t as L}from"./search-z2oZt00P.js";import{t as R}from"./send-CpoY_2F-.js";import{t as z}from"./shield-CIarwBvx.js";import{t as B}from"./sparkles-DVvY6jDT.js";import{t as V}from"./terminal-BEcTK780.js";import{t as te}from"./trash-2-D6oziYAK.js";import{t as ne}from"./volume-2-EaA0JRvD.js";import{t as re}from"./zap-DSoX9NDk.js";import{n as ie}from"./utils-DEmd_M8c.js";import{l as ae}from"./vendor-router-DP84b3LQ.js";import{r as oe}from"./gateway-url-BALS_wVh.js";import{$ as se,A as H,D as ce,G as U,J as le,O as W,Q as ue,T as de,W as G,Y as fe,Z as pe,a as me,at as he,c as ge,ct as _e,et as ve,i as ye,j as K,k as q,lt as be,nt as xe,o as Se,ot as Ce,q as we,r as Te,rt as J,s as Ee,st as De,tt as Oe,ut as ke,w as Ae,x as je}from"./index-C5Hhusqq.js";import{t as Me}from"./badge-B5AKge1b.js";import{t as Ne}from"./scroll-area-CbH8FOo8.js";import{a as Pe,c as Fe,i as Ie,o as Le,r as Re,s as ze,t as Be}from"./dialog-DcgGvP2g.js";import{t as Y}from"./label-D_fvqJyD.js";import{t as Ve}from"./textarea-BgZJFZTX.js";import{i as X,n as He,o as Ue,s as We,t as Ge}from"./select-v_3QBYrD.js";import{t as Ke}from"./switch-ndx8VCpm.js";import{a as qe,i as Je,n as Ye,r as Xe,t as Ze}from"./card-mTJ4oZbL.js";var Qe=a(`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`}]]),$e=a(`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`}]]),et=a(`Code`,[[`polyline`,{points:`16 18 22 12 16 6`,key:`z7tu5w`}],[`polyline`,{points:`8 6 2 12 8 18`,key:`1eg1df`}]]),tt=a(`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`}]]),nt=a(`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`}]]),rt=a(`LockKeyhole`,[[`circle`,{cx:`12`,cy:`16`,r:`1`,key:`1au0dj`}],[`rect`,{x:`3`,y:`10`,width:`18`,height:`12`,rx:`2`,key:`6s8ecr`}],[`path`,{d:`M7 10V7a5 5 0 0 1 10 0v3`,key:`1pqi11`}]]),it=a(`MessageCircle`,[[`path`,{d:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,key:`vv11sd`}]]),at=a(`Power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),ot=a(`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`}]]),st=a(`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`}]]),ct=a(`ZoomIn`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`,key:`13gj7c`}],[`line`,{x1:`11`,x2:`11`,y1:`8`,y2:`14`,key:`1vmskp`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`,key:`durymu`}]]),Z=e(t(),1),Q=n(),lt=oe((e,t)=>({isLoading:!1,error:null,configs:[],setLoading:t=>e({isLoading:t}),setError:t=>e({error:t}),fetchEthics:async()=>{e({isLoading:!0,error:null});try{let t=(await W(`/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 W(`/api/ethics/${i.id}`,{method:`PUT`,body:{content:n}}):await W(`/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}},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:ie(),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)}))}})),$=i();function ut(){let{configs:e,fetchEthics:t,isLoading:n}=lt(),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)({name:``,description:``,content:``}),[l,u]=(0,Z.useState)(!1),d=(0,Z.useRef)(null),f=()=>{let e=d.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)};(0,Z.useEffect)(()=>{a&&setTimeout(f,0)},[a,s.content]),(0,Z.useEffect)(()=>{t().catch(console.error)},[t]),(0,Z.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=>{K.show(`Activando registro de ética...`);let r=e;try{let e=await Promise.all(r.map(e=>W(`/api/ethics/${e.id}`,{method:`PUT`,body:{active:+(e.id===n)}}).catch(()=>({}))));await t();let i=e.find((e,t)=>r[t].id===n);q.fire({icon:`success`,title:i?.message||`Registro de ética activado`})}catch(e){q.fire({icon:`error`,title:e instanceof Error?e.message:`Error al activar registro`})}finally{K.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)(J,{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)(z,{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)(ue,{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,$.jsxs)(`p`,{className:`text-xs text-white/40 mb-8 max-w-[300px] mx-auto leading-relaxed`,children:[`No se detectaron lineamientos éticos en el sistema. Esto no debería ocurrir en una instalación completa — verifica la conexión con el gateway o ejecuta `,(0,$.jsx)(`code`,{children:`hive doctor`}),`.`]})]})]})}):(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)(ve,{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)(Be,{open:a,onOpenChange:o,children:(0,$.jsx)(Re,{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)(z,{className:`h-6 w-6`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(ze,{className:`hive-title-page !text-2xl uppercase tracking-tighter`,children:p.name}),(0,$.jsx)(Ie,{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)(Y,{className:`hive-label uppercase !text-[10px]`,children:`Nombre del Protocolo`}),(0,$.jsx)(G,{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)(Y,{className:`hive-label uppercase !text-[10px]`,children:`Descripción / Meta`}),(0,$.jsx)(G,{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)(Y,{className:`hive-label uppercase !text-[10px]`,children:`Lineamientos de Capa (Markdown)`})}),(0,$.jsx)(Ve,{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),K.show(`Guardando lineamientos éticos...`);try{let e=await W(`/api/ethics/${p.id}`,{method:`PUT`,body:s});await t(),q.fire({icon:`success`,title:e.message||`Contenido ético guardado`})}catch(e){q.fire({icon:`error`,title:e instanceof Error?e.message:`Error al guardar`})}finally{u(!1),K.hide(),o(!1)}}},disabled:l,className:`hive-btn hive-btn--primary px-8 text-[10px]`,children:l?`SINCRONIZANDO...`:`GUARDAR LINEAMIENTOS`})]})]})]})})})]})}var dt={filesystem:`Sistema de archivos`,web:`Web`,cron:`Cron`,cli:`CLI`,agents:`Agentes`};function ft(){let{tools:e,isLoading:t,fetchTools:n,toggleTool:r,updateTool:i}=de(),[a,o]=(0,Z.useState)(`all`),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{n()},[n]);let p=async(e,t)=>{if(!l){u(e);try{await r(e,t),n(),q.fire({icon:`success`,title:`Herramienta ${t?`activada`:`desactivada`}`})}catch{q.fire({icon:`error`,title:`Error al actualizar estado de la herramienta`})}finally{u(null)}}},h=async()=>{if(s){f(!0),K.show(`Guardando herramienta...`);try{await i(s.id,{name:s.name,description:s.description}),q.fire({icon:`success`,title:`Herramienta actualizada`}),n(),c(null)}catch{q.fire({icon:`error`,title:`Error al guardar cambios`})}finally{f(!1),K.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)(J,{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)(le,{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`,`a2ui`].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`:dt[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)(ue,{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)(m,{className:`h-6 w-6`}),e.category===`web`&&(0,$.jsx)(m,{className:`h-6 w-6`}),e.category===`cron`&&(0,$.jsx)(L,{className:`h-6 w-6`}),e.category===`cli`&&(0,$.jsx)(V,{className:`h-6 w-6`}),e.category===`agents`&&(0,$.jsx)(O,{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)(Ke,{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)(Be,{open:!!s,onOpenChange:e=>!e&&c(null),children:(0,$.jsxs)(Re,{className:`sm:max-w-sm bg-zinc-950 border-white/10`,children:[(0,$.jsxs)(Le,{children:[(0,$.jsxs)(ze,{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)(O,{className:`h-3.5 w-3.5`})}),`Editar herramienta`]}),(0,$.jsx)(Ie,{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)(Y,{className:`text-[10px] text-zinc-500 uppercase tracking-widest font-bold`,children:`Nombre`}),(0,$.jsx)(G,{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)(Y,{className:`text-[10px] text-zinc-500 uppercase tracking-widest font-bold`,children:`Descripción`}),(0,$.jsx)(Ve,{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)(Me,{variant:`outline`,className:`text-[9px] border-zinc-800 text-zinc-500 uppercase`,children:s?.category})]})]}),(0,$.jsxs)(Pe,{className:`gap-2 sm:gap-0`,children:[(0,$.jsx)(U,{variant:`outline`,size:`sm`,onClick:()=>c(null),className:`hive-btn--form-cancel h-10`,children:`Cancelar`}),(0,$.jsxs)(U,{size:`sm`,onClick:h,disabled:d,className:`hive-btn--form-submit h-10`,children:[d&&(0,$.jsx)(J,{className:`h-3.5 w-3.5 animate-spin`}),`Guardar Cambios`]})]})]})})]})}function pt(e){let t=(0,Q.c)(44),{server:n,onClick:r,isConnected:i,isLoading:a}=e,o=i||n.status===`connected`,s=n.transport===`stdio`,c=`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 ${o?`border-cyan-500/20 bg-cyan-500/[0.02]`:`opacity-80 grayscale-[0.2]`} ${a?`pointer-events-none opacity-50`:``}`,l=`absolute top-0 left-0 w-1 h-full transition-colors ${o?`bg-cyan-500`:`bg-zinc-800`}`,u;t[0]===l?u=t[1]:(u=(0,$.jsx)(`div`,{className:l}),t[0]=l,t[1]=u);let d=`p-2 rounded-lg transition-colors ${o?`bg-cyan-500/10 text-cyan-400`:`bg-zinc-800 text-zinc-500`}`,f;t[2]===s?f=t[3]:(f=s?(0,$.jsx)(g,{className:`h-5 w-5`}):(0,$.jsx)(Ce,{className:`h-5 w-5`}),t[2]=s,t[3]=f);let p;t[4]!==d||t[5]!==f?(p=(0,$.jsx)(`div`,{className:d,children:f}),t[4]=d,t[5]=f,t[6]=p):p=t[6];let m;t[7]===o?m=t[8]:(m=(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:o?(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)(Me,{variant:`outline`,className:`text-[10px] border-zinc-800 text-zinc-500 uppercase tracking-tighter`,children:`OFFLINE`})}),t[7]=o,t[8]=m);let h;t[9]!==p||t[10]!==m?(h=(0,$.jsxs)(`div`,{className:`flex items-start justify-between mb-2`,children:[p,m]}),t[9]=p,t[10]=m,t[11]=h):h=t[11];let _;t[12]===n.name?_=t[13]:(_=(0,$.jsx)(qe,{className:`text-sm font-bold truncate group-hover:text-cyan-400 transition-colors`,children:n.name}),t[12]=n.name,t[13]=_);let v=n.url||`stdio: ${n.transport}`,y;t[14]===v?y=t[15]:(y=(0,$.jsx)(Xe,{className:`text-[10px] font-mono opacity-50 truncate mt-0.5`,children:v}),t[14]=v,t[15]=y);let b;t[16]!==y||t[17]!==h||t[18]!==_?(b=(0,$.jsxs)(Je,{className:`pb-2`,children:[h,_,y]}),t[16]=y,t[17]=h,t[18]=_,t[19]=b):b=t[19];let x;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(`span`,{className:`text-[9px] text-zinc-500 uppercase font-bold tracking-widest`,children:`Transport`}),t[20]=x):x=t[20];let S;t[21]===n.transport?S=t[22]:(S=(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[x,(0,$.jsx)(`span`,{className:`text-xs font-semibold text-zinc-300`,children:n.transport})]}),t[21]=n.transport,t[22]=S);let C;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(`div`,{className:`h-4 w-px bg-white/10`}),t[23]=C):C=t[23];let w;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(`span`,{className:`text-[9px] text-zinc-500 uppercase font-bold tracking-widest`,children:`Tools`}),t[24]=w):w=t[24];let T=n.tools?.length||n.tools_count||0,E;t[25]===T?E=t[26]:(E=(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[w,(0,$.jsxs)(`span`,{className:`text-xs font-semibold text-zinc-300`,children:[T,` expuestas`]})]}),t[25]=T,t[26]=E);let D;t[27]!==S||t[28]!==E?(D=(0,$.jsxs)(`div`,{className:`flex items-center gap-3 mt-2`,children:[S,C,E]}),t[27]=S,t[28]=E,t[29]=D):D=t[29];let O;t[30]===n.builtin?O=t[31]:(O=n.builtin&&(0,$.jsx)(Me,{variant:`outline`,className:`mt-3 text-[9px] border-amber-500/20 text-amber-500/70 bg-amber-500/5`,children:`BUILTIN`}),t[30]=n.builtin,t[31]=O);let k;t[32]!==D||t[33]!==O?(k=(0,$.jsxs)(Ye,{className:`pt-0 pb-4`,children:[D,O]}),t[32]=D,t[33]=O,t[34]=k):k=t[34];let A;t[35]===o?A=t[36]:(A=o&&(0,$.jsx)(`div`,{className:`absolute -bottom-6 -right-6 w-12 h-12 bg-cyan-500/10 blur-2xl rounded-full`}),t[35]=o,t[36]=A);let j;return t[37]!==r||t[38]!==c||t[39]!==b||t[40]!==k||t[41]!==A||t[42]!==u?(j=(0,$.jsxs)(Ze,{onClick:r,className:c,children:[u,b,k,A]}),t[37]=r,t[38]=c,t[39]=b,t[40]=k,t[41]=A,t[42]=u,t[43]=j):j=t[43],j}function mt(e){let t=(0,Q.c)(15),{serverName:n,tools:r}=e,i=r===void 0?[]:r,[a,o]=(0,Z.useState)(``),s;t[0]===a?s=t[1]:(s=e=>e.name.toLowerCase().includes(a.toLowerCase())||e.description.toLowerCase().includes(a.toLowerCase()),t[0]=a,t[1]=s);let c=i.filter(s),l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(L,{className:`absolute left-2.5 top-2.5 h-3.5 w-3.5 text-zinc-500`}),t[2]=l):l=t[2];let u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=e=>o(e.target.value),t[3]=u):u=t[3];let d;t[4]===a?d=t[5]:(d=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 relative`,children:[l,(0,$.jsx)(G,{placeholder:`Buscar herramientas...`,className:`pl-8 h-8 text-[11px] bg-white/5 border-white/10 focus:border-cyan-500/30`,value:a,onChange:u})]}),t[4]=a,t[5]=d);let f=c.length===0?(0,$.jsx)(`div`,{className:`py-8 text-center text-[10px] text-zinc-500 italic`,children:a?`No se encontraron herramientas que coincidan.`:`Este servidor no expone herramientas actualmente.`}):c.map(ht),p;t[6]===f?p=t[7]:(p=(0,$.jsx)(`div`,{className:`space-y-2 max-h-[300px] overflow-y-auto pr-1 custom-scrollbar`,children:f}),t[6]=f,t[7]=p);let m;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(b,{className:`h-3 w-3 text-cyan-500`}),t[8]=m):m=t[8];let h;t[9]===n?h=t[10]:(h=(0,$.jsxs)(`div`,{className:`p-2 rounded bg-cyan-500/5 border border-cyan-500/10 flex items-center gap-2`,children:[m,(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:n}),`.`]})]}),t[9]=n,t[10]=h);let g;return t[11]!==h||t[12]!==d||t[13]!==p?(g=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[d,p,h]}),t[11]=h,t[12]=d,t[13]=p,t[14]=g):g=t[14],g}function ht(e){return(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)(tt,{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)(Me,{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)}function gt(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 _t({server:e,onClose:t}){let{updateMCPServer:n,toggleMCPServer:r,deleteMCPServer:i,fetchMCPServers:a}=je(),[o,s]=(0,Z.useState)(e.transport||`stdio`),[c,l]=(0,Z.useState)(e.command||``),[u,d]=(0,Z.useState)(e.args?.join(` `)||``),[f,p]=(0,Z.useState)(e.url||``),[m,h]=(0,Z.useState)(()=>gt(e.headers).authType),[g,_]=(0,Z.useState)(()=>gt(e.headers).authToken),[v,y]=(0,Z.useState)(e.headers?JSON.stringify(e.headers,null,2):``),[b,x]=(0,Z.useState)(!1),[w,T]=(0,Z.useState)(!1),[E,D]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(!0),[j,M]=(0,Z.useState)(!1),[N,ee]=(0,Z.useState)(`config`),[P,F]=(0,Z.useState)(e.status),[I,L]=(0,Z.useState)(e.active),R=P===`connected`||I===1||I===!0;return(0,Z.useEffect)(()=>{let t=!1;return(async()=>{A(!0);try{let n=await W(`/api/mcp/servers/${e.id}`);if(t)return;s(n.transport||`stdio`),l(n.command||``),d(Array.isArray(n.args)?n.args.join(` `):``),p(n.url||``);let r=gt(n.headers);h(r.authType),_(r.authToken),y(n.headers?JSON.stringify(n.headers,null,2):``),F(n.status||e.status),L(+!!n.enabled)}catch{}finally{t||A(!1)}})(),()=>{t=!0}},[e.id]),(0,$.jsx)(Be,{open:!0,onOpenChange:e=>!e&&t(),children:(0,$.jsxs)(Re,{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)(Le,{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 ${R?`bg-cyan-500/10 text-cyan-400`:`bg-zinc-800 text-zinc-500`}`,children:(0,$.jsx)(O,{className:`h-5 w-5`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(ze,{className:`text-white flex items-center gap-2`,children:[`Configurar `,e.name,R&&(0,$.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full bg-cyan-500 animate-pulse`})]}),(0,$.jsxs)(Ie,{className:`text-[10px] font-mono opacity-50 uppercase tracking-widest mt-0.5`,children:[`ID: `,e.id,` • `,e.transport]})]})]}),!e.builtin&&(0,$.jsx)(U,{variant:`ghost`,size:`icon`,onClick:()=>M(!0),disabled:w||j,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)(te,{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:()=>ee(`config`),className:`px-4 py-2 text-[10px] uppercase font-bold tracking-widest transition-all relative ${N===`config`?`text-cyan-400`:`text-zinc-500 hover:text-zinc-300`}`,children:[`Configuración`,N===`config`&&(0,$.jsx)(`div`,{className:`absolute bottom-0 left-0 w-full h-0.5 bg-cyan-500`})]}),(0,$.jsxs)(`button`,{onClick:()=>ee(`tools`),className:`px-4 py-2 text-[10px] uppercase font-bold tracking-widest transition-all relative ${N===`tools`?`text-cyan-400`:`text-zinc-500 hover:text-zinc-300`}`,children:[`Herramientas`,N===`tools`&&(0,$.jsx)(`div`,{className:`absolute bottom-0 left-0 w-full h-0.5 bg-cyan-500`})]})]})]}),j&&(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)(U,{variant:`ghost`,size:`sm`,onClick:()=>M(!1),disabled:w,className:`h-7 px-3 text-[10px] font-bold uppercase tracking-wider text-zinc-400 hover:text-white`,children:`Cancelar`}),(0,$.jsx)(U,{size:`sm`,onClick:async()=>{T(!0);try{await W(`/api/mcp/servers/${e.id}`,{method:`DELETE`,showLoader:`Eliminando servidor...`,showError:!0}),await a(),t()}catch{}finally{T(!1),M(!1)}},disabled:w,className:`h-7 px-3 text-[10px] font-bold uppercase tracking-wider bg-red-600 hover:bg-red-500 text-white`,children:w?(0,$.jsx)(J,{className:`h-3 w-3 animate-spin`}):`Sí, eliminar`})]})]}),(0,$.jsx)(`div`,{className:`p-6`,children:N===`config`?(0,$.jsxs)(`div`,{className:`space-y-4 animate-in fade-in duration-300`,children:[k&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-zinc-500`,children:[(0,$.jsx)(J,{className:`h-3 w-3 animate-spin`}),(0,$.jsx)(`span`,{children:`Cargando configuración...`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Y,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Transporte`}),(0,$.jsxs)(Ge,{value:o,onValueChange:s,children:[(0,$.jsx)(Ue,{className:`bg-white/5 border-white/10 h-9`,children:(0,$.jsx)(We,{})}),(0,$.jsxs)(He,{className:`bg-zinc-900 border-white/10`,children:[(0,$.jsx)(X,{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)(V,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`stdio (Binario Local)`})]})}),(0,$.jsx)(X,{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)(Ce,{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)(Y,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Comando`}),(0,$.jsx)(G,{value:c,onChange:e=>l(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)(Y,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Argumentos`}),(0,$.jsx)(G,{value:u,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-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Y,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Endpoint URL`}),(0,$.jsx)(G,{value:f,onChange:e=>p(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)(Y,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Autenticación`}),(0,$.jsxs)(Ge,{value:m,onValueChange:h,children:[(0,$.jsx)(Ue,{className:`bg-white/5 border-white/10 focus:border-cyan-500/50 h-9`,children:(0,$.jsx)(We,{})}),(0,$.jsxs)(He,{className:`bg-zinc-900 border-white/10`,children:[(0,$.jsx)(X,{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)(Ce,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Ninguna`})]})}),(0,$.jsx)(X,{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)(S,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`API Key (x-api-key)`})]})}),(0,$.jsx)(X,{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)(ot,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Bearer Token (Authorization)`})]})}),(0,$.jsx)(X,{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)(et,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Custom Headers (JSON)`})]})})]})]})]}),(m===`api-key`||m===`bearer`)&&(0,$.jsxs)(`div`,{className:`space-y-2 animate-in fade-in slide-in-from-top-1 duration-200`,children:[(0,$.jsx)(Y,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:m===`api-key`?`API Key`:`Bearer Token`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(G,{type:`password`,placeholder:`sk-...`,value:g,onChange:e=>_(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 transition-all h-9 pl-9`}),(0,$.jsx)(C,{className:`absolute left-3 top-2.5 h-3.5 w-3.5 text-zinc-500`})]})]}),m===`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)(Y,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Headers JSON`})}),(0,$.jsx)(`textarea`,{value:v,onChange:e=>y(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 ${R?`bg-green-500/10 text-green-400`:`bg-zinc-800 text-zinc-500`}`,children:(0,$.jsx)(at,{className:`h-3.5 w-3.5 ${R?`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 ${R?`text-green-500`:`text-zinc-500`}`,children:R?`ACTIVE_CONNECTION`:`INACTIVE_NODE`})]})]}),(0,$.jsx)(U,{size:`sm`,variant:R?`outline`:`default`,onClick:async()=>{D(!0),K.show(R?`Desconectando servidor...`:`Conectando servidor...`);try{await r(e.id,!R),L(+!R),F(R?`disconnected`:`connected`),q.fire({icon:`success`,title:R?`Servidor desconectado`:`Servidor conectado`}),setTimeout(a,1500)}catch{q.fire({icon:`error`,title:`Error al cambiar estado de conexión`})}finally{D(!1),K.hide()}},disabled:E,className:`h-7 px-4 text-[10px] font-bold uppercase tracking-wider ${R?`border-zinc-800 text-zinc-400 hover:bg-zinc-800`:`bg-cyan-600 hover:bg-cyan-500 text-white`}`,children:E?(0,$.jsx)(J,{className:`h-3 w-3 animate-spin`}):R?`Desconectar`:`Conectar`})]})]}):(0,$.jsx)(`div`,{className:`animate-in fade-in duration-300`,children:(0,$.jsx)(mt,{serverId:e.id,serverName:e.name,tools:e.tools||[]})})}),(0,$.jsxs)(Pe,{className:`p-6 bg-white/[0.02] border-t border-white/5`,children:[(0,$.jsx)(U,{variant:`ghost`,onClick:t,className:`text-zinc-500 hover:text-white`,children:`Cerrar`}),N===`config`&&(0,$.jsx)(U,{onClick:async()=>{x(!0),K.show(`Actualizando configuración...`);try{let t={transport:o};if(o===`stdio`){if(!c){q.fire({icon:`warning`,title:`El comando es obligatorio`});return}t.command=c;let e=u.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(!f){q.fire({icon:`warning`,title:`La URL es obligatoria`});return}t.url=f;let e={};if(m===`api-key`&&g)e[`x-api-key`]=g;else if(m===`bearer`&&g)e.Authorization=`Bearer ${g}`;else if(m===`custom`&&v.trim())try{e=JSON.parse(v.trim())}catch{q.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(),q.fire({icon:`success`,title:`Configuración actualizada`})}catch(e){q.fire({icon:`error`,title:e instanceof Error?e.message:`Error al actualizar configuración`})}finally{x(!1),K.hide()}},disabled:b,className:`bg-cyan-600 hover:bg-cyan-500 text-white min-w-[120px]`,children:b?(0,$.jsx)(J,{className:`h-4 w-4 animate-spin`}):`Guardar Cambios`})]})]})})}function vt(){let{fetchMCPServers:e}=je(),[t,n]=(0,Z.useState)(!1),[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(`stdio`),[d,p]=(0,Z.useState)(``),[m,h]=(0,Z.useState)(`none`),[g,_]=(0,Z.useState)(``),[v,y]=(0,Z.useState)(``),[b,x]=(0,Z.useState)(!1);return(0,$.jsxs)(Be,{open:t,onOpenChange:n,children:[(0,$.jsx)(Fe,{asChild:!0,children:(0,$.jsxs)(U,{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)(Re,{className:`sm:max-w-[425px] border-cyan-500/20 bg-zinc-950/95 backdrop-blur-xl`,children:[(0,$.jsxs)(Le,{children:[(0,$.jsxs)(ze,{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)(Oe,{className:`h-4 w-4`})}),`Nuevo Servidor MCP`]}),(0,$.jsx)(Ie,{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)(Y,{htmlFor:`mcp-name`,className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Nombre Identificador`}),(0,$.jsx)(G,{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)(Y,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Protocolo de Transporte`}),(0,$.jsxs)(Ge,{value:l,onValueChange:u,children:[(0,$.jsx)(Ue,{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)(We,{placeholder:`Seleccionar transporte`})}),(0,$.jsxs)(He,{position:`popper`,className:`bg-zinc-900 border-white/10 z-[99999]`,sideOffset:4,children:[(0,$.jsx)(X,{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)(V,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`stdio (Binario Local)`})]})}),(0,$.jsx)(X,{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)(Ce,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`SSE (Remote HTTP)`})]})})]})]})]}),l===`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)(Y,{htmlFor:`mcp-cmd`,className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Comando Ejecutable`}),(0,$.jsx)(G,{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)(Y,{htmlFor:`mcp-args`,className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Argumentos`}),(0,$.jsx)(G,{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)(Y,{htmlFor:`mcp-url`,className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Endpoint URL`}),(0,$.jsx)(G,{id:`mcp-url`,placeholder:`https://mcp-server.com/sse`,value:d,onChange:e=>p(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)(Y,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Autenticación`}),(0,$.jsxs)(Ge,{value:m,onValueChange:h,children:[(0,$.jsx)(Ue,{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)(We,{placeholder:`Seleccionar autenticación`})}),(0,$.jsxs)(He,{position:`popper`,className:`bg-zinc-900 border-white/10 z-[99999]`,sideOffset:4,children:[(0,$.jsx)(X,{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)(Ce,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Ninguna`})]})}),(0,$.jsx)(X,{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)(S,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`API Key (x-api-key)`})]})}),(0,$.jsx)(X,{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)(ot,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Bearer Token (Authorization)`})]})}),(0,$.jsx)(X,{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)(S,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Google API Key (X-Goog-Api-Key)`})]})}),(0,$.jsx)(X,{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)(et,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Custom Headers (JSON)`})]})})]})]})]}),(m===`api-key`||m===`google-api-key`||m===`bearer`)&&(0,$.jsxs)(`div`,{className:`space-y-2 animate-in fade-in slide-in-from-top-1 duration-200`,children:[(0,$.jsx)(Y,{htmlFor:`mcp-token`,className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:m===`api-key`?`API Key`:m===`google-api-key`?`Google API Key`:`Bearer Token`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(G,{id:`mcp-token`,type:`password`,placeholder:`sk-...`,value:g,onChange:e=>_(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 transition-all h-9 pl-9`}),(0,$.jsx)(C,{className:`absolute left-3 top-2.5 h-3.5 w-3.5 text-zinc-500`})]})]}),m===`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)(Y,{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:v,onChange:e=>{let t=e.target.value;y(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)(f,{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)(Pe,{children:[(0,$.jsx)(U,{variant:`ghost`,onClick:()=>n(!1),className:`hover:bg-white/5 text-zinc-400 h-9 text-xs`,children:`Cancelar`}),(0,$.jsx)(U,{onClick:async()=>{if(!r){q.fire({icon:`error`,title:`El nombre es obligatorio`});return}x(!0);try{let t={transport:l};if(l===`stdio`){if(!a){q.fire({icon:`error`,title:`El comando es obligatorio para transporte stdio`}),x(!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(!d){q.fire({icon:`error`,title:`La URL es obligatoria para transporte SSE`}),x(!1);return}t.url=d;let e={};if(m===`api-key`&&g)e[`x-api-key`]=g;else if(m===`google-api-key`&&g)e[`X-Goog-Api-Key`]=g;else if(m===`bearer`&&g)e.Authorization=`Bearer ${g}`;else if(m===`custom`&&v.trim())try{e=JSON.parse(v.trim())}catch{H.fire(`Error`,`JSON de Headers inválido`,`error`),x(!1);return}Object.keys(e).length>0&&(t.headers=e)}await W(`/api/mcp/servers`,{method:`POST`,body:{name:r,config:t},showLoader:`Conectando servidor MCP...`,showError:!0}),q.fire({icon:`success`,title:`Servidor "${r}" añadido correctamente`}),i(``),o(``),c(``),p(``),h(`none`),_(``),y(``),n(!1),await e()}catch{}finally{x(!1)}},disabled:b,className:`bg-cyan-600 hover:bg-cyan-500 text-white shadow-lg shadow-cyan-600/20 h-9 text-xs px-6`,children:b?`Conectando...`:`Conectar Servidor`})]})]})]})}function yt(){let e=(0,Q.c)(26),{servers:t,fetchMCPServers:n}=je(),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(``),s,c;e[0]===n?(s=e[1],c=e[2]):(s=()=>{n()},c=[n],e[0]=n,e[1]=s,e[2]=c),(0,Z.useEffect)(s,c);let l,u,d;if(e[3]!==a||e[4]!==t){let n;e[8]===a?n=e[9]:(n=e=>e.name.toLowerCase().includes(a.toLowerCase()),e[8]=a,e[9]=n);let r=t.filter(n),s;e[10]===Symbol.for(`react.memo_cache_sentinel`)?(s=e=>{i({...e,args:typeof e.args==`string`?JSON.parse(e.args):e.args})},e[10]=s):s=e[10];let c=s;l=`space-y-6`;let f;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(f=(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)(Oe,{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`})]})]}),e[11]=f):f=e[11];let p;e[12]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(L,{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`}),e[12]=p):p=e[12];let m;e[13]===Symbol.for(`react.memo_cache_sentinel`)?(m=e=>o(e.target.value),e[13]=m):m=e[13];let h;e[14]===a?h=e[15]:(h=(0,$.jsxs)(`div`,{className:`relative group`,children:[p,(0,$.jsx)(G,{placeholder:`Buscar servidor...`,value:a,onChange:m,className:`pl-9 bg-zinc-900/50 border-white/5 focus:border-cyan-500/30 transition-all h-9 w-[260px] text-xs`})]}),e[14]=a,e[15]=h);let g;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(vt,{}),e[16]=g):g=e[16],e[17]===h?u=e[18]:(u=(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-white/5 pb-4`,children:[f,(0,$.jsxs)(`div`,{className:`flex items-center gap-4`,children:[h,g]})]}),e[17]=h,e[18]=u),d=r.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)(ue,{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:r.map(e=>(0,$.jsx)(pt,{server:e,isConnected:e.status===`connected`||e.active===!0,onClick:()=>c(e)},e.id))}),e[3]=a,e[4]=t,e[5]=l,e[6]=u,e[7]=d}else l=e[5],u=e[6],d=e[7];let f;e[19]===r?f=e[20]:(f=r&&(0,$.jsx)(_t,{server:r,onClose:()=>i(null)}),e[19]=r,e[20]=f);let p;return e[21]!==l||e[22]!==u||e[23]!==d||e[24]!==f?(p=(0,$.jsxs)(`div`,{className:l,children:[u,d,f]}),e[21]=l,e[22]=u,e[23]=d,e[24]=f,e[25]=p):p=e[25],p}var bt=oe((e,t)=>({notes:[],scheduledTasks:[],taskHistory:{},cronChannels:[],cronRecommended:`webchat`,cronUserPreference:`auto`,isLoading:!1,error:null,fetchNotes:async()=>{e({isLoading:!0,error:null});try{e({notes:(await W(`/api/notes`)).notes,isLoading:!1})}catch(t){e({error:t.message,isLoading:!1})}},fetchScheduledTasks:async t=>{e({isLoading:!0,error:null});try{e({scheduledTasks:(await W(t?`/api/cron?status=${t}`:`/api/cron`)).tasks??[],isLoading:!1})}catch(t){e({error:t.message,isLoading:!1,scheduledTasks:[]})}},pauseTask:async t=>{try{await W(`/api/cron/${t}/pause`,{method:`POST`}),e(e=>({scheduledTasks:e.scheduledTasks.map(e=>e.id===t?{...e,status:`paused`}:e)}))}catch(t){e({error:t.message})}},resumeTask:async t=>{try{await W(`/api/cron/${t}/resume`,{method:`POST`}),e(e=>({scheduledTasks:e.scheduledTasks.map(e=>e.id===t?{...e,status:`active`}:e)}))}catch(t){e({error:t.message})}},deleteTask:async t=>{try{await W(`/api/cron/${t}`,{method:`DELETE`}),e(e=>({scheduledTasks:e.scheduledTasks.filter(e=>e.id!==t)}))}catch(t){e({error:t.message})}},triggerTask:async t=>{try{await W(`/api/cron/${t}/trigger`,{method:`POST`})}catch(t){e({error:t.message})}},fetchTaskHistory:async(t,n=10)=>{try{let r=await W(`/api/cron/${t}/history?limit=${n}`);e(e=>({taskHistory:{...e.taskHistory,[t]:r.history??[]}}))}catch(t){e({error:t.message})}},fetchCronChannels:async()=>{try{let t=await W(`/api/cron/channels`),n=[];Array.isArray(t.channels)&&(n=t.channels.map(e=>typeof e==`string`?{id:e,type:e,active:!0,recommended:e===`webchat`||e===`telegram`}:e)),e({cronChannels:n,cronRecommended:`webchat`,cronUserPreference:t.preference??`auto`})}catch{}},saveCronChannelPreference:async t=>{try{await W(`/api/user/settings`,{method:`PATCH`,body:{preferred_cron_channel:t}}),e({cronUserPreference:t})}catch(t){e({error:t.message})}}}));function xt({email:e,profileEditing:t=!1}){let[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(!0),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)(!1),[g,y]=(0,Z.useState)(``),[b,S]=(0,Z.useState)(``),[C,w]=(0,Z.useState)(``),[T,E]=(0,Z.useState)(!1),[D,O]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{j()},[]);async function j(){s(!0);try{let e=await W(`/api/auth/status`);r(e.hasCredentials),a(e.email??``)}catch{}finally{s(!1)}}async function M(){if(!t){u(!0);try{f((await W(`/api/auth/recovery-key`)).recoveryKey)}catch{}}}function N(){y(``),S(``),w(``)}async function ee(e){if(e.preventDefault(),g!==b){await H.fire({icon:`error`,title:`Error`,text:`Las contraseñas no coinciden`});return}if(g.length<8){await H.fire({icon:`error`,title:`Error`,text:`La contraseña debe tener al menos 8 caracteres`});return}A(!0);try{n?await W(`/api/auth/change-password`,{method:`POST`,body:{currentPassword:C,newPassword:g}}):await W(`/api/auth/setup-credentials`,{method:`POST`,body:{password:g}}),await H.fire({icon:`success`,title:n?`Contraseña actualizada`:`Protección activada`,timer:2200,showConfirmButton:!1,toast:!0,position:`top-end`}),N(),u(!1),await j()}catch{}finally{A(!1)}}async function P(){if((await H.fire({title:`¿Desactivar protección?`,text:`Cualquiera con acceso a la URL podrá usar Hive sin contraseña.`,icon:`warning`,showCancelButton:!0,confirmButtonText:`Sí, desactivar`,cancelButtonText:`Cancelar`})).isConfirmed)try{await W(`/api/auth/disable`,{method:`POST`}),await H.fire({icon:`success`,title:`Protección desactivada`,timer:1800,showConfirmButton:!1,toast:!0,position:`top-end`}),r(!1),a(``),N(),u(!1)}catch{}}async function F(){d&&(await navigator.clipboard.writeText(d),m(!0),window.setTimeout(()=>m(!1),2e3))}let I=i||e.trim().toLowerCase();return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border p-3.5 sm:flex-row sm:items-center sm:justify-between`,style:{background:`hsl(var(--hive-glass))`,borderColor:n?`hsl(var(--hive-green) / 0.25)`:`hsl(var(--hive-border-base))`},children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(`div`,{className:`mt-0.5 rounded-lg border p-2`,style:{color:n?`hsl(var(--hive-green))`:`hsl(var(--hive-amber))`,background:n?`hsl(var(--hive-green) / 0.08)`:`hsl(var(--hive-amber) / 0.08)`,borderColor:n?`hsl(var(--hive-green) / 0.18)`:`hsl(var(--hive-amber) / 0.18)`},children:n?(0,$.jsx)(ot,{className:`h-4 w-4`}):(0,$.jsx)(st,{className:`h-4 w-4`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-xs font-bold text-white`,children:`Acceso con contraseña`}),(0,$.jsx)(`p`,{className:`mt-0.5 truncate text-[11px]`,style:{color:`hsl(var(--hive-text-muted))`},children:o?`Comprobando protección…`:n?`Protegido · ${I}`:I?`Sin contraseña · ${I}`:`Guarda un correo válido para activar la protección`})]})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void M(),disabled:o||t||!I,className:`flex h-9 flex-shrink-0 items-center justify-center gap-1.5 rounded-lg px-3 text-[11px] font-bold transition-colors disabled:cursor-not-allowed disabled:opacity-45`,style:{background:`hsl(var(--hive-amber) / 0.12)`,border:`1px solid hsl(var(--hive-amber) / 0.3)`,color:`hsl(var(--hive-amber))`},children:[(0,$.jsx)(x,{className:`h-3.5 w-3.5`}),t?`Guarda el perfil primero`:n?`Gestionar acceso`:`Crear contraseña`]})]}),(0,$.jsx)(Be,{open:l,onOpenChange:e=>{u(e),e||N()},children:(0,$.jsxs)(Re,{className:`overflow-hidden rounded-2xl p-0`,style:{background:`hsl(var(--hive-surface))`,borderColor:`hsl(var(--hive-border-base))`},children:[(0,$.jsx)(`div`,{className:`border-b px-6 py-5`,style:{background:`linear-gradient(135deg, hsl(var(--hive-amber) / 0.12), transparent 65%)`,borderColor:`hsl(var(--hive-border-subtle))`},children:(0,$.jsxs)(Le,{children:[(0,$.jsx)(`div`,{className:`mb-2 flex h-10 w-10 items-center justify-center rounded-xl border`,style:{color:`hsl(var(--hive-amber))`,background:`hsl(var(--hive-amber) / 0.1)`,borderColor:`hsl(var(--hive-amber) / 0.25)`},children:(0,$.jsx)(rt,{className:`h-5 w-5`})}),(0,$.jsx)(ze,{children:n?`Cambiar contraseña`:`Proteger tu instancia`}),(0,$.jsxs)(Ie,{children:[`Tu identidad de acceso será `,(0,$.jsx)(`span`,{className:`font-semibold text-foreground`,children:I}),`.`]})]})}),(0,$.jsxs)(`form`,{onSubmit:ee,className:`space-y-4 px-6 pb-6`,children:[n&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Y,{htmlFor:`profile-current-password`,children:`Contraseña actual`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(G,{id:`profile-current-password`,type:T?`text`:`password`,autoComplete:`current-password`,value:C,onChange:e=>w(e.target.value),required:!0,disabled:k,className:`pr-10`}),(0,$.jsx)(`button`,{type:`button`,"aria-label":T?`Ocultar contraseña actual`:`Mostrar contraseña actual`,className:`absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground transition-colors hover:text-foreground`,onClick:()=>E(e=>!e),children:T?(0,$.jsx)(_,{className:`h-4 w-4`}):(0,$.jsx)(v,{className:`h-4 w-4`})})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Y,{htmlFor:`profile-new-password`,children:n?`Nueva contraseña`:`Contraseña`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(G,{id:`profile-new-password`,type:D?`text`:`password`,autoComplete:`new-password`,placeholder:`Mínimo 8 caracteres`,value:g,onChange:e=>y(e.target.value),minLength:8,required:!0,disabled:k,className:`pr-10`}),(0,$.jsx)(`button`,{type:`button`,"aria-label":D?`Ocultar contraseña nueva`:`Mostrar contraseña nueva`,className:`absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground transition-colors hover:text-foreground`,onClick:()=>O(e=>!e),children:D?(0,$.jsx)(_,{className:`h-4 w-4`}):(0,$.jsx)(v,{className:`h-4 w-4`})})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Y,{htmlFor:`profile-confirm-password`,children:`Confirmar contraseña`}),(0,$.jsx)(G,{id:`profile-confirm-password`,type:D?`text`:`password`,autoComplete:`new-password`,value:b,onChange:e=>S(e.target.value),minLength:8,required:!0,disabled:k})]}),d&&(0,$.jsxs)(`div`,{className:`rounded-xl border p-3`,style:{background:`hsl(var(--hive-glass))`,borderColor:`hsl(var(--hive-border-subtle))`},children:[(0,$.jsx)(`p`,{className:`text-[11px] font-bold`,children:`Clave de recuperación`}),(0,$.jsx)(`p`,{className:`mt-0.5 text-[10px] text-muted-foreground`,children:`Guárdala fuera de este equipo por si olvidas tu contraseña.`}),(0,$.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,$.jsx)(`code`,{className:`min-w-0 flex-1 truncate rounded-md bg-black/20 px-2.5 py-2 text-[10px]`,children:d}),(0,$.jsx)(U,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Copiar clave de recuperación`,onClick:()=>void F(),children:p?(0,$.jsx)(c,{className:`h-4 w-4 text-green-500`}):(0,$.jsx)(h,{className:`h-4 w-4`})})]})]}),(0,$.jsxs)(Pe,{className:`gap-2 pt-1 sm:justify-between`,children:[n?(0,$.jsx)(U,{type:`button`,variant:`ghost`,className:`text-destructive`,onClick:()=>void P(),disabled:k,children:`Desactivar protección`}):(0,$.jsx)(`span`,{}),(0,$.jsxs)(U,{type:`submit`,disabled:k,children:[k&&(0,$.jsx)(J,{className:`mr-2 h-4 w-4 animate-spin`}),n?`Actualizar contraseña`:`Activar protección`]})]})]})]})})]})}var St=()=>{let e=(0,Q.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={opacity:.05,color:`hsl(var(--hive-amber))`},e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(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:t,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[1]=n):n=e[1],n},Ct=e=>{let t=(0,Q.c)(8),{initials:n,size:r}=e,i=r===void 0?`lg`:r,a=i===`sm`?`w-14 h-14`:`w-20 h-20`,o=i===`sm`?`text-lg`:`text-2xl`,s=`relative ${a} flex-shrink-0`,c=`w-full h-full flex items-center justify-center text-white font-black ${o} tracking-tight select-none`,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l={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)`},t[0]=l):l=t[0];let u;t[1]!==n||t[2]!==c?(u=(0,$.jsx)(`div`,{className:c,style:l,children:n}),t[1]=n,t[2]=c,t[3]=u):u=t[3];let d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=(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)`}}),t[4]=d):d=t[4];let f;return t[5]!==s||t[6]!==u?(f=(0,$.jsxs)(`div`,{className:s,children:[u,d]}),t[5]=s,t[6]=u,t[7]=f):f=t[7],f},wt=e=>{let t=(0,Q.c)(4),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(he,{className:`h-3 w-3 flex-shrink-0`,style:{color:`hsl(var(--hive-amber))`,fill:`hsl(var(--hive-amber) / 0.2)`}}),t[0]=r):r=t[0];let i;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(i={color:`hsl(var(--hive-amber) / 0.85)`},t[1]=i):i=t[1];let a;return t[2]===n?a=t[3]:(a=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-2.5`,children:[r,(0,$.jsx)(`p`,{className:`text-[10px] font-black uppercase tracking-[0.18em]`,style:i,children:n})]}),t[2]=n,t[3]=a),a},Tt=()=>{let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:`h-px`,style:{background:`linear-gradient(90deg,transparent,hsl(var(--hive-amber)/0.18),transparent)`}}),e[0]=t):t=e[0],t},Et=e=>{let t=(0,Q.c)(10),{icon:n,label:r,colorVar:i}=e,a=`hsl(var(${i}) / 0.08)`,o=`hsl(var(${i}) / 0.2)`,s=`hsl(var(${i}))`,c;t[0]!==a||t[1]!==o||t[2]!==s?(c={background:a,borderColor:o,color:s},t[0]=a,t[1]=o,t[2]=s,t[3]=c):c=t[3];let l;t[4]===n?l=t[5]:(l=(0,$.jsx)(n,{className:`h-2.5 w-2.5 flex-shrink-0`}),t[4]=n,t[5]=l);let u;return t[6]!==r||t[7]!==c||t[8]!==l?(u=(0,$.jsxs)(`span`,{className:`flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-medium border`,style:c,children:[l,r]}),t[6]=r,t[7]=c,t[8]=l,t[9]=u):u=t[9],u},Dt=e=>{let t=(0,Q.c)(11),{label:n,icon:r,editing:i,children:a}=e,o=i?`hsl(var(--hive-text-muted))`:`hsl(var(--hive-text-placeholder))`,s;t[0]===o?s=t[1]:(s={color:o},t[0]=o,t[1]=s);let c;t[2]===r?c=t[3]:(c=(0,$.jsx)(r,{className:`h-3 w-3 opacity-60`}),t[2]=r,t[3]=c);let l;t[4]!==n||t[5]!==s||t[6]!==c?(l=(0,$.jsxs)(`label`,{className:`flex items-center gap-1.5 text-[10px] font-bold uppercase tracking-widest transition-colors`,style:s,children:[c,n]}),t[4]=n,t[5]=s,t[6]=c,t[7]=l):l=t[7];let u;return t[8]!==a||t[9]!==l?(u=(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[l,a]}),t[8]=a,t[9]=l,t[10]=u):u=t[10],u};function Ot(e){return e.split(` `).map(e=>e[0]).slice(0,2).join(``).toUpperCase()||`?`}function kt(){let{fetchUser:e,saveUser:t,isLoading:n}=ce(),{cronChannels:r,fetchCronChannels:i}=bt(),[a,o]=(0,Z.useState)(!1),[s,l]=(0,Z.useState)({name:``,email:``,occupation:``,language:``,timezone:``,preferred_cron_channel:`auto`,notes:``}),[u,d]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{e().then(e=>{if(!e)return;let t={name:e.name||``,email:e.email||``,occupation:e.occupation||``,language:e.language||``,timezone:e.timezone||``,preferred_cron_channel:e.preferred_cron_channel||`auto`,notes:e.notes||``};l(t),d(t)}).catch(console.error),i()},[e,i]);let f=(e,t)=>l(n=>({...n,[e]:t})),p=()=>{u&&l(u),o(!1)},m=async()=>{let e=s.email.trim().toLowerCase();if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)){q.fire({icon:`error`,title:`Ingresa un correo válido`});return}K.show(`Guardando perfil...`);try{let n={...s,email:e},r=await t(n);l(n),d(n),q.fire({icon:`success`,title:r}),o(!1)}catch(e){q.fire({icon:`error`,title:e instanceof Error?e.message:`Error al guardar`})}finally{K.hide()}},h=r.filter(e=>e.active),g=s.preferred_cron_channel===`auto`?`Auto — detectar mejor canal`:h.find(e=>e.id===s.preferred_cron_channel)?.type??s.preferred_cron_channel,_=Ot(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
|
-
|
|
3
|
-
/* mobile: horizontal compact row */
|
|
4
|
-
flex flex-row items-center gap-4 p-4
|
|
5
|
-
/* tablet: slightly more padding */
|
|
6
|
-
sm:p-5
|
|
7
|
-
/* desktop: vertical centered column */
|
|
8
|
-
lg:flex-col lg:items-center lg:text-center lg:gap-4 lg:p-6`,style:{background:`hsl(220 15% 10% / 0.85)`},children:[(0,$.jsx)(St,{}),(0,$.jsx)(`div`,{className:`absolute -top-16 -left-16 w-48 h-48 rounded-full blur-[80px] pointer-events-none`,style:{background:`hsl(var(--hive-amber)/0.1)`}}),(0,$.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-px lg:hidden`,style:{background:`linear-gradient(90deg,transparent,hsl(var(--hive-amber)/0.3),transparent)`}}),(0,$.jsx)(`div`,{className:`absolute top-0 right-0 bottom-0 w-px hidden lg:block`,style:{background:`linear-gradient(to bottom,transparent,hsl(var(--hive-amber)/0.25),transparent)`}}),(0,$.jsxs)(`div`,{className:`relative w-full hidden lg:flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full animate-pulse`,style:{background:`hsl(var(--hive-amber))`,boxShadow:`0 0 6px hsl(var(--hive-amber))`}}),(0,$.jsx)(`span`,{className:`text-[9px] font-black tracking-[0.25em] uppercase`,style:{color:`hsl(var(--hive-amber)/0.7)`},children:`HIVE OS`})]}),(0,$.jsx)(`span`,{className:`text-[8px] font-mono uppercase tracking-widest`,style:{color:`hsl(var(--hive-text-placeholder))`},children:`v1.0`})]}),(0,$.jsxs)(`div`,{className:`relative flex-shrink-0 lg:mx-auto`,children:[(0,$.jsx)(`div`,{className:`block lg:hidden`,children:(0,$.jsx)(Ct,{initials:_,size:`sm`})}),(0,$.jsx)(`div`,{className:`hidden lg:block`,children:(0,$.jsx)(Ct,{initials:_,size:`lg`})})]}),(0,$.jsxs)(`div`,{className:`relative flex-1 lg:flex-none lg:w-full space-y-1 lg:text-center`,children:[(0,$.jsx)(`h3`,{className:`text-sm sm:text-base font-bold text-white leading-tight`,children:s.name||(0,$.jsx)(`span`,{className:`text-sm font-normal italic`,style:{color:`hsl(var(--hive-text-placeholder))`},children:`Sin nombre`})}),s.occupation&&(0,$.jsx)(`p`,{className:`text-xs`,style:{color:`hsl(var(--hive-text-muted))`},children:s.occupation}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-1 lg:justify-center pt-0.5`,children:[s.language&&(0,$.jsx)(Et,{icon:Ce,label:s.language,colorVar:`--hive-blue`}),s.timezone&&(0,$.jsx)(Et,{icon:De,label:s.timezone,colorVar:`--hive-blue`}),s.preferred_cron_channel!==`auto`&&(0,$.jsx)(Et,{icon:ke,label:s.preferred_cron_channel,colorVar:`--hive-purple`})]})]}),(0,$.jsx)(`div`,{className:`relative hidden sm:grid sm:grid-cols-2 lg:grid-cols-1 lg:w-full gap-x-4 gap-y-2
|
|
9
|
-
sm:mt-0 lg:mt-auto lg:pt-4 lg:border-t`,style:{borderColor:`hsl(var(--hive-border-subtle))`},children:[{icon:be,label:`Agente`,value:`Activo`,colorVar:`--hive-green`},{icon:Ce,label:`Idioma`,value:s.language||`—`,colorVar:`--hive-blue`},{icon:De,label:`Zona`,value:s.timezone||`—`,colorVar:`--hive-blue`},{icon:re,label:`Canal`,value:g.split(`—`)[0].trim(),colorVar:`--hive-amber`}].map(({icon:e,label:t,value:n,colorVar:r})=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(e,{className:`h-3 w-3 flex-shrink-0`,style:{color:`hsl(var(${r}))`}}),(0,$.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest`,style:{color:`hsl(var(--hive-text-placeholder))`},children:t})]}),(0,$.jsx)(`span`,{className:`text-[10px] font-semibold truncate max-w-[90px] text-right`,style:{color:`hsl(var(--hive-surface-foreground)/0.7)`},children:n})]},t))})]}),(0,$.jsxs)(`div`,{className:`relative flex-1 flex flex-col overflow-hidden`,children:[(0,$.jsx)(`div`,{className:`absolute -bottom-16 -right-16 w-48 h-48 rounded-full blur-[80px] pointer-events-none`,style:{background:`hsl(var(--hive-blue)/0.07)`}}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 sm:px-5 pt-4 pb-3 border-b`,style:{borderColor:`hsl(var(--hive-border-subtle))`},children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(`div`,{className:`p-1.5 rounded-lg border flex-shrink-0`,style:{background:`hsl(var(--hive-amber)/0.1)`,borderColor:`hsl(var(--hive-amber)/0.2)`,color:`hsl(var(--hive-amber))`},children:(0,$.jsx)(pe,{className:`h-3.5 w-3.5`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-[11px] font-black uppercase tracking-[0.18em] truncate`,style:{color:`hsl(var(--hive-amber))`},children:`Perfil de usuario`}),(0,$.jsx)(`p`,{className:`text-[9px] mt-0.5 hidden sm:block`,style:{color:`hsl(var(--hive-text-placeholder))`},children:`Configuración personal y preferencias del agente`})]})]}),(0,$.jsxs)(`button`,{onClick:()=>a?p():o(!0),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[11px] font-semibold transition-all duration-200 flex-shrink-0 ml-2`,style:a?{background:`hsl(var(--hive-red-dark)/0.15)`,border:`1px solid hsl(var(--hive-red)/0.3)`,color:`hsl(var(--hive-red))`}:{background:`hsl(var(--hive-glass))`,border:`1px solid hsl(var(--hive-border-base))`,color:`hsl(var(--hive-text-muted))`},children:[a?(0,$.jsx)(we,{className:`h-3 w-3`}):(0,$.jsx)(N,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:a?`Cancelar`:`Editar`})]})]}),(0,$.jsxs)(`div`,{className:`relative flex-1 overflow-y-auto p-4 sm:p-5 space-y-4`,children:[(0,$.jsxs)(`section`,{children:[(0,$.jsx)(wt,{children:`Identidad`}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2.5`,children:[(0,$.jsx)(Dt,{label:`Nombre completo`,icon:pe,editing:a,children:(0,$.jsx)(G,{placeholder:`John Doe`,value:s.name,disabled:!a,onChange:e=>f(`name`,e.target.value),className:`hive-input h-9 text-sm rounded-lg disabled:opacity-50 disabled:cursor-default`})}),(0,$.jsx)(Dt,{label:`Ocupación`,icon:Qe,editing:a,children:(0,$.jsx)(G,{placeholder:`AI Engineer`,value:s.occupation,disabled:!a,onChange:e=>f(`occupation`,e.target.value),className:`hive-input h-9 text-sm rounded-lg disabled:opacity-50 disabled:cursor-default`})}),(0,$.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,$.jsx)(Dt,{label:`Correo propio`,icon:w,editing:a,children:(0,$.jsx)(G,{type:`email`,autoComplete:`email`,placeholder:`tu@correo.com`,maxLength:254,required:!0,value:s.email,disabled:!a,onChange:e=>f(`email`,e.target.value),className:`hive-input h-9 text-sm rounded-lg disabled:opacity-50 disabled:cursor-default`})}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[10px]`,style:{color:`hsl(var(--hive-text-placeholder))`},children:`El coordinador lo usa como destinatario cuando dices «envíame».`})]})]})]}),(0,$.jsx)(Tt,{}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(wt,{children:`Acceso y seguridad`}),(0,$.jsx)(xt,{email:s.email,profileEditing:a})]}),(0,$.jsx)(Tt,{}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(wt,{children:`Localización`}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2.5`,children:[(0,$.jsx)(Dt,{label:`Idioma`,icon:Ce,editing:a,children:(0,$.jsx)(G,{placeholder:`Spanish`,value:s.language,disabled:!a,onChange:e=>f(`language`,e.target.value),className:`hive-input h-9 text-sm rounded-lg disabled:opacity-50 disabled:cursor-default`})}),(0,$.jsx)(Dt,{label:`Zona horaria`,icon:De,editing:a,children:(0,$.jsx)(G,{placeholder:`America/Bogota`,value:s.timezone,disabled:!a,onChange:e=>f(`timezone`,e.target.value),className:`hive-input h-9 text-sm rounded-lg disabled:opacity-50 disabled:cursor-default`})})]})]}),(0,$.jsx)(Tt,{}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(wt,{children:`Notificaciones`}),(0,$.jsx)(Dt,{label:`Canal para Cron Jobs`,icon:ke,editing:a,children:(0,$.jsxs)(Ge,{value:s.preferred_cron_channel,onValueChange:e=>f(`preferred_cron_channel`,e),disabled:!a,children:[(0,$.jsx)(Ue,{className:`hive-select-trigger h-9 text-sm rounded-lg disabled:opacity-50`,children:(0,$.jsx)(We,{})}),(0,$.jsxs)(He,{className:`hive-select-content`,children:[(0,$.jsx)(X,{value:`auto`,className:`hive-select-item text-sm`,children:`Auto — detectar mejor canal`}),h.map(e=>(0,$.jsx)(X,{value:e.id,className:`hive-select-item text-sm`,children:e.id===`webchat`?`Web Chat`:e.id===`telegram`?`Telegram`:e.id===`discord`?`Discord`:e.id===`slack`?`Slack`:e.id===`whatsapp`?`WhatsApp`:e.id},e.id))]})]})})]}),(0,$.jsx)(Tt,{}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(wt,{children:`Contexto para el agente`}),(0,$.jsx)(Ve,{placeholder:`Describe tu perfil, preferencias de trabajo, estilo de comunicación...`,value:s.notes,disabled:!a,onChange:e=>f(`notes`,e.target.value),className:`hive-textarea text-sm rounded-lg min-h-[80px] disabled:opacity-50 disabled:cursor-default`})]})]}),(0,$.jsx)(`div`,{className:`px-4 sm:px-5 py-3 flex items-center justify-end gap-2 border-t`,style:{borderColor:`hsl(var(--hive-border-subtle))`},children:a?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`button`,{onClick:p,className:`flex items-center gap-1.5 h-9 px-3 sm:px-4 rounded-lg text-xs font-semibold transition-all`,style:{background:`transparent`,border:`1px solid hsl(var(--hive-border-base))`,color:`hsl(var(--hive-text-muted))`},children:[(0,$.jsx)(we,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:`Cancelar`})]}),(0,$.jsxs)(`button`,{onClick:m,disabled:n,className:`flex items-center gap-1.5 h-9 px-4 sm:px-5 rounded-lg text-xs font-bold text-white transition-all disabled:opacity-60`,style:{background:`hsl(var(--hive-blue-dark))`,boxShadow:`var(--shadow-btn-primary)`},children:[n?(0,$.jsx)(J,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(c,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:`Guardar cambios`}),(0,$.jsx)(`span`,{className:`sm:hidden`,children:`Guardar`})]})]}):(0,$.jsxs)(`button`,{onClick:()=>o(!0),className:`flex items-center gap-1.5 h-9 px-4 sm:px-5 rounded-lg text-xs font-bold transition-all`,style:{background:`hsl(var(--hive-amber)/0.12)`,border:`1px solid hsl(var(--hive-amber)/0.3)`,color:`hsl(var(--hive-amber))`},children:[(0,$.jsx)(N,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:`Editar perfil`}),(0,$.jsx)(`span`,{className:`sm:hidden`,children:`Editar`})]})}),(0,$.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-px`,style:{background:`linear-gradient(90deg,transparent,hsl(var(--hive-blue)/0.3),transparent)`}})]})]})}var At=e=>{let t=e.toLowerCase();return t.includes(`code`)||t.includes(`program`)?(0,$.jsx)(p,{className:`h-5 w-5`}):t.includes(`research`)||t.includes(`investiga`)?(0,$.jsx)(L,{className:`h-5 w-5`}):t.includes(`write`)||t.includes(`escrib`)?(0,$.jsx)(xe,{className:`h-5 w-5`}):t.includes(`data`)||t.includes(`anal`)||t.includes(`estad`)?(0,$.jsx)($e,{className:`h-5 w-5`}):t.includes(`trans`)||t.includes(`traduc`)?(0,$.jsx)(nt,{className:`h-5 w-5`}):t.includes(`web`)||t.includes(`glob`)||t.includes(`scrape`)?(0,$.jsx)(Ce,{className:`h-5 w-5`}):t.includes(`tool`)||t.includes(`herram`)?(0,$.jsx)(le,{className:`h-5 w-5`}):t.includes(`cpu`)||t.includes(`proc`)?(0,$.jsx)(g,{className:`h-5 w-5`}):(0,$.jsx)(re,{className:`h-5 w-5`})},jt=e=>e?e.split(`,`).filter(Boolean).length:0,Mt=e=>e?e.split(`,`).filter(Boolean).length:0;function Nt(e){let t=(0,Q.c)(50),{skill:n,onClick:r,className:i}=e,a=!!n.active,o=jt(n.tools),s=Mt(n.triggers),c=`hive-card group cursor-pointer transition-all duration-300 hover:scale-[1.02] ${a?`hive-card--active`:`hive-card--disabled`} ${i}`,l=`h-1.5 w-1.5 rounded-full ${a?`bg-blue-400`:`bg-white/20`}`,u;t[0]===l?u=t[1]:(u=(0,$.jsx)(`span`,{className:l}),t[0]=l,t[1]=u);let d=n.category||`GENERAL`,f;t[2]!==u||t[3]!==d?(f=(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[9px] font-black uppercase tracking-widest text-white/30 bg-white/5 border border-white/5 rounded-full px-2.5 py-1`,children:[u,d]}),t[2]=u,t[3]=d,t[4]=f):f=t[4];let p;t[5]===a?p=t[6]:(p=a&&(0,$.jsxs)(`span`,{className:`flex h-2 w-2`,children:[(0,$.jsx)(`span`,{className:`animate-ping absolute h-2 w-2 rounded-full bg-blue-400 opacity-40`}),(0,$.jsx)(`span`,{className:`relative h-2 w-2 rounded-full bg-blue-500`})]}),t[5]=a,t[6]=p);let m;t[7]!==f||t[8]!==p?(m=(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[f,p]}),t[7]=f,t[8]=p,t[9]=m):m=t[9];let h=`shrink-0 h-12 w-12 rounded-xl flex items-center justify-center border transition-all duration-300 ${a?`bg-blue-500/10 border-blue-500/30 text-blue-400 shadow-[0_0_12px_hsl(217_91%_60%/0.2)]`:`bg-white/5 border-white/10 text-white/25`}`,g;t[10]===n.name?g=t[11]:(g=At(n.name),t[10]=n.name,t[11]=g);let _;t[12]!==h||t[13]!==g?(_=(0,$.jsx)(`div`,{className:h,children:g}),t[12]=h,t[13]=g,t[14]=_):_=t[14];let v=`text-sm font-black uppercase tracking-tight line-clamp-1 transition-colors ${a?`text-white group-hover:text-blue-400`:`text-white/40`}`,y;t[15]!==n.name||t[16]!==v?(y=(0,$.jsx)(`h3`,{className:v,children:n.name}),t[15]=n.name,t[16]=v,t[17]=y):y=t[17];let b;t[18]===n.body?b=t[19]:(b=n.body?.substring(0,90)||`Sin descripción`,t[18]=n.body,t[19]=b);let x;t[20]===b?x=t[21]:(x=(0,$.jsx)(`p`,{className:`text-[11px] text-white/30 leading-relaxed line-clamp-2 mt-1`,children:b}),t[20]=b,t[21]=x);let S;t[22]!==y||t[23]!==x?(S=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[y,x]}),t[22]=y,t[23]=x,t[24]=S):S=t[24];let C;t[25]!==_||t[26]!==S?(C=(0,$.jsxs)(`div`,{className:`flex items-start gap-4`,children:[_,S]}),t[25]=_,t[26]=S,t[27]=C):C=t[27];let w=n.version??1,T;t[28]===w?T=t[29]:(T=(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[9px] font-black tracking-widest uppercase text-amber-400/70 bg-amber-500/5 border border-amber-500/10 rounded px-2 py-0.5`,children:[`v`,w]}),t[28]=w,t[29]=T);let E;t[30]===o?E=t[31]:(E=o>0&&(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[9px] font-black tracking-widest uppercase text-cyan-400/70 bg-cyan-500/5 border border-cyan-500/10 rounded px-2 py-0.5`,children:[o,` TOOLS`]}),t[30]=o,t[31]=E);let D;t[32]===s?D=t[33]:(D=s>0&&(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[9px] font-black tracking-widest uppercase text-purple-400/70 bg-purple-500/5 border border-purple-500/10 rounded px-2 py-0.5`,children:[s,` TRIGGERS`]}),t[32]=s,t[33]=D);let O;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(`div`,{className:`ml-auto opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,$.jsx)(B,{className:`h-3 w-3 text-blue-400`})}),t[34]=O):O=t[34];let k;t[35]!==T||t[36]!==E||t[37]!==D?(k=(0,$.jsxs)(`div`,{className:`pt-3 border-t border-white/5 flex items-center gap-2 flex-wrap`,children:[T,E,D,O]}),t[35]=T,t[36]=E,t[37]=D,t[38]=k):k=t[38];let A;t[39]!==C||t[40]!==k||t[41]!==m?(A=(0,$.jsxs)(`div`,{className:`hive-card-body flex flex-col gap-4`,children:[m,C,k]}),t[39]=C,t[40]=k,t[41]=m,t[42]=A):A=t[42];let j=`hive-strip--bottom ${a?`bg-blue-500`:`bg-white/5`}`,M;t[43]===j?M=t[44]:(M=(0,$.jsx)(`div`,{className:j}),t[43]=j,t[44]=M);let N;return t[45]!==r||t[46]!==c||t[47]!==A||t[48]!==M?(N=(0,$.jsxs)(`div`,{onClick:r,className:c,children:[A,M]}),t[45]=r,t[46]=c,t[47]=A,t[48]=M,t[49]=N):N=t[49],N}var Pt={name:``,body:``,tools:``,triggers:``,category:``,version:1,active:!0};function Ft(){let{skills:e,isLoading:t,fetchSkills:n,toggleSkill:r,updateSkill:i}=Ae(),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(`TODOS`),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(Pt),[h,_]=(0,Z.useState)(null),[v,y]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(null),D=(0,Z.useRef)(null),O=()=>{let e=D.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)};(0,Z.useEffect)(()=>{if(!l&&!d)return;let e=setTimeout(O,0);return()=>clearTimeout(e)},[l,d,p.body]),(0,Z.useEffect)(()=>{n()},[n]),(0,Z.useEffect)(()=>{if(e.length>0)return;let t=!1;return W(`/api/system/runtime`,{showError:!1}).then(e=>{t||E(e)}).catch(()=>{t||E(null)}),()=>{t=!0}},[e.length]);let k=(0,Z.useMemo)(()=>{let t=new Set(e.map(e=>(e.category||`GENERAL`).toUpperCase()));return[`TODOS`,...Array.from(t).sort()]},[e]),A=(0,Z.useMemo)(()=>{let t=a.toLowerCase();return e.filter(e=>{let n=!t||e.name.toLowerCase().includes(t)||(e.category||``).toLowerCase().includes(t)||(e.body||``).toLowerCase().includes(t),r=s===`TODOS`||(e.category||`GENERAL`).toUpperCase()===s;return n&&r})},[e,a,s]),j=e.filter(e=>e.active).length,M=async(e,t)=>{if(!h){_(e);try{await r(e,t),await n(),q.fire({icon:`success`,title:t?`Skill habilitado`:`Skill deshabilitado`})}catch{q.fire({icon:`error`,title:`Error al cambiar estado del skill`})}finally{_(null)}}},N=async()=>{if(l){w(!0);try{await W(`/api/skills/${l.id}`,{method:`DELETE`,showError:!0}),q.fire({icon:`success`,title:`Skill eliminado`}),n(),u(null)}catch{q.fire({icon:`error`,title:`Error al eliminar skill`})}finally{w(!1),S(!1)}}},ee=e=>{f(!1),S(!1),u(e),m({name:e.name,body:e.body||``,tools:e.tools||``,triggers:e.triggers||``,category:e.category||``,version:Number(e.version)||1,active:!!e.active})},F=()=>{u(null),S(!1),m(Pt),f(!0)},I=()=>{u(null),f(!1),S(!1)},R=async()=>{y(!0),K.show(d?`Creando skill...`:`Guardando skill...`);try{d?(await W(`/api/skills`,{method:`POST`,body:p,showError:!0}),q.fire({icon:`success`,title:`Skill creado correctamente`})):l&&(await i(l.id,p),q.fire({icon:`success`,title:`Skill actualizado correctamente`})),n(),I()}catch{q.fire({icon:`error`,title:d?`Error al crear skill`:`Error al actualizar skill`})}finally{y(!1),K.hide()}},z=!!l||d;return t&&e.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-20 space-y-4`,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(J,{className:`h-10 w-10 animate-spin text-primary/40`}),(0,$.jsx)(B,{className:`h-4 w-4 text-primary absolute -top-1 -right-1 animate-pulse`})]}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground animate-pulse`,children:`Cargando habilidades del sistema...`})]}):(0,$.jsxs)(`div`,{className:`space-y-6 animate-in fade-in duration-500`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-start justify-between gap-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[(0,$.jsx)(fe,{className:`h-4 w-4 text-blue-400`}),(0,$.jsx)(`h3`,{className:`hive-title-section !text-lg`,children:`Habilidades del Sistema`}),(0,$.jsxs)(`span`,{className:`hive-tag bg-blue-500/10 text-blue-400 border-blue-500/20`,children:[j,` ACTIVAS`]}),(0,$.jsxs)(`span`,{className:`hive-tag bg-white/5 text-white/30 border-white/5`,children:[e.length,` TOTAL`]})]}),(0,$.jsx)(`p`,{className:`hive-subtitle !mt-0 !text-xs`,children:`Gestiona los módulos cognitivos que otorgan capacidades autónomas a tus agentes.`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(L,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-white/20`}),(0,$.jsx)(G,{value:a,onChange:e=>o(e.target.value),placeholder:`Buscar habilidad...`,className:`pl-8 pr-8 h-8 w-52 bg-white/5 border-white/10 text-white text-xs placeholder:text-white/20 focus-visible:ring-blue-500/30`}),a&&(0,$.jsx)(`button`,{type:`button`,"aria-label":`Limpiar búsqueda`,onClick:()=>o(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-white/20 hover:text-white/60 transition-colors`,children:(0,$.jsx)(we,{className:`h-3 w-3`})})]}),(0,$.jsxs)(U,{onClick:F,className:`h-8 bg-blue-600 hover:bg-blue-500 text-white font-black text-[10px] tracking-widest uppercase px-4 shadow-btn-primary`,children:[(0,$.jsx)(P,{className:`h-3.5 w-3.5 mr-1.5`}),`Nueva Habilidad`]})]})]}),e.length>0&&(0,$.jsx)(`div`,{className:`flex items-center gap-2 overflow-x-auto pb-1 scrollbar-none`,children:k.map(t=>{let n=t===`TODOS`?e.length:e.filter(e=>(e.category||`GENERAL`).toUpperCase()===t).length,r=s===t;return(0,$.jsxs)(`button`,{onClick:()=>c(t),className:`shrink-0 inline-flex items-center gap-1.5 text-[9px] font-black uppercase tracking-widest px-3 py-1.5 rounded-full border transition-all duration-200 ${r?`bg-blue-500/15 border-blue-500/40 text-blue-400 shadow-[0_0_8px_hsl(217_91%_60%/0.15)]`:`bg-white/5 border-white/10 text-white/30 hover:text-white/60 hover:border-white/20`}`,children:[(0,$.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full ${r?`bg-blue-400`:`bg-white/20`}`}),t,(0,$.jsxs)(`span`,{className:`text-[8px] ${r?`text-blue-300/70`:`text-white/20`}`,children:[`(`,n,`)`]})]},t)})}),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)(fe,{className:`h-8 w-8 text-white/20`})}),(0,$.jsx)(`p`,{className:`hive-title-section text-center mb-2`,children:`No se detectan habilidades`}),(0,$.jsx)(`p`,{className:`text-xs text-white/40 mb-8 max-w-[300px] mx-auto leading-relaxed text-center`,children:`El repositorio de habilidades está vacío. Revisa el estado del gateway antes de crear una habilidad.`}),T&&(0,$.jsxs)(`div`,{className:`mb-8 max-w-xl rounded-lg border border-amber-500/20 bg-amber-500/5 px-4 py-3 text-left text-[11px] text-amber-100/70`,children:[(0,$.jsxs)(`p`,{className:`font-semibold text-amber-200`,children:[`Diagnóstico del runtime `,T.version]}),(0,$.jsxs)(`p`,{className:`mt-1 font-mono break-all`,children:[`HIVE_HOME: `,T.hiveHome]}),(0,$.jsxs)(`p`,{className:`mt-1`,children:[T.skills.total,` skills detectadas, `,T.skills.active,` activas.`,!T.healthy&&` Faltan dependencias del catálogo A2UI.`]}),(0,$.jsxs)(`p`,{className:`mt-1`,children:[`Requeridas ausentes/inactivas: `,T.skills.required.reduce((e,t)=>((!t.present||!t.active)&&e.push(t.name),e),[]).join(`, `)||`ninguna`]})]}),(0,$.jsxs)(U,{onClick:F,className:`hive-btn hive-btn--primary px-8`,children:[(0,$.jsx)(P,{className:`h-4 w-4 mr-2`}),`Crear Habilidad`]})]})}):A.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 space-y-3 text-center`,children:[(0,$.jsx)(L,{className:`h-8 w-8 text-white/10`}),(0,$.jsx)(`p`,{className:`text-sm font-bold text-white/30 uppercase tracking-widest`,children:`Sin resultados`}),(0,$.jsxs)(`p`,{className:`text-xs text-white/20`,children:[`No hay habilidades que coincidan con “`,a,`”`,s!==`TODOS`&&` en la categoría ${s}`,`.`]}),(0,$.jsx)(`button`,{onClick:()=>{o(``),c(`TODOS`)},className:`text-[10px] font-black uppercase tracking-widest text-blue-400/60 hover:text-blue-400 transition-colors mt-2`,children:`Limpiar filtros`})]}):(0,$.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-5`,children:A.map(e=>(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(Nt,{skill:e,onClick:()=>ee(e)}),(0,$.jsxs)(`div`,{className:`absolute top-5 right-5 z-20 pointer-events-auto flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[9px] font-black tracking-widest ${e.active?`text-blue-400`:`text-white/20`}`,children:e.active?`ON`:`OFF`}),(0,$.jsx)(Ke,{checked:!!e.active,disabled:h===e.id,onClick:e=>e.stopPropagation(),onCheckedChange:t=>M(e.id,t),className:`scale-75 data-[state=checked]:bg-blue-500`})]})]},e.id))}),(0,$.jsx)(Be,{open:z,onOpenChange:e=>{e||I()},children:(0,$.jsxs)(Re,{className:`max-w-3xl bg-zinc-950 border-white/10 text-white p-0 overflow-hidden shadow-2xl`,children:[(0,$.jsx)(`div`,{className:`p-6 border-b border-white/5 bg-white/[0.03]`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`h-10 w-10 rounded-lg flex items-center justify-center border ${d?`bg-blue-500/10 border-blue-500/20 text-blue-400`:`bg-white/5 border-white/10 text-white/60`}`,children:d?(0,$.jsx)(P,{className:`h-5 w-5`}):(0,$.jsx)(g,{className:`h-5 w-5`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(ze,{className:`text-sm font-black text-white uppercase tracking-tight`,children:d?`Nueva Habilidad`:`Propiedades del Nodo`}),(0,$.jsx)(Ie,{className:`text-[10px] text-white/30`,children:d?`Define las propiedades del nuevo módulo cognitivo.`:`Editor granular de capacidades cognitivas y herramientas vinculadas.`})]})]}),!d&&(0,$.jsx)(U,{variant:`ghost`,size:`icon`,onClick:()=>S(!0),disabled:C||x,className:`text-zinc-600 hover:text-red-400 hover:bg-red-400/10 h-8 w-8 transition-colors shrink-0`,title:`Eliminar Skill`,children:(0,$.jsx)(te,{className:`h-4 w-4`})})]})}),x&&(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-black`,children:l?.name}),`? Esta acción no se puede deshacer.`]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 justify-end`,children:[(0,$.jsx)(U,{variant:`ghost`,size:`sm`,onClick:()=>S(!1),disabled:C,className:`h-7 px-3 text-[10px] font-black uppercase tracking-wider text-zinc-400 hover:text-white`,children:`Cancelar`}),(0,$.jsx)(U,{size:`sm`,onClick:N,disabled:C,className:`h-7 px-3 text-[10px] font-black uppercase tracking-wider bg-red-600 hover:bg-red-500 text-white`,children:C?(0,$.jsx)(J,{className:`h-3 w-3 animate-spin`}):`Sí, eliminar`})]})]}),(0,$.jsxs)(`div`,{className:`p-6 space-y-7 max-h-[65vh] overflow-y-auto custom-scrollbar`,children:[(0,$.jsxs)(`section`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`h-px flex-1 bg-white/5`}),(0,$.jsx)(`span`,{className:`text-[9px] font-black tracking-widest text-white/20 uppercase px-2`,children:`Información General`}),(0,$.jsx)(`div`,{className:`h-px flex-1 bg-white/5`})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(Y,{htmlFor:`skill-name`,className:`text-[10px] uppercase tracking-widest text-white/40`,children:`Nombre del Nodo`}),(0,$.jsx)(G,{id:`skill-name`,value:p.name,onChange:e=>m(t=>({...t,name:e.target.value})),className:`bg-white/5 border-white/10 focus-visible:ring-blue-500/30 text-white font-medium`,placeholder:`Ej: a2ui_dashboard`})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(Y,{htmlFor:`skill-category`,className:`text-[10px] uppercase tracking-widest text-white/40`,children:`Categoría Funcional`}),(0,$.jsx)(G,{id:`skill-category`,value:p.category,onChange:e=>m(t=>({...t,category:e.target.value})),className:`bg-white/5 border-white/10 focus-visible:ring-blue-500/30 text-white/70`,placeholder:`Ej: visualización, análisis...`})]})]})]}),(0,$.jsxs)(`section`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`h-px flex-1 bg-white/5`}),(0,$.jsx)(`span`,{className:`text-[9px] font-black tracking-widest text-white/20 uppercase px-2`,children:`Capacidades y Activación`}),(0,$.jsx)(`div`,{className:`h-px flex-1 bg-white/5`})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(Y,{htmlFor:`skill-tools`,className:`text-[10px] uppercase tracking-widest text-white/40`,children:[(0,$.jsx)(`span`,{className:`text-cyan-400/60`,children:`Herramientas Vinculadas`}),` (CSV)`]}),(0,$.jsx)(G,{id:`skill-tools`,value:p.tools,onChange:e=>m(t=>({...t,tools:e.target.value})),className:`bg-white/5 border-white/10 focus-visible:ring-cyan-500/30 text-white/80 font-mono text-[11px]`,placeholder:`tool1, tool2, tool3...`})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(Y,{htmlFor:`skill-triggers`,className:`text-[10px] uppercase tracking-widest text-white/40`,children:[(0,$.jsx)(`span`,{className:`text-purple-400/60`,children:`Triggers`}),` de Activación (CSV)`]}),(0,$.jsx)(G,{id:`skill-triggers`,value:p.triggers,onChange:e=>m(t=>({...t,triggers:e.target.value})),className:`bg-white/5 border-white/10 focus-visible:ring-purple-500/30 text-white/80 font-mono text-[11px]`,placeholder:`mostrar panel, dashboard...`})]})]})]}),(0,$.jsxs)(`section`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`h-px flex-1 bg-white/5`}),(0,$.jsx)(`span`,{className:`text-[9px] font-black tracking-widest text-white/20 uppercase px-2`,children:`Cuerpo / Lógica del Nodo`}),(0,$.jsx)(`div`,{className:`h-px flex-1 bg-white/5`})]}),(0,$.jsx)(Ve,{ref:D,value:p.body,onChange:e=>{m(t=>({...t,body:e.target.value})),O()},className:`min-h-[140px] resize-none bg-white/5 border-white/10 focus-visible:ring-blue-500/30 text-white/80 text-sm overflow-hidden font-sans leading-relaxed p-4`,placeholder:`Instrucciones detalladas y lógica de ejecución del módulo cognitivo...`})]}),(0,$.jsxs)(`section`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6 pt-4 border-t border-white/5`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(Y,{htmlFor:`skill-version`,className:`text-[10px] uppercase tracking-widest text-white/40`,children:[(0,$.jsx)(`span`,{className:`text-amber-400/60`,children:`Versión`}),` del Skill`]}),(0,$.jsx)(G,{id:`skill-version`,type:`number`,step:`0.1`,min:`0.1`,value:p.version,onChange:e=>m(t=>({...t,version:Number(e.target.value)})),className:`bg-white/5 border-white/10 focus-visible:ring-amber-500/20 text-white w-32`})]}),(0,$.jsxs)(`div`,{className:`flex flex-col justify-center space-y-2`,children:[(0,$.jsx)(Y,{className:`text-[10px] uppercase tracking-widest text-white/40`,children:`Estado del Nodo`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3 bg-white/5 p-3 rounded-xl border border-white/10 w-fit`,children:[(0,$.jsx)(`div`,{className:`h-2 w-2 rounded-full transition-colors ${p.active?`bg-blue-500 shadow-[0_0_6px_hsl(217_91%_60%/0.8)] animate-pulse`:`bg-white/20`}`}),(0,$.jsx)(`span`,{className:`text-[9px] font-black tracking-widest ${p.active?`text-white`:`text-white/30`}`,children:p.active?`OPERATIVO / ACTIVO`:`FUERA DE LÍNEA / INACTIVO`}),(0,$.jsx)(Ke,{checked:p.active,onCheckedChange:e=>m(t=>({...t,active:e})),className:`data-[state=checked]:bg-blue-500`})]})]})]})]}),(0,$.jsxs)(Pe,{className:`p-5 bg-white/[0.02] flex items-center justify-between gap-3 border-t border-white/5 sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[9px] font-black tracking-widest text-white/15 uppercase`,children:[(0,$.jsx)(b,{className:`h-3 w-3`}),d?`Nueva habilidad`:`ID: ${l?.id?.substring(0,8)}...`]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(U,{variant:`ghost`,className:`text-[10px] font-black tracking-widest hover:bg-white/5 hover:text-white text-white/30 uppercase`,onClick:I,children:`Cancelar`}),(0,$.jsx)(U,{className:`bg-blue-600 hover:bg-blue-500 text-white font-black text-[10px] tracking-widest px-6 rounded-lg shadow-btn-primary uppercase`,onClick:R,disabled:v||!p.name.trim(),children:v?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(J,{className:`h-3 w-3 animate-spin mr-2`}),`PROCESANDO...`]}):d?`Crear Habilidad`:`Sincronizar Propiedades`})]})]})]})})]})}var It=()=>{let e=(0,Q.c)(15),{notes:t,isLoading:n,fetchNotes:r}=bt(),i,a;e[0]===r?(i=e[1],a=e[2]):(i=()=>{r()},a=[r],e[0]=r,e[1]=i,e[2]=a),(0,Z.useEffect)(i,a);let o;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`p-2 rounded-xl bg-primary/10 text-primary`,children:(0,$.jsx)(se,{className:`w-5 h-5`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(qe,{className:`text-xl font-bold tracking-tight`,children:`Notas`}),(0,$.jsx)(Xe,{children:`Scratchpad del agente`})]})]}),e[3]=o):o=e[3];let s;e[4]===n?s=e[5]:(s=n&&(0,$.jsx)(J,{className:`w-4 h-4 animate-spin text-muted-foreground`}),e[4]=n,e[5]=s);let c;e[6]===s?c=e[7]:(c=(0,$.jsx)(Je,{className:`pb-2`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[o,s]})}),e[6]=s,e[7]=c);let l;e[8]===t?l=e[9]:(l=t.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-[250px] text-muted-foreground space-y-2`,children:[(0,$.jsx)(se,{className:`w-12 h-12 opacity-20`}),(0,$.jsx)(`p`,{className:`text-sm`,children:`No hay notas guardadas`}),(0,$.jsx)(`p`,{className:`text-[10px] opacity-70`,children:`El agente guardará notas con save_note`})]}):t.map(Lt),e[8]=t,e[9]=l);let u;e[10]===l?u=e[11]:(u=(0,$.jsx)(Ye,{children:(0,$.jsx)(Ne,{className:`h-[350px] pr-4`,children:(0,$.jsx)(`div`,{className:`space-y-4`,children:l})})}),e[10]=l,e[11]=u);let d;return e[12]!==c||e[13]!==u?(d=(0,$.jsxs)(Ze,{className:`border-none bg-background/50 backdrop-blur-xl shadow-2xl overflow-hidden group border border-white/10`,children:[c,u]}),e[12]=c,e[13]=u,e[14]=d):d=e[14],d};function Lt(e){return(0,$.jsxs)(`div`,{className:`p-4 rounded-2xl border border-white/5 bg-card/40 hover:bg-card/60 transition-all duration-300 relative overflow-hidden`,children:[(0,$.jsx)(`h4`,{className:`font-semibold text-sm mb-1.5 line-clamp-1`,children:e.key}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground line-clamp-3 leading-relaxed`,children:e.value}),(0,$.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,$.jsx)(Me,{variant:`secondary`,className:`text-[10px] px-2 py-0.5 bg-primary/10 text-primary border-none font-medium font-mono truncate max-w-[120px]`,children:e.thread_id.slice(-8)}),(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground font-mono`,children:new Date(e.updated_at*1e3).toLocaleDateString()})]})]},e.id)}function Rt(e){if(!e)return`—`;try{return new Date(e).toLocaleString([],{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}catch{return e}}function zt(e){let t=(0,Q.c)(4),{status:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={active:{label:`Activa`,className:`bg-green-500/10 text-green-400 border-green-500/20`},paused:{label:`Pausada`,className:`bg-yellow-500/10 text-yellow-400 border-yellow-500/20`},completed:{label:`Completada`,className:`bg-blue-500/10 text-blue-400 border-blue-500/20`},failed:{label:`Fallida`,className:`bg-red-500/10 text-red-400 border-red-500/20`},cancelled:{label:`Cancelada`,className:`bg-muted/30 text-muted-foreground border-white/10`}},t[0]=r):r=t[0];let i=r,{label:a,className:o}=i[n]??i.cancelled,s=`inline-flex items-center text-[9px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded-full border ${o}`,c;return t[1]!==a||t[2]!==s?(c=(0,$.jsx)(`span`,{className:s,children:a}),t[1]=a,t[2]=s,t[3]=c):c=t[3],c}function Bt(e){let t=(0,Q.c)(6),{type:n}=e,r=n===`recurring`,i=`inline-flex items-center gap-1 text-[9px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded-full border ${r?`bg-violet-500/10 text-violet-400 border-violet-500/20`:`bg-teal-500/10 text-teal-400 border-teal-500/20`}`,a;t[0]===r?a=t[1]:(a=r?(0,$.jsx)(F,{className:`w-2.5 h-2.5`}):(0,$.jsx)(s,{className:`w-2.5 h-2.5`}),t[0]=r,t[1]=a);let o=r?`Recurrente`:`Una vez`,c;return t[2]!==i||t[3]!==a||t[4]!==o?(c=(0,$.jsxs)(`span`,{className:i,children:[a,o]}),t[2]=i,t[3]=a,t[4]=o,t[5]=c):c=t[5],c}function Vt(e){let t=(0,Q.c)(5),{channel:n}=e;if(!n||n===`system`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`inline-flex items-center gap-1 text-[9px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded-full bg-muted/30 text-muted-foreground border border-white/10`,children:`System`}),t[0]=e):e=t[0],e}if(n===`webchat`){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[9px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded-full bg-blue-500/10 text-blue-400 border border-blue-500/20`,children:[(0,$.jsx)(it,{className:`w-2.5 h-2.5`}),`Web`]}),t[1]=e):e=t[1],e}if(n===`telegram`){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[9px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded-full bg-sky-500/10 text-sky-400 border border-sky-500/20`,children:[(0,$.jsx)(R,{className:`w-2.5 h-2.5`}),`Telegram`]}),t[2]=e):e=t[2],e}let r;return t[3]===n?r=t[4]:(r=(0,$.jsx)(`span`,{className:`inline-flex items-center gap-1 text-[9px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded-full bg-muted/30 text-muted-foreground border border-white/10`,children:n}),t[3]=n,t[4]=r),r}function Ht(e){let t=(0,Q.c)(3),{status:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={running:`bg-blue-400 animate-pulse`,success:`bg-green-400`,failed:`bg-red-400`,timeout:`bg-amber-400`},t[0]=r):r=t[0];let i=`inline-block w-1.5 h-1.5 rounded-full ${r[n]??`bg-muted-foreground`}`,a;return t[1]===i?a=t[2]:(a=(0,$.jsx)(`span`,{className:i}),t[1]=i,t[2]=a),a}function Ut(e,t){let n=e===`telegram`?`Telegram`:e===`webchat`?`Web Chat`:e;return e===t?`${n} (recomendado)`:n}function Wt(e){let t=(0,Q.c)(6),{history:n}=e;if(!n){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground px-1`,children:`Cargando historial…`}),t[0]=e):e=t[0],e}if(n.length===0){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground px-1`,children:`Sin ejecuciones registradas.`}),t[1]=e):e=t[1],e}let r;t[2]===n?r=t[3]:(r=n.map(Gt),t[2]=n,t[3]=r);let i;return t[4]===r?i=t[5]:(i=(0,$.jsx)(`div`,{className:`mt-2 space-y-1`,children:r}),t[4]=r,t[5]=i),i}function Gt(e){return(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,$.jsx)(Ht,{status:e.status}),(0,$.jsx)(`span`,{className:`font-mono`,children:Rt(e.started_at)}),e.duration_ms!=null&&(0,$.jsxs)(`span`,{className:`text-primary/70`,children:[e.duration_ms,`ms`]}),e.error_message&&(0,$.jsx)(`span`,{className:`text-red-400 truncate max-w-[160px]`,children:e.error_message})]},e.id)}function Kt(e){let t=(0,Q.c)(96),{task:n,onPause:r,onResume:i,onDelete:a,onTrigger:c,onLoadHistory:f,history:p}=e,[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(!1),v=n.status===`active`,b=n.status===`active`||n.status===`paused`,x;t[0]!==p||t[1]!==f||t[2]!==m||t[3]!==n.id?(x=function(){!m&&!p&&f(n.id),h(qt)},t[0]=p,t[1]=f,t[2]=m,t[3]=n.id,t[4]=x):x=t[4];let S=x,C;t[5]!==g||t[6]!==a||t[7]!==n.id?(C=function(){g?a(n.id):(_(!0),setTimeout(()=>_(!1),3e3))},t[5]=g,t[6]=a,t[7]=n.id,t[8]=C):C=t[8];let w=C,T;t[9]===n.name?T=t[10]:(T=(0,$.jsx)(`h4`,{className:`font-semibold text-sm truncate`,children:n.name}),t[9]=n.name,t[10]=T);let E;t[11]===n.description?E=t[12]:(E=n.description&&(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground truncate mt-0.5`,children:n.description}),t[11]=n.description,t[12]=E);let D;t[13]!==T||t[14]!==E?(D=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[T,E]}),t[13]=T,t[14]=E,t[15]=D):D=t[15];let O;t[16]===n.status?O=t[17]:(O=(0,$.jsx)(`div`,{className:`flex items-center gap-1 shrink-0`,children:(0,$.jsx)(zt,{status:n.status})}),t[16]=n.status,t[17]=O);let k;t[18]!==D||t[19]!==O?(k=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2 mb-2`,children:[D,O]}),t[18]=D,t[19]=O,t[20]=k):k=t[20];let A;t[21]===n.task_type?A=t[22]:(A=(0,$.jsx)(Bt,{type:n.task_type}),t[21]=n.task_type,t[22]=A);let j;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(s,{className:`w-3 h-3`}),t[23]=j):j=t[23];let N;t[24]!==n.cron_expression||t[25]!==n.fire_at||t[26]!==n.task_type?(N=n.task_type===`recurring`?n.cron_expression??`—`:n.fire_at?Rt(n.fire_at):`—`,t[24]=n.cron_expression,t[25]=n.fire_at,t[26]=n.task_type,t[27]=N):N=t[27];let P;t[28]===N?P=t[29]:(P=(0,$.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] text-primary font-bold uppercase tracking-wider bg-primary/5 px-2 py-0.5 rounded-full`,children:[j,N]}),t[28]=N,t[29]=P);let F;t[30]===n.channel?F=t[31]:(F=(0,$.jsx)(Vt,{channel:n.channel}),t[30]=n.channel,t[31]=F);let I;t[32]!==P||t[33]!==F||t[34]!==A?(I=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap mb-2`,children:[A,P,F]}),t[32]=P,t[33]=F,t[34]=A,t[35]=I):I=t[35];let L;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(o,{className:`w-3 h-3`}),t[36]=L):L=t[36];let R;t[37]===n.run_count?R=t[38]:(R=(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[L,n.run_count,` runs`]}),t[37]=n.run_count,t[38]=R);let z;t[39]===n.error_count?z=t[40]:(z=n.error_count>0&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-red-400`,children:[(0,$.jsx)(d,{className:`w-3 h-3`}),n.error_count,` errores`]}),t[39]=n.error_count,t[40]=z);let B;t[41]===n.timezone?B=t[42]:(B=n.timezone&&n.timezone!==`UTC`&&(0,$.jsx)(`span`,{className:`font-mono`,children:n.timezone}),t[41]=n.timezone,t[42]=B);let V;t[43]!==R||t[44]!==z||t[45]!==B?(V=(0,$.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px] text-muted-foreground mb-2`,children:[R,z,B]}),t[43]=R,t[44]=z,t[45]=B,t[46]=V):V=t[46];let ne;t[47]===n.last_run_at?ne=t[48]:(ne=n.last_run_at&&(0,$.jsxs)(`span`,{children:[`Último: `,Rt(n.last_run_at)]}),t[47]=n.last_run_at,t[48]=ne);let ie;t[49]!==n.next_run_at||t[50]!==n.status?(ie=n.next_run_at&&n.status===`active`&&(0,$.jsxs)(`span`,{className:`text-primary/70`,children:[`Próximo: `,Rt(n.next_run_at)]}),t[49]=n.next_run_at,t[50]=n.status,t[51]=ie):ie=t[51];let ae;t[52]!==ne||t[53]!==ie?(ae=(0,$.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px] text-muted-foreground mb-3`,children:[ne,ie]}),t[52]=ne,t[53]=ie,t[54]=ae):ae=t[54];let oe;t[55]===n.last_error?oe=t[56]:(oe=n.last_error&&(0,$.jsx)(`div`,{className:`mb-2 text-[10px] text-red-400 bg-red-500/5 border border-red-500/20 rounded-lg px-2 py-1 truncate`,children:n.last_error}),t[55]=n.last_error,t[56]=oe);let se;t[57]!==b||t[58]!==v||t[59]!==r||t[60]!==i||t[61]!==n.id?(se=b&&(v?(0,$.jsxs)(U,{size:`sm`,variant:`outline`,className:`h-6 text-[10px] px-2 border-white/10 hover:bg-yellow-500/10 hover:text-yellow-400 hover:border-yellow-500/20`,onClick:()=>r(n.id),children:[(0,$.jsx)(M,{className:`w-3 h-3 mr-1`}),`Pausar`]}):(0,$.jsxs)(U,{size:`sm`,variant:`outline`,className:`h-6 text-[10px] px-2 border-white/10 hover:bg-green-500/10 hover:text-green-400 hover:border-green-500/20`,onClick:()=>i(n.id),children:[(0,$.jsx)(ee,{className:`w-3 h-3 mr-1`}),`Reanudar`]})),t[57]=b,t[58]=v,t[59]=r,t[60]=i,t[61]=n.id,t[62]=se):se=t[62];let H;t[63]!==v||t[64]!==c||t[65]!==n.id?(H=v&&(0,$.jsxs)(U,{size:`sm`,variant:`outline`,className:`h-6 text-[10px] px-2 border-white/10 hover:bg-primary/10 hover:text-primary hover:border-primary/20`,onClick:()=>c(n.id),title:`Ejecutar ahora (sin afectar el schedule)`,children:[(0,$.jsx)(re,{className:`w-3 h-3 mr-1`}),`Ejecutar`]}),t[63]=v,t[64]=c,t[65]=n.id,t[66]=H):H=t[66];let ce;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,$.jsx)(y,{className:`w-3 h-3 mr-1`}),t[67]=ce):ce=t[67];let le;t[68]===m?le=t[69]:(le=m?(0,$.jsx)(u,{className:`w-3 h-3 ml-1`}):(0,$.jsx)(l,{className:`w-3 h-3 ml-1`}),t[68]=m,t[69]=le);let W;t[70]!==S||t[71]!==le?(W=(0,$.jsxs)(U,{size:`sm`,variant:`ghost`,className:`h-6 text-[10px] px-2 text-muted-foreground hover:text-foreground`,onClick:S,children:[ce,`Historial`,le]}),t[70]=S,t[71]=le,t[72]=W):W=t[72];let ue=`h-6 text-[10px] px-2 ml-auto ${g?`text-red-400 bg-red-500/10 border border-red-500/20`:`text-muted-foreground hover:text-red-400`}`,de=g?`Confirmar eliminación`:`Eliminar tarea`,G;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,$.jsx)(te,{className:`w-3 h-3 mr-1`}),t[73]=G):G=t[73];let fe=g?`Confirmar`:`Eliminar`,pe;t[74]!==w||t[75]!==ue||t[76]!==de||t[77]!==fe?(pe=(0,$.jsxs)(U,{size:`sm`,variant:`ghost`,className:ue,onClick:w,title:de,children:[G,fe]}),t[74]=w,t[75]=ue,t[76]=de,t[77]=fe,t[78]=pe):pe=t[78];let me;t[79]!==se||t[80]!==H||t[81]!==W||t[82]!==pe?(me=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[se,H,W,pe]}),t[79]=se,t[80]=H,t[81]=W,t[82]=pe,t[83]=me):me=t[83];let he;t[84]!==p||t[85]!==m||t[86]!==n.id?(he=m&&(0,$.jsx)(`div`,{className:`mt-2 pt-2 border-t border-white/5`,children:(0,$.jsx)(Wt,{taskId:n.id,history:p})}),t[84]=p,t[85]=m,t[86]=n.id,t[87]=he):he=t[87];let ge;return t[88]!==I||t[89]!==V||t[90]!==ae||t[91]!==oe||t[92]!==me||t[93]!==he||t[94]!==k?(ge=(0,$.jsxs)(`div`,{className:`p-4 rounded-2xl border border-white/5 bg-card/40 hover:bg-card/60 transition-all duration-200`,children:[k,I,V,ae,oe,me,he]}),t[88]=I,t[89]=V,t[90]=ae,t[91]=oe,t[92]=me,t[93]=he,t[94]=k,t[95]=ge):ge=t[95],ge}function qt(e){return!e}var Jt=()=>{let e=(0,Q.c)(60),{scheduledTasks:t,taskHistory:n,cronChannels:r,cronRecommended:i,cronUserPreference:a,isLoading:o,fetchScheduledTasks:s,fetchCronChannels:c,pauseTask:l,resumeTask:u,deleteTask:d,triggerTask:f,fetchTaskHistory:p,saveCronChannelPreference:m}=bt(),[h,g]=(0,Z.useState)(`all`),_,v;e[0]!==c||e[1]!==s?(_=()=>{s(),c()},v=[s,c],e[0]=c,e[1]=s,e[2]=_,e[3]=v):(_=e[2],v=e[3]),(0,Z.useEffect)(_,v);let y,b,x,S,C,w,T,E;if(e[4]!==r||e[5]!==i||e[6]!==a||e[7]!==d||e[8]!==s||e[9]!==p||e[10]!==o||e[11]!==l||e[12]!==u||e[13]!==m||e[14]!==t||e[15]!==h||e[16]!==n||e[17]!==f){let c=h===`all`?t:t.filter(e=>e.status===h),_=(r??[]).filter(Yt),v=c.filter(Xt);x=Ze,T=`border-none bg-background/50 backdrop-blur-xl shadow-2xl overflow-hidden border border-white/10`;let D;e[26]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`p-2 rounded-xl bg-primary/10 text-primary`,children:(0,$.jsx)(De,{className:`w-5 h-5`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(qe,{className:`text-xl font-bold tracking-tight`,children:`Tareas Programadas`}),(0,$.jsx)(Xe,{children:`Scheduler basado en Croner`})]})]}),e[26]=D):D=e[26];let O;e[27]===o?O=e[28]:(O=o&&(0,$.jsx)(J,{className:`w-4 h-4 animate-spin text-muted-foreground`}),e[27]=o,e[28]=O);let k;e[29]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(Ue,{className:`h-7 text-[10px] w-[110px] border-white/10 bg-card/40`,children:(0,$.jsx)(We,{})}),e[29]=k):k=e[29];let A;e[30]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsxs)(He,{children:[(0,$.jsx)(X,{value:`all`,className:`text-xs`,children:`Todas`}),(0,$.jsx)(X,{value:`active`,className:`text-xs`,children:`Activas`}),(0,$.jsx)(X,{value:`paused`,className:`text-xs`,children:`Pausadas`}),(0,$.jsx)(X,{value:`completed`,className:`text-xs`,children:`Completadas`}),(0,$.jsx)(X,{value:`failed`,className:`text-xs`,children:`Fallidas`})]}),e[30]=A):A=e[30];let j;e[31]===h?j=e[32]:(j=(0,$.jsxs)(Ge,{value:h,onValueChange:g,children:[k,A]}),e[31]=h,e[32]=j);let M=_.length>1&&(0,$.jsxs)(Ge,{value:a,onValueChange:m,children:[(0,$.jsx)(Ue,{className:`h-7 text-[10px] w-[130px] border-white/10 bg-card/40`,children:(0,$.jsx)(We,{placeholder:`Canal`})}),(0,$.jsxs)(He,{children:[(0,$.jsx)(X,{value:`auto`,className:`text-xs`,children:`Auto`}),_.map(e=>(0,$.jsx)(X,{value:e.id,className:`text-xs`,children:Ut(e.id,i)},e.id))]})]}),N;e[33]!==s||e[34]!==h?(N=()=>s(h===`all`?void 0:h),e[33]=s,e[34]=h,e[35]=N):N=e[35];let ee;e[36]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,$.jsx)(F,{className:`w-3.5 h-3.5`}),e[36]=ee):ee=e[36];let P;e[37]!==o||e[38]!==N?(P=(0,$.jsx)(U,{size:`sm`,variant:`ghost`,className:`h-7 w-7 p-0 text-muted-foreground hover:text-foreground`,onClick:N,disabled:o,title:`Refrescar`,children:ee}),e[37]=o,e[38]=N,e[39]=P):P=e[39],e[40]!==j||e[41]!==M||e[42]!==P||e[43]!==O?(E=(0,$.jsx)(Je,{className:`pb-2`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 flex-wrap`,children:[D,(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[O,j,M,P]})]})}),e[40]=j,e[41]=M,e[42]=P,e[43]=O,e[44]=E):E=e[44],b=Ye,y=Ne,w=`h-[420px] pr-4`,S=`space-y-3`,C=v.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-[280px] text-muted-foreground space-y-2`,children:[(0,$.jsx)(De,{className:`w-12 h-12 opacity-20`}),(0,$.jsx)(`p`,{className:`text-sm`,children:`Sin tareas programadas`}),(0,$.jsxs)(`p`,{className:`text-[10px] opacity-70`,children:[`Crea tareas desde el chat o con `,(0,$.jsx)(`code`,{className:`font-mono`,children:`hive cron add`})]})]}):v.map(e=>(0,$.jsx)(Kt,{task:e,onPause:l,onResume:u,onDelete:d,onTrigger:f,onLoadHistory:p,history:n[e.id]},e.id)),e[4]=r,e[5]=i,e[6]=a,e[7]=d,e[8]=s,e[9]=p,e[10]=o,e[11]=l,e[12]=u,e[13]=m,e[14]=t,e[15]=h,e[16]=n,e[17]=f,e[18]=y,e[19]=b,e[20]=x,e[21]=S,e[22]=C,e[23]=w,e[24]=T,e[25]=E}else y=e[18],b=e[19],x=e[20],S=e[21],C=e[22],w=e[23],T=e[24],E=e[25];let D;e[45]!==S||e[46]!==C?(D=(0,$.jsx)(`div`,{className:S,children:C}),e[45]=S,e[46]=C,e[47]=D):D=e[47];let O;e[48]!==y||e[49]!==w||e[50]!==D?(O=(0,$.jsx)(y,{className:w,children:D}),e[48]=y,e[49]=w,e[50]=D,e[51]=O):O=e[51];let k;e[52]!==b||e[53]!==O?(k=(0,$.jsx)(b,{children:O}),e[52]=b,e[53]=O,e[54]=k):k=e[54];let A;return e[55]!==x||e[56]!==T||e[57]!==E||e[58]!==k?(A=(0,$.jsxs)(x,{className:T,children:[E,k]}),e[55]=x,e[56]=T,e[57]=E,e[58]=k,e[59]=A):A=e[59],A};function Yt(e){return e.active}function Xt(e){return!e.name.startsWith(`_hive_`)}var Zt=`https://github.com/johpaz/hive/releases/latest`;function Qt(){let e=(0,Q.c)(26),{phase:t,update:n,percent:i,error:a,check:o,install:s}=Ee(),c;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(c={queryKey:[`version-check`],queryFn:$t,retry:1},e[0]=c):c=e[0];let{data:l}=r(c),u;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=Se(),e[1]=u):u=e[1];let d=u,p=t===`checking`||t===`downloading`||t===`installing`||t===`restarting`,m;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(`h3`,{className:`font-medium`,children:`Versión instalada`}),e[2]=m):m=e[2];let h=l?.current??`—`,g=l?.installationType?` · ${l.installationType}`:``,_;e[3]!==h||e[4]!==g?(_=(0,$.jsxs)(`div`,{children:[m,(0,$.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Hive `,h,g]})]}),e[3]=h,e[4]=g,e[5]=_):_=e[5];let v;e[6]===t?v=e[7]:(v=t===`up-to-date`&&(0,$.jsxs)(Me,{variant:`secondary`,className:`gap-1`,children:[(0,$.jsx)(f,{className:`h-3.5 w-3.5`}),` Al día`]}),e[6]=t,e[7]=v);let y;e[8]===n?y=e[9]:(y=n&&(0,$.jsxs)(Me,{className:`gap-1`,children:[(0,$.jsx)(_e,{className:`h-3.5 w-3.5`}),` `,n.version,` disponible`]}),e[8]=n,e[9]=y);let b;e[10]!==_||e[11]!==v||e[12]!==y?(b=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[_,v,y]}),e[10]=_,e[11]=v,e[12]=y,e[13]=b):b=e[13];let x;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(x=!d&&(0,$.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Esta instalación no se actualiza desde acá. Con npm o bun:`,` `,(0,$.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 text-xs`,children:`bun install -g @johpaz/hive-agents@latest`}),`. Con Docker:`,` `,(0,$.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 text-xs`,children:`docker compose pull`}),`.`]}),e[14]=x):x=e[14];let S;e[15]!==p||e[16]!==o||e[17]!==a||e[18]!==s||e[19]!==i||e[20]!==t||e[21]!==n?(S=d&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`La app revisa si hay versión nueva al abrirse y cada 6 horas. Cuando la instalas, se descarga, se verifica su firma y Hive se reinicia solo. Tus datos y agentes no se tocan.`}),t===`downloading`&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(ge,{value:i}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i>0?`Descargando… ${i}%`:`Preparando la descarga…`})]}),t===`installing`&&(0,$.jsx)(`p`,{className:`text-sm`,children:`Instalando… no cierres la aplicación.`}),t===`restarting`&&(0,$.jsx)(`p`,{className:`text-sm`,children:`Listo. Reiniciando Hive…`}),t===`unsupported`&&(0,$.jsxs)(`p`,{className:`flex items-start gap-2 text-sm`,children:[(0,$.jsx)(ue,{className:`mt-0.5 h-4 w-4 shrink-0 text-amber-500`}),(0,$.jsxs)(`span`,{children:[`La actualización automática de Linux se publica como .deb, y este sistema no puede instalarlo. Descarga el .rpm desde`,` `,(0,$.jsx)(`a`,{className:`underline`,href:Zt,target:`_blank`,rel:`noreferrer`,children:`la página de releases`}),` `,`e instálalo encima: conserva tus datos, agentes y claves.`]})]}),t===`error`&&(0,$.jsxs)(`p`,{className:`flex items-start gap-2 text-sm text-destructive`,children:[(0,$.jsx)(ue,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,$.jsxs)(`span`,{children:[a,` `,(0,$.jsx)(`a`,{className:`underline`,href:Zt,target:`_blank`,rel:`noreferrer`,children:`Instalar manualmente`})]})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(U,{variant:`outline`,disabled:p,onClick:()=>void o({manual:!0}),children:t===`checking`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(J,{className:`mr-2 h-4 w-4 animate-spin`}),` Buscando…`]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(F,{className:`mr-2 h-4 w-4`}),` Buscar actualizaciones`]})}),n&&t===`available`&&(0,$.jsxs)(U,{onClick:()=>void s(),children:[(0,$.jsx)(_e,{className:`mr-2 h-4 w-4`}),` Instalar `,n.version]})]})]}),e[15]=p,e[16]=o,e[17]=a,e[18]=s,e[19]=i,e[20]=t,e[21]=n,e[22]=S):S=e[22];let C;return e[23]!==S||e[24]!==b?(C=(0,$.jsxs)(`div`,{className:`space-y-4 rounded-lg border border-border/60 bg-card/50 p-5`,children:[b,x,S]}),e[23]=S,e[24]=b,e[25]=C):C=e[25],C}function $t(){return W(`/api/version`)}function en(){let e=(0,Q.c)(43),t=k(sn),n=k(on),r=k(an),i=k(rn),[a,o]=(0,Z.useState)(nn),{entradas:s,salidas:c,motivoSalidas:l}=j(),[u,d]=(0,Z.useState)(tn),f=A(u.input,!0,i),p;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=me(),e[0]=p):p=e[0];let m=p,h,g;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>{let e=e=>o(e.detail);return window.addEventListener(`hive-zoom`,e),()=>window.removeEventListener(`hive-zoom`,e)},g=[],e[1]=h,e[2]=g):(h=e[1],g=e[2]),(0,Z.useEffect)(h,g);let _;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(_=e=>void Te(e).then(o),e[3]=_):_=e[3];let v=_,y;e[4]===a?y=e[5]:(y=m&&(0,$.jsxs)(`div`,{className:`space-y-4 rounded-lg border border-border/60 bg-card/50 p-5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(ct,{className:`h-4 w-4 text-muted-foreground`}),(0,$.jsx)(`h3`,{className:`font-medium`,children:`Tamaño de la vista`})]}),(0,$.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Escala toda la aplicación. También con `,(0,$.jsx)(`kbd`,{children:`Ctrl`}),` y `,(0,$.jsx)(`kbd`,{children:`+`}),` / `,(0,$.jsx)(`kbd`,{children:`−`}),` / `,(0,$.jsx)(`kbd`,{children:`0`}),`, o `,(0,$.jsx)(`kbd`,{children:`Ctrl`}),` y la rueda del ratón.`]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(U,{variant:`outline`,size:`icon`,"aria-label":`Reducir`,disabled:a<=.6,onClick:()=>v(a-.1),children:(0,$.jsx)(D,{className:`h-4 w-4`})}),(0,$.jsxs)(`span`,{className:`min-w-16 text-center font-mono text-sm tabular-nums`,children:[Math.round(a*100),`%`]}),(0,$.jsx)(U,{variant:`outline`,size:`icon`,"aria-label":`Ampliar`,disabled:a>=2,onClick:()=>v(a+.1),children:(0,$.jsx)(P,{className:`h-4 w-4`})}),(0,$.jsxs)(U,{variant:`ghost`,size:`sm`,className:`gap-2`,onClick:()=>v(1),children:[(0,$.jsx)(I,{className:`h-3.5 w-3.5`}),` Restablecer`]})]})]}),e[4]=a,e[5]=y);let b,x;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(T,{className:`h-4 w-4 text-muted-foreground`}),(0,$.jsx)(`h3`,{className:`font-medium`,children:`Micrófono`})]}),x=(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Por dónde te oye la colmena en HiveLive. Se puede cambiar incluso con la llamada abierta.`}),e[6]=b,e[7]=x):(b=e[6],x=e[7]);let S;e[8]!==u||e[9]!==n?(S=e=>{d({...u,input:e}),n(e)},e[8]=u,e[9]=n,e[10]=S):S=e[10];let C;e[11]!==s||e[12]!==u.input||e[13]!==S?(C=(0,$.jsx)(cn,{dispositivos:s,valor:u.input,vacio:`Predeterminado del sistema`,onCambio:S,sinNada:`No se detectó ningún micrófono.`}),e[11]=s,e[12]=u.input,e[13]=S,e[14]=C):C=e[14];let w=`scaleX(${Math.min(1,f*1.6)})`,E;e[15]===w?E=e[16]:(E=(0,$.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-muted`,children:(0,$.jsx)(`div`,{className:`h-full origin-left rounded-full bg-primary transition-transform duration-100`,style:{transform:w}})}),e[15]=w,e[16]=E);let O;e[17]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Habla y comprueba que la barra se mueve.`}),e[17]=O):O=e[17];let M;e[18]!==E||e[19]!==C?(M=(0,$.jsxs)(`div`,{className:`space-y-4 rounded-lg border border-border/60 bg-card/50 p-5`,children:[b,x,C,E,O]}),e[18]=E,e[19]=C,e[20]=M):M=e[20];let N,F;e[21]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(ne,{className:`h-4 w-4 text-muted-foreground`}),(0,$.jsx)(`h3`,{className:`font-medium`,children:`Salida de la voz en vivo`})]}),F=(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Por dónde se oye a la colmena en HiveLive. La lista la reporta el sistema operativo y se actualiza al conectar o desconectar un aparato.`}),e[21]=N,e[22]=F):(N=e[21],F=e[22]);let L;e[23]!==u||e[24]!==t?(L=e=>{d({...u,output:e}),t(e)},e[23]=u,e[24]=t,e[25]=L):L=e[25];let R=l??`Buscando salidas…`,z;e[26]!==u.output||e[27]!==c||e[28]!==L||e[29]!==R?(z=(0,$.jsx)(cn,{dispositivos:c,valor:u.output,vacio:`Predeterminada del sistema`,onCambio:L,sinNada:R}),e[26]=u.output,e[27]=c,e[28]=L,e[29]=R,e[30]=z):z=e[30];let B;e[31]===r?B=e[32]:(B=()=>void r(),e[31]=r,e[32]=B);let V;e[33]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,$.jsx)(ee,{className:`h-3.5 w-3.5`}),e[33]=V):V=e[33];let te;e[34]===B?te=e[35]:(te=(0,$.jsxs)(U,{variant:`outline`,size:`sm`,className:`gap-2`,onClick:B,children:[V,` Probar sonido`]}),e[34]=B,e[35]=te);let re;e[36]!==z||e[37]!==te?(re=(0,$.jsxs)(`div`,{className:`space-y-4 rounded-lg border border-border/60 bg-card/50 p-5`,children:[N,F,z,te]}),e[36]=z,e[37]=te,e[38]=re):re=e[38];let ie;return e[39]!==M||e[40]!==re||e[41]!==y?(ie=(0,$.jsxs)(`div`,{className:`space-y-6`,children:[y,M,re]}),e[39]=M,e[40]=re,e[41]=y,e[42]=ie):ie=e[42],ie}function tn(){return E()}function nn(){return ye()}function rn(e){return e.status!==`idle`&&e.status!==`error`}function an(e){return e.probarSalida}function on(e){return e.usarEntrada}function sn(e){return e.usarSalida}function cn(e){let t=(0,Q.c)(13),{dispositivos:n,valor:r,vacio:i,sinNada:a,onCambio:o}=e;if(n.length===0){let e;return t[0]===a?e=t[1]:(e=(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:a}),t[0]=a,t[1]=e),e}let s;t[2]===o?s=t[3]:(s=e=>o(e.target.value),t[2]=o,t[3]=s);let c;t[4]===i?c=t[5]:(c=(0,$.jsx)(`option`,{value:``,children:i}),t[4]=i,t[5]=c);let l;t[6]===n?l=t[7]:(l=n.map(ln),t[6]=n,t[7]=l);let u;return t[8]!==s||t[9]!==c||t[10]!==l||t[11]!==r?(u=(0,$.jsxs)(`select`,{className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm`,value:r,onChange:s,children:[c,l]}),t[8]=s,t[9]=c,t[10]=l,t[11]=r,t[12]=u):u=t[12],u}function ln(e){return(0,$.jsxs)(`option`,{value:e.id,children:[e.nombre,e.porDefecto?` (actual del sistema)`:``]},e.id)}function un(e){if(e.includes(` & `)){let[t,n]=e.split(` & `,2);return{lead:t,accent:`& ${n}`}}let[t,...n]=e.split(` `);return{lead:t,accent:n.join(` `)}}function dn(e){let t=(0,Q.c)(9),{panel:n}=e;switch(n){case`etica`:{let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(ut,{})}),t[0]=e):e=t[0],e}case`herramientas`:{let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(ft,{})}),t[1]=e):e=t[1],e}case`mcp`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(yt,{})}),t[2]=e):e=t[2],e}case`skills`:{let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(Ft,{})}),t[3]=e):e=t[3],e}case`perfil`:{let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(kt,{})}),t[4]=e):e=t[4],e}case`notas`:{let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(It,{})}),t[5]=e):e=t[5],e}case`cron-jobs`:{let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(Jt,{})}),t[6]=e):e=t[6],e}case`actualizaciones`:{let e;return t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(Qt,{})}),t[7]=e):e=t[7],e}case`pantalla`:{let e;return t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(en,{})}),t[8]=e):e=t[8],e}default:return null}}var fn=[`etica`,`herramientas`,`mcp`,`skills`,`perfil`,`notas`,`cron-jobs`,`actualizaciones`,`pantalla`];function pn(e){let t=(0,Q.c)(31),{forcePanel:n}=e,{panel:r}=ae(),{fetchSkills:i}=Ae(),{fetchTools:a}=de(),{fetchMCPServers:o}=je(),s,c;t[0]!==o||t[1]!==i||t[2]!==a?(s=()=>{i(),a(),o()},c=[i,a,o],t[0]=o,t[1]=i,t[2]=a,t[3]=s,t[4]=c):(s=t[3],c=t[4]),(0,Z.useEffect)(s,c);let l=r===`seguridad`?`perfil`:r,u;t[5]!==n||t[6]!==l?(u=n||(fn.includes(l)?l:`herramientas`),t[5]=n,t[6]=l,t[7]=u):u=t[7];let d=u,f,p,m;if(t[8]!==d){let{title:e,subtitle:n,eyebrow:r}={etica:{eyebrow:`PROTOCOLOS DE CONDUCTA`,title:`Ética & Alineación`,subtitle:`Configura los límites morales y el comportamiento base de tus agentes.`},herramientas:{eyebrow:`CAPACIDADES DINÁMICAS`,title:`Gestión de Herramientas`,subtitle:`Habilita y configura las funciones que tus agentes pueden ejecutar.`},mcp:{eyebrow:`CONECTIVIDAD EXTERNA`,title:`Servidores MCP`,subtitle:`Conecta Hive con fuentes de datos externas y herramientas de terceros.`},skills:{eyebrow:`HABILIDADES ESPECIALIZADAS`,title:`Galería de Skills`,subtitle:`Nodos cognitivos preconfigurados para tareas específicas de alto nivel.`},perfil:{eyebrow:`IDENTIDAD DEL OPERADOR`,title:`Perfil de Usuario`,subtitle:`Gestiona tu información personal y preferencias de la interfaz.`},notas:{eyebrow:`MEMORIA OPERATIVA`,title:`Notas del Sistema`,subtitle:`Registro de información persistente y recordatorios del enjambre.`},"cron-jobs":{eyebrow:`AUTOMATIZACIÓN TEMPORAL`,title:`Tareas Programadas`,subtitle:`Gestión de ejecuciones recurrentes y disparadores cron.`},actualizaciones:{eyebrow:`MANTENIMIENTO`,title:`Actualizaciones`,subtitle:`Consulta tu versión, busca una nueva e instálala sin salir de la app.`},pantalla:{eyebrow:`APARIENCIA Y SONIDO`,title:`Pantalla & Audio`,subtitle:`Ajusta el tamaño de la vista y elige por dónde se oye la voz en vivo.`}}[d];p=n,f=r,m=un(e),t[8]=d,t[9]=f,t[10]=p,t[11]=m}else f=t[9],p=t[10],m=t[11];let h=m,g;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(`div`,{className:`hive-page-header__dot`}),t[12]=g):g=t[12];let _;t[13]===f?_=t[14]:(_=(0,$.jsxs)(`div`,{className:`hive-page-header__eyebrow`,children:[g,(0,$.jsx)(`span`,{className:`hive-page-header__label`,children:f})]}),t[13]=f,t[14]=_);let v;t[15]===h.accent?v=t[16]:(v=h.accent&&(0,$.jsxs)($.Fragment,{children:[` `,(0,$.jsx)(`span`,{className:`hive-title-page__accent`,children:h.accent})]}),t[15]=h.accent,t[16]=v);let y;t[17]!==v||t[18]!==h.lead?(y=(0,$.jsxs)(`h2`,{className:`hive-title-page`,children:[h.lead,v]}),t[17]=v,t[18]=h.lead,t[19]=y):y=t[19];let b;t[20]===p?b=t[21]:(b=(0,$.jsx)(`p`,{className:`hive-subtitle`,children:p}),t[20]=p,t[21]=b);let x;t[22]!==_||t[23]!==y||t[24]!==b?(x=(0,$.jsx)(`div`,{className:`hive-page-header`,children:(0,$.jsxs)(`div`,{className:`relative z-10`,children:[_,y,b]})}),t[22]=_,t[23]=y,t[24]=b,t[25]=x):x=t[25];let S;t[26]===d?S=t[27]:(S=(0,$.jsx)(`div`,{className:`animate-fade-in`,children:(0,$.jsx)(dn,{panel:d})}),t[26]=d,t[27]=S);let C;return t[28]!==x||t[29]!==S?(C=(0,$.jsxs)(`div`,{className:`hive-page-container`,children:[x,S]}),t[28]=x,t[29]=S,t[30]=C):C=t[30],C}export{pn as SettingsPage};
|