text: "use strict";
  
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  
  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  exports.default = void 0;
  
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
  
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread"));
  
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
  
  var _getPrototypeOf = _interopRequireDefault(require("@babel/runtime/core-js/object/get-prototype-of"));
  
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
  
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
  
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
  
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
  
  var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
  
  var _react = _interopRequireDefault(require("react"));
  
  var _propTypes = _interopRequireDefault(require("prop-types"));
  
  var _Transition = _interopRequireDefault(require("react-transition-group/Transition"));
  
  var _transitions = require("../styles/transitions");
  
  var _withTheme = _interopRequireDefault(require("../styles/withTheme"));
  
  var _utils = require("./utils");
  
  // @inheritedComponent Transition
  var styles = {
    entering: {
      opacity: 1
    },
    entered: {
      opacity: 1
    }
  };
  /**
   * The Fade transition is used by the [Modal](/utils/modals) component.
   * It uses [react-transition-group](https://github.com/reactjs/react-transition-group) internally.
   */
  
  var Fade =
  /*#__PURE__*/
  function (_React$Component) {
    (0, _inherits2.default)(Fade, _React$Component);
  
    function Fade() {
      var _ref;
  
      var _temp, _this;
  
      (0, _classCallCheck2.default)(this, Fade);
  
      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
        args[_key] = arguments[_key];
      }
  
      return (0, _possibleConstructorReturn2.default)(_this, (_temp = _this = (0, _possibleConstructorReturn2.default)(this, (_ref = Fade.__proto__ || (0, _getPrototypeOf.default)(Fade)).call.apply(_ref, [this].concat(args))), Object.defineProperty((0, _assertThisInitialized2.default)(_this), "handleEnter", {
        configurable: true,
        enumerable: true,
        writable: true,
        value: function value(node) {
          var theme = _this.props.theme;
          (0, _utils.reflow)(node); // So the animation always start from the start.
  
          var transitionProps = (0, _utils.getTransitionProps)(_this.props, {
            mode: 'enter'
          });
          node.style.webkitTransition = theme.transitions.create('opacity', transitionProps);
          node.style.transition = theme.transitions.create('opacity', transitionProps);
  
          if (_this.props.onEnter) {
            _this.props.onEnter(node);
          }
        }
      }), Object.defineProperty((0, _assertThisInitialized2.default)(_this), "handleExit", {
        configurable: true,
        enumerable: true,
        writable: true,
        value: function value(node) {
          var theme = _this.props.theme;
          var transitionProps = (0, _utils.getTransitionProps)(_this.props, {
            mode: 'exit'
          });
          node.style.webkitTransition = theme.transitions.create('opacity', transitionProps);
          node.style.transition = theme.transitions.create('opacity', transitionProps);
  
          if (_this.props.onExit) {
            _this.props.onExit(node);
          }
        }
      }), _temp));
    }
  
    (0, _createClass2.default)(Fade, [{
      key: "render",
      value: function render() {
        var _props = this.props,
            children = _props.children,
            onEnter = _props.onEnter,
            onExit = _props.onExit,
            styleProp = _props.style,
            theme = _props.theme,
            other = (0, _objectWithoutProperties2.default)(_props, ["children", "onEnter", "onExit", "style", "theme"]);
        var style = (0, _objectSpread2.default)({}, styleProp, _react.default.isValidElement(children) ? children.props.style : {});
        return _react.default.createElement(_Transition.default, (0, _extends2.default)({
          appear: true,
          onEnter: this.handleEnter,
          onExit: this.handleExit
        }, other), function (state, childProps) {
          return _react.default.cloneElement(children, (0, _objectSpread2.default)({
            style: (0, _objectSpread2.default)({
              opacity: 0,
              willChange: 'opacity'
            }, styles[state], style)
          }, childProps));
        });
      }
    }]);
    return Fade;
  }(_react.default.Component);
  
  Fade.propTypes = process.env.NODE_ENV !== "production" ? {
    /**
     * A single child content element.
     */
    children: _propTypes.default.oneOfType([_propTypes.default.element, _propTypes.default.func]),
  
    /**
     * If `true`, the component will transition in.
     */
    in: _propTypes.default.bool,
  
    /**
     * @ignore
     */
    onEnter: _propTypes.default.func,
  
    /**
     * @ignore
     */
    onExit: _propTypes.default.func,
  
    /**
     * @ignore
     */
    style: _propTypes.default.object,
  
    /**
     * @ignore
     */
    theme: _propTypes.default.object.isRequired,
  
    /**
     * The duration for the transition, in milliseconds.
     * You may specify a single timeout for all transitions, or individually with an object.
     */
    timeout: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.shape({
      enter: _propTypes.default.number,
      exit: _propTypes.default.number
    })])
  } : {};
  Fade.defaultProps = {
    timeout: {
      enter: _transitions.duration.enteringScreen,
      exit: _transitions.duration.leavingScreen
    }
  };
  
  var _default = (0, _withTheme.default)()(Fade);
  
  exports.default = _default;