import * as React from "react";
import { a as useControllableState, c as createContextScope, P as Primitive, b as composeEventHandlers, j as composeRefs, y as y$1, m as Slottable } from "./index.NovFngrl.js";
import { c as createMenuScope, R as Root3, A as Anchor2, P as Portal, C as Content2$1, G as Group, L as Label, I as Item2$1, S as Separator, a as CheckboxItem, b as ItemIndicator, d as RadioGroup, e as RadioItem, f as Arrow2, g as SubTrigger, h as SubContent, n, i as c, j as a$1, k as i, p } from "./base-menu.props.OTtpaBGG.js";
import { u as useId, H, R as R$1 } from "./theme.aQt__Z8L.js";
import { a, t, l } from "./icons.Pdy-RqzJ.js";
import { v as v$1 } from "./radius.prop.DTamp0tm.js";
import { jsx } from "react/jsx-runtime";
var DROPDOWN_MENU_NAME = "DropdownMenu";
var [createDropdownMenuContext, createDropdownMenuScope] = createContextScope(
  DROPDOWN_MENU_NAME,
  [createMenuScope]
);
var useMenuScope = createMenuScope();
var [DropdownMenuProvider, useDropdownMenuContext] = createDropdownMenuContext(DROPDOWN_MENU_NAME);
var DropdownMenu = (props) => {
  const {
    __scopeDropdownMenu,
    children,
    dir,
    open: openProp,
    defaultOpen,
    onOpenChange,
    modal = true
  } = props;
  const menuScope = useMenuScope(__scopeDropdownMenu);
  const triggerRef = React.useRef(null);
  const [open, setOpen] = useControllableState({
    prop: openProp,
    defaultProp: defaultOpen ?? false,
    onChange: onOpenChange,
    caller: DROPDOWN_MENU_NAME
  });
  return /* @__PURE__ */ jsx(
    DropdownMenuProvider,
    {
      scope: __scopeDropdownMenu,
      triggerId: useId(),
      triggerRef,
      contentId: useId(),
      open,
      onOpenChange: setOpen,
      onOpenToggle: React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
      modal,
      children: /* @__PURE__ */ jsx(Root3, { ...menuScope, open, onOpenChange: setOpen, dir, modal, children })
    }
  );
};
DropdownMenu.displayName = DROPDOWN_MENU_NAME;
var TRIGGER_NAME = "DropdownMenuTrigger";
var DropdownMenuTrigger = React.forwardRef(
  (props, forwardedRef) => {
    const { __scopeDropdownMenu, disabled = false, ...triggerProps } = props;
    const context = useDropdownMenuContext(TRIGGER_NAME, __scopeDropdownMenu);
    const menuScope = useMenuScope(__scopeDropdownMenu);
    return /* @__PURE__ */ jsx(Anchor2, { asChild: true, ...menuScope, children: /* @__PURE__ */ jsx(
      Primitive.button,
      {
        type: "button",
        id: context.triggerId,
        "aria-haspopup": "menu",
        "aria-expanded": context.open,
        "aria-controls": context.open ? context.contentId : void 0,
        "data-state": context.open ? "open" : "closed",
        "data-disabled": disabled ? "" : void 0,
        disabled,
        ...triggerProps,
        ref: composeRefs(forwardedRef, context.triggerRef),
        onPointerDown: composeEventHandlers(props.onPointerDown, (event) => {
          if (!disabled && event.button === 0 && event.ctrlKey === false) {
            context.onOpenToggle();
            if (!context.open) event.preventDefault();
          }
        }),
        onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
          if (disabled) return;
          if (["Enter", " "].includes(event.key)) context.onOpenToggle();
          if (event.key === "ArrowDown") context.onOpenChange(true);
          if (["Enter", " ", "ArrowDown"].includes(event.key)) event.preventDefault();
        })
      }
    ) });
  }
);
DropdownMenuTrigger.displayName = TRIGGER_NAME;
var PORTAL_NAME = "DropdownMenuPortal";
var DropdownMenuPortal = (props) => {
  const { __scopeDropdownMenu, ...portalProps } = props;
  const menuScope = useMenuScope(__scopeDropdownMenu);
  return /* @__PURE__ */ jsx(Portal, { ...menuScope, ...portalProps });
};
DropdownMenuPortal.displayName = PORTAL_NAME;
var CONTENT_NAME = "DropdownMenuContent";
var DropdownMenuContent = React.forwardRef(
  (props, forwardedRef) => {
    const { __scopeDropdownMenu, ...contentProps } = props;
    const context = useDropdownMenuContext(CONTENT_NAME, __scopeDropdownMenu);
    const menuScope = useMenuScope(__scopeDropdownMenu);
    const hasInteractedOutsideRef = React.useRef(false);
    return /* @__PURE__ */ jsx(
      Content2$1,
      {
        id: context.contentId,
        "aria-labelledby": context.triggerId,
        ...menuScope,
        ...contentProps,
        ref: forwardedRef,
        onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, (event) => {
          if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();
          hasInteractedOutsideRef.current = false;
          event.preventDefault();
        }),
        onInteractOutside: composeEventHandlers(props.onInteractOutside, (event) => {
          const originalEvent = event.detail.originalEvent;
          const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
          const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
          if (!context.modal || isRightClick) hasInteractedOutsideRef.current = true;
        }),
        style: {
          ...props.style,
          // re-namespace exposed content custom properties
          ...{
            "--radix-dropdown-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
            "--radix-dropdown-menu-content-available-width": "var(--radix-popper-available-width)",
            "--radix-dropdown-menu-content-available-height": "var(--radix-popper-available-height)",
            "--radix-dropdown-menu-trigger-width": "var(--radix-popper-anchor-width)",
            "--radix-dropdown-menu-trigger-height": "var(--radix-popper-anchor-height)"
          }
        }
      }
    );
  }
);
DropdownMenuContent.displayName = CONTENT_NAME;
var GROUP_NAME = "DropdownMenuGroup";
var DropdownMenuGroup = React.forwardRef(
  (props, forwardedRef) => {
    const { __scopeDropdownMenu, ...groupProps } = props;
    const menuScope = useMenuScope(__scopeDropdownMenu);
    return /* @__PURE__ */ jsx(Group, { ...menuScope, ...groupProps, ref: forwardedRef });
  }
);
DropdownMenuGroup.displayName = GROUP_NAME;
var LABEL_NAME = "DropdownMenuLabel";
var DropdownMenuLabel = React.forwardRef(
  (props, forwardedRef) => {
    const { __scopeDropdownMenu, ...labelProps } = props;
    const menuScope = useMenuScope(__scopeDropdownMenu);
    return /* @__PURE__ */ jsx(Label, { ...menuScope, ...labelProps, ref: forwardedRef });
  }
);
DropdownMenuLabel.displayName = LABEL_NAME;
var ITEM_NAME = "DropdownMenuItem";
var DropdownMenuItem = React.forwardRef(
  (props, forwardedRef) => {
    const { __scopeDropdownMenu, ...itemProps } = props;
    const menuScope = useMenuScope(__scopeDropdownMenu);
    return /* @__PURE__ */ jsx(Item2$1, { ...menuScope, ...itemProps, ref: forwardedRef });
  }
);
DropdownMenuItem.displayName = ITEM_NAME;
var CHECKBOX_ITEM_NAME = "DropdownMenuCheckboxItem";
var DropdownMenuCheckboxItem = React.forwardRef((props, forwardedRef) => {
  const { __scopeDropdownMenu, ...checkboxItemProps } = props;
  const menuScope = useMenuScope(__scopeDropdownMenu);
  return /* @__PURE__ */ jsx(CheckboxItem, { ...menuScope, ...checkboxItemProps, ref: forwardedRef });
});
DropdownMenuCheckboxItem.displayName = CHECKBOX_ITEM_NAME;
var RADIO_GROUP_NAME = "DropdownMenuRadioGroup";
var DropdownMenuRadioGroup = React.forwardRef((props, forwardedRef) => {
  const { __scopeDropdownMenu, ...radioGroupProps } = props;
  const menuScope = useMenuScope(__scopeDropdownMenu);
  return /* @__PURE__ */ jsx(RadioGroup, { ...menuScope, ...radioGroupProps, ref: forwardedRef });
});
DropdownMenuRadioGroup.displayName = RADIO_GROUP_NAME;
var RADIO_ITEM_NAME = "DropdownMenuRadioItem";
var DropdownMenuRadioItem = React.forwardRef((props, forwardedRef) => {
  const { __scopeDropdownMenu, ...radioItemProps } = props;
  const menuScope = useMenuScope(__scopeDropdownMenu);
  return /* @__PURE__ */ jsx(RadioItem, { ...menuScope, ...radioItemProps, ref: forwardedRef });
});
DropdownMenuRadioItem.displayName = RADIO_ITEM_NAME;
var INDICATOR_NAME = "DropdownMenuItemIndicator";
var DropdownMenuItemIndicator = React.forwardRef((props, forwardedRef) => {
  const { __scopeDropdownMenu, ...itemIndicatorProps } = props;
  const menuScope = useMenuScope(__scopeDropdownMenu);
  return /* @__PURE__ */ jsx(ItemIndicator, { ...menuScope, ...itemIndicatorProps, ref: forwardedRef });
});
DropdownMenuItemIndicator.displayName = INDICATOR_NAME;
var SEPARATOR_NAME = "DropdownMenuSeparator";
var DropdownMenuSeparator = React.forwardRef((props, forwardedRef) => {
  const { __scopeDropdownMenu, ...separatorProps } = props;
  const menuScope = useMenuScope(__scopeDropdownMenu);
  return /* @__PURE__ */ jsx(Separator, { ...menuScope, ...separatorProps, ref: forwardedRef });
});
DropdownMenuSeparator.displayName = SEPARATOR_NAME;
var ARROW_NAME = "DropdownMenuArrow";
var DropdownMenuArrow = React.forwardRef(
  (props, forwardedRef) => {
    const { __scopeDropdownMenu, ...arrowProps } = props;
    const menuScope = useMenuScope(__scopeDropdownMenu);
    return /* @__PURE__ */ jsx(Arrow2, { ...menuScope, ...arrowProps, ref: forwardedRef });
  }
);
DropdownMenuArrow.displayName = ARROW_NAME;
var SUB_TRIGGER_NAME = "DropdownMenuSubTrigger";
var DropdownMenuSubTrigger = React.forwardRef((props, forwardedRef) => {
  const { __scopeDropdownMenu, ...subTriggerProps } = props;
  const menuScope = useMenuScope(__scopeDropdownMenu);
  return /* @__PURE__ */ jsx(SubTrigger, { ...menuScope, ...subTriggerProps, ref: forwardedRef });
});
DropdownMenuSubTrigger.displayName = SUB_TRIGGER_NAME;
var SUB_CONTENT_NAME = "DropdownMenuSubContent";
var DropdownMenuSubContent = React.forwardRef((props, forwardedRef) => {
  const { __scopeDropdownMenu, ...subContentProps } = props;
  const menuScope = useMenuScope(__scopeDropdownMenu);
  return /* @__PURE__ */ jsx(
    SubContent,
    {
      ...menuScope,
      ...subContentProps,
      ref: forwardedRef,
      style: {
        ...props.style,
        // re-namespace exposed content custom properties
        ...{
          "--radix-dropdown-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
          "--radix-dropdown-menu-content-available-width": "var(--radix-popper-available-width)",
          "--radix-dropdown-menu-content-available-height": "var(--radix-popper-available-height)",
          "--radix-dropdown-menu-trigger-width": "var(--radix-popper-anchor-width)",
          "--radix-dropdown-menu-trigger-height": "var(--radix-popper-anchor-height)"
        }
      }
    }
  );
});
DropdownMenuSubContent.displayName = SUB_CONTENT_NAME;
var Root2 = DropdownMenu;
var Trigger = DropdownMenuTrigger;
var Portal2 = DropdownMenuPortal;
var Content2 = DropdownMenuContent;
var Group2 = DropdownMenuGroup;
var Label2 = DropdownMenuLabel;
var Item2 = DropdownMenuItem;
var CheckboxItem2 = DropdownMenuCheckboxItem;
var RadioGroup2 = DropdownMenuRadioGroup;
var RadioItem2 = DropdownMenuRadioItem;
var ItemIndicator2 = DropdownMenuItemIndicator;
var Separator2 = DropdownMenuSeparator;
var SubTrigger2 = DropdownMenuSubTrigger;
var SubContent2 = DropdownMenuSubContent;
const I = (e) => React.createElement(Root2, { ...e });
I.displayName = "DropdownMenu.Root";
const h = React.forwardRef(({ children: e, ...n2 }, r) => React.createElement(Trigger, { ...n2, ref: r, asChild: true }, a(e)));
h.displayName = "DropdownMenu.Trigger";
const b = React.createContext({}), g = React.forwardRef((e, n$1) => {
  const r = H(), { size: s = n.size.default, variant: p2 = n.variant.default, highContrast: u = n.highContrast.default } = e, { className: a2, children: m, color: M, container: w, forceMount: D, ...k } = v$1(e, n), l2 = M || r.accentColor;
  return React.createElement(Portal2, { container: w, forceMount: D }, React.createElement(R$1, { asChild: true }, React.createElement(Content2, { "data-accent-color": l2, align: "start", sideOffset: 4, collisionPadding: 10, ...k, asChild: false, ref: n$1, className: y$1("rt-PopperContent", "rt-BaseMenuContent", "rt-DropdownMenuContent", a2) }, React.createElement(c, { type: "auto" }, React.createElement("div", { className: y$1("rt-BaseMenuViewport", "rt-DropdownMenuViewport") }, React.createElement(b.Provider, { value: React.useMemo(() => ({ size: s, variant: p2, color: l2, highContrast: u }), [s, p2, l2, u]) }, m))))));
});
g.displayName = "DropdownMenu.Content";
const y = React.forwardRef(({ className: e, ...n2 }, r) => React.createElement(Label2, { ...n2, asChild: false, ref: r, className: y$1("rt-BaseMenuLabel", "rt-DropdownMenuLabel", e) }));
y.displayName = "DropdownMenu.Label";
const v = React.forwardRef((e, n2) => {
  const { className: r, children: s, color: p2 = a$1.color.default, shortcut: u, ...a2 } = e;
  return React.createElement(Item2, { "data-accent-color": p2, ...a2, ref: n2, className: y$1("rt-reset", "rt-BaseMenuItem", "rt-DropdownMenuItem", r) }, React.createElement(Slottable, null, s), u && React.createElement("div", { className: "rt-BaseMenuShortcut rt-DropdownMenuShortcut" }, u));
});
v.displayName = "DropdownMenu.Item";
const R = React.forwardRef(({ className: e, ...n2 }, r) => React.createElement(Group2, { ...n2, asChild: false, ref: r, className: y$1("rt-BaseMenuGroup", "rt-DropdownMenuGroup", e) }));
R.displayName = "DropdownMenu.Group";
const S = React.forwardRef(({ className: e, ...n2 }, r) => React.createElement(RadioGroup2, { ...n2, asChild: false, ref: r, className: y$1("rt-BaseMenuRadioGroup", "rt-DropdownMenuRadioGroup", e) }));
S.displayName = "DropdownMenu.RadioGroup";
const x = React.forwardRef((e, n2) => {
  const { children: r, className: s, color: p$1 = p.color.default, ...u } = e;
  return React.createElement(RadioItem2, { ...u, asChild: false, ref: n2, "data-accent-color": p$1, className: y$1("rt-BaseMenuItem", "rt-BaseMenuRadioItem", "rt-DropdownMenuItem", "rt-DropdownMenuRadioItem", s) }, r, React.createElement(ItemIndicator2, { className: "rt-BaseMenuItemIndicator rt-DropdownMenuItemIndicator" }, React.createElement(t, { className: "rt-BaseMenuItemIndicatorIcon rt-DropdownMenuItemIndicatorIcon" })));
});
x.displayName = "DropdownMenu.RadioItem";
const T = React.forwardRef((e, n2) => {
  const { children: r, className: s, shortcut: p2, color: u = i.color.default, ...a2 } = e;
  return React.createElement(CheckboxItem2, { ...a2, asChild: false, ref: n2, "data-accent-color": u, className: y$1("rt-BaseMenuItem", "rt-BaseMenuCheckboxItem", "rt-DropdownMenuItem", "rt-DropdownMenuCheckboxItem", s) }, r, React.createElement(ItemIndicator2, { className: "rt-BaseMenuItemIndicator rt-DropdownMenuItemIndicator" }, React.createElement(t, { className: "rt-BaseMenuItemIndicatorIcon rt-ContextMenuItemIndicatorIcon" })), p2 && React.createElement("div", { className: "rt-BaseMenuShortcut rt-DropdownMenuShortcut" }, p2));
});
T.displayName = "DropdownMenu.CheckboxItem";
const E = React.forwardRef((e, n2) => {
  const { className: r, children: s, ...p2 } = e;
  return React.createElement(SubTrigger2, { ...p2, asChild: false, ref: n2, className: y$1("rt-BaseMenuItem", "rt-BaseMenuSubTrigger", "rt-DropdownMenuItem", "rt-DropdownMenuSubTrigger", r) }, s, React.createElement("div", { className: "rt-BaseMenuShortcut rt-DropdownMenuShortcut" }, React.createElement(l, { className: "rt-BaseMenuSubTriggerIcon rt-DropdownMenuSubtriggerIcon" })));
});
E.displayName = "DropdownMenu.SubTrigger";
const G = React.forwardRef((e, n$1) => {
  const { size: r, variant: s, color: p2, highContrast: u } = React.useContext(b), { className: a2, children: m, container: M, forceMount: w, ...D } = v$1({ size: r, variant: s, color: p2, highContrast: u, ...e }, n);
  return React.createElement(Portal2, { container: M, forceMount: w }, React.createElement(R$1, { asChild: true }, React.createElement(SubContent2, { "data-accent-color": p2, alignOffset: -Number(r) * 4, sideOffset: 1, collisionPadding: 10, ...D, asChild: false, ref: n$1, className: y$1("rt-PopperContent", "rt-BaseMenuContent", "rt-BaseMenuSubContent", "rt-DropdownMenuContent", "rt-DropdownMenuSubContent", a2) }, React.createElement(c, { type: "auto" }, React.createElement("div", { className: y$1("rt-BaseMenuViewport", "rt-DropdownMenuViewport") }, m)))));
});
G.displayName = "DropdownMenu.SubContent";
const B = React.forwardRef(({ className: e, ...n2 }, r) => React.createElement(Separator2, { ...n2, asChild: false, ref: r, className: y$1("rt-BaseMenuSeparator", "rt-DropdownMenuSeparator", e) }));
B.displayName = "DropdownMenu.Separator";
export {
  B,
  I,
  R,
  T,
  g,
  h,
  v,
  y
};
//# sourceMappingURL=dropdown-menu.B0Dr4Kg8.js.map
