var a = Object.defineProperty;
var d = (t, e, r) => e in t ? a(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
var i = (t, e, r) => d(t, typeof e != "symbol" ? e + "" : e, r);
const c = 1100;
class o {
  constructor() {
    i(this, "order", /* @__PURE__ */ new Map());
    i(this, "kind", /* @__PURE__ */ new Map());
  }
  /** Assign the next slot above all currently-mounted overlays and return its z-index. */
  register(e, r) {
    const s = this.getMaxOrder() + 1;
    return this.order.set(e, s), this.kind.set(e, r), 1100 + s;
  }
  /** Free the slot. The next opener will reuse the now-vacated topmost order. */
  unregister(e) {
    this.order.delete(e), this.kind.delete(e);
  }
  /** Slot order for an id, or 0 if not registered. */
  getOrder(e) {
    return this.order.get(e) ?? 0;
  }
  /**
   * Topmost z-index across all overlays, or — when `kind` is supplied — the
   * topmost z within that kind only. Returns `OVERLAY_BASE_Z_INDEX` (the
   * stacking floor) when nothing of the requested kind is registered.
   */
  getTopmostZIndex(e) {
    return 1100 + this.getMaxOrder(e);
  }
  /** Test-only: wipe internal state. Not for production code paths. */
  __resetForTests() {
    this.order.clear(), this.kind.clear();
  }
  getMaxOrder(e) {
    let r = 0;
    return this.order.forEach((s, n) => {
      e && this.kind.get(n) !== e || s > r && (r = s);
    }), r;
  }
}
const g = new o();
export {
  c as OVERLAY_BASE_Z_INDEX,
  g as OverlayStackingService
};
