import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import App from './App';
import './styles/global.css';

const container = document.getElementById('root');
if (!container) throw new Error('#root bulunamadi');

createRoot(container).render(
  <StrictMode>
    <App />
  </StrictMode>,
);

// PWA service worker (§17) — yalnizca production build'de kaydedilir.
if ('serviceWorker' in navigator && import.meta.env.PROD) {
  window.addEventListener('load', () => {
    void navigator.serviceWorker.register('./service-worker.js').catch((error: unknown) => {
      if (import.meta.env.DEV) console.warn('[pwa] service worker kaydedilemedi:', error);
    });
  });
}
