import p from "../../../@babel/runtime/helpers/esm/objectSpread2.mjs";
import a from "../../../@babel/runtime/helpers/esm/objectWithoutProperties.mjs";
import * as s from "react";
import d from "../../../rc-util/es/Children/toArray.mjs";
var _ = ["children", "value"], m = ["children"];
function h(l) {
  var o = l, e = o.key, r = o.props, t = r.children, i = r.value, n = a(r, _);
  return p({
    key: e,
    value: i !== void 0 ? i : e,
    children: t
  }, n);
}
function v(l) {
  var o = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1;
  return d(l).map(function(e, r) {
    if (!/* @__PURE__ */ s.isValidElement(e) || !e.type)
      return null;
    var t = e, i = t.type.isSelectOptGroup, n = t.key, u = t.props, c = u.children, f = a(u, m);
    return o || !i ? h(e) : p(p({
      key: "__RC_SELECT_GRP__".concat(n === null ? r : n, "__"),
      label: n
    }, f), {}, {
      options: v(c)
    });
  }).filter(function(e) {
    return e;
  });
}
export {
  v as convertChildrenToData
};
