import e from"@babel/runtime/helpers/defineProperty";import{jsxs as r,Fragment as o,jsx as n}from"react/jsx-runtime";import{forwardRef as t,useRef as c,useCallback as i,useEffect as a,useMemo as p}from"react";import{Grow as l}from"@material-ui/core";import s from"classnames";import{Popper as u}from"../Popper/Popper.js";import{Paper as d}from"../Paper/Paper.js";import{disableScroll as f}from"./utils.js";import m from"./Popover.scss.js";function v(e,r){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),o.push.apply(o,n)}return o}function b(r){for(var o=1;o<arguments.length;o++){var n=null!=arguments[o]?arguments[o]:{};o%2?v(Object(n),!0).forEach((function(o){e(r,o,n[o])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):v(Object(n)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))}))}return r}var y=t((function(e,t){var v=e.children,y=e.open,O=e.onClose,h=e.className,j=e.closeOnBackdropClick,E=void 0===j||j,P=e.closeOnEscape,w=void 0===P||P,k=e.backdrop,g=void 0===k||k,C=e.anchorEl,M=e.preventScroll,N=void 0===M||M,x=e.placement,D=void 0===x?"bottom-start":x,L=e.onMouseLeave,S=e.onMouseEnter,A=e.flip,R=void 0===A||A,z=e.preventOverflow,B=void 0===z||z,K=e.container,T=e.animate,U=void 0===T||T,q=e.type,F=void 0===q?"popover":q,G=c(null),H=c(new ResizeObserver((function(){var e;null===(e=G.current)||void 0===e||e.scheduleUpdate()}))),I=i((function(){O&&E&&O("backdropClick")}),[O,E]);a((function(){var e=function(e){"Escape"!==e.key&&"Esc"!==e.key||null==O||O("escapeKey")};return y&&w?(document.addEventListener("keydown",e),function(){document.removeEventListener("keydown",e)}):function(){}}),[O,w,y]),a((function(){return y&&N?f(document.body):function(){}}),[y,N]);var J=p((function(){return{preventOverflow:{enabled:B,padding:20,boundariesElement:"viewport"},flip:{enabled:R}}}),[R,B]);return r(o,{children:[g&&n(u,{open:y,className:m.root,container:K,children:n("div",{className:m.backdrop,onClick:I})}),n(u,{open:y,anchorEl:C,placement:D,className:m.root,transition:!0,popperRef:G,modifiers:J,container:K,children:function(e){var r=e.TransitionProps;return n(l,b(b({},r),{},{timeout:U?"auto":0,disableStrictModeCompat:!0,onEntered:function(){for(var e,o=arguments.length,n=new Array(o),t=0;t<o;t++)n[t]=arguments[t];null==r||null===(e=r.onEntered)||void 0===e||e.call.apply(e,[r].concat(n)),H.current.observe(n[0])},onExit:function(){for(var e,o=arguments.length,n=new Array(o),t=0;t<o;t++)n[t]=arguments[t];null==r||null===(e=r.onExit)||void 0===e||e.call.apply(e,[r].concat(n)),H.current.disconnect()},children:n(d,{className:s(m.paper,h),onMouseEnter:S,onMouseLeave:L,ref:t,type:F,children:v})}))}})]})}));export{y as Popover};
//# sourceMappingURL=Popover.js.map
