import t from"../../@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js";import e from"../../@babel/runtime/helpers/esm/inheritsLoose.js";import n from"../../prop-types/index.js";import i from"react";import o from"react-dom";import r from"./config.js";import{timeoutsShape as s}from"./utils/PropTypes.js";import a from"./TransitionGroupContext.js";var u="unmounted",p="exited",d="entering",l="entered",c="exiting",f=function(n){function s(t,e){var i;i=n.call(this,t,e)||this;var o,r=e&&!e.isMounting?t.enter:t.appear;return i.appearStatus=null,t.in?r?(o="exited",i.appearStatus="entering"):o="entered":o=t.unmountOnExit||t.mountOnEnter?"unmounted":"exited",i.state={status:o},i.nextCallback=null,i}e(s,n),s.getDerivedStateFromProps=function(t,e){return t.in&&"unmounted"===e.status?{status:"exited"}:null};var u=s.prototype;return u.componentDidMount=function(){this.updateStatus(!0,this.appearStatus)},u.componentDidUpdate=function(t){var e=null;if(t!==this.props){var n=this.state.status;this.props.in?"entering"!==n&&"entered"!==n&&(e="entering"):"entering"!==n&&"entered"!==n||(e="exiting")}this.updateStatus(!1,e)},u.componentWillUnmount=function(){this.cancelNextCallback()},u.getTimeouts=function(){var t,e,n,i=this.props.timeout;return t=e=n=i,null!=i&&"number"!=typeof i&&(t=i.exit,e=i.enter,n=void 0!==i.appear?i.appear:e),{exit:t,enter:e,appear:n}},u.updateStatus=function(t,e){void 0===t&&(t=!1),null!==e?(this.cancelNextCallback(),"entering"===e?this.performEnter(t):this.performExit()):this.props.unmountOnExit&&"exited"===this.state.status&&this.setState({status:"unmounted"})},u.performEnter=function(t){var e=this,n=this.props.enter,i=this.context?this.context.isMounting:t,s=this.props.nodeRef?[i]:[o.findDOMNode(this),i],a=s[0],u=s[1],p=this.getTimeouts(),d=i?p.appear:p.enter;!t&&!n||r.disabled?this.safeSetState({status:"entered"},(function(){e.props.onEntered(a)})):(this.props.onEnter(a,u),this.safeSetState({status:"entering"},(function(){e.props.onEntering(a,u),e.onTransitionEnd(d,(function(){e.safeSetState({status:"entered"},(function(){e.props.onEntered(a,u)}))}))})))},u.performExit=function(){var t=this,e=this.props.exit,n=this.getTimeouts(),i=this.props.nodeRef?void 0:o.findDOMNode(this);e&&!r.disabled?(this.props.onExit(i),this.safeSetState({status:"exiting"},(function(){t.props.onExiting(i),t.onTransitionEnd(n.exit,(function(){t.safeSetState({status:"exited"},(function(){t.props.onExited(i)}))}))}))):this.safeSetState({status:"exited"},(function(){t.props.onExited(i)}))},u.cancelNextCallback=function(){null!==this.nextCallback&&(this.nextCallback.cancel(),this.nextCallback=null)},u.safeSetState=function(t,e){e=this.setNextCallback(e),this.setState(t,e)},u.setNextCallback=function(t){var e=this,n=!0;return this.nextCallback=function(i){n&&(n=!1,e.nextCallback=null,t(i))},this.nextCallback.cancel=function(){n=!1},this.nextCallback},u.onTransitionEnd=function(t,e){this.setNextCallback(e);var n=this.props.nodeRef?this.props.nodeRef.current:o.findDOMNode(this),i=null==t&&!this.props.addEndListener;if(n&&!i){if(this.props.addEndListener){var r=this.props.nodeRef?[this.nextCallback]:[n,this.nextCallback],s=r[0],a=r[1];this.props.addEndListener(s,a)}null!=t&&setTimeout(this.nextCallback,t)}else setTimeout(this.nextCallback,0)},u.render=function(){var e=this.state.status;if("unmounted"===e)return null;var n=this.props,o=n.children;n.in,n.mountOnEnter,n.unmountOnExit,n.appear,n.enter,n.exit,n.timeout,n.addEndListener,n.onEnter,n.onEntering,n.onEntered,n.onExit,n.onExiting,n.onExited,n.nodeRef;var r=t(n,["children","in","mountOnEnter","unmountOnExit","appear","enter","exit","timeout","addEndListener","onEnter","onEntering","onEntered","onExit","onExiting","onExited","nodeRef"]);return i.createElement(a.Provider,{value:null},"function"==typeof o?o(e,r):i.cloneElement(i.Children.only(o),r))},s}(i.Component);function E(){}f.contextType=a,f.propTypes="production"!==process.env.NODE_ENV?{nodeRef:n.shape({current:"undefined"==typeof Element?n.any:function(t,e,i,o,r,s){var a=t[e];return n.instanceOf(a&&"ownerDocument"in a?a.ownerDocument.defaultView.Element:Element)(t,e,i,o,r,s)}}),children:n.oneOfType([n.func.isRequired,n.element.isRequired]).isRequired,in:n.bool,mountOnEnter:n.bool,unmountOnExit:n.bool,appear:n.bool,enter:n.bool,exit:n.bool,timeout:function(t){var e=s;t.addEndListener||(e=e.isRequired);for(var n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return e.apply(void 0,[t].concat(i))},addEndListener:n.func,onEnter:n.func,onEntering:n.func,onEntered:n.func,onExit:n.func,onExiting:n.func,onExited:n.func}:{},f.defaultProps={in:!1,mountOnEnter:!1,unmountOnExit:!1,appear:!1,enter:!0,exit:!0,onEnter:E,onEntering:E,onEntered:E,onExit:E,onExiting:E,onExited:E},f.UNMOUNTED="unmounted",f.EXITED="exited",f.ENTERING="entering",f.ENTERED="entered",f.EXITING="exiting";export default f;export{l as ENTERED,d as ENTERING,p as EXITED,c as EXITING,u as UNMOUNTED};
//# sourceMappingURL=Transition.js.map
