import { j as o } from "../../node_modules/react/jsx-runtime.mjs";
import c, { memo as B, useMemo as I } from "react";
import H from "../../hooks/useMergedState.mjs";
import L from "../../node_modules/classnames/index.mjs";
import w from "../../node_modules/antd/es/grid/col.mjs";
import U from "../../node_modules/antd/es/grid/row.mjs";
import q from "../../node_modules/antd/es/form/index.mjs";
import J from "../../node_modules/antd/es/space/index.mjs";
import x from "../../node_modules/antd/es/button/button.mjs";
const O = (s, i, f) => s == null ? void 0 : s.flatMap((r) => {
  var S, p, d;
  if ((r == null ? void 0 : r.type.displayName) === "ProForm-Group" && !((S = r.props) != null && S.title))
    return r.props.children;
  if ((r == null ? void 0 : r.type.displayName) === "ProFormDependency" && !((p = r.props) != null && p.title)) {
    const N = r.props.name.reduce((j, u) => ({
      ...j,
      [u]: f == null ? void 0 : f.getFieldValue(u)
    }), {});
    return r.props.children(N);
  }
  return i && c.isValidElement(r) ? c.cloneElement(r, {
    ...r.props,
    formItemProps: {
      ...(d = r.props) == null ? void 0 : d.formItemProps,
      rules: []
    }
  }) : r;
}), T = (s) => {
  var k, R, v;
  const [i, f] = H(
    () => s.defaultCollapsed,
    // && !!props.submitter
    {
      value: s.collapsed,
      onChange: s.onCollapse
    }
  ), { split: r, items: S, spanSize: p, showLength: d, searchGutter: N, showHiddenNum: j, form: u, baseClassName: E, onReset: g, onFinish: P } = s;
  let h = 0, F = 0, $ = !1, y = 0, t = 0;
  const V = O(S, s.ignoreRules, u).map((e, l) => {
    var m, C, D, M;
    const n = c.isValidElement(e) ? ((m = e == null ? void 0 : e.props) == null ? void 0 : m.colSize) ?? 1 : 1, a = Math.min(p.span * (n || 1), 24);
    h += a, y += n, l === 0 && ($ = a === 24 && !((C = e == null ? void 0 : e.props) != null && C.hidden));
    const z = ((D = e == null ? void 0 : e.props) == null ? void 0 : D.hidden) || // 如果收起了
    i && ($ || // 如果 超过显示长度 且 总长度超过了 24
    y > d - 1) && !!l && h >= 24;
    F += 1;
    const b = c.isValidElement(e) && (e.key || `${(M = e.props) == null ? void 0 : M.name}`) || l;
    return c.isValidElement(e) && z ? s.preserve ? {
      itemDom: c.cloneElement(e, {
        hidden: !0,
        key: b || l
      }),
      hidden: !0,
      colSpan: a
    } : {
      itemDom: null,
      colSpan: 0,
      hidden: !0
    } : {
      itemDom: e,
      colSpan: a,
      hidden: !1
    };
  }), G = V.map((e, l) => {
    var m, C;
    const { itemDom: n, colSpan: a } = e;
    if ((m = n == null ? void 0 : n.props) == null ? void 0 : m.hidden)
      return n;
    const b = c.isValidElement(n) && (n.key || `${(C = n.props) == null ? void 0 : C.name}`) || l;
    return 24 - t % 24 < a && (h += 24 - t % 24, t += 24 - t % 24), t += a, r && t % 24 === 0 && l < F - 1 ? o.jsx(w, { span: a, className: `${s.baseClassName}-row-split-line ${s.baseClassName}-row-split`.trim(), children: n }, b) : o.jsx(w, { className: `${s.baseClassName}-row-split`.trim(), span: a, children: n }, b);
  });
  j && V.filter((e) => e.hidden).length;
  const K = I(() => !(h < 24 || y <= d), [y, d, h]), Q = I(() => {
    var l, n;
    const e = t % 24 + (((l = s.submitterColSpanProps) == null ? void 0 : l.span) ?? p.span);
    return e > 24 ? 24 - (((n = s.submitterColSpanProps) == null ? void 0 : n.span) ?? p.span) : 24 - e;
  }, [t, t % 24 + (((k = s.submitterColSpanProps) == null ? void 0 : k.span) ?? p.span), (R = s.submitterColSpanProps) == null ? void 0 : R.span]), _ = () => {
    u.resetFields(), g == null || g();
  }, A = () => {
    const e = u.getFieldsValue();
    P == null || P(e);
  };
  return o.jsxs(U, { gutter: N, justify: "start", className: L(`${E}-row`), children: [G, o.jsx(w, { span: p.span, offset: Q, className: L((v = s.submitterColSpanProps) == null ? void 0 : v.className), ...s.submitterColSpanProps, style: {
    textAlign: "end"
  }, children: o.jsx(q.Item, { label: " ", colon: !1, shouldUpdate: !1, className: `${E}-actions`.trim(), children: o.jsxs(J, { children: [o.jsx(x, { onClick: A, type: "primary", children: "搜索" }), o.jsx(x, { onClick: _, children: "重置" }), K ? o.jsx(x, { type: "text", onClick: () => f(!i), children: i ? "展开" : "收起" }) : null] }) }) }, "submitter")] }, "resize-observer-row");
}, te = B(T);
export {
  te as default
};
