import{r as A,M as E,aS as O,aA as P,a2 as j,bG as z,bK as m,w as R,i as D,h as G,v as K,aC as M,aO as Z,a5 as I,ad as S,aD as $,m as q,c0 as F}from"./index-25eb6331.js";import{$ as y,Q as g,Z as h}from"./index-3bef6acb.js";function H(t,e){let l;const o=A(!1),n=E({...t,originalPosition:"",originalOverflow:"",visible:!1});function a(s){n.text=s}function u(){const s=n.parent,r=v.ns;if(!s.vLoadingAddClassList){let i=s.getAttribute("loading-number");i=Number.parseInt(i)-1,i?s.setAttribute("loading-number",i.toString()):(y(s,r.bm("parent","relative")),s.removeAttribute("loading-number")),y(s,r.bm("parent","hidden"))}d(),f.unmount()}function d(){var s,r;(r=(s=v.$el)==null?void 0:s.parentNode)==null||r.removeChild(v.$el)}function C(){var s;t.beforeClose&&!t.beforeClose()||(o.value=!0,clearTimeout(l),l=setTimeout(c,400),n.visible=!1,(s=t.closed)==null||s.call(t))}function c(){if(!o.value)return;const s=n.parent;o.value=!1,s.vLoadingAddClassList=void 0,u()}const b=j({name:"ElLoading",setup(s,{expose:r}){const{ns:i,zIndex:T}=z("loading");return r({ns:i,zIndex:T}),()=>{const L=n.spinner||n.svg,V=m("svg",{class:"circular",viewBox:n.svgViewBox?n.svgViewBox:"0 0 50 50",...L?{innerHTML:L}:{}},[m("circle",{class:"path",cx:"25",cy:"25",r:"20",fill:"none"})]),N=n.text?m("p",{class:i.b("text")},[n.text]):void 0;return m(M,{name:i.b("fade"),onAfterLeave:c},{default:R(()=>[D(G("div",{style:{backgroundColor:n.background||""},class:[i.b("mask"),n.customClass,n.fullscreen?"is-fullscreen":""]},[m("div",{class:i.b("spinner")},[V,N])]),[[K,n.visible]])])})}}}),f=O(b);Object.assign(f._context,e!=null?e:{});const v=f.mount(document.createElement("div"));return{...P(n),setText:a,removeElLoadingChild:d,close:C,handleAfterLeave:c,vm:v,get $el(){return v.$el}}}let p;const _=function(t={}){if(!Z)return;const e=Q(t);if(e.fullscreen&&p)return p;const l=H({...e,closed:()=>{var n;(n=e.closed)==null||n.call(e),e.fullscreen&&(p=void 0)}},_._context);Y(e,e.parent,l),k(e,e.parent,l),e.parent.vLoadingAddClassList=()=>k(e,e.parent,l);let o=e.parent.getAttribute("loading-number");return o?o="".concat(Number.parseInt(o)+1):o="1",e.parent.setAttribute("loading-number",o),e.parent.appendChild(l.$el),I(()=>l.visible.value=e.visible),e.fullscreen&&(p=l),l},Q=t=>{var e,l,o,n;let a;return S(t.target)?a=(e=document.querySelector(t.target))!=null?e:document.body:a=t.target||document.body,{parent:a===document.body||t.body?document.body:a,background:t.background||"",svg:t.svg||"",svgViewBox:t.svgViewBox||"",spinner:t.spinner||!1,text:t.text||"",fullscreen:a===document.body&&((l=t.fullscreen)!=null?l:!0),lock:(o=t.lock)!=null?o:!1,customClass:t.customClass||"",visible:(n=t.visible)!=null?n:!0,beforeClose:t.beforeClose,closed:t.closed,target:a}},Y=async(t,e,l)=>{const{nextZIndex:o}=l.vm.zIndex||l.vm._.exposed.zIndex,n={};if(t.fullscreen)l.originalPosition.value=g(document.body,"position"),l.originalOverflow.value=g(document.body,"overflow"),n.zIndex=o();else if(t.parent===document.body){l.originalPosition.value=g(document.body,"position"),await I();for(const a of["top","left"]){const u=a==="top"?"scrollTop":"scrollLeft";n[a]="".concat(t.target.getBoundingClientRect()[a]+document.body[u]+document.documentElement[u]-Number.parseInt(g(document.body,"margin-".concat(a)),10),"px")}for(const a of["height","width"])n[a]="".concat(t.target.getBoundingClientRect()[a],"px")}else l.originalPosition.value=g(e,"position");for(const[a,u]of Object.entries(n))l.$el.style[a]=u},k=(t,e,l)=>{const o=l.vm.ns||l.vm._.exposed.ns;["absolute","fixed","sticky"].includes(l.originalPosition.value)?y(e,o.bm("parent","relative")):h(e,o.bm("parent","relative")),t.fullscreen&&t.lock?h(e,o.bm("parent","hidden")):y(e,o.bm("parent","hidden"))};_._context=null;const x=Symbol("ElLoading"),w=(t,e)=>{var l,o,n,a;const u=e.instance,d=s=>$(e.value)?e.value[s]:void 0,C=s=>{const r=S(s)&&(u==null?void 0:u[s])||s;return r&&A(r)},c=s=>C(d(s)||t.getAttribute("element-loading-".concat(F(s)))),b=(l=d("fullscreen"))!=null?l:e.modifiers.fullscreen,f={text:c("text"),svg:c("svg"),svgViewBox:c("svgViewBox"),spinner:c("spinner"),background:c("background"),customClass:c("customClass"),fullscreen:b,target:(o=d("target"))!=null?o:b?void 0:t,body:(n=d("body"))!=null?n:e.modifiers.body,lock:(a=d("lock"))!=null?a:e.modifiers.lock},v=_(f);v._context=B._context,t[x]={options:f,instance:v}},J=(t,e)=>{for(const l of Object.keys(e))q(e[l])&&(e[l].value=t[l])},B={mounted(t,e){e.value&&w(t,e)},updated(t,e){const l=t[x];e.oldValue!==e.value&&(e.value&&!e.oldValue?w(t,e):e.value&&e.oldValue?$(e.value)&&J(e.value,l.options):l==null||l.instance.close())},unmounted(t){var e;(e=t[x])==null||e.instance.close(),t[x]=null}};B._context=null;export{_ as L,B as v};
