Plugin Directory

Changeset 2778375


Ignore:
Timestamp:
08/31/2022 04:05:10 PM (4 years ago)
Author:
bahson
Message:

included missing updated dist folder items

Location:
flair-chat/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • flair-chat/trunk/dist/chat_nv.bundle.js

    r2777697 r2778375  
    1 (function(){var __webpack_modules__={606:function(module){eval("/*!\n * Pusher JavaScript Library v7.4.0\n * https://pusher.com/\n *\n * Copyright 2020, Pusher\n * Released under the MIT licence.\n */\n\n(function webpackUniversalModuleDefinition(root, factory) {\n\tif(true)\n\t\tmodule.exports = factory();\n\telse {}\n})(window, function() {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __nested_webpack_require_669__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId]) {\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/ \t\t}\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __nested_webpack_require_669__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__nested_webpack_require_669__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__nested_webpack_require_669__.c = installedModules;\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__nested_webpack_require_669__.d = function(exports, name, getter) {\n/******/ \t\tif(!__nested_webpack_require_669__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// define __esModule on exports\n/******/ \t__nested_webpack_require_669__.r = function(exports) {\n/******/ \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n/******/ \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n/******/ \t\t}\n/******/ \t\tObject.defineProperty(exports, '__esModule', { value: true });\n/******/ \t};\n/******/\n/******/ \t// create a fake namespace object\n/******/ \t// mode & 1: value is a module id, require it\n/******/ \t// mode & 2: merge all properties of value into the ns\n/******/ \t// mode & 4: return value when already ns object\n/******/ \t// mode & 8|1: behave like require\n/******/ \t__nested_webpack_require_669__.t = function(value, mode) {\n/******/ \t\tif(mode & 1) value = __nested_webpack_require_669__(value);\n/******/ \t\tif(mode & 8) return value;\n/******/ \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n/******/ \t\tvar ns = Object.create(null);\n/******/ \t\t__nested_webpack_require_669__.r(ns);\n/******/ \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n/******/ \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __nested_webpack_require_669__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n/******/ \t\treturn ns;\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__nested_webpack_require_669__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__nested_webpack_require_669__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__nested_webpack_require_669__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__nested_webpack_require_669__.p = \"\";\n/******/\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __nested_webpack_require_669__(__nested_webpack_require_669__.s = 2);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\nvar __extends = (this && this.__extends) || (function () {\n    var extendStatics = function (d, b) {\n        extendStatics = Object.setPrototypeOf ||\n            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n        return extendStatics(d, b);\n    };\n    return function (d, b) {\n        extendStatics(d, b);\n        function __() { this.constructor = d; }\n        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n    };\n})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nvar INVALID_BYTE = 256;\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nvar Coder = /** @class */ (function () {\n    // TODO(dchest): methods to encode chunk-by-chunk.\n    function Coder(_paddingCharacter) {\n        if (_paddingCharacter === void 0) { _paddingCharacter = \"=\"; }\n        this._paddingCharacter = _paddingCharacter;\n    }\n    Coder.prototype.encodedLength = function (length) {\n        if (!this._paddingCharacter) {\n            return (length * 8 + 5) / 6 | 0;\n        }\n        return (length + 2) / 3 * 4 | 0;\n    };\n    Coder.prototype.encode = function (data) {\n        var out = \"\";\n        var i = 0;\n        for (; i < data.length - 2; i += 3) {\n            var c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n            out += this._encodeByte((c >>> 3 * 6) & 63);\n            out += this._encodeByte((c >>> 2 * 6) & 63);\n            out += this._encodeByte((c >>> 1 * 6) & 63);\n            out += this._encodeByte((c >>> 0 * 6) & 63);\n        }\n        var left = data.length - i;\n        if (left > 0) {\n            var c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n            out += this._encodeByte((c >>> 3 * 6) & 63);\n            out += this._encodeByte((c >>> 2 * 6) & 63);\n            if (left === 2) {\n                out += this._encodeByte((c >>> 1 * 6) & 63);\n            }\n            else {\n                out += this._paddingCharacter || \"\";\n            }\n            out += this._paddingCharacter || \"\";\n        }\n        return out;\n    };\n    Coder.prototype.maxDecodedLength = function (length) {\n        if (!this._paddingCharacter) {\n            return (length * 6 + 7) / 8 | 0;\n        }\n        return length / 4 * 3 | 0;\n    };\n    Coder.prototype.decodedLength = function (s) {\n        return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n    };\n    Coder.prototype.decode = function (s) {\n        if (s.length === 0) {\n            return new Uint8Array(0);\n        }\n        var paddingLength = this._getPaddingLength(s);\n        var length = s.length - paddingLength;\n        var out = new Uint8Array(this.maxDecodedLength(length));\n        var op = 0;\n        var i = 0;\n        var haveBad = 0;\n        var v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n        for (; i < length - 4; i += 4) {\n            v0 = this._decodeChar(s.charCodeAt(i + 0));\n            v1 = this._decodeChar(s.charCodeAt(i + 1));\n            v2 = this._decodeChar(s.charCodeAt(i + 2));\n            v3 = this._decodeChar(s.charCodeAt(i + 3));\n            out[op++] = (v0 << 2) | (v1 >>> 4);\n            out[op++] = (v1 << 4) | (v2 >>> 2);\n            out[op++] = (v2 << 6) | v3;\n            haveBad |= v0 & INVALID_BYTE;\n            haveBad |= v1 & INVALID_BYTE;\n            haveBad |= v2 & INVALID_BYTE;\n            haveBad |= v3 & INVALID_BYTE;\n        }\n        if (i < length - 1) {\n            v0 = this._decodeChar(s.charCodeAt(i));\n            v1 = this._decodeChar(s.charCodeAt(i + 1));\n            out[op++] = (v0 << 2) | (v1 >>> 4);\n            haveBad |= v0 & INVALID_BYTE;\n            haveBad |= v1 & INVALID_BYTE;\n        }\n        if (i < length - 2) {\n            v2 = this._decodeChar(s.charCodeAt(i + 2));\n            out[op++] = (v1 << 4) | (v2 >>> 2);\n            haveBad |= v2 & INVALID_BYTE;\n        }\n        if (i < length - 3) {\n            v3 = this._decodeChar(s.charCodeAt(i + 3));\n            out[op++] = (v2 << 6) | v3;\n            haveBad |= v3 & INVALID_BYTE;\n        }\n        if (haveBad !== 0) {\n            throw new Error(\"Base64Coder: incorrect characters for decoding\");\n        }\n        return out;\n    };\n    // Standard encoding have the following encoded/decoded ranges,\n    // which we need to convert between.\n    //\n    // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789  +   /\n    // Index:   0 - 25                    26 - 51              52 - 61   62  63\n    // ASCII:  65 - 90                    97 - 122             48 - 57   43  47\n    //\n    // Encode 6 bits in b into a new character.\n    Coder.prototype._encodeByte = function (b) {\n        // Encoding uses constant time operations as follows:\n        //\n        // 1. Define comparison of A with B using (A - B) >>> 8:\n        //          if A > B, then result is positive integer\n        //          if A <= B, then result is 0\n        //\n        // 2. Define selection of C or 0 using bitwise AND: X & C:\n        //          if X == 0, then result is 0\n        //          if X != 0, then result is C\n        //\n        // 3. Start with the smallest comparison (b >= 0), which is always\n        //    true, so set the result to the starting ASCII value (65).\n        //\n        // 4. Continue comparing b to higher ASCII values, and selecting\n        //    zero if comparison isn't true, otherwise selecting a value\n        //    to add to result, which:\n        //\n        //          a) undoes the previous addition\n        //          b) provides new value to add\n        //\n        var result = b;\n        // b >= 0\n        result += 65;\n        // b > 25\n        result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n        // b > 51\n        result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n        // b > 61\n        result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n        // b > 62\n        result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n        return String.fromCharCode(result);\n    };\n    // Decode a character code into a byte.\n    // Must return 256 if character is out of alphabet range.\n    Coder.prototype._decodeChar = function (c) {\n        // Decoding works similar to encoding: using the same comparison\n        // function, but now it works on ranges: result is always incremented\n        // by value, but this value becomes zero if the range is not\n        // satisfied.\n        //\n        // Decoding starts with invalid value, 256, which is then\n        // subtracted when the range is satisfied. If none of the ranges\n        // apply, the function returns 256, which is then checked by\n        // the caller to throw error.\n        var result = INVALID_BYTE; // start with invalid character\n        // c == 43 (c > 42 and c < 44)\n        result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n        // c == 47 (c > 46 and c < 48)\n        result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n        // c > 47 and c < 58\n        result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n        // c > 64 and c < 91\n        result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n        // c > 96 and c < 123\n        result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n        return result;\n    };\n    Coder.prototype._getPaddingLength = function (s) {\n        var paddingLength = 0;\n        if (this._paddingCharacter) {\n            for (var i = s.length - 1; i >= 0; i--) {\n                if (s[i] !== this._paddingCharacter) {\n                    break;\n                }\n                paddingLength++;\n            }\n            if (s.length < 4 || paddingLength > 2) {\n                throw new Error(\"Base64Coder: incorrect padding\");\n            }\n        }\n        return paddingLength;\n    };\n    return Coder;\n}());\nexports.Coder = Coder;\nvar stdCoder = new Coder();\nfunction encode(data) {\n    return stdCoder.encode(data);\n}\nexports.encode = encode;\nfunction decode(s) {\n    return stdCoder.decode(s);\n}\nexports.decode = decode;\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nvar URLSafeCoder = /** @class */ (function (_super) {\n    __extends(URLSafeCoder, _super);\n    function URLSafeCoder() {\n        return _super !== null && _super.apply(this, arguments) || this;\n    }\n    // URL-safe encoding have the following encoded/decoded ranges:\n    //\n    // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789  -   _\n    // Index:   0 - 25                    26 - 51              52 - 61   62  63\n    // ASCII:  65 - 90                    97 - 122             48 - 57   45  95\n    //\n    URLSafeCoder.prototype._encodeByte = function (b) {\n        var result = b;\n        // b >= 0\n        result += 65;\n        // b > 25\n        result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n        // b > 51\n        result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n        // b > 61\n        result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n        // b > 62\n        result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n        return String.fromCharCode(result);\n    };\n    URLSafeCoder.prototype._decodeChar = function (c) {\n        var result = INVALID_BYTE;\n        // c == 45 (c > 44 and c < 46)\n        result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n        // c == 95 (c > 94 and c < 96)\n        result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n        // c > 47 and c < 58\n        result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n        // c > 64 and c < 91\n        result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n        // c > 96 and c < 123\n        result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n        return result;\n    };\n    return URLSafeCoder;\n}(Coder));\nexports.URLSafeCoder = URLSafeCoder;\nvar urlSafeCoder = new URLSafeCoder();\nfunction encodeURLSafe(data) {\n    return urlSafeCoder.encode(data);\n}\nexports.encodeURLSafe = encodeURLSafe;\nfunction decodeURLSafe(s) {\n    return urlSafeCoder.decode(s);\n}\nexports.decodeURLSafe = decodeURLSafe;\nexports.encodedLength = function (length) {\n    return stdCoder.encodedLength(length);\n};\nexports.maxDecodedLength = function (length) {\n    return stdCoder.maxDecodedLength(length);\n};\nexports.decodedLength = function (s) {\n    return stdCoder.decodedLength(s);\n};\n\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\nvar INVALID_UTF16 = \"utf8: invalid string\";\nvar INVALID_UTF8 = \"utf8: invalid source encoding\";\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nfunction encode(s) {\n    // Calculate result length and allocate output array.\n    // encodedLength() also validates string and throws errors,\n    // so we don't need repeat validation here.\n    var arr = new Uint8Array(encodedLength(s));\n    var pos = 0;\n    for (var i = 0; i < s.length; i++) {\n        var c = s.charCodeAt(i);\n        if (c < 0x80) {\n            arr[pos++] = c;\n        }\n        else if (c < 0x800) {\n            arr[pos++] = 0xc0 | c >> 6;\n            arr[pos++] = 0x80 | c & 0x3f;\n        }\n        else if (c < 0xd800) {\n            arr[pos++] = 0xe0 | c >> 12;\n            arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n            arr[pos++] = 0x80 | c & 0x3f;\n        }\n        else {\n            i++; // get one more character\n            c = (c & 0x3ff) << 10;\n            c |= s.charCodeAt(i) & 0x3ff;\n            c += 0x10000;\n            arr[pos++] = 0xf0 | c >> 18;\n            arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n            arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n            arr[pos++] = 0x80 | c & 0x3f;\n        }\n    }\n    return arr;\n}\nexports.encode = encode;\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nfunction encodedLength(s) {\n    var result = 0;\n    for (var i = 0; i < s.length; i++) {\n        var c = s.charCodeAt(i);\n        if (c < 0x80) {\n            result += 1;\n        }\n        else if (c < 0x800) {\n            result += 2;\n        }\n        else if (c < 0xd800) {\n            result += 3;\n        }\n        else if (c <= 0xdfff) {\n            if (i >= s.length - 1) {\n                throw new Error(INVALID_UTF16);\n            }\n            i++; // \"eat\" next character\n            result += 4;\n        }\n        else {\n            throw new Error(INVALID_UTF16);\n        }\n    }\n    return result;\n}\nexports.encodedLength = encodedLength;\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nfunction decode(arr) {\n    var chars = [];\n    for (var i = 0; i < arr.length; i++) {\n        var b = arr[i];\n        if (b & 0x80) {\n            var min = void 0;\n            if (b < 0xe0) {\n                // Need 1 more byte.\n                if (i >= arr.length) {\n                    throw new Error(INVALID_UTF8);\n                }\n                var n1 = arr[++i];\n                if ((n1 & 0xc0) !== 0x80) {\n                    throw new Error(INVALID_UTF8);\n                }\n                b = (b & 0x1f) << 6 | (n1 & 0x3f);\n                min = 0x80;\n            }\n            else if (b < 0xf0) {\n                // Need 2 more bytes.\n                if (i >= arr.length - 1) {\n                    throw new Error(INVALID_UTF8);\n                }\n                var n1 = arr[++i];\n                var n2 = arr[++i];\n                if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n                    throw new Error(INVALID_UTF8);\n                }\n                b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n                min = 0x800;\n            }\n            else if (b < 0xf8) {\n                // Need 3 more bytes.\n                if (i >= arr.length - 2) {\n                    throw new Error(INVALID_UTF8);\n                }\n                var n1 = arr[++i];\n                var n2 = arr[++i];\n                var n3 = arr[++i];\n                if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n                    throw new Error(INVALID_UTF8);\n                }\n                b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n                min = 0x10000;\n            }\n            else {\n                throw new Error(INVALID_UTF8);\n            }\n            if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n                throw new Error(INVALID_UTF8);\n            }\n            if (b >= 0x10000) {\n                // Surrogate pair.\n                if (b > 0x10ffff) {\n                    throw new Error(INVALID_UTF8);\n                }\n                b -= 0x10000;\n                chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n                b = 0xdc00 | (b & 0x3ff);\n            }\n        }\n        chars.push(String.fromCharCode(b));\n    }\n    return chars.join(\"\");\n}\nexports.decode = decode;\n\n\n/***/ }),\n/* 2 */\n/***/ (function(module, exports, __nested_webpack_require_19901__) {\n\n// required so we don't have to do require('pusher').default etc.\nmodule.exports = __nested_webpack_require_19901__(3).default;\n\n\n/***/ }),\n/* 3 */\n/***/ (function(module, __webpack_exports__, __nested_webpack_require_20105__) {\n\n\"use strict\";\n// ESM COMPAT FLAG\n__nested_webpack_require_20105__.r(__webpack_exports__);\n\n// CONCATENATED MODULE: ./src/runtimes/web/dom/script_receiver_factory.ts\nvar ScriptReceiverFactory = (function () {\n    function ScriptReceiverFactory(prefix, name) {\n        this.lastId = 0;\n        this.prefix = prefix;\n        this.name = name;\n    }\n    ScriptReceiverFactory.prototype.create = function (callback) {\n        this.lastId++;\n        var number = this.lastId;\n        var id = this.prefix + number;\n        var name = this.name + '[' + number + ']';\n        var called = false;\n        var callbackWrapper = function () {\n            if (!called) {\n                callback.apply(null, arguments);\n                called = true;\n            }\n        };\n        this[number] = callbackWrapper;\n        return { number: number, id: id, name: name, callback: callbackWrapper };\n    };\n    ScriptReceiverFactory.prototype.remove = function (receiver) {\n        delete this[receiver.number];\n    };\n    return ScriptReceiverFactory;\n}());\n\nvar ScriptReceivers = new ScriptReceiverFactory('_pusher_script_', 'Pusher.ScriptReceivers');\n\n// CONCATENATED MODULE: ./src/core/defaults.ts\nvar Defaults = {\n    VERSION: \"7.4.0\",\n    PROTOCOL: 7,\n    wsPort: 80,\n    wssPort: 443,\n    wsPath: '',\n    httpHost: 'sockjs.pusher.com',\n    httpPort: 80,\n    httpsPort: 443,\n    httpPath: '/pusher',\n    stats_host: 'stats.pusher.com',\n    authEndpoint: '/pusher/auth',\n    authTransport: 'ajax',\n    activityTimeout: 120000,\n    pongTimeout: 30000,\n    unavailableTimeout: 10000,\n    cluster: 'mt1',\n    userAuthentication: {\n        endpoint: '/pusher/user-auth',\n        transport: 'ajax'\n    },\n    channelAuthorization: {\n        endpoint: '/pusher/auth',\n        transport: 'ajax'\n    },\n    cdn_http: \"http://js.pusher.com\",\n    cdn_https: \"https://js.pusher.com\",\n    dependency_suffix: \"\"\n};\n/* harmony default export */ var defaults = (Defaults);\n\n// CONCATENATED MODULE: ./src/runtimes/web/dom/dependency_loader.ts\n\n\nvar dependency_loader_DependencyLoader = (function () {\n    function DependencyLoader(options) {\n        this.options = options;\n        this.receivers = options.receivers || ScriptReceivers;\n        this.loading = {};\n    }\n    DependencyLoader.prototype.load = function (name, options, callback) {\n        var self = this;\n        if (self.loading[name] && self.loading[name].length > 0) {\n            self.loading[name].push(callback);\n        }\n        else {\n            self.loading[name] = [callback];\n            var request = runtime.createScriptRequest(self.getPath(name, options));\n            var receiver = self.receivers.create(function (error) {\n                self.receivers.remove(receiver);\n                if (self.loading[name]) {\n                    var callbacks = self.loading[name];\n                    delete self.loading[name];\n                    var successCallback = function (wasSuccessful) {\n                        if (!wasSuccessful) {\n                            request.cleanup();\n                        }\n                    };\n                    for (var i = 0; i < callbacks.length; i++) {\n                        callbacks[i](error, successCallback);\n                    }\n                }\n            });\n            request.send(receiver);\n        }\n    };\n    DependencyLoader.prototype.getRoot = function (options) {\n        var cdn;\n        var protocol = runtime.getDocument().location.protocol;\n        if ((options && options.useTLS) || protocol === 'https:') {\n            cdn = this.options.cdn_https;\n        }\n        else {\n            cdn = this.options.cdn_http;\n        }\n        return cdn.replace(/\\/*$/, '') + '/' + this.options.version;\n    };\n    DependencyLoader.prototype.getPath = function (name, options) {\n        return this.getRoot(options) + '/' + name + this.options.suffix + '.js';\n    };\n    return DependencyLoader;\n}());\n/* harmony default export */ var dependency_loader = (dependency_loader_DependencyLoader);\n\n// CONCATENATED MODULE: ./src/runtimes/web/dom/dependencies.ts\n\n\n\nvar DependenciesReceivers = new ScriptReceiverFactory('_pusher_dependencies', 'Pusher.DependenciesReceivers');\nvar Dependencies = new dependency_loader({\n    cdn_http: defaults.cdn_http,\n    cdn_https: defaults.cdn_https,\n    version: defaults.VERSION,\n    suffix: defaults.dependency_suffix,\n    receivers: DependenciesReceivers\n});\n\n// CONCATENATED MODULE: ./src/core/utils/url_store.ts\nvar urlStore = {\n    baseUrl: 'https://pusher.com',\n    urls: {\n        authenticationEndpoint: {\n            path: '/docs/channels/server_api/authenticating_users'\n        },\n        authorizationEndpoint: {\n            path: '/docs/channels/server_api/authorizing-users/'\n        },\n        javascriptQuickStart: {\n            path: '/docs/javascript_quick_start'\n        },\n        triggeringClientEvents: {\n            path: '/docs/client_api_guide/client_events#trigger-events'\n        },\n        encryptedChannelSupport: {\n            fullUrl: 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n        }\n    }\n};\nvar buildLogSuffix = function (key) {\n    var urlPrefix = 'See:';\n    var urlObj = urlStore.urls[key];\n    if (!urlObj)\n        return '';\n    var url;\n    if (urlObj.fullUrl) {\n        url = urlObj.fullUrl;\n    }\n    else if (urlObj.path) {\n        url = urlStore.baseUrl + urlObj.path;\n    }\n    if (!url)\n        return '';\n    return urlPrefix + \" \" + url;\n};\n/* harmony default export */ var url_store = ({ buildLogSuffix: buildLogSuffix });\n\n// CONCATENATED MODULE: ./src/core/auth/options.ts\nvar AuthRequestType;\n(function (AuthRequestType) {\n    AuthRequestType[\"UserAuthentication\"] = \"user-authentication\";\n    AuthRequestType[\"ChannelAuthorization\"] = \"channel-authorization\";\n})(AuthRequestType || (AuthRequestType = {}));\n\n// CONCATENATED MODULE: ./src/core/errors.ts\nvar __extends = ( false) || (function () {\n    var extendStatics = function (d, b) {\n        extendStatics = Object.setPrototypeOf ||\n            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n        return extendStatics(d, b);\n    };\n    return function (d, b) {\n        extendStatics(d, b);\n        function __() { this.constructor = d; }\n        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n    };\n})();\nvar BadEventName = (function (_super) {\n    __extends(BadEventName, _super);\n    function BadEventName(msg) {\n        var _newTarget = this.constructor;\n        var _this = _super.call(this, msg) || this;\n        Object.setPrototypeOf(_this, _newTarget.prototype);\n        return _this;\n    }\n    return BadEventName;\n}(Error));\n\nvar BadChannelName = (function (_super) {\n    __extends(BadChannelName, _super);\n    function BadChannelName(msg) {\n        var _newTarget = this.constructor;\n        var _this = _super.call(this, msg) || this;\n        Object.setPrototypeOf(_this, _newTarget.prototype);\n        return _this;\n    }\n    return BadChannelName;\n}(Error));\n\nvar RequestTimedOut = (function (_super) {\n    __extends(RequestTimedOut, _super);\n    function RequestTimedOut(msg) {\n        var _newTarget = this.constructor;\n        var _this = _super.call(this, msg) || this;\n        Object.setPrototypeOf(_this, _newTarget.prototype);\n        return _this;\n    }\n    return RequestTimedOut;\n}(Error));\n\nvar TransportPriorityTooLow = (function (_super) {\n    __extends(TransportPriorityTooLow, _super);\n    function TransportPriorityTooLow(msg) {\n        var _newTarget = this.constructor;\n        var _this = _super.call(this, msg) || this;\n        Object.setPrototypeOf(_this, _newTarget.prototype);\n        return _this;\n    }\n    return TransportPriorityTooLow;\n}(Error));\n\nvar TransportClosed = (function (_super) {\n    __extends(TransportClosed, _super);\n    function TransportClosed(msg) {\n        var _newTarget = this.constructor;\n        var _this = _super.call(this, msg) || this;\n        Object.setPrototypeOf(_this, _newTarget.prototype);\n        return _this;\n    }\n    return TransportClosed;\n}(Error));\n\nvar UnsupportedFeature = (function (_super) {\n    __extends(UnsupportedFeature, _super);\n    function UnsupportedFeature(msg) {\n        var _newTarget = this.constructor;\n        var _this = _super.call(this, msg) || this;\n        Object.setPrototypeOf(_this, _newTarget.prototype);\n        return _this;\n    }\n    return UnsupportedFeature;\n}(Error));\n\nvar UnsupportedTransport = (function (_super) {\n    __extends(UnsupportedTransport, _super);\n    function UnsupportedTransport(msg) {\n        var _newTarget = this.constructor;\n        var _this = _super.call(this, msg) || this;\n        Object.setPrototypeOf(_this, _newTarget.prototype);\n        return _this;\n    }\n    return UnsupportedTransport;\n}(Error));\n\nvar UnsupportedStrategy = (function (_super) {\n    __extends(UnsupportedStrategy, _super);\n    function UnsupportedStrategy(msg) {\n        var _newTarget = this.constructor;\n        var _this = _super.call(this, msg) || this;\n        Object.setPrototypeOf(_this, _newTarget.prototype);\n        return _this;\n    }\n    return UnsupportedStrategy;\n}(Error));\n\nvar HTTPAuthError = (function (_super) {\n    __extends(HTTPAuthError, _super);\n    function HTTPAuthError(status, msg) {\n        var _newTarget = this.constructor;\n        var _this = _super.call(this, msg) || this;\n        _this.status = status;\n        Object.setPrototypeOf(_this, _newTarget.prototype);\n        return _this;\n    }\n    return HTTPAuthError;\n}(Error));\n\n\n// CONCATENATED MODULE: ./src/runtimes/isomorphic/auth/xhr_auth.ts\n\n\n\n\nvar ajax = function (context, query, authOptions, authRequestType, callback) {\n    var xhr = runtime.createXHR();\n    xhr.open('POST', authOptions.endpoint, true);\n    xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n    for (var headerName in authOptions.headers) {\n        xhr.setRequestHeader(headerName, authOptions.headers[headerName]);\n    }\n    xhr.onreadystatechange = function () {\n        if (xhr.readyState === 4) {\n            if (xhr.status === 200) {\n                var data = void 0;\n                var parsed = false;\n                try {\n                    data = JSON.parse(xhr.responseText);\n                    parsed = true;\n                }\n                catch (e) {\n                    callback(new HTTPAuthError(200, \"JSON returned from \" + authRequestType.toString() + \" endpoint was invalid, yet status code was 200. Data was: \" + xhr.responseText), null);\n                }\n                if (parsed) {\n                    callback(null, data);\n                }\n            }\n            else {\n                var suffix = '';\n                switch (authRequestType) {\n                    case AuthRequestType.UserAuthentication:\n                        suffix = url_store.buildLogSuffix('authenticationEndpoint');\n                        break;\n                    case AuthRequestType.ChannelAuthorization:\n                        suffix = \"Clients must be authenticated to join private or presence channels. \" + url_store.buildLogSuffix('authorizationEndpoint');\n                        break;\n                }\n                callback(new HTTPAuthError(xhr.status, \"Unable to retrieve auth string from \" + authRequestType.toString() + \" endpoint - \" +\n                    (\"received status: \" + xhr.status + \" from \" + authOptions.endpoint + \". \" + suffix)), null);\n            }\n        }\n    };\n    xhr.send(query);\n    return xhr;\n};\n/* harmony default export */ var xhr_auth = (ajax);\n\n// CONCATENATED MODULE: ./src/core/base64.ts\nfunction encode(s) {\n    return btoa(utob(s));\n}\nvar fromCharCode = String.fromCharCode;\nvar b64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\nfor (var base64_i = 0, l = b64chars.length; base64_i < l; base64_i++) {\n    b64tab[b64chars.charAt(base64_i)] = base64_i;\n}\nvar cb_utob = function (c) {\n    var cc = c.charCodeAt(0);\n    return cc < 0x80\n        ? c\n        : cc < 0x800\n            ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n            : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n                fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n                fromCharCode(0x80 | (cc & 0x3f));\n};\nvar utob = function (u) {\n    return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\nvar cb_encode = function (ccc) {\n    var padlen = [0, 2, 1][ccc.length % 3];\n    var ord = (ccc.charCodeAt(0) << 16) |\n        ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n        (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n    var chars = [\n        b64chars.charAt(ord >>> 18),\n        b64chars.charAt((ord >>> 12) & 63),\n        padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n        padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n    ];\n    return chars.join('');\n};\nvar btoa = window.btoa ||\n    function (b) {\n        return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n    };\n\n// CONCATENATED MODULE: ./src/core/utils/timers/abstract_timer.ts\nvar Timer = (function () {\n    function Timer(set, clear, delay, callback) {\n        var _this = this;\n        this.clear = clear;\n        this.timer = set(function () {\n            if (_this.timer) {\n                _this.timer = callback(_this.timer);\n            }\n        }, delay);\n    }\n    Timer.prototype.isRunning = function () {\n        return this.timer !== null;\n    };\n    Timer.prototype.ensureAborted = function () {\n        if (this.timer) {\n            this.clear(this.timer);\n            this.timer = null;\n        }\n    };\n    return Timer;\n}());\n/* harmony default export */ var abstract_timer = (Timer);\n\n// CONCATENATED MODULE: ./src/core/utils/timers/index.ts\nvar timers_extends = ( false) || (function () {\n    var extendStatics = function (d, b) {\n        extendStatics = Object.setPrototypeOf ||\n            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n        return extendStatics(d, b);\n    };\n    return function (d, b) {\n        extendStatics(d, b);\n        function __() { this.constructor = d; }\n        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n    };\n})();\n\nfunction timers_clearTimeout(timer) {\n    window.clearTimeout(timer);\n}\nfunction timers_clearInterval(timer) {\n    window.clearInterval(timer);\n}\nvar OneOffTimer = (function (_super) {\n    timers_extends(OneOffTimer, _super);\n    function OneOffTimer(delay, callback) {\n        return _super.call(this, setTimeout, timers_clearTimeout, delay, function (timer) {\n            callback();\n            return null;\n        }) || this;\n    }\n    return OneOffTimer;\n}(abstract_timer));\n\nvar PeriodicTimer = (function (_super) {\n    timers_extends(PeriodicTimer, _super);\n    function PeriodicTimer(delay, callback) {\n        return _super.call(this, setInterval, timers_clearInterval, delay, function (timer) {\n            callback();\n            return timer;\n        }) || this;\n    }\n    return PeriodicTimer;\n}(abstract_timer));\n\n\n// CONCATENATED MODULE: ./src/core/util.ts\n\nvar Util = {\n    now: function () {\n        if (Date.now) {\n            return Date.now();\n        }\n        else {\n            return new Date().valueOf();\n        }\n    },\n    defer: function (callback) {\n        return new OneOffTimer(0, callback);\n    },\n    method: function (name) {\n        var args = [];\n        for (var _i = 1; _i < arguments.length; _i++) {\n            args[_i - 1] = arguments[_i];\n        }\n        var boundArguments = Array.prototype.slice.call(arguments, 1);\n        return function (object) {\n            return object[name].apply(object, boundArguments.concat(arguments));\n        };\n    }\n};\n/* harmony default export */ var util = (Util);\n\n// CONCATENATED MODULE: ./src/core/utils/collections.ts\n\n\nfunction extend(target) {\n    var sources = [];\n    for (var _i = 1; _i < arguments.length; _i++) {\n        sources[_i - 1] = arguments[_i];\n    }\n    for (var i = 0; i < sources.length; i++) {\n        var extensions = sources[i];\n        for (var property in extensions) {\n            if (extensions[property] &&\n                extensions[property].constructor &&\n                extensions[property].constructor === Object) {\n                target[property] = extend(target[property] || {}, extensions[property]);\n            }\n            else {\n                target[property] = extensions[property];\n            }\n        }\n    }\n    return target;\n}\nfunction stringify() {\n    var m = ['Pusher'];\n    for (var i = 0; i < arguments.length; i++) {\n        if (typeof arguments[i] === 'string') {\n            m.push(arguments[i]);\n        }\n        else {\n            m.push(safeJSONStringify(arguments[i]));\n        }\n    }\n    return m.join(' : ');\n}\nfunction arrayIndexOf(array, item) {\n    var nativeIndexOf = Array.prototype.indexOf;\n    if (array === null) {\n        return -1;\n    }\n    if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n        return array.indexOf(item);\n    }\n    for (var i = 0, l = array.length; i < l; i++) {\n        if (array[i] === item) {\n            return i;\n        }\n    }\n    return -1;\n}\nfunction objectApply(object, f) {\n    for (var key in object) {\n        if (Object.prototype.hasOwnProperty.call(object, key)) {\n            f(object[key], key, object);\n        }\n    }\n}\nfunction keys(object) {\n    var keys = [];\n    objectApply(object, function (_, key) {\n        keys.push(key);\n    });\n    return keys;\n}\nfunction values(object) {\n    var values = [];\n    objectApply(object, function (value) {\n        values.push(value);\n    });\n    return values;\n}\nfunction apply(array, f, context) {\n    for (var i = 0; i < array.length; i++) {\n        f.call(context || window, array[i], i, array);\n    }\n}\nfunction map(array, f) {\n    var result = [];\n    for (var i = 0; i < array.length; i++) {\n        result.push(f(array[i], i, array, result));\n    }\n    return result;\n}\nfunction mapObject(object, f) {\n    var result = {};\n    objectApply(object, function (value, key) {\n        result[key] = f(value);\n    });\n    return result;\n}\nfunction filter(array, test) {\n    test =\n        test ||\n            function (value) {\n                return !!value;\n            };\n    var result = [];\n    for (var i = 0; i < array.length; i++) {\n        if (test(array[i], i, array, result)) {\n            result.push(array[i]);\n        }\n    }\n    return result;\n}\nfunction filterObject(object, test) {\n    var result = {};\n    objectApply(object, function (value, key) {\n        if ((test && test(value, key, object, result)) || Boolean(value)) {\n            result[key] = value;\n        }\n    });\n    return result;\n}\nfunction flatten(object) {\n    var result = [];\n    objectApply(object, function (value, key) {\n        result.push([key, value]);\n    });\n    return result;\n}\nfunction any(array, test) {\n    for (var i = 0; i < array.length; i++) {\n        if (test(array[i], i, array)) {\n            return true;\n        }\n    }\n    return false;\n}\nfunction collections_all(array, test) {\n    for (var i = 0; i < array.length; i++) {\n        if (!test(array[i], i, array)) {\n            return false;\n        }\n    }\n    return true;\n}\nfunction encodeParamsObject(data) {\n    return mapObject(data, function (value) {\n        if (typeof value === 'object') {\n            value = safeJSONStringify(value);\n        }\n        return encodeURIComponent(encode(value.toString()));\n    });\n}\nfunction buildQueryString(data) {\n    var params = filterObject(data, function (value) {\n        return value !== undefined;\n    });\n    var query = map(flatten(encodeParamsObject(params)), util.method('join', '=')).join('&');\n    return query;\n}\nfunction decycleObject(object) {\n    var objects = [], paths = [];\n    return (function derez(value, path) {\n        var i, name, nu;\n        switch (typeof value) {\n            case 'object':\n                if (!value) {\n                    return null;\n                }\n                for (i = 0; i < objects.length; i += 1) {\n                    if (objects[i] === value) {\n                        return { $ref: paths[i] };\n                    }\n                }\n                objects.push(value);\n                paths.push(path);\n                if (Object.prototype.toString.apply(value) === '[object Array]') {\n                    nu = [];\n                    for (i = 0; i < value.length; i += 1) {\n                        nu[i] = derez(value[i], path + '[' + i + ']');\n                    }\n                }\n                else {\n                    nu = {};\n                    for (name in value) {\n                        if (Object.prototype.hasOwnProperty.call(value, name)) {\n                            nu[name] = derez(value[name], path + '[' + JSON.stringify(name) + ']');\n                        }\n                    }\n                }\n                return nu;\n            case 'number':\n            case 'string':\n            case 'boolean':\n                return value;\n        }\n    })(object, '$');\n}\nfunction safeJSONStringify(source) {\n    try {\n        return JSON.stringify(source);\n    }\n    catch (e) {\n        return JSON.stringify(decycleObject(source));\n    }\n}\n\n// CONCATENATED MODULE: ./src/core/logger.ts\n\n\nvar logger_Logger = (function () {\n    function Logger() {\n        this.globalLog = function (message) {\n            if (window.console && window.console.log) {\n                window.console.log(message);\n            }\n        };\n    }\n    Logger.prototype.debug = function () {\n        var args = [];\n        for (var _i = 0; _i < arguments.length; _i++) {\n            args[_i] = arguments[_i];\n        }\n        this.log(this.globalLog, args);\n    };\n    Logger.prototype.warn = function () {\n        var args = [];\n        for (var _i = 0; _i < arguments.length; _i++) {\n            args[_i] = arguments[_i];\n        }\n        this.log(this.globalLogWarn, args);\n    };\n    Logger.prototype.error = function () {\n        var args = [];\n        for (var _i = 0; _i < arguments.length; _i++) {\n            args[_i] = arguments[_i];\n        }\n        this.log(this.globalLogError, args);\n    };\n    Logger.prototype.globalLogWarn = function (message) {\n        if (window.console && window.console.warn) {\n            window.console.warn(message);\n        }\n        else {\n            this.globalLog(message);\n        }\n    };\n    Logger.prototype.globalLogError = function (message) {\n        if (window.console && window.console.error) {\n            window.console.error(message);\n        }\n        else {\n            this.globalLogWarn(message);\n        }\n    };\n    Logger.prototype.log = function (defaultLoggingFunction) {\n        var args = [];\n        for (var _i = 1; _i < arguments.length; _i++) {\n            args[_i - 1] = arguments[_i];\n        }\n        var message = stringify.apply(this, arguments);\n        if (core_pusher.log) {\n            core_pusher.log(message);\n        }\n        else if (core_pusher.logToConsole) {\n            var log = defaultLoggingFunction.bind(this);\n            log(message);\n        }\n    };\n    return Logger;\n}());\n/* harmony default export */ var logger = (new logger_Logger());\n\n// CONCATENATED MODULE: ./src/runtimes/web/auth/jsonp_auth.ts\n\nvar jsonp = function (context, query, authOptions, authRequestType, callback) {\n    if (authOptions.headers !== undefined) {\n        logger.warn(\"To send headers with the \" + authRequestType.toString() + \" request, you must use AJAX, rather than JSONP.\");\n    }\n    var callbackName = context.nextAuthCallbackID.toString();\n    context.nextAuthCallbackID++;\n    var document = context.getDocument();\n    var script = document.createElement('script');\n    context.auth_callbacks[callbackName] = function (data) {\n        callback(null, data);\n    };\n    var callback_name = \"Pusher.auth_callbacks['\" + callbackName + \"']\";\n    script.src =\n        authOptions.endpoint +\n            '?callback=' +\n            encodeURIComponent(callback_name) +\n            '&' +\n            query;\n    var head = document.getElementsByTagName('head')[0] || document.documentElement;\n    head.insertBefore(script, head.firstChild);\n};\n/* harmony default export */ var jsonp_auth = (jsonp);\n\n// CONCATENATED MODULE: ./src/runtimes/web/dom/script_request.ts\nvar ScriptRequest = (function () {\n    function ScriptRequest(src) {\n        this.src = src;\n    }\n    ScriptRequest.prototype.send = function (receiver) {\n        var self = this;\n        var errorString = 'Error loading ' + self.src;\n        self.script = document.createElement('script');\n        self.script.id = receiver.id;\n        self.script.src = self.src;\n        self.script.type = 'text/javascript';\n        self.script.charset = 'UTF-8';\n        if (self.script.addEventListener) {\n            self.script.onerror = function () {\n                receiver.callback(errorString);\n            };\n            self.script.onload = function () {\n                receiver.callback(null);\n            };\n        }\n        else {\n            self.script.onreadystatechange = function () {\n                if (self.script.readyState === 'loaded' ||\n                    self.script.readyState === 'complete') {\n                    receiver.callback(null);\n                }\n            };\n        }\n        if (self.script.async === undefined &&\n            document.attachEvent &&\n            /opera/i.test(navigator.userAgent)) {\n            self.errorScript = document.createElement('script');\n            self.errorScript.id = receiver.id + '_error';\n            self.errorScript.text = receiver.name + \"('\" + errorString + \"');\";\n            self.script.async = self.errorScript.async = false;\n        }\n        else {\n            self.script.async = true;\n        }\n        var head = document.getElementsByTagName('head')[0];\n        head.insertBefore(self.script, head.firstChild);\n        if (self.errorScript) {\n            head.insertBefore(self.errorScript, self.script.nextSibling);\n        }\n    };\n    ScriptRequest.prototype.cleanup = function () {\n        if (this.script) {\n            this.script.onload = this.script.onerror = null;\n            this.script.onreadystatechange = null;\n        }\n        if (this.script && this.script.parentNode) {\n            this.script.parentNode.removeChild(this.script);\n        }\n        if (this.errorScript && this.errorScript.parentNode) {\n            this.errorScript.parentNode.removeChild(this.errorScript);\n        }\n        this.script = null;\n        this.errorScript = null;\n    };\n    return ScriptRequest;\n}());\n/* harmony default export */ var script_request = (ScriptRequest);\n\n// CONCATENATED MODULE: ./src/runtimes/web/dom/jsonp_request.ts\n\n\nvar jsonp_request_JSONPRequest = (function () {\n    function JSONPRequest(url, data) {\n        this.url = url;\n        this.data = data;\n    }\n    JSONPRequest.prototype.send = function (receiver) {\n        if (this.request) {\n            return;\n        }\n        var query = buildQueryString(this.data);\n        var url = this.url + '/' + receiver.number + '?' + query;\n        this.request = runtime.createScriptRequest(url);\n        this.request.send(receiver);\n    };\n    JSONPRequest.prototype.cleanup = function () {\n        if (this.request) {\n            this.request.cleanup();\n        }\n    };\n    return JSONPRequest;\n}());\n/* harmony default export */ var jsonp_request = (jsonp_request_JSONPRequest);\n\n// CONCATENATED MODULE: ./src/runtimes/web/timeline/jsonp_timeline.ts\n\n\nvar getAgent = function (sender, useTLS) {\n    return function (data, callback) {\n        var scheme = 'http' + (useTLS ? 's' : '') + '://';\n        var url = scheme + (sender.host || sender.options.host) + sender.options.path;\n        var request = runtime.createJSONPRequest(url, data);\n        var receiver = runtime.ScriptReceivers.create(function (error, result) {\n            ScriptReceivers.remove(receiver);\n            request.cleanup();\n            if (result && result.host) {\n                sender.host = result.host;\n            }\n            if (callback) {\n                callback(error, result);\n            }\n        });\n        request.send(receiver);\n    };\n};\nvar jsonp_timeline_jsonp = {\n    name: 'jsonp',\n    getAgent: getAgent\n};\n/* harmony default export */ var jsonp_timeline = (jsonp_timeline_jsonp);\n\n// CONCATENATED MODULE: ./src/core/transports/url_schemes.ts\n\nfunction getGenericURL(baseScheme, params, path) {\n    var scheme = baseScheme + (params.useTLS ? 's' : '');\n    var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n    return scheme + '://' + host + path;\n}\nfunction getGenericPath(key, queryString) {\n    var path = '/app/' + key;\n    var query = '?protocol=' +\n        defaults.PROTOCOL +\n        '&client=js' +\n        '&version=' +\n        defaults.VERSION +\n        (queryString ? '&' + queryString : '');\n    return path + query;\n}\nvar ws = {\n    getInitial: function (key, params) {\n        var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n        return getGenericURL('ws', params, path);\n    }\n};\nvar http = {\n    getInitial: function (key, params) {\n        var path = (params.httpPath || '/pusher') + getGenericPath(key);\n        return getGenericURL('http', params, path);\n    }\n};\nvar sockjs = {\n    getInitial: function (key, params) {\n        return getGenericURL('http', params, params.httpPath || '/pusher');\n    },\n    getPath: function (key, params) {\n        return getGenericPath(key);\n    }\n};\n\n// CONCATENATED MODULE: ./src/core/events/callback_registry.ts\n\nvar callback_registry_CallbackRegistry = (function () {\n    function CallbackRegistry() {\n        this._callbacks = {};\n    }\n    CallbackRegistry.prototype.get = function (name) {\n        return this._callbacks[prefix(name)];\n    };\n    CallbackRegistry.prototype.add = function (name, callback, context) {\n        var prefixedEventName = prefix(name);\n        this._callbacks[prefixedEventName] =\n            this._callbacks[prefixedEventName] || [];\n        this._callbacks[prefixedEventName].push({\n            fn: callback,\n            context: context\n        });\n    };\n    CallbackRegistry.prototype.remove = function (name, callback, context) {\n        if (!name && !callback && !context) {\n            this._callbacks = {};\n            return;\n        }\n        var names = name ? [prefix(name)] : keys(this._callbacks);\n        if (callback || context) {\n            this.removeCallback(names, callback, context);\n        }\n        else {\n            this.removeAllCallbacks(names);\n        }\n    };\n    CallbackRegistry.prototype.removeCallback = function (names, callback, context) {\n        apply(names, function (name) {\n            this._callbacks[name] = filter(this._callbacks[name] || [], function (binding) {\n                return ((callback && callback !== binding.fn) ||\n                    (context && context !== binding.context));\n            });\n            if (this._callbacks[name].length === 0) {\n                delete this._callbacks[name];\n            }\n        }, this);\n    };\n    CallbackRegistry.prototype.removeAllCallbacks = function (names) {\n        apply(names, function (name) {\n            delete this._callbacks[name];\n        }, this);\n    };\n    return CallbackRegistry;\n}());\n/* harmony default export */ var callback_registry = (callback_registry_CallbackRegistry);\nfunction prefix(name) {\n    return '_' + name;\n}\n\n// CONCATENATED MODULE: ./src/core/events/dispatcher.ts\n\n\nvar dispatcher_Dispatcher = (function () {\n    function Dispatcher(failThrough) {\n        this.callbacks = new callback_registry();\n        this.global_callbacks = [];\n        this.failThrough = failThrough;\n    }\n    Dispatcher.prototype.bind = function (eventName, callback, context) {\n        this.callbacks.add(eventName, callback, context);\n        return this;\n    };\n    Dispatcher.prototype.bind_global = function (callback) {\n        this.global_callbacks.push(callback);\n        return this;\n    };\n    Dispatcher.prototype.unbind = function (eventName, callback, context) {\n        this.callbacks.remove(eventName, callback, context);\n        return this;\n    };\n    Dispatcher.prototype.unbind_global = function (callback) {\n        if (!callback) {\n            this.global_callbacks = [];\n            return this;\n        }\n        this.global_callbacks = filter(this.global_callbacks || [], function (c) { return c !== callback; });\n        return this;\n    };\n    Dispatcher.prototype.unbind_all = function () {\n        this.unbind();\n        this.unbind_global();\n        return this;\n    };\n    Dispatcher.prototype.emit = function (eventName, data, metadata) {\n        for (var i = 0; i < this.global_callbacks.length; i++) {\n            this.global_callbacks[i](eventName, data);\n        }\n        var callbacks = this.callbacks.get(eventName);\n        var args = [];\n        if (metadata) {\n            args.push(data, metadata);\n        }\n        else if (data) {\n            args.push(data);\n        }\n        if (callbacks && callbacks.length > 0) {\n            for (var i = 0; i < callbacks.length; i++) {\n                callbacks[i].fn.apply(callbacks[i].context || window, args);\n            }\n        }\n        else if (this.failThrough) {\n            this.failThrough(eventName, data);\n        }\n        return this;\n    };\n    return Dispatcher;\n}());\n/* harmony default export */ var dispatcher = (dispatcher_Dispatcher);\n\n// CONCATENATED MODULE: ./src/core/transports/transport_connection.ts\nvar transport_connection_extends = ( false) || (function () {\n    var extendStatics = function (d, b) {\n        extendStatics = Object.setPrototypeOf ||\n            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n        return extendStatics(d, b);\n    };\n    return function (d, b) {\n        extendStatics(d, b);\n        function __() { this.constructor = d; }\n        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n    };\n})();\n\n\n\n\n\nvar transport_connection_TransportConnection = (function (_super) {\n    transport_connection_extends(TransportConnection, _super);\n    function TransportConnection(hooks, name, priority, key, options) {\n        var _this = _super.call(this) || this;\n        _this.initialize = runtime.transportConnectionInitializer;\n        _this.hooks = hooks;\n        _this.name = name;\n        _this.priority = priority;\n        _this.key = key;\n        _this.options = options;\n        _this.state = 'new';\n        _this.timeline = options.timeline;\n        _this.activityTimeout = options.activityTimeout;\n        _this.id = _this.timeline.generateUniqueID();\n        return _this;\n    }\n    TransportConnection.prototype.handlesActivityChecks = function () {\n        return Boolean(this.hooks.handlesActivityChecks);\n    };\n    TransportConnection.prototype.supportsPing = function () {\n        return Boolean(this.hooks.supportsPing);\n    };\n    TransportConnection.prototype.connect = function () {\n        var _this = this;\n        if (this.socket || this.state !== 'initialized') {\n            return false;\n        }\n        var url = this.hooks.urls.getInitial(this.key, this.options);\n        try {\n            this.socket = this.hooks.getSocket(url, this.options);\n        }\n        catch (e) {\n            util.defer(function () {\n                _this.onError(e);\n                _this.changeState('closed');\n            });\n            return false;\n        }\n        this.bindListeners();\n        logger.debug('Connecting', { transport: this.name, url: url });\n        this.changeState('connecting');\n        return true;\n    };\n    TransportConnection.prototype.close = function () {\n        if (this.socket) {\n            this.socket.close();\n            return true;\n        }\n        else {\n            return false;\n        }\n    };\n    TransportConnection.prototype.send = function (data) {\n        var _this = this;\n        if (this.state === 'open') {\n            util.defer(function () {\n                if (_this.socket) {\n                    _this.socket.send(data);\n                }\n            });\n            return true;\n        }\n        else {\n            return false;\n        }\n    };\n    TransportConnection.prototype.ping = function () {\n        if (this.state === 'open' && this.supportsPing()) {\n            this.socket.ping();\n        }\n    };\n    TransportConnection.prototype.onOpen = function () {\n        if (this.hooks.beforeOpen) {\n            this.hooks.beforeOpen(this.socket, this.hooks.urls.getPath(this.key, this.options));\n        }\n        this.changeState('open');\n        this.socket.onopen = undefined;\n    };\n    TransportConnection.prototype.onError = function (error) {\n        this.emit('error', { type: 'WebSocketError', error: error });\n        this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n    };\n    TransportConnection.prototype.onClose = function (closeEvent) {\n        if (closeEvent) {\n            this.changeState('closed', {\n                code: closeEvent.code,\n                reason: closeEvent.reason,\n                wasClean: closeEvent.wasClean\n            });\n        }\n        else {\n            this.changeState('closed');\n        }\n        this.unbindListeners();\n        this.socket = undefined;\n    };\n    TransportConnection.prototype.onMessage = function (message) {\n        this.emit('message', message);\n    };\n    TransportConnection.prototype.onActivity = function () {\n        this.emit('activity');\n    };\n    TransportConnection.prototype.bindListeners = function () {\n        var _this = this;\n        this.socket.onopen = function () {\n            _this.onOpen();\n        };\n        this.socket.onerror = function (error) {\n            _this.onError(error);\n        };\n        this.socket.onclose = function (closeEvent) {\n            _this.onClose(closeEvent);\n        };\n        this.socket.onmessage = function (message) {\n            _this.onMessage(message);\n        };\n        if (this.supportsPing()) {\n            this.socket.onactivity = function () {\n                _this.onActivity();\n            };\n        }\n    };\n    TransportConnection.prototype.unbindListeners = function () {\n        if (this.socket) {\n            this.socket.onopen = undefined;\n            this.socket.onerror = undefined;\n            this.socket.onclose = undefined;\n            this.socket.onmessage = undefined;\n            if (this.supportsPing()) {\n                this.socket.onactivity = undefined;\n            }\n        }\n    };\n    TransportConnection.prototype.changeState = function (state, params) {\n        this.state = state;\n        this.timeline.info(this.buildTimelineMessage({\n            state: state,\n            params: params\n        }));\n        this.emit(state, params);\n    };\n    TransportConnection.prototype.buildTimelineMessage = function (message) {\n        return extend({ cid: this.id }, message);\n    };\n    return TransportConnection;\n}(dispatcher));\n/* harmony default export */ var transport_connection = (transport_connection_TransportConnection);\n\n// CONCATENATED MODULE: ./src/core/transports/transport.ts\n\nvar transport_Transport = (function () {\n    function Transport(hooks) {\n        this.hooks = hooks;\n    }\n    Transport.prototype.isSupported = function (environment) {\n        return this.hooks.isSupported(environment);\n    };\n    Transport.prototype.createConnection = function (name, priority, key, options) {\n        return new transport_connection(this.hooks, name, priority, key, options);\n    };\n    return Transport;\n}());\n/* harmony default export */ var transports_transport = (transport_Transport);\n\n// CONCATENATED MODULE: ./src/runtimes/isomorphic/transports/transports.ts\n\n\n\n\nvar WSTransport = new transports_transport({\n    urls: ws,\n    handlesActivityChecks: false,\n    supportsPing: false,\n    isInitialized: function () {\n        return Boolean(runtime.getWebSocketAPI());\n    },\n    isSupported: function () {\n        return Boolean(runtime.getWebSocketAPI());\n    },\n    getSocket: function (url) {\n        return runtime.createWebSocket(url);\n    }\n});\nvar httpConfiguration = {\n    urls: http,\n    handlesActivityChecks: false,\n    supportsPing: true,\n    isInitialized: function () {\n        return true;\n    }\n};\nvar streamingConfiguration = extend({\n    getSocket: function (url) {\n        return runtime.HTTPFactory.createStreamingSocket(url);\n    }\n}, httpConfiguration);\nvar pollingConfiguration = extend({\n    getSocket: function (url) {\n        return runtime.HTTPFactory.createPollingSocket(url);\n    }\n}, httpConfiguration);\nvar xhrConfiguration = {\n    isSupported: function () {\n        return runtime.isXHRSupported();\n    }\n};\nvar XHRStreamingTransport = new transports_transport((extend({}, streamingConfiguration, xhrConfiguration)));\nvar XHRPollingTransport = new transports_transport(extend({}, pollingConfiguration, xhrConfiguration));\nvar Transports = {\n    ws: WSTransport,\n    xhr_streaming: XHRStreamingTransport,\n    xhr_polling: XHRPollingTransport\n};\n/* harmony default export */ var transports = (Transports);\n\n// CONCATENATED MODULE: ./src/runtimes/web/transports/transports.ts\n\n\n\n\n\n\nvar SockJSTransport = new transports_transport({\n    file: 'sockjs',\n    urls: sockjs,\n    handlesActivityChecks: true,\n    supportsPing: false,\n    isSupported: function () {\n        return true;\n    },\n    isInitialized: function () {\n        return window.SockJS !== undefined;\n    },\n    getSocket: function (url, options) {\n        return new window.SockJS(url, null, {\n            js_path: Dependencies.getPath('sockjs', {\n                useTLS: options.useTLS\n            }),\n            ignore_null_origin: options.ignoreNullOrigin\n        });\n    },\n    beforeOpen: function (socket, path) {\n        socket.send(JSON.stringify({\n            path: path\n        }));\n    }\n});\nvar xdrConfiguration = {\n    isSupported: function (environment) {\n        var yes = runtime.isXDRSupported(environment.useTLS);\n        return yes;\n    }\n};\nvar XDRStreamingTransport = new transports_transport((extend({}, streamingConfiguration, xdrConfiguration)));\nvar XDRPollingTransport = new transports_transport(extend({}, pollingConfiguration, xdrConfiguration));\ntransports.xdr_streaming = XDRStreamingTransport;\ntransports.xdr_polling = XDRPollingTransport;\ntransports.sockjs = SockJSTransport;\n/* harmony default export */ var transports_transports = (transports);\n\n// CONCATENATED MODULE: ./src/runtimes/web/net_info.ts\nvar net_info_extends = ( false) || (function () {\n    var extendStatics = function (d, b) {\n        extendStatics = Object.setPrototypeOf ||\n            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n        return extendStatics(d, b);\n    };\n    return function (d, b) {\n        extendStatics(d, b);\n        function __() { this.constructor = d; }\n        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n    };\n})();\n\nvar NetInfo = (function (_super) {\n    net_info_extends(NetInfo, _super);\n    function NetInfo() {\n        var _this = _super.call(this) || this;\n        var self = _this;\n        if (window.addEventListener !== undefined) {\n            window.addEventListener('online', function () {\n                self.emit('online');\n            }, false);\n            window.addEventListener('offline', function () {\n                self.emit('offline');\n            }, false);\n        }\n        return _this;\n    }\n    NetInfo.prototype.isOnline = function () {\n        if (window.navigator.onLine === undefined) {\n            return true;\n        }\n        else {\n            return window.navigator.onLine;\n        }\n    };\n    return NetInfo;\n}(dispatcher));\n\nvar net_info_Network = new NetInfo();\n\n// CONCATENATED MODULE: ./src/core/transports/assistant_to_the_transport_manager.ts\n\n\nvar assistant_to_the_transport_manager_AssistantToTheTransportManager = (function () {\n    function AssistantToTheTransportManager(manager, transport, options) {\n        this.manager = manager;\n        this.transport = transport;\n        this.minPingDelay = options.minPingDelay;\n        this.maxPingDelay = options.maxPingDelay;\n        this.pingDelay = undefined;\n    }\n    AssistantToTheTransportManager.prototype.createConnection = function (name, priority, key, options) {\n        var _this = this;\n        options = extend({}, options, {\n            activityTimeout: this.pingDelay\n        });\n        var connection = this.transport.createConnection(name, priority, key, options);\n        var openTimestamp = null;\n        var onOpen = function () {\n            connection.unbind('open', onOpen);\n            connection.bind('closed', onClosed);\n            openTimestamp = util.now();\n        };\n        var onClosed = function (closeEvent) {\n            connection.unbind('closed', onClosed);\n            if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n                _this.manager.reportDeath();\n            }\n            else if (!closeEvent.wasClean && openTimestamp) {\n                var lifespan = util.now() - openTimestamp;\n                if (lifespan < 2 * _this.maxPingDelay) {\n                    _this.manager.reportDeath();\n                    _this.pingDelay = Math.max(lifespan / 2, _this.minPingDelay);\n                }\n            }\n        };\n        connection.bind('open', onOpen);\n        return connection;\n    };\n    AssistantToTheTransportManager.prototype.isSupported = function (environment) {\n        return this.manager.isAlive() && this.transport.isSupported(environment);\n    };\n    return AssistantToTheTransportManager;\n}());\n/* harmony default export */ var assistant_to_the_transport_manager = (assistant_to_the_transport_manager_AssistantToTheTransportManager);\n\n// CONCATENATED MODULE: ./src/core/connection/protocol/protocol.ts\nvar Protocol = {\n    decodeMessage: function (messageEvent) {\n        try {\n            var messageData = JSON.parse(messageEvent.data);\n            var pusherEventData = messageData.data;\n            if (typeof pusherEventData === 'string') {\n                try {\n                    pusherEventData = JSON.parse(messageData.data);\n                }\n                catch (e) { }\n            }\n            var pusherEvent = {\n                event: messageData.event,\n                channel: messageData.channel,\n                data: pusherEventData\n            };\n            if (messageData.user_id) {\n                pusherEvent.user_id = messageData.user_id;\n            }\n            return pusherEvent;\n        }\n        catch (e) {\n            throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n        }\n    },\n    encodeMessage: function (event) {\n        return JSON.stringify(event);\n    },\n    processHandshake: function (messageEvent) {\n        var message = Protocol.decodeMessage(messageEvent);\n        if (message.event === 'pusher:connection_established') {\n            if (!message.data.activity_timeout) {\n                throw 'No activity timeout specified in handshake';\n            }\n            return {\n                action: 'connected',\n                id: message.data.socket_id,\n                activityTimeout: message.data.activity_timeout * 1000\n            };\n        }\n        else if (message.event === 'pusher:error') {\n            return {\n                action: this.getCloseAction(message.data),\n                error: this.getCloseError(message.data)\n            };\n        }\n        else {\n            throw 'Invalid handshake';\n        }\n    },\n    getCloseAction: function (closeEvent) {\n        if (closeEvent.code < 4000) {\n            if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n                return 'backoff';\n            }\n            else {\n                return null;\n            }\n        }\n        else if (closeEvent.code === 4000) {\n            return 'tls_only';\n        }\n        else if (closeEvent.code < 4100) {\n            return 'refused';\n        }\n        else if (closeEvent.code < 4200) {\n            return 'backoff';\n        }\n        else if (closeEvent.code < 4300) {\n            return 'retry';\n        }\n        else {\n            return 'refused';\n        }\n    },\n    getCloseError: function (closeEvent) {\n        if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n            return {\n                type: 'PusherError',\n                data: {\n                    code: closeEvent.code,\n                    message: closeEvent.reason || closeEvent.message\n                }\n            };\n        }\n        else {\n            return null;\n        }\n    }\n};\n/* harmony default export */ var protocol_protocol = (Protocol);\n\n// CONCATENATED MODULE: ./src/core/connection/connection.ts\nvar connection_extends = ( false) || (function () {\n    var extendStatics = function (d, b) {\n        extendStatics = Object.setPrototypeOf ||\n            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n        return extendStatics(d, b);\n    };\n    return function (d, b) {\n        extendStatics(d, b);\n        function __() { this.constructor = d; }\n        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n    };\n})();\n\n\n\n\nvar connection_Connection = (function (_super) {\n    connection_extends(Connection, _super);\n    function Connection(id, transport) {\n        var _this = _super.call(this) || this;\n        _this.id = id;\n        _this.transport = transport;\n        _this.activityTimeout = transport.activityTimeout;\n        _this.bindListeners();\n        return _this;\n    }\n    Connection.prototype.handlesActivityChecks = function () {\n        return this.transport.handlesActivityChecks();\n    };\n    Connection.prototype.send = function (data) {\n        return this.transport.send(data);\n    };\n    Connection.prototype.send_event = function (name, data, channel) {\n        var event = { event: name, data: data };\n        if (channel) {\n            event.channel = channel;\n        }\n        logger.debug('Event sent', event);\n        return this.send(protocol_protocol.encodeMessage(event));\n    };\n    Connection.prototype.ping = function () {\n        if (this.transport.supportsPing()) {\n            this.transport.ping();\n        }\n        else {\n            this.send_event('pusher:ping', {});\n        }\n    };\n    Connection.prototype.close = function () {\n        this.transport.close();\n    };\n    Connection.prototype.bindListeners = function () {\n        var _this = this;\n        var listeners = {\n            message: function (messageEvent) {\n                var pusherEvent;\n                try {\n                    pusherEvent = protocol_protocol.decodeMessage(messageEvent);\n                }\n                catch (e) {\n                    _this.emit('error', {\n                        type: 'MessageParseError',\n                        error: e,\n                        data: messageEvent.data\n                    });\n                }\n                if (pusherEvent !== undefined) {\n                    logger.debug('Event recd', pusherEvent);\n                    switch (pusherEvent.event) {\n                        case 'pusher:error':\n                            _this.emit('error', {\n                                type: 'PusherError',\n                                data: pusherEvent.data\n                            });\n                            break;\n                        case 'pusher:ping':\n                            _this.emit('ping');\n                            break;\n                        case 'pusher:pong':\n                            _this.emit('pong');\n                            break;\n                    }\n                    _this.emit('message', pusherEvent);\n                }\n            },\n            activity: function () {\n                _this.emit('activity');\n            },\n            error: function (error) {\n                _this.emit('error', error);\n            },\n            closed: function (closeEvent) {\n                unbindListeners();\n                if (closeEvent && closeEvent.code) {\n                    _this.handleCloseEvent(closeEvent);\n                }\n                _this.transport = null;\n                _this.emit('closed');\n            }\n        };\n        var unbindListeners = function () {\n            objectApply(listeners, function (listener, event) {\n                _this.transport.unbind(event, listener);\n            });\n        };\n        objectApply(listeners, function (listener, event) {\n            _this.transport.bind(event, listener);\n        });\n    };\n    Connection.prototype.handleCloseEvent = function (closeEvent) {\n        var action = protocol_protocol.getCloseAction(closeEvent);\n        var error = protocol_protocol.getCloseError(closeEvent);\n        if (error) {\n            this.emit('error', error);\n        }\n        if (action) {\n            this.emit(action, { action: action, error: error });\n        }\n    };\n    return Connection;\n}(dispatcher));\n/* harmony default export */ var connection_connection = (connection_Connection);\n\n// CONCATENATED MODULE: ./src/core/connection/handshake/index.ts\n\n\n\nvar handshake_Handshake = (function () {\n    function Handshake(transport, callback) {\n        this.transport = transport;\n        this.callback = callback;\n        this.bindListeners();\n    }\n    Handshake.prototype.close = function () {\n        this.unbindListeners();\n        this.transport.close();\n    };\n    Handshake.prototype.bindListeners = function () {\n        var _this = this;\n        this.onMessage = function (m) {\n            _this.unbindListeners();\n            var result;\n            try {\n                result = protocol_protocol.processHandshake(m);\n            }\n            catch (e) {\n                _this.finish('error', { error: e });\n                _this.transport.close();\n                return;\n            }\n            if (result.action === 'connected') {\n                _this.finish('connected', {\n                    connection: new connection_connection(result.id, _this.transport),\n                    activityTimeout: result.activityTimeout\n                });\n            }\n            else {\n                _this.finish(result.action, { error: result.error });\n                _this.transport.close();\n            }\n        };\n        this.onClosed = function (closeEvent) {\n            _this.unbindListeners();\n            var action = protocol_protocol.getCloseAction(closeEvent) || 'backoff';\n            var error = protocol_protocol.getCloseError(closeEvent);\n            _this.finish(action, { error: error });\n        };\n        this.transport.bind('message', this.onMessage);\n        this.transport.bind('closed', this.onClosed);\n    };\n    Handshake.prototype.unbindListeners = function () {\n        this.transport.unbind('message', this.onMessage);\n        this.transport.unbind('closed', this.onClosed);\n    };\n    Handshake.prototype.finish = function (action, params) {\n        this.callback(extend({ transport: this.transport, action: action }, params));\n    };\n    return Handshake;\n}());\n/* harmony default export */ var connection_handshake = (handshake_Handshake);\n\n// CONCATENATED MODULE: ./src/core/timeline/timeline_sender.ts\n\nvar timeline_sender_TimelineSender = (function () {\n    function TimelineSender(timeline, options) {\n        this.timeline = timeline;\n        this.options = options || {};\n    }\n    TimelineSender.prototype.send = function (useTLS, callback) {\n        if (this.timeline.isEmpty()) {\n            return;\n        }\n        this.timeline.send(runtime.TimelineTransport.getAgent(this, useTLS), callback);\n    };\n    return TimelineSender;\n}());\n/* harmony default export */ var timeline_sender = (timeline_sender_TimelineSender);\n\n// CONCATENATED MODULE: ./src/core/channels/channel.ts\nvar channel_extends = ( false) || (function () {\n    var extendStatics = function (d, b) {\n        extendStatics = Object.setPrototypeOf ||\n            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n        return extendStatics(d, b);\n    };\n    return function (d, b) {\n        extendStatics(d, b);\n        function __() { this.constructor = d; }\n        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n    };\n})();\n\n\n\n\n\nvar channel_Channel = (function (_super) {\n    channel_extends(Channel, _super);\n    function Channel(name, pusher) {\n        var _this = _super.call(this, function (event, data) {\n            logger.debug('No callbacks on ' + name + ' for ' + event);\n        }) || this;\n        _this.name = name;\n        _this.pusher = pusher;\n        _this.subscribed = false;\n        _this.subscriptionPending = false;\n        _this.subscriptionCancelled = false;\n        return _this;\n    }\n    Channel.prototype.authorize = function (socketId, callback) {\n        return callback(null, { auth: '' });\n    };\n    Channel.prototype.trigger = function (event, data) {\n        if (event.indexOf('client-') !== 0) {\n            throw new BadEventName(\"Event '\" + event + \"' does not start with 'client-'\");\n        }\n        if (!this.subscribed) {\n            var suffix = url_store.buildLogSuffix('triggeringClientEvents');\n            logger.warn(\"Client event triggered before channel 'subscription_succeeded' event . \" + suffix);\n        }\n        return this.pusher.send_event(event, data, this.name);\n    };\n    Channel.prototype.disconnect = function () {\n        this.subscribed = false;\n        this.subscriptionPending = false;\n    };\n    Channel.prototype.handleEvent = function (event) {\n        var eventName = event.event;\n        var data = event.data;\n        if (eventName === 'pusher_internal:subscription_succeeded') {\n            this.handleSubscriptionSucceededEvent(event);\n        }\n        else if (eventName === 'pusher_internal:subscription_count') {\n            this.handleSubscriptionCountEvent(event);\n        }\n        else if (eventName.indexOf('pusher_internal:') !== 0) {\n            var metadata = {};\n            this.emit(eventName, data, metadata);\n        }\n    };\n    Channel.prototype.handleSubscriptionSucceededEvent = function (event) {\n        this.subscriptionPending = false;\n        this.subscribed = true;\n        if (this.subscriptionCancelled) {\n            this.pusher.unsubscribe(this.name);\n        }\n        else {\n            this.emit('pusher:subscription_succeeded', event.data);\n        }\n    };\n    Channel.prototype.handleSubscriptionCountEvent = function (event) {\n        if (event.data.subscription_count) {\n            this.subscriptionCount = event.data.subscription_count;\n        }\n        this.emit('pusher:subscription_count', event.data);\n    };\n    Channel.prototype.subscribe = function () {\n        var _this = this;\n        if (this.subscribed) {\n            return;\n        }\n        this.subscriptionPending = true;\n        this.subscriptionCancelled = false;\n        this.authorize(this.pusher.connection.socket_id, function (error, data) {\n            if (error) {\n                _this.subscriptionPending = false;\n                logger.error(error.toString());\n                _this.emit('pusher:subscription_error', Object.assign({}, {\n                    type: 'AuthError',\n                    error: error.message\n                }, error instanceof HTTPAuthError ? { status: error.status } : {}));\n            }\n            else {\n                _this.pusher.send_event('pusher:subscribe', {\n                    auth: data.auth,\n                    channel_data: data.channel_data,\n                    channel: _this.name\n                });\n            }\n        });\n    };\n    Channel.prototype.unsubscribe = function () {\n        this.subscribed = false;\n        this.pusher.send_event('pusher:unsubscribe', {\n            channel: this.name\n        });\n    };\n    Channel.prototype.cancelSubscription = function () {\n        this.subscriptionCancelled = true;\n    };\n    Channel.prototype.reinstateSubscription = function () {\n        this.subscriptionCancelled = false;\n    };\n    return Channel;\n}(dispatcher));\n/* harmony default export */ var channels_channel = (channel_Channel);\n\n// CONCATENATED MODULE: ./src/core/channels/private_channel.ts\nvar private_channel_extends = ( false) || (function () {\n    var extendStatics = function (d, b) {\n        extendStatics = Object.setPrototypeOf ||\n            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n        return extendStatics(d, b);\n    };\n    return function (d, b) {\n        extendStatics(d, b);\n        function __() { this.constructor = d; }\n        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n    };\n})();\n\nvar PrivateChannel = (function (_super) {\n    private_channel_extends(PrivateChannel, _super);\n    function PrivateChannel() {\n        return _super !== null && _super.apply(this, arguments) || this;\n    }\n    PrivateChannel.prototype.authorize = function (socketId, callback) {\n        return this.pusher.config.channelAuthorizer({\n            channelName: this.name,\n            socketId: socketId\n        }, callback);\n    };\n    return PrivateChannel;\n}(channels_channel));\n/* harmony default export */ var private_channel = (PrivateChannel);\n\n// CONCATENATED MODULE: ./src/core/channels/members.ts\n\nvar members_Members = (function () {\n    function Members() {\n        this.reset();\n    }\n    Members.prototype.get = function (id) {\n        if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n            return {\n                id: id,\n                info: this.members[id]\n            };\n        }\n        else {\n            return null;\n        }\n    };\n    Members.prototype.each = function (callback) {\n        var _this = this;\n        objectApply(this.members, function (member, id) {\n            callback(_this.get(id));\n        });\n    };\n    Members.prototype.setMyID = function (id) {\n        this.myID = id;\n    };\n    Members.prototype.onSubscription = function (subscriptionData) {\n        this.members = subscriptionData.presence.hash;\n        this.count = subscriptionData.presence.count;\n        this.me = this.get(this.myID);\n    };\n    Members.prototype.addMember = function (memberData) {\n        if (this.get(memberData.user_id) === null) {\n            this.count++;\n        }\n        this.members[memberData.user_id] = memberData.user_info;\n        return this.get(memberData.user_id);\n    };\n    Members.prototype.removeMember = function (memberData) {\n        var member = this.get(memberData.user_id);\n        if (member) {\n            delete this.members[memberData.user_id];\n            this.count--;\n        }\n        return member;\n    };\n    Members.prototype.reset = function () {\n        this.members = {};\n        this.count = 0;\n        this.myID = null;\n        this.me = null;\n    };\n    return Members;\n}());\n/* harmony default export */ var members = (members_Members);\n\n// CONCATENATED MODULE: ./src/core/channels/presence_channel.ts\nvar presence_channel_extends = ( false) || (function () {\n    var extendStatics = function (d, b) {\n        extendStatics = Object.setPrototypeOf ||\n            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n        return extendStatics(d, b);\n    };\n    return function (d, b) {\n        extendStatics(d, b);\n        function __() { this.constructor = d; }\n        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n    };\n})();\nvar __awaiter = ( false) || function (thisArg, _arguments, P, generator) {\n    return new (P || (P = Promise))(function (resolve, reject) {\n        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n        function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n        function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n        step((generator = generator.apply(thisArg, _arguments || [])).next());\n    });\n};\nvar __generator = ( false) || function (thisArg, body) {\n    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n    return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n    function verb(n) { return function (v) { return step([n, v]); }; }\n    function step(op) {\n        if (f) throw new TypeError(\"Generator is already executing.\");\n        while (_) try {\n            if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n            if (y = 0, t) op = [op[0] & 2, t.value];\n            switch (op[0]) {\n                case 0: case 1: t = op; break;\n                case 4: _.label++; return { value: op[1], done: false };\n                case 5: _.label++; y = op[1]; op = [0]; continue;\n                case 7: op = _.ops.pop(); _.trys.pop(); continue;\n                default:\n                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n                    if (t[2]) _.ops.pop();\n                    _.trys.pop(); continue;\n            }\n            op = body.call(thisArg, _);\n        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n    }\n};\n\n\n\n\nvar presence_channel_PresenceChannel = (function (_super) {\n    presence_channel_extends(PresenceChannel, _super);\n    function PresenceChannel(name, pusher) {\n        var _this = _super.call(this, name, pusher) || this;\n        _this.members = new members();\n        return _this;\n    }\n    PresenceChannel.prototype.authorize = function (socketId, callback) {\n        var _this = this;\n        _super.prototype.authorize.call(this, socketId, function (error, authData) { return __awaiter(_this, void 0, void 0, function () {\n            var channelData, suffix;\n            return __generator(this, function (_a) {\n                switch (_a.label) {\n                    case 0:\n                        if (!!error) return [3, 3];\n                        authData = authData;\n                        if (!(authData.channel_data != null)) return [3, 1];\n                        channelData = JSON.parse(authData.channel_data);\n                        this.members.setMyID(channelData.user_id);\n                        return [3, 3];\n                    case 1: return [4, this.pusher.user.signinDonePromise];\n                    case 2:\n                        _a.sent();\n                        if (this.pusher.user.user_data != null) {\n                            this.members.setMyID(this.pusher.user.user_data.id);\n                        }\n                        else {\n                            suffix = url_store.buildLogSuffix('authorizationEndpoint');\n                            logger.error(\"Invalid auth response for channel '\" + this.name + \"', \" +\n                                (\"expected 'channel_data' field. \" + suffix + \", \") +\n                                \"or the user should be signed in.\");\n                            callback('Invalid auth response');\n                            return [2];\n                        }\n                        _a.label = 3;\n                    case 3:\n                        callback(error, authData);\n                        return [2];\n                }\n            });\n        }); });\n    };\n    PresenceChannel.prototype.handleEvent = function (event) {\n        var eventName = event.event;\n        if (eventName.indexOf('pusher_internal:') === 0) {\n            this.handleInternalEvent(event);\n        }\n        else {\n            var data = event.data;\n            var metadata = {};\n            if (event.user_id) {\n                metadata.user_id = event.user_id;\n            }\n            this.emit(eventName, data, metadata);\n        }\n    };\n    PresenceChannel.prototype.handleInternalEvent = function (event) {\n        var eventName = event.event;\n        var data = event.data;\n        switch (eventName) {\n            case 'pusher_internal:subscription_succeeded':\n                this.handleSubscriptionSucceededEvent(event);\n                break;\n            case 'pusher_internal:subscription_count':\n                this.handleSubscriptionCountEvent(event);\n                break;\n            case 'pusher_internal:member_added':\n                var addedMember = this.members.addMember(data);\n                this.emit('pusher:member_added', addedMember);\n                break;\n            case 'pusher_internal:member_removed':\n                var removedMember = this.members.removeMember(data);\n                if (removedMember) {\n                    this.emit('pusher:member_removed', removedMember);\n                }\n                break;\n        }\n    };\n    PresenceChannel.prototype.handleSubscriptionSucceededEvent = function (event) {\n        this.subscriptionPending = false;\n        this.subscribed = true;\n        if (this.subscriptionCancelled) {\n            this.pusher.unsubscribe(this.name);\n        }\n        else {\n            this.members.onSubscription(event.data);\n            this.emit('pusher:subscription_succeeded', this.members);\n        }\n    };\n    PresenceChannel.prototype.disconnect = function () {\n        this.members.reset();\n        _super.prototype.disconnect.call(this);\n    };\n    return PresenceChannel;\n}(private_channel));\n/* harmony default export */ var presence_channel = (presence_channel_PresenceChannel);\n\n// EXTERNAL MODULE: ./node_modules/@stablelib/utf8/lib/utf8.js\nvar utf8 = __nested_webpack_require_20105__(1);\n\n// EXTERNAL MODULE: ./node_modules/@stablelib/base64/lib/base64.js\nvar base64 = __nested_webpack_require_20105__(0);\n\n// CONCATENATED MODULE: ./src/core/channels/encrypted_channel.ts\nvar encrypted_channel_extends = ( false) || (function () {\n    var extendStatics = function (d, b) {\n        extendStatics = Object.setPrototypeOf ||\n            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n        return extendStatics(d, b);\n    };\n    return function (d, b) {\n        extendStatics(d, b);\n        function __() { this.constructor = d; }\n        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n    };\n})();\n\n\n\n\n\nvar encrypted_channel_EncryptedChannel = (function (_super) {\n    encrypted_channel_extends(EncryptedChannel, _super);\n    function EncryptedChannel(name, pusher, nacl) {\n        var _this = _super.call(this, name, pusher) || this;\n        _this.key = null;\n        _this.nacl = nacl;\n        return _this;\n    }\n    EncryptedChannel.prototype.authorize = function (socketId, callback) {\n        var _this = this;\n        _super.prototype.authorize.call(this, socketId, function (error, authData) {\n            if (error) {\n                callback(error, authData);\n                return;\n            }\n            var sharedSecret = authData['shared_secret'];\n            if (!sharedSecret) {\n                callback(new Error(\"No shared_secret key in auth payload for encrypted channel: \" + _this.name), null);\n                return;\n            }\n            _this.key = Object(base64[\"decode\"])(sharedSecret);\n            delete authData['shared_secret'];\n            callback(null, authData);\n        });\n    };\n    EncryptedChannel.prototype.trigger = function (event, data) {\n        throw new UnsupportedFeature('Client events are not currently supported for encrypted channels');\n    };\n    EncryptedChannel.prototype.handleEvent = function (event) {\n        var eventName = event.event;\n        var data = event.data;\n        if (eventName.indexOf('pusher_internal:') === 0 ||\n            eventName.indexOf('pusher:') === 0) {\n            _super.prototype.handleEvent.call(this, event);\n            return;\n        }\n        this.handleEncryptedEvent(eventName, data);\n    };\n    EncryptedChannel.prototype.handleEncryptedEvent = function (event, data) {\n        var _this = this;\n        if (!this.key) {\n            logger.debug('Received encrypted event before key has been retrieved from the authEndpoint');\n            return;\n        }\n        if (!data.ciphertext || !data.nonce) {\n            logger.error('Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n                data);\n            return;\n        }\n        var cipherText = Object(base64[\"decode\"])(data.ciphertext);\n        if (cipherText.length < this.nacl.secretbox.overheadLength) {\n            logger.error(\"Expected encrypted event ciphertext length to be \" + this.nacl.secretbox.overheadLength + \", got: \" + cipherText.length);\n            return;\n        }\n        var nonce = Object(base64[\"decode\"])(data.nonce);\n        if (nonce.length < this.nacl.secretbox.nonceLength) {\n            logger.error(\"Expected encrypted event nonce length to be \" + this.nacl.secretbox.nonceLength + \", got: \" + nonce.length);\n            return;\n        }\n        var bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n        if (bytes === null) {\n            logger.debug('Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...');\n            this.authorize(this.pusher.connection.socket_id, function (error, authData) {\n                if (error) {\n                    logger.error(\"Failed to make a request to the authEndpoint: \" + authData + \". Unable to fetch new key, so dropping encrypted event\");\n                    return;\n                }\n                bytes = _this.nacl.secretbox.open(cipherText, nonce, _this.key);\n                if (bytes === null) {\n                    logger.error(\"Failed to decrypt event with new key. Dropping encrypted event\");\n                    return;\n                }\n                _this.emit(event, _this.getDataToEmit(bytes));\n                return;\n            });\n            return;\n        }\n        this.emit(event, this.getDataToEmit(bytes));\n    };\n    EncryptedChannel.prototype.getDataToEmit = function (bytes) {\n        var raw = Object(utf8[\"decode\"])(bytes);\n        try {\n            return JSON.parse(raw);\n        }\n        catch (_a) {\n            return raw;\n        }\n    };\n    return EncryptedChannel;\n}(private_channel));\n/* harmony default export */ var encrypted_channel = (encrypted_channel_EncryptedChannel);\n\n// CONCATENATED MODULE: ./src/core/connection/connection_manager.ts\nvar connection_manager_extends = ( false) || (function () {\n    var extendStatics = function (d, b) {\n        extendStatics = Object.setPrototypeOf ||\n            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n        return extendStatics(d, b);\n    };\n    return function (d, b) {\n        extendStatics(d, b);\n        function __() { this.constructor = d; }\n        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n    };\n})();\n\n\n\n\n\nvar connection_manager_ConnectionManager = (function (_super) {\n    connection_manager_extends(ConnectionManager, _super);\n    function ConnectionManager(key, options) {\n        var _this = _super.call(this) || this;\n        _this.state = 'initialized';\n        _this.connection = null;\n        _this.key = key;\n        _this.options = options;\n        _this.timeline = _this.options.timeline;\n        _this.usingTLS = _this.options.useTLS;\n        _this.errorCallbacks = _this.buildErrorCallbacks();\n        _this.connectionCallbacks = _this.buildConnectionCallbacks(_this.errorCallbacks);\n        _this.handshakeCallbacks = _this.buildHandshakeCallbacks(_this.errorCallbacks);\n        var Network = runtime.getNetwork();\n        Network.bind('online', function () {\n            _this.timeline.info({ netinfo: 'online' });\n            if (_this.state === 'connecting' || _this.state === 'unavailable') {\n                _this.retryIn(0);\n            }\n        });\n        Network.bind('offline', function () {\n            _this.timeline.info({ netinfo: 'offline' });\n            if (_this.connection) {\n                _this.sendActivityCheck();\n            }\n        });\n        _this.updateStrategy();\n        return _this;\n    }\n    ConnectionManager.prototype.connect = function () {\n        if (this.connection || this.runner) {\n            return;\n        }\n        if (!this.strategy.isSupported()) {\n            this.updateState('failed');\n            return;\n        }\n        this.updateState('connecting');\n        this.startConnecting();\n        this.setUnavailableTimer();\n    };\n    ConnectionManager.prototype.send = function (data) {\n        if (this.connection) {\n            return this.connection.send(data);\n        }\n        else {\n            return false;\n        }\n    };\n    ConnectionManager.prototype.send_event = function (name, data, channel) {\n        if (this.connection) {\n            return this.connection.send_event(name, data, channel);\n        }\n        else {\n            return false;\n        }\n    };\n    ConnectionManager.prototype.disconnect = function () {\n        this.disconnectInternally();\n        this.updateState('disconnected');\n    };\n    ConnectionManager.prototype.isUsingTLS = function () {\n        return this.usingTLS;\n    };\n    ConnectionManager.prototype.startConnecting = function () {\n        var _this = this;\n        var callback = function (error, handshake) {\n            if (error) {\n                _this.runner = _this.strategy.connect(0, callback);\n            }\n            else {\n                if (handshake.action === 'error') {\n                    _this.emit('error', {\n                        type: 'HandshakeError',\n                        error: handshake.error\n                    });\n                    _this.timeline.error({ handshakeError: handshake.error });\n                }\n                else {\n                    _this.abortConnecting();\n                    _this.handshakeCallbacks[handshake.action](handshake);\n                }\n            }\n        };\n        this.runner = this.strategy.connect(0, callback);\n    };\n    ConnectionManager.prototype.abortConnecting = function () {\n        if (this.runner) {\n            this.runner.abort();\n            this.runner = null;\n        }\n    };\n    ConnectionManager.prototype.disconnectInternally = function () {\n        this.abortConnecting();\n        this.clearRetryTimer();\n        this.clearUnavailableTimer();\n        if (this.connection) {\n            var connection = this.abandonConnection();\n            connection.close();\n        }\n    };\n    ConnectionManager.prototype.updateStrategy = function () {\n        this.strategy = this.options.getStrategy({\n            key: this.key,\n            timeline: this.timeline,\n            useTLS: this.usingTLS\n        });\n    };\n    ConnectionManager.prototype.retryIn = function (delay) {\n        var _this = this;\n        this.timeline.info({ action: 'retry', delay: delay });\n        if (delay > 0) {\n            this.emit('connecting_in', Math.round(delay / 1000));\n        }\n        this.retryTimer = new OneOffTimer(delay || 0, function () {\n            _this.disconnectInternally();\n            _this.connect();\n        });\n    };\n    ConnectionManager.prototype.clearRetryTimer = function () {\n        if (this.retryTimer) {\n            this.retryTimer.ensureAborted();\n            this.retryTimer = null;\n        }\n    };\n    ConnectionManager.prototype.setUnavailableTimer = function () {\n        var _this = this;\n        this.unavailableTimer = new OneOffTimer(this.options.unavailableTimeout, function () {\n            _this.updateState('unavailable');\n        });\n    };\n    ConnectionManager.prototype.clearUnavailableTimer = function () {\n        if (this.unavailableTimer) {\n            this.unavailableTimer.ensureAborted();\n        }\n    };\n    ConnectionManager.prototype.sendActivityCheck = function () {\n        var _this = this;\n        this.stopActivityCheck();\n        this.connection.ping();\n        this.activityTimer = new OneOffTimer(this.options.pongTimeout, function () {\n            _this.timeline.error({ pong_timed_out: _this.options.pongTimeout });\n            _this.retryIn(0);\n        });\n    };\n    ConnectionManager.prototype.resetActivityCheck = function () {\n        var _this = this;\n        this.stopActivityCheck();\n        if (this.connection && !this.connection.handlesActivityChecks()) {\n            this.activityTimer = new OneOffTimer(this.activityTimeout, function () {\n                _this.sendActivityCheck();\n            });\n        }\n    };\n    ConnectionManager.prototype.stopActivityCheck = function () {\n        if (this.activityTimer) {\n            this.activityTimer.ensureAborted();\n        }\n    };\n    ConnectionManager.prototype.buildConnectionCallbacks = function (errorCallbacks) {\n        var _this = this;\n        return extend({}, errorCallbacks, {\n            message: function (message) {\n                _this.resetActivityCheck();\n                _this.emit('message', message);\n            },\n            ping: function () {\n                _this.send_event('pusher:pong', {});\n            },\n            activity: function () {\n                _this.resetActivityCheck();\n            },\n            error: function (error) {\n                _this.emit('error', error);\n            },\n            closed: function () {\n                _this.abandonConnection();\n                if (_this.shouldRetry()) {\n                    _this.retryIn(1000);\n                }\n            }\n        });\n    };\n    ConnectionManager.prototype.buildHandshakeCallbacks = function (errorCallbacks) {\n        var _this = this;\n        return extend({}, errorCallbacks, {\n            connected: function (handshake) {\n                _this.activityTimeout = Math.min(_this.options.activityTimeout, handshake.activityTimeout, handshake.connection.activityTimeout || Infinity);\n                _this.clearUnavailableTimer();\n                _this.setConnection(handshake.connection);\n                _this.socket_id = _this.connection.id;\n                _this.updateState('connected', { socket_id: _this.socket_id });\n            }\n        });\n    };\n    ConnectionManager.prototype.buildErrorCallbacks = function () {\n        var _this = this;\n        var withErrorEmitted = function (callback) {\n            return function (result) {\n                if (result.error) {\n                    _this.emit('error', { type: 'WebSocketError', error: result.error });\n                }\n                callback(result);\n            };\n        };\n        return {\n            tls_only: withErrorEmitted(function () {\n                _this.usingTLS = true;\n                _this.updateStrategy();\n                _this.retryIn(0);\n            }),\n            refused: withErrorEmitted(function () {\n                _this.disconnect();\n            }),\n            backoff: withErrorEmitted(function () {\n                _this.retryIn(1000);\n            }),\n            retry: withErrorEmitted(function () {\n                _this.retryIn(0);\n            })\n        };\n    };\n    ConnectionManager.prototype.setConnection = function (connection) {\n        this.connection = connection;\n        for (var event in this.connectionCallbacks) {\n            this.connection.bind(event, this.connectionCallbacks[event]);\n        }\n        this.resetActivityCheck();\n    };\n    ConnectionManager.prototype.abandonConnection = function () {\n        if (!this.connection) {\n            return;\n        }\n        this.stopActivityCheck();\n        for (var event in this.connectionCallbacks) {\n            this.connection.unbind(event, this.connectionCallbacks[event]);\n        }\n        var connection = this.connection;\n        this.connection = null;\n        return connection;\n    };\n    ConnectionManager.prototype.updateState = function (newState, data) {\n        var previousState = this.state;\n        this.state = newState;\n        if (previousState !== newState) {\n            var newStateDescription = newState;\n            if (newStateDescription === 'connected') {\n                newStateDescription += ' with new socket ID ' + data.socket_id;\n            }\n            logger.debug('State changed', previousState + ' -> ' + newStateDescription);\n            this.timeline.info({ state: newState, params: data });\n            this.emit('state_change', { previous: previousState, current: newState });\n            this.emit(newState, data);\n        }\n    };\n    ConnectionManager.prototype.shouldRetry = function () {\n        return this.state === 'connecting' || this.state === 'connected';\n    };\n    return ConnectionManager;\n}(dispatcher));\n/* harmony default export */ var connection_manager = (connection_manager_ConnectionManager);\n\n// CONCATENATED MODULE: ./src/core/channels/channels.ts\n\n\n\n\nvar channels_Channels = (function () {\n    function Channels() {\n        this.channels = {};\n    }\n    Channels.prototype.add = function (name, pusher) {\n        if (!this.channels[name]) {\n            this.channels[name] = createChannel(name, pusher);\n        }\n        return this.channels[name];\n    };\n    Channels.prototype.all = function () {\n        return values(this.channels);\n    };\n    Channels.prototype.find = function (name) {\n        return this.channels[name];\n    };\n    Channels.prototype.remove = function (name) {\n        var channel = this.channels[name];\n        delete this.channels[name];\n        return channel;\n    };\n    Channels.prototype.disconnect = function () {\n        objectApply(this.channels, function (channel) {\n            channel.disconnect();\n        });\n    };\n    return Channels;\n}());\n/* harmony default export */ var channels = (channels_Channels);\nfunction createChannel(name, pusher) {\n    if (name.indexOf('private-encrypted-') === 0) {\n        if (pusher.config.nacl) {\n            return factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n        }\n        var errMsg = 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n        var suffix = url_store.buildLogSuffix('encryptedChannelSupport');\n        throw new UnsupportedFeature(errMsg + \". \" + suffix);\n    }\n    else if (name.indexOf('private-') === 0) {\n        return factory.createPrivateChannel(name, pusher);\n    }\n    else if (name.indexOf('presence-') === 0) {\n        return factory.createPresenceChannel(name, pusher);\n    }\n    else if (name.indexOf('#') === 0) {\n        throw new BadChannelName('Cannot create a channel with name \"' + name + '\".');\n    }\n    else {\n        return factory.createChannel(name, pusher);\n    }\n}\n\n// CONCATENATED MODULE: ./src/core/utils/factory.ts\n\n\n\n\n\n\n\n\n\nvar Factory = {\n    createChannels: function () {\n        return new channels();\n    },\n    createConnectionManager: function (key, options) {\n        return new connection_manager(key, options);\n    },\n    createChannel: function (name, pusher) {\n        return new channels_channel(name, pusher);\n    },\n    createPrivateChannel: function (name, pusher) {\n        return new private_channel(name, pusher);\n    },\n    createPresenceChannel: function (name, pusher) {\n        return new presence_channel(name, pusher);\n    },\n    createEncryptedChannel: function (name, pusher, nacl) {\n        return new encrypted_channel(name, pusher, nacl);\n    },\n    createTimelineSender: function (timeline, options) {\n        return new timeline_sender(timeline, options);\n    },\n    createHandshake: function (transport, callback) {\n        return new connection_handshake(transport, callback);\n    },\n    createAssistantToTheTransportManager: function (manager, transport, options) {\n        return new assistant_to_the_transport_manager(manager, transport, options);\n    }\n};\n/* harmony default export */ var factory = (Factory);\n\n// CONCATENATED MODULE: ./src/core/transports/transport_manager.ts\n\nvar transport_manager_TransportManager = (function () {\n    function TransportManager(options) {\n        this.options = options || {};\n        this.livesLeft = this.options.lives || Infinity;\n    }\n    TransportManager.prototype.getAssistant = function (transport) {\n        return factory.createAssistantToTheTransportManager(this, transport, {\n            minPingDelay: this.options.minPingDelay,\n            maxPingDelay: this.options.maxPingDelay\n        });\n    };\n    TransportManager.prototype.isAlive = function () {\n        return this.livesLeft > 0;\n    };\n    TransportManager.prototype.reportDeath = function () {\n        this.livesLeft -= 1;\n    };\n    return TransportManager;\n}());\n/* harmony default export */ var transport_manager = (transport_manager_TransportManager);\n\n// CONCATENATED MODULE: ./src/core/strategies/sequential_strategy.ts\n\n\n\nvar sequential_strategy_SequentialStrategy = (function () {\n    function SequentialStrategy(strategies, options) {\n        this.strategies = strategies;\n        this.loop = Boolean(options.loop);\n        this.failFast = Boolean(options.failFast);\n        this.timeout = options.timeout;\n        this.timeoutLimit = options.timeoutLimit;\n    }\n    SequentialStrategy.prototype.isSupported = function () {\n        return any(this.strategies, util.method('isSupported'));\n    };\n    SequentialStrategy.prototype.connect = function (minPriority, callback) {\n        var _this = this;\n        var strategies = this.strategies;\n        var current = 0;\n        var timeout = this.timeout;\n        var runner = null;\n        var tryNextStrategy = function (error, handshake) {\n            if (handshake) {\n                callback(null, handshake);\n            }\n            else {\n                current = current + 1;\n                if (_this.loop) {\n                    current = current % strategies.length;\n                }\n                if (current < strategies.length) {\n                    if (timeout) {\n                        timeout = timeout * 2;\n                        if (_this.timeoutLimit) {\n                            timeout = Math.min(timeout, _this.timeoutLimit);\n                        }\n                    }\n                    runner = _this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: _this.failFast }, tryNextStrategy);\n                }\n                else {\n                    callback(true);\n                }\n            }\n        };\n        runner = this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: this.failFast }, tryNextStrategy);\n        return {\n            abort: function () {\n                runner.abort();\n            },\n            forceMinPriority: function (p) {\n                minPriority = p;\n                if (runner) {\n                    runner.forceMinPriority(p);\n                }\n            }\n        };\n    };\n    SequentialStrategy.prototype.tryStrategy = function (strategy, minPriority, options, callback) {\n        var timer = null;\n        var runner = null;\n        if (options.timeout > 0) {\n            timer = new OneOffTimer(options.timeout, function () {\n                runner.abort();\n                callback(true);\n            });\n        }\n        runner = strategy.connect(minPriority, function (error, handshake) {\n            if (error && timer && timer.isRunning() && !options.failFast) {\n                return;\n            }\n            if (timer) {\n                timer.ensureAborted();\n            }\n            callback(error, handshake);\n        });\n        return {\n            abort: function () {\n                if (timer) {\n                    timer.ensureAborted();\n                }\n                runner.abort();\n            },\n            forceMinPriority: function (p) {\n                runner.forceMinPriority(p);\n            }\n        };\n    };\n    return SequentialStrategy;\n}());\n/* harmony default export */ var sequential_strategy = (sequential_strategy_SequentialStrategy);\n\n// CONCATENATED MODULE: ./src/core/strategies/best_connected_ever_strategy.ts\n\n\nvar best_connected_ever_strategy_BestConnectedEverStrategy = (function () {\n    function BestConnectedEverStrategy(strategies) {\n        this.strategies = strategies;\n    }\n    BestConnectedEverStrategy.prototype.isSupported = function () {\n        return any(this.strategies, util.method('isSupported'));\n    };\n    BestConnectedEverStrategy.prototype.connect = function (minPriority, callback) {\n        return connect(this.strategies, minPriority, function (i, runners) {\n            return function (error, handshake) {\n                runners[i].error = error;\n                if (error) {\n                    if (allRunnersFailed(runners)) {\n                        callback(true);\n                    }\n                    return;\n                }\n                apply(runners, function (runner) {\n                    runner.forceMinPriority(handshake.transport.priority);\n                });\n                callback(null, handshake);\n            };\n        });\n    };\n    return BestConnectedEverStrategy;\n}());\n/* harmony default export */ var best_connected_ever_strategy = (best_connected_ever_strategy_BestConnectedEverStrategy);\nfunction connect(strategies, minPriority, callbackBuilder) {\n    var runners = map(strategies, function (strategy, i, _, rs) {\n        return strategy.connect(minPriority, callbackBuilder(i, rs));\n    });\n    return {\n        abort: function () {\n            apply(runners, abortRunner);\n        },\n        forceMinPriority: function (p) {\n            apply(runners, function (runner) {\n                runner.forceMinPriority(p);\n            });\n        }\n    };\n}\nfunction allRunnersFailed(runners) {\n    return collections_all(runners, function (runner) {\n        return Boolean(runner.error);\n    });\n}\nfunction abortRunner(runner) {\n    if (!runner.error && !runner.aborted) {\n        runner.abort();\n        runner.aborted = true;\n    }\n}\n\n// CONCATENATED MODULE: ./src/core/strategies/cached_strategy.ts\n\n\n\n\nvar cached_strategy_CachedStrategy = (function () {\n    function CachedStrategy(strategy, transports, options) {\n        this.strategy = strategy;\n        this.transports = transports;\n        this.ttl = options.ttl || 1800 * 1000;\n        this.usingTLS = options.useTLS;\n        this.timeline = options.timeline;\n    }\n    CachedStrategy.prototype.isSupported = function () {\n        return this.strategy.isSupported();\n    };\n    CachedStrategy.prototype.connect = function (minPriority, callback) {\n        var usingTLS = this.usingTLS;\n        var info = fetchTransportCache(usingTLS);\n        var strategies = [this.strategy];\n        if (info && info.timestamp + this.ttl >= util.now()) {\n            var transport = this.transports[info.transport];\n            if (transport) {\n                this.timeline.info({\n                    cached: true,\n                    transport: info.transport,\n                    latency: info.latency\n                });\n                strategies.push(new sequential_strategy([transport], {\n                    timeout: info.latency * 2 + 1000,\n                    failFast: true\n                }));\n            }\n        }\n        var startTimestamp = util.now();\n        var runner = strategies\n            .pop()\n            .connect(minPriority, function cb(error, handshake) {\n            if (error) {\n                flushTransportCache(usingTLS);\n                if (strategies.length > 0) {\n                    startTimestamp = util.now();\n                    runner = strategies.pop().connect(minPriority, cb);\n                }\n                else {\n                    callback(error);\n                }\n            }\n            else {\n                storeTransportCache(usingTLS, handshake.transport.name, util.now() - startTimestamp);\n                callback(null, handshake);\n            }\n        });\n        return {\n            abort: function () {\n                runner.abort();\n            },\n            forceMinPriority: function (p) {\n                minPriority = p;\n                if (runner) {\n                    runner.forceMinPriority(p);\n                }\n            }\n        };\n    };\n    return CachedStrategy;\n}());\n/* harmony default export */ var cached_strategy = (cached_strategy_CachedStrategy);\nfunction getTransportCacheKey(usingTLS) {\n    return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\nfunction fetchTransportCache(usingTLS) {\n    var storage = runtime.getLocalStorage();\n    if (storage) {\n        try {\n            var serializedCache = storage[getTransportCacheKey(usingTLS)];\n            if (serializedCache) {\n                return JSON.parse(serializedCache);\n            }\n        }\n        catch (e) {\n            flushTransportCache(usingTLS);\n        }\n    }\n    return null;\n}\nfunction storeTransportCache(usingTLS, transport, latency) {\n    var storage = runtime.getLocalStorage();\n    if (storage) {\n        try {\n            storage[getTransportCacheKey(usingTLS)] = safeJSONStringify({\n                timestamp: util.now(),\n                transport: transport,\n                latency: latency\n            });\n        }\n        catch (e) {\n        }\n    }\n}\nfunction flushTransportCache(usingTLS) {\n    var storage = runtime.getLocalStorage();\n    if (storage) {\n        try {\n            delete storage[getTransportCacheKey(usingTLS)];\n        }\n        catch (e) {\n        }\n    }\n}\n\n// CONCATENATED MODULE: ./src/core/strategies/delayed_strategy.ts\n\nvar delayed_strategy_DelayedStrategy = (function () {\n    function DelayedStrategy(strategy, _a) {\n        var number = _a.delay;\n        this.strategy = strategy;\n        this.options = { delay: number };\n    }\n    DelayedStrategy.prototype.isSupported = function () {\n        return this.strategy.isSupported();\n    };\n    DelayedStrategy.prototype.connect = function (minPriority, callback) {\n        var strategy = this.strategy;\n        var runner;\n        var timer = new OneOffTimer(this.options.delay, function () {\n            runner = strategy.connect(minPriority, callback);\n        });\n        return {\n            abort: function () {\n                timer.ensureAborted();\n                if (runner) {\n                    runner.abort();\n                }\n            },\n            forceMinPriority: function (p) {\n                minPriority = p;\n                if (runner) {\n                    runner.forceMinPriority(p);\n                }\n            }\n        };\n    };\n    return DelayedStrategy;\n}());\n/* harmony default export */ var delayed_strategy = (delayed_strategy_DelayedStrategy);\n\n// CONCATENATED MODULE: ./src/core/strategies/if_strategy.ts\nvar IfStrategy = (function () {\n    function IfStrategy(test, trueBranch, falseBranch) {\n        this.test = test;\n        this.trueBranch = trueBranch;\n        this.falseBranch = falseBranch;\n    }\n    IfStrategy.prototype.isSupported = function () {\n        var branch = this.test() ? this.trueBranch : this.falseBranch;\n        return branch.isSupported();\n    };\n    IfStrategy.prototype.connect = function (minPriority, callback) {\n        var branch = this.test() ? this.trueBranch : this.falseBranch;\n        return branch.connect(minPriority, callback);\n    };\n    return IfStrategy;\n}());\n/* harmony default export */ var if_strategy = (IfStrategy);\n\n// CONCATENATED MODULE: ./src/core/strategies/first_connected_strategy.ts\nvar FirstConnectedStrategy = (function () {\n    function FirstConnectedStrategy(strategy) {\n        this.strategy = strategy;\n    }\n    FirstConnectedStrategy.prototype.isSupported = function () {\n        return this.strategy.isSupported();\n    };\n    FirstConnectedStrategy.prototype.connect = function (minPriority, callback) {\n        var runner = this.strategy.connect(minPriority, function (error, handshake) {\n            if (handshake) {\n                runner.abort();\n            }\n            callback(error, handshake);\n        });\n        return runner;\n    };\n    return FirstConnectedStrategy;\n}());\n/* harmony default export */ var first_connected_strategy = (FirstConnectedStrategy);\n\n// CONCATENATED MODULE: ./src/runtimes/web/default_strategy.ts\n\n\n\n\n\n\n\nfunction testSupportsStrategy(strategy) {\n    return function () {\n        return strategy.isSupported();\n    };\n}\nvar getDefaultStrategy = function (config, baseOptions, defineTransport) {\n    var definedTransports = {};\n    function defineTransportStrategy(name, type, priority, options, manager) {\n        var transport = defineTransport(config, name, type, priority, options, manager);\n        definedTransports[name] = transport;\n        return transport;\n    }\n    var ws_options = Object.assign({}, baseOptions, {\n        hostNonTLS: config.wsHost + ':' + config.wsPort,\n        hostTLS: config.wsHost + ':' + config.wssPort,\n        httpPath: config.wsPath\n    });\n    var wss_options = Object.assign({}, ws_options, {\n        useTLS: true\n    });\n    var sockjs_options = Object.assign({}, baseOptions, {\n        hostNonTLS: config.httpHost + ':' + config.httpPort,\n        hostTLS: config.httpHost + ':' + config.httpsPort,\n        httpPath: config.httpPath\n    });\n    var timeouts = {\n        loop: true,\n        timeout: 15000,\n        timeoutLimit: 60000\n    };\n    var ws_manager = new transport_manager({\n        lives: 2,\n        minPingDelay: 10000,\n        maxPingDelay: config.activityTimeout\n    });\n    var streaming_manager = new transport_manager({\n        lives: 2,\n        minPingDelay: 10000,\n        maxPingDelay: config.activityTimeout\n    });\n    var ws_transport = defineTransportStrategy('ws', 'ws', 3, ws_options, ws_manager);\n    var wss_transport = defineTransportStrategy('wss', 'ws', 3, wss_options, ws_manager);\n    var sockjs_transport = defineTransportStrategy('sockjs', 'sockjs', 1, sockjs_options);\n    var xhr_streaming_transport = defineTransportStrategy('xhr_streaming', 'xhr_streaming', 1, sockjs_options, streaming_manager);\n    var xdr_streaming_transport = defineTransportStrategy('xdr_streaming', 'xdr_streaming', 1, sockjs_options, streaming_manager);\n    var xhr_polling_transport = defineTransportStrategy('xhr_polling', 'xhr_polling', 1, sockjs_options);\n    var xdr_polling_transport = defineTransportStrategy('xdr_polling', 'xdr_polling', 1, sockjs_options);\n    var ws_loop = new sequential_strategy([ws_transport], timeouts);\n    var wss_loop = new sequential_strategy([wss_transport], timeouts);\n    var sockjs_loop = new sequential_strategy([sockjs_transport], timeouts);\n    var streaming_loop = new sequential_strategy([\n        new if_strategy(testSupportsStrategy(xhr_streaming_transport), xhr_streaming_transport, xdr_streaming_transport)\n    ], timeouts);\n    var polling_loop = new sequential_strategy([\n        new if_strategy(testSupportsStrategy(xhr_polling_transport), xhr_polling_transport, xdr_polling_transport)\n    ], timeouts);\n    var http_loop = new sequential_strategy([\n        new if_strategy(testSupportsStrategy(streaming_loop), new best_connected_ever_strategy([\n            streaming_loop,\n            new delayed_strategy(polling_loop, { delay: 4000 })\n        ]), polling_loop)\n    ], timeouts);\n    var http_fallback_loop = new if_strategy(testSupportsStrategy(http_loop), http_loop, sockjs_loop);\n    var wsStrategy;\n    if (baseOptions.useTLS) {\n        wsStrategy = new best_connected_ever_strategy([\n            ws_loop,\n            new delayed_strategy(http_fallback_loop, { delay: 2000 })\n        ]);\n    }\n    else {\n        wsStrategy = new best_connected_ever_strategy([\n            ws_loop,\n            new delayed_strategy(wss_loop, { delay: 2000 }),\n            new delayed_strategy(http_fallback_loop, { delay: 5000 })\n        ]);\n    }\n    return new cached_strategy(new first_connected_strategy(new if_strategy(testSupportsStrategy(ws_transport), wsStrategy, http_fallback_loop)), definedTransports, {\n        ttl: 1800000,\n        timeline: baseOptions.timeline,\n        useTLS: baseOptions.useTLS\n    });\n};\n/* harmony default export */ var default_strategy = (getDefaultStrategy);\n\n// CONCATENATED MODULE: ./src/runtimes/web/transports/transport_connection_initializer.ts\n\n/* harmony default export */ var transport_connection_initializer = (function () {\n    var self = this;\n    self.timeline.info(self.buildTimelineMessage({\n        transport: self.name + (self.options.useTLS ? 's' : '')\n    }));\n    if (self.hooks.isInitialized()) {\n        self.changeState('initialized');\n    }\n    else if (self.hooks.file) {\n        self.changeState('initializing');\n        Dependencies.load(self.hooks.file, { useTLS: self.options.useTLS }, function (error, callback) {\n            if (self.hooks.isInitialized()) {\n                self.changeState('initialized');\n                callback(true);\n            }\n            else {\n                if (error) {\n                    self.onError(error);\n                }\n                self.onClose();\n                callback(false);\n            }\n        });\n    }\n    else {\n        self.onClose();\n    }\n});\n\n// CONCATENATED MODULE: ./src/runtimes/web/http/http_xdomain_request.ts\n\nvar http_xdomain_request_hooks = {\n    getRequest: function (socket) {\n        var xdr = new window.XDomainRequest();\n        xdr.ontimeout = function () {\n            socket.emit('error', new RequestTimedOut());\n            socket.close();\n        };\n        xdr.onerror = function (e) {\n            socket.emit('error', e);\n            socket.close();\n        };\n        xdr.onprogress = function () {\n            if (xdr.responseText && xdr.responseText.length > 0) {\n                socket.onChunk(200, xdr.responseText);\n            }\n        };\n        xdr.onload = function () {\n            if (xdr.responseText && xdr.responseText.length > 0) {\n                socket.onChunk(200, xdr.responseText);\n            }\n            socket.emit('finished', 200);\n            socket.close();\n        };\n        return xdr;\n    },\n    abortRequest: function (xdr) {\n        xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;\n        xdr.abort();\n    }\n};\n/* harmony default export */ var http_xdomain_request = (http_xdomain_request_hooks);\n\n// CONCATENATED MODULE: ./src/core/http/http_request.ts\nvar http_request_extends = ( false) || (function () {\n    var extendStatics = function (d, b) {\n        extendStatics = Object.setPrototypeOf ||\n            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n        return extendStatics(d, b);\n    };\n    return function (d, b) {\n        extendStatics(d, b);\n        function __() { this.constructor = d; }\n        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n    };\n})();\n\n\nvar MAX_BUFFER_LENGTH = 256 * 1024;\nvar http_request_HTTPRequest = (function (_super) {\n    http_request_extends(HTTPRequest, _super);\n    function HTTPRequest(hooks, method, url) {\n        var _this = _super.call(this) || this;\n        _this.hooks = hooks;\n        _this.method = method;\n        _this.url = url;\n        return _this;\n    }\n    HTTPRequest.prototype.start = function (payload) {\n        var _this = this;\n        this.position = 0;\n        this.xhr = this.hooks.getRequest(this);\n        this.unloader = function () {\n            _this.close();\n        };\n        runtime.addUnloadListener(this.unloader);\n        this.xhr.open(this.method, this.url, true);\n        if (this.xhr.setRequestHeader) {\n            this.xhr.setRequestHeader('Content-Type', 'application/json');\n        }\n        this.xhr.send(payload);\n    };\n    HTTPRequest.prototype.close = function () {\n        if (this.unloader) {\n            runtime.removeUnloadListener(this.unloader);\n            this.unloader = null;\n        }\n        if (this.xhr) {\n            this.hooks.abortRequest(this.xhr);\n            this.xhr = null;\n        }\n    };\n    HTTPRequest.prototype.onChunk = function (status, data) {\n        while (true) {\n            var chunk = this.advanceBuffer(data);\n            if (chunk) {\n                this.emit('chunk', { status: status, data: chunk });\n            }\n            else {\n                break;\n            }\n        }\n        if (this.isBufferTooLong(data)) {\n            this.emit('buffer_too_long');\n        }\n    };\n    HTTPRequest.prototype.advanceBuffer = function (buffer) {\n        var unreadData = buffer.slice(this.position);\n        var endOfLinePosition = unreadData.indexOf('\\n');\n        if (endOfLinePosition !== -1) {\n            this.position += endOfLinePosition + 1;\n            return unreadData.slice(0, endOfLinePosition);\n        }\n        else {\n            return null;\n        }\n    };\n    HTTPRequest.prototype.isBufferTooLong = function (buffer) {\n        return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n    };\n    return HTTPRequest;\n}(dispatcher));\n/* harmony default export */ var http_request = (http_request_HTTPRequest);\n\n// CONCATENATED MODULE: ./src/core/http/state.ts\nvar State;\n(function (State) {\n    State[State[\"CONNECTING\"] = 0] = \"CONNECTING\";\n    State[State[\"OPEN\"] = 1] = \"OPEN\";\n    State[State[\"CLOSED\"] = 3] = \"CLOSED\";\n})(State || (State = {}));\n/* harmony default export */ var state = (State);\n\n// CONCATENATED MODULE: ./src/core/http/http_socket.ts\n\n\n\nvar autoIncrement = 1;\nvar http_socket_HTTPSocket = (function () {\n    function HTTPSocket(hooks, url) {\n        this.hooks = hooks;\n        this.session = randomNumber(1000) + '/' + randomString(8);\n        this.location = getLocation(url);\n        this.readyState = state.CONNECTING;\n        this.openStream();\n    }\n    HTTPSocket.prototype.send = function (payload) {\n        return this.sendRaw(JSON.stringify([payload]));\n    };\n    HTTPSocket.prototype.ping = function () {\n        this.hooks.sendHeartbeat(this);\n    };\n    HTTPSocket.prototype.close = function (code, reason) {\n        this.onClose(code, reason, true);\n    };\n    HTTPSocket.prototype.sendRaw = function (payload) {\n        if (this.readyState === state.OPEN) {\n            try {\n                runtime.createSocketRequest('POST', getUniqueURL(getSendURL(this.location, this.session))).start(payload);\n                return true;\n            }\n            catch (e) {\n                return false;\n            }\n        }\n        else {\n            return false;\n        }\n    };\n    HTTPSocket.prototype.reconnect = function () {\n        this.closeStream();\n        this.openStream();\n    };\n    HTTPSocket.prototype.onClose = function (code, reason, wasClean) {\n        this.closeStream();\n        this.readyState = state.CLOSED;\n        if (this.onclose) {\n            this.onclose({\n                code: code,\n                reason: reason,\n                wasClean: wasClean\n            });\n        }\n    };\n    HTTPSocket.prototype.onChunk = function (chunk) {\n        if (chunk.status !== 200) {\n            return;\n        }\n        if (this.readyState === state.OPEN) {\n            this.onActivity();\n        }\n        var payload;\n        var type = chunk.data.slice(0, 1);\n        switch (type) {\n            case 'o':\n                payload = JSON.parse(chunk.data.slice(1) || '{}');\n                this.onOpen(payload);\n                break;\n            case 'a':\n                payload = JSON.parse(chunk.data.slice(1) || '[]');\n                for (var i = 0; i < payload.length; i++) {\n                    this.onEvent(payload[i]);\n                }\n                break;\n            case 'm':\n                payload = JSON.parse(chunk.data.slice(1) || 'null');\n                this.onEvent(payload);\n                break;\n            case 'h':\n                this.hooks.onHeartbeat(this);\n                break;\n            case 'c':\n                payload = JSON.parse(chunk.data.slice(1) || '[]');\n                this.onClose(payload[0], payload[1], true);\n                break;\n        }\n    };\n    HTTPSocket.prototype.onOpen = function (options) {\n        if (this.readyState === state.CONNECTING) {\n            if (options && options.hostname) {\n                this.location.base = replaceHost(this.location.base, options.hostname);\n            }\n            this.readyState = state.OPEN;\n            if (this.onopen) {\n                this.onopen();\n            }\n        }\n        else {\n            this.onClose(1006, 'Server lost session', true);\n        }\n    };\n    HTTPSocket.prototype.onEvent = function (event) {\n        if (this.readyState === state.OPEN && this.onmessage) {\n            this.onmessage({ data: event });\n        }\n    };\n    HTTPSocket.prototype.onActivity = function () {\n        if (this.onactivity) {\n            this.onactivity();\n        }\n    };\n    HTTPSocket.prototype.onError = function (error) {\n        if (this.onerror) {\n            this.onerror(error);\n        }\n    };\n    HTTPSocket.prototype.openStream = function () {\n        var _this = this;\n        this.stream = runtime.createSocketRequest('POST', getUniqueURL(this.hooks.getReceiveURL(this.location, this.session)));\n        this.stream.bind('chunk', function (chunk) {\n            _this.onChunk(chunk);\n        });\n        this.stream.bind('finished', function (status) {\n            _this.hooks.onFinished(_this, status);\n        });\n        this.stream.bind('buffer_too_long', function () {\n            _this.reconnect();\n        });\n        try {\n            this.stream.start();\n        }\n        catch (error) {\n            util.defer(function () {\n                _this.onError(error);\n                _this.onClose(1006, 'Could not start streaming', false);\n            });\n        }\n    };\n    HTTPSocket.prototype.closeStream = function () {\n        if (this.stream) {\n            this.stream.unbind_all();\n            this.stream.close();\n            this.stream = null;\n        }\n    };\n    return HTTPSocket;\n}());\nfunction getLocation(url) {\n    var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n    return {\n        base: parts[1],\n        queryString: parts[2]\n    };\n}\nfunction getSendURL(url, session) {\n    return url.base + '/' + session + '/xhr_send';\n}\nfunction getUniqueURL(url) {\n    var separator = url.indexOf('?') === -1 ? '?' : '&';\n    return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\nfunction replaceHost(url, hostname) {\n    var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n    return urlParts[1] + hostname + urlParts[3];\n}\nfunction randomNumber(max) {\n    return Math.floor(Math.random() * max);\n}\nfunction randomString(length) {\n    var result = [];\n    for (var i = 0; i < length; i++) {\n        result.push(randomNumber(32).toString(32));\n    }\n    return result.join('');\n}\n/* harmony default export */ var http_socket = (http_socket_HTTPSocket);\n\n// CONCATENATED MODULE: ./src/core/http/http_streaming_socket.ts\nvar http_streaming_socket_hooks = {\n    getReceiveURL: function (url, session) {\n        return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n    },\n    onHeartbeat: function (socket) {\n        socket.sendRaw('[]');\n    },\n    sendHeartbeat: function (socket) {\n        socket.sendRaw('[]');\n    },\n    onFinished: function (socket, status) {\n        socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n    }\n};\n/* harmony default export */ var http_streaming_socket = (http_streaming_socket_hooks);\n\n// CONCATENATED MODULE: ./src/core/http/http_polling_socket.ts\nvar http_polling_socket_hooks = {\n    getReceiveURL: function (url, session) {\n        return url.base + '/' + session + '/xhr' + url.queryString;\n    },\n    onHeartbeat: function () {\n    },\n    sendHeartbeat: function (socket) {\n        socket.sendRaw('[]');\n    },\n    onFinished: function (socket, status) {\n        if (status === 200) {\n            socket.reconnect();\n        }\n        else {\n            socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n        }\n    }\n};\n/* harmony default export */ var http_polling_socket = (http_polling_socket_hooks);\n\n// CONCATENATED MODULE: ./src/runtimes/isomorphic/http/http_xhr_request.ts\n\nvar http_xhr_request_hooks = {\n    getRequest: function (socket) {\n        var Constructor = runtime.getXHRAPI();\n        var xhr = new Constructor();\n        xhr.onreadystatechange = xhr.onprogress = function () {\n            switch (xhr.readyState) {\n                case 3:\n                    if (xhr.responseText && xhr.responseText.length > 0) {\n                        socket.onChunk(xhr.status, xhr.responseText);\n                    }\n                    break;\n                case 4:\n                    if (xhr.responseText && xhr.responseText.length > 0) {\n                        socket.onChunk(xhr.status, xhr.responseText);\n                    }\n                    socket.emit('finished', xhr.status);\n                    socket.close();\n                    break;\n            }\n        };\n        return xhr;\n    },\n    abortRequest: function (xhr) {\n        xhr.onreadystatechange = null;\n        xhr.abort();\n    }\n};\n/* harmony default export */ var http_xhr_request = (http_xhr_request_hooks);\n\n// CONCATENATED MODULE: ./src/runtimes/isomorphic/http/http.ts\n\n\n\n\n\nvar HTTP = {\n    createStreamingSocket: function (url) {\n        return this.createSocket(http_streaming_socket, url);\n    },\n    createPollingSocket: function (url) {\n        return this.createSocket(http_polling_socket, url);\n    },\n    createSocket: function (hooks, url) {\n        return new http_socket(hooks, url);\n    },\n    createXHR: function (method, url) {\n        return this.createRequest(http_xhr_request, method, url);\n    },\n    createRequest: function (hooks, method, url) {\n        return new http_request(hooks, method, url);\n    }\n};\n/* harmony default export */ var http_http = (HTTP);\n\n// CONCATENATED MODULE: ./src/runtimes/web/http/http.ts\n\n\nhttp_http.createXDR = function (method, url) {\n    return this.createRequest(http_xdomain_request, method, url);\n};\n/* harmony default export */ var web_http_http = (http_http);\n\n// CONCATENATED MODULE: ./src/runtimes/web/runtime.ts\n\n\n\n\n\n\n\n\n\n\n\n\nvar Runtime = {\n    nextAuthCallbackID: 1,\n    auth_callbacks: {},\n    ScriptReceivers: ScriptReceivers,\n    DependenciesReceivers: DependenciesReceivers,\n    getDefaultStrategy: default_strategy,\n    Transports: transports_transports,\n    transportConnectionInitializer: transport_connection_initializer,\n    HTTPFactory: web_http_http,\n    TimelineTransport: jsonp_timeline,\n    getXHRAPI: function () {\n        return window.XMLHttpRequest;\n    },\n    getWebSocketAPI: function () {\n        return window.WebSocket || window.MozWebSocket;\n    },\n    setup: function (PusherClass) {\n        var _this = this;\n        window.Pusher = PusherClass;\n        var initializeOnDocumentBody = function () {\n            _this.onDocumentBody(PusherClass.ready);\n        };\n        if (!window.JSON) {\n            Dependencies.load('json2', {}, initializeOnDocumentBody);\n        }\n        else {\n            initializeOnDocumentBody();\n        }\n    },\n    getDocument: function () {\n        return document;\n    },\n    getProtocol: function () {\n        return this.getDocument().location.protocol;\n    },\n    getAuthorizers: function () {\n        return { ajax: xhr_auth, jsonp: jsonp_auth };\n    },\n    onDocumentBody: function (callback) {\n        var _this = this;\n        if (document.body) {\n            callback();\n        }\n        else {\n            setTimeout(function () {\n                _this.onDocumentBody(callback);\n            }, 0);\n        }\n    },\n    createJSONPRequest: function (url, data) {\n        return new jsonp_request(url, data);\n    },\n    createScriptRequest: function (src) {\n        return new script_request(src);\n    },\n    getLocalStorage: function () {\n        try {\n            return window.localStorage;\n        }\n        catch (e) {\n            return undefined;\n        }\n    },\n    createXHR: function () {\n        if (this.getXHRAPI()) {\n            return this.createXMLHttpRequest();\n        }\n        else {\n            return this.createMicrosoftXHR();\n        }\n    },\n    createXMLHttpRequest: function () {\n        var Constructor = this.getXHRAPI();\n        return new Constructor();\n    },\n    createMicrosoftXHR: function () {\n        return new ActiveXObject('Microsoft.XMLHTTP');\n    },\n    getNetwork: function () {\n        return net_info_Network;\n    },\n    createWebSocket: function (url) {\n        var Constructor = this.getWebSocketAPI();\n        return new Constructor(url);\n    },\n    createSocketRequest: function (method, url) {\n        if (this.isXHRSupported()) {\n            return this.HTTPFactory.createXHR(method, url);\n        }\n        else if (this.isXDRSupported(url.indexOf('https:') === 0)) {\n            return this.HTTPFactory.createXDR(method, url);\n        }\n        else {\n            throw 'Cross-origin HTTP requests are not supported';\n        }\n    },\n    isXHRSupported: function () {\n        var Constructor = this.getXHRAPI();\n        return (Boolean(Constructor) && new Constructor().withCredentials !== undefined);\n    },\n    isXDRSupported: function (useTLS) {\n        var protocol = useTLS ? 'https:' : 'http:';\n        var documentProtocol = this.getProtocol();\n        return (Boolean(window['XDomainRequest']) && documentProtocol === protocol);\n    },\n    addUnloadListener: function (listener) {\n        if (window.addEventListener !== undefined) {\n            window.addEventListener('unload', listener, false);\n        }\n        else if (window.attachEvent !== undefined) {\n            window.attachEvent('onunload', listener);\n        }\n    },\n    removeUnloadListener: function (listener) {\n        if (window.addEventListener !== undefined) {\n            window.removeEventListener('unload', listener, false);\n        }\n        else if (window.detachEvent !== undefined) {\n            window.detachEvent('onunload', listener);\n        }\n    }\n};\n/* harmony default export */ var runtime = (Runtime);\n\n// CONCATENATED MODULE: ./src/core/timeline/level.ts\nvar TimelineLevel;\n(function (TimelineLevel) {\n    TimelineLevel[TimelineLevel[\"ERROR\"] = 3] = \"ERROR\";\n    TimelineLevel[TimelineLevel[\"INFO\"] = 6] = \"INFO\";\n    TimelineLevel[TimelineLevel[\"DEBUG\"] = 7] = \"DEBUG\";\n})(TimelineLevel || (TimelineLevel = {}));\n/* harmony default export */ var timeline_level = (TimelineLevel);\n\n// CONCATENATED MODULE: ./src/core/timeline/timeline.ts\n\n\n\nvar timeline_Timeline = (function () {\n    function Timeline(key, session, options) {\n        this.key = key;\n        this.session = session;\n        this.events = [];\n        this.options = options || {};\n        this.sent = 0;\n        this.uniqueID = 0;\n    }\n    Timeline.prototype.log = function (level, event) {\n        if (level <= this.options.level) {\n            this.events.push(extend({}, event, { timestamp: util.now() }));\n            if (this.options.limit && this.events.length > this.options.limit) {\n                this.events.shift();\n            }\n        }\n    };\n    Timeline.prototype.error = function (event) {\n        this.log(timeline_level.ERROR, event);\n    };\n    Timeline.prototype.info = function (event) {\n        this.log(timeline_level.INFO, event);\n    };\n    Timeline.prototype.debug = function (event) {\n        this.log(timeline_level.DEBUG, event);\n    };\n    Timeline.prototype.isEmpty = function () {\n        return this.events.length === 0;\n    };\n    Timeline.prototype.send = function (sendfn, callback) {\n        var _this = this;\n        var data = extend({\n            session: this.session,\n            bundle: this.sent + 1,\n            key: this.key,\n            lib: 'js',\n            version: this.options.version,\n            cluster: this.options.cluster,\n            features: this.options.features,\n            timeline: this.events\n        }, this.options.params);\n        this.events = [];\n        sendfn(data, function (error, result) {\n            if (!error) {\n                _this.sent++;\n            }\n            if (callback) {\n                callback(error, result);\n            }\n        });\n        return true;\n    };\n    Timeline.prototype.generateUniqueID = function () {\n        this.uniqueID++;\n        return this.uniqueID;\n    };\n    return Timeline;\n}());\n/* harmony default export */ var timeline_timeline = (timeline_Timeline);\n\n// CONCATENATED MODULE: ./src/core/strategies/transport_strategy.ts\n\n\n\n\nvar transport_strategy_TransportStrategy = (function () {\n    function TransportStrategy(name, priority, transport, options) {\n        this.name = name;\n        this.priority = priority;\n        this.transport = transport;\n        this.options = options || {};\n    }\n    TransportStrategy.prototype.isSupported = function () {\n        return this.transport.isSupported({\n            useTLS: this.options.useTLS\n        });\n    };\n    TransportStrategy.prototype.connect = function (minPriority, callback) {\n        var _this = this;\n        if (!this.isSupported()) {\n            return failAttempt(new UnsupportedStrategy(), callback);\n        }\n        else if (this.priority < minPriority) {\n            return failAttempt(new TransportPriorityTooLow(), callback);\n        }\n        var connected = false;\n        var transport = this.transport.createConnection(this.name, this.priority, this.options.key, this.options);\n        var handshake = null;\n        var onInitialized = function () {\n            transport.unbind('initialized', onInitialized);\n            transport.connect();\n        };\n        var onOpen = function () {\n            handshake = factory.createHandshake(transport, function (result) {\n                connected = true;\n                unbindListeners();\n                callback(null, result);\n            });\n        };\n        var onError = function (error) {\n            unbindListeners();\n            callback(error);\n        };\n        var onClosed = function () {\n            unbindListeners();\n            var serializedTransport;\n            serializedTransport = safeJSONStringify(transport);\n            callback(new TransportClosed(serializedTransport));\n        };\n        var unbindListeners = function () {\n            transport.unbind('initialized', onInitialized);\n            transport.unbind('open', onOpen);\n            transport.unbind('error', onError);\n            transport.unbind('closed', onClosed);\n        };\n        transport.bind('initialized', onInitialized);\n        transport.bind('open', onOpen);\n        transport.bind('error', onError);\n        transport.bind('closed', onClosed);\n        transport.initialize();\n        return {\n            abort: function () {\n                if (connected) {\n                    return;\n                }\n                unbindListeners();\n                if (handshake) {\n                    handshake.close();\n                }\n                else {\n                    transport.close();\n                }\n            },\n            forceMinPriority: function (p) {\n                if (connected) {\n                    return;\n                }\n                if (_this.priority < p) {\n                    if (handshake) {\n                        handshake.close();\n                    }\n                    else {\n                        transport.close();\n                    }\n                }\n            }\n        };\n    };\n    return TransportStrategy;\n}());\n/* harmony default export */ var transport_strategy = (transport_strategy_TransportStrategy);\nfunction failAttempt(error, callback) {\n    util.defer(function () {\n        callback(error);\n    });\n    return {\n        abort: function () { },\n        forceMinPriority: function () { }\n    };\n}\n\n// CONCATENATED MODULE: ./src/core/strategies/strategy_builder.ts\n\n\n\n\n\nvar strategy_builder_Transports = runtime.Transports;\nvar strategy_builder_defineTransport = function (config, name, type, priority, options, manager) {\n    var transportClass = strategy_builder_Transports[type];\n    if (!transportClass) {\n        throw new UnsupportedTransport(type);\n    }\n    var enabled = (!config.enabledTransports ||\n        arrayIndexOf(config.enabledTransports, name) !== -1) &&\n        (!config.disabledTransports ||\n            arrayIndexOf(config.disabledTransports, name) === -1);\n    var transport;\n    if (enabled) {\n        options = Object.assign({ ignoreNullOrigin: config.ignoreNullOrigin }, options);\n        transport = new transport_strategy(name, priority, manager ? manager.getAssistant(transportClass) : transportClass, options);\n    }\n    else {\n        transport = strategy_builder_UnsupportedStrategy;\n    }\n    return transport;\n};\nvar strategy_builder_UnsupportedStrategy = {\n    isSupported: function () {\n        return false;\n    },\n    connect: function (_, callback) {\n        var deferred = util.defer(function () {\n            callback(new UnsupportedStrategy());\n        });\n        return {\n            abort: function () {\n                deferred.ensureAborted();\n            },\n            forceMinPriority: function () { }\n        };\n    }\n};\n\n// CONCATENATED MODULE: ./src/core/auth/user_authenticator.ts\n\n\nvar composeChannelQuery = function (params, authOptions) {\n    var query = 'socket_id=' + encodeURIComponent(params.socketId);\n    for (var i in authOptions.params) {\n        query +=\n            '&' +\n                encodeURIComponent(i) +\n                '=' +\n                encodeURIComponent(authOptions.params[i]);\n    }\n    return query;\n};\nvar UserAuthenticator = function (authOptions) {\n    if (typeof runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n        throw \"'\" + authOptions.transport + \"' is not a recognized auth transport\";\n    }\n    return function (params, callback) {\n        var query = composeChannelQuery(params, authOptions);\n        runtime.getAuthorizers()[authOptions.transport](runtime, query, authOptions, AuthRequestType.UserAuthentication, callback);\n    };\n};\n/* harmony default export */ var user_authenticator = (UserAuthenticator);\n\n// CONCATENATED MODULE: ./src/core/auth/channel_authorizer.ts\n\n\nvar channel_authorizer_composeChannelQuery = function (params, authOptions) {\n    var query = 'socket_id=' + encodeURIComponent(params.socketId);\n    query += '&channel_name=' + encodeURIComponent(params.channelName);\n    for (var i in authOptions.params) {\n        query +=\n            '&' +\n                encodeURIComponent(i) +\n                '=' +\n                encodeURIComponent(authOptions.params[i]);\n    }\n    return query;\n};\nvar ChannelAuthorizer = function (authOptions) {\n    if (typeof runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n        throw \"'\" + authOptions.transport + \"' is not a recognized auth transport\";\n    }\n    return function (params, callback) {\n        var query = channel_authorizer_composeChannelQuery(params, authOptions);\n        runtime.getAuthorizers()[authOptions.transport](runtime, query, authOptions, AuthRequestType.ChannelAuthorization, callback);\n    };\n};\n/* harmony default export */ var channel_authorizer = (ChannelAuthorizer);\n\n// CONCATENATED MODULE: ./src/core/auth/deprecated_channel_authorizer.ts\nvar ChannelAuthorizerProxy = function (pusher, authOptions, channelAuthorizerGenerator) {\n    var deprecatedAuthorizerOptions = {\n        authTransport: authOptions.transport,\n        authEndpoint: authOptions.endpoint,\n        auth: {\n            params: authOptions.params,\n            headers: authOptions.headers\n        }\n    };\n    return function (params, callback) {\n        var channel = pusher.channel(params.channelName);\n        var channelAuthorizer = channelAuthorizerGenerator(channel, deprecatedAuthorizerOptions);\n        channelAuthorizer.authorize(params.socketId, callback);\n    };\n};\n\n// CONCATENATED MODULE: ./src/core/config.ts\nvar __assign = ( false) || function () {\n    __assign = Object.assign || function(t) {\n        for (var s, i = 1, n = arguments.length; i < n; i++) {\n            s = arguments[i];\n            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n                t[p] = s[p];\n        }\n        return t;\n    };\n    return __assign.apply(this, arguments);\n};\n\n\n\n\n\nfunction getConfig(opts, pusher) {\n    var config = {\n        activityTimeout: opts.activityTimeout || defaults.activityTimeout,\n        cluster: opts.cluster || defaults.cluster,\n        httpPath: opts.httpPath || defaults.httpPath,\n        httpPort: opts.httpPort || defaults.httpPort,\n        httpsPort: opts.httpsPort || defaults.httpsPort,\n        pongTimeout: opts.pongTimeout || defaults.pongTimeout,\n        statsHost: opts.statsHost || defaults.stats_host,\n        unavailableTimeout: opts.unavailableTimeout || defaults.unavailableTimeout,\n        wsPath: opts.wsPath || defaults.wsPath,\n        wsPort: opts.wsPort || defaults.wsPort,\n        wssPort: opts.wssPort || defaults.wssPort,\n        enableStats: getEnableStatsConfig(opts),\n        httpHost: getHttpHost(opts),\n        useTLS: shouldUseTLS(opts),\n        wsHost: getWebsocketHost(opts),\n        userAuthenticator: buildUserAuthenticator(opts),\n        channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n    };\n    if ('disabledTransports' in opts)\n        config.disabledTransports = opts.disabledTransports;\n    if ('enabledTransports' in opts)\n        config.enabledTransports = opts.enabledTransports;\n    if ('ignoreNullOrigin' in opts)\n        config.ignoreNullOrigin = opts.ignoreNullOrigin;\n    if ('timelineParams' in opts)\n        config.timelineParams = opts.timelineParams;\n    if ('nacl' in opts) {\n        config.nacl = opts.nacl;\n    }\n    return config;\n}\nfunction getHttpHost(opts) {\n    if (opts.httpHost) {\n        return opts.httpHost;\n    }\n    if (opts.cluster) {\n        return \"sockjs-\" + opts.cluster + \".pusher.com\";\n    }\n    return defaults.httpHost;\n}\nfunction getWebsocketHost(opts) {\n    if (opts.wsHost) {\n        return opts.wsHost;\n    }\n    if (opts.cluster) {\n        return getWebsocketHostFromCluster(opts.cluster);\n    }\n    return getWebsocketHostFromCluster(defaults.cluster);\n}\nfunction getWebsocketHostFromCluster(cluster) {\n    return \"ws-\" + cluster + \".pusher.com\";\n}\nfunction shouldUseTLS(opts) {\n    if (runtime.getProtocol() === 'https:') {\n        return true;\n    }\n    else if (opts.forceTLS === false) {\n        return false;\n    }\n    return true;\n}\nfunction getEnableStatsConfig(opts) {\n    if ('enableStats' in opts) {\n        return opts.enableStats;\n    }\n    if ('disableStats' in opts) {\n        return !opts.disableStats;\n    }\n    return false;\n}\nfunction buildUserAuthenticator(opts) {\n    var userAuthentication = __assign({}, defaults.userAuthentication, opts.userAuthentication);\n    if ('customHandler' in userAuthentication &&\n        userAuthentication['customHandler'] != null) {\n        return userAuthentication['customHandler'];\n    }\n    return user_authenticator(userAuthentication);\n}\nfunction buildChannelAuth(opts, pusher) {\n    var channelAuthorization;\n    if ('channelAuthorization' in opts) {\n        channelAuthorization = __assign({}, defaults.channelAuthorization, opts.channelAuthorization);\n    }\n    else {\n        channelAuthorization = {\n            transport: opts.authTransport || defaults.authTransport,\n            endpoint: opts.authEndpoint || defaults.authEndpoint\n        };\n        if ('auth' in opts) {\n            if ('params' in opts.auth)\n                channelAuthorization.params = opts.auth.params;\n            if ('headers' in opts.auth)\n                channelAuthorization.headers = opts.auth.headers;\n        }\n        if ('authorizer' in opts)\n            channelAuthorization.customHandler = ChannelAuthorizerProxy(pusher, channelAuthorization, opts.authorizer);\n    }\n    return channelAuthorization;\n}\nfunction buildChannelAuthorizer(opts, pusher) {\n    var channelAuthorization = buildChannelAuth(opts, pusher);\n    if ('customHandler' in channelAuthorization &&\n        channelAuthorization['customHandler'] != null) {\n        return channelAuthorization['customHandler'];\n    }\n    return channel_authorizer(channelAuthorization);\n}\n\n// CONCATENATED MODULE: ./src/core/utils/flat_promise.ts\nfunction flatPromise() {\n    var resolve, reject;\n    var promise = new Promise(function (res, rej) {\n        resolve = res;\n        reject = rej;\n    });\n    return { promise: promise, resolve: resolve, reject: reject };\n}\n/* harmony default export */ var flat_promise = (flatPromise);\n\n// CONCATENATED MODULE: ./src/core/user.ts\nvar user_extends = ( false) || (function () {\n    var extendStatics = function (d, b) {\n        extendStatics = Object.setPrototypeOf ||\n            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n        return extendStatics(d, b);\n    };\n    return function (d, b) {\n        extendStatics(d, b);\n        function __() { this.constructor = d; }\n        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n    };\n})();\n\n\n\n\nvar user_UserFacade = (function (_super) {\n    user_extends(UserFacade, _super);\n    function UserFacade(pusher) {\n        var _this = _super.call(this, function (eventName, data) {\n            logger.debug('No callbacks on user for ' + eventName);\n        }) || this;\n        _this.signin_requested = false;\n        _this.user_data = null;\n        _this.serverToUserChannel = null;\n        _this.signinDonePromise = null;\n        _this._signinDoneResolve = null;\n        _this._onAuthorize = function (err, authData) {\n            if (err) {\n                logger.warn(\"Error during signin: \" + err);\n                _this._cleanup();\n                return;\n            }\n            _this.pusher.send_event('pusher:signin', {\n                auth: authData.auth,\n                user_data: authData.user_data\n            });\n        };\n        _this.pusher = pusher;\n        _this.pusher.connection.bind('state_change', function (_a) {\n            var previous = _a.previous, current = _a.current;\n            if (previous !== 'connected' && current === 'connected') {\n                _this._signin();\n            }\n            if (previous === 'connected' && current !== 'connected') {\n                _this._cleanup();\n                _this._newSigninPromiseIfNeeded();\n            }\n        });\n        _this.pusher.connection.bind('message', function (event) {\n            var eventName = event.event;\n            if (eventName === 'pusher:signin_success') {\n                _this._onSigninSuccess(event.data);\n            }\n            if (_this.serverToUserChannel &&\n                _this.serverToUserChannel.name === event.channel) {\n                _this.serverToUserChannel.handleEvent(event);\n            }\n        });\n        return _this;\n    }\n    UserFacade.prototype.signin = function () {\n        if (this.signin_requested) {\n            return;\n        }\n        this.signin_requested = true;\n        this._signin();\n    };\n    UserFacade.prototype._signin = function () {\n        if (!this.signin_requested) {\n            return;\n        }\n        this._newSigninPromiseIfNeeded();\n        if (this.pusher.connection.state !== 'connected') {\n            return;\n        }\n        this.pusher.config.userAuthenticator({\n            socketId: this.pusher.connection.socket_id\n        }, this._onAuthorize);\n    };\n    UserFacade.prototype._onSigninSuccess = function (data) {\n        try {\n            this.user_data = JSON.parse(data.user_data);\n        }\n        catch (e) {\n            logger.error(\"Failed parsing user data after signin: \" + data.user_data);\n            this._cleanup();\n            return;\n        }\n        if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n            logger.error(\"user_data doesn't contain an id. user_data: \" + this.user_data);\n            this._cleanup();\n            return;\n        }\n        this._signinDoneResolve();\n        this._subscribeChannels();\n    };\n    UserFacade.prototype._subscribeChannels = function () {\n        var _this = this;\n        var ensure_subscribed = function (channel) {\n            if (channel.subscriptionPending && channel.subscriptionCancelled) {\n                channel.reinstateSubscription();\n            }\n            else if (!channel.subscriptionPending &&\n                _this.pusher.connection.state === 'connected') {\n                channel.subscribe();\n            }\n        };\n        this.serverToUserChannel = new channels_channel(\"#server-to-user-\" + this.user_data.id, this.pusher);\n        this.serverToUserChannel.bind_global(function (eventName, data) {\n            if (eventName.indexOf('pusher_internal:') === 0 ||\n                eventName.indexOf('pusher:') === 0) {\n                return;\n            }\n            _this.emit(eventName, data);\n        });\n        ensure_subscribed(this.serverToUserChannel);\n    };\n    UserFacade.prototype._cleanup = function () {\n        this.user_data = null;\n        if (this.serverToUserChannel) {\n            this.serverToUserChannel.unbind_all();\n            this.serverToUserChannel.disconnect();\n            this.serverToUserChannel = null;\n        }\n        if (this.signin_requested) {\n            this._signinDoneResolve();\n        }\n    };\n    UserFacade.prototype._newSigninPromiseIfNeeded = function () {\n        if (!this.signin_requested) {\n            return;\n        }\n        if (this.signinDonePromise && !this.signinDonePromise.done) {\n            return;\n        }\n        var _a = flat_promise(), promise = _a.promise, resolve = _a.resolve, _ = _a.reject;\n        promise.done = false;\n        var setDone = function () {\n            promise.done = true;\n        };\n        promise.then(setDone)[\"catch\"](setDone);\n        this.signinDonePromise = promise;\n        this._signinDoneResolve = resolve;\n    };\n    return UserFacade;\n}(dispatcher));\n/* harmony default export */ var user = (user_UserFacade);\n\n// CONCATENATED MODULE: ./src/core/pusher.ts\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar pusher_Pusher = (function () {\n    function Pusher(app_key, options) {\n        var _this = this;\n        checkAppKey(app_key);\n        options = options || {};\n        if (!options.cluster && !(options.wsHost || options.httpHost)) {\n            var suffix = url_store.buildLogSuffix('javascriptQuickStart');\n            logger.warn(\"You should always specify a cluster when connecting. \" + suffix);\n        }\n        if ('disableStats' in options) {\n            logger.warn('The disableStats option is deprecated in favor of enableStats');\n        }\n        this.key = app_key;\n        this.config = getConfig(options, this);\n        this.channels = factory.createChannels();\n        this.global_emitter = new dispatcher();\n        this.sessionID = Math.floor(Math.random() * 1000000000);\n        this.timeline = new timeline_timeline(this.key, this.sessionID, {\n            cluster: this.config.cluster,\n            features: Pusher.getClientFeatures(),\n            params: this.config.timelineParams || {},\n            limit: 50,\n            level: timeline_level.INFO,\n            version: defaults.VERSION\n        });\n        if (this.config.enableStats) {\n            this.timelineSender = factory.createTimelineSender(this.timeline, {\n                host: this.config.statsHost,\n                path: '/timeline/v2/' + runtime.TimelineTransport.name\n            });\n        }\n        var getStrategy = function (options) {\n            return runtime.getDefaultStrategy(_this.config, options, strategy_builder_defineTransport);\n        };\n        this.connection = factory.createConnectionManager(this.key, {\n            getStrategy: getStrategy,\n            timeline: this.timeline,\n            activityTimeout: this.config.activityTimeout,\n            pongTimeout: this.config.pongTimeout,\n            unavailableTimeout: this.config.unavailableTimeout,\n            useTLS: Boolean(this.config.useTLS)\n        });\n        this.connection.bind('connected', function () {\n            _this.subscribeAll();\n            if (_this.timelineSender) {\n                _this.timelineSender.send(_this.connection.isUsingTLS());\n            }\n        });\n        this.connection.bind('message', function (event) {\n            var eventName = event.event;\n            var internal = eventName.indexOf('pusher_internal:') === 0;\n            if (event.channel) {\n                var channel = _this.channel(event.channel);\n                if (channel) {\n                    channel.handleEvent(event);\n                }\n            }\n            if (!internal) {\n                _this.global_emitter.emit(event.event, event.data);\n            }\n        });\n        this.connection.bind('connecting', function () {\n            _this.channels.disconnect();\n        });\n        this.connection.bind('disconnected', function () {\n            _this.channels.disconnect();\n        });\n        this.connection.bind('error', function (err) {\n            logger.warn(err);\n        });\n        Pusher.instances.push(this);\n        this.timeline.info({ instances: Pusher.instances.length });\n        this.user = new user(this);\n        if (Pusher.isReady) {\n            this.connect();\n        }\n    }\n    Pusher.ready = function () {\n        Pusher.isReady = true;\n        for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n            Pusher.instances[i].connect();\n        }\n    };\n    Pusher.getClientFeatures = function () {\n        return keys(filterObject({ ws: runtime.Transports.ws }, function (t) {\n            return t.isSupported({});\n        }));\n    };\n    Pusher.prototype.channel = function (name) {\n        return this.channels.find(name);\n    };\n    Pusher.prototype.allChannels = function () {\n        return this.channels.all();\n    };\n    Pusher.prototype.connect = function () {\n        this.connection.connect();\n        if (this.timelineSender) {\n            if (!this.timelineSenderTimer) {\n                var usingTLS = this.connection.isUsingTLS();\n                var timelineSender = this.timelineSender;\n                this.timelineSenderTimer = new PeriodicTimer(60000, function () {\n                    timelineSender.send(usingTLS);\n                });\n            }\n        }\n    };\n    Pusher.prototype.disconnect = function () {\n        this.connection.disconnect();\n        if (this.timelineSenderTimer) {\n            this.timelineSenderTimer.ensureAborted();\n            this.timelineSenderTimer = null;\n        }\n    };\n    Pusher.prototype.bind = function (event_name, callback, context) {\n        this.global_emitter.bind(event_name, callback, context);\n        return this;\n    };\n    Pusher.prototype.unbind = function (event_name, callback, context) {\n        this.global_emitter.unbind(event_name, callback, context);\n        return this;\n    };\n    Pusher.prototype.bind_global = function (callback) {\n        this.global_emitter.bind_global(callback);\n        return this;\n    };\n    Pusher.prototype.unbind_global = function (callback) {\n        this.global_emitter.unbind_global(callback);\n        return this;\n    };\n    Pusher.prototype.unbind_all = function (callback) {\n        this.global_emitter.unbind_all();\n        return this;\n    };\n    Pusher.prototype.subscribeAll = function () {\n        var channelName;\n        for (channelName in this.channels.channels) {\n            if (this.channels.channels.hasOwnProperty(channelName)) {\n                this.subscribe(channelName);\n            }\n        }\n    };\n    Pusher.prototype.subscribe = function (channel_name) {\n        var channel = this.channels.add(channel_name, this);\n        if (channel.subscriptionPending && channel.subscriptionCancelled) {\n            channel.reinstateSubscription();\n        }\n        else if (!channel.subscriptionPending &&\n            this.connection.state === 'connected') {\n            channel.subscribe();\n        }\n        return channel;\n    };\n    Pusher.prototype.unsubscribe = function (channel_name) {\n        var channel = this.channels.find(channel_name);\n        if (channel && channel.subscriptionPending) {\n            channel.cancelSubscription();\n        }\n        else {\n            channel = this.channels.remove(channel_name);\n            if (channel && channel.subscribed) {\n                channel.unsubscribe();\n            }\n        }\n    };\n    Pusher.prototype.send_event = function (event_name, data, channel) {\n        return this.connection.send_event(event_name, data, channel);\n    };\n    Pusher.prototype.shouldUseTLS = function () {\n        return this.config.useTLS;\n    };\n    Pusher.prototype.signin = function () {\n        this.user.signin();\n    };\n    Pusher.instances = [];\n    Pusher.isReady = false;\n    Pusher.logToConsole = false;\n    Pusher.Runtime = runtime;\n    Pusher.ScriptReceivers = runtime.ScriptReceivers;\n    Pusher.DependenciesReceivers = runtime.DependenciesReceivers;\n    Pusher.auth_callbacks = runtime.auth_callbacks;\n    return Pusher;\n}());\n/* harmony default export */ var core_pusher = __webpack_exports__[\"default\"] = (pusher_Pusher);\nfunction checkAppKey(key) {\n    if (key === null || key === undefined) {\n        throw 'You must pass your app key when you instantiate Pusher.';\n    }\n}\nruntime.setup(pusher_Pusher);\n\n\n/***/ })\n/******/ ]);\n});\n//# sourceMappingURL=pusher.js.map\n\n//# sourceURL=webpack://webpacked/./node_modules/pusher-js/dist/web/pusher.js?")},486:function(__unused_webpack_module,__unused_webpack___webpack_exports__,__webpack_require__){"use strict";eval("\n// EXTERNAL MODULE: ./node_modules/pusher-js/dist/web/pusher.js\nvar web_pusher = __webpack_require__(606);\nvar pusher_default = /*#__PURE__*/__webpack_require__.n(web_pusher);\n;// CONCATENATED MODULE: ./src/chat/Chat.js\n\n\nclass Chat {\n  constructor(messages_url, new_message_url, pusher_configs, current_id, headers = {}) {\n    const chatBlockView = document.querySelector(\"#chat-block-main\")\n      //const chatMainView = document.querySelector(\"#chat-block-main .chat-block\")\n    const maximizeBtn = document.querySelector(\"#chat-block-main .maximize\")\n    const minimizeBtn = document.querySelector(\"#chat-block-main .minimize\")\n    const users = document.querySelectorAll(\"#chat-block-main .users-wrapper .users-list .user\")\n\n    // Go back button on smaller screens.\n    const resetView = chatBlockView.querySelector('.chat-controls .go-back')\n\n    const usersView = chatBlockView.querySelector('.users-wrapper')\n    const messagesView = chatBlockView.querySelector('.messages-view')\n    const chatInput = chatBlockView.querySelector('[type=\"input\"], [name=\"message\"]')\n\n    chatInput\n      .addEventListener('keyup', async (e) => await this.sendNewMessage(e))\n\n    const controls = [maximizeBtn, minimizeBtn]\n\n    controls.forEach(item => {\n      item.addEventListener('click', event => {\n        this.updateControls(event)\n      })\n    })\n    this.controls = controls\n    this.chatBlockView  = chatBlockView\n    this.usersView  = usersView\n    this.messagesView  = messagesView\n    this.resetView = resetView\n    this.chatInput = chatInput\n    this.resetView.addEventListener('click', this.showUserListing)\n    this.messagesUrl = messages_url\n    this.newMessageUrl = new_message_url\n    this.receiverId = ''\n    this.currentId = current_id\n    this.headers = headers\n    // Holds the messages pages (pager) item\n    this.pages = {\n      current_page: null,\n      total_pages: 0,\n      total_items: \"\"\n    }\n\n    users.forEach(user => {\n      user.addEventListener('click',  async () => await this.showChats(user))\n\n    })\n\n    // Observer definitions\n    this.observerConfig = {\n      attributes: true,\n      attributeOldValue: true,\n      attributeFilter: ['class'],\n      childList: true,\n      subtree: true\n    };\n\n    const options = {\n      root: null,\n      //threshold: 1, //@TODO only works on windows!!!\n      rootMargin: \"60%\" // fetch earlier\n      // rootMargin: \"-10px\" // fetch later\n    }\n    /**\n     * Observes scroll position on the particular\n     * DOM elements it's assigned to.\n     * @type {IntersectionObserver}\n     */\n    this.intersectionObserver =\n      new IntersectionObserver(entries => {\n          this.observeIntersections(entries)\n        },\n        options\n      )\n\n\n     // Observes attribute changes on the particular\n     // DOM elements it's assigned to.\n\n    // this.mutationObserver = new MutationObserver(entries => {\n    //   this.observeMutations(entries)\n    // })\n\n\n    const pusher = new (pusher_default())(pusher_configs.app_key, {\n      cluster: pusher_configs.cluster,\n      headers: headers,\n    })\n\n    const channel = pusher.subscribe('my-channel')\n    channel.bind('dru-chat-event', (data) => this.druChatEvent(data))\n  }\n\n  updateControls = (event) => {\n\n    // Toggle now-show class between the controls\n    this.controls.forEach(control => {\n      control.classList.toggle('no-show')\n    });\n\n    // Toggle children-hidden class too, on main block\n    this.chatBlockView.classList.toggle('children-hidden')\n    // Toggle show for div with users and messages listing\n    this.chatBlockView.querySelector('.chat-block')\n      .classList.toggle('no-show')\n\n    // Use the event details to determine what other\n    // parts (attributes) of the chat to update\n\n  }\n\n  // Resets user view on smaller screens.\n  showUserListing = () => {\n    this.resetView.classList.toggle('no-show')\n\n    // Hide message view and show users listing instead.\n    // Like reset what's done in show chats,\n    this.usersView.classList.toggle('no-show')\n    this.messagesView.classList.toggle('no-show')\n  }\n\n  showChats = async (user) => {\n\n    // Remove active class from previous if any\n    this.usersView.querySelector('.active')\n      ?.classList?.remove('active')\n\n    // remove inactive state from input\n    this.chatInput.removeAttribute('disabled')\n\n\n    // Add active class to current.\n    user.classList.add('active')\n    const userId = user.getAttribute('id');\n    this.receiverId = userId\n    // Reset pages too.\n    this.pages = {\n      current_page: null,\n      total_pages: 0,\n      total_items: \"\"\n    }\n\n    // Reset message view\n    this.messagesView.querySelector('.message-list')\n      .innerHTML = ''\n\n    // Toggle for mobile apps .users-wrapper and messages-view\n    // User listing vs message listing view.\n\n    this.usersView.classList.toggle('no-show')\n    this.messagesView.classList.toggle('no-show')\n    this.resetView.classList.toggle('no-show')\n    // Display btn to go back to user listing too\n\n    // Update message header.\n\n    this.messagesView.querySelector('.header img').src\n      = user.querySelector('img').src\n\n    this.messagesView.querySelector('.header .username').innerText\n      = user.querySelector('.display-name').innerText\n    await this.loadChats()\n  }\n\n  loadChats = async () => {\n\n    // Just a limit to compare against current_pages.\n    const limit = this.pages.total_pages ? this.pages.total_pages : -2;\n    if (limit === (this.pages.current_page + 1)) return\n\n\n    const messages = this.messagesView.querySelector('.message-list')\n\n    // Determine if to auto scroll/focus with messages.innerHTML\n    // const shouldScroll = messages.innerHTML ? false : true\n\n    const messageList = await this.newMsgFromTemplate()\n\n    // If no messages from request and it's the first request.\n    // meaning messages.innerHTML is empty string, we show a message,\n    // of \"no chat between the two users\".\n    if (!messageList.childElementCount && !messages.innerHTML) {\n      const noMsgWrapper = document.createElement('div')\n      noMsgWrapper.classList.add('no-message')\n      noMsgWrapper.style.height = 'auto'\n      const messageDiv = document.createElement('div')\n      messageDiv.classList.add('message', 'received')\n      const msgParagraph = document.createElement('p')\n      msgParagraph.innerText = \"This is the very beginning of your chat with this user, go on \" +\n        \"and send your first message.\"\n      messageDiv.prepend(msgParagraph)\n      noMsgWrapper.appendChild(messageDiv)\n      messages.prepend(noMsgWrapper)\n      // @TODO add height to this div\n    }\n\n    // Append to screen\n    messages.prepend(messageList)\n\n    //if (shouldScroll) {\n      messages\n        ?.querySelector(`[tabindex=\"${this.pages.current_page}\"]`)\n        ?.focus()\n    //}\n\n      //.focus({preventScroll: false})\n\n    // @TODO scroll into view bug,\n\n  }\n\n\n  observeIntersections = (entries) => {\n\n    entries.forEach( async (entry) => {\n\n      if (entry.isIntersecting) {\n\n        // Get the next items (pager).\n         await this.loadChats();\n\n        // Only observing the last item on the message list.\n        this.intersectionObserver.unobserve(entry.target)\n\n      }\n    })\n  }\n\n  newMsgFromTemplate = async () => {\n\n    const messageData = await this.fetchMessagesByPage()\n\n    const newMessages = document.createDocumentFragment();\n    const {messages, pages} = messageData\n    this.pages = {...pages}\n\n    // Reverse array since we're appending items in that order.\n    messages?.reverse().forEach((data, index) => {\n      //data.created = data.created * 1000\n      const messageDiv = this.messageTemplateFromData(data)\n      if (index === 0) {\n        // Last item scroll Dom listener, so we load the\n        // Next page(pager).\n        //messageDiv.classList.add('testing-index-30')\n        this.intersectionObserver.observe(messageDiv)\n      }\n      // Add tabindex to the message at the bottom to focus.\n      if (messages.length === (index + 1)) {\n        // Add tabindex for to focus()\n        messageDiv.setAttribute('tabindex', pages.current_page)\n\n      }\n      newMessages.appendChild(messageDiv)\n    })\n    return newMessages\n  }\n\n  sendNewMessage = async (event) => {\n\n    // On larger screens, the message listing plus,\n    // the input are displayed even if no user is\n    // selected (receiver), we set a message and\n    // disable input.\n    const messages = this.messagesView.querySelector('.message-list')\n    if (!this.receiverId) {\n      const noReceiverWrapper = document.createElement('div')\n      noReceiverWrapper.classList.add('no-message')\n      //noReceiverWrapper.style.height = '80%'\n\n      const messageDiv = document.createElement('div')\n      messageDiv.classList.add('message', 'received')\n      const msgParagraph = document.createElement('p')\n      msgParagraph.innerText = \"Please select a user from the left to chat with!.\"\n      msgParagraph.classList.add('warning')\n      messageDiv.prepend(msgParagraph)\n      noReceiverWrapper.appendChild(messageDiv)\n      messages.prepend(noReceiverWrapper)\n      event.target.setAttribute('disabled', 'true')\n      return\n    }\n\n\n    if (event.keyCode === 13 && this.receiverId && event.target.value) {\n\n      const headers = {'Content-Type': 'application/x-www-form-urlencoded', ...this.headers}\n\n      await fetch(this.newMessageUrl, {\n        method: 'POST',\n        mode: 'same-origin', // no-cors, *cors, same-origin\n        cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached\n        credentials: 'same-origin', // include, *same-origin, omit\n        headers,\n        redirect: 'follow', // manual, *follow, error\n        referrerPolicy: 'no-referrer', // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url\n        body: new URLSearchParams({\n          'receiver_id': this.receiverId,\n          'message': event.target.value\n        })\n\n        // 'message': Drupal.checkPlain(event.target.value)\n      })\n\n      const messages = this.messagesView.querySelector('.message-list')\n\n      // Append message to message view\n      const data = {\n        message: event.target.value,\n        to: this.receiverId,\n        from: this.currentId,\n        is_read: 1,\n        created: Date.now(),\n      }\n      const messageDiv = this.messageTemplateFromData(data)\n      messages.appendChild(messageDiv)\n\n      messages.scrollTop = messages.scrollHeight\n      // Clear value\n      event.target.value = ''\n    }\n\n    //alert(e.target.value)\n  }\n\n  druChatEvent = ({from, to}) => {\n    // If currentId is same as from,\n    // update view the messages for the message sender.\n    if (this.currentId === from) {\n     // For this user the message is attached to the message view,\n      // before the input field is cleared, message contains the\n      // input field value @TODO about is_read.\n\n    }\n      // The receiver of the message now.\n      // Which has multiple variants to consider for\n      // each work-flow.\n      // @TODO play sound for receiver below too\n    else if (this.currentId === parseInt(to)) {\n      // Check if 'from' has a class of active.\n      // Update view chat if so\n      // Else update unread count\n      const receiver = this.usersView.querySelector(`[id=\"${from}\"]`)\n      if (receiver.classList.contains('active')) {\n        // Load the last message between current user (this receiver) and sender (from).\n        this.fetchMessagesByPage(from)\n          .then((data) => {\n            const messages = this.messagesView.querySelector('.message-list')\n            data.messages[0].created = data.messages[0].created * 1000\n            const msgDiv = this.messageTemplateFromData(data.messages[0])\n            messages.appendChild(msgDiv)\n\n            messages.scrollTop = messages.scrollHeight\n          })\n\n      } else {\n        // Update unread count.\n        const unreadCount = receiver.querySelector('.pending .unread-count')\n        if (unreadCount?.innerText) {\n          unreadCount.innerText = parseInt(unreadCount.innerText) + 1\n        } else {\n          const item = document.createElement('span')\n          item.classList.add('unread-count')\n          item.innerText = 1\n          receiver.querySelector('.pending')\n            .appendChild(item)\n        }\n      }\n    }\n  }\n\n  /**\n   * Creates a message div from the data object.\n   * @param data\n   * @returns {HTMLDivElement}\n   */\n  messageTemplateFromData = data => {\n    // Create a message div from data\n    const messageDiv = document.createElement('div')\n    if (parseInt(data.from) === parseInt(this.currentId)) {\n      messageDiv.classList.add('message','sent')\n    } else {\n      messageDiv.classList.add('message','received')\n    }\n    const msgParagraph = document.createElement('p')\n    msgParagraph.innerText = data.message\n    const sentAt = document.createElement('span')\n\n    sentAt.innerText = new Date(data.created).toLocaleString()\n    msgParagraph.append(sentAt)\n    messageDiv.appendChild(msgParagraph)\n    return messageDiv\n  }\n\n\n  /**\n   * Fetches message by receiver_id.\n   * also updates the pages item {}.\n   * @param receiver_id\n   * @returns {Promise<any>}\n   */\n  fetchMessagesByPage = async (receiver_id = null) => {\n    if (this.pages.current_page || this.pages.current_page === 0) {\n      const current_page = this.pages.current_page += 1\n      this.pages = {...this.pages, current_page}\n    }\n\n    let url = ''\n    if (receiver_id) {\n      url = this.messagesUrl + receiver_id + '?page=' + 0 + '&limit=1'\n    } else {\n      url = this.messagesUrl + this.receiverId + '?page=' +this.pages.current_page\n    }\n\n    const headers = {...this.headers}\n\n    const res = await fetch(url, {\n      method: 'GET',\n      mode: 'same-origin',\n      cache: 'no-cache',\n      credentials: 'same-origin',\n      headers,\n      redirect: 'follow',\n      })\n\n\n    if (res.status === 200) {\n\n      return await res.json();\n\n    } else  {\n      console.error('An error occurred!')\n    }\n  }\n\n}\n\n\n\n;// CONCATENATED MODULE: ./src/chat_nv.js\n\n\n\nconst messages_url = flairChatData.messages_url\nconst new_message_url = flairChatData.new_msg_url\nconst currentId = parseInt(flairChatData.current_id)\nconst headers = flairChatData.headers\nconst pusher_configs = {\n    app_key: flairChatData.app_key,\n    cluster: flairChatData.cluster,\n    presence_url: flairChatData.presence_url,\n}\n\n// Initialize chat app\nnew Chat(messages_url, new_message_url, pusher_configs, currentId, headers);\n\n\n\n\n\n\n\n\n\n//# sourceURL=webpack://webpacked/./src/chat_nv.js_+_1_modules?")}},__webpack_module_cache__={};function __webpack_require__(n){var e=__webpack_module_cache__[n];if(void 0!==e)return e.exports;var t=__webpack_module_cache__[n]={exports:{}};return __webpack_modules__[n](t,t.exports,__webpack_require__),t.exports}__webpack_require__.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return __webpack_require__.d(e,{a:e}),e},__webpack_require__.d=function(n,e){for(var t in e)__webpack_require__.o(e,t)&&!__webpack_require__.o(n,t)&&Object.defineProperty(n,t,{enumerable:!0,get:e[t]})},__webpack_require__.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)};var __webpack_exports__=__webpack_require__(486)})();
     1(function(){var __webpack_modules__={606:function(module){eval("/*!\n * Pusher JavaScript Library v7.4.0\n * https://pusher.com/\n *\n * Copyright 2020, Pusher\n * Released under the MIT licence.\n */\n\n(function webpackUniversalModuleDefinition(root, factory) {\n\tif(true)\n\t\tmodule.exports = factory();\n\telse {}\n})(window, function() {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __nested_webpack_require_669__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId]) {\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/ \t\t}\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __nested_webpack_require_669__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__nested_webpack_require_669__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__nested_webpack_require_669__.c = installedModules;\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__nested_webpack_require_669__.d = function(exports, name, getter) {\n/******/ \t\tif(!__nested_webpack_require_669__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// define __esModule on exports\n/******/ \t__nested_webpack_require_669__.r = function(exports) {\n/******/ \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n/******/ \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n/******/ \t\t}\n/******/ \t\tObject.defineProperty(exports, '__esModule', { value: true });\n/******/ \t};\n/******/\n/******/ \t// create a fake namespace object\n/******/ \t// mode & 1: value is a module id, require it\n/******/ \t// mode & 2: merge all properties of value into the ns\n/******/ \t// mode & 4: return value when already ns object\n/******/ \t// mode & 8|1: behave like require\n/******/ \t__nested_webpack_require_669__.t = function(value, mode) {\n/******/ \t\tif(mode & 1) value = __nested_webpack_require_669__(value);\n/******/ \t\tif(mode & 8) return value;\n/******/ \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n/******/ \t\tvar ns = Object.create(null);\n/******/ \t\t__nested_webpack_require_669__.r(ns);\n/******/ \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n/******/ \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __nested_webpack_require_669__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n/******/ \t\treturn ns;\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__nested_webpack_require_669__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__nested_webpack_require_669__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__nested_webpack_require_669__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__nested_webpack_require_669__.p = \"\";\n/******/\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __nested_webpack_require_669__(__nested_webpack_require_669__.s = 2);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\nvar __extends = (this && this.__extends) || (function () {\n    var extendStatics = function (d, b) {\n        extendStatics = Object.setPrototypeOf ||\n            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n        return extendStatics(d, b);\n    };\n    return function (d, b) {\n        extendStatics(d, b);\n        function __() { this.constructor = d; }\n        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n    };\n})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nvar INVALID_BYTE = 256;\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nvar Coder = /** @class */ (function () {\n    // TODO(dchest): methods to encode chunk-by-chunk.\n    function Coder(_paddingCharacter) {\n        if (_paddingCharacter === void 0) { _paddingCharacter = \"=\"; }\n        this._paddingCharacter = _paddingCharacter;\n    }\n    Coder.prototype.encodedLength = function (length) {\n        if (!this._paddingCharacter) {\n            return (length * 8 + 5) / 6 | 0;\n        }\n        return (length + 2) / 3 * 4 | 0;\n    };\n    Coder.prototype.encode = function (data) {\n        var out = \"\";\n        var i = 0;\n        for (; i < data.length - 2; i += 3) {\n            var c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n            out += this._encodeByte((c >>> 3 * 6) & 63);\n            out += this._encodeByte((c >>> 2 * 6) & 63);\n            out += this._encodeByte((c >>> 1 * 6) & 63);\n            out += this._encodeByte((c >>> 0 * 6) & 63);\n        }\n        var left = data.length - i;\n        if (left > 0) {\n            var c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n            out += this._encodeByte((c >>> 3 * 6) & 63);\n            out += this._encodeByte((c >>> 2 * 6) & 63);\n            if (left === 2) {\n                out += this._encodeByte((c >>> 1 * 6) & 63);\n            }\n            else {\n                out += this._paddingCharacter || \"\";\n            }\n            out += this._paddingCharacter || \"\";\n        }\n        return out;\n    };\n    Coder.prototype.maxDecodedLength = function (length) {\n        if (!this._paddingCharacter) {\n            return (length * 6 + 7) / 8 | 0;\n        }\n        return length / 4 * 3 | 0;\n    };\n    Coder.prototype.decodedLength = function (s) {\n        return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n    };\n    Coder.prototype.decode = function (s) {\n        if (s.length === 0) {\n            return new Uint8Array(0);\n        }\n        var paddingLength = this._getPaddingLength(s);\n        var length = s.length - paddingLength;\n        var out = new Uint8Array(this.maxDecodedLength(length));\n        var op = 0;\n        var i = 0;\n        var haveBad = 0;\n        var v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n        for (; i < length - 4; i += 4) {\n            v0 = this._decodeChar(s.charCodeAt(i + 0));\n            v1 = this._decodeChar(s.charCodeAt(i + 1));\n            v2 = this._decodeChar(s.charCodeAt(i + 2));\n            v3 = this._decodeChar(s.charCodeAt(i + 3));\n            out[op++] = (v0 << 2) | (v1 >>> 4);\n            out[op++] = (v1 << 4) | (v2 >>> 2);\n            out[op++] = (v2 << 6) | v3;\n            haveBad |= v0 & INVALID_BYTE;\n            haveBad |= v1 & INVALID_BYTE;\n            haveBad |= v2 & INVALID_BYTE;\n            haveBad |= v3 & INVALID_BYTE;\n        }\n        if (i < length - 1) {\n            v0 = this._decodeChar(s.charCodeAt(i));\n            v1 = this._decodeChar(s.charCodeAt(i + 1));\n            out[op++] = (v0 << 2) | (v1 >>> 4);\n            haveBad |= v0 & INVALID_BYTE;\n            haveBad |= v1 & INVALID_BYTE;\n        }\n        if (i < length - 2) {\n            v2 = this._decodeChar(s.charCodeAt(i + 2));\n            out[op++] = (v1 << 4) | (v2 >>> 2);\n            haveBad |= v2 & INVALID_BYTE;\n        }\n        if (i < length - 3) {\n            v3 = this._decodeChar(s.charCodeAt(i + 3));\n            out[op++] = (v2 << 6) | v3;\n            haveBad |= v3 & INVALID_BYTE;\n        }\n        if (haveBad !== 0) {\n            throw new Error(\"Base64Coder: incorrect characters for decoding\");\n        }\n        return out;\n    };\n    // Standard encoding have the following encoded/decoded ranges,\n    // which we need to convert between.\n    //\n    // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789  +   /\n    // Index:   0 - 25                    26 - 51              52 - 61   62  63\n    // ASCII:  65 - 90                    97 - 122             48 - 57   43  47\n    //\n    // Encode 6 bits in b into a new character.\n    Coder.prototype._encodeByte = function (b) {\n        // Encoding uses constant time operations as follows:\n        //\n        // 1. Define comparison of A with B using (A - B) >>> 8:\n        //          if A > B, then result is positive integer\n        //          if A <= B, then result is 0\n        //\n        // 2. Define selection of C or 0 using bitwise AND: X & C:\n        //          if X == 0, then result is 0\n        //          if X != 0, then result is C\n        //\n        // 3. Start with the smallest comparison (b >= 0), which is always\n        //    true, so set the result to the starting ASCII value (65).\n        //\n        // 4. Continue comparing b to higher ASCII values, and selecting\n        //    zero if comparison isn't true, otherwise selecting a value\n        //    to add to result, which:\n        //\n        //          a) undoes the previous addition\n        //          b) provides new value to add\n        //\n        var result = b;\n        // b >= 0\n        result += 65;\n        // b > 25\n        result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n        // b > 51\n        result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n        // b > 61\n        result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n        // b > 62\n        result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n        return String.fromCharCode(result);\n    };\n    // Decode a character code into a byte.\n    // Must return 256 if character is out of alphabet range.\n    Coder.prototype._decodeChar = function (c) {\n        // Decoding works similar to encoding: using the same comparison\n        // function, but now it works on ranges: result is always incremented\n        // by value, but this value becomes zero if the range is not\n        // satisfied.\n        //\n        // Decoding starts with invalid value, 256, which is then\n        // subtracted when the range is satisfied. If none of the ranges\n        // apply, the function returns 256, which is then checked by\n        // the caller to throw error.\n        var result = INVALID_BYTE; // start with invalid character\n        // c == 43 (c > 42 and c < 44)\n        result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n        // c == 47 (c > 46 and c < 48)\n        result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n        // c > 47 and c < 58\n        result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n        // c > 64 and c < 91\n        result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n        // c > 96 and c < 123\n        result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n        return result;\n    };\n    Coder.prototype._getPaddingLength = function (s) {\n        var paddingLength = 0;\n        if (this._paddingCharacter) {\n            for (var i = s.length - 1; i >= 0; i--) {\n                if (s[i] !== this._paddingCharacter) {\n                    break;\n                }\n                paddingLength++;\n            }\n            if (s.length < 4 || paddingLength > 2) {\n                throw new Error(\"Base64Coder: incorrect padding\");\n            }\n        }\n        return paddingLength;\n    };\n    return Coder;\n}());\nexports.Coder = Coder;\nvar stdCoder = new Coder();\nfunction encode(data) {\n    return stdCoder.encode(data);\n}\nexports.encode = encode;\nfunction decode(s) {\n    return stdCoder.decode(s);\n}\nexports.decode = decode;\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nvar URLSafeCoder = /** @class */ (function (_super) {\n    __extends(URLSafeCoder, _super);\n    function URLSafeCoder() {\n        return _super !== null && _super.apply(this, arguments) || this;\n    }\n    // URL-safe encoding have the following encoded/decoded ranges:\n    //\n    // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789  -   _\n    // Index:   0 - 25                    26 - 51              52 - 61   62  63\n    // ASCII:  65 - 90                    97 - 122             48 - 57   45  95\n    //\n    URLSafeCoder.prototype._encodeByte = function (b) {\n        var result = b;\n        // b >= 0\n        result += 65;\n        // b > 25\n        result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n        // b > 51\n        result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n        // b > 61\n        result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n        // b > 62\n        result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n        return String.fromCharCode(result);\n    };\n    URLSafeCoder.prototype._decodeChar = function (c) {\n        var result = INVALID_BYTE;\n        // c == 45 (c > 44 and c < 46)\n        result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n        // c == 95 (c > 94 and c < 96)\n        result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n        // c > 47 and c < 58\n        result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n        // c > 64 and c < 91\n        result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n        // c > 96 and c < 123\n        result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n        return result;\n    };\n    return URLSafeCoder;\n}(Coder));\nexports.URLSafeCoder = URLSafeCoder;\nvar urlSafeCoder = new URLSafeCoder();\nfunction encodeURLSafe(data) {\n    return urlSafeCoder.encode(data);\n}\nexports.encodeURLSafe = encodeURLSafe;\nfunction decodeURLSafe(s) {\n    return urlSafeCoder.decode(s);\n}\nexports.decodeURLSafe = decodeURLSafe;\nexports.encodedLength = function (length) {\n    return stdCoder.encodedLength(length);\n};\nexports.maxDecodedLength = function (length) {\n    return stdCoder.maxDecodedLength(length);\n};\nexports.decodedLength = function (s) {\n    return stdCoder.decodedLength(s);\n};\n\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\nvar INVALID_UTF16 = \"utf8: invalid string\";\nvar INVALID_UTF8 = \"utf8: invalid source encoding\";\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nfunction encode(s) {\n    // Calculate result length and allocate output array.\n    // encodedLength() also validates string and throws errors,\n    // so we don't need repeat validation here.\n    var arr = new Uint8Array(encodedLength(s));\n    var pos = 0;\n    for (var i = 0; i < s.length; i++) {\n        var c = s.charCodeAt(i);\n        if (c < 0x80) {\n            arr[pos++] = c;\n        }\n        else if (c < 0x800) {\n            arr[pos++] = 0xc0 | c >> 6;\n            arr[pos++] = 0x80 | c & 0x3f;\n        }\n        else if (c < 0xd800) {\n            arr[pos++] = 0xe0 | c >> 12;\n            arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n            arr[pos++] = 0x80 | c & 0x3f;\n        }\n        else {\n            i++; // get one more character\n            c = (c & 0x3ff) << 10;\n            c |= s.charCodeAt(i) & 0x3ff;\n            c += 0x10000;\n            arr[pos++] = 0xf0 | c >> 18;\n            arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n            arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n            arr[pos++] = 0x80 | c & 0x3f;\n        }\n    }\n    return arr;\n}\nexports.encode = encode;\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nfunction encodedLength(s) {\n    var result = 0;\n    for (var i = 0; i < s.length; i++) {\n        var c = s.charCodeAt(i);\n        if (c < 0x80) {\n            result += 1;\n        }\n        else if (c < 0x800) {\n            result += 2;\n        }\n        else if (c < 0xd800) {\n            result += 3;\n        }\n        else if (c <= 0xdfff) {\n            if (i >= s.length - 1) {\n                throw new Error(INVALID_UTF16);\n            }\n            i++; // \"eat\" next character\n            result += 4;\n        }\n        else {\n            throw new Error(INVALID_UTF16);\n        }\n    }\n    return result;\n}\nexports.encodedLength = encodedLength;\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nfunction decode(arr) {\n    var chars = [];\n    for (var i = 0; i < arr.length; i++) {\n        var b = arr[i];\n        if (b & 0x80) {\n            var min = void 0;\n            if (b < 0xe0) {\n                // Need 1 more byte.\n                if (i >= arr.length) {\n                    throw new Error(INVALID_UTF8);\n                }\n                var n1 = arr[++i];\n                if ((n1 & 0xc0) !== 0x80) {\n                    throw new Error(INVALID_UTF8);\n                }\n                b = (b & 0x1f) << 6 | (n1 & 0x3f);\n                min = 0x80;\n            }\n            else if (b < 0xf0) {\n                // Need 2 more bytes.\n                if (i >= arr.length - 1) {\n                    throw new Error(INVALID_UTF8);\n                }\n                var n1 = arr[++i];\n                var n2 = arr[++i];\n                if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n                    throw new Error(INVALID_UTF8);\n                }\n                b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n                min = 0x800;\n            }\n            else if (b < 0xf8) {\n                // Need 3 more bytes.\n                if (i >= arr.length - 2) {\n                    throw new Error(INVALID_UTF8);\n                }\n                var n1 = arr[++i];\n                var n2 = arr[++i];\n                var n3 = arr[++i];\n                if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n                    throw new Error(INVALID_UTF8);\n                }\n                b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n                min = 0x10000;\n            }\n            else {\n                throw new Error(INVALID_UTF8);\n            }\n            if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n                throw new Error(INVALID_UTF8);\n            }\n            if (b >= 0x10000) {\n                // Surrogate pair.\n                if (b > 0x10ffff) {\n                    throw new Error(INVALID_UTF8);\n                }\n                b -= 0x10000;\n                chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n                b = 0xdc00 | (b & 0x3ff);\n            }\n        }\n        chars.push(String.fromCharCode(b));\n    }\n    return chars.join(\"\");\n}\nexports.decode = decode;\n\n\n/***/ }),\n/* 2 */\n/***/ (function(module, exports, __nested_webpack_require_19901__) {\n\n// required so we don't have to do require('pusher').default etc.\nmodule.exports = __nested_webpack_require_19901__(3).default;\n\n\n/***/ }),\n/* 3 */\n/***/ (function(module, __webpack_exports__, __nested_webpack_require_20105__) {\n\n\"use strict\";\n// ESM COMPAT FLAG\n__nested_webpack_require_20105__.r(__webpack_exports__);\n\n// CONCATENATED MODULE: ./src/runtimes/web/dom/script_receiver_factory.ts\nvar ScriptReceiverFactory = (function () {\n    function ScriptReceiverFactory(prefix, name) {\n        this.lastId = 0;\n        this.prefix = prefix;\n        this.name = name;\n    }\n    ScriptReceiverFactory.prototype.create = function (callback) {\n        this.lastId++;\n        var number = this.lastId;\n        var id = this.prefix + number;\n        var name = this.name + '[' + number + ']';\n        var called = false;\n        var callbackWrapper = function () {\n            if (!called) {\n                callback.apply(null, arguments);\n                called = true;\n            }\n        };\n        this[number] = callbackWrapper;\n        return { number: number, id: id, name: name, callback: callbackWrapper };\n    };\n    ScriptReceiverFactory.prototype.remove = function (receiver) {\n        delete this[receiver.number];\n    };\n    return ScriptReceiverFactory;\n}());\n\nvar ScriptReceivers = new ScriptReceiverFactory('_pusher_script_', 'Pusher.ScriptReceivers');\n\n// CONCATENATED MODULE: ./src/core/defaults.ts\nvar Defaults = {\n    VERSION: \"7.4.0\",\n    PROTOCOL: 7,\n    wsPort: 80,\n    wssPort: 443,\n    wsPath: '',\n    httpHost: 'sockjs.pusher.com',\n    httpPort: 80,\n    httpsPort: 443,\n    httpPath: '/pusher',\n    stats_host: 'stats.pusher.com',\n    authEndpoint: '/pusher/auth',\n    authTransport: 'ajax',\n    activityTimeout: 120000,\n    pongTimeout: 30000,\n    unavailableTimeout: 10000,\n    cluster: 'mt1',\n    userAuthentication: {\n        endpoint: '/pusher/user-auth',\n        transport: 'ajax'\n    },\n    channelAuthorization: {\n        endpoint: '/pusher/auth',\n        transport: 'ajax'\n    },\n    cdn_http: \"http://js.pusher.com\",\n    cdn_https: \"https://js.pusher.com\",\n    dependency_suffix: \"\"\n};\n/* harmony default export */ var defaults = (Defaults);\n\n// CONCATENATED MODULE: ./src/runtimes/web/dom/dependency_loader.ts\n\n\nvar dependency_loader_DependencyLoader = (function () {\n    function DependencyLoader(options) {\n        this.options = options;\n        this.receivers = options.receivers || ScriptReceivers;\n        this.loading = {};\n    }\n    DependencyLoader.prototype.load = function (name, options, callback) {\n        var self = this;\n        if (self.loading[name] && self.loading[name].length > 0) {\n            self.loading[name].push(callback);\n        }\n        else {\n            self.loading[name] = [callback];\n            var request = runtime.createScriptRequest(self.getPath(name, options));\n            var receiver = self.receivers.create(function (error) {\n                self.receivers.remove(receiver);\n                if (self.loading[name]) {\n                    var callbacks = self.loading[name];\n                    delete self.loading[name];\n                    var successCallback = function (wasSuccessful) {\n                        if (!wasSuccessful) {\n                            request.cleanup();\n                        }\n                    };\n                    for (var i = 0; i < callbacks.length; i++) {\n                        callbacks[i](error, successCallback);\n                    }\n                }\n            });\n            request.send(receiver);\n        }\n    };\n    DependencyLoader.prototype.getRoot = function (options) {\n        var cdn;\n        var protocol = runtime.getDocument().location.protocol;\n        if ((options && options.useTLS) || protocol === 'https:') {\n            cdn = this.options.cdn_https;\n        }\n        else {\n            cdn = this.options.cdn_http;\n        }\n        return cdn.replace(/\\/*$/, '') + '/' + this.options.version;\n    };\n    DependencyLoader.prototype.getPath = function (name, options) {\n        return this.getRoot(options) + '/' + name + this.options.suffix + '.js';\n    };\n    return DependencyLoader;\n}());\n/* harmony default export */ var dependency_loader = (dependency_loader_DependencyLoader);\n\n// CONCATENATED MODULE: ./src/runtimes/web/dom/dependencies.ts\n\n\n\nvar DependenciesReceivers = new ScriptReceiverFactory('_pusher_dependencies', 'Pusher.DependenciesReceivers');\nvar Dependencies = new dependency_loader({\n    cdn_http: defaults.cdn_http,\n    cdn_https: defaults.cdn_https,\n    version: defaults.VERSION,\n    suffix: defaults.dependency_suffix,\n    receivers: DependenciesReceivers\n});\n\n// CONCATENATED MODULE: ./src/core/utils/url_store.ts\nvar urlStore = {\n    baseUrl: 'https://pusher.com',\n    urls: {\n        authenticationEndpoint: {\n            path: '/docs/channels/server_api/authenticating_users'\n        },\n        authorizationEndpoint: {\n            path: '/docs/channels/server_api/authorizing-users/'\n        },\n        javascriptQuickStart: {\n            path: '/docs/javascript_quick_start'\n        },\n        triggeringClientEvents: {\n            path: '/docs/client_api_guide/client_events#trigger-events'\n        },\n        encryptedChannelSupport: {\n            fullUrl: 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n        }\n    }\n};\nvar buildLogSuffix = function (key) {\n    var urlPrefix = 'See:';\n    var urlObj = urlStore.urls[key];\n    if (!urlObj)\n        return '';\n    var url;\n    if (urlObj.fullUrl) {\n        url = urlObj.fullUrl;\n    }\n    else if (urlObj.path) {\n        url = urlStore.baseUrl + urlObj.path;\n    }\n    if (!url)\n        return '';\n    return urlPrefix + \" \" + url;\n};\n/* harmony default export */ var url_store = ({ buildLogSuffix: buildLogSuffix });\n\n// CONCATENATED MODULE: ./src/core/auth/options.ts\nvar AuthRequestType;\n(function (AuthRequestType) {\n    AuthRequestType[\"UserAuthentication\"] = \"user-authentication\";\n    AuthRequestType[\"ChannelAuthorization\"] = \"channel-authorization\";\n})(AuthRequestType || (AuthRequestType = {}));\n\n// CONCATENATED MODULE: ./src/core/errors.ts\nvar __extends = ( false) || (function () {\n    var extendStatics = function (d, b) {\n        extendStatics = Object.setPrototypeOf ||\n            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n        return extendStatics(d, b);\n    };\n    return function (d, b) {\n        extendStatics(d, b);\n        function __() { this.constructor = d; }\n        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n    };\n})();\nvar BadEventName = (function (_super) {\n    __extends(BadEventName, _super);\n    function BadEventName(msg) {\n        var _newTarget = this.constructor;\n        var _this = _super.call(this, msg) || this;\n        Object.setPrototypeOf(_this, _newTarget.prototype);\n        return _this;\n    }\n    return BadEventName;\n}(Error));\n\nvar BadChannelName = (function (_super) {\n    __extends(BadChannelName, _super);\n    function BadChannelName(msg) {\n        var _newTarget = this.constructor;\n        var _this = _super.call(this, msg) || this;\n        Object.setPrototypeOf(_this, _newTarget.prototype);\n        return _this;\n    }\n    return BadChannelName;\n}(Error));\n\nvar RequestTimedOut = (function (_super) {\n    __extends(RequestTimedOut, _super);\n    function RequestTimedOut(msg) {\n        var _newTarget = this.constructor;\n        var _this = _super.call(this, msg) || this;\n        Object.setPrototypeOf(_this, _newTarget.prototype);\n        return _this;\n    }\n    return RequestTimedOut;\n}(Error));\n\nvar TransportPriorityTooLow = (function (_super) {\n    __extends(TransportPriorityTooLow, _super);\n    function TransportPriorityTooLow(msg) {\n        var _newTarget = this.constructor;\n        var _this = _super.call(this, msg) || this;\n        Object.setPrototypeOf(_this, _newTarget.prototype);\n        return _this;\n    }\n    return TransportPriorityTooLow;\n}(Error));\n\nvar TransportClosed = (function (_super) {\n    __extends(TransportClosed, _super);\n    function TransportClosed(msg) {\n        var _newTarget = this.constructor;\n        var _this = _super.call(this, msg) || this;\n        Object.setPrototypeOf(_this, _newTarget.prototype);\n        return _this;\n    }\n    return TransportClosed;\n}(Error));\n\nvar UnsupportedFeature = (function (_super) {\n    __extends(UnsupportedFeature, _super);\n    function UnsupportedFeature(msg) {\n        var _newTarget = this.constructor;\n        var _this = _super.call(this, msg) || this;\n        Object.setPrototypeOf(_this, _newTarget.prototype);\n        return _this;\n    }\n    return UnsupportedFeature;\n}(Error));\n\nvar UnsupportedTransport = (function (_super) {\n    __extends(UnsupportedTransport, _super);\n    function UnsupportedTransport(msg) {\n        var _newTarget = this.constructor;\n        var _this = _super.call(this, msg) || this;\n        Object.setPrototypeOf(_this, _newTarget.prototype);\n        return _this;\n    }\n    return UnsupportedTransport;\n}(Error));\n\nvar UnsupportedStrategy = (function (_super) {\n    __extends(UnsupportedStrategy, _super);\n    function UnsupportedStrategy(msg) {\n        var _newTarget = this.constructor;\n        var _this = _super.call(this, msg) || this;\n        Object.setPrototypeOf(_this, _newTarget.prototype);\n        return _this;\n    }\n    return UnsupportedStrategy;\n}(Error));\n\nvar HTTPAuthError = (function (_super) {\n    __extends(HTTPAuthError, _super);\n    function HTTPAuthError(status, msg) {\n        var _newTarget = this.constructor;\n        var _this = _super.call(this, msg) || this;\n        _this.status = status;\n        Object.setPrototypeOf(_this, _newTarget.prototype);\n        return _this;\n    }\n    return HTTPAuthError;\n}(Error));\n\n\n// CONCATENATED MODULE: ./src/runtimes/isomorphic/auth/xhr_auth.ts\n\n\n\n\nvar ajax = function (context, query, authOptions, authRequestType, callback) {\n    var xhr = runtime.createXHR();\n    xhr.open('POST', authOptions.endpoint, true);\n    xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n    for (var headerName in authOptions.headers) {\n        xhr.setRequestHeader(headerName, authOptions.headers[headerName]);\n    }\n    xhr.onreadystatechange = function () {\n        if (xhr.readyState === 4) {\n            if (xhr.status === 200) {\n                var data = void 0;\n                var parsed = false;\n                try {\n                    data = JSON.parse(xhr.responseText);\n                    parsed = true;\n                }\n                catch (e) {\n                    callback(new HTTPAuthError(200, \"JSON returned from \" + authRequestType.toString() + \" endpoint was invalid, yet status code was 200. Data was: \" + xhr.responseText), null);\n                }\n                if (parsed) {\n                    callback(null, data);\n                }\n            }\n            else {\n                var suffix = '';\n                switch (authRequestType) {\n                    case AuthRequestType.UserAuthentication:\n                        suffix = url_store.buildLogSuffix('authenticationEndpoint');\n                        break;\n                    case AuthRequestType.ChannelAuthorization:\n                        suffix = \"Clients must be authenticated to join private or presence channels. \" + url_store.buildLogSuffix('authorizationEndpoint');\n                        break;\n                }\n                callback(new HTTPAuthError(xhr.status, \"Unable to retrieve auth string from \" + authRequestType.toString() + \" endpoint - \" +\n                    (\"received status: \" + xhr.status + \" from \" + authOptions.endpoint + \". \" + suffix)), null);\n            }\n        }\n    };\n    xhr.send(query);\n    return xhr;\n};\n/* harmony default export */ var xhr_auth = (ajax);\n\n// CONCATENATED MODULE: ./src/core/base64.ts\nfunction encode(s) {\n    return btoa(utob(s));\n}\nvar fromCharCode = String.fromCharCode;\nvar b64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\nfor (var base64_i = 0, l = b64chars.length; base64_i < l; base64_i++) {\n    b64tab[b64chars.charAt(base64_i)] = base64_i;\n}\nvar cb_utob = function (c) {\n    var cc = c.charCodeAt(0);\n    return cc < 0x80\n        ? c\n        : cc < 0x800\n            ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n            : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n                fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n                fromCharCode(0x80 | (cc & 0x3f));\n};\nvar utob = function (u) {\n    return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\nvar cb_encode = function (ccc) {\n    var padlen = [0, 2, 1][ccc.length % 3];\n    var ord = (ccc.charCodeAt(0) << 16) |\n        ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n        (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n    var chars = [\n        b64chars.charAt(ord >>> 18),\n        b64chars.charAt((ord >>> 12) & 63),\n        padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n        padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n    ];\n    return chars.join('');\n};\nvar btoa = window.btoa ||\n    function (b) {\n        return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n    };\n\n// CONCATENATED MODULE: ./src/core/utils/timers/abstract_timer.ts\nvar Timer = (function () {\n    function Timer(set, clear, delay, callback) {\n        var _this = this;\n        this.clear = clear;\n        this.timer = set(function () {\n            if (_this.timer) {\n                _this.timer = callback(_this.timer);\n            }\n        }, delay);\n    }\n    Timer.prototype.isRunning = function () {\n        return this.timer !== null;\n    };\n    Timer.prototype.ensureAborted = function () {\n        if (this.timer) {\n            this.clear(this.timer);\n            this.timer = null;\n        }\n    };\n    return Timer;\n}());\n/* harmony default export */ var abstract_timer = (Timer);\n\n// CONCATENATED MODULE: ./src/core/utils/timers/index.ts\nvar timers_extends = ( false) || (function () {\n    var extendStatics = function (d, b) {\n        extendStatics = Object.setPrototypeOf ||\n            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n        return extendStatics(d, b);\n    };\n    return function (d, b) {\n        extendStatics(d, b);\n        function __() { this.constructor = d; }\n        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n    };\n})();\n\nfunction timers_clearTimeout(timer) {\n    window.clearTimeout(timer);\n}\nfunction timers_clearInterval(timer) {\n    window.clearInterval(timer);\n}\nvar OneOffTimer = (function (_super) {\n    timers_extends(OneOffTimer, _super);\n    function OneOffTimer(delay, callback) {\n        return _super.call(this, setTimeout, timers_clearTimeout, delay, function (timer) {\n            callback();\n            return null;\n        }) || this;\n    }\n    return OneOffTimer;\n}(abstract_timer));\n\nvar PeriodicTimer = (function (_super) {\n    timers_extends(PeriodicTimer, _super);\n    function PeriodicTimer(delay, callback) {\n        return _super.call(this, setInterval, timers_clearInterval, delay, function (timer) {\n            callback();\n            return timer;\n        }) || this;\n    }\n    return PeriodicTimer;\n}(abstract_timer));\n\n\n// CONCATENATED MODULE: ./src/core/util.ts\n\nvar Util = {\n    now: function () {\n        if (Date.now) {\n            return Date.now();\n        }\n        else {\n            return new Date().valueOf();\n        }\n    },\n    defer: function (callback) {\n        return new OneOffTimer(0, callback);\n    },\n    method: function (name) {\n        var args = [];\n        for (var _i = 1; _i < arguments.length; _i++) {\n            args[_i - 1] = arguments[_i];\n        }\n        var boundArguments = Array.prototype.slice.call(arguments, 1);\n        return function (object) {\n            return object[name].apply(object, boundArguments.concat(arguments));\n        };\n    }\n};\n/* harmony default export */ var util = (Util);\n\n// CONCATENATED MODULE: ./src/core/utils/collections.ts\n\n\nfunction extend(target) {\n    var sources = [];\n    for (var _i = 1; _i < arguments.length; _i++) {\n        sources[_i - 1] = arguments[_i];\n    }\n    for (var i = 0; i < sources.length; i++) {\n        var extensions = sources[i];\n        for (var property in extensions) {\n            if (extensions[property] &&\n                extensions[property].constructor &&\n                extensions[property].constructor === Object) {\n                target[property] = extend(target[property] || {}, extensions[property]);\n            }\n            else {\n                target[property] = extensions[property];\n            }\n        }\n    }\n    return target;\n}\nfunction stringify() {\n    var m = ['Pusher'];\n    for (var i = 0; i < arguments.length; i++) {\n        if (typeof arguments[i] === 'string') {\n            m.push(arguments[i]);\n        }\n        else {\n            m.push(safeJSONStringify(arguments[i]));\n        }\n    }\n    return m.join(' : ');\n}\nfunction arrayIndexOf(array, item) {\n    var nativeIndexOf = Array.prototype.indexOf;\n    if (array === null) {\n        return -1;\n    }\n    if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n        return array.indexOf(item);\n    }\n    for (var i = 0, l = array.length; i < l; i++) {\n        if (array[i] === item) {\n            return i;\n        }\n    }\n    return -1;\n}\nfunction objectApply(object, f) {\n    for (var key in object) {\n        if (Object.prototype.hasOwnProperty.call(object, key)) {\n            f(object[key], key, object);\n        }\n    }\n}\nfunction keys(object) {\n    var keys = [];\n    objectApply(object, function (_, key) {\n        keys.push(key);\n    });\n    return keys;\n}\nfunction values(object) {\n    var values = [];\n    objectApply(object, function (value) {\n        values.push(value);\n    });\n    return values;\n}\nfunction apply(array, f, context) {\n    for (var i = 0; i < array.length; i++) {\n        f.call(context || window, array[i], i, array);\n    }\n}\nfunction map(array, f) {\n    var result = [];\n    for (var i = 0; i < array.length; i++) {\n        result.push(f(array[i], i, array, result));\n    }\n    return result;\n}\nfunction mapObject(object, f) {\n    var result = {};\n    objectApply(object, function (value, key) {\n        result[key] = f(value);\n    });\n    return result;\n}\nfunction filter(array, test) {\n    test =\n        test ||\n            function (value) {\n                return !!value;\n            };\n    var result = [];\n    for (var i = 0; i < array.length; i++) {\n        if (test(array[i], i, array, result)) {\n            result.push(array[i]);\n        }\n    }\n    return result;\n}\nfunction filterObject(object, test) {\n    var result = {};\n    objectApply(object, function (value, key) {\n        if ((test && test(value, key, object, result)) || Boolean(value)) {\n            result[key] = value;\n        }\n    });\n    return result;\n}\nfunction flatten(object) {\n    var result = [];\n    objectApply(object, function (value, key) {\n        result.push([key, value]);\n    });\n    return result;\n}\nfunction any(array, test) {\n    for (var i = 0; i < array.length; i++) {\n        if (test(array[i], i, array)) {\n            return true;\n        }\n    }\n    return false;\n}\nfunction collections_all(array, test) {\n    for (var i = 0; i < array.length; i++) {\n        if (!test(array[i], i, array)) {\n            return false;\n        }\n    }\n    return true;\n}\nfunction encodeParamsObject(data) {\n    return mapObject(data, function (value) {\n        if (typeof value === 'object') {\n            value = safeJSONStringify(value);\n        }\n        return encodeURIComponent(encode(value.toString()));\n    });\n}\nfunction buildQueryString(data) {\n    var params = filterObject(data, function (value) {\n        return value !== undefined;\n    });\n    var query = map(flatten(encodeParamsObject(params)), util.method('join', '=')).join('&');\n    return query;\n}\nfunction decycleObject(object) {\n    var objects = [], paths = [];\n    return (function derez(value, path) {\n        var i, name, nu;\n        switch (typeof value) {\n            case 'object':\n                if (!value) {\n                    return null;\n                }\n                for (i = 0; i < objects.length; i += 1) {\n                    if (objects[i] === value) {\n                        return { $ref: paths[i] };\n                    }\n                }\n                objects.push(value);\n                paths.push(path);\n                if (Object.prototype.toString.apply(value) === '[object Array]') {\n                    nu = [];\n                    for (i = 0; i < value.length; i += 1) {\n                        nu[i] = derez(value[i], path + '[' + i + ']');\n                    }\n                }\n                else {\n                    nu = {};\n                    for (name in value) {\n                        if (Object.prototype.hasOwnProperty.call(value, name)) {\n                            nu[name] = derez(value[name], path + '[' + JSON.stringify(name) + ']');\n                        }\n                    }\n                }\n                return nu;\n            case 'number':\n            case 'string':\n            case 'boolean':\n                return value;\n        }\n    })(object, '$');\n}\nfunction safeJSONStringify(source) {\n    try {\n        return JSON.stringify(source);\n    }\n    catch (e) {\n        return JSON.stringify(decycleObject(source));\n    }\n}\n\n// CONCATENATED MODULE: ./src/core/logger.ts\n\n\nvar logger_Logger = (function () {\n    function Logger() {\n        this.globalLog = function (message) {\n            if (window.console && window.console.log) {\n                window.console.log(message);\n            }\n        };\n    }\n    Logger.prototype.debug = function () {\n        var args = [];\n        for (var _i = 0; _i < arguments.length; _i++) {\n            args[_i] = arguments[_i];\n        }\n        this.log(this.globalLog, args);\n    };\n    Logger.prototype.warn = function () {\n        var args = [];\n        for (var _i = 0; _i < arguments.length; _i++) {\n            args[_i] = arguments[_i];\n        }\n        this.log(this.globalLogWarn, args);\n    };\n    Logger.prototype.error = function () {\n        var args = [];\n        for (var _i = 0; _i < arguments.length; _i++) {\n            args[_i] = arguments[_i];\n        }\n        this.log(this.globalLogError, args);\n    };\n    Logger.prototype.globalLogWarn = function (message) {\n        if (window.console && window.console.warn) {\n            window.console.warn(message);\n        }\n        else {\n            this.globalLog(message);\n        }\n    };\n    Logger.prototype.globalLogError = function (message) {\n        if (window.console && window.console.error) {\n            window.console.error(message);\n        }\n        else {\n            this.globalLogWarn(message);\n        }\n    };\n    Logger.prototype.log = function (defaultLoggingFunction) {\n        var args = [];\n        for (var _i = 1; _i < arguments.length; _i++) {\n            args[_i - 1] = arguments[_i];\n        }\n        var message = stringify.apply(this, arguments);\n        if (core_pusher.log) {\n            core_pusher.log(message);\n        }\n        else if (core_pusher.logToConsole) {\n            var log = defaultLoggingFunction.bind(this);\n            log(message);\n        }\n    };\n    return Logger;\n}());\n/* harmony default export */ var logger = (new logger_Logger());\n\n// CONCATENATED MODULE: ./src/runtimes/web/auth/jsonp_auth.ts\n\nvar jsonp = function (context, query, authOptions, authRequestType, callback) {\n    if (authOptions.headers !== undefined) {\n        logger.warn(\"To send headers with the \" + authRequestType.toString() + \" request, you must use AJAX, rather than JSONP.\");\n    }\n    var callbackName = context.nextAuthCallbackID.toString();\n    context.nextAuthCallbackID++;\n    var document = context.getDocument();\n    var script = document.createElement('script');\n    context.auth_callbacks[callbackName] = function (data) {\n        callback(null, data);\n    };\n    var callback_name = \"Pusher.auth_callbacks['\" + callbackName + \"']\";\n    script.src =\n        authOptions.endpoint +\n            '?callback=' +\n            encodeURIComponent(callback_name) +\n            '&' +\n            query;\n    var head = document.getElementsByTagName('head')[0] || document.documentElement;\n    head.insertBefore(script, head.firstChild);\n};\n/* harmony default export */ var jsonp_auth = (jsonp);\n\n// CONCATENATED MODULE: ./src/runtimes/web/dom/script_request.ts\nvar ScriptRequest = (function () {\n    function ScriptRequest(src) {\n        this.src = src;\n    }\n    ScriptRequest.prototype.send = function (receiver) {\n        var self = this;\n        var errorString = 'Error loading ' + self.src;\n        self.script = document.createElement('script');\n        self.script.id = receiver.id;\n        self.script.src = self.src;\n        self.script.type = 'text/javascript';\n        self.script.charset = 'UTF-8';\n        if (self.script.addEventListener) {\n            self.script.onerror = function () {\n                receiver.callback(errorString);\n            };\n            self.script.onload = function () {\n                receiver.callback(null);\n            };\n        }\n        else {\n            self.script.onreadystatechange = function () {\n                if (self.script.readyState === 'loaded' ||\n                    self.script.readyState === 'complete') {\n                    receiver.callback(null);\n                }\n            };\n        }\n        if (self.script.async === undefined &&\n            document.attachEvent &&\n            /opera/i.test(navigator.userAgent)) {\n            self.errorScript = document.createElement('script');\n            self.errorScript.id = receiver.id + '_error';\n            self.errorScript.text = receiver.name + \"('\" + errorString + \"');\";\n            self.script.async = self.errorScript.async = false;\n        }\n        else {\n            self.script.async = true;\n        }\n        var head = document.getElementsByTagName('head')[0];\n        head.insertBefore(self.script, head.firstChild);\n        if (self.errorScript) {\n            head.insertBefore(self.errorScript, self.script.nextSibling);\n        }\n    };\n    ScriptRequest.prototype.cleanup = function () {\n        if (this.script) {\n            this.script.onload = this.script.onerror = null;\n            this.script.onreadystatechange = null;\n        }\n        if (this.script && this.script.parentNode) {\n            this.script.parentNode.removeChild(this.script);\n        }\n        if (this.errorScript && this.errorScript.parentNode) {\n            this.errorScript.parentNode.removeChild(this.errorScript);\n        }\n        this.script = null;\n        this.errorScript = null;\n    };\n    return ScriptRequest;\n}());\n/* harmony default export */ var script_request = (ScriptRequest);\n\n// CONCATENATED MODULE: ./src/runtimes/web/dom/jsonp_request.ts\n\n\nvar jsonp_request_JSONPRequest = (function () {\n    function JSONPRequest(url, data) {\n        this.url = url;\n        this.data = data;\n    }\n    JSONPRequest.prototype.send = function (receiver) {\n        if (this.request) {\n            return;\n        }\n        var query = buildQueryString(this.data);\n        var url = this.url + '/' + receiver.number + '?' + query;\n        this.request = runtime.createScriptRequest(url);\n        this.request.send(receiver);\n    };\n    JSONPRequest.prototype.cleanup = function () {\n        if (this.request) {\n            this.request.cleanup();\n        }\n    };\n    return JSONPRequest;\n}());\n/* harmony default export */ var jsonp_request = (jsonp_request_JSONPRequest);\n\n// CONCATENATED MODULE: ./src/runtimes/web/timeline/jsonp_timeline.ts\n\n\nvar getAgent = function (sender, useTLS) {\n    return function (data, callback) {\n        var scheme = 'http' + (useTLS ? 's' : '') + '://';\n        var url = scheme + (sender.host || sender.options.host) + sender.options.path;\n        var request = runtime.createJSONPRequest(url, data);\n        var receiver = runtime.ScriptReceivers.create(function (error, result) {\n            ScriptReceivers.remove(receiver);\n            request.cleanup();\n            if (result && result.host) {\n                sender.host = result.host;\n            }\n            if (callback) {\n                callback(error, result);\n            }\n        });\n        request.send(receiver);\n    };\n};\nvar jsonp_timeline_jsonp = {\n    name: 'jsonp',\n    getAgent: getAgent\n};\n/* harmony default export */ var jsonp_timeline = (jsonp_timeline_jsonp);\n\n// CONCATENATED MODULE: ./src/core/transports/url_schemes.ts\n\nfunction getGenericURL(baseScheme, params, path) {\n    var scheme = baseScheme + (params.useTLS ? 's' : '');\n    var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n    return scheme + '://' + host + path;\n}\nfunction getGenericPath(key, queryString) {\n    var path = '/app/' + key;\n    var query = '?protocol=' +\n        defaults.PROTOCOL +\n        '&client=js' +\n        '&version=' +\n        defaults.VERSION +\n        (queryString ? '&' + queryString : '');\n    return path + query;\n}\nvar ws = {\n    getInitial: function (key, params) {\n        var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n        return getGenericURL('ws', params, path);\n    }\n};\nvar http = {\n    getInitial: function (key, params) {\n        var path = (params.httpPath || '/pusher') + getGenericPath(key);\n        return getGenericURL('http', params, path);\n    }\n};\nvar sockjs = {\n    getInitial: function (key, params) {\n        return getGenericURL('http', params, params.httpPath || '/pusher');\n    },\n    getPath: function (key, params) {\n        return getGenericPath(key);\n    }\n};\n\n// CONCATENATED MODULE: ./src/core/events/callback_registry.ts\n\nvar callback_registry_CallbackRegistry = (function () {\n    function CallbackRegistry() {\n        this._callbacks = {};\n    }\n    CallbackRegistry.prototype.get = function (name) {\n        return this._callbacks[prefix(name)];\n    };\n    CallbackRegistry.prototype.add = function (name, callback, context) {\n        var prefixedEventName = prefix(name);\n        this._callbacks[prefixedEventName] =\n            this._callbacks[prefixedEventName] || [];\n        this._callbacks[prefixedEventName].push({\n            fn: callback,\n            context: context\n        });\n    };\n    CallbackRegistry.prototype.remove = function (name, callback, context) {\n        if (!name && !callback && !context) {\n            this._callbacks = {};\n            return;\n        }\n        var names = name ? [prefix(name)] : keys(this._callbacks);\n        if (callback || context) {\n            this.removeCallback(names, callback, context);\n        }\n        else {\n            this.removeAllCallbacks(names);\n        }\n    };\n    CallbackRegistry.prototype.removeCallback = function (names, callback, context) {\n        apply(names, function (name) {\n            this._callbacks[name] = filter(this._callbacks[name] || [], function (binding) {\n                return ((callback && callback !== binding.fn) ||\n                    (context && context !== binding.context));\n            });\n            if (this._callbacks[name].length === 0) {\n                delete this._callbacks[name];\n            }\n        }, this);\n    };\n    CallbackRegistry.prototype.removeAllCallbacks = function (names) {\n        apply(names, function (name) {\n            delete this._callbacks[name];\n        }, this);\n    };\n    return CallbackRegistry;\n}());\n/* harmony default export */ var callback_registry = (callback_registry_CallbackRegistry);\nfunction prefix(name) {\n    return '_' + name;\n}\n\n// CONCATENATED MODULE: ./src/core/events/dispatcher.ts\n\n\nvar dispatcher_Dispatcher = (function () {\n    function Dispatcher(failThrough) {\n        this.callbacks = new callback_registry();\n        this.global_callbacks = [];\n        this.failThrough = failThrough;\n    }\n    Dispatcher.prototype.bind = function (eventName, callback, context) {\n        this.callbacks.add(eventName, callback, context);\n        return this;\n    };\n    Dispatcher.prototype.bind_global = function (callback) {\n        this.global_callbacks.push(callback);\n        return this;\n    };\n    Dispatcher.prototype.unbind = function (eventName, callback, context) {\n        this.callbacks.remove(eventName, callback, context);\n        return this;\n    };\n    Dispatcher.prototype.unbind_global = function (callback) {\n        if (!callback) {\n            this.global_callbacks = [];\n            return this;\n        }\n        this.global_callbacks = filter(this.global_callbacks || [], function (c) { return c !== callback; });\n        return this;\n    };\n    Dispatcher.prototype.unbind_all = function () {\n        this.unbind();\n        this.unbind_global();\n        return this;\n    };\n    Dispatcher.prototype.emit = function (eventName, data, metadata) {\n        for (var i = 0; i < this.global_callbacks.length; i++) {\n            this.global_callbacks[i](eventName, data);\n        }\n        var callbacks = this.callbacks.get(eventName);\n        var args = [];\n        if (metadata) {\n            args.push(data, metadata);\n        }\n        else if (data) {\n            args.push(data);\n        }\n        if (callbacks && callbacks.length > 0) {\n            for (var i = 0; i < callbacks.length; i++) {\n                callbacks[i].fn.apply(callbacks[i].context || window, args);\n            }\n        }\n        else if (this.failThrough) {\n            this.failThrough(eventName, data);\n        }\n        return this;\n    };\n    return Dispatcher;\n}());\n/* harmony default export */ var dispatcher = (dispatcher_Dispatcher);\n\n// CONCATENATED MODULE: ./src/core/transports/transport_connection.ts\nvar transport_connection_extends = ( false) || (function () {\n    var extendStatics = function (d, b) {\n        extendStatics = Object.setPrototypeOf ||\n            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n        return extendStatics(d, b);\n    };\n    return function (d, b) {\n        extendStatics(d, b);\n        function __() { this.constructor = d; }\n        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n    };\n})();\n\n\n\n\n\nvar transport_connection_TransportConnection = (function (_super) {\n    transport_connection_extends(TransportConnection, _super);\n    function TransportConnection(hooks, name, priority, key, options) {\n        var _this = _super.call(this) || this;\n        _this.initialize = runtime.transportConnectionInitializer;\n        _this.hooks = hooks;\n        _this.name = name;\n        _this.priority = priority;\n        _this.key = key;\n        _this.options = options;\n        _this.state = 'new';\n        _this.timeline = options.timeline;\n        _this.activityTimeout = options.activityTimeout;\n        _this.id = _this.timeline.generateUniqueID();\n        return _this;\n    }\n    TransportConnection.prototype.handlesActivityChecks = function () {\n        return Boolean(this.hooks.handlesActivityChecks);\n    };\n    TransportConnection.prototype.supportsPing = function () {\n        return Boolean(this.hooks.supportsPing);\n    };\n    TransportConnection.prototype.connect = function () {\n        var _this = this;\n        if (this.socket || this.state !== 'initialized') {\n            return false;\n        }\n        var url = this.hooks.urls.getInitial(this.key, this.options);\n        try {\n            this.socket = this.hooks.getSocket(url, this.options);\n        }\n        catch (e) {\n            util.defer(function () {\n                _this.onError(e);\n                _this.changeState('closed');\n            });\n            return false;\n        }\n        this.bindListeners();\n        logger.debug('Connecting', { transport: this.name, url: url });\n        this.changeState('connecting');\n        return true;\n    };\n    TransportConnection.prototype.close = function () {\n        if (this.socket) {\n            this.socket.close();\n            return true;\n        }\n        else {\n            return false;\n        }\n    };\n    TransportConnection.prototype.send = function (data) {\n        var _this = this;\n        if (this.state === 'open') {\n            util.defer(function () {\n                if (_this.socket) {\n                    _this.socket.send(data);\n                }\n            });\n            return true;\n        }\n        else {\n            return false;\n        }\n    };\n    TransportConnection.prototype.ping = function () {\n        if (this.state === 'open' && this.supportsPing()) {\n            this.socket.ping();\n        }\n    };\n    TransportConnection.prototype.onOpen = function () {\n        if (this.hooks.beforeOpen) {\n            this.hooks.beforeOpen(this.socket, this.hooks.urls.getPath(this.key, this.options));\n        }\n        this.changeState('open');\n        this.socket.onopen = undefined;\n    };\n    TransportConnection.prototype.onError = function (error) {\n        this.emit('error', { type: 'WebSocketError', error: error });\n        this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n    };\n    TransportConnection.prototype.onClose = function (closeEvent) {\n        if (closeEvent) {\n            this.changeState('closed', {\n                code: closeEvent.code,\n                reason: closeEvent.reason,\n                wasClean: closeEvent.wasClean\n            });\n        }\n        else {\n            this.changeState('closed');\n        }\n        this.unbindListeners();\n        this.socket = undefined;\n    };\n    TransportConnection.prototype.onMessage = function (message) {\n        this.emit('message', message);\n    };\n    TransportConnection.prototype.onActivity = function () {\n        this.emit('activity');\n    };\n    TransportConnection.prototype.bindListeners = function () {\n        var _this = this;\n        this.socket.onopen = function () {\n            _this.onOpen();\n        };\n        this.socket.onerror = function (error) {\n            _this.onError(error);\n        };\n        this.socket.onclose = function (closeEvent) {\n            _this.onClose(closeEvent);\n        };\n        this.socket.onmessage = function (message) {\n            _this.onMessage(message);\n        };\n        if (this.supportsPing()) {\n            this.socket.onactivity = function () {\n                _this.onActivity();\n            };\n        }\n    };\n    TransportConnection.prototype.unbindListeners = function () {\n        if (this.socket) {\n            this.socket.onopen = undefined;\n            this.socket.onerror = undefined;\n            this.socket.onclose = undefined;\n            this.socket.onmessage = undefined;\n            if (this.supportsPing()) {\n                this.socket.onactivity = undefined;\n            }\n        }\n    };\n    TransportConnection.prototype.changeState = function (state, params) {\n        this.state = state;\n        this.timeline.info(this.buildTimelineMessage({\n            state: state,\n            params: params\n        }));\n        this.emit(state, params);\n    };\n    TransportConnection.prototype.buildTimelineMessage = function (message) {\n        return extend({ cid: this.id }, message);\n    };\n    return TransportConnection;\n}(dispatcher));\n/* harmony default export */ var transport_connection = (transport_connection_TransportConnection);\n\n// CONCATENATED MODULE: ./src/core/transports/transport.ts\n\nvar transport_Transport = (function () {\n    function Transport(hooks) {\n        this.hooks = hooks;\n    }\n    Transport.prototype.isSupported = function (environment) {\n        return this.hooks.isSupported(environment);\n    };\n    Transport.prototype.createConnection = function (name, priority, key, options) {\n        return new transport_connection(this.hooks, name, priority, key, options);\n    };\n    return Transport;\n}());\n/* harmony default export */ var transports_transport = (transport_Transport);\n\n// CONCATENATED MODULE: ./src/runtimes/isomorphic/transports/transports.ts\n\n\n\n\nvar WSTransport = new transports_transport({\n    urls: ws,\n    handlesActivityChecks: false,\n    supportsPing: false,\n    isInitialized: function () {\n        return Boolean(runtime.getWebSocketAPI());\n    },\n    isSupported: function () {\n        return Boolean(runtime.getWebSocketAPI());\n    },\n    getSocket: function (url) {\n        return runtime.createWebSocket(url);\n    }\n});\nvar httpConfiguration = {\n    urls: http,\n    handlesActivityChecks: false,\n    supportsPing: true,\n    isInitialized: function () {\n        return true;\n    }\n};\nvar streamingConfiguration = extend({\n    getSocket: function (url) {\n        return runtime.HTTPFactory.createStreamingSocket(url);\n    }\n}, httpConfiguration);\nvar pollingConfiguration = extend({\n    getSocket: function (url) {\n        return runtime.HTTPFactory.createPollingSocket(url);\n    }\n}, httpConfiguration);\nvar xhrConfiguration = {\n    isSupported: function () {\n        return runtime.isXHRSupported();\n    }\n};\nvar XHRStreamingTransport = new transports_transport((extend({}, streamingConfiguration, xhrConfiguration)));\nvar XHRPollingTransport = new transports_transport(extend({}, pollingConfiguration, xhrConfiguration));\nvar Transports = {\n    ws: WSTransport,\n    xhr_streaming: XHRStreamingTransport,\n    xhr_polling: XHRPollingTransport\n};\n/* harmony default export */ var transports = (Transports);\n\n// CONCATENATED MODULE: ./src/runtimes/web/transports/transports.ts\n\n\n\n\n\n\nvar SockJSTransport = new transports_transport({\n    file: 'sockjs',\n    urls: sockjs,\n    handlesActivityChecks: true,\n    supportsPing: false,\n    isSupported: function () {\n        return true;\n    },\n    isInitialized: function () {\n        return window.SockJS !== undefined;\n    },\n    getSocket: function (url, options) {\n        return new window.SockJS(url, null, {\n            js_path: Dependencies.getPath('sockjs', {\n                useTLS: options.useTLS\n            }),\n            ignore_null_origin: options.ignoreNullOrigin\n        });\n    },\n    beforeOpen: function (socket, path) {\n        socket.send(JSON.stringify({\n            path: path\n        }));\n    }\n});\nvar xdrConfiguration = {\n    isSupported: function (environment) {\n        var yes = runtime.isXDRSupported(environment.useTLS);\n        return yes;\n    }\n};\nvar XDRStreamingTransport = new transports_transport((extend({}, streamingConfiguration, xdrConfiguration)));\nvar XDRPollingTransport = new transports_transport(extend({}, pollingConfiguration, xdrConfiguration));\ntransports.xdr_streaming = XDRStreamingTransport;\ntransports.xdr_polling = XDRPollingTransport;\ntransports.sockjs = SockJSTransport;\n/* harmony default export */ var transports_transports = (transports);\n\n// CONCATENATED MODULE: ./src/runtimes/web/net_info.ts\nvar net_info_extends = ( false) || (function () {\n    var extendStatics = function (d, b) {\n        extendStatics = Object.setPrototypeOf ||\n            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n        return extendStatics(d, b);\n    };\n    return function (d, b) {\n        extendStatics(d, b);\n        function __() { this.constructor = d; }\n        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n    };\n})();\n\nvar NetInfo = (function (_super) {\n    net_info_extends(NetInfo, _super);\n    function NetInfo() {\n        var _this = _super.call(this) || this;\n        var self = _this;\n        if (window.addEventListener !== undefined) {\n            window.addEventListener('online', function () {\n                self.emit('online');\n            }, false);\n            window.addEventListener('offline', function () {\n                self.emit('offline');\n            }, false);\n        }\n        return _this;\n    }\n    NetInfo.prototype.isOnline = function () {\n        if (window.navigator.onLine === undefined) {\n            return true;\n        }\n        else {\n            return window.navigator.onLine;\n        }\n    };\n    return NetInfo;\n}(dispatcher));\n\nvar net_info_Network = new NetInfo();\n\n// CONCATENATED MODULE: ./src/core/transports/assistant_to_the_transport_manager.ts\n\n\nvar assistant_to_the_transport_manager_AssistantToTheTransportManager = (function () {\n    function AssistantToTheTransportManager(manager, transport, options) {\n        this.manager = manager;\n        this.transport = transport;\n        this.minPingDelay = options.minPingDelay;\n        this.maxPingDelay = options.maxPingDelay;\n        this.pingDelay = undefined;\n    }\n    AssistantToTheTransportManager.prototype.createConnection = function (name, priority, key, options) {\n        var _this = this;\n        options = extend({}, options, {\n            activityTimeout: this.pingDelay\n        });\n        var connection = this.transport.createConnection(name, priority, key, options);\n        var openTimestamp = null;\n        var onOpen = function () {\n            connection.unbind('open', onOpen);\n            connection.bind('closed', onClosed);\n            openTimestamp = util.now();\n        };\n        var onClosed = function (closeEvent) {\n            connection.unbind('closed', onClosed);\n            if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n                _this.manager.reportDeath();\n            }\n            else if (!closeEvent.wasClean && openTimestamp) {\n                var lifespan = util.now() - openTimestamp;\n                if (lifespan < 2 * _this.maxPingDelay) {\n                    _this.manager.reportDeath();\n                    _this.pingDelay = Math.max(lifespan / 2, _this.minPingDelay);\n                }\n            }\n        };\n        connection.bind('open', onOpen);\n        return connection;\n    };\n    AssistantToTheTransportManager.prototype.isSupported = function (environment) {\n        return this.manager.isAlive() && this.transport.isSupported(environment);\n    };\n    return AssistantToTheTransportManager;\n}());\n/* harmony default export */ var assistant_to_the_transport_manager = (assistant_to_the_transport_manager_AssistantToTheTransportManager);\n\n// CONCATENATED MODULE: ./src/core/connection/protocol/protocol.ts\nvar Protocol = {\n    decodeMessage: function (messageEvent) {\n        try {\n            var messageData = JSON.parse(messageEvent.data);\n            var pusherEventData = messageData.data;\n            if (typeof pusherEventData === 'string') {\n                try {\n                    pusherEventData = JSON.parse(messageData.data);\n                }\n                catch (e) { }\n            }\n            var pusherEvent = {\n                event: messageData.event,\n                channel: messageData.channel,\n                data: pusherEventData\n            };\n            if (messageData.user_id) {\n                pusherEvent.user_id = messageData.user_id;\n            }\n            return pusherEvent;\n        }\n        catch (e) {\n            throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n        }\n    },\n    encodeMessage: function (event) {\n        return JSON.stringify(event);\n    },\n    processHandshake: function (messageEvent) {\n        var message = Protocol.decodeMessage(messageEvent);\n        if (message.event === 'pusher:connection_established') {\n            if (!message.data.activity_timeout) {\n                throw 'No activity timeout specified in handshake';\n            }\n            return {\n                action: 'connected',\n                id: message.data.socket_id,\n                activityTimeout: message.data.activity_timeout * 1000\n            };\n        }\n        else if (message.event === 'pusher:error') {\n            return {\n                action: this.getCloseAction(message.data),\n                error: this.getCloseError(message.data)\n            };\n        }\n        else {\n            throw 'Invalid handshake';\n        }\n    },\n    getCloseAction: function (closeEvent) {\n        if (closeEvent.code < 4000) {\n            if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n                return 'backoff';\n            }\n            else {\n                return null;\n            }\n        }\n        else if (closeEvent.code === 4000) {\n            return 'tls_only';\n        }\n        else if (closeEvent.code < 4100) {\n            return 'refused';\n        }\n        else if (closeEvent.code < 4200) {\n            return 'backoff';\n        }\n        else if (closeEvent.code < 4300) {\n            return 'retry';\n        }\n        else {\n            return 'refused';\n        }\n    },\n    getCloseError: function (closeEvent) {\n        if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n            return {\n                type: 'PusherError',\n                data: {\n                    code: closeEvent.code,\n                    message: closeEvent.reason || closeEvent.message\n                }\n            };\n        }\n        else {\n            return null;\n        }\n    }\n};\n/* harmony default export */ var protocol_protocol = (Protocol);\n\n// CONCATENATED MODULE: ./src/core/connection/connection.ts\nvar connection_extends = ( false) || (function () {\n    var extendStatics = function (d, b) {\n        extendStatics = Object.setPrototypeOf ||\n            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n        return extendStatics(d, b);\n    };\n    return function (d, b) {\n        extendStatics(d, b);\n        function __() { this.constructor = d; }\n        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n    };\n})();\n\n\n\n\nvar connection_Connection = (function (_super) {\n    connection_extends(Connection, _super);\n    function Connection(id, transport) {\n        var _this = _super.call(this) || this;\n        _this.id = id;\n        _this.transport = transport;\n        _this.activityTimeout = transport.activityTimeout;\n        _this.bindListeners();\n        return _this;\n    }\n    Connection.prototype.handlesActivityChecks = function () {\n        return this.transport.handlesActivityChecks();\n    };\n    Connection.prototype.send = function (data) {\n        return this.transport.send(data);\n    };\n    Connection.prototype.send_event = function (name, data, channel) {\n        var event = { event: name, data: data };\n        if (channel) {\n            event.channel = channel;\n        }\n        logger.debug('Event sent', event);\n        return this.send(protocol_protocol.encodeMessage(event));\n    };\n    Connection.prototype.ping = function () {\n        if (this.transport.supportsPing()) {\n            this.transport.ping();\n        }\n        else {\n            this.send_event('pusher:ping', {});\n        }\n    };\n    Connection.prototype.close = function () {\n        this.transport.close();\n    };\n    Connection.prototype.bindListeners = function () {\n        var _this = this;\n        var listeners = {\n            message: function (messageEvent) {\n                var pusherEvent;\n                try {\n                    pusherEvent = protocol_protocol.decodeMessage(messageEvent);\n                }\n                catch (e) {\n                    _this.emit('error', {\n                        type: 'MessageParseError',\n                        error: e,\n                        data: messageEvent.data\n                    });\n                }\n                if (pusherEvent !== undefined) {\n                    logger.debug('Event recd', pusherEvent);\n                    switch (pusherEvent.event) {\n                        case 'pusher:error':\n                            _this.emit('error', {\n                                type: 'PusherError',\n                                data: pusherEvent.data\n                            });\n                            break;\n                        case 'pusher:ping':\n                            _this.emit('ping');\n                            break;\n                        case 'pusher:pong':\n                            _this.emit('pong');\n                            break;\n                    }\n                    _this.emit('message', pusherEvent);\n                }\n            },\n            activity: function () {\n                _this.emit('activity');\n            },\n            error: function (error) {\n                _this.emit('error', error);\n            },\n            closed: function (closeEvent) {\n                unbindListeners();\n                if (closeEvent && closeEvent.code) {\n                    _this.handleCloseEvent(closeEvent);\n                }\n                _this.transport = null;\n                _this.emit('closed');\n            }\n        };\n        var unbindListeners = function () {\n            objectApply(listeners, function (listener, event) {\n                _this.transport.unbind(event, listener);\n            });\n        };\n        objectApply(listeners, function (listener, event) {\n            _this.transport.bind(event, listener);\n        });\n    };\n    Connection.prototype.handleCloseEvent = function (closeEvent) {\n        var action = protocol_protocol.getCloseAction(closeEvent);\n        var error = protocol_protocol.getCloseError(closeEvent);\n        if (error) {\n            this.emit('error', error);\n        }\n        if (action) {\n            this.emit(action, { action: action, error: error });\n        }\n    };\n    return Connection;\n}(dispatcher));\n/* harmony default export */ var connection_connection = (connection_Connection);\n\n// CONCATENATED MODULE: ./src/core/connection/handshake/index.ts\n\n\n\nvar handshake_Handshake = (function () {\n    function Handshake(transport, callback) {\n        this.transport = transport;\n        this.callback = callback;\n        this.bindListeners();\n    }\n    Handshake.prototype.close = function () {\n        this.unbindListeners();\n        this.transport.close();\n    };\n    Handshake.prototype.bindListeners = function () {\n        var _this = this;\n        this.onMessage = function (m) {\n            _this.unbindListeners();\n            var result;\n            try {\n                result = protocol_protocol.processHandshake(m);\n            }\n            catch (e) {\n                _this.finish('error', { error: e });\n                _this.transport.close();\n                return;\n            }\n            if (result.action === 'connected') {\n                _this.finish('connected', {\n                    connection: new connection_connection(result.id, _this.transport),\n                    activityTimeout: result.activityTimeout\n                });\n            }\n            else {\n                _this.finish(result.action, { error: result.error });\n                _this.transport.close();\n            }\n        };\n        this.onClosed = function (closeEvent) {\n            _this.unbindListeners();\n            var action = protocol_protocol.getCloseAction(closeEvent) || 'backoff';\n            var error = protocol_protocol.getCloseError(closeEvent);\n            _this.finish(action, { error: error });\n        };\n        this.transport.bind('message', this.onMessage);\n        this.transport.bind('closed', this.onClosed);\n    };\n    Handshake.prototype.unbindListeners = function () {\n        this.transport.unbind('message', this.onMessage);\n        this.transport.unbind('closed', this.onClosed);\n    };\n    Handshake.prototype.finish = function (action, params) {\n        this.callback(extend({ transport: this.transport, action: action }, params));\n    };\n    return Handshake;\n}());\n/* harmony default export */ var connection_handshake = (handshake_Handshake);\n\n// CONCATENATED MODULE: ./src/core/timeline/timeline_sender.ts\n\nvar timeline_sender_TimelineSender = (function () {\n    function TimelineSender(timeline, options) {\n        this.timeline = timeline;\n        this.options = options || {};\n    }\n    TimelineSender.prototype.send = function (useTLS, callback) {\n        if (this.timeline.isEmpty()) {\n            return;\n        }\n        this.timeline.send(runtime.TimelineTransport.getAgent(this, useTLS), callback);\n    };\n    return TimelineSender;\n}());\n/* harmony default export */ var timeline_sender = (timeline_sender_TimelineSender);\n\n// CONCATENATED MODULE: ./src/core/channels/channel.ts\nvar channel_extends = ( false) || (function () {\n    var extendStatics = function (d, b) {\n        extendStatics = Object.setPrototypeOf ||\n            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n        return extendStatics(d, b);\n    };\n    return function (d, b) {\n        extendStatics(d, b);\n        function __() { this.constructor = d; }\n        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n    };\n})();\n\n\n\n\n\nvar channel_Channel = (function (_super) {\n    channel_extends(Channel, _super);\n    function Channel(name, pusher) {\n        var _this = _super.call(this, function (event, data) {\n            logger.debug('No callbacks on ' + name + ' for ' + event);\n        }) || this;\n        _this.name = name;\n        _this.pusher = pusher;\n        _this.subscribed = false;\n        _this.subscriptionPending = false;\n        _this.subscriptionCancelled = false;\n        return _this;\n    }\n    Channel.prototype.authorize = function (socketId, callback) {\n        return callback(null, { auth: '' });\n    };\n    Channel.prototype.trigger = function (event, data) {\n        if (event.indexOf('client-') !== 0) {\n            throw new BadEventName(\"Event '\" + event + \"' does not start with 'client-'\");\n        }\n        if (!this.subscribed) {\n            var suffix = url_store.buildLogSuffix('triggeringClientEvents');\n            logger.warn(\"Client event triggered before channel 'subscription_succeeded' event . \" + suffix);\n        }\n        return this.pusher.send_event(event, data, this.name);\n    };\n    Channel.prototype.disconnect = function () {\n        this.subscribed = false;\n        this.subscriptionPending = false;\n    };\n    Channel.prototype.handleEvent = function (event) {\n        var eventName = event.event;\n        var data = event.data;\n        if (eventName === 'pusher_internal:subscription_succeeded') {\n            this.handleSubscriptionSucceededEvent(event);\n        }\n        else if (eventName === 'pusher_internal:subscription_count') {\n            this.handleSubscriptionCountEvent(event);\n        }\n        else if (eventName.indexOf('pusher_internal:') !== 0) {\n            var metadata = {};\n            this.emit(eventName, data, metadata);\n        }\n    };\n    Channel.prototype.handleSubscriptionSucceededEvent = function (event) {\n        this.subscriptionPending = false;\n        this.subscribed = true;\n        if (this.subscriptionCancelled) {\n            this.pusher.unsubscribe(this.name);\n        }\n        else {\n            this.emit('pusher:subscription_succeeded', event.data);\n        }\n    };\n    Channel.prototype.handleSubscriptionCountEvent = function (event) {\n        if (event.data.subscription_count) {\n            this.subscriptionCount = event.data.subscription_count;\n        }\n        this.emit('pusher:subscription_count', event.data);\n    };\n    Channel.prototype.subscribe = function () {\n        var _this = this;\n        if (this.subscribed) {\n            return;\n        }\n        this.subscriptionPending = true;\n        this.subscriptionCancelled = false;\n        this.authorize(this.pusher.connection.socket_id, function (error, data) {\n            if (error) {\n                _this.subscriptionPending = false;\n                logger.error(error.toString());\n                _this.emit('pusher:subscription_error', Object.assign({}, {\n                    type: 'AuthError',\n                    error: error.message\n                }, error instanceof HTTPAuthError ? { status: error.status } : {}));\n            }\n            else {\n                _this.pusher.send_event('pusher:subscribe', {\n                    auth: data.auth,\n                    channel_data: data.channel_data,\n                    channel: _this.name\n                });\n            }\n        });\n    };\n    Channel.prototype.unsubscribe = function () {\n        this.subscribed = false;\n        this.pusher.send_event('pusher:unsubscribe', {\n            channel: this.name\n        });\n    };\n    Channel.prototype.cancelSubscription = function () {\n        this.subscriptionCancelled = true;\n    };\n    Channel.prototype.reinstateSubscription = function () {\n        this.subscriptionCancelled = false;\n    };\n    return Channel;\n}(dispatcher));\n/* harmony default export */ var channels_channel = (channel_Channel);\n\n// CONCATENATED MODULE: ./src/core/channels/private_channel.ts\nvar private_channel_extends = ( false) || (function () {\n    var extendStatics = function (d, b) {\n        extendStatics = Object.setPrototypeOf ||\n            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n        return extendStatics(d, b);\n    };\n    return function (d, b) {\n        extendStatics(d, b);\n        function __() { this.constructor = d; }\n        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n    };\n})();\n\nvar PrivateChannel = (function (_super) {\n    private_channel_extends(PrivateChannel, _super);\n    function PrivateChannel() {\n        return _super !== null && _super.apply(this, arguments) || this;\n    }\n    PrivateChannel.prototype.authorize = function (socketId, callback) {\n        return this.pusher.config.channelAuthorizer({\n            channelName: this.name,\n            socketId: socketId\n        }, callback);\n    };\n    return PrivateChannel;\n}(channels_channel));\n/* harmony default export */ var private_channel = (PrivateChannel);\n\n// CONCATENATED MODULE: ./src/core/channels/members.ts\n\nvar members_Members = (function () {\n    function Members() {\n        this.reset();\n    }\n    Members.prototype.get = function (id) {\n        if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n            return {\n                id: id,\n                info: this.members[id]\n            };\n        }\n        else {\n            return null;\n        }\n    };\n    Members.prototype.each = function (callback) {\n        var _this = this;\n        objectApply(this.members, function (member, id) {\n            callback(_this.get(id));\n        });\n    };\n    Members.prototype.setMyID = function (id) {\n        this.myID = id;\n    };\n    Members.prototype.onSubscription = function (subscriptionData) {\n        this.members = subscriptionData.presence.hash;\n        this.count = subscriptionData.presence.count;\n        this.me = this.get(this.myID);\n    };\n    Members.prototype.addMember = function (memberData) {\n        if (this.get(memberData.user_id) === null) {\n            this.count++;\n        }\n        this.members[memberData.user_id] = memberData.user_info;\n        return this.get(memberData.user_id);\n    };\n    Members.prototype.removeMember = function (memberData) {\n        var member = this.get(memberData.user_id);\n        if (member) {\n            delete this.members[memberData.user_id];\n            this.count--;\n        }\n        return member;\n    };\n    Members.prototype.reset = function () {\n        this.members = {};\n        this.count = 0;\n        this.myID = null;\n        this.me = null;\n    };\n    return Members;\n}());\n/* harmony default export */ var members = (members_Members);\n\n// CONCATENATED MODULE: ./src/core/channels/presence_channel.ts\nvar presence_channel_extends = ( false) || (function () {\n    var extendStatics = function (d, b) {\n        extendStatics = Object.setPrototypeOf ||\n            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n        return extendStatics(d, b);\n    };\n    return function (d, b) {\n        extendStatics(d, b);\n        function __() { this.constructor = d; }\n        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n    };\n})();\nvar __awaiter = ( false) || function (thisArg, _arguments, P, generator) {\n    return new (P || (P = Promise))(function (resolve, reject) {\n        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n        function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n        function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n        step((generator = generator.apply(thisArg, _arguments || [])).next());\n    });\n};\nvar __generator = ( false) || function (thisArg, body) {\n    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n    return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n    function verb(n) { return function (v) { return step([n, v]); }; }\n    function step(op) {\n        if (f) throw new TypeError(\"Generator is already executing.\");\n        while (_) try {\n            if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n            if (y = 0, t) op = [op[0] & 2, t.value];\n            switch (op[0]) {\n                case 0: case 1: t = op; break;\n                case 4: _.label++; return { value: op[1], done: false };\n                case 5: _.label++; y = op[1]; op = [0]; continue;\n                case 7: op = _.ops.pop(); _.trys.pop(); continue;\n                default:\n                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n                    if (t[2]) _.ops.pop();\n                    _.trys.pop(); continue;\n            }\n            op = body.call(thisArg, _);\n        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n    }\n};\n\n\n\n\nvar presence_channel_PresenceChannel = (function (_super) {\n    presence_channel_extends(PresenceChannel, _super);\n    function PresenceChannel(name, pusher) {\n        var _this = _super.call(this, name, pusher) || this;\n        _this.members = new members();\n        return _this;\n    }\n    PresenceChannel.prototype.authorize = function (socketId, callback) {\n        var _this = this;\n        _super.prototype.authorize.call(this, socketId, function (error, authData) { return __awaiter(_this, void 0, void 0, function () {\n            var channelData, suffix;\n            return __generator(this, function (_a) {\n                switch (_a.label) {\n                    case 0:\n                        if (!!error) return [3, 3];\n                        authData = authData;\n                        if (!(authData.channel_data != null)) return [3, 1];\n                        channelData = JSON.parse(authData.channel_data);\n                        this.members.setMyID(channelData.user_id);\n                        return [3, 3];\n                    case 1: return [4, this.pusher.user.signinDonePromise];\n                    case 2:\n                        _a.sent();\n                        if (this.pusher.user.user_data != null) {\n                            this.members.setMyID(this.pusher.user.user_data.id);\n                        }\n                        else {\n                            suffix = url_store.buildLogSuffix('authorizationEndpoint');\n                            logger.error(\"Invalid auth response for channel '\" + this.name + \"', \" +\n                                (\"expected 'channel_data' field. \" + suffix + \", \") +\n                                \"or the user should be signed in.\");\n                            callback('Invalid auth response');\n                            return [2];\n                        }\n                        _a.label = 3;\n                    case 3:\n                        callback(error, authData);\n                        return [2];\n                }\n            });\n        }); });\n    };\n    PresenceChannel.prototype.handleEvent = function (event) {\n        var eventName = event.event;\n        if (eventName.indexOf('pusher_internal:') === 0) {\n            this.handleInternalEvent(event);\n        }\n        else {\n            var data = event.data;\n            var metadata = {};\n            if (event.user_id) {\n                metadata.user_id = event.user_id;\n            }\n            this.emit(eventName, data, metadata);\n        }\n    };\n    PresenceChannel.prototype.handleInternalEvent = function (event) {\n        var eventName = event.event;\n        var data = event.data;\n        switch (eventName) {\n            case 'pusher_internal:subscription_succeeded':\n                this.handleSubscriptionSucceededEvent(event);\n                break;\n            case 'pusher_internal:subscription_count':\n                this.handleSubscriptionCountEvent(event);\n                break;\n            case 'pusher_internal:member_added':\n                var addedMember = this.members.addMember(data);\n                this.emit('pusher:member_added', addedMember);\n                break;\n            case 'pusher_internal:member_removed':\n                var removedMember = this.members.removeMember(data);\n                if (removedMember) {\n                    this.emit('pusher:member_removed', removedMember);\n                }\n                break;\n        }\n    };\n    PresenceChannel.prototype.handleSubscriptionSucceededEvent = function (event) {\n        this.subscriptionPending = false;\n        this.subscribed = true;\n        if (this.subscriptionCancelled) {\n            this.pusher.unsubscribe(this.name);\n        }\n        else {\n            this.members.onSubscription(event.data);\n            this.emit('pusher:subscription_succeeded', this.members);\n        }\n    };\n    PresenceChannel.prototype.disconnect = function () {\n        this.members.reset();\n        _super.prototype.disconnect.call(this);\n    };\n    return PresenceChannel;\n}(private_channel));\n/* harmony default export */ var presence_channel = (presence_channel_PresenceChannel);\n\n// EXTERNAL MODULE: ./node_modules/@stablelib/utf8/lib/utf8.js\nvar utf8 = __nested_webpack_require_20105__(1);\n\n// EXTERNAL MODULE: ./node_modules/@stablelib/base64/lib/base64.js\nvar base64 = __nested_webpack_require_20105__(0);\n\n// CONCATENATED MODULE: ./src/core/channels/encrypted_channel.ts\nvar encrypted_channel_extends = ( false) || (function () {\n    var extendStatics = function (d, b) {\n        extendStatics = Object.setPrototypeOf ||\n            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n        return extendStatics(d, b);\n    };\n    return function (d, b) {\n        extendStatics(d, b);\n        function __() { this.constructor = d; }\n        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n    };\n})();\n\n\n\n\n\nvar encrypted_channel_EncryptedChannel = (function (_super) {\n    encrypted_channel_extends(EncryptedChannel, _super);\n    function EncryptedChannel(name, pusher, nacl) {\n        var _this = _super.call(this, name, pusher) || this;\n        _this.key = null;\n        _this.nacl = nacl;\n        return _this;\n    }\n    EncryptedChannel.prototype.authorize = function (socketId, callback) {\n        var _this = this;\n        _super.prototype.authorize.call(this, socketId, function (error, authData) {\n            if (error) {\n                callback(error, authData);\n                return;\n            }\n            var sharedSecret = authData['shared_secret'];\n            if (!sharedSecret) {\n                callback(new Error(\"No shared_secret key in auth payload for encrypted channel: \" + _this.name), null);\n                return;\n            }\n            _this.key = Object(base64[\"decode\"])(sharedSecret);\n            delete authData['shared_secret'];\n            callback(null, authData);\n        });\n    };\n    EncryptedChannel.prototype.trigger = function (event, data) {\n        throw new UnsupportedFeature('Client events are not currently supported for encrypted channels');\n    };\n    EncryptedChannel.prototype.handleEvent = function (event) {\n        var eventName = event.event;\n        var data = event.data;\n        if (eventName.indexOf('pusher_internal:') === 0 ||\n            eventName.indexOf('pusher:') === 0) {\n            _super.prototype.handleEvent.call(this, event);\n            return;\n        }\n        this.handleEncryptedEvent(eventName, data);\n    };\n    EncryptedChannel.prototype.handleEncryptedEvent = function (event, data) {\n        var _this = this;\n        if (!this.key) {\n            logger.debug('Received encrypted event before key has been retrieved from the authEndpoint');\n            return;\n        }\n        if (!data.ciphertext || !data.nonce) {\n            logger.error('Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n                data);\n            return;\n        }\n        var cipherText = Object(base64[\"decode\"])(data.ciphertext);\n        if (cipherText.length < this.nacl.secretbox.overheadLength) {\n            logger.error(\"Expected encrypted event ciphertext length to be \" + this.nacl.secretbox.overheadLength + \", got: \" + cipherText.length);\n            return;\n        }\n        var nonce = Object(base64[\"decode\"])(data.nonce);\n        if (nonce.length < this.nacl.secretbox.nonceLength) {\n            logger.error(\"Expected encrypted event nonce length to be \" + this.nacl.secretbox.nonceLength + \", got: \" + nonce.length);\n            return;\n        }\n        var bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n        if (bytes === null) {\n            logger.debug('Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...');\n            this.authorize(this.pusher.connection.socket_id, function (error, authData) {\n                if (error) {\n                    logger.error(\"Failed to make a request to the authEndpoint: \" + authData + \". Unable to fetch new key, so dropping encrypted event\");\n                    return;\n                }\n                bytes = _this.nacl.secretbox.open(cipherText, nonce, _this.key);\n                if (bytes === null) {\n                    logger.error(\"Failed to decrypt event with new key. Dropping encrypted event\");\n                    return;\n                }\n                _this.emit(event, _this.getDataToEmit(bytes));\n                return;\n            });\n            return;\n        }\n        this.emit(event, this.getDataToEmit(bytes));\n    };\n    EncryptedChannel.prototype.getDataToEmit = function (bytes) {\n        var raw = Object(utf8[\"decode\"])(bytes);\n        try {\n            return JSON.parse(raw);\n        }\n        catch (_a) {\n            return raw;\n        }\n    };\n    return EncryptedChannel;\n}(private_channel));\n/* harmony default export */ var encrypted_channel = (encrypted_channel_EncryptedChannel);\n\n// CONCATENATED MODULE: ./src/core/connection/connection_manager.ts\nvar connection_manager_extends = ( false) || (function () {\n    var extendStatics = function (d, b) {\n        extendStatics = Object.setPrototypeOf ||\n            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n        return extendStatics(d, b);\n    };\n    return function (d, b) {\n        extendStatics(d, b);\n        function __() { this.constructor = d; }\n        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n    };\n})();\n\n\n\n\n\nvar connection_manager_ConnectionManager = (function (_super) {\n    connection_manager_extends(ConnectionManager, _super);\n    function ConnectionManager(key, options) {\n        var _this = _super.call(this) || this;\n        _this.state = 'initialized';\n        _this.connection = null;\n        _this.key = key;\n        _this.options = options;\n        _this.timeline = _this.options.timeline;\n        _this.usingTLS = _this.options.useTLS;\n        _this.errorCallbacks = _this.buildErrorCallbacks();\n        _this.connectionCallbacks = _this.buildConnectionCallbacks(_this.errorCallbacks);\n        _this.handshakeCallbacks = _this.buildHandshakeCallbacks(_this.errorCallbacks);\n        var Network = runtime.getNetwork();\n        Network.bind('online', function () {\n            _this.timeline.info({ netinfo: 'online' });\n            if (_this.state === 'connecting' || _this.state === 'unavailable') {\n                _this.retryIn(0);\n            }\n        });\n        Network.bind('offline', function () {\n            _this.timeline.info({ netinfo: 'offline' });\n            if (_this.connection) {\n                _this.sendActivityCheck();\n            }\n        });\n        _this.updateStrategy();\n        return _this;\n    }\n    ConnectionManager.prototype.connect = function () {\n        if (this.connection || this.runner) {\n            return;\n        }\n        if (!this.strategy.isSupported()) {\n            this.updateState('failed');\n            return;\n        }\n        this.updateState('connecting');\n        this.startConnecting();\n        this.setUnavailableTimer();\n    };\n    ConnectionManager.prototype.send = function (data) {\n        if (this.connection) {\n            return this.connection.send(data);\n        }\n        else {\n            return false;\n        }\n    };\n    ConnectionManager.prototype.send_event = function (name, data, channel) {\n        if (this.connection) {\n            return this.connection.send_event(name, data, channel);\n        }\n        else {\n            return false;\n        }\n    };\n    ConnectionManager.prototype.disconnect = function () {\n        this.disconnectInternally();\n        this.updateState('disconnected');\n    };\n    ConnectionManager.prototype.isUsingTLS = function () {\n        return this.usingTLS;\n    };\n    ConnectionManager.prototype.startConnecting = function () {\n        var _this = this;\n        var callback = function (error, handshake) {\n            if (error) {\n                _this.runner = _this.strategy.connect(0, callback);\n            }\n            else {\n                if (handshake.action === 'error') {\n                    _this.emit('error', {\n                        type: 'HandshakeError',\n                        error: handshake.error\n                    });\n                    _this.timeline.error({ handshakeError: handshake.error });\n                }\n                else {\n                    _this.abortConnecting();\n                    _this.handshakeCallbacks[handshake.action](handshake);\n                }\n            }\n        };\n        this.runner = this.strategy.connect(0, callback);\n    };\n    ConnectionManager.prototype.abortConnecting = function () {\n        if (this.runner) {\n            this.runner.abort();\n            this.runner = null;\n        }\n    };\n    ConnectionManager.prototype.disconnectInternally = function () {\n        this.abortConnecting();\n        this.clearRetryTimer();\n        this.clearUnavailableTimer();\n        if (this.connection) {\n            var connection = this.abandonConnection();\n            connection.close();\n        }\n    };\n    ConnectionManager.prototype.updateStrategy = function () {\n        this.strategy = this.options.getStrategy({\n            key: this.key,\n            timeline: this.timeline,\n            useTLS: this.usingTLS\n        });\n    };\n    ConnectionManager.prototype.retryIn = function (delay) {\n        var _this = this;\n        this.timeline.info({ action: 'retry', delay: delay });\n        if (delay > 0) {\n            this.emit('connecting_in', Math.round(delay / 1000));\n        }\n        this.retryTimer = new OneOffTimer(delay || 0, function () {\n            _this.disconnectInternally();\n            _this.connect();\n        });\n    };\n    ConnectionManager.prototype.clearRetryTimer = function () {\n        if (this.retryTimer) {\n            this.retryTimer.ensureAborted();\n            this.retryTimer = null;\n        }\n    };\n    ConnectionManager.prototype.setUnavailableTimer = function () {\n        var _this = this;\n        this.unavailableTimer = new OneOffTimer(this.options.unavailableTimeout, function () {\n            _this.updateState('unavailable');\n        });\n    };\n    ConnectionManager.prototype.clearUnavailableTimer = function () {\n        if (this.unavailableTimer) {\n            this.unavailableTimer.ensureAborted();\n        }\n    };\n    ConnectionManager.prototype.sendActivityCheck = function () {\n        var _this = this;\n        this.stopActivityCheck();\n        this.connection.ping();\n        this.activityTimer = new OneOffTimer(this.options.pongTimeout, function () {\n            _this.timeline.error({ pong_timed_out: _this.options.pongTimeout });\n            _this.retryIn(0);\n        });\n    };\n    ConnectionManager.prototype.resetActivityCheck = function () {\n        var _this = this;\n        this.stopActivityCheck();\n        if (this.connection && !this.connection.handlesActivityChecks()) {\n            this.activityTimer = new OneOffTimer(this.activityTimeout, function () {\n                _this.sendActivityCheck();\n            });\n        }\n    };\n    ConnectionManager.prototype.stopActivityCheck = function () {\n        if (this.activityTimer) {\n            this.activityTimer.ensureAborted();\n        }\n    };\n    ConnectionManager.prototype.buildConnectionCallbacks = function (errorCallbacks) {\n        var _this = this;\n        return extend({}, errorCallbacks, {\n            message: function (message) {\n                _this.resetActivityCheck();\n                _this.emit('message', message);\n            },\n            ping: function () {\n                _this.send_event('pusher:pong', {});\n            },\n            activity: function () {\n                _this.resetActivityCheck();\n            },\n            error: function (error) {\n                _this.emit('error', error);\n            },\n            closed: function () {\n                _this.abandonConnection();\n                if (_this.shouldRetry()) {\n                    _this.retryIn(1000);\n                }\n            }\n        });\n    };\n    ConnectionManager.prototype.buildHandshakeCallbacks = function (errorCallbacks) {\n        var _this = this;\n        return extend({}, errorCallbacks, {\n            connected: function (handshake) {\n                _this.activityTimeout = Math.min(_this.options.activityTimeout, handshake.activityTimeout, handshake.connection.activityTimeout || Infinity);\n                _this.clearUnavailableTimer();\n                _this.setConnection(handshake.connection);\n                _this.socket_id = _this.connection.id;\n                _this.updateState('connected', { socket_id: _this.socket_id });\n            }\n        });\n    };\n    ConnectionManager.prototype.buildErrorCallbacks = function () {\n        var _this = this;\n        var withErrorEmitted = function (callback) {\n            return function (result) {\n                if (result.error) {\n                    _this.emit('error', { type: 'WebSocketError', error: result.error });\n                }\n                callback(result);\n            };\n        };\n        return {\n            tls_only: withErrorEmitted(function () {\n                _this.usingTLS = true;\n                _this.updateStrategy();\n                _this.retryIn(0);\n            }),\n            refused: withErrorEmitted(function () {\n                _this.disconnect();\n            }),\n            backoff: withErrorEmitted(function () {\n                _this.retryIn(1000);\n            }),\n            retry: withErrorEmitted(function () {\n                _this.retryIn(0);\n            })\n        };\n    };\n    ConnectionManager.prototype.setConnection = function (connection) {\n        this.connection = connection;\n        for (var event in this.connectionCallbacks) {\n            this.connection.bind(event, this.connectionCallbacks[event]);\n        }\n        this.resetActivityCheck();\n    };\n    ConnectionManager.prototype.abandonConnection = function () {\n        if (!this.connection) {\n            return;\n        }\n        this.stopActivityCheck();\n        for (var event in this.connectionCallbacks) {\n            this.connection.unbind(event, this.connectionCallbacks[event]);\n        }\n        var connection = this.connection;\n        this.connection = null;\n        return connection;\n    };\n    ConnectionManager.prototype.updateState = function (newState, data) {\n        var previousState = this.state;\n        this.state = newState;\n        if (previousState !== newState) {\n            var newStateDescription = newState;\n            if (newStateDescription === 'connected') {\n                newStateDescription += ' with new socket ID ' + data.socket_id;\n            }\n            logger.debug('State changed', previousState + ' -> ' + newStateDescription);\n            this.timeline.info({ state: newState, params: data });\n            this.emit('state_change', { previous: previousState, current: newState });\n            this.emit(newState, data);\n        }\n    };\n    ConnectionManager.prototype.shouldRetry = function () {\n        return this.state === 'connecting' || this.state === 'connected';\n    };\n    return ConnectionManager;\n}(dispatcher));\n/* harmony default export */ var connection_manager = (connection_manager_ConnectionManager);\n\n// CONCATENATED MODULE: ./src/core/channels/channels.ts\n\n\n\n\nvar channels_Channels = (function () {\n    function Channels() {\n        this.channels = {};\n    }\n    Channels.prototype.add = function (name, pusher) {\n        if (!this.channels[name]) {\n            this.channels[name] = createChannel(name, pusher);\n        }\n        return this.channels[name];\n    };\n    Channels.prototype.all = function () {\n        return values(this.channels);\n    };\n    Channels.prototype.find = function (name) {\n        return this.channels[name];\n    };\n    Channels.prototype.remove = function (name) {\n        var channel = this.channels[name];\n        delete this.channels[name];\n        return channel;\n    };\n    Channels.prototype.disconnect = function () {\n        objectApply(this.channels, function (channel) {\n            channel.disconnect();\n        });\n    };\n    return Channels;\n}());\n/* harmony default export */ var channels = (channels_Channels);\nfunction createChannel(name, pusher) {\n    if (name.indexOf('private-encrypted-') === 0) {\n        if (pusher.config.nacl) {\n            return factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n        }\n        var errMsg = 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n        var suffix = url_store.buildLogSuffix('encryptedChannelSupport');\n        throw new UnsupportedFeature(errMsg + \". \" + suffix);\n    }\n    else if (name.indexOf('private-') === 0) {\n        return factory.createPrivateChannel(name, pusher);\n    }\n    else if (name.indexOf('presence-') === 0) {\n        return factory.createPresenceChannel(name, pusher);\n    }\n    else if (name.indexOf('#') === 0) {\n        throw new BadChannelName('Cannot create a channel with name \"' + name + '\".');\n    }\n    else {\n        return factory.createChannel(name, pusher);\n    }\n}\n\n// CONCATENATED MODULE: ./src/core/utils/factory.ts\n\n\n\n\n\n\n\n\n\nvar Factory = {\n    createChannels: function () {\n        return new channels();\n    },\n    createConnectionManager: function (key, options) {\n        return new connection_manager(key, options);\n    },\n    createChannel: function (name, pusher) {\n        return new channels_channel(name, pusher);\n    },\n    createPrivateChannel: function (name, pusher) {\n        return new private_channel(name, pusher);\n    },\n    createPresenceChannel: function (name, pusher) {\n        return new presence_channel(name, pusher);\n    },\n    createEncryptedChannel: function (name, pusher, nacl) {\n        return new encrypted_channel(name, pusher, nacl);\n    },\n    createTimelineSender: function (timeline, options) {\n        return new timeline_sender(timeline, options);\n    },\n    createHandshake: function (transport, callback) {\n        return new connection_handshake(transport, callback);\n    },\n    createAssistantToTheTransportManager: function (manager, transport, options) {\n        return new assistant_to_the_transport_manager(manager, transport, options);\n    }\n};\n/* harmony default export */ var factory = (Factory);\n\n// CONCATENATED MODULE: ./src/core/transports/transport_manager.ts\n\nvar transport_manager_TransportManager = (function () {\n    function TransportManager(options) {\n        this.options = options || {};\n        this.livesLeft = this.options.lives || Infinity;\n    }\n    TransportManager.prototype.getAssistant = function (transport) {\n        return factory.createAssistantToTheTransportManager(this, transport, {\n            minPingDelay: this.options.minPingDelay,\n            maxPingDelay: this.options.maxPingDelay\n        });\n    };\n    TransportManager.prototype.isAlive = function () {\n        return this.livesLeft > 0;\n    };\n    TransportManager.prototype.reportDeath = function () {\n        this.livesLeft -= 1;\n    };\n    return TransportManager;\n}());\n/* harmony default export */ var transport_manager = (transport_manager_TransportManager);\n\n// CONCATENATED MODULE: ./src/core/strategies/sequential_strategy.ts\n\n\n\nvar sequential_strategy_SequentialStrategy = (function () {\n    function SequentialStrategy(strategies, options) {\n        this.strategies = strategies;\n        this.loop = Boolean(options.loop);\n        this.failFast = Boolean(options.failFast);\n        this.timeout = options.timeout;\n        this.timeoutLimit = options.timeoutLimit;\n    }\n    SequentialStrategy.prototype.isSupported = function () {\n        return any(this.strategies, util.method('isSupported'));\n    };\n    SequentialStrategy.prototype.connect = function (minPriority, callback) {\n        var _this = this;\n        var strategies = this.strategies;\n        var current = 0;\n        var timeout = this.timeout;\n        var runner = null;\n        var tryNextStrategy = function (error, handshake) {\n            if (handshake) {\n                callback(null, handshake);\n            }\n            else {\n                current = current + 1;\n                if (_this.loop) {\n                    current = current % strategies.length;\n                }\n                if (current < strategies.length) {\n                    if (timeout) {\n                        timeout = timeout * 2;\n                        if (_this.timeoutLimit) {\n                            timeout = Math.min(timeout, _this.timeoutLimit);\n                        }\n                    }\n                    runner = _this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: _this.failFast }, tryNextStrategy);\n                }\n                else {\n                    callback(true);\n                }\n            }\n        };\n        runner = this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: this.failFast }, tryNextStrategy);\n        return {\n            abort: function () {\n                runner.abort();\n            },\n            forceMinPriority: function (p) {\n                minPriority = p;\n                if (runner) {\n                    runner.forceMinPriority(p);\n                }\n            }\n        };\n    };\n    SequentialStrategy.prototype.tryStrategy = function (strategy, minPriority, options, callback) {\n        var timer = null;\n        var runner = null;\n        if (options.timeout > 0) {\n            timer = new OneOffTimer(options.timeout, function () {\n                runner.abort();\n                callback(true);\n            });\n        }\n        runner = strategy.connect(minPriority, function (error, handshake) {\n            if (error && timer && timer.isRunning() && !options.failFast) {\n                return;\n            }\n            if (timer) {\n                timer.ensureAborted();\n            }\n            callback(error, handshake);\n        });\n        return {\n            abort: function () {\n                if (timer) {\n                    timer.ensureAborted();\n                }\n                runner.abort();\n            },\n            forceMinPriority: function (p) {\n                runner.forceMinPriority(p);\n            }\n        };\n    };\n    return SequentialStrategy;\n}());\n/* harmony default export */ var sequential_strategy = (sequential_strategy_SequentialStrategy);\n\n// CONCATENATED MODULE: ./src/core/strategies/best_connected_ever_strategy.ts\n\n\nvar best_connected_ever_strategy_BestConnectedEverStrategy = (function () {\n    function BestConnectedEverStrategy(strategies) {\n        this.strategies = strategies;\n    }\n    BestConnectedEverStrategy.prototype.isSupported = function () {\n        return any(this.strategies, util.method('isSupported'));\n    };\n    BestConnectedEverStrategy.prototype.connect = function (minPriority, callback) {\n        return connect(this.strategies, minPriority, function (i, runners) {\n            return function (error, handshake) {\n                runners[i].error = error;\n                if (error) {\n                    if (allRunnersFailed(runners)) {\n                        callback(true);\n                    }\n                    return;\n                }\n                apply(runners, function (runner) {\n                    runner.forceMinPriority(handshake.transport.priority);\n                });\n                callback(null, handshake);\n            };\n        });\n    };\n    return BestConnectedEverStrategy;\n}());\n/* harmony default export */ var best_connected_ever_strategy = (best_connected_ever_strategy_BestConnectedEverStrategy);\nfunction connect(strategies, minPriority, callbackBuilder) {\n    var runners = map(strategies, function (strategy, i, _, rs) {\n        return strategy.connect(minPriority, callbackBuilder(i, rs));\n    });\n    return {\n        abort: function () {\n            apply(runners, abortRunner);\n        },\n        forceMinPriority: function (p) {\n            apply(runners, function (runner) {\n                runner.forceMinPriority(p);\n            });\n        }\n    };\n}\nfunction allRunnersFailed(runners) {\n    return collections_all(runners, function (runner) {\n        return Boolean(runner.error);\n    });\n}\nfunction abortRunner(runner) {\n    if (!runner.error && !runner.aborted) {\n        runner.abort();\n        runner.aborted = true;\n    }\n}\n\n// CONCATENATED MODULE: ./src/core/strategies/cached_strategy.ts\n\n\n\n\nvar cached_strategy_CachedStrategy = (function () {\n    function CachedStrategy(strategy, transports, options) {\n        this.strategy = strategy;\n        this.transports = transports;\n        this.ttl = options.ttl || 1800 * 1000;\n        this.usingTLS = options.useTLS;\n        this.timeline = options.timeline;\n    }\n    CachedStrategy.prototype.isSupported = function () {\n        return this.strategy.isSupported();\n    };\n    CachedStrategy.prototype.connect = function (minPriority, callback) {\n        var usingTLS = this.usingTLS;\n        var info = fetchTransportCache(usingTLS);\n        var strategies = [this.strategy];\n        if (info && info.timestamp + this.ttl >= util.now()) {\n            var transport = this.transports[info.transport];\n            if (transport) {\n                this.timeline.info({\n                    cached: true,\n                    transport: info.transport,\n                    latency: info.latency\n                });\n                strategies.push(new sequential_strategy([transport], {\n                    timeout: info.latency * 2 + 1000,\n                    failFast: true\n                }));\n            }\n        }\n        var startTimestamp = util.now();\n        var runner = strategies\n            .pop()\n            .connect(minPriority, function cb(error, handshake) {\n            if (error) {\n                flushTransportCache(usingTLS);\n                if (strategies.length > 0) {\n                    startTimestamp = util.now();\n                    runner = strategies.pop().connect(minPriority, cb);\n                }\n                else {\n                    callback(error);\n                }\n            }\n            else {\n                storeTransportCache(usingTLS, handshake.transport.name, util.now() - startTimestamp);\n                callback(null, handshake);\n            }\n        });\n        return {\n            abort: function () {\n                runner.abort();\n            },\n            forceMinPriority: function (p) {\n                minPriority = p;\n                if (runner) {\n                    runner.forceMinPriority(p);\n                }\n            }\n        };\n    };\n    return CachedStrategy;\n}());\n/* harmony default export */ var cached_strategy = (cached_strategy_CachedStrategy);\nfunction getTransportCacheKey(usingTLS) {\n    return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\nfunction fetchTransportCache(usingTLS) {\n    var storage = runtime.getLocalStorage();\n    if (storage) {\n        try {\n            var serializedCache = storage[getTransportCacheKey(usingTLS)];\n            if (serializedCache) {\n                return JSON.parse(serializedCache);\n            }\n        }\n        catch (e) {\n            flushTransportCache(usingTLS);\n        }\n    }\n    return null;\n}\nfunction storeTransportCache(usingTLS, transport, latency) {\n    var storage = runtime.getLocalStorage();\n    if (storage) {\n        try {\n            storage[getTransportCacheKey(usingTLS)] = safeJSONStringify({\n                timestamp: util.now(),\n                transport: transport,\n                latency: latency\n            });\n        }\n        catch (e) {\n        }\n    }\n}\nfunction flushTransportCache(usingTLS) {\n    var storage = runtime.getLocalStorage();\n    if (storage) {\n        try {\n            delete storage[getTransportCacheKey(usingTLS)];\n        }\n        catch (e) {\n        }\n    }\n}\n\n// CONCATENATED MODULE: ./src/core/strategies/delayed_strategy.ts\n\nvar delayed_strategy_DelayedStrategy = (function () {\n    function DelayedStrategy(strategy, _a) {\n        var number = _a.delay;\n        this.strategy = strategy;\n        this.options = { delay: number };\n    }\n    DelayedStrategy.prototype.isSupported = function () {\n        return this.strategy.isSupported();\n    };\n    DelayedStrategy.prototype.connect = function (minPriority, callback) {\n        var strategy = this.strategy;\n        var runner;\n        var timer = new OneOffTimer(this.options.delay, function () {\n            runner = strategy.connect(minPriority, callback);\n        });\n        return {\n            abort: function () {\n                timer.ensureAborted();\n                if (runner) {\n                    runner.abort();\n                }\n            },\n            forceMinPriority: function (p) {\n                minPriority = p;\n                if (runner) {\n                    runner.forceMinPriority(p);\n                }\n            }\n        };\n    };\n    return DelayedStrategy;\n}());\n/* harmony default export */ var delayed_strategy = (delayed_strategy_DelayedStrategy);\n\n// CONCATENATED MODULE: ./src/core/strategies/if_strategy.ts\nvar IfStrategy = (function () {\n    function IfStrategy(test, trueBranch, falseBranch) {\n        this.test = test;\n        this.trueBranch = trueBranch;\n        this.falseBranch = falseBranch;\n    }\n    IfStrategy.prototype.isSupported = function () {\n        var branch = this.test() ? this.trueBranch : this.falseBranch;\n        return branch.isSupported();\n    };\n    IfStrategy.prototype.connect = function (minPriority, callback) {\n        var branch = this.test() ? this.trueBranch : this.falseBranch;\n        return branch.connect(minPriority, callback);\n    };\n    return IfStrategy;\n}());\n/* harmony default export */ var if_strategy = (IfStrategy);\n\n// CONCATENATED MODULE: ./src/core/strategies/first_connected_strategy.ts\nvar FirstConnectedStrategy = (function () {\n    function FirstConnectedStrategy(strategy) {\n        this.strategy = strategy;\n    }\n    FirstConnectedStrategy.prototype.isSupported = function () {\n        return this.strategy.isSupported();\n    };\n    FirstConnectedStrategy.prototype.connect = function (minPriority, callback) {\n        var runner = this.strategy.connect(minPriority, function (error, handshake) {\n            if (handshake) {\n                runner.abort();\n            }\n            callback(error, handshake);\n        });\n        return runner;\n    };\n    return FirstConnectedStrategy;\n}());\n/* harmony default export */ var first_connected_strategy = (FirstConnectedStrategy);\n\n// CONCATENATED MODULE: ./src/runtimes/web/default_strategy.ts\n\n\n\n\n\n\n\nfunction testSupportsStrategy(strategy) {\n    return function () {\n        return strategy.isSupported();\n    };\n}\nvar getDefaultStrategy = function (config, baseOptions, defineTransport) {\n    var definedTransports = {};\n    function defineTransportStrategy(name, type, priority, options, manager) {\n        var transport = defineTransport(config, name, type, priority, options, manager);\n        definedTransports[name] = transport;\n        return transport;\n    }\n    var ws_options = Object.assign({}, baseOptions, {\n        hostNonTLS: config.wsHost + ':' + config.wsPort,\n        hostTLS: config.wsHost + ':' + config.wssPort,\n        httpPath: config.wsPath\n    });\n    var wss_options = Object.assign({}, ws_options, {\n        useTLS: true\n    });\n    var sockjs_options = Object.assign({}, baseOptions, {\n        hostNonTLS: config.httpHost + ':' + config.httpPort,\n        hostTLS: config.httpHost + ':' + config.httpsPort,\n        httpPath: config.httpPath\n    });\n    var timeouts = {\n        loop: true,\n        timeout: 15000,\n        timeoutLimit: 60000\n    };\n    var ws_manager = new transport_manager({\n        lives: 2,\n        minPingDelay: 10000,\n        maxPingDelay: config.activityTimeout\n    });\n    var streaming_manager = new transport_manager({\n        lives: 2,\n        minPingDelay: 10000,\n        maxPingDelay: config.activityTimeout\n    });\n    var ws_transport = defineTransportStrategy('ws', 'ws', 3, ws_options, ws_manager);\n    var wss_transport = defineTransportStrategy('wss', 'ws', 3, wss_options, ws_manager);\n    var sockjs_transport = defineTransportStrategy('sockjs', 'sockjs', 1, sockjs_options);\n    var xhr_streaming_transport = defineTransportStrategy('xhr_streaming', 'xhr_streaming', 1, sockjs_options, streaming_manager);\n    var xdr_streaming_transport = defineTransportStrategy('xdr_streaming', 'xdr_streaming', 1, sockjs_options, streaming_manager);\n    var xhr_polling_transport = defineTransportStrategy('xhr_polling', 'xhr_polling', 1, sockjs_options);\n    var xdr_polling_transport = defineTransportStrategy('xdr_polling', 'xdr_polling', 1, sockjs_options);\n    var ws_loop = new sequential_strategy([ws_transport], timeouts);\n    var wss_loop = new sequential_strategy([wss_transport], timeouts);\n    var sockjs_loop = new sequential_strategy([sockjs_transport], timeouts);\n    var streaming_loop = new sequential_strategy([\n        new if_strategy(testSupportsStrategy(xhr_streaming_transport), xhr_streaming_transport, xdr_streaming_transport)\n    ], timeouts);\n    var polling_loop = new sequential_strategy([\n        new if_strategy(testSupportsStrategy(xhr_polling_transport), xhr_polling_transport, xdr_polling_transport)\n    ], timeouts);\n    var http_loop = new sequential_strategy([\n        new if_strategy(testSupportsStrategy(streaming_loop), new best_connected_ever_strategy([\n            streaming_loop,\n            new delayed_strategy(polling_loop, { delay: 4000 })\n        ]), polling_loop)\n    ], timeouts);\n    var http_fallback_loop = new if_strategy(testSupportsStrategy(http_loop), http_loop, sockjs_loop);\n    var wsStrategy;\n    if (baseOptions.useTLS) {\n        wsStrategy = new best_connected_ever_strategy([\n            ws_loop,\n            new delayed_strategy(http_fallback_loop, { delay: 2000 })\n        ]);\n    }\n    else {\n        wsStrategy = new best_connected_ever_strategy([\n            ws_loop,\n            new delayed_strategy(wss_loop, { delay: 2000 }),\n            new delayed_strategy(http_fallback_loop, { delay: 5000 })\n        ]);\n    }\n    return new cached_strategy(new first_connected_strategy(new if_strategy(testSupportsStrategy(ws_transport), wsStrategy, http_fallback_loop)), definedTransports, {\n        ttl: 1800000,\n        timeline: baseOptions.timeline,\n        useTLS: baseOptions.useTLS\n    });\n};\n/* harmony default export */ var default_strategy = (getDefaultStrategy);\n\n// CONCATENATED MODULE: ./src/runtimes/web/transports/transport_connection_initializer.ts\n\n/* harmony default export */ var transport_connection_initializer = (function () {\n    var self = this;\n    self.timeline.info(self.buildTimelineMessage({\n        transport: self.name + (self.options.useTLS ? 's' : '')\n    }));\n    if (self.hooks.isInitialized()) {\n        self.changeState('initialized');\n    }\n    else if (self.hooks.file) {\n        self.changeState('initializing');\n        Dependencies.load(self.hooks.file, { useTLS: self.options.useTLS }, function (error, callback) {\n            if (self.hooks.isInitialized()) {\n                self.changeState('initialized');\n                callback(true);\n            }\n            else {\n                if (error) {\n                    self.onError(error);\n                }\n                self.onClose();\n                callback(false);\n            }\n        });\n    }\n    else {\n        self.onClose();\n    }\n});\n\n// CONCATENATED MODULE: ./src/runtimes/web/http/http_xdomain_request.ts\n\nvar http_xdomain_request_hooks = {\n    getRequest: function (socket) {\n        var xdr = new window.XDomainRequest();\n        xdr.ontimeout = function () {\n            socket.emit('error', new RequestTimedOut());\n            socket.close();\n        };\n        xdr.onerror = function (e) {\n            socket.emit('error', e);\n            socket.close();\n        };\n        xdr.onprogress = function () {\n            if (xdr.responseText && xdr.responseText.length > 0) {\n                socket.onChunk(200, xdr.responseText);\n            }\n        };\n        xdr.onload = function () {\n            if (xdr.responseText && xdr.responseText.length > 0) {\n                socket.onChunk(200, xdr.responseText);\n            }\n            socket.emit('finished', 200);\n            socket.close();\n        };\n        return xdr;\n    },\n    abortRequest: function (xdr) {\n        xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;\n        xdr.abort();\n    }\n};\n/* harmony default export */ var http_xdomain_request = (http_xdomain_request_hooks);\n\n// CONCATENATED MODULE: ./src/core/http/http_request.ts\nvar http_request_extends = ( false) || (function () {\n    var extendStatics = function (d, b) {\n        extendStatics = Object.setPrototypeOf ||\n            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n        return extendStatics(d, b);\n    };\n    return function (d, b) {\n        extendStatics(d, b);\n        function __() { this.constructor = d; }\n        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n    };\n})();\n\n\nvar MAX_BUFFER_LENGTH = 256 * 1024;\nvar http_request_HTTPRequest = (function (_super) {\n    http_request_extends(HTTPRequest, _super);\n    function HTTPRequest(hooks, method, url) {\n        var _this = _super.call(this) || this;\n        _this.hooks = hooks;\n        _this.method = method;\n        _this.url = url;\n        return _this;\n    }\n    HTTPRequest.prototype.start = function (payload) {\n        var _this = this;\n        this.position = 0;\n        this.xhr = this.hooks.getRequest(this);\n        this.unloader = function () {\n            _this.close();\n        };\n        runtime.addUnloadListener(this.unloader);\n        this.xhr.open(this.method, this.url, true);\n        if (this.xhr.setRequestHeader) {\n            this.xhr.setRequestHeader('Content-Type', 'application/json');\n        }\n        this.xhr.send(payload);\n    };\n    HTTPRequest.prototype.close = function () {\n        if (this.unloader) {\n            runtime.removeUnloadListener(this.unloader);\n            this.unloader = null;\n        }\n        if (this.xhr) {\n            this.hooks.abortRequest(this.xhr);\n            this.xhr = null;\n        }\n    };\n    HTTPRequest.prototype.onChunk = function (status, data) {\n        while (true) {\n            var chunk = this.advanceBuffer(data);\n            if (chunk) {\n                this.emit('chunk', { status: status, data: chunk });\n            }\n            else {\n                break;\n            }\n        }\n        if (this.isBufferTooLong(data)) {\n            this.emit('buffer_too_long');\n        }\n    };\n    HTTPRequest.prototype.advanceBuffer = function (buffer) {\n        var unreadData = buffer.slice(this.position);\n        var endOfLinePosition = unreadData.indexOf('\\n');\n        if (endOfLinePosition !== -1) {\n            this.position += endOfLinePosition + 1;\n            return unreadData.slice(0, endOfLinePosition);\n        }\n        else {\n            return null;\n        }\n    };\n    HTTPRequest.prototype.isBufferTooLong = function (buffer) {\n        return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n    };\n    return HTTPRequest;\n}(dispatcher));\n/* harmony default export */ var http_request = (http_request_HTTPRequest);\n\n// CONCATENATED MODULE: ./src/core/http/state.ts\nvar State;\n(function (State) {\n    State[State[\"CONNECTING\"] = 0] = \"CONNECTING\";\n    State[State[\"OPEN\"] = 1] = \"OPEN\";\n    State[State[\"CLOSED\"] = 3] = \"CLOSED\";\n})(State || (State = {}));\n/* harmony default export */ var state = (State);\n\n// CONCATENATED MODULE: ./src/core/http/http_socket.ts\n\n\n\nvar autoIncrement = 1;\nvar http_socket_HTTPSocket = (function () {\n    function HTTPSocket(hooks, url) {\n        this.hooks = hooks;\n        this.session = randomNumber(1000) + '/' + randomString(8);\n        this.location = getLocation(url);\n        this.readyState = state.CONNECTING;\n        this.openStream();\n    }\n    HTTPSocket.prototype.send = function (payload) {\n        return this.sendRaw(JSON.stringify([payload]));\n    };\n    HTTPSocket.prototype.ping = function () {\n        this.hooks.sendHeartbeat(this);\n    };\n    HTTPSocket.prototype.close = function (code, reason) {\n        this.onClose(code, reason, true);\n    };\n    HTTPSocket.prototype.sendRaw = function (payload) {\n        if (this.readyState === state.OPEN) {\n            try {\n                runtime.createSocketRequest('POST', getUniqueURL(getSendURL(this.location, this.session))).start(payload);\n                return true;\n            }\n            catch (e) {\n                return false;\n            }\n        }\n        else {\n            return false;\n        }\n    };\n    HTTPSocket.prototype.reconnect = function () {\n        this.closeStream();\n        this.openStream();\n    };\n    HTTPSocket.prototype.onClose = function (code, reason, wasClean) {\n        this.closeStream();\n        this.readyState = state.CLOSED;\n        if (this.onclose) {\n            this.onclose({\n                code: code,\n                reason: reason,\n                wasClean: wasClean\n            });\n        }\n    };\n    HTTPSocket.prototype.onChunk = function (chunk) {\n        if (chunk.status !== 200) {\n            return;\n        }\n        if (this.readyState === state.OPEN) {\n            this.onActivity();\n        }\n        var payload;\n        var type = chunk.data.slice(0, 1);\n        switch (type) {\n            case 'o':\n                payload = JSON.parse(chunk.data.slice(1) || '{}');\n                this.onOpen(payload);\n                break;\n            case 'a':\n                payload = JSON.parse(chunk.data.slice(1) || '[]');\n                for (var i = 0; i < payload.length; i++) {\n                    this.onEvent(payload[i]);\n                }\n                break;\n            case 'm':\n                payload = JSON.parse(chunk.data.slice(1) || 'null');\n                this.onEvent(payload);\n                break;\n            case 'h':\n                this.hooks.onHeartbeat(this);\n                break;\n            case 'c':\n                payload = JSON.parse(chunk.data.slice(1) || '[]');\n                this.onClose(payload[0], payload[1], true);\n                break;\n        }\n    };\n    HTTPSocket.prototype.onOpen = function (options) {\n        if (this.readyState === state.CONNECTING) {\n            if (options && options.hostname) {\n                this.location.base = replaceHost(this.location.base, options.hostname);\n            }\n            this.readyState = state.OPEN;\n            if (this.onopen) {\n                this.onopen();\n            }\n        }\n        else {\n            this.onClose(1006, 'Server lost session', true);\n        }\n    };\n    HTTPSocket.prototype.onEvent = function (event) {\n        if (this.readyState === state.OPEN && this.onmessage) {\n            this.onmessage({ data: event });\n        }\n    };\n    HTTPSocket.prototype.onActivity = function () {\n        if (this.onactivity) {\n            this.onactivity();\n        }\n    };\n    HTTPSocket.prototype.onError = function (error) {\n        if (this.onerror) {\n            this.onerror(error);\n        }\n    };\n    HTTPSocket.prototype.openStream = function () {\n        var _this = this;\n        this.stream = runtime.createSocketRequest('POST', getUniqueURL(this.hooks.getReceiveURL(this.location, this.session)));\n        this.stream.bind('chunk', function (chunk) {\n            _this.onChunk(chunk);\n        });\n        this.stream.bind('finished', function (status) {\n            _this.hooks.onFinished(_this, status);\n        });\n        this.stream.bind('buffer_too_long', function () {\n            _this.reconnect();\n        });\n        try {\n            this.stream.start();\n        }\n        catch (error) {\n            util.defer(function () {\n                _this.onError(error);\n                _this.onClose(1006, 'Could not start streaming', false);\n            });\n        }\n    };\n    HTTPSocket.prototype.closeStream = function () {\n        if (this.stream) {\n            this.stream.unbind_all();\n            this.stream.close();\n            this.stream = null;\n        }\n    };\n    return HTTPSocket;\n}());\nfunction getLocation(url) {\n    var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n    return {\n        base: parts[1],\n        queryString: parts[2]\n    };\n}\nfunction getSendURL(url, session) {\n    return url.base + '/' + session + '/xhr_send';\n}\nfunction getUniqueURL(url) {\n    var separator = url.indexOf('?') === -1 ? '?' : '&';\n    return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\nfunction replaceHost(url, hostname) {\n    var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n    return urlParts[1] + hostname + urlParts[3];\n}\nfunction randomNumber(max) {\n    return Math.floor(Math.random() * max);\n}\nfunction randomString(length) {\n    var result = [];\n    for (var i = 0; i < length; i++) {\n        result.push(randomNumber(32).toString(32));\n    }\n    return result.join('');\n}\n/* harmony default export */ var http_socket = (http_socket_HTTPSocket);\n\n// CONCATENATED MODULE: ./src/core/http/http_streaming_socket.ts\nvar http_streaming_socket_hooks = {\n    getReceiveURL: function (url, session) {\n        return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n    },\n    onHeartbeat: function (socket) {\n        socket.sendRaw('[]');\n    },\n    sendHeartbeat: function (socket) {\n        socket.sendRaw('[]');\n    },\n    onFinished: function (socket, status) {\n        socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n    }\n};\n/* harmony default export */ var http_streaming_socket = (http_streaming_socket_hooks);\n\n// CONCATENATED MODULE: ./src/core/http/http_polling_socket.ts\nvar http_polling_socket_hooks = {\n    getReceiveURL: function (url, session) {\n        return url.base + '/' + session + '/xhr' + url.queryString;\n    },\n    onHeartbeat: function () {\n    },\n    sendHeartbeat: function (socket) {\n        socket.sendRaw('[]');\n    },\n    onFinished: function (socket, status) {\n        if (status === 200) {\n            socket.reconnect();\n        }\n        else {\n            socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n        }\n    }\n};\n/* harmony default export */ var http_polling_socket = (http_polling_socket_hooks);\n\n// CONCATENATED MODULE: ./src/runtimes/isomorphic/http/http_xhr_request.ts\n\nvar http_xhr_request_hooks = {\n    getRequest: function (socket) {\n        var Constructor = runtime.getXHRAPI();\n        var xhr = new Constructor();\n        xhr.onreadystatechange = xhr.onprogress = function () {\n            switch (xhr.readyState) {\n                case 3:\n                    if (xhr.responseText && xhr.responseText.length > 0) {\n                        socket.onChunk(xhr.status, xhr.responseText);\n                    }\n                    break;\n                case 4:\n                    if (xhr.responseText && xhr.responseText.length > 0) {\n                        socket.onChunk(xhr.status, xhr.responseText);\n                    }\n                    socket.emit('finished', xhr.status);\n                    socket.close();\n                    break;\n            }\n        };\n        return xhr;\n    },\n    abortRequest: function (xhr) {\n        xhr.onreadystatechange = null;\n        xhr.abort();\n    }\n};\n/* harmony default export */ var http_xhr_request = (http_xhr_request_hooks);\n\n// CONCATENATED MODULE: ./src/runtimes/isomorphic/http/http.ts\n\n\n\n\n\nvar HTTP = {\n    createStreamingSocket: function (url) {\n        return this.createSocket(http_streaming_socket, url);\n    },\n    createPollingSocket: function (url) {\n        return this.createSocket(http_polling_socket, url);\n    },\n    createSocket: function (hooks, url) {\n        return new http_socket(hooks, url);\n    },\n    createXHR: function (method, url) {\n        return this.createRequest(http_xhr_request, method, url);\n    },\n    createRequest: function (hooks, method, url) {\n        return new http_request(hooks, method, url);\n    }\n};\n/* harmony default export */ var http_http = (HTTP);\n\n// CONCATENATED MODULE: ./src/runtimes/web/http/http.ts\n\n\nhttp_http.createXDR = function (method, url) {\n    return this.createRequest(http_xdomain_request, method, url);\n};\n/* harmony default export */ var web_http_http = (http_http);\n\n// CONCATENATED MODULE: ./src/runtimes/web/runtime.ts\n\n\n\n\n\n\n\n\n\n\n\n\nvar Runtime = {\n    nextAuthCallbackID: 1,\n    auth_callbacks: {},\n    ScriptReceivers: ScriptReceivers,\n    DependenciesReceivers: DependenciesReceivers,\n    getDefaultStrategy: default_strategy,\n    Transports: transports_transports,\n    transportConnectionInitializer: transport_connection_initializer,\n    HTTPFactory: web_http_http,\n    TimelineTransport: jsonp_timeline,\n    getXHRAPI: function () {\n        return window.XMLHttpRequest;\n    },\n    getWebSocketAPI: function () {\n        return window.WebSocket || window.MozWebSocket;\n    },\n    setup: function (PusherClass) {\n        var _this = this;\n        window.Pusher = PusherClass;\n        var initializeOnDocumentBody = function () {\n            _this.onDocumentBody(PusherClass.ready);\n        };\n        if (!window.JSON) {\n            Dependencies.load('json2', {}, initializeOnDocumentBody);\n        }\n        else {\n            initializeOnDocumentBody();\n        }\n    },\n    getDocument: function () {\n        return document;\n    },\n    getProtocol: function () {\n        return this.getDocument().location.protocol;\n    },\n    getAuthorizers: function () {\n        return { ajax: xhr_auth, jsonp: jsonp_auth };\n    },\n    onDocumentBody: function (callback) {\n        var _this = this;\n        if (document.body) {\n            callback();\n        }\n        else {\n            setTimeout(function () {\n                _this.onDocumentBody(callback);\n            }, 0);\n        }\n    },\n    createJSONPRequest: function (url, data) {\n        return new jsonp_request(url, data);\n    },\n    createScriptRequest: function (src) {\n        return new script_request(src);\n    },\n    getLocalStorage: function () {\n        try {\n            return window.localStorage;\n        }\n        catch (e) {\n            return undefined;\n        }\n    },\n    createXHR: function () {\n        if (this.getXHRAPI()) {\n            return this.createXMLHttpRequest();\n        }\n        else {\n            return this.createMicrosoftXHR();\n        }\n    },\n    createXMLHttpRequest: function () {\n        var Constructor = this.getXHRAPI();\n        return new Constructor();\n    },\n    createMicrosoftXHR: function () {\n        return new ActiveXObject('Microsoft.XMLHTTP');\n    },\n    getNetwork: function () {\n        return net_info_Network;\n    },\n    createWebSocket: function (url) {\n        var Constructor = this.getWebSocketAPI();\n        return new Constructor(url);\n    },\n    createSocketRequest: function (method, url) {\n        if (this.isXHRSupported()) {\n            return this.HTTPFactory.createXHR(method, url);\n        }\n        else if (this.isXDRSupported(url.indexOf('https:') === 0)) {\n            return this.HTTPFactory.createXDR(method, url);\n        }\n        else {\n            throw 'Cross-origin HTTP requests are not supported';\n        }\n    },\n    isXHRSupported: function () {\n        var Constructor = this.getXHRAPI();\n        return (Boolean(Constructor) && new Constructor().withCredentials !== undefined);\n    },\n    isXDRSupported: function (useTLS) {\n        var protocol = useTLS ? 'https:' : 'http:';\n        var documentProtocol = this.getProtocol();\n        return (Boolean(window['XDomainRequest']) && documentProtocol === protocol);\n    },\n    addUnloadListener: function (listener) {\n        if (window.addEventListener !== undefined) {\n            window.addEventListener('unload', listener, false);\n        }\n        else if (window.attachEvent !== undefined) {\n            window.attachEvent('onunload', listener);\n        }\n    },\n    removeUnloadListener: function (listener) {\n        if (window.addEventListener !== undefined) {\n            window.removeEventListener('unload', listener, false);\n        }\n        else if (window.detachEvent !== undefined) {\n            window.detachEvent('onunload', listener);\n        }\n    }\n};\n/* harmony default export */ var runtime = (Runtime);\n\n// CONCATENATED MODULE: ./src/core/timeline/level.ts\nvar TimelineLevel;\n(function (TimelineLevel) {\n    TimelineLevel[TimelineLevel[\"ERROR\"] = 3] = \"ERROR\";\n    TimelineLevel[TimelineLevel[\"INFO\"] = 6] = \"INFO\";\n    TimelineLevel[TimelineLevel[\"DEBUG\"] = 7] = \"DEBUG\";\n})(TimelineLevel || (TimelineLevel = {}));\n/* harmony default export */ var timeline_level = (TimelineLevel);\n\n// CONCATENATED MODULE: ./src/core/timeline/timeline.ts\n\n\n\nvar timeline_Timeline = (function () {\n    function Timeline(key, session, options) {\n        this.key = key;\n        this.session = session;\n        this.events = [];\n        this.options = options || {};\n        this.sent = 0;\n        this.uniqueID = 0;\n    }\n    Timeline.prototype.log = function (level, event) {\n        if (level <= this.options.level) {\n            this.events.push(extend({}, event, { timestamp: util.now() }));\n            if (this.options.limit && this.events.length > this.options.limit) {\n                this.events.shift();\n            }\n        }\n    };\n    Timeline.prototype.error = function (event) {\n        this.log(timeline_level.ERROR, event);\n    };\n    Timeline.prototype.info = function (event) {\n        this.log(timeline_level.INFO, event);\n    };\n    Timeline.prototype.debug = function (event) {\n        this.log(timeline_level.DEBUG, event);\n    };\n    Timeline.prototype.isEmpty = function () {\n        return this.events.length === 0;\n    };\n    Timeline.prototype.send = function (sendfn, callback) {\n        var _this = this;\n        var data = extend({\n            session: this.session,\n            bundle: this.sent + 1,\n            key: this.key,\n            lib: 'js',\n            version: this.options.version,\n            cluster: this.options.cluster,\n            features: this.options.features,\n            timeline: this.events\n        }, this.options.params);\n        this.events = [];\n        sendfn(data, function (error, result) {\n            if (!error) {\n                _this.sent++;\n            }\n            if (callback) {\n                callback(error, result);\n            }\n        });\n        return true;\n    };\n    Timeline.prototype.generateUniqueID = function () {\n        this.uniqueID++;\n        return this.uniqueID;\n    };\n    return Timeline;\n}());\n/* harmony default export */ var timeline_timeline = (timeline_Timeline);\n\n// CONCATENATED MODULE: ./src/core/strategies/transport_strategy.ts\n\n\n\n\nvar transport_strategy_TransportStrategy = (function () {\n    function TransportStrategy(name, priority, transport, options) {\n        this.name = name;\n        this.priority = priority;\n        this.transport = transport;\n        this.options = options || {};\n    }\n    TransportStrategy.prototype.isSupported = function () {\n        return this.transport.isSupported({\n            useTLS: this.options.useTLS\n        });\n    };\n    TransportStrategy.prototype.connect = function (minPriority, callback) {\n        var _this = this;\n        if (!this.isSupported()) {\n            return failAttempt(new UnsupportedStrategy(), callback);\n        }\n        else if (this.priority < minPriority) {\n            return failAttempt(new TransportPriorityTooLow(), callback);\n        }\n        var connected = false;\n        var transport = this.transport.createConnection(this.name, this.priority, this.options.key, this.options);\n        var handshake = null;\n        var onInitialized = function () {\n            transport.unbind('initialized', onInitialized);\n            transport.connect();\n        };\n        var onOpen = function () {\n            handshake = factory.createHandshake(transport, function (result) {\n                connected = true;\n                unbindListeners();\n                callback(null, result);\n            });\n        };\n        var onError = function (error) {\n            unbindListeners();\n            callback(error);\n        };\n        var onClosed = function () {\n            unbindListeners();\n            var serializedTransport;\n            serializedTransport = safeJSONStringify(transport);\n            callback(new TransportClosed(serializedTransport));\n        };\n        var unbindListeners = function () {\n            transport.unbind('initialized', onInitialized);\n            transport.unbind('open', onOpen);\n            transport.unbind('error', onError);\n            transport.unbind('closed', onClosed);\n        };\n        transport.bind('initialized', onInitialized);\n        transport.bind('open', onOpen);\n        transport.bind('error', onError);\n        transport.bind('closed', onClosed);\n        transport.initialize();\n        return {\n            abort: function () {\n                if (connected) {\n                    return;\n                }\n                unbindListeners();\n                if (handshake) {\n                    handshake.close();\n                }\n                else {\n                    transport.close();\n                }\n            },\n            forceMinPriority: function (p) {\n                if (connected) {\n                    return;\n                }\n                if (_this.priority < p) {\n                    if (handshake) {\n                        handshake.close();\n                    }\n                    else {\n                        transport.close();\n                    }\n                }\n            }\n        };\n    };\n    return TransportStrategy;\n}());\n/* harmony default export */ var transport_strategy = (transport_strategy_TransportStrategy);\nfunction failAttempt(error, callback) {\n    util.defer(function () {\n        callback(error);\n    });\n    return {\n        abort: function () { },\n        forceMinPriority: function () { }\n    };\n}\n\n// CONCATENATED MODULE: ./src/core/strategies/strategy_builder.ts\n\n\n\n\n\nvar strategy_builder_Transports = runtime.Transports;\nvar strategy_builder_defineTransport = function (config, name, type, priority, options, manager) {\n    var transportClass = strategy_builder_Transports[type];\n    if (!transportClass) {\n        throw new UnsupportedTransport(type);\n    }\n    var enabled = (!config.enabledTransports ||\n        arrayIndexOf(config.enabledTransports, name) !== -1) &&\n        (!config.disabledTransports ||\n            arrayIndexOf(config.disabledTransports, name) === -1);\n    var transport;\n    if (enabled) {\n        options = Object.assign({ ignoreNullOrigin: config.ignoreNullOrigin }, options);\n        transport = new transport_strategy(name, priority, manager ? manager.getAssistant(transportClass) : transportClass, options);\n    }\n    else {\n        transport = strategy_builder_UnsupportedStrategy;\n    }\n    return transport;\n};\nvar strategy_builder_UnsupportedStrategy = {\n    isSupported: function () {\n        return false;\n    },\n    connect: function (_, callback) {\n        var deferred = util.defer(function () {\n            callback(new UnsupportedStrategy());\n        });\n        return {\n            abort: function () {\n                deferred.ensureAborted();\n            },\n            forceMinPriority: function () { }\n        };\n    }\n};\n\n// CONCATENATED MODULE: ./src/core/auth/user_authenticator.ts\n\n\nvar composeChannelQuery = function (params, authOptions) {\n    var query = 'socket_id=' + encodeURIComponent(params.socketId);\n    for (var i in authOptions.params) {\n        query +=\n            '&' +\n                encodeURIComponent(i) +\n                '=' +\n                encodeURIComponent(authOptions.params[i]);\n    }\n    return query;\n};\nvar UserAuthenticator = function (authOptions) {\n    if (typeof runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n        throw \"'\" + authOptions.transport + \"' is not a recognized auth transport\";\n    }\n    return function (params, callback) {\n        var query = composeChannelQuery(params, authOptions);\n        runtime.getAuthorizers()[authOptions.transport](runtime, query, authOptions, AuthRequestType.UserAuthentication, callback);\n    };\n};\n/* harmony default export */ var user_authenticator = (UserAuthenticator);\n\n// CONCATENATED MODULE: ./src/core/auth/channel_authorizer.ts\n\n\nvar channel_authorizer_composeChannelQuery = function (params, authOptions) {\n    var query = 'socket_id=' + encodeURIComponent(params.socketId);\n    query += '&channel_name=' + encodeURIComponent(params.channelName);\n    for (var i in authOptions.params) {\n        query +=\n            '&' +\n                encodeURIComponent(i) +\n                '=' +\n                encodeURIComponent(authOptions.params[i]);\n    }\n    return query;\n};\nvar ChannelAuthorizer = function (authOptions) {\n    if (typeof runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n        throw \"'\" + authOptions.transport + \"' is not a recognized auth transport\";\n    }\n    return function (params, callback) {\n        var query = channel_authorizer_composeChannelQuery(params, authOptions);\n        runtime.getAuthorizers()[authOptions.transport](runtime, query, authOptions, AuthRequestType.ChannelAuthorization, callback);\n    };\n};\n/* harmony default export */ var channel_authorizer = (ChannelAuthorizer);\n\n// CONCATENATED MODULE: ./src/core/auth/deprecated_channel_authorizer.ts\nvar ChannelAuthorizerProxy = function (pusher, authOptions, channelAuthorizerGenerator) {\n    var deprecatedAuthorizerOptions = {\n        authTransport: authOptions.transport,\n        authEndpoint: authOptions.endpoint,\n        auth: {\n            params: authOptions.params,\n            headers: authOptions.headers\n        }\n    };\n    return function (params, callback) {\n        var channel = pusher.channel(params.channelName);\n        var channelAuthorizer = channelAuthorizerGenerator(channel, deprecatedAuthorizerOptions);\n        channelAuthorizer.authorize(params.socketId, callback);\n    };\n};\n\n// CONCATENATED MODULE: ./src/core/config.ts\nvar __assign = ( false) || function () {\n    __assign = Object.assign || function(t) {\n        for (var s, i = 1, n = arguments.length; i < n; i++) {\n            s = arguments[i];\n            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n                t[p] = s[p];\n        }\n        return t;\n    };\n    return __assign.apply(this, arguments);\n};\n\n\n\n\n\nfunction getConfig(opts, pusher) {\n    var config = {\n        activityTimeout: opts.activityTimeout || defaults.activityTimeout,\n        cluster: opts.cluster || defaults.cluster,\n        httpPath: opts.httpPath || defaults.httpPath,\n        httpPort: opts.httpPort || defaults.httpPort,\n        httpsPort: opts.httpsPort || defaults.httpsPort,\n        pongTimeout: opts.pongTimeout || defaults.pongTimeout,\n        statsHost: opts.statsHost || defaults.stats_host,\n        unavailableTimeout: opts.unavailableTimeout || defaults.unavailableTimeout,\n        wsPath: opts.wsPath || defaults.wsPath,\n        wsPort: opts.wsPort || defaults.wsPort,\n        wssPort: opts.wssPort || defaults.wssPort,\n        enableStats: getEnableStatsConfig(opts),\n        httpHost: getHttpHost(opts),\n        useTLS: shouldUseTLS(opts),\n        wsHost: getWebsocketHost(opts),\n        userAuthenticator: buildUserAuthenticator(opts),\n        channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n    };\n    if ('disabledTransports' in opts)\n        config.disabledTransports = opts.disabledTransports;\n    if ('enabledTransports' in opts)\n        config.enabledTransports = opts.enabledTransports;\n    if ('ignoreNullOrigin' in opts)\n        config.ignoreNullOrigin = opts.ignoreNullOrigin;\n    if ('timelineParams' in opts)\n        config.timelineParams = opts.timelineParams;\n    if ('nacl' in opts) {\n        config.nacl = opts.nacl;\n    }\n    return config;\n}\nfunction getHttpHost(opts) {\n    if (opts.httpHost) {\n        return opts.httpHost;\n    }\n    if (opts.cluster) {\n        return \"sockjs-\" + opts.cluster + \".pusher.com\";\n    }\n    return defaults.httpHost;\n}\nfunction getWebsocketHost(opts) {\n    if (opts.wsHost) {\n        return opts.wsHost;\n    }\n    if (opts.cluster) {\n        return getWebsocketHostFromCluster(opts.cluster);\n    }\n    return getWebsocketHostFromCluster(defaults.cluster);\n}\nfunction getWebsocketHostFromCluster(cluster) {\n    return \"ws-\" + cluster + \".pusher.com\";\n}\nfunction shouldUseTLS(opts) {\n    if (runtime.getProtocol() === 'https:') {\n        return true;\n    }\n    else if (opts.forceTLS === false) {\n        return false;\n    }\n    return true;\n}\nfunction getEnableStatsConfig(opts) {\n    if ('enableStats' in opts) {\n        return opts.enableStats;\n    }\n    if ('disableStats' in opts) {\n        return !opts.disableStats;\n    }\n    return false;\n}\nfunction buildUserAuthenticator(opts) {\n    var userAuthentication = __assign({}, defaults.userAuthentication, opts.userAuthentication);\n    if ('customHandler' in userAuthentication &&\n        userAuthentication['customHandler'] != null) {\n        return userAuthentication['customHandler'];\n    }\n    return user_authenticator(userAuthentication);\n}\nfunction buildChannelAuth(opts, pusher) {\n    var channelAuthorization;\n    if ('channelAuthorization' in opts) {\n        channelAuthorization = __assign({}, defaults.channelAuthorization, opts.channelAuthorization);\n    }\n    else {\n        channelAuthorization = {\n            transport: opts.authTransport || defaults.authTransport,\n            endpoint: opts.authEndpoint || defaults.authEndpoint\n        };\n        if ('auth' in opts) {\n            if ('params' in opts.auth)\n                channelAuthorization.params = opts.auth.params;\n            if ('headers' in opts.auth)\n                channelAuthorization.headers = opts.auth.headers;\n        }\n        if ('authorizer' in opts)\n            channelAuthorization.customHandler = ChannelAuthorizerProxy(pusher, channelAuthorization, opts.authorizer);\n    }\n    return channelAuthorization;\n}\nfunction buildChannelAuthorizer(opts, pusher) {\n    var channelAuthorization = buildChannelAuth(opts, pusher);\n    if ('customHandler' in channelAuthorization &&\n        channelAuthorization['customHandler'] != null) {\n        return channelAuthorization['customHandler'];\n    }\n    return channel_authorizer(channelAuthorization);\n}\n\n// CONCATENATED MODULE: ./src/core/utils/flat_promise.ts\nfunction flatPromise() {\n    var resolve, reject;\n    var promise = new Promise(function (res, rej) {\n        resolve = res;\n        reject = rej;\n    });\n    return { promise: promise, resolve: resolve, reject: reject };\n}\n/* harmony default export */ var flat_promise = (flatPromise);\n\n// CONCATENATED MODULE: ./src/core/user.ts\nvar user_extends = ( false) || (function () {\n    var extendStatics = function (d, b) {\n        extendStatics = Object.setPrototypeOf ||\n            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n        return extendStatics(d, b);\n    };\n    return function (d, b) {\n        extendStatics(d, b);\n        function __() { this.constructor = d; }\n        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n    };\n})();\n\n\n\n\nvar user_UserFacade = (function (_super) {\n    user_extends(UserFacade, _super);\n    function UserFacade(pusher) {\n        var _this = _super.call(this, function (eventName, data) {\n            logger.debug('No callbacks on user for ' + eventName);\n        }) || this;\n        _this.signin_requested = false;\n        _this.user_data = null;\n        _this.serverToUserChannel = null;\n        _this.signinDonePromise = null;\n        _this._signinDoneResolve = null;\n        _this._onAuthorize = function (err, authData) {\n            if (err) {\n                logger.warn(\"Error during signin: \" + err);\n                _this._cleanup();\n                return;\n            }\n            _this.pusher.send_event('pusher:signin', {\n                auth: authData.auth,\n                user_data: authData.user_data\n            });\n        };\n        _this.pusher = pusher;\n        _this.pusher.connection.bind('state_change', function (_a) {\n            var previous = _a.previous, current = _a.current;\n            if (previous !== 'connected' && current === 'connected') {\n                _this._signin();\n            }\n            if (previous === 'connected' && current !== 'connected') {\n                _this._cleanup();\n                _this._newSigninPromiseIfNeeded();\n            }\n        });\n        _this.pusher.connection.bind('message', function (event) {\n            var eventName = event.event;\n            if (eventName === 'pusher:signin_success') {\n                _this._onSigninSuccess(event.data);\n            }\n            if (_this.serverToUserChannel &&\n                _this.serverToUserChannel.name === event.channel) {\n                _this.serverToUserChannel.handleEvent(event);\n            }\n        });\n        return _this;\n    }\n    UserFacade.prototype.signin = function () {\n        if (this.signin_requested) {\n            return;\n        }\n        this.signin_requested = true;\n        this._signin();\n    };\n    UserFacade.prototype._signin = function () {\n        if (!this.signin_requested) {\n            return;\n        }\n        this._newSigninPromiseIfNeeded();\n        if (this.pusher.connection.state !== 'connected') {\n            return;\n        }\n        this.pusher.config.userAuthenticator({\n            socketId: this.pusher.connection.socket_id\n        }, this._onAuthorize);\n    };\n    UserFacade.prototype._onSigninSuccess = function (data) {\n        try {\n            this.user_data = JSON.parse(data.user_data);\n        }\n        catch (e) {\n            logger.error(\"Failed parsing user data after signin: \" + data.user_data);\n            this._cleanup();\n            return;\n        }\n        if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n            logger.error(\"user_data doesn't contain an id. user_data: \" + this.user_data);\n            this._cleanup();\n            return;\n        }\n        this._signinDoneResolve();\n        this._subscribeChannels();\n    };\n    UserFacade.prototype._subscribeChannels = function () {\n        var _this = this;\n        var ensure_subscribed = function (channel) {\n            if (channel.subscriptionPending && channel.subscriptionCancelled) {\n                channel.reinstateSubscription();\n            }\n            else if (!channel.subscriptionPending &&\n                _this.pusher.connection.state === 'connected') {\n                channel.subscribe();\n            }\n        };\n        this.serverToUserChannel = new channels_channel(\"#server-to-user-\" + this.user_data.id, this.pusher);\n        this.serverToUserChannel.bind_global(function (eventName, data) {\n            if (eventName.indexOf('pusher_internal:') === 0 ||\n                eventName.indexOf('pusher:') === 0) {\n                return;\n            }\n            _this.emit(eventName, data);\n        });\n        ensure_subscribed(this.serverToUserChannel);\n    };\n    UserFacade.prototype._cleanup = function () {\n        this.user_data = null;\n        if (this.serverToUserChannel) {\n            this.serverToUserChannel.unbind_all();\n            this.serverToUserChannel.disconnect();\n            this.serverToUserChannel = null;\n        }\n        if (this.signin_requested) {\n            this._signinDoneResolve();\n        }\n    };\n    UserFacade.prototype._newSigninPromiseIfNeeded = function () {\n        if (!this.signin_requested) {\n            return;\n        }\n        if (this.signinDonePromise && !this.signinDonePromise.done) {\n            return;\n        }\n        var _a = flat_promise(), promise = _a.promise, resolve = _a.resolve, _ = _a.reject;\n        promise.done = false;\n        var setDone = function () {\n            promise.done = true;\n        };\n        promise.then(setDone)[\"catch\"](setDone);\n        this.signinDonePromise = promise;\n        this._signinDoneResolve = resolve;\n    };\n    return UserFacade;\n}(dispatcher));\n/* harmony default export */ var user = (user_UserFacade);\n\n// CONCATENATED MODULE: ./src/core/pusher.ts\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar pusher_Pusher = (function () {\n    function Pusher(app_key, options) {\n        var _this = this;\n        checkAppKey(app_key);\n        options = options || {};\n        if (!options.cluster && !(options.wsHost || options.httpHost)) {\n            var suffix = url_store.buildLogSuffix('javascriptQuickStart');\n            logger.warn(\"You should always specify a cluster when connecting. \" + suffix);\n        }\n        if ('disableStats' in options) {\n            logger.warn('The disableStats option is deprecated in favor of enableStats');\n        }\n        this.key = app_key;\n        this.config = getConfig(options, this);\n        this.channels = factory.createChannels();\n        this.global_emitter = new dispatcher();\n        this.sessionID = Math.floor(Math.random() * 1000000000);\n        this.timeline = new timeline_timeline(this.key, this.sessionID, {\n            cluster: this.config.cluster,\n            features: Pusher.getClientFeatures(),\n            params: this.config.timelineParams || {},\n            limit: 50,\n            level: timeline_level.INFO,\n            version: defaults.VERSION\n        });\n        if (this.config.enableStats) {\n            this.timelineSender = factory.createTimelineSender(this.timeline, {\n                host: this.config.statsHost,\n                path: '/timeline/v2/' + runtime.TimelineTransport.name\n            });\n        }\n        var getStrategy = function (options) {\n            return runtime.getDefaultStrategy(_this.config, options, strategy_builder_defineTransport);\n        };\n        this.connection = factory.createConnectionManager(this.key, {\n            getStrategy: getStrategy,\n            timeline: this.timeline,\n            activityTimeout: this.config.activityTimeout,\n            pongTimeout: this.config.pongTimeout,\n            unavailableTimeout: this.config.unavailableTimeout,\n            useTLS: Boolean(this.config.useTLS)\n        });\n        this.connection.bind('connected', function () {\n            _this.subscribeAll();\n            if (_this.timelineSender) {\n                _this.timelineSender.send(_this.connection.isUsingTLS());\n            }\n        });\n        this.connection.bind('message', function (event) {\n            var eventName = event.event;\n            var internal = eventName.indexOf('pusher_internal:') === 0;\n            if (event.channel) {\n                var channel = _this.channel(event.channel);\n                if (channel) {\n                    channel.handleEvent(event);\n                }\n            }\n            if (!internal) {\n                _this.global_emitter.emit(event.event, event.data);\n            }\n        });\n        this.connection.bind('connecting', function () {\n            _this.channels.disconnect();\n        });\n        this.connection.bind('disconnected', function () {\n            _this.channels.disconnect();\n        });\n        this.connection.bind('error', function (err) {\n            logger.warn(err);\n        });\n        Pusher.instances.push(this);\n        this.timeline.info({ instances: Pusher.instances.length });\n        this.user = new user(this);\n        if (Pusher.isReady) {\n            this.connect();\n        }\n    }\n    Pusher.ready = function () {\n        Pusher.isReady = true;\n        for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n            Pusher.instances[i].connect();\n        }\n    };\n    Pusher.getClientFeatures = function () {\n        return keys(filterObject({ ws: runtime.Transports.ws }, function (t) {\n            return t.isSupported({});\n        }));\n    };\n    Pusher.prototype.channel = function (name) {\n        return this.channels.find(name);\n    };\n    Pusher.prototype.allChannels = function () {\n        return this.channels.all();\n    };\n    Pusher.prototype.connect = function () {\n        this.connection.connect();\n        if (this.timelineSender) {\n            if (!this.timelineSenderTimer) {\n                var usingTLS = this.connection.isUsingTLS();\n                var timelineSender = this.timelineSender;\n                this.timelineSenderTimer = new PeriodicTimer(60000, function () {\n                    timelineSender.send(usingTLS);\n                });\n            }\n        }\n    };\n    Pusher.prototype.disconnect = function () {\n        this.connection.disconnect();\n        if (this.timelineSenderTimer) {\n            this.timelineSenderTimer.ensureAborted();\n            this.timelineSenderTimer = null;\n        }\n    };\n    Pusher.prototype.bind = function (event_name, callback, context) {\n        this.global_emitter.bind(event_name, callback, context);\n        return this;\n    };\n    Pusher.prototype.unbind = function (event_name, callback, context) {\n        this.global_emitter.unbind(event_name, callback, context);\n        return this;\n    };\n    Pusher.prototype.bind_global = function (callback) {\n        this.global_emitter.bind_global(callback);\n        return this;\n    };\n    Pusher.prototype.unbind_global = function (callback) {\n        this.global_emitter.unbind_global(callback);\n        return this;\n    };\n    Pusher.prototype.unbind_all = function (callback) {\n        this.global_emitter.unbind_all();\n        return this;\n    };\n    Pusher.prototype.subscribeAll = function () {\n        var channelName;\n        for (channelName in this.channels.channels) {\n            if (this.channels.channels.hasOwnProperty(channelName)) {\n                this.subscribe(channelName);\n            }\n        }\n    };\n    Pusher.prototype.subscribe = function (channel_name) {\n        var channel = this.channels.add(channel_name, this);\n        if (channel.subscriptionPending && channel.subscriptionCancelled) {\n            channel.reinstateSubscription();\n        }\n        else if (!channel.subscriptionPending &&\n            this.connection.state === 'connected') {\n            channel.subscribe();\n        }\n        return channel;\n    };\n    Pusher.prototype.unsubscribe = function (channel_name) {\n        var channel = this.channels.find(channel_name);\n        if (channel && channel.subscriptionPending) {\n            channel.cancelSubscription();\n        }\n        else {\n            channel = this.channels.remove(channel_name);\n            if (channel && channel.subscribed) {\n                channel.unsubscribe();\n            }\n        }\n    };\n    Pusher.prototype.send_event = function (event_name, data, channel) {\n        return this.connection.send_event(event_name, data, channel);\n    };\n    Pusher.prototype.shouldUseTLS = function () {\n        return this.config.useTLS;\n    };\n    Pusher.prototype.signin = function () {\n        this.user.signin();\n    };\n    Pusher.instances = [];\n    Pusher.isReady = false;\n    Pusher.logToConsole = false;\n    Pusher.Runtime = runtime;\n    Pusher.ScriptReceivers = runtime.ScriptReceivers;\n    Pusher.DependenciesReceivers = runtime.DependenciesReceivers;\n    Pusher.auth_callbacks = runtime.auth_callbacks;\n    return Pusher;\n}());\n/* harmony default export */ var core_pusher = __webpack_exports__[\"default\"] = (pusher_Pusher);\nfunction checkAppKey(key) {\n    if (key === null || key === undefined) {\n        throw 'You must pass your app key when you instantiate Pusher.';\n    }\n}\nruntime.setup(pusher_Pusher);\n\n\n/***/ })\n/******/ ]);\n});\n//# sourceMappingURL=pusher.js.map\n\n//# sourceURL=webpack://webpacked/./node_modules/pusher-js/dist/web/pusher.js?")},486:function(__unused_webpack_module,__unused_webpack___webpack_exports__,__webpack_require__){"use strict";eval("\n// EXTERNAL MODULE: ./node_modules/pusher-js/dist/web/pusher.js\nvar web_pusher = __webpack_require__(606);\nvar pusher_default = /*#__PURE__*/__webpack_require__.n(web_pusher);\n;// CONCATENATED MODULE: ./src/chat/Chat.js\n\n\nclass Chat {\n  constructor(messages_url, new_message_url, pusher_configs, current_id, headers = {}) {\n    const chatBlockView = document.querySelector(\"#chat-block-main\")\n      //const chatMainView = document.querySelector(\"#chat-block-main .chat-block\")\n    const maximizeBtn = document.querySelector(\"#chat-block-main .maximize\")\n    const minimizeBtn = document.querySelector(\"#chat-block-main .minimize\")\n    const users = document.querySelectorAll(\"#chat-block-main .users-wrapper .users-list .user\")\n\n    // Go back button on smaller screens.\n    const resetView = chatBlockView.querySelector('.chat-controls .go-back')\n\n    const usersView = chatBlockView.querySelector('.users-wrapper')\n    const messagesView = chatBlockView.querySelector('.messages-view')\n    const chatInput = chatBlockView.querySelector('[type=\"input\"], [name=\"message\"]')\n\n    chatInput\n      .addEventListener('keyup', async (e) => await this.sendNewMessage(e))\n\n    const controls = [maximizeBtn, minimizeBtn]\n\n    controls.forEach(item => {\n      item.addEventListener('click', event => {\n        this.updateControls(event)\n      })\n    })\n    this.controls = controls\n    this.chatBlockView  = chatBlockView\n    this.usersView  = usersView\n    this.messagesView  = messagesView\n    this.resetView = resetView\n    this.chatInput = chatInput\n    this.resetView.addEventListener('click', this.showUserListing)\n    this.messagesUrl = messages_url\n    this.newMessageUrl = new_message_url\n    this.receiverId = ''\n    this.currentId = current_id\n    this.headers = headers\n    // Holds the messages pages (pager) item\n    this.pages = {\n      current_page: null,\n      total_pages: 0,\n      total_items: \"\"\n    }\n\n    users.forEach(user => {\n      user.addEventListener('click',  async () => await this.showChats(user))\n\n    })\n\n    // Observer definitions\n    this.observerConfig = {\n      attributes: true,\n      attributeOldValue: true,\n      attributeFilter: ['class'],\n      childList: true,\n      subtree: true\n    };\n\n    const options = {\n      root: null,\n      //threshold: 1, //@TODO only works on windows!!!\n      rootMargin: \"60%\" // fetch earlier\n      // rootMargin: \"-10px\" // fetch later\n    }\n    /**\n     * Observes scroll position on the particular\n     * DOM elements it's assigned to.\n     * @type {IntersectionObserver}\n     */\n    this.intersectionObserver =\n      new IntersectionObserver(entries => {\n          this.observeIntersections(entries)\n        },\n        options\n      )\n\n\n     // Observes attribute changes on the particular\n     // DOM elements it's assigned to.\n\n    // this.mutationObserver = new MutationObserver(entries => {\n    //   this.observeMutations(entries)\n    // })\n\n\n    const pusher = new (pusher_default())(pusher_configs.app_key, {\n      cluster: pusher_configs.cluster,\n      headers: headers,\n    })\n\n    const channel = pusher.subscribe('my-channel')\n    channel.bind('dru-chat-event', (data) => this.druChatEvent(data))\n  }\n\n  updateControls = (event) => {\n\n    // Toggle now-show class between the controls\n    this.controls.forEach(control => {\n      control.classList.toggle('no-show')\n    });\n\n    // Toggle children-hidden class too, on main block\n    this.chatBlockView.classList.toggle('children-hidden')\n    // Toggle show for div with users and messages listing\n    this.chatBlockView.querySelector('.chat-block')\n      .classList.toggle('no-show')\n\n    // Use the event details to determine what other\n    // parts (attributes) of the chat to update\n\n  }\n\n  // Resets user view on smaller screens.\n  showUserListing = () => {\n    this.resetView.classList.toggle('no-show')\n\n    // Hide message view and show users listing instead.\n    // Like reset what's done in show chats,\n    this.usersView.classList.toggle('no-show')\n    this.messagesView.classList.toggle('no-show')\n  }\n\n  showChats = async (user) => {\n\n    // Remove active class from previous if any\n    this.usersView.querySelector('.active')\n      ?.classList?.remove('active')\n\n    // remove inactive state from input\n    this.chatInput.removeAttribute('disabled')\n\n\n    // Add active class to current.\n    user.classList.add('active')\n    const userId = user.getAttribute('id');\n    this.receiverId = userId\n    // Reset pages too.\n    this.pages = {\n      current_page: null,\n      total_pages: 0,\n      total_items: \"\"\n    }\n\n    // Reset message view\n    this.messagesView.querySelector('.message-list')\n      .innerHTML = ''\n\n    // Toggle for mobile apps .users-wrapper and messages-view\n    // User listing vs message listing view.\n\n    this.usersView.classList.toggle('no-show')\n    this.messagesView.classList.toggle('no-show')\n    this.resetView.classList.toggle('no-show')\n    // Display btn to go back to user listing too\n\n    // Update message header.\n\n    this.messagesView.querySelector('.header img').src\n      = user.querySelector('img').src\n\n    this.messagesView.querySelector('.header .username').innerText\n      = user.querySelector('.display-name').innerText\n    await this.loadChats()\n  }\n\n  loadChats = async () => {\n\n    // Just a limit to compare against current_pages.\n    const limit = this.pages.total_pages ? this.pages.total_pages : -2;\n    if (limit === (this.pages.current_page + 1)) return\n\n\n    const messages = this.messagesView.querySelector('.message-list')\n\n    // Determine if to auto scroll/focus with messages.innerHTML\n    // const shouldScroll = messages.innerHTML ? false : true\n\n    const messageList = await this.newMsgFromTemplate()\n\n    // If no messages from request and it's the first request.\n    // meaning messages.innerHTML is empty string, we show a message,\n    // of \"no chat between the two users\".\n    if (!messageList.childElementCount && !messages.innerHTML) {\n      const noMsgWrapper = document.createElement('div')\n      noMsgWrapper.classList.add('no-message')\n      noMsgWrapper.style.height = 'auto'\n      const messageDiv = document.createElement('div')\n      messageDiv.classList.add('message', 'received')\n      const msgParagraph = document.createElement('p')\n      msgParagraph.innerText = \"This is the very beginning of your chat with this user, go on \" +\n        \"and send your first message.\"\n      messageDiv.prepend(msgParagraph)\n      noMsgWrapper.appendChild(messageDiv)\n      messages.prepend(noMsgWrapper)\n      // @TODO add height to this div\n    }\n\n    // Append to screen\n    messages.prepend(messageList)\n\n    //if (shouldScroll) {\n      messages\n        ?.querySelector(`[tabindex=\"${this.pages.current_page}\"]`)\n        ?.focus()\n    //}\n\n      //.focus({preventScroll: false})\n\n    // @TODO scroll into view bug,\n\n  }\n\n\n  observeIntersections = (entries) => {\n\n    entries.forEach( async (entry) => {\n\n      if (entry.isIntersecting) {\n\n        // Get the next items (pager).\n         await this.loadChats();\n\n        // Only observing the last item on the message list.\n        this.intersectionObserver.unobserve(entry.target)\n\n      }\n    })\n  }\n\n  newMsgFromTemplate = async () => {\n\n    const messageData = await this.fetchMessagesByPage()\n\n    const newMessages = document.createDocumentFragment();\n    const {messages, pages} = messageData\n    this.pages = {...pages}\n\n    // Reverse array since we're appending items in that order.\n    messages?.reverse().forEach((data, index) => {\n      //data.created = data.created * 1000\n      const messageDiv = this.messageTemplateFromData(data)\n      if (index === 0) {\n        // Last item scroll Dom listener, so we load the\n        // Next page(pager).\n        //messageDiv.classList.add('testing-index-30')\n        this.intersectionObserver.observe(messageDiv)\n      }\n      // Add tabindex to the message at the bottom to focus.\n      if (messages.length === (index + 1)) {\n        // Add tabindex for to focus()\n        messageDiv.setAttribute('tabindex', pages.current_page)\n\n      }\n      newMessages.appendChild(messageDiv)\n    })\n    return newMessages\n  }\n\n  sendNewMessage = async (event) => {\n\n    // On larger screens, the message listing plus,\n    // the input are displayed even if no user is\n    // selected (receiver), we set a message and\n    // disable input.\n    const messages = this.messagesView.querySelector('.message-list')\n    if (!this.receiverId) {\n      const noReceiverWrapper = document.createElement('div')\n      noReceiverWrapper.classList.add('no-message')\n      //noReceiverWrapper.style.height = '80%'\n\n      const messageDiv = document.createElement('div')\n      messageDiv.classList.add('message', 'received')\n      const msgParagraph = document.createElement('p')\n      msgParagraph.innerText = \"Please select a user from the left to chat with!.\"\n      msgParagraph.classList.add('warning')\n      messageDiv.prepend(msgParagraph)\n      noReceiverWrapper.appendChild(messageDiv)\n      messages.prepend(noReceiverWrapper)\n      event.target.setAttribute('disabled', 'true')\n      return\n    }\n\n\n    if (event.keyCode === 13 && this.receiverId && event.target.value) {\n\n      const headers = {'Content-Type': 'application/x-www-form-urlencoded', ...this.headers}\n\n      await fetch(this.newMessageUrl, {\n        method: 'POST',\n        mode: 'same-origin', // no-cors, *cors, same-origin\n        cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached\n        credentials: 'same-origin', // include, *same-origin, omit\n        headers,\n        redirect: 'follow', // manual, *follow, error\n        referrerPolicy: 'no-referrer', // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url\n        body: new URLSearchParams({\n          'receiver_id': this.receiverId,\n          'message': event.target.value\n        })\n\n        // 'message': Drupal.checkPlain(event.target.value)\n      })\n\n      const messages = this.messagesView.querySelector('.message-list')\n\n      // Append message to message view\n      const data = {\n        message: event.target.value,\n        to: this.receiverId,\n        from: this.currentId,\n        is_read: 1,\n        created: Date.now(),\n      }\n      const messageDiv = this.messageTemplateFromData(data)\n      messages.appendChild(messageDiv)\n\n      messages.scrollTop = messages.scrollHeight\n      // Clear value\n      event.target.value = ''\n    }\n\n    //alert(e.target.value)\n  }\n\n  druChatEvent = ({from, to}) => {\n    // If currentId is same as from,\n    // update view the messages for the message sender.\n    if (this.currentId === from) {\n     // For this user the message is attached to the message view,\n      // before the input field is cleared, message contains the\n      // input field value @TODO about is_read.\n\n    }\n      // The receiver of the message now.\n      // Which has multiple variants to consider for\n      // each work-flow.\n      // @TODO play sound for receiver below too\n    else if (this.currentId === parseInt(to)) {\n      // Check if 'from' has a class of active.\n      // Update view chat if so\n      // Else update unread count\n      const receiver = this.usersView.querySelector(`[id=\"${from}\"]`)\n      if (receiver.classList.contains('active')) {\n        // Load the last message between current user (this receiver) and sender (from).\n        this.fetchMessagesByPage(from)\n          .then((data) => {\n            const messages = this.messagesView.querySelector('.message-list')\n            // data.messages[0].created = data.messages[0].created * 1000\n            const msgDiv = this.messageTemplateFromData(data.messages[0])\n            messages.appendChild(msgDiv)\n\n            messages.scrollTop = messages.scrollHeight\n          })\n\n      } else {\n        // Update unread count.\n        const unreadCount = receiver.querySelector('.pending .unread-count')\n        if (unreadCount?.innerText) {\n          unreadCount.innerText = parseInt(unreadCount.innerText) + 1\n        } else {\n          const item = document.createElement('span')\n          item.classList.add('unread-count')\n          item.innerText = 1\n          receiver.querySelector('.pending')\n            .appendChild(item)\n        }\n      }\n    }\n  }\n\n  /**\n   * Creates a message div from the data object.\n   * @param data\n   * @returns {HTMLDivElement}\n   */\n  messageTemplateFromData = data => {\n    // Create a message div from data\n    const messageDiv = document.createElement('div')\n    if (parseInt(data.from) === parseInt(this.currentId)) {\n      messageDiv.classList.add('message','sent')\n    } else {\n      messageDiv.classList.add('message','received')\n    }\n    const msgParagraph = document.createElement('p')\n    msgParagraph.innerText = data.message\n    const sentAt = document.createElement('span')\n\n    sentAt.innerText = new Date(data.created).toLocaleString()\n    msgParagraph.append(sentAt)\n    messageDiv.appendChild(msgParagraph)\n    return messageDiv\n  }\n\n\n  /**\n   * Fetches message by receiver_id.\n   * also updates the pages item {}.\n   * @param receiver_id\n   * @returns {Promise<any>}\n   */\n  fetchMessagesByPage = async (receiver_id = null) => {\n    if (this.pages.current_page || this.pages.current_page === 0) {\n      const current_page = this.pages.current_page += 1\n      this.pages = {...this.pages, current_page}\n    }\n\n    let url = ''\n    if (receiver_id) {\n      url = this.messagesUrl + receiver_id + '?page=' + 0 + '&limit=1'\n    } else {\n      url = this.messagesUrl + this.receiverId + '?page=' +this.pages.current_page\n    }\n\n    const headers = {...this.headers}\n\n    const res = await fetch(url, {\n      method: 'GET',\n      mode: 'same-origin',\n      cache: 'no-cache',\n      credentials: 'same-origin',\n      headers,\n      redirect: 'follow',\n      })\n\n\n    if (res.status === 200) {\n\n      return await res.json();\n\n    } else  {\n      console.error('An error occurred!')\n    }\n  }\n\n}\n\n\n\n;// CONCATENATED MODULE: ./src/chat_nv.js\n\n\n\nconst messages_url = flairChatData.messages_url\nconst new_message_url = flairChatData.new_msg_url\nconst currentId = parseInt(flairChatData.current_id)\nconst headers = flairChatData.headers\nconst pusher_configs = {\n    app_key: flairChatData.app_key,\n    cluster: flairChatData.cluster,\n    presence_url: flairChatData.presence_url,\n}\n\n// Initialize chat app\nnew Chat(messages_url, new_message_url, pusher_configs, currentId, headers);\n\n\n\n\n\n\n\n\n\n//# sourceURL=webpack://webpacked/./src/chat_nv.js_+_1_modules?")}},__webpack_module_cache__={};function __webpack_require__(n){var e=__webpack_module_cache__[n];if(void 0!==e)return e.exports;var t=__webpack_module_cache__[n]={exports:{}};return __webpack_modules__[n](t,t.exports,__webpack_require__),t.exports}__webpack_require__.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return __webpack_require__.d(e,{a:e}),e},__webpack_require__.d=function(n,e){for(var t in e)__webpack_require__.o(e,t)&&!__webpack_require__.o(n,t)&&Object.defineProperty(n,t,{enumerable:!0,get:e[t]})},__webpack_require__.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)};var __webpack_exports__=__webpack_require__(486)})();
  • flair-chat/trunk/readme.md

    r2778367 r2778375  
    4747= 1.0.0 =
    4848First version
     49
     50= 1.0.1 =
     51Fixed invalid date, error on to_uid just sent message.
Note: See TracChangeset for help on using the changeset viewer.