import React, { Suspense } from "react";
import ReactDOM from "react-dom/client";
import ThemeProvider from "./providers/ThemeProvider";
import { CssBaseline } from "@mui/material";
import AppRouter from "./components/AppRouter";
import { TuitioProvider } from "@flare/tuitio-client-react";
import { ToastProvider } from "./providers";
import env from "./utils/env";
import "./utils/i18n";

const root = ReactDOM.createRoot(document.getElementById("root") as HTMLElement);

root.render(
  <TuitioProvider tuitioUrl={env.REACT_APP_TUITIO_URL}>
    <ThemeProvider>
      <CssBaseline />
      <Suspense fallback={<div>Loading...</div>}>
        <ToastProvider>
          <AppRouter />
        </ToastProvider>
      </Suspense>
    </ThemeProvider>
  </TuitioProvider>
);
