@johpaz/hive-agents 1.1.2 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/hive.js +3741 -3150
  2. package/dist/tool-worker.js +25 -2
  3. package/dist/ui/assets/{A2UIPage-BOR7GzYi.js → A2UIPage-EDS7lN-K.js} +4 -4
  4. package/dist/ui/assets/{AgentCreateForm-Btza1Kiv.js → AgentCreateForm-KvhVhAFP.js} +1 -1
  5. package/dist/ui/assets/AgentDetailPage-B2dCpO92.js +1 -0
  6. package/dist/ui/assets/{AgentNewPage-DvP05Ap5.js → AgentNewPage-CF2B4dbu.js} +1 -1
  7. package/dist/ui/assets/AgentsPage-CMvz-CtA.js +10 -0
  8. package/dist/ui/assets/{ApiClientPage-Cmo0XBwk.js → ApiClientPage-tzzL3rZC.js} +1 -1
  9. package/dist/ui/assets/{ChannelsPage-C53NCtXi.js → ChannelsPage-fE2vRwup.js} +2 -2
  10. package/dist/ui/assets/DashboardPage-57SaHnBL.js +6 -0
  11. package/dist/ui/assets/{LoginPage-CTc-MbtG.js → LoginPage-Fag9Bp5h.js} +1 -1
  12. package/dist/ui/assets/{LogsPage-D-2DgTQh.js → LogsPage-GVJd_a65.js} +1 -1
  13. package/dist/ui/assets/{MeetingPage-B8Xb1z_0.js → MeetingPage-TKQu8Nr-.js} +1 -1
  14. package/dist/ui/assets/{ModelSelector-BcaASPWF.js → ModelSelector-DciHLo7R.js} +1 -1
  15. package/dist/ui/assets/{NotFound-PUg3gEO0.js → NotFound-D4ZlDVg9.js} +1 -1
  16. package/dist/ui/assets/{Office3DPage-6bDnybWI.js → Office3DPage-CQnO522l.js} +2 -2
  17. package/dist/ui/assets/ProvidersPage-BsWFvzqz.js +1 -0
  18. package/dist/ui/assets/{RecoverPage-UL782VIG.js → RecoverPage-BkdOyljs.js} +1 -1
  19. package/dist/ui/assets/SettingsPage-D_43Rc2I.js +9 -0
  20. package/dist/ui/assets/{SetupPage-B_fXVcuJ.js → SetupPage-D6Z3SYZu.js} +1 -1
  21. package/dist/ui/assets/VoicePage-CCE2EOE9.js +307 -0
  22. package/dist/ui/assets/{WebChatPage-D8KsJqMf.js → WebChatPage-Dzk3FhiR.js} +4 -4
  23. package/dist/ui/assets/{conversationsStore-8WwqUOpe.js → conversationsStore-5hf5grlP.js} +1 -1
  24. package/dist/ui/assets/{core-B_5cyOSV.js → core-p4c5dns5.js} +1 -1
  25. package/dist/ui/assets/{dialog-DcgGvP2g.js → dialog-DKnsGLwr.js} +1 -1
  26. package/dist/ui/assets/{dist-js-q7C_AB0j.js → dist-js-CkNhvsFc.js} +1 -1
  27. package/dist/ui/assets/dist-js-jWCEHSkB.js +1 -0
  28. package/dist/ui/assets/{index-C5Hhusqq.js → index-mBw9Tl7u.js} +44 -4
  29. package/dist/ui/assets/useAudioDevices-BYFaA0X-.js +1 -0
  30. package/dist/ui/assets/{useHiveAgentsModelLoad-IOqfYcrC.js → useHiveAgentsModelLoad-RRQ6-ANC.js} +1 -1
  31. package/dist/ui/assets/{useProviders-DsFqfiyM.js → useProviders-DXr4pJ57.js} +1 -1
  32. package/dist/ui/assets/{vendor-router-DP84b3LQ.js → vendor-router-DSMCk-Ka.js} +1 -1
  33. package/dist/ui/index.html +2 -2
  34. package/package.json +5 -3
  35. package/packages/core/src/agent/compaction.ts +162 -25
  36. package/packages/core/src/agent/context-compiler.ts +121 -8
  37. package/packages/core/src/agent/conversation-store.ts +43 -2
  38. package/packages/core/src/agent/handoff.ts +129 -0
  39. package/packages/core/src/agent/history-timeline.ts +133 -0
  40. package/packages/core/src/agent/message-memory.ts +148 -0
  41. package/packages/core/src/agent/summary-memory.ts +152 -0
  42. package/packages/core/src/agent/thread-store.ts +4 -0
  43. package/packages/core/src/config/loader.ts +37 -1
  44. package/packages/core/src/gateway/realtime/voice-session.ts +19 -0
  45. package/packages/core/src/storage/collections.ts +3 -0
  46. package/packages/core/src/tools/core/index.ts +19 -6
  47. package/packages/skills/src/bundled-data.generated.ts +756 -756
  48. package/dist/ui/assets/AgentDetailPage-D435IX8G.js +0 -1
  49. package/dist/ui/assets/AgentsPage-BT9CssIN.js +0 -10
  50. package/dist/ui/assets/DashboardPage-DpI54Ot0.js +0 -6
  51. package/dist/ui/assets/ProvidersPage-CVK-nKxE.js +0 -1
  52. package/dist/ui/assets/SettingsPage-CHJfutPk.js +0 -9
  53. package/dist/ui/assets/VoicePage-CdBZrLAm.js +0 -307
  54. package/dist/ui/assets/dist-js-Dh18rcg9.js +0 -1
  55. package/dist/ui/assets/useAudioDevices-BO-kUbtK.js +0 -41
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{f as t}from"./vendor-charts-K3xcRl0X.js";import{n,t as r}from"./vendor-react-kUOwxn0g.js";import{o as i}from"./vendor-query-Dj8xYhQD.js";import{t as a}from"./createLucideIcon-BRaPSYgN.js";import{t as o}from"./activity-C_GS5wrG.js";import{t as s}from"./arrow-right-BuNjN-bk.js";import{t as c}from"./chevron-down-8GjmTjLR.js";import{t as l}from"./chevron-left-GK4EQOyZ.js";import{t as u}from"./chevron-right-BupZqrxu.js";import{t as d}from"./chevron-up-DZrzJIW8.js";import{t as f}from"./circle-check-BKNT2_q6.js";import{n as p,t as m}from"./useOfficeModel-BaDn7U-X.js";import{t as h}from"./gauge-CEu7PhTW.js";import{t as g}from"./radio-lFPMHi6-.js";import{t as _}from"./send-CpoY_2F-.js";import{t as v}from"./volume-2-EaA0JRvD.js";import{t as y}from"./volume-x-CROXNMGT.js";import{n as b,t as x}from"./wifi-BUJuOcgP.js";import{r as S}from"./gateway-url-BALS_wVh.js";import{N as C,O as w,Q as T,_ as E,at as D,q as O}from"./index-C5Hhusqq.js";import{A as k,At as A,Ct as j,E as M,Mt as N,Ot as P,P as F,Pt as I,Q as L,S as R,X as z,Z as B,b as V,bt as H,c as ee,ct as te,d as ne,f as U,h as re,ht as ie,i as ae,j as oe,jt as W,l as se,lt as ce,m as le,mt as ue,n as de,s as fe,st as pe,t as me,u as he,v as ge,y as G,z as _e}from"./Vignette-bSrGVyRd.js";var ve=a(`Crown`,[[`path`,{d:`M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z`,key:`1vdc57`}],[`path`,{d:`M5 21h14`,key:`11awu3`}]]),ye=a(`SearchCheck`,[[`path`,{d:`m8 11 2 2 4-4`,key:`1sed1v`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]),K=r(),q=e(t(),1);function be(){let e=(0,K.c)(9),{agents:t,fetchAgents:n}=E(),r=C(we),i=C(Ce),a=C(Se),o=C(xe),s,c;e[0]===n?(s=e[1],c=e[2]):(s=()=>{n()},c=[n],e[0]=n,e[1]=s,e[2]=c),(0,q.useEffect)(s,c);let{coordinator:l,desks:u,interactions:d}=m(t,r,i),f;return e[3]!==l||e[4]!==u||e[5]!==d||e[6]!==o||e[7]!==a?(f={coordinator:l,desks:u,interactions:d,workEvents:a,isConnected:o},e[3]=l,e[4]=u,e[5]=d,e[6]=o,e[7]=a,e[8]=f):f=e[8],f}function xe(e){return e.isConnected}function Se(e){return e.workEvents}function Ce(e){return e.graphEdges}function we(e){return e.graphNodes}function Te(){return typeof window>`u`?!1:window.localStorage.getItem(`office3d-sound`)===`on`}var J=S(e=>({selectedAgentId:null,quality:`high`,motion:`calm`,introDone:!1,soundEnabled:Te(),activeCue:null,select:t=>e({selectedAgentId:t}),setQuality:t=>e({quality:t}),setMotion:t=>e({motion:t}),setIntroDone:()=>e({introDone:!0}),setSoundEnabled:t=>{typeof window<`u`&&window.localStorage.setItem(`office3d-sound`,t?`on`:`off`),e({soundEnabled:t})},setActiveCue:t=>e({activeCue:t})})),Ee=`#a78bfa`,De=`#94a3b8`,Oe={context:`Contexto`,iteration:`Iteración`,parallel:`Paralelismo`};function ke(e){return Oe[e]}function Ae(e){return e?.backend===`kev`?`Kev`:`Jev`}function je(e){return e===`ready`?`activo`:e===`fallback`?`flujo clásico`:`desactivado`}function Me(e){let t=Math.abs(e);return t<1e3?String(Math.round(t)):`${(t/1e3).toLocaleString(`es`,{maximumFractionDigits:1})}k`}function Ne(e){return Math.abs(e)<50?null:`${e>0?`−`:`+`}${Me(e)} tok`}function Pe(e){return e===0?`$0`:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function Fe(){let e=(0,K.c)(6),t=C(Be),n=C(ze),r=C(Re),i,a;e[0]===r?(i=e[1],a=e[2]):(i=()=>{if(C.getState().jevStatus)return;let e=!1;return w(`/api/providers`).then(t=>{let{providers:n}=t,i=n.find(Le)?.jev;!e&&i&&!C.getState().jevStatus&&r(i)}).catch(Ie),()=>{e=!0}},a=[r],e[0]=r,e[1]=i,e[2]=a),(0,q.useEffect)(i,a);let o;return e[3]!==n||e[4]!==t?(o={status:t,decisions:n},e[3]=n,e[4]=t,e[5]=o):o=e[5],o}function Ie(){}function Le(e){return e.id===`openrouter`}function Re(e){return e.setJevStatus}function ze(e){return e.jevDecisions}function Be(e){return e.jevStatus}var Ve=e(n()),He=new W,Ue=new W,We=new W,Ge=new A;function Ke(e,t,n){let r=He.setFromMatrixPosition(e.matrixWorld);r.project(t);let i=n.width/2,a=n.height/2;return[r.x*i+i,-(r.y*a)+a]}function qe(e,t){let n=He.setFromMatrixPosition(e.matrixWorld),r=Ue.setFromMatrixPosition(t.matrixWorld),i=n.sub(r),a=t.getWorldDirection(We);return i.angleTo(a)>Math.PI/2}function Je(e,t,n,r){let i=He.setFromMatrixPosition(e.matrixWorld),a=i.clone();a.project(t),Ge.set(a.x,a.y),n.setFromCamera(Ge,t);let o=n.intersectObjects(r,!0);if(o.length){let e=o[0].distance;return i.distanceTo(n.ray.origin)<e}return!0}function Ye(e,t){if(t instanceof te)return t.zoom;if(t instanceof ce){let n=He.setFromMatrixPosition(e.matrixWorld),r=Ue.setFromMatrixPosition(t.matrixWorld),i=t.fov*Math.PI/180,a=n.distanceTo(r);return 1/(2*Math.tan(i/2)*a)}else return 1}function Xe(e,t,n){if(t instanceof ce||t instanceof te){let r=He.setFromMatrixPosition(e.matrixWorld),i=Ue.setFromMatrixPosition(t.matrixWorld),a=r.distanceTo(i),o=(n[1]-n[0])/(t.far-t.near),s=n[1]-o*t.far;return Math.round(o*a+s)}}var Ze=e=>Math.abs(e)<1e-10?0:e;function Qe(e,t,n=``){let r=`matrix3d(`;for(let n=0;n!==16;n++)r+=Ze(t[n]*e.elements[n])+(n===15?`)`:`,`);return n+r}var $e=(e=>t=>Qe(t,e))([1,-1,1,1,1,-1,1,1,1,-1,1,1,1,-1,1,1]),et=(e=>(t,n)=>Qe(t,e(n),`translate(-50%,-50%)`))(e=>[1/e,1/e,1/e,1,-1/e,-1/e,-1/e,-1,1/e,1/e,1/e,1,1,1,1,1]);function tt(e){return e&&typeof e==`object`&&`current`in e}var nt=q.forwardRef(({children:e,eps:t=.001,style:n,className:r,prepend:i,center:a,fullscreen:o,portal:s,distanceFactor:c,sprite:l=!1,transform:u=!1,occlude:d,onOcclude:f,castShadow:p,receiveShadow:m,material:h,geometry:g,zIndexRange:_=[16777271,0],calculatePosition:v=Ke,as:y=`div`,wrapperClass:b,pointerEvents:x=`auto`,...S},C)=>{let{gl:w,camera:T,scene:E,size:D,raycaster:O,events:k,viewport:A}=le(),[j]=q.useState(()=>document.createElement(y)),M=q.useRef(),N=q.useRef(null),P=q.useRef(0),F=q.useRef([0,0]),I=q.useRef(null),L=q.useRef(null),R=s?.current||k.connected||w.domElement.parentNode,z=q.useRef(null),B=q.useRef(!1),V=q.useMemo(()=>d&&d!==`blending`||Array.isArray(d)&&d.length&&tt(d[0]),[d]);q.useLayoutEffect(()=>{let e=w.domElement;d&&d===`blending`?(e.style.zIndex=`${Math.floor(_[0]/2)}`,e.style.position=`absolute`,e.style.pointerEvents=`none`):(e.style.zIndex=null,e.style.position=null,e.style.pointerEvents=null)},[d]),q.useLayoutEffect(()=>{if(N.current){let e=M.current=Ve.createRoot(j);if(E.updateMatrixWorld(),u)j.style.cssText=`position:absolute;top:0;left:0;pointer-events:none;overflow:hidden;`;else{let e=v(N.current,T,D);j.style.cssText=`position:absolute;top:0;left:0;transform:translate3d(${e[0]}px,${e[1]}px,0);transform-origin:0 0;`}return R&&(i?R.prepend(j):R.appendChild(j)),()=>{R&&R.removeChild(j),e.unmount()}}},[R,u]),q.useLayoutEffect(()=>{b&&(j.className=b)},[b]);let H=q.useMemo(()=>u?{position:`absolute`,top:0,left:0,width:D.width,height:D.height,transformStyle:`preserve-3d`,pointerEvents:`none`}:{position:`absolute`,transform:a?`translate3d(-50%,-50%,0)`:`none`,...o&&{top:-D.height/2,left:-D.width/2,width:D.width,height:D.height},...n},[n,a,o,D,u]),ee=q.useMemo(()=>({position:`absolute`,pointerEvents:x}),[x]);q.useLayoutEffect(()=>{if(B.current=!1,u){var t;(t=M.current)==null||t.render(q.createElement(`div`,{ref:I,style:H},q.createElement(`div`,{ref:L,style:ee},q.createElement(`div`,{ref:C,className:r,style:n,children:e}))))}else{var i;(i=M.current)==null||i.render(q.createElement(`div`,{ref:C,style:H,className:r,children:e}))}});let te=q.useRef(!0);U(e=>{if(N.current){T.updateMatrixWorld(),N.current.updateWorldMatrix(!0,!1);let e=u?F.current:v(N.current,T,D);if(u||Math.abs(P.current-T.zoom)>t||Math.abs(F.current[0]-e[0])>t||Math.abs(F.current[1]-e[1])>t){let t=qe(N.current,T),n=!1;V&&(Array.isArray(d)?n=d.map(e=>e.current):d!==`blending`&&(n=[E]));let r=te.current;n?te.current=Je(N.current,T,O,n)&&!t:te.current=!t,r!==te.current&&(f?f(!te.current):j.style.display=te.current?`block`:`none`);let i=Math.floor(_[0]/2),a=d?V?[_[0],i]:[i-1,0]:_;if(j.style.zIndex=`${Xe(N.current,T,a)}`,u){let[e,t]=[D.width/2,D.height/2],n=T.projectionMatrix.elements[5]*t,{isOrthographicCamera:r,top:i,left:a,bottom:o,right:s}=T,u=$e(T.matrixWorldInverse),d=r?`scale(${n})translate(${Ze(-(s+a)/2)}px,${Ze((i+o)/2)}px)`:`translateZ(${n}px)`,f=N.current.matrixWorld;l&&(f=T.matrixWorldInverse.clone().transpose().copyPosition(f).scale(N.current.scale),f.elements[3]=f.elements[7]=f.elements[11]=0,f.elements[15]=1),j.style.width=D.width+`px`,j.style.height=D.height+`px`,j.style.perspective=r?``:`${n}px`,I.current&&L.current&&(I.current.style.transform=`${d}${u}translate(${e}px,${t}px)`,L.current.style.transform=et(f,1/((c||10)/400)))}else{let t=c===void 0?1:Ye(N.current,T)*c;j.style.transform=`translate3d(${e[0]}px,${e[1]}px,0) scale(${t})`}F.current=e,P.current=T.zoom}}if(!V&&z.current&&!B.current)if(u){if(I.current){let e=I.current.children[0];if(e!=null&&e.clientWidth&&e!=null&&e.clientHeight){let{isOrthographicCamera:t}=T;if(t||g)S.scale&&(Array.isArray(S.scale)?S.scale instanceof W?z.current.scale.copy(S.scale.clone().divideScalar(1)):z.current.scale.set(1/S.scale[0],1/S.scale[1],1/S.scale[2]):z.current.scale.setScalar(1/S.scale));else{let t=(c||10)/400,n=e.clientWidth*t,r=e.clientHeight*t;z.current.scale.set(n,r,1)}B.current=!0}}}else{let t=j.children[0];if(t!=null&&t.clientWidth&&t!=null&&t.clientHeight){let e=1/A.factor,n=t.clientWidth*e,r=t.clientHeight*e;z.current.scale.set(n,r,1),B.current=!0}z.current.lookAt(e.camera.position)}});let ne=q.useMemo(()=>({vertexShader:u?void 0:`
1
+ import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{f as t}from"./vendor-charts-K3xcRl0X.js";import{n,t as r}from"./vendor-react-kUOwxn0g.js";import{o as i}from"./vendor-query-Dj8xYhQD.js";import{t as a}from"./createLucideIcon-BRaPSYgN.js";import{t as o}from"./activity-C_GS5wrG.js";import{t as s}from"./arrow-right-BuNjN-bk.js";import{t as c}from"./chevron-down-8GjmTjLR.js";import{t as l}from"./chevron-left-GK4EQOyZ.js";import{t as u}from"./chevron-right-BupZqrxu.js";import{t as d}from"./chevron-up-DZrzJIW8.js";import{t as f}from"./circle-check-BKNT2_q6.js";import{n as p,t as m}from"./useOfficeModel-BaDn7U-X.js";import{t as h}from"./gauge-CEu7PhTW.js";import{t as g}from"./radio-lFPMHi6-.js";import{t as _}from"./send-CpoY_2F-.js";import{t as v}from"./volume-2-EaA0JRvD.js";import{t as y}from"./volume-x-CROXNMGT.js";import{n as b,t as x}from"./wifi-BUJuOcgP.js";import{r as S}from"./gateway-url-BALS_wVh.js";import{N as C,Q as w,R as T,S as E,rt as D,ut as O}from"./index-mBw9Tl7u.js";import{A as k,At as A,Ct as j,E as M,Mt as N,Ot as P,P as F,Pt as I,Q as L,S as R,X as z,Z as B,b as V,bt as H,c as ee,ct as te,d as ne,f as U,h as re,ht as ie,i as ae,j as oe,jt as W,l as se,lt as ce,m as le,mt as ue,n as de,s as fe,st as pe,t as me,u as he,v as ge,y as G,z as _e}from"./Vignette-bSrGVyRd.js";var ve=a(`Crown`,[[`path`,{d:`M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z`,key:`1vdc57`}],[`path`,{d:`M5 21h14`,key:`11awu3`}]]),ye=a(`SearchCheck`,[[`path`,{d:`m8 11 2 2 4-4`,key:`1sed1v`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]),K=r(),q=e(t(),1);function be(){let e=(0,K.c)(9),{agents:t,fetchAgents:n}=E(),r=T(we),i=T(Ce),a=T(Se),o=T(xe),s,c;e[0]===n?(s=e[1],c=e[2]):(s=()=>{n()},c=[n],e[0]=n,e[1]=s,e[2]=c),(0,q.useEffect)(s,c);let{coordinator:l,desks:u,interactions:d}=m(t,r,i),f;return e[3]!==l||e[4]!==u||e[5]!==d||e[6]!==o||e[7]!==a?(f={coordinator:l,desks:u,interactions:d,workEvents:a,isConnected:o},e[3]=l,e[4]=u,e[5]=d,e[6]=o,e[7]=a,e[8]=f):f=e[8],f}function xe(e){return e.isConnected}function Se(e){return e.workEvents}function Ce(e){return e.graphEdges}function we(e){return e.graphNodes}function Te(){return typeof window>`u`?!1:window.localStorage.getItem(`office3d-sound`)===`on`}var J=S(e=>({selectedAgentId:null,quality:`high`,motion:`calm`,introDone:!1,soundEnabled:Te(),activeCue:null,select:t=>e({selectedAgentId:t}),setQuality:t=>e({quality:t}),setMotion:t=>e({motion:t}),setIntroDone:()=>e({introDone:!0}),setSoundEnabled:t=>{typeof window<`u`&&window.localStorage.setItem(`office3d-sound`,t?`on`:`off`),e({soundEnabled:t})},setActiveCue:t=>e({activeCue:t})})),Ee=`#a78bfa`,De=`#94a3b8`,Oe={context:`Contexto`,iteration:`Iteración`,parallel:`Paralelismo`};function ke(e){return Oe[e]}function Ae(e){return e?.backend===`kev`?`Kev`:`Jev`}function je(e){return e===`ready`?`activo`:e===`fallback`?`flujo clásico`:`desactivado`}function Me(e){let t=Math.abs(e);return t<1e3?String(Math.round(t)):`${(t/1e3).toLocaleString(`es`,{maximumFractionDigits:1})}k`}function Ne(e){return Math.abs(e)<50?null:`${e>0?`−`:`+`}${Me(e)} tok`}function Pe(e){return e===0?`$0`:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function Fe(){let e=(0,K.c)(6),t=T(Be),n=T(ze),r=T(Re),i,a;e[0]===r?(i=e[1],a=e[2]):(i=()=>{if(T.getState().jevStatus)return;let e=!1;return C(`/api/providers`).then(t=>{let{providers:n}=t,i=n.find(Le)?.jev;!e&&i&&!T.getState().jevStatus&&r(i)}).catch(Ie),()=>{e=!0}},a=[r],e[0]=r,e[1]=i,e[2]=a),(0,q.useEffect)(i,a);let o;return e[3]!==n||e[4]!==t?(o={status:t,decisions:n},e[3]=n,e[4]=t,e[5]=o):o=e[5],o}function Ie(){}function Le(e){return e.id===`openrouter`}function Re(e){return e.setJevStatus}function ze(e){return e.jevDecisions}function Be(e){return e.jevStatus}var Ve=e(n()),He=new W,Ue=new W,We=new W,Ge=new A;function Ke(e,t,n){let r=He.setFromMatrixPosition(e.matrixWorld);r.project(t);let i=n.width/2,a=n.height/2;return[r.x*i+i,-(r.y*a)+a]}function qe(e,t){let n=He.setFromMatrixPosition(e.matrixWorld),r=Ue.setFromMatrixPosition(t.matrixWorld),i=n.sub(r),a=t.getWorldDirection(We);return i.angleTo(a)>Math.PI/2}function Je(e,t,n,r){let i=He.setFromMatrixPosition(e.matrixWorld),a=i.clone();a.project(t),Ge.set(a.x,a.y),n.setFromCamera(Ge,t);let o=n.intersectObjects(r,!0);if(o.length){let e=o[0].distance;return i.distanceTo(n.ray.origin)<e}return!0}function Ye(e,t){if(t instanceof te)return t.zoom;if(t instanceof ce){let n=He.setFromMatrixPosition(e.matrixWorld),r=Ue.setFromMatrixPosition(t.matrixWorld),i=t.fov*Math.PI/180,a=n.distanceTo(r);return 1/(2*Math.tan(i/2)*a)}else return 1}function Xe(e,t,n){if(t instanceof ce||t instanceof te){let r=He.setFromMatrixPosition(e.matrixWorld),i=Ue.setFromMatrixPosition(t.matrixWorld),a=r.distanceTo(i),o=(n[1]-n[0])/(t.far-t.near),s=n[1]-o*t.far;return Math.round(o*a+s)}}var Ze=e=>Math.abs(e)<1e-10?0:e;function Qe(e,t,n=``){let r=`matrix3d(`;for(let n=0;n!==16;n++)r+=Ze(t[n]*e.elements[n])+(n===15?`)`:`,`);return n+r}var $e=(e=>t=>Qe(t,e))([1,-1,1,1,1,-1,1,1,1,-1,1,1,1,-1,1,1]),et=(e=>(t,n)=>Qe(t,e(n),`translate(-50%,-50%)`))(e=>[1/e,1/e,1/e,1,-1/e,-1/e,-1/e,-1,1/e,1/e,1/e,1,1,1,1,1]);function tt(e){return e&&typeof e==`object`&&`current`in e}var nt=q.forwardRef(({children:e,eps:t=.001,style:n,className:r,prepend:i,center:a,fullscreen:o,portal:s,distanceFactor:c,sprite:l=!1,transform:u=!1,occlude:d,onOcclude:f,castShadow:p,receiveShadow:m,material:h,geometry:g,zIndexRange:_=[16777271,0],calculatePosition:v=Ke,as:y=`div`,wrapperClass:b,pointerEvents:x=`auto`,...S},C)=>{let{gl:w,camera:T,scene:E,size:D,raycaster:O,events:k,viewport:A}=le(),[j]=q.useState(()=>document.createElement(y)),M=q.useRef(),N=q.useRef(null),P=q.useRef(0),F=q.useRef([0,0]),I=q.useRef(null),L=q.useRef(null),R=s?.current||k.connected||w.domElement.parentNode,z=q.useRef(null),B=q.useRef(!1),V=q.useMemo(()=>d&&d!==`blending`||Array.isArray(d)&&d.length&&tt(d[0]),[d]);q.useLayoutEffect(()=>{let e=w.domElement;d&&d===`blending`?(e.style.zIndex=`${Math.floor(_[0]/2)}`,e.style.position=`absolute`,e.style.pointerEvents=`none`):(e.style.zIndex=null,e.style.position=null,e.style.pointerEvents=null)},[d]),q.useLayoutEffect(()=>{if(N.current){let e=M.current=Ve.createRoot(j);if(E.updateMatrixWorld(),u)j.style.cssText=`position:absolute;top:0;left:0;pointer-events:none;overflow:hidden;`;else{let e=v(N.current,T,D);j.style.cssText=`position:absolute;top:0;left:0;transform:translate3d(${e[0]}px,${e[1]}px,0);transform-origin:0 0;`}return R&&(i?R.prepend(j):R.appendChild(j)),()=>{R&&R.removeChild(j),e.unmount()}}},[R,u]),q.useLayoutEffect(()=>{b&&(j.className=b)},[b]);let H=q.useMemo(()=>u?{position:`absolute`,top:0,left:0,width:D.width,height:D.height,transformStyle:`preserve-3d`,pointerEvents:`none`}:{position:`absolute`,transform:a?`translate3d(-50%,-50%,0)`:`none`,...o&&{top:-D.height/2,left:-D.width/2,width:D.width,height:D.height},...n},[n,a,o,D,u]),ee=q.useMemo(()=>({position:`absolute`,pointerEvents:x}),[x]);q.useLayoutEffect(()=>{if(B.current=!1,u){var t;(t=M.current)==null||t.render(q.createElement(`div`,{ref:I,style:H},q.createElement(`div`,{ref:L,style:ee},q.createElement(`div`,{ref:C,className:r,style:n,children:e}))))}else{var i;(i=M.current)==null||i.render(q.createElement(`div`,{ref:C,style:H,className:r,children:e}))}});let te=q.useRef(!0);U(e=>{if(N.current){T.updateMatrixWorld(),N.current.updateWorldMatrix(!0,!1);let e=u?F.current:v(N.current,T,D);if(u||Math.abs(P.current-T.zoom)>t||Math.abs(F.current[0]-e[0])>t||Math.abs(F.current[1]-e[1])>t){let t=qe(N.current,T),n=!1;V&&(Array.isArray(d)?n=d.map(e=>e.current):d!==`blending`&&(n=[E]));let r=te.current;n?te.current=Je(N.current,T,O,n)&&!t:te.current=!t,r!==te.current&&(f?f(!te.current):j.style.display=te.current?`block`:`none`);let i=Math.floor(_[0]/2),a=d?V?[_[0],i]:[i-1,0]:_;if(j.style.zIndex=`${Xe(N.current,T,a)}`,u){let[e,t]=[D.width/2,D.height/2],n=T.projectionMatrix.elements[5]*t,{isOrthographicCamera:r,top:i,left:a,bottom:o,right:s}=T,u=$e(T.matrixWorldInverse),d=r?`scale(${n})translate(${Ze(-(s+a)/2)}px,${Ze((i+o)/2)}px)`:`translateZ(${n}px)`,f=N.current.matrixWorld;l&&(f=T.matrixWorldInverse.clone().transpose().copyPosition(f).scale(N.current.scale),f.elements[3]=f.elements[7]=f.elements[11]=0,f.elements[15]=1),j.style.width=D.width+`px`,j.style.height=D.height+`px`,j.style.perspective=r?``:`${n}px`,I.current&&L.current&&(I.current.style.transform=`${d}${u}translate(${e}px,${t}px)`,L.current.style.transform=et(f,1/((c||10)/400)))}else{let t=c===void 0?1:Ye(N.current,T)*c;j.style.transform=`translate3d(${e[0]}px,${e[1]}px,0) scale(${t})`}F.current=e,P.current=T.zoom}}if(!V&&z.current&&!B.current)if(u){if(I.current){let e=I.current.children[0];if(e!=null&&e.clientWidth&&e!=null&&e.clientHeight){let{isOrthographicCamera:t}=T;if(t||g)S.scale&&(Array.isArray(S.scale)?S.scale instanceof W?z.current.scale.copy(S.scale.clone().divideScalar(1)):z.current.scale.set(1/S.scale[0],1/S.scale[1],1/S.scale[2]):z.current.scale.setScalar(1/S.scale));else{let t=(c||10)/400,n=e.clientWidth*t,r=e.clientHeight*t;z.current.scale.set(n,r,1)}B.current=!0}}}else{let t=j.children[0];if(t!=null&&t.clientWidth&&t!=null&&t.clientHeight){let e=1/A.factor,n=t.clientWidth*e,r=t.clientHeight*e;z.current.scale.set(n,r,1),B.current=!0}z.current.lookAt(e.camera.position)}});let ne=q.useMemo(()=>({vertexShader:u?void 0:`
2
2
  /*
3
3
  This shader is from the THREE's SpriteMaterial.
4
4
  We need to turn the backing plane into a Sprite
@@ -724,4 +724,4 @@ import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{f as t}from"./vendor-c
724
724
  vec3 glow = col * (uIntensity * (0.45 + fresnel * 1.7));
725
725
  gl_FragColor = vec4(glow, alpha);
726
726
  }
727
- `;function Qn(e){let t=e?.toLowerCase()??``;return/knowledge|memory|rag|embed|document|vector/.test(t)?`knowledge`:/browser|web|search|fetch|http|url/.test(t)?`browser`:/file|code|exec|shell|terminal|git|patch|write|read/.test(t)?`code`:/message|mail|slack|discord|telegram|whatsapp|notify/.test(t)?`communication`:`generic`}function $n(e){let t=(0,K.c)(2),{color:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`meshBasicMaterial`,{color:n,transparent:!0,opacity:.72,wireframe:!0,blending:2,depthWrite:!1}),t[0]=n,t[1]=r),r}function er(e){let t=(0,K.c)(27),{toolName:n,color:r}=e,i=(0,q.useRef)(null),a;t[0]===n?a=t[1]:(a=Qn(n),t[0]=n,t[1]=a);let o=a,s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(e,t)=>{i.current&&(i.current.rotation.y=i.current.rotation.y+t*.85,i.current.position.y=1.05+Math.sin(e.clock.elapsedTime*2.4)*.08)},t[2]=s):s=t[2],U(s);let c;t[3]!==o||t[4]!==r?(c=o===`browser`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`mesh`,{children:[(0,$.jsx)(`sphereGeometry`,{args:[.42,10,8]}),(0,$.jsx)($n,{color:r})]}),(0,$.jsxs)(`mesh`,{rotation:[Math.PI/2,0,0],children:[(0,$.jsx)(`torusGeometry`,{args:[.53,.035,6,24]}),(0,$.jsx)($n,{color:r})]})]}),t[3]=o,t[4]=r,t[5]=c):c=t[5];let l;t[6]!==o||t[7]!==r?(l=o===`code`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`mesh`,{children:[(0,$.jsx)(`boxGeometry`,{args:[.75,.55,.12]}),(0,$.jsx)($n,{color:r})]}),(0,$.jsxs)(`mesh`,{position:[-.16,0,.1],rotation:[0,0,-.55],children:[(0,$.jsx)(`boxGeometry`,{args:[.06,.32,.05]}),(0,$.jsx)($n,{color:r})]}),(0,$.jsxs)(`mesh`,{position:[.16,0,.1],rotation:[0,0,.55],children:[(0,$.jsx)(`boxGeometry`,{args:[.06,.32,.05]}),(0,$.jsx)($n,{color:r})]})]}),t[6]=o,t[7]=r,t[8]=l):l=t[8];let u;t[9]!==o||t[10]!==r?(u=o===`knowledge`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`mesh`,{children:[(0,$.jsx)(`octahedronGeometry`,{args:[.46,0]}),(0,$.jsx)($n,{color:r})]}),(0,$.jsxs)(`mesh`,{rotation:[Math.PI/2,0,0],children:[(0,$.jsx)(`torusGeometry`,{args:[.58,.025,6,6]}),(0,$.jsx)($n,{color:r})]})]}),t[9]=o,t[10]=r,t[11]=u):u=t[11];let d;t[12]!==o||t[13]!==r?(d=o===`communication`&&(0,$.jsx)($.Fragment,{children:[.25,.42,.59].map(e=>(0,$.jsxs)(`mesh`,{rotation:[0,Math.PI/2,0],children:[(0,$.jsx)(`torusGeometry`,{args:[e,.025,5,20,Math.PI]}),(0,$.jsx)($n,{color:r})]},e))}),t[12]=o,t[13]=r,t[14]=d):d=t[14];let f;t[15]!==o||t[16]!==r?(f=o===`generic`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`mesh`,{children:[(0,$.jsx)(`icosahedronGeometry`,{args:[.4,0]}),(0,$.jsx)($n,{color:r})]}),(0,$.jsxs)(`mesh`,{rotation:[Math.PI/2,0,0],children:[(0,$.jsx)(`torusGeometry`,{args:[.56,.025,5,24]}),(0,$.jsx)($n,{color:r})]})]}),t[15]=o,t[16]=r,t[17]=f):f=t[17];let p;t[18]===r?p=t[19]:(p=(0,$.jsx)(`pointLight`,{color:r,intensity:2.2,distance:4,decay:2}),t[18]=r,t[19]=p);let m;return t[20]!==c||t[21]!==l||t[22]!==u||t[23]!==d||t[24]!==f||t[25]!==p?(m=(0,$.jsxs)(`group`,{ref:i,scale:.7,children:[c,l,u,d,f,p]}),t[20]=c,t[21]=l,t[22]=u,t[23]=d,t[24]=f,t[25]=p,t[26]=m):m=t[26],m}var tr=new W,nr=new B,rr=new ie,ir=new W(0,1,0),ar=new W(0,0,0),or={archived:{flap:0,intensity:.08,opacity:.12},idle:{flap:0,intensity:.45,opacity:.72},thinking:{flap:5,intensity:.85,opacity:.9},tool_call:{flap:8,intensity:1.05,opacity:1},stuck:{flap:2,intensity:.9,opacity:.95},disabled:{flap:0,intensity:.12,opacity:.06}};function sr({desk:e,swarmRef:t}){let{agent:n,state:r,color:i}=e,a=J(e=>e.selectedAgentId===n.id),o=J(e=>e.select),s=J(e=>e.motion),c=J(e=>e.activeCue),l=(0,q.useRef)(null),u=(0,q.useRef)(null),d=(0,q.useRef)(null),f=(0,q.useRef)(null),p=(0,q.useRef)(null),m=(0,q.useRef)(null),h=(0,q.useMemo)(()=>new H({vertexShader:Xn,fragmentShader:Zn,uniforms:{uTime:{value:0},uColor:{value:new R(i)},uIntensity:{value:.65},uGlitch:{value:0},uOpacity:{value:.8}},transparent:!0,depthWrite:!1,side:2,blending:2}),[i]),g=(0,q.useMemo)(()=>new H({vertexShader:Xn,fragmentShader:Zn,uniforms:{uTime:{value:0},uColor:{value:new R(i).lerp(new R(`#ffffff`),.55)},uIntensity:{value:.9},uGlitch:{value:0},uOpacity:{value:.4}},transparent:!0,depthWrite:!1,side:2,blending:2}),[i]),_=(0,q.useMemo)(()=>new R(i),[i]);U((e,i)=>{let o=e.clock.elapsedTime,_=or[r],v=c?.actorId===n.id||c?.targetId===n.id,y=c&&!v&&!a?.28:1;h.uniforms.uTime.value=o,g.uniforms.uTime.value=o;let b=1-.002**i;h.uniforms.uIntensity.value+=(_.intensity-h.uniforms.uIntensity.value)*b,h.uniforms.uOpacity.value+=(_.opacity*y-h.uniforms.uOpacity.value)*b,g.uniforms.uOpacity.value+=(.4*y-g.uniforms.uOpacity.value)*b,h.uniforms.uGlitch.value+=(+(r===`stuck`)-h.uniforms.uGlitch.value)*b;let x=t.current.get(n.id);x&&l.current&&(l.current.position.copy(x.pos),u.current&&(tr.subVectors(x.pos,x.prevPos),tr.lengthSq()>1e-8&&(nr.lookAt(tr,ar,ir),rr.setFromRotationMatrix(nr),u.current.quaternion.slerp(rr,1-.01**i))));let S=s===`calm`&&_.flap>0?Math.sin(o*_.flap)*.45+.2:.15;if(f.current&&(f.current.rotation.z=S),p.current&&(p.current.rotation.z=-S),m.current){let e=r===`disabled`||r===`archived`?0:r===`tool_call`?7:2.6;m.current.intensity+=(e-m.current.intensity)*b}if(d.current){let e=c?.phase===`delegated`&&c.targetId===n.id,t=c?.actorId===n.id&&(c.phase===`completed`||c.phase===`failed`),r=s===`calm`&&e?Math.sin(o*8.5)*.22:s===`calm`&&t?-.16:0;d.current.rotation.x=z.damp(d.current.rotation.x,r,7,i);let a=v&&s===`calm`?1.12:1,l=z.damp(d.current.scale.x,a,6,i);d.current.scale.setScalar(l)}});let v=e=>{e.stopPropagation(),o(a?null:n.id)},y=r===`tool_call`?Yn(e.currentTool):null;return(0,$.jsxs)(`group`,{ref:l,children:[(0,$.jsx)(`group`,{onClick:v,onPointerOver:e=>{e.stopPropagation(),document.body.style.cursor=`pointer`},onPointerOut:()=>{document.body.style.cursor=`auto`},children:(0,$.jsx)(Bt,{width:r===`idle`||r===`disabled`||r===`archived`?0:.65,length:2.2,color:_,attenuation:e=>e*e,children:(0,$.jsx)(`group`,{ref:u,scale:a?.85:.62,children:(0,$.jsxs)(`group`,{ref:d,children:[(0,$.jsx)(`mesh`,{material:h,scale:[.85,.75,1.35],children:(0,$.jsx)(`sphereGeometry`,{args:[.32,14,14]})}),(0,$.jsxs)(`mesh`,{position:[0,0,.1],children:[(0,$.jsx)(`torusGeometry`,{args:[.24,.045,8,20]}),(0,$.jsx)(`meshStandardMaterial`,{color:`#241804`,metalness:.4,roughness:.6})]}),(0,$.jsxs)(`mesh`,{position:[0,0,-.14],children:[(0,$.jsx)(`torusGeometry`,{args:[.22,.04,8,20]}),(0,$.jsx)(`meshStandardMaterial`,{color:`#241804`,metalness:.4,roughness:.6})]}),(0,$.jsx)(`mesh`,{material:h,position:[0,.03,.5],children:(0,$.jsx)(`sphereGeometry`,{args:[.18,12,12]})}),(0,$.jsx)(`mesh`,{material:h,position:[0,0,-.52],rotation:[-Math.PI/2,0,0],children:(0,$.jsx)(`coneGeometry`,{args:[.07,.22,8]})}),(0,$.jsx)(`mesh`,{ref:f,material:g,position:[.26,.24,.05],rotation:[.35,0,.5],scale:[1,.08,.55],children:(0,$.jsx)(`sphereGeometry`,{args:[.3,10,10]})}),(0,$.jsx)(`mesh`,{ref:p,material:g,position:[-.26,.24,.05],rotation:[.35,0,-.5],scale:[1,.08,.55],children:(0,$.jsx)(`sphereGeometry`,{args:[.3,10,10]})})]})})})}),(0,$.jsx)(`pointLight`,{ref:m,color:i,intensity:2.6,distance:8,decay:1.7}),r===`tool_call`&&(0,$.jsx)(er,{toolName:e.currentTool,color:i}),r===`thinking`&&(0,$.jsxs)(`mesh`,{position:[0,.95,0],rotation:[-Math.PI/2,0,0],children:[(0,$.jsx)(`ringGeometry`,{args:[.42,.52,6]}),(0,$.jsx)(`meshBasicMaterial`,{color:i,transparent:!0,opacity:.42,blending:2,depthWrite:!1})]}),r===`stuck`&&(0,$.jsxs)(`mesh`,{position:[0,1.05,0],rotation:[-Math.PI/2,0,0],children:[(0,$.jsx)(`ringGeometry`,{args:[.52,.68,6]}),(0,$.jsx)(`meshBasicMaterial`,{color:`#fb7185`,transparent:!0,opacity:.86,blending:2,depthWrite:!1})]}),e.currentTask&&(0,$.jsx)(nt,{position:[0,1.55,0],center:!0,distanceFactor:17,className:`pointer-events-none select-none`,children:(0,$.jsxs)(`div`,{className:`office3d-task-chip`,style:{"--chip-color":i},children:[(0,$.jsx)(`span`,{className:`office3d-task-chip-prefix`,children:`◈`}),` `,e.currentTask]})}),y&&(0,$.jsx)(nt,{position:[0,e.currentTask?1.05:1.3,0],center:!0,distanceFactor:17,className:`pointer-events-none select-none`,children:(0,$.jsx)(`div`,{className:`office3d-tool-chip`,style:{"--chip-color":i},children:y})}),(0,$.jsx)(nt,{position:[0,-.85,0],center:!0,distanceFactor:16,className:`pointer-events-none select-none`,zIndexRange:[10,0],children:(0,$.jsxs)(`div`,{className:`office3d-name-plate ${a?`is-active`:``}`,style:{"--chip-color":i},children:[(0,$.jsx)(`span`,{className:`office3d-name-dot office3d-name-dot--${r}`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`strong`,{children:n.name}),(0,$.jsx)(`small`,{children:n.description||`Agente especialista`})]})]})})]})}var cr=new Set([`failed`,`aborted`,`review_failed`,`blocked`]);function lr(e){return cr.has(e)?4200:e===`completed`?3200:2800}function ur(e){return cr.has(e)}function dr(e,t){return e.some(e=>e.eventId===t.eventId)?e:(ur(t.phase)?[t,...e]:[...e,t]).slice(0,3)}function fr(e){switch(e){case`delegated`:return`Delegando trabajo`;case`review_passed`:return`Revisión aprobada`;case`review_failed`:return`Revisión no aprobada`;case`completed`:return`Entregando resultado`;case`failed`:return`Trabajo fallido`;case`aborted`:return`Trabajo interrumpido`;case`blocked`:return`Agente bloqueado`}}function pr(e){return e===`failed`||e===`aborted`||e===`review_failed`?`alert`:e===`completed`||e===`review_passed`?`done`:`work`}var mr=new W(0,4.4,0),hr=2.25,gr=0;function _r(e,t){let n=pr(e.phase);return n===`alert`?`#fb7185`:n===`done`?`#86efac`:n===`review`?`#67e8f9`:t??`#f59e0b`}function vr({desks:e,events:t,swarmRef:n,coordinatorId:r,coordinatorName:i}){let[a,o]=(0,q.useState)([]),s=(0,q.useRef)(new Set),c=(0,q.useRef)(!1);return(0,q.useEffect)(()=>{if(!c.current){t.forEach(e=>s.current.add(e.eventId)),c.current=!0;return}let n=new Map(e.map(e=>[e.agent.id,e])),a=e=>e===r?i:n.get(e)?.agent.name??`Agente`,l=[];for(let e of t){if(s.current.has(e.eventId))continue;s.current.add(e.eventId);let t=e.targetId||r;t&&l.push({id:++gr,event:e,startId:e.actorId,endId:t,sourceName:a(e.actorId),targetName:a(t),color:_r(e,n.get(t)?.color??n.get(e.actorId)?.color)})}l.length>0&&o(e=>[...e,...l].slice(-8))},[r,i,e,t]),(0,$.jsx)(`group`,{children:a.map(e=>(0,$.jsx)(yr,{transfer:e,swarmRef:n,coordinatorId:r,onDone:()=>o(t=>t.filter(t=>t.id!==e.id))},e.id))})}function yr({transfer:e,swarmRef:t,coordinatorId:n,onDone:r}){let i=(0,q.useRef)(null),a=(0,q.useRef)(null),o=(0,q.useRef)(null),s=(0,q.useRef)(0),c=(0,q.useRef)(!1),l=(0,q.useRef)(new W),u=(0,q.useRef)(new W);U((d,f)=>{if(c.current||!i.current)return;s.current=Math.min(hr,s.current+f);let p=e.startId===n?mr:t.current.get(e.startId)?.pos,m=e.endId===n?mr:t.current.get(e.endId)?.pos;if(!p||!m){i.current.visible=!1,s.current>=hr&&(c.current=!0,r());return}i.current.visible=!0,l.current.copy(p),u.current.copy(m);let h=s.current/hr,g=1-(1-Math.min(1,Math.max(0,(h-.14)/.86)))**3;if(i.current.position.lerpVectors(l.current,u.current,g),i.current.position.y+=Math.sin(g*Math.PI)*2.2,i.current.rotation.x+=f*2.4,i.current.rotation.y+=f*3.2,o.current?.position.copy(i.current.position),a.current){a.current.position.copy(l.current),a.current.visible=h<.46;let e=.8+h*5.2%1*1.35;a.current.scale.setScalar(e),a.current.rotation.y+=f*.8}s.current>=hr&&(c.current=!0,r())});let d=e.event.phase===`delegated`?`${e.sourceName} llama a ${e.targetName}`:e.event.phase===`completed`?`${e.sourceName} entrega a ${e.targetName}`:`${e.sourceName} informa a ${e.targetName}`;return(0,$.jsxs)(`group`,{children:[(0,$.jsx)(`group`,{ref:a,children:[.72,1.08].map((t,n)=>(0,$.jsxs)(`mesh`,{rotation:[Math.PI/2,0,0],children:[(0,$.jsx)(`torusGeometry`,{args:[t,n===0?.055:.035,6,28]}),(0,$.jsx)(`meshBasicMaterial`,{color:e.color,transparent:!0,opacity:n===0?.72:.42,blending:2,depthWrite:!1})]},t))}),(0,$.jsxs)(`mesh`,{ref:i,children:[(0,$.jsx)(`octahedronGeometry`,{args:[.3,0]}),(0,$.jsx)(`meshBasicMaterial`,{color:e.color,transparent:!0,opacity:.98,blending:2,depthWrite:!1})]}),(0,$.jsx)(`group`,{ref:o,children:(0,$.jsx)(nt,{position:[0,.75,0],center:!0,distanceFactor:20,className:`pointer-events-none select-none`,children:(0,$.jsxs)(`div`,{className:`office3d-transfer-label is-compact is-${pr(e.event.phase)}`,style:{"--chip-color":e.color},children:[(0,$.jsx)(`span`,{children:d}),(0,$.jsx)(`strong`,{children:fr(e.event.phase).toUpperCase()})]})})})]})}function br({events:e,desks:t,coordinatorId:n}){let r=J(e=>e.setActiveCue),i=(0,q.useRef)(new Set),a=(0,q.useRef)(!1),o=(0,q.useRef)([]),s=(0,q.useRef)(null),c=(0,q.useRef)(null),l=(0,q.useRef)(new Map),u=(0,q.useRef)(!1),d=(0,q.useCallback)(function e(){if(s.current||o.current.length===0)return;let t=o.current.shift()??null;s.current=t,r(t),t&&(c.current=setTimeout(()=>{s.current=null,r(null),c.current=null,e()},lr(t.phase)))},[r]),f=(0,q.useCallback)(e=>{ur(e.phase)&&s.current&&!ur(s.current.phase)&&(c.current&&clearTimeout(c.current),o.current=dr(o.current,s.current),s.current=null,r(null)),o.current=dr(o.current,e),d()},[d,r]);return(0,q.useEffect)(()=>{if(!a.current){e.forEach(e=>i.current.add(e.eventId)),a.current=!0;return}for(let t of e)i.current.has(t.eventId)||(i.current.add(t.eventId),f(t))},[e,f]),(0,q.useEffect)(()=>{if(!u.current){l.current=new Map(t.map(e=>[e.agent.id,e.state])),u.current=!0;return}for(let e of t){let t=l.current.get(e.agent.id);e.state===`stuck`&&t!==`stuck`&&f({eventId:`blocked:${e.agent.id}:${Date.now()}`,phase:`blocked`,taskRef:e.taskId??`agent:${e.agent.id}`,taskName:e.currentTask??`Ejecución del agente`,actorId:e.agent.id,targetId:n,detail:`El agente necesita atención`,timestamp:Date.now()}),l.current.set(e.agent.id,e.state)}},[n,t,f]),(0,q.useEffect)(()=>()=>{c.current&&clearTimeout(c.current),r(null)},[r]),null}var xr=new W(0,7.6,0),Sr=new W(0,4.4,0),Cr=1.7,wr=6;function Tr(e){let t=(0,K.c)(46),{status:n,decisions:r,swarmRef:i,coordinatorId:a,motion:o}=e,s=(0,q.useRef)(null),c=(0,q.useRef)(null),l=(0,q.useRef)(null),u=(0,q.useRef)(null),d=(0,q.useRef)(0),f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=[],t[0]=f):f=t[0];let[p,m]=(0,q.useState)(f),h;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(h=new Set,t[1]=h):h=t[1];let g=(0,q.useRef)(h),_=(0,q.useRef)(!1),v,y;t[2]!==r||t[3]!==o?(v=()=>{if(!_.current){r.forEach(e=>g.current.add(e.eventId)),_.current=!0;return}let e=r.filter(e=>!g.current.has(e.eventId));e.length!==0&&(e.forEach(e=>g.current.add(e.eventId)),d.current=1,o!==`off`&&m(t=>[...t,...e.map(Er)].slice(-wr)))},y=[r,o],t[2]=r,t[3]=o,t[4]=v,t[5]=y):(v=t[4],y=t[5]),(0,q.useEffect)(v,y);let b=n?.state===`fallback`,x=b?De:Ee,S;if(t[6]!==b||t[7]!==o?(S=(e,t)=>{let n=e.clock.elapsedTime;d.current=Math.max(0,d.current-t*1.4);let r=o===`calm`?(b?.12:.35)+d.current*2.2:0;if(s.current&&(s.current.rotation.y=s.current.rotation.y+t*r,s.current.rotation.x=s.current.rotation.x+t*r*.4,s.current.scale.setScalar(1+d.current*.22)),c.current){let e=c.current.material;e.emissiveIntensity=(b?.25+Math.max(0,Math.sin(n*9))*.15:.7+Math.sin(n*1.6)*.12)+d.current*1.6,c.current.rotation.y=c.current.rotation.y-t*r*.6}l.current&&(l.current.rotation.z=l.current.rotation.z+t*(o===`calm`?.5+d.current*3:0)),u.current&&(u.current.intensity=(b?1.2:3)+d.current*9)},t[6]=b,t[7]=o,t[8]=S):S=t[8],U(S),!n||n.state===`off`)return null;let C;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(`icosahedronGeometry`,{args:[.95,0]}),t[9]=C):C=t[9];let w;t[10]===x?w=t[11]:(w=(0,$.jsxs)(`mesh`,{ref:s,children:[C,(0,$.jsx)(`meshBasicMaterial`,{color:x,wireframe:!0,transparent:!0,opacity:.55,blending:2,depthWrite:!1})]}),t[10]=x,t[11]=w);let T;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(`octahedronGeometry`,{args:[.45,0]}),t[12]=T):T=t[12];let E;t[13]===x?E=t[14]:(E=(0,$.jsxs)(`mesh`,{ref:c,children:[T,(0,$.jsx)(`meshStandardMaterial`,{color:`#1e1535`,emissive:x,emissiveIntensity:.7,metalness:.4,roughness:.25})]}),t[13]=x,t[14]=E);let D,O;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(D=[Math.PI/2,0,0],O=(0,$.jsx)(`torusGeometry`,{args:[1.45,.025,6,48]}),t[15]=D,t[16]=O):(D=t[15],O=t[16]);let k,A;t[17]===x?(k=t[18],A=t[19]):(k=(0,$.jsx)(`group`,{ref:l,rotation:D,children:(0,$.jsxs)(`mesh`,{children:[O,(0,$.jsx)(`meshBasicMaterial`,{color:x,transparent:!0,opacity:.45,blending:2,depthWrite:!1})]})}),A=(0,$.jsx)(`pointLight`,{ref:u,color:x,intensity:3,distance:12,decay:1.8}),t[17]=x,t[18]=k,t[19]=A);let j;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(j=[0,1.55,0],t[20]=j):j=t[20];let M=`office3d-jev-tag ${b?`is-fallback`:``}`,N;t[21]===n?N=t[22]:(N=Ae(n).toUpperCase(),t[21]=n,t[22]=N);let P;t[23]!==M||t[24]!==N?(P=(0,$.jsx)(nt,{position:j,center:!0,distanceFactor:22,className:`pointer-events-none select-none`,children:(0,$.jsx)(`div`,{className:M,children:N})}),t[23]=M,t[24]=N,t[25]=P):P=t[25];let F;t[26]!==k||t[27]!==A||t[28]!==P||t[29]!==w||t[30]!==E?(F=(0,$.jsxs)(`group`,{position:xr,children:[w,E,k,A,P]}),t[26]=k,t[27]=A,t[28]=P,t[29]=w,t[30]=E,t[31]=F):F=t[31];let I;if(t[32]!==p||t[33]!==x||t[34]!==a||t[35]!==n||t[36]!==i){let e;t[38]!==x||t[39]!==a||t[40]!==n||t[41]!==i?(e=e=>(0,$.jsx)(Dr,{beam:e,swarmRef:i,coordinatorId:a,color:x,name:Ae(n),onDone:()=>m(t=>t.filter(t=>t.decision.eventId!==e.decision.eventId))},e.decision.eventId),t[38]=x,t[39]=a,t[40]=n,t[41]=i,t[42]=e):e=t[42],I=p.map(e),t[32]=p,t[33]=x,t[34]=a,t[35]=n,t[36]=i,t[37]=I}else I=t[37];let L;return t[43]!==F||t[44]!==I?(L=(0,$.jsxs)(`group`,{children:[F,I]}),t[43]=F,t[44]=I,t[45]=L):L=t[45],L}function Er(e){return{decision:e,chip:Ne(e.savedTokens)}}function Dr(e){let t=(0,K.c)(31),{beam:n,swarmRef:r,coordinatorId:i,color:a,name:o,onDone:s}=e,c=(0,q.useRef)(null),l=(0,q.useRef)(null),u=(0,q.useRef)(null),d=(0,q.useRef)(0),f=(0,q.useRef)(!1),p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=new W,t[0]=p):p=t[0];let m=(0,q.useRef)(p),h;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(h=new W,t[1]=h):h=t[1];let g=(0,q.useRef)(h),{decision:_,chip:v}=n,y;t[2]!==i||t[3]!==_.agentId||t[4]!==s||t[5]!==r?(y=(e,t)=>{if(f.current)return;d.current+=t;let n=_.agentId===i?Sr:r.current.get(_.agentId)?.pos;n?m.current.copy(n):m.current.copy(Sr),g.current.lerpVectors(xr,m.current,.5),g.current.y=g.current.y+2.4;let a=Math.min(1,d.current/Cr),o=a<.2?a/.2:1-Math.max(0,(a-.55)/.45);if(c.current&&(c.current.setPoints(xr,m.current,g.current),c.current.material.opacity=o*.85),l.current){let e=Math.min(1,a/.45),t=1-e;l.current.position.set(t*t*xr.x+2*t*e*g.current.x+e*e*m.current.x,t*t*xr.y+2*t*e*g.current.y+e*e*m.current.y,t*t*xr.z+2*t*e*g.current.z+e*e*m.current.z),l.current.material.opacity=o}u.current?.position.copy(m.current),a>=1&&(f.current=!0,s())},t[2]=i,t[3]=_.agentId,t[4]=s,t[5]=r,t[6]=y):y=t[6],U(y);let b;t[7]===a?b=t[8]:(b=(0,$.jsx)(Ot,{ref:c,start:xr,end:Sr,color:a,lineWidth:1.6,transparent:!0,opacity:0,depthWrite:!1}),t[7]=a,t[8]=b);let x;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(`sphereGeometry`,{args:[.16,10,8]}),t[9]=x):x=t[9];let S;t[10]===a?S=t[11]:(S=(0,$.jsxs)(`mesh`,{ref:l,children:[x,(0,$.jsx)(`meshBasicMaterial`,{color:a,transparent:!0,opacity:0,blending:2,depthWrite:!1})]}),t[10]=a,t[11]=S);let C;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(C=[0,1.35,0],t[12]=C):C=t[12];let w;t[13]===_.kind?w=t[14]:(w=ke(_.kind),t[13]=_.kind,t[14]=w);let T;t[15]!==o||t[16]!==w?(T=(0,$.jsxs)(`span`,{children:[o,` · `,w]}),t[15]=o,t[16]=w,t[17]=T):T=t[17];let E;t[18]!==v||t[19]!==_.savedTokens?(E=v&&(0,$.jsx)(`strong`,{className:_.savedTokens<0?`is-cost`:``,children:v}),t[18]=v,t[19]=_.savedTokens,t[20]=E):E=t[20];let D;t[21]===_.latencyMs?D=t[22]:(D=(0,$.jsxs)(`small`,{children:[_.latencyMs,` ms`]}),t[21]=_.latencyMs,t[22]=D);let O;t[23]!==E||t[24]!==D||t[25]!==T?(O=(0,$.jsx)(`group`,{ref:u,children:(0,$.jsx)(nt,{position:C,center:!0,distanceFactor:20,className:`pointer-events-none select-none`,children:(0,$.jsxs)(`div`,{className:`office3d-jev-chip`,children:[T,E,D]})})}),t[23]=E,t[24]=D,t[25]=T,t[26]=O):O=t[26];let k;return t[27]!==O||t[28]!==b||t[29]!==S?(k=(0,$.jsxs)(`group`,{children:[b,S,O]}),t[27]=O,t[28]=b,t[29]=S,t[30]=k):k=t[30],k}function Or(e){let t=(0,K.c)(74),{desks:n,coordinator:r,interactions:i,workEvents:a,jev:o}=e,s=J(Fr),c=J(Pr),l=J(Nr),u=typeof window<`u`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`off`:l,d=J(Mr),f=J(jr),p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=new Map,t[0]=p):p=t[0];let m=(0,q.useRef)(p),h;t[1]===n?h=t[2]:(h=n.some(Ar),t[1]=n,t[2]=h);let g=h,_;t[3]===s?_=t[4]:(_=s===`high`?[1,1.75]:1,t[3]=s,t[4]=_);let v;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(v={antialias:!1,alpha:!1,powerPreference:`high-performance`},t[5]=v):v=t[5];let y;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(y={fov:42,near:.1,far:220,position:[0,46,62]},t[6]=y):y=t[6];let b;t[7]===f?b=t[8]:(b=()=>f(null),t[7]=f,t[8]=b);let x;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(`color`,{attach:`background`,args:[`#04060c`]}),t[9]=x):x=t[9];let S,C,w;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(`fog`,{attach:`fog`,args:[`#04060c`,34,100]}),w=(0,$.jsx)(`ambientLight`,{intensity:.35}),S=(0,$.jsx)(`directionalLight`,{position:[12,24,8],intensity:.35,color:`#9db8ff`}),t[10]=S,t[11]=C,t[12]=w):(S=t[10],C=t[11],w=t[12]);let T=r?.id??null,E;t[13]!==n||t[14]!==T||t[15]!==a?(E=(0,$.jsx)(br,{events:a,desks:n,coordinatorId:T}),t[13]=n,t[14]=T,t[15]=a,t[16]=E):E=t[16];let D;t[17]!==n||t[18]!==u?(D=(0,$.jsx)(qn,{desks:n,swarmRef:m,motion:u}),t[17]=n,t[18]=u,t[19]=D):D=t[19];let O=r?.id??null,k;t[20]!==u||t[21]!==d||t[22]!==O?(k=(0,$.jsx)(Qt,{coordinatorId:O,selectedAgentId:d,swarmRef:m,motion:u}),t[20]=u,t[21]=d,t[22]=O,t[23]=k):k=t[23];let A;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(cn,{}),t[24]=A):A=t[24];let j;t[25]!==g||t[26]!==r?(j=(0,$.jsx)(bn,{coordinator:r,active:g,swarmRef:m}),t[25]=g,t[26]=r,t[27]=j):j=t[27];let M;t[28]===n?M=t[29]:(M=n.map(e=>(0,$.jsx)(sr,{desk:e,swarmRef:m},e.agent.id)),t[28]=n,t[29]=M);let N=r?.id??null,P;t[30]!==n||t[31]!==i||t[32]!==N?(P=(0,$.jsx)(An,{desks:n,interactions:i,swarmRef:m,coordinatorId:N}),t[30]=n,t[31]=i,t[32]=N,t[33]=P):P=t[33];let F=r?.id??null,I;t[34]!==u||t[35]!==o.decisions||t[36]!==o.status||t[37]!==F?(I=(0,$.jsx)(Tr,{status:o.status,decisions:o.decisions,swarmRef:m,coordinatorId:F,motion:u}),t[34]=u,t[35]=o.decisions,t[36]=o.status,t[37]=F,t[38]=I):I=t[38];let L;t[39]!==r?.id||t[40]!==r?.name||t[41]!==n||t[42]!==u||t[43]!==a?(L=u===`calm`&&(0,$.jsx)(vr,{desks:n,events:a,swarmRef:m,coordinatorId:r?.id??null,coordinatorName:r?.name??`Coordinador`}),t[39]=r?.id,t[40]=r?.name,t[41]=n,t[42]=u,t[43]=a,t[44]=L):L=t[44];let R;t[45]!==n||t[46]!==u||t[47]!==s?(R=u===`calm`&&s===`high`&&(0,$.jsx)(Un,{desks:n,swarmRef:m}),t[45]=n,t[46]=u,t[47]=s,t[48]=R):R=t[48];let z;t[49]!==u||t[50]!==s?(z=u===`calm`&&s===`high`&&(0,$.jsx)(zn,{}),t[49]=u,t[50]=s,t[51]=z):z=t[51];let B;t[52]===s?B=t[53]:(B=(0,$.jsx)(Gn,{quality:s}),t[52]=s,t[53]=B);let V;t[54]!==s||t[55]!==c?(V=(0,$.jsx)(Ht,{bounds:kr,onDecline:()=>{s===`high`&&c(`low`)}}),t[54]=s,t[55]=c,t[56]=V):V=t[56];let H;t[57]!==E||t[58]!==D||t[59]!==k||t[60]!==j||t[61]!==M||t[62]!==P||t[63]!==I||t[64]!==L||t[65]!==R||t[66]!==z||t[67]!==B||t[68]!==V?(H=(0,$.jsxs)(q.Suspense,{fallback:null,children:[E,D,k,A,j,M,P,I,L,R,z,B,V]}),t[57]=E,t[58]=D,t[59]=k,t[60]=j,t[61]=M,t[62]=P,t[63]=I,t[64]=L,t[65]=R,t[66]=z,t[67]=B,t[68]=V,t[69]=H):H=t[69];let ee;return t[70]!==H||t[71]!==_||t[72]!==b?(ee=(0,$.jsxs)(he,{dpr:_,gl:v,camera:y,onPointerMissed:b,children:[x,C,w,S,H]}),t[70]=H,t[71]=_,t[72]=b,t[73]=ee):ee=t[73],ee}function kr(e){return[Math.min(42,e*.68),e*.92]}function Ar(e){return e.state===`thinking`||e.state===`tool_call`||e.state===`stuck`}function jr(e){return e.select}function Mr(e){return e.selectedAgentId}function Nr(e){return e.motion}function Pr(e){return e.setQuality}function Fr(e){return e.quality}function Ir(e){let t=(0,K.c)(8),{events:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`div`,{className:`office3d-ticker-title`,children:`Actividad`}),t[0]=r):r=t[0];let i;t[1]===n.length?i=t[2]:(i=n.length===0&&(0,$.jsx)(`div`,{className:`office3d-ticker-empty`,children:`Sin eventos todavía…`}),t[1]=n.length,t[2]=i);let a;t[3]===n?a=t[4]:(a=n.slice(0,6).map(Lr),t[3]=n,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,$.jsxs)(`div`,{className:`office3d-ticker`,children:[r,(0,$.jsxs)(`div`,{className:`office3d-ticker-list`,role:`log`,"aria-live":`polite`,"aria-relevant":`additions`,children:[i,a]})]}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o}function Lr(e){return(0,$.jsxs)(`div`,{className:`office3d-ticker-item office3d-ticker-item--${e.kind}`,children:[(0,$.jsx)(`span`,{className:`office3d-ticker-dot`,style:{background:e.color}}),(0,$.jsx)(`span`,{className:`office3d-ticker-text`,children:e.text}),(0,$.jsx)(`span`,{className:`office3d-ticker-time`,children:e.time})]},e.id)}var Rr=0;function zr(e,t){return t===`tool_call`&&!e.currentTask?{text:`${e.agent.name} · ${Yn(e.currentTool)??`Ejecutando herramienta`}`,color:e.color,kind:`work`}:t===`thinking`&&!e.currentTask?{text:`${e.agent.name} está pensando…`,color:e.color,kind:`info`}:t===`stuck`?{text:`${e.agent.name} necesita ayuda`,color:`#f87171`,kind:`warn`}:null}function Br(e,t,n,r,i=[]){let[a,o]=(0,q.useState)([]),s=(0,q.useRef)(new Map),c=(0,q.useRef)(new Set),l=(0,q.useRef)(new Set),u=(0,q.useRef)(!1);return(0,q.useEffect)(()=>{let a=s.current,d=new Map(e.map(e=>[e.agent.id,e])),f=[],p=new Date().toLocaleTimeString(`es`,{hour12:!1}),m=e=>e===n?.id?n.name:d.get(e)?.agent.name??e;if(u.current){for(let e of r){if(c.current.has(e.eventId))continue;c.current.add(e.eventId);let t=pr(e.phase);f.push({id:++Rr,time:new Date(e.timestamp).toLocaleTimeString(`es`,{hour12:!1}),text:`${fr(e.phase)} · ${m(e.actorId)}${e.targetId?` → ${m(e.targetId)}`:``}: «${e.taskName}»`,color:t===`alert`?`#fb7185`:t===`done`?`#86efac`:d.get(e.targetId??``)?.color??`#f59e0b`,kind:t===`alert`?`warn`:t===`done`?`done`:`work`})}for(let e of i){if(l.current.has(e.eventId)||(l.current.add(e.eventId),e.kind!==`context`))continue;let t=Ne(e.savedTokens);f.push({id:++Rr,time:new Date(e.timestamp).toLocaleTimeString(`es`,{hour12:!1}),text:`Jev → ${m(e.agentId)}: ${e.summary}${t?` (${t})`:``}${e.recommendedAgentId?` · sugiere ${m(e.recommendedAgentId)}`:``}${e.mcpOff?.length?` (encender ${e.mcpOff.join(`, `)})`:``}`,color:Ee,kind:`info`})}}else{r.forEach(e=>c.current.add(e.eventId)),i.forEach(e=>l.current.add(e.eventId));for(let e of t)f.push({id:++Rr,time:p,text:`${m(e.sourceId)} → ${m(e.targetId)}: «${e.taskName??`Flujo activo`}»`,color:d.get(e.targetId)?.color??`#f59e0b`,kind:`work`});u.current=!0}for(let t of e){let e=a.get(t.agent.id);if(e&&e.state!==t.state){let e=zr(t,t.state);e&&f.push({id:++Rr,time:p,...e})}a.set(t.agent.id,{state:t.state})}f.length&&o(e=>[...f.reverse(),...e].slice(0,24))},[e,t,n,r,i]),a}function Vr(e){let t=(0,K.c)(63),{status:n,decisions:r,coordinator:i,desks:a}=e,[o,s]=(0,q.useState)(!1),l=C(Gr);if(!n||n.state===`off`)return null;let u;t[0]!==i||t[1]!==a?(u=e=>e===i?.id?i.name:a.find(t=>t.agent.id===e)?.agent.name??e,t[0]=i,t[1]=a,t[2]=u):u=t[2];let f=u,m;t[3]===n.totals?m=t[4]:(m=n.totals??{decisions:0,savedTokens:0,costUsd:0},t[3]=n.totals,t[4]=m);let h=m,g=r[r.length-1],_;t[5]===r?_=t[6]:(_=r.length?Math.round(r.reduce(Wr,0)/r.length):null,t[5]=r,t[6]=_);let v=_,y;if(t[7]!==v||t[8]!==l||t[9]!==o||t[10]!==g||t[11]!==f||t[12]!==n||t[13]!==h.costUsd||t[14]!==h.decisions||t[15]!==h.savedTokens){let e=Object.entries(l).sort(Ur).slice(0,4),r,i;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`span`,{className:`office3d-jev-icon`,children:(0,$.jsx)(p,{size:14})}),i=(0,$.jsx)(`span`,{className:`office3d-section-kicker`,children:`PLANO DE DECISIÓN`}),t[17]=r,t[18]=i):(r=t[17],i=t[18]);let a;t[19]===n?a=t[20]:(a=Ae(n),t[19]=n,t[20]=a);let u;t[21]===n.state?u=t[22]:(u=je(n.state),t[21]=n.state,t[22]=u);let m;t[23]!==a||t[24]!==u?(m=(0,$.jsxs)(`div`,{children:[i,(0,$.jsxs)(`h2`,{children:[a,` · `,u]})]}),t[23]=a,t[24]=u,t[25]=m):m=t[25];let _;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>s(Hr),t[26]=_):_=t[26];let b=o?`Mostrar detalle de Jev`:`Ocultar detalle de Jev`,x=!o,S;t[27]===o?S=t[28]:(S=o?(0,$.jsx)(c,{size:14}):(0,$.jsx)(d,{size:14}),t[27]=o,t[28]=S);let C;t[29]!==b||t[30]!==x||t[31]!==S?(C=(0,$.jsx)(`button`,{type:`button`,className:`office3d-roster-toggle`,onClick:_,"aria-label":b,"aria-expanded":x,children:S}),t[29]=b,t[30]=x,t[31]=S,t[32]=C):C=t[32];let w;t[33]!==C||t[34]!==m?(w=(0,$.jsxs)(`header`,{className:`office3d-jev-head`,children:[r,m,C]}),t[33]=C,t[34]=m,t[35]=w):w=t[35];let T;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(`dt`,{children:`Decisiones`}),t[36]=T):T=t[36];let E;t[37]===h.decisions?E=t[38]:(E=(0,$.jsxs)(`div`,{children:[T,(0,$.jsx)(`dd`,{children:h.decisions})]}),t[37]=h.decisions,t[38]=E);let D=h.savedTokens>=0?`Tokens ahorrados`:`Tokens añadidos`,O;t[39]===D?O=t[40]:(O=(0,$.jsx)(`dt`,{children:D}),t[39]=D,t[40]=O);let k;t[41]===h.savedTokens?k=t[42]:(k=Me(h.savedTokens),t[41]=h.savedTokens,t[42]=k);let A;t[43]===k?A=t[44]:(A=(0,$.jsxs)(`dd`,{children:[`~`,k]}),t[43]=k,t[44]=A);let j;t[45]!==O||t[46]!==A?(j=(0,$.jsxs)(`div`,{children:[O,A]}),t[45]=O,t[46]=A,t[47]=j):j=t[47];let M;t[48]===n?M=t[49]:(M=Ae(n),t[48]=n,t[49]=M);let N;t[50]===M?N=t[51]:(N=(0,$.jsxs)(`dt`,{children:[`Costo `,M]}),t[50]=M,t[51]=N);let P;t[52]===h.costUsd?P=t[53]:(P=Pe(h.costUsd),t[52]=h.costUsd,t[53]=P);let F;t[54]===P?F=t[55]:(F=(0,$.jsx)(`dd`,{children:P}),t[54]=P,t[55]=F);let I;t[56]!==N||t[57]!==F?(I=(0,$.jsxs)(`div`,{children:[N,F]}),t[56]=N,t[57]=F,t[58]=I):I=t[58];let L;t[59]!==E||t[60]!==j||t[61]!==I?(L=(0,$.jsxs)(`dl`,{className:`office3d-jev-metrics`,children:[E,j,I]}),t[59]=E,t[60]=j,t[61]=I,t[62]=L):L=t[62],y=(0,$.jsxs)(`section`,{className:`office3d-jev office3d-glass ${n.state===`fallback`?`is-fallback`:``} ${o?`is-collapsed`:``}`,"aria-label":`Jev, plano de decisión`,children:[w,L,!o&&(0,$.jsxs)($.Fragment,{children:[n.state===`fallback`&&n.lastError&&(0,$.jsxs)(`p`,{className:`office3d-jev-warn`,children:[`Usando el flujo clásico: `,n.lastError]}),g&&(0,$.jsxs)(`div`,{className:`office3d-jev-latest`,children:[(0,$.jsxs)(`span`,{children:[`Última decisión · `,f(g.agentId),` · `,ke(g.kind)]}),(0,$.jsx)(`p`,{children:g.summary}),g.recommendedAgentId&&(g.mcpOff?.length?(0,$.jsxs)(`p`,{className:`office3d-jev-warn`,children:[f(g.recommendedAgentId),` es el indicado, pero necesita encender `,g.mcpOff.join(`, `)]}):(0,$.jsxs)(`p`,{children:[`Recomendó delegar en `,f(g.recommendedAgentId)]}))]}),e.length>0&&(0,$.jsx)(`ul`,{className:`office3d-jev-agents`,"aria-label":`Ahorro por agente desde que abriste la oficina`,children:e.map(e=>{let[t,n]=e;return(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`span`,{children:f(t)}),(0,$.jsxs)(`b`,{children:[n.savedTokens>=0?`−`:`+`,Me(n.savedTokens)]}),(0,$.jsxs)(`small`,{children:[n.decisions,` dec.`]})]},t)})}),(0,$.jsxs)(`p`,{className:`office3d-jev-note`,children:[`Estimación frente al flujo clásico (caracteres ÷ 4)`,v===null?``:` · ${v} ms de media`]})]})]}),t[7]=v,t[8]=l,t[9]=o,t[10]=g,t[11]=f,t[12]=n,t[13]=h.costUsd,t[14]=h.decisions,t[15]=h.savedTokens,t[16]=y}else y=t[16];return y}function Hr(e){return!e}function Ur(e,t){let[,n]=e,[,r]=t;return r.savedTokens-n.savedTokens}function Wr(e,t){return e+t.latencyMs}function Gr(e){return e.jevByAgent}function Kr(e){let t=(0,K.c)(9),{agentId:n}=e,r;t[0]===n?r=t[1]:(r=e=>e.jevByAgent[n],t[0]=n,t[1]=r);let i=C(r);if(!i)return null;let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(`span`,{className:`office3d-inspector-label`,children:`Jev`}),t[2]=a):a=t[2];let o=i.decisions,s=i.savedTokens>=0?`−`:`+`,c;t[3]===i.savedTokens?c=t[4]:(c=Me(i.savedTokens),t[3]=i.savedTokens,t[4]=c);let l;return t[5]!==i.decisions||t[6]!==s||t[7]!==c?(l=(0,$.jsxs)(`div`,{className:`office3d-inspector-row`,children:[a,(0,$.jsxs)(`span`,{className:`font-mono`,children:[o,` dec. · `,s,c,` tok`]})]}),t[5]=i.decisions,t[6]=s,t[7]=c,t[8]=l):l=t[8],l}var qr={archived:`Archivado manualmente`,disabled:`Desactivado`,idle:`En espera`,thinking:`Pensando`,tool_call:`Ejecutando herramienta`,stuck:`Atascado`};function Jr({desk:e,delegatorName:t}){let n=J(e=>e.select);if(!e)return null;let{agent:r}=e;return(0,$.jsxs)(`aside`,{className:`office3d-inspector`,style:{"--agent-color":e.color},children:[(0,$.jsx)(`button`,{type:`button`,className:`office3d-inspector-close`,onClick:()=>n(null),"aria-label":`Cerrar`,children:(0,$.jsx)(O,{size:14})}),(0,$.jsxs)(`div`,{className:`office3d-inspector-head`,children:[(0,$.jsx)(`span`,{className:`office3d-inspector-orb`}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`office3d-inspector-name`,children:r.name}),(0,$.jsx)(`span`,{className:`office3d-inspector-id`,children:r.id})]})]}),(0,$.jsxs)(`div`,{className:`office3d-inspector-row`,children:[(0,$.jsx)(`span`,{className:`office3d-inspector-label`,children:`Rol`}),(0,$.jsx)(`span`,{children:r.role===`coordinator`?`Coordinador`:`Especialista`})]}),(0,$.jsxs)(`div`,{className:`office3d-inspector-row`,children:[(0,$.jsx)(`span`,{className:`office3d-inspector-label`,children:`Estado`}),(0,$.jsx)(`span`,{className:`office3d-state-chip office3d-state-chip--${e.state}`,children:qr[e.state]})]}),e.currentTask&&(0,$.jsxs)(`div`,{className:`office3d-inspector-row`,children:[(0,$.jsx)(`span`,{className:`office3d-inspector-label`,children:`Tarea`}),(0,$.jsx)(`span`,{className:`office3d-inspector-task`,children:e.currentTask})]}),e.delegatedBy&&(0,$.jsxs)(`div`,{className:`office3d-inspector-row`,children:[(0,$.jsx)(`span`,{className:`office3d-inspector-label`,children:`Delegado por`}),(0,$.jsx)(`span`,{children:t})]}),e.currentTool&&(0,$.jsxs)(`div`,{className:`office3d-inspector-row`,children:[(0,$.jsx)(`span`,{className:`office3d-inspector-label`,children:`Herramienta`}),(0,$.jsx)(`span`,{className:`office3d-inspector-tool`,children:Yn(e.currentTool)})]}),(0,$.jsxs)(`div`,{className:`office3d-inspector-row`,children:[(0,$.jsx)(`span`,{className:`office3d-inspector-label`,children:`Workers`}),(0,$.jsx)(`span`,{className:`font-mono`,children:e.workerCount})]}),(0,$.jsx)(Kr,{agentId:r.id}),r.description&&(0,$.jsx)(`p`,{className:`office3d-inspector-desc`,children:r.description})]})}function Yr({coordinator:e}){let t=J(e=>e.select);return e?(0,$.jsxs)(`aside`,{className:`office3d-inspector office3d-inspector--coordinator`,style:{"--agent-color":`#f59e0b`},children:[(0,$.jsx)(`button`,{type:`button`,className:`office3d-inspector-close`,onClick:()=>t(null),"aria-label":`Cerrar`,children:(0,$.jsx)(O,{size:14})}),(0,$.jsxs)(`div`,{className:`office3d-inspector-head`,children:[(0,$.jsx)(`span`,{className:`office3d-inspector-orb`}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`office3d-inspector-eyebrow`,children:`Coordinador principal`}),(0,$.jsx)(`h3`,{className:`office3d-inspector-name`,children:e.name})]})]}),(0,$.jsxs)(`div`,{className:`office3d-inspector-row`,children:[(0,$.jsx)(`span`,{className:`office3d-inspector-label`,children:`Función`}),(0,$.jsx)(`span`,{children:`Asigna y supervisa`})]}),(0,$.jsxs)(`div`,{className:`office3d-inspector-row`,children:[(0,$.jsx)(`span`,{className:`office3d-inspector-label`,children:`Estado`}),(0,$.jsx)(`span`,{className:`office3d-state-chip office3d-state-chip--${e.status}`,children:e.status===`tool_call`?`Ejecutando herramienta`:e.status===`thinking`?`Pensando`:`En espera`})]}),(0,$.jsx)(Kr,{agentId:e.id}),typeof e.description==`string`&&(0,$.jsx)(`p`,{className:`office3d-inspector-desc`,children:e.description})]}):null}var Xr={archived:`Archivado`,disabled:`Desactivado`,idle:`Disponible`,thinking:`Pensando`,tool_call:`Ejecutando`,stuck:`Necesita ayuda`};function Zr(e){let t=e.agent.description?.trim();return t?t.length>62?`${t.slice(0,59)}…`:t:`Agente especialista`}function Qr({coordinator:e,desks:t,interactions:n,workEvents:r}){let[i,a]=(0,q.useState)(!1),o=J(e=>e.selectedAgentId),c=J(e=>e.select),d=new Map(t.map(e=>[e.agent.id,e])),f=t=>t===e?.id?e.name:d.get(t)?.agent.name??t,p=new Map;for(let e of r)p.set(e.taskRef,e);return(0,$.jsxs)(`aside`,{className:`office3d-roster office3d-glass ${i?`is-collapsed`:``}`,"aria-label":`Equipo y flujo de trabajo`,children:[(0,$.jsxs)(`div`,{className:`office3d-roster-heading`,children:[(0,$.jsxs)(`div`,{className:`office3d-roster-title`,children:[(0,$.jsx)(`span`,{className:`office3d-section-kicker`,children:`CENTRO DE OPERACIONES`}),(0,$.jsx)(`h2`,{children:`Quién hace qué`})]}),(0,$.jsx)(`span`,{className:`office3d-roster-live`,"aria-label":`${n.length} flujos activos`,children:(0,$.jsx)(g,{size:15,className:n.length?`is-active`:``})}),(0,$.jsx)(`button`,{type:`button`,className:`office3d-roster-toggle`,onClick:()=>a(e=>!e),"aria-expanded":!i,"aria-label":i?`Abrir centro de operaciones`:`Colapsar centro de operaciones`,title:i?`Abrir centro de operaciones`:`Colapsar centro de operaciones`,children:i?(0,$.jsx)(l,{size:16}):(0,$.jsx)(u,{size:16})})]}),(0,$.jsxs)(`div`,{className:`office3d-roster-content`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`office3d-roster-coordinator ${o===e?.id?`is-selected`:``}`,onClick:()=>e&&c(o===e.id?null:e.id),disabled:!e,children:[(0,$.jsx)(ve,{size:17}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`small`,{children:`ABEJA REINA · COORDINADOR`}),(0,$.jsx)(`strong`,{children:e?.name??`Conectando…`}),(0,$.jsx)(`em`,{children:`Asigna · supervisa · recibe`})]})]}),(0,$.jsxs)(`div`,{className:`office3d-flow`,children:[(0,$.jsxs)(`div`,{className:`office3d-section-title`,children:[`Flujo activo `,(0,$.jsx)(`span`,{children:n.length})]}),n.length===0?(0,$.jsx)(`p`,{className:`office3d-flow-empty`,children:`El equipo está disponible. Las delegaciones aparecerán aquí.`}):n.map(e=>{let t=d.get(e.targetId),n=e.taskId?p.get(e.taskId):null,r=n?.phase===`completed`||n?.phase===`review_passed`?3:e.kind===`reviews`?2:+(t?.state===`thinking`||t?.state===`tool_call`),i=n?.phase===`failed`||n?.phase===`aborted`||n?.phase===`review_failed`||n?.phase===`blocked`;return(0,$.jsxs)(`div`,{className:`office3d-flow-item ${i?`is-failed`:``}`,children:[(0,$.jsx)(`span`,{children:f(e.sourceId)}),(0,$.jsx)(s,{size:12}),(0,$.jsx)(`span`,{children:f(e.targetId)}),(0,$.jsx)(`strong`,{children:e.kind===`reviews`?`Revisión`:`Delegación`}),e.taskName&&(0,$.jsx)(`small`,{children:e.taskName}),(0,$.jsx)(`div`,{className:`office3d-flow-steps`,"aria-label":`Progreso del trabajo`,children:[`Delegado`,`Trabajando`,`Revisando`,i?`Atención`:`Entregado`].map((e,t)=>(0,$.jsx)(`span`,{className:`${t<r?`is-done`:``} ${t===r?`is-current`:``}`,children:e},e))})]},e.id)})]}),(0,$.jsxs)(`div`,{className:`office3d-agents-list`,children:[(0,$.jsxs)(`div`,{className:`office3d-section-title`,children:[`Especialistas `,(0,$.jsx)(`span`,{children:t.length})]}),t.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:`office3d-agent-row ${o===e.agent.id?`is-selected`:``}`,onClick:()=>c(o===e.agent.id?null:e.agent.id),style:{"--agent-color":e.color},children:[(0,$.jsx)(`span`,{className:`office3d-agent-status office3d-name-dot--${e.state}`}),(0,$.jsxs)(`span`,{className:`office3d-agent-copy`,children:[(0,$.jsx)(`strong`,{children:e.agent.name}),(0,$.jsx)(`small`,{children:e.currentTask||Zr(e)})]}),(0,$.jsx)(`em`,{children:Xr[e.state]})]},e.agent.id))]})]})]})}function $r(e){let t=(0,K.c)(46),{coordinator:n,desks:r}=e,i=J(ti);if(!i)return null;let a,o,s,c,l,u,d,p,m,h;if(t[0]!==n||t[1]!==i.actorId||t[2]!==i.phase||t[3]!==i.targetId||t[4]!==r){let e=new Map(r.map(ei)),v=t=>t?t===n?.id?n.name:e.get(t)?.agent.name??`Agente`:n?.name??`Coordinador`,y;t[15]===i.phase?y=t[16]:(y=pr(i.phase),t[15]=i.phase,t[16]=y);let b=y,x=b===`alert`?T:b===`done`?f:b===`review`?ye:i.phase===`delegated`?_:g;p=`office3d-now office3d-glass is-${b}`,m=b===`alert`?`assertive`:`polite`,h=`true`,t[17]===x?o=t[18]:(o=(0,$.jsx)(`div`,{className:`office3d-now-icon`,children:(0,$.jsx)(x,{size:17})}),t[17]=x,t[18]=o),l=`office3d-now-copy`,t[19]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(`span`,{children:`AHORA OCURRE`}),t[19]=u):u=t[19];let S;t[20]===i.phase?S=t[21]:(S=fr(i.phase),t[20]=i.phase,t[21]=S),t[22]===S?d=t[23]:(d=(0,$.jsx)(`strong`,{children:S}),t[22]=S,t[23]=d),a=v(i.actorId),t[24]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(`b`,{children:`→`}),t[24]=s):s=t[24],c=v(i.targetId),t[0]=n,t[1]=i.actorId,t[2]=i.phase,t[3]=i.targetId,t[4]=r,t[5]=a,t[6]=o,t[7]=s,t[8]=c,t[9]=l,t[10]=u,t[11]=d,t[12]=p,t[13]=m,t[14]=h}else a=t[5],o=t[6],s=t[7],c=t[8],l=t[9],u=t[10],d=t[11],p=t[12],m=t[13],h=t[14];let v;t[25]!==a||t[26]!==s||t[27]!==c?(v=(0,$.jsxs)(`p`,{children:[a,s,c]}),t[25]=a,t[26]=s,t[27]=c,t[28]=v):v=t[28];let y;t[29]===i.taskName?y=t[30]:(y=(0,$.jsx)(`small`,{children:i.taskName}),t[29]=i.taskName,t[30]=y);let b;t[31]===i.detail?b=t[32]:(b=i.detail&&(0,$.jsx)(`em`,{children:i.detail}),t[31]=i.detail,t[32]=b);let x;t[33]!==v||t[34]!==y||t[35]!==b||t[36]!==l||t[37]!==u||t[38]!==d?(x=(0,$.jsxs)(`div`,{className:l,children:[u,d,v,y,b]}),t[33]=v,t[34]=y,t[35]=b,t[36]=l,t[37]=u,t[38]=d,t[39]=x):x=t[39];let S;return t[40]!==o||t[41]!==x||t[42]!==p||t[43]!==m||t[44]!==h?(S=(0,$.jsxs)(`section`,{className:p,"aria-live":m,"aria-atomic":h,children:[o,x]}),t[40]=o,t[41]=x,t[42]=p,t[43]=m,t[44]=h,t[45]=S):S=t[45],S}function ei(e){return[e.agent.id,e]}function ti(e){return e.activeCue}var ni=null;function ri(){if(!(typeof window>`u`))try{ni??=new AudioContext,ni.state===`suspended`&&ni.resume()}catch{ni=null}}var ii={delegated:[520,680],review_passed:[720,960],review_failed:[260,190],completed:[660,880],failed:[220,150],aborted:[280,210],blocked:[240,180]};function ai(e){if(ri(),!ni||ni.state!==`running`)return;let[t,n]=ii[e.phase],r=ni.currentTime,i=ni.createGain();i.gain.setValueAtTime(1e-4,r),i.gain.exponentialRampToValueAtTime(.045,r+.018),i.gain.exponentialRampToValueAtTime(1e-4,r+.34),i.connect(ni.destination);for(let[e,a]of[[t,0],[n,.12]]){let t=ni.createOscillator();t.type=`sine`,t.frequency.setValueAtTime(e,r+a),t.connect(i),t.start(r+a),t.stop(r+a+.2)}}function oi(e){let t=(0,K.c)(89),{desks:n,coordinator:r,interactions:i,workEvents:a,isConnected:s,selectedDesk:c,coordinatorSelected:l,coordinatorName:u,jev:d}=e,f=J(pi),m=J(fi),g=J(di),_=J(ui),S=J(li),C=J(ci),w=Br(n,i,r,a,d.decisions),T;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(T=new Set,t[0]=T):T=t[0];let E=(0,q.useRef)(T),O=(0,q.useRef)(!1),k,A;t[1]!==S||t[2]!==a?(k=()=>{if(!O.current){a.forEach(e=>E.current.add(e.eventId)),O.current=!0;return}for(let e of a)E.current.has(e.eventId)||(E.current.add(e.eventId),S&&ai(e))},A=[S,a],t[1]=S,t[2]=a,t[3]=k,t[4]=A):(k=t[3],A=t[4]),(0,q.useEffect)(k,A);let j;t[5]===n?j=t[6]:(j=n.filter(si),t[5]=n,t[6]=j);let M=j.length,N;t[7]!==u||t[8]!==n||t[9]!==c?(N=c?.delegatedBy?n.find(e=>e.agent.id===c.delegatedBy)?.agent.name??u:u,t[7]=u,t[8]=n,t[9]=c,t[10]=N):N=t[10];let P=N,F,I;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(`div`,{className:`office3d-logo`,children:(0,$.jsx)(D,{size:18})}),I=(0,$.jsx)(`h1`,{className:`office3d-title`,children:`HoloHive · Oficina 3D`}),t[11]=F,t[12]=I):(F=t[11],I=t[12]);let L;t[13]!==n.length||t[14]!==M?(L=(0,$.jsxs)(`div`,{className:`office3d-topbar-left`,children:[F,(0,$.jsxs)(`div`,{children:[I,(0,$.jsxs)(`p`,{className:`office3d-subtitle`,children:[n.length,` especialistas · `,M,` trabajando`]})]})]}),t[13]=n.length,t[14]=M,t[15]=L):L=t[15];let R=`office3d-live-badge ${s?`is-live`:`is-off`}`,z;t[16]===s?z=t[17]:(z=s?(0,$.jsx)(x,{size:12}):(0,$.jsx)(b,{size:12}),t[16]=s,t[17]=z);let B=s?`LIVE`:`OFFLINE`,V;t[18]!==z||t[19]!==B||t[20]!==R?(V=(0,$.jsxs)(`span`,{className:R,children:[z,B]}),t[18]=z,t[19]=B,t[20]=R,t[21]=V):V=t[21];let H;t[22]===d.status?H=t[23]:(H=d.status&&d.status.state!==`off`&&(0,$.jsxs)(`span`,{className:`office3d-jev-badge is-${d.status.state}`,title:`${Ae(d.status)} ${je(d.status.state)}`,children:[(0,$.jsx)(p,{size:11}),Ae(d.status).toUpperCase(),d.status.totals&&d.status.totals.savedTokens>0&&(0,$.jsxs)(`b`,{children:[`−`,Me(d.status.totals.savedTokens)]})]}),t[22]=d.status,t[23]=H);let ee;t[24]!==f||t[25]!==m?(ee=()=>m(f===`high`?`low`:`high`),t[24]=f,t[25]=m,t[26]=ee):ee=t[26];let te;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,$.jsx)(h,{size:13}),t[27]=te):te=t[27];let ne=f===`high`?`Alta`:`Eco`,U;t[28]!==ee||t[29]!==ne?(U=(0,$.jsxs)(`button`,{type:`button`,className:`office3d-hud-btn`,onClick:ee,title:`Alternar calidad gráfica`,children:[te,ne]}),t[28]=ee,t[29]=ne,t[30]=U):U=t[30];let re=`office3d-hud-btn ${g===`calm`?`is-on`:``}`,ie;t[31]!==g||t[32]!==_?(ie=()=>_(g===`calm`?`off`:`calm`),t[31]=g,t[32]=_,t[33]=ie):ie=t[33];let ae;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,$.jsx)(o,{size:13}),t[34]=ae):ae=t[34];let oe=g===`calm`?`Enfoque`:`Fijo`,W;t[35]!==re||t[36]!==ie||t[37]!==oe?(W=(0,$.jsxs)(`button`,{type:`button`,className:re,onClick:ie,title:`Alternar enfoque y movimiento de eventos`,children:[ae,oe]}),t[35]=re,t[36]=ie,t[37]=oe,t[38]=W):W=t[38];let se=`office3d-hud-btn ${S?`is-on`:``}`,ce;t[39]!==C||t[40]!==S?(ce=()=>{S||ri(),C(!S)},t[39]=C,t[40]=S,t[41]=ce):ce=t[41];let le=S?`Desactivar sonido de eventos`:`Activar sonido de eventos`,ue;t[42]===S?ue=t[43]:(ue=S?(0,$.jsx)(v,{size:13}):(0,$.jsx)(y,{size:13}),t[42]=S,t[43]=ue);let de=S?`Audio`:`Silencio`,fe;t[44]!==S||t[45]!==se||t[46]!==ce||t[47]!==le||t[48]!==ue||t[49]!==de?(fe=(0,$.jsxs)(`button`,{type:`button`,className:se,onClick:ce,title:le,"aria-pressed":S,children:[ue,de]}),t[44]=S,t[45]=se,t[46]=ce,t[47]=le,t[48]=ue,t[49]=de,t[50]=fe):fe=t[50];let pe;t[51]!==V||t[52]!==H||t[53]!==U||t[54]!==W||t[55]!==fe?(pe=(0,$.jsxs)(`div`,{className:`office3d-topbar-right`,children:[V,H,U,W,fe]}),t[51]=V,t[52]=H,t[53]=U,t[54]=W,t[55]=fe,t[56]=pe):pe=t[56];let me;t[57]!==pe||t[58]!==L?(me=(0,$.jsxs)(`header`,{className:`office3d-topbar office3d-glass`,children:[L,pe]}),t[57]=pe,t[58]=L,t[59]=me):me=t[59];let he;t[60]!==r||t[61]!==n?(he=(0,$.jsx)($r,{coordinator:r,desks:n}),t[60]=r,t[61]=n,t[62]=he):he=t[62];let ge;t[63]!==r||t[64]!==n||t[65]!==d.decisions||t[66]!==d.status?(ge=(0,$.jsx)(Vr,{status:d.status,decisions:d.decisions,coordinator:r,desks:n}),t[63]=r,t[64]=n,t[65]=d.decisions,t[66]=d.status,t[67]=ge):ge=t[67];let G;t[68]!==r||t[69]!==n||t[70]!==i||t[71]!==a?(G=(0,$.jsx)(Qr,{coordinator:r,desks:n,interactions:i,workEvents:a}),t[68]=r,t[69]=n,t[70]=i,t[71]=a,t[72]=G):G=t[72];let _e;t[73]===w?_e=t[74]:(_e=(0,$.jsx)(`div`,{className:`office3d-bottom-left`,children:(0,$.jsx)(Ir,{events:w})}),t[73]=w,t[74]=_e);let ve;t[75]!==P||t[76]!==c?(ve=(0,$.jsx)(Jr,{desk:c,delegatorName:P}),t[75]=P,t[76]=c,t[77]=ve):ve=t[77];let ye;t[78]!==r||t[79]!==l?(ye=l&&(0,$.jsx)(Yr,{coordinator:r}),t[78]=r,t[79]=l,t[80]=ye):ye=t[80];let be;return t[81]!==me||t[82]!==he||t[83]!==ge||t[84]!==G||t[85]!==_e||t[86]!==ve||t[87]!==ye?(be=(0,$.jsxs)(`div`,{className:`office3d-hud`,children:[me,he,ge,G,_e,ve,ye]}),t[81]=me,t[82]=he,t[83]=ge,t[84]=G,t[85]=_e,t[86]=ve,t[87]=ye,t[88]=be):be=t[88],be}function si(e){return e.state===`thinking`||e.state===`tool_call`}function ci(e){return e.setSoundEnabled}function li(e){return e.soundEnabled}function ui(e){return e.setMotion}function di(e){return e.motion}function fi(e){return e.setQuality}function pi(e){return e.quality}function mi(){let e=(0,K.c)(22),{coordinator:t,desks:n,interactions:r,workEvents:i,isConnected:a}=be(),o=J(hi),s=Fe(),c;e[0]!==n||e[1]!==o?(c=n.find(e=>e.agent.id===o)??null,e[0]=n,e[1]=o,e[2]=c):c=e[2];let l=c,u=!!t&&o===t.id,d=t?.name??`Coordinador`,f=t??null,p;e[3]!==n||e[4]!==r||e[5]!==s||e[6]!==f||e[7]!==i?(p=(0,$.jsx)(Or,{desks:n,coordinator:f,interactions:r,workEvents:i,jev:s}),e[3]=n,e[4]=r,e[5]=s,e[6]=f,e[7]=i,e[8]=p):p=e[8];let m=t??null,h;e[9]!==d||e[10]!==u||e[11]!==n||e[12]!==r||e[13]!==a||e[14]!==s||e[15]!==l||e[16]!==m||e[17]!==i?(h=(0,$.jsx)(oi,{desks:n,coordinator:m,interactions:r,workEvents:i,isConnected:a,selectedDesk:l,coordinatorSelected:u,coordinatorName:d,jev:s}),e[9]=d,e[10]=u,e[11]=n,e[12]=r,e[13]=a,e[14]=s,e[15]=l,e[16]=m,e[17]=i,e[18]=h):h=e[18];let g;return e[19]!==p||e[20]!==h?(g=(0,$.jsxs)(`div`,{className:`office3d-root`,children:[p,h]}),e[19]=p,e[20]=h,e[21]=g):g=e[21],g}function hi(e){return e.selectedAgentId}export{mi as default};
727
+ `;function Qn(e){let t=e?.toLowerCase()??``;return/knowledge|memory|rag|embed|document|vector/.test(t)?`knowledge`:/browser|web|search|fetch|http|url/.test(t)?`browser`:/file|code|exec|shell|terminal|git|patch|write|read/.test(t)?`code`:/message|mail|slack|discord|telegram|whatsapp|notify/.test(t)?`communication`:`generic`}function $n(e){let t=(0,K.c)(2),{color:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`meshBasicMaterial`,{color:n,transparent:!0,opacity:.72,wireframe:!0,blending:2,depthWrite:!1}),t[0]=n,t[1]=r),r}function er(e){let t=(0,K.c)(27),{toolName:n,color:r}=e,i=(0,q.useRef)(null),a;t[0]===n?a=t[1]:(a=Qn(n),t[0]=n,t[1]=a);let o=a,s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(e,t)=>{i.current&&(i.current.rotation.y=i.current.rotation.y+t*.85,i.current.position.y=1.05+Math.sin(e.clock.elapsedTime*2.4)*.08)},t[2]=s):s=t[2],U(s);let c;t[3]!==o||t[4]!==r?(c=o===`browser`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`mesh`,{children:[(0,$.jsx)(`sphereGeometry`,{args:[.42,10,8]}),(0,$.jsx)($n,{color:r})]}),(0,$.jsxs)(`mesh`,{rotation:[Math.PI/2,0,0],children:[(0,$.jsx)(`torusGeometry`,{args:[.53,.035,6,24]}),(0,$.jsx)($n,{color:r})]})]}),t[3]=o,t[4]=r,t[5]=c):c=t[5];let l;t[6]!==o||t[7]!==r?(l=o===`code`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`mesh`,{children:[(0,$.jsx)(`boxGeometry`,{args:[.75,.55,.12]}),(0,$.jsx)($n,{color:r})]}),(0,$.jsxs)(`mesh`,{position:[-.16,0,.1],rotation:[0,0,-.55],children:[(0,$.jsx)(`boxGeometry`,{args:[.06,.32,.05]}),(0,$.jsx)($n,{color:r})]}),(0,$.jsxs)(`mesh`,{position:[.16,0,.1],rotation:[0,0,.55],children:[(0,$.jsx)(`boxGeometry`,{args:[.06,.32,.05]}),(0,$.jsx)($n,{color:r})]})]}),t[6]=o,t[7]=r,t[8]=l):l=t[8];let u;t[9]!==o||t[10]!==r?(u=o===`knowledge`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`mesh`,{children:[(0,$.jsx)(`octahedronGeometry`,{args:[.46,0]}),(0,$.jsx)($n,{color:r})]}),(0,$.jsxs)(`mesh`,{rotation:[Math.PI/2,0,0],children:[(0,$.jsx)(`torusGeometry`,{args:[.58,.025,6,6]}),(0,$.jsx)($n,{color:r})]})]}),t[9]=o,t[10]=r,t[11]=u):u=t[11];let d;t[12]!==o||t[13]!==r?(d=o===`communication`&&(0,$.jsx)($.Fragment,{children:[.25,.42,.59].map(e=>(0,$.jsxs)(`mesh`,{rotation:[0,Math.PI/2,0],children:[(0,$.jsx)(`torusGeometry`,{args:[e,.025,5,20,Math.PI]}),(0,$.jsx)($n,{color:r})]},e))}),t[12]=o,t[13]=r,t[14]=d):d=t[14];let f;t[15]!==o||t[16]!==r?(f=o===`generic`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`mesh`,{children:[(0,$.jsx)(`icosahedronGeometry`,{args:[.4,0]}),(0,$.jsx)($n,{color:r})]}),(0,$.jsxs)(`mesh`,{rotation:[Math.PI/2,0,0],children:[(0,$.jsx)(`torusGeometry`,{args:[.56,.025,5,24]}),(0,$.jsx)($n,{color:r})]})]}),t[15]=o,t[16]=r,t[17]=f):f=t[17];let p;t[18]===r?p=t[19]:(p=(0,$.jsx)(`pointLight`,{color:r,intensity:2.2,distance:4,decay:2}),t[18]=r,t[19]=p);let m;return t[20]!==c||t[21]!==l||t[22]!==u||t[23]!==d||t[24]!==f||t[25]!==p?(m=(0,$.jsxs)(`group`,{ref:i,scale:.7,children:[c,l,u,d,f,p]}),t[20]=c,t[21]=l,t[22]=u,t[23]=d,t[24]=f,t[25]=p,t[26]=m):m=t[26],m}var tr=new W,nr=new B,rr=new ie,ir=new W(0,1,0),ar=new W(0,0,0),or={archived:{flap:0,intensity:.08,opacity:.12},idle:{flap:0,intensity:.45,opacity:.72},thinking:{flap:5,intensity:.85,opacity:.9},tool_call:{flap:8,intensity:1.05,opacity:1},stuck:{flap:2,intensity:.9,opacity:.95},disabled:{flap:0,intensity:.12,opacity:.06}};function sr({desk:e,swarmRef:t}){let{agent:n,state:r,color:i}=e,a=J(e=>e.selectedAgentId===n.id),o=J(e=>e.select),s=J(e=>e.motion),c=J(e=>e.activeCue),l=(0,q.useRef)(null),u=(0,q.useRef)(null),d=(0,q.useRef)(null),f=(0,q.useRef)(null),p=(0,q.useRef)(null),m=(0,q.useRef)(null),h=(0,q.useMemo)(()=>new H({vertexShader:Xn,fragmentShader:Zn,uniforms:{uTime:{value:0},uColor:{value:new R(i)},uIntensity:{value:.65},uGlitch:{value:0},uOpacity:{value:.8}},transparent:!0,depthWrite:!1,side:2,blending:2}),[i]),g=(0,q.useMemo)(()=>new H({vertexShader:Xn,fragmentShader:Zn,uniforms:{uTime:{value:0},uColor:{value:new R(i).lerp(new R(`#ffffff`),.55)},uIntensity:{value:.9},uGlitch:{value:0},uOpacity:{value:.4}},transparent:!0,depthWrite:!1,side:2,blending:2}),[i]),_=(0,q.useMemo)(()=>new R(i),[i]);U((e,i)=>{let o=e.clock.elapsedTime,_=or[r],v=c?.actorId===n.id||c?.targetId===n.id,y=c&&!v&&!a?.28:1;h.uniforms.uTime.value=o,g.uniforms.uTime.value=o;let b=1-.002**i;h.uniforms.uIntensity.value+=(_.intensity-h.uniforms.uIntensity.value)*b,h.uniforms.uOpacity.value+=(_.opacity*y-h.uniforms.uOpacity.value)*b,g.uniforms.uOpacity.value+=(.4*y-g.uniforms.uOpacity.value)*b,h.uniforms.uGlitch.value+=(+(r===`stuck`)-h.uniforms.uGlitch.value)*b;let x=t.current.get(n.id);x&&l.current&&(l.current.position.copy(x.pos),u.current&&(tr.subVectors(x.pos,x.prevPos),tr.lengthSq()>1e-8&&(nr.lookAt(tr,ar,ir),rr.setFromRotationMatrix(nr),u.current.quaternion.slerp(rr,1-.01**i))));let S=s===`calm`&&_.flap>0?Math.sin(o*_.flap)*.45+.2:.15;if(f.current&&(f.current.rotation.z=S),p.current&&(p.current.rotation.z=-S),m.current){let e=r===`disabled`||r===`archived`?0:r===`tool_call`?7:2.6;m.current.intensity+=(e-m.current.intensity)*b}if(d.current){let e=c?.phase===`delegated`&&c.targetId===n.id,t=c?.actorId===n.id&&(c.phase===`completed`||c.phase===`failed`),r=s===`calm`&&e?Math.sin(o*8.5)*.22:s===`calm`&&t?-.16:0;d.current.rotation.x=z.damp(d.current.rotation.x,r,7,i);let a=v&&s===`calm`?1.12:1,l=z.damp(d.current.scale.x,a,6,i);d.current.scale.setScalar(l)}});let v=e=>{e.stopPropagation(),o(a?null:n.id)},y=r===`tool_call`?Yn(e.currentTool):null;return(0,$.jsxs)(`group`,{ref:l,children:[(0,$.jsx)(`group`,{onClick:v,onPointerOver:e=>{e.stopPropagation(),document.body.style.cursor=`pointer`},onPointerOut:()=>{document.body.style.cursor=`auto`},children:(0,$.jsx)(Bt,{width:r===`idle`||r===`disabled`||r===`archived`?0:.65,length:2.2,color:_,attenuation:e=>e*e,children:(0,$.jsx)(`group`,{ref:u,scale:a?.85:.62,children:(0,$.jsxs)(`group`,{ref:d,children:[(0,$.jsx)(`mesh`,{material:h,scale:[.85,.75,1.35],children:(0,$.jsx)(`sphereGeometry`,{args:[.32,14,14]})}),(0,$.jsxs)(`mesh`,{position:[0,0,.1],children:[(0,$.jsx)(`torusGeometry`,{args:[.24,.045,8,20]}),(0,$.jsx)(`meshStandardMaterial`,{color:`#241804`,metalness:.4,roughness:.6})]}),(0,$.jsxs)(`mesh`,{position:[0,0,-.14],children:[(0,$.jsx)(`torusGeometry`,{args:[.22,.04,8,20]}),(0,$.jsx)(`meshStandardMaterial`,{color:`#241804`,metalness:.4,roughness:.6})]}),(0,$.jsx)(`mesh`,{material:h,position:[0,.03,.5],children:(0,$.jsx)(`sphereGeometry`,{args:[.18,12,12]})}),(0,$.jsx)(`mesh`,{material:h,position:[0,0,-.52],rotation:[-Math.PI/2,0,0],children:(0,$.jsx)(`coneGeometry`,{args:[.07,.22,8]})}),(0,$.jsx)(`mesh`,{ref:f,material:g,position:[.26,.24,.05],rotation:[.35,0,.5],scale:[1,.08,.55],children:(0,$.jsx)(`sphereGeometry`,{args:[.3,10,10]})}),(0,$.jsx)(`mesh`,{ref:p,material:g,position:[-.26,.24,.05],rotation:[.35,0,-.5],scale:[1,.08,.55],children:(0,$.jsx)(`sphereGeometry`,{args:[.3,10,10]})})]})})})}),(0,$.jsx)(`pointLight`,{ref:m,color:i,intensity:2.6,distance:8,decay:1.7}),r===`tool_call`&&(0,$.jsx)(er,{toolName:e.currentTool,color:i}),r===`thinking`&&(0,$.jsxs)(`mesh`,{position:[0,.95,0],rotation:[-Math.PI/2,0,0],children:[(0,$.jsx)(`ringGeometry`,{args:[.42,.52,6]}),(0,$.jsx)(`meshBasicMaterial`,{color:i,transparent:!0,opacity:.42,blending:2,depthWrite:!1})]}),r===`stuck`&&(0,$.jsxs)(`mesh`,{position:[0,1.05,0],rotation:[-Math.PI/2,0,0],children:[(0,$.jsx)(`ringGeometry`,{args:[.52,.68,6]}),(0,$.jsx)(`meshBasicMaterial`,{color:`#fb7185`,transparent:!0,opacity:.86,blending:2,depthWrite:!1})]}),e.currentTask&&(0,$.jsx)(nt,{position:[0,1.55,0],center:!0,distanceFactor:17,className:`pointer-events-none select-none`,children:(0,$.jsxs)(`div`,{className:`office3d-task-chip`,style:{"--chip-color":i},children:[(0,$.jsx)(`span`,{className:`office3d-task-chip-prefix`,children:`◈`}),` `,e.currentTask]})}),y&&(0,$.jsx)(nt,{position:[0,e.currentTask?1.05:1.3,0],center:!0,distanceFactor:17,className:`pointer-events-none select-none`,children:(0,$.jsx)(`div`,{className:`office3d-tool-chip`,style:{"--chip-color":i},children:y})}),(0,$.jsx)(nt,{position:[0,-.85,0],center:!0,distanceFactor:16,className:`pointer-events-none select-none`,zIndexRange:[10,0],children:(0,$.jsxs)(`div`,{className:`office3d-name-plate ${a?`is-active`:``}`,style:{"--chip-color":i},children:[(0,$.jsx)(`span`,{className:`office3d-name-dot office3d-name-dot--${r}`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`strong`,{children:n.name}),(0,$.jsx)(`small`,{children:n.description||`Agente especialista`})]})]})})]})}var cr=new Set([`failed`,`aborted`,`review_failed`,`blocked`]);function lr(e){return cr.has(e)?4200:e===`completed`?3200:2800}function ur(e){return cr.has(e)}function dr(e,t){return e.some(e=>e.eventId===t.eventId)?e:(ur(t.phase)?[t,...e]:[...e,t]).slice(0,3)}function fr(e){switch(e){case`delegated`:return`Delegando trabajo`;case`review_passed`:return`Revisión aprobada`;case`review_failed`:return`Revisión no aprobada`;case`completed`:return`Entregando resultado`;case`failed`:return`Trabajo fallido`;case`aborted`:return`Trabajo interrumpido`;case`blocked`:return`Agente bloqueado`}}function pr(e){return e===`failed`||e===`aborted`||e===`review_failed`?`alert`:e===`completed`||e===`review_passed`?`done`:`work`}var mr=new W(0,4.4,0),hr=2.25,gr=0;function _r(e,t){let n=pr(e.phase);return n===`alert`?`#fb7185`:n===`done`?`#86efac`:n===`review`?`#67e8f9`:t??`#f59e0b`}function vr({desks:e,events:t,swarmRef:n,coordinatorId:r,coordinatorName:i}){let[a,o]=(0,q.useState)([]),s=(0,q.useRef)(new Set),c=(0,q.useRef)(!1);return(0,q.useEffect)(()=>{if(!c.current){t.forEach(e=>s.current.add(e.eventId)),c.current=!0;return}let n=new Map(e.map(e=>[e.agent.id,e])),a=e=>e===r?i:n.get(e)?.agent.name??`Agente`,l=[];for(let e of t){if(s.current.has(e.eventId))continue;s.current.add(e.eventId);let t=e.targetId||r;t&&l.push({id:++gr,event:e,startId:e.actorId,endId:t,sourceName:a(e.actorId),targetName:a(t),color:_r(e,n.get(t)?.color??n.get(e.actorId)?.color)})}l.length>0&&o(e=>[...e,...l].slice(-8))},[r,i,e,t]),(0,$.jsx)(`group`,{children:a.map(e=>(0,$.jsx)(yr,{transfer:e,swarmRef:n,coordinatorId:r,onDone:()=>o(t=>t.filter(t=>t.id!==e.id))},e.id))})}function yr({transfer:e,swarmRef:t,coordinatorId:n,onDone:r}){let i=(0,q.useRef)(null),a=(0,q.useRef)(null),o=(0,q.useRef)(null),s=(0,q.useRef)(0),c=(0,q.useRef)(!1),l=(0,q.useRef)(new W),u=(0,q.useRef)(new W);U((d,f)=>{if(c.current||!i.current)return;s.current=Math.min(hr,s.current+f);let p=e.startId===n?mr:t.current.get(e.startId)?.pos,m=e.endId===n?mr:t.current.get(e.endId)?.pos;if(!p||!m){i.current.visible=!1,s.current>=hr&&(c.current=!0,r());return}i.current.visible=!0,l.current.copy(p),u.current.copy(m);let h=s.current/hr,g=1-(1-Math.min(1,Math.max(0,(h-.14)/.86)))**3;if(i.current.position.lerpVectors(l.current,u.current,g),i.current.position.y+=Math.sin(g*Math.PI)*2.2,i.current.rotation.x+=f*2.4,i.current.rotation.y+=f*3.2,o.current?.position.copy(i.current.position),a.current){a.current.position.copy(l.current),a.current.visible=h<.46;let e=.8+h*5.2%1*1.35;a.current.scale.setScalar(e),a.current.rotation.y+=f*.8}s.current>=hr&&(c.current=!0,r())});let d=e.event.phase===`delegated`?`${e.sourceName} llama a ${e.targetName}`:e.event.phase===`completed`?`${e.sourceName} entrega a ${e.targetName}`:`${e.sourceName} informa a ${e.targetName}`;return(0,$.jsxs)(`group`,{children:[(0,$.jsx)(`group`,{ref:a,children:[.72,1.08].map((t,n)=>(0,$.jsxs)(`mesh`,{rotation:[Math.PI/2,0,0],children:[(0,$.jsx)(`torusGeometry`,{args:[t,n===0?.055:.035,6,28]}),(0,$.jsx)(`meshBasicMaterial`,{color:e.color,transparent:!0,opacity:n===0?.72:.42,blending:2,depthWrite:!1})]},t))}),(0,$.jsxs)(`mesh`,{ref:i,children:[(0,$.jsx)(`octahedronGeometry`,{args:[.3,0]}),(0,$.jsx)(`meshBasicMaterial`,{color:e.color,transparent:!0,opacity:.98,blending:2,depthWrite:!1})]}),(0,$.jsx)(`group`,{ref:o,children:(0,$.jsx)(nt,{position:[0,.75,0],center:!0,distanceFactor:20,className:`pointer-events-none select-none`,children:(0,$.jsxs)(`div`,{className:`office3d-transfer-label is-compact is-${pr(e.event.phase)}`,style:{"--chip-color":e.color},children:[(0,$.jsx)(`span`,{children:d}),(0,$.jsx)(`strong`,{children:fr(e.event.phase).toUpperCase()})]})})})]})}function br({events:e,desks:t,coordinatorId:n}){let r=J(e=>e.setActiveCue),i=(0,q.useRef)(new Set),a=(0,q.useRef)(!1),o=(0,q.useRef)([]),s=(0,q.useRef)(null),c=(0,q.useRef)(null),l=(0,q.useRef)(new Map),u=(0,q.useRef)(!1),d=(0,q.useCallback)(function e(){if(s.current||o.current.length===0)return;let t=o.current.shift()??null;s.current=t,r(t),t&&(c.current=setTimeout(()=>{s.current=null,r(null),c.current=null,e()},lr(t.phase)))},[r]),f=(0,q.useCallback)(e=>{ur(e.phase)&&s.current&&!ur(s.current.phase)&&(c.current&&clearTimeout(c.current),o.current=dr(o.current,s.current),s.current=null,r(null)),o.current=dr(o.current,e),d()},[d,r]);return(0,q.useEffect)(()=>{if(!a.current){e.forEach(e=>i.current.add(e.eventId)),a.current=!0;return}for(let t of e)i.current.has(t.eventId)||(i.current.add(t.eventId),f(t))},[e,f]),(0,q.useEffect)(()=>{if(!u.current){l.current=new Map(t.map(e=>[e.agent.id,e.state])),u.current=!0;return}for(let e of t){let t=l.current.get(e.agent.id);e.state===`stuck`&&t!==`stuck`&&f({eventId:`blocked:${e.agent.id}:${Date.now()}`,phase:`blocked`,taskRef:e.taskId??`agent:${e.agent.id}`,taskName:e.currentTask??`Ejecución del agente`,actorId:e.agent.id,targetId:n,detail:`El agente necesita atención`,timestamp:Date.now()}),l.current.set(e.agent.id,e.state)}},[n,t,f]),(0,q.useEffect)(()=>()=>{c.current&&clearTimeout(c.current),r(null)},[r]),null}var xr=new W(0,7.6,0),Sr=new W(0,4.4,0),Cr=1.7,wr=6;function Tr(e){let t=(0,K.c)(46),{status:n,decisions:r,swarmRef:i,coordinatorId:a,motion:o}=e,s=(0,q.useRef)(null),c=(0,q.useRef)(null),l=(0,q.useRef)(null),u=(0,q.useRef)(null),d=(0,q.useRef)(0),f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=[],t[0]=f):f=t[0];let[p,m]=(0,q.useState)(f),h;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(h=new Set,t[1]=h):h=t[1];let g=(0,q.useRef)(h),_=(0,q.useRef)(!1),v,y;t[2]!==r||t[3]!==o?(v=()=>{if(!_.current){r.forEach(e=>g.current.add(e.eventId)),_.current=!0;return}let e=r.filter(e=>!g.current.has(e.eventId));e.length!==0&&(e.forEach(e=>g.current.add(e.eventId)),d.current=1,o!==`off`&&m(t=>[...t,...e.map(Er)].slice(-wr)))},y=[r,o],t[2]=r,t[3]=o,t[4]=v,t[5]=y):(v=t[4],y=t[5]),(0,q.useEffect)(v,y);let b=n?.state===`fallback`,x=b?De:Ee,S;if(t[6]!==b||t[7]!==o?(S=(e,t)=>{let n=e.clock.elapsedTime;d.current=Math.max(0,d.current-t*1.4);let r=o===`calm`?(b?.12:.35)+d.current*2.2:0;if(s.current&&(s.current.rotation.y=s.current.rotation.y+t*r,s.current.rotation.x=s.current.rotation.x+t*r*.4,s.current.scale.setScalar(1+d.current*.22)),c.current){let e=c.current.material;e.emissiveIntensity=(b?.25+Math.max(0,Math.sin(n*9))*.15:.7+Math.sin(n*1.6)*.12)+d.current*1.6,c.current.rotation.y=c.current.rotation.y-t*r*.6}l.current&&(l.current.rotation.z=l.current.rotation.z+t*(o===`calm`?.5+d.current*3:0)),u.current&&(u.current.intensity=(b?1.2:3)+d.current*9)},t[6]=b,t[7]=o,t[8]=S):S=t[8],U(S),!n||n.state===`off`)return null;let C;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(`icosahedronGeometry`,{args:[.95,0]}),t[9]=C):C=t[9];let w;t[10]===x?w=t[11]:(w=(0,$.jsxs)(`mesh`,{ref:s,children:[C,(0,$.jsx)(`meshBasicMaterial`,{color:x,wireframe:!0,transparent:!0,opacity:.55,blending:2,depthWrite:!1})]}),t[10]=x,t[11]=w);let T;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(`octahedronGeometry`,{args:[.45,0]}),t[12]=T):T=t[12];let E;t[13]===x?E=t[14]:(E=(0,$.jsxs)(`mesh`,{ref:c,children:[T,(0,$.jsx)(`meshStandardMaterial`,{color:`#1e1535`,emissive:x,emissiveIntensity:.7,metalness:.4,roughness:.25})]}),t[13]=x,t[14]=E);let D,O;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(D=[Math.PI/2,0,0],O=(0,$.jsx)(`torusGeometry`,{args:[1.45,.025,6,48]}),t[15]=D,t[16]=O):(D=t[15],O=t[16]);let k,A;t[17]===x?(k=t[18],A=t[19]):(k=(0,$.jsx)(`group`,{ref:l,rotation:D,children:(0,$.jsxs)(`mesh`,{children:[O,(0,$.jsx)(`meshBasicMaterial`,{color:x,transparent:!0,opacity:.45,blending:2,depthWrite:!1})]})}),A=(0,$.jsx)(`pointLight`,{ref:u,color:x,intensity:3,distance:12,decay:1.8}),t[17]=x,t[18]=k,t[19]=A);let j;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(j=[0,1.55,0],t[20]=j):j=t[20];let M=`office3d-jev-tag ${b?`is-fallback`:``}`,N;t[21]===n?N=t[22]:(N=Ae(n).toUpperCase(),t[21]=n,t[22]=N);let P;t[23]!==M||t[24]!==N?(P=(0,$.jsx)(nt,{position:j,center:!0,distanceFactor:22,className:`pointer-events-none select-none`,children:(0,$.jsx)(`div`,{className:M,children:N})}),t[23]=M,t[24]=N,t[25]=P):P=t[25];let F;t[26]!==k||t[27]!==A||t[28]!==P||t[29]!==w||t[30]!==E?(F=(0,$.jsxs)(`group`,{position:xr,children:[w,E,k,A,P]}),t[26]=k,t[27]=A,t[28]=P,t[29]=w,t[30]=E,t[31]=F):F=t[31];let I;if(t[32]!==p||t[33]!==x||t[34]!==a||t[35]!==n||t[36]!==i){let e;t[38]!==x||t[39]!==a||t[40]!==n||t[41]!==i?(e=e=>(0,$.jsx)(Dr,{beam:e,swarmRef:i,coordinatorId:a,color:x,name:Ae(n),onDone:()=>m(t=>t.filter(t=>t.decision.eventId!==e.decision.eventId))},e.decision.eventId),t[38]=x,t[39]=a,t[40]=n,t[41]=i,t[42]=e):e=t[42],I=p.map(e),t[32]=p,t[33]=x,t[34]=a,t[35]=n,t[36]=i,t[37]=I}else I=t[37];let L;return t[43]!==F||t[44]!==I?(L=(0,$.jsxs)(`group`,{children:[F,I]}),t[43]=F,t[44]=I,t[45]=L):L=t[45],L}function Er(e){return{decision:e,chip:Ne(e.savedTokens)}}function Dr(e){let t=(0,K.c)(31),{beam:n,swarmRef:r,coordinatorId:i,color:a,name:o,onDone:s}=e,c=(0,q.useRef)(null),l=(0,q.useRef)(null),u=(0,q.useRef)(null),d=(0,q.useRef)(0),f=(0,q.useRef)(!1),p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=new W,t[0]=p):p=t[0];let m=(0,q.useRef)(p),h;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(h=new W,t[1]=h):h=t[1];let g=(0,q.useRef)(h),{decision:_,chip:v}=n,y;t[2]!==i||t[3]!==_.agentId||t[4]!==s||t[5]!==r?(y=(e,t)=>{if(f.current)return;d.current+=t;let n=_.agentId===i?Sr:r.current.get(_.agentId)?.pos;n?m.current.copy(n):m.current.copy(Sr),g.current.lerpVectors(xr,m.current,.5),g.current.y=g.current.y+2.4;let a=Math.min(1,d.current/Cr),o=a<.2?a/.2:1-Math.max(0,(a-.55)/.45);if(c.current&&(c.current.setPoints(xr,m.current,g.current),c.current.material.opacity=o*.85),l.current){let e=Math.min(1,a/.45),t=1-e;l.current.position.set(t*t*xr.x+2*t*e*g.current.x+e*e*m.current.x,t*t*xr.y+2*t*e*g.current.y+e*e*m.current.y,t*t*xr.z+2*t*e*g.current.z+e*e*m.current.z),l.current.material.opacity=o}u.current?.position.copy(m.current),a>=1&&(f.current=!0,s())},t[2]=i,t[3]=_.agentId,t[4]=s,t[5]=r,t[6]=y):y=t[6],U(y);let b;t[7]===a?b=t[8]:(b=(0,$.jsx)(Ot,{ref:c,start:xr,end:Sr,color:a,lineWidth:1.6,transparent:!0,opacity:0,depthWrite:!1}),t[7]=a,t[8]=b);let x;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(`sphereGeometry`,{args:[.16,10,8]}),t[9]=x):x=t[9];let S;t[10]===a?S=t[11]:(S=(0,$.jsxs)(`mesh`,{ref:l,children:[x,(0,$.jsx)(`meshBasicMaterial`,{color:a,transparent:!0,opacity:0,blending:2,depthWrite:!1})]}),t[10]=a,t[11]=S);let C;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(C=[0,1.35,0],t[12]=C):C=t[12];let w;t[13]===_.kind?w=t[14]:(w=ke(_.kind),t[13]=_.kind,t[14]=w);let T;t[15]!==o||t[16]!==w?(T=(0,$.jsxs)(`span`,{children:[o,` · `,w]}),t[15]=o,t[16]=w,t[17]=T):T=t[17];let E;t[18]!==v||t[19]!==_.savedTokens?(E=v&&(0,$.jsx)(`strong`,{className:_.savedTokens<0?`is-cost`:``,children:v}),t[18]=v,t[19]=_.savedTokens,t[20]=E):E=t[20];let D;t[21]===_.latencyMs?D=t[22]:(D=(0,$.jsxs)(`small`,{children:[_.latencyMs,` ms`]}),t[21]=_.latencyMs,t[22]=D);let O;t[23]!==E||t[24]!==D||t[25]!==T?(O=(0,$.jsx)(`group`,{ref:u,children:(0,$.jsx)(nt,{position:C,center:!0,distanceFactor:20,className:`pointer-events-none select-none`,children:(0,$.jsxs)(`div`,{className:`office3d-jev-chip`,children:[T,E,D]})})}),t[23]=E,t[24]=D,t[25]=T,t[26]=O):O=t[26];let k;return t[27]!==O||t[28]!==b||t[29]!==S?(k=(0,$.jsxs)(`group`,{children:[b,S,O]}),t[27]=O,t[28]=b,t[29]=S,t[30]=k):k=t[30],k}function Or(e){let t=(0,K.c)(74),{desks:n,coordinator:r,interactions:i,workEvents:a,jev:o}=e,s=J(Fr),c=J(Pr),l=J(Nr),u=typeof window<`u`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`off`:l,d=J(Mr),f=J(jr),p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=new Map,t[0]=p):p=t[0];let m=(0,q.useRef)(p),h;t[1]===n?h=t[2]:(h=n.some(Ar),t[1]=n,t[2]=h);let g=h,_;t[3]===s?_=t[4]:(_=s===`high`?[1,1.75]:1,t[3]=s,t[4]=_);let v;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(v={antialias:!1,alpha:!1,powerPreference:`high-performance`},t[5]=v):v=t[5];let y;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(y={fov:42,near:.1,far:220,position:[0,46,62]},t[6]=y):y=t[6];let b;t[7]===f?b=t[8]:(b=()=>f(null),t[7]=f,t[8]=b);let x;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(`color`,{attach:`background`,args:[`#04060c`]}),t[9]=x):x=t[9];let S,C,w;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(`fog`,{attach:`fog`,args:[`#04060c`,34,100]}),w=(0,$.jsx)(`ambientLight`,{intensity:.35}),S=(0,$.jsx)(`directionalLight`,{position:[12,24,8],intensity:.35,color:`#9db8ff`}),t[10]=S,t[11]=C,t[12]=w):(S=t[10],C=t[11],w=t[12]);let T=r?.id??null,E;t[13]!==n||t[14]!==T||t[15]!==a?(E=(0,$.jsx)(br,{events:a,desks:n,coordinatorId:T}),t[13]=n,t[14]=T,t[15]=a,t[16]=E):E=t[16];let D;t[17]!==n||t[18]!==u?(D=(0,$.jsx)(qn,{desks:n,swarmRef:m,motion:u}),t[17]=n,t[18]=u,t[19]=D):D=t[19];let O=r?.id??null,k;t[20]!==u||t[21]!==d||t[22]!==O?(k=(0,$.jsx)(Qt,{coordinatorId:O,selectedAgentId:d,swarmRef:m,motion:u}),t[20]=u,t[21]=d,t[22]=O,t[23]=k):k=t[23];let A;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(cn,{}),t[24]=A):A=t[24];let j;t[25]!==g||t[26]!==r?(j=(0,$.jsx)(bn,{coordinator:r,active:g,swarmRef:m}),t[25]=g,t[26]=r,t[27]=j):j=t[27];let M;t[28]===n?M=t[29]:(M=n.map(e=>(0,$.jsx)(sr,{desk:e,swarmRef:m},e.agent.id)),t[28]=n,t[29]=M);let N=r?.id??null,P;t[30]!==n||t[31]!==i||t[32]!==N?(P=(0,$.jsx)(An,{desks:n,interactions:i,swarmRef:m,coordinatorId:N}),t[30]=n,t[31]=i,t[32]=N,t[33]=P):P=t[33];let F=r?.id??null,I;t[34]!==u||t[35]!==o.decisions||t[36]!==o.status||t[37]!==F?(I=(0,$.jsx)(Tr,{status:o.status,decisions:o.decisions,swarmRef:m,coordinatorId:F,motion:u}),t[34]=u,t[35]=o.decisions,t[36]=o.status,t[37]=F,t[38]=I):I=t[38];let L;t[39]!==r?.id||t[40]!==r?.name||t[41]!==n||t[42]!==u||t[43]!==a?(L=u===`calm`&&(0,$.jsx)(vr,{desks:n,events:a,swarmRef:m,coordinatorId:r?.id??null,coordinatorName:r?.name??`Coordinador`}),t[39]=r?.id,t[40]=r?.name,t[41]=n,t[42]=u,t[43]=a,t[44]=L):L=t[44];let R;t[45]!==n||t[46]!==u||t[47]!==s?(R=u===`calm`&&s===`high`&&(0,$.jsx)(Un,{desks:n,swarmRef:m}),t[45]=n,t[46]=u,t[47]=s,t[48]=R):R=t[48];let z;t[49]!==u||t[50]!==s?(z=u===`calm`&&s===`high`&&(0,$.jsx)(zn,{}),t[49]=u,t[50]=s,t[51]=z):z=t[51];let B;t[52]===s?B=t[53]:(B=(0,$.jsx)(Gn,{quality:s}),t[52]=s,t[53]=B);let V;t[54]!==s||t[55]!==c?(V=(0,$.jsx)(Ht,{bounds:kr,onDecline:()=>{s===`high`&&c(`low`)}}),t[54]=s,t[55]=c,t[56]=V):V=t[56];let H;t[57]!==E||t[58]!==D||t[59]!==k||t[60]!==j||t[61]!==M||t[62]!==P||t[63]!==I||t[64]!==L||t[65]!==R||t[66]!==z||t[67]!==B||t[68]!==V?(H=(0,$.jsxs)(q.Suspense,{fallback:null,children:[E,D,k,A,j,M,P,I,L,R,z,B,V]}),t[57]=E,t[58]=D,t[59]=k,t[60]=j,t[61]=M,t[62]=P,t[63]=I,t[64]=L,t[65]=R,t[66]=z,t[67]=B,t[68]=V,t[69]=H):H=t[69];let ee;return t[70]!==H||t[71]!==_||t[72]!==b?(ee=(0,$.jsxs)(he,{dpr:_,gl:v,camera:y,onPointerMissed:b,children:[x,C,w,S,H]}),t[70]=H,t[71]=_,t[72]=b,t[73]=ee):ee=t[73],ee}function kr(e){return[Math.min(42,e*.68),e*.92]}function Ar(e){return e.state===`thinking`||e.state===`tool_call`||e.state===`stuck`}function jr(e){return e.select}function Mr(e){return e.selectedAgentId}function Nr(e){return e.motion}function Pr(e){return e.setQuality}function Fr(e){return e.quality}function Ir(e){let t=(0,K.c)(8),{events:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`div`,{className:`office3d-ticker-title`,children:`Actividad`}),t[0]=r):r=t[0];let i;t[1]===n.length?i=t[2]:(i=n.length===0&&(0,$.jsx)(`div`,{className:`office3d-ticker-empty`,children:`Sin eventos todavía…`}),t[1]=n.length,t[2]=i);let a;t[3]===n?a=t[4]:(a=n.slice(0,6).map(Lr),t[3]=n,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,$.jsxs)(`div`,{className:`office3d-ticker`,children:[r,(0,$.jsxs)(`div`,{className:`office3d-ticker-list`,role:`log`,"aria-live":`polite`,"aria-relevant":`additions`,children:[i,a]})]}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o}function Lr(e){return(0,$.jsxs)(`div`,{className:`office3d-ticker-item office3d-ticker-item--${e.kind}`,children:[(0,$.jsx)(`span`,{className:`office3d-ticker-dot`,style:{background:e.color}}),(0,$.jsx)(`span`,{className:`office3d-ticker-text`,children:e.text}),(0,$.jsx)(`span`,{className:`office3d-ticker-time`,children:e.time})]},e.id)}var Rr=0;function zr(e,t){return t===`tool_call`&&!e.currentTask?{text:`${e.agent.name} · ${Yn(e.currentTool)??`Ejecutando herramienta`}`,color:e.color,kind:`work`}:t===`thinking`&&!e.currentTask?{text:`${e.agent.name} está pensando…`,color:e.color,kind:`info`}:t===`stuck`?{text:`${e.agent.name} necesita ayuda`,color:`#f87171`,kind:`warn`}:null}function Br(e,t,n,r,i=[]){let[a,o]=(0,q.useState)([]),s=(0,q.useRef)(new Map),c=(0,q.useRef)(new Set),l=(0,q.useRef)(new Set),u=(0,q.useRef)(!1);return(0,q.useEffect)(()=>{let a=s.current,d=new Map(e.map(e=>[e.agent.id,e])),f=[],p=new Date().toLocaleTimeString(`es`,{hour12:!1}),m=e=>e===n?.id?n.name:d.get(e)?.agent.name??e;if(u.current){for(let e of r){if(c.current.has(e.eventId))continue;c.current.add(e.eventId);let t=pr(e.phase);f.push({id:++Rr,time:new Date(e.timestamp).toLocaleTimeString(`es`,{hour12:!1}),text:`${fr(e.phase)} · ${m(e.actorId)}${e.targetId?` → ${m(e.targetId)}`:``}: «${e.taskName}»`,color:t===`alert`?`#fb7185`:t===`done`?`#86efac`:d.get(e.targetId??``)?.color??`#f59e0b`,kind:t===`alert`?`warn`:t===`done`?`done`:`work`})}for(let e of i){if(l.current.has(e.eventId)||(l.current.add(e.eventId),e.kind!==`context`))continue;let t=Ne(e.savedTokens);f.push({id:++Rr,time:new Date(e.timestamp).toLocaleTimeString(`es`,{hour12:!1}),text:`Jev → ${m(e.agentId)}: ${e.summary}${t?` (${t})`:``}${e.recommendedAgentId?` · sugiere ${m(e.recommendedAgentId)}`:``}${e.mcpOff?.length?` (encender ${e.mcpOff.join(`, `)})`:``}`,color:Ee,kind:`info`})}}else{r.forEach(e=>c.current.add(e.eventId)),i.forEach(e=>l.current.add(e.eventId));for(let e of t)f.push({id:++Rr,time:p,text:`${m(e.sourceId)} → ${m(e.targetId)}: «${e.taskName??`Flujo activo`}»`,color:d.get(e.targetId)?.color??`#f59e0b`,kind:`work`});u.current=!0}for(let t of e){let e=a.get(t.agent.id);if(e&&e.state!==t.state){let e=zr(t,t.state);e&&f.push({id:++Rr,time:p,...e})}a.set(t.agent.id,{state:t.state})}f.length&&o(e=>[...f.reverse(),...e].slice(0,24))},[e,t,n,r,i]),a}function Vr(e){let t=(0,K.c)(63),{status:n,decisions:r,coordinator:i,desks:a}=e,[o,s]=(0,q.useState)(!1),l=T(Gr);if(!n||n.state===`off`)return null;let u;t[0]!==i||t[1]!==a?(u=e=>e===i?.id?i.name:a.find(t=>t.agent.id===e)?.agent.name??e,t[0]=i,t[1]=a,t[2]=u):u=t[2];let f=u,m;t[3]===n.totals?m=t[4]:(m=n.totals??{decisions:0,savedTokens:0,costUsd:0},t[3]=n.totals,t[4]=m);let h=m,g=r[r.length-1],_;t[5]===r?_=t[6]:(_=r.length?Math.round(r.reduce(Wr,0)/r.length):null,t[5]=r,t[6]=_);let v=_,y;if(t[7]!==v||t[8]!==l||t[9]!==o||t[10]!==g||t[11]!==f||t[12]!==n||t[13]!==h.costUsd||t[14]!==h.decisions||t[15]!==h.savedTokens){let e=Object.entries(l).sort(Ur).slice(0,4),r,i;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`span`,{className:`office3d-jev-icon`,children:(0,$.jsx)(p,{size:14})}),i=(0,$.jsx)(`span`,{className:`office3d-section-kicker`,children:`PLANO DE DECISIÓN`}),t[17]=r,t[18]=i):(r=t[17],i=t[18]);let a;t[19]===n?a=t[20]:(a=Ae(n),t[19]=n,t[20]=a);let u;t[21]===n.state?u=t[22]:(u=je(n.state),t[21]=n.state,t[22]=u);let m;t[23]!==a||t[24]!==u?(m=(0,$.jsxs)(`div`,{children:[i,(0,$.jsxs)(`h2`,{children:[a,` · `,u]})]}),t[23]=a,t[24]=u,t[25]=m):m=t[25];let _;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>s(Hr),t[26]=_):_=t[26];let b=o?`Mostrar detalle de Jev`:`Ocultar detalle de Jev`,x=!o,S;t[27]===o?S=t[28]:(S=o?(0,$.jsx)(c,{size:14}):(0,$.jsx)(d,{size:14}),t[27]=o,t[28]=S);let C;t[29]!==b||t[30]!==x||t[31]!==S?(C=(0,$.jsx)(`button`,{type:`button`,className:`office3d-roster-toggle`,onClick:_,"aria-label":b,"aria-expanded":x,children:S}),t[29]=b,t[30]=x,t[31]=S,t[32]=C):C=t[32];let w;t[33]!==C||t[34]!==m?(w=(0,$.jsxs)(`header`,{className:`office3d-jev-head`,children:[r,m,C]}),t[33]=C,t[34]=m,t[35]=w):w=t[35];let T;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(`dt`,{children:`Decisiones`}),t[36]=T):T=t[36];let E;t[37]===h.decisions?E=t[38]:(E=(0,$.jsxs)(`div`,{children:[T,(0,$.jsx)(`dd`,{children:h.decisions})]}),t[37]=h.decisions,t[38]=E);let D=h.savedTokens>=0?`Tokens ahorrados`:`Tokens añadidos`,O;t[39]===D?O=t[40]:(O=(0,$.jsx)(`dt`,{children:D}),t[39]=D,t[40]=O);let k;t[41]===h.savedTokens?k=t[42]:(k=Me(h.savedTokens),t[41]=h.savedTokens,t[42]=k);let A;t[43]===k?A=t[44]:(A=(0,$.jsxs)(`dd`,{children:[`~`,k]}),t[43]=k,t[44]=A);let j;t[45]!==O||t[46]!==A?(j=(0,$.jsxs)(`div`,{children:[O,A]}),t[45]=O,t[46]=A,t[47]=j):j=t[47];let M;t[48]===n?M=t[49]:(M=Ae(n),t[48]=n,t[49]=M);let N;t[50]===M?N=t[51]:(N=(0,$.jsxs)(`dt`,{children:[`Costo `,M]}),t[50]=M,t[51]=N);let P;t[52]===h.costUsd?P=t[53]:(P=Pe(h.costUsd),t[52]=h.costUsd,t[53]=P);let F;t[54]===P?F=t[55]:(F=(0,$.jsx)(`dd`,{children:P}),t[54]=P,t[55]=F);let I;t[56]!==N||t[57]!==F?(I=(0,$.jsxs)(`div`,{children:[N,F]}),t[56]=N,t[57]=F,t[58]=I):I=t[58];let L;t[59]!==E||t[60]!==j||t[61]!==I?(L=(0,$.jsxs)(`dl`,{className:`office3d-jev-metrics`,children:[E,j,I]}),t[59]=E,t[60]=j,t[61]=I,t[62]=L):L=t[62],y=(0,$.jsxs)(`section`,{className:`office3d-jev office3d-glass ${n.state===`fallback`?`is-fallback`:``} ${o?`is-collapsed`:``}`,"aria-label":`Jev, plano de decisión`,children:[w,L,!o&&(0,$.jsxs)($.Fragment,{children:[n.state===`fallback`&&n.lastError&&(0,$.jsxs)(`p`,{className:`office3d-jev-warn`,children:[`Usando el flujo clásico: `,n.lastError]}),g&&(0,$.jsxs)(`div`,{className:`office3d-jev-latest`,children:[(0,$.jsxs)(`span`,{children:[`Última decisión · `,f(g.agentId),` · `,ke(g.kind)]}),(0,$.jsx)(`p`,{children:g.summary}),g.recommendedAgentId&&(g.mcpOff?.length?(0,$.jsxs)(`p`,{className:`office3d-jev-warn`,children:[f(g.recommendedAgentId),` es el indicado, pero necesita encender `,g.mcpOff.join(`, `)]}):(0,$.jsxs)(`p`,{children:[`Recomendó delegar en `,f(g.recommendedAgentId)]}))]}),e.length>0&&(0,$.jsx)(`ul`,{className:`office3d-jev-agents`,"aria-label":`Ahorro por agente desde que abriste la oficina`,children:e.map(e=>{let[t,n]=e;return(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`span`,{children:f(t)}),(0,$.jsxs)(`b`,{children:[n.savedTokens>=0?`−`:`+`,Me(n.savedTokens)]}),(0,$.jsxs)(`small`,{children:[n.decisions,` dec.`]})]},t)})}),(0,$.jsxs)(`p`,{className:`office3d-jev-note`,children:[`Estimación frente al flujo clásico (caracteres ÷ 4)`,v===null?``:` · ${v} ms de media`]})]})]}),t[7]=v,t[8]=l,t[9]=o,t[10]=g,t[11]=f,t[12]=n,t[13]=h.costUsd,t[14]=h.decisions,t[15]=h.savedTokens,t[16]=y}else y=t[16];return y}function Hr(e){return!e}function Ur(e,t){let[,n]=e,[,r]=t;return r.savedTokens-n.savedTokens}function Wr(e,t){return e+t.latencyMs}function Gr(e){return e.jevByAgent}function Kr(e){let t=(0,K.c)(9),{agentId:n}=e,r;t[0]===n?r=t[1]:(r=e=>e.jevByAgent[n],t[0]=n,t[1]=r);let i=T(r);if(!i)return null;let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(`span`,{className:`office3d-inspector-label`,children:`Jev`}),t[2]=a):a=t[2];let o=i.decisions,s=i.savedTokens>=0?`−`:`+`,c;t[3]===i.savedTokens?c=t[4]:(c=Me(i.savedTokens),t[3]=i.savedTokens,t[4]=c);let l;return t[5]!==i.decisions||t[6]!==s||t[7]!==c?(l=(0,$.jsxs)(`div`,{className:`office3d-inspector-row`,children:[a,(0,$.jsxs)(`span`,{className:`font-mono`,children:[o,` dec. · `,s,c,` tok`]})]}),t[5]=i.decisions,t[6]=s,t[7]=c,t[8]=l):l=t[8],l}var qr={archived:`Archivado manualmente`,disabled:`Desactivado`,idle:`En espera`,thinking:`Pensando`,tool_call:`Ejecutando herramienta`,stuck:`Atascado`};function Jr({desk:e,delegatorName:t}){let n=J(e=>e.select);if(!e)return null;let{agent:r}=e;return(0,$.jsxs)(`aside`,{className:`office3d-inspector`,style:{"--agent-color":e.color},children:[(0,$.jsx)(`button`,{type:`button`,className:`office3d-inspector-close`,onClick:()=>n(null),"aria-label":`Cerrar`,children:(0,$.jsx)(w,{size:14})}),(0,$.jsxs)(`div`,{className:`office3d-inspector-head`,children:[(0,$.jsx)(`span`,{className:`office3d-inspector-orb`}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`office3d-inspector-name`,children:r.name}),(0,$.jsx)(`span`,{className:`office3d-inspector-id`,children:r.id})]})]}),(0,$.jsxs)(`div`,{className:`office3d-inspector-row`,children:[(0,$.jsx)(`span`,{className:`office3d-inspector-label`,children:`Rol`}),(0,$.jsx)(`span`,{children:r.role===`coordinator`?`Coordinador`:`Especialista`})]}),(0,$.jsxs)(`div`,{className:`office3d-inspector-row`,children:[(0,$.jsx)(`span`,{className:`office3d-inspector-label`,children:`Estado`}),(0,$.jsx)(`span`,{className:`office3d-state-chip office3d-state-chip--${e.state}`,children:qr[e.state]})]}),e.currentTask&&(0,$.jsxs)(`div`,{className:`office3d-inspector-row`,children:[(0,$.jsx)(`span`,{className:`office3d-inspector-label`,children:`Tarea`}),(0,$.jsx)(`span`,{className:`office3d-inspector-task`,children:e.currentTask})]}),e.delegatedBy&&(0,$.jsxs)(`div`,{className:`office3d-inspector-row`,children:[(0,$.jsx)(`span`,{className:`office3d-inspector-label`,children:`Delegado por`}),(0,$.jsx)(`span`,{children:t})]}),e.currentTool&&(0,$.jsxs)(`div`,{className:`office3d-inspector-row`,children:[(0,$.jsx)(`span`,{className:`office3d-inspector-label`,children:`Herramienta`}),(0,$.jsx)(`span`,{className:`office3d-inspector-tool`,children:Yn(e.currentTool)})]}),(0,$.jsxs)(`div`,{className:`office3d-inspector-row`,children:[(0,$.jsx)(`span`,{className:`office3d-inspector-label`,children:`Workers`}),(0,$.jsx)(`span`,{className:`font-mono`,children:e.workerCount})]}),(0,$.jsx)(Kr,{agentId:r.id}),r.description&&(0,$.jsx)(`p`,{className:`office3d-inspector-desc`,children:r.description})]})}function Yr({coordinator:e}){let t=J(e=>e.select);return e?(0,$.jsxs)(`aside`,{className:`office3d-inspector office3d-inspector--coordinator`,style:{"--agent-color":`#f59e0b`},children:[(0,$.jsx)(`button`,{type:`button`,className:`office3d-inspector-close`,onClick:()=>t(null),"aria-label":`Cerrar`,children:(0,$.jsx)(w,{size:14})}),(0,$.jsxs)(`div`,{className:`office3d-inspector-head`,children:[(0,$.jsx)(`span`,{className:`office3d-inspector-orb`}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`office3d-inspector-eyebrow`,children:`Coordinador principal`}),(0,$.jsx)(`h3`,{className:`office3d-inspector-name`,children:e.name})]})]}),(0,$.jsxs)(`div`,{className:`office3d-inspector-row`,children:[(0,$.jsx)(`span`,{className:`office3d-inspector-label`,children:`Función`}),(0,$.jsx)(`span`,{children:`Asigna y supervisa`})]}),(0,$.jsxs)(`div`,{className:`office3d-inspector-row`,children:[(0,$.jsx)(`span`,{className:`office3d-inspector-label`,children:`Estado`}),(0,$.jsx)(`span`,{className:`office3d-state-chip office3d-state-chip--${e.status}`,children:e.status===`tool_call`?`Ejecutando herramienta`:e.status===`thinking`?`Pensando`:`En espera`})]}),(0,$.jsx)(Kr,{agentId:e.id}),typeof e.description==`string`&&(0,$.jsx)(`p`,{className:`office3d-inspector-desc`,children:e.description})]}):null}var Xr={archived:`Archivado`,disabled:`Desactivado`,idle:`Disponible`,thinking:`Pensando`,tool_call:`Ejecutando`,stuck:`Necesita ayuda`};function Zr(e){let t=e.agent.description?.trim();return t?t.length>62?`${t.slice(0,59)}…`:t:`Agente especialista`}function Qr({coordinator:e,desks:t,interactions:n,workEvents:r}){let[i,a]=(0,q.useState)(!1),o=J(e=>e.selectedAgentId),c=J(e=>e.select),d=new Map(t.map(e=>[e.agent.id,e])),f=t=>t===e?.id?e.name:d.get(t)?.agent.name??t,p=new Map;for(let e of r)p.set(e.taskRef,e);return(0,$.jsxs)(`aside`,{className:`office3d-roster office3d-glass ${i?`is-collapsed`:``}`,"aria-label":`Equipo y flujo de trabajo`,children:[(0,$.jsxs)(`div`,{className:`office3d-roster-heading`,children:[(0,$.jsxs)(`div`,{className:`office3d-roster-title`,children:[(0,$.jsx)(`span`,{className:`office3d-section-kicker`,children:`CENTRO DE OPERACIONES`}),(0,$.jsx)(`h2`,{children:`Quién hace qué`})]}),(0,$.jsx)(`span`,{className:`office3d-roster-live`,"aria-label":`${n.length} flujos activos`,children:(0,$.jsx)(g,{size:15,className:n.length?`is-active`:``})}),(0,$.jsx)(`button`,{type:`button`,className:`office3d-roster-toggle`,onClick:()=>a(e=>!e),"aria-expanded":!i,"aria-label":i?`Abrir centro de operaciones`:`Colapsar centro de operaciones`,title:i?`Abrir centro de operaciones`:`Colapsar centro de operaciones`,children:i?(0,$.jsx)(l,{size:16}):(0,$.jsx)(u,{size:16})})]}),(0,$.jsxs)(`div`,{className:`office3d-roster-content`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`office3d-roster-coordinator ${o===e?.id?`is-selected`:``}`,onClick:()=>e&&c(o===e.id?null:e.id),disabled:!e,children:[(0,$.jsx)(ve,{size:17}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`small`,{children:`ABEJA REINA · COORDINADOR`}),(0,$.jsx)(`strong`,{children:e?.name??`Conectando…`}),(0,$.jsx)(`em`,{children:`Asigna · supervisa · recibe`})]})]}),(0,$.jsxs)(`div`,{className:`office3d-flow`,children:[(0,$.jsxs)(`div`,{className:`office3d-section-title`,children:[`Flujo activo `,(0,$.jsx)(`span`,{children:n.length})]}),n.length===0?(0,$.jsx)(`p`,{className:`office3d-flow-empty`,children:`El equipo está disponible. Las delegaciones aparecerán aquí.`}):n.map(e=>{let t=d.get(e.targetId),n=e.taskId?p.get(e.taskId):null,r=n?.phase===`completed`||n?.phase===`review_passed`?3:e.kind===`reviews`?2:+(t?.state===`thinking`||t?.state===`tool_call`),i=n?.phase===`failed`||n?.phase===`aborted`||n?.phase===`review_failed`||n?.phase===`blocked`;return(0,$.jsxs)(`div`,{className:`office3d-flow-item ${i?`is-failed`:``}`,children:[(0,$.jsx)(`span`,{children:f(e.sourceId)}),(0,$.jsx)(s,{size:12}),(0,$.jsx)(`span`,{children:f(e.targetId)}),(0,$.jsx)(`strong`,{children:e.kind===`reviews`?`Revisión`:`Delegación`}),e.taskName&&(0,$.jsx)(`small`,{children:e.taskName}),(0,$.jsx)(`div`,{className:`office3d-flow-steps`,"aria-label":`Progreso del trabajo`,children:[`Delegado`,`Trabajando`,`Revisando`,i?`Atención`:`Entregado`].map((e,t)=>(0,$.jsx)(`span`,{className:`${t<r?`is-done`:``} ${t===r?`is-current`:``}`,children:e},e))})]},e.id)})]}),(0,$.jsxs)(`div`,{className:`office3d-agents-list`,children:[(0,$.jsxs)(`div`,{className:`office3d-section-title`,children:[`Especialistas `,(0,$.jsx)(`span`,{children:t.length})]}),t.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:`office3d-agent-row ${o===e.agent.id?`is-selected`:``}`,onClick:()=>c(o===e.agent.id?null:e.agent.id),style:{"--agent-color":e.color},children:[(0,$.jsx)(`span`,{className:`office3d-agent-status office3d-name-dot--${e.state}`}),(0,$.jsxs)(`span`,{className:`office3d-agent-copy`,children:[(0,$.jsx)(`strong`,{children:e.agent.name}),(0,$.jsx)(`small`,{children:e.currentTask||Zr(e)})]}),(0,$.jsx)(`em`,{children:Xr[e.state]})]},e.agent.id))]})]})]})}function $r(e){let t=(0,K.c)(46),{coordinator:n,desks:r}=e,i=J(ti);if(!i)return null;let a,o,s,c,l,u,d,p,m,h;if(t[0]!==n||t[1]!==i.actorId||t[2]!==i.phase||t[3]!==i.targetId||t[4]!==r){let e=new Map(r.map(ei)),v=t=>t?t===n?.id?n.name:e.get(t)?.agent.name??`Agente`:n?.name??`Coordinador`,y;t[15]===i.phase?y=t[16]:(y=pr(i.phase),t[15]=i.phase,t[16]=y);let b=y,x=b===`alert`?D:b===`done`?f:b===`review`?ye:i.phase===`delegated`?_:g;p=`office3d-now office3d-glass is-${b}`,m=b===`alert`?`assertive`:`polite`,h=`true`,t[17]===x?o=t[18]:(o=(0,$.jsx)(`div`,{className:`office3d-now-icon`,children:(0,$.jsx)(x,{size:17})}),t[17]=x,t[18]=o),l=`office3d-now-copy`,t[19]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(`span`,{children:`AHORA OCURRE`}),t[19]=u):u=t[19];let S;t[20]===i.phase?S=t[21]:(S=fr(i.phase),t[20]=i.phase,t[21]=S),t[22]===S?d=t[23]:(d=(0,$.jsx)(`strong`,{children:S}),t[22]=S,t[23]=d),a=v(i.actorId),t[24]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(`b`,{children:`→`}),t[24]=s):s=t[24],c=v(i.targetId),t[0]=n,t[1]=i.actorId,t[2]=i.phase,t[3]=i.targetId,t[4]=r,t[5]=a,t[6]=o,t[7]=s,t[8]=c,t[9]=l,t[10]=u,t[11]=d,t[12]=p,t[13]=m,t[14]=h}else a=t[5],o=t[6],s=t[7],c=t[8],l=t[9],u=t[10],d=t[11],p=t[12],m=t[13],h=t[14];let v;t[25]!==a||t[26]!==s||t[27]!==c?(v=(0,$.jsxs)(`p`,{children:[a,s,c]}),t[25]=a,t[26]=s,t[27]=c,t[28]=v):v=t[28];let y;t[29]===i.taskName?y=t[30]:(y=(0,$.jsx)(`small`,{children:i.taskName}),t[29]=i.taskName,t[30]=y);let b;t[31]===i.detail?b=t[32]:(b=i.detail&&(0,$.jsx)(`em`,{children:i.detail}),t[31]=i.detail,t[32]=b);let x;t[33]!==v||t[34]!==y||t[35]!==b||t[36]!==l||t[37]!==u||t[38]!==d?(x=(0,$.jsxs)(`div`,{className:l,children:[u,d,v,y,b]}),t[33]=v,t[34]=y,t[35]=b,t[36]=l,t[37]=u,t[38]=d,t[39]=x):x=t[39];let S;return t[40]!==o||t[41]!==x||t[42]!==p||t[43]!==m||t[44]!==h?(S=(0,$.jsxs)(`section`,{className:p,"aria-live":m,"aria-atomic":h,children:[o,x]}),t[40]=o,t[41]=x,t[42]=p,t[43]=m,t[44]=h,t[45]=S):S=t[45],S}function ei(e){return[e.agent.id,e]}function ti(e){return e.activeCue}var ni=null;function ri(){if(!(typeof window>`u`))try{ni??=new AudioContext,ni.state===`suspended`&&ni.resume()}catch{ni=null}}var ii={delegated:[520,680],review_passed:[720,960],review_failed:[260,190],completed:[660,880],failed:[220,150],aborted:[280,210],blocked:[240,180]};function ai(e){if(ri(),!ni||ni.state!==`running`)return;let[t,n]=ii[e.phase],r=ni.currentTime,i=ni.createGain();i.gain.setValueAtTime(1e-4,r),i.gain.exponentialRampToValueAtTime(.045,r+.018),i.gain.exponentialRampToValueAtTime(1e-4,r+.34),i.connect(ni.destination);for(let[e,a]of[[t,0],[n,.12]]){let t=ni.createOscillator();t.type=`sine`,t.frequency.setValueAtTime(e,r+a),t.connect(i),t.start(r+a),t.stop(r+a+.2)}}function oi(e){let t=(0,K.c)(89),{desks:n,coordinator:r,interactions:i,workEvents:a,isConnected:s,selectedDesk:c,coordinatorSelected:l,coordinatorName:u,jev:d}=e,f=J(pi),m=J(fi),g=J(di),_=J(ui),S=J(li),C=J(ci),w=Br(n,i,r,a,d.decisions),T;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(T=new Set,t[0]=T):T=t[0];let E=(0,q.useRef)(T),D=(0,q.useRef)(!1),k,A;t[1]!==S||t[2]!==a?(k=()=>{if(!D.current){a.forEach(e=>E.current.add(e.eventId)),D.current=!0;return}for(let e of a)E.current.has(e.eventId)||(E.current.add(e.eventId),S&&ai(e))},A=[S,a],t[1]=S,t[2]=a,t[3]=k,t[4]=A):(k=t[3],A=t[4]),(0,q.useEffect)(k,A);let j;t[5]===n?j=t[6]:(j=n.filter(si),t[5]=n,t[6]=j);let M=j.length,N;t[7]!==u||t[8]!==n||t[9]!==c?(N=c?.delegatedBy?n.find(e=>e.agent.id===c.delegatedBy)?.agent.name??u:u,t[7]=u,t[8]=n,t[9]=c,t[10]=N):N=t[10];let P=N,F,I;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(`div`,{className:`office3d-logo`,children:(0,$.jsx)(O,{size:18})}),I=(0,$.jsx)(`h1`,{className:`office3d-title`,children:`HoloHive · Oficina 3D`}),t[11]=F,t[12]=I):(F=t[11],I=t[12]);let L;t[13]!==n.length||t[14]!==M?(L=(0,$.jsxs)(`div`,{className:`office3d-topbar-left`,children:[F,(0,$.jsxs)(`div`,{children:[I,(0,$.jsxs)(`p`,{className:`office3d-subtitle`,children:[n.length,` especialistas · `,M,` trabajando`]})]})]}),t[13]=n.length,t[14]=M,t[15]=L):L=t[15];let R=`office3d-live-badge ${s?`is-live`:`is-off`}`,z;t[16]===s?z=t[17]:(z=s?(0,$.jsx)(x,{size:12}):(0,$.jsx)(b,{size:12}),t[16]=s,t[17]=z);let B=s?`LIVE`:`OFFLINE`,V;t[18]!==z||t[19]!==B||t[20]!==R?(V=(0,$.jsxs)(`span`,{className:R,children:[z,B]}),t[18]=z,t[19]=B,t[20]=R,t[21]=V):V=t[21];let H;t[22]===d.status?H=t[23]:(H=d.status&&d.status.state!==`off`&&(0,$.jsxs)(`span`,{className:`office3d-jev-badge is-${d.status.state}`,title:`${Ae(d.status)} ${je(d.status.state)}`,children:[(0,$.jsx)(p,{size:11}),Ae(d.status).toUpperCase(),d.status.totals&&d.status.totals.savedTokens>0&&(0,$.jsxs)(`b`,{children:[`−`,Me(d.status.totals.savedTokens)]})]}),t[22]=d.status,t[23]=H);let ee;t[24]!==f||t[25]!==m?(ee=()=>m(f===`high`?`low`:`high`),t[24]=f,t[25]=m,t[26]=ee):ee=t[26];let te;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,$.jsx)(h,{size:13}),t[27]=te):te=t[27];let ne=f===`high`?`Alta`:`Eco`,U;t[28]!==ee||t[29]!==ne?(U=(0,$.jsxs)(`button`,{type:`button`,className:`office3d-hud-btn`,onClick:ee,title:`Alternar calidad gráfica`,children:[te,ne]}),t[28]=ee,t[29]=ne,t[30]=U):U=t[30];let re=`office3d-hud-btn ${g===`calm`?`is-on`:``}`,ie;t[31]!==g||t[32]!==_?(ie=()=>_(g===`calm`?`off`:`calm`),t[31]=g,t[32]=_,t[33]=ie):ie=t[33];let ae;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,$.jsx)(o,{size:13}),t[34]=ae):ae=t[34];let oe=g===`calm`?`Enfoque`:`Fijo`,W;t[35]!==re||t[36]!==ie||t[37]!==oe?(W=(0,$.jsxs)(`button`,{type:`button`,className:re,onClick:ie,title:`Alternar enfoque y movimiento de eventos`,children:[ae,oe]}),t[35]=re,t[36]=ie,t[37]=oe,t[38]=W):W=t[38];let se=`office3d-hud-btn ${S?`is-on`:``}`,ce;t[39]!==C||t[40]!==S?(ce=()=>{S||ri(),C(!S)},t[39]=C,t[40]=S,t[41]=ce):ce=t[41];let le=S?`Desactivar sonido de eventos`:`Activar sonido de eventos`,ue;t[42]===S?ue=t[43]:(ue=S?(0,$.jsx)(v,{size:13}):(0,$.jsx)(y,{size:13}),t[42]=S,t[43]=ue);let de=S?`Audio`:`Silencio`,fe;t[44]!==S||t[45]!==se||t[46]!==ce||t[47]!==le||t[48]!==ue||t[49]!==de?(fe=(0,$.jsxs)(`button`,{type:`button`,className:se,onClick:ce,title:le,"aria-pressed":S,children:[ue,de]}),t[44]=S,t[45]=se,t[46]=ce,t[47]=le,t[48]=ue,t[49]=de,t[50]=fe):fe=t[50];let pe;t[51]!==V||t[52]!==H||t[53]!==U||t[54]!==W||t[55]!==fe?(pe=(0,$.jsxs)(`div`,{className:`office3d-topbar-right`,children:[V,H,U,W,fe]}),t[51]=V,t[52]=H,t[53]=U,t[54]=W,t[55]=fe,t[56]=pe):pe=t[56];let me;t[57]!==pe||t[58]!==L?(me=(0,$.jsxs)(`header`,{className:`office3d-topbar office3d-glass`,children:[L,pe]}),t[57]=pe,t[58]=L,t[59]=me):me=t[59];let he;t[60]!==r||t[61]!==n?(he=(0,$.jsx)($r,{coordinator:r,desks:n}),t[60]=r,t[61]=n,t[62]=he):he=t[62];let ge;t[63]!==r||t[64]!==n||t[65]!==d.decisions||t[66]!==d.status?(ge=(0,$.jsx)(Vr,{status:d.status,decisions:d.decisions,coordinator:r,desks:n}),t[63]=r,t[64]=n,t[65]=d.decisions,t[66]=d.status,t[67]=ge):ge=t[67];let G;t[68]!==r||t[69]!==n||t[70]!==i||t[71]!==a?(G=(0,$.jsx)(Qr,{coordinator:r,desks:n,interactions:i,workEvents:a}),t[68]=r,t[69]=n,t[70]=i,t[71]=a,t[72]=G):G=t[72];let _e;t[73]===w?_e=t[74]:(_e=(0,$.jsx)(`div`,{className:`office3d-bottom-left`,children:(0,$.jsx)(Ir,{events:w})}),t[73]=w,t[74]=_e);let ve;t[75]!==P||t[76]!==c?(ve=(0,$.jsx)(Jr,{desk:c,delegatorName:P}),t[75]=P,t[76]=c,t[77]=ve):ve=t[77];let ye;t[78]!==r||t[79]!==l?(ye=l&&(0,$.jsx)(Yr,{coordinator:r}),t[78]=r,t[79]=l,t[80]=ye):ye=t[80];let be;return t[81]!==me||t[82]!==he||t[83]!==ge||t[84]!==G||t[85]!==_e||t[86]!==ve||t[87]!==ye?(be=(0,$.jsxs)(`div`,{className:`office3d-hud`,children:[me,he,ge,G,_e,ve,ye]}),t[81]=me,t[82]=he,t[83]=ge,t[84]=G,t[85]=_e,t[86]=ve,t[87]=ye,t[88]=be):be=t[88],be}function si(e){return e.state===`thinking`||e.state===`tool_call`}function ci(e){return e.setSoundEnabled}function li(e){return e.soundEnabled}function ui(e){return e.setMotion}function di(e){return e.motion}function fi(e){return e.setQuality}function pi(e){return e.quality}function mi(){let e=(0,K.c)(22),{coordinator:t,desks:n,interactions:r,workEvents:i,isConnected:a}=be(),o=J(hi),s=Fe(),c;e[0]!==n||e[1]!==o?(c=n.find(e=>e.agent.id===o)??null,e[0]=n,e[1]=o,e[2]=c):c=e[2];let l=c,u=!!t&&o===t.id,d=t?.name??`Coordinador`,f=t??null,p;e[3]!==n||e[4]!==r||e[5]!==s||e[6]!==f||e[7]!==i?(p=(0,$.jsx)(Or,{desks:n,coordinator:f,interactions:r,workEvents:i,jev:s}),e[3]=n,e[4]=r,e[5]=s,e[6]=f,e[7]=i,e[8]=p):p=e[8];let m=t??null,h;e[9]!==d||e[10]!==u||e[11]!==n||e[12]!==r||e[13]!==a||e[14]!==s||e[15]!==l||e[16]!==m||e[17]!==i?(h=(0,$.jsx)(oi,{desks:n,coordinator:m,interactions:r,workEvents:i,isConnected:a,selectedDesk:l,coordinatorSelected:u,coordinatorName:d,jev:s}),e[9]=d,e[10]=u,e[11]=n,e[12]=r,e[13]=a,e[14]=s,e[15]=l,e[16]=m,e[17]=i,e[18]=h):h=e[18];let g;return e[19]!==p||e[20]!==h?(g=(0,$.jsxs)(`div`,{className:`office3d-root`,children:[p,h]}),e[19]=p,e[20]=h,e[21]=g):g=e[21],g}function hi(e){return e.selectedAgentId}export{mi as default};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{f as t}from"./vendor-charts-K3xcRl0X.js";import{t as n}from"./vendor-react-kUOwxn0g.js";import{o as r}from"./vendor-query-Dj8xYhQD.js";import{t as i}from"./createLucideIcon-BRaPSYgN.js";import{t as a}from"./check-C8pw-7Fx.js";import{t as o}from"./chevron-down-8GjmTjLR.js";import{t as s}from"./chevron-right-BupZqrxu.js";import{t as c}from"./circle-check-BKNT2_q6.js";import{t as l}from"./useProviders-DXr4pJ57.js";import{t as u}from"./download-BQXrpH0m.js";import{n as d,t as f}from"./eye-CxvxtQT5.js";import{n as p,t as m}from"./key-DPkOY-J0.js";import{t as h}from"./lock-open-v0EphssG.js";import{t as g}from"./lock-3IApZyVy.js";import{t as _}from"./mic-CpDU_2as.js";import{t as v}from"./pencil-CKritjT_.js";import{t as y}from"./play-Cwpe4tp6.js";import{t as b}from"./plus-RD44ce15.js";import{t as x}from"./refresh-cw-DtJMHRHO.js";import{t as S}from"./search-z2oZt00P.js";import{t as C}from"./settings-qV3kVkeG.js";import{t as w}from"./square-D5zdNkAY.js";import{t as T}from"./terminal-BEcTK780.js";import{t as E}from"./trash-2-D6oziYAK.js";import{n as D,t as O}from"./wifi-BUJuOcgP.js";import{t as k}from"./utils-DEmd_M8c.js";import{D as A,F as j,N as M,O as N,T as P,X as F,Y as I,ct as L,dt as ee,j as te,ot as ne,w as R}from"./index-mBw9Tl7u.js";import{t as z}from"./badge-B5AKge1b.js";import{t as re}from"./scroll-area-CbH8FOo8.js";import{i as B,n as V,r as ie,t as ae}from"./tabs-epu-3Tl4.js";import{c as H,i as U,o as oe,r as W,s as G,t as K}from"./dialog-DKnsGLwr.js";import{t as se}from"./label-D_fvqJyD.js";import{i as q,n as ce,o as le,s as ue,t as de}from"./select-v_3QBYrD.js";import{t as fe}from"./switch-ndx8VCpm.js";import{a as pe,i as me,n as he,r as ge,t as _e}from"./card-mTJ4oZbL.js";var ve=i(`BookOpen`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z`,key:`ruj8y`}]]),ye=i(`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`}]]),J=n(),Y=e(t(),1);function be(e=720){let[t,n]=(0,Y.useState)(null);return(0,Y.useEffect)(()=>{let t=!1;return M(`/api/usage-stats?hours=${e}`).then(e=>{t||n(e.byProvider??{})}).catch(()=>{t||n(null)}),()=>{t=!0}},[e]),t}function xe(e){return e===0?`$0`:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function Se(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(e)}var X=r();function Ce(e){let t=(0,J.c)(62),{provider:n,onSave:r,onCancel:i}=e,[a,o]=(0,Y.useState)(!1),[s,l]=(0,Y.useState)(``),[u,p]=(0,Y.useState)(n?.baseUrl||n?.base_url||``),m;t[0]===n?m=t[1]:(m=n?.config?.headers?JSON.stringify(n.config.headers,null,2):``,t[0]=n,t[1]=m);let[h,g]=(0,Y.useState)(m),[_,v]=(0,Y.useState)(n?.num_ctx?String(n.num_ctx):``),y=u||n?.baseUrl||n?.base_url||``,b;t[2]!==y||t[3]!==n?.id?(b=n?.id===`ollama`||y.includes(`localhost`)||y.includes(`127.0.0.1`),t[2]=y,t[3]=n?.id,t[4]=b):b=t[4];let x=b,S=!!n?.has_api_key,C=!!n?.has_headers,w;t[5]!==s||t[6]!==u||t[7]!==h||t[8]!==_||t[9]!==r?(w=()=>{let e;if(h.trim())try{e=JSON.parse(h.trim())}catch{j.fire(`Error`,`JSON de Headers inválido`,`error`);return}r&&r({apiKey:s,baseUrl:u||void 0,headers:e,numCtx:_.trim()?Number(_.trim()):null})},t[5]=s,t[6]=u,t[7]=h,t[8]=_,t[9]=r,t[10]=w):w=t[10];let T=w,E;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,X.jsx)(se,{className:`hive-label`,children:`API Key`}),t[11]=E):E=t[11];let D;t[12]===S?D=t[13]:(D=S&&(0,X.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] font-bold text-emerald-400`,children:[(0,X.jsx)(c,{className:`h-3 w-3`}),`Configurada`]}),t[12]=S,t[13]=D);let O;t[14]===D?O=t[15]:(O=(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[E,D]}),t[14]=D,t[15]=O);let k=a?`text`:`password`,A;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(A=e=>l(e.target.value),t[16]=A):A=t[16];let M=S?`•••••••••••••••• (dejar vacío para conservar)`:`sk-...`,N;t[17]!==s||t[18]!==k||t[19]!==M?(N=(0,X.jsx)(I,{type:k,value:s,onChange:A,placeholder:M,className:`hive-input !h-8 text-xs pr-8`}),t[17]=s,t[18]=k,t[19]=M,t[20]=N):N=t[20];let P;t[21]===a?P=t[22]:(P=(0,X.jsx)(F,{variant:`ghost`,size:`icon`,className:`absolute right-0 top-0 h-8 w-8 text-white/40 hover:text-white`,onClick:()=>o(!a),children:a?(0,X.jsx)(d,{className:`h-3 w-3`}):(0,X.jsx)(f,{className:`h-3 w-3`})}),t[21]=a,t[22]=P);let L;t[23]!==N||t[24]!==P?(L=(0,X.jsxs)(`div`,{className:`relative`,children:[N,P]}),t[23]=N,t[24]=P,t[25]=L):L=t[25];let ee;t[26]!==L||t[27]!==O?(ee=(0,X.jsxs)(`div`,{className:`space-y-1`,children:[O,L]}),t[26]=L,t[27]=O,t[28]=ee):ee=t[28];let te;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,X.jsx)(se,{className:`hive-label`,children:`Base URL (opcional)`}),t[29]=te):te=t[29];let ne;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(ne=e=>p(e.target.value),t[30]=ne):ne=t[30];let R;t[31]===u?R=t[32]:(R=(0,X.jsxs)(`div`,{className:`space-y-1`,children:[te,(0,X.jsx)(I,{value:u,onChange:ne,placeholder:`https://api.example.com`,className:`hive-input !h-8 text-xs`})]}),t[31]=u,t[32]=R);let z;t[33]!==x||t[34]!==_?(z=x&&(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(se,{className:`hive-label`,children:`Context Window (num_ctx)`}),(0,X.jsx)(`span`,{className:`text-[10px] text-white/30`,children:`tokens — por defecto 32 768`})]}),(0,X.jsx)(I,{type:`number`,value:_,onChange:e=>v(e.target.value),placeholder:`8192`,min:512,step:512,className:`hive-input !h-8 text-xs font-mono`}),(0,X.jsx)(`p`,{className:`text-[10px] text-amber-400/60`,children:`Aumenta si ves errores de contexto. Tu modelo soporta hasta 262 144 tokens.`})]}),t[33]=x,t[34]=_,t[35]=z):z=t[35];let re;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,X.jsx)(se,{className:`hive-label`,children:`Custom Headers (JSON)`}),t[36]=re):re=t[36];let B;t[37]===C?B=t[38]:(B=C&&(0,X.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] font-bold text-emerald-400`,children:[(0,X.jsx)(c,{className:`h-3 w-3`}),`Configurados`]}),t[37]=C,t[38]=B);let V;t[39]===B?V=t[40]:(V=(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[re,B]}),t[39]=B,t[40]=V);let ie;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(ie=e=>g(e.target.value),t[41]=ie):ie=t[41];let ae=C?`{ ... } (dejar vacío para conservar)`:`{ "x-custom-header": "value" }`,H;t[42]!==h||t[43]!==ae?(H=(0,X.jsx)(`textarea`,{value:h,onChange:ie,placeholder:ae,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`}),t[42]=h,t[43]=ae,t[44]=H):H=t[44];let U;t[45]!==V||t[46]!==H?(U=(0,X.jsxs)(`div`,{className:`space-y-1`,children:[V,H]}),t[45]=V,t[46]=H,t[47]=U):U=t[47];let oe;t[48]===i?oe=t[49]:(oe=(0,X.jsx)(`button`,{className:`hive-btn hive-btn--form-cancel flex-1`,onClick:i,children:`Cancelar`}),t[48]=i,t[49]=oe);let W;t[50]===T?W=t[51]:(W=(0,X.jsx)(`button`,{className:`hive-btn hive-btn--form-submit flex-1`,onClick:T,children:`Guardar`}),t[50]=T,t[51]=W);let G;t[52]!==oe||t[53]!==W?(G=(0,X.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[oe,W]}),t[52]=oe,t[53]=W,t[54]=G):G=t[54];let K;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,X.jsx)(`p`,{className:`text-[10px] text-white/20 pt-2`,children:`La API key se guarda cifrada en la base de datos.`}),t[55]=K):K=t[55];let q;return t[56]!==ee||t[57]!==R||t[58]!==z||t[59]!==U||t[60]!==G?(q=(0,X.jsxs)(`div`,{className:`space-y-3`,children:[ee,R,z,U,G,K]}),t[56]=ee,t[57]=R,t[58]=z,t[59]=U,t[60]=G,t[61]=q):q=t[61],q}function we(e){let t=e.input_per_1m??e.inputPer1M,n=e.output_per_1m??e.outputPer1M;return typeof t!=`number`||typeof n!=`number`?null:{input:t,output:n}}function Te(e){return e.input===0&&e.output===0}function Ee(e){return e===0?`$0`:e<.01?`$${e.toFixed(3)}`:e<1?`$${e.toFixed(2)}`:`$${e%1==0?e:e.toFixed(2)}`}function De(e){let t=e.map(we).filter(e=>e!==null);if(t.length===0)return null;if(t.every(Te))return{label:`Gratis`,allFree:!0};let n=t.filter(e=>!Te(e));return{label:`desde ${Ee(Math.min(...n.map(e=>e.input)))}/1M`,allFree:!1}}function Oe(e){let t=(0,J.c)(14),{model:n,showContext:r}=e,i=r===void 0?!1:r,a,o,s;if(t[0]!==n||t[1]!==i){let e=we(n),r=n.contextWindow??n.context_window,c;t[5]!==r||t[6]!==i?(c=i&&r?`${r>=1e6?`${(r/1e6).toFixed(r%1e6==0?0:1)}M`:`${Math.round(r/1e3)}K`} ctx`:null,t[5]=r,t[6]=i,t[7]=c):c=t[7],a=c,o=`flex items-center gap-1.5 text-[10px] leading-tight font-mono`,s=e===null?(0,X.jsx)(`span`,{className:`text-white/25`,title:`Este modelo no tiene tarifa en el catálogo: su consumo se contabiliza como $0`,children:`Sin tarifa`}):Te(e)?(0,X.jsx)(`span`,{className:`text-emerald-400/70`,children:`Gratis`}):(0,X.jsxs)(`span`,{className:`text-white/40`,title:`USD por millón de tokens (entrada / salida)`,children:[(0,X.jsx)(`span`,{className:`text-white/55`,children:Ee(e.input)}),(0,X.jsx)(`span`,{className:`text-white/25`,children:` / `}),(0,X.jsx)(`span`,{className:`text-white/55`,children:Ee(e.output)}),(0,X.jsx)(`span`,{className:`text-white/25`,children:` /1M`})]}),t[0]=n,t[1]=i,t[2]=a,t[3]=o,t[4]=s}else a=t[2],o=t[3],s=t[4];let c;t[8]===a?c=t[9]:(c=a&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`text-white/15`,children:`·`}),(0,X.jsx)(`span`,{className:`text-white/30`,children:a})]}),t[8]=a,t[9]=c);let l;return t[10]!==o||t[11]!==s||t[12]!==c?(l=(0,X.jsxs)(`span`,{className:o,children:[s,c]}),t[10]=o,t[11]=s,t[12]=c,t[13]=l):l=t[13],l}var ke=[{value:`llm`,label:`LLM (texto)`},{value:`vision`,label:`Visión`},{value:`stt`,label:`STT (voz → texto)`},{value:`tts`,label:`TTS (texto → voz)`},{value:`embedding`,label:`Embeddings`}],Ae=[`chat`,`code`,`vision`,`reasoning`,`function_calling`,`json_mode`,`streaming`,`transcription`,`tts`,`speech`];function je(e){if(!e)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t.map(String):[]}catch{return[]}}function Me(e){let t=e.trim();if(t===``)return null;let n=Number(t);return Number.isFinite(n)&&n>=0?n:null}function Ne({open:e,onOpenChange:t,providerId:n,model:r,onSubmit:i,onOpenGuide:a,isFreeProvider:o}){let s=!!r,[c,l]=(0,Y.useState)(`manual`),[u,d]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(!1),[g,_]=(0,Y.useState)(``),[v,y]=(0,Y.useState)(``),[b,x]=(0,Y.useState)(``),[S,C]=(0,Y.useState)(`llm`),[w,T]=(0,Y.useState)(``),[E,D]=(0,Y.useState)(``),[O,k]=(0,Y.useState)(``),[A,j]=(0,Y.useState)([]),[N,P]=(0,Y.useState)(!1),[F,I]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{if(!e)return;I(null),y(r?r.wire_id??r.id:``),x(r?.name??``),C(r?.model_type??`llm`);let t=r?.contextWindow??r?.context_window;T(t?String(t):``);let n=r?.input_per_1m??r?.inputPer1M,i=r?.output_per_1m??r?.outputPer1M,a=!r&&o?`0`:``;D(typeof n==`number`?String(n):a),k(typeof i==`number`?String(i):a),j(je(r?.capabilities)),l(r?`manual`:`discover`),_(``),d(null),p(null)},[e,r,n,o]),(0,Y.useEffect)(()=>{!e||c!==`discover`||u!==null||m||(h(!0),p(null),M(`/api/providers/${encodeURIComponent(n)}/available-models`).then(e=>d(e.models??[])).catch(e=>p(e.message||`No se pudo consultar el provider.`)).finally(()=>h(!1)))},[e,c,n,u,m]);let L=(0,Y.useMemo)(()=>{if(!u)return[];let e=g.trim().toLowerCase();return e?u.filter(t=>t.wire_id.toLowerCase().includes(e)):u},[u,g]),ee=e=>{y(e.wire_id),x(e.wire_id.split(`/`).pop()||e.wire_id),l(`manual`)},te=e=>{j(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},ne=async()=>{let e=v.trim();if(!e){I(`El ID del modelo en la API es obligatorio.`);return}let n=Number(w.trim());if(w.trim()&&(!Number.isFinite(n)||n<=0)){I(`El contexto debe ser un número mayor que cero.`);return}P(!0),I(null);try{await i({id:e,name:b.trim()||e,model_type:S,context_window:w.trim()?n:void 0,input_per_1m:Me(E),output_per_1m:Me(O),capabilities:A.length?A:null}),t(!1)}catch(e){I(e.message||`No se pudo guardar el modelo.`)}finally{P(!1)}},R=`w-full bg-white/5 border border-white/10 rounded-md px-2.5 h-8 text-xs text-white/80 placeholder-white/20 focus:outline-none focus:border-blue-500/50 transition-all`,z=`block text-[10px] font-black uppercase tracking-widest text-white/40 mb-1`;return(0,X.jsx)(K,{open:e,onOpenChange:t,children:(0,X.jsxs)(W,{className:`rounded-xl border border-white/10 p-0 overflow-hidden w-[calc(100vw-2rem)] max-w-lg bg-[#09090b]`,children:[(0,X.jsxs)(`div`,{className:`p-5 border-b border-white/5 bg-white/5 relative overflow-hidden`,children:[(0,X.jsx)(`div`,{className:`absolute -top-10 -right-10 h-32 w-32 bg-blue-600/10 rounded-full blur-[80px] pointer-events-none`}),(0,X.jsx)(G,{className:`text-lg font-black text-white uppercase tracking-tighter`,children:s?`Editar modelo`:`Nuevo modelo`}),(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,X.jsxs)(U,{className:`text-xs text-white/40 font-medium mt-0.5`,children:[n,` — los precios alimentan el costo del dashboard.`]}),a&&(0,X.jsx)(`button`,{type:`button`,onClick:a,className:`shrink-0 h-6 px-2 rounded-md bg-white/5 border border-white/10 text-white/50 text-[10px] font-black uppercase tracking-widest hover:text-white hover:bg-white/10 transition-colors`,children:`? Guía`})]})]}),!s&&(0,X.jsx)(`div`,{className:`flex gap-1 px-5 pt-3`,children:[[`discover`,`Descubrir`],[`manual`,`Manual`]].map(([e,t])=>(0,X.jsx)(`button`,{type:`button`,onClick:()=>l(e),className:`h-7 px-3 rounded-md text-[10px] font-black uppercase tracking-widest border transition-colors ${c===e?`bg-blue-500/15 border-blue-500/30 text-blue-300`:`bg-transparent border-white/10 text-white/35 hover:text-white/70`}`,children:t},e))}),!s&&c===`discover`&&(0,X.jsxs)(`div`,{className:`p-5 space-y-3 max-h-[65vh] overflow-y-auto hive-scroll`,children:[(0,X.jsxs)(`p`,{className:`text-[11px] text-white/40 leading-relaxed`,children:[`Modelos que `,(0,X.jsx)(`span`,{className:`text-white/70`,children:n}),` sirve en este momento. Elegir de acá evita guardar un ID que no existe o que fue retirado — eso no falla al guardar, falla después en plena conversación.`]}),(0,X.jsx)(`input`,{value:g,onChange:e=>_(e.target.value),placeholder:`Buscar modelo…`,className:`${R} font-mono`}),m&&(0,X.jsx)(`p`,{className:`text-[11px] text-white/30 py-4 text-center`,children:`Consultando al provider…`}),f&&(0,X.jsxs)(`div`,{className:`text-[11px] text-amber-400/80 bg-amber-400/10 border border-amber-400/20 rounded-md px-2.5 py-2`,children:[f,(0,X.jsx)(`p`,{className:`text-white/40 mt-1`,children:`Este provider puede no publicar su lista de modelos. Usá la pestaña Manual.`})]}),u&&!m&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{className:`text-[10px] text-white/30`,children:[L.length,` de `,u.length,` modelos`]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5 max-h-72 overflow-y-auto hive-scroll pr-1`,children:[L.map(e=>(0,X.jsxs)(`button`,{type:`button`,disabled:e.already_added,onClick:()=>ee(e),className:`flex items-center justify-between gap-2 text-left rounded-md px-2.5 py-1.5 border transition-colors ${e.already_added?`border-transparent opacity-35 cursor-not-allowed`:`border-transparent hover:bg-white/5 hover:border-white/10`}`,children:[(0,X.jsx)(`span`,{className:`font-mono text-[11px] text-white/70 truncate`,children:e.wire_id}),e.already_added&&(0,X.jsx)(`span`,{className:`shrink-0 text-[9px] font-black uppercase tracking-widest text-emerald-400/70`,children:`ya está`})]},e.id)),L.length===0&&(0,X.jsx)(`p`,{className:`text-[11px] text-white/25 py-3 text-center`,children:`Ningún modelo coincide.`})]})]})]}),(s||c===`manual`)&&(0,X.jsxs)(`div`,{className:`p-5 space-y-3.5 max-h-[65vh] overflow-y-auto hive-scroll`,children:[(0,X.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:z,children:`ID en la API *`}),(0,X.jsx)(`input`,{className:`${R} font-mono`,value:v,onChange:e=>y(e.target.value),placeholder:`claude-sonnet-5`}),(0,X.jsx)(`p`,{className:`text-[10px] text-white/25 mt-1`,children:`Tal cual lo espera el provider.`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:z,children:`Nombre visible`}),(0,X.jsx)(`input`,{className:R,value:b,onChange:e=>x(e.target.value),placeholder:`Claude Sonnet 5`})]})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:z,children:`Tipo`}),(0,X.jsx)(`select`,{className:R,value:S,onChange:e=>C(e.target.value),children:ke.map(e=>(0,X.jsx)(`option`,{value:e.value,className:`bg-[#09090b]`,children:e.label},e.value))})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:z,children:`Contexto (tokens)`}),(0,X.jsx)(`input`,{type:`number`,min:0,className:`${R} font-mono`,value:w,onChange:e=>T(e.target.value),placeholder:`200000`})]})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`flex items-baseline justify-between mb-1`,children:[(0,X.jsx)(`span`,{className:`${z} mb-0`,children:`Costo — USD por millón de tokens`}),(0,X.jsx)(`span`,{className:`text-[10px] text-white/25`,children:`Vacío = sin tarifa`})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,X.jsx)(`div`,{children:(0,X.jsx)(`input`,{type:`number`,min:0,step:`0.001`,className:`${R} font-mono`,value:E,onChange:e=>D(e.target.value),placeholder:`Entrada — 3`})}),(0,X.jsx)(`div`,{children:(0,X.jsx)(`input`,{type:`number`,min:0,step:`0.001`,className:`${R} font-mono`,value:O,onChange:e=>k(e.target.value),placeholder:`Salida — 15`})})]}),(0,X.jsxs)(`p`,{className:`text-[10px] text-white/25 mt-1`,children:[`Pon `,(0,X.jsx)(`span`,{className:`font-mono text-white/40`,children:`0`}),` si el endpoint es gratuito: dejarlo vacío marca el modelo como “sin tarifa” y su consumo se contabiliza como $0 sin avisar en el dashboard.`]})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:z,children:`Capacidades`}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Ae.map(e=>(0,X.jsx)(`button`,{type:`button`,onClick:()=>te(e),className:`text-[10px] font-mono rounded px-2 py-1 leading-none border transition-colors ${A.includes(e)?`bg-blue-500/15 border-blue-500/30 text-blue-300`:`bg-white/5 border-white/10 text-white/30 hover:text-white/60`}`,children:e},e))})]}),F&&(0,X.jsx)(`p`,{className:`text-[11px] text-red-400 bg-red-500/10 border border-red-500/20 rounded-md px-2.5 py-1.5`,children:F})]}),(s||c===`manual`)&&(0,X.jsxs)(`div`,{className:`px-5 py-3 border-t border-white/5 flex items-center justify-end gap-2`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>t(!1),className:`hive-btn hive-btn--ghost h-8 px-3 text-[10px] font-black uppercase tracking-widest text-white/40`,children:`Cancelar`}),(0,X.jsx)(`button`,{type:`button`,onClick:ne,disabled:N||!v.trim(),className:`h-8 px-3.5 rounded-md bg-blue-500/15 border border-blue-500/30 text-blue-300 text-[10px] font-black uppercase tracking-widest hover:bg-blue-500/25 disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,children:N?`Guardando…`:s?`Guardar`:`Agregar`})]})]})})}var Pe=C,Fe=o,Ie=s,Le=l,Re=b,ze=p,Be=ee,Ve=x,He=v,Ue=E;function We({provider:e,updateProvider:t,onManageModels:n,usage:r,onOpenGuide:i}){let[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(null),[p,m]=(0,Y.useState)(null),{models:h,toggleModel:g,createModel:_,syncModels:v,deleteModel:y,updateModel:b}=A(),{toggleProvider:x}=N(),S=(0,Y.useMemo)(()=>{let t=h.filter(t=>(t.providerId||t.provider_id)===e.id);return t.length>0?t:e.models||[]},[h,e.id,e.models]),C=S.filter(e=>e.enabled||e.active),w=(0,Y.useMemo)(()=>De(S),[S]),T=n=>{t(e.id,n),o(!1)},E=async t=>{try{await x(e.id,t)}catch(e){console.error(`Failed to toggle provider:`,e)}},D=async(e,t)=>{try{await g(e.id,t)}catch(e){console.error(`Failed to toggle model:`,e)}},O=async()=>{u(!0);try{await v(e.id),c(!0)}catch(e){console.error(`Failed to sync models:`,e)}finally{u(!1)}},k=async t=>{p?.model?await b(p.model.id,t):await _(e.id,t)},j=async e=>{f(e.id);try{await y(e.id)}catch(e){console.error(`Failed to delete model:`,e)}finally{f(null)}},M=!!e.active,P=e.base_url||e.baseUrl,F=e.id===`ollama`||P?.includes(`localhost`)||P?.includes(`127.0.0.1`);return(0,X.jsxs)(`div`,{className:`hive-card group overflow-hidden flex flex-col gap-0 transition-all duration-500 ${M?`hive-card--active`:`opacity-70 grayscale-[0.5] hover:grayscale-0 hover:opacity-100`}`,children:[(0,X.jsx)(`div`,{className:`hive-card-body pb-3`,children:(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,X.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 ${M?`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,X.jsx)(Le,{className:`h-5 w-5`})}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,X.jsx)(`h3`,{className:`font-black text-white tracking-tight text-base sm:text-lg uppercase leading-none truncate`,children:e.name}),M&&(0,X.jsx)(`div`,{className:`hive-status-dot--active h-1.5 w-1.5 shrink-0`})]}),(0,X.jsx)(`p`,{className:`text-[11px] text-white/35 font-medium leading-none truncate`,children:e.id})]})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,X.jsx)(`span`,{className:`hidden sm:block text-[10px] font-black tracking-widest ${M?`text-blue-400`:`text-white/30`}`,children:M?`ON`:`OFF`}),(0,X.jsx)(fe,{checked:M,onCheckedChange:E,className:`data-[state=checked]:bg-blue-500`})]})]})}),(0,X.jsxs)(`div`,{className:`px-5 pb-3 space-y-2 border-b border-white/5`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,X.jsx)(ze,{className:`h-3.5 w-3.5 shrink-0 ${e.has_api_key?`text-emerald-400`:F?`text-amber-400`:`text-white/20`}`}),(0,X.jsx)(`span`,{className:`text-[11px] font-mono truncate`,children:e.masked_api_key?(0,X.jsx)(`span`,{className:`text-white/50`,children:e.masked_api_key}):e.has_api_key?(0,X.jsx)(`span`,{className:`text-white/50`,children:`••••••••••••••••`}):F?(0,X.jsx)(`span`,{className:`text-amber-400/70`,children:`Local — sin API key`}):(0,X.jsx)(`span`,{className:`text-white/25`,children:`Sin API key`})}),e.id===`openrouter`&&e.has_api_key?(0,X.jsx)(`button`,{type:`button`,onClick:()=>t(e.id,{clearApiKey:!0}),className:`ml-auto text-[10px] text-white/40 hover:text-rose-300`,children:`Quitar clave`}):null]}),e.id===`openrouter`&&e.jev?(0,X.jsxs)(`div`,{className:`text-[11px] text-white/50`,title:e.jev.lastError??void 0,children:[e.jev.backend===`kev`?`Kev`:`Jev`,` · `,e.jev.state===`ready`?`activo`:e.jev.state===`fallback`?`usando flujo clásico`:`desactivado`]}):null,P&&(0,X.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,X.jsx)(Be,{className:`h-3.5 w-3.5 shrink-0 text-white/20`}),(0,X.jsx)(`span`,{className:`text-[11px] text-white/40 truncate font-mono`,children:P})]}),F&&(0,X.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,X.jsx)(Le,{className:`h-3.5 w-3.5 shrink-0 text-white/20`}),(0,X.jsxs)(`span`,{className:`text-[11px] text-white/40 font-mono`,children:[`ctx: `,(0,X.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,X.jsxs)(`div`,{className:`px-5 py-3 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,X.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:()=>c(!s),children:[s?(0,X.jsx)(Fe,{className:`h-3 w-3`}):(0,X.jsx)(Ie,{className:`h-3 w-3`}),`MODELOS`,(0,X.jsxs)(`span`,{className:`hive-tag scale-90 origin-left`,children:[C.length,`/`,S.length]})]}),w&&(0,X.jsx)(`span`,{className:`text-[9px] font-mono font-semibold rounded px-1.5 py-0.5 leading-none whitespace-nowrap border ${w.allFree?`text-emerald-400/80 bg-emerald-400/10 border-emerald-400/20`:`text-white/45 bg-white/5 border-white/10`}`,title:w.allFree?`Todos los modelos de este provider son gratuitos`:`Precio del modelo más barato, en USD por millón de tokens de entrada`,children:w.label}),F&&(0,X.jsxs)(X.Fragment,{children:[(0,X.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,X.jsx)(`button`,{type:`button`,onClick:O,disabled:l,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,X.jsx)(Ve,{className:`h-3 w-3 ${l?`animate-spin`:``}`})})]})]}),!s&&S.length>0&&(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:[S.slice(0,3).map(e=>(0,X.jsx)(`span`,{className:`hive-tag text-[10px] ${e.enabled||e.active?``:`opacity-40`}`,children:e.name.split(`/`).pop()||e.name},e.id)),S.length>3&&(0,X.jsxs)(`span`,{className:`hive-tag text-[10px] text-white/30`,children:[`+`,S.length-3]})]}),s&&(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsxs)(`div`,{className:`hive-scroll max-h-44 overflow-y-auto flex flex-col gap-0.5 pr-1`,children:[S.length===0&&(0,X.jsx)(`p`,{className:`text-[11px] text-white/25 py-2 text-center`,children:`Sin modelos configurados`}),S.map(e=>{let t=e.enabled||!!e.active;return(0,X.jsx)(`div`,{className:`rounded-lg transition-colors ${t?`bg-white/5`:`bg-transparent opacity-40`}`,children:(0,X.jsxs)(`div`,{className:`flex items-center justify-between px-2.5 py-1.5`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1 mr-2`,children:[(0,X.jsx)(`span`,{className:`block text-[11px] font-medium text-white truncate`,children:e.name}),(0,X.jsx)(Oe,{model:e,showContext:!0})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>m({model:e}),title:`Editar modelo — ID, contexto, costo y capacidades`,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,X.jsx)(He,{className:`h-3 w-3`})}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>j(e),disabled:d===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,X.jsx)(Ue,{className:`h-3 w-3`})}),(0,X.jsx)(fe,{checked:t,onCheckedChange:t=>D(e,t),className:`scale-[0.7] origin-right data-[state=checked]:bg-blue-400 ml-0.5`})]})]})},e.id)})]}),(0,X.jsxs)(`button`,{type:`button`,onClick:()=>m({}),className:`w-full mt-1.5 h-7 flex items-center justify-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 transition-colors`,children:[(0,X.jsx)(Re,{className:`h-3 w-3`}),`Agregar modelo`]})]})]}),(0,X.jsxs)(`div`,{className:`px-4 py-3 border-t border-white/5 flex items-center justify-between gap-2 overflow-hidden`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 overflow-hidden`,children:[(0,X.jsxs)(`div`,{className:`hive-stat shrink-0`,title:`Gasto acumulado en los últimos 30 días`,children:[(0,X.jsx)(`span`,{className:`hive-stat__label`,children:`Gasto 30d`}),(0,X.jsx)(`span`,{className:`hive-stat__value ${r&&r.costUsd>0?`text-amber-400`:`text-white/30`}`,children:r?xe(r.costUsd):`—`})]}),(0,X.jsxs)(`div`,{className:`hive-stat shrink-0`,title:`Tokens consumidos en los últimos 30 días`,children:[(0,X.jsx)(`span`,{className:`hive-stat__label`,children:`Tokens`}),(0,X.jsx)(`span`,{className:`hive-stat__value ${r&&r.tokens>0?`text-white/60`:`text-white/30`}`,children:r?Se(r.tokens):`—`})]}),(0,X.jsxs)(`div`,{className:`hive-stat shrink-0`,children:[(0,X.jsx)(`span`,{className:`hive-stat__label`,children:`Estado`}),(0,X.jsx)(`span`,{className:`hive-stat__value ${M?`text-emerald-400`:`text-white/30`}`,children:M?`Activo`:`Inactivo`})]})]}),(0,X.jsxs)(K,{open:a,onOpenChange:o,children:[(0,X.jsx)(H,{asChild:!0,children:(0,X.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,X.jsx)(Pe,{className:`h-3 w-3`}),(0,X.jsx)(`span`,{children:`CONFIG`})]})}),(0,X.jsxs)(W,{className:`rounded-xl border border-white/10 p-0 overflow-hidden w-[calc(100vw-2rem)] max-w-md bg-[#09090b]`,children:[(0,X.jsxs)(`div`,{className:`p-5 border-b border-white/5 bg-white/5 relative overflow-hidden`,children:[(0,X.jsx)(`div`,{className:`absolute -top-10 -right-10 h-32 w-32 bg-blue-600/10 rounded-full blur-[80px] pointer-events-none`}),(0,X.jsx)(G,{className:`text-lg font-black text-white uppercase tracking-tighter`,children:e.name}),(0,X.jsx)(U,{className:`text-xs text-white/40 font-medium mt-0.5`,children:`Autenticación y punto de enlace.`})]}),(0,X.jsx)(`div`,{className:`p-5`,children:(0,X.jsx)(Ce,{provider:e,onSave:T,onCancel:()=>o(!1)})})]})]})]}),(0,X.jsx)(Ne,{open:p!==null,onOpenChange:e=>{e||m(null)},providerId:e.id,model:p?.model,onSubmit:k,onOpenGuide:i,isFreeProvider:w?.allFree??!1}),(0,X.jsx)(`div`,{className:`hive-strip--bottom ${M?``:`opacity-20`}`})]})}function Ge(e){let t=(0,J.c)(24),{onOpenGuide:n}=e,{providers:r,updateProvider:i}=N(),a=be(),o,s,c,l,u;if(t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a){u=r.filter(qe);let e=u.filter(Ke).length;c=`space-y-4`;let d;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,X.jsx)(`h3`,{className:`hive-title-section`,children:`Providers de IA`}),t[9]=d):d=t[9],l=(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[d,(0,X.jsxs)(`span`,{className:`hive-tag hive-tag--provider`,children:[e,` activos / `,u.length,` total`]})]}),o=`grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 gap-4 sm:gap-5`;let f;t[10]!==n||t[11]!==i||t[12]!==a?(f=e=>(0,X.jsx)(We,{provider:e,updateProvider:i,usage:a?.[e.id],onOpenGuide:n},e.id),t[10]=n,t[11]=i,t[12]=a,t[13]=f):f=t[13],s=u.map(f),t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u}else o=t[4],s=t[5],c=t[6],l=t[7],u=t[8];let d;t[14]===u.length?d=t[15]:(d=u.length===0&&(0,X.jsx)(`div`,{className:`hive-empty-state col-span-full`,children:`No hay providers disponibles.`}),t[14]=u.length,t[15]=d);let f;t[16]!==o||t[17]!==s||t[18]!==d?(f=(0,X.jsxs)(`div`,{className:o,children:[s,d]}),t[16]=o,t[17]=s,t[18]=d,t[19]=f):f=t[19];let p;return t[20]!==c||t[21]!==l||t[22]!==f?(p=(0,X.jsxs)(`div`,{className:c,children:[l,f]}),t[20]=c,t[21]=l,t[22]=f,t[23]=p):p=t[23],p}function Ke(e){return e.active}function qe(e){return(e.category??`llm`)===`llm`}function Je(e){let t=(0,J.c)(69),{onSave:n,onCancel:r}=e,[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(``),[c,l]=(0,Y.useState)(``),[u,p]=(0,Y.useState)(``),[m,h]=(0,Y.useState)(``),[g,_]=(0,Y.useState)(``),[v,y]=(0,Y.useState)(``),b;t[0]!==m||t[1]!==c?(b=c.toLowerCase()===`ollama`||m.includes(`localhost`)||m.includes(`127.0.0.1`),t[0]=m,t[1]=c,t[2]=b):b=t[2];let x=b,S;t[3]!==u||t[4]!==m||t[5]!==g||t[6]!==x||t[7]!==o||t[8]!==v||t[9]!==n||t[10]!==c?(S=()=>{if(!o.trim()){j.fire(`Error`,`El nombre del provider es requerido`,`error`);return}if(!c){j.fire(`Error`,`Selecciona un tipo de provider`,`error`);return}if(!u.trim()&&!x){j.fire(`Error`,`La API Key es requerida para este provider`,`error`);return}let e;if(g.trim())try{e=JSON.parse(g.trim())}catch{j.fire(`Error`,`JSON de Headers inválido`,`error`);return}n({id:o.trim().toLowerCase().replace(/\s+/g,`-`),name:o.trim(),type:c,apiKey:u.trim()||``,baseUrl:m.trim()||void 0,headers:e,numCtx:v.trim()?Number(v.trim()):null})},t[3]=u,t[4]=m,t[5]=g,t[6]=x,t[7]=o,t[8]=v,t[9]=n,t[10]=c,t[11]=S):S=t[11];let C=S,w;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,X.jsx)(se,{className:`hive-label`,children:`Nombre del Provider`}),t[12]=w):w=t[12];let T;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(T=e=>s(e.target.value),t[13]=T):T=t[13];let E;t[14]===o?E=t[15]:(E=(0,X.jsx)(I,{value:o,onChange:T,placeholder:`Mi Provider Personalizado`,className:`hive-input !h-8 text-xs`}),t[14]=o,t[15]=E);let D;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,X.jsx)(`p`,{className:`text-[10px] text-white/30`,children:`Se usará como identificador interno`}),t[16]=D):D=t[16];let O;t[17]===E?O=t[18]:(O=(0,X.jsxs)(`div`,{className:`space-y-1`,children:[w,E,D]}),t[17]=E,t[18]=O);let k;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,X.jsx)(se,{className:`hive-label`,children:`Tipo de Provider`}),t[19]=k):k=t[19];let A;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(A=e=>l(e.target.value),t[20]=A):A=t[20];let M;t[21]===c?M=t[22]:(M=(0,X.jsx)(I,{value:c,onChange:A,placeholder:`openai, anthropic, ollama...`,className:`hive-input !h-8 text-xs`}),t[21]=c,t[22]=M);let N;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,X.jsx)(`p`,{className:`text-[10px] text-white/30`,children:`Ej: openai, anthropic, ollama, custom...`}),t[23]=N):N=t[23];let P;t[24]===M?P=t[25]:(P=(0,X.jsxs)(`div`,{className:`space-y-1`,children:[k,M,N]}),t[24]=M,t[25]=P);let F;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,X.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,X.jsx)(se,{className:`hive-label`,children:`API Key`})}),t[26]=F):F=t[26];let L=i?`text`:`password`,ee;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(ee=e=>p(e.target.value),t[27]=ee):ee=t[27];let te=x?`Opcional para providers locales`:`sk-...`,ne;t[28]!==u||t[29]!==L||t[30]!==te?(ne=(0,X.jsx)(I,{type:L,value:u,onChange:ee,placeholder:te,className:`hive-input !h-8 text-xs pr-8`}),t[28]=u,t[29]=L,t[30]=te,t[31]=ne):ne=t[31];let R;t[32]===i?R=t[33]:(R=()=>a(!i),t[32]=i,t[33]=R);let z;t[34]===i?z=t[35]:(z=i?(0,X.jsx)(d,{className:`h-3 w-3`}):(0,X.jsx)(f,{className:`h-3 w-3`}),t[34]=i,t[35]=z);let re;t[36]!==R||t[37]!==z?(re=(0,X.jsx)(`button`,{type:`button`,onClick:R,className:`absolute right-0 top-0 h-8 w-8 flex items-center justify-center text-white/40 hover:text-white`,children:z}),t[36]=R,t[37]=z,t[38]=re):re=t[38];let B;t[39]!==ne||t[40]!==re?(B=(0,X.jsxs)(`div`,{className:`space-y-1`,children:[F,(0,X.jsxs)(`div`,{className:`relative`,children:[ne,re]})]}),t[39]=ne,t[40]=re,t[41]=B):B=t[41];let V;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,X.jsx)(se,{className:`hive-label`,children:`Base URL (opcional)`}),t[42]=V):V=t[42];let ie;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(ie=e=>h(e.target.value),t[43]=ie):ie=t[43];let ae;t[44]===m?ae=t[45]:(ae=(0,X.jsxs)(`div`,{className:`space-y-1`,children:[V,(0,X.jsx)(I,{value:m,onChange:ie,placeholder:`https://api.example.com o http://localhost:11434`,className:`hive-input !h-8 text-xs`})]}),t[44]=m,t[45]=ae);let H;t[46]!==x||t[47]!==v?(H=x&&(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(se,{className:`hive-label`,children:`Context Window (num_ctx)`}),(0,X.jsx)(`span`,{className:`text-[10px] text-white/30`,children:`tokens — por defecto 32 768`})]}),(0,X.jsx)(I,{type:`number`,value:v,onChange:e=>y(e.target.value),placeholder:`32768`,min:512,step:512,className:`hive-input !h-8 text-xs font-mono`}),(0,X.jsx)(`p`,{className:`text-[10px] text-amber-400/60`,children:`Aumenta si ves errores de contexto.`})]}),t[46]=x,t[47]=v,t[48]=H):H=t[48];let U;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,X.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,X.jsx)(se,{className:`hive-label`,children:`Custom Headers (JSON)`})}),t[49]=U):U=t[49];let oe;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(oe=e=>_(e.target.value),t[50]=oe):oe=t[50];let W;t[51]===g?W=t[52]:(W=(0,X.jsxs)(`div`,{className:`space-y-1`,children:[U,(0,X.jsx)(`textarea`,{value:g,onChange:oe,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`})]}),t[51]=g,t[52]=W);let G;t[53]===r?G=t[54]:(G=(0,X.jsx)(`button`,{className:`hive-btn hive-btn--form-cancel flex-1`,onClick:r,children:`Cancelar`}),t[53]=r,t[54]=G);let K;t[55]===C?K=t[56]:(K=(0,X.jsx)(`button`,{className:`hive-btn hive-btn--form-submit flex-1`,onClick:C,children:`Crear Provider`}),t[55]=C,t[56]=K);let q;t[57]!==G||t[58]!==K?(q=(0,X.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[G,K]}),t[57]=G,t[58]=K,t[59]=q):q=t[59];let ce;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,X.jsx)(`p`,{className:`text-[10px] text-white/20 pt-2`,children:`La API key se guarda cifrada en la base de datos.`}),t[60]=ce):ce=t[60];let le;return t[61]!==P||t[62]!==B||t[63]!==ae||t[64]!==H||t[65]!==W||t[66]!==q||t[67]!==O?(le=(0,X.jsxs)(`div`,{className:`space-y-3`,children:[O,P,B,ae,H,W,q,ce]}),t[61]=P,t[62]=B,t[63]=ae,t[64]=H,t[65]=W,t[66]=q,t[67]=O,t[68]=le):le=t[68],le}var Ye={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 Xe(e){let t=(0,J.c)(8),{capabilities:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=[],t[0]=r):r=t[0];let i=r;if(typeof n==`string`)try{let e;t[1]===n?e=t[2]:(e=JSON.parse(n),t[1]=n,t[2]=e),i=e}catch{let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[3]=e):e=t[3],i=e}else Array.isArray(n)&&(i=n);if(i.length===0)return null;let a;t[4]===i?a=t[5]:(a=i.map(Ze),t[4]=i,t[5]=a);let o;return t[6]===a?o=t[7]:(o=(0,X.jsx)(X.Fragment,{children:a}),t[6]=a,t[7]=o),o}function Ze(e){return(0,X.jsx)(z,{variant:`outline`,className:`text-[10px] py-0 h-4`,children:Ye[e]??e},e)}function Qe(e){let t=(0,J.c)(33),{model:n}=e,{toggleModel:r}=A(),i=n.active?``:`opacity-70 bg-muted/30`,a;t[0]===n.name?a=t[1]:(a=(0,X.jsx)(`p`,{className:`text-sm font-semibold`,children:n.name}),t[0]=n.name,t[1]=a);let o=n.providerId||n.provider_id,s;t[2]===o?s=t[3]:(s=(0,X.jsx)(z,{variant:`secondary`,className:`text-[10px]`,children:o}),t[2]=o,t[3]=s);let c;t[4]!==a||t[5]!==s?(c=(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[a,s]}),t[4]=a,t[5]=s,t[6]=c):c=t[6];let l;t[7]===n?l=t[8]:(l=(0,X.jsx)(Oe,{model:n,showContext:!0}),t[7]=n,t[8]=l);let u;t[9]===n.capabilities?u=t[10]:(u=(0,X.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 pt-1`,children:(0,X.jsx)(Xe,{capabilities:n.capabilities})}),t[9]=n.capabilities,t[10]=u);let d;t[11]!==c||t[12]!==l||t[13]!==u?(d=(0,X.jsxs)(`div`,{className:`flex-1 space-y-1`,children:[c,l,u]}),t[11]=c,t[12]=l,t[13]=u,t[14]=d):d=t[14];let f=!!n.active,p;t[15]!==n.id||t[16]!==r?(p=e=>r(n.id,e),t[15]=n.id,t[16]=r,t[17]=p):p=t[17];let m;t[18]!==p||t[19]!==f?(m=(0,X.jsx)(fe,{checked:f,onCheckedChange:p}),t[18]=p,t[19]=f,t[20]=m):m=t[20];let h=n.active?`default`:`secondary`,g=n.active?`Activo`:`Inactivo`,_;t[21]!==h||t[22]!==g?(_=(0,X.jsx)(z,{variant:h,className:`text-[10px]`,children:g}),t[21]=h,t[22]=g,t[23]=_):_=t[23];let v;t[24]!==m||t[25]!==_?(v=(0,X.jsxs)(`div`,{className:`flex flex-col items-end gap-2`,children:[m,_]}),t[24]=m,t[25]=_,t[26]=v):v=t[26];let y;t[27]!==v||t[28]!==d?(y=(0,X.jsxs)(he,{className:`flex items-center gap-4 p-3`,children:[d,v]}),t[27]=v,t[28]=d,t[29]=y):y=t[29];let b;return t[30]!==i||t[31]!==y?(b=(0,X.jsx)(_e,{className:i,children:y}),t[30]=i,t[31]=y,t[32]=b):b=t[32],b}function $e(e){if(!e)return[];if(typeof e==`string`)try{return JSON.parse(e)}catch{return[]}return Array.isArray(e)?e:[]}function et(){let e=(0,J.c)(41),{availableModels:t,activeProviders:n}=N(),r=R(rt),[i,a]=(0,Y.useState)(``),[o,s]=(0,Y.useState)(`all`),c,l;e[0]===r?(c=e[1],l=e[2]):(c=()=>{r(!0)},l=[r],e[0]=r,e[1]=c,e[2]=l),(0,Y.useEffect)(c,l);let u;if(e[3]!==t||e[4]!==i||e[5]!==o){let n;e[7]!==i||e[8]!==o?(n=e=>{let t=$e(e.capabilities),n=t.includes(`vision`)||t.includes(`image_generation`)||t.includes(`ocr`),r=e.name.toLowerCase().includes(i.toLowerCase())||e.id.toLowerCase().includes(i.toLowerCase()),a=o===`all`||e.providerId===o||e.provider_id===o;return n&&r&&a},e[7]=i,e[8]=o,e[9]=n):n=e[9],u=t.filter(n),e[3]=t,e[4]=i,e[5]=o,e[6]=u}else u=e[6];let d=u,p;e[10]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,X.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Modelos de Imagen / Vision`})}),e[10]=p):p=e[10];let m;e[11]===d.length?m=e[12]:(m=(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[p,(0,X.jsx)(z,{variant:`secondary`,children:d.length})]}),e[11]=d.length,e[12]=m);let h;e[13]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,X.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.`}),e[13]=h):h=e[13];let g;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,X.jsx)(S,{className:`absolute left-2 top-2 h-4 w-4 text-muted-foreground`}),e[14]=g):g=e[14];let _;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(_=e=>a(e.target.value),e[15]=_):_=e[15];let v;e[16]===i?v=e[17]:(v=(0,X.jsxs)(`div`,{className:`relative flex-1`,children:[g,(0,X.jsx)(I,{placeholder:`Buscar modelo...`,className:`h-8 pl-8 text-sm`,value:i,onChange:_})]}),e[16]=i,e[17]=v);let y;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,X.jsx)(le,{className:`h-8 w-40 text-sm`,children:(0,X.jsx)(ue,{placeholder:`Provider`})}),e[18]=y):y=e[18];let b;e[19]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,X.jsx)(q,{value:`all`,children:`Todos`}),e[19]=b):b=e[19];let x;e[20]===n?x=e[21]:(x=n.map(nt),e[20]=n,e[21]=x);let C;e[22]===x?C=e[23]:(C=(0,X.jsxs)(ce,{children:[b,x]}),e[22]=x,e[23]=C);let w;e[24]!==o||e[25]!==C?(w=(0,X.jsxs)(de,{value:o,onValueChange:s,children:[y,C]}),e[24]=o,e[25]=C,e[26]=w):w=e[26];let T;e[27]!==w||e[28]!==v?(T=(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[v,w]}),e[27]=w,e[28]=v,e[29]=T):T=e[29];let E;e[30]===d?E=e[31]:(E=d.map(tt),e[30]=d,e[31]=E);let D;e[32]===d.length?D=e[33]:(D=d.length===0&&(0,X.jsxs)(`div`,{className:`hive-empty-state`,children:[(0,X.jsx)(f,{className:`h-8 w-8 mx-auto mb-2 text-muted-foreground`}),(0,X.jsx)(`p`,{children:`No hay modelos con capacidad de vision.`}),(0,X.jsx)(`p`,{className:`text-xs mt-1`,children:`Habilita modelos con capability "vision" en la tab Providers.`})]}),e[32]=d.length,e[33]=D);let O;e[34]!==E||e[35]!==D?(O=(0,X.jsx)(re,{className:`h-[calc(100vh-26rem)]`,children:(0,X.jsxs)(`div`,{className:`space-y-2`,children:[E,D]})}),e[34]=E,e[35]=D,e[36]=O):O=e[36];let k;return e[37]!==T||e[38]!==O||e[39]!==m?(k=(0,X.jsxs)(`div`,{className:`space-y-4`,children:[m,h,T,O]}),e[37]=T,e[38]=O,e[39]=m,e[40]=k):k=e[40],k}function tt(e){return(0,X.jsx)(Qe,{model:e},e.id)}function nt(e){return(0,X.jsx)(q,{value:e.id,children:e.name},e.id)}function rt(e){return e.fetchAll}var it=Y.forwardRef((e,t)=>{let n=(0,J.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=k(`w-full caption-bottom text-sm`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,X.jsx)(`div`,{className:`relative w-full overflow-auto`,children:(0,X.jsx)(`table`,{ref:t,className:a,...i})}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});it.displayName=`Table`;var at=Y.forwardRef((e,t)=>{let n=(0,J.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=k(`[&_tr]:border-b`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,X.jsx)(`thead`,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});at.displayName=`TableHeader`;var ot=Y.forwardRef((e,t)=>{let n=(0,J.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=k(`[&_tr:last-child]:border-0`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,X.jsx)(`tbody`,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});ot.displayName=`TableBody`;var st=Y.forwardRef((e,t)=>{let n=(0,J.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=k(`border-t bg-muted/50 font-medium [&>tr]:last:border-b-0`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,X.jsx)(`tfoot`,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});st.displayName=`TableFooter`;var ct=Y.forwardRef((e,t)=>{let n=(0,J.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=k(`border-b transition-colors data-[state=selected]:bg-muted hover:bg-muted/50`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,X.jsx)(`tr`,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});ct.displayName=`TableRow`;var lt=Y.forwardRef((e,t)=>{let n=(0,J.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=k(`h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,X.jsx)(`th`,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});lt.displayName=`TableHead`;var ut=Y.forwardRef((e,t)=>{let n=(0,J.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=k(`p-4 align-middle [&:has([role=checkbox])]:pr-0`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,X.jsx)(`td`,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});ut.displayName=`TableCell`;var dt=Y.forwardRef((e,t)=>{let n=(0,J.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=k(`mt-4 text-sm text-muted-foreground`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,X.jsx)(`caption`,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});dt.displayName=`TableCaption`;function ft(e){let t=(0,J.c)(40),{open:n,onOpenChange:r}=e,{availableTTSModels:i,fetchAvailableTTSModels:o,downloadTTSModel:s,isDownloadingModel:c,downloadLogs:l}=P(),[d,f]=(0,Y.useState)(!1),p;t[0]===o?p=t[1]:(p=async()=>{f(!0),await o(),f(!1)},t[0]=o,t[1]=p);let m=p,h;t[2]!==m||t[3]!==n?(h=()=>{n&&m()},t[2]=m,t[3]=n,t[4]=h):h=t[4];let g;t[5]===n?g=t[6]:(g=[n],t[5]=n,t[6]=g),(0,Y.useEffect)(h,g);let _;t[7]===s?_=t[8]:(_=async e=>{await s(e)},t[7]=s,t[8]=_);let v=_,y=ht,b;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,X.jsxs)(oe,{children:[(0,X.jsx)(G,{className:`flex items-center gap-2`,children:`📦 Gestionar Modelos TTS`}),(0,X.jsx)(U,{children:`Descarga modelos de voz adicionales para Piper TTS. Cada modelo incluye el archivo de voz (.onnx) y su configuración (.json).`})]}),t[9]=b):b=t[9];let S;t[10]===i?S=t[11]:(S=i.filter(mt),t[10]=i,t[11]=S);let C;t[12]!==i.length||t[13]!==S.length?(C=(0,X.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,X.jsxs)(z,{variant:`outline`,children:[S.length,` / `,i.length,` instalados`]})}),t[12]=i.length,t[13]=S.length,t[14]=C):C=t[14];let w=d||c,T=`h-4 w-4 ${d?`animate-spin`:``}`,E;t[15]===T?E=t[16]:(E=(0,X.jsx)(x,{className:T}),t[15]=T,t[16]=E);let D;t[17]!==m||t[18]!==E||t[19]!==w?(D=(0,X.jsxs)(F,{size:`sm`,variant:`ghost`,onClick:m,disabled:w,className:`gap-2`,children:[E,`Actualizar`]}),t[17]=m,t[18]=E,t[19]=w,t[20]=D):D=t[20];let O;t[21]!==D||t[22]!==C?(O=(0,X.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[C,D]}),t[21]=D,t[22]=C,t[23]=O):O=t[23];let k;t[24]!==i||t[25]!==l||t[26]!==v||t[27]!==c||t[28]!==d?(k=d&&!i.length?(0,X.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,X.jsx)(L,{className:`h-6 w-6 animate-spin text-muted-foreground`})}):i.length===0?(0,X.jsx)(`div`,{className:`text-center py-8 text-muted-foreground`,children:`No hay modelos disponibles`}):(0,X.jsxs)(it,{children:[(0,X.jsx)(at,{children:(0,X.jsxs)(ct,{children:[(0,X.jsx)(lt,{children:`Modelo`}),(0,X.jsx)(lt,{children:`Idioma`}),(0,X.jsx)(lt,{children:`Calidad`}),(0,X.jsx)(lt,{children:`Tamaño`}),(0,X.jsx)(lt,{children:`Estado`}),(0,X.jsx)(lt,{className:`text-right`,children:`Acciones`})]})}),(0,X.jsx)(ot,{children:i.map(e=>(0,X.jsxs)(ct,{children:[(0,X.jsx)(ut,{className:`font-medium`,children:e.name}),(0,X.jsx)(ut,{children:e.language}),(0,X.jsx)(ut,{children:(0,X.jsx)(z,{className:y(e.quality),children:e.quality})}),(0,X.jsx)(ut,{className:`text-muted-foreground`,children:e.size}),(0,X.jsx)(ut,{children:e.installed?(0,X.jsxs)(z,{className:`bg-green-500/20 text-green-400 border-green-500/30 gap-1`,children:[(0,X.jsx)(a,{className:`h-3 w-3`}),`Instalado`]}):c&&l.some(t=>t.includes(e.name))?(0,X.jsxs)(z,{className:`bg-blue-500/20 text-blue-400 border-blue-500/30 gap-1`,children:[(0,X.jsx)(L,{className:`h-3 w-3 animate-spin`}),`Descargando`]}):(0,X.jsx)(z,{variant:`secondary`,className:`bg-zinc-700/50 text-zinc-400`,children:`No instalado`})}),(0,X.jsx)(ut,{className:`text-right`,children:e.installed?(0,X.jsxs)(F,{size:`sm`,variant:`ghost`,disabled:!0,className:`gap-2 opacity-50`,children:[(0,X.jsx)(a,{className:`h-4 w-4`}),`Instalado`]}):(0,X.jsxs)(F,{size:`sm`,onClick:()=>v(e.id),disabled:c,className:`gap-2`,children:[(0,X.jsx)(u,{className:`h-4 w-4`}),`Descargar`]})})]},e.id))})]}),t[24]=i,t[25]=l,t[26]=v,t[27]=c,t[28]=d,t[29]=k):k=t[29];let A;t[30]===l?A=t[31]:(A=l.length>0&&(0,X.jsxs)(`div`,{className:`mt-4`,children:[(0,X.jsx)(`div`,{className:`text-sm font-medium mb-2`,children:`Progreso de descarga:`}),(0,X.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:l.map(pt)})]}),t[30]=l,t[31]=A);let j;t[32]!==O||t[33]!==k||t[34]!==A?(j=(0,X.jsxs)(W,{className:`max-w-3xl max-h-[80vh] overflow-hidden flex flex-col`,children:[b,(0,X.jsxs)(`div`,{className:`flex-1 overflow-auto mt-4`,children:[O,k,A]})]}),t[32]=O,t[33]=k,t[34]=A,t[35]=j):j=t[35];let M;return t[36]!==r||t[37]!==n||t[38]!==j?(M=(0,X.jsx)(K,{open:n,onOpenChange:r,children:j}),t[36]=r,t[37]=n,t[38]=j,t[39]=M):M=t[39],M}function pt(e,t){return(0,X.jsx)(`div`,{className:e.startsWith(`[error]`)?`text-red-400`:e.startsWith(`✓`)?`text-green-400`:``,children:e},t)}function mt(e){return e.installed}function ht(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`}}function gt(){let{localTTS:e,fetchLocalTTSStatus:t,installLocalTTS:n,startLocalTTS:r,stopLocalTTS:i}=P(),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),[l,d]=(0,Y.useState)([]),[f,p]=(0,Y.useState)(``),[m,h]=(0,Y.useState)(!1),g=(0,Y.useRef)(null),_=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{t()},[t]),(0,Y.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,Y.useEffect)(()=>{_.current&&(_.current.scrollTop=_.current.scrollHeight)},[l]);let v=async()=>{try{let e=await M(`/api/tts-local/logs`);d(e.logs),p(e.ttsRoot)}catch{}},b=async()=>{o(!0),c(!0);try{await n(),await v()}finally{o(!1)}},S=async()=>{o(!0);try{await r()}finally{o(!1)}},C=async()=>{o(!0);try{await i()}finally{o(!1)}},E=async()=>{c(e=>!e),s||await v()},{installed:k,running:A,piperExists:j,voiceExists:N,port:I}=e,L=e.installing;return(0,X.jsxs)(_e,{className:`relative overflow-hidden col-span-full ${A?`border-blue-500/30 bg-blue-500/[0.02]`:``}`,children:[(0,X.jsx)(me,{children:(0,X.jsxs)(`div`,{className:`flex items-start justify-between flex-wrap gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`text-3xl`,children:`🎙️`}),(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(pe,{className:`text-lg flex items-center gap-2`,children:[`Piper TTS`,(0,X.jsx)(z,{variant:`outline`,className:`text-[10px] px-1.5 py-0 font-normal border-zinc-600 text-zinc-400`,children:`Local · Offline`})]}),(0,X.jsx)(ge,{className:`text-xs`,children:`TTS sin internet — binario nativo, sin Python, sin Docker. Fallback cuando no hay providers online.`})]})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[L?(0,X.jsxs)(z,{className:`bg-yellow-500/20 text-yellow-400 border-yellow-500/30 gap-1`,children:[(0,X.jsx)(x,{className:`h-3 w-3 animate-spin`}),`Instalando…`]}):k?(0,X.jsx)(z,{className:`bg-green-500/20 text-green-400 border-green-500/30`,children:`Instalado`}):(0,X.jsx)(z,{variant:`secondary`,className:`bg-zinc-700/50 text-zinc-400`,children:`No instalado`}),k&&(A?(0,X.jsxs)(z,{className:`bg-blue-500/20 text-blue-400 border-blue-500/30 gap-1`,children:[(0,X.jsx)(O,{className:`h-3 w-3`}),`Servidor :`,I]}):(0,X.jsxs)(z,{variant:`secondary`,className:`bg-zinc-700/50 text-zinc-400 gap-1`,children:[(0,X.jsx)(D,{className:`h-3 w-3`}),`Detenido`]}))]})]})}),(0,X.jsxs)(he,{className:`space-y-4`,children:[!k&&!L&&(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-xs text-muted-foreground`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 ${j?`text-green-400`:``}`,children:[(0,X.jsx)(`span`,{children:j?`✓`:`○`}),` Binario Piper (~8 MB)`]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 ${N?`text-green-400`:``}`,children:[(0,X.jsx)(`span`,{children:N?`✓`:`○`}),` Voz española (~60 MB)`]})]}),k&&(0,X.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Voz: `,(0,X.jsx)(`code`,{className:`text-zinc-300`,children:e.voices?.[0]||`N/A`}),` · Puerto:`,` `,(0,X.jsx)(`code`,{className:`text-zinc-300`,children:I}),` · Configurable con`,` `,(0,X.jsx)(`code`,{className:`text-zinc-300`,children:`TTS_PORT`}),` / `,(0,X.jsx)(`code`,{className:`text-zinc-300`,children:`TTS_VOICE`})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[!k&&!L&&(0,X.jsxs)(F,{size:`sm`,onClick:b,disabled:a,className:`gap-2`,children:[(0,X.jsx)(u,{className:`h-3.5 w-3.5`}),`Instalar Piper (~68 MB)`]}),L&&(0,X.jsxs)(F,{size:`sm`,disabled:!0,className:`gap-2 opacity-70`,children:[(0,X.jsx)(x,{className:`h-3.5 w-3.5 animate-spin`}),`Descargando…`]}),k&&!A&&(0,X.jsxs)(F,{size:`sm`,onClick:S,disabled:a,className:`gap-2 bg-blue-600 hover:bg-blue-500 text-white`,children:[(0,X.jsx)(y,{className:`h-3.5 w-3.5`}),`Iniciar servidor`]}),A&&(0,X.jsxs)(F,{size:`sm`,variant:`outline`,onClick:C,disabled:a,className:`gap-2 border-red-500/40 text-red-400 hover:bg-red-500/10`,children:[(0,X.jsx)(w,{className:`h-3.5 w-3.5`}),`Detener servidor`]}),k&&(0,X.jsxs)(F,{size:`sm`,variant:`outline`,onClick:()=>h(!0),disabled:a,className:`gap-2`,children:[(0,X.jsx)(ye,{className:`h-3.5 w-3.5`}),`Gestionar modelos`,e.voices&&e.voices.length>0&&(0,X.jsx)(z,{variant:`secondary`,className:`ml-1 text-[10px] px-1`,children:e.voices.length})]}),(0,X.jsx)(F,{size:`sm`,variant:`ghost`,onClick:()=>t(),title:`Actualizar estado`,className:`text-zinc-400`,children:(0,X.jsx)(x,{className:`h-3.5 w-3.5`})}),(0,X.jsxs)(F,{size:`sm`,variant:`ghost`,onClick:E,className:`gap-1.5 text-zinc-400 text-xs`,children:[(0,X.jsx)(T,{className:`h-3.5 w-3.5`}),s?`Ocultar log`:`Ver log`]})]}),L&&(0,X.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,X.jsxs)(`div`,{className:`space-y-1`,children:[f&&(0,X.jsxs)(`p`,{className:`text-[10px] text-zinc-500 font-mono`,children:[`ruta: `,f]}),(0,X.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,X.jsx)(`span`,{className:`text-zinc-600`,children:`Sin registros aún. Inicia la instalación para ver el progreso.`}):l.map((e,t)=>(0,X.jsx)(`div`,{className:e.startsWith(`[stderr]`)||e.startsWith(`[error]`)?`text-red-400`:``,children:e},t))})]}),(0,X.jsx)(ft,{open:m,onOpenChange:h})]})]})}var _t={groq:{logo:`🔴`,consoleUrl:`https://console.groq.com/keys`},elevenlabs:{logo:`🎙️`,consoleUrl:`https://elevenlabs.io/app/settings/api-keys`},openai:{logo:`🟢`,consoleUrl:`https://platform.openai.com/api-keys`},gemini:{logo:`🔵`,consoleUrl:`https://aistudio.google.com/app/apikey`},qwen:{logo:`🟣`,consoleUrl:`https://dashscope.console.aliyun.com/apiKey`},piper:{logo:`🖥️`}};function vt(){let{providers:e,availableModels:t,activeProviders:n}=N(),{voiceProviders:r,configuredVoiceProviders:i,fetchVoiceProviders:o,fetchConfiguredVoiceProviders:s,saveVoiceProviderKey:c}=te(),l=R(e=>e.fetchAll),[u,d]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(``),[v,y]=(0,Y.useState)(!1),[b,x]=(0,Y.useState)(!1),[C,w]=(0,Y.useState)(``),[T,E]=(0,Y.useState)(`all`);(0,Y.useEffect)(()=>{o(),s(),l(!0)},[o,s,l]);let D=async e=>{if(f.trim()){y(!0);try{await c(e,f.trim()),await s(),d(null),p(``)}catch(e){console.error(`Failed to save API key:`,e)}finally{y(!1)}}},O=t=>{let n=e.find(e=>e.id===t),r=(n?.models||[]).filter(e=>e.model_type===`stt`||e.model_type===`tts`),i=r.some(e=>e.model_type===`stt`),a=r.some(e=>e.model_type===`tts`),o=r.some(e=>$e(e.capabilities).includes(`local`)),s=_t[t]||{logo:`🔌`};return{name:n?.name||t,description:[i&&`STT (Speech-to-Text)`,a&&`TTS (Text-to-Speech)`].filter(Boolean).join(` / `),logo:s.logo,consoleUrl:s.consoleUrl,noApiKey:o}},k=r.filter(e=>!O(e).noApiKey),A=(0,Y.useMemo)(()=>t.filter(e=>{let t=e.model_type===`stt`||e.model_type===`tts`,n=$e(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}),[t,C,T]);return(0,X.jsxs)(`div`,{className:`space-y-6`,children:[(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Modelos de Voz (STT / TTS)`}),(0,X.jsx)(z,{variant:`secondary`,children:A.length})]}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsxs)(`div`,{className:`relative flex-1`,children:[(0,X.jsx)(S,{className:`absolute left-2 top-2 h-4 w-4 text-muted-foreground`}),(0,X.jsx)(I,{placeholder:`Buscar modelo...`,className:`h-8 pl-8 text-sm`,value:C,onChange:e=>w(e.target.value)})]}),(0,X.jsxs)(de,{value:T,onValueChange:E,children:[(0,X.jsx)(le,{className:`h-8 w-40 text-sm`,children:(0,X.jsx)(ue,{placeholder:`Provider`})}),(0,X.jsxs)(ce,{children:[(0,X.jsx)(q,{value:`all`,children:`Todos`}),n.map(e=>(0,X.jsx)(q,{value:e.id,children:e.name},e.id))]})]})]}),(0,X.jsx)(re,{className:`h-60`,children:(0,X.jsxs)(`div`,{className:`space-y-2`,children:[A.map(e=>(0,X.jsx)(Qe,{model:e},e.id)),A.length===0&&(0,X.jsxs)(`div`,{className:`hive-empty-state`,children:[(0,X.jsx)(_,{className:`h-8 w-8 mx-auto mb-2 text-muted-foreground`}),(0,X.jsx)(`p`,{children:`No hay modelos de voz disponibles.`})]})]})})]}),(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:`API Keys de Voz`}),(0,X.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,X.jsx)(gt,{}),k.map(e=>{let t=O(e),n=i[e]===!0,r=u===e;return(0,X.jsxs)(_e,{className:`relative overflow-hidden ${n?`border-green-500/30 bg-green-500/[0.02]`:``}`,children:[(0,X.jsx)(me,{children:(0,X.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`text-3xl`,children:t.logo}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(pe,{className:`text-lg`,children:t.name}),(0,X.jsx)(ge,{className:`text-xs`,children:t.description})]})]}),t.noApiKey?(0,X.jsx)(z,{variant:`outline`,className:`bg-zinc-700/40 text-zinc-300 border-zinc-600`,children:`Sin API key`}):n?(0,X.jsxs)(z,{variant:`default`,className:`bg-green-500/20 text-green-400 border-green-500/30`,children:[(0,X.jsx)(a,{className:`h-3 w-3 mr-1`}),`Configurado`]}):(0,X.jsx)(z,{variant:`secondary`,className:`bg-yellow-500/20 text-yellow-400 border-yellow-500/30`,children:`Sin configurar`})]})}),(0,X.jsx)(he,{className:`space-y-4`,children:t.noApiKey?(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t.description}):r?(0,X.jsxs)(`div`,{className:`space-y-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(se,{htmlFor:`api-key-${e}`,children:`API Key`}),(0,X.jsxs)(`div`,{className:`flex gap-2 mt-1`,children:[(0,X.jsx)(I,{id:`api-key-${e}`,type:b?`text`:`password`,placeholder:`sk-...`,value:f,onChange:e=>p(e.target.value),className:`flex-1 font-mono text-sm`,autoFocus:!0}),(0,X.jsx)(F,{variant:`outline`,size:`icon`,onClick:()=>x(!b),title:b?`Ocultar`:`Mostrar`,children:b?(0,X.jsx)(g,{className:`h-4 w-4`}):(0,X.jsx)(h,{className:`h-4 w-4`})})]})]}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(F,{size:`sm`,onClick:()=>D(e),disabled:v||!f.trim(),className:`flex-1`,children:v?`Guardando...`:`Guardar`}),(0,X.jsx)(F,{size:`sm`,variant:`outline`,onClick:()=>{d(null),p(``)},children:`Cancelar`})]})]}):(0,X.jsxs)(`div`,{className:`space-y-3`,children:[n?(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,X.jsx)(m,{className:`h-4 w-4`}),(0,X.jsx)(`span`,{children:`API key guardada de forma segura (encriptada)`})]}):(0,X.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Necesitas una API key de `,t.name,` para usar esta funcionalidad.`]}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[n?(0,X.jsxs)(F,{size:`sm`,variant:`outline`,onClick:()=>{d(e),p(``)},className:`flex-1`,children:[(0,X.jsx)(m,{className:`h-3 w-3 mr-2`}),`Actualizar API Key`]}):(0,X.jsxs)(F,{size:`sm`,onClick:()=>{d(e),p(``)},className:`flex-1`,children:[(0,X.jsx)(m,{className:`h-3 w-3 mr-2`}),`Configurar API Key`]}),t.consoleUrl&&(0,X.jsx)(F,{size:`sm`,variant:`outline`,onClick:()=>window.open(t.consoleUrl,`_blank`),children:`Obtener Key`})]})]})})]},e)})]})]}),(0,X.jsxs)(_e,{children:[(0,X.jsxs)(me,{children:[(0,X.jsx)(pe,{className:`text-lg`,children:`Como funciona?`}),(0,X.jsx)(ge,{children:`Configura las API keys de los providers de voz para habilitar STT y TTS en tus canales.`})]}),(0,X.jsxs)(he,{className:`space-y-4 text-sm text-muted-foreground`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`strong`,{className:`text-foreground`,children:`STT (Speech-to-Text):`}),` Convierte el audio entrante en texto. Groq Whisper es recomendado por su velocidad.`]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`strong`,{className:`text-foreground`,children:`TTS (Text-to-Speech):`}),` Convierte las respuestas de texto en audio. ElevenLabs ofrece las voces mas naturales.`]}),(0,X.jsx)(`div`,{className:`pt-2 border-t`,children:(0,X.jsx)(`p`,{className:`text-xs`,children:`Las API keys se guardan encriptadas en la base de datos local de Hive.`})})]})]})]})}var yt=[{id:`configurar`,title:`Configurar un provider`,blurb:`API key, endpoint y activación`},{id:`gratuitos`,title:`Providers gratuitos`,blurb:`Cuáles no cobran por token`},{id:`agregar`,title:`Agregar un modelo`,blurb:`Descubrir vs. cargar a mano`},{id:`ollama`,title:`Modelos de Ollama`,blurb:`Cómo se nombran los modelos locales`},{id:`modelscope`,title:`ModelScope y Qwen`,blurb:`El dominio correcto y los créditos`},{id:`costos`,title:`Cómo se calcula el costo`,blurb:`Precios, «sin tarifa» y el dashboard`}],Z=`text-[12px] leading-relaxed text-white/55`,Q=`text-[11px] font-black uppercase tracking-widest text-white/70 mt-4 mb-1.5 first:mt-0`,$=`font-mono text-[11px] bg-white/5 border border-white/10 rounded px-1 py-0.5 text-white/70`;function bt(e){let t=(0,J.c)(48),{open:n,onOpenChange:r,providers:i,models:a,initialGuide:o}=e,[s,c]=(0,Y.useState)(o??`configurar`),l;if(t[0]!==a||t[1]!==i){let e=new Map;for(let t of a){let n=t.providerId||t.provider_id;n&&(e.has(n)||e.set(n,[]),e.get(n).push(t))}l=[...e.entries()].filter(Ct).map(e=>{let[t]=e;return i.find(e=>e.id===t)?.name||t}).sort(),t[0]=a,t[1]=i,t[2]=l}else l=t[2];let u=l,d;t[3]===i?d=t[4]:(d=i.filter(St),t[3]=i,t[4]=d);let f=d.length,p,m;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,X.jsx)(`div`,{className:`absolute -top-10 -right-10 h-32 w-32 bg-blue-600/10 rounded-full blur-[80px] pointer-events-none`}),m=(0,X.jsx)(G,{className:`text-lg font-black text-white uppercase tracking-tighter`,children:`Guía de providers`}),t[5]=p,t[6]=m):(p=t[5],m=t[6]);let h;t[7]!==f||t[8]!==a.length||t[9]!==i.length?(h=(0,X.jsxs)(`div`,{className:`p-5 border-b border-white/5 bg-white/5 relative overflow-hidden`,children:[p,m,(0,X.jsxs)(U,{className:`text-xs text-white/40 font-medium mt-0.5`,children:[i.length,` providers · `,f,` con API key · `,a.length,` modelos`]})]}),t[7]=f,t[8]=a.length,t[9]=i.length,t[10]=h):h=t[10];let g;t[11]===s?g=t[12]:(g=yt.map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>c(e.id),className:`text-left rounded-md px-2.5 py-2 transition-colors shrink-0 ${s===e.id?`bg-blue-500/10 border border-blue-500/25`:`border border-transparent hover:bg-white/5`}`,children:[(0,X.jsx)(`span`,{className:`block text-[11px] font-bold ${s===e.id?`text-blue-300`:`text-white/70`}`,children:e.title}),(0,X.jsx)(`span`,{className:`block text-[10px] text-white/30 mt-0.5 whitespace-nowrap sm:whitespace-normal`,children:e.blurb})]},e.id)),t[11]=s,t[12]=g);let _;t[13]===g?_=t[14]:(_=(0,X.jsx)(`nav`,{className:`sm:w-56 shrink-0 border-b sm:border-b-0 sm:border-r border-white/5 p-2 flex sm:flex-col gap-1 overflow-x-auto`,children:g}),t[13]=g,t[14]=_);let v;t[15]===s?v=t[16]:(v=s===`configurar`&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h4`,{className:Q,children:`1. Activa el provider`}),(0,X.jsx)(`p`,{className:Z,children:`El switch de la tarjeta activa el provider y, en cascada, sus modelos. Un provider apagado no se ofrece a los agentes aunque tenga la key cargada.`}),(0,X.jsx)(`h4`,{className:Q,children:`2. Carga la API key`}),(0,X.jsxs)(`p`,{className:Z,children:[`Botón `,(0,X.jsx)(`span`,{className:$,children:`CONFIG`}),`. La key se guarda cifrada, separada del resto de la configuración, y nunca se devuelve entera: la tarjeta sólo muestra una versión enmascarada.`]}),(0,X.jsx)(`h4`,{className:Q,children:`3. Endpoint`}),(0,X.jsxs)(`p`,{className:Z,children:[`Cada provider trae su `,(0,X.jsx)(`span`,{className:$,children:`base_url`}),` por defecto. Cámbialo solo si usas un proxy propio o un gateway corporativo. El verificador de key y el descubrimiento de modelos usan ese mismo endpoint, así que apuntar a un proxy funciona de punta a punta.`]}),(0,X.jsx)(`h4`,{className:Q,children:`Providers locales`}),(0,X.jsxs)(`p`,{className:Z,children:[`Ollama y otros en `,(0,X.jsx)(`span`,{className:$,children:`localhost`}),` no necesitan API key. En esos aparece además el campo `,(0,X.jsx)(`span`,{className:$,children:`num_ctx`}),`, que fija el contexto que el servidor local reserva por request.`]})]}),t[15]=s,t[16]=v);let y;t[17]!==u||t[18]!==s?(y=s===`gratuitos`&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h4`,{className:Q,children:`Sin costo por token`}),u.length>0?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:Z,children:`Según el catálogo cargado, estos providers tienen todos sus modelos a precio cero:`}),(0,X.jsx)(`ul`,{className:`mt-2 space-y-1`,children:u.map(xt)}),(0,X.jsx)(`p`,{className:`${Z} mt-3`,children:`Esta lista sale de los precios guardados en la base, así que se actualiza sola cuando cambia el catálogo. Gratis no significa sin límites: suelen tener cuotas de uso por cuenta.`})]}):(0,X.jsx)(`p`,{className:Z,children:`Ningún provider del catálogo actual tiene todos sus modelos a precio cero.`}),(0,X.jsx)(`h4`,{className:Q,children:`Ojo con el $0 engañoso`}),(0,X.jsxs)(`p`,{className:Z,children:[`Un modelo `,(0,X.jsx)(`em`,{children:`sin tarifa cargada`}),` también suma $0 al dashboard, pero no porque sea gratis sino porque falta el dato. En la lista de modelos se distinguen: `,(0,X.jsx)(`span`,{className:$,children:`Gratis`}),` en verde contra `,(0,X.jsx)(`span`,{className:$,children:`Sin tarifa`}),` en gris.`]})]}),t[17]=u,t[18]=s,t[19]=y):y=t[19];let b;t[20]===s?b=t[21]:(b=s===`agregar`&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h4`,{className:Q,children:`Descubrir (recomendado)`}),(0,X.jsxs)(`p`,{className:Z,children:[`Trae la lista real de modelos que el provider sirve en este momento y eliges de ahí. Es la forma segura: un ID escrito a mano puede estar mal o haber sido retirado, y eso no falla al guardar — falla mucho después, en plena conversación, con un `,(0,X.jsx)(`span`,{className:$,children:`404`}),` o un`,` `,(0,X.jsx)(`span`,{className:$,children:`410 Gone`}),`.`]}),(0,X.jsx)(`p`,{className:`${Z} mt-2`,children:`Los modelos que ya tienes cargados aparecen marcados para que no los dupliques.`}),(0,X.jsx)(`h4`,{className:Q,children:`Manual`}),(0,X.jsx)(`p`,{className:Z,children:`Para providers que no publican su lista de modelos. Campos:`}),(0,X.jsxs)(`ul`,{className:`${Z} mt-2 space-y-1.5 list-disc pl-4`,children:[(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`b`,{className:`text-white/70`,children:`ID en la API`}),` — el nombre exacto que espera el provider.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`b`,{className:`text-white/70`,children:`Nombre visible`}),` — sólo para la UI.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`b`,{className:`text-white/70`,children:`Contexto`}),` — tokens de entrada máximos; también decide cuándo se compacta la conversación.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`b`,{className:`text-white/70`,children:`Costo`}),` — USD por millón de tokens.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`b`,{className:`text-white/70`,children:`Capacidades`}),` — `,(0,X.jsx)(`span`,{className:$,children:`function_calling`}),` es la que habilita herramientas.`]})]}),(0,X.jsx)(`p`,{className:`${Z} mt-3`,children:`Los modelos que agregues a mano sobreviven a las actualizaciones del catálogo: no se borran al actualizar la lista de modelos que trae Hive.`})]}),t[20]=s,t[21]=b);let x;t[22]===s?x=t[23]:(x=s===`ollama`&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h4`,{className:Q,children:`Cómo se llaman`}),(0,X.jsxs)(`p`,{className:Z,children:[`Ollama identifica cada modelo como `,(0,X.jsx)(`span`,{className:$,children:`nombre:tag`}),`, donde el tag es la variante o el tamaño. Ejemplos: `,(0,X.jsx)(`span`,{className:$,children:`llama3.3:8b`}),`,`,` `,(0,X.jsx)(`span`,{className:$,children:`qwen3:14b`}),`, `,(0,X.jsx)(`span`,{className:$,children:`mistral:7b`}),`. Sin tag, Ollama asume `,(0,X.jsx)(`span`,{className:$,children:`:latest`}),`.`]}),(0,X.jsx)(`h4`,{className:Q,children:`No los escribas a mano`}),(0,X.jsxs)(`p`,{className:Z,children:[`El botón de sincronizar de la tarjeta lee los modelos que ya tienes instalados y los carga solo. Si un modelo no aparece, primero bájalo en tu máquina con`,` `,(0,X.jsx)(`span`,{className:$,children:`ollama pull llama3.3:8b`}),` y vuelve a sincronizar.`]}),(0,X.jsx)(`h4`,{className:Q,children:`Contexto`}),(0,X.jsx)(`p`,{className:Z,children:`Los modelos descubiertos entran con contexto 0 porque Ollama no lo reporta en el listado. Editalo con el valor real del modelo: si queda en 0, Hive usa un valor por defecto que puede no corresponder al que tienes cargado.`}),(0,X.jsx)(`h4`,{className:Q,children:`Costo`}),(0,X.jsxs)(`p`,{className:Z,children:[`Corren en tu máquina, así que entran en `,(0,X.jsx)(`span`,{className:$,children:`0`}),`. No consumen presupuesto.`]})]}),t[22]=s,t[23]=x);let S;t[24]===s?S=t[25]:(S=s===`modelscope`&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h4`,{className:Q,children:`El error que casi nadie encuentra: .ai vs .cn`}),(0,X.jsxs)(`p`,{className:Z,children:[`ModelScope tiene dos endpoints con `,(0,X.jsx)(`b`,{className:`text-white/70`,children:`cuentas y tokens separados`}),`:`,` `,(0,X.jsx)(`span`,{className:$,children:`api-inference.modelscope.ai`}),` (internacional) y`,` `,(0,X.jsx)(`span`,{className:$,children:`api-inference.modelscope.cn`}),` (China). Un token de uno responde`,` `,(0,X.jsx)(`span`,{className:$,children:`401`}),` en el otro.`]}),(0,X.jsxs)(`p`,{className:`${Z} mt-2`,children:[`Lo confuso: `,(0,X.jsx)(`b`,{className:`text-white/70`,children:`el listado de modelos responde 200 en los dos`}),`, porque es público y no valida la key. El 401 aparece recién al invocar un modelo. Si te pasa eso, no es la key — es el dominio. Hive viene apuntando al internacional (`,(0,X.jsx)(`span`,{className:$,children:`.ai`}),`); cámbialo desde CONFIG si tu cuenta es la china.`]}),(0,X.jsx)(`h4`,{className:Q,children:`ModelScope no es DashScope`}),(0,X.jsxs)(`p`,{className:Z,children:[`Son plataformas distintas de Alibaba, con cuentas y créditos separados. El provider`,` `,(0,X.jsx)(`span`,{className:$,children:`ModelScope Qwen`}),` usa un token de modelscope.cn → Access Tokens. El provider `,(0,X.jsx)(`span`,{className:$,children:`Qwen (Alibaba)`}),` usa una API key de Model Studio / DashScope. Una no sirve para el otro.`]}),(0,X.jsx)(`h4`,{className:Q,children:`Cuota`}),(0,X.jsxs)(`p`,{className:Z,children:[`El endpoint es gratuito dentro de límite: 2000 llamadas por día y hasta 500 por modelo. Por eso sus modelos figuran con costo `,(0,X.jsx)(`span`,{className:$,children:`0`}),`.`]}),(0,X.jsx)(`h4`,{className:Q,children:`Modelos de embajador`}),(0,X.jsxs)(`p`,{className:Z,children:[`Los `,(0,X.jsx)(`span`,{className:$,children:`Qwen-Ambassador/*`}),` (3.7-Plus, 3.7-Max, 3.8-Max) aparecen en el listado para todo el mundo, pero sólo los puede invocar una cuenta del programa de embajadores. Si no eres parte, el provider devuelve un error de autorización al usarlos.`]})]}),t[24]=s,t[25]=S);let C;t[26]===s?C=t[27]:(C=s===`costos`&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h4`,{className:Q,children:`De dónde sale el número`}),(0,X.jsx)(`p`,{className:Z,children:`Cada modelo guarda su precio de entrada y de salida en USD por millón de tokens. Cuando un agente responde, se registran los tokens reales de esa llamada y se multiplican por el precio de ese modelo. No hay tabla de precios aparte: lo que ves en la tarjeta es lo mismo que factura el dashboard.`}),(0,X.jsx)(`h4`,{className:Q,children:`Entrada y salida no valen igual`}),(0,X.jsxs)(`p`,{className:Z,children:[`La salida suele costar entre 3 y 6 veces más que la entrada. Por eso se muestran los dos números:`,` `,(0,X.jsx)(`span`,{className:$,children:`$3 / $15`}),` es entrada / salida.`]}),(0,X.jsx)(`h4`,{className:Q,children:`«Sin tarifa» vs. 0`}),(0,X.jsxs)(`p`,{className:Z,children:[`Dejar el precio vacío marca el modelo como sin tarifa y su consumo se cuenta como $0 — lo cual ensucia el total sin avisar. Si el endpoint es realmente gratuito, pon`,` `,(0,X.jsx)(`span`,{className:$,children:`0`}),` explícito.`]}),(0,X.jsx)(`h4`,{className:Q,children:`Gasto por provider`}),(0,X.jsxs)(`p`,{className:Z,children:[`El pie de cada tarjeta muestra el gasto y los tokens de los últimos 30 días de ese provider. Un`,` `,(0,X.jsx)(`span`,{className:$,children:`—`}),` significa que todavía no hay registros de uso.`]})]}),t[26]=s,t[27]=C);let w;t[28]!==b||t[29]!==x||t[30]!==S||t[31]!==C||t[32]!==v||t[33]!==y?(w=(0,X.jsxs)(`div`,{className:`flex-1 p-5 overflow-y-auto hive-scroll`,children:[v,y,b,x,S,C]}),t[28]=b,t[29]=x,t[30]=S,t[31]=C,t[32]=v,t[33]=y,t[34]=w):w=t[34];let T;t[35]!==w||t[36]!==_?(T=(0,X.jsxs)(`div`,{className:`flex flex-col sm:flex-row max-h-[65vh]`,children:[_,w]}),t[35]=w,t[36]=_,t[37]=T):T=t[37];let E;t[38]===r?E=t[39]:(E=(0,X.jsx)(`div`,{className:`px-5 py-3 border-t border-white/5 flex justify-end`,children:(0,X.jsx)(`button`,{type:`button`,onClick:()=>r(!1),className:`h-8 px-3.5 rounded-md bg-white/5 border border-white/10 text-white/60 text-[10px] font-black uppercase tracking-widest hover:bg-white/10 transition-colors`,children:`Cerrar`})}),t[38]=r,t[39]=E);let D;t[40]!==T||t[41]!==E||t[42]!==h?(D=(0,X.jsxs)(W,{className:`rounded-xl border border-white/10 p-0 overflow-hidden w-[calc(100vw-2rem)] max-w-3xl bg-[#09090b]`,children:[h,T,E]}),t[40]=T,t[41]=E,t[42]=h,t[43]=D):D=t[43];let O;return t[44]!==r||t[45]!==n||t[46]!==D?(O=(0,X.jsx)(K,{open:n,onOpenChange:r,children:D}),t[44]=r,t[45]=n,t[46]=D,t[47]=O):O=t[47],O}function xt(e){return(0,X.jsxs)(`li`,{className:`flex items-center gap-2 text-[12px] text-emerald-400/80`,children:[(0,X.jsx)(`span`,{className:`h-1 w-1 rounded-full bg-emerald-400/60`}),e]},e)}function St(e){return e.has_api_key}function Ct(e){let[,t]=e,n=t.map(we).filter(wt);return n.length>0&&n.every(Te)}function wt(e){return e!==null}var Tt=b,Et=f,Dt=_,Ot=ne,kt=ve;function At(){let e=(0,J.c)(31),{providers:t,createProvider:n}=N(),{models:r}=A(),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(`providers`),u;e[0]===n?u=e[1]:(u=async e=>{try{await n({id:e.id,name:e.name,base_url:e.baseUrl,api_key:e.apiKey,headers:e.headers,num_ctx:e.numCtx}),a(!1)}catch(e){console.error(`Error creating provider:`,e)}},e[0]=n,e[1]=u);let d=u,f;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,X.jsxs)(`div`,{className:`flex items-center gap-3 mb-2`,children:[(0,X.jsx)(`div`,{className:`hive-page-header__dot`}),(0,X.jsx)(`span`,{className:`hive-page-header__label`,children:`INFRAESTRUCTURA`})]}),e[2]=f):f=e[2];let p;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,X.jsxs)(`div`,{children:[f,(0,X.jsxs)(`h2`,{className:`hive-title-page`,children:[`Providers de IA`,(0,X.jsx)(`span`,{className:`hive-title-page__accent`,children:`.`})]})]}),e[3]=p):p=e[3];let m;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>s(!0),e[4]=m):m=e[4];let h;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,X.jsxs)(`button`,{type:`button`,onClick:m,className:`hive-btn hive-btn--ghost`,title:`Cómo configurar providers, cuáles son gratis, cómo agregar modelos`,children:[(0,X.jsx)(kt,{className:`mr-1 h-4 w-4`}),`Guía`]}),e[5]=h):h=e[5];let g;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(g=e=>{a(e)},e[6]=g):g=e[6];let _;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,X.jsx)(H,{asChild:!0,children:(0,X.jsxs)(`button`,{className:`hive-btn hive-btn--primary`,children:[(0,X.jsx)(Tt,{className:`mr-1 h-4 w-4`}),`Añadir Provider`]})}),e[7]=_):_=e[7];let v;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,X.jsxs)(oe,{className:`p-6 border-b border-white/5 bg-white/5 relative overflow-hidden`,children:[(0,X.jsx)(`div`,{className:`hive-glow-blob hive-glow-blob--blue -top-10 -right-10 h-32 w-32 opacity-20`}),(0,X.jsx)(G,{className:`text-xl font-black text-white uppercase tracking-tighter`,children:`Añadir Provider`}),(0,X.jsx)(U,{className:`text-xs text-white/40 font-medium mt-1`,children:`Crea un nuevo provider de IA para tu infraestructura.`})]}),e[8]=v):v=e[8];let y;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>a(!1),e[9]=y):y=e[9];let b;e[10]===d?b=e[11]:(b=(0,X.jsxs)(W,{className:`max-w-md`,children:[v,(0,X.jsx)(`div`,{className:`p-6`,children:(0,X.jsx)(Je,{onSave:d,onCancel:y})})]}),e[10]=d,e[11]=b);let x;e[12]!==i||e[13]!==b?(x=(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[p,(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[h,(0,X.jsxs)(K,{open:i,onOpenChange:g,children:[_,b]})]})]}),e[12]=i,e[13]=b,e[14]=x):x=e[14];let S;e[15]!==o||e[16]!==r||e[17]!==t?(S=(0,X.jsx)(bt,{open:o,onOpenChange:s,providers:t,models:r}),e[15]=o,e[16]=r,e[17]=t,e[18]=S):S=e[18];let C;e[19]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,X.jsxs)(B,{value:`providers`,className:`gap-1.5 text-xs`,children:[(0,X.jsx)(Ot,{className:`h-3.5 w-3.5`}),`Providers`]}),e[19]=C):C=e[19];let w;e[20]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,X.jsxs)(B,{value:`vision`,className:`gap-1.5 text-xs`,children:[(0,X.jsx)(Et,{className:`h-3.5 w-3.5`}),`Imagen`]}),e[20]=w):w=e[20];let T;e[21]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,X.jsxs)(ie,{className:`w-full grid grid-cols-3 h-10`,children:[C,w,(0,X.jsxs)(B,{value:`voice`,className:`gap-1.5 text-xs`,children:[(0,X.jsx)(Dt,{className:`h-3.5 w-3.5`}),`Voz`]})]}),e[21]=T):T=e[21];let E;e[22]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,X.jsx)(V,{value:`providers`,className:`mt-4`,children:(0,X.jsx)(Ge,{onOpenGuide:()=>s(!0)})}),e[22]=E):E=e[22];let D;e[23]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,X.jsx)(V,{value:`vision`,className:`mt-4`,children:(0,X.jsx)(et,{})}),e[23]=D):D=e[23];let O;e[24]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,X.jsx)(V,{value:`voice`,className:`mt-4`,children:(0,X.jsx)(vt,{})}),e[24]=O):O=e[24];let k;e[25]===c?k=e[26]:(k=(0,X.jsxs)(ae,{value:c,onValueChange:l,className:`w-full`,children:[T,E,D,O]}),e[25]=c,e[26]=k);let j;return e[27]!==x||e[28]!==S||e[29]!==k?(j=(0,X.jsxs)(`div`,{className:`space-y-4 mt-6 sm:mt-10`,children:[x,S,k]}),e[27]=x,e[28]=S,e[29]=k,e[30]=j):j=e[30],j}export{At as ProvidersPage};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{f as t}from"./vendor-charts-K3xcRl0X.js";import{o as n}from"./vendor-query-Dj8xYhQD.js";import{t as r}from"./arrow-left-WyDPYZXU.js";import{n as i,t as a}from"./eye-CxvxtQT5.js";import{c as o}from"./vendor-router-DP84b3LQ.js";import{G as s,W as c,rt as l}from"./index-C5Hhusqq.js";import{t as u}from"./label-D_fvqJyD.js";var d=e(t(),1),f=n();function p(){let e=o(),[t,n]=(0,d.useState)(``),[p,m]=(0,d.useState)(``),[h,g]=(0,d.useState)(``),[_,v]=(0,d.useState)(!1),[y,b]=(0,d.useState)(!1),[x,S]=(0,d.useState)(``);async function C(n){if(n.preventDefault(),S(``),p!==h){S(`Las contraseñas no coinciden`);return}if(p.length<8){S(`La contraseña debe tener al menos 8 caracteres`);return}b(!0);try{let n=await fetch(`/api/auth/recover`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recoveryKey:t,newPassword:p})}),r=await n.json();if(!n.ok){S(r.error||`Recovery key inválido`);return}localStorage.setItem(`hive-auth-token`,r.authToken),e(`/`,{replace:!0})}catch{S(`No se pudo conectar al servidor`)}finally{b(!1)}}return(0,f.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-background`,children:(0,f.jsxs)(`div`,{className:`w-full max-w-sm space-y-6 p-8`,children:[(0,f.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,f.jsx)(`div`,{className:`text-4xl`,children:`🐝`}),(0,f.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight`,children:`Recuperar acceso`}),(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Usa tu recovery key para restablecer la contraseña`})]}),(0,f.jsxs)(`form`,{onSubmit:C,className:`space-y-4`,children:[(0,f.jsxs)(`div`,{className:`space-y-2`,children:[(0,f.jsx)(u,{htmlFor:`recoveryKey`,children:`Recovery Key`}),(0,f.jsx)(c,{id:`recoveryKey`,type:`text`,placeholder:`xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`,value:t,onChange:e=>n(e.target.value),required:!0,disabled:y,className:`font-mono text-sm`}),(0,f.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Encuéntralo en `,(0,f.jsx)(`code`,{className:`bg-muted px-1 rounded`,children:`~/.hive/.auth_token`})]})]}),(0,f.jsxs)(`div`,{className:`space-y-2`,children:[(0,f.jsx)(u,{htmlFor:`newPassword`,children:`Nueva contraseña`}),(0,f.jsxs)(`div`,{className:`relative`,children:[(0,f.jsx)(c,{id:`newPassword`,type:_?`text`:`password`,placeholder:`••••••••`,value:p,onChange:e=>m(e.target.value),required:!0,disabled:y,className:`pr-10`}),(0,f.jsx)(`button`,{type:`button`,className:`absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>v(e=>!e),tabIndex:-1,children:_?(0,f.jsx)(i,{className:`h-4 w-4`}):(0,f.jsx)(a,{className:`h-4 w-4`})})]})]}),(0,f.jsxs)(`div`,{className:`space-y-2`,children:[(0,f.jsx)(u,{htmlFor:`confirmPassword`,children:`Confirmar contraseña`}),(0,f.jsx)(c,{id:`confirmPassword`,type:_?`text`:`password`,placeholder:`••••••••`,value:h,onChange:e=>g(e.target.value),required:!0,disabled:y})]}),x&&(0,f.jsx)(`p`,{className:`text-sm text-destructive`,children:x}),(0,f.jsxs)(s,{type:`submit`,className:`w-full`,disabled:y,children:[y&&(0,f.jsx)(l,{className:`mr-2 h-4 w-4 animate-spin`}),`Recuperar acceso`]})]}),(0,f.jsx)(`div`,{className:`text-center`,children:(0,f.jsxs)(`button`,{type:`button`,onClick:()=>e(`/login`),className:`text-sm text-muted-foreground hover:text-foreground inline-flex items-center gap-1`,children:[(0,f.jsx)(r,{className:`h-3 w-3`}),`Volver al login`]})})]})})}export{p as default};
1
+ import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{f as t}from"./vendor-charts-K3xcRl0X.js";import{o as n}from"./vendor-query-Dj8xYhQD.js";import{t as r}from"./arrow-left-WyDPYZXU.js";import{n as i,t as a}from"./eye-CxvxtQT5.js";import{c as o}from"./vendor-router-DSMCk-Ka.js";import{X as s,Y as c,ct as l}from"./index-mBw9Tl7u.js";import{t as u}from"./label-D_fvqJyD.js";var d=e(t(),1),f=n();function p(){let e=o(),[t,n]=(0,d.useState)(``),[p,m]=(0,d.useState)(``),[h,g]=(0,d.useState)(``),[_,v]=(0,d.useState)(!1),[y,b]=(0,d.useState)(!1),[x,S]=(0,d.useState)(``);async function C(n){if(n.preventDefault(),S(``),p!==h){S(`Las contraseñas no coinciden`);return}if(p.length<8){S(`La contraseña debe tener al menos 8 caracteres`);return}b(!0);try{let n=await fetch(`/api/auth/recover`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recoveryKey:t,newPassword:p})}),r=await n.json();if(!n.ok){S(r.error||`Recovery key inválido`);return}localStorage.setItem(`hive-auth-token`,r.authToken),e(`/`,{replace:!0})}catch{S(`No se pudo conectar al servidor`)}finally{b(!1)}}return(0,f.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-background`,children:(0,f.jsxs)(`div`,{className:`w-full max-w-sm space-y-6 p-8`,children:[(0,f.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,f.jsx)(`div`,{className:`text-4xl`,children:`🐝`}),(0,f.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight`,children:`Recuperar acceso`}),(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Usa tu recovery key para restablecer la contraseña`})]}),(0,f.jsxs)(`form`,{onSubmit:C,className:`space-y-4`,children:[(0,f.jsxs)(`div`,{className:`space-y-2`,children:[(0,f.jsx)(u,{htmlFor:`recoveryKey`,children:`Recovery Key`}),(0,f.jsx)(c,{id:`recoveryKey`,type:`text`,placeholder:`xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`,value:t,onChange:e=>n(e.target.value),required:!0,disabled:y,className:`font-mono text-sm`}),(0,f.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Encuéntralo en `,(0,f.jsx)(`code`,{className:`bg-muted px-1 rounded`,children:`~/.hive/.auth_token`})]})]}),(0,f.jsxs)(`div`,{className:`space-y-2`,children:[(0,f.jsx)(u,{htmlFor:`newPassword`,children:`Nueva contraseña`}),(0,f.jsxs)(`div`,{className:`relative`,children:[(0,f.jsx)(c,{id:`newPassword`,type:_?`text`:`password`,placeholder:`••••••••`,value:p,onChange:e=>m(e.target.value),required:!0,disabled:y,className:`pr-10`}),(0,f.jsx)(`button`,{type:`button`,className:`absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>v(e=>!e),tabIndex:-1,children:_?(0,f.jsx)(i,{className:`h-4 w-4`}):(0,f.jsx)(a,{className:`h-4 w-4`})})]})]}),(0,f.jsxs)(`div`,{className:`space-y-2`,children:[(0,f.jsx)(u,{htmlFor:`confirmPassword`,children:`Confirmar contraseña`}),(0,f.jsx)(c,{id:`confirmPassword`,type:_?`text`:`password`,placeholder:`••••••••`,value:h,onChange:e=>g(e.target.value),required:!0,disabled:y})]}),x&&(0,f.jsx)(`p`,{className:`text-sm text-destructive`,children:x}),(0,f.jsxs)(s,{type:`submit`,className:`w-full`,disabled:y,children:[y&&(0,f.jsx)(l,{className:`mr-2 h-4 w-4 animate-spin`}),`Recuperar acceso`]})]}),(0,f.jsx)(`div`,{className:`text-center`,children:(0,f.jsxs)(`button`,{type:`button`,onClick:()=>e(`/login`),className:`text-sm text-muted-foreground hover:text-foreground inline-flex items-center gap-1`,children:[(0,f.jsx)(r,{className:`h-3 w-3`}),`Volver al login`]})})]})})}export{p as default};