import{G as e,H as t,Q as n,R as r,U as i,V as a,W as o,Y as s,Z as c}from"./icon-K_9KhGme.js";import{C as l,D as u,L as d,P as f,U as p,X as m,Z as h,h as g,mt as _,ot as v,rt as y,tt as b,w as x}from"./vue.esm-bundler-DcNPjsgv.js";import{r as S,t as C}from"./vnode-DPERABh8.js";var w=(e,n,r,i)=>{let a={offsetX:0,offsetY:0},o=v(!1),s=(n,r)=>{if(e.value){let{offsetX:o,offsetY:s}=a,c=e.value.getBoundingClientRect(),l=c.left,u=c.top,d=c.width,f=c.height,p=document.documentElement.clientWidth,m=document.documentElement.clientHeight,h=-l+o,g=-u+s,_=p-l-d+o,v=m-u-(f<m?f:0)+s;i?.value||(n=Math.min(Math.max(n,h),_),r=Math.min(Math.max(r,g),v)),a.offsetX=n,a.offsetY=r,e.value.style.transform=`translate(${t(n)}, ${t(r)})`}},c=e=>{let t=e.clientX,n=e.clientY,{offsetX:r,offsetY:i}=a,c=e=>{o.value||=!0,s(r+e.clientX-t,i+e.clientY-n)},l=()=>{o.value=!1,document.removeEventListener(`mousemove`,c),document.removeEventListener(`mouseup`,l)};document.addEventListener(`mousemove`,c),document.addEventListener(`mouseup`,l)},l=()=>{n.value&&e.value&&(n.value.addEventListener(`mousedown`,c),window.addEventListener(`resize`,m))},u=()=>{n.value&&e.value&&(n.value.removeEventListener(`mousedown`,c),window.removeEventListener(`resize`,m))},p=()=>{a.offsetX=0,a.offsetY=0,e.value&&(e.value.style.transform=``)},m=()=>{let{offsetX:e,offsetY:t}=a;s(e,t)};return d(()=>{h(()=>{r.value?l():u()})}),f(()=>{u()}),{isDragging:o,resetPosition:p,updatePosition:m}},T=(t,n={})=>{b(t)||s(`[useLockscreen]`,`You need to pass a ref param to this function`);let c=n.ns||r(`popup`),l=g(()=>c.bm(`parent`,`hidden`)),u=0,d=!1,f=`0`,p=!1,h=()=>{p||(p=!0,setTimeout(()=>{typeof document>`u`||d&&document&&(document.body.style.width=f,e(document.body,l.value))},200))};m(t,e=>{if(!e){h();return}p=!1,d=!o(document.body,l.value),d&&(f=document.body.style.width,a(document.body,l.value)),u=S(c.namespace.value);let t=document.documentElement.clientHeight<document.body.scrollHeight,n=i(document.body,`overflowY`);u>0&&(t||n===`scroll`)&&d&&(document.body.style.width=`calc(100% - ${u}px)`)}),y(()=>h())},E=e=>{if(!e)return{onClick:_,onMousedown:_,onMouseup:_};let t=!1,n=!1;return{onClick:r=>{t&&n&&e(r),t=n=!1},onMousedown:e=>{t=e.target===e.currentTarget},onMouseup:e=>{n=e.target===e.currentTarget}}},D=c({mask:{type:Boolean,default:!0},customMaskEvent:Boolean,overlayClass:{type:n([String,Array,Object])},zIndex:{type:n([String,Number])}}),O={click:e=>e instanceof MouseEvent},k=`overlay`,A=x({name:`ElOverlay`,props:D,emits:O,setup(e,{slots:t,emit:n}){let i=r(k),{onClick:a,onMousedown:o,onMouseup:s}=E(e.customMaskEvent?void 0:e=>{n(`click`,e)});return()=>e.mask?l(`div`,{class:[i.b(),e.overlayClass],style:{zIndex:e.zIndex},onClick:a,onMousedown:o,onMouseup:s},[p(t,`default`)],C.STYLE|C.CLASS|C.PROPS,[`onClick`,`onMouseup`,`onMousedown`]):u(`div`,{class:e.overlayClass,style:{zIndex:e.zIndex,position:`fixed`,top:`0px`,right:`0px`,bottom:`0px`,left:`0px`}},[p(t,`default`)])}});export{w as i,E as n,T as r,A as t};