import { useEffect as n } from "react";
import { useDraft as s } from "../../../../../use-page-data.js";
function l() {
  const t = s(), e = t.previewTheme ?? t.theme;
  return n(() => {
    f(), d(e.typography);
  }, [e.typography]), e.typography;
}
function d(t) {
  for (const e of ["body", "heading"])
    if (t[e].type === "google") {
      const o = document.getElementById(`stylesheet-font-${e}`);
      o.href = `https://fonts.googleapis.com/css2?family=${t[e].family.replace(
        / /g,
        "+"
      )}&display=swap`;
    }
}
function f() {
  for (const t of ["body", "heading"]) {
    const e = `stylesheet-font-${t}`;
    document.getElementById(e) && document.getElementById(e)?.remove();
    const o = document.createElement("link");
    o.rel = "stylesheet", o.id = e, document.head.appendChild(o);
  }
}
export {
  l as useFontWatcher
};
//# sourceMappingURL=use-font-watcher.js.map
