@johpaz/hive-agents 0.0.39 → 0.0.40

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.
Files changed (202) hide show
  1. package/README.md +29 -69
  2. package/dist/hive.js +2522 -1927
  3. package/dist/tool-worker.js +1791 -1334
  4. package/dist/ui/assets/AgentCreateForm-b7xHyfNc.js +1 -0
  5. package/dist/ui/assets/AgentDetailPage-VHy3M7mI.js +1 -0
  6. package/dist/ui/assets/AgentNewPage-BnWImQMx.js +1 -0
  7. package/dist/ui/{dist/assets/AgentsPage-C-GSRk-N.js → assets/AgentsPage-WFy5abqx.js} +1 -1
  8. package/dist/ui/assets/ApiClientPage-BV7zLIL7.js +3 -0
  9. package/dist/ui/assets/{CanvasPage-Cvs5ctza.js → CanvasPage-B9zuIrTm.js} +1 -1
  10. package/dist/ui/assets/{ChannelsPage-C5m_L7P9.js → ChannelsPage-DiN3NvIM.js} +1 -1
  11. package/dist/ui/assets/{DashboardPage-CztbRQdm.js → DashboardPage-CHjARjVK.js} +1 -1
  12. package/dist/ui/assets/{LoginPage-OMsrx5oj.js → LoginPage-Dwd_XxoU.js} +1 -1
  13. package/dist/ui/{dist/assets/LogsPage-CcYYwjgF.js → assets/LogsPage-DW8Nnqe6.js} +1 -1
  14. package/dist/ui/assets/MeetingPage-D3bkiKYt.js +1 -0
  15. package/dist/ui/assets/{NotFound-GbAJDgoD.js → NotFound-BIUDlIXU.js} +1 -1
  16. package/dist/ui/assets/ProvidersPage-UqsDAxPQ.js +1 -0
  17. package/dist/ui/{dist/assets/RecoverPage-CwB2ByCU.js → assets/RecoverPage-8hTjr_JU.js} +1 -1
  18. package/dist/ui/assets/SettingsPage-DNa0jOkA.js +9 -0
  19. package/dist/ui/assets/{SetupPage-DOVh1ldK.js → SetupPage-Bdm2irQG.js} +1 -1
  20. package/dist/ui/assets/WebChatPage-DElJg6P2.js +16 -0
  21. package/dist/ui/assets/accordion-CnLzKNHK.js +1 -0
  22. package/dist/ui/{dist/assets/alert-D_2Y3qjL.js → assets/alert-DylmSCDJ.js} +1 -1
  23. package/dist/ui/{dist/assets/alert-dialog-CpMxaNcu.js → assets/alert-dialog-DNNWN_SI.js} +1 -1
  24. package/dist/ui/assets/{badge-CxTPR6_t.js → badge-ChENFgkC.js} +1 -1
  25. package/dist/ui/assets/chevron-down-DIosfU_U.js +1 -0
  26. package/dist/ui/assets/chevron-up-CI-W21Fy.js +1 -0
  27. package/dist/ui/{dist/assets/dialog-DfS3idb3.js → assets/dialog-BJ-npIv8.js} +1 -1
  28. package/dist/ui/assets/{dropdown-menu-BdCbAW1z.js → dropdown-menu-DDiaHg5y.js} +1 -1
  29. package/dist/ui/assets/{es-Cz5h9_84.js → es-ecSKCyB6.js} +1 -1
  30. package/dist/ui/assets/index-CawKP29y.js +116 -0
  31. package/dist/ui/assets/index-DIcsEkyd.css +2 -0
  32. package/dist/ui/{dist/assets/label-byJkqOYq.js → assets/label-Bi6udtSd.js} +1 -1
  33. package/dist/ui/assets/select-BQCOjM2j.js +1 -0
  34. package/dist/ui/assets/useProviders-Dlizq_8q.js +1 -0
  35. package/dist/ui/dist/assets/AgentCreateForm-b7xHyfNc.js +1 -0
  36. package/dist/ui/dist/assets/AgentDetailPage-VHy3M7mI.js +1 -0
  37. package/dist/ui/dist/assets/AgentNewPage-BnWImQMx.js +1 -0
  38. package/dist/ui/{assets/AgentsPage-C-GSRk-N.js → dist/assets/AgentsPage-WFy5abqx.js} +1 -1
  39. package/dist/ui/dist/assets/ApiClientPage-BV7zLIL7.js +3 -0
  40. package/dist/ui/dist/assets/{CanvasPage-Cvs5ctza.js → CanvasPage-B9zuIrTm.js} +1 -1
  41. package/dist/ui/dist/assets/{ChannelsPage-C5m_L7P9.js → ChannelsPage-DiN3NvIM.js} +1 -1
  42. package/dist/ui/dist/assets/{DashboardPage-CztbRQdm.js → DashboardPage-CHjARjVK.js} +1 -1
  43. package/dist/ui/dist/assets/{LoginPage-OMsrx5oj.js → LoginPage-Dwd_XxoU.js} +1 -1
  44. package/dist/ui/{assets/LogsPage-CcYYwjgF.js → dist/assets/LogsPage-DW8Nnqe6.js} +1 -1
  45. package/dist/ui/dist/assets/MeetingPage-D3bkiKYt.js +1 -0
  46. package/dist/ui/dist/assets/{NotFound-GbAJDgoD.js → NotFound-BIUDlIXU.js} +1 -1
  47. package/dist/ui/dist/assets/ProvidersPage-UqsDAxPQ.js +1 -0
  48. package/dist/ui/{assets/RecoverPage-CwB2ByCU.js → dist/assets/RecoverPage-8hTjr_JU.js} +1 -1
  49. package/dist/ui/dist/assets/SettingsPage-DNa0jOkA.js +9 -0
  50. package/dist/ui/dist/assets/{SetupPage-DOVh1ldK.js → SetupPage-Bdm2irQG.js} +1 -1
  51. package/dist/ui/dist/assets/WebChatPage-DElJg6P2.js +16 -0
  52. package/dist/ui/dist/assets/accordion-CnLzKNHK.js +1 -0
  53. package/dist/ui/{assets/alert-D_2Y3qjL.js → dist/assets/alert-DylmSCDJ.js} +1 -1
  54. package/dist/ui/{assets/alert-dialog-CpMxaNcu.js → dist/assets/alert-dialog-DNNWN_SI.js} +1 -1
  55. package/dist/ui/dist/assets/{badge-CxTPR6_t.js → badge-ChENFgkC.js} +1 -1
  56. package/dist/ui/dist/assets/chevron-down-DIosfU_U.js +1 -0
  57. package/dist/ui/dist/assets/chevron-up-CI-W21Fy.js +1 -0
  58. package/dist/ui/{assets/dialog-DfS3idb3.js → dist/assets/dialog-BJ-npIv8.js} +1 -1
  59. package/dist/ui/dist/assets/{dropdown-menu-BdCbAW1z.js → dropdown-menu-DDiaHg5y.js} +1 -1
  60. package/dist/ui/dist/assets/{es-Cz5h9_84.js → es-ecSKCyB6.js} +1 -1
  61. package/dist/ui/dist/assets/index-CawKP29y.js +116 -0
  62. package/dist/ui/dist/assets/index-DIcsEkyd.css +2 -0
  63. package/dist/ui/{assets/label-byJkqOYq.js → dist/assets/label-Bi6udtSd.js} +1 -1
  64. package/dist/ui/dist/assets/select-BQCOjM2j.js +1 -0
  65. package/dist/ui/dist/assets/useProviders-Dlizq_8q.js +1 -0
  66. package/dist/ui/dist/index.html +4 -4
  67. package/dist/ui/index.html +4 -4
  68. package/package.json +1 -1
  69. package/packages/cli/src/commands/gateway.ts +1 -1
  70. package/packages/cli/src/commands/onboard.ts +27 -1
  71. package/packages/core/src/agent/agent-loop.ts +104 -2
  72. package/packages/core/src/agent/context-compiler.ts +6 -0
  73. package/packages/core/src/agent/llm-client.ts +2 -0
  74. package/packages/core/src/agent/llm-providers/hiveagents.ts +248 -0
  75. package/packages/core/src/agent/llm-providers/interface.ts +2 -0
  76. package/packages/core/src/agent/llm-providers/openai-compat-base.ts +49 -25
  77. package/packages/core/src/agent/providers/index.ts +3 -2
  78. package/packages/core/src/agent/stuck-loop.ts +90 -14
  79. package/packages/core/src/channels/base.ts +7 -1
  80. package/packages/core/src/config/loader.ts +1 -1
  81. package/packages/core/src/gateway/routes/providers.ts +56 -0
  82. package/packages/core/src/gateway/server.ts +120 -55
  83. package/packages/core/src/gateway/slash-commands.ts +7 -1
  84. package/packages/core/src/storage/onboarding.ts +28 -0
  85. package/packages/core/src/storage/seed.ts +14 -0
  86. package/packages/skills/src/bundled-data.generated.ts +1357 -1357
  87. package/dist/ui/assets/AgentCreateForm-BTCzFbca.js +0 -1
  88. package/dist/ui/assets/AgentDetailPage-o27TRSVw.js +0 -1
  89. package/dist/ui/assets/AgentNewPage-400cCpYt.js +0 -1
  90. package/dist/ui/assets/ApiClientPage-BOTpz6oP.js +0 -3
  91. package/dist/ui/assets/MeetingPage-CrKVAfe6.js +0 -1
  92. package/dist/ui/assets/ProvidersPage-uqPcZUSV.js +0 -1
  93. package/dist/ui/assets/SettingsPage-DKLlye0z.js +0 -9
  94. package/dist/ui/assets/WebChatPage-c-7S9jnT.js +0 -16
  95. package/dist/ui/assets/accordion-DAbcVQCn.js +0 -1
  96. package/dist/ui/assets/chevron-up-BYhk0K2J.js +0 -1
  97. package/dist/ui/assets/index-CmGm_r89.js +0 -116
  98. package/dist/ui/assets/index-T7HgphSn.css +0 -2
  99. package/dist/ui/assets/select-Cl16QYa_.js +0 -1
  100. package/dist/ui/assets/useProviders-eEri6BAc.js +0 -1
  101. package/dist/ui/dist/assets/AgentCreateForm-BTCzFbca.js +0 -1
  102. package/dist/ui/dist/assets/AgentDetailPage-o27TRSVw.js +0 -1
  103. package/dist/ui/dist/assets/AgentNewPage-400cCpYt.js +0 -1
  104. package/dist/ui/dist/assets/ApiClientPage-BOTpz6oP.js +0 -3
  105. package/dist/ui/dist/assets/MeetingPage-CrKVAfe6.js +0 -1
  106. package/dist/ui/dist/assets/ProvidersPage-uqPcZUSV.js +0 -1
  107. package/dist/ui/dist/assets/SettingsPage-DKLlye0z.js +0 -9
  108. package/dist/ui/dist/assets/WebChatPage-c-7S9jnT.js +0 -16
  109. package/dist/ui/dist/assets/accordion-DAbcVQCn.js +0 -1
  110. package/dist/ui/dist/assets/chevron-up-BYhk0K2J.js +0 -1
  111. package/dist/ui/dist/assets/index-CmGm_r89.js +0 -116
  112. package/dist/ui/dist/assets/index-T7HgphSn.css +0 -2
  113. package/dist/ui/dist/assets/select-Cl16QYa_.js +0 -1
  114. package/dist/ui/dist/assets/useProviders-eEri6BAc.js +0 -1
  115. /package/dist/ui/assets/{card-CXAm46at.js → card-DFKnZ6ky.js} +0 -0
  116. /package/dist/ui/assets/{circle-alert-CyHDwUj8.js → circle-alert-KuAm2FWh.js} +0 -0
  117. /package/dist/ui/assets/{circle-check-Bb54Ebmu.js → circle-check-6Ard1-2z.js} +0 -0
  118. /package/dist/ui/assets/{circle-x-Bv6WrUJo.js → circle-x-DjLkFDO8.js} +0 -0
  119. /package/dist/ui/assets/{copy-dU94ZGsi.js → copy-Bu5d7C-0.js} +0 -0
  120. /package/dist/ui/assets/{cpu-DSpPVLAz.js → cpu-KDy6-FAI.js} +0 -0
  121. /package/dist/ui/assets/{download-D9ZyUZZR.js → download-Cjbk4Rek.js} +0 -0
  122. /package/dist/ui/assets/{external-link-CHPbUorN.js → external-link-6sTlRDUR.js} +0 -0
  123. /package/dist/ui/assets/{eye-epHJZ_nQ.js → eye-Df8o0tkC.js} +0 -0
  124. /package/dist/ui/assets/{file-text-BEjEmgby.js → file-text-lnxnjBp0.js} +0 -0
  125. /package/dist/ui/assets/{folder-open-iQMHVEqS.js → folder-open-DJBLDFjv.js} +0 -0
  126. /package/dist/ui/assets/{format-oFACFaca.js → format-BwdV8bB5.js} +0 -0
  127. /package/dist/ui/assets/{gateway-url-iG-C6Agn.js → gateway-url-DwzPmoc8.js} +0 -0
  128. /package/dist/ui/assets/{gauge-D0_GMEcq.js → gauge-B8Tj43rC.js} +0 -0
  129. /package/dist/ui/assets/{hexagon-DsGOUl-H.js → hexagon-6L79pgVK.js} +0 -0
  130. /package/dist/ui/assets/{history-BSG-Ypqf.js → history-CAF_R34_.js} +0 -0
  131. /package/dist/ui/assets/{info-NwLoa2Mj.js → info-WjromB4Y.js} +0 -0
  132. /package/dist/ui/assets/{key-3EP0dhkT.js → key-DyKOoQh5.js} +0 -0
  133. /package/dist/ui/assets/{loader-circle-CZNax6kS.js → loader-circle-BmBOgYze.js} +0 -0
  134. /package/dist/ui/assets/{lock-Ei1_J-Nq.js → lock-BS6OLXPv.js} +0 -0
  135. /package/dist/ui/assets/{pause-BUqah9Bi.js → pause-VqeUmp2Z.js} +0 -0
  136. /package/dist/ui/assets/{play-NcZ4swwL.js → play-zJpWuhrr.js} +0 -0
  137. /package/dist/ui/assets/{plus-CX1xyhp5.js → plus-BZQX26Dr.js} +0 -0
  138. /package/dist/ui/assets/{progress-Dtz-Mzys.js → progress-D5c-Eilm.js} +0 -0
  139. /package/dist/ui/assets/{refresh-cw-DaYdjQFk.js → refresh-cw-CCzDCAuz.js} +0 -0
  140. /package/dist/ui/assets/{save-CUdYyHNy.js → save-hUmZhceG.js} +0 -0
  141. /package/dist/ui/assets/{scroll-area-BXtLsE9E.js → scroll-area-CihOx0cb.js} +0 -0
  142. /package/dist/ui/assets/{search-BGmPJ-6L.js → search-DzDptO9s.js} +0 -0
  143. /package/dist/ui/assets/{send-BuQcUO-R.js → send-BPk9XbIq.js} +0 -0
  144. /package/dist/ui/assets/{settings-CcMGI1iU.js → settings-BGfrZ_zM.js} +0 -0
  145. /package/dist/ui/assets/{shield-C-05qB-2.js → shield-CxhcUT39.js} +0 -0
  146. /package/dist/ui/assets/{slider-D2I0qven.js → slider-bcUiUfx0.js} +0 -0
  147. /package/dist/ui/assets/{sparkles-D6fx8JC5.js → sparkles-BhwlS1pc.js} +0 -0
  148. /package/dist/ui/assets/{square-BD81nFtN.js → square-DMNWw4Hi.js} +0 -0
  149. /package/dist/ui/assets/{switch-h2SfQX4B.js → switch-BR30E4ej.js} +0 -0
  150. /package/dist/ui/assets/{table-CVkIRJKK.js → table-B3aGEaVp.js} +0 -0
  151. /package/dist/ui/assets/{tabs-C619jxbO.js → tabs-LQidMKRS.js} +0 -0
  152. /package/dist/ui/assets/{terminal-DN38Q456.js → terminal--7G943As.js} +0 -0
  153. /package/dist/ui/assets/{textarea-wvA-FDjO.js → textarea-B6Z1Zc6W.js} +0 -0
  154. /package/dist/ui/assets/{trash-2-BHRa5ft9.js → trash-2-xD2o4SgX.js} +0 -0
  155. /package/dist/ui/assets/{triangle-alert-D4nwAVbc.js → triangle-alert-pVIJGjga.js} +0 -0
  156. /package/dist/ui/assets/{vendor-router-pCP7sjma.js → vendor-router-gqiZ7xhx.js} +0 -0
  157. /package/dist/ui/assets/{volume-2-B6tkRy2u.js → volume-2-BekVQl6P.js} +0 -0
  158. /package/dist/ui/assets/{zap-QO7iWMRg.js → zap-B4RaNNO5.js} +0 -0
  159. /package/dist/ui/dist/assets/{card-CXAm46at.js → card-DFKnZ6ky.js} +0 -0
  160. /package/dist/ui/dist/assets/{circle-alert-CyHDwUj8.js → circle-alert-KuAm2FWh.js} +0 -0
  161. /package/dist/ui/dist/assets/{circle-check-Bb54Ebmu.js → circle-check-6Ard1-2z.js} +0 -0
  162. /package/dist/ui/dist/assets/{circle-x-Bv6WrUJo.js → circle-x-DjLkFDO8.js} +0 -0
  163. /package/dist/ui/dist/assets/{copy-dU94ZGsi.js → copy-Bu5d7C-0.js} +0 -0
  164. /package/dist/ui/dist/assets/{cpu-DSpPVLAz.js → cpu-KDy6-FAI.js} +0 -0
  165. /package/dist/ui/dist/assets/{download-D9ZyUZZR.js → download-Cjbk4Rek.js} +0 -0
  166. /package/dist/ui/dist/assets/{external-link-CHPbUorN.js → external-link-6sTlRDUR.js} +0 -0
  167. /package/dist/ui/dist/assets/{eye-epHJZ_nQ.js → eye-Df8o0tkC.js} +0 -0
  168. /package/dist/ui/dist/assets/{file-text-BEjEmgby.js → file-text-lnxnjBp0.js} +0 -0
  169. /package/dist/ui/dist/assets/{folder-open-iQMHVEqS.js → folder-open-DJBLDFjv.js} +0 -0
  170. /package/dist/ui/dist/assets/{format-oFACFaca.js → format-BwdV8bB5.js} +0 -0
  171. /package/dist/ui/dist/assets/{gateway-url-iG-C6Agn.js → gateway-url-DwzPmoc8.js} +0 -0
  172. /package/dist/ui/dist/assets/{gauge-D0_GMEcq.js → gauge-B8Tj43rC.js} +0 -0
  173. /package/dist/ui/dist/assets/{hexagon-DsGOUl-H.js → hexagon-6L79pgVK.js} +0 -0
  174. /package/dist/ui/dist/assets/{history-BSG-Ypqf.js → history-CAF_R34_.js} +0 -0
  175. /package/dist/ui/dist/assets/{info-NwLoa2Mj.js → info-WjromB4Y.js} +0 -0
  176. /package/dist/ui/dist/assets/{key-3EP0dhkT.js → key-DyKOoQh5.js} +0 -0
  177. /package/dist/ui/dist/assets/{loader-circle-CZNax6kS.js → loader-circle-BmBOgYze.js} +0 -0
  178. /package/dist/ui/dist/assets/{lock-Ei1_J-Nq.js → lock-BS6OLXPv.js} +0 -0
  179. /package/dist/ui/dist/assets/{pause-BUqah9Bi.js → pause-VqeUmp2Z.js} +0 -0
  180. /package/dist/ui/dist/assets/{play-NcZ4swwL.js → play-zJpWuhrr.js} +0 -0
  181. /package/dist/ui/dist/assets/{plus-CX1xyhp5.js → plus-BZQX26Dr.js} +0 -0
  182. /package/dist/ui/dist/assets/{progress-Dtz-Mzys.js → progress-D5c-Eilm.js} +0 -0
  183. /package/dist/ui/dist/assets/{refresh-cw-DaYdjQFk.js → refresh-cw-CCzDCAuz.js} +0 -0
  184. /package/dist/ui/dist/assets/{save-CUdYyHNy.js → save-hUmZhceG.js} +0 -0
  185. /package/dist/ui/dist/assets/{scroll-area-BXtLsE9E.js → scroll-area-CihOx0cb.js} +0 -0
  186. /package/dist/ui/dist/assets/{search-BGmPJ-6L.js → search-DzDptO9s.js} +0 -0
  187. /package/dist/ui/dist/assets/{send-BuQcUO-R.js → send-BPk9XbIq.js} +0 -0
  188. /package/dist/ui/dist/assets/{settings-CcMGI1iU.js → settings-BGfrZ_zM.js} +0 -0
  189. /package/dist/ui/dist/assets/{shield-C-05qB-2.js → shield-CxhcUT39.js} +0 -0
  190. /package/dist/ui/dist/assets/{slider-D2I0qven.js → slider-bcUiUfx0.js} +0 -0
  191. /package/dist/ui/dist/assets/{sparkles-D6fx8JC5.js → sparkles-BhwlS1pc.js} +0 -0
  192. /package/dist/ui/dist/assets/{square-BD81nFtN.js → square-DMNWw4Hi.js} +0 -0
  193. /package/dist/ui/dist/assets/{switch-h2SfQX4B.js → switch-BR30E4ej.js} +0 -0
  194. /package/dist/ui/dist/assets/{table-CVkIRJKK.js → table-B3aGEaVp.js} +0 -0
  195. /package/dist/ui/dist/assets/{tabs-C619jxbO.js → tabs-LQidMKRS.js} +0 -0
  196. /package/dist/ui/dist/assets/{terminal-DN38Q456.js → terminal--7G943As.js} +0 -0
  197. /package/dist/ui/dist/assets/{textarea-wvA-FDjO.js → textarea-B6Z1Zc6W.js} +0 -0
  198. /package/dist/ui/dist/assets/{trash-2-BHRa5ft9.js → trash-2-xD2o4SgX.js} +0 -0
  199. /package/dist/ui/dist/assets/{triangle-alert-D4nwAVbc.js → triangle-alert-pVIJGjga.js} +0 -0
  200. /package/dist/ui/dist/assets/{vendor-router-pCP7sjma.js → vendor-router-gqiZ7xhx.js} +0 -0
  201. /package/dist/ui/dist/assets/{volume-2-B6tkRy2u.js → volume-2-BekVQl6P.js} +0 -0
  202. /package/dist/ui/dist/assets/{zap-QO7iWMRg.js → zap-B4RaNNO5.js} +0 -0
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as t}from"./vendor-charts-Bu2lyBKP.js";import{o as n}from"./vendor-query-DsWPbQdG.js";import{t as r}from"./utils-3pnRFmFe.js";import{c as i,i as a,n as o,o as s,s as c,t as l}from"./select-Cl16QYa_.js";import{t as u}from"./circle-alert-CyHDwUj8.js";import{t as d}from"./cpu-DSpPVLAz.js";import{t as f}from"./external-link-CHPbUorN.js";import{t as p}from"./folder-open-iQMHVEqS.js";import{t as m}from"./loader-circle-CZNax6kS.js";import{t as h}from"./save-CUdYyHNy.js";import{t as g}from"./shield-C-05qB-2.js";import{t as _}from"./sparkles-D6fx8JC5.js";import{M as v,R as y,c as b,h as x,j as S,p as C,r as w,t as T,z as E}from"./index-CmGm_r89.js";import{t as D}from"./label-byJkqOYq.js";import{t as O}from"./textarea-wvA-FDjO.js";import{t as k}from"./switch-h2SfQX4B.js";import{a as A,c as j,i as M,n as N,o as P,r as F,s as I,t as L}from"./dialog-DfS3idb3.js";import{t as R}from"./badge-CxTPR6_t.js";import{a as z,n as B,o as V,r as H,t as U}from"./card-CXAm46at.js";import"./useProviders-eEri6BAc.js";var W=e(t(),1),G=n();function K({selectedProviderId:e,selectedModelId:t,onProviderChange:n,onModelChange:r,disabled:i=!1,typeFilter:u}){let{providers:d,models:f}=b(),p=w(e=>e.localLLM),m=w(e=>e.fetchLocalLLMStatus);(0,W.useEffect)(()=>{m()},[m]);let h=(0,W.useMemo)(()=>p?.models?new Set(p.models.filter(e=>e.downloaded).map(e=>e.id)):new Set,[p.models]),g=e=>{if(e.id===`ollama`)return!0;let t=e.base_url||e.baseUrl||``;return t.includes(`localhost`)||t.includes(`127.0.0.1`)?!0:!!e.has_api_key},_=e=>{if(e.id===`ollama`)return!0;let t=e.base_url||e.baseUrl||``;return t.includes(`localhost`)||t.includes(`127.0.0.1`)},v=d.filter(e=>(e.enabled||e.active)&&g(e)),x=d.find(t=>t.id===e),S=!!x&&!v.some(e=>e.id===x.id),C=(0,W.useMemo)(()=>e?f.filter(t=>{let n=(t.provider_id||t.providerId)===e,r=!u||t.model_type===u;return n&&r}):[],[e,f,u]),T=(0,W.useMemo)(()=>C.filter(e=>e.enabled||e.active),[C]),E=(e,t)=>t===`local-llama`?h.has(e):!0,O=C.find(e=>e.id===t),k=!!O&&!T.some(e=>e.id===O.id);(0,W.useEffect)(()=>{t&&C.length>0&&!C.find(e=>e.id===t)&&r(``)},[C,t,r]);let A=e=>{if(!e)return[];try{return JSON.parse(e)}catch{return[]}};return(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(D,{htmlFor:`provider`,children:`Proveedor de IA`}),(0,G.jsxs)(l,{value:e||``,onValueChange:n,disabled:i||v.length===0,children:[(0,G.jsx)(s,{id:`provider`,className:`w-full`,children:(0,G.jsx)(c,{placeholder:`Selecciona un proveedor`,children:e&&x?(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{children:x.name}),S&&(0,G.jsx)(`span`,{className:`text-[10px] text-amber-400/80`,children:`(inactivo)`}),_(x)?(0,G.jsx)(`span`,{className:`text-[9px] font-bold px-1.5 py-0.5 rounded-full bg-amber-500/20 text-amber-400`,children:`LOCAL`}):(0,G.jsx)(`span`,{className:`text-[9px] font-bold px-1.5 py-0.5 rounded-full bg-emerald-500/20 text-emerald-400`,children:`API`})]}):`Selecciona un proveedor`})}),(0,G.jsx)(o,{children:v.length===0?(0,G.jsx)(a,{value:`none`,disabled:!0,children:`No hay proveedores configurados`}):v.map(e=>(0,G.jsx)(a,{value:e.id,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{children:e.name}),_(e)?(0,G.jsx)(`span`,{className:`text-[9px] font-bold px-1.5 py-0.5 rounded-full bg-amber-500/20 text-amber-400`,children:`LOCAL`}):(0,G.jsx)(`span`,{className:`text-[9px] font-bold px-1.5 py-0.5 rounded-full bg-emerald-500/20 text-emerald-400`,children:`API`})]})},e.id))})]}),S&&x&&(0,G.jsxs)(`p`,{className:`text-[10px] text-amber-400/80`,children:[`El proveedor "`,x.name,`" está inactivo. Selecciona uno activo para cambiar.`]}),v.length===0&&(0,G.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Configura un proveedor en`,` `,(0,G.jsx)(`a`,{href:`/providers`,className:`text-primary underline`,children:`Settings > Providers`})]})]}),e&&(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(D,{htmlFor:`model`,children:`Modelo`}),(0,G.jsxs)(l,{value:t||``,onValueChange:t=>{let n=C.find(e=>e.id===t);if(n&&!E(n.id,e)){y.error(`"${n.name}" no está descargado`,{description:`Ve a Providers > Local LLM para descargarlo primero.`});return}r(t)},disabled:i||T.length===0,children:[(0,G.jsx)(s,{id:`model`,className:`w-full`,children:(0,G.jsx)(c,{placeholder:`Selecciona un modelo`,children:t&&O?(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{children:O.name}),k&&(0,G.jsx)(`span`,{className:`text-[10px] text-amber-400/80`,children:`(inactivo)`})]}):`Selecciona un modelo`})}),(0,G.jsx)(o,{children:T.length===0?(0,G.jsx)(a,{value:`none`,disabled:!0,children:`No hay modelos disponibles`}):T.map(t=>{let n=E(t.id,e);return(0,G.jsx)(a,{value:t.id,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{children:t.name}),t.contextWindow&&(0,G.jsxs)(R,{variant:`secondary`,className:`text-[10px]`,children:[(t.contextWindow/1e3).toFixed(0),`K ctx`]}),e===`local-llama`&&!n&&(0,G.jsx)(R,{variant:`destructive`,className:`text-[9px]`,children:`No descargado`})]})},t.id)})})]}),k&&O&&(0,G.jsxs)(`p`,{className:`text-[10px] text-amber-400/80`,children:[`El modelo "`,O.name,`" está inactivo. Selecciona uno activo para cambiar.`]}),t&&C.find(e=>e.id===t)&&(0,G.jsx)(U,{className:`mt-2`,children:(0,G.jsxs)(B,{className:`p-3 space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium`,children:C.find(e=>e.id===t)?.name}),(0,G.jsx)(R,{variant:`outline`,children:d.find(t=>t.id===e)?.name})]}),(()=>{let e=A(C.find(e=>e.id===t)?.capabilities);return e.length>0?(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.slice(0,5).map(e=>(0,G.jsx)(R,{variant:`secondary`,className:`text-[10px]`,children:e},e))}):null})()]})})]})]})}var ee=[{value:`friendly`,label:`Amigable`},{value:`professional`,label:`Profesional`},{value:`casual`,label:`Casual`},{value:`formal`,label:`Formal`},{value:`creative`,label:`Creativo`}];function q({initialData:e,onSuccess:t,onCancel:n}){let{createAgent:y,updateAgent:w,isLoading:R,error:q}=T(),{activeProviders:te}=b(),[J,Y]=(0,W.useState)({isValidating:!1,exists:!1,accessible:!1}),[X,Z]=(0,W.useState)({name:``,description:``,tone:`professional`,provider_id:``,model_id:``,role:`coordinator`,enabled:!0,systemPrompt:``,workspace:e?.workspace||``});(0,W.useEffect)(()=>{e&&Z({...e,provider_id:e.provider_id||e.providerId||``,model_id:e.model_id||e.modelId||``})},[e]);let Q=async e=>{if(!e||e.trim()===``){Y({isValidating:!1,exists:!1,accessible:!1});return}Y({isValidating:!0,exists:!1,accessible:!1});try{let t=await C(`/api/workspace/validate`,{method:`POST`,body:{path:e}});Y({isValidating:!1,exists:t.exists,accessible:t.accessible,error:t.error,message:t.message})}catch(e){Y({isValidating:!1,exists:!1,accessible:!1,error:e.message})}},ne=async()=>{if(X.workspace)try{await C(`/api/workspace/create`,{method:`POST`,body:{path:X.workspace},showLoader:`Creando directorio...`,showSuccess:`Directorio creado exitosamente`}),await Q(X.workspace)}catch(e){x.fire(`Error`,e.message,`error`)}},re=async()=>{if(X.workspace)try{await C(`/api/workspace/open?path=${encodeURIComponent(X.workspace)}`,{method:`GET`})}catch(e){x.fire(`Error`,e.message,`error`)}},ie=async n=>{if(n.preventDefault(),!X.provider_id||!X.model_id){x.fire(`Incompleto`,`Por favor selecciona un proveedor y modelo`,`warning`);return}try{e?.id?await w(e.id,X):await y(X),t&&t()}catch(e){console.error(e)}},$=!!e?.id;return(0,G.jsxs)(U,{className:`hive-card--form group`,children:[(0,G.jsx)(`div`,{className:`hive-glow-blob--card absolute -top-24 -right-24 h-48 w-48 bg-blue-600/10 group-hover:bg-blue-600/20`,style:{borderRadius:`50%`,filter:`blur(80px)`}}),(0,G.jsx)(z,{className:`relative`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(`div`,{className:`hive-icon-wrap hive-icon-wrap--primary`,children:$?(0,G.jsx)(h,{className:`h-5 w-5`}):(0,G.jsx)(_,{className:`h-5 w-5`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(V,{className:`text-xl font-bold text-white/90`,children:$?`Configurar Nodo`:`Desplegar Nuevo Nodo`}),(0,G.jsx)(H,{className:`text-white/40`,children:$?`Ajusta los parámetros de tu agente inteligente.`:`Crea una nueva entidad inteligente para tu colmena.`})]})]}),n&&(0,G.jsx)(v,{variant:`ghost`,size:`icon`,onClick:n,className:`text-white/40 hover:text-white hover:bg-white/5`,children:(0,G.jsx)(E,{className:`h-5 w-5`})})]})}),(0,G.jsx)(B,{className:`relative space-y-6 pt-2`,children:(0,G.jsxs)(`form`,{onSubmit:ie,className:`space-y-8`,children:[(0,G.jsxs)(`div`,{className:`grid gap-6`,children:[(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(D,{htmlFor:`name`,className:`hive-label--field`,children:`Nombre del Agente`}),(0,G.jsx)(S,{id:`name`,placeholder:`Ej: Analista de Mercado`,className:`hive-input`,value:X.name,onChange:e=>Z({...X,name:e.target.value}),disabled:R,required:!0})]}),(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(D,{htmlFor:`description`,className:`hive-label--field`,children:`Descripción / Rol`}),(0,G.jsx)(O,{id:`description`,placeholder:`Describe qué hace este agente y cuáles son sus objetivos...`,className:`hive-textarea`,value:X.description,onChange:e=>Z({...X,description:e.target.value}),disabled:R})]})]}),(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(D,{htmlFor:`systemPrompt`,className:`hive-label--field`,children:`System Prompt`}),(0,G.jsxs)(L,{children:[(0,G.jsx)(j,{asChild:!0,children:(0,G.jsx)(v,{type:`button`,variant:`outline`,size:`sm`,className:`h-7 px-3 text-xs bg-blue-500/10 hover:bg-blue-500/20 text-blue-400 border-blue-500/30 transition-colors`,children:`Modifica acá el System Prompt`})}),(0,G.jsxs)(F,{className:`sm:max-w-3xl bg-[#0a0a0c] border-white/10 text-white shadow-2xl [&>button]:text-white/50 hover:[&>button]:text-white`,children:[(0,G.jsxs)(P,{children:[(0,G.jsx)(I,{className:`text-xl`,children:`Editar System Prompt`}),(0,G.jsx)(M,{className:`text-sm text-white/50`,children:`El prompt base de comportamiento del agente. Se recomienda formato Markdown.`})]}),(0,G.jsx)(`div`,{className:`py-2`,children:(0,G.jsx)(O,{value:X.systemPrompt||``,onChange:e=>Z({...X,systemPrompt:e.target.value}),className:`min-h-[400px] font-mono text-sm bg-black/40 border-white/10 text-white/90 focus-visible:ring-blue-500/50 resize-y`,placeholder:`Escribe el system prompt detallado aquí...`,disabled:R})}),(0,G.jsx)(A,{children:(0,G.jsx)(N,{asChild:!0,children:(0,G.jsx)(v,{type:`button`,className:`bg-blue-600 hover:bg-blue-500 text-white shadow-[0_0_15px_rgba(37,99,235,0.3)]`,children:`Guardar Cambios`})})})]})]})]}),X.systemPrompt?(0,G.jsxs)(`p`,{className:`text-xs text-white/40 line-clamp-1 italic border border-white/5 bg-white/[0.02] p-2 rounded-md`,children:[`"`,X.systemPrompt,`"`]}):(0,G.jsx)(`p`,{className:`text-xs text-white/30 italic`,children:`Sin system prompt configurado...`})]}),(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,G.jsx)(p,{className:`h-4 w-4 text-emerald-400`}),(0,G.jsx)(`h3`,{className:`hive-title-section`,children:`Workspace Directory`})]}),(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(D,{htmlFor:`workspace`,className:`hive-label--field`,children:`Directorio de Trabajo del Agente`}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(S,{id:`workspace`,placeholder:`Ej: /home/user/proyectos, D:\\Work, /Volumes/USB`,className:`hive-input flex-1 font-mono text-sm`,value:X.workspace,onChange:e=>{Z({...X,workspace:e.target.value}),Q(e.target.value)},disabled:R}),X.workspace&&J.exists&&J.accessible&&(0,G.jsx)(v,{type:`button`,variant:`outline`,size:`icon`,onClick:re,className:`shrink-0 border-emerald-500/30 text-emerald-400 hover:bg-emerald-500/10`,title:`Abrir en el explorador`,children:(0,G.jsx)(f,{className:`h-4 w-4`})})]}),(0,G.jsx)(`p`,{className:`text-xs text-white/40 leading-relaxed`,children:`Directorio donde el agente creará archivos, carpetas y ejecutará comandos. Puede ser cualquier ubicación en tu sistema (disco duro, USB, red, etc.).`}),X.workspace&&X.workspace.trim()!==``&&(0,G.jsxs)(`div`,{className:r(`flex items-center gap-2 text-xs p-2.5 rounded-lg border backdrop-blur-md transition-all`,J.isValidating&&`bg-blue-500/10 border-blue-500/20 text-blue-400`,!J.isValidating&&J.exists&&J.accessible&&`bg-emerald-500/10 border-emerald-500/20 text-emerald-400`,!J.isValidating&&J.exists&&!J.accessible&&`bg-amber-500/10 border-amber-500/20 text-amber-400`,!J.isValidating&&!J.exists&&`bg-purple-500/10 border-purple-500/20 text-purple-400`),children:[J.isValidating&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(m,{className:`h-3.5 w-3.5 animate-spin`}),(0,G.jsx)(`span`,{children:`Validando directorio...`})]}),!J.isValidating&&J.exists&&J.accessible&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(i,{className:`h-3.5 w-3.5`}),(0,G.jsx)(`span`,{children:J.message||`Directorio válido y accesible`})]}),!J.isValidating&&J.exists&&!J.accessible&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(u,{className:`h-3.5 w-3.5`}),(0,G.jsx)(`span`,{children:J.message||`El directorio existe pero no tiene permisos de lectura/escritura`})]}),!J.isValidating&&!J.exists&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(p,{className:`h-3.5 w-3.5`}),(0,G.jsx)(`span`,{children:J.message||`El directorio no existe`}),!J.error&&(0,G.jsx)(v,{type:`button`,variant:`outline`,size:`sm`,onClick:ne,className:`ml-auto h-6 px-2 text-xs bg-purple-500/20 hover:bg-purple-500/30 text-purple-300 border-purple-500/30`,children:`Crear directorio`})]})]})]})]}),(0,G.jsx)(`div`,{className:`hive-card-divider`}),(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,G.jsx)(d,{className:`h-4 w-4 text-blue-400`}),(0,G.jsx)(`h3`,{className:`hive-title-section`,children:`Motor de Inteligencia`})]}),(0,G.jsx)(K,{selectedProviderId:X.provider_id||void 0,selectedModelId:X.model_id||void 0,onProviderChange:e=>Z({...X,provider_id:e,model_id:``}),onModelChange:e=>Z({...X,model_id:e}),disabled:R,typeFilter:`llm`})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:[(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(D,{htmlFor:`tone`,className:`hive-label--field`,children:`Tono de Voz`}),(0,G.jsxs)(l,{value:X.tone,onValueChange:e=>Z({...X,tone:e}),disabled:R,children:[(0,G.jsx)(s,{className:`hive-select-trigger`,children:(0,G.jsx)(c,{placeholder:`Selecciona un tono`})}),(0,G.jsx)(o,{className:`hive-select-content`,children:ee.map(e=>(0,G.jsx)(a,{value:e.value,className:`hive-select-item`,children:e.label},e.value))})]})]}),(0,G.jsxs)(`div`,{className:`hive-toggle-panel`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(g,{className:`h-3.5 w-3.5 text-purple-400`}),(0,G.jsx)(D,{htmlFor:`role`,className:`text-xs font-medium text-white/70`,children:`Rol`})]}),(0,G.jsxs)(l,{value:X.role,onValueChange:e=>Z({...X,role:e}),disabled:R,children:[(0,G.jsx)(s,{className:`w-[120px] bg-white/5 border-white/10 text-white`,children:(0,G.jsx)(c,{})}),(0,G.jsxs)(o,{className:`bg-zinc-900 border-white/10`,children:[(0,G.jsx)(a,{value:`coordinator`,children:`Coordinador`}),(0,G.jsx)(a,{value:`worker`,children:`Worker`})]})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`div`,{className:`h-2 w-2 rounded-full ${X.enabled?`bg-blue-400`:`bg-zinc-600`}`}),(0,G.jsx)(D,{htmlFor:`enabled`,className:`text-xs font-medium text-white/70`,children:`Habilitado`})]}),(0,G.jsx)(k,{id:`enabled`,checked:X.enabled,onCheckedChange:e=>Z({...X,enabled:e}),disabled:R})]})]})]}),q&&(0,G.jsx)(`div`,{className:`hive-form-error`,children:q}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3 pt-4`,children:[n&&(0,G.jsx)(v,{type:`button`,variant:`outline`,onClick:n,disabled:R,className:`hive-btn--form-cancel`,children:`Cancelar`}),(0,G.jsx)(v,{type:`submit`,disabled:R,className:`hive-btn--form-submit`,children:R?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(m,{className:`mr-2 h-4 w-4 animate-spin`}),`Procesando...`]}):(0,G.jsx)(G.Fragment,{children:$?`Actualizar Agente`:`Desplegar Agente`})})]})]})})]})}export{q as t};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as t}from"./vendor-charts-Bu2lyBKP.js";import{o as n}from"./vendor-query-DsWPbQdG.js";import{r,t as i}from"./utils-3pnRFmFe.js";import{t as a}from"./activity-c3pNngT_.js";import{t as o}from"./calendar-B-KZ9RQO.js";import{c as s,i as c,n as l,o as u,s as d,t as f}from"./select-Cl16QYa_.js";import{t as p}from"./chevron-left-D4U-5A27.js";import{t as ee}from"./circle-alert-CyHDwUj8.js";import{t as m}from"./cpu-DSpPVLAz.js";import{t as te}from"./external-link-CHPbUorN.js";import{t as h}from"./folder-open-iQMHVEqS.js";import{t as ne}from"./loader-circle-CZNax6kS.js";import{t as re}from"./save-CUdYyHNy.js";import{t as ie}from"./shield-C-05qB-2.js";import{t as ae}from"./sparkles-D6fx8JC5.js";import{t as g}from"./zap-QO7iWMRg.js";import{c as _,l as v}from"./vendor-router-pCP7sjma.js";import{H as oe,J as se,M as y,c as b,g as x,j as S,m as C,p as w,s as T,t as E}from"./index-CmGm_r89.js";import{t as D}from"./label-byJkqOYq.js";import{t as O}from"./textarea-wvA-FDjO.js";import{t as k}from"./switch-h2SfQX4B.js";import{a as A,c as j,i as M,n as N,o as P,r as F,s as ce,t as le}from"./dialog-DfS3idb3.js";import{t as I}from"./badge-CxTPR6_t.js";import{n as L,t as R}from"./es-Cz5h9_84.js";import{t as z}from"./format-oFACFaca.js";var B=r(`Fingerprint`,[[`path`,{d:`M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4`,key:`1nerag`}],[`path`,{d:`M14 13.12c0 2.38 0 6.38-1 8.88`,key:`o46ks0`}],[`path`,{d:`M17.29 21.02c.12-.6.43-2.3.5-3.02`,key:`ptglia`}],[`path`,{d:`M2 12a10 10 0 0 1 18-6`,key:`ydlgp0`}],[`path`,{d:`M2 16h.01`,key:`1gqxmh`}],[`path`,{d:`M21.8 16c.2-2 .131-5.354 0-6`,key:`drycrb`}],[`path`,{d:`M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2`,key:`1tidbn`}],[`path`,{d:`M8.65 22c.21-.66.45-1.32.57-2`,key:`13wd9y`}],[`path`,{d:`M9 6.8a6 6 0 0 1 9 5.2v2`,key:`1fr1j5`}]]),V=r(`LayoutGrid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),H=e(t(),1),U=n();function W({icon:e,...t}){return(0,U.jsx)(e,{...t})}function G({agentId:e}){let{agents:t,updateAgent:n,fetchAgents:r}=E(),{providers:o,fetchProviders:p}=b(),{models:m,fetchModels:g}=T();(0,H.useEffect)(()=>{r(),p(),g()},[r,p,g]);let _=t.find(t=>t.id===e),[v,I]=(0,H.useState)({name:``,description:``,provider_id:``,model_id:``,tone:``,role:`coordinator`,enabled:!0,headers:``,systemPrompt:``,workspace:``}),[L,R]=(0,H.useState)({isValidating:!1,exists:!1,accessible:!1});(0,H.useEffect)(()=>{_&&(I({name:_.name||``,description:_.description||``,provider_id:_.provider_id||_.providerId||``,model_id:_.model_id||_.modelId||``,tone:_.tone||``,role:_.role||`coordinator`,enabled:!!_.enabled,headers:``,systemPrompt:_.systemPrompt||``,workspace:_.workspace||``}),_.workspace&&z(_.workspace))},[_]);let z=async e=>{if(!e||e.trim()===``){R({isValidating:!1,exists:!1,accessible:!1});return}R({isValidating:!0,exists:!1,accessible:!1});try{let t=await w(`/api/workspace/validate`,{method:`POST`,body:{path:e}});R({isValidating:!1,exists:t.exists,accessible:t.accessible,error:t.error,message:t.message})}catch(e){R({isValidating:!1,exists:!1,accessible:!1,error:e.message})}},B=async()=>{if(v.workspace)try{await w(`/api/workspace/create`,{method:`POST`,body:{path:v.workspace},showLoader:`Creando directorio...`,showSuccess:`Directorio creado exitosamente`}),await z(v.workspace)}catch(e){C.fire({icon:`error`,title:e.message})}},V=async()=>{if(v.workspace)try{await w(`/api/workspace/open?path=${encodeURIComponent(v.workspace)}`,{method:`GET`})}catch(e){C.fire({icon:`error`,title:e.message})}},G=async()=>{x.show(`Sincronizando configuración del agente...`);try{await n(e,{...v,role:v.role,enabled:+!!v.enabled,workspace:v.workspace||null}),C.fire({icon:`success`,title:`Cambios sincronizados correctamente`})}catch(e){C.fire({icon:`error`,title:e instanceof Error?e.message:`Error al sincronizar cambios`})}finally{x.hide()}};if(!_)return(0,U.jsxs)(`div`,{className:`flex flex-col items-center justify-center p-12 text-center space-y-4 rounded-3xl border border-dashed border-white/10 bg-white/5`,children:[(0,U.jsx)(W,{icon:a,className:`h-12 w-12 text-white/10 animate-pulse`}),(0,U.jsx)(`p`,{className:`text-white/40 font-medium`,children:`Buscando nodo en la colmena...`})]});let K=e=>{if(e.id===`ollama`)return!0;let t=e.base_url||e.baseUrl||``;return t.includes(`localhost`)||t.includes(`127.0.0.1`)?!0:!!e.has_api_key},q=e=>{if(e.id===`ollama`)return!0;let t=e.base_url||e.baseUrl||``;return t.includes(`localhost`)||t.includes(`127.0.0.1`)},J=o.filter(e=>(e.enabled||e.active)&&K(e)),Y=m.filter(e=>(e.provider_id||e.providerId)===v.provider_id&&(e.enabled||e.active)),X=o.find(e=>e.id===v.provider_id),Z=!!X&&!J.some(e=>e.id===X.id),Q=m.filter(e=>(e.provider_id||e.providerId)===v.provider_id).find(e=>e.id===v.model_id),$=!!Q&&!Y.some(e=>e.id===Q.id);return(0,U.jsx)(`div`,{className:`space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-500`,children:(0,U.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-8`,children:[(0,U.jsxs)(`div`,{className:`lg:col-span-1 space-y-6`,children:[(0,U.jsxs)(`div`,{className:`p-6 rounded-3xl border border-white/10 bg-black/20 backdrop-blur-md space-y-6`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(`div`,{className:`p-2 rounded-xl bg-blue-500/10 border border-blue-500/20`,children:(0,U.jsx)(W,{icon:oe,className:`h-4 w-4 text-blue-400`})}),(0,U.jsx)(`h3`,{className:`font-bold text-white uppercase tracking-wider text-xs`,children:`Identidad Base`})]}),(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(D,{htmlFor:`name`,className:`text-xs text-white/40 uppercase tracking-widest pl-1`,children:`Nombre Público`}),(0,U.jsx)(S,{id:`name`,value:v.name,onChange:e=>I(t=>({...t,name:e.target.value})),className:`bg-white/5 border-white/10 focus:border-blue-500/50 rounded-xl h-11`,placeholder:`Nombre del nodo`})]}),(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(D,{htmlFor:`tone`,className:`text-xs text-white/40 uppercase tracking-widest pl-1`,children:`Tono Cognitivo`}),(0,U.jsx)(S,{id:`tone`,value:v.tone,onChange:e=>I(t=>({...t,tone:e.target.value})),className:`bg-white/5 border-white/10 focus:border-blue-500/50 rounded-xl h-11`,placeholder:`Ej: Analítico, Conciso...`})]})]})]}),(0,U.jsxs)(`div`,{className:`p-6 rounded-3xl border border-white/10 bg-black/20 backdrop-blur-md space-y-6`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(`div`,{className:`p-2 rounded-xl bg-purple-500/10 border border-purple-500/20`,children:(0,U.jsx)(W,{icon:ie,className:`h-4 w-4 text-purple-400`})}),(0,U.jsx)(`h3`,{className:`font-bold text-white uppercase tracking-wider text-xs`,children:`Permisos de Red`})]}),(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between p-3 rounded-2xl bg-white/5 hover:bg-white/10 transition-colors`,children:[(0,U.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,U.jsx)(D,{className:`text-sm font-semibold`,children:`Rol`}),(0,U.jsx)(`p`,{className:`text-[10px] text-white/30`,children:`Coordinador o Worker`})]}),(0,U.jsxs)(f,{value:v.role,onValueChange:e=>I(t=>({...t,role:e})),children:[(0,U.jsx)(u,{className:`w-[120px] bg-white/5 border-white/10 text-white`,children:(0,U.jsx)(d,{})}),(0,U.jsxs)(l,{className:`bg-zinc-900 border-white/10`,children:[(0,U.jsx)(c,{value:`coordinator`,children:`Coordinador`}),(0,U.jsx)(c,{value:`worker`,children:`Worker`})]})]})]}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between p-3 rounded-2xl bg-white/5 hover:bg-white/10 transition-colors`,children:[(0,U.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,U.jsx)(D,{className:`text-sm font-semibold`,children:`Nodo Activo`}),(0,U.jsx)(`p`,{className:`text-[10px] text-white/30`,children:`Disponible para la colmena`})]}),(0,U.jsx)(k,{checked:v.enabled,onCheckedChange:e=>I(t=>({...t,enabled:e}))})]})]})]}),(0,U.jsxs)(`div`,{className:`p-6 rounded-3xl border border-white/10 bg-black/20 backdrop-blur-md space-y-6`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(`div`,{className:`p-2 rounded-xl bg-emerald-500/10 border border-emerald-500/20`,children:(0,U.jsx)(W,{icon:h,className:`h-4 w-4 text-emerald-400`})}),(0,U.jsx)(`h3`,{className:`font-bold text-white uppercase tracking-wider text-xs`,children:`Workspace Directory`})]}),(0,U.jsx)(`div`,{className:`space-y-4`,children:(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(D,{htmlFor:`workspace`,className:`text-xs text-white/40 uppercase tracking-widest pl-1`,children:`Directorio de Trabajo`}),(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(S,{id:`workspace`,value:v.workspace,onChange:e=>{I(t=>({...t,workspace:e.target.value})),z(e.target.value)},className:`bg-white/5 border-white/10 focus:border-emerald-500/50 rounded-xl h-11 font-mono text-sm flex-1`,placeholder:`Ej: /home/user/proyectos, D:\\Work`}),v.workspace&&L.exists&&L.accessible&&(0,U.jsx)(y,{type:`button`,variant:`outline`,size:`icon`,onClick:V,className:`shrink-0 border-emerald-500/30 text-emerald-400 hover:bg-emerald-500/10 h-11 w-11`,title:`Abrir en el explorador`,children:(0,U.jsx)(te,{className:`h-4 w-4`})})]}),(0,U.jsx)(`p`,{className:`text-xs text-white/40 leading-relaxed`,children:`Directorio donde el agente operará. Puede ser cualquier ubicación (disco, USB, red).`}),v.workspace&&v.workspace.trim()!==``&&(0,U.jsxs)(`div`,{className:i(`flex items-center gap-2 text-xs p-2.5 rounded-lg border backdrop-blur-md transition-all`,L.isValidating&&`bg-blue-500/10 border-blue-500/20 text-blue-400`,!L.isValidating&&L.exists&&L.accessible&&`bg-emerald-500/10 border-emerald-500/20 text-emerald-400`,!L.isValidating&&L.exists&&!L.accessible&&`bg-amber-500/10 border-amber-500/20 text-amber-400`,!L.isValidating&&!L.exists&&`bg-purple-500/10 border-purple-500/20 text-purple-400`),children:[L.isValidating&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(ne,{className:`h-3.5 w-3.5 animate-spin`}),(0,U.jsx)(`span`,{children:`Validando directorio...`})]}),!L.isValidating&&L.exists&&L.accessible&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(s,{className:`h-3.5 w-3.5`}),(0,U.jsx)(`span`,{children:L.message||`Directorio válido y accesible`})]}),!L.isValidating&&L.exists&&!L.accessible&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(ee,{className:`h-3.5 w-3.5`}),(0,U.jsx)(`span`,{children:L.message||`Sin permisos de lectura/escritura`})]}),!L.isValidating&&!L.exists&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(h,{className:`h-3.5 w-3.5`}),(0,U.jsx)(`span`,{children:L.message||`El directorio no existe`}),!L.error&&(0,U.jsx)(y,{type:`button`,variant:`outline`,size:`sm`,onClick:B,className:`ml-auto h-6 px-2 text-xs bg-purple-500/20 hover:bg-purple-500/30 text-purple-300 border-purple-500/30`,children:`Crear`})]})]})]})})]})]}),(0,U.jsx)(`div`,{className:`lg:col-span-2 space-y-6`,children:(0,U.jsxs)(`div`,{className:`p-8 rounded-3xl border border-white/10 bg-black/20 backdrop-blur-md space-y-8`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(`div`,{className:`p-2 rounded-xl bg-amber-500/10 border border-amber-500/20`,children:(0,U.jsx)(W,{icon:ae,className:`h-4 w-4 text-amber-400`})}),(0,U.jsx)(`h3`,{className:`font-bold text-white uppercase tracking-wider text-xs`,children:`Configuración Cognitiva`})]}),(0,U.jsxs)(y,{onClick:G,className:`bg-blue-600 hover:bg-blue-500 text-white font-bold rounded-xl px-6 shadow-[0_4px_15px_rgba(37,99,235,0.3)] transition-all active:scale-95 gap-2`,children:[(0,U.jsx)(W,{icon:re,className:`h-4 w-4`}),`Sincronizar Cambios`]})]}),(0,U.jsxs)(`div`,{className:`space-y-6`,children:[(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(D,{htmlFor:`description`,className:`text-xs text-white/40 uppercase tracking-widest pl-1`,children:`Directiva de Misión (Descripción)`}),(0,U.jsx)(O,{id:`description`,value:v.description,onChange:e=>I(t=>({...t,description:e.target.value})),className:`bg-white/5 border-white/10 focus:border-blue-500/50 rounded-2xl min-h-[80px] resize-none`,placeholder:`Define el propósito general de este nodo...`})]}),(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between pl-1`,children:[(0,U.jsx)(D,{className:`text-xs text-white/40 uppercase tracking-widest`,children:`System Prompt (Markdown)`}),(0,U.jsxs)(le,{children:[(0,U.jsx)(j,{asChild:!0,children:(0,U.jsx)(y,{type:`button`,variant:`outline`,size:`sm`,className:`h-7 px-3 text-xs bg-blue-500/10 hover:bg-blue-500/20 text-blue-400 border-blue-500/30 transition-colors`,children:`Modifica acá el System Prompt`})}),(0,U.jsxs)(F,{className:`sm:max-w-3xl bg-[#0a0a0c] border-white/10 text-white shadow-2xl [&>button]:text-white/50 hover:[&>button]:text-white`,children:[(0,U.jsxs)(P,{children:[(0,U.jsx)(ce,{className:`text-xl`,children:`Editar System Prompt`}),(0,U.jsx)(M,{className:`text-sm text-white/50`,children:`El comportamiento principal del agente. Se recomienda usar Markdown.`})]}),(0,U.jsx)(`div`,{className:`py-2`,children:(0,U.jsx)(O,{value:v.systemPrompt,onChange:e=>I(t=>({...t,systemPrompt:e.target.value})),className:`min-h-[400px] font-mono text-sm bg-black/40 border-white/10 text-white/90 focus-visible:ring-blue-500/50 resize-y`,placeholder:`Escribe el system prompt detallado aquí...`})}),(0,U.jsx)(A,{children:(0,U.jsx)(N,{asChild:!0,children:(0,U.jsx)(y,{type:`button`,className:`bg-blue-600 hover:bg-blue-500 text-white shadow-[0_0_15px_rgba(37,99,235,0.3)]`,children:`Listo`})})})]})]})]}),v.systemPrompt?(0,U.jsx)(`div`,{className:`bg-white/[0.02] border border-white/5 rounded-2xl p-4 max-h-[120px] overflow-y-auto custom-scrollbar`,children:(0,U.jsx)(`p`,{className:`text-xs text-white/60 font-mono whitespace-pre-wrap italic`,children:v.systemPrompt})}):(0,U.jsx)(`div`,{className:`bg-white/[0.02] border border-white/5 rounded-2xl p-4`,children:(0,U.jsx)(`p`,{className:`text-xs text-white/30 italic`,children:`Sin system prompt configurado...`})})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:[(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between pl-1`,children:[(0,U.jsx)(D,{className:`text-xs text-white/40 uppercase tracking-widest`,children:`Proveedor`}),J.length===0&&(0,U.jsx)(`span`,{className:`text-[10px] text-amber-400/80`,children:`Sin providers activos`})]}),(0,U.jsxs)(f,{value:v.provider_id,onValueChange:e=>I(t=>({...t,provider_id:e,model_id:``})),children:[(0,U.jsx)(u,{className:`bg-white/5 border-white/10 rounded-xl h-11`,children:(0,U.jsx)(d,{placeholder:`Seleccionar proveedor`,children:v.provider_id&&X?(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`span`,{children:X.name}),Z&&(0,U.jsx)(`span`,{className:`text-[10px] text-amber-400/80`,children:`(inactivo)`}),q(X)?(0,U.jsx)(`span`,{className:`text-[9px] font-bold px-1.5 py-0.5 rounded-full bg-amber-500/20 text-amber-400`,children:`LOCAL`}):(0,U.jsx)(`span`,{className:`text-[9px] font-bold px-1.5 py-0.5 rounded-full bg-emerald-500/20 text-emerald-400`,children:`API`})]}):`Seleccionar proveedor`})}),(0,U.jsxs)(l,{className:`bg-zinc-900 border-white/10 text-white`,children:[J.length===0&&(0,U.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-white/30`,children:`Activa al menos un provider con API key en la sección de Providers`}),J.map(e=>{let t=q(e);return(0,U.jsx)(c,{value:e.id,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`span`,{children:e.name}),(0,U.jsx)(`span`,{className:`text-[9px] font-bold px-1.5 py-0.5 rounded-full ${t?`bg-amber-500/20 text-amber-400`:`bg-emerald-500/20 text-emerald-400`}`,children:t?`LOCAL`:`API`})]})},e.id)})]})]}),Z&&X&&(0,U.jsxs)(`p`,{className:`text-[10px] text-amber-400/80 pl-1`,children:[`El proveedor "`,X.name,`" está inactivo. Selecciona uno activo para cambiar.`]})]}),(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between pl-1`,children:[(0,U.jsx)(D,{className:`text-xs text-white/40 uppercase tracking-widest`,children:`Modelo`}),v.provider_id&&Y.length===0&&(0,U.jsx)(`span`,{className:`text-[10px] text-amber-400/80`,children:`Sin modelos activos`})]}),(0,U.jsxs)(f,{value:v.model_id,onValueChange:e=>I(t=>({...t,model_id:e})),disabled:!v.provider_id||Y.length===0,children:[(0,U.jsx)(u,{className:`bg-white/5 border-white/10 rounded-xl h-11 disabled:opacity-50`,children:(0,U.jsx)(d,{placeholder:v.provider_id?Y.length===0?`Activa modelos en el provider`:`Seleccionar modelo`:`Primero selecciona un proveedor`,children:v.model_id&&Q?(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`font-mono text-sm`,children:Q.name}),$&&(0,U.jsx)(`span`,{className:`text-[10px] text-amber-400/80`,children:`(inactivo)`})]}):void 0})}),(0,U.jsx)(l,{className:`bg-zinc-900 border-white/10 text-white`,children:Y.map(e=>(0,U.jsx)(c,{value:e.id,children:(0,U.jsx)(`span`,{className:`font-mono text-sm`,children:e.name})},e.id))})]}),$&&Q&&(0,U.jsxs)(`p`,{className:`text-[10px] text-amber-400/80 pl-1`,children:[`El modelo "`,Q.name,`" está inactivo. Selecciona uno activo para cambiar.`]})]})]})]}),(0,U.jsxs)(`div`,{className:`mt-8 p-4 rounded-2xl bg-white/[0.03] border border-white/5 flex items-start gap-4 italic`,children:[(0,U.jsx)(W,{icon:se,className:`h-5 w-5 text-white/20 mt-0.5`}),(0,U.jsx)(`p`,{className:`text-[11px] text-white/30 leading-relaxed`,children:`Las credenciales de acceso y llaves de cifrado para los headers personalizados se gestionan en una capa segura y no son visibles en texto plano para mantener la integridad de la red.`})]})]})})]})})}function K({agent:e}){let{providers:t}=b(),{models:n}=T(),r=e.role===`coordinator`,i=e.provider_id||e.providerId,s=e.model_id||e.modelId,c=e.created_at||e.createdAt,l=c?z(typeof c==`string`?new Date(c):new Date(c*1e3),`PPP`,{locale:R}):`Fecha desconocida`,u=t.find(e=>e.id===i)?.name||i,d=n.find(e=>e.id===s)?.name||s;return(0,U.jsxs)(`div`,{className:`hive-card--internal group ${e.enabled?`hive-card--internal-active`:`hive-card--internal-disabled`}`,children:[e.enabled&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{className:`absolute -top-24 -right-24 h-64 w-64 bg-blue-600/10 rounded-full blur-[100px] pointer-events-none group-hover:bg-blue-600/20 transition-all duration-700`}),(0,U.jsx)(`div`,{className:`absolute -bottom-24 -left-24 h-64 w-64 bg-purple-600/10 rounded-full blur-[100px] pointer-events-none group-hover:bg-purple-600/20 transition-all duration-700`})]}),(0,U.jsxs)(`div`,{className:`relative flex flex-col md:flex-row gap-8 items-start justify-between`,children:[(0,U.jsxs)(`div`,{className:`flex-1 space-y-6`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(`div`,{className:`hive-icon-wrap--internal ${e.enabled?`hive-icon-wrap--internal-active`:`hive-icon-wrap--internal-disabled`}`,children:(0,U.jsx)(B,{className:`h-6 w-6 ${e.enabled?`text-blue-400`:`text-white/20`}`})}),(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,U.jsx)(`span`,{className:`hive-page-header__label ${!e.enabled&&`text-white/20`}`,children:`Identidad de Nodo`}),r&&(0,U.jsx)(I,{className:`hive-tag--coordinator ${!e.enabled&&`bg-white/5 text-white/20 border-white/10`}`,children:`Coordinador`})]}),(0,U.jsx)(`h1`,{className:`text-4xl font-black tracking-tighter ${e.enabled?`text-white`:`text-white/40`}`,children:e.name})]})]}),(0,U.jsxs)(`p`,{className:`text-lg leading-relaxed max-w-2xl font-light italic ${e.enabled?`text-white/60`:`text-white/20`}`,children:[`"`,e.description||`Este agente no tiene una descripción definida aún.`,`"`]})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4`,children:[(0,U.jsx)(q,{icon:m,label:`Infraestructura`,value:u,subValue:d,color:e.enabled?`text-blue-400`:`text-white/20`,enabled:e.enabled}),(0,U.jsx)(q,{icon:g,label:`Personalidad`,value:e.tone||`Neutral`,color:e.enabled?`text-purple-400`:`text-white/20`,enabled:e.enabled}),(0,U.jsx)(q,{icon:o,label:`Desplegado el`,value:l,color:e.enabled?`text-emerald-400`:`text-white/20`,enabled:e.enabled})]})]}),(0,U.jsxs)(`div`,{className:`flex flex-col items-center md:items-end gap-6 min-w-[200px]`,children:[(0,U.jsxs)(`div`,{className:`text-center md:text-right space-y-2`,children:[(0,U.jsx)(`span`,{className:`hive-label block`,children:`Estado Operativo`}),(0,U.jsx)(L,{status:e.enabled?e.status:`hibernated`,className:`px-6 py-2 text-sm border-2`})]}),(0,U.jsxs)(`div`,{className:`hive-network-panel md:w-auto`,children:[(0,U.jsxs)(`div`,{className:`flex-1`,children:[(0,U.jsx)(`p`,{className:`hive-label mb-1`,children:`Carga de Red`}),(0,U.jsx)(`div`,{className:`hive-network-track`,children:e.enabled&&(0,U.jsx)(`div`,{className:`hive-network-fill`})})]}),(0,U.jsx)(a,{className:`h-5 w-5 ${e.enabled?`text-blue-400 animate-pulse`:`text-white/10`}`})]})]})]}),(0,U.jsx)(`div`,{className:`hive-strip--bottom ${!e.enabled&&`opacity-20`}`}),(0,U.jsxs)(`div`,{className:`absolute top-4 right-8 hive-mono hidden md:block`,children:[`NODE_UID: `,e.id]})]})}function q({icon:e,label:t,value:n,subValue:r,color:i,enabled:a}){return(0,U.jsxs)(`div`,{className:`hive-info-card ${a?`hive-info-card--active`:`hive-info-card--disabled`}`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,U.jsx)(e,{className:`h-3.5 w-3.5 ${i}`}),(0,U.jsx)(`span`,{className:`hive-info-card__label`,children:t})]}),(0,U.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,U.jsx)(`p`,{className:`hive-info-card__value ${a?`text-white/80 group-hover/item:text-white`:`text-white/20`}`,children:n}),r&&(0,U.jsx)(`p`,{className:`hive-info-card__sub ${a?`text-white/40`:`text-white/10`}`,children:r})]})]})}function J(){let{id:e}=v(),t=_(),n=e??`unknown`,{agents:r,fetchAgents:i,isLoading:o}=E();(0,H.useEffect)(()=>{i()},[i]);let s=r.find(e=>e.id===n);return(0,U.jsx)(`div`,{className:`min-h-screen bg-transparent pb-20`,children:(0,U.jsxs)(`div`,{className:`max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8 animate-in fade-in slide-in-from-bottom-4 duration-700`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between mb-8`,children:[(0,U.jsxs)(y,{variant:`ghost`,onClick:()=>t(`/agents`),className:`group flex items-center gap-2 text-white/40 hover:text-white hover:bg-white/5 px-4 py-2 rounded-xl transition-all`,children:[(0,U.jsx)(p,{className:`h-4 w-4 transition-transform group-hover:-translate-x-1`}),(0,U.jsx)(`span`,{className:`text-sm font-bold uppercase tracking-widest`,children:`Volver a la Colmena`})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-4 text-white/20`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(V,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest`,children:`Agentes`})]}),(0,U.jsx)(`div`,{className:`h-4 w-px bg-white/10`}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(a,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest`,children:`Detalles Operativos`})]})]})]}),s?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(K,{agent:s}),(0,U.jsx)(`div`,{className:`grid grid-cols-1 gap-8`,children:(0,U.jsx)(G,{agentId:n})})]}):(0,U.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-[60vh] text-center space-y-6`,children:[(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(`div`,{className:`h-24 w-24 rounded-full border-4 border-t-blue-500 border-white/5 animate-spin`}),(0,U.jsx)(a,{className:`absolute inset-0 m-auto h-8 w-8 text-blue-400 animate-pulse`})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h3`,{className:`text-xl font-bold text-white mb-2`,children:`Sincronizando con el Nodo`}),(0,U.jsx)(`p`,{className:`text-white/40 max-w-xs mx-auto`,children:`Estamos recuperando la configuración cuántica de este agente desde la base de datos central.`})]})]})]})})}export{J as AgentDetailPage};
@@ -1 +0,0 @@
1
- import{o as e}from"./vendor-query-DsWPbQdG.js";import{t}from"./AgentCreateForm-BTCzFbca.js";var n=e();function r(){return(0,n.jsx)(t,{})}export{r as AgentNewPage};
@@ -1,3 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as t}from"./vendor-charts-Bu2lyBKP.js";import{o as n}from"./vendor-query-DsWPbQdG.js";import{t as r}from"./utils-3pnRFmFe.js";import{i,n as a,o,s,t as ee}from"./select-Cl16QYa_.js";import{n as c}from"./chevron-up-BYhk0K2J.js";import{t as l}from"./chevron-right-CR4Skrf3.js";import{t as te}from"./circle-check-Bb54Ebmu.js";import{t as u}from"./circle-x-Bv6WrUJo.js";import{t as d}from"./copy-dU94ZGsi.js";import{t as f}from"./history-BSG-Ypqf.js";import{t as ne}from"./plus-CX1xyhp5.js";import{t as re}from"./send-BuQcUO-R.js";import{t as p}from"./trash-2-BHRa5ft9.js";import{J as m,M as h,Y as g,j as _,p as v}from"./index-CmGm_r89.js";import{t as y}from"./textarea-wvA-FDjO.js";import{t as b}from"./badge-CxTPR6_t.js";import{a as x,n as S,o as C,t as w}from"./card-CXAm46at.js";import{i as T,n as E,r as D,t as O}from"./tabs-C619jxbO.js";import{t as k}from"./scroll-area-BXtLsE9E.js";var A=e(t(),1),j=n(),ie=[`GET`,`POST`,`PUT`,`DELETE`,`PATCH`,`HEAD`,`OPTIONS`];function M(){return Math.random().toString(36).substring(2,9)}function N(){return{id:M(),key:``,value:``,enabled:!0}}function P(){let[e,t]=(0,A.useState)(`GET`),[n,P]=(0,A.useState)(``),[F,I]=(0,A.useState)([N()]),[L,R]=(0,A.useState)([N()]),[z,B]=(0,A.useState)(``),[V,H]=(0,A.useState)(null),[U,W]=(0,A.useState)(!1),[G,K]=(0,A.useState)(0),[q,J]=(0,A.useState)([]),[Y,ae]=(0,A.useState)(!1),[oe,se]=(0,A.useState)(`body`);(0,A.useEffect)(()=>{try{let e=localStorage.getItem(`hive-api-client-history`);e&&J(JSON.parse(e))}catch{}},[]);let ce=(0,A.useCallback)(e=>{localStorage.setItem(`hive-api-client-history`,JSON.stringify(e.slice(0,50)))},[]),X=(e,t,n,r,i)=>{t(e.map(e=>e.id===n?{...e,[r]:i}:e))},le=(e,t)=>{t([...e,N()])},ue=(e,t,n)=>{e.length===1?t([N()]):t(e.filter(e=>e.id!==n))},Z=()=>{let e={};for(let t of F)t.enabled&&t.key.trim()&&(e[t.key.trim()]=t.value);return e},de=()=>{let e={};for(let t of L)t.enabled&&t.key.trim()&&(e[t.key.trim()]=t.value);return e},Q=async()=>{if(!n.trim())return;W(!0),H(null);let t=performance.now();try{let r={method:e,url:n.trim(),headers:Z(),query_params:de()};z.trim()&&e!==`GET`&&e!==`HEAD`&&(r.body=z.trim());let i=await v(`/api/http-request`,{method:`POST`,body:r,showError:!1});K(Math.round(performance.now()-t)),H(i);let a=[{id:M(),method:e,url:n.trim(),timestamp:Date.now(),status:i.status,ok:i.ok},...q];J(a),ce(a)}catch(e){K(Math.round(performance.now()-t)),H({ok:!1,error:e.message||`Request failed`})}finally{W(!1)}},fe=e=>{t(e.method),P(e.url),H(null)},pe=e=>{navigator.clipboard.writeText(e)},me=e=>{if(e==null)return``;if(typeof e==`string`)try{let t=JSON.parse(e);return JSON.stringify(t,null,2)}catch{return e}return JSON.stringify(e,null,2)},he=e=>e?e>=200&&e<300?`bg-green-500`:e>=300&&e<400?`bg-yellow-500`:e>=400&&e<500?`bg-orange-500`:`bg-red-500`:`bg-gray-500`,$=(e,t,n,r)=>(0,j.jsxs)(`div`,{className:`space-y-2`,children:[e.map(i=>(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:i.enabled,onChange:n=>X(e,t,i.id,`enabled`,n.target.checked),className:`h-4 w-4 rounded border-white/20 bg-background`}),(0,j.jsx)(_,{placeholder:n,value:i.key,onChange:n=>X(e,t,i.id,`key`,n.target.value),className:`h-8 text-xs bg-background/50`}),(0,j.jsx)(_,{placeholder:r,value:i.value,onChange:n=>X(e,t,i.id,`value`,n.target.value),className:`h-8 text-xs bg-background/50`}),(0,j.jsx)(h,{variant:`ghost`,size:`icon`,className:`h-8 w-8 text-muted-foreground hover:text-red-400`,onClick:()=>ue(e,t,i.id),children:(0,j.jsx)(p,{className:`h-3.5 w-3.5`})})]},i.id)),(0,j.jsxs)(h,{variant:`ghost`,size:`sm`,className:`text-xs text-muted-foreground hover:text-primary`,onClick:()=>le(e,t),children:[(0,j.jsx)(ne,{className:`h-3.5 w-3.5 mr-1`}),`Agregar`]})]});return(0,j.jsxs)(`div`,{className:`hive-page-container animate-fade-in mt-10`,children:[(0,j.jsx)(`div`,{className:`hive-page-header mb-6`,children:(0,j.jsxs)(`div`,{className:`flex items-center gap-3 mb-2`,children:[(0,j.jsx)(`div`,{className:`h-10 w-10 rounded-xl bg-purple-500/10 border border-purple-500/20 flex items-center justify-center text-purple-400`,children:(0,j.jsx)(m,{className:`h-6 w-6`})}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h1`,{className:`text-3xl font-black text-white uppercase tracking-tighter`,children:`API Client`}),(0,j.jsx)(`p`,{className:`hive-subtitle`,children:`Cliente HTTP para probar endpoints REST directamente desde Hive.`})]})]})}),(0,j.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-[1fr_320px] gap-6`,children:[(0,j.jsxs)(`div`,{className:`space-y-4`,children:[(0,j.jsx)(w,{className:`border-white/10 bg-card/50`,children:(0,j.jsx)(S,{className:`p-4`,children:(0,j.jsxs)(`div`,{className:`flex gap-2`,children:[(0,j.jsxs)(ee,{value:e,onValueChange:t,children:[(0,j.jsx)(o,{className:`w-[110px] h-10 text-xs font-bold tracking-wider`,children:(0,j.jsx)(s,{})}),(0,j.jsx)(a,{children:ie.map(e=>(0,j.jsx)(i,{value:e,className:`text-xs font-bold`,children:e},e))})]}),(0,j.jsx)(_,{placeholder:`https://api.example.com/endpoint`,value:n,onChange:e=>P(e.target.value),onKeyDown:e=>e.key===`Enter`&&Q(),className:`h-10 text-sm bg-background/50 font-mono`}),(0,j.jsxs)(h,{onClick:Q,disabled:U||!n.trim(),className:`h-10 px-6 bg-purple-600 hover:bg-purple-500 text-white font-bold text-xs tracking-wider`,children:[U?(0,j.jsx)(g,{className:`h-4 w-4 animate-spin mr-2`}):(0,j.jsx)(re,{className:`h-4 w-4 mr-2`}),`ENVIAR`]})]})})}),(0,j.jsx)(w,{className:`border-white/10 bg-card/50`,children:(0,j.jsx)(S,{className:`p-4`,children:(0,j.jsxs)(O,{defaultValue:`headers`,className:`w-full`,children:[(0,j.jsxs)(D,{className:`bg-background/50 h-8`,children:[(0,j.jsxs)(T,{value:`headers`,className:`text-xs h-7`,children:[`Headers (`,F.filter(e=>e.enabled&&e.key.trim()).length,`)`]}),(0,j.jsxs)(T,{value:`query`,className:`text-xs h-7`,children:[`Query Params (`,L.filter(e=>e.enabled&&e.key.trim()).length,`)`]}),(0,j.jsx)(T,{value:`body`,className:`text-xs h-7`,children:`Body`})]}),(0,j.jsx)(E,{value:`headers`,className:`mt-3`,children:$(F,I,`Header`,`Value`)}),(0,j.jsx)(E,{value:`query`,className:`mt-3`,children:$(L,R,`Key`,`Value`)}),(0,j.jsxs)(E,{value:`body`,className:`mt-3`,children:[(0,j.jsx)(y,{placeholder:`{
2
- "key": "value"
3
- }`,value:z,onChange:e=>B(e.target.value),className:`min-h-[140px] font-mono text-xs bg-background/50`}),(0,j.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-2`,children:`Se enviará como string crudo. Para JSON, asegurate de que sea válido.`})]})]})})}),V&&(0,j.jsxs)(w,{className:r(`border-white/10`,V.ok?`bg-green-500/[0.02]`:`bg-red-500/[0.02]`),children:[(0,j.jsx)(x,{className:`pb-3`,children:(0,j.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,j.jsx)(C,{className:`text-sm font-bold tracking-wider`,children:`RESPUESTA`}),V.status!==void 0&&(0,j.jsxs)(b,{variant:`outline`,className:r(`text-xs font-bold border-none`,he(V.status),`text-white`),children:[V.status,` `,V.statusText||``]}),V.ok?(0,j.jsx)(te,{className:`h-4 w-4 text-green-500`}):(0,j.jsx)(u,{className:`h-4 w-4 text-red-500`}),(0,j.jsxs)(`span`,{className:`text-[10px] text-muted-foreground font-mono`,children:[G,`ms`]})]}),(0,j.jsxs)(h,{variant:`ghost`,size:`sm`,className:`h-7 text-xs`,onClick:()=>pe(JSON.stringify(V,null,2)),children:[(0,j.jsx)(d,{className:`h-3 w-3 mr-1`}),`Copiar`]})]})}),(0,j.jsx)(S,{className:`pt-0`,children:(0,j.jsxs)(O,{value:oe,onValueChange:se,children:[(0,j.jsxs)(D,{className:`bg-background/50 h-8`,children:[(0,j.jsx)(T,{value:`body`,className:`text-xs h-7`,children:`Body`}),(0,j.jsx)(T,{value:`headers`,className:`text-xs h-7`,children:`Headers`}),(0,j.jsx)(T,{value:`raw`,className:`text-xs h-7`,children:`Raw`})]}),(0,j.jsx)(E,{value:`body`,className:`mt-3`,children:(0,j.jsx)(k,{className:`h-[300px] w-full rounded-md border bg-black/40 p-3`,children:(0,j.jsx)(`pre`,{className:`font-mono text-xs text-green-400 whitespace-pre-wrap`,children:me(V.body??V)})})}),(0,j.jsx)(E,{value:`headers`,className:`mt-3`,children:(0,j.jsx)(k,{className:`h-[300px] w-full rounded-md border bg-black/40 p-3`,children:V.headers?(0,j.jsx)(`div`,{className:`space-y-1`,children:Object.entries(V.headers).map(([e,t])=>(0,j.jsxs)(`div`,{className:`flex gap-2 text-xs font-mono`,children:[(0,j.jsxs)(`span`,{className:`text-purple-400 shrink-0`,children:[e,`:`]}),(0,j.jsx)(`span`,{className:`text-white/70`,children:String(t)})]},e))}):(0,j.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No headers disponibles`})})}),(0,j.jsx)(E,{value:`raw`,className:`mt-3`,children:(0,j.jsx)(k,{className:`h-[300px] w-full rounded-md border bg-black/40 p-3`,children:(0,j.jsx)(`pre`,{className:`font-mono text-xs text-white/60 whitespace-pre-wrap`,children:JSON.stringify(V,null,2)})})})]})})]})]}),(0,j.jsx)(`div`,{children:(0,j.jsxs)(w,{className:`border-white/10 bg-card/50`,children:[(0,j.jsx)(x,{className:`pb-3`,children:(0,j.jsxs)(`button`,{onClick:()=>ae(!Y),className:`flex items-center justify-between w-full`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(f,{className:`h-4 w-4 text-muted-foreground`}),(0,j.jsx)(C,{className:`text-xs font-bold tracking-wider`,children:`HISTORIAL`})]}),Y?(0,j.jsx)(c,{className:`h-4 w-4 text-muted-foreground`}):(0,j.jsx)(l,{className:`h-4 w-4 text-muted-foreground`})]})}),Y&&(0,j.jsxs)(S,{className:`pt-0`,children:[q.length===0?(0,j.jsx)(`p`,{className:`text-xs text-muted-foreground text-center py-4`,children:`No hay requests en el historial`}):(0,j.jsx)(k,{className:`h-[calc(100vh-300px)]`,children:(0,j.jsx)(`div`,{className:`space-y-1`,children:q.map(e=>(0,j.jsxs)(`button`,{onClick:()=>fe(e),className:`w-full text-left p-2 rounded-lg hover:bg-white/5 transition-colors group`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(`span`,{className:r(`text-[10px] font-bold px-1.5 py-0.5 rounded`,e.ok?`bg-green-500/20 text-green-400`:`bg-red-500/20 text-red-400`),children:e.method}),e.status&&(0,j.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e.status})]}),(0,j.jsx)(`p`,{className:`text-[10px] text-white/50 truncate mt-1 font-mono`,children:e.url}),(0,j.jsx)(`p`,{className:`text-[9px] text-white/30 mt-0.5`,children:new Date(e.timestamp).toLocaleTimeString()})]},e.id))})}),q.length>0&&(0,j.jsxs)(h,{variant:`ghost`,size:`sm`,className:`w-full mt-2 text-[10px] text-muted-foreground hover:text-red-400`,onClick:()=>{J([]),localStorage.removeItem(`hive-api-client-history`)},children:[(0,j.jsx)(p,{className:`h-3 w-3 mr-1`}),`Limpiar historial`]})]})]})})]})]})}export{P as ApiClientPage};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as t}from"./vendor-charts-Bu2lyBKP.js";import{o as n}from"./vendor-query-DsWPbQdG.js";import{r}from"./utils-3pnRFmFe.js";import{n as i,t as a}from"./chevron-up-BYhk0K2J.js";import{t as ee}from"./file-text-BEjEmgby.js";import{t as o}from"./history-BSG-Ypqf.js";import{n as s,t as c}from"./square-BD81nFtN.js";import{n as l,r as u,t as d}from"./gateway-url-iG-C6Agn.js";import{M as f,Y as p,j as m}from"./index-CmGm_r89.js";import{t as h}from"./badge-CxTPR6_t.js";var g=r(`MicOff`,[[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}],[`path`,{d:`M18.89 13.23A7.12 7.12 0 0 0 19 12v-2`,key:`80xlxr`}],[`path`,{d:`M5 10v2a7 7 0 0 0 12 5`,key:`p2k8kg`}],[`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`,key:`1gzdoj`}],[`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`,key:`r2i35w`}],[`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`,key:`x3vr5v`}]]),_=r(`MonitorSpeaker`,[[`path`,{d:`M5.5 20H8`,key:`1k40s5`}],[`path`,{d:`M17 9h.01`,key:`1j24nn`}],[`rect`,{width:`10`,height:`16`,x:`12`,y:`4`,rx:`2`,key:`ixliua`}],[`path`,{d:`M8 6H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h4`,key:`1mp6e1`}],[`circle`,{cx:`17`,cy:`15`,r:`1`,key:`tqvash`}]]),v=r(`Radio`,[[`path`,{d:`M4.9 19.1C1 15.2 1 8.8 4.9 4.9`,key:`1vaf9d`}],[`path`,{d:`M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5`,key:`u1ii0m`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}],[`path`,{d:`M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5`,key:`1j5fej`}],[`path`,{d:`M19.1 4.9C23 8.8 23 15.1 19.1 19`,key:`10b0cb`}]]),y=e(t(),1),b=u((e,t)=>({sessions:[],activeSessionId:null,segments:[],isRecording:!1,isConnecting:!1,error:null,wsConnection:null,startSession:async(n,r=`whisper-large-v3-turbo`)=>{e({error:null,isConnecting:!0});try{let i=await(await fetch(`${d()}/api/meetings`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({title:n,stt_model:r})})).json();return!i.ok||!i.session?(e({error:i.error??`Error al crear sesión`,isConnecting:!1}),null):(e({activeSessionId:i.session.id,segments:[],sessions:[i.session,...t().sessions],isConnecting:!1}),i.session.id)}catch(t){return e({error:t.message,isConnecting:!1}),null}},stopSession:async()=>{let{activeSessionId:n,wsConnection:r}=t();if(n){if(r&&r.readyState===WebSocket.OPEN)r.send(JSON.stringify({type:`meeting_stop`}));else try{await fetch(`${d()}/api/meetings/${n}/stop`,{method:`POST`})}catch{}r?.close(),e({isRecording:!1,wsConnection:null})}},fetchSessions:async()=>{try{let t=await(await fetch(`${d()}/api/meetings`)).json();t.ok&&t.sessions&&e({sessions:t.sessions})}catch{}},fetchSession:async t=>{try{let n=await(await fetch(`${d()}/api/meetings/${t}`)).json();n.ok&&n.session&&e({activeSessionId:t,segments:n.segments??[]})}catch{}},addSegmentLocal:t=>e(e=>({segments:[...e.segments,t]})),setWsConnection:t=>e({wsConnection:t}),setRecording:t=>e({isRecording:t}),setConnecting:t=>e({isConnecting:t}),setError:t=>e({error:t}),clearActiveSession:()=>e({activeSessionId:null,segments:[],isRecording:!1,wsConnection:null})}));function x(e){return`${l()}/meeting-stream?meetingSessionId=${encodeURIComponent(e)}`}var S=n();function te(e){let t=Math.floor(Date.now()/1e3-e);return`${Math.floor(t/60).toString().padStart(2,`0`)}:${(t%60).toString().padStart(2,`0`)}`}async function ne(){if(!navigator.mediaDevices?.getDisplayMedia)return!1;try{let e=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!0,systemAudio:`include`}),t=e.getAudioTracks().length>0;return e.getTracks().forEach(e=>e.stop()),t}catch{return!1}}function re({segment:e}){return(0,S.jsxs)(`div`,{className:`flex gap-3 py-2 px-3 rounded-lg hover:bg-white/[0.03] transition-colors`,children:[e.speaker&&(0,S.jsxs)(`span`,{className:`shrink-0 text-xs font-semibold text-amber-400 mt-0.5 leading-5`,children:[`[`,e.speaker,`]`]}),(0,S.jsx)(`span`,{className:`text-sm text-zinc-300 leading-relaxed`,children:e.text})]})}function ie(){return(0,S.jsxs)(`span`,{className:`relative flex h-3 w-3`,children:[(0,S.jsx)(`span`,{className:`animate-ping absolute inline-flex h-full w-full rounded-full bg-red-400 opacity-75`}),(0,S.jsx)(`span`,{className:`relative inline-flex rounded-full h-3 w-3 bg-red-500`})]})}function ae(){let{sessions:e,activeSessionId:t,segments:n,isRecording:r,isConnecting:l,error:u,wsConnection:ae,startSession:C,stopSession:w,fetchSessions:T,addSegmentLocal:E,setWsConnection:D,setRecording:O,setError:k,clearActiveSession:oe}=b(),[A,j]=(0,y.useState)(``),[M,N]=(0,y.useState)(`00:00`),[P,F]=(0,y.useState)(!0),[I,L]=(0,y.useState)(!1),[R,z]=(0,y.useState)(!1),[B,V]=(0,y.useState)(`microphone`),[H,U]=(0,y.useState)(null),W=(0,y.useRef)(null),G=(0,y.useRef)([]),K=(0,y.useRef)(null),q=(0,y.useRef)(null),J=(0,y.useRef)(null),Y=(0,y.useRef)(null),X=(0,y.useRef)(null),Z=(0,y.useRef)(!1),Q=e.find(e=>e.id===t);(0,y.useEffect)(()=>{if(!r||!Q)return;let e=setInterval(()=>N(te(Q.started_at)),1e3);return()=>clearInterval(e)},[r,Q]),(0,y.useEffect)(()=>{X.current?.scrollIntoView({behavior:`smooth`})},[n]),(0,y.useEffect)(()=>{T()},[]),(0,y.useEffect)(()=>{ne().then(e=>{U(e)})},[]);let $=(0,y.useCallback)(async()=>{if(!A.trim()){k(`Ingresa el título de la reunión`);return}if(k(null),z(!1),!navigator.mediaDevices?.getUserMedia){k(`Tu navegador no puede acceder al micrófono. Asegúrate de usar HTTPS o localhost.`);return}let e=`audio/webm`,t,n=`microphone`;try{let e=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}});K.current=e;let r;if(H)try{r=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!0,systemAudio:`include`}),q.current=r,n=r.getAudioTracks().length>0?`system`:`microphone`}catch{n=`microphone`}if(n===`system`&&r){let n=new AudioContext;J.current=n;let i=n.createMediaStreamDestination();Y.current=i,n.createMediaStreamSource(e).connect(i),n.createMediaStreamSource(r).connect(i),t=new MediaStream([...i.stream.getAudioTracks()]),V(`dual`)}else t=e,V(`microphone`)}catch(e){let t=e.name;k(t===`NotAllowedError`||t===`PermissionDeniedError`?`Permiso de micrófono denegado. Ve a la configuración del navegador (🔒 en la barra de URL) y permite el micrófono.`:t===`NotFoundError`?`No se encontró ningún micrófono en este dispositivo.`:`No se pudo acceder al micrófono: ${e.message}`);return}K.current=t;let r=await C(A.trim());if(!r){t.getTracks().forEach(e=>e.stop()),q.current?.getTracks().forEach(e=>e.stop());return}let i=new WebSocket(x(r));D(i);let a=()=>{if(!Z.current||i.readyState!==WebSocket.OPEN)return;G.current=[];let n=new MediaRecorder(t,{mimeType:e});W.current=n,n.ondataavailable=e=>{e.data.size>0&&G.current.push(e.data)},n.onstop=()=>{if(G.current.length===0){Z.current&&i.readyState===WebSocket.OPEN&&a();return}let t=new Blob(G.current,{type:e}),n=new FileReader;n.readAsDataURL(t),n.onloadend=()=>{let t=n.result.split(`,`)[1];i.readyState===WebSocket.OPEN&&i.send(JSON.stringify({type:`audio_chunk`,audio:t,mime_type:e})),Z.current&&i.readyState===WebSocket.OPEN&&a()}},n.start(),setTimeout(()=>{n.state===`recording`&&n.stop()},5e3)};i.onopen=()=>{Z.current=!0,O(!0),a()},i.onmessage=e=>{try{let t=JSON.parse(e.data);t.type===`transcript_segment`&&E({seq:t.seq,speaker:t.speaker||null,text:t.text}),t.type===`meeting_stopped`&&(Z.current=!1,O(!1)),t.type===`error`&&k(t.error)}catch{}},i.onerror=()=>k(`Error en la conexión WebSocket`),i.onclose=()=>{Z.current=!1,O(!1),K.current?.getTracks().forEach(e=>e.stop()),q.current?.getTracks().forEach(e=>e.stop()),J.current?.close()}},[A,C,D,O,k,E,H]),se=(0,y.useCallback)(async()=>{Z.current=!1,W.current?.stop(),K.current?.getTracks().forEach(e=>e.stop()),q.current?.getTracks().forEach(e=>e.stop()),J.current?.close(),await w(),N(`00:00`)},[w]),ce=(0,y.useCallback)(async()=>{if(t){L(!0),k(null);try{(await fetch(`${d()}/api/chat`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({message:`Genera el reporte de la reunión ${t}`})})).ok?z(!0):k(`Error al enviar el mensaje al agente`)}catch(e){k(e.message)}finally{L(!1)}}},[t,k]),le=!r&&t,ue=!r&&!Q?.status.startsWith(`stop`)&&!t;return(0,S.jsxs)(`div`,{className:`flex h-full flex-col bg-[#111319] text-white`,children:[(0,S.jsx)(`div`,{className:`shrink-0 px-5 py-4 border-b border-white/[0.06] bg-[#191b22]/80 backdrop-blur-sm`,children:(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,S.jsx)(`div`,{className:`flex items-center justify-center w-9 h-9 rounded-xl bg-amber-500/10 border border-amber-500/20`,children:(0,S.jsx)(v,{className:`h-4 w-4 text-amber-400`})}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h1`,{className:`text-sm font-semibold text-white leading-tight`,children:`Transcripción de Reuniones`}),(0,S.jsx)(`p`,{className:`text-[11px] text-zinc-500 leading-tight`,children:`Captura · Transcribe · Informa en tiempo real`})]})]}),r&&(0,S.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 rounded-full bg-red-500/10 border border-red-500/20`,children:[(0,S.jsx)(ie,{}),(0,S.jsx)(`span`,{className:`text-xs font-semibold text-red-400 tabular-nums`,children:M})]})]})}),(0,S.jsxs)(`div`,{className:`flex flex-col lg:flex-row flex-1 overflow-hidden min-h-0`,children:[(0,S.jsxs)(`div`,{className:`flex flex-col flex-1 min-h-0 overflow-hidden`,children:[(0,S.jsxs)(`div`,{className:`shrink-0 px-5 py-4 border-b border-white/[0.06] space-y-3`,children:[ue?(0,S.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-2`,children:[(0,S.jsx)(m,{placeholder:`Nombre de la reunión...`,value:A,onChange:e=>j(e.target.value),onKeyDown:e=>e.key===`Enter`&&$(),className:`flex-1 bg-white/[0.04] border-white/[0.08] text-white placeholder:text-zinc-600 focus-visible:ring-amber-500/40 focus-visible:border-amber-500/40 rounded-xl h-10`,disabled:l}),(0,S.jsxs)(f,{onClick:$,disabled:l||!A.trim(),className:`shrink-0 bg-amber-500 hover:bg-amber-400 active:bg-amber-600 text-black font-semibold rounded-xl h-10 px-5 shadow-lg shadow-amber-900/30 transition-all`,children:[(0,S.jsx)(s,{className:`h-4 w-4 mr-1.5`}),l?`Iniciando...`:`Iniciar`]})]}):(0,S.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[(0,S.jsx)(h,{variant:`outline`,className:r?`border-red-500/40 text-red-400 bg-red-500/10 rounded-full px-2.5`:`border-zinc-600/40 text-zinc-400 bg-white/[0.04] rounded-full px-2.5`,children:r?`● REC`:`Detenida`}),B!==`microphone`&&r&&(0,S.jsx)(h,{variant:`outline`,className:`border-blue-500/40 text-blue-400 bg-blue-500/10 rounded-full px-2.5`,children:B===`dual`?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(_,{className:`h-3 w-3 mr-1`}),`Mic+Altavozz`]}):B===`system`?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(_,{className:`h-3 w-3 mr-1`}),`Altavozz`]}):null}),(0,S.jsx)(`span`,{className:`text-sm font-medium text-zinc-200 truncate max-w-[180px]`,children:Q?.title}),r&&(0,S.jsxs)(`span`,{className:`hidden sm:flex items-center gap-1 text-xs text-zinc-500`,children:[(0,S.jsx)(p,{className:`h-3 w-3`}),M]})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[r&&(0,S.jsxs)(f,{variant:`outline`,size:`sm`,onClick:se,className:`border-red-500/30 text-red-400 hover:bg-red-500/10 hover:border-red-500/50 rounded-xl h-8`,children:[(0,S.jsx)(c,{className:`h-3 w-3 mr-1.5 fill-current`}),`Detener`]}),le&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(f,{size:`sm`,onClick:ce,disabled:I||R,className:`bg-amber-500 hover:bg-amber-400 text-black font-semibold rounded-xl h-8 px-3 shadow-md shadow-amber-900/30 disabled:opacity-60`,children:[(0,S.jsx)(ee,{className:`h-3.5 w-3.5 mr-1.5`}),I?`Generando...`:R?`Enviado ✓`:`Generar Reporte`]}),(0,S.jsx)(f,{variant:`ghost`,size:`sm`,onClick:oe,className:`text-zinc-500 hover:text-zinc-300 hover:bg-white/[0.05] rounded-xl h-8`,children:`Nueva reunión`})]})]})]}),u&&(0,S.jsxs)(`div`,{className:`flex items-start gap-2.5 px-3.5 py-2.5 rounded-xl bg-red-500/[0.08] border border-red-500/20 text-xs text-red-400`,children:[(0,S.jsx)(`span`,{className:`shrink-0 mt-px`,children:`⚠`}),(0,S.jsx)(`span`,{children:u})]}),R&&(0,S.jsxs)(`div`,{className:`flex items-center gap-2.5 px-3.5 py-2.5 rounded-xl bg-emerald-500/[0.08] border border-emerald-500/20 text-xs text-emerald-400`,children:[(0,S.jsx)(`span`,{children:`✓`}),(0,S.jsx)(`span`,{children:`El agente está generando el reporte. Verifica el chat para el informe completo.`})]})]}),(0,S.jsx)(`div`,{className:`flex-1 overflow-y-auto px-4 py-4 min-h-0`,children:n.length===0?(0,S.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4 text-zinc-600`,children:[(0,S.jsx)(`div`,{className:`flex items-center justify-center w-16 h-16 rounded-2xl bg-white/[0.03] border border-white/[0.06]`,children:(0,S.jsx)(g,{className:`h-7 w-7`})}),(0,S.jsx)(`p`,{className:`text-sm text-center max-w-[220px] leading-relaxed`,children:r?`Escuchando… las transcripciones aparecerán aquí`:`Inicia una sesión para ver la transcripción en tiempo real`})]}):(0,S.jsxs)(`div`,{className:`space-y-0.5`,children:[n.map(e=>(0,S.jsx)(re,{segment:e},e.seq)),(0,S.jsx)(`div`,{ref:X})]})}),n.length>0&&(0,S.jsxs)(`div`,{className:`shrink-0 border-t border-white/[0.06] px-5 py-2 flex items-center justify-between`,children:[(0,S.jsxs)(`span`,{className:`text-[11px] text-zinc-600`,children:[n.length,` segmento`,n.length===1?``:`s`,` transcritos`]}),r&&(0,S.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] text-zinc-500`,children:[(0,S.jsx)(p,{className:`h-3 w-3`}),M]})]})]}),(0,S.jsxs)(`div`,{className:`shrink-0 flex flex-col lg:w-64 xl:w-72 border-t lg:border-t-0 lg:border-l border-white/[0.06] bg-[#191b22]/40 max-h-60 lg:max-h-none`,children:[(0,S.jsxs)(`button`,{onClick:()=>F(!P),className:`flex items-center justify-between px-4 py-3 text-[11px] font-semibold text-zinc-500 uppercase tracking-wider hover:text-zinc-300 border-b border-white/[0.06] transition-colors`,children:[(0,S.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(o,{className:`h-3.5 w-3.5`}),`Historial (`,e.length,`)`]}),P?(0,S.jsx)(a,{className:`h-3 w-3`}):(0,S.jsx)(i,{className:`h-3 w-3`})]}),P&&(0,S.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:e.length===0?(0,S.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 gap-2 text-zinc-600`,children:[(0,S.jsx)(o,{className:`h-6 w-6 opacity-40`}),(0,S.jsx)(`p`,{className:`text-xs`,children:`Sin reuniones aún`})]}):(0,S.jsx)(`div`,{className:`py-1`,children:e.map(e=>(0,S.jsxs)(`button`,{onClick:()=>b.getState().fetchSession(e.id),className:`w-full text-left px-4 py-3 hover:bg-white/[0.04] transition-colors border-b border-white/[0.04] ${e.id===t?`bg-amber-500/[0.06]`:``}`,children:[(0,S.jsx)(`p`,{className:`text-xs font-medium text-zinc-200 truncate leading-snug`,children:e.title}),(0,S.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-1`,children:[(0,S.jsx)(h,{variant:`outline`,className:`text-[10px] px-1.5 py-0 rounded-full border-0 ${e.status===`active`?`bg-emerald-500/15 text-emerald-400`:e.status===`report_ready`?`bg-blue-500/15 text-blue-400`:`bg-white/[0.05] text-zinc-500`}`,children:e.status===`active`?`activa`:e.status===`report_ready`?`con reporte`:`detenida`}),e.segment_count!==void 0&&e.segment_count>0&&(0,S.jsxs)(`span`,{className:`text-[10px] text-zinc-600`,children:[e.segment_count,` seg`]})]})]},e.id))})})]})]})]})}function C(){return(0,S.jsx)(`div`,{className:`h-full overflow-hidden`,children:(0,S.jsx)(ae,{})})}export{C as MeetingPage};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as t}from"./vendor-charts-Bu2lyBKP.js";import{o as n}from"./vendor-query-DsWPbQdG.js";import{r}from"./utils-3pnRFmFe.js";import{c as i,i as a,n as o,o as s,s as c,t as l}from"./select-Cl16QYa_.js";import{n as u}from"./chevron-up-BYhk0K2J.js";import{t as d}from"./chevron-right-CR4Skrf3.js";import{t as f}from"./circle-check-Bb54Ebmu.js";import{t as p}from"./cpu-DSpPVLAz.js";import{t as m}from"./download-D9ZyUZZR.js";import{n as h,t as g}from"./eye-epHJZ_nQ.js";import{t as _}from"./key-3EP0dhkT.js";import{t as v}from"./loader-circle-CZNax6kS.js";import{a as y,c as b,i as x,l as S,n as C,o as w,r as T,s as E,t as D}from"./table-CVkIRJKK.js";import{t as O}from"./lock-Ei1_J-Nq.js";import{n as k,t as A}from"./square-BD81nFtN.js";import{n as j,t as M}from"./terminal-DN38Q456.js";import{t as ee}from"./play-NcZ4swwL.js";import{t as te}from"./plus-CX1xyhp5.js";import{t as N}from"./refresh-cw-DaYdjQFk.js";import{t as P}from"./search-BGmPJ-6L.js";import{t as F}from"./settings-CcMGI1iU.js";import{t as ne}from"./trash-2-BHRa5ft9.js";import{G as I,J as L,K as R,M as z,a as re,c as B,d as ie,h as V,i as ae,j as H,p as oe,r as U,s as se,z as ce}from"./index-CmGm_r89.js";import{t as W}from"./label-byJkqOYq.js";import{t as le}from"./switch-h2SfQX4B.js";import{c as ue,i as de,o as fe,r as pe,s as me,t as he}from"./dialog-DfS3idb3.js";import{t as G}from"./badge-CxTPR6_t.js";import{a as K,n as q,o as J,r as Y,t as X}from"./card-CXAm46at.js";import"./useProviders-eEri6BAc.js";import{i as Z,n as ge,r as _e,t as ve}from"./tabs-C619jxbO.js";import{t as ye}from"./scroll-area-BXtLsE9E.js";import{t as be}from"./progress-Dtz-Mzys.js";var xe=r(`Binary`,[[`rect`,{x:`14`,y:`14`,width:`4`,height:`6`,rx:`2`,key:`p02svl`}],[`rect`,{x:`6`,y:`4`,width:`4`,height:`6`,rx:`2`,key:`xm4xkj`}],[`path`,{d:`M6 20h4`,key:`1i6q5t`}],[`path`,{d:`M14 10h4`,key:`ru81e7`}],[`path`,{d:`M6 14h2v6`,key:`16z9wg`}],[`path`,{d:`M14 4h2v6`,key:`1idq9u`}]]),Se=r(`KeyRound`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),Ce=r(`Package`,[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`path`,{d:`m3.3 7 7.703 4.734a2 2 0 0 0 1.994 0L20.7 7`,key:`yx3hmr`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]),Q=e(t(),1),$=n();function we({provider:e,onSave:t,onCancel:n}){let[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(e?.baseUrl||e?.base_url||``),[l,u]=(0,Q.useState)(e?.config?.headers?JSON.stringify(e.config.headers,null,2):``),[d,p]=(0,Q.useState)(e?.num_ctx?String(e.num_ctx):``),m=s||e?.baseUrl||e?.base_url||``,_=e?.id===`ollama`||m.includes(`localhost`)||m.includes(`127.0.0.1`),v=!!e?.has_api_key,y=!!e?.has_headers;return(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(W,{className:`hive-label`,children:`API Key`}),v&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] font-bold text-emerald-400`,children:[(0,$.jsx)(f,{className:`h-3 w-3`}),`Configurada`]})]}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(H,{type:r?`text`:`password`,value:a,onChange:e=>o(e.target.value),placeholder:v?`•••••••••••••••• (dejar vacío para conservar)`:`sk-...`,className:`hive-input !h-8 text-xs pr-8`}),(0,$.jsx)(z,{variant:`ghost`,size:`icon`,className:`absolute right-0 top-0 h-8 w-8 text-white/40 hover:text-white`,onClick:()=>i(!r),children:r?(0,$.jsx)(h,{className:`h-3 w-3`}):(0,$.jsx)(g,{className:`h-3 w-3`})})]})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(W,{className:`hive-label`,children:`Base URL (opcional)`}),(0,$.jsx)(H,{value:s,onChange:e=>c(e.target.value),placeholder:`https://api.example.com`,className:`hive-input !h-8 text-xs`})]}),_&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(W,{className:`hive-label`,children:`Context Window (num_ctx)`}),(0,$.jsx)(`span`,{className:`text-[10px] text-white/30`,children:`tokens — por defecto 32 768`})]}),(0,$.jsx)(H,{type:`number`,value:d,onChange:e=>p(e.target.value),placeholder:`8192`,min:512,step:512,className:`hive-input !h-8 text-xs font-mono`}),(0,$.jsx)(`p`,{className:`text-[10px] text-amber-400/60`,children:`Aumenta si ves errores de contexto. Tu modelo soporta hasta 262 144 tokens.`})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(W,{className:`hive-label`,children:`Custom Headers (JSON)`}),y&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] font-bold text-emerald-400`,children:[(0,$.jsx)(f,{className:`h-3 w-3`}),`Configurados`]})]}),(0,$.jsx)(`textarea`,{value:l,onChange:e=>u(e.target.value),placeholder:y?`{ ... } (dejar vacío para conservar)`:`{ "x-custom-header": "value" }`,rows:3,className:`w-full bg-white/5 border border-white/10 rounded-md p-2 text-xs text-white/70 focus:outline-none focus:border-blue-500/50 transition-all font-mono`})]}),(0,$.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,$.jsx)(`button`,{className:`hive-btn hive-btn--form-cancel flex-1`,onClick:n,children:`Cancelar`}),(0,$.jsx)(`button`,{className:`hive-btn hive-btn--form-submit flex-1`,onClick:()=>{let e;if(l.trim())try{e=JSON.parse(l.trim())}catch{V.fire(`Error`,`JSON de Headers inválido`,`error`);return}t&&t({apiKey:a,baseUrl:s||void 0,headers:e,numCtx:d.trim()?Number(d.trim()):null})},children:`Guardar`})]}),(0,$.jsx)(`p`,{className:`text-[10px] text-white/20 pt-2`,children:`La API key se guarda cifrada en la base de datos.`})]})}var Te=F,Ee=u,De=d,Oe=p,ke=te,Ae=Se,je=L,Me=N,Ne=j,Pe=ne,Fe=i,Ie=ce;function Le({provider:e,updateProvider:t,onManageModels:n}){let[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(null),{models:x,toggleModel:S,createModel:C,syncModels:w,deleteModel:T,updateModel:E}=se(),{toggleProvider:D}=B(),O=(0,Q.useMemo)(()=>{let t=x.filter(t=>(t.providerId||t.provider_id)===e.id);return t.length>0?t:e.models||[]},[x,e.id,e.models]),k=O.filter(e=>e.enabled||e.active),A=n=>{t(e.id,n),i(!1)},j=async t=>{try{await D(e.id,t)}catch(e){console.error(`Failed to toggle provider:`,e)}},M=async(e,t)=>{try{await S(e.id,t)}catch(e){console.error(`Failed to toggle model:`,e)}},ee=async()=>{f(!0);try{await w(e.id),o(!0)}catch(e){console.error(`Failed to sync models:`,e)}finally{f(!1)}},te=e=>{m(e.id),g(e.name),v(e.id)},N=()=>{m(null),g(``),v(``)},P=async e=>{let t=h.trim()||e.name,n=_.trim()||e.id;if(t===e.name&&n===e.id){N();return}try{await E(e.id,{name:t,id:n}),N()}catch(e){console.error(`Failed to update model:`,e)}},F=async e=>{b(e.id);try{await T(e.id)}catch(e){console.error(`Failed to delete model:`,e)}finally{b(null)}},ne=async()=>{let t=s.trim();if(t){u(!0);try{await C(e.id,t),c(``)}catch(e){console.error(`Failed to add model:`,e)}finally{u(!1)}}},I=!!e.active,L=e.base_url||e.baseUrl,R=e.id===`ollama`||L?.includes(`localhost`)||L?.includes(`127.0.0.1`);return(0,$.jsxs)(`div`,{className:`hive-card group overflow-hidden flex flex-col gap-0 transition-all duration-500 ${I?`hive-card--active`:`opacity-70 grayscale-[0.5] hover:grayscale-0 hover:opacity-100`}`,children:[(0,$.jsx)(`div`,{className:`hive-card-body pb-3`,children:(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,$.jsx)(`div`,{className:`shrink-0 h-10 w-10 sm:h-11 sm:w-11 rounded-xl flex items-center justify-center border transition-all duration-500 ${I?`bg-blue-500/10 border-blue-500/30 text-blue-400 shadow-[0_0_16px_rgba(59,130,246,0.15)]`:`bg-white/5 border-white/10 text-white/30`}`,children:(0,$.jsx)(Oe,{className:`h-5 w-5`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,$.jsx)(`h3`,{className:`font-black text-white tracking-tight text-base sm:text-lg uppercase leading-none truncate`,children:e.name}),I&&(0,$.jsx)(`div`,{className:`hive-status-dot--active h-1.5 w-1.5 shrink-0`})]}),(0,$.jsx)(`p`,{className:`text-[11px] text-white/35 font-medium leading-none truncate`,children:e.id})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,$.jsx)(`span`,{className:`hidden sm:block text-[10px] font-black tracking-widest ${I?`text-blue-400`:`text-white/30`}`,children:I?`ON`:`OFF`}),(0,$.jsx)(le,{checked:I,onCheckedChange:j,className:`data-[state=checked]:bg-blue-500`})]})]})}),(0,$.jsxs)(`div`,{className:`px-5 pb-3 space-y-2 border-b border-white/5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(Ae,{className:`h-3.5 w-3.5 shrink-0 ${e.has_api_key?`text-emerald-400`:R?`text-amber-400`:`text-white/20`}`}),(0,$.jsx)(`span`,{className:`text-[11px] font-mono truncate`,children:e.masked_api_key?(0,$.jsx)(`span`,{className:`text-white/50`,children:e.masked_api_key}):e.has_api_key?(0,$.jsx)(`span`,{className:`text-white/50`,children:`••••••••••••••••`}):R?(0,$.jsx)(`span`,{className:`text-amber-400/70`,children:`Local — sin API key`}):(0,$.jsx)(`span`,{className:`text-white/25`,children:`Sin API key`})})]}),L&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(je,{className:`h-3.5 w-3.5 shrink-0 text-white/20`}),(0,$.jsx)(`span`,{className:`text-[11px] text-white/40 truncate font-mono`,children:L})]}),R&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(Oe,{className:`h-3.5 w-3.5 shrink-0 text-white/20`}),(0,$.jsxs)(`span`,{className:`text-[11px] text-white/40 font-mono`,children:[`ctx: `,(0,$.jsx)(`span`,{className:e.num_ctx?`text-amber-400/70`:`text-white/25`,children:e.num_ctx?`${e.num_ctx.toLocaleString()} tokens`:`32 768 (default)`})]})]})]}),(0,$.jsxs)(`div`,{className:`px-5 py-3 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2 flex-1 text-left text-[10px] font-black uppercase tracking-widest text-white/40 hover:text-white transition-colors`,onClick:()=>o(!a),children:[a?(0,$.jsx)(Ee,{className:`h-3 w-3`}):(0,$.jsx)(De,{className:`h-3 w-3`}),`MODELOS`,(0,$.jsxs)(`span`,{className:`hive-tag scale-90 origin-left`,children:[k.length,`/`,O.length]})]}),R&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`text-[9px] font-semibold text-amber-400/70 bg-amber-400/10 border border-amber-400/20 rounded px-1.5 py-0.5 leading-none whitespace-nowrap`,children:`Actualiza modelos locales`}),(0,$.jsx)(`button`,{type:`button`,onClick:ee,disabled:d,title:`Sincronizar modelos instalados en Ollama`,className:`h-6 w-6 flex items-center justify-center rounded-md text-white/30 hover:text-amber-400 hover:bg-amber-400/10 disabled:opacity-40 transition-colors`,children:(0,$.jsx)(Me,{className:`h-3 w-3 ${d?`animate-spin`:``}`})})]})]}),!a&&O.length>0&&(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:[O.slice(0,3).map(e=>(0,$.jsx)(`span`,{className:`hive-tag text-[10px] ${e.enabled||e.active?``:`opacity-40`}`,children:e.name.split(`/`).pop()||e.name},e.id)),O.length>3&&(0,$.jsxs)(`span`,{className:`hive-tag text-[10px] text-white/30`,children:[`+`,O.length-3]})]}),a&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`div`,{className:`hive-scroll max-h-44 overflow-y-auto flex flex-col gap-0.5 pr-1`,children:[O.length===0&&(0,$.jsx)(`p`,{className:`text-[11px] text-white/25 py-2 text-center`,children:`Sin modelos configurados`}),O.map(e=>{let t=e.enabled||!!e.active,n=p===e.id;return(0,$.jsx)(`div`,{className:`rounded-lg transition-colors ${t&&!n||n?`bg-white/5`:`bg-transparent opacity-40`}`,children:n?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1 px-2.5 py-1.5`,children:[(0,$.jsx)(`input`,{type:`text`,value:h,onChange:e=>g(e.target.value),placeholder:`Display name`,className:`w-full bg-white/5 border border-white/10 rounded-md px-2 h-7 text-[11px] text-white/70 placeholder-white/20 focus:outline-none focus:border-blue-500/50 transition-all`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`input`,{type:`text`,value:_,onChange:e=>v(e.target.value),placeholder:`API model ID`,className:`flex-1 min-w-0 bg-white/5 border border-white/10 rounded-md px-2 h-7 text-[11px] text-white/70 placeholder-white/20 focus:outline-none focus:border-blue-500/50 transition-all font-mono`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>P(e),className:`shrink-0 h-7 w-7 flex items-center justify-center rounded-md bg-emerald-500/10 border border-emerald-500/20 text-emerald-400 hover:bg-emerald-500/20 transition-colors`,children:(0,$.jsx)(Fe,{className:`h-3 w-3`})}),(0,$.jsx)(`button`,{type:`button`,onClick:N,className:`shrink-0 h-7 w-7 flex items-center justify-center rounded-md bg-white/5 border border-white/10 text-white/40 hover:text-white hover:bg-white/10 transition-colors`,children:(0,$.jsx)(Ie,{className:`h-3 w-3`})})]})]}):(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-2.5 py-1.5`,children:[(0,$.jsx)(`span`,{className:`text-[11px] font-medium text-white truncate flex-1 mr-2`,children:e.name}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>te(e),title:`Editar modelo`,className:`h-5 w-5 flex items-center justify-center rounded text-white/25 hover:text-blue-400 hover:bg-blue-400/10 transition-colors`,children:(0,$.jsx)(Ne,{className:`h-3 w-3`})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>F(e),disabled:y===e.id,title:`Eliminar modelo`,className:`h-5 w-5 flex items-center justify-center rounded text-white/25 hover:text-red-400 hover:bg-red-400/10 disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,children:(0,$.jsx)(Pe,{className:`h-3 w-3`})}),(0,$.jsx)(le,{checked:t,onCheckedChange:t=>M(e,t),className:`scale-[0.7] origin-right data-[state=checked]:bg-blue-400 ml-0.5`})]})]})},e.id)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 pt-1.5 border-t border-white/5`,children:[(0,$.jsx)(`input`,{type:`text`,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>e.key===`Enter`&&ne(),placeholder:`nombre-del-modelo`,className:`flex-1 min-w-0 bg-white/5 border border-white/10 rounded-md px-2 h-7 text-[11px] text-white/70 placeholder-white/20 focus:outline-none focus:border-blue-500/50 transition-all font-mono`}),(0,$.jsxs)(`button`,{type:`button`,onClick:ne,disabled:l||!s.trim(),className:`shrink-0 h-7 px-2.5 flex items-center gap-1 rounded-md bg-blue-500/10 border border-blue-500/20 text-blue-400 text-[10px] font-black uppercase tracking-wider hover:bg-blue-500/20 disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,children:[(0,$.jsx)(ke,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{className:`hidden xs:inline`,children:`ADD`})]})]})]})]}),(0,$.jsxs)(`div`,{className:`px-4 py-3 border-t border-white/5 flex items-center justify-between gap-2 overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`hive-stat shrink-0`,children:[(0,$.jsx)(`span`,{className:`hive-stat__label`,children:`Uptime`}),(0,$.jsx)(`span`,{className:`hive-stat__value`,children:`99.9%`})]}),(0,$.jsxs)(`div`,{className:`hive-stat shrink-0`,children:[(0,$.jsx)(`span`,{className:`hive-stat__label`,children:`Estado`}),(0,$.jsx)(`span`,{className:`hive-stat__value ${I?`text-emerald-400`:`text-white/30`}`,children:I?`Activo`:`Inactivo`})]})]}),(0,$.jsxs)(he,{open:r,onOpenChange:i,children:[(0,$.jsx)(ue,{asChild:!0,children:(0,$.jsxs)(`button`,{className:`hive-btn hive-btn--ghost h-8 px-2.5 text-[10px] font-black uppercase tracking-widest text-blue-400 shrink-0 flex items-center gap-1.5`,children:[(0,$.jsx)(Te,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:`CONFIG`})]})}),(0,$.jsxs)(pe,{className:`rounded-xl border border-white/10 p-0 overflow-hidden w-[calc(100vw-2rem)] max-w-md bg-[#09090b]`,children:[(0,$.jsxs)(`div`,{className:`p-5 border-b border-white/5 bg-white/5 relative overflow-hidden`,children:[(0,$.jsx)(`div`,{className:`absolute -top-10 -right-10 h-32 w-32 bg-blue-600/10 rounded-full blur-[80px] pointer-events-none`}),(0,$.jsx)(me,{className:`text-lg font-black text-white uppercase tracking-tighter`,children:e.name}),(0,$.jsx)(de,{className:`text-xs text-white/40 font-medium mt-0.5`,children:`Autenticación y punto de enlace.`})]}),(0,$.jsx)(`div`,{className:`p-5`,children:(0,$.jsx)(we,{provider:e,onSave:A,onCancel:()=>i(!1)})})]})]})]}),(0,$.jsx)(`div`,{className:`hive-strip--bottom ${I?``:`opacity-20`}`})]})}function Re(){let{providers:e,updateProvider:t}=B(),n=e.filter(e=>e.active).length;return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`hive-title-section`,children:`Providers de IA`}),(0,$.jsxs)(`span`,{className:`hive-tag hive-tag--provider`,children:[n,` activos / `,e.length,` total`]})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 gap-4 sm:gap-5`,children:[e.map(e=>(0,$.jsx)(Le,{provider:e,updateProvider:t},e.id)),e.length===0&&(0,$.jsx)(`div`,{className:`hive-empty-state col-span-full`,children:`No hay providers disponibles.`})]})]})}function ze({onSave:e,onCancel:t}){let[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(``),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(``),[m,_]=(0,Q.useState)(``),v=o.toLowerCase()===`ollama`||u.includes(`localhost`)||u.includes(`127.0.0.1`);return(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(W,{className:`hive-label`,children:`Nombre del Provider`}),(0,$.jsx)(H,{value:i,onChange:e=>a(e.target.value),placeholder:`Mi Provider Personalizado`,className:`hive-input !h-8 text-xs`}),(0,$.jsx)(`p`,{className:`text-[10px] text-white/30`,children:`Se usará como identificador interno`})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(W,{className:`hive-label`,children:`Tipo de Provider`}),(0,$.jsx)(H,{value:o,onChange:e=>s(e.target.value),placeholder:`openai, anthropic, ollama...`,className:`hive-input !h-8 text-xs`}),(0,$.jsx)(`p`,{className:`text-[10px] text-white/30`,children:`Ej: openai, anthropic, ollama, custom...`})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,$.jsx)(W,{className:`hive-label`,children:`API Key`})}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(H,{type:n?`text`:`password`,value:c,onChange:e=>l(e.target.value),placeholder:v?`Opcional para providers locales`:`sk-...`,className:`hive-input !h-8 text-xs pr-8`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>r(!n),className:`absolute right-0 top-0 h-8 w-8 flex items-center justify-center text-white/40 hover:text-white`,children:n?(0,$.jsx)(h,{className:`h-3 w-3`}):(0,$.jsx)(g,{className:`h-3 w-3`})})]})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(W,{className:`hive-label`,children:`Base URL (opcional)`}),(0,$.jsx)(H,{value:u,onChange:e=>d(e.target.value),placeholder:`https://api.example.com o http://localhost:11434`,className:`hive-input !h-8 text-xs`})]}),v&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(W,{className:`hive-label`,children:`Context Window (num_ctx)`}),(0,$.jsx)(`span`,{className:`text-[10px] text-white/30`,children:`tokens — por defecto 32 768`})]}),(0,$.jsx)(H,{type:`number`,value:m,onChange:e=>_(e.target.value),placeholder:`32768`,min:512,step:512,className:`hive-input !h-8 text-xs font-mono`}),(0,$.jsx)(`p`,{className:`text-[10px] text-amber-400/60`,children:`Aumenta si ves errores de contexto.`})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,$.jsx)(W,{className:`hive-label`,children:`Custom Headers (JSON)`})}),(0,$.jsx)(`textarea`,{value:f,onChange:e=>p(e.target.value),placeholder:`{ "x-custom-header": "value" }`,rows:3,className:`w-full bg-white/5 border border-white/10 rounded-md p-2 text-xs text-white/70 focus:outline-none focus:border-blue-500/50 transition-all font-mono`})]}),(0,$.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,$.jsx)(`button`,{className:`hive-btn hive-btn--form-cancel flex-1`,onClick:t,children:`Cancelar`}),(0,$.jsx)(`button`,{className:`hive-btn hive-btn--form-submit flex-1`,onClick:()=>{if(!i.trim()){V.fire(`Error`,`El nombre del provider es requerido`,`error`);return}if(!o){V.fire(`Error`,`Selecciona un tipo de provider`,`error`);return}if(!c.trim()&&!v){V.fire(`Error`,`La API Key es requerida para este provider`,`error`);return}let t;if(f.trim())try{t=JSON.parse(f.trim())}catch{V.fire(`Error`,`JSON de Headers inválido`,`error`);return}e({id:i.trim().toLowerCase().replace(/\s+/g,`-`),name:i.trim(),type:o,apiKey:c.trim()||``,baseUrl:u.trim()||void 0,headers:t,numCtx:m.trim()?Number(m.trim()):null})},children:`Crear Provider`})]}),(0,$.jsx)(`p`,{className:`text-[10px] text-white/20 pt-2`,children:`La API key se guarda cifrada en la base de datos.`})]})}var Be={chat:`Chat`,vision:`Vision`,json_mode:`JSON`,function_calling:`Functions`,streaming:`Stream`,embeddings:`Embed`,image_generation:`Imagen`,code:`Codigo`,reasoning:`Razonamiento`,transcription:`STT`,translation:`Traduccion`,tts:`TTS`,speech:`Voz`,high_quality:`HQ`,ocr:`OCR`};function Ve({capabilities:e}){let t=[];if(typeof e==`string`)try{t=JSON.parse(e)}catch{t=[]}else Array.isArray(e)&&(t=e);return t.length===0?null:(0,$.jsx)($.Fragment,{children:t.map(e=>(0,$.jsx)(G,{variant:`outline`,className:`text-[10px] py-0 h-4`,children:Be[e]??e},e))})}function He({model:e}){let{toggleModel:t}=se();return(0,$.jsx)(X,{className:e.active?``:`opacity-70 bg-muted/30`,children:(0,$.jsxs)(q,{className:`flex items-center gap-4 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex-1 space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`p`,{className:`text-sm font-semibold`,children:e.name}),(0,$.jsx)(G,{variant:`secondary`,className:`text-[10px]`,children:e.providerId||e.provider_id})]}),e.contextWindow&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[(e.contextWindow/1e3).toFixed(0),`K tokens contexto`]}),(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 pt-1`,children:(0,$.jsx)(Ve,{capabilities:e.capabilities})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col items-end gap-2`,children:[(0,$.jsx)(le,{checked:!!e.active,onCheckedChange:n=>t(e.id,n)}),(0,$.jsx)(G,{variant:e.active?`default`:`secondary`,className:`text-[10px]`,children:e.active?`Activo`:`Inactivo`})]})]})})}function Ue(e){if(!e)return[];if(typeof e==`string`)try{return JSON.parse(e)}catch{return[]}return Array.isArray(e)?e:[]}function We(){let{availableModels:e,activeProviders:t}=B(),n=U(e=>e.fetchAll),[r,i]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(`all`);(0,Q.useEffect)(()=>{n(!0)},[n]);let f=(0,Q.useMemo)(()=>e.filter(e=>{let t=Ue(e.capabilities),n=t.includes(`vision`)||t.includes(`image_generation`)||t.includes(`ocr`),i=e.name.toLowerCase().includes(r.toLowerCase())||e.id.toLowerCase().includes(r.toLowerCase()),a=u===`all`||e.providerId===u||e.provider_id===u;return n&&i&&a}),[e,r,u]);return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Modelos de Imagen / Vision`})}),(0,$.jsx)(G,{variant:`secondary`,children:f.length})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Estos modelos pueden procesar imagenes y documentos visuales. Si el agente usa uno de estos modelos, las imagenes se envian directamente. Si no, se usa OCR para extraer el texto.`}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(`div`,{className:`relative flex-1`,children:[(0,$.jsx)(P,{className:`absolute left-2 top-2 h-4 w-4 text-muted-foreground`}),(0,$.jsx)(H,{placeholder:`Buscar modelo...`,className:`h-8 pl-8 text-sm`,value:r,onChange:e=>i(e.target.value)})]}),(0,$.jsxs)(l,{value:u,onValueChange:d,children:[(0,$.jsx)(s,{className:`h-8 w-40 text-sm`,children:(0,$.jsx)(c,{placeholder:`Provider`})}),(0,$.jsxs)(o,{children:[(0,$.jsx)(a,{value:`all`,children:`Todos`}),t.map(e=>(0,$.jsx)(a,{value:e.id,children:e.name},e.id))]})]})]}),(0,$.jsx)(ye,{className:`h-[calc(100vh-26rem)]`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[f.map(e=>(0,$.jsx)(He,{model:e},e.id)),f.length===0&&(0,$.jsxs)(`div`,{className:`hive-empty-state`,children:[(0,$.jsx)(g,{className:`h-8 w-8 mx-auto mb-2 text-muted-foreground`}),(0,$.jsx)(`p`,{children:`No hay modelos con capacidad de vision.`}),(0,$.jsx)(`p`,{className:`text-xs mt-1`,children:`Habilita modelos con capability "vision" en la tab Providers.`})]})]})})]})}function Ge({open:e,onOpenChange:t}){let{availableTTSModels:n,fetchAvailableTTSModels:r,downloadTTSModel:a,isDownloadingModel:o,downloadLogs:s,fetchDownloadLogs:c}=re(),[l,u]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{e&&d()},[e]);let d=async()=>{u(!0),await r(),u(!1)},f=async e=>{await a(e)},p=e=>{switch(e){case`high`:return`bg-green-500/20 text-green-400 border-green-500/30`;case`medium`:return`bg-yellow-500/20 text-yellow-400 border-yellow-500/30`;case`low`:return`bg-zinc-500/20 text-zinc-400 border-zinc-500/30`}};return(0,$.jsx)(he,{open:e,onOpenChange:t,children:(0,$.jsxs)(pe,{className:`max-w-3xl max-h-[80vh] overflow-hidden flex flex-col`,children:[(0,$.jsxs)(fe,{children:[(0,$.jsx)(me,{className:`flex items-center gap-2`,children:`📦 Gestionar Modelos TTS`}),(0,$.jsx)(de,{children:`Descarga modelos de voz adicionales para Piper TTS. Cada modelo incluye el archivo de voz (.onnx) y su configuración (.json).`})]}),(0,$.jsxs)(`div`,{className:`flex-1 overflow-auto mt-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsxs)(G,{variant:`outline`,children:[n.filter(e=>e.installed).length,` / `,n.length,` instalados`]})}),(0,$.jsxs)(z,{size:`sm`,variant:`ghost`,onClick:d,disabled:l||o,className:`gap-2`,children:[(0,$.jsx)(N,{className:`h-4 w-4 ${l?`animate-spin`:``}`}),`Actualizar`]})]}),l&&!n.length?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,$.jsx)(v,{className:`h-6 w-6 animate-spin text-muted-foreground`})}):n.length===0?(0,$.jsx)(`div`,{className:`text-center py-8 text-muted-foreground`,children:`No hay modelos disponibles`}):(0,$.jsxs)(D,{children:[(0,$.jsx)(y,{children:(0,$.jsxs)(w,{children:[(0,$.jsx)(x,{children:`Modelo`}),(0,$.jsx)(x,{children:`Idioma`}),(0,$.jsx)(x,{children:`Calidad`}),(0,$.jsx)(x,{children:`Tamaño`}),(0,$.jsx)(x,{children:`Estado`}),(0,$.jsx)(x,{className:`text-right`,children:`Acciones`})]})}),(0,$.jsx)(C,{children:n.map(e=>(0,$.jsxs)(w,{children:[(0,$.jsx)(T,{className:`font-medium`,children:e.name}),(0,$.jsx)(T,{children:e.language}),(0,$.jsx)(T,{children:(0,$.jsx)(G,{className:p(e.quality),children:e.quality})}),(0,$.jsx)(T,{className:`text-muted-foreground`,children:e.size}),(0,$.jsx)(T,{children:e.installed?(0,$.jsxs)(G,{className:`bg-green-500/20 text-green-400 border-green-500/30 gap-1`,children:[(0,$.jsx)(i,{className:`h-3 w-3`}),`Instalado`]}):o&&s.some(t=>t.includes(e.name))?(0,$.jsxs)(G,{className:`bg-blue-500/20 text-blue-400 border-blue-500/30 gap-1`,children:[(0,$.jsx)(v,{className:`h-3 w-3 animate-spin`}),`Descargando`]}):(0,$.jsx)(G,{variant:`secondary`,className:`bg-zinc-700/50 text-zinc-400`,children:`No instalado`})}),(0,$.jsx)(T,{className:`text-right`,children:e.installed?(0,$.jsxs)(z,{size:`sm`,variant:`ghost`,disabled:!0,className:`gap-2 opacity-50`,children:[(0,$.jsx)(i,{className:`h-4 w-4`}),`Instalado`]}):(0,$.jsxs)(z,{size:`sm`,onClick:()=>f(e.id),disabled:o,className:`gap-2`,children:[(0,$.jsx)(m,{className:`h-4 w-4`}),`Descargar`]})})]},e.id))})]}),s.length>0&&(0,$.jsxs)(`div`,{className:`mt-4`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium mb-2`,children:`Progreso de descarga:`}),(0,$.jsx)(`div`,{className:`bg-black/40 rounded-md border border-zinc-700/50 p-3 h-32 overflow-y-auto font-mono text-xs text-zinc-300`,children:s.map((e,t)=>(0,$.jsx)(`div`,{className:e.startsWith(`[error]`)?`text-red-400`:e.startsWith(`✓`)?`text-green-400`:``,children:e},t))})]})]})]})})}function Ke(){let{localTTS:e,fetchLocalTTSStatus:t,installLocalTTS:n,startLocalTTS:r,stopLocalTTS:i}=re(),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)([]),[d,f]=(0,Q.useState)(``),[p,h]=(0,Q.useState)(!1),g=(0,Q.useRef)(null),_=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{t()},[t]),(0,Q.useEffect)(()=>(e.installing?g.current=setInterval(()=>{t(),s&&v()},3e3):g.current&&clearInterval(g.current),()=>{g.current&&clearInterval(g.current)}),[e.installing,s,t]),(0,Q.useEffect)(()=>{_.current&&(_.current.scrollTop=_.current.scrollHeight)},[l]);let v=async()=>{try{let e=await oe(`/api/tts-local/logs`);u(e.logs),f(e.ttsRoot)}catch{}},y=async()=>{o(!0),c(!0);try{await n(),await v()}finally{o(!1)}},x=async()=>{o(!0);try{await r()}finally{o(!1)}},S=async()=>{o(!0);try{await i()}finally{o(!1)}},C=async()=>{c(e=>!e),s||await v()},{installed:w,running:T,piperExists:D,voiceExists:O,port:k}=e,j=e.installing;return(0,$.jsxs)(X,{className:`relative overflow-hidden col-span-full ${T?`border-blue-500/30 bg-blue-500/[0.02]`:``}`,children:[(0,$.jsx)(K,{children:(0,$.jsxs)(`div`,{className:`flex items-start justify-between flex-wrap gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`text-3xl`,children:`🎙️`}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(J,{className:`text-lg flex items-center gap-2`,children:[`Piper TTS`,(0,$.jsx)(G,{variant:`outline`,className:`text-[10px] px-1.5 py-0 font-normal border-zinc-600 text-zinc-400`,children:`Local · Offline`})]}),(0,$.jsx)(Y,{className:`text-xs`,children:`TTS sin internet — binario nativo, sin Python, sin Docker. Fallback cuando no hay providers online.`})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[j?(0,$.jsxs)(G,{className:`bg-yellow-500/20 text-yellow-400 border-yellow-500/30 gap-1`,children:[(0,$.jsx)(N,{className:`h-3 w-3 animate-spin`}),`Instalando…`]}):w?(0,$.jsx)(G,{className:`bg-green-500/20 text-green-400 border-green-500/30`,children:`Instalado`}):(0,$.jsx)(G,{variant:`secondary`,className:`bg-zinc-700/50 text-zinc-400`,children:`No instalado`}),w&&(T?(0,$.jsxs)(G,{className:`bg-blue-500/20 text-blue-400 border-blue-500/30 gap-1`,children:[(0,$.jsx)(E,{className:`h-3 w-3`}),`Servidor :`,k]}):(0,$.jsxs)(G,{variant:`secondary`,className:`bg-zinc-700/50 text-zinc-400 gap-1`,children:[(0,$.jsx)(b,{className:`h-3 w-3`}),`Detenido`]}))]})]})}),(0,$.jsxs)(q,{className:`space-y-4`,children:[!w&&!j&&(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-xs text-muted-foreground`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 ${D?`text-green-400`:``}`,children:[(0,$.jsx)(`span`,{children:D?`✓`:`○`}),` Binario Piper (~8 MB)`]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 ${O?`text-green-400`:``}`,children:[(0,$.jsx)(`span`,{children:O?`✓`:`○`}),` Voz española (~60 MB)`]})]}),w&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Voz: `,(0,$.jsx)(`code`,{className:`text-zinc-300`,children:e.voices?.[0]||`N/A`}),` · Puerto:`,` `,(0,$.jsx)(`code`,{className:`text-zinc-300`,children:k}),` · Configurable con`,` `,(0,$.jsx)(`code`,{className:`text-zinc-300`,children:`TTS_PORT`}),` / `,(0,$.jsx)(`code`,{className:`text-zinc-300`,children:`TTS_VOICE`})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[!w&&!j&&(0,$.jsxs)(z,{size:`sm`,onClick:y,disabled:a,className:`gap-2`,children:[(0,$.jsx)(m,{className:`h-3.5 w-3.5`}),`Instalar Piper (~68 MB)`]}),j&&(0,$.jsxs)(z,{size:`sm`,disabled:!0,className:`gap-2 opacity-70`,children:[(0,$.jsx)(N,{className:`h-3.5 w-3.5 animate-spin`}),`Descargando…`]}),w&&!T&&(0,$.jsxs)(z,{size:`sm`,onClick:x,disabled:a,className:`gap-2 bg-blue-600 hover:bg-blue-500 text-white`,children:[(0,$.jsx)(ee,{className:`h-3.5 w-3.5`}),`Iniciar servidor`]}),T&&(0,$.jsxs)(z,{size:`sm`,variant:`outline`,onClick:S,disabled:a,className:`gap-2 border-red-500/40 text-red-400 hover:bg-red-500/10`,children:[(0,$.jsx)(A,{className:`h-3.5 w-3.5`}),`Detener servidor`]}),w&&(0,$.jsxs)(z,{size:`sm`,variant:`outline`,onClick:()=>h(!0),disabled:a,className:`gap-2`,children:[(0,$.jsx)(Ce,{className:`h-3.5 w-3.5`}),`Gestionar modelos`,e.voices&&e.voices.length>0&&(0,$.jsx)(G,{variant:`secondary`,className:`ml-1 text-[10px] px-1`,children:e.voices.length})]}),(0,$.jsx)(z,{size:`sm`,variant:`ghost`,onClick:()=>t(),title:`Actualizar estado`,className:`text-zinc-400`,children:(0,$.jsx)(N,{className:`h-3.5 w-3.5`})}),(0,$.jsxs)(z,{size:`sm`,variant:`ghost`,onClick:C,className:`gap-1.5 text-zinc-400 text-xs`,children:[(0,$.jsx)(M,{className:`h-3.5 w-3.5`}),s?`Ocultar log`:`Ver log`]})]}),j&&(0,$.jsx)(`p`,{className:`text-xs text-yellow-400/80`,children:`Descargando binario y modelo de voz… puede tardar 1-3 min. El estado se actualiza automáticamente.`}),s&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[d&&(0,$.jsxs)(`p`,{className:`text-[10px] text-zinc-500 font-mono`,children:[`ruta: `,d]}),(0,$.jsx)(`div`,{ref:_,className:`bg-black/40 rounded-md border border-zinc-700/50 p-3 h-40 overflow-y-auto font-mono text-[11px] text-zinc-300 leading-relaxed`,children:l.length===0?(0,$.jsx)(`span`,{className:`text-zinc-600`,children:`Sin registros aún. Inicia la instalación para ver el progreso.`}):l.map((e,t)=>(0,$.jsx)(`div`,{className:e.startsWith(`[stderr]`)||e.startsWith(`[error]`)?`text-red-400`:``,children:e},t))})]}),(0,$.jsx)(Ge,{open:p,onOpenChange:h})]})]})}var qe={groq:{name:`Groq`,description:`STT (Speech-to-Text) - Transcripcion de audio ultra-rapida`,logo:`🔴`,consoleUrl:`https://console.groq.com/keys`},elevenlabs:{name:`ElevenLabs`,description:`TTS (Text-to-Speech) - Voces neuronales de alta calidad`,logo:`🎙️`,consoleUrl:`https://elevenlabs.io/app/settings/api-keys`},openai:{name:`OpenAI`,description:`STT/TTS - Whisper y TTS-1`,logo:`🟢`,consoleUrl:`https://platform.openai.com/api-keys`},gemini:{name:`Google Gemini`,description:`TTS - Voces de Gemini`,logo:`🔵`,consoleUrl:`https://aistudio.google.com/app/apikey`},qwen:{name:`Qwen (Alibaba)`,description:`TTS - Voces de Qwen`,logo:`🟣`,consoleUrl:`https://dashscope.console.aliyun.com/apiKey`},piper:{name:`Piper TTS (Local)`,description:`TTS offline — sin internet, sin API key.`,logo:`🖥️`,consoleUrl:`/settings/voz`,noApiKey:!0}};function Je(e){if(!e)return[];if(typeof e==`string`)try{return JSON.parse(e)}catch{return[]}return Array.isArray(e)?e:[]}function Ye(){let{availableModels:e,activeProviders:t}=B(),{voiceProviders:n,configuredVoiceProviders:r,fetchVoiceProviders:u,fetchConfiguredVoiceProviders:d,saveVoiceProviderKey:f}=ie(),p=U(e=>e.fetchAll),[m,h]=(0,Q.useState)(null),[g,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(!1),[x,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(``),[E,D]=(0,Q.useState)(`all`);(0,Q.useEffect)(()=>{u(),d(),p(!0)},[u,d,p]);let A=async e=>{if(g.trim()){b(!0);try{await f(e,g.trim()),await d(),h(null),v(``)}catch(e){console.error(`Failed to save API key:`,e)}finally{b(!1)}}},j=n.length>0?n:Object.keys(qe),M=(0,Q.useMemo)(()=>e.filter(e=>{let t=e.model_type===`stt`||e.model_type===`tts`,n=Je(e.capabilities),r=n.includes(`transcription`)||n.includes(`tts`)||n.includes(`speech`),i=e.name.toLowerCase().includes(w.toLowerCase())||e.id.toLowerCase().includes(w.toLowerCase()),a=E===`all`||e.providerId===E||e.provider_id===E;return(t||r)&&i&&a}),[e,w,E]);return(0,$.jsxs)(`div`,{className:`space-y-6`,children:[(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Modelos de Voz (STT / TTS)`}),(0,$.jsx)(G,{variant:`secondary`,children:M.length})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(`div`,{className:`relative flex-1`,children:[(0,$.jsx)(P,{className:`absolute left-2 top-2 h-4 w-4 text-muted-foreground`}),(0,$.jsx)(H,{placeholder:`Buscar modelo...`,className:`h-8 pl-8 text-sm`,value:w,onChange:e=>T(e.target.value)})]}),(0,$.jsxs)(l,{value:E,onValueChange:D,children:[(0,$.jsx)(s,{className:`h-8 w-40 text-sm`,children:(0,$.jsx)(c,{placeholder:`Provider`})}),(0,$.jsxs)(o,{children:[(0,$.jsx)(a,{value:`all`,children:`Todos`}),t.map(e=>(0,$.jsx)(a,{value:e.id,children:e.name},e.id))]})]})]}),(0,$.jsx)(ye,{className:`h-60`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[M.map(e=>(0,$.jsx)(He,{model:e},e.id)),M.length===0&&(0,$.jsxs)(`div`,{className:`hive-empty-state`,children:[(0,$.jsx)(k,{className:`h-8 w-8 mx-auto mb-2 text-muted-foreground`}),(0,$.jsx)(`p`,{children:`No hay modelos de voz disponibles.`})]})]})})]}),(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:`API Keys de Voz`}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsx)(Ke,{}),j.map(e=>{let t=qe[e]||{name:e,description:``,logo:`🔌`,consoleUrl:`#`},n=r[e]===!0,a=m===e;return(0,$.jsxs)(X,{className:`relative overflow-hidden ${n?`border-green-500/30 bg-green-500/[0.02]`:``}`,children:[(0,$.jsx)(K,{children:(0,$.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`text-3xl`,children:t.logo}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(J,{className:`text-lg`,children:t.name}),(0,$.jsx)(Y,{className:`text-xs`,children:t.description})]})]}),t.noApiKey?(0,$.jsx)(G,{variant:`outline`,className:`bg-zinc-700/40 text-zinc-300 border-zinc-600`,children:`Sin API key`}):n?(0,$.jsxs)(G,{variant:`default`,className:`bg-green-500/20 text-green-400 border-green-500/30`,children:[(0,$.jsx)(i,{className:`h-3 w-3 mr-1`}),`Configurado`]}):(0,$.jsx)(G,{variant:`secondary`,className:`bg-yellow-500/20 text-yellow-400 border-yellow-500/30`,children:`Sin configurar`})]})}),(0,$.jsx)(q,{className:`space-y-4`,children:t.noApiKey?(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t.description}):a?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(W,{htmlFor:`api-key-${e}`,children:`API Key`}),(0,$.jsxs)(`div`,{className:`flex gap-2 mt-1`,children:[(0,$.jsx)(H,{id:`api-key-${e}`,type:x?`text`:`password`,placeholder:`sk-...`,value:g,onChange:e=>v(e.target.value),className:`flex-1 font-mono text-sm`,autoFocus:!0}),(0,$.jsx)(z,{variant:`outline`,size:`icon`,onClick:()=>C(!x),title:x?`Ocultar`:`Mostrar`,children:x?(0,$.jsx)(O,{className:`h-4 w-4`}):(0,$.jsx)(S,{className:`h-4 w-4`})})]})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(z,{size:`sm`,onClick:()=>A(e),disabled:y||!g.trim(),className:`flex-1`,children:y?`Guardando...`:`Guardar`}),(0,$.jsx)(z,{size:`sm`,variant:`outline`,onClick:()=>{h(null),v(``)},children:`Cancelar`})]})]}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[n?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(_,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:`API key guardada de forma segura (encriptada)`})]}):(0,$.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Necesitas una API key de `,t.name,` para usar esta funcionalidad.`]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[n?(0,$.jsxs)(z,{size:`sm`,variant:`outline`,onClick:()=>{h(e),v(``)},className:`flex-1`,children:[(0,$.jsx)(_,{className:`h-3 w-3 mr-2`}),`Actualizar API Key`]}):(0,$.jsxs)(z,{size:`sm`,onClick:()=>{h(e),v(``)},className:`flex-1`,children:[(0,$.jsx)(_,{className:`h-3 w-3 mr-2`}),`Configurar API Key`]}),(0,$.jsx)(z,{size:`sm`,variant:`outline`,onClick:()=>window.open(t.consoleUrl,`_blank`),children:`Obtener Key`})]})]})})]},e)})]})]}),(0,$.jsxs)(X,{children:[(0,$.jsxs)(K,{children:[(0,$.jsx)(J,{className:`text-lg`,children:`Como funciona?`}),(0,$.jsx)(Y,{children:`Configura las API keys de los providers de voz para habilitar STT y TTS en tus canales.`})]}),(0,$.jsxs)(q,{className:`space-y-4 text-sm text-muted-foreground`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`strong`,{className:`text-foreground`,children:`STT (Speech-to-Text):`}),` Convierte el audio entrante en texto. Groq Whisper es recomendado por su velocidad.`]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`strong`,{className:`text-foreground`,children:`TTS (Text-to-Speech):`}),` Convierte las respuestas de texto en audio. ElevenLabs ofrece las voces mas naturales.`]}),(0,$.jsx)(`div`,{className:`pt-2 border-t`,children:(0,$.jsx)(`p`,{className:`text-xs`,children:`Las API keys se guardan encriptadas en la base de datos local de Hive.`})})]})]})]})}function Xe(){let{localLLM:e,localLLMLogs:t,fetchLocalLLMStatus:n,installLocalLLM:r,startLocalLLM:i,stopLocalLLM:a,downloadLLMModel:o,fetchDownloadProgress:s,fetchLocalLLMLogs:c}=ae(),{installed:l,binaryExists:u,anyModelExists:d,installing:f,downloadingModelId:h,gpu:g,models:_}=e,[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(``),[w,T]=(0,Q.useState)(``),[E,D]=(0,Q.useState)(null),O=(0,Q.useRef)(null),k=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{n()},[n]),(0,Q.useEffect)(()=>{let e=_.filter(e=>e.downloaded);if(e.length===0){T(``);return}(!w||!e.find(e=>e.id===w))&&T(e[0].id)},[_,w]),(0,Q.useEffect)(()=>(e.installing||e.downloadingModelId?O.current=setInterval(()=>{n()},3e3):O.current&&clearInterval(O.current),()=>{O.current&&clearInterval(O.current)}),[e.installing,e.downloadingModelId,n]),(0,Q.useEffect)(()=>{if(!e.downloadingModelId){D(null);return}let t=setInterval(async()=>{let e=await s();e?.active?D({percent:e.percent??0,downloaded:e.downloaded??0,total:e.total??0}):(D(null),await n())},800);return()=>clearInterval(t)},[e.downloadingModelId,s,n]),(0,Q.useEffect)(()=>{k.current&&(k.current.scrollTop=k.current.scrollHeight)},[t]),(0,Q.useEffect)(()=>{if(!b)return;let e=new EventSource(`/api/llm-local/logs?mode=TEXT`);return e.onmessage=e=>{try{let t=JSON.parse(e.data);t.llmRoot&&C(t.llmRoot),(t.logs||t.serverLogs)&&U.setState(e=>({localLLMLogs:[...t.logs||[],...t.serverLogs||[]]}))}catch(e){console.error(`Error parsing SSE log data`,e)}},()=>{e.close()}},[b]);let j=async()=>{y(!0),x(!0);try{await r()}finally{y(!1)}},te=async e=>{y(!0);try{await o(e)}finally{y(!1)}},P=async(e=`TEXT`)=>{if(w){y(!0);try{await i(e,w)}finally{y(!1)}}},F=async e=>{y(!0);try{await a(e)}finally{y(!1)}};return(0,$.jsxs)(X,{className:`relative overflow-hidden col-span-full ${l?`border-amber-500/30 bg-amber-500/[0.02]`:``}`,children:[(0,$.jsx)(K,{children:(0,$.jsxs)(`div`,{className:`flex items-start justify-between flex-wrap gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`text-3xl`,children:`🤖`}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(J,{className:`text-lg flex items-center gap-2`,children:[`Local LLM (llama-server)`,(0,$.jsx)(G,{variant:`outline`,className:`text-[10px] px-1.5 py-0 font-normal border-zinc-600 text-zinc-400`,children:`Local · Private`})]}),(0,$.jsxs)(Y,{className:`text-xs`,children:[`Inferencia local sin internet usando llama-server. Soporta aceleración por GPU (`,g.backend,`).`]})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[e.activeServers.map(e=>(0,$.jsxs)(G,{className:`bg-green-500/20 text-green-400 border-green-500/30 gap-1.5`,children:[(0,$.jsxs)(`span`,{className:`relative flex h-2 w-2`,children:[(0,$.jsx)(`span`,{className:`animate-ping absolute inline-flex h-full w-full rounded-full bg-green-400 opacity-75`}),(0,$.jsx)(`span`,{className:`relative inline-flex rounded-full h-2 w-2 bg-green-500`})]}),e.mode,` (`,e.port,`)`]},e.mode)),!e.running&&u&&(0,$.jsx)(G,{variant:`outline`,className:`border-zinc-700 text-zinc-500`,children:`Apagado`}),f?(0,$.jsxs)(G,{className:`bg-yellow-500/20 text-yellow-400 border-yellow-500/30 gap-1`,children:[(0,$.jsx)(N,{className:`h-3 w-3 animate-spin`}),`Configurando…`]}):u?(0,$.jsx)(G,{className:`bg-amber-500/10 text-amber-500 border-amber-500/30`,children:`Binario Listo`}):(0,$.jsx)(G,{variant:`secondary`,className:`bg-zinc-700/50 text-zinc-400`,children:`No configurado`}),g&&(0,$.jsxs)(G,{variant:`outline`,className:`gap-1 border-zinc-700 text-zinc-400`,children:[(0,$.jsx)(p,{className:`h-3 w-3`}),g.deviceName||g.backend]})]})]})}),(0,$.jsxs)(q,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`h4`,{className:`text-sm font-medium flex items-center gap-2`,children:[(0,$.jsx)(xe,{className:`h-4 w-4 text-amber-400`}),`Infraestructura`]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs border border-zinc-800 p-2 rounded bg-zinc-900/50`,children:[(0,$.jsx)(`span`,{className:`text-zinc-400`,children:`Motor llama-server`}),u?(0,$.jsx)(`span`,{className:`text-green-400 font-medium`,children:`✓ Instalado`}):(0,$.jsx)(z,{variant:`link`,size:`sm`,onClick:j,disabled:v||f,className:`h-auto p-0 text-amber-400`,children:`Instalar ahora`})]}),e.activeServers.length>0&&(0,$.jsxs)(`div`,{className:`space-y-1.5 mt-2`,children:[(0,$.jsx)(`p`,{className:`text-[10px] text-zinc-500 uppercase font-bold tracking-wider`,children:`Servidores Activos`}),e.activeServers.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-[11px] bg-zinc-800/30 p-1.5 rounded border border-zinc-700/50`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{className:`text-zinc-300 font-medium`,children:e.mode}),(0,$.jsx)(`span`,{className:`text-[10px] text-zinc-500 truncate max-w-[180px]`,title:e.modelId,children:e.modelId})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`span`,{className:`text-zinc-500`,children:[`Puerto `,e.port]}),(0,$.jsx)(z,{variant:`ghost`,size:`icon`,className:`h-5 w-5 text-red-400 hover:text-red-300 hover:bg-red-400/10`,onClick:()=>F(e.mode),disabled:v,children:(0,$.jsx)(A,{className:`h-3 w-3 fill-current`})})]})]},e.mode))]})]})]}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`h4`,{className:`text-sm font-medium flex items-center gap-2`,children:[(0,$.jsx)(Ce,{className:`h-4 w-4 text-amber-400`}),`Modelos Disponibles`]}),(0,$.jsx)(`div`,{className:`space-y-2`,children:_.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs border border-zinc-800 p-2 rounded bg-zinc-900/50`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{className:`text-zinc-200`,children:e.name}),(0,$.jsx)(`span`,{className:`text-[10px] text-zinc-500`,children:e.size})]}),e.downloaded?(0,$.jsx)(`span`,{className:`text-green-400 font-medium`,children:`✓ Descargado`}):h===e.id?(0,$.jsxs)(`div`,{className:`flex flex-col items-end gap-1 w-32`,children:[(0,$.jsxs)(`span`,{className:`text-yellow-400 flex items-center gap-1 text-[10px]`,children:[(0,$.jsx)(N,{className:`h-3 w-3 animate-spin`}),`Descargando…`]}),E&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(be,{value:E.percent,className:`h-1.5 w-full bg-zinc-800`}),(0,$.jsxs)(`span`,{className:`text-[9px] text-zinc-500`,children:[E.percent,`% · `,(E.downloaded/1024/1024).toFixed(0),` MB / `,(E.total/1024/1024).toFixed(0),` MB`]})]})]}):(0,$.jsx)(z,{variant:`outline`,size:`sm`,onClick:()=>te(e.id),disabled:v||!!h,className:`h-7 text-[10px] px-2 border-zinc-700`,children:`Descargar`})]},e.id))})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2 pt-2 border-t border-zinc-800`,children:[!u&&!f&&(0,$.jsxs)(z,{size:`sm`,onClick:j,disabled:v,className:`gap-2 bg-amber-600 hover:bg-amber-500`,children:[(0,$.jsx)(m,{className:`h-3.5 w-3.5`}),`Configurar Local LLM`]}),u&&!f&&(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2 w-full items-center`,children:[(0,$.jsx)(`div`,{className:`w-full sm:w-auto`,children:(0,$.jsxs)(`select`,{value:w,onChange:e=>T(e.target.value),disabled:v||e.activeServers.length>0,className:`h-8 text-xs w-full sm:w-[260px] bg-zinc-900 border border-zinc-700 text-zinc-200 rounded-md px-2 py-1 focus:outline-none focus:ring-1 focus:ring-amber-500/50 disabled:opacity-50`,children:[_.filter(e=>e.downloaded).length===0&&(0,$.jsx)(`option`,{value:``,children:`No hay modelos descargados`}),_.filter(e=>e.downloaded).map(e=>(0,$.jsxs)(`option`,{value:e.id,children:[e.name,` (`,e.size,`)`]},e.id))]})}),(0,$.jsx)(`div`,{className:`flex gap-1 bg-zinc-900/80 p-1 rounded-lg border border-zinc-800`,children:[`TEXT`,`IMAGE`,`AUDIO`].map(t=>{let n=e.activeServers.some(e=>e.mode===t);return(0,$.jsxs)(z,{size:`sm`,variant:n?`default`:`ghost`,onClick:()=>n?F(t):P(t),disabled:v||!n&&!d,className:`gap-1.5 text-[10px] h-7 px-2.5 ${n?`bg-green-600 hover:bg-green-500 text-white`:`text-zinc-400 hover:text-zinc-200`}`,children:[n?(0,$.jsx)(A,{className:`h-3 w-3 fill-current`}):(0,$.jsx)(ee,{className:`h-3 w-3 fill-current`}),t]},t)})}),e.running&&(0,$.jsxs)(z,{size:`sm`,variant:`outline`,onClick:()=>F(),disabled:v,className:`gap-2 border-red-500/30 text-red-400 hover:bg-red-500/10 h-9`,children:[(0,$.jsx)(A,{className:`h-3.5 w-3.5 fill-current`}),`Apagar Todo`]})]}),(0,$.jsx)(z,{size:`sm`,variant:`ghost`,onClick:()=>n(),title:`Actualizar estado`,className:`text-zinc-400`,children:(0,$.jsx)(N,{className:`h-3.5 w-3.5`})}),(0,$.jsxs)(z,{size:`sm`,variant:`ghost`,onClick:()=>{x(e=>!e)},className:`gap-1.5 text-zinc-400 text-xs ml-auto`,children:[(0,$.jsx)(M,{className:`h-3.5 w-3.5`}),b?`Ocultar log`:`Ver log`]})]}),b&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[S&&(0,$.jsxs)(`p`,{className:`text-[10px] text-zinc-500 font-mono text-right`,children:[`ruta: `,S]}),(0,$.jsx)(`div`,{ref:k,className:`bg-black/40 rounded-md border border-zinc-700/50 p-3 h-48 overflow-y-auto font-mono text-[11px] text-zinc-300 leading-relaxed`,children:t.length===0?(0,$.jsx)(`span`,{className:`text-zinc-600`,children:`Sin registros aún. Inicia la configuración para ver el progreso.`}):t.map((e,t)=>(0,$.jsx)(`div`,{className:e.includes(`[error]`)?`text-red-400`:e.includes(`✓`)?`text-green-400`:``,children:e},t))})]})]})]})}function Ze(e){if(!e)return[];if(typeof e==`string`)try{return JSON.parse(e)}catch{return[]}return Array.isArray(e)?e:[]}function Qe(){let{availableModels:e,activeProviders:t}=B(),n=U(e=>e.fetchAll),[r,i]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(`all`);(0,Q.useEffect)(()=>{n(!0)},[]);let f=(0,Q.useMemo)(()=>e.filter(e=>{let t=Ze(e.capabilities),n=(t.includes(`chat`)||!t.includes(`vision`))&&e.model_type!==`stt`&&e.model_type!==`tts`,i=e.name.toLowerCase().includes(r.toLowerCase())||e.id.toLowerCase().includes(r.toLowerCase()),a=u===`all`||e.providerId===u||e.provider_id===u;return n&&i&&a}),[e,r,u]);return(0,$.jsxs)(`div`,{className:`space-y-6`,children:[(0,$.jsx)(Xe,{}),(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Modelos de Texto`}),(0,$.jsx)(G,{variant:`secondary`,children:f.length})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(`div`,{className:`relative flex-1`,children:[(0,$.jsx)(P,{className:`absolute left-2 top-2 h-4 w-4 text-muted-foreground`}),(0,$.jsx)(H,{placeholder:`Buscar modelo...`,className:`h-8 pl-8 text-sm`,value:r,onChange:e=>i(e.target.value)})]}),(0,$.jsxs)(l,{value:u,onValueChange:d,children:[(0,$.jsx)(s,{className:`h-8 w-40 text-sm`,children:(0,$.jsx)(c,{placeholder:`Provider`})}),(0,$.jsxs)(o,{children:[(0,$.jsx)(a,{value:`all`,children:`Todos`}),t.map(e=>(0,$.jsx)(a,{value:e.id,children:e.name},e.id))]})]})]}),(0,$.jsx)(ye,{className:`h-[calc(100vh-22rem)]`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[f.map(e=>(0,$.jsx)(He,{model:e},e.id)),f.length===0&&(0,$.jsx)(`div`,{className:`hive-empty-state`,children:`No hay modelos de texto disponibles.`})]})})]})]})}var $e=te,et=R,tt=g,nt=k,rt=I;function it(){let{providers:e,createProvider:t}=B(),[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(`text`);return(0,$.jsxs)(`div`,{className:`space-y-4 mt-6 sm:mt-10`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3 mb-2`,children:[(0,$.jsx)(`div`,{className:`hive-page-header__dot`}),(0,$.jsx)(`span`,{className:`hive-page-header__label`,children:`INFRAESTRUCTURA`})]}),(0,$.jsxs)(`h2`,{className:`hive-title-page`,children:[`Providers de IA`,(0,$.jsx)(`span`,{className:`hive-title-page__accent`,children:`.`})]})]}),(0,$.jsxs)(he,{open:n,onOpenChange:e=>{r(e)},children:[(0,$.jsx)(ue,{asChild:!0,children:(0,$.jsxs)(`button`,{className:`hive-btn hive-btn--primary`,children:[(0,$.jsx)($e,{className:`mr-1 h-4 w-4`}),`Añadir Provider`]})}),(0,$.jsxs)(pe,{className:`max-w-md`,children:[(0,$.jsxs)(fe,{className:`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,$.jsx)(me,{className:`text-xl font-black text-white uppercase tracking-tighter`,children:`Añadir Provider`}),(0,$.jsx)(de,{className:`text-xs text-white/40 font-medium mt-1`,children:`Crea un nuevo provider de IA para tu infraestructura.`})]}),(0,$.jsx)(`div`,{className:`p-6`,children:(0,$.jsx)(ze,{onSave:async e=>{try{await t({id:e.id,name:e.name,base_url:e.baseUrl,api_key:e.apiKey,headers:e.headers,num_ctx:e.numCtx}),r(!1)}catch(e){console.error(`Error creating provider:`,e)}},onCancel:()=>r(!1)})})]})]})]}),(0,$.jsxs)(ve,{value:i,onValueChange:a,className:`w-full`,children:[(0,$.jsxs)(_e,{className:`w-full grid grid-cols-4 h-10`,children:[(0,$.jsxs)(Z,{value:`text`,className:`gap-1.5 text-xs`,children:[(0,$.jsx)(et,{className:`h-3.5 w-3.5`}),`Texto`]}),(0,$.jsxs)(Z,{value:`vision`,className:`gap-1.5 text-xs`,children:[(0,$.jsx)(tt,{className:`h-3.5 w-3.5`}),`Imagen`]}),(0,$.jsxs)(Z,{value:`voice`,className:`gap-1.5 text-xs`,children:[(0,$.jsx)(nt,{className:`h-3.5 w-3.5`}),`Voz`]}),(0,$.jsxs)(Z,{value:`providers`,className:`gap-1.5 text-xs`,children:[(0,$.jsx)(rt,{className:`h-3.5 w-3.5`}),`Providers`]})]}),(0,$.jsx)(ge,{value:`text`,className:`mt-4`,children:(0,$.jsx)(Qe,{})}),(0,$.jsx)(ge,{value:`vision`,className:`mt-4`,children:(0,$.jsx)(We,{})}),(0,$.jsx)(ge,{value:`voice`,className:`mt-4`,children:(0,$.jsx)(Ye,{})}),(0,$.jsx)(ge,{value:`providers`,className:`mt-4`,children:(0,$.jsx)(Re,{})})]})]})}export{it as ProvidersPage};
@@ -1,9 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as t}from"./vendor-charts-Bu2lyBKP.js";import{o as n}from"./vendor-query-DsWPbQdG.js";import{n as r,r as i}from"./utils-3pnRFmFe.js";import{t as a}from"./activity-c3pNngT_.js";import{t as o}from"./bell-8BqRYmzf.js";import{t as s}from"./calendar-B-KZ9RQO.js";import{c,i as l,n as u,o as d,s as f,t as p}from"./select-Cl16QYa_.js";import{n as m,t as h}from"./chevron-up-BYhk0K2J.js";import{t as g}from"./circle-alert-CyHDwUj8.js";import{t as _}from"./circle-check-Bb54Ebmu.js";import{t as v}from"./copy-dU94ZGsi.js";import{t as y}from"./cpu-DSpPVLAz.js";import{n as b,t as x}from"./eye-epHJZ_nQ.js";import{t as S}from"./hexagon-DsGOUl-H.js";import{t as C}from"./history-BSG-Ypqf.js";import{t as w}from"./info-NwLoa2Mj.js";import{t as T}from"./key-3EP0dhkT.js";import{t as E}from"./loader-circle-CZNax6kS.js";import{t as D}from"./lock-Ei1_J-Nq.js";import{t as O}from"./pause-BUqah9Bi.js";import{n as k,t as A}from"./terminal-DN38Q456.js";import{t as j}from"./play-NcZ4swwL.js";import{t as M}from"./plus-CX1xyhp5.js";import{t as N}from"./refresh-cw-DaYdjQFk.js";import{t as P}from"./search-BGmPJ-6L.js";import{t as F}from"./send-BuQcUO-R.js";import{t as I}from"./shield-C-05qB-2.js";import{t as L}from"./sparkles-D6fx8JC5.js";import{t as ee}from"./trash-2-BHRa5ft9.js";import{t as R}from"./triangle-alert-D4nwAVbc.js";import{t as z}from"./zap-QO7iWMRg.js";import{l as B}from"./vendor-router-pCP7sjma.js";import{r as te}from"./gateway-url-iG-C6Agn.js";import{B as V,G as H,H as ne,J as U,K as W,M as G,U as re,V as ie,W as ae,X as oe,Y as se,f as ce,g as K,h as q,j as J,l as le,m as Y,n as ue,o as de,p as X,u as fe,z as pe}from"./index-CmGm_r89.js";import{t as Z}from"./label-byJkqOYq.js";import{t as me}from"./textarea-wvA-FDjO.js";import{t as he}from"./switch-h2SfQX4B.js";import{a as ge,c as _e,i as ve,o as ye,r as be,s as xe,t as Se}from"./dialog-DfS3idb3.js";import{t as Ce}from"./badge-CxTPR6_t.js";import{a as we,n as Te,o as Ee,r as De,t as Oe}from"./card-CXAm46at.js";import"./useProviders-eEri6BAc.js";import{t as ke}from"./scroll-area-BXtLsE9E.js";var Ae=i(`Briefcase`,[[`path`,{d:`M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16`,key:`jecpp`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`6`,rx:`2`,key:`i6l2r4`}]]),je=i(`ChartColumn`,[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]]),Me=i(`CodeXml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),Ne=i(`Code`,[[`polyline`,{points:`16 18 22 12 16 6`,key:`z7tu5w`}],[`polyline`,{points:`8 6 2 12 8 18`,key:`1eg1df`}]]),Pe=i(`Earth`,[[`path`,{d:`M21.54 15H17a2 2 0 0 0-2 2v4.54`,key:`1djwo0`}],[`path`,{d:`M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17`,key:`1tzkfa`}],[`path`,{d:`M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05`,key:`14pb5j`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Fe=i(`Hammer`,[[`path`,{d:`m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9`,key:`eefl8a`}],[`path`,{d:`m18 15 4-4`,key:`16gjal`}],[`path`,{d:`m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172V7l-2.26-2.26a6 6 0 0 0-4.202-1.756L9 2.96l.92.82A6.18 6.18 0 0 1 12 8.4V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5`,key:`b7pghm`}]]),Ie=i(`Languages`,[[`path`,{d:`m5 8 6 6`,key:`1wu5hv`}],[`path`,{d:`m4 14 6-6 2-3`,key:`1k1g8d`}],[`path`,{d:`M2 5h12`,key:`or177f`}],[`path`,{d:`M7 2h1`,key:`1t2jsx`}],[`path`,{d:`m22 22-5-10-5 10`,key:`don7ne`}],[`path`,{d:`M14 18h6`,key:`1m8k6r`}]]),Le=i(`MessageCircle`,[[`path`,{d:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,key:`vv11sd`}]]),Re=i(`Power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),ze=i(`Settings2`,[[`path`,{d:`M20 7h-9`,key:`3s1dr2`}],[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),Be=i(`ShieldCheck`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Ve=i(`ShieldOff`,[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]),Q=e(t(),1),He=te((e,t)=>({isLoading:!1,error:null,configs:[],conflicts:[],templates:[],setLoading:t=>e({isLoading:t}),setError:t=>e({error:t}),fetchEthics:async()=>{e({isLoading:!0,error:null});try{let t=(await X(`/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 X(`/api/ethics/${i.id}`,{method:`PUT`,body:{content:n}}):await X(`/api/ethics`,{method:`POST`,body:{name:`Default`,content:n,active:!0}}),e({isLoading:!1}),a.message||`Guardado correctamente`}catch(t){throw e({isLoading:!1,error:t instanceof Error?t.message:`Failed to save ethics`}),t}},fetchConfigs:async()=>{e({isLoading:!0,error:null});try{e({configs:await X(`/api/workspace/ethics/configs`),isLoading:!1})}catch(t){e({isLoading:!1,error:t instanceof Error?t.message:`Failed to fetch configs`})}},fetchConflicts:async()=>{e({isLoading:!0,error:null});try{e({conflicts:await X(`/api/workspace/ethics/conflicts`),isLoading:!1})}catch(t){e({isLoading:!1,error:t instanceof Error?t.message:`Failed to fetch conflicts`})}},fetchTemplates:async()=>{e({isLoading:!0,error:null});try{e({templates:await X(`/api/workspace/ethics/templates`),isLoading:!1})}catch(t){e({isLoading:!1,error:t instanceof Error?t.message:`Failed to fetch templates`})}},updateConfig:(t,n)=>{e(e=>({configs:e.configs.map(e=>e.id===t?{...e,...n,updatedAt:new Date().toISOString(),version:e.version+1}:e)}))},addConfig:t=>{let n={...t,id:r(),version:1,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};e(e=>({configs:[...e.configs,n]}))},removeConfig:t=>{e(e=>({configs:e.configs.filter(e=>e.id!==t)}))}})),$=n();function Ue(){let{configs:e,fetchEthics:t,isLoading:n}=He(),[r,i]=(0,Q.useState)(null),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)({name:``,description:``,content:``}),[l,u]=(0,Q.useState)(!1),d=(0,Q.useRef)(null),f=()=>{let e=d.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)};(0,Q.useEffect)(()=>{a&&setTimeout(f,0)},[a,s.content]),(0,Q.useEffect)(()=>{t().catch(console.error)},[t]),(0,Q.useEffect)(()=>{if(e.length===0)return;let t=e,n=t.find(e=>e.active)||t[0];r||(i(n.id),c({name:n.name,description:n.description||``,content:n.content}))},[e,r]);let p=e.find(e=>e.id===r),m=e=>{i(e.id),c({name:e.name,description:e.description||``,content:e.content}),o(!0)},h=async n=>{K.show(`Activando registro de ética...`);let r=e;try{let e=await Promise.all(r.map(e=>X(`/api/ethics/${e.id}`,{method:`PUT`,body:{active:+(e.id===n)}}).catch(()=>({}))));await t();let i=e.find((e,t)=>r[t].id===n);Y.fire({icon:`success`,title:i?.message||`Registro de ética activado`})}catch(e){Y.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)(E,{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)(I,{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)(R,{className:`h-8 w-8 text-white/20`})}),(0,$.jsxs)(`div`,{className:`text-center`,children:[(0,$.jsx)(`p`,{className:`hive-title-section text-center mb-2`,children:`Sin Protocolos Base`}),(0,$.jsx)(`p`,{className:`text-xs text-white/40 mb-8 max-w-[300px] mx-auto leading-relaxed`,children:`No se han detectado lineamientos éticos en el sistema. Selecciona una de las plantillas inferiores para comenzar.`})]})]})}):(0,$.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6`,children:e.map(e=>{let t=!!e.active,n=r===e.id;return(0,$.jsxs)(`div`,{onClick:()=>m(e),className:`hive-card group transition-all duration-500 cursor-pointer ${n?`hive-card--active`:`opacity-60 grayscale-[0.8] hover:opacity-100 hover:grayscale-0`}`,children:[(0,$.jsxs)(`div`,{className:`hive-card-body relative overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between mb-6`,children:[(0,$.jsx)(`div`,{className:`hive-icon-wrap--internal ${n?`hive-icon-wrap--internal-active`:`hive-icon-wrap--internal-disabled`}`,children:(0,$.jsx)(ae,{className:`h-6 w-6`})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t&&(0,$.jsx)(`span`,{className:`hive-status-label--active`,children:`ACTIVO`}),(0,$.jsx)(`div`,{className:t?`hive-status-dot--active`:`hive-status-dot--disabled`})]})]}),(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-lg font-black text-white uppercase tracking-tighter mb-1 line-clamp-1 group-hover:text-blue-400 transition-colors text-ellipsis`,children:e.name}),(0,$.jsx)(`p`,{className:`text-xs text-white/40 font-medium leading-relaxed line-clamp-1 h-4`,children:e.description||`Sin descripción adicional`})]}),(0,$.jsxs)(`div`,{className:`pt-4 border-t border-white/5 flex items-center gap-4`,children:[(0,$.jsxs)(`div`,{className:`hive-stat`,children:[(0,$.jsx)(`span`,{className:`hive-stat__label`,children:`CONFIG`}),(0,$.jsx)(`span`,{className:`hive-stat__value`,children:e.is_default?`DEFAULT`:`CUSTOM`})]}),(0,$.jsxs)(`div`,{className:`hive-stat`,children:[(0,$.jsx)(`span`,{className:`hive-stat__label`,children:`PRECEDENCIA`}),(0,$.jsx)(`span`,{className:`hive-stat__value`,children:t?`ALTA`:`NORMAL`})]})]})]}),n&&(0,$.jsx)(`div`,{className:`hive-glow-blob--card hive-glow-blob--blue -bottom-10 -right-10 h-24 w-24 opacity-20`})]}),(0,$.jsx)(`div`,{className:`hive-strip--bottom ${t?``:`opacity-20`}`})]},e.id)})}),(0,$.jsx)(Se,{open:a,onOpenChange:o,children:(0,$.jsx)(be,{className:`max-w-4xl border-white/10 !bg-[#09090b] p-0 overflow-hidden shadow-2xl`,children:p&&(0,$.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between p-6 border-b border-white/5 bg-white/5 relative overflow-hidden`,children:[(0,$.jsx)(`div`,{className:`hive-glow-blob hive-glow-blob--blue -top-10 -right-10 h-32 w-32 opacity-20`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-4 relative z-10`,children:[(0,$.jsx)(`div`,{className:`hive-icon-wrap--internal hive-icon-wrap--internal-active`,children:(0,$.jsx)(I,{className:`h-6 w-6`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(xe,{className:`hive-title-page !text-2xl uppercase tracking-tighter`,children:p.name}),(0,$.jsx)(ve,{className:`hive-subtitle !mt-0`,children:`Sintonización de la capa moral y operativa del agente.`})]})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-3 relative z-10`,children:!p.active&&(0,$.jsx)(`button`,{className:`hive-btn hive-btn--ghost px-6 text-[10px]`,onClick:()=>h(p.id),children:`ESTABLECER COMO ACTIVO`})})]}),(0,$.jsx)(`div`,{className:`p-6 space-y-4 border-b border-white/5`,children:(0,$.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{className:`hive-label uppercase !text-[10px]`,children:`Nombre del Protocolo`}),(0,$.jsx)(J,{value:s.name,onChange:e=>c(t=>({...t,name:e.target.value})),className:`bg-white/5 border-white/5 focus-visible:ring-blue-500/30 text-white font-bold`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{className:`hive-label uppercase !text-[10px]`,children:`Descripción / Meta`}),(0,$.jsx)(J,{value:s.description,onChange:e=>c(t=>({...t,description:e.target.value})),className:`bg-white/5 border-white/5 focus-visible:ring-blue-500/30 text-white/60 text-xs italic`})]})]})}),(0,$.jsxs)(`div`,{className:`p-0 bg-[#09090b]`,children:[(0,$.jsx)(`div`,{className:`px-6 pt-4`,children:(0,$.jsx)(Z,{className:`hive-label uppercase !text-[10px]`,children:`Lineamientos de Capa (Markdown)`})}),(0,$.jsx)(me,{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 X(`/api/ethics/${p.id}`,{method:`PUT`,body:s});await t(),Y.fire({icon:`success`,title:e.message||`Contenido ético guardado`})}catch(e){Y.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 We={filesystem:`Sistema de archivos`,web:`Web`,cron:`Cron`,cli:`CLI`,agents:`Agentes`,canvas:`Canvas`,voice:`Voz`};function Ge(){let{tools:e,isLoading:t,fetchTools:n,toggleTool:r,updateTool:i}=fe(),[a,o]=(0,Q.useState)(`all`),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{n()},[n]);let p=async(e,t)=>{if(!l){u(e);try{await r(e,t),n(),Y.fire({icon:`success`,title:`Herramienta ${t?`activada`:`desactivada`}`})}catch{Y.fire({icon:`error`,title:`Error al actualizar estado de la herramienta`})}finally{u(null)}}},m=async()=>{if(s){f(!0),K.show(`Guardando herramienta...`);try{await i(s.id,{name:s.name,description:s.description}),Y.fire({icon:`success`,title:`Herramienta actualizada`}),n(),c(null)}catch{Y.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)(E,{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 h=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:[h.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)(V,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Arsenal Operativo`})]})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-1.5 p-1 bg-white/5 rounded-2xl w-fit border border-white/5`,children:[`all`,`filesystem`,`web`,`cron`,`cli`,`agents`,`canvas`,`a2ui`,`voice`].map(e=>(0,$.jsx)(`button`,{onClick:()=>o(e),className:`px-6 py-2 rounded-xl text-[10px] font-black tracking-widest uppercase transition-all duration-300 ${a===e?`bg-blue-600 text-white shadow-btn-primary`:`text-white/20 hover:text-white/40 hover:bg-white/5`}`,children:e===`all`?`TODAS`:We[e]||e},e))}),h.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)(R,{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:h.map(e=>{let t=e.active,n=e.core;return(0,$.jsxs)(`div`,{onClick:()=>c({...e}),className:`hive-card group cursor-pointer transition-all duration-500 ${t?`hive-card--active`:`hive-card--disabled`}`,children:[(0,$.jsxs)(`div`,{className:`hive-card-body relative overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between mb-6`,children:[(0,$.jsxs)(`div`,{className:`hive-icon-wrap--internal ${t?`hive-icon-wrap--internal-active`:`hive-icon-wrap--internal-disabled`}`,children:[e.category===`filesystem`&&(0,$.jsx)(Pe,{className:`h-6 w-6`}),e.category===`web`&&(0,$.jsx)(Pe,{className:`h-6 w-6`}),e.category===`cron`&&(0,$.jsx)(P,{className:`h-6 w-6`}),e.category===`cli`&&(0,$.jsx)(A,{className:`h-6 w-6`}),e.category===`agents`&&(0,$.jsx)(ze,{className:`h-6 w-6`}),e.category===`canvas`&&(0,$.jsx)(A,{className:`h-6 w-6`}),e.category===`voice`&&(0,$.jsx)(ze,{className:`h-6 w-6`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n&&(0,$.jsx)(`span`,{className:`hive-status-label--active`,children:`NATIVO`}),(0,$.jsx)(he,{checked:t,onCheckedChange:()=>p(e.id,!t),onClick:e=>e.stopPropagation(),className:`data-[state=checked]:bg-blue-500 scale-75 origin-right`})]})]}),(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-lg font-black text-white uppercase tracking-tighter mb-1 line-clamp-1 group-hover:text-blue-400 transition-colors`,children:e.name}),(0,$.jsx)(`p`,{className:`hive-subtitle !mt-0 !text-[11px] h-8 line-clamp-2`,children:e.description||`Sin descripción disponible`})]}),(0,$.jsxs)(`div`,{className:`pt-4 border-t border-white/5 flex items-center gap-4`,children:[(0,$.jsxs)(`div`,{className:`hive-stat`,children:[(0,$.jsx)(`span`,{className:`hive-stat__label`,children:`TIPO`}),(0,$.jsx)(`span`,{className:`hive-stat__value truncate max-w-[80px]`,children:e.category})]}),(0,$.jsxs)(`div`,{className:`hive-stat`,children:[(0,$.jsx)(`span`,{className:`hive-stat__label`,children:`ESTADO`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:t?`hive-status-dot--active`:`hive-status-dot--disabled`}),(0,$.jsx)(`span`,{className:t?`hive-status-label--active`:`hive-status-label--disabled`,children:t?`ACTIVE`:`STANDBY`})]})]})]})]}),t&&(0,$.jsx)(`div`,{className:`hive-glow-blob--card hive-glow-blob--blue -bottom-10 -right-10 h-24 w-24 opacity-20`})]}),(0,$.jsx)(`div`,{className:`hive-strip--bottom ${t?``:`opacity-20`}`})]},e.id)})}),(0,$.jsx)(Se,{open:!!s,onOpenChange:e=>!e&&c(null),children:(0,$.jsxs)(be,{className:`sm:max-w-sm bg-zinc-950 border-white/10`,children:[(0,$.jsxs)(ye,{children:[(0,$.jsxs)(xe,{className:`flex items-center gap-2 text-sm`,children:[(0,$.jsx)(`div`,{className:`p-1.5 rounded-lg bg-violet-500/10 text-violet-400`,children:(0,$.jsx)(ze,{className:`h-3.5 w-3.5`})}),`Editar herramienta`]}),(0,$.jsx)(ve,{className:`text-[10px] text-zinc-500 font-medium`,children:`Modifica los parámetros y la descripción de la herramienta seleccionada.`})]}),(0,$.jsxs)(`div`,{className:`space-y-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(Z,{className:`text-[10px] text-zinc-500 uppercase tracking-widest font-bold`,children:`Nombre`}),(0,$.jsx)(J,{value:s?.name||``,onChange:e=>c({...s,name:e.target.value}),className:`h-9 text-sm bg-white/5 border-white/10 focus:border-violet-500/50`})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(Z,{className:`text-[10px] text-zinc-500 uppercase tracking-widest font-bold`,children:`Descripción`}),(0,$.jsx)(me,{value:s?.description||``,onChange:e=>c({...s,description:e.target.value}),className:`text-sm min-h-[80px] resize-none bg-white/5 border-white/10 focus:border-violet-500/50 font-mono`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 pt-1 border-t border-white/5`,children:[(0,$.jsx)(`span`,{className:`font-mono text-[10px] bg-zinc-900 border border-white/5 text-zinc-500 px-2 py-0.5 rounded truncate max-w-[180px]`,children:s?.id}),(0,$.jsx)(Ce,{variant:`outline`,className:`text-[9px] border-zinc-800 text-zinc-500 uppercase`,children:s?.category})]})]}),(0,$.jsxs)(ge,{className:`gap-2 sm:gap-0`,children:[(0,$.jsx)(G,{variant:`outline`,size:`sm`,onClick:()=>c(null),className:`hive-btn--form-cancel h-10`,children:`Cancelar`}),(0,$.jsxs)(G,{size:`sm`,onClick:m,disabled:d,className:`hive-btn--form-submit h-10`,children:[d&&(0,$.jsx)(E,{className:`h-3.5 w-3.5 animate-spin`}),`Guardar Cambios`]})]})]})})]})}function Ke({server:e,onClick:t,isConnected:n,isLoading:r}){let i=n||e.status===`connected`,a=e.transport===`stdio`;return(0,$.jsxs)(Oe,{onClick:t,className:`group relative overflow-hidden transition-all hover:border-cyan-500/50 hover:shadow-lg hover:shadow-cyan-500/5 cursor-pointer border-white/5 bg-zinc-950/50 backdrop-blur-sm ${i?`border-cyan-500/20 bg-cyan-500/[0.02]`:`opacity-80 grayscale-[0.2]`} ${r?`pointer-events-none opacity-50`:``}`,children:[(0,$.jsx)(`div`,{className:`absolute top-0 left-0 w-1 h-full transition-colors ${i?`bg-cyan-500`:`bg-zinc-800`}`}),(0,$.jsxs)(we,{className:`pb-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between mb-2`,children:[(0,$.jsx)(`div`,{className:`p-2 rounded-lg transition-colors ${i?`bg-cyan-500/10 text-cyan-400`:`bg-zinc-800 text-zinc-500`}`,children:a?(0,$.jsx)(y,{className:`h-5 w-5`}):(0,$.jsx)(U,{className:`h-5 w-5`})}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:i?(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-0.5 rounded-full bg-cyan-500/10 border border-cyan-500/20`,children:[(0,$.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full bg-cyan-500 animate-pulse`}),(0,$.jsx)(`span`,{className:`text-[10px] font-bold text-cyan-500 uppercase tracking-wider`,children:`LIVE`})]}):(0,$.jsx)(Ce,{variant:`outline`,className:`text-[10px] border-zinc-800 text-zinc-500 uppercase tracking-tighter`,children:`OFFLINE`})})]}),(0,$.jsx)(Ee,{className:`text-sm font-bold truncate group-hover:text-cyan-400 transition-colors`,children:e.name}),(0,$.jsx)(De,{className:`text-[10px] font-mono opacity-50 truncate mt-0.5`,children:e.url||`stdio: ${e.transport}`})]}),(0,$.jsxs)(Te,{className:`pt-0 pb-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3 mt-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{className:`text-[9px] text-zinc-500 uppercase font-bold tracking-widest`,children:`Transport`}),(0,$.jsx)(`span`,{className:`text-xs font-semibold text-zinc-300`,children:e.transport})]}),(0,$.jsx)(`div`,{className:`h-4 w-px bg-white/10`}),(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{className:`text-[9px] text-zinc-500 uppercase font-bold tracking-widest`,children:`Tools`}),(0,$.jsxs)(`span`,{className:`text-xs font-semibold text-zinc-300`,children:[e.tools?.length||e.tools_count||0,` expuestas`]})]})]}),e.builtin&&(0,$.jsx)(Ce,{variant:`outline`,className:`mt-3 text-[9px] border-amber-500/20 text-amber-500/70 bg-amber-500/5`,children:`BUILTIN`})]}),i&&(0,$.jsx)(`div`,{className:`absolute -bottom-6 -right-6 w-12 h-12 bg-cyan-500/10 blur-2xl rounded-full`})]})}function qe({serverId:e,serverName:t,tools:n=[]}){let[r,i]=(0,Q.useState)(``),a=n.filter(e=>e.name.toLowerCase().includes(r.toLowerCase())||e.description.toLowerCase().includes(r.toLowerCase()));return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 relative`,children:[(0,$.jsx)(P,{className:`absolute left-2.5 top-2.5 h-3.5 w-3.5 text-zinc-500`}),(0,$.jsx)(J,{placeholder:`Buscar herramientas...`,className:`pl-8 h-8 text-[11px] bg-white/5 border-white/10 focus:border-cyan-500/30`,value:r,onChange:e=>i(e.target.value)})]}),(0,$.jsx)(`div`,{className:`space-y-2 max-h-[300px] overflow-y-auto pr-1 custom-scrollbar`,children:a.length===0?(0,$.jsx)(`div`,{className:`py-8 text-center text-[10px] text-zinc-500 italic`,children:r?`No se encontraron herramientas que coincidan.`:`Este servidor no expone herramientas actualmente.`}):a.map(e=>(0,$.jsxs)(`div`,{className:`p-3 rounded-lg bg-zinc-900/50 border border-white/5 hover:border-cyan-500/20 transition-all group`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`p-1.5 rounded bg-cyan-500/5 text-cyan-400 group-hover:bg-cyan-500/10 transition-colors`,children:(0,$.jsx)(Fe,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`h5`,{className:`text-[11px] font-bold text-zinc-200 group-hover:text-cyan-400 transition-colors`,children:e.name})]}),e.inputSchema&&(0,$.jsx)(Ce,{variant:`outline`,className:`text-[9px] border-zinc-800 text-zinc-600 h-4`,children:`JSON Schema`})]}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[10px] text-zinc-500 leading-relaxed line-clamp-2`,children:e.description})]},e.name))}),(0,$.jsxs)(`div`,{className:`p-2 rounded bg-cyan-500/5 border border-cyan-500/10 flex items-center gap-2`,children:[(0,$.jsx)(w,{className:`h-3 w-3 text-cyan-500`}),(0,$.jsxs)(`span`,{className:`text-[9px] text-cyan-200/50`,children:[`Estas herramientas son gestionadas directamente por `,(0,$.jsx)(`span`,{className:`text-cyan-400 font-mono`,children:t}),`.`]})]})]})}function Je(e){return e?e[`x-api-key`]?{authType:`api-key`,authToken:e[`x-api-key`]}:e.Authorization?.startsWith(`Bearer `)?{authType:`bearer`,authToken:e.Authorization.replace(`Bearer `,``)}:Object.keys(e).length>0?{authType:`custom`,authToken:``}:{authType:`none`,authToken:``}:{authType:`none`,authToken:``}}function Ye({server:e,onClose:t}){let{updateMCPServer:n,toggleMCPServer:r,deleteMCPServer:i,fetchMCPServers:a}=de(),[o,s]=(0,Q.useState)(e.transport||`stdio`),[c,m]=(0,Q.useState)(e.command||``),[h,g]=(0,Q.useState)(e.args?.join(` `)||``),[_,v]=(0,Q.useState)(e.url||``),[y,b]=(0,Q.useState)(()=>Je(e.headers).authType),[x,S]=(0,Q.useState)(()=>Je(e.headers).authToken),[C,w]=(0,Q.useState)(e.headers?JSON.stringify(e.headers,null,2):``),[O,k]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(!1),[N,P]=(0,Q.useState)(!1),[F,I]=(0,Q.useState)(!0),[L,R]=(0,Q.useState)(!1),[z,B]=(0,Q.useState)(`config`),[te,V]=(0,Q.useState)(e.status),[H,ne]=(0,Q.useState)(e.active),W=te===`connected`||H===1||H===!0;return(0,Q.useEffect)(()=>{let t=!1;return(async()=>{I(!0);try{let n=await X(`/api/mcp/servers/${e.id}`);if(t)return;s(n.transport||`stdio`),m(n.command||``),g(Array.isArray(n.args)?n.args.join(` `):``),v(n.url||``);let r=Je(n.headers);b(r.authType),S(r.authToken),w(n.headers?JSON.stringify(n.headers,null,2):``),V(n.status||e.status),ne(+!!n.enabled)}catch{}finally{t||I(!1)}})(),()=>{t=!0}},[e.id]),(0,$.jsx)(Se,{open:!0,onOpenChange:e=>!e&&t(),children:(0,$.jsxs)(be,{className:`sm:max-w-[500px] border-cyan-500/20 bg-zinc-950/95 backdrop-blur-xl p-0 overflow-hidden`,children:[(0,$.jsx)(`div`,{className:`absolute top-0 left-0 w-full h-1 bg-gradient-to-r from-transparent via-cyan-500/50 to-transparent`}),(0,$.jsxs)(ye,{className:`p-6 pb-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`p-2 rounded-lg ${W?`bg-cyan-500/10 text-cyan-400`:`bg-zinc-800 text-zinc-500`}`,children:(0,$.jsx)(ze,{className:`h-5 w-5`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(xe,{className:`text-white flex items-center gap-2`,children:[`Configurar `,e.name,W&&(0,$.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full bg-cyan-500 animate-pulse`})]}),(0,$.jsxs)(ve,{className:`text-[10px] font-mono opacity-50 uppercase tracking-widest mt-0.5`,children:[`ID: `,e.id,` • `,e.transport]})]})]}),!e.builtin&&(0,$.jsx)(G,{variant:`ghost`,size:`icon`,onClick:()=>R(!0),disabled:j||L,className:`text-zinc-600 hover:text-red-400 hover:bg-red-400/10 h-8 w-8 transition-colors`,title:`Eliminar Servidor`,children:(0,$.jsx)(ee,{className:`h-4 w-4`})})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 mt-6 border-b border-white/5`,children:[(0,$.jsxs)(`button`,{onClick:()=>B(`config`),className:`px-4 py-2 text-[10px] uppercase font-bold tracking-widest transition-all relative ${z===`config`?`text-cyan-400`:`text-zinc-500 hover:text-zinc-300`}`,children:[`Configuración`,z===`config`&&(0,$.jsx)(`div`,{className:`absolute bottom-0 left-0 w-full h-0.5 bg-cyan-500`})]}),(0,$.jsxs)(`button`,{onClick:()=>B(`tools`),className:`px-4 py-2 text-[10px] uppercase font-bold tracking-widest transition-all relative ${z===`tools`?`text-cyan-400`:`text-zinc-500 hover:text-zinc-300`}`,children:[`Herramientas`,z===`tools`&&(0,$.jsx)(`div`,{className:`absolute bottom-0 left-0 w-full h-0.5 bg-cyan-500`})]})]})]}),L&&(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)(G,{variant:`ghost`,size:`sm`,onClick:()=>R(!1),disabled:j,className:`h-7 px-3 text-[10px] font-bold uppercase tracking-wider text-zinc-400 hover:text-white`,children:`Cancelar`}),(0,$.jsx)(G,{size:`sm`,onClick:async()=>{M(!0);try{await X(`/api/mcp/servers/${e.id}`,{method:`DELETE`,showLoader:`Eliminando servidor...`,showError:!0}),await a(),t()}catch{}finally{M(!1),R(!1)}},disabled:j,className:`h-7 px-3 text-[10px] font-bold uppercase tracking-wider bg-red-600 hover:bg-red-500 text-white`,children:j?(0,$.jsx)(E,{className:`h-3 w-3 animate-spin`}):`Sí, eliminar`})]})]}),(0,$.jsx)(`div`,{className:`p-6`,children:z===`config`?(0,$.jsxs)(`div`,{className:`space-y-4 animate-in fade-in duration-300`,children:[F&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-zinc-500`,children:[(0,$.jsx)(E,{className:`h-3 w-3 animate-spin`}),(0,$.jsx)(`span`,{children:`Cargando configuración...`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Transporte`}),(0,$.jsxs)(p,{value:o,onValueChange:s,children:[(0,$.jsx)(d,{className:`bg-white/5 border-white/10 h-9`,children:(0,$.jsx)(f,{})}),(0,$.jsxs)(u,{className:`bg-zinc-900 border-white/10`,children:[(0,$.jsx)(l,{value:`stdio`,className:`focus:bg-cyan-500/20 focus:text-cyan-400`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(A,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`stdio (Binario Local)`})]})}),(0,$.jsx)(l,{value:`sse`,className:`focus:bg-cyan-500/20 focus:text-cyan-400`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(U,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`SSE (Remote HTTP)`})]})})]})]})]}),o===`stdio`?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Comando`}),(0,$.jsx)(J,{value:c,onChange:e=>m(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 h-9`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Argumentos`}),(0,$.jsx)(J,{value:h,onChange:e=>g(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 h-9`})]})]}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Endpoint URL`}),(0,$.jsx)(J,{value:_,onChange:e=>v(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 h-9`})]}),(0,$.jsxs)(`div`,{className:`space-y-4 pt-2 border-t border-white/5`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Autenticación`}),(0,$.jsxs)(p,{value:y,onValueChange:b,children:[(0,$.jsx)(d,{className:`bg-white/5 border-white/10 focus:border-cyan-500/50 h-9`,children:(0,$.jsx)(f,{})}),(0,$.jsxs)(u,{className:`bg-zinc-900 border-white/10`,children:[(0,$.jsx)(l,{value:`none`,className:`focus:bg-cyan-500/20 focus:text-cyan-400`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(U,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Ninguna`})]})}),(0,$.jsx)(l,{value:`api-key`,className:`focus:bg-cyan-500/20 focus:text-cyan-400`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(T,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`API Key (x-api-key)`})]})}),(0,$.jsx)(l,{value:`bearer`,className:`focus:bg-cyan-500/20 focus:text-cyan-400`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Be,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Bearer Token (Authorization)`})]})}),(0,$.jsx)(l,{value:`custom`,className:`focus:bg-cyan-500/20 focus:text-cyan-400`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Ne,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Custom Headers (JSON)`})]})})]})]})]}),(y===`api-key`||y===`bearer`)&&(0,$.jsxs)(`div`,{className:`space-y-2 animate-in fade-in slide-in-from-top-1 duration-200`,children:[(0,$.jsx)(Z,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:y===`api-key`?`API Key`:`Bearer Token`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(J,{type:`password`,placeholder:`sk-...`,value:x,onChange:e=>S(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 transition-all h-9 pl-9`}),(0,$.jsx)(D,{className:`absolute left-3 top-2.5 h-3.5 w-3.5 text-zinc-500`})]})]}),y===`custom`&&(0,$.jsxs)(`div`,{className:`space-y-2 animate-in fade-in slide-in-from-top-1 duration-200`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,$.jsx)(Z,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Headers JSON`})}),(0,$.jsx)(`textarea`,{value:C,onChange:e=>w(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 ${W?`bg-green-500/10 text-green-400`:`bg-zinc-800 text-zinc-500`}`,children:(0,$.jsx)(Re,{className:`h-3.5 w-3.5 ${W?`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 ${W?`text-green-500`:`text-zinc-500`}`,children:W?`ACTIVE_CONNECTION`:`INACTIVE_NODE`})]})]}),(0,$.jsx)(G,{size:`sm`,variant:W?`outline`:`default`,onClick:async()=>{P(!0),K.show(W?`Desconectando servidor...`:`Conectando servidor...`);try{await r(e.id,!W),ne(+!W),V(W?`disconnected`:`connected`),Y.fire({icon:`success`,title:W?`Servidor desconectado`:`Servidor conectado`}),setTimeout(a,1500)}catch{Y.fire({icon:`error`,title:`Error al cambiar estado de conexión`})}finally{P(!1),K.hide()}},disabled:N,className:`h-7 px-4 text-[10px] font-bold uppercase tracking-wider ${W?`border-zinc-800 text-zinc-400 hover:bg-zinc-800`:`bg-cyan-600 hover:bg-cyan-500 text-white`}`,children:N?(0,$.jsx)(E,{className:`h-3 w-3 animate-spin`}):W?`Desconectar`:`Conectar`})]})]}):(0,$.jsx)(`div`,{className:`animate-in fade-in duration-300`,children:(0,$.jsx)(qe,{serverId:e.id,serverName:e.name,tools:e.tools||[]})})}),(0,$.jsxs)(ge,{className:`p-6 bg-white/[0.02] border-t border-white/5`,children:[(0,$.jsx)(G,{variant:`ghost`,onClick:t,className:`text-zinc-500 hover:text-white`,children:`Cerrar`}),z===`config`&&(0,$.jsx)(G,{onClick:async()=>{k(!0),K.show(`Actualizando configuración...`);try{let t={transport:o};if(o===`stdio`){if(!c){Y.fire({icon:`warning`,title:`El comando es obligatorio`});return}t.command=c;let e=h.trim();if(e.startsWith(`[`)&&e.endsWith(`]`))try{t.args=JSON.parse(e)}catch{t.args=e.match(/"[^"]*"|'[^']*'|[^\\s,]+/g)?.map(e=>e.replace(/^["']|["']$/g,``).replace(/,$/,``).trim()).filter(Boolean)||[]}else t.args=e.match(/"[^"]*"|'[^']*'|[^\\s,]+/g)?.map(e=>e.replace(/^["']|["']$/g,``).replace(/,$/,``).trim()).filter(Boolean)||[]}else if(o===`sse`){if(!_){Y.fire({icon:`warning`,title:`La URL es obligatoria`});return}t.url=_;let e={};if(y===`api-key`&&x)e[`x-api-key`]=x;else if(y===`bearer`&&x)e.Authorization=`Bearer ${x}`;else if(y===`custom`&&C.trim())try{e=JSON.parse(C.trim())}catch{Y.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(),Y.fire({icon:`success`,title:`Configuración actualizada`})}catch(e){Y.fire({icon:`error`,title:e instanceof Error?e.message:`Error al actualizar configuración`})}finally{k(!1),K.hide()}},disabled:O,className:`bg-cyan-600 hover:bg-cyan-500 text-white min-w-[120px]`,children:O?(0,$.jsx)(E,{className:`h-4 w-4 animate-spin`}):`Guardar Cambios`})]})]})})}function Xe(){let{fetchMCPServers:e}=de(),[t,n]=(0,Q.useState)(!1),[r,i]=(0,Q.useState)(``),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(``),[m,h]=(0,Q.useState)(`stdio`),[g,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(`none`),[x,S]=(0,Q.useState)(``),[C,w]=(0,Q.useState)(``),[E,O]=(0,Q.useState)(!1);return(0,$.jsxs)(Se,{open:t,onOpenChange:n,children:[(0,$.jsx)(_e,{asChild:!0,children:(0,$.jsxs)(G,{className:`bg-cyan-600 hover:bg-cyan-500 text-white shadow-lg shadow-cyan-600/20 gap-2`,children:[(0,$.jsx)(M,{className:`h-4 w-4`}),`Añadir Servidor MCP`]})}),(0,$.jsxs)(be,{className:`sm:max-w-[425px] border-cyan-500/20 bg-zinc-950/95 backdrop-blur-xl`,children:[(0,$.jsxs)(ye,{children:[(0,$.jsxs)(xe,{className:`flex items-center gap-2 text-white`,children:[(0,$.jsx)(`div`,{className:`p-1.5 rounded-md bg-cyan-500/10 text-cyan-400`,children:(0,$.jsx)(H,{className:`h-4 w-4`})}),`Nuevo Servidor MCP`]}),(0,$.jsx)(ve,{className:`text-zinc-400`,children:`Conecta una nueva fuente de herramientas para tus agentes mediante el protocolo MCP.`})]}),(0,$.jsxs)(`div`,{className:`grid gap-4 py-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{htmlFor:`mcp-name`,className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Nombre Identificador`}),(0,$.jsx)(J,{id:`mcp-name`,placeholder:`github-tools`,value:r,onChange:e=>i(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 transition-all h-9`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Protocolo de Transporte`}),(0,$.jsxs)(p,{value:m,onValueChange:h,children:[(0,$.jsx)(d,{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)(f,{placeholder:`Seleccionar transporte`})}),(0,$.jsxs)(u,{position:`popper`,className:`bg-zinc-900 border-white/10 z-[99999]`,sideOffset:4,children:[(0,$.jsx)(l,{value:`stdio`,className:`focus:bg-cyan-500/20 focus:text-cyan-400 cursor-pointer`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(A,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`stdio (Binario Local)`})]})}),(0,$.jsx)(l,{value:`sse`,className:`focus:bg-cyan-500/20 focus:text-cyan-400 cursor-pointer`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(U,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`SSE (Remote HTTP)`})]})})]})]})]}),m===`stdio`?(0,$.jsxs)(`div`,{className:`space-y-4 animate-in fade-in slide-in-from-top-2 duration-300`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{htmlFor:`mcp-cmd`,className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Comando Ejecutable`}),(0,$.jsx)(J,{id:`mcp-cmd`,placeholder:`npx`,value:a,onChange:e=>o(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 transition-all h-9`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{htmlFor:`mcp-args`,className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Argumentos`}),(0,$.jsx)(J,{id:`mcp-args`,placeholder:`-y @modelcontextprotocol/server-github`,value:s,onChange:e=>c(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 transition-all h-9`})]})]}):(0,$.jsxs)(`div`,{className:`space-y-4 animate-in fade-in slide-in-from-top-2 duration-300`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{htmlFor:`mcp-url`,className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Endpoint URL`}),(0,$.jsx)(J,{id:`mcp-url`,placeholder:`https://mcp-server.com/sse`,value:g,onChange:e=>v(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 transition-all h-9`})]}),(0,$.jsxs)(`div`,{className:`space-y-4 pt-2 border-t border-white/5`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Autenticación`}),(0,$.jsxs)(p,{value:y,onValueChange:b,children:[(0,$.jsx)(d,{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)(f,{placeholder:`Seleccionar autenticación`})}),(0,$.jsxs)(u,{position:`popper`,className:`bg-zinc-900 border-white/10 z-[99999]`,sideOffset:4,children:[(0,$.jsx)(l,{value:`none`,className:`focus:bg-cyan-500/20 focus:text-cyan-400 cursor-pointer`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(U,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Ninguna`})]})}),(0,$.jsx)(l,{value:`api-key`,className:`focus:bg-cyan-500/20 focus:text-cyan-400 cursor-pointer`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(T,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`API Key (x-api-key)`})]})}),(0,$.jsx)(l,{value:`bearer`,className:`focus:bg-cyan-500/20 focus:text-cyan-400 cursor-pointer`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Be,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Bearer Token (Authorization)`})]})}),(0,$.jsx)(l,{value:`google-api-key`,className:`focus:bg-cyan-500/20 focus:text-cyan-400 cursor-pointer`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(T,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Google API Key (X-Goog-Api-Key)`})]})}),(0,$.jsx)(l,{value:`custom`,className:`focus:bg-cyan-500/20 focus:text-cyan-400 cursor-pointer`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Ne,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Custom Headers (JSON)`})]})})]})]})]}),(y===`api-key`||y===`google-api-key`||y===`bearer`)&&(0,$.jsxs)(`div`,{className:`space-y-2 animate-in fade-in slide-in-from-top-1 duration-200`,children:[(0,$.jsx)(Z,{htmlFor:`mcp-token`,className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:y===`api-key`?`API Key`:y===`google-api-key`?`Google API Key`:`Bearer Token`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(J,{id:`mcp-token`,type:`password`,placeholder:`sk-...`,value:x,onChange:e=>S(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 transition-all h-9 pl-9`}),(0,$.jsx)(D,{className:`absolute left-3 top-2.5 h-3.5 w-3.5 text-zinc-500`})]})]}),y===`custom`&&(0,$.jsxs)(`div`,{className:`space-y-2 animate-in fade-in slide-in-from-top-1 duration-200`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,$.jsx)(Z,{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:C,onChange:e=>{let t=e.target.value;w(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)(_,{className:`h-5 w-5 text-cyan-500 shrink-0`}),(0,$.jsx)(`div`,{className:`text-[10px] text-cyan-200/70`,children:`El servidor se inicializará y validará inmediatamente después de ser añadido.`})]})]}),(0,$.jsxs)(ge,{children:[(0,$.jsx)(G,{variant:`ghost`,onClick:()=>n(!1),className:`hover:bg-white/5 text-zinc-400 h-9 text-xs`,children:`Cancelar`}),(0,$.jsx)(G,{onClick:async()=>{if(!r){Y.fire({icon:`error`,title:`El nombre es obligatorio`});return}O(!0);try{let t={transport:m};if(m===`stdio`){if(!a){Y.fire({icon:`error`,title:`El comando es obligatorio para transporte stdio`}),O(!1);return}t.command=a;let e=s.trim();if(e.startsWith(`[`)&&e.endsWith(`]`))try{t.args=JSON.parse(e)}catch{t.args=e.match(/"[^"]*"|'[^']*'|[^\\s,]+/g)?.map(e=>e.replace(/^["']|["']$/g,``).replace(/,$/,``).trim()).filter(Boolean)||[]}else t.args=e.match(/"[^"]*"|'[^']*'|[^\\s,]+/g)?.map(e=>e.replace(/^["']|["']$/g,``).replace(/,$/,``).trim()).filter(Boolean)||[]}else{if(!g){Y.fire({icon:`error`,title:`La URL es obligatoria para transporte SSE`}),O(!1);return}t.url=g;let e={};if(y===`api-key`&&x)e[`x-api-key`]=x;else if(y===`google-api-key`&&x)e[`X-Goog-Api-Key`]=x;else if(y===`bearer`&&x)e.Authorization=`Bearer ${x}`;else if(y===`custom`&&C.trim())try{e=JSON.parse(C.trim())}catch{q.fire(`Error`,`JSON de Headers inválido`,`error`),O(!1);return}Object.keys(e).length>0&&(t.headers=e)}await X(`/api/mcp/servers`,{method:`POST`,body:{name:r,config:t},showLoader:`Conectando servidor MCP...`,showError:!0}),Y.fire({icon:`success`,title:`Servidor "${r}" añadido correctamente`}),i(``),o(``),c(``),v(``),b(`none`),S(``),w(``),n(!1),await e()}catch{}finally{O(!1)}},disabled:E,className:`bg-cyan-600 hover:bg-cyan-500 text-white shadow-lg shadow-cyan-600/20 h-9 text-xs px-6`,children:E?`Conectando...`:`Conectar Servidor`})]})]})]})}function Ze(){let{servers:e,activeServers:t,isLoading:n,fetchMCPServers:r}=de(),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(``);(0,Q.useEffect)(()=>{r()},[r]);let c=e.filter(e=>e.name.toLowerCase().includes(o.toLowerCase())),l=e=>{a({...e,args:typeof e.args==`string`?JSON.parse(e.args):e.args})};return(0,$.jsxs)(`div`,{className:`space-y-6`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-white/5 pb-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`p-2 rounded-lg bg-cyan-500/10 text-cyan-400`,children:(0,$.jsx)(H,{className:`h-5 w-5`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h4`,{className:`text-sm font-bold text-white uppercase tracking-wider`,children:`MCP Ecosystem`}),(0,$.jsx)(`p`,{className:`text-[10px] text-zinc-500 font-mono`,children:`Model Context Protocol Servers`})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,$.jsxs)(`div`,{className:`relative group`,children:[(0,$.jsx)(P,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-zinc-500 group-focus-within:text-cyan-400 transition-colors`}),(0,$.jsx)(J,{placeholder:`Buscar servidor...`,value:o,onChange:e=>s(e.target.value),className:`pl-9 bg-zinc-900/50 border-white/5 focus:border-cyan-500/30 transition-all h-9 w-[260px] text-xs`})]}),(0,$.jsx)(Xe,{})]})]}),c.length===0?(0,$.jsxs)(`div`,{className:`py-16 flex flex-col items-center justify-center border border-dashed border-white/10 rounded-2xl bg-zinc-950/20 group hover:border-cyan-500/20 transition-colors`,children:[(0,$.jsx)(`div`,{className:`p-4 rounded-full bg-zinc-900 mb-4 group-hover:scale-110 transition-transform`,children:(0,$.jsx)(R,{className:`h-8 w-8 text-zinc-700 group-hover:text-cyan-500/50 transition-colors`})}),(0,$.jsx)(`p`,{className:`text-xs text-zinc-500 font-medium`,children:`No se detectan servidores MCP configurados.`}),(0,$.jsx)(`p`,{className:`text-[10px] text-zinc-600 mt-1`,children:`Añade uno para expandir las capacidades de tus agentes.`})]}):(0,$.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4`,children:c.map(e=>(0,$.jsx)(Ke,{server:e,isConnected:e.status===`connected`||e.active===!0,onClick:()=>l(e)},e.id))}),i&&(0,$.jsx)(Ye,{server:i,onClose:()=>a(null)})]})}var Qe=()=>(0,$.jsxs)(`svg`,{"aria-hidden":!0,className:`absolute inset-0 w-full h-full pointer-events-none`,xmlns:`http://www.w3.org/2000/svg`,style:{opacity:.05,color:`hsl(var(--hive-amber))`},children:[(0,$.jsx)(`defs`,{children:(0,$.jsx)(`pattern`,{id:`hc-profile`,x:`0`,y:`0`,width:`30`,height:`34`,patternUnits:`userSpaceOnUse`,children:(0,$.jsx)(`polygon`,{points:`15,2 28,9.5 28,24.5 15,32 2,24.5 2,9.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`1`})})}),(0,$.jsx)(`rect`,{width:`100%`,height:`100%`,fill:`url(#hc-profile)`})]}),$e=({initials:e,size:t=`lg`})=>{let n=t===`sm`?`w-14 h-14`:`w-20 h-20`,r=t===`sm`?`text-lg`:`text-2xl`;return(0,$.jsxs)(`div`,{className:`relative ${n} flex-shrink-0`,children:[(0,$.jsx)(`div`,{className:`w-full h-full flex items-center justify-center text-white font-black ${r} tracking-tight select-none`,style:{clipPath:`polygon(50% 0%, 95% 25%, 95% 75%, 50% 100%, 5% 75%, 5% 25%)`,background:`linear-gradient(135deg, hsl(var(--hive-amber)) 0%, hsl(var(--hive-orange)) 100%)`,boxShadow:`0 0 24px hsl(var(--hive-amber) / 0.4)`},children:e}),(0,$.jsx)(`span`,{className:`absolute bottom-0.5 right-1 h-3.5 w-3.5 rounded-full border-2 animate-pulse`,style:{background:`hsl(var(--hive-green))`,borderColor:`hsl(var(--background))`,boxShadow:`0 0 8px hsl(var(--hive-green) / 0.6)`}})]})},et=({children:e})=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-2.5`,children:[(0,$.jsx)(S,{className:`h-3 w-3 flex-shrink-0`,style:{color:`hsl(var(--hive-amber))`,fill:`hsl(var(--hive-amber) / 0.2)`}}),(0,$.jsx)(`p`,{className:`text-[10px] font-black uppercase tracking-[0.18em]`,style:{color:`hsl(var(--hive-amber) / 0.85)`},children:e})]}),tt=()=>(0,$.jsx)(`div`,{className:`h-px`,style:{background:`linear-gradient(90deg,transparent,hsl(var(--hive-amber)/0.18),transparent)`}}),nt=({icon:e,label:t,colorVar:n})=>(0,$.jsxs)(`span`,{className:`flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-medium border`,style:{background:`hsl(var(${n}) / 0.08)`,borderColor:`hsl(var(${n}) / 0.2)`,color:`hsl(var(${n}))`},children:[(0,$.jsx)(e,{className:`h-2.5 w-2.5 flex-shrink-0`}),t]}),rt=({label:e,icon:t,editing:n,children:r})=>(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-1.5 text-[10px] font-bold uppercase tracking-widest transition-colors`,style:{color:n?`hsl(var(--hive-text-muted))`:`hsl(var(--hive-text-placeholder))`},children:[(0,$.jsx)(t,{className:`h-3 w-3 opacity-60`}),e]}),r]});function it(e){return e.split(` `).map(e=>e[0]).slice(0,2).join(``).toUpperCase()||`?`}function at(){let{fetchUser:e,saveUser:t,isLoading:n}=ce(),{channels:r}=ue(),[i,a]=(0,Q.useState)(!1),[s,m]=(0,Q.useState)({name:``,occupation:``,language:``,timezone:``,preferred_cron_channel:`auto`,notes:``}),[h,g]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{e().then(e=>{if(!e)return;let t={name:e.name||``,occupation:e.occupation||``,language:e.language||``,timezone:e.timezone||``,preferred_cron_channel:e.preferred_cron_channel||`auto`,notes:e.notes||``};m(t),g(t)}).catch(console.error)},[e]);let _=(e,t)=>m(n=>({...n,[e]:t})),v=()=>{h&&m(h),a(!1)},y=async()=>{K.show(`Guardando perfil...`);try{let e=await t(s);g(s),Y.fire({icon:`success`,title:e}),a(!1)}catch(e){Y.fire({icon:`error`,title:e instanceof Error?e.message:`Error al guardar`})}finally{K.hide()}},b=r.filter(e=>e.active),x=s.preferred_cron_channel===`auto`?`Auto — detectar mejor canal`:b.find(e=>e.type===s.preferred_cron_channel)?.type??s.preferred_cron_channel,S=it(s.name);return(0,$.jsxs)(`div`,{className:`relative overflow-hidden rounded-2xl border flex flex-col lg:flex-row`,style:{background:`hsl(var(--hive-surface)/0.7)`,borderColor:`hsl(var(--hive-border-base))`,backdropFilter:`blur(16px)`,boxShadow:`0 0 60px hsl(var(--hive-amber)/0.05)`},children:[(0,$.jsxs)(`div`,{className:`relative overflow-hidden flex-shrink-0 lg:w-[40%] lg:flex-col lg:items-center lg:text-center
2
-
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)(Qe,{}),(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)($e,{initials:S,size:`sm`})}),(0,$.jsx)(`div`,{className:`hidden lg:block`,children:(0,$.jsx)($e,{initials:S,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)(nt,{icon:U,label:s.language,colorVar:`--hive-blue`}),s.timezone&&(0,$.jsx)(nt,{icon:se,label:s.timezone,colorVar:`--hive-blue`}),s.preferred_cron_channel!==`auto`&&(0,$.jsx)(nt,{icon:o,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:oe,label:`Agente`,value:`Activo`,colorVar:`--hive-green`},{icon:U,label:`Idioma`,value:s.language||`—`,colorVar:`--hive-blue`},{icon:se,label:`Zona`,value:s.timezone||`—`,colorVar:`--hive-blue`},{icon:z,label:`Canal`,value:x.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)(ne,{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:()=>i?v():a(!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:i?{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:[i?(0,$.jsx)(pe,{className:`h-3 w-3`}):(0,$.jsx)(k,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:i?`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)(et,{children:`Identidad`}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2.5`,children:[(0,$.jsx)(rt,{label:`Nombre completo`,icon:ne,editing:i,children:(0,$.jsx)(J,{placeholder:`John Doe`,value:s.name,disabled:!i,onChange:e=>_(`name`,e.target.value),className:`hive-input h-9 text-sm rounded-lg disabled:opacity-50 disabled:cursor-default`})}),(0,$.jsx)(rt,{label:`Ocupación`,icon:Ae,editing:i,children:(0,$.jsx)(J,{placeholder:`AI Engineer`,value:s.occupation,disabled:!i,onChange:e=>_(`occupation`,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)(et,{children:`Localización`}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2.5`,children:[(0,$.jsx)(rt,{label:`Idioma`,icon:U,editing:i,children:(0,$.jsx)(J,{placeholder:`Spanish`,value:s.language,disabled:!i,onChange:e=>_(`language`,e.target.value),className:`hive-input h-9 text-sm rounded-lg disabled:opacity-50 disabled:cursor-default`})}),(0,$.jsx)(rt,{label:`Zona horaria`,icon:se,editing:i,children:(0,$.jsx)(J,{placeholder:`America/Bogota`,value:s.timezone,disabled:!i,onChange:e=>_(`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)(et,{children:`Notificaciones`}),(0,$.jsx)(rt,{label:`Canal para Cron Jobs`,icon:o,editing:i,children:(0,$.jsxs)(p,{value:s.preferred_cron_channel,onValueChange:e=>_(`preferred_cron_channel`,e),disabled:!i,children:[(0,$.jsx)(d,{className:`hive-select-trigger h-9 text-sm rounded-lg disabled:opacity-50`,children:(0,$.jsx)(f,{})}),(0,$.jsxs)(u,{className:`hive-select-content`,children:[(0,$.jsx)(l,{value:`auto`,className:`hive-select-item text-sm`,children:`Auto — detectar mejor canal`}),b.map(e=>(0,$.jsx)(l,{value:e.type,className:`hive-select-item text-sm`,children:e.type===`webchat`?`Web Chat`:e.type===`telegram`?`Telegram`:e.type===`discord`?`Discord`:e.type===`slack`?`Slack`:e.type===`whatsapp`?`WhatsApp`:e.type},e.id))]})]})})]}),(0,$.jsx)(tt,{}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(et,{children:`Contexto para el agente`}),(0,$.jsx)(me,{placeholder:`Describe tu perfil, preferencias de trabajo, estilo de comunicación...`,value:s.notes,disabled:!i,onChange:e=>_(`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:i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`button`,{onClick:v,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)(pe,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:`Cancelar`})]}),(0,$.jsxs)(`button`,{onClick:y,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)(E,{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:()=>a(!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)(k,{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 ot=e=>{let t=e.toLowerCase();return t.includes(`code`)||t.includes(`program`)?(0,$.jsx)(Me,{className:`h-5 w-5`}):t.includes(`research`)||t.includes(`investiga`)?(0,$.jsx)(P,{className:`h-5 w-5`}):t.includes(`write`)||t.includes(`escrib`)?(0,$.jsx)(W,{className:`h-5 w-5`}):t.includes(`data`)||t.includes(`anal`)||t.includes(`estad`)?(0,$.jsx)(je,{className:`h-5 w-5`}):t.includes(`trans`)||t.includes(`traduc`)?(0,$.jsx)(Ie,{className:`h-5 w-5`}):t.includes(`web`)||t.includes(`glob`)||t.includes(`scrape`)?(0,$.jsx)(U,{className:`h-5 w-5`}):t.includes(`tool`)||t.includes(`herram`)?(0,$.jsx)(V,{className:`h-5 w-5`}):t.includes(`cpu`)||t.includes(`proc`)?(0,$.jsx)(y,{className:`h-5 w-5`}):(0,$.jsx)(z,{className:`h-5 w-5`})},st=e=>e?e.split(`,`).filter(Boolean).length:0,ct=e=>e?e.split(`,`).filter(Boolean).length:0;function lt({skill:e,onClick:t,className:n}){let r=!!e.active,i=st(e.tools),a=ct(e.triggers);return(0,$.jsxs)(`div`,{onClick:t,className:`hive-card group cursor-pointer transition-all duration-300 hover:scale-[1.02] ${r?`hive-card--active`:`hive-card--disabled`} ${n}`,children:[(0,$.jsxs)(`div`,{className:`hive-card-body flex flex-col gap-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(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:[(0,$.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full ${r?`bg-blue-400`:`bg-white/20`}`}),e.category||`GENERAL`]}),r&&(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`})]})]}),(0,$.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,$.jsx)(`div`,{className:`shrink-0 h-12 w-12 rounded-xl flex items-center justify-center border transition-all duration-300 ${r?`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`}`,children:ot(e.name)}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-black uppercase tracking-tight line-clamp-1 transition-colors ${r?`text-white group-hover:text-blue-400`:`text-white/40`}`,children:e.name}),(0,$.jsx)(`p`,{className:`text-[11px] text-white/30 leading-relaxed line-clamp-2 mt-1`,children:e.body?.substring(0,90)||`Sin descripción`})]})]}),(0,$.jsxs)(`div`,{className:`pt-3 border-t border-white/5 flex items-center gap-2 flex-wrap`,children:[(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`,e.version??1]}),i>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:[i,` TOOLS`]}),a>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:[a,` TRIGGERS`]}),(0,$.jsx)(`div`,{className:`ml-auto opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,$.jsx)(L,{className:`h-3 w-3 text-blue-400`})})]})]}),(0,$.jsx)(`div`,{className:`hive-strip--bottom ${r?`bg-blue-500`:`bg-white/5`}`})]})}var ut={name:``,body:``,tools:``,triggers:``,category:``,version:1,active:!0};function dt(){let{skills:e,isLoading:t,fetchSkills:n,toggleSkill:r,updateSkill:i}=le(),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(`TODOS`),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(ut),[h,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(!1),T=(0,Q.useRef)(null),D=()=>{let e=T.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)};(0,Q.useEffect)(()=>{(l||d)&&setTimeout(D,0)},[l,d,p.body]),(0,Q.useEffect)(()=>{n()},[n]);let O=(0,Q.useMemo)(()=>{let t=new Set(e.map(e=>(e.category||`GENERAL`).toUpperCase()));return[`TODOS`,...Array.from(t).sort()]},[e]),k=(0,Q.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]),A=e.filter(e=>e.active).length,j=async(e,t)=>{if(!h){g(e);try{await r(e,t),await n(),Y.fire({icon:`success`,title:t?`Skill habilitado`:`Skill deshabilitado`})}catch{Y.fire({icon:`error`,title:`Error al cambiar estado del skill`})}finally{g(null)}}},N=async()=>{if(l){C(!0);try{await X(`/api/skills/${l.id}`,{method:`DELETE`,showError:!0}),Y.fire({icon:`success`,title:`Skill eliminado`}),n(),u(null)}catch{Y.fire({icon:`error`,title:`Error al eliminar skill`})}finally{C(!1),x(!1)}}},F=e=>{f(!1),x(!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})},I=()=>{u(null),x(!1),m(ut),f(!0)},R=()=>{u(null),f(!1),x(!1)},z=async()=>{v(!0),K.show(d?`Creando skill...`:`Guardando skill...`);try{d?(await X(`/api/skills`,{method:`POST`,body:p,showError:!0}),Y.fire({icon:`success`,title:`Skill creado correctamente`})):l&&(await i(l.id,p),Y.fire({icon:`success`,title:`Skill actualizado correctamente`})),n(),R()}catch{Y.fire({icon:`error`,title:d?`Error al crear skill`:`Error al actualizar skill`})}finally{v(!1),K.hide()}},B=!!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)(E,{className:`h-10 w-10 animate-spin text-primary/40`}),(0,$.jsx)(L,{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)(ie,{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:[A,` 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)(P,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-white/20`}),(0,$.jsx)(J,{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`,{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)(pe,{className:`h-3 w-3`})})]}),(0,$.jsxs)(G,{onClick:I,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)(M,{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:O.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)(ie,{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. Crea una nueva habilidad o visita el Marketplace.`}),(0,$.jsxs)(G,{onClick:I,className:`hive-btn hive-btn--primary px-8`,children:[(0,$.jsx)(M,{className:`h-4 w-4 mr-2`}),`Crear Habilidad`]})]})}):k.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 space-y-3 text-center`,children:[(0,$.jsx)(P,{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:k.map(e=>(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(lt,{skill:e,onClick:()=>F(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)(he,{checked:!!e.active,disabled:h===e.id,onClick:e=>e.stopPropagation(),onCheckedChange:t=>j(e.id,t),className:`scale-75 data-[state=checked]:bg-blue-500`})]})]},e.id))}),(0,$.jsx)(Se,{open:B,onOpenChange:e=>{e||R()},children:(0,$.jsxs)(be,{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)(M,{className:`h-5 w-5`}):(0,$.jsx)(y,{className:`h-5 w-5`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(xe,{className:`text-sm font-black text-white uppercase tracking-tight`,children:d?`Nueva Habilidad`:`Propiedades del Nodo`}),(0,$.jsx)(ve,{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)(G,{variant:`ghost`,size:`icon`,onClick:()=>x(!0),disabled:S||b,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)(ee,{className:`h-4 w-4`})})]})}),b&&(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)(G,{variant:`ghost`,size:`sm`,onClick:()=>x(!1),disabled:S,className:`h-7 px-3 text-[10px] font-black uppercase tracking-wider text-zinc-400 hover:text-white`,children:`Cancelar`}),(0,$.jsx)(G,{size:`sm`,onClick:N,disabled:S,className:`h-7 px-3 text-[10px] font-black uppercase tracking-wider bg-red-600 hover:bg-red-500 text-white`,children:S?(0,$.jsx)(E,{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)(Z,{htmlFor:`skill-name`,className:`text-[10px] uppercase tracking-widest text-white/40`,children:`Nombre del Nodo`}),(0,$.jsx)(J,{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: canvas_dashboard`})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(Z,{htmlFor:`skill-category`,className:`text-[10px] uppercase tracking-widest text-white/40`,children:`Categoría Funcional`}),(0,$.jsx)(J,{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)(Z,{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)(J,{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)(Z,{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)(J,{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)(me,{ref:T,value:p.body,onChange:e=>{m(t=>({...t,body:e.target.value})),D()},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)(Z,{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)(J,{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)(Z,{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)(he,{checked:p.active,onCheckedChange:e=>m(t=>({...t,active:e})),className:`data-[state=checked]:bg-blue-500`})]})]})]})]}),(0,$.jsxs)(ge,{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)(w,{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)(G,{variant:`ghost`,className:`text-[10px] font-black tracking-widest hover:bg-white/5 hover:text-white text-white/30 uppercase`,onClick:R,children:`Cancelar`}),(0,$.jsx)(G,{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:z,disabled:_||!p.name.trim(),children:_?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(E,{className:`h-3 w-3 animate-spin mr-2`}),`PROCESANDO...`]}):d?`Crear Habilidad`:`Sincronizar Propiedades`})]})]})]})})]})}var ft=te((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 X(`/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 X(t?`/api/cron?status=${t}`:`/api/cron`)).tasks??[],isLoading:!1})}catch(t){e({error:t.message,isLoading:!1,scheduledTasks:[]})}},pauseTask:async t=>{try{await X(`/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 X(`/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 X(`/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 X(`/api/cron/${t}/trigger`,{method:`POST`})}catch(t){e({error:t.message})}},fetchTaskHistory:async(t,n=10)=>{try{let r=await X(`/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 X(`/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:`auto`})}catch{}},saveCronChannelPreference:async t=>{try{await X(`/api/user/settings`,{method:`PATCH`,body:{preferred_cron_channel:t}}),e({cronUserPreference:t})}catch(t){e({error:t.message})}}})),pt=()=>{let{notes:e,isLoading:t,fetchNotes:n}=ft();return(0,Q.useEffect)(()=>{n()},[n]),(0,$.jsxs)(Oe,{className:`border-none bg-background/50 backdrop-blur-xl shadow-2xl overflow-hidden group border border-white/10`,children:[(0,$.jsx)(we,{className:`pb-2`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(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)(re,{className:`w-5 h-5`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Ee,{className:`text-xl font-bold tracking-tight`,children:`Notas`}),(0,$.jsx)(De,{children:`Scratchpad del agente`})]})]}),t&&(0,$.jsx)(E,{className:`w-4 h-4 animate-spin text-muted-foreground`})]})}),(0,$.jsx)(Te,{children:(0,$.jsx)(ke,{className:`h-[350px] pr-4`,children:(0,$.jsx)(`div`,{className:`space-y-4`,children:e.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-[250px] text-muted-foreground space-y-2`,children:[(0,$.jsx)(re,{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`})]}):e.map(e=>(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)(Ce,{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 mt(e){if(!e)return`—`;try{return new Date(e).toLocaleString([],{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}catch{return e}}function ht({status:e}){let t={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`}},{label:n,className:r}=t[e]??t.cancelled;return(0,$.jsx)(`span`,{className:`inline-flex items-center text-[9px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded-full border ${r}`,children:n})}function gt({type:e}){let t=e===`recurring`;return(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 border ${t?`bg-violet-500/10 text-violet-400 border-violet-500/20`:`bg-teal-500/10 text-teal-400 border-teal-500/20`}`,children:[t?(0,$.jsx)(N,{className:`w-2.5 h-2.5`}):(0,$.jsx)(s,{className:`w-2.5 h-2.5`}),t?`Recurrente`:`Una vez`]})}function _t({channel:e}){return!e||e===`system`?(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`}):e===`webchat`?(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)(Le,{className:`w-2.5 h-2.5`}),`Web`]}):e===`telegram`?(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)(F,{className:`w-2.5 h-2.5`}),`Telegram`]}):(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:e})}function vt({status:e}){return(0,$.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full ${{running:`bg-blue-400 animate-pulse`,success:`bg-green-400`,failed:`bg-red-400`,timeout:`bg-amber-400`}[e]??`bg-muted-foreground`}`})}function yt(e,t){let n=e===`telegram`?`Telegram`:e===`webchat`?`Web Chat`:e;return e===t?`${n} (recomendado)`:n}function bt({taskId:e,history:t}){return t?t.length===0?(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground px-1`,children:`Sin ejecuciones registradas.`}):(0,$.jsx)(`div`,{className:`mt-2 space-y-1`,children:t.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,$.jsx)(vt,{status:e.status}),(0,$.jsx)(`span`,{className:`font-mono`,children:mt(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))}):(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground px-1`,children:`Cargando historial…`})}function xt({task:e,onPause:t,onResume:n,onDelete:r,onTrigger:i,onLoadHistory:o,history:c}){let[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(!1),p=e.status===`active`,_=e.status===`active`||e.status===`paused`;function v(){!l&&!c&&o(e.id),u(e=>!e)}function y(){d?r(e.id):(f(!0),setTimeout(()=>f(!1),3e3))}return(0,$.jsxs)(`div`,{className:`p-4 rounded-2xl border border-white/5 bg-card/40 hover:bg-card/60 transition-all duration-200`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2 mb-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h4`,{className:`font-semibold text-sm truncate`,children:e.name}),e.description&&(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground truncate mt-0.5`,children:e.description})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-1 shrink-0`,children:(0,$.jsx)(ht,{status:e.status})})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap mb-2`,children:[(0,$.jsx)(gt,{type:e.task_type}),(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:[(0,$.jsx)(s,{className:`w-3 h-3`}),e.task_type===`recurring`?e.cron_expression??`—`:e.fire_at?mt(e.fire_at):`—`]}),(0,$.jsx)(_t,{channel:e.channel})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px] text-muted-foreground mb-2`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(a,{className:`w-3 h-3`}),e.run_count,` runs`]}),e.error_count>0&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-red-400`,children:[(0,$.jsx)(g,{className:`w-3 h-3`}),e.error_count,` errores`]}),e.timezone&&e.timezone!==`UTC`&&(0,$.jsx)(`span`,{className:`font-mono`,children:e.timezone})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px] text-muted-foreground mb-3`,children:[e.last_run_at&&(0,$.jsxs)(`span`,{children:[`Último: `,mt(e.last_run_at)]}),e.next_run_at&&e.status===`active`&&(0,$.jsxs)(`span`,{className:`text-primary/70`,children:[`Próximo: `,mt(e.next_run_at)]})]}),e.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:e.last_error}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[_&&(p?(0,$.jsxs)(G,{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:()=>t(e.id),children:[(0,$.jsx)(O,{className:`w-3 h-3 mr-1`}),`Pausar`]}):(0,$.jsxs)(G,{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:()=>n(e.id),children:[(0,$.jsx)(j,{className:`w-3 h-3 mr-1`}),`Reanudar`]})),p&&(0,$.jsxs)(G,{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:()=>i(e.id),title:`Ejecutar ahora (sin afectar el schedule)`,children:[(0,$.jsx)(z,{className:`w-3 h-3 mr-1`}),`Ejecutar`]}),(0,$.jsxs)(G,{size:`sm`,variant:`ghost`,className:`h-6 text-[10px] px-2 text-muted-foreground hover:text-foreground`,onClick:v,children:[(0,$.jsx)(C,{className:`w-3 h-3 mr-1`}),`Historial`,l?(0,$.jsx)(h,{className:`w-3 h-3 ml-1`}):(0,$.jsx)(m,{className:`w-3 h-3 ml-1`})]}),(0,$.jsxs)(G,{size:`sm`,variant:`ghost`,className:`h-6 text-[10px] px-2 ml-auto ${d?`text-red-400 bg-red-500/10 border border-red-500/20`:`text-muted-foreground hover:text-red-400`}`,onClick:y,title:d?`Confirmar eliminación`:`Eliminar tarea`,children:[(0,$.jsx)(ee,{className:`w-3 h-3 mr-1`}),d?`Confirmar`:`Eliminar`]})]}),l&&(0,$.jsx)(`div`,{className:`mt-2 pt-2 border-t border-white/5`,children:(0,$.jsx)(bt,{taskId:e.id,history:c})})]})}var St=()=>{let{scheduledTasks:e,taskHistory:t,cronChannels:n,cronRecommended:r,cronUserPreference:i,isLoading:a,fetchScheduledTasks:o,fetchCronChannels:s,pauseTask:c,resumeTask:m,deleteTask:h,triggerTask:g,fetchTaskHistory:_,saveCronChannelPreference:v}=ft(),[y,b]=(0,Q.useState)(`all`);(0,Q.useEffect)(()=>{o(),s()},[o,s]);let x=y===`all`?e:e.filter(e=>e.status===y),S=(n??[]).filter(e=>e.active),C=x.filter(e=>!e.name.startsWith(`_hive_`));return(0,$.jsxs)(Oe,{className:`border-none bg-background/50 backdrop-blur-xl shadow-2xl overflow-hidden border border-white/10`,children:[(0,$.jsx)(we,{className:`pb-2`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 flex-wrap`,children:[(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)(Ee,{className:`text-xl font-bold tracking-tight`,children:`Tareas Programadas`}),(0,$.jsx)(De,{children:`Scheduler basado en Croner`})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[a&&(0,$.jsx)(E,{className:`w-4 h-4 animate-spin text-muted-foreground`}),(0,$.jsxs)(p,{value:y,onValueChange:b,children:[(0,$.jsx)(d,{className:`h-7 text-[10px] w-[110px] border-white/10 bg-card/40`,children:(0,$.jsx)(f,{})}),(0,$.jsxs)(u,{children:[(0,$.jsx)(l,{value:`all`,className:`text-xs`,children:`Todas`}),(0,$.jsx)(l,{value:`active`,className:`text-xs`,children:`Activas`}),(0,$.jsx)(l,{value:`paused`,className:`text-xs`,children:`Pausadas`}),(0,$.jsx)(l,{value:`completed`,className:`text-xs`,children:`Completadas`}),(0,$.jsx)(l,{value:`failed`,className:`text-xs`,children:`Fallidas`})]})]}),S.length>1&&(0,$.jsxs)(p,{value:i,onValueChange:v,children:[(0,$.jsx)(d,{className:`h-7 text-[10px] w-[130px] border-white/10 bg-card/40`,children:(0,$.jsx)(f,{placeholder:`Canal`})}),(0,$.jsxs)(u,{children:[(0,$.jsx)(l,{value:`auto`,className:`text-xs`,children:`Auto`}),S.map(e=>(0,$.jsx)(l,{value:e.id,className:`text-xs`,children:yt(e.id,r)},e.id))]})]}),(0,$.jsx)(G,{size:`sm`,variant:`ghost`,className:`h-7 w-7 p-0 text-muted-foreground hover:text-foreground`,onClick:()=>o(y===`all`?void 0:y),disabled:a,title:`Refrescar`,children:(0,$.jsx)(N,{className:`w-3.5 h-3.5`})})]})]})}),(0,$.jsx)(Te,{children:(0,$.jsx)(ke,{className:`h-[420px] pr-4`,children:(0,$.jsx)(`div`,{className:`space-y-3`,children:C.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-[280px] text-muted-foreground space-y-2`,children:[(0,$.jsx)(se,{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`})]})]}):C.map(e=>(0,$.jsx)(xt,{task:e,onPause:c,onResume:m,onDelete:h,onTrigger:g,onLoadHistory:_,history:t[e.id]},e.id))})})})]})};function Ct(){let[e,t]=(0,Q.useState)(!1),[n,r]=(0,Q.useState)(``),[i,a]=(0,Q.useState)(!0),[o,s]=(0,Q.useState)(`status`),[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(``),[h,g]=(0,Q.useState)(``),[_,y]=(0,Q.useState)(``),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(!1),[D,O]=(0,Q.useState)(``),[k,A]=(0,Q.useState)(``),[j,M]=(0,Q.useState)(``),[N,P]=(0,Q.useState)(!1),[F,I]=(0,Q.useState)(!1),[L,ee]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{R(),z()},[]);async function R(){a(!0);try{let e=await fetch(`/api/auth/status`).then(e=>e.json());t(e.hasCredentials),e.email&&r(e.email)}catch{}finally{a(!1)}}async function z(){try{u((await X(`/api/auth/recovery-key`)).recoveryKey)}catch{}}async function B(e){if(e.preventDefault(),h!==_){q.fire({icon:`error`,title:`Error`,text:`Las contraseñas no coinciden`});return}if(h.length<8){q.fire({icon:`error`,title:`Error`,text:`La contraseña debe tener al menos 8 caracteres`});return}T(!0);try{await X(`/api/auth/setup-credentials`,{method:`POST`,body:{email:p,password:h}}),q.fire({icon:`success`,title:`Protección activada`,text:`La próxima vez que accedas necesitarás tu email y contraseña.`,timer:3e3,showConfirmButton:!1,toast:!0,position:`top-end`}),m(``),g(``),y(``),s(`status`),await R()}catch{}finally{T(!1)}}async function te(){if((await q.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 X(`/api/auth/disable`,{method:`POST`}),q.fire({icon:`success`,title:`Protección desactivada`,timer:2e3,showConfirmButton:!1,toast:!0,position:`top-end`}),t(!1),r(``),s(`status`)}catch{}}async function V(e){if(e.preventDefault(),k!==j){q.fire({icon:`error`,title:`Error`,text:`Las contraseñas no coinciden`});return}if(k.length<8){q.fire({icon:`error`,title:`Error`,text:`La contraseña debe tener al menos 8 caracteres`});return}ee(!0);try{await X(`/api/auth/change-password`,{method:`POST`,body:{currentPassword:D,newPassword:k}}),q.fire({icon:`success`,title:`Contraseña actualizada`,timer:2e3,showConfirmButton:!1,toast:!0,position:`top-end`}),O(``),A(``),M(``),s(`status`)}catch{}finally{ee(!1)}}function H(){l&&(navigator.clipboard.writeText(l),f(!0),setTimeout(()=>f(!1),2e3))}return i?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,$.jsx)(E,{className:`h-4 w-4 animate-spin`}),` Cargando...`]}):(0,$.jsxs)(`div`,{className:`space-y-8 max-w-xl`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e?(0,$.jsx)(Be,{className:`h-5 w-5 text-green-500`}):(0,$.jsx)(Ve,{className:`h-5 w-5 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`font-medium`,children:`Protección con contraseña`})]}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e?`Activa — ${n||`credenciales configuradas`}`:`Desactivada — acceso libre sin contraseña`})]}),(0,$.jsx)(he,{checked:e,onCheckedChange:e=>{e?s(`enable`):te()}})]}),o===`enable`&&!e&&(0,$.jsxs)(`form`,{onSubmit:B,className:`space-y-4 border rounded-lg p-4`,children:[(0,$.jsx)(`h3`,{className:`font-medium`,children:`Configurar credenciales`}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{htmlFor:`sec-email`,children:`Email`}),(0,$.jsx)(J,{id:`sec-email`,type:`email`,placeholder:`tu@email.com`,value:p,onChange:e=>m(e.target.value),required:!0,disabled:w})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{htmlFor:`sec-pwd`,children:`Contraseña`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(J,{id:`sec-pwd`,type:S?`text`:`password`,placeholder:`Mínimo 8 caracteres`,value:h,onChange:e=>g(e.target.value),required:!0,disabled:w,className:`pr-10`}),(0,$.jsx)(`button`,{type:`button`,className:`absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>C(e=>!e),tabIndex:-1,children:S?(0,$.jsx)(b,{className:`h-4 w-4`}):(0,$.jsx)(x,{className:`h-4 w-4`})})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{htmlFor:`sec-confirm`,children:`Confirmar contraseña`}),(0,$.jsx)(J,{id:`sec-confirm`,type:S?`text`:`password`,placeholder:`Repite la contraseña`,value:_,onChange:e=>y(e.target.value),required:!0,disabled:w})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(G,{type:`submit`,disabled:w,children:[w&&(0,$.jsx)(E,{className:`mr-2 h-4 w-4 animate-spin`}),`Activar protección`]}),(0,$.jsx)(G,{type:`button`,variant:`ghost`,onClick:()=>s(`status`),disabled:w,children:`Cancelar`})]})]}),e&&o===`status`&&(0,$.jsx)(`div`,{className:`flex gap-2`,children:(0,$.jsx)(G,{variant:`outline`,size:`sm`,onClick:()=>s(`change-password`),children:`Cambiar contraseña`})}),o===`change-password`&&e&&(0,$.jsxs)(`form`,{onSubmit:V,className:`space-y-4 border rounded-lg p-4`,children:[(0,$.jsx)(`h3`,{className:`font-medium`,children:`Cambiar contraseña`}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{htmlFor:`current-pwd`,children:`Contraseña actual`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(J,{id:`current-pwd`,type:N?`text`:`password`,placeholder:`••••••••`,value:D,onChange:e=>O(e.target.value),required:!0,disabled:L,className:`pr-10`}),(0,$.jsx)(`button`,{type:`button`,className:`absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>P(e=>!e),tabIndex:-1,children:N?(0,$.jsx)(b,{className:`h-4 w-4`}):(0,$.jsx)(x,{className:`h-4 w-4`})})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{htmlFor:`new-pwd`,children:`Nueva contraseña`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(J,{id:`new-pwd`,type:F?`text`:`password`,placeholder:`Mínimo 8 caracteres`,value:k,onChange:e=>A(e.target.value),required:!0,disabled:L,className:`pr-10`}),(0,$.jsx)(`button`,{type:`button`,className:`absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>I(e=>!e),tabIndex:-1,children:F?(0,$.jsx)(b,{className:`h-4 w-4`}):(0,$.jsx)(x,{className:`h-4 w-4`})})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Z,{htmlFor:`confirm-new`,children:`Confirmar nueva contraseña`}),(0,$.jsx)(J,{id:`confirm-new`,type:F?`text`:`password`,placeholder:`••••••••`,value:j,onChange:e=>M(e.target.value),required:!0,disabled:L})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(G,{type:`submit`,disabled:L,children:[L&&(0,$.jsx)(E,{className:`mr-2 h-4 w-4 animate-spin`}),`Actualizar contraseña`]}),(0,$.jsx)(G,{type:`button`,variant:`ghost`,onClick:()=>s(`status`),disabled:L,children:`Cancelar`})]})]}),l&&(0,$.jsxs)(`div`,{className:`space-y-2 border rounded-lg p-4 bg-muted/30`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:`Recovery Key`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Úsalo para recuperar el acceso si olvidas tu contraseña`})]})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`code`,{className:`flex-1 text-xs bg-muted rounded px-3 py-2 font-mono break-all`,children:l}),(0,$.jsx)(G,{variant:`ghost`,size:`icon`,onClick:H,className:`shrink-0`,children:d?(0,$.jsx)(c,{className:`h-4 w-4 text-green-500`}):(0,$.jsx)(v,{className:`h-4 w-4`})})]})]})]})}function wt({panel:e}){switch(e){case`etica`:return(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(Ue,{})});case`herramientas`:return(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(Ge,{})});case`mcp`:return(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(Ze,{})});case`skills`:return(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(dt,{})});case`perfil`:return(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(at,{})});case`notas`:return(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(pt,{})});case`cron-jobs`:return(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(St,{})});case`seguridad`:return(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(Ct,{})});default:return null}}var Tt=[`etica`,`herramientas`,`mcp`,`skills`,`perfil`,`notas`,`cron-jobs`,`seguridad`];function Et({forcePanel:e}){let{panel:t}=B(),{fetchSkills:n}=le(),{fetchTools:r}=fe(),{fetchMCPServers:i}=de();(0,Q.useEffect)(()=>{n(),r(),i()},[n,r,i]);let a=e||(Tt.includes(t)?t:`herramientas`),{title:o,subtitle:s,eyebrow:c}={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.`},seguridad:{eyebrow:`CONTROL DE ACCESO`,title:`Seguridad`,subtitle:`Protege tu instancia con email y contraseña. Esencial si despliegas Hive en un servidor público.`}}[a];return(0,$.jsxs)(`div`,{className:`hive-page-container`,children:[(0,$.jsx)(`div`,{className:`hive-page-header`,children:(0,$.jsxs)(`div`,{className:`relative z-10`,children:[(0,$.jsxs)(`div`,{className:`hive-page-header__eyebrow`,children:[(0,$.jsx)(`div`,{className:`hive-page-header__dot`}),(0,$.jsx)(`span`,{className:`hive-page-header__label`,children:c})]}),(0,$.jsxs)(`h2`,{className:`hive-title-page`,children:[o.split(` & `)[0],` `,o.includes(` & `)&&(0,$.jsxs)(`span`,{className:`hive-title-page__accent`,children:[`& `,o.split(` & `)[1]]}),o.includes(` `)&&!o.includes(` & `)&&(0,$.jsxs)($.Fragment,{children:[o.split(` `)[0],` `,(0,$.jsx)(`span`,{className:`hive-title-page__accent`,children:o.split(` `).slice(1).join(` `)})]}),!o.includes(` `)&&o]}),(0,$.jsx)(`p`,{className:`hive-subtitle`,children:s})]})}),(0,$.jsx)(`div`,{className:`animate-fade-in`,children:(0,$.jsx)(wt,{panel:a})})]})}export{Et as SettingsPage};