import xe from "../../../@babel/runtime/helpers/esm/toConsumableArray.mjs";
import * as l from "react";
import z from "../../../classnames/index.mjs";
import k from "../../../rc-cascader/es/Cascader.mjs";
import "../../../rc-util/es/hooks/useLayoutEffect.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 "../../../rc-cascader/es/OptionList/List.mjs";
import { useZIndex as ye } from "../_util/hooks/useZIndex.mjs";
import { getTransitionName as A } from "../_util/motion.mjs";
import Pe from "../_util/PurePanel.mjs";
import { getStatusClassNames as ve, getMergedStatus as Oe } from "../_util/statusUtils.mjs";
import { devUseWarning as Ee } from "../_util/warning.mjs";
import "../config-provider/index.mjs";
import je from "../config-provider/defaultRenderEmpty.mjs";
import _e from "../config-provider/DisabledContext.mjs";
import R from "../config-provider/hooks/useCSSVarCls.mjs";
import De from "../config-provider/hooks/useSize.mjs";
import { FormItemInputContext as $e } from "../form/context.mjs";
import ze from "../select/style/index.mjs";
import Ae from "../select/useBuiltinPlacements.mjs";
import Re from "../select/useIcons.mjs";
import ke from "../select/useShowArrow.mjs";
import { useCompactItemContext as Fe } from "../space/Compact.mjs";
import Te from "./hooks/useBase.mjs";
import Le from "./hooks/useCheckable.mjs";
import Ve from "./hooks/useColumnIcons.mjs";
import We from "./Panel.mjs";
import He from "./style/index.mjs";
import { ConfigContext as Be } from "../config-provider/context.mjs";
var Me = globalThis && globalThis.__rest || function(e, i) {
  var s = {};
  for (var o in e)
    Object.prototype.hasOwnProperty.call(e, o) && i.indexOf(o) < 0 && (s[o] = e[o]);
  if (e != null && typeof Object.getOwnPropertySymbols == "function")
    for (var t = 0, o = Object.getOwnPropertySymbols(e); t < o.length; t++)
      i.indexOf(o[t]) < 0 && Object.prototype.propertyIsEnumerable.call(e, o[t]) && (s[o[t]] = e[o[t]]);
  return s;
};
const {
  SHOW_CHILD: Ue,
  SHOW_PARENT: Ye
} = k;
function Ze(e, i, s) {
  const o = e.toLowerCase().split(i).reduce((p, a, r) => r === 0 ? [a] : [].concat(xe(p), [i, a]), []), t = [];
  let c = 0;
  return o.forEach((p, a) => {
    const r = c + p.length;
    let m = e.slice(c, r);
    c = r, a % 2 === 1 && (m = // eslint-disable-next-line react/no-array-index-key
    /* @__PURE__ */ l.createElement("span", {
      className: `${s}-menu-item-keyword`,
      key: `separator-${a}`
    }, m)), t.push(m);
  }), t;
}
const qe = (e, i, s, o) => {
  const t = [], c = e.toLowerCase();
  return i.forEach((p, a) => {
    a !== 0 && t.push(" / ");
    let r = p[o.label];
    const m = typeof r;
    (m === "string" || m === "number") && (r = Ze(String(r), c, s)), t.push(r);
  }), t;
}, f = /* @__PURE__ */ l.forwardRef((e, i) => {
  var s;
  const {
    prefixCls: o,
    size: t,
    disabled: c,
    className: p,
    rootClassName: a,
    multiple: r,
    bordered: m = !0,
    transitionName: F,
    choiceTransitionName: T = "",
    popupClassName: L,
    dropdownClassName: P,
    expandIcon: V,
    placement: w,
    showSearch: g,
    allowClear: v = !0,
    notFoundContent: W,
    direction: O,
    getPopupContainer: H,
    status: B,
    showArrow: M,
    builtinPlacements: U,
    style: Y
  } = e, Z = Me(e, ["prefixCls", "size", "disabled", "className", "rootClassName", "multiple", "bordered", "transitionName", "choiceTransitionName", "popupClassName", "dropdownClassName", "expandIcon", "placement", "showSearch", "allowClear", "notFoundContent", "direction", "getPopupContainer", "status", "showArrow", "builtinPlacements", "style"]), h = Ie(Z, ["suffixIcon"]), {
    getPopupContainer: q,
    getPrefixCls: G,
    popupOverflow: J,
    cascader: C
  } = l.useContext(Be), {
    status: K,
    hasFeedback: E,
    isFormItemInput: Q,
    feedbackIcon: X
  } = l.useContext($e), ee = Oe(K, B);
  if (process.env.NODE_ENV !== "production") {
    const d = Ee("Cascader");
    d.deprecated(!P, "dropdownClassName", "popupClassName"), process.env.NODE_ENV !== "production" && d(!("showArrow" in e), "deprecated", "`showArrow` is deprecated which will be removed in next major version. It will be a default behavior, you can hide it by setting `suffixIcon` to null.");
  }
  const [n, u, N, S] = Te(o, O), b = N === "rtl", j = G(), x = R(n), [oe, _, D] = ze(n, x), I = R(u), [te] = He(u, I), {
    compactSize: re,
    compactItemClassnames: ne
  } = Fe(n, O), se = W || (S == null ? void 0 : S("Cascader")) || /* @__PURE__ */ l.createElement(je, {
    componentName: "Cascader"
  }), ae = z(L || P, `${u}-dropdown`, {
    [`${u}-dropdown-rtl`]: N === "rtl"
  }, a, x, I, _, D), ie = l.useMemo(() => {
    if (!g)
      return g;
    let d = {
      render: qe
    };
    return typeof g == "object" && (d = Object.assign(Object.assign({}, d), g)), d;
  }, [g]), $ = De((d) => {
    var y;
    return (y = t ?? re) !== null && y !== void 0 ? y : d;
  }), ce = l.useContext(_e), le = c ?? ce, [me, de] = Ve(n, b, V), pe = Le(u, r), ue = ke(e.suffixIcon, M), {
    suffixIcon: fe,
    removeIcon: Ce,
    clearIcon: ge
  } = Re(Object.assign(Object.assign({}, e), {
    hasFeedback: E,
    feedbackIcon: X,
    showSuffixIcon: ue,
    multiple: r,
    prefixCls: n,
    componentName: "Cascader"
  })), be = l.useMemo(() => w !== void 0 ? w : b ? "bottomRight" : "bottomLeft", [w, b]), we = Ae(U, J), he = v === !0 ? {
    clearIcon: ge
  } : v, [Ne] = ye("SelectLike", (s = h.dropdownStyle) === null || s === void 0 ? void 0 : s.zIndex), Se = /* @__PURE__ */ l.createElement(k, Object.assign({
    prefixCls: n,
    className: z(!o && u, {
      [`${n}-lg`]: $ === "large",
      [`${n}-sm`]: $ === "small",
      [`${n}-rtl`]: b,
      [`${n}-borderless`]: !m,
      [`${n}-in-form-item`]: Q
    }, ve(n, ee, E), ne, C == null ? void 0 : C.className, p, a, x, I, _, D),
    disabled: le,
    style: Object.assign(Object.assign({}, C == null ? void 0 : C.style), Y)
  }, h, {
    builtinPlacements: we,
    direction: N,
    placement: be,
    notFoundContent: se,
    allowClear: he,
    showSearch: ie,
    expandIcon: me,
    suffixIcon: fe,
    removeIcon: Ce,
    loadingIcon: de,
    checkable: pe,
    dropdownClassName: ae,
    dropdownPrefixCls: o || u,
    dropdownStyle: Object.assign(Object.assign({}, h.dropdownStyle), {
      zIndex: Ne
    }),
    choiceTransitionName: A(j, "", T),
    transitionName: A(j, "slide-up", F),
    getPopupContainer: H || q,
    ref: i
  }));
  return te(oe(Se));
});
process.env.NODE_ENV !== "production" && (f.displayName = "Cascader");
const Ge = Pe(f);
f.SHOW_PARENT = Ye;
f.SHOW_CHILD = Ue;
f.Panel = We;
f._InternalPanelDoNotUseOrYouWillBeFired = Ge;
const Oo = f;
export {
  Oo as default
};
