import { Children, isValidElement, cloneElement } from 'react';

var updatePropsRecursively = function updatePropsRecursively(children, activeIndex, view, disabled, updateValue) {
  return Children.map(children || [], function (child, index) {
    if (! /*#__PURE__*/isValidElement(child)) {
      return child;
    }
    var props = {
      index: index,
      value: !!((activeIndex === null || activeIndex === void 0 ? void 0 : activeIndex.findIndex(function (i) {
        var _child$props$eventKey;
        return i === ((_child$props$eventKey = child.props.eventKey) !== null && _child$props$eventKey !== void 0 ? _child$props$eventKey : index);
      })) !== -1),
      view: view,
      disabled: disabled,
      onChange: updateValue
    };
    return /*#__PURE__*/cloneElement(child, props);
  });
};
var getChildren = function getChildren(children, activeIndex, view, disabled, updateValue) {
  return updatePropsRecursively(children, activeIndex, view, disabled, updateValue);
};

export { getChildren, updatePropsRecursively };
