
import React from 'react';
import { createRoot } from 'react-dom/client';
import App from './App';

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

const globalWindow = window as any;

// Ensure we only create the root once even if the script is re-executed
if (!globalWindow._reactRoot) {
  globalWindow._reactRoot = createRoot(rootElement);
}

globalWindow._reactRoot.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>
);
