import{d as w,G as x,o as D,e as C,p as G,H,b as c,r as P,E as _}from"./BvNnk7SS.js";const X=w({__name:"LoadingProgress",props:{loading:{type:Boolean},throttle:{default:20},duration:{default:200},height:{default:3},color:{type:[String,Boolean],default:"repeating-linear-gradient(to right,#00dc82 0%,#34cdfe 50%,#0047e1 100%)"},estimatedProgress:{}},setup(L){const s=L;function b(e,a){const n=a/e*100;return 2/Math.PI*100*Math.atan(n/50)}function k(){const e=s.duration,a=s.throttle,n=500,S=400,$=s.estimatedProgress||b,o=P(0),r=P(!1);let i=!1,l,f,m,g;const z=()=>h(0);function h(t=0){if(t>=100)return p();u(),o.value=t<0?0:t,a?f=setTimeout(()=>{r.value=!0,v()},a):(r.value=!0,v())}function A(){m=setTimeout(()=>{r.value=!1,g=setTimeout(()=>{o.value=0},S)},n)}function p(t={}){o.value=100,i=!0,u(),F(),t.force?(o.value=0,r.value=!1):A()}function F(){clearTimeout(m),clearTimeout(g)}function u(){clearTimeout(f),cancelAnimationFrame(l)}function v(){i=!1;let t;function T(y){if(i)return;t??=y;const q=y-t;o.value=Math.max(0,Math.min(100,$(e,q))),l=requestAnimationFrame(T)}l=requestAnimationFrame(T)}return{progress:_(()=>o.value),isLoading:_(()=>r.value),start:z,set:h,finish:p,clear:u}}const{clear:B,finish:E,start:I,isLoading:M,progress:d}=k();return x(()=>s.loading,e=>{e?I():(E(),B())},{immediate:!0}),(e,a)=>(D(),C("div",{class:"loading-progress-indicator",style:H({position:"absolute",top:"0",right:"0",left:"0",pointerEvents:"none",width:"auto",height:`${e.height}px`,opacity:c(M)?"1":"0",background:e.color||void 0,backgroundSize:`${100/c(d)*100}% auto`,transform:`scaleX(${c(d)}%)`,transformOrigin:"left",transition:"transform 0.1s, height 0.4s, opacity 0.4s",zIndex:"999999"})},[G(e.$slots,"default")],4))}});export{X as _};
