1import{w as h,r as f,j as e,aS as H,B as g,I as z,C as D}from"./index-CEnZ8FY1.js";import{L as I}from"./Layout-DNWe9qIl.js";import{B as o}from"./badge-DmJzgv4o.js";import{C as i,a as l,b as v,c as N}from"./card-CaCVRK7N.js";import{S as T}from"./skeleton-CWKQvVFA.js";import{h as U}from"./use-admin-DTGANoCx.js";import{R as E}from"./refresh-cw-Bsl1f5iZ.js";import{T as S}from"./triangle-alert-UasMvsAS.js";import{W as A}from"./wifi-DVxoE8vB.js";import{W as B}from"./wifi-off-Dv3_RGSs.js";import{S as y}from"./smartphone-7XSG4qpr.js";import{A as V}from"./activity-DG8aGU3Y.js";import"./separator-BRFbcbgD.js";import"./circle-help-WO7fKraY.js";import"./message-circle-DD8URC7w.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const F=h("Cpu",[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}
6],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]]);/** 7 * @license lucide-react v0.462.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const W=h("HardDrive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]);/** 12 * @license lucide-react v0.462.0 - ISC 13 * 14 * This source code is licensed under the ISC license. 15 * See the LICENSE file in the root directory of this source tree. 16 */const P=h("MemoryStick",[["path",{d:"M6 19v-3",key:"1nvgqn"}],["path",{d:"M10 19v-3",key:"iu8nkm"}],["path",{d:"M14 19v-3",key:"kcehxu"}],["path",{d:"M18 19v-3",key:"1vh91z"}],["path",{d:"M8 11V9",key:"63erz4"}],["path",{d:"M16 11V9",key:"fru6f3"}],["path",{d:"M12 11V9",key:"ha00sb"}],["path",{d:"M2 15h20",key:"16ne18"}],["path",{d:"M2 7a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1.1a2 2 0 0 0 0 3.837V17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5.1a2 2 0 0 0 0-3.837Z",key:"lhddv3"}]]);/** 17 * @license lucide-react v0.462.0 - ISC 18 * 19 * This source code is licensed under the ISC license. 20 * See the LICENSE file in the root directory of this source tree. 21 */const L=h("Unplug",[["path",{d:"m19 5 3-3",key:"yk6iyv"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z",key:"1snsnr"}]]),M=(s=0)=>{if(!s)return"0 MB";const a=["B","KB","MB","GB","TB"],r=Math.min(Math.floor(Math.log(s)/Math.log(1024)),a.length-1);return`${(s/1024**r).toFixed(r>=3?1:0)} ${a[r]}`},R=(s=0)=>{const a=Math.floor(s/86400),r=Math.floor(s%86400/3600);return a?`${a}d ${r}h`:`${r}h`};function b({title:s,usage:a,icon:r}){const n=(a==null?void 0:a.percent)??0,u=n>=85?"bg-destructive":n>=70?"bg-warning":"bg-success";return e.jsx(i,{children:e.jsxs(l,{className:"p-5 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:s}),e.jsx(r,{className:"w-5 h-5 text-muted-foreground"})]}),e.jsxs("div",{className:"flex items-end justify-between gap-3",children:[e.jsxs("span",{className:"text-3xl font-semibold",children:[n.toFixed(1),"%"]}),a&&s!=="CPU"&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[M(a.used)," / ",M(a.total)]})]}),e.jsx("div",{className:"h-2.5 rounded-full bg-muted overflow-hidden",children:e.jsx("div",{className:`h-full ${u}`,style:{width:`${Math.min(n,100)}%`}})})]})})}function q({row:s}){return s.health==="HEALTHY"?e.jsx(o,{className:"bg-success hover:bg-success",children:"Saudável"}):s.health==="DIVERGENT"?e.jsx(o,{variant:"destructive",children:"Estado divergente"}):s.health==="UNAVAILABLE"?e.jsx(o,{variant:"outline",children:"Sem resposta"}):e.jsx(o,{variant:"secondary",children:"Desconectada"})}const k=(s,a,r)=>s===null?e.jsx("span",{className:"text-muted-foreground",children:"â"}):s?a:r;function ce(){const{data:s,isLoading:a,isFetching:r,error:n,refetch:u}=U(),[p,$]=f.useState(""),[m,C]=f.useState("all"),w=f.useMemo(()=>{const t=p.trim().toLowerCase();return((s==null?void 0:s.connections.items)??[]).filter(c=>m==="problems"&&c.health==="HEALTHY"?!1:t?[c.name,c.client,c.instance,c.phone,c.provider].some(j=>j==null?void 0:j.toLowerCase().includes(t)):!0)},[s,m,p]);return e.jsx(I,{children:e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center lg:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"p-2 bg-primary rounded-xl",children:e.jsx(H,{className:"w-6 h-6 text-white"})}),e.jsx("h1",{className:"text-4xl font-semibold",children:"Saúde da infraestrutura"})]}),e.jsx("p",{className:"text-muted-foreground",children:"VM, serviços e conexões WhatsApp verificadas ao vivo a cada 20 segundos."})]}),e.jsxs(g,{variant:"outline",onClick:()=>u(),disabled:r,children:[e.jsx(E,{className:`w-4 h-4 mr-2 ${r?"animate-spin":""}`}),"Atualizar agora"]})]}),n&&e.jsx(i,{className:"border-destructive",children:e.jsxs(l,{className:"p-5 flex gap-3 text-destructive",children:[e.jsx(S,{className:"w-5 h-5 shrink-0"}),e.jsx("span",{children:"Não foi possÃvel carregar a telemetria. A próxima tentativa é automática."})]})}),a?e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:Array.from({length:4}).map((t,c)=>e.jsx(T,{className:"h-32"}
21,c))}):s&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-5 gap-4",children:[e.jsx(d,{label:"Conectadas",value:s.connections.connected,icon:A,tone:"text-success"}),e.jsx(d,{label:"Desconectadas",value:s.connections.disconnected,icon:B,tone:"text-warning"}),e.jsx(d,{label:"Celulares online",value:s.connections.phonesOnline,icon:y,tone:"text-info"}),e.jsx(d,{label:"Divergências",value:s.connections.divergent,icon:S,tone:s.connections.divergent?"text-destructive":"text-success"}),e.jsx(d,{label:"Sem resposta",value:s.connections.unavailable,icon:L,tone:s.connections.unavailable?"text-warning":"text-success"})]}),e.jsx(i,{className:"border-primary/30 bg-primary/5",children:e.jsxs(l,{className:"p-6",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4 mb-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Capacidade segura estimada"}),e.jsxs("p",{className:"text-3xl font-semibold",children:[s.capacity.connected," ",e.jsxs("span",{className:"text-base text-muted-foreground",children:["de ",s.capacity.safeLimit," conexões"]})]})]}),e.jsxs("div",{className:"text-left md:text-right",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Margem disponÃvel"}),e.jsxs("p",{className:"text-2xl font-semibold text-success",children:["+",s.capacity.remaining]})]})]}),e.jsx("div",{className:"h-3 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary",style:{width:`${Math.min(s.capacity.usagePercent,100)}%`}})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Limite operacional conservador; tráfego e estabilidade continuam sendo considerados antes de ampliar."})]})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx(b,{title:"CPU",usage:s.infrastructure.cpu,icon:F}),e.jsx(b,{title:"Memória",usage:s.infrastructure.memory,icon:P}),e.jsx(b,{title:"Disco",usage:s.infrastructure.disk,icon:W})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs(i,{className:"lg:col-span-2",children:[e.jsx(v,{children:e.jsxs(N,{className:"flex items-center gap-2",children:[e.jsx(V,{className:"w-5 h-5"}),"Consumo por serviço"]})}),e.jsx(l,{children:e.jsx("div",{className:"space-y-3",children:s.infrastructure.pods.map(t=>e.jsxs("div",{className:"grid grid-cols-[1fr_auto_auto] gap-4 items-center border-b last:border-0 pb-3 last:pb-0",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium truncate",children:t.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t.namespace})]}),e.jsxs("span",{className:"text-sm tabular-nums",children:[t.cpuMillicores,"m CPU"]}),e.jsx("span",{className:"text-sm tabular-nums w-20 text-right",children:M(t.memoryBytes)})]},`${t.namespace}/${t.name}`))})})]}),e.jsxs(i,{children:[e.jsx(v,{children:e.jsx(N,{children:"Servidor"})}),e.jsxs(l,{className:"space-y-4",children:[e.jsx(x,{label:"Nó",value:s.infrastructure.node}),e.jsx(x,{label:"Uptime",value:R(s.infrastructure.uptimeSeconds)}),e.jsx(x,{label:"Load 1/5/15m",value:s.infrastructure.load.map(t=>t.toFixed(2)).join(" · ")||"â"}),e.jsx(x,{label:"Amostra",value:new Date(s.sampledAt).toLocaleTimeString("pt-BR")})]})]})]}),e.jsxs(i,{children:[e.jsx(v,{children:e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-3",children:[e.jsx(N,{children:"Conexões por cliente"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{size:"sm",variant:m==="all"?"default":"outline",onClick:()=>C("all"),children:"Todas"}),e.jsx(g,{size:"sm",variant:m==="problems"?"destructive":"outline",onClick:()=>C("problems"),children:"Só problemas"}),e.jsx(z,{className:"w-64",placeholder:"Buscar cliente, instância ou telefone",value:p,onChange:t=>$(t.target.value)})]})]})}),e.jsxs(l,{className:"overflow-x-auto",children:[e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b text-left text-muted-foreground",children:[e.jsx("th",{className:"py-3 pr-4",children:"Cliente / instância"}),e.jsx("th",{className:"py-3 pr-4",children:"Provider"}),e.jsx("th",{className:"py-3 pr-4",children:"WhatsApp"}),e.jsx("th",{className:"py-3 pr-4",children:"Socket"}),e.jsx("th",{className:"py-3 pr-4",children:"Celular"}),e.jsx("th",{className:"py-3",children:"Diagnóstico"})]})}),e.jsx("tbody",{children:w.map(t=>e.jsxs("tr",{className:"border-b last:border-0",children:[e.jsxs("td",{className:"py-4 pr-4",children:[e.jsx("p",{className:"font-medium",children:t.client}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.name," · ",t.ph
21one||"sem telefone"]})]}),e.jsx("td",{className:"py-4 pr-4",children:e.jsx(o,{variant:"outline",children:t.provider})}),e.jsx("td",{className:"py-4 pr-4",children:k(t.connected,e.jsx(D,{className:"w-5 h-5 text-success"}),e.jsx(B,{className:"w-5 h-5 text-destructive"}))}),e.jsx("td",{className:"py-4 pr-4",children:k(t.websocketConnected,e.jsx(A,{className:"w-5 h-5 text-success"}),e.jsx(L,{className:"w-5 h-5 text-destructive"}))}),e.jsx("td",{className:"py-4 pr-4",children:k(t.smartphoneConnected,e.jsx(y,{className:"w-5 h-5 text-success"}),e.jsx(y,{className:"w-5 h-5 text-muted-foreground"}))}),e.jsxs("td",{className:"py-4",children:[e.jsx(q,{row:t}),t.diagnostic&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 max-w-xs",children:t.diagnostic})]})]},t.id))})]}),w.length===0&&e.jsx("p",{className:"text-center text-muted-foreground py-10",children:"Nenhuma conexão neste filtro."})]})]})]})]})})}function d({label:s,value:a,icon:r,tone:n}){return e.jsx(i,{children:e.jsx(l,{className:"p-5",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s}),e.jsx("p",{className:`text-3xl font-semibold ${n}`,children:a})]}),e.jsx(r,{className:`w-6 h-6 ${n}`})]})})})}function x({label:s,value:a}){return e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s}),e.jsx("p",{className:"font-medium break-all",children:a})]})}export{ce as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.