import * as n from "react";
import oe from "../../../@ant-design/icons/es/icons/RightOutlined.mjs";
import I from "../../../classnames/index.mjs";
import ne from "../../../rc-dropdown/es/Dropdown.mjs";
import te from "../../../rc-util/es/hooks/useEvent.mjs";
import re from "../../../rc-util/es/hooks/useMergedState.mjs";
import "../../../rc-util/node_modules/react-is/index.mjs";
import "../../../rc-util/es/warning.mjs";
import ie from "../../../rc-util/es/omit.mjs";
import { useZIndex as se } from "../_util/hooks/useZIndex.mjs";
import le from "../_util/placements.mjs";
import ae from "../_util/PurePanel.mjs";
import { cloneElement as me } from "../_util/reactNode.mjs";
import { devUseWarning as de } from "../_util/warning.mjs";
import ce from "../_util/zindexContext.mjs";
import "../config-provider/index.mjs";
import ue from "../menu/index.mjs";
import { OverrideProvider as pe } from "../menu/OverrideContext.mjs";
import "../../../@ant-design/cssinjs/es/extractStyle.mjs";
import "../../../@ant-design/cssinjs/es/hooks/useCacheToken.mjs";
import "../../../@ant-design/cssinjs/es/StyleContext.mjs";
import "../../../@ant-design/cssinjs/es/theme/createTheme.mjs";
import "../../../@ant-design/cssinjs/es/theme/ThemeCache.mjs";
import "../../../@ant-design/cssinjs/es/hooks/useCompatibleInsertionEffect.mjs";
import "../../../@ant-design/cssinjs/es/hooks/useEffectCleanupRegister.mjs";
import "../../../@ant-design/cssinjs/es/hooks/useHMR.mjs";
import "../../../@ant-design/cssinjs/es/transformers/legacyLogicalProperties.mjs";
import fe from "../theme/useToken.mjs";
import ve from "./style/index.mjs";
import ge from "../config-provider/hooks/useCSSVarCls.mjs";
import { ConfigContext as Ce } from "../config-provider/context.mjs";
const f = (r) => {
  const {
    menu: o,
    arrow: c,
    prefixCls: S,
    children: M,
    trigger: z,
    disabled: E,
    dropdownRender: O,
    getPopupContainer: R,
    overlayClassName: _,
    rootClassName: k,
    overlayStyle: u,
    open: v,
    onOpenChange: a,
    // Deprecated
    visible: A,
    onVisibleChange: g,
    mouseEnterDelay: T = 0.15,
    mouseLeaveDelay: W = 0.1,
    autoAdjustOverflow: L = !0,
    placement: t = "",
    overlay: C,
    transitionName: N
  } = r, {
    getPopupContainer: X,
    getPrefixCls: b,
    direction: p,
    dropdown: m
  } = n.useContext(Ce), d = de("Dropdown");
  process.env.NODE_ENV !== "production" && ([["visible", "open"], ["onVisibleChange", "onOpenChange"]].forEach((e) => {
    let [s, l] = e;
    d.deprecated(!(s in r), s, l);
  }), d.deprecated(!("overlay" in r), "overlay", "menu"));
  const Y = n.useMemo(() => {
    const e = b();
    return N !== void 0 ? N : t.includes("top") ? `${e}-slide-down` : `${e}-slide-up`;
  }, [b, t, N]), U = n.useMemo(() => t ? t.includes("Center") ? t.slice(0, t.indexOf("Center")) : t : p === "rtl" ? "bottomRight" : "bottomLeft", [t, p]);
  if (process.env.NODE_ENV !== "production") {
    if (t.includes("Center")) {
      const e = t.slice(0, t.indexOf("Center"));
      process.env.NODE_ENV !== "production" && d(!t.includes("Center"), "deprecated", `You are using '${t}' placement in Dropdown, which is deprecated. Try to use '${e}' instead.`);
    }
    [["visible", "open"], ["onVisibleChange", "onOpenChange"]].forEach((e) => {
      let [s, l] = e;
      d.deprecated(!(s in r), s, l);
    });
  }
  const i = b("dropdown", S), h = ge(i), [Z, B, x] = ve(i, h), [, w] = fe(), D = n.Children.only(M), F = me(D, {
    className: I(`${i}-trigger`, {
      [`${i}-rtl`]: p === "rtl"
    }, D.props.className),
    disabled: E
  }), P = E ? [] : z;
  let j;
  P && P.includes("contextMenu") && (j = !0);
  const [q, V] = re(!1, {
    value: v ?? A
  }), G = te((e) => {
    a == null || a(e, {
      source: "trigger"
    }), g == null || g(e), V(e);
  }), H = I(_, k, B, x, h, m == null ? void 0 : m.className, {
    [`${i}-rtl`]: p === "rtl"
  }), J = le({
    arrowPointAtCenter: typeof c == "object" && c.pointAtCenter,
    autoAdjustOverflow: L,
    offset: w.marginXXS,
    arrowWidth: c ? w.sizePopupArrow : 0,
    borderRadius: w.borderRadius
  }), K = n.useCallback(() => {
    o != null && o.selectable && (o != null && o.multiple) || (a == null || a(!1, {
      source: "menu"
    }), V(!1));
  }, [o == null ? void 0 : o.selectable, o == null ? void 0 : o.multiple]), Q = () => {
    let e;
    return o != null && o.items ? e = /* @__PURE__ */ n.createElement(ue, Object.assign({}, o)) : typeof C == "function" ? e = C() : e = C, O && (e = O(e)), e = n.Children.only(typeof e == "string" ? /* @__PURE__ */ n.createElement("span", null, e) : e), /* @__PURE__ */ n.createElement(pe, {
      prefixCls: `${i}-menu`,
      rootClassName: x,
      expandIcon: /* @__PURE__ */ n.createElement("span", {
        className: `${i}-menu-submenu-arrow`
      }, /* @__PURE__ */ n.createElement(oe, {
        className: `${i}-menu-submenu-arrow-icon`
      })),
      mode: "vertical",
      selectable: !1,
      onClick: K,
      validator: (s) => {
        let {
          mode: l
        } = s;
        process.env.NODE_ENV !== "production" && d(!l || l === "vertical", "usage", `mode="${l}" is not supported for Dropdown's Menu.`);
      }
    }, e);
  }, [$, ee] = se("Dropdown", u == null ? void 0 : u.zIndex);
  let y = /* @__PURE__ */ n.createElement(ne, Object.assign({
    alignPoint: j
  }, ie(r, ["rootClassName"]), {
    mouseEnterDelay: T,
    mouseLeaveDelay: W,
    visible: q,
    builtinPlacements: J,
    arrow: !!c,
    overlayClassName: H,
    prefixCls: i,
    getPopupContainer: R || X,
    transitionName: Y,
    trigger: P,
    overlay: Q,
    placement: U,
    onVisibleChange: G,
    overlayStyle: Object.assign(Object.assign(Object.assign({}, m == null ? void 0 : m.style), u), {
      zIndex: $
    })
  }), F);
  return $ && (y = /* @__PURE__ */ n.createElement(ce.Provider, {
    value: ee
  }, y)), Z(y);
};
function Ne(r) {
  return Object.assign(Object.assign({}, r), {
    align: {
      overflow: {
        adjustX: !1,
        adjustY: !1
      }
    }
  });
}
const be = ae(f, "dropdown", (r) => r, Ne), we = (r) => /* @__PURE__ */ n.createElement(be, Object.assign({}, r), /* @__PURE__ */ n.createElement("span", null));
f._InternalPanelDoNotUseOrYouWillBeFired = we;
process.env.NODE_ENV !== "production" && (f.displayName = "Dropdown");
const Je = f;
export {
  Je as default
};
