if (0 === arguments.length) {
var r, s = Object.keys(n);
for (i = 0; i < s.length; ++i)
"removeListener" !== (r = s[i]) && this.removeAllListeners(r);
return this.removeAllListeners("removeListener"),
this._events = Object.create(null),
this._eventsCount = 0,
this
}
if ("function" == typeof (t = n[e]))
this.removeListener(e, t);
else if (void 0 !== t)
for (i = t.length - 1; i >= 0; i--)
this.removeListener(e, t[i]);
return this
}
,
EventEmitter.prototype.listeners = function(e) {
return _listeners(this, e, !0)
}
,
EventEmitter.prototype.rawListeners = function(e) {
return _listeners(this, e, !1)
}
,
EventEmitter.listenerCount = function(e, t) {
return "function" == typeof e.listenerCount ? e.listenerCount(t) : listenerCount.call(e, t)
}
,
EventEmitter.prototype.listenerCount = listenerCount,
EventEmitter.prototype.eventNames = function() {
return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : []
}
;
var eventsExports = events.exports, EventEmitter$1 = getDefaultExportFromCjs(eventsExports), errorCodes, connectingCodes, disconnectedCodes, subscribingCodes, unsubscribedCodes, subscriptionFlags, State$1, SubscriptionState;
function startsWith(e, t) {
return 0 === e.lastIndexOf(t, 0)
}
function isFunction(e) {
return null != e && "function" == typeof e
}
function log(e, t) {
if (globalThis.console) {
const n = globalThis.console[e];
isFunction(n) && n.apply(globalThis.console, t)
}
}
function randomInt(e, t) {
return Math.floor(Math.random() * (t - e + 1) + e)
}
function backoff(e, t, n) {
e > 31 && (e = 31);
const i = randomInt(0, Math.min(n, t * Math.pow(2, e)));
return Math.min(n, t + i)
}
function errorExists(e) {
return "error"in e && null !== e.error
}
function ttlMilliseconds(e) {
return Math.min(1e3 * e, 2147483647)
}
!function(e) {
e[e.timeout = 1] = "timeout",
e[e.transportClosed = 2] = "transportClosed",
e[e.clientDisconnected = 3] = "clientDisconnected",
e[e.clientClosed = 4] = "clientClosed",
e[e.clientConnectToken = 5] = "clientConnectToken",
e[e.clientRefreshToken = 6] = "clientRefreshToken",
e[e.subscriptionUnsubscribed = 7] = "subscriptionUnsubscribed",
e[e.subscriptionSubscribeToken = 8] = "subscriptionSubscribeToken",
e[e.subscriptionRefreshToken = 9] = "subscriptionRefreshToken",
e[e.transportWriteError = 10] = "transportWriteError",
e[e.connectionClosed = 11] = "connectionClosed",
e[e.badConfiguration = 12] = "badConfiguration"
}(errorCodes || (errorCodes = {})),
function(e) {
e[e.connectCalled = 0] = "connectCalled",
e[e.transportClosed = 1] = "transportClosed",
e[e.noPing = 2] = "noPing",
e[e.subscribeTimeout = 3] = "subscribeTimeout",
e[e.unsubscribeError = 4] = "unsubscribeError"
}(connectingCodes || (connectingCodes = {})),
function(e) {
e[e.disconnectCalled = 0] = "disconnectCalled",
e[e.unauthorized = 1] = "unauthorized",
e[e.badProtocol = 2] = "badProtocol",
e[e.messageSizeLimit = 3] = "messageSizeLimit"
}(disconnectedCodes || (disconnectedCodes = {})),
function(e) {
e[e.subscribeCalled = 0] = "subscribeCalled",
e[e.transportClosed = 1] = "transportClosed"
}(subscribingCodes || (subscribingCodes = {})),
function(e) {
e[e.unsubscribeCalled = 0] = "unsubscribeCalled",
e[e.unauthorized = 1] = "unauthorized",
e[e.clientClosed = 2] = "clientClosed"
}(unsubscribedCodes || (unsubscribedCodes = {})),
function(e) {
e[e.channelCompaction = 1] = "channelCompaction"
}(subscriptionFlags || (subscriptionFlags = {})),
function(e) {
e.Disconnected = "disconnected",
e.Connecting = "connecting",
e.Connected = "connected"
}(State$1 || (State$1 = {})),
function(e) {
e.Unsubscribed = "unsubscribed",
e.Subscribing = "subscribing",
e.Subscribed = "subscribed"
}(SubscriptionState || (SubscriptionState = {}));
class Subscription extends EventEmitter$1 {
constructor(e, t, n) {
super(),
this._resubscribeTimeout = null,
this._refreshTimeout = null,
this.channel = t,
this.state = SubscriptionState.Unsubscribed,
this._centrifuge = e,
this._token = "",
this._getToken = null,
this._data = null,
this._getData = null,
this._recover = !1,
this._offset = null,
this._epoch = null,
this._id = 0,
this._recoverable = !1,
this._positioned = !1,
this._joinLeave = !1,
this._minResubscribeDelay = 500,
this._maxResubscribeDelay = 2e4,
this._resubscribeTimeout = null,
this._resubscribeAttempts = 0,
this._promises = {},
this._promiseId = 0,
this._inflight = !1,
this._refreshTimeout = null,
this._delta = "",
this._delta_negotiated = !1,
this._tagsFilter = null,
|