/// <reference no-default-lib="true" />
/// <reference lib="esnext" />
/// <reference lib="dom" />
/** @jsx h */
import { h, render } from "../preact/mod.tsx";
import { App } from "./App.tsx";
import { Scrapbox } from "../scrapbox-jp%2Ftypes/userscript.ts";
declare const scrapbox: Scrapbox;

const app = document.createElement("div");
const shadowRoot = app.attachShadow({ mode: "open" });
document.body.append(app);
const ops = await new Promise(
  (resolve) => render(<App getController={resolve} />, shadowRoot)
);

scrapbox.PageMenu.addItem({
  title: "Ex Drawing",
  onClick: () => {
    ops?.open?.();
  },
});