"use strict";

exports.__esModule = true;
exports.default = void 0;
var _noop2 = _interopRequireDefault(require("lodash/fp/noop"));
var _react = _interopRequireWildcard(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
var _childPropTypes = _interopRequireDefault(require("./child-prop-types"));
var _transitionPropTypes = _interopRequireDefault(require("./transition-prop-types"));
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const Child = ({
  child,
  onAnimationEnd,
  className,
  name
}) => {
  const {
    props: {
      className: propClassName
    }
  } = child;
  const handleAnimationEnd = (0, _react.useCallback)(() => {
    return onAnimationEnd(name);
  }, [onAnimationEnd, name]);
  return /*#__PURE__*/_react.default.cloneElement(child, {
    className: (0, _classnames.default)(propClassName, className),
    onTransitionEnd: handleAnimationEnd,
    onAnimationEnd: handleAnimationEnd
  });
};
Child.propTypes = process.env.NODE_ENV !== "production" ? _childPropTypes.default : {};
const Transition = props => {
  const {
    name,
    children,
    className,
    animated,
    onAnimationEnd = _noop2.default
  } = props;
  const animatedChildren = (0, _react.useMemo)(() => _react.default.Children.map(children, child => /*#__PURE__*/_react.default.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.default : {};
var _default = exports.default = Transition;
//# sourceMappingURL=index.js.map