From 34ff5d33db654f9e86b1d96964c583221cbad233 Mon Sep 17 00:00:00 2001 From: poppabear8883 Date: Wed, 2 May 2018 23:08:26 -0400 Subject: [PATCH] (WIP) Chat v2.0 (pusher) This is a "Work In Progress" commit. Its not expected to work. --- app/Events/MessageSent.php | 5 +- app/Events/UserJoinedChat.php | 39 + app/Http/Controllers/API/ChatController.php | 3 + composer.json | 1 + composer.lock | 57 +- package-lock.json | 27 + package.json | 7 +- public/js/app.js | 5197 ++++++++++++++++- resources/assets/js/bootstrap.js | 18 +- .../assets/js/components/chat/Chatbox.vue | 11 +- routes/channels.php | 18 +- 11 files changed, 5249 insertions(+), 134 deletions(-) create mode 100644 app/Events/UserJoinedChat.php diff --git a/app/Events/MessageSent.php b/app/Events/MessageSent.php index 9ba4ab93f..48a3793b0 100644 --- a/app/Events/MessageSent.php +++ b/app/Events/MessageSent.php @@ -15,6 +15,7 @@ namespace App\Events; use App\Chatroom; use App\Message; use App\User; +use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Contracts\Broadcasting\ShouldBroadcast; @@ -61,10 +62,10 @@ class MessageSent implements ShouldBroadcast /** * Get the channels the event should broadcast on. * - * @return PrivateChannel|array + * @return Channel|array */ public function broadcastOn() { - return new PrivateChannel('chatroom.' . $this->chatroom->id); + return new Channel('chatroom.' . $this->chatroom->id); } } \ No newline at end of file diff --git a/app/Events/UserJoinedChat.php b/app/Events/UserJoinedChat.php new file mode 100644 index 000000000..2177c2740 --- /dev/null +++ b/app/Events/UserJoinedChat.php @@ -0,0 +1,39 @@ +chatroom = $chatroom; + } + + /** + * Get the channels the event should broadcast on. + * + * @return \Illuminate\Broadcasting\Channel|array + */ + public function broadcastOn() + { + return new Channel('chatroom.' . $this->chatroom->id); + } +} diff --git a/app/Http/Controllers/API/ChatController.php b/app/Http/Controllers/API/ChatController.php index fe8ad9bc1..62cd69339 100644 --- a/app/Http/Controllers/API/ChatController.php +++ b/app/Http/Controllers/API/ChatController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers\API; use App\Chatroom; +use App\Events\UserJoinedChat; use App\Http\Resources\ChatMessageResource; use App\Http\Resources\ChatRoomResource; use App\Http\Resources\UserResource; @@ -125,6 +126,8 @@ class ChatController extends Controller $user->save(); + UserJoinedChat::dispatch($room); + return response($user, 200); } } diff --git a/composer.json b/composer.json index 12c2ade60..84c855253 100755 --- a/composer.json +++ b/composer.json @@ -29,6 +29,7 @@ "moinax/tvdb": "1.*", "paragonie/constant_time_encoding": "^2.0", "predis/predis": "1.1.1", + "pusher/pusher-php-server": "~3.0", "rachidlaasri/laravel-installer": "^3.2", "spatie/laravel-backup": "^5.0", "spatie/laravel-cookie-consent": "^2.1.0", diff --git a/composer.lock b/composer.lock index 4098b4d08..c2b598966 100644 --- a/composer.lock +++ b/composer.lock @@ -1,10 +1,10 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "86e79875e2a2caaebe82669067f97c23", + "content-hash": "4d2dc61c3e87ae46df28e13992765453", "packages": [ { "name": "arcanedev/log-viewer", @@ -2492,6 +2492,59 @@ ], "time": "2018-04-18T12:32:50+00:00" }, + { + "name": "pusher/pusher-php-server", + "version": "v3.0.3", + "source": { + "type": "git", + "url": "https://github.com/pusher/pusher-http-php.git", + "reference": "e4f6980fa69699945873f0895de8c5a14e7244e7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pusher/pusher-http-php/zipball/e4f6980fa69699945873f0895de8c5a14e7244e7", + "reference": "e4f6980fa69699945873f0895de8c5a14e7244e7", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "php": "^5.4 || ^7.0", + "psr/log": "^1.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8 || ^5.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "Pusher\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Library for interacting with the Pusher REST API", + "keywords": [ + "events", + "messaging", + "php-pusher-server", + "publish", + "push", + "pusher", + "real time", + "real-time", + "realtime", + "rest", + "trigger" + ], + "time": "2018-04-26T09:54:45+00:00" + }, { "name": "rachidlaasri/laravel-installer", "version": "3.2.1", diff --git a/package-lock.json b/package-lock.json index 18550a6a2..01dc4c5fc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11397,6 +11397,27 @@ "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", "dev": true }, + "pusher-js": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/pusher-js/-/pusher-js-4.2.2.tgz", + "integrity": "sha512-EjFE+PAC6lG7Ap3fhU7c2NyVul6DghNlEbiJVkcTca182U3b7iYgiQY8sQu9FCl5YmnOZ2L95RVYT9JM+YX9jQ==", + "dev": true, + "requires": { + "faye-websocket": "0.9.4", + "xmlhttprequest": "1.8.0" + }, + "dependencies": { + "faye-websocket": { + "version": "0.9.4", + "resolved": "https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.9.4.tgz", + "integrity": "sha1-iFk0x57/sECVSeDAo4Ae0XpAza0=", + "dev": true, + "requires": { + "websocket-driver": "0.7.0" + } + } + } + }, "q": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", @@ -14464,6 +14485,12 @@ "ultron": "1.1.1" } }, + "xmlhttprequest": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/xmlhttprequest/-/xmlhttprequest-1.8.0.tgz", + "integrity": "sha1-Z/4HXFwk/vOfnWX197f+dRcZaPw=", + "dev": true + }, "xmlhttprequest-ssl": { "version": "1.5.5", "resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.5.tgz", diff --git a/package.json b/package.json index 48cdf5dc4..f18066de5 100755 --- a/package.json +++ b/package.json @@ -20,16 +20,17 @@ "jquery-textcomplete": "^1.8.4", "jquery.flot": "^0.8.3", "ladda": "^1.0.6", + "laravel-echo": "^1.1.3", "laravel-mix": "^2.0", "lodash": "^4.17.4", + "pusher-js": "^4.2.2", "raphael": "^2.2.7", "select2": "^4.0.6-rc.1", + "socket.io": "^2.1.0", "spin.js": "^3.1.0", "sweetalert2": "^7.18.0", "toastr": "^2.1.4", "vue": "^2.5.7", - "vue-countup-v2": "^1.0.3", - "socket.io": "^2.1.0", - "laravel-echo": "^1.1.3" + "vue-countup-v2": "^1.0.3" } } diff --git a/public/js/app.js b/public/js/app.js index a9eb9b4e3..ce0717806 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -13232,12 +13232,12 @@ module.exports = Cancel; /***/ (function(module, exports, __webpack_require__) { __webpack_require__(13); -__webpack_require__(73); -__webpack_require__(74); __webpack_require__(75); __webpack_require__(76); __webpack_require__(77); -module.exports = __webpack_require__(78); +__webpack_require__(78); +__webpack_require__(79); +module.exports = __webpack_require__(80); /***/ }), @@ -13252,7 +13252,7 @@ module.exports = __webpack_require__(78); __webpack_require__(14); -window.Vue = __webpack_require__(47); +window.Vue = __webpack_require__(49); /** * Next, we will create a fresh Vue application instance and attach it to @@ -13260,9 +13260,9 @@ window.Vue = __webpack_require__(47); * or customize the JavaScript scaffolding to fit your unique needs. */ -Vue.component('example', __webpack_require__(50)); -Vue.component('version', __webpack_require__(53)); -Vue.component('chatbox', __webpack_require__(56)); +Vue.component('example', __webpack_require__(52)); +Vue.component('version', __webpack_require__(55)); +Vue.component('chatbox', __webpack_require__(58)); var app = new Vue({ el: '#app' @@ -13270,8 +13270,12 @@ var app = new Vue({ /***/ }), /* 14 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, __webpack_exports__, __webpack_require__) { +"use strict"; +Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_laravel_echo__ = __webpack_require__(37); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_laravel_echo___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_laravel_echo__); window._ = __webpack_require__(15); /** @@ -13323,37 +13327,40 @@ if (token) { * allows your team to easily build robust real-time web applications. */ -// import Echo from 'laravel-echo'; -// -// window.Echo = new Echo({ -// broadcaster: 'socket.io', -// client: require('socket.io-client'), -// host: window.location.hostname + ':6001', -// }); + + +window.Pusher = __webpack_require__(38); + +window.Echo = new __WEBPACK_IMPORTED_MODULE_0_laravel_echo___default.a({ + broadcaster: 'pusher', + key: '3952ae7020e1a8237c6e', + cluster: 'eu', + encrypted: true +}); /** * UNIT3D */ -__webpack_require__(37); -__webpack_require__(38); +__webpack_require__(39); +__webpack_require__(40); /* * jQuery Extensions * * Note: Eventually we will end up 100% jQuery free with the conversion to VueJS */ -__webpack_require__(40); -__webpack_require__(41); - -// countUp JS from npm -window.CountUp = __webpack_require__(42); - -// wysibb editor +__webpack_require__(42); __webpack_require__(43); -window.Raphael = __webpack_require__(44); +// countUp JS from npm +window.CountUp = __webpack_require__(44); + +// wysibb editor +__webpack_require__(45); + +window.Raphael = __webpack_require__(46); window.swal = __webpack_require__(11); -window.toastr = __webpack_require__(45); +window.toastr = __webpack_require__(47); /***/ }), /* 15 */ @@ -33761,6 +33768,4992 @@ module.exports = function spread(callback) { /***/ }), /* 37 */ +/***/ (function(module, exports) { + +var asyncGenerator = function () { + function AwaitValue(value) { + this.value = value; + } + + function AsyncGenerator(gen) { + var front, back; + + function send(key, arg) { + return new Promise(function (resolve, reject) { + var request = { + key: key, + arg: arg, + resolve: resolve, + reject: reject, + next: null + }; + + if (back) { + back = back.next = request; + } else { + front = back = request; + resume(key, arg); + } + }); + } + + function resume(key, arg) { + try { + var result = gen[key](arg); + var value = result.value; + + if (value instanceof AwaitValue) { + Promise.resolve(value.value).then(function (arg) { + resume("next", arg); + }, function (arg) { + resume("throw", arg); + }); + } else { + settle(result.done ? "return" : "normal", result.value); + } + } catch (err) { + settle("throw", err); + } + } + + function settle(type, value) { + switch (type) { + case "return": + front.resolve({ + value: value, + done: true + }); + break; + + case "throw": + front.reject(value); + break; + + default: + front.resolve({ + value: value, + done: false + }); + break; + } + + front = front.next; + + if (front) { + resume(front.key, front.arg); + } else { + back = null; + } + } + + this._invoke = send; + + if (typeof gen.return !== "function") { + this.return = undefined; + } + } + + if (typeof Symbol === "function" && Symbol.asyncIterator) { + AsyncGenerator.prototype[Symbol.asyncIterator] = function () { + return this; + }; + } + + AsyncGenerator.prototype.next = function (arg) { + return this._invoke("next", arg); + }; + + AsyncGenerator.prototype.throw = function (arg) { + return this._invoke("throw", arg); + }; + + AsyncGenerator.prototype.return = function (arg) { + return this._invoke("return", arg); + }; + + return { + wrap: function (fn) { + return function () { + return new AsyncGenerator(fn.apply(this, arguments)); + }; + }, + await: function (value) { + return new AwaitValue(value); + } + }; +}(); + +var classCallCheck = function (instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } +}; + +var createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; +}(); + +var _extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + + return target; +}; + +var inherits = function (subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + enumerable: false, + writable: true, + configurable: true + } + }); + if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; +}; + +var possibleConstructorReturn = function (self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return call && (typeof call === "object" || typeof call === "function") ? call : self; +}; + +var Connector = function () { + function Connector(options) { + classCallCheck(this, Connector); + + this._defaultOptions = { + auth: { + headers: {} + }, + authEndpoint: '/broadcasting/auth', + broadcaster: 'pusher', + csrfToken: null, + host: null, + key: null, + namespace: 'App.Events' + }; + this.setOptions(options); + this.connect(); + } + + createClass(Connector, [{ + key: 'setOptions', + value: function setOptions(options) { + this.options = _extends(this._defaultOptions, options); + if (this.csrfToken()) { + this.options.auth.headers['X-CSRF-TOKEN'] = this.csrfToken(); + } + return options; + } + }, { + key: 'csrfToken', + value: function csrfToken() { + var selector = void 0; + if (typeof window !== 'undefined' && window['Laravel'] && window['Laravel'].csrfToken) { + return window['Laravel'].csrfToken; + } else if (this.options.csrfToken) { + return this.options.csrfToken; + } else if (typeof document !== 'undefined' && (selector = document.querySelector('meta[name="csrf-token"]'))) { + return selector.getAttribute('content'); + } + return null; + } + }]); + return Connector; +}(); + +var Channel = function () { + function Channel() { + classCallCheck(this, Channel); + } + + createClass(Channel, [{ + key: 'notification', + value: function notification(callback) { + return this.listen('.Illuminate\\Notifications\\Events\\BroadcastNotificationCreated', callback); + } + }, { + key: 'listenForWhisper', + value: function listenForWhisper(event, callback) { + return this.listen('.client-' + event, callback); + } + }]); + return Channel; +}(); + +var EventFormatter = function () { + function EventFormatter(namespace) { + classCallCheck(this, EventFormatter); + + this.setNamespace(namespace); + } + + createClass(EventFormatter, [{ + key: 'format', + value: function format(event) { + if (event.charAt(0) === '.' || event.charAt(0) === '\\') { + return event.substr(1); + } else if (this.namespace) { + event = this.namespace + '.' + event; + } + return event.replace(/\./g, '\\'); + } + }, { + key: 'setNamespace', + value: function setNamespace(value) { + this.namespace = value; + } + }]); + return EventFormatter; +}(); + +var PusherChannel = function (_Channel) { + inherits(PusherChannel, _Channel); + + function PusherChannel(pusher, name, options) { + classCallCheck(this, PusherChannel); + + var _this = possibleConstructorReturn(this, (PusherChannel.__proto__ || Object.getPrototypeOf(PusherChannel)).call(this)); + + _this.name = name; + _this.pusher = pusher; + _this.options = options; + _this.eventFormatter = new EventFormatter(_this.options.namespace); + _this.subscribe(); + return _this; + } + + createClass(PusherChannel, [{ + key: 'subscribe', + value: function subscribe() { + this.subscription = this.pusher.subscribe(this.name); + } + }, { + key: 'unsubscribe', + value: function unsubscribe() { + this.pusher.unsubscribe(this.name); + } + }, { + key: 'listen', + value: function listen(event, callback) { + this.on(this.eventFormatter.format(event), callback); + return this; + } + }, { + key: 'stopListening', + value: function stopListening(event) { + this.subscription.unbind(this.eventFormatter.format(event)); + return this; + } + }, { + key: 'on', + value: function on(event, callback) { + this.subscription.bind(event, callback); + return this; + } + }]); + return PusherChannel; +}(Channel); + +var PusherPrivateChannel = function (_PusherChannel) { + inherits(PusherPrivateChannel, _PusherChannel); + + function PusherPrivateChannel() { + classCallCheck(this, PusherPrivateChannel); + return possibleConstructorReturn(this, (PusherPrivateChannel.__proto__ || Object.getPrototypeOf(PusherPrivateChannel)).apply(this, arguments)); + } + + createClass(PusherPrivateChannel, [{ + key: 'whisper', + value: function whisper(eventName, data) { + this.pusher.channels.channels[this.name].trigger('client-' + eventName, data); + return this; + } + }]); + return PusherPrivateChannel; +}(PusherChannel); + +var PusherPresenceChannel = function (_PusherChannel) { + inherits(PusherPresenceChannel, _PusherChannel); + + function PusherPresenceChannel() { + classCallCheck(this, PusherPresenceChannel); + return possibleConstructorReturn(this, (PusherPresenceChannel.__proto__ || Object.getPrototypeOf(PusherPresenceChannel)).apply(this, arguments)); + } + + createClass(PusherPresenceChannel, [{ + key: 'here', + value: function here(callback) { + this.on('pusher:subscription_succeeded', function (data) { + callback(Object.keys(data.members).map(function (k) { + return data.members[k]; + })); + }); + return this; + } + }, { + key: 'joining', + value: function joining(callback) { + this.on('pusher:member_added', function (member) { + callback(member.info); + }); + return this; + } + }, { + key: 'leaving', + value: function leaving(callback) { + this.on('pusher:member_removed', function (member) { + callback(member.info); + }); + return this; + } + }, { + key: 'whisper', + value: function whisper(eventName, data) { + this.pusher.channels.channels[this.name].trigger('client-' + eventName, data); + return this; + } + }]); + return PusherPresenceChannel; +}(PusherChannel); + +var SocketIoChannel = function (_Channel) { + inherits(SocketIoChannel, _Channel); + + function SocketIoChannel(socket, name, options) { + classCallCheck(this, SocketIoChannel); + + var _this = possibleConstructorReturn(this, (SocketIoChannel.__proto__ || Object.getPrototypeOf(SocketIoChannel)).call(this)); + + _this.events = {}; + _this.name = name; + _this.socket = socket; + _this.options = options; + _this.eventFormatter = new EventFormatter(_this.options.namespace); + _this.subscribe(); + _this.configureReconnector(); + return _this; + } + + createClass(SocketIoChannel, [{ + key: 'subscribe', + value: function subscribe() { + this.socket.emit('subscribe', { + channel: this.name, + auth: this.options.auth || {} + }); + } + }, { + key: 'unsubscribe', + value: function unsubscribe() { + this.unbind(); + this.socket.emit('unsubscribe', { + channel: this.name, + auth: this.options.auth || {} + }); + } + }, { + key: 'listen', + value: function listen(event, callback) { + this.on(this.eventFormatter.format(event), callback); + return this; + } + }, { + key: 'on', + value: function on(event, callback) { + var _this2 = this; + + var listener = function listener(channel, data) { + if (_this2.name == channel) { + callback(data); + } + }; + this.socket.on(event, listener); + this.bind(event, listener); + } + }, { + key: 'configureReconnector', + value: function configureReconnector() { + var _this3 = this; + + var listener = function listener() { + _this3.subscribe(); + }; + this.socket.on('reconnect', listener); + this.bind('reconnect', listener); + } + }, { + key: 'bind', + value: function bind(event, callback) { + this.events[event] = this.events[event] || []; + this.events[event].push(callback); + } + }, { + key: 'unbind', + value: function unbind() { + var _this4 = this; + + Object.keys(this.events).forEach(function (event) { + _this4.events[event].forEach(function (callback) { + _this4.socket.removeListener(event, callback); + }); + delete _this4.events[event]; + }); + } + }]); + return SocketIoChannel; +}(Channel); + +var SocketIoPrivateChannel = function (_SocketIoChannel) { + inherits(SocketIoPrivateChannel, _SocketIoChannel); + + function SocketIoPrivateChannel() { + classCallCheck(this, SocketIoPrivateChannel); + return possibleConstructorReturn(this, (SocketIoPrivateChannel.__proto__ || Object.getPrototypeOf(SocketIoPrivateChannel)).apply(this, arguments)); + } + + createClass(SocketIoPrivateChannel, [{ + key: 'whisper', + value: function whisper(eventName, data) { + this.socket.emit('client event', { + channel: this.name, + event: 'client-' + eventName, + data: data + }); + return this; + } + }]); + return SocketIoPrivateChannel; +}(SocketIoChannel); + +var SocketIoPresenceChannel = function (_SocketIoPrivateChann) { + inherits(SocketIoPresenceChannel, _SocketIoPrivateChann); + + function SocketIoPresenceChannel() { + classCallCheck(this, SocketIoPresenceChannel); + return possibleConstructorReturn(this, (SocketIoPresenceChannel.__proto__ || Object.getPrototypeOf(SocketIoPresenceChannel)).apply(this, arguments)); + } + + createClass(SocketIoPresenceChannel, [{ + key: 'here', + value: function here(callback) { + this.on('presence:subscribed', function (members) { + callback(members.map(function (m) { + return m.user_info; + })); + }); + return this; + } + }, { + key: 'joining', + value: function joining(callback) { + this.on('presence:joining', function (member) { + return callback(member.user_info); + }); + return this; + } + }, { + key: 'leaving', + value: function leaving(callback) { + this.on('presence:leaving', function (member) { + return callback(member.user_info); + }); + return this; + } + }]); + return SocketIoPresenceChannel; +}(SocketIoPrivateChannel); + +var PusherConnector = function (_Connector) { + inherits(PusherConnector, _Connector); + + function PusherConnector() { + var _ref; + + classCallCheck(this, PusherConnector); + + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var _this = possibleConstructorReturn(this, (_ref = PusherConnector.__proto__ || Object.getPrototypeOf(PusherConnector)).call.apply(_ref, [this].concat(args))); + + _this.channels = {}; + return _this; + } + + createClass(PusherConnector, [{ + key: 'connect', + value: function connect() { + this.pusher = new Pusher(this.options.key, this.options); + } + }, { + key: 'listen', + value: function listen(name, event, callback) { + return this.channel(name).listen(event, callback); + } + }, { + key: 'channel', + value: function channel(name) { + if (!this.channels[name]) { + this.channels[name] = new PusherChannel(this.pusher, name, this.options); + } + return this.channels[name]; + } + }, { + key: 'privateChannel', + value: function privateChannel(name) { + if (!this.channels['private-' + name]) { + this.channels['private-' + name] = new PusherPrivateChannel(this.pusher, 'private-' + name, this.options); + } + return this.channels['private-' + name]; + } + }, { + key: 'presenceChannel', + value: function presenceChannel(name) { + if (!this.channels['presence-' + name]) { + this.channels['presence-' + name] = new PusherPresenceChannel(this.pusher, 'presence-' + name, this.options); + } + return this.channels['presence-' + name]; + } + }, { + key: 'leave', + value: function leave(name) { + var _this2 = this; + + var channels = [name, 'private-' + name, 'presence-' + name]; + channels.forEach(function (name, index) { + if (_this2.channels[name]) { + _this2.channels[name].unsubscribe(); + delete _this2.channels[name]; + } + }); + } + }, { + key: 'socketId', + value: function socketId() { + return this.pusher.connection.socket_id; + } + }, { + key: 'disconnect', + value: function disconnect() { + this.pusher.disconnect(); + } + }]); + return PusherConnector; +}(Connector); + +var SocketIoConnector = function (_Connector) { + inherits(SocketIoConnector, _Connector); + + function SocketIoConnector() { + var _ref; + + classCallCheck(this, SocketIoConnector); + + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var _this = possibleConstructorReturn(this, (_ref = SocketIoConnector.__proto__ || Object.getPrototypeOf(SocketIoConnector)).call.apply(_ref, [this].concat(args))); + + _this.channels = {}; + return _this; + } + + createClass(SocketIoConnector, [{ + key: 'connect', + value: function connect() { + var io = this.getSocketIO(); + this.socket = io(this.options.host, this.options); + return this.socket; + } + }, { + key: 'getSocketIO', + value: function getSocketIO() { + if (typeof io !== 'undefined') { + return io; + } + if (this.options.client !== 'undefined') { + return this.options.client; + } + throw new Error('Socket.io client not found. Should be globally available or passed via options.client'); + } + }, { + key: 'listen', + value: function listen(name, event, callback) { + return this.channel(name).listen(event, callback); + } + }, { + key: 'channel', + value: function channel(name) { + if (!this.channels[name]) { + this.channels[name] = new SocketIoChannel(this.socket, name, this.options); + } + return this.channels[name]; + } + }, { + key: 'privateChannel', + value: function privateChannel(name) { + if (!this.channels['private-' + name]) { + this.channels['private-' + name] = new SocketIoPrivateChannel(this.socket, 'private-' + name, this.options); + } + return this.channels['private-' + name]; + } + }, { + key: 'presenceChannel', + value: function presenceChannel(name) { + if (!this.channels['presence-' + name]) { + this.channels['presence-' + name] = new SocketIoPresenceChannel(this.socket, 'presence-' + name, this.options); + } + return this.channels['presence-' + name]; + } + }, { + key: 'leave', + value: function leave(name) { + var _this2 = this; + + var channels = [name, 'private-' + name, 'presence-' + name]; + channels.forEach(function (name) { + if (_this2.channels[name]) { + _this2.channels[name].unsubscribe(); + delete _this2.channels[name]; + } + }); + } + }, { + key: 'socketId', + value: function socketId() { + return this.socket.id; + } + }, { + key: 'disconnect', + value: function disconnect() { + this.socket.disconnect(); + } + }]); + return SocketIoConnector; +}(Connector); + +var Echo = function () { + function Echo(options) { + classCallCheck(this, Echo); + + this.options = options; + if (typeof Vue === 'function' && Vue.http) { + this.registerVueRequestInterceptor(); + } + if (typeof axios === 'function') { + this.registerAxiosRequestInterceptor(); + } + if (typeof jQuery === 'function') { + this.registerjQueryAjaxSetup(); + } + if (this.options.broadcaster == 'pusher') { + this.connector = new PusherConnector(this.options); + } else if (this.options.broadcaster == 'socket.io') { + this.connector = new SocketIoConnector(this.options); + } + } + + createClass(Echo, [{ + key: 'registerVueRequestInterceptor', + value: function registerVueRequestInterceptor() { + var _this = this; + + Vue.http.interceptors.push(function (request, next) { + if (_this.socketId()) { + request.headers.set('X-Socket-ID', _this.socketId()); + } + next(); + }); + } + }, { + key: 'registerAxiosRequestInterceptor', + value: function registerAxiosRequestInterceptor() { + var _this2 = this; + + axios.interceptors.request.use(function (config) { + if (_this2.socketId()) { + config.headers['X-Socket-Id'] = _this2.socketId(); + } + return config; + }); + } + }, { + key: 'registerjQueryAjaxSetup', + value: function registerjQueryAjaxSetup() { + var _this3 = this; + + if (typeof jQuery.ajax != 'undefined') { + jQuery.ajaxSetup({ + beforeSend: function beforeSend(xhr) { + if (_this3.socketId()) { + xhr.setRequestHeader('X-Socket-Id', _this3.socketId()); + } + } + }); + } + } + }, { + key: 'listen', + value: function listen(channel, event, callback) { + return this.connector.listen(channel, event, callback); + } + }, { + key: 'channel', + value: function channel(_channel) { + return this.connector.channel(_channel); + } + }, { + key: 'private', + value: function _private(channel) { + return this.connector.privateChannel(channel); + } + }, { + key: 'join', + value: function join(channel) { + return this.connector.presenceChannel(channel); + } + }, { + key: 'leave', + value: function leave(channel) { + this.connector.leave(channel); + } + }, { + key: 'socketId', + value: function socketId() { + return this.connector.socketId(); + } + }, { + key: 'disconnect', + value: function disconnect() { + this.connector.disconnect(); + } + }]); + return Echo; +}(); + +module.exports = Echo; + +/***/ }), +/* 38 */ +/***/ (function(module, exports, __webpack_require__) { + +/*! + * Pusher JavaScript Library v4.2.2 + * https://pusher.com/ + * + * Copyright 2017, Pusher + * Released under the MIT licence. + */ + +(function webpackUniversalModuleDefinition(root, factory) { + if(true) + module.exports = factory(); + else if(typeof define === 'function' && define.amd) + define([], factory); + else if(typeof exports === 'object') + exports["Pusher"] = factory(); + else + root["Pusher"] = factory(); +})(this, function() { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; + +/******/ // The require function +/******/ function __webpack_require__(moduleId) { + +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].exports; + +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.loaded = true; + +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } + + +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; + +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; + +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; + +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var pusher_1 = __webpack_require__(1); + module.exports = pusher_1["default"]; + + +/***/ }), +/* 1 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var runtime_1 = __webpack_require__(2); + var Collections = __webpack_require__(9); + var dispatcher_1 = __webpack_require__(24); + var timeline_1 = __webpack_require__(39); + var level_1 = __webpack_require__(40); + var StrategyBuilder = __webpack_require__(41); + var timers_1 = __webpack_require__(12); + var defaults_1 = __webpack_require__(5); + var DefaultConfig = __webpack_require__(63); + var logger_1 = __webpack_require__(8); + var factory_1 = __webpack_require__(43); + var url_store_1 = __webpack_require__(14); + var Pusher = (function () { + function Pusher(app_key, options) { + var _this = this; + checkAppKey(app_key); + options = options || {}; + if (!options.cluster && !(options.wsHost || options.httpHost)) { + var suffix = url_store_1["default"].buildLogSuffix("javascriptQuickStart"); + logger_1["default"].warn("You should always specify a cluster when connecting. " + suffix); + } + this.key = app_key; + this.config = Collections.extend(DefaultConfig.getGlobalConfig(), options.cluster ? DefaultConfig.getClusterConfig(options.cluster) : {}, options); + this.channels = factory_1["default"].createChannels(); + this.global_emitter = new dispatcher_1["default"](); + this.sessionID = Math.floor(Math.random() * 1000000000); + this.timeline = new timeline_1["default"](this.key, this.sessionID, { + cluster: this.config.cluster, + features: Pusher.getClientFeatures(), + params: this.config.timelineParams || {}, + limit: 50, + level: level_1["default"].INFO, + version: defaults_1["default"].VERSION + }); + if (!this.config.disableStats) { + this.timelineSender = factory_1["default"].createTimelineSender(this.timeline, { + host: this.config.statsHost, + path: "/timeline/v2/" + runtime_1["default"].TimelineTransport.name + }); + } + var getStrategy = function (options) { + var config = Collections.extend({}, _this.config, options); + return StrategyBuilder.build(runtime_1["default"].getDefaultStrategy(config), config); + }; + this.connection = factory_1["default"].createConnectionManager(this.key, Collections.extend({ getStrategy: getStrategy, + timeline: this.timeline, + activityTimeout: this.config.activity_timeout, + pongTimeout: this.config.pong_timeout, + unavailableTimeout: this.config.unavailable_timeout + }, this.config, { encrypted: this.isEncrypted() })); + this.connection.bind('connected', function () { + _this.subscribeAll(); + if (_this.timelineSender) { + _this.timelineSender.send(_this.connection.isEncrypted()); + } + }); + this.connection.bind('message', function (params) { + var internal = (params.event.indexOf('pusher_internal:') === 0); + if (params.channel) { + var channel = _this.channel(params.channel); + if (channel) { + channel.handleEvent(params.event, params.data); + } + } + if (!internal) { + _this.global_emitter.emit(params.event, params.data); + } + }); + this.connection.bind('connecting', function () { + _this.channels.disconnect(); + }); + this.connection.bind('disconnected', function () { + _this.channels.disconnect(); + }); + this.connection.bind('error', function (err) { + logger_1["default"].warn('Error', err); + }); + Pusher.instances.push(this); + this.timeline.info({ instances: Pusher.instances.length }); + if (Pusher.isReady) { + this.connect(); + } + } + Pusher.ready = function () { + Pusher.isReady = true; + for (var i = 0, l = Pusher.instances.length; i < l; i++) { + Pusher.instances[i].connect(); + } + }; + Pusher.log = function (message) { + if (Pusher.logToConsole && (window).console && (window).console.log) { + (window).console.log(message); + } + }; + Pusher.getClientFeatures = function () { + return Collections.keys(Collections.filterObject({ "ws": runtime_1["default"].Transports.ws }, function (t) { return t.isSupported({}); })); + }; + Pusher.prototype.channel = function (name) { + return this.channels.find(name); + }; + Pusher.prototype.allChannels = function () { + return this.channels.all(); + }; + Pusher.prototype.connect = function () { + this.connection.connect(); + if (this.timelineSender) { + if (!this.timelineSenderTimer) { + var encrypted = this.connection.isEncrypted(); + var timelineSender = this.timelineSender; + this.timelineSenderTimer = new timers_1.PeriodicTimer(60000, function () { + timelineSender.send(encrypted); + }); + } + } + }; + Pusher.prototype.disconnect = function () { + this.connection.disconnect(); + if (this.timelineSenderTimer) { + this.timelineSenderTimer.ensureAborted(); + this.timelineSenderTimer = null; + } + }; + Pusher.prototype.bind = function (event_name, callback, context) { + this.global_emitter.bind(event_name, callback, context); + return this; + }; + Pusher.prototype.unbind = function (event_name, callback, context) { + this.global_emitter.unbind(event_name, callback, context); + return this; + }; + Pusher.prototype.bind_global = function (callback) { + this.global_emitter.bind_global(callback); + return this; + }; + Pusher.prototype.unbind_global = function (callback) { + this.global_emitter.unbind_global(callback); + return this; + }; + Pusher.prototype.unbind_all = function (callback) { + this.global_emitter.unbind_all(); + return this; + }; + Pusher.prototype.subscribeAll = function () { + var channelName; + for (channelName in this.channels.channels) { + if (this.channels.channels.hasOwnProperty(channelName)) { + this.subscribe(channelName); + } + } + }; + Pusher.prototype.subscribe = function (channel_name) { + var channel = this.channels.add(channel_name, this); + if (channel.subscriptionPending && channel.subscriptionCancelled) { + channel.reinstateSubscription(); + } + else if (!channel.subscriptionPending && this.connection.state === "connected") { + channel.subscribe(); + } + return channel; + }; + Pusher.prototype.unsubscribe = function (channel_name) { + var channel = this.channels.find(channel_name); + if (channel && channel.subscriptionPending) { + channel.cancelSubscription(); + } + else { + channel = this.channels.remove(channel_name); + if (channel && this.connection.state === "connected") { + channel.unsubscribe(); + } + } + }; + Pusher.prototype.send_event = function (event_name, data, channel) { + return this.connection.send_event(event_name, data, channel); + }; + Pusher.prototype.isEncrypted = function () { + if (runtime_1["default"].getProtocol() === "https:") { + return true; + } + else { + return Boolean(this.config.encrypted); + } + }; + Pusher.instances = []; + Pusher.isReady = false; + Pusher.logToConsole = false; + Pusher.Runtime = runtime_1["default"]; + Pusher.ScriptReceivers = runtime_1["default"].ScriptReceivers; + Pusher.DependenciesReceivers = runtime_1["default"].DependenciesReceivers; + Pusher.auth_callbacks = runtime_1["default"].auth_callbacks; + return Pusher; + }()); + exports.__esModule = true; + exports["default"] = Pusher; + function checkAppKey(key) { + if (key === null || key === undefined) { + throw "You must pass your app key when you instantiate Pusher."; + } + } + runtime_1["default"].setup(Pusher); + + +/***/ }), +/* 2 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var dependencies_1 = __webpack_require__(3); + var xhr_auth_1 = __webpack_require__(7); + var jsonp_auth_1 = __webpack_require__(15); + var script_request_1 = __webpack_require__(16); + var jsonp_request_1 = __webpack_require__(17); + var script_receiver_factory_1 = __webpack_require__(4); + var jsonp_timeline_1 = __webpack_require__(18); + var transports_1 = __webpack_require__(19); + var net_info_1 = __webpack_require__(26); + var default_strategy_1 = __webpack_require__(27); + var transport_connection_initializer_1 = __webpack_require__(28); + var http_1 = __webpack_require__(29); + var Runtime = { + nextAuthCallbackID: 1, + auth_callbacks: {}, + ScriptReceivers: script_receiver_factory_1.ScriptReceivers, + DependenciesReceivers: dependencies_1.DependenciesReceivers, + getDefaultStrategy: default_strategy_1["default"], + Transports: transports_1["default"], + transportConnectionInitializer: transport_connection_initializer_1["default"], + HTTPFactory: http_1["default"], + TimelineTransport: jsonp_timeline_1["default"], + getXHRAPI: function () { + return window.XMLHttpRequest; + }, + getWebSocketAPI: function () { + return window.WebSocket || window.MozWebSocket; + }, + setup: function (PusherClass) { + var _this = this; + window.Pusher = PusherClass; + var initializeOnDocumentBody = function () { + _this.onDocumentBody(PusherClass.ready); + }; + if (!window.JSON) { + dependencies_1.Dependencies.load("json2", {}, initializeOnDocumentBody); + } + else { + initializeOnDocumentBody(); + } + }, + getDocument: function () { + return document; + }, + getProtocol: function () { + return this.getDocument().location.protocol; + }, + getAuthorizers: function () { + return { ajax: xhr_auth_1["default"], jsonp: jsonp_auth_1["default"] }; + }, + onDocumentBody: function (callback) { + var _this = this; + if (document.body) { + callback(); + } + else { + setTimeout(function () { + _this.onDocumentBody(callback); + }, 0); + } + }, + createJSONPRequest: function (url, data) { + return new jsonp_request_1["default"](url, data); + }, + createScriptRequest: function (src) { + return new script_request_1["default"](src); + }, + getLocalStorage: function () { + try { + return window.localStorage; + } + catch (e) { + return undefined; + } + }, + createXHR: function () { + if (this.getXHRAPI()) { + return this.createXMLHttpRequest(); + } + else { + return this.createMicrosoftXHR(); + } + }, + createXMLHttpRequest: function () { + var Constructor = this.getXHRAPI(); + return new Constructor(); + }, + createMicrosoftXHR: function () { + return new ActiveXObject("Microsoft.XMLHTTP"); + }, + getNetwork: function () { + return net_info_1.Network; + }, + createWebSocket: function (url) { + var Constructor = this.getWebSocketAPI(); + return new Constructor(url); + }, + createSocketRequest: function (method, url) { + if (this.isXHRSupported()) { + return this.HTTPFactory.createXHR(method, url); + } + else if (this.isXDRSupported(url.indexOf("https:") === 0)) { + return this.HTTPFactory.createXDR(method, url); + } + else { + throw "Cross-origin HTTP requests are not supported"; + } + }, + isXHRSupported: function () { + var Constructor = this.getXHRAPI(); + return Boolean(Constructor) && (new Constructor()).withCredentials !== undefined; + }, + isXDRSupported: function (encrypted) { + var protocol = encrypted ? "https:" : "http:"; + var documentProtocol = this.getProtocol(); + return Boolean((window['XDomainRequest'])) && documentProtocol === protocol; + }, + addUnloadListener: function (listener) { + if (window.addEventListener !== undefined) { + window.addEventListener("unload", listener, false); + } + else if (window.attachEvent !== undefined) { + window.attachEvent("onunload", listener); + } + }, + removeUnloadListener: function (listener) { + if (window.addEventListener !== undefined) { + window.removeEventListener("unload", listener, false); + } + else if (window.detachEvent !== undefined) { + window.detachEvent("onunload", listener); + } + } + }; + exports.__esModule = true; + exports["default"] = Runtime; + + +/***/ }), +/* 3 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var script_receiver_factory_1 = __webpack_require__(4); + var defaults_1 = __webpack_require__(5); + var dependency_loader_1 = __webpack_require__(6); + exports.DependenciesReceivers = new script_receiver_factory_1.ScriptReceiverFactory("_pusher_dependencies", "Pusher.DependenciesReceivers"); + exports.Dependencies = new dependency_loader_1["default"]({ + cdn_http: defaults_1["default"].cdn_http, + cdn_https: defaults_1["default"].cdn_https, + version: defaults_1["default"].VERSION, + suffix: defaults_1["default"].dependency_suffix, + receivers: exports.DependenciesReceivers + }); + + +/***/ }), +/* 4 */ +/***/ (function(module, exports) { + + "use strict"; + var ScriptReceiverFactory = (function () { + function ScriptReceiverFactory(prefix, name) { + this.lastId = 0; + this.prefix = prefix; + this.name = name; + } + ScriptReceiverFactory.prototype.create = function (callback) { + this.lastId++; + var number = this.lastId; + var id = this.prefix + number; + var name = this.name + "[" + number + "]"; + var called = false; + var callbackWrapper = function () { + if (!called) { + callback.apply(null, arguments); + called = true; + } + }; + this[number] = callbackWrapper; + return { number: number, id: id, name: name, callback: callbackWrapper }; + }; + ScriptReceiverFactory.prototype.remove = function (receiver) { + delete this[receiver.number]; + }; + return ScriptReceiverFactory; + }()); + exports.ScriptReceiverFactory = ScriptReceiverFactory; + exports.ScriptReceivers = new ScriptReceiverFactory("_pusher_script_", "Pusher.ScriptReceivers"); + + +/***/ }), +/* 5 */ +/***/ (function(module, exports) { + + "use strict"; + var Defaults = { + VERSION: "4.2.2", + PROTOCOL: 7, + host: 'ws.pusherapp.com', + ws_port: 80, + wss_port: 443, + ws_path: '', + sockjs_host: 'sockjs.pusher.com', + sockjs_http_port: 80, + sockjs_https_port: 443, + sockjs_path: "/pusher", + stats_host: 'stats.pusher.com', + channel_auth_endpoint: '/pusher/auth', + channel_auth_transport: 'ajax', + activity_timeout: 120000, + pong_timeout: 30000, + unavailable_timeout: 10000, + cdn_http: 'http://js.pusher.com', + cdn_https: 'https://js.pusher.com', + dependency_suffix: '' + }; + exports.__esModule = true; + exports["default"] = Defaults; + + +/***/ }), +/* 6 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var script_receiver_factory_1 = __webpack_require__(4); + var runtime_1 = __webpack_require__(2); + var DependencyLoader = (function () { + function DependencyLoader(options) { + this.options = options; + this.receivers = options.receivers || script_receiver_factory_1.ScriptReceivers; + this.loading = {}; + } + DependencyLoader.prototype.load = function (name, options, callback) { + var self = this; + if (self.loading[name] && self.loading[name].length > 0) { + self.loading[name].push(callback); + } + else { + self.loading[name] = [callback]; + var request = runtime_1["default"].createScriptRequest(self.getPath(name, options)); + var receiver = self.receivers.create(function (error) { + self.receivers.remove(receiver); + if (self.loading[name]) { + var callbacks = self.loading[name]; + delete self.loading[name]; + var successCallback = function (wasSuccessful) { + if (!wasSuccessful) { + request.cleanup(); + } + }; + for (var i = 0; i < callbacks.length; i++) { + callbacks[i](error, successCallback); + } + } + }); + request.send(receiver); + } + }; + DependencyLoader.prototype.getRoot = function (options) { + var cdn; + var protocol = runtime_1["default"].getDocument().location.protocol; + if ((options && options.encrypted) || protocol === "https:") { + cdn = this.options.cdn_https; + } + else { + cdn = this.options.cdn_http; + } + return cdn.replace(/\/*$/, "") + "/" + this.options.version; + }; + DependencyLoader.prototype.getPath = function (name, options) { + return this.getRoot(options) + '/' + name + this.options.suffix + '.js'; + }; + ; + return DependencyLoader; + }()); + exports.__esModule = true; + exports["default"] = DependencyLoader; + + +/***/ }), +/* 7 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var logger_1 = __webpack_require__(8); + var runtime_1 = __webpack_require__(2); + var url_store_1 = __webpack_require__(14); + var ajax = function (context, socketId, callback) { + var self = this, xhr; + xhr = runtime_1["default"].createXHR(); + xhr.open("POST", self.options.authEndpoint, true); + xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + for (var headerName in this.authOptions.headers) { + xhr.setRequestHeader(headerName, this.authOptions.headers[headerName]); + } + xhr.onreadystatechange = function () { + if (xhr.readyState === 4) { + if (xhr.status === 200) { + var data, parsed = false; + try { + data = JSON.parse(xhr.responseText); + parsed = true; + } + catch (e) { + callback(true, 'JSON returned from webapp was invalid, yet status code was 200. Data was: ' + xhr.responseText); + } + if (parsed) { + callback(false, data); + } + } + else { + var suffix = url_store_1["default"].buildLogSuffix("authenticationEndpoint"); + logger_1["default"].warn(("Couldn't retrieve authentication info. " + xhr.status) + + ("Clients must be authenticated to join private or presence channels. " + suffix)); + callback(true, xhr.status); + } + } + }; + xhr.send(this.composeQuery(socketId)); + return xhr; + }; + exports.__esModule = true; + exports["default"] = ajax; + + +/***/ }), +/* 8 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var collections_1 = __webpack_require__(9); + var pusher_1 = __webpack_require__(1); + var Logger = { + debug: function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i - 0] = arguments[_i]; + } + if (!pusher_1["default"].log) { + return; + } + pusher_1["default"].log(collections_1.stringify.apply(this, arguments)); + }, + warn: function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i - 0] = arguments[_i]; + } + var message = collections_1.stringify.apply(this, arguments); + if (pusher_1["default"].log) { + pusher_1["default"].log(message); + } + else if ((window).console) { + if ((window).console.warn) { + (window).console.warn(message); + } + else if ((window).console.log) { + (window).console.log(message); + } + } + } + }; + exports.__esModule = true; + exports["default"] = Logger; + + +/***/ }), +/* 9 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var base64_1 = __webpack_require__(10); + var util_1 = __webpack_require__(11); + function extend(target) { + var sources = []; + for (var _i = 1; _i < arguments.length; _i++) { + sources[_i - 1] = arguments[_i]; + } + for (var i = 0; i < sources.length; i++) { + var extensions = sources[i]; + for (var property in extensions) { + if (extensions[property] && extensions[property].constructor && + extensions[property].constructor === Object) { + target[property] = extend(target[property] || {}, extensions[property]); + } + else { + target[property] = extensions[property]; + } + } + } + return target; + } + exports.extend = extend; + function stringify() { + var m = ["Pusher"]; + for (var i = 0; i < arguments.length; i++) { + if (typeof arguments[i] === "string") { + m.push(arguments[i]); + } + else { + m.push(safeJSONStringify(arguments[i])); + } + } + return m.join(" : "); + } + exports.stringify = stringify; + function arrayIndexOf(array, item) { + var nativeIndexOf = Array.prototype.indexOf; + if (array === null) { + return -1; + } + if (nativeIndexOf && array.indexOf === nativeIndexOf) { + return array.indexOf(item); + } + for (var i = 0, l = array.length; i < l; i++) { + if (array[i] === item) { + return i; + } + } + return -1; + } + exports.arrayIndexOf = arrayIndexOf; + function objectApply(object, f) { + for (var key in object) { + if (Object.prototype.hasOwnProperty.call(object, key)) { + f(object[key], key, object); + } + } + } + exports.objectApply = objectApply; + function keys(object) { + var keys = []; + objectApply(object, function (_, key) { + keys.push(key); + }); + return keys; + } + exports.keys = keys; + function values(object) { + var values = []; + objectApply(object, function (value) { + values.push(value); + }); + return values; + } + exports.values = values; + function apply(array, f, context) { + for (var i = 0; i < array.length; i++) { + f.call(context || (window), array[i], i, array); + } + } + exports.apply = apply; + function map(array, f) { + var result = []; + for (var i = 0; i < array.length; i++) { + result.push(f(array[i], i, array, result)); + } + return result; + } + exports.map = map; + function mapObject(object, f) { + var result = {}; + objectApply(object, function (value, key) { + result[key] = f(value); + }); + return result; + } + exports.mapObject = mapObject; + function filter(array, test) { + test = test || function (value) { return !!value; }; + var result = []; + for (var i = 0; i < array.length; i++) { + if (test(array[i], i, array, result)) { + result.push(array[i]); + } + } + return result; + } + exports.filter = filter; + function filterObject(object, test) { + var result = {}; + objectApply(object, function (value, key) { + if ((test && test(value, key, object, result)) || Boolean(value)) { + result[key] = value; + } + }); + return result; + } + exports.filterObject = filterObject; + function flatten(object) { + var result = []; + objectApply(object, function (value, key) { + result.push([key, value]); + }); + return result; + } + exports.flatten = flatten; + function any(array, test) { + for (var i = 0; i < array.length; i++) { + if (test(array[i], i, array)) { + return true; + } + } + return false; + } + exports.any = any; + function all(array, test) { + for (var i = 0; i < array.length; i++) { + if (!test(array[i], i, array)) { + return false; + } + } + return true; + } + exports.all = all; + function encodeParamsObject(data) { + return mapObject(data, function (value) { + if (typeof value === "object") { + value = safeJSONStringify(value); + } + return encodeURIComponent(base64_1["default"](value.toString())); + }); + } + exports.encodeParamsObject = encodeParamsObject; + function buildQueryString(data) { + var params = filterObject(data, function (value) { + return value !== undefined; + }); + var query = map(flatten(encodeParamsObject(params)), util_1["default"].method("join", "=")).join("&"); + return query; + } + exports.buildQueryString = buildQueryString; + function decycleObject(object) { + var objects = [], paths = []; + return (function derez(value, path) { + var i, name, nu; + switch (typeof value) { + case 'object': + if (!value) { + return null; + } + for (i = 0; i < objects.length; i += 1) { + if (objects[i] === value) { + return { $ref: paths[i] }; + } + } + objects.push(value); + paths.push(path); + if (Object.prototype.toString.apply(value) === '[object Array]') { + nu = []; + for (i = 0; i < value.length; i += 1) { + nu[i] = derez(value[i], path + '[' + i + ']'); + } + } + else { + nu = {}; + for (name in value) { + if (Object.prototype.hasOwnProperty.call(value, name)) { + nu[name] = derez(value[name], path + '[' + JSON.stringify(name) + ']'); + } + } + } + return nu; + case 'number': + case 'string': + case 'boolean': + return value; + } + }(object, '$')); + } + exports.decycleObject = decycleObject; + function safeJSONStringify(source) { + try { + return JSON.stringify(source); + } + catch (e) { + return JSON.stringify(decycleObject(source)); + } + } + exports.safeJSONStringify = safeJSONStringify; + + +/***/ }), +/* 10 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + function encode(s) { + return btoa(utob(s)); + } + exports.__esModule = true; + exports["default"] = encode; + var fromCharCode = String.fromCharCode; + var b64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; + var b64tab = {}; + for (var i = 0, l = b64chars.length; i < l; i++) { + b64tab[b64chars.charAt(i)] = i; + } + var cb_utob = function (c) { + var cc = c.charCodeAt(0); + return cc < 0x80 ? c + : cc < 0x800 ? fromCharCode(0xc0 | (cc >>> 6)) + + fromCharCode(0x80 | (cc & 0x3f)) + : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) + + fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) + + fromCharCode(0x80 | (cc & 0x3f)); + }; + var utob = function (u) { + return u.replace(/[^\x00-\x7F]/g, cb_utob); + }; + var cb_encode = function (ccc) { + var padlen = [0, 2, 1][ccc.length % 3]; + var ord = ccc.charCodeAt(0) << 16 + | ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) + | ((ccc.length > 2 ? ccc.charCodeAt(2) : 0)); + var chars = [ + b64chars.charAt(ord >>> 18), + b64chars.charAt((ord >>> 12) & 63), + padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63), + padlen >= 1 ? '=' : b64chars.charAt(ord & 63) + ]; + return chars.join(''); + }; + var btoa = (window).btoa || function (b) { + return b.replace(/[\s\S]{1,3}/g, cb_encode); + }; + + +/***/ }), +/* 11 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var timers_1 = __webpack_require__(12); + var Util = { + now: function () { + if (Date.now) { + return Date.now(); + } + else { + return new Date().valueOf(); + } + }, + defer: function (callback) { + return new timers_1.OneOffTimer(0, callback); + }, + method: function (name) { + var args = []; + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i]; + } + var boundArguments = Array.prototype.slice.call(arguments, 1); + return function (object) { + return object[name].apply(object, boundArguments.concat(arguments)); + }; + } + }; + exports.__esModule = true; + exports["default"] = Util; + + +/***/ }), +/* 12 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + var abstract_timer_1 = __webpack_require__(13); + function clearTimeout(timer) { + (window).clearTimeout(timer); + } + function clearInterval(timer) { + (window).clearInterval(timer); + } + var OneOffTimer = (function (_super) { + __extends(OneOffTimer, _super); + function OneOffTimer(delay, callback) { + _super.call(this, setTimeout, clearTimeout, delay, function (timer) { + callback(); + return null; + }); + } + return OneOffTimer; + }(abstract_timer_1["default"])); + exports.OneOffTimer = OneOffTimer; + var PeriodicTimer = (function (_super) { + __extends(PeriodicTimer, _super); + function PeriodicTimer(delay, callback) { + _super.call(this, setInterval, clearInterval, delay, function (timer) { + callback(); + return timer; + }); + } + return PeriodicTimer; + }(abstract_timer_1["default"])); + exports.PeriodicTimer = PeriodicTimer; + + +/***/ }), +/* 13 */ +/***/ (function(module, exports) { + + "use strict"; + var Timer = (function () { + function Timer(set, clear, delay, callback) { + var _this = this; + this.clear = clear; + this.timer = set(function () { + if (_this.timer) { + _this.timer = callback(_this.timer); + } + }, delay); + } + Timer.prototype.isRunning = function () { + return this.timer !== null; + }; + Timer.prototype.ensureAborted = function () { + if (this.timer) { + this.clear(this.timer); + this.timer = null; + } + }; + return Timer; + }()); + exports.__esModule = true; + exports["default"] = Timer; + + +/***/ }), +/* 14 */ +/***/ (function(module, exports) { + + "use strict"; + var urlStore = { + baseUrl: "https://pusher.com", + urls: { + authenticationEndpoint: { + path: "/docs/authenticating_users" + }, + javascriptQuickStart: { + path: "/docs/javascript_quick_start" + } + } + }; + var buildLogSuffix = function (key) { + var urlPrefix = "See:"; + var urlObj = urlStore.urls[key]; + if (!urlObj) + return ""; + var url; + if (urlObj.fullUrl) { + url = urlObj.fullUrl; + } + else if (urlObj.path) { + url = urlStore.baseUrl + urlObj.path; + } + if (!url) + return ""; + return urlPrefix + " " + url; + }; + exports.__esModule = true; + exports["default"] = { buildLogSuffix: buildLogSuffix }; + + +/***/ }), +/* 15 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var logger_1 = __webpack_require__(8); + var jsonp = function (context, socketId, callback) { + if (this.authOptions.headers !== undefined) { + logger_1["default"].warn("Warn", "To send headers with the auth request, you must use AJAX, rather than JSONP."); + } + var callbackName = context.nextAuthCallbackID.toString(); + context.nextAuthCallbackID++; + var document = context.getDocument(); + var script = document.createElement("script"); + context.auth_callbacks[callbackName] = function (data) { + callback(false, data); + }; + var callback_name = "Pusher.auth_callbacks['" + callbackName + "']"; + script.src = this.options.authEndpoint + + '?callback=' + + encodeURIComponent(callback_name) + + '&' + + this.composeQuery(socketId); + var head = document.getElementsByTagName("head")[0] || document.documentElement; + head.insertBefore(script, head.firstChild); + }; + exports.__esModule = true; + exports["default"] = jsonp; + + +/***/ }), +/* 16 */ +/***/ (function(module, exports) { + + "use strict"; + var ScriptRequest = (function () { + function ScriptRequest(src) { + this.src = src; + } + ScriptRequest.prototype.send = function (receiver) { + var self = this; + var errorString = "Error loading " + self.src; + self.script = document.createElement("script"); + self.script.id = receiver.id; + self.script.src = self.src; + self.script.type = "text/javascript"; + self.script.charset = "UTF-8"; + if (self.script.addEventListener) { + self.script.onerror = function () { + receiver.callback(errorString); + }; + self.script.onload = function () { + receiver.callback(null); + }; + } + else { + self.script.onreadystatechange = function () { + if (self.script.readyState === 'loaded' || + self.script.readyState === 'complete') { + receiver.callback(null); + } + }; + } + if (self.script.async === undefined && document.attachEvent && + /opera/i.test(navigator.userAgent)) { + self.errorScript = document.createElement("script"); + self.errorScript.id = receiver.id + "_error"; + self.errorScript.text = receiver.name + "('" + errorString + "');"; + self.script.async = self.errorScript.async = false; + } + else { + self.script.async = true; + } + var head = document.getElementsByTagName('head')[0]; + head.insertBefore(self.script, head.firstChild); + if (self.errorScript) { + head.insertBefore(self.errorScript, self.script.nextSibling); + } + }; + ScriptRequest.prototype.cleanup = function () { + if (this.script) { + this.script.onload = this.script.onerror = null; + this.script.onreadystatechange = null; + } + if (this.script && this.script.parentNode) { + this.script.parentNode.removeChild(this.script); + } + if (this.errorScript && this.errorScript.parentNode) { + this.errorScript.parentNode.removeChild(this.errorScript); + } + this.script = null; + this.errorScript = null; + }; + return ScriptRequest; + }()); + exports.__esModule = true; + exports["default"] = ScriptRequest; + + +/***/ }), +/* 17 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var Collections = __webpack_require__(9); + var runtime_1 = __webpack_require__(2); + var JSONPRequest = (function () { + function JSONPRequest(url, data) { + this.url = url; + this.data = data; + } + JSONPRequest.prototype.send = function (receiver) { + if (this.request) { + return; + } + var query = Collections.buildQueryString(this.data); + var url = this.url + "/" + receiver.number + "?" + query; + this.request = runtime_1["default"].createScriptRequest(url); + this.request.send(receiver); + }; + JSONPRequest.prototype.cleanup = function () { + if (this.request) { + this.request.cleanup(); + } + }; + return JSONPRequest; + }()); + exports.__esModule = true; + exports["default"] = JSONPRequest; + + +/***/ }), +/* 18 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var runtime_1 = __webpack_require__(2); + var script_receiver_factory_1 = __webpack_require__(4); + var getAgent = function (sender, encrypted) { + return function (data, callback) { + var scheme = "http" + (encrypted ? "s" : "") + "://"; + var url = scheme + (sender.host || sender.options.host) + sender.options.path; + var request = runtime_1["default"].createJSONPRequest(url, data); + var receiver = runtime_1["default"].ScriptReceivers.create(function (error, result) { + script_receiver_factory_1.ScriptReceivers.remove(receiver); + request.cleanup(); + if (result && result.host) { + sender.host = result.host; + } + if (callback) { + callback(error, result); + } + }); + request.send(receiver); + }; + }; + var jsonp = { + name: 'jsonp', + getAgent: getAgent + }; + exports.__esModule = true; + exports["default"] = jsonp; + + +/***/ }), +/* 19 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var transports_1 = __webpack_require__(20); + var transport_1 = __webpack_require__(22); + var URLSchemes = __webpack_require__(21); + var runtime_1 = __webpack_require__(2); + var dependencies_1 = __webpack_require__(3); + var Collections = __webpack_require__(9); + var SockJSTransport = new transport_1["default"]({ + file: "sockjs", + urls: URLSchemes.sockjs, + handlesActivityChecks: true, + supportsPing: false, + isSupported: function () { + return true; + }, + isInitialized: function () { + return window.SockJS !== undefined; + }, + getSocket: function (url, options) { + return new window.SockJS(url, null, { + js_path: dependencies_1.Dependencies.getPath("sockjs", { + encrypted: options.encrypted + }), + ignore_null_origin: options.ignoreNullOrigin + }); + }, + beforeOpen: function (socket, path) { + socket.send(JSON.stringify({ + path: path + })); + } + }); + var xdrConfiguration = { + isSupported: function (environment) { + var yes = runtime_1["default"].isXDRSupported(environment.encrypted); + return yes; + } + }; + var XDRStreamingTransport = new transport_1["default"](Collections.extend({}, transports_1.streamingConfiguration, xdrConfiguration)); + var XDRPollingTransport = new transport_1["default"](Collections.extend({}, transports_1.pollingConfiguration, xdrConfiguration)); + transports_1["default"].xdr_streaming = XDRStreamingTransport; + transports_1["default"].xdr_polling = XDRPollingTransport; + transports_1["default"].sockjs = SockJSTransport; + exports.__esModule = true; + exports["default"] = transports_1["default"]; + + +/***/ }), +/* 20 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var URLSchemes = __webpack_require__(21); + var transport_1 = __webpack_require__(22); + var Collections = __webpack_require__(9); + var runtime_1 = __webpack_require__(2); + var WSTransport = new transport_1["default"]({ + urls: URLSchemes.ws, + handlesActivityChecks: false, + supportsPing: false, + isInitialized: function () { + return Boolean(runtime_1["default"].getWebSocketAPI()); + }, + isSupported: function () { + return Boolean(runtime_1["default"].getWebSocketAPI()); + }, + getSocket: function (url) { + return runtime_1["default"].createWebSocket(url); + } + }); + var httpConfiguration = { + urls: URLSchemes.http, + handlesActivityChecks: false, + supportsPing: true, + isInitialized: function () { + return true; + } + }; + exports.streamingConfiguration = Collections.extend({ getSocket: function (url) { + return runtime_1["default"].HTTPFactory.createStreamingSocket(url); + } + }, httpConfiguration); + exports.pollingConfiguration = Collections.extend({ getSocket: function (url) { + return runtime_1["default"].HTTPFactory.createPollingSocket(url); + } + }, httpConfiguration); + var xhrConfiguration = { + isSupported: function () { + return runtime_1["default"].isXHRSupported(); + } + }; + var XHRStreamingTransport = new transport_1["default"](Collections.extend({}, exports.streamingConfiguration, xhrConfiguration)); + var XHRPollingTransport = new transport_1["default"](Collections.extend({}, exports.pollingConfiguration, xhrConfiguration)); + var Transports = { + ws: WSTransport, + xhr_streaming: XHRStreamingTransport, + xhr_polling: XHRPollingTransport + }; + exports.__esModule = true; + exports["default"] = Transports; + + +/***/ }), +/* 21 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var defaults_1 = __webpack_require__(5); + function getGenericURL(baseScheme, params, path) { + var scheme = baseScheme + (params.encrypted ? "s" : ""); + var host = params.encrypted ? params.hostEncrypted : params.hostUnencrypted; + return scheme + "://" + host + path; + } + function getGenericPath(key, queryString) { + var path = "/app/" + key; + var query = "?protocol=" + defaults_1["default"].PROTOCOL + + "&client=js" + + "&version=" + defaults_1["default"].VERSION + + (queryString ? ("&" + queryString) : ""); + return path + query; + } + exports.ws = { + getInitial: function (key, params) { + var path = (params.httpPath || "") + getGenericPath(key, "flash=false"); + return getGenericURL("ws", params, path); + } + }; + exports.http = { + getInitial: function (key, params) { + var path = (params.httpPath || "/pusher") + getGenericPath(key); + return getGenericURL("http", params, path); + } + }; + exports.sockjs = { + getInitial: function (key, params) { + return getGenericURL("http", params, params.httpPath || "/pusher"); + }, + getPath: function (key, params) { + return getGenericPath(key); + } + }; + + +/***/ }), +/* 22 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var transport_connection_1 = __webpack_require__(23); + var Transport = (function () { + function Transport(hooks) { + this.hooks = hooks; + } + Transport.prototype.isSupported = function (environment) { + return this.hooks.isSupported(environment); + }; + Transport.prototype.createConnection = function (name, priority, key, options) { + return new transport_connection_1["default"](this.hooks, name, priority, key, options); + }; + return Transport; + }()); + exports.__esModule = true; + exports["default"] = Transport; + + +/***/ }), +/* 23 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + var util_1 = __webpack_require__(11); + var Collections = __webpack_require__(9); + var dispatcher_1 = __webpack_require__(24); + var logger_1 = __webpack_require__(8); + var runtime_1 = __webpack_require__(2); + var TransportConnection = (function (_super) { + __extends(TransportConnection, _super); + function TransportConnection(hooks, name, priority, key, options) { + _super.call(this); + this.initialize = runtime_1["default"].transportConnectionInitializer; + this.hooks = hooks; + this.name = name; + this.priority = priority; + this.key = key; + this.options = options; + this.state = "new"; + this.timeline = options.timeline; + this.activityTimeout = options.activityTimeout; + this.id = this.timeline.generateUniqueID(); + } + TransportConnection.prototype.handlesActivityChecks = function () { + return Boolean(this.hooks.handlesActivityChecks); + }; + TransportConnection.prototype.supportsPing = function () { + return Boolean(this.hooks.supportsPing); + }; + TransportConnection.prototype.connect = function () { + var _this = this; + if (this.socket || this.state !== "initialized") { + return false; + } + var url = this.hooks.urls.getInitial(this.key, this.options); + try { + this.socket = this.hooks.getSocket(url, this.options); + } + catch (e) { + util_1["default"].defer(function () { + _this.onError(e); + _this.changeState("closed"); + }); + return false; + } + this.bindListeners(); + logger_1["default"].debug("Connecting", { transport: this.name, url: url }); + this.changeState("connecting"); + return true; + }; + TransportConnection.prototype.close = function () { + if (this.socket) { + this.socket.close(); + return true; + } + else { + return false; + } + }; + TransportConnection.prototype.send = function (data) { + var _this = this; + if (this.state === "open") { + util_1["default"].defer(function () { + if (_this.socket) { + _this.socket.send(data); + } + }); + return true; + } + else { + return false; + } + }; + TransportConnection.prototype.ping = function () { + if (this.state === "open" && this.supportsPing()) { + this.socket.ping(); + } + }; + TransportConnection.prototype.onOpen = function () { + if (this.hooks.beforeOpen) { + this.hooks.beforeOpen(this.socket, this.hooks.urls.getPath(this.key, this.options)); + } + this.changeState("open"); + this.socket.onopen = undefined; + }; + TransportConnection.prototype.onError = function (error) { + this.emit("error", { type: 'WebSocketError', error: error }); + this.timeline.error(this.buildTimelineMessage({ error: error.toString() })); + }; + TransportConnection.prototype.onClose = function (closeEvent) { + if (closeEvent) { + this.changeState("closed", { + code: closeEvent.code, + reason: closeEvent.reason, + wasClean: closeEvent.wasClean + }); + } + else { + this.changeState("closed"); + } + this.unbindListeners(); + this.socket = undefined; + }; + TransportConnection.prototype.onMessage = function (message) { + this.emit("message", message); + }; + TransportConnection.prototype.onActivity = function () { + this.emit("activity"); + }; + TransportConnection.prototype.bindListeners = function () { + var _this = this; + this.socket.onopen = function () { + _this.onOpen(); + }; + this.socket.onerror = function (error) { + _this.onError(error); + }; + this.socket.onclose = function (closeEvent) { + _this.onClose(closeEvent); + }; + this.socket.onmessage = function (message) { + _this.onMessage(message); + }; + if (this.supportsPing()) { + this.socket.onactivity = function () { _this.onActivity(); }; + } + }; + TransportConnection.prototype.unbindListeners = function () { + if (this.socket) { + this.socket.onopen = undefined; + this.socket.onerror = undefined; + this.socket.onclose = undefined; + this.socket.onmessage = undefined; + if (this.supportsPing()) { + this.socket.onactivity = undefined; + } + } + }; + TransportConnection.prototype.changeState = function (state, params) { + this.state = state; + this.timeline.info(this.buildTimelineMessage({ + state: state, + params: params + })); + this.emit(state, params); + }; + TransportConnection.prototype.buildTimelineMessage = function (message) { + return Collections.extend({ cid: this.id }, message); + }; + return TransportConnection; + }(dispatcher_1["default"])); + exports.__esModule = true; + exports["default"] = TransportConnection; + + +/***/ }), +/* 24 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var Collections = __webpack_require__(9); + var callback_registry_1 = __webpack_require__(25); + var Dispatcher = (function () { + function Dispatcher(failThrough) { + this.callbacks = new callback_registry_1["default"](); + this.global_callbacks = []; + this.failThrough = failThrough; + } + Dispatcher.prototype.bind = function (eventName, callback, context) { + this.callbacks.add(eventName, callback, context); + return this; + }; + Dispatcher.prototype.bind_global = function (callback) { + this.global_callbacks.push(callback); + return this; + }; + Dispatcher.prototype.unbind = function (eventName, callback, context) { + this.callbacks.remove(eventName, callback, context); + return this; + }; + Dispatcher.prototype.unbind_global = function (callback) { + if (!callback) { + this.global_callbacks = []; + return this; + } + this.global_callbacks = Collections.filter(this.global_callbacks || [], function (c) { return c !== callback; }); + return this; + }; + Dispatcher.prototype.unbind_all = function () { + this.unbind(); + this.unbind_global(); + return this; + }; + Dispatcher.prototype.emit = function (eventName, data) { + var i; + for (i = 0; i < this.global_callbacks.length; i++) { + this.global_callbacks[i](eventName, data); + } + var callbacks = this.callbacks.get(eventName); + if (callbacks && callbacks.length > 0) { + for (i = 0; i < callbacks.length; i++) { + callbacks[i].fn.call(callbacks[i].context || (window), data); + } + } + else if (this.failThrough) { + this.failThrough(eventName, data); + } + return this; + }; + return Dispatcher; + }()); + exports.__esModule = true; + exports["default"] = Dispatcher; + + +/***/ }), +/* 25 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var Collections = __webpack_require__(9); + var CallbackRegistry = (function () { + function CallbackRegistry() { + this._callbacks = {}; + } + CallbackRegistry.prototype.get = function (name) { + return this._callbacks[prefix(name)]; + }; + CallbackRegistry.prototype.add = function (name, callback, context) { + var prefixedEventName = prefix(name); + this._callbacks[prefixedEventName] = this._callbacks[prefixedEventName] || []; + this._callbacks[prefixedEventName].push({ + fn: callback, + context: context + }); + }; + CallbackRegistry.prototype.remove = function (name, callback, context) { + if (!name && !callback && !context) { + this._callbacks = {}; + return; + } + var names = name ? [prefix(name)] : Collections.keys(this._callbacks); + if (callback || context) { + this.removeCallback(names, callback, context); + } + else { + this.removeAllCallbacks(names); + } + }; + CallbackRegistry.prototype.removeCallback = function (names, callback, context) { + Collections.apply(names, function (name) { + this._callbacks[name] = Collections.filter(this._callbacks[name] || [], function (binding) { + return (callback && callback !== binding.fn) || + (context && context !== binding.context); + }); + if (this._callbacks[name].length === 0) { + delete this._callbacks[name]; + } + }, this); + }; + CallbackRegistry.prototype.removeAllCallbacks = function (names) { + Collections.apply(names, function (name) { + delete this._callbacks[name]; + }, this); + }; + return CallbackRegistry; + }()); + exports.__esModule = true; + exports["default"] = CallbackRegistry; + function prefix(name) { + return "_" + name; + } + + +/***/ }), +/* 26 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + var dispatcher_1 = __webpack_require__(24); + var NetInfo = (function (_super) { + __extends(NetInfo, _super); + function NetInfo() { + _super.call(this); + var self = this; + if (window.addEventListener !== undefined) { + window.addEventListener("online", function () { + self.emit('online'); + }, false); + window.addEventListener("offline", function () { + self.emit('offline'); + }, false); + } + } + NetInfo.prototype.isOnline = function () { + if (window.navigator.onLine === undefined) { + return true; + } + else { + return window.navigator.onLine; + } + }; + return NetInfo; + }(dispatcher_1["default"])); + exports.NetInfo = NetInfo; + exports.Network = new NetInfo(); + + +/***/ }), +/* 27 */ +/***/ (function(module, exports) { + + "use strict"; + var getDefaultStrategy = function (config) { + var wsStrategy; + if (config.encrypted) { + wsStrategy = [ + ":best_connected_ever", + ":ws_loop", + [":delayed", 2000, [":http_fallback_loop"]] + ]; + } + else { + wsStrategy = [ + ":best_connected_ever", + ":ws_loop", + [":delayed", 2000, [":wss_loop"]], + [":delayed", 5000, [":http_fallback_loop"]] + ]; + } + return [ + [":def", "ws_options", { + hostUnencrypted: config.wsHost + ":" + config.wsPort, + hostEncrypted: config.wsHost + ":" + config.wssPort, + httpPath: config.wsPath + }], + [":def", "wss_options", [":extend", ":ws_options", { + encrypted: true + }]], + [":def", "sockjs_options", { + hostUnencrypted: config.httpHost + ":" + config.httpPort, + hostEncrypted: config.httpHost + ":" + config.httpsPort, + httpPath: config.httpPath + }], + [":def", "timeouts", { + loop: true, + timeout: 15000, + timeoutLimit: 60000 + }], + [":def", "ws_manager", [":transport_manager", { + lives: 2, + minPingDelay: 10000, + maxPingDelay: config.activity_timeout + }]], + [":def", "streaming_manager", [":transport_manager", { + lives: 2, + minPingDelay: 10000, + maxPingDelay: config.activity_timeout + }]], + [":def_transport", "ws", "ws", 3, ":ws_options", ":ws_manager"], + [":def_transport", "wss", "ws", 3, ":wss_options", ":ws_manager"], + [":def_transport", "sockjs", "sockjs", 1, ":sockjs_options"], + [":def_transport", "xhr_streaming", "xhr_streaming", 1, ":sockjs_options", ":streaming_manager"], + [":def_transport", "xdr_streaming", "xdr_streaming", 1, ":sockjs_options", ":streaming_manager"], + [":def_transport", "xhr_polling", "xhr_polling", 1, ":sockjs_options"], + [":def_transport", "xdr_polling", "xdr_polling", 1, ":sockjs_options"], + [":def", "ws_loop", [":sequential", ":timeouts", ":ws"]], + [":def", "wss_loop", [":sequential", ":timeouts", ":wss"]], + [":def", "sockjs_loop", [":sequential", ":timeouts", ":sockjs"]], + [":def", "streaming_loop", [":sequential", ":timeouts", + [":if", [":is_supported", ":xhr_streaming"], + ":xhr_streaming", + ":xdr_streaming" + ] + ]], + [":def", "polling_loop", [":sequential", ":timeouts", + [":if", [":is_supported", ":xhr_polling"], + ":xhr_polling", + ":xdr_polling" + ] + ]], + [":def", "http_loop", [":if", [":is_supported", ":streaming_loop"], [ + ":best_connected_ever", + ":streaming_loop", + [":delayed", 4000, [":polling_loop"]] + ], [ + ":polling_loop" + ]]], + [":def", "http_fallback_loop", + [":if", [":is_supported", ":http_loop"], [ + ":http_loop" + ], [ + ":sockjs_loop" + ]] + ], + [":def", "strategy", + [":cached", 1800000, + [":first_connected", + [":if", [":is_supported", ":ws"], + wsStrategy, + ":http_fallback_loop" + ] + ] + ] + ] + ]; + }; + exports.__esModule = true; + exports["default"] = getDefaultStrategy; + + +/***/ }), +/* 28 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var dependencies_1 = __webpack_require__(3); + function default_1() { + var self = this; + self.timeline.info(self.buildTimelineMessage({ + transport: self.name + (self.options.encrypted ? "s" : "") + })); + if (self.hooks.isInitialized()) { + self.changeState("initialized"); + } + else if (self.hooks.file) { + self.changeState("initializing"); + dependencies_1.Dependencies.load(self.hooks.file, { encrypted: self.options.encrypted }, function (error, callback) { + if (self.hooks.isInitialized()) { + self.changeState("initialized"); + callback(true); + } + else { + if (error) { + self.onError(error); + } + self.onClose(); + callback(false); + } + }); + } + else { + self.onClose(); + } + } + exports.__esModule = true; + exports["default"] = default_1; + + +/***/ }), +/* 29 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var http_xdomain_request_1 = __webpack_require__(30); + var http_1 = __webpack_require__(32); + http_1["default"].createXDR = function (method, url) { + return this.createRequest(http_xdomain_request_1["default"], method, url); + }; + exports.__esModule = true; + exports["default"] = http_1["default"]; + + +/***/ }), +/* 30 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var Errors = __webpack_require__(31); + var hooks = { + getRequest: function (socket) { + var xdr = new window.XDomainRequest(); + xdr.ontimeout = function () { + socket.emit("error", new Errors.RequestTimedOut()); + socket.close(); + }; + xdr.onerror = function (e) { + socket.emit("error", e); + socket.close(); + }; + xdr.onprogress = function () { + if (xdr.responseText && xdr.responseText.length > 0) { + socket.onChunk(200, xdr.responseText); + } + }; + xdr.onload = function () { + if (xdr.responseText && xdr.responseText.length > 0) { + socket.onChunk(200, xdr.responseText); + } + socket.emit("finished", 200); + socket.close(); + }; + return xdr; + }, + abortRequest: function (xdr) { + xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null; + xdr.abort(); + } + }; + exports.__esModule = true; + exports["default"] = hooks; + + +/***/ }), +/* 31 */ +/***/ (function(module, exports) { + + "use strict"; + var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + var BadEventName = (function (_super) { + __extends(BadEventName, _super); + function BadEventName() { + _super.apply(this, arguments); + } + return BadEventName; + }(Error)); + exports.BadEventName = BadEventName; + var RequestTimedOut = (function (_super) { + __extends(RequestTimedOut, _super); + function RequestTimedOut() { + _super.apply(this, arguments); + } + return RequestTimedOut; + }(Error)); + exports.RequestTimedOut = RequestTimedOut; + var TransportPriorityTooLow = (function (_super) { + __extends(TransportPriorityTooLow, _super); + function TransportPriorityTooLow() { + _super.apply(this, arguments); + } + return TransportPriorityTooLow; + }(Error)); + exports.TransportPriorityTooLow = TransportPriorityTooLow; + var TransportClosed = (function (_super) { + __extends(TransportClosed, _super); + function TransportClosed() { + _super.apply(this, arguments); + } + return TransportClosed; + }(Error)); + exports.TransportClosed = TransportClosed; + var UnsupportedTransport = (function (_super) { + __extends(UnsupportedTransport, _super); + function UnsupportedTransport() { + _super.apply(this, arguments); + } + return UnsupportedTransport; + }(Error)); + exports.UnsupportedTransport = UnsupportedTransport; + var UnsupportedStrategy = (function (_super) { + __extends(UnsupportedStrategy, _super); + function UnsupportedStrategy() { + _super.apply(this, arguments); + } + return UnsupportedStrategy; + }(Error)); + exports.UnsupportedStrategy = UnsupportedStrategy; + + +/***/ }), +/* 32 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var http_request_1 = __webpack_require__(33); + var http_socket_1 = __webpack_require__(34); + var http_streaming_socket_1 = __webpack_require__(36); + var http_polling_socket_1 = __webpack_require__(37); + var http_xhr_request_1 = __webpack_require__(38); + var HTTP = { + createStreamingSocket: function (url) { + return this.createSocket(http_streaming_socket_1["default"], url); + }, + createPollingSocket: function (url) { + return this.createSocket(http_polling_socket_1["default"], url); + }, + createSocket: function (hooks, url) { + return new http_socket_1["default"](hooks, url); + }, + createXHR: function (method, url) { + return this.createRequest(http_xhr_request_1["default"], method, url); + }, + createRequest: function (hooks, method, url) { + return new http_request_1["default"](hooks, method, url); + } + }; + exports.__esModule = true; + exports["default"] = HTTP; + + +/***/ }), +/* 33 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + var runtime_1 = __webpack_require__(2); + var dispatcher_1 = __webpack_require__(24); + var MAX_BUFFER_LENGTH = 256 * 1024; + var HTTPRequest = (function (_super) { + __extends(HTTPRequest, _super); + function HTTPRequest(hooks, method, url) { + _super.call(this); + this.hooks = hooks; + this.method = method; + this.url = url; + } + HTTPRequest.prototype.start = function (payload) { + var _this = this; + this.position = 0; + this.xhr = this.hooks.getRequest(this); + this.unloader = function () { + _this.close(); + }; + runtime_1["default"].addUnloadListener(this.unloader); + this.xhr.open(this.method, this.url, true); + if (this.xhr.setRequestHeader) { + this.xhr.setRequestHeader("Content-Type", "application/json"); + } + this.xhr.send(payload); + }; + HTTPRequest.prototype.close = function () { + if (this.unloader) { + runtime_1["default"].removeUnloadListener(this.unloader); + this.unloader = null; + } + if (this.xhr) { + this.hooks.abortRequest(this.xhr); + this.xhr = null; + } + }; + HTTPRequest.prototype.onChunk = function (status, data) { + while (true) { + var chunk = this.advanceBuffer(data); + if (chunk) { + this.emit("chunk", { status: status, data: chunk }); + } + else { + break; + } + } + if (this.isBufferTooLong(data)) { + this.emit("buffer_too_long"); + } + }; + HTTPRequest.prototype.advanceBuffer = function (buffer) { + var unreadData = buffer.slice(this.position); + var endOfLinePosition = unreadData.indexOf("\n"); + if (endOfLinePosition !== -1) { + this.position += endOfLinePosition + 1; + return unreadData.slice(0, endOfLinePosition); + } + else { + return null; + } + }; + HTTPRequest.prototype.isBufferTooLong = function (buffer) { + return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH; + }; + return HTTPRequest; + }(dispatcher_1["default"])); + exports.__esModule = true; + exports["default"] = HTTPRequest; + + +/***/ }), +/* 34 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var state_1 = __webpack_require__(35); + var util_1 = __webpack_require__(11); + var runtime_1 = __webpack_require__(2); + var autoIncrement = 1; + var HTTPSocket = (function () { + function HTTPSocket(hooks, url) { + this.hooks = hooks; + this.session = randomNumber(1000) + "/" + randomString(8); + this.location = getLocation(url); + this.readyState = state_1["default"].CONNECTING; + this.openStream(); + } + HTTPSocket.prototype.send = function (payload) { + return this.sendRaw(JSON.stringify([payload])); + }; + HTTPSocket.prototype.ping = function () { + this.hooks.sendHeartbeat(this); + }; + HTTPSocket.prototype.close = function (code, reason) { + this.onClose(code, reason, true); + }; + HTTPSocket.prototype.sendRaw = function (payload) { + if (this.readyState === state_1["default"].OPEN) { + try { + runtime_1["default"].createSocketRequest("POST", getUniqueURL(getSendURL(this.location, this.session))).start(payload); + return true; + } + catch (e) { + return false; + } + } + else { + return false; + } + }; + HTTPSocket.prototype.reconnect = function () { + this.closeStream(); + this.openStream(); + }; + ; + HTTPSocket.prototype.onClose = function (code, reason, wasClean) { + this.closeStream(); + this.readyState = state_1["default"].CLOSED; + if (this.onclose) { + this.onclose({ + code: code, + reason: reason, + wasClean: wasClean + }); + } + }; + HTTPSocket.prototype.onChunk = function (chunk) { + if (chunk.status !== 200) { + return; + } + if (this.readyState === state_1["default"].OPEN) { + this.onActivity(); + } + var payload; + var type = chunk.data.slice(0, 1); + switch (type) { + case 'o': + payload = JSON.parse(chunk.data.slice(1) || '{}'); + this.onOpen(payload); + break; + case 'a': + payload = JSON.parse(chunk.data.slice(1) || '[]'); + for (var i = 0; i < payload.length; i++) { + this.onEvent(payload[i]); + } + break; + case 'm': + payload = JSON.parse(chunk.data.slice(1) || 'null'); + this.onEvent(payload); + break; + case 'h': + this.hooks.onHeartbeat(this); + break; + case 'c': + payload = JSON.parse(chunk.data.slice(1) || '[]'); + this.onClose(payload[0], payload[1], true); + break; + } + }; + HTTPSocket.prototype.onOpen = function (options) { + if (this.readyState === state_1["default"].CONNECTING) { + if (options && options.hostname) { + this.location.base = replaceHost(this.location.base, options.hostname); + } + this.readyState = state_1["default"].OPEN; + if (this.onopen) { + this.onopen(); + } + } + else { + this.onClose(1006, "Server lost session", true); + } + }; + HTTPSocket.prototype.onEvent = function (event) { + if (this.readyState === state_1["default"].OPEN && this.onmessage) { + this.onmessage({ data: event }); + } + }; + HTTPSocket.prototype.onActivity = function () { + if (this.onactivity) { + this.onactivity(); + } + }; + HTTPSocket.prototype.onError = function (error) { + if (this.onerror) { + this.onerror(error); + } + }; + HTTPSocket.prototype.openStream = function () { + var _this = this; + this.stream = runtime_1["default"].createSocketRequest("POST", getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))); + this.stream.bind("chunk", function (chunk) { + _this.onChunk(chunk); + }); + this.stream.bind("finished", function (status) { + _this.hooks.onFinished(_this, status); + }); + this.stream.bind("buffer_too_long", function () { + _this.reconnect(); + }); + try { + this.stream.start(); + } + catch (error) { + util_1["default"].defer(function () { + _this.onError(error); + _this.onClose(1006, "Could not start streaming", false); + }); + } + }; + HTTPSocket.prototype.closeStream = function () { + if (this.stream) { + this.stream.unbind_all(); + this.stream.close(); + this.stream = null; + } + }; + return HTTPSocket; + }()); + function getLocation(url) { + var parts = /([^\?]*)\/*(\??.*)/.exec(url); + return { + base: parts[1], + queryString: parts[2] + }; + } + function getSendURL(url, session) { + return url.base + "/" + session + "/xhr_send"; + } + function getUniqueURL(url) { + var separator = (url.indexOf('?') === -1) ? "?" : "&"; + return url + separator + "t=" + (+new Date()) + "&n=" + autoIncrement++; + } + function replaceHost(url, hostname) { + var urlParts = /(https?:\/\/)([^\/:]+)((\/|:)?.*)/.exec(url); + return urlParts[1] + hostname + urlParts[3]; + } + function randomNumber(max) { + return Math.floor(Math.random() * max); + } + function randomString(length) { + var result = []; + for (var i = 0; i < length; i++) { + result.push(randomNumber(32).toString(32)); + } + return result.join(''); + } + exports.__esModule = true; + exports["default"] = HTTPSocket; + + +/***/ }), +/* 35 */ +/***/ (function(module, exports) { + + "use strict"; + var State; + (function (State) { + State[State["CONNECTING"] = 0] = "CONNECTING"; + State[State["OPEN"] = 1] = "OPEN"; + State[State["CLOSED"] = 3] = "CLOSED"; + })(State || (State = {})); + exports.__esModule = true; + exports["default"] = State; + + +/***/ }), +/* 36 */ +/***/ (function(module, exports) { + + "use strict"; + var hooks = { + getReceiveURL: function (url, session) { + return url.base + "/" + session + "/xhr_streaming" + url.queryString; + }, + onHeartbeat: function (socket) { + socket.sendRaw("[]"); + }, + sendHeartbeat: function (socket) { + socket.sendRaw("[]"); + }, + onFinished: function (socket, status) { + socket.onClose(1006, "Connection interrupted (" + status + ")", false); + } + }; + exports.__esModule = true; + exports["default"] = hooks; + + +/***/ }), +/* 37 */ +/***/ (function(module, exports) { + + "use strict"; + var hooks = { + getReceiveURL: function (url, session) { + return url.base + "/" + session + "/xhr" + url.queryString; + }, + onHeartbeat: function () { + }, + sendHeartbeat: function (socket) { + socket.sendRaw("[]"); + }, + onFinished: function (socket, status) { + if (status === 200) { + socket.reconnect(); + } + else { + socket.onClose(1006, "Connection interrupted (" + status + ")", false); + } + } + }; + exports.__esModule = true; + exports["default"] = hooks; + + +/***/ }), +/* 38 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var runtime_1 = __webpack_require__(2); + var hooks = { + getRequest: function (socket) { + var Constructor = runtime_1["default"].getXHRAPI(); + var xhr = new Constructor(); + xhr.onreadystatechange = xhr.onprogress = function () { + switch (xhr.readyState) { + case 3: + if (xhr.responseText && xhr.responseText.length > 0) { + socket.onChunk(xhr.status, xhr.responseText); + } + break; + case 4: + if (xhr.responseText && xhr.responseText.length > 0) { + socket.onChunk(xhr.status, xhr.responseText); + } + socket.emit("finished", xhr.status); + socket.close(); + break; + } + }; + return xhr; + }, + abortRequest: function (xhr) { + xhr.onreadystatechange = null; + xhr.abort(); + } + }; + exports.__esModule = true; + exports["default"] = hooks; + + +/***/ }), +/* 39 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var Collections = __webpack_require__(9); + var util_1 = __webpack_require__(11); + var level_1 = __webpack_require__(40); + var Timeline = (function () { + function Timeline(key, session, options) { + this.key = key; + this.session = session; + this.events = []; + this.options = options || {}; + this.sent = 0; + this.uniqueID = 0; + } + Timeline.prototype.log = function (level, event) { + if (level <= this.options.level) { + this.events.push(Collections.extend({}, event, { timestamp: util_1["default"].now() })); + if (this.options.limit && this.events.length > this.options.limit) { + this.events.shift(); + } + } + }; + Timeline.prototype.error = function (event) { + this.log(level_1["default"].ERROR, event); + }; + Timeline.prototype.info = function (event) { + this.log(level_1["default"].INFO, event); + }; + Timeline.prototype.debug = function (event) { + this.log(level_1["default"].DEBUG, event); + }; + Timeline.prototype.isEmpty = function () { + return this.events.length === 0; + }; + Timeline.prototype.send = function (sendfn, callback) { + var _this = this; + var data = Collections.extend({ + session: this.session, + bundle: this.sent + 1, + key: this.key, + lib: "js", + version: this.options.version, + cluster: this.options.cluster, + features: this.options.features, + timeline: this.events + }, this.options.params); + this.events = []; + sendfn(data, function (error, result) { + if (!error) { + _this.sent++; + } + if (callback) { + callback(error, result); + } + }); + return true; + }; + Timeline.prototype.generateUniqueID = function () { + this.uniqueID++; + return this.uniqueID; + }; + return Timeline; + }()); + exports.__esModule = true; + exports["default"] = Timeline; + + +/***/ }), +/* 40 */ +/***/ (function(module, exports) { + + "use strict"; + var TimelineLevel; + (function (TimelineLevel) { + TimelineLevel[TimelineLevel["ERROR"] = 3] = "ERROR"; + TimelineLevel[TimelineLevel["INFO"] = 6] = "INFO"; + TimelineLevel[TimelineLevel["DEBUG"] = 7] = "DEBUG"; + })(TimelineLevel || (TimelineLevel = {})); + exports.__esModule = true; + exports["default"] = TimelineLevel; + + +/***/ }), +/* 41 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var Collections = __webpack_require__(9); + var util_1 = __webpack_require__(11); + var transport_manager_1 = __webpack_require__(42); + var Errors = __webpack_require__(31); + var transport_strategy_1 = __webpack_require__(56); + var sequential_strategy_1 = __webpack_require__(57); + var best_connected_ever_strategy_1 = __webpack_require__(58); + var cached_strategy_1 = __webpack_require__(59); + var delayed_strategy_1 = __webpack_require__(60); + var if_strategy_1 = __webpack_require__(61); + var first_connected_strategy_1 = __webpack_require__(62); + var runtime_1 = __webpack_require__(2); + var Transports = runtime_1["default"].Transports; + exports.build = function (scheme, options) { + var context = Collections.extend({}, globalContext, options); + return evaluate(scheme, context)[1].strategy; + }; + var UnsupportedStrategy = { + isSupported: function () { + return false; + }, + connect: function (_, callback) { + var deferred = util_1["default"].defer(function () { + callback(new Errors.UnsupportedStrategy()); + }); + return { + abort: function () { + deferred.ensureAborted(); + }, + forceMinPriority: function () { } + }; + } + }; + function returnWithOriginalContext(f) { + return function (context) { + return [f.apply(this, arguments), context]; + }; + } + var globalContext = { + extend: function (context, first, second) { + return [Collections.extend({}, first, second), context]; + }, + def: function (context, name, value) { + if (context[name] !== undefined) { + throw "Redefining symbol " + name; + } + context[name] = value; + return [undefined, context]; + }, + def_transport: function (context, name, type, priority, options, manager) { + var transportClass = Transports[type]; + if (!transportClass) { + throw new Errors.UnsupportedTransport(type); + } + var enabled = (!context.enabledTransports || + Collections.arrayIndexOf(context.enabledTransports, name) !== -1) && + (!context.disabledTransports || + Collections.arrayIndexOf(context.disabledTransports, name) === -1); + var transport; + if (enabled) { + transport = new transport_strategy_1["default"](name, priority, manager ? manager.getAssistant(transportClass) : transportClass, Collections.extend({ + key: context.key, + encrypted: context.encrypted, + timeline: context.timeline, + ignoreNullOrigin: context.ignoreNullOrigin + }, options)); + } + else { + transport = UnsupportedStrategy; + } + var newContext = context.def(context, name, transport)[1]; + newContext.Transports = context.Transports || {}; + newContext.Transports[name] = transport; + return [undefined, newContext]; + }, + transport_manager: returnWithOriginalContext(function (_, options) { + return new transport_manager_1["default"](options); + }), + sequential: returnWithOriginalContext(function (_, options) { + var strategies = Array.prototype.slice.call(arguments, 2); + return new sequential_strategy_1["default"](strategies, options); + }), + cached: returnWithOriginalContext(function (context, ttl, strategy) { + return new cached_strategy_1["default"](strategy, context.Transports, { + ttl: ttl, + timeline: context.timeline, + encrypted: context.encrypted + }); + }), + first_connected: returnWithOriginalContext(function (_, strategy) { + return new first_connected_strategy_1["default"](strategy); + }), + best_connected_ever: returnWithOriginalContext(function () { + var strategies = Array.prototype.slice.call(arguments, 1); + return new best_connected_ever_strategy_1["default"](strategies); + }), + delayed: returnWithOriginalContext(function (_, delay, strategy) { + return new delayed_strategy_1["default"](strategy, { delay: delay }); + }), + "if": returnWithOriginalContext(function (_, test, trueBranch, falseBranch) { + return new if_strategy_1["default"](test, trueBranch, falseBranch); + }), + is_supported: returnWithOriginalContext(function (_, strategy) { + return function () { + return strategy.isSupported(); + }; + }) + }; + function isSymbol(expression) { + return (typeof expression === "string") && expression.charAt(0) === ":"; + } + function getSymbolValue(expression, context) { + return context[expression.slice(1)]; + } + function evaluateListOfExpressions(expressions, context) { + if (expressions.length === 0) { + return [[], context]; + } + var head = evaluate(expressions[0], context); + var tail = evaluateListOfExpressions(expressions.slice(1), head[1]); + return [[head[0]].concat(tail[0]), tail[1]]; + } + function evaluateString(expression, context) { + if (!isSymbol(expression)) { + return [expression, context]; + } + var value = getSymbolValue(expression, context); + if (value === undefined) { + throw "Undefined symbol " + expression; + } + return [value, context]; + } + function evaluateArray(expression, context) { + if (isSymbol(expression[0])) { + var f = getSymbolValue(expression[0], context); + if (expression.length > 1) { + if (typeof f !== "function") { + throw "Calling non-function " + expression[0]; + } + var args = [Collections.extend({}, context)].concat(Collections.map(expression.slice(1), function (arg) { + return evaluate(arg, Collections.extend({}, context))[0]; + })); + return f.apply(this, args); + } + else { + return [f, context]; + } + } + else { + return evaluateListOfExpressions(expression, context); + } + } + function evaluate(expression, context) { + if (typeof expression === "string") { + return evaluateString(expression, context); + } + else if (typeof expression === "object") { + if (expression instanceof Array && expression.length > 0) { + return evaluateArray(expression, context); + } + } + return [expression, context]; + } + + +/***/ }), +/* 42 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var factory_1 = __webpack_require__(43); + var TransportManager = (function () { + function TransportManager(options) { + this.options = options || {}; + this.livesLeft = this.options.lives || Infinity; + } + TransportManager.prototype.getAssistant = function (transport) { + return factory_1["default"].createAssistantToTheTransportManager(this, transport, { + minPingDelay: this.options.minPingDelay, + maxPingDelay: this.options.maxPingDelay + }); + }; + TransportManager.prototype.isAlive = function () { + return this.livesLeft > 0; + }; + TransportManager.prototype.reportDeath = function () { + this.livesLeft -= 1; + }; + return TransportManager; + }()); + exports.__esModule = true; + exports["default"] = TransportManager; + + +/***/ }), +/* 43 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var assistant_to_the_transport_manager_1 = __webpack_require__(44); + var handshake_1 = __webpack_require__(45); + var pusher_authorizer_1 = __webpack_require__(48); + var timeline_sender_1 = __webpack_require__(49); + var presence_channel_1 = __webpack_require__(50); + var private_channel_1 = __webpack_require__(51); + var channel_1 = __webpack_require__(52); + var connection_manager_1 = __webpack_require__(54); + var channels_1 = __webpack_require__(55); + var Factory = { + createChannels: function () { + return new channels_1["default"](); + }, + createConnectionManager: function (key, options) { + return new connection_manager_1["default"](key, options); + }, + createChannel: function (name, pusher) { + return new channel_1["default"](name, pusher); + }, + createPrivateChannel: function (name, pusher) { + return new private_channel_1["default"](name, pusher); + }, + createPresenceChannel: function (name, pusher) { + return new presence_channel_1["default"](name, pusher); + }, + createTimelineSender: function (timeline, options) { + return new timeline_sender_1["default"](timeline, options); + }, + createAuthorizer: function (channel, options) { + if (options.authorizer) { + return options.authorizer(channel, options); + } + return new pusher_authorizer_1["default"](channel, options); + }, + createHandshake: function (transport, callback) { + return new handshake_1["default"](transport, callback); + }, + createAssistantToTheTransportManager: function (manager, transport, options) { + return new assistant_to_the_transport_manager_1["default"](manager, transport, options); + } + }; + exports.__esModule = true; + exports["default"] = Factory; + + +/***/ }), +/* 44 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var util_1 = __webpack_require__(11); + var Collections = __webpack_require__(9); + var AssistantToTheTransportManager = (function () { + function AssistantToTheTransportManager(manager, transport, options) { + this.manager = manager; + this.transport = transport; + this.minPingDelay = options.minPingDelay; + this.maxPingDelay = options.maxPingDelay; + this.pingDelay = undefined; + } + AssistantToTheTransportManager.prototype.createConnection = function (name, priority, key, options) { + var _this = this; + options = Collections.extend({}, options, { + activityTimeout: this.pingDelay + }); + var connection = this.transport.createConnection(name, priority, key, options); + var openTimestamp = null; + var onOpen = function () { + connection.unbind("open", onOpen); + connection.bind("closed", onClosed); + openTimestamp = util_1["default"].now(); + }; + var onClosed = function (closeEvent) { + connection.unbind("closed", onClosed); + if (closeEvent.code === 1002 || closeEvent.code === 1003) { + _this.manager.reportDeath(); + } + else if (!closeEvent.wasClean && openTimestamp) { + var lifespan = util_1["default"].now() - openTimestamp; + if (lifespan < 2 * _this.maxPingDelay) { + _this.manager.reportDeath(); + _this.pingDelay = Math.max(lifespan / 2, _this.minPingDelay); + } + } + }; + connection.bind("open", onOpen); + return connection; + }; + AssistantToTheTransportManager.prototype.isSupported = function (environment) { + return this.manager.isAlive() && this.transport.isSupported(environment); + }; + return AssistantToTheTransportManager; + }()); + exports.__esModule = true; + exports["default"] = AssistantToTheTransportManager; + + +/***/ }), +/* 45 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var Collections = __webpack_require__(9); + var Protocol = __webpack_require__(46); + var connection_1 = __webpack_require__(47); + var Handshake = (function () { + function Handshake(transport, callback) { + this.transport = transport; + this.callback = callback; + this.bindListeners(); + } + Handshake.prototype.close = function () { + this.unbindListeners(); + this.transport.close(); + }; + Handshake.prototype.bindListeners = function () { + var _this = this; + this.onMessage = function (m) { + _this.unbindListeners(); + var result; + try { + result = Protocol.processHandshake(m); + } + catch (e) { + _this.finish("error", { error: e }); + _this.transport.close(); + return; + } + if (result.action === "connected") { + _this.finish("connected", { + connection: new connection_1["default"](result.id, _this.transport), + activityTimeout: result.activityTimeout + }); + } + else { + _this.finish(result.action, { error: result.error }); + _this.transport.close(); + } + }; + this.onClosed = function (closeEvent) { + _this.unbindListeners(); + var action = Protocol.getCloseAction(closeEvent) || "backoff"; + var error = Protocol.getCloseError(closeEvent); + _this.finish(action, { error: error }); + }; + this.transport.bind("message", this.onMessage); + this.transport.bind("closed", this.onClosed); + }; + Handshake.prototype.unbindListeners = function () { + this.transport.unbind("message", this.onMessage); + this.transport.unbind("closed", this.onClosed); + }; + Handshake.prototype.finish = function (action, params) { + this.callback(Collections.extend({ transport: this.transport, action: action }, params)); + }; + return Handshake; + }()); + exports.__esModule = true; + exports["default"] = Handshake; + + +/***/ }), +/* 46 */ +/***/ (function(module, exports) { + + "use strict"; + exports.decodeMessage = function (message) { + try { + var params = JSON.parse(message.data); + if (typeof params.data === 'string') { + try { + params.data = JSON.parse(params.data); + } + catch (e) { + if (!(e instanceof SyntaxError)) { + throw e; + } + } + } + return params; + } + catch (e) { + throw { type: 'MessageParseError', error: e, data: message.data }; + } + }; + exports.encodeMessage = function (message) { + return JSON.stringify(message); + }; + exports.processHandshake = function (message) { + message = exports.decodeMessage(message); + if (message.event === "pusher:connection_established") { + if (!message.data.activity_timeout) { + throw "No activity timeout specified in handshake"; + } + return { + action: "connected", + id: message.data.socket_id, + activityTimeout: message.data.activity_timeout * 1000 + }; + } + else if (message.event === "pusher:error") { + return { + action: this.getCloseAction(message.data), + error: this.getCloseError(message.data) + }; + } + else { + throw "Invalid handshake"; + } + }; + exports.getCloseAction = function (closeEvent) { + if (closeEvent.code < 4000) { + if (closeEvent.code >= 1002 && closeEvent.code <= 1004) { + return "backoff"; + } + else { + return null; + } + } + else if (closeEvent.code === 4000) { + return "ssl_only"; + } + else if (closeEvent.code < 4100) { + return "refused"; + } + else if (closeEvent.code < 4200) { + return "backoff"; + } + else if (closeEvent.code < 4300) { + return "retry"; + } + else { + return "refused"; + } + }; + exports.getCloseError = function (closeEvent) { + if (closeEvent.code !== 1000 && closeEvent.code !== 1001) { + return { + type: 'PusherError', + data: { + code: closeEvent.code, + message: closeEvent.reason || closeEvent.message + } + }; + } + else { + return null; + } + }; + + +/***/ }), +/* 47 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + var Collections = __webpack_require__(9); + var dispatcher_1 = __webpack_require__(24); + var Protocol = __webpack_require__(46); + var logger_1 = __webpack_require__(8); + var Connection = (function (_super) { + __extends(Connection, _super); + function Connection(id, transport) { + _super.call(this); + this.id = id; + this.transport = transport; + this.activityTimeout = transport.activityTimeout; + this.bindListeners(); + } + Connection.prototype.handlesActivityChecks = function () { + return this.transport.handlesActivityChecks(); + }; + Connection.prototype.send = function (data) { + return this.transport.send(data); + }; + Connection.prototype.send_event = function (name, data, channel) { + var message = { event: name, data: data }; + if (channel) { + message.channel = channel; + } + logger_1["default"].debug('Event sent', message); + return this.send(Protocol.encodeMessage(message)); + }; + Connection.prototype.ping = function () { + if (this.transport.supportsPing()) { + this.transport.ping(); + } + else { + this.send_event('pusher:ping', {}); + } + }; + Connection.prototype.close = function () { + this.transport.close(); + }; + Connection.prototype.bindListeners = function () { + var _this = this; + var listeners = { + message: function (m) { + var message; + try { + message = Protocol.decodeMessage(m); + } + catch (e) { + _this.emit('error', { + type: 'MessageParseError', + error: e, + data: m.data + }); + } + if (message !== undefined) { + logger_1["default"].debug('Event recd', message); + switch (message.event) { + case 'pusher:error': + _this.emit('error', { type: 'PusherError', data: message.data }); + break; + case 'pusher:ping': + _this.emit("ping"); + break; + case 'pusher:pong': + _this.emit("pong"); + break; + } + _this.emit('message', message); + } + }, + activity: function () { + _this.emit("activity"); + }, + error: function (error) { + _this.emit("error", { type: "WebSocketError", error: error }); + }, + closed: function (closeEvent) { + unbindListeners(); + if (closeEvent && closeEvent.code) { + _this.handleCloseEvent(closeEvent); + } + _this.transport = null; + _this.emit("closed"); + } + }; + var unbindListeners = function () { + Collections.objectApply(listeners, function (listener, event) { + _this.transport.unbind(event, listener); + }); + }; + Collections.objectApply(listeners, function (listener, event) { + _this.transport.bind(event, listener); + }); + }; + Connection.prototype.handleCloseEvent = function (closeEvent) { + var action = Protocol.getCloseAction(closeEvent); + var error = Protocol.getCloseError(closeEvent); + if (error) { + this.emit('error', error); + } + if (action) { + this.emit(action); + } + }; + return Connection; + }(dispatcher_1["default"])); + exports.__esModule = true; + exports["default"] = Connection; + + +/***/ }), +/* 48 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var runtime_1 = __webpack_require__(2); + var PusherAuthorizer = (function () { + function PusherAuthorizer(channel, options) { + this.channel = channel; + var authTransport = options.authTransport; + if (typeof runtime_1["default"].getAuthorizers()[authTransport] === "undefined") { + throw "'" + authTransport + "' is not a recognized auth transport"; + } + this.type = authTransport; + this.options = options; + this.authOptions = (options || {}).auth || {}; + } + PusherAuthorizer.prototype.composeQuery = function (socketId) { + var query = 'socket_id=' + encodeURIComponent(socketId) + + '&channel_name=' + encodeURIComponent(this.channel.name); + for (var i in this.authOptions.params) { + query += "&" + encodeURIComponent(i) + "=" + encodeURIComponent(this.authOptions.params[i]); + } + return query; + }; + PusherAuthorizer.prototype.authorize = function (socketId, callback) { + PusherAuthorizer.authorizers = PusherAuthorizer.authorizers || runtime_1["default"].getAuthorizers(); + return PusherAuthorizer.authorizers[this.type].call(this, runtime_1["default"], socketId, callback); + }; + return PusherAuthorizer; + }()); + exports.__esModule = true; + exports["default"] = PusherAuthorizer; + + +/***/ }), +/* 49 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var runtime_1 = __webpack_require__(2); + var TimelineSender = (function () { + function TimelineSender(timeline, options) { + this.timeline = timeline; + this.options = options || {}; + } + TimelineSender.prototype.send = function (encrypted, callback) { + if (this.timeline.isEmpty()) { + return; + } + this.timeline.send(runtime_1["default"].TimelineTransport.getAgent(this, encrypted), callback); + }; + return TimelineSender; + }()); + exports.__esModule = true; + exports["default"] = TimelineSender; + + +/***/ }), +/* 50 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + var private_channel_1 = __webpack_require__(51); + var logger_1 = __webpack_require__(8); + var members_1 = __webpack_require__(53); + var url_store_1 = __webpack_require__(14); + var PresenceChannel = (function (_super) { + __extends(PresenceChannel, _super); + function PresenceChannel(name, pusher) { + _super.call(this, name, pusher); + this.members = new members_1["default"](); + } + PresenceChannel.prototype.authorize = function (socketId, callback) { + var _this = this; + _super.prototype.authorize.call(this, socketId, function (error, authData) { + if (!error) { + if (authData.channel_data === undefined) { + var suffix = url_store_1["default"].buildLogSuffix("authenticationEndpoint"); + logger_1["default"].warn(("Invalid auth response for channel '" + _this.name + "',") + + ("expected 'channel_data' field. " + suffix)); + callback("Invalid auth response"); + return; + } + var channelData = JSON.parse(authData.channel_data); + _this.members.setMyID(channelData.user_id); + } + callback(error, authData); + }); + }; + PresenceChannel.prototype.handleEvent = function (event, data) { + switch (event) { + case "pusher_internal:subscription_succeeded": + this.subscriptionPending = false; + this.subscribed = true; + if (this.subscriptionCancelled) { + this.pusher.unsubscribe(this.name); + } + else { + this.members.onSubscription(data); + this.emit("pusher:subscription_succeeded", this.members); + } + break; + case "pusher_internal:member_added": + var addedMember = this.members.addMember(data); + this.emit('pusher:member_added', addedMember); + break; + case "pusher_internal:member_removed": + var removedMember = this.members.removeMember(data); + if (removedMember) { + this.emit('pusher:member_removed', removedMember); + } + break; + default: + private_channel_1["default"].prototype.handleEvent.call(this, event, data); + } + }; + PresenceChannel.prototype.disconnect = function () { + this.members.reset(); + _super.prototype.disconnect.call(this); + }; + return PresenceChannel; + }(private_channel_1["default"])); + exports.__esModule = true; + exports["default"] = PresenceChannel; + + +/***/ }), +/* 51 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + var factory_1 = __webpack_require__(43); + var channel_1 = __webpack_require__(52); + var PrivateChannel = (function (_super) { + __extends(PrivateChannel, _super); + function PrivateChannel() { + _super.apply(this, arguments); + } + PrivateChannel.prototype.authorize = function (socketId, callback) { + var authorizer = factory_1["default"].createAuthorizer(this, this.pusher.config); + return authorizer.authorize(socketId, callback); + }; + return PrivateChannel; + }(channel_1["default"])); + exports.__esModule = true; + exports["default"] = PrivateChannel; + + +/***/ }), +/* 52 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + var dispatcher_1 = __webpack_require__(24); + var Errors = __webpack_require__(31); + var logger_1 = __webpack_require__(8); + var Channel = (function (_super) { + __extends(Channel, _super); + function Channel(name, pusher) { + _super.call(this, function (event, data) { + logger_1["default"].debug('No callbacks on ' + name + ' for ' + event); + }); + this.name = name; + this.pusher = pusher; + this.subscribed = false; + this.subscriptionPending = false; + this.subscriptionCancelled = false; + } + Channel.prototype.authorize = function (socketId, callback) { + return callback(false, {}); + }; + Channel.prototype.trigger = function (event, data) { + if (event.indexOf("client-") !== 0) { + throw new Errors.BadEventName("Event '" + event + "' does not start with 'client-'"); + } + return this.pusher.send_event(event, data, this.name); + }; + Channel.prototype.disconnect = function () { + this.subscribed = false; + this.subscriptionPending = false; + }; + Channel.prototype.handleEvent = function (event, data) { + if (event.indexOf("pusher_internal:") === 0) { + if (event === "pusher_internal:subscription_succeeded") { + this.subscriptionPending = false; + this.subscribed = true; + if (this.subscriptionCancelled) { + this.pusher.unsubscribe(this.name); + } + else { + this.emit("pusher:subscription_succeeded", data); + } + } + } + else { + this.emit(event, data); + } + }; + Channel.prototype.subscribe = function () { + var _this = this; + if (this.subscribed) { + return; + } + this.subscriptionPending = true; + this.subscriptionCancelled = false; + this.authorize(this.pusher.connection.socket_id, function (error, data) { + if (error) { + _this.handleEvent('pusher:subscription_error', data); + } + else { + _this.pusher.send_event('pusher:subscribe', { + auth: data.auth, + channel_data: data.channel_data, + channel: _this.name + }); + } + }); + }; + Channel.prototype.unsubscribe = function () { + this.subscribed = false; + this.pusher.send_event('pusher:unsubscribe', { + channel: this.name + }); + }; + Channel.prototype.cancelSubscription = function () { + this.subscriptionCancelled = true; + }; + Channel.prototype.reinstateSubscription = function () { + this.subscriptionCancelled = false; + }; + return Channel; + }(dispatcher_1["default"])); + exports.__esModule = true; + exports["default"] = Channel; + + +/***/ }), +/* 53 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var Collections = __webpack_require__(9); + var Members = (function () { + function Members() { + this.reset(); + } + Members.prototype.get = function (id) { + if (Object.prototype.hasOwnProperty.call(this.members, id)) { + return { + id: id, + info: this.members[id] + }; + } + else { + return null; + } + }; + Members.prototype.each = function (callback) { + var _this = this; + Collections.objectApply(this.members, function (member, id) { + callback(_this.get(id)); + }); + }; + Members.prototype.setMyID = function (id) { + this.myID = id; + }; + Members.prototype.onSubscription = function (subscriptionData) { + this.members = subscriptionData.presence.hash; + this.count = subscriptionData.presence.count; + this.me = this.get(this.myID); + }; + Members.prototype.addMember = function (memberData) { + if (this.get(memberData.user_id) === null) { + this.count++; + } + this.members[memberData.user_id] = memberData.user_info; + return this.get(memberData.user_id); + }; + Members.prototype.removeMember = function (memberData) { + var member = this.get(memberData.user_id); + if (member) { + delete this.members[memberData.user_id]; + this.count--; + } + return member; + }; + Members.prototype.reset = function () { + this.members = {}; + this.count = 0; + this.myID = null; + this.me = null; + }; + return Members; + }()); + exports.__esModule = true; + exports["default"] = Members; + + +/***/ }), +/* 54 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + var dispatcher_1 = __webpack_require__(24); + var timers_1 = __webpack_require__(12); + var logger_1 = __webpack_require__(8); + var Collections = __webpack_require__(9); + var runtime_1 = __webpack_require__(2); + var ConnectionManager = (function (_super) { + __extends(ConnectionManager, _super); + function ConnectionManager(key, options) { + var _this = this; + _super.call(this); + this.key = key; + this.options = options || {}; + this.state = "initialized"; + this.connection = null; + this.encrypted = !!options.encrypted; + this.timeline = this.options.timeline; + this.connectionCallbacks = this.buildConnectionCallbacks(); + this.errorCallbacks = this.buildErrorCallbacks(); + this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks); + var Network = runtime_1["default"].getNetwork(); + Network.bind("online", function () { + _this.timeline.info({ netinfo: "online" }); + if (_this.state === "connecting" || _this.state === "unavailable") { + _this.retryIn(0); + } + }); + Network.bind("offline", function () { + _this.timeline.info({ netinfo: "offline" }); + if (_this.connection) { + _this.sendActivityCheck(); + } + }); + this.updateStrategy(); + } + ConnectionManager.prototype.connect = function () { + if (this.connection || this.runner) { + return; + } + if (!this.strategy.isSupported()) { + this.updateState("failed"); + return; + } + this.updateState("connecting"); + this.startConnecting(); + this.setUnavailableTimer(); + }; + ; + ConnectionManager.prototype.send = function (data) { + if (this.connection) { + return this.connection.send(data); + } + else { + return false; + } + }; + ; + ConnectionManager.prototype.send_event = function (name, data, channel) { + if (this.connection) { + return this.connection.send_event(name, data, channel); + } + else { + return false; + } + }; + ; + ConnectionManager.prototype.disconnect = function () { + this.disconnectInternally(); + this.updateState("disconnected"); + }; + ; + ConnectionManager.prototype.isEncrypted = function () { + return this.encrypted; + }; + ; + ConnectionManager.prototype.startConnecting = function () { + var _this = this; + var callback = function (error, handshake) { + if (error) { + _this.runner = _this.strategy.connect(0, callback); + } + else { + if (handshake.action === "error") { + _this.emit("error", { type: "HandshakeError", error: handshake.error }); + _this.timeline.error({ handshakeError: handshake.error }); + } + else { + _this.abortConnecting(); + _this.handshakeCallbacks[handshake.action](handshake); + } + } + }; + this.runner = this.strategy.connect(0, callback); + }; + ; + ConnectionManager.prototype.abortConnecting = function () { + if (this.runner) { + this.runner.abort(); + this.runner = null; + } + }; + ; + ConnectionManager.prototype.disconnectInternally = function () { + this.abortConnecting(); + this.clearRetryTimer(); + this.clearUnavailableTimer(); + if (this.connection) { + var connection = this.abandonConnection(); + connection.close(); + } + }; + ; + ConnectionManager.prototype.updateStrategy = function () { + this.strategy = this.options.getStrategy({ + key: this.key, + timeline: this.timeline, + encrypted: this.encrypted + }); + }; + ; + ConnectionManager.prototype.retryIn = function (delay) { + var _this = this; + this.timeline.info({ action: "retry", delay: delay }); + if (delay > 0) { + this.emit("connecting_in", Math.round(delay / 1000)); + } + this.retryTimer = new timers_1.OneOffTimer(delay || 0, function () { + _this.disconnectInternally(); + _this.connect(); + }); + }; + ; + ConnectionManager.prototype.clearRetryTimer = function () { + if (this.retryTimer) { + this.retryTimer.ensureAborted(); + this.retryTimer = null; + } + }; + ; + ConnectionManager.prototype.setUnavailableTimer = function () { + var _this = this; + this.unavailableTimer = new timers_1.OneOffTimer(this.options.unavailableTimeout, function () { + _this.updateState("unavailable"); + }); + }; + ; + ConnectionManager.prototype.clearUnavailableTimer = function () { + if (this.unavailableTimer) { + this.unavailableTimer.ensureAborted(); + } + }; + ; + ConnectionManager.prototype.sendActivityCheck = function () { + var _this = this; + this.stopActivityCheck(); + this.connection.ping(); + this.activityTimer = new timers_1.OneOffTimer(this.options.pongTimeout, function () { + _this.timeline.error({ pong_timed_out: _this.options.pongTimeout }); + _this.retryIn(0); + }); + }; + ; + ConnectionManager.prototype.resetActivityCheck = function () { + var _this = this; + this.stopActivityCheck(); + if (this.connection && !this.connection.handlesActivityChecks()) { + this.activityTimer = new timers_1.OneOffTimer(this.activityTimeout, function () { + _this.sendActivityCheck(); + }); + } + }; + ; + ConnectionManager.prototype.stopActivityCheck = function () { + if (this.activityTimer) { + this.activityTimer.ensureAborted(); + } + }; + ; + ConnectionManager.prototype.buildConnectionCallbacks = function () { + var _this = this; + return { + message: function (message) { + _this.resetActivityCheck(); + _this.emit('message', message); + }, + ping: function () { + _this.send_event('pusher:pong', {}); + }, + activity: function () { + _this.resetActivityCheck(); + }, + error: function (error) { + _this.emit("error", { type: "WebSocketError", error: error }); + }, + closed: function () { + _this.abandonConnection(); + if (_this.shouldRetry()) { + _this.retryIn(1000); + } + } + }; + }; + ; + ConnectionManager.prototype.buildHandshakeCallbacks = function (errorCallbacks) { + var _this = this; + return Collections.extend({}, errorCallbacks, { + connected: function (handshake) { + _this.activityTimeout = Math.min(_this.options.activityTimeout, handshake.activityTimeout, handshake.connection.activityTimeout || Infinity); + _this.clearUnavailableTimer(); + _this.setConnection(handshake.connection); + _this.socket_id = _this.connection.id; + _this.updateState("connected", { socket_id: _this.socket_id }); + } + }); + }; + ; + ConnectionManager.prototype.buildErrorCallbacks = function () { + var _this = this; + var withErrorEmitted = function (callback) { + return function (result) { + if (result.error) { + _this.emit("error", { type: "WebSocketError", error: result.error }); + } + callback(result); + }; + }; + return { + ssl_only: withErrorEmitted(function () { + _this.encrypted = true; + _this.updateStrategy(); + _this.retryIn(0); + }), + refused: withErrorEmitted(function () { + _this.disconnect(); + }), + backoff: withErrorEmitted(function () { + _this.retryIn(1000); + }), + retry: withErrorEmitted(function () { + _this.retryIn(0); + }) + }; + }; + ; + ConnectionManager.prototype.setConnection = function (connection) { + this.connection = connection; + for (var event in this.connectionCallbacks) { + this.connection.bind(event, this.connectionCallbacks[event]); + } + this.resetActivityCheck(); + }; + ; + ConnectionManager.prototype.abandonConnection = function () { + if (!this.connection) { + return; + } + this.stopActivityCheck(); + for (var event in this.connectionCallbacks) { + this.connection.unbind(event, this.connectionCallbacks[event]); + } + var connection = this.connection; + this.connection = null; + return connection; + }; + ConnectionManager.prototype.updateState = function (newState, data) { + var previousState = this.state; + this.state = newState; + if (previousState !== newState) { + var newStateDescription = newState; + if (newStateDescription === "connected") { + newStateDescription += " with new socket ID " + data.socket_id; + } + logger_1["default"].debug('State changed', previousState + ' -> ' + newStateDescription); + this.timeline.info({ state: newState, params: data }); + this.emit('state_change', { previous: previousState, current: newState }); + this.emit(newState, data); + } + }; + ConnectionManager.prototype.shouldRetry = function () { + return this.state === "connecting" || this.state === "connected"; + }; + return ConnectionManager; + }(dispatcher_1["default"])); + exports.__esModule = true; + exports["default"] = ConnectionManager; + + +/***/ }), +/* 55 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var Collections = __webpack_require__(9); + var factory_1 = __webpack_require__(43); + var Channels = (function () { + function Channels() { + this.channels = {}; + } + Channels.prototype.add = function (name, pusher) { + if (!this.channels[name]) { + this.channels[name] = createChannel(name, pusher); + } + return this.channels[name]; + }; + Channels.prototype.all = function () { + return Collections.values(this.channels); + }; + Channels.prototype.find = function (name) { + return this.channels[name]; + }; + Channels.prototype.remove = function (name) { + var channel = this.channels[name]; + delete this.channels[name]; + return channel; + }; + Channels.prototype.disconnect = function () { + Collections.objectApply(this.channels, function (channel) { + channel.disconnect(); + }); + }; + return Channels; + }()); + exports.__esModule = true; + exports["default"] = Channels; + function createChannel(name, pusher) { + if (name.indexOf('private-') === 0) { + return factory_1["default"].createPrivateChannel(name, pusher); + } + else if (name.indexOf('presence-') === 0) { + return factory_1["default"].createPresenceChannel(name, pusher); + } + else { + return factory_1["default"].createChannel(name, pusher); + } + } + + +/***/ }), +/* 56 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var factory_1 = __webpack_require__(43); + var util_1 = __webpack_require__(11); + var Errors = __webpack_require__(31); + var Collections = __webpack_require__(9); + var TransportStrategy = (function () { + function TransportStrategy(name, priority, transport, options) { + this.name = name; + this.priority = priority; + this.transport = transport; + this.options = options || {}; + } + TransportStrategy.prototype.isSupported = function () { + return this.transport.isSupported({ + encrypted: this.options.encrypted + }); + }; + TransportStrategy.prototype.connect = function (minPriority, callback) { + var _this = this; + if (!this.isSupported()) { + return failAttempt(new Errors.UnsupportedStrategy(), callback); + } + else if (this.priority < minPriority) { + return failAttempt(new Errors.TransportPriorityTooLow(), callback); + } + var connected = false; + var transport = this.transport.createConnection(this.name, this.priority, this.options.key, this.options); + var handshake = null; + var onInitialized = function () { + transport.unbind("initialized", onInitialized); + transport.connect(); + }; + var onOpen = function () { + handshake = factory_1["default"].createHandshake(transport, function (result) { + connected = true; + unbindListeners(); + callback(null, result); + }); + }; + var onError = function (error) { + unbindListeners(); + callback(error); + }; + var onClosed = function () { + unbindListeners(); + var serializedTransport; + serializedTransport = Collections.safeJSONStringify(transport); + callback(new Errors.TransportClosed(serializedTransport)); + }; + var unbindListeners = function () { + transport.unbind("initialized", onInitialized); + transport.unbind("open", onOpen); + transport.unbind("error", onError); + transport.unbind("closed", onClosed); + }; + transport.bind("initialized", onInitialized); + transport.bind("open", onOpen); + transport.bind("error", onError); + transport.bind("closed", onClosed); + transport.initialize(); + return { + abort: function () { + if (connected) { + return; + } + unbindListeners(); + if (handshake) { + handshake.close(); + } + else { + transport.close(); + } + }, + forceMinPriority: function (p) { + if (connected) { + return; + } + if (_this.priority < p) { + if (handshake) { + handshake.close(); + } + else { + transport.close(); + } + } + } + }; + }; + return TransportStrategy; + }()); + exports.__esModule = true; + exports["default"] = TransportStrategy; + function failAttempt(error, callback) { + util_1["default"].defer(function () { + callback(error); + }); + return { + abort: function () { }, + forceMinPriority: function () { } + }; + } + + +/***/ }), +/* 57 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var Collections = __webpack_require__(9); + var util_1 = __webpack_require__(11); + var timers_1 = __webpack_require__(12); + var SequentialStrategy = (function () { + function SequentialStrategy(strategies, options) { + this.strategies = strategies; + this.loop = Boolean(options.loop); + this.failFast = Boolean(options.failFast); + this.timeout = options.timeout; + this.timeoutLimit = options.timeoutLimit; + } + SequentialStrategy.prototype.isSupported = function () { + return Collections.any(this.strategies, util_1["default"].method("isSupported")); + }; + SequentialStrategy.prototype.connect = function (minPriority, callback) { + var _this = this; + var strategies = this.strategies; + var current = 0; + var timeout = this.timeout; + var runner = null; + var tryNextStrategy = function (error, handshake) { + if (handshake) { + callback(null, handshake); + } + else { + current = current + 1; + if (_this.loop) { + current = current % strategies.length; + } + if (current < strategies.length) { + if (timeout) { + timeout = timeout * 2; + if (_this.timeoutLimit) { + timeout = Math.min(timeout, _this.timeoutLimit); + } + } + runner = _this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: _this.failFast }, tryNextStrategy); + } + else { + callback(true); + } + } + }; + runner = this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: this.failFast }, tryNextStrategy); + return { + abort: function () { + runner.abort(); + }, + forceMinPriority: function (p) { + minPriority = p; + if (runner) { + runner.forceMinPriority(p); + } + } + }; + }; + SequentialStrategy.prototype.tryStrategy = function (strategy, minPriority, options, callback) { + var timer = null; + var runner = null; + if (options.timeout > 0) { + timer = new timers_1.OneOffTimer(options.timeout, function () { + runner.abort(); + callback(true); + }); + } + runner = strategy.connect(minPriority, function (error, handshake) { + if (error && timer && timer.isRunning() && !options.failFast) { + return; + } + if (timer) { + timer.ensureAborted(); + } + callback(error, handshake); + }); + return { + abort: function () { + if (timer) { + timer.ensureAborted(); + } + runner.abort(); + }, + forceMinPriority: function (p) { + runner.forceMinPriority(p); + } + }; + }; + return SequentialStrategy; + }()); + exports.__esModule = true; + exports["default"] = SequentialStrategy; + + +/***/ }), +/* 58 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var Collections = __webpack_require__(9); + var util_1 = __webpack_require__(11); + var BestConnectedEverStrategy = (function () { + function BestConnectedEverStrategy(strategies) { + this.strategies = strategies; + } + BestConnectedEverStrategy.prototype.isSupported = function () { + return Collections.any(this.strategies, util_1["default"].method("isSupported")); + }; + BestConnectedEverStrategy.prototype.connect = function (minPriority, callback) { + return connect(this.strategies, minPriority, function (i, runners) { + return function (error, handshake) { + runners[i].error = error; + if (error) { + if (allRunnersFailed(runners)) { + callback(true); + } + return; + } + Collections.apply(runners, function (runner) { + runner.forceMinPriority(handshake.transport.priority); + }); + callback(null, handshake); + }; + }); + }; + return BestConnectedEverStrategy; + }()); + exports.__esModule = true; + exports["default"] = BestConnectedEverStrategy; + function connect(strategies, minPriority, callbackBuilder) { + var runners = Collections.map(strategies, function (strategy, i, _, rs) { + return strategy.connect(minPriority, callbackBuilder(i, rs)); + }); + return { + abort: function () { + Collections.apply(runners, abortRunner); + }, + forceMinPriority: function (p) { + Collections.apply(runners, function (runner) { + runner.forceMinPriority(p); + }); + } + }; + } + function allRunnersFailed(runners) { + return Collections.all(runners, function (runner) { + return Boolean(runner.error); + }); + } + function abortRunner(runner) { + if (!runner.error && !runner.aborted) { + runner.abort(); + runner.aborted = true; + } + } + + +/***/ }), +/* 59 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var util_1 = __webpack_require__(11); + var runtime_1 = __webpack_require__(2); + var sequential_strategy_1 = __webpack_require__(57); + var Collections = __webpack_require__(9); + var CachedStrategy = (function () { + function CachedStrategy(strategy, transports, options) { + this.strategy = strategy; + this.transports = transports; + this.ttl = options.ttl || 1800 * 1000; + this.encrypted = options.encrypted; + this.timeline = options.timeline; + } + CachedStrategy.prototype.isSupported = function () { + return this.strategy.isSupported(); + }; + CachedStrategy.prototype.connect = function (minPriority, callback) { + var encrypted = this.encrypted; + var info = fetchTransportCache(encrypted); + var strategies = [this.strategy]; + if (info && info.timestamp + this.ttl >= util_1["default"].now()) { + var transport = this.transports[info.transport]; + if (transport) { + this.timeline.info({ + cached: true, + transport: info.transport, + latency: info.latency + }); + strategies.push(new sequential_strategy_1["default"]([transport], { + timeout: info.latency * 2 + 1000, + failFast: true + })); + } + } + var startTimestamp = util_1["default"].now(); + var runner = strategies.pop().connect(minPriority, function cb(error, handshake) { + if (error) { + flushTransportCache(encrypted); + if (strategies.length > 0) { + startTimestamp = util_1["default"].now(); + runner = strategies.pop().connect(minPriority, cb); + } + else { + callback(error); + } + } + else { + storeTransportCache(encrypted, handshake.transport.name, util_1["default"].now() - startTimestamp); + callback(null, handshake); + } + }); + return { + abort: function () { + runner.abort(); + }, + forceMinPriority: function (p) { + minPriority = p; + if (runner) { + runner.forceMinPriority(p); + } + } + }; + }; + return CachedStrategy; + }()); + exports.__esModule = true; + exports["default"] = CachedStrategy; + function getTransportCacheKey(encrypted) { + return "pusherTransport" + (encrypted ? "Encrypted" : "Unencrypted"); + } + function fetchTransportCache(encrypted) { + var storage = runtime_1["default"].getLocalStorage(); + if (storage) { + try { + var serializedCache = storage[getTransportCacheKey(encrypted)]; + if (serializedCache) { + return JSON.parse(serializedCache); + } + } + catch (e) { + flushTransportCache(encrypted); + } + } + return null; + } + function storeTransportCache(encrypted, transport, latency) { + var storage = runtime_1["default"].getLocalStorage(); + if (storage) { + try { + storage[getTransportCacheKey(encrypted)] = Collections.safeJSONStringify({ + timestamp: util_1["default"].now(), + transport: transport, + latency: latency + }); + } + catch (e) { + } + } + } + function flushTransportCache(encrypted) { + var storage = runtime_1["default"].getLocalStorage(); + if (storage) { + try { + delete storage[getTransportCacheKey(encrypted)]; + } + catch (e) { + } + } + } + + +/***/ }), +/* 60 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var timers_1 = __webpack_require__(12); + var DelayedStrategy = (function () { + function DelayedStrategy(strategy, _a) { + var number = _a.delay; + this.strategy = strategy; + this.options = { delay: number }; + } + DelayedStrategy.prototype.isSupported = function () { + return this.strategy.isSupported(); + }; + DelayedStrategy.prototype.connect = function (minPriority, callback) { + var strategy = this.strategy; + var runner; + var timer = new timers_1.OneOffTimer(this.options.delay, function () { + runner = strategy.connect(minPriority, callback); + }); + return { + abort: function () { + timer.ensureAborted(); + if (runner) { + runner.abort(); + } + }, + forceMinPriority: function (p) { + minPriority = p; + if (runner) { + runner.forceMinPriority(p); + } + } + }; + }; + return DelayedStrategy; + }()); + exports.__esModule = true; + exports["default"] = DelayedStrategy; + + +/***/ }), +/* 61 */ +/***/ (function(module, exports) { + + "use strict"; + var IfStrategy = (function () { + function IfStrategy(test, trueBranch, falseBranch) { + this.test = test; + this.trueBranch = trueBranch; + this.falseBranch = falseBranch; + } + IfStrategy.prototype.isSupported = function () { + var branch = this.test() ? this.trueBranch : this.falseBranch; + return branch.isSupported(); + }; + IfStrategy.prototype.connect = function (minPriority, callback) { + var branch = this.test() ? this.trueBranch : this.falseBranch; + return branch.connect(minPriority, callback); + }; + return IfStrategy; + }()); + exports.__esModule = true; + exports["default"] = IfStrategy; + + +/***/ }), +/* 62 */ +/***/ (function(module, exports) { + + "use strict"; + var FirstConnectedStrategy = (function () { + function FirstConnectedStrategy(strategy) { + this.strategy = strategy; + } + FirstConnectedStrategy.prototype.isSupported = function () { + return this.strategy.isSupported(); + }; + FirstConnectedStrategy.prototype.connect = function (minPriority, callback) { + var runner = this.strategy.connect(minPriority, function (error, handshake) { + if (handshake) { + runner.abort(); + } + callback(error, handshake); + }); + return runner; + }; + return FirstConnectedStrategy; + }()); + exports.__esModule = true; + exports["default"] = FirstConnectedStrategy; + + +/***/ }), +/* 63 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + var defaults_1 = __webpack_require__(5); + exports.getGlobalConfig = function () { + return { + wsHost: defaults_1["default"].host, + wsPort: defaults_1["default"].ws_port, + wssPort: defaults_1["default"].wss_port, + wsPath: defaults_1["default"].ws_path, + httpHost: defaults_1["default"].sockjs_host, + httpPort: defaults_1["default"].sockjs_http_port, + httpsPort: defaults_1["default"].sockjs_https_port, + httpPath: defaults_1["default"].sockjs_path, + statsHost: defaults_1["default"].stats_host, + authEndpoint: defaults_1["default"].channel_auth_endpoint, + authTransport: defaults_1["default"].channel_auth_transport, + activity_timeout: defaults_1["default"].activity_timeout, + pong_timeout: defaults_1["default"].pong_timeout, + unavailable_timeout: defaults_1["default"].unavailable_timeout + }; + }; + exports.getClusterConfig = function (clusterName) { + return { + wsHost: "ws-" + clusterName + ".pusher.com", + httpHost: "sockjs-" + clusterName + ".pusher.com" + }; + }; + + +/***/ }) +/******/ ]) +}); +; + +/***/ }), +/* 39 */ /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;var require;var require;/*! @@ -39616,7 +44609,7 @@ S2.define('jquery.select2',[ /***/ }), -/* 38 */ +/* 40 */ /***/ (function(module, exports, __webpack_require__) { /*! @@ -39627,10 +44620,10 @@ S2.define('jquery.select2',[ * Copyright (C) 2017 Hakim El Hattab, http://hakim.se */ -!function(t,e){"use strict"; true?module.exports=e(__webpack_require__(39)):"function"==typeof define&&define.amd?define(["spin"],e):t.Ladda=e(t.Spinner)}(this,function(t){"use strict";var e=[];function a(a){if(void 0!==a){if(/ladda-button/i.test(a.className)||(a.className+=" ladda-button"),a.hasAttribute("data-style")||a.setAttribute("data-style","expand-right"),!a.querySelector(".ladda-label")){var u=document.createElement("span");u.className="ladda-label",n=a,i=u,(r=document.createRange()).selectNodeContents(n),r.surroundContents(i),n.appendChild(i)}var n,i,r,d,o,s=a.querySelector(".ladda-spinner");s||((s=document.createElement("span")).className="ladda-spinner"),a.appendChild(s);var F={start:function(){return d||(d=function(e){var a,u,n=e.offsetHeight;0===n&&(n=parseFloat(window.getComputedStyle(e).height));n>32&&(n*=.8);e.hasAttribute("data-spinner-size")&&(n=parseInt(e.getAttribute("data-spinner-size"),10));e.hasAttribute("data-spinner-color")&&(a=e.getAttribute("data-spinner-color"));e.hasAttribute("data-spinner-lines")&&(u=parseInt(e.getAttribute("data-spinner-lines"),10));var i=.2*n;return new t({color:a||"#fff",lines:u||12,radius:i,length:.6*i,width:i<7?2:3,zIndex:"auto",top:"auto",left:"auto",className:""})}(a)),a.disabled=!0,a.setAttribute("data-loading",""),clearTimeout(o),d.spin(s),this.setProgress(0),this},startAfter:function(t){return clearTimeout(o),o=setTimeout(function(){F.start()},t),this},stop:function(){return F.isLoading()&&(a.disabled=!1,a.removeAttribute("data-loading")),clearTimeout(o),d&&(o=setTimeout(function(){d.stop()},1e3)),this},toggle:function(){return this.isLoading()?this.stop():this.start()},setProgress:function(t){t=Math.max(Math.min(t,1),0);var e=a.querySelector(".ladda-progress");0===t&&e&&e.parentNode?e.parentNode.removeChild(e):(e||((e=document.createElement("div")).className="ladda-progress",a.appendChild(e)),e.style.width=(t||0)*a.offsetWidth+"px")},enable:function(){return this.stop()},disable:function(){return this.stop(),a.disabled=!0,this},isLoading:function(){return a.hasAttribute("data-loading")},remove:function(){clearTimeout(o),a.disabled=!1,a.removeAttribute("data-loading"),d&&(d.stop(),d=null),e.splice(e.indexOf(F),1)}};return e.push(F),F}console.warn("Ladda button target must be defined.")}function u(t,e){if("function"==typeof t.addEventListener){var u=a(t),n=-1;t.addEventListener("click",function(){var a,i,r=!0,d=function(t,e){for(;t.parentNode&&t.tagName!==e;)t=t.parentNode;return e===t.tagName?t:void 0}(t,"FORM");if(void 0!==d&&!d.hasAttribute("novalidate"))if("function"==typeof d.checkValidity)r=d.checkValidity();else for(var o=(a=d,i=[],["input","textarea","select"].forEach(function(t){for(var e=a.getElementsByTagName(t),u=0;u32&&(n*=.8);e.hasAttribute("data-spinner-size")&&(n=parseInt(e.getAttribute("data-spinner-size"),10));e.hasAttribute("data-spinner-color")&&(a=e.getAttribute("data-spinner-color"));e.hasAttribute("data-spinner-lines")&&(u=parseInt(e.getAttribute("data-spinner-lines"),10));var i=.2*n;return new t({color:a||"#fff",lines:u||12,radius:i,length:.6*i,width:i<7?2:3,zIndex:"auto",top:"auto",left:"auto",className:""})}(a)),a.disabled=!0,a.setAttribute("data-loading",""),clearTimeout(o),d.spin(s),this.setProgress(0),this},startAfter:function(t){return clearTimeout(o),o=setTimeout(function(){F.start()},t),this},stop:function(){return F.isLoading()&&(a.disabled=!1,a.removeAttribute("data-loading")),clearTimeout(o),d&&(o=setTimeout(function(){d.stop()},1e3)),this},toggle:function(){return this.isLoading()?this.stop():this.start()},setProgress:function(t){t=Math.max(Math.min(t,1),0);var e=a.querySelector(".ladda-progress");0===t&&e&&e.parentNode?e.parentNode.removeChild(e):(e||((e=document.createElement("div")).className="ladda-progress",a.appendChild(e)),e.style.width=(t||0)*a.offsetWidth+"px")},enable:function(){return this.stop()},disable:function(){return this.stop(),a.disabled=!0,this},isLoading:function(){return a.hasAttribute("data-loading")},remove:function(){clearTimeout(o),a.disabled=!1,a.removeAttribute("data-loading"),d&&(d.stop(),d=null),e.splice(e.indexOf(F),1)}};return e.push(F),F}console.warn("Ladda button target must be defined.")}function u(t,e){if("function"==typeof t.addEventListener){var u=a(t),n=-1;t.addEventListener("click",function(){var a,i,r=!0,d=function(t,e){for(;t.parentNode&&t.tagName!==e;)t=t.parentNode;return e===t.tagName?t:void 0}(t,"FORM");if(void 0!==d&&!d.hasAttribute("novalidate"))if("function"==typeof d.checkValidity)r=d.checkValidity();else for(var o=(a=d,i=[],["input","textarea","select"].forEach(function(t){for(var e=a.getElementsByTagName(t),u=0;u1?l.options.decimal+n[1]:"",l.options.useGrouping){for(i="",r=0,o=t.length;rl.endVal,l.frameVal=l.startVal,l.initialized=!0,!0):(l.error="[CountUp] startVal ("+n+") or endVal ("+t+") is not a number",!1)):(l.error="[CountUp] target is null or undefined",!1))},l.printValue=function(a){var n=l.options.formattingFn(a);"INPUT"===l.d.tagName?this.d.value=n:"text"===l.d.tagName||"tspan"===l.d.tagName?this.d.textContent=n:this.d.innerHTML=n},l.count=function(a){l.startTime||(l.startTime=a),l.timestamp=a;var n=a-l.startTime;l.remaining=l.duration-n,l.options.useEasing?l.countDown?l.frameVal=l.startVal-l.options.easingFn(n,0,l.startVal-l.endVal,l.duration):l.frameVal=l.options.easingFn(n,l.startVal,l.endVal-l.startVal,l.duration):l.countDown?l.frameVal=l.startVal-(l.startVal-l.endVal)*(n/l.duration):l.frameVal=l.startVal+(l.endVal-l.startVal)*(n/l.duration),l.countDown?l.frameVal=l.frameVall.endVal?l.endVal:l.frameVal,l.frameVal=Math.round(l.frameVal*l.dec)/l.dec,l.printValue(l.frameVal),nl.endVal,l.rAF=requestAnimationFrame(l.count))}},l.initialize()&&l.printValue(l.startVal)};return e}); /***/ }), -/* 43 */ +/* 45 */ /***/ (function(module, exports) { var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; @@ -47896,7 +52889,7 @@ wbbdebug = true; })(jQuery); /***/ }), -/* 44 */ +/* 46 */ /***/ (function(module, exports, __webpack_require__) { !function t(e,r){ true?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.Raphael=r():e.Raphael=r()}(this,function(){return function(t){function e(i){if(r[i])return r[i].exports;var n=r[i]={exports:{},id:i,loaded:!1};return t[i].call(n.exports,n,n.exports,e),n.loaded=!0,n.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){var i,n;i=[r(1),r(3),r(4)],n=function(t){return t}.apply(e,i),!(void 0!==n&&(t.exports=n))},function(t,e,r){var i,n;i=[r(2)],n=function(t){function e(r){if(e.is(r,"function"))return w?r():t.on("raphael.DOMload",r);if(e.is(r,Q))return e._engine.create[z](e,r.splice(0,3+e.is(r[0],$))).add(r);var i=Array.prototype.slice.call(arguments,0);if(e.is(i[i.length-1],"function")){var n=i.pop();return w?n.call(e._engine.create[z](e,i)):t.on("raphael.DOMload",function(){n.call(e._engine.create[z](e,i))})}return e._engine.create[z](e,arguments)}function r(t){if("function"==typeof t||Object(t)!==t)return t;var e=new t.constructor;for(var i in t)t[A](i)&&(e[i]=r(t[i]));return e}function i(t,e){for(var r=0,i=t.length;r=1e3&&delete o[l.shift()],l.push(s),o[s]=t[z](e,a),r?r(o[s]):o[s])}return n}function a(){return this.hex}function s(t,e){for(var r=[],i=0,n=t.length;n-2*!e>i;i+=2){var a=[{x:+t[i-2],y:+t[i-1]},{x:+t[i],y:+t[i+1]},{x:+t[i+2],y:+t[i+3]},{x:+t[i+4],y:+t[i+5]}];e?i?n-4==i?a[3]={x:+t[0],y:+t[1]}:n-2==i&&(a[2]={x:+t[0],y:+t[1]},a[3]={x:+t[2],y:+t[3]}):a[0]={x:+t[n-2],y:+t[n-1]}:n-4==i?a[3]=a[2]:i||(a[0]={x:+t[i],y:+t[i+1]}),r.push(["C",(-a[0].x+6*a[1].x+a[2].x)/6,(-a[0].y+6*a[1].y+a[2].y)/6,(a[1].x+6*a[2].x-a[3].x)/6,(a[1].y+6*a[2].y-a[3].y)/6,a[2].x,a[2].y])}return r}function o(t,e,r,i,n){var a=-3*e+9*r-9*i+3*n,s=t*a+6*e-12*r+6*i;return t*s-3*e+3*r}function l(t,e,r,i,n,a,s,l,h){null==h&&(h=1),h=h>1?1:h<0?0:h;for(var u=h/2,c=12,f=[-.1252,.1252,-.3678,.3678,-.5873,.5873,-.7699,.7699,-.9041,.9041,-.9816,.9816],p=[.2491,.2491,.2335,.2335,.2032,.2032,.1601,.1601,.1069,.1069,.0472,.0472],d=0,g=0;gd;)c/=2,f+=(pW(n,s)||W(e,i)W(a,o))){var l=(t*i-e*r)*(n-s)-(t-r)*(n*o-a*s),h=(t*i-e*r)*(a-o)-(e-i)*(n*o-a*s),u=(t-r)*(a-o)-(e-i)*(n-s);if(u){var c=l/u,f=h/u,p=+c.toFixed(2),d=+f.toFixed(2);if(!(p<+G(t,r).toFixed(2)||p>+W(t,r).toFixed(2)||p<+G(n,s).toFixed(2)||p>+W(n,s).toFixed(2)||d<+G(e,i).toFixed(2)||d>+W(e,i).toFixed(2)||d<+G(a,o).toFixed(2)||d>+W(a,o).toFixed(2)))return{x:c,y:f}}}}function c(t,e){return p(t,e)}function f(t,e){return p(t,e,1)}function p(t,r,i){var n=e.bezierBBox(t),a=e.bezierBBox(r);if(!e.isBBoxIntersect(n,a))return i?0:[];for(var s=l.apply(0,t),o=l.apply(0,r),h=W(~~(s/5),1),c=W(~~(o/5),1),f=[],p=[],d={},g=i?0:[],v=0;v=0&&S<=1.001&&A>=0&&A<=1.001&&(i?g++:g.push({x:C.x,y:C.y,t1:G(S,1),t2:G(A,1)}))}}return g}function d(t,r,i){t=e._path2curve(t),r=e._path2curve(r);for(var n,a,s,o,l,h,u,c,f,d,g=i?0:[],v=0,x=t.length;vi)return i;for(;ra?r=n:i=n,n=(i-r)/2+r}return n}var h=3*e,u=3*(i-e)-h,c=1-h-u,f=3*r,p=3*(n-r)-f,d=1-f-p;return o(t,1/(200*a))}function m(t,e){var r=[],i={};if(this.ms=e,this.times=1,t){for(var n in t)t[A](n)&&(i[ht(n)]=t[n],r.push(ht(n)));r.sort(Bt)}this.anim=i,this.top=r[r.length-1],this.percents=r}function b(r,i,n,a,s,o){n=ht(n);var l,h,u,c=[],f,p,d,v=r.ms,x={},m={},b={};if(a)for(w=0,B=Ee.length;wa*r.top){n=r.percents[w],p=r.percents[w-1]||0,v=v/r.top*(n-p),f=r.percents[w+1],l=r.anim[n];break}a&&i.attr(r.anim[r.percents[w]])}if(l){if(h)h.initstatus=a,h.start=new Date-h.ms*a;else{for(var C in l)if(l[A](C)&&(pt[A](C)||i.paper.customAttributes[A](C)))switch(x[C]=i.attr(C),null==x[C]&&(x[C]=ft[C]),m[C]=l[C],pt[C]){case $:b[C]=(m[C]-x[C])/v;break;case"colour":x[C]=e.getRGB(x[C]);var S=e.getRGB(m[C]);b[C]={r:(S.r-x[C].r)/v,g:(S.g-x[C].g)/v,b:(S.b-x[C].b)/v};break;case"path":var T=Qt(x[C],m[C]),E=T[1];for(x[C]=T[0],b[C]=[],w=0,B=x[C].length;w',Lt=Nt.firstChild,Lt.style.behavior="url(#default#VML)",!Lt||"object"!=typeof Lt.adj)return e.type=R;Nt=null}e.svg=!(e.vml="VML"==e.type),e._Paper=M,e.fn=N=M.prototype=e.prototype,e._id=0,e.is=function(t,e){return e=O.call(e),"finite"==e?!at[A](+t):"array"==e?t instanceof Array:"null"==e&&null===t||e==typeof t&&null!==t||"object"==e&&t===Object(t)||"array"==e&&Array.isArray&&Array.isArray(t)||tt.call(t).slice(8,-1).toLowerCase()==e},e.angle=function(t,r,i,n,a,s){if(null==a){var o=t-i,l=r-n;return o||l?(180+180*Y.atan2(-l,-o)/U+360)%360:0}return e.angle(t,r,a,s)-e.angle(i,n,a,s)},e.rad=function(t){return t%360*U/180},e.deg=function(t){return Math.round(180*t/U%360*1e3)/1e3},e.snapTo=function(t,r,i){if(i=e.is(i,"finite")?i:10,e.is(t,Q)){for(var n=t.length;n--;)if(H(t[n]-r)<=i)return t[n]}else{t=+t;var a=r%t;if(at-i)return r-a+t}return r};var zt=e.createUUID=function(t,e){return function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(t,e).toUpperCase()}}(/[xy]/g,function(t){var e=16*Y.random()|0,r="x"==t?e:3&e|8;return r.toString(16)});e.setWindow=function(r){t("raphael.setWindow",e,T.win,r),T.win=r,T.doc=T.win.document,e._engine.initWin&&e._engine.initWin(T.win)};var Pt=function(t){if(e.vml){var r=/^\s+|\s+$/g,i;try{var a=new ActiveXObject("htmlfile");a.write(""),a.close(),i=a.body}catch(s){i=createPopup().document.body}var o=i.createTextRange();Pt=n(function(t){try{i.style.color=I(t).replace(r,R);var e=o.queryCommandValue("ForeColor");return e=(255&e)<<16|65280&e|(16711680&e)>>>16,"#"+("000000"+e.toString(16)).slice(-6)}catch(n){return"none"}})}else{var l=T.doc.createElement("i");l.title="Raphaël Colour Picker",l.style.display="none",T.doc.body.appendChild(l),Pt=n(function(t){return l.style.color=t,T.doc.defaultView.getComputedStyle(l,R).getPropertyValue("color")})}return Pt(t)},Ft=function(){return"hsb("+[this.h,this.s,this.b]+")"},Rt=function(){return"hsl("+[this.h,this.s,this.l]+")"},jt=function(){return this.hex},It=function(t,r,i){if(null==r&&e.is(t,"object")&&"r"in t&&"g"in t&&"b"in t&&(i=t.b,r=t.g,t=t.r),null==r&&e.is(t,Z)){var n=e.getRGB(t);t=n.r,r=n.g,i=n.b}return(t>1||r>1||i>1)&&(t/=255,r/=255,i/=255),[t,r,i]},qt=function(t,r,i,n){t*=255,r*=255,i*=255;var a={r:t,g:r,b:i,hex:e.rgb(t,r,i),toString:jt};return e.is(n,"finite")&&(a.opacity=n),a};e.color=function(t){var r;return e.is(t,"object")&&"h"in t&&"s"in t&&"b"in t?(r=e.hsb2rgb(t),t.r=r.r,t.g=r.g,t.b=r.b,t.hex=r.hex):e.is(t,"object")&&"h"in t&&"s"in t&&"l"in t?(r=e.hsl2rgb(t),t.r=r.r,t.g=r.g,t.b=r.b,t.hex=r.hex):(e.is(t,"string")&&(t=e.getRGB(t)),e.is(t,"object")&&"r"in t&&"g"in t&&"b"in t?(r=e.rgb2hsl(t),t.h=r.h,t.s=r.s,t.l=r.l,r=e.rgb2hsb(t),t.v=r.b):(t={hex:"none"},t.r=t.g=t.b=t.h=t.s=t.v=t.l=-1)),t.toString=jt,t},e.hsb2rgb=function(t,e,r,i){this.is(t,"object")&&"h"in t&&"s"in t&&"b"in t&&(r=t.b,e=t.s,i=t.o,t=t.h),t*=360;var n,a,s,o,l;return t=t%360/60,l=r*e,o=l*(1-H(t%2-1)),n=a=s=r-l,t=~~t,n+=[l,o,0,0,o,l][t],a+=[o,l,l,o,0,0][t],s+=[0,0,o,l,l,o][t],qt(n,a,s,i)},e.hsl2rgb=function(t,e,r,i){this.is(t,"object")&&"h"in t&&"s"in t&&"l"in t&&(r=t.l,e=t.s,t=t.h),(t>1||e>1||r>1)&&(t/=360,e/=100,r/=100),t*=360;var n,a,s,o,l;return t=t%360/60,l=2*e*(r<.5?r:1-r),o=l*(1-H(t%2-1)),n=a=s=r-l/2,t=~~t,n+=[l,o,0,0,o,l][t],a+=[o,l,l,o,0,0][t],s+=[0,0,o,l,l,o][t],qt(n,a,s,i)},e.rgb2hsb=function(t,e,r){r=It(t,e,r),t=r[0],e=r[1],r=r[2];var i,n,a,s;return a=W(t,e,r),s=a-G(t,e,r),i=0==s?null:a==t?(e-r)/s:a==e?(r-t)/s+2:(t-e)/s+4,i=(i+360)%6*60/360,n=0==s?0:s/a,{h:i,s:n,b:a,toString:Ft}},e.rgb2hsl=function(t,e,r){r=It(t,e,r),t=r[0],e=r[1],r=r[2];var i,n,a,s,o,l;return s=W(t,e,r),o=G(t,e,r),l=s-o,i=0==l?null:s==t?(e-r)/l:s==e?(r-t)/l+2:(t-e)/l+4,i=(i+360)%6*60/360,a=(s+o)/2,n=0==l?0:a<.5?l/(2*a):l/(2-2*a),{h:i,s:n,l:a,toString:Rt}},e._path2string=function(){return this.join(",").replace(xt,"$1")};var Dt=e._preload=function(t,e){var r=T.doc.createElement("img");r.style.cssText="position:absolute;left:-9999em;top:-9999em",r.onload=function(){e.call(this),this.onload=null,T.doc.body.removeChild(this)},r.onerror=function(){T.doc.body.removeChild(this)},T.doc.body.appendChild(r),r.src=t};e.getRGB=n(function(t){if(!t||(t=I(t)).indexOf("-")+1)return{r:-1,g:-1,b:-1,hex:"none",error:1,toString:a};if("none"==t)return{r:-1,g:-1,b:-1,hex:"none",toString:a};!(vt[A](t.toLowerCase().substring(0,2))||"#"==t.charAt())&&(t=Pt(t));var r,i,n,s,o,l,h,u=t.match(nt);return u?(u[2]&&(s=ut(u[2].substring(5),16),n=ut(u[2].substring(3,5),16),i=ut(u[2].substring(1,3),16)),u[3]&&(s=ut((l=u[3].charAt(3))+l,16),n=ut((l=u[3].charAt(2))+l,16),i=ut((l=u[3].charAt(1))+l,16)),u[4]&&(h=u[4][q](gt),i=ht(h[0]),"%"==h[0].slice(-1)&&(i*=2.55),n=ht(h[1]),"%"==h[1].slice(-1)&&(n*=2.55),s=ht(h[2]),"%"==h[2].slice(-1)&&(s*=2.55),"rgba"==u[1].toLowerCase().slice(0,4)&&(o=ht(h[3])),h[3]&&"%"==h[3].slice(-1)&&(o/=100)),u[5]?(h=u[5][q](gt),i=ht(h[0]),"%"==h[0].slice(-1)&&(i*=2.55),n=ht(h[1]),"%"==h[1].slice(-1)&&(n*=2.55),s=ht(h[2]),"%"==h[2].slice(-1)&&(s*=2.55),("deg"==h[0].slice(-3)||"°"==h[0].slice(-1))&&(i/=360),"hsba"==u[1].toLowerCase().slice(0,4)&&(o=ht(h[3])),h[3]&&"%"==h[3].slice(-1)&&(o/=100),e.hsb2rgb(i,n,s,o)):u[6]?(h=u[6][q](gt),i=ht(h[0]),"%"==h[0].slice(-1)&&(i*=2.55),n=ht(h[1]),"%"==h[1].slice(-1)&&(n*=2.55),s=ht(h[2]),"%"==h[2].slice(-1)&&(s*=2.55),("deg"==h[0].slice(-3)||"°"==h[0].slice(-1))&&(i/=360),"hsla"==u[1].toLowerCase().slice(0,4)&&(o=ht(h[3])),h[3]&&"%"==h[3].slice(-1)&&(o/=100),e.hsl2rgb(i,n,s,o)):(u={r:i,g:n,b:s,toString:a},u.hex="#"+(16777216|s|n<<8|i<<16).toString(16).slice(1),e.is(o,"finite")&&(u.opacity=o),u)):{r:-1,g:-1,b:-1,hex:"none",error:1,toString:a}},e),e.hsb=n(function(t,r,i){return e.hsb2rgb(t,r,i).hex}),e.hsl=n(function(t,r,i){return e.hsl2rgb(t,r,i).hex}),e.rgb=n(function(t,e,r){function i(t){return t+.5|0}return"#"+(16777216|i(r)|i(e)<<8|i(t)<<16).toString(16).slice(1)}),e.getColor=function(t){var e=this.getColor.start=this.getColor.start||{h:0,s:1,b:t||.75},r=this.hsb2rgb(e.h,e.s,e.b);return e.h+=.075,e.h>1&&(e.h=0,e.s-=.2,e.s<=0&&(this.getColor.start={h:0,s:1,b:e.b})),r.hex},e.getColor.reset=function(){delete this.start},e.parsePathString=function(t){if(!t)return null;var r=Vt(t);if(r.arr)return Yt(r.arr);var i={a:7,c:6,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,z:0},n=[];return e.is(t,Q)&&e.is(t[0],Q)&&(n=Yt(t)),n.length||I(t).replace(yt,function(t,e,r){var a=[],s=e.toLowerCase();if(r.replace(bt,function(t,e){e&&a.push(+e)}),"m"==s&&a.length>2&&(n.push([e][P](a.splice(0,2))),s="l",e="m"==e?"l":"L"),"r"==s)n.push([e][P](a));else for(;a.length>=i[s]&&(n.push([e][P](a.splice(0,i[s]))),i[s]););}),n.toString=e._path2string,r.arr=Yt(n),n},e.parseTransformString=n(function(t){if(!t)return null;var r={r:3,s:4,t:2,m:6},i=[];return e.is(t,Q)&&e.is(t[0],Q)&&(i=Yt(t)),i.length||I(t).replace(mt,function(t,e,r){var n=[],a=O.call(e);r.replace(bt,function(t,e){e&&n.push(+e)}),i.push([e][P](n))}),i.toString=e._path2string,i});var Vt=function(t){var e=Vt.ps=Vt.ps||{};return e[t]?e[t].sleep=100:e[t]={sleep:100},setTimeout(function(){for(var r in e)e[A](r)&&r!=t&&(e[r].sleep--,!e[r].sleep&&delete e[r])}),e[t]};e.findDotsAtSegment=function(t,e,r,i,n,a,s,o,l){var h=1-l,u=X(h,3),c=X(h,2),f=l*l,p=f*l,d=u*t+3*c*l*r+3*h*l*l*n+p*s,g=u*e+3*c*l*i+3*h*l*l*a+p*o,v=t+2*l*(r-t)+f*(n-2*r+t),x=e+2*l*(i-e)+f*(a-2*i+e),y=r+2*l*(n-r)+f*(s-2*n+r),m=i+2*l*(a-i)+f*(o-2*a+i),b=h*t+l*r,_=h*e+l*i,w=h*n+l*s,k=h*a+l*o,B=90-180*Y.atan2(v-y,x-m)/U;return(v>y||x=t.x&&e<=t.x2&&r>=t.y&&r<=t.y2},e.isBBoxIntersect=function(t,r){var i=e.isPointInsideBBox;return i(r,t.x,t.y)||i(r,t.x2,t.y)||i(r,t.x,t.y2)||i(r,t.x2,t.y2)||i(t,r.x,r.y)||i(t,r.x2,r.y)||i(t,r.x,r.y2)||i(t,r.x2,r.y2)||(t.xr.x||r.xt.x)&&(t.yr.y||r.yt.y)},e.pathIntersection=function(t,e){return d(t,e)},e.pathIntersectionNumber=function(t,e){return d(t,e,1)},e.isPointInsidePath=function(t,r,i){var n=e.pathBBox(t);return e.isPointInsideBBox(n,r,i)&&d(t,[["M",r,i],["H",n.x2+10]],1)%2==1},e._removedFactory=function(e){return function(){t("raphael.log",null,"Raphaël: you are calling to method “"+e+"” of removed object",e)}};var Ot=e.pathBBox=function(t){var e=Vt(t);if(e.bbox)return r(e.bbox);if(!t)return{x:0,y:0,width:0,height:0,x2:0,y2:0};t=Qt(t);for(var i=0,n=0,a=[],s=[],o,l=0,h=t.length;l1&&(b=Y.sqrt(b),r=b*r,i=b*i);var _=r*r,w=i*i,k=(s==o?-1:1)*Y.sqrt(H((_*w-_*m*m-w*y*y)/(_*m*m+w*y*y))),B=k*r*m/i+(t+l)/2,C=k*-i*y/r+(e+h)/2,S=Y.asin(((e-C)/i).toFixed(9)),A=Y.asin(((h-C)/i).toFixed(9));S=tA&&(S-=2*U),!o&&A>S&&(A-=2*U)}var T=A-S;if(H(T)>c){var E=A,M=l,N=h;A=S+c*(o&&A>S?1:-1),l=B+r*Y.cos(A),h=C+i*Y.sin(A),p=Ut(l,h,r,i,a,0,o,M,N,[A,E,B,C])}T=A-S;var L=Y.cos(S),z=Y.sin(S),F=Y.cos(A),R=Y.sin(A),j=Y.tan(T/4),I=4/3*r*j,D=4/3*i*j,V=[t,e],O=[t+I*z,e-D*L],W=[l+I*R,h-D*F],G=[l,h];if(O[0]=2*V[0]-O[0],O[1]=2*V[1]-O[1],u)return[O,W,G][P](p);p=[O,W,G][P](p).join()[q](",");for(var X=[],$=0,Z=p.length;$"1e12"&&(c=.5),H(f)>"1e12"&&(f=.5),c>0&&c<1&&(g=$t(t,e,r,i,n,a,s,o,c),d.push(g.x),p.push(g.y)),f>0&&f<1&&(g=$t(t,e,r,i,n,a,s,o,f),d.push(g.x),p.push(g.y)),l=a-2*i+e-(o-2*a+i),h=2*(i-e)-2*(a-i),u=e-i,c=(-h+Y.sqrt(h*h-4*l*u))/2/l,f=(-h-Y.sqrt(h*h-4*l*u))/2/l,H(c)>"1e12"&&(c=.5),H(f)>"1e12"&&(f=.5),c>0&&c<1&&(g=$t(t,e,r,i,n,a,s,o,c),d.push(g.x),p.push(g.y)),f>0&&f<1&&(g=$t(t,e,r,i,n,a,s,o,f),d.push(g.x),p.push(g.y)),{min:{x:G[z](0,d),y:G[z](0,p)},max:{x:W[z](0,d),y:W[z](0,p)}}}),Qt=e._path2curve=n(function(t,e){var r=!e&&Vt(t);if(!e&&r.curve)return Yt(r.curve);for(var i=Gt(t),n=e&&Gt(e),a={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},s={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},o=(function(t,e,r){var i,n,a={T:1,Q:1};if(!t)return["C",e.x,e.y,e.x,e.y,e.x,e.y];switch(!(t[0]in a)&&(e.qx=e.qy=null),t[0]){case"M":e.X=t[1],e.Y=t[2];break;case"A":t=["C"][P](Ut[z](0,[e.x,e.y][P](t.slice(1))));break;case"S":"C"==r||"S"==r?(i=2*e.x-e.bx,n=2*e.y-e.by):(i=e.x,n=e.y),t=["C",i,n][P](t.slice(1));break;case"T":"Q"==r||"T"==r?(e.qx=2*e.x-e.qx,e.qy=2*e.y-e.qy):(e.qx=e.x,e.qy=e.y),t=["C"][P](Xt(e.x,e.y,e.qx,e.qy,t[1],t[2]));break;case"Q":e.qx=t[1],e.qy=t[2],t=["C"][P](Xt(e.x,e.y,t[1],t[2],t[3],t[4]));break;case"L":t=["C"][P](Ht(e.x,e.y,t[1],t[2]));break;case"H":t=["C"][P](Ht(e.x,e.y,t[1],e.y));break;case"V":t=["C"][P](Ht(e.x,e.y,e.x,t[1]));break;case"Z":t=["C"][P](Ht(e.x,e.y,e.X,e.Y))}return t}),l=function(t,e){if(t[e].length>7){t[e].shift();for(var r=t[e];r.length;)u[e]="A",n&&(c[e]="A"),t.splice(e++,0,["C"][P](r.splice(0,6)));t.splice(e,1),g=W(i.length,n&&n.length||0)}},h=function(t,e,r,a,s){t&&e&&"M"==t[s][0]&&"M"!=e[s][0]&&(e.splice(s,0,["M",a.x,a.y]),r.bx=0,r.by=0,r.x=t[s][1],r.y=t[s][2],g=W(i.length,n&&n.length||0))},u=[],c=[],f="",p="",d=0,g=W(i.length,n&&n.length||0);d1?z.opacity/100:z.opacity});case"stroke":z=t.getRGB(g),l.setAttribute(d,z.hex),"stroke"==d&&z[e]("opacity")&&v(l,{"stroke-opacity":z.opacity>1?z.opacity/100:z.opacity}),"stroke"==d&&i._.arrows&&("startString"in i._.arrows&&_(i,i._.arrows.startString),"endString"in i._.arrows&&_(i,i._.arrows.endString,1));break;case"gradient":("circle"==i.type||"ellipse"==i.type||"r"!=r(g).charAt())&&x(i,g);break;case"opacity":u.gradient&&!u[e]("stroke-opacity")&&v(l,{"stroke-opacity":g>1?g/100:g});case"fill-opacity":if(u.gradient){P=t._g.doc.getElementById(l.getAttribute("fill").replace(/^url\(#|\)$/g,c)),P&&(F=P.getElementsByTagName("stop"),v(F[F.length-1],{"stop-opacity":g}));break}default:"font-size"==d&&(g=n(g,10)+"px");var R=d.replace(/(\-.)/g,function(t){return t.substring(1).toUpperCase()});l.style[R]=g,i._.dirty=1,l.setAttribute(d,g)}}S(i,a),l.style.visibility=f},C=1.2,S=function(i,a){if("text"==i.type&&(a[e]("text")||a[e]("font")||a[e]("font-size")||a[e]("x")||a[e]("y"))){var s=i.attrs,o=i.node,l=o.firstChild?n(t._g.doc.defaultView.getComputedStyle(o.firstChild,c).getPropertyValue("font-size"),10):10;if(a[e]("text")){for(s.text=a.text;o.firstChild;)o.removeChild(o.firstChild);for(var h=r(a.text).split("\n"),u=[],f,p=0,d=h.length;p"));var Z=X.getBoundingClientRect();m.W=f.w=(Z.right-Z.left)/U,m.H=f.h=(Z.bottom-Z.top)/U,m.X=f.x,m.Y=f.y+m.H/2,("x"in l||"y"in l)&&(m.path.v=t.format("m{0},{1}l{2},{1}",a(f.x*b),a(f.y*b),a(f.x*b)+1));for(var Q=["x","y","text","font","font-family","font-weight","font-style","font-size"],J=0,K=Q.length;J.25&&(r=n.sqrt(.25-l(e-.5,2))*(2*(r>.5)-1)+.5),f=e+p+r),d}),a=a.split(/\s*\-\s*/),"linear"==c){var g=a.shift();if(g=-i(g),isNaN(g))return null}var v=t._parseDots(a);if(!v)return null;if(e=e.shape||e.node,v.length){e.removeChild(s),s.on=!0,s.method="none",s.color=v[0].color,s.color2=v[v.length-1].color;for(var x=[],y=0,m=v.length;y')}}catch(r){N=function(t){return e.createElement("<"+t+' xmlns="urn:schemas-microsoft.com:vml" class="rvml">')}}},t._engine.initWin(t._g.win),t._engine.create=function(){var e=t._getContainer.apply(0,arguments),r=e.container,i=e.height,n,a=e.width,s=e.x,o=e.y;if(!r)throw new Error("VML container not found.");var l=new t._Paper,h=l.canvas=t._g.doc.createElement("div"),u=h.style;return s=s||0,o=o||0,a=a||512,i=i||342,l.width=a,l.height=i,a==+a&&(a+="px"),i==+i&&(i+="px"),l.coordsize=1e3*b+p+1e3*b,l.coordorigin="0 0",l.span=t._g.doc.createElement("span"),l.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;",h.appendChild(l.span),u.cssText=t.format("top:0;left:0;width:{0};height:{1};display:inline-block;position:relative;clip:rect(0 {0} {1} 0);overflow:hidden",a,i),1==r?(t._g.doc.body.appendChild(h),u.left=s+"px",u.top=o+"px",u.position="absolute"):r.firstChild?r.insertBefore(h,r.firstChild):r.appendChild(h),l.renderfix=function(){},l},t.prototype.clear=function(){t.eve("raphael.clear",this),this.canvas.innerHTML=d,this.span=t._g.doc.createElement("span"),this.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;",this.canvas.appendChild(this.span),this.bottom=this.top=null},t.prototype.remove=function(){t.eve("raphael.remove",this),this.canvas.parentNode.removeChild(this.canvas);for(var e in this)this[e]="function"==typeof this[e]?t._removedFactory(e):null;return!0};var L=t.st;for(var z in M)M[e](z)&&!L[e](z)&&(L[z]=function(t){return function(){var e=arguments;return this.forEach(function(r){r[t].apply(r,e)})}}(z))}}.apply(e,i),!(void 0!==n&&(t.exports=n))}])}); /***/ }), -/* 45 */ +/* 47 */ /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/* @@ -48377,11 +53370,11 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/* })(); }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); -}(__webpack_require__(46))); +}(__webpack_require__(48))); /***/ }), -/* 46 */ +/* 48 */ /***/ (function(module, exports) { module.exports = function() { @@ -48390,7 +53383,7 @@ module.exports = function() { /***/ }), -/* 47 */ +/* 49 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -59353,10 +64346,10 @@ Vue.compile = compileToFunctions; module.exports = Vue; -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2), __webpack_require__(48).setImmediate)) +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2), __webpack_require__(50).setImmediate)) /***/ }), -/* 48 */ +/* 50 */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(global) {var scope = (typeof global !== "undefined" && global) || @@ -59412,7 +64405,7 @@ exports._unrefActive = exports.active = function(item) { }; // setimmediate attaches itself to the global object -__webpack_require__(49); +__webpack_require__(51); // On some exotic environments, it's not clear which object `setimmediate` was // able to install onto. Search each possibility in the same order as the // `setimmediate` library. @@ -59426,7 +64419,7 @@ exports.clearImmediate = (typeof self !== "undefined" && self.clearImmediate) || /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2))) /***/ }), -/* 49 */ +/* 51 */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) { @@ -59619,15 +64612,15 @@ exports.clearImmediate = (typeof self !== "undefined" && self.clearImmediate) || /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2), __webpack_require__(6))) /***/ }), -/* 50 */ +/* 52 */ /***/ (function(module, exports, __webpack_require__) { var disposed = false var normalizeComponent = __webpack_require__(1) /* script */ -var __vue_script__ = __webpack_require__(51) +var __vue_script__ = __webpack_require__(53) /* template */ -var __vue_template__ = __webpack_require__(52) +var __vue_template__ = __webpack_require__(54) /* template functional */ var __vue_template_functional__ = false /* styles */ @@ -59666,7 +64659,7 @@ module.exports = Component.exports /***/ }), -/* 51 */ +/* 53 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -59695,7 +64688,7 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); }); /***/ }), -/* 52 */ +/* 54 */ /***/ (function(module, exports, __webpack_require__) { var render = function() { @@ -59738,15 +64731,15 @@ if (false) { } /***/ }), -/* 53 */ +/* 55 */ /***/ (function(module, exports, __webpack_require__) { var disposed = false var normalizeComponent = __webpack_require__(1) /* script */ -var __vue_script__ = __webpack_require__(54) +var __vue_script__ = __webpack_require__(56) /* template */ -var __vue_template__ = __webpack_require__(55) +var __vue_template__ = __webpack_require__(57) /* template functional */ var __vue_template_functional__ = false /* styles */ @@ -59785,7 +64778,7 @@ module.exports = Component.exports /***/ }), -/* 54 */ +/* 56 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -59844,7 +64837,7 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); }); /***/ }), -/* 55 */ +/* 57 */ /***/ (function(module, exports, __webpack_require__) { var render = function() { @@ -59886,15 +64879,15 @@ if (false) { } /***/ }), -/* 56 */ +/* 58 */ /***/ (function(module, exports, __webpack_require__) { var disposed = false var normalizeComponent = __webpack_require__(1) /* script */ -var __vue_script__ = __webpack_require__(57) +var __vue_script__ = __webpack_require__(59) /* template */ -var __vue_template__ = __webpack_require__(72) +var __vue_template__ = __webpack_require__(74) /* template functional */ var __vue_template_functional__ = false /* styles */ @@ -59933,16 +64926,16 @@ module.exports = Component.exports /***/ }), -/* 57 */ +/* 59 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__ChatroomsDropdown__ = __webpack_require__(58); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__ChatroomsDropdown__ = __webpack_require__(60); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__ChatroomsDropdown___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__ChatroomsDropdown__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__ChatMessages__ = __webpack_require__(66); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__ChatMessages__ = __webpack_require__(68); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__ChatMessages___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1__ChatMessages__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__ChatForm__ = __webpack_require__(69); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__ChatForm__ = __webpack_require__(71); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__ChatForm___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2__ChatForm__); // // @@ -60113,9 +65106,13 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); this.fetchMessages(); this.scrollToBottom(); - setInterval(function () { - _this6.fetchMessages(); - }, 3000); + Echo.channel('chatroom.' + this.auth.chatroom.id).listen('UserJoinedChat', function (e) { + console.log(e.username); + }); + + // setInterval(() => { + // this.fetchMessages() + // }, 3000) setInterval(function () { _this6.scrollToBottom(); @@ -60124,19 +65121,19 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); }); /***/ }), -/* 58 */ +/* 60 */ /***/ (function(module, exports, __webpack_require__) { var disposed = false function injectStyle (ssrContext) { if (disposed) return - __webpack_require__(59) + __webpack_require__(61) } var normalizeComponent = __webpack_require__(1) /* script */ -var __vue_script__ = __webpack_require__(64) +var __vue_script__ = __webpack_require__(66) /* template */ -var __vue_template__ = __webpack_require__(65) +var __vue_template__ = __webpack_require__(67) /* template functional */ var __vue_template_functional__ = false /* styles */ @@ -60175,17 +65172,17 @@ module.exports = Component.exports /***/ }), -/* 59 */ +/* 61 */ /***/ (function(module, exports, __webpack_require__) { // style-loader: Adds some css to the DOM by adding a