import _noop from "lodash/fp/noop";
import React, { useMemo, useCallback } from 'react';
import classnames from 'classnames';
import childPropTypes from './child-prop-types';
import transitionPropTypes from './transition-prop-types';
const Child = ({
  child,
  onAnimationEnd,
  className,
  name
}) => {
  const {
    props: {
      className: propClassName
    }
  } = child;
  const handleAnimationEnd = useCallback(() => {
    return onAnimationEnd(name);
  }, [onAnimationEnd, name]);
  return /*#__PURE__*/React.cloneElement(child, {
    className: classnames(propClassName, className),
    onTransitionEnd: handleAnimationEnd,
    onAnimationEnd: handleAnimationEnd
  });
};
Child.propTypes = process.env.NODE_ENV !== "production" ? childPropTypes : {};
const Transition = props => {
  const {
    name,
    children,
    className,
    animated,
    onAnimationEnd = _noop
  } = props;
  const animatedChildren = useMemo(() => React.Children.map(children, child => /*#__PURE__*/React.createElement(Child, {
    child: child,
    onAnimationEnd: onAnimationEnd,
    className: className,
    name: name
  })), [children, className, name, onAnimationEnd]);
  return animated ? animatedChildren : children;
};
Transition.propTypes = process.env.NODE_ENV !== "production" ? transitionPropTypes : {};
export default Transition;
//# sourceMappingURL=index.js.map