"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),k=require("../_util/KeyCode.js"),E=require("../_util/classNames.js"),K=require("../_util/omit.js"),U=require("../_util/pickAttrs.js"),$=require("../_util/props-util/initDefaultProps.js"),j=require("../vc-util/Dom/contains.js"),B=require("./Content.js"),W=require("./IDialogPropTypes.js"),_=require("./Mask.js"),d=require("./util.js"),z=t.defineComponent({compatConfig:{MODE:3},name:"VcDialog",inheritAttrs:!1,props:$.default({...W.default(),getOpenCount:Function,scrollLocker:Object},{mask:!0,visible:!1,keyboard:!0,closable:!0,maskClosable:!0,destroyOnClose:!1,prefixCls:"rc-dialog",getOpenCount:()=>null,focusTriggerAfterClose:!0}),setup(l,{attrs:b,slots:m}){const a=t.shallowRef(),n=t.shallowRef(),i=t.shallowRef(),o=t.shallowRef(l.visible),v=t.shallowRef(`vcDialogTitle${d.getUUID()}`),g=e=>{if(e)j.default(n.value,document.activeElement)||(a.value=document.activeElement,i.value?.focus());else{const c=o.value;if(o.value=!1,l.mask&&a.value&&l.focusTriggerAfterClose){try{a.value.focus({preventScroll:!0})}catch{}a.value=null}c&&l.afterClose?.()}},r=e=>{l.onClose?.(e)},s=t.shallowRef(!1),u=t.shallowRef(),y=()=>{clearTimeout(u.value),s.value=!0},w=()=>{u.value=setTimeout(()=>{s.value=!1})},h=e=>{if(!l.maskClosable)return null;s.value?s.value=!1:n.value===e.target&&r(e)},N=e=>{if(l.keyboard&&e.keyCode===k.default.ESC){e.stopPropagation(),r(e);return}l.visible&&e.keyCode===k.default.TAB&&i.value.changeActive(!e.shiftKey)};return t.watch(()=>l.visible,()=>{l.visible&&(o.value=!0)},{flush:"post"}),t.onBeforeUnmount(()=>{clearTimeout(u.value),l.scrollLocker?.unLock()}),t.watchEffect(()=>{l.scrollLocker?.unLock(),o.value&&l.scrollLocker?.lock()}),()=>{const{prefixCls:e,mask:c,visible:f,maskTransitionName:R,maskAnimation:q,zIndex:C,wrapClassName:T,rootClassName:D,wrapStyle:M,closable:A,maskProps:V,maskStyle:p,transitionName:I,animation:L,wrapProps:O,title:P=m.title}=l,{style:S,class:x}=b;return t.createVNode("div",{class:[`${e}-root`,D],...U.default(l,{data:!0})},[t.createVNode(_.default,{prefixCls:e,visible:c&&f,motionName:d.getMotionName(e,R,q),style:{zIndex:C,...p},maskProps:V},null),t.createVNode("div",{tabIndex:-1,onKeydown:N,class:E.default(`${e}-wrap`,T),ref:n,onClick:h,role:"dialog","aria-labelledby":P?v.value:null,style:{zIndex:C,...M,display:o.value?null:"none"},...O},[t.createVNode(B.default,{...K.default(l,["scrollLocker"]),style:S,class:x,onMousedown:y,onMouseup:w,ref:i,closable:A,ariaId:v.value,prefixCls:e,visible:f,onClose:r,onVisibleChanged:g,motionName:d.getMotionName(e,I,L)},m)])])}}});exports.default=z;
