export default defineNuxtRouteMiddleware((to, from) => {
  // تعریف سایدبار پیش‌فرض
  const defaultSidebar = {
    topMenu: [
      {
        label: "پیشخوان",
        icon: "i-lucide-home",
        to: "/dashboard/base",
        active: true,
      },
      { label: "اعلانات", icon: "i-lucide-bell", to: "/", badge: "۳" },
      { label: "علاقه‌مندی‌ها", icon: "i-lucide-bookmark", to: "/" },
      { label: "تقویم", icon: "i-lucide-calendar", to: "/" },
    ],
    bottomMenu: [
      { label: "تم", icon: "i-lucide-palette", to: "/" },
      { label: "زبان", icon: "i-lucide-languages", to: "/" },
      { label: "حساب کاربری", icon: "i-lucide-user", to: "/" },
      { label: "راهنما", icon: "i-lucide-help-circle", to: "/" },
    ],
  };

  // بررسی آیا route فعلی sidebarItems دارد یا نه
  const routeSidebar = to.meta?.sidebarItems;

  if (routeSidebar) {
    // استفاده از سایدبار تعریف شده در route
    useState("sidebar", () => routeSidebar);
  } else {
    // استفاده از پیش‌فرض
    useState("sidebar", () => defaultSidebar);
  }
});
