import{u as g}from"./nuxt-link.a91ddf68.js";import"./app.config.5ff5ca90.js";import{f as p,o as m,h as v,r as l,c as x}from"./runtime-core.esm-bundler.24b58585.js";const N=p({name:"NuxtLoadingIndicator",props:{throttle:{type:Number,default:200},duration:{type:Number,default:2e3},height:{type:Number,default:3},color:{type:[String,Boolean],default:"repeating-linear-gradient(to right,#00dc82 0%,#34cdfe 50%,#0047e1 100%)"}},setup(e,{slots:n}){const t=y({duration:e.duration,throttle:e.throttle}),o=g();return o.hook("page:start",t.start),o.hook("page:finish",t.finish),m(()=>t.clear),()=>v("div",{class:"nuxt-loading-indicator",style:{position:"fixed",top:0,right:0,left:0,pointerEvents:"none",width:`${t.progress.value}%`,height:`${e.height}px`,opacity:t.isLoading.value?1:0,background:e.color||void 0,backgroundSize:`${100/t.progress.value*100}% auto`,transition:"width 0.1s, height 0.4s, opacity 0.4s",zIndex:999999}},n)}});function y(e){const n=l(0),t=l(!1),o=x(()=>1e4/e.duration);let i=null,a=null;function s(){r(),n.value=0,e.throttle?a=setTimeout(()=>{t.value=!0,u()},e.throttle):(t.value=!0,u())}function c(){n.value=100,f()}function r(){clearInterval(i),clearTimeout(a),i=null,a=null}function d(h){n.value=Math.min(100,n.value+h)}function f(){r(),setTimeout(()=>{t.value=!1,setTimeout(()=>{n.value=0},400)},500)}function u(){i=setInterval(()=>{d(o.value)},100)}return{progress:n,isLoading:t,start:s,finish:c,clear:r}}export{N as default};
