"use client";

import { ThemeProvider } from "next-themes";
import { Toaster } from "@/components/ui/sonner";
import { TooltipProvider } from "@/components/ui/tooltip";
import { I18nProvider, type Locale } from "@/lib/i18n/provider";
import en from "@/messages/en.json";
import fr from "@/messages/fr.json";

const messages = { en, fr } as Record<string, Record<string, unknown>>;

export function Providers({
  children,
  initialLocale,
}: {
  children: React.ReactNode;
  initialLocale?: Locale;
}) {
  return (
    <ThemeProvider attribute="class" defaultTheme="system" enableSystem>
      <I18nProvider messages={messages} initialLocale={initialLocale}>
        <TooltipProvider>
          {children}
          <Toaster richColors position="top-right" />
        </TooltipProvider>
      </I18nProvider>
    </ThemeProvider>
  );
}
