@johpaz/hive-agents 0.0.37 → 0.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -18
- package/dist/hive.js +3529 -2702
- package/dist/tool-worker.js +2110 -1856
- package/dist/ui/assets/AgentCreateForm-BTCzFbca.js +1 -0
- package/dist/ui/assets/AgentDetailPage-o27TRSVw.js +1 -0
- package/dist/ui/assets/AgentNewPage-400cCpYt.js +1 -0
- package/dist/ui/{dist/assets/AgentsPage-YvSgWRiw.js → assets/AgentsPage-C-GSRk-N.js} +5 -5
- package/dist/ui/assets/ApiClientPage-BOTpz6oP.js +3 -0
- package/dist/ui/assets/{CanvasPage-DtMwGvxf.js → CanvasPage-Cvs5ctza.js} +7 -7
- package/dist/ui/assets/ChannelsPage-C5m_L7P9.js +8 -0
- package/dist/ui/{dist/assets/DashboardPage-ghl1ZguH.js → assets/DashboardPage-CztbRQdm.js} +2 -2
- package/dist/ui/assets/{LoginPage-CAmSI9Vy.js → LoginPage-OMsrx5oj.js} +1 -1
- package/dist/ui/assets/LogsPage-CcYYwjgF.js +1 -0
- package/dist/ui/{dist/assets/MeetingPage-WjjGOqqU.js → assets/MeetingPage-CrKVAfe6.js} +1 -1
- package/dist/ui/assets/{NotFound-BMeQSGcG.js → NotFound-GbAJDgoD.js} +1 -1
- package/dist/ui/assets/ProvidersPage-uqPcZUSV.js +1 -0
- package/dist/ui/{dist/assets/RecoverPage-DpW3l-yv.js → assets/RecoverPage-CwB2ByCU.js} +1 -1
- package/dist/ui/assets/SettingsPage-DKLlye0z.js +9 -0
- package/dist/ui/assets/SetupPage-DOVh1ldK.js +1 -0
- package/dist/ui/assets/WebChatPage-c-7S9jnT.js +16 -0
- package/dist/ui/assets/accordion-DAbcVQCn.js +1 -0
- package/dist/ui/{dist/assets/alert-C-NE-P3s.js → assets/alert-D_2Y3qjL.js} +1 -1
- package/dist/ui/{dist/assets/alert-dialog-C5mzbHdP.js → assets/alert-dialog-CpMxaNcu.js} +1 -1
- package/dist/ui/assets/{badge-ChpACfWO.js → badge-CxTPR6_t.js} +1 -1
- package/dist/ui/assets/bell-8BqRYmzf.js +1 -0
- package/dist/ui/assets/circle-x-Bv6WrUJo.js +1 -0
- package/dist/ui/assets/copy-dU94ZGsi.js +1 -0
- package/dist/ui/{dist/assets/dialog-QnZ0ad8O.js → assets/dialog-DfS3idb3.js} +1 -1
- package/dist/ui/{dist/assets/dropdown-menu-BK-CO3Od.js → assets/dropdown-menu-BdCbAW1z.js} +1 -1
- package/dist/ui/assets/{es-NQNoaWDx.js → es-Cz5h9_84.js} +1 -1
- package/dist/ui/assets/index-CmGm_r89.js +116 -0
- package/dist/ui/assets/index-T7HgphSn.css +2 -0
- package/dist/ui/{dist/assets/label-D2H1IR_J.js → assets/label-byJkqOYq.js} +1 -1
- package/dist/ui/assets/progress-Dtz-Mzys.js +1 -0
- package/dist/ui/assets/scroll-area-BXtLsE9E.js +1 -0
- package/dist/ui/assets/search-BGmPJ-6L.js +1 -0
- package/dist/ui/assets/select-Cl16QYa_.js +1 -0
- package/dist/ui/assets/send-BuQcUO-R.js +1 -0
- package/dist/ui/assets/shield-C-05qB-2.js +1 -0
- package/dist/ui/{dist/assets/slider-CsiUDxc3.js → assets/slider-D2I0qven.js} +1 -1
- package/dist/ui/assets/switch-h2SfQX4B.js +1 -0
- package/dist/ui/assets/table-CVkIRJKK.js +1 -0
- package/dist/ui/assets/tabs-C619jxbO.js +1 -0
- package/dist/ui/assets/textarea-wvA-FDjO.js +1 -0
- package/dist/ui/assets/useProviders-eEri6BAc.js +1 -0
- package/dist/ui/{dist/assets/vendor-radix-cw1bQaVC.js → assets/vendor-radix-D6rA7xKY.js} +4 -4
- package/dist/ui/assets/{vendor-react-D4s9E-zj.js → vendor-react-BU5iQU4f.js} +1 -1
- package/dist/ui/dist/assets/AgentCreateForm-BTCzFbca.js +1 -0
- package/dist/ui/dist/assets/AgentDetailPage-o27TRSVw.js +1 -0
- package/dist/ui/dist/assets/AgentNewPage-400cCpYt.js +1 -0
- package/dist/ui/{assets/AgentsPage-YvSgWRiw.js → dist/assets/AgentsPage-C-GSRk-N.js} +5 -5
- package/dist/ui/dist/assets/ApiClientPage-BOTpz6oP.js +3 -0
- package/dist/ui/dist/assets/{CanvasPage-DtMwGvxf.js → CanvasPage-Cvs5ctza.js} +7 -7
- package/dist/ui/dist/assets/ChannelsPage-C5m_L7P9.js +8 -0
- package/dist/ui/{assets/DashboardPage-ghl1ZguH.js → dist/assets/DashboardPage-CztbRQdm.js} +2 -2
- package/dist/ui/dist/assets/{LoginPage-CAmSI9Vy.js → LoginPage-OMsrx5oj.js} +1 -1
- package/dist/ui/dist/assets/LogsPage-CcYYwjgF.js +1 -0
- package/dist/ui/{assets/MeetingPage-WjjGOqqU.js → dist/assets/MeetingPage-CrKVAfe6.js} +1 -1
- package/dist/ui/dist/assets/{NotFound-BMeQSGcG.js → NotFound-GbAJDgoD.js} +1 -1
- package/dist/ui/dist/assets/ProvidersPage-uqPcZUSV.js +1 -0
- package/dist/ui/{assets/RecoverPage-DpW3l-yv.js → dist/assets/RecoverPage-CwB2ByCU.js} +1 -1
- package/dist/ui/dist/assets/SettingsPage-DKLlye0z.js +9 -0
- package/dist/ui/dist/assets/SetupPage-DOVh1ldK.js +1 -0
- package/dist/ui/dist/assets/WebChatPage-c-7S9jnT.js +16 -0
- package/dist/ui/dist/assets/accordion-DAbcVQCn.js +1 -0
- package/dist/ui/{assets/alert-C-NE-P3s.js → dist/assets/alert-D_2Y3qjL.js} +1 -1
- package/dist/ui/{assets/alert-dialog-C5mzbHdP.js → dist/assets/alert-dialog-CpMxaNcu.js} +1 -1
- package/dist/ui/dist/assets/{badge-ChpACfWO.js → badge-CxTPR6_t.js} +1 -1
- package/dist/ui/dist/assets/bell-8BqRYmzf.js +1 -0
- package/dist/ui/dist/assets/circle-x-Bv6WrUJo.js +1 -0
- package/dist/ui/dist/assets/copy-dU94ZGsi.js +1 -0
- package/dist/ui/{assets/dialog-QnZ0ad8O.js → dist/assets/dialog-DfS3idb3.js} +1 -1
- package/dist/ui/{assets/dropdown-menu-BK-CO3Od.js → dist/assets/dropdown-menu-BdCbAW1z.js} +1 -1
- package/dist/ui/dist/assets/{es-NQNoaWDx.js → es-Cz5h9_84.js} +1 -1
- package/dist/ui/dist/assets/index-CmGm_r89.js +116 -0
- package/dist/ui/dist/assets/index-T7HgphSn.css +2 -0
- package/dist/ui/{assets/label-D2H1IR_J.js → dist/assets/label-byJkqOYq.js} +1 -1
- package/dist/ui/dist/assets/progress-Dtz-Mzys.js +1 -0
- package/dist/ui/dist/assets/scroll-area-BXtLsE9E.js +1 -0
- package/dist/ui/dist/assets/search-BGmPJ-6L.js +1 -0
- package/dist/ui/dist/assets/select-Cl16QYa_.js +1 -0
- package/dist/ui/dist/assets/send-BuQcUO-R.js +1 -0
- package/dist/ui/dist/assets/shield-C-05qB-2.js +1 -0
- package/dist/ui/{assets/slider-CsiUDxc3.js → dist/assets/slider-D2I0qven.js} +1 -1
- package/dist/ui/dist/assets/switch-h2SfQX4B.js +1 -0
- package/dist/ui/dist/assets/table-CVkIRJKK.js +1 -0
- package/dist/ui/dist/assets/tabs-C619jxbO.js +1 -0
- package/dist/ui/dist/assets/textarea-wvA-FDjO.js +1 -0
- package/dist/ui/dist/assets/useProviders-eEri6BAc.js +1 -0
- package/dist/ui/{assets/vendor-radix-cw1bQaVC.js → dist/assets/vendor-radix-D6rA7xKY.js} +4 -4
- package/dist/ui/dist/assets/{vendor-react-D4s9E-zj.js → vendor-react-BU5iQU4f.js} +1 -1
- package/dist/ui/dist/index.html +6 -6
- package/dist/ui/index.html +6 -6
- package/package.json +1 -1
- package/packages/cli/src/adapters/binary.ts +8 -4
- package/packages/cli/src/adapters/bun-global.ts +5 -1
- package/packages/cli/src/adapters/config.ts +4 -3
- package/packages/cli/src/adapters/docker.ts +2 -1
- package/packages/cli/src/commands/gateway.ts +123 -9
- package/packages/cli/src/commands/logs.ts +2 -1
- package/packages/cli/src/commands/onboard.ts +1 -1
- package/packages/cli/src/commands/sessions.ts +2 -1
- package/packages/cli/src/commands/skills.ts +2 -1
- package/packages/core/src/agent/agent-loop.ts +4 -14
- package/packages/core/src/agent/context-compiler.ts +1 -1
- package/packages/core/src/agent/conversation-store.ts +4 -5
- package/packages/core/src/agent/llm-client.ts +4 -0
- package/packages/core/src/agent/llm-providers/anthropic.ts +23 -8
- package/packages/core/src/agent/llm-providers/interface.ts +5 -1
- package/packages/core/src/agent/llm-providers/minimax.ts +13 -0
- package/packages/core/src/agent/llm-providers/opencode-go.ts +9 -0
- package/packages/core/src/agent/providers/index.ts +3 -4
- package/packages/core/src/agent/tool-selector.ts +3 -4
- package/packages/core/src/channels/whatsapp.ts +13 -1
- package/packages/core/src/config/loader.ts +7 -7
- package/packages/core/src/gateway/helpers/path.ts +2 -1
- package/packages/core/src/gateway/initializer.ts +4 -4
- package/packages/core/src/gateway/llm-local/downloader.ts +130 -11
- package/packages/core/src/gateway/llm-local/index.ts +2 -0
- package/packages/core/src/gateway/llm-local/models.ts +4 -3
- package/packages/core/src/gateway/resolver.ts +5 -1
- package/packages/core/src/gateway/router.ts +7 -5
- package/packages/core/src/gateway/routes/chat.ts +16 -16
- package/packages/core/src/gateway/routes/http-client.ts +16 -0
- package/packages/core/src/gateway/routes/llm-local.ts +51 -5
- package/packages/core/src/gateway/routes/providers.ts +43 -2
- package/packages/core/src/gateway/server.ts +55 -47
- package/packages/core/src/gateway/tts/src/install.ts +17 -9
- package/packages/core/src/storage/crypto.ts +152 -20
- package/packages/core/src/storage/migrate.ts +51 -18
- package/packages/core/src/storage/seed.ts +77 -35
- package/packages/core/src/tool-runtime/index.ts +42 -1
- package/packages/core/src/tools/api/api-request.ts +174 -0
- package/packages/core/src/tools/api/index.ts +16 -0
- package/packages/core/src/tools/index.ts +12 -0
- package/packages/core/src/tools/web/browser-click.ts +2 -2
- package/packages/core/src/tools/web/browser-extract.ts +22 -6
- package/packages/core/src/tools/web/browser-navigate.ts +34 -18
- package/packages/core/src/tools/web/browser-screenshot.ts +40 -8
- package/packages/core/src/tools/web/browser-script.ts +2 -2
- package/packages/core/src/tools/web/browser-service.ts +295 -341
- package/packages/core/src/tools/web/browser-type.ts +5 -10
- package/packages/core/src/tools/web/browser-wait.ts +2 -2
- package/packages/core/src/tools/web/index.ts +1 -1
- package/packages/core/src/utils/logger.ts +2 -1
- package/packages/mcp/src/manager.ts +2 -1
- package/packages/skills/src/bundled/api/api_client/SKILL.md +132 -0
- package/packages/skills/src/bundled-data.generated.ts +1274 -1217
- package/packages/skills/src/loader.ts +2 -1
- package/dist/ui/assets/AgentCreateForm-tJZv9FZC.js +0 -1
- package/dist/ui/assets/AgentDetailPage-Du-mRcAX.js +0 -1
- package/dist/ui/assets/AgentNewPage-DIFYd_Ys.js +0 -1
- package/dist/ui/assets/ChannelsPage-BdBXWHjj.js +0 -8
- package/dist/ui/assets/LogsPage-DAPBHkwK.js +0 -1
- package/dist/ui/assets/ProvidersPage-Ct6HsAi1.js +0 -1
- package/dist/ui/assets/SettingsPage-DBJ7_E6C.js +0 -9
- package/dist/ui/assets/SetupPage-DKmLVUaj.js +0 -1
- package/dist/ui/assets/WebChatPage-CVRcKept.js +0 -16
- package/dist/ui/assets/accordion-C5d5Rm5z.js +0 -1
- package/dist/ui/assets/globe-DeCQTCDJ.js +0 -1
- package/dist/ui/assets/index-B2fCYtTS.css +0 -2
- package/dist/ui/assets/index-DMCjjdqf.js +0 -116
- package/dist/ui/assets/progress-BherYzY6.js +0 -1
- package/dist/ui/assets/scroll-area-DkeyX32e.js +0 -1
- package/dist/ui/assets/send-B0H5SEIE.js +0 -1
- package/dist/ui/assets/switch-BDwN8RYV.js +0 -1
- package/dist/ui/assets/table-CSc8ubon.js +0 -1
- package/dist/ui/assets/textarea-CXgXWKrT.js +0 -1
- package/dist/ui/assets/useProviders-C6_QHsEi.js +0 -1
- package/dist/ui/dist/assets/AgentCreateForm-tJZv9FZC.js +0 -1
- package/dist/ui/dist/assets/AgentDetailPage-Du-mRcAX.js +0 -1
- package/dist/ui/dist/assets/AgentNewPage-DIFYd_Ys.js +0 -1
- package/dist/ui/dist/assets/ChannelsPage-BdBXWHjj.js +0 -8
- package/dist/ui/dist/assets/LogsPage-DAPBHkwK.js +0 -1
- package/dist/ui/dist/assets/ProvidersPage-Ct6HsAi1.js +0 -1
- package/dist/ui/dist/assets/SettingsPage-DBJ7_E6C.js +0 -9
- package/dist/ui/dist/assets/SetupPage-DKmLVUaj.js +0 -1
- package/dist/ui/dist/assets/WebChatPage-CVRcKept.js +0 -16
- package/dist/ui/dist/assets/accordion-C5d5Rm5z.js +0 -1
- package/dist/ui/dist/assets/globe-DeCQTCDJ.js +0 -1
- package/dist/ui/dist/assets/index-B2fCYtTS.css +0 -2
- package/dist/ui/dist/assets/index-DMCjjdqf.js +0 -116
- package/dist/ui/dist/assets/progress-BherYzY6.js +0 -1
- package/dist/ui/dist/assets/scroll-area-DkeyX32e.js +0 -1
- package/dist/ui/dist/assets/send-B0H5SEIE.js +0 -1
- package/dist/ui/dist/assets/switch-BDwN8RYV.js +0 -1
- package/dist/ui/dist/assets/table-CSc8ubon.js +0 -1
- package/dist/ui/dist/assets/textarea-CXgXWKrT.js +0 -1
- package/dist/ui/dist/assets/useProviders-C6_QHsEi.js +0 -1
- /package/dist/ui/assets/{card-CNf6BS2e.js → card-CXAm46at.js} +0 -0
- /package/dist/ui/assets/{cpu-Cdgc_B1K.js → cpu-DSpPVLAz.js} +0 -0
- /package/dist/ui/assets/{download-C3ifGMjJ.js → download-D9ZyUZZR.js} +0 -0
- /package/dist/ui/assets/{external-link-BvxYeTP1.js → external-link-CHPbUorN.js} +0 -0
- /package/dist/ui/assets/{eye-DqNTU_GD.js → eye-epHJZ_nQ.js} +0 -0
- /package/dist/ui/assets/{file-text-BT_9S9SM.js → file-text-BEjEmgby.js} +0 -0
- /package/dist/ui/assets/{folder-open-BhH8y9ac.js → folder-open-iQMHVEqS.js} +0 -0
- /package/dist/ui/assets/{format-GVHeOyWI.js → format-oFACFaca.js} +0 -0
- /package/dist/ui/assets/{gateway-url-COCbW0IR.js → gateway-url-iG-C6Agn.js} +0 -0
- /package/dist/ui/assets/{gauge-D_TMa4i9.js → gauge-D0_GMEcq.js} +0 -0
- /package/dist/ui/assets/{settings-Ds4SqD8s.js → settings-CcMGI1iU.js} +0 -0
- /package/dist/ui/assets/{sparkles-yUEb-7oH.js → sparkles-D6fx8JC5.js} +0 -0
- /package/dist/ui/assets/{trash-2-CNjMkoq6.js → trash-2-BHRa5ft9.js} +0 -0
- /package/dist/ui/assets/{triangle-alert-C9Y8Ub4X.js → triangle-alert-D4nwAVbc.js} +0 -0
- /package/dist/ui/assets/{vendor-router-C9pIYwbJ.js → vendor-router-pCP7sjma.js} +0 -0
- /package/dist/ui/assets/{volume-2-CeSXNDv4.js → volume-2-B6tkRy2u.js} +0 -0
- /package/dist/ui/assets/{zap-hlXjpSeA.js → zap-QO7iWMRg.js} +0 -0
- /package/dist/ui/dist/assets/{card-CNf6BS2e.js → card-CXAm46at.js} +0 -0
- /package/dist/ui/dist/assets/{cpu-Cdgc_B1K.js → cpu-DSpPVLAz.js} +0 -0
- /package/dist/ui/dist/assets/{download-C3ifGMjJ.js → download-D9ZyUZZR.js} +0 -0
- /package/dist/ui/dist/assets/{external-link-BvxYeTP1.js → external-link-CHPbUorN.js} +0 -0
- /package/dist/ui/dist/assets/{eye-DqNTU_GD.js → eye-epHJZ_nQ.js} +0 -0
- /package/dist/ui/dist/assets/{file-text-BT_9S9SM.js → file-text-BEjEmgby.js} +0 -0
- /package/dist/ui/dist/assets/{folder-open-BhH8y9ac.js → folder-open-iQMHVEqS.js} +0 -0
- /package/dist/ui/dist/assets/{format-GVHeOyWI.js → format-oFACFaca.js} +0 -0
- /package/dist/ui/dist/assets/{gateway-url-COCbW0IR.js → gateway-url-iG-C6Agn.js} +0 -0
- /package/dist/ui/dist/assets/{gauge-D_TMa4i9.js → gauge-D0_GMEcq.js} +0 -0
- /package/dist/ui/dist/assets/{settings-Ds4SqD8s.js → settings-CcMGI1iU.js} +0 -0
- /package/dist/ui/dist/assets/{sparkles-yUEb-7oH.js → sparkles-D6fx8JC5.js} +0 -0
- /package/dist/ui/dist/assets/{trash-2-CNjMkoq6.js → trash-2-BHRa5ft9.js} +0 -0
- /package/dist/ui/dist/assets/{triangle-alert-C9Y8Ub4X.js → triangle-alert-D4nwAVbc.js} +0 -0
- /package/dist/ui/dist/assets/{vendor-router-C9pIYwbJ.js → vendor-router-pCP7sjma.js} +0 -0
- /package/dist/ui/dist/assets/{volume-2-CeSXNDv4.js → volume-2-B6tkRy2u.js} +0 -0
- /package/dist/ui/dist/assets/{zap-hlXjpSeA.js → zap-QO7iWMRg.js} +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
2
|
import * as path from "node:path";
|
|
3
|
+
import { homedir } from "node:os";
|
|
3
4
|
import { YAML } from "bun";
|
|
4
5
|
|
|
5
6
|
// Static bundled data generated by packages/skills/scripts/generate-bundle.ts
|
|
@@ -164,7 +165,7 @@ export class SkillLoader {
|
|
|
164
165
|
|
|
165
166
|
private expandPath(p: string): string {
|
|
166
167
|
if (p.startsWith("~")) {
|
|
167
|
-
return path.join(
|
|
168
|
+
return path.join(homedir(), p.slice(1));
|
|
168
169
|
}
|
|
169
170
|
return p;
|
|
170
171
|
}
|
|
@@ -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{a as i,c as a,l as o,n as s,r as c,s as l,t as u}from"./switch-BDwN8RYV.js";import{t as d}from"./circle-alert-CyHDwUj8.js";import{t as f}from"./cpu-Cdgc_B1K.js";import{t as p}from"./external-link-BvxYeTP1.js";import{t as m}from"./folder-open-BhH8y9ac.js";import{t as h}from"./loader-circle-CZNax6kS.js";import{t as g}from"./save-CUdYyHNy.js";import{n as _,t as v}from"./textarea-CXgXWKrT.js";import{t as y}from"./sparkles-yUEb-7oH.js";import{M as b,R as x,c as S,h as C,j as w,p as T,t as E}from"./index-DMCjjdqf.js";import{t as D}from"./label-D2H1IR_J.js";import{a as O,c as k,i as ee,n as A,o as j,r as M,s as N,t as P}from"./dialog-QnZ0ad8O.js";import{t as F}from"./badge-ChpACfWO.js";import{a as I,n as L,o as R,r as z,t as B}from"./card-CNf6BS2e.js";import"./useProviders-C6_QHsEi.js";var V=e(t(),1),H=n();function U({selectedProviderId:e,selectedModelId:t,onProviderChange:n,onModelChange:r,disabled:o=!1,typeFilter:u}){let{providers:d,models:f}=S(),p=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},m=e=>{if(e.id===`ollama`)return!0;let t=e.base_url||e.baseUrl||``;return t.includes(`localhost`)||t.includes(`127.0.0.1`)},h=d.filter(e=>(e.enabled||e.active)&&p(e)),g=d.find(t=>t.id===e),_=!!g&&!h.some(e=>e.id===g.id),v=(0,V.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]),y=(0,V.useMemo)(()=>v.filter(e=>e.enabled||e.active),[v]),b=v.find(e=>e.id===t),x=!!b&&!y.some(e=>e.id===b.id);(0,V.useEffect)(()=>{t&&v.length>0&&!v.find(e=>e.id===t)&&r(``)},[v,t,r]);let C=e=>{if(!e)return[];try{return JSON.parse(e)}catch{return[]}};return(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(D,{htmlFor:`provider`,children:`Proveedor de IA`}),(0,H.jsxs)(s,{value:e||``,onValueChange:n,disabled:o||h.length===0,children:[(0,H.jsx)(l,{id:`provider`,className:`w-full`,children:(0,H.jsx)(a,{placeholder:`Selecciona un proveedor`,children:e&&g?(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`span`,{children:g.name}),_&&(0,H.jsx)(`span`,{className:`text-[10px] text-amber-400/80`,children:`(inactivo)`}),m(g)?(0,H.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,H.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,H.jsx)(c,{children:h.length===0?(0,H.jsx)(i,{value:`none`,disabled:!0,children:`No hay proveedores configurados`}):h.map(e=>(0,H.jsx)(i,{value:e.id,children:(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`span`,{children:e.name}),m(e)?(0,H.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,H.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))})]}),_&&g&&(0,H.jsxs)(`p`,{className:`text-[10px] text-amber-400/80`,children:[`El proveedor "`,g.name,`" está inactivo. Selecciona uno activo para cambiar.`]}),h.length===0&&(0,H.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Configura un proveedor en`,` `,(0,H.jsx)(`a`,{href:`/providers`,className:`text-primary underline`,children:`Settings > Providers`})]})]}),e&&(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(D,{htmlFor:`model`,children:`Modelo`}),(0,H.jsxs)(s,{value:t||``,onValueChange:r,disabled:o||y.length===0,children:[(0,H.jsx)(l,{id:`model`,className:`w-full`,children:(0,H.jsx)(a,{placeholder:`Selecciona un modelo`,children:t&&b?(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`span`,{children:b.name}),x&&(0,H.jsx)(`span`,{className:`text-[10px] text-amber-400/80`,children:`(inactivo)`})]}):`Selecciona un modelo`})}),(0,H.jsx)(c,{children:y.length===0?(0,H.jsx)(i,{value:`none`,disabled:!0,children:`No hay modelos disponibles`}):y.map(e=>(0,H.jsx)(i,{value:e.id,children:(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`span`,{children:e.name}),e.contextWindow&&(0,H.jsxs)(F,{variant:`secondary`,className:`text-[10px]`,children:[(e.contextWindow/1e3).toFixed(0),`K ctx`]})]})},e.id))})]}),x&&b&&(0,H.jsxs)(`p`,{className:`text-[10px] text-amber-400/80`,children:[`El modelo "`,b.name,`" está inactivo. Selecciona uno activo para cambiar.`]}),t&&v.find(e=>e.id===t)&&(0,H.jsx)(B,{className:`mt-2`,children:(0,H.jsxs)(L,{className:`p-3 space-y-2`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium`,children:v.find(e=>e.id===t)?.name}),(0,H.jsx)(F,{variant:`outline`,children:d.find(t=>t.id===e)?.name})]}),(()=>{let e=C(v.find(e=>e.id===t)?.capabilities);return e.length>0?(0,H.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.slice(0,5).map(e=>(0,H.jsx)(F,{variant:`secondary`,className:`text-[10px]`,children:e},e))}):null})()]})})]})]})}var W=[{value:`friendly`,label:`Amigable`},{value:`professional`,label:`Profesional`},{value:`casual`,label:`Casual`},{value:`formal`,label:`Formal`},{value:`creative`,label:`Creativo`}];function G({initialData:e,onSuccess:t,onCancel:n}){let{createAgent:F,updateAgent:G,isLoading:K,error:q}=E(),{activeProviders:te}=S(),[J,Y]=(0,V.useState)({isValidating:!1,exists:!1,accessible:!1}),[X,Z]=(0,V.useState)({name:``,description:``,tone:`professional`,provider_id:``,model_id:``,role:`coordinator`,enabled:!0,systemPrompt:``,workspace:e?.workspace||``});(0,V.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 T(`/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 T(`/api/workspace/create`,{method:`POST`,body:{path:X.workspace},showLoader:`Creando directorio...`,showSuccess:`Directorio creado exitosamente`}),await Q(X.workspace)}catch(e){C.fire(`Error`,e.message,`error`)}},re=async()=>{if(X.workspace)try{await T(`/api/workspace/open?path=${encodeURIComponent(X.workspace)}`,{method:`GET`})}catch(e){C.fire(`Error`,e.message,`error`)}},ie=async n=>{if(n.preventDefault(),!X.provider_id||!X.model_id){C.fire(`Incompleto`,`Por favor selecciona un proveedor y modelo`,`warning`);return}try{e?.id?await G(e.id,X):await F(X),t&&t()}catch(e){console.error(e)}},$=!!e?.id;return(0,H.jsxs)(B,{className:`hive-card--form group`,children:[(0,H.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,H.jsx)(I,{className:`relative`,children:(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsx)(`div`,{className:`hive-icon-wrap hive-icon-wrap--primary`,children:$?(0,H.jsx)(g,{className:`h-5 w-5`}):(0,H.jsx)(y,{className:`h-5 w-5`})}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(R,{className:`text-xl font-bold text-white/90`,children:$?`Configurar Nodo`:`Desplegar Nuevo Nodo`}),(0,H.jsx)(z,{className:`text-white/40`,children:$?`Ajusta los parámetros de tu agente inteligente.`:`Crea una nueva entidad inteligente para tu colmena.`})]})]}),n&&(0,H.jsx)(b,{variant:`ghost`,size:`icon`,onClick:n,className:`text-white/40 hover:text-white hover:bg-white/5`,children:(0,H.jsx)(x,{className:`h-5 w-5`})})]})}),(0,H.jsx)(L,{className:`relative space-y-6 pt-2`,children:(0,H.jsxs)(`form`,{onSubmit:ie,className:`space-y-8`,children:[(0,H.jsxs)(`div`,{className:`grid gap-6`,children:[(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(D,{htmlFor:`name`,className:`hive-label--field`,children:`Nombre del Agente`}),(0,H.jsx)(w,{id:`name`,placeholder:`Ej: Analista de Mercado`,className:`hive-input`,value:X.name,onChange:e=>Z({...X,name:e.target.value}),disabled:K,required:!0})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(D,{htmlFor:`description`,className:`hive-label--field`,children:`Descripción / Rol`}),(0,H.jsx)(v,{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:K})]})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsx)(D,{htmlFor:`systemPrompt`,className:`hive-label--field`,children:`System Prompt`}),(0,H.jsxs)(P,{children:[(0,H.jsx)(k,{asChild:!0,children:(0,H.jsx)(b,{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,H.jsxs)(M,{className:`sm:max-w-3xl bg-[#0a0a0c] border-white/10 text-white shadow-2xl [&>button]:text-white/50 hover:[&>button]:text-white`,children:[(0,H.jsxs)(j,{children:[(0,H.jsx)(N,{className:`text-xl`,children:`Editar System Prompt`}),(0,H.jsx)(ee,{className:`text-sm text-white/50`,children:`El prompt base de comportamiento del agente. Se recomienda formato Markdown.`})]}),(0,H.jsx)(`div`,{className:`py-2`,children:(0,H.jsx)(v,{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:K})}),(0,H.jsx)(O,{children:(0,H.jsx)(A,{asChild:!0,children:(0,H.jsx)(b,{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,H.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,H.jsx)(`p`,{className:`text-xs text-white/30 italic`,children:`Sin system prompt configurado...`})]}),(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,H.jsx)(m,{className:`h-4 w-4 text-emerald-400`}),(0,H.jsx)(`h3`,{className:`hive-title-section`,children:`Workspace Directory`})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(D,{htmlFor:`workspace`,className:`hive-label--field`,children:`Directorio de Trabajo del Agente`}),(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsx)(w,{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:K}),X.workspace&&J.exists&&J.accessible&&(0,H.jsx)(b,{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,H.jsx)(p,{className:`h-4 w-4`})})]}),(0,H.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,H.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,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(h,{className:`h-3.5 w-3.5 animate-spin`}),(0,H.jsx)(`span`,{children:`Validando directorio...`})]}),!J.isValidating&&J.exists&&J.accessible&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(o,{className:`h-3.5 w-3.5`}),(0,H.jsx)(`span`,{children:J.message||`Directorio válido y accesible`})]}),!J.isValidating&&J.exists&&!J.accessible&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(d,{className:`h-3.5 w-3.5`}),(0,H.jsx)(`span`,{children:J.message||`El directorio existe pero no tiene permisos de lectura/escritura`})]}),!J.isValidating&&!J.exists&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(m,{className:`h-3.5 w-3.5`}),(0,H.jsx)(`span`,{children:J.message||`El directorio no existe`}),!J.error&&(0,H.jsx)(b,{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,H.jsx)(`div`,{className:`hive-card-divider`}),(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,H.jsx)(f,{className:`h-4 w-4 text-blue-400`}),(0,H.jsx)(`h3`,{className:`hive-title-section`,children:`Motor de Inteligencia`})]}),(0,H.jsx)(U,{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:K,typeFilter:`llm`})]}),(0,H.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:[(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(D,{htmlFor:`tone`,className:`hive-label--field`,children:`Tono de Voz`}),(0,H.jsxs)(s,{value:X.tone,onValueChange:e=>Z({...X,tone:e}),disabled:K,children:[(0,H.jsx)(l,{className:`hive-select-trigger`,children:(0,H.jsx)(a,{placeholder:`Selecciona un tono`})}),(0,H.jsx)(c,{className:`hive-select-content`,children:W.map(e=>(0,H.jsx)(i,{value:e.value,className:`hive-select-item`,children:e.label},e.value))})]})]}),(0,H.jsxs)(`div`,{className:`hive-toggle-panel`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(_,{className:`h-3.5 w-3.5 text-purple-400`}),(0,H.jsx)(D,{htmlFor:`role`,className:`text-xs font-medium text-white/70`,children:`Rol`})]}),(0,H.jsxs)(s,{value:X.role,onValueChange:e=>Z({...X,role:e}),disabled:K,children:[(0,H.jsx)(l,{className:`w-[120px] bg-white/5 border-white/10 text-white`,children:(0,H.jsx)(a,{})}),(0,H.jsxs)(c,{className:`bg-zinc-900 border-white/10`,children:[(0,H.jsx)(i,{value:`coordinator`,children:`Coordinador`}),(0,H.jsx)(i,{value:`worker`,children:`Worker`})]})]})]}),(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`div`,{className:`h-2 w-2 rounded-full ${X.enabled?`bg-blue-400`:`bg-zinc-600`}`}),(0,H.jsx)(D,{htmlFor:`enabled`,className:`text-xs font-medium text-white/70`,children:`Habilitado`})]}),(0,H.jsx)(u,{id:`enabled`,checked:X.enabled,onCheckedChange:e=>Z({...X,enabled:e}),disabled:K})]})]})]}),q&&(0,H.jsx)(`div`,{className:`hive-form-error`,children:q}),(0,H.jsxs)(`div`,{className:`flex items-center gap-3 pt-4`,children:[n&&(0,H.jsx)(b,{type:`button`,variant:`outline`,onClick:n,disabled:K,className:`hive-btn--form-cancel`,children:`Cancelar`}),(0,H.jsx)(b,{type:`submit`,disabled:K,className:`hive-btn--form-submit`,children:K?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(h,{className:`mr-2 h-4 w-4 animate-spin`}),`Procesando...`]}):(0,H.jsx)(H.Fragment,{children:$?`Actualizar Agente`:`Desplegar Agente`})})]})]})})]})}export{G 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{a as s,c,l,n as u,r as d,s as f,t as ee}from"./switch-BDwN8RYV.js";import{t as p}from"./chevron-left-D4U-5A27.js";import{t as te}from"./circle-alert-CyHDwUj8.js";import{t as m}from"./cpu-Cdgc_B1K.js";import{t as ne}from"./external-link-BvxYeTP1.js";import{t as h}from"./folder-open-BhH8y9ac.js";import{t as re}from"./globe-DeCQTCDJ.js";import{t as ie}from"./loader-circle-CZNax6kS.js";import{t as g}from"./save-CUdYyHNy.js";import{n as ae,t as _}from"./textarea-CXgXWKrT.js";import{t as oe}from"./sparkles-yUEb-7oH.js";import{t as v}from"./zap-hlXjpSeA.js";import{c as y,l as b}from"./vendor-router-C9pIYwbJ.js";import{M as x,V as se,c as S,g as C,j as w,m as T,p as E,s as D,t as O}from"./index-DMCjjdqf.js";import{t as k}from"./label-D2H1IR_J.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-QnZ0ad8O.js";import{t as I}from"./badge-ChpACfWO.js";import{n as L,t as R}from"./es-NQNoaWDx.js";import{t as z}from"./format-GVHeOyWI.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}=O(),{providers:o,fetchProviders:p}=S(),{models:m,fetchModels:v}=D();(0,H.useEffect)(()=>{r(),p(),v()},[r,p,v]);let y=t.find(t=>t.id===e),[b,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)(()=>{y&&(I({name:y.name||``,description:y.description||``,provider_id:y.provider_id||y.providerId||``,model_id:y.model_id||y.modelId||``,tone:y.tone||``,role:y.role||`coordinator`,enabled:!!y.enabled,headers:``,systemPrompt:y.systemPrompt||``,workspace:y.workspace||``}),y.workspace&&z(y.workspace))},[y]);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 E(`/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(b.workspace)try{await E(`/api/workspace/create`,{method:`POST`,body:{path:b.workspace},showLoader:`Creando directorio...`,showSuccess:`Directorio creado exitosamente`}),await z(b.workspace)}catch(e){T.fire({icon:`error`,title:e.message})}},V=async()=>{if(b.workspace)try{await E(`/api/workspace/open?path=${encodeURIComponent(b.workspace)}`,{method:`GET`})}catch(e){T.fire({icon:`error`,title:e.message})}},G=async()=>{C.show(`Sincronizando configuración del agente...`);try{await n(e,{...b,role:b.role,enabled:+!!b.enabled,workspace:b.workspace||null}),T.fire({icon:`success`,title:`Cambios sincronizados correctamente`})}catch(e){T.fire({icon:`error`,title:e instanceof Error?e.message:`Error al sincronizar cambios`})}finally{C.hide()}};if(!y)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)===b.provider_id&&(e.enabled||e.active)),X=o.find(e=>e.id===b.provider_id),Z=!!X&&!J.some(e=>e.id===X.id),Q=m.filter(e=>(e.provider_id||e.providerId)===b.provider_id).find(e=>e.id===b.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:se,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)(k,{htmlFor:`name`,className:`text-xs text-white/40 uppercase tracking-widest pl-1`,children:`Nombre Público`}),(0,U.jsx)(w,{id:`name`,value:b.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)(k,{htmlFor:`tone`,className:`text-xs text-white/40 uppercase tracking-widest pl-1`,children:`Tono Cognitivo`}),(0,U.jsx)(w,{id:`tone`,value:b.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:ae,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)(k,{className:`text-sm font-semibold`,children:`Rol`}),(0,U.jsx)(`p`,{className:`text-[10px] text-white/30`,children:`Coordinador o Worker`})]}),(0,U.jsxs)(u,{value:b.role,onValueChange:e=>I(t=>({...t,role:e})),children:[(0,U.jsx)(f,{className:`w-[120px] bg-white/5 border-white/10 text-white`,children:(0,U.jsx)(c,{})}),(0,U.jsxs)(d,{className:`bg-zinc-900 border-white/10`,children:[(0,U.jsx)(s,{value:`coordinator`,children:`Coordinador`}),(0,U.jsx)(s,{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)(k,{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)(ee,{checked:b.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)(k,{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)(w,{id:`workspace`,value:b.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`}),b.workspace&&L.exists&&L.accessible&&(0,U.jsx)(x,{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)(ne,{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).`}),b.workspace&&b.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)(ie,{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)(l,{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)(te,{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)(x,{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:oe,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)(x,{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:g,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)(k,{htmlFor:`description`,className:`text-xs text-white/40 uppercase tracking-widest pl-1`,children:`Directiva de Misión (Descripción)`}),(0,U.jsx)(_,{id:`description`,value:b.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)(k,{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)(x,{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)(_,{value:b.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)(x,{type:`button`,className:`bg-blue-600 hover:bg-blue-500 text-white shadow-[0_0_15px_rgba(37,99,235,0.3)]`,children:`Listo`})})})]})]})]}),b.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:b.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)(k,{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)(u,{value:b.provider_id,onValueChange:e=>I(t=>({...t,provider_id:e,model_id:``})),children:[(0,U.jsx)(f,{className:`bg-white/5 border-white/10 rounded-xl h-11`,children:(0,U.jsx)(c,{placeholder:`Seleccionar proveedor`,children:b.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)(d,{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)(s,{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)(k,{className:`text-xs text-white/40 uppercase tracking-widest`,children:`Modelo`}),b.provider_id&&Y.length===0&&(0,U.jsx)(`span`,{className:`text-[10px] text-amber-400/80`,children:`Sin modelos activos`})]}),(0,U.jsxs)(u,{value:b.model_id,onValueChange:e=>I(t=>({...t,model_id:e})),disabled:!b.provider_id||Y.length===0,children:[(0,U.jsx)(f,{className:`bg-white/5 border-white/10 rounded-xl h-11 disabled:opacity-50`,children:(0,U.jsx)(c,{placeholder:b.provider_id?Y.length===0?`Activa modelos en el provider`:`Seleccionar modelo`:`Primero selecciona un proveedor`,children:b.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)(d,{className:`bg-zinc-900 border-white/10 text-white`,children:Y.map(e=>(0,U.jsx)(s,{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:re,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}=S(),{models:n}=D(),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:v,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}=b(),t=y(),n=e??`unknown`,{agents:r,fetchAgents:i,isLoading:o}=O();(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)(x,{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-tJZv9FZC.js";var n=e();function r(){return(0,n.jsx)(t,{})}export{r as AgentNewPage};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import{r as e,t}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as n}from"./vendor-charts-Bu2lyBKP.js";import{o as r}from"./vendor-query-DsWPbQdG.js";import{r as i}from"./utils-3pnRFmFe.js";import{a,c as o,i as s,n as c,o as l,r as u,s as d,t as f}from"./switch-BDwN8RYV.js";import{t as p}from"./circle-alert-CyHDwUj8.js";import{t as m}from"./circle-check-Bb54Ebmu.js";import{n as h,t as g}from"./eye-DqNTU_GD.js";import{t as _}from"./loader-circle-CZNax6kS.js";import{t as v}from"./plus-CX1xyhp5.js";import{t as ee}from"./refresh-cw-DaYdjQFk.js";import{t as y}from"./settings-Ds4SqD8s.js";import{t as b}from"./zap-hlXjpSeA.js";import{c as x}from"./vendor-router-C9pIYwbJ.js";import{G as S,K as C,M as w,R as te,d as ne,j as T,n as re,p as ie}from"./index-DMCjjdqf.js";import{t as E}from"./label-D2H1IR_J.js";import{n as ae,t as oe}from"./alert-C-NE-P3s.js";var se=i(`QrCode`,[[`rect`,{width:`5`,height:`5`,x:`3`,y:`3`,rx:`1`,key:`1tu5fj`}],[`rect`,{width:`5`,height:`5`,x:`16`,y:`3`,rx:`1`,key:`1v8r4q`}],[`rect`,{width:`5`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`1x03jg`}],[`path`,{d:`M21 16h-3a2 2 0 0 0-2 2v3`,key:`177gqh`}],[`path`,{d:`M21 21v.01`,key:`ents32`}],[`path`,{d:`M12 7v3a2 2 0 0 1-2 2H7`,key:`8crl2c`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M12 3h.01`,key:`n36tog`}],[`path`,{d:`M12 16v.01`,key:`133mhm`}],[`path`,{d:`M16 12h1`,key:`1slzba`}],[`path`,{d:`M21 12v.01`,key:`1lwtk9`}],[`path`,{d:`M12 21v-1`,key:`1880an`}]]),D=e(n(),1),O=r();function k({channel:e,onEdit:t,onToggle:n}){e.status;let r=e.isConfigured===!1,i=e.status===`connected`||e.status===`connecting`;return(0,O.jsxs)(`div`,{onClick:()=>t(e),className:`hive-card group transition-all duration-500 cursor-pointer ${i?`hive-card--active border-emerald-500/20`:r?`opacity-50 border-dashed hover:opacity-80 hover:border-blue-500/30`:`opacity-60 grayscale-[0.8] hover:opacity-100 hover:grayscale-0`}`,children:[(0,O.jsxs)(`div`,{className:`hive-card-body relative overflow-hidden`,children:[(0,O.jsxs)(`div`,{className:`flex items-start justify-between mb-8`,children:[(0,O.jsx)(`div`,{className:`h-12 w-12 rounded-xl flex items-center justify-center border transition-all duration-500 ${i?`bg-emerald-500/10 border-emerald-500/30 text-emerald-400 shadow-[0_0_15px_rgba(16,185,129,0.2)]`:r?`bg-blue-500/5 border-blue-500/20 text-blue-400/40`:`bg-white/5 border-white/10 text-white/30`}`,children:(0,O.jsx)(S,{className:`h-6 w-6`})}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[i&&(0,O.jsx)(`span`,{className:`text-[9px] font-black tracking-widest text-emerald-500 shadow-emerald-glow`,children:e.status===`connecting`?`CONECTANDO`:`CONECTADO`}),r?(0,O.jsx)(`span`,{className:`text-[9px] font-black tracking-widest text-blue-400/60 uppercase`,children:`DISPONIBLE`}):(0,O.jsx)(f,{checked:e.enabled,onCheckedChange:t=>n(e.id,t),onClick:e=>e.stopPropagation(),className:`data-[state=checked]:bg-emerald-500 scale-75 origin-right`})]})]}),(0,O.jsxs)(`div`,{className:`space-y-4`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h3`,{className:`text-xl font-black text-white uppercase tracking-tighter mb-1 line-clamp-1 group-hover:text-emerald-400 transition-colors`,children:e.type}),(0,O.jsx)(`p`,{className:`text-[10px] text-white/20 font-black tracking-[0.2em] mb-4`,children:r?`CLICK PARA CONFIGURAR`:`ID: ${e.id.substring(0,12).toUpperCase()}`})]}),(0,O.jsxs)(`div`,{className:`pt-4 border-t border-white/5 flex items-center gap-6`,children:[(0,O.jsxs)(`div`,{className:`hive-stat`,children:[(0,O.jsx)(`span`,{className:`hive-stat__label`,children:`VOZ`}),(0,O.jsx)(`span`,{className:`hive-stat__value ${e.voice_enabled?`text-emerald-500`:`text-white/20`}`,children:e.voice_enabled?`ON`:`OFF`})]}),(0,O.jsxs)(`div`,{className:`hive-stat`,children:[(0,O.jsx)(`span`,{className:`hive-stat__label`,children:`SÍNTESIS`}),(0,O.jsx)(`span`,{className:`hive-stat__value ${e.tts_enabled?`text-emerald-500`:`text-white/20`}`,children:e.tts_enabled?`ON`:`OFF`})]})]})]}),i&&(0,O.jsx)(`div`,{className:`hive-glow-blob hive-glow-blob--emerald -bottom-10 -right-10 h-24 w-24 opacity-20`})]}),(0,O.jsx)(`div`,{className:`hive-strip--bottom ${i?`bg-emerald-500`:r?`bg-blue-500/30`:`bg-white/10`}`})]})}var ce=t(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),A=t((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),j=t((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),M=t(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),le=t(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),N=t((e=>{var t=A().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),P=t((e=>{var t=A().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),F=t((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),I=t((e=>{var t=j(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return r[(e-1)*4+0];case t.M:return r[(e-1)*4+1];case t.Q:return r[(e-1)*4+2];case t.H:return r[(e-1)*4+3];default:return}}})),L=t((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),R=t((e=>{var t=L();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),ue=t(((e,t)=>{var n=R();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),de=t((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),z=t((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r
|
|
2
|
-
]))+`;e.KANJI=new RegExp(r,`g`),e.BYTE_KANJI=RegExp(`[^A-Z0-9 $%*+\\-./:]+`,`g`),e.BYTE=new RegExp(i,`g`),e.NUMERIC=new RegExp(t,`g`),e.ALPHANUMERIC=new RegExp(n,`g`);var a=RegExp(`^`+r+`$`),o=RegExp(`^`+t+`$`),s=RegExp(`^[A-Z0-9 $%*+\\-./:]+$`);e.testKanji=function(e){return a.test(e)},e.testNumeric=function(e){return o.test(e)},e.testAlphanumeric=function(e){return s.test(e)}})),B=t((e=>{var t=de(),n=z();e.NUMERIC={id:`Numeric`,bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:`Alphanumeric`,bit:2,ccBits:[9,11,13]},e.BYTE={id:`Byte`,bit:4,ccBits:[8,16,16]},e.KANJI={id:`Kanji`,bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,n){if(!e.ccBits)throw Error(`Invalid mode: `+e);if(!t.isValid(n))throw Error(`Invalid version: `+n);return n>=1&&n<10?e.ccBits[0]:n<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return n.testNumeric(t)?e.NUMERIC:n.testAlphanumeric(t)?e.ALPHANUMERIC:n.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw Error(`Invalid mode`)},e.isValid=function(e){return e&&e.bit&&e.ccBits};function r(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`numeric`:return e.NUMERIC;case`alphanumeric`:return e.ALPHANUMERIC;case`kanji`:return e.KANJI;case`byte`:return e.BYTE;default:throw Error(`Unknown mode: `+t)}}e.from=function(t,n){if(e.isValid(t))return t;try{return r(t)}catch{return n}}})),fe=t((e=>{var t=A(),n=I(),r=j(),i=B(),a=de(),o=7973,s=t.getBCHDigit(o);function c(t,n,r){for(let i=1;i<=40;i++)if(n<=e.getCapacity(i,r,t))return i}function l(e,t){return i.getCharCountIndicator(e,t)+4}function u(e,t){let n=0;return e.forEach(function(e){let r=l(e.mode,t);n+=r+e.getBitsLength()}),n}function d(t,n){for(let r=1;r<=40;r++)if(u(t,r)<=e.getCapacity(r,n,i.MIXED))return r}e.from=function(e,t){return a.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,r,o){if(!a.isValid(e))throw Error(`Invalid QR Code version`);o===void 0&&(o=i.BYTE);let s=(t.getSymbolTotalCodewords(e)-n.getTotalCodewordsCount(e,r))*8;if(o===i.MIXED)return s;let c=s-l(o,e);switch(o){case i.NUMERIC:return Math.floor(c/10*3);case i.ALPHANUMERIC:return Math.floor(c/11*2);case i.KANJI:return Math.floor(c/13);case i.BYTE:default:return Math.floor(c/8)}},e.getBestVersionForData=function(e,t){let n,i=r.from(t,r.M);if(Array.isArray(e)){if(e.length>1)return d(e,i);if(e.length===0)return 1;n=e[0]}else n=e;return c(n.mode,n.getLength(),i)},e.getEncodedBits=function(e){if(!a.isValid(e)||e<7)throw Error(`Invalid QR Code version`);let n=e<<12;for(;t.getBCHDigit(n)-s>=0;)n^=o<<t.getBCHDigit(n)-s;return e<<12|n}})),V=t((e=>{var t=A(),n=1335,r=21522,i=t.getBCHDigit(n);e.getEncodedBits=function(e,a){let o=e.bit<<3|a,s=o<<10;for(;t.getBCHDigit(s)-i>=0;)s^=n<<t.getBCHDigit(s)-i;return(o<<10|s)^r}})),pe=t(((e,t)=>{var n=B();function r(e){this.mode=n.NUMERIC,this.data=e.toString()}r.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){let t,n,r;for(t=0;t+3<=this.data.length;t+=3)n=this.data.substr(t,3),r=parseInt(n,10),e.put(r,10);let i=this.data.length-t;i>0&&(n=this.data.substr(t),r=parseInt(n,10),e.put(r,i*3+1))},t.exports=r})),H=t(((e,t)=>{var n=B(),r=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`.split(``);function i(e){this.mode=n.ALPHANUMERIC,this.data=e}i.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let n=r.indexOf(this.data[t])*45;n+=r.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(r.indexOf(this.data[t]),6)},t.exports=i})),me=t(((e,t)=>{var n=B();function r(e){this.mode=n.BYTE,typeof e==`string`?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}r.getBitsLength=function(e){return e*8},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)},t.exports=r})),U=t(((e,t)=>{var n=B(),r=A();function i(e){this.mode=n.KANJI,this.data=e}i.getBitsLength=function(e){return e*13},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=r.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw Error(`Invalid SJIS character: `+this.data[t]+`
|
|
3
|
-
Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}},t.exports=i})),W=t(((e,t)=>{var n={single_source_shortest_paths:function(e,t,r){var i={},a={};a[t]=0;var o=n.PriorityQueue.make();o.push(t,0);for(var s,c,l,u,d,f,p,m,h;!o.empty();)for(l in s=o.pop(),c=s.value,u=s.cost,d=e[c]||{},d)d.hasOwnProperty(l)&&(f=d[l],p=u+f,m=a[l],h=a[l]===void 0,(h||m>p)&&(a[l]=p,o.push(l,p),i[l]=c));if(r!==void 0&&a[r]===void 0){var g=[`Could not find a path from `,t,` to `,r,`.`].join(``);throw Error(g)}return i},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],r=t;r;)n.push(r),e[r],r=e[r];return n.reverse(),n},find_path:function(e,t,r){var i=n.single_source_shortest_paths(e,t,r);return n.extract_shortest_path_from_predecessor_list(i,r)},PriorityQueue:{make:function(e){var t=n.PriorityQueue,r={},i;for(i in e||={},t)t.hasOwnProperty(i)&&(r[i]=t[i]);return r.queue=[],r.sorter=e.sorter||t.default_sorter,r},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var n={value:e,cost:t};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t!==void 0&&(t.exports=n)})),G=t((e=>{var t=B(),n=pe(),r=H(),i=me(),a=U(),o=z(),s=A(),c=W();function l(e){return unescape(encodeURIComponent(e)).length}function u(e,t,n){let r=[],i;for(;(i=e.exec(n))!==null;)r.push({data:i[0],index:i.index,mode:t,length:i[0].length});return r}function d(e){let n=u(o.NUMERIC,t.NUMERIC,e),r=u(o.ALPHANUMERIC,t.ALPHANUMERIC,e),i,a;return s.isKanjiModeEnabled()?(i=u(o.BYTE,t.BYTE,e),a=u(o.KANJI,t.KANJI,e)):(i=u(o.BYTE_KANJI,t.BYTE,e),a=[]),n.concat(r,i,a).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function f(e,o){switch(o){case t.NUMERIC:return n.getBitsLength(e);case t.ALPHANUMERIC:return r.getBitsLength(e);case t.KANJI:return a.getBitsLength(e);case t.BYTE:return i.getBitsLength(e)}}function p(e){return e.reduce(function(e,t){let n=e.length-1>=0?e[e.length-1]:null;return n&&n.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}function m(e){let n=[];for(let r=0;r<e.length;r++){let i=e[r];switch(i.mode){case t.NUMERIC:n.push([i,{data:i.data,mode:t.ALPHANUMERIC,length:i.length},{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.ALPHANUMERIC:n.push([i,{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.KANJI:n.push([i,{data:i.data,mode:t.BYTE,length:l(i.data)}]);break;case t.BYTE:n.push([{data:i.data,mode:t.BYTE,length:l(i.data)}])}}return n}function h(e,n){let r={},i={start:{}},a=[`start`];for(let o=0;o<e.length;o++){let s=e[o],c=[];for(let e=0;e<s.length;e++){let l=s[e],u=``+o+e;c.push(u),r[u]={node:l,lastCount:0},i[u]={};for(let e=0;e<a.length;e++){let o=a[e];r[o]&&r[o].node.mode===l.mode?(i[o][u]=f(r[o].lastCount+l.length,l.mode)-f(r[o].lastCount,l.mode),r[o].lastCount+=l.length):(r[o]&&(r[o].lastCount=l.length),i[o][u]=f(l.length,l.mode)+4+t.getCharCountIndicator(l.mode,n))}}a=c}for(let e=0;e<a.length;e++)i[a[e]].end=0;return{map:i,table:r}}function g(e,o){let c,l=t.getBestModeForData(e);if(c=t.from(o,l),c!==t.BYTE&&c.bit<l.bit)throw Error(`"`+e+`" cannot be encoded with mode `+t.toString(c)+`.
|
|
4
|
-
Suggested mode is: `+t.toString(l));switch(c===t.KANJI&&!s.isKanjiModeEnabled()&&(c=t.BYTE),c){case t.NUMERIC:return new n(e);case t.ALPHANUMERIC:return new r(e);case t.KANJI:return new a(e);case t.BYTE:return new i(e)}}e.fromArray=function(e){return e.reduce(function(e,t){return typeof t==`string`?e.push(g(t,null)):t.data&&e.push(g(t.data,t.mode)),e},[])},e.fromString=function(t,n){let r=h(m(d(t,s.isKanjiModeEnabled())),n),i=c.find_path(r.map,`start`,`end`),a=[];for(let e=1;e<i.length-1;e++)a.push(r.table[i[e]].node);return e.fromArray(p(a))},e.rawSplit=function(t){return e.fromArray(d(t,s.isKanjiModeEnabled()))}})),K=t((e=>{var t=A(),n=j(),r=M(),i=le(),a=N(),o=P(),s=F(),c=I(),l=ue(),u=fe(),d=V(),f=B(),p=G();function m(e,t){let n=e.size,r=o.getPositions(t);for(let t=0;t<r.length;t++){let i=r[t][0],a=r[t][1];for(let t=-1;t<=7;t++)if(!(i+t<=-1||n<=i+t))for(let r=-1;r<=7;r++)a+r<=-1||n<=a+r||(t>=0&&t<=6&&(r===0||r===6)||r>=0&&r<=6&&(t===0||t===6)||t>=2&&t<=4&&r>=2&&r<=4?e.set(i+t,a+r,!0,!0):e.set(i+t,a+r,!1,!0))}}function h(e){let t=e.size;for(let n=8;n<t-8;n++){let t=n%2==0;e.set(n,6,t,!0),e.set(6,n,t,!0)}}function g(e,t){let n=a.getPositions(t);for(let t=0;t<n.length;t++){let r=n[t][0],i=n[t][1];for(let t=-2;t<=2;t++)for(let n=-2;n<=2;n++)t===-2||t===2||n===-2||n===2||t===0&&n===0?e.set(r+t,i+n,!0,!0):e.set(r+t,i+n,!1,!0)}}function _(e,t){let n=e.size,r=u.getEncodedBits(t),i,a,o;for(let t=0;t<18;t++)i=Math.floor(t/3),a=t%3+n-8-3,o=(r>>t&1)==1,e.set(i,a,o,!0),e.set(a,i,o,!0)}function v(e,t,n){let r=e.size,i=d.getEncodedBits(t,n),a,o;for(a=0;a<15;a++)o=(i>>a&1)==1,a<6?e.set(a,8,o,!0):a<8?e.set(a+1,8,o,!0):e.set(r-15+a,8,o,!0),a<8?e.set(8,r-a-1,o,!0):a<9?e.set(8,15-a-1+1,o,!0):e.set(8,15-a-1,o,!0);e.set(r-8,8,1,!0)}function ee(e,t){let n=e.size,r=-1,i=n-1,a=7,o=0;for(let s=n-1;s>0;s-=2)for(s===6&&s--;;){for(let n=0;n<2;n++)if(!e.isReserved(i,s-n)){let r=!1;o<t.length&&(r=(t[o]>>>a&1)==1),e.set(i,s-n,r),a--,a===-1&&(o++,a=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}function y(e,n,i){let a=new r;i.forEach(function(t){a.put(t.mode.bit,4),a.put(t.getLength(),f.getCharCountIndicator(t.mode,e)),t.write(a)});let o=(t.getSymbolTotalCodewords(e)-c.getTotalCodewordsCount(e,n))*8;for(a.getLengthInBits()+4<=o&&a.put(0,4);a.getLengthInBits()%8!=0;)a.putBit(0);let s=(o-a.getLengthInBits())/8;for(let e=0;e<s;e++)a.put(e%2?17:236,8);return b(a,e,n)}function b(e,n,r){let i=t.getSymbolTotalCodewords(n),a=i-c.getTotalCodewordsCount(n,r),o=c.getBlocksCount(n,r),s=o-i%o,u=Math.floor(i/o),d=Math.floor(a/o),f=d+1,p=u-d,m=new l(p),h=0,g=Array(o),_=Array(o),v=0,ee=new Uint8Array(e.buffer);for(let e=0;e<o;e++){let t=e<s?d:f;g[e]=ee.slice(h,h+t),_[e]=m.encode(g[e]),h+=t,v=Math.max(v,t)}let y=new Uint8Array(i),b=0,x,S;for(x=0;x<v;x++)for(S=0;S<o;S++)x<g[S].length&&(y[b++]=g[S][x]);for(x=0;x<p;x++)for(S=0;S<o;S++)y[b++]=_[S][x];return y}function x(e,n,r,a){let o;if(Array.isArray(e))o=p.fromArray(e);else if(typeof e==`string`){let t=n;if(!t){let n=p.rawSplit(e);t=u.getBestVersionForData(n,r)}o=p.fromString(e,t||40)}else throw Error(`Invalid data`);let c=u.getBestVersionForData(o,r);if(!c)throw Error(`The amount of data is too big to be stored in a QR Code`);if(!n)n=c;else if(n<c)throw Error(`
|
|
5
|
-
The chosen QR Code version cannot contain this amount of data.
|
|
6
|
-
Minimum version required to store current data is: `+c+`.
|
|
7
|
-
`);let l=y(n,r,o),d=new i(t.getSymbolSize(n));return m(d,n),h(d),g(d,n),v(d,r,0),n>=7&&_(d,n),ee(d,l),isNaN(a)&&(a=s.getBestMask(d,v.bind(null,d,r))),s.applyMask(a,d),v(d,r,a),{modules:d,version:n,errorCorrectionLevel:r,maskPattern:a,segments:o}}e.create=function(e,r){if(e===void 0||e===``)throw Error(`No input text`);let i=n.M,a,o;return r!==void 0&&(i=n.from(r.errorCorrectionLevel,n.M),a=u.from(r.version),o=s.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),x(e,a,i,o)}})),q=t((e=>{function t(e){if(typeof e==`number`&&(e=e.toString()),typeof e!=`string`)throw Error(`Color should be defined as hex string`);let t=e.slice().replace(`#`,``).split(``);if(t.length<3||t.length===5||t.length>8)throw Error(`Invalid hex color: `+e);(t.length===3||t.length===4)&&(t=Array.prototype.concat.apply([],t.map(function(e){return[e,e]}))),t.length===6&&t.push(`F`,`F`);let n=parseInt(t.join(``),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:n&255,hex:`#`+t.slice(0,6).join(``)}}e.getOptions=function(e){e||={},e.color||={};let n=e.margin===void 0||e.margin===null||e.margin<0?4:e.margin,r=e.width&&e.width>=21?e.width:void 0,i=e.scale||4;return{width:r,scale:r?4:i,margin:n,color:{dark:t(e.color.dark||`#000000ff`),light:t(e.color.light||`#ffffffff`)},type:e.type,rendererOpts:e.rendererOpts||{}}},e.getScale=function(e,t){return t.width&&t.width>=e+t.margin*2?t.width/(e+t.margin*2):t.scale},e.getImageWidth=function(t,n){let r=e.getScale(t,n);return Math.floor((t+n.margin*2)*r)},e.qrToImageData=function(t,n,r){let i=n.modules.size,a=n.modules.data,o=e.getScale(i,r),s=Math.floor((i+r.margin*2)*o),c=r.margin*o,l=[r.color.light,r.color.dark];for(let e=0;e<s;e++)for(let n=0;n<s;n++){let u=(e*s+n)*4,d=r.color.light;if(e>=c&&n>=c&&e<s-c&&n<s-c){let t=Math.floor((e-c)/o),r=Math.floor((n-c)/o);d=l[+!!a[t*i+r]]}t[u++]=d.r,t[u++]=d.g,t[u++]=d.b,t[u]=d.a}}})),he=t((e=>{var t=q();function n(e,t,n){e.clearRect(0,0,t.width,t.height),t.style||={},t.height=n,t.width=n,t.style.height=n+`px`,t.style.width=n+`px`}function r(){try{return document.createElement(`canvas`)}catch{throw Error(`You need to specify a canvas element`)}}e.render=function(e,i,a){let o=a,s=i;o===void 0&&(!i||!i.getContext)&&(o=i,i=void 0),i||(s=r()),o=t.getOptions(o);let c=t.getImageWidth(e.modules.size,o),l=s.getContext(`2d`),u=l.createImageData(c,c);return t.qrToImageData(u.data,e,o),n(l,s,c),l.putImageData(u,0,0),s},e.renderToDataURL=function(t,n,r){let i=r;i===void 0&&(!n||!n.getContext)&&(i=n,n=void 0),i||={};let a=e.render(t,n,i),o=i.type||`image/png`,s=i.rendererOpts||{};return a.toDataURL(o,s.quality)}})),J=t((e=>{var t=q();function n(e,t){let n=e.a/255,r=t+`="`+e.hex+`"`;return n<1?r+` `+t+`-opacity="`+n.toFixed(2).slice(1)+`"`:r}function r(e,t,n){let r=e+t;return n!==void 0&&(r+=` `+n),r}function i(e,t,n){let i=``,a=0,o=!1,s=0;for(let c=0;c<e.length;c++){let l=Math.floor(c%t),u=Math.floor(c/t);!l&&!o&&(o=!0),e[c]?(s++,c>0&&l>0&&e[c-1]||(i+=o?r(`M`,l+n,.5+u+n):r(`m`,a,0),a=0,o=!1),l+1<t&&e[c+1]||(i+=r(`h`,s),s=0)):a++}return i}e.render=function(e,r,a){let o=t.getOptions(r),s=e.modules.size,c=e.modules.data,l=s+o.margin*2,u=o.color.light.a?`<path `+n(o.color.light,`fill`)+` d="M0 0h`+l+`v`+l+`H0z"/>`:``,d=`<path `+n(o.color.dark,`stroke`)+` d="`+i(c,s,o.margin)+`"/>`,f=`viewBox="0 0 `+l+` `+l+`"`,p=`<svg xmlns="http://www.w3.org/2000/svg" `+(o.width?`width="`+o.width+`" height="`+o.width+`" `:``)+f+` shape-rendering="crispEdges">`+u+d+`</svg>
|
|
8
|
-
`;return typeof a==`function`&&a(null,p),p}})),Y=e(t((e=>{var t=ce(),n=K(),r=he(),i=J();function a(e,r,i,a,o){let s=[].slice.call(arguments,1),c=s.length,l=typeof s[c-1]==`function`;if(!l&&!t())throw Error(`Callback required as last argument`);if(l){if(c<2)throw Error(`Too few arguments provided`);c===2?(o=i,i=r,r=a=void 0):c===3&&(r.getContext&&o===void 0?(o=a,a=void 0):(o=a,a=i,i=r,r=void 0))}else{if(c<1)throw Error(`Too few arguments provided`);return c===1?(i=r,r=a=void 0):c===2&&!r.getContext&&(a=i,i=r,r=void 0),new Promise(function(t,o){try{t(e(n.create(i,a),r,a))}catch(e){o(e)}})}try{let t=n.create(i,a);o(null,e(t,r,a))}catch(e){o(e)}}e.create=n.create,e.toCanvas=a.bind(null,r.render),e.toDataURL=a.bind(null,r.renderToDataURL),e.toString=a.bind(null,function(e,t,n){return i.render(e,n)})}))(),1),ge=[{id:`whisper-large-v3-turbo`,name:`Whisper Large V3 Turbo (Groq)`,provider:`groq`},{id:`whisper-large-v3`,name:`Whisper Large V3 (Groq)`,provider:`groq`},{id:`distil-whisper-large-v3-en`,name:`Distil Whisper V3 EN (Groq)`,provider:`groq`},{id:`whisper-1`,name:`Whisper 1 (OpenAI)`,provider:`openai`}],_e=[{group:`ElevenLabs`,provider:`elevenlabs`,models:[{id:`eleven_flash_v2_5`,name:`Flash v2.5`},{id:`eleven_turbo_v2_5`,name:`Turbo v2.5`},{id:`eleven_multilingual_v2`,name:`Multilingual v2`},{id:`eleven_v3`,name:`V3`}]},{group:`OpenAI`,provider:`openai`,models:[{id:`tts-1`,name:`TTS-1`},{id:`tts-1-hd`,name:`TTS-1 HD`},{id:`gpt-4o-mini-tts`,name:`GPT-4o Mini TTS`}]},{group:`Google Gemini`,provider:`gemini`,models:[{id:`gemini-2.5-flash-preview-tts`,name:`Gemini 2.5 Flash TTS`},{id:`gemini-2.5-pro-preview-tts`,name:`Gemini 2.5 Pro TTS`}]},{group:`Qwen`,provider:`qwen`,models:[{id:`qwen3-tts-instruct-flash`,name:`Qwen3 TTS Instruct Flash`},{id:`qwen3-tts-flash`,name:`Qwen3 TTS Flash`},{id:`qwen-tts`,name:`Qwen TTS`}]},{group:`Piper (Local)`,provider:`piper`,models:[{id:`piper`,name:`Piper TTS (es_MX Cortana)`}]}];function ve(e){return e.startsWith(`eleven`)?`elevenlabs`:e.startsWith(`tts-`)||e.startsWith(`gpt-`)?`openai`:e.startsWith(`gemini`)?`gemini`:e.startsWith(`qwen`)?`qwen`:e===`piper`?`piper`:null}var ye=[{id:`gemini`,name:`Google Gemini`,provider:`gemini`},{id:`openai`,name:`OpenAI`,provider:`openai`},{id:`anthropic`,name:`Anthropic Claude`,provider:`anthropic`}];function be({data:e}){let t=(0,D.useRef)(null);return(0,D.useEffect)(()=>{!e||!t.current||Y.toCanvas(t.current,e,{width:220,margin:2,color:{dark:`#000000`,light:`#ffffff`}}).catch(console.error)},[e]),(0,O.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[(0,O.jsx)(`div`,{className:`rounded-xl overflow-hidden border-4 border-white shadow-lg`,children:(0,O.jsx)(`canvas`,{ref:t})}),(0,O.jsx)(`p`,{className:`text-xs text-white/40 text-center`,children:`Abre WhatsApp → Ajustes → Dispositivos vinculados → Vincular dispositivo`})]})}function xe({channel:e,isOpen:t,onClose:n,onSave:r}){let i=x(),{createChannel:b,reconnectChannel:S,fetchChannels:C}=re(),{configuredVoiceProviders:k,fetchConfiguredVoiceProviders:ce}=ne(),[A,j]=(0,D.useState)(e?`settings`:`type`),[M,le]=(0,D.useState)(`telegram`),[N,P]=(0,D.useState)(``),[F,I]=(0,D.useState)(``),[L,R]=(0,D.useState)(``),[ue,de]=(0,D.useState)(!1),[z,B]=(0,D.useState)(!1),[fe,V]=(0,D.useState)(null),[pe,H]=(0,D.useState)(null),[me,U]=(0,D.useState)(!1),[W,G]=(0,D.useState)(null),[K,q]=(0,D.useState)(!1),he=(0,D.useRef)(null),[J,Y]=(0,D.useState)({}),[xe,Se]=(0,D.useState)(!1),[Ce,we]=(0,D.useState)([]),[Te,Ee]=(0,D.useState)(!1),[De,Oe]=(0,D.useState)(!1),[ke,Ae]=(0,D.useState)(``),[je,Me]=(0,D.useState)(!1),[Ne,Pe]=(0,D.useState)(!0),[Fe,Ie]=(0,D.useState)(!1),[Le,Re]=(0,D.useState)(`open`),[X,ze]=(0,D.useState)([]),[Be,Ve]=(0,D.useState)(``),[He,Ue]=(0,D.useState)(5),[We,Ge]=(0,D.useState)(1e3),[Ke,qe]=(0,D.useState)(!1),Je=e&&e.status!==`connected`,Z=e&&e.isConfigured===!1;(0,D.useEffect)(()=>{t?e?(j(Je?`reconnect`:`settings`),le(e.type),P(``),I(``),R(``),V(e.id),H(null),U(!1),G(null),Y(e),Oe(!1),Ae(``),Me(!1)):(j(`type`),le(`telegram`),P(``),I(``),R(``),V(null),H(null),U(!1),G(null)):Q()},[t,e]),(0,D.useEffect)(()=>{ce()},[ce]),(0,D.useEffect)(()=>{if(!t||!e||e.type!==`whatsapp`){qe(!1);return}let n=!1;return ie(`/api/channels/whatsapp/${e.id}/details`,{showError:!1}).then(e=>{n||(Pe(e.selfMessagesOnly??!0),Ie(e.acceptGroups??!1),Re(e.dmPolicy??`open`),ze(e.allowFrom??[]),Ue(e.reconnectMaxAttempts??5),Ge(e.reconnectBaseDelayMs??1e3),qe(!0))}).catch(()=>qe(!1)),()=>{n=!0}},[t,e]),(0,D.useEffect)(()=>{let e=J.tts_provider?ve(J.tts_provider):null;if(!e){we([]);return}Ee(!0),ie(`/api/voice/${e}/voices`,{showError:!1}).then(e=>we(e.voices||[])).catch(()=>we([])).finally(()=>Ee(!1))},[J.tts_provider]);let Q=(0,D.useCallback)(()=>{he.current&&=(clearInterval(he.current),null)},[]),Ye=(0,D.useCallback)((e,t)=>{Q(),he.current=setInterval(async()=>{try{let n=await ie(`/api/channels/${e}/${t}/status`,{showError:!1});n.status===`qr`&&n.qrCode?(H(n.qrCode),U(!1),j(`qr`)):n.status===`connected`?(Q(),await C(),j(`success`)):n.status===`error`?(Q(),G(`Error de conexión. Intenta de nuevo.`),j(`credentials`)):(n.status===`disconnected`||n.status===`not_found`)&&U(!0)}catch{}},2e3)},[Q,C]),Xe=async()=>{if(e){q(!0),G(null);try{let t={};M===`telegram`&&N.trim()&&(t.botToken=N),M===`discord`&&(N.trim()&&(t.botToken=N),F.trim()&&(t.applicationId=F)),await S(e.id,Object.keys(t).length>0?t:void 0),j(`connecting`),Ye(M,e.id)}catch(e){G(e.message||`Error al reconectar`)}finally{q(!1)}}},Ze=async()=>{q(!0),G(null);try{let e={};M===`telegram`&&(e.botToken=N),M===`discord`&&(e.botToken=N,e.applicationId=F),M===`slack`&&(e.botToken=N,e.signingSecret=L);let{id:t}=await b(M,e);V(t),M===`whatsapp`?(j(`connecting`),Ye(`whatsapp`,t)):(j(`connecting`),Ye(M,t))}catch(e){G(e.message||`Error al conectar`)}finally{q(!1)}},Qe=async()=>{if(e?.id){Se(!0);try{if(ke.trim().length>10&&(e.type===`telegram`||e.type===`discord`)){let t={botToken:ke.trim()};await S(e.id,t)}await r(e.id,J),e.type===`whatsapp`&&await ie(`/api/channels/whatsapp/${e.id}/config`,{method:`PUT`,body:{selfMessagesOnly:Ne,acceptGroups:Fe,dmPolicy:Le,allowFrom:X,reconnectMaxAttempts:He,reconnectBaseDelayMs:We}}),n()}catch(e){console.error(`Save failed`,e)}finally{Se(!1)}}},$=()=>{Q(),n()},$e=M===`whatsapp`||M===`webchat`||M===`telegram`&&N.trim().length>10||M===`discord`&&N.trim().length>10&&F.trim().length>0||M===`slack`&&N.trim().length>10&&L.trim().length>10,et=()=>A===`reconnect`?(0,O.jsxs)(`div`,{className:`space-y-4 py-2`,children:[W&&(0,O.jsxs)(oe,{variant:`destructive`,className:`bg-red-500/10 border-red-500/30`,children:[(0,O.jsx)(p,{className:`h-4 w-4`}),(0,O.jsx)(ae,{children:W})]}),(0,O.jsxs)(`div`,{className:`p-4 rounded-xl ${Z?`bg-blue-500/10 border border-blue-500/20`:`bg-amber-500/10 border border-amber-500/20`}`,children:[(0,O.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-widest mb-1 ${Z?`text-blue-300`:`text-amber-300`}`,children:Z?`Canal no configurado`:`Canal desconectado`}),(0,O.jsx)(`p`,{className:`text-xs ${Z?`text-blue-200/70`:`text-amber-200/70`}`,children:Z?M===`whatsapp`?`Haz clic en Conectar para generar el código QR.`:M===`webchat`?`Haz clic en Conectar para activar el canal web.`:`Ingresa las credenciales para activar este canal.`:M===`whatsapp`?`Haz clic en Reconectar para generar un nuevo código QR.`:M===`webchat`?`Haz clic en Reconectar para activar el canal.`:`Puedes reconectar con las credenciales existentes o ingresar un nuevo token.`})]}),(M===`telegram`||M===`discord`)&&(0,O.jsxs)(`div`,{className:`space-y-3`,children:[(0,O.jsx)(`p`,{className:`text-[10px] text-white/30 uppercase tracking-widest`,children:Z?`Credenciales`:`Actualizar credenciales (opcional)`}),(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(E,{className:`text-xs text-white/50`,children:`Bot Token`}),(0,O.jsxs)(`div`,{className:`relative`,children:[(0,O.jsx)(T,{type:z?`text`:`password`,value:N,onChange:e=>P(e.target.value),placeholder:Z?M===`telegram`?`123456789:AAF...`:`MTA5NDY...`:`Dejar vacío para usar el token actual`,className:`bg-white/5 border-white/10 pr-10 font-mono text-sm`}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>B(e=>!e),className:`absolute right-2 top-1/2 -translate-y-1/2 text-white/40 hover:text-white/70`,children:z?(0,O.jsx)(h,{className:`h-4 w-4`}):(0,O.jsx)(g,{className:`h-4 w-4`})})]})]}),M===`discord`&&(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(E,{className:`text-xs text-white/50`,children:`Application ID`}),(0,O.jsx)(T,{value:F,onChange:e=>I(e.target.value),placeholder:Z?`123456789012345678`:`Dejar vacío para usar el actual`,className:`bg-white/5 border-white/10 font-mono text-sm`})]})]})]}):A===`type`?(0,O.jsxs)(`div`,{className:`space-y-4 py-2`,children:[(0,O.jsx)(`p`,{className:`text-sm text-white/50`,children:`Selecciona el tipo de canal a conectar:`}),(0,O.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:[{id:`telegram`,label:`Telegram`,icon:`✈️`},{id:`whatsapp`,label:`WhatsApp`,icon:`💬`},{id:`discord`,label:`Discord`,icon:`🎮`},{id:`slack`,label:`Slack`,icon:`💼`},{id:`webchat`,label:`WebChat`,icon:`🌐`}].map(e=>(0,O.jsxs)(`button`,{onClick:()=>le(e.id),className:`p-4 rounded-xl border text-left transition-all duration-200 ${M===e.id?`border-blue-500 bg-blue-500/10 text-white`:`border-white/10 bg-white/5 text-white/50 hover:border-white/20 hover:text-white/70`}`,children:[(0,O.jsx)(`div`,{className:`text-2xl mb-1`,children:e.icon}),(0,O.jsx)(`div`,{className:`text-sm font-semibold`,children:e.label})]},e.id))})]}):A===`credentials`?(0,O.jsxs)(`div`,{className:`space-y-4 py-2`,children:[W&&(0,O.jsxs)(oe,{variant:`destructive`,className:`bg-red-500/10 border-red-500/30`,children:[(0,O.jsx)(p,{className:`h-4 w-4`}),(0,O.jsx)(ae,{children:W})]}),M===`whatsapp`&&(0,O.jsx)(`div`,{className:`p-4 rounded-xl bg-emerald-500/10 border border-emerald-500/20 text-sm text-emerald-300`,children:`WhatsApp no requiere token. Haz clic en "Conectar" y escanea el código QR con tu teléfono.`}),M===`webchat`&&(0,O.jsx)(`div`,{className:`p-4 rounded-xl bg-blue-500/10 border border-blue-500/20 text-sm text-blue-300`,children:`WebChat no requiere configuración. Haz clic en "Conectar" para activarlo.`}),(M===`telegram`||M===`discord`||M===`slack`)&&(0,O.jsxs)(`div`,{className:`space-y-3`,children:[(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(E,{className:`text-xs text-white/50 uppercase tracking-widest`,children:`Bot Token`}),(0,O.jsxs)(`div`,{className:`relative`,children:[(0,O.jsx)(T,{type:z?`text`:`password`,value:N,onChange:e=>P(e.target.value),placeholder:M===`telegram`?`123456789:AAF...`:M===`slack`?`xoxb-...`:`MTA5NDY...`,className:`bg-white/5 border-white/10 pr-10 font-mono text-sm`}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>B(e=>!e),className:`absolute right-2 top-1/2 -translate-y-1/2 text-white/40 hover:text-white/70`,children:z?(0,O.jsx)(h,{className:`h-4 w-4`}):(0,O.jsx)(g,{className:`h-4 w-4`})})]})]}),M===`discord`&&(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(E,{className:`text-xs text-white/50 uppercase tracking-widest`,children:`Application ID`}),(0,O.jsx)(T,{value:F,onChange:e=>I(e.target.value),placeholder:`123456789012345678`,className:`bg-white/5 border-white/10 font-mono text-sm`})]}),M===`slack`&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(E,{className:`text-xs text-white/50 uppercase tracking-widest`,children:`Signing Secret`}),(0,O.jsxs)(`div`,{className:`relative`,children:[(0,O.jsx)(T,{type:ue?`text`:`password`,value:L,onChange:e=>R(e.target.value),placeholder:`a1b2c3d4e5f6...`,className:`bg-white/5 border-white/10 pr-10 font-mono text-sm`}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>de(e=>!e),className:`absolute right-2 top-1/2 -translate-y-1/2 text-white/40 hover:text-white/70`,children:ue?(0,O.jsx)(h,{className:`h-4 w-4`}):(0,O.jsx)(g,{className:`h-4 w-4`})})]})]}),(0,O.jsxs)(`div`,{className:`p-3 rounded-lg bg-amber-500/10 border border-amber-500/20 text-xs text-amber-200/80`,children:[`Slack requiere una URL pública para webhooks. Usa ngrok, cloudflared o Tailscale y configura la Request URL en tu Slack App: `,(0,O.jsx)(`span`,{className:`font-mono`,children:`https://tu-url/slack/events`})]})]})]})]}):A===`connecting`?(0,O.jsxs)(`div`,{className:`flex flex-col items-center gap-4 py-8`,children:[(0,O.jsx)(`div`,{className:`relative`,children:(0,O.jsx)(`div`,{className:`h-16 w-16 rounded-full border-2 border-white/10 flex items-center justify-center`,children:(0,O.jsx)(_,{className:`h-8 w-8 animate-spin text-blue-400`})})}),(0,O.jsx)(`p`,{className:`text-sm text-white/60 text-center`,children:M===`whatsapp`?`Iniciando WhatsApp... Generando código QR`:`Conectando canal...`}),(0,O.jsx)(`p`,{className:`text-xs text-white/30`,children:`Esto puede tardar unos segundos`})]}):A===`qr`?(0,O.jsxs)(`div`,{className:`flex flex-col items-center gap-4 py-4`,children:[(0,O.jsxs)(`div`,{className:`relative`,children:[pe?(0,O.jsx)(be,{data:pe}):(0,O.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-6`,children:[(0,O.jsx)(se,{className:`h-16 w-16 text-white/20`}),(0,O.jsx)(`p`,{className:`text-xs text-white/40`,children:`Generando QR...`})]}),me&&(0,O.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center rounded-xl bg-zinc-950/80 backdrop-blur-sm gap-2`,children:[(0,O.jsx)(_,{className:`h-8 w-8 animate-spin text-amber-400`}),(0,O.jsx)(`p`,{className:`text-xs text-amber-300 font-medium`,children:`QR expirado, renovando...`})]})]}),(0,O.jsx)(`div`,{className:`flex items-center gap-2 text-xs text-white/30`,children:me?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full bg-amber-400 animate-pulse`}),`Renovando código QR...`]}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full bg-emerald-400 animate-pulse`}),`Esperando escaneo...`]})}),(0,O.jsx)(`p`,{className:`text-[11px] text-white/30 text-center`,children:`Abre WhatsApp → Ajustes → Dispositivos vinculados → Vincular dispositivo`})]}):A===`success`?(0,O.jsxs)(`div`,{className:`flex flex-col items-center gap-4 py-8`,children:[(0,O.jsx)(`div`,{className:`h-16 w-16 rounded-full bg-emerald-500/10 border border-emerald-500/30 flex items-center justify-center`,children:(0,O.jsx)(m,{className:`h-8 w-8 text-emerald-400`})}),(0,O.jsxs)(`div`,{className:`text-center`,children:[(0,O.jsx)(`p`,{className:`text-sm font-semibold text-white`,children:`Canal conectado`}),(0,O.jsxs)(`p`,{className:`text-xs text-white/40 mt-1`,children:[M.charAt(0).toUpperCase()+M.slice(1),` está activo y listo para recibir mensajes.`]})]})]}):null,tt=()=>(0,O.jsxs)(`div`,{className:`grid gap-4 py-4`,children:[e?.type===`whatsapp`&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:`space-y-2 pb-2 border-b border-white/10`,children:[(0,O.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,O.jsx)(E,{className:`text-xs text-white/50 uppercase tracking-widest`,children:`Número Vinculado`})}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg bg-white/5 border border-white/10`,children:[(0,O.jsx)(`span`,{className:`font-mono text-sm text-white/70`,children:e.accountId?`+${e.accountId}`:`No conectado`}),(0,O.jsx)(`span`,{className:`text-[10px] text-white/40 ml-auto`,children:e.status===`connected`?`✓`:`sin conexión`})]})]}),(0,O.jsxs)(`div`,{className:`space-y-3 pb-2 border-b border-white/10`,children:[(0,O.jsx)(`p`,{className:`text-xs font-bold uppercase tracking-widest text-green-400`,children:`Recepción de Mensajes`}),(0,O.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,O.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,O.jsx)(E,{className:`text-xs text-white/60`,children:`Solo mensajes propios`}),(0,O.jsx)(`p`,{className:`text-[10px] text-white/30`,children:`Solo se procesan los mensajes enviados por la propia cuenta`})]}),(0,O.jsx)(f,{checked:Ne,onCheckedChange:Pe})]}),(0,O.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,O.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,O.jsx)(E,{className:`text-xs text-white/60`,children:`Aceptar mensajes de grupo`}),(0,O.jsx)(`p`,{className:`text-[10px] text-white/30`,children:`Procesar mensajes provenientes de conversaciones grupales`})]}),(0,O.jsx)(f,{checked:Fe,onCheckedChange:Ie})]}),!Ne&&(0,O.jsxs)(`div`,{className:`space-y-2 animate-in fade-in slide-in-from-top-1 duration-200`,children:[(0,O.jsx)(E,{className:`text-xs text-white/60 uppercase tracking-widest`,children:`Política de DM (WhatsApp)`}),(0,O.jsxs)(c,{value:Le,onValueChange:e=>Re(e),children:[(0,O.jsx)(d,{className:`bg-white/5 border-white/10`,children:(0,O.jsx)(o,{})}),(0,O.jsxs)(u,{children:[(0,O.jsx)(a,{value:`open`,children:(0,O.jsxs)(`div`,{className:`flex flex-col`,children:[(0,O.jsx)(`span`,{children:`Abierto`}),(0,O.jsx)(`span`,{className:`text-[10px] text-white/30`,children:`Cualquiera puede iniciar chat`})]})}),(0,O.jsx)(a,{value:`allowlist`,children:(0,O.jsxs)(`div`,{className:`flex flex-col`,children:[(0,O.jsx)(`span`,{children:`Lista permitida`}),(0,O.jsx)(`span`,{className:`text-[10px] text-white/30`,children:`Solo números autorizados`})]})}),(0,O.jsx)(a,{value:`pairing`,children:(0,O.jsxs)(`div`,{className:`flex flex-col`,children:[(0,O.jsx)(`span`,{children:`Emparejamiento`}),(0,O.jsx)(`span`,{className:`text-[10px] text-white/30`,children:`Requiere vinculación manual`})]})})]})]}),(Le===`allowlist`||Le===`pairing`)&&(0,O.jsxs)(`div`,{className:`space-y-2 animate-in fade-in slide-in-from-top-1 duration-200`,children:[(0,O.jsx)(E,{className:`text-xs text-white/60 uppercase tracking-widest`,children:`Números permitidos`}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(T,{value:Be,onChange:e=>Ve(e.target.value),placeholder:`Ej. +521234567890`,className:`bg-white/5 border-white/10 font-mono text-sm`,onKeyDown:e=>{if(e.key===`Enter`){e.preventDefault();let t=Be.trim();t&&!X.includes(t)&&(ze(e=>[...e,t]),Ve(``))}}}),(0,O.jsx)(w,{type:`button`,variant:`ghost`,size:`sm`,disabled:!Be.trim(),onClick:()=>{let e=Be.trim();e&&!X.includes(e)&&(ze(t=>[...t,e]),Ve(``))},className:`h-9 w-9 p-0 shrink-0 hover:bg-blue-500/10`,children:(0,O.jsx)(v,{className:`h-4 w-4`})})]}),X.length>0?(0,O.jsx)(`div`,{className:`space-y-1.5`,children:X.map(e=>(0,O.jsxs)(`div`,{className:`flex items-center justify-between h-9 px-3 rounded-lg bg-white/5 border border-white/10`,children:[(0,O.jsx)(`span`,{className:`text-sm font-mono font-medium`,children:e}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>ze(t=>t.filter(t=>t!==e)),className:`text-white/30 hover:text-red-400 transition-colors`,children:(0,O.jsx)(te,{className:`h-3.5 w-3.5`})})]},e))}):(0,O.jsx)(`p`,{className:`text-[10px] text-white/30 italic`,children:`No hay números en la lista permitida`})]})]})]}),(0,O.jsxs)(`div`,{className:`space-y-3 pb-2 border-b border-white/10`,children:[(0,O.jsx)(`p`,{className:`text-xs font-bold uppercase tracking-widest text-amber-400`,children:`Reconexión`}),(0,O.jsxs)(`div`,{className:`grid grid-cols-4 items-center gap-4`,children:[(0,O.jsx)(E,{className:`text-right text-xs`,children:`Intentos máx.`}),(0,O.jsx)(T,{type:`number`,min:0,value:He,onChange:e=>Ue(parseInt(e.target.value,10)||0),className:`col-span-3 bg-white/5 border-white/10 text-sm`})]}),(0,O.jsxs)(`div`,{className:`grid grid-cols-4 items-center gap-4`,children:[(0,O.jsx)(E,{className:`text-right text-xs`,children:`Retardo base (ms)`}),(0,O.jsx)(T,{type:`number`,min:0,value:We,onChange:e=>Ge(parseInt(e.target.value,10)||0),className:`col-span-3 bg-white/5 border-white/10 text-sm`})]}),(0,O.jsx)(`p`,{className:`text-[10px] text-white/30`,children:`Backoff exponencial usando el retardo base configurado.`})]})]}),(e?.type===`telegram`||e?.type===`discord`)&&(0,O.jsxs)(`div`,{className:`space-y-2 pb-2 border-b border-white/10`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,O.jsx)(E,{className:`text-xs text-white/50 uppercase tracking-widest`,children:`Bot Token`}),!De&&(0,O.jsx)(`button`,{type:`button`,onClick:()=>Oe(!0),className:`text-[11px] text-blue-400 hover:text-blue-300 transition-colors`,children:`Cambiar token`})]}),De?(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsxs)(`div`,{className:`relative`,children:[(0,O.jsx)(T,{type:je?`text`:`password`,value:ke,onChange:e=>Ae(e.target.value),placeholder:e?.type===`telegram`?`123456789:AAF...`:`MTA5NDY...`,className:`bg-white/5 border-white/10 pr-10 font-mono text-sm`,autoFocus:!0}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>Me(e=>!e),className:`absolute right-2 top-1/2 -translate-y-1/2 text-white/40 hover:text-white/70`,children:je?(0,O.jsx)(h,{className:`h-4 w-4`}):(0,O.jsx)(g,{className:`h-4 w-4`})})]}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:()=>{Oe(!1),Ae(``),Me(!1)},className:`text-[11px] text-white/40 hover:text-white/60 transition-colors`,children:`Cancelar`}),ke.trim().length>0&&(0,O.jsx)(`span`,{className:`text-[11px] text-amber-400/70`,children:`Se aplicará al guardar`})]})]}):(0,O.jsx)(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg bg-white/5 border border-white/10`,children:(0,O.jsx)(`span`,{className:`font-mono text-sm text-white/30 tracking-widest select-none`,children:`••••••••••••••••••••••••`})})]}),(0,O.jsxs)(`div`,{className:`grid grid-cols-4 items-center gap-4`,children:[(0,O.jsx)(E,{className:`text-right text-xs`,children:`Voz (STT)`}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 col-span-3`,children:[(0,O.jsx)(f,{checked:J.voice_enabled,onCheckedChange:e=>Y(t=>({...t,voice_enabled:e}))}),(0,O.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Procesar notas de voz`})]})]}),(0,O.jsxs)(`div`,{className:`grid grid-cols-4 items-center gap-4`,children:[(0,O.jsx)(E,{className:`text-right text-xs`,children:`TTS`}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 col-span-3`,children:[(0,O.jsx)(f,{checked:J.tts_enabled,onCheckedChange:e=>Y(t=>({...t,tts_enabled:e}))}),(0,O.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Responder por voz`})]})]}),J.voice_enabled&&(0,O.jsxs)(`div`,{className:`grid grid-cols-4 items-center gap-4`,children:[(0,O.jsx)(E,{className:`text-right text-xs`,children:`Modelo STT`}),(0,O.jsxs)(c,{value:J.stt_provider||``,onValueChange:e=>Y(t=>({...t,stt_provider:e})),children:[(0,O.jsx)(d,{className:`col-span-3`,children:(0,O.jsx)(o,{placeholder:`Selecciona modelo STT`})}),(0,O.jsx)(u,{children:ge.filter(e=>k[e.provider]).map(e=>(0,O.jsx)(a,{value:e.id,children:e.name},e.id))})]})]}),J.tts_enabled&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:`grid grid-cols-4 items-center gap-4`,children:[(0,O.jsx)(E,{className:`text-right text-xs`,children:`Modelo TTS`}),(0,O.jsxs)(c,{value:J.tts_provider||``,onValueChange:e=>Y(t=>({...t,tts_provider:e,tts_voice_id:``})),children:[(0,O.jsx)(d,{className:`col-span-3`,children:(0,O.jsx)(o,{placeholder:`Selecciona modelo TTS`})}),(0,O.jsx)(u,{children:_e.filter(e=>k[e.provider]).map(e=>(0,O.jsxs)(s,{children:[(0,O.jsx)(l,{children:e.group}),e.models.map(e=>(0,O.jsx)(a,{value:e.id,children:e.name},e.id))]},e.group))})]})]}),J.tts_provider&&(0,O.jsxs)(`div`,{className:`grid grid-cols-4 items-center gap-4`,children:[(0,O.jsx)(E,{className:`text-right text-xs`,children:`Voz`}),(0,O.jsxs)(c,{value:J.tts_voice_id||``,onValueChange:e=>Y(t=>({...t,tts_voice_id:e})),disabled:Te||Ce.length===0,children:[(0,O.jsx)(d,{className:`col-span-3`,children:(0,O.jsx)(o,{placeholder:Te?`Cargando...`:`Selecciona una voz`})}),(0,O.jsx)(u,{children:Ce.map(e=>(0,O.jsx)(a,{value:e.id,children:e.name},e.id))})]})]}),!k.elevenlabs&&!k.openai&&!k.gemini&&!k.qwen&&!k.piper&&(0,O.jsxs)(oe,{variant:`destructive`,className:`bg-yellow-500/10 border-yellow-500/30 text-yellow-200`,children:[(0,O.jsx)(p,{className:`h-4 w-4`}),(0,O.jsxs)(ae,{className:`text-yellow-200/80`,children:[`Configura un provider TTS.`,` `,(0,O.jsx)(`button`,{className:`underline`,onClick:()=>{n(),i(`/settings/voz`)},children:`Ir a Configuración de Voz`})]})]})]}),(0,O.jsxs)(`div`,{className:`grid grid-cols-4 items-center gap-4`,children:[(0,O.jsx)(E,{className:`text-right text-xs`,children:`Entrega`}),(0,O.jsxs)(c,{value:J.step_delivery_mode,onValueChange:e=>Y(t=>({...t,step_delivery_mode:e})),children:[(0,O.jsx)(d,{className:`col-span-3`,children:(0,O.jsx)(o,{placeholder:`Modo de entrega`})}),(0,O.jsxs)(u,{children:[(0,O.jsx)(a,{value:`new_messages`,children:`Solo Mensajes Nuevos`}),(0,O.jsx)(a,{value:`all`,children:`Todo (Sincronización)`})]})]})]}),(0,O.jsxs)(`div`,{className:`pt-4 mt-2 border-t border-white/5 space-y-4`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,O.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,O.jsx)(E,{className:`text-xs font-bold uppercase tracking-wider text-blue-400`,children:`Visión / Multimodal`}),(0,O.jsx)(`p`,{className:`text-[10px] text-white/30`,children:`Procesamiento de imágenes y documentos`})]}),(0,O.jsx)(f,{checked:J.vision_enabled,onCheckedChange:e=>Y(t=>({...t,vision_enabled:e}))})]}),J.vision_enabled&&(0,O.jsxs)(`div`,{className:`grid grid-cols-4 items-center gap-4 animate-in fade-in slide-in-from-top-1 duration-200`,children:[(0,O.jsx)(E,{className:`text-right text-xs`,children:`OCR Fallback`}),(0,O.jsxs)(c,{value:J.ocr_provider||``,onValueChange:e=>Y(t=>({...t,ocr_provider:e})),children:[(0,O.jsx)(d,{className:`col-span-3`,children:(0,O.jsx)(o,{placeholder:`Selecciona provider de OCR`})}),(0,O.jsx)(u,{children:ye.map(e=>(0,O.jsx)(a,{value:e.id,children:e.name},e.id))})]}),(0,O.jsx)(`div`,{className:`col-start-2 col-span-3 text-[10px] text-white/30 italic`,children:`Se usa cuando el modelo del agente no soporta visión nativa.`})]})]})]}),nt=M===`whatsapp`||M===`webchat`||!Z||M===`telegram`&&N.trim().length>10||M===`discord`&&N.trim().length>10&&F.trim().length>0;return t?(0,O.jsx)(`div`,{className:`fixed inset-0 z-[9999] bg-black/80 flex items-center justify-center`,onClick:$,children:(0,O.jsxs)(`div`,{className:`relative w-full max-w-[480px] mx-4 hive-card border-white/10 overflow-hidden`,onClick:e=>e.stopPropagation(),children:[(0,O.jsx)(`button`,{onClick:$,className:`absolute right-4 top-4 z-10 text-white/40 hover:text-white transition-colors`,children:(0,O.jsx)(te,{className:`h-4 w-4`})}),(0,O.jsxs)(`div`,{className:`p-6 border-b border-white/5 bg-white/5 relative overflow-hidden`,children:[(0,O.jsx)(`div`,{className:`hive-glow-blob hive-glow-blob--blue -top-10 -right-10 h-32 w-32 opacity-20`}),(0,O.jsxs)(`h2`,{className:`text-xl font-black text-white uppercase tracking-tighter relative z-10 flex items-center gap-2`,children:[(0,O.jsx)(y,{className:`h-4 w-4 text-blue-400`}),{type:`Nuevo Canal`,credentials:`Conectar ${M.charAt(0).toUpperCase()+M.slice(1)}`,reconnect:Z?`Configurar ${M.charAt(0).toUpperCase()+M.slice(1)}`:`Reconectar ${M.charAt(0).toUpperCase()+M.slice(1)}`,connecting:`Conectando...`,qr:`Escanea el código QR`,success:`¡Canal conectado!`,settings:`Configurar ${e?.type??`canal`}`}[A]??`Nuevo Canal`]}),(0,O.jsx)(`p`,{className:`text-xs text-white/40 font-medium mt-1 relative z-10`,children:A===`settings`?`Ajusta el comportamiento y las opciones de voz del canal.`:A===`qr`?`Abre WhatsApp en tu teléfono y escanea el código para vincular el dispositivo.`:A===`reconnect`?Z?`Ingresa las credenciales para activar este canal.`:`Reconecta el canal con las credenciales existentes o actualízalas.`:`Conecta un nuevo canal de comunicación a Hive.`})]}),(0,O.jsx)(`div`,{className:`p-6`,children:e&&A===`settings`?tt():et()}),(0,O.jsx)(`div`,{className:`p-6 pt-4 flex gap-2`,children:e&&A===`settings`?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(w,{variant:`outline`,onClick:$,disabled:xe,children:`Cancelar`}),(0,O.jsx)(w,{onClick:Qe,disabled:xe,children:xe?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(_,{className:`h-4 w-4 animate-spin mr-2`}),`Guardando...`]}):`Guardar Cambios`})]}):A===`reconnect`?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(w,{variant:`outline`,onClick:$,children:`Cancelar`}),(0,O.jsx)(w,{onClick:Xe,disabled:K||!nt,children:K?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(_,{className:`h-4 w-4 animate-spin mr-2`}),`Conectando...`]}):Z?`Conectar`:`Reconectar`})]}):A===`type`?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(w,{variant:`outline`,onClick:$,children:`Cancelar`}),(0,O.jsx)(w,{onClick:()=>j(`credentials`),children:`Siguiente →`})]}):A===`credentials`?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(w,{variant:`outline`,onClick:()=>j(`type`),children:`← Atrás`}),(0,O.jsx)(w,{onClick:Ze,disabled:K||!$e,children:K?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(_,{className:`h-4 w-4 animate-spin mr-2`}),`Conectando...`]}):`Conectar`})]}):A===`connecting`?(0,O.jsx)(w,{variant:`outline`,onClick:$,children:`Cancelar`}):A===`qr`?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(w,{variant:`outline`,size:`sm`,onClick:()=>{fe&&Ye(M,fe)},children:[(0,O.jsx)(ee,{className:`h-3.5 w-3.5 mr-2`}),`Actualizar QR`]}),(0,O.jsx)(w,{variant:`outline`,onClick:$,children:`Cancelar`})]}):A===`success`?(0,O.jsx)(w,{onClick:$,children:`Cerrar`}):null})]})}):null}function Se(){let{channels:e,activeChannels:t,fetchChannels:n,isLoading:r,toggleChannel:i,updateChannel:a}=re(),[o,s]=(0,D.useState)(`all`),[c,l]=(0,D.useState)(null),[u,d]=(0,D.useState)(!1);(0,D.useEffect)(()=>{n()},[]);let f=(0,D.useMemo)(()=>o===`all`?e:o===`active`?e.filter(e=>e.active):o===`inactive`?e.filter(e=>!e.active):e,[e,o]),p=e=>{l(e),d(!0)},m=()=>{l(null),d(!0)};return(0,O.jsxs)(`div`,{className:`hive-page-container animate-fade-in mt-10`,children:[(0,O.jsx)(`div`,{className:`hive-page-header`,children:(0,O.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center justify-between gap-6`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-3 mb-2`,children:[(0,O.jsx)(`div`,{className:`h-10 w-10 rounded-xl bg-blue-500/10 border border-blue-500/20 flex items-center justify-center text-blue-400`,children:(0,O.jsx)(C,{className:`h-6 w-6`})}),(0,O.jsx)(`h1`,{className:`text-3xl font-black text-white uppercase tracking-tighter`,children:`Canales`})]}),(0,O.jsx)(`p`,{className:`hive-subtitle`,children:`Gestiona tus puntos de entrada y salida de comunicación en la red Hive.`})]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,O.jsxs)(`button`,{onClick:()=>n(),disabled:r,className:`hive-btn hive-btn--ghost px-6 text-[10px]`,children:[(0,O.jsx)(ee,{className:`h-3.5 w-3.5 mr-2 ${r?`animate-spin`:``}`}),`SINCRONIZAR`]}),(0,O.jsxs)(`button`,{onClick:m,className:`hive-btn hive-btn--primary px-8 text-[10px]`,children:[(0,O.jsx)(v,{className:`h-3.5 w-3.5 mr-2`}),`NUEVO CANAL`]})]})]})}),(0,O.jsxs)(`div`,{className:`hive-card border-blue-500/10 !bg-blue-500/[0.02] mb-8 overflow-hidden relative`,children:[(0,O.jsxs)(`div`,{className:`hive-card-body py-4 px-6 flex items-center justify-between relative z-10`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,O.jsx)(`div`,{className:`h-8 w-8 rounded-lg bg-blue-500/10 flex items-center justify-center text-blue-400`,children:(0,O.jsx)(b,{className:`h-4 w-4`})}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`p`,{className:`text-[10px] font-black tracking-widest text-blue-500/50 uppercase`,children:`Estado Operativo`}),(0,O.jsxs)(`p`,{className:`text-xs text-white/60`,children:[`Actualmente tienes `,(0,O.jsx)(`span`,{className:`text-blue-400 font-black`,children:t.length}),` canales procesando datos.`]})]})]}),(0,O.jsx)(`div`,{className:`text-[10px] text-white/20 font-black tracking-widest uppercase`,children:`HIVE NODE SECURE`})]}),(0,O.jsx)(`div`,{className:`hive-glow-blob hive-glow-blob--blue -top-10 -right-10 h-32 w-32 opacity-10`})]}),(0,O.jsx)(`div`,{className:`flex items-center gap-1.5 p-1 bg-white/5 rounded-2xl w-fit border border-white/5 mb-8`,children:[{id:`all`,label:`TODOS (${e.length})`},{id:`active`,label:`ACTIVOS (${e.filter(e=>e.active).length})`},{id:`inactive`,label:`INACTIVOS (${e.filter(e=>!e.active).length})`}].map(e=>(0,O.jsx)(`button`,{onClick:()=>s(e.id),className:`px-8 py-2.5 rounded-xl text-[10px] font-black tracking-widest uppercase transition-all duration-300 ${o===e.id?`bg-blue-500 text-white shadow-blue-glow`:`text-white/20 hover:text-white/40 hover:bg-white/5`}`,children:e.label},e.id))}),(0,O.jsx)(`div`,{className:`animate-fade-in`,children:f.length>0?(0,O.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6`,children:f.map(e=>(0,O.jsx)(k,{channel:e,onEdit:p,onToggle:i},e.id))}):(0,O.jsx)(`div`,{className:`hive-card border-dashed border-white/10 bg-white/[0.02]`,children:(0,O.jsxs)(`div`,{className:`hive-card-body flex flex-col items-center justify-center py-20 px-4`,children:[(0,O.jsx)(`div`,{className:`h-20 w-20 rounded-2xl bg-white/5 flex items-center justify-center mb-6`,children:(0,O.jsx)(C,{className:`h-10 w-10 text-white/10`})}),(0,O.jsxs)(`div`,{className:`text-center`,children:[(0,O.jsx)(`p`,{className:`hive-title-section text-center mb-2`,children:`No se detectaron canales`}),(0,O.jsx)(`p`,{className:`text-xs text-white/40 mb-8 max-w-[300px] mx-auto leading-relaxed`,children:`Configura tu primer punto de enlace para empezar a recibir datos en tiempo real.`}),(0,O.jsx)(`button`,{onClick:m,className:`hive-btn hive-btn--primary px-10 text-[10px]`,children:`ESTABLECER CONEXIÓNHORA`})]})]})})}),(0,O.jsx)(xe,{channel:c,isOpen:u,onClose:()=>d(!1),onSave:async(e,t)=>{await a(e,t)}})]})}export{Se as ChannelsPage};
|
|
@@ -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{t as i}from"./activity-c3pNngT_.js";import{t as a}from"./pause-BUqah9Bi.js";import{t as o}from"./play-NcZ4swwL.js";import{t as s}from"./refresh-cw-DaYdjQFk.js";import{n as c,t as l}from"./scroll-area-DkeyX32e.js";import{t as u}from"./trash-2-CNjMkoq6.js";import{M as d,j as f,x as p}from"./index-DMCjjdqf.js";import{t as m}from"./badge-ChpACfWO.js";import{n as h,t as g}from"./card-CNf6BS2e.js";var _=e(t(),1),v=n();function y(){let[e,t]=(0,_.useState)([]),[n,y]=(0,_.useState)(!1),[b,x]=(0,_.useState)(``),[S,C]=(0,_.useState)([`info`,`warn`,`error`]),[w,T]=(0,_.useState)(!1),[E,D]=(0,_.useState)(!0),O=(0,_.useRef)(null),{url:k,status:A,subscribe:j,send:M}=p();(0,_.useEffect)(()=>{if(A!==`connected`)return;M({type:`logs_subscribe`});let e=j(`log`,e=>{w||e.logEntry&&t(t=>[...t,e.logEntry].slice(-2e3))});return()=>{M({type:`logs_unsubscribe`}),e()}},[A,j,M,w]),(0,_.useEffect)(()=>{if(E&&O.current){let e=O.current.querySelector(`[data-radix-scroll-area-viewport]`);e&&(e.scrollTop=e.scrollHeight)}},[e,E]);let N=e=>{C(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},P=(0,_.useMemo)(()=>e.filter(e=>{let t=S.includes(e.level),n=e.message.toLowerCase().includes(b.toLowerCase())||e.meta&&JSON.stringify(e.meta).toLowerCase().includes(b.toLowerCase());return t&&n}),[e,S,b]),F=e=>{switch(e){case`error`:return`bg-red-500/10 text-red-500 border-red-500/20`;case`warn`:return`bg-yellow-500/10 text-yellow-500 border-yellow-500/20`;case`debug`:return`bg-slate-500/10 text-slate-500 border-slate-500/20`;default:return`bg-blue-500/10 text-blue-500 border-blue-500/20`}};return(0,v.jsxs)(`div`,{className:`flex flex-col h-[calc(100vh-8rem)] space-y-4 mt-10`,children:[(0,v.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center justify-between gap-4`,children:[(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`h2`,{className:`text-2xl font-bold tracking-tight`,children:`Logs del Sistema`}),(0,v.jsx)(`p`,{className:`text-muted-foreground`,children:`Monitoreo en tiempo real de la actividad del enjambre.`})]}),(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsxs)(d,{variant:`outline`,size:`sm`,onClick:()=>T(!w),className:w?`text-yellow-500 border-yellow-500/50 hover:bg-yellow-500/10`:``,children:[w?(0,v.jsx)(o,{className:`h-4 w-4 mr-2`}):(0,v.jsx)(a,{className:`h-4 w-4 mr-2`}),w?`Renaudar`:`Pausar`]}),(0,v.jsxs)(d,{variant:`outline`,size:`sm`,onClick:()=>t([]),children:[(0,v.jsx)(u,{className:`h-4 w-4 mr-2`}),`Limpiar`]}),(0,v.jsxs)(d,{variant:`outline`,size:`sm`,onClick:()=>{},disabled:!0,className:`opacity-50`,children:[(0,v.jsx)(s,{className:`h-4 w-4 mr-2`}),`Sincronizado via WS`]})]})]}),(0,v.jsx)(g,{className:`bg-muted/30`,children:(0,v.jsxs)(h,{className:`p-3 flex flex-wrap items-center gap-4`,children:[(0,v.jsxs)(`div`,{className:`relative flex-1 min-w-[200px]`,children:[(0,v.jsx)(c,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground`}),(0,v.jsx)(f,{placeholder:`Buscar en logs...`,className:`pl-9 h-9 bg-background`,value:b,onChange:e=>x(e.target.value)})]}),(0,v.jsx)(`div`,{className:`flex items-center gap-1.5 p-1 bg-background rounded-md border text-xs`,children:[`debug`,`info`,`warn`,`error`].map(e=>(0,v.jsx)(`button`,{onClick:()=>N(e),className:r(`px-2 py-1 rounded capitalize transition-colors`,S.includes(e)?F(e).split(` `)[1]+` `+F(e).split(` `)[0]:`text-muted-foreground hover:bg-muted`),children:e},e))}),(0,v.jsxs)(`label`,{className:`flex items-center gap-2 text-xs cursor-pointer select-none`,children:[(0,v.jsx)(`input`,{type:`checkbox`,className:`sr-only`,checked:E,onChange:()=>D(!E)}),(0,v.jsx)(`div`,{className:r(`w-8 h-4 rounded-full relative transition-colors`,E?`bg-primary`:`bg-muted border shadow-inner`),children:(0,v.jsx)(`div`,{className:r(`absolute top-0.5 w-3 h-3 rounded-full bg-white transition-all shadow-sm`,E?`left-[17px]`:`left-0.5`)})}),`Auto-scroll`]}),(0,v.jsxs)(`div`,{className:`ml-auto flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,v.jsx)(`div`,{className:r(`w-2 h-2 rounded-full`,A===`connected`?`bg-green-500 animate-pulse`:`bg-red-500`)}),A===`connected`?`STREAMING`:`OFFLINE`,(0,v.jsx)(`span`,{className:`mx-1 opacity-30`,children:`|`}),P.length,` de `,e.length,` entradas`]})]})}),(0,v.jsx)(g,{className:`flex-1 overflow-hidden border-2`,children:(0,v.jsx)(h,{className:`p-0 h-full bg-black/95`,children:(0,v.jsx)(l,{className:`h-full w-full`,ref:O,children:(0,v.jsxs)(`div`,{className:`p-4 font-mono text-[11px] leading-relaxed`,children:[P.length===0?(0,v.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-20 text-muted-foreground opacity-50`,children:[(0,v.jsx)(i,{className:`h-10 w-10 mb-4 stroke-[1]`}),(0,v.jsx)(`p`,{children:n?`Analizando registros...`:`No se encontraron logs con los filtros activos.`})]}):(0,v.jsx)(`div`,{className:`space-y-0.5`,children:P.map(e=>(0,v.jsxs)(`div`,{className:`group flex items-start gap-3 py-0.5 hover:bg-white/5 rounded px-1 transition-colors`,children:[(0,v.jsx)(`span`,{className:`text-slate-600 shrink-0 select-none hidden md:inline`,children:e.timestamp.includes(`T`)?e.timestamp.split(`T`)[1].split(`.`)[0]:e.timestamp}),(0,v.jsx)(m,{variant:`outline`,className:r(`px-1 py-0 h-4 text-[9px] uppercase font-bold shrink-0 border`,F(e.level)),children:e.level}),(0,v.jsxs)(`div`,{className:`flex-1 break-all text-slate-300`,children:[(0,v.jsxs)(`span`,{className:`text-slate-500 mr-2`,children:[`[`,e.source,`]`]}),e.message,e.meta&&(0,v.jsx)(`span`,{className:`text-slate-500 ml-2 italic opacity-60`,children:JSON.stringify(e.meta)})]})]},`${e.timestamp}-${e.source}-${e.message.slice(0,30)}`))}),(0,v.jsx)(`div`,{className:`h-4`}),` `]})})})})]})}export{y as LogsPage};
|
|
@@ -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{a as i,c as a,l as o,n as s,r as c,s as l,t as u}from"./switch-BDwN8RYV.js";import{n as d}from"./chevron-up-BYhk0K2J.js";import{t as f}from"./chevron-right-CR4Skrf3.js";import{t as p}from"./circle-check-Bb54Ebmu.js";import{t as m}from"./cpu-Cdgc_B1K.js";import{t as h}from"./download-C3ifGMjJ.js";import{n as g,t as _}from"./eye-DqNTU_GD.js";import{t as v}from"./globe-DeCQTCDJ.js";import{t as y}from"./key-3EP0dhkT.js";import{t as b}from"./loader-circle-CZNax6kS.js";import{a as x,c as S,d as C,f as w,i as T,l as E,n as D,o as O,p as k,r as A,s as ee,t as te,u as j}from"./table-CSc8ubon.js";import{t as ne}from"./lock-Ei1_J-Nq.js";import{n as M,t as N}from"./square-BD81nFtN.js";import{n as re,t as P}from"./terminal-DN38Q456.js";import{t as F}from"./play-NcZ4swwL.js";import{t as I}from"./plus-CX1xyhp5.js";import{t as L}from"./refresh-cw-DaYdjQFk.js";import{n as R,t as z}from"./scroll-area-DkeyX32e.js";import{t as ie}from"./settings-Ds4SqD8s.js";import{t as ae}from"./trash-2-CNjMkoq6.js";import{G as oe,M as B,R as se,W as ce,a as le,c as V,d as ue,h as H,i as de,j as U,p as fe,r as W,s as pe}from"./index-DMCjjdqf.js";import{t as G}from"./label-D2H1IR_J.js";import{c as me,i as he,o as ge,r as _e,s as ve,t as ye}from"./dialog-QnZ0ad8O.js";import{t as K}from"./badge-ChpACfWO.js";import{a as q,n as J,o as Y,r as X,t as Z}from"./card-CNf6BS2e.js";import"./useProviders-C6_QHsEi.js";var be=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`}]]),xe=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`}]]),Se=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 Ce({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,f]=(0,Q.useState)(e?.num_ctx?String(e.num_ctx):``),m=s||e?.baseUrl||e?.base_url||``,h=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)(G,{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)(p,{className:`h-3 w-3`}),`Configurada`]})]}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(U,{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)(B,{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)(g,{className:`h-3 w-3`}):(0,$.jsx)(_,{className:`h-3 w-3`})})]})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(G,{className:`hive-label`,children:`Base URL (opcional)`}),(0,$.jsx)(U,{value:s,onChange:e=>c(e.target.value),placeholder:`https://api.example.com`,className:`hive-input !h-8 text-xs`})]}),h&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(G,{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)(U,{type:`number`,value:d,onChange:e=>f(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)(G,{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)(p,{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{H.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 we=ie,Te=d,Ee=f,De=m,Oe=I,ke=xe,Ae=v,je=L,Me=re,Ne=ae,Pe=o,Fe=se;function Ie({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,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(``),[v,y]=(0,Q.useState)(``),[b,x]=(0,Q.useState)(null),{models:S,toggleModel:C,createModel:w,syncModels:T,deleteModel:E,updateModel:D}=pe(),{toggleProvider:O}=V(),k=(0,Q.useMemo)(()=>{let t=S.filter(t=>(t.providerId||t.provider_id)===e.id);return t.length>0?t:e.models||[]},[S,e.id,e.models]),A=k.filter(e=>e.enabled||e.active),ee=n=>{t(e.id,n),i(!1)},te=async t=>{try{await O(e.id,t)}catch(e){console.error(`Failed to toggle provider:`,e)}},j=async(e,t)=>{try{await C(e.id,t)}catch(e){console.error(`Failed to toggle model:`,e)}},ne=async()=>{p(!0);try{await T(e.id),o(!0)}catch(e){console.error(`Failed to sync models:`,e)}finally{p(!1)}},M=e=>{h(e.id),_(e.name),y(e.id)},N=()=>{h(null),_(``),y(``)},re=async e=>{let t=g.trim()||e.name,n=v.trim()||e.id;if(t===e.name&&n===e.id){N();return}try{await D(e.id,{name:t,id:n}),N()}catch(e){console.error(`Failed to update model:`,e)}},P=async e=>{x(e.id);try{await E(e.id)}catch(e){console.error(`Failed to delete model:`,e)}finally{x(null)}},F=async()=>{let t=s.trim();if(t){d(!0);try{await w(e.id,t),c(``)}catch(e){console.error(`Failed to add model:`,e)}finally{d(!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)(De,{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)(u,{checked:I,onCheckedChange:te,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)(ke,{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)(Ae,{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)(De,{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)(Te,{className:`h-3 w-3`}):(0,$.jsx)(Ee,{className:`h-3 w-3`}),`MODELOS`,(0,$.jsxs)(`span`,{className:`hive-tag scale-90 origin-left`,children:[A.length,`/`,k.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:ne,disabled:f,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)(je,{className:`h-3 w-3 ${f?`animate-spin`:``}`})})]})]}),!a&&k.length>0&&(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:[k.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)),k.length>3&&(0,$.jsxs)(`span`,{className:`hive-tag text-[10px] text-white/30`,children:[`+`,k.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:[k.length===0&&(0,$.jsx)(`p`,{className:`text-[11px] text-white/25 py-2 text-center`,children:`Sin modelos configurados`}),k.map(e=>{let t=e.enabled||!!e.active,n=m===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:g,onChange:e=>_(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:v,onChange:e=>y(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:()=>re(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)(Pe,{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)(Fe,{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:()=>M(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)(Me,{className:`h-3 w-3`})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>P(e),disabled:b===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)(Ne,{className:`h-3 w-3`})}),(0,$.jsx)(u,{checked:t,onCheckedChange:t=>j(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`&&F(),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:F,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)(Oe,{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)(ye,{open:r,onOpenChange:i,children:[(0,$.jsx)(me,{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)(we,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:`CONFIG`})]})}),(0,$.jsxs)(_e,{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)(ve,{className:`text-lg font-black text-white uppercase tracking-tighter`,children:e.name}),(0,$.jsx)(he,{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)(Ce,{provider:e,onSave:ee,onCancel:()=>i(!1)})})]})]})]}),(0,$.jsx)(`div`,{className:`hive-strip--bottom ${I?``:`opacity-20`}`})]})}function Le(){let{providers:e,updateProvider:t}=V(),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)(Ie,{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 Re({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,h]=(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)(G,{className:`hive-label`,children:`Nombre del Provider`}),(0,$.jsx)(U,{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)(G,{className:`hive-label`,children:`Tipo de Provider`}),(0,$.jsx)(U,{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)(G,{className:`hive-label`,children:`API Key`})}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(U,{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)(g,{className:`h-3 w-3`}):(0,$.jsx)(_,{className:`h-3 w-3`})})]})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(G,{className:`hive-label`,children:`Base URL (opcional)`}),(0,$.jsx)(U,{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)(G,{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)(U,{type:`number`,value:m,onChange:e=>h(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)(G,{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()){H.fire(`Error`,`El nombre del provider es requerido`,`error`);return}if(!o){H.fire(`Error`,`Selecciona un tipo de provider`,`error`);return}if(!c.trim()&&!v){H.fire(`Error`,`La API Key es requerida para este provider`,`error`);return}let t;if(f.trim())try{t=JSON.parse(f.trim())}catch{H.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 ze={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 Be({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)(K,{variant:`outline`,className:`text-[10px] py-0 h-4`,children:ze[e]??e},e))})}function Ve({model:e}){let{toggleModel:t}=pe();return(0,$.jsx)(Z,{className:e.active?``:`opacity-70 bg-muted/30`,children:(0,$.jsxs)(J,{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)(K,{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)(Be,{capabilities:e.capabilities})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col items-end gap-2`,children:[(0,$.jsx)(u,{checked:!!e.active,onCheckedChange:n=>t(e.id,n)}),(0,$.jsx)(K,{variant:e.active?`default`:`secondary`,className:`text-[10px]`,children:e.active?`Activo`:`Inactivo`})]})]})})}function He(e){if(!e)return[];if(typeof e==`string`)try{return JSON.parse(e)}catch{return[]}return Array.isArray(e)?e:[]}function Ue(){let{availableModels:e,activeProviders:t}=V(),n=W(e=>e.fetchAll),[r,o]=(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=He(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)(K,{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)(R,{className:`absolute left-2 top-2 h-4 w-4 text-muted-foreground`}),(0,$.jsx)(U,{placeholder:`Buscar modelo...`,className:`h-8 pl-8 text-sm`,value:r,onChange:e=>o(e.target.value)})]}),(0,$.jsxs)(s,{value:u,onValueChange:d,children:[(0,$.jsx)(l,{className:`h-8 w-40 text-sm`,children:(0,$.jsx)(a,{placeholder:`Provider`})}),(0,$.jsxs)(c,{children:[(0,$.jsx)(i,{value:`all`,children:`Todos`}),t.map(e=>(0,$.jsx)(i,{value:e.id,children:e.name},e.id))]})]})]}),(0,$.jsx)(z,{className:`h-[calc(100vh-26rem)]`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[f.map(e=>(0,$.jsx)(Ve,{model:e},e.id)),f.length===0&&(0,$.jsxs)(`div`,{className:`hive-empty-state`,children:[(0,$.jsx)(_,{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 We({open:e,onOpenChange:t}){let{availableTTSModels:n,fetchAvailableTTSModels:r,downloadTTSModel:i,isDownloadingModel:a,downloadLogs:s,fetchDownloadLogs:c}=le(),[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 i(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)(ye,{open:e,onOpenChange:t,children:(0,$.jsxs)(_e,{className:`max-w-3xl max-h-[80vh] overflow-hidden flex flex-col`,children:[(0,$.jsxs)(ge,{children:[(0,$.jsx)(ve,{className:`flex items-center gap-2`,children:`📦 Gestionar Modelos TTS`}),(0,$.jsx)(he,{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)(K,{variant:`outline`,children:[n.filter(e=>e.installed).length,` / `,n.length,` instalados`]})}),(0,$.jsxs)(B,{size:`sm`,variant:`ghost`,onClick:d,disabled:l||a,className:`gap-2`,children:[(0,$.jsx)(L,{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)(b,{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)(te,{children:[(0,$.jsx)(x,{children:(0,$.jsxs)(O,{children:[(0,$.jsx)(T,{children:`Modelo`}),(0,$.jsx)(T,{children:`Idioma`}),(0,$.jsx)(T,{children:`Calidad`}),(0,$.jsx)(T,{children:`Tamaño`}),(0,$.jsx)(T,{children:`Estado`}),(0,$.jsx)(T,{className:`text-right`,children:`Acciones`})]})}),(0,$.jsx)(D,{children:n.map(e=>(0,$.jsxs)(O,{children:[(0,$.jsx)(A,{className:`font-medium`,children:e.name}),(0,$.jsx)(A,{children:e.language}),(0,$.jsx)(A,{children:(0,$.jsx)(K,{className:p(e.quality),children:e.quality})}),(0,$.jsx)(A,{className:`text-muted-foreground`,children:e.size}),(0,$.jsx)(A,{children:e.installed?(0,$.jsxs)(K,{className:`bg-green-500/20 text-green-400 border-green-500/30 gap-1`,children:[(0,$.jsx)(o,{className:`h-3 w-3`}),`Instalado`]}):a&&s.some(t=>t.includes(e.name))?(0,$.jsxs)(K,{className:`bg-blue-500/20 text-blue-400 border-blue-500/30 gap-1`,children:[(0,$.jsx)(b,{className:`h-3 w-3 animate-spin`}),`Descargando`]}):(0,$.jsx)(K,{variant:`secondary`,className:`bg-zinc-700/50 text-zinc-400`,children:`No instalado`})}),(0,$.jsx)(A,{className:`text-right`,children:e.installed?(0,$.jsxs)(B,{size:`sm`,variant:`ghost`,disabled:!0,className:`gap-2 opacity-50`,children:[(0,$.jsx)(o,{className:`h-4 w-4`}),`Instalado`]}):(0,$.jsxs)(B,{size:`sm`,onClick:()=>f(e.id),disabled:a,className:`gap-2`,children:[(0,$.jsx)(h,{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 Ge(){let{localTTS:e,fetchLocalTTSStatus:t,installLocalTTS:n,startLocalTTS:r,stopLocalTTS:i}=le(),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)([]),[d,f]=(0,Q.useState)(``),[p,m]=(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 fe(`/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)}},b=async()=>{o(!0);try{await r()}finally{o(!1)}},x=async()=>{o(!0);try{await i()}finally{o(!1)}},S=async()=>{c(e=>!e),s||await v()},{installed:T,running:E,piperExists:D,voiceExists:O,port:k}=e,A=e.installing;return(0,$.jsxs)(Z,{className:`relative overflow-hidden col-span-full ${E?`border-blue-500/30 bg-blue-500/[0.02]`:``}`,children:[(0,$.jsx)(q,{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)(Y,{className:`text-lg flex items-center gap-2`,children:[`Piper TTS`,(0,$.jsx)(K,{variant:`outline`,className:`text-[10px] px-1.5 py-0 font-normal border-zinc-600 text-zinc-400`,children:`Local · Offline`})]}),(0,$.jsx)(X,{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:[A?(0,$.jsxs)(K,{className:`bg-yellow-500/20 text-yellow-400 border-yellow-500/30 gap-1`,children:[(0,$.jsx)(L,{className:`h-3 w-3 animate-spin`}),`Instalando…`]}):T?(0,$.jsx)(K,{className:`bg-green-500/20 text-green-400 border-green-500/30`,children:`Instalado`}):(0,$.jsx)(K,{variant:`secondary`,className:`bg-zinc-700/50 text-zinc-400`,children:`No instalado`}),T&&(E?(0,$.jsxs)(K,{className:`bg-blue-500/20 text-blue-400 border-blue-500/30 gap-1`,children:[(0,$.jsx)(C,{className:`h-3 w-3`}),`Servidor :`,k]}):(0,$.jsxs)(K,{variant:`secondary`,className:`bg-zinc-700/50 text-zinc-400 gap-1`,children:[(0,$.jsx)(w,{className:`h-3 w-3`}),`Detenido`]}))]})]})}),(0,$.jsxs)(J,{className:`space-y-4`,children:[!T&&!A&&(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)`]})]}),T&&(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:[!T&&!A&&(0,$.jsxs)(B,{size:`sm`,onClick:y,disabled:a,className:`gap-2`,children:[(0,$.jsx)(h,{className:`h-3.5 w-3.5`}),`Instalar Piper (~68 MB)`]}),A&&(0,$.jsxs)(B,{size:`sm`,disabled:!0,className:`gap-2 opacity-70`,children:[(0,$.jsx)(L,{className:`h-3.5 w-3.5 animate-spin`}),`Descargando…`]}),T&&!E&&(0,$.jsxs)(B,{size:`sm`,onClick:b,disabled:a,className:`gap-2 bg-blue-600 hover:bg-blue-500 text-white`,children:[(0,$.jsx)(F,{className:`h-3.5 w-3.5`}),`Iniciar servidor`]}),E&&(0,$.jsxs)(B,{size:`sm`,variant:`outline`,onClick:x,disabled:a,className:`gap-2 border-red-500/40 text-red-400 hover:bg-red-500/10`,children:[(0,$.jsx)(N,{className:`h-3.5 w-3.5`}),`Detener servidor`]}),T&&(0,$.jsxs)(B,{size:`sm`,variant:`outline`,onClick:()=>m(!0),disabled:a,className:`gap-2`,children:[(0,$.jsx)(Se,{className:`h-3.5 w-3.5`}),`Gestionar modelos`,e.voices&&e.voices.length>0&&(0,$.jsx)(K,{variant:`secondary`,className:`ml-1 text-[10px] px-1`,children:e.voices.length})]}),(0,$.jsx)(B,{size:`sm`,variant:`ghost`,onClick:()=>t(),title:`Actualizar estado`,className:`text-zinc-400`,children:(0,$.jsx)(L,{className:`h-3.5 w-3.5`})}),(0,$.jsxs)(B,{size:`sm`,variant:`ghost`,onClick:S,className:`gap-1.5 text-zinc-400 text-xs`,children:[(0,$.jsx)(P,{className:`h-3.5 w-3.5`}),s?`Ocultar log`:`Ver log`]})]}),A&&(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)(We,{open:p,onOpenChange:m})]})]})}var Ke={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 qe(e){if(!e)return[];if(typeof e==`string`)try{return JSON.parse(e)}catch{return[]}return Array.isArray(e)?e:[]}function Je(){let{availableModels:e,activeProviders:t}=V(),{voiceProviders:n,configuredVoiceProviders:r,fetchVoiceProviders:u,fetchConfiguredVoiceProviders:d,saveVoiceProviderKey:f}=ue(),p=W(e=>e.fetchAll),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(``),[v,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(``),[T,E]=(0,Q.useState)(`all`);(0,Q.useEffect)(()=>{u(),d(),p(!0)},[u,d,p]);let D=async e=>{if(g.trim()){b(!0);try{await f(e,g.trim()),await d(),h(null),_(``)}catch(e){console.error(`Failed to save API key:`,e)}finally{b(!1)}}},O=n.length>0?n:Object.keys(Ke),A=(0,Q.useMemo)(()=>e.filter(e=>{let t=e.model_type===`stt`||e.model_type===`tts`,n=qe(e.capabilities),r=n.includes(`transcription`)||n.includes(`tts`)||n.includes(`speech`),i=e.name.toLowerCase().includes(C.toLowerCase())||e.id.toLowerCase().includes(C.toLowerCase()),a=T===`all`||e.providerId===T||e.provider_id===T;return(t||r)&&i&&a}),[e,C,T]);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)(K,{variant:`secondary`,children:A.length})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(`div`,{className:`relative flex-1`,children:[(0,$.jsx)(R,{className:`absolute left-2 top-2 h-4 w-4 text-muted-foreground`}),(0,$.jsx)(U,{placeholder:`Buscar modelo...`,className:`h-8 pl-8 text-sm`,value:C,onChange:e=>w(e.target.value)})]}),(0,$.jsxs)(s,{value:T,onValueChange:E,children:[(0,$.jsx)(l,{className:`h-8 w-40 text-sm`,children:(0,$.jsx)(a,{placeholder:`Provider`})}),(0,$.jsxs)(c,{children:[(0,$.jsx)(i,{value:`all`,children:`Todos`}),t.map(e=>(0,$.jsx)(i,{value:e.id,children:e.name},e.id))]})]})]}),(0,$.jsx)(z,{className:`h-60`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[A.map(e=>(0,$.jsx)(Ve,{model:e},e.id)),A.length===0&&(0,$.jsxs)(`div`,{className:`hive-empty-state`,children:[(0,$.jsx)(M,{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)(Ge,{}),O.map(e=>{let t=Ke[e]||{name:e,description:``,logo:`🔌`,consoleUrl:`#`},n=r[e]===!0,i=m===e;return(0,$.jsxs)(Z,{className:`relative overflow-hidden ${n?`border-green-500/30 bg-green-500/[0.02]`:``}`,children:[(0,$.jsx)(q,{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)(Y,{className:`text-lg`,children:t.name}),(0,$.jsx)(X,{className:`text-xs`,children:t.description})]})]}),t.noApiKey?(0,$.jsx)(K,{variant:`outline`,className:`bg-zinc-700/40 text-zinc-300 border-zinc-600`,children:`Sin API key`}):n?(0,$.jsxs)(K,{variant:`default`,className:`bg-green-500/20 text-green-400 border-green-500/30`,children:[(0,$.jsx)(o,{className:`h-3 w-3 mr-1`}),`Configurado`]}):(0,$.jsx)(K,{variant:`secondary`,className:`bg-yellow-500/20 text-yellow-400 border-yellow-500/30`,children:`Sin configurar`})]})}),(0,$.jsx)(J,{className:`space-y-4`,children:t.noApiKey?(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t.description}):i?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(G,{htmlFor:`api-key-${e}`,children:`API Key`}),(0,$.jsxs)(`div`,{className:`flex gap-2 mt-1`,children:[(0,$.jsx)(U,{id:`api-key-${e}`,type:x?`text`:`password`,placeholder:`sk-...`,value:g,onChange:e=>_(e.target.value),className:`flex-1 font-mono text-sm`,autoFocus:!0}),(0,$.jsx)(B,{variant:`outline`,size:`icon`,onClick:()=>S(!x),title:x?`Ocultar`:`Mostrar`,children:x?(0,$.jsx)(ne,{className:`h-4 w-4`}):(0,$.jsx)(k,{className:`h-4 w-4`})})]})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(B,{size:`sm`,onClick:()=>D(e),disabled:v||!g.trim(),className:`flex-1`,children:v?`Guardando...`:`Guardar`}),(0,$.jsx)(B,{size:`sm`,variant:`outline`,onClick:()=>{h(null),_(``)},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)(y,{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)(B,{size:`sm`,variant:`outline`,onClick:()=>{h(e),_(``)},className:`flex-1`,children:[(0,$.jsx)(y,{className:`h-3 w-3 mr-2`}),`Actualizar API Key`]}):(0,$.jsxs)(B,{size:`sm`,onClick:()=>{h(e),_(``)},className:`flex-1`,children:[(0,$.jsx)(y,{className:`h-3 w-3 mr-2`}),`Configurar API Key`]}),(0,$.jsx)(B,{size:`sm`,variant:`outline`,onClick:()=>window.open(t.consoleUrl,`_blank`),children:`Obtener Key`})]})]})})]},e)})]})]}),(0,$.jsxs)(Z,{children:[(0,$.jsxs)(q,{children:[(0,$.jsx)(Y,{className:`text-lg`,children:`Como funciona?`}),(0,$.jsx)(X,{children:`Configura las API keys de los providers de voz para habilitar STT y TTS en tus canales.`})]}),(0,$.jsxs)(J,{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 Ye(){let{localLLM:e,localLLMLogs:t,fetchLocalLLMStatus:n,installLocalLLM:r,startLocalLLM:i,stopLocalLLM:a,downloadLLMModel:o,fetchLocalLLMLogs:s}=de(),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(``),g=(0,Q.useRef)(null),_=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{n()},[n]),(0,Q.useEffect)(()=>(e.installing||e.downloadingModelId?g.current=setInterval(()=>{n()},3e3):g.current&&clearInterval(g.current),()=>{g.current&&clearInterval(g.current)}),[e.installing,e.downloadingModelId,n]),(0,Q.useEffect)(()=>{_.current&&(_.current.scrollTop=_.current.scrollHeight)},[t]),(0,Q.useEffect)(()=>{if(!u)return;let e=new EventSource(`/api/llm-local/logs?mode=TEXT`);return e.onmessage=e=>{try{let t=JSON.parse(e.data);t.llmRoot&&p(t.llmRoot),(t.logs||t.serverLogs)&&W.setState(e=>({localLLMLogs:[...t.logs||[],...t.serverLogs||[]]}))}catch(e){console.error(`Error parsing SSE log data`,e)}},()=>{e.close()}},[u]);let v=async()=>{l(!0),d(!0);try{await r()}finally{l(!1)}},y=async e=>{l(!0);try{await o(e)}finally{l(!1)}},b=async(e=`TEXT`)=>{l(!0);try{await i(e)}finally{l(!1)}},x=async e=>{l(!0);try{await a(e)}finally{l(!1)}},S=()=>{d(e=>!e)},{installed:C,binaryExists:w,anyModelExists:T,installing:E,downloadingModelId:D,gpu:O,models:k}=e;return(0,$.jsxs)(Z,{className:`relative overflow-hidden col-span-full ${C?`border-amber-500/30 bg-amber-500/[0.02]`:``}`,children:[(0,$.jsx)(q,{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)(Y,{className:`text-lg flex items-center gap-2`,children:[`Local LLM (llama-server)`,(0,$.jsx)(K,{variant:`outline`,className:`text-[10px] px-1.5 py-0 font-normal border-zinc-600 text-zinc-400`,children:`Local · Private`})]}),(0,$.jsxs)(X,{className:`text-xs`,children:[`Inferencia local sin internet usando llama-server. Soporta aceleración por GPU (`,O.backend,`).`]})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[e.activeServers.map(e=>(0,$.jsxs)(K,{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&&w&&(0,$.jsx)(K,{variant:`outline`,className:`border-zinc-700 text-zinc-500`,children:`Apagado`}),E?(0,$.jsxs)(K,{className:`bg-yellow-500/20 text-yellow-400 border-yellow-500/30 gap-1`,children:[(0,$.jsx)(L,{className:`h-3 w-3 animate-spin`}),`Configurando…`]}):w?(0,$.jsx)(K,{className:`bg-amber-500/10 text-amber-500 border-amber-500/30`,children:`Binario Listo`}):(0,$.jsx)(K,{variant:`secondary`,className:`bg-zinc-700/50 text-zinc-400`,children:`No configurado`}),O&&(0,$.jsxs)(K,{variant:`outline`,className:`gap-1 border-zinc-700 text-zinc-400`,children:[(0,$.jsx)(m,{className:`h-3 w-3`}),O.deviceName||O.backend]})]})]})}),(0,$.jsxs)(J,{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)(be,{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`}),w?(0,$.jsx)(`span`,{className:`text-green-400 font-medium`,children:`✓ Instalado`}):(0,$.jsx)(B,{variant:`link`,size:`sm`,onClick:v,disabled:c||E,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,$.jsx)(`span`,{className:`text-zinc-300 font-medium`,children:e.mode}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`span`,{className:`text-zinc-500`,children:[`Puerto `,e.port]}),(0,$.jsx)(B,{variant:`ghost`,size:`icon`,className:`h-5 w-5 text-red-400 hover:text-red-300 hover:bg-red-400/10`,onClick:()=>x(e.mode),disabled:c,children:(0,$.jsx)(N,{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)(Se,{className:`h-4 w-4 text-amber-400`}),`Modelos Disponibles`]}),(0,$.jsx)(`div`,{className:`space-y-2`,children:k.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`}):D===e.id?(0,$.jsxs)(`span`,{className:`text-yellow-400 flex items-center gap-1`,children:[(0,$.jsx)(L,{className:`h-3 w-3 animate-spin`}),`Descargando…`]}):(0,$.jsx)(B,{variant:`outline`,size:`sm`,onClick:()=>y(e.id),disabled:c||!!D,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:[!w&&!E&&(0,$.jsxs)(B,{size:`sm`,onClick:v,disabled:c,className:`gap-2 bg-amber-600 hover:bg-amber-500`,children:[(0,$.jsx)(h,{className:`h-3.5 w-3.5`}),`Configurar Local LLM`]}),w&&!E&&(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2 w-full`,children:[(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)(B,{size:`sm`,variant:n?`default`:`ghost`,onClick:()=>n?x(t):b(t),disabled:c||!n&&!T,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)(N,{className:`h-3 w-3 fill-current`}):(0,$.jsx)(F,{className:`h-3 w-3 fill-current`}),t]},t)})}),e.running&&(0,$.jsxs)(B,{size:`sm`,variant:`outline`,onClick:()=>x(),disabled:c,className:`gap-2 border-red-500/30 text-red-400 hover:bg-red-500/10 h-9`,children:[(0,$.jsx)(N,{className:`h-3.5 w-3.5 fill-current`}),`Apagar Todo`]})]}),(0,$.jsx)(B,{size:`sm`,variant:`ghost`,onClick:()=>n(),title:`Actualizar estado`,className:`text-zinc-400`,children:(0,$.jsx)(L,{className:`h-3.5 w-3.5`})}),(0,$.jsxs)(B,{size:`sm`,variant:`ghost`,onClick:S,className:`gap-1.5 text-zinc-400 text-xs ml-auto`,children:[(0,$.jsx)(P,{className:`h-3.5 w-3.5`}),u?`Ocultar log`:`Ver log`]})]}),u&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[f&&(0,$.jsxs)(`p`,{className:`text-[10px] text-zinc-500 font-mono text-right`,children:[`ruta: `,f]}),(0,$.jsx)(`div`,{ref:_,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 Xe(e){if(!e)return[];if(typeof e==`string`)try{return JSON.parse(e)}catch{return[]}return Array.isArray(e)?e:[]}function Ze(){let{availableModels:e,activeProviders:t}=V(),n=W(e=>e.fetchAll),[r,o]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(`all`);(0,Q.useEffect)(()=>{n(!0)},[]);let f=(0,Q.useMemo)(()=>e.filter(e=>{let t=Xe(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)(Ye,{}),(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)(K,{variant:`secondary`,children:f.length})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(`div`,{className:`relative flex-1`,children:[(0,$.jsx)(R,{className:`absolute left-2 top-2 h-4 w-4 text-muted-foreground`}),(0,$.jsx)(U,{placeholder:`Buscar modelo...`,className:`h-8 pl-8 text-sm`,value:r,onChange:e=>o(e.target.value)})]}),(0,$.jsxs)(s,{value:u,onValueChange:d,children:[(0,$.jsx)(l,{className:`h-8 w-40 text-sm`,children:(0,$.jsx)(a,{placeholder:`Provider`})}),(0,$.jsxs)(c,{children:[(0,$.jsx)(i,{value:`all`,children:`Todos`}),t.map(e=>(0,$.jsx)(i,{value:e.id,children:e.name},e.id))]})]})]}),(0,$.jsx)(z,{className:`h-[calc(100vh-22rem)]`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[f.map(e=>(0,$.jsx)(Ve,{model:e},e.id)),f.length===0&&(0,$.jsx)(`div`,{className:`hive-empty-state`,children:`No hay modelos de texto disponibles.`})]})})]})]})}var Qe=I,$e=oe,et=_,tt=M,nt=ce;function rt(){let{providers:e,createProvider:t}=V(),[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)(ye,{open:n,onOpenChange:e=>{r(e)},children:[(0,$.jsx)(me,{asChild:!0,children:(0,$.jsxs)(`button`,{className:`hive-btn hive-btn--primary`,children:[(0,$.jsx)(Qe,{className:`mr-1 h-4 w-4`}),`Añadir Provider`]})}),(0,$.jsxs)(_e,{className:`max-w-md`,children:[(0,$.jsxs)(ge,{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)(ve,{className:`text-xl font-black text-white uppercase tracking-tighter`,children:`Añadir Provider`}),(0,$.jsx)(he,{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)(Re,{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)(ee,{value:i,onValueChange:a,className:`w-full`,children:[(0,$.jsxs)(E,{className:`w-full grid grid-cols-4 h-10`,children:[(0,$.jsxs)(j,{value:`text`,className:`gap-1.5 text-xs`,children:[(0,$.jsx)($e,{className:`h-3.5 w-3.5`}),`Texto`]}),(0,$.jsxs)(j,{value:`vision`,className:`gap-1.5 text-xs`,children:[(0,$.jsx)(et,{className:`h-3.5 w-3.5`}),`Imagen`]}),(0,$.jsxs)(j,{value:`voice`,className:`gap-1.5 text-xs`,children:[(0,$.jsx)(tt,{className:`h-3.5 w-3.5`}),`Voz`]}),(0,$.jsxs)(j,{value:`providers`,className:`gap-1.5 text-xs`,children:[(0,$.jsx)(nt,{className:`h-3.5 w-3.5`}),`Providers`]})]}),(0,$.jsx)(S,{value:`text`,className:`mt-4`,children:(0,$.jsx)(Ze,{})}),(0,$.jsx)(S,{value:`vision`,className:`mt-4`,children:(0,$.jsx)(Ue,{})}),(0,$.jsx)(S,{value:`voice`,className:`mt-4`,children:(0,$.jsx)(Je,{})}),(0,$.jsx)(S,{value:`providers`,className:`mt-4`,children:(0,$.jsx)(Le,{})})]})]})}export{rt as ProvidersPage};
|