'use client';
import{jsx as e,Fragment as i,jsxs as t}from"react/jsx-runtime";import{useRef as p,useCallback as l,useEffect as r}from"react";import{cls as a,isEmptyChildren as n}from"@gem-sdk/core";import{createPortal as o}from"react-dom";import g from"../hooks/useModalContainer.js";import d from"../../grid/components/ChildrenDroppable.js";let s=({setting:s,styles:c,children:m,willUnmount:h,closeOnEscape:u,onKeypressEscape:w,keyCodeForClose:f,closeOnClickOutside:v,onClose:x,contentClass:y,disableIframeClickEvent:C})=>{let{open:k}=s??{},b=g(),L=p(null),N=p(null),M=l(e=>{let i=e.code;f?.includes(i),u&&"Escape"===i&&w?.(e)},[u,f,w]);r(()=>(document.addEventListener("keydown",M,!1),()=>{document.removeEventListener("keydown",M,!1),h?.()}),[M,h]);let j=l(e=>{let i=e.target===L.current,t=e.target===N.current;(v&&i||t)&&(window?.parent?.postMessage?.(JSON.stringify({type:"active-modal",value:!1}),"*"),x?.())},[v,x]);return(r(()=>{window?.parent?.postMessage?.(JSON.stringify({type:"active-modal",value:k}),"*")},[k]),b&&k)?o(e(i,{children:e("div",{className:"gp-fixed gp-inset-0 gp-z-50 gp-overflow-y-auto","data-disable-iframe-click-event":C||!1,children:t("div",{className:"gp-min-h-screen gp-px-4 gp-text-center",children:[e("div",{ref:L,className:a("gp-fixed gp-inset-0 gp-bg-black/60 gp-backdrop-blur-sm gp-transition-all gp-duration-100",{"gp-opacity-100":k,"gp-opacity-0":!k}),onClick:j,"aria-hidden":!0}),e("span",{className:"gp-inline-block gp-h-screen gp-align-middle"}),t("div",{className:a("gp-relative gp-my-8 gp-inline-block gp-w-full gp-overflow-hidden gp-rounded gp-bg-white gp-p-6 gp-text-left gp-align-middle gp-shadow-xl gp-transition-all gp-duration-100",{"gp-max-w-2xl":!c?.width,"gp-scale-100 gp-opacity-100":k,"gp-scale-0 gp-opacity-0":!k},y),style:{width:c?.width},children:[e("div",{className:"gp-absolute gp-right-[16px] gp-top-[16px] gp-z-10 gp-cursor-pointer",onClick:j,"aria-hidden":"true",children:e("svg",{ref:N,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e("path",{d:"M11.1758 12.0241C11.4101 12.2584 11.79 12.2584 12.0243 12.0241C12.2586 11.7898 12.2586 11.4099 12.0243 11.1755L8.84858 7.9998L12.0243 4.82407C12.2586 4.58975 12.2586 4.20986 12.0243 3.97554C11.79 3.74123 11.4101 3.74123 11.1758 3.97554L8.00005 7.15128L4.82431 3.97554C4.59 3.74123 4.2101 3.74123 3.97578 3.97554C3.74147 4.20986 3.74147 4.58975 3.97578 4.82407L7.15152 7.9998L3.97579 11.1755C3.74147 11.4099 3.74147 11.7898 3.97579 12.0241C4.2101 12.2584 4.59 12.2584 4.82431 12.0241L8.00005 8.84833L11.1758 12.0241Z",fill:"#676767"})})}),e("div",{children:n(m)?e(d,{}):m})]})]})})}),b):null};export{s as default};
