import{isLive as t}from"../date/date-range-utils.js";class e{constructor(t){this._overflowWatermark=t,this.reset()}reset(){this._value=0,this._percent=null,this._isLive=!1,this._lastLogDate=null,this._overflowWasNotified=!1}start(e){this._isLive=t(e),this._dateRangeStart=new Date(e.since).getTime(),this._dateRangeDuration=this._isLive?0:new Date(e.until).getTime()-this._dateRangeStart,this._isLive||(this._percent=0)}progress(t){if(0===t.length)return!1;if(this._value=this._value+t.length,this._lastLogDate=t[t.length-1].date,!this._isLive){const t=this._lastLogDate.getTime()-this._dateRangeStart;this._percent=100*t/this._dateRangeDuration}return!this._overflowWasNotified&&this._value>=this._overflowWatermark&&(this._overflowWasNotified=!0,!0)}complete(){this._isLive||(this._percent=100)}getProgress(){return this._isLive?{value:this._value}:{value:this._value,percent:this._percent}}isOverflowing(){return this._value>=this._overflowWatermark}getLastLogDate(){return this._lastLogDate}isLive(){return this._isLive}isEmpty(){return 0===this._value}}export{e as LogsProgress};
//# sourceMappingURL=logs-progress.js.map
