(function (global, factory) {
    typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular-ru/cdk/array'), require('@angular-ru/cdk/string'), require('@angular-ru/cdk/utils')) :
    typeof define === 'function' && define.amd ? define('@angular-ru/cdk/stream/jwt', ['exports', '@angular-ru/cdk/array', '@angular-ru/cdk/string', '@angular-ru/cdk/utils'], factory) :
    (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global["angular-ru"] = global["angular-ru"] || {}, global["angular-ru"].cdk = global["angular-ru"].cdk || {}, global["angular-ru"].cdk.stream = global["angular-ru"].cdk.stream || {}, global["angular-ru"].cdk.stream.jwt = {}), global["angular-ru"].cdk.array, global["angular-ru"].cdk.string, global["angular-ru"].cdk.utils));
})(this, (function (exports, array, string, utils) { 'use strict';

    function decodeJwt(token) {
        var _a, _b;
        var result = null;
        if (string.isString(token)) {
            var base64Url = (_a = array.takeSecondItem(token === null || token === void 0 ? void 0 : token.split('.'))) !== null && _a !== void 0 ? _a : '';
            var base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
            var decodedStringValue = decodeURIComponent(escape(window.atob(base64)));
            result = (_b = utils.tryParseJson(decodedStringValue)) !== null && _b !== void 0 ? _b : null;
        }
        return result;
    }

    function toBase64(pojo) {
        return window.btoa(unescape(encodeURIComponent(JSON.stringify(pojo))));
    }

    /**
     * Generated bundle index. Do not edit.
     */

    exports.decodeJwt = decodeJwt;
    exports.toBase64 = toBase64;

    Object.defineProperty(exports, '__esModule', { value: true });

}));
//# sourceMappingURL=angular-ru-stream-jwt.umd.js.map
