import React from "react";
import ReactDOM from "react-dom/client";
import "@xyflow/react/dist/style.css";
import "./styles/index.css";
import App from "./App";
import { reportError } from "./utils/errorReporting";

window.addEventListener("unhandledrejection", (event) => {
  reportError(event.reason, "rejection");
});

window.addEventListener("error", (event) => {
  if (event.error) reportError(event.error, "unhandled");
});

const root = document.getElementById("root");

if (!root) {
  throw new Error("Root element not found");
}

ReactDOM.createRoot(root).render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
);
