import type { Metadata } from "next";
import "./globals.css";
import ReduxProvider from "@/state/ReduxProvider";
import LayoutWrapper from "@/components/shared/LayoutWrapper";
import { DEFAULT_DESCRIPTION, DEFAULT_TITLE, IS_INDEXABLE_SITE, SITE_NAME, SITE_URL } from "@/lib/seo";

// Defaults for every page; pages override title/description/canonical (see lib/seo.ts pageMetadata)
export const metadata: Metadata = {
  metadataBase: new URL(SITE_URL),
  title: {
    default: DEFAULT_TITLE,
    template: `%s | ${SITE_NAME}`,
  },
  description: DEFAULT_DESCRIPTION,
  applicationName: SITE_NAME,
  openGraph: {
    type: "website",
    siteName: SITE_NAME,
    locale: "en_AU",
    title: DEFAULT_TITLE,
    description: DEFAULT_DESCRIPTION,
  },
  // Staging / local builds must never be indexed
  ...(!IS_INDEXABLE_SITE && { robots: { index: false, follow: false } }),
};

export default function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  return (
    <html lang="en">
      <body className="flex flex-col min-h-screen">
        <ReduxProvider>
          <LayoutWrapper>{children}</LayoutWrapper>
        </ReduxProvider>
      </body>
    </html>
  );
}
