"use strict";const E=require("./Select-928983e7.js"),i=require("./FetchConfigsUtils-c73b687c.js"),d=require("./SSRHelper-b80e8420.js"),r=require("classnames"),t=require("react"),h=require("react-dom"),p=require("react-feather"),a=require("./Button-44f4db23.js");function v(){return d.SSRHelper.isSSR()?null:document.createElement("div")}function l(o){if(d.SSRHelper.isSSR())return null;const e=o?"editorModalWrapper":"modal-root";let n=document.getElementById(e);return n||(n=document.createElement("div"),n.id=e,n.style.zIndex="50",o?y(n):document.body.appendChild(n)),n}function y(o){const e=document.getElementById(i.EDITOR_PREVIEWER_ID);e&&e.appendChild(o)}class M extends t.Component{constructor(e){super(e),this.modalRoot=l(this.props.isPreviewMode),this.containerElement=v()}componentDidMount(){this.modalRoot||(this.modalRoot=l()),this.modalRoot&&this.containerElement&&this.modalRoot.appendChild(this.containerElement)}componentWillUnmount(){this.modalRoot&&this.containerElement&&this.modalRoot.removeChild(this.containerElement)}renderModal(){const{overlayBackground:e,overlayClassName:n,children:s,className:c,dataQa:m}=this.props;return t.createElement("div",{className:r("modalOverlay",n),style:e},t.createElement("section",{onClick:u=>u.stopPropagation(),className:r("modalContainer",c),"data-qa-id":m},s))}renderModalOverlay(){const{visible:e}=this.props;return e?t.createElement("div",{className:"modalOverlay editorModalOverlay"},this.renderModal()):t.createElement("div",null)}render(){const{visible:e,isPreviewMode:n}=this.props;return n?this.renderModalOverlay():!e||!this.containerElement?t.createElement("div",null):h.createPortal(this.renderModalOverlay(),this.containerElement)}}const R=o=>t.createElement("div",{className:"header"},t.createElement("div",{className:"header-wrapper"},t.createElement(f,{...o}))),S=o=>t.createElement("div",{className:r("body",o.className)},o.children),f=({className:o,onClose:e,...n})=>t.createElement(t.Fragment,null,t.createElement(E.Typography,{...n,className:r(o,i.OverrideCSS.TITLE_FONT),fontSize:e?"md":"3xl",isCentered:!0}),e&&t.createElement(a.Button,{buttonType:a.ButtonType.TEXT,className:"btnClose",onClick:e,buttonStyle:a.ButtonStyle.SECONDARY},t.createElement(p.X,{size:"24",strokeWidth:1})));exports.Modal=M;exports.ModalBody=S;exports.ModalHeader=R;
