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