New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@microsoft/signalr

Package Overview
Dependencies
Maintainers
6
Versions
132
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@microsoft/signalr - npm Package Compare versions

Comparing version 7.0.0-preview.4.22251.1 to 7.0.0-preview.5.22303.8

2

dist/browser/signalr.min.js

@@ -1,2 +0,2 @@

var t,e;t=self,e=function(){return(()=>{var t={d:(e,n)=>{for(var s in n)t.o(n,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:n[s]})}};t.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),t.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),t.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"t",{value:!0})};var e,n={};t.r(n),t.d(n,{AbortError:()=>r,DefaultHttpClient:()=>H,HttpClient:()=>d,HttpError:()=>s,HttpResponse:()=>u,HttpTransportType:()=>q,HubConnection:()=>N,HubConnectionBuilder:()=>Q,HubConnectionState:()=>A,JsonHubProtocol:()=>G,LogLevel:()=>e,MessageType:()=>R,NullLogger:()=>f,Subject:()=>U,TimeoutError:()=>i,TransferFormat:()=>W,VERSION:()=>p});class s extends Error{constructor(t,e){const n=new.target.prototype;super(`${t}: Status code '${e}'`),this.statusCode=e,this.__proto__=n}}class i extends Error{constructor(t="A timeout occurred."){const e=new.target.prototype;super(t),this.__proto__=e}}class r extends Error{constructor(t="An abort occurred."){const e=new.target.prototype;super(t),this.__proto__=e}}class o extends Error{constructor(t,e){const n=new.target.prototype;super(t),this.transport=e,this.errorType="UnsupportedTransportError",this.__proto__=n}}class h extends Error{constructor(t,e){const n=new.target.prototype;super(t),this.transport=e,this.errorType="DisabledTransportError",this.__proto__=n}}class c extends Error{constructor(t,e){const n=new.target.prototype;super(t),this.transport=e,this.errorType="FailedToStartTransportError",this.__proto__=n}}class a extends Error{constructor(t){const e=new.target.prototype;super(t),this.errorType="FailedToNegotiateWithServerError",this.__proto__=e}}class l extends Error{constructor(t,e){const n=new.target.prototype;super(t),this.innerErrors=e,this.__proto__=n}}class u{constructor(t,e,n){this.statusCode=t,this.statusText=e,this.content=n}}class d{get(t,e){return this.send({...e,method:"GET",url:t})}post(t,e){return this.send({...e,method:"POST",url:t})}delete(t,e){return this.send({...e,method:"DELETE",url:t})}getCookieString(t){return""}}!function(t){t[t.Trace=0]="Trace",t[t.Debug=1]="Debug",t[t.Information=2]="Information",t[t.Warning=3]="Warning",t[t.Error=4]="Error",t[t.Critical=5]="Critical",t[t.None=6]="None"}(e||(e={}));class f{constructor(){}log(t,e){}}f.instance=new f;const p="7.0.0-preview.4.22251.1";class w{static isRequired(t,e){if(null==t)throw new Error(`The '${e}' argument is required.`)}static isNotEmpty(t,e){if(!t||t.match(/^\s*$/))throw new Error(`The '${e}' argument should not be empty.`)}static isIn(t,e,n){if(!(t in e))throw new Error(`Unknown ${n} value: ${t}.`)}}class g{static get isBrowser(){return"object"==typeof window&&"object"==typeof window.document}static get isWebWorker(){return"object"==typeof self&&"importScripts"in self}static get isReactNative(){return"object"==typeof window&&void 0===window.document}static get isNode(){return!this.isBrowser&&!this.isWebWorker&&!this.isReactNative}}function y(t,e){let n="";return m(t)?(n=`Binary data of length ${t.byteLength}`,e&&(n+=`. Content: '${function(t){const e=new Uint8Array(t);let n="";return e.forEach((t=>{n+=`0x${t<16?"0":""}${t.toString(16)} `})),n.substr(0,n.length-1)}(t)}'`)):"string"==typeof t&&(n=`String data of length ${t.length}`,e&&(n+=`. Content: '${t}'`)),n}function m(t){return t&&"undefined"!=typeof ArrayBuffer&&(t instanceof ArrayBuffer||t.constructor&&"ArrayBuffer"===t.constructor.name)}async function b(t,n,s,i,r,o,h){let c={};if(r){const t=await r();t&&(c={Authorization:`Bearer ${t}`})}const[a,l]=E();c[a]=l,t.log(e.Trace,`(${n} transport) sending data. ${y(o,h.logMessageContent)}.`);const u=m(o)?"arraybuffer":"text",d=await s.post(i,{content:o,headers:{...c,...h.headers},responseType:u,timeout:h.timeout,withCredentials:h.withCredentials});t.log(e.Trace,`(${n} transport) request complete. Response status: ${d.statusCode}.`)}class v{constructor(t,e){this.i=t,this.h=e}dispose(){const t=this.i.observers.indexOf(this.h);t>-1&&this.i.observers.splice(t,1),0===this.i.observers.length&&this.i.cancelCallback&&this.i.cancelCallback().catch((t=>{}))}}class ${constructor(t){this.l=t,this.out=console}log(t,n){if(t>=this.l){const s=`[${(new Date).toISOString()}] ${e[t]}: ${n}`;switch(t){case e.Critical:case e.Error:this.out.error(s);break;case e.Warning:this.out.warn(s);break;case e.Information:this.out.info(s);break;default:this.out.log(s)}}}}function E(){let t="X-SignalR-User-Agent";return g.isNode&&(t="User-Agent"),[t,C(p,S(),g.isNode?"NodeJS":"Browser",k())]}function C(t,e,n,s){let i="Microsoft SignalR/";const r=t.split(".");return i+=`${r[0]}.${r[1]}`,i+=` (${t}; `,i+=e&&""!==e?`${e}; `:"Unknown OS; ",i+=`${n}`,i+=s?`; ${s}`:"; Unknown Runtime Version",i+=")",i}function S(){if(!g.isNode)return"";switch(process.platform){case"win32":return"Windows NT";case"darwin":return"macOS";case"linux":return"Linux";default:return process.platform}}function k(){if(g.isNode)return process.versions.node}function P(t){return t.stack?t.stack:t.message?t.message:`${t}`}class T extends d{constructor(e){if(super(),this.u=e,"undefined"==typeof fetch){const t=require;this.p=new(t("tough-cookie").CookieJar),this.m=t("node-fetch"),this.m=t("fetch-cookie")(this.m,this.p)}else this.m=fetch.bind(function(){if("undefined"!=typeof globalThis)return globalThis;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==t.g)return t.g;throw new Error("could not find global")}());if("undefined"==typeof AbortController){const t=require;this.v=t("abort-controller")}else this.v=AbortController}async send(t){if(t.abortSignal&&t.abortSignal.aborted)throw new r;if(!t.method)throw new Error("No method defined.");if(!t.url)throw new Error("No url defined.");const n=new this.v;let o;t.abortSignal&&(t.abortSignal.onabort=()=>{n.abort(),o=new r});let h,c=null;if(t.timeout){const s=t.timeout;c=setTimeout((()=>{n.abort(),this.u.log(e.Warning,"Timeout from HTTP request."),o=new i}),s)}try{h=await this.m(t.url,{body:t.content,cache:"no-cache",credentials:!0===t.withCredentials?"include":"same-origin",headers:{"Content-Type":"text/plain;charset=UTF-8","X-Requested-With":"XMLHttpRequest",...t.headers},method:t.method,mode:"cors",redirect:"follow",signal:n.signal})}catch(t){if(o)throw o;throw this.u.log(e.Warning,`Error from HTTP request. ${t}.`),t}finally{c&&clearTimeout(c),t.abortSignal&&(t.abortSignal.onabort=null)}if(!h.ok){const t=await I(h,"text");throw new s(t||h.statusText,h.status)}const a=I(h,t.responseType),l=await a;return new u(h.status,h.statusText,l)}getCookieString(t){let e="";return g.isNode&&this.p&&this.p.getCookies(t,((t,n)=>e=n.join("; "))),e}}function I(t,e){let n;switch(e){case"arraybuffer":n=t.arrayBuffer();break;case"text":n=t.text();break;case"blob":case"document":case"json":throw new Error(`${e} is not supported.`);default:n=t.text()}return n}class _ extends d{constructor(t){super(),this.u=t}send(t){return t.abortSignal&&t.abortSignal.aborted?Promise.reject(new r):t.method?t.url?new Promise(((n,o)=>{const h=new XMLHttpRequest;h.open(t.method,t.url,!0),h.withCredentials=void 0===t.withCredentials||t.withCredentials,h.setRequestHeader("X-Requested-With","XMLHttpRequest"),h.setRequestHeader("Content-Type","text/plain;charset=UTF-8");const c=t.headers;c&&Object.keys(c).forEach((t=>{h.setRequestHeader(t,c[t])})),t.responseType&&(h.responseType=t.responseType),t.abortSignal&&(t.abortSignal.onabort=()=>{h.abort(),o(new r)}),t.timeout&&(h.timeout=t.timeout),h.onload=()=>{t.abortSignal&&(t.abortSignal.onabort=null),h.status>=200&&h.status<300?n(new u(h.status,h.statusText,h.response||h.responseText)):o(new s(h.response||h.responseText||h.statusText,h.status))},h.onerror=()=>{this.u.log(e.Warning,`Error from HTTP request. ${h.status}: ${h.statusText}.`),o(new s(h.statusText,h.status))},h.ontimeout=()=>{this.u.log(e.Warning,"Timeout from HTTP request."),o(new i)},h.send(t.content||"")})):Promise.reject(new Error("No url defined.")):Promise.reject(new Error("No method defined."))}}class H extends d{constructor(t){if(super(),"undefined"!=typeof fetch||g.isNode)this.$=new T(t);else{if("undefined"==typeof XMLHttpRequest)throw new Error("No usable HttpClient found.");this.$=new _(t)}}send(t){return t.abortSignal&&t.abortSignal.aborted?Promise.reject(new r):t.method?t.url?this.$.send(t):Promise.reject(new Error("No url defined.")):Promise.reject(new Error("No method defined."))}getCookieString(t){return this.$.getCookieString(t)}}class D{static write(t){return`${t}${D.RecordSeparator}`}static parse(t){if(t[t.length-1]!==D.RecordSeparator)throw new Error("Message is incomplete.");const e=t.split(D.RecordSeparator);return e.pop(),e}}D.RecordSeparatorCode=30,D.RecordSeparator=String.fromCharCode(D.RecordSeparatorCode);class x{writeHandshakeRequest(t){return D.write(JSON.stringify(t))}parseHandshakeResponse(t){let e,n;if(m(t)){const s=new Uint8Array(t),i=s.indexOf(D.RecordSeparatorCode);if(-1===i)throw new Error("Message is incomplete.");const r=i+1;e=String.fromCharCode.apply(null,Array.prototype.slice.call(s.slice(0,r))),n=s.byteLength>r?s.slice(r).buffer:null}else{const s=t,i=s.indexOf(D.RecordSeparator);if(-1===i)throw new Error("Message is incomplete.");const r=i+1;e=s.substring(0,r),n=s.length>r?s.substring(r):null}const s=D.parse(e),i=JSON.parse(s[0]);if(i.type)throw new Error("Expected a handshake response from the server.");return[n,i]}}var R,A;!function(t){t[t.Invocation=1]="Invocation",t[t.StreamItem=2]="StreamItem",t[t.Completion=3]="Completion",t[t.StreamInvocation=4]="StreamInvocation",t[t.CancelInvocation=5]="CancelInvocation",t[t.Ping=6]="Ping",t[t.Close=7]="Close"}(R||(R={}));class U{constructor(){this.observers=[]}next(t){for(const e of this.observers)e.next(t)}error(t){for(const e of this.observers)e.error&&e.error(t)}complete(){for(const t of this.observers)t.complete&&t.complete()}subscribe(t){return this.observers.push(t),new v(this,t)}}!function(t){t.Disconnected="Disconnected",t.Connecting="Connecting",t.Connected="Connected",t.Disconnecting="Disconnecting",t.Reconnecting="Reconnecting"}(A||(A={}));class N{constructor(t,n,s,i){this.C=0,this.S=()=>{this.u.log(e.Warning,"The page is being frozen, this will likely lead to the connection being closed and messages being lost. For more information see the docs at https://docs.microsoft.com/aspnet/core/signalr/javascript-client#bsleep")},w.isRequired(t,"connection"),w.isRequired(n,"logger"),w.isRequired(s,"protocol"),this.serverTimeoutInMilliseconds=3e4,this.keepAliveIntervalInMilliseconds=15e3,this.u=n,this.k=s,this.connection=t,this.P=i,this.T=new x,this.connection.onreceive=t=>this.I(t),this.connection.onclose=t=>this._(t),this.H={},this.D={},this.R=[],this.A=[],this.U=[],this.N=0,this.L=!1,this.M=A.Disconnected,this.j=!1,this.q=this.k.writeMessage({type:R.Ping})}static create(t,e,n,s){return new N(t,e,n,s)}get state(){return this.M}get connectionId(){return this.connection&&this.connection.connectionId||null}get baseUrl(){return this.connection.baseUrl||""}set baseUrl(t){if(this.M!==A.Disconnected&&this.M!==A.Reconnecting)throw new Error("The HubConnection must be in the Disconnected or Reconnecting state to change the url.");if(!t)throw new Error("The HubConnection url must be a valid url.");this.connection.baseUrl=t}start(){return this.W=this.O(),this.W}async O(){if(this.M!==A.Disconnected)return Promise.reject(new Error("Cannot start a HubConnection that is not in the 'Disconnected' state."));this.M=A.Connecting,this.u.log(e.Debug,"Starting HubConnection.");try{await this.F(),g.isBrowser&&window.document.addEventListener("freeze",this.S),this.M=A.Connected,this.j=!0,this.u.log(e.Debug,"HubConnection connected successfully.")}catch(t){return this.M=A.Disconnected,this.u.log(e.Debug,`HubConnection failed to start successfully because of error '${t}'.`),Promise.reject(t)}}async F(){this.B=void 0,this.L=!1;const t=new Promise(((t,e)=>{this.X=t,this.J=e}));await this.connection.start(this.k.transferFormat);try{const n={protocol:this.k.name,version:this.k.version};if(this.u.log(e.Debug,"Sending handshake request."),await this.V(this.T.writeHandshakeRequest(n)),this.u.log(e.Information,`Using HubProtocol '${this.k.name}'.`),this.G(),this.K(),this.Y(),await t,this.B)throw this.B}catch(t){throw this.u.log(e.Debug,`Hub handshake failed with error '${t}' during start(). Stopping HubConnection.`),this.G(),this.Z(),await this.connection.stop(t),t}}async stop(){const t=this.W;this.tt=this.et(),await this.tt;try{await t}catch(t){}}et(t){return this.M===A.Disconnected?(this.u.log(e.Debug,`Call to HubConnection.stop(${t}) ignored because it is already in the disconnected state.`),Promise.resolve()):this.M===A.Disconnecting?(this.u.log(e.Debug,`Call to HttpConnection.stop(${t}) ignored because the connection is already in the disconnecting state.`),this.tt):(this.M=A.Disconnecting,this.u.log(e.Debug,"Stopping HubConnection."),this.nt?(this.u.log(e.Debug,"Connection stopped during reconnect delay. Done reconnecting."),clearTimeout(this.nt),this.nt=void 0,this.st(),Promise.resolve()):(this.G(),this.Z(),this.B=t||new r("The connection was stopped before the hub handshake could complete."),this.connection.stop(t)))}stream(t,...e){const[n,s]=this.it(e),i=this.rt(t,e,s);let r;const o=new U;return o.cancelCallback=()=>{const t=this.ot(i.invocationId);return delete this.H[i.invocationId],r.then((()=>this.ht(t)))},this.H[i.invocationId]=(t,e)=>{e?o.error(e):t&&(t.type===R.Completion?t.error?o.error(new Error(t.error)):o.complete():o.next(t.item))},r=this.ht(i).catch((t=>{o.error(t),delete this.H[i.invocationId]})),this.ct(n,r),o}V(t){return this.Y(),this.connection.send(t)}ht(t){return this.V(this.k.writeMessage(t))}send(t,...e){const[n,s]=this.it(e),i=this.ht(this.lt(t,e,!0,s));return this.ct(n,i),i}invoke(t,...e){const[n,s]=this.it(e),i=this.lt(t,e,!1,s);return new Promise(((t,e)=>{this.H[i.invocationId]=(n,s)=>{s?e(s):n&&(n.type===R.Completion?n.error?e(new Error(n.error)):t(n.result):e(new Error(`Unexpected message type: ${n.type}`)))};const s=this.ht(i).catch((t=>{e(t),delete this.H[i.invocationId]}));this.ct(n,s)}))}on(t,e){t&&e&&(t=t.toLowerCase(),this.D[t]||(this.D[t]=[]),-1===this.D[t].indexOf(e)&&this.D[t].push(e))}off(t,e){if(!t)return;t=t.toLowerCase();const n=this.D[t];if(n)if(e){const s=n.indexOf(e);-1!==s&&(n.splice(s,1),0===n.length&&delete this.D[t])}else delete this.D[t]}onclose(t){t&&this.R.push(t)}onreconnecting(t){t&&this.A.push(t)}onreconnected(t){t&&this.U.push(t)}I(t){if(this.G(),this.L||(t=this.ut(t),this.L=!0),t){const n=this.k.parseMessages(t,this.u);for(const t of n)switch(t.type){case R.Invocation:this.dt(t);break;case R.StreamItem:case R.Completion:{const n=this.H[t.invocationId];if(n){t.type===R.Completion&&delete this.H[t.invocationId];try{n(t)}catch(t){this.u.log(e.Error,`Stream callback threw error: ${P(t)}`)}}break}case R.Ping:break;case R.Close:{this.u.log(e.Information,"Close message received from server.");const n=t.error?new Error("Server returned an error on close: "+t.error):void 0;!0===t.allowReconnect?this.connection.stop(n):this.tt=this.et(n);break}default:this.u.log(e.Warning,`Invalid message type: ${t.type}.`)}}this.K()}ut(t){let n,s;try{[s,n]=this.T.parseHandshakeResponse(t)}catch(t){const n="Error parsing handshake response: "+t;this.u.log(e.Error,n);const s=new Error(n);throw this.J(s),s}if(n.error){const t="Server returned handshake error: "+n.error;this.u.log(e.Error,t);const s=new Error(t);throw this.J(s),s}return this.u.log(e.Debug,"Server handshake complete."),this.X(),s}Y(){this.connection.features.inherentKeepAlive||(this.C=(new Date).getTime()+this.keepAliveIntervalInMilliseconds,this.Z())}K(){if(!(this.connection.features&&this.connection.features.inherentKeepAlive||(this.ft=setTimeout((()=>this.serverTimeout()),this.serverTimeoutInMilliseconds),void 0!==this.wt))){let t=this.C-(new Date).getTime();t<0&&(t=0),this.wt=setTimeout((async()=>{if(this.M===A.Connected)try{await this.V(this.q)}catch{this.Z()}}),t)}}serverTimeout(){this.connection.stop(new Error("Server timeout elapsed without receiving a message from the server."))}async dt(t){const n=t.target.toLowerCase(),s=this.D[n];if(!s)return this.u.log(e.Warning,`No client method with the name '${n}' found.`),void(t.invocationId&&(this.u.log(e.Warning,`No result given for '${n}' method and invocation ID '${t.invocationId}'.`),await this.ht(this.gt(t.invocationId,"Client didn't provide a result.",null))));const i=s.slice(),r=!!t.invocationId;let o,h,c;for(const s of i)try{const i=o;o=await s.apply(this,t.arguments),r&&o&&i&&(this.u.log(e.Error,`Multiple results provided for '${n}'. Sending error to server.`),c=this.gt(t.invocationId,"Client provided multiple results.",null)),h=void 0}catch(t){h=t,this.u.log(e.Error,`A callback for the method '${n}' threw error '${t}'.`)}c?await this.ht(c):r?(h?c=this.gt(t.invocationId,`${h}`,null):void 0!==o?c=this.gt(t.invocationId,null,o):(this.u.log(e.Warning,`No result given for '${n}' method and invocation ID '${t.invocationId}'.`),c=this.gt(t.invocationId,"Client didn't provide a result.",null)),await this.ht(c)):o&&this.u.log(e.Error,`Result given for '${n}' method but server is not expecting a result.`)}_(t){this.u.log(e.Debug,`HubConnection.connectionClosed(${t}) called while in state ${this.M}.`),this.B=this.B||t||new r("The underlying connection was closed before the hub handshake could complete."),this.X&&this.X(),this.yt(t||new Error("Invocation canceled due to the underlying connection being closed.")),this.G(),this.Z(),this.M===A.Disconnecting?this.st(t):this.M===A.Connected&&this.P?this.bt(t):this.M===A.Connected&&this.st(t)}st(t){if(this.j){this.M=A.Disconnected,this.j=!1,g.isBrowser&&window.document.removeEventListener("freeze",this.S);try{this.R.forEach((e=>e.apply(this,[t])))}catch(n){this.u.log(e.Error,`An onclose callback called with error '${t}' threw error '${n}'.`)}}}async bt(t){const n=Date.now();let s=0,i=void 0!==t?t:new Error("Attempting to reconnect due to a unknown error."),r=this.vt(s++,0,i);if(null===r)return this.u.log(e.Debug,"Connection not reconnecting because the IRetryPolicy returned null on the first reconnect attempt."),void this.st(t);if(this.M=A.Reconnecting,t?this.u.log(e.Information,`Connection reconnecting because of error '${t}'.`):this.u.log(e.Information,"Connection reconnecting."),0!==this.A.length){try{this.A.forEach((e=>e.apply(this,[t])))}catch(n){this.u.log(e.Error,`An onreconnecting callback called with error '${t}' threw error '${n}'.`)}if(this.M!==A.Reconnecting)return void this.u.log(e.Debug,"Connection left the reconnecting state in onreconnecting callback. Done reconnecting.")}for(;null!==r;){if(this.u.log(e.Information,`Reconnect attempt number ${s} will start in ${r} ms.`),await new Promise((t=>{this.nt=setTimeout(t,r)})),this.nt=void 0,this.M!==A.Reconnecting)return void this.u.log(e.Debug,"Connection left the reconnecting state during reconnect delay. Done reconnecting.");try{if(await this.F(),this.M=A.Connected,this.u.log(e.Information,"HubConnection reconnected successfully."),0!==this.U.length)try{this.U.forEach((t=>t.apply(this,[this.connection.connectionId])))}catch(t){this.u.log(e.Error,`An onreconnected callback called with connectionId '${this.connection.connectionId}; threw error '${t}'.`)}return}catch(t){if(this.u.log(e.Information,`Reconnect attempt failed because of error '${t}'.`),this.M!==A.Reconnecting)return this.u.log(e.Debug,`Connection moved to the '${this.M}' from the reconnecting state during reconnect attempt. Done reconnecting.`),void(this.M===A.Disconnecting&&this.st());i=t instanceof Error?t:new Error(t.toString()),r=this.vt(s++,Date.now()-n,i)}}this.u.log(e.Information,`Reconnect retries have been exhausted after ${Date.now()-n} ms and ${s} failed attempts. Connection disconnecting.`),this.st()}vt(t,n,s){try{return this.P.nextRetryDelayInMilliseconds({elapsedMilliseconds:n,previousRetryCount:t,retryReason:s})}catch(s){return this.u.log(e.Error,`IRetryPolicy.nextRetryDelayInMilliseconds(${t}, ${n}) threw error '${s}'.`),null}}yt(t){const n=this.H;this.H={},Object.keys(n).forEach((s=>{const i=n[s];try{i(null,t)}catch(n){this.u.log(e.Error,`Stream 'error' callback called with '${t}' threw error: ${P(n)}`)}}))}Z(){this.wt&&(clearTimeout(this.wt),this.wt=void 0)}G(){this.ft&&clearTimeout(this.ft)}lt(t,e,n,s){if(n)return 0!==s.length?{arguments:e,streamIds:s,target:t,type:R.Invocation}:{arguments:e,target:t,type:R.Invocation};{const n=this.N;return this.N++,0!==s.length?{arguments:e,invocationId:n.toString(),streamIds:s,target:t,type:R.Invocation}:{arguments:e,invocationId:n.toString(),target:t,type:R.Invocation}}}ct(t,e){if(0!==t.length){e||(e=Promise.resolve());for(const n in t)t[n].subscribe({complete:()=>{e=e.then((()=>this.ht(this.gt(n))))},error:t=>{let s;s=t instanceof Error?t.message:t&&t.toString?t.toString():"Unknown error",e=e.then((()=>this.ht(this.gt(n,s))))},next:t=>{e=e.then((()=>this.ht(this.$t(n,t))))}})}}it(t){const e=[],n=[];for(let s=0;s<t.length;s++){const i=t[s];if(this.Et(i)){const r=this.N;this.N++,e[r]=i,n.push(r.toString()),t.splice(s,1)}}return[e,n]}Et(t){return t&&t.subscribe&&"function"==typeof t.subscribe}rt(t,e,n){const s=this.N;return this.N++,0!==n.length?{arguments:e,invocationId:s.toString(),streamIds:n,target:t,type:R.StreamInvocation}:{arguments:e,invocationId:s.toString(),target:t,type:R.StreamInvocation}}ot(t){return{invocationId:t,type:R.CancelInvocation}}$t(t,e){return{invocationId:t,item:e,type:R.StreamItem}}gt(t,e,n){return e?{error:e,invocationId:t,type:R.Completion}:{invocationId:t,result:n,type:R.Completion}}}const L=[0,2e3,1e4,3e4,null];class M{constructor(t){this.Ct=void 0!==t?[...t,null]:L}nextRetryDelayInMilliseconds(t){return this.Ct[t.previousRetryCount]}}class j{}var q,W;j.Authorization="Authorization",j.Cookie="Cookie",function(t){t[t.None=0]="None",t[t.WebSockets=1]="WebSockets",t[t.ServerSentEvents=2]="ServerSentEvents",t[t.LongPolling=4]="LongPolling"}(q||(q={})),function(t){t[t.Text=1]="Text",t[t.Binary=2]="Binary"}(W||(W={}));class O{constructor(){this.St=!1,this.onabort=null}abort(){this.St||(this.St=!0,this.onabort&&this.onabort())}get signal(){return this}get aborted(){return this.St}}class F{constructor(t,e,n,s){this.$=t,this.kt=e,this.u=n,this.Pt=new O,this.Tt=s,this.It=!1,this.onreceive=null,this.onclose=null}get pollAborted(){return this.Pt.aborted}async connect(t,n){if(w.isRequired(t,"url"),w.isRequired(n,"transferFormat"),w.isIn(n,W,"transferFormat"),this._t=t,this.u.log(e.Trace,"(LongPolling transport) Connecting."),n===W.Binary&&"undefined"!=typeof XMLHttpRequest&&"string"!=typeof(new XMLHttpRequest).responseType)throw new Error("Binary protocols over XmlHttpRequest not implementing advanced features are not supported.");const[i,r]=E(),o={[i]:r,...this.Tt.headers},h={abortSignal:this.Pt.signal,headers:o,timeout:1e5,withCredentials:this.Tt.withCredentials};n===W.Binary&&(h.responseType="arraybuffer"),await this.Ht(h);const c=`${t}&_=${Date.now()}`;this.u.log(e.Trace,`(LongPolling transport) polling: ${c}.`);const a=await this.$.get(c,h);200!==a.statusCode?(this.u.log(e.Error,`(LongPolling transport) Unexpected response code: ${a.statusCode}.`),this.Dt=new s(a.statusText||"",a.statusCode),this.It=!1):this.It=!0,this.xt=this.Rt(this._t,h)}async Ht(t){if(t.headers||(t.headers={}),this.kt){const e=await this.kt();e?t.headers[j.Authorization]=`Bearer ${e}`:t.headers[j.Authorization]&&delete t.headers[j.Authorization]}}async Rt(t,n){try{for(;this.It;){await this.Ht(n);try{const i=`${t}&_=${Date.now()}`;this.u.log(e.Trace,`(LongPolling transport) polling: ${i}.`);const r=await this.$.get(i,n);204===r.statusCode?(this.u.log(e.Information,"(LongPolling transport) Poll terminated by server."),this.It=!1):200!==r.statusCode?(this.u.log(e.Error,`(LongPolling transport) Unexpected response code: ${r.statusCode}.`),this.Dt=new s(r.statusText||"",r.statusCode),this.It=!1):r.content?(this.u.log(e.Trace,`(LongPolling transport) data received. ${y(r.content,this.Tt.logMessageContent)}.`),this.onreceive&&this.onreceive(r.content)):this.u.log(e.Trace,"(LongPolling transport) Poll timed out, reissuing.")}catch(t){this.It?t instanceof i?this.u.log(e.Trace,"(LongPolling transport) Poll timed out, reissuing."):(this.Dt=t,this.It=!1):this.u.log(e.Trace,`(LongPolling transport) Poll errored after shutdown: ${t.message}`)}}}finally{this.u.log(e.Trace,"(LongPolling transport) Polling complete."),this.pollAborted||this.At()}}async send(t){return this.It?b(this.u,"LongPolling",this.$,this._t,this.kt,t,this.Tt):Promise.reject(new Error("Cannot send until the transport is connected"))}async stop(){this.u.log(e.Trace,"(LongPolling transport) Stopping polling."),this.It=!1,this.Pt.abort();try{await this.xt,this.u.log(e.Trace,`(LongPolling transport) sending DELETE request to ${this._t}.`);const t={},[n,s]=E();t[n]=s;const i={headers:{...t,...this.Tt.headers},timeout:this.Tt.timeout,withCredentials:this.Tt.withCredentials};await this.Ht(i),await this.$.delete(this._t,i),this.u.log(e.Trace,"(LongPolling transport) DELETE request sent.")}finally{this.u.log(e.Trace,"(LongPolling transport) Stop finished."),this.At()}}At(){if(this.onclose){let t="(LongPolling transport) Firing onclose event.";this.Dt&&(t+=" Error: "+this.Dt),this.u.log(e.Trace,t),this.onclose(this.Dt)}}}class B{constructor(t,e,n,s){this.$=t,this.kt=e,this.u=n,this.Tt=s,this.onreceive=null,this.onclose=null}async connect(t,n){if(w.isRequired(t,"url"),w.isRequired(n,"transferFormat"),w.isIn(n,W,"transferFormat"),this.u.log(e.Trace,"(SSE transport) Connecting."),this._t=t,this.kt){const e=await this.kt();e&&(t+=(t.indexOf("?")<0?"?":"&")+`access_token=${encodeURIComponent(e)}`)}return new Promise(((s,i)=>{let r,o=!1;if(n===W.Text){if(g.isBrowser||g.isWebWorker)r=new this.Tt.EventSource(t,{withCredentials:this.Tt.withCredentials});else{const e=this.$.getCookieString(t),n={};n.Cookie=e;const[s,i]=E();n[s]=i,r=new this.Tt.EventSource(t,{withCredentials:this.Tt.withCredentials,headers:{...n,...this.Tt.headers}})}try{r.onmessage=t=>{if(this.onreceive)try{this.u.log(e.Trace,`(SSE transport) data received. ${y(t.data,this.Tt.logMessageContent)}.`),this.onreceive(t.data)}catch(t){return void this.Ut(t)}},r.onerror=t=>{o?this.Ut():i(new Error("EventSource failed to connect. The connection could not be found on the server, either the connection ID is not present on the server, or a proxy is refusing/buffering the connection. If you have multiple servers check that sticky sessions are enabled."))},r.onopen=()=>{this.u.log(e.Information,`SSE connected to ${this._t}`),this.Nt=r,o=!0,s()}}catch(t){return void i(t)}}else i(new Error("The Server-Sent Events transport only supports the 'Text' transfer format"))}))}async send(t){return this.Nt?b(this.u,"SSE",this.$,this._t,this.kt,t,this.Tt):Promise.reject(new Error("Cannot send until the transport is connected"))}stop(){return this.Ut(),Promise.resolve()}Ut(t){this.Nt&&(this.Nt.close(),this.Nt=void 0,this.onclose&&this.onclose(t))}}class X{constructor(t,e,n,s,i,r){this.u=n,this.kt=e,this.Lt=s,this.Mt=i,this.$=t,this.onreceive=null,this.onclose=null,this.jt=r}async connect(t,n){let s;return w.isRequired(t,"url"),w.isRequired(n,"transferFormat"),w.isIn(n,W,"transferFormat"),this.u.log(e.Trace,"(WebSockets transport) Connecting."),this.kt&&(s=await this.kt()),new Promise(((i,r)=>{let o;t=t.replace(/^http/,"ws");const h=this.$.getCookieString(t);let c=!1;if(g.isNode||g.isReactNative){const e={},[n,i]=E();e[n]=i,s&&(e[j.Authorization]=`Bearer ${s}`),h&&(e[j.Cookie]=h),o=new this.Mt(t,void 0,{headers:{...e,...this.jt}})}else s&&(t+=(t.indexOf("?")<0?"?":"&")+`access_token=${encodeURIComponent(s)}`);o||(o=new this.Mt(t)),n===W.Binary&&(o.binaryType="arraybuffer"),o.onopen=n=>{this.u.log(e.Information,`WebSocket connected to ${t}.`),this.qt=o,c=!0,i()},o.onerror=t=>{let n=null;n="undefined"!=typeof ErrorEvent&&t instanceof ErrorEvent?t.error:"There was an error with the transport",this.u.log(e.Information,`(WebSockets transport) ${n}.`)},o.onmessage=t=>{if(this.u.log(e.Trace,`(WebSockets transport) data received. ${y(t.data,this.Lt)}.`),this.onreceive)try{this.onreceive(t.data)}catch(t){return void this.Ut(t)}},o.onclose=t=>{if(c)this.Ut(t);else{let e=null;e="undefined"!=typeof ErrorEvent&&t instanceof ErrorEvent?t.error:"WebSocket failed to connect. The connection could not be found on the server, either the endpoint may not be a SignalR endpoint, the connection ID is not present on the server, or there is a proxy blocking WebSockets. If you have multiple servers check that sticky sessions are enabled.",r(new Error(e))}}}))}send(t){return this.qt&&this.qt.readyState===this.Mt.OPEN?(this.u.log(e.Trace,`(WebSockets transport) sending data. ${y(t,this.Lt)}.`),this.qt.send(t),Promise.resolve()):Promise.reject("WebSocket is not in the OPEN state")}stop(){return this.qt&&this.Ut(void 0),Promise.resolve()}Ut(t){this.qt&&(this.qt.onclose=()=>{},this.qt.onmessage=()=>{},this.qt.onerror=()=>{},this.qt.close(),this.qt=void 0),this.u.log(e.Trace,"(WebSockets transport) socket closed."),this.onclose&&(!this.Wt(t)||!1!==t.wasClean&&1e3===t.code?t instanceof Error?this.onclose(t):this.onclose():this.onclose(new Error(`WebSocket closed with status code: ${t.code} (${t.reason||"no reason given"}).`)))}Wt(t){return t&&"boolean"==typeof t.wasClean&&"number"==typeof t.code}}class J{constructor(t,n={}){var s;if(this.Ot=()=>{},this.features={},this.Ft=1,w.isRequired(t,"url"),this.u=void 0===(s=n.logger)?new $(e.Information):null===s?f.instance:void 0!==s.log?s:new $(s),this.baseUrl=this.Bt(t),(n=n||{}).logMessageContent=void 0!==n.logMessageContent&&n.logMessageContent,"boolean"!=typeof n.withCredentials&&void 0!==n.withCredentials)throw new Error("withCredentials option was not a 'boolean' or 'undefined' value");n.withCredentials=void 0===n.withCredentials||n.withCredentials,n.timeout=void 0===n.timeout?1e5:n.timeout;let i=null,r=null;if(g.isNode){const t=require;i=t("ws"),r=t("eventsource")}g.isNode||"undefined"==typeof WebSocket||n.WebSocket?g.isNode&&!n.WebSocket&&i&&(n.WebSocket=i):n.WebSocket=WebSocket,g.isNode||"undefined"==typeof EventSource||n.EventSource?g.isNode&&!n.EventSource&&void 0!==r&&(n.EventSource=r):n.EventSource=EventSource,this.$=n.httpClient||new H(this.u),this.M="Disconnected",this.j=!1,this.Tt=n,this.onreceive=null,this.onclose=null}async start(t){if(t=t||W.Binary,w.isIn(t,W,"transferFormat"),this.u.log(e.Debug,`Starting connection with transfer format '${W[t]}'.`),"Disconnected"!==this.M)return Promise.reject(new Error("Cannot start an HttpConnection that is not in the 'Disconnected' state."));if(this.M="Connecting",this.Xt=this.F(t),await this.Xt,"Disconnecting"===this.M){const t="Failed to start the HttpConnection before stop() was called.";return this.u.log(e.Error,t),await this.tt,Promise.reject(new r(t))}if("Connected"!==this.M){const t="HttpConnection.startInternal completed gracefully but didn't enter the connection into the connected state!";return this.u.log(e.Error,t),Promise.reject(new r(t))}this.j=!0}send(t){return"Connected"!==this.M?Promise.reject(new Error("Cannot send data if the connection is not in the 'Connected' State.")):(this.Jt||(this.Jt=new z(this.transport)),this.Jt.send(t))}async stop(t){return"Disconnected"===this.M?(this.u.log(e.Debug,`Call to HttpConnection.stop(${t}) ignored because the connection is already in the disconnected state.`),Promise.resolve()):"Disconnecting"===this.M?(this.u.log(e.Debug,`Call to HttpConnection.stop(${t}) ignored because the connection is already in the disconnecting state.`),this.tt):(this.M="Disconnecting",this.tt=new Promise((t=>{this.Ot=t})),await this.et(t),void await this.tt)}async et(t){this.zt=t;try{await this.Xt}catch(t){}if(this.transport){try{await this.transport.stop()}catch(t){this.u.log(e.Error,`HttpConnection.transport.stop() threw error '${t}'.`),this.Vt()}this.transport=void 0}else this.u.log(e.Debug,"HttpConnection.transport is undefined in HttpConnection.stop() because start() failed.")}async F(t){let n=this.baseUrl;this.kt=this.Tt.accessTokenFactory;try{if(this.Tt.skipNegotiation){if(this.Tt.transport!==q.WebSockets)throw new Error("Negotiation can only be skipped when using the WebSocket transport directly.");this.transport=this.Gt(q.WebSockets),await this.Kt(n,t)}else{let e=null,s=0;do{if(e=await this.Qt(n),"Disconnecting"===this.M||"Disconnected"===this.M)throw new r("The connection was stopped during negotiation.");if(e.error)throw new Error(e.error);if(e.ProtocolVersion)throw new Error("Detected a connection attempt to an ASP.NET SignalR Server. This client only supports connecting to an ASP.NET Core SignalR Server. See https://aka.ms/signalr-core-differences for details.");if(e.url&&(n=e.url),e.accessToken){const t=e.accessToken;this.kt=()=>t}s++}while(e.url&&s<100);if(100===s&&e.url)throw new Error("Negotiate redirection limit exceeded.");await this.Yt(n,this.Tt.transport,e,t)}this.transport instanceof F&&(this.features.inherentKeepAlive=!0),"Connecting"===this.M&&(this.u.log(e.Debug,"The HttpConnection connected successfully."),this.M="Connected")}catch(t){return this.u.log(e.Error,"Failed to start the connection: "+t),this.M="Disconnected",this.transport=void 0,this.Ot(),Promise.reject(t)}}async Qt(t){const n={};if(this.kt){const t=await this.kt();t&&(n[j.Authorization]=`Bearer ${t}`)}const[i,r]=E();n[i]=r;const o=this.Zt(t);this.u.log(e.Debug,`Sending negotiation request: ${o}.`);try{const t=await this.$.post(o,{content:"",headers:{...n,...this.Tt.headers},timeout:this.Tt.timeout,withCredentials:this.Tt.withCredentials});if(200!==t.statusCode)return Promise.reject(new Error(`Unexpected status code returned from negotiate '${t.statusCode}'`));const e=JSON.parse(t.content);return(!e.negotiateVersion||e.negotiateVersion<1)&&(e.connectionToken=e.connectionId),e}catch(t){let n="Failed to complete negotiation with the server: "+t;return t instanceof s&&404===t.statusCode&&(n+=" Either this is not a SignalR endpoint or there is a proxy blocking the connection."),this.u.log(e.Error,n),Promise.reject(new a(n))}}te(t,e){return e?t+(-1===t.indexOf("?")?"?":"&")+`id=${e}`:t}async Yt(t,n,s,i){let o=this.te(t,s.connectionToken);if(this.ee(n))return this.u.log(e.Debug,"Connection was provided an instance of ITransport, using that directly."),this.transport=n,await this.Kt(o,i),void(this.connectionId=s.connectionId);const h=[],a=s.availableTransports||[];let u=s;for(const s of a){const a=this.ne(s,n,i);if(a instanceof Error)h.push(`${s.transport} failed:`),h.push(a);else if(this.ee(a)){if(this.transport=a,!u){try{u=await this.Qt(t)}catch(t){return Promise.reject(t)}o=this.te(t,u.connectionToken)}try{return await this.Kt(o,i),void(this.connectionId=u.connectionId)}catch(t){if(this.u.log(e.Error,`Failed to start the transport '${s.transport}': ${t}`),u=void 0,h.push(new c(`${s.transport} failed: ${t}`,q[s.transport])),"Connecting"!==this.M){const t="Failed to select transport before stop() was called.";return this.u.log(e.Debug,t),Promise.reject(new r(t))}}}}return h.length>0?Promise.reject(new l(`Unable to connect to the server with any of the available transports. ${h.join(" ")}`,h)):Promise.reject(new Error("None of the transports supported by the client are supported by the server."))}Gt(t){switch(t){case q.WebSockets:if(!this.Tt.WebSocket)throw new Error("'WebSocket' is not supported in your environment.");return new X(this.$,this.kt,this.u,this.Tt.logMessageContent,this.Tt.WebSocket,this.Tt.headers||{});case q.ServerSentEvents:if(!this.Tt.EventSource)throw new Error("'EventSource' is not supported in your environment.");return new B(this.$,this.kt,this.u,this.Tt);case q.LongPolling:return new F(this.$,this.kt,this.u,this.Tt);default:throw new Error(`Unknown transport: ${t}.`)}}Kt(t,e){return this.transport.onreceive=this.onreceive,this.transport.onclose=t=>this.Vt(t),this.transport.connect(t,e)}ne(t,n,s){const i=q[t.transport];if(null==i)return this.u.log(e.Debug,`Skipping transport '${t.transport}' because it is not supported by this client.`),new Error(`Skipping transport '${t.transport}' because it is not supported by this client.`);if(!function(t,e){return!t||0!=(e&t)}(n,i))return this.u.log(e.Debug,`Skipping transport '${q[i]}' because it was disabled by the client.`),new h(`'${q[i]}' is disabled by the client.`,i);if(!(t.transferFormats.map((t=>W[t])).indexOf(s)>=0))return this.u.log(e.Debug,`Skipping transport '${q[i]}' because it does not support the requested transfer format '${W[s]}'.`),new Error(`'${q[i]}' does not support ${W[s]}.`);if(i===q.WebSockets&&!this.Tt.WebSocket||i===q.ServerSentEvents&&!this.Tt.EventSource)return this.u.log(e.Debug,`Skipping transport '${q[i]}' because it is not supported in your environment.'`),new o(`'${q[i]}' is not supported in your environment.`,i);this.u.log(e.Debug,`Selecting transport '${q[i]}'.`);try{return this.Gt(i)}catch(t){return t}}ee(t){return t&&"object"==typeof t&&"connect"in t}Vt(t){if(this.u.log(e.Debug,`HttpConnection.stopConnection(${t}) called while in state ${this.M}.`),this.transport=void 0,t=this.zt||t,this.zt=void 0,"Disconnected"!==this.M){if("Connecting"===this.M)throw this.u.log(e.Warning,`Call to HttpConnection.stopConnection(${t}) was ignored because the connection is still in the connecting state.`),new Error(`HttpConnection.stopConnection(${t}) was called while the connection is still in the connecting state.`);if("Disconnecting"===this.M&&this.Ot(),t?this.u.log(e.Error,`Connection disconnected with error '${t}'.`):this.u.log(e.Information,"Connection disconnected."),this.Jt&&(this.Jt.stop().catch((t=>{this.u.log(e.Error,`TransportSendQueue.stop() threw error '${t}'.`)})),this.Jt=void 0),this.connectionId=void 0,this.M="Disconnected",this.j){this.j=!1;try{this.onclose&&this.onclose(t)}catch(n){this.u.log(e.Error,`HttpConnection.onclose(${t}) threw error '${n}'.`)}}}else this.u.log(e.Debug,`Call to HttpConnection.stopConnection(${t}) was ignored because the connection is already in the disconnected state.`)}Bt(t){if(0===t.lastIndexOf("https://",0)||0===t.lastIndexOf("http://",0))return t;if(!g.isBrowser)throw new Error(`Cannot resolve '${t}'.`);const n=window.document.createElement("a");return n.href=t,this.u.log(e.Information,`Normalizing '${t}' to '${n.href}'.`),n.href}Zt(t){const e=t.indexOf("?");let n=t.substring(0,-1===e?t.length:e);return"/"!==n[n.length-1]&&(n+="/"),n+="negotiate",n+=-1===e?"":t.substring(e),-1===n.indexOf("negotiateVersion")&&(n+=-1===e?"?":"&",n+="negotiateVersion="+this.Ft),n}}class z{constructor(t){this.se=t,this.ie=[],this.re=!0,this.oe=new V,this.he=new V,this.ce=this.ae()}send(t){return this.le(t),this.he||(this.he=new V),this.he.promise}stop(){return this.re=!1,this.oe.resolve(),this.ce}le(t){if(this.ie.length&&typeof this.ie[0]!=typeof t)throw new Error(`Expected data to be of type ${typeof this.ie} but was of type ${typeof t}`);this.ie.push(t),this.oe.resolve()}async ae(){for(;;){if(await this.oe.promise,!this.re){this.he&&this.he.reject("Connection stopped.");break}this.oe=new V;const t=this.he;this.he=void 0;const e="string"==typeof this.ie[0]?this.ie.join(""):z.ue(this.ie);this.ie.length=0;try{await this.se.send(e),t.resolve()}catch(e){t.reject(e)}}}static ue(t){const e=t.map((t=>t.byteLength)).reduce(((t,e)=>t+e)),n=new Uint8Array(e);let s=0;for(const e of t)n.set(new Uint8Array(e),s),s+=e.byteLength;return n.buffer}}class V{constructor(){this.promise=new Promise(((t,e)=>[this.de,this.fe]=[t,e]))}resolve(){this.de()}reject(t){this.fe(t)}}class G{constructor(){this.name="json",this.version=1,this.transferFormat=W.Text}parseMessages(t,n){if("string"!=typeof t)throw new Error("Invalid input for JSON hub protocol. Expected a string.");if(!t)return[];null===n&&(n=f.instance);const s=D.parse(t),i=[];for(const t of s){const s=JSON.parse(t);if("number"!=typeof s.type)throw new Error("Invalid payload.");switch(s.type){case R.Invocation:this.pe(s);break;case R.StreamItem:this.we(s);break;case R.Completion:this.ge(s);break;case R.Ping:case R.Close:break;default:n.log(e.Information,"Unknown message type '"+s.type+"' ignored.");continue}i.push(s)}return i}writeMessage(t){return D.write(JSON.stringify(t))}pe(t){this.ye(t.target,"Invalid payload for Invocation message."),void 0!==t.invocationId&&this.ye(t.invocationId,"Invalid payload for Invocation message.")}we(t){if(this.ye(t.invocationId,"Invalid payload for StreamItem message."),void 0===t.item)throw new Error("Invalid payload for StreamItem message.")}ge(t){if(t.result&&t.error)throw new Error("Invalid payload for Completion message.");!t.result&&t.error&&this.ye(t.error,"Invalid payload for Completion message."),this.ye(t.invocationId,"Invalid payload for Completion message.")}ye(t,e){if("string"!=typeof t||""===t)throw new Error(e)}}const K={trace:e.Trace,debug:e.Debug,info:e.Information,information:e.Information,warn:e.Warning,warning:e.Warning,error:e.Error,critical:e.Critical,none:e.None};class Q{configureLogging(t){if(w.isRequired(t,"logging"),void 0!==t.log)this.logger=t;else if("string"==typeof t){const e=function(t){const e=K[t.toLowerCase()];if(void 0!==e)return e;throw new Error(`Unknown log level: ${t}`)}(t);this.logger=new $(e)}else this.logger=new $(t);return this}withUrl(t,e){return w.isRequired(t,"url"),w.isNotEmpty(t,"url"),this.url=t,this.httpConnectionOptions="object"==typeof e?{...this.httpConnectionOptions,...e}:{...this.httpConnectionOptions,transport:e},this}withHubProtocol(t){return w.isRequired(t,"protocol"),this.protocol=t,this}withAutomaticReconnect(t){if(this.reconnectPolicy)throw new Error("A reconnectPolicy has already been set.");return t?Array.isArray(t)?this.reconnectPolicy=new M(t):this.reconnectPolicy=t:this.reconnectPolicy=new M,this}build(){const t=this.httpConnectionOptions||{};if(void 0===t.logger&&(t.logger=this.logger),!this.url)throw new Error("The 'HubConnectionBuilder.withUrl' method must be called before building the connection.");const e=new J(this.url,t);return N.create(e,this.logger||f.instance,this.protocol||new G,this.reconnectPolicy)}}return Uint8Array.prototype.indexOf||Object.defineProperty(Uint8Array.prototype,"indexOf",{value:Array.prototype.indexOf,writable:!0}),Uint8Array.prototype.slice||Object.defineProperty(Uint8Array.prototype,"slice",{value:function(t,e){return new Uint8Array(Array.prototype.slice.call(this,t,e))},writable:!0}),Uint8Array.prototype.forEach||Object.defineProperty(Uint8Array.prototype,"forEach",{value:Array.prototype.forEach,writable:!0}),n})()},"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.signalR=e():t.signalR=e();
var t,e;t=self,e=function(){return(()=>{var t={d:(e,n)=>{for(var s in n)t.o(n,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:n[s]})}};t.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),t.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),t.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"t",{value:!0})};var e,n={};t.r(n),t.d(n,{AbortError:()=>r,DefaultHttpClient:()=>H,HttpClient:()=>d,HttpError:()=>s,HttpResponse:()=>u,HttpTransportType:()=>q,HubConnection:()=>N,HubConnectionBuilder:()=>Q,HubConnectionState:()=>A,JsonHubProtocol:()=>G,LogLevel:()=>e,MessageType:()=>R,NullLogger:()=>f,Subject:()=>U,TimeoutError:()=>i,TransferFormat:()=>W,VERSION:()=>p});class s extends Error{constructor(t,e){const n=new.target.prototype;super(`${t}: Status code '${e}'`),this.statusCode=e,this.__proto__=n}}class i extends Error{constructor(t="A timeout occurred."){const e=new.target.prototype;super(t),this.__proto__=e}}class r extends Error{constructor(t="An abort occurred."){const e=new.target.prototype;super(t),this.__proto__=e}}class o extends Error{constructor(t,e){const n=new.target.prototype;super(t),this.transport=e,this.errorType="UnsupportedTransportError",this.__proto__=n}}class h extends Error{constructor(t,e){const n=new.target.prototype;super(t),this.transport=e,this.errorType="DisabledTransportError",this.__proto__=n}}class c extends Error{constructor(t,e){const n=new.target.prototype;super(t),this.transport=e,this.errorType="FailedToStartTransportError",this.__proto__=n}}class a extends Error{constructor(t){const e=new.target.prototype;super(t),this.errorType="FailedToNegotiateWithServerError",this.__proto__=e}}class l extends Error{constructor(t,e){const n=new.target.prototype;super(t),this.innerErrors=e,this.__proto__=n}}class u{constructor(t,e,n){this.statusCode=t,this.statusText=e,this.content=n}}class d{get(t,e){return this.send({...e,method:"GET",url:t})}post(t,e){return this.send({...e,method:"POST",url:t})}delete(t,e){return this.send({...e,method:"DELETE",url:t})}getCookieString(t){return""}}!function(t){t[t.Trace=0]="Trace",t[t.Debug=1]="Debug",t[t.Information=2]="Information",t[t.Warning=3]="Warning",t[t.Error=4]="Error",t[t.Critical=5]="Critical",t[t.None=6]="None"}(e||(e={}));class f{constructor(){}log(t,e){}}f.instance=new f;const p="7.0.0-preview.5.22303.8";class w{static isRequired(t,e){if(null==t)throw new Error(`The '${e}' argument is required.`)}static isNotEmpty(t,e){if(!t||t.match(/^\s*$/))throw new Error(`The '${e}' argument should not be empty.`)}static isIn(t,e,n){if(!(t in e))throw new Error(`Unknown ${n} value: ${t}.`)}}class g{static get isBrowser(){return"object"==typeof window&&"object"==typeof window.document}static get isWebWorker(){return"object"==typeof self&&"importScripts"in self}static get isReactNative(){return"object"==typeof window&&void 0===window.document}static get isNode(){return!this.isBrowser&&!this.isWebWorker&&!this.isReactNative}}function y(t,e){let n="";return m(t)?(n=`Binary data of length ${t.byteLength}`,e&&(n+=`. Content: '${function(t){const e=new Uint8Array(t);let n="";return e.forEach((t=>{n+=`0x${t<16?"0":""}${t.toString(16)} `})),n.substr(0,n.length-1)}(t)}'`)):"string"==typeof t&&(n=`String data of length ${t.length}`,e&&(n+=`. Content: '${t}'`)),n}function m(t){return t&&"undefined"!=typeof ArrayBuffer&&(t instanceof ArrayBuffer||t.constructor&&"ArrayBuffer"===t.constructor.name)}async function b(t,n,s,i,r,o,h){let c={};if(r){const t=await r();t&&(c={Authorization:`Bearer ${t}`})}const[a,l]=E();c[a]=l,t.log(e.Trace,`(${n} transport) sending data. ${y(o,h.logMessageContent)}.`);const u=m(o)?"arraybuffer":"text",d=await s.post(i,{content:o,headers:{...c,...h.headers},responseType:u,timeout:h.timeout,withCredentials:h.withCredentials});t.log(e.Trace,`(${n} transport) request complete. Response status: ${d.statusCode}.`)}class v{constructor(t,e){this.i=t,this.h=e}dispose(){const t=this.i.observers.indexOf(this.h);t>-1&&this.i.observers.splice(t,1),0===this.i.observers.length&&this.i.cancelCallback&&this.i.cancelCallback().catch((t=>{}))}}class ${constructor(t){this.l=t,this.out=console}log(t,n){if(t>=this.l){const s=`[${(new Date).toISOString()}] ${e[t]}: ${n}`;switch(t){case e.Critical:case e.Error:this.out.error(s);break;case e.Warning:this.out.warn(s);break;case e.Information:this.out.info(s);break;default:this.out.log(s)}}}}function E(){let t="X-SignalR-User-Agent";return g.isNode&&(t="User-Agent"),[t,C(p,S(),g.isNode?"NodeJS":"Browser",k())]}function C(t,e,n,s){let i="Microsoft SignalR/";const r=t.split(".");return i+=`${r[0]}.${r[1]}`,i+=` (${t}; `,i+=e&&""!==e?`${e}; `:"Unknown OS; ",i+=`${n}`,i+=s?`; ${s}`:"; Unknown Runtime Version",i+=")",i}function S(){if(!g.isNode)return"";switch(process.platform){case"win32":return"Windows NT";case"darwin":return"macOS";case"linux":return"Linux";default:return process.platform}}function k(){if(g.isNode)return process.versions.node}function P(t){return t.stack?t.stack:t.message?t.message:`${t}`}class T extends d{constructor(e){if(super(),this.u=e,"undefined"==typeof fetch){const t=require;this.p=new(t("tough-cookie").CookieJar),this.m=t("node-fetch"),this.m=t("fetch-cookie")(this.m,this.p)}else this.m=fetch.bind(function(){if("undefined"!=typeof globalThis)return globalThis;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==t.g)return t.g;throw new Error("could not find global")}());if("undefined"==typeof AbortController){const t=require;this.v=t("abort-controller")}else this.v=AbortController}async send(t){if(t.abortSignal&&t.abortSignal.aborted)throw new r;if(!t.method)throw new Error("No method defined.");if(!t.url)throw new Error("No url defined.");const n=new this.v;let o;t.abortSignal&&(t.abortSignal.onabort=()=>{n.abort(),o=new r});let h,c=null;if(t.timeout){const s=t.timeout;c=setTimeout((()=>{n.abort(),this.u.log(e.Warning,"Timeout from HTTP request."),o=new i}),s)}try{h=await this.m(t.url,{body:t.content,cache:"no-cache",credentials:!0===t.withCredentials?"include":"same-origin",headers:{"Content-Type":"text/plain;charset=UTF-8","X-Requested-With":"XMLHttpRequest",...t.headers},method:t.method,mode:"cors",redirect:"follow",signal:n.signal})}catch(t){if(o)throw o;throw this.u.log(e.Warning,`Error from HTTP request. ${t}.`),t}finally{c&&clearTimeout(c),t.abortSignal&&(t.abortSignal.onabort=null)}if(!h.ok){const t=await I(h,"text");throw new s(t||h.statusText,h.status)}const a=I(h,t.responseType),l=await a;return new u(h.status,h.statusText,l)}getCookieString(t){let e="";return g.isNode&&this.p&&this.p.getCookies(t,((t,n)=>e=n.join("; "))),e}}function I(t,e){let n;switch(e){case"arraybuffer":n=t.arrayBuffer();break;case"text":n=t.text();break;case"blob":case"document":case"json":throw new Error(`${e} is not supported.`);default:n=t.text()}return n}class _ extends d{constructor(t){super(),this.u=t}send(t){return t.abortSignal&&t.abortSignal.aborted?Promise.reject(new r):t.method?t.url?new Promise(((n,o)=>{const h=new XMLHttpRequest;h.open(t.method,t.url,!0),h.withCredentials=void 0===t.withCredentials||t.withCredentials,h.setRequestHeader("X-Requested-With","XMLHttpRequest"),h.setRequestHeader("Content-Type","text/plain;charset=UTF-8");const c=t.headers;c&&Object.keys(c).forEach((t=>{h.setRequestHeader(t,c[t])})),t.responseType&&(h.responseType=t.responseType),t.abortSignal&&(t.abortSignal.onabort=()=>{h.abort(),o(new r)}),t.timeout&&(h.timeout=t.timeout),h.onload=()=>{t.abortSignal&&(t.abortSignal.onabort=null),h.status>=200&&h.status<300?n(new u(h.status,h.statusText,h.response||h.responseText)):o(new s(h.response||h.responseText||h.statusText,h.status))},h.onerror=()=>{this.u.log(e.Warning,`Error from HTTP request. ${h.status}: ${h.statusText}.`),o(new s(h.statusText,h.status))},h.ontimeout=()=>{this.u.log(e.Warning,"Timeout from HTTP request."),o(new i)},h.send(t.content||"")})):Promise.reject(new Error("No url defined.")):Promise.reject(new Error("No method defined."))}}class H extends d{constructor(t){if(super(),"undefined"!=typeof fetch||g.isNode)this.$=new T(t);else{if("undefined"==typeof XMLHttpRequest)throw new Error("No usable HttpClient found.");this.$=new _(t)}}send(t){return t.abortSignal&&t.abortSignal.aborted?Promise.reject(new r):t.method?t.url?this.$.send(t):Promise.reject(new Error("No url defined.")):Promise.reject(new Error("No method defined."))}getCookieString(t){return this.$.getCookieString(t)}}class D{static write(t){return`${t}${D.RecordSeparator}`}static parse(t){if(t[t.length-1]!==D.RecordSeparator)throw new Error("Message is incomplete.");const e=t.split(D.RecordSeparator);return e.pop(),e}}D.RecordSeparatorCode=30,D.RecordSeparator=String.fromCharCode(D.RecordSeparatorCode);class x{writeHandshakeRequest(t){return D.write(JSON.stringify(t))}parseHandshakeResponse(t){let e,n;if(m(t)){const s=new Uint8Array(t),i=s.indexOf(D.RecordSeparatorCode);if(-1===i)throw new Error("Message is incomplete.");const r=i+1;e=String.fromCharCode.apply(null,Array.prototype.slice.call(s.slice(0,r))),n=s.byteLength>r?s.slice(r).buffer:null}else{const s=t,i=s.indexOf(D.RecordSeparator);if(-1===i)throw new Error("Message is incomplete.");const r=i+1;e=s.substring(0,r),n=s.length>r?s.substring(r):null}const s=D.parse(e),i=JSON.parse(s[0]);if(i.type)throw new Error("Expected a handshake response from the server.");return[n,i]}}var R,A;!function(t){t[t.Invocation=1]="Invocation",t[t.StreamItem=2]="StreamItem",t[t.Completion=3]="Completion",t[t.StreamInvocation=4]="StreamInvocation",t[t.CancelInvocation=5]="CancelInvocation",t[t.Ping=6]="Ping",t[t.Close=7]="Close"}(R||(R={}));class U{constructor(){this.observers=[]}next(t){for(const e of this.observers)e.next(t)}error(t){for(const e of this.observers)e.error&&e.error(t)}complete(){for(const t of this.observers)t.complete&&t.complete()}subscribe(t){return this.observers.push(t),new v(this,t)}}!function(t){t.Disconnected="Disconnected",t.Connecting="Connecting",t.Connected="Connected",t.Disconnecting="Disconnecting",t.Reconnecting="Reconnecting"}(A||(A={}));class N{constructor(t,n,s,i){this.C=0,this.S=()=>{this.u.log(e.Warning,"The page is being frozen, this will likely lead to the connection being closed and messages being lost. For more information see the docs at https://docs.microsoft.com/aspnet/core/signalr/javascript-client#bsleep")},w.isRequired(t,"connection"),w.isRequired(n,"logger"),w.isRequired(s,"protocol"),this.serverTimeoutInMilliseconds=3e4,this.keepAliveIntervalInMilliseconds=15e3,this.u=n,this.k=s,this.connection=t,this.P=i,this.T=new x,this.connection.onreceive=t=>this.I(t),this.connection.onclose=t=>this._(t),this.H={},this.D={},this.R=[],this.A=[],this.U=[],this.N=0,this.L=!1,this.M=A.Disconnected,this.j=!1,this.q=this.k.writeMessage({type:R.Ping})}static create(t,e,n,s){return new N(t,e,n,s)}get state(){return this.M}get connectionId(){return this.connection&&this.connection.connectionId||null}get baseUrl(){return this.connection.baseUrl||""}set baseUrl(t){if(this.M!==A.Disconnected&&this.M!==A.Reconnecting)throw new Error("The HubConnection must be in the Disconnected or Reconnecting state to change the url.");if(!t)throw new Error("The HubConnection url must be a valid url.");this.connection.baseUrl=t}start(){return this.W=this.O(),this.W}async O(){if(this.M!==A.Disconnected)return Promise.reject(new Error("Cannot start a HubConnection that is not in the 'Disconnected' state."));this.M=A.Connecting,this.u.log(e.Debug,"Starting HubConnection.");try{await this.F(),g.isBrowser&&window.document.addEventListener("freeze",this.S),this.M=A.Connected,this.j=!0,this.u.log(e.Debug,"HubConnection connected successfully.")}catch(t){return this.M=A.Disconnected,this.u.log(e.Debug,`HubConnection failed to start successfully because of error '${t}'.`),Promise.reject(t)}}async F(){this.B=void 0,this.L=!1;const t=new Promise(((t,e)=>{this.X=t,this.J=e}));await this.connection.start(this.k.transferFormat);try{const n={protocol:this.k.name,version:this.k.version};if(this.u.log(e.Debug,"Sending handshake request."),await this.V(this.T.writeHandshakeRequest(n)),this.u.log(e.Information,`Using HubProtocol '${this.k.name}'.`),this.G(),this.K(),this.Y(),await t,this.B)throw this.B}catch(t){throw this.u.log(e.Debug,`Hub handshake failed with error '${t}' during start(). Stopping HubConnection.`),this.G(),this.Z(),await this.connection.stop(t),t}}async stop(){const t=this.W;this.tt=this.et(),await this.tt;try{await t}catch(t){}}et(t){return this.M===A.Disconnected?(this.u.log(e.Debug,`Call to HubConnection.stop(${t}) ignored because it is already in the disconnected state.`),Promise.resolve()):this.M===A.Disconnecting?(this.u.log(e.Debug,`Call to HttpConnection.stop(${t}) ignored because the connection is already in the disconnecting state.`),this.tt):(this.M=A.Disconnecting,this.u.log(e.Debug,"Stopping HubConnection."),this.nt?(this.u.log(e.Debug,"Connection stopped during reconnect delay. Done reconnecting."),clearTimeout(this.nt),this.nt=void 0,this.st(),Promise.resolve()):(this.G(),this.Z(),this.B=t||new r("The connection was stopped before the hub handshake could complete."),this.connection.stop(t)))}stream(t,...e){const[n,s]=this.it(e),i=this.rt(t,e,s);let r;const o=new U;return o.cancelCallback=()=>{const t=this.ot(i.invocationId);return delete this.H[i.invocationId],r.then((()=>this.ht(t)))},this.H[i.invocationId]=(t,e)=>{e?o.error(e):t&&(t.type===R.Completion?t.error?o.error(new Error(t.error)):o.complete():o.next(t.item))},r=this.ht(i).catch((t=>{o.error(t),delete this.H[i.invocationId]})),this.ct(n,r),o}V(t){return this.Y(),this.connection.send(t)}ht(t){return this.V(this.k.writeMessage(t))}send(t,...e){const[n,s]=this.it(e),i=this.ht(this.lt(t,e,!0,s));return this.ct(n,i),i}invoke(t,...e){const[n,s]=this.it(e),i=this.lt(t,e,!1,s);return new Promise(((t,e)=>{this.H[i.invocationId]=(n,s)=>{s?e(s):n&&(n.type===R.Completion?n.error?e(new Error(n.error)):t(n.result):e(new Error(`Unexpected message type: ${n.type}`)))};const s=this.ht(i).catch((t=>{e(t),delete this.H[i.invocationId]}));this.ct(n,s)}))}on(t,e){t&&e&&(t=t.toLowerCase(),this.D[t]||(this.D[t]=[]),-1===this.D[t].indexOf(e)&&this.D[t].push(e))}off(t,e){if(!t)return;t=t.toLowerCase();const n=this.D[t];if(n)if(e){const s=n.indexOf(e);-1!==s&&(n.splice(s,1),0===n.length&&delete this.D[t])}else delete this.D[t]}onclose(t){t&&this.R.push(t)}onreconnecting(t){t&&this.A.push(t)}onreconnected(t){t&&this.U.push(t)}I(t){if(this.G(),this.L||(t=this.ut(t),this.L=!0),t){const n=this.k.parseMessages(t,this.u);for(const t of n)switch(t.type){case R.Invocation:this.dt(t);break;case R.StreamItem:case R.Completion:{const n=this.H[t.invocationId];if(n){t.type===R.Completion&&delete this.H[t.invocationId];try{n(t)}catch(t){this.u.log(e.Error,`Stream callback threw error: ${P(t)}`)}}break}case R.Ping:break;case R.Close:{this.u.log(e.Information,"Close message received from server.");const n=t.error?new Error("Server returned an error on close: "+t.error):void 0;!0===t.allowReconnect?this.connection.stop(n):this.tt=this.et(n);break}default:this.u.log(e.Warning,`Invalid message type: ${t.type}.`)}}this.K()}ut(t){let n,s;try{[s,n]=this.T.parseHandshakeResponse(t)}catch(t){const n="Error parsing handshake response: "+t;this.u.log(e.Error,n);const s=new Error(n);throw this.J(s),s}if(n.error){const t="Server returned handshake error: "+n.error;this.u.log(e.Error,t);const s=new Error(t);throw this.J(s),s}return this.u.log(e.Debug,"Server handshake complete."),this.X(),s}Y(){this.connection.features.inherentKeepAlive||(this.C=(new Date).getTime()+this.keepAliveIntervalInMilliseconds,this.Z())}K(){if(!(this.connection.features&&this.connection.features.inherentKeepAlive||(this.ft=setTimeout((()=>this.serverTimeout()),this.serverTimeoutInMilliseconds),void 0!==this.wt))){let t=this.C-(new Date).getTime();t<0&&(t=0),this.wt=setTimeout((async()=>{if(this.M===A.Connected)try{await this.V(this.q)}catch{this.Z()}}),t)}}serverTimeout(){this.connection.stop(new Error("Server timeout elapsed without receiving a message from the server."))}async dt(t){const n=t.target.toLowerCase(),s=this.D[n];if(!s)return this.u.log(e.Warning,`No client method with the name '${n}' found.`),void(t.invocationId&&(this.u.log(e.Warning,`No result given for '${n}' method and invocation ID '${t.invocationId}'.`),await this.ht(this.gt(t.invocationId,"Client didn't provide a result.",null))));const i=s.slice(),r=!!t.invocationId;let o,h,c;for(const s of i)try{const i=o;o=await s.apply(this,t.arguments),r&&o&&i&&(this.u.log(e.Error,`Multiple results provided for '${n}'. Sending error to server.`),c=this.gt(t.invocationId,"Client provided multiple results.",null)),h=void 0}catch(t){h=t,this.u.log(e.Error,`A callback for the method '${n}' threw error '${t}'.`)}c?await this.ht(c):r?(h?c=this.gt(t.invocationId,`${h}`,null):void 0!==o?c=this.gt(t.invocationId,null,o):(this.u.log(e.Warning,`No result given for '${n}' method and invocation ID '${t.invocationId}'.`),c=this.gt(t.invocationId,"Client didn't provide a result.",null)),await this.ht(c)):o&&this.u.log(e.Error,`Result given for '${n}' method but server is not expecting a result.`)}_(t){this.u.log(e.Debug,`HubConnection.connectionClosed(${t}) called while in state ${this.M}.`),this.B=this.B||t||new r("The underlying connection was closed before the hub handshake could complete."),this.X&&this.X(),this.yt(t||new Error("Invocation canceled due to the underlying connection being closed.")),this.G(),this.Z(),this.M===A.Disconnecting?this.st(t):this.M===A.Connected&&this.P?this.bt(t):this.M===A.Connected&&this.st(t)}st(t){if(this.j){this.M=A.Disconnected,this.j=!1,g.isBrowser&&window.document.removeEventListener("freeze",this.S);try{this.R.forEach((e=>e.apply(this,[t])))}catch(n){this.u.log(e.Error,`An onclose callback called with error '${t}' threw error '${n}'.`)}}}async bt(t){const n=Date.now();let s=0,i=void 0!==t?t:new Error("Attempting to reconnect due to a unknown error."),r=this.vt(s++,0,i);if(null===r)return this.u.log(e.Debug,"Connection not reconnecting because the IRetryPolicy returned null on the first reconnect attempt."),void this.st(t);if(this.M=A.Reconnecting,t?this.u.log(e.Information,`Connection reconnecting because of error '${t}'.`):this.u.log(e.Information,"Connection reconnecting."),0!==this.A.length){try{this.A.forEach((e=>e.apply(this,[t])))}catch(n){this.u.log(e.Error,`An onreconnecting callback called with error '${t}' threw error '${n}'.`)}if(this.M!==A.Reconnecting)return void this.u.log(e.Debug,"Connection left the reconnecting state in onreconnecting callback. Done reconnecting.")}for(;null!==r;){if(this.u.log(e.Information,`Reconnect attempt number ${s} will start in ${r} ms.`),await new Promise((t=>{this.nt=setTimeout(t,r)})),this.nt=void 0,this.M!==A.Reconnecting)return void this.u.log(e.Debug,"Connection left the reconnecting state during reconnect delay. Done reconnecting.");try{if(await this.F(),this.M=A.Connected,this.u.log(e.Information,"HubConnection reconnected successfully."),0!==this.U.length)try{this.U.forEach((t=>t.apply(this,[this.connection.connectionId])))}catch(t){this.u.log(e.Error,`An onreconnected callback called with connectionId '${this.connection.connectionId}; threw error '${t}'.`)}return}catch(t){if(this.u.log(e.Information,`Reconnect attempt failed because of error '${t}'.`),this.M!==A.Reconnecting)return this.u.log(e.Debug,`Connection moved to the '${this.M}' from the reconnecting state during reconnect attempt. Done reconnecting.`),void(this.M===A.Disconnecting&&this.st());i=t instanceof Error?t:new Error(t.toString()),r=this.vt(s++,Date.now()-n,i)}}this.u.log(e.Information,`Reconnect retries have been exhausted after ${Date.now()-n} ms and ${s} failed attempts. Connection disconnecting.`),this.st()}vt(t,n,s){try{return this.P.nextRetryDelayInMilliseconds({elapsedMilliseconds:n,previousRetryCount:t,retryReason:s})}catch(s){return this.u.log(e.Error,`IRetryPolicy.nextRetryDelayInMilliseconds(${t}, ${n}) threw error '${s}'.`),null}}yt(t){const n=this.H;this.H={},Object.keys(n).forEach((s=>{const i=n[s];try{i(null,t)}catch(n){this.u.log(e.Error,`Stream 'error' callback called with '${t}' threw error: ${P(n)}`)}}))}Z(){this.wt&&(clearTimeout(this.wt),this.wt=void 0)}G(){this.ft&&clearTimeout(this.ft)}lt(t,e,n,s){if(n)return 0!==s.length?{arguments:e,streamIds:s,target:t,type:R.Invocation}:{arguments:e,target:t,type:R.Invocation};{const n=this.N;return this.N++,0!==s.length?{arguments:e,invocationId:n.toString(),streamIds:s,target:t,type:R.Invocation}:{arguments:e,invocationId:n.toString(),target:t,type:R.Invocation}}}ct(t,e){if(0!==t.length){e||(e=Promise.resolve());for(const n in t)t[n].subscribe({complete:()=>{e=e.then((()=>this.ht(this.gt(n))))},error:t=>{let s;s=t instanceof Error?t.message:t&&t.toString?t.toString():"Unknown error",e=e.then((()=>this.ht(this.gt(n,s))))},next:t=>{e=e.then((()=>this.ht(this.$t(n,t))))}})}}it(t){const e=[],n=[];for(let s=0;s<t.length;s++){const i=t[s];if(this.Et(i)){const r=this.N;this.N++,e[r]=i,n.push(r.toString()),t.splice(s,1)}}return[e,n]}Et(t){return t&&t.subscribe&&"function"==typeof t.subscribe}rt(t,e,n){const s=this.N;return this.N++,0!==n.length?{arguments:e,invocationId:s.toString(),streamIds:n,target:t,type:R.StreamInvocation}:{arguments:e,invocationId:s.toString(),target:t,type:R.StreamInvocation}}ot(t){return{invocationId:t,type:R.CancelInvocation}}$t(t,e){return{invocationId:t,item:e,type:R.StreamItem}}gt(t,e,n){return e?{error:e,invocationId:t,type:R.Completion}:{invocationId:t,result:n,type:R.Completion}}}const L=[0,2e3,1e4,3e4,null];class M{constructor(t){this.Ct=void 0!==t?[...t,null]:L}nextRetryDelayInMilliseconds(t){return this.Ct[t.previousRetryCount]}}class j{}var q,W;j.Authorization="Authorization",j.Cookie="Cookie",function(t){t[t.None=0]="None",t[t.WebSockets=1]="WebSockets",t[t.ServerSentEvents=2]="ServerSentEvents",t[t.LongPolling=4]="LongPolling"}(q||(q={})),function(t){t[t.Text=1]="Text",t[t.Binary=2]="Binary"}(W||(W={}));class O{constructor(){this.St=!1,this.onabort=null}abort(){this.St||(this.St=!0,this.onabort&&this.onabort())}get signal(){return this}get aborted(){return this.St}}class F{constructor(t,e,n,s){this.$=t,this.kt=e,this.u=n,this.Pt=new O,this.Tt=s,this.It=!1,this.onreceive=null,this.onclose=null}get pollAborted(){return this.Pt.aborted}async connect(t,n){if(w.isRequired(t,"url"),w.isRequired(n,"transferFormat"),w.isIn(n,W,"transferFormat"),this._t=t,this.u.log(e.Trace,"(LongPolling transport) Connecting."),n===W.Binary&&"undefined"!=typeof XMLHttpRequest&&"string"!=typeof(new XMLHttpRequest).responseType)throw new Error("Binary protocols over XmlHttpRequest not implementing advanced features are not supported.");const[i,r]=E(),o={[i]:r,...this.Tt.headers},h={abortSignal:this.Pt.signal,headers:o,timeout:1e5,withCredentials:this.Tt.withCredentials};n===W.Binary&&(h.responseType="arraybuffer"),await this.Ht(h);const c=`${t}&_=${Date.now()}`;this.u.log(e.Trace,`(LongPolling transport) polling: ${c}.`);const a=await this.$.get(c,h);200!==a.statusCode?(this.u.log(e.Error,`(LongPolling transport) Unexpected response code: ${a.statusCode}.`),this.Dt=new s(a.statusText||"",a.statusCode),this.It=!1):this.It=!0,this.xt=this.Rt(this._t,h)}async Ht(t){if(t.headers||(t.headers={}),this.kt){const e=await this.kt();e?t.headers[j.Authorization]=`Bearer ${e}`:t.headers[j.Authorization]&&delete t.headers[j.Authorization]}}async Rt(t,n){try{for(;this.It;){await this.Ht(n);try{const i=`${t}&_=${Date.now()}`;this.u.log(e.Trace,`(LongPolling transport) polling: ${i}.`);const r=await this.$.get(i,n);204===r.statusCode?(this.u.log(e.Information,"(LongPolling transport) Poll terminated by server."),this.It=!1):200!==r.statusCode?(this.u.log(e.Error,`(LongPolling transport) Unexpected response code: ${r.statusCode}.`),this.Dt=new s(r.statusText||"",r.statusCode),this.It=!1):r.content?(this.u.log(e.Trace,`(LongPolling transport) data received. ${y(r.content,this.Tt.logMessageContent)}.`),this.onreceive&&this.onreceive(r.content)):this.u.log(e.Trace,"(LongPolling transport) Poll timed out, reissuing.")}catch(t){this.It?t instanceof i?this.u.log(e.Trace,"(LongPolling transport) Poll timed out, reissuing."):(this.Dt=t,this.It=!1):this.u.log(e.Trace,`(LongPolling transport) Poll errored after shutdown: ${t.message}`)}}}finally{this.u.log(e.Trace,"(LongPolling transport) Polling complete."),this.pollAborted||this.At()}}async send(t){return this.It?b(this.u,"LongPolling",this.$,this._t,this.kt,t,this.Tt):Promise.reject(new Error("Cannot send until the transport is connected"))}async stop(){this.u.log(e.Trace,"(LongPolling transport) Stopping polling."),this.It=!1,this.Pt.abort();try{await this.xt,this.u.log(e.Trace,`(LongPolling transport) sending DELETE request to ${this._t}.`);const t={},[n,s]=E();t[n]=s;const i={headers:{...t,...this.Tt.headers},timeout:this.Tt.timeout,withCredentials:this.Tt.withCredentials};await this.Ht(i),await this.$.delete(this._t,i),this.u.log(e.Trace,"(LongPolling transport) DELETE request sent.")}finally{this.u.log(e.Trace,"(LongPolling transport) Stop finished."),this.At()}}At(){if(this.onclose){let t="(LongPolling transport) Firing onclose event.";this.Dt&&(t+=" Error: "+this.Dt),this.u.log(e.Trace,t),this.onclose(this.Dt)}}}class B{constructor(t,e,n,s){this.$=t,this.kt=e,this.u=n,this.Tt=s,this.onreceive=null,this.onclose=null}async connect(t,n){if(w.isRequired(t,"url"),w.isRequired(n,"transferFormat"),w.isIn(n,W,"transferFormat"),this.u.log(e.Trace,"(SSE transport) Connecting."),this._t=t,this.kt){const e=await this.kt();e&&(t+=(t.indexOf("?")<0?"?":"&")+`access_token=${encodeURIComponent(e)}`)}return new Promise(((s,i)=>{let r,o=!1;if(n===W.Text){if(g.isBrowser||g.isWebWorker)r=new this.Tt.EventSource(t,{withCredentials:this.Tt.withCredentials});else{const e=this.$.getCookieString(t),n={};n.Cookie=e;const[s,i]=E();n[s]=i,r=new this.Tt.EventSource(t,{withCredentials:this.Tt.withCredentials,headers:{...n,...this.Tt.headers}})}try{r.onmessage=t=>{if(this.onreceive)try{this.u.log(e.Trace,`(SSE transport) data received. ${y(t.data,this.Tt.logMessageContent)}.`),this.onreceive(t.data)}catch(t){return void this.Ut(t)}},r.onerror=t=>{o?this.Ut():i(new Error("EventSource failed to connect. The connection could not be found on the server, either the connection ID is not present on the server, or a proxy is refusing/buffering the connection. If you have multiple servers check that sticky sessions are enabled."))},r.onopen=()=>{this.u.log(e.Information,`SSE connected to ${this._t}`),this.Nt=r,o=!0,s()}}catch(t){return void i(t)}}else i(new Error("The Server-Sent Events transport only supports the 'Text' transfer format"))}))}async send(t){return this.Nt?b(this.u,"SSE",this.$,this._t,this.kt,t,this.Tt):Promise.reject(new Error("Cannot send until the transport is connected"))}stop(){return this.Ut(),Promise.resolve()}Ut(t){this.Nt&&(this.Nt.close(),this.Nt=void 0,this.onclose&&this.onclose(t))}}class X{constructor(t,e,n,s,i,r){this.u=n,this.kt=e,this.Lt=s,this.Mt=i,this.$=t,this.onreceive=null,this.onclose=null,this.jt=r}async connect(t,n){let s;return w.isRequired(t,"url"),w.isRequired(n,"transferFormat"),w.isIn(n,W,"transferFormat"),this.u.log(e.Trace,"(WebSockets transport) Connecting."),this.kt&&(s=await this.kt()),new Promise(((i,r)=>{let o;t=t.replace(/^http/,"ws");const h=this.$.getCookieString(t);let c=!1;if(g.isNode||g.isReactNative){const e={},[n,i]=E();e[n]=i,s&&(e[j.Authorization]=`Bearer ${s}`),h&&(e[j.Cookie]=h),o=new this.Mt(t,void 0,{headers:{...e,...this.jt}})}else s&&(t+=(t.indexOf("?")<0?"?":"&")+`access_token=${encodeURIComponent(s)}`);o||(o=new this.Mt(t)),n===W.Binary&&(o.binaryType="arraybuffer"),o.onopen=n=>{this.u.log(e.Information,`WebSocket connected to ${t}.`),this.qt=o,c=!0,i()},o.onerror=t=>{let n=null;n="undefined"!=typeof ErrorEvent&&t instanceof ErrorEvent?t.error:"There was an error with the transport",this.u.log(e.Information,`(WebSockets transport) ${n}.`)},o.onmessage=t=>{if(this.u.log(e.Trace,`(WebSockets transport) data received. ${y(t.data,this.Lt)}.`),this.onreceive)try{this.onreceive(t.data)}catch(t){return void this.Ut(t)}},o.onclose=t=>{if(c)this.Ut(t);else{let e=null;e="undefined"!=typeof ErrorEvent&&t instanceof ErrorEvent?t.error:"WebSocket failed to connect. The connection could not be found on the server, either the endpoint may not be a SignalR endpoint, the connection ID is not present on the server, or there is a proxy blocking WebSockets. If you have multiple servers check that sticky sessions are enabled.",r(new Error(e))}}}))}send(t){return this.qt&&this.qt.readyState===this.Mt.OPEN?(this.u.log(e.Trace,`(WebSockets transport) sending data. ${y(t,this.Lt)}.`),this.qt.send(t),Promise.resolve()):Promise.reject("WebSocket is not in the OPEN state")}stop(){return this.qt&&this.Ut(void 0),Promise.resolve()}Ut(t){this.qt&&(this.qt.onclose=()=>{},this.qt.onmessage=()=>{},this.qt.onerror=()=>{},this.qt.close(),this.qt=void 0),this.u.log(e.Trace,"(WebSockets transport) socket closed."),this.onclose&&(!this.Wt(t)||!1!==t.wasClean&&1e3===t.code?t instanceof Error?this.onclose(t):this.onclose():this.onclose(new Error(`WebSocket closed with status code: ${t.code} (${t.reason||"no reason given"}).`)))}Wt(t){return t&&"boolean"==typeof t.wasClean&&"number"==typeof t.code}}class J{constructor(t,n={}){var s;if(this.Ot=()=>{},this.features={},this.Ft=1,w.isRequired(t,"url"),this.u=void 0===(s=n.logger)?new $(e.Information):null===s?f.instance:void 0!==s.log?s:new $(s),this.baseUrl=this.Bt(t),(n=n||{}).logMessageContent=void 0!==n.logMessageContent&&n.logMessageContent,"boolean"!=typeof n.withCredentials&&void 0!==n.withCredentials)throw new Error("withCredentials option was not a 'boolean' or 'undefined' value");n.withCredentials=void 0===n.withCredentials||n.withCredentials,n.timeout=void 0===n.timeout?1e5:n.timeout;let i=null,r=null;if(g.isNode){const t=require;i=t("ws"),r=t("eventsource")}g.isNode||"undefined"==typeof WebSocket||n.WebSocket?g.isNode&&!n.WebSocket&&i&&(n.WebSocket=i):n.WebSocket=WebSocket,g.isNode||"undefined"==typeof EventSource||n.EventSource?g.isNode&&!n.EventSource&&void 0!==r&&(n.EventSource=r):n.EventSource=EventSource,this.$=n.httpClient||new H(this.u),this.M="Disconnected",this.j=!1,this.Tt=n,this.onreceive=null,this.onclose=null}async start(t){if(t=t||W.Binary,w.isIn(t,W,"transferFormat"),this.u.log(e.Debug,`Starting connection with transfer format '${W[t]}'.`),"Disconnected"!==this.M)return Promise.reject(new Error("Cannot start an HttpConnection that is not in the 'Disconnected' state."));if(this.M="Connecting",this.Xt=this.F(t),await this.Xt,"Disconnecting"===this.M){const t="Failed to start the HttpConnection before stop() was called.";return this.u.log(e.Error,t),await this.tt,Promise.reject(new r(t))}if("Connected"!==this.M){const t="HttpConnection.startInternal completed gracefully but didn't enter the connection into the connected state!";return this.u.log(e.Error,t),Promise.reject(new r(t))}this.j=!0}send(t){return"Connected"!==this.M?Promise.reject(new Error("Cannot send data if the connection is not in the 'Connected' State.")):(this.Jt||(this.Jt=new z(this.transport)),this.Jt.send(t))}async stop(t){return"Disconnected"===this.M?(this.u.log(e.Debug,`Call to HttpConnection.stop(${t}) ignored because the connection is already in the disconnected state.`),Promise.resolve()):"Disconnecting"===this.M?(this.u.log(e.Debug,`Call to HttpConnection.stop(${t}) ignored because the connection is already in the disconnecting state.`),this.tt):(this.M="Disconnecting",this.tt=new Promise((t=>{this.Ot=t})),await this.et(t),void await this.tt)}async et(t){this.zt=t;try{await this.Xt}catch(t){}if(this.transport){try{await this.transport.stop()}catch(t){this.u.log(e.Error,`HttpConnection.transport.stop() threw error '${t}'.`),this.Vt()}this.transport=void 0}else this.u.log(e.Debug,"HttpConnection.transport is undefined in HttpConnection.stop() because start() failed.")}async F(t){let n=this.baseUrl;this.kt=this.Tt.accessTokenFactory;try{if(this.Tt.skipNegotiation){if(this.Tt.transport!==q.WebSockets)throw new Error("Negotiation can only be skipped when using the WebSocket transport directly.");this.transport=this.Gt(q.WebSockets),await this.Kt(n,t)}else{let e=null,s=0;do{if(e=await this.Qt(n),"Disconnecting"===this.M||"Disconnected"===this.M)throw new r("The connection was stopped during negotiation.");if(e.error)throw new Error(e.error);if(e.ProtocolVersion)throw new Error("Detected a connection attempt to an ASP.NET SignalR Server. This client only supports connecting to an ASP.NET Core SignalR Server. See https://aka.ms/signalr-core-differences for details.");if(e.url&&(n=e.url),e.accessToken){const t=e.accessToken;this.kt=()=>t}s++}while(e.url&&s<100);if(100===s&&e.url)throw new Error("Negotiate redirection limit exceeded.");await this.Yt(n,this.Tt.transport,e,t)}this.transport instanceof F&&(this.features.inherentKeepAlive=!0),"Connecting"===this.M&&(this.u.log(e.Debug,"The HttpConnection connected successfully."),this.M="Connected")}catch(t){return this.u.log(e.Error,"Failed to start the connection: "+t),this.M="Disconnected",this.transport=void 0,this.Ot(),Promise.reject(t)}}async Qt(t){const n={};if(this.kt){const t=await this.kt();t&&(n[j.Authorization]=`Bearer ${t}`)}const[i,r]=E();n[i]=r;const o=this.Zt(t);this.u.log(e.Debug,`Sending negotiation request: ${o}.`);try{const t=await this.$.post(o,{content:"",headers:{...n,...this.Tt.headers},timeout:this.Tt.timeout,withCredentials:this.Tt.withCredentials});if(200!==t.statusCode)return Promise.reject(new Error(`Unexpected status code returned from negotiate '${t.statusCode}'`));const e=JSON.parse(t.content);return(!e.negotiateVersion||e.negotiateVersion<1)&&(e.connectionToken=e.connectionId),e}catch(t){let n="Failed to complete negotiation with the server: "+t;return t instanceof s&&404===t.statusCode&&(n+=" Either this is not a SignalR endpoint or there is a proxy blocking the connection."),this.u.log(e.Error,n),Promise.reject(new a(n))}}te(t,e){return e?t+(-1===t.indexOf("?")?"?":"&")+`id=${e}`:t}async Yt(t,n,s,i){let o=this.te(t,s.connectionToken);if(this.ee(n))return this.u.log(e.Debug,"Connection was provided an instance of ITransport, using that directly."),this.transport=n,await this.Kt(o,i),void(this.connectionId=s.connectionId);const h=[],a=s.availableTransports||[];let u=s;for(const s of a){const a=this.ne(s,n,i);if(a instanceof Error)h.push(`${s.transport} failed:`),h.push(a);else if(this.ee(a)){if(this.transport=a,!u){try{u=await this.Qt(t)}catch(t){return Promise.reject(t)}o=this.te(t,u.connectionToken)}try{return await this.Kt(o,i),void(this.connectionId=u.connectionId)}catch(t){if(this.u.log(e.Error,`Failed to start the transport '${s.transport}': ${t}`),u=void 0,h.push(new c(`${s.transport} failed: ${t}`,q[s.transport])),"Connecting"!==this.M){const t="Failed to select transport before stop() was called.";return this.u.log(e.Debug,t),Promise.reject(new r(t))}}}}return h.length>0?Promise.reject(new l(`Unable to connect to the server with any of the available transports. ${h.join(" ")}`,h)):Promise.reject(new Error("None of the transports supported by the client are supported by the server."))}Gt(t){switch(t){case q.WebSockets:if(!this.Tt.WebSocket)throw new Error("'WebSocket' is not supported in your environment.");return new X(this.$,this.kt,this.u,this.Tt.logMessageContent,this.Tt.WebSocket,this.Tt.headers||{});case q.ServerSentEvents:if(!this.Tt.EventSource)throw new Error("'EventSource' is not supported in your environment.");return new B(this.$,this.kt,this.u,this.Tt);case q.LongPolling:return new F(this.$,this.kt,this.u,this.Tt);default:throw new Error(`Unknown transport: ${t}.`)}}Kt(t,e){return this.transport.onreceive=this.onreceive,this.transport.onclose=t=>this.Vt(t),this.transport.connect(t,e)}ne(t,n,s){const i=q[t.transport];if(null==i)return this.u.log(e.Debug,`Skipping transport '${t.transport}' because it is not supported by this client.`),new Error(`Skipping transport '${t.transport}' because it is not supported by this client.`);if(!function(t,e){return!t||0!=(e&t)}(n,i))return this.u.log(e.Debug,`Skipping transport '${q[i]}' because it was disabled by the client.`),new h(`'${q[i]}' is disabled by the client.`,i);if(!(t.transferFormats.map((t=>W[t])).indexOf(s)>=0))return this.u.log(e.Debug,`Skipping transport '${q[i]}' because it does not support the requested transfer format '${W[s]}'.`),new Error(`'${q[i]}' does not support ${W[s]}.`);if(i===q.WebSockets&&!this.Tt.WebSocket||i===q.ServerSentEvents&&!this.Tt.EventSource)return this.u.log(e.Debug,`Skipping transport '${q[i]}' because it is not supported in your environment.'`),new o(`'${q[i]}' is not supported in your environment.`,i);this.u.log(e.Debug,`Selecting transport '${q[i]}'.`);try{return this.Gt(i)}catch(t){return t}}ee(t){return t&&"object"==typeof t&&"connect"in t}Vt(t){if(this.u.log(e.Debug,`HttpConnection.stopConnection(${t}) called while in state ${this.M}.`),this.transport=void 0,t=this.zt||t,this.zt=void 0,"Disconnected"!==this.M){if("Connecting"===this.M)throw this.u.log(e.Warning,`Call to HttpConnection.stopConnection(${t}) was ignored because the connection is still in the connecting state.`),new Error(`HttpConnection.stopConnection(${t}) was called while the connection is still in the connecting state.`);if("Disconnecting"===this.M&&this.Ot(),t?this.u.log(e.Error,`Connection disconnected with error '${t}'.`):this.u.log(e.Information,"Connection disconnected."),this.Jt&&(this.Jt.stop().catch((t=>{this.u.log(e.Error,`TransportSendQueue.stop() threw error '${t}'.`)})),this.Jt=void 0),this.connectionId=void 0,this.M="Disconnected",this.j){this.j=!1;try{this.onclose&&this.onclose(t)}catch(n){this.u.log(e.Error,`HttpConnection.onclose(${t}) threw error '${n}'.`)}}}else this.u.log(e.Debug,`Call to HttpConnection.stopConnection(${t}) was ignored because the connection is already in the disconnected state.`)}Bt(t){if(0===t.lastIndexOf("https://",0)||0===t.lastIndexOf("http://",0))return t;if(!g.isBrowser)throw new Error(`Cannot resolve '${t}'.`);const n=window.document.createElement("a");return n.href=t,this.u.log(e.Information,`Normalizing '${t}' to '${n.href}'.`),n.href}Zt(t){const e=t.indexOf("?");let n=t.substring(0,-1===e?t.length:e);return"/"!==n[n.length-1]&&(n+="/"),n+="negotiate",n+=-1===e?"":t.substring(e),-1===n.indexOf("negotiateVersion")&&(n+=-1===e?"?":"&",n+="negotiateVersion="+this.Ft),n}}class z{constructor(t){this.se=t,this.ie=[],this.re=!0,this.oe=new V,this.he=new V,this.ce=this.ae()}send(t){return this.le(t),this.he||(this.he=new V),this.he.promise}stop(){return this.re=!1,this.oe.resolve(),this.ce}le(t){if(this.ie.length&&typeof this.ie[0]!=typeof t)throw new Error(`Expected data to be of type ${typeof this.ie} but was of type ${typeof t}`);this.ie.push(t),this.oe.resolve()}async ae(){for(;;){if(await this.oe.promise,!this.re){this.he&&this.he.reject("Connection stopped.");break}this.oe=new V;const t=this.he;this.he=void 0;const e="string"==typeof this.ie[0]?this.ie.join(""):z.ue(this.ie);this.ie.length=0;try{await this.se.send(e),t.resolve()}catch(e){t.reject(e)}}}static ue(t){const e=t.map((t=>t.byteLength)).reduce(((t,e)=>t+e)),n=new Uint8Array(e);let s=0;for(const e of t)n.set(new Uint8Array(e),s),s+=e.byteLength;return n.buffer}}class V{constructor(){this.promise=new Promise(((t,e)=>[this.de,this.fe]=[t,e]))}resolve(){this.de()}reject(t){this.fe(t)}}class G{constructor(){this.name="json",this.version=1,this.transferFormat=W.Text}parseMessages(t,n){if("string"!=typeof t)throw new Error("Invalid input for JSON hub protocol. Expected a string.");if(!t)return[];null===n&&(n=f.instance);const s=D.parse(t),i=[];for(const t of s){const s=JSON.parse(t);if("number"!=typeof s.type)throw new Error("Invalid payload.");switch(s.type){case R.Invocation:this.pe(s);break;case R.StreamItem:this.we(s);break;case R.Completion:this.ge(s);break;case R.Ping:case R.Close:break;default:n.log(e.Information,"Unknown message type '"+s.type+"' ignored.");continue}i.push(s)}return i}writeMessage(t){return D.write(JSON.stringify(t))}pe(t){this.ye(t.target,"Invalid payload for Invocation message."),void 0!==t.invocationId&&this.ye(t.invocationId,"Invalid payload for Invocation message.")}we(t){if(this.ye(t.invocationId,"Invalid payload for StreamItem message."),void 0===t.item)throw new Error("Invalid payload for StreamItem message.")}ge(t){if(t.result&&t.error)throw new Error("Invalid payload for Completion message.");!t.result&&t.error&&this.ye(t.error,"Invalid payload for Completion message."),this.ye(t.invocationId,"Invalid payload for Completion message.")}ye(t,e){if("string"!=typeof t||""===t)throw new Error(e)}}const K={trace:e.Trace,debug:e.Debug,info:e.Information,information:e.Information,warn:e.Warning,warning:e.Warning,error:e.Error,critical:e.Critical,none:e.None};class Q{configureLogging(t){if(w.isRequired(t,"logging"),void 0!==t.log)this.logger=t;else if("string"==typeof t){const e=function(t){const e=K[t.toLowerCase()];if(void 0!==e)return e;throw new Error(`Unknown log level: ${t}`)}(t);this.logger=new $(e)}else this.logger=new $(t);return this}withUrl(t,e){return w.isRequired(t,"url"),w.isNotEmpty(t,"url"),this.url=t,this.httpConnectionOptions="object"==typeof e?{...this.httpConnectionOptions,...e}:{...this.httpConnectionOptions,transport:e},this}withHubProtocol(t){return w.isRequired(t,"protocol"),this.protocol=t,this}withAutomaticReconnect(t){if(this.reconnectPolicy)throw new Error("A reconnectPolicy has already been set.");return t?Array.isArray(t)?this.reconnectPolicy=new M(t):this.reconnectPolicy=t:this.reconnectPolicy=new M,this}build(){const t=this.httpConnectionOptions||{};if(void 0===t.logger&&(t.logger=this.logger),!this.url)throw new Error("The 'HubConnectionBuilder.withUrl' method must be called before building the connection.");const e=new J(this.url,t);return N.create(e,this.logger||f.instance,this.protocol||new G,this.reconnectPolicy)}}return Uint8Array.prototype.indexOf||Object.defineProperty(Uint8Array.prototype,"indexOf",{value:Array.prototype.indexOf,writable:!0}),Uint8Array.prototype.slice||Object.defineProperty(Uint8Array.prototype,"slice",{value:function(t,e){return new Uint8Array(Array.prototype.slice.call(this,t,e))},writable:!0}),Uint8Array.prototype.forEach||Object.defineProperty(Uint8Array.prototype,"forEach",{value:Array.prototype.forEach,writable:!0}),n})()},"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.signalR=e():t.signalR=e();
//# sourceMappingURL=signalr.min.js.map

@@ -10,3 +10,3 @@ "use strict";

/** The version of the SignalR client. */
exports.VERSION = "7.0.0-preview.4.22251.1";
exports.VERSION = "7.0.0-preview.5.22303.8";
/** @private */

@@ -13,0 +13,0 @@ class Arg {

@@ -7,3 +7,3 @@ // Licensed to the .NET Foundation under one or more agreements.

/** The version of the SignalR client. */
export const VERSION = "7.0.0-preview.4.22251.1";
export const VERSION = "7.0.0-preview.5.22303.8";
/** @private */

@@ -10,0 +10,0 @@ export class Arg {

@@ -1,2 +0,2 @@

var t,e;t=self,e=function(){return(()=>{var t={d:(e,n)=>{for(var s in n)t.o(n,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:n[s]})}};t.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),t.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),t.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"t",{value:!0})};var e,n={};t.r(n),t.d(n,{AbortError:()=>r,DefaultHttpClient:()=>H,HttpClient:()=>d,HttpError:()=>s,HttpResponse:()=>u,HttpTransportType:()=>q,HubConnection:()=>N,HubConnectionBuilder:()=>Q,HubConnectionState:()=>A,JsonHubProtocol:()=>G,LogLevel:()=>e,MessageType:()=>R,NullLogger:()=>f,Subject:()=>U,TimeoutError:()=>i,TransferFormat:()=>W,VERSION:()=>p});class s extends Error{constructor(t,e){const n=new.target.prototype;super(`${t}: Status code '${e}'`),this.statusCode=e,this.__proto__=n}}class i extends Error{constructor(t="A timeout occurred."){const e=new.target.prototype;super(t),this.__proto__=e}}class r extends Error{constructor(t="An abort occurred."){const e=new.target.prototype;super(t),this.__proto__=e}}class o extends Error{constructor(t,e){const n=new.target.prototype;super(t),this.transport=e,this.errorType="UnsupportedTransportError",this.__proto__=n}}class h extends Error{constructor(t,e){const n=new.target.prototype;super(t),this.transport=e,this.errorType="DisabledTransportError",this.__proto__=n}}class c extends Error{constructor(t,e){const n=new.target.prototype;super(t),this.transport=e,this.errorType="FailedToStartTransportError",this.__proto__=n}}class a extends Error{constructor(t){const e=new.target.prototype;super(t),this.errorType="FailedToNegotiateWithServerError",this.__proto__=e}}class l extends Error{constructor(t,e){const n=new.target.prototype;super(t),this.innerErrors=e,this.__proto__=n}}class u{constructor(t,e,n){this.statusCode=t,this.statusText=e,this.content=n}}class d{get(t,e){return this.send({...e,method:"GET",url:t})}post(t,e){return this.send({...e,method:"POST",url:t})}delete(t,e){return this.send({...e,method:"DELETE",url:t})}getCookieString(t){return""}}!function(t){t[t.Trace=0]="Trace",t[t.Debug=1]="Debug",t[t.Information=2]="Information",t[t.Warning=3]="Warning",t[t.Error=4]="Error",t[t.Critical=5]="Critical",t[t.None=6]="None"}(e||(e={}));class f{constructor(){}log(t,e){}}f.instance=new f;const p="7.0.0-preview.4.22251.1";class w{static isRequired(t,e){if(null==t)throw new Error(`The '${e}' argument is required.`)}static isNotEmpty(t,e){if(!t||t.match(/^\s*$/))throw new Error(`The '${e}' argument should not be empty.`)}static isIn(t,e,n){if(!(t in e))throw new Error(`Unknown ${n} value: ${t}.`)}}class g{static get isBrowser(){return"object"==typeof window&&"object"==typeof window.document}static get isWebWorker(){return"object"==typeof self&&"importScripts"in self}static get isReactNative(){return"object"==typeof window&&void 0===window.document}static get isNode(){return!this.isBrowser&&!this.isWebWorker&&!this.isReactNative}}function y(t,e){let n="";return m(t)?(n=`Binary data of length ${t.byteLength}`,e&&(n+=`. Content: '${function(t){const e=new Uint8Array(t);let n="";return e.forEach((t=>{n+=`0x${t<16?"0":""}${t.toString(16)} `})),n.substr(0,n.length-1)}(t)}'`)):"string"==typeof t&&(n=`String data of length ${t.length}`,e&&(n+=`. Content: '${t}'`)),n}function m(t){return t&&"undefined"!=typeof ArrayBuffer&&(t instanceof ArrayBuffer||t.constructor&&"ArrayBuffer"===t.constructor.name)}async function b(t,n,s,i,r,o,h){let c={};if(r){const t=await r();t&&(c={Authorization:`Bearer ${t}`})}const[a,l]=E();c[a]=l,t.log(e.Trace,`(${n} transport) sending data. ${y(o,h.logMessageContent)}.`);const u=m(o)?"arraybuffer":"text",d=await s.post(i,{content:o,headers:{...c,...h.headers},responseType:u,timeout:h.timeout,withCredentials:h.withCredentials});t.log(e.Trace,`(${n} transport) request complete. Response status: ${d.statusCode}.`)}class v{constructor(t,e){this.i=t,this.h=e}dispose(){const t=this.i.observers.indexOf(this.h);t>-1&&this.i.observers.splice(t,1),0===this.i.observers.length&&this.i.cancelCallback&&this.i.cancelCallback().catch((t=>{}))}}class ${constructor(t){this.l=t,this.out=console}log(t,n){if(t>=this.l){const s=`[${(new Date).toISOString()}] ${e[t]}: ${n}`;switch(t){case e.Critical:case e.Error:this.out.error(s);break;case e.Warning:this.out.warn(s);break;case e.Information:this.out.info(s);break;default:this.out.log(s)}}}}function E(){let t="X-SignalR-User-Agent";return g.isNode&&(t="User-Agent"),[t,C(p,S(),g.isNode?"NodeJS":"Browser",k())]}function C(t,e,n,s){let i="Microsoft SignalR/";const r=t.split(".");return i+=`${r[0]}.${r[1]}`,i+=` (${t}; `,i+=e&&""!==e?`${e}; `:"Unknown OS; ",i+=`${n}`,i+=s?`; ${s}`:"; Unknown Runtime Version",i+=")",i}function S(){if(!g.isNode)return"";switch(process.platform){case"win32":return"Windows NT";case"darwin":return"macOS";case"linux":return"Linux";default:return process.platform}}function k(){if(g.isNode)return process.versions.node}function P(t){return t.stack?t.stack:t.message?t.message:`${t}`}class T extends d{constructor(e){if(super(),this.u=e,"undefined"==typeof fetch){const t=require;this.p=new(t("tough-cookie").CookieJar),this.m=t("node-fetch"),this.m=t("fetch-cookie")(this.m,this.p)}else this.m=fetch.bind(function(){if("undefined"!=typeof globalThis)return globalThis;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==t.g)return t.g;throw new Error("could not find global")}());if("undefined"==typeof AbortController){const t=require;this.v=t("abort-controller")}else this.v=AbortController}async send(t){if(t.abortSignal&&t.abortSignal.aborted)throw new r;if(!t.method)throw new Error("No method defined.");if(!t.url)throw new Error("No url defined.");const n=new this.v;let o;t.abortSignal&&(t.abortSignal.onabort=()=>{n.abort(),o=new r});let h,c=null;if(t.timeout){const s=t.timeout;c=setTimeout((()=>{n.abort(),this.u.log(e.Warning,"Timeout from HTTP request."),o=new i}),s)}try{h=await this.m(t.url,{body:t.content,cache:"no-cache",credentials:!0===t.withCredentials?"include":"same-origin",headers:{"Content-Type":"text/plain;charset=UTF-8","X-Requested-With":"XMLHttpRequest",...t.headers},method:t.method,mode:"cors",redirect:"follow",signal:n.signal})}catch(t){if(o)throw o;throw this.u.log(e.Warning,`Error from HTTP request. ${t}.`),t}finally{c&&clearTimeout(c),t.abortSignal&&(t.abortSignal.onabort=null)}if(!h.ok){const t=await I(h,"text");throw new s(t||h.statusText,h.status)}const a=I(h,t.responseType),l=await a;return new u(h.status,h.statusText,l)}getCookieString(t){let e="";return g.isNode&&this.p&&this.p.getCookies(t,((t,n)=>e=n.join("; "))),e}}function I(t,e){let n;switch(e){case"arraybuffer":n=t.arrayBuffer();break;case"text":n=t.text();break;case"blob":case"document":case"json":throw new Error(`${e} is not supported.`);default:n=t.text()}return n}class _ extends d{constructor(t){super(),this.u=t}send(t){return t.abortSignal&&t.abortSignal.aborted?Promise.reject(new r):t.method?t.url?new Promise(((n,o)=>{const h=new XMLHttpRequest;h.open(t.method,t.url,!0),h.withCredentials=void 0===t.withCredentials||t.withCredentials,h.setRequestHeader("X-Requested-With","XMLHttpRequest"),h.setRequestHeader("Content-Type","text/plain;charset=UTF-8");const c=t.headers;c&&Object.keys(c).forEach((t=>{h.setRequestHeader(t,c[t])})),t.responseType&&(h.responseType=t.responseType),t.abortSignal&&(t.abortSignal.onabort=()=>{h.abort(),o(new r)}),t.timeout&&(h.timeout=t.timeout),h.onload=()=>{t.abortSignal&&(t.abortSignal.onabort=null),h.status>=200&&h.status<300?n(new u(h.status,h.statusText,h.response||h.responseText)):o(new s(h.response||h.responseText||h.statusText,h.status))},h.onerror=()=>{this.u.log(e.Warning,`Error from HTTP request. ${h.status}: ${h.statusText}.`),o(new s(h.statusText,h.status))},h.ontimeout=()=>{this.u.log(e.Warning,"Timeout from HTTP request."),o(new i)},h.send(t.content||"")})):Promise.reject(new Error("No url defined.")):Promise.reject(new Error("No method defined."))}}class H extends d{constructor(t){if(super(),"undefined"!=typeof fetch||g.isNode)this.$=new T(t);else{if("undefined"==typeof XMLHttpRequest)throw new Error("No usable HttpClient found.");this.$=new _(t)}}send(t){return t.abortSignal&&t.abortSignal.aborted?Promise.reject(new r):t.method?t.url?this.$.send(t):Promise.reject(new Error("No url defined.")):Promise.reject(new Error("No method defined."))}getCookieString(t){return this.$.getCookieString(t)}}class D{static write(t){return`${t}${D.RecordSeparator}`}static parse(t){if(t[t.length-1]!==D.RecordSeparator)throw new Error("Message is incomplete.");const e=t.split(D.RecordSeparator);return e.pop(),e}}D.RecordSeparatorCode=30,D.RecordSeparator=String.fromCharCode(D.RecordSeparatorCode);class x{writeHandshakeRequest(t){return D.write(JSON.stringify(t))}parseHandshakeResponse(t){let e,n;if(m(t)){const s=new Uint8Array(t),i=s.indexOf(D.RecordSeparatorCode);if(-1===i)throw new Error("Message is incomplete.");const r=i+1;e=String.fromCharCode.apply(null,Array.prototype.slice.call(s.slice(0,r))),n=s.byteLength>r?s.slice(r).buffer:null}else{const s=t,i=s.indexOf(D.RecordSeparator);if(-1===i)throw new Error("Message is incomplete.");const r=i+1;e=s.substring(0,r),n=s.length>r?s.substring(r):null}const s=D.parse(e),i=JSON.parse(s[0]);if(i.type)throw new Error("Expected a handshake response from the server.");return[n,i]}}var R,A;!function(t){t[t.Invocation=1]="Invocation",t[t.StreamItem=2]="StreamItem",t[t.Completion=3]="Completion",t[t.StreamInvocation=4]="StreamInvocation",t[t.CancelInvocation=5]="CancelInvocation",t[t.Ping=6]="Ping",t[t.Close=7]="Close"}(R||(R={}));class U{constructor(){this.observers=[]}next(t){for(const e of this.observers)e.next(t)}error(t){for(const e of this.observers)e.error&&e.error(t)}complete(){for(const t of this.observers)t.complete&&t.complete()}subscribe(t){return this.observers.push(t),new v(this,t)}}!function(t){t.Disconnected="Disconnected",t.Connecting="Connecting",t.Connected="Connected",t.Disconnecting="Disconnecting",t.Reconnecting="Reconnecting"}(A||(A={}));class N{constructor(t,n,s,i){this.C=0,this.S=()=>{this.u.log(e.Warning,"The page is being frozen, this will likely lead to the connection being closed and messages being lost. For more information see the docs at https://docs.microsoft.com/aspnet/core/signalr/javascript-client#bsleep")},w.isRequired(t,"connection"),w.isRequired(n,"logger"),w.isRequired(s,"protocol"),this.serverTimeoutInMilliseconds=3e4,this.keepAliveIntervalInMilliseconds=15e3,this.u=n,this.k=s,this.connection=t,this.P=i,this.T=new x,this.connection.onreceive=t=>this.I(t),this.connection.onclose=t=>this._(t),this.H={},this.D={},this.R=[],this.A=[],this.U=[],this.N=0,this.L=!1,this.M=A.Disconnected,this.j=!1,this.q=this.k.writeMessage({type:R.Ping})}static create(t,e,n,s){return new N(t,e,n,s)}get state(){return this.M}get connectionId(){return this.connection&&this.connection.connectionId||null}get baseUrl(){return this.connection.baseUrl||""}set baseUrl(t){if(this.M!==A.Disconnected&&this.M!==A.Reconnecting)throw new Error("The HubConnection must be in the Disconnected or Reconnecting state to change the url.");if(!t)throw new Error("The HubConnection url must be a valid url.");this.connection.baseUrl=t}start(){return this.W=this.O(),this.W}async O(){if(this.M!==A.Disconnected)return Promise.reject(new Error("Cannot start a HubConnection that is not in the 'Disconnected' state."));this.M=A.Connecting,this.u.log(e.Debug,"Starting HubConnection.");try{await this.F(),g.isBrowser&&window.document.addEventListener("freeze",this.S),this.M=A.Connected,this.j=!0,this.u.log(e.Debug,"HubConnection connected successfully.")}catch(t){return this.M=A.Disconnected,this.u.log(e.Debug,`HubConnection failed to start successfully because of error '${t}'.`),Promise.reject(t)}}async F(){this.B=void 0,this.L=!1;const t=new Promise(((t,e)=>{this.X=t,this.J=e}));await this.connection.start(this.k.transferFormat);try{const n={protocol:this.k.name,version:this.k.version};if(this.u.log(e.Debug,"Sending handshake request."),await this.V(this.T.writeHandshakeRequest(n)),this.u.log(e.Information,`Using HubProtocol '${this.k.name}'.`),this.G(),this.K(),this.Y(),await t,this.B)throw this.B}catch(t){throw this.u.log(e.Debug,`Hub handshake failed with error '${t}' during start(). Stopping HubConnection.`),this.G(),this.Z(),await this.connection.stop(t),t}}async stop(){const t=this.W;this.tt=this.et(),await this.tt;try{await t}catch(t){}}et(t){return this.M===A.Disconnected?(this.u.log(e.Debug,`Call to HubConnection.stop(${t}) ignored because it is already in the disconnected state.`),Promise.resolve()):this.M===A.Disconnecting?(this.u.log(e.Debug,`Call to HttpConnection.stop(${t}) ignored because the connection is already in the disconnecting state.`),this.tt):(this.M=A.Disconnecting,this.u.log(e.Debug,"Stopping HubConnection."),this.nt?(this.u.log(e.Debug,"Connection stopped during reconnect delay. Done reconnecting."),clearTimeout(this.nt),this.nt=void 0,this.st(),Promise.resolve()):(this.G(),this.Z(),this.B=t||new r("The connection was stopped before the hub handshake could complete."),this.connection.stop(t)))}stream(t,...e){const[n,s]=this.it(e),i=this.rt(t,e,s);let r;const o=new U;return o.cancelCallback=()=>{const t=this.ot(i.invocationId);return delete this.H[i.invocationId],r.then((()=>this.ht(t)))},this.H[i.invocationId]=(t,e)=>{e?o.error(e):t&&(t.type===R.Completion?t.error?o.error(new Error(t.error)):o.complete():o.next(t.item))},r=this.ht(i).catch((t=>{o.error(t),delete this.H[i.invocationId]})),this.ct(n,r),o}V(t){return this.Y(),this.connection.send(t)}ht(t){return this.V(this.k.writeMessage(t))}send(t,...e){const[n,s]=this.it(e),i=this.ht(this.lt(t,e,!0,s));return this.ct(n,i),i}invoke(t,...e){const[n,s]=this.it(e),i=this.lt(t,e,!1,s);return new Promise(((t,e)=>{this.H[i.invocationId]=(n,s)=>{s?e(s):n&&(n.type===R.Completion?n.error?e(new Error(n.error)):t(n.result):e(new Error(`Unexpected message type: ${n.type}`)))};const s=this.ht(i).catch((t=>{e(t),delete this.H[i.invocationId]}));this.ct(n,s)}))}on(t,e){t&&e&&(t=t.toLowerCase(),this.D[t]||(this.D[t]=[]),-1===this.D[t].indexOf(e)&&this.D[t].push(e))}off(t,e){if(!t)return;t=t.toLowerCase();const n=this.D[t];if(n)if(e){const s=n.indexOf(e);-1!==s&&(n.splice(s,1),0===n.length&&delete this.D[t])}else delete this.D[t]}onclose(t){t&&this.R.push(t)}onreconnecting(t){t&&this.A.push(t)}onreconnected(t){t&&this.U.push(t)}I(t){if(this.G(),this.L||(t=this.ut(t),this.L=!0),t){const n=this.k.parseMessages(t,this.u);for(const t of n)switch(t.type){case R.Invocation:this.dt(t);break;case R.StreamItem:case R.Completion:{const n=this.H[t.invocationId];if(n){t.type===R.Completion&&delete this.H[t.invocationId];try{n(t)}catch(t){this.u.log(e.Error,`Stream callback threw error: ${P(t)}`)}}break}case R.Ping:break;case R.Close:{this.u.log(e.Information,"Close message received from server.");const n=t.error?new Error("Server returned an error on close: "+t.error):void 0;!0===t.allowReconnect?this.connection.stop(n):this.tt=this.et(n);break}default:this.u.log(e.Warning,`Invalid message type: ${t.type}.`)}}this.K()}ut(t){let n,s;try{[s,n]=this.T.parseHandshakeResponse(t)}catch(t){const n="Error parsing handshake response: "+t;this.u.log(e.Error,n);const s=new Error(n);throw this.J(s),s}if(n.error){const t="Server returned handshake error: "+n.error;this.u.log(e.Error,t);const s=new Error(t);throw this.J(s),s}return this.u.log(e.Debug,"Server handshake complete."),this.X(),s}Y(){this.connection.features.inherentKeepAlive||(this.C=(new Date).getTime()+this.keepAliveIntervalInMilliseconds,this.Z())}K(){if(!(this.connection.features&&this.connection.features.inherentKeepAlive||(this.ft=setTimeout((()=>this.serverTimeout()),this.serverTimeoutInMilliseconds),void 0!==this.wt))){let t=this.C-(new Date).getTime();t<0&&(t=0),this.wt=setTimeout((async()=>{if(this.M===A.Connected)try{await this.V(this.q)}catch{this.Z()}}),t)}}serverTimeout(){this.connection.stop(new Error("Server timeout elapsed without receiving a message from the server."))}async dt(t){const n=t.target.toLowerCase(),s=this.D[n];if(!s)return this.u.log(e.Warning,`No client method with the name '${n}' found.`),void(t.invocationId&&(this.u.log(e.Warning,`No result given for '${n}' method and invocation ID '${t.invocationId}'.`),await this.ht(this.gt(t.invocationId,"Client didn't provide a result.",null))));const i=s.slice(),r=!!t.invocationId;let o,h,c;for(const s of i)try{const i=o;o=await s.apply(this,t.arguments),r&&o&&i&&(this.u.log(e.Error,`Multiple results provided for '${n}'. Sending error to server.`),c=this.gt(t.invocationId,"Client provided multiple results.",null)),h=void 0}catch(t){h=t,this.u.log(e.Error,`A callback for the method '${n}' threw error '${t}'.`)}c?await this.ht(c):r?(h?c=this.gt(t.invocationId,`${h}`,null):void 0!==o?c=this.gt(t.invocationId,null,o):(this.u.log(e.Warning,`No result given for '${n}' method and invocation ID '${t.invocationId}'.`),c=this.gt(t.invocationId,"Client didn't provide a result.",null)),await this.ht(c)):o&&this.u.log(e.Error,`Result given for '${n}' method but server is not expecting a result.`)}_(t){this.u.log(e.Debug,`HubConnection.connectionClosed(${t}) called while in state ${this.M}.`),this.B=this.B||t||new r("The underlying connection was closed before the hub handshake could complete."),this.X&&this.X(),this.yt(t||new Error("Invocation canceled due to the underlying connection being closed.")),this.G(),this.Z(),this.M===A.Disconnecting?this.st(t):this.M===A.Connected&&this.P?this.bt(t):this.M===A.Connected&&this.st(t)}st(t){if(this.j){this.M=A.Disconnected,this.j=!1,g.isBrowser&&window.document.removeEventListener("freeze",this.S);try{this.R.forEach((e=>e.apply(this,[t])))}catch(n){this.u.log(e.Error,`An onclose callback called with error '${t}' threw error '${n}'.`)}}}async bt(t){const n=Date.now();let s=0,i=void 0!==t?t:new Error("Attempting to reconnect due to a unknown error."),r=this.vt(s++,0,i);if(null===r)return this.u.log(e.Debug,"Connection not reconnecting because the IRetryPolicy returned null on the first reconnect attempt."),void this.st(t);if(this.M=A.Reconnecting,t?this.u.log(e.Information,`Connection reconnecting because of error '${t}'.`):this.u.log(e.Information,"Connection reconnecting."),0!==this.A.length){try{this.A.forEach((e=>e.apply(this,[t])))}catch(n){this.u.log(e.Error,`An onreconnecting callback called with error '${t}' threw error '${n}'.`)}if(this.M!==A.Reconnecting)return void this.u.log(e.Debug,"Connection left the reconnecting state in onreconnecting callback. Done reconnecting.")}for(;null!==r;){if(this.u.log(e.Information,`Reconnect attempt number ${s} will start in ${r} ms.`),await new Promise((t=>{this.nt=setTimeout(t,r)})),this.nt=void 0,this.M!==A.Reconnecting)return void this.u.log(e.Debug,"Connection left the reconnecting state during reconnect delay. Done reconnecting.");try{if(await this.F(),this.M=A.Connected,this.u.log(e.Information,"HubConnection reconnected successfully."),0!==this.U.length)try{this.U.forEach((t=>t.apply(this,[this.connection.connectionId])))}catch(t){this.u.log(e.Error,`An onreconnected callback called with connectionId '${this.connection.connectionId}; threw error '${t}'.`)}return}catch(t){if(this.u.log(e.Information,`Reconnect attempt failed because of error '${t}'.`),this.M!==A.Reconnecting)return this.u.log(e.Debug,`Connection moved to the '${this.M}' from the reconnecting state during reconnect attempt. Done reconnecting.`),void(this.M===A.Disconnecting&&this.st());i=t instanceof Error?t:new Error(t.toString()),r=this.vt(s++,Date.now()-n,i)}}this.u.log(e.Information,`Reconnect retries have been exhausted after ${Date.now()-n} ms and ${s} failed attempts. Connection disconnecting.`),this.st()}vt(t,n,s){try{return this.P.nextRetryDelayInMilliseconds({elapsedMilliseconds:n,previousRetryCount:t,retryReason:s})}catch(s){return this.u.log(e.Error,`IRetryPolicy.nextRetryDelayInMilliseconds(${t}, ${n}) threw error '${s}'.`),null}}yt(t){const n=this.H;this.H={},Object.keys(n).forEach((s=>{const i=n[s];try{i(null,t)}catch(n){this.u.log(e.Error,`Stream 'error' callback called with '${t}' threw error: ${P(n)}`)}}))}Z(){this.wt&&(clearTimeout(this.wt),this.wt=void 0)}G(){this.ft&&clearTimeout(this.ft)}lt(t,e,n,s){if(n)return 0!==s.length?{arguments:e,streamIds:s,target:t,type:R.Invocation}:{arguments:e,target:t,type:R.Invocation};{const n=this.N;return this.N++,0!==s.length?{arguments:e,invocationId:n.toString(),streamIds:s,target:t,type:R.Invocation}:{arguments:e,invocationId:n.toString(),target:t,type:R.Invocation}}}ct(t,e){if(0!==t.length){e||(e=Promise.resolve());for(const n in t)t[n].subscribe({complete:()=>{e=e.then((()=>this.ht(this.gt(n))))},error:t=>{let s;s=t instanceof Error?t.message:t&&t.toString?t.toString():"Unknown error",e=e.then((()=>this.ht(this.gt(n,s))))},next:t=>{e=e.then((()=>this.ht(this.$t(n,t))))}})}}it(t){const e=[],n=[];for(let s=0;s<t.length;s++){const i=t[s];if(this.Et(i)){const r=this.N;this.N++,e[r]=i,n.push(r.toString()),t.splice(s,1)}}return[e,n]}Et(t){return t&&t.subscribe&&"function"==typeof t.subscribe}rt(t,e,n){const s=this.N;return this.N++,0!==n.length?{arguments:e,invocationId:s.toString(),streamIds:n,target:t,type:R.StreamInvocation}:{arguments:e,invocationId:s.toString(),target:t,type:R.StreamInvocation}}ot(t){return{invocationId:t,type:R.CancelInvocation}}$t(t,e){return{invocationId:t,item:e,type:R.StreamItem}}gt(t,e,n){return e?{error:e,invocationId:t,type:R.Completion}:{invocationId:t,result:n,type:R.Completion}}}const L=[0,2e3,1e4,3e4,null];class M{constructor(t){this.Ct=void 0!==t?[...t,null]:L}nextRetryDelayInMilliseconds(t){return this.Ct[t.previousRetryCount]}}class j{}var q,W;j.Authorization="Authorization",j.Cookie="Cookie",function(t){t[t.None=0]="None",t[t.WebSockets=1]="WebSockets",t[t.ServerSentEvents=2]="ServerSentEvents",t[t.LongPolling=4]="LongPolling"}(q||(q={})),function(t){t[t.Text=1]="Text",t[t.Binary=2]="Binary"}(W||(W={}));class O{constructor(){this.St=!1,this.onabort=null}abort(){this.St||(this.St=!0,this.onabort&&this.onabort())}get signal(){return this}get aborted(){return this.St}}class F{constructor(t,e,n,s){this.$=t,this.kt=e,this.u=n,this.Pt=new O,this.Tt=s,this.It=!1,this.onreceive=null,this.onclose=null}get pollAborted(){return this.Pt.aborted}async connect(t,n){if(w.isRequired(t,"url"),w.isRequired(n,"transferFormat"),w.isIn(n,W,"transferFormat"),this._t=t,this.u.log(e.Trace,"(LongPolling transport) Connecting."),n===W.Binary&&"undefined"!=typeof XMLHttpRequest&&"string"!=typeof(new XMLHttpRequest).responseType)throw new Error("Binary protocols over XmlHttpRequest not implementing advanced features are not supported.");const[i,r]=E(),o={[i]:r,...this.Tt.headers},h={abortSignal:this.Pt.signal,headers:o,timeout:1e5,withCredentials:this.Tt.withCredentials};n===W.Binary&&(h.responseType="arraybuffer"),await this.Ht(h);const c=`${t}&_=${Date.now()}`;this.u.log(e.Trace,`(LongPolling transport) polling: ${c}.`);const a=await this.$.get(c,h);200!==a.statusCode?(this.u.log(e.Error,`(LongPolling transport) Unexpected response code: ${a.statusCode}.`),this.Dt=new s(a.statusText||"",a.statusCode),this.It=!1):this.It=!0,this.xt=this.Rt(this._t,h)}async Ht(t){if(t.headers||(t.headers={}),this.kt){const e=await this.kt();e?t.headers[j.Authorization]=`Bearer ${e}`:t.headers[j.Authorization]&&delete t.headers[j.Authorization]}}async Rt(t,n){try{for(;this.It;){await this.Ht(n);try{const i=`${t}&_=${Date.now()}`;this.u.log(e.Trace,`(LongPolling transport) polling: ${i}.`);const r=await this.$.get(i,n);204===r.statusCode?(this.u.log(e.Information,"(LongPolling transport) Poll terminated by server."),this.It=!1):200!==r.statusCode?(this.u.log(e.Error,`(LongPolling transport) Unexpected response code: ${r.statusCode}.`),this.Dt=new s(r.statusText||"",r.statusCode),this.It=!1):r.content?(this.u.log(e.Trace,`(LongPolling transport) data received. ${y(r.content,this.Tt.logMessageContent)}.`),this.onreceive&&this.onreceive(r.content)):this.u.log(e.Trace,"(LongPolling transport) Poll timed out, reissuing.")}catch(t){this.It?t instanceof i?this.u.log(e.Trace,"(LongPolling transport) Poll timed out, reissuing."):(this.Dt=t,this.It=!1):this.u.log(e.Trace,`(LongPolling transport) Poll errored after shutdown: ${t.message}`)}}}finally{this.u.log(e.Trace,"(LongPolling transport) Polling complete."),this.pollAborted||this.At()}}async send(t){return this.It?b(this.u,"LongPolling",this.$,this._t,this.kt,t,this.Tt):Promise.reject(new Error("Cannot send until the transport is connected"))}async stop(){this.u.log(e.Trace,"(LongPolling transport) Stopping polling."),this.It=!1,this.Pt.abort();try{await this.xt,this.u.log(e.Trace,`(LongPolling transport) sending DELETE request to ${this._t}.`);const t={},[n,s]=E();t[n]=s;const i={headers:{...t,...this.Tt.headers},timeout:this.Tt.timeout,withCredentials:this.Tt.withCredentials};await this.Ht(i),await this.$.delete(this._t,i),this.u.log(e.Trace,"(LongPolling transport) DELETE request sent.")}finally{this.u.log(e.Trace,"(LongPolling transport) Stop finished."),this.At()}}At(){if(this.onclose){let t="(LongPolling transport) Firing onclose event.";this.Dt&&(t+=" Error: "+this.Dt),this.u.log(e.Trace,t),this.onclose(this.Dt)}}}class B{constructor(t,e,n,s){this.$=t,this.kt=e,this.u=n,this.Tt=s,this.onreceive=null,this.onclose=null}async connect(t,n){if(w.isRequired(t,"url"),w.isRequired(n,"transferFormat"),w.isIn(n,W,"transferFormat"),this.u.log(e.Trace,"(SSE transport) Connecting."),this._t=t,this.kt){const e=await this.kt();e&&(t+=(t.indexOf("?")<0?"?":"&")+`access_token=${encodeURIComponent(e)}`)}return new Promise(((s,i)=>{let r,o=!1;if(n===W.Text){if(g.isBrowser||g.isWebWorker)r=new this.Tt.EventSource(t,{withCredentials:this.Tt.withCredentials});else{const e=this.$.getCookieString(t),n={};n.Cookie=e;const[s,i]=E();n[s]=i,r=new this.Tt.EventSource(t,{withCredentials:this.Tt.withCredentials,headers:{...n,...this.Tt.headers}})}try{r.onmessage=t=>{if(this.onreceive)try{this.u.log(e.Trace,`(SSE transport) data received. ${y(t.data,this.Tt.logMessageContent)}.`),this.onreceive(t.data)}catch(t){return void this.Ut(t)}},r.onerror=t=>{o?this.Ut():i(new Error("EventSource failed to connect. The connection could not be found on the server, either the connection ID is not present on the server, or a proxy is refusing/buffering the connection. If you have multiple servers check that sticky sessions are enabled."))},r.onopen=()=>{this.u.log(e.Information,`SSE connected to ${this._t}`),this.Nt=r,o=!0,s()}}catch(t){return void i(t)}}else i(new Error("The Server-Sent Events transport only supports the 'Text' transfer format"))}))}async send(t){return this.Nt?b(this.u,"SSE",this.$,this._t,this.kt,t,this.Tt):Promise.reject(new Error("Cannot send until the transport is connected"))}stop(){return this.Ut(),Promise.resolve()}Ut(t){this.Nt&&(this.Nt.close(),this.Nt=void 0,this.onclose&&this.onclose(t))}}class X{constructor(t,e,n,s,i,r){this.u=n,this.kt=e,this.Lt=s,this.Mt=i,this.$=t,this.onreceive=null,this.onclose=null,this.jt=r}async connect(t,n){let s;return w.isRequired(t,"url"),w.isRequired(n,"transferFormat"),w.isIn(n,W,"transferFormat"),this.u.log(e.Trace,"(WebSockets transport) Connecting."),this.kt&&(s=await this.kt()),new Promise(((i,r)=>{let o;t=t.replace(/^http/,"ws");const h=this.$.getCookieString(t);let c=!1;if(g.isNode||g.isReactNative){const e={},[n,i]=E();e[n]=i,s&&(e[j.Authorization]=`Bearer ${s}`),h&&(e[j.Cookie]=h),o=new this.Mt(t,void 0,{headers:{...e,...this.jt}})}else s&&(t+=(t.indexOf("?")<0?"?":"&")+`access_token=${encodeURIComponent(s)}`);o||(o=new this.Mt(t)),n===W.Binary&&(o.binaryType="arraybuffer"),o.onopen=n=>{this.u.log(e.Information,`WebSocket connected to ${t}.`),this.qt=o,c=!0,i()},o.onerror=t=>{let n=null;n="undefined"!=typeof ErrorEvent&&t instanceof ErrorEvent?t.error:"There was an error with the transport",this.u.log(e.Information,`(WebSockets transport) ${n}.`)},o.onmessage=t=>{if(this.u.log(e.Trace,`(WebSockets transport) data received. ${y(t.data,this.Lt)}.`),this.onreceive)try{this.onreceive(t.data)}catch(t){return void this.Ut(t)}},o.onclose=t=>{if(c)this.Ut(t);else{let e=null;e="undefined"!=typeof ErrorEvent&&t instanceof ErrorEvent?t.error:"WebSocket failed to connect. The connection could not be found on the server, either the endpoint may not be a SignalR endpoint, the connection ID is not present on the server, or there is a proxy blocking WebSockets. If you have multiple servers check that sticky sessions are enabled.",r(new Error(e))}}}))}send(t){return this.qt&&this.qt.readyState===this.Mt.OPEN?(this.u.log(e.Trace,`(WebSockets transport) sending data. ${y(t,this.Lt)}.`),this.qt.send(t),Promise.resolve()):Promise.reject("WebSocket is not in the OPEN state")}stop(){return this.qt&&this.Ut(void 0),Promise.resolve()}Ut(t){this.qt&&(this.qt.onclose=()=>{},this.qt.onmessage=()=>{},this.qt.onerror=()=>{},this.qt.close(),this.qt=void 0),this.u.log(e.Trace,"(WebSockets transport) socket closed."),this.onclose&&(!this.Wt(t)||!1!==t.wasClean&&1e3===t.code?t instanceof Error?this.onclose(t):this.onclose():this.onclose(new Error(`WebSocket closed with status code: ${t.code} (${t.reason||"no reason given"}).`)))}Wt(t){return t&&"boolean"==typeof t.wasClean&&"number"==typeof t.code}}class J{constructor(t,n={}){var s;if(this.Ot=()=>{},this.features={},this.Ft=1,w.isRequired(t,"url"),this.u=void 0===(s=n.logger)?new $(e.Information):null===s?f.instance:void 0!==s.log?s:new $(s),this.baseUrl=this.Bt(t),(n=n||{}).logMessageContent=void 0!==n.logMessageContent&&n.logMessageContent,"boolean"!=typeof n.withCredentials&&void 0!==n.withCredentials)throw new Error("withCredentials option was not a 'boolean' or 'undefined' value");n.withCredentials=void 0===n.withCredentials||n.withCredentials,n.timeout=void 0===n.timeout?1e5:n.timeout;let i=null,r=null;if(g.isNode){const t=require;i=t("ws"),r=t("eventsource")}g.isNode||"undefined"==typeof WebSocket||n.WebSocket?g.isNode&&!n.WebSocket&&i&&(n.WebSocket=i):n.WebSocket=WebSocket,g.isNode||"undefined"==typeof EventSource||n.EventSource?g.isNode&&!n.EventSource&&void 0!==r&&(n.EventSource=r):n.EventSource=EventSource,this.$=n.httpClient||new H(this.u),this.M="Disconnected",this.j=!1,this.Tt=n,this.onreceive=null,this.onclose=null}async start(t){if(t=t||W.Binary,w.isIn(t,W,"transferFormat"),this.u.log(e.Debug,`Starting connection with transfer format '${W[t]}'.`),"Disconnected"!==this.M)return Promise.reject(new Error("Cannot start an HttpConnection that is not in the 'Disconnected' state."));if(this.M="Connecting",this.Xt=this.F(t),await this.Xt,"Disconnecting"===this.M){const t="Failed to start the HttpConnection before stop() was called.";return this.u.log(e.Error,t),await this.tt,Promise.reject(new r(t))}if("Connected"!==this.M){const t="HttpConnection.startInternal completed gracefully but didn't enter the connection into the connected state!";return this.u.log(e.Error,t),Promise.reject(new r(t))}this.j=!0}send(t){return"Connected"!==this.M?Promise.reject(new Error("Cannot send data if the connection is not in the 'Connected' State.")):(this.Jt||(this.Jt=new z(this.transport)),this.Jt.send(t))}async stop(t){return"Disconnected"===this.M?(this.u.log(e.Debug,`Call to HttpConnection.stop(${t}) ignored because the connection is already in the disconnected state.`),Promise.resolve()):"Disconnecting"===this.M?(this.u.log(e.Debug,`Call to HttpConnection.stop(${t}) ignored because the connection is already in the disconnecting state.`),this.tt):(this.M="Disconnecting",this.tt=new Promise((t=>{this.Ot=t})),await this.et(t),void await this.tt)}async et(t){this.zt=t;try{await this.Xt}catch(t){}if(this.transport){try{await this.transport.stop()}catch(t){this.u.log(e.Error,`HttpConnection.transport.stop() threw error '${t}'.`),this.Vt()}this.transport=void 0}else this.u.log(e.Debug,"HttpConnection.transport is undefined in HttpConnection.stop() because start() failed.")}async F(t){let n=this.baseUrl;this.kt=this.Tt.accessTokenFactory;try{if(this.Tt.skipNegotiation){if(this.Tt.transport!==q.WebSockets)throw new Error("Negotiation can only be skipped when using the WebSocket transport directly.");this.transport=this.Gt(q.WebSockets),await this.Kt(n,t)}else{let e=null,s=0;do{if(e=await this.Qt(n),"Disconnecting"===this.M||"Disconnected"===this.M)throw new r("The connection was stopped during negotiation.");if(e.error)throw new Error(e.error);if(e.ProtocolVersion)throw new Error("Detected a connection attempt to an ASP.NET SignalR Server. This client only supports connecting to an ASP.NET Core SignalR Server. See https://aka.ms/signalr-core-differences for details.");if(e.url&&(n=e.url),e.accessToken){const t=e.accessToken;this.kt=()=>t}s++}while(e.url&&s<100);if(100===s&&e.url)throw new Error("Negotiate redirection limit exceeded.");await this.Yt(n,this.Tt.transport,e,t)}this.transport instanceof F&&(this.features.inherentKeepAlive=!0),"Connecting"===this.M&&(this.u.log(e.Debug,"The HttpConnection connected successfully."),this.M="Connected")}catch(t){return this.u.log(e.Error,"Failed to start the connection: "+t),this.M="Disconnected",this.transport=void 0,this.Ot(),Promise.reject(t)}}async Qt(t){const n={};if(this.kt){const t=await this.kt();t&&(n[j.Authorization]=`Bearer ${t}`)}const[i,r]=E();n[i]=r;const o=this.Zt(t);this.u.log(e.Debug,`Sending negotiation request: ${o}.`);try{const t=await this.$.post(o,{content:"",headers:{...n,...this.Tt.headers},timeout:this.Tt.timeout,withCredentials:this.Tt.withCredentials});if(200!==t.statusCode)return Promise.reject(new Error(`Unexpected status code returned from negotiate '${t.statusCode}'`));const e=JSON.parse(t.content);return(!e.negotiateVersion||e.negotiateVersion<1)&&(e.connectionToken=e.connectionId),e}catch(t){let n="Failed to complete negotiation with the server: "+t;return t instanceof s&&404===t.statusCode&&(n+=" Either this is not a SignalR endpoint or there is a proxy blocking the connection."),this.u.log(e.Error,n),Promise.reject(new a(n))}}te(t,e){return e?t+(-1===t.indexOf("?")?"?":"&")+`id=${e}`:t}async Yt(t,n,s,i){let o=this.te(t,s.connectionToken);if(this.ee(n))return this.u.log(e.Debug,"Connection was provided an instance of ITransport, using that directly."),this.transport=n,await this.Kt(o,i),void(this.connectionId=s.connectionId);const h=[],a=s.availableTransports||[];let u=s;for(const s of a){const a=this.ne(s,n,i);if(a instanceof Error)h.push(`${s.transport} failed:`),h.push(a);else if(this.ee(a)){if(this.transport=a,!u){try{u=await this.Qt(t)}catch(t){return Promise.reject(t)}o=this.te(t,u.connectionToken)}try{return await this.Kt(o,i),void(this.connectionId=u.connectionId)}catch(t){if(this.u.log(e.Error,`Failed to start the transport '${s.transport}': ${t}`),u=void 0,h.push(new c(`${s.transport} failed: ${t}`,q[s.transport])),"Connecting"!==this.M){const t="Failed to select transport before stop() was called.";return this.u.log(e.Debug,t),Promise.reject(new r(t))}}}}return h.length>0?Promise.reject(new l(`Unable to connect to the server with any of the available transports. ${h.join(" ")}`,h)):Promise.reject(new Error("None of the transports supported by the client are supported by the server."))}Gt(t){switch(t){case q.WebSockets:if(!this.Tt.WebSocket)throw new Error("'WebSocket' is not supported in your environment.");return new X(this.$,this.kt,this.u,this.Tt.logMessageContent,this.Tt.WebSocket,this.Tt.headers||{});case q.ServerSentEvents:if(!this.Tt.EventSource)throw new Error("'EventSource' is not supported in your environment.");return new B(this.$,this.kt,this.u,this.Tt);case q.LongPolling:return new F(this.$,this.kt,this.u,this.Tt);default:throw new Error(`Unknown transport: ${t}.`)}}Kt(t,e){return this.transport.onreceive=this.onreceive,this.transport.onclose=t=>this.Vt(t),this.transport.connect(t,e)}ne(t,n,s){const i=q[t.transport];if(null==i)return this.u.log(e.Debug,`Skipping transport '${t.transport}' because it is not supported by this client.`),new Error(`Skipping transport '${t.transport}' because it is not supported by this client.`);if(!function(t,e){return!t||0!=(e&t)}(n,i))return this.u.log(e.Debug,`Skipping transport '${q[i]}' because it was disabled by the client.`),new h(`'${q[i]}' is disabled by the client.`,i);if(!(t.transferFormats.map((t=>W[t])).indexOf(s)>=0))return this.u.log(e.Debug,`Skipping transport '${q[i]}' because it does not support the requested transfer format '${W[s]}'.`),new Error(`'${q[i]}' does not support ${W[s]}.`);if(i===q.WebSockets&&!this.Tt.WebSocket||i===q.ServerSentEvents&&!this.Tt.EventSource)return this.u.log(e.Debug,`Skipping transport '${q[i]}' because it is not supported in your environment.'`),new o(`'${q[i]}' is not supported in your environment.`,i);this.u.log(e.Debug,`Selecting transport '${q[i]}'.`);try{return this.Gt(i)}catch(t){return t}}ee(t){return t&&"object"==typeof t&&"connect"in t}Vt(t){if(this.u.log(e.Debug,`HttpConnection.stopConnection(${t}) called while in state ${this.M}.`),this.transport=void 0,t=this.zt||t,this.zt=void 0,"Disconnected"!==this.M){if("Connecting"===this.M)throw this.u.log(e.Warning,`Call to HttpConnection.stopConnection(${t}) was ignored because the connection is still in the connecting state.`),new Error(`HttpConnection.stopConnection(${t}) was called while the connection is still in the connecting state.`);if("Disconnecting"===this.M&&this.Ot(),t?this.u.log(e.Error,`Connection disconnected with error '${t}'.`):this.u.log(e.Information,"Connection disconnected."),this.Jt&&(this.Jt.stop().catch((t=>{this.u.log(e.Error,`TransportSendQueue.stop() threw error '${t}'.`)})),this.Jt=void 0),this.connectionId=void 0,this.M="Disconnected",this.j){this.j=!1;try{this.onclose&&this.onclose(t)}catch(n){this.u.log(e.Error,`HttpConnection.onclose(${t}) threw error '${n}'.`)}}}else this.u.log(e.Debug,`Call to HttpConnection.stopConnection(${t}) was ignored because the connection is already in the disconnected state.`)}Bt(t){if(0===t.lastIndexOf("https://",0)||0===t.lastIndexOf("http://",0))return t;if(!g.isBrowser)throw new Error(`Cannot resolve '${t}'.`);const n=window.document.createElement("a");return n.href=t,this.u.log(e.Information,`Normalizing '${t}' to '${n.href}'.`),n.href}Zt(t){const e=t.indexOf("?");let n=t.substring(0,-1===e?t.length:e);return"/"!==n[n.length-1]&&(n+="/"),n+="negotiate",n+=-1===e?"":t.substring(e),-1===n.indexOf("negotiateVersion")&&(n+=-1===e?"?":"&",n+="negotiateVersion="+this.Ft),n}}class z{constructor(t){this.se=t,this.ie=[],this.re=!0,this.oe=new V,this.he=new V,this.ce=this.ae()}send(t){return this.le(t),this.he||(this.he=new V),this.he.promise}stop(){return this.re=!1,this.oe.resolve(),this.ce}le(t){if(this.ie.length&&typeof this.ie[0]!=typeof t)throw new Error(`Expected data to be of type ${typeof this.ie} but was of type ${typeof t}`);this.ie.push(t),this.oe.resolve()}async ae(){for(;;){if(await this.oe.promise,!this.re){this.he&&this.he.reject("Connection stopped.");break}this.oe=new V;const t=this.he;this.he=void 0;const e="string"==typeof this.ie[0]?this.ie.join(""):z.ue(this.ie);this.ie.length=0;try{await this.se.send(e),t.resolve()}catch(e){t.reject(e)}}}static ue(t){const e=t.map((t=>t.byteLength)).reduce(((t,e)=>t+e)),n=new Uint8Array(e);let s=0;for(const e of t)n.set(new Uint8Array(e),s),s+=e.byteLength;return n.buffer}}class V{constructor(){this.promise=new Promise(((t,e)=>[this.de,this.fe]=[t,e]))}resolve(){this.de()}reject(t){this.fe(t)}}class G{constructor(){this.name="json",this.version=1,this.transferFormat=W.Text}parseMessages(t,n){if("string"!=typeof t)throw new Error("Invalid input for JSON hub protocol. Expected a string.");if(!t)return[];null===n&&(n=f.instance);const s=D.parse(t),i=[];for(const t of s){const s=JSON.parse(t);if("number"!=typeof s.type)throw new Error("Invalid payload.");switch(s.type){case R.Invocation:this.pe(s);break;case R.StreamItem:this.we(s);break;case R.Completion:this.ge(s);break;case R.Ping:case R.Close:break;default:n.log(e.Information,"Unknown message type '"+s.type+"' ignored.");continue}i.push(s)}return i}writeMessage(t){return D.write(JSON.stringify(t))}pe(t){this.ye(t.target,"Invalid payload for Invocation message."),void 0!==t.invocationId&&this.ye(t.invocationId,"Invalid payload for Invocation message.")}we(t){if(this.ye(t.invocationId,"Invalid payload for StreamItem message."),void 0===t.item)throw new Error("Invalid payload for StreamItem message.")}ge(t){if(t.result&&t.error)throw new Error("Invalid payload for Completion message.");!t.result&&t.error&&this.ye(t.error,"Invalid payload for Completion message."),this.ye(t.invocationId,"Invalid payload for Completion message.")}ye(t,e){if("string"!=typeof t||""===t)throw new Error(e)}}const K={trace:e.Trace,debug:e.Debug,info:e.Information,information:e.Information,warn:e.Warning,warning:e.Warning,error:e.Error,critical:e.Critical,none:e.None};class Q{configureLogging(t){if(w.isRequired(t,"logging"),void 0!==t.log)this.logger=t;else if("string"==typeof t){const e=function(t){const e=K[t.toLowerCase()];if(void 0!==e)return e;throw new Error(`Unknown log level: ${t}`)}(t);this.logger=new $(e)}else this.logger=new $(t);return this}withUrl(t,e){return w.isRequired(t,"url"),w.isNotEmpty(t,"url"),this.url=t,this.httpConnectionOptions="object"==typeof e?{...this.httpConnectionOptions,...e}:{...this.httpConnectionOptions,transport:e},this}withHubProtocol(t){return w.isRequired(t,"protocol"),this.protocol=t,this}withAutomaticReconnect(t){if(this.reconnectPolicy)throw new Error("A reconnectPolicy has already been set.");return t?Array.isArray(t)?this.reconnectPolicy=new M(t):this.reconnectPolicy=t:this.reconnectPolicy=new M,this}build(){const t=this.httpConnectionOptions||{};if(void 0===t.logger&&(t.logger=this.logger),!this.url)throw new Error("The 'HubConnectionBuilder.withUrl' method must be called before building the connection.");const e=new J(this.url,t);return N.create(e,this.logger||f.instance,this.protocol||new G,this.reconnectPolicy)}}return Uint8Array.prototype.indexOf||Object.defineProperty(Uint8Array.prototype,"indexOf",{value:Array.prototype.indexOf,writable:!0}),Uint8Array.prototype.slice||Object.defineProperty(Uint8Array.prototype,"slice",{value:function(t,e){return new Uint8Array(Array.prototype.slice.call(this,t,e))},writable:!0}),Uint8Array.prototype.forEach||Object.defineProperty(Uint8Array.prototype,"forEach",{value:Array.prototype.forEach,writable:!0}),n})()},"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.signalR=e():t.signalR=e();
var t,e;t=self,e=function(){return(()=>{var t={d:(e,n)=>{for(var s in n)t.o(n,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:n[s]})}};t.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),t.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),t.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"t",{value:!0})};var e,n={};t.r(n),t.d(n,{AbortError:()=>r,DefaultHttpClient:()=>H,HttpClient:()=>d,HttpError:()=>s,HttpResponse:()=>u,HttpTransportType:()=>q,HubConnection:()=>N,HubConnectionBuilder:()=>Q,HubConnectionState:()=>A,JsonHubProtocol:()=>G,LogLevel:()=>e,MessageType:()=>R,NullLogger:()=>f,Subject:()=>U,TimeoutError:()=>i,TransferFormat:()=>W,VERSION:()=>p});class s extends Error{constructor(t,e){const n=new.target.prototype;super(`${t}: Status code '${e}'`),this.statusCode=e,this.__proto__=n}}class i extends Error{constructor(t="A timeout occurred."){const e=new.target.prototype;super(t),this.__proto__=e}}class r extends Error{constructor(t="An abort occurred."){const e=new.target.prototype;super(t),this.__proto__=e}}class o extends Error{constructor(t,e){const n=new.target.prototype;super(t),this.transport=e,this.errorType="UnsupportedTransportError",this.__proto__=n}}class h extends Error{constructor(t,e){const n=new.target.prototype;super(t),this.transport=e,this.errorType="DisabledTransportError",this.__proto__=n}}class c extends Error{constructor(t,e){const n=new.target.prototype;super(t),this.transport=e,this.errorType="FailedToStartTransportError",this.__proto__=n}}class a extends Error{constructor(t){const e=new.target.prototype;super(t),this.errorType="FailedToNegotiateWithServerError",this.__proto__=e}}class l extends Error{constructor(t,e){const n=new.target.prototype;super(t),this.innerErrors=e,this.__proto__=n}}class u{constructor(t,e,n){this.statusCode=t,this.statusText=e,this.content=n}}class d{get(t,e){return this.send({...e,method:"GET",url:t})}post(t,e){return this.send({...e,method:"POST",url:t})}delete(t,e){return this.send({...e,method:"DELETE",url:t})}getCookieString(t){return""}}!function(t){t[t.Trace=0]="Trace",t[t.Debug=1]="Debug",t[t.Information=2]="Information",t[t.Warning=3]="Warning",t[t.Error=4]="Error",t[t.Critical=5]="Critical",t[t.None=6]="None"}(e||(e={}));class f{constructor(){}log(t,e){}}f.instance=new f;const p="7.0.0-preview.5.22303.8";class w{static isRequired(t,e){if(null==t)throw new Error(`The '${e}' argument is required.`)}static isNotEmpty(t,e){if(!t||t.match(/^\s*$/))throw new Error(`The '${e}' argument should not be empty.`)}static isIn(t,e,n){if(!(t in e))throw new Error(`Unknown ${n} value: ${t}.`)}}class g{static get isBrowser(){return"object"==typeof window&&"object"==typeof window.document}static get isWebWorker(){return"object"==typeof self&&"importScripts"in self}static get isReactNative(){return"object"==typeof window&&void 0===window.document}static get isNode(){return!this.isBrowser&&!this.isWebWorker&&!this.isReactNative}}function y(t,e){let n="";return m(t)?(n=`Binary data of length ${t.byteLength}`,e&&(n+=`. Content: '${function(t){const e=new Uint8Array(t);let n="";return e.forEach((t=>{n+=`0x${t<16?"0":""}${t.toString(16)} `})),n.substr(0,n.length-1)}(t)}'`)):"string"==typeof t&&(n=`String data of length ${t.length}`,e&&(n+=`. Content: '${t}'`)),n}function m(t){return t&&"undefined"!=typeof ArrayBuffer&&(t instanceof ArrayBuffer||t.constructor&&"ArrayBuffer"===t.constructor.name)}async function b(t,n,s,i,r,o,h){let c={};if(r){const t=await r();t&&(c={Authorization:`Bearer ${t}`})}const[a,l]=E();c[a]=l,t.log(e.Trace,`(${n} transport) sending data. ${y(o,h.logMessageContent)}.`);const u=m(o)?"arraybuffer":"text",d=await s.post(i,{content:o,headers:{...c,...h.headers},responseType:u,timeout:h.timeout,withCredentials:h.withCredentials});t.log(e.Trace,`(${n} transport) request complete. Response status: ${d.statusCode}.`)}class v{constructor(t,e){this.i=t,this.h=e}dispose(){const t=this.i.observers.indexOf(this.h);t>-1&&this.i.observers.splice(t,1),0===this.i.observers.length&&this.i.cancelCallback&&this.i.cancelCallback().catch((t=>{}))}}class ${constructor(t){this.l=t,this.out=console}log(t,n){if(t>=this.l){const s=`[${(new Date).toISOString()}] ${e[t]}: ${n}`;switch(t){case e.Critical:case e.Error:this.out.error(s);break;case e.Warning:this.out.warn(s);break;case e.Information:this.out.info(s);break;default:this.out.log(s)}}}}function E(){let t="X-SignalR-User-Agent";return g.isNode&&(t="User-Agent"),[t,C(p,S(),g.isNode?"NodeJS":"Browser",k())]}function C(t,e,n,s){let i="Microsoft SignalR/";const r=t.split(".");return i+=`${r[0]}.${r[1]}`,i+=` (${t}; `,i+=e&&""!==e?`${e}; `:"Unknown OS; ",i+=`${n}`,i+=s?`; ${s}`:"; Unknown Runtime Version",i+=")",i}function S(){if(!g.isNode)return"";switch(process.platform){case"win32":return"Windows NT";case"darwin":return"macOS";case"linux":return"Linux";default:return process.platform}}function k(){if(g.isNode)return process.versions.node}function P(t){return t.stack?t.stack:t.message?t.message:`${t}`}class T extends d{constructor(e){if(super(),this.u=e,"undefined"==typeof fetch){const t=require;this.p=new(t("tough-cookie").CookieJar),this.m=t("node-fetch"),this.m=t("fetch-cookie")(this.m,this.p)}else this.m=fetch.bind(function(){if("undefined"!=typeof globalThis)return globalThis;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==t.g)return t.g;throw new Error("could not find global")}());if("undefined"==typeof AbortController){const t=require;this.v=t("abort-controller")}else this.v=AbortController}async send(t){if(t.abortSignal&&t.abortSignal.aborted)throw new r;if(!t.method)throw new Error("No method defined.");if(!t.url)throw new Error("No url defined.");const n=new this.v;let o;t.abortSignal&&(t.abortSignal.onabort=()=>{n.abort(),o=new r});let h,c=null;if(t.timeout){const s=t.timeout;c=setTimeout((()=>{n.abort(),this.u.log(e.Warning,"Timeout from HTTP request."),o=new i}),s)}try{h=await this.m(t.url,{body:t.content,cache:"no-cache",credentials:!0===t.withCredentials?"include":"same-origin",headers:{"Content-Type":"text/plain;charset=UTF-8","X-Requested-With":"XMLHttpRequest",...t.headers},method:t.method,mode:"cors",redirect:"follow",signal:n.signal})}catch(t){if(o)throw o;throw this.u.log(e.Warning,`Error from HTTP request. ${t}.`),t}finally{c&&clearTimeout(c),t.abortSignal&&(t.abortSignal.onabort=null)}if(!h.ok){const t=await I(h,"text");throw new s(t||h.statusText,h.status)}const a=I(h,t.responseType),l=await a;return new u(h.status,h.statusText,l)}getCookieString(t){let e="";return g.isNode&&this.p&&this.p.getCookies(t,((t,n)=>e=n.join("; "))),e}}function I(t,e){let n;switch(e){case"arraybuffer":n=t.arrayBuffer();break;case"text":n=t.text();break;case"blob":case"document":case"json":throw new Error(`${e} is not supported.`);default:n=t.text()}return n}class _ extends d{constructor(t){super(),this.u=t}send(t){return t.abortSignal&&t.abortSignal.aborted?Promise.reject(new r):t.method?t.url?new Promise(((n,o)=>{const h=new XMLHttpRequest;h.open(t.method,t.url,!0),h.withCredentials=void 0===t.withCredentials||t.withCredentials,h.setRequestHeader("X-Requested-With","XMLHttpRequest"),h.setRequestHeader("Content-Type","text/plain;charset=UTF-8");const c=t.headers;c&&Object.keys(c).forEach((t=>{h.setRequestHeader(t,c[t])})),t.responseType&&(h.responseType=t.responseType),t.abortSignal&&(t.abortSignal.onabort=()=>{h.abort(),o(new r)}),t.timeout&&(h.timeout=t.timeout),h.onload=()=>{t.abortSignal&&(t.abortSignal.onabort=null),h.status>=200&&h.status<300?n(new u(h.status,h.statusText,h.response||h.responseText)):o(new s(h.response||h.responseText||h.statusText,h.status))},h.onerror=()=>{this.u.log(e.Warning,`Error from HTTP request. ${h.status}: ${h.statusText}.`),o(new s(h.statusText,h.status))},h.ontimeout=()=>{this.u.log(e.Warning,"Timeout from HTTP request."),o(new i)},h.send(t.content||"")})):Promise.reject(new Error("No url defined.")):Promise.reject(new Error("No method defined."))}}class H extends d{constructor(t){if(super(),"undefined"!=typeof fetch||g.isNode)this.$=new T(t);else{if("undefined"==typeof XMLHttpRequest)throw new Error("No usable HttpClient found.");this.$=new _(t)}}send(t){return t.abortSignal&&t.abortSignal.aborted?Promise.reject(new r):t.method?t.url?this.$.send(t):Promise.reject(new Error("No url defined.")):Promise.reject(new Error("No method defined."))}getCookieString(t){return this.$.getCookieString(t)}}class D{static write(t){return`${t}${D.RecordSeparator}`}static parse(t){if(t[t.length-1]!==D.RecordSeparator)throw new Error("Message is incomplete.");const e=t.split(D.RecordSeparator);return e.pop(),e}}D.RecordSeparatorCode=30,D.RecordSeparator=String.fromCharCode(D.RecordSeparatorCode);class x{writeHandshakeRequest(t){return D.write(JSON.stringify(t))}parseHandshakeResponse(t){let e,n;if(m(t)){const s=new Uint8Array(t),i=s.indexOf(D.RecordSeparatorCode);if(-1===i)throw new Error("Message is incomplete.");const r=i+1;e=String.fromCharCode.apply(null,Array.prototype.slice.call(s.slice(0,r))),n=s.byteLength>r?s.slice(r).buffer:null}else{const s=t,i=s.indexOf(D.RecordSeparator);if(-1===i)throw new Error("Message is incomplete.");const r=i+1;e=s.substring(0,r),n=s.length>r?s.substring(r):null}const s=D.parse(e),i=JSON.parse(s[0]);if(i.type)throw new Error("Expected a handshake response from the server.");return[n,i]}}var R,A;!function(t){t[t.Invocation=1]="Invocation",t[t.StreamItem=2]="StreamItem",t[t.Completion=3]="Completion",t[t.StreamInvocation=4]="StreamInvocation",t[t.CancelInvocation=5]="CancelInvocation",t[t.Ping=6]="Ping",t[t.Close=7]="Close"}(R||(R={}));class U{constructor(){this.observers=[]}next(t){for(const e of this.observers)e.next(t)}error(t){for(const e of this.observers)e.error&&e.error(t)}complete(){for(const t of this.observers)t.complete&&t.complete()}subscribe(t){return this.observers.push(t),new v(this,t)}}!function(t){t.Disconnected="Disconnected",t.Connecting="Connecting",t.Connected="Connected",t.Disconnecting="Disconnecting",t.Reconnecting="Reconnecting"}(A||(A={}));class N{constructor(t,n,s,i){this.C=0,this.S=()=>{this.u.log(e.Warning,"The page is being frozen, this will likely lead to the connection being closed and messages being lost. For more information see the docs at https://docs.microsoft.com/aspnet/core/signalr/javascript-client#bsleep")},w.isRequired(t,"connection"),w.isRequired(n,"logger"),w.isRequired(s,"protocol"),this.serverTimeoutInMilliseconds=3e4,this.keepAliveIntervalInMilliseconds=15e3,this.u=n,this.k=s,this.connection=t,this.P=i,this.T=new x,this.connection.onreceive=t=>this.I(t),this.connection.onclose=t=>this._(t),this.H={},this.D={},this.R=[],this.A=[],this.U=[],this.N=0,this.L=!1,this.M=A.Disconnected,this.j=!1,this.q=this.k.writeMessage({type:R.Ping})}static create(t,e,n,s){return new N(t,e,n,s)}get state(){return this.M}get connectionId(){return this.connection&&this.connection.connectionId||null}get baseUrl(){return this.connection.baseUrl||""}set baseUrl(t){if(this.M!==A.Disconnected&&this.M!==A.Reconnecting)throw new Error("The HubConnection must be in the Disconnected or Reconnecting state to change the url.");if(!t)throw new Error("The HubConnection url must be a valid url.");this.connection.baseUrl=t}start(){return this.W=this.O(),this.W}async O(){if(this.M!==A.Disconnected)return Promise.reject(new Error("Cannot start a HubConnection that is not in the 'Disconnected' state."));this.M=A.Connecting,this.u.log(e.Debug,"Starting HubConnection.");try{await this.F(),g.isBrowser&&window.document.addEventListener("freeze",this.S),this.M=A.Connected,this.j=!0,this.u.log(e.Debug,"HubConnection connected successfully.")}catch(t){return this.M=A.Disconnected,this.u.log(e.Debug,`HubConnection failed to start successfully because of error '${t}'.`),Promise.reject(t)}}async F(){this.B=void 0,this.L=!1;const t=new Promise(((t,e)=>{this.X=t,this.J=e}));await this.connection.start(this.k.transferFormat);try{const n={protocol:this.k.name,version:this.k.version};if(this.u.log(e.Debug,"Sending handshake request."),await this.V(this.T.writeHandshakeRequest(n)),this.u.log(e.Information,`Using HubProtocol '${this.k.name}'.`),this.G(),this.K(),this.Y(),await t,this.B)throw this.B}catch(t){throw this.u.log(e.Debug,`Hub handshake failed with error '${t}' during start(). Stopping HubConnection.`),this.G(),this.Z(),await this.connection.stop(t),t}}async stop(){const t=this.W;this.tt=this.et(),await this.tt;try{await t}catch(t){}}et(t){return this.M===A.Disconnected?(this.u.log(e.Debug,`Call to HubConnection.stop(${t}) ignored because it is already in the disconnected state.`),Promise.resolve()):this.M===A.Disconnecting?(this.u.log(e.Debug,`Call to HttpConnection.stop(${t}) ignored because the connection is already in the disconnecting state.`),this.tt):(this.M=A.Disconnecting,this.u.log(e.Debug,"Stopping HubConnection."),this.nt?(this.u.log(e.Debug,"Connection stopped during reconnect delay. Done reconnecting."),clearTimeout(this.nt),this.nt=void 0,this.st(),Promise.resolve()):(this.G(),this.Z(),this.B=t||new r("The connection was stopped before the hub handshake could complete."),this.connection.stop(t)))}stream(t,...e){const[n,s]=this.it(e),i=this.rt(t,e,s);let r;const o=new U;return o.cancelCallback=()=>{const t=this.ot(i.invocationId);return delete this.H[i.invocationId],r.then((()=>this.ht(t)))},this.H[i.invocationId]=(t,e)=>{e?o.error(e):t&&(t.type===R.Completion?t.error?o.error(new Error(t.error)):o.complete():o.next(t.item))},r=this.ht(i).catch((t=>{o.error(t),delete this.H[i.invocationId]})),this.ct(n,r),o}V(t){return this.Y(),this.connection.send(t)}ht(t){return this.V(this.k.writeMessage(t))}send(t,...e){const[n,s]=this.it(e),i=this.ht(this.lt(t,e,!0,s));return this.ct(n,i),i}invoke(t,...e){const[n,s]=this.it(e),i=this.lt(t,e,!1,s);return new Promise(((t,e)=>{this.H[i.invocationId]=(n,s)=>{s?e(s):n&&(n.type===R.Completion?n.error?e(new Error(n.error)):t(n.result):e(new Error(`Unexpected message type: ${n.type}`)))};const s=this.ht(i).catch((t=>{e(t),delete this.H[i.invocationId]}));this.ct(n,s)}))}on(t,e){t&&e&&(t=t.toLowerCase(),this.D[t]||(this.D[t]=[]),-1===this.D[t].indexOf(e)&&this.D[t].push(e))}off(t,e){if(!t)return;t=t.toLowerCase();const n=this.D[t];if(n)if(e){const s=n.indexOf(e);-1!==s&&(n.splice(s,1),0===n.length&&delete this.D[t])}else delete this.D[t]}onclose(t){t&&this.R.push(t)}onreconnecting(t){t&&this.A.push(t)}onreconnected(t){t&&this.U.push(t)}I(t){if(this.G(),this.L||(t=this.ut(t),this.L=!0),t){const n=this.k.parseMessages(t,this.u);for(const t of n)switch(t.type){case R.Invocation:this.dt(t);break;case R.StreamItem:case R.Completion:{const n=this.H[t.invocationId];if(n){t.type===R.Completion&&delete this.H[t.invocationId];try{n(t)}catch(t){this.u.log(e.Error,`Stream callback threw error: ${P(t)}`)}}break}case R.Ping:break;case R.Close:{this.u.log(e.Information,"Close message received from server.");const n=t.error?new Error("Server returned an error on close: "+t.error):void 0;!0===t.allowReconnect?this.connection.stop(n):this.tt=this.et(n);break}default:this.u.log(e.Warning,`Invalid message type: ${t.type}.`)}}this.K()}ut(t){let n,s;try{[s,n]=this.T.parseHandshakeResponse(t)}catch(t){const n="Error parsing handshake response: "+t;this.u.log(e.Error,n);const s=new Error(n);throw this.J(s),s}if(n.error){const t="Server returned handshake error: "+n.error;this.u.log(e.Error,t);const s=new Error(t);throw this.J(s),s}return this.u.log(e.Debug,"Server handshake complete."),this.X(),s}Y(){this.connection.features.inherentKeepAlive||(this.C=(new Date).getTime()+this.keepAliveIntervalInMilliseconds,this.Z())}K(){if(!(this.connection.features&&this.connection.features.inherentKeepAlive||(this.ft=setTimeout((()=>this.serverTimeout()),this.serverTimeoutInMilliseconds),void 0!==this.wt))){let t=this.C-(new Date).getTime();t<0&&(t=0),this.wt=setTimeout((async()=>{if(this.M===A.Connected)try{await this.V(this.q)}catch{this.Z()}}),t)}}serverTimeout(){this.connection.stop(new Error("Server timeout elapsed without receiving a message from the server."))}async dt(t){const n=t.target.toLowerCase(),s=this.D[n];if(!s)return this.u.log(e.Warning,`No client method with the name '${n}' found.`),void(t.invocationId&&(this.u.log(e.Warning,`No result given for '${n}' method and invocation ID '${t.invocationId}'.`),await this.ht(this.gt(t.invocationId,"Client didn't provide a result.",null))));const i=s.slice(),r=!!t.invocationId;let o,h,c;for(const s of i)try{const i=o;o=await s.apply(this,t.arguments),r&&o&&i&&(this.u.log(e.Error,`Multiple results provided for '${n}'. Sending error to server.`),c=this.gt(t.invocationId,"Client provided multiple results.",null)),h=void 0}catch(t){h=t,this.u.log(e.Error,`A callback for the method '${n}' threw error '${t}'.`)}c?await this.ht(c):r?(h?c=this.gt(t.invocationId,`${h}`,null):void 0!==o?c=this.gt(t.invocationId,null,o):(this.u.log(e.Warning,`No result given for '${n}' method and invocation ID '${t.invocationId}'.`),c=this.gt(t.invocationId,"Client didn't provide a result.",null)),await this.ht(c)):o&&this.u.log(e.Error,`Result given for '${n}' method but server is not expecting a result.`)}_(t){this.u.log(e.Debug,`HubConnection.connectionClosed(${t}) called while in state ${this.M}.`),this.B=this.B||t||new r("The underlying connection was closed before the hub handshake could complete."),this.X&&this.X(),this.yt(t||new Error("Invocation canceled due to the underlying connection being closed.")),this.G(),this.Z(),this.M===A.Disconnecting?this.st(t):this.M===A.Connected&&this.P?this.bt(t):this.M===A.Connected&&this.st(t)}st(t){if(this.j){this.M=A.Disconnected,this.j=!1,g.isBrowser&&window.document.removeEventListener("freeze",this.S);try{this.R.forEach((e=>e.apply(this,[t])))}catch(n){this.u.log(e.Error,`An onclose callback called with error '${t}' threw error '${n}'.`)}}}async bt(t){const n=Date.now();let s=0,i=void 0!==t?t:new Error("Attempting to reconnect due to a unknown error."),r=this.vt(s++,0,i);if(null===r)return this.u.log(e.Debug,"Connection not reconnecting because the IRetryPolicy returned null on the first reconnect attempt."),void this.st(t);if(this.M=A.Reconnecting,t?this.u.log(e.Information,`Connection reconnecting because of error '${t}'.`):this.u.log(e.Information,"Connection reconnecting."),0!==this.A.length){try{this.A.forEach((e=>e.apply(this,[t])))}catch(n){this.u.log(e.Error,`An onreconnecting callback called with error '${t}' threw error '${n}'.`)}if(this.M!==A.Reconnecting)return void this.u.log(e.Debug,"Connection left the reconnecting state in onreconnecting callback. Done reconnecting.")}for(;null!==r;){if(this.u.log(e.Information,`Reconnect attempt number ${s} will start in ${r} ms.`),await new Promise((t=>{this.nt=setTimeout(t,r)})),this.nt=void 0,this.M!==A.Reconnecting)return void this.u.log(e.Debug,"Connection left the reconnecting state during reconnect delay. Done reconnecting.");try{if(await this.F(),this.M=A.Connected,this.u.log(e.Information,"HubConnection reconnected successfully."),0!==this.U.length)try{this.U.forEach((t=>t.apply(this,[this.connection.connectionId])))}catch(t){this.u.log(e.Error,`An onreconnected callback called with connectionId '${this.connection.connectionId}; threw error '${t}'.`)}return}catch(t){if(this.u.log(e.Information,`Reconnect attempt failed because of error '${t}'.`),this.M!==A.Reconnecting)return this.u.log(e.Debug,`Connection moved to the '${this.M}' from the reconnecting state during reconnect attempt. Done reconnecting.`),void(this.M===A.Disconnecting&&this.st());i=t instanceof Error?t:new Error(t.toString()),r=this.vt(s++,Date.now()-n,i)}}this.u.log(e.Information,`Reconnect retries have been exhausted after ${Date.now()-n} ms and ${s} failed attempts. Connection disconnecting.`),this.st()}vt(t,n,s){try{return this.P.nextRetryDelayInMilliseconds({elapsedMilliseconds:n,previousRetryCount:t,retryReason:s})}catch(s){return this.u.log(e.Error,`IRetryPolicy.nextRetryDelayInMilliseconds(${t}, ${n}) threw error '${s}'.`),null}}yt(t){const n=this.H;this.H={},Object.keys(n).forEach((s=>{const i=n[s];try{i(null,t)}catch(n){this.u.log(e.Error,`Stream 'error' callback called with '${t}' threw error: ${P(n)}`)}}))}Z(){this.wt&&(clearTimeout(this.wt),this.wt=void 0)}G(){this.ft&&clearTimeout(this.ft)}lt(t,e,n,s){if(n)return 0!==s.length?{arguments:e,streamIds:s,target:t,type:R.Invocation}:{arguments:e,target:t,type:R.Invocation};{const n=this.N;return this.N++,0!==s.length?{arguments:e,invocationId:n.toString(),streamIds:s,target:t,type:R.Invocation}:{arguments:e,invocationId:n.toString(),target:t,type:R.Invocation}}}ct(t,e){if(0!==t.length){e||(e=Promise.resolve());for(const n in t)t[n].subscribe({complete:()=>{e=e.then((()=>this.ht(this.gt(n))))},error:t=>{let s;s=t instanceof Error?t.message:t&&t.toString?t.toString():"Unknown error",e=e.then((()=>this.ht(this.gt(n,s))))},next:t=>{e=e.then((()=>this.ht(this.$t(n,t))))}})}}it(t){const e=[],n=[];for(let s=0;s<t.length;s++){const i=t[s];if(this.Et(i)){const r=this.N;this.N++,e[r]=i,n.push(r.toString()),t.splice(s,1)}}return[e,n]}Et(t){return t&&t.subscribe&&"function"==typeof t.subscribe}rt(t,e,n){const s=this.N;return this.N++,0!==n.length?{arguments:e,invocationId:s.toString(),streamIds:n,target:t,type:R.StreamInvocation}:{arguments:e,invocationId:s.toString(),target:t,type:R.StreamInvocation}}ot(t){return{invocationId:t,type:R.CancelInvocation}}$t(t,e){return{invocationId:t,item:e,type:R.StreamItem}}gt(t,e,n){return e?{error:e,invocationId:t,type:R.Completion}:{invocationId:t,result:n,type:R.Completion}}}const L=[0,2e3,1e4,3e4,null];class M{constructor(t){this.Ct=void 0!==t?[...t,null]:L}nextRetryDelayInMilliseconds(t){return this.Ct[t.previousRetryCount]}}class j{}var q,W;j.Authorization="Authorization",j.Cookie="Cookie",function(t){t[t.None=0]="None",t[t.WebSockets=1]="WebSockets",t[t.ServerSentEvents=2]="ServerSentEvents",t[t.LongPolling=4]="LongPolling"}(q||(q={})),function(t){t[t.Text=1]="Text",t[t.Binary=2]="Binary"}(W||(W={}));class O{constructor(){this.St=!1,this.onabort=null}abort(){this.St||(this.St=!0,this.onabort&&this.onabort())}get signal(){return this}get aborted(){return this.St}}class F{constructor(t,e,n,s){this.$=t,this.kt=e,this.u=n,this.Pt=new O,this.Tt=s,this.It=!1,this.onreceive=null,this.onclose=null}get pollAborted(){return this.Pt.aborted}async connect(t,n){if(w.isRequired(t,"url"),w.isRequired(n,"transferFormat"),w.isIn(n,W,"transferFormat"),this._t=t,this.u.log(e.Trace,"(LongPolling transport) Connecting."),n===W.Binary&&"undefined"!=typeof XMLHttpRequest&&"string"!=typeof(new XMLHttpRequest).responseType)throw new Error("Binary protocols over XmlHttpRequest not implementing advanced features are not supported.");const[i,r]=E(),o={[i]:r,...this.Tt.headers},h={abortSignal:this.Pt.signal,headers:o,timeout:1e5,withCredentials:this.Tt.withCredentials};n===W.Binary&&(h.responseType="arraybuffer"),await this.Ht(h);const c=`${t}&_=${Date.now()}`;this.u.log(e.Trace,`(LongPolling transport) polling: ${c}.`);const a=await this.$.get(c,h);200!==a.statusCode?(this.u.log(e.Error,`(LongPolling transport) Unexpected response code: ${a.statusCode}.`),this.Dt=new s(a.statusText||"",a.statusCode),this.It=!1):this.It=!0,this.xt=this.Rt(this._t,h)}async Ht(t){if(t.headers||(t.headers={}),this.kt){const e=await this.kt();e?t.headers[j.Authorization]=`Bearer ${e}`:t.headers[j.Authorization]&&delete t.headers[j.Authorization]}}async Rt(t,n){try{for(;this.It;){await this.Ht(n);try{const i=`${t}&_=${Date.now()}`;this.u.log(e.Trace,`(LongPolling transport) polling: ${i}.`);const r=await this.$.get(i,n);204===r.statusCode?(this.u.log(e.Information,"(LongPolling transport) Poll terminated by server."),this.It=!1):200!==r.statusCode?(this.u.log(e.Error,`(LongPolling transport) Unexpected response code: ${r.statusCode}.`),this.Dt=new s(r.statusText||"",r.statusCode),this.It=!1):r.content?(this.u.log(e.Trace,`(LongPolling transport) data received. ${y(r.content,this.Tt.logMessageContent)}.`),this.onreceive&&this.onreceive(r.content)):this.u.log(e.Trace,"(LongPolling transport) Poll timed out, reissuing.")}catch(t){this.It?t instanceof i?this.u.log(e.Trace,"(LongPolling transport) Poll timed out, reissuing."):(this.Dt=t,this.It=!1):this.u.log(e.Trace,`(LongPolling transport) Poll errored after shutdown: ${t.message}`)}}}finally{this.u.log(e.Trace,"(LongPolling transport) Polling complete."),this.pollAborted||this.At()}}async send(t){return this.It?b(this.u,"LongPolling",this.$,this._t,this.kt,t,this.Tt):Promise.reject(new Error("Cannot send until the transport is connected"))}async stop(){this.u.log(e.Trace,"(LongPolling transport) Stopping polling."),this.It=!1,this.Pt.abort();try{await this.xt,this.u.log(e.Trace,`(LongPolling transport) sending DELETE request to ${this._t}.`);const t={},[n,s]=E();t[n]=s;const i={headers:{...t,...this.Tt.headers},timeout:this.Tt.timeout,withCredentials:this.Tt.withCredentials};await this.Ht(i),await this.$.delete(this._t,i),this.u.log(e.Trace,"(LongPolling transport) DELETE request sent.")}finally{this.u.log(e.Trace,"(LongPolling transport) Stop finished."),this.At()}}At(){if(this.onclose){let t="(LongPolling transport) Firing onclose event.";this.Dt&&(t+=" Error: "+this.Dt),this.u.log(e.Trace,t),this.onclose(this.Dt)}}}class B{constructor(t,e,n,s){this.$=t,this.kt=e,this.u=n,this.Tt=s,this.onreceive=null,this.onclose=null}async connect(t,n){if(w.isRequired(t,"url"),w.isRequired(n,"transferFormat"),w.isIn(n,W,"transferFormat"),this.u.log(e.Trace,"(SSE transport) Connecting."),this._t=t,this.kt){const e=await this.kt();e&&(t+=(t.indexOf("?")<0?"?":"&")+`access_token=${encodeURIComponent(e)}`)}return new Promise(((s,i)=>{let r,o=!1;if(n===W.Text){if(g.isBrowser||g.isWebWorker)r=new this.Tt.EventSource(t,{withCredentials:this.Tt.withCredentials});else{const e=this.$.getCookieString(t),n={};n.Cookie=e;const[s,i]=E();n[s]=i,r=new this.Tt.EventSource(t,{withCredentials:this.Tt.withCredentials,headers:{...n,...this.Tt.headers}})}try{r.onmessage=t=>{if(this.onreceive)try{this.u.log(e.Trace,`(SSE transport) data received. ${y(t.data,this.Tt.logMessageContent)}.`),this.onreceive(t.data)}catch(t){return void this.Ut(t)}},r.onerror=t=>{o?this.Ut():i(new Error("EventSource failed to connect. The connection could not be found on the server, either the connection ID is not present on the server, or a proxy is refusing/buffering the connection. If you have multiple servers check that sticky sessions are enabled."))},r.onopen=()=>{this.u.log(e.Information,`SSE connected to ${this._t}`),this.Nt=r,o=!0,s()}}catch(t){return void i(t)}}else i(new Error("The Server-Sent Events transport only supports the 'Text' transfer format"))}))}async send(t){return this.Nt?b(this.u,"SSE",this.$,this._t,this.kt,t,this.Tt):Promise.reject(new Error("Cannot send until the transport is connected"))}stop(){return this.Ut(),Promise.resolve()}Ut(t){this.Nt&&(this.Nt.close(),this.Nt=void 0,this.onclose&&this.onclose(t))}}class X{constructor(t,e,n,s,i,r){this.u=n,this.kt=e,this.Lt=s,this.Mt=i,this.$=t,this.onreceive=null,this.onclose=null,this.jt=r}async connect(t,n){let s;return w.isRequired(t,"url"),w.isRequired(n,"transferFormat"),w.isIn(n,W,"transferFormat"),this.u.log(e.Trace,"(WebSockets transport) Connecting."),this.kt&&(s=await this.kt()),new Promise(((i,r)=>{let o;t=t.replace(/^http/,"ws");const h=this.$.getCookieString(t);let c=!1;if(g.isNode||g.isReactNative){const e={},[n,i]=E();e[n]=i,s&&(e[j.Authorization]=`Bearer ${s}`),h&&(e[j.Cookie]=h),o=new this.Mt(t,void 0,{headers:{...e,...this.jt}})}else s&&(t+=(t.indexOf("?")<0?"?":"&")+`access_token=${encodeURIComponent(s)}`);o||(o=new this.Mt(t)),n===W.Binary&&(o.binaryType="arraybuffer"),o.onopen=n=>{this.u.log(e.Information,`WebSocket connected to ${t}.`),this.qt=o,c=!0,i()},o.onerror=t=>{let n=null;n="undefined"!=typeof ErrorEvent&&t instanceof ErrorEvent?t.error:"There was an error with the transport",this.u.log(e.Information,`(WebSockets transport) ${n}.`)},o.onmessage=t=>{if(this.u.log(e.Trace,`(WebSockets transport) data received. ${y(t.data,this.Lt)}.`),this.onreceive)try{this.onreceive(t.data)}catch(t){return void this.Ut(t)}},o.onclose=t=>{if(c)this.Ut(t);else{let e=null;e="undefined"!=typeof ErrorEvent&&t instanceof ErrorEvent?t.error:"WebSocket failed to connect. The connection could not be found on the server, either the endpoint may not be a SignalR endpoint, the connection ID is not present on the server, or there is a proxy blocking WebSockets. If you have multiple servers check that sticky sessions are enabled.",r(new Error(e))}}}))}send(t){return this.qt&&this.qt.readyState===this.Mt.OPEN?(this.u.log(e.Trace,`(WebSockets transport) sending data. ${y(t,this.Lt)}.`),this.qt.send(t),Promise.resolve()):Promise.reject("WebSocket is not in the OPEN state")}stop(){return this.qt&&this.Ut(void 0),Promise.resolve()}Ut(t){this.qt&&(this.qt.onclose=()=>{},this.qt.onmessage=()=>{},this.qt.onerror=()=>{},this.qt.close(),this.qt=void 0),this.u.log(e.Trace,"(WebSockets transport) socket closed."),this.onclose&&(!this.Wt(t)||!1!==t.wasClean&&1e3===t.code?t instanceof Error?this.onclose(t):this.onclose():this.onclose(new Error(`WebSocket closed with status code: ${t.code} (${t.reason||"no reason given"}).`)))}Wt(t){return t&&"boolean"==typeof t.wasClean&&"number"==typeof t.code}}class J{constructor(t,n={}){var s;if(this.Ot=()=>{},this.features={},this.Ft=1,w.isRequired(t,"url"),this.u=void 0===(s=n.logger)?new $(e.Information):null===s?f.instance:void 0!==s.log?s:new $(s),this.baseUrl=this.Bt(t),(n=n||{}).logMessageContent=void 0!==n.logMessageContent&&n.logMessageContent,"boolean"!=typeof n.withCredentials&&void 0!==n.withCredentials)throw new Error("withCredentials option was not a 'boolean' or 'undefined' value");n.withCredentials=void 0===n.withCredentials||n.withCredentials,n.timeout=void 0===n.timeout?1e5:n.timeout;let i=null,r=null;if(g.isNode){const t=require;i=t("ws"),r=t("eventsource")}g.isNode||"undefined"==typeof WebSocket||n.WebSocket?g.isNode&&!n.WebSocket&&i&&(n.WebSocket=i):n.WebSocket=WebSocket,g.isNode||"undefined"==typeof EventSource||n.EventSource?g.isNode&&!n.EventSource&&void 0!==r&&(n.EventSource=r):n.EventSource=EventSource,this.$=n.httpClient||new H(this.u),this.M="Disconnected",this.j=!1,this.Tt=n,this.onreceive=null,this.onclose=null}async start(t){if(t=t||W.Binary,w.isIn(t,W,"transferFormat"),this.u.log(e.Debug,`Starting connection with transfer format '${W[t]}'.`),"Disconnected"!==this.M)return Promise.reject(new Error("Cannot start an HttpConnection that is not in the 'Disconnected' state."));if(this.M="Connecting",this.Xt=this.F(t),await this.Xt,"Disconnecting"===this.M){const t="Failed to start the HttpConnection before stop() was called.";return this.u.log(e.Error,t),await this.tt,Promise.reject(new r(t))}if("Connected"!==this.M){const t="HttpConnection.startInternal completed gracefully but didn't enter the connection into the connected state!";return this.u.log(e.Error,t),Promise.reject(new r(t))}this.j=!0}send(t){return"Connected"!==this.M?Promise.reject(new Error("Cannot send data if the connection is not in the 'Connected' State.")):(this.Jt||(this.Jt=new z(this.transport)),this.Jt.send(t))}async stop(t){return"Disconnected"===this.M?(this.u.log(e.Debug,`Call to HttpConnection.stop(${t}) ignored because the connection is already in the disconnected state.`),Promise.resolve()):"Disconnecting"===this.M?(this.u.log(e.Debug,`Call to HttpConnection.stop(${t}) ignored because the connection is already in the disconnecting state.`),this.tt):(this.M="Disconnecting",this.tt=new Promise((t=>{this.Ot=t})),await this.et(t),void await this.tt)}async et(t){this.zt=t;try{await this.Xt}catch(t){}if(this.transport){try{await this.transport.stop()}catch(t){this.u.log(e.Error,`HttpConnection.transport.stop() threw error '${t}'.`),this.Vt()}this.transport=void 0}else this.u.log(e.Debug,"HttpConnection.transport is undefined in HttpConnection.stop() because start() failed.")}async F(t){let n=this.baseUrl;this.kt=this.Tt.accessTokenFactory;try{if(this.Tt.skipNegotiation){if(this.Tt.transport!==q.WebSockets)throw new Error("Negotiation can only be skipped when using the WebSocket transport directly.");this.transport=this.Gt(q.WebSockets),await this.Kt(n,t)}else{let e=null,s=0;do{if(e=await this.Qt(n),"Disconnecting"===this.M||"Disconnected"===this.M)throw new r("The connection was stopped during negotiation.");if(e.error)throw new Error(e.error);if(e.ProtocolVersion)throw new Error("Detected a connection attempt to an ASP.NET SignalR Server. This client only supports connecting to an ASP.NET Core SignalR Server. See https://aka.ms/signalr-core-differences for details.");if(e.url&&(n=e.url),e.accessToken){const t=e.accessToken;this.kt=()=>t}s++}while(e.url&&s<100);if(100===s&&e.url)throw new Error("Negotiate redirection limit exceeded.");await this.Yt(n,this.Tt.transport,e,t)}this.transport instanceof F&&(this.features.inherentKeepAlive=!0),"Connecting"===this.M&&(this.u.log(e.Debug,"The HttpConnection connected successfully."),this.M="Connected")}catch(t){return this.u.log(e.Error,"Failed to start the connection: "+t),this.M="Disconnected",this.transport=void 0,this.Ot(),Promise.reject(t)}}async Qt(t){const n={};if(this.kt){const t=await this.kt();t&&(n[j.Authorization]=`Bearer ${t}`)}const[i,r]=E();n[i]=r;const o=this.Zt(t);this.u.log(e.Debug,`Sending negotiation request: ${o}.`);try{const t=await this.$.post(o,{content:"",headers:{...n,...this.Tt.headers},timeout:this.Tt.timeout,withCredentials:this.Tt.withCredentials});if(200!==t.statusCode)return Promise.reject(new Error(`Unexpected status code returned from negotiate '${t.statusCode}'`));const e=JSON.parse(t.content);return(!e.negotiateVersion||e.negotiateVersion<1)&&(e.connectionToken=e.connectionId),e}catch(t){let n="Failed to complete negotiation with the server: "+t;return t instanceof s&&404===t.statusCode&&(n+=" Either this is not a SignalR endpoint or there is a proxy blocking the connection."),this.u.log(e.Error,n),Promise.reject(new a(n))}}te(t,e){return e?t+(-1===t.indexOf("?")?"?":"&")+`id=${e}`:t}async Yt(t,n,s,i){let o=this.te(t,s.connectionToken);if(this.ee(n))return this.u.log(e.Debug,"Connection was provided an instance of ITransport, using that directly."),this.transport=n,await this.Kt(o,i),void(this.connectionId=s.connectionId);const h=[],a=s.availableTransports||[];let u=s;for(const s of a){const a=this.ne(s,n,i);if(a instanceof Error)h.push(`${s.transport} failed:`),h.push(a);else if(this.ee(a)){if(this.transport=a,!u){try{u=await this.Qt(t)}catch(t){return Promise.reject(t)}o=this.te(t,u.connectionToken)}try{return await this.Kt(o,i),void(this.connectionId=u.connectionId)}catch(t){if(this.u.log(e.Error,`Failed to start the transport '${s.transport}': ${t}`),u=void 0,h.push(new c(`${s.transport} failed: ${t}`,q[s.transport])),"Connecting"!==this.M){const t="Failed to select transport before stop() was called.";return this.u.log(e.Debug,t),Promise.reject(new r(t))}}}}return h.length>0?Promise.reject(new l(`Unable to connect to the server with any of the available transports. ${h.join(" ")}`,h)):Promise.reject(new Error("None of the transports supported by the client are supported by the server."))}Gt(t){switch(t){case q.WebSockets:if(!this.Tt.WebSocket)throw new Error("'WebSocket' is not supported in your environment.");return new X(this.$,this.kt,this.u,this.Tt.logMessageContent,this.Tt.WebSocket,this.Tt.headers||{});case q.ServerSentEvents:if(!this.Tt.EventSource)throw new Error("'EventSource' is not supported in your environment.");return new B(this.$,this.kt,this.u,this.Tt);case q.LongPolling:return new F(this.$,this.kt,this.u,this.Tt);default:throw new Error(`Unknown transport: ${t}.`)}}Kt(t,e){return this.transport.onreceive=this.onreceive,this.transport.onclose=t=>this.Vt(t),this.transport.connect(t,e)}ne(t,n,s){const i=q[t.transport];if(null==i)return this.u.log(e.Debug,`Skipping transport '${t.transport}' because it is not supported by this client.`),new Error(`Skipping transport '${t.transport}' because it is not supported by this client.`);if(!function(t,e){return!t||0!=(e&t)}(n,i))return this.u.log(e.Debug,`Skipping transport '${q[i]}' because it was disabled by the client.`),new h(`'${q[i]}' is disabled by the client.`,i);if(!(t.transferFormats.map((t=>W[t])).indexOf(s)>=0))return this.u.log(e.Debug,`Skipping transport '${q[i]}' because it does not support the requested transfer format '${W[s]}'.`),new Error(`'${q[i]}' does not support ${W[s]}.`);if(i===q.WebSockets&&!this.Tt.WebSocket||i===q.ServerSentEvents&&!this.Tt.EventSource)return this.u.log(e.Debug,`Skipping transport '${q[i]}' because it is not supported in your environment.'`),new o(`'${q[i]}' is not supported in your environment.`,i);this.u.log(e.Debug,`Selecting transport '${q[i]}'.`);try{return this.Gt(i)}catch(t){return t}}ee(t){return t&&"object"==typeof t&&"connect"in t}Vt(t){if(this.u.log(e.Debug,`HttpConnection.stopConnection(${t}) called while in state ${this.M}.`),this.transport=void 0,t=this.zt||t,this.zt=void 0,"Disconnected"!==this.M){if("Connecting"===this.M)throw this.u.log(e.Warning,`Call to HttpConnection.stopConnection(${t}) was ignored because the connection is still in the connecting state.`),new Error(`HttpConnection.stopConnection(${t}) was called while the connection is still in the connecting state.`);if("Disconnecting"===this.M&&this.Ot(),t?this.u.log(e.Error,`Connection disconnected with error '${t}'.`):this.u.log(e.Information,"Connection disconnected."),this.Jt&&(this.Jt.stop().catch((t=>{this.u.log(e.Error,`TransportSendQueue.stop() threw error '${t}'.`)})),this.Jt=void 0),this.connectionId=void 0,this.M="Disconnected",this.j){this.j=!1;try{this.onclose&&this.onclose(t)}catch(n){this.u.log(e.Error,`HttpConnection.onclose(${t}) threw error '${n}'.`)}}}else this.u.log(e.Debug,`Call to HttpConnection.stopConnection(${t}) was ignored because the connection is already in the disconnected state.`)}Bt(t){if(0===t.lastIndexOf("https://",0)||0===t.lastIndexOf("http://",0))return t;if(!g.isBrowser)throw new Error(`Cannot resolve '${t}'.`);const n=window.document.createElement("a");return n.href=t,this.u.log(e.Information,`Normalizing '${t}' to '${n.href}'.`),n.href}Zt(t){const e=t.indexOf("?");let n=t.substring(0,-1===e?t.length:e);return"/"!==n[n.length-1]&&(n+="/"),n+="negotiate",n+=-1===e?"":t.substring(e),-1===n.indexOf("negotiateVersion")&&(n+=-1===e?"?":"&",n+="negotiateVersion="+this.Ft),n}}class z{constructor(t){this.se=t,this.ie=[],this.re=!0,this.oe=new V,this.he=new V,this.ce=this.ae()}send(t){return this.le(t),this.he||(this.he=new V),this.he.promise}stop(){return this.re=!1,this.oe.resolve(),this.ce}le(t){if(this.ie.length&&typeof this.ie[0]!=typeof t)throw new Error(`Expected data to be of type ${typeof this.ie} but was of type ${typeof t}`);this.ie.push(t),this.oe.resolve()}async ae(){for(;;){if(await this.oe.promise,!this.re){this.he&&this.he.reject("Connection stopped.");break}this.oe=new V;const t=this.he;this.he=void 0;const e="string"==typeof this.ie[0]?this.ie.join(""):z.ue(this.ie);this.ie.length=0;try{await this.se.send(e),t.resolve()}catch(e){t.reject(e)}}}static ue(t){const e=t.map((t=>t.byteLength)).reduce(((t,e)=>t+e)),n=new Uint8Array(e);let s=0;for(const e of t)n.set(new Uint8Array(e),s),s+=e.byteLength;return n.buffer}}class V{constructor(){this.promise=new Promise(((t,e)=>[this.de,this.fe]=[t,e]))}resolve(){this.de()}reject(t){this.fe(t)}}class G{constructor(){this.name="json",this.version=1,this.transferFormat=W.Text}parseMessages(t,n){if("string"!=typeof t)throw new Error("Invalid input for JSON hub protocol. Expected a string.");if(!t)return[];null===n&&(n=f.instance);const s=D.parse(t),i=[];for(const t of s){const s=JSON.parse(t);if("number"!=typeof s.type)throw new Error("Invalid payload.");switch(s.type){case R.Invocation:this.pe(s);break;case R.StreamItem:this.we(s);break;case R.Completion:this.ge(s);break;case R.Ping:case R.Close:break;default:n.log(e.Information,"Unknown message type '"+s.type+"' ignored.");continue}i.push(s)}return i}writeMessage(t){return D.write(JSON.stringify(t))}pe(t){this.ye(t.target,"Invalid payload for Invocation message."),void 0!==t.invocationId&&this.ye(t.invocationId,"Invalid payload for Invocation message.")}we(t){if(this.ye(t.invocationId,"Invalid payload for StreamItem message."),void 0===t.item)throw new Error("Invalid payload for StreamItem message.")}ge(t){if(t.result&&t.error)throw new Error("Invalid payload for Completion message.");!t.result&&t.error&&this.ye(t.error,"Invalid payload for Completion message."),this.ye(t.invocationId,"Invalid payload for Completion message.")}ye(t,e){if("string"!=typeof t||""===t)throw new Error(e)}}const K={trace:e.Trace,debug:e.Debug,info:e.Information,information:e.Information,warn:e.Warning,warning:e.Warning,error:e.Error,critical:e.Critical,none:e.None};class Q{configureLogging(t){if(w.isRequired(t,"logging"),void 0!==t.log)this.logger=t;else if("string"==typeof t){const e=function(t){const e=K[t.toLowerCase()];if(void 0!==e)return e;throw new Error(`Unknown log level: ${t}`)}(t);this.logger=new $(e)}else this.logger=new $(t);return this}withUrl(t,e){return w.isRequired(t,"url"),w.isNotEmpty(t,"url"),this.url=t,this.httpConnectionOptions="object"==typeof e?{...this.httpConnectionOptions,...e}:{...this.httpConnectionOptions,transport:e},this}withHubProtocol(t){return w.isRequired(t,"protocol"),this.protocol=t,this}withAutomaticReconnect(t){if(this.reconnectPolicy)throw new Error("A reconnectPolicy has already been set.");return t?Array.isArray(t)?this.reconnectPolicy=new M(t):this.reconnectPolicy=t:this.reconnectPolicy=new M,this}build(){const t=this.httpConnectionOptions||{};if(void 0===t.logger&&(t.logger=this.logger),!this.url)throw new Error("The 'HubConnectionBuilder.withUrl' method must be called before building the connection.");const e=new J(this.url,t);return N.create(e,this.logger||f.instance,this.protocol||new G,this.reconnectPolicy)}}return Uint8Array.prototype.indexOf||Object.defineProperty(Uint8Array.prototype,"indexOf",{value:Array.prototype.indexOf,writable:!0}),Uint8Array.prototype.slice||Object.defineProperty(Uint8Array.prototype,"slice",{value:function(t,e){return new Uint8Array(Array.prototype.slice.call(this,t,e))},writable:!0}),Uint8Array.prototype.forEach||Object.defineProperty(Uint8Array.prototype,"forEach",{value:Array.prototype.forEach,writable:!0}),n})()},"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.signalR=e():t.signalR=e();
//# sourceMappingURL=signalr.min.js.map
{
"name": "@microsoft/signalr",
"version": "7.0.0-preview.4.22251.1",
"version": "7.0.0-preview.5.22303.8",
"description": "ASP.NET Core SignalR Client",

@@ -5,0 +5,0 @@ "main": "./dist/cjs/index.js",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc