"use client";
import { useState } from "react";
const EXAMPLE_NOTIFICATIONS = [
  {
    id: "1",
    title: "Bienvenido al Dashboard",
    message: "Tu cuenta ha sido configurada exitosamente. Explora todas las funcionalidades disponibles.",
    type: "success",
    timestamp: new Date(Date.now() - 2 * 60 * 1e3),
    // 2 minutos atrás
    isRead: false,
    actionUrl: "/dashboard/settings/profile"
  },
  {
    id: "2",
    title: "Nueva tarea pendiente",
    message: "Tienes 3 tareas sin completar. \xBFQuieres revisarlas ahora?",
    type: "info",
    timestamp: new Date(Date.now() - 15 * 60 * 1e3),
    // 15 minutos atrás
    isRead: false,
    actionUrl: "/dashboard/tasks"
  },
  {
    id: "3",
    title: "Configuraci\xF3n de seguridad",
    message: "Te recomendamos activar la autenticaci\xF3n de dos factores para mayor seguridad.",
    type: "warning",
    timestamp: new Date(Date.now() - 2 * 60 * 60 * 1e3),
    // 2 horas atrás
    isRead: true,
    actionUrl: "/dashboard/settings/security"
  },
  {
    id: "4",
    title: "Perfil actualizado",
    message: "Tu informaci\xF3n de perfil ha sido actualizada correctamente.",
    type: "success",
    timestamp: new Date(Date.now() - 24 * 60 * 60 * 1e3),
    // 1 día atrás
    isRead: true,
    actionUrl: "/dashboard/settings/profile"
  },
  {
    id: "5",
    title: "Nuevo login detectado",
    message: "Se detect\xF3 un nuevo inicio de sesi\xF3n desde Chrome en Ciudad de M\xE9xico.",
    type: "info",
    timestamp: new Date(Date.now() - 3 * 24 * 60 * 60 * 1e3),
    // 3 días atrás
    isRead: true
  },
  {
    id: "6",
    title: "Backup completado",
    message: "Se ha realizado una copia de seguridad de tus datos exitosamente.",
    type: "success",
    timestamp: new Date(Date.now() - 7 * 24 * 60 * 60 * 1e3),
    // 1 semana atrás
    isRead: true
  }
];
function useNotifications() {
  const [notifications, setNotifications] = useState(EXAMPLE_NOTIFICATIONS);
  const markAsRead = (notificationId) => {
    setNotifications(
      (prev) => prev.map(
        (notification) => notification.id === notificationId ? { ...notification, isRead: true } : notification
      )
    );
  };
  const markAllAsRead = () => {
    setNotifications(
      (prev) => prev.map((notification) => ({ ...notification, isRead: true }))
    );
  };
  const deleteNotification = (notificationId) => {
    setNotifications(
      (prev) => prev.filter((notification) => notification.id !== notificationId)
    );
  };
  const addNotification = (notification) => {
    const newNotification = {
      ...notification,
      id: Date.now().toString(),
      timestamp: /* @__PURE__ */ new Date()
    };
    setNotifications((prev) => [newNotification, ...prev]);
  };
  const unreadCount = notifications.filter((n) => !n.isRead).length;
  const sortedNotifications = [...notifications].sort(
    (a, b) => b.timestamp.getTime() - a.timestamp.getTime()
  );
  return {
    notifications: sortedNotifications,
    unreadCount,
    markAsRead,
    markAllAsRead,
    deleteNotification,
    addNotification
  };
}
export {
  useNotifications
};
