import y from "../../../@babel/runtime/helpers/esm/extends.mjs";
import E from "../../../@babel/runtime/helpers/esm/objectSpread2.mjs";
import N from "../../../@babel/runtime/helpers/esm/slicedToArray.mjs";
import * as e from "react";
import k from "../../../rc-motion/es/CSSMotion.mjs";
import "../../../rc-motion/es/CSSMotionList.mjs";
import { getMotion as L } from "../utils/motionUtil.mjs";
import O, { MenuContext as P } from "../context/MenuContext.mjs";
import $ from "./SubMenuList.mjs";
function z(n) {
  var d = n.id, c = n.open, f = n.keyPath, p = n.children, a = "inline", r = e.useContext(P), v = r.prefixCls, C = r.forceSubMenuRender, M = r.motion, S = r.defaultMotions, l = r.mode, t = e.useRef(!1);
  t.current = l === a;
  var h = e.useState(!t.current), m = N(h, 2), b = m[0], u = m[1], x = t.current ? c : !1;
  e.useEffect(function() {
    t.current && u(!1);
  }, [l]);
  var i = E({}, L(a, M, S));
  f.length > 1 && (i.motionAppear = !1);
  var s = i.onVisibleChanged;
  return i.onVisibleChanged = function(o) {
    return !t.current && !o && u(!0), s == null ? void 0 : s(o);
  }, b ? null : /* @__PURE__ */ e.createElement(O, {
    mode: a,
    locked: !t.current
  }, /* @__PURE__ */ e.createElement(k, y({
    visible: x
  }, i, {
    forceRender: C,
    removeOnLeave: !1,
    leavedClassName: "".concat(v, "-hidden")
  }), function(o) {
    var R = o.className, g = o.style;
    return /* @__PURE__ */ e.createElement($, {
      id: d,
      className: R,
      style: g
    }, p);
  }));
}
export {
  z as default
};
