import "@fontsource/roboto/300.css";
import "@fontsource/roboto/400.css";
import "@fontsource/roboto/500.css";
import "@fontsource/roboto/700.css";

import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import "./index.css";
import { App } from "./App";
import { AlertDialogProvider } from "./hooks/contexts_provider/AlertDialogProvider";
import { ConfirmDialogProvider } from "./hooks/contexts_provider/ConfirmDialogProvider";
import { SnackbarProvider } from "./hooks/contexts_provider/SnackbarProvider";
import { LoadingMessageProvider } from "./hooks/contexts_provider/LoadingMessageProvider";
import { AsyncWidget } from "./widgets/AsyncWidget";
import { ServerApi } from "./api/ServerApi";

createRoot(document.getElementById("root")!).render(
  <StrictMode>
    <AlertDialogProvider>
      <ConfirmDialogProvider>
        <SnackbarProvider>
          <LoadingMessageProvider>
            <AsyncWidget
              loadKey={1}
              load={async () => {
                await ServerApi.LoadConfig();
              }}
              errMsg="Failed to load static server configuration!"
              build={() => <App />}
            />
          </LoadingMessageProvider>
        </SnackbarProvider>
      </ConfirmDialogProvider>
    </AlertDialogProvider>
  </StrictMode>
);
