diff --git a/src/Components/Web.JS/dist/Release/blazor.server.js b/src/Components/Web.JS/dist/Release/blazor.server.js index 974908836134f..03acff8d08435 100644 --- a/src/Components/Web.JS/dist/Release/blazor.server.js +++ b/src/Components/Web.JS/dist/Release/blazor.server.js @@ -1 +1 @@ -(()=>{var e={778:()=>{},77:()=>{},203:()=>{},200:()=>{},628:()=>{},321:()=>{}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var s=t[o]={exports:{}};return e[o](s,s.exports,n),s.exports}n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),(()=>{"use strict";var e,t,o;!function(e){const t=[],n="__jsObjectId",o="__dotNetObject",r="__byte[]",s="__dotNetStream",i="__jsStreamReferenceLength";let a,c;class l{constructor(e){this._jsObject=e,this._cachedFunctions=new Map}findFunction(e){const t=this._cachedFunctions.get(e);if(t)return t;let n,o=this._jsObject;if(e.split(".").forEach((t=>{if(!(t in o))throw new Error(`Could not find '${e}' ('${t}' was undefined).`);n=o,o=o[t]})),o instanceof Function)return o=o.bind(n),this._cachedFunctions.set(e,o),o;throw new Error(`The value '${e}' is not a function.`)}getWrappedObject(){return this._jsObject}}const h={0:new l(window)};h[0]._cachedFunctions.set("import",(e=>("string"==typeof e&&e.startsWith("./")&&(e=new URL(e.substr(2),document.baseURI).toString()),import(e))));let d,u=1;function p(e){t.push(e)}function f(e){if(e&&"object"==typeof e){h[u]=new l(e);const t={[n]:u};return u++,t}throw new Error(`Cannot create a JSObjectReference from the value '${e}'.`)}function g(e){let t=-1;if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e instanceof Blob)t=e.size;else{if(!(e.buffer instanceof ArrayBuffer))throw new Error("Supplied value is not a typed array or blob.");if(void 0===e.byteLength)throw new Error(`Cannot create a JSStreamReference from the value '${e}' as it doesn't have a byteLength.`);t=e.byteLength}const o={[i]:t};try{const t=f(e);o[n]=t[n]}catch(t){throw new Error(`Cannot create a JSStreamReference from the value '${e}'.`)}return o}function m(e,n){c=e;const o=n?JSON.parse(n,((e,n)=>t.reduce(((t,n)=>n(e,t)),n))):null;return c=void 0,o}function y(){if(void 0===a)throw new Error("No call dispatcher has been set.");if(null===a)throw new Error("There are multiple .NET runtimes present, so a default dispatcher could not be resolved. Use DotNetObject to invoke .NET instance methods.");return a}e.attachDispatcher=function(e){const t=new v(e);return void 0===a?a=t:a&&(a=null),t},e.attachReviver=p,e.invokeMethod=function(e,t,...n){return y().invokeDotNetStaticMethod(e,t,...n)},e.invokeMethodAsync=function(e,t,...n){return y().invokeDotNetStaticMethodAsync(e,t,...n)},e.createJSObjectReference=f,e.createJSStreamReference=g,e.disposeJSObjectReference=function(e){const t=e&&e[n];"number"==typeof t&&b(t)},function(e){e[e.Default=0]="Default",e[e.JSObjectReference=1]="JSObjectReference",e[e.JSStreamReference=2]="JSStreamReference",e[e.JSVoidResult=3]="JSVoidResult"}(d=e.JSCallResultType||(e.JSCallResultType={}));class v{constructor(e){this._dotNetCallDispatcher=e,this._byteArraysToBeRevived=new Map,this._pendingDotNetToJSStreams=new Map,this._pendingAsyncCalls={},this._nextAsyncCallId=1}getDotNetCallDispatcher(){return this._dotNetCallDispatcher}invokeJSFromDotNet(e,t,n,o){const r=m(this,t),s=I(_(e,o)(...r||[]),n);return null==s?null:T(this,s)}beginInvokeJSFromDotNet(e,t,n,o,r){const s=new Promise((e=>{const o=m(this,n);e(_(t,r)(...o||[]))}));e&&s.then((t=>T(this,[e,!0,I(t,o)]))).then((t=>this._dotNetCallDispatcher.endInvokeJSFromDotNet(e,!0,t)),(t=>this._dotNetCallDispatcher.endInvokeJSFromDotNet(e,!1,JSON.stringify([e,!1,w(t)]))))}endInvokeDotNetFromJS(e,t,n){const o=t?m(this,n):new Error(n);this.completePendingCall(parseInt(e,10),t,o)}invokeDotNetStaticMethod(e,t,...n){return this.invokeDotNetMethod(e,t,null,n)}invokeDotNetStaticMethodAsync(e,t,...n){return this.invokeDotNetMethodAsync(e,t,null,n)}invokeDotNetMethod(e,t,n,o){if(this._dotNetCallDispatcher.invokeDotNetFromJS){const r=T(this,o),s=this._dotNetCallDispatcher.invokeDotNetFromJS(e,t,n,r);return s?m(this,s):null}throw new Error("The current dispatcher does not support synchronous calls from JS to .NET. Use invokeDotNetMethodAsync instead.")}invokeDotNetMethodAsync(e,t,n,o){if(e&&n)throw new Error(`For instance method calls, assemblyName should be null. Received '${e}'.`);const r=this._nextAsyncCallId++,s=new Promise(((e,t)=>{this._pendingAsyncCalls[r]={resolve:e,reject:t}}));try{const s=T(this,o);this._dotNetCallDispatcher.beginInvokeDotNetFromJS(r,e,t,n,s)}catch(e){this.completePendingCall(r,!1,e)}return s}receiveByteArray(e,t){this._byteArraysToBeRevived.set(e,t)}processByteArray(e){const t=this._byteArraysToBeRevived.get(e);return t?(this._byteArraysToBeRevived.delete(e),t):null}supplyDotNetStream(e,t){if(this._pendingDotNetToJSStreams.has(e)){const n=this._pendingDotNetToJSStreams.get(e);this._pendingDotNetToJSStreams.delete(e),n.resolve(t)}else{const n=new C;n.resolve(t),this._pendingDotNetToJSStreams.set(e,n)}}getDotNetStreamPromise(e){let t;if(this._pendingDotNetToJSStreams.has(e))t=this._pendingDotNetToJSStreams.get(e).streamPromise,this._pendingDotNetToJSStreams.delete(e);else{const n=new C;this._pendingDotNetToJSStreams.set(e,n),t=n.streamPromise}return t}completePendingCall(e,t,n){if(!this._pendingAsyncCalls.hasOwnProperty(e))throw new Error(`There is no pending async call with ID ${e}.`);const o=this._pendingAsyncCalls[e];delete this._pendingAsyncCalls[e],t?o.resolve(n):o.reject(n)}}function w(e){return e instanceof Error?`${e.message}\n${e.stack}`:e?e.toString():"null"}function _(e,t){const n=h[t];if(n)return n.findFunction(e);throw new Error(`JS object instance with ID ${t} does not exist (has it been disposed?).`)}function b(e){delete h[e]}e.findJSFunction=_,e.disposeJSObjectReferenceById=b;class S{constructor(e,t){this._id=e,this._callDispatcher=t}invokeMethod(e,...t){return this._callDispatcher.invokeDotNetMethod(null,e,this._id,t)}invokeMethodAsync(e,...t){return this._callDispatcher.invokeDotNetMethodAsync(null,e,this._id,t)}dispose(){this._callDispatcher.invokeDotNetMethodAsync(null,"__Dispose",this._id,null).catch((e=>console.error(e)))}serializeAsArg(){return{[o]:this._id}}}e.DotNetObject=S,p((function(e,t){if(t&&"object"==typeof t){if(t.hasOwnProperty(o))return new S(t[o],c);if(t.hasOwnProperty(n)){const e=t[n],o=h[e];if(o)return o.getWrappedObject();throw new Error(`JS object instance with Id '${e}' does not exist. It may have been disposed.`)}if(t.hasOwnProperty(r)){const e=t[r],n=c.processByteArray(e);if(void 0===n)throw new Error(`Byte array index '${e}' does not exist.`);return n}if(t.hasOwnProperty(s)){const e=t[s],n=c.getDotNetStreamPromise(e);return new E(n)}}return t}));class E{constructor(e){this._streamPromise=e}stream(){return this._streamPromise}async arrayBuffer(){return new Response(await this.stream()).arrayBuffer()}}class C{constructor(){this.streamPromise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}}function I(e,t){switch(t){case d.Default:return e;case d.JSObjectReference:return f(e);case d.JSStreamReference:return g(e);case d.JSVoidResult:return null;default:throw new Error(`Invalid JS call result type '${t}'.`)}}let k=0;function T(e,t){k=0,c=e;const n=JSON.stringify(t,D);return c=void 0,n}function D(e,t){if(t instanceof S)return t.serializeAsArg();if(t instanceof Uint8Array){c.getDotNetCallDispatcher().sendByteArray(k,t);const e={[r]:k};return k++,e}return t}}(e||(e={})),function(e){e[e.prependFrame=1]="prependFrame",e[e.removeFrame=2]="removeFrame",e[e.setAttribute=3]="setAttribute",e[e.removeAttribute=4]="removeAttribute",e[e.updateText=5]="updateText",e[e.stepIn=6]="stepIn",e[e.stepOut=7]="stepOut",e[e.updateMarkup=8]="updateMarkup",e[e.permutationListEntry=9]="permutationListEntry",e[e.permutationListEnd=10]="permutationListEnd"}(t||(t={})),function(e){e[e.element=1]="element",e[e.text=2]="text",e[e.attribute=3]="attribute",e[e.component=4]="component",e[e.region=5]="region",e[e.elementReferenceCapture=6]="elementReferenceCapture",e[e.markup=8]="markup",e[e.namedEvent=10]="namedEvent"}(o||(o={}));class r{constructor(e,t){this.componentId=e,this.fieldValue=t}static fromEvent(e,t){const n=t.target;if(n instanceof Element){const t=function(e){return e instanceof HTMLInputElement?e.type&&"checkbox"===e.type.toLowerCase()?{value:e.checked}:{value:e.value}:e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement?{value:e.value}:null}(n);if(t)return new r(e,t.value)}return null}}const s=new Map,i=new Map,a=[];function c(e){return s.get(e)}function l(e){const t=s.get(e);return(null==t?void 0:t.browserEventName)||e}function h(e,t){e.forEach((e=>s.set(e,t)))}function d(e){const t=[];for(let n=0;ne.selected)).map((e=>e.value))}}{const e=function(e){return!!e&&"INPUT"===e.tagName&&"checkbox"===e.getAttribute("type")}(t);return{value:e?!!t.checked:t.value}}}}),h(["copy","cut","paste"],{createEventArgs:e=>({type:e.type})}),h(["drag","dragend","dragenter","dragleave","dragover","dragstart","drop"],{createEventArgs:e=>{return{...u(t=e),dataTransfer:t.dataTransfer?{dropEffect:t.dataTransfer.dropEffect,effectAllowed:t.dataTransfer.effectAllowed,files:Array.from(t.dataTransfer.files).map((e=>e.name)),items:Array.from(t.dataTransfer.items).map((e=>({kind:e.kind,type:e.type}))),types:t.dataTransfer.types}:null};var t}}),h(["focus","blur","focusin","focusout"],{createEventArgs:e=>({type:e.type})}),h(["keydown","keyup","keypress"],{createEventArgs:e=>{return{key:(t=e).key,code:t.code,location:t.location,repeat:t.repeat,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,type:t.type};var t}}),h(["contextmenu","click","mouseover","mouseout","mousemove","mousedown","mouseup","mouseleave","mouseenter","dblclick"],{createEventArgs:e=>u(e)}),h(["error"],{createEventArgs:e=>{return{message:(t=e).message,filename:t.filename,lineno:t.lineno,colno:t.colno,type:t.type};var t}}),h(["loadstart","timeout","abort","load","loadend","progress"],{createEventArgs:e=>{return{lengthComputable:(t=e).lengthComputable,loaded:t.loaded,total:t.total,type:t.type};var t}}),h(["touchcancel","touchend","touchmove","touchenter","touchleave","touchstart"],{createEventArgs:e=>{return{detail:(t=e).detail,touches:d(t.touches),targetTouches:d(t.targetTouches),changedTouches:d(t.changedTouches),ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,type:t.type};var t}}),h(["gotpointercapture","lostpointercapture","pointercancel","pointerdown","pointerenter","pointerleave","pointermove","pointerout","pointerover","pointerup"],{createEventArgs:e=>{return{...u(t=e),pointerId:t.pointerId,width:t.width,height:t.height,pressure:t.pressure,tiltX:t.tiltX,tiltY:t.tiltY,pointerType:t.pointerType,isPrimary:t.isPrimary};var t}}),h(["wheel","mousewheel"],{createEventArgs:e=>{return{...u(t=e),deltaX:t.deltaX,deltaY:t.deltaY,deltaZ:t.deltaZ,deltaMode:t.deltaMode};var t}}),h(["toggle"],{createEventArgs:()=>({})});const p=["date","datetime-local","month","time","week"],f=new Map;let g,m,y=0;const v={async add(e,t,n){if(!n)throw new Error("initialParameters must be an object, even if empty.");const o="__bl-dynamic-root:"+(++y).toString();f.set(o,e);const r=await b().invokeMethodAsync("AddRootComponent",t,o),s=new _(r,m[t]);return await s.setParameters(n),s}};class w{invoke(e){return this._callback(e)}setCallback(t){this._selfJSObjectReference||(this._selfJSObjectReference=e.createJSObjectReference(this)),this._callback=t}getJSObjectReference(){return this._selfJSObjectReference}dispose(){this._selfJSObjectReference&&e.disposeJSObjectReference(this._selfJSObjectReference)}}class _{constructor(e,t){this._jsEventCallbackWrappers=new Map,this._componentId=e;for(const e of t)"eventcallback"===e.type&&this._jsEventCallbackWrappers.set(e.name.toLowerCase(),new w)}setParameters(e){const t={},n=Object.entries(e||{}),o=n.length;for(const[e,o]of n){const n=this._jsEventCallbackWrappers.get(e.toLowerCase());n&&o?(n.setCallback(o),t[e]=n.getJSObjectReference()):t[e]=o}return b().invokeMethodAsync("SetRootComponentParameters",this._componentId,o,t)}async dispose(){if(null!==this._componentId){await b().invokeMethodAsync("RemoveRootComponent",this._componentId),this._componentId=null;for(const e of this._jsEventCallbackWrappers.values())e.dispose()}}}function b(){if(!g)throw new Error("Dynamic root components have not been enabled in this application.");return g}const S=new Map,E=[];let C;const I=new Promise((e=>{C=e}));function k(e,t,n){return D(e,t.eventHandlerId,(()=>T(e).invokeMethodAsync("DispatchEventAsync",t,n)))}function T(e){const t=S.get(e);if(!t)throw new Error(`No interop methods are registered for renderer ${e}`);return t}let D=(e,t,n)=>n();const x=M(["abort","blur","canplay","canplaythrough","change","cuechange","durationchange","emptied","ended","error","focus","load","loadeddata","loadedmetadata","loadend","loadstart","mouseenter","mouseleave","pointerenter","pointerleave","pause","play","playing","progress","ratechange","reset","scroll","seeked","seeking","stalled","submit","suspend","timeupdate","toggle","unload","volumechange","waiting","DOMNodeInsertedIntoDocument","DOMNodeRemovedFromDocument"]),R={submit:!0},A=M(["click","dblclick","mousedown","mousemove","mouseup"]);class P{constructor(e){this.browserRendererId=e,this.afterClickCallbacks=[];const t=++P.nextEventDelegatorId;this.eventsCollectionKey=`_blazorEvents_${t}`,this.eventInfoStore=new N(this.onGlobalEvent.bind(this))}setListener(e,t,n,o){const r=this.getEventHandlerInfosForElement(e,!0),s=r.getHandler(t);if(s)this.eventInfoStore.update(s.eventHandlerId,n);else{const s={element:e,eventName:t,eventHandlerId:n,renderingComponentId:o};this.eventInfoStore.add(s),r.setHandler(t,s)}}getHandler(e){return this.eventInfoStore.get(e)}removeListener(e){const t=this.eventInfoStore.remove(e);if(t){const e=t.element,n=this.getEventHandlerInfosForElement(e,!1);n&&n.removeHandler(t.eventName)}}notifyAfterClick(e){this.afterClickCallbacks.push(e),this.eventInfoStore.addGlobalListener("click")}setStopPropagation(e,t,n){this.getEventHandlerInfosForElement(e,!0).stopPropagation(t,n)}setPreventDefault(e,t,n){this.getEventHandlerInfosForElement(e,!0).preventDefault(t,n)}onGlobalEvent(e){if(!(e.target instanceof Element))return;this.dispatchGlobalEventToAllElements(e.type,e);const t=(n=e.type,i.get(n));var n;t&&t.forEach((t=>this.dispatchGlobalEventToAllElements(t,e))),"click"===e.type&&this.afterClickCallbacks.forEach((t=>t(e)))}dispatchGlobalEventToAllElements(e,t){const n=t.composedPath();let o=n.shift(),s=null,i=!1;const a=Object.prototype.hasOwnProperty.call(x,e);let l=!1;for(;o;){const u=o,p=this.getEventHandlerInfosForElement(u,!1);if(p){const n=p.getHandler(e);if(n&&(h=u,d=t.type,!((h instanceof HTMLButtonElement||h instanceof HTMLInputElement||h instanceof HTMLTextAreaElement||h instanceof HTMLSelectElement)&&Object.prototype.hasOwnProperty.call(A,d)&&h.disabled))){if(!i){const n=c(e);s=(null==n?void 0:n.createEventArgs)?n.createEventArgs(t):{},i=!0}Object.prototype.hasOwnProperty.call(R,t.type)&&t.preventDefault(),k(this.browserRendererId,{eventHandlerId:n.eventHandlerId,eventName:e,eventFieldInfo:r.fromEvent(n.renderingComponentId,t)},s)}p.stopPropagation(e)&&(l=!0),p.preventDefault(e)&&t.preventDefault()}o=a||l?void 0:n.shift()}var h,d}getEventHandlerInfosForElement(e,t){return Object.prototype.hasOwnProperty.call(e,this.eventsCollectionKey)?e[this.eventsCollectionKey]:t?e[this.eventsCollectionKey]=new U:null}}P.nextEventDelegatorId=0;class N{constructor(e){this.globalListener=e,this.infosByEventHandlerId={},this.countByEventName={},a.push(this.handleEventNameAliasAdded.bind(this))}add(e){if(this.infosByEventHandlerId[e.eventHandlerId])throw new Error(`Event ${e.eventHandlerId} is already tracked`);this.infosByEventHandlerId[e.eventHandlerId]=e,this.addGlobalListener(e.eventName)}get(e){return this.infosByEventHandlerId[e]}addGlobalListener(e){if(e=l(e),Object.prototype.hasOwnProperty.call(this.countByEventName,e))this.countByEventName[e]++;else{this.countByEventName[e]=1;const t=Object.prototype.hasOwnProperty.call(x,e);document.addEventListener(e,this.globalListener,t)}}update(e,t){if(Object.prototype.hasOwnProperty.call(this.infosByEventHandlerId,t))throw new Error(`Event ${t} is already tracked`);const n=this.infosByEventHandlerId[e];delete this.infosByEventHandlerId[e],n.eventHandlerId=t,this.infosByEventHandlerId[t]=n}remove(e){const t=this.infosByEventHandlerId[e];if(t){delete this.infosByEventHandlerId[e];const n=l(t.eventName);0==--this.countByEventName[n]&&(delete this.countByEventName[n],document.removeEventListener(n,this.globalListener))}return t}handleEventNameAliasAdded(e,t){if(Object.prototype.hasOwnProperty.call(this.countByEventName,e)){const n=this.countByEventName[e];delete this.countByEventName[e],document.removeEventListener(e,this.globalListener),this.addGlobalListener(t),this.countByEventName[t]+=n-1}}}class U{constructor(){this.handlers={},this.preventDefaultFlags=null,this.stopPropagationFlags=null}getHandler(e){return Object.prototype.hasOwnProperty.call(this.handlers,e)?this.handlers[e]:null}setHandler(e,t){this.handlers[e]=t}removeHandler(e){delete this.handlers[e]}preventDefault(e,t){return void 0!==t&&(this.preventDefaultFlags=this.preventDefaultFlags||{},this.preventDefaultFlags[e]=t),!!this.preventDefaultFlags&&this.preventDefaultFlags[e]}stopPropagation(e,t){return void 0!==t&&(this.stopPropagationFlags=this.stopPropagationFlags||{},this.stopPropagationFlags[e]=t),!!this.stopPropagationFlags&&this.stopPropagationFlags[e]}}function M(e){const t={};return e.forEach((e=>{t[e]=!0})),t}const B=Symbol(),L=Symbol(),$=Symbol();function O(e,t){if(B in e)return e;const n=[];if(e.childNodes.length>0){if(!t)throw new Error("New logical elements must start empty, or allowExistingContents must be true");e.childNodes.forEach((t=>{const o=O(t,!0);o[L]=e,n.push(o)}))}return e[B]=n,e}function F(e){const t=K(e);for(;t.length;)W(e,0)}function H(e,t){const n=document.createComment("!");return j(n,e,t),n}function j(e,t,n){const o=e;let r=e;if(B in e){const t=Q(o);if(t!==e){const n=new Range;n.setStartBefore(e),n.setEndAfter(t),r=n.extractContents()}}const s=z(o);if(s){const e=K(s),t=Array.prototype.indexOf.call(e,o);e.splice(t,1),delete o[L]}const i=K(t);if(n0;)W(n,0)}const o=n;o.parentNode.removeChild(o)}function z(e){return e[L]||null}function q(e,t){return K(e)[t]}function J(e){const t=Y(e);return"http://www.w3.org/2000/svg"===t.namespaceURI&&"foreignObject"!==t.tagName}function K(e){return e[B]}function V(e){const t=K(z(e));return t[Array.prototype.indexOf.call(t,e)+1]||null}function X(e,t){const n=K(e);t.forEach((e=>{e.moveRangeStart=n[e.fromSiblingIndex],e.moveRangeEnd=Q(e.moveRangeStart)})),t.forEach((t=>{const o=document.createComment("marker");t.moveToBeforeMarker=o;const r=n[t.toSiblingIndex+1];r?r.parentNode.insertBefore(o,r):G(o,e)})),t.forEach((e=>{const t=e.moveToBeforeMarker,n=t.parentNode,o=e.moveRangeStart,r=e.moveRangeEnd;let s=o;for(;s;){const e=s.nextSibling;if(n.insertBefore(s,t),s===r)break;s=e}n.removeChild(t)})),t.forEach((e=>{n[e.toSiblingIndex]=e.moveRangeStart}))}function Y(e){if(e instanceof Element||e instanceof DocumentFragment)return e;if(e instanceof Comment)return e.parentNode;throw new Error("Not a valid logical element")}function G(e,t){if(t instanceof Element||t instanceof DocumentFragment)t.appendChild(e);else{if(!(t instanceof Comment))throw new Error(`Cannot append node because the parent is not a valid logical element. Parent: ${t}`);{const n=V(t);n?n.parentNode.insertBefore(e,n):G(e,z(t))}}}function Q(e){if(e instanceof Element||e instanceof DocumentFragment)return e;const t=V(e);if(t)return t.previousSibling;{const t=z(e);return t instanceof Element||t instanceof DocumentFragment?t.lastChild:Q(t)}}function Z(e){return`_bl_${e}`}const ee="__internalId";e.attachReviver(((e,t)=>t&&"object"==typeof t&&Object.prototype.hasOwnProperty.call(t,ee)&&"string"==typeof t[ee]?function(e){const t=`[${Z(e)}]`;return document.querySelector(t)}(t[ee]):t));const te="_blazorDeferredValue";function ne(e){return"select-multiple"===e.type}function oe(e,t){e.value=t||""}function re(e,t){e instanceof HTMLSelectElement?ne(e)?function(e,t){t||(t=[]);for(let n=0;n{Ce()&&function(e,t){if(0!==e.button||function(e){return e.ctrlKey||e.shiftKey||e.altKey||e.metaKey}(e))return;if(e.defaultPrevented)return;const n=function(e){const t=!window._blazorDisableComposedPath&&e.composedPath&&e.composedPath();if(t){for(let e=0;edocument.baseURI,getLocationHref:()=>location.href,scrollToElement:Ue};function Ue(e){const t=document.getElementById(e);return!!t&&(t.scrollIntoView(),!0)}function Me(e,t,n=!1){const o=Se(e);!t.forceLoad&&we(o)?We()?Be(o,!1,t.replaceHistoryEntry,t.historyEntryState,n):be(o,t.replaceHistoryEntry):function(e,t){if(location.href===e){const t=e+"?";history.replaceState(null,"",t),location.replace(e)}else t?location.replace(e):location.href=e}(e,t.replaceHistoryEntry)}async function Be(e,t,n,o=void 0,r=!1){if(Oe(),function(e){const t=e.indexOf("#");return t>-1&&location.href.replace(location.hash,"")===e.substring(0,t)}(e))!function(e,t,n){Le(e,t,n);const o=e.indexOf("#");o!==e.length-1&&Ue(e.substring(o+1))}(e,n,o);else{if(!r&&ke&&!await Fe(e,o,t))return;ye=!0,Le(e,n,o),await He(t)}}function Le(e,t,n=void 0){t?history.replaceState({userState:n,_index:Te},"",e):(Te++,history.pushState({userState:n,_index:Te},"",e))}function $e(e){return new Promise((t=>{const n=Ae;Ae=()=>{Ae=n,t()},history.go(e)}))}function Oe(){Pe&&(Pe(!1),Pe=null)}function Fe(e,t,n){return new Promise((o=>{Oe(),Re?(De++,Pe=o,Re(De,e,t,n)):o(!1)}))}async function He(e){var t;xe&&await xe(location.href,null===(t=history.state)||void 0===t?void 0:t.userState,e)}async function je(e){var t,n;Ae&&We()&&await Ae(e),Te=null!==(n=null===(t=history.state)||void 0===t?void 0:t._index)&&void 0!==n?n:0}function We(){return Ce()||!_e()}const ze={focus:function(e,t){if(e instanceof HTMLElement)e.focus({preventScroll:t});else{if(!(e instanceof SVGElement))throw new Error("Unable to focus an invalid element.");if(!e.hasAttribute("tabindex"))throw new Error("Unable to focus an SVG element that does not have a tabindex.");e.focus({preventScroll:t})}},focusBySelector:function(e,t){const n=document.querySelector(e);n&&(n.hasAttribute("tabindex")||(n.tabIndex=-1),n.focus({preventScroll:!0}))}},qe={init:function(e,t,n,o=50){const r=Ke(t);(r||document.documentElement).style.overflowAnchor="none";const s=document.createRange();u(n.parentElement)&&(t.style.display="table-row",n.style.display="table-row");const i=new IntersectionObserver((function(o){o.forEach((o=>{var r;if(!o.isIntersecting)return;s.setStartAfter(t),s.setEndBefore(n);const i=s.getBoundingClientRect().height,a=null===(r=o.rootBounds)||void 0===r?void 0:r.height;o.target===t?e.invokeMethodAsync("OnSpacerBeforeVisible",o.intersectionRect.top-o.boundingClientRect.top,i,a):o.target===n&&n.offsetHeight>0&&e.invokeMethodAsync("OnSpacerAfterVisible",o.boundingClientRect.bottom-o.intersectionRect.bottom,i,a)}))}),{root:r,rootMargin:`${o}px`});i.observe(t),i.observe(n);const a=d(t),c=d(n),{observersByDotNetObjectId:l,id:h}=Ve(e);function d(e){const t={attributes:!0},n=new MutationObserver(((n,o)=>{u(e.parentElement)&&(o.disconnect(),e.style.display="table-row",o.observe(e,t)),i.unobserve(e),i.observe(e)}));return n.observe(e,t),n}function u(e){return null!==e&&(e instanceof HTMLTableElement&&""===e.style.display||"table"===e.style.display||e instanceof HTMLTableSectionElement&&""===e.style.display||"table-row-group"===e.style.display)}l[h]={intersectionObserver:i,mutationObserverBefore:a,mutationObserverAfter:c}},dispose:function(e){const{observersByDotNetObjectId:t,id:n}=Ve(e),o=t[n];o&&(o.intersectionObserver.disconnect(),o.mutationObserverBefore.disconnect(),o.mutationObserverAfter.disconnect(),e.dispose(),delete t[n])}},Je=Symbol();function Ke(e){return e&&e!==document.body&&e!==document.documentElement?"visible"!==getComputedStyle(e).overflowY?e:Ke(e.parentElement):null}function Ve(e){var t;const n=e._callDispatcher,o=e._id;return null!==(t=n[Je])&&void 0!==t||(n[Je]={}),{observersByDotNetObjectId:n[Je],id:o}}const Xe={getAndRemoveExistingTitle:function(){var e;const t=document.head?document.head.getElementsByTagName("title"):[];if(0===t.length)return null;let n=null;for(let o=t.length-1;o>=0;o--){const r=t[o],s=r.previousSibling;s instanceof Comment&&null!==z(s)||(null===n&&(n=r.textContent),null===(e=r.parentNode)||void 0===e||e.removeChild(r))}return n}},Ye={init:function(e,t){t._blazorInputFileNextFileId=0,t.addEventListener("click",(function(){t.value=""})),t.addEventListener("change",(function(){t._blazorFilesById={};const n=Array.prototype.map.call(t.files,(function(e){const n={id:++t._blazorInputFileNextFileId,lastModified:new Date(e.lastModified).toISOString(),name:e.name,size:e.size,contentType:e.type,readPromise:void 0,arrayBuffer:void 0,blob:e};return t._blazorFilesById[n.id]=n,n}));e.invokeMethodAsync("NotifyChange",n)}))},toImageFile:async function(e,t,n,o,r){const s=Ge(e,t),i=await new Promise((function(e){const t=new Image;t.onload=function(){URL.revokeObjectURL(t.src),e(t)},t.onerror=function(){t.onerror=null,URL.revokeObjectURL(t.src)},t.src=URL.createObjectURL(s.blob)})),a=await new Promise((function(e){var t;const s=Math.min(1,o/i.width),a=Math.min(1,r/i.height),c=Math.min(s,a),l=document.createElement("canvas");l.width=Math.round(i.width*c),l.height=Math.round(i.height*c),null===(t=l.getContext("2d"))||void 0===t||t.drawImage(i,0,0,l.width,l.height),l.toBlob(e,n)})),c={id:++e._blazorInputFileNextFileId,lastModified:s.lastModified,name:s.name,size:(null==a?void 0:a.size)||0,contentType:n,blob:a||s.blob};return e._blazorFilesById[c.id]=c,c},readFileData:async function(e,t){return Ge(e,t).blob}};function Ge(e,t){const n=e._blazorFilesById[t];if(!n)throw new Error(`There is no file with ID ${t}. The file list may have changed. See https://aka.ms/aspnet/blazor-input-file-multiple-selections.`);return n}const Qe=new Set,Ze={enableNavigationPrompt:function(e){0===Qe.size&&window.addEventListener("beforeunload",et),Qe.add(e)},disableNavigationPrompt:function(e){Qe.delete(e),0===Qe.size&&window.removeEventListener("beforeunload",et)}};function et(e){e.preventDefault(),e.returnValue=!0}async function tt(e,t,n){return e instanceof Blob?await async function(e,t,n){const o=e.slice(t,t+n),r=await o.arrayBuffer();return new Uint8Array(r)}(e,t,n):function(e,t,n){return new Uint8Array(e.buffer,e.byteOffset+t,n)}(e,t,n)}new Map;const nt={navigateTo:function(e,t,n=!1){Me(e,t instanceof Object?t:{forceLoad:t,replaceHistoryEntry:n})},registerCustomEventType:function(e,t){if(!t)throw new Error("The options parameter is required.");if(s.has(e))throw new Error(`The event '${e}' is already registered.`);if(t.browserEventName){const n=i.get(t.browserEventName);n?n.push(e):i.set(t.browserEventName,[e]),a.forEach((n=>n(e,t.browserEventName)))}s.set(e,t)},rootComponents:v,runtime:{},_internal:{navigationManager:Ne,domWrapper:ze,Virtualize:qe,PageTitle:Xe,InputFile:Ye,NavigationLock:Ze,getJSDataStreamChunk:tt,attachWebRendererInterop:function(t,n,o,r){if(S.has(t))throw new Error(`Interop methods are already registered for renderer ${t}`);S.set(t,n),Object.keys(o).length>0&&function(t,n,o){if(g)throw new Error("Dynamic root components have already been enabled.");g=t,m=n;for(const[t,r]of Object.entries(o)){const o=e.findJSFunction(t,0);for(const e of r)o(e,n[e])}}(T(t),o,r),C(),function(e){for(const t of E)t(e)}(t)}}};var ot;window.Blazor=nt,function(e){e[e.Trace=0]="Trace",e[e.Debug=1]="Debug",e[e.Information=2]="Information",e[e.Warning=3]="Warning",e[e.Error=4]="Error",e[e.Critical=5]="Critical",e[e.None=6]="None"}(ot||(ot={}));class rt{log(e,t){}}rt.instance=new rt;class st{constructor(e){this.minLevel=e}log(e,t){if(e>=this.minLevel){const n=`[${(new Date).toISOString()}] ${ot[e]}: ${t}`;switch(e){case ot.Critical:case ot.Error:console.error(n);break;case ot.Warning:console.warn(n);break;case ot.Information:console.info(n);break;default:console.log(n)}}}}const it=/^\s*Blazor-Component-State:(?[a-zA-Z0-9+/=]+)$/;function at(e){var t;if(e.nodeType===Node.COMMENT_NODE){const n=e.textContent||"",o=it.exec(n),r=o&&o.groups&&o.groups.state;return r&&(null===(t=e.parentNode)||void 0===t||t.removeChild(e)),r}if(!e.hasChildNodes())return;const n=e.childNodes;for(let e=0;e.*)$/);function ht(e,t){const n=e.currentElement;var o,r,s;if(n&&n.nodeType===Node.COMMENT_NODE&&n.textContent){const i=lt.exec(n.textContent),a=i&&i.groups&&i.groups.descriptor;if(!a)return;!function(e){if(e.parentNode instanceof Document)throw new Error("Root components cannot be marked as interactive. The element must be rendered statically so that scripts are not evaluated multiple times.")}(n);try{const i=function(e){const t=JSON.parse(e),{type:n}=t;if("server"!==n&&"webassembly"!==n&&"auto"!==n)throw new Error(`Invalid component type '${n}'.`);return t}(a),c=function(e,t,n){const{prerenderId:o}=e;if(o){for(;n.next()&&n.currentElement;){const e=n.currentElement;if(e.nodeType!==Node.COMMENT_NODE)continue;if(!e.textContent)continue;const t=lt.exec(e.textContent),r=t&&t[1];if(r)return ft(r,o),e}throw new Error(`Could not find an end component comment for '${t}'.`)}}(i,n,e);if(t!==i.type)return;switch(i.type){case"webassembly":return r=n,s=c,pt(o=i),{...o,uniqueId:dt++,start:r,end:s};case"server":return function(e,t,n){return ut(e),{...e,uniqueId:dt++,start:t,end:n}}(i,n,c);case"auto":return function(e,t,n){return ut(e),pt(e),{...e,uniqueId:dt++,start:t,end:n}}(i,n,c)}}catch(e){throw new Error(`Found malformed component comment at ${n.textContent}`)}}}let dt=0;function ut(e){const{descriptor:t,sequence:n}=e;if(!t)throw new Error("descriptor must be defined when using a descriptor.");if(void 0===n)throw new Error("sequence must be defined when using a descriptor.");if(!Number.isInteger(n))throw new Error(`Error parsing the sequence '${n}' for component '${JSON.stringify(e)}'`)}function pt(e){const{assembly:t,typeName:n}=e;if(!t)throw new Error("assembly must be defined when using a descriptor.");if(!n)throw new Error("typeName must be defined when using a descriptor.");e.parameterDefinitions=e.parameterDefinitions&&atob(e.parameterDefinitions),e.parameterValues=e.parameterValues&&atob(e.parameterValues)}function ft(e,t){const n=JSON.parse(e);if(1!==Object.keys(n).length)throw new Error(`Invalid end of component comment: '${e}'`);const o=n.prerenderId;if(!o)throw new Error(`End of component comment must have a value for the prerendered property: '${e}'`);if(o!==t)throw new Error(`End of component comment prerendered property must match the start comment prerender id: '${t}', '${o}'`)}class gt{constructor(e){this.childNodes=e,this.currentIndex=-1,this.length=e.length}next(){return this.currentIndex++,this.currentIndex{n+=`0x${e<16?"0":""}${e.toString(16)} `})),n.substr(0,n.length-1)}(e)}'`)):"string"==typeof e&&(n=`String data of length ${e.length}`,t&&(n+=`. Content: '${e}'`)),n}function Et(e){return e&&"undefined"!=typeof ArrayBuffer&&(e instanceof ArrayBuffer||e.constructor&&"ArrayBuffer"===e.constructor.name)}async function Ct(e,t,n,o,r,s){const i={},[a,c]=Tt();i[a]=c,e.log(yt.Trace,`(${t} transport) sending data. ${St(r,s.logMessageContent)}.`);const l=Et(r)?"arraybuffer":"text",h=await n.post(o,{content:r,headers:{...i,...s.headers},responseType:l,timeout:s.timeout,withCredentials:s.withCredentials});e.log(yt.Trace,`(${t} transport) request complete. Response status: ${h.statusCode}.`)}class It{constructor(e,t){this._subject=e,this._observer=t}dispose(){const e=this._subject.observers.indexOf(this._observer);e>-1&&this._subject.observers.splice(e,1),0===this._subject.observers.length&&this._subject.cancelCallback&&this._subject.cancelCallback().catch((e=>{}))}}class kt{constructor(e){this._minLevel=e,this.out=console}log(e,t){if(e>=this._minLevel){const n=`[${(new Date).toISOString()}] ${yt[e]}: ${t}`;switch(e){case yt.Critical:case yt.Error:this.out.error(n);break;case yt.Warning:this.out.warn(n);break;case yt.Information:this.out.info(n);break;default:this.out.log(n)}}}}function Tt(){let e="X-SignalR-User-Agent";return bt.isNode&&(e="User-Agent"),[e,Dt(wt,xt(),bt.isNode?"NodeJS":"Browser",Rt())]}function Dt(e,t,n,o){let r="Microsoft SignalR/";const s=e.split(".");return r+=`${s[0]}.${s[1]}`,r+=` (${e}; `,r+=t&&""!==t?`${t}; `:"Unknown OS; ",r+=`${n}`,r+=o?`; ${o}`:"; Unknown Runtime Version",r+=")",r}function xt(){if(!bt.isNode)return"";switch(process.platform){case"win32":return"Windows NT";case"darwin":return"macOS";case"linux":return"Linux";default:return process.platform}}function Rt(){if(bt.isNode)return process.versions.node}function At(e){return e.stack?e.stack:e.message?e.message:`${e}`}class Pt{writeHandshakeRequest(e){return mt.write(JSON.stringify(e))}parseHandshakeResponse(e){let t,n;if(Et(e)){const o=new Uint8Array(e),r=o.indexOf(mt.RecordSeparatorCode);if(-1===r)throw new Error("Message is incomplete.");const s=r+1;t=String.fromCharCode.apply(null,Array.prototype.slice.call(o.slice(0,s))),n=o.byteLength>s?o.slice(s).buffer:null}else{const o=e,r=o.indexOf(mt.RecordSeparator);if(-1===r)throw new Error("Message is incomplete.");const s=r+1;t=o.substring(0,s),n=o.length>s?o.substring(s):null}const o=mt.parse(t),r=JSON.parse(o[0]);if(r.type)throw new Error("Expected a handshake response from the server.");return[n,r]}}class Nt extends Error{constructor(e,t){const n=new.target.prototype;super(`${e}: Status code '${t}'`),this.statusCode=t,this.__proto__=n}}class Ut extends Error{constructor(e="A timeout occurred."){const t=new.target.prototype;super(e),this.__proto__=t}}class Mt extends Error{constructor(e="An abort occurred."){const t=new.target.prototype;super(e),this.__proto__=t}}class Bt extends Error{constructor(e,t){const n=new.target.prototype;super(e),this.transport=t,this.errorType="UnsupportedTransportError",this.__proto__=n}}class Lt extends Error{constructor(e,t){const n=new.target.prototype;super(e),this.transport=t,this.errorType="DisabledTransportError",this.__proto__=n}}class $t extends Error{constructor(e,t){const n=new.target.prototype;super(e),this.transport=t,this.errorType="FailedToStartTransportError",this.__proto__=n}}class Ot extends Error{constructor(e){const t=new.target.prototype;super(e),this.errorType="FailedToNegotiateWithServerError",this.__proto__=t}}class Ft extends Error{constructor(e,t){const n=new.target.prototype;super(e),this.innerErrors=t,this.__proto__=n}}var Ht,jt;!function(e){e[e.Invocation=1]="Invocation",e[e.StreamItem=2]="StreamItem",e[e.Completion=3]="Completion",e[e.StreamInvocation=4]="StreamInvocation",e[e.CancelInvocation=5]="CancelInvocation",e[e.Ping=6]="Ping",e[e.Close=7]="Close",e[e.Ack=8]="Ack",e[e.Sequence=9]="Sequence"}(Ht||(Ht={}));class Wt{constructor(){this.observers=[]}next(e){for(const t of this.observers)t.next(e)}error(e){for(const t of this.observers)t.error&&t.error(e)}complete(){for(const e of this.observers)e.complete&&e.complete()}subscribe(e){return this.observers.push(e),new It(this,e)}}class zt{constructor(e,t,n){this._bufferSize=1e5,this._messages=[],this._totalMessageCount=0,this._waitForSequenceMessage=!1,this._nextReceivingSequenceId=1,this._latestReceivedSequenceId=0,this._bufferedByteCount=0,this._reconnectInProgress=!1,this._protocol=e,this._connection=t,this._bufferSize=n}async _send(e){const t=this._protocol.writeMessage(e);let n=Promise.resolve();if(this._isInvocationMessage(e)){this._totalMessageCount++;let e=()=>{},o=()=>{};Et(t)?this._bufferedByteCount+=t.byteLength:this._bufferedByteCount+=t.length,this._bufferedByteCount>=this._bufferSize&&(n=new Promise(((t,n)=>{e=t,o=n}))),this._messages.push(new qt(t,this._totalMessageCount,e,o))}try{this._reconnectInProgress||await this._connection.send(t)}catch{this._disconnected()}await n}_ack(e){let t=-1;for(let n=0;nthis._nextReceivingSequenceId?this._connection.stop(new Error("Sequence ID greater than amount of messages we've received.")):this._nextReceivingSequenceId=e.sequenceId}_disconnected(){this._reconnectInProgress=!0,this._waitForSequenceMessage=!0}async _resend(){const e=0!==this._messages.length?this._messages[0]._id:this._totalMessageCount+1;await this._connection.send(this._protocol.writeMessage({type:Ht.Sequence,sequenceId:e}));const t=this._messages;for(const e of t)await this._connection.send(e._message);this._reconnectInProgress=!1}_dispose(e){null!=e||(e=new Error("Unable to reconnect to server."));for(const t of this._messages)t._rejector(e)}_isInvocationMessage(e){switch(e.type){case Ht.Invocation:case Ht.StreamItem:case Ht.Completion:case Ht.StreamInvocation:case Ht.CancelInvocation:return!0;case Ht.Close:case Ht.Sequence:case Ht.Ping:case Ht.Ack:return!1}}_ackTimer(){void 0===this._ackTimerHandle&&(this._ackTimerHandle=setTimeout((async()=>{try{this._reconnectInProgress||await this._connection.send(this._protocol.writeMessage({type:Ht.Ack,sequenceId:this._latestReceivedSequenceId}))}catch{}clearTimeout(this._ackTimerHandle),this._ackTimerHandle=void 0}),1e3))}}class qt{constructor(e,t,n,o){this._message=e,this._id=t,this._resolver=n,this._rejector=o}}!function(e){e.Disconnected="Disconnected",e.Connecting="Connecting",e.Connected="Connected",e.Disconnecting="Disconnecting",e.Reconnecting="Reconnecting"}(jt||(jt={}));class Jt{static create(e,t,n,o,r,s,i){return new Jt(e,t,n,o,r,s,i)}constructor(e,t,n,o,r,s,i){this._nextKeepAlive=0,this._freezeEventListener=()=>{this._logger.log(yt.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")},_t.isRequired(e,"connection"),_t.isRequired(t,"logger"),_t.isRequired(n,"protocol"),this.serverTimeoutInMilliseconds=null!=r?r:3e4,this.keepAliveIntervalInMilliseconds=null!=s?s:15e3,this._statefulReconnectBufferSize=null!=i?i:1e5,this._logger=t,this._protocol=n,this.connection=e,this._reconnectPolicy=o,this._handshakeProtocol=new Pt,this.connection.onreceive=e=>this._processIncomingData(e),this.connection.onclose=e=>this._connectionClosed(e),this._callbacks={},this._methods={},this._closedCallbacks=[],this._reconnectingCallbacks=[],this._reconnectedCallbacks=[],this._invocationId=0,this._receivedHandshakeResponse=!1,this._connectionState=jt.Disconnected,this._connectionStarted=!1,this._cachedPingMessage=this._protocol.writeMessage({type:Ht.Ping})}get state(){return this._connectionState}get connectionId(){return this.connection&&this.connection.connectionId||null}get baseUrl(){return this.connection.baseUrl||""}set baseUrl(e){if(this._connectionState!==jt.Disconnected&&this._connectionState!==jt.Reconnecting)throw new Error("The HubConnection must be in the Disconnected or Reconnecting state to change the url.");if(!e)throw new Error("The HubConnection url must be a valid url.");this.connection.baseUrl=e}start(){return this._startPromise=this._startWithStateTransitions(),this._startPromise}async _startWithStateTransitions(){if(this._connectionState!==jt.Disconnected)return Promise.reject(new Error("Cannot start a HubConnection that is not in the 'Disconnected' state."));this._connectionState=jt.Connecting,this._logger.log(yt.Debug,"Starting HubConnection.");try{await this._startInternal(),bt.isBrowser&&window.document.addEventListener("freeze",this._freezeEventListener),this._connectionState=jt.Connected,this._connectionStarted=!0,this._logger.log(yt.Debug,"HubConnection connected successfully.")}catch(e){return this._connectionState=jt.Disconnected,this._logger.log(yt.Debug,`HubConnection failed to start successfully because of error '${e}'.`),Promise.reject(e)}}async _startInternal(){this._stopDuringStartError=void 0,this._receivedHandshakeResponse=!1;const e=new Promise(((e,t)=>{this._handshakeResolver=e,this._handshakeRejecter=t}));await this.connection.start(this._protocol.transferFormat);try{const t={protocol:this._protocol.name,version:this._protocol.version};if(this._logger.log(yt.Debug,"Sending handshake request."),await this._sendMessage(this._handshakeProtocol.writeHandshakeRequest(t)),this._logger.log(yt.Information,`Using HubProtocol '${this._protocol.name}'.`),this._cleanupTimeout(),this._resetTimeoutPeriod(),this._resetKeepAliveInterval(),await e,this._stopDuringStartError)throw this._stopDuringStartError;!!this.connection.features.reconnect&&(this._messageBuffer=new zt(this._protocol,this.connection,this._statefulReconnectBufferSize),this.connection.features.disconnected=this._messageBuffer._disconnected.bind(this._messageBuffer),this.connection.features.resend=()=>{if(this._messageBuffer)return this._messageBuffer._resend()}),this.connection.features.inherentKeepAlive||await this._sendMessage(this._cachedPingMessage)}catch(e){throw this._logger.log(yt.Debug,`Hub handshake failed with error '${e}' during start(). Stopping HubConnection.`),this._cleanupTimeout(),this._cleanupPingTimer(),await this.connection.stop(e),e}}async stop(){const e=this._startPromise;this.connection.features.reconnect=!1,this._stopPromise=this._stopInternal(),await this._stopPromise;try{await e}catch(e){}}_stopInternal(e){if(this._connectionState===jt.Disconnected)return this._logger.log(yt.Debug,`Call to HubConnection.stop(${e}) ignored because it is already in the disconnected state.`),Promise.resolve();if(this._connectionState===jt.Disconnecting)return this._logger.log(yt.Debug,`Call to HttpConnection.stop(${e}) ignored because the connection is already in the disconnecting state.`),this._stopPromise;const t=this._connectionState;return this._connectionState=jt.Disconnecting,this._logger.log(yt.Debug,"Stopping HubConnection."),this._reconnectDelayHandle?(this._logger.log(yt.Debug,"Connection stopped during reconnect delay. Done reconnecting."),clearTimeout(this._reconnectDelayHandle),this._reconnectDelayHandle=void 0,this._completeClose(),Promise.resolve()):(t===jt.Connected&&this._sendCloseMessage(),this._cleanupTimeout(),this._cleanupPingTimer(),this._stopDuringStartError=e||new Mt("The connection was stopped before the hub handshake could complete."),this.connection.stop(e))}async _sendCloseMessage(){try{await this._sendWithProtocol(this._createCloseMessage())}catch{}}stream(e,...t){const[n,o]=this._replaceStreamingParams(t),r=this._createStreamInvocation(e,t,o);let s;const i=new Wt;return i.cancelCallback=()=>{const e=this._createCancelInvocation(r.invocationId);return delete this._callbacks[r.invocationId],s.then((()=>this._sendWithProtocol(e)))},this._callbacks[r.invocationId]=(e,t)=>{t?i.error(t):e&&(e.type===Ht.Completion?e.error?i.error(new Error(e.error)):i.complete():i.next(e.item))},s=this._sendWithProtocol(r).catch((e=>{i.error(e),delete this._callbacks[r.invocationId]})),this._launchStreams(n,s),i}_sendMessage(e){return this._resetKeepAliveInterval(),this.connection.send(e)}_sendWithProtocol(e){return this._messageBuffer?this._messageBuffer._send(e):this._sendMessage(this._protocol.writeMessage(e))}send(e,...t){const[n,o]=this._replaceStreamingParams(t),r=this._sendWithProtocol(this._createInvocation(e,t,!0,o));return this._launchStreams(n,r),r}invoke(e,...t){const[n,o]=this._replaceStreamingParams(t),r=this._createInvocation(e,t,!1,o);return new Promise(((e,t)=>{this._callbacks[r.invocationId]=(n,o)=>{o?t(o):n&&(n.type===Ht.Completion?n.error?t(new Error(n.error)):e(n.result):t(new Error(`Unexpected message type: ${n.type}`)))};const o=this._sendWithProtocol(r).catch((e=>{t(e),delete this._callbacks[r.invocationId]}));this._launchStreams(n,o)}))}on(e,t){e&&t&&(e=e.toLowerCase(),this._methods[e]||(this._methods[e]=[]),-1===this._methods[e].indexOf(t)&&this._methods[e].push(t))}off(e,t){if(!e)return;e=e.toLowerCase();const n=this._methods[e];if(n)if(t){const o=n.indexOf(t);-1!==o&&(n.splice(o,1),0===n.length&&delete this._methods[e])}else delete this._methods[e]}onclose(e){e&&this._closedCallbacks.push(e)}onreconnecting(e){e&&this._reconnectingCallbacks.push(e)}onreconnected(e){e&&this._reconnectedCallbacks.push(e)}_processIncomingData(e){if(this._cleanupTimeout(),this._receivedHandshakeResponse||(e=this._processHandshakeResponse(e),this._receivedHandshakeResponse=!0),e){const t=this._protocol.parseMessages(e,this._logger);for(const e of t)if(!this._messageBuffer||this._messageBuffer._shouldProcessMessage(e))switch(e.type){case Ht.Invocation:this._invokeClientMethod(e);break;case Ht.StreamItem:case Ht.Completion:{const t=this._callbacks[e.invocationId];if(t){e.type===Ht.Completion&&delete this._callbacks[e.invocationId];try{t(e)}catch(e){this._logger.log(yt.Error,`Stream callback threw error: ${At(e)}`)}}break}case Ht.Ping:break;case Ht.Close:{this._logger.log(yt.Information,"Close message received from server.");const t=e.error?new Error("Server returned an error on close: "+e.error):void 0;!0===e.allowReconnect?this.connection.stop(t):this._stopPromise=this._stopInternal(t);break}case Ht.Ack:this._messageBuffer&&this._messageBuffer._ack(e);break;case Ht.Sequence:this._messageBuffer&&this._messageBuffer._resetSequence(e);break;default:this._logger.log(yt.Warning,`Invalid message type: ${e.type}.`)}}this._resetTimeoutPeriod()}_processHandshakeResponse(e){let t,n;try{[n,t]=this._handshakeProtocol.parseHandshakeResponse(e)}catch(e){const t="Error parsing handshake response: "+e;this._logger.log(yt.Error,t);const n=new Error(t);throw this._handshakeRejecter(n),n}if(t.error){const e="Server returned handshake error: "+t.error;this._logger.log(yt.Error,e);const n=new Error(e);throw this._handshakeRejecter(n),n}return this._logger.log(yt.Debug,"Server handshake complete."),this._handshakeResolver(),n}_resetKeepAliveInterval(){this.connection.features.inherentKeepAlive||(this._nextKeepAlive=(new Date).getTime()+this.keepAliveIntervalInMilliseconds,this._cleanupPingTimer())}_resetTimeoutPeriod(){if(!(this.connection.features&&this.connection.features.inherentKeepAlive||(this._timeoutHandle=setTimeout((()=>this.serverTimeout()),this.serverTimeoutInMilliseconds),void 0!==this._pingServerHandle))){let e=this._nextKeepAlive-(new Date).getTime();e<0&&(e=0),this._pingServerHandle=setTimeout((async()=>{if(this._connectionState===jt.Connected)try{await this._sendMessage(this._cachedPingMessage)}catch{this._cleanupPingTimer()}}),e)}}serverTimeout(){this.connection.stop(new Error("Server timeout elapsed without receiving a message from the server."))}async _invokeClientMethod(e){const t=e.target.toLowerCase(),n=this._methods[t];if(!n)return this._logger.log(yt.Warning,`No client method with the name '${t}' found.`),void(e.invocationId&&(this._logger.log(yt.Warning,`No result given for '${t}' method and invocation ID '${e.invocationId}'.`),await this._sendWithProtocol(this._createCompletionMessage(e.invocationId,"Client didn't provide a result.",null))));const o=n.slice(),r=!!e.invocationId;let s,i,a;for(const n of o)try{const o=s;s=await n.apply(this,e.arguments),r&&s&&o&&(this._logger.log(yt.Error,`Multiple results provided for '${t}'. Sending error to server.`),a=this._createCompletionMessage(e.invocationId,"Client provided multiple results.",null)),i=void 0}catch(e){i=e,this._logger.log(yt.Error,`A callback for the method '${t}' threw error '${e}'.`)}a?await this._sendWithProtocol(a):r?(i?a=this._createCompletionMessage(e.invocationId,`${i}`,null):void 0!==s?a=this._createCompletionMessage(e.invocationId,null,s):(this._logger.log(yt.Warning,`No result given for '${t}' method and invocation ID '${e.invocationId}'.`),a=this._createCompletionMessage(e.invocationId,"Client didn't provide a result.",null)),await this._sendWithProtocol(a)):s&&this._logger.log(yt.Error,`Result given for '${t}' method but server is not expecting a result.`)}_connectionClosed(e){this._logger.log(yt.Debug,`HubConnection.connectionClosed(${e}) called while in state ${this._connectionState}.`),this._stopDuringStartError=this._stopDuringStartError||e||new Mt("The underlying connection was closed before the hub handshake could complete."),this._handshakeResolver&&this._handshakeResolver(),this._cancelCallbacksWithError(e||new Error("Invocation canceled due to the underlying connection being closed.")),this._cleanupTimeout(),this._cleanupPingTimer(),this._connectionState===jt.Disconnecting?this._completeClose(e):this._connectionState===jt.Connected&&this._reconnectPolicy?this._reconnect(e):this._connectionState===jt.Connected&&this._completeClose(e)}_completeClose(e){if(this._connectionStarted){this._connectionState=jt.Disconnected,this._connectionStarted=!1,this._messageBuffer&&(this._messageBuffer._dispose(null!=e?e:new Error("Connection closed.")),this._messageBuffer=void 0),bt.isBrowser&&window.document.removeEventListener("freeze",this._freezeEventListener);try{this._closedCallbacks.forEach((t=>t.apply(this,[e])))}catch(t){this._logger.log(yt.Error,`An onclose callback called with error '${e}' threw error '${t}'.`)}}}async _reconnect(e){const t=Date.now();let n=0,o=void 0!==e?e:new Error("Attempting to reconnect due to a unknown error."),r=this._getNextRetryDelay(n++,0,o);if(null===r)return this._logger.log(yt.Debug,"Connection not reconnecting because the IRetryPolicy returned null on the first reconnect attempt."),void this._completeClose(e);if(this._connectionState=jt.Reconnecting,e?this._logger.log(yt.Information,`Connection reconnecting because of error '${e}'.`):this._logger.log(yt.Information,"Connection reconnecting."),0!==this._reconnectingCallbacks.length){try{this._reconnectingCallbacks.forEach((t=>t.apply(this,[e])))}catch(t){this._logger.log(yt.Error,`An onreconnecting callback called with error '${e}' threw error '${t}'.`)}if(this._connectionState!==jt.Reconnecting)return void this._logger.log(yt.Debug,"Connection left the reconnecting state in onreconnecting callback. Done reconnecting.")}for(;null!==r;){if(this._logger.log(yt.Information,`Reconnect attempt number ${n} will start in ${r} ms.`),await new Promise((e=>{this._reconnectDelayHandle=setTimeout(e,r)})),this._reconnectDelayHandle=void 0,this._connectionState!==jt.Reconnecting)return void this._logger.log(yt.Debug,"Connection left the reconnecting state during reconnect delay. Done reconnecting.");try{if(await this._startInternal(),this._connectionState=jt.Connected,this._logger.log(yt.Information,"HubConnection reconnected successfully."),0!==this._reconnectedCallbacks.length)try{this._reconnectedCallbacks.forEach((e=>e.apply(this,[this.connection.connectionId])))}catch(e){this._logger.log(yt.Error,`An onreconnected callback called with connectionId '${this.connection.connectionId}; threw error '${e}'.`)}return}catch(e){if(this._logger.log(yt.Information,`Reconnect attempt failed because of error '${e}'.`),this._connectionState!==jt.Reconnecting)return this._logger.log(yt.Debug,`Connection moved to the '${this._connectionState}' from the reconnecting state during reconnect attempt. Done reconnecting.`),void(this._connectionState===jt.Disconnecting&&this._completeClose());o=e instanceof Error?e:new Error(e.toString()),r=this._getNextRetryDelay(n++,Date.now()-t,o)}}this._logger.log(yt.Information,`Reconnect retries have been exhausted after ${Date.now()-t} ms and ${n} failed attempts. Connection disconnecting.`),this._completeClose()}_getNextRetryDelay(e,t,n){try{return this._reconnectPolicy.nextRetryDelayInMilliseconds({elapsedMilliseconds:t,previousRetryCount:e,retryReason:n})}catch(n){return this._logger.log(yt.Error,`IRetryPolicy.nextRetryDelayInMilliseconds(${e}, ${t}) threw error '${n}'.`),null}}_cancelCallbacksWithError(e){const t=this._callbacks;this._callbacks={},Object.keys(t).forEach((n=>{const o=t[n];try{o(null,e)}catch(t){this._logger.log(yt.Error,`Stream 'error' callback called with '${e}' threw error: ${At(t)}`)}}))}_cleanupPingTimer(){this._pingServerHandle&&(clearTimeout(this._pingServerHandle),this._pingServerHandle=void 0)}_cleanupTimeout(){this._timeoutHandle&&clearTimeout(this._timeoutHandle)}_createInvocation(e,t,n,o){if(n)return 0!==o.length?{arguments:t,streamIds:o,target:e,type:Ht.Invocation}:{arguments:t,target:e,type:Ht.Invocation};{const n=this._invocationId;return this._invocationId++,0!==o.length?{arguments:t,invocationId:n.toString(),streamIds:o,target:e,type:Ht.Invocation}:{arguments:t,invocationId:n.toString(),target:e,type:Ht.Invocation}}}_launchStreams(e,t){if(0!==e.length){t||(t=Promise.resolve());for(const n in e)e[n].subscribe({complete:()=>{t=t.then((()=>this._sendWithProtocol(this._createCompletionMessage(n))))},error:e=>{let o;o=e instanceof Error?e.message:e&&e.toString?e.toString():"Unknown error",t=t.then((()=>this._sendWithProtocol(this._createCompletionMessage(n,o))))},next:e=>{t=t.then((()=>this._sendWithProtocol(this._createStreamItemMessage(n,e))))}})}}_replaceStreamingParams(e){const t=[],n=[];for(let o=0;o0)&&(t=!1,this._accessToken=await this._accessTokenFactory()),this._setAuthorizationHeader(e);const n=await this._innerClient.send(e);return t&&401===n.statusCode&&this._accessTokenFactory?(this._accessToken=await this._accessTokenFactory(),this._setAuthorizationHeader(e),await this._innerClient.send(e)):n}_setAuthorizationHeader(e){e.headers||(e.headers={}),this._accessToken?e.headers[Xt.Authorization]=`Bearer ${this._accessToken}`:this._accessTokenFactory&&e.headers[Xt.Authorization]&&delete e.headers[Xt.Authorization]}getCookieString(e){return this._innerClient.getCookieString(e)}}class Zt extends Gt{constructor(e){super(),this._logger=e;const t={_fetchType:void 0,_jar:void 0};var o;o=t,"undefined"==typeof fetch&&(o._jar=new(n(628).CookieJar),"undefined"==typeof fetch?o._fetchType=n(200):o._fetchType=fetch,o._fetchType=n(203)(o._fetchType,o._jar),1)?(this._fetchType=t._fetchType,this._jar=t._jar):this._fetchType=fetch.bind(function(){if("undefined"!=typeof globalThis)return globalThis;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==n.g)return n.g;throw new Error("could not find global")}()),this._abortControllerType=AbortController;const r={_abortControllerType:this._abortControllerType};(function(e){return"undefined"==typeof AbortController&&(e._abortControllerType=n(778),!0)})(r)&&(this._abortControllerType=r._abortControllerType)}async send(e){if(e.abortSignal&&e.abortSignal.aborted)throw new Mt;if(!e.method)throw new Error("No method defined.");if(!e.url)throw new Error("No url defined.");const t=new this._abortControllerType;let n;e.abortSignal&&(e.abortSignal.onabort=()=>{t.abort(),n=new Mt});let o,r=null;if(e.timeout){const o=e.timeout;r=setTimeout((()=>{t.abort(),this._logger.log(yt.Warning,"Timeout from HTTP request."),n=new Ut}),o)}""===e.content&&(e.content=void 0),e.content&&(e.headers=e.headers||{},Et(e.content)?e.headers["Content-Type"]="application/octet-stream":e.headers["Content-Type"]="text/plain;charset=UTF-8");try{o=await this._fetchType(e.url,{body:e.content,cache:"no-cache",credentials:!0===e.withCredentials?"include":"same-origin",headers:{"X-Requested-With":"XMLHttpRequest",...e.headers},method:e.method,mode:"cors",redirect:"follow",signal:t.signal})}catch(e){if(n)throw n;throw this._logger.log(yt.Warning,`Error from HTTP request. ${e}.`),e}finally{r&&clearTimeout(r),e.abortSignal&&(e.abortSignal.onabort=null)}if(!o.ok){const e=await en(o,"text");throw new Nt(e||o.statusText,o.status)}const s=en(o,e.responseType),i=await s;return new Yt(o.status,o.statusText,i)}getCookieString(e){return""}}function en(e,t){let n;switch(t){case"arraybuffer":n=e.arrayBuffer();break;case"text":default:n=e.text();break;case"blob":case"document":case"json":throw new Error(`${t} is not supported.`)}return n}class tn extends Gt{constructor(e){super(),this._logger=e}send(e){return e.abortSignal&&e.abortSignal.aborted?Promise.reject(new Mt):e.method?e.url?new Promise(((t,n)=>{const o=new XMLHttpRequest;o.open(e.method,e.url,!0),o.withCredentials=void 0===e.withCredentials||e.withCredentials,o.setRequestHeader("X-Requested-With","XMLHttpRequest"),""===e.content&&(e.content=void 0),e.content&&(Et(e.content)?o.setRequestHeader("Content-Type","application/octet-stream"):o.setRequestHeader("Content-Type","text/plain;charset=UTF-8"));const r=e.headers;r&&Object.keys(r).forEach((e=>{o.setRequestHeader(e,r[e])})),e.responseType&&(o.responseType=e.responseType),e.abortSignal&&(e.abortSignal.onabort=()=>{o.abort(),n(new Mt)}),e.timeout&&(o.timeout=e.timeout),o.onload=()=>{e.abortSignal&&(e.abortSignal.onabort=null),o.status>=200&&o.status<300?t(new Yt(o.status,o.statusText,o.response||o.responseText)):n(new Nt(o.response||o.responseText||o.statusText,o.status))},o.onerror=()=>{this._logger.log(yt.Warning,`Error from HTTP request. ${o.status}: ${o.statusText}.`),n(new Nt(o.statusText,o.status))},o.ontimeout=()=>{this._logger.log(yt.Warning,"Timeout from HTTP request."),n(new Ut)},o.send(e.content)})):Promise.reject(new Error("No url defined.")):Promise.reject(new Error("No method defined."))}}class nn extends Gt{constructor(e){if(super(),"undefined"!=typeof fetch)this._httpClient=new Zt(e);else{if("undefined"==typeof XMLHttpRequest)throw new Error("No usable HttpClient found.");this._httpClient=new tn(e)}}send(e){return e.abortSignal&&e.abortSignal.aborted?Promise.reject(new Mt):e.method?e.url?this._httpClient.send(e):Promise.reject(new Error("No url defined.")):Promise.reject(new Error("No method defined."))}getCookieString(e){return this._httpClient.getCookieString(e)}}var on,rn;!function(e){e[e.None=0]="None",e[e.WebSockets=1]="WebSockets",e[e.ServerSentEvents=2]="ServerSentEvents",e[e.LongPolling=4]="LongPolling"}(on||(on={})),function(e){e[e.Text=1]="Text",e[e.Binary=2]="Binary"}(rn||(rn={}));class sn{constructor(){this._isAborted=!1,this.onabort=null}abort(){this._isAborted||(this._isAborted=!0,this.onabort&&this.onabort())}get signal(){return this}get aborted(){return this._isAborted}}class an{get pollAborted(){return this._pollAbort.aborted}constructor(e,t,n){this._httpClient=e,this._logger=t,this._pollAbort=new sn,this._options=n,this._running=!1,this.onreceive=null,this.onclose=null}async connect(e,t){if(_t.isRequired(e,"url"),_t.isRequired(t,"transferFormat"),_t.isIn(t,rn,"transferFormat"),this._url=e,this._logger.log(yt.Trace,"(LongPolling transport) Connecting."),t===rn.Binary&&"undefined"!=typeof XMLHttpRequest&&"string"!=typeof(new XMLHttpRequest).responseType)throw new Error("Binary protocols over XmlHttpRequest not implementing advanced features are not supported.");const[n,o]=Tt(),r={[n]:o,...this._options.headers},s={abortSignal:this._pollAbort.signal,headers:r,timeout:1e5,withCredentials:this._options.withCredentials};t===rn.Binary&&(s.responseType="arraybuffer");const i=`${e}&_=${Date.now()}`;this._logger.log(yt.Trace,`(LongPolling transport) polling: ${i}.`);const a=await this._httpClient.get(i,s);200!==a.statusCode?(this._logger.log(yt.Error,`(LongPolling transport) Unexpected response code: ${a.statusCode}.`),this._closeError=new Nt(a.statusText||"",a.statusCode),this._running=!1):this._running=!0,this._receiving=this._poll(this._url,s)}async _poll(e,t){try{for(;this._running;)try{const n=`${e}&_=${Date.now()}`;this._logger.log(yt.Trace,`(LongPolling transport) polling: ${n}.`);const o=await this._httpClient.get(n,t);204===o.statusCode?(this._logger.log(yt.Information,"(LongPolling transport) Poll terminated by server."),this._running=!1):200!==o.statusCode?(this._logger.log(yt.Error,`(LongPolling transport) Unexpected response code: ${o.statusCode}.`),this._closeError=new Nt(o.statusText||"",o.statusCode),this._running=!1):o.content?(this._logger.log(yt.Trace,`(LongPolling transport) data received. ${St(o.content,this._options.logMessageContent)}.`),this.onreceive&&this.onreceive(o.content)):this._logger.log(yt.Trace,"(LongPolling transport) Poll timed out, reissuing.")}catch(e){this._running?e instanceof Ut?this._logger.log(yt.Trace,"(LongPolling transport) Poll timed out, reissuing."):(this._closeError=e,this._running=!1):this._logger.log(yt.Trace,`(LongPolling transport) Poll errored after shutdown: ${e.message}`)}}finally{this._logger.log(yt.Trace,"(LongPolling transport) Polling complete."),this.pollAborted||this._raiseOnClose()}}async send(e){return this._running?Ct(this._logger,"LongPolling",this._httpClient,this._url,e,this._options):Promise.reject(new Error("Cannot send until the transport is connected"))}async stop(){this._logger.log(yt.Trace,"(LongPolling transport) Stopping polling."),this._running=!1,this._pollAbort.abort();try{await this._receiving,this._logger.log(yt.Trace,`(LongPolling transport) sending DELETE request to ${this._url}.`);const e={},[t,n]=Tt();e[t]=n;const o={headers:{...e,...this._options.headers},timeout:this._options.timeout,withCredentials:this._options.withCredentials};let r;try{await this._httpClient.delete(this._url,o)}catch(e){r=e}r?r instanceof Nt&&(404===r.statusCode?this._logger.log(yt.Trace,"(LongPolling transport) A 404 response was returned from sending a DELETE request."):this._logger.log(yt.Trace,`(LongPolling transport) Error sending a DELETE request: ${r}`)):this._logger.log(yt.Trace,"(LongPolling transport) DELETE request accepted.")}finally{this._logger.log(yt.Trace,"(LongPolling transport) Stop finished."),this._raiseOnClose()}}_raiseOnClose(){if(this.onclose){let e="(LongPolling transport) Firing onclose event.";this._closeError&&(e+=" Error: "+this._closeError),this._logger.log(yt.Trace,e),this.onclose(this._closeError)}}}class cn{constructor(e,t,n,o){this._httpClient=e,this._accessToken=t,this._logger=n,this._options=o,this.onreceive=null,this.onclose=null}async connect(e,t){return _t.isRequired(e,"url"),_t.isRequired(t,"transferFormat"),_t.isIn(t,rn,"transferFormat"),this._logger.log(yt.Trace,"(SSE transport) Connecting."),this._url=e,this._accessToken&&(e+=(e.indexOf("?")<0?"?":"&")+`access_token=${encodeURIComponent(this._accessToken)}`),new Promise(((n,o)=>{let r,s=!1;if(t===rn.Text){if(bt.isBrowser||bt.isWebWorker)r=new this._options.EventSource(e,{withCredentials:this._options.withCredentials});else{const t=this._httpClient.getCookieString(e),n={};n.Cookie=t;const[o,s]=Tt();n[o]=s,r=new this._options.EventSource(e,{withCredentials:this._options.withCredentials,headers:{...n,...this._options.headers}})}try{r.onmessage=e=>{if(this.onreceive)try{this._logger.log(yt.Trace,`(SSE transport) data received. ${St(e.data,this._options.logMessageContent)}.`),this.onreceive(e.data)}catch(e){return void this._close(e)}},r.onerror=e=>{s?this._close():o(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._logger.log(yt.Information,`SSE connected to ${this._url}`),this._eventSource=r,s=!0,n()}}catch(e){return void o(e)}}else o(new Error("The Server-Sent Events transport only supports the 'Text' transfer format"))}))}async send(e){return this._eventSource?Ct(this._logger,"SSE",this._httpClient,this._url,e,this._options):Promise.reject(new Error("Cannot send until the transport is connected"))}stop(){return this._close(),Promise.resolve()}_close(e){this._eventSource&&(this._eventSource.close(),this._eventSource=void 0,this.onclose&&this.onclose(e))}}class ln{constructor(e,t,n,o,r,s){this._logger=n,this._accessTokenFactory=t,this._logMessageContent=o,this._webSocketConstructor=r,this._httpClient=e,this.onreceive=null,this.onclose=null,this._headers=s}async connect(e,t){let n;return _t.isRequired(e,"url"),_t.isRequired(t,"transferFormat"),_t.isIn(t,rn,"transferFormat"),this._logger.log(yt.Trace,"(WebSockets transport) Connecting."),this._accessTokenFactory&&(n=await this._accessTokenFactory()),new Promise(((o,r)=>{let s;e=e.replace(/^http/,"ws");const i=this._httpClient.getCookieString(e);let a=!1;if(bt.isReactNative){const t={},[o,r]=Tt();t[o]=r,n&&(t[Xt.Authorization]=`Bearer ${n}`),i&&(t[Xt.Cookie]=i),s=new this._webSocketConstructor(e,void 0,{headers:{...t,...this._headers}})}else n&&(e+=(e.indexOf("?")<0?"?":"&")+`access_token=${encodeURIComponent(n)}`);s||(s=new this._webSocketConstructor(e)),t===rn.Binary&&(s.binaryType="arraybuffer"),s.onopen=t=>{this._logger.log(yt.Information,`WebSocket connected to ${e}.`),this._webSocket=s,a=!0,o()},s.onerror=e=>{let t=null;t="undefined"!=typeof ErrorEvent&&e instanceof ErrorEvent?e.error:"There was an error with the transport",this._logger.log(yt.Information,`(WebSockets transport) ${t}.`)},s.onmessage=e=>{if(this._logger.log(yt.Trace,`(WebSockets transport) data received. ${St(e.data,this._logMessageContent)}.`),this.onreceive)try{this.onreceive(e.data)}catch(e){return void this._close(e)}},s.onclose=e=>{if(a)this._close(e);else{let t=null;t="undefined"!=typeof ErrorEvent&&e instanceof ErrorEvent?e.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(t))}}}))}send(e){return this._webSocket&&this._webSocket.readyState===this._webSocketConstructor.OPEN?(this._logger.log(yt.Trace,`(WebSockets transport) sending data. ${St(e,this._logMessageContent)}.`),this._webSocket.send(e),Promise.resolve()):Promise.reject("WebSocket is not in the OPEN state")}stop(){return this._webSocket&&this._close(void 0),Promise.resolve()}_close(e){this._webSocket&&(this._webSocket.onclose=()=>{},this._webSocket.onmessage=()=>{},this._webSocket.onerror=()=>{},this._webSocket.close(),this._webSocket=void 0),this._logger.log(yt.Trace,"(WebSockets transport) socket closed."),this.onclose&&(!this._isCloseEvent(e)||!1!==e.wasClean&&1e3===e.code?e instanceof Error?this.onclose(e):this.onclose():this.onclose(new Error(`WebSocket closed with status code: ${e.code} (${e.reason||"no reason given"}).`)))}_isCloseEvent(e){return e&&"boolean"==typeof e.wasClean&&"number"==typeof e.code}}class hn{constructor(e,t={}){if(this._stopPromiseResolver=()=>{},this.features={},this._negotiateVersion=1,_t.isRequired(e,"url"),this._logger=function(e){return void 0===e?new kt(yt.Information):null===e?vt.instance:void 0!==e.log?e:new kt(e)}(t.logger),this.baseUrl=this._resolveUrl(e),(t=t||{}).logMessageContent=void 0!==t.logMessageContent&&t.logMessageContent,"boolean"!=typeof t.withCredentials&&void 0!==t.withCredentials)throw new Error("withCredentials option was not a 'boolean' or 'undefined' value");t.withCredentials=void 0===t.withCredentials||t.withCredentials,t.timeout=void 0===t.timeout?1e5:t.timeout,"undefined"==typeof WebSocket||t.WebSocket||(t.WebSocket=WebSocket),"undefined"==typeof EventSource||t.EventSource||(t.EventSource=EventSource),this._httpClient=new Qt(t.httpClient||new nn(this._logger),t.accessTokenFactory),this._connectionState="Disconnected",this._connectionStarted=!1,this._options=t,this.onreceive=null,this.onclose=null}async start(e){if(e=e||rn.Binary,_t.isIn(e,rn,"transferFormat"),this._logger.log(yt.Debug,`Starting connection with transfer format '${rn[e]}'.`),"Disconnected"!==this._connectionState)return Promise.reject(new Error("Cannot start an HttpConnection that is not in the 'Disconnected' state."));if(this._connectionState="Connecting",this._startInternalPromise=this._startInternal(e),await this._startInternalPromise,"Disconnecting"===this._connectionState){const e="Failed to start the HttpConnection before stop() was called.";return this._logger.log(yt.Error,e),await this._stopPromise,Promise.reject(new Mt(e))}if("Connected"!==this._connectionState){const e="HttpConnection.startInternal completed gracefully but didn't enter the connection into the connected state!";return this._logger.log(yt.Error,e),Promise.reject(new Mt(e))}this._connectionStarted=!0}send(e){return"Connected"!==this._connectionState?Promise.reject(new Error("Cannot send data if the connection is not in the 'Connected' State.")):(this._sendQueue||(this._sendQueue=new dn(this.transport)),this._sendQueue.send(e))}async stop(e){return"Disconnected"===this._connectionState?(this._logger.log(yt.Debug,`Call to HttpConnection.stop(${e}) ignored because the connection is already in the disconnected state.`),Promise.resolve()):"Disconnecting"===this._connectionState?(this._logger.log(yt.Debug,`Call to HttpConnection.stop(${e}) ignored because the connection is already in the disconnecting state.`),this._stopPromise):(this._connectionState="Disconnecting",this._stopPromise=new Promise((e=>{this._stopPromiseResolver=e})),await this._stopInternal(e),void await this._stopPromise)}async _stopInternal(e){this._stopError=e;try{await this._startInternalPromise}catch(e){}if(this.transport){try{await this.transport.stop()}catch(e){this._logger.log(yt.Error,`HttpConnection.transport.stop() threw error '${e}'.`),this._stopConnection()}this.transport=void 0}else this._logger.log(yt.Debug,"HttpConnection.transport is undefined in HttpConnection.stop() because start() failed.")}async _startInternal(e){let t=this.baseUrl;this._accessTokenFactory=this._options.accessTokenFactory,this._httpClient._accessTokenFactory=this._accessTokenFactory;try{if(this._options.skipNegotiation){if(this._options.transport!==on.WebSockets)throw new Error("Negotiation can only be skipped when using the WebSocket transport directly.");this.transport=this._constructTransport(on.WebSockets),await this._startTransport(t,e)}else{let n=null,o=0;do{if(n=await this._getNegotiationResponse(t),"Disconnecting"===this._connectionState||"Disconnected"===this._connectionState)throw new Mt("The connection was stopped during negotiation.");if(n.error)throw new Error(n.error);if(n.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(n.url&&(t=n.url),n.accessToken){const e=n.accessToken;this._accessTokenFactory=()=>e,this._httpClient._accessToken=e,this._httpClient._accessTokenFactory=void 0}o++}while(n.url&&o<100);if(100===o&&n.url)throw new Error("Negotiate redirection limit exceeded.");await this._createTransport(t,this._options.transport,n,e)}this.transport instanceof an&&(this.features.inherentKeepAlive=!0),"Connecting"===this._connectionState&&(this._logger.log(yt.Debug,"The HttpConnection connected successfully."),this._connectionState="Connected")}catch(e){return this._logger.log(yt.Error,"Failed to start the connection: "+e),this._connectionState="Disconnected",this.transport=void 0,this._stopPromiseResolver(),Promise.reject(e)}}async _getNegotiationResponse(e){const t={},[n,o]=Tt();t[n]=o;const r=this._resolveNegotiateUrl(e);this._logger.log(yt.Debug,`Sending negotiation request: ${r}.`);try{const e=await this._httpClient.post(r,{content:"",headers:{...t,...this._options.headers},timeout:this._options.timeout,withCredentials:this._options.withCredentials});if(200!==e.statusCode)return Promise.reject(new Error(`Unexpected status code returned from negotiate '${e.statusCode}'`));const n=JSON.parse(e.content);return(!n.negotiateVersion||n.negotiateVersion<1)&&(n.connectionToken=n.connectionId),n.useAck&&!0!==this._options._useStatefulReconnect?Promise.reject(new Ot("Client didn't negotiate Stateful Reconnect but the server did.")):n}catch(e){let t="Failed to complete negotiation with the server: "+e;return e instanceof Nt&&404===e.statusCode&&(t+=" Either this is not a SignalR endpoint or there is a proxy blocking the connection."),this._logger.log(yt.Error,t),Promise.reject(new Ot(t))}}_createConnectUrl(e,t){return t?e+(-1===e.indexOf("?")?"?":"&")+`id=${t}`:e}async _createTransport(e,t,n,o){let r=this._createConnectUrl(e,n.connectionToken);if(this._isITransport(t))return this._logger.log(yt.Debug,"Connection was provided an instance of ITransport, using that directly."),this.transport=t,await this._startTransport(r,o),void(this.connectionId=n.connectionId);const s=[],i=n.availableTransports||[];let a=n;for(const n of i){const i=this._resolveTransportOrError(n,t,o,!0===(null==a?void 0:a.useAck));if(i instanceof Error)s.push(`${n.transport} failed:`),s.push(i);else if(this._isITransport(i)){if(this.transport=i,!a){try{a=await this._getNegotiationResponse(e)}catch(e){return Promise.reject(e)}r=this._createConnectUrl(e,a.connectionToken)}try{return await this._startTransport(r,o),void(this.connectionId=a.connectionId)}catch(e){if(this._logger.log(yt.Error,`Failed to start the transport '${n.transport}': ${e}`),a=void 0,s.push(new $t(`${n.transport} failed: ${e}`,on[n.transport])),"Connecting"!==this._connectionState){const e="Failed to select transport before stop() was called.";return this._logger.log(yt.Debug,e),Promise.reject(new Mt(e))}}}}return s.length>0?Promise.reject(new Ft(`Unable to connect to the server with any of the available transports. ${s.join(" ")}`,s)):Promise.reject(new Error("None of the transports supported by the client are supported by the server."))}_constructTransport(e){switch(e){case on.WebSockets:if(!this._options.WebSocket)throw new Error("'WebSocket' is not supported in your environment.");return new ln(this._httpClient,this._accessTokenFactory,this._logger,this._options.logMessageContent,this._options.WebSocket,this._options.headers||{});case on.ServerSentEvents:if(!this._options.EventSource)throw new Error("'EventSource' is not supported in your environment.");return new cn(this._httpClient,this._httpClient._accessToken,this._logger,this._options);case on.LongPolling:return new an(this._httpClient,this._logger,this._options);default:throw new Error(`Unknown transport: ${e}.`)}}_startTransport(e,t){return this.transport.onreceive=this.onreceive,this.features.reconnect?this.transport.onclose=async n=>{let o=!1;if(this.features.resend){try{this.features.disconnected(),await this.transport.connect(e,t),await this.features.resend()}catch{o=!0}o&&this._stopConnection(n)}else this._stopConnection(n)}:this.transport.onclose=e=>this._stopConnection(e),this.transport.connect(e,t)}_resolveTransportOrError(e,t,n,o){const r=on[e.transport];if(null==r)return this._logger.log(yt.Debug,`Skipping transport '${e.transport}' because it is not supported by this client.`),new Error(`Skipping transport '${e.transport}' because it is not supported by this client.`);if(!function(e,t){return!e||0!=(t&e)}(t,r))return this._logger.log(yt.Debug,`Skipping transport '${on[r]}' because it was disabled by the client.`),new Lt(`'${on[r]}' is disabled by the client.`,r);if(!(e.transferFormats.map((e=>rn[e])).indexOf(n)>=0))return this._logger.log(yt.Debug,`Skipping transport '${on[r]}' because it does not support the requested transfer format '${rn[n]}'.`),new Error(`'${on[r]}' does not support ${rn[n]}.`);if(r===on.WebSockets&&!this._options.WebSocket||r===on.ServerSentEvents&&!this._options.EventSource)return this._logger.log(yt.Debug,`Skipping transport '${on[r]}' because it is not supported in your environment.'`),new Bt(`'${on[r]}' is not supported in your environment.`,r);this._logger.log(yt.Debug,`Selecting transport '${on[r]}'.`);try{return this.features.reconnect=r===on.WebSockets?o:void 0,this._constructTransport(r)}catch(e){return e}}_isITransport(e){return e&&"object"==typeof e&&"connect"in e}_stopConnection(e){if(this._logger.log(yt.Debug,`HttpConnection.stopConnection(${e}) called while in state ${this._connectionState}.`),this.transport=void 0,e=this._stopError||e,this._stopError=void 0,"Disconnected"!==this._connectionState){if("Connecting"===this._connectionState)throw this._logger.log(yt.Warning,`Call to HttpConnection.stopConnection(${e}) was ignored because the connection is still in the connecting state.`),new Error(`HttpConnection.stopConnection(${e}) was called while the connection is still in the connecting state.`);if("Disconnecting"===this._connectionState&&this._stopPromiseResolver(),e?this._logger.log(yt.Error,`Connection disconnected with error '${e}'.`):this._logger.log(yt.Information,"Connection disconnected."),this._sendQueue&&(this._sendQueue.stop().catch((e=>{this._logger.log(yt.Error,`TransportSendQueue.stop() threw error '${e}'.`)})),this._sendQueue=void 0),this.connectionId=void 0,this._connectionState="Disconnected",this._connectionStarted){this._connectionStarted=!1;try{this.onclose&&this.onclose(e)}catch(t){this._logger.log(yt.Error,`HttpConnection.onclose(${e}) threw error '${t}'.`)}}}else this._logger.log(yt.Debug,`Call to HttpConnection.stopConnection(${e}) was ignored because the connection is already in the disconnected state.`)}_resolveUrl(e){if(0===e.lastIndexOf("https://",0)||0===e.lastIndexOf("http://",0))return e;if(!bt.isBrowser)throw new Error(`Cannot resolve '${e}'.`);const t=window.document.createElement("a");return t.href=e,this._logger.log(yt.Information,`Normalizing '${e}' to '${t.href}'.`),t.href}_resolveNegotiateUrl(e){const t=new URL(e);t.pathname.endsWith("/")?t.pathname+="negotiate":t.pathname+="/negotiate";const n=new URLSearchParams(t.searchParams);return n.has("negotiateVersion")||n.append("negotiateVersion",this._negotiateVersion.toString()),n.has("useAck")?"true"===n.get("useAck")&&(this._options._useStatefulReconnect=!0):!0===this._options._useStatefulReconnect&&n.append("useAck","true"),t.search=n.toString(),t.toString()}}class dn{constructor(e){this._transport=e,this._buffer=[],this._executing=!0,this._sendBufferedData=new un,this._transportResult=new un,this._sendLoopPromise=this._sendLoop()}send(e){return this._bufferData(e),this._transportResult||(this._transportResult=new un),this._transportResult.promise}stop(){return this._executing=!1,this._sendBufferedData.resolve(),this._sendLoopPromise}_bufferData(e){if(this._buffer.length&&typeof this._buffer[0]!=typeof e)throw new Error(`Expected data to be of type ${typeof this._buffer} but was of type ${typeof e}`);this._buffer.push(e),this._sendBufferedData.resolve()}async _sendLoop(){for(;;){if(await this._sendBufferedData.promise,!this._executing){this._transportResult&&this._transportResult.reject("Connection stopped.");break}this._sendBufferedData=new un;const e=this._transportResult;this._transportResult=void 0;const t="string"==typeof this._buffer[0]?this._buffer.join(""):dn._concatBuffers(this._buffer);this._buffer.length=0;try{await this._transport.send(t),e.resolve()}catch(t){e.reject(t)}}}static _concatBuffers(e){const t=e.map((e=>e.byteLength)).reduce(((e,t)=>e+t)),n=new Uint8Array(t);let o=0;for(const t of e)n.set(new Uint8Array(t),o),o+=t.byteLength;return n.buffer}}class un{constructor(){this.promise=new Promise(((e,t)=>[this._resolver,this._rejecter]=[e,t]))}resolve(){this._resolver()}reject(e){this._rejecter(e)}}class pn{constructor(){this.name="json",this.version=1,this.transferFormat=rn.Text}parseMessages(e,t){if("string"!=typeof e)throw new Error("Invalid input for JSON hub protocol. Expected a string.");if(!e)return[];null===t&&(t=vt.instance);const n=mt.parse(e),o=[];for(const e of n){const n=JSON.parse(e);if("number"!=typeof n.type)throw new Error("Invalid payload.");switch(n.type){case Ht.Invocation:this._isInvocationMessage(n);break;case Ht.StreamItem:this._isStreamItemMessage(n);break;case Ht.Completion:this._isCompletionMessage(n);break;case Ht.Ping:case Ht.Close:break;case Ht.Ack:this._isAckMessage(n);break;case Ht.Sequence:this._isSequenceMessage(n);break;default:t.log(yt.Information,"Unknown message type '"+n.type+"' ignored.");continue}o.push(n)}return o}writeMessage(e){return mt.write(JSON.stringify(e))}_isInvocationMessage(e){this._assertNotEmptyString(e.target,"Invalid payload for Invocation message."),void 0!==e.invocationId&&this._assertNotEmptyString(e.invocationId,"Invalid payload for Invocation message.")}_isStreamItemMessage(e){if(this._assertNotEmptyString(e.invocationId,"Invalid payload for StreamItem message."),void 0===e.item)throw new Error("Invalid payload for StreamItem message.")}_isCompletionMessage(e){if(e.result&&e.error)throw new Error("Invalid payload for Completion message.");!e.result&&e.error&&this._assertNotEmptyString(e.error,"Invalid payload for Completion message."),this._assertNotEmptyString(e.invocationId,"Invalid payload for Completion message.")}_isAckMessage(e){if("number"!=typeof e.sequenceId)throw new Error("Invalid SequenceId for Ack message.")}_isSequenceMessage(e){if("number"!=typeof e.sequenceId)throw new Error("Invalid SequenceId for Sequence message.")}_assertNotEmptyString(e,t){if("string"!=typeof e||""===e)throw new Error(t)}}const fn={trace:yt.Trace,debug:yt.Debug,info:yt.Information,information:yt.Information,warn:yt.Warning,warning:yt.Warning,error:yt.Error,critical:yt.Critical,none:yt.None};class gn{configureLogging(e){if(_t.isRequired(e,"logging"),function(e){return void 0!==e.log}(e))this.logger=e;else if("string"==typeof e){const t=function(e){const t=fn[e.toLowerCase()];if(void 0!==t)return t;throw new Error(`Unknown log level: ${e}`)}(e);this.logger=new kt(t)}else this.logger=new kt(e);return this}withUrl(e,t){return _t.isRequired(e,"url"),_t.isNotEmpty(e,"url"),this.url=e,this.httpConnectionOptions="object"==typeof t?{...this.httpConnectionOptions,...t}:{...this.httpConnectionOptions,transport:t},this}withHubProtocol(e){return _t.isRequired(e,"protocol"),this.protocol=e,this}withAutomaticReconnect(e){if(this.reconnectPolicy)throw new Error("A reconnectPolicy has already been set.");return e?Array.isArray(e)?this.reconnectPolicy=new Vt(e):this.reconnectPolicy=e:this.reconnectPolicy=new Vt,this}withServerTimeout(e){return _t.isRequired(e,"milliseconds"),this._serverTimeoutInMilliseconds=e,this}withKeepAliveInterval(e){return _t.isRequired(e,"milliseconds"),this._keepAliveIntervalInMilliseconds=e,this}withStatefulReconnect(e){return void 0===this.httpConnectionOptions&&(this.httpConnectionOptions={}),this.httpConnectionOptions._useStatefulReconnect=!0,this._statefulReconnectBufferSize=null==e?void 0:e.bufferSize,this}build(){const e=this.httpConnectionOptions||{};if(void 0===e.logger&&(e.logger=this.logger),!this.url)throw new Error("The 'HubConnectionBuilder.withUrl' method must be called before building the connection.");const t=new hn(this.url,e);return Jt.create(t,this.logger||vt.instance,this.protocol||new pn,this.reconnectPolicy,this._serverTimeoutInMilliseconds,this._keepAliveIntervalInMilliseconds,this._statefulReconnectBufferSize)}}var mn;!function(e){e[e.Default=0]="Default",e[e.Server=1]="Server",e[e.WebAssembly=2]="WebAssembly",e[e.WebView=3]="WebView"}(mn||(mn={}));var yn,vn,wn,_n=4294967295;function bn(e,t,n){var o=Math.floor(n/4294967296),r=n;e.setUint32(t,o),e.setUint32(t+4,r)}function Sn(e,t){return 4294967296*e.getInt32(t)+e.getUint32(t+4)}var En=("undefined"==typeof process||"never"!==(null===(yn=null===process||void 0===process?void 0:process.env)||void 0===yn?void 0:yn.TEXT_ENCODING))&&"undefined"!=typeof TextEncoder&&"undefined"!=typeof TextDecoder;function Cn(e){for(var t=e.length,n=0,o=0;o=55296&&r<=56319&&o65535&&(h-=65536,s.push(h>>>10&1023|55296),h=56320|1023&h),s.push(h)}else s.push(a);s.length>=4096&&(i+=String.fromCharCode.apply(String,s),s.length=0)}return s.length>0&&(i+=String.fromCharCode.apply(String,s)),i}var xn,Rn=En?new TextDecoder:null,An=En?"undefined"!=typeof process&&"force"!==(null===(wn=null===process||void 0===process?void 0:process.env)||void 0===wn?void 0:wn.TEXT_DECODER)?200:0:_n,Pn=function(e,t){this.type=e,this.data=t},Nn=(xn=function(e,t){return xn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},xn(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}xn(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),Un=function(e){function t(n){var o=e.call(this,n)||this,r=Object.create(t.prototype);return Object.setPrototypeOf(o,r),Object.defineProperty(o,"name",{configurable:!0,enumerable:!1,value:t.name}),o}return Nn(t,e),t}(Error),Mn={type:-1,encode:function(e){var t,n,o,r;return e instanceof Date?function(e){var t,n=e.sec,o=e.nsec;if(n>=0&&o>=0&&n<=17179869183){if(0===o&&n<=4294967295){var r=new Uint8Array(4);return(t=new DataView(r.buffer)).setUint32(0,n),r}var s=n/4294967296,i=4294967295&n;return r=new Uint8Array(8),(t=new DataView(r.buffer)).setUint32(0,o<<2|3&s),t.setUint32(4,i),r}return r=new Uint8Array(12),(t=new DataView(r.buffer)).setUint32(0,o),bn(t,4,n),r}((o=1e6*((t=e.getTime())-1e3*(n=Math.floor(t/1e3))),{sec:n+(r=Math.floor(o/1e9)),nsec:o-1e9*r})):null},decode:function(e){var t=function(e){var t=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(e.byteLength){case 4:return{sec:t.getUint32(0),nsec:0};case 8:var n=t.getUint32(0);return{sec:4294967296*(3&n)+t.getUint32(4),nsec:n>>>2};case 12:return{sec:Sn(t,4),nsec:t.getUint32(0)};default:throw new Un("Unrecognized data size for timestamp (expected 4, 8, or 12): ".concat(e.length))}}(e);return new Date(1e3*t.sec+t.nsec/1e6)}},Bn=function(){function e(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(Mn)}return e.prototype.register=function(e){var t=e.type,n=e.encode,o=e.decode;if(t>=0)this.encoders[t]=n,this.decoders[t]=o;else{var r=1+t;this.builtInEncoders[r]=n,this.builtInDecoders[r]=o}},e.prototype.tryToEncode=function(e,t){for(var n=0;nthis.maxDepth)throw new Error("Too deep objects in depth ".concat(t));null==e?this.encodeNil():"boolean"==typeof e?this.encodeBoolean(e):"number"==typeof e?this.encodeNumber(e):"string"==typeof e?this.encodeString(e):this.encodeObject(e,t)},e.prototype.ensureBufferSizeToWrite=function(e){var t=this.pos+e;this.view.byteLength=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):(this.writeU8(211),this.writeI64(e)):this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))},e.prototype.writeStringHeader=function(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else{if(!(e<4294967296))throw new Error("Too long string: ".concat(e," bytes in UTF-8"));this.writeU8(219),this.writeU32(e)}},e.prototype.encodeString=function(e){if(e.length>kn){var t=Cn(e);this.ensureBufferSizeToWrite(5+t),this.writeStringHeader(t),Tn(e,this.bytes,this.pos),this.pos+=t}else t=Cn(e),this.ensureBufferSizeToWrite(5+t),this.writeStringHeader(t),function(e,t,n){for(var o=e.length,r=n,s=0;s>6&31|192;else{if(i>=55296&&i<=56319&&s>12&15|224,t[r++]=i>>6&63|128):(t[r++]=i>>18&7|240,t[r++]=i>>12&63|128,t[r++]=i>>6&63|128)}t[r++]=63&i|128}else t[r++]=i}}(e,this.bytes,this.pos),this.pos+=t},e.prototype.encodeObject=function(e,t){var n=this.extensionCodec.tryToEncode(e,this.context);if(null!=n)this.encodeExtension(n);else if(Array.isArray(e))this.encodeArray(e,t);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else{if("object"!=typeof e)throw new Error("Unrecognized object: ".concat(Object.prototype.toString.apply(e)));this.encodeMap(e,t)}},e.prototype.encodeBinary=function(e){var t=e.byteLength;if(t<256)this.writeU8(196),this.writeU8(t);else if(t<65536)this.writeU8(197),this.writeU16(t);else{if(!(t<4294967296))throw new Error("Too large binary: ".concat(t));this.writeU8(198),this.writeU32(t)}var n=Ln(e);this.writeU8a(n)},e.prototype.encodeArray=function(e,t){var n=e.length;if(n<16)this.writeU8(144+n);else if(n<65536)this.writeU8(220),this.writeU16(n);else{if(!(n<4294967296))throw new Error("Too large array: ".concat(n));this.writeU8(221),this.writeU32(n)}for(var o=0,r=e;o0&&e<=this.maxKeyLength},e.prototype.find=function(e,t,n){e:for(var o=0,r=this.caches[n-1];o=this.maxLengthPerKey?n[Math.random()*n.length|0]=o:n.push(o)},e.prototype.decode=function(e,t,n){var o=this.find(e,t,n);if(null!=o)return this.hit++,o;this.miss++;var r=Dn(e,t,n),s=Uint8Array.prototype.slice.call(e,t,t+n);return this.store(s,r),r},e}(),Hn=function(e,t){var n,o,r,s,i={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,o&&(r=2&s[0]?o.return:s[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,s[1])).done)return r;switch(o=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,o=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((r=(r=i.trys).length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]=e},e.prototype.createExtraByteError=function(e){var t=this.view,n=this.pos;return new RangeError("Extra ".concat(t.byteLength-n," of ").concat(t.byteLength," byte(s) found at buffer[").concat(e,"]"))},e.prototype.decode=function(e){this.reinitializeState(),this.setBuffer(e);var t=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return t},e.prototype.decodeMulti=function(e){return Hn(this,(function(t){switch(t.label){case 0:this.reinitializeState(),this.setBuffer(e),t.label=1;case 1:return this.hasRemaining(1)?[4,this.doDecodeSync()]:[3,3];case 2:return t.sent(),[3,1];case 3:return[2]}}))},e.prototype.decodeAsync=function(e){var t,n,o,r,s,i,a;return s=this,void 0,a=function(){var s,i,a,c,l,h,d,u;return Hn(this,(function(p){switch(p.label){case 0:s=!1,p.label=1;case 1:p.trys.push([1,6,7,12]),t=jn(e),p.label=2;case 2:return[4,t.next()];case 3:if((n=p.sent()).done)return[3,5];if(a=n.value,s)throw this.createExtraByteError(this.totalPos);this.appendBuffer(a);try{i=this.doDecodeSync(),s=!0}catch(e){if(!(e instanceof Jn))throw e}this.totalPos+=this.pos,p.label=4;case 4:return[3,2];case 5:return[3,12];case 6:return c=p.sent(),o={error:c},[3,12];case 7:return p.trys.push([7,,10,11]),n&&!n.done&&(r=t.return)?[4,r.call(t)]:[3,9];case 8:p.sent(),p.label=9;case 9:return[3,11];case 10:if(o)throw o.error;return[7];case 11:return[7];case 12:if(s){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return[2,i]}throw h=(l=this).headByte,d=l.pos,u=l.totalPos,new RangeError("Insufficient data in parsing ".concat(On(h)," at ").concat(u," (").concat(d," in the current buffer)"))}}))},new((i=void 0)||(i=Promise))((function(e,t){function n(e){try{r(a.next(e))}catch(e){t(e)}}function o(e){try{r(a.throw(e))}catch(e){t(e)}}function r(t){var r;t.done?e(t.value):(r=t.value,r instanceof i?r:new i((function(e){e(r)}))).then(n,o)}r((a=a.apply(s,[])).next())}))},e.prototype.decodeArrayStream=function(e){return this.decodeMultiAsync(e,!0)},e.prototype.decodeStream=function(e){return this.decodeMultiAsync(e,!1)},e.prototype.decodeMultiAsync=function(e,t){return function(n,o,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s,i=function(){var n,o,r,s,i,a,c,l,h;return Hn(this,(function(d){switch(d.label){case 0:n=t,o=-1,d.label=1;case 1:d.trys.push([1,13,14,19]),r=jn(e),d.label=2;case 2:return[4,Wn(r.next())];case 3:if((s=d.sent()).done)return[3,12];if(i=s.value,t&&0===o)throw this.createExtraByteError(this.totalPos);this.appendBuffer(i),n&&(o=this.readArraySize(),n=!1,this.complete()),d.label=4;case 4:d.trys.push([4,9,,10]),d.label=5;case 5:return[4,Wn(this.doDecodeSync())];case 6:return[4,d.sent()];case 7:return d.sent(),0==--o?[3,8]:[3,5];case 8:return[3,10];case 9:if(!((a=d.sent())instanceof Jn))throw a;return[3,10];case 10:this.totalPos+=this.pos,d.label=11;case 11:return[3,2];case 12:return[3,19];case 13:return c=d.sent(),l={error:c},[3,19];case 14:return d.trys.push([14,,17,18]),s&&!s.done&&(h=r.return)?[4,Wn(h.call(r))]:[3,16];case 15:d.sent(),d.label=16;case 16:return[3,18];case 17:if(l)throw l.error;return[7];case 18:return[7];case 19:return[2]}}))}.apply(n,o||[]),a=[];return s={},c("next"),c("throw"),c("return"),s[Symbol.asyncIterator]=function(){return this},s;function c(e){i[e]&&(s[e]=function(t){return new Promise((function(n,o){a.push([e,t,n,o])>1||l(e,t)}))})}function l(e,t){try{(n=i[e](t)).value instanceof Wn?Promise.resolve(n.value.v).then(h,d):u(a[0][2],n)}catch(e){u(a[0][3],e)}var n}function h(e){l("next",e)}function d(e){l("throw",e)}function u(e,t){e(t),a.shift(),a.length&&l(a[0][0],a[0][1])}}(this,arguments)},e.prototype.doDecodeSync=function(){e:for(;;){var e=this.readHeadByte(),t=void 0;if(e>=224)t=e-256;else if(e<192)if(e<128)t=e;else if(e<144){if(0!=(o=e-128)){this.pushMapState(o),this.complete();continue e}t={}}else if(e<160){if(0!=(o=e-144)){this.pushArrayState(o),this.complete();continue e}t=[]}else{var n=e-160;t=this.decodeUtf8String(n,0)}else if(192===e)t=null;else if(194===e)t=!1;else if(195===e)t=!0;else if(202===e)t=this.readF32();else if(203===e)t=this.readF64();else if(204===e)t=this.readU8();else if(205===e)t=this.readU16();else if(206===e)t=this.readU32();else if(207===e)t=this.readU64();else if(208===e)t=this.readI8();else if(209===e)t=this.readI16();else if(210===e)t=this.readI32();else if(211===e)t=this.readI64();else if(217===e)n=this.lookU8(),t=this.decodeUtf8String(n,1);else if(218===e)n=this.lookU16(),t=this.decodeUtf8String(n,2);else if(219===e)n=this.lookU32(),t=this.decodeUtf8String(n,4);else if(220===e){if(0!==(o=this.readU16())){this.pushArrayState(o),this.complete();continue e}t=[]}else if(221===e){if(0!==(o=this.readU32())){this.pushArrayState(o),this.complete();continue e}t=[]}else if(222===e){if(0!==(o=this.readU16())){this.pushMapState(o),this.complete();continue e}t={}}else if(223===e){if(0!==(o=this.readU32())){this.pushMapState(o),this.complete();continue e}t={}}else if(196===e){var o=this.lookU8();t=this.decodeBinary(o,1)}else if(197===e)o=this.lookU16(),t=this.decodeBinary(o,2);else if(198===e)o=this.lookU32(),t=this.decodeBinary(o,4);else if(212===e)t=this.decodeExtension(1,0);else if(213===e)t=this.decodeExtension(2,0);else if(214===e)t=this.decodeExtension(4,0);else if(215===e)t=this.decodeExtension(8,0);else if(216===e)t=this.decodeExtension(16,0);else if(199===e)o=this.lookU8(),t=this.decodeExtension(o,1);else if(200===e)o=this.lookU16(),t=this.decodeExtension(o,2);else{if(201!==e)throw new Un("Unrecognized type byte: ".concat(On(e)));o=this.lookU32(),t=this.decodeExtension(o,4)}this.complete();for(var r=this.stack;r.length>0;){var s=r[r.length-1];if(0===s.type){if(s.array[s.position]=t,s.position++,s.position!==s.size)continue e;r.pop(),t=s.array}else{if(1===s.type){if("string"!=(i=typeof t)&&"number"!==i)throw new Un("The type of key must be string or number but "+typeof t);if("__proto__"===t)throw new Un("The key __proto__ is not allowed");s.key=t,s.type=2;continue e}if(s.map[s.key]=t,s.readCount++,s.readCount!==s.size){s.key=null,s.type=1;continue e}r.pop(),t=s.map}}return t}var i},e.prototype.readHeadByte=function(){return-1===this.headByte&&(this.headByte=this.readU8()),this.headByte},e.prototype.complete=function(){this.headByte=-1},e.prototype.readArraySize=function(){var e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:if(e<160)return e-144;throw new Un("Unrecognized array type byte: ".concat(On(e)))}},e.prototype.pushMapState=function(e){if(e>this.maxMapLength)throw new Un("Max length exceeded: map length (".concat(e,") > maxMapLengthLength (").concat(this.maxMapLength,")"));this.stack.push({type:1,size:e,key:null,readCount:0,map:{}})},e.prototype.pushArrayState=function(e){if(e>this.maxArrayLength)throw new Un("Max length exceeded: array length (".concat(e,") > maxArrayLength (").concat(this.maxArrayLength,")"));this.stack.push({type:0,size:e,array:new Array(e),position:0})},e.prototype.decodeUtf8String=function(e,t){var n;if(e>this.maxStrLength)throw new Un("Max length exceeded: UTF-8 byte length (".concat(e,") > maxStrLength (").concat(this.maxStrLength,")"));if(this.bytes.byteLengthAn?function(e,t,n){var o=e.subarray(t,t+n);return Rn.decode(o)}(this.bytes,r,e):Dn(this.bytes,r,e),this.pos+=t+e,o},e.prototype.stateIsMapKey=function(){return this.stack.length>0&&1===this.stack[this.stack.length-1].type},e.prototype.decodeBinary=function(e,t){if(e>this.maxBinLength)throw new Un("Max length exceeded: bin length (".concat(e,") > maxBinLength (").concat(this.maxBinLength,")"));if(!this.hasRemaining(e+t))throw Kn;var n=this.pos+t,o=this.bytes.subarray(n,n+e);return this.pos+=t+e,o},e.prototype.decodeExtension=function(e,t){if(e>this.maxExtLength)throw new Un("Max length exceeded: ext length (".concat(e,") > maxExtLength (").concat(this.maxExtLength,")"));var n=this.view.getInt8(this.pos+t),o=this.decodeBinary(e,t+1);return this.extensionCodec.decode(o,n,this.context)},e.prototype.lookU8=function(){return this.view.getUint8(this.pos)},e.prototype.lookU16=function(){return this.view.getUint16(this.pos)},e.prototype.lookU32=function(){return this.view.getUint32(this.pos)},e.prototype.readU8=function(){var e=this.view.getUint8(this.pos);return this.pos++,e},e.prototype.readI8=function(){var e=this.view.getInt8(this.pos);return this.pos++,e},e.prototype.readU16=function(){var e=this.view.getUint16(this.pos);return this.pos+=2,e},e.prototype.readI16=function(){var e=this.view.getInt16(this.pos);return this.pos+=2,e},e.prototype.readU32=function(){var e=this.view.getUint32(this.pos);return this.pos+=4,e},e.prototype.readI32=function(){var e=this.view.getInt32(this.pos);return this.pos+=4,e},e.prototype.readU64=function(){var e,t,n=(e=this.view,t=this.pos,4294967296*e.getUint32(t)+e.getUint32(t+4));return this.pos+=8,n},e.prototype.readI64=function(){var e=Sn(this.view,this.pos);return this.pos+=8,e},e.prototype.readF32=function(){var e=this.view.getFloat32(this.pos);return this.pos+=4,e},e.prototype.readF64=function(){var e=this.view.getFloat64(this.pos);return this.pos+=8,e},e}();class Yn{static write(e){let t=e.byteLength||e.length;const n=[];do{let e=127&t;t>>=7,t>0&&(e|=128),n.push(e)}while(t>0);t=e.byteLength||e.length;const o=new Uint8Array(n.length+t);return o.set(n,0),o.set(e,n.length),o.buffer}static parse(e){const t=[],n=new Uint8Array(e),o=[0,7,14,21,28];for(let r=0;r7)throw new Error("Messages bigger than 2GB are not supported.");if(!(n.byteLength>=r+i+a))throw new Error("Incomplete message.");t.push(n.slice?n.slice(r+i,r+i+a):n.subarray(r+i,r+i+a)),r=r+i+a}return t}}const Gn=new Uint8Array([145,Ht.Ping]);class Qn{constructor(e){this.name="messagepack",this.version=1,this.transferFormat=rn.Binary,this._errorResult=1,this._voidResult=2,this._nonVoidResult=3,e=e||{},this._encoder=new $n(e.extensionCodec,e.context,e.maxDepth,e.initialBufferSize,e.sortKeys,e.forceFloat32,e.ignoreUndefined,e.forceIntegerToFloat),this._decoder=new Xn(e.extensionCodec,e.context,e.maxStrLength,e.maxBinLength,e.maxArrayLength,e.maxMapLength,e.maxExtLength)}parseMessages(e,t){if(!(n=e)||"undefined"==typeof ArrayBuffer||!(n instanceof ArrayBuffer||n.constructor&&"ArrayBuffer"===n.constructor.name))throw new Error("Invalid input for MessagePack hub protocol. Expected an ArrayBuffer.");var n;null===t&&(t=vt.instance);const o=Yn.parse(e),r=[];for(const e of o){const n=this._parseMessage(e,t);n&&r.push(n)}return r}writeMessage(e){switch(e.type){case Ht.Invocation:return this._writeInvocation(e);case Ht.StreamInvocation:return this._writeStreamInvocation(e);case Ht.StreamItem:return this._writeStreamItem(e);case Ht.Completion:return this._writeCompletion(e);case Ht.Ping:return Yn.write(Gn);case Ht.CancelInvocation:return this._writeCancelInvocation(e);case Ht.Close:return this._writeClose();case Ht.Ack:return this._writeAck(e);case Ht.Sequence:return this._writeSequence(e);default:throw new Error("Invalid message type.")}}_parseMessage(e,t){if(0===e.length)throw new Error("Invalid payload.");const n=this._decoder.decode(e);if(0===n.length||!(n instanceof Array))throw new Error("Invalid payload.");const o=n[0];switch(o){case Ht.Invocation:return this._createInvocationMessage(this._readHeaders(n),n);case Ht.StreamItem:return this._createStreamItemMessage(this._readHeaders(n),n);case Ht.Completion:return this._createCompletionMessage(this._readHeaders(n),n);case Ht.Ping:return this._createPingMessage(n);case Ht.Close:return this._createCloseMessage(n);case Ht.Ack:return this._createAckMessage(n);case Ht.Sequence:return this._createSequenceMessage(n);default:return t.log(yt.Information,"Unknown message type '"+o+"' ignored."),null}}_createCloseMessage(e){if(e.length<2)throw new Error("Invalid payload for Close message.");return{allowReconnect:e.length>=3?e[2]:void 0,error:e[1],type:Ht.Close}}_createPingMessage(e){if(e.length<1)throw new Error("Invalid payload for Ping message.");return{type:Ht.Ping}}_createInvocationMessage(e,t){if(t.length<5)throw new Error("Invalid payload for Invocation message.");const n=t[2];return n?{arguments:t[4],headers:e,invocationId:n,streamIds:[],target:t[3],type:Ht.Invocation}:{arguments:t[4],headers:e,streamIds:[],target:t[3],type:Ht.Invocation}}_createStreamItemMessage(e,t){if(t.length<4)throw new Error("Invalid payload for StreamItem message.");return{headers:e,invocationId:t[2],item:t[3],type:Ht.StreamItem}}_createCompletionMessage(e,t){if(t.length<4)throw new Error("Invalid payload for Completion message.");const n=t[3];if(n!==this._voidResult&&t.length<5)throw new Error("Invalid payload for Completion message.");let o,r;switch(n){case this._errorResult:o=t[4];break;case this._nonVoidResult:r=t[4]}return{error:o,headers:e,invocationId:t[2],result:r,type:Ht.Completion}}_createAckMessage(e){if(e.length<1)throw new Error("Invalid payload for Ack message.");return{sequenceId:e[1],type:Ht.Ack}}_createSequenceMessage(e){if(e.length<1)throw new Error("Invalid payload for Sequence message.");return{sequenceId:e[1],type:Ht.Sequence}}_writeInvocation(e){let t;return t=e.streamIds?this._encoder.encode([Ht.Invocation,e.headers||{},e.invocationId||null,e.target,e.arguments,e.streamIds]):this._encoder.encode([Ht.Invocation,e.headers||{},e.invocationId||null,e.target,e.arguments]),Yn.write(t.slice())}_writeStreamInvocation(e){let t;return t=e.streamIds?this._encoder.encode([Ht.StreamInvocation,e.headers||{},e.invocationId,e.target,e.arguments,e.streamIds]):this._encoder.encode([Ht.StreamInvocation,e.headers||{},e.invocationId,e.target,e.arguments]),Yn.write(t.slice())}_writeStreamItem(e){const t=this._encoder.encode([Ht.StreamItem,e.headers||{},e.invocationId,e.item]);return Yn.write(t.slice())}_writeCompletion(e){const t=e.error?this._errorResult:void 0!==e.result?this._nonVoidResult:this._voidResult;let n;switch(t){case this._errorResult:n=this._encoder.encode([Ht.Completion,e.headers||{},e.invocationId,t,e.error]);break;case this._voidResult:n=this._encoder.encode([Ht.Completion,e.headers||{},e.invocationId,t]);break;case this._nonVoidResult:n=this._encoder.encode([Ht.Completion,e.headers||{},e.invocationId,t,e.result])}return Yn.write(n.slice())}_writeCancelInvocation(e){const t=this._encoder.encode([Ht.CancelInvocation,e.headers||{},e.invocationId]);return Yn.write(t.slice())}_writeClose(){const e=this._encoder.encode([Ht.Close,null]);return Yn.write(e.slice())}_writeAck(e){const t=this._encoder.encode([Ht.Ack,e.sequenceId]);return Yn.write(t.slice())}_writeSequence(e){const t=this._encoder.encode([Ht.Sequence,e.sequenceId]);return Yn.write(t.slice())}_readHeaders(e){const t=e[1];if("object"!=typeof t)throw new Error("Invalid headers.");return t}}const Zn="function"==typeof TextDecoder?new TextDecoder("utf-8"):null,eo=Zn?Zn.decode.bind(Zn):function(e){let t=0;const n=e.length,o=[],r=[];for(;t65535&&(r-=65536,o.push(r>>>10&1023|55296),r=56320|1023&r),o.push(r)}o.length>1024&&(r.push(String.fromCharCode.apply(null,o)),o.length=0)}return r.push(String.fromCharCode.apply(null,o)),r.join("")},to=Math.pow(2,32),no=Math.pow(2,21)-1;function oo(e,t){return e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24}function ro(e,t){return e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24>>>0)}function so(e,t){const n=ro(e,t+4);if(n>no)throw new Error(`Cannot read uint64 with high order part ${n}, because the result would exceed Number.MAX_SAFE_INTEGER.`);return n*to+ro(e,t)}class io{constructor(e){this.batchData=e;const t=new ho(e);this.arrayRangeReader=new uo(e),this.arrayBuilderSegmentReader=new po(e),this.diffReader=new ao(e),this.editReader=new co(e,t),this.frameReader=new lo(e,t)}updatedComponents(){return oo(this.batchData,this.batchData.length-20)}referenceFrames(){return oo(this.batchData,this.batchData.length-16)}disposedComponentIds(){return oo(this.batchData,this.batchData.length-12)}disposedEventHandlerIds(){return oo(this.batchData,this.batchData.length-8)}updatedComponentsEntry(e,t){const n=e+4*t;return oo(this.batchData,n)}referenceFramesEntry(e,t){return e+20*t}disposedComponentIdsEntry(e,t){const n=e+4*t;return oo(this.batchData,n)}disposedEventHandlerIdsEntry(e,t){const n=e+8*t;return so(this.batchData,n)}}class ao{constructor(e){this.batchDataUint8=e}componentId(e){return oo(this.batchDataUint8,e)}edits(e){return e+4}editsEntry(e,t){return e+16*t}}class co{constructor(e,t){this.batchDataUint8=e,this.stringReader=t}editType(e){return oo(this.batchDataUint8,e)}siblingIndex(e){return oo(this.batchDataUint8,e+4)}newTreeIndex(e){return oo(this.batchDataUint8,e+8)}moveToSiblingIndex(e){return oo(this.batchDataUint8,e+8)}removedAttributeName(e){const t=oo(this.batchDataUint8,e+12);return this.stringReader.readString(t)}}class lo{constructor(e,t){this.batchDataUint8=e,this.stringReader=t}frameType(e){return oo(this.batchDataUint8,e)}subtreeLength(e){return oo(this.batchDataUint8,e+4)}elementReferenceCaptureId(e){const t=oo(this.batchDataUint8,e+4);return this.stringReader.readString(t)}componentId(e){return oo(this.batchDataUint8,e+8)}elementName(e){const t=oo(this.batchDataUint8,e+8);return this.stringReader.readString(t)}textContent(e){const t=oo(this.batchDataUint8,e+4);return this.stringReader.readString(t)}markupContent(e){const t=oo(this.batchDataUint8,e+4);return this.stringReader.readString(t)}attributeName(e){const t=oo(this.batchDataUint8,e+4);return this.stringReader.readString(t)}attributeValue(e){const t=oo(this.batchDataUint8,e+8);return this.stringReader.readString(t)}attributeEventHandlerId(e){return so(this.batchDataUint8,e+12)}}class ho{constructor(e){this.batchDataUint8=e,this.stringTableStartIndex=oo(e,e.length-4)}readString(e){if(-1===e)return null;{const n=oo(this.batchDataUint8,this.stringTableStartIndex+4*e),o=function(e,t){let n=0,o=0;for(let r=0;r<4;r++){const s=e[t+r];if(n|=(127&s)<this.nextBatchId)return this.fatalError?(this.logger.log(ot.Debug,`Received a new batch ${e} but errored out on a previous batch ${this.nextBatchId-1}`),void await n.send("OnRenderCompleted",this.nextBatchId-1,this.fatalError.toString())):void this.logger.log(ot.Debug,`Waiting for batch ${this.nextBatchId}. Batch ${e} not processed.`);try{this.nextBatchId++,this.logger.log(ot.Debug,`Applying batch ${e}.`),function(e,t){const n=fe[e];if(!n)throw new Error(`There is no browser renderer with ID ${e}.`);const o=t.arrayRangeReader,r=t.updatedComponents(),s=o.values(r),i=o.count(r),a=t.referenceFrames(),c=o.values(a),l=t.diffReader;for(let e=0;e{e.onclick=function(e){location.reload(),e.preventDefault()}})),document.querySelectorAll("#blazor-error-ui .dismiss").forEach((e=>{e.onclick=function(e){const t=document.querySelector("#blazor-error-ui");t&&(t.style.display="none"),e.preventDefault()}})))}class yo{constructor(t,n,o,r){this._renderingFailed=!1,this._disposed=!1,this._circuitId=void 0,this._applicationState=n,this._componentManager=t,this._options=o,this._logger=r,this._renderQueue=new fo(this._logger),this._dispatcher=e.attachDispatcher(this)}start(){if(this.isDisposedOrDisposing())throw new Error("Cannot start a disposed circuit.");return this._startPromise||(this._startPromise=this.startCore()),this._startPromise}async startCore(){if(this._connection=await this.startConnection(),this._connection.state!==jt.Connected)return!1;const e=JSON.stringify(this._componentManager.initialComponents.map((e=>{return t=e,{...t,start:void 0,end:void 0};var t})));return this._circuitId=await this._connection.invoke("StartCircuit",Ne.getBaseURI(),Ne.getLocationHref(),e,this._applicationState||""),!!this._circuitId}async startConnection(){var e,t;const n=new Qn;n.name="blazorpack";const o=(new gn).withUrl("_blazor").withHubProtocol(n);this._options.configureSignalR(o);const r=o.build();r.on("JS.AttachComponent",((e,t)=>function(e,t,n,o){let r=fe[e];r||(r=new he(e),fe[e]=r),r.attachRootComponentToLogicalElement(n,t,!1)}(mn.Server,this.resolveElement(t,e),e))),r.on("JS.BeginInvokeJS",this._dispatcher.beginInvokeJSFromDotNet.bind(this._dispatcher)),r.on("JS.EndInvokeDotNet",this._dispatcher.endInvokeDotNetFromJS.bind(this._dispatcher)),r.on("JS.ReceiveByteArray",this._dispatcher.receiveByteArray.bind(this._dispatcher)),r.on("JS.BeginTransmitStream",(e=>{const t=new ReadableStream({start:t=>{r.stream("SendDotNetStreamToJS",e).subscribe({next:e=>t.enqueue(e),complete:()=>t.close(),error:e=>t.error(e)})}});this._dispatcher.supplyDotNetStream(e,t)})),r.on("JS.RenderBatch",(async(e,t)=>{var n,o;this._logger.log(yt.Debug,`Received render batch with id ${e} and ${t.byteLength} bytes.`),await this._renderQueue.processBatch(e,t,this._connection),null===(o=(n=this._componentManager).onAfterRenderBatch)||void 0===o||o.call(n,mn.Server)})),r.on("JS.EndLocationChanging",nt._internal.navigationManager.endLocationChanging),r.onclose((e=>!this._disposed&&!this._renderingFailed&&this._options.reconnectionHandler.onConnectionDown(this._options.reconnectionOptions,e))),r.on("JS.Error",(e=>{this._renderingFailed=!0,this.unhandledError(e),mo()}));try{await r.start()}catch(e){if(this.unhandledError(e),"FailedToNegotiateWithServerError"===e.errorType)throw e;mo(),e.innerErrors&&(e.innerErrors.some((e=>"UnsupportedTransportError"===e.errorType&&e.transport===on.WebSockets))?this._logger.log(yt.Error,"Unable to connect, please ensure you are using an updated browser that supports WebSockets."):e.innerErrors.some((e=>"FailedToStartTransportError"===e.errorType&&e.transport===on.WebSockets))?this._logger.log(yt.Error,"Unable to connect, please ensure WebSockets are available. A VPN or proxy may be blocking the connection."):e.innerErrors.some((e=>"DisabledTransportError"===e.errorType&&e.transport===on.LongPolling))&&this._logger.log(yt.Error,"Unable to initiate a SignalR connection to the server. This might be because the server is not configured to support WebSockets. For additional details, visit https://aka.ms/blazor-server-websockets-error."))}return(null===(t=null===(e=r.connection)||void 0===e?void 0:e.features)||void 0===t?void 0:t.inherentKeepAlive)&&this._logger.log(yt.Warning,"Failed to connect via WebSockets, using the Long Polling fallback transport. This may be due to a VPN or proxy blocking the connection. To troubleshoot this, visit https://aka.ms/blazor-server-using-fallback-long-polling."),r}async disconnect(){var e;await(null===(e=this._connection)||void 0===e?void 0:e.stop())}async reconnect(){if(!this._circuitId)throw new Error("Circuit host not initialized.");return this._connection.state===jt.Connected||(this._connection=await this.startConnection(),!!await this._connection.invoke("ConnectCircuit",this._circuitId)&&(this._options.reconnectionHandler.onConnectionUp(),!0))}beginInvokeDotNetFromJS(e,t,n,o,r){this.throwIfDispatchingWhenDisposed(),this._connection.send("BeginInvokeDotNetFromJS",e?e.toString():null,t,n,o||0,r)}endInvokeJSFromDotNet(e,t,n){this.throwIfDispatchingWhenDisposed(),this._connection.send("EndInvokeJSFromDotNet",e,t,n)}sendByteArray(e,t){this.throwIfDispatchingWhenDisposed(),this._connection.send("ReceiveByteArray",e,t)}throwIfDispatchingWhenDisposed(){if(this._disposed)throw new Error("The circuit associated with this dispatcher is no longer available.")}sendLocationChanged(e,t,n){return this._connection.send("OnLocationChanged",e,t,n)}sendLocationChanging(e,t,n,o){return this._connection.send("OnLocationChanging",e,t,n,o)}sendJsDataStream(e,t,n){return function(e,t,n,o){setTimeout((async()=>{let r=5,s=(new Date).valueOf();try{const i=t instanceof Blob?t.size:t.byteLength;let a=0,c=0;for(;a1)await e.send("ReceiveJSDataChunk",n,c,h,null);else{if(!await e.invoke("ReceiveJSDataChunk",n,c,h,null))break;const t=(new Date).valueOf(),o=t-s;s=t,r=Math.max(1,Math.round(500/Math.max(1,o)))}a+=l,c++}}catch(t){await e.send("ReceiveJSDataChunk",n,-1,null,t.toString())}}),0)}(this._connection,e,t,n)}resolveElement(e,t){const n=function(e){const t=f.get(e);if(t)return f.delete(e),t}(e);if(n)return O(n,!0);const o=Number.parseInt(e);if(!Number.isNaN(o))return function(e){const{start:t,end:n}=e,o=t[$];if(o){if(o!==e)throw new Error("The start component comment was already associated with another component descriptor.");return t}const r=t.parentNode;if(!r)throw new Error(`Comment not connected to the DOM ${t.textContent}`);const s=O(r,!0),i=K(s);t[L]=s,t[$]=e;const a=O(t);if(n){const e=K(a),o=Array.prototype.indexOf.call(i,a)+1;let r=null;for(;r!==n;){const n=i.splice(o,1)[0];if(!n)throw new Error("Could not find the end component comment in the parent logical node list");n[L]=t,e.push(n),r=n}}return a}(this._componentManager.resolveRootComponent(o,t));throw new Error(`Invalid sequence number or identifier '${e}'.`)}getRootComponentManager(){return this._componentManager}unhandledError(e){this._logger.log(yt.Error,e),this.disconnect()}getDisconnectFormData(){const e=new FormData,t=this._circuitId;return e.append("circuitId",t),e}didRenderingFail(){return this._renderingFailed}isDisposedOrDisposing(){return void 0!==this._disposePromise}sendDisconnectBeacon(){if(this._disposed)return;const e=this.getDisconnectFormData();this._disposed=navigator.sendBeacon("_blazor/disconnect",e)}dispose(){return this._disposePromise||(this._disposePromise=this.disposeCore()),this._disposePromise}async disposeCore(){var e;if(!this._startPromise)return void(this._disposed=!0);await this._startPromise,this._disposed=!0,null===(e=this._connection)||void 0===e||e.stop();const t=this.getDisconnectFormData();fetch("_blazor/disconnect",{method:"POST",body:t}),function(e){if(!S.delete(e))throw new Error(`Interop methods are not registered for renderer ${e}`)}(mn.Server)}}const vo={configureSignalR:e=>{},logLevel:ot.Warning,reconnectionOptions:{maxRetries:8,retryIntervalMilliseconds:2e4,dialogId:"components-reconnect-modal"}};class wo{constructor(e,t,n,o){this.maxRetries=t,this.document=n,this.logger=o,this.addedToDom=!1,this.modal=this.document.createElement("div"),this.modal.id=e,this.maxRetries=t,this.modal.style.cssText=["position: fixed","top: 0","right: 0","bottom: 0","left: 0","z-index: 1050","display: none","overflow: hidden","background-color: #fff","opacity: 0.8","text-align: center","font-weight: bold","transition: visibility 0s linear 500ms"].join(";"),this.message=this.document.createElement("h5"),this.message.style.cssText="margin-top: 20px",this.button=this.document.createElement("button"),this.button.style.cssText="margin:5px auto 5px",this.button.textContent="Retry";const r=this.document.createElement("a");r.addEventListener("click",(()=>location.reload())),r.textContent="reload",this.reloadParagraph=this.document.createElement("p"),this.reloadParagraph.textContent="Alternatively, ",this.reloadParagraph.appendChild(r),this.modal.appendChild(this.message),this.modal.appendChild(this.button),this.modal.appendChild(this.reloadParagraph),this.loader=this.getLoader(),this.message.after(this.loader),this.button.addEventListener("click",(async()=>{this.show();try{await nt.reconnect()||this.rejected()}catch(e){this.logger.log(ot.Error,e),this.failed()}}))}show(){this.addedToDom||(this.addedToDom=!0,this.document.body.appendChild(this.modal)),this.modal.style.display="block",this.loader.style.display="inline-block",this.button.style.display="none",this.reloadParagraph.style.display="none",this.message.textContent="Attempting to reconnect to the server...",this.modal.style.visibility="hidden",setTimeout((()=>{this.modal.style.visibility="visible"}),0)}update(e){this.message.textContent=`Attempting to reconnect to the server: ${e} of ${this.maxRetries}`}hide(){this.modal.style.display="none"}failed(){this.button.style.display="block",this.reloadParagraph.style.display="none",this.loader.style.display="none";const e=this.document.createTextNode("Reconnection failed. Try "),t=this.document.createElement("a");t.textContent="reloading",t.setAttribute("href",""),t.addEventListener("click",(()=>location.reload()));const n=this.document.createTextNode(" the page if you're unable to reconnect.");this.message.replaceChildren(e,t,n)}rejected(){this.button.style.display="none",this.reloadParagraph.style.display="none",this.loader.style.display="none";const e=this.document.createTextNode("Could not reconnect to the server. "),t=this.document.createElement("a");t.textContent="Reload",t.setAttribute("href",""),t.addEventListener("click",(()=>location.reload()));const n=this.document.createTextNode(" the page to restore functionality.");this.message.replaceChildren(e,t,n)}getLoader(){const e=this.document.createElement("div");return e.style.cssText=["border: 0.3em solid #f3f3f3","border-top: 0.3em solid #3498db","border-radius: 50%","width: 2em","height: 2em","display: inline-block"].join(";"),e.animate([{transform:"rotate(0deg)"},{transform:"rotate(360deg)"}],{duration:2e3,iterations:1/0}),e}}class _o{constructor(e,t,n){this.dialog=e,this.maxRetries=t,this.document=n,this.document=n;const o=this.document.getElementById(_o.MaxRetriesId);o&&(o.innerText=this.maxRetries.toString())}show(){this.removeClasses(),this.dialog.classList.add(_o.ShowClassName)}update(e){const t=this.document.getElementById(_o.CurrentAttemptId);t&&(t.innerText=e.toString())}hide(){this.removeClasses(),this.dialog.classList.add(_o.HideClassName)}failed(){this.removeClasses(),this.dialog.classList.add(_o.FailedClassName)}rejected(){this.removeClasses(),this.dialog.classList.add(_o.RejectedClassName)}removeClasses(){this.dialog.classList.remove(_o.ShowClassName,_o.HideClassName,_o.FailedClassName,_o.RejectedClassName)}}_o.ShowClassName="components-reconnect-show",_o.HideClassName="components-reconnect-hide",_o.FailedClassName="components-reconnect-failed",_o.RejectedClassName="components-reconnect-rejected",_o.MaxRetriesId="components-reconnect-max-retries",_o.CurrentAttemptId="components-reconnect-current-attempt";class bo{constructor(e,t,n){this._currentReconnectionProcess=null,this._logger=e,this._reconnectionDisplay=t,this._reconnectCallback=n||nt.reconnect}onConnectionDown(e,t){if(!this._reconnectionDisplay){const t=document.getElementById(e.dialogId);this._reconnectionDisplay=t?new _o(t,e.maxRetries,document):new wo(e.dialogId,e.maxRetries,document,this._logger)}this._currentReconnectionProcess||(this._currentReconnectionProcess=new So(e,this._logger,this._reconnectCallback,this._reconnectionDisplay))}onConnectionUp(){this._currentReconnectionProcess&&(this._currentReconnectionProcess.dispose(),this._currentReconnectionProcess=null)}}class So{constructor(e,t,n,o){this.logger=t,this.reconnectCallback=n,this.isDisposed=!1,this.reconnectDisplay=o,this.reconnectDisplay.show(),this.attemptPeriodicReconnection(e)}dispose(){this.isDisposed=!0,this.reconnectDisplay.hide()}async attemptPeriodicReconnection(e){for(let t=0;tSo.MaximumFirstRetryInterval?So.MaximumFirstRetryInterval:e.retryIntervalMilliseconds;if(await this.delay(n),this.isDisposed)break;try{return await this.reconnectCallback()?void 0:void this.reconnectDisplay.rejected()}catch(e){this.logger.log(ot.Error,e)}}this.reconnectDisplay.failed()}delay(e){return new Promise((t=>setTimeout(t,e)))}}So.MaximumFirstRetryInterval=3e3;class Eo{constructor(){this.afterStartedCallbacks=[]}async importInitializersAsync(e,t){await Promise.all(e.map((e=>async function(e,n){const o=function(e){const t=document.baseURI;return t.endsWith("/")?`${t}${e}`:`${t}/${e}`}(n),r=await import(o);if(void 0===r)return;const{beforeStart:s,afterStarted:i}=r;return i&&e.afterStartedCallbacks.push(i),s?s(...t):void 0}(this,e))))}async invokeAfterStartedCallbacks(e){await I,await Promise.all(this.afterStartedCallbacks.map((t=>t(e))))}}let Co,Io,ko,To,Do=!1;async function xo(e){if(Do)throw new Error("Blazor Server has already started.");Do=!0,Co=at(document)||"",To=new st(ko.logLevel),Io=new yo(e,Co,ko,To),To.log(ot.Information,"Starting up Blazor server-side application."),nt.reconnect=async()=>!(Io.didRenderingFail()||!await Io.reconnect()&&(To.log(ot.Information,"Reconnection attempt to the circuit was rejected by the server. This may indicate that the associated state is no longer available on the server."),1)),nt.defaultReconnectionHandler=new bo(To),ko.reconnectionHandler=ko.reconnectionHandler||nt.defaultReconnectionHandler,nt._internal.navigationManager.listenForNavigationEvents(((e,t,n)=>Io.sendLocationChanged(e,t,n)),((e,t,n,o)=>Io.sendLocationChanging(e,t,n,o))),nt._internal.forceCloseConnection=()=>Io.disconnect(),nt._internal.sendJSDataStream=(e,t,n)=>Io.sendJsDataStream(e,t,n);const t=await async function(e){const t=await fetch("_blazor/initializers",{method:"GET",credentials:"include",cache:"no-cache"}),n=await t.json(),o=new Eo;return await o.importInitializersAsync(n,[e]),o}(ko);if(!await Io.start())return void To.log(ot.Error,"Failed to start the circuit.");const n=()=>{Io.sendDisconnectBeacon()};nt.disconnect=n,window.addEventListener("unload",n,{capture:!1,once:!0}),To.log(ot.Information,"Blazor server-side application started."),t.invokeAfterStartedCallbacks(nt)}class Ro{constructor(e){this.initialComponents=e}resolveRootComponent(e,t){return this.initialComponents[e]}}let Ao=!1;function Po(e){if(Ao)throw new Error("Blazor has already started.");Ao=!0,function(e){if(ko)throw new Error("Circuit options have already been configured.");ko=function(e){const t={...vo,...e};return e&&e.reconnectionOptions&&(t.reconnectionOptions={...vo.reconnectionOptions,...e.reconnectionOptions}),t}(e)}(e);const t=function(e){return ct(e,"server").sort(((e,t)=>e.sequence-t.sequence))}(document);return xo(new Ro(t))}nt.start=Po,window.DotNet=e,document&&document.currentScript&&"false"!==document.currentScript.getAttribute("autostart")&&Po()})()})(); \ No newline at end of file +(()=>{var e={778:()=>{},77:()=>{},203:()=>{},200:()=>{},628:()=>{},321:()=>{}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var s=t[o]={exports:{}};return e[o](s,s.exports,n),s.exports}n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),(()=>{"use strict";var e,t,o;!function(e){const t=[],n="__jsObjectId",o="__dotNetObject",r="__byte[]",s="__dotNetStream",i="__jsStreamReferenceLength";let a,c;class l{constructor(e){this._jsObject=e,this._cachedFunctions=new Map}findFunction(e){const t=this._cachedFunctions.get(e);if(t)return t;let n,o=this._jsObject;if(e.split(".").forEach((t=>{if(!(t in o))throw new Error(`Could not find '${e}' ('${t}' was undefined).`);n=o,o=o[t]})),o instanceof Function)return o=o.bind(n),this._cachedFunctions.set(e,o),o;throw new Error(`The value '${e}' is not a function.`)}getWrappedObject(){return this._jsObject}}const h={0:new l(window)};h[0]._cachedFunctions.set("import",(e=>("string"==typeof e&&e.startsWith("./")&&(e=new URL(e.substr(2),document.baseURI).toString()),import(e))));let d,u=1;function p(e){t.push(e)}function f(e){if(e&&"object"==typeof e){h[u]=new l(e);const t={[n]:u};return u++,t}throw new Error(`Cannot create a JSObjectReference from the value '${e}'.`)}function g(e){let t=-1;if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e instanceof Blob)t=e.size;else{if(!(e.buffer instanceof ArrayBuffer))throw new Error("Supplied value is not a typed array or blob.");if(void 0===e.byteLength)throw new Error(`Cannot create a JSStreamReference from the value '${e}' as it doesn't have a byteLength.`);t=e.byteLength}const o={[i]:t};try{const t=f(e);o[n]=t[n]}catch(t){throw new Error(`Cannot create a JSStreamReference from the value '${e}'.`)}return o}function m(e,n){c=e;const o=n?JSON.parse(n,((e,n)=>t.reduce(((t,n)=>n(e,t)),n))):null;return c=void 0,o}function v(){if(void 0===a)throw new Error("No call dispatcher has been set.");if(null===a)throw new Error("There are multiple .NET runtimes present, so a default dispatcher could not be resolved. Use DotNetObject to invoke .NET instance methods.");return a}e.attachDispatcher=function(e){const t=new y(e);return void 0===a?a=t:a&&(a=null),t},e.attachReviver=p,e.invokeMethod=function(e,t,...n){return v().invokeDotNetStaticMethod(e,t,...n)},e.invokeMethodAsync=function(e,t,...n){return v().invokeDotNetStaticMethodAsync(e,t,...n)},e.createJSObjectReference=f,e.createJSStreamReference=g,e.disposeJSObjectReference=function(e){const t=e&&e[n];"number"==typeof t&&b(t)},function(e){e[e.Default=0]="Default",e[e.JSObjectReference=1]="JSObjectReference",e[e.JSStreamReference=2]="JSStreamReference",e[e.JSVoidResult=3]="JSVoidResult"}(d=e.JSCallResultType||(e.JSCallResultType={}));class y{constructor(e){this._dotNetCallDispatcher=e,this._byteArraysToBeRevived=new Map,this._pendingDotNetToJSStreams=new Map,this._pendingAsyncCalls={},this._nextAsyncCallId=1}getDotNetCallDispatcher(){return this._dotNetCallDispatcher}invokeJSFromDotNet(e,t,n,o){const r=m(this,t),s=I(_(e,o)(...r||[]),n);return null==s?null:T(this,s)}beginInvokeJSFromDotNet(e,t,n,o,r){const s=new Promise((e=>{const o=m(this,n);e(_(t,r)(...o||[]))}));e&&s.then((t=>T(this,[e,!0,I(t,o)]))).then((t=>this._dotNetCallDispatcher.endInvokeJSFromDotNet(e,!0,t)),(t=>this._dotNetCallDispatcher.endInvokeJSFromDotNet(e,!1,JSON.stringify([e,!1,w(t)]))))}endInvokeDotNetFromJS(e,t,n){const o=t?m(this,n):new Error(n);this.completePendingCall(parseInt(e,10),t,o)}invokeDotNetStaticMethod(e,t,...n){return this.invokeDotNetMethod(e,t,null,n)}invokeDotNetStaticMethodAsync(e,t,...n){return this.invokeDotNetMethodAsync(e,t,null,n)}invokeDotNetMethod(e,t,n,o){if(this._dotNetCallDispatcher.invokeDotNetFromJS){const r=T(this,o),s=this._dotNetCallDispatcher.invokeDotNetFromJS(e,t,n,r);return s?m(this,s):null}throw new Error("The current dispatcher does not support synchronous calls from JS to .NET. Use invokeDotNetMethodAsync instead.")}invokeDotNetMethodAsync(e,t,n,o){if(e&&n)throw new Error(`For instance method calls, assemblyName should be null. Received '${e}'.`);const r=this._nextAsyncCallId++,s=new Promise(((e,t)=>{this._pendingAsyncCalls[r]={resolve:e,reject:t}}));try{const s=T(this,o);this._dotNetCallDispatcher.beginInvokeDotNetFromJS(r,e,t,n,s)}catch(e){this.completePendingCall(r,!1,e)}return s}receiveByteArray(e,t){this._byteArraysToBeRevived.set(e,t)}processByteArray(e){const t=this._byteArraysToBeRevived.get(e);return t?(this._byteArraysToBeRevived.delete(e),t):null}supplyDotNetStream(e,t){if(this._pendingDotNetToJSStreams.has(e)){const n=this._pendingDotNetToJSStreams.get(e);this._pendingDotNetToJSStreams.delete(e),n.resolve(t)}else{const n=new C;n.resolve(t),this._pendingDotNetToJSStreams.set(e,n)}}getDotNetStreamPromise(e){let t;if(this._pendingDotNetToJSStreams.has(e))t=this._pendingDotNetToJSStreams.get(e).streamPromise,this._pendingDotNetToJSStreams.delete(e);else{const n=new C;this._pendingDotNetToJSStreams.set(e,n),t=n.streamPromise}return t}completePendingCall(e,t,n){if(!this._pendingAsyncCalls.hasOwnProperty(e))throw new Error(`There is no pending async call with ID ${e}.`);const o=this._pendingAsyncCalls[e];delete this._pendingAsyncCalls[e],t?o.resolve(n):o.reject(n)}}function w(e){return e instanceof Error?`${e.message}\n${e.stack}`:e?e.toString():"null"}function _(e,t){const n=h[t];if(n)return n.findFunction(e);throw new Error(`JS object instance with ID ${t} does not exist (has it been disposed?).`)}function b(e){delete h[e]}e.findJSFunction=_,e.disposeJSObjectReferenceById=b;class S{constructor(e,t){this._id=e,this._callDispatcher=t}invokeMethod(e,...t){return this._callDispatcher.invokeDotNetMethod(null,e,this._id,t)}invokeMethodAsync(e,...t){return this._callDispatcher.invokeDotNetMethodAsync(null,e,this._id,t)}dispose(){this._callDispatcher.invokeDotNetMethodAsync(null,"__Dispose",this._id,null).catch((e=>console.error(e)))}serializeAsArg(){return{[o]:this._id}}}e.DotNetObject=S,p((function(e,t){if(t&&"object"==typeof t){if(t.hasOwnProperty(o))return new S(t[o],c);if(t.hasOwnProperty(n)){const e=t[n],o=h[e];if(o)return o.getWrappedObject();throw new Error(`JS object instance with Id '${e}' does not exist. It may have been disposed.`)}if(t.hasOwnProperty(r)){const e=t[r],n=c.processByteArray(e);if(void 0===n)throw new Error(`Byte array index '${e}' does not exist.`);return n}if(t.hasOwnProperty(s)){const e=t[s],n=c.getDotNetStreamPromise(e);return new E(n)}}return t}));class E{constructor(e){this._streamPromise=e}stream(){return this._streamPromise}async arrayBuffer(){return new Response(await this.stream()).arrayBuffer()}}class C{constructor(){this.streamPromise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}}function I(e,t){switch(t){case d.Default:return e;case d.JSObjectReference:return f(e);case d.JSStreamReference:return g(e);case d.JSVoidResult:return null;default:throw new Error(`Invalid JS call result type '${t}'.`)}}let k=0;function T(e,t){k=0,c=e;const n=JSON.stringify(t,D);return c=void 0,n}function D(e,t){if(t instanceof S)return t.serializeAsArg();if(t instanceof Uint8Array){c.getDotNetCallDispatcher().sendByteArray(k,t);const e={[r]:k};return k++,e}return t}}(e||(e={})),function(e){e[e.prependFrame=1]="prependFrame",e[e.removeFrame=2]="removeFrame",e[e.setAttribute=3]="setAttribute",e[e.removeAttribute=4]="removeAttribute",e[e.updateText=5]="updateText",e[e.stepIn=6]="stepIn",e[e.stepOut=7]="stepOut",e[e.updateMarkup=8]="updateMarkup",e[e.permutationListEntry=9]="permutationListEntry",e[e.permutationListEnd=10]="permutationListEnd"}(t||(t={})),function(e){e[e.element=1]="element",e[e.text=2]="text",e[e.attribute=3]="attribute",e[e.component=4]="component",e[e.region=5]="region",e[e.elementReferenceCapture=6]="elementReferenceCapture",e[e.markup=8]="markup",e[e.namedEvent=10]="namedEvent"}(o||(o={}));class r{constructor(e,t){this.componentId=e,this.fieldValue=t}static fromEvent(e,t){const n=t.target;if(n instanceof Element){const t=function(e){return e instanceof HTMLInputElement?e.type&&"checkbox"===e.type.toLowerCase()?{value:e.checked}:{value:e.value}:e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement?{value:e.value}:null}(n);if(t)return new r(e,t.value)}return null}}const s=new Map,i=new Map,a=[];function c(e){return s.get(e)}function l(e){const t=s.get(e);return(null==t?void 0:t.browserEventName)||e}function h(e,t){e.forEach((e=>s.set(e,t)))}function d(e){const t=[];for(let n=0;ne.selected)).map((e=>e.value))}}{const e=function(e){return!!e&&"INPUT"===e.tagName&&"checkbox"===e.getAttribute("type")}(t);return{value:e?!!t.checked:t.value}}}}),h(["copy","cut","paste"],{createEventArgs:e=>({type:e.type})}),h(["drag","dragend","dragenter","dragleave","dragover","dragstart","drop"],{createEventArgs:e=>{return{...u(t=e),dataTransfer:t.dataTransfer?{dropEffect:t.dataTransfer.dropEffect,effectAllowed:t.dataTransfer.effectAllowed,files:Array.from(t.dataTransfer.files).map((e=>e.name)),items:Array.from(t.dataTransfer.items).map((e=>({kind:e.kind,type:e.type}))),types:t.dataTransfer.types}:null};var t}}),h(["focus","blur","focusin","focusout"],{createEventArgs:e=>({type:e.type})}),h(["keydown","keyup","keypress"],{createEventArgs:e=>{return{key:(t=e).key,code:t.code,location:t.location,repeat:t.repeat,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,type:t.type};var t}}),h(["contextmenu","click","mouseover","mouseout","mousemove","mousedown","mouseup","mouseleave","mouseenter","dblclick"],{createEventArgs:e=>u(e)}),h(["error"],{createEventArgs:e=>{return{message:(t=e).message,filename:t.filename,lineno:t.lineno,colno:t.colno,type:t.type};var t}}),h(["loadstart","timeout","abort","load","loadend","progress"],{createEventArgs:e=>{return{lengthComputable:(t=e).lengthComputable,loaded:t.loaded,total:t.total,type:t.type};var t}}),h(["touchcancel","touchend","touchmove","touchenter","touchleave","touchstart"],{createEventArgs:e=>{return{detail:(t=e).detail,touches:d(t.touches),targetTouches:d(t.targetTouches),changedTouches:d(t.changedTouches),ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,type:t.type};var t}}),h(["gotpointercapture","lostpointercapture","pointercancel","pointerdown","pointerenter","pointerleave","pointermove","pointerout","pointerover","pointerup"],{createEventArgs:e=>{return{...u(t=e),pointerId:t.pointerId,width:t.width,height:t.height,pressure:t.pressure,tiltX:t.tiltX,tiltY:t.tiltY,pointerType:t.pointerType,isPrimary:t.isPrimary};var t}}),h(["wheel","mousewheel"],{createEventArgs:e=>{return{...u(t=e),deltaX:t.deltaX,deltaY:t.deltaY,deltaZ:t.deltaZ,deltaMode:t.deltaMode};var t}}),h(["toggle"],{createEventArgs:()=>({})});const p=["date","datetime-local","month","time","week"],f=new Map;let g,m,v=0;const y={async add(e,t,n){if(!n)throw new Error("initialParameters must be an object, even if empty.");const o="__bl-dynamic-root:"+(++v).toString();f.set(o,e);const r=await b().invokeMethodAsync("AddRootComponent",t,o),s=new _(r,m[t]);return await s.setParameters(n),s}};class w{invoke(e){return this._callback(e)}setCallback(t){this._selfJSObjectReference||(this._selfJSObjectReference=e.createJSObjectReference(this)),this._callback=t}getJSObjectReference(){return this._selfJSObjectReference}dispose(){this._selfJSObjectReference&&e.disposeJSObjectReference(this._selfJSObjectReference)}}class _{constructor(e,t){this._jsEventCallbackWrappers=new Map,this._componentId=e;for(const e of t)"eventcallback"===e.type&&this._jsEventCallbackWrappers.set(e.name.toLowerCase(),new w)}setParameters(e){const t={},n=Object.entries(e||{}),o=n.length;for(const[e,o]of n){const n=this._jsEventCallbackWrappers.get(e.toLowerCase());n&&o?(n.setCallback(o),t[e]=n.getJSObjectReference()):t[e]=o}return b().invokeMethodAsync("SetRootComponentParameters",this._componentId,o,t)}async dispose(){if(null!==this._componentId){await b().invokeMethodAsync("RemoveRootComponent",this._componentId),this._componentId=null;for(const e of this._jsEventCallbackWrappers.values())e.dispose()}}}function b(){if(!g)throw new Error("Dynamic root components have not been enabled in this application.");return g}const S=new Map,E=[];let C;const I=new Promise((e=>{C=e}));function k(e,t,n){return D(e,t.eventHandlerId,(()=>T(e).invokeMethodAsync("DispatchEventAsync",t,n)))}function T(e){const t=S.get(e);if(!t)throw new Error(`No interop methods are registered for renderer ${e}`);return t}let D=(e,t,n)=>n();const x=M(["abort","blur","canplay","canplaythrough","change","cuechange","durationchange","emptied","ended","error","focus","load","loadeddata","loadedmetadata","loadend","loadstart","mouseenter","mouseleave","pointerenter","pointerleave","pause","play","playing","progress","ratechange","reset","scroll","seeked","seeking","stalled","submit","suspend","timeupdate","toggle","unload","volumechange","waiting","DOMNodeInsertedIntoDocument","DOMNodeRemovedFromDocument"]),R={submit:!0},A=M(["click","dblclick","mousedown","mousemove","mouseup"]);class P{constructor(e){this.browserRendererId=e,this.afterClickCallbacks=[];const t=++P.nextEventDelegatorId;this.eventsCollectionKey=`_blazorEvents_${t}`,this.eventInfoStore=new N(this.onGlobalEvent.bind(this))}setListener(e,t,n,o){const r=this.getEventHandlerInfosForElement(e,!0),s=r.getHandler(t);if(s)this.eventInfoStore.update(s.eventHandlerId,n);else{const s={element:e,eventName:t,eventHandlerId:n,renderingComponentId:o};this.eventInfoStore.add(s),r.setHandler(t,s)}}getHandler(e){return this.eventInfoStore.get(e)}removeListener(e){const t=this.eventInfoStore.remove(e);if(t){const e=t.element,n=this.getEventHandlerInfosForElement(e,!1);n&&n.removeHandler(t.eventName)}}notifyAfterClick(e){this.afterClickCallbacks.push(e),this.eventInfoStore.addGlobalListener("click")}setStopPropagation(e,t,n){this.getEventHandlerInfosForElement(e,!0).stopPropagation(t,n)}setPreventDefault(e,t,n){this.getEventHandlerInfosForElement(e,!0).preventDefault(t,n)}onGlobalEvent(e){if(!(e.target instanceof Element))return;this.dispatchGlobalEventToAllElements(e.type,e);const t=(n=e.type,i.get(n));var n;t&&t.forEach((t=>this.dispatchGlobalEventToAllElements(t,e))),"click"===e.type&&this.afterClickCallbacks.forEach((t=>t(e)))}dispatchGlobalEventToAllElements(e,t){const n=t.composedPath();let o=n.shift(),s=null,i=!1;const a=Object.prototype.hasOwnProperty.call(x,e);let l=!1;for(;o;){const u=o,p=this.getEventHandlerInfosForElement(u,!1);if(p){const n=p.getHandler(e);if(n&&(h=u,d=t.type,!((h instanceof HTMLButtonElement||h instanceof HTMLInputElement||h instanceof HTMLTextAreaElement||h instanceof HTMLSelectElement)&&Object.prototype.hasOwnProperty.call(A,d)&&h.disabled))){if(!i){const n=c(e);s=(null==n?void 0:n.createEventArgs)?n.createEventArgs(t):{},i=!0}Object.prototype.hasOwnProperty.call(R,t.type)&&t.preventDefault(),k(this.browserRendererId,{eventHandlerId:n.eventHandlerId,eventName:e,eventFieldInfo:r.fromEvent(n.renderingComponentId,t)},s)}p.stopPropagation(e)&&(l=!0),p.preventDefault(e)&&t.preventDefault()}o=a||l?void 0:n.shift()}var h,d}getEventHandlerInfosForElement(e,t){return Object.prototype.hasOwnProperty.call(e,this.eventsCollectionKey)?e[this.eventsCollectionKey]:t?e[this.eventsCollectionKey]=new U:null}}P.nextEventDelegatorId=0;class N{constructor(e){this.globalListener=e,this.infosByEventHandlerId={},this.countByEventName={},a.push(this.handleEventNameAliasAdded.bind(this))}add(e){if(this.infosByEventHandlerId[e.eventHandlerId])throw new Error(`Event ${e.eventHandlerId} is already tracked`);this.infosByEventHandlerId[e.eventHandlerId]=e,this.addGlobalListener(e.eventName)}get(e){return this.infosByEventHandlerId[e]}addGlobalListener(e){if(e=l(e),Object.prototype.hasOwnProperty.call(this.countByEventName,e))this.countByEventName[e]++;else{this.countByEventName[e]=1;const t=Object.prototype.hasOwnProperty.call(x,e);document.addEventListener(e,this.globalListener,t)}}update(e,t){if(Object.prototype.hasOwnProperty.call(this.infosByEventHandlerId,t))throw new Error(`Event ${t} is already tracked`);const n=this.infosByEventHandlerId[e];delete this.infosByEventHandlerId[e],n.eventHandlerId=t,this.infosByEventHandlerId[t]=n}remove(e){const t=this.infosByEventHandlerId[e];if(t){delete this.infosByEventHandlerId[e];const n=l(t.eventName);0==--this.countByEventName[n]&&(delete this.countByEventName[n],document.removeEventListener(n,this.globalListener))}return t}handleEventNameAliasAdded(e,t){if(Object.prototype.hasOwnProperty.call(this.countByEventName,e)){const n=this.countByEventName[e];delete this.countByEventName[e],document.removeEventListener(e,this.globalListener),this.addGlobalListener(t),this.countByEventName[t]+=n-1}}}class U{constructor(){this.handlers={},this.preventDefaultFlags=null,this.stopPropagationFlags=null}getHandler(e){return Object.prototype.hasOwnProperty.call(this.handlers,e)?this.handlers[e]:null}setHandler(e,t){this.handlers[e]=t}removeHandler(e){delete this.handlers[e]}preventDefault(e,t){return void 0!==t&&(this.preventDefaultFlags=this.preventDefaultFlags||{},this.preventDefaultFlags[e]=t),!!this.preventDefaultFlags&&this.preventDefaultFlags[e]}stopPropagation(e,t){return void 0!==t&&(this.stopPropagationFlags=this.stopPropagationFlags||{},this.stopPropagationFlags[e]=t),!!this.stopPropagationFlags&&this.stopPropagationFlags[e]}}function M(e){const t={};return e.forEach((e=>{t[e]=!0})),t}const B=Symbol(),L=Symbol(),$=Symbol();function O(e,t){if(B in e)return e;const n=[];if(e.childNodes.length>0){if(!t)throw new Error("New logical elements must start empty, or allowExistingContents must be true");e.childNodes.forEach((t=>{const o=O(t,!0);o[L]=e,n.push(o)}))}return e[B]=n,e}function F(e){const t=K(e);for(;t.length;)W(e,0)}function H(e,t){const n=document.createComment("!");return j(n,e,t),n}function j(e,t,n){const o=e;let r=e;if(B in e){const t=Q(o);if(t!==e){const n=new Range;n.setStartBefore(e),n.setEndAfter(t),r=n.extractContents()}}const s=z(o);if(s){const e=K(s),t=Array.prototype.indexOf.call(e,o);e.splice(t,1),delete o[L]}const i=K(t);if(n0;)W(n,0)}const o=n;o.parentNode.removeChild(o)}function z(e){return e[L]||null}function q(e,t){return K(e)[t]}function J(e){const t=Y(e);return"http://www.w3.org/2000/svg"===t.namespaceURI&&"foreignObject"!==t.tagName}function K(e){return e[B]}function V(e){const t=K(z(e));return t[Array.prototype.indexOf.call(t,e)+1]||null}function X(e,t){const n=K(e);t.forEach((e=>{e.moveRangeStart=n[e.fromSiblingIndex],e.moveRangeEnd=Q(e.moveRangeStart)})),t.forEach((t=>{const o=document.createComment("marker");t.moveToBeforeMarker=o;const r=n[t.toSiblingIndex+1];r?r.parentNode.insertBefore(o,r):G(o,e)})),t.forEach((e=>{const t=e.moveToBeforeMarker,n=t.parentNode,o=e.moveRangeStart,r=e.moveRangeEnd;let s=o;for(;s;){const e=s.nextSibling;if(n.insertBefore(s,t),s===r)break;s=e}n.removeChild(t)})),t.forEach((e=>{n[e.toSiblingIndex]=e.moveRangeStart}))}function Y(e){if(e instanceof Element||e instanceof DocumentFragment)return e;if(e instanceof Comment)return e.parentNode;throw new Error("Not a valid logical element")}function G(e,t){if(t instanceof Element||t instanceof DocumentFragment)t.appendChild(e);else{if(!(t instanceof Comment))throw new Error(`Cannot append node because the parent is not a valid logical element. Parent: ${t}`);{const n=V(t);n?n.parentNode.insertBefore(e,n):G(e,z(t))}}}function Q(e){if(e instanceof Element||e instanceof DocumentFragment)return e;const t=V(e);if(t)return t.previousSibling;{const t=z(e);return t instanceof Element||t instanceof DocumentFragment?t.lastChild:Q(t)}}function Z(e){return`_bl_${e}`}const ee="__internalId";e.attachReviver(((e,t)=>t&&"object"==typeof t&&Object.prototype.hasOwnProperty.call(t,ee)&&"string"==typeof t[ee]?function(e){const t=`[${Z(e)}]`;return document.querySelector(t)}(t[ee]):t));const te="_blazorDeferredValue";function ne(e){return"select-multiple"===e.type}function oe(e,t){e.value=t||""}function re(e,t){e instanceof HTMLSelectElement?ne(e)?function(e,t){t||(t=[]);for(let n=0;n{Ce()&&function(e,t){if(0!==e.button||function(e){return e.ctrlKey||e.shiftKey||e.altKey||e.metaKey}(e))return;if(e.defaultPrevented)return;const n=function(e){const t=!window._blazorDisableComposedPath&&e.composedPath&&e.composedPath();if(t){for(let e=0;edocument.baseURI,getLocationHref:()=>location.href,scrollToElement:Ue};function Ue(e){const t=document.getElementById(e);return!!t&&(t.scrollIntoView(),!0)}function Me(e,t,n=!1){const o=Se(e);!t.forceLoad&&we(o)?We()?Be(o,!1,t.replaceHistoryEntry,t.historyEntryState,n):be(o,t.replaceHistoryEntry):function(e,t){if(location.href===e){const t=e+"?";history.replaceState(null,"",t),location.replace(e)}else t?location.replace(e):location.href=e}(e,t.replaceHistoryEntry)}async function Be(e,t,n,o=void 0,r=!1){if(Oe(),function(e){const t=e.indexOf("#");return t>-1&&location.href.replace(location.hash,"")===e.substring(0,t)}(e))!function(e,t,n){Le(e,t,n);const o=e.indexOf("#");o!==e.length-1&&Ue(e.substring(o+1))}(e,n,o);else{if(!r&&ke&&!await Fe(e,o,t))return;ve=!0,Le(e,n,o),await He(t)}}function Le(e,t,n=void 0){t?history.replaceState({userState:n,_index:Te},"",e):(Te++,history.pushState({userState:n,_index:Te},"",e))}function $e(e){return new Promise((t=>{const n=Ae;Ae=()=>{Ae=n,t()},history.go(e)}))}function Oe(){Pe&&(Pe(!1),Pe=null)}function Fe(e,t,n){return new Promise((o=>{Oe(),Re?(De++,Pe=o,Re(De,e,t,n)):o(!1)}))}async function He(e){var t;xe&&await xe(location.href,null===(t=history.state)||void 0===t?void 0:t.userState,e)}async function je(e){var t,n;Ae&&We()&&await Ae(e),Te=null!==(n=null===(t=history.state)||void 0===t?void 0:t._index)&&void 0!==n?n:0}function We(){return Ce()||!_e()}const ze={focus:function(e,t){if(e instanceof HTMLElement)e.focus({preventScroll:t});else{if(!(e instanceof SVGElement))throw new Error("Unable to focus an invalid element.");if(!e.hasAttribute("tabindex"))throw new Error("Unable to focus an SVG element that does not have a tabindex.");e.focus({preventScroll:t})}},focusBySelector:function(e,t){const n=document.querySelector(e);n&&(n.hasAttribute("tabindex")||(n.tabIndex=-1),n.focus({preventScroll:!0}))}},qe={init:function(e,t,n,o=50){const r=Ke(t);(r||document.documentElement).style.overflowAnchor="none";const s=document.createRange();u(n.parentElement)&&(t.style.display="table-row",n.style.display="table-row");const i=new IntersectionObserver((function(o){o.forEach((o=>{var r;if(!o.isIntersecting)return;s.setStartAfter(t),s.setEndBefore(n);const i=s.getBoundingClientRect().height,a=null===(r=o.rootBounds)||void 0===r?void 0:r.height;o.target===t?e.invokeMethodAsync("OnSpacerBeforeVisible",o.intersectionRect.top-o.boundingClientRect.top,i,a):o.target===n&&n.offsetHeight>0&&e.invokeMethodAsync("OnSpacerAfterVisible",o.boundingClientRect.bottom-o.intersectionRect.bottom,i,a)}))}),{root:r,rootMargin:`${o}px`});i.observe(t),i.observe(n);const a=d(t),c=d(n),{observersByDotNetObjectId:l,id:h}=Ve(e);function d(e){const t={attributes:!0},n=new MutationObserver(((n,o)=>{u(e.parentElement)&&(o.disconnect(),e.style.display="table-row",o.observe(e,t)),i.unobserve(e),i.observe(e)}));return n.observe(e,t),n}function u(e){return null!==e&&(e instanceof HTMLTableElement&&""===e.style.display||"table"===e.style.display||e instanceof HTMLTableSectionElement&&""===e.style.display||"table-row-group"===e.style.display)}l[h]={intersectionObserver:i,mutationObserverBefore:a,mutationObserverAfter:c}},dispose:function(e){const{observersByDotNetObjectId:t,id:n}=Ve(e),o=t[n];o&&(o.intersectionObserver.disconnect(),o.mutationObserverBefore.disconnect(),o.mutationObserverAfter.disconnect(),e.dispose(),delete t[n])}},Je=Symbol();function Ke(e){return e&&e!==document.body&&e!==document.documentElement?"visible"!==getComputedStyle(e).overflowY?e:Ke(e.parentElement):null}function Ve(e){var t;const n=e._callDispatcher,o=e._id;return null!==(t=n[Je])&&void 0!==t||(n[Je]={}),{observersByDotNetObjectId:n[Je],id:o}}const Xe={getAndRemoveExistingTitle:function(){var e;const t=document.head?document.head.getElementsByTagName("title"):[];if(0===t.length)return null;let n=null;for(let o=t.length-1;o>=0;o--){const r=t[o],s=r.previousSibling;s instanceof Comment&&null!==z(s)||(null===n&&(n=r.textContent),null===(e=r.parentNode)||void 0===e||e.removeChild(r))}return n}},Ye={init:function(e,t){t._blazorInputFileNextFileId=0,t.addEventListener("click",(function(){t.value=""})),t.addEventListener("change",(function(){t._blazorFilesById={};const n=Array.prototype.map.call(t.files,(function(e){const n={id:++t._blazorInputFileNextFileId,lastModified:new Date(e.lastModified).toISOString(),name:e.name,size:e.size,contentType:e.type,readPromise:void 0,arrayBuffer:void 0,blob:e};return t._blazorFilesById[n.id]=n,n}));e.invokeMethodAsync("NotifyChange",n)}))},toImageFile:async function(e,t,n,o,r){const s=Ge(e,t),i=await new Promise((function(e){const t=new Image;t.onload=function(){URL.revokeObjectURL(t.src),e(t)},t.onerror=function(){t.onerror=null,URL.revokeObjectURL(t.src)},t.src=URL.createObjectURL(s.blob)})),a=await new Promise((function(e){var t;const s=Math.min(1,o/i.width),a=Math.min(1,r/i.height),c=Math.min(s,a),l=document.createElement("canvas");l.width=Math.round(i.width*c),l.height=Math.round(i.height*c),null===(t=l.getContext("2d"))||void 0===t||t.drawImage(i,0,0,l.width,l.height),l.toBlob(e,n)})),c={id:++e._blazorInputFileNextFileId,lastModified:s.lastModified,name:s.name,size:(null==a?void 0:a.size)||0,contentType:n,blob:a||s.blob};return e._blazorFilesById[c.id]=c,c},readFileData:async function(e,t){return Ge(e,t).blob}};function Ge(e,t){const n=e._blazorFilesById[t];if(!n)throw new Error(`There is no file with ID ${t}. The file list may have changed. See https://aka.ms/aspnet/blazor-input-file-multiple-selections.`);return n}const Qe=new Set,Ze={enableNavigationPrompt:function(e){0===Qe.size&&window.addEventListener("beforeunload",et),Qe.add(e)},disableNavigationPrompt:function(e){Qe.delete(e),0===Qe.size&&window.removeEventListener("beforeunload",et)}};function et(e){e.preventDefault(),e.returnValue=!0}async function tt(e,t,n){return e instanceof Blob?await async function(e,t,n){const o=e.slice(t,t+n),r=await o.arrayBuffer();return new Uint8Array(r)}(e,t,n):function(e,t,n){return new Uint8Array(e.buffer,e.byteOffset+t,n)}(e,t,n)}new Map;const nt=new class{constructor(){this._eventListeners=new Map,this._blazor=null}attachBlazorInstance(e){this._blazor=e}addEventListener(e,t){let n=this._eventListeners.get(e);n||(n=new Set,this._eventListeners.set(e,n)),n.add(t)}removeEventListener(e,t){const n=this._eventListeners.get(e);n&&n.delete(t)}dispatchEvent(e,t){if(null===this._blazor)throw new Error("Blazor events cannot be dispatched until a Blazor instance gets attached");const n=this._eventListeners.get(e);if(!n)return;const o={...t,blazor:this._blazor,type:e};for(const e of n)e(o)}},ot={navigateTo:function(e,t,n=!1){Me(e,t instanceof Object?t:{forceLoad:t,replaceHistoryEntry:n})},registerCustomEventType:function(e,t){if(!t)throw new Error("The options parameter is required.");if(s.has(e))throw new Error(`The event '${e}' is already registered.`);if(t.browserEventName){const n=i.get(t.browserEventName);n?n.push(e):i.set(t.browserEventName,[e]),a.forEach((n=>n(e,t.browserEventName)))}s.set(e,t)},addEventListener:nt.addEventListener.bind(nt),removeEventListener:nt.removeEventListener.bind(nt),rootComponents:y,runtime:{},_internal:{navigationManager:Ne,domWrapper:ze,Virtualize:qe,PageTitle:Xe,InputFile:Ye,NavigationLock:Ze,getJSDataStreamChunk:tt,attachWebRendererInterop:function(t,n,o,r){if(S.has(t))throw new Error(`Interop methods are already registered for renderer ${t}`);S.set(t,n),Object.keys(o).length>0&&function(t,n,o){if(g)throw new Error("Dynamic root components have already been enabled.");g=t,m=n;for(const[t,r]of Object.entries(o)){const o=e.findJSFunction(t,0);for(const e of r)o(e,n[e])}}(T(t),o,r),C(),function(e){for(const t of E)t(e)}(t)},dispatchEvent:nt.dispatchEvent.bind(nt)}};var rt;nt.attachBlazorInstance(ot),window.Blazor=ot,function(e){e[e.Trace=0]="Trace",e[e.Debug=1]="Debug",e[e.Information=2]="Information",e[e.Warning=3]="Warning",e[e.Error=4]="Error",e[e.Critical=5]="Critical",e[e.None=6]="None"}(rt||(rt={}));class st{log(e,t){}}st.instance=new st;class it{constructor(e){this.minLevel=e}log(e,t){if(e>=this.minLevel){const n=`[${(new Date).toISOString()}] ${rt[e]}: ${t}`;switch(e){case rt.Critical:case rt.Error:console.error(n);break;case rt.Warning:console.warn(n);break;case rt.Information:console.info(n);break;default:console.log(n)}}}}const at=/^\s*Blazor-Component-State:(?[a-zA-Z0-9+/=]+)$/;function ct(e){var t;if(e.nodeType===Node.COMMENT_NODE){const n=e.textContent||"",o=at.exec(n),r=o&&o.groups&&o.groups.state;return r&&(null===(t=e.parentNode)||void 0===t||t.removeChild(e)),r}if(!e.hasChildNodes())return;const n=e.childNodes;for(let e=0;e.*)$/);function dt(e,t){const n=e.currentElement;var o,r,s;if(n&&n.nodeType===Node.COMMENT_NODE&&n.textContent){const i=ht.exec(n.textContent),a=i&&i.groups&&i.groups.descriptor;if(!a)return;!function(e){if(e.parentNode instanceof Document)throw new Error("Root components cannot be marked as interactive. The element must be rendered statically so that scripts are not evaluated multiple times.")}(n);try{const i=function(e){const t=JSON.parse(e),{type:n}=t;if("server"!==n&&"webassembly"!==n&&"auto"!==n)throw new Error(`Invalid component type '${n}'.`);return t}(a),c=function(e,t,n){const{prerenderId:o}=e;if(o){for(;n.next()&&n.currentElement;){const e=n.currentElement;if(e.nodeType!==Node.COMMENT_NODE)continue;if(!e.textContent)continue;const t=ht.exec(e.textContent),r=t&&t[1];if(r)return gt(r,o),e}throw new Error(`Could not find an end component comment for '${t}'.`)}}(i,n,e);if(t!==i.type)return;switch(i.type){case"webassembly":return r=n,s=c,ft(o=i),{...o,uniqueId:ut++,start:r,end:s};case"server":return function(e,t,n){return pt(e),{...e,uniqueId:ut++,start:t,end:n}}(i,n,c);case"auto":return function(e,t,n){return pt(e),ft(e),{...e,uniqueId:ut++,start:t,end:n}}(i,n,c)}}catch(e){throw new Error(`Found malformed component comment at ${n.textContent}`)}}}let ut=0;function pt(e){const{descriptor:t,sequence:n}=e;if(!t)throw new Error("descriptor must be defined when using a descriptor.");if(void 0===n)throw new Error("sequence must be defined when using a descriptor.");if(!Number.isInteger(n))throw new Error(`Error parsing the sequence '${n}' for component '${JSON.stringify(e)}'`)}function ft(e){const{assembly:t,typeName:n}=e;if(!t)throw new Error("assembly must be defined when using a descriptor.");if(!n)throw new Error("typeName must be defined when using a descriptor.");e.parameterDefinitions=e.parameterDefinitions&&atob(e.parameterDefinitions),e.parameterValues=e.parameterValues&&atob(e.parameterValues)}function gt(e,t){const n=JSON.parse(e);if(1!==Object.keys(n).length)throw new Error(`Invalid end of component comment: '${e}'`);const o=n.prerenderId;if(!o)throw new Error(`End of component comment must have a value for the prerendered property: '${e}'`);if(o!==t)throw new Error(`End of component comment prerendered property must match the start comment prerender id: '${t}', '${o}'`)}class mt{constructor(e){this.childNodes=e,this.currentIndex=-1,this.length=e.length}next(){return this.currentIndex++,this.currentIndex{n+=`0x${e<16?"0":""}${e.toString(16)} `})),n.substr(0,n.length-1)}(e)}'`)):"string"==typeof e&&(n=`String data of length ${e.length}`,t&&(n+=`. Content: '${e}'`)),n}function Ct(e){return e&&"undefined"!=typeof ArrayBuffer&&(e instanceof ArrayBuffer||e.constructor&&"ArrayBuffer"===e.constructor.name)}async function It(e,t,n,o,r,s){const i={},[a,c]=Dt();i[a]=c,e.log(yt.Trace,`(${t} transport) sending data. ${Et(r,s.logMessageContent)}.`);const l=Ct(r)?"arraybuffer":"text",h=await n.post(o,{content:r,headers:{...i,...s.headers},responseType:l,timeout:s.timeout,withCredentials:s.withCredentials});e.log(yt.Trace,`(${t} transport) request complete. Response status: ${h.statusCode}.`)}class kt{constructor(e,t){this._subject=e,this._observer=t}dispose(){const e=this._subject.observers.indexOf(this._observer);e>-1&&this._subject.observers.splice(e,1),0===this._subject.observers.length&&this._subject.cancelCallback&&this._subject.cancelCallback().catch((e=>{}))}}class Tt{constructor(e){this._minLevel=e,this.out=console}log(e,t){if(e>=this._minLevel){const n=`[${(new Date).toISOString()}] ${yt[e]}: ${t}`;switch(e){case yt.Critical:case yt.Error:this.out.error(n);break;case yt.Warning:this.out.warn(n);break;case yt.Information:this.out.info(n);break;default:this.out.log(n)}}}}function Dt(){let e="X-SignalR-User-Agent";return St.isNode&&(e="User-Agent"),[e,xt(_t,Rt(),St.isNode?"NodeJS":"Browser",At())]}function xt(e,t,n,o){let r="Microsoft SignalR/";const s=e.split(".");return r+=`${s[0]}.${s[1]}`,r+=` (${e}; `,r+=t&&""!==t?`${t}; `:"Unknown OS; ",r+=`${n}`,r+=o?`; ${o}`:"; Unknown Runtime Version",r+=")",r}function Rt(){if(!St.isNode)return"";switch(process.platform){case"win32":return"Windows NT";case"darwin":return"macOS";case"linux":return"Linux";default:return process.platform}}function At(){if(St.isNode)return process.versions.node}function Pt(e){return e.stack?e.stack:e.message?e.message:`${e}`}class Nt{writeHandshakeRequest(e){return vt.write(JSON.stringify(e))}parseHandshakeResponse(e){let t,n;if(Ct(e)){const o=new Uint8Array(e),r=o.indexOf(vt.RecordSeparatorCode);if(-1===r)throw new Error("Message is incomplete.");const s=r+1;t=String.fromCharCode.apply(null,Array.prototype.slice.call(o.slice(0,s))),n=o.byteLength>s?o.slice(s).buffer:null}else{const o=e,r=o.indexOf(vt.RecordSeparator);if(-1===r)throw new Error("Message is incomplete.");const s=r+1;t=o.substring(0,s),n=o.length>s?o.substring(s):null}const o=vt.parse(t),r=JSON.parse(o[0]);if(r.type)throw new Error("Expected a handshake response from the server.");return[n,r]}}class Ut extends Error{constructor(e,t){const n=new.target.prototype;super(`${e}: Status code '${t}'`),this.statusCode=t,this.__proto__=n}}class Mt extends Error{constructor(e="A timeout occurred."){const t=new.target.prototype;super(e),this.__proto__=t}}class Bt extends Error{constructor(e="An abort occurred."){const t=new.target.prototype;super(e),this.__proto__=t}}class Lt extends Error{constructor(e,t){const n=new.target.prototype;super(e),this.transport=t,this.errorType="UnsupportedTransportError",this.__proto__=n}}class $t extends Error{constructor(e,t){const n=new.target.prototype;super(e),this.transport=t,this.errorType="DisabledTransportError",this.__proto__=n}}class Ot extends Error{constructor(e,t){const n=new.target.prototype;super(e),this.transport=t,this.errorType="FailedToStartTransportError",this.__proto__=n}}class Ft extends Error{constructor(e){const t=new.target.prototype;super(e),this.errorType="FailedToNegotiateWithServerError",this.__proto__=t}}class Ht extends Error{constructor(e,t){const n=new.target.prototype;super(e),this.innerErrors=t,this.__proto__=n}}var jt,Wt;!function(e){e[e.Invocation=1]="Invocation",e[e.StreamItem=2]="StreamItem",e[e.Completion=3]="Completion",e[e.StreamInvocation=4]="StreamInvocation",e[e.CancelInvocation=5]="CancelInvocation",e[e.Ping=6]="Ping",e[e.Close=7]="Close",e[e.Ack=8]="Ack",e[e.Sequence=9]="Sequence"}(jt||(jt={}));class zt{constructor(){this.observers=[]}next(e){for(const t of this.observers)t.next(e)}error(e){for(const t of this.observers)t.error&&t.error(e)}complete(){for(const e of this.observers)e.complete&&e.complete()}subscribe(e){return this.observers.push(e),new kt(this,e)}}class qt{constructor(e,t,n){this._bufferSize=1e5,this._messages=[],this._totalMessageCount=0,this._waitForSequenceMessage=!1,this._nextReceivingSequenceId=1,this._latestReceivedSequenceId=0,this._bufferedByteCount=0,this._reconnectInProgress=!1,this._protocol=e,this._connection=t,this._bufferSize=n}async _send(e){const t=this._protocol.writeMessage(e);let n=Promise.resolve();if(this._isInvocationMessage(e)){this._totalMessageCount++;let e=()=>{},o=()=>{};Ct(t)?this._bufferedByteCount+=t.byteLength:this._bufferedByteCount+=t.length,this._bufferedByteCount>=this._bufferSize&&(n=new Promise(((t,n)=>{e=t,o=n}))),this._messages.push(new Jt(t,this._totalMessageCount,e,o))}try{this._reconnectInProgress||await this._connection.send(t)}catch{this._disconnected()}await n}_ack(e){let t=-1;for(let n=0;nthis._nextReceivingSequenceId?this._connection.stop(new Error("Sequence ID greater than amount of messages we've received.")):this._nextReceivingSequenceId=e.sequenceId}_disconnected(){this._reconnectInProgress=!0,this._waitForSequenceMessage=!0}async _resend(){const e=0!==this._messages.length?this._messages[0]._id:this._totalMessageCount+1;await this._connection.send(this._protocol.writeMessage({type:jt.Sequence,sequenceId:e}));const t=this._messages;for(const e of t)await this._connection.send(e._message);this._reconnectInProgress=!1}_dispose(e){null!=e||(e=new Error("Unable to reconnect to server."));for(const t of this._messages)t._rejector(e)}_isInvocationMessage(e){switch(e.type){case jt.Invocation:case jt.StreamItem:case jt.Completion:case jt.StreamInvocation:case jt.CancelInvocation:return!0;case jt.Close:case jt.Sequence:case jt.Ping:case jt.Ack:return!1}}_ackTimer(){void 0===this._ackTimerHandle&&(this._ackTimerHandle=setTimeout((async()=>{try{this._reconnectInProgress||await this._connection.send(this._protocol.writeMessage({type:jt.Ack,sequenceId:this._latestReceivedSequenceId}))}catch{}clearTimeout(this._ackTimerHandle),this._ackTimerHandle=void 0}),1e3))}}class Jt{constructor(e,t,n,o){this._message=e,this._id=t,this._resolver=n,this._rejector=o}}!function(e){e.Disconnected="Disconnected",e.Connecting="Connecting",e.Connected="Connected",e.Disconnecting="Disconnecting",e.Reconnecting="Reconnecting"}(Wt||(Wt={}));class Kt{static create(e,t,n,o,r,s,i){return new Kt(e,t,n,o,r,s,i)}constructor(e,t,n,o,r,s,i){this._nextKeepAlive=0,this._freezeEventListener=()=>{this._logger.log(yt.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")},bt.isRequired(e,"connection"),bt.isRequired(t,"logger"),bt.isRequired(n,"protocol"),this.serverTimeoutInMilliseconds=null!=r?r:3e4,this.keepAliveIntervalInMilliseconds=null!=s?s:15e3,this._statefulReconnectBufferSize=null!=i?i:1e5,this._logger=t,this._protocol=n,this.connection=e,this._reconnectPolicy=o,this._handshakeProtocol=new Nt,this.connection.onreceive=e=>this._processIncomingData(e),this.connection.onclose=e=>this._connectionClosed(e),this._callbacks={},this._methods={},this._closedCallbacks=[],this._reconnectingCallbacks=[],this._reconnectedCallbacks=[],this._invocationId=0,this._receivedHandshakeResponse=!1,this._connectionState=Wt.Disconnected,this._connectionStarted=!1,this._cachedPingMessage=this._protocol.writeMessage({type:jt.Ping})}get state(){return this._connectionState}get connectionId(){return this.connection&&this.connection.connectionId||null}get baseUrl(){return this.connection.baseUrl||""}set baseUrl(e){if(this._connectionState!==Wt.Disconnected&&this._connectionState!==Wt.Reconnecting)throw new Error("The HubConnection must be in the Disconnected or Reconnecting state to change the url.");if(!e)throw new Error("The HubConnection url must be a valid url.");this.connection.baseUrl=e}start(){return this._startPromise=this._startWithStateTransitions(),this._startPromise}async _startWithStateTransitions(){if(this._connectionState!==Wt.Disconnected)return Promise.reject(new Error("Cannot start a HubConnection that is not in the 'Disconnected' state."));this._connectionState=Wt.Connecting,this._logger.log(yt.Debug,"Starting HubConnection.");try{await this._startInternal(),St.isBrowser&&window.document.addEventListener("freeze",this._freezeEventListener),this._connectionState=Wt.Connected,this._connectionStarted=!0,this._logger.log(yt.Debug,"HubConnection connected successfully.")}catch(e){return this._connectionState=Wt.Disconnected,this._logger.log(yt.Debug,`HubConnection failed to start successfully because of error '${e}'.`),Promise.reject(e)}}async _startInternal(){this._stopDuringStartError=void 0,this._receivedHandshakeResponse=!1;const e=new Promise(((e,t)=>{this._handshakeResolver=e,this._handshakeRejecter=t}));await this.connection.start(this._protocol.transferFormat);try{const t={protocol:this._protocol.name,version:this._protocol.version};if(this._logger.log(yt.Debug,"Sending handshake request."),await this._sendMessage(this._handshakeProtocol.writeHandshakeRequest(t)),this._logger.log(yt.Information,`Using HubProtocol '${this._protocol.name}'.`),this._cleanupTimeout(),this._resetTimeoutPeriod(),this._resetKeepAliveInterval(),await e,this._stopDuringStartError)throw this._stopDuringStartError;!!this.connection.features.reconnect&&(this._messageBuffer=new qt(this._protocol,this.connection,this._statefulReconnectBufferSize),this.connection.features.disconnected=this._messageBuffer._disconnected.bind(this._messageBuffer),this.connection.features.resend=()=>{if(this._messageBuffer)return this._messageBuffer._resend()}),this.connection.features.inherentKeepAlive||await this._sendMessage(this._cachedPingMessage)}catch(e){throw this._logger.log(yt.Debug,`Hub handshake failed with error '${e}' during start(). Stopping HubConnection.`),this._cleanupTimeout(),this._cleanupPingTimer(),await this.connection.stop(e),e}}async stop(){const e=this._startPromise;this.connection.features.reconnect=!1,this._stopPromise=this._stopInternal(),await this._stopPromise;try{await e}catch(e){}}_stopInternal(e){if(this._connectionState===Wt.Disconnected)return this._logger.log(yt.Debug,`Call to HubConnection.stop(${e}) ignored because it is already in the disconnected state.`),Promise.resolve();if(this._connectionState===Wt.Disconnecting)return this._logger.log(yt.Debug,`Call to HttpConnection.stop(${e}) ignored because the connection is already in the disconnecting state.`),this._stopPromise;const t=this._connectionState;return this._connectionState=Wt.Disconnecting,this._logger.log(yt.Debug,"Stopping HubConnection."),this._reconnectDelayHandle?(this._logger.log(yt.Debug,"Connection stopped during reconnect delay. Done reconnecting."),clearTimeout(this._reconnectDelayHandle),this._reconnectDelayHandle=void 0,this._completeClose(),Promise.resolve()):(t===Wt.Connected&&this._sendCloseMessage(),this._cleanupTimeout(),this._cleanupPingTimer(),this._stopDuringStartError=e||new Bt("The connection was stopped before the hub handshake could complete."),this.connection.stop(e))}async _sendCloseMessage(){try{await this._sendWithProtocol(this._createCloseMessage())}catch{}}stream(e,...t){const[n,o]=this._replaceStreamingParams(t),r=this._createStreamInvocation(e,t,o);let s;const i=new zt;return i.cancelCallback=()=>{const e=this._createCancelInvocation(r.invocationId);return delete this._callbacks[r.invocationId],s.then((()=>this._sendWithProtocol(e)))},this._callbacks[r.invocationId]=(e,t)=>{t?i.error(t):e&&(e.type===jt.Completion?e.error?i.error(new Error(e.error)):i.complete():i.next(e.item))},s=this._sendWithProtocol(r).catch((e=>{i.error(e),delete this._callbacks[r.invocationId]})),this._launchStreams(n,s),i}_sendMessage(e){return this._resetKeepAliveInterval(),this.connection.send(e)}_sendWithProtocol(e){return this._messageBuffer?this._messageBuffer._send(e):this._sendMessage(this._protocol.writeMessage(e))}send(e,...t){const[n,o]=this._replaceStreamingParams(t),r=this._sendWithProtocol(this._createInvocation(e,t,!0,o));return this._launchStreams(n,r),r}invoke(e,...t){const[n,o]=this._replaceStreamingParams(t),r=this._createInvocation(e,t,!1,o);return new Promise(((e,t)=>{this._callbacks[r.invocationId]=(n,o)=>{o?t(o):n&&(n.type===jt.Completion?n.error?t(new Error(n.error)):e(n.result):t(new Error(`Unexpected message type: ${n.type}`)))};const o=this._sendWithProtocol(r).catch((e=>{t(e),delete this._callbacks[r.invocationId]}));this._launchStreams(n,o)}))}on(e,t){e&&t&&(e=e.toLowerCase(),this._methods[e]||(this._methods[e]=[]),-1===this._methods[e].indexOf(t)&&this._methods[e].push(t))}off(e,t){if(!e)return;e=e.toLowerCase();const n=this._methods[e];if(n)if(t){const o=n.indexOf(t);-1!==o&&(n.splice(o,1),0===n.length&&delete this._methods[e])}else delete this._methods[e]}onclose(e){e&&this._closedCallbacks.push(e)}onreconnecting(e){e&&this._reconnectingCallbacks.push(e)}onreconnected(e){e&&this._reconnectedCallbacks.push(e)}_processIncomingData(e){if(this._cleanupTimeout(),this._receivedHandshakeResponse||(e=this._processHandshakeResponse(e),this._receivedHandshakeResponse=!0),e){const t=this._protocol.parseMessages(e,this._logger);for(const e of t)if(!this._messageBuffer||this._messageBuffer._shouldProcessMessage(e))switch(e.type){case jt.Invocation:this._invokeClientMethod(e);break;case jt.StreamItem:case jt.Completion:{const t=this._callbacks[e.invocationId];if(t){e.type===jt.Completion&&delete this._callbacks[e.invocationId];try{t(e)}catch(e){this._logger.log(yt.Error,`Stream callback threw error: ${Pt(e)}`)}}break}case jt.Ping:break;case jt.Close:{this._logger.log(yt.Information,"Close message received from server.");const t=e.error?new Error("Server returned an error on close: "+e.error):void 0;!0===e.allowReconnect?this.connection.stop(t):this._stopPromise=this._stopInternal(t);break}case jt.Ack:this._messageBuffer&&this._messageBuffer._ack(e);break;case jt.Sequence:this._messageBuffer&&this._messageBuffer._resetSequence(e);break;default:this._logger.log(yt.Warning,`Invalid message type: ${e.type}.`)}}this._resetTimeoutPeriod()}_processHandshakeResponse(e){let t,n;try{[n,t]=this._handshakeProtocol.parseHandshakeResponse(e)}catch(e){const t="Error parsing handshake response: "+e;this._logger.log(yt.Error,t);const n=new Error(t);throw this._handshakeRejecter(n),n}if(t.error){const e="Server returned handshake error: "+t.error;this._logger.log(yt.Error,e);const n=new Error(e);throw this._handshakeRejecter(n),n}return this._logger.log(yt.Debug,"Server handshake complete."),this._handshakeResolver(),n}_resetKeepAliveInterval(){this.connection.features.inherentKeepAlive||(this._nextKeepAlive=(new Date).getTime()+this.keepAliveIntervalInMilliseconds,this._cleanupPingTimer())}_resetTimeoutPeriod(){if(!(this.connection.features&&this.connection.features.inherentKeepAlive||(this._timeoutHandle=setTimeout((()=>this.serverTimeout()),this.serverTimeoutInMilliseconds),void 0!==this._pingServerHandle))){let e=this._nextKeepAlive-(new Date).getTime();e<0&&(e=0),this._pingServerHandle=setTimeout((async()=>{if(this._connectionState===Wt.Connected)try{await this._sendMessage(this._cachedPingMessage)}catch{this._cleanupPingTimer()}}),e)}}serverTimeout(){this.connection.stop(new Error("Server timeout elapsed without receiving a message from the server."))}async _invokeClientMethod(e){const t=e.target.toLowerCase(),n=this._methods[t];if(!n)return this._logger.log(yt.Warning,`No client method with the name '${t}' found.`),void(e.invocationId&&(this._logger.log(yt.Warning,`No result given for '${t}' method and invocation ID '${e.invocationId}'.`),await this._sendWithProtocol(this._createCompletionMessage(e.invocationId,"Client didn't provide a result.",null))));const o=n.slice(),r=!!e.invocationId;let s,i,a;for(const n of o)try{const o=s;s=await n.apply(this,e.arguments),r&&s&&o&&(this._logger.log(yt.Error,`Multiple results provided for '${t}'. Sending error to server.`),a=this._createCompletionMessage(e.invocationId,"Client provided multiple results.",null)),i=void 0}catch(e){i=e,this._logger.log(yt.Error,`A callback for the method '${t}' threw error '${e}'.`)}a?await this._sendWithProtocol(a):r?(i?a=this._createCompletionMessage(e.invocationId,`${i}`,null):void 0!==s?a=this._createCompletionMessage(e.invocationId,null,s):(this._logger.log(yt.Warning,`No result given for '${t}' method and invocation ID '${e.invocationId}'.`),a=this._createCompletionMessage(e.invocationId,"Client didn't provide a result.",null)),await this._sendWithProtocol(a)):s&&this._logger.log(yt.Error,`Result given for '${t}' method but server is not expecting a result.`)}_connectionClosed(e){this._logger.log(yt.Debug,`HubConnection.connectionClosed(${e}) called while in state ${this._connectionState}.`),this._stopDuringStartError=this._stopDuringStartError||e||new Bt("The underlying connection was closed before the hub handshake could complete."),this._handshakeResolver&&this._handshakeResolver(),this._cancelCallbacksWithError(e||new Error("Invocation canceled due to the underlying connection being closed.")),this._cleanupTimeout(),this._cleanupPingTimer(),this._connectionState===Wt.Disconnecting?this._completeClose(e):this._connectionState===Wt.Connected&&this._reconnectPolicy?this._reconnect(e):this._connectionState===Wt.Connected&&this._completeClose(e)}_completeClose(e){if(this._connectionStarted){this._connectionState=Wt.Disconnected,this._connectionStarted=!1,this._messageBuffer&&(this._messageBuffer._dispose(null!=e?e:new Error("Connection closed.")),this._messageBuffer=void 0),St.isBrowser&&window.document.removeEventListener("freeze",this._freezeEventListener);try{this._closedCallbacks.forEach((t=>t.apply(this,[e])))}catch(t){this._logger.log(yt.Error,`An onclose callback called with error '${e}' threw error '${t}'.`)}}}async _reconnect(e){const t=Date.now();let n=0,o=void 0!==e?e:new Error("Attempting to reconnect due to a unknown error."),r=this._getNextRetryDelay(n++,0,o);if(null===r)return this._logger.log(yt.Debug,"Connection not reconnecting because the IRetryPolicy returned null on the first reconnect attempt."),void this._completeClose(e);if(this._connectionState=Wt.Reconnecting,e?this._logger.log(yt.Information,`Connection reconnecting because of error '${e}'.`):this._logger.log(yt.Information,"Connection reconnecting."),0!==this._reconnectingCallbacks.length){try{this._reconnectingCallbacks.forEach((t=>t.apply(this,[e])))}catch(t){this._logger.log(yt.Error,`An onreconnecting callback called with error '${e}' threw error '${t}'.`)}if(this._connectionState!==Wt.Reconnecting)return void this._logger.log(yt.Debug,"Connection left the reconnecting state in onreconnecting callback. Done reconnecting.")}for(;null!==r;){if(this._logger.log(yt.Information,`Reconnect attempt number ${n} will start in ${r} ms.`),await new Promise((e=>{this._reconnectDelayHandle=setTimeout(e,r)})),this._reconnectDelayHandle=void 0,this._connectionState!==Wt.Reconnecting)return void this._logger.log(yt.Debug,"Connection left the reconnecting state during reconnect delay. Done reconnecting.");try{if(await this._startInternal(),this._connectionState=Wt.Connected,this._logger.log(yt.Information,"HubConnection reconnected successfully."),0!==this._reconnectedCallbacks.length)try{this._reconnectedCallbacks.forEach((e=>e.apply(this,[this.connection.connectionId])))}catch(e){this._logger.log(yt.Error,`An onreconnected callback called with connectionId '${this.connection.connectionId}; threw error '${e}'.`)}return}catch(e){if(this._logger.log(yt.Information,`Reconnect attempt failed because of error '${e}'.`),this._connectionState!==Wt.Reconnecting)return this._logger.log(yt.Debug,`Connection moved to the '${this._connectionState}' from the reconnecting state during reconnect attempt. Done reconnecting.`),void(this._connectionState===Wt.Disconnecting&&this._completeClose());o=e instanceof Error?e:new Error(e.toString()),r=this._getNextRetryDelay(n++,Date.now()-t,o)}}this._logger.log(yt.Information,`Reconnect retries have been exhausted after ${Date.now()-t} ms and ${n} failed attempts. Connection disconnecting.`),this._completeClose()}_getNextRetryDelay(e,t,n){try{return this._reconnectPolicy.nextRetryDelayInMilliseconds({elapsedMilliseconds:t,previousRetryCount:e,retryReason:n})}catch(n){return this._logger.log(yt.Error,`IRetryPolicy.nextRetryDelayInMilliseconds(${e}, ${t}) threw error '${n}'.`),null}}_cancelCallbacksWithError(e){const t=this._callbacks;this._callbacks={},Object.keys(t).forEach((n=>{const o=t[n];try{o(null,e)}catch(t){this._logger.log(yt.Error,`Stream 'error' callback called with '${e}' threw error: ${Pt(t)}`)}}))}_cleanupPingTimer(){this._pingServerHandle&&(clearTimeout(this._pingServerHandle),this._pingServerHandle=void 0)}_cleanupTimeout(){this._timeoutHandle&&clearTimeout(this._timeoutHandle)}_createInvocation(e,t,n,o){if(n)return 0!==o.length?{arguments:t,streamIds:o,target:e,type:jt.Invocation}:{arguments:t,target:e,type:jt.Invocation};{const n=this._invocationId;return this._invocationId++,0!==o.length?{arguments:t,invocationId:n.toString(),streamIds:o,target:e,type:jt.Invocation}:{arguments:t,invocationId:n.toString(),target:e,type:jt.Invocation}}}_launchStreams(e,t){if(0!==e.length){t||(t=Promise.resolve());for(const n in e)e[n].subscribe({complete:()=>{t=t.then((()=>this._sendWithProtocol(this._createCompletionMessage(n))))},error:e=>{let o;o=e instanceof Error?e.message:e&&e.toString?e.toString():"Unknown error",t=t.then((()=>this._sendWithProtocol(this._createCompletionMessage(n,o))))},next:e=>{t=t.then((()=>this._sendWithProtocol(this._createStreamItemMessage(n,e))))}})}}_replaceStreamingParams(e){const t=[],n=[];for(let o=0;o0)&&(t=!1,this._accessToken=await this._accessTokenFactory()),this._setAuthorizationHeader(e);const n=await this._innerClient.send(e);return t&&401===n.statusCode&&this._accessTokenFactory?(this._accessToken=await this._accessTokenFactory(),this._setAuthorizationHeader(e),await this._innerClient.send(e)):n}_setAuthorizationHeader(e){e.headers||(e.headers={}),this._accessToken?e.headers[Yt.Authorization]=`Bearer ${this._accessToken}`:this._accessTokenFactory&&e.headers[Yt.Authorization]&&delete e.headers[Yt.Authorization]}getCookieString(e){return this._innerClient.getCookieString(e)}}class en extends Qt{constructor(e){super(),this._logger=e;const t={_fetchType:void 0,_jar:void 0};var o;o=t,"undefined"==typeof fetch&&(o._jar=new(n(628).CookieJar),"undefined"==typeof fetch?o._fetchType=n(200):o._fetchType=fetch,o._fetchType=n(203)(o._fetchType,o._jar),1)?(this._fetchType=t._fetchType,this._jar=t._jar):this._fetchType=fetch.bind(function(){if("undefined"!=typeof globalThis)return globalThis;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==n.g)return n.g;throw new Error("could not find global")}()),this._abortControllerType=AbortController;const r={_abortControllerType:this._abortControllerType};(function(e){return"undefined"==typeof AbortController&&(e._abortControllerType=n(778),!0)})(r)&&(this._abortControllerType=r._abortControllerType)}async send(e){if(e.abortSignal&&e.abortSignal.aborted)throw new Bt;if(!e.method)throw new Error("No method defined.");if(!e.url)throw new Error("No url defined.");const t=new this._abortControllerType;let n;e.abortSignal&&(e.abortSignal.onabort=()=>{t.abort(),n=new Bt});let o,r=null;if(e.timeout){const o=e.timeout;r=setTimeout((()=>{t.abort(),this._logger.log(yt.Warning,"Timeout from HTTP request."),n=new Mt}),o)}""===e.content&&(e.content=void 0),e.content&&(e.headers=e.headers||{},Ct(e.content)?e.headers["Content-Type"]="application/octet-stream":e.headers["Content-Type"]="text/plain;charset=UTF-8");try{o=await this._fetchType(e.url,{body:e.content,cache:"no-cache",credentials:!0===e.withCredentials?"include":"same-origin",headers:{"X-Requested-With":"XMLHttpRequest",...e.headers},method:e.method,mode:"cors",redirect:"follow",signal:t.signal})}catch(e){if(n)throw n;throw this._logger.log(yt.Warning,`Error from HTTP request. ${e}.`),e}finally{r&&clearTimeout(r),e.abortSignal&&(e.abortSignal.onabort=null)}if(!o.ok){const e=await tn(o,"text");throw new Ut(e||o.statusText,o.status)}const s=tn(o,e.responseType),i=await s;return new Gt(o.status,o.statusText,i)}getCookieString(e){return""}}function tn(e,t){let n;switch(t){case"arraybuffer":n=e.arrayBuffer();break;case"text":default:n=e.text();break;case"blob":case"document":case"json":throw new Error(`${t} is not supported.`)}return n}class nn extends Qt{constructor(e){super(),this._logger=e}send(e){return e.abortSignal&&e.abortSignal.aborted?Promise.reject(new Bt):e.method?e.url?new Promise(((t,n)=>{const o=new XMLHttpRequest;o.open(e.method,e.url,!0),o.withCredentials=void 0===e.withCredentials||e.withCredentials,o.setRequestHeader("X-Requested-With","XMLHttpRequest"),""===e.content&&(e.content=void 0),e.content&&(Ct(e.content)?o.setRequestHeader("Content-Type","application/octet-stream"):o.setRequestHeader("Content-Type","text/plain;charset=UTF-8"));const r=e.headers;r&&Object.keys(r).forEach((e=>{o.setRequestHeader(e,r[e])})),e.responseType&&(o.responseType=e.responseType),e.abortSignal&&(e.abortSignal.onabort=()=>{o.abort(),n(new Bt)}),e.timeout&&(o.timeout=e.timeout),o.onload=()=>{e.abortSignal&&(e.abortSignal.onabort=null),o.status>=200&&o.status<300?t(new Gt(o.status,o.statusText,o.response||o.responseText)):n(new Ut(o.response||o.responseText||o.statusText,o.status))},o.onerror=()=>{this._logger.log(yt.Warning,`Error from HTTP request. ${o.status}: ${o.statusText}.`),n(new Ut(o.statusText,o.status))},o.ontimeout=()=>{this._logger.log(yt.Warning,"Timeout from HTTP request."),n(new Mt)},o.send(e.content)})):Promise.reject(new Error("No url defined.")):Promise.reject(new Error("No method defined."))}}class on extends Qt{constructor(e){if(super(),"undefined"!=typeof fetch)this._httpClient=new en(e);else{if("undefined"==typeof XMLHttpRequest)throw new Error("No usable HttpClient found.");this._httpClient=new nn(e)}}send(e){return e.abortSignal&&e.abortSignal.aborted?Promise.reject(new Bt):e.method?e.url?this._httpClient.send(e):Promise.reject(new Error("No url defined.")):Promise.reject(new Error("No method defined."))}getCookieString(e){return this._httpClient.getCookieString(e)}}var rn,sn;!function(e){e[e.None=0]="None",e[e.WebSockets=1]="WebSockets",e[e.ServerSentEvents=2]="ServerSentEvents",e[e.LongPolling=4]="LongPolling"}(rn||(rn={})),function(e){e[e.Text=1]="Text",e[e.Binary=2]="Binary"}(sn||(sn={}));class an{constructor(){this._isAborted=!1,this.onabort=null}abort(){this._isAborted||(this._isAborted=!0,this.onabort&&this.onabort())}get signal(){return this}get aborted(){return this._isAborted}}class cn{get pollAborted(){return this._pollAbort.aborted}constructor(e,t,n){this._httpClient=e,this._logger=t,this._pollAbort=new an,this._options=n,this._running=!1,this.onreceive=null,this.onclose=null}async connect(e,t){if(bt.isRequired(e,"url"),bt.isRequired(t,"transferFormat"),bt.isIn(t,sn,"transferFormat"),this._url=e,this._logger.log(yt.Trace,"(LongPolling transport) Connecting."),t===sn.Binary&&"undefined"!=typeof XMLHttpRequest&&"string"!=typeof(new XMLHttpRequest).responseType)throw new Error("Binary protocols over XmlHttpRequest not implementing advanced features are not supported.");const[n,o]=Dt(),r={[n]:o,...this._options.headers},s={abortSignal:this._pollAbort.signal,headers:r,timeout:1e5,withCredentials:this._options.withCredentials};t===sn.Binary&&(s.responseType="arraybuffer");const i=`${e}&_=${Date.now()}`;this._logger.log(yt.Trace,`(LongPolling transport) polling: ${i}.`);const a=await this._httpClient.get(i,s);200!==a.statusCode?(this._logger.log(yt.Error,`(LongPolling transport) Unexpected response code: ${a.statusCode}.`),this._closeError=new Ut(a.statusText||"",a.statusCode),this._running=!1):this._running=!0,this._receiving=this._poll(this._url,s)}async _poll(e,t){try{for(;this._running;)try{const n=`${e}&_=${Date.now()}`;this._logger.log(yt.Trace,`(LongPolling transport) polling: ${n}.`);const o=await this._httpClient.get(n,t);204===o.statusCode?(this._logger.log(yt.Information,"(LongPolling transport) Poll terminated by server."),this._running=!1):200!==o.statusCode?(this._logger.log(yt.Error,`(LongPolling transport) Unexpected response code: ${o.statusCode}.`),this._closeError=new Ut(o.statusText||"",o.statusCode),this._running=!1):o.content?(this._logger.log(yt.Trace,`(LongPolling transport) data received. ${Et(o.content,this._options.logMessageContent)}.`),this.onreceive&&this.onreceive(o.content)):this._logger.log(yt.Trace,"(LongPolling transport) Poll timed out, reissuing.")}catch(e){this._running?e instanceof Mt?this._logger.log(yt.Trace,"(LongPolling transport) Poll timed out, reissuing."):(this._closeError=e,this._running=!1):this._logger.log(yt.Trace,`(LongPolling transport) Poll errored after shutdown: ${e.message}`)}}finally{this._logger.log(yt.Trace,"(LongPolling transport) Polling complete."),this.pollAborted||this._raiseOnClose()}}async send(e){return this._running?It(this._logger,"LongPolling",this._httpClient,this._url,e,this._options):Promise.reject(new Error("Cannot send until the transport is connected"))}async stop(){this._logger.log(yt.Trace,"(LongPolling transport) Stopping polling."),this._running=!1,this._pollAbort.abort();try{await this._receiving,this._logger.log(yt.Trace,`(LongPolling transport) sending DELETE request to ${this._url}.`);const e={},[t,n]=Dt();e[t]=n;const o={headers:{...e,...this._options.headers},timeout:this._options.timeout,withCredentials:this._options.withCredentials};let r;try{await this._httpClient.delete(this._url,o)}catch(e){r=e}r?r instanceof Ut&&(404===r.statusCode?this._logger.log(yt.Trace,"(LongPolling transport) A 404 response was returned from sending a DELETE request."):this._logger.log(yt.Trace,`(LongPolling transport) Error sending a DELETE request: ${r}`)):this._logger.log(yt.Trace,"(LongPolling transport) DELETE request accepted.")}finally{this._logger.log(yt.Trace,"(LongPolling transport) Stop finished."),this._raiseOnClose()}}_raiseOnClose(){if(this.onclose){let e="(LongPolling transport) Firing onclose event.";this._closeError&&(e+=" Error: "+this._closeError),this._logger.log(yt.Trace,e),this.onclose(this._closeError)}}}class ln{constructor(e,t,n,o){this._httpClient=e,this._accessToken=t,this._logger=n,this._options=o,this.onreceive=null,this.onclose=null}async connect(e,t){return bt.isRequired(e,"url"),bt.isRequired(t,"transferFormat"),bt.isIn(t,sn,"transferFormat"),this._logger.log(yt.Trace,"(SSE transport) Connecting."),this._url=e,this._accessToken&&(e+=(e.indexOf("?")<0?"?":"&")+`access_token=${encodeURIComponent(this._accessToken)}`),new Promise(((n,o)=>{let r,s=!1;if(t===sn.Text){if(St.isBrowser||St.isWebWorker)r=new this._options.EventSource(e,{withCredentials:this._options.withCredentials});else{const t=this._httpClient.getCookieString(e),n={};n.Cookie=t;const[o,s]=Dt();n[o]=s,r=new this._options.EventSource(e,{withCredentials:this._options.withCredentials,headers:{...n,...this._options.headers}})}try{r.onmessage=e=>{if(this.onreceive)try{this._logger.log(yt.Trace,`(SSE transport) data received. ${Et(e.data,this._options.logMessageContent)}.`),this.onreceive(e.data)}catch(e){return void this._close(e)}},r.onerror=e=>{s?this._close():o(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._logger.log(yt.Information,`SSE connected to ${this._url}`),this._eventSource=r,s=!0,n()}}catch(e){return void o(e)}}else o(new Error("The Server-Sent Events transport only supports the 'Text' transfer format"))}))}async send(e){return this._eventSource?It(this._logger,"SSE",this._httpClient,this._url,e,this._options):Promise.reject(new Error("Cannot send until the transport is connected"))}stop(){return this._close(),Promise.resolve()}_close(e){this._eventSource&&(this._eventSource.close(),this._eventSource=void 0,this.onclose&&this.onclose(e))}}class hn{constructor(e,t,n,o,r,s){this._logger=n,this._accessTokenFactory=t,this._logMessageContent=o,this._webSocketConstructor=r,this._httpClient=e,this.onreceive=null,this.onclose=null,this._headers=s}async connect(e,t){let n;return bt.isRequired(e,"url"),bt.isRequired(t,"transferFormat"),bt.isIn(t,sn,"transferFormat"),this._logger.log(yt.Trace,"(WebSockets transport) Connecting."),this._accessTokenFactory&&(n=await this._accessTokenFactory()),new Promise(((o,r)=>{let s;e=e.replace(/^http/,"ws");const i=this._httpClient.getCookieString(e);let a=!1;if(St.isReactNative){const t={},[o,r]=Dt();t[o]=r,n&&(t[Yt.Authorization]=`Bearer ${n}`),i&&(t[Yt.Cookie]=i),s=new this._webSocketConstructor(e,void 0,{headers:{...t,...this._headers}})}else n&&(e+=(e.indexOf("?")<0?"?":"&")+`access_token=${encodeURIComponent(n)}`);s||(s=new this._webSocketConstructor(e)),t===sn.Binary&&(s.binaryType="arraybuffer"),s.onopen=t=>{this._logger.log(yt.Information,`WebSocket connected to ${e}.`),this._webSocket=s,a=!0,o()},s.onerror=e=>{let t=null;t="undefined"!=typeof ErrorEvent&&e instanceof ErrorEvent?e.error:"There was an error with the transport",this._logger.log(yt.Information,`(WebSockets transport) ${t}.`)},s.onmessage=e=>{if(this._logger.log(yt.Trace,`(WebSockets transport) data received. ${Et(e.data,this._logMessageContent)}.`),this.onreceive)try{this.onreceive(e.data)}catch(e){return void this._close(e)}},s.onclose=e=>{if(a)this._close(e);else{let t=null;t="undefined"!=typeof ErrorEvent&&e instanceof ErrorEvent?e.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(t))}}}))}send(e){return this._webSocket&&this._webSocket.readyState===this._webSocketConstructor.OPEN?(this._logger.log(yt.Trace,`(WebSockets transport) sending data. ${Et(e,this._logMessageContent)}.`),this._webSocket.send(e),Promise.resolve()):Promise.reject("WebSocket is not in the OPEN state")}stop(){return this._webSocket&&this._close(void 0),Promise.resolve()}_close(e){this._webSocket&&(this._webSocket.onclose=()=>{},this._webSocket.onmessage=()=>{},this._webSocket.onerror=()=>{},this._webSocket.close(),this._webSocket=void 0),this._logger.log(yt.Trace,"(WebSockets transport) socket closed."),this.onclose&&(!this._isCloseEvent(e)||!1!==e.wasClean&&1e3===e.code?e instanceof Error?this.onclose(e):this.onclose():this.onclose(new Error(`WebSocket closed with status code: ${e.code} (${e.reason||"no reason given"}).`)))}_isCloseEvent(e){return e&&"boolean"==typeof e.wasClean&&"number"==typeof e.code}}class dn{constructor(e,t={}){if(this._stopPromiseResolver=()=>{},this.features={},this._negotiateVersion=1,bt.isRequired(e,"url"),this._logger=function(e){return void 0===e?new Tt(yt.Information):null===e?wt.instance:void 0!==e.log?e:new Tt(e)}(t.logger),this.baseUrl=this._resolveUrl(e),(t=t||{}).logMessageContent=void 0!==t.logMessageContent&&t.logMessageContent,"boolean"!=typeof t.withCredentials&&void 0!==t.withCredentials)throw new Error("withCredentials option was not a 'boolean' or 'undefined' value");t.withCredentials=void 0===t.withCredentials||t.withCredentials,t.timeout=void 0===t.timeout?1e5:t.timeout,"undefined"==typeof WebSocket||t.WebSocket||(t.WebSocket=WebSocket),"undefined"==typeof EventSource||t.EventSource||(t.EventSource=EventSource),this._httpClient=new Zt(t.httpClient||new on(this._logger),t.accessTokenFactory),this._connectionState="Disconnected",this._connectionStarted=!1,this._options=t,this.onreceive=null,this.onclose=null}async start(e){if(e=e||sn.Binary,bt.isIn(e,sn,"transferFormat"),this._logger.log(yt.Debug,`Starting connection with transfer format '${sn[e]}'.`),"Disconnected"!==this._connectionState)return Promise.reject(new Error("Cannot start an HttpConnection that is not in the 'Disconnected' state."));if(this._connectionState="Connecting",this._startInternalPromise=this._startInternal(e),await this._startInternalPromise,"Disconnecting"===this._connectionState){const e="Failed to start the HttpConnection before stop() was called.";return this._logger.log(yt.Error,e),await this._stopPromise,Promise.reject(new Bt(e))}if("Connected"!==this._connectionState){const e="HttpConnection.startInternal completed gracefully but didn't enter the connection into the connected state!";return this._logger.log(yt.Error,e),Promise.reject(new Bt(e))}this._connectionStarted=!0}send(e){return"Connected"!==this._connectionState?Promise.reject(new Error("Cannot send data if the connection is not in the 'Connected' State.")):(this._sendQueue||(this._sendQueue=new un(this.transport)),this._sendQueue.send(e))}async stop(e){return"Disconnected"===this._connectionState?(this._logger.log(yt.Debug,`Call to HttpConnection.stop(${e}) ignored because the connection is already in the disconnected state.`),Promise.resolve()):"Disconnecting"===this._connectionState?(this._logger.log(yt.Debug,`Call to HttpConnection.stop(${e}) ignored because the connection is already in the disconnecting state.`),this._stopPromise):(this._connectionState="Disconnecting",this._stopPromise=new Promise((e=>{this._stopPromiseResolver=e})),await this._stopInternal(e),void await this._stopPromise)}async _stopInternal(e){this._stopError=e;try{await this._startInternalPromise}catch(e){}if(this.transport){try{await this.transport.stop()}catch(e){this._logger.log(yt.Error,`HttpConnection.transport.stop() threw error '${e}'.`),this._stopConnection()}this.transport=void 0}else this._logger.log(yt.Debug,"HttpConnection.transport is undefined in HttpConnection.stop() because start() failed.")}async _startInternal(e){let t=this.baseUrl;this._accessTokenFactory=this._options.accessTokenFactory,this._httpClient._accessTokenFactory=this._accessTokenFactory;try{if(this._options.skipNegotiation){if(this._options.transport!==rn.WebSockets)throw new Error("Negotiation can only be skipped when using the WebSocket transport directly.");this.transport=this._constructTransport(rn.WebSockets),await this._startTransport(t,e)}else{let n=null,o=0;do{if(n=await this._getNegotiationResponse(t),"Disconnecting"===this._connectionState||"Disconnected"===this._connectionState)throw new Bt("The connection was stopped during negotiation.");if(n.error)throw new Error(n.error);if(n.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(n.url&&(t=n.url),n.accessToken){const e=n.accessToken;this._accessTokenFactory=()=>e,this._httpClient._accessToken=e,this._httpClient._accessTokenFactory=void 0}o++}while(n.url&&o<100);if(100===o&&n.url)throw new Error("Negotiate redirection limit exceeded.");await this._createTransport(t,this._options.transport,n,e)}this.transport instanceof cn&&(this.features.inherentKeepAlive=!0),"Connecting"===this._connectionState&&(this._logger.log(yt.Debug,"The HttpConnection connected successfully."),this._connectionState="Connected")}catch(e){return this._logger.log(yt.Error,"Failed to start the connection: "+e),this._connectionState="Disconnected",this.transport=void 0,this._stopPromiseResolver(),Promise.reject(e)}}async _getNegotiationResponse(e){const t={},[n,o]=Dt();t[n]=o;const r=this._resolveNegotiateUrl(e);this._logger.log(yt.Debug,`Sending negotiation request: ${r}.`);try{const e=await this._httpClient.post(r,{content:"",headers:{...t,...this._options.headers},timeout:this._options.timeout,withCredentials:this._options.withCredentials});if(200!==e.statusCode)return Promise.reject(new Error(`Unexpected status code returned from negotiate '${e.statusCode}'`));const n=JSON.parse(e.content);return(!n.negotiateVersion||n.negotiateVersion<1)&&(n.connectionToken=n.connectionId),n.useAck&&!0!==this._options._useStatefulReconnect?Promise.reject(new Ft("Client didn't negotiate Stateful Reconnect but the server did.")):n}catch(e){let t="Failed to complete negotiation with the server: "+e;return e instanceof Ut&&404===e.statusCode&&(t+=" Either this is not a SignalR endpoint or there is a proxy blocking the connection."),this._logger.log(yt.Error,t),Promise.reject(new Ft(t))}}_createConnectUrl(e,t){return t?e+(-1===e.indexOf("?")?"?":"&")+`id=${t}`:e}async _createTransport(e,t,n,o){let r=this._createConnectUrl(e,n.connectionToken);if(this._isITransport(t))return this._logger.log(yt.Debug,"Connection was provided an instance of ITransport, using that directly."),this.transport=t,await this._startTransport(r,o),void(this.connectionId=n.connectionId);const s=[],i=n.availableTransports||[];let a=n;for(const n of i){const i=this._resolveTransportOrError(n,t,o,!0===(null==a?void 0:a.useAck));if(i instanceof Error)s.push(`${n.transport} failed:`),s.push(i);else if(this._isITransport(i)){if(this.transport=i,!a){try{a=await this._getNegotiationResponse(e)}catch(e){return Promise.reject(e)}r=this._createConnectUrl(e,a.connectionToken)}try{return await this._startTransport(r,o),void(this.connectionId=a.connectionId)}catch(e){if(this._logger.log(yt.Error,`Failed to start the transport '${n.transport}': ${e}`),a=void 0,s.push(new Ot(`${n.transport} failed: ${e}`,rn[n.transport])),"Connecting"!==this._connectionState){const e="Failed to select transport before stop() was called.";return this._logger.log(yt.Debug,e),Promise.reject(new Bt(e))}}}}return s.length>0?Promise.reject(new Ht(`Unable to connect to the server with any of the available transports. ${s.join(" ")}`,s)):Promise.reject(new Error("None of the transports supported by the client are supported by the server."))}_constructTransport(e){switch(e){case rn.WebSockets:if(!this._options.WebSocket)throw new Error("'WebSocket' is not supported in your environment.");return new hn(this._httpClient,this._accessTokenFactory,this._logger,this._options.logMessageContent,this._options.WebSocket,this._options.headers||{});case rn.ServerSentEvents:if(!this._options.EventSource)throw new Error("'EventSource' is not supported in your environment.");return new ln(this._httpClient,this._httpClient._accessToken,this._logger,this._options);case rn.LongPolling:return new cn(this._httpClient,this._logger,this._options);default:throw new Error(`Unknown transport: ${e}.`)}}_startTransport(e,t){return this.transport.onreceive=this.onreceive,this.features.reconnect?this.transport.onclose=async n=>{let o=!1;if(this.features.resend){try{this.features.disconnected(),await this.transport.connect(e,t),await this.features.resend()}catch{o=!0}o&&this._stopConnection(n)}else this._stopConnection(n)}:this.transport.onclose=e=>this._stopConnection(e),this.transport.connect(e,t)}_resolveTransportOrError(e,t,n,o){const r=rn[e.transport];if(null==r)return this._logger.log(yt.Debug,`Skipping transport '${e.transport}' because it is not supported by this client.`),new Error(`Skipping transport '${e.transport}' because it is not supported by this client.`);if(!function(e,t){return!e||0!=(t&e)}(t,r))return this._logger.log(yt.Debug,`Skipping transport '${rn[r]}' because it was disabled by the client.`),new $t(`'${rn[r]}' is disabled by the client.`,r);if(!(e.transferFormats.map((e=>sn[e])).indexOf(n)>=0))return this._logger.log(yt.Debug,`Skipping transport '${rn[r]}' because it does not support the requested transfer format '${sn[n]}'.`),new Error(`'${rn[r]}' does not support ${sn[n]}.`);if(r===rn.WebSockets&&!this._options.WebSocket||r===rn.ServerSentEvents&&!this._options.EventSource)return this._logger.log(yt.Debug,`Skipping transport '${rn[r]}' because it is not supported in your environment.'`),new Lt(`'${rn[r]}' is not supported in your environment.`,r);this._logger.log(yt.Debug,`Selecting transport '${rn[r]}'.`);try{return this.features.reconnect=r===rn.WebSockets?o:void 0,this._constructTransport(r)}catch(e){return e}}_isITransport(e){return e&&"object"==typeof e&&"connect"in e}_stopConnection(e){if(this._logger.log(yt.Debug,`HttpConnection.stopConnection(${e}) called while in state ${this._connectionState}.`),this.transport=void 0,e=this._stopError||e,this._stopError=void 0,"Disconnected"!==this._connectionState){if("Connecting"===this._connectionState)throw this._logger.log(yt.Warning,`Call to HttpConnection.stopConnection(${e}) was ignored because the connection is still in the connecting state.`),new Error(`HttpConnection.stopConnection(${e}) was called while the connection is still in the connecting state.`);if("Disconnecting"===this._connectionState&&this._stopPromiseResolver(),e?this._logger.log(yt.Error,`Connection disconnected with error '${e}'.`):this._logger.log(yt.Information,"Connection disconnected."),this._sendQueue&&(this._sendQueue.stop().catch((e=>{this._logger.log(yt.Error,`TransportSendQueue.stop() threw error '${e}'.`)})),this._sendQueue=void 0),this.connectionId=void 0,this._connectionState="Disconnected",this._connectionStarted){this._connectionStarted=!1;try{this.onclose&&this.onclose(e)}catch(t){this._logger.log(yt.Error,`HttpConnection.onclose(${e}) threw error '${t}'.`)}}}else this._logger.log(yt.Debug,`Call to HttpConnection.stopConnection(${e}) was ignored because the connection is already in the disconnected state.`)}_resolveUrl(e){if(0===e.lastIndexOf("https://",0)||0===e.lastIndexOf("http://",0))return e;if(!St.isBrowser)throw new Error(`Cannot resolve '${e}'.`);const t=window.document.createElement("a");return t.href=e,this._logger.log(yt.Information,`Normalizing '${e}' to '${t.href}'.`),t.href}_resolveNegotiateUrl(e){const t=new URL(e);t.pathname.endsWith("/")?t.pathname+="negotiate":t.pathname+="/negotiate";const n=new URLSearchParams(t.searchParams);return n.has("negotiateVersion")||n.append("negotiateVersion",this._negotiateVersion.toString()),n.has("useAck")?"true"===n.get("useAck")&&(this._options._useStatefulReconnect=!0):!0===this._options._useStatefulReconnect&&n.append("useAck","true"),t.search=n.toString(),t.toString()}}class un{constructor(e){this._transport=e,this._buffer=[],this._executing=!0,this._sendBufferedData=new pn,this._transportResult=new pn,this._sendLoopPromise=this._sendLoop()}send(e){return this._bufferData(e),this._transportResult||(this._transportResult=new pn),this._transportResult.promise}stop(){return this._executing=!1,this._sendBufferedData.resolve(),this._sendLoopPromise}_bufferData(e){if(this._buffer.length&&typeof this._buffer[0]!=typeof e)throw new Error(`Expected data to be of type ${typeof this._buffer} but was of type ${typeof e}`);this._buffer.push(e),this._sendBufferedData.resolve()}async _sendLoop(){for(;;){if(await this._sendBufferedData.promise,!this._executing){this._transportResult&&this._transportResult.reject("Connection stopped.");break}this._sendBufferedData=new pn;const e=this._transportResult;this._transportResult=void 0;const t="string"==typeof this._buffer[0]?this._buffer.join(""):un._concatBuffers(this._buffer);this._buffer.length=0;try{await this._transport.send(t),e.resolve()}catch(t){e.reject(t)}}}static _concatBuffers(e){const t=e.map((e=>e.byteLength)).reduce(((e,t)=>e+t)),n=new Uint8Array(t);let o=0;for(const t of e)n.set(new Uint8Array(t),o),o+=t.byteLength;return n.buffer}}class pn{constructor(){this.promise=new Promise(((e,t)=>[this._resolver,this._rejecter]=[e,t]))}resolve(){this._resolver()}reject(e){this._rejecter(e)}}class fn{constructor(){this.name="json",this.version=1,this.transferFormat=sn.Text}parseMessages(e,t){if("string"!=typeof e)throw new Error("Invalid input for JSON hub protocol. Expected a string.");if(!e)return[];null===t&&(t=wt.instance);const n=vt.parse(e),o=[];for(const e of n){const n=JSON.parse(e);if("number"!=typeof n.type)throw new Error("Invalid payload.");switch(n.type){case jt.Invocation:this._isInvocationMessage(n);break;case jt.StreamItem:this._isStreamItemMessage(n);break;case jt.Completion:this._isCompletionMessage(n);break;case jt.Ping:case jt.Close:break;case jt.Ack:this._isAckMessage(n);break;case jt.Sequence:this._isSequenceMessage(n);break;default:t.log(yt.Information,"Unknown message type '"+n.type+"' ignored.");continue}o.push(n)}return o}writeMessage(e){return vt.write(JSON.stringify(e))}_isInvocationMessage(e){this._assertNotEmptyString(e.target,"Invalid payload for Invocation message."),void 0!==e.invocationId&&this._assertNotEmptyString(e.invocationId,"Invalid payload for Invocation message.")}_isStreamItemMessage(e){if(this._assertNotEmptyString(e.invocationId,"Invalid payload for StreamItem message."),void 0===e.item)throw new Error("Invalid payload for StreamItem message.")}_isCompletionMessage(e){if(e.result&&e.error)throw new Error("Invalid payload for Completion message.");!e.result&&e.error&&this._assertNotEmptyString(e.error,"Invalid payload for Completion message."),this._assertNotEmptyString(e.invocationId,"Invalid payload for Completion message.")}_isAckMessage(e){if("number"!=typeof e.sequenceId)throw new Error("Invalid SequenceId for Ack message.")}_isSequenceMessage(e){if("number"!=typeof e.sequenceId)throw new Error("Invalid SequenceId for Sequence message.")}_assertNotEmptyString(e,t){if("string"!=typeof e||""===e)throw new Error(t)}}const gn={trace:yt.Trace,debug:yt.Debug,info:yt.Information,information:yt.Information,warn:yt.Warning,warning:yt.Warning,error:yt.Error,critical:yt.Critical,none:yt.None};class mn{configureLogging(e){if(bt.isRequired(e,"logging"),function(e){return void 0!==e.log}(e))this.logger=e;else if("string"==typeof e){const t=function(e){const t=gn[e.toLowerCase()];if(void 0!==t)return t;throw new Error(`Unknown log level: ${e}`)}(e);this.logger=new Tt(t)}else this.logger=new Tt(e);return this}withUrl(e,t){return bt.isRequired(e,"url"),bt.isNotEmpty(e,"url"),this.url=e,this.httpConnectionOptions="object"==typeof t?{...this.httpConnectionOptions,...t}:{...this.httpConnectionOptions,transport:t},this}withHubProtocol(e){return bt.isRequired(e,"protocol"),this.protocol=e,this}withAutomaticReconnect(e){if(this.reconnectPolicy)throw new Error("A reconnectPolicy has already been set.");return e?Array.isArray(e)?this.reconnectPolicy=new Xt(e):this.reconnectPolicy=e:this.reconnectPolicy=new Xt,this}withServerTimeout(e){return bt.isRequired(e,"milliseconds"),this._serverTimeoutInMilliseconds=e,this}withKeepAliveInterval(e){return bt.isRequired(e,"milliseconds"),this._keepAliveIntervalInMilliseconds=e,this}withStatefulReconnect(e){return void 0===this.httpConnectionOptions&&(this.httpConnectionOptions={}),this.httpConnectionOptions._useStatefulReconnect=!0,this._statefulReconnectBufferSize=null==e?void 0:e.bufferSize,this}build(){const e=this.httpConnectionOptions||{};if(void 0===e.logger&&(e.logger=this.logger),!this.url)throw new Error("The 'HubConnectionBuilder.withUrl' method must be called before building the connection.");const t=new dn(this.url,e);return Kt.create(t,this.logger||wt.instance,this.protocol||new fn,this.reconnectPolicy,this._serverTimeoutInMilliseconds,this._keepAliveIntervalInMilliseconds,this._statefulReconnectBufferSize)}}var vn;!function(e){e[e.Default=0]="Default",e[e.Server=1]="Server",e[e.WebAssembly=2]="WebAssembly",e[e.WebView=3]="WebView"}(vn||(vn={}));var yn,wn,_n,bn=4294967295;function Sn(e,t,n){var o=Math.floor(n/4294967296),r=n;e.setUint32(t,o),e.setUint32(t+4,r)}function En(e,t){return 4294967296*e.getInt32(t)+e.getUint32(t+4)}var Cn=("undefined"==typeof process||"never"!==(null===(yn=null===process||void 0===process?void 0:process.env)||void 0===yn?void 0:yn.TEXT_ENCODING))&&"undefined"!=typeof TextEncoder&&"undefined"!=typeof TextDecoder;function In(e){for(var t=e.length,n=0,o=0;o=55296&&r<=56319&&o65535&&(h-=65536,s.push(h>>>10&1023|55296),h=56320|1023&h),s.push(h)}else s.push(a);s.length>=4096&&(i+=String.fromCharCode.apply(String,s),s.length=0)}return s.length>0&&(i+=String.fromCharCode.apply(String,s)),i}var Rn,An=Cn?new TextDecoder:null,Pn=Cn?"undefined"!=typeof process&&"force"!==(null===(_n=null===process||void 0===process?void 0:process.env)||void 0===_n?void 0:_n.TEXT_DECODER)?200:0:bn,Nn=function(e,t){this.type=e,this.data=t},Un=(Rn=function(e,t){return Rn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Rn(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}Rn(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),Mn=function(e){function t(n){var o=e.call(this,n)||this,r=Object.create(t.prototype);return Object.setPrototypeOf(o,r),Object.defineProperty(o,"name",{configurable:!0,enumerable:!1,value:t.name}),o}return Un(t,e),t}(Error),Bn={type:-1,encode:function(e){var t,n,o,r;return e instanceof Date?function(e){var t,n=e.sec,o=e.nsec;if(n>=0&&o>=0&&n<=17179869183){if(0===o&&n<=4294967295){var r=new Uint8Array(4);return(t=new DataView(r.buffer)).setUint32(0,n),r}var s=n/4294967296,i=4294967295&n;return r=new Uint8Array(8),(t=new DataView(r.buffer)).setUint32(0,o<<2|3&s),t.setUint32(4,i),r}return r=new Uint8Array(12),(t=new DataView(r.buffer)).setUint32(0,o),Sn(t,4,n),r}((o=1e6*((t=e.getTime())-1e3*(n=Math.floor(t/1e3))),{sec:n+(r=Math.floor(o/1e9)),nsec:o-1e9*r})):null},decode:function(e){var t=function(e){var t=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(e.byteLength){case 4:return{sec:t.getUint32(0),nsec:0};case 8:var n=t.getUint32(0);return{sec:4294967296*(3&n)+t.getUint32(4),nsec:n>>>2};case 12:return{sec:En(t,4),nsec:t.getUint32(0)};default:throw new Mn("Unrecognized data size for timestamp (expected 4, 8, or 12): ".concat(e.length))}}(e);return new Date(1e3*t.sec+t.nsec/1e6)}},Ln=function(){function e(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(Bn)}return e.prototype.register=function(e){var t=e.type,n=e.encode,o=e.decode;if(t>=0)this.encoders[t]=n,this.decoders[t]=o;else{var r=1+t;this.builtInEncoders[r]=n,this.builtInDecoders[r]=o}},e.prototype.tryToEncode=function(e,t){for(var n=0;nthis.maxDepth)throw new Error("Too deep objects in depth ".concat(t));null==e?this.encodeNil():"boolean"==typeof e?this.encodeBoolean(e):"number"==typeof e?this.encodeNumber(e):"string"==typeof e?this.encodeString(e):this.encodeObject(e,t)},e.prototype.ensureBufferSizeToWrite=function(e){var t=this.pos+e;this.view.byteLength=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):(this.writeU8(211),this.writeI64(e)):this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))},e.prototype.writeStringHeader=function(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else{if(!(e<4294967296))throw new Error("Too long string: ".concat(e," bytes in UTF-8"));this.writeU8(219),this.writeU32(e)}},e.prototype.encodeString=function(e){if(e.length>Tn){var t=In(e);this.ensureBufferSizeToWrite(5+t),this.writeStringHeader(t),Dn(e,this.bytes,this.pos),this.pos+=t}else t=In(e),this.ensureBufferSizeToWrite(5+t),this.writeStringHeader(t),function(e,t,n){for(var o=e.length,r=n,s=0;s>6&31|192;else{if(i>=55296&&i<=56319&&s>12&15|224,t[r++]=i>>6&63|128):(t[r++]=i>>18&7|240,t[r++]=i>>12&63|128,t[r++]=i>>6&63|128)}t[r++]=63&i|128}else t[r++]=i}}(e,this.bytes,this.pos),this.pos+=t},e.prototype.encodeObject=function(e,t){var n=this.extensionCodec.tryToEncode(e,this.context);if(null!=n)this.encodeExtension(n);else if(Array.isArray(e))this.encodeArray(e,t);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else{if("object"!=typeof e)throw new Error("Unrecognized object: ".concat(Object.prototype.toString.apply(e)));this.encodeMap(e,t)}},e.prototype.encodeBinary=function(e){var t=e.byteLength;if(t<256)this.writeU8(196),this.writeU8(t);else if(t<65536)this.writeU8(197),this.writeU16(t);else{if(!(t<4294967296))throw new Error("Too large binary: ".concat(t));this.writeU8(198),this.writeU32(t)}var n=$n(e);this.writeU8a(n)},e.prototype.encodeArray=function(e,t){var n=e.length;if(n<16)this.writeU8(144+n);else if(n<65536)this.writeU8(220),this.writeU16(n);else{if(!(n<4294967296))throw new Error("Too large array: ".concat(n));this.writeU8(221),this.writeU32(n)}for(var o=0,r=e;o0&&e<=this.maxKeyLength},e.prototype.find=function(e,t,n){e:for(var o=0,r=this.caches[n-1];o=this.maxLengthPerKey?n[Math.random()*n.length|0]=o:n.push(o)},e.prototype.decode=function(e,t,n){var o=this.find(e,t,n);if(null!=o)return this.hit++,o;this.miss++;var r=xn(e,t,n),s=Uint8Array.prototype.slice.call(e,t,t+n);return this.store(s,r),r},e}(),jn=function(e,t){var n,o,r,s,i={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,o&&(r=2&s[0]?o.return:s[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,s[1])).done)return r;switch(o=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,o=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((r=(r=i.trys).length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]=e},e.prototype.createExtraByteError=function(e){var t=this.view,n=this.pos;return new RangeError("Extra ".concat(t.byteLength-n," of ").concat(t.byteLength," byte(s) found at buffer[").concat(e,"]"))},e.prototype.decode=function(e){this.reinitializeState(),this.setBuffer(e);var t=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return t},e.prototype.decodeMulti=function(e){return jn(this,(function(t){switch(t.label){case 0:this.reinitializeState(),this.setBuffer(e),t.label=1;case 1:return this.hasRemaining(1)?[4,this.doDecodeSync()]:[3,3];case 2:return t.sent(),[3,1];case 3:return[2]}}))},e.prototype.decodeAsync=function(e){var t,n,o,r,s,i,a;return s=this,void 0,a=function(){var s,i,a,c,l,h,d,u;return jn(this,(function(p){switch(p.label){case 0:s=!1,p.label=1;case 1:p.trys.push([1,6,7,12]),t=Wn(e),p.label=2;case 2:return[4,t.next()];case 3:if((n=p.sent()).done)return[3,5];if(a=n.value,s)throw this.createExtraByteError(this.totalPos);this.appendBuffer(a);try{i=this.doDecodeSync(),s=!0}catch(e){if(!(e instanceof Kn))throw e}this.totalPos+=this.pos,p.label=4;case 4:return[3,2];case 5:return[3,12];case 6:return c=p.sent(),o={error:c},[3,12];case 7:return p.trys.push([7,,10,11]),n&&!n.done&&(r=t.return)?[4,r.call(t)]:[3,9];case 8:p.sent(),p.label=9;case 9:return[3,11];case 10:if(o)throw o.error;return[7];case 11:return[7];case 12:if(s){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return[2,i]}throw h=(l=this).headByte,d=l.pos,u=l.totalPos,new RangeError("Insufficient data in parsing ".concat(Fn(h)," at ").concat(u," (").concat(d," in the current buffer)"))}}))},new((i=void 0)||(i=Promise))((function(e,t){function n(e){try{r(a.next(e))}catch(e){t(e)}}function o(e){try{r(a.throw(e))}catch(e){t(e)}}function r(t){var r;t.done?e(t.value):(r=t.value,r instanceof i?r:new i((function(e){e(r)}))).then(n,o)}r((a=a.apply(s,[])).next())}))},e.prototype.decodeArrayStream=function(e){return this.decodeMultiAsync(e,!0)},e.prototype.decodeStream=function(e){return this.decodeMultiAsync(e,!1)},e.prototype.decodeMultiAsync=function(e,t){return function(n,o,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s,i=function(){var n,o,r,s,i,a,c,l,h;return jn(this,(function(d){switch(d.label){case 0:n=t,o=-1,d.label=1;case 1:d.trys.push([1,13,14,19]),r=Wn(e),d.label=2;case 2:return[4,zn(r.next())];case 3:if((s=d.sent()).done)return[3,12];if(i=s.value,t&&0===o)throw this.createExtraByteError(this.totalPos);this.appendBuffer(i),n&&(o=this.readArraySize(),n=!1,this.complete()),d.label=4;case 4:d.trys.push([4,9,,10]),d.label=5;case 5:return[4,zn(this.doDecodeSync())];case 6:return[4,d.sent()];case 7:return d.sent(),0==--o?[3,8]:[3,5];case 8:return[3,10];case 9:if(!((a=d.sent())instanceof Kn))throw a;return[3,10];case 10:this.totalPos+=this.pos,d.label=11;case 11:return[3,2];case 12:return[3,19];case 13:return c=d.sent(),l={error:c},[3,19];case 14:return d.trys.push([14,,17,18]),s&&!s.done&&(h=r.return)?[4,zn(h.call(r))]:[3,16];case 15:d.sent(),d.label=16;case 16:return[3,18];case 17:if(l)throw l.error;return[7];case 18:return[7];case 19:return[2]}}))}.apply(n,o||[]),a=[];return s={},c("next"),c("throw"),c("return"),s[Symbol.asyncIterator]=function(){return this},s;function c(e){i[e]&&(s[e]=function(t){return new Promise((function(n,o){a.push([e,t,n,o])>1||l(e,t)}))})}function l(e,t){try{(n=i[e](t)).value instanceof zn?Promise.resolve(n.value.v).then(h,d):u(a[0][2],n)}catch(e){u(a[0][3],e)}var n}function h(e){l("next",e)}function d(e){l("throw",e)}function u(e,t){e(t),a.shift(),a.length&&l(a[0][0],a[0][1])}}(this,arguments)},e.prototype.doDecodeSync=function(){e:for(;;){var e=this.readHeadByte(),t=void 0;if(e>=224)t=e-256;else if(e<192)if(e<128)t=e;else if(e<144){if(0!=(o=e-128)){this.pushMapState(o),this.complete();continue e}t={}}else if(e<160){if(0!=(o=e-144)){this.pushArrayState(o),this.complete();continue e}t=[]}else{var n=e-160;t=this.decodeUtf8String(n,0)}else if(192===e)t=null;else if(194===e)t=!1;else if(195===e)t=!0;else if(202===e)t=this.readF32();else if(203===e)t=this.readF64();else if(204===e)t=this.readU8();else if(205===e)t=this.readU16();else if(206===e)t=this.readU32();else if(207===e)t=this.readU64();else if(208===e)t=this.readI8();else if(209===e)t=this.readI16();else if(210===e)t=this.readI32();else if(211===e)t=this.readI64();else if(217===e)n=this.lookU8(),t=this.decodeUtf8String(n,1);else if(218===e)n=this.lookU16(),t=this.decodeUtf8String(n,2);else if(219===e)n=this.lookU32(),t=this.decodeUtf8String(n,4);else if(220===e){if(0!==(o=this.readU16())){this.pushArrayState(o),this.complete();continue e}t=[]}else if(221===e){if(0!==(o=this.readU32())){this.pushArrayState(o),this.complete();continue e}t=[]}else if(222===e){if(0!==(o=this.readU16())){this.pushMapState(o),this.complete();continue e}t={}}else if(223===e){if(0!==(o=this.readU32())){this.pushMapState(o),this.complete();continue e}t={}}else if(196===e){var o=this.lookU8();t=this.decodeBinary(o,1)}else if(197===e)o=this.lookU16(),t=this.decodeBinary(o,2);else if(198===e)o=this.lookU32(),t=this.decodeBinary(o,4);else if(212===e)t=this.decodeExtension(1,0);else if(213===e)t=this.decodeExtension(2,0);else if(214===e)t=this.decodeExtension(4,0);else if(215===e)t=this.decodeExtension(8,0);else if(216===e)t=this.decodeExtension(16,0);else if(199===e)o=this.lookU8(),t=this.decodeExtension(o,1);else if(200===e)o=this.lookU16(),t=this.decodeExtension(o,2);else{if(201!==e)throw new Mn("Unrecognized type byte: ".concat(Fn(e)));o=this.lookU32(),t=this.decodeExtension(o,4)}this.complete();for(var r=this.stack;r.length>0;){var s=r[r.length-1];if(0===s.type){if(s.array[s.position]=t,s.position++,s.position!==s.size)continue e;r.pop(),t=s.array}else{if(1===s.type){if("string"!=(i=typeof t)&&"number"!==i)throw new Mn("The type of key must be string or number but "+typeof t);if("__proto__"===t)throw new Mn("The key __proto__ is not allowed");s.key=t,s.type=2;continue e}if(s.map[s.key]=t,s.readCount++,s.readCount!==s.size){s.key=null,s.type=1;continue e}r.pop(),t=s.map}}return t}var i},e.prototype.readHeadByte=function(){return-1===this.headByte&&(this.headByte=this.readU8()),this.headByte},e.prototype.complete=function(){this.headByte=-1},e.prototype.readArraySize=function(){var e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:if(e<160)return e-144;throw new Mn("Unrecognized array type byte: ".concat(Fn(e)))}},e.prototype.pushMapState=function(e){if(e>this.maxMapLength)throw new Mn("Max length exceeded: map length (".concat(e,") > maxMapLengthLength (").concat(this.maxMapLength,")"));this.stack.push({type:1,size:e,key:null,readCount:0,map:{}})},e.prototype.pushArrayState=function(e){if(e>this.maxArrayLength)throw new Mn("Max length exceeded: array length (".concat(e,") > maxArrayLength (").concat(this.maxArrayLength,")"));this.stack.push({type:0,size:e,array:new Array(e),position:0})},e.prototype.decodeUtf8String=function(e,t){var n;if(e>this.maxStrLength)throw new Mn("Max length exceeded: UTF-8 byte length (".concat(e,") > maxStrLength (").concat(this.maxStrLength,")"));if(this.bytes.byteLengthPn?function(e,t,n){var o=e.subarray(t,t+n);return An.decode(o)}(this.bytes,r,e):xn(this.bytes,r,e),this.pos+=t+e,o},e.prototype.stateIsMapKey=function(){return this.stack.length>0&&1===this.stack[this.stack.length-1].type},e.prototype.decodeBinary=function(e,t){if(e>this.maxBinLength)throw new Mn("Max length exceeded: bin length (".concat(e,") > maxBinLength (").concat(this.maxBinLength,")"));if(!this.hasRemaining(e+t))throw Vn;var n=this.pos+t,o=this.bytes.subarray(n,n+e);return this.pos+=t+e,o},e.prototype.decodeExtension=function(e,t){if(e>this.maxExtLength)throw new Mn("Max length exceeded: ext length (".concat(e,") > maxExtLength (").concat(this.maxExtLength,")"));var n=this.view.getInt8(this.pos+t),o=this.decodeBinary(e,t+1);return this.extensionCodec.decode(o,n,this.context)},e.prototype.lookU8=function(){return this.view.getUint8(this.pos)},e.prototype.lookU16=function(){return this.view.getUint16(this.pos)},e.prototype.lookU32=function(){return this.view.getUint32(this.pos)},e.prototype.readU8=function(){var e=this.view.getUint8(this.pos);return this.pos++,e},e.prototype.readI8=function(){var e=this.view.getInt8(this.pos);return this.pos++,e},e.prototype.readU16=function(){var e=this.view.getUint16(this.pos);return this.pos+=2,e},e.prototype.readI16=function(){var e=this.view.getInt16(this.pos);return this.pos+=2,e},e.prototype.readU32=function(){var e=this.view.getUint32(this.pos);return this.pos+=4,e},e.prototype.readI32=function(){var e=this.view.getInt32(this.pos);return this.pos+=4,e},e.prototype.readU64=function(){var e,t,n=(e=this.view,t=this.pos,4294967296*e.getUint32(t)+e.getUint32(t+4));return this.pos+=8,n},e.prototype.readI64=function(){var e=En(this.view,this.pos);return this.pos+=8,e},e.prototype.readF32=function(){var e=this.view.getFloat32(this.pos);return this.pos+=4,e},e.prototype.readF64=function(){var e=this.view.getFloat64(this.pos);return this.pos+=8,e},e}();class Gn{static write(e){let t=e.byteLength||e.length;const n=[];do{let e=127&t;t>>=7,t>0&&(e|=128),n.push(e)}while(t>0);t=e.byteLength||e.length;const o=new Uint8Array(n.length+t);return o.set(n,0),o.set(e,n.length),o.buffer}static parse(e){const t=[],n=new Uint8Array(e),o=[0,7,14,21,28];for(let r=0;r7)throw new Error("Messages bigger than 2GB are not supported.");if(!(n.byteLength>=r+i+a))throw new Error("Incomplete message.");t.push(n.slice?n.slice(r+i,r+i+a):n.subarray(r+i,r+i+a)),r=r+i+a}return t}}const Qn=new Uint8Array([145,jt.Ping]);class Zn{constructor(e){this.name="messagepack",this.version=1,this.transferFormat=sn.Binary,this._errorResult=1,this._voidResult=2,this._nonVoidResult=3,e=e||{},this._encoder=new On(e.extensionCodec,e.context,e.maxDepth,e.initialBufferSize,e.sortKeys,e.forceFloat32,e.ignoreUndefined,e.forceIntegerToFloat),this._decoder=new Yn(e.extensionCodec,e.context,e.maxStrLength,e.maxBinLength,e.maxArrayLength,e.maxMapLength,e.maxExtLength)}parseMessages(e,t){if(!(n=e)||"undefined"==typeof ArrayBuffer||!(n instanceof ArrayBuffer||n.constructor&&"ArrayBuffer"===n.constructor.name))throw new Error("Invalid input for MessagePack hub protocol. Expected an ArrayBuffer.");var n;null===t&&(t=wt.instance);const o=Gn.parse(e),r=[];for(const e of o){const n=this._parseMessage(e,t);n&&r.push(n)}return r}writeMessage(e){switch(e.type){case jt.Invocation:return this._writeInvocation(e);case jt.StreamInvocation:return this._writeStreamInvocation(e);case jt.StreamItem:return this._writeStreamItem(e);case jt.Completion:return this._writeCompletion(e);case jt.Ping:return Gn.write(Qn);case jt.CancelInvocation:return this._writeCancelInvocation(e);case jt.Close:return this._writeClose();case jt.Ack:return this._writeAck(e);case jt.Sequence:return this._writeSequence(e);default:throw new Error("Invalid message type.")}}_parseMessage(e,t){if(0===e.length)throw new Error("Invalid payload.");const n=this._decoder.decode(e);if(0===n.length||!(n instanceof Array))throw new Error("Invalid payload.");const o=n[0];switch(o){case jt.Invocation:return this._createInvocationMessage(this._readHeaders(n),n);case jt.StreamItem:return this._createStreamItemMessage(this._readHeaders(n),n);case jt.Completion:return this._createCompletionMessage(this._readHeaders(n),n);case jt.Ping:return this._createPingMessage(n);case jt.Close:return this._createCloseMessage(n);case jt.Ack:return this._createAckMessage(n);case jt.Sequence:return this._createSequenceMessage(n);default:return t.log(yt.Information,"Unknown message type '"+o+"' ignored."),null}}_createCloseMessage(e){if(e.length<2)throw new Error("Invalid payload for Close message.");return{allowReconnect:e.length>=3?e[2]:void 0,error:e[1],type:jt.Close}}_createPingMessage(e){if(e.length<1)throw new Error("Invalid payload for Ping message.");return{type:jt.Ping}}_createInvocationMessage(e,t){if(t.length<5)throw new Error("Invalid payload for Invocation message.");const n=t[2];return n?{arguments:t[4],headers:e,invocationId:n,streamIds:[],target:t[3],type:jt.Invocation}:{arguments:t[4],headers:e,streamIds:[],target:t[3],type:jt.Invocation}}_createStreamItemMessage(e,t){if(t.length<4)throw new Error("Invalid payload for StreamItem message.");return{headers:e,invocationId:t[2],item:t[3],type:jt.StreamItem}}_createCompletionMessage(e,t){if(t.length<4)throw new Error("Invalid payload for Completion message.");const n=t[3];if(n!==this._voidResult&&t.length<5)throw new Error("Invalid payload for Completion message.");let o,r;switch(n){case this._errorResult:o=t[4];break;case this._nonVoidResult:r=t[4]}return{error:o,headers:e,invocationId:t[2],result:r,type:jt.Completion}}_createAckMessage(e){if(e.length<1)throw new Error("Invalid payload for Ack message.");return{sequenceId:e[1],type:jt.Ack}}_createSequenceMessage(e){if(e.length<1)throw new Error("Invalid payload for Sequence message.");return{sequenceId:e[1],type:jt.Sequence}}_writeInvocation(e){let t;return t=e.streamIds?this._encoder.encode([jt.Invocation,e.headers||{},e.invocationId||null,e.target,e.arguments,e.streamIds]):this._encoder.encode([jt.Invocation,e.headers||{},e.invocationId||null,e.target,e.arguments]),Gn.write(t.slice())}_writeStreamInvocation(e){let t;return t=e.streamIds?this._encoder.encode([jt.StreamInvocation,e.headers||{},e.invocationId,e.target,e.arguments,e.streamIds]):this._encoder.encode([jt.StreamInvocation,e.headers||{},e.invocationId,e.target,e.arguments]),Gn.write(t.slice())}_writeStreamItem(e){const t=this._encoder.encode([jt.StreamItem,e.headers||{},e.invocationId,e.item]);return Gn.write(t.slice())}_writeCompletion(e){const t=e.error?this._errorResult:void 0!==e.result?this._nonVoidResult:this._voidResult;let n;switch(t){case this._errorResult:n=this._encoder.encode([jt.Completion,e.headers||{},e.invocationId,t,e.error]);break;case this._voidResult:n=this._encoder.encode([jt.Completion,e.headers||{},e.invocationId,t]);break;case this._nonVoidResult:n=this._encoder.encode([jt.Completion,e.headers||{},e.invocationId,t,e.result])}return Gn.write(n.slice())}_writeCancelInvocation(e){const t=this._encoder.encode([jt.CancelInvocation,e.headers||{},e.invocationId]);return Gn.write(t.slice())}_writeClose(){const e=this._encoder.encode([jt.Close,null]);return Gn.write(e.slice())}_writeAck(e){const t=this._encoder.encode([jt.Ack,e.sequenceId]);return Gn.write(t.slice())}_writeSequence(e){const t=this._encoder.encode([jt.Sequence,e.sequenceId]);return Gn.write(t.slice())}_readHeaders(e){const t=e[1];if("object"!=typeof t)throw new Error("Invalid headers.");return t}}const eo="function"==typeof TextDecoder?new TextDecoder("utf-8"):null,to=eo?eo.decode.bind(eo):function(e){let t=0;const n=e.length,o=[],r=[];for(;t65535&&(r-=65536,o.push(r>>>10&1023|55296),r=56320|1023&r),o.push(r)}o.length>1024&&(r.push(String.fromCharCode.apply(null,o)),o.length=0)}return r.push(String.fromCharCode.apply(null,o)),r.join("")},no=Math.pow(2,32),oo=Math.pow(2,21)-1;function ro(e,t){return e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24}function so(e,t){return e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24>>>0)}function io(e,t){const n=so(e,t+4);if(n>oo)throw new Error(`Cannot read uint64 with high order part ${n}, because the result would exceed Number.MAX_SAFE_INTEGER.`);return n*no+so(e,t)}class ao{constructor(e){this.batchData=e;const t=new uo(e);this.arrayRangeReader=new po(e),this.arrayBuilderSegmentReader=new fo(e),this.diffReader=new co(e),this.editReader=new lo(e,t),this.frameReader=new ho(e,t)}updatedComponents(){return ro(this.batchData,this.batchData.length-20)}referenceFrames(){return ro(this.batchData,this.batchData.length-16)}disposedComponentIds(){return ro(this.batchData,this.batchData.length-12)}disposedEventHandlerIds(){return ro(this.batchData,this.batchData.length-8)}updatedComponentsEntry(e,t){const n=e+4*t;return ro(this.batchData,n)}referenceFramesEntry(e,t){return e+20*t}disposedComponentIdsEntry(e,t){const n=e+4*t;return ro(this.batchData,n)}disposedEventHandlerIdsEntry(e,t){const n=e+8*t;return io(this.batchData,n)}}class co{constructor(e){this.batchDataUint8=e}componentId(e){return ro(this.batchDataUint8,e)}edits(e){return e+4}editsEntry(e,t){return e+16*t}}class lo{constructor(e,t){this.batchDataUint8=e,this.stringReader=t}editType(e){return ro(this.batchDataUint8,e)}siblingIndex(e){return ro(this.batchDataUint8,e+4)}newTreeIndex(e){return ro(this.batchDataUint8,e+8)}moveToSiblingIndex(e){return ro(this.batchDataUint8,e+8)}removedAttributeName(e){const t=ro(this.batchDataUint8,e+12);return this.stringReader.readString(t)}}class ho{constructor(e,t){this.batchDataUint8=e,this.stringReader=t}frameType(e){return ro(this.batchDataUint8,e)}subtreeLength(e){return ro(this.batchDataUint8,e+4)}elementReferenceCaptureId(e){const t=ro(this.batchDataUint8,e+4);return this.stringReader.readString(t)}componentId(e){return ro(this.batchDataUint8,e+8)}elementName(e){const t=ro(this.batchDataUint8,e+8);return this.stringReader.readString(t)}textContent(e){const t=ro(this.batchDataUint8,e+4);return this.stringReader.readString(t)}markupContent(e){const t=ro(this.batchDataUint8,e+4);return this.stringReader.readString(t)}attributeName(e){const t=ro(this.batchDataUint8,e+4);return this.stringReader.readString(t)}attributeValue(e){const t=ro(this.batchDataUint8,e+8);return this.stringReader.readString(t)}attributeEventHandlerId(e){return io(this.batchDataUint8,e+12)}}class uo{constructor(e){this.batchDataUint8=e,this.stringTableStartIndex=ro(e,e.length-4)}readString(e){if(-1===e)return null;{const n=ro(this.batchDataUint8,this.stringTableStartIndex+4*e),o=function(e,t){let n=0,o=0;for(let r=0;r<4;r++){const s=e[t+r];if(n|=(127&s)<this.nextBatchId)return this.fatalError?(this.logger.log(rt.Debug,`Received a new batch ${e} but errored out on a previous batch ${this.nextBatchId-1}`),void await n.send("OnRenderCompleted",this.nextBatchId-1,this.fatalError.toString())):void this.logger.log(rt.Debug,`Waiting for batch ${this.nextBatchId}. Batch ${e} not processed.`);try{this.nextBatchId++,this.logger.log(rt.Debug,`Applying batch ${e}.`),function(e,t){const n=fe[e];if(!n)throw new Error(`There is no browser renderer with ID ${e}.`);const o=t.arrayRangeReader,r=t.updatedComponents(),s=o.values(r),i=o.count(r),a=t.referenceFrames(),c=o.values(a),l=t.diffReader;for(let e=0;e{e.onclick=function(e){location.reload(),e.preventDefault()}})),document.querySelectorAll("#blazor-error-ui .dismiss").forEach((e=>{e.onclick=function(e){const t=document.querySelector("#blazor-error-ui");t&&(t.style.display="none"),e.preventDefault()}})))}class yo{constructor(t,n,o,r){this._renderingFailed=!1,this._disposed=!1,this._circuitId=void 0,this._applicationState=n,this._componentManager=t,this._options=o,this._logger=r,this._renderQueue=new go(this._logger),this._dispatcher=e.attachDispatcher(this)}start(){if(this.isDisposedOrDisposing())throw new Error("Cannot start a disposed circuit.");return this._startPromise||(this._startPromise=this.startCore()),this._startPromise}async startCore(){if(this._connection=await this.startConnection(),this._connection.state!==Wt.Connected)return!1;const e=JSON.stringify(this._componentManager.initialComponents.map((e=>{return t=e,{...t,start:void 0,end:void 0};var t})));return this._circuitId=await this._connection.invoke("StartCircuit",Ne.getBaseURI(),Ne.getLocationHref(),e,this._applicationState||""),!!this._circuitId}async startConnection(){var e,t;const n=new Zn;n.name="blazorpack";const o=(new mn).withUrl("_blazor").withHubProtocol(n);this._options.configureSignalR(o);const r=o.build();r.on("JS.AttachComponent",((e,t)=>function(e,t,n,o){let r=fe[e];r||(r=new he(e),fe[e]=r),r.attachRootComponentToLogicalElement(n,t,!1)}(vn.Server,this.resolveElement(t,e),e))),r.on("JS.BeginInvokeJS",this._dispatcher.beginInvokeJSFromDotNet.bind(this._dispatcher)),r.on("JS.EndInvokeDotNet",this._dispatcher.endInvokeDotNetFromJS.bind(this._dispatcher)),r.on("JS.ReceiveByteArray",this._dispatcher.receiveByteArray.bind(this._dispatcher)),r.on("JS.BeginTransmitStream",(e=>{const t=new ReadableStream({start:t=>{r.stream("SendDotNetStreamToJS",e).subscribe({next:e=>t.enqueue(e),complete:()=>t.close(),error:e=>t.error(e)})}});this._dispatcher.supplyDotNetStream(e,t)})),r.on("JS.RenderBatch",(async(e,t)=>{var n,o;this._logger.log(yt.Debug,`Received render batch with id ${e} and ${t.byteLength} bytes.`),await this._renderQueue.processBatch(e,t,this._connection),null===(o=(n=this._componentManager).onAfterRenderBatch)||void 0===o||o.call(n,vn.Server)})),r.on("JS.EndLocationChanging",ot._internal.navigationManager.endLocationChanging),r.onclose((e=>!this._disposed&&!this._renderingFailed&&this._options.reconnectionHandler.onConnectionDown(this._options.reconnectionOptions,e))),r.on("JS.Error",(e=>{this._renderingFailed=!0,this.unhandledError(e),vo()}));try{await r.start()}catch(e){if(this.unhandledError(e),"FailedToNegotiateWithServerError"===e.errorType)throw e;vo(),e.innerErrors&&(e.innerErrors.some((e=>"UnsupportedTransportError"===e.errorType&&e.transport===rn.WebSockets))?this._logger.log(yt.Error,"Unable to connect, please ensure you are using an updated browser that supports WebSockets."):e.innerErrors.some((e=>"FailedToStartTransportError"===e.errorType&&e.transport===rn.WebSockets))?this._logger.log(yt.Error,"Unable to connect, please ensure WebSockets are available. A VPN or proxy may be blocking the connection."):e.innerErrors.some((e=>"DisabledTransportError"===e.errorType&&e.transport===rn.LongPolling))&&this._logger.log(yt.Error,"Unable to initiate a SignalR connection to the server. This might be because the server is not configured to support WebSockets. For additional details, visit https://aka.ms/blazor-server-websockets-error."))}return(null===(t=null===(e=r.connection)||void 0===e?void 0:e.features)||void 0===t?void 0:t.inherentKeepAlive)&&this._logger.log(yt.Warning,"Failed to connect via WebSockets, using the Long Polling fallback transport. This may be due to a VPN or proxy blocking the connection. To troubleshoot this, visit https://aka.ms/blazor-server-using-fallback-long-polling."),r}async disconnect(){var e;await(null===(e=this._connection)||void 0===e?void 0:e.stop())}async reconnect(){if(!this._circuitId)throw new Error("Circuit host not initialized.");return this._connection.state===Wt.Connected||(this._connection=await this.startConnection(),!!await this._connection.invoke("ConnectCircuit",this._circuitId)&&(this._options.reconnectionHandler.onConnectionUp(),!0))}beginInvokeDotNetFromJS(e,t,n,o,r){this.throwIfDispatchingWhenDisposed(),this._connection.send("BeginInvokeDotNetFromJS",e?e.toString():null,t,n,o||0,r)}endInvokeJSFromDotNet(e,t,n){this.throwIfDispatchingWhenDisposed(),this._connection.send("EndInvokeJSFromDotNet",e,t,n)}sendByteArray(e,t){this.throwIfDispatchingWhenDisposed(),this._connection.send("ReceiveByteArray",e,t)}throwIfDispatchingWhenDisposed(){if(this._disposed)throw new Error("The circuit associated with this dispatcher is no longer available.")}sendLocationChanged(e,t,n){return this._connection.send("OnLocationChanged",e,t,n)}sendLocationChanging(e,t,n,o){return this._connection.send("OnLocationChanging",e,t,n,o)}sendJsDataStream(e,t,n){return function(e,t,n,o){setTimeout((async()=>{let r=5,s=(new Date).valueOf();try{const i=t instanceof Blob?t.size:t.byteLength;let a=0,c=0;for(;a1)await e.send("ReceiveJSDataChunk",n,c,h,null);else{if(!await e.invoke("ReceiveJSDataChunk",n,c,h,null))break;const t=(new Date).valueOf(),o=t-s;s=t,r=Math.max(1,Math.round(500/Math.max(1,o)))}a+=l,c++}}catch(t){await e.send("ReceiveJSDataChunk",n,-1,null,t.toString())}}),0)}(this._connection,e,t,n)}resolveElement(e,t){const n=function(e){const t=f.get(e);if(t)return f.delete(e),t}(e);if(n)return O(n,!0);const o=Number.parseInt(e);if(!Number.isNaN(o))return function(e){const{start:t,end:n}=e,o=t[$];if(o){if(o!==e)throw new Error("The start component comment was already associated with another component descriptor.");return t}const r=t.parentNode;if(!r)throw new Error(`Comment not connected to the DOM ${t.textContent}`);const s=O(r,!0),i=K(s);t[L]=s,t[$]=e;const a=O(t);if(n){const e=K(a),o=Array.prototype.indexOf.call(i,a)+1;let r=null;for(;r!==n;){const n=i.splice(o,1)[0];if(!n)throw new Error("Could not find the end component comment in the parent logical node list");n[L]=t,e.push(n),r=n}}return a}(this._componentManager.resolveRootComponent(o,t));throw new Error(`Invalid sequence number or identifier '${e}'.`)}getRootComponentManager(){return this._componentManager}unhandledError(e){this._logger.log(yt.Error,e),this.disconnect()}getDisconnectFormData(){const e=new FormData,t=this._circuitId;return e.append("circuitId",t),e}didRenderingFail(){return this._renderingFailed}isDisposedOrDisposing(){return void 0!==this._disposePromise}sendDisconnectBeacon(){if(this._disposed)return;const e=this.getDisconnectFormData();this._disposed=navigator.sendBeacon("_blazor/disconnect",e)}dispose(){return this._disposePromise||(this._disposePromise=this.disposeCore()),this._disposePromise}async disposeCore(){var e;if(!this._startPromise)return void(this._disposed=!0);await this._startPromise,this._disposed=!0,null===(e=this._connection)||void 0===e||e.stop();const t=this.getDisconnectFormData();fetch("_blazor/disconnect",{method:"POST",body:t}),function(e){if(!S.delete(e))throw new Error(`Interop methods are not registered for renderer ${e}`)}(vn.Server)}}const wo={configureSignalR:e=>{},logLevel:rt.Warning,reconnectionOptions:{maxRetries:8,retryIntervalMilliseconds:2e4,dialogId:"components-reconnect-modal"}};class _o{constructor(e,t,n,o){this.maxRetries=t,this.document=n,this.logger=o,this.addedToDom=!1,this.modal=this.document.createElement("div"),this.modal.id=e,this.maxRetries=t,this.modal.style.cssText=["position: fixed","top: 0","right: 0","bottom: 0","left: 0","z-index: 1050","display: none","overflow: hidden","background-color: #fff","opacity: 0.8","text-align: center","font-weight: bold","transition: visibility 0s linear 500ms"].join(";"),this.message=this.document.createElement("h5"),this.message.style.cssText="margin-top: 20px",this.button=this.document.createElement("button"),this.button.style.cssText="margin:5px auto 5px",this.button.textContent="Retry";const r=this.document.createElement("a");r.addEventListener("click",(()=>location.reload())),r.textContent="reload",this.reloadParagraph=this.document.createElement("p"),this.reloadParagraph.textContent="Alternatively, ",this.reloadParagraph.appendChild(r),this.modal.appendChild(this.message),this.modal.appendChild(this.button),this.modal.appendChild(this.reloadParagraph),this.loader=this.getLoader(),this.message.after(this.loader),this.button.addEventListener("click",(async()=>{this.show();try{await ot.reconnect()||this.rejected()}catch(e){this.logger.log(rt.Error,e),this.failed()}}))}show(){this.addedToDom||(this.addedToDom=!0,this.document.body.appendChild(this.modal)),this.modal.style.display="block",this.loader.style.display="inline-block",this.button.style.display="none",this.reloadParagraph.style.display="none",this.message.textContent="Attempting to reconnect to the server...",this.modal.style.visibility="hidden",setTimeout((()=>{this.modal.style.visibility="visible"}),0)}update(e){this.message.textContent=`Attempting to reconnect to the server: ${e} of ${this.maxRetries}`}hide(){this.modal.style.display="none"}failed(){this.button.style.display="block",this.reloadParagraph.style.display="none",this.loader.style.display="none";const e=this.document.createTextNode("Reconnection failed. Try "),t=this.document.createElement("a");t.textContent="reloading",t.setAttribute("href",""),t.addEventListener("click",(()=>location.reload()));const n=this.document.createTextNode(" the page if you're unable to reconnect.");this.message.replaceChildren(e,t,n)}rejected(){this.button.style.display="none",this.reloadParagraph.style.display="none",this.loader.style.display="none";const e=this.document.createTextNode("Could not reconnect to the server. "),t=this.document.createElement("a");t.textContent="Reload",t.setAttribute("href",""),t.addEventListener("click",(()=>location.reload()));const n=this.document.createTextNode(" the page to restore functionality.");this.message.replaceChildren(e,t,n)}getLoader(){const e=this.document.createElement("div");return e.style.cssText=["border: 0.3em solid #f3f3f3","border-top: 0.3em solid #3498db","border-radius: 50%","width: 2em","height: 2em","display: inline-block"].join(";"),e.animate([{transform:"rotate(0deg)"},{transform:"rotate(360deg)"}],{duration:2e3,iterations:1/0}),e}}class bo{constructor(e,t,n){this.dialog=e,this.maxRetries=t,this.document=n,this.document=n;const o=this.document.getElementById(bo.MaxRetriesId);o&&(o.innerText=this.maxRetries.toString())}show(){this.removeClasses(),this.dialog.classList.add(bo.ShowClassName)}update(e){const t=this.document.getElementById(bo.CurrentAttemptId);t&&(t.innerText=e.toString())}hide(){this.removeClasses(),this.dialog.classList.add(bo.HideClassName)}failed(){this.removeClasses(),this.dialog.classList.add(bo.FailedClassName)}rejected(){this.removeClasses(),this.dialog.classList.add(bo.RejectedClassName)}removeClasses(){this.dialog.classList.remove(bo.ShowClassName,bo.HideClassName,bo.FailedClassName,bo.RejectedClassName)}}bo.ShowClassName="components-reconnect-show",bo.HideClassName="components-reconnect-hide",bo.FailedClassName="components-reconnect-failed",bo.RejectedClassName="components-reconnect-rejected",bo.MaxRetriesId="components-reconnect-max-retries",bo.CurrentAttemptId="components-reconnect-current-attempt";class So{constructor(e,t,n){this._currentReconnectionProcess=null,this._logger=e,this._reconnectionDisplay=t,this._reconnectCallback=n||ot.reconnect}onConnectionDown(e,t){if(!this._reconnectionDisplay){const t=document.getElementById(e.dialogId);this._reconnectionDisplay=t?new bo(t,e.maxRetries,document):new _o(e.dialogId,e.maxRetries,document,this._logger)}this._currentReconnectionProcess||(this._currentReconnectionProcess=new Eo(e,this._logger,this._reconnectCallback,this._reconnectionDisplay))}onConnectionUp(){this._currentReconnectionProcess&&(this._currentReconnectionProcess.dispose(),this._currentReconnectionProcess=null)}}class Eo{constructor(e,t,n,o){this.logger=t,this.reconnectCallback=n,this.isDisposed=!1,this.reconnectDisplay=o,this.reconnectDisplay.show(),this.attemptPeriodicReconnection(e)}dispose(){this.isDisposed=!0,this.reconnectDisplay.hide()}async attemptPeriodicReconnection(e){for(let t=0;tEo.MaximumFirstRetryInterval?Eo.MaximumFirstRetryInterval:e.retryIntervalMilliseconds;if(await this.delay(n),this.isDisposed)break;try{return await this.reconnectCallback()?void 0:void this.reconnectDisplay.rejected()}catch(e){this.logger.log(rt.Error,e)}}this.reconnectDisplay.failed()}delay(e){return new Promise((t=>setTimeout(t,e)))}}Eo.MaximumFirstRetryInterval=3e3;class Co{constructor(){this.afterStartedCallbacks=[]}async importInitializersAsync(e,t){await Promise.all(e.map((e=>async function(e,n){const o=function(e){const t=document.baseURI;return t.endsWith("/")?`${t}${e}`:`${t}/${e}`}(n),r=await import(o);if(void 0===r)return;const{beforeStart:s,afterStarted:i}=r;return i&&e.afterStartedCallbacks.push(i),s?s(...t):void 0}(this,e))))}async invokeAfterStartedCallbacks(e){await I,await Promise.all(this.afterStartedCallbacks.map((t=>t(e))))}}let Io,ko,To,Do,xo=!1;async function Ro(e){if(xo)throw new Error("Blazor Server has already started.");xo=!0,Io=ct(document)||"",Do=new it(To.logLevel),ko=new yo(e,Io,To,Do),Do.log(rt.Information,"Starting up Blazor server-side application."),ot.reconnect=async()=>!(ko.didRenderingFail()||!await ko.reconnect()&&(Do.log(rt.Information,"Reconnection attempt to the circuit was rejected by the server. This may indicate that the associated state is no longer available on the server."),1)),ot.defaultReconnectionHandler=new So(Do),To.reconnectionHandler=To.reconnectionHandler||ot.defaultReconnectionHandler,ot._internal.navigationManager.listenForNavigationEvents(((e,t,n)=>ko.sendLocationChanged(e,t,n)),((e,t,n,o)=>ko.sendLocationChanging(e,t,n,o))),ot._internal.forceCloseConnection=()=>ko.disconnect(),ot._internal.sendJSDataStream=(e,t,n)=>ko.sendJsDataStream(e,t,n);const t=await async function(e){const t=await fetch("_blazor/initializers",{method:"GET",credentials:"include",cache:"no-cache"}),n=await t.json(),o=new Co;return await o.importInitializersAsync(n,[e]),o}(To);if(!await ko.start())return void Do.log(rt.Error,"Failed to start the circuit.");const n=()=>{ko.sendDisconnectBeacon()};ot.disconnect=n,window.addEventListener("unload",n,{capture:!1,once:!0}),Do.log(rt.Information,"Blazor server-side application started."),t.invokeAfterStartedCallbacks(ot)}class Ao{constructor(e){this.initialComponents=e}resolveRootComponent(e,t){return this.initialComponents[e]}}let Po=!1;function No(e){if(Po)throw new Error("Blazor has already started.");Po=!0,function(e){if(To)throw new Error("Circuit options have already been configured.");To=function(e){const t={...wo,...e};return e&&e.reconnectionOptions&&(t.reconnectionOptions={...wo.reconnectionOptions,...e.reconnectionOptions}),t}(e)}(e);const t=function(e){return lt(e,"server").sort(((e,t)=>e.sequence-t.sequence))}(document);return Ro(new Ao(t))}ot.start=No,window.DotNet=e,document&&document.currentScript&&"false"!==document.currentScript.getAttribute("autostart")&&No()})()})(); \ No newline at end of file diff --git a/src/Components/Web.JS/dist/Release/blazor.webview.js b/src/Components/Web.JS/dist/Release/blazor.webview.js index c69a53fec86b8..abff39485ac7c 100644 --- a/src/Components/Web.JS/dist/Release/blazor.webview.js +++ b/src/Components/Web.JS/dist/Release/blazor.webview.js @@ -1 +1 @@ -(()=>{"use strict";var e,t,n,r={d:(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};r.d({},{e:()=>Tt}),function(e){const t=[],n="__jsObjectId",r="__dotNetObject",o="__byte[]",a="__dotNetStream",s="__jsStreamReferenceLength";let i,c;class l{constructor(e){this._jsObject=e,this._cachedFunctions=new Map}findFunction(e){const t=this._cachedFunctions.get(e);if(t)return t;let n,r=this._jsObject;if(e.split(".").forEach((t=>{if(!(t in r))throw new Error(`Could not find '${e}' ('${t}' was undefined).`);n=r,r=r[t]})),r instanceof Function)return r=r.bind(n),this._cachedFunctions.set(e,r),r;throw new Error(`The value '${e}' is not a function.`)}getWrappedObject(){return this._jsObject}}const u={0:new l(window)};u[0]._cachedFunctions.set("import",(e=>("string"==typeof e&&e.startsWith("./")&&(e=new URL(e.substr(2),document.baseURI).toString()),import(e))));let d,h=1;function f(e){t.push(e)}function p(e){if(e&&"object"==typeof e){u[h]=new l(e);const t={[n]:h};return h++,t}throw new Error(`Cannot create a JSObjectReference from the value '${e}'.`)}function m(e){let t=-1;if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e instanceof Blob)t=e.size;else{if(!(e.buffer instanceof ArrayBuffer))throw new Error("Supplied value is not a typed array or blob.");if(void 0===e.byteLength)throw new Error(`Cannot create a JSStreamReference from the value '${e}' as it doesn't have a byteLength.`);t=e.byteLength}const r={[s]:t};try{const t=p(e);r[n]=t[n]}catch(t){throw new Error(`Cannot create a JSStreamReference from the value '${e}'.`)}return r}function v(e,n){c=e;const r=n?JSON.parse(n,((e,n)=>t.reduce(((t,n)=>n(e,t)),n))):null;return c=void 0,r}function b(){if(void 0===i)throw new Error("No call dispatcher has been set.");if(null===i)throw new Error("There are multiple .NET runtimes present, so a default dispatcher could not be resolved. Use DotNetObject to invoke .NET instance methods.");return i}e.attachDispatcher=function(e){const t=new g(e);return void 0===i?i=t:i&&(i=null),t},e.attachReviver=f,e.invokeMethod=function(e,t,...n){return b().invokeDotNetStaticMethod(e,t,...n)},e.invokeMethodAsync=function(e,t,...n){return b().invokeDotNetStaticMethodAsync(e,t,...n)},e.createJSObjectReference=p,e.createJSStreamReference=m,e.disposeJSObjectReference=function(e){const t=e&&e[n];"number"==typeof t&&E(t)},function(e){e[e.Default=0]="Default",e[e.JSObjectReference=1]="JSObjectReference",e[e.JSStreamReference=2]="JSStreamReference",e[e.JSVoidResult=3]="JSVoidResult"}(d=e.JSCallResultType||(e.JSCallResultType={}));class g{constructor(e){this._dotNetCallDispatcher=e,this._byteArraysToBeRevived=new Map,this._pendingDotNetToJSStreams=new Map,this._pendingAsyncCalls={},this._nextAsyncCallId=1}getDotNetCallDispatcher(){return this._dotNetCallDispatcher}invokeJSFromDotNet(e,t,n,r){const o=v(this,t),a=C(w(e,r)(...o||[]),n);return null==a?null:A(this,a)}beginInvokeJSFromDotNet(e,t,n,r,o){const a=new Promise((e=>{const r=v(this,n);e(w(t,o)(...r||[]))}));e&&a.then((t=>A(this,[e,!0,C(t,r)]))).then((t=>this._dotNetCallDispatcher.endInvokeJSFromDotNet(e,!0,t)),(t=>this._dotNetCallDispatcher.endInvokeJSFromDotNet(e,!1,JSON.stringify([e,!1,y(t)]))))}endInvokeDotNetFromJS(e,t,n){const r=t?v(this,n):new Error(n);this.completePendingCall(parseInt(e,10),t,r)}invokeDotNetStaticMethod(e,t,...n){return this.invokeDotNetMethod(e,t,null,n)}invokeDotNetStaticMethodAsync(e,t,...n){return this.invokeDotNetMethodAsync(e,t,null,n)}invokeDotNetMethod(e,t,n,r){if(this._dotNetCallDispatcher.invokeDotNetFromJS){const o=A(this,r),a=this._dotNetCallDispatcher.invokeDotNetFromJS(e,t,n,o);return a?v(this,a):null}throw new Error("The current dispatcher does not support synchronous calls from JS to .NET. Use invokeDotNetMethodAsync instead.")}invokeDotNetMethodAsync(e,t,n,r){if(e&&n)throw new Error(`For instance method calls, assemblyName should be null. Received '${e}'.`);const o=this._nextAsyncCallId++,a=new Promise(((e,t)=>{this._pendingAsyncCalls[o]={resolve:e,reject:t}}));try{const a=A(this,r);this._dotNetCallDispatcher.beginInvokeDotNetFromJS(o,e,t,n,a)}catch(e){this.completePendingCall(o,!1,e)}return a}receiveByteArray(e,t){this._byteArraysToBeRevived.set(e,t)}processByteArray(e){const t=this._byteArraysToBeRevived.get(e);return t?(this._byteArraysToBeRevived.delete(e),t):null}supplyDotNetStream(e,t){if(this._pendingDotNetToJSStreams.has(e)){const n=this._pendingDotNetToJSStreams.get(e);this._pendingDotNetToJSStreams.delete(e),n.resolve(t)}else{const n=new D;n.resolve(t),this._pendingDotNetToJSStreams.set(e,n)}}getDotNetStreamPromise(e){let t;if(this._pendingDotNetToJSStreams.has(e))t=this._pendingDotNetToJSStreams.get(e).streamPromise,this._pendingDotNetToJSStreams.delete(e);else{const n=new D;this._pendingDotNetToJSStreams.set(e,n),t=n.streamPromise}return t}completePendingCall(e,t,n){if(!this._pendingAsyncCalls.hasOwnProperty(e))throw new Error(`There is no pending async call with ID ${e}.`);const r=this._pendingAsyncCalls[e];delete this._pendingAsyncCalls[e],t?r.resolve(n):r.reject(n)}}function y(e){return e instanceof Error?`${e.message}\n${e.stack}`:e?e.toString():"null"}function w(e,t){const n=u[t];if(n)return n.findFunction(e);throw new Error(`JS object instance with ID ${t} does not exist (has it been disposed?).`)}function E(e){delete u[e]}e.findJSFunction=w,e.disposeJSObjectReferenceById=E;class S{constructor(e,t){this._id=e,this._callDispatcher=t}invokeMethod(e,...t){return this._callDispatcher.invokeDotNetMethod(null,e,this._id,t)}invokeMethodAsync(e,...t){return this._callDispatcher.invokeDotNetMethodAsync(null,e,this._id,t)}dispose(){this._callDispatcher.invokeDotNetMethodAsync(null,"__Dispose",this._id,null).catch((e=>console.error(e)))}serializeAsArg(){return{[r]:this._id}}}e.DotNetObject=S,f((function(e,t){if(t&&"object"==typeof t){if(t.hasOwnProperty(r))return new S(t[r],c);if(t.hasOwnProperty(n)){const e=t[n],r=u[e];if(r)return r.getWrappedObject();throw new Error(`JS object instance with Id '${e}' does not exist. It may have been disposed.`)}if(t.hasOwnProperty(o)){const e=t[o],n=c.processByteArray(e);if(void 0===n)throw new Error(`Byte array index '${e}' does not exist.`);return n}if(t.hasOwnProperty(a)){const e=t[a],n=c.getDotNetStreamPromise(e);return new I(n)}}return t}));class I{constructor(e){this._streamPromise=e}stream(){return this._streamPromise}async arrayBuffer(){return new Response(await this.stream()).arrayBuffer()}}class D{constructor(){this.streamPromise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}}function C(e,t){switch(t){case d.Default:return e;case d.JSObjectReference:return p(e);case d.JSStreamReference:return m(e);case d.JSVoidResult:return null;default:throw new Error(`Invalid JS call result type '${t}'.`)}}let N=0;function A(e,t){N=0,c=e;const n=JSON.stringify(t,k);return c=void 0,n}function k(e,t){if(t instanceof S)return t.serializeAsArg();if(t instanceof Uint8Array){c.getDotNetCallDispatcher().sendByteArray(N,t);const e={[o]:N};return N++,e}return t}}(e||(e={})),function(e){e[e.prependFrame=1]="prependFrame",e[e.removeFrame=2]="removeFrame",e[e.setAttribute=3]="setAttribute",e[e.removeAttribute=4]="removeAttribute",e[e.updateText=5]="updateText",e[e.stepIn=6]="stepIn",e[e.stepOut=7]="stepOut",e[e.updateMarkup=8]="updateMarkup",e[e.permutationListEntry=9]="permutationListEntry",e[e.permutationListEnd=10]="permutationListEnd"}(t||(t={})),function(e){e[e.element=1]="element",e[e.text=2]="text",e[e.attribute=3]="attribute",e[e.component=4]="component",e[e.region=5]="region",e[e.elementReferenceCapture=6]="elementReferenceCapture",e[e.markup=8]="markup",e[e.namedEvent=10]="namedEvent"}(n||(n={}));class o{constructor(e,t){this.componentId=e,this.fieldValue=t}static fromEvent(e,t){const n=t.target;if(n instanceof Element){const t=function(e){return e instanceof HTMLInputElement?e.type&&"checkbox"===e.type.toLowerCase()?{value:e.checked}:{value:e.value}:e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement?{value:e.value}:null}(n);if(t)return new o(e,t.value)}return null}}const a=new Map,s=new Map,i=[];function c(e){return a.get(e)}function l(e){const t=a.get(e);return(null==t?void 0:t.browserEventName)||e}function u(e,t){e.forEach((e=>a.set(e,t)))}function d(e){const t=[];for(let n=0;ne.selected)).map((e=>e.value))}}{const e=function(e){return!!e&&"INPUT"===e.tagName&&"checkbox"===e.getAttribute("type")}(t);return{value:e?!!t.checked:t.value}}}}),u(["copy","cut","paste"],{createEventArgs:e=>({type:e.type})}),u(["drag","dragend","dragenter","dragleave","dragover","dragstart","drop"],{createEventArgs:e=>{return{...h(t=e),dataTransfer:t.dataTransfer?{dropEffect:t.dataTransfer.dropEffect,effectAllowed:t.dataTransfer.effectAllowed,files:Array.from(t.dataTransfer.files).map((e=>e.name)),items:Array.from(t.dataTransfer.items).map((e=>({kind:e.kind,type:e.type}))),types:t.dataTransfer.types}:null};var t}}),u(["focus","blur","focusin","focusout"],{createEventArgs:e=>({type:e.type})}),u(["keydown","keyup","keypress"],{createEventArgs:e=>{return{key:(t=e).key,code:t.code,location:t.location,repeat:t.repeat,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,type:t.type};var t}}),u(["contextmenu","click","mouseover","mouseout","mousemove","mousedown","mouseup","mouseleave","mouseenter","dblclick"],{createEventArgs:e=>h(e)}),u(["error"],{createEventArgs:e=>{return{message:(t=e).message,filename:t.filename,lineno:t.lineno,colno:t.colno,type:t.type};var t}}),u(["loadstart","timeout","abort","load","loadend","progress"],{createEventArgs:e=>{return{lengthComputable:(t=e).lengthComputable,loaded:t.loaded,total:t.total,type:t.type};var t}}),u(["touchcancel","touchend","touchmove","touchenter","touchleave","touchstart"],{createEventArgs:e=>{return{detail:(t=e).detail,touches:d(t.touches),targetTouches:d(t.targetTouches),changedTouches:d(t.changedTouches),ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,type:t.type};var t}}),u(["gotpointercapture","lostpointercapture","pointercancel","pointerdown","pointerenter","pointerleave","pointermove","pointerout","pointerover","pointerup"],{createEventArgs:e=>{return{...h(t=e),pointerId:t.pointerId,width:t.width,height:t.height,pressure:t.pressure,tiltX:t.tiltX,tiltY:t.tiltY,pointerType:t.pointerType,isPrimary:t.isPrimary};var t}}),u(["wheel","mousewheel"],{createEventArgs:e=>{return{...h(t=e),deltaX:t.deltaX,deltaY:t.deltaY,deltaZ:t.deltaZ,deltaMode:t.deltaMode};var t}}),u(["toggle"],{createEventArgs:()=>({})});const f=["date","datetime-local","month","time","week"],p=new Map;let m,v,b=0;const g={async add(e,t,n){if(!n)throw new Error("initialParameters must be an object, even if empty.");const r="__bl-dynamic-root:"+(++b).toString();p.set(r,e);const o=await E().invokeMethodAsync("AddRootComponent",t,r),a=new w(o,v[t]);return await a.setParameters(n),a}};class y{invoke(e){return this._callback(e)}setCallback(t){this._selfJSObjectReference||(this._selfJSObjectReference=e.createJSObjectReference(this)),this._callback=t}getJSObjectReference(){return this._selfJSObjectReference}dispose(){this._selfJSObjectReference&&e.disposeJSObjectReference(this._selfJSObjectReference)}}class w{constructor(e,t){this._jsEventCallbackWrappers=new Map,this._componentId=e;for(const e of t)"eventcallback"===e.type&&this._jsEventCallbackWrappers.set(e.name.toLowerCase(),new y)}setParameters(e){const t={},n=Object.entries(e||{}),r=n.length;for(const[e,r]of n){const n=this._jsEventCallbackWrappers.get(e.toLowerCase());n&&r?(n.setCallback(r),t[e]=n.getJSObjectReference()):t[e]=r}return E().invokeMethodAsync("SetRootComponentParameters",this._componentId,r,t)}async dispose(){if(null!==this._componentId){await E().invokeMethodAsync("RemoveRootComponent",this._componentId),this._componentId=null;for(const e of this._jsEventCallbackWrappers.values())e.dispose()}}}function E(){if(!m)throw new Error("Dynamic root components have not been enabled in this application.");return m}const S=new Map,I=[];let D;const C=new Promise((e=>{D=e}));function N(e,t,n){return k(e,t.eventHandlerId,(()=>A(e).invokeMethodAsync("DispatchEventAsync",t,n)))}function A(e){const t=S.get(e);if(!t)throw new Error(`No interop methods are registered for renderer ${e}`);return t}let k=(e,t,n)=>n();const R=F(["abort","blur","canplay","canplaythrough","change","cuechange","durationchange","emptied","ended","error","focus","load","loadeddata","loadedmetadata","loadend","loadstart","mouseenter","mouseleave","pointerenter","pointerleave","pause","play","playing","progress","ratechange","reset","scroll","seeked","seeking","stalled","submit","suspend","timeupdate","toggle","unload","volumechange","waiting","DOMNodeInsertedIntoDocument","DOMNodeRemovedFromDocument"]),T={submit:!0},_=F(["click","dblclick","mousedown","mousemove","mouseup"]);class O{constructor(e){this.browserRendererId=e,this.afterClickCallbacks=[];const t=++O.nextEventDelegatorId;this.eventsCollectionKey=`_blazorEvents_${t}`,this.eventInfoStore=new x(this.onGlobalEvent.bind(this))}setListener(e,t,n,r){const o=this.getEventHandlerInfosForElement(e,!0),a=o.getHandler(t);if(a)this.eventInfoStore.update(a.eventHandlerId,n);else{const a={element:e,eventName:t,eventHandlerId:n,renderingComponentId:r};this.eventInfoStore.add(a),o.setHandler(t,a)}}getHandler(e){return this.eventInfoStore.get(e)}removeListener(e){const t=this.eventInfoStore.remove(e);if(t){const e=t.element,n=this.getEventHandlerInfosForElement(e,!1);n&&n.removeHandler(t.eventName)}}notifyAfterClick(e){this.afterClickCallbacks.push(e),this.eventInfoStore.addGlobalListener("click")}setStopPropagation(e,t,n){this.getEventHandlerInfosForElement(e,!0).stopPropagation(t,n)}setPreventDefault(e,t,n){this.getEventHandlerInfosForElement(e,!0).preventDefault(t,n)}onGlobalEvent(e){if(!(e.target instanceof Element))return;this.dispatchGlobalEventToAllElements(e.type,e);const t=(n=e.type,s.get(n));var n;t&&t.forEach((t=>this.dispatchGlobalEventToAllElements(t,e))),"click"===e.type&&this.afterClickCallbacks.forEach((t=>t(e)))}dispatchGlobalEventToAllElements(e,t){const n=t.composedPath();let r=n.shift(),a=null,s=!1;const i=Object.prototype.hasOwnProperty.call(R,e);let l=!1;for(;r;){const h=r,f=this.getEventHandlerInfosForElement(h,!1);if(f){const n=f.getHandler(e);if(n&&(u=h,d=t.type,!((u instanceof HTMLButtonElement||u instanceof HTMLInputElement||u instanceof HTMLTextAreaElement||u instanceof HTMLSelectElement)&&Object.prototype.hasOwnProperty.call(_,d)&&u.disabled))){if(!s){const n=c(e);a=(null==n?void 0:n.createEventArgs)?n.createEventArgs(t):{},s=!0}Object.prototype.hasOwnProperty.call(T,t.type)&&t.preventDefault(),N(this.browserRendererId,{eventHandlerId:n.eventHandlerId,eventName:e,eventFieldInfo:o.fromEvent(n.renderingComponentId,t)},a)}f.stopPropagation(e)&&(l=!0),f.preventDefault(e)&&t.preventDefault()}r=i||l?void 0:n.shift()}var u,d}getEventHandlerInfosForElement(e,t){return Object.prototype.hasOwnProperty.call(e,this.eventsCollectionKey)?e[this.eventsCollectionKey]:t?e[this.eventsCollectionKey]=new L:null}}O.nextEventDelegatorId=0;class x{constructor(e){this.globalListener=e,this.infosByEventHandlerId={},this.countByEventName={},i.push(this.handleEventNameAliasAdded.bind(this))}add(e){if(this.infosByEventHandlerId[e.eventHandlerId])throw new Error(`Event ${e.eventHandlerId} is already tracked`);this.infosByEventHandlerId[e.eventHandlerId]=e,this.addGlobalListener(e.eventName)}get(e){return this.infosByEventHandlerId[e]}addGlobalListener(e){if(e=l(e),Object.prototype.hasOwnProperty.call(this.countByEventName,e))this.countByEventName[e]++;else{this.countByEventName[e]=1;const t=Object.prototype.hasOwnProperty.call(R,e);document.addEventListener(e,this.globalListener,t)}}update(e,t){if(Object.prototype.hasOwnProperty.call(this.infosByEventHandlerId,t))throw new Error(`Event ${t} is already tracked`);const n=this.infosByEventHandlerId[e];delete this.infosByEventHandlerId[e],n.eventHandlerId=t,this.infosByEventHandlerId[t]=n}remove(e){const t=this.infosByEventHandlerId[e];if(t){delete this.infosByEventHandlerId[e];const n=l(t.eventName);0==--this.countByEventName[n]&&(delete this.countByEventName[n],document.removeEventListener(n,this.globalListener))}return t}handleEventNameAliasAdded(e,t){if(Object.prototype.hasOwnProperty.call(this.countByEventName,e)){const n=this.countByEventName[e];delete this.countByEventName[e],document.removeEventListener(e,this.globalListener),this.addGlobalListener(t),this.countByEventName[t]+=n-1}}}class L{constructor(){this.handlers={},this.preventDefaultFlags=null,this.stopPropagationFlags=null}getHandler(e){return Object.prototype.hasOwnProperty.call(this.handlers,e)?this.handlers[e]:null}setHandler(e,t){this.handlers[e]=t}removeHandler(e){delete this.handlers[e]}preventDefault(e,t){return void 0!==t&&(this.preventDefaultFlags=this.preventDefaultFlags||{},this.preventDefaultFlags[e]=t),!!this.preventDefaultFlags&&this.preventDefaultFlags[e]}stopPropagation(e,t){return void 0!==t&&(this.stopPropagationFlags=this.stopPropagationFlags||{},this.stopPropagationFlags[e]=t),!!this.stopPropagationFlags&&this.stopPropagationFlags[e]}}function F(e){const t={};return e.forEach((e=>{t[e]=!0})),t}const P=Symbol(),M=Symbol();function B(e,t){if(P in e)return e;const n=[];if(e.childNodes.length>0){if(!t)throw new Error("New logical elements must start empty, or allowExistingContents must be true");e.childNodes.forEach((t=>{const r=B(t,!0);r[M]=e,n.push(r)}))}return e[P]=n,e}function j(e){const t=W(e);for(;t.length;)U(e,0)}function H(e,t){const n=document.createComment("!");return J(n,e,t),n}function J(e,t,n){const r=e;let o=e;if(P in e){const t=q(r);if(t!==e){const n=new Range;n.setStartBefore(e),n.setEndAfter(t),o=n.extractContents()}}const a=$(r);if(a){const e=W(a),t=Array.prototype.indexOf.call(e,r);e.splice(t,1),delete r[M]}const s=W(t);if(n0;)U(n,0)}const r=n;r.parentNode.removeChild(r)}function $(e){return e[M]||null}function z(e,t){return W(e)[t]}function K(e){const t=Y(e);return"http://www.w3.org/2000/svg"===t.namespaceURI&&"foreignObject"!==t.tagName}function W(e){return e[P]}function V(e){const t=W($(e));return t[Array.prototype.indexOf.call(t,e)+1]||null}function X(e,t){const n=W(e);t.forEach((e=>{e.moveRangeStart=n[e.fromSiblingIndex],e.moveRangeEnd=q(e.moveRangeStart)})),t.forEach((t=>{const r=document.createComment("marker");t.moveToBeforeMarker=r;const o=n[t.toSiblingIndex+1];o?o.parentNode.insertBefore(r,o):G(r,e)})),t.forEach((e=>{const t=e.moveToBeforeMarker,n=t.parentNode,r=e.moveRangeStart,o=e.moveRangeEnd;let a=r;for(;a;){const e=a.nextSibling;if(n.insertBefore(a,t),a===o)break;a=e}n.removeChild(t)})),t.forEach((e=>{n[e.toSiblingIndex]=e.moveRangeStart}))}function Y(e){if(e instanceof Element||e instanceof DocumentFragment)return e;if(e instanceof Comment)return e.parentNode;throw new Error("Not a valid logical element")}function G(e,t){if(t instanceof Element||t instanceof DocumentFragment)t.appendChild(e);else{if(!(t instanceof Comment))throw new Error(`Cannot append node because the parent is not a valid logical element. Parent: ${t}`);{const n=V(t);n?n.parentNode.insertBefore(e,n):G(e,$(t))}}}function q(e){if(e instanceof Element||e instanceof DocumentFragment)return e;const t=V(e);if(t)return t.previousSibling;{const t=$(e);return t instanceof Element||t instanceof DocumentFragment?t.lastChild:q(t)}}function Z(e){return`_bl_${e}`}Symbol();const Q="__internalId";e.attachReviver(((e,t)=>t&&"object"==typeof t&&Object.prototype.hasOwnProperty.call(t,Q)&&"string"==typeof t[Q]?function(e){const t=`[${Z(e)}]`;return document.querySelector(t)}(t[Q]):t));const ee="_blazorDeferredValue";function te(e){return"select-multiple"===e.type}function ne(e,t){e.value=t||""}function re(e,t){e instanceof HTMLSelectElement?te(e)?function(e,t){t||(t=[]);for(let n=0;n{Ie()&&function(e,t){if(0!==e.button||function(e){return e.ctrlKey||e.shiftKey||e.altKey||e.metaKey}(e))return;if(e.defaultPrevented)return;const n=function(e){const t=!window._blazorDisableComposedPath&&e.composedPath&&e.composedPath();if(t){for(let e=0;edocument.baseURI,getLocationHref:()=>location.href,scrollToElement:xe};function xe(e){const t=document.getElementById(e);return!!t&&(t.scrollIntoView(),!0)}function Le(e,t,n=!1){const r=Ee(e);!t.forceLoad&&ge(r)?Ue()?Fe(r,!1,t.replaceHistoryEntry,t.historyEntryState,n):we(r,t.replaceHistoryEntry):function(e,t){if(location.href===e){const t=e+"?";history.replaceState(null,"",t),location.replace(e)}else t?location.replace(e):location.href=e}(e,t.replaceHistoryEntry)}async function Fe(e,t,n,r=void 0,o=!1){if(Be(),function(e){const t=e.indexOf("#");return t>-1&&location.href.replace(location.hash,"")===e.substring(0,t)}(e))!function(e,t,n){Pe(e,t,n);const r=e.indexOf("#");r!==e.length-1&&xe(e.substring(r+1))}(e,n,r);else{if(!o&&Ce&&!await je(e,r,t))return;ve=!0,Pe(e,n,r),await He(t)}}function Pe(e,t,n=void 0){t?history.replaceState({userState:n,_index:Ne},"",e):(Ne++,history.pushState({userState:n,_index:Ne},"",e))}function Me(e){return new Promise((t=>{const n=Te;Te=()=>{Te=n,t()},history.go(e)}))}function Be(){_e&&(_e(!1),_e=null)}function je(e,t,n){return new Promise((r=>{Be(),Re?(Ae++,_e=r,Re(Ae,e,t,n)):r(!1)}))}async function He(e){var t;ke&&await ke(location.href,null===(t=history.state)||void 0===t?void 0:t.userState,e)}async function Je(e){var t,n;Te&&Ue()&&await Te(e),Ne=null!==(n=null===(t=history.state)||void 0===t?void 0:t._index)&&void 0!==n?n:0}function Ue(){return Ie()||!ye()}const $e={focus:function(e,t){if(e instanceof HTMLElement)e.focus({preventScroll:t});else{if(!(e instanceof SVGElement))throw new Error("Unable to focus an invalid element.");if(!e.hasAttribute("tabindex"))throw new Error("Unable to focus an SVG element that does not have a tabindex.");e.focus({preventScroll:t})}},focusBySelector:function(e,t){const n=document.querySelector(e);n&&(n.hasAttribute("tabindex")||(n.tabIndex=-1),n.focus({preventScroll:!0}))}},ze={init:function(e,t,n,r=50){const o=We(t);(o||document.documentElement).style.overflowAnchor="none";const a=document.createRange();h(n.parentElement)&&(t.style.display="table-row",n.style.display="table-row");const s=new IntersectionObserver((function(r){r.forEach((r=>{var o;if(!r.isIntersecting)return;a.setStartAfter(t),a.setEndBefore(n);const s=a.getBoundingClientRect().height,i=null===(o=r.rootBounds)||void 0===o?void 0:o.height;r.target===t?e.invokeMethodAsync("OnSpacerBeforeVisible",r.intersectionRect.top-r.boundingClientRect.top,s,i):r.target===n&&n.offsetHeight>0&&e.invokeMethodAsync("OnSpacerAfterVisible",r.boundingClientRect.bottom-r.intersectionRect.bottom,s,i)}))}),{root:o,rootMargin:`${r}px`});s.observe(t),s.observe(n);const i=d(t),c=d(n),{observersByDotNetObjectId:l,id:u}=Ve(e);function d(e){const t={attributes:!0},n=new MutationObserver(((n,r)=>{h(e.parentElement)&&(r.disconnect(),e.style.display="table-row",r.observe(e,t)),s.unobserve(e),s.observe(e)}));return n.observe(e,t),n}function h(e){return null!==e&&(e instanceof HTMLTableElement&&""===e.style.display||"table"===e.style.display||e instanceof HTMLTableSectionElement&&""===e.style.display||"table-row-group"===e.style.display)}l[u]={intersectionObserver:s,mutationObserverBefore:i,mutationObserverAfter:c}},dispose:function(e){const{observersByDotNetObjectId:t,id:n}=Ve(e),r=t[n];r&&(r.intersectionObserver.disconnect(),r.mutationObserverBefore.disconnect(),r.mutationObserverAfter.disconnect(),e.dispose(),delete t[n])}},Ke=Symbol();function We(e){return e&&e!==document.body&&e!==document.documentElement?"visible"!==getComputedStyle(e).overflowY?e:We(e.parentElement):null}function Ve(e){var t;const n=e._callDispatcher,r=e._id;return null!==(t=n[Ke])&&void 0!==t||(n[Ke]={}),{observersByDotNetObjectId:n[Ke],id:r}}const Xe={getAndRemoveExistingTitle:function(){var e;const t=document.head?document.head.getElementsByTagName("title"):[];if(0===t.length)return null;let n=null;for(let r=t.length-1;r>=0;r--){const o=t[r],a=o.previousSibling;a instanceof Comment&&null!==$(a)||(null===n&&(n=o.textContent),null===(e=o.parentNode)||void 0===e||e.removeChild(o))}return n}},Ye={init:function(e,t){t._blazorInputFileNextFileId=0,t.addEventListener("click",(function(){t.value=""})),t.addEventListener("change",(function(){t._blazorFilesById={};const n=Array.prototype.map.call(t.files,(function(e){const n={id:++t._blazorInputFileNextFileId,lastModified:new Date(e.lastModified).toISOString(),name:e.name,size:e.size,contentType:e.type,readPromise:void 0,arrayBuffer:void 0,blob:e};return t._blazorFilesById[n.id]=n,n}));e.invokeMethodAsync("NotifyChange",n)}))},toImageFile:async function(e,t,n,r,o){const a=Ge(e,t),s=await new Promise((function(e){const t=new Image;t.onload=function(){URL.revokeObjectURL(t.src),e(t)},t.onerror=function(){t.onerror=null,URL.revokeObjectURL(t.src)},t.src=URL.createObjectURL(a.blob)})),i=await new Promise((function(e){var t;const a=Math.min(1,r/s.width),i=Math.min(1,o/s.height),c=Math.min(a,i),l=document.createElement("canvas");l.width=Math.round(s.width*c),l.height=Math.round(s.height*c),null===(t=l.getContext("2d"))||void 0===t||t.drawImage(s,0,0,l.width,l.height),l.toBlob(e,n)})),c={id:++e._blazorInputFileNextFileId,lastModified:a.lastModified,name:a.name,size:(null==i?void 0:i.size)||0,contentType:n,blob:i||a.blob};return e._blazorFilesById[c.id]=c,c},readFileData:async function(e,t){return Ge(e,t).blob}};function Ge(e,t){const n=e._blazorFilesById[t];if(!n)throw new Error(`There is no file with ID ${t}. The file list may have changed. See https://aka.ms/aspnet/blazor-input-file-multiple-selections.`);return n}const qe=new Set,Ze={enableNavigationPrompt:function(e){0===qe.size&&window.addEventListener("beforeunload",Qe),qe.add(e)},disableNavigationPrompt:function(e){qe.delete(e),0===qe.size&&window.removeEventListener("beforeunload",Qe)}};function Qe(e){e.preventDefault(),e.returnValue=!0}const et=new Map,tt={navigateTo:function(e,t,n=!1){Le(e,t instanceof Object?t:{forceLoad:t,replaceHistoryEntry:n})},registerCustomEventType:function(e,t){if(!t)throw new Error("The options parameter is required.");if(a.has(e))throw new Error(`The event '${e}' is already registered.`);if(t.browserEventName){const n=s.get(t.browserEventName);n?n.push(e):s.set(t.browserEventName,[e]),i.forEach((n=>n(e,t.browserEventName)))}a.set(e,t)},rootComponents:g,runtime:{},_internal:{navigationManager:Oe,domWrapper:$e,Virtualize:ze,PageTitle:Xe,InputFile:Ye,NavigationLock:Ze,getJSDataStreamChunk:async function(e,t,n){return e instanceof Blob?await async function(e,t,n){const r=e.slice(t,t+n),o=await r.arrayBuffer();return new Uint8Array(o)}(e,t,n):function(e,t,n){return new Uint8Array(e.buffer,e.byteOffset+t,n)}(e,t,n)},attachWebRendererInterop:function(t,n,r,o){if(S.has(t))throw new Error(`Interop methods are already registered for renderer ${t}`);S.set(t,n),Object.keys(r).length>0&&function(t,n,r){if(m)throw new Error("Dynamic root components have already been enabled.");m=t,v=n;for(const[t,o]of Object.entries(r)){const r=e.findJSFunction(t,0);for(const e of o)r(e,n[e])}}(A(t),r,o),D(),function(e){for(const t of I)t(e)}(t)}}};window.Blazor=tt;let nt=!1;const rt="function"==typeof TextDecoder?new TextDecoder("utf-8"):null,ot=rt?rt.decode.bind(rt):function(e){let t=0;const n=e.length,r=[],o=[];for(;t65535&&(o-=65536,r.push(o>>>10&1023|55296),o=56320|1023&o),r.push(o)}r.length>1024&&(o.push(String.fromCharCode.apply(null,r)),r.length=0)}return o.push(String.fromCharCode.apply(null,r)),o.join("")},at=Math.pow(2,32),st=Math.pow(2,21)-1;function it(e,t){return e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24}function ct(e,t){return e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24>>>0)}function lt(e,t){const n=ct(e,t+4);if(n>st)throw new Error(`Cannot read uint64 with high order part ${n}, because the result would exceed Number.MAX_SAFE_INTEGER.`);return n*at+ct(e,t)}class ut{constructor(e){this.batchData=e;const t=new pt(e);this.arrayRangeReader=new mt(e),this.arrayBuilderSegmentReader=new vt(e),this.diffReader=new dt(e),this.editReader=new ht(e,t),this.frameReader=new ft(e,t)}updatedComponents(){return it(this.batchData,this.batchData.length-20)}referenceFrames(){return it(this.batchData,this.batchData.length-16)}disposedComponentIds(){return it(this.batchData,this.batchData.length-12)}disposedEventHandlerIds(){return it(this.batchData,this.batchData.length-8)}updatedComponentsEntry(e,t){const n=e+4*t;return it(this.batchData,n)}referenceFramesEntry(e,t){return e+20*t}disposedComponentIdsEntry(e,t){const n=e+4*t;return it(this.batchData,n)}disposedEventHandlerIdsEntry(e,t){const n=e+8*t;return lt(this.batchData,n)}}class dt{constructor(e){this.batchDataUint8=e}componentId(e){return it(this.batchDataUint8,e)}edits(e){return e+4}editsEntry(e,t){return e+16*t}}class ht{constructor(e,t){this.batchDataUint8=e,this.stringReader=t}editType(e){return it(this.batchDataUint8,e)}siblingIndex(e){return it(this.batchDataUint8,e+4)}newTreeIndex(e){return it(this.batchDataUint8,e+8)}moveToSiblingIndex(e){return it(this.batchDataUint8,e+8)}removedAttributeName(e){const t=it(this.batchDataUint8,e+12);return this.stringReader.readString(t)}}class ft{constructor(e,t){this.batchDataUint8=e,this.stringReader=t}frameType(e){return it(this.batchDataUint8,e)}subtreeLength(e){return it(this.batchDataUint8,e+4)}elementReferenceCaptureId(e){const t=it(this.batchDataUint8,e+4);return this.stringReader.readString(t)}componentId(e){return it(this.batchDataUint8,e+8)}elementName(e){const t=it(this.batchDataUint8,e+8);return this.stringReader.readString(t)}textContent(e){const t=it(this.batchDataUint8,e+4);return this.stringReader.readString(t)}markupContent(e){const t=it(this.batchDataUint8,e+4);return this.stringReader.readString(t)}attributeName(e){const t=it(this.batchDataUint8,e+4);return this.stringReader.readString(t)}attributeValue(e){const t=it(this.batchDataUint8,e+8);return this.stringReader.readString(t)}attributeEventHandlerId(e){return lt(this.batchDataUint8,e+12)}}class pt{constructor(e){this.batchDataUint8=e,this.stringTableStartIndex=it(e,e.length-4)}readString(e){if(-1===e)return null;{const n=it(this.batchDataUint8,this.stringTableStartIndex+4*e),r=function(e,t){let n=0,r=0;for(let o=0;o<4;o++){const a=e[t+o];if(n|=(127&a)<async function(e,n){const r=function(e){const t=document.baseURI;return t.endsWith("/")?`${t}${e}`:`${t}/${e}`}(n),o=await import(r);if(void 0===o)return;const{beforeStart:a,afterStarted:s}=o;return s&&e.afterStartedCallbacks.push(s),a?a(...t):void 0}(this,e))))}async invokeAfterStartedCallbacks(e){await C,await Promise.all(this.afterStartedCallbacks.map((t=>t(e))))}}let Tt,_t=!1;async function Ot(){if(_t)throw new Error("Blazor has already started.");_t=!0,Tt=e.attachDispatcher({beginInvokeDotNetFromJS:wt,endInvokeJSFromDotNet:Et,sendByteArray:St});const t=await async function(){const e=await fetch("_framework/blazor.modules.json",{method:"GET",credentials:"include",cache:"no-cache"}),t=await e.json(),n=new Rt;return await n.importInitializersAsync(t,[]),n}();(function(){const e={AttachToDocument:(e,t)=>{!function(e,t,n){const r="::before";let o=!1;if(e.endsWith("::after"))e=e.slice(0,-7),o=!0;else if(e.endsWith(r))throw new Error(`The '${r}' selector is not supported.`);const a=function(e){const t=p.get(e);if(t)return p.delete(e),t}(e)||document.querySelector(e);if(!a)throw new Error(`Could not find any element matching selector '${e}'.`);!function(e,t,n,r){let o=fe[e];o||(o=new le(e),fe[e]=o),o.attachRootComponentToLogicalElement(n,t,r)}(n||0,B(a,!0),t,o)}(t,e,Nt.WebView)},RenderBatch:(e,t)=>{try{const n=kt(t);(function(e,t){const n=fe[e];if(!n)throw new Error(`There is no browser renderer with ID ${e}.`);const r=t.arrayRangeReader,o=t.updatedComponents(),a=r.values(o),s=r.count(o),i=t.referenceFrames(),c=r.values(i),l=t.diffReader;for(let e=0;e{gt=!0,console.error(`${e}\n${t}`),function(){const e=document.querySelector("#blazor-error-ui");e&&(e.style.display="block"),nt||(nt=!0,document.querySelectorAll("#blazor-error-ui .reload").forEach((e=>{e.onclick=function(e){location.reload(),e.preventDefault()}})),document.querySelectorAll("#blazor-error-ui .dismiss").forEach((e=>{e.onclick=function(e){const t=document.querySelector("#blazor-error-ui");t&&(t.style.display="none"),e.preventDefault()}})))}()},BeginInvokeJS:Tt.beginInvokeJSFromDotNet.bind(Tt),EndInvokeDotNet:Tt.endInvokeDotNetFromJS.bind(Tt),SendByteArrayToJS:At,Navigate:Oe.navigateTo,Refresh:Oe.refresh,SetHasLocationChangingListeners:Oe.setHasLocationChangingListeners,EndLocationChanging:Oe.endLocationChanging};window.external.receiveMessage((t=>{const n=function(e){if(gt||!e||!e.startsWith(bt))return null;const t=e.substring(bt.length),[n,...r]=JSON.parse(t);return{messageType:n,args:r}}(t);if(n){if(!Object.prototype.hasOwnProperty.call(e,n.messageType))throw new Error(`Unsupported IPC message type '${n.messageType}'`);e[n.messageType].apply(null,n.args)}}))})(),tt._internal.receiveWebViewDotNetDataStream=xt,Oe.enableNavigationInterception(),Oe.listenForNavigationEvents(It,Dt),Ct("AttachPage",Oe.getBaseURI(),Oe.getLocationHref()),await t.invokeAfterStartedCallbacks(tt)}function xt(e,t,n,r){!function(e,t,n,r,o){let a=et.get(t);if(!a){const n=new ReadableStream({start(e){et.set(t,e),a=e}});e.supplyDotNetStream(t,n)}o?(a.error(o),et.delete(t)):0===r?(a.close(),et.delete(t)):a.enqueue(n.length===r?n:n.subarray(0,r))}(Tt,e,t,n,r)}tt.start=Ot,window.DotNet=e,document&&document.currentScript&&"false"!==document.currentScript.getAttribute("autostart")&&Ot()})(); \ No newline at end of file +(()=>{"use strict";var e,t,n,r={d:(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};r.d({},{e:()=>_t}),function(e){const t=[],n="__jsObjectId",r="__dotNetObject",o="__byte[]",a="__dotNetStream",s="__jsStreamReferenceLength";let i,c;class l{constructor(e){this._jsObject=e,this._cachedFunctions=new Map}findFunction(e){const t=this._cachedFunctions.get(e);if(t)return t;let n,r=this._jsObject;if(e.split(".").forEach((t=>{if(!(t in r))throw new Error(`Could not find '${e}' ('${t}' was undefined).`);n=r,r=r[t]})),r instanceof Function)return r=r.bind(n),this._cachedFunctions.set(e,r),r;throw new Error(`The value '${e}' is not a function.`)}getWrappedObject(){return this._jsObject}}const u={0:new l(window)};u[0]._cachedFunctions.set("import",(e=>("string"==typeof e&&e.startsWith("./")&&(e=new URL(e.substr(2),document.baseURI).toString()),import(e))));let d,h=1;function f(e){t.push(e)}function p(e){if(e&&"object"==typeof e){u[h]=new l(e);const t={[n]:h};return h++,t}throw new Error(`Cannot create a JSObjectReference from the value '${e}'.`)}function m(e){let t=-1;if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e instanceof Blob)t=e.size;else{if(!(e.buffer instanceof ArrayBuffer))throw new Error("Supplied value is not a typed array or blob.");if(void 0===e.byteLength)throw new Error(`Cannot create a JSStreamReference from the value '${e}' as it doesn't have a byteLength.`);t=e.byteLength}const r={[s]:t};try{const t=p(e);r[n]=t[n]}catch(t){throw new Error(`Cannot create a JSStreamReference from the value '${e}'.`)}return r}function v(e,n){c=e;const r=n?JSON.parse(n,((e,n)=>t.reduce(((t,n)=>n(e,t)),n))):null;return c=void 0,r}function b(){if(void 0===i)throw new Error("No call dispatcher has been set.");if(null===i)throw new Error("There are multiple .NET runtimes present, so a default dispatcher could not be resolved. Use DotNetObject to invoke .NET instance methods.");return i}e.attachDispatcher=function(e){const t=new g(e);return void 0===i?i=t:i&&(i=null),t},e.attachReviver=f,e.invokeMethod=function(e,t,...n){return b().invokeDotNetStaticMethod(e,t,...n)},e.invokeMethodAsync=function(e,t,...n){return b().invokeDotNetStaticMethodAsync(e,t,...n)},e.createJSObjectReference=p,e.createJSStreamReference=m,e.disposeJSObjectReference=function(e){const t=e&&e[n];"number"==typeof t&&E(t)},function(e){e[e.Default=0]="Default",e[e.JSObjectReference=1]="JSObjectReference",e[e.JSStreamReference=2]="JSStreamReference",e[e.JSVoidResult=3]="JSVoidResult"}(d=e.JSCallResultType||(e.JSCallResultType={}));class g{constructor(e){this._dotNetCallDispatcher=e,this._byteArraysToBeRevived=new Map,this._pendingDotNetToJSStreams=new Map,this._pendingAsyncCalls={},this._nextAsyncCallId=1}getDotNetCallDispatcher(){return this._dotNetCallDispatcher}invokeJSFromDotNet(e,t,n,r){const o=v(this,t),a=C(w(e,r)(...o||[]),n);return null==a?null:A(this,a)}beginInvokeJSFromDotNet(e,t,n,r,o){const a=new Promise((e=>{const r=v(this,n);e(w(t,o)(...r||[]))}));e&&a.then((t=>A(this,[e,!0,C(t,r)]))).then((t=>this._dotNetCallDispatcher.endInvokeJSFromDotNet(e,!0,t)),(t=>this._dotNetCallDispatcher.endInvokeJSFromDotNet(e,!1,JSON.stringify([e,!1,y(t)]))))}endInvokeDotNetFromJS(e,t,n){const r=t?v(this,n):new Error(n);this.completePendingCall(parseInt(e,10),t,r)}invokeDotNetStaticMethod(e,t,...n){return this.invokeDotNetMethod(e,t,null,n)}invokeDotNetStaticMethodAsync(e,t,...n){return this.invokeDotNetMethodAsync(e,t,null,n)}invokeDotNetMethod(e,t,n,r){if(this._dotNetCallDispatcher.invokeDotNetFromJS){const o=A(this,r),a=this._dotNetCallDispatcher.invokeDotNetFromJS(e,t,n,o);return a?v(this,a):null}throw new Error("The current dispatcher does not support synchronous calls from JS to .NET. Use invokeDotNetMethodAsync instead.")}invokeDotNetMethodAsync(e,t,n,r){if(e&&n)throw new Error(`For instance method calls, assemblyName should be null. Received '${e}'.`);const o=this._nextAsyncCallId++,a=new Promise(((e,t)=>{this._pendingAsyncCalls[o]={resolve:e,reject:t}}));try{const a=A(this,r);this._dotNetCallDispatcher.beginInvokeDotNetFromJS(o,e,t,n,a)}catch(e){this.completePendingCall(o,!1,e)}return a}receiveByteArray(e,t){this._byteArraysToBeRevived.set(e,t)}processByteArray(e){const t=this._byteArraysToBeRevived.get(e);return t?(this._byteArraysToBeRevived.delete(e),t):null}supplyDotNetStream(e,t){if(this._pendingDotNetToJSStreams.has(e)){const n=this._pendingDotNetToJSStreams.get(e);this._pendingDotNetToJSStreams.delete(e),n.resolve(t)}else{const n=new D;n.resolve(t),this._pendingDotNetToJSStreams.set(e,n)}}getDotNetStreamPromise(e){let t;if(this._pendingDotNetToJSStreams.has(e))t=this._pendingDotNetToJSStreams.get(e).streamPromise,this._pendingDotNetToJSStreams.delete(e);else{const n=new D;this._pendingDotNetToJSStreams.set(e,n),t=n.streamPromise}return t}completePendingCall(e,t,n){if(!this._pendingAsyncCalls.hasOwnProperty(e))throw new Error(`There is no pending async call with ID ${e}.`);const r=this._pendingAsyncCalls[e];delete this._pendingAsyncCalls[e],t?r.resolve(n):r.reject(n)}}function y(e){return e instanceof Error?`${e.message}\n${e.stack}`:e?e.toString():"null"}function w(e,t){const n=u[t];if(n)return n.findFunction(e);throw new Error(`JS object instance with ID ${t} does not exist (has it been disposed?).`)}function E(e){delete u[e]}e.findJSFunction=w,e.disposeJSObjectReferenceById=E;class S{constructor(e,t){this._id=e,this._callDispatcher=t}invokeMethod(e,...t){return this._callDispatcher.invokeDotNetMethod(null,e,this._id,t)}invokeMethodAsync(e,...t){return this._callDispatcher.invokeDotNetMethodAsync(null,e,this._id,t)}dispose(){this._callDispatcher.invokeDotNetMethodAsync(null,"__Dispose",this._id,null).catch((e=>console.error(e)))}serializeAsArg(){return{[r]:this._id}}}e.DotNetObject=S,f((function(e,t){if(t&&"object"==typeof t){if(t.hasOwnProperty(r))return new S(t[r],c);if(t.hasOwnProperty(n)){const e=t[n],r=u[e];if(r)return r.getWrappedObject();throw new Error(`JS object instance with Id '${e}' does not exist. It may have been disposed.`)}if(t.hasOwnProperty(o)){const e=t[o],n=c.processByteArray(e);if(void 0===n)throw new Error(`Byte array index '${e}' does not exist.`);return n}if(t.hasOwnProperty(a)){const e=t[a],n=c.getDotNetStreamPromise(e);return new I(n)}}return t}));class I{constructor(e){this._streamPromise=e}stream(){return this._streamPromise}async arrayBuffer(){return new Response(await this.stream()).arrayBuffer()}}class D{constructor(){this.streamPromise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}}function C(e,t){switch(t){case d.Default:return e;case d.JSObjectReference:return p(e);case d.JSStreamReference:return m(e);case d.JSVoidResult:return null;default:throw new Error(`Invalid JS call result type '${t}'.`)}}let N=0;function A(e,t){N=0,c=e;const n=JSON.stringify(t,k);return c=void 0,n}function k(e,t){if(t instanceof S)return t.serializeAsArg();if(t instanceof Uint8Array){c.getDotNetCallDispatcher().sendByteArray(N,t);const e={[o]:N};return N++,e}return t}}(e||(e={})),function(e){e[e.prependFrame=1]="prependFrame",e[e.removeFrame=2]="removeFrame",e[e.setAttribute=3]="setAttribute",e[e.removeAttribute=4]="removeAttribute",e[e.updateText=5]="updateText",e[e.stepIn=6]="stepIn",e[e.stepOut=7]="stepOut",e[e.updateMarkup=8]="updateMarkup",e[e.permutationListEntry=9]="permutationListEntry",e[e.permutationListEnd=10]="permutationListEnd"}(t||(t={})),function(e){e[e.element=1]="element",e[e.text=2]="text",e[e.attribute=3]="attribute",e[e.component=4]="component",e[e.region=5]="region",e[e.elementReferenceCapture=6]="elementReferenceCapture",e[e.markup=8]="markup",e[e.namedEvent=10]="namedEvent"}(n||(n={}));class o{constructor(e,t){this.componentId=e,this.fieldValue=t}static fromEvent(e,t){const n=t.target;if(n instanceof Element){const t=function(e){return e instanceof HTMLInputElement?e.type&&"checkbox"===e.type.toLowerCase()?{value:e.checked}:{value:e.value}:e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement?{value:e.value}:null}(n);if(t)return new o(e,t.value)}return null}}const a=new Map,s=new Map,i=[];function c(e){return a.get(e)}function l(e){const t=a.get(e);return(null==t?void 0:t.browserEventName)||e}function u(e,t){e.forEach((e=>a.set(e,t)))}function d(e){const t=[];for(let n=0;ne.selected)).map((e=>e.value))}}{const e=function(e){return!!e&&"INPUT"===e.tagName&&"checkbox"===e.getAttribute("type")}(t);return{value:e?!!t.checked:t.value}}}}),u(["copy","cut","paste"],{createEventArgs:e=>({type:e.type})}),u(["drag","dragend","dragenter","dragleave","dragover","dragstart","drop"],{createEventArgs:e=>{return{...h(t=e),dataTransfer:t.dataTransfer?{dropEffect:t.dataTransfer.dropEffect,effectAllowed:t.dataTransfer.effectAllowed,files:Array.from(t.dataTransfer.files).map((e=>e.name)),items:Array.from(t.dataTransfer.items).map((e=>({kind:e.kind,type:e.type}))),types:t.dataTransfer.types}:null};var t}}),u(["focus","blur","focusin","focusout"],{createEventArgs:e=>({type:e.type})}),u(["keydown","keyup","keypress"],{createEventArgs:e=>{return{key:(t=e).key,code:t.code,location:t.location,repeat:t.repeat,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,type:t.type};var t}}),u(["contextmenu","click","mouseover","mouseout","mousemove","mousedown","mouseup","mouseleave","mouseenter","dblclick"],{createEventArgs:e=>h(e)}),u(["error"],{createEventArgs:e=>{return{message:(t=e).message,filename:t.filename,lineno:t.lineno,colno:t.colno,type:t.type};var t}}),u(["loadstart","timeout","abort","load","loadend","progress"],{createEventArgs:e=>{return{lengthComputable:(t=e).lengthComputable,loaded:t.loaded,total:t.total,type:t.type};var t}}),u(["touchcancel","touchend","touchmove","touchenter","touchleave","touchstart"],{createEventArgs:e=>{return{detail:(t=e).detail,touches:d(t.touches),targetTouches:d(t.targetTouches),changedTouches:d(t.changedTouches),ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,type:t.type};var t}}),u(["gotpointercapture","lostpointercapture","pointercancel","pointerdown","pointerenter","pointerleave","pointermove","pointerout","pointerover","pointerup"],{createEventArgs:e=>{return{...h(t=e),pointerId:t.pointerId,width:t.width,height:t.height,pressure:t.pressure,tiltX:t.tiltX,tiltY:t.tiltY,pointerType:t.pointerType,isPrimary:t.isPrimary};var t}}),u(["wheel","mousewheel"],{createEventArgs:e=>{return{...h(t=e),deltaX:t.deltaX,deltaY:t.deltaY,deltaZ:t.deltaZ,deltaMode:t.deltaMode};var t}}),u(["toggle"],{createEventArgs:()=>({})});const f=["date","datetime-local","month","time","week"],p=new Map;let m,v,b=0;const g={async add(e,t,n){if(!n)throw new Error("initialParameters must be an object, even if empty.");const r="__bl-dynamic-root:"+(++b).toString();p.set(r,e);const o=await E().invokeMethodAsync("AddRootComponent",t,r),a=new w(o,v[t]);return await a.setParameters(n),a}};class y{invoke(e){return this._callback(e)}setCallback(t){this._selfJSObjectReference||(this._selfJSObjectReference=e.createJSObjectReference(this)),this._callback=t}getJSObjectReference(){return this._selfJSObjectReference}dispose(){this._selfJSObjectReference&&e.disposeJSObjectReference(this._selfJSObjectReference)}}class w{constructor(e,t){this._jsEventCallbackWrappers=new Map,this._componentId=e;for(const e of t)"eventcallback"===e.type&&this._jsEventCallbackWrappers.set(e.name.toLowerCase(),new y)}setParameters(e){const t={},n=Object.entries(e||{}),r=n.length;for(const[e,r]of n){const n=this._jsEventCallbackWrappers.get(e.toLowerCase());n&&r?(n.setCallback(r),t[e]=n.getJSObjectReference()):t[e]=r}return E().invokeMethodAsync("SetRootComponentParameters",this._componentId,r,t)}async dispose(){if(null!==this._componentId){await E().invokeMethodAsync("RemoveRootComponent",this._componentId),this._componentId=null;for(const e of this._jsEventCallbackWrappers.values())e.dispose()}}}function E(){if(!m)throw new Error("Dynamic root components have not been enabled in this application.");return m}const S=new Map,I=[];let D;const C=new Promise((e=>{D=e}));function N(e,t,n){return k(e,t.eventHandlerId,(()=>A(e).invokeMethodAsync("DispatchEventAsync",t,n)))}function A(e){const t=S.get(e);if(!t)throw new Error(`No interop methods are registered for renderer ${e}`);return t}let k=(e,t,n)=>n();const R=F(["abort","blur","canplay","canplaythrough","change","cuechange","durationchange","emptied","ended","error","focus","load","loadeddata","loadedmetadata","loadend","loadstart","mouseenter","mouseleave","pointerenter","pointerleave","pause","play","playing","progress","ratechange","reset","scroll","seeked","seeking","stalled","submit","suspend","timeupdate","toggle","unload","volumechange","waiting","DOMNodeInsertedIntoDocument","DOMNodeRemovedFromDocument"]),T={submit:!0},_=F(["click","dblclick","mousedown","mousemove","mouseup"]);class O{constructor(e){this.browserRendererId=e,this.afterClickCallbacks=[];const t=++O.nextEventDelegatorId;this.eventsCollectionKey=`_blazorEvents_${t}`,this.eventInfoStore=new L(this.onGlobalEvent.bind(this))}setListener(e,t,n,r){const o=this.getEventHandlerInfosForElement(e,!0),a=o.getHandler(t);if(a)this.eventInfoStore.update(a.eventHandlerId,n);else{const a={element:e,eventName:t,eventHandlerId:n,renderingComponentId:r};this.eventInfoStore.add(a),o.setHandler(t,a)}}getHandler(e){return this.eventInfoStore.get(e)}removeListener(e){const t=this.eventInfoStore.remove(e);if(t){const e=t.element,n=this.getEventHandlerInfosForElement(e,!1);n&&n.removeHandler(t.eventName)}}notifyAfterClick(e){this.afterClickCallbacks.push(e),this.eventInfoStore.addGlobalListener("click")}setStopPropagation(e,t,n){this.getEventHandlerInfosForElement(e,!0).stopPropagation(t,n)}setPreventDefault(e,t,n){this.getEventHandlerInfosForElement(e,!0).preventDefault(t,n)}onGlobalEvent(e){if(!(e.target instanceof Element))return;this.dispatchGlobalEventToAllElements(e.type,e);const t=(n=e.type,s.get(n));var n;t&&t.forEach((t=>this.dispatchGlobalEventToAllElements(t,e))),"click"===e.type&&this.afterClickCallbacks.forEach((t=>t(e)))}dispatchGlobalEventToAllElements(e,t){const n=t.composedPath();let r=n.shift(),a=null,s=!1;const i=Object.prototype.hasOwnProperty.call(R,e);let l=!1;for(;r;){const h=r,f=this.getEventHandlerInfosForElement(h,!1);if(f){const n=f.getHandler(e);if(n&&(u=h,d=t.type,!((u instanceof HTMLButtonElement||u instanceof HTMLInputElement||u instanceof HTMLTextAreaElement||u instanceof HTMLSelectElement)&&Object.prototype.hasOwnProperty.call(_,d)&&u.disabled))){if(!s){const n=c(e);a=(null==n?void 0:n.createEventArgs)?n.createEventArgs(t):{},s=!0}Object.prototype.hasOwnProperty.call(T,t.type)&&t.preventDefault(),N(this.browserRendererId,{eventHandlerId:n.eventHandlerId,eventName:e,eventFieldInfo:o.fromEvent(n.renderingComponentId,t)},a)}f.stopPropagation(e)&&(l=!0),f.preventDefault(e)&&t.preventDefault()}r=i||l?void 0:n.shift()}var u,d}getEventHandlerInfosForElement(e,t){return Object.prototype.hasOwnProperty.call(e,this.eventsCollectionKey)?e[this.eventsCollectionKey]:t?e[this.eventsCollectionKey]=new x:null}}O.nextEventDelegatorId=0;class L{constructor(e){this.globalListener=e,this.infosByEventHandlerId={},this.countByEventName={},i.push(this.handleEventNameAliasAdded.bind(this))}add(e){if(this.infosByEventHandlerId[e.eventHandlerId])throw new Error(`Event ${e.eventHandlerId} is already tracked`);this.infosByEventHandlerId[e.eventHandlerId]=e,this.addGlobalListener(e.eventName)}get(e){return this.infosByEventHandlerId[e]}addGlobalListener(e){if(e=l(e),Object.prototype.hasOwnProperty.call(this.countByEventName,e))this.countByEventName[e]++;else{this.countByEventName[e]=1;const t=Object.prototype.hasOwnProperty.call(R,e);document.addEventListener(e,this.globalListener,t)}}update(e,t){if(Object.prototype.hasOwnProperty.call(this.infosByEventHandlerId,t))throw new Error(`Event ${t} is already tracked`);const n=this.infosByEventHandlerId[e];delete this.infosByEventHandlerId[e],n.eventHandlerId=t,this.infosByEventHandlerId[t]=n}remove(e){const t=this.infosByEventHandlerId[e];if(t){delete this.infosByEventHandlerId[e];const n=l(t.eventName);0==--this.countByEventName[n]&&(delete this.countByEventName[n],document.removeEventListener(n,this.globalListener))}return t}handleEventNameAliasAdded(e,t){if(Object.prototype.hasOwnProperty.call(this.countByEventName,e)){const n=this.countByEventName[e];delete this.countByEventName[e],document.removeEventListener(e,this.globalListener),this.addGlobalListener(t),this.countByEventName[t]+=n-1}}}class x{constructor(){this.handlers={},this.preventDefaultFlags=null,this.stopPropagationFlags=null}getHandler(e){return Object.prototype.hasOwnProperty.call(this.handlers,e)?this.handlers[e]:null}setHandler(e,t){this.handlers[e]=t}removeHandler(e){delete this.handlers[e]}preventDefault(e,t){return void 0!==t&&(this.preventDefaultFlags=this.preventDefaultFlags||{},this.preventDefaultFlags[e]=t),!!this.preventDefaultFlags&&this.preventDefaultFlags[e]}stopPropagation(e,t){return void 0!==t&&(this.stopPropagationFlags=this.stopPropagationFlags||{},this.stopPropagationFlags[e]=t),!!this.stopPropagationFlags&&this.stopPropagationFlags[e]}}function F(e){const t={};return e.forEach((e=>{t[e]=!0})),t}const B=Symbol(),M=Symbol();function P(e,t){if(B in e)return e;const n=[];if(e.childNodes.length>0){if(!t)throw new Error("New logical elements must start empty, or allowExistingContents must be true");e.childNodes.forEach((t=>{const r=P(t,!0);r[M]=e,n.push(r)}))}return e[B]=n,e}function j(e){const t=W(e);for(;t.length;)U(e,0)}function H(e,t){const n=document.createComment("!");return J(n,e,t),n}function J(e,t,n){const r=e;let o=e;if(B in e){const t=q(r);if(t!==e){const n=new Range;n.setStartBefore(e),n.setEndAfter(t),o=n.extractContents()}}const a=$(r);if(a){const e=W(a),t=Array.prototype.indexOf.call(e,r);e.splice(t,1),delete r[M]}const s=W(t);if(n0;)U(n,0)}const r=n;r.parentNode.removeChild(r)}function $(e){return e[M]||null}function z(e,t){return W(e)[t]}function K(e){const t=Y(e);return"http://www.w3.org/2000/svg"===t.namespaceURI&&"foreignObject"!==t.tagName}function W(e){return e[B]}function V(e){const t=W($(e));return t[Array.prototype.indexOf.call(t,e)+1]||null}function X(e,t){const n=W(e);t.forEach((e=>{e.moveRangeStart=n[e.fromSiblingIndex],e.moveRangeEnd=q(e.moveRangeStart)})),t.forEach((t=>{const r=document.createComment("marker");t.moveToBeforeMarker=r;const o=n[t.toSiblingIndex+1];o?o.parentNode.insertBefore(r,o):G(r,e)})),t.forEach((e=>{const t=e.moveToBeforeMarker,n=t.parentNode,r=e.moveRangeStart,o=e.moveRangeEnd;let a=r;for(;a;){const e=a.nextSibling;if(n.insertBefore(a,t),a===o)break;a=e}n.removeChild(t)})),t.forEach((e=>{n[e.toSiblingIndex]=e.moveRangeStart}))}function Y(e){if(e instanceof Element||e instanceof DocumentFragment)return e;if(e instanceof Comment)return e.parentNode;throw new Error("Not a valid logical element")}function G(e,t){if(t instanceof Element||t instanceof DocumentFragment)t.appendChild(e);else{if(!(t instanceof Comment))throw new Error(`Cannot append node because the parent is not a valid logical element. Parent: ${t}`);{const n=V(t);n?n.parentNode.insertBefore(e,n):G(e,$(t))}}}function q(e){if(e instanceof Element||e instanceof DocumentFragment)return e;const t=V(e);if(t)return t.previousSibling;{const t=$(e);return t instanceof Element||t instanceof DocumentFragment?t.lastChild:q(t)}}function Z(e){return`_bl_${e}`}Symbol();const Q="__internalId";e.attachReviver(((e,t)=>t&&"object"==typeof t&&Object.prototype.hasOwnProperty.call(t,Q)&&"string"==typeof t[Q]?function(e){const t=`[${Z(e)}]`;return document.querySelector(t)}(t[Q]):t));const ee="_blazorDeferredValue";function te(e){return"select-multiple"===e.type}function ne(e,t){e.value=t||""}function re(e,t){e instanceof HTMLSelectElement?te(e)?function(e,t){t||(t=[]);for(let n=0;n{Ie()&&function(e,t){if(0!==e.button||function(e){return e.ctrlKey||e.shiftKey||e.altKey||e.metaKey}(e))return;if(e.defaultPrevented)return;const n=function(e){const t=!window._blazorDisableComposedPath&&e.composedPath&&e.composedPath();if(t){for(let e=0;edocument.baseURI,getLocationHref:()=>location.href,scrollToElement:Le};function Le(e){const t=document.getElementById(e);return!!t&&(t.scrollIntoView(),!0)}function xe(e,t,n=!1){const r=Ee(e);!t.forceLoad&&ge(r)?Ue()?Fe(r,!1,t.replaceHistoryEntry,t.historyEntryState,n):we(r,t.replaceHistoryEntry):function(e,t){if(location.href===e){const t=e+"?";history.replaceState(null,"",t),location.replace(e)}else t?location.replace(e):location.href=e}(e,t.replaceHistoryEntry)}async function Fe(e,t,n,r=void 0,o=!1){if(Pe(),function(e){const t=e.indexOf("#");return t>-1&&location.href.replace(location.hash,"")===e.substring(0,t)}(e))!function(e,t,n){Be(e,t,n);const r=e.indexOf("#");r!==e.length-1&&Le(e.substring(r+1))}(e,n,r);else{if(!o&&Ce&&!await je(e,r,t))return;ve=!0,Be(e,n,r),await He(t)}}function Be(e,t,n=void 0){t?history.replaceState({userState:n,_index:Ne},"",e):(Ne++,history.pushState({userState:n,_index:Ne},"",e))}function Me(e){return new Promise((t=>{const n=Te;Te=()=>{Te=n,t()},history.go(e)}))}function Pe(){_e&&(_e(!1),_e=null)}function je(e,t,n){return new Promise((r=>{Pe(),Re?(Ae++,_e=r,Re(Ae,e,t,n)):r(!1)}))}async function He(e){var t;ke&&await ke(location.href,null===(t=history.state)||void 0===t?void 0:t.userState,e)}async function Je(e){var t,n;Te&&Ue()&&await Te(e),Ne=null!==(n=null===(t=history.state)||void 0===t?void 0:t._index)&&void 0!==n?n:0}function Ue(){return Ie()||!ye()}const $e={focus:function(e,t){if(e instanceof HTMLElement)e.focus({preventScroll:t});else{if(!(e instanceof SVGElement))throw new Error("Unable to focus an invalid element.");if(!e.hasAttribute("tabindex"))throw new Error("Unable to focus an SVG element that does not have a tabindex.");e.focus({preventScroll:t})}},focusBySelector:function(e,t){const n=document.querySelector(e);n&&(n.hasAttribute("tabindex")||(n.tabIndex=-1),n.focus({preventScroll:!0}))}},ze={init:function(e,t,n,r=50){const o=We(t);(o||document.documentElement).style.overflowAnchor="none";const a=document.createRange();h(n.parentElement)&&(t.style.display="table-row",n.style.display="table-row");const s=new IntersectionObserver((function(r){r.forEach((r=>{var o;if(!r.isIntersecting)return;a.setStartAfter(t),a.setEndBefore(n);const s=a.getBoundingClientRect().height,i=null===(o=r.rootBounds)||void 0===o?void 0:o.height;r.target===t?e.invokeMethodAsync("OnSpacerBeforeVisible",r.intersectionRect.top-r.boundingClientRect.top,s,i):r.target===n&&n.offsetHeight>0&&e.invokeMethodAsync("OnSpacerAfterVisible",r.boundingClientRect.bottom-r.intersectionRect.bottom,s,i)}))}),{root:o,rootMargin:`${r}px`});s.observe(t),s.observe(n);const i=d(t),c=d(n),{observersByDotNetObjectId:l,id:u}=Ve(e);function d(e){const t={attributes:!0},n=new MutationObserver(((n,r)=>{h(e.parentElement)&&(r.disconnect(),e.style.display="table-row",r.observe(e,t)),s.unobserve(e),s.observe(e)}));return n.observe(e,t),n}function h(e){return null!==e&&(e instanceof HTMLTableElement&&""===e.style.display||"table"===e.style.display||e instanceof HTMLTableSectionElement&&""===e.style.display||"table-row-group"===e.style.display)}l[u]={intersectionObserver:s,mutationObserverBefore:i,mutationObserverAfter:c}},dispose:function(e){const{observersByDotNetObjectId:t,id:n}=Ve(e),r=t[n];r&&(r.intersectionObserver.disconnect(),r.mutationObserverBefore.disconnect(),r.mutationObserverAfter.disconnect(),e.dispose(),delete t[n])}},Ke=Symbol();function We(e){return e&&e!==document.body&&e!==document.documentElement?"visible"!==getComputedStyle(e).overflowY?e:We(e.parentElement):null}function Ve(e){var t;const n=e._callDispatcher,r=e._id;return null!==(t=n[Ke])&&void 0!==t||(n[Ke]={}),{observersByDotNetObjectId:n[Ke],id:r}}const Xe={getAndRemoveExistingTitle:function(){var e;const t=document.head?document.head.getElementsByTagName("title"):[];if(0===t.length)return null;let n=null;for(let r=t.length-1;r>=0;r--){const o=t[r],a=o.previousSibling;a instanceof Comment&&null!==$(a)||(null===n&&(n=o.textContent),null===(e=o.parentNode)||void 0===e||e.removeChild(o))}return n}},Ye={init:function(e,t){t._blazorInputFileNextFileId=0,t.addEventListener("click",(function(){t.value=""})),t.addEventListener("change",(function(){t._blazorFilesById={};const n=Array.prototype.map.call(t.files,(function(e){const n={id:++t._blazorInputFileNextFileId,lastModified:new Date(e.lastModified).toISOString(),name:e.name,size:e.size,contentType:e.type,readPromise:void 0,arrayBuffer:void 0,blob:e};return t._blazorFilesById[n.id]=n,n}));e.invokeMethodAsync("NotifyChange",n)}))},toImageFile:async function(e,t,n,r,o){const a=Ge(e,t),s=await new Promise((function(e){const t=new Image;t.onload=function(){URL.revokeObjectURL(t.src),e(t)},t.onerror=function(){t.onerror=null,URL.revokeObjectURL(t.src)},t.src=URL.createObjectURL(a.blob)})),i=await new Promise((function(e){var t;const a=Math.min(1,r/s.width),i=Math.min(1,o/s.height),c=Math.min(a,i),l=document.createElement("canvas");l.width=Math.round(s.width*c),l.height=Math.round(s.height*c),null===(t=l.getContext("2d"))||void 0===t||t.drawImage(s,0,0,l.width,l.height),l.toBlob(e,n)})),c={id:++e._blazorInputFileNextFileId,lastModified:a.lastModified,name:a.name,size:(null==i?void 0:i.size)||0,contentType:n,blob:i||a.blob};return e._blazorFilesById[c.id]=c,c},readFileData:async function(e,t){return Ge(e,t).blob}};function Ge(e,t){const n=e._blazorFilesById[t];if(!n)throw new Error(`There is no file with ID ${t}. The file list may have changed. See https://aka.ms/aspnet/blazor-input-file-multiple-selections.`);return n}const qe=new Set,Ze={enableNavigationPrompt:function(e){0===qe.size&&window.addEventListener("beforeunload",Qe),qe.add(e)},disableNavigationPrompt:function(e){qe.delete(e),0===qe.size&&window.removeEventListener("beforeunload",Qe)}};function Qe(e){e.preventDefault(),e.returnValue=!0}const et=new Map,tt=new class{constructor(){this._eventListeners=new Map,this._blazor=null}attachBlazorInstance(e){this._blazor=e}addEventListener(e,t){let n=this._eventListeners.get(e);n||(n=new Set,this._eventListeners.set(e,n)),n.add(t)}removeEventListener(e,t){const n=this._eventListeners.get(e);n&&n.delete(t)}dispatchEvent(e,t){if(null===this._blazor)throw new Error("Blazor events cannot be dispatched until a Blazor instance gets attached");const n=this._eventListeners.get(e);if(!n)return;const r={...t,blazor:this._blazor,type:e};for(const e of n)e(r)}},nt={navigateTo:function(e,t,n=!1){xe(e,t instanceof Object?t:{forceLoad:t,replaceHistoryEntry:n})},registerCustomEventType:function(e,t){if(!t)throw new Error("The options parameter is required.");if(a.has(e))throw new Error(`The event '${e}' is already registered.`);if(t.browserEventName){const n=s.get(t.browserEventName);n?n.push(e):s.set(t.browserEventName,[e]),i.forEach((n=>n(e,t.browserEventName)))}a.set(e,t)},addEventListener:tt.addEventListener.bind(tt),removeEventListener:tt.removeEventListener.bind(tt),rootComponents:g,runtime:{},_internal:{navigationManager:Oe,domWrapper:$e,Virtualize:ze,PageTitle:Xe,InputFile:Ye,NavigationLock:Ze,getJSDataStreamChunk:async function(e,t,n){return e instanceof Blob?await async function(e,t,n){const r=e.slice(t,t+n),o=await r.arrayBuffer();return new Uint8Array(o)}(e,t,n):function(e,t,n){return new Uint8Array(e.buffer,e.byteOffset+t,n)}(e,t,n)},attachWebRendererInterop:function(t,n,r,o){if(S.has(t))throw new Error(`Interop methods are already registered for renderer ${t}`);S.set(t,n),Object.keys(r).length>0&&function(t,n,r){if(m)throw new Error("Dynamic root components have already been enabled.");m=t,v=n;for(const[t,o]of Object.entries(r)){const r=e.findJSFunction(t,0);for(const e of o)r(e,n[e])}}(A(t),r,o),D(),function(e){for(const t of I)t(e)}(t)},dispatchEvent:tt.dispatchEvent.bind(tt)}};tt.attachBlazorInstance(nt),window.Blazor=nt;let rt=!1;const ot="function"==typeof TextDecoder?new TextDecoder("utf-8"):null,at=ot?ot.decode.bind(ot):function(e){let t=0;const n=e.length,r=[],o=[];for(;t65535&&(o-=65536,r.push(o>>>10&1023|55296),o=56320|1023&o),r.push(o)}r.length>1024&&(o.push(String.fromCharCode.apply(null,r)),r.length=0)}return o.push(String.fromCharCode.apply(null,r)),o.join("")},st=Math.pow(2,32),it=Math.pow(2,21)-1;function ct(e,t){return e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24}function lt(e,t){return e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24>>>0)}function ut(e,t){const n=lt(e,t+4);if(n>it)throw new Error(`Cannot read uint64 with high order part ${n}, because the result would exceed Number.MAX_SAFE_INTEGER.`);return n*st+lt(e,t)}class dt{constructor(e){this.batchData=e;const t=new mt(e);this.arrayRangeReader=new vt(e),this.arrayBuilderSegmentReader=new bt(e),this.diffReader=new ht(e),this.editReader=new ft(e,t),this.frameReader=new pt(e,t)}updatedComponents(){return ct(this.batchData,this.batchData.length-20)}referenceFrames(){return ct(this.batchData,this.batchData.length-16)}disposedComponentIds(){return ct(this.batchData,this.batchData.length-12)}disposedEventHandlerIds(){return ct(this.batchData,this.batchData.length-8)}updatedComponentsEntry(e,t){const n=e+4*t;return ct(this.batchData,n)}referenceFramesEntry(e,t){return e+20*t}disposedComponentIdsEntry(e,t){const n=e+4*t;return ct(this.batchData,n)}disposedEventHandlerIdsEntry(e,t){const n=e+8*t;return ut(this.batchData,n)}}class ht{constructor(e){this.batchDataUint8=e}componentId(e){return ct(this.batchDataUint8,e)}edits(e){return e+4}editsEntry(e,t){return e+16*t}}class ft{constructor(e,t){this.batchDataUint8=e,this.stringReader=t}editType(e){return ct(this.batchDataUint8,e)}siblingIndex(e){return ct(this.batchDataUint8,e+4)}newTreeIndex(e){return ct(this.batchDataUint8,e+8)}moveToSiblingIndex(e){return ct(this.batchDataUint8,e+8)}removedAttributeName(e){const t=ct(this.batchDataUint8,e+12);return this.stringReader.readString(t)}}class pt{constructor(e,t){this.batchDataUint8=e,this.stringReader=t}frameType(e){return ct(this.batchDataUint8,e)}subtreeLength(e){return ct(this.batchDataUint8,e+4)}elementReferenceCaptureId(e){const t=ct(this.batchDataUint8,e+4);return this.stringReader.readString(t)}componentId(e){return ct(this.batchDataUint8,e+8)}elementName(e){const t=ct(this.batchDataUint8,e+8);return this.stringReader.readString(t)}textContent(e){const t=ct(this.batchDataUint8,e+4);return this.stringReader.readString(t)}markupContent(e){const t=ct(this.batchDataUint8,e+4);return this.stringReader.readString(t)}attributeName(e){const t=ct(this.batchDataUint8,e+4);return this.stringReader.readString(t)}attributeValue(e){const t=ct(this.batchDataUint8,e+8);return this.stringReader.readString(t)}attributeEventHandlerId(e){return ut(this.batchDataUint8,e+12)}}class mt{constructor(e){this.batchDataUint8=e,this.stringTableStartIndex=ct(e,e.length-4)}readString(e){if(-1===e)return null;{const n=ct(this.batchDataUint8,this.stringTableStartIndex+4*e),r=function(e,t){let n=0,r=0;for(let o=0;o<4;o++){const a=e[t+o];if(n|=(127&a)<async function(e,n){const r=function(e){const t=document.baseURI;return t.endsWith("/")?`${t}${e}`:`${t}/${e}`}(n),o=await import(r);if(void 0===o)return;const{beforeStart:a,afterStarted:s}=o;return s&&e.afterStartedCallbacks.push(s),a?a(...t):void 0}(this,e))))}async invokeAfterStartedCallbacks(e){await C,await Promise.all(this.afterStartedCallbacks.map((t=>t(e))))}}let _t,Ot=!1;async function Lt(){if(Ot)throw new Error("Blazor has already started.");Ot=!0,_t=e.attachDispatcher({beginInvokeDotNetFromJS:Et,endInvokeJSFromDotNet:St,sendByteArray:It});const t=await async function(){const e=await fetch("_framework/blazor.modules.json",{method:"GET",credentials:"include",cache:"no-cache"}),t=await e.json(),n=new Tt;return await n.importInitializersAsync(t,[]),n}();(function(){const e={AttachToDocument:(e,t)=>{!function(e,t,n){const r="::before";let o=!1;if(e.endsWith("::after"))e=e.slice(0,-7),o=!0;else if(e.endsWith(r))throw new Error(`The '${r}' selector is not supported.`);const a=function(e){const t=p.get(e);if(t)return p.delete(e),t}(e)||document.querySelector(e);if(!a)throw new Error(`Could not find any element matching selector '${e}'.`);!function(e,t,n,r){let o=fe[e];o||(o=new le(e),fe[e]=o),o.attachRootComponentToLogicalElement(n,t,r)}(n||0,P(a,!0),t,o)}(t,e,At.WebView)},RenderBatch:(e,t)=>{try{const n=Rt(t);(function(e,t){const n=fe[e];if(!n)throw new Error(`There is no browser renderer with ID ${e}.`);const r=t.arrayRangeReader,o=t.updatedComponents(),a=r.values(o),s=r.count(o),i=t.referenceFrames(),c=r.values(i),l=t.diffReader;for(let e=0;e{yt=!0,console.error(`${e}\n${t}`),function(){const e=document.querySelector("#blazor-error-ui");e&&(e.style.display="block"),rt||(rt=!0,document.querySelectorAll("#blazor-error-ui .reload").forEach((e=>{e.onclick=function(e){location.reload(),e.preventDefault()}})),document.querySelectorAll("#blazor-error-ui .dismiss").forEach((e=>{e.onclick=function(e){const t=document.querySelector("#blazor-error-ui");t&&(t.style.display="none"),e.preventDefault()}})))}()},BeginInvokeJS:_t.beginInvokeJSFromDotNet.bind(_t),EndInvokeDotNet:_t.endInvokeDotNetFromJS.bind(_t),SendByteArrayToJS:kt,Navigate:Oe.navigateTo,Refresh:Oe.refresh,SetHasLocationChangingListeners:Oe.setHasLocationChangingListeners,EndLocationChanging:Oe.endLocationChanging};window.external.receiveMessage((t=>{const n=function(e){if(yt||!e||!e.startsWith(gt))return null;const t=e.substring(gt.length),[n,...r]=JSON.parse(t);return{messageType:n,args:r}}(t);if(n){if(!Object.prototype.hasOwnProperty.call(e,n.messageType))throw new Error(`Unsupported IPC message type '${n.messageType}'`);e[n.messageType].apply(null,n.args)}}))})(),nt._internal.receiveWebViewDotNetDataStream=xt,Oe.enableNavigationInterception(),Oe.listenForNavigationEvents(Dt,Ct),Nt("AttachPage",Oe.getBaseURI(),Oe.getLocationHref()),await t.invokeAfterStartedCallbacks(nt)}function xt(e,t,n,r){!function(e,t,n,r,o){let a=et.get(t);if(!a){const n=new ReadableStream({start(e){et.set(t,e),a=e}});e.supplyDotNetStream(t,n)}o?(a.error(o),et.delete(t)):0===r?(a.close(),et.delete(t)):a.enqueue(n.length===r?n:n.subarray(0,r))}(_t,e,t,n,r)}nt.start=Lt,window.DotNet=e,document&&document.currentScript&&"false"!==document.currentScript.getAttribute("autostart")&&Lt()})(); \ No newline at end of file diff --git a/src/Components/Web.JS/src/Boot.Web.ts b/src/Components/Web.JS/src/Boot.Web.ts index b989332d4a051..2e54c1a9041d4 100644 --- a/src/Components/Web.JS/src/Boot.Web.ts +++ b/src/Components/Web.JS/src/Boot.Web.ts @@ -19,7 +19,6 @@ import { NavigationEnhancementCallbacks, attachProgressivelyEnhancedNavigationLi import { WebRootComponentManager } from './Services/WebRootComponentManager'; import { hasProgrammaticEnhancedNavigationHandler, performProgrammaticEnhancedNavigation } from './Services/NavigationUtils'; import { attachComponentDescriptorHandler, registerAllComponentDescriptors } from './Rendering/DomMerging/DomSync'; -import { CallbackCollection } from './Services/CallbackCollection'; let started = false; let rootComponentManager: WebRootComponentManager; @@ -45,14 +44,12 @@ function boot(options?: Partial) : Promise { setWebAssemblyOptions(options?.webAssembly); rootComponentManager = new WebRootComponentManager(options?.ssr?.circuitInactivityTimeoutMs ?? 2000); - const enhancedPageUpdateCallbacks = new CallbackCollection(); - - Blazor.registerEnhancedPageUpdateCallback = (callback) => enhancedPageUpdateCallbacks.registerCallback(callback); + const enqueueDispatchEnhancedLoad = createEnhancedLoadDispatcher(); const navigationEnhancementCallbacks: NavigationEnhancementCallbacks = { documentUpdated: () => { rootComponentManager.onDocumentUpdated(); - enhancedPageUpdateCallbacks.enqueueCallbackInvocation(); + enqueueDispatchEnhancedLoad(); }, }; @@ -80,6 +77,24 @@ function onInitialDomContentLoaded() { rootComponentManager.onDocumentUpdated(); } +// This function ensures that 'enhancedload' only gets invoked once +// for any synchronous sequence of document updates via SSR. +function createEnhancedLoadDispatcher() { + let isDispatchPending = false; + + return function() { + if (isDispatchPending) { + return; + } + + isDispatchPending = true; + setTimeout(() => { + isDispatchPending = false; + Blazor._internal.dispatchEvent('enhancedload', {}); + }, 0); + }; +} + Blazor.start = boot; window['DotNet'] = DotNet; diff --git a/src/Components/Web.JS/src/GlobalExports.ts b/src/Components/Web.JS/src/GlobalExports.ts index d9593c4362e04..d2c56d23c40e5 100644 --- a/src/Components/Web.JS/src/GlobalExports.ts +++ b/src/Components/Web.JS/src/GlobalExports.ts @@ -18,6 +18,7 @@ import { RootComponentsFunctions } from './Rendering/JSRootComponents'; import { attachWebRendererInterop } from './Rendering/WebRendererInteropMethods'; import { WebStartOptions } from './Platform/WebStartOptions'; import { RuntimeAPI } from 'dotnet'; +import { EventRegistry } from './Services/EventRegistry'; // TODO: It's kind of hard to tell which .NET platform(s) some of these APIs are relevant to. // It's important to know this information when dealing with the possibility of mulitple .NET platforms being available. @@ -29,11 +30,12 @@ import { RuntimeAPI } from 'dotnet'; // * Blazor._internal.{foo}: internal, platform-agnostic Blazor APIs // * Blazor.platform.{somePlatformName}.{foo}: public, platform-specific Blazor APIs (would be empty at first, so no initial breaking changes) // * Blazor.platform.{somePlatformName}.{_internal}.{foo}: internal, platform-specific Blazor APIs -interface IBlazor { +export interface IBlazor { navigateTo: (uri: string, options: NavigationOptions) => void; registerCustomEventType: (eventName: string, options: EventTypeOptions) => void; - registerEnhancedPageUpdateCallback?: (callback: () => void) => { dispose(): void }; + addEventListener: typeof EventRegistry.prototype.addEventListener; + removeEventListener: typeof EventRegistry.prototype.removeEventListener; disconnect?: () => void; reconnect?: (existingConnection?: HubConnection) => Promise; defaultReconnectionHandler?: DefaultReconnectionHandler; @@ -47,6 +49,7 @@ interface IBlazor { domWrapper: typeof domFunctions; Virtualize: typeof Virtualize; PageTitle: typeof PageTitle; + dispatchEvent: typeof EventRegistry.prototype.dispatchEvent; forceCloseConnection?: () => Promise; InputFile?: typeof InputFile; NavigationLock: typeof NavigationLock; @@ -91,9 +94,13 @@ interface IBlazor { } } +const eventRegistry = new EventRegistry(); + export const Blazor: IBlazor = { navigateTo, registerCustomEventType, + addEventListener: eventRegistry.addEventListener.bind(eventRegistry), + removeEventListener: eventRegistry.removeEventListener.bind(eventRegistry), rootComponents: RootComponentsFunctions, runtime: {} as RuntimeAPI, @@ -106,8 +113,11 @@ export const Blazor: IBlazor = { NavigationLock, getJSDataStreamChunk: getNextChunk, attachWebRendererInterop, + dispatchEvent: eventRegistry.dispatchEvent.bind(eventRegistry), }, }; +eventRegistry.attachBlazorInstance(Blazor); + // Make the following APIs available in global scope for invocation from JS window['Blazor'] = Blazor; diff --git a/src/Components/Web.JS/src/Services/CallbackCollection.ts b/src/Components/Web.JS/src/Services/CallbackCollection.ts deleted file mode 100644 index b0b613ddaa96b..0000000000000 --- a/src/Components/Web.JS/src/Services/CallbackCollection.ts +++ /dev/null @@ -1,35 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -type CallbackRegistration = { - dispose(): void; -}; - -export class CallbackCollection { - private readonly _callbacks = new Set<() => void>(); - - private _isInvocationPending = false; - - public registerCallback(callback: () => void): CallbackRegistration { - this._callbacks.add(callback); - return { - dispose: () => { - this._callbacks.delete(callback); - }, - }; - } - - public enqueueCallbackInvocation(): void { - if (this._isInvocationPending) { - return; - } - - this._isInvocationPending = true; - setTimeout(() => { - this._isInvocationPending = false; - for (const callback of this._callbacks) { - callback(); - } - }, 0); - } -} diff --git a/src/Components/Web.JS/src/Services/EventRegistry.ts b/src/Components/Web.JS/src/Services/EventRegistry.ts new file mode 100644 index 0000000000000..0917b7c5a5350 --- /dev/null +++ b/src/Components/Web.JS/src/Services/EventRegistry.ts @@ -0,0 +1,66 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +import { IBlazor } from '../GlobalExports'; + +// The base Blazor event type. +// Properties listed here get assigned by the event registry in 'dispatchEvent'. +interface BlazorEvent { + blazor: IBlazor; + type: keyof BlazorEventMap; +} + +// Maps Blazor event names to the argument type passed to registered listeners. +export interface BlazorEventMap { + 'enhancedload': BlazorEvent; +} + +export class EventRegistry { + private readonly _eventListeners = new Map void>>(); + + private _blazor: IBlazor | null = null; + + public attachBlazorInstance(blazor: IBlazor) { + this._blazor = blazor; + } + + public addEventListener(type: K, listener: (ev: BlazorEventMap[K]) => void): void { + let listenersForEventType = this._eventListeners.get(type); + if (!listenersForEventType) { + listenersForEventType = new Set(); + this._eventListeners.set(type, listenersForEventType); + } + + listenersForEventType.add(listener); + } + + public removeEventListener(type: K, listener: (ev: BlazorEventMap[K]) => void): void { + const listenersForEventType = this._eventListeners.get(type); + if (!listenersForEventType) { + return; + } + + listenersForEventType.delete(listener); + } + + public dispatchEvent(type: K, ev: Omit): void { + if (this._blazor === null) { + throw new Error('Blazor events cannot be dispatched until a Blazor instance gets attached'); + } + + const listenersForEventType = this._eventListeners.get(type); + if (!listenersForEventType) { + return; + } + + const event: BlazorEventMap[K] = { + ...ev, + blazor: this._blazor, + type, + }; + + for (const listener of listenersForEventType) { + listener(event); + } + } +} diff --git a/src/Components/test/testassets/Components.TestServer/RazorComponents/Pages/EnhancedNav/PageThatPreservesContent.razor b/src/Components/test/testassets/Components.TestServer/RazorComponents/Pages/EnhancedNav/PageThatPreservesContent.razor index 0791fb6f3a5e5..63c6e944f03f5 100644 --- a/src/Components/test/testassets/Components.TestServer/RazorComponents/Pages/EnhancedNav/PageThatPreservesContent.razor +++ b/src/Components/test/testassets/Components.TestServer/RazorComponents/Pages/EnhancedNav/PageThatPreservesContent.razor @@ -22,22 +22,17 @@ preservedContent.textContent = 'Preserved content'; nonPreservedContent.textContent = 'Non preserved content'; - let registration = null; + const onEnhancedLoad = (ev) => { + window.enhancedPageUpdateCount++; + } window.listenForEnhancedUpdates = () => { - if (!registration) { - window.enhancedPageUpdateCount = 0; - registration = Blazor.registerEnhancedPageUpdateCallback(() => { - window.enhancedPageUpdateCount++; - }); - } + window.enhancedPageUpdateCount = 0; + Blazor.addEventListener('enhancedload', onEnhancedLoad); }; window.stopListeningForEnhancedUpdates = () => { - if (registration) { - registration.dispose(); - registration = null; - } + Blazor.removeEventListener('enhancedload', onEnhancedLoad); };