import React from 'react';
import ReactDOM from 'react-dom/client';
import { BrowserRouter as Router } from 'react-router-dom';
import App from '@/App.jsx';
import '@/index.css';

/**
 * @description Registra o Service Worker para funcionalidades offline e PWA.
 * Verifica se o navegador suporta Service Workers e tenta registrá-lo.
 */
if ('serviceWorker' in navigator) {
  window.addEventListener('load', () => {
    navigator.serviceWorker.register('/sw.js').then(registration => {
      console.log('SW registered: ', registration);
    }).catch(registrationError => {
      console.log('SW registration failed: ', registrationError);
    });
  });
}

/**
 * @description Ponto de entrada principal da aplicação React.
 * Renderiza o componente `App` dentro de um `React.StrictMode` e `BrowserRouter`.
 */
ReactDOM.createRoot(document.getElementById('root')).render(
  <React.StrictMode>
    <Router>
      <App />
    </Router>
  </React.StrictMode>
);