import{r as s,P,D as m,a as v,O as f,R as b}from"./iframe-B4rglaWu.js";import{c as g,d as h,e as A}from"./componentbase.esm-O764U3c0.js";function M(e){if(Array.isArray(e))return e}function S(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var o,l,u,i,a=[],n=!0,d=!1;try{if(u=(r=r.call(e)).next,t!==0)for(;!(n=(o=u.call(r)).done)&&(a.push(o.value),a.length!==t);n=!0);}catch(p){d=!0,l=p}finally{try{if(!n&&r.return!=null&&(i=r.return(),Object(i)!==i))return}finally{if(d)throw l}}return a}}function y(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}function _(e,t){if(e){if(typeof e=="string")return y(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?y(e,t):void 0}}function O(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function R(e,t){return M(e)||S(e,t)||_(e,t)||O()}var c={defaultProps:{__TYPE:"Portal",element:null,appendTo:null,visible:!1,onMounted:null,onUnmounted:null,children:void 0},getProps:function(t){return f.getMergedProps(t,c.defaultProps)},getOtherProps:function(t){return f.getDiffProps(t,c.defaultProps)}},U=s.memo(function(e){var t=c.getProps(e),r=s.useContext(P),o=s.useState(t.visible&&m.isClient()),l=R(o,2),u=l[0],i=l[1];g(function(){m.isClient()&&!u&&(i(!0),t.onMounted&&t.onMounted())}),h(function(){t.onMounted&&t.onMounted()},[u]),A(function(){t.onUnmounted&&t.onUnmounted()});var a=t.element||t.children;if(a&&u){var n=t.appendTo||r&&r.appendTo||v.appendTo;return f.isFunction(n)&&(n=n()),n||(n=document.body),n==="self"?a:b.createPortal(a,n)}return null});U.displayName="Portal";export{U as P};
