var __extends = (this && this.__extends) || (function () {
    var extendStatics = Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
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 ConfigService, b as Storage } from "./chunk-d01c0689.js";
import { a as Util, b as global$1 } from "./chunk-4bbd7b7f.js";
var en = { ADD: "Add", ADDRESS: "Address", ADMIN: "Administration", CANCEL: "Cancel", "CHANGE LANGUAGE": "Change language", CLOSE: "Close", CONFIRM: "Confirm", "CONFIRM WARNING": "This action cannot be undone", CONTACT: "Contact", COUNTRY: "Country", CREATE: "Create", CURRENT: "Current", DATA: "Data", DATE: "Date", DATE_NTH: { 1: "{day} January {year}", 2: "{day} February {year}", 3: "{day} March {year}", 4: "{day} April {year}", 5: "{day} May {year}", 6: "{day} June {year}", 7: "{day} July {year}", 8: "{day} August {year}", 9: "{day} September {year}", 10: "{day} October {year}", 11: "{day} November {year}", 12: "{day} December {year}" }, DATE_MONTH_NTH: { 1: "January", 2: "February", 3: "March", 4: "April", 5: "May", 6: "June", 7: "July", 8: "August", 9: "September", 10: "October", 11: "November", 12: "December" }, DELETE: "Delete", "DELETE CONFIRM": "Are you sure you want to delete this item", "DELETE CONFIRM MULTIPLE": "Are you sure you want to delete these items", DETAIL: "Detail", DETAILS: "Details", EDIT: "Edit", EMAIL: "E-mail", "EMAIL ADDRESS": "E-mail address", "EMAIL ERROR": "This is not a valid email address", ERROR: "Error", FIELD: "Field", "FIELD REQUIRED": "This field is required", "FORM INVALID": "The form can not be submitted yet. Please fill in the required fields", "FORM SUCCESS": "The data have been stored", LANGUAGE: "Language", LOGIN: "Login", "LOGIN ERROR": "The credentials you provided are not valid", "LOGIN EXPIRED": "Your authorization has expired. Please login again", LOGOUT: "Log out", NAME: "Name", "NETWORK ERROR": "There is no internet connection", PASSWORD: "Password", "PASSWORD ERROR": "Password is required", "PASSWORD MATCH ERROR": "The passwords don't match", REMARKS: "Remarks", REMEMBER: "Remember", REQUIRED: "Required", RESET: "Wissen", RESULT: "Result", RESULTS: "Results", RESULTS_NTH: { 0: "No results", 1: "{n} result", 2: "{n} results", n: "{n} results", gt99: "99+ results" }, SAVE: "Save", SEARCH: "Search", SUBMIT: "Submit", TITLE: "Title", USER: "User", USERS: "Users", USERNAME: "Username", counter: "The count is {n}" }, nl = { ADD: "Toevoegen", ADDRESS: "Adres", ADMIN: "Beheer", CANCEL: "Annuleren", "CHANGE LANGUAGE": "Taal wijzigen", CLOSE: "Sluiten", CONFIRM: "Bevestigen", "CONFIRM WARNING": "Deze handeling kan niet ongedaan worden gemaakt", CONTACT: "Contact", COUNTRY: "Land", CREATE: "Aanmaken", CURRENT: "Huidige", DATA: "Gegevens", DATE: "Datum", DATE_NTH: { 1: "{day} Januari {year}", 2: "{day} Februari {year}", 3: "{day} Maart {year}", 4: "{day} April {year}", 5: "{day} Mei {year}", 6: "{day} Juni {year}", 7: "{day} Juli {year}", 8: "{day} Augustus {year}", 9: "{day} September {year}", 10: "{day} Oktober {year}", 11: "{day} November {year}", 12: "{day} December {year}" }, DATE_MONTH_NTH: { 1: "Januari", 2: "Februari", 3: "Maart", 4: "April", 5: "Mei", 6: "Juni", 7: "Juli", 8: "Augustus", 9: "September", 10: "Oktober", 11: "November", 12: "December" }, DELETE: "Verwijderen", "DELETE CONFIRM": "Weet u zeker dat u dit onderdeel wilt verwijderen", "DELETE CONFIRM MULTIPLE": "Weet u zeker dat u deze onderdelen wilt verwijderen", DETAIL: "Detail", DETAILS: "Details", EDIT: "Bewerken", EMAIL: "E-mail", "EMAIL ADDRESS": "E-mailadres", "EMAIL ERROR": "Er is geen geldige e-mail ingevoerd", ERROR: "Fout", FIELD: "Veld", "FIELD REQUIRED": "Dit veld is verplicht", "FORM INVALID": "Het formulier kan niet worden verstuurd. Vul eerst de ontbrekende velden in", "FORM SUCCESS": "De gegevens zijn opgeslagen", LANGUAGE: "Taal", LOGIN: "Inloggen", "LOGIN ERROR": "De ingevoerde login combinatie is niet geldig", "LOGIN EXPIRED": "Uw autorisatie is verlopen. Log opnieuw in a.u.b", LOGOUT: "Uitloggen", NAME: "Naam", "NETWORK ERROR": "De internetverbinding is verbroken", PASSWORD: "Wachtwoord", "PASSWORD ERROR": "Er is geen geldig wachtwoord ingevoerd", "PASSWORD MATCH ERROR": "De ingevoerde wachtwoorden komen niet overeen", REMARKS: "Opmerkingen", REMEMBER: "Onthouden", REQUIRED: "Verplicht", RESET: "Reset", RESULT: "Resultaat", RESULTS: "Resultaten", RESULTS_NTH: { 0: "Geen resultaten", 1: "{n} resultaat", 2: "{n} resultaten", n: "{n} resultaten", gt99: "99+ resultaten" }, SAVE: "Opslaan", SEARCH: "Zoeken", SUBMIT: "Indienen", TITLE: "Titel", USER: "Gebruiker", USERS: "Gebruikers", USERNAME: "Gebruikersnaam", counter: "Het aantal is {n}" }, i18n = { en: en, nl: nl }, configDefaults = { id: "ema-js-base", name: "ema-js-base", authenticated: !1, version: "0.0.1", domain: "ema-js-base.firebaseapp.com", baseUrl: "https://ema-js-base.firebaseapp.com/", baseRoot: "https://ema-js-base.firebaseapp.com", api_headers: [{ "Content-Type": "application/json;charset=utf-8" }], firebaseApps: { "ema-js-base": { apiKey: "AIzaSyDQuSusOA5HNwIUoyViVOPwEWbGXWt91p4", authDomain: "ema-js-base.firebaseapp.com", databaseURL: "https://ema-js-base.firebaseio.com", projectId: "ema-js-base", storageBucket: "ema-js-base.appspot.com", messagingSenderId: "419979785648" } }, firebase: { apiKey: "AIzaSyDQuSusOA5HNwIUoyViVOPwEWbGXWt91p4", authDomain: "ema-js-base.firebaseapp.com", databaseURL: "https://ema-js-base.firebaseio.com", projectId: "ema-js-base", storageBucket: "ema-js-base.appspot.com", messagingSenderId: "419979785648" }, language: "en", languages: [{ key: "nl", value: "Nederlands" }, { key: "en", value: "English" }], i18n: i18n, permissions: ["read"], roles: { ANONYMOUS: ["read"], AUTHENTICATED: ["read", "create", "update", "logout"], EDITOR: ["create", "read", "update", "delete", "logout"], DEVELOPER: ["create", "read", "update", "delete", "logout", "debug"], ADMINISTRATOR: ["create", "read", "update", "delete", "administrate", "logout", "create-user", "delete-user"], OWNER: ["create", "read", "update", "delete", "administrate", "logout", "create-user", "delete-user", "debug", "autoLogin", "fetchCredentials"] } };
var DomUtil = /** @class */ (function () {
    function DomUtil() {
    }
    DomUtil.addClass = function (e, t) { e.classList ? e.classList.add(t) : e.className += " " + t; };
    DomUtil.hasClass = function (e, t) { e.classList ? e.classList.contains(t) : new RegExp("(^| )" + t + "( |$)", "gi").test(e.className); };
    DomUtil.removeClass = function (e, t) { e.classList ? e.classList.remove(t) : e.className = e.className.replace(new RegExp("(^|\\b)" + t.split(" ").join("|") + "(\\b|$)", "gi"), " "); };
    DomUtil.toggleClass = function (e, t) { if (e.classList)
        e.classList.toggle(t);
    else {
        var r = e.className.split(" "), n = r.indexOf(t);
        n >= 0 ? r.splice(n, 1) : r.push(t), e.className = r.join(" ");
    } };
    DomUtil.remove = function (e) { e.parentNode.removeChild(e); };
    DomUtil.getAttributes = function (e) { var t = e.attributes, r = {}, n = 0; for (; n < t.length; n++)
        r[t[n].name] = t[n].value; return r; };
    DomUtil.setAttributes = function (e, t) { Object.keys(t).forEach(function (r) { e.setAttribute(r, t[r]); }); };
    DomUtil.getStyle = function (e, t) { var r; var n = e.ownerDocument.defaultView; return n && n.getComputedStyle ? (t = t.replace(/([A-Z])/g, "-$1").toLowerCase(), n.getComputedStyle(e, null).getPropertyValue(t)) : e.currentStyle ? (t = t.replace(/\-(\w)/g, function (e, t) { return t.toUpperCase(); }), r = e.currentStyle[t], /^\d+(em|pt|%|ex)?$/i.test(r) ? function (t) { var r = e.style.left, n = e.runtimeStyle.left; return e.runtimeStyle.left = e.currentStyle.left, e.style.left = t || 0, t = e.style.pixelLeft + "px", e.style.left = r, e.runtimeStyle.left = n, t; }(r) : r) : void 0; };
    DomUtil.viewportSize = function () { var e = { width: void 0, height: void 0 }; return "undefined" != typeof window && (window.innerHeight ? (e.width = window.innerWidth, e.height = window.innerHeight) : (e.width = document.documentElement.clientWidth, e.height = document.documentElement.clientHeight)), e; };
    DomUtil.copyToClipboard = function (e) { var t = document.createElement("textarea"); t.value = e, t.setAttribute("readonly", ""), t.style.position = "absolute", t.style.left = "-9999px", document.body.appendChild(t); var r = document.getSelection().rangeCount > 0 && document.getSelection().getRangeAt(0); t.select(), document.execCommand("copy"), document.body.removeChild(t), r && (document.getSelection().removeAllRanges(), document.getSelection().addRange(r)); };
    DomUtil.fadeIn = function (e, t, r, n) {
        if (t === void 0) { t = 300; }
        if (r === void 0) { r = 0; }
        if (n === void 0) { n = "block"; }
        var i = 1 / t * 10;
        e.style.opacity = "0", e.style.display = n, setTimeout(function () { !function t() { var r = parseFloat(e.style.opacity); (r += i) > 1 || (e.style.opacity = r.toString(), requestAnimationFrame(t)); }(); }, r);
    };
    DomUtil.fadeOut = function (e, t, r, n) {
        if (t === void 0) { t = 300; }
        if (r === void 0) { r = 0; }
        if (n === void 0) { n = !1; }
        var i = 1 / t * 10;
        e.style.opacity = "1", setTimeout(function () { !function t() { var r = Number(e.style.opacity); r -= i, e.style.opacity = r.toString(), r < 0 ? !1 === n && (e.style.display = "none", e.style.opacity = "1") : requestAnimationFrame(t); }(); }, r);
    };
    DomUtil.getUrlParameterByName = function (e) { var t = RegExp("[?&]" + e + "=([^&]*)").exec(window.location.search); return t && decodeURIComponent(t[1].replace(/\+/g, " ")); };
    return DomUtil;
}());
var StringUtil = /** @class */ (function () {
    function StringUtil() {
    }
    StringUtil.lowercaseFirst = function (e) { return e.charAt(0).toLowerCase() + e.slice(1); };
    StringUtil.uppercaseFirst = function (e) { return e.charAt(0).toUpperCase() + e.slice(1); };
    StringUtil.replaceAll = function (e, t, r, n) {
        if (n === void 0) { n = !1; }
        return e ? (i = t, s = r, o = n, String(e).replace(new RegExp(i.replace(/([\/\,\!\\\^\$\{\}\[\]\(\)\.\*\+\?\|\<\>\-\&])/g, "\\$&"), o ? "gi" : "g"), "string" == typeof s ? s.replace(/\$/g, "$$$$") : s)) : e;
        var i, s, o;
    };
    StringUtil.between = function (e, t, r, n) {
        if (n === void 0) { n = !1; }
        return e ? function (e, t, r) { var n = e.indexOf(t); if (!(n >= 0))
            return ""; if (e = e.substring(n + t.length), r) {
            if (!((n = e.indexOf(r)) >= 0))
                return "";
            e = e.substring(0, n);
        } return e; }(e, t, r) : e;
    };
    return StringUtil;
}());
var __awaiter = function (e, t, r, n) { return new (r || (r = Promise))(function (i, s) { function o(e) { try {
    c(n.next(e));
}
catch (e) {
    s(e);
} } function u(e) { try {
    c(n.throw(e));
}
catch (e) {
    s(e);
} } function c(e) { e.done ? i(e.value) : new r(function (t) { t(e.value); }).then(o, u); } c((n = n.apply(e, t || [])).next()); }); };
var Translate = /** @class */ (function () {
    function Translate() {
        var _this = this;
        this.i18n = i18n, this.defaultLanguage = "en-US", this.supportedLanguages = ["en-US", "nl-NL"], this.translations = {}, this.translationsLocation = "assets/translations", this.options = { debug: !1, namespaceSplitter: "::" }, this.initTranslateJs(), this.libTranslate = Util.getGlobal().libTranslate, Object.keys(i18n).forEach(function (e) { _this.supportedLanguages.push(e); }), this.translations = Util.copy(i18n), this.translations["nl-NL"] = Util.copy(this.translations.nl), this.translations["en-US"] = Util.copy(this.translations.en), this.translations["en-BE"] = Util.copy(this.translations.en), this.use(this.defaultLanguage);
    }
    Translate.prototype.get = function (e) {
        var t = [];
        for (var _i = 1; _i < arguments.length; _i++) {
            t[_i - 1] = arguments[_i];
        }
        return this.t.apply(this, [e].concat(t));
    };
    Translate.prototype.set = function (e, t) { this.translations[this.language][e] = t; };
    Translate.prototype.add = function (e) {
        var _this = this;
        Object.keys(e).forEach(function (t) { _this.set(t, e[t]); });
    };
    Translate.prototype.use = function (e, t) {
        if (t === void 0) { t = !1; }
        return __awaiter(this, void 0, void 0, function () { var _a; return __generator(this, function (_b) {
            switch (_b.label) {
                case 0:
                    this.language = e;
                    _a = this.translations[e] && !t;
                    if (_a) return [3 /*break*/, 2];
                    return [4 /*yield*/, this.loadTranslation(e)];
                case 1:
                    _a = (_b.sent());
                    _b.label = 2;
                case 2:
                    _a, this.t = this.libTranslate.getTranslationFunction(this.translations[e], [this.options]);
                    return [2 /*return*/];
            }
        }); });
    };
    Translate.prototype.loadTranslation = function (e) { return __awaiter(this, void 0, void 0, function () {
        var t;
        var _this = this;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    this.translations[e] || (this.translations[e] = {});
                    return [4 /*yield*/, Util.fetchJson(this.translationsLocation + "/" + e + ".json")];
                case 1:
                    t = _a.sent();
                    Object.keys(t).forEach(function (r) { _this.translations[e][r] = t[r]; });
                    return [2 /*return*/];
            }
        });
    }); };
    Translate.prototype.initTranslateJs = function () { var e, t, r; e = function (e) { return !isNaN(parseFloat(e)) && isFinite(e); }, t = function (e) { return "object" == typeof e && null !== e; }, r = function (e) { return "[object String]" === Object.prototype.toString.call(e); }, Util.getGlobal().libTranslate = { getTranslationFunction: function (n, i) { function s(e) { if (n[e])
            return n[e]; var t = e.split(c), r = t[0], i = t[1]; return n[r] && n[r][i] ? n[r][i] : null; } function o(e, t) { return r(e) ? e.replace(/\{(\w*)\}/g, function (e, r) { return t.hasOwnProperty(r) ? t.hasOwnProperty(r) ? t[r] : r : (u && console.log('Could not find replacement "' + r + '" in provided replacements object:', t), "{" + r + "}"); }) : e; } var u = (i = t(i) ? i : {}).debug, c = i.namespaceSplitter || "::"; return function (r) { var n = t(arguments[1]) ? arguments[1] : t(arguments[2]) ? arguments[2] : {}, i = e(arguments[1]) ? arguments[1] : e(arguments[2]) ? arguments[2] : null, c = s(r); return null !== i && (n.n = n.n ? n.n : i, c = function (e, r) { if (t(e)) {
            var n, i = Object.keys(e);
            if (0 === i.length)
                return u && console.log("[Translation] No plural forms found."), null;
            for (var s = 0; s < i.length; s++)
                0 === i[s].indexOf("gt") && (n = parseInt(i[s].replace("gt", ""), 10));
            e[r] ? e = e[r] : r > n ? e = e["gt" + n] : e.n ? e = e.n : (u && console.log('[Translation] No plural forms found for count:"' + r + '" in', e), e = e[Object.keys(e).reverse()[0]]);
        } return e; }(c, i)), null === (c = o(c, n)) && (c = u ? "@@" + r + "@@" : r, u && console.log('Translation for "' + r + '" not found.')), c; }; } }; };
    return Translate;
}());
var singleton = Symbol(), singletonEnforcer = Symbol();
var TranslateService = /** @class */ (function (_super) {
    __extends(TranslateService, _super);
    function TranslateService(e) {
        var _this = this;
        if (_this = _super.call(this) || this, e !== singletonEnforcer)
            throw new Error("Cannot construct singleton");
        _this._type = "TranslateService";
        return _this;
    }
    Object.defineProperty(TranslateService, "instance", {
        get: function () { return this[singleton] || (this[singleton] = new TranslateService(singletonEnforcer)), this[singleton]; },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(TranslateService.prototype, "type", {
        get: function () { return this._type; },
        set: function (e) { this._type = e; },
        enumerable: true,
        configurable: true
    });
    return TranslateService;
}(Translate));
var __awaiter$1 = function (e, t, r, n) { return new (r || (r = Promise))(function (i, s) { function o(e) { try {
    c(n.next(e));
}
catch (e) {
    s(e);
} } function u(e) { try {
    c(n.throw(e));
}
catch (e) {
    s(e);
} } function c(e) { e.done ? i(e.value) : new r(function (t) { t(e.value); }).then(o, u); } c((n = n.apply(e, t || [])).next()); }); };
var singleton$1 = Symbol(), singletonEnforcer$1 = Symbol();
var BaseService = /** @class */ (function () {
    function BaseService(e) {
        if (this._environment = { type: "node" }, e !== singletonEnforcer$1)
            throw new Error("Cannot construct singleton");
        this._configService = ConfigService.instance, this._translateService = TranslateService.instance, this._global = this.getGlobal(), this._type = "BaseService";
    }
    BaseService.prototype.initApp = function (e, t, r) {
        if (t === void 0) { t = !1; }
        return __awaiter$1(this, void 0, void 0, function () { var _a; return __generator(this, function (_b) {
            switch (_b.label) {
                case 0:
                    r && this.initGlobalNameSpace(r), t && this.config.setDefaults(configDefaults);
                    if (!("string" == typeof e)) return [3 /*break*/, 2];
                    return [4 /*yield*/, this.config.fetch(e, !0)];
                case 1:
                    _a = _b.sent();
                    return [3 /*break*/, 3];
                case 2:
                    _a = "object" == typeof e ? (this.config.add(e), e) : void 0;
                    _b.label = 3;
                case 3: return [2 /*return*/, _a];
            }
        }); });
    };
    BaseService.prototype.initGlobalNameSpace = function (e) {
        if (e === void 0) { e = "_ema"; }
        this.config.set("globalNameSpace", e), this._environment.namespace = e, this._environment.date = new Date, this._environment.started = Math.round(+new Date / 1e3), this._environment.framework = "js", this.getGlobal()[e] = this, "undefined" != typeof window && (this._environment.type = "browser", window.angular && (this._environment.framework = "angularJs"));
    };
    BaseService.prototype.fetchJson = function (e) { return __awaiter$1(this, void 0, void 0, function () { return __generator(this, function (_a) {
        switch (_a.label) {
            case 0: return [4 /*yield*/, fetch(e)];
            case 1: return [4 /*yield*/, (_a.sent()).json()];
            case 2: return [2 /*return*/, _a.sent()];
        }
    }); }); };
    Object.defineProperty(BaseService.prototype, "config", {
        get: function () { return this._configService; },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(BaseService.prototype, "environment", {
        get: function () { return this._environment; },
        enumerable: true,
        configurable: true
    });
    BaseService.prototype.getGlobal = function () { if ("undefined" != typeof self)
        return self; if ("undefined" != typeof window)
        return window; if (void 0 !== global$1)
        return global$1; throw new Error("unable to locate global object"); };
    Object.defineProperty(BaseService.prototype, "translation", {
        get: function () { return this._translateService; },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(BaseService, "instance", {
        get: function () { return this[singleton$1] || (this[singleton$1] = new BaseService(singletonEnforcer$1)), this[singleton$1]; },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(BaseService.prototype, "type", {
        get: function () { return this._type; },
        set: function (e) { this._type = e; },
        enumerable: true,
        configurable: true
    });
    return BaseService;
}());
var singleton$2 = Symbol(), singletonEnforcer$2 = Symbol();
var PermissionsService = /** @class */ (function () {
    function PermissionsService(e) {
        if (this._permissions = ["read"], this._roles = { ANONYMOUS: ["read"] }, e !== singletonEnforcer$2)
            throw new Error("Cannot construct singleton");
        this._type = "PermissionsService";
    }
    Object.defineProperty(PermissionsService, "instance", {
        get: function () { return this[singleton$2] || (this[singleton$2] = new PermissionsService(singletonEnforcer$2)), this[singleton$2]; },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(PermissionsService.prototype, "permissions", {
        get: function () { return this._permissions; },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(PermissionsService.prototype, "roles", {
        get: function () { return this._roles; },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(PermissionsService.prototype, "user", {
        get: function () { return this._user; },
        set: function (e) { this._user = e; },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(PermissionsService.prototype, "type", {
        get: function () { return this._type; },
        set: function (e) { this._type = e; },
        enumerable: true,
        configurable: true
    });
    return PermissionsService;
}());
var User$$1 = /** @class */ (function () {
    function User$$1(e, t, r, n) {
        if (e === void 0) { e = "visitor"; }
        if (t === void 0) { t = ["ANONYMOUS"]; }
        this.roles = [], this.permissions = PermissionsService.instance, this.name = e, this.roles = t, r || (this.id = Util.getUUID()), n || (this.created = Util.getTimeStamp());
    }
    User$$1.prototype.addRole = function (e) { this.roles.push(e), this.roles = Util.arraySetUnique(this.roles); };
    User$$1.prototype.removeRole = function (e) { var t = this.roles.filter(function (t, r, n) { return t !== e; }); this.roles = t; };
    User$$1.prototype.hasRole = function (e) { var t = !1; return this.roles.forEach(function (r) { r === e && (t = !0); }), t; };
    return User$$1;
}());
var Wordpress = /** @class */ (function () {
    function Wordpress() {
        this.authenticated = !1, this.model = { menus: {}, params: {}, collections: { post: {} } };
    }
    Wordpress.prototype.init = function (e) { var t = this; return "undefined" != typeof window && (window.wp = window.wp || {}), new Promise(function (r, n) { t.initApi(e).then(function () { e.app_server ? t.getParams().then(function () { t.getMenus().then(function () { t.ready = !0, r(); }); }) : r(); }); }); };
    Wordpress.prototype.initApi = function (e) { var t = this; return this.settings = e, this.endpoint = this.settings.protocol + "//" + this.settings.host + "/index.php/wp-json/", new Promise(function (e, r) { "undefined" == typeof window || window.WPAPI || (console.error("ERROR: WPAPI is not defined as global"), r()), location && location.origin === t.settings.protocol + "//" + t.settings.host ? t.discover().then(function () { t.api = new WPAPI({ endpoint: t.endpoint }), t.initCustomRoutes(), e(); }) : (t.api = new WPAPI({ endpoint: t.endpoint }), t.initCustomRoutes(), e()); }); };
    Wordpress.prototype.initCustomRoutes = function () { this.api.params = this.api.registerRoute("app-server/v1", "/params"), this.api.menus = this.api.registerRoute("app-server/v1", "/menus/(?P<id>[a-zA-Z(-]+)"), this.api.apps = this.api.registerRoute("wp/v2", "/apps/(?P<id>\\d+)"), this.api.iframes = this.api.registerRoute("wp/v2", "/iframes/(?P<id>\\d+)"); };
    Wordpress.prototype.getPosts = function () { var e = this; return new Promise(function (t, r) { e.api.posts().then(function (r) { var n = []; r.forEach(function (t) { t.id && (e.model.collections.post[t.id] = t, n.push(t)); }), t(n); }); }); };
    Wordpress.prototype.getParams = function () { var e = this; return new Promise(function (t, r) { e.api.params().then(function (r) { e.model.params = r, t(r); }); }); };
    Wordpress.prototype.getPost = function (e, t) { var r = this; return this.model.collections[t] || (this.model.collections[t] = {}), new Promise(function (n, i) { function s(e, t, i) { r.model.collections[t][e] = i, n(i); } !0 === r.settings.cache && r.model.collections[t][e] ? n(r.model.collections[t][e]) : ("post" === t && r.api.posts().id(e).then(function (r) { return s(e, t, r); }), "page" === t && r.api.pages().id(e).then(function (r) { return s(e, t, r); }), "app" === t && r.api.apps().id(e).then(function (r) { return s(e, t, r); }), "iframe" === t && r.api.iframes().id(e).then(function (r) { return s(e, t, r); })); }); };
    Wordpress.prototype.getMenu = function (e) { var t = this; return new Promise(function (r, n) { t.api.menus().id(e).then(function (n) { t.model.menus[e] = n, r(t.model.menus[e]); }); }); };
    Wordpress.prototype.getMenus = function () { var e = this; return new Promise(function (t, r) { var n = []; var i = 0; e.model.params.menus.length ? (e.model.params.menus.forEach(function (e) { n.push(e.slug); }), n.forEach(function (r) { e.getMenu(r).then(function (s) { e.model.menus[r] = s, ++i === n.length && t(e.model.menus); }); })) : t(e.model.menus); }); };
    Wordpress.prototype.saveLocal = function () { Storage.saveLocalModel(this.model, this.model.params.baseUrl); };
    Wordpress.prototype.restoreLocal = function () { this.model = Storage.restoreLocalModel(this.model.params.baseUrl); };
    Wordpress.prototype.discover = function () { var e = this, t = WPAPI.discover(this.settings.protocol + "//" + this.settings.host); return new Promise(function (r, n) { t.then(function (t) { e.site = t, r(); }); }); };
    return Wordpress;
}());
var Css = /** @class */ (function () {
    function Css() {
    }
    Css.getStyle = function (e, t) {
        if (t === void 0) { t = document.documentElement; }
        return window.getComputedStyle(t).getPropertyValue(e);
    };
    Css.setStyle = function (e, t, r) {
        if (r === void 0) { r = document.documentElement; }
        r.style.setProperty(e, t);
    };
    Css.getVar = function (e, t) {
        if (t === void 0) { t = document.documentElement; }
        return "-" !== e[0] && "-" !== e[1] && (e = "--" + e), Css.getStyle(e, t);
    };
    Css.setVar = function (e, t, r) {
        if (r === void 0) { r = document.documentElement; }
        "-" !== e[0] && "-" !== e[1] && (e = "--" + e), Css.setStyle(e, t, r);
    };
    return Css;
}());
var extendStatics = function (e, t) { return (extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (e, t) { e.__proto__ = t; } || function (e, t) { for (var r in t)
    t.hasOwnProperty(r) && (e[r] = t[r]); })(e, t); };
function __extends(e, t) { function r() { this.constructor = e; } extendStatics(e, t), e.prototype = null === t ? Object.create(t) : (r.prototype = t.prototype, new r); }
function isFunction(e) { return "function" == typeof e; }
var _enable_super_gross_mode_that_will_cause_bad_things = !1, config = { Promise: void 0, set useDeprecatedSynchronousErrorHandling(e) { e && (new Error).stack, _enable_super_gross_mode_that_will_cause_bad_things = e; }, get useDeprecatedSynchronousErrorHandling() { return _enable_super_gross_mode_that_will_cause_bad_things; } };
function hostReportError(e) { setTimeout(function () { throw e; }); }
var empty = { closed: !0, next: function (e) { }, error: function (e) { if (config.useDeprecatedSynchronousErrorHandling)
        throw e; hostReportError(e); }, complete: function () { } }, isArray = Array.isArray || function (e) { return e && "number" == typeof e.length; };
function isObject(e) { return null != e && "object" == typeof e; }
var tryCatchTarget, errorObject = { e: {} };
function tryCatcher() { try {
    return tryCatchTarget.apply(this, arguments);
}
catch (e) {
    return errorObject.e = e, errorObject;
} }
function tryCatch(e) { return tryCatchTarget = e, tryCatcher; }
var UnsubscriptionError = function (e) { function t(r) { var n = e.call(this, r ? r.length + " errors occurred during unsubscription:\n  " + r.map(function (e, t) { return t + 1 + ") " + e.toString(); }).join("\n  ") : "") || this; return n.errors = r, n.name = "UnsubscriptionError", Object.setPrototypeOf(n, t.prototype), n; } return __extends(t, e), t; }(Error), Subscription = function () { function e(e) { this.closed = !1, this._parent = null, this._parents = null, this._subscriptions = null, e && (this._unsubscribe = e); } var t; return e.prototype.unsubscribe = function () { var e, t = !1; if (!this.closed) {
    var r = this._parent, n = this._parents, i = this._unsubscribe, s = this._subscriptions;
    this.closed = !0, this._parent = null, this._parents = null, this._subscriptions = null;
    for (var o = -1, u = n ? n.length : 0; r;)
        r.remove(this), r = ++o < u && n[o] || null;
    if (isFunction(i) && tryCatch(i).call(this) === errorObject && (t = !0, e = e || (errorObject.e instanceof UnsubscriptionError ? flattenUnsubscriptionErrors(errorObject.e.errors) : [errorObject.e])), isArray(s))
        for (o = -1, u = s.length; ++o < u;) {
            var c = s[o];
            if (isObject(c) && tryCatch(c.unsubscribe).call(c) === errorObject) {
                t = !0, e = e || [];
                var a = errorObject.e;
                a instanceof UnsubscriptionError ? e = e.concat(flattenUnsubscriptionErrors(a.errors)) : e.push(a);
            }
        }
    if (t)
        throw new UnsubscriptionError(e);
} }, e.prototype.add = function (t) { if (!t || t === e.EMPTY)
    return e.EMPTY; if (t === this)
    return this; var r = t; switch (typeof t) {
    case "function": r = new e(t);
    case "object":
        if (r.closed || "function" != typeof r.unsubscribe)
            return r;
        if (this.closed)
            return r.unsubscribe(), r;
        if ("function" != typeof r._addParent) {
            var n = r;
            (r = new e)._subscriptions = [n];
        }
        break;
    default: throw new Error("unrecognized teardown " + t + " added to Subscription.");
} return (this._subscriptions || (this._subscriptions = [])).push(r), r._addParent(this), r; }, e.prototype.remove = function (e) { var t = this._subscriptions; if (t) {
    var r = t.indexOf(e);
    -1 !== r && t.splice(r, 1);
} }, e.prototype._addParent = function (e) { var t = this._parent, r = this._parents; t && t !== e ? r ? -1 === r.indexOf(e) && r.push(e) : this._parents = [e] : this._parent = e; }, e.EMPTY = ((t = new e).closed = !0, t), e; }();
function flattenUnsubscriptionErrors(e) { return e.reduce(function (e, t) { return e.concat(t instanceof UnsubscriptionError ? t.errors : t); }, []); }
var rxSubscriber = "function" == typeof Symbol && "function" == typeof Symbol.for ? Symbol.for("rxSubscriber") : "@@rxSubscriber", Subscriber = function (e) { function t(t, r, n) { var i = e.call(this) || this; switch ((i.syncErrorValue = null, i.syncErrorThrown = !1, i.syncErrorThrowable = !1, i.isStopped = !1, arguments.length)) {
    case 0:
        i.destination = empty;
        break;
    case 1:
        if (!t) {
            i.destination = empty;
            break;
        }
        if ("object" == typeof t) {
            if (isTrustedSubscriber(t)) {
                var s = t[rxSubscriber]();
                i.syncErrorThrowable = s.syncErrorThrowable, i.destination = s, s.add(i);
            }
            else
                i.syncErrorThrowable = !0, i.destination = new SafeSubscriber(i, t);
            break;
        }
    default: i.syncErrorThrowable = !0, i.destination = new SafeSubscriber(i, t, r, n);
} return i; } return __extends(t, e), t.prototype[rxSubscriber] = function () { return this; }, t.create = function (e, r, n) { var i = new t(e, r, n); return i.syncErrorThrowable = !1, i; }, t.prototype.next = function (e) { this.isStopped || this._next(e); }, t.prototype.error = function (e) { this.isStopped || (this.isStopped = !0, this._error(e)); }, t.prototype.complete = function () { this.isStopped || (this.isStopped = !0, this._complete()); }, t.prototype.unsubscribe = function () { this.closed || (this.isStopped = !0, e.prototype.unsubscribe.call(this)); }, t.prototype._next = function (e) { this.destination.next(e); }, t.prototype._error = function (e) { this.destination.error(e), this.unsubscribe(); }, t.prototype._complete = function () { this.destination.complete(), this.unsubscribe(); }, t.prototype._unsubscribeAndRecycle = function () { var e = this._parent, t = this._parents; return this._parent = null, this._parents = null, this.unsubscribe(), this.closed = !1, this.isStopped = !1, this._parent = e, this._parents = t, this; }, t; }(Subscription), SafeSubscriber = function (e) { function t(t, r, n, i) { var s, o = e.call(this) || this; o._parentSubscriber = t; var u = o; return isFunction(r) ? s = r : r && (s = r.next, n = r.error, i = r.complete, r !== empty && (isFunction((u = Object.create(r)).unsubscribe) && o.add(u.unsubscribe.bind(u)), u.unsubscribe = o.unsubscribe.bind(o))), o._context = u, o._next = s, o._error = n, o._complete = i, o; } return __extends(t, e), t.prototype.next = function (e) { if (!this.isStopped && this._next) {
    var t = this._parentSubscriber;
    config.useDeprecatedSynchronousErrorHandling && t.syncErrorThrowable ? this.__tryOrSetError(t, this._next, e) && this.unsubscribe() : this.__tryOrUnsub(this._next, e);
} }, t.prototype.error = function (e) { if (!this.isStopped) {
    var t = this._parentSubscriber, r = config.useDeprecatedSynchronousErrorHandling;
    if (this._error)
        r && t.syncErrorThrowable ? (this.__tryOrSetError(t, this._error, e), this.unsubscribe()) : (this.__tryOrUnsub(this._error, e), this.unsubscribe());
    else if (t.syncErrorThrowable)
        r ? (t.syncErrorValue = e, t.syncErrorThrown = !0) : hostReportError(e), this.unsubscribe();
    else {
        if (this.unsubscribe(), r)
            throw e;
        hostReportError(e);
    }
} }, t.prototype.complete = function () { var e = this; if (!this.isStopped) {
    var t = this._parentSubscriber;
    if (this._complete) {
        var r = function () { return e._complete.call(e._context); };
        config.useDeprecatedSynchronousErrorHandling && t.syncErrorThrowable ? (this.__tryOrSetError(t, r), this.unsubscribe()) : (this.__tryOrUnsub(r), this.unsubscribe());
    }
    else
        this.unsubscribe();
} }, t.prototype.__tryOrUnsub = function (e, t) { try {
    e.call(this._context, t);
}
catch (e) {
    if (this.unsubscribe(), config.useDeprecatedSynchronousErrorHandling)
        throw e;
    hostReportError(e);
} }, t.prototype.__tryOrSetError = function (e, t, r) { if (!config.useDeprecatedSynchronousErrorHandling)
    throw new Error("bad call"); try {
    t.call(this._context, r);
}
catch (t) {
    return config.useDeprecatedSynchronousErrorHandling ? (e.syncErrorValue = t, e.syncErrorThrown = !0, !0) : (hostReportError(t), !0);
} return !1; }, t.prototype._unsubscribe = function () { var e = this._parentSubscriber; this._context = null, this._parentSubscriber = null, e.unsubscribe(); }, t; }(Subscriber);
function isTrustedSubscriber(e) { return e instanceof Subscriber || "syncErrorThrowable" in e && e[rxSubscriber]; }
function toSubscriber(e, t, r) { if (e) {
    if (e instanceof Subscriber)
        return e;
    if (e[rxSubscriber])
        return e[rxSubscriber]();
} return e || t || r ? new Subscriber(e, t, r) : new Subscriber(empty); }
var observable = "function" == typeof Symbol && Symbol.observable || "@@observable";
function noop() { }
function pipeFromArray(e) { return e ? 1 === e.length ? e[0] : function (t) { return e.reduce(function (e, t) { return t(e); }, t); } : noop; }
var Observable = function () { function e(e) { this._isScalar = !1, e && (this._subscribe = e); } return e.prototype.lift = function (t) { var r = new e; return r.source = this, r.operator = t, r; }, e.prototype.subscribe = function (e, t, r) { var n = this.operator, i = toSubscriber(e, t, r); if (n ? n.call(i, this.source) : i.add(this.source || config.useDeprecatedSynchronousErrorHandling && !i.syncErrorThrowable ? this._subscribe(i) : this._trySubscribe(i)), config.useDeprecatedSynchronousErrorHandling && i.syncErrorThrowable && (i.syncErrorThrowable = !1, i.syncErrorThrown))
    throw i.syncErrorValue; return i; }, e.prototype._trySubscribe = function (e) { try {
    return this._subscribe(e);
}
catch (t) {
    config.useDeprecatedSynchronousErrorHandling && (e.syncErrorThrown = !0, e.syncErrorValue = t), e.error(t);
} }, e.prototype.forEach = function (e, t) { var r = this; return new (t = getPromiseCtor(t))(function (t, n) { var i; i = r.subscribe(function (t) { try {
    e(t);
}
catch (e) {
    n(e), i && i.unsubscribe();
} }, n, t); }); }, e.prototype._subscribe = function (e) { var t = this.source; return t && t.subscribe(e); }, e.prototype[observable] = function () { return this; }, e.prototype.pipe = function () { for (var e = [], t = 0; t < arguments.length; t++)
    e[t] = arguments[t]; return 0 === e.length ? this : pipeFromArray(e)(this); }, e.prototype.toPromise = function (e) { var t = this; return new (e = getPromiseCtor(e))(function (e, r) { var n; t.subscribe(function (e) { return n = e; }, function (e) { return r(e); }, function () { return e(n); }); }); }, e.create = function (t) { return new e(t); }, e; }();
function getPromiseCtor(e) { if (e || (e = config.Promise || Promise), !e)
    throw new Error("no Promise impl found"); return e; }
var ObjectUnsubscribedError = function (e) { function t() { var r = e.call(this, "object unsubscribed") || this; return r.name = "ObjectUnsubscribedError", Object.setPrototypeOf(r, t.prototype), r; } return __extends(t, e), t; }(Error), SubjectSubscription = function (e) { function t(t, r) { var n = e.call(this) || this; return n.subject = t, n.subscriber = r, n.closed = !1, n; } return __extends(t, e), t.prototype.unsubscribe = function () { if (!this.closed) {
    this.closed = !0;
    var e = this.subject, t = e.observers;
    if (this.subject = null, t && 0 !== t.length && !e.isStopped && !e.closed) {
        var r = t.indexOf(this.subscriber);
        -1 !== r && t.splice(r, 1);
    }
} }, t; }(Subscription), SubjectSubscriber = function (e) { function t(t) { var r = e.call(this, t) || this; return r.destination = t, r; } return __extends(t, e), t; }(Subscriber), Subject = function (e) { function t() { var t = e.call(this) || this; return t.observers = [], t.closed = !1, t.isStopped = !1, t.hasError = !1, t.thrownError = null, t; } return __extends(t, e), t.prototype[rxSubscriber] = function () { return new SubjectSubscriber(this); }, t.prototype.lift = function (e) { var t = new AnonymousSubject(this, this); return t.operator = e, t; }, t.prototype.next = function (e) { if (this.closed)
    throw new ObjectUnsubscribedError; if (!this.isStopped)
    for (var t = this.observers, r = t.length, n = t.slice(), i = 0; i < r; i++)
        n[i].next(e); }, t.prototype.error = function (e) { if (this.closed)
    throw new ObjectUnsubscribedError; this.hasError = !0, this.thrownError = e, this.isStopped = !0; for (var t = this.observers, r = t.length, n = t.slice(), i = 0; i < r; i++)
    n[i].error(e); this.observers.length = 0; }, t.prototype.complete = function () { if (this.closed)
    throw new ObjectUnsubscribedError; this.isStopped = !0; for (var e = this.observers, t = e.length, r = e.slice(), n = 0; n < t; n++)
    r[n].complete(); this.observers.length = 0; }, t.prototype.unsubscribe = function () { this.isStopped = !0, this.closed = !0, this.observers = null; }, t.prototype._trySubscribe = function (t) { if (this.closed)
    throw new ObjectUnsubscribedError; return e.prototype._trySubscribe.call(this, t); }, t.prototype._subscribe = function (e) { if (this.closed)
    throw new ObjectUnsubscribedError; return this.hasError ? (e.error(this.thrownError), Subscription.EMPTY) : this.isStopped ? (e.complete(), Subscription.EMPTY) : (this.observers.push(e), new SubjectSubscription(this, e)); }, t.prototype.asObservable = function () { var e = new Observable; return e.source = this, e; }, t.create = function (e, t) { return new AnonymousSubject(e, t); }, t; }(Observable), AnonymousSubject = function (e) { function t(t, r) { var n = e.call(this) || this; return n.destination = t, n.source = r, n; } return __extends(t, e), t.prototype.next = function (e) { var t = this.destination; t && t.next && t.next(e); }, t.prototype.error = function (e) { var t = this.destination; t && t.error && this.destination.error(e); }, t.prototype.complete = function () { var e = this.destination; e && e.complete && this.destination.complete(); }, t.prototype._subscribe = function (e) { return this.source ? this.source.subscribe(e) : Subscription.EMPTY; }, t; }(Subject);
function refCount() { return function (e) { return e.lift(new RefCountOperator(e)); }; }
var RefCountOperator = function () { function e(e) { this.connectable = e; } return e.prototype.call = function (e, t) { var r = this.connectable; r._refCount++; var n = new RefCountSubscriber(e, r), i = t.subscribe(n); return n.closed || (n.connection = r.connect()), i; }, e; }(), RefCountSubscriber = function (e) { function t(t, r) { var n = e.call(this, t) || this; return n.connectable = r, n; } return __extends(t, e), t.prototype._unsubscribe = function () { var e = this.connectable; if (e) {
    this.connectable = null;
    var t = e._refCount;
    if (t <= 0)
        this.connection = null;
    else if (e._refCount = t - 1, t > 1)
        this.connection = null;
    else {
        var r = this.connection, n = e._connection;
        this.connection = null, !n || r && n !== r || n.unsubscribe();
    }
}
else
    this.connection = null; }, t; }(Subscriber), ConnectableObservable = function (e) { function t(t, r) { var n = e.call(this) || this; return n.source = t, n.subjectFactory = r, n._refCount = 0, n._isComplete = !1, n; } return __extends(t, e), t.prototype._subscribe = function (e) { return this.getSubject().subscribe(e); }, t.prototype.getSubject = function () { var e = this._subject; return e && !e.isStopped || (this._subject = this.subjectFactory()), this._subject; }, t.prototype.connect = function () { var e = this._connection; return e || (this._isComplete = !1, (e = this._connection = new Subscription).add(this.source.subscribe(new ConnectableSubscriber(this.getSubject(), this))), e.closed ? (this._connection = null, e = Subscription.EMPTY) : this._connection = e), e; }, t.prototype.refCount = function () { return refCount()(this); }, t; }(Observable), ConnectableSubscriber = function (e) { function t(t, r) { var n = e.call(this, t) || this; return n.connectable = r, n; } return __extends(t, e), t.prototype._error = function (t) { this._unsubscribe(), e.prototype._error.call(this, t); }, t.prototype._complete = function () { this.connectable._isComplete = !0, this._unsubscribe(), e.prototype._complete.call(this); }, t.prototype._unsubscribe = function () { var e = this.connectable; if (e) {
    this.connectable = null;
    var t = e._connection;
    e._refCount = 0, e._subject = null, e._connection = null, t && t.unsubscribe();
} }, t; }(SubjectSubscriber), RefCountSubscriber$1 = function (e) { function t(t, r) { var n = e.call(this, t) || this; return n.connectable = r, n; } return __extends(t, e), t.prototype._unsubscribe = function () { var e = this.connectable; if (e) {
    this.connectable = null;
    var t = e._refCount;
    if (t <= 0)
        this.connection = null;
    else if (e._refCount = t - 1, t > 1)
        this.connection = null;
    else {
        var r = this.connection, n = e._connection;
        this.connection = null, !n || r && n !== r || n.unsubscribe();
    }
}
else
    this.connection = null; }, t; }(Subscriber), GroupBySubscriber = function (e) { function t(t, r, n, i, s) { var o = e.call(this, t) || this; return o.keySelector = r, o.elementSelector = n, o.durationSelector = i, o.subjectSelector = s, o.groups = null, o.attemptedToUnsubscribe = !1, o.count = 0, o; } return __extends(t, e), t.prototype._next = function (e) { var t; try {
    t = this.keySelector(e);
}
catch (e) {
    return void this.error(e);
} this._group(e, t); }, t.prototype._group = function (e, t) { var r = this.groups; r || (r = this.groups = new Map); var n, i = r.get(t); if (this.elementSelector)
    try {
        n = this.elementSelector(e);
    }
    catch (e) {
        this.error(e);
    }
else
    n = e; if (!i) {
    i = this.subjectSelector ? this.subjectSelector() : new Subject, r.set(t, i);
    var s = new GroupedObservable(t, i, this);
    if (this.destination.next(s), this.durationSelector) {
        var o = void 0;
        try {
            o = this.durationSelector(new GroupedObservable(t, i));
        }
        catch (e) {
            return void this.error(e);
        }
        this.add(o.subscribe(new GroupDurationSubscriber(t, i, this)));
    }
} i.closed || i.next(n); }, t.prototype._error = function (e) { var t = this.groups; t && (t.forEach(function (t, r) { t.error(e); }), t.clear()), this.destination.error(e); }, t.prototype._complete = function () { var e = this.groups; e && (e.forEach(function (e, t) { e.complete(); }), e.clear()), this.destination.complete(); }, t.prototype.removeGroup = function (e) { this.groups.delete(e); }, t.prototype.unsubscribe = function () { this.closed || (this.attemptedToUnsubscribe = !0, 0 === this.count && e.prototype.unsubscribe.call(this)); }, t; }(Subscriber), GroupDurationSubscriber = function (e) { function t(t, r, n) { var i = e.call(this, r) || this; return i.key = t, i.group = r, i.parent = n, i; } return __extends(t, e), t.prototype._next = function (e) { this.complete(); }, t.prototype._unsubscribe = function () { var e = this.parent, t = this.key; this.key = this.parent = null, e && e.removeGroup(t); }, t; }(Subscriber), GroupedObservable = function (e) { function t(t, r, n) { var i = e.call(this) || this; return i.key = t, i.groupSubject = r, i.refCountSubscription = n, i; } return __extends(t, e), t.prototype._subscribe = function (e) { var t = new Subscription, r = this.refCountSubscription, n = this.groupSubject; return r && !r.closed && t.add(new InnerRefCountSubscription(r)), t.add(n.subscribe(e)), t; }, t; }(Observable), InnerRefCountSubscription = function (e) { function t(t) { var r = e.call(this) || this; return r.parent = t, t.count++, r; } return __extends(t, e), t.prototype.unsubscribe = function () { var t = this.parent; t.closed || this.closed || (e.prototype.unsubscribe.call(this), t.count -= 1, 0 === t.count && t.attemptedToUnsubscribe && t.unsubscribe()); }, t; }(Subscription), BehaviorSubject = function (e) { function t(t) { var r = e.call(this) || this; return r._value = t, r; } return __extends(t, e), Object.defineProperty(t.prototype, "value", { get: function () { return this.getValue(); }, enumerable: !0, configurable: !0 }), t.prototype._subscribe = function (t) { var r = e.prototype._subscribe.call(this, t); return r && !r.closed && t.next(this._value), r; }, t.prototype.getValue = function () { if (this.hasError)
    throw this.thrownError; if (this.closed)
    throw new ObjectUnsubscribedError; return this._value; }, t.prototype.next = function (t) { e.prototype.next.call(this, this._value = t); }, t; }(Subject), Action = function (e) { function t(t, r) { return e.call(this) || this; } return __extends(t, e), t.prototype.schedule = function (e, t) { return void 0 === t && (t = 0), this; }, t; }(Subscription), AsyncAction = function (e) { function t(t, r) { var n = e.call(this, t, r) || this; return n.scheduler = t, n.work = r, n.pending = !1, n; } return __extends(t, e), t.prototype.schedule = function (e, t) { if (void 0 === t && (t = 0), this.closed)
    return this; this.state = e; var r = this.id, n = this.scheduler; return null != r && (this.id = this.recycleAsyncId(n, r, t)), this.pending = !0, this.delay = t, this.id = this.id || this.requestAsyncId(n, this.id, t), this; }, t.prototype.requestAsyncId = function (e, t, r) { return void 0 === r && (r = 0), setInterval(e.flush.bind(e, this), r); }, t.prototype.recycleAsyncId = function (e, t, r) { if (void 0 === r && (r = 0), null !== r && this.delay === r && !1 === this.pending)
    return t; clearInterval(t); }, t.prototype.execute = function (e, t) { if (this.closed)
    return new Error("executing a cancelled action"); this.pending = !1; var r = this._execute(e, t); if (r)
    return r; !1 === this.pending && null != this.id && (this.id = this.recycleAsyncId(this.scheduler, this.id, null)); }, t.prototype._execute = function (e, t) { var r = !1, n = void 0; try {
    this.work(e);
}
catch (e) {
    r = !0, n = !!e && e || new Error(e);
} if (r)
    return this.unsubscribe(), n; }, t.prototype._unsubscribe = function () { var e = this.id, t = this.scheduler, r = t.actions, n = r.indexOf(this); this.work = null, this.state = null, this.pending = !1, this.scheduler = null, -1 !== n && r.splice(n, 1), null != e && (this.id = this.recycleAsyncId(t, e, null)), this.delay = null; }, t; }(Action), QueueAction = function (e) { function t(t, r) { var n = e.call(this, t, r) || this; return n.scheduler = t, n.work = r, n; } return __extends(t, e), t.prototype.schedule = function (t, r) { return void 0 === r && (r = 0), r > 0 ? e.prototype.schedule.call(this, t, r) : (this.delay = r, this.state = t, this.scheduler.flush(this), this); }, t.prototype.execute = function (t, r) { return r > 0 || this.closed ? e.prototype.execute.call(this, t, r) : this._execute(t, r); }, t.prototype.requestAsyncId = function (t, r, n) { return void 0 === n && (n = 0), null !== n && n > 0 || null === n && this.delay > 0 ? e.prototype.requestAsyncId.call(this, t, r, n) : t.flush(this); }, t; }(AsyncAction), Scheduler = function () { function e(t, r) { void 0 === r && (r = e.now), this.SchedulerAction = t, this.now = r; } return e.prototype.schedule = function (e, t, r) { return void 0 === t && (t = 0), new this.SchedulerAction(this, e).schedule(r, t); }, e.now = function () { return Date.now(); }, e; }(), AsyncScheduler = function (e) { function t(r, n) { void 0 === n && (n = Scheduler.now); var i = e.call(this, r, function () { return t.delegate && t.delegate !== i ? t.delegate.now() : n(); }) || this; return i.actions = [], i.active = !1, i.scheduled = void 0, i; } return __extends(t, e), t.prototype.schedule = function (r, n, i) { return void 0 === n && (n = 0), t.delegate && t.delegate !== this ? t.delegate.schedule(r, n, i) : e.prototype.schedule.call(this, r, n, i); }, t.prototype.flush = function (e) { var t = this.actions; if (this.active)
    t.push(e);
else {
    var r;
    this.active = !0;
    do {
        if (r = e.execute(e.state, e.delay))
            break;
    } while (e = t.shift());
    if (this.active = !1, r) {
        for (; e = t.shift();)
            e.unsubscribe();
        throw r;
    }
} }, t; }(Scheduler), QueueScheduler = function (e) { function t() { return null !== e && e.apply(this, arguments) || this; } return __extends(t, e), t; }(AsyncScheduler), queue = new QueueScheduler(QueueAction), EMPTY = new Observable(function (e) { return e.complete(); });
function empty$1(e) { return e ? emptyScheduled(e) : EMPTY; }
function emptyScheduled(e) { return new Observable(function (t) { return e.schedule(function () { return t.complete(); }); }); }
function isScheduler(e) { return e && "function" == typeof e.schedule; }
var subscribeToArray = function (e) { return function (t) { for (var r = 0, n = e.length; r < n && !t.closed; r++)
    t.next(e[r]); t.closed || t.complete(); }; };
function fromArray(e, t) { return new Observable(t ? function (r) { var n = new Subscription, i = 0; return n.add(t.schedule(function () { i !== e.length ? (r.next(e[i++]), r.closed || n.add(this.schedule())) : r.complete(); })), n; } : subscribeToArray(e)); }
function scalar(e) { var t = new Observable(function (t) { t.next(e), t.complete(); }); return t._isScalar = !0, t.value = e, t; }
function of() { for (var e = [], t = 0; t < arguments.length; t++)
    e[t] = arguments[t]; var r = e[e.length - 1]; switch (isScheduler(r) ? e.pop() : r = void 0, e.length) {
    case 0: return empty$1(r);
    case 1: return r ? fromArray(e, r) : scalar(e[0]);
    default: return fromArray(e, r);
} }
function throwError(e, t) { return new Observable(t ? function (r) { return t.schedule(dispatch, 0, { error: e, subscriber: r }); } : function (t) { return t.error(e); }); }
function dispatch(e) { var t = e.error; e.subscriber.error(t); }
var Notification = function () { function e(e, t, r) { this.kind = e, this.value = t, this.error = r, this.hasValue = "N" === e; } return e.prototype.observe = function (e) { switch (this.kind) {
    case "N": return e.next && e.next(this.value);
    case "E": return e.error && e.error(this.error);
    case "C": return e.complete && e.complete();
} }, e.prototype.do = function (e, t, r) { switch (this.kind) {
    case "N": return e && e(this.value);
    case "E": return t && t(this.error);
    case "C": return r && r();
} }, e.prototype.accept = function (e, t, r) { return e && "function" == typeof e.next ? this.observe(e) : this.do(e, t, r); }, e.prototype.toObservable = function () { switch (this.kind) {
    case "N": return of(this.value);
    case "E": return throwError(this.error);
    case "C": return empty$1();
} throw new Error("unexpected notification kind value"); }, e.createNext = function (t) { return void 0 !== t ? new e("N", t) : e.undefinedValueNotification; }, e.createError = function (t) { return new e("E", void 0, t); }, e.createComplete = function () { return e.completeNotification; }, e.completeNotification = new e("C"), e.undefinedValueNotification = new e("N", void 0), e; }(), ObserveOnSubscriber = function (e) { function t(t, r, n) { void 0 === n && (n = 0); var i = e.call(this, t) || this; return i.scheduler = r, i.delay = n, i; } return __extends(t, e), t.dispatch = function (e) { var t = e.notification, r = e.destination; t.observe(r), this.unsubscribe(); }, t.prototype.scheduleMessage = function (e) { this.add(this.scheduler.schedule(t.dispatch, this.delay, new ObserveOnMessage(e, this.destination))); }, t.prototype._next = function (e) { this.scheduleMessage(Notification.createNext(e)); }, t.prototype._error = function (e) { this.scheduleMessage(Notification.createError(e)); }, t.prototype._complete = function () { this.scheduleMessage(Notification.createComplete()); }, t; }(Subscriber), ObserveOnMessage = function (e, t) { this.notification = e, this.destination = t; }, ReplaySubject = function (e) { function t(t, r, n) { void 0 === t && (t = Number.POSITIVE_INFINITY), void 0 === r && (r = Number.POSITIVE_INFINITY); var i = e.call(this) || this; return i.scheduler = n, i._events = [], i._infiniteTimeWindow = !1, i._bufferSize = t < 1 ? 1 : t, i._windowTime = r < 1 ? 1 : r, r === Number.POSITIVE_INFINITY ? (i._infiniteTimeWindow = !0, i.next = i.nextInfiniteTimeWindow) : i.next = i.nextTimeWindow, i; } return __extends(t, e), t.prototype.nextInfiniteTimeWindow = function (t) { var r = this._events; r.push(t), r.length > this._bufferSize && r.shift(), e.prototype.next.call(this, t); }, t.prototype.nextTimeWindow = function (t) { this._events.push(new ReplayEvent(this._getNow(), t)), this._trimBufferThenGetEvents(), e.prototype.next.call(this, t); }, t.prototype._subscribe = function (e) { var t, r = this._infiniteTimeWindow, n = r ? this._events : this._trimBufferThenGetEvents(), i = this.scheduler, s = n.length; if (this.closed)
    throw new ObjectUnsubscribedError; if (this.isStopped || this.hasError ? t = Subscription.EMPTY : (this.observers.push(e), t = new SubjectSubscription(this, e)), i && e.add(e = new ObserveOnSubscriber(e, i)), r)
    for (var o = 0; o < s && !e.closed; o++)
        e.next(n[o]);
else
    for (o = 0; o < s && !e.closed; o++)
        e.next(n[o].value); return this.hasError ? e.error(this.thrownError) : this.isStopped && e.complete(), t; }, t.prototype._getNow = function () { return (this.scheduler || queue).now(); }, t.prototype._trimBufferThenGetEvents = function () { for (var e = this._getNow(), t = this._bufferSize, r = this._windowTime, n = this._events, i = n.length, s = 0; s < i && !(e - n[s].time < r);)
    s++; return i > t && (s = Math.max(s, i - t)), s > 0 && n.splice(0, s), n; }, t; }(Subject), ReplayEvent = function (e, t) { this.time = e, this.value = t; }, AsyncSubject = function (e) { function t() { var t = null !== e && e.apply(this, arguments) || this; return t.value = null, t.hasNext = !1, t.hasCompleted = !1, t; } return __extends(t, e), t.prototype._subscribe = function (t) { return this.hasError ? (t.error(this.thrownError), Subscription.EMPTY) : this.hasCompleted && this.hasNext ? (t.next(this.value), t.complete(), Subscription.EMPTY) : e.prototype._subscribe.call(this, t); }, t.prototype.next = function (e) { this.hasCompleted || (this.value = e, this.hasNext = !0); }, t.prototype.error = function (t) { this.hasCompleted || e.prototype.error.call(this, t); }, t.prototype.complete = function () { this.hasCompleted = !0, this.hasNext && e.prototype.next.call(this, this.value), e.prototype.complete.call(this); }, t; }(Subject), nextHandle = 1, tasksByHandle = {};
function runIfPresent(e) { var t = tasksByHandle[e]; t && t(); }
var Immediate = { setImmediate: function (e) { var t = nextHandle++; return tasksByHandle[t] = e, Promise.resolve().then(function () { return runIfPresent(t); }), t; }, clearImmediate: function (e) { delete tasksByHandle[e]; } }, AsapAction = function (e) { function t(t, r) { var n = e.call(this, t, r) || this; return n.scheduler = t, n.work = r, n; } return __extends(t, e), t.prototype.requestAsyncId = function (t, r, n) { return void 0 === n && (n = 0), null !== n && n > 0 ? e.prototype.requestAsyncId.call(this, t, r, n) : (t.actions.push(this), t.scheduled || (t.scheduled = Immediate.setImmediate(t.flush.bind(t, null)))); }, t.prototype.recycleAsyncId = function (t, r, n) { if (void 0 === n && (n = 0), null !== n && n > 0 || null === n && this.delay > 0)
    return e.prototype.recycleAsyncId.call(this, t, r, n); 0 === t.actions.length && (Immediate.clearImmediate(r), t.scheduled = void 0); }, t; }(AsyncAction), AsapScheduler = function (e) { function t() { return null !== e && e.apply(this, arguments) || this; } return __extends(t, e), t.prototype.flush = function (e) { this.active = !0, this.scheduled = void 0; var t, r = this.actions, n = -1, i = r.length; e = e || r.shift(); do {
    if (t = e.execute(e.state, e.delay))
        break;
} while (++n < i && (e = r.shift())); if (this.active = !1, t) {
    for (; ++n < i && (e = r.shift());)
        e.unsubscribe();
    throw t;
} }, t; }(AsyncScheduler), asap = new AsapScheduler(AsapAction), async = new AsyncScheduler(AsyncAction), AnimationFrameAction = function (e) { function t(t, r) { var n = e.call(this, t, r) || this; return n.scheduler = t, n.work = r, n; } return __extends(t, e), t.prototype.requestAsyncId = function (t, r, n) { return void 0 === n && (n = 0), null !== n && n > 0 ? e.prototype.requestAsyncId.call(this, t, r, n) : (t.actions.push(this), t.scheduled || (t.scheduled = requestAnimationFrame(function () { return t.flush(null); }))); }, t.prototype.recycleAsyncId = function (t, r, n) { if (void 0 === n && (n = 0), null !== n && n > 0 || null === n && this.delay > 0)
    return e.prototype.recycleAsyncId.call(this, t, r, n); 0 === t.actions.length && (cancelAnimationFrame(r), t.scheduled = void 0); }, t; }(AsyncAction), AnimationFrameScheduler = function (e) { function t() { return null !== e && e.apply(this, arguments) || this; } return __extends(t, e), t.prototype.flush = function (e) { this.active = !0, this.scheduled = void 0; var t, r = this.actions, n = -1, i = r.length; e = e || r.shift(); do {
    if (t = e.execute(e.state, e.delay))
        break;
} while (++n < i && (e = r.shift())); if (this.active = !1, t) {
    for (; ++n < i && (e = r.shift());)
        e.unsubscribe();
    throw t;
} }, t; }(AsyncScheduler), animationFrame = new AnimationFrameScheduler(AnimationFrameAction), VirtualTimeScheduler = function (e) { function t(t, r) { void 0 === t && (t = VirtualAction), void 0 === r && (r = Number.POSITIVE_INFINITY); var n = e.call(this, t, function () { return n.frame; }) || this; return n.maxFrames = r, n.frame = 0, n.index = -1, n; } return __extends(t, e), t.prototype.flush = function () { for (var e, t, r = this.actions, n = this.maxFrames; (t = r.shift()) && (this.frame = t.delay) <= n && !(e = t.execute(t.state, t.delay));)
    ; if (e) {
    for (; t = r.shift();)
        t.unsubscribe();
    throw e;
} }, t.frameTimeFactor = 10, t; }(AsyncScheduler), VirtualAction = function (e) { function t(t, r, n) { void 0 === n && (n = t.index += 1); var i = e.call(this, t, r) || this; return i.scheduler = t, i.work = r, i.index = n, i.active = !0, i.index = t.index = n, i; } return __extends(t, e), t.prototype.schedule = function (r, n) { if (void 0 === n && (n = 0), !this.id)
    return e.prototype.schedule.call(this, r, n); this.active = !1; var i = new t(this.scheduler, this.work); return this.add(i), i.schedule(r, n); }, t.prototype.requestAsyncId = function (e, r, n) { void 0 === n && (n = 0), this.delay = e.frame + n; var i = e.actions; return i.push(this), i.sort(t.sortActions), !0; }, t.prototype.recycleAsyncId = function (e, t, r) { void 0 === r && (r = 0); }, t.prototype._execute = function (t, r) { if (!0 === this.active)
    return e.prototype._execute.call(this, t, r); }, t.sortActions = function (e, t) { return e.delay === t.delay ? e.index === t.index ? 0 : e.index > t.index ? 1 : -1 : e.delay > t.delay ? 1 : -1; }, t; }(AsyncAction);
function identity(e) { return e; }
var ArgumentOutOfRangeError = function (e) { function t() { var r = e.call(this, "argument out of range") || this; return r.name = "ArgumentOutOfRangeError", Object.setPrototypeOf(r, t.prototype), r; } return __extends(t, e), t; }(Error), EmptyError = function (e) { function t() { var r = e.call(this, "no elements in sequence") || this; return r.name = "EmptyError", Object.setPrototypeOf(r, t.prototype), r; } return __extends(t, e), t; }(Error), TimeoutError = function (e) { function t() { var r = e.call(this, "Timeout has occurred") || this; return r.name = "TimeoutError", Object.setPrototypeOf(r, t.prototype), r; } return __extends(t, e), t; }(Error);
function map(e, t) { return function (r) { if ("function" != typeof e)
    throw new TypeError("argument is not a function. Are you looking for `mapTo()`?"); return r.lift(new MapOperator(e, t)); }; }
var MapOperator = function () { function e(e, t) { this.project = e, this.thisArg = t; } return e.prototype.call = function (e, t) { return t.subscribe(new MapSubscriber(e, this.project, this.thisArg)); }, e; }(), MapSubscriber = function (e) { function t(t, r, n) { var i = e.call(this, t) || this; return i.project = r, i.count = 0, i.thisArg = n || i, i; } return __extends(t, e), t.prototype._next = function (e) { var t; try {
    t = this.project.call(this.thisArg, e, this.count++);
}
catch (e) {
    return void this.destination.error(e);
} this.destination.next(t); }, t; }(Subscriber), OuterSubscriber = function (e) { function t() { return null !== e && e.apply(this, arguments) || this; } return __extends(t, e), t.prototype.notifyNext = function (e, t, r, n, i) { this.destination.next(t); }, t.prototype.notifyError = function (e, t) { this.destination.error(e); }, t.prototype.notifyComplete = function (e) { this.destination.complete(); }, t; }(Subscriber), InnerSubscriber = function (e) { function t(t, r, n) { var i = e.call(this) || this; return i.parent = t, i.outerValue = r, i.outerIndex = n, i.index = 0, i; } return __extends(t, e), t.prototype._next = function (e) { this.parent.notifyNext(this.outerValue, e, this.outerIndex, this.index++, this); }, t.prototype._error = function (e) { this.parent.notifyError(e, this), this.unsubscribe(); }, t.prototype._complete = function () { this.parent.notifyComplete(this), this.unsubscribe(); }, t; }(Subscriber), subscribeToPromise = function (e) { return function (t) { return e.then(function (e) { t.closed || (t.next(e), t.complete()); }, function (e) { return t.error(e); }).then(null, hostReportError), t; }; };
function getSymbolIterator() { return "function" == typeof Symbol && Symbol.iterator ? Symbol.iterator : "@@iterator"; }
var iterator = getSymbolIterator(), subscribeToIterable = function (e) { return function (t) { for (var r = e[iterator]();;) {
    var n = r.next();
    if (n.done) {
        t.complete();
        break;
    }
    if (t.next(n.value), t.closed)
        break;
} return "function" == typeof r.return && t.add(function () { r.return && r.return(); }), t; }; }, subscribeToObservable = function (e) { return function (t) { var r = e[observable](); if ("function" != typeof r.subscribe)
    throw new TypeError("Provided object does not correctly implement Symbol.observable"); return r.subscribe(t); }; }, isArrayLike = function (e) { return e && "number" == typeof e.length && "function" != typeof e; };
function isPromise(e) { return e && "function" != typeof e.subscribe && "function" == typeof e.then; }
var subscribeTo = function (e) { if (e instanceof Observable)
    return function (t) { return e._isScalar ? (t.next(e.value), void t.complete()) : e.subscribe(t); }; if (e && "function" == typeof e[observable])
    return subscribeToObservable(e); if (isArrayLike(e))
    return subscribeToArray(e); if (isPromise(e))
    return subscribeToPromise(e); if (e && "function" == typeof e[iterator])
    return subscribeToIterable(e); var t = isObject(e) ? "an invalid object" : "'" + e + "'"; throw new TypeError("You provided " + t + " where a stream was expected. You can provide an Observable, Promise, Array, or Iterable."); };
function subscribeToResult(e, t, r, n) { var i = new InnerSubscriber(e, r, n); return subscribeTo(t)(i); }
var NONE = {}, CombineLatestSubscriber = function (e) { function t(t, r) { var n = e.call(this, t) || this; return n.resultSelector = r, n.active = 0, n.values = [], n.observables = [], n; } return __extends(t, e), t.prototype._next = function (e) { this.values.push(NONE), this.observables.push(e); }, t.prototype._complete = function () { var e = this.observables, t = e.length; if (0 === t)
    this.destination.complete();
else {
    this.active = t, this.toRespond = t;
    for (var r = 0; r < t; r++) {
        var n = e[r];
        this.add(subscribeToResult(this, n, n, r));
    }
} }, t.prototype.notifyComplete = function (e) { 0 == (this.active -= 1) && this.destination.complete(); }, t.prototype.notifyNext = function (e, t, r, n, i) { var s = this.values, o = s[r], u = this.toRespond ? o === NONE ? --this.toRespond : this.toRespond : 0; s[r] = t, 0 === u && (this.resultSelector ? this._tryResultSelector(s) : this.destination.next(s.slice())); }, t.prototype._tryResultSelector = function (e) { var t; try {
    t = this.resultSelector.apply(this, e);
}
catch (e) {
    return void this.destination.error(e);
} this.destination.next(t); }, t; }(OuterSubscriber);
function isInteropObservable(e) { return e && "function" == typeof e[observable]; }
function isIterable(e) { return e && "function" == typeof e[iterator]; }
function fromPromise(e, t) { return new Observable(t ? function (r) { var n = new Subscription; return n.add(t.schedule(function () { return e.then(function (e) { n.add(t.schedule(function () { r.next(e), n.add(t.schedule(function () { return r.complete(); })); })); }, function (e) { n.add(t.schedule(function () { return r.error(e); })); }); })), n; } : subscribeToPromise(e)); }
function fromIterable(e, t) { if (!e)
    throw new Error("Iterable cannot be null"); return new Observable(t ? function (r) { var n, i = new Subscription; return i.add(function () { n && "function" == typeof n.return && n.return(); }), i.add(t.schedule(function () { n = e[iterator](), i.add(t.schedule(function () { if (!r.closed) {
    var e, t;
    try {
        var i = n.next();
        e = i.value, t = i.done;
    }
    catch (e) {
        return void r.error(e);
    }
    t ? r.complete() : (r.next(e), this.schedule());
} })); })), i; } : subscribeToIterable(e)); }
function fromObservable(e, t) { return new Observable(t ? function (r) { var n = new Subscription; return n.add(t.schedule(function () { var i = e[observable](); n.add(i.subscribe({ next: function (e) { n.add(t.schedule(function () { return r.next(e); })); }, error: function (e) { n.add(t.schedule(function () { return r.error(e); })); }, complete: function () { n.add(t.schedule(function () { return r.complete(); })); } })); })), n; } : subscribeToObservable(e)); }
function from(e, t) { if (!t)
    return e instanceof Observable ? e : new Observable(subscribeTo(e)); if (null != e) {
    if (isInteropObservable(e))
        return fromObservable(e, t);
    if (isPromise(e))
        return fromPromise(e, t);
    if (isArrayLike(e))
        return fromArray(e, t);
    if (isIterable(e) || "string" == typeof e)
        return fromIterable(e, t);
} throw new TypeError((null !== e && typeof e || e) + " is not observable"); }
function mergeMap(e, t, r) { return void 0 === r && (r = Number.POSITIVE_INFINITY), "function" == typeof t ? function (n) { return n.pipe(mergeMap(function (r, n) { return from(e(r, n)).pipe(map(function (e, i) { return t(r, e, n, i); })); }, r)); } : ("number" == typeof t && (r = t), function (t) { return t.lift(new MergeMapOperator(e, r)); }); }
var MergeMapOperator = function () { function e(e, t) { void 0 === t && (t = Number.POSITIVE_INFINITY), this.project = e, this.concurrent = t; } return e.prototype.call = function (e, t) { return t.subscribe(new MergeMapSubscriber(e, this.project, this.concurrent)); }, e; }(), MergeMapSubscriber = function (e) { function t(t, r, n) { void 0 === n && (n = Number.POSITIVE_INFINITY); var i = e.call(this, t) || this; return i.project = r, i.concurrent = n, i.hasCompleted = !1, i.buffer = [], i.active = 0, i.index = 0, i; } return __extends(t, e), t.prototype._next = function (e) { this.active < this.concurrent ? this._tryNext(e) : this.buffer.push(e); }, t.prototype._tryNext = function (e) { var t, r = this.index++; try {
    t = this.project(e, r);
}
catch (e) {
    return void this.destination.error(e);
} this.active++, this._innerSub(t, e, r); }, t.prototype._innerSub = function (e, t, r) { this.add(subscribeToResult(this, e, t, r)); }, t.prototype._complete = function () { this.hasCompleted = !0, 0 === this.active && 0 === this.buffer.length && this.destination.complete(); }, t.prototype.notifyNext = function (e, t, r, n, i) { this.destination.next(t); }, t.prototype.notifyComplete = function (e) { var t = this.buffer; this.remove(e), this.active--, t.length > 0 ? this._next(t.shift()) : 0 === this.active && this.hasCompleted && this.destination.complete(); }, t; }(OuterSubscriber);
function mergeAll(e) { return void 0 === e && (e = Number.POSITIVE_INFINITY), mergeMap(identity, e); }
function concatAll() { return mergeAll(1); }
function concat() { for (var e = [], t = 0; t < arguments.length; t++)
    e[t] = arguments[t]; return 1 === e.length || 2 === e.length && isScheduler(e[1]) ? from(e[0]) : concatAll()(of.apply(void 0, e)); }
var ForkJoinSubscriber = function (e) { function t(t, r) { var n = e.call(this, t) || this; n.sources = r, n.completed = 0, n.haveValues = 0; var i = r.length; n.values = new Array(i); for (var s = 0; s < i; s++) {
    var o = subscribeToResult(n, r[s], null, s);
    o && n.add(o);
} return n; } return __extends(t, e), t.prototype.notifyNext = function (e, t, r, n, i) { this.values[r] = t, i._hasValue || (i._hasValue = !0, this.haveValues++); }, t.prototype.notifyComplete = function (e) { var t = this.destination, r = this.haveValues, n = this.values, i = n.length; e._hasValue ? (this.completed++, this.completed === i && (r === i && t.next(n), t.complete())) : t.complete(); }, t; }(OuterSubscriber);
function isNumeric(e) { return !isArray(e) && e - parseFloat(e) + 1 >= 0; }
function interval(e, t) { return void 0 === e && (e = 0), void 0 === t && (t = async), (!isNumeric(e) || e < 0) && (e = 0), t && "function" == typeof t.schedule || (t = async), new Observable(function (r) { return r.add(t.schedule(dispatch$4, e, { subscriber: r, counter: 0, period: e })), r; }); }
function dispatch$4(e) { var t = e.subscriber, r = e.counter, n = e.period; t.next(r), this.schedule({ subscriber: t, counter: r + 1, period: n }, n); }
var RaceSubscriber = function (e) { function t(t) { var r = e.call(this, t) || this; return r.hasFirst = !1, r.observables = [], r.subscriptions = [], r; } return __extends(t, e), t.prototype._next = function (e) { this.observables.push(e); }, t.prototype._complete = function () { var e = this.observables, t = e.length; if (0 === t)
    this.destination.complete();
else {
    for (var r = 0; r < t && !this.hasFirst; r++) {
        var n = e[r], i = subscribeToResult(this, n, n, r);
        this.subscriptions && this.subscriptions.push(i), this.add(i);
    }
    this.observables = null;
} }, t.prototype.notifyNext = function (e, t, r, n, i) { if (!this.hasFirst) {
    this.hasFirst = !0;
    for (var s = 0; s < this.subscriptions.length; s++)
        if (s !== r) {
            var o = this.subscriptions[s];
            o.unsubscribe(), this.remove(o);
        }
    this.subscriptions = null;
} this.destination.next(t); }, t; }(OuterSubscriber), ZipSubscriber = function (e) { function t(t, r, n) { void 0 === n && (n = Object.create(null)); var i = e.call(this, t) || this; return i.iterators = [], i.active = 0, i.resultSelector = "function" == typeof r ? r : null, i.values = n, i; } return __extends(t, e), t.prototype._next = function (e) { var t = this.iterators; isArray(e) ? t.push(new StaticArrayIterator(e)) : "function" == typeof e[iterator] ? t.push(new StaticIterator(e[iterator]())) : t.push(new ZipBufferIterator(this.destination, this, e)); }, t.prototype._complete = function () { var e = this.iterators, t = e.length; if (0 !== t) {
    this.active = t;
    for (var r = 0; r < t; r++) {
        var n = e[r];
        n.stillUnsubscribed ? this.add(n.subscribe(n, r)) : this.active--;
    }
}
else
    this.destination.complete(); }, t.prototype.notifyInactive = function () { this.active--, 0 === this.active && this.destination.complete(); }, t.prototype.checkIterators = function () { for (var e = this.iterators, t = e.length, r = this.destination, n = 0; n < t; n++)
    if ("function" == typeof (o = e[n]).hasValue && !o.hasValue())
        return; var i = !1, s = []; for (n = 0; n < t; n++) {
    var o, u = (o = e[n]).next();
    if (o.hasCompleted() && (i = !0), u.done)
        return void r.complete();
    s.push(u.value);
} this.resultSelector ? this._tryresultSelector(s) : r.next(s), i && r.complete(); }, t.prototype._tryresultSelector = function (e) { var t; try {
    t = this.resultSelector.apply(this, e);
}
catch (e) {
    return void this.destination.error(e);
} this.destination.next(t); }, t; }(Subscriber), StaticIterator = function () { function e(e) { this.iterator = e, this.nextResult = e.next(); } return e.prototype.hasValue = function () { return !0; }, e.prototype.next = function () { var e = this.nextResult; return this.nextResult = this.iterator.next(), e; }, e.prototype.hasCompleted = function () { var e = this.nextResult; return e && e.done; }, e; }(), StaticArrayIterator = function () { function e(e) { this.array = e, this.index = 0, this.length = 0, this.length = e.length; } return e.prototype[iterator] = function () { return this; }, e.prototype.next = function (e) { var t = this.index++, r = this.array; return t < this.length ? { value: r[t], done: !1 } : { value: null, done: !0 }; }, e.prototype.hasValue = function () { return this.array.length > this.index; }, e.prototype.hasCompleted = function () { return this.array.length === this.index; }, e; }(), ZipBufferIterator = function (e) { function t(t, r, n) { var i = e.call(this, t) || this; return i.parent = r, i.observable = n, i.stillUnsubscribed = !0, i.buffer = [], i.isComplete = !1, i; } return __extends(t, e), t.prototype[iterator] = function () { return this; }, t.prototype.next = function () { var e = this.buffer; return 0 === e.length && this.isComplete ? { value: null, done: !0 } : { value: e.shift(), done: !1 }; }, t.prototype.hasValue = function () { return this.buffer.length > 0; }, t.prototype.hasCompleted = function () { return 0 === this.buffer.length && this.isComplete; }, t.prototype.notifyComplete = function () { this.buffer.length > 0 ? (this.isComplete = !0, this.parent.notifyInactive()) : this.destination.complete(); }, t.prototype.notifyNext = function (e, t, r, n, i) { this.buffer.push(t), this.parent.checkIterators(); }, t.prototype.subscribe = function (e, t) { return subscribeToResult(this, this.observable, this, t); }, t; }(OuterSubscriber);
var singleton$3 = Symbol(), singletonEnforcer$3 = Symbol();
var HttpService = /** @class */ (function () {
    function HttpService(e) {
        if (this.optionDefaults = { cache: "no-cache", credentials: "same-origin", headers: {}, mode: "same-origin", method: "GET" }, e !== singletonEnforcer$3)
            throw new Error("Cannot construct singleton");
        this._type = "HttpService";
    }
    HttpService.prototype.get = function (e, t) {
        if (t === void 0) { t = this.optionDefaults; }
        return Observable.create(function (r) { fetch(e, t).then(function (e) { return e.json(); }).then(function (e) { r.next(e), r.complete(); }).catch(function (e) { console.error("http.get error:", e), r.error(e); }); });
    };
    HttpService.prototype.put = function (e, t, r) { };
    HttpService.prototype.post = function (e, t, r) { };
    HttpService.prototype.delete = function (e, t, r) { };
    Object.defineProperty(HttpService, "instance", {
        get: function () { return this[singleton$3] || (this[singleton$3] = new HttpService(singletonEnforcer$3)), this[singleton$3]; },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(HttpService.prototype, "type", {
        get: function () { return this._type; },
        set: function (e) { this._type = e; },
        enumerable: true,
        configurable: true
    });
    return HttpService;
}());
export { __extends as a, tryCatch as b, errorObject as c, OuterSubscriber as d, subscribeToResult as e, async as f, Subscriber as g, isScheduler as h, Subscription as i, isArray as j, from as k, concat as l, mergeMap as m, Notification as n, Observable as o, noop as p, isFunction as q, EmptyError as r, ArgumentOutOfRangeError as s, empty$1 as t, fromArray as u, scalar as v, map as w, identity as x, Subject as y, BehaviorSubject as z, AsyncSubject as A, ReplaySubject as B, refCount as C, asap as D, isNumeric as E, TimeoutError as F, throwError as G, User$$1 as H, BaseService as I, DomUtil as J, interval as K, HttpService as L, concatAll as M, TranslateService as N, Wordpress as O, StringUtil as P, Css as Q, PermissionsService as R };
