import { useMemo as d } from "react";
import { devUseWarning as h } from "../../_util/warning.mjs";
function r(t, o, s) {
  let e = t, n = !1;
  return (s === void 0 || s > o) && (e = Object.assign(Object.assign({}, t), {
    span: o
  }), n = s !== void 0), [e, n];
}
function g(t, o) {
  const s = [];
  let e = [], n = o, i = !1;
  return t.filter((c) => c).forEach((c, a) => {
    const f = c == null ? void 0 : c.span, u = f || 1;
    if (a === t.length - 1) {
      const [l, p] = r(c, n, f);
      i = i || p, e.push(l), s.push(e);
      return;
    }
    if (u < n)
      n -= u, e.push(c);
    else {
      const [l, p] = r(c, n, u);
      i = i || p, e.push(l), s.push(e), n = o, e = [];
    }
  }), [s, i];
}
const E = (t, o) => {
  const [s, e] = d(() => g(o, t), [o, t]);
  if (process.env.NODE_ENV !== "production") {
    const n = h("Descriptions");
    process.env.NODE_ENV !== "production" && n(!e, "usage", "Sum of column `span` in a line not match `column` of Descriptions.");
  }
  return s;
}, m = E;
export {
  m as default
};
