// Mounts whichever page component this HTML asked for.
//
// Why this file exists: when a page mixes `src=` Babel scripts with an inline
// <script type="text/babel"> block, Babel-standalone runs the src scripts a
// second time — the compiled code redeclares `Splash` and the page dies before
// React mounts. index.html never had an inline block, which is why the home
// page worked while every other page white-screened.
//
// So no page has an inline Babel block any more. Each one sets a plain
// (non-Babel) script with the component name, and this file does the mounting:
//
//   <script>window.__MOUNT__ = "CategoryPage";</script>
//   <script type="text/babel" data-presets="react" src="mount.jsx"></script>
//
// Removing the runtime Babel transpiler altogether would make this unnecessary
// and load a great deal faster — worth doing, but a bigger change.
(function () {
  const name = window.__MOUNT__;
  const { Splash, Cursor, Nav, Footer, BackToTop } = window.JMK;
  const Page = window.JMK[name];

  if (!Page) {
    console.error('[JMK] mount.jsx: window.JMK["' + name + '"] is not defined.');
    return;
  }

  ReactDOM.createRoot(document.getElementById("root")).render(
    <React.Fragment>
      <Splash />
      <Cursor />
      <Nav />
      <Page />
      <Footer />
      <BackToTop />
    </React.Fragment>
  );
})();
