import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import { BrowserRouter } from 'react-router-dom'
// Self-hosted variable font (one file, weights 100-900) — no CDN request, no
// render-blocking third-party origin. Fixes the default system-ui stack reading thin
// and grey on Windows (Segoe UI's regular weight is lighter than it looks on other OSes).
import '@fontsource-variable/inter'
import './index.css'
import App from './App.tsx'
import { AuthProvider } from '@/lib/auth/AuthContext'
import { watchForAppUpdates } from '@/lib/appUpdate'

// Reaching this line means the main bundle loaded, so clear the boot-reload guard in
// index.html and let a future deploy recover the same way. Kept as a literal because
// index.html cannot import from here.
try {
  sessionStorage.removeItem('stayz:boot-reload')
} catch {
  /* storage disabled: the guard degrades to reloading every time, which still recovers */
}

watchForAppUpdates()

createRoot(document.getElementById('root')!).render(
  <StrictMode>
    <BrowserRouter>
      <AuthProvider>
        <App />
      </AuthProvider>
    </BrowserRouter>
  </StrictMode>,
)
