import type { Metadata } from "next";
import { cookies } from "next/headers";
import { Host_Grotesk, Inclusive_Sans, Inter } from "next/font/google";
import { AuthProvider } from "./context/AuthContext";
import { LanguageProvider } from "./context/LanguageContext";
import { DEFAULT_LOCALE, isLocale } from "./i18n/locales";
import "bootstrap/dist/css/bootstrap.min.css";
import "./globals.css";
import BodyClass from "./BodyClass";

import BootstrapClient from "./components/layout/BootstrapClient";
import PushNotificationManager from "./components/PushNotificationManager";
import { Toaster } from "react-hot-toast";

const hostGrotesk = Host_Grotesk({
  variable: "--font-host",
  subsets: ["latin"],
  display: "swap",
});

// const inclusiveSans = Inclusive_Sans({
//   variable: "--font-inclusive",
//   subsets: ["latin"],
//   weight: ["400"],
//   display: "swap",
// });

const inter = Inter({
  variable: "--font-inter",
  subsets: ["latin"],
  display: "swap",
});

export const metadata: Metadata = {
  title: "AstroEye",
  description: "Generated by create next app",
};

export default async function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode;
}>) {
  const cookieStore = await cookies();
  const cookieLocale = cookieStore.get("NEXT_LOCALE")?.value;
  const locale = isLocale(cookieLocale) ? cookieLocale : DEFAULT_LOCALE;

  return (
    <html
      lang={locale}
      className={`${hostGrotesk.variable} ${inter.variable}`}
    >
      <body>
        <BodyClass />
        <BootstrapClient />
        <Toaster position="top-right"/>
        <AuthProvider>
        <LanguageProvider>
        <PushNotificationManager />
        {children}
        </LanguageProvider>
        </AuthProvider>
      </body>
    </html>
  );
}
