"use strict";(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["app/app/progress"],{1348:(e,s,t)=>{t.r(s);var r=t(92),o=t(88);class n extends o.Component{constructor(...e){super(...e),(0,r.default)(this,"STATUS_STARTED",0),(0,r.default)(this,"STATUS_NOT_STARTED",1),(0,r.default)(this,"STATUS_DONE",2),(0,r.default)(this,"STATUS_ERROR",3)}_initConfiguration(e){super._initConfiguration({locale:o.Locale.getSection("smb.components.elements.download"),...e}),setTimeout((()=>{this.updateProgress()}),1e3)}_initComponentElement(){this._progressTextElement=new Element("div",{class:"progress-label"}),this._progressBarElement=new Element("div",{class:"progress"}),this._progressBarElement.innerHTML='<div class="progress-bar"></div>',this._componentElement=new Element("div",{class:"progress-box app-progress-panel"}),this._componentElement.appendChild(this._progressTextElement),this._componentElement.appendChild(this._progressBarElement),this._update(0)}_update(e){e=Math.max(e,1),this._progressTextElement.innerHTML=this.lmsg("progress",{percents:e}),this._progressBarElement.querySelectorAll("div.progress-bar").forEach((s=>{s.style.width=`${e}%`}))}updateProgress(){new Ajax.Request(this._getConfigParam("requestUrl"),{method:"get",onSuccess:e=>{try{const s=JSON.parse(e.responseText);if(s.progress&&this._update(s.progress),s.status===this.STATUS_STARTED||s.status===this.STATUS_NOT_STARTED)return void setTimeout((()=>{this.updateProgress()}),this._getConfigParam("timeout",1e3));s.url=s.url?s.url:this._getConfigParam("redirectUrl").replace("%packageId%",s.packageId).replace("%resourceId%",s.resourceId),s.method=this._getConfigParam("redirectMethod","get"),(0,o.redirect)(s)}catch{}}})}}s.default=e=>{new n(e)}}}]);
//# sourceMappingURL=progress.js.map?a2c3231c9c1a86468ef0