import{r as e,al as E,aX as p,ap as l,gI as c,j as u,cg as g}from"./index-e717fda1.js";function P(a){return typeof a=="function"?a():a}const x=e.forwardRef(function(i,o){const{children:t,container:s,disablePortal:r=!1}=i,[n,f]=e.useState(null),m=E(e.isValidElement(t)?p(t):null,o);if(l(()=>{r||f(P(s)||document.body)},[s,r]),l(()=>{if(n&&!r)return c(o,n),()=>{c(o,null)}},[o,n,r]),r){if(e.isValidElement(t)){const d={ref:m};return e.cloneElement(t,d)}return u(e.Fragment,{children:t})}return u(e.Fragment,{children:n&&g.createPortal(t,n)})});export{x as P};
