import f from "../../../classnames/index.mjs";
import "../../../rc-menu/es/index.mjs";
import E from "../../../rc-util/es/Children/toArray.mjs";
import I from "../../../rc-util/es/omit.mjs";
import * as o from "react";
import { SiderContext as M } from "../layout/Sider.mjs";
import T from "../tooltip/index.mjs";
import { cloneElement as b, isValidElement as u } from "../_util/reactNode.mjs";
import j from "./MenuContext.mjs";
import A from "../../../rc-menu/es/MenuItem.mjs";
const L = (m) => {
  var l;
  const {
    className: g,
    children: e,
    icon: i,
    title: n,
    danger: C
  } = m, {
    prefixCls: t,
    firstLevel: c,
    direction: N,
    disableMenuItemTitleTooltip: h,
    inlineCollapsed: p
  } = o.useContext(j), y = (v) => {
    const x = /* @__PURE__ */ o.createElement("span", {
      className: `${t}-title-content`
    }, e);
    return (!i || u(e) && e.type === "span") && e && v && c && typeof e == "string" ? /* @__PURE__ */ o.createElement("div", {
      className: `${t}-inline-collapsed-noicon`
    }, e.charAt(0)) : x;
  }, {
    siderCollapsed: $
  } = o.useContext(M);
  let r = n;
  typeof n > "u" ? r = c ? e : "" : n === !1 && (r = "");
  const s = {
    title: r
  };
  !$ && !p && (s.title = null, s.open = !1);
  const d = E(e).length;
  let a = /* @__PURE__ */ o.createElement(A, Object.assign({}, I(m, ["title", "icon", "danger"]), {
    className: f({
      [`${t}-item-danger`]: C,
      [`${t}-item-only-child`]: (i ? d + 1 : d) === 1
    }, g),
    title: typeof n == "string" ? n : void 0
  }), b(i, {
    className: f(u(i) ? (l = i.props) === null || l === void 0 ? void 0 : l.className : "", `${t}-item-icon`)
  }), y(p));
  return h || (a = /* @__PURE__ */ o.createElement(T, Object.assign({}, s, {
    placement: N === "rtl" ? "left" : "right",
    overlayClassName: `${t}-inline-collapsed-tooltip`
  }), a)), a;
}, z = L;
export {
  z as default
};
