import type { Metadata } from "next";
import { NextIntlClientProvider } from "next-intl";
import { getLocale, getMessages } from "next-intl/server";
import Providers from "./providers";
import { auth } from "@/auth";

// Styles
import "bootstrap/dist/css/bootstrap.min.css";
import "@limitless/ui/css";
import "@/styles/all.min.css";
import "@/styles/sidebar-overrides.css";
import "@/styles/icons/phosphor/styles.min.css";

export const metadata: Metadata = {
  title: "GSC My Settings",
  description: "GoSec Cloud Personal Settings",
  icons: {
    icon: "data:image/x-icon;base64,AA",
  },
};

export default async function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  const locale = await getLocale();
  const messages = await getMessages();
  const session = await auth();
  const accessToken = (session?.user as { accessToken?: string } | undefined)?.accessToken ?? null;

  return (
    <html lang={locale}>
      <body>
        <NextIntlClientProvider messages={messages}>
          <Providers accessToken={accessToken}>{children}</Providers>
        </NextIntlClientProvider>
      </body>
    </html>
  );
}
