@johpaz/hive-agents 0.0.33 → 0.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/README.md +16 -16
  2. package/dist/hive.js +1426 -1496
  3. package/dist/ui/assets/AgentCreateForm-B4eK7efF.js +1 -0
  4. package/dist/ui/assets/AgentDetailPage-BD2uoJWk.js +1 -0
  5. package/dist/ui/assets/AgentNewPage-GB-tVN50.js +1 -0
  6. package/dist/ui/assets/{AgentsPage-DhCjvDNa.js → AgentsPage-4JUZXvkA.js} +5 -5
  7. package/dist/ui/assets/{BridgePage-BD93aBKM.js → BridgePage-DDcDILKu.js} +1 -1
  8. package/dist/ui/assets/{CanvasPage-CM35yj0Q.js → CanvasPage-oOk2sGOD.js} +7 -7
  9. package/dist/ui/assets/ChannelsPage-BUn7-nhV.js +8 -0
  10. package/dist/ui/assets/DashboardPage-DV_2qWYJ.js +6 -0
  11. package/dist/ui/assets/{LoginPage-B30OrEBy.js → LoginPage-C8j_urUD.js} +1 -1
  12. package/dist/ui/assets/{LogsPage-DqUsG3MW.js → LogsPage-DayYjh01.js} +1 -1
  13. package/dist/ui/assets/{MeetingPage-C5B8-IzE.js → MeetingPage-C01uPuqj.js} +1 -1
  14. package/dist/ui/assets/{NotFound-HD1Yp9yK.js → NotFound-Drh-sJPN.js} +1 -1
  15. package/dist/ui/assets/ProjectsPage-B8_am_Ib.js +1 -0
  16. package/dist/ui/assets/ProvidersPage-DBzi66e4.js +1 -0
  17. package/dist/ui/assets/{RecoverPage-CLF6buGP.js → RecoverPage-DNb1Pr8h.js} +1 -1
  18. package/dist/ui/assets/SettingsPage-CFA_Tknl.js +9 -0
  19. package/dist/ui/assets/SetupPage-BrUWbhvT.js +1 -0
  20. package/dist/ui/assets/{WebChatPage-Um3VANzn.js → WebChatPage-R-YOwA4F.js} +2 -2
  21. package/dist/ui/assets/{accordion-BEVqJf2A.js → accordion-DdAEfIXR.js} +1 -1
  22. package/dist/ui/assets/{activity-SfJ6UDF2.js → activity-c3pNngT_.js} +1 -1
  23. package/dist/ui/assets/alert-U8FsgWi7.js +1 -0
  24. package/dist/ui/assets/{alert-dialog-M893TdvF.js → alert-dialog-CRdMkkmk.js} +1 -1
  25. package/dist/ui/assets/arrow-left-CBcbX5EZ.js +1 -0
  26. package/dist/ui/assets/badge-Cli1jnH5.js +1 -0
  27. package/dist/ui/assets/{calendar-CMMeWsP-.js → calendar-B-KZ9RQO.js} +1 -1
  28. package/dist/ui/assets/{card-C7P3W6_y.js → card-DFKnZ6ky.js} +1 -1
  29. package/dist/ui/assets/chevron-down-DIosfU_U.js +1 -0
  30. package/dist/ui/assets/chevron-left-D4U-5A27.js +1 -0
  31. package/dist/ui/assets/chevron-right-CR4Skrf3.js +1 -0
  32. package/dist/ui/assets/chevron-up-CI-W21Fy.js +1 -0
  33. package/dist/ui/assets/circle-S0-ouLz-.js +1 -0
  34. package/dist/ui/assets/{circle-alert-7koABcbO.js → circle-alert-KuAm2FWh.js} +1 -1
  35. package/dist/ui/assets/circle-check-6Ard1-2z.js +1 -0
  36. package/dist/ui/assets/circle-minus-CE0iJrl8.js +1 -0
  37. package/dist/ui/assets/{circle-x-Cm3Sr-xb.js → circle-x-jUJ5zZvQ.js} +1 -1
  38. package/dist/ui/assets/{cpu-mBJgRJzM.js → cpu-KDy6-FAI.js} +1 -1
  39. package/dist/ui/assets/dialog-DQ3s-LuO.js +1 -0
  40. package/dist/ui/assets/{download-oaofq4K1.js → download-Cjbk4Rek.js} +1 -1
  41. package/dist/ui/assets/{dropdown-menu-DJoOchfz.js → dropdown-menu-C2CXM1VE.js} +1 -1
  42. package/dist/ui/assets/{es-eUrU2hyB.js → es-DcMjrpbA.js} +1 -1
  43. package/dist/ui/assets/{external-link-SkkF2Z7B.js → external-link-HtrFM63g.js} +1 -1
  44. package/dist/ui/assets/{eye-B8lq7sWG.js → eye-D1dB40_o.js} +1 -1
  45. package/dist/ui/assets/{file-text-0oYol8Bb.js → file-text-CE58EfH0.js} +1 -1
  46. package/dist/ui/assets/{folder-open-DVYu2lgk.js → folder-open-DIPKeiI_.js} +1 -1
  47. package/dist/ui/assets/gauge-DmQmJHEg.js +1 -0
  48. package/dist/ui/assets/{globe-BVPd5DRa.js → globe-_hUGxQF4.js} +1 -1
  49. package/dist/ui/assets/{hexagon-BIAFUAlQ.js → hexagon-BaNGQlQj.js} +1 -1
  50. package/dist/ui/assets/{history-BUAnaMQo.js → history-BfZVGlZa.js} +1 -1
  51. package/dist/ui/assets/index-CH6sBa3Q.js +116 -0
  52. package/dist/ui/assets/{info-DWioleen.js → info-CBZ5-AlC.js} +1 -1
  53. package/dist/ui/assets/{key-BCGwSKKc.js → key-Bv5DdTPh.js} +1 -1
  54. package/dist/ui/assets/label-0BvGVXvZ.js +1 -0
  55. package/dist/ui/assets/loader-circle-C4hhXLgp.js +1 -0
  56. package/dist/ui/assets/{lock-D7PCO7GC.js → lock-CkZYexqw.js} +1 -1
  57. package/dist/ui/assets/{pause-CI1JFH6r.js → pause-Bpy1_s7y.js} +1 -1
  58. package/dist/ui/assets/{pencil-BF2_XX-i.js → pencil-5VdSj-h5.js} +1 -1
  59. package/dist/ui/assets/play-Cj4osqJZ.js +1 -0
  60. package/dist/ui/assets/plus-BQhgZN3A.js +1 -0
  61. package/dist/ui/assets/{progress-B1HC9cB_.js → progress-JN30I5fF.js} +1 -1
  62. package/dist/ui/assets/{refresh-cw-BLmKlO4J.js → refresh-cw-BfREHVQM.js} +1 -1
  63. package/dist/ui/assets/{save-M1nv6H3P.js → save-FFTD4dMp.js} +1 -1
  64. package/dist/ui/assets/{scroll-area-DKNpYkRA.js → scroll-area-BQQPitM8.js} +1 -1
  65. package/dist/ui/assets/search-ChPgnVKj.js +1 -0
  66. package/dist/ui/assets/{send-ijRfR0gp.js → send-B0H5SEIE.js} +1 -1
  67. package/dist/ui/assets/{settings-BvXhlJCF.js → settings-BdHKUL92.js} +1 -1
  68. package/dist/ui/assets/{slider-DrDFLwXh.js → slider-D47dOrRa.js} +1 -1
  69. package/dist/ui/assets/{sparkles-C4MACMbE.js → sparkles-r4uJbJAl.js} +1 -1
  70. package/dist/ui/assets/{square-D_-gRT1l.js → square-G7Hyufqm.js} +1 -1
  71. package/dist/ui/assets/{switch-7AuR7x2g.js → switch-C7W2-KEx.js} +1 -1
  72. package/dist/ui/assets/{table-DWEJJiuF.js → table-DhowbNxQ.js} +1 -1
  73. package/dist/ui/assets/terminal-C-R5Fckz.js +1 -0
  74. package/dist/ui/assets/{textarea-CwPvQVAG.js → textarea-5kyuD04X.js} +1 -1
  75. package/dist/ui/assets/{trash-2-Blkv31Dz.js → trash-2-DXVBRWfh.js} +1 -1
  76. package/dist/ui/assets/{triangle-alert-BKgbd30k.js → triangle-alert-Bu5seg9O.js} +1 -1
  77. package/dist/ui/assets/useProviders-TBnWn-Hq.js +1 -0
  78. package/dist/ui/assets/{volume-2-BiUgObeI.js → volume-2-s9DuS696.js} +1 -1
  79. package/dist/ui/assets/{zap-CpyuQJEC.js → zap-BPHZzXKV.js} +1 -1
  80. package/dist/ui/index.html +4 -8
  81. package/package.json +1 -3
  82. package/dist/ui/assets/AgentCreateForm-DS6yXjGV.js +0 -1
  83. package/dist/ui/assets/AgentDetailPage-Ud552U7_.js +0 -1
  84. package/dist/ui/assets/AgentNewPage-DWWs1P7s.js +0 -1
  85. package/dist/ui/assets/ChannelsPage-CtsWtJdc.js +0 -8
  86. package/dist/ui/assets/DashboardPage-BpiwR5Jg.js +0 -6
  87. package/dist/ui/assets/ProjectsPage-zic2sjUf.js +0 -1
  88. package/dist/ui/assets/ProvidersPage-BxyIGKzh.js +0 -1
  89. package/dist/ui/assets/SettingsPage-CNFm3nun.js +0 -9
  90. package/dist/ui/assets/SetupPage-RBcjQtv7.js +0 -1
  91. package/dist/ui/assets/alert-BeGcM0nb.js +0 -1
  92. package/dist/ui/assets/api-q5Ax-vD2.js +0 -63
  93. package/dist/ui/assets/arrow-left-B_jlw8X_.js +0 -1
  94. package/dist/ui/assets/badge-pNhtItyt.js +0 -1
  95. package/dist/ui/assets/chevron-down-B16UVNlu.js +0 -1
  96. package/dist/ui/assets/chevron-left-_8ly7Fz0.js +0 -1
  97. package/dist/ui/assets/chevron-right-yzZLjezG.js +0 -1
  98. package/dist/ui/assets/chevron-up-CxKDQEE5.js +0 -1
  99. package/dist/ui/assets/circle-CFKiO9Ds.js +0 -1
  100. package/dist/ui/assets/circle-check-E2u7ZS2r.js +0 -1
  101. package/dist/ui/assets/circle-minus-1-TZF2pu.js +0 -1
  102. package/dist/ui/assets/dialog-BaJbZsQF.js +0 -1
  103. package/dist/ui/assets/dist-DB-fE0Co.js +0 -1
  104. package/dist/ui/assets/gauge-BTpFKuAj.js +0 -1
  105. package/dist/ui/assets/index-D4pdc0Uw.js +0 -54
  106. package/dist/ui/assets/label-C6tqnnKd.js +0 -1
  107. package/dist/ui/assets/loader-circle-CK3qRV3f.js +0 -1
  108. package/dist/ui/assets/play-DidATMfT.js +0 -1
  109. package/dist/ui/assets/plus-DXm1XDhQ.js +0 -1
  110. package/dist/ui/assets/search-Co6mulZS.js +0 -1
  111. package/dist/ui/assets/terminal-CjZu0OZ0.js +0 -1
  112. package/dist/ui/assets/useProviders-Bxsnav4y.js +0 -1
  113. package/dist/ui/assets/useWebSocketStore-ZCW_Nt1w.js +0 -1
  114. package/dist/ui/assets/x-5cXW_1ZS.js +0 -1
  115. /package/dist/ui/assets/{format-C0EOLKvf.js → format-BwdV8bB5.js} +0 -0
  116. /package/dist/ui/assets/{gateway-url-OqLaEDK-.js → gateway-url-D5uj6Nxg.js} +0 -0
  117. /package/dist/ui/assets/{utils-_qMjiZaF.js → utils-3pnRFmFe.js} +0 -0
  118. /package/dist/ui/assets/{vendor-router-DhLEd920.js → vendor-router-CCECILJ0.js} +0 -0
@@ -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-_qMjiZaF.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-7AuR7x2g.js";import{t as p}from"./circle-alert-7koABcbO.js";import{t as m}from"./circle-check-E2u7ZS2r.js";import{n as h,t as g}from"./eye-B8lq7sWG.js";import{t as _}from"./loader-circle-CK3qRV3f.js";import{t as v}from"./plus-DXm1XDhQ.js";import{t as ee}from"./refresh-cw-BLmKlO4J.js";import{t as y}from"./settings-BvXhlJCF.js";import{t as b}from"./x-5cXW_1ZS.js";import{t as x}from"./zap-CpyuQJEC.js";import{c as S}from"./vendor-router-DhLEd920.js";import{t as C}from"./api-q5Ax-vD2.js";import{E as w,R as te,T,d as ne,n as re,z as ie}from"./index-D4pdc0Uw.js";import{t as E}from"./label-C6tqnnKd.js";import{n as ae,t as oe}from"./alert-BeGcM0nb.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)(te,{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=S(),{createChannel:x,reconnectChannel:te,fetchChannels:ie}=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 C(`/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),C(`/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 C(`/api/channels/${e}/${t}/status`,{showError:!1});n.status===`qr`&&n.qrCode?(H(n.qrCode),U(!1),j(`qr`)):n.status===`connected`?(Q(),await ie(),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,ie]),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 te(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 x(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 te(e.id,t)}await r(e.id,J),e.type===`whatsapp`&&await C(`/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)(b,{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)(b,{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)(ie,{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)(x,{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)(ie,{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,6 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as t,a as n,f as r,l as i,m as a,o,p as s,r as c,s as l,t as u,u as d}from"./vendor-charts-Bu2lyBKP.js";import{i as f,n as p,o as m,t as h}from"./vendor-query-DsWPbQdG.js";import{r as g}from"./utils-_qMjiZaF.js";import{t as _}from"./activity-SfJ6UDF2.js";import{t as v}from"./circle-check-E2u7ZS2r.js";import{t as y}from"./download-oaofq4K1.js";import{t as ee}from"./external-link-SkkF2Z7B.js";import{t as te}from"./gauge-BTpFKuAj.js";import{t as ne}from"./info-DWioleen.js";import{t as b}from"./loader-circle-CK3qRV3f.js";import{t as re}from"./triangle-alert-BKgbd30k.js";import{t as x}from"./zap-CpyuQJEC.js";import{r as S,t as C}from"./api-q5Ax-vD2.js";import{E as ie,H as w,L as T,R as ae,V as E,g as D,t as oe,z as O}from"./index-D4pdc0Uw.js";import{t as k}from"./badge-pNhtItyt.js";import{a as A,n as j,o as M,r as N,t as P}from"./card-C7P3W6_y.js";import{t as F}from"./progress-B1HC9cB_.js";import{a as I,c as L,i as R,n as z,o as B,r as V,s as H,t as U}from"./alert-dialog-M893TdvF.js";var W=g(`ArrowUpRight`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),G=g(`CircleArrowUp`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]]),K=g(`DollarSign`,[[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`22`,key:`7eqyqh`}],[`path`,{d:`M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6`,key:`1b0p4s`}]]),se=g(`HardDrive`,[[`line`,{x1:`22`,x2:`2`,y1:`12`,y2:`12`,key:`1y58io`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}],[`line`,{x1:`6`,x2:`6.01`,y1:`16`,y2:`16`,key:`sgf278`}],[`line`,{x1:`10`,x2:`10.01`,y1:`16`,y2:`16`,key:`1l4acy`}]]),ce=g(`Hash`,[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]),le=g(`MemoryStick`,[[`path`,{d:`M6 19v-3`,key:`1nvgqn`}],[`path`,{d:`M10 19v-3`,key:`iu8nkm`}],[`path`,{d:`M14 19v-3`,key:`kcehxu`}],[`path`,{d:`M18 19v-3`,key:`1vh91z`}],[`path`,{d:`M8 11V9`,key:`63erz4`}],[`path`,{d:`M16 11V9`,key:`fru6f3`}],[`path`,{d:`M12 11V9`,key:`ha00sb`}],[`path`,{d:`M2 15h20`,key:`16ne18`}],[`path`,{d:`M2 7a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1.1a2 2 0 0 0 0 3.837V17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5.1a2 2 0 0 0 0-3.837Z`,key:`lhddv3`}]]),ue=g(`TrendingUp`,[[`polyline`,{points:`22 7 13.5 15.5 8.5 10.5 2 17`,key:`126l90`}],[`polyline`,{points:`16 7 22 7 22 13`,key:`kwv8wd`}]]),q=e(t(),1);function de(){let{agents:e,isLoading:t,error:n,fetchAgents:r,createAgent:i,updateAgent:a,deleteAgent:o}=oe(),[s,c]=(0,q.useState)(`all`);return(0,q.useEffect)(()=>{r()},[r]),{agents:(0,q.useMemo)(()=>Array.isArray(e)?s===`all`?e:e.filter(e=>e.status===s):[],[e,s]),allAgents:e||[],filter:s,setFilter:c,createAgent:i,updateAgent:a,deleteAgent:o,isLoading:t,error:n,refreshAgents:r}}var J=m();function fe(e){return e<50?`#22c55e`:e<80?`#eab308`:`#ef4444`}function pe(){let[e,t]=(0,q.useState)(()=>{let e=new Date;return Array.from({length:12},(t,n)=>({time:new Date(e.getTime()-(11-n)*5e3).toLocaleTimeString(`es`,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}),msgs:0,rss:0}))}),[r,i]=(0,q.useState)([]),{data:a}=p({queryKey:[`system-stats`],queryFn:()=>C(`/api/system-stats`),refetchInterval:5e3}),c=(0,q.useRef)(a);(0,q.useEffect)(()=>{c.current=a},[a]),(0,q.useEffect)(()=>{let e=setInterval(()=>{let e=c.current;if(!e)return;let n=new Date().toLocaleTimeString(`es`,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`});t(t=>[...t,{time:n,msgs:e.recentMessages,rss:e.memory.rss}].slice(-20))},5e3);return()=>clearInterval(e)},[]);let d=a?.memory.rss??0,f=a?.memory.heapUsed??0,m=a?.memory.external??0,h=a?.recentMessages??0;return(0,J.jsxs)(`div`,{className:`flex flex-col gap-4 mb-4`,children:[(0,J.jsxs)(P,{className:`overflow-hidden border-primary/10`,children:[(0,J.jsx)(A,{className:`pb-2 bg-gradient-to-r from-primary/5 to-transparent`,children:(0,J.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,J.jsxs)(M,{className:`text-base flex items-center gap-2`,children:[(0,J.jsx)(te,{className:`h-4 w-4 text-primary`}),`Monitor del Proceso Hive`]})})}),(0,J.jsxs)(j,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-4 pt-4`,children:[(0,J.jsx)(Y,{icon:ae,label:`Actividad reciente`,value:`${h}`,subValue:`mensajes últimos 5 min`,color:h>0?`#22c55e`:`hsl(var(--muted-foreground))`,progress:Math.min(100,h*10)}),(0,J.jsx)(Y,{icon:se,label:`Memoria Hive (RSS)`,value:`${d} MB`,subValue:`Heap JS: ${f} MB usados`,color:fe(Math.min(100,Math.round(d/1024*100))),progress:Math.min(100,Math.round(d/1024*100))}),(0,J.jsx)(Y,{icon:le,label:`Heap JS`,value:`${f} MB`,subValue:`External: ${m} MB`,color:`#3b82f6`,progress:Math.min(100,Math.round(f/512*100))}),(0,J.jsx)(Y,{icon:T,label:`Sesiones WS activas`,value:`${a?.connections??0}`,subValue:`conexiones WebSocket`,color:`#a855f7`,progress:Math.min(100,(a?.connections??0)*10)})]})]}),(0,J.jsxs)(P,{className:`border-primary/10`,children:[(0,J.jsx)(A,{className:`pb-2`,children:(0,J.jsxs)(M,{className:`text-sm flex items-center gap-2`,children:[(0,J.jsx)(_,{className:`h-4 w-4 text-primary`}),`Historial — `,(0,J.jsx)(`span`,{className:`text-green-400`,children:`Mensajes`}),` · `,(0,J.jsx)(`span`,{className:`text-purple-400`,children:`RSS MB`})]})}),(0,J.jsx)(j,{className:`h-[160px]`,children:(0,J.jsx)(s,{width:`100%`,height:`100%`,children:(0,J.jsxs)(u,{data:e,children:[(0,J.jsxs)(`defs`,{children:[(0,J.jsxs)(`linearGradient`,{id:`gMsgs`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,J.jsx)(`stop`,{offset:`5%`,stopColor:`#22c55e`,stopOpacity:.3}),(0,J.jsx)(`stop`,{offset:`95%`,stopColor:`#22c55e`,stopOpacity:0})]}),(0,J.jsxs)(`linearGradient`,{id:`gHeap`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,J.jsx)(`stop`,{offset:`5%`,stopColor:`#8b5cf6`,stopOpacity:.3}),(0,J.jsx)(`stop`,{offset:`95%`,stopColor:`#8b5cf6`,stopOpacity:0})]})]}),(0,J.jsx)(o,{dataKey:`time`,axisLine:!1,tickLine:!1,tick:{fill:`hsl(var(--muted-foreground))`,fontSize:9},interval:`preserveStartEnd`}),(0,J.jsx)(n,{axisLine:!1,tickLine:!1,tick:{fill:`hsl(var(--muted-foreground))`,fontSize:9}}),(0,J.jsx)(l,{type:`monotone`,dataKey:`msgs`,stroke:`#22c55e`,strokeWidth:2,fillOpacity:1,fill:`url(#gMsgs)`,name:`Mensajes`}),(0,J.jsx)(l,{type:`monotone`,dataKey:`rss`,stroke:`#8b5cf6`,strokeWidth:2,fillOpacity:1,fill:`url(#gHeap)`,name:`RSS MB`})]})})})]})]})}function Y({icon:e,label:t,value:n,subValue:r,color:i,progress:a}){return(0,J.jsxs)(`div`,{className:`rounded-lg border bg-card/50 p-3 space-y-2`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{style:{color:i},children:(0,J.jsx)(e,{className:`h-4 w-4`})}),(0,J.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:t})]}),(0,J.jsx)(`span`,{className:`text-lg font-bold font-mono`,style:{color:i},children:n})]}),(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(`div`,{className:`h-1.5 w-full rounded-full bg-muted overflow-hidden`,children:(0,J.jsx)(`div`,{className:`h-full rounded-full transition-all duration-500`,style:{width:`${Math.min(a,100)}%`,backgroundColor:i}})}),(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r})]})]})}var X={anthropic:`#d97706`,openai:`#10b981`,google:`#3b82f6`,gemini:`#3b82f6`,deepseek:`#8b5cf6`,kimi:`#ec4899`,ollama:`#14b8a6`,openrouter:`#f59e0b`,mistral:`#6366f1`};function Z(e){return e>=1e6?(e/1e6).toFixed(2)+`M`:e>=1e3?(e/1e3).toFixed(1)+`K`:e.toString()}function Q(e){return e>=1?`$`+e.toFixed(2):e>=.01?`$`+e.toFixed(3):e>0?`$`+e.toFixed(5):`$0.00`}function $(e){return e>=10?e.toFixed(1)+`%`:e>=1?e.toFixed(2)+`%`:e>0?e.toFixed(3)+`%`:`0%`}function me(){let[e,t]=(0,q.useState)(24),{data:i,isLoading:l}=p({queryKey:[`usage-stats`,e],queryFn:async()=>await C(`/api/usage-stats?hours=${e}`),refetchInterval:6e4});if(l&&!i)return(0,J.jsxs)(P,{className:`border-primary/10`,children:[(0,J.jsx)(A,{children:(0,J.jsxs)(M,{className:`flex items-center gap-2`,children:[(0,J.jsx)(K,{className:`h-5 w-5 text-primary`}),`Uso y Costos de API`]})}),(0,J.jsx)(j,{children:(0,J.jsx)(`div`,{className:`h-40 flex items-center justify-center text-muted-foreground animate-pulse`,children:`Cargando estadísticas de uso...`})})]});let u=i&&(i.totalTokens>0||i.totalCostUsd>0),f=i?Object.entries(i.byProvider).map(([e,t])=>({name:e.charAt(0).toUpperCase()+e.slice(1),value:t.tokens,cost:t.costUsd,color:X[e.toLowerCase()]||`#6b7280`})):[],m=i?Object.entries(i.byModel).slice(0,8).map(([e,t])=>({name:e.length>20?e.slice(0,18)+`...`:e,tokens:t.tokens,cost:t.costUsd,fullName:e})):[];return(0,J.jsxs)(P,{className:`border-primary/10`,children:[(0,J.jsx)(A,{className:`pb-2`,children:(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(M,{className:`text-base flex items-center gap-2`,children:[(0,J.jsx)(K,{className:`h-5 w-5 text-primary`}),`Uso y Costos de API`]}),(0,J.jsx)(N,{children:`Tokens consumidos y costos por provider/modelo`})]}),(0,J.jsx)(`div`,{className:`flex gap-1`,children:[6,24,168].map(n=>(0,J.jsx)(`button`,{onClick:()=>t(n),className:`px-2 py-1 text-xs rounded-md transition-colors ${e===n?`bg-primary text-primary-foreground`:`bg-muted hover:bg-muted/80`}`,children:n===6?`6h`:n===24?`24h`:`7d`},n))})]})}),(0,J.jsxs)(j,{className:`space-y-4`,children:[(0,J.jsxs)(`div`,{className:`rounded-lg border p-3 ${i?.toonSavedTokens?`border-emerald-500/30 bg-emerald-500/5`:`bg-card/50`}`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,J.jsx)(x,{className:`h-3 w-3 ${i?.toonSavedTokens?`text-emerald-400`:``}`}),(0,J.jsx)(`span`,{className:`font-medium`,children:`TOON Optimización de Tokens`})]}),i?.toonSavingsPercent&&i.toonSavingsPercent>0?(0,J.jsxs)(`span`,{className:`text-xs font-bold text-emerald-400`,children:[$(i.toonSavingsPercent),` reducción`]}):null]}),(0,J.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 md:grid-cols-4 gap-3`,children:[(0,J.jsxs)(`div`,{className:`bg-emerald-500/5 rounded-md p-2`,children:[(0,J.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Tokens Ahorrados`}),(0,J.jsx)(`div`,{className:`text-lg font-bold ${i?.toonSavedTokens?`text-emerald-400`:`text-muted-foreground`}`,children:i?Z(i.toonSavedTokens):`—`})]}),(0,J.jsxs)(`div`,{className:`bg-emerald-500/5 rounded-md p-2`,children:[(0,J.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Costo Ahorrado`}),(0,J.jsx)(`div`,{className:`text-lg font-bold text-emerald-400`,children:i?Q(i.toonSavedCost):`—`})]}),(0,J.jsxs)(`div`,{className:`bg-emerald-500/5 rounded-md p-2`,children:[(0,J.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Bytes Ahorrados`}),(0,J.jsx)(`div`,{className:`text-lg font-bold text-emerald-400`,children:i&&i.toonSavedBytes>0?Z(i.toonSavedBytes):`—`})]}),(0,J.jsxs)(`div`,{className:`bg-emerald-500/5 rounded-md p-2`,children:[(0,J.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Reducción Bytes`}),(0,J.jsx)(`div`,{className:`text-lg font-bold text-emerald-400`,children:i?.toonSavedBytesPercent&&i.toonSavedBytesPercent>0?$(i.toonSavedBytesPercent):`—`})]})]}),i&&(i.toonJsonTokens>0||i.toonToonTokens>0)&&(0,J.jsx)(`div`,{className:`mt-3 pt-3 border-t border-emerald-500/20`,children:(0,J.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,J.jsxs)(`span`,{className:`text-muted-foreground`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`JSON:`}),` `,(0,J.jsx)(`span`,{className:`font-medium`,children:i.toonJsonTokens>0?Z(i.toonJsonTokens):`—`}),` `,(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`tokens`})]}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`→`}),(0,J.jsxs)(`span`,{className:`text-muted-foreground`,children:[(0,J.jsx)(`span`,{className:`text-emerald-400`,children:`TOON:`}),` `,(0,J.jsx)(`span`,{className:`font-medium text-emerald-400`,children:i.toonToonTokens>0?Z(i.toonToonTokens):`—`}),` `,(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`tokens`})]})]}),i?.toonSavingsPercent&&i.toonSavingsPercent>0?(0,J.jsxs)(`span`,{className:`text-xs font-bold text-emerald-400`,children:[$(i.toonSavingsPercent),` menos tokens`]}):null]})}),i&&!i.toonSavedTokens&&(0,J.jsx)(`div`,{className:`mt-2 text-xs text-muted-foreground italic`,children:`Sin optimizaciones TOON registradas aún`})]}),u?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[(0,J.jsxs)(`div`,{className:`rounded-lg border bg-card/50 p-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground mb-1`,children:[(0,J.jsx)(K,{className:`h-3 w-3`}),`Costo Total`]}),(0,J.jsx)(`div`,{className:`text-2xl font-bold text-green-500`,children:Q(i.totalCostUsd)})]}),(0,J.jsxs)(`div`,{className:`rounded-lg border bg-card/50 p-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground mb-1`,children:[(0,J.jsx)(ce,{className:`h-3 w-3`}),`Total Tokens`]}),(0,J.jsx)(`div`,{className:`text-2xl font-bold`,children:Z(i.totalTokens)})]}),(0,J.jsxs)(`div`,{className:`rounded-lg border bg-card/50 p-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground mb-1`,children:[(0,J.jsx)(ue,{className:`h-3 w-3`}),`Input / Output`]}),(0,J.jsxs)(`div`,{className:`text-lg font-semibold`,children:[(0,J.jsx)(`span`,{className:`text-blue-500`,children:Z(i.totalInputTokens)}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:` / `}),(0,J.jsx)(`span`,{className:`text-purple-500`,children:Z(i.totalOutputTokens)})]})]}),(0,J.jsxs)(`div`,{className:`rounded-lg border bg-card/50 p-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground mb-1`,children:[(0,J.jsx)(T,{className:`h-3 w-3`}),`Providers`]}),(0,J.jsx)(`div`,{className:`text-2xl font-bold`,children:Object.keys(i.byProvider).length})]})]}),(0,J.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`h4`,{className:`text-sm font-medium mb-2 flex items-center gap-2`,children:[(0,J.jsx)(T,{className:`h-4 w-4 text-muted-foreground`}),`Por Provider`]}),(0,J.jsx)(`div`,{className:`h-[180px]`,children:(0,J.jsx)(s,{width:`100%`,height:`100%`,children:(0,J.jsxs)(c,{data:f,layout:`vertical`,children:[(0,J.jsx)(o,{type:`number`,hide:!0}),(0,J.jsx)(n,{type:`category`,dataKey:`name`,axisLine:!1,tickLine:!1,tick:{fill:`hsl(var(--muted-foreground))`,fontSize:11},width:70}),(0,J.jsx)(a,{contentStyle:{backgroundColor:`hsl(var(--card))`,border:`1px solid hsl(var(--border))`,borderRadius:`8px`},formatter:(e,t)=>[t===`cost`?Q(e):Z(e),t===`cost`?`Costo`:`Tokens`]}),(0,J.jsx)(d,{dataKey:`value`,radius:[0,4,4,0],barSize:16,children:f.map(e=>(0,J.jsx)(r,{fill:e.color},e.name))})]})})})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`h4`,{className:`text-sm font-medium mb-2 flex items-center gap-2`,children:[(0,J.jsx)(w,{className:`h-4 w-4 text-muted-foreground`}),`Por Modelo (Top 8)`]}),(0,J.jsx)(`div`,{className:`h-[180px]`,children:(0,J.jsx)(s,{width:`100%`,height:`100%`,children:(0,J.jsxs)(c,{data:m,children:[(0,J.jsx)(o,{dataKey:`name`,axisLine:!1,tickLine:!1,tick:{fill:`hsl(var(--muted-foreground))`,fontSize:10},angle:-45,textAnchor:`end`,height:60}),(0,J.jsx)(n,{axisLine:!1,tickLine:!1,tick:{fill:`hsl(var(--muted-foreground))`,fontSize:10}}),(0,J.jsx)(a,{contentStyle:{backgroundColor:`hsl(var(--card))`,border:`1px solid hsl(var(--border))`,borderRadius:`8px`},formatter:e=>Q(e),labelFormatter:e=>m.find(t=>t.name===e)?.fullName||e}),(0,J.jsx)(d,{dataKey:`cost`,radius:[4,4,0,0],children:m.map(e=>(0,J.jsx)(r,{fill:X[e.fullName.split(`-`)[0]?.toLowerCase()]||`#6b7280`},e.fullName))})]})})})]})]}),f.length>0&&(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h4`,{className:`text-sm font-medium mb-2`,children:`Detalle por Provider`}),(0,J.jsx)(`div`,{className:`rounded-lg border overflow-hidden`,children:(0,J.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,J.jsx)(`thead`,{className:`bg-muted/50`,children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{className:`text-left p-2 font-medium`,children:`Provider`}),(0,J.jsx)(`th`,{className:`text-right p-2 font-medium`,children:`Input`}),(0,J.jsx)(`th`,{className:`text-right p-2 font-medium`,children:`Output`}),(0,J.jsx)(`th`,{className:`text-right p-2 font-medium`,children:`Total`}),(0,J.jsx)(`th`,{className:`text-right p-2 font-medium`,children:`Costo`})]})}),(0,J.jsx)(`tbody`,{children:Object.entries(i.byProvider).map(([e,t])=>(0,J.jsxs)(`tr`,{className:`border-t`,children:[(0,J.jsx)(`td`,{className:`p-2 font-medium`,children:e}),(0,J.jsx)(`td`,{className:`p-2 text-right text-blue-500`,children:Z(t.inputTokens)}),(0,J.jsx)(`td`,{className:`p-2 text-right text-purple-500`,children:Z(t.outputTokens)}),(0,J.jsx)(`td`,{className:`p-2 text-right`,children:Z(t.tokens)}),(0,J.jsx)(`td`,{className:`p-2 text-right font-medium text-green-500`,children:Q(t.costUsd)})]},e))})]})})]})]}):(0,J.jsx)(`div`,{className:`h-32 flex items-center justify-center text-muted-foreground`,children:(0,J.jsxs)(`div`,{className:`text-center`,children:[(0,J.jsx)(_,{className:`h-8 w-8 mx-auto mb-2 opacity-50`}),(0,J.jsx)(`p`,{children:`No hay datos de uso aún`}),(0,J.jsx)(`p`,{className:`text-xs`,children:`Los tokens se registrarán automáticamente`})]})})]})]})}function he(){let[e,t]=(0,q.useState)(!1),[n,r]=(0,q.useState)(0),[i,a]=(0,q.useState)([]),o=f(),{data:s,isLoading:c}=p({queryKey:[`version-check`],queryFn:()=>C(`/api/version`),refetchInterval:3e5,retry:2}),l=h({mutationFn:()=>C(`/api/update`,{method:`POST`,showLoader:`Actualizando Hive...`}),onSuccess:e=>{r(100),e.success?(a(e.instructions||[]),S.fire({title:`¡Actualización Completada!`,text:e.message||`Hive ha sido actualizado exitosamente.`,icon:`success`,confirmButtonText:`Continuar`})):(e.instructions&&a(e.instructions),S.fire({title:`Información de Actualización`,html:`
2
- <div class="text-left space-y-2">
3
- ${e.error?`<p class="mb-2">${e.error}</p>`:``}
4
- ${e.output?`<pre class="bg-muted p-2 rounded text-xs overflow-auto max-h-40">${e.output}</pre>`:``}
5
- </div>
6
- `,icon:e.instructions?`info`:`error`,confirmButtonText:`Entendido`})),setTimeout(()=>{o.invalidateQueries({queryKey:[`version-check`]})},2e3)},onError:e=>{r(0),console.error(`[UpdateChecker] Error:`,e)}}),u=()=>{t(!0)},d=()=>{t(!1),r(10),l.mutate();let e=setInterval(()=>{r(t=>t>=90?(clearInterval(e),t):t+10)},500)},m=e=>{switch(e){case`docker`:return`Docker`;case`binary`:return`Binario`;case`npm`:return`npm`;case`bun`:return`Bun`;default:return`Desconocida`}},g=()=>{if(!s)return null;switch(s.status){case`up-to-date`:return(0,J.jsxs)(k,{variant:`outline`,className:`flex items-center gap-1 bg-green-500/10 text-green-400 border-green-500/20`,children:[(0,J.jsx)(v,{className:`h-3 w-3`}),`Actualizado`]});case`update-available`:return(0,J.jsxs)(k,{className:`flex items-center gap-1 bg-blue-500 text-white border-blue-400 hover:bg-blue-600`,children:[(0,J.jsx)(G,{className:`h-3 w-3`}),`v`,s.latest,` disponible`]});case`checking`:return(0,J.jsxs)(k,{variant:`outline`,className:`flex items-center gap-1`,children:[(0,J.jsx)(b,{className:`h-3 w-3 animate-spin`}),`Verificando...`]});case`error`:return(0,J.jsxs)(k,{variant:`destructive`,className:`flex items-center gap-1`,children:[(0,J.jsx)(re,{className:`h-3 w-3`}),`Error`]})}},_=s?.status===`update-available`;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[(0,J.jsx)(`span`,{className:`hive-label mb-1`,children:`Versión`}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[g(),s&&(0,J.jsxs)(`span`,{className:`text-xs text-white/40 font-mono`,children:[`v`,s.current,` · `,m(s.installationType)]})]})]}),_&&(0,J.jsx)(ie,{size:`sm`,onClick:u,disabled:l.isPending,className:`bg-blue-600 hover:bg-blue-700 text-white shadow-lg shadow-blue-500/20`,children:l.isPending?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(b,{className:`h-4 w-4 mr-2 animate-spin`}),`Actualizando...`]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(y,{className:`h-4 w-4 mr-2`}),`Actualizar a v`,s.latest]})}),(0,J.jsx)(U,{open:e,onOpenChange:t,children:(0,J.jsxs)(R,{children:[(0,J.jsxs)(H,{children:[(0,J.jsxs)(L,{className:`flex items-center gap-2`,children:[(0,J.jsx)(y,{className:`h-5 w-5 text-blue-500`}),`Actualizar Hive`]}),(0,J.jsxs)(I,{className:`space-y-3`,children:[(0,J.jsxs)(`p`,{children:[`Se ha detectado una nueva versión disponible (`,(0,J.jsxs)(`strong`,{children:[`v`,s?.latest]}),`). Tu versión actual es `,(0,J.jsxs)(`strong`,{children:[`v`,s?.current]}),`.`]}),(0,J.jsx)(`div`,{className:`bg-muted p-3 rounded-lg space-y-2`,children:(0,J.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,J.jsx)(ne,{className:`h-4 w-4 text-blue-500 mt-0.5`}),(0,J.jsxs)(`div`,{className:`text-sm`,children:[(0,J.jsxs)(`p`,{className:`font-semibold mb-1`,children:[`Tipo de instalación: `,m(s?.installationType)]}),s?.installationType===`docker`&&(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:`Para Docker, deberás ejecutar manualmente los comandos en tu terminal.`}),s?.installationType===`binary`&&(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:`Para el binario, serás redirigido a GitHub Releases para descargar la nueva versión.`}),(s?.installationType===`npm`||s?.installationType===`bun`)&&(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:`La actualización se realizará automáticamente. Deberás reiniciar el gateway después.`})]})]})}),l.isPending&&(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between text-sm`,children:[(0,J.jsx)(`span`,{children:`Progreso de actualización...`}),(0,J.jsxs)(`span`,{className:`text-muted-foreground`,children:[n,`%`]})]}),(0,J.jsx)(F,{value:n,className:`h-2`})]})]})]}),(0,J.jsxs)(B,{children:[(0,J.jsx)(V,{disabled:l.isPending,children:`Cancelar`}),(0,J.jsx)(z,{onClick:d,disabled:l.isPending,className:`bg-blue-600 hover:bg-blue-700`,children:l.isPending?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(b,{className:`h-4 w-4 mr-2 animate-spin`}),`Actualizando...`]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(y,{className:`h-4 w-4 mr-2`}),`Confirmar actualización`]})})]})]})}),i.length>0&&(0,J.jsx)(U,{open:!0,onOpenChange:()=>a([]),children:(0,J.jsxs)(R,{children:[(0,J.jsxs)(H,{children:[(0,J.jsx)(L,{children:`Instrucciones de Actualización`}),(0,J.jsxs)(I,{className:`space-y-3`,children:[(0,J.jsx)(`p`,{children:`Sigue estos pasos para completar la actualización:`}),(0,J.jsx)(`ol`,{className:`list-decimal list-inside space-y-2 bg-muted p-4 rounded-lg`,children:i.map((e,t)=>(0,J.jsx)(`li`,{className:`text-sm`,children:e},t))}),(0,J.jsxs)(`div`,{className:`flex items-start gap-2 text-xs text-muted-foreground`,children:[(0,J.jsx)(ee,{className:`h-4 w-4 mt-0.5`}),(0,J.jsx)(`p`,{children:`Después de completar los pasos, recarga esta página para ver la nueva versión.`})]})]})]}),(0,J.jsx)(B,{children:(0,J.jsx)(z,{children:`Entendido`})})]})})]})}function ge({icon:e,...t}){return(0,J.jsx)(e,{...t})}function _e(){let{status:e}=D(),{allAgents:t}=de(),{data:f}=p({queryKey:[`system-stats`],queryFn:()=>C(`/api/system-stats`),refetchInterval:5e3}),{data:m=[]}=p({queryKey:[`activity-stats`],queryFn:()=>C(`/api/activity-stats?hours=12`),refetchInterval:6e4}),h=(0,q.useMemo)(()=>t||[],[t]),g=[{label:`Agentes Activos`,value:h.length,icon:w,color:`text-blue-500`,trend:`${h.filter(e=>e.status===`active`||e.status===`thinking`).length} en uso`},{label:`Sesiones Canvas`,value:f?.connections??0,icon:O,color:`text-orange-500`,trend:`Live`},{label:`Procesos Bridge`,value:h.filter(e=>e.status===`thinking`).length,icon:E,color:`text-purple-500`,trend:`Estable`},{label:`Mensajes / 1h`,value:m.at(-1)?.count??0,icon:_,color:`text-green-500`,trend:`Última hora`}],v=(0,q.useMemo)(()=>{let e=h.filter(e=>e.status===`idle`||e.status===`hibernated`).length,t=h.filter(e=>e.status===`active`).length,n=h.filter(e=>e.status===`thinking`).length,r=h.filter(e=>e.status===`error`).length;return[{name:`Idle`,value:e||0,color:`hsl(var(--muted))`},{name:`Active`,value:t||0,color:`hsl(var(--primary))`},{name:`Thinking`,value:n||0,color:`hsl(var(--accent))`},...r>0?[{name:`Error`,value:r,color:`#ef4444`}]:[]].filter(e=>e.value>0||e.name===`Idle`)},[h]),y=m.reduce((e,t)=>e+t.count,0);return f?.memory?.percentage&&Math.max(0,Math.round(100-f.memory.percentage*.3-(f.cpu||0)*.2)),(0,J.jsxs)(`div`,{className:`hive-page-container`,children:[(0,J.jsxs)(`div`,{className:`hive-page-header`,children:[(0,J.jsxs)(`div`,{className:`relative z-10`,children:[(0,J.jsxs)(`div`,{className:`hive-page-header__eyebrow`,children:[(0,J.jsx)(`div`,{className:`hive-page-header__dot`}),(0,J.jsx)(`span`,{className:`hive-page-header__label`,children:`SISTEMA OPERATIVO HIVE`})]}),(0,J.jsxs)(`h2`,{className:`hive-title-page`,children:[`Centro de `,(0,J.jsx)(`span`,{className:`hive-title-page__accent`,children:`Control`})]}),(0,J.jsx)(`p`,{className:`hive-subtitle`,children:`Monitoreo en tiempo real del enjambre y estado de los nodos cognitivos.`})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-6 relative z-10`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col items-end`,children:[(0,J.jsx)(`span`,{className:`hive-label mb-1`,children:`Estado Hive`}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`div`,{className:e===`connected`?`hive-status-dot--active`:`hive-status-dot--disabled`}),(0,J.jsx)(`span`,{className:e===`connected`?`hive-status-label--active`:`hive-status-label--disabled`,children:e===`connected`?`EN LÍNEA`:`DESCONECTADO`})]})]}),(0,J.jsx)(`div`,{className:`h-10 w-px bg-white/10 hidden sm:block`}),(0,J.jsx)(he,{})]})]}),(0,J.jsx)(`div`,{className:`grid gap-6 sm:grid-cols-2 lg:grid-cols-4 mb-8`,children:g.map(e=>(0,J.jsxs)(`div`,{className:`hive-card hive-card--active group`,children:[(0,J.jsxs)(`div`,{className:`hive-card-body`,children:[(0,J.jsxs)(`div`,{className:`flex flex-row items-center justify-between mb-4`,children:[(0,J.jsx)(`span`,{className:`hive-title-section`,children:e.label}),(0,J.jsx)(`div`,{className:`p-2 rounded-lg bg-white/5 border border-white/5`,children:(0,J.jsx)(ge,{icon:e.icon,className:`h-4 w-4 ${e.color}`})})]}),(0,J.jsxs)(`div`,{className:`flex items-end justify-between`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-3xl font-black text-white group-hover:text-blue-400 transition-colors`,children:e.value}),(0,J.jsxs)(`p`,{className:`text-[10px] font-bold text-white/30 uppercase tracking-widest mt-1 flex items-center gap-1`,children:[(0,J.jsx)(W,{className:`h-2.5 w-2.5 text-green-500`}),e.trend]})]}),(0,J.jsx)(`div`,{className:`h-8 w-8 rounded-full border border-white/5 bg-white/5 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,J.jsx)(W,{className:`h-4 w-4 text-blue-400`})})]})]}),(0,J.jsx)(`div`,{className:`hive-strip--bottom`})]},e.label))}),(0,J.jsx)(pe,{}),(0,J.jsx)(me,{}),(0,J.jsxs)(`div`,{className:`grid gap-6 lg:grid-cols-3 mb-8`,children:[(0,J.jsx)(`div`,{className:`lg:col-span-2 hive-card`,children:(0,J.jsxs)(`div`,{className:`hive-card-body !pb-0`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between mb-6`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h3`,{className:`hive-title-section`,children:`Actividad del Enjambre`}),(0,J.jsxs)(`p`,{className:`text-[10px] text-white/40 uppercase tracking-widest font-bold`,children:[`Últimas 12 horas · `,y,` mensajes`]})]}),(0,J.jsx)(_,{className:`h-5 w-5 text-blue-500 animate-pulse shadow-blue-glow`})]}),(0,J.jsx)(`div`,{className:`h-[280px] w-full`,children:m.length>0?(0,J.jsx)(s,{width:`100%`,height:`100%`,children:(0,J.jsxs)(u,{data:m,children:[(0,J.jsx)(`defs`,{children:(0,J.jsxs)(`linearGradient`,{id:`colorCount`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,J.jsx)(`stop`,{offset:`5%`,stopColor:`#3b82f6`,stopOpacity:.2}),(0,J.jsx)(`stop`,{offset:`95%`,stopColor:`#3b82f6`,stopOpacity:0})]})}),(0,J.jsx)(i,{strokeDasharray:`3 3`,vertical:!1,stroke:`rgba(255,255,255,0.05)`}),(0,J.jsx)(o,{dataKey:`time`,axisLine:!1,tickLine:!1,tick:{fill:`rgba(255,255,255,0.3)`,fontSize:10,fontWeight:`bold`}}),(0,J.jsx)(n,{axisLine:!1,tickLine:!1,tick:{fill:`rgba(255,255,255,0.3)`,fontSize:10,fontWeight:`bold`},allowDecimals:!1}),(0,J.jsx)(a,{contentStyle:{backgroundColor:`#09090b`,borderRadius:`12px`,border:`1px solid rgba(255,255,255,0.1)`,color:`#fff`},itemStyle:{color:`#3b82f6`},formatter:e=>[e,`Mensajes`]}),(0,J.jsx)(l,{type:`monotone`,dataKey:`count`,stroke:`#3b82f6`,strokeWidth:4,fillOpacity:1,fill:`url(#colorCount)`})]})}):(0,J.jsx)(`div`,{className:`h-full flex items-center justify-center text-white/30 text-sm`,children:`Cargando actividad...`})})]})}),(0,J.jsx)(`div`,{className:`hive-card`,children:(0,J.jsxs)(`div`,{className:`hive-card-body`,children:[(0,J.jsx)(`h3`,{className:`hive-title-section mb-6`,children:`Distribución de Agentes`}),(0,J.jsx)(`div`,{className:`h-[210px]`,children:v.length>0?(0,J.jsx)(s,{width:`100%`,height:`100%`,children:(0,J.jsxs)(c,{data:v,layout:`vertical`,children:[(0,J.jsx)(o,{type:`number`,hide:!0,allowDecimals:!1}),(0,J.jsx)(n,{dataKey:`name`,type:`category`,axisLine:!1,tickLine:!1,tick:{fill:`rgba(255,255,255,0.5)`,fontSize:10,fontWeight:`bold`},width:70}),(0,J.jsx)(a,{cursor:{fill:`rgba(255,255,255,0.02)`}}),(0,J.jsx)(d,{dataKey:`value`,radius:[0,8,8,0],barSize:16,children:v.map(e=>(0,J.jsx)(r,{fill:e.color},e.name))})]})}):(0,J.jsx)(`div`,{className:`h-full flex items-center justify-center text-white/30 text-sm`,children:`Sin agentes configurados`})}),(0,J.jsxs)(`div`,{className:`mt-4 pt-4 border-t border-white/5 grid grid-cols-2 gap-4`,children:[(0,J.jsxs)(`div`,{className:`hive-stat`,children:[(0,J.jsx)(`span`,{className:`hive-stat__label`,children:`Salud Monitor`}),(0,J.jsx)(`span`,{className:`hive-stat__value hive-stat__value--active`,children:`Óptima`})]}),(0,J.jsxs)(`div`,{className:`hive-stat`,children:[(0,J.jsx)(`span`,{className:`hive-stat__label`,children:`Uptime`}),(0,J.jsx)(`span`,{className:`hive-stat__value hive-stat__value--active`,children:f?.uptime??`—`})]})]})]})})]})]})}export{_e as DashboardPage};
@@ -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"./chevron-down-B16UVNlu.js";import{t as i}from"./chevron-right-yzZLjezG.js";import{t as a}from"./circle-check-E2u7ZS2r.js";import{t as o}from"./circle-minus-1-TZF2pu.js";import{t as s}from"./circle-x-Cm3Sr-xb.js";import{t as c}from"./circle-CFKiO9Ds.js";import{t as l}from"./folder-open-DVYu2lgk.js";import{t as u}from"./loader-circle-CK3qRV3f.js";import{t as d}from"./refresh-cw-BLmKlO4J.js";import{r as f}from"./gateway-url-OqLaEDK-.js";import{t as p}from"./api-q5Ax-vD2.js";import{t as m}from"./badge-pNhtItyt.js";import{t as h}from"./progress-B1HC9cB_.js";var g=e(t(),1),_=f((e,t)=>({projects:[],isLoading:!1,fetchProjects:async t=>{e({isLoading:!0});try{let n=await p(t?`/api/projects?status=${t}`:`/api/projects`,{showLoader:!1,showError:!0}),r=[];Array.isArray(n)?r=n:`projects`in n?r=n.projects:`project`in n?r=n.project?[n.project]:[]:n&&typeof n==`object`&&`id`in n&&(r=[n]),e({projects:r})}catch(t){console.error(`[ProjectsStore] Error en fetchProjects:`,t),e({projects:[]})}finally{e({isLoading:!1})}},fetchActiveProjects:async()=>{e({isLoading:!0});try{let t=await p(`/api/projects/active`,{showLoader:!1,showError:!0}),n=[];Array.isArray(t)?n=t:`projects`in t?n=t.projects:`project`in t?n=t.project?[t.project]:[]:t&&typeof t==`object`&&`id`in t&&(n=[t]),e({projects:n})}catch(t){console.error(`[ProjectsStore] Error en fetchActiveProjects:`,t),e({projects:[]})}finally{e({isLoading:!1})}},updateTaskLocal:(t,n)=>{e(e=>({projects:e.projects.map(e=>({...e,tasks:e.tasks.map(e=>e.id===t?{...e,...n}:e)}))}))},updateProjectLocal:(t,n)=>{e(e=>({projects:e.projects.map(e=>e.id===t?{...e,...n}:e)}))}})),v=n();function y({icon:e,...t}){return(0,v.jsx)(e,{...t})}var b={code:`Código`,research:`Investigación`,content:`Contenido`,data:`Datos`,general:`General`},x={code:`bg-blue-500/10 text-blue-400 border-blue-500/20`,research:`bg-purple-500/10 text-purple-400 border-purple-500/20`,content:`bg-green-500/10 text-green-400 border-green-500/20`,data:`bg-orange-500/10 text-orange-400 border-orange-500/20`,general:`bg-gray-500/10 text-gray-400 border-gray-500/20`},S={active:`bg-green-500/10 text-green-400 border-green-500/20`,pending:`bg-yellow-500/10 text-yellow-400 border-yellow-500/20`,paused:`bg-gray-500/10 text-gray-400 border-gray-500/20`,done:`bg-blue-500/10 text-blue-400 border-blue-500/20`,failed:`bg-red-500/10 text-red-400 border-red-500/20`},C={active:`Activo`,pending:`Pendiente`,paused:`Pausado`,done:`Completado`,failed:`Fallido`,in_progress:`En progreso`,completed:`Completada`,blocked:`Bloqueada`};function w({status:e}){switch(e){case`completed`:return(0,v.jsx)(y,{icon:a,className:`h-3.5 w-3.5 text-green-400`});case`in_progress`:return(0,v.jsx)(y,{icon:u,className:`h-3.5 w-3.5 text-yellow-400 animate-spin`});case`failed`:return(0,v.jsx)(y,{icon:s,className:`h-3.5 w-3.5 text-red-400`});case`blocked`:return(0,v.jsx)(y,{icon:o,className:`h-3.5 w-3.5 text-orange-400`});default:return(0,v.jsx)(y,{icon:c,className:`h-3.5 w-3.5 text-muted-foreground`})}}function T({task:e}){return(0,v.jsxs)(`div`,{className:`flex items-center gap-3 py-1.5 px-3 rounded-md hover:bg-white/5 transition-colors group`,children:[(0,v.jsx)(w,{status:e.status}),(0,v.jsx)(`span`,{className:`text-sm flex-1 text-white/40 group-hover:text-white/80 transition-colors`,children:e.name}),e.description&&(0,v.jsx)(`span`,{className:`text-xs text-white/20 hidden sm:block max-w-[200px] truncate`,children:e.description}),(0,v.jsxs)(`div`,{className:`flex items-center gap-2 ml-auto`,children:[e.status===`in_progress`&&(0,v.jsx)(`div`,{className:`w-16`,children:(0,v.jsx)(h,{value:e.progress,className:`h-1`})}),(0,v.jsxs)(`span`,{className:`text-[11px] text-white/30 w-8 text-right`,children:[e.progress,`%`]})]})]})}function E({project:e}){let[t,n]=(0,g.useState)(e.status===`active`||e.status===`pending`);return(0,v.jsxs)(`div`,{className:`hive-card group overflow-hidden mt-10`,children:[(0,v.jsxs)(`button`,{className:`w-full flex items-center gap-3 p-4 hover:bg-white/5 transition-colors text-left`,onClick:()=>n(!t),children:[(0,v.jsx)(y,{icon:t?r:i,className:`h-4 w-4 text-white/30 shrink-0`}),(0,v.jsx)(y,{icon:l,className:`h-4 w-4 text-blue-400 shrink-0`}),(0,v.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,v.jsx)(`span`,{className:`font-medium text-sm text-white`,children:e.name}),(0,v.jsx)(m,{variant:`outline`,className:`text-[10px] px-1.5 py-0 ${x[e.type]??x.general}`,children:b[e.type]??e.type}),(0,v.jsx)(m,{variant:`outline`,className:`text-[10px] px-1.5 py-0 ${S[e.status]??``}`,children:C[e.status]??e.status})]}),e.description&&(0,v.jsx)(`p`,{className:`hive-subtitle !mt-0.5 truncate`,children:e.description})]}),(0,v.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,v.jsx)(`div`,{className:`w-20`,children:(0,v.jsx)(h,{value:e.progress,className:`h-1.5`})}),(0,v.jsxs)(`span`,{className:`text-xs text-white/30 w-8 text-right`,children:[e.progress,`%`]})]}),(e.tasks??[]).length>0&&(0,v.jsxs)(`span`,{className:`text-xs text-white/30`,children:[(e.tasks??[]).filter(e=>e.status===`completed`).length,`/`,(e.tasks??[]).length]})]})]}),t&&(e.tasks??[]).length>0&&(0,v.jsx)(`div`,{className:`border-t border-white/5 px-2 py-2`,children:(e.tasks??[]).map(e=>(0,v.jsx)(T,{task:e},e.id))}),t&&(e.tasks??[]).length===0&&(0,v.jsx)(`div`,{className:`border-t border-white/5 px-4 py-3 text-xs text-white/20`,children:`Sin tareas registradas`})]})}function D(){let{projects:e,isLoading:t,fetchProjects:n,fetchActiveProjects:r}=_(),[i,a]=(0,g.useState)(`active`),o=()=>{i===`active`?r():i===`done`?n(`done`):n()};return(0,g.useEffect)(()=>{o()},[i]),(0,v.jsx)(`div`,{className:`hive-page`,children:(0,v.jsxs)(`div`,{className:`hive-page-container`,children:[(0,v.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,v.jsxs)(`div`,{children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-3 mb-2`,children:[(0,v.jsx)(`div`,{className:`hive-page-header__dot`}),(0,v.jsx)(`span`,{className:`hive-page-header__label`,children:`GESTIÓN`})]}),(0,v.jsxs)(`h1`,{className:`hive-title-page`,children:[`Proyectos`,(0,v.jsx)(`span`,{className:`hive-title-page__accent`,children:`.`})]}),(0,v.jsx)(`p`,{className:`hive-subtitle`,children:`Seguimiento de tareas y proyectos activos del agente`})]}),(0,v.jsxs)(`button`,{className:`hive-btn hive-btn--primary`,onClick:o,disabled:t,children:[(0,v.jsx)(y,{icon:d,className:`h-3.5 w-3.5 mr-1.5 ${t?`animate-spin`:``}`}),`Actualizar`]})]}),(0,v.jsx)(`div`,{className:`flex gap-1 mt-6 bg-white/[0.02] rounded-xl p-1 border border-white/5`,children:[{key:`active`,label:`Activos`},{key:`all`,label:`Todos`},{key:`done`,label:`Completados`}].map(e=>(0,v.jsx)(`button`,{onClick:()=>a(e.key),className:`px-6 py-2 rounded-xl text-[10px] font-black tracking-widest uppercase transition-all duration-300 ${i===e.key?`bg-blue-600 text-white shadow-btn-primary`:`text-white/20 hover:text-white/40 hover:bg-white/5`}`,children:e.label},e.key))}),(0,v.jsx)(`div`,{className:`mt-6 space-y-3`,children:t?(0,v.jsxs)(`div`,{className:`hive-empty-state`,children:[(0,v.jsx)(y,{icon:u,className:`h-5 w-5 animate-spin mr-2`}),`Cargando proyectos...`]}):e.length===0?(0,v.jsxs)(`div`,{className:`hive-empty-state`,children:[(0,v.jsx)(y,{icon:l,className:`h-10 w-10 opacity-30 mb-3`}),(0,v.jsxs)(`p`,{className:`text-sm text-white/30`,children:[`No hay proyectos `,i===`active`?`activos`:``]}),(0,v.jsx)(`p`,{className:`text-xs text-white/15 mt-1`,children:`El agente creará proyectos automáticamente cuando reciba tareas complejas`})]}):e.filter(Boolean).map(e=>(0,v.jsx)(E,{project:e},e.id))})]})})}export{D as ProjectsPage};
@@ -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-_qMjiZaF.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-7AuR7x2g.js";import{t as d}from"./chevron-down-B16UVNlu.js";import{t as f}from"./chevron-right-yzZLjezG.js";import{t as p}from"./circle-check-E2u7ZS2r.js";import{t as m}from"./cpu-mBJgRJzM.js";import{t as h}from"./download-oaofq4K1.js";import{n as g,t as _}from"./eye-B8lq7sWG.js";import{t as v}from"./globe-BVPd5DRa.js";import{t as y}from"./key-BCGwSKKc.js";import{t as b}from"./loader-circle-CK3qRV3f.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-DWEJJiuF.js";import{t as ne}from"./lock-D7PCO7GC.js";import{n as M,t as N}from"./square-D_-gRT1l.js";import{t as re}from"./pencil-BF2_XX-i.js";import{t as ie}from"./play-DidATMfT.js";import{t as P}from"./plus-DXm1XDhQ.js";import{t as F}from"./refresh-cw-BLmKlO4J.js";import{t as I}from"./search-Co6mulZS.js";import{t as L}from"./settings-BvXhlJCF.js";import{t as ae}from"./terminal-CjZu0OZ0.js";import{t as oe}from"./trash-2-Blkv31Dz.js";import{t as se}from"./x-5cXW_1ZS.js";import{r as R,t as ce}from"./api-q5Ax-vD2.js";import{E as z,L as le,R as ue,T as B,a as de,c as V,d as fe,i as pe,r as H,s as me}from"./index-D4pdc0Uw.js";import{t as U}from"./label-C6tqnnKd.js";import{c as he,i as W,o as ge,r as _e,s as G,t as ve}from"./dialog-BaJbZsQF.js";import{t as K}from"./badge-pNhtItyt.js";import{a as q,n as J,o as Y,r as X,t as Z}from"./card-C7P3W6_y.js";import"./useProviders-Bxsnav4y.js";import{t as ye}from"./scroll-area-DKNpYkRA.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)(U,{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)(B,{type:r?`text`:`password`,value:a,onChange:e=>o(e.target.value),placeholder:v?`•••••••••••••••• (dejar vacío para conservar)`:`sk-...`,className:`hive-input !h-8 text-xs pr-8`}),(0,$.jsx)(z,{variant:`ghost`,size:`icon`,className:`absolute right-0 top-0 h-8 w-8 text-white/40 hover:text-white`,onClick:()=>i(!r),children:r?(0,$.jsx)(g,{className:`h-3 w-3`}):(0,$.jsx)(_,{className:`h-3 w-3`})})]})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(U,{className:`hive-label`,children:`Base URL (opcional)`}),(0,$.jsx)(B,{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)(U,{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)(B,{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)(U,{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{R.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=L,Te=d,Ee=f,De=m,Oe=P,ke=xe,Ae=v,je=F,Me=re,Ne=oe,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}=me(),{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)}},ie=async e=>{x(e.id);try{await E(e.id)}catch(e){console.error(`Failed to delete model:`,e)}finally{x(null)}},P=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)}}},F=!!e.active,I=e.base_url||e.baseUrl,L=e.id===`ollama`||I?.includes(`localhost`)||I?.includes(`127.0.0.1`);return(0,$.jsxs)(`div`,{className:`hive-card group overflow-hidden flex flex-col gap-0 transition-all duration-500 ${F?`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 ${F?`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}),F&&(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 ${F?`text-blue-400`:`text-white/30`}`,children:F?`ON`:`OFF`}),(0,$.jsx)(u,{checked:F,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`:L?`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:`••••••••••••••••`}):L?(0,$.jsx)(`span`,{className:`text-amber-400/70`,children:`Local — sin API key`}):(0,$.jsx)(`span`,{className:`text-white/25`,children:`Sin API key`})})]}),I&&(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:I})]}),L&&(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]})]}),L&&(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:()=>ie(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`&&P(),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:P,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 ${F?`text-emerald-400`:`text-white/30`}`,children:F?`Activo`:`Inactivo`})]})]}),(0,$.jsxs)(ve,{open:r,onOpenChange:i,children:[(0,$.jsx)(he,{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)(G,{className:`text-lg font-black text-white uppercase tracking-tighter`,children:e.name}),(0,$.jsx)(W,{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 ${F?``:`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)(U,{className:`hive-label`,children:`Nombre del Provider`}),(0,$.jsx)(B,{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)(U,{className:`hive-label`,children:`Tipo de Provider`}),(0,$.jsx)(B,{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)(U,{className:`hive-label`,children:`API Key`})}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(B,{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)(U,{className:`hive-label`,children:`Base URL (opcional)`}),(0,$.jsx)(B,{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)(U,{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)(B,{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)(U,{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()){R.fire(`Error`,`El nombre del provider es requerido`,`error`);return}if(!o){R.fire(`Error`,`Selecciona un tipo de provider`,`error`);return}if(!c.trim()&&!v){R.fire(`Error`,`La API Key es requerida para este provider`,`error`);return}let t;if(f.trim())try{t=JSON.parse(f.trim())}catch{R.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}=me();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=H(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)(I,{className:`absolute left-2 top-2 h-4 w-4 text-muted-foreground`}),(0,$.jsx)(B,{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)(ye,{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}=de(),[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)(ve,{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)(G,{className:`flex items-center gap-2`,children:`📦 Gestionar Modelos TTS`}),(0,$.jsx)(W,{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)(z,{size:`sm`,variant:`ghost`,onClick:d,disabled:l||a,className:`gap-2`,children:[(0,$.jsx)(F,{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)(z,{size:`sm`,variant:`ghost`,disabled:!0,className:`gap-2 opacity-50`,children:[(0,$.jsx)(o,{className:`h-4 w-4`}),`Instalado`]}):(0,$.jsxs)(z,{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}=de(),[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 ce(`/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)(F,{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)(z,{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)(z,{size:`sm`,disabled:!0,className:`gap-2 opacity-70`,children:[(0,$.jsx)(F,{className:`h-3.5 w-3.5 animate-spin`}),`Descargando…`]}),T&&!E&&(0,$.jsxs)(z,{size:`sm`,onClick:b,disabled:a,className:`gap-2 bg-blue-600 hover:bg-blue-500 text-white`,children:[(0,$.jsx)(ie,{className:`h-3.5 w-3.5`}),`Iniciar servidor`]}),E&&(0,$.jsxs)(z,{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)(z,{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)(z,{size:`sm`,variant:`ghost`,onClick:()=>t(),title:`Actualizar estado`,className:`text-zinc-400`,children:(0,$.jsx)(F,{className:`h-3.5 w-3.5`})}),(0,$.jsxs)(z,{size:`sm`,variant:`ghost`,onClick:S,className:`gap-1.5 text-zinc-400 text-xs`,children:[(0,$.jsx)(ae,{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}=fe(),p=H(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)(I,{className:`absolute left-2 top-2 h-4 w-4 text-muted-foreground`}),(0,$.jsx)(B,{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)(ye,{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)(U,{htmlFor:`api-key-${e}`,children:`API Key`}),(0,$.jsxs)(`div`,{className:`flex gap-2 mt-1`,children:[(0,$.jsx)(B,{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)(z,{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)(z,{size:`sm`,onClick:()=>D(e),disabled:v||!g.trim(),className:`flex-1`,children:v?`Guardando...`:`Guardar`}),(0,$.jsx)(z,{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)(z,{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)(z,{size:`sm`,onClick:()=>{h(e),_(``)},className:`flex-1`,children:[(0,$.jsx)(y,{className:`h-3 w-3 mr-2`}),`Configurar API Key`]}),(0,$.jsx)(z,{size:`sm`,variant:`outline`,onClick:()=>window.open(t.consoleUrl,`_blank`),children:`Obtener Key`})]})]})})]},e)})]})]}),(0,$.jsxs)(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}=pe(),[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)&&H.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)(F,{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)(z,{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)(z,{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)(F,{className:`h-3 w-3 animate-spin`}),`Descargando…`]}):(0,$.jsx)(z,{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)(z,{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)(z,{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)(ie,{className:`h-3 w-3 fill-current`}),t]},t)})}),e.running&&(0,$.jsxs)(z,{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)(z,{size:`sm`,variant:`ghost`,onClick:()=>n(),title:`Actualizar estado`,className:`text-zinc-400`,children:(0,$.jsx)(F,{className:`h-3.5 w-3.5`})}),(0,$.jsxs)(z,{size:`sm`,variant:`ghost`,onClick:S,className:`gap-1.5 text-zinc-400 text-xs ml-auto`,children:[(0,$.jsx)(ae,{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=H(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)(I,{className:`absolute left-2 top-2 h-4 w-4 text-muted-foreground`}),(0,$.jsx)(B,{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)(ye,{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=P,$e=ue,et=_,tt=M,nt=le;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)(ve,{open:n,onOpenChange:e=>{r(e)},children:[(0,$.jsx)(he,{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)(G,{className:`text-xl font-black text-white uppercase tracking-tighter`,children:`Añadir Provider`}),(0,$.jsx)(W,{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};