var f = (i) => {
  throw TypeError(i);
};
var l = (i, e, n) => e.has(i) || f("Cannot " + n);
var r = (i, e, n) => (l(i, e, "read from private field"), n ? n.call(i) : e.get(i)), d = (i, e, n) => e.has(i) ? f("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(i) : e.set(i, n), o = (i, e, n, s) => (l(i, e, "write to private field"), s ? s.call(i, n) : e.set(i, n), n);
import { Subscribable as v } from "./subscribable.js";
import { isServer as u } from "./utils.js";
var h, t, a, c, w = (c = class extends v {
  constructor() {
    super();
    d(this, h, !0);
    d(this, t);
    d(this, a);
    o(this, a, (e) => {
      if (!u && window.addEventListener) {
        const n = () => e(!0), s = () => e(!1);
        return window.addEventListener("online", n, !1), window.addEventListener("offline", s, !1), () => {
          window.removeEventListener("online", n), window.removeEventListener("offline", s);
        };
      }
    });
  }
  onSubscribe() {
    r(this, t) || this.setEventListener(r(this, a));
  }
  onUnsubscribe() {
    var e;
    this.hasListeners() || ((e = r(this, t)) == null || e.call(this), o(this, t, void 0));
  }
  setEventListener(e) {
    var n;
    o(this, a, e), (n = r(this, t)) == null || n.call(this), o(this, t, e(this.setOnline.bind(this)));
  }
  setOnline(e) {
    r(this, h) !== e && (o(this, h, e), this.listeners.forEach((s) => {
      s(e);
    }));
  }
  isOnline() {
    return r(this, h);
  }
}, h = new WeakMap(), t = new WeakMap(), a = new WeakMap(), c), m = new w();
export {
  w as OnlineManager,
  m as onlineManager
};
//# sourceMappingURL=onlineManager.js.map
