/* @license
 * Copyright (c) .NET Foundation. All rights reserved.
 * Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
*/
(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?module.exports=factory():typeof define==="function"&&define.amd?define(factory):global.signalR=factory()})(this,function(){"use strict";var commonjsGlobal=typeof window!=="undefined"?window:typeof global!=="undefined"?global:typeof self!=="undefined"?self:{};function commonjsRequire(){throw new Error("Dynamic requires are not currently supported by rollup-plugin-commonjs")}function unwrapExports(x){return x&&x.__esModule&&Object.prototype.hasOwnProperty.call(x,"default")?x["default"]:x}function createCommonjsModule(fn,module){return module={exports:{}},fn(module,module.exports),module.exports}var es6Promise_auto=createCommonjsModule(function(module,exports){
/*!
 * @overview es6-promise - a tiny implementation of Promises/A+.
 * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
 * @license   Licensed under MIT license
 *            See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE
 * @version   v4.2.2+97478eb6
 */
(function(global,factory){module.exports=factory()})(commonjsGlobal,function(){function objectOrFunction(x){var type=typeof x;return x!==null&&(type==="object"||type==="function")}function isFunction(x){return typeof x==="function"}var _isArray=void 0;if(Array.isArray){_isArray=Array.isArray}else{_isArray=function(x){return Object.prototype.toString.call(x)==="[object Array]"}}var isArray=_isArray;var len=0;var vertxNext=void 0;var customSchedulerFn=void 0;var asap=function asap(callback,arg){queue[len]=callback;queue[len+1]=arg;len+=2;if(len===2){if(customSchedulerFn){customSchedulerFn(flush)}else{scheduleFlush()}}};function setScheduler(scheduleFn){customSchedulerFn=scheduleFn}function setAsap(asapFn){asap=asapFn}var browserWindow=typeof window!=="undefined"?window:undefined;var browserGlobal=browserWindow||{};var BrowserMutationObserver=browserGlobal.MutationObserver||browserGlobal.WebKitMutationObserver;var isNode=typeof self==="undefined"&&typeof process!=="undefined"&&{}.toString.call(process)==="[object process]";var isWorker=typeof Uint8ClampedArray!=="undefined"&&typeof importScripts!=="undefined"&&typeof MessageChannel!=="undefined";function useNextTick(){return function(){return process.nextTick(flush)}}function useVertxTimer(){if(typeof vertxNext!=="undefined"){return function(){vertxNext(flush)}}return useSetTimeout()}function useMutationObserver(){var iterations=0;var observer=new BrowserMutationObserver(flush);var node=document.createTextNode("");observer.observe(node,{characterData:true});return function(){node.data=iterations=++iterations%2}}function useMessageChannel(){var channel=new MessageChannel;channel.port1.onmessage=flush;return function(){return channel.port2.postMessage(0)}}function useSetTimeout(){var globalSetTimeout=setTimeout;return function(){return globalSetTimeout(flush,1)}}var queue=new Array(1e3);function flush(){for(var i=0;i<len;i+=2){var callback=queue[i];var arg=queue[i+1];callback(arg);queue[i]=undefined;queue[i+1]=undefined}len=0}function attemptVertx(){try{var r=commonjsRequire;var vertx=r("vertx");vertxNext=vertx.runOnLoop||vertx.runOnContext;return useVertxTimer()}catch(e){return useSetTimeout()}}var scheduleFlush=void 0;if(isNode){scheduleFlush=useNextTick()}else if(BrowserMutationObserver){scheduleFlush=useMutationObserver()}else if(isWorker){scheduleFlush=useMessageChannel()}else if(browserWindow===undefined&&typeof commonjsRequire==="function"){scheduleFlush=attemptVertx()}else{scheduleFlush=useSetTimeout()}function then(onFulfillment,onRejection){var parent=this;var child=new this.constructor(noop);if(child[PROMISE_ID]===undefined){makePromise(child)}var _state=parent._state;if(_state){var callback=arguments[_state-1];asap(function(){return invokeCallback(_state,child,callback,parent._result)})}else{subscribe(parent,child,onFulfillment,onRejection)}return child}function resolve$1(object){var Constructor=this;if(object&&typeof object==="object"&&object.constructor===Constructor){return object}var promise=new Constructor(noop);resolve(promise,object);return promise}var PROMISE_ID=Math.random().toString(36).substring(16);function noop(){}var PENDING=void 0;var FULFILLED=1;var REJECTED=2;var GET_THEN_ERROR=new ErrorObject;function selfFulfillment(){return new TypeError("You cannot resolve a promise with itself")}function cannotReturnOwn(){return new TypeError("A promises callback cannot return that same promise.")}function getThen(promise){try{return promise.then}catch(error){GET_THEN_ERROR.error=error;return GET_THEN_ERROR}}function tryThen(then$$1,value,fulfillmentHandler,rejectionHandler){try{then$$1.call(value,fulfillmentHandler,rejectionHandler)}catch(e){return e}}function handleForeignThenable(promise,thenable,then$$1){asap(function(promise){var sealed=false;var error=tryThen(then$$1,thenable,function(value){if(sealed){return}sealed=true;if(thenable!==value){resolve(promise,value)}else{fulfill(promise,value)}},function(reason){if(sealed){return}sealed=true;reject(promise,reason)},"Settle: "+(promise._label||" unknown promise"));if(!sealed&&error){sealed=true;reject(promise,error)}},promise)}function handleOwnThenable(promise,thenable){if(thenable._state===FULFILLED){fulfill(promise,thenable._result)}else if(thenable._state===REJECTED){reject(promise,thenable._result)}else{subscribe(thenable,undefined,function(value){return resolve(promise,value)},function(reason){return reject(promise,reason)})}}function handleMaybeThenable(promise,maybeThenable,then$$1){if(maybeThenable.constructor===promise.constructor&&then$$1===then&&maybeThenable.constructor.resolve===resolve$1){handleOwnThenable(promise,maybeThenable)}else{if(then$$1===GET_THEN_ERROR){reject(promise,GET_THEN_ERROR.error);GET_THEN_ERROR.error=null}else if(then$$1===undefined){fulfill(promise,maybeThenable)}else if(isFunction(then$$1)){handleForeignThenable(promise,maybeThenable,then$$1)}else{fulfill(promise,maybeThenable)}}}function resolve(promise,value){if(promise===value){reject(promise,selfFulfillment())}else if(objectOrFunction(value)){handleMaybeThenable(promise,value,getThen(value))}else{fulfill(promise,value)}}function publishRejection(promise){if(promise._onerror){promise._onerror(promise._result)}publish(promise)}function fulfill(promise,value){if(promise._state!==PENDING){return}promise._result=value;promise._state=FULFILLED;if(promise._subscribers.length!==0){asap(publish,promise)}}function reject(promise,reason){if(promise._state!==PENDING){return}promise._state=REJECTED;promise._result=reason;asap(publishRejection,promise)}function subscribe(parent,child,onFulfillment,onRejection){var _subscribers=parent._subscribers;var length=_subscribers.length;parent._onerror=null;_subscribers[length]=child;_subscribers[length+FULFILLED]=onFulfillment;_subscribers[length+REJECTED]=onRejection;if(length===0&&parent._state){asap(publish,parent)}}function publish(promise){var subscribers=promise._subscribers;var settled=promise._state;if(subscribers.length===0){return}var child=void 0,callback=void 0,detail=promise._result;for(var i=0;i<subscribers.length;i+=3){child=subscribers[i];callback=subscribers[i+settled];if(child){invokeCallback(settled,child,callback,detail)}else{callback(detail)}}promise._subscribers.length=0}function ErrorObject(){this.error=null}var TRY_CATCH_ERROR=new ErrorObject;function tryCatch(callback,detail){try{return callback(detail)}catch(e){TRY_CATCH_ERROR.error=e;return TRY_CATCH_ERROR}}function invokeCallback(settled,promise,callback,detail){var hasCallback=isFunction(callback),value=void 0,error=void 0,succeeded=void 0,failed=void 0;if(hasCallback){value=tryCatch(callback,detail);if(value===TRY_CATCH_ERROR){failed=true;error=value.error;value.error=null}else{succeeded=true}if(promise===value){reject(promise,cannotReturnOwn());return}}else{value=detail;succeeded=true}if(promise._state!==PENDING){}else if(hasCallback&&succeeded){resolve(promise,value)}else if(failed){reject(promise,error)}else if(settled===FULFILLED){fulfill(promise,value)}else if(settled===REJECTED){reject(promise,value)}}function initializePromise(promise,resolver){try{resolver(function resolvePromise(value){resolve(promise,value)},function rejectPromise(reason){reject(promise,reason)})}catch(e){reject(promise,e)}}var id=0;function nextId(){return id++}function makePromise(promise){promise[PROMISE_ID]=id++;promise._state=undefined;promise._result=undefined;promise._subscribers=[]}function validationError(){return new Error("Array Methods must be provided an Array")}function validationError(){return new Error("Array Methods must be provided an Array")}var Enumerator=function(){function Enumerator(Constructor,input){this._instanceConstructor=Constructor;this.promise=new Constructor(noop);if(!this.promise[PROMISE_ID]){makePromise(this.promise)}if(isArray(input)){this.length=input.length;this._remaining=input.length;this._result=new Array(this.length);if(this.length===0){fulfill(this.promise,this._result)}else{this.length=this.length||0;this._enumerate(input);if(this._remaining===0){fulfill(this.promise,this._result)}}}else{reject(this.promise,validationError())}}Enumerator.prototype._enumerate=function _enumerate(input){for(var i=0;this._state===PENDING&&i<input.length;i++){this._eachEntry(input[i],i)}};Enumerator.prototype._eachEntry=function _eachEntry(entry,i){var c=this._instanceConstructor;var resolve$$1=c.resolve;if(resolve$$1===resolve$1){var _then=getThen(entry);if(_then===then&&entry._state!==PENDING){this._settledAt(entry._state,i,entry._result)}else if(typeof _then!=="function"){this._remaining--;this._result[i]=entry}else if(c===Promise$2){var promise=new c(noop);handleMaybeThenable(promise,entry,_then);this._willSettleAt(promise,i)}else{this._willSettleAt(new c(function(resolve$$1){return resolve$$1(entry)}),i)}}else{this._willSettleAt(resolve$$1(entry),i)}};Enumerator.prototype._settledAt=function _settledAt(state,i,value){var promise=this.promise;if(promise._state===PENDING){this._remaining--;if(state===REJECTED){reject(promise,value)}else{this._result[i]=value}}if(this._remaining===0){fulfill(promise,this._result)}};Enumerator.prototype._willSettleAt=function _willSettleAt(promise,i){var enumerator=this;subscribe(promise,undefined,function(value){return enumerator._settledAt(FULFILLED,i,value)},function(reason){return enumerator._settledAt(REJECTED,i,reason)})};return Enumerator}();function all(entries){return new Enumerator(this,entries).promise}function race(entries){var Constructor=this;if(!isArray(entries)){return new Constructor(function(_,reject){return reject(new TypeError("You must pass an array to race."))})}else{return new Constructor(function(resolve,reject){var length=entries.length;for(var i=0;i<length;i++){Constructor.resolve(entries[i]).then(resolve,reject)}})}}function reject$1(reason){var Constructor=this;var promise=new Constructor(noop);reject(promise,reason);return promise}function needsResolver(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function needsNew(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}var Promise$2=function(){function Promise(resolver){this[PROMISE_ID]=nextId();this._result=this._state=undefined;this._subscribers=[];if(noop!==resolver){typeof resolver!=="function"&&needsResolver();this instanceof Promise?initializePromise(this,resolver):needsNew()}}Promise.prototype.catch=function _catch(onRejection){return this.then(null,onRejection)};Promise.prototype.finally=function _finally(callback){var promise=this;var constructor=promise.constructor;return promise.then(function(value){return constructor.resolve(callback()).then(function(){return value})},function(reason){return constructor.resolve(callback()).then(function(){throw reason})})};return Promise}();Promise$2.prototype.then=then;Promise$2.all=all;Promise$2.race=race;Promise$2.resolve=resolve$1;Promise$2.reject=reject$1;Promise$2._setScheduler=setScheduler;Promise$2._setAsap=setAsap;Promise$2._asap=asap;function polyfill(){var local=void 0;if(typeof commonjsGlobal!=="undefined"){local=commonjsGlobal}else if(typeof self!=="undefined"){local=self}else{try{local=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}}var P=local.Promise;if(P){var promiseToString=null;try{promiseToString=Object.prototype.toString.call(P.resolve())}catch(e){}if(promiseToString==="[object Promise]"&&!P.cast){return}}local.Promise=Promise$2}Promise$2.polyfill=polyfill;Promise$2.Promise=Promise$2;Promise$2.polyfill();return Promise$2})});var Errors=createCommonjsModule(function(module,exports){var __extends=commonjsGlobal&&commonjsGlobal.__extends||function(){var extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)if(b.hasOwnProperty(p))d[p]=b[p]};return function(d,b){extendStatics(d,b);function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)}}();Object.defineProperty(exports,"__esModule",{value:true});var HttpError=function(_super){__extends(HttpError,_super);function HttpError(errorMessage,statusCode){var _this=_super.call(this,errorMessage)||this;_this.statusCode=statusCode;return _this}return HttpError}(Error);exports.HttpError=HttpError;var TimeoutError=function(_super){__extends(TimeoutError,_super);function TimeoutError(errorMessage){if(errorMessage===void 0){errorMessage="A timeout occurred."}return _super.call(this,errorMessage)||this}return TimeoutError}(Error);exports.TimeoutError=TimeoutError});unwrapExports(Errors);var Errors_1=Errors.HttpError;var Errors_2=Errors.TimeoutError;var HttpClient_1=createCommonjsModule(function(module,exports){var __extends=commonjsGlobal&&commonjsGlobal.__extends||function(){var extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)if(b.hasOwnProperty(p))d[p]=b[p]};return function(d,b){extendStatics(d,b);function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)}}();var __assign=commonjsGlobal&&commonjsGlobal.__assign||Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)if(Object.prototype.hasOwnProperty.call(s,p))t[p]=s[p]}return t};Object.defineProperty(exports,"__esModule",{value:true});var HttpResponse=function(){function HttpResponse(statusCode,statusText,content){this.statusCode=statusCode;this.statusText=statusText;this.content=content}return HttpResponse}();exports.HttpResponse=HttpResponse;var HttpClient=function(){function HttpClient(){}HttpClient.prototype.get=function(url,options){return this.send(__assign({},options,{method:"GET",url:url}))};HttpClient.prototype.post=function(url,options){return this.send(__assign({},options,{method:"POST",url:url}))};return HttpClient}();exports.HttpClient=HttpClient;var DefaultHttpClient=function(_super){__extends(DefaultHttpClient,_super);function DefaultHttpClient(){return _super!==null&&_super.apply(this,arguments)||this}DefaultHttpClient.prototype.send=function(request){return new Promise(function(resolve,reject){var xhr=new XMLHttpRequest;xhr.open(request.method,request.url,true);xhr.setRequestHeader("X-Requested-With","XMLHttpRequest");if(request.headers){request.headers.forEach(function(value,header){return xhr.setRequestHeader(header,value)})}if(request.responseType){xhr.responseType=request.responseType}if(request.abortSignal){request.abortSignal.onabort=function(){xhr.abort()}}if(request.timeout){xhr.timeout=request.timeout}xhr.onload=function(){if(request.abortSignal){request.abortSignal.onabort=null}if(xhr.status>=200&&xhr.status<300){resolve(new HttpResponse(xhr.status,xhr.statusText,xhr.response||xhr.responseText))}else{reject(new Errors.HttpError(xhr.statusText,xhr.status))}};xhr.onerror=function(){reject(new Errors.HttpError(xhr.statusText,xhr.status))};xhr.ontimeout=function(){reject(new Errors.TimeoutError)};xhr.send(request.content||"")})};return DefaultHttpClient}(HttpClient);exports.DefaultHttpClient=DefaultHttpClient});unwrapExports(HttpClient_1);var HttpClient_2=HttpClient_1.HttpResponse;var HttpClient_3=HttpClient_1.HttpClient;var HttpClient_4=HttpClient_1.DefaultHttpClient;var ILogger=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:true});var LogLevel;(function(LogLevel){LogLevel[LogLevel["Trace"]=0]="Trace";LogLevel[LogLevel["Information"]=1]="Information";LogLevel[LogLevel["Warning"]=2]="Warning";LogLevel[LogLevel["Error"]=3]="Error";LogLevel[LogLevel["None"]=4]="None"})(LogLevel=exports.LogLevel||(exports.LogLevel={}))});unwrapExports(ILogger);var ILogger_1=ILogger.LogLevel;var AbortController_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:true});var AbortController=function(){function AbortController(){this.isAborted=false}AbortController.prototype.abort=function(){if(!this.isAborted){this.isAborted=true;if(this.onabort){this.onabort()}}};Object.defineProperty(AbortController.prototype,"signal",{get:function(){return this},enumerable:true,configurable:true});Object.defineProperty(AbortController.prototype,"aborted",{get:function(){return this.isAborted},enumerable:true,configurable:true});return AbortController}();exports.AbortController=AbortController});unwrapExports(AbortController_1);var AbortController_2=AbortController_1.AbortController;var Transports=createCommonjsModule(function(module,exports){var __awaiter=commonjsGlobal&&commonjsGlobal.__awaiter||function(thisArg,_arguments,P,generator){return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator["throw"](value))}catch(e){reject(e)}}function step(result){result.done?resolve(result.value):new P(function(resolve){resolve(result.value)}).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})};var __generator=commonjsGlobal&&commonjsGlobal.__generator||function(thisArg,body){var _={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},f,y,t,g;return g={next:verb(0),throw:verb(1),return:verb(2)},typeof Symbol==="function"&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError("Generator is already executing.");while(_)try{if(f=1,y&&(t=y[op[0]&2?"return":op[0]?"throw":"next"])&&!(t=t.call(y,op[1])).done)return t;if(y=0,t)op=[0,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return{value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(op[0]===6&&_.label<t[1]){_.label=t[1];t=op;break}if(t&&_.label<t[2]){_.label=t[2];_.ops.push(op);break}if(t[2])_.ops.pop();_.trys.pop();continue}op=body.call(thisArg,_)}catch(e){op=[6,e];y=0}finally{f=t=0}if(op[0]&5)throw op[1];return{value:op[0]?op[1]:void 0,done:true}}};Object.defineProperty(exports,"__esModule",{value:true});var TransportType;(function(TransportType){TransportType[TransportType["WebSockets"]=0]="WebSockets";TransportType[TransportType["ServerSentEvents"]=1]="ServerSentEvents";TransportType[TransportType["LongPolling"]=2]="LongPolling"})(TransportType=exports.TransportType||(exports.TransportType={}));var WebSocketTransport=function(){function WebSocketTransport(accessToken,logger){this.logger=logger;this.accessToken=accessToken}WebSocketTransport.prototype.connect=function(url,requestedTransferMode,connection){var _this=this;return new Promise(function(resolve,reject){url=url.replace(/^http/,"ws");if(_this.accessToken){var token=_this.accessToken();url+=(url.indexOf("?")<0?"?":"&")+("signalRTokenHeader="+token)}var webSocket=new WebSocket(url);if(requestedTransferMode==2){webSocket.binaryType="arraybuffer"}webSocket.onopen=function(event){_this.logger.log(ILogger.LogLevel.Information,"WebSocket connected to "+url);_this.webSocket=webSocket;resolve(requestedTransferMode)};webSocket.onerror=function(event){reject()};webSocket.onmessage=function(message){_this.logger.log(ILogger.LogLevel.Trace,"(WebSockets transport) data received: "+message.data);if(_this.onreceive){_this.onreceive(message.data)}};webSocket.onclose=function(event){if(_this.onclose&&_this.webSocket){if(event.wasClean===false||event.code!==1e3){_this.onclose(new Error("Websocket closed with status code: "+event.code+" ("+event.reason+")"))}else{_this.onclose()}}}})};WebSocketTransport.prototype.send=function(data){if(this.webSocket&&this.webSocket.readyState===WebSocket.OPEN){this.webSocket.send(data);return Promise.resolve()}return Promise.reject("WebSocket is not in the OPEN state")};WebSocketTransport.prototype.stop=function(){if(this.webSocket){this.webSocket.close();this.webSocket=null}return Promise.resolve()};return WebSocketTransport}();exports.WebSocketTransport=WebSocketTransport;var ServerSentEventsTransport=function(){function ServerSentEventsTransport(httpClient,accessToken,logger){this.httpClient=httpClient;this.accessToken=accessToken;this.logger=logger}ServerSentEventsTransport.prototype.connect=function(url,requestedTransferMode,connection){var _this=this;if(typeof EventSource==="undefined"){Promise.reject("EventSource not supported by the browser.")}this.url=url;return new Promise(function(resolve,reject){if(_this.accessToken){var token=_this.accessToken();url+=(url.indexOf("?")<0?"?":"&")+("signalRTokenHeader="+token)}var eventSource=new EventSource(url);try{eventSource.onmessage=function(e){if(_this.onreceive){try{_this.logger.log(ILogger.LogLevel.Trace,"(SSE transport) data received: "+e.data);_this.onreceive(e.data)}catch(error){if(_this.onclose){_this.onclose(error)}return}}};eventSource.onerror=function(e){reject();if(_this.eventSource&&_this.onclose){_this.onclose(new Error(e.message||"Error occurred"))}};eventSource.onopen=function(){_this.logger.log(ILogger.LogLevel.Information,"SSE connected to "+_this.url);_this.eventSource=eventSource;resolve(1)}}catch(e){return Promise.reject(e)}})};ServerSentEventsTransport.prototype.send=function(data){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(_a){return[2,send(this.httpClient,this.url,this.accessToken,data)]})})};ServerSentEventsTransport.prototype.stop=function(){if(this.eventSource){this.eventSource.close();this.eventSource=null}return Promise.resolve()};return ServerSentEventsTransport}();exports.ServerSentEventsTransport=ServerSentEventsTransport;var LongPollingTransport=function(){function LongPollingTransport(httpClient,accessToken,logger){this.httpClient=httpClient;this.accessToken=accessToken;this.logger=logger;this.pollAbort=new AbortController_1.AbortController}LongPollingTransport.prototype.connect=function(url,requestedTransferMode,connection){this.url=url;connection.features.inherentKeepAlive=true;if(requestedTransferMode===2&&typeof(new XMLHttpRequest).responseType!=="string"){throw new Error("Binary protocols over XmlHttpRequest not implementing advanced features are not supported.")}this.poll(this.url,requestedTransferMode);return Promise.resolve(requestedTransferMode)};LongPollingTransport.prototype.poll=function(url,transferMode){return __awaiter(this,void 0,void 0,function(){var pollOptions,pollUrl,response,e_1;return __generator(this,function(_a){switch(_a.label){case 0:pollOptions={timeout:12e4,abortSignal:this.pollAbort.signal,headers:new Map};if(transferMode===2){pollOptions.responseType="arraybuffer"}if(this.accessToken){pollOptions.headers.set("Authorization","Bearer "+this.accessToken())}_a.label=1;case 1:if(!!this.pollAbort.signal.aborted)return[3,6];_a.label=2;case 2:_a.trys.push([2,4,,5]);pollUrl=url+"&_="+Date.now();this.logger.log(ILogger.LogLevel.Trace,"(LongPolling transport) polling: "+pollUrl);return[4,this.httpClient.get(pollUrl,pollOptions)];case 3:response=_a.sent();if(response.statusCode===204){this.logger.log(ILogger.LogLevel.Information,"(LongPolling transport) Poll terminated by server");if(this.onclose){this.onclose()}this.pollAbort.abort()}else if(response.statusCode!==200){this.logger.log(ILogger.LogLevel.Error,"(LongPolling transport) Unexpected response code: "+response.statusCode);if(this.onclose){this.onclose(new Errors.HttpError(response.statusText,response.statusCode))}this.pollAbort.abort()}else{if(response.content){this.logger.log(ILogger.LogLevel.Trace,"(LongPolling transport) data received: "+response.content);if(this.onreceive){this.onreceive(response.content)}}else{this.logger.log(ILogger.LogLevel.Trace,"(LongPolling transport) Poll timed out, reissuing.")}}return[3,5];case 4:e_1=_a.sent();if(e_1 instanceof Errors.TimeoutError){this.logger.log(ILogger.LogLevel.Trace,"(LongPolling transport) Poll timed out, reissuing.")}else{if(this.onclose){this.onclose(e_1)}this.pollAbort.abort()}return[3,5];case 5:return[3,1];case 6:return[2]}})})};LongPollingTransport.prototype.send=function(data){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(_a){return[2,send(this.httpClient,this.url,this.accessToken,data)]})})};LongPollingTransport.prototype.stop=function(){this.pollAbort.abort();return Promise.resolve()};return LongPollingTransport}();exports.LongPollingTransport=LongPollingTransport;function send(httpClient,url,accessToken,content){return __awaiter(this,void 0,void 0,function(){var headers;return __generator(this,function(_a){switch(_a.label){case 0:if(accessToken){headers=new Map;headers.set("Authorization","Bearer "+accessToken())}return[4,httpClient.post(url,{content:content,headers:headers})];case 1:_a.sent();return[2]}})})}});unwrapExports(Transports);var Transports_1=Transports.TransportType;var Transports_2=Transports.WebSocketTransport;var Transports_3=Transports.ServerSentEventsTransport;var Transports_4=Transports.LongPollingTransport;var Loggers=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:true});var NullLogger=function(){function NullLogger(){}NullLogger.prototype.log=function(logLevel,message){};return NullLogger}();exports.NullLogger=NullLogger;var ConsoleLogger=function(){function ConsoleLogger(minimumLogLevel){this.minimumLogLevel=minimumLogLevel}ConsoleLogger.prototype.log=function(logLevel,message){if(logLevel>=this.minimumLogLevel){switch(logLevel){case ILogger.LogLevel.Error:console.error(ILogger.LogLevel[logLevel]+": "+message);break;case ILogger.LogLevel.Warning:console.warn(ILogger.LogLevel[logLevel]+": "+message);break;case ILogger.LogLevel.Information:console.info(ILogger.LogLevel[logLevel]+": "+message);break;default:console.log(ILogger.LogLevel[logLevel]+": "+message);break}}};return ConsoleLogger}();exports.ConsoleLogger=ConsoleLogger;var LoggerFactory;(function(LoggerFactory){function createLogger(logging){if(logging===undefined){return new ConsoleLogger(ILogger.LogLevel.Information)}if(logging===null){return new NullLogger}if(logging.log){return logging}return new ConsoleLogger(logging)}LoggerFactory.createLogger=createLogger})(LoggerFactory=exports.LoggerFactory||(exports.LoggerFactory={}))});unwrapExports(Loggers);var Loggers_1=Loggers.NullLogger;var Loggers_2=Loggers.ConsoleLogger;var Loggers_3=Loggers.LoggerFactory;var HttpConnection_1=createCommonjsModule(function(module,exports){var __awaiter=commonjsGlobal&&commonjsGlobal.__awaiter||function(thisArg,_arguments,P,generator){return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator["throw"](value))}catch(e){reject(e)}}function step(result){result.done?resolve(result.value):new P(function(resolve){resolve(result.value)}).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})};var __generator=commonjsGlobal&&commonjsGlobal.__generator||function(thisArg,body){var _={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},f,y,t,g;return g={next:verb(0),throw:verb(1),return:verb(2)},typeof Symbol==="function"&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError("Generator is already executing.");while(_)try{if(f=1,y&&(t=y[op[0]&2?"return":op[0]?"throw":"next"])&&!(t=t.call(y,op[1])).done)return t;if(y=0,t)op=[0,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return{value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(op[0]===6&&_.label<t[1]){_.label=t[1];t=op;break}if(t&&_.label<t[2]){_.label=t[2];_.ops.push(op);break}if(t[2])_.ops.pop();_.trys.pop();continue}op=body.call(thisArg,_)}catch(e){op=[6,e];y=0}finally{f=t=0}if(op[0]&5)throw op[1];return{value:op[0]?op[1]:void 0,done:true}}};Object.defineProperty(exports,"__esModule",{value:true});var HttpConnection=function(){function HttpConnection(url,options){if(options===void 0){options={}}this.features={};this.logger=Loggers.LoggerFactory.createLogger(options.logger);this.baseUrl=this.resolveUrl(url);options=options||{};this.httpClient=options.httpClient||new HttpClient_1.DefaultHttpClient;this.connectionState=2;this.options=options}HttpConnection.prototype.start=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(_a){if(this.connectionState!==2){return[2,Promise.reject(new Error("Cannot start a connection that is not in the 'Disconnected' state."))]}this.connectionState=0;this.startPromise=this.startInternal();return[2,this.startPromise]})})};HttpConnection.prototype.startInternal=function(){return __awaiter(this,void 0,void 0,function(){var _this=this;var headers,negotiatePayload,negotiateResponse,requestedTransferMode,_a,e_1;return __generator(this,function(_b){switch(_b.label){case 0:_b.trys.push([0,5,,6]);if(!(this.options.transport===Transports.TransportType.WebSockets))return[3,1];this.url=this.baseUrl;this.transport=this.createTransport(this.options.transport,[Transports.TransportType[Transports.TransportType.WebSockets]]);return[3,3];case 1:headers=void 0;if(this.options.accessToken){headers=new Map;headers.set("Authorization","Bearer "+this.options.accessToken())}return[4,this.httpClient.post(this.resolveNegotiateUrl(this.baseUrl),{content:"",headers:headers})];case 2:negotiatePayload=_b.sent();negotiateResponse=JSON.parse(negotiatePayload.content);this.connectionId=negotiateResponse.connectionId;if(this.connectionState==2){return[2]}if(this.connectionId){this.url=this.baseUrl+(this.baseUrl.indexOf("?")===-1?"?":"&")+("id="+this.connectionId);this.transport=this.createTransport(this.options.transport,negotiateResponse.availableTransports)}_b.label=3;case 3:this.transport.onreceive=this.onreceive;this.transport.onclose=function(e){return _this.stopConnection(true,e)};requestedTransferMode=this.features.transferMode===2?2:1;_a=this.features;return[4,this.transport.connect(this.url,requestedTransferMode,this)];case 4:_a.transferMode=_b.sent();this.changeState(0,1);return[3,6];case 5:e_1=_b.sent();this.logger.log(ILogger.LogLevel.Error,"Failed to start the connection. "+e_1);this.connectionState=2;this.transport=null;throw e_1;case 6:;return[2]}})})};HttpConnection.prototype.createTransport=function(transport,availableTransports){if((transport===null||transport===undefined)&&availableTransports.length>0){transport=Transports.TransportType[availableTransports[0]]}if(transport===Transports.TransportType.WebSockets&&availableTransports.indexOf(Transports.TransportType[transport])>=0){return new Transports.WebSocketTransport(this.options.accessToken,this.logger)}if(transport===Transports.TransportType.ServerSentEvents&&availableTransports.indexOf(Transports.TransportType[transport])>=0){return new Transports.ServerSentEventsTransport(this.httpClient,this.options.accessToken,this.logger)}if(transport===Transports.TransportType.LongPolling&&availableTransports.indexOf(Transports.TransportType[transport])>=0){return new Transports.LongPollingTransport(this.httpClient,this.options.accessToken,this.logger)}if(this.isITransport(transport)){return transport}throw new Error("No available transports found.")};HttpConnection.prototype.isITransport=function(transport){return typeof transport==="object"&&"connect"in transport};HttpConnection.prototype.changeState=function(from,to){if(this.connectionState==from){this.connectionState=to;return true}return false};HttpConnection.prototype.send=function(data){if(this.connectionState!=1){throw new Error("Cannot send data if the connection is not in the 'Connected' State")}return this.transport.send(data)};HttpConnection.prototype.stop=function(error){return __awaiter(this,void 0,void 0,function(){var previousState,e_2;return __generator(this,function(_a){switch(_a.label){case 0:previousState=this.connectionState;this.connectionState=2;_a.label=1;case 1:_a.trys.push([1,3,,4]);return[4,this.startPromise];case 2:_a.sent();return[3,4];case 3:e_2=_a.sent();return[3,4];case 4:this.stopConnection(previousState==1,error);return[2]}})})};HttpConnection.prototype.stopConnection=function(raiseClosed,error){if(this.transport){this.transport.stop();this.transport=null}if(error){this.logger.log(ILogger.LogLevel.Error,"Connection disconnected with error '"+error+"'.")}else{this.logger.log(ILogger.LogLevel.Information,"Connection disconnected.")}this.connectionState=2;if(raiseClosed&&this.onclose){this.onclose(error)}};HttpConnection.prototype.resolveUrl=function(url){if(url.lastIndexOf("https://",0)===0||url.lastIndexOf("http://",0)===0){return url}if(typeof window==="undefined"||!window||!window.document){throw new Error("Cannot resolve '"+url+"'.")}var parser=window.document.createElement("a");parser.href=url;var baseUrl=!parser.protocol||parser.protocol===":"?window.document.location.protocol+"//"+(parser.host||window.document.location.host):parser.protocol+"//"+parser.host;if(!url||url[0]!="/"){url="/"+url}var normalizedUrl=baseUrl+url;this.logger.log(ILogger.LogLevel.Information,"Normalizing '"+url+"' to '"+normalizedUrl+"'");return normalizedUrl};HttpConnection.prototype.resolveNegotiateUrl=function(url){var index=url.indexOf("?");var negotiateUrl=url.substring(0,index===-1?url.length:index);if(negotiateUrl[negotiateUrl.length-1]!=="/"){negotiateUrl+="/"}negotiateUrl+="negotiate";negotiateUrl+=index===-1?"":url.substring(index);return negotiateUrl};return HttpConnection}();exports.HttpConnection=HttpConnection});unwrapExports(HttpConnection_1);var HttpConnection_2=HttpConnection_1.HttpConnection;var Observable=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:true});var Subscription=function(){function Subscription(subject,observer){this.subject=subject;this.observer=observer}Subscription.prototype.dispose=function(){var index=this.subject.observers.indexOf(this.observer);if(index>-1){this.subject.observers.splice(index,1)}if(this.subject.observers.length===0){this.subject.cancelCallback().catch(function(_){})}};return Subscription}();exports.Subscription=Subscription;var Subject=function(){function Subject(cancelCallback){this.observers=[];this.cancelCallback=cancelCallback}Subject.prototype.next=function(item){for(var _i=0,_a=this.observers;_i<_a.length;_i++){var observer=_a[_i];observer.next(item)}};Subject.prototype.error=function(err){for(var _i=0,_a=this.observers;_i<_a.length;_i++){var observer=_a[_i];if(observer.error){observer.error(err)}}};Subject.prototype.complete=function(){for(var _i=0,_a=this.observers;_i<_a.length;_i++){var observer=_a[_i];if(observer.complete){observer.complete()}}};Subject.prototype.subscribe=function(observer){this.observers.push(observer);return new Subscription(this,observer)};return Subject}();exports.Subject=Subject});unwrapExports(Observable);var Observable_1=Observable.Subscription;var Observable_2=Observable.Subject;var TextMessageFormat_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:true});var TextMessageFormat=function(){function TextMessageFormat(){}TextMessageFormat.write=function(output){return""+output+TextMessageFormat.RecordSeparator};TextMessageFormat.parse=function(input){if(input[input.length-1]!=TextMessageFormat.RecordSeparator){throw new Error("Message is incomplete.")}var messages=input.split(TextMessageFormat.RecordSeparator);messages.pop();return messages};TextMessageFormat.RecordSeparator=String.fromCharCode(30);return TextMessageFormat}();exports.TextMessageFormat=TextMessageFormat});unwrapExports(TextMessageFormat_1);var TextMessageFormat_2=TextMessageFormat_1.TextMessageFormat;var JsonHubProtocol_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:true});exports.JSON_HUB_PROTOCOL_NAME="json";var JsonHubProtocol=function(){function JsonHubProtocol(){this.name=exports.JSON_HUB_PROTOCOL_NAME;this.type=1}JsonHubProtocol.prototype.parseMessages=function(input){if(!input){return[]}var messages=TextMessageFormat_1.TextMessageFormat.parse(input);var hubMessages=[];for(var i=0;i<messages.length;++i){hubMessages.push(JSON.parse(messages[i]))}return hubMessages};JsonHubProtocol.prototype.writeMessage=function(message){return TextMessageFormat_1.TextMessageFormat.write(JSON.stringify(message))};return JsonHubProtocol}();exports.JsonHubProtocol=JsonHubProtocol});unwrapExports(JsonHubProtocol_1);var JsonHubProtocol_2=JsonHubProtocol_1.JSON_HUB_PROTOCOL_NAME;var JsonHubProtocol_3=JsonHubProtocol_1.JsonHubProtocol;var Base64EncodedHubProtocol_1=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:true});var Base64EncodedHubProtocol=function(){function Base64EncodedHubProtocol(protocol){this.wrappedProtocol=protocol;this.name=this.wrappedProtocol.name;this.type=1}Base64EncodedHubProtocol.prototype.parseMessages=function(input){var pos=input.indexOf(":");if(pos==-1||input[input.length-1]!=";"){throw new Error("Invalid payload.")}var lenStr=input.substring(0,pos);if(!/^[0-9]+$/.test(lenStr)){throw new Error("Invalid length: '"+lenStr+"'")}var messageSize=parseInt(lenStr,10);if(messageSize!=input.length-pos-2){throw new Error("Invalid message size.")}var encodedMessage=input.substring(pos+1,input.length-1);var s=atob(encodedMessage);var payload=new Uint8Array(s.length);for(var i=0;i<payload.length;i++){payload[i]=s.charCodeAt(i)}return this.wrappedProtocol.parseMessages(payload.buffer)};Base64EncodedHubProtocol.prototype.writeMessage=function(message){var payload=new Uint8Array(this.wrappedProtocol.writeMessage(message));var s="";for(var i=0;i<payload.byteLength;i++){s+=String.fromCharCode(payload[i])}var encodedMessage=btoa(s);return encodedMessage.length.toString()+":"+encodedMessage+";"};return Base64EncodedHubProtocol}();exports.Base64EncodedHubProtocol=Base64EncodedHubProtocol});unwrapExports(Base64EncodedHubProtocol_1);var Base64EncodedHubProtocol_2=Base64EncodedHubProtocol_1.Base64EncodedHubProtocol;var HubConnection_1=createCommonjsModule(function(module,exports){var __awaiter=commonjsGlobal&&commonjsGlobal.__awaiter||function(thisArg,_arguments,P,generator){return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator["throw"](value))}catch(e){reject(e)}}function step(result){result.done?resolve(result.value):new P(function(resolve){resolve(result.value)}).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})};var __generator=commonjsGlobal&&commonjsGlobal.__generator||function(thisArg,body){var _={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},f,y,t,g;return g={next:verb(0),throw:verb(1),return:verb(2)},typeof Symbol==="function"&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError("Generator is already executing.");while(_)try{if(f=1,y&&(t=y[op[0]&2?"return":op[0]?"throw":"next"])&&!(t=t.call(y,op[1])).done)return t;if(y=0,t)op=[0,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return{value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(op[0]===6&&_.label<t[1]){_.label=t[1];t=op;break}if(t&&_.label<t[2]){_.label=t[2];_.ops.push(op);break}if(t[2])_.ops.pop();_.trys.pop();continue}op=body.call(thisArg,_)}catch(e){op=[6,e];y=0}finally{f=t=0}if(op[0]&5)throw op[1];return{value:op[0]?op[1]:void 0,done:true}}};Object.defineProperty(exports,"__esModule",{value:true});exports.JsonHubProtocol=JsonHubProtocol_1.JsonHubProtocol;var DEFAULT_TIMEOUT_IN_MS=30*1e3;var HubConnection=function(){function HubConnection(urlOrConnection,options){if(options===void 0){options={}}var _this=this;options=options||{};this.timeoutInMilliseconds=options.timeoutInMilliseconds||DEFAULT_TIMEOUT_IN_MS;if(typeof urlOrConnection==="string"){this.connection=new HttpConnection_1.HttpConnection(urlOrConnection,options)}else{this.connection=urlOrConnection}this.logger=Loggers.LoggerFactory.createLogger(options.logger);this.protocol=options.protocol||new JsonHubProtocol_1.JsonHubProtocol;this.connection.onreceive=function(data){return _this.processIncomingData(data)};this.connection.onclose=function(error){return _this.connectionClosed(error)};this.callbacks=new Map;this.methods=new Map;this.closedCallbacks=[];this.id=0}HubConnection.prototype.processIncomingData=function(data){if(this.timeoutHandle!==undefined){clearTimeout(this.timeoutHandle)}var messages=this.protocol.parseMessages(data);for(var i=0;i<messages.length;++i){var message=messages[i];switch(message.type){case 1:this.invokeClientMethod(message);break;case 2:case 3:var callback=this.callbacks.get(message.invocationId);if(callback!=null){if(message.type===3){this.callbacks.delete(message.invocationId)}callback(message)}break;case 6:break;default:this.logger.log(ILogger.LogLevel.Warning,"Invalid message type: "+data);break}}this.configureTimeout()};HubConnection.prototype.configureTimeout=function(){var _this=this;if(!this.connection.features||!this.connection.features.inherentKeepAlive){this.timeoutHandle=setTimeout(function(){return _this.serverTimeout()},this.timeoutInMilliseconds)}};HubConnection.prototype.serverTimeout=function(){this.connection.stop(new Error("Server timeout elapsed without receiving a message from the server."))};HubConnection.prototype.invokeClientMethod=function(invocationMessage){var _this=this;var methods=this.methods.get(invocationMessage.target.toLowerCase());if(methods){methods.forEach(function(m){return m.apply(_this,invocationMessage.arguments)});if(invocationMessage.invocationId){var message="Server requested a response, which is not supported in this version of the client.";this.logger.log(ILogger.LogLevel.Error,message);this.connection.stop(new Error(message))}}else{this.logger.log(ILogger.LogLevel.Warning,"No client method with the name '"+invocationMessage.target+"' found.")}};HubConnection.prototype.connectionClosed=function(error){var _this=this;this.callbacks.forEach(function(callback){callback(undefined,error?error:new Error("Invocation canceled due to connection being closed."))});this.callbacks.clear();this.closedCallbacks.forEach(function(c){return c.apply(_this,[error])});this.cleanupTimeout()};HubConnection.prototype.start=function(){return __awaiter(this,void 0,void 0,function(){var requestedTransferMode,actualTransferMode;return __generator(this,function(_a){switch(_a.label){case 0:requestedTransferMode=this.protocol.type===2?2:1;this.connection.features.transferMode=requestedTransferMode;return[4,this.connection.start()];case 1:_a.sent();actualTransferMode=this.connection.features.transferMode;return[4,this.connection.send(TextMessageFormat_1.TextMessageFormat.write(JSON.stringify({protocol:this.protocol.name})))];case 2:_a.sent();this.logger.log(ILogger.LogLevel.Information,"Using HubProtocol '"+this.protocol.name+"'.");if(requestedTransferMode===2&&actualTransferMode===1){this.protocol=new Base64EncodedHubProtocol_1.Base64EncodedHubProtocol(this.protocol)}this.configureTimeout();return[2]}})})};HubConnection.prototype.stop=function(){this.cleanupTimeout();return this.connection.stop()};HubConnection.prototype.stream=function(methodName){var _this=this;var args=[];for(var _i=1;_i<arguments.length;_i++){args[_i-1]=arguments[_i]}var invocationDescriptor=this.createStreamInvocation(methodName,args);var subject=new Observable.Subject(function(){var cancelInvocation=_this.createCancelInvocation(invocationDescriptor.invocationId);var message=_this.protocol.writeMessage(cancelInvocation);_this.callbacks.delete(invocationDescriptor.invocationId);return _this.connection.send(message)});this.callbacks.set(invocationDescriptor.invocationId,function(invocationEvent,error){if(error){subject.error(error);return}if(invocationEvent.type===3){var completionMessage=invocationEvent;if(completionMessage.error){subject.error(new Error(completionMessage.error))}else{subject.complete()}}else{subject.next(invocationEvent.item)}});var message=this.protocol.writeMessage(invocationDescriptor);this.connection.send(message).catch(function(e){subject.error(e);_this.callbacks.delete(invocationDescriptor.invocationId)});return subject};HubConnection.prototype.send=function(methodName){var args=[];for(var _i=1;_i<arguments.length;_i++){args[_i-1]=arguments[_i]}var invocationDescriptor=this.createInvocation(methodName,args,true);var message=this.protocol.writeMessage(invocationDescriptor);return this.connection.send(message)};HubConnection.prototype.invoke=function(methodName){var _this=this;var args=[];for(var _i=1;_i<arguments.length;_i++){args[_i-1]=arguments[_i]}var invocationDescriptor=this.createInvocation(methodName,args,false);var p=new Promise(function(resolve,reject){_this.callbacks.set(invocationDescriptor.invocationId,function(invocationEvent,error){if(error){reject(error);return}if(invocationEvent.type===3){var completionMessage=invocationEvent;if(completionMessage.error){reject(new Error(completionMessage.error))}else{resolve(completionMessage.result)}}else{reject(new Error("Unexpected message type: "+invocationEvent.type))}});var message=_this.protocol.writeMessage(invocationDescriptor);_this.connection.send(message).catch(function(e){reject(e);_this.callbacks.delete(invocationDescriptor.invocationId)})});return p};HubConnection.prototype.on=function(methodName,method){if(!methodName||!method){return}methodName=methodName.toLowerCase();if(!this.methods.has(methodName)){this.methods.set(methodName,[])}this.methods.get(methodName).push(method)};HubConnection.prototype.off=function(methodName,method){if(!methodName||!method){return}methodName=methodName.toLowerCase();var handlers=this.methods.get(methodName);if(!handlers){return}var removeIdx=handlers.indexOf(method);if(removeIdx!=-1){handlers.splice(removeIdx,1)}};HubConnection.prototype.onclose=function(callback){if(callback){this.closedCallbacks.push(callback)}};HubConnection.prototype.cleanupTimeout=function(){if(this.timeoutHandle){clearTimeout(this.timeoutHandle)}};HubConnection.prototype.createInvocation=function(methodName,args,nonblocking){if(nonblocking){return{type:1,target:methodName,arguments:args}}else{var id=this.id;this.id++;return{type:1,invocationId:id.toString(),target:methodName,arguments:args}}};HubConnection.prototype.createStreamInvocation=function(methodName,args){var id=this.id;this.id++;return{type:4,invocationId:id.toString(),target:methodName,arguments:args}};HubConnection.prototype.createCancelInvocation=function(id){return{type:5,invocationId:id}};return HubConnection}();exports.HubConnection=HubConnection});unwrapExports(HubConnection_1);var HubConnection_2=HubConnection_1.JsonHubProtocol;var HubConnection_3=HubConnection_1.HubConnection;var IHubProtocol=createCommonjsModule(function(module,exports){Object.defineProperty(exports,"__esModule",{value:true})});unwrapExports(IHubProtocol);var cjs=createCommonjsModule(function(module,exports){function __export(m){for(var p in m)if(!exports.hasOwnProperty(p))exports[p]=m[p]}Object.defineProperty(exports,"__esModule",{value:true});__export(Errors);__export(HttpClient_1);__export(HttpConnection_1);__export(HubConnection_1);__export(IHubProtocol);__export(ILogger);__export(Loggers);__export(Transports);__export(Observable)});unwrapExports(cjs);var browserIndex=createCommonjsModule(function(module,exports){function __export(m){for(var p in m)if(!exports.hasOwnProperty(p))exports[p]=m[p]}Object.defineProperty(exports,"__esModule",{value:true});__export(cjs)});var browserIndex$1=unwrapExports(browserIndex);return browserIndex$1});
//# sourceMappingURL=signalr.min.js.map