import y from "../../../@babel/runtime/helpers/esm/toConsumableArray.mjs";
import g from "../../../classnames/index.mjs";
import j from "../../../rc-motion/es/CSSMotion.mjs";
import O from "../../../rc-motion/es/CSSMotionList.mjs";
import * as o from "react";
import { useMemo as T } from "react";
import S from "../_util/motion.mjs";
import { FormItemPrefixContext as A } from "./context.mjs";
import N from "./hooks/useDebounce.mjs";
import F from "./style/index.mjs";
import K from "../config-provider/hooks/useCSSVarCls.mjs";
const b = [];
function l(r, t, a) {
  let i = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 0;
  return {
    key: typeof r == "string" ? r : `${t}-${i}`,
    error: r,
    errorStatus: a
  };
}
const R = (r) => {
  let {
    help: t,
    helpStatus: a,
    errors: i = b,
    warnings: E = b,
    className: $,
    fieldId: m,
    onVisibleChanged: x
  } = r;
  const {
    prefixCls: e
  } = o.useContext(A), c = `${e}-item-explain`, p = K(e), [M, w, L] = F(e, p), V = T(() => S(e), [e]), u = N(i), f = N(E), d = o.useMemo(() => t != null ? [l(t, "help", a)] : [].concat(y(u.map((s, n) => l(s, "error", "error", n))), y(f.map((s, n) => l(s, "warning", "warning", n)))), [t, a, u, f]), C = {};
  return m && (C.id = `${m}_help`), M(/* @__PURE__ */ o.createElement(j, {
    motionDeadline: V.motionDeadline,
    motionName: `${e}-show-help`,
    visible: !!d.length,
    onVisibleChanged: x
  }, (s) => {
    const {
      className: n,
      style: k
    } = s;
    return /* @__PURE__ */ o.createElement("div", Object.assign({}, C, {
      className: g(c, n, L, p, $, w),
      style: k,
      role: "alert"
    }), /* @__PURE__ */ o.createElement(O, Object.assign({
      keys: d
    }, S(e), {
      motionName: `${e}-show-help-item`,
      component: !1
    }), (I) => {
      const {
        key: v,
        error: D,
        errorStatus: h,
        className: P,
        style: _
      } = I;
      return /* @__PURE__ */ o.createElement("div", {
        key: v,
        className: g(P, {
          [`${c}-${h}`]: h
        }),
        style: _
      }, D);
    }));
  }));
}, X = R;
export {
  X as default
};
