import z from "../../../@babel/runtime/helpers/esm/defineProperty.mjs";
import o from "../../../@babel/runtime/helpers/esm/objectSpread2.mjs";
import j from "../../../@babel/runtime/helpers/esm/slicedToArray.mjs";
import * as p from "react";
import w from "../../../@rc-component/trigger/es/index.mjs";
import I from "../../../classnames/index.mjs";
import b from "../../../rc-util/es/raf.mjs";
import { MenuContext as W } from "../context/MenuContext.mjs";
import { placementsRtl as k, placements as q } from "../placements.mjs";
import { getMotion as B } from "../utils/motionUtil.mjs";
var F = {
  horizontal: "bottomLeft",
  vertical: "rightTop",
  "vertical-left": "rightTop",
  "vertical-right": "leftTop"
};
function _(e) {
  var n = e.prefixCls, a = e.visible, d = e.children, g = e.popup, v = e.popupStyle, C = e.popupClassName, i = e.popupOffset, M = e.disabled, r = e.mode, h = e.onVisibleChange, t = p.useContext(W), R = t.getPopupContainer, l = t.rtl, P = t.subMenuOpenDelay, y = t.subMenuCloseDelay, u = t.builtinPlacements, S = t.triggerSubMenuAction, x = t.forceSubMenuRender, N = t.rootClassName, D = t.motion, T = t.defaultMotions, V = p.useState(!1), s = j(V, 2), A = s[0], O = s[1], E = l ? o(o({}, k), u) : o(o({}, q), u), L = F[r], m = B(r, D, T), c = p.useRef(m);
  r !== "inline" && (c.current = m);
  var $ = o(o({}, c.current), {}, {
    leavedClassName: "".concat(n, "-hidden"),
    removeOnLeave: !1,
    motionAppear: !0
  }), f = p.useRef();
  return p.useEffect(function() {
    return f.current = b(function() {
      O(a);
    }), function() {
      b.cancel(f.current);
    };
  }, [a]), /* @__PURE__ */ p.createElement(w, {
    prefixCls: n,
    popupClassName: I("".concat(n, "-popup"), z({}, "".concat(n, "-rtl"), l), C, N),
    stretch: r === "horizontal" ? "minWidth" : null,
    getPopupContainer: R,
    builtinPlacements: E,
    popupPlacement: L,
    popupVisible: A,
    popup: g,
    popupStyle: v,
    popupAlign: i && {
      offset: i
    },
    action: M ? [] : [S],
    mouseEnterDelay: P,
    mouseLeaveDelay: y,
    onPopupVisibleChange: h,
    forceRender: x,
    popupMotion: $,
    fresh: !0
  }, d);
}
export {
  _ as default
};
