import * as e from "react";
import c from "../../../classnames/index.mjs";
import "../../../rc-menu/es/index.mjs";
import $ from "../../../rc-util/es/omit.mjs";
import { useZIndex as v } from "../_util/hooks/useZIndex.mjs";
import { isValidElement as i, cloneElement as b } from "../_util/reactNode.mjs";
import r from "./MenuContext.mjs";
import { useFullPath as g } from "../../../rc-menu/es/context/PathContext.mjs";
import C from "../../../rc-menu/es/SubMenu/index.mjs";
const M = (m) => {
  var s;
  const {
    popupClassName: p,
    icon: o,
    title: t,
    theme: u
  } = m, a = e.useContext(r), {
    prefixCls: n,
    inlineCollapsed: f,
    theme: d
  } = a, x = g();
  let l;
  if (!o)
    l = f && !x.length && t && typeof t == "string" ? /* @__PURE__ */ e.createElement("div", {
      className: `${n}-inline-collapsed-noicon`
    }, t.charAt(0)) : /* @__PURE__ */ e.createElement("span", {
      className: `${n}-title-content`
    }, t);
  else {
    const E = i(t) && t.type === "span";
    l = /* @__PURE__ */ e.createElement(e.Fragment, null, b(o, {
      className: c(i(o) ? (s = o.props) === null || s === void 0 ? void 0 : s.className : "", `${n}-item-icon`)
    }), E ? t : /* @__PURE__ */ e.createElement("span", {
      className: `${n}-title-content`
    }, t));
  }
  const N = e.useMemo(() => Object.assign(Object.assign({}, a), {
    firstLevel: !1
  }), [a]), [h] = v("Menu");
  return /* @__PURE__ */ e.createElement(r.Provider, {
    value: N
  }, /* @__PURE__ */ e.createElement(C, Object.assign({}, $(m, ["icon"]), {
    title: l,
    popupClassName: c(n, p, `${n}-${u || d}`),
    popupStyle: {
      zIndex: h
    }
  })));
}, V = M;
export {
  V as default
};
