import{A as e,Dt as t,F as n,Kt as r,M as i,Qt as a,Rt as o,St as s,V as c,_t as l,a as u,bt as d,dt as f,ft as p,p as m,r as h,zt as g}from"./_plugin-vue_export-helper-C0lsYS1a.js";import{V as _,a as v,c as y,r as b,t as x}from"./style-Bvb0L3Ww.js";function S(r,a){let o,c=s(!1),l=d({...r,originalPosition:``,originalOverflow:``,visible:!1});function g(e){l.text=e}function _(){let e=l.parent,t=w.ns;if(!e.vLoadingAddClassList){let n=e.getAttribute(`loading-number`);n=Number.parseInt(n)-1,n?e.setAttribute(`loading-number`,n.toString()):(v(e,t.bm(`parent`,`relative`)),e.removeAttribute(`loading-number`)),v(e,t.bm(`parent`,`hidden`))}b(),C.unmount()}function b(){var e;(e=w.$el?.parentNode)==null||e.removeChild(w.$el)}function x(){var e;r.beforeClose&&!r.beforeClose()||(c.value=!0,clearTimeout(o),o=setTimeout(S,400),l.visible=!1,(e=r.closed)==null||e.call(r))}function S(){if(!c.value)return;let e=l.parent;c.value=!1,e.vLoadingAddClassList=void 0,_()}let C=u(i({name:`ElLoading`,setup(t,{expose:r}){let{ns:i,zIndex:a}=y(`loading`);return r({ns:i,zIndex:a}),()=>{let t=l.spinner||l.svg,r=n(`svg`,{class:`circular`,viewBox:l.svgViewBox?l.svgViewBox:`0 0 50 50`,...t?{innerHTML:t}:{}},[n(`circle`,{class:`path`,cx:`25`,cy:`25`,r:`20`,fill:`none`})]),a=l.text?n(`p`,{class:i.b(`text`)},[l.text]):void 0;return n(h,{name:i.b(`fade`),onAfterLeave:S},{default:f(()=>[p(e(`div`,{style:{backgroundColor:l.background||``},class:[i.b(`mask`),l.customClass,i.is(`fullscreen`,l.fullscreen)]},[n(`div`,{class:i.b(`spinner`)},[r,a])]),[[m,l.visible]])])})}}}));Object.assign(C._context,a??{});let w=C.mount(document.createElement(`div`));return{...t(l),setText:g,removeElLoadingChild:b,close:x,handleAfterLeave:S,vm:w,get $el(){return w.$el}}}g();var C=void 0,w=function(e={},t){if(!_)return;let n=T(e);if(n.fullscreen&&C)return C;let r=S({...n,closed:()=>{var e;(e=n.closed)==null||e.call(n),n.fullscreen&&(C=void 0)}},t??w._context);E(n,n.parent,r),D(n,n.parent,r),n.parent.vLoadingAddClassList=()=>D(n,n.parent,r);let i=n.parent.getAttribute(`loading-number`);return i=i?`${Number.parseInt(i)+1}`:`1`,n.parent.setAttribute(`loading-number`,i),n.parent.appendChild(r.$el),c(()=>r.visible.value=n.visible),n.fullscreen&&(C=r),r},T=e=>{let t;return t=a(e.target)?document.querySelector(e.target)??document.body:e.target||document.body,{parent:t===document.body||e.body?document.body:t,background:e.background||``,svg:e.svg||``,svgViewBox:e.svgViewBox||``,spinner:e.spinner||!1,text:e.text||``,fullscreen:t===document.body&&(e.fullscreen??!0),lock:e.lock??!1,customClass:e.customClass||``,visible:e.visible??!0,beforeClose:e.beforeClose,closed:e.closed,target:t}},E=async(e,t,n)=>{let{nextZIndex:r}=n.vm.zIndex||n.vm._.exposed.zIndex,i={};if(e.fullscreen)n.originalPosition.value=b(document.body,`position`),n.originalOverflow.value=b(document.body,`overflow`),i.zIndex=r();else if(e.parent===document.body){n.originalPosition.value=b(document.body,`position`),await c();for(let t of[`top`,`left`]){let n=t===`top`?`scrollTop`:`scrollLeft`;i[t]=`${e.target.getBoundingClientRect()[t]+document.body[n]+document.documentElement[n]-Number.parseInt(b(document.body,`margin-${t}`),10)}px`}for(let t of[`height`,`width`])i[t]=`${e.target.getBoundingClientRect()[t]}px`}else n.originalPosition.value=b(t,`position`);for(let[e,t]of Object.entries(i))n.$el.style[e]=t},D=(e,t,n)=>{let r=n.vm.ns||n.vm._.exposed.ns;[`absolute`,`fixed`,`sticky`].includes(n.originalPosition.value)?v(t,r.bm(`parent`,`relative`)):x(t,r.bm(`parent`,`relative`)),e.fullscreen&&e.lock?x(t,r.bm(`parent`,`hidden`)):v(t,r.bm(`parent`,`hidden`))};w._context=null,g();var O=Symbol(`ElLoading`),k=e=>`element-loading-${o(e)}`,A=(e,t)=>{let n=t.instance,i=e=>r(t.value)?t.value[e]:void 0,o=e=>s(a(e)&&n?.[e]||e),c=t=>o(i(t)||e.getAttribute(k(t))),l=i(`fullscreen`)??t.modifiers.fullscreen,u={text:c(`text`),svg:c(`svg`),svgViewBox:c(`svgViewBox`),spinner:c(`spinner`),background:c(`background`),customClass:c(`customClass`),fullscreen:l,target:i(`target`)??(l?void 0:e),body:i(`body`)??t.modifiers.body,lock:i(`lock`)??t.modifiers.lock},d=w(u);d._context=M._context,e[O]={options:u,instance:d}},j=(e,t)=>{for(let n of Object.keys(e))l(e[n])&&(e[n].value=t[n])},M={mounted(e,t){t.value&&A(e,t)},updated(e,t){let n=e[O];if(!t.value){n?.instance.close(),e[O]=null;return}n?j(n.options,r(t.value)?t.value:{text:e.getAttribute(k(`text`)),svg:e.getAttribute(k(`svg`)),svgViewBox:e.getAttribute(k(`svgViewBox`)),spinner:e.getAttribute(k(`spinner`)),background:e.getAttribute(k(`background`)),customClass:e.getAttribute(k(`customClass`))}):A(e,t)},unmounted(e){var t;(t=e[O])==null||t.instance.close(),e[O]=null}};M._context=null;export{w as n,M as t};