"use strict";var u=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var x=(a,t)=>{for(var s in t)u(a,s,{get:t[s],enumerable:!0})},P=(a,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of O(t))!R.call(a,r)&&r!==s&&u(a,r,{get:()=>t[r],enumerable:!(i=v(t,r))||i.enumerable});return a};var L=a=>P(u({},"__esModule",{value:!0}),a);var $={};x($,{ProgressBar:()=>w});module.exports=L($);var _=require("os"),c=require("@opentf/cli-styles"),o=require("@opentf/std");var m="\u2588",A="\u2501",d="\u2586",C="=",g="-";var f=class{_options={stream:process.stderr,width:30,color:"g",bgColor:"gr",autoClear:!1,size:"DEFAULT",prefix:"",suffix:"",showPercent:!0,showCount:!1,variant:"STANDARD"};_bars;constructor(t){let s=t?.variant==="PLAIN"?{...this._options,color:"",bgColor:""}:this._options;this._options=(0,o.shallowMerge)(s,t),this._bars=[]}_getBarCharBySize(t){let s=t||this._options.size;return s==="SMALL"?A:s==="MEDIUM"?d:m}_getBars(t,s){let i,r,n=t.color||this._options.color,h=t.bgColor||this._options.bgColor,e=Math.trunc((0,o.percentageOf)(s,this._options.width));if(this._options.variant==="PLAIN")i=(0,c.style)(`$${n}.bol{${C}}`).repeat(e),r=(0,c.style)(`$${h}.dim{${g}}`).repeat(this._options.width-e);else{let p=this._getBarCharBySize(t.size);i=(0,c.style)(`$${n}.bol{${p}}`).repeat(e),r=(0,c.style)(`$${h}.dim{${p}}`).repeat(this._options.width-e)}return i+r}_render(){this._bars.forEach((t,s)=>{let i="";s>0&&this._options.stream.isTTY&&this._options.stream.write(_.EOL);let r=Object.hasOwn(t,"prefix")?t.prefix:this._options.prefix,n=Object.hasOwn(t,"suffix")?t.suffix:this._options.suffix,h=Object.hasOwn(t,"showPercent")?t.showPercent:this._options.showPercent,e=Object.hasOwn(t,"showCount")?t.showCount:this._options.showCount,p=Object.hasOwn(t,"variant")?t.variant:this._options.variant,l=t.total?Math.trunc((0,o.percentage)(isNaN(t.value)?0:t.value,t.total)):0;if(t.progress&&this._options.stream.isTTY){let B=this._getBars(t,l);i+=(0,o.intersperse)((0,o.compact)([r,p==="PLAIN"?`[${B}]`:B,h?l+"%":null,e?`[${t.value||0}/${t.total||0}]`:null,n])," ").join("")}else i+=r+" "+n;if(!this._options.stream.isTTY){i=(0,o.intersperse)((0,o.compact)(["\u23F3",r,h?l+"%":null,e?`[${t.value||0}/${t.total||0}]`:null,n])," ").join(""),this._options.stream.write(i+_.EOL);return}this._options.stream.cursorTo(0)&&this._options.stream.clearLine(0)&&this._options.stream.write(i)})}start(t){(0,o.isObj)(t)&&this._bars.push({...t,progress:!0}),this._render()}_clear(){this._options.stream.moveCursor(0,-(this._bars.length-1)),this._options.stream.cursorTo(0),this._options.stream.clearScreenDown()}stop(t){if(this._options.autoClear){this._clear(),t&&this._options.stream.write(t+_.EOL);return}this._options.stream.write(_.EOL)}update(t,s){if(!s)this._bars[0]={...this._bars[0],...t};else{let i=this._bars.findIndex(r=>(0,o.isObj)(r)&&r.id===s);this._bars[i]={...this._bars[i],...t}}this._options.stream.moveCursor(0,-(this._bars.length-1)),this._render()}add(t){let s=this._bars.length+1,i={progress:!0,...t,id:s};return this._bars.push(i),this._bars.length>2&&this._options.stream.moveCursor(0,-(this._bars.length-2)),this._render(),{update:r=>{this.update(r,s)},inc:(r,n=1)=>{let e=this._bars.find(p=>p.id===s)?.value||0;this.update({...r,value:e+n},s)}}}inc(t,s=1){let i=this._bars[0]?.value||0;this.update({...t,value:i+s})}},w=f;0&&(module.exports={ProgressBar}); //# sourceMappingURL=index.cjs.map