var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [0, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
import { a as __extends, b as tryCatch, c as errorObject, d as OuterSubscriber, e as subscribeToResult, g as Subscriber, h as isScheduler, i as Subscription, k as from, l as concat, m as mergeMap, n as Notification, o as Observable, p as noop, q as isFunction, r as EmptyError, t as empty, u as fromArray, v as scalar, y as Subject, D as asap, E as isNumeric, H as BaseService } from "./chunk-c1dbd7c7.js";
import { a as Util } from "./chunk-25ecf4a4.js";
var AuditSubscriber = function (t) { function e(e, i) { var n = t.call(this, e) || this; return n.durationSelector = i, n.hasValue = !1, n; } return __extends(e, t), e.prototype._next = function (t) { if (this.value = t, this.hasValue = !0, !this.throttled) {
    var e = tryCatch(this.durationSelector)(t);
    if (e === errorObject)
        this.destination.error(errorObject.e);
    else {
        var i = subscribeToResult(this, e);
        !i || i.closed ? this.clearThrottle() : this.add(this.throttled = i);
    }
} }, e.prototype.clearThrottle = function () { var t = this.value, e = this.hasValue, i = this.throttled; i && (this.remove(i), this.throttled = null, i.unsubscribe()), e && (this.value = null, this.hasValue = !1, this.destination.next(t)); }, e.prototype.notifyNext = function (t, e, i, n) { this.clearThrottle(); }, e.prototype.notifyComplete = function () { this.clearThrottle(); }, e; }(OuterSubscriber), BufferSubscriber = function (t) { function e(e, i) { var n = t.call(this, e) || this; return n.buffer = [], n.add(subscribeToResult(n, i)), n; } return __extends(e, t), e.prototype._next = function (t) { this.buffer.push(t); }, e.prototype.notifyNext = function (t, e, i, n, r) { var s = this.buffer; this.buffer = [], this.destination.next(s); }, e; }(OuterSubscriber), BufferCountSubscriber = function (t) { function e(e, i) { var n = t.call(this, e) || this; return n.bufferSize = i, n.buffer = [], n; } return __extends(e, t), e.prototype._next = function (t) { var e = this.buffer; e.push(t), e.length == this.bufferSize && (this.destination.next(e), this.buffer = []); }, e.prototype._complete = function () { var e = this.buffer; e.length > 0 && this.destination.next(e), t.prototype._complete.call(this); }, e; }(Subscriber), BufferSkipCountSubscriber = function (t) { function e(e, i, n) { var r = t.call(this, e) || this; return r.bufferSize = i, r.startBufferEvery = n, r.buffers = [], r.count = 0, r; } return __extends(e, t), e.prototype._next = function (t) { var e = this.bufferSize, i = this.startBufferEvery, n = this.buffers, r = this.count; this.count++, r % i == 0 && n.push([]); for (var s = n.length; s--;) {
    var o = n[s];
    o.push(t), o.length === e && (n.splice(s, 1), this.destination.next(o));
} }, e.prototype._complete = function () { for (var e = this.buffers, i = this.destination; e.length > 0;) {
    var n = e.shift();
    n.length > 0 && i.next(n);
} t.prototype._complete.call(this); }, e; }(Subscriber), Context = function () { this.buffer = []; }, BufferTimeSubscriber = function (t) { function e(e, i, n, r, s) { var o = t.call(this, e) || this; o.bufferTimeSpan = i, o.bufferCreationInterval = n, o.maxBufferSize = r, o.scheduler = s, o.contexts = []; var c = o.openContext(); if (o.timespanOnly = null == n || n < 0, o.timespanOnly) {
    var u = { subscriber: o, context: c, bufferTimeSpan: i };
    o.add(c.closeAction = s.schedule(dispatchBufferTimeSpanOnly, i, u));
}
else {
    var h = { subscriber: o, context: c }, a = { bufferTimeSpan: i, bufferCreationInterval: n, subscriber: o, scheduler: s };
    o.add(c.closeAction = s.schedule(dispatchBufferClose, i, h)), o.add(s.schedule(dispatchBufferCreation, n, a));
} return o; } return __extends(e, t), e.prototype._next = function (t) { for (var e, i = this.contexts, n = i.length, r = 0; r < n; r++) {
    var s = i[r], o = s.buffer;
    o.push(t), o.length == this.maxBufferSize && (e = s);
} e && this.onBufferFull(e); }, e.prototype._error = function (e) { this.contexts.length = 0, t.prototype._error.call(this, e); }, e.prototype._complete = function () { for (var e = this.contexts, i = this.destination; e.length > 0;) {
    var n = e.shift();
    i.next(n.buffer);
} t.prototype._complete.call(this); }, e.prototype._unsubscribe = function () { this.contexts = null; }, e.prototype.onBufferFull = function (t) { this.closeContext(t); var e = t.closeAction; if (e.unsubscribe(), this.remove(e), !this.closed && this.timespanOnly) {
    t = this.openContext();
    var i = this.bufferTimeSpan, n = { subscriber: this, context: t, bufferTimeSpan: i };
    this.add(t.closeAction = this.scheduler.schedule(dispatchBufferTimeSpanOnly, i, n));
} }, e.prototype.openContext = function () { var t = new Context; return this.contexts.push(t), t; }, e.prototype.closeContext = function (t) { this.destination.next(t.buffer); var e = this.contexts; (e ? e.indexOf(t) : -1) >= 0 && e.splice(e.indexOf(t), 1); }, e; }(Subscriber);
function dispatchBufferTimeSpanOnly(t) { var e = t.subscriber, i = t.context; i && e.closeContext(i), e.closed || (t.context = e.openContext(), t.context.closeAction = this.schedule(t, t.bufferTimeSpan)); }
function dispatchBufferCreation(t) { var e = t.bufferCreationInterval, i = t.bufferTimeSpan, n = t.subscriber, r = t.scheduler, s = n.openContext(); n.closed || (n.add(s.closeAction = r.schedule(dispatchBufferClose, i, { subscriber: n, context: s })), this.schedule(t, e)); }
function dispatchBufferClose(t) { var e = t.subscriber, i = t.context; e.closeContext(i); }
var BufferToggleSubscriber = function (t) { function e(e, i, n) { var r = t.call(this, e) || this; return r.openings = i, r.closingSelector = n, r.contexts = [], r.add(subscribeToResult(r, i)), r; } return __extends(e, t), e.prototype._next = function (t) { for (var e = this.contexts, i = e.length, n = 0; n < i; n++)
    e[n].buffer.push(t); }, e.prototype._error = function (e) { for (var i = this.contexts; i.length > 0;) {
    var n = i.shift();
    n.subscription.unsubscribe(), n.buffer = null, n.subscription = null;
} this.contexts = null, t.prototype._error.call(this, e); }, e.prototype._complete = function () { for (var e = this.contexts; e.length > 0;) {
    var i = e.shift();
    this.destination.next(i.buffer), i.subscription.unsubscribe(), i.buffer = null, i.subscription = null;
} this.contexts = null, t.prototype._complete.call(this); }, e.prototype.notifyNext = function (t, e, i, n, r) { t ? this.closeBuffer(t) : this.openBuffer(e); }, e.prototype.notifyComplete = function (t) { this.closeBuffer(t.context); }, e.prototype.openBuffer = function (t) { try {
    var e = this.closingSelector.call(this, t);
    e && this.trySubscribe(e);
}
catch (t) {
    this._error(t);
} }, e.prototype.closeBuffer = function (t) { var e = this.contexts; if (e && t) {
    var i = t.buffer, n = t.subscription;
    this.destination.next(i), e.splice(e.indexOf(t), 1), this.remove(n), n.unsubscribe();
} }, e.prototype.trySubscribe = function (t) { var e = this.contexts, i = new Subscription, n = { buffer: [], subscription: i }; e.push(n); var r = subscribeToResult(this, t, n); !r || r.closed ? this.closeBuffer(n) : (r.context = n, this.add(r), i.add(r)); }, e; }(OuterSubscriber), BufferWhenSubscriber = function (t) { function e(e, i) { var n = t.call(this, e) || this; return n.closingSelector = i, n.subscribing = !1, n.openBuffer(), n; } return __extends(e, t), e.prototype._next = function (t) { this.buffer.push(t); }, e.prototype._complete = function () { var e = this.buffer; e && this.destination.next(e), t.prototype._complete.call(this); }, e.prototype._unsubscribe = function () { this.buffer = null, this.subscribing = !1; }, e.prototype.notifyNext = function (t, e, i, n, r) { this.openBuffer(); }, e.prototype.notifyComplete = function () { this.subscribing ? this.complete() : this.openBuffer(); }, e.prototype.openBuffer = function () { var t = this.closingSubscription; t && (this.remove(t), t.unsubscribe()); var e = this.buffer; this.buffer && this.destination.next(e), this.buffer = []; var i = tryCatch(this.closingSelector)(); i === errorObject ? this.error(errorObject.e) : (t = new Subscription, this.closingSubscription = t, this.add(t), this.subscribing = !0, t.add(subscribeToResult(this, i)), this.subscribing = !1); }, e; }(OuterSubscriber), CatchSubscriber = function (t) { function e(e, i, n) { var r = t.call(this, e) || this; return r.selector = i, r.caught = n, r; } return __extends(e, t), e.prototype.error = function (e) { if (!this.isStopped) {
    var i = void 0;
    try {
        i = this.selector(e, this.caught);
    }
    catch (e) {
        return void t.prototype.error.call(this, e);
    }
    this._unsubscribeAndRecycle(), this.add(subscribeToResult(this, i));
} }, e; }(OuterSubscriber), CountSubscriber = function (t) { function e(e, i, n) { var r = t.call(this, e) || this; return r.predicate = i, r.source = n, r.count = 0, r.index = 0, r; } return __extends(e, t), e.prototype._next = function (t) { this.predicate ? this._tryPredicate(t) : this.count++; }, e.prototype._tryPredicate = function (t) { var e; try {
    e = this.predicate(t, this.index++, this.source);
}
catch (t) {
    return void this.destination.error(t);
} e && this.count++; }, e.prototype._complete = function () { this.destination.next(this.count), this.destination.complete(); }, e; }(Subscriber), DebounceSubscriber = function (t) { function e(e, i) { var n = t.call(this, e) || this; return n.durationSelector = i, n.hasValue = !1, n.durationSubscription = null, n; } return __extends(e, t), e.prototype._next = function (t) { try {
    var e = this.durationSelector.call(this, t);
    e && this._tryNext(t, e);
}
catch (t) {
    this.destination.error(t);
} }, e.prototype._complete = function () { this.emitValue(), this.destination.complete(); }, e.prototype._tryNext = function (t, e) { var i = this.durationSubscription; this.value = t, this.hasValue = !0, i && (i.unsubscribe(), this.remove(i)), (i = subscribeToResult(this, e)) && !i.closed && this.add(this.durationSubscription = i); }, e.prototype.notifyNext = function (t, e, i, n, r) { this.emitValue(); }, e.prototype.notifyComplete = function () { this.emitValue(); }, e.prototype.emitValue = function () { if (this.hasValue) {
    var e = this.value, i = this.durationSubscription;
    i && (this.durationSubscription = null, i.unsubscribe(), this.remove(i)), this.value = null, this.hasValue = !1, t.prototype._next.call(this, e);
} }, e; }(OuterSubscriber), DebounceTimeSubscriber = function (t) { function e(e, i, n) { var r = t.call(this, e) || this; return r.dueTime = i, r.scheduler = n, r.debouncedSubscription = null, r.lastValue = null, r.hasValue = !1, r; } return __extends(e, t), e.prototype._next = function (t) { this.clearDebounce(), this.lastValue = t, this.hasValue = !0, this.add(this.debouncedSubscription = this.scheduler.schedule(dispatchNext, this.dueTime, this)); }, e.prototype._complete = function () { this.debouncedNext(), this.destination.complete(); }, e.prototype.debouncedNext = function () { if (this.clearDebounce(), this.hasValue) {
    var t = this.lastValue;
    this.lastValue = null, this.hasValue = !1, this.destination.next(t);
} }, e.prototype.clearDebounce = function () { var t = this.debouncedSubscription; null !== t && (this.remove(t), t.unsubscribe(), this.debouncedSubscription = null); }, e; }(Subscriber);
function dispatchNext(t) { t.debouncedNext(); }
var DefaultIfEmptySubscriber = function (t) { function e(e, i) { var n = t.call(this, e) || this; return n.defaultValue = i, n.isEmpty = !0, n; } return __extends(e, t), e.prototype._next = function (t) { this.isEmpty = !1, this.destination.next(t); }, e.prototype._complete = function () { this.isEmpty && this.destination.next(this.defaultValue), this.destination.complete(); }, e; }(Subscriber), DelaySubscriber = function (t) { function e(e, i, n) { var r = t.call(this, e) || this; return r.delay = i, r.scheduler = n, r.queue = [], r.active = !1, r.errored = !1, r; } return __extends(e, t), e.dispatch = function (t) { for (var e = t.source, i = e.queue, n = t.scheduler, r = t.destination; i.length > 0 && i[0].time - n.now() <= 0;)
    i.shift().notification.observe(r); if (i.length > 0) {
    var s = Math.max(0, i[0].time - n.now());
    this.schedule(t, s);
}
else
    this.unsubscribe(), e.active = !1; }, e.prototype._schedule = function (t) { this.active = !0, this.add(t.schedule(e.dispatch, this.delay, { source: this, destination: this.destination, scheduler: t })); }, e.prototype.scheduleNotification = function (t) { if (!0 !== this.errored) {
    var e = this.scheduler, i = new DelayMessage(e.now() + this.delay, t);
    this.queue.push(i), !1 === this.active && this._schedule(e);
} }, e.prototype._next = function (t) { this.scheduleNotification(Notification.createNext(t)); }, e.prototype._error = function (t) { this.errored = !0, this.queue = [], this.destination.error(t); }, e.prototype._complete = function () { this.scheduleNotification(Notification.createComplete()); }, e; }(Subscriber), DelayMessage = function (t, e) { this.time = t, this.notification = e; }, DelayWhenSubscriber = function (t) { function e(e, i) { var n = t.call(this, e) || this; return n.delayDurationSelector = i, n.completed = !1, n.delayNotifierSubscriptions = [], n; } return __extends(e, t), e.prototype.notifyNext = function (t, e, i, n, r) { this.destination.next(t), this.removeSubscription(r), this.tryComplete(); }, e.prototype.notifyError = function (t, e) { this._error(t); }, e.prototype.notifyComplete = function (t) { var e = this.removeSubscription(t); e && this.destination.next(e), this.tryComplete(); }, e.prototype._next = function (t) { try {
    var e = this.delayDurationSelector(t);
    e && this.tryDelay(e, t);
}
catch (t) {
    this.destination.error(t);
} }, e.prototype._complete = function () { this.completed = !0, this.tryComplete(); }, e.prototype.removeSubscription = function (t) { t.unsubscribe(); var e = this.delayNotifierSubscriptions.indexOf(t); return -1 !== e && this.delayNotifierSubscriptions.splice(e, 1), t.outerValue; }, e.prototype.tryDelay = function (t, e) { var i = subscribeToResult(this, t, e); i && !i.closed && (this.add(i), this.delayNotifierSubscriptions.push(i)); }, e.prototype.tryComplete = function () { this.completed && 0 === this.delayNotifierSubscriptions.length && this.destination.complete(); }, e; }(OuterSubscriber), SubscriptionDelayObservable = function (t) { function e(e, i) { var n = t.call(this) || this; return n.source = e, n.subscriptionDelay = i, n; } return __extends(e, t), e.prototype._subscribe = function (t) { this.subscriptionDelay.subscribe(new SubscriptionDelaySubscriber(t, this.source)); }, e; }(Observable), SubscriptionDelaySubscriber = function (t) { function e(e, i) { var n = t.call(this) || this; return n.parent = e, n.source = i, n.sourceSubscribed = !1, n; } return __extends(e, t), e.prototype._next = function (t) { this.subscribeToSource(); }, e.prototype._error = function (t) { this.unsubscribe(), this.parent.error(t); }, e.prototype._complete = function () { this.subscribeToSource(); }, e.prototype.subscribeToSource = function () { this.sourceSubscribed || (this.sourceSubscribed = !0, this.unsubscribe(), this.source.subscribe(this.parent)); }, e; }(Subscriber), DeMaterializeSubscriber = function (t) { function e(e) { return t.call(this, e) || this; } return __extends(e, t), e.prototype._next = function (t) { t.observe(this.destination); }, e; }(Subscriber), DistinctSubscriber = function (t) { function e(e, i, n) { var r = t.call(this, e) || this; return r.keySelector = i, r.values = new Set, n && r.add(subscribeToResult(r, n)), r; } return __extends(e, t), e.prototype.notifyNext = function (t, e, i, n, r) { this.values.clear(); }, e.prototype.notifyError = function (t, e) { this._error(t); }, e.prototype._next = function (t) { this.keySelector ? this._useKeySelector(t) : this._finalizeNext(t, t); }, e.prototype._useKeySelector = function (t) { var e, i = this.destination; try {
    e = this.keySelector(t);
}
catch (t) {
    return void i.error(t);
} this._finalizeNext(e, t); }, e.prototype._finalizeNext = function (t, e) { var i = this.values; i.has(t) || (i.add(t), this.destination.next(e)); }, e; }(OuterSubscriber), DistinctUntilChangedSubscriber = function (t) { function e(e, i, n) { var r = t.call(this, e) || this; return r.keySelector = n, r.hasKey = !1, "function" == typeof i && (r.compare = i), r; } return __extends(e, t), e.prototype.compare = function (t, e) { return t === e; }, e.prototype._next = function (t) { var e = t; if (this.keySelector && (e = tryCatch(this.keySelector)(t)) === errorObject)
    return this.destination.error(errorObject.e); var i = !1; if (this.hasKey) {
    if ((i = tryCatch(this.compare)(this.key, e)) === errorObject)
        return this.destination.error(errorObject.e);
}
else
    this.hasKey = !0; !1 === Boolean(i) && (this.key = e, this.destination.next(t)); }, e; }(Subscriber), FilterSubscriber = function (t) { function e(e, i, n) { var r = t.call(this, e) || this; return r.predicate = i, r.thisArg = n, r.count = 0, r; } return __extends(e, t), e.prototype._next = function (t) { var e; try {
    e = this.predicate.call(this.thisArg, t, this.count++);
}
catch (t) {
    return void this.destination.error(t);
} e && this.destination.next(t); }, e; }(Subscriber), TapSubscriber = function (t) { function e(e, i, n, r) { var s = t.call(this, e) || this; return s._tapNext = noop, s._tapError = noop, s._tapComplete = noop, s._tapError = n || noop, s._tapComplete = r || noop, isFunction(i) ? (s._context = s, s._tapNext = i) : i && (s._context = i, s._tapNext = i.next || noop, s._tapError = i.error || noop, s._tapComplete = i.complete || noop), s; } return __extends(e, t), e.prototype._next = function (t) { try {
    this._tapNext.call(this._context, t);
}
catch (t) {
    return void this.destination.error(t);
} this.destination.next(t); }, e.prototype._error = function (t) { try {
    this._tapError.call(this._context, t);
}
catch (t) {
    return void this.destination.error(t);
} this.destination.error(t); }, e.prototype._complete = function () { try {
    this._tapComplete.call(this._context);
}
catch (t) {
    return void this.destination.error(t);
} return this.destination.complete(); }, e; }(Subscriber), TakeSubscriber = function (t) { function e(e, i) { var n = t.call(this, e) || this; return n.total = i, n.count = 0, n; } return __extends(e, t), e.prototype._next = function (t) { var e = this.total, i = ++this.count; i <= e && (this.destination.next(t), i === e && (this.destination.complete(), this.unsubscribe())); }, e; }(Subscriber), EverySubscriber = function (t) { function e(e, i, n, r) { var s = t.call(this, e) || this; return s.predicate = i, s.thisArg = n, s.source = r, s.index = 0, s.thisArg = n || s, s; } return __extends(e, t), e.prototype.notifyComplete = function (t) { this.destination.next(t), this.destination.complete(); }, e.prototype._next = function (t) { var e = !1; try {
    e = this.predicate.call(this.thisArg, t, this.index++, this.source);
}
catch (t) {
    return void this.destination.error(t);
} e || this.notifyComplete(!1); }, e.prototype._complete = function () { this.notifyComplete(!0); }, e; }(Subscriber), SwitchFirstSubscriber = function (t) { function e(e) { var i = t.call(this, e) || this; return i.hasCompleted = !1, i.hasSubscription = !1, i; } return __extends(e, t), e.prototype._next = function (t) { this.hasSubscription || (this.hasSubscription = !0, this.add(subscribeToResult(this, t))); }, e.prototype._complete = function () { this.hasCompleted = !0, this.hasSubscription || this.destination.complete(); }, e.prototype.notifyComplete = function (t) { this.remove(t), this.hasSubscription = !1, this.hasCompleted && this.destination.complete(); }, e; }(OuterSubscriber), ExhaustMapSubscriber = function (t) { function e(e, i) { var n = t.call(this, e) || this; return n.project = i, n.hasSubscription = !1, n.hasCompleted = !1, n.index = 0, n; } return __extends(e, t), e.prototype._next = function (t) { this.hasSubscription || this.tryNext(t); }, e.prototype.tryNext = function (t) { var e = this.index++, i = this.destination; try {
    var n = this.project(t, e);
    this.hasSubscription = !0, this.add(subscribeToResult(this, n, t, e));
}
catch (t) {
    i.error(t);
} }, e.prototype._complete = function () { this.hasCompleted = !0, this.hasSubscription || this.destination.complete(); }, e.prototype.notifyNext = function (t, e, i, n, r) { this.destination.next(e); }, e.prototype.notifyError = function (t) { this.destination.error(t); }, e.prototype.notifyComplete = function (t) { this.remove(t), this.hasSubscription = !1, this.hasCompleted && this.destination.complete(); }, e; }(OuterSubscriber), ExpandSubscriber = function (t) { function e(e, i, n, r) { var s = t.call(this, e) || this; return s.project = i, s.concurrent = n, s.scheduler = r, s.index = 0, s.active = 0, s.hasCompleted = !1, n < Number.POSITIVE_INFINITY && (s.buffer = []), s; } return __extends(e, t), e.dispatch = function (t) { var e = t.subscriber, i = t.result, n = t.value, r = t.index; e.subscribeToProjection(i, n, r); }, e.prototype._next = function (t) { var i = this.destination; if (i.closed)
    this._complete();
else {
    var n = this.index++;
    if (this.active < this.concurrent) {
        i.next(t);
        var r = tryCatch(this.project)(t, n);
        if (r === errorObject)
            i.error(errorObject.e);
        else if (this.scheduler) {
            var s = { subscriber: this, result: r, value: t, index: n };
            this.add(this.scheduler.schedule(e.dispatch, 0, s));
        }
        else
            this.subscribeToProjection(r, t, n);
    }
    else
        this.buffer.push(t);
} }, e.prototype.subscribeToProjection = function (t, e, i) { this.active++, this.add(subscribeToResult(this, t, e, i)); }, e.prototype._complete = function () { this.hasCompleted = !0, this.hasCompleted && 0 === this.active && this.destination.complete(); }, e.prototype.notifyNext = function (t, e, i, n, r) { this._next(e); }, e.prototype.notifyComplete = function (t) { var e = this.buffer; this.remove(t), this.active--, e && e.length > 0 && this._next(e.shift()), this.hasCompleted && 0 === this.active && this.destination.complete(); }, e; }(OuterSubscriber), FinallySubscriber = function (t) { function e(e, i) { var n = t.call(this, e) || this; return n.add(new Subscription(i)), n; } return __extends(e, t), e; }(Subscriber), FindValueSubscriber = function (t) { function e(e, i, n, r, s) { var o = t.call(this, e) || this; return o.predicate = i, o.source = n, o.yieldIndex = r, o.thisArg = s, o.index = 0, o; } return __extends(e, t), e.prototype.notifyComplete = function (t) { var e = this.destination; e.next(t), e.complete(); }, e.prototype._next = function (t) { var e = this.predicate, i = this.thisArg, n = this.index++; try {
    e.call(i || this, t, n, this.source) && this.notifyComplete(this.yieldIndex ? n : t);
}
catch (t) {
    this.destination.error(t);
} }, e.prototype._complete = function () { this.notifyComplete(this.yieldIndex ? -1 : void 0); }, e; }(Subscriber), IgnoreElementsSubscriber = function (t) { function e() { return null !== t && t.apply(this, arguments) || this; } return __extends(e, t), e.prototype._next = function (t) { }, e; }(Subscriber), IsEmptySubscriber = function (t) { function e(e) { return t.call(this, e) || this; } return __extends(e, t), e.prototype.notifyComplete = function (t) { var e = this.destination; e.next(t), e.complete(); }, e.prototype._next = function (t) { this.notifyComplete(!1); }, e.prototype._complete = function () { this.notifyComplete(!0); }, e; }(Subscriber), TakeLastSubscriber = function (t) { function e(e, i) { var n = t.call(this, e) || this; return n.total = i, n.ring = new Array, n.count = 0, n; } return __extends(e, t), e.prototype._next = function (t) { var e = this.ring, i = this.total, n = this.count++; e.length < i ? e.push(t) : e[n % i] = t; }, e.prototype._complete = function () { var t = this.destination, e = this.count; if (e > 0)
    for (var i = this.count >= this.total ? this.total : this.count, n = this.ring, r = 0; r < i; r++) {
        var s = e++ % i;
        t.next(n[s]);
    } t.complete(); }, e; }(Subscriber), MapToSubscriber = function (t) { function e(e, i) { var n = t.call(this, e) || this; return n.value = i, n; } return __extends(e, t), e.prototype._next = function (t) { this.destination.next(this.value); }, e; }(Subscriber), MaterializeSubscriber = function (t) { function e(e) { return t.call(this, e) || this; } return __extends(e, t), e.prototype._next = function (t) { this.destination.next(Notification.createNext(t)); }, e.prototype._error = function (t) { var e = this.destination; e.next(Notification.createError(t)), e.complete(); }, e.prototype._complete = function () { var t = this.destination; t.next(Notification.createComplete()), t.complete(); }, e; }(Subscriber);
function scan(t, e) { var i = !1; return arguments.length >= 2 && (i = !0), function (n) { return n.lift(new ScanOperator(t, e, i)); }; }
var ScanOperator = function () { function t(t, e, i) { void 0 === i && (i = !1), this.accumulator = t, this.seed = e, this.hasSeed = i; } return t.prototype.call = function (t, e) { return e.subscribe(new ScanSubscriber(t, this.accumulator, this.seed, this.hasSeed)); }, t; }(), ScanSubscriber = function (t) { function e(e, i, n, r) { var s = t.call(this, e) || this; return s.accumulator = i, s._seed = n, s.hasSeed = r, s.index = 0, s; } return __extends(e, t), Object.defineProperty(e.prototype, "seed", { get: function () { return this._seed; }, set: function (t) { this.hasSeed = !0, this._seed = t; }, enumerable: !0, configurable: !0 }), e.prototype._next = function (t) { if (this.hasSeed)
    return this._tryNext(t); this.seed = t, this.destination.next(t); }, e.prototype._tryNext = function (t) { var e, i = this.index++; try {
    e = this.accumulator(this.seed, t, i);
}
catch (t) {
    this.destination.error(t);
} this.seed = e, this.destination.next(e); }, e; }(Subscriber), MergeScanSubscriber = function (t) { function e(e, i, n, r) { var s = t.call(this, e) || this; return s.accumulator = i, s.acc = n, s.concurrent = r, s.hasValue = !1, s.hasCompleted = !1, s.buffer = [], s.active = 0, s.index = 0, s; } return __extends(e, t), e.prototype._next = function (t) { if (this.active < this.concurrent) {
    var e = this.index++, i = tryCatch(this.accumulator)(this.acc, t), n = this.destination;
    i === errorObject ? n.error(errorObject.e) : (this.active++, this._innerSub(i, t, e));
}
else
    this.buffer.push(t); }, e.prototype._innerSub = function (t, e, i) { this.add(subscribeToResult(this, t, e, i)); }, e.prototype._complete = function () { this.hasCompleted = !0, 0 === this.active && 0 === this.buffer.length && (!1 === this.hasValue && this.destination.next(this.acc), this.destination.complete()); }, e.prototype.notifyNext = function (t, e, i, n, r) { var s = this.destination; this.acc = e, this.hasValue = !0, s.next(e); }, e.prototype.notifyComplete = function (t) { var e = this.buffer; this.remove(t), this.active--, e.length > 0 ? this._next(e.shift()) : 0 === this.active && this.hasCompleted && (!1 === this.hasValue && this.destination.next(this.acc), this.destination.complete()); }, e; }(OuterSubscriber), OnErrorResumeNextSubscriber = function (t) { function e(e, i) { var n = t.call(this, e) || this; return n.destination = e, n.nextSources = i, n; } return __extends(e, t), e.prototype.notifyError = function (t, e) { this.subscribeToNextSource(); }, e.prototype.notifyComplete = function (t) { this.subscribeToNextSource(); }, e.prototype._error = function (t) { this.subscribeToNextSource(); }, e.prototype._complete = function () { this.subscribeToNextSource(); }, e.prototype.subscribeToNextSource = function () { var t = this.nextSources.shift(); t ? this.add(subscribeToResult(this, t)) : this.destination.complete(); }, e; }(OuterSubscriber), PairwiseSubscriber = function (t) { function e(e) { var i = t.call(this, e) || this; return i.hasPrev = !1, i; } return __extends(e, t), e.prototype._next = function (t) { this.hasPrev ? this.destination.next([this.prev, t]) : this.hasPrev = !0, this.prev = t; }, e; }(Subscriber), RepeatSubscriber = function (t) { function e(e, i, n) { var r = t.call(this, e) || this; return r.count = i, r.source = n, r; } return __extends(e, t), e.prototype.complete = function () { if (!this.isStopped) {
    var e = this.source, i = this.count;
    if (0 === i)
        return t.prototype.complete.call(this);
    i > -1 && (this.count = i - 1), e.subscribe(this._unsubscribeAndRecycle());
} }, e; }(Subscriber), RepeatWhenSubscriber = function (t) { function e(e, i, n) { var r = t.call(this, e) || this; return r.notifier = i, r.source = n, r.sourceIsBeingSubscribedTo = !0, r; } return __extends(e, t), e.prototype.notifyNext = function (t, e, i, n, r) { this.sourceIsBeingSubscribedTo = !0, this.source.subscribe(this); }, e.prototype.notifyComplete = function (e) { if (!1 === this.sourceIsBeingSubscribedTo)
    return t.prototype.complete.call(this); }, e.prototype.complete = function () { if (this.sourceIsBeingSubscribedTo = !1, !this.isStopped) {
    if (this.retries || this.subscribeToRetries(), !this.retriesSubscription || this.retriesSubscription.closed)
        return t.prototype.complete.call(this);
    this._unsubscribeAndRecycle(), this.notifications.next();
} }, e.prototype._unsubscribe = function () { var t = this.notifications, e = this.retriesSubscription; t && (t.unsubscribe(), this.notifications = null), e && (e.unsubscribe(), this.retriesSubscription = null), this.retries = null; }, e.prototype._unsubscribeAndRecycle = function () { var e = this._unsubscribe; return this._unsubscribe = null, t.prototype._unsubscribeAndRecycle.call(this), this._unsubscribe = e, this; }, e.prototype.subscribeToRetries = function () { this.notifications = new Subject; var e = tryCatch(this.notifier)(this.notifications); if (e === errorObject)
    return t.prototype.complete.call(this); this.retries = e, this.retriesSubscription = subscribeToResult(this, e); }, e; }(OuterSubscriber), RetrySubscriber = function (t) { function e(e, i, n) { var r = t.call(this, e) || this; return r.count = i, r.source = n, r; } return __extends(e, t), e.prototype.error = function (e) { if (!this.isStopped) {
    var i = this.source, n = this.count;
    if (0 === n)
        return t.prototype.error.call(this, e);
    n > -1 && (this.count = n - 1), i.subscribe(this._unsubscribeAndRecycle());
} }, e; }(Subscriber), RetryWhenSubscriber = function (t) { function e(e, i, n) { var r = t.call(this, e) || this; return r.notifier = i, r.source = n, r; } return __extends(e, t), e.prototype.error = function (e) { if (!this.isStopped) {
    var i = this.errors, n = this.retries, r = this.retriesSubscription;
    if (n)
        this.errors = null, this.retriesSubscription = null;
    else {
        if (i = new Subject, (n = tryCatch(this.notifier)(i)) === errorObject)
            return t.prototype.error.call(this, errorObject.e);
        r = subscribeToResult(this, n);
    }
    this._unsubscribeAndRecycle(), this.errors = i, this.retries = n, this.retriesSubscription = r, i.next(e);
} }, e.prototype._unsubscribe = function () { var t = this.errors, e = this.retriesSubscription; t && (t.unsubscribe(), this.errors = null), e && (e.unsubscribe(), this.retriesSubscription = null), this.retries = null; }, e.prototype.notifyNext = function (t, e, i, n, r) { var s = this._unsubscribe; this._unsubscribe = null, this._unsubscribeAndRecycle(), this._unsubscribe = s, this.source.subscribe(this); }, e; }(OuterSubscriber), SampleSubscriber = function (t) { function e() { var e = null !== t && t.apply(this, arguments) || this; return e.hasValue = !1, e; } return __extends(e, t), e.prototype._next = function (t) { this.value = t, this.hasValue = !0; }, e.prototype.notifyNext = function (t, e, i, n, r) { this.emitValue(); }, e.prototype.notifyComplete = function () { this.emitValue(); }, e.prototype.emitValue = function () { this.hasValue && (this.hasValue = !1, this.destination.next(this.value)); }, e; }(OuterSubscriber), SampleTimeSubscriber = function (t) { function e(e, i, n) { var r = t.call(this, e) || this; return r.period = i, r.scheduler = n, r.hasValue = !1, r.add(n.schedule(dispatchNotification, i, { subscriber: r, period: i })), r; } return __extends(e, t), e.prototype._next = function (t) { this.lastValue = t, this.hasValue = !0; }, e.prototype.notifyNext = function () { this.hasValue && (this.hasValue = !1, this.destination.next(this.lastValue)); }, e; }(Subscriber);
function dispatchNotification(t) { var e = t.subscriber, i = t.period; e.notifyNext(), this.schedule(t, i); }
var SequenceEqualSubscriber = function (t) { function e(e, i, n) { var r = t.call(this, e) || this; return r.compareTo = i, r.comparor = n, r._a = [], r._b = [], r._oneComplete = !1, r.add(i.subscribe(new SequenceEqualCompareToSubscriber(e, r))), r; } return __extends(e, t), e.prototype._next = function (t) { this._oneComplete && 0 === this._b.length ? this.emit(!1) : (this._a.push(t), this.checkValues()); }, e.prototype._complete = function () { this._oneComplete ? this.emit(0 === this._a.length && 0 === this._b.length) : this._oneComplete = !0; }, e.prototype.checkValues = function () { for (var t = this._a, e = this._b, i = this.comparor; t.length > 0 && e.length > 0;) {
    var n = t.shift(), r = e.shift(), s = !1;
    i ? (s = tryCatch(i)(n, r)) === errorObject && this.destination.error(errorObject.e) : s = n === r, s || this.emit(!1);
} }, e.prototype.emit = function (t) { var e = this.destination; e.next(t), e.complete(); }, e.prototype.nextB = function (t) { this._oneComplete && 0 === this._a.length ? this.emit(!1) : (this._b.push(t), this.checkValues()); }, e; }(Subscriber), SequenceEqualCompareToSubscriber = function (t) { function e(e, i) { var n = t.call(this, e) || this; return n.parent = i, n; } return __extends(e, t), e.prototype._next = function (t) { this.parent.nextB(t); }, e.prototype._error = function (t) { this.parent.error(t); }, e.prototype._complete = function () { this.parent._complete(); }, e; }(Subscriber), SingleSubscriber = function (t) { function e(e, i, n) { var r = t.call(this, e) || this; return r.predicate = i, r.source = n, r.seenValue = !1, r.index = 0, r; } return __extends(e, t), e.prototype.applySingleValue = function (t) { this.seenValue ? this.destination.error("Sequence contains more than one element") : (this.seenValue = !0, this.singleValue = t); }, e.prototype._next = function (t) { var e = this.index++; this.predicate ? this.tryNext(t, e) : this.applySingleValue(t); }, e.prototype.tryNext = function (t, e) { try {
    this.predicate(t, e, this.source) && this.applySingleValue(t);
}
catch (t) {
    this.destination.error(t);
} }, e.prototype._complete = function () { var t = this.destination; this.index > 0 ? (t.next(this.seenValue ? this.singleValue : void 0), t.complete()) : t.error(new EmptyError); }, e; }(Subscriber), SkipSubscriber = function (t) { function e(e, i) { var n = t.call(this, e) || this; return n.total = i, n.count = 0, n; } return __extends(e, t), e.prototype._next = function (t) { ++this.count > this.total && this.destination.next(t); }, e; }(Subscriber), SkipLastSubscriber = function (t) { function e(e, i) { var n = t.call(this, e) || this; return n._skipCount = i, n._count = 0, n._ring = new Array(i), n; } return __extends(e, t), e.prototype._next = function (t) { var e = this._skipCount, i = this._count++; if (i < e)
    this._ring[i] = t;
else {
    var n = i % e, r = this._ring, s = r[n];
    r[n] = t, this.destination.next(s);
} }, e; }(Subscriber), SkipUntilSubscriber = function (t) { function e(e, i) { var n = t.call(this, e) || this; return n.hasValue = !1, n.add(n.innerSubscription = subscribeToResult(n, i)), n; } return __extends(e, t), e.prototype._next = function (e) { this.hasValue && t.prototype._next.call(this, e); }, e.prototype.notifyNext = function (t, e, i, n, r) { this.hasValue = !0, this.innerSubscription && this.innerSubscription.unsubscribe(); }, e.prototype.notifyComplete = function () { }, e; }(OuterSubscriber), SkipWhileSubscriber = function (t) { function e(e, i) { var n = t.call(this, e) || this; return n.predicate = i, n.skipping = !0, n.index = 0, n; } return __extends(e, t), e.prototype._next = function (t) { var e = this.destination; this.skipping && this.tryCallPredicate(t), this.skipping || e.next(t); }, e.prototype.tryCallPredicate = function (t) { try {
    var e = this.predicate(t, this.index++);
    this.skipping = Boolean(e);
}
catch (t) {
    this.destination.error(t);
} }, e; }(Subscriber);
function startWith() { for (var t = [], e = 0; e < arguments.length; e++)
    t[e] = arguments[e]; return function (e) { var i = t[t.length - 1]; isScheduler(i) ? t.pop() : i = null; var n = t.length; return concat(1 !== n || i ? n > 0 ? fromArray(t, i) : empty(i) : scalar(t[0]), e); }; }
var SubscribeOnObservable = function (t) { function e(e, i, n) { void 0 === i && (i = 0), void 0 === n && (n = asap); var r = t.call(this) || this; return r.source = e, r.delayTime = i, r.scheduler = n, (!isNumeric(i) || i < 0) && (r.delayTime = 0), n && "function" == typeof n.schedule || (r.scheduler = asap), r; } return __extends(e, t), e.create = function (t, i, n) { return void 0 === i && (i = 0), void 0 === n && (n = asap), new e(t, i, n); }, e.dispatch = function (t) { var e = t.source, i = t.subscriber; return this.add(e.subscribe(i)); }, e.prototype._subscribe = function (t) { var i = this.delayTime, n = this.source; return this.scheduler.schedule(e.dispatch, i, { source: n, subscriber: t }); }, e; }(Observable), SwitchMapSubscriber = function (t) { function e(e, i) { var n = t.call(this, e) || this; return n.project = i, n.index = 0, n; } return __extends(e, t), e.prototype._next = function (t) { var e, i = this.index++; try {
    e = this.project(t, i);
}
catch (t) {
    return void this.destination.error(t);
} this._innerSub(e, t, i); }, e.prototype._innerSub = function (t, e, i) { var n = this.innerSubscription; n && n.unsubscribe(), this.add(this.innerSubscription = subscribeToResult(this, t, e, i)); }, e.prototype._complete = function () { var e = this.innerSubscription; e && !e.closed || t.prototype._complete.call(this); }, e.prototype._unsubscribe = function () { this.innerSubscription = null; }, e.prototype.notifyComplete = function (e) { this.remove(e), this.innerSubscription = null, this.isStopped && t.prototype._complete.call(this); }, e.prototype.notifyNext = function (t, e, i, n, r) { this.destination.next(e); }, e; }(OuterSubscriber), TakeUntilSubscriber = function (t) { function e(e) { return t.call(this, e) || this; } return __extends(e, t), e.prototype.notifyNext = function (t, e, i, n, r) { this.complete(); }, e.prototype.notifyComplete = function () { }, e; }(OuterSubscriber), TakeWhileSubscriber = function (t) { function e(e, i) { var n = t.call(this, e) || this; return n.predicate = i, n.index = 0, n; } return __extends(e, t), e.prototype._next = function (t) { var e, i = this.destination; try {
    e = this.predicate(t, this.index++);
}
catch (t) {
    return void i.error(t);
} this.nextOrComplete(t, e); }, e.prototype.nextOrComplete = function (t, e) { var i = this.destination; Boolean(e) ? i.next(t) : i.complete(); }, e; }(Subscriber), ThrottleSubscriber = function (t) { function e(e, i, n, r) { var s = t.call(this, e) || this; return s.destination = e, s.durationSelector = i, s._leading = n, s._trailing = r, s._hasValue = !1, s; } return __extends(e, t), e.prototype._next = function (t) { this._hasValue = !0, this._sendValue = t, this._throttled || (this._leading ? this.send() : this.throttle(t)); }, e.prototype.send = function () { var t = this._hasValue, e = this._sendValue; t && (this.destination.next(e), this.throttle(e)), this._hasValue = !1, this._sendValue = null; }, e.prototype.throttle = function (t) { var e = this.tryDurationSelector(t); e && this.add(this._throttled = subscribeToResult(this, e)); }, e.prototype.tryDurationSelector = function (t) { try {
    return this.durationSelector(t);
}
catch (t) {
    return this.destination.error(t), null;
} }, e.prototype.throttlingDone = function () { var t = this._throttled, e = this._trailing; t && t.unsubscribe(), this._throttled = null, e && this.send(); }, e.prototype.notifyNext = function (t, e, i, n, r) { this.throttlingDone(); }, e.prototype.notifyComplete = function () { this.throttlingDone(); }, e; }(OuterSubscriber), ThrottleTimeSubscriber = function (t) { function e(e, i, n, r, s) { var o = t.call(this, e) || this; return o.duration = i, o.scheduler = n, o.leading = r, o.trailing = s, o._hasTrailingValue = !1, o._trailingValue = null, o; } return __extends(e, t), e.prototype._next = function (t) { this.throttled ? this.trailing && (this._trailingValue = t, this._hasTrailingValue = !0) : (this.add(this.throttled = this.scheduler.schedule(dispatchNext$1, this.duration, { subscriber: this })), this.leading && this.destination.next(t)); }, e.prototype._complete = function () { this._hasTrailingValue ? (this.destination.next(this._trailingValue), this.destination.complete()) : this.destination.complete(); }, e.prototype.clearThrottle = function () { var t = this.throttled; t && (this.trailing && this._hasTrailingValue && (this.destination.next(this._trailingValue), this._trailingValue = null, this._hasTrailingValue = !1), t.unsubscribe(), this.remove(t), this.throttled = null); }, e; }(Subscriber);
function dispatchNext$1(t) { t.subscriber.clearThrottle(); }
var TimeoutWithSubscriber = function (t) { function e(e, i, n, r, s) { var o = t.call(this, e) || this; return o.absoluteTimeout = i, o.waitFor = n, o.withObservable = r, o.scheduler = s, o.action = null, o.scheduleTimeout(), o; } return __extends(e, t), e.dispatchTimeout = function (t) { var e = t.withObservable; t._unsubscribeAndRecycle(), t.add(subscribeToResult(t, e)); }, e.prototype.scheduleTimeout = function () { var t = this.action; t ? this.action = t.schedule(this, this.waitFor) : this.add(this.action = this.scheduler.schedule(e.dispatchTimeout, this.waitFor, this)); }, e.prototype._next = function (e) { this.absoluteTimeout || this.scheduleTimeout(), t.prototype._next.call(this, e); }, e.prototype._unsubscribe = function () { this.action = null, this.scheduler = null, this.withObservable = null; }, e; }(OuterSubscriber), WindowSubscriber = function (t) { function e(e) { var i = t.call(this, e) || this; return i.window = new Subject, e.next(i.window), i; } return __extends(e, t), e.prototype.notifyNext = function (t, e, i, n, r) { this.openWindow(); }, e.prototype.notifyError = function (t, e) { this._error(t); }, e.prototype.notifyComplete = function (t) { this._complete(); }, e.prototype._next = function (t) { this.window.next(t); }, e.prototype._error = function (t) { this.window.error(t), this.destination.error(t); }, e.prototype._complete = function () { this.window.complete(), this.destination.complete(); }, e.prototype._unsubscribe = function () { this.window = null; }, e.prototype.openWindow = function () { var t = this.window; t && t.complete(); var e = this.destination, i = this.window = new Subject; e.next(i); }, e; }(OuterSubscriber), WindowCountSubscriber = function (t) { function e(e, i, n) { var r = t.call(this, e) || this; return r.destination = e, r.windowSize = i, r.startWindowEvery = n, r.windows = [new Subject], r.count = 0, e.next(r.windows[0]), r; } return __extends(e, t), e.prototype._next = function (t) { for (var e = this.startWindowEvery > 0 ? this.startWindowEvery : this.windowSize, i = this.destination, n = this.windowSize, r = this.windows, s = r.length, o = 0; o < s && !this.closed; o++)
    r[o].next(t); var c = this.count - n + 1; if (c >= 0 && c % e == 0 && !this.closed && r.shift().complete(), ++this.count % e == 0 && !this.closed) {
    var u = new Subject;
    r.push(u), i.next(u);
} }, e.prototype._error = function (t) { var e = this.windows; if (e)
    for (; e.length > 0 && !this.closed;)
        e.shift().error(t); this.destination.error(t); }, e.prototype._complete = function () { var t = this.windows; if (t)
    for (; t.length > 0 && !this.closed;)
        t.shift().complete(); this.destination.complete(); }, e.prototype._unsubscribe = function () { this.count = 0, this.windows = null; }, e; }(Subscriber), CountedSubject = function (t) { function e() { var e = null !== t && t.apply(this, arguments) || this; return e._numberOfNextedValues = 0, e; } return __extends(e, t), e.prototype.next = function (e) { this._numberOfNextedValues++, t.prototype.next.call(this, e); }, Object.defineProperty(e.prototype, "numberOfNextedValues", { get: function () { return this._numberOfNextedValues; }, enumerable: !0, configurable: !0 }), e; }(Subject), WindowTimeSubscriber = function (t) { function e(e, i, n, r, s) { var o = t.call(this, e) || this; o.destination = e, o.windowTimeSpan = i, o.windowCreationInterval = n, o.maxWindowSize = r, o.scheduler = s, o.windows = []; var c = o.openWindow(); if (null !== n && n >= 0) {
    var u = { subscriber: o, window: c, context: null }, h = { windowTimeSpan: i, windowCreationInterval: n, subscriber: o, scheduler: s };
    o.add(s.schedule(dispatchWindowClose, i, u)), o.add(s.schedule(dispatchWindowCreation, n, h));
}
else {
    var a = { subscriber: o, window: c, windowTimeSpan: i };
    o.add(s.schedule(dispatchWindowTimeSpanOnly, i, a));
} return o; } return __extends(e, t), e.prototype._next = function (t) { for (var e = this.windows, i = e.length, n = 0; n < i; n++) {
    var r = e[n];
    r.closed || (r.next(t), r.numberOfNextedValues >= this.maxWindowSize && this.closeWindow(r));
} }, e.prototype._error = function (t) { for (var e = this.windows; e.length > 0;)
    e.shift().error(t); this.destination.error(t); }, e.prototype._complete = function () { for (var t = this.windows; t.length > 0;) {
    var e = t.shift();
    e.closed || e.complete();
} this.destination.complete(); }, e.prototype.openWindow = function () { var t = new CountedSubject; return this.windows.push(t), this.destination.next(t), t; }, e.prototype.closeWindow = function (t) { t.complete(); var e = this.windows; e.splice(e.indexOf(t), 1); }, e; }(Subscriber);
function dispatchWindowTimeSpanOnly(t) { var e = t.subscriber, i = t.windowTimeSpan, n = t.window; n && e.closeWindow(n), t.window = e.openWindow(), this.schedule(t, i); }
function dispatchWindowCreation(t) { var e = t.windowTimeSpan, i = t.subscriber, n = t.scheduler, r = t.windowCreationInterval, s = { action: this, subscription: null }, o = { subscriber: i, window: i.openWindow(), context: s }; s.subscription = n.schedule(dispatchWindowClose, e, o), this.add(s.subscription), this.schedule(t, r); }
function dispatchWindowClose(t) { var e = t.subscriber, i = t.window, n = t.context; n && n.action && n.subscription && n.action.remove(n.subscription), e.closeWindow(i); }
var WindowToggleSubscriber = function (t) { function e(e, i, n) { var r = t.call(this, e) || this; return r.openings = i, r.closingSelector = n, r.contexts = [], r.add(r.openSubscription = subscribeToResult(r, i, i)), r; } return __extends(e, t), e.prototype._next = function (t) { var e = this.contexts; if (e)
    for (var i = e.length, n = 0; n < i; n++)
        e[n].window.next(t); }, e.prototype._error = function (e) { var i = this.contexts; if (this.contexts = null, i)
    for (var n = i.length, r = -1; ++r < n;) {
        var s = i[r];
        s.window.error(e), s.subscription.unsubscribe();
    } t.prototype._error.call(this, e); }, e.prototype._complete = function () { var e = this.contexts; if (this.contexts = null, e)
    for (var i = e.length, n = -1; ++n < i;) {
        var r = e[n];
        r.window.complete(), r.subscription.unsubscribe();
    } t.prototype._complete.call(this); }, e.prototype._unsubscribe = function () { var t = this.contexts; if (this.contexts = null, t)
    for (var e = t.length, i = -1; ++i < e;) {
        var n = t[i];
        n.window.unsubscribe(), n.subscription.unsubscribe();
    } }, e.prototype.notifyNext = function (t, e, i, n, r) { if (t === this.openings) {
    var s = this.closingSelector, o = tryCatch(s)(e);
    if (o === errorObject)
        return this.error(errorObject.e);
    var c = new Subject, u = new Subscription, h = { window: c, subscription: u };
    this.contexts.push(h);
    var a = subscribeToResult(this, o, h);
    a.closed ? this.closeWindow(this.contexts.length - 1) : (a.context = h, u.add(a)), this.destination.next(c);
}
else
    this.closeWindow(this.contexts.indexOf(t)); }, e.prototype.notifyError = function (t) { this.error(t); }, e.prototype.notifyComplete = function (t) { t !== this.openSubscription && this.closeWindow(this.contexts.indexOf(t.context)); }, e.prototype.closeWindow = function (t) { if (-1 !== t) {
    var e = this.contexts, i = e[t], n = i.window, r = i.subscription;
    e.splice(t, 1), n.complete(), r.unsubscribe();
} }, e; }(OuterSubscriber), WindowSubscriber$1 = function (t) { function e(e, i) { var n = t.call(this, e) || this; return n.destination = e, n.closingSelector = i, n.openWindow(), n; } return __extends(e, t), e.prototype.notifyNext = function (t, e, i, n, r) { this.openWindow(r); }, e.prototype.notifyError = function (t, e) { this._error(t); }, e.prototype.notifyComplete = function (t) { this.openWindow(t); }, e.prototype._next = function (t) { this.window.next(t); }, e.prototype._error = function (t) { this.window.error(t), this.destination.error(t), this.unsubscribeClosingNotification(); }, e.prototype._complete = function () { this.window.complete(), this.destination.complete(), this.unsubscribeClosingNotification(); }, e.prototype.unsubscribeClosingNotification = function () { this.closingNotification && this.closingNotification.unsubscribe(); }, e.prototype.openWindow = function (t) { void 0 === t && (t = null), t && (this.remove(t), t.unsubscribe()); var e = this.window; e && e.complete(); var i = this.window = new Subject; this.destination.next(i); var n = tryCatch(this.closingSelector)(); if (n === errorObject) {
    var r = errorObject.e;
    this.destination.error(r), this.window.error(r);
}
else
    this.add(this.closingNotification = subscribeToResult(this, n)); }, e; }(OuterSubscriber), WithLatestFromSubscriber = function (t) { function e(e, i, n) { var r = t.call(this, e) || this; r.observables = i, r.project = n, r.toRespond = []; var s = i.length; r.values = new Array(s); for (var o = 0; o < s; o++)
    r.toRespond.push(o); for (o = 0; o < s; o++) {
    var c = i[o];
    r.add(subscribeToResult(r, c, c, o));
} return r; } return __extends(e, t), e.prototype.notifyNext = function (t, e, i, n, r) { this.values[i] = e; var s = this.toRespond; if (s.length > 0) {
    var o = s.indexOf(i);
    -1 !== o && s.splice(o, 1);
} }, e.prototype.notifyComplete = function () { }, e.prototype._next = function (t) { if (0 === this.toRespond.length) {
    var e = [t].concat(this.values);
    this.project ? this._tryProject(e) : this.destination.next(e);
} }, e.prototype._tryProject = function (t) { var e; try {
    e = this.project.apply(this, t);
}
catch (t) {
    return void this.destination.error(t);
} this.destination.next(e); }, e; }(OuterSubscriber);
var isObservable = function (t) { return t instanceof Observable; }, log = console.log.bind(console), action$ = new Subject, createStore = function (t, e) {
    if (e === void 0) { e = { timestamp: Util.getTimeStamp(), id: Util.getUUID() }; }
    return action$.pipe(mergeMap(function (t) { return isObservable(t) ? t : from([t]); }), startWith(e), scan(t));
};
function baseReducer(t, e) { switch (e.type) {
    case "CONFIG_LOADING": return Object.assign({}, t, { isLoading: !0 });
    case "CONFIG_LOADED":
        var i_1 = Object.assign({}, t, { isLoading: !1 });
        return Object.keys(e.payload).forEach(function (t) { i_1[t] = e.payload[t]; }), i_1;
    case "SET_CONFIG":
        var n_1 = Object.assign({}, t);
        return Object.keys(e.payload).forEach(function (t) { n_1[t] = e.payload[t]; }), n_1;
    default: return t;
} }
function appReducer(t, e) { switch (e.type) {
    case "GITHUB_FOLLOWERS_LOADING": return Object.assign({}, t, { isLoading: !0 });
    case "GITHUB_FOLLOWERS_LOADED": return Object.assign({}, t, { isLoading: !1, users: e.payload });
    case "NAME_CHANGED": return Object.assign({}, t, { isLoading: !1, name: e.payload });
    default: return t;
} }
var __awaiter = function (t, e, i, n) { return new (i || (i = Promise))(function (r, s) { function o(t) { try {
    u(n.next(t));
}
catch (t) {
    s(t);
} } function c(t) { try {
    u(n.throw(t));
}
catch (t) {
    s(t);
} } function u(t) { t.done ? r(t.value) : new i(function (e) { e(t.value); }).then(o, c); } u((n = n.apply(t, e || [])).next()); }); };
var singleton = Symbol(), singletonEnforcer = Symbol();
var AppService = /** @class */ (function () {
    function AppService(t) {
        if (this.baseUrl = "", this.loading = !0, this.authenticated = !1, this.errorMessage = "", t !== singletonEnforcer)
            throw new Error("Cannot construct singleton");
        this.initStores(), this.base = BaseService.instance, this.config = this.base.config;
    }
    AppService.prototype.init = function (t, e) {
        if (e === void 0) { e = ""; }
        return __awaiter(this, void 0, void 0, function () { var _c, _d, _e, _f; return __generator(this, function (_g) {
            switch (_g.label) {
                case 0:
                    "" !== e && (this.baseUrl = e), this.appRoot = t;
                    return [4 /*yield*/, this.base.initApp(this.baseUrl + "/assets/config.json", !0, "_emaApp")];
                case 1:
                    _g.sent(), this.baseUrl = e, this.base.translation.use(this.config.get("language")), this.data = {};
                    _c = this.data;
                    return [4 /*yield*/, Util.fetchJson(this.baseUrl + "/assets/collection-manifest.json")];
                case 2:
                    _c.manifest = _g.sent();
                    _d = this.data;
                    return [4 /*yield*/, Util.fetchJson(this.baseUrl + "/assets/data/mock-data.json")];
                case 3:
                    _d.mockData = _g.sent();
                    _e = this.data;
                    return [4 /*yield*/, Util.fetchJson(this.baseUrl + "/assets/data/mock-dwp.json")];
                case 4:
                    _e.dwpData = _g.sent();
                    _f = this.data;
                    return [4 /*yield*/, Util.fetchJson(this.baseUrl + "/assets/data/apiSwagger.json")];
                case 5: return [2 /*return*/, (_f.swaggerData = _g.sent(), this.collectionManifest = this.data.manifest, this.parseComponents(), this.initHistory(), window.document.location.hostname.match("localhost") && this.config.set("dev", !0), this.data)];
            }
        }); });
    };
    AppService.prototype.initStores = function () { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_c) {
        this.store$ = createStore(appReducer), this.config$ = createStore(baseReducer), this.store$.pipe().subscribe(function (t) { }), this.config$.pipe().subscribe(function (t) { });
        return [2 /*return*/];
    }); }); };
    AppService.prototype.initHistory = function () { "undefined" != typeof window && window.history; };
    AppService.prototype.parseComponents = function () {
        var _this = this;
        var t = [];
        Util.copy(this.data.manifest.components).map(function (e) { var i = e.tag, n = !1; _this.config.get("componentsIgnorePatterns").forEach(function (t) { i.match(t) && (n = !0); }), n || t.push(e); }), this.components = t;
    };
    AppService.prototype.showFlashMessage = function (t, e, i) {
        if (i === void 0) { i = 2e3; }
        document.querySelector("ema-flash-message").show(t, e, i);
    };
    Object.defineProperty(AppService, "instance", {
        get: function () { return this[singleton] || (this[singleton] = new AppService(singletonEnforcer)), this[singleton]; },
        enumerable: true,
        configurable: true
    });
    return AppService;
}());
export { AppService as a };
