import*as Common from"../common/common.js";import{VBox}from"./Widget.js";export class ThrottledWidget extends VBox{constructor(e,t){super(e),this._updateThrottler=new Common.Throttler.Throttler(void 0===t?100:t),this._updateWhenVisible=!1}doUpdate(){return Promise.resolve()}update(){this._updateWhenVisible=!this.isShowing(),this._updateWhenVisible||this._updateThrottler.schedule((()=>this.isShowing()?this.doUpdate():(this._updateWhenVisible=!0,Promise.resolve())))}wasShown(){super.wasShown(),this._updateWhenVisible&&this.update()}}