class DebouncedRequestListener {
  constructor() {
    this._debounceTime = 1500;
    this.requests = new Map();
    this.requestsLoadingBar = [];
  }
  onRequestStart(param) {
    if (param.url.includes("quietMode=true")) {
      return;
    }
    this.requestsLoadingBar.push(param.requestId);
    const timeout = setTimeout(() => {
      this.ezLoadingBar.show();
    }, this._debounceTime);
    this.requests.set(param.requestId, timeout);
  }
  ;
  onRequestEnd(param) {
    var _a, _b, _c;
    const timeoutId = this.requests.get(param.requestId);
    clearTimeout(timeoutId);
    if ((_a = this.requestsLoadingBar) === null || _a === void 0 ? void 0 : _a.includes(param.requestId)) {
      this.requestsLoadingBar = (_b = this.requestsLoadingBar) === null || _b === void 0 ? void 0 : _b.filter(id => id !== param.requestId);
      !this.requestsLoadingBar.length && ((_c = this.ezLoadingBar) === null || _c === void 0 ? void 0 : _c.hide());
    }
  }
  ;
}
export default DebouncedRequestListener;
