/* Socket Lib - Built with esbuild */
var w=Object.create;var c=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var S=Object.getPrototypeOf,W=Object.prototype.hasOwnProperty;var y=(r,t)=>{for(var e in t)c(r,e,{get:t[e],enumerable:!0})},u=(r,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of $(t))!W.call(r,n)&&n!==e&&c(r,n,{get:()=>t[n],enumerable:!(s=T(t,n))||s.enumerable});return r};var D=(r,t,e)=>(e=r!=null?w(S(r)):{},u(t||!r||!r.__esModule?c(e,"default",{value:r,enumerable:!0}):e,r)),R=r=>u(c({},"__esModule",{value:!0}),r);var k={};y(k,{ProgressBar:()=>M,createProgressIndicator:()=>P});module.exports=R(k);var l=D(require("../external/yoctocolors-cjs")),o=require("../strings");class M{current=0;total;startTime;lastRender=0;stream;options;terminated=!1;lastDrawnWidth=0;constructor(t,e){this.total=t,this.startTime=Date.now(),this.stream=e?.stream||process.stderr,this.options={width:40,format:":bar :percent :current/:total",complete:"\u2588",incomplete:"\u2591",head:"",clear:!1,renderThrottle:16,stream:this.stream,color:"cyan",...e}}update(t,e){if(this.terminated)return;this.current=Math.min(t,this.total);const s=Date.now();s-this.lastRender<this.options.renderThrottle&&this.current<this.total||(this.lastRender=s,this.render(e),this.current>=this.total&&this.terminate())}tick(t=1,e){this.update(this.current+t,e)}render(t){const e=l.default[this.options.color]||(h=>h),s=Math.floor(this.current/this.total*100),n=Date.now()-this.startTime,a=this.current===0?0:n/this.current*(this.total-this.current),d=this.options.width,m=Math.floor(this.current/this.total*d),p=d-m,f=(0,o.repeatString)(this.options.complete,m),g=(0,o.repeatString)(this.options.incomplete,p),b=e(f)+g;let i=this.options.format;if(i=i.replace(":bar",b),i=i.replace(":percent",`${s}%`),i=i.replace(":current",String(this.current)),i=i.replace(":total",String(this.total)),i=i.replace(":elapsed",this.formatTime(n)),i=i.replace(":eta",this.formatTime(a)),t)for(const[h,v]of Object.entries(t))i=i.replace(`:${h}`,String(v));this.clearLine(),this.stream.write(i),this.lastDrawnWidth=(0,o.stripAnsi)(i).length}clearLine(){this.stream.isTTY?(this.stream.cursorTo(0),this.stream.clearLine(0)):this.lastDrawnWidth>0&&this.stream.write(`\r${(0,o.repeatString)(" ",this.lastDrawnWidth)}\r`)}formatTime(t){const e=Math.round(t/1e3);if(e<60)return`${e}s`;const s=Math.floor(e/60),n=e%60;return`${s}m${n}s`}terminate(){this.terminated||(this.terminated=!0,this.options.clear?this.clearLine():this.stream.write(`
`))}}function P(r,t,e){const s=Math.floor(r/t*100),n=`${r}/${t}`;let a="";return e&&(a+=`${e}: `),a+=`${l.default.cyan(`[${s}%]`)} ${n}`,a}0&&(module.exports={ProgressBar,createProgressIndicator});
//# sourceMappingURL=progress.js.map
