class r {
  constructor(e = 50) {
    this.store = /* @__PURE__ */ new Map(), this.maxSize = e, this.isExpired = !1, this.expiredTimer = null;
  }
  changeMaxSize(e) {
    this.maxSize = e;
  }
  expireCheck() {
    this.isExpired && (clearTimeout(this.expiredTimer), this.expiredTimer = setTimeout(() => {
      this.isExpired = !1;
    }));
  }
  has(e) {
    return this.expireCheck(), this.store.has(e);
  }
  get(e) {
    if (this.expireCheck(), !this.has(e))
      return null;
    const s = this.store.get(e);
    return this.store.delete(e), this.store.set(e, s), s;
  }
  set(e, s) {
    if (this.expireCheck(), !this.isExpired) {
      if (this.has(e))
        this.store.delete(e);
      else if (this.store.size >= this.maxSize) {
        const t = this.store.keys().next().value;
        t && this.store.delete(t);
      }
      Array.isArray(s) && (s = new Map(s)), this.store.set(e, s);
    }
  }
  del(e) {
    this.isExpired = !0, this.store.delete(e);
  }
  clear() {
    this.store.clear();
  }
}
export {
  r as LruCacher,
  r as default
};
