1import{r as l,j as e,i as N,a1 as m,a7 as u,e as n}from"./app-BEDoDvHI.js";import{B as f}from"./Badge-DqJ5axtq.js";function w(){const[a,h]=l.useState(null),[x,p]=l.useState(null),[y,j]=l.useState(!0),d=async()=>{try{const[s,t]=await Promise.all([n.get("/admin/wa/sessions"),n.get("/admin/wa/queues")]);h(s.data),p(t.data.queues)}catch{}finally{j(!1)}};if(l.useEffect(()=>{d()},[]),l.useEffect(()=>{const s=setInterval(d,15e3);return()=>clearInterval(s)},[]),y)return e.jsx(N,{});const r=(a==null?void 0:a.summary)||{},i=(a==null?void 0:a.sessions)||[];return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-100",children:"WhatsApp Sessions Monitor"}),e.jsx("p",{className:"text-gray-400 mt-1",children:"Monitoramento em tempo real de todas as sessões."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-red-500 animate-pulse"}),e.jsx("span",{className:"text-sm text-gray-400",children:"Live"}),e.jsx("button",{onClick:d,className:"ml-3 text-gray-400 hover:text-gray-200",children:e.jsx(m,{size:16})})]})]}),e.jsx("div",{className:"bg-dark-800 border border-gray-700/50 rounded-xl p-5",children:e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-5 gap-4 text-center",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-gray-100",children:r.total||0}),e.jsx("div",{className:"text-xs text-gray-500",children:"Total"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-emerald-400",children:r.online||0}),e.jsx("div",{className:"text-xs text-gray-500",children:"Online"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-gray-400",children:r.offline||0}),e.jsx("div",{className:"text-xs text-gray-500",children:"Offline"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-red-400",children:r.errors||0}),e.jsx("div",{className:"text-xs text-gray-500",children:"Errors"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-2xl font-bold text-indigo-400",children:[r.totalRssMb||0," MB"]}),e.jsx("div",{className:"text-xs text-gray-500",children:"RAM Total"})]})]})}),e.jsx("div",{className:"bg-dark-800 border border-gray-700/50 rounded-xl overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-gray-700/30 text-left",children:[e.jsx("th",{className:"px-4 py-3 text-gray-400 font-medium",children:"Sessão"}),e.jsx("th",{className:"px-4 py-3 text-gray-400 font-medium",children:"User"}),e.jsx("th",{className:"px-4 py-3 text-gray-400 font-medium",children:"Phone"}),e.jsx("th",{className:"px-4 py-3 text-gray-400 font-medium",children:"Status"}),e.jsx("th",{className:"px-4 py-3 text-gray-400 font-medium",children:"Platform"}),e.jsx("th",{className:"px-4 py-3 text-gray-400 font-medium",children:"RAM"}),e.jsx("th",{className:"px-4 py-3 text-gray-400 font-medium",children:"Chats"}),e.jsx("th",{className:"px-4 py-3 text-gray-400 font-medium",children:"Msgs"}),e.jsx("th",{className:"px-4 py-3 text-gray-400 font-medium",children:"Groups"}),e.jsx("th",{className:"px-4 py-3 text-gray-400 font-medium",children:"Contacts"}),e.jsx("th",{className:"px-4 py-3 text-gray-400 font-medium",children:"Ações"})]})}),e.jsx("tbody",{children:i.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:11,className:"px-4 py-8 text-center text-gray-500",children:"Nenhuma sessão ativa"})}):i.map(s=>{var t;return e.jsxs("tr",{className:"border-b border-gray-700/20 hover:bg-dark-700/30",children:[e.jsx("td",{className:"px-4 py-3 text-gray-200 font-mono text-xs",children:s.name||((t=s.sessionId)==null?void 0:t.substring(0,16))}),e.jsx("td",{className:"px-4 py-3 text-gray-300",children:s.email||`#${s.userId}`}),e.jsx("td",{className:"px-4 py-3 text-gray-300",children:s.phone?u(s.phone):"--"}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(f,{status:s.status==="connected"?"active":s.status})}),e.jsx("td",{className:"px-4 py-3 text-gray-400",children:s.platform||"--"}),e.jsxs("td",{className:"px-4 py-3 text-gray-300",children:[s.rss||0," MB"]}),e.jsx("td",{className:"px-4 py-3 text-gray-300",children:s.chats||0}),e.jsx("td",{className:"px-4 py-3 text-gray-300",children:(s.msgsSent||0)+(s.msgsReceived||0)}),e.jsx("td",{className:"px-4 py-3 text-gray-300",children:s.groups||0}),e.jsx("td",{className:"px-4 py-3 text-gray-300",children:s.contacts||0}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("button",{onClick:async()=>{var c,o;try{await n.post(`/admin/wa/sessions/${s.sessionId}/restart`),d()}catch(g){alert(((o=(c=g.response)==null?void 0:c.data)==null?void 0:o.error)||"Erro")}},className:"text-xs text-indigo-400 hover:text-indigo-300",children:e.jsx(m,{size:14})})})]},s.sessionId)})})]})})}),x&&Object.keys(x).length>0&&e.jsxs("div",{className:"bg-dark-800 border border-gray-700/50 rounded-xl p-5",children:[e.jsx("h3",{className:"font-semibold text-gray-100 mb-3",children:"Filas BullMQ"}),e.jsx("div",{className:"space-y-2",children:Object.entries(x).map(([s,t])=>e.jsxs("div",{className:"flex items-center justify-between py-2 px-3 bg-dark-700/30 rounded-lg",children:[e.jsx("span",{className:"text-sm text-gray-300 font-mono",children:s}),e.jsxs("div",{className:"flex gap-3 text-xs",children:[e.jsxs("span",{className:"text-yellow-400",children:[t.waiting||0," waiting"]}),e.jsxs("span",{className:"text-blue-400",children:[t.active||0," active"]}),e.jsxs("span",{className:"text-gray-500",children:[t.delayed||0," delayed"]}),e.jsxs("span",{className:"text-red-400",children:[t.failed||0," failed"]})]})]},s))})]})]})}export{w 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.