import React, { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import App from "./App";

let frontendData: any;

if (typeof topPostsFrontendData !== "undefined") {
  frontendData = topPostsFrontendData;
}

if (typeof topPostsFrontendWidgetData !== "undefined") {
  frontendData = topPostsFrontendWidgetData;
}

const rootElement = document.getElementById(
  `topPosts-frontend-page${frontendData.is_widget ? "--widget-" : "-"}${
    frontendData.filter_slug
  }`
);

if (rootElement) {
  const root = createRoot(rootElement);

  root.render(
    <StrictMode>
      <App />
    </StrictMode>
  );
}
