import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import { applyNodedcTheme } from "@nodedc/ui-core";
import "@nodedc/tokens/tokens.css";
import "@nodedc/tokens/themes.css";
import "@nodedc/ui-core/styles.css";

import App from "./App";
import { installedDevicePlugins } from "./composition/devicePlugins";
import { DevicePluginHostProvider } from "./core/device-plugins/DevicePluginHost";
import "./styles.css";

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

if (!rootElement) {
  throw new Error("Не найден корневой элемент пункта управления.");
}

rootElement.classList.add("nodedc-ui-root");
rootElement.dataset.nodedcUi = "";
applyNodedcTheme(rootElement, { theme: "dark" });

createRoot(rootElement).render(
  <StrictMode>
    <DevicePluginHostProvider plugins={installedDevicePlugins}>
      <App />
    </DevicePluginHostProvider>
  </StrictMode>,
);
