import * as l from "react";
import j from "../../../classnames/index.mjs";
import be from "../../../rc-select/es/Select.mjs";
import Oe from "../../../rc-select/es/Option.mjs";
import we from "../../../rc-select/es/OptGroup.mjs";
import "../../../rc-select/es/BaseSelect.mjs";
import ve from "../../../rc-util/es/omit.mjs";
import { useZIndex as Ne } from "../_util/hooks/useZIndex.mjs";
import { getTransitionName as xe } from "../_util/motion.mjs";
import Ie from "../_util/PurePanel.mjs";
import { getStatusClassNames as Pe, getMergedStatus as _e } from "../_util/statusUtils.mjs";
import { devUseWarning as Ee } from "../_util/warning.mjs";
import "../config-provider/index.mjs";
import ye from "../config-provider/defaultRenderEmpty.mjs";
import Me from "../config-provider/DisabledContext.mjs";
import De from "../config-provider/hooks/useSize.mjs";
import { FormItemInputContext as je } from "../form/context.mjs";
import { useCompactItemContext as We } from "../space/Compact.mjs";
import ze from "./style/index.mjs";
import Te from "./useBuiltinPlacements.mjs";
import Be from "./useIcons.mjs";
import Fe from "./useShowArrow.mjs";
import $e from "../config-provider/hooks/useCSSVarCls.mjs";
import { ConfigContext as Ae } from "../config-provider/context.mjs";
var Re = globalThis && globalThis.__rest || function(r, d) {
  var c = {};
  for (var e in r)
    Object.prototype.hasOwnProperty.call(r, e) && d.indexOf(e) < 0 && (c[e] = r[e]);
  if (r != null && typeof Object.getOwnPropertySymbols == "function")
    for (var i = 0, e = Object.getOwnPropertySymbols(r); i < e.length; i++)
      d.indexOf(e[i]) < 0 && Object.prototype.propertyIsEnumerable.call(r, e[i]) && (c[e[i]] = r[e[i]]);
  return c;
};
const W = "SECRET_COMBOBOX_MODE_DO_NOT_USE", z = (r, d) => {
  var c, e, {
    prefixCls: i,
    bordered: T = !0,
    className: B,
    rootClassName: v,
    getPopupContainer: F,
    popupClassName: $,
    dropdownClassName: N,
    listHeight: A = 256,
    placement: f,
    listItemHeight: R = 24,
    size: C,
    disabled: S,
    notFoundContent: x,
    status: V,
    builtinPlacements: H,
    dropdownMatchSelectWidth: I,
    popupMatchSelectWidth: h,
    direction: g,
    style: U,
    allowClear: P
  } = r, t = Re(r, ["prefixCls", "bordered", "className", "rootClassName", "getPopupContainer", "popupClassName", "dropdownClassName", "listHeight", "placement", "listItemHeight", "size", "disabled", "notFoundContent", "status", "builtinPlacements", "dropdownMatchSelectWidth", "popupMatchSelectWidth", "direction", "style", "allowClear"]);
  const {
    getPopupContainer: k,
    getPrefixCls: _,
    renderEmpty: b,
    direction: X,
    virtual: G,
    popupMatchSelectWidth: L,
    popupOverflow: Y,
    select: n
  } = l.useContext(Ae), o = _("select", i), Z = _(), a = g ?? X, {
    compactSize: q,
    compactItemClassnames: J
  } = We(o, a), O = $e(o), [K, E, y] = ze(o, O), p = l.useMemo(() => {
    const {
      mode: s
    } = t;
    if (s !== "combobox")
      return s === W ? "combobox" : s;
  }, [t.mode]), Q = p === "multiple" || p === "tags", ee = Fe(t.suffixIcon, t.showArrow), te = (c = h ?? I) !== null && c !== void 0 ? c : L, {
    status: oe,
    hasFeedback: M,
    isFormItemInput: re,
    feedbackIcon: ne
  } = l.useContext(je), se = _e(oe, V);
  let u;
  x !== void 0 ? u = x : p === "combobox" ? u = null : u = (b == null ? void 0 : b("Select")) || /* @__PURE__ */ l.createElement(ye, {
    componentName: "Select"
  });
  const {
    suffixIcon: ie,
    itemIcon: le,
    removeIcon: ce,
    clearIcon: ae
  } = Be(Object.assign(Object.assign({}, t), {
    multiple: Q,
    hasFeedback: M,
    feedbackIcon: ne,
    showSuffixIcon: ee,
    prefixCls: o,
    showArrow: t.showArrow,
    componentName: "Select"
  })), me = P === !0 ? {
    clearIcon: ae
  } : P, de = ve(t, ["suffixIcon", "itemIcon"]), pe = j($ || N, {
    [`${o}-dropdown-${a}`]: a === "rtl"
  }, v, y, O, E), D = De((s) => {
    var w;
    return (w = C ?? q) !== null && w !== void 0 ? w : s;
  }), ue = l.useContext(Me), fe = S ?? ue, Ce = j({
    [`${o}-lg`]: D === "large",
    [`${o}-sm`]: D === "small",
    [`${o}-rtl`]: a === "rtl",
    [`${o}-borderless`]: !T,
    [`${o}-in-form-item`]: re
  }, Pe(o, se, M), J, n == null ? void 0 : n.className, B, v, y, O, E), Se = l.useMemo(() => f !== void 0 ? f : a === "rtl" ? "bottomRight" : "bottomLeft", [f, a]), he = Te(H, Y);
  if (process.env.NODE_ENV !== "production") {
    const s = Ee("Select");
    s.deprecated(!N, "dropdownClassName", "popupClassName"), s.deprecated(I === void 0, "dropdownMatchSelectWidth", "popupMatchSelectWidth"), process.env.NODE_ENV !== "production" && s(!("showArrow" in t), "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 [ge] = Ne("SelectLike", (e = t.dropdownStyle) === null || e === void 0 ? void 0 : e.zIndex);
  return K(/* @__PURE__ */ l.createElement(be, Object.assign({
    ref: d,
    virtual: G,
    showSearch: n == null ? void 0 : n.showSearch
  }, de, {
    style: Object.assign(Object.assign({}, n == null ? void 0 : n.style), U),
    dropdownMatchSelectWidth: te,
    builtinPlacements: he,
    transitionName: xe(Z, "slide-up", t.transitionName),
    listHeight: A,
    listItemHeight: R,
    mode: p,
    prefixCls: o,
    placement: Se,
    direction: a,
    suffixIcon: ie,
    menuItemSelectedIcon: le,
    removeIcon: ce,
    allowClear: me,
    notFoundContent: u,
    className: Ce,
    getPopupContainer: F || k,
    dropdownClassName: pe,
    disabled: fe,
    dropdownStyle: Object.assign(Object.assign({}, t == null ? void 0 : t.dropdownStyle), {
      zIndex: ge
    })
  })));
};
process.env.NODE_ENV !== "production" && (z.displayName = "Select");
const m = /* @__PURE__ */ l.forwardRef(z), Ve = Ie(m);
m.SECRET_COMBOBOX_MODE_DO_NOT_USE = W;
m.Option = Oe;
m.OptGroup = we;
m._InternalPanelDoNotUseOrYouWillBeFired = Ve;
process.env.NODE_ENV !== "production" && (m.displayName = "Select");
const dt = m;
export {
  dt as default
};
