import { StrictMode } from "react"
import { createRoot } from "react-dom/client"
import { BrowserRouter } from "react-router-dom"
import App from "./App"
import { AuthProvider } from "./contexts/AuthContext"
import { BrandingProvider } from "./contexts/BrandingContext"
import { ToastHost } from "./utils/toast"
import "antd/dist/reset.css"
import "./index.css"

createRoot(document.getElementById("root")!).render(
  <StrictMode>
    <BrowserRouter>
      <BrandingProvider><AuthProvider><App /><ToastHost /></AuthProvider></BrandingProvider>
    </BrowserRouter>
  </StrictMode>
)

if ("serviceWorker" in navigator) {
  window.addEventListener("load", () => {
    navigator.serviceWorker.register("/sw.js").catch(() => {
      // Service worker is only used for optional store image caching.
    })
  })
}
