import{createShadowRootWithCoreStyles}from"./utils/create-shadow-root-with-core-styles.js";export class ProgressIndicator{constructor(){this.element=document.createElement("div"),this.element.classList.add("progress-indicator"),this._shadowRoot=createShadowRootWithCoreStyles(this.element,{cssFile:"ui/progressIndicator.css",enableLegacyPatching:!0,delegatesFocus:void 0}),this._contentElement=this._shadowRoot.createChild("div","progress-indicator-shadow-container"),this._labelElement=this._contentElement.createChild("div","title"),this._progressElement=this._contentElement.createChild("progress"),this._progressElement.value=0,this._stopButton=this._contentElement.createChild("button","progress-indicator-shadow-stop-button"),this._stopButton.addEventListener("click",this.cancel.bind(this)),this._isCanceled=!1,this._worked=0}show(e){e.appendChild(this.element)}done(){this._isDone||(this._isDone=!0,this.element.remove())}cancel(){this._isCanceled=!0}isCanceled(){return this._isCanceled}setTitle(e){this._labelElement.textContent=e}setTotalWork(e){this._progressElement.max=e}setWorked(e,t){this._worked=e,this._progressElement.value=e,t&&this.setTitle(t)}worked(e){this.setWorked(this._worked+(e||1))}}