(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[185],{9656:function(e,t,r){Promise.resolve().then(r.t.bind(r,2445,23)),Promise.resolve().then(r.bind(r,50)),Promise.resolve().then(r.t.bind(r,6087,23))},50:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return q}});var a=r(3827),n=r(4090),s=r(7907),i=r(8792),l=r(7461);/** * @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 o=(0,l.Z)("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]),c=(0,l.Z)("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);var d=r(6509),h=r(9142),u=r(9387),g=r(933),y=r(1280),x=r(9910),f=r(527),m=r(4059),p=r(8219),k=r(5032),b=r(7326),v=r(7451),w=r(43),Z=r(7805),j=r(1213),N=r(1049);/** * @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,l.Z)("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);var S=r(2235),P=r(1657);let _=["/login","/register","/forgot-password"],z=[{href:"/dashboard",label:"Dashboard",icon:o},{href:"/instances",label:"Inst\xe2ncias Web",icon:c},{href:"/chatbot",label:"Chatbot",icon:d.Z},{href:"/birthday",label:"Aniversariantes",icon:h.Z},{href:"/webhooks",label:"Webhooks",icon:u.Z},{href:"/tokens",label:"Tokens",icon:g.Z},{href:"/logs",label:"Logs",icon:y.Z},{href:"/settings",label:"Configura\xe7\xf5es",icon:x.Z}],A=[{href:"/admin/plans",label:"Planos",icon:f.Z},{href:"/admin/users",label:"Usu\xe1rios",icon:m.Z},{href:"/admin/financial",label:"Financeiro",icon:p.Z},{href:"/admin/status",label:"Status",icon:k.Z},{href:"/admin/audit-logs",label:"Auditoria",icon:b.Z},{href:"/admin/bot",label:"Bot WhatsApp",icon:d.Z},{href:"/admin/landing",label:"Landing Page",icon:v.Z},{href:"/admin/pwa",label:"PWA",icon:w.Z}];function C(e){let{pathname:t,userEmail:r,isAdmin:n,handleLogout:s}=e;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex h-16 items-center gap-3 border-b border-gray-100 px-5",children:[(0,a.jsx)("div",{className:"flex h-9 w-9 items-center justify-center rounded-xl bg-gradient-to-br from-green-500 to-green-600 shadow-lg shadow-green-500/25",children:(0,a.jsx)(v.Z,{className:"h-5 w-5 text-white"})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-base font-bold text-gray-900 dark:text-white",children:"MaxWhats"}),(0,a.jsx)("p",{className:"text-[10px] text-gray-400 -mt-0.5",children:"SaaS Platform"})]})]}),(0,a.jsxs)("nav",{className:"flex-1 space-y-1 px-3 py-4 overflow-y-auto",children:[z.map(e=>{let r=t===e.href||t.startsWith(e.href+"/");return(0,a.jsxs)(i.default,{href:e.href,className:(0,P.cn)("group flex items-center gap-3 rounded-xl px-3 py-2.5 text-sm font-medium transition-all duration-200",r?"bg-gradient-to-r from-green-50 to-green-100/50 text-green-700 shadow-sm shadow-green-500/10 dark:from-green-900/30 dark:to-green-900/10 dark:text-green-400":"text-gray-500 hover:bg-gray-50 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-white"),children:[(0,a.jsx)("div",{className:(0,P.cn)("flex h-8 w-8 items-center justify-center rounded-lg transition-colors",r?"bg-green-100 text-green-600 dark:bg-green-900/40 dark:text-green-400":"bg-gray-100 text-gray-400 group-hover:bg-gray-200 group-hover:text-gray-600 dark:bg-gray-800 dark:text-gray-500 dark:group-hover:bg-gray-700"),children:(0,a.jsx)(e.icon,{className:"h-4 w-4"})}),e.label,r&&(0,a.jsx)(Z.Z,{className:"h-4 w-4 ml-auto text-green-400"})]},e.href)}),n&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"pt-5 pb-2 px-3",children:(0,a.jsxs)("p",{className:"text-[10px] font-semibold text-gray-400 uppercase tracking-widest flex items-center gap-2",children:[(0,a.jsx)(b.Z,{className:"h-3 w-3"}),"Administra\xe7\xe3o"]})}),A.map(e=>{let r=t===e.href||t.startsWith(e.href+"/");return(0,a.jsxs)(i.default,{href:e.href,className:(0,P.cn)("group flex items-center gap-3 rounded-xl px-3 py-2.5 text-sm font-medium transition-all duration-200",r?"bg-gradient-to-r from-purple-50 to-purple-100/50 text-purple-700 shadow-sm shadow-purple-500/10 dark:from-purple-900/30 dark:to-purple-900/10 dark:text-purple-400":"text-gray-500 hover:bg-gray-50 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-white"),children:[(0,a.jsx)("div",{className:(0,P.cn)("flex h-8 w-8 items-center justify-center rounded-lg transition-colors",r?"bg-purple-100 text-purple-600 dark:bg-purple-900/40 dark:text-purple-400":"bg-gray-100 text-gray-400 group-hover:bg-gray-200 group-hover:text-gray-600 dark:bg-gray-800 dark:text-gray-500 dark:group-hover:bg-gray-700"),children:(0,a.jsx)(e.icon,{className:"h-4 w-4"})}),e.label,r&&(0,a.jsx)(Z.Z,{className:"h-4 w-4 ml-auto text-purple-400"})]},e.href)})]})]}),(0,a.jsxs)("div",{className:"border-t border-gray-100 p-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 px-2 mb-3",children:[(0,a.jsx)("div",{className:"flex h-9 w-9 items-center justify-center rounded-full bg-gradient-to-br from-green-400 to-green-600 shadow-sm",children:(0,a.jsx)(j.Z,{className:"h-4 w-4 text-white"})}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium text-gray-900 dark:text-white truncate",children:r||"Usu\xe1rio"}),(0,a.jsx)("p",{className:"text-[10px] text-gray-400 dark:text-gray-500",children:n?"Super Admin":"Plano B\xe1sico"})]})]}),(0,a.jsxs)("button",{onClick:s,className:"flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-sm font-medium text-gray-500 hover:bg-red-50 hover:text-red-600 dark:text-gray-400 dark:hover:bg-red-900/20 dark:hover:text-red-400 transition-all duration-200",children:[(0,a.jsx)("div",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-gray-100 dark:bg-gray-800 group-hover:bg-red-100",children:(0,a.jsx)(N.Z,{className:"h-4 w-4"})}),"Sair da conta"]})]})]})}function W(){let e=(0,s.usePathname)(),t=(0,s.useRouter)(),[r,i]=(0,n.useState)(""),[l,o]=(0,n.useState)(!1),[c,d]=(0,n.useState)(!1),[h,u]=(0,n.useState)(!1);if((0,n.useEffect)(()=>{if(!localStorage.getItem("accessToken")){o(!1);return}o(!0);let e=localStorage.getItem("user");if(e)try{let t=JSON.parse(e);i(t.email||"");let r=Array.isArray(t.roles)&&t.roles.includes("SUPER_ADMIN");d(r)}catch(e){localStorage.removeItem("accessToken"),localStorage.removeItem("refreshToken"),localStorage.removeItem("user"),o(!1)}},[e]),(0,n.useEffect)(()=>{u(!1)},[e]),(0,n.useEffect)(()=>(h?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[h]),_.some(t=>e.startsWith(t))||!l)return null;function g(){localStorage.removeItem("accessToken"),localStorage.removeItem("refreshToken"),localStorage.removeItem("user"),t.push("/login")}return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{onClick:()=>u(!0),className:"fixed top-4 left-4 z-50 flex h-10 w-10 items-center justify-center rounded-xl bg-white shadow-lg border border-gray-200 text-gray-600 hover:bg-gray-50 transition-colors lg:hidden",children:(0,a.jsx)(M,{className:"h-5 w-5"})}),(0,a.jsx)("aside",{className:"hidden lg:flex fixed left-0 top-0 z-40 h-screen w-64 border-r border-gray-100 bg-white dark:bg-gray-900 flex-col",children:(0,a.jsx)(C,{pathname:e,userEmail:r,isAdmin:c,handleLogout:g})}),h&&(0,a.jsxs)("div",{className:"fixed inset-0 z-50 lg:hidden",children:[(0,a.jsx)("div",{className:"fixed inset-0 bg-black/40 backdrop-blur-sm transition-opacity",onClick:()=>u(!1)}),(0,a.jsxs)("aside",{className:"fixed left-0 top-0 h-full w-72 bg-white dark:bg-gray-900 shadow-2xl flex flex-col animate-in slide-in-from-left duration-300",children:[(0,a.jsx)("button",{onClick:()=>u(!1),className:"absolute top-4 right-4 flex h-8 w-8 items-center justify-center rounded-lg bg-gray-100 text-gray-500 hover:bg-gray-200 transition-colors",children:(0,a.jsx)(S.Z,{className:"h-4 w-4"})}),(0,a.jsx)(C,{pathname:e,userEmail:r,isAdmin:c,handleLogout:g})]})]})]})}let I=["/dashboard","/instances","/chatbot","/birthday","/webhooks","/tokens","/logs","/settings","/messages","/admin"];function q(e){let{children:t}=e,r=(0,s.usePathname)(),[i,l]=(0,n.useState)(!1),o=I.some(e=>r.startsWith(e));return((0,n.useEffect)(()=>{l(!0),"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js").then(e=>{e.update().catch(()=>{})}).catch(()=>{})},[]),o)?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(W,{}),(0,a.jsx)("main",{className:"min-h-screen bg-gray-50/80 dark:bg-gray-900 lg:ml-64",children:t})]}):(0,a.jsx)(a.Fragment,{children:t})}},1657:function(e,t,r){"use strict";r.d(t,{cn:function(){return s}});var a=r(3167),n=r(1367);function s(){for(var e=arguments.length,t=Array(e),r=0;r