import{defineComponent as Y,shallowRef as c,onMounted as j,nextTick as p,watch as d,onUnmounted as z,createVNode as s,Transition as b,withDirectives as D,vShow as L}from"vue";import B from"../../_util/KeyCode.mjs";import G from"../../_util/classNames.mjs";import J from"../../_util/omit.mjs";import{drawerChildProps as Q}from"./IDrawerPropTypes.mjs";import{windowIsUndefined as X,dataToArray as Z}from"./utils.mjs";const he=Y({compatConfig:{MODE:3},inheritAttrs:!1,props:Q(),emits:["close","handleClick","change"],setup(n,{emit:C,slots:f}){const M=c(),u=c(),$=c(),A=c(),k=c();let m=[];`${Number((Date.now()+Math.random()).toString().replace(".",Math.round(Math.random()*9).toString())).toString(16)}`,j(()=>{p(()=>{const{open:e,getContainer:l,showMask:a,autofocus:o}=n,r=l?.();v(n),e&&(r&&(r.parentNode,document.body),p(()=>{o&&y()}),a&&n.scrollLocker?.lock())})}),d(()=>n.level,()=>{v(n)},{flush:"post"}),d(()=>n.open,()=>{const{open:e,getContainer:l,scrollLocker:a,showMask:o,autofocus:r}=n,t=l?.();t&&(t.parentNode,document.body),e?(r&&y(),o&&a?.lock()):a?.unLock()},{flush:"post"}),z(()=>{const{open:e}=n;e&&(document.body.style.touchAction=""),n.scrollLocker?.unLock()}),d(()=>n.placement,e=>{e&&(k.value=null)});const y=()=>{u.value?.focus?.()},w=e=>{C("close",e)},E=e=>{e.keyCode===B.ESC&&(e.stopPropagation(),w(e))},g=()=>{const{open:e,afterVisibleChange:l}=n;l&&l(!!e)},v=({level:e,getContainer:l})=>{if(X)return;const a=l?.(),o=a?a.parentNode:null;m=[],e==="all"?(o?Array.prototype.slice.call(o.children):[]).forEach(t=>{t.nodeName!=="SCRIPT"&&t.nodeName!=="STYLE"&&t.nodeName!=="LINK"&&t!==a&&m.push(t)}):e&&Z(e).forEach(r=>{document.querySelectorAll(r).forEach(t=>{m.push(t)})})},P=e=>{C("handleClick",e)},N=c(!1);return d(u,()=>{p(()=>{N.value=!0})}),()=>{const{width:e,height:l,open:a,prefixCls:o,placement:r,level:t,levelMove:ee,ease:oe,duration:ne,getContainer:te,onChange:ae,afterVisibleChange:re,showMask:S,maskClosable:T,maskStyle:x,keyboard:K,getOpenCount:le,scrollLocker:se,contentWrapperStyle:V,style:I,class:O,rootClassName:R,rootStyle:U,maskMotion:W,motion:h,inline:_,...q}=n,i=a&&N.value,F=G(o,{[`${o}-${r}`]:!0,[`${o}-open`]:i,[`${o}-inline`]:_,"no-mask":!S,[R]:!0}),H=typeof h=="function"?h(r):h;return s("div",{...J(q,["autofocus"]),tabindex:-1,class:F,style:U,ref:u,onKeydown:i&&K?E:void 0},[s(b,W,{default:()=>[S&&D(s("div",{class:`${o}-mask`,onClick:T?w:void 0,style:x,ref:$},null),[[L,i]])]}),s(b,{...H,onAfterEnter:g,onAfterLeave:g},{default:()=>[D(s("div",{class:`${o}-content-wrapper`,style:[V],ref:M},[s("div",{class:[`${o}-content`,O],style:I,ref:k},[f.default?.()]),f.handler?s("div",{onClick:P,ref:A},[f.handler?.()]):null]),[[L,i]])]})])}}});export{he as default};
