import{af as L,aI as y,aJ as H,z as m,n as p}from"./B7moA0Zy.js";function S(a,e){const o=e/a*100;return 2/Math.PI*100*Math.atan(o/50)}function q(a={}){const{duration:e=2e3,throttle:o=200,hideDelay:P=500,resetDelay:k=400}=a,x=a.estimatedProgress||S,i=L(),n=m(0),r=m(!1),d=m(!1);let f=!1,g,v,h,I;const _=()=>{d.value=!1,T(0)};function T(t=0){if(!i.isHydrating){if(t>=100)return s();u(),n.value=t<0?0:t,o?v=setTimeout(()=>{r.value=!0,D()},o):(r.value=!0,D())}}function F(){h=setTimeout(()=>{r.value=!1,I=setTimeout(()=>{n.value=0},k)},P)}function s(t={}){n.value=100,f=!0,u(),M(),t.error&&(d.value=!0),t.force?(n.value=0,r.value=!1):F()}function M(){clearTimeout(h),clearTimeout(I)}function u(){clearTimeout(v),cancelAnimationFrame(g)}function D(){f=!1;let t;function l(c){if(f)return;t??(t=c);const b=c-t;n.value=Math.max(0,Math.min(100,x(e,b))),g=requestAnimationFrame(l)}g=requestAnimationFrame(l)}let A=()=>{};{const t=i.hook("page:loading:start",()=>{_()}),l=i.hook("page:loading:end",()=>{s()}),c=i.hook("vue:error",()=>s());A=()=>{c(),t(),l(),u()}}return{_cleanup:A,progress:p(()=>n.value),isLoading:p(()=>r.value),error:p(()=>d.value),start:_,set:T,finish:s,clear:u}}function z(a={}){const e=L(),o=e._loadingIndicator=e._loadingIndicator||q(a);return y()&&(e._loadingIndicatorDeps=e._loadingIndicatorDeps||0,e._loadingIndicatorDeps++,H(()=>{e._loadingIndicatorDeps--,e._loadingIndicatorDeps===0&&(o._cleanup(),delete e._loadingIndicator)})),o}export{z as u};