"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const array = require("./dist-es-utils-array.cjs");
class SubscriptionManager {
  constructor() {
    this.subscriptions = [];
  }
  add(handler) {
    array.addUniqueItem(this.subscriptions, handler);
    return () => array.removeItem(this.subscriptions, handler);
  }
  notify(a, b, c) {
    const numSubscriptions = this.subscriptions.length;
    if (!numSubscriptions)
      return;
    if (numSubscriptions === 1) {
      this.subscriptions[0](a, b, c);
    } else {
      for (let i = 0; i < numSubscriptions; i++) {
        const handler = this.subscriptions[i];
        handler && handler(a, b, c);
      }
    }
  }
  getSize() {
    return this.subscriptions.length;
  }
  clear() {
    this.subscriptions.length = 0;
  }
}
exports.SubscriptionManager = SubscriptionManager;
//# sourceMappingURL=dist-es-utils-subscription-manager.cjs.map
