"use strict";(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["app/app/progress"],{2001:(e,t,s)=>{s.r(t),s.d(t,{default:()=>n});var r=s(94),a=s(90),i=s(297);class o extends a.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:a.Locale.getSection("smb.components.elements.download"),...e}),setTimeout((()=>{this.updateProgress()}),1e3)}_initComponentElement(){this._progressTextElement=(0,i.createHtmlElement)("div",{class:"progress-label"}),this._progressBarElement=(0,i.createHtmlElement)("div",{class:"progress"}),this._progressBarElement.innerHTML='<div class="progress-bar"></div>',this._componentElement=(0,i.createHtmlElement)("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((t=>{t.style.width=`${e}%`}))}updateProgress(){a.api.get(this._getConfigParam("requestUrl")).then((e=>{e.progress&&this._update(e.progress),e.status!==this.STATUS_STARTED&&e.status!==this.STATUS_NOT_STARTED?(e.url=e.url?e.url:this._getConfigParam("redirectUrl").replace("%packageId%",e.packageId).replace("%resourceId%",e.resourceId),e.method=this._getConfigParam("redirectMethod","get"),(0,a.redirect)(e)):setTimeout((()=>{this.updateProgress()}),this._getConfigParam("timeout",1e3))}))}}const n=e=>{new o(e)}}}]);
//# sourceMappingURL=progress.js.map?4e1aaefc785df772488a