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