text: function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
  
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
  
  import { cx, mergeWith, warn, __DEV__ } from "@chakra-ui/utils";
  import { AnimatePresence, motion } from "framer-motion";
  import * as React from "react";
  import { TransitionEasings, withDelay } from "./transition-utils";
  
  var isNumeric = value => value != null && parseInt(value.toString(), 10) > 0;
  
  var defaultTransitions = {
    exit: {
      height: {
        duration: 0.2,
        ease: TransitionEasings.ease
      },
      opacity: {
        duration: 0.3,
        ease: TransitionEasings.ease
      }
    },
    enter: {
      height: {
        duration: 0.3,
        ease: TransitionEasings.ease
      },
      opacity: {
        duration: 0.4,
        ease: TransitionEasings.ease
      }
    }
  };
  var variants = {
    exit: (_ref) => {
      var _transition$exit;
  
      var {
        animateOpacity,
        startingHeight,
        transition,
        transitionEnd,
        delay
      } = _ref;
      return _extends({}, animateOpacity && {
        opacity: isNumeric(startingHeight) ? 1 : 0
      }, {
        overflow: "hidden",
        height: startingHeight,
        transitionEnd: transitionEnd == null ? void 0 : transitionEnd.exit,
        transition: (_transition$exit = transition == null ? void 0 : transition.exit) != null ? _transition$exit : withDelay.exit(defaultTransitions.exit, delay)
      });
    },
    enter: (_ref2) => {
      var _transition$enter;
  
      var {
        animateOpacity,
        endingHeight,
        transition,
        transitionEnd,
        delay
      } = _ref2;
      return _extends({}, animateOpacity && {
        opacity: 1
      }, {
        height: endingHeight,
        transitionEnd: transitionEnd == null ? void 0 : transitionEnd.enter,
        transition: (_transition$enter = transition == null ? void 0 : transition.enter) != null ? _transition$enter : withDelay.enter(defaultTransitions.enter, delay)
      });
    }
  };
  export var Collapse = /*#__PURE__*/React.forwardRef((props, ref) => {
    var {
      in: isOpen,
      unmountOnExit,
      animateOpacity = true,
      startingHeight = 0,
      endingHeight = "auto",
      style,
      className,
      transition,
      transitionEnd
    } = props,
        rest = _objectWithoutPropertiesLoose(props, ["in", "unmountOnExit", "animateOpacity", "startingHeight", "endingHeight", "style", "className", "transition", "transitionEnd"]);
  
    var [mounted, setMounted] = React.useState(false);
    React.useEffect(() => {
      var timeout = setTimeout(() => {
        setMounted(true);
      });
      return () => clearTimeout(timeout);
    }, []);
    var hasStartingHeight = parseFloat(startingHeight.toString()) > 0;
    /**
     * Warn 🚨: `startingHeight` and `unmountOnExit` are mutually exclusive
     *
     * If you specify a starting height, the collapsed needs to be mounted
     * for the height to take effect.
     */
  
    warn({
      condition: Boolean(startingHeight > 0 && unmountOnExit),
      message: "startingHeight and unmountOnExit are mutually exclusive. You can't use them together"
    });
    var custom = {
      startingHeight,
      endingHeight,
      animateOpacity,
      transition: !mounted ? {
        enter: {
          duration: 0
        }
      } : transition,
      transitionEnd: mergeWith(transitionEnd, {
        enter: {
          overflow: "initial"
        },
        exit: {
          display: hasStartingHeight ? "block" : "none"
        }
      })
    };
    var show = unmountOnExit ? isOpen : true;
    var animate = isOpen || unmountOnExit ? "enter" : "exit";
    return /*#__PURE__*/React.createElement(AnimatePresence, {
      initial: false,
      custom: custom
    }, show && /*#__PURE__*/React.createElement(motion.div, _extends({
      ref: ref
    }, rest, {
      className: cx("chakra-collapse", className),
      style: _extends({
        overflow: "hidden",
        display: "block"
      }, style),
      custom: custom,
      variants: variants,
      initial: unmountOnExit ? "exit" : false,
      animate: animate,
      exit: "exit"
    })));
  });
  
  if (__DEV__) {
    Collapse.displayName = "Collapse";
  }
  //# sourceMappingURL=collapse.js.map