import e from"../../../../@babel/runtime/helpers/esm/objectWithoutProperties.js";import n from"../../../../@babel/runtime/helpers/esm/defineProperty.js";import t from"../../../../@babel/runtime/helpers/esm/extends.js";import*as o from"react";import r from"../../../../prop-types/index.js";import i from"../../../../clsx/dist/clsx.m.js";import s from"../styles/withStyles.js";import{duration as a}from"../styles/transitions.js";import u from"../utils/useEventCallback.js";import c from"../utils/capitalize.js";import l from"../utils/createChainedFunction.js";import m from"../ClickAwayListener/ClickAwayListener.js";import p from"../SnackbarContent/SnackbarContent.js";import f from"../Grow/Grow.js";var d=function(e){var o={top:8},r={bottom:8},i={justifyContent:"flex-end"},s={justifyContent:"flex-start"},a={top:24},u={bottom:24},c={right:24},l={left:24},m={left:"50%",right:"auto",transform:"translateX(-50%)"};return{root:{zIndex:e.zIndex.snackbar,position:"fixed",display:"flex",left:8,right:8,justifyContent:"center",alignItems:"center"},anchorOriginTopCenter:t({},o,n({},e.breakpoints.up("sm"),t({},a,m))),anchorOriginBottomCenter:t({},r,n({},e.breakpoints.up("sm"),t({},u,m))),anchorOriginTopRight:t({},o,i,n({},e.breakpoints.up("sm"),t({left:"auto"},a,c))),anchorOriginBottomRight:t({},r,i,n({},e.breakpoints.up("sm"),t({left:"auto"},u,c))),anchorOriginTopLeft:t({},o,s,n({},e.breakpoints.up("sm"),t({right:"auto"},a,l))),anchorOriginBottomLeft:t({},r,s,n({},e.breakpoints.up("sm"),t({right:"auto"},u,l)))}},E=o.forwardRef((function(n,r){var s=n.action,d=n.anchorOrigin,E=(d=void 0===d?{vertical:"bottom",horizontal:"center"}:d).vertical,b=d.horizontal,g=n.autoHideDuration,h=void 0===g?null:g,v=n.children,x=n.classes,C=n.className,w=n.ClickAwayListenerProps,y=n.ContentProps,j=n.disableWindowBlurListener,k=void 0!==j&&j,L=n.message,T=n.onClose,O=n.onEnter,P=n.onEntered,D=n.onEntering,M=n.onExit,S=n.onExited,z=n.onExiting,A=n.onMouseEnter,B=n.onMouseLeave,H=n.open,N=n.resumeHideDuration,R=n.TransitionComponent,W=void 0===R?f:R,I=n.transitionDuration,q=void 0===I?{enter:a.enteringScreen,exit:a.leavingScreen}:I,G=n.TransitionProps,F=e(n,["action","anchorOrigin","autoHideDuration","children","classes","className","ClickAwayListenerProps","ContentProps","disableWindowBlurListener","message","onClose","onEnter","onEntered","onEntering","onExit","onExited","onExiting","onMouseEnter","onMouseLeave","open","resumeHideDuration","TransitionComponent","transitionDuration","TransitionProps"]),V=o.useRef(),X=o.useState(!0),_=X[0],J=X[1],K=u((function(){T&&T.apply(void 0,arguments)})),Q=u((function(e){T&&null!=e&&(clearTimeout(V.current),V.current=setTimeout((function(){K(null,"timeout")}),e))}));o.useEffect((function(){return H&&Q(h),function(){clearTimeout(V.current)}}),[H,h,Q]);var U=function(){clearTimeout(V.current)},Y=o.useCallback((function(){null!=h&&Q(null!=N?N:.5*h)}),[h,N,Q]);return o.useEffect((function(){if(!k&&H)return window.addEventListener("focus",Y),window.addEventListener("blur",U),function(){window.removeEventListener("focus",Y),window.removeEventListener("blur",U)}}),[k,Y,H]),!H&&_?null:o.createElement(m,t({onClickAway:function(e){T&&T(e,"clickaway")}},w),o.createElement("div",t({className:i(x.root,x["anchorOrigin".concat(c(E)).concat(c(b))],C),onMouseEnter:function(e){A&&A(e),U()},onMouseLeave:function(e){B&&B(e),Y()},ref:r},F),o.createElement(W,t({appear:!0,in:H,onEnter:l((function(){J(!1)}),O),onEntered:P,onEntering:D,onExit:M,onExited:l((function(){J(!0)}),S),onExiting:z,timeout:q,direction:"top"===E?"down":"up"},G),v||o.createElement(p,t({message:L,action:s},y)))))}));"production"!==process.env.NODE_ENV&&(E.propTypes={action:r.node,anchorOrigin:r.shape({horizontal:r.oneOf(["center","left","right"]).isRequired,vertical:r.oneOf(["bottom","top"]).isRequired}),autoHideDuration:r.number,children:r.element,classes:r.object,className:r.string,ClickAwayListenerProps:r.object,ContentProps:r.object,disableWindowBlurListener:r.bool,key:r.any,message:r.node,onClose:r.func,onEnter:r.func,onEntered:r.func,onEntering:r.func,onExit:r.func,onExited:r.func,onExiting:r.func,onMouseEnter:r.func,onMouseLeave:r.func,open:r.bool,resumeHideDuration:r.number,TransitionComponent:r.elementType,transitionDuration:r.oneOfType([r.number,r.shape({appear:r.number,enter:r.number,exit:r.number})]),TransitionProps:r.object});var b=s(d,{flip:!1,name:"MuiSnackbar"})(E);export default b;export{d as styles};
//# sourceMappingURL=Snackbar.js.map
