
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';

// Suppress benign ResizeObserver errors that can occur with 3rd party scripts (like AdSense)
// resizing elements within the same animation frame.
const resizeObserverLoopErr = 'ResizeObserver loop completed with undelivered notifications.';
const resizeObserverLimitErr = 'ResizeObserver loop limit exceeded';
// Suppress AdSense specific benign error when container temporarily shrinks
const adsenseNoSlotErr = 'adsbygoogle.push() error: No slot size for availableWidth';

window.addEventListener('error', (event) => {
  if (
    event.message === resizeObserverLoopErr || 
    event.message === resizeObserverLimitErr ||
    (event.message && event.message.includes(adsenseNoSlotErr))
  ) {
    event.stopImmediatePropagation();
  }
});

const rootElement = document.getElementById('root');
if (!rootElement) {
  throw new Error("Could not find root element to mount to");
}

const root = ReactDOM.createRoot(rootElement);
root.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>
);
