import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import App from './App.jsx';
import './styles/global.css';
import { getThemeAccent } from './utils/themeAccent.js';
import { applyThemeMode, getThemeMode, watchAutoThemeMode } from './utils/themeMode.js';

applyThemeMode(getThemeMode());
document.documentElement.dataset.accent = getThemeAccent();
watchAutoThemeMode();

createRoot(document.getElementById('root')).render(
  <StrictMode>
    <App />
  </StrictMode>,
);

if (import.meta.env.PROD && 'serviceWorker' in navigator) {
  window.addEventListener('load', () => {
    navigator.serviceWorker.register('/pwa-sw.js').catch(() => {});
  });
}
