import { jsx as s, jsxs as g, Fragment as I } from "react/jsx-runtime";
import * as r from "react";
import { useRef as j, useState as J, useEffect as Y, forwardRef as H, useCallback as Ve, startTransition as We } from "react";
import { a as V, b as q, f as Fe, u as Q, n as Ue, p as Xe, h as Ke, v as je, e as Je } from "./use-editor.BDXlYRYz.js";
import { h as Ye, c as qe, P as Qe, b as B, a as Ze, y as v, l as W } from "./index.D1WHzYVh.js";
import { a as et, o as tt, b as nt, c as ot, s as rt, d as at, u as st, F as it, e as ct } from "./floating-ui.react.C1E-7PBa.js";
import { c as lt, B as ut } from "./use-section-style.CihCUEtb.js";
import { m as dt } from "./menubar-styles.DM8mXdFr.js";
import { u as F } from "./schema-resolver.ByXeiTGY.js";
import { _ as T } from "./twind.D7be0E5m.js";
import { P as pt } from "./dnd.esm.ByOls-Fs.js";
import { r as K } from "./chunk-3RDGTRSB.DySNCMmQ.js";
import "@sinclair/typebox";
import { f as Z, x as mt } from "./use-page-data.BTws06Go.js";
import { H as ft, I as ee, a as ht } from "./theme.DDkAXowQ.js";
import { g as te, j as xt, A as Ct, P as Mt, C as gt, G as vt, L as wt, m as bt, n as Pt, D as Nt, r as It, s as St, k as yt, l as Et, o as Rt, p as Bt, q as kt, a as _t, v as _, w as ne, y as Tt, B as Ot, x as At, t as oe, z as zt } from "./base-menu.props.D-lzb1w2.js";
import { v as re } from "./radius.prop.CaQGG1qO.js";
import { c as k } from "./index.CQJkC40r.js";
var U = "ContextMenu", [Dt, $n] = qe(U, [
  te
]), M = te(), [Gt, ae] = Dt(U), se = (e) => {
  const { __scopeContextMenu: t, children: n, onOpenChange: a, dir: o, modal: i = !0 } = e, [c, u] = r.useState(!1), p = M(t), f = Ye(a), d = r.useCallback(
    (h) => {
      u(h), f(h);
    },
    [f]
  );
  return /* @__PURE__ */ s(
    Gt,
    {
      scope: t,
      open: c,
      onOpenChange: d,
      modal: i,
      children: /* @__PURE__ */ s(
        xt,
        {
          ...p,
          dir: o,
          open: c,
          onOpenChange: d,
          modal: i,
          children: n
        }
      )
    }
  );
};
se.displayName = U;
var ie = "ContextMenuTrigger", ce = r.forwardRef(
  (e, t) => {
    const { __scopeContextMenu: n, disabled: a = !1, ...o } = e, i = ae(ie, n), c = M(n), u = r.useRef({ x: 0, y: 0 }), p = r.useRef({
      getBoundingClientRect: () => DOMRect.fromRect({ width: 0, height: 0, ...u.current })
    }), f = r.useRef(0), d = r.useCallback(
      () => window.clearTimeout(f.current),
      []
    ), h = (l) => {
      u.current = { x: l.clientX, y: l.clientY }, i.onOpenChange(!0);
    };
    return r.useEffect(() => d, [d]), r.useEffect(() => void (a && d()), [a, d]), /* @__PURE__ */ g(I, { children: [
      /* @__PURE__ */ s(Ct, { ...c, virtualRef: p }),
      /* @__PURE__ */ s(
        Qe.span,
        {
          "data-state": i.open ? "open" : "closed",
          "data-disabled": a ? "" : void 0,
          ...o,
          ref: t,
          style: { WebkitTouchCallout: "none", ...e.style },
          onContextMenu: a ? e.onContextMenu : B(e.onContextMenu, (l) => {
            d(), h(l), l.preventDefault();
          }),
          onPointerDown: a ? e.onPointerDown : B(
            e.onPointerDown,
            O((l) => {
              d(), f.current = window.setTimeout(() => h(l), 700);
            })
          ),
          onPointerMove: a ? e.onPointerMove : B(e.onPointerMove, O(d)),
          onPointerCancel: a ? e.onPointerCancel : B(e.onPointerCancel, O(d)),
          onPointerUp: a ? e.onPointerUp : B(e.onPointerUp, O(d))
        }
      )
    ] });
  }
);
ce.displayName = ie;
var Lt = "ContextMenuPortal", le = (e) => {
  const { __scopeContextMenu: t, ...n } = e, a = M(t);
  return /* @__PURE__ */ s(Mt, { ...a, ...n });
};
le.displayName = Lt;
var ue = "ContextMenuContent", de = r.forwardRef(
  (e, t) => {
    const { __scopeContextMenu: n, ...a } = e, o = ae(ue, n), i = M(n), c = r.useRef(!1);
    return /* @__PURE__ */ s(
      gt,
      {
        ...i,
        ...a,
        ref: t,
        side: "right",
        sideOffset: 2,
        align: "start",
        onCloseAutoFocus: (u) => {
          var p;
          (p = e.onCloseAutoFocus) == null || p.call(e, u), !u.defaultPrevented && c.current && u.preventDefault(), c.current = !1;
        },
        onInteractOutside: (u) => {
          var p;
          (p = e.onInteractOutside) == null || p.call(e, u), !u.defaultPrevented && !o.modal && (c.current = !0);
        },
        style: {
          ...e.style,
          "--radix-context-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
          "--radix-context-menu-content-available-width": "var(--radix-popper-available-width)",
          "--radix-context-menu-content-available-height": "var(--radix-popper-available-height)",
          "--radix-context-menu-trigger-width": "var(--radix-popper-anchor-width)",
          "--radix-context-menu-trigger-height": "var(--radix-popper-anchor-height)"
        }
      }
    );
  }
);
de.displayName = ue;
var $t = "ContextMenuGroup", pe = r.forwardRef(
  (e, t) => {
    const { __scopeContextMenu: n, ...a } = e, o = M(n);
    return /* @__PURE__ */ s(vt, { ...o, ...a, ref: t });
  }
);
pe.displayName = $t;
var Ht = "ContextMenuLabel", me = r.forwardRef(
  (e, t) => {
    const { __scopeContextMenu: n, ...a } = e, o = M(n);
    return /* @__PURE__ */ s(wt, { ...o, ...a, ref: t });
  }
);
me.displayName = Ht;
var Vt = "ContextMenuItem", fe = r.forwardRef(
  (e, t) => {
    const { __scopeContextMenu: n, ...a } = e, o = M(n);
    return /* @__PURE__ */ s(bt, { ...o, ...a, ref: t });
  }
);
fe.displayName = Vt;
var Wt = "ContextMenuCheckboxItem", he = r.forwardRef((e, t) => {
  const { __scopeContextMenu: n, ...a } = e, o = M(n);
  return /* @__PURE__ */ s(yt, { ...o, ...a, ref: t });
});
he.displayName = Wt;
var Ft = "ContextMenuRadioGroup", xe = r.forwardRef((e, t) => {
  const { __scopeContextMenu: n, ...a } = e, o = M(n);
  return /* @__PURE__ */ s(Rt, { ...o, ...a, ref: t });
});
xe.displayName = Ft;
var Ut = "ContextMenuRadioItem", Ce = r.forwardRef((e, t) => {
  const { __scopeContextMenu: n, ...a } = e, o = M(n);
  return /* @__PURE__ */ s(Bt, { ...o, ...a, ref: t });
});
Ce.displayName = Ut;
var Xt = "ContextMenuItemIndicator", Me = r.forwardRef((e, t) => {
  const { __scopeContextMenu: n, ...a } = e, o = M(n);
  return /* @__PURE__ */ s(Et, { ...o, ...a, ref: t });
});
Me.displayName = Xt;
var Kt = "ContextMenuSeparator", ge = r.forwardRef((e, t) => {
  const { __scopeContextMenu: n, ...a } = e, o = M(n);
  return /* @__PURE__ */ s(Pt, { ...o, ...a, ref: t });
});
ge.displayName = Kt;
var jt = "ContextMenuArrow", Jt = r.forwardRef(
  (e, t) => {
    const { __scopeContextMenu: n, ...a } = e, o = M(n);
    return /* @__PURE__ */ s(kt, { ...o, ...a, ref: t });
  }
);
Jt.displayName = jt;
var Yt = "ContextMenuSub", ve = (e) => {
  const { __scopeContextMenu: t, children: n, onOpenChange: a, open: o, defaultOpen: i } = e, c = M(t), [u, p] = Ze({
    prop: o,
    defaultProp: i,
    onChange: a
  });
  return /* @__PURE__ */ s(Nt, { ...c, open: u, onOpenChange: p, children: n });
};
ve.displayName = Yt;
var qt = "ContextMenuSubTrigger", we = r.forwardRef((e, t) => {
  const { __scopeContextMenu: n, ...a } = e, o = M(n);
  return /* @__PURE__ */ s(It, { ...o, ...a, ref: t });
});
we.displayName = qt;
var Qt = "ContextMenuSubContent", be = r.forwardRef((e, t) => {
  const { __scopeContextMenu: n, ...a } = e, o = M(n);
  return /* @__PURE__ */ s(
    St,
    {
      ...o,
      ...a,
      ref: t,
      style: {
        ...e.style,
        "--radix-context-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
        "--radix-context-menu-content-available-width": "var(--radix-popper-available-width)",
        "--radix-context-menu-content-available-height": "var(--radix-popper-available-height)",
        "--radix-context-menu-trigger-width": "var(--radix-popper-anchor-width)",
        "--radix-context-menu-trigger-height": "var(--radix-popper-anchor-height)"
      }
    }
  );
});
be.displayName = Qt;
function O(e) {
  return (t) => t.pointerType !== "mouse" ? e(t) : void 0;
}
var Zt = se, en = ce, Pe = le, tn = de, nn = pe, on = me, rn = fe, an = he, sn = xe, cn = Ce, Ne = Me, ln = ge, un = ve, dn = we, pn = be;
const Ie = (e) => r.createElement(Zt, { ...e });
Ie.displayName = "ContextMenu.Root";
const Se = r.forwardRef(({ children: e, ...t }, n) => r.createElement(en, { ...t, ref: n, asChild: !0 }, _t(e)));
Se.displayName = "ContextMenu.Trigger";
const ye = r.createContext({}), Ee = r.forwardRef((e, t) => {
  const n = ft(), { size: a = _.size.default, variant: o = _.variant.default, highContrast: i = _.highContrast.default } = e, { className: c, children: u, color: p, container: f, forceMount: d, ...h } = re(e, _), l = p || n.accentColor;
  return r.createElement(Pe, { container: f, forceMount: d }, r.createElement(ee, { asChild: !0 }, r.createElement(tn, { "data-accent-color": l, alignOffset: -Number(a) * 4, collisionPadding: 10, ...h, asChild: !1, ref: t, className: v("rt-PopperContent", "rt-BaseMenuContent", "rt-ContextMenuContent", c) }, r.createElement(ne, { type: "auto" }, r.createElement("div", { className: v("rt-BaseMenuViewport", "rt-ContextMenuViewport") }, r.createElement(ye.Provider, { value: r.useMemo(() => ({ size: a, variant: o, color: l, highContrast: i }), [a, o, l, i]) }, u))))));
});
Ee.displayName = "ContextMenu.Content";
const Re = r.forwardRef(({ className: e, ...t }, n) => r.createElement(on, { ...t, asChild: !1, ref: n, className: v("rt-BaseMenuLabel", "rt-ContextMenuLabel", e) }));
Re.displayName = "ContextMenu.Label";
const b = r.forwardRef((e, t) => {
  const { className: n, children: a, color: o = Tt.color.default, shortcut: i, ...c } = e;
  return r.createElement(rn, { "data-accent-color": o, ...c, ref: t, className: v("rt-reset", "rt-BaseMenuItem", "rt-ContextMenuItem", n) }, r.createElement(W, null, a), i && r.createElement("div", { className: "rt-BaseMenuShortcut rt-ContextMenuShortcut" }, i));
});
b.displayName = "ContextMenu.Item";
const mn = r.forwardRef(({ className: e, ...t }, n) => r.createElement(nn, { ...t, asChild: !1, ref: n, className: v("rt-BaseMenuGroup", "rt-ContextMenuGroup", e) }));
mn.displayName = "ContextMenu.Group";
const fn = r.forwardRef(({ className: e, ...t }, n) => r.createElement(sn, { ...t, asChild: !1, ref: n, className: v("rt-BaseMenuRadioGroup", "rt-ContextMenuRadioGroup", e) }));
fn.displayName = "ContextMenu.RadioGroup";
const hn = r.forwardRef((e, t) => {
  const { children: n, className: a, color: o = zt.color.default, ...i } = e;
  return r.createElement(cn, { ...i, asChild: !1, ref: t, "data-accent-color": o, className: v("rt-BaseMenuItem", "rt-BaseMenuRadioItem", "rt-ContextMenuItem", "rt-ContextMenuRadioItem", a) }, r.createElement(W, null, n), r.createElement(Ne, { className: "rt-BaseMenuItemIndicator rt-ContextMenuItemIndicator" }, r.createElement(oe, { className: "rt-BaseMenuItemIndicatorIcon rt-ContextMenuItemIndicatorIcon" })));
});
hn.displayName = "ContextMenu.RadioItem";
const D = r.forwardRef((e, t) => {
  const { children: n, className: a, shortcut: o, color: i = At.color.default, ...c } = e;
  return r.createElement(an, { ...c, asChild: !1, ref: t, "data-accent-color": i, className: v("rt-BaseMenuItem", "rt-BaseMenuCheckboxItem", "rt-ContextMenuItem", "rt-ContextMenuCheckboxItem", a) }, r.createElement(W, null, n), r.createElement(Ne, { className: "rt-BaseMenuItemIndicator rt-ContextMenuItemIndicator" }, r.createElement(oe, { className: "rt-BaseMenuItemIndicatorIcon rt-ContextMenuItemIndicatorIcon" })), o && r.createElement("div", { className: "rt-BaseMenuShortcut rt-ContextMenuShortcut" }, o));
});
D.displayName = "ContextMenu.CheckboxItem";
const G = (e) => r.createElement(un, { ...e });
G.displayName = "ContextMenu.Sub";
const L = r.forwardRef((e, t) => {
  const { className: n, children: a, ...o } = e;
  return r.createElement(dn, { ...o, asChild: !1, ref: t, className: v("rt-BaseMenuItem", "rt-BaseMenuSubTrigger", "rt-ContextMenuItem", "rt-ContextMenuSubTrigger", n) }, a, r.createElement("div", { className: "rt-BaseMenuShortcut rt-ContextMenuShortcut" }, r.createElement(Ot, { className: "rt-BaseMenuSubTriggerIcon rt-ContextMenuSubTriggerIcon" })));
});
L.displayName = "ContextMenu.SubTrigger";
const $ = r.forwardRef((e, t) => {
  const { size: n, variant: a, color: o, highContrast: i } = r.useContext(ye), { className: c, children: u, container: p, forceMount: f, ...d } = re({ size: n, variant: a, color: o, highContrast: i, ...e }, _);
  return r.createElement(Pe, { container: p, forceMount: f }, r.createElement(ee, { asChild: !0 }, r.createElement(pn, { "data-accent-color": o, alignOffset: -Number(n) * 4, sideOffset: 1, collisionPadding: 10, ...d, asChild: !1, ref: t, className: v("rt-PopperContent", "rt-BaseMenuContent", "rt-BaseMenuSubContent", "rt-ContextMenuContent", "rt-ContextMenuSubContent", c) }, r.createElement(ne, { type: "auto" }, r.createElement("div", { className: v("rt-BaseMenuViewport", "rt-ContextMenuViewport") }, u)))));
});
$.displayName = "ContextMenu.SubContent";
const A = r.forwardRef(({ className: e, ...t }, n) => r.createElement(ln, { ...t, asChild: !1, ref: n, className: v("rt-BaseMenuSeparator", "rt-ContextMenuSeparator", e) }));
A.displayName = "ContextMenu.Separator";
function N({
  direction: e,
  show: t,
  manifest: n
}) {
  if (V() === "mobile" && e !== "s" && e !== "n")
    return null;
  const o = n.isContainer ? 8 : 4;
  return /* @__PURE__ */ s(
    "button",
    {
      type: "button",
      className: T(
        "resizable-handle absolute focus:outline-none",
        "overflow-visible z-[9998]",
        `resizable-handle-${e}`,
        {
          "-bottom-[2px] left-0 right-0 h-[6px] cursor-row-resize": e === "s",
          "-top-[2px] left-0 right-0 h-[6px] cursor-row-resize": e === "n",
          "top-0 -left-[2px] bottom-0 w-[6px] cursor-col-resize": e === "w",
          "top-0 -right-[2px] bottom-0 w-[6px] cursor-col-resize": e === "e",
          // sw and nw
          "-bottom-[2px] -left-[2px] w-[6px] h-[6px] cursor-nesw-resize": e === "sw",
          "-top-[2px] -left-[2px] w-[6px] h-[6px] cursor-nwse-resize": e === "nw",
          // se and ne
          "-bottom-[2px] -right-[2px] w-[6px] h-[6px] cursor-nwse-resize": e === "se",
          "-top-[2px] -right-[2px] w-[6px] h-[6px] cursor-nesw-resize": e === "ne"
        }
      ),
      children: /* @__PURE__ */ s(
        "div",
        {
          className: T(
            "opacity-0 z-[9999] group-hover/brick:opacity-100 transition-opacity absolute w-[10px] h-[10px] bg-white border-2 rounded-full shadow-md resizable-handle-dot",
            n.isContainer ? "border-orange-500" : "border-upstart-500",
            t && "opacity-100",
            {
              [`top-1/2 -translate-y-1/2 -left-[${o}px]`]: e === "w",
              [`top-1/2 -translate-y-1/2 -right-[${o}px]`]: e === "e",
              [`left-1/2 -translate-x-1/2 -top-[${o}px]`]: e === "n",
              [`left-1/2 -translate-x-1/2 -bottom-[${o}px]`]: e === "s",
              // sw and nw
              [`-bottom-[${o}px] -left-[${o}px]`]: e === "sw",
              [`-top-[${o}px] -left-[${o}px]`]: e === "nw",
              // se and ne
              [`-bottom-[${o}px] -right-[${o}px]`]: e === "se",
              [`-top-[${o}px] -right-[${o}px]`]: e === "ne"
            }
          )
        }
      )
    }
  );
}
function xn(e) {
  const { resizable: t } = e;
  return {
    canGrowVertical: t === !0 || t === "vertical",
    canGrowHorizontal: t === !0 || t === "horizontal",
    canShrinkVertical: t === !0 || t === "vertical",
    canShrinkHorizontal: t === !0 || t === "horizontal"
  };
}
function Cn(e = {}) {
  const { tolerance: t = 0, deepCheck: n = !1 } = e, a = j(null), [o, i] = J(!1);
  return Y(() => {
    const c = a.current;
    if (!c) return;
    const u = (f) => {
      const d = c.getBoundingClientRect(), { clientX: h, clientY: l } = f;
      if (!(h >= d.left - t && h <= d.right + t && l >= d.top - t && l <= d.bottom + t)) {
        i(!1);
        return;
      }
      if (n) {
        const y = document.elementFromPoint(h, l), z = y === c || c.contains(y);
        i(z);
      } else
        i(!0);
    }, p = () => {
      i(!1);
    };
    return document.addEventListener("mousemove", u), c.addEventListener("mouseleave", p), () => {
      document.removeEventListener("mousemove", u), c.removeEventListener("mouseleave", p);
    };
  }, [t, n]), { ref: a, isHovered: o };
}
function Mn(e, t, n) {
  if (!(n != null && n.isDropAnimating) || !n.dropAnimation)
    return t;
  const { draggingOver: a } = n, { moveTo: o } = n.dropAnimation;
  if (a === e) {
    const i = `translate(${o.x}px, 0px)`;
    return {
      ...t,
      transform: `${i}`
    };
  }
  return t;
}
function gn(e) {
  return ["bottom", "top"];
}
const Hn = H(
  ({ brick: e, children: t, isContainerChild: n, index: a }, o) => {
    const i = j(!1), c = q(), u = V(), { panelPosition: p } = Fe(), f = Q(), { getParentBrick: d } = Z(), h = mt(e.id), l = F(e.type), m = d(e.id), [y, z] = J(!1), Be = gn(), ke = Ue(), _e = Xe();
    l.isContainer;
    const {
      refs: E,
      floatingStyles: Te,
      update: X,
      context: Oe
    } = et({
      open: y,
      onOpenChange: z,
      whileElementsMounted: ct,
      transform: !0,
      middleware: [
        tt(l.isContainer ? { mainAxis: 8, crossAxis: 0 } : { mainAxis: 6, crossAxis: 0 }),
        nt({
          allowedPlacements: Be
        })
      ]
    }), Ae = ot(Oe, {
      handleClose: rt(),
      delay: {
        open: 50,
        close: 200
      }
    }), { getReferenceProps: ze, getFloatingProps: De } = at([Ae]);
    Y(() => {
      if (E.reference.current) {
        const C = () => {
          i.current = !0;
        }, w = () => {
          i.current = !1;
        }, S = () => {
          X(), setTimeout(() => {
            i.current = !1;
          }, 200);
        }, x = E.reference.current;
        return x.addEventListener("mousedown", w), x.addEventListener("mouseup", S), x.addEventListener("mousemove", C), () => {
          x.removeEventListener("mousedown", w), x.removeEventListener("mouseup", S), x.removeEventListener("mousemove", C);
        };
      }
    }, [E.reference, X]);
    const Ge = Ve(
      (C) => {
        const w = C.target, S = C.currentTarget;
        if (i.current || !S.matches("[data-brick]") || C.defaultPrevented && !w.closest('[data-prevented-by-editor="true"]')) {
          console.log(
            "EditableBrickWrapper: Click ignored due to mouse movement or default prevented",
            w
          );
          return;
        }
        let x = e, R = "brick";
        C.shiftKey ? m && (x = m) : (C.ctrlKey || C.metaKey) && h && (R = "section", x = h), f.hidePanel(), (p === "left" && C.clientX < window.innerWidth * 0.25 || p === "right" && C.clientX > window.innerWidth * 0.75) && f.togglePanelPosition(), We(() => {
          R === "section" ? f.setSelectedSectionId(x.id) : f.setSelectedBrickId(x.id), f.setPanel("inspector");
        }), i.current = !1, C.stopPropagation();
      },
      [p]
    ), { ref: Le, isHovered: P } = Cn({ tolerance: 6, deepCheck: !0 }), $e = lt({
      brick: e,
      editable: !0,
      selected: c === e.id,
      isContainerChild: n
    }), He = _e || !l.movable || n || u === "mobile";
    return /* @__PURE__ */ s(pt, { draggableId: e.id, index: a, isDragDisabled: He, children: (C, w) => {
      var R;
      const S = st([C.innerRef, E.setReference, o, Le]), x = xn(K[e.type]);
      return /* @__PURE__ */ s(bn, { brick: e, isContainerChild: n, children: /* @__PURE__ */ g(
        "div",
        {
          ref: S,
          ...C.draggableProps,
          ...C.dragHandleProps,
          ...ze(),
          id: e.id,
          "data-brick": !0,
          "data-brick-id": e.id,
          "data-brick-type": e.type,
          "data-last-touched": e.props.lastTouched ?? "0",
          "data-container-child": n,
          "data-draggable-for-brick-id": e.id,
          "data-brick-width": e.props.width,
          "data-brick-height": e.props.height,
          "data-brick-max-width": JSON.stringify(l.maxWidth),
          "data-brick-min-width": JSON.stringify(l.minWidth),
          style: Mn(h == null ? void 0 : h.id, C.draggableProps.style, w),
          className: T(
            $e,
            w.isDragging ? "!z-[9999] !shadow-2xl overflow-hidden !cursor-grabbing" : "hover:cursor-auto"
          ),
          onClick: Ge,
          children: [
            /* @__PURE__ */ s(ut, { brick: e, selectedBrickId: c, editable: !0 }),
            /* @__PURE__ */ s(it, { children: /* @__PURE__ */ s(
              vn,
              {
                ref: E.setFloating,
                brick: e,
                isContainerChild: n,
                style: Te,
                show: y,
                ...De()
              }
            ) }),
            ((R = K[e.type]) == null ? void 0 : R.resizable) && !ke && !w.isDragging && c === e.id && /* @__PURE__ */ g(I, { children: [
              (x.canGrowVertical || x.canShrinkVertical) && /* @__PURE__ */ g(I, { children: [
                /* @__PURE__ */ s(N, { direction: "s", show: P, manifest: l }),
                /* @__PURE__ */ s(N, { direction: "n", show: P, manifest: l })
              ] }),
              (x.canGrowHorizontal || x.canShrinkHorizontal) && /* @__PURE__ */ g(I, { children: [
                /* @__PURE__ */ s(N, { direction: "w", show: P, manifest: l }),
                /* @__PURE__ */ s(N, { direction: "e", show: P, manifest: l })
              ] }),
              (x.canGrowVertical && x.canGrowHorizontal || x.canShrinkVertical && x.canShrinkHorizontal) && /* @__PURE__ */ g(I, { children: [
                /* @__PURE__ */ s(N, { direction: "se", show: P, manifest: l }),
                /* @__PURE__ */ s(N, { direction: "sw", show: P, manifest: l }),
                /* @__PURE__ */ s(N, { direction: "ne", show: P, manifest: l }),
                /* @__PURE__ */ s(N, { direction: "nw", show: P, manifest: l })
              ] })
            ] })
          ]
        }
      ) });
    } }, e.id);
  }
), vn = H(
  ({ brick: e, style: t, isContainerChild: n, show: a, ...o }, i) => {
    const c = q(), u = F(e.type), p = je(), f = a && u.isContainer && !c || a && !u.isContainer && !n || c === e.id;
    return !f || p ? null : /* @__PURE__ */ s(
      "div",
      {
        ref: i,
        "data-ui": !0,
        "data-ui-menu-bars-container": !0,
        role: "navigation",
        className: T(
          "z-[99999] isolate text-base items-center gap-1",
          "transition-opacity duration-150 border rounded-lg",
          f ? "opacity-100 flex" : "opacity-0 hidden",
          u.isContainer ? "border-orange-300" : "border-transparent"
        ),
        style: t,
        ...o,
        children: /* @__PURE__ */ s(wn, { brick: e })
      }
    );
  }
);
function wn({ brick: e }) {
  return /* @__PURE__ */ s(
    "div",
    {
      id: `text-editor-menu-${e.id}`,
      className: T("contents", dt, "!empty:hidden")
    }
  );
}
const bn = H(
  ({ brick: e, isContainerChild: t, children: n }, a) => {
    var h, l;
    const o = Z(), i = Q(), c = Ke();
    V();
    const u = F(e.type), p = o.canMoveToWithinParent(e.id, "previous"), f = o.canMoveToWithinParent(e.id, "next"), d = o.getParentBrick(e.id);
    return /* @__PURE__ */ g(
      Ie,
      {
        modal: !1,
        onOpenChange: (m) => {
          i.setContextMenuVisible(m);
        },
        children: [
          /* @__PURE__ */ s(Se, { disabled: c, ref: a, children: n }),
          /* @__PURE__ */ s(ht, { children: /* @__PURE__ */ g(Ee, { className: "nodrag", size: "2", children: [
            /* @__PURE__ */ g(Re, { className: "!text-sm", children: [
              u.name,
              " (brick)"
            ] }),
            u.duplicatable && /* @__PURE__ */ s(
              b,
              {
                shortcut: "⌘D",
                onClick: (m) => {
                  m.stopPropagation(), o.duplicateBrick(e.id);
                },
                children: "Duplicate"
              }
            ),
            p && /* @__PURE__ */ s(
              b,
              {
                shortcut: t ? "⌘↑" : "⌘←",
                onClick: (m) => {
                  m.stopPropagation(), o.moveBrickWithin(e.id, "previous");
                },
                children: t ? "Move up" : "Move left"
              }
            ),
            f && /* @__PURE__ */ s(
              b,
              {
                shortcut: t ? "⌘↓" : "⌘→",
                onClick: (m) => {
                  m.stopPropagation(), o.moveBrickWithin(e.id, "next");
                },
                children: t ? "Move down" : "Move right"
              }
            ),
            /* @__PURE__ */ g(G, { children: [
              /* @__PURE__ */ s(L, { children: "Visible on" }),
              /* @__PURE__ */ g($, { children: [
                /* @__PURE__ */ s(
                  D,
                  {
                    checked: !((h = e.props.hidden) != null && h.mobile),
                    onClick: (m) => m.stopPropagation(),
                    onCheckedChange: () => o.toggleBrickVisibilityPerBreakpoint(e.id, "mobile"),
                    children: "Mobile"
                  }
                ),
                /* @__PURE__ */ s(
                  D,
                  {
                    checked: !((l = e.props.hidden) != null && l.desktop),
                    onClick: (m) => m.stopPropagation(),
                    onCheckedChange: () => o.toggleBrickVisibilityPerBreakpoint(e.id, "desktop"),
                    children: "Desktop"
                  }
                )
              ] })
            ] }),
            d && /* @__PURE__ */ g(I, { children: [
              /* @__PURE__ */ s(A, {}),
              /* @__PURE__ */ g(G, { children: [
                /* @__PURE__ */ s(L, { children: "Parent container" }),
                /* @__PURE__ */ g($, { children: [
                  /* @__PURE__ */ s(
                    b,
                    {
                      onClick: (m) => {
                        m.stopPropagation(), o.duplicateBrick(d.id);
                      },
                      children: "Duplicate container"
                    }
                  ),
                  /* @__PURE__ */ s(
                    b,
                    {
                      onClick: (m) => {
                        m.stopPropagation(), i.setSelectedBrickId(d.id), i.setPanel("inspector");
                      },
                      children: "Edit container"
                    }
                  ),
                  /* @__PURE__ */ s(A, {}),
                  /* @__PURE__ */ s(
                    b,
                    {
                      shortcut: "⌫",
                      color: "red",
                      onClick: (m) => {
                        m.stopPropagation(), o.deleteBrick(d.id), i.deselectBrick(d.id), i.hidePanel("inspector");
                      },
                      children: "Delete container"
                    }
                  )
                ] })
              ] }),
              /* @__PURE__ */ s(
                b,
                {
                  onClick: (m) => {
                    m.stopPropagation(), o.detachBrickFromContainer(e.id);
                  },
                  children: "Detach from parent"
                }
              )
            ] }),
            u.deletable && /* @__PURE__ */ g(I, { children: [
              /* @__PURE__ */ s(A, {}),
              /* @__PURE__ */ s(
                b,
                {
                  shortcut: "⌫",
                  color: "red",
                  onClick: (m) => {
                    m.stopPropagation(), o.deleteBrick(e.id), i.deselectBrick(e.id), i.hidePanel("inspector");
                  },
                  children: "Delete"
                }
              )
            ] })
          ] }) })
        ]
      }
    );
  }
);
function Vn() {
  const e = Je(), t = k("(max-width: 768px)"), n = k("(min-width: 769px) and (max-width: 1024px)"), a = k("(min-width: 1025px)"), o = k("(min-width: 1420px)"), i = k("(min-width: 1200px)");
  return {
    isMobile: t,
    isTablet: n,
    isDesktop: a,
    canUseDnd: !e && i || e && o
  };
}
export {
  Hn as E,
  mn as N,
  b as R,
  Re as S,
  A as W,
  Se as g,
  Ie as h,
  Vn as u,
  Ee as y
};
//# sourceMappingURL=use-device-info.owyffR9m.js.map
