import y from "../../../@babel/runtime/helpers/esm/toConsumableArray.mjs";
import K from "../../../@babel/runtime/helpers/esm/slicedToArray.mjs";
import I from "../../../@babel/runtime/helpers/esm/typeof.mjs";
import { warningOnce as O } from "../../../rc-util/es/warning.mjs";
import * as i from "react";
import { INTERNAL_HOOKS as T } from "../constant.mjs";
import { findAllChildrenKeys as S, renderExpandIcon as g } from "../utils/expandUtil.mjs";
import { getExpandableProps as k } from "../utils/legacyUtil.mjs";
function q(o, a, s) {
  var n = k(o), v = n.expandIcon, x = n.expandedRowKeys, m = n.defaultExpandedRowKeys, w = n.defaultExpandAllRows, l = n.expandedRowRender, u = n.onExpand, p = n.onExpandedRowsChange, _ = n.childrenColumnName, h = v || g, d = _ || "children", C = i.useMemo(function() {
    return l ? "row" : o.expandable && o.internalHooks === T && o.expandable.__PARENT_RENDER_ICON__ || a.some(function(e) {
      return e && I(e) === "object" && e[d];
    }) ? "nest" : !1;
  }, [!!l, a]), N = i.useState(function() {
    return m || (w ? S(a, s, d) : []);
  }), E = K(N, 2), c = E[0], b = E[1], r = i.useMemo(function() {
    return new Set(x || c || []);
  }, [x, c]), A = i.useCallback(function(e) {
    var f = s(e, a.indexOf(e)), t, R = r.has(f);
    R ? (r.delete(f), t = y(r)) : t = [].concat(y(r), [f]), b(t), u && u(!R, e), p && p(t);
  }, [s, r, a, u, p]);
  return process.env.NODE_ENV !== "production" && l && a.some(function(e) {
    return Array.isArray(e == null ? void 0 : e[d]);
  }) && O(!1, "`expandedRowRender` should not use with nested Table"), [n, C, r, h, d, A];
}
export {
  q as default
};
