"use client";
import { jsxs as e, jsx as t, Fragment as s } from "react/jsx-runtime";
import { useAppDispatch as A } from "../../hooks/use-app-dispatch.js";
import { BuilderRightPanelType as D } from "../../store/app-slice.js";
import { useState as j } from "react";
import { useFrame as k } from "../../hooks/use-frame.js";
import { selectBlock as m, duplicateBlock as E, copyToClipboard as F, removeBlock as R } from "../../store/builder-slice.js";
import { ContextMenu as T, ContextMenuTrigger as w, ContextMenuPortal as z, ContextMenuContent as L, ContextMenuItem as r, ContextMenuSeparator as h, ContextMenuShortcut as c } from "./context-menu.js";
import { useAppSelector as N } from "../../hooks/use-app-selector.js";
import { getBlock as O } from "../../../../../store/selectors.js";
import { useActionContext as Y } from "../../contexts/action-context.js";
const Z = ({ blockId: o, children: u }) => {
  var p;
  const n = A(), {
    save: C,
    pasteFromClipboard: d,
    getPlatformSpecificCopyShortcut: f,
    getPlatformSpecificPasteShortcut: g,
    getPlatformSpecificSaveShortcut: S,
    toggleRightPanel: x,
    getClipboardData: P
  } = Y(), { document: a } = k(), [M, y] = j(!0), l = N(O(o)), i = l == null ? void 0 : l.type;
  return /* @__PURE__ */ e(
    T,
    {
      onOpenChange: async (B) => {
        if (B) {
          const v = await P();
          y(!!v);
        }
      },
      children: [
        /* @__PURE__ */ t(w, { asChild: !0, children: u }),
        /* @__PURE__ */ t(z, { container: a == null ? void 0 : a.body, children: /* @__PURE__ */ e(L, { children: [
          i !== "root" && /* @__PURE__ */ e(s, { children: [
            /* @__PURE__ */ e(r, { onClick: () => n(m(o)), children: [
              "Edit ",
              /* @__PURE__ */ t("span", { className: "ml-1.5 capitalize", children: (p = i == null ? void 0 : i.split("-")) == null ? void 0 : p.join(" ") })
            ] }),
            /* @__PURE__ */ t(r, { onClick: () => n(E({ blockId: o })), children: "Duplicate" }),
            /* @__PURE__ */ t(h, {}),
            /* @__PURE__ */ e(r, { onClick: () => n(F({ blockId: o })), children: [
              "Copy ",
              /* @__PURE__ */ t(c, { children: f() })
            ] })
          ] }),
          /* @__PURE__ */ e(r, { disabled: !M, onClick: () => d({ blockId: o }), children: [
            "Paste ",
            /* @__PURE__ */ t(c, { children: g() })
          ] }),
          /* @__PURE__ */ t(h, {}),
          /* @__PURE__ */ t(
            r,
            {
              onClick: () => {
                i !== "root" && n(m(o)), x(D.LAYER);
              },
              children: "Structure"
            }
          ),
          /* @__PURE__ */ e(r, { onClick: C, children: [
            "Save",
            /* @__PURE__ */ t(c, { children: S() })
          ] }),
          i !== "root" && /* @__PURE__ */ t(s, { children: /* @__PURE__ */ e(r, { onClick: () => n(R(o)), children: [
            "Delete",
            /* @__PURE__ */ t(c, { children: "⌦" })
          ] }) })
        ] }) })
      ]
    }
  );
};
export {
  Z as EditorContextMenu
};
//# sourceMappingURL=editor-context-menu.js.map
