import { j as e } from "../../../../../_virtual/jsx-runtime.js";
import { forwardRef as P } from "react";
import { useEditorHelpers as C, useDebugMode as v } from "../../../../../use-editor.js";
import "../../../../../node_modules/.pnpm/@formkit_auto-animate@0.8.2/node_modules/@formkit/auto-animate/index.js";
import { toast as M } 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 { useBrickManifest as D } from "../../shared/hooks/use-brick-manifest.js";
import { useDraftHelpers as b } from "../../../../../use-page-data.js";
import { Root as y, Trigger as S, Content as w, Label as E, Item as n, Sub as h, SubTrigger as m, SubContent as x, CheckboxItem as g, Separator as l } from "../../../../../node_modules/.pnpm/@radix-ui_themes@3.1.4_@types_react-dom@18.3.6_@types_react@18.3.3__@types_react@18.3.3_46b1dabc193c5ff5696ee783983c694e/node_modules/@radix-ui/themes/dist/esm/components/context-menu.js";
import { Portal as N } from "../../../../../node_modules/.pnpm/@radix-ui_react-portal@1.1.1_@types_react-dom@18.3.6_@types_react@18.3.3__@types_react@_d91fd04d10d265136bf0d35a7b9375b2/node_modules/@radix-ui/react-portal/dist/index.js";
const J = P(
  ({ brick: t, isContainerChild: a, children: u }, j) => {
    const i = b(), r = C(), k = v(), c = D(t.type), f = i.canMoveTo(t.id, "previous"), B = i.canMoveTo(t.id, "next"), s = i.getParentBrick(t.id), d = s ? document.getElementById(s.id) : null, p = d && getComputedStyle(d).flexDirection || "row";
    return /* @__PURE__ */ e.jsxs(
      y,
      {
        modal: !1,
        onOpenChange: (o) => {
          r.setContextMenuVisible(o);
        },
        children: [
          /* @__PURE__ */ e.jsx(S, { disabled: k, ref: j, children: u }),
          /* @__PURE__ */ e.jsx(N, { children: /* @__PURE__ */ e.jsxs(w, { className: "nodrag", size: "2", children: [
            /* @__PURE__ */ e.jsxs(E, { className: "!text-sm", children: [
              c.name,
              " (brick)"
            ] }),
            c.duplicatable && /* @__PURE__ */ e.jsx(
              n,
              {
                shortcut: "⌘D",
                onClick: (o) => {
                  o.stopPropagation(), i.duplicateBrick(t.id);
                },
                children: "Duplicate"
              }
            ),
            /* @__PURE__ */ e.jsx(
              n,
              {
                onClick: (o) => {
                  o.stopPropagation(), navigator.clipboard.writeText(JSON.stringify(t)), M(
                    `Brick "${c.name}" copied to clipboard. You can paste it on this page or another page.`,
                    {
                      className: "min-w-fit"
                    }
                  );
                },
                children: "Copy brick"
              }
            ),
            f && /* @__PURE__ */ e.jsx(
              n,
              {
                shortcut: a ? "⌘↑" : "⌘←",
                onClick: (o) => {
                  o.stopPropagation(), i.moveBrick(t.id, "previous");
                },
                children: a && p === "column" ? "Move up" : "Move left"
              }
            ),
            B && /* @__PURE__ */ e.jsx(
              n,
              {
                shortcut: a ? "⌘↓" : "⌘→",
                onClick: (o) => {
                  o.stopPropagation(), i.moveBrick(t.id, "next");
                },
                children: a && p === "column" ? "Move down" : "Move right"
              }
            ),
            /* @__PURE__ */ e.jsxs(h, { children: [
              /* @__PURE__ */ e.jsx(m, { children: "Visible on" }),
              /* @__PURE__ */ e.jsxs(x, { children: [
                /* @__PURE__ */ e.jsx(
                  g,
                  {
                    checked: !t.props.hidden?.mobile,
                    onClick: (o) => o.stopPropagation(),
                    onCheckedChange: () => i.toggleBrickVisibilityPerBreakpoint(t.id, "mobile"),
                    children: "Mobile"
                  }
                ),
                /* @__PURE__ */ e.jsx(
                  g,
                  {
                    checked: !t.props.hidden?.desktop,
                    onClick: (o) => o.stopPropagation(),
                    onCheckedChange: () => i.toggleBrickVisibilityPerBreakpoint(t.id, "desktop"),
                    children: "Desktop"
                  }
                )
              ] })
            ] }),
            s && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
              /* @__PURE__ */ e.jsx(l, {}),
              /* @__PURE__ */ e.jsxs(h, { children: [
                /* @__PURE__ */ e.jsx(m, { children: "Parent container" }),
                /* @__PURE__ */ e.jsxs(x, { children: [
                  /* @__PURE__ */ e.jsx(
                    n,
                    {
                      onClick: (o) => {
                        o.stopPropagation(), i.duplicateBrick(s.id);
                      },
                      children: "Duplicate container"
                    }
                  ),
                  /* @__PURE__ */ e.jsx(
                    n,
                    {
                      onClick: (o) => {
                        o.stopPropagation(), r.setSelectedBrickId(s.id), r.setPanel("inspector");
                      },
                      children: "Edit container"
                    }
                  ),
                  /* @__PURE__ */ e.jsx(l, {}),
                  /* @__PURE__ */ e.jsx(
                    n,
                    {
                      shortcut: "⌫",
                      color: "red",
                      onClick: (o) => {
                        o.stopPropagation(), i.deleteBrick(s.id), r.deselectBrick(s.id), r.hidePanel("inspector");
                      },
                      children: "Delete container"
                    }
                  )
                ] })
              ] }),
              /* @__PURE__ */ e.jsx(
                n,
                {
                  onClick: (o) => {
                    o.stopPropagation(), i.detachBrickFromContainer(t.id);
                  },
                  children: "Detach from parent"
                }
              )
            ] }),
            c.deletable && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
              /* @__PURE__ */ e.jsx(l, {}),
              /* @__PURE__ */ e.jsx(
                n,
                {
                  shortcut: "⌫",
                  color: "red",
                  onClick: (o) => {
                    o.stopPropagation(), i.deleteBrick(t.id), r.deselectBrick(t.id), r.hidePanel("inspector");
                  },
                  children: "Delete"
                }
              )
            ] })
          ] }) })
        ]
      }
    );
  }
);
export {
  J as default
};
//# sourceMappingURL=EditableBrickContextMenu.js.map
