import _defineProperty from"@babel/runtime/helpers/defineProperty";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["children","container","style"];function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import React,{useEffect,useRef,useState}from"react";import ReactDOM from"react-dom";import{useForkRef}from"../../hooks/useForkRef/useForkRef";import{Theme}from"../Theme/Theme";import{PortalWithThemeProvider,usePortalContext}from"./PortalWithThemeContext/PortalWithThemeContext";export{usePortalContext};var getZIndex=function(a,b){return"number"==typeof b?b:a?a+1:void 0},isRef=function(a){return!!a&&"current"in a&&a.current instanceof HTMLElement},getElement=function(a){return isRef(a)?a.current:a};export var PortalWithTheme=React.forwardRef(function(a,b){var c=a.children,d=a.container,e=void 0===d?window.document.body:d,f=a.style,g=_objectWithoutProperties(a,_excluded),h=usePortalContext(),i=h.addRefs,j=h.zIndex,k=useState(getElement(e)),l=_slicedToArray(k,2),m=l[0],n=l[1],o=useRef(null),p=getZIndex(j,null===f||void 0===f?void 0:f.zIndex),q=useForkRef([o,b]);return useEffect(function(){i&&i([o])},[o]),useEffect(function(){n(getElement(e))},[getElement(e)]),m?ReactDOM.createPortal(React.createElement(PortalWithThemeProvider,{zIndex:p},React.createElement(Theme,Object.assign({},g,{ref:q,style:_objectSpread(_objectSpread({},f),{},{zIndex:p})}),c)),m):null});
//# sourceMappingURL=PortalWithTheme.js.map