var i=this&&this.__assign||function(){return(i=Object.assign||function(i){for(var a,s=1,n=arguments.length;s<n;s++)for(var e in a=arguments[s])Object.prototype.hasOwnProperty.call(a,e)&&(i[e]=a[e]);return i}).apply(this,arguments)},a=function(){function t(a,s,n){var e=this;this.target=a,this.endVal=s,this.options=n,this.version="2.0.4",this.defaults={startVal:0,decimalPlaces:0,duration:2,useEasing:!0,useGrouping:!0,smartEasingThreshold:999,smartEasingAmount:333,separator:",",decimal:".",prefix:"",suffix:""},this.finalEndVal=null,this.useEasing=!0,this.countDown=!1,this.error="",this.startVal=0,this.paused=!0,this.count=function(i){e.startTime||(e.startTime=i);var a=i-e.startTime;e.remaining=e.duration-a,e.useEasing?e.countDown?e.frameVal=e.startVal-e.easingFn(a,0,e.startVal-e.endVal,e.duration):e.frameVal=e.easingFn(a,e.startVal,e.endVal-e.startVal,e.duration):e.countDown?e.frameVal=e.startVal-(e.startVal-e.endVal)*(a/e.duration):e.frameVal=e.startVal+(e.endVal-e.startVal)*(a/e.duration),e.countDown?e.frameVal=e.frameVal<e.endVal?e.endVal:e.frameVal:e.frameVal=e.frameVal>e.endVal?e.endVal:e.frameVal,e.frameVal=Math.round(e.frameVal*e.decimalMult)/e.decimalMult,e.printValue(e.frameVal),a<e.duration?e.rAF=requestAnimationFrame(e.count):null!==e.finalEndVal?e.update(e.finalEndVal):e.callback&&e.callback()},this.formatNumber=function(i){var a,s,n,r,o,l=i<0?"-":"";if(a=Math.abs(i).toFixed(e.options.decimalPlaces),n=(s=(a+="").split("."))[0],r=s.length>1?e.options.decimal+s[1]:"",e.options.useGrouping){o="";for(var h=0,u=n.length;h<u;++h)0!==h&&h%3==0&&(o=e.options.separator+o),o=n[u-h-1]+o;n=o}return e.options.numerals&&e.options.numerals.length&&(n=n.replace(/[0-9]/g,(function(i){return e.options.numerals[+i]})),r=r.replace(/[0-9]/g,(function(i){return e.options.numerals[+i]}))),l+e.options.prefix+n+r+e.options.suffix},this.easeOutExpo=function(i,a,s,n){return s*(1-Math.pow(2,-10*i/n))*1024/1023+a},this.options=i({},this.defaults,n),this.formattingFn=this.options.formattingFn?this.options.formattingFn:this.formatNumber,this.easingFn=this.options.easingFn?this.options.easingFn:this.easeOutExpo,this.startVal=this.validateValue(this.options.startVal),this.frameVal=this.startVal,this.endVal=this.validateValue(s),this.options.decimalPlaces=Math.max(this.options.decimalPlaces),this.decimalMult=Math.pow(10,this.options.decimalPlaces),this.resetDuration(),this.options.separator=String(this.options.separator),this.useEasing=this.options.useEasing,""===this.options.separator&&(this.options.useGrouping=!1),this.el="string"==typeof a?globalThis.document.getElementById(a):a,this.el?this.printValue(this.startVal):this.error="[CountUp] target is null or undefined"}return t.prototype.determineDirectionAndSmartEasing=function(){var i=this.finalEndVal?this.finalEndVal:this.endVal;this.countDown=this.startVal>i;var a=i-this.startVal;if(Math.abs(a)>this.options.smartEasingThreshold){this.finalEndVal=i;var s=this.countDown?1:-1;this.endVal=i+s*this.options.smartEasingAmount,this.duration=this.duration/2}else this.endVal=i,this.finalEndVal=null;this.finalEndVal?this.useEasing=!1:this.useEasing=this.options.useEasing},t.prototype.start=function(i){this.error||(this.callback=i,this.duration>0?(this.determineDirectionAndSmartEasing(),this.paused=!1,this.rAF=requestAnimationFrame(this.count)):this.printValue(this.endVal))},t.prototype.pauseResume=function(){this.paused?(this.startTime=null,this.duration=this.remaining,this.startVal=this.frameVal,this.determineDirectionAndSmartEasing(),this.rAF=requestAnimationFrame(this.count)):cancelAnimationFrame(this.rAF),this.paused=!this.paused},t.prototype.reset=function(){cancelAnimationFrame(this.rAF),this.paused=!0,this.resetDuration(),this.startVal=this.validateValue(this.options.startVal),this.frameVal=this.startVal,this.printValue(this.startVal)},t.prototype.update=function(i){cancelAnimationFrame(this.rAF),this.startTime=null,this.endVal=this.validateValue(i),this.endVal!==this.frameVal&&(this.startVal=this.frameVal,this.finalEndVal||this.resetDuration(),this.determineDirectionAndSmartEasing(),this.rAF=requestAnimationFrame(this.count))},t.prototype.printValue=function(i){var a=this.formattingFn(i);"INPUT"===this.el.tagName?this.el.value=a:"text"===this.el.tagName||"tspan"===this.el.tagName?this.el.textContent=a:this.el.innerHTML=a},t.prototype.ensureNumber=function(i){return"number"==typeof i&&!isNaN(i)},t.prototype.validateValue=function(i){var a=Number(i);return this.ensureNumber(a)?a:(this.error="[CountUp] invalid start or end value: "+i,null)},t.prototype.resetDuration=function(){this.startTime=null,this.duration=1e3*Number(this.options.duration),this.remaining=this.duration},t}();export{a as CountUp};