(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[702],{5070:function(e,t,n){Promise.resolve().then(n.bind(n,95))},95:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return x}});var s=n(3827),l=n(4090),r=n(7907),a=n(7815),i=n(5754),o=n(8994),d=n(7451),c=n(1530),u=n(5677),f=n(9990);/** * @license lucide-react v0.309.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */let m=(0,n(7461).Z)("Inbox",[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["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"}]]);var h=n(438),v=n(826);function x(){var e,t,n,x,p,g,y,j,b,N,w,k,S,T,Z,E,R,z,C,O,M,P,I,_,A,W,V,Y,q,B,D,L,H,$,F,G,J,Q,K,U,X;let ee=(0,r.useRouter)(),[et,en]=(0,l.useState)([]),[es,el]=(0,l.useState)(!0),[er,ea]=(0,l.useState)(null),[ei,eo]=(0,l.useState)("month"),[ed,ec]=(0,l.useState)(null),[eu,ef]=(0,l.useState)(null);(0,l.useEffect)(()=>{let e=localStorage.getItem("accessToken"),t=localStorage.getItem("user");if(!e){ee.push("/login");return}ea(t?JSON.parse(t):null),Promise.all([(0,v.S)("/v1/instances").then(e=>e.json()),(0,v.S)("/v1/dashboard/stats").then(e=>e.json()),(0,v.S)("/v1/dashboard/messages?period=".concat(ei)).then(e=>e.json())]).then(e=>{var t;let[n,s,l]=e;en((null===(t=n.data)||void 0===t?void 0:t.instances)||n.data||[]),ec(s.data||null),ef(l.data||null),el(!1)}).catch(()=>el(!1))},[ee]);let em=et.filter(e=>"CONNECTED"===e.status).length,eh=et.length-em;return es?(0,s.jsx)("div",{className:"flex items-center justify-center h-96",children:(0,s.jsx)(o.Z,{className:"h-8 w-8 animate-spin text-green-600"})}):(0,s.jsx)("div",{className:"p-6",children:(0,s.jsxs)("div",{className:"mb-6",children:[(0,s.jsxs)("div",{className:"bg-gradient-to-r from-green-600 to-green-500 rounded-xl p-6 text-white mb-6",children:[(0,s.jsx)("p",{className:"text-xs font-semibold uppercase tracking-wider opacity-80",children:"MaxWhats API"}),(0,s.jsxs)("h1",{className:"text-2xl font-bold mt-1",children:["Bem-vindo",er?", ".concat(er.firstName||er.email):""]}),(0,s.jsx)("p",{className:"text-sm opacity-90 mt-1",children:"Gerencie suas instancias WhatsApp e acompanhe suas metricas."})]}),(0,s.jsxs)("div",{className:"grid grid-cols-3 gap-4 mb-6",children:[(0,s.jsx)(a.Zb,{children:(0,s.jsxs)(a.aY,{className:"flex items-center gap-4 p-4",children:[(0,s.jsx)("div",{className:"flex h-12 w-12 items-center justify-center rounded-lg bg-blue-100",children:(0,s.jsx)(d.Z,{className:"h-6 w-6 text-blue-600"})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Total de instancias web"}),(0,s.jsx)("p",{className:"text-2xl font-bold",children:null!==(W=null==ed?void 0:null===(e=ed.instances)||void 0===e?void 0:e.total)&&void 0!==W?W:et.length}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Total de instancias web executando"})]})]})}),(0,s.jsx)(a.Zb,{children:(0,s.jsxs)(a.aY,{className:"flex items-center gap-4 p-4",children:[(0,s.jsx)("div",{className:"flex h-12 w-12 items-center justify-center rounded-lg bg-green-100",children:(0,s.jsx)(c.Z,{className:"h-6 w-6 text-green-600"})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Instancias web conectadas"}),(0,s.jsx)("p",{className:"text-2xl font-bold",children:null!==(V=null==ed?void 0:null===(t=ed.instances)||void 0===t?void 0:t.connected)&&void 0!==V?V:em}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Total de instancias web conectadas"})]})]})}),(0,s.jsx)(a.Zb,{children:(0,s.jsxs)(a.aY,{className:"flex items-center gap-4 p-4",children:[(0,s.jsx)("div",{className:"flex h-12 w-12 items-center justify-center rounded-lg bg-red-100",children:(0,s.jsx)(u.Z,{className:"h-6 w-6 text-red-600"})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Instancias web desconectadas"}),(0,s.jsx)("p",{className:"text-2xl font-bold",children:null!==(Y=null==ed?void 0:null===(n=ed.instances)||void 0===n?void 0:n.disconnected)&&void 0!==Y?Y:eh}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Total de instancias web desconectadas"})]})]})})]}),(0,s.jsx)("div",{className:"flex items-center gap-4 mb-6",children:(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium mb-2",children:"Periodo"}),(0,s.jsx)("div",{className:"flex items-center gap-2",children:[["month","Este mes"],["last_month","Mes passado"],["yesterday","Ontem"],["today","Hoje"]].map(e=>{let[t,n]=e;return(0,s.jsx)(i.z,{variant:ei===t?"default":"outline",size:"sm",onClick:()=>eo(t),className:ei===t?"bg-green-600 hover:bg-green-700":"",children:n},t)})})]})}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-4 mb-6",children:[(0,s.jsx)(a.Zb,{children:(0,s.jsx)(a.aY,{className:"p-4",children:(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-green-100",children:(0,s.jsx)(f.Z,{className:"h-5 w-5 text-green-600"})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Total enviado"}),(0,s.jsx)("p",{className:"text-3xl font-bold",children:null!==(B=null!==(q=null==eu?void 0:eu.sent)&&void 0!==q?q:null==ed?void 0:null===(p=ed.messages)||void 0===p?void 0:null===(x=p.month)||void 0===x?void 0:x.sent)&&void 0!==B?B:0})]})]})})}),(0,s.jsx)(a.Zb,{children:(0,s.jsx)(a.aY,{className:"p-4",children:(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-orange-100",children:(0,s.jsx)(m,{className:"h-5 w-5 text-orange-600"})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Total recebido"}),(0,s.jsx)("p",{className:"text-3xl font-bold",children:null!==(L=null!==(D=null==eu?void 0:eu.received)&&void 0!==D?D:null==ed?void 0:null===(y=ed.messages)||void 0===y?void 0:null===(g=y.month)||void 0===g?void 0:g.received)&&void 0!==L?L:0})]})]})})})]}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,s.jsxs)(a.Zb,{children:[(0,s.jsx)(a.Ol,{children:(0,s.jsx)(a.ll,{className:"text-base",children:"Total recebido/enviado no ultimo mes"})}),(0,s.jsxs)(a.aY,{children:[(0,s.jsx)("div",{className:"h-64 flex items-center justify-center text-muted-foreground border rounded-lg",children:(0,s.jsxs)("div",{className:"text-center",children:[(0,s.jsx)(h.Z,{className:"h-12 w-12 mx-auto mb-2 opacity-30"}),(0,s.jsx)("p",{className:"text-sm",children:"Nenhum dado de mensagens ainda"})]})}),(0,s.jsxs)("div",{className:"flex items-center justify-center gap-4 mt-3 text-sm",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[(0,s.jsx)("div",{className:"w-3 h-3 rounded-full bg-green-500"}),(0,s.jsx)("span",{children:"Qtd. recebida"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[(0,s.jsx)("div",{className:"w-3 h-3 rounded-full bg-blue-500"}),(0,s.jsx)("span",{children:"Qtd. enviada"})]})]})]})]}),(0,s.jsxs)(a.Zb,{children:[(0,s.jsxs)(a.Ol,{className:"flex flex-row items-center justify-between",children:[(0,s.jsx)(a.ll,{className:"text-base",children:"Mensagens Enviadas"}),(0,s.jsxs)("div",{className:"flex gap-1",children:[(0,s.jsx)(i.z,{variant:"default",size:"sm",className:"bg-green-600 hover:bg-green-700 h-7 text-xs",children:"Enviadas"}),(0,s.jsx)(i.z,{variant:"outline",size:"sm",className:"h-7 text-xs",children:"Recebidas"})]})]}),(0,s.jsx)(a.aY,{children:(0,s.jsx)("div",{className:"space-y-3",children:[["Textos",null!==(H=null==ed?void 0:null===(b=ed.messages)||void 0===b?void 0:null===(j=b.byType)||void 0===j?void 0:j.text)&&void 0!==H?H:0],["Links",null!==($=null==ed?void 0:null===(w=ed.messages)||void 0===w?void 0:null===(N=w.byType)||void 0===N?void 0:N.link)&&void 0!==$?$:0],["Documentos",null!==(F=null==ed?void 0:null===(S=ed.messages)||void 0===S?void 0:null===(k=S.byType)||void 0===k?void 0:k.document)&&void 0!==F?F:0],["Audios",null!==(G=null==ed?void 0:null===(Z=ed.messages)||void 0===Z?void 0:null===(T=Z.byType)||void 0===T?void 0:T.audio)&&void 0!==G?G:0],["Videos",null!==(J=null==ed?void 0:null===(R=ed.messages)||void 0===R?void 0:null===(E=R.byType)||void 0===E?void 0:E.video)&&void 0!==J?J:0],["Contatos",null!==(Q=null==ed?void 0:null===(C=ed.messages)||void 0===C?void 0:null===(z=C.byType)||void 0===z?void 0:z.contact)&&void 0!==Q?Q:0],["Imagens",null!==(K=null==ed?void 0:null===(M=ed.messages)||void 0===M?void 0:null===(O=M.byType)||void 0===O?void 0:O.image)&&void 0!==K?K:0],["Localizacoes",null!==(U=null==ed?void 0:null===(I=ed.messages)||void 0===I?void 0:null===(P=I.byType)||void 0===P?void 0:P.location)&&void 0!==U?U:0],["Stickers",null!==(X=null==ed?void 0:null===(A=ed.messages)||void 0===A?void 0:null===(_=A.byType)||void 0===_?void 0:_.sticker)&&void 0!==X?X:0]].map(e=>{let[t,n]=e;return(0,s.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:t}),(0,s.jsx)("span",{className:"font-medium",children:n})]},t)})})})]})]})]})})}},5754:function(e,t,n){"use strict";n.d(t,{z:function(){return d}});var s=n(3827),l=n(4090),r=n(6371),a=n(9769),i=n(1657);let o=(0,a.j)("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),d=l.forwardRef((e,t)=>{let{className:n,variant:l,size:a,asChild:d=!1,...c}=e,u=d?r.g7:"button";return(0,s.jsx)(u,{className:(0,i.cn)(o({variant:l,size:a,className:n})),ref:t,...c})});d.displayName="Button"},7815:function(e,t,n){"use strict";n.d(t,{Ol:function(){return i},SZ:function(){return d},Zb:function(){return a},aY:function(){return c},ll:function(){return o}});var s=n(3827),l=n(4090),r=n(1657);let a=l.forwardRef((e,t)=>{let{className:n,...l}=e;return(0,s.jsx)("div",{ref:t,className:(0,r.cn)("rounded-lg border bg-card text-card-foreground shadow-sm",n),...l})});a.displayName="Card";let i=l.forwardRef((e,t)=>{let{className:n,...l}=e;return(0,s.jsx)("div",{ref:t,className:(0,r.cn)("flex flex-col space-y-1.5 p-6",n),...l})});i.displayName="CardHeader";let o=l.forwardRef((e,t)=>{let{className:n,...l}=e;return(0,s.jsx)("h3",{ref:t,className:(0,r.cn)("text-2xl font-semibold leading-none tracking-tight",n),...l})});o.displayName="CardTitle";let d=l.forwardRef((e,t)=>{let{className:n,...l}=e;return(0,s.jsx)("p",{ref:t,className:(0,r.cn)("text-sm text-muted-foreground",n),...l})});d.displayName="CardDescription";let c=l.forwardRef((e,t)=>{let{className:n,...l}=e;return(0,s.jsx)("div",{ref:t,className:(0,r.cn)("p-6 pt-0",n),...l})});c.displayName="CardContent",l.forwardRef((e,t)=>{let{className:n,...l}=e;return(0,s.jsx)("div",{ref:t,className:(0,r.cn)("flex items-center p-6 pt-0",n),...l})}).displayName="CardFooter"},826:function(e,t,n){"use strict";n.d(t,{S:function(){return o}});let s="https://api.maxwhats.maxsystec.com.br",l=!1,r=[];function a(e,t){r.forEach(n=>{let{resolve:s,reject:l}=n;e?l(e):s(t)}),r=[]}async function i(){var e,t;let n=localStorage.getItem("refreshToken");if(!n)throw Error("No refresh token");let l=await fetch("".concat(s,"/v1/auth/refresh"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:n})});if(!l.ok)throw Error("Refresh failed");let r=await l.json(),a=(null===(e=r.data)||void 0===e?void 0:e.accessToken)||r.accessToken,i=(null===(t=r.data)||void 0===t?void 0:t.refreshToken)||r.refreshToken;return a&&localStorage.setItem("accessToken",a),i&&localStorage.setItem("refreshToken",i),a}async function o(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=localStorage.getItem("accessToken");if(!n)throw window.location.href="/login",Error("Not authenticated");let o={"Content-Type":"application/json",Authorization:"Bearer ".concat(n),...t.headers},d=await fetch("".concat(s).concat(e),{...t,headers:o});if(401===d.status){if(l)return new Promise((e,t)=>{r.push({resolve:e,reject:t})}).then(n=>fetch("".concat(s).concat(e),{...t,headers:{...o,Authorization:"Bearer ".concat(n)}}));l=!0;try{let n=await i();a(null,n),d=await fetch("".concat(s).concat(e),{...t,headers:{...o,Authorization:"Bearer ".concat(n)}})}catch(e){throw a(e,null),localStorage.removeItem("accessToken"),localStorage.removeItem("refreshToken"),localStorage.removeItem("user"),window.location.href="/login",e}finally{l=!1}}return d}},1657:function(e,t,n){"use strict";n.d(t,{cn:function(){return r}});var s=n(3167),l=n(1367);function r(){for(var e=arguments.length,t=Array(e),n=0;nr(e,"name",{value:t,configurable:!0});function i(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function o(){for(var e=arguments.length,t=Array(e),n=0;n{let n=!1,s=t.map(t=>{let s=i(t,e);return n||"function"!=typeof s||(n=!0),s});if(n)return()=>{for(let e=0;ec(e,"name",{value:t,configurable:!0});function f(e){let t=s.forwardRef((t,n)=>{var l;let{children:r,...a}=t,i=null,o=!1,c=[];j(r)&&"function"==typeof k&&(r=k(r._payload)),s.Children.forEach(r,e=>{if(g(e)){var t;o=!0;let n="child"in e.props?e.props.child:e.props.children;j(n)&&"function"==typeof k&&(n=k(n._payload)),i=v(e,n),c.push(null==i?void 0:null===(t=i.props)||void 0===t?void 0:t.children)}else c.push(e)}),i?i=s.cloneElement(i,void 0,c):!o&&1===s.Children.count(r)&&s.isValidElement(r)&&(i=r);let u=i?p(i):void 0,f=d(n,u);if(!i){if(r||0===r)throw Error(o?w(e):N(e));return r}let m=x(a,null!==(l=i.props)&&void 0!==l?l:{});return i.type!==s.Fragment&&(m.ref=n?f:u),s.cloneElement(i,m)});return t.displayName="".concat(e,".Slot"),t}u(f,"createSlot");var m=f("Slot"),h=Symbol.for("radix.slottable");u(function(e){let t=u(e=>"child"in e?e.children(e.child):e.children,"Slottable");return t.displayName="".concat(e,".Slottable"),t.__radixId=h,t},"createSlottable");var v=u((e,t)=>{if("child"in e.props){let t=e.props.child;return s.isValidElement(t)?s.cloneElement(t,void 0,e.props.children(t.props.children)):null}return s.isValidElement(t)?t:null},"getSlottableElementFromSlottable");function x(e,t){let n={...t};for(let s in t){let l=e[s],r=t[s];/^on[A-Z]/.test(s)?l&&r?n[s]=function(){for(var e=arguments.length,t=Array(e),n=0;n"".concat(e," failed to slot onto its children. Expected a single React element child or `Slottable`."),"createSlotError"),w=u(e=>"".concat(e," failed to slot onto its `Slottable`. Expected `Slottable` to receive a single React element child."),"createSlottableError"),k=l[" use ".trim().toString()]},9769:function(e,t,n){"use strict";n.d(t,{j:function(){return a}});var s=n(3167);let l=e=>"boolean"==typeof e?"".concat(e):0===e?"0":e,r=s.W,a=(e,t)=>n=>{var s;if((null==t?void 0:t.variants)==null)return r(e,null==n?void 0:n.class,null==n?void 0:n.className);let{variants:a,defaultVariants:i}=t,o=Object.keys(a).map(e=>{let t=null==n?void 0:n[e],s=null==i?void 0:i[e];if(null===t)return null;let r=l(t)||l(s);return a[e][r]}),d=n&&Object.entries(n).reduce((e,t)=>{let[n,s]=t;return void 0===s||(e[n]=s),e},{});return r(e,o,null==t?void 0:null===(s=t.compoundVariants)||void 0===s?void 0:s.reduce((e,t)=>{let{class:n,className:s,...l}=t;return Object.entries(l).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...d}[t]):({...i,...d})[t]===n})?[...e,n,s]:e},[]),null==n?void 0:n.class,null==n?void 0:n.className)}}},function(e){e.O(0,[700,971,69,744],function(){return e(e.s=5070)}),_N_E=e.O()}]);