import { useHotkeys as t } from "../../../../../node_modules/.pnpm/react-hotkeys-hook@4.6.1_react-dom@18.3.0-canary-3d9b20132-20240124_react@18.3.0-canary_491cd93b885e50c46ba63c9769517513/node_modules/react-hotkeys-hook/dist/react-hotkeys-hook.esm.js";
import { useEditorHelpers as v, usePreviewMode as w, useSelectedBrickId as D, useSelectedSectionId as b } from "../../../../../use-editor.js";
import "react";
import "../../../../../node_modules/.pnpm/@formkit_auto-animate@0.8.2/node_modules/@formkit/auto-animate/index.js";
import { toast as B } from "../../../../../node_modules/.pnpm/react-hot-toast@2.5.2_react-dom@18.3.0-canary-3d9b20132-20240124_react@18.3.0-canary-3d_c02c1e17bf76c343fd22d1f22394ecf5/node_modules/react-hot-toast/dist/index.js";
import { useDraftHelpers as h, useDraft as y, useBrick as P, useDraftUndoManager as A } from "../../../../../use-page-data.js";
function C() {
  const n = v(), i = h(), a = y(), d = w(), o = D(), c = b(), s = P(o), { undo: p, redo: f } = A();
  t("esc", () => {
    n.deselectBrick(), n.setSelectedSectionId(), n.hidePanel();
  }), t("mod+c", () => {
    window.getSelection()?.rangeCount || console.debug("mod+c pressed");
  }), t(["backspace", "del"], (e) => {
    o && (e.preventDefault(), i.deleteBrick(o), n.deselectBrick(o), n.hidePanel("inspector"));
  }), t("s", (e) => {
    e.preventDefault(), n.togglePanel("settings");
  }), t("l", (e) => {
    e.preventDefault(), n.togglePanel("library");
  }), t("t", (e) => {
    e.preventDefault(), n.togglePanel("theme");
  }), t("p", (e) => {
    e.preventDefault(), n.togglePanel();
  }), t(["mod+z", "ctrl+z"], (e) => {
    e.preventDefault(), p();
  }), t(["mod+shift+z", "ctrl+shift+z"], (e) => {
    e.preventDefault(), f();
  }), t(
    ["up", "left"],
    (e) => {
      if (o) {
        e.preventDefault();
        const r = i.getParentBrick(o);
        r ? (r.props.direction === "flex-row" ? "ArrowLeft" : "ArrowUp") === e.key && i.moveBrick(o, "previous") : e.key === "ArrowLeft" && i.moveBrick(o, "previous");
      } else if (c && e.key === "ArrowUp") {
        e.preventDefault(), i.moveSectionUp(c);
        const r = document.getElementById(c);
        r && r.scrollIntoView({ behavior: "smooth", block: "center" });
      }
    },
    {
      enableOnContentEditable: !1
    }
  ), t(
    ["down", "right"],
    (e) => {
      if (o) {
        e.preventDefault();
        const r = i.getParentBrick(o);
        r ? (r.props.direction === "flex-row" ? "ArrowRight" : "ArrowDown") === e.key && i.moveBrick(o, "next") : e.key === "ArrowRight" && i.moveBrick(o, "next");
      } else if (c && e.key === "ArrowDown") {
        e.preventDefault(), i.moveSectionDown(c);
        const r = document.getElementById(c);
        r && r.scrollIntoView({ behavior: "smooth", block: "center" });
      }
    },
    {
      enableOnContentEditable: !1
    }
  ), t("mod+d", (e) => {
    e.preventDefault(), o && (i.duplicateBrick(o), B("Brick duplicated", {
      id: "duplicate-brick"
    }));
  }), t("mod+j", (e) => {
    e.preventDefault(), n.toggleEditorEnabled();
  }), t("mod+g", (e) => {
    e.preventDefault(), console.log("Debugging draft:");
    const { sections: r, themes: l, siteAttributes: u, sitemap: g, pageAttributes: m, brickMap: k } = a;
    console.log({ sections: r, themes: l, siteAttributes: u, sitemap: g, pageAttributes: m, brickMap: k });
  }), t(
    "space",
    (e) => {
      e.target.classList.contains("tiptap") || (e.preventDefault(), e.stopPropagation(), s && i.updateBrickProps(
        s.id,
        {
          grow: !s.props.grow
        },
        d === "mobile"
      ));
    },
    {
      enableOnContentEditable: !0
    }
  );
}
export {
  C as useEditorHotKeys
};
//# sourceMappingURL=use-editor-hot-keys.js.map
