Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@microsoft/signalr

Package Overview
Dependencies
Maintainers
5
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 8.0.0-preview.7.23375.9 to 8.0.0-rc.1.23421.29

2

dist/browser/signalr.min.js

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

var t,e;t=self,e=()=>(()=>{var t={d:(e,s)=>{for(var n in s)t.o(s,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:s[n]})}};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,s={};t.r(s),t.d(s,{AbortError:()=>r,DefaultHttpClient:()=>H,HttpClient:()=>d,HttpError:()=>n,HttpResponse:()=>u,HttpTransportType:()=>q,HubConnection:()=>L,HubConnectionBuilder:()=>Y,HubConnectionState:()=>A,JsonHubProtocol:()=>G,LogLevel:()=>e,MessageType:()=>R,NullLogger:()=>p,Subject:()=>U,TimeoutError:()=>i,TransferFormat:()=>O,VERSION:()=>f});class n extends Error{constructor(t,e){const s=new.target.prototype;super(`${t}: Status code '${e}'`),this.statusCode=e,this.__proto__=s}}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 s=new.target.prototype;super(t),this.transport=e,this.errorType="UnsupportedTransportError",this.__proto__=s}}class h extends Error{constructor(t,e){const s=new.target.prototype;super(t),this.transport=e,this.errorType="DisabledTransportError",this.__proto__=s}}class c extends Error{constructor(t,e){const s=new.target.prototype;super(t),this.transport=e,this.errorType="FailedToStartTransportError",this.__proto__=s}}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 s=new.target.prototype;super(t),this.innerErrors=e,this.__proto__=s}}class u{constructor(t,e,s){this.statusCode=t,this.statusText=e,this.content=s}}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 p{constructor(){}log(t,e){}}p.instance=new p;const f="8.0.0-preview.7.23375.9";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,s){if(!(t in e))throw new Error(`Unknown ${s} value: ${t}.`)}}class g{static get isBrowser(){return!g.isNode&&"object"==typeof window&&"object"==typeof window.document}static get isWebWorker(){return!g.isNode&&"object"==typeof self&&"importScripts"in self}static get isReactNative(){return!g.isNode&&"object"==typeof window&&void 0===window.document}static get isNode(){return"undefined"!=typeof process&&process.release&&"node"===process.release.name}}function m(t,e){let s="";return y(t)?(s=`Binary data of length ${t.byteLength}`,e&&(s+=`. Content: '${function(t){const e=new Uint8Array(t);let s="";return e.forEach((t=>{s+=`0x${t<16?"0":""}${t.toString(16)} `})),s.substr(0,s.length-1)}(t)}'`)):"string"==typeof t&&(s=`String data of length ${t.length}`,e&&(s+=`. Content: '${t}'`)),s}function y(t){return t&&"undefined"!=typeof ArrayBuffer&&(t instanceof ArrayBuffer||t.constructor&&"ArrayBuffer"===t.constructor.name)}async function b(t,s,n,i,r,o){const h={},[c,a]=$();h[c]=a,t.log(e.Trace,`(${s} transport) sending data. ${m(r,o.logMessageContent)}.`);const l=y(r)?"arraybuffer":"text",u=await n.post(i,{content:r,headers:{...h,...o.headers},responseType:l,timeout:o.timeout,withCredentials:o.withCredentials});t.log(e.Trace,`(${s} transport) request complete. Response status: ${u.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 E{constructor(t){this.l=t,this.out=console}log(t,s){if(t>=this.l){const n=`[${(new Date).toISOString()}] ${e[t]}: ${s}`;switch(t){case e.Critical:case e.Error:this.out.error(n);break;case e.Warning:this.out.warn(n);break;case e.Information:this.out.info(n);break;default:this.out.log(n)}}}}function $(){let t="X-SignalR-User-Agent";return g.isNode&&(t="User-Agent"),[t,C(f,S(),g.isNode?"NodeJS":"Browser",k())]}function C(t,e,s,n){let i="Microsoft SignalR/";const r=t.split(".");return i+=`${r[0]}.${r[1]}`,i+=` (${t}; `,i+=e&&""!==e?`${e}; `:"Unknown OS; ",i+=`${s}`,i+=n?`; ${n}`:"; 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){super(),this.u=e,this.p=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")}()),this.m=AbortController,this.m}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 s=new this.m;let o;t.abortSignal&&(t.abortSignal.onabort=()=>{s.abort(),o=new r});let h,c=null;if(t.timeout){const n=t.timeout;c=setTimeout((()=>{s.abort(),this.u.log(e.Warning,"Timeout from HTTP request."),o=new i}),n)}""===t.content&&(t.content=void 0),t.content&&(t.headers=t.headers||{},y(t.content)?t.headers["Content-Type"]="application/octet-stream":t.headers["Content-Type"]="text/plain;charset=UTF-8");try{h=await this.p(t.url,{body:t.content,cache:"no-cache",credentials:!0===t.withCredentials?"include":"same-origin",headers:{"X-Requested-With":"XMLHttpRequest",...t.headers},method:t.method,mode:"cors",redirect:"follow",signal:s.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 n(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.v&&this.v.getCookies(t,((t,s)=>e=s.join("; "))),e}}function I(t,e){let s;switch(e){case"arraybuffer":s=t.arrayBuffer();break;case"text":default:s=t.text();break;case"blob":case"document":case"json":throw new Error(`${e} is not supported.`)}return s}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(((s,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"),""===t.content&&(t.content=void 0),t.content&&(y(t.content)?h.setRequestHeader("Content-Type","application/octet-stream"):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?s(new u(h.status,h.statusText,h.response||h.responseText)):o(new n(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 n(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,s;if(y(t)){const n=new Uint8Array(t),i=n.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(n.slice(0,r))),s=n.byteLength>r?n.slice(r).buffer:null}else{const n=t,i=n.indexOf(D.RecordSeparator);if(-1===i)throw new Error("Message is incomplete.");const r=i+1;e=n.substring(0,r),s=n.length>r?n.substring(r):null}const n=D.parse(e),i=JSON.parse(n[0]);if(i.type)throw new Error("Expected a handshake response from the server.");return[s,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 L{static create(t,e,s,n,i,r){return new L(t,e,s,n,i,r)}constructor(t,s,n,i,r,o){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://learn.microsoft.com/aspnet/core/signalr/javascript-client#bsleep")},w.isRequired(t,"connection"),w.isRequired(s,"logger"),w.isRequired(n,"protocol"),this.serverTimeoutInMilliseconds=null!=r?r:3e4,this.keepAliveIntervalInMilliseconds=null!=o?o:15e3,this.u=s,this.k=n,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.L=0,this.N=!1,this.M=A.Disconnected,this.j=!1,this.W=this.k.writeMessage({type:R.Ping})}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.q=this.O(),this.q}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.N=!1;const t=new Promise(((t,e)=>{this.X=t,this.J=e}));await this.connection.start(this.k.transferFormat);try{const s={protocol:this.k.name,version:this.k.version};if(this.u.log(e.Debug,"Sending handshake request."),await this.V(this.T.writeHandshakeRequest(s)),this.u.log(e.Information,`Using HubProtocol '${this.k.name}'.`),this.K(),this.G(),this.Y(),await t,this.B)throw this.B;this.connection.features.inherentKeepAlive||await this.V(this.W)}catch(t){throw this.u.log(e.Debug,`Hub handshake failed with error '${t}' during start(). Stopping HubConnection.`),this.K(),this.Z(),await this.connection.stop(t),t}}async stop(){const t=this.q;this.tt=this.et(),await this.tt;try{await t}catch(t){}}et(t){if(this.M===A.Disconnected)return this.u.log(e.Debug,`Call to HubConnection.stop(${t}) ignored because it is already in the disconnected state.`),Promise.resolve();if(this.M===A.Disconnecting)return this.u.log(e.Debug,`Call to HttpConnection.stop(${t}) ignored because the connection is already in the disconnecting state.`),this.tt;const s=this.M;return this.M=A.Disconnecting,this.u.log(e.Debug,"Stopping HubConnection."),this.st?(this.u.log(e.Debug,"Connection stopped during reconnect delay. Done reconnecting."),clearTimeout(this.st),this.st=void 0,this.nt(),Promise.resolve()):(s===A.Connected&&this.it(),this.K(),this.Z(),this.B=t||new r("The connection was stopped before the hub handshake could complete."),this.connection.stop(t))}async it(){try{await this.rt(this.ot())}catch{}}stream(t,...e){const[s,n]=this.ht(e),i=this.ct(t,e,n);let r;const o=new U;return o.cancelCallback=()=>{const t=this.lt(i.invocationId);return delete this.H[i.invocationId],r.then((()=>this.rt(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.rt(i).catch((t=>{o.error(t),delete this.H[i.invocationId]})),this.ut(s,r),o}V(t){return this.Y(),this.connection.send(t)}rt(t){return this.V(this.k.writeMessage(t))}send(t,...e){const[s,n]=this.ht(e),i=this.rt(this.dt(t,e,!0,n));return this.ut(s,i),i}invoke(t,...e){const[s,n]=this.ht(e),i=this.dt(t,e,!1,n);return new Promise(((t,e)=>{this.H[i.invocationId]=(s,n)=>{n?e(n):s&&(s.type===R.Completion?s.error?e(new Error(s.error)):t(s.result):e(new Error(`Unexpected message type: ${s.type}`)))};const n=this.rt(i).catch((t=>{e(t),delete this.H[i.invocationId]}));this.ut(s,n)}))}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 s=this.D[t];if(s)if(e){const n=s.indexOf(e);-1!==n&&(s.splice(n,1),0===s.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.K(),this.N||(t=this.ft(t),this.N=!0),t){const s=this.k.parseMessages(t,this.u);for(const t of s)switch(t.type){case R.Invocation:this.wt(t);break;case R.StreamItem:case R.Completion:{const s=this.H[t.invocationId];if(s){t.type===R.Completion&&delete this.H[t.invocationId];try{s(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 s=t.error?new Error("Server returned an error on close: "+t.error):void 0;!0===t.allowReconnect?this.connection.stop(s):this.tt=this.et(s);break}default:this.u.log(e.Warning,`Invalid message type: ${t.type}.`)}}this.G()}ft(t){let s,n;try{[n,s]=this.T.parseHandshakeResponse(t)}catch(t){const s="Error parsing handshake response: "+t;this.u.log(e.Error,s);const n=new Error(s);throw this.J(n),n}if(s.error){const t="Server returned handshake error: "+s.error;this.u.log(e.Error,t);const n=new Error(t);throw this.J(n),n}return this.u.log(e.Debug,"Server handshake complete."),this.X(),n}Y(){this.connection.features.inherentKeepAlive||(this.C=(new Date).getTime()+this.keepAliveIntervalInMilliseconds,this.Z())}G(){if(!(this.connection.features&&this.connection.features.inherentKeepAlive||(this.gt=setTimeout((()=>this.serverTimeout()),this.serverTimeoutInMilliseconds),void 0!==this.yt))){let t=this.C-(new Date).getTime();t<0&&(t=0),this.yt=setTimeout((async()=>{if(this.M===A.Connected)try{await this.V(this.W)}catch{this.Z()}}),t)}}serverTimeout(){this.connection.stop(new Error("Server timeout elapsed without receiving a message from the server."))}async wt(t){const s=t.target.toLowerCase(),n=this.D[s];if(!n)return this.u.log(e.Warning,`No client method with the name '${s}' found.`),void(t.invocationId&&(this.u.log(e.Warning,`No result given for '${s}' method and invocation ID '${t.invocationId}'.`),await this.rt(this.bt(t.invocationId,"Client didn't provide a result.",null))));const i=n.slice(),r=!!t.invocationId;let o,h,c;for(const n of i)try{const i=o;o=await n.apply(this,t.arguments),r&&o&&i&&(this.u.log(e.Error,`Multiple results provided for '${s}'. Sending error to server.`),c=this.bt(t.invocationId,"Client provided multiple results.",null)),h=void 0}catch(t){h=t,this.u.log(e.Error,`A callback for the method '${s}' threw error '${t}'.`)}c?await this.rt(c):r?(h?c=this.bt(t.invocationId,`${h}`,null):void 0!==o?c=this.bt(t.invocationId,null,o):(this.u.log(e.Warning,`No result given for '${s}' method and invocation ID '${t.invocationId}'.`),c=this.bt(t.invocationId,"Client didn't provide a result.",null)),await this.rt(c)):o&&this.u.log(e.Error,`Result given for '${s}' 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.vt(t||new Error("Invocation canceled due to the underlying connection being closed.")),this.K(),this.Z(),this.M===A.Disconnecting?this.nt(t):this.M===A.Connected&&this.P?this.Et(t):this.M===A.Connected&&this.nt(t)}nt(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(s){this.u.log(e.Error,`An onclose callback called with error '${t}' threw error '${s}'.`)}}}async Et(t){const s=Date.now();let n=0,i=void 0!==t?t:new Error("Attempting to reconnect due to a unknown error."),r=this.$t(n++,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.nt(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(s){this.u.log(e.Error,`An onreconnecting callback called with error '${t}' threw error '${s}'.`)}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 ${n} will start in ${r} ms.`),await new Promise((t=>{this.st=setTimeout(t,r)})),this.st=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.nt());i=t instanceof Error?t:new Error(t.toString()),r=this.$t(n++,Date.now()-s,i)}}this.u.log(e.Information,`Reconnect retries have been exhausted after ${Date.now()-s} ms and ${n} failed attempts. Connection disconnecting.`),this.nt()}$t(t,s,n){try{return this.P.nextRetryDelayInMilliseconds({elapsedMilliseconds:s,previousRetryCount:t,retryReason:n})}catch(n){return this.u.log(e.Error,`IRetryPolicy.nextRetryDelayInMilliseconds(${t}, ${s}) threw error '${n}'.`),null}}vt(t){const s=this.H;this.H={},Object.keys(s).forEach((n=>{const i=s[n];try{i(null,t)}catch(s){this.u.log(e.Error,`Stream 'error' callback called with '${t}' threw error: ${P(s)}`)}}))}Z(){this.yt&&(clearTimeout(this.yt),this.yt=void 0)}K(){this.gt&&clearTimeout(this.gt)}dt(t,e,s,n){if(s)return 0!==n.length?{arguments:e,streamIds:n,target:t,type:R.Invocation}:{arguments:e,target:t,type:R.Invocation};{const s=this.L;return this.L++,0!==n.length?{arguments:e,invocationId:s.toString(),streamIds:n,target:t,type:R.Invocation}:{arguments:e,invocationId:s.toString(),target:t,type:R.Invocation}}}ut(t,e){if(0!==t.length){e||(e=Promise.resolve());for(const s in t)t[s].subscribe({complete:()=>{e=e.then((()=>this.rt(this.bt(s))))},error:t=>{let n;n=t instanceof Error?t.message:t&&t.toString?t.toString():"Unknown error",e=e.then((()=>this.rt(this.bt(s,n))))},next:t=>{e=e.then((()=>this.rt(this.Ct(s,t))))}})}}ht(t){const e=[],s=[];for(let n=0;n<t.length;n++){const i=t[n];if(this.St(i)){const r=this.L;this.L++,e[r]=i,s.push(r.toString()),t.splice(n,1)}}return[e,s]}St(t){return t&&t.subscribe&&"function"==typeof t.subscribe}ct(t,e,s){const n=this.L;return this.L++,0!==s.length?{arguments:e,invocationId:n.toString(),streamIds:s,target:t,type:R.StreamInvocation}:{arguments:e,invocationId:n.toString(),target:t,type:R.StreamInvocation}}lt(t){return{invocationId:t,type:R.CancelInvocation}}Ct(t,e){return{invocationId:t,item:e,type:R.StreamItem}}bt(t,e,s){return e?{error:e,invocationId:t,type:R.Completion}:{invocationId:t,result:s,type:R.Completion}}ot(){return{type:R.Close}}}const N=[0,2e3,1e4,3e4,null];class M{constructor(t){this.kt=void 0!==t?[...t,null]:N}nextRetryDelayInMilliseconds(t){return this.kt[t.previousRetryCount]}}class j{}j.Authorization="Authorization",j.Cookie="Cookie";class W extends d{constructor(t,e){super(),this.Pt=t,this.Tt=e}async send(t){let e=!0;this.Tt&&(!this.It||t.url&&t.url.indexOf("/negotiate?")>0)&&(e=!1,this.It=await this.Tt()),this._t(t);const s=await this.Pt.send(t);return e&&401===s.statusCode&&this.Tt?(this.It=await this.Tt(),this._t(t),await this.Pt.send(t)):s}_t(t){t.headers||(t.headers={}),this.It?t.headers[j.Authorization]=`Bearer ${this.It}`:this.Tt&&t.headers[j.Authorization]&&delete t.headers[j.Authorization]}getCookieString(t){return this.Pt.getCookieString(t)}}var q,O;!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"}(O||(O={}));class F{constructor(){this.Ht=!1,this.onabort=null}abort(){this.Ht||(this.Ht=!0,this.onabort&&this.onabort())}get signal(){return this}get aborted(){return this.Ht}}class B{get pollAborted(){return this.Dt.aborted}constructor(t,e,s){this.$=t,this.u=e,this.Dt=new F,this.xt=s,this.Rt=!1,this.onreceive=null,this.onclose=null}async connect(t,s){if(w.isRequired(t,"url"),w.isRequired(s,"transferFormat"),w.isIn(s,O,"transferFormat"),this.At=t,this.u.log(e.Trace,"(LongPolling transport) Connecting."),s===O.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]=$(),o={[i]:r,...this.xt.headers},h={abortSignal:this.Dt.signal,headers:o,timeout:1e5,withCredentials:this.xt.withCredentials};s===O.Binary&&(h.responseType="arraybuffer");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.Ut=new n(a.statusText||"",a.statusCode),this.Rt=!1):this.Rt=!0,this.Lt=this.Nt(this.At,h)}async Nt(t,s){try{for(;this.Rt;)try{const i=`${t}&_=${Date.now()}`;this.u.log(e.Trace,`(LongPolling transport) polling: ${i}.`);const r=await this.$.get(i,s);204===r.statusCode?(this.u.log(e.Information,"(LongPolling transport) Poll terminated by server."),this.Rt=!1):200!==r.statusCode?(this.u.log(e.Error,`(LongPolling transport) Unexpected response code: ${r.statusCode}.`),this.Ut=new n(r.statusText||"",r.statusCode),this.Rt=!1):r.content?(this.u.log(e.Trace,`(LongPolling transport) data received. ${m(r.content,this.xt.logMessageContent)}.`),this.onreceive&&this.onreceive(r.content)):this.u.log(e.Trace,"(LongPolling transport) Poll timed out, reissuing.")}catch(t){this.Rt?t instanceof i?this.u.log(e.Trace,"(LongPolling transport) Poll timed out, reissuing."):(this.Ut=t,this.Rt=!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.Mt()}}async send(t){return this.Rt?b(this.u,"LongPolling",this.$,this.At,t,this.xt):Promise.reject(new Error("Cannot send until the transport is connected"))}async stop(){this.u.log(e.Trace,"(LongPolling transport) Stopping polling."),this.Rt=!1,this.Dt.abort();try{await this.Lt,this.u.log(e.Trace,`(LongPolling transport) sending DELETE request to ${this.At}.`);const t={},[s,i]=$();t[s]=i;const r={headers:{...t,...this.xt.headers},timeout:this.xt.timeout,withCredentials:this.xt.withCredentials};let o;try{await this.$.delete(this.At,r)}catch(t){o=t}o?o instanceof n&&(404===o.statusCode?this.u.log(e.Trace,"(LongPolling transport) A 404 response was returned from sending a DELETE request."):this.u.log(e.Trace,`(LongPolling transport) Error sending a DELETE request: ${o}`)):this.u.log(e.Trace,"(LongPolling transport) DELETE request accepted.")}finally{this.u.log(e.Trace,"(LongPolling transport) Stop finished."),this.Mt()}}Mt(){if(this.onclose){let t="(LongPolling transport) Firing onclose event.";this.Ut&&(t+=" Error: "+this.Ut),this.u.log(e.Trace,t),this.onclose(this.Ut)}}}class X{constructor(t,e,s,n){this.$=t,this.It=e,this.u=s,this.xt=n,this.onreceive=null,this.onclose=null}async connect(t,s){return w.isRequired(t,"url"),w.isRequired(s,"transferFormat"),w.isIn(s,O,"transferFormat"),this.u.log(e.Trace,"(SSE transport) Connecting."),this.At=t,this.It&&(t+=(t.indexOf("?")<0?"?":"&")+`access_token=${encodeURIComponent(this.It)}`),new Promise(((n,i)=>{let r,o=!1;if(s===O.Text){if(g.isBrowser||g.isWebWorker)r=new this.xt.EventSource(t,{withCredentials:this.xt.withCredentials});else{const e=this.$.getCookieString(t),s={};s.Cookie=e;const[n,i]=$();s[n]=i,r=new this.xt.EventSource(t,{withCredentials:this.xt.withCredentials,headers:{...s,...this.xt.headers}})}try{r.onmessage=t=>{if(this.onreceive)try{this.u.log(e.Trace,`(SSE transport) data received. ${m(t.data,this.xt.logMessageContent)}.`),this.onreceive(t.data)}catch(t){return void this.jt(t)}},r.onerror=t=>{o?this.jt():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.At}`),this.Wt=r,o=!0,n()}}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.Wt?b(this.u,"SSE",this.$,this.At,t,this.xt):Promise.reject(new Error("Cannot send until the transport is connected"))}stop(){return this.jt(),Promise.resolve()}jt(t){this.Wt&&(this.Wt.close(),this.Wt=void 0,this.onclose&&this.onclose(t))}}class J{constructor(t,e,s,n,i,r){this.u=s,this.Tt=e,this.qt=n,this.Ot=i,this.$=t,this.onreceive=null,this.onclose=null,this.Ft=r}async connect(t,s){let n;return w.isRequired(t,"url"),w.isRequired(s,"transferFormat"),w.isIn(s,O,"transferFormat"),this.u.log(e.Trace,"(WebSockets transport) Connecting."),this.Tt&&(n=await this.Tt()),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={},[s,i]=$();e[s]=i,n&&(e[j.Authorization]=`Bearer ${n}`),h&&(e[j.Cookie]=h),o=new this.Ot(t,void 0,{headers:{...e,...this.Ft}})}else n&&(t+=(t.indexOf("?")<0?"?":"&")+`access_token=${encodeURIComponent(n)}`);o||(o=new this.Ot(t)),s===O.Binary&&(o.binaryType="arraybuffer"),o.onopen=s=>{this.u.log(e.Information,`WebSocket connected to ${t}.`),this.Bt=o,c=!0,i()},o.onerror=t=>{let s=null;s="undefined"!=typeof ErrorEvent&&t instanceof ErrorEvent?t.error:"There was an error with the transport",this.u.log(e.Information,`(WebSockets transport) ${s}.`)},o.onmessage=t=>{if(this.u.log(e.Trace,`(WebSockets transport) data received. ${m(t.data,this.qt)}.`),this.onreceive)try{this.onreceive(t.data)}catch(t){return void this.jt(t)}},o.onclose=t=>{if(c)this.jt(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.Bt&&this.Bt.readyState===this.Ot.OPEN?(this.u.log(e.Trace,`(WebSockets transport) sending data. ${m(t,this.qt)}.`),this.Bt.send(t),Promise.resolve()):Promise.reject("WebSocket is not in the OPEN state")}stop(){return this.Bt&&this.jt(void 0),Promise.resolve()}jt(t){this.Bt&&(this.Bt.onclose=()=>{},this.Bt.onmessage=()=>{},this.Bt.onerror=()=>{},this.Bt.close(),this.Bt=void 0),this.u.log(e.Trace,"(WebSockets transport) socket closed."),this.onclose&&(!this.Xt(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"}).`)))}Xt(t){return t&&"boolean"==typeof t.wasClean&&"number"==typeof t.code}}class z{constructor(t,s={}){var n;if(this.Jt=()=>{},this.features={},this.zt=1,w.isRequired(t,"url"),this.u=void 0===(n=s.logger)?new E(e.Information):null===n?p.instance:void 0!==n.log?n:new E(n),this.baseUrl=this.Vt(t),(s=s||{}).logMessageContent=void 0!==s.logMessageContent&&s.logMessageContent,"boolean"!=typeof s.withCredentials&&void 0!==s.withCredentials)throw new Error("withCredentials option was not a 'boolean' or 'undefined' value");s.withCredentials=void 0===s.withCredentials||s.withCredentials,s.timeout=void 0===s.timeout?1e5:s.timeout;let i=null,r=null;g.isNode&&(i=function(){throw new Error("Trying to import 'ws' in the browser.")}(),r=function(){throw new Error("Trying to import 'eventsource' in the browser.")}()),g.isNode||"undefined"==typeof WebSocket||s.WebSocket?g.isNode&&!s.WebSocket&&i&&(s.WebSocket=i):s.WebSocket=WebSocket,g.isNode||"undefined"==typeof EventSource||s.EventSource?g.isNode&&!s.EventSource&&void 0!==r&&(s.EventSource=r):s.EventSource=EventSource,this.$=new W(s.httpClient||new H(this.u),s.accessTokenFactory),this.M="Disconnected",this.j=!1,this.xt=s,this.onreceive=null,this.onclose=null}async start(t){if(t=t||O.Binary,w.isIn(t,O,"transferFormat"),this.u.log(e.Debug,`Starting connection with transfer format '${O[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.Kt=this.F(t),await this.Kt,"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.Gt||(this.Gt=new V(this.transport)),this.Gt.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.Jt=t})),await this.et(t),void await this.tt)}async et(t){this.Qt=t;try{await this.Kt}catch(t){}if(this.transport){try{await this.transport.stop()}catch(t){this.u.log(e.Error,`HttpConnection.transport.stop() threw error '${t}'.`),this.Yt()}this.transport=void 0}else this.u.log(e.Debug,"HttpConnection.transport is undefined in HttpConnection.stop() because start() failed.")}async F(t){let s=this.baseUrl;this.Tt=this.xt.accessTokenFactory,this.$.Tt=this.Tt;try{if(this.xt.skipNegotiation){if(this.xt.transport!==q.WebSockets)throw new Error("Negotiation can only be skipped when using the WebSocket transport directly.");this.transport=this.Zt(q.WebSockets),await this.te(s,t)}else{let e=null,n=0;do{if(e=await this.ee(s),"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&&(s=e.url),e.accessToken){const t=e.accessToken;this.Tt=()=>t,this.$.It=t,this.$.Tt=void 0}n++}while(e.url&&n<100);if(100===n&&e.url)throw new Error("Negotiate redirection limit exceeded.");await this.se(s,this.xt.transport,e,t)}this.transport instanceof B&&(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.Jt(),Promise.reject(t)}}async ee(t){const s={},[i,r]=$();s[i]=r;const o=this.ne(t);this.u.log(e.Debug,`Sending negotiation request: ${o}.`);try{const t=await this.$.post(o,{content:"",headers:{...s,...this.xt.headers},timeout:this.xt.timeout,withCredentials:this.xt.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 s="Failed to complete negotiation with the server: "+t;return t instanceof n&&404===t.statusCode&&(s+=" Either this is not a SignalR endpoint or there is a proxy blocking the connection."),this.u.log(e.Error,s),Promise.reject(new a(s))}}ie(t,e){return e?t+(-1===t.indexOf("?")?"?":"&")+`id=${e}`:t}async se(t,s,n,i){let o=this.ie(t,n.connectionToken);if(this.re(s))return this.u.log(e.Debug,"Connection was provided an instance of ITransport, using that directly."),this.transport=s,await this.te(o,i),void(this.connectionId=n.connectionId);const h=[],a=n.availableTransports||[];let u=n;for(const n of a){const a=this.oe(n,s,i);if(a instanceof Error)h.push(`${n.transport} failed:`),h.push(a);else if(this.re(a)){if(this.transport=a,!u){try{u=await this.ee(t)}catch(t){return Promise.reject(t)}o=this.ie(t,u.connectionToken)}try{return await this.te(o,i),void(this.connectionId=u.connectionId)}catch(t){if(this.u.log(e.Error,`Failed to start the transport '${n.transport}': ${t}`),u=void 0,h.push(new c(`${n.transport} failed: ${t}`,q[n.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."))}Zt(t){switch(t){case q.WebSockets:if(!this.xt.WebSocket)throw new Error("'WebSocket' is not supported in your environment.");return new J(this.$,this.Tt,this.u,this.xt.logMessageContent,this.xt.WebSocket,this.xt.headers||{});case q.ServerSentEvents:if(!this.xt.EventSource)throw new Error("'EventSource' is not supported in your environment.");return new X(this.$,this.$.It,this.u,this.xt);case q.LongPolling:return new B(this.$,this.u,this.xt);default:throw new Error(`Unknown transport: ${t}.`)}}te(t,e){return this.transport.onreceive=this.onreceive,this.transport.onclose=t=>this.Yt(t),this.transport.connect(t,e)}oe(t,s,n){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)}(s,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=>O[t])).indexOf(n)>=0))return this.u.log(e.Debug,`Skipping transport '${q[i]}' because it does not support the requested transfer format '${O[n]}'.`),new Error(`'${q[i]}' does not support ${O[n]}.`);if(i===q.WebSockets&&!this.xt.WebSocket||i===q.ServerSentEvents&&!this.xt.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.Zt(i)}catch(t){return t}}re(t){return t&&"object"==typeof t&&"connect"in t}Yt(t){if(this.u.log(e.Debug,`HttpConnection.stopConnection(${t}) called while in state ${this.M}.`),this.transport=void 0,t=this.Qt||t,this.Qt=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.Jt(),t?this.u.log(e.Error,`Connection disconnected with error '${t}'.`):this.u.log(e.Information,"Connection disconnected."),this.Gt&&(this.Gt.stop().catch((t=>{this.u.log(e.Error,`TransportSendQueue.stop() threw error '${t}'.`)})),this.Gt=void 0),this.connectionId=void 0,this.M="Disconnected",this.j){this.j=!1;try{this.onclose&&this.onclose(t)}catch(s){this.u.log(e.Error,`HttpConnection.onclose(${t}) threw error '${s}'.`)}}}else this.u.log(e.Debug,`Call to HttpConnection.stopConnection(${t}) was ignored because the connection is already in the disconnected state.`)}Vt(t){if(0===t.lastIndexOf("https://",0)||0===t.lastIndexOf("http://",0))return t;if(!g.isBrowser)throw new Error(`Cannot resolve '${t}'.`);const s=window.document.createElement("a");return s.href=t,this.u.log(e.Information,`Normalizing '${t}' to '${s.href}'.`),s.href}ne(t){const e=t.indexOf("?");let s=t.substring(0,-1===e?t.length:e);return"/"!==s[s.length-1]&&(s+="/"),s+="negotiate",s+=-1===e?"":t.substring(e),-1===s.indexOf("negotiateVersion")&&(s+=-1===e?"?":"&",s+="negotiateVersion="+this.zt),s}}class V{constructor(t){this.he=t,this.ce=[],this.ae=!0,this.le=new K,this.ue=new K,this.de=this.pe()}send(t){return this.fe(t),this.ue||(this.ue=new K),this.ue.promise}stop(){return this.ae=!1,this.le.resolve(),this.de}fe(t){if(this.ce.length&&typeof this.ce[0]!=typeof t)throw new Error(`Expected data to be of type ${typeof this.ce} but was of type ${typeof t}`);this.ce.push(t),this.le.resolve()}async pe(){for(;;){if(await this.le.promise,!this.ae){this.ue&&this.ue.reject("Connection stopped.");break}this.le=new K;const t=this.ue;this.ue=void 0;const e="string"==typeof this.ce[0]?this.ce.join(""):V.we(this.ce);this.ce.length=0;try{await this.he.send(e),t.resolve()}catch(e){t.reject(e)}}}static we(t){const e=t.map((t=>t.byteLength)).reduce(((t,e)=>t+e)),s=new Uint8Array(e);let n=0;for(const e of t)s.set(new Uint8Array(e),n),n+=e.byteLength;return s.buffer}}class K{constructor(){this.promise=new Promise(((t,e)=>[this.ge,this.me]=[t,e]))}resolve(){this.ge()}reject(t){this.me(t)}}class G{constructor(){this.name="json",this.version=1,this.transferFormat=O.Text}parseMessages(t,s){if("string"!=typeof t)throw new Error("Invalid input for JSON hub protocol. Expected a string.");if(!t)return[];null===s&&(s=p.instance);const n=D.parse(t),i=[];for(const t of n){const n=JSON.parse(t);if("number"!=typeof n.type)throw new Error("Invalid payload.");switch(n.type){case R.Invocation:this.ye(n);break;case R.StreamItem:this.be(n);break;case R.Completion:this.ve(n);break;case R.Ping:case R.Close:break;default:s.log(e.Information,"Unknown message type '"+n.type+"' ignored.");continue}i.push(n)}return i}writeMessage(t){return D.write(JSON.stringify(t))}ye(t){this.Ee(t.target,"Invalid payload for Invocation message."),void 0!==t.invocationId&&this.Ee(t.invocationId,"Invalid payload for Invocation message.")}be(t){if(this.Ee(t.invocationId,"Invalid payload for StreamItem message."),void 0===t.item)throw new Error("Invalid payload for StreamItem message.")}ve(t){if(t.result&&t.error)throw new Error("Invalid payload for Completion message.");!t.result&&t.error&&this.Ee(t.error,"Invalid payload for Completion message."),this.Ee(t.invocationId,"Invalid payload for Completion message.")}Ee(t,e){if("string"!=typeof t||""===t)throw new Error(e)}}const Q={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 Y{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=Q[t.toLowerCase()];if(void 0!==e)return e;throw new Error(`Unknown log level: ${t}`)}(t);this.logger=new E(e)}else this.logger=new E(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}withServerTimeout(t){return w.isRequired(t,"milliseconds"),this.$e=t,this}withKeepAliveInterval(t){return w.isRequired(t,"milliseconds"),this.Ce=t,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 z(this.url,t);return L.create(e,this.logger||p.instance,this.protocol||new G,this.reconnectPolicy,this.$e,this.Ce)}}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}),s})(),"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=()=>(()=>{var t={d:(e,s)=>{for(var n in s)t.o(s,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:s[n]})}};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,s={};t.r(s),t.d(s,{AbortError:()=>r,DefaultHttpClient:()=>H,HttpClient:()=>d,HttpError:()=>n,HttpResponse:()=>u,HttpTransportType:()=>q,HubConnection:()=>L,HubConnectionBuilder:()=>Y,HubConnectionState:()=>A,JsonHubProtocol:()=>G,LogLevel:()=>e,MessageType:()=>R,NullLogger:()=>p,Subject:()=>U,TimeoutError:()=>i,TransferFormat:()=>O,VERSION:()=>f});class n extends Error{constructor(t,e){const s=new.target.prototype;super(`${t}: Status code '${e}'`),this.statusCode=e,this.__proto__=s}}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 s=new.target.prototype;super(t),this.transport=e,this.errorType="UnsupportedTransportError",this.__proto__=s}}class h extends Error{constructor(t,e){const s=new.target.prototype;super(t),this.transport=e,this.errorType="DisabledTransportError",this.__proto__=s}}class c extends Error{constructor(t,e){const s=new.target.prototype;super(t),this.transport=e,this.errorType="FailedToStartTransportError",this.__proto__=s}}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 s=new.target.prototype;super(t),this.innerErrors=e,this.__proto__=s}}class u{constructor(t,e,s){this.statusCode=t,this.statusText=e,this.content=s}}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 p{constructor(){}log(t,e){}}p.instance=new p;const f="8.0.0-rc.1.23421.29";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,s){if(!(t in e))throw new Error(`Unknown ${s} value: ${t}.`)}}class g{static get isBrowser(){return!g.isNode&&"object"==typeof window&&"object"==typeof window.document}static get isWebWorker(){return!g.isNode&&"object"==typeof self&&"importScripts"in self}static get isReactNative(){return!g.isNode&&"object"==typeof window&&void 0===window.document}static get isNode(){return"undefined"!=typeof process&&process.release&&"node"===process.release.name}}function m(t,e){let s="";return y(t)?(s=`Binary data of length ${t.byteLength}`,e&&(s+=`. Content: '${function(t){const e=new Uint8Array(t);let s="";return e.forEach((t=>{s+=`0x${t<16?"0":""}${t.toString(16)} `})),s.substr(0,s.length-1)}(t)}'`)):"string"==typeof t&&(s=`String data of length ${t.length}`,e&&(s+=`. Content: '${t}'`)),s}function y(t){return t&&"undefined"!=typeof ArrayBuffer&&(t instanceof ArrayBuffer||t.constructor&&"ArrayBuffer"===t.constructor.name)}async function b(t,s,n,i,r,o){const h={},[c,a]=$();h[c]=a,t.log(e.Trace,`(${s} transport) sending data. ${m(r,o.logMessageContent)}.`);const l=y(r)?"arraybuffer":"text",u=await n.post(i,{content:r,headers:{...h,...o.headers},responseType:l,timeout:o.timeout,withCredentials:o.withCredentials});t.log(e.Trace,`(${s} transport) request complete. Response status: ${u.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 E{constructor(t){this.l=t,this.out=console}log(t,s){if(t>=this.l){const n=`[${(new Date).toISOString()}] ${e[t]}: ${s}`;switch(t){case e.Critical:case e.Error:this.out.error(n);break;case e.Warning:this.out.warn(n);break;case e.Information:this.out.info(n);break;default:this.out.log(n)}}}}function $(){let t="X-SignalR-User-Agent";return g.isNode&&(t="User-Agent"),[t,C(f,S(),g.isNode?"NodeJS":"Browser",k())]}function C(t,e,s,n){let i="Microsoft SignalR/";const r=t.split(".");return i+=`${r[0]}.${r[1]}`,i+=` (${t}; `,i+=e&&""!==e?`${e}; `:"Unknown OS; ",i+=`${s}`,i+=n?`; ${n}`:"; 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){super(),this.u=e,this.p=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")}()),this.m=AbortController,this.m}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 s=new this.m;let o;t.abortSignal&&(t.abortSignal.onabort=()=>{s.abort(),o=new r});let h,c=null;if(t.timeout){const n=t.timeout;c=setTimeout((()=>{s.abort(),this.u.log(e.Warning,"Timeout from HTTP request."),o=new i}),n)}""===t.content&&(t.content=void 0),t.content&&(t.headers=t.headers||{},y(t.content)?t.headers["Content-Type"]="application/octet-stream":t.headers["Content-Type"]="text/plain;charset=UTF-8");try{h=await this.p(t.url,{body:t.content,cache:"no-cache",credentials:!0===t.withCredentials?"include":"same-origin",headers:{"X-Requested-With":"XMLHttpRequest",...t.headers},method:t.method,mode:"cors",redirect:"follow",signal:s.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 n(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.v&&this.v.getCookies(t,((t,s)=>e=s.join("; "))),e}}function I(t,e){let s;switch(e){case"arraybuffer":s=t.arrayBuffer();break;case"text":default:s=t.text();break;case"blob":case"document":case"json":throw new Error(`${e} is not supported.`)}return s}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(((s,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"),""===t.content&&(t.content=void 0),t.content&&(y(t.content)?h.setRequestHeader("Content-Type","application/octet-stream"):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?s(new u(h.status,h.statusText,h.response||h.responseText)):o(new n(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 n(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,s;if(y(t)){const n=new Uint8Array(t),i=n.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(n.slice(0,r))),s=n.byteLength>r?n.slice(r).buffer:null}else{const n=t,i=n.indexOf(D.RecordSeparator);if(-1===i)throw new Error("Message is incomplete.");const r=i+1;e=n.substring(0,r),s=n.length>r?n.substring(r):null}const n=D.parse(e),i=JSON.parse(n[0]);if(i.type)throw new Error("Expected a handshake response from the server.");return[s,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 L{static create(t,e,s,n,i,r){return new L(t,e,s,n,i,r)}constructor(t,s,n,i,r,o){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://learn.microsoft.com/aspnet/core/signalr/javascript-client#bsleep")},w.isRequired(t,"connection"),w.isRequired(s,"logger"),w.isRequired(n,"protocol"),this.serverTimeoutInMilliseconds=null!=r?r:3e4,this.keepAliveIntervalInMilliseconds=null!=o?o:15e3,this.u=s,this.k=n,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.L=0,this.N=!1,this.M=A.Disconnected,this.j=!1,this.W=this.k.writeMessage({type:R.Ping})}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.q=this.O(),this.q}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.N=!1;const t=new Promise(((t,e)=>{this.X=t,this.J=e}));await this.connection.start(this.k.transferFormat);try{const s={protocol:this.k.name,version:this.k.version};if(this.u.log(e.Debug,"Sending handshake request."),await this.V(this.T.writeHandshakeRequest(s)),this.u.log(e.Information,`Using HubProtocol '${this.k.name}'.`),this.K(),this.G(),this.Y(),await t,this.B)throw this.B;this.connection.features.inherentKeepAlive||await this.V(this.W)}catch(t){throw this.u.log(e.Debug,`Hub handshake failed with error '${t}' during start(). Stopping HubConnection.`),this.K(),this.Z(),await this.connection.stop(t),t}}async stop(){const t=this.q;this.tt=this.et(),await this.tt;try{await t}catch(t){}}et(t){if(this.M===A.Disconnected)return this.u.log(e.Debug,`Call to HubConnection.stop(${t}) ignored because it is already in the disconnected state.`),Promise.resolve();if(this.M===A.Disconnecting)return this.u.log(e.Debug,`Call to HttpConnection.stop(${t}) ignored because the connection is already in the disconnecting state.`),this.tt;const s=this.M;return this.M=A.Disconnecting,this.u.log(e.Debug,"Stopping HubConnection."),this.st?(this.u.log(e.Debug,"Connection stopped during reconnect delay. Done reconnecting."),clearTimeout(this.st),this.st=void 0,this.nt(),Promise.resolve()):(s===A.Connected&&this.it(),this.K(),this.Z(),this.B=t||new r("The connection was stopped before the hub handshake could complete."),this.connection.stop(t))}async it(){try{await this.rt(this.ot())}catch{}}stream(t,...e){const[s,n]=this.ht(e),i=this.ct(t,e,n);let r;const o=new U;return o.cancelCallback=()=>{const t=this.lt(i.invocationId);return delete this.H[i.invocationId],r.then((()=>this.rt(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.rt(i).catch((t=>{o.error(t),delete this.H[i.invocationId]})),this.ut(s,r),o}V(t){return this.Y(),this.connection.send(t)}rt(t){return this.V(this.k.writeMessage(t))}send(t,...e){const[s,n]=this.ht(e),i=this.rt(this.dt(t,e,!0,n));return this.ut(s,i),i}invoke(t,...e){const[s,n]=this.ht(e),i=this.dt(t,e,!1,n);return new Promise(((t,e)=>{this.H[i.invocationId]=(s,n)=>{n?e(n):s&&(s.type===R.Completion?s.error?e(new Error(s.error)):t(s.result):e(new Error(`Unexpected message type: ${s.type}`)))};const n=this.rt(i).catch((t=>{e(t),delete this.H[i.invocationId]}));this.ut(s,n)}))}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 s=this.D[t];if(s)if(e){const n=s.indexOf(e);-1!==n&&(s.splice(n,1),0===s.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.K(),this.N||(t=this.ft(t),this.N=!0),t){const s=this.k.parseMessages(t,this.u);for(const t of s)switch(t.type){case R.Invocation:this.wt(t);break;case R.StreamItem:case R.Completion:{const s=this.H[t.invocationId];if(s){t.type===R.Completion&&delete this.H[t.invocationId];try{s(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 s=t.error?new Error("Server returned an error on close: "+t.error):void 0;!0===t.allowReconnect?this.connection.stop(s):this.tt=this.et(s);break}default:this.u.log(e.Warning,`Invalid message type: ${t.type}.`)}}this.G()}ft(t){let s,n;try{[n,s]=this.T.parseHandshakeResponse(t)}catch(t){const s="Error parsing handshake response: "+t;this.u.log(e.Error,s);const n=new Error(s);throw this.J(n),n}if(s.error){const t="Server returned handshake error: "+s.error;this.u.log(e.Error,t);const n=new Error(t);throw this.J(n),n}return this.u.log(e.Debug,"Server handshake complete."),this.X(),n}Y(){this.connection.features.inherentKeepAlive||(this.C=(new Date).getTime()+this.keepAliveIntervalInMilliseconds,this.Z())}G(){if(!(this.connection.features&&this.connection.features.inherentKeepAlive||(this.gt=setTimeout((()=>this.serverTimeout()),this.serverTimeoutInMilliseconds),void 0!==this.yt))){let t=this.C-(new Date).getTime();t<0&&(t=0),this.yt=setTimeout((async()=>{if(this.M===A.Connected)try{await this.V(this.W)}catch{this.Z()}}),t)}}serverTimeout(){this.connection.stop(new Error("Server timeout elapsed without receiving a message from the server."))}async wt(t){const s=t.target.toLowerCase(),n=this.D[s];if(!n)return this.u.log(e.Warning,`No client method with the name '${s}' found.`),void(t.invocationId&&(this.u.log(e.Warning,`No result given for '${s}' method and invocation ID '${t.invocationId}'.`),await this.rt(this.bt(t.invocationId,"Client didn't provide a result.",null))));const i=n.slice(),r=!!t.invocationId;let o,h,c;for(const n of i)try{const i=o;o=await n.apply(this,t.arguments),r&&o&&i&&(this.u.log(e.Error,`Multiple results provided for '${s}'. Sending error to server.`),c=this.bt(t.invocationId,"Client provided multiple results.",null)),h=void 0}catch(t){h=t,this.u.log(e.Error,`A callback for the method '${s}' threw error '${t}'.`)}c?await this.rt(c):r?(h?c=this.bt(t.invocationId,`${h}`,null):void 0!==o?c=this.bt(t.invocationId,null,o):(this.u.log(e.Warning,`No result given for '${s}' method and invocation ID '${t.invocationId}'.`),c=this.bt(t.invocationId,"Client didn't provide a result.",null)),await this.rt(c)):o&&this.u.log(e.Error,`Result given for '${s}' 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.vt(t||new Error("Invocation canceled due to the underlying connection being closed.")),this.K(),this.Z(),this.M===A.Disconnecting?this.nt(t):this.M===A.Connected&&this.P?this.Et(t):this.M===A.Connected&&this.nt(t)}nt(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(s){this.u.log(e.Error,`An onclose callback called with error '${t}' threw error '${s}'.`)}}}async Et(t){const s=Date.now();let n=0,i=void 0!==t?t:new Error("Attempting to reconnect due to a unknown error."),r=this.$t(n++,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.nt(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(s){this.u.log(e.Error,`An onreconnecting callback called with error '${t}' threw error '${s}'.`)}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 ${n} will start in ${r} ms.`),await new Promise((t=>{this.st=setTimeout(t,r)})),this.st=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.nt());i=t instanceof Error?t:new Error(t.toString()),r=this.$t(n++,Date.now()-s,i)}}this.u.log(e.Information,`Reconnect retries have been exhausted after ${Date.now()-s} ms and ${n} failed attempts. Connection disconnecting.`),this.nt()}$t(t,s,n){try{return this.P.nextRetryDelayInMilliseconds({elapsedMilliseconds:s,previousRetryCount:t,retryReason:n})}catch(n){return this.u.log(e.Error,`IRetryPolicy.nextRetryDelayInMilliseconds(${t}, ${s}) threw error '${n}'.`),null}}vt(t){const s=this.H;this.H={},Object.keys(s).forEach((n=>{const i=s[n];try{i(null,t)}catch(s){this.u.log(e.Error,`Stream 'error' callback called with '${t}' threw error: ${P(s)}`)}}))}Z(){this.yt&&(clearTimeout(this.yt),this.yt=void 0)}K(){this.gt&&clearTimeout(this.gt)}dt(t,e,s,n){if(s)return 0!==n.length?{arguments:e,streamIds:n,target:t,type:R.Invocation}:{arguments:e,target:t,type:R.Invocation};{const s=this.L;return this.L++,0!==n.length?{arguments:e,invocationId:s.toString(),streamIds:n,target:t,type:R.Invocation}:{arguments:e,invocationId:s.toString(),target:t,type:R.Invocation}}}ut(t,e){if(0!==t.length){e||(e=Promise.resolve());for(const s in t)t[s].subscribe({complete:()=>{e=e.then((()=>this.rt(this.bt(s))))},error:t=>{let n;n=t instanceof Error?t.message:t&&t.toString?t.toString():"Unknown error",e=e.then((()=>this.rt(this.bt(s,n))))},next:t=>{e=e.then((()=>this.rt(this.Ct(s,t))))}})}}ht(t){const e=[],s=[];for(let n=0;n<t.length;n++){const i=t[n];if(this.St(i)){const r=this.L;this.L++,e[r]=i,s.push(r.toString()),t.splice(n,1)}}return[e,s]}St(t){return t&&t.subscribe&&"function"==typeof t.subscribe}ct(t,e,s){const n=this.L;return this.L++,0!==s.length?{arguments:e,invocationId:n.toString(),streamIds:s,target:t,type:R.StreamInvocation}:{arguments:e,invocationId:n.toString(),target:t,type:R.StreamInvocation}}lt(t){return{invocationId:t,type:R.CancelInvocation}}Ct(t,e){return{invocationId:t,item:e,type:R.StreamItem}}bt(t,e,s){return e?{error:e,invocationId:t,type:R.Completion}:{invocationId:t,result:s,type:R.Completion}}ot(){return{type:R.Close}}}const N=[0,2e3,1e4,3e4,null];class M{constructor(t){this.kt=void 0!==t?[...t,null]:N}nextRetryDelayInMilliseconds(t){return this.kt[t.previousRetryCount]}}class j{}j.Authorization="Authorization",j.Cookie="Cookie";class W extends d{constructor(t,e){super(),this.Pt=t,this.Tt=e}async send(t){let e=!0;this.Tt&&(!this.It||t.url&&t.url.indexOf("/negotiate?")>0)&&(e=!1,this.It=await this.Tt()),this._t(t);const s=await this.Pt.send(t);return e&&401===s.statusCode&&this.Tt?(this.It=await this.Tt(),this._t(t),await this.Pt.send(t)):s}_t(t){t.headers||(t.headers={}),this.It?t.headers[j.Authorization]=`Bearer ${this.It}`:this.Tt&&t.headers[j.Authorization]&&delete t.headers[j.Authorization]}getCookieString(t){return this.Pt.getCookieString(t)}}var q,O;!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"}(O||(O={}));class F{constructor(){this.Ht=!1,this.onabort=null}abort(){this.Ht||(this.Ht=!0,this.onabort&&this.onabort())}get signal(){return this}get aborted(){return this.Ht}}class B{get pollAborted(){return this.Dt.aborted}constructor(t,e,s){this.$=t,this.u=e,this.Dt=new F,this.xt=s,this.Rt=!1,this.onreceive=null,this.onclose=null}async connect(t,s){if(w.isRequired(t,"url"),w.isRequired(s,"transferFormat"),w.isIn(s,O,"transferFormat"),this.At=t,this.u.log(e.Trace,"(LongPolling transport) Connecting."),s===O.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]=$(),o={[i]:r,...this.xt.headers},h={abortSignal:this.Dt.signal,headers:o,timeout:1e5,withCredentials:this.xt.withCredentials};s===O.Binary&&(h.responseType="arraybuffer");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.Ut=new n(a.statusText||"",a.statusCode),this.Rt=!1):this.Rt=!0,this.Lt=this.Nt(this.At,h)}async Nt(t,s){try{for(;this.Rt;)try{const i=`${t}&_=${Date.now()}`;this.u.log(e.Trace,`(LongPolling transport) polling: ${i}.`);const r=await this.$.get(i,s);204===r.statusCode?(this.u.log(e.Information,"(LongPolling transport) Poll terminated by server."),this.Rt=!1):200!==r.statusCode?(this.u.log(e.Error,`(LongPolling transport) Unexpected response code: ${r.statusCode}.`),this.Ut=new n(r.statusText||"",r.statusCode),this.Rt=!1):r.content?(this.u.log(e.Trace,`(LongPolling transport) data received. ${m(r.content,this.xt.logMessageContent)}.`),this.onreceive&&this.onreceive(r.content)):this.u.log(e.Trace,"(LongPolling transport) Poll timed out, reissuing.")}catch(t){this.Rt?t instanceof i?this.u.log(e.Trace,"(LongPolling transport) Poll timed out, reissuing."):(this.Ut=t,this.Rt=!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.Mt()}}async send(t){return this.Rt?b(this.u,"LongPolling",this.$,this.At,t,this.xt):Promise.reject(new Error("Cannot send until the transport is connected"))}async stop(){this.u.log(e.Trace,"(LongPolling transport) Stopping polling."),this.Rt=!1,this.Dt.abort();try{await this.Lt,this.u.log(e.Trace,`(LongPolling transport) sending DELETE request to ${this.At}.`);const t={},[s,i]=$();t[s]=i;const r={headers:{...t,...this.xt.headers},timeout:this.xt.timeout,withCredentials:this.xt.withCredentials};let o;try{await this.$.delete(this.At,r)}catch(t){o=t}o?o instanceof n&&(404===o.statusCode?this.u.log(e.Trace,"(LongPolling transport) A 404 response was returned from sending a DELETE request."):this.u.log(e.Trace,`(LongPolling transport) Error sending a DELETE request: ${o}`)):this.u.log(e.Trace,"(LongPolling transport) DELETE request accepted.")}finally{this.u.log(e.Trace,"(LongPolling transport) Stop finished."),this.Mt()}}Mt(){if(this.onclose){let t="(LongPolling transport) Firing onclose event.";this.Ut&&(t+=" Error: "+this.Ut),this.u.log(e.Trace,t),this.onclose(this.Ut)}}}class X{constructor(t,e,s,n){this.$=t,this.It=e,this.u=s,this.xt=n,this.onreceive=null,this.onclose=null}async connect(t,s){return w.isRequired(t,"url"),w.isRequired(s,"transferFormat"),w.isIn(s,O,"transferFormat"),this.u.log(e.Trace,"(SSE transport) Connecting."),this.At=t,this.It&&(t+=(t.indexOf("?")<0?"?":"&")+`access_token=${encodeURIComponent(this.It)}`),new Promise(((n,i)=>{let r,o=!1;if(s===O.Text){if(g.isBrowser||g.isWebWorker)r=new this.xt.EventSource(t,{withCredentials:this.xt.withCredentials});else{const e=this.$.getCookieString(t),s={};s.Cookie=e;const[n,i]=$();s[n]=i,r=new this.xt.EventSource(t,{withCredentials:this.xt.withCredentials,headers:{...s,...this.xt.headers}})}try{r.onmessage=t=>{if(this.onreceive)try{this.u.log(e.Trace,`(SSE transport) data received. ${m(t.data,this.xt.logMessageContent)}.`),this.onreceive(t.data)}catch(t){return void this.jt(t)}},r.onerror=t=>{o?this.jt():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.At}`),this.Wt=r,o=!0,n()}}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.Wt?b(this.u,"SSE",this.$,this.At,t,this.xt):Promise.reject(new Error("Cannot send until the transport is connected"))}stop(){return this.jt(),Promise.resolve()}jt(t){this.Wt&&(this.Wt.close(),this.Wt=void 0,this.onclose&&this.onclose(t))}}class J{constructor(t,e,s,n,i,r){this.u=s,this.Tt=e,this.qt=n,this.Ot=i,this.$=t,this.onreceive=null,this.onclose=null,this.Ft=r}async connect(t,s){let n;return w.isRequired(t,"url"),w.isRequired(s,"transferFormat"),w.isIn(s,O,"transferFormat"),this.u.log(e.Trace,"(WebSockets transport) Connecting."),this.Tt&&(n=await this.Tt()),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={},[s,i]=$();e[s]=i,n&&(e[j.Authorization]=`Bearer ${n}`),h&&(e[j.Cookie]=h),o=new this.Ot(t,void 0,{headers:{...e,...this.Ft}})}else n&&(t+=(t.indexOf("?")<0?"?":"&")+`access_token=${encodeURIComponent(n)}`);o||(o=new this.Ot(t)),s===O.Binary&&(o.binaryType="arraybuffer"),o.onopen=s=>{this.u.log(e.Information,`WebSocket connected to ${t}.`),this.Bt=o,c=!0,i()},o.onerror=t=>{let s=null;s="undefined"!=typeof ErrorEvent&&t instanceof ErrorEvent?t.error:"There was an error with the transport",this.u.log(e.Information,`(WebSockets transport) ${s}.`)},o.onmessage=t=>{if(this.u.log(e.Trace,`(WebSockets transport) data received. ${m(t.data,this.qt)}.`),this.onreceive)try{this.onreceive(t.data)}catch(t){return void this.jt(t)}},o.onclose=t=>{if(c)this.jt(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.Bt&&this.Bt.readyState===this.Ot.OPEN?(this.u.log(e.Trace,`(WebSockets transport) sending data. ${m(t,this.qt)}.`),this.Bt.send(t),Promise.resolve()):Promise.reject("WebSocket is not in the OPEN state")}stop(){return this.Bt&&this.jt(void 0),Promise.resolve()}jt(t){this.Bt&&(this.Bt.onclose=()=>{},this.Bt.onmessage=()=>{},this.Bt.onerror=()=>{},this.Bt.close(),this.Bt=void 0),this.u.log(e.Trace,"(WebSockets transport) socket closed."),this.onclose&&(!this.Xt(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"}).`)))}Xt(t){return t&&"boolean"==typeof t.wasClean&&"number"==typeof t.code}}class z{constructor(t,s={}){var n;if(this.Jt=()=>{},this.features={},this.zt=1,w.isRequired(t,"url"),this.u=void 0===(n=s.logger)?new E(e.Information):null===n?p.instance:void 0!==n.log?n:new E(n),this.baseUrl=this.Vt(t),(s=s||{}).logMessageContent=void 0!==s.logMessageContent&&s.logMessageContent,"boolean"!=typeof s.withCredentials&&void 0!==s.withCredentials)throw new Error("withCredentials option was not a 'boolean' or 'undefined' value");s.withCredentials=void 0===s.withCredentials||s.withCredentials,s.timeout=void 0===s.timeout?1e5:s.timeout;let i=null,r=null;g.isNode&&(i=function(){throw new Error("Trying to import 'ws' in the browser.")}(),r=function(){throw new Error("Trying to import 'eventsource' in the browser.")}()),g.isNode||"undefined"==typeof WebSocket||s.WebSocket?g.isNode&&!s.WebSocket&&i&&(s.WebSocket=i):s.WebSocket=WebSocket,g.isNode||"undefined"==typeof EventSource||s.EventSource?g.isNode&&!s.EventSource&&void 0!==r&&(s.EventSource=r):s.EventSource=EventSource,this.$=new W(s.httpClient||new H(this.u),s.accessTokenFactory),this.M="Disconnected",this.j=!1,this.xt=s,this.onreceive=null,this.onclose=null}async start(t){if(t=t||O.Binary,w.isIn(t,O,"transferFormat"),this.u.log(e.Debug,`Starting connection with transfer format '${O[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.Kt=this.F(t),await this.Kt,"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.Gt||(this.Gt=new V(this.transport)),this.Gt.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.Jt=t})),await this.et(t),void await this.tt)}async et(t){this.Qt=t;try{await this.Kt}catch(t){}if(this.transport){try{await this.transport.stop()}catch(t){this.u.log(e.Error,`HttpConnection.transport.stop() threw error '${t}'.`),this.Yt()}this.transport=void 0}else this.u.log(e.Debug,"HttpConnection.transport is undefined in HttpConnection.stop() because start() failed.")}async F(t){let s=this.baseUrl;this.Tt=this.xt.accessTokenFactory,this.$.Tt=this.Tt;try{if(this.xt.skipNegotiation){if(this.xt.transport!==q.WebSockets)throw new Error("Negotiation can only be skipped when using the WebSocket transport directly.");this.transport=this.Zt(q.WebSockets),await this.te(s,t)}else{let e=null,n=0;do{if(e=await this.ee(s),"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&&(s=e.url),e.accessToken){const t=e.accessToken;this.Tt=()=>t,this.$.It=t,this.$.Tt=void 0}n++}while(e.url&&n<100);if(100===n&&e.url)throw new Error("Negotiate redirection limit exceeded.");await this.se(s,this.xt.transport,e,t)}this.transport instanceof B&&(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.Jt(),Promise.reject(t)}}async ee(t){const s={},[i,r]=$();s[i]=r;const o=this.ne(t);this.u.log(e.Debug,`Sending negotiation request: ${o}.`);try{const t=await this.$.post(o,{content:"",headers:{...s,...this.xt.headers},timeout:this.xt.timeout,withCredentials:this.xt.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 s="Failed to complete negotiation with the server: "+t;return t instanceof n&&404===t.statusCode&&(s+=" Either this is not a SignalR endpoint or there is a proxy blocking the connection."),this.u.log(e.Error,s),Promise.reject(new a(s))}}ie(t,e){return e?t+(-1===t.indexOf("?")?"?":"&")+`id=${e}`:t}async se(t,s,n,i){let o=this.ie(t,n.connectionToken);if(this.re(s))return this.u.log(e.Debug,"Connection was provided an instance of ITransport, using that directly."),this.transport=s,await this.te(o,i),void(this.connectionId=n.connectionId);const h=[],a=n.availableTransports||[];let u=n;for(const n of a){const a=this.oe(n,s,i);if(a instanceof Error)h.push(`${n.transport} failed:`),h.push(a);else if(this.re(a)){if(this.transport=a,!u){try{u=await this.ee(t)}catch(t){return Promise.reject(t)}o=this.ie(t,u.connectionToken)}try{return await this.te(o,i),void(this.connectionId=u.connectionId)}catch(t){if(this.u.log(e.Error,`Failed to start the transport '${n.transport}': ${t}`),u=void 0,h.push(new c(`${n.transport} failed: ${t}`,q[n.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."))}Zt(t){switch(t){case q.WebSockets:if(!this.xt.WebSocket)throw new Error("'WebSocket' is not supported in your environment.");return new J(this.$,this.Tt,this.u,this.xt.logMessageContent,this.xt.WebSocket,this.xt.headers||{});case q.ServerSentEvents:if(!this.xt.EventSource)throw new Error("'EventSource' is not supported in your environment.");return new X(this.$,this.$.It,this.u,this.xt);case q.LongPolling:return new B(this.$,this.u,this.xt);default:throw new Error(`Unknown transport: ${t}.`)}}te(t,e){return this.transport.onreceive=this.onreceive,this.transport.onclose=t=>this.Yt(t),this.transport.connect(t,e)}oe(t,s,n){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)}(s,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=>O[t])).indexOf(n)>=0))return this.u.log(e.Debug,`Skipping transport '${q[i]}' because it does not support the requested transfer format '${O[n]}'.`),new Error(`'${q[i]}' does not support ${O[n]}.`);if(i===q.WebSockets&&!this.xt.WebSocket||i===q.ServerSentEvents&&!this.xt.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.Zt(i)}catch(t){return t}}re(t){return t&&"object"==typeof t&&"connect"in t}Yt(t){if(this.u.log(e.Debug,`HttpConnection.stopConnection(${t}) called while in state ${this.M}.`),this.transport=void 0,t=this.Qt||t,this.Qt=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.Jt(),t?this.u.log(e.Error,`Connection disconnected with error '${t}'.`):this.u.log(e.Information,"Connection disconnected."),this.Gt&&(this.Gt.stop().catch((t=>{this.u.log(e.Error,`TransportSendQueue.stop() threw error '${t}'.`)})),this.Gt=void 0),this.connectionId=void 0,this.M="Disconnected",this.j){this.j=!1;try{this.onclose&&this.onclose(t)}catch(s){this.u.log(e.Error,`HttpConnection.onclose(${t}) threw error '${s}'.`)}}}else this.u.log(e.Debug,`Call to HttpConnection.stopConnection(${t}) was ignored because the connection is already in the disconnected state.`)}Vt(t){if(0===t.lastIndexOf("https://",0)||0===t.lastIndexOf("http://",0))return t;if(!g.isBrowser)throw new Error(`Cannot resolve '${t}'.`);const s=window.document.createElement("a");return s.href=t,this.u.log(e.Information,`Normalizing '${t}' to '${s.href}'.`),s.href}ne(t){const e=t.indexOf("?");let s=t.substring(0,-1===e?t.length:e);return"/"!==s[s.length-1]&&(s+="/"),s+="negotiate",s+=-1===e?"":t.substring(e),-1===s.indexOf("negotiateVersion")&&(s+=-1===e?"?":"&",s+="negotiateVersion="+this.zt),s}}class V{constructor(t){this.he=t,this.ce=[],this.ae=!0,this.le=new K,this.ue=new K,this.de=this.pe()}send(t){return this.fe(t),this.ue||(this.ue=new K),this.ue.promise}stop(){return this.ae=!1,this.le.resolve(),this.de}fe(t){if(this.ce.length&&typeof this.ce[0]!=typeof t)throw new Error(`Expected data to be of type ${typeof this.ce} but was of type ${typeof t}`);this.ce.push(t),this.le.resolve()}async pe(){for(;;){if(await this.le.promise,!this.ae){this.ue&&this.ue.reject("Connection stopped.");break}this.le=new K;const t=this.ue;this.ue=void 0;const e="string"==typeof this.ce[0]?this.ce.join(""):V.we(this.ce);this.ce.length=0;try{await this.he.send(e),t.resolve()}catch(e){t.reject(e)}}}static we(t){const e=t.map((t=>t.byteLength)).reduce(((t,e)=>t+e)),s=new Uint8Array(e);let n=0;for(const e of t)s.set(new Uint8Array(e),n),n+=e.byteLength;return s.buffer}}class K{constructor(){this.promise=new Promise(((t,e)=>[this.ge,this.me]=[t,e]))}resolve(){this.ge()}reject(t){this.me(t)}}class G{constructor(){this.name="json",this.version=1,this.transferFormat=O.Text}parseMessages(t,s){if("string"!=typeof t)throw new Error("Invalid input for JSON hub protocol. Expected a string.");if(!t)return[];null===s&&(s=p.instance);const n=D.parse(t),i=[];for(const t of n){const n=JSON.parse(t);if("number"!=typeof n.type)throw new Error("Invalid payload.");switch(n.type){case R.Invocation:this.ye(n);break;case R.StreamItem:this.be(n);break;case R.Completion:this.ve(n);break;case R.Ping:case R.Close:break;default:s.log(e.Information,"Unknown message type '"+n.type+"' ignored.");continue}i.push(n)}return i}writeMessage(t){return D.write(JSON.stringify(t))}ye(t){this.Ee(t.target,"Invalid payload for Invocation message."),void 0!==t.invocationId&&this.Ee(t.invocationId,"Invalid payload for Invocation message.")}be(t){if(this.Ee(t.invocationId,"Invalid payload for StreamItem message."),void 0===t.item)throw new Error("Invalid payload for StreamItem message.")}ve(t){if(t.result&&t.error)throw new Error("Invalid payload for Completion message.");!t.result&&t.error&&this.Ee(t.error,"Invalid payload for Completion message."),this.Ee(t.invocationId,"Invalid payload for Completion message.")}Ee(t,e){if("string"!=typeof t||""===t)throw new Error(e)}}const Q={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 Y{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=Q[t.toLowerCase()];if(void 0!==e)return e;throw new Error(`Unknown log level: ${t}`)}(t);this.logger=new E(e)}else this.logger=new E(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}withServerTimeout(t){return w.isRequired(t,"milliseconds"),this.$e=t,this}withKeepAliveInterval(t){return w.isRequired(t,"milliseconds"),this.Ce=t,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 z(this.url,t);return L.create(e,this.logger||p.instance,this.protocol||new G,this.reconnectPolicy,this.$e,this.Ce)}}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}),s})(),"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 = "8.0.0-preview.7.23375.9";
exports.VERSION = "8.0.0-rc.1.23421.29";
/** @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 = "8.0.0-preview.7.23375.9";
export const VERSION = "8.0.0-rc.1.23421.29";
/** @private */

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

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

var t,e;t=self,e=()=>(()=>{var t={d:(e,s)=>{for(var n in s)t.o(s,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:s[n]})}};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,s={};t.r(s),t.d(s,{AbortError:()=>r,DefaultHttpClient:()=>H,HttpClient:()=>d,HttpError:()=>n,HttpResponse:()=>u,HttpTransportType:()=>q,HubConnection:()=>L,HubConnectionBuilder:()=>Y,HubConnectionState:()=>A,JsonHubProtocol:()=>G,LogLevel:()=>e,MessageType:()=>R,NullLogger:()=>p,Subject:()=>U,TimeoutError:()=>i,TransferFormat:()=>O,VERSION:()=>f});class n extends Error{constructor(t,e){const s=new.target.prototype;super(`${t}: Status code '${e}'`),this.statusCode=e,this.__proto__=s}}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 s=new.target.prototype;super(t),this.transport=e,this.errorType="UnsupportedTransportError",this.__proto__=s}}class h extends Error{constructor(t,e){const s=new.target.prototype;super(t),this.transport=e,this.errorType="DisabledTransportError",this.__proto__=s}}class c extends Error{constructor(t,e){const s=new.target.prototype;super(t),this.transport=e,this.errorType="FailedToStartTransportError",this.__proto__=s}}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 s=new.target.prototype;super(t),this.innerErrors=e,this.__proto__=s}}class u{constructor(t,e,s){this.statusCode=t,this.statusText=e,this.content=s}}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 p{constructor(){}log(t,e){}}p.instance=new p;const f="8.0.0-preview.7.23375.9";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,s){if(!(t in e))throw new Error(`Unknown ${s} value: ${t}.`)}}class g{static get isBrowser(){return!g.isNode&&"object"==typeof window&&"object"==typeof window.document}static get isWebWorker(){return!g.isNode&&"object"==typeof self&&"importScripts"in self}static get isReactNative(){return!g.isNode&&"object"==typeof window&&void 0===window.document}static get isNode(){return"undefined"!=typeof process&&process.release&&"node"===process.release.name}}function m(t,e){let s="";return y(t)?(s=`Binary data of length ${t.byteLength}`,e&&(s+=`. Content: '${function(t){const e=new Uint8Array(t);let s="";return e.forEach((t=>{s+=`0x${t<16?"0":""}${t.toString(16)} `})),s.substr(0,s.length-1)}(t)}'`)):"string"==typeof t&&(s=`String data of length ${t.length}`,e&&(s+=`. Content: '${t}'`)),s}function y(t){return t&&"undefined"!=typeof ArrayBuffer&&(t instanceof ArrayBuffer||t.constructor&&"ArrayBuffer"===t.constructor.name)}async function b(t,s,n,i,r,o){const h={},[c,a]=$();h[c]=a,t.log(e.Trace,`(${s} transport) sending data. ${m(r,o.logMessageContent)}.`);const l=y(r)?"arraybuffer":"text",u=await n.post(i,{content:r,headers:{...h,...o.headers},responseType:l,timeout:o.timeout,withCredentials:o.withCredentials});t.log(e.Trace,`(${s} transport) request complete. Response status: ${u.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 E{constructor(t){this.l=t,this.out=console}log(t,s){if(t>=this.l){const n=`[${(new Date).toISOString()}] ${e[t]}: ${s}`;switch(t){case e.Critical:case e.Error:this.out.error(n);break;case e.Warning:this.out.warn(n);break;case e.Information:this.out.info(n);break;default:this.out.log(n)}}}}function $(){let t="X-SignalR-User-Agent";return g.isNode&&(t="User-Agent"),[t,C(f,S(),g.isNode?"NodeJS":"Browser",k())]}function C(t,e,s,n){let i="Microsoft SignalR/";const r=t.split(".");return i+=`${r[0]}.${r[1]}`,i+=` (${t}; `,i+=e&&""!==e?`${e}; `:"Unknown OS; ",i+=`${s}`,i+=n?`; ${n}`:"; 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){super(),this.u=e,this.p=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")}()),this.m=AbortController,this.m}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 s=new this.m;let o;t.abortSignal&&(t.abortSignal.onabort=()=>{s.abort(),o=new r});let h,c=null;if(t.timeout){const n=t.timeout;c=setTimeout((()=>{s.abort(),this.u.log(e.Warning,"Timeout from HTTP request."),o=new i}),n)}""===t.content&&(t.content=void 0),t.content&&(t.headers=t.headers||{},y(t.content)?t.headers["Content-Type"]="application/octet-stream":t.headers["Content-Type"]="text/plain;charset=UTF-8");try{h=await this.p(t.url,{body:t.content,cache:"no-cache",credentials:!0===t.withCredentials?"include":"same-origin",headers:{"X-Requested-With":"XMLHttpRequest",...t.headers},method:t.method,mode:"cors",redirect:"follow",signal:s.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 n(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.v&&this.v.getCookies(t,((t,s)=>e=s.join("; "))),e}}function I(t,e){let s;switch(e){case"arraybuffer":s=t.arrayBuffer();break;case"text":default:s=t.text();break;case"blob":case"document":case"json":throw new Error(`${e} is not supported.`)}return s}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(((s,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"),""===t.content&&(t.content=void 0),t.content&&(y(t.content)?h.setRequestHeader("Content-Type","application/octet-stream"):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?s(new u(h.status,h.statusText,h.response||h.responseText)):o(new n(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 n(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,s;if(y(t)){const n=new Uint8Array(t),i=n.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(n.slice(0,r))),s=n.byteLength>r?n.slice(r).buffer:null}else{const n=t,i=n.indexOf(D.RecordSeparator);if(-1===i)throw new Error("Message is incomplete.");const r=i+1;e=n.substring(0,r),s=n.length>r?n.substring(r):null}const n=D.parse(e),i=JSON.parse(n[0]);if(i.type)throw new Error("Expected a handshake response from the server.");return[s,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 L{static create(t,e,s,n,i,r){return new L(t,e,s,n,i,r)}constructor(t,s,n,i,r,o){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://learn.microsoft.com/aspnet/core/signalr/javascript-client#bsleep")},w.isRequired(t,"connection"),w.isRequired(s,"logger"),w.isRequired(n,"protocol"),this.serverTimeoutInMilliseconds=null!=r?r:3e4,this.keepAliveIntervalInMilliseconds=null!=o?o:15e3,this.u=s,this.k=n,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.L=0,this.N=!1,this.M=A.Disconnected,this.j=!1,this.W=this.k.writeMessage({type:R.Ping})}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.q=this.O(),this.q}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.N=!1;const t=new Promise(((t,e)=>{this.X=t,this.J=e}));await this.connection.start(this.k.transferFormat);try{const s={protocol:this.k.name,version:this.k.version};if(this.u.log(e.Debug,"Sending handshake request."),await this.V(this.T.writeHandshakeRequest(s)),this.u.log(e.Information,`Using HubProtocol '${this.k.name}'.`),this.K(),this.G(),this.Y(),await t,this.B)throw this.B;this.connection.features.inherentKeepAlive||await this.V(this.W)}catch(t){throw this.u.log(e.Debug,`Hub handshake failed with error '${t}' during start(). Stopping HubConnection.`),this.K(),this.Z(),await this.connection.stop(t),t}}async stop(){const t=this.q;this.tt=this.et(),await this.tt;try{await t}catch(t){}}et(t){if(this.M===A.Disconnected)return this.u.log(e.Debug,`Call to HubConnection.stop(${t}) ignored because it is already in the disconnected state.`),Promise.resolve();if(this.M===A.Disconnecting)return this.u.log(e.Debug,`Call to HttpConnection.stop(${t}) ignored because the connection is already in the disconnecting state.`),this.tt;const s=this.M;return this.M=A.Disconnecting,this.u.log(e.Debug,"Stopping HubConnection."),this.st?(this.u.log(e.Debug,"Connection stopped during reconnect delay. Done reconnecting."),clearTimeout(this.st),this.st=void 0,this.nt(),Promise.resolve()):(s===A.Connected&&this.it(),this.K(),this.Z(),this.B=t||new r("The connection was stopped before the hub handshake could complete."),this.connection.stop(t))}async it(){try{await this.rt(this.ot())}catch{}}stream(t,...e){const[s,n]=this.ht(e),i=this.ct(t,e,n);let r;const o=new U;return o.cancelCallback=()=>{const t=this.lt(i.invocationId);return delete this.H[i.invocationId],r.then((()=>this.rt(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.rt(i).catch((t=>{o.error(t),delete this.H[i.invocationId]})),this.ut(s,r),o}V(t){return this.Y(),this.connection.send(t)}rt(t){return this.V(this.k.writeMessage(t))}send(t,...e){const[s,n]=this.ht(e),i=this.rt(this.dt(t,e,!0,n));return this.ut(s,i),i}invoke(t,...e){const[s,n]=this.ht(e),i=this.dt(t,e,!1,n);return new Promise(((t,e)=>{this.H[i.invocationId]=(s,n)=>{n?e(n):s&&(s.type===R.Completion?s.error?e(new Error(s.error)):t(s.result):e(new Error(`Unexpected message type: ${s.type}`)))};const n=this.rt(i).catch((t=>{e(t),delete this.H[i.invocationId]}));this.ut(s,n)}))}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 s=this.D[t];if(s)if(e){const n=s.indexOf(e);-1!==n&&(s.splice(n,1),0===s.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.K(),this.N||(t=this.ft(t),this.N=!0),t){const s=this.k.parseMessages(t,this.u);for(const t of s)switch(t.type){case R.Invocation:this.wt(t);break;case R.StreamItem:case R.Completion:{const s=this.H[t.invocationId];if(s){t.type===R.Completion&&delete this.H[t.invocationId];try{s(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 s=t.error?new Error("Server returned an error on close: "+t.error):void 0;!0===t.allowReconnect?this.connection.stop(s):this.tt=this.et(s);break}default:this.u.log(e.Warning,`Invalid message type: ${t.type}.`)}}this.G()}ft(t){let s,n;try{[n,s]=this.T.parseHandshakeResponse(t)}catch(t){const s="Error parsing handshake response: "+t;this.u.log(e.Error,s);const n=new Error(s);throw this.J(n),n}if(s.error){const t="Server returned handshake error: "+s.error;this.u.log(e.Error,t);const n=new Error(t);throw this.J(n),n}return this.u.log(e.Debug,"Server handshake complete."),this.X(),n}Y(){this.connection.features.inherentKeepAlive||(this.C=(new Date).getTime()+this.keepAliveIntervalInMilliseconds,this.Z())}G(){if(!(this.connection.features&&this.connection.features.inherentKeepAlive||(this.gt=setTimeout((()=>this.serverTimeout()),this.serverTimeoutInMilliseconds),void 0!==this.yt))){let t=this.C-(new Date).getTime();t<0&&(t=0),this.yt=setTimeout((async()=>{if(this.M===A.Connected)try{await this.V(this.W)}catch{this.Z()}}),t)}}serverTimeout(){this.connection.stop(new Error("Server timeout elapsed without receiving a message from the server."))}async wt(t){const s=t.target.toLowerCase(),n=this.D[s];if(!n)return this.u.log(e.Warning,`No client method with the name '${s}' found.`),void(t.invocationId&&(this.u.log(e.Warning,`No result given for '${s}' method and invocation ID '${t.invocationId}'.`),await this.rt(this.bt(t.invocationId,"Client didn't provide a result.",null))));const i=n.slice(),r=!!t.invocationId;let o,h,c;for(const n of i)try{const i=o;o=await n.apply(this,t.arguments),r&&o&&i&&(this.u.log(e.Error,`Multiple results provided for '${s}'. Sending error to server.`),c=this.bt(t.invocationId,"Client provided multiple results.",null)),h=void 0}catch(t){h=t,this.u.log(e.Error,`A callback for the method '${s}' threw error '${t}'.`)}c?await this.rt(c):r?(h?c=this.bt(t.invocationId,`${h}`,null):void 0!==o?c=this.bt(t.invocationId,null,o):(this.u.log(e.Warning,`No result given for '${s}' method and invocation ID '${t.invocationId}'.`),c=this.bt(t.invocationId,"Client didn't provide a result.",null)),await this.rt(c)):o&&this.u.log(e.Error,`Result given for '${s}' 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.vt(t||new Error("Invocation canceled due to the underlying connection being closed.")),this.K(),this.Z(),this.M===A.Disconnecting?this.nt(t):this.M===A.Connected&&this.P?this.Et(t):this.M===A.Connected&&this.nt(t)}nt(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(s){this.u.log(e.Error,`An onclose callback called with error '${t}' threw error '${s}'.`)}}}async Et(t){const s=Date.now();let n=0,i=void 0!==t?t:new Error("Attempting to reconnect due to a unknown error."),r=this.$t(n++,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.nt(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(s){this.u.log(e.Error,`An onreconnecting callback called with error '${t}' threw error '${s}'.`)}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 ${n} will start in ${r} ms.`),await new Promise((t=>{this.st=setTimeout(t,r)})),this.st=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.nt());i=t instanceof Error?t:new Error(t.toString()),r=this.$t(n++,Date.now()-s,i)}}this.u.log(e.Information,`Reconnect retries have been exhausted after ${Date.now()-s} ms and ${n} failed attempts. Connection disconnecting.`),this.nt()}$t(t,s,n){try{return this.P.nextRetryDelayInMilliseconds({elapsedMilliseconds:s,previousRetryCount:t,retryReason:n})}catch(n){return this.u.log(e.Error,`IRetryPolicy.nextRetryDelayInMilliseconds(${t}, ${s}) threw error '${n}'.`),null}}vt(t){const s=this.H;this.H={},Object.keys(s).forEach((n=>{const i=s[n];try{i(null,t)}catch(s){this.u.log(e.Error,`Stream 'error' callback called with '${t}' threw error: ${P(s)}`)}}))}Z(){this.yt&&(clearTimeout(this.yt),this.yt=void 0)}K(){this.gt&&clearTimeout(this.gt)}dt(t,e,s,n){if(s)return 0!==n.length?{arguments:e,streamIds:n,target:t,type:R.Invocation}:{arguments:e,target:t,type:R.Invocation};{const s=this.L;return this.L++,0!==n.length?{arguments:e,invocationId:s.toString(),streamIds:n,target:t,type:R.Invocation}:{arguments:e,invocationId:s.toString(),target:t,type:R.Invocation}}}ut(t,e){if(0!==t.length){e||(e=Promise.resolve());for(const s in t)t[s].subscribe({complete:()=>{e=e.then((()=>this.rt(this.bt(s))))},error:t=>{let n;n=t instanceof Error?t.message:t&&t.toString?t.toString():"Unknown error",e=e.then((()=>this.rt(this.bt(s,n))))},next:t=>{e=e.then((()=>this.rt(this.Ct(s,t))))}})}}ht(t){const e=[],s=[];for(let n=0;n<t.length;n++){const i=t[n];if(this.St(i)){const r=this.L;this.L++,e[r]=i,s.push(r.toString()),t.splice(n,1)}}return[e,s]}St(t){return t&&t.subscribe&&"function"==typeof t.subscribe}ct(t,e,s){const n=this.L;return this.L++,0!==s.length?{arguments:e,invocationId:n.toString(),streamIds:s,target:t,type:R.StreamInvocation}:{arguments:e,invocationId:n.toString(),target:t,type:R.StreamInvocation}}lt(t){return{invocationId:t,type:R.CancelInvocation}}Ct(t,e){return{invocationId:t,item:e,type:R.StreamItem}}bt(t,e,s){return e?{error:e,invocationId:t,type:R.Completion}:{invocationId:t,result:s,type:R.Completion}}ot(){return{type:R.Close}}}const N=[0,2e3,1e4,3e4,null];class M{constructor(t){this.kt=void 0!==t?[...t,null]:N}nextRetryDelayInMilliseconds(t){return this.kt[t.previousRetryCount]}}class j{}j.Authorization="Authorization",j.Cookie="Cookie";class W extends d{constructor(t,e){super(),this.Pt=t,this.Tt=e}async send(t){let e=!0;this.Tt&&(!this.It||t.url&&t.url.indexOf("/negotiate?")>0)&&(e=!1,this.It=await this.Tt()),this._t(t);const s=await this.Pt.send(t);return e&&401===s.statusCode&&this.Tt?(this.It=await this.Tt(),this._t(t),await this.Pt.send(t)):s}_t(t){t.headers||(t.headers={}),this.It?t.headers[j.Authorization]=`Bearer ${this.It}`:this.Tt&&t.headers[j.Authorization]&&delete t.headers[j.Authorization]}getCookieString(t){return this.Pt.getCookieString(t)}}var q,O;!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"}(O||(O={}));class F{constructor(){this.Ht=!1,this.onabort=null}abort(){this.Ht||(this.Ht=!0,this.onabort&&this.onabort())}get signal(){return this}get aborted(){return this.Ht}}class B{get pollAborted(){return this.Dt.aborted}constructor(t,e,s){this.$=t,this.u=e,this.Dt=new F,this.xt=s,this.Rt=!1,this.onreceive=null,this.onclose=null}async connect(t,s){if(w.isRequired(t,"url"),w.isRequired(s,"transferFormat"),w.isIn(s,O,"transferFormat"),this.At=t,this.u.log(e.Trace,"(LongPolling transport) Connecting."),s===O.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]=$(),o={[i]:r,...this.xt.headers},h={abortSignal:this.Dt.signal,headers:o,timeout:1e5,withCredentials:this.xt.withCredentials};s===O.Binary&&(h.responseType="arraybuffer");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.Ut=new n(a.statusText||"",a.statusCode),this.Rt=!1):this.Rt=!0,this.Lt=this.Nt(this.At,h)}async Nt(t,s){try{for(;this.Rt;)try{const i=`${t}&_=${Date.now()}`;this.u.log(e.Trace,`(LongPolling transport) polling: ${i}.`);const r=await this.$.get(i,s);204===r.statusCode?(this.u.log(e.Information,"(LongPolling transport) Poll terminated by server."),this.Rt=!1):200!==r.statusCode?(this.u.log(e.Error,`(LongPolling transport) Unexpected response code: ${r.statusCode}.`),this.Ut=new n(r.statusText||"",r.statusCode),this.Rt=!1):r.content?(this.u.log(e.Trace,`(LongPolling transport) data received. ${m(r.content,this.xt.logMessageContent)}.`),this.onreceive&&this.onreceive(r.content)):this.u.log(e.Trace,"(LongPolling transport) Poll timed out, reissuing.")}catch(t){this.Rt?t instanceof i?this.u.log(e.Trace,"(LongPolling transport) Poll timed out, reissuing."):(this.Ut=t,this.Rt=!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.Mt()}}async send(t){return this.Rt?b(this.u,"LongPolling",this.$,this.At,t,this.xt):Promise.reject(new Error("Cannot send until the transport is connected"))}async stop(){this.u.log(e.Trace,"(LongPolling transport) Stopping polling."),this.Rt=!1,this.Dt.abort();try{await this.Lt,this.u.log(e.Trace,`(LongPolling transport) sending DELETE request to ${this.At}.`);const t={},[s,i]=$();t[s]=i;const r={headers:{...t,...this.xt.headers},timeout:this.xt.timeout,withCredentials:this.xt.withCredentials};let o;try{await this.$.delete(this.At,r)}catch(t){o=t}o?o instanceof n&&(404===o.statusCode?this.u.log(e.Trace,"(LongPolling transport) A 404 response was returned from sending a DELETE request."):this.u.log(e.Trace,`(LongPolling transport) Error sending a DELETE request: ${o}`)):this.u.log(e.Trace,"(LongPolling transport) DELETE request accepted.")}finally{this.u.log(e.Trace,"(LongPolling transport) Stop finished."),this.Mt()}}Mt(){if(this.onclose){let t="(LongPolling transport) Firing onclose event.";this.Ut&&(t+=" Error: "+this.Ut),this.u.log(e.Trace,t),this.onclose(this.Ut)}}}class X{constructor(t,e,s,n){this.$=t,this.It=e,this.u=s,this.xt=n,this.onreceive=null,this.onclose=null}async connect(t,s){return w.isRequired(t,"url"),w.isRequired(s,"transferFormat"),w.isIn(s,O,"transferFormat"),this.u.log(e.Trace,"(SSE transport) Connecting."),this.At=t,this.It&&(t+=(t.indexOf("?")<0?"?":"&")+`access_token=${encodeURIComponent(this.It)}`),new Promise(((n,i)=>{let r,o=!1;if(s===O.Text){if(g.isBrowser||g.isWebWorker)r=new this.xt.EventSource(t,{withCredentials:this.xt.withCredentials});else{const e=this.$.getCookieString(t),s={};s.Cookie=e;const[n,i]=$();s[n]=i,r=new this.xt.EventSource(t,{withCredentials:this.xt.withCredentials,headers:{...s,...this.xt.headers}})}try{r.onmessage=t=>{if(this.onreceive)try{this.u.log(e.Trace,`(SSE transport) data received. ${m(t.data,this.xt.logMessageContent)}.`),this.onreceive(t.data)}catch(t){return void this.jt(t)}},r.onerror=t=>{o?this.jt():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.At}`),this.Wt=r,o=!0,n()}}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.Wt?b(this.u,"SSE",this.$,this.At,t,this.xt):Promise.reject(new Error("Cannot send until the transport is connected"))}stop(){return this.jt(),Promise.resolve()}jt(t){this.Wt&&(this.Wt.close(),this.Wt=void 0,this.onclose&&this.onclose(t))}}class J{constructor(t,e,s,n,i,r){this.u=s,this.Tt=e,this.qt=n,this.Ot=i,this.$=t,this.onreceive=null,this.onclose=null,this.Ft=r}async connect(t,s){let n;return w.isRequired(t,"url"),w.isRequired(s,"transferFormat"),w.isIn(s,O,"transferFormat"),this.u.log(e.Trace,"(WebSockets transport) Connecting."),this.Tt&&(n=await this.Tt()),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={},[s,i]=$();e[s]=i,n&&(e[j.Authorization]=`Bearer ${n}`),h&&(e[j.Cookie]=h),o=new this.Ot(t,void 0,{headers:{...e,...this.Ft}})}else n&&(t+=(t.indexOf("?")<0?"?":"&")+`access_token=${encodeURIComponent(n)}`);o||(o=new this.Ot(t)),s===O.Binary&&(o.binaryType="arraybuffer"),o.onopen=s=>{this.u.log(e.Information,`WebSocket connected to ${t}.`),this.Bt=o,c=!0,i()},o.onerror=t=>{let s=null;s="undefined"!=typeof ErrorEvent&&t instanceof ErrorEvent?t.error:"There was an error with the transport",this.u.log(e.Information,`(WebSockets transport) ${s}.`)},o.onmessage=t=>{if(this.u.log(e.Trace,`(WebSockets transport) data received. ${m(t.data,this.qt)}.`),this.onreceive)try{this.onreceive(t.data)}catch(t){return void this.jt(t)}},o.onclose=t=>{if(c)this.jt(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.Bt&&this.Bt.readyState===this.Ot.OPEN?(this.u.log(e.Trace,`(WebSockets transport) sending data. ${m(t,this.qt)}.`),this.Bt.send(t),Promise.resolve()):Promise.reject("WebSocket is not in the OPEN state")}stop(){return this.Bt&&this.jt(void 0),Promise.resolve()}jt(t){this.Bt&&(this.Bt.onclose=()=>{},this.Bt.onmessage=()=>{},this.Bt.onerror=()=>{},this.Bt.close(),this.Bt=void 0),this.u.log(e.Trace,"(WebSockets transport) socket closed."),this.onclose&&(!this.Xt(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"}).`)))}Xt(t){return t&&"boolean"==typeof t.wasClean&&"number"==typeof t.code}}class z{constructor(t,s={}){var n;if(this.Jt=()=>{},this.features={},this.zt=1,w.isRequired(t,"url"),this.u=void 0===(n=s.logger)?new E(e.Information):null===n?p.instance:void 0!==n.log?n:new E(n),this.baseUrl=this.Vt(t),(s=s||{}).logMessageContent=void 0!==s.logMessageContent&&s.logMessageContent,"boolean"!=typeof s.withCredentials&&void 0!==s.withCredentials)throw new Error("withCredentials option was not a 'boolean' or 'undefined' value");s.withCredentials=void 0===s.withCredentials||s.withCredentials,s.timeout=void 0===s.timeout?1e5:s.timeout;let i=null,r=null;g.isNode&&(i=function(){throw new Error("Trying to import 'ws' in the browser.")}(),r=function(){throw new Error("Trying to import 'eventsource' in the browser.")}()),g.isNode||"undefined"==typeof WebSocket||s.WebSocket?g.isNode&&!s.WebSocket&&i&&(s.WebSocket=i):s.WebSocket=WebSocket,g.isNode||"undefined"==typeof EventSource||s.EventSource?g.isNode&&!s.EventSource&&void 0!==r&&(s.EventSource=r):s.EventSource=EventSource,this.$=new W(s.httpClient||new H(this.u),s.accessTokenFactory),this.M="Disconnected",this.j=!1,this.xt=s,this.onreceive=null,this.onclose=null}async start(t){if(t=t||O.Binary,w.isIn(t,O,"transferFormat"),this.u.log(e.Debug,`Starting connection with transfer format '${O[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.Kt=this.F(t),await this.Kt,"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.Gt||(this.Gt=new V(this.transport)),this.Gt.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.Jt=t})),await this.et(t),void await this.tt)}async et(t){this.Qt=t;try{await this.Kt}catch(t){}if(this.transport){try{await this.transport.stop()}catch(t){this.u.log(e.Error,`HttpConnection.transport.stop() threw error '${t}'.`),this.Yt()}this.transport=void 0}else this.u.log(e.Debug,"HttpConnection.transport is undefined in HttpConnection.stop() because start() failed.")}async F(t){let s=this.baseUrl;this.Tt=this.xt.accessTokenFactory,this.$.Tt=this.Tt;try{if(this.xt.skipNegotiation){if(this.xt.transport!==q.WebSockets)throw new Error("Negotiation can only be skipped when using the WebSocket transport directly.");this.transport=this.Zt(q.WebSockets),await this.te(s,t)}else{let e=null,n=0;do{if(e=await this.ee(s),"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&&(s=e.url),e.accessToken){const t=e.accessToken;this.Tt=()=>t,this.$.It=t,this.$.Tt=void 0}n++}while(e.url&&n<100);if(100===n&&e.url)throw new Error("Negotiate redirection limit exceeded.");await this.se(s,this.xt.transport,e,t)}this.transport instanceof B&&(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.Jt(),Promise.reject(t)}}async ee(t){const s={},[i,r]=$();s[i]=r;const o=this.ne(t);this.u.log(e.Debug,`Sending negotiation request: ${o}.`);try{const t=await this.$.post(o,{content:"",headers:{...s,...this.xt.headers},timeout:this.xt.timeout,withCredentials:this.xt.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 s="Failed to complete negotiation with the server: "+t;return t instanceof n&&404===t.statusCode&&(s+=" Either this is not a SignalR endpoint or there is a proxy blocking the connection."),this.u.log(e.Error,s),Promise.reject(new a(s))}}ie(t,e){return e?t+(-1===t.indexOf("?")?"?":"&")+`id=${e}`:t}async se(t,s,n,i){let o=this.ie(t,n.connectionToken);if(this.re(s))return this.u.log(e.Debug,"Connection was provided an instance of ITransport, using that directly."),this.transport=s,await this.te(o,i),void(this.connectionId=n.connectionId);const h=[],a=n.availableTransports||[];let u=n;for(const n of a){const a=this.oe(n,s,i);if(a instanceof Error)h.push(`${n.transport} failed:`),h.push(a);else if(this.re(a)){if(this.transport=a,!u){try{u=await this.ee(t)}catch(t){return Promise.reject(t)}o=this.ie(t,u.connectionToken)}try{return await this.te(o,i),void(this.connectionId=u.connectionId)}catch(t){if(this.u.log(e.Error,`Failed to start the transport '${n.transport}': ${t}`),u=void 0,h.push(new c(`${n.transport} failed: ${t}`,q[n.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."))}Zt(t){switch(t){case q.WebSockets:if(!this.xt.WebSocket)throw new Error("'WebSocket' is not supported in your environment.");return new J(this.$,this.Tt,this.u,this.xt.logMessageContent,this.xt.WebSocket,this.xt.headers||{});case q.ServerSentEvents:if(!this.xt.EventSource)throw new Error("'EventSource' is not supported in your environment.");return new X(this.$,this.$.It,this.u,this.xt);case q.LongPolling:return new B(this.$,this.u,this.xt);default:throw new Error(`Unknown transport: ${t}.`)}}te(t,e){return this.transport.onreceive=this.onreceive,this.transport.onclose=t=>this.Yt(t),this.transport.connect(t,e)}oe(t,s,n){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)}(s,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=>O[t])).indexOf(n)>=0))return this.u.log(e.Debug,`Skipping transport '${q[i]}' because it does not support the requested transfer format '${O[n]}'.`),new Error(`'${q[i]}' does not support ${O[n]}.`);if(i===q.WebSockets&&!this.xt.WebSocket||i===q.ServerSentEvents&&!this.xt.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.Zt(i)}catch(t){return t}}re(t){return t&&"object"==typeof t&&"connect"in t}Yt(t){if(this.u.log(e.Debug,`HttpConnection.stopConnection(${t}) called while in state ${this.M}.`),this.transport=void 0,t=this.Qt||t,this.Qt=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.Jt(),t?this.u.log(e.Error,`Connection disconnected with error '${t}'.`):this.u.log(e.Information,"Connection disconnected."),this.Gt&&(this.Gt.stop().catch((t=>{this.u.log(e.Error,`TransportSendQueue.stop() threw error '${t}'.`)})),this.Gt=void 0),this.connectionId=void 0,this.M="Disconnected",this.j){this.j=!1;try{this.onclose&&this.onclose(t)}catch(s){this.u.log(e.Error,`HttpConnection.onclose(${t}) threw error '${s}'.`)}}}else this.u.log(e.Debug,`Call to HttpConnection.stopConnection(${t}) was ignored because the connection is already in the disconnected state.`)}Vt(t){if(0===t.lastIndexOf("https://",0)||0===t.lastIndexOf("http://",0))return t;if(!g.isBrowser)throw new Error(`Cannot resolve '${t}'.`);const s=window.document.createElement("a");return s.href=t,this.u.log(e.Information,`Normalizing '${t}' to '${s.href}'.`),s.href}ne(t){const e=t.indexOf("?");let s=t.substring(0,-1===e?t.length:e);return"/"!==s[s.length-1]&&(s+="/"),s+="negotiate",s+=-1===e?"":t.substring(e),-1===s.indexOf("negotiateVersion")&&(s+=-1===e?"?":"&",s+="negotiateVersion="+this.zt),s}}class V{constructor(t){this.he=t,this.ce=[],this.ae=!0,this.le=new K,this.ue=new K,this.de=this.pe()}send(t){return this.fe(t),this.ue||(this.ue=new K),this.ue.promise}stop(){return this.ae=!1,this.le.resolve(),this.de}fe(t){if(this.ce.length&&typeof this.ce[0]!=typeof t)throw new Error(`Expected data to be of type ${typeof this.ce} but was of type ${typeof t}`);this.ce.push(t),this.le.resolve()}async pe(){for(;;){if(await this.le.promise,!this.ae){this.ue&&this.ue.reject("Connection stopped.");break}this.le=new K;const t=this.ue;this.ue=void 0;const e="string"==typeof this.ce[0]?this.ce.join(""):V.we(this.ce);this.ce.length=0;try{await this.he.send(e),t.resolve()}catch(e){t.reject(e)}}}static we(t){const e=t.map((t=>t.byteLength)).reduce(((t,e)=>t+e)),s=new Uint8Array(e);let n=0;for(const e of t)s.set(new Uint8Array(e),n),n+=e.byteLength;return s.buffer}}class K{constructor(){this.promise=new Promise(((t,e)=>[this.ge,this.me]=[t,e]))}resolve(){this.ge()}reject(t){this.me(t)}}class G{constructor(){this.name="json",this.version=1,this.transferFormat=O.Text}parseMessages(t,s){if("string"!=typeof t)throw new Error("Invalid input for JSON hub protocol. Expected a string.");if(!t)return[];null===s&&(s=p.instance);const n=D.parse(t),i=[];for(const t of n){const n=JSON.parse(t);if("number"!=typeof n.type)throw new Error("Invalid payload.");switch(n.type){case R.Invocation:this.ye(n);break;case R.StreamItem:this.be(n);break;case R.Completion:this.ve(n);break;case R.Ping:case R.Close:break;default:s.log(e.Information,"Unknown message type '"+n.type+"' ignored.");continue}i.push(n)}return i}writeMessage(t){return D.write(JSON.stringify(t))}ye(t){this.Ee(t.target,"Invalid payload for Invocation message."),void 0!==t.invocationId&&this.Ee(t.invocationId,"Invalid payload for Invocation message.")}be(t){if(this.Ee(t.invocationId,"Invalid payload for StreamItem message."),void 0===t.item)throw new Error("Invalid payload for StreamItem message.")}ve(t){if(t.result&&t.error)throw new Error("Invalid payload for Completion message.");!t.result&&t.error&&this.Ee(t.error,"Invalid payload for Completion message."),this.Ee(t.invocationId,"Invalid payload for Completion message.")}Ee(t,e){if("string"!=typeof t||""===t)throw new Error(e)}}const Q={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 Y{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=Q[t.toLowerCase()];if(void 0!==e)return e;throw new Error(`Unknown log level: ${t}`)}(t);this.logger=new E(e)}else this.logger=new E(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}withServerTimeout(t){return w.isRequired(t,"milliseconds"),this.$e=t,this}withKeepAliveInterval(t){return w.isRequired(t,"milliseconds"),this.Ce=t,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 z(this.url,t);return L.create(e,this.logger||p.instance,this.protocol||new G,this.reconnectPolicy,this.$e,this.Ce)}}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}),s})(),"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=()=>(()=>{var t={d:(e,s)=>{for(var n in s)t.o(s,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:s[n]})}};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,s={};t.r(s),t.d(s,{AbortError:()=>r,DefaultHttpClient:()=>H,HttpClient:()=>d,HttpError:()=>n,HttpResponse:()=>u,HttpTransportType:()=>q,HubConnection:()=>L,HubConnectionBuilder:()=>Y,HubConnectionState:()=>A,JsonHubProtocol:()=>G,LogLevel:()=>e,MessageType:()=>R,NullLogger:()=>p,Subject:()=>U,TimeoutError:()=>i,TransferFormat:()=>O,VERSION:()=>f});class n extends Error{constructor(t,e){const s=new.target.prototype;super(`${t}: Status code '${e}'`),this.statusCode=e,this.__proto__=s}}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 s=new.target.prototype;super(t),this.transport=e,this.errorType="UnsupportedTransportError",this.__proto__=s}}class h extends Error{constructor(t,e){const s=new.target.prototype;super(t),this.transport=e,this.errorType="DisabledTransportError",this.__proto__=s}}class c extends Error{constructor(t,e){const s=new.target.prototype;super(t),this.transport=e,this.errorType="FailedToStartTransportError",this.__proto__=s}}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 s=new.target.prototype;super(t),this.innerErrors=e,this.__proto__=s}}class u{constructor(t,e,s){this.statusCode=t,this.statusText=e,this.content=s}}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 p{constructor(){}log(t,e){}}p.instance=new p;const f="8.0.0-rc.1.23421.29";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,s){if(!(t in e))throw new Error(`Unknown ${s} value: ${t}.`)}}class g{static get isBrowser(){return!g.isNode&&"object"==typeof window&&"object"==typeof window.document}static get isWebWorker(){return!g.isNode&&"object"==typeof self&&"importScripts"in self}static get isReactNative(){return!g.isNode&&"object"==typeof window&&void 0===window.document}static get isNode(){return"undefined"!=typeof process&&process.release&&"node"===process.release.name}}function m(t,e){let s="";return y(t)?(s=`Binary data of length ${t.byteLength}`,e&&(s+=`. Content: '${function(t){const e=new Uint8Array(t);let s="";return e.forEach((t=>{s+=`0x${t<16?"0":""}${t.toString(16)} `})),s.substr(0,s.length-1)}(t)}'`)):"string"==typeof t&&(s=`String data of length ${t.length}`,e&&(s+=`. Content: '${t}'`)),s}function y(t){return t&&"undefined"!=typeof ArrayBuffer&&(t instanceof ArrayBuffer||t.constructor&&"ArrayBuffer"===t.constructor.name)}async function b(t,s,n,i,r,o){const h={},[c,a]=$();h[c]=a,t.log(e.Trace,`(${s} transport) sending data. ${m(r,o.logMessageContent)}.`);const l=y(r)?"arraybuffer":"text",u=await n.post(i,{content:r,headers:{...h,...o.headers},responseType:l,timeout:o.timeout,withCredentials:o.withCredentials});t.log(e.Trace,`(${s} transport) request complete. Response status: ${u.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 E{constructor(t){this.l=t,this.out=console}log(t,s){if(t>=this.l){const n=`[${(new Date).toISOString()}] ${e[t]}: ${s}`;switch(t){case e.Critical:case e.Error:this.out.error(n);break;case e.Warning:this.out.warn(n);break;case e.Information:this.out.info(n);break;default:this.out.log(n)}}}}function $(){let t="X-SignalR-User-Agent";return g.isNode&&(t="User-Agent"),[t,C(f,S(),g.isNode?"NodeJS":"Browser",k())]}function C(t,e,s,n){let i="Microsoft SignalR/";const r=t.split(".");return i+=`${r[0]}.${r[1]}`,i+=` (${t}; `,i+=e&&""!==e?`${e}; `:"Unknown OS; ",i+=`${s}`,i+=n?`; ${n}`:"; 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){super(),this.u=e,this.p=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")}()),this.m=AbortController,this.m}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 s=new this.m;let o;t.abortSignal&&(t.abortSignal.onabort=()=>{s.abort(),o=new r});let h,c=null;if(t.timeout){const n=t.timeout;c=setTimeout((()=>{s.abort(),this.u.log(e.Warning,"Timeout from HTTP request."),o=new i}),n)}""===t.content&&(t.content=void 0),t.content&&(t.headers=t.headers||{},y(t.content)?t.headers["Content-Type"]="application/octet-stream":t.headers["Content-Type"]="text/plain;charset=UTF-8");try{h=await this.p(t.url,{body:t.content,cache:"no-cache",credentials:!0===t.withCredentials?"include":"same-origin",headers:{"X-Requested-With":"XMLHttpRequest",...t.headers},method:t.method,mode:"cors",redirect:"follow",signal:s.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 n(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.v&&this.v.getCookies(t,((t,s)=>e=s.join("; "))),e}}function I(t,e){let s;switch(e){case"arraybuffer":s=t.arrayBuffer();break;case"text":default:s=t.text();break;case"blob":case"document":case"json":throw new Error(`${e} is not supported.`)}return s}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(((s,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"),""===t.content&&(t.content=void 0),t.content&&(y(t.content)?h.setRequestHeader("Content-Type","application/octet-stream"):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?s(new u(h.status,h.statusText,h.response||h.responseText)):o(new n(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 n(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,s;if(y(t)){const n=new Uint8Array(t),i=n.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(n.slice(0,r))),s=n.byteLength>r?n.slice(r).buffer:null}else{const n=t,i=n.indexOf(D.RecordSeparator);if(-1===i)throw new Error("Message is incomplete.");const r=i+1;e=n.substring(0,r),s=n.length>r?n.substring(r):null}const n=D.parse(e),i=JSON.parse(n[0]);if(i.type)throw new Error("Expected a handshake response from the server.");return[s,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 L{static create(t,e,s,n,i,r){return new L(t,e,s,n,i,r)}constructor(t,s,n,i,r,o){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://learn.microsoft.com/aspnet/core/signalr/javascript-client#bsleep")},w.isRequired(t,"connection"),w.isRequired(s,"logger"),w.isRequired(n,"protocol"),this.serverTimeoutInMilliseconds=null!=r?r:3e4,this.keepAliveIntervalInMilliseconds=null!=o?o:15e3,this.u=s,this.k=n,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.L=0,this.N=!1,this.M=A.Disconnected,this.j=!1,this.W=this.k.writeMessage({type:R.Ping})}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.q=this.O(),this.q}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.N=!1;const t=new Promise(((t,e)=>{this.X=t,this.J=e}));await this.connection.start(this.k.transferFormat);try{const s={protocol:this.k.name,version:this.k.version};if(this.u.log(e.Debug,"Sending handshake request."),await this.V(this.T.writeHandshakeRequest(s)),this.u.log(e.Information,`Using HubProtocol '${this.k.name}'.`),this.K(),this.G(),this.Y(),await t,this.B)throw this.B;this.connection.features.inherentKeepAlive||await this.V(this.W)}catch(t){throw this.u.log(e.Debug,`Hub handshake failed with error '${t}' during start(). Stopping HubConnection.`),this.K(),this.Z(),await this.connection.stop(t),t}}async stop(){const t=this.q;this.tt=this.et(),await this.tt;try{await t}catch(t){}}et(t){if(this.M===A.Disconnected)return this.u.log(e.Debug,`Call to HubConnection.stop(${t}) ignored because it is already in the disconnected state.`),Promise.resolve();if(this.M===A.Disconnecting)return this.u.log(e.Debug,`Call to HttpConnection.stop(${t}) ignored because the connection is already in the disconnecting state.`),this.tt;const s=this.M;return this.M=A.Disconnecting,this.u.log(e.Debug,"Stopping HubConnection."),this.st?(this.u.log(e.Debug,"Connection stopped during reconnect delay. Done reconnecting."),clearTimeout(this.st),this.st=void 0,this.nt(),Promise.resolve()):(s===A.Connected&&this.it(),this.K(),this.Z(),this.B=t||new r("The connection was stopped before the hub handshake could complete."),this.connection.stop(t))}async it(){try{await this.rt(this.ot())}catch{}}stream(t,...e){const[s,n]=this.ht(e),i=this.ct(t,e,n);let r;const o=new U;return o.cancelCallback=()=>{const t=this.lt(i.invocationId);return delete this.H[i.invocationId],r.then((()=>this.rt(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.rt(i).catch((t=>{o.error(t),delete this.H[i.invocationId]})),this.ut(s,r),o}V(t){return this.Y(),this.connection.send(t)}rt(t){return this.V(this.k.writeMessage(t))}send(t,...e){const[s,n]=this.ht(e),i=this.rt(this.dt(t,e,!0,n));return this.ut(s,i),i}invoke(t,...e){const[s,n]=this.ht(e),i=this.dt(t,e,!1,n);return new Promise(((t,e)=>{this.H[i.invocationId]=(s,n)=>{n?e(n):s&&(s.type===R.Completion?s.error?e(new Error(s.error)):t(s.result):e(new Error(`Unexpected message type: ${s.type}`)))};const n=this.rt(i).catch((t=>{e(t),delete this.H[i.invocationId]}));this.ut(s,n)}))}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 s=this.D[t];if(s)if(e){const n=s.indexOf(e);-1!==n&&(s.splice(n,1),0===s.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.K(),this.N||(t=this.ft(t),this.N=!0),t){const s=this.k.parseMessages(t,this.u);for(const t of s)switch(t.type){case R.Invocation:this.wt(t);break;case R.StreamItem:case R.Completion:{const s=this.H[t.invocationId];if(s){t.type===R.Completion&&delete this.H[t.invocationId];try{s(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 s=t.error?new Error("Server returned an error on close: "+t.error):void 0;!0===t.allowReconnect?this.connection.stop(s):this.tt=this.et(s);break}default:this.u.log(e.Warning,`Invalid message type: ${t.type}.`)}}this.G()}ft(t){let s,n;try{[n,s]=this.T.parseHandshakeResponse(t)}catch(t){const s="Error parsing handshake response: "+t;this.u.log(e.Error,s);const n=new Error(s);throw this.J(n),n}if(s.error){const t="Server returned handshake error: "+s.error;this.u.log(e.Error,t);const n=new Error(t);throw this.J(n),n}return this.u.log(e.Debug,"Server handshake complete."),this.X(),n}Y(){this.connection.features.inherentKeepAlive||(this.C=(new Date).getTime()+this.keepAliveIntervalInMilliseconds,this.Z())}G(){if(!(this.connection.features&&this.connection.features.inherentKeepAlive||(this.gt=setTimeout((()=>this.serverTimeout()),this.serverTimeoutInMilliseconds),void 0!==this.yt))){let t=this.C-(new Date).getTime();t<0&&(t=0),this.yt=setTimeout((async()=>{if(this.M===A.Connected)try{await this.V(this.W)}catch{this.Z()}}),t)}}serverTimeout(){this.connection.stop(new Error("Server timeout elapsed without receiving a message from the server."))}async wt(t){const s=t.target.toLowerCase(),n=this.D[s];if(!n)return this.u.log(e.Warning,`No client method with the name '${s}' found.`),void(t.invocationId&&(this.u.log(e.Warning,`No result given for '${s}' method and invocation ID '${t.invocationId}'.`),await this.rt(this.bt(t.invocationId,"Client didn't provide a result.",null))));const i=n.slice(),r=!!t.invocationId;let o,h,c;for(const n of i)try{const i=o;o=await n.apply(this,t.arguments),r&&o&&i&&(this.u.log(e.Error,`Multiple results provided for '${s}'. Sending error to server.`),c=this.bt(t.invocationId,"Client provided multiple results.",null)),h=void 0}catch(t){h=t,this.u.log(e.Error,`A callback for the method '${s}' threw error '${t}'.`)}c?await this.rt(c):r?(h?c=this.bt(t.invocationId,`${h}`,null):void 0!==o?c=this.bt(t.invocationId,null,o):(this.u.log(e.Warning,`No result given for '${s}' method and invocation ID '${t.invocationId}'.`),c=this.bt(t.invocationId,"Client didn't provide a result.",null)),await this.rt(c)):o&&this.u.log(e.Error,`Result given for '${s}' 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.vt(t||new Error("Invocation canceled due to the underlying connection being closed.")),this.K(),this.Z(),this.M===A.Disconnecting?this.nt(t):this.M===A.Connected&&this.P?this.Et(t):this.M===A.Connected&&this.nt(t)}nt(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(s){this.u.log(e.Error,`An onclose callback called with error '${t}' threw error '${s}'.`)}}}async Et(t){const s=Date.now();let n=0,i=void 0!==t?t:new Error("Attempting to reconnect due to a unknown error."),r=this.$t(n++,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.nt(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(s){this.u.log(e.Error,`An onreconnecting callback called with error '${t}' threw error '${s}'.`)}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 ${n} will start in ${r} ms.`),await new Promise((t=>{this.st=setTimeout(t,r)})),this.st=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.nt());i=t instanceof Error?t:new Error(t.toString()),r=this.$t(n++,Date.now()-s,i)}}this.u.log(e.Information,`Reconnect retries have been exhausted after ${Date.now()-s} ms and ${n} failed attempts. Connection disconnecting.`),this.nt()}$t(t,s,n){try{return this.P.nextRetryDelayInMilliseconds({elapsedMilliseconds:s,previousRetryCount:t,retryReason:n})}catch(n){return this.u.log(e.Error,`IRetryPolicy.nextRetryDelayInMilliseconds(${t}, ${s}) threw error '${n}'.`),null}}vt(t){const s=this.H;this.H={},Object.keys(s).forEach((n=>{const i=s[n];try{i(null,t)}catch(s){this.u.log(e.Error,`Stream 'error' callback called with '${t}' threw error: ${P(s)}`)}}))}Z(){this.yt&&(clearTimeout(this.yt),this.yt=void 0)}K(){this.gt&&clearTimeout(this.gt)}dt(t,e,s,n){if(s)return 0!==n.length?{arguments:e,streamIds:n,target:t,type:R.Invocation}:{arguments:e,target:t,type:R.Invocation};{const s=this.L;return this.L++,0!==n.length?{arguments:e,invocationId:s.toString(),streamIds:n,target:t,type:R.Invocation}:{arguments:e,invocationId:s.toString(),target:t,type:R.Invocation}}}ut(t,e){if(0!==t.length){e||(e=Promise.resolve());for(const s in t)t[s].subscribe({complete:()=>{e=e.then((()=>this.rt(this.bt(s))))},error:t=>{let n;n=t instanceof Error?t.message:t&&t.toString?t.toString():"Unknown error",e=e.then((()=>this.rt(this.bt(s,n))))},next:t=>{e=e.then((()=>this.rt(this.Ct(s,t))))}})}}ht(t){const e=[],s=[];for(let n=0;n<t.length;n++){const i=t[n];if(this.St(i)){const r=this.L;this.L++,e[r]=i,s.push(r.toString()),t.splice(n,1)}}return[e,s]}St(t){return t&&t.subscribe&&"function"==typeof t.subscribe}ct(t,e,s){const n=this.L;return this.L++,0!==s.length?{arguments:e,invocationId:n.toString(),streamIds:s,target:t,type:R.StreamInvocation}:{arguments:e,invocationId:n.toString(),target:t,type:R.StreamInvocation}}lt(t){return{invocationId:t,type:R.CancelInvocation}}Ct(t,e){return{invocationId:t,item:e,type:R.StreamItem}}bt(t,e,s){return e?{error:e,invocationId:t,type:R.Completion}:{invocationId:t,result:s,type:R.Completion}}ot(){return{type:R.Close}}}const N=[0,2e3,1e4,3e4,null];class M{constructor(t){this.kt=void 0!==t?[...t,null]:N}nextRetryDelayInMilliseconds(t){return this.kt[t.previousRetryCount]}}class j{}j.Authorization="Authorization",j.Cookie="Cookie";class W extends d{constructor(t,e){super(),this.Pt=t,this.Tt=e}async send(t){let e=!0;this.Tt&&(!this.It||t.url&&t.url.indexOf("/negotiate?")>0)&&(e=!1,this.It=await this.Tt()),this._t(t);const s=await this.Pt.send(t);return e&&401===s.statusCode&&this.Tt?(this.It=await this.Tt(),this._t(t),await this.Pt.send(t)):s}_t(t){t.headers||(t.headers={}),this.It?t.headers[j.Authorization]=`Bearer ${this.It}`:this.Tt&&t.headers[j.Authorization]&&delete t.headers[j.Authorization]}getCookieString(t){return this.Pt.getCookieString(t)}}var q,O;!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"}(O||(O={}));class F{constructor(){this.Ht=!1,this.onabort=null}abort(){this.Ht||(this.Ht=!0,this.onabort&&this.onabort())}get signal(){return this}get aborted(){return this.Ht}}class B{get pollAborted(){return this.Dt.aborted}constructor(t,e,s){this.$=t,this.u=e,this.Dt=new F,this.xt=s,this.Rt=!1,this.onreceive=null,this.onclose=null}async connect(t,s){if(w.isRequired(t,"url"),w.isRequired(s,"transferFormat"),w.isIn(s,O,"transferFormat"),this.At=t,this.u.log(e.Trace,"(LongPolling transport) Connecting."),s===O.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]=$(),o={[i]:r,...this.xt.headers},h={abortSignal:this.Dt.signal,headers:o,timeout:1e5,withCredentials:this.xt.withCredentials};s===O.Binary&&(h.responseType="arraybuffer");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.Ut=new n(a.statusText||"",a.statusCode),this.Rt=!1):this.Rt=!0,this.Lt=this.Nt(this.At,h)}async Nt(t,s){try{for(;this.Rt;)try{const i=`${t}&_=${Date.now()}`;this.u.log(e.Trace,`(LongPolling transport) polling: ${i}.`);const r=await this.$.get(i,s);204===r.statusCode?(this.u.log(e.Information,"(LongPolling transport) Poll terminated by server."),this.Rt=!1):200!==r.statusCode?(this.u.log(e.Error,`(LongPolling transport) Unexpected response code: ${r.statusCode}.`),this.Ut=new n(r.statusText||"",r.statusCode),this.Rt=!1):r.content?(this.u.log(e.Trace,`(LongPolling transport) data received. ${m(r.content,this.xt.logMessageContent)}.`),this.onreceive&&this.onreceive(r.content)):this.u.log(e.Trace,"(LongPolling transport) Poll timed out, reissuing.")}catch(t){this.Rt?t instanceof i?this.u.log(e.Trace,"(LongPolling transport) Poll timed out, reissuing."):(this.Ut=t,this.Rt=!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.Mt()}}async send(t){return this.Rt?b(this.u,"LongPolling",this.$,this.At,t,this.xt):Promise.reject(new Error("Cannot send until the transport is connected"))}async stop(){this.u.log(e.Trace,"(LongPolling transport) Stopping polling."),this.Rt=!1,this.Dt.abort();try{await this.Lt,this.u.log(e.Trace,`(LongPolling transport) sending DELETE request to ${this.At}.`);const t={},[s,i]=$();t[s]=i;const r={headers:{...t,...this.xt.headers},timeout:this.xt.timeout,withCredentials:this.xt.withCredentials};let o;try{await this.$.delete(this.At,r)}catch(t){o=t}o?o instanceof n&&(404===o.statusCode?this.u.log(e.Trace,"(LongPolling transport) A 404 response was returned from sending a DELETE request."):this.u.log(e.Trace,`(LongPolling transport) Error sending a DELETE request: ${o}`)):this.u.log(e.Trace,"(LongPolling transport) DELETE request accepted.")}finally{this.u.log(e.Trace,"(LongPolling transport) Stop finished."),this.Mt()}}Mt(){if(this.onclose){let t="(LongPolling transport) Firing onclose event.";this.Ut&&(t+=" Error: "+this.Ut),this.u.log(e.Trace,t),this.onclose(this.Ut)}}}class X{constructor(t,e,s,n){this.$=t,this.It=e,this.u=s,this.xt=n,this.onreceive=null,this.onclose=null}async connect(t,s){return w.isRequired(t,"url"),w.isRequired(s,"transferFormat"),w.isIn(s,O,"transferFormat"),this.u.log(e.Trace,"(SSE transport) Connecting."),this.At=t,this.It&&(t+=(t.indexOf("?")<0?"?":"&")+`access_token=${encodeURIComponent(this.It)}`),new Promise(((n,i)=>{let r,o=!1;if(s===O.Text){if(g.isBrowser||g.isWebWorker)r=new this.xt.EventSource(t,{withCredentials:this.xt.withCredentials});else{const e=this.$.getCookieString(t),s={};s.Cookie=e;const[n,i]=$();s[n]=i,r=new this.xt.EventSource(t,{withCredentials:this.xt.withCredentials,headers:{...s,...this.xt.headers}})}try{r.onmessage=t=>{if(this.onreceive)try{this.u.log(e.Trace,`(SSE transport) data received. ${m(t.data,this.xt.logMessageContent)}.`),this.onreceive(t.data)}catch(t){return void this.jt(t)}},r.onerror=t=>{o?this.jt():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.At}`),this.Wt=r,o=!0,n()}}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.Wt?b(this.u,"SSE",this.$,this.At,t,this.xt):Promise.reject(new Error("Cannot send until the transport is connected"))}stop(){return this.jt(),Promise.resolve()}jt(t){this.Wt&&(this.Wt.close(),this.Wt=void 0,this.onclose&&this.onclose(t))}}class J{constructor(t,e,s,n,i,r){this.u=s,this.Tt=e,this.qt=n,this.Ot=i,this.$=t,this.onreceive=null,this.onclose=null,this.Ft=r}async connect(t,s){let n;return w.isRequired(t,"url"),w.isRequired(s,"transferFormat"),w.isIn(s,O,"transferFormat"),this.u.log(e.Trace,"(WebSockets transport) Connecting."),this.Tt&&(n=await this.Tt()),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={},[s,i]=$();e[s]=i,n&&(e[j.Authorization]=`Bearer ${n}`),h&&(e[j.Cookie]=h),o=new this.Ot(t,void 0,{headers:{...e,...this.Ft}})}else n&&(t+=(t.indexOf("?")<0?"?":"&")+`access_token=${encodeURIComponent(n)}`);o||(o=new this.Ot(t)),s===O.Binary&&(o.binaryType="arraybuffer"),o.onopen=s=>{this.u.log(e.Information,`WebSocket connected to ${t}.`),this.Bt=o,c=!0,i()},o.onerror=t=>{let s=null;s="undefined"!=typeof ErrorEvent&&t instanceof ErrorEvent?t.error:"There was an error with the transport",this.u.log(e.Information,`(WebSockets transport) ${s}.`)},o.onmessage=t=>{if(this.u.log(e.Trace,`(WebSockets transport) data received. ${m(t.data,this.qt)}.`),this.onreceive)try{this.onreceive(t.data)}catch(t){return void this.jt(t)}},o.onclose=t=>{if(c)this.jt(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.Bt&&this.Bt.readyState===this.Ot.OPEN?(this.u.log(e.Trace,`(WebSockets transport) sending data. ${m(t,this.qt)}.`),this.Bt.send(t),Promise.resolve()):Promise.reject("WebSocket is not in the OPEN state")}stop(){return this.Bt&&this.jt(void 0),Promise.resolve()}jt(t){this.Bt&&(this.Bt.onclose=()=>{},this.Bt.onmessage=()=>{},this.Bt.onerror=()=>{},this.Bt.close(),this.Bt=void 0),this.u.log(e.Trace,"(WebSockets transport) socket closed."),this.onclose&&(!this.Xt(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"}).`)))}Xt(t){return t&&"boolean"==typeof t.wasClean&&"number"==typeof t.code}}class z{constructor(t,s={}){var n;if(this.Jt=()=>{},this.features={},this.zt=1,w.isRequired(t,"url"),this.u=void 0===(n=s.logger)?new E(e.Information):null===n?p.instance:void 0!==n.log?n:new E(n),this.baseUrl=this.Vt(t),(s=s||{}).logMessageContent=void 0!==s.logMessageContent&&s.logMessageContent,"boolean"!=typeof s.withCredentials&&void 0!==s.withCredentials)throw new Error("withCredentials option was not a 'boolean' or 'undefined' value");s.withCredentials=void 0===s.withCredentials||s.withCredentials,s.timeout=void 0===s.timeout?1e5:s.timeout;let i=null,r=null;g.isNode&&(i=function(){throw new Error("Trying to import 'ws' in the browser.")}(),r=function(){throw new Error("Trying to import 'eventsource' in the browser.")}()),g.isNode||"undefined"==typeof WebSocket||s.WebSocket?g.isNode&&!s.WebSocket&&i&&(s.WebSocket=i):s.WebSocket=WebSocket,g.isNode||"undefined"==typeof EventSource||s.EventSource?g.isNode&&!s.EventSource&&void 0!==r&&(s.EventSource=r):s.EventSource=EventSource,this.$=new W(s.httpClient||new H(this.u),s.accessTokenFactory),this.M="Disconnected",this.j=!1,this.xt=s,this.onreceive=null,this.onclose=null}async start(t){if(t=t||O.Binary,w.isIn(t,O,"transferFormat"),this.u.log(e.Debug,`Starting connection with transfer format '${O[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.Kt=this.F(t),await this.Kt,"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.Gt||(this.Gt=new V(this.transport)),this.Gt.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.Jt=t})),await this.et(t),void await this.tt)}async et(t){this.Qt=t;try{await this.Kt}catch(t){}if(this.transport){try{await this.transport.stop()}catch(t){this.u.log(e.Error,`HttpConnection.transport.stop() threw error '${t}'.`),this.Yt()}this.transport=void 0}else this.u.log(e.Debug,"HttpConnection.transport is undefined in HttpConnection.stop() because start() failed.")}async F(t){let s=this.baseUrl;this.Tt=this.xt.accessTokenFactory,this.$.Tt=this.Tt;try{if(this.xt.skipNegotiation){if(this.xt.transport!==q.WebSockets)throw new Error("Negotiation can only be skipped when using the WebSocket transport directly.");this.transport=this.Zt(q.WebSockets),await this.te(s,t)}else{let e=null,n=0;do{if(e=await this.ee(s),"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&&(s=e.url),e.accessToken){const t=e.accessToken;this.Tt=()=>t,this.$.It=t,this.$.Tt=void 0}n++}while(e.url&&n<100);if(100===n&&e.url)throw new Error("Negotiate redirection limit exceeded.");await this.se(s,this.xt.transport,e,t)}this.transport instanceof B&&(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.Jt(),Promise.reject(t)}}async ee(t){const s={},[i,r]=$();s[i]=r;const o=this.ne(t);this.u.log(e.Debug,`Sending negotiation request: ${o}.`);try{const t=await this.$.post(o,{content:"",headers:{...s,...this.xt.headers},timeout:this.xt.timeout,withCredentials:this.xt.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 s="Failed to complete negotiation with the server: "+t;return t instanceof n&&404===t.statusCode&&(s+=" Either this is not a SignalR endpoint or there is a proxy blocking the connection."),this.u.log(e.Error,s),Promise.reject(new a(s))}}ie(t,e){return e?t+(-1===t.indexOf("?")?"?":"&")+`id=${e}`:t}async se(t,s,n,i){let o=this.ie(t,n.connectionToken);if(this.re(s))return this.u.log(e.Debug,"Connection was provided an instance of ITransport, using that directly."),this.transport=s,await this.te(o,i),void(this.connectionId=n.connectionId);const h=[],a=n.availableTransports||[];let u=n;for(const n of a){const a=this.oe(n,s,i);if(a instanceof Error)h.push(`${n.transport} failed:`),h.push(a);else if(this.re(a)){if(this.transport=a,!u){try{u=await this.ee(t)}catch(t){return Promise.reject(t)}o=this.ie(t,u.connectionToken)}try{return await this.te(o,i),void(this.connectionId=u.connectionId)}catch(t){if(this.u.log(e.Error,`Failed to start the transport '${n.transport}': ${t}`),u=void 0,h.push(new c(`${n.transport} failed: ${t}`,q[n.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."))}Zt(t){switch(t){case q.WebSockets:if(!this.xt.WebSocket)throw new Error("'WebSocket' is not supported in your environment.");return new J(this.$,this.Tt,this.u,this.xt.logMessageContent,this.xt.WebSocket,this.xt.headers||{});case q.ServerSentEvents:if(!this.xt.EventSource)throw new Error("'EventSource' is not supported in your environment.");return new X(this.$,this.$.It,this.u,this.xt);case q.LongPolling:return new B(this.$,this.u,this.xt);default:throw new Error(`Unknown transport: ${t}.`)}}te(t,e){return this.transport.onreceive=this.onreceive,this.transport.onclose=t=>this.Yt(t),this.transport.connect(t,e)}oe(t,s,n){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)}(s,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=>O[t])).indexOf(n)>=0))return this.u.log(e.Debug,`Skipping transport '${q[i]}' because it does not support the requested transfer format '${O[n]}'.`),new Error(`'${q[i]}' does not support ${O[n]}.`);if(i===q.WebSockets&&!this.xt.WebSocket||i===q.ServerSentEvents&&!this.xt.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.Zt(i)}catch(t){return t}}re(t){return t&&"object"==typeof t&&"connect"in t}Yt(t){if(this.u.log(e.Debug,`HttpConnection.stopConnection(${t}) called while in state ${this.M}.`),this.transport=void 0,t=this.Qt||t,this.Qt=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.Jt(),t?this.u.log(e.Error,`Connection disconnected with error '${t}'.`):this.u.log(e.Information,"Connection disconnected."),this.Gt&&(this.Gt.stop().catch((t=>{this.u.log(e.Error,`TransportSendQueue.stop() threw error '${t}'.`)})),this.Gt=void 0),this.connectionId=void 0,this.M="Disconnected",this.j){this.j=!1;try{this.onclose&&this.onclose(t)}catch(s){this.u.log(e.Error,`HttpConnection.onclose(${t}) threw error '${s}'.`)}}}else this.u.log(e.Debug,`Call to HttpConnection.stopConnection(${t}) was ignored because the connection is already in the disconnected state.`)}Vt(t){if(0===t.lastIndexOf("https://",0)||0===t.lastIndexOf("http://",0))return t;if(!g.isBrowser)throw new Error(`Cannot resolve '${t}'.`);const s=window.document.createElement("a");return s.href=t,this.u.log(e.Information,`Normalizing '${t}' to '${s.href}'.`),s.href}ne(t){const e=t.indexOf("?");let s=t.substring(0,-1===e?t.length:e);return"/"!==s[s.length-1]&&(s+="/"),s+="negotiate",s+=-1===e?"":t.substring(e),-1===s.indexOf("negotiateVersion")&&(s+=-1===e?"?":"&",s+="negotiateVersion="+this.zt),s}}class V{constructor(t){this.he=t,this.ce=[],this.ae=!0,this.le=new K,this.ue=new K,this.de=this.pe()}send(t){return this.fe(t),this.ue||(this.ue=new K),this.ue.promise}stop(){return this.ae=!1,this.le.resolve(),this.de}fe(t){if(this.ce.length&&typeof this.ce[0]!=typeof t)throw new Error(`Expected data to be of type ${typeof this.ce} but was of type ${typeof t}`);this.ce.push(t),this.le.resolve()}async pe(){for(;;){if(await this.le.promise,!this.ae){this.ue&&this.ue.reject("Connection stopped.");break}this.le=new K;const t=this.ue;this.ue=void 0;const e="string"==typeof this.ce[0]?this.ce.join(""):V.we(this.ce);this.ce.length=0;try{await this.he.send(e),t.resolve()}catch(e){t.reject(e)}}}static we(t){const e=t.map((t=>t.byteLength)).reduce(((t,e)=>t+e)),s=new Uint8Array(e);let n=0;for(const e of t)s.set(new Uint8Array(e),n),n+=e.byteLength;return s.buffer}}class K{constructor(){this.promise=new Promise(((t,e)=>[this.ge,this.me]=[t,e]))}resolve(){this.ge()}reject(t){this.me(t)}}class G{constructor(){this.name="json",this.version=1,this.transferFormat=O.Text}parseMessages(t,s){if("string"!=typeof t)throw new Error("Invalid input for JSON hub protocol. Expected a string.");if(!t)return[];null===s&&(s=p.instance);const n=D.parse(t),i=[];for(const t of n){const n=JSON.parse(t);if("number"!=typeof n.type)throw new Error("Invalid payload.");switch(n.type){case R.Invocation:this.ye(n);break;case R.StreamItem:this.be(n);break;case R.Completion:this.ve(n);break;case R.Ping:case R.Close:break;default:s.log(e.Information,"Unknown message type '"+n.type+"' ignored.");continue}i.push(n)}return i}writeMessage(t){return D.write(JSON.stringify(t))}ye(t){this.Ee(t.target,"Invalid payload for Invocation message."),void 0!==t.invocationId&&this.Ee(t.invocationId,"Invalid payload for Invocation message.")}be(t){if(this.Ee(t.invocationId,"Invalid payload for StreamItem message."),void 0===t.item)throw new Error("Invalid payload for StreamItem message.")}ve(t){if(t.result&&t.error)throw new Error("Invalid payload for Completion message.");!t.result&&t.error&&this.Ee(t.error,"Invalid payload for Completion message."),this.Ee(t.invocationId,"Invalid payload for Completion message.")}Ee(t,e){if("string"!=typeof t||""===t)throw new Error(e)}}const Q={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 Y{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=Q[t.toLowerCase()];if(void 0!==e)return e;throw new Error(`Unknown log level: ${t}`)}(t);this.logger=new E(e)}else this.logger=new E(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}withServerTimeout(t){return w.isRequired(t,"milliseconds"),this.$e=t,this}withKeepAliveInterval(t){return w.isRequired(t,"milliseconds"),this.Ce=t,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 z(this.url,t);return L.create(e,this.logger||p.instance,this.protocol||new G,this.reconnectPolicy,this.$e,this.Ce)}}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}),s})(),"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": "8.0.0-preview.7.23375.9",
"version": "8.0.0-rc.1.23421.29",
"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