import{slicedToArray as e,defineProperty as t}from"../../../_virtual/_rollupPluginBabelHelpers.js";import o,{useMemo as l,useCallback as r,cloneElement as i}from"react";import a from"react-dom";import n from"classnames";import{useA11yDialog as s}from"./a11yDialog.js";import d from"./LegacyModalContent/LegacyModalContent.js";import m from"./LegacyModalHeader/LegacyModalHeader.js";import c from"./useBodyScrollLock.js";import u from"./useShowHideModal.js";import{ModalWidth as f,validateTitleProp as p,isModalHeader as v,isModalContent as g,isModalFooter as y}from"./ModalHelper.js";import{NOOP as j}from"../../utils/function-utils.js";import{withStaticPropsWithoutForwardRef as h}from"../../types/withStaticProps.js";import"../../utils/colors-vars-map.js";import{getTestId as L}from"../../tests/testIds.js";import{ComponentDefaultTestId as M}from"../../tests/constants.js";import w from"./LegacyModal.module.scss.js";import{LayerProvider as C}from"@vibe/layer/mockedClassNames";import{isClient as E}from"../../utils/ssr-utils.js";var b=h((function(f){var h=f.classNames,b=void 0===h?{container:"",overlay:"",modal:""}:h,A=f.id,D=f.show,O=f.title,H=void 0===O?"":O,N=f.description,S=void 0===N?"":N,B=f.onClose,P=void 0===B?j:B,k=f.alertDialog,x=void 0!==k&&k,_=f.children,z=f.triggerElement,I=f.width,R=void 0===I?"default":I,T=f.closeButtonAriaLabel,V=void 0===T?"Close":T,Y=f.contentSpacing,$=void 0!==Y&&Y,q=f.zIndex,F=void 0===q?1e4:q,G=f.unmountOnClose,J=void 0===G||G,K=f["data-testid"],Q=l((function(){return _?o.Children.toArray(_):[]}),[_]);p(H,Q);var U=s({id:A,alertDialog:x}),W=e(U,2),X=W[0],Z=W[1],ee=r((function(){x||null==P||P()}),[x,P]);c({instance:X});var te=u({instance:X,show:D,triggerElement:z,onClose:P,alertDialog:x}).shouldShow,oe=l((function(){var e=Z.title.id,t=Q.find(v);return t?i(t,{id:e,closeModal:P}):o.createElement(m,{title:H,description:S,closeModal:P,id:e,closeButtonAriaLabel:V})}),[Z.title,Q,H,S,P,V]),le=l((function(){return Q.find(g)||o.createElement(d,null,Q.filter((function(e){return!v(e)&&!y(e)})))}),[Q]),re=l((function(){return Q.find(y)||null}),[Q]),ie="default"!==R&&"full-width"!==R,ae=o.createElement(C,{layerRef:{current:null==X?void 0:X.$el}},o.createElement("div",Object.assign({},Z.container,{className:n(w.container,b.container),"data-testid":K||L(M.MODAL,A),style:{"--monday-modal-z-index":F}}),o.createElement("div",{onClick:ee,className:n(w.overlay,b.overlay),"data-testid":M.MODAL_OVERLAY}),o.createElement("div",Object.assign({},Z.dialog,{className:n(w.dialog,b.modal,t(t(t({},w.default,"default"===R),w.full,"full-width"===R),w.spacing,$)),style:{width:ie?R:null}}),oe,le,re)));return J&&!te?null:E()?a.createPortal(ae,document.body):null}),{width:f});export{b as default};
//# sourceMappingURL=LegacyModal.js.map
