nervoscan-js-sdk 1.0.7 → 1.0.8-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
- "use strict";var wc=Object.defineProperty;var vc=(n,e,t)=>e in n?wc(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var x=(n,e,t)=>vc(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class A extends Error{constructor(e){super(e)}}class ki extends A{constructor(e){super(e)}}class Ai extends A{constructor(e){super(e)}}class Oi extends A{constructor(e){super(e)}}class xi extends A{constructor(e){super(e)}}class Pi extends A{constructor(e){super(e)}}class Di extends A{constructor(e){super(e)}}class Li extends A{constructor(e){super(e)}}class Fi extends A{constructor(e){super(e)}}class Mi extends A{constructor(e){super(e)}}class Bi extends A{constructor(e){super(e)}}class Ui extends A{constructor(e){super(e)}}class Hi extends A{constructor(e){super(e)}}class Wi extends A{constructor(e){super(e)}}class qi extends A{constructor(e){super(e)}}class Vi extends A{constructor(e){super(e)}}class $i extends A{constructor(e){super(e)}}class zi extends A{constructor(e){super(e)}}class ji extends A{constructor(e){super(e)}}class Ki extends A{constructor(t){super(t.message);x(this,"errorCode");this.errorCode=t.code}}class Gi extends A{constructor(e){super(e)}}class Yi extends A{constructor(e){super(e)}}class Qi extends A{constructor(e){super(e)}}class Ji extends A{constructor(e){super(e)}}class Xi extends A{constructor(e){super(e)}}class Zi extends A{constructor(e){super(e)}}class eo extends A{constructor(e){super(e)}}class to extends A{constructor(e){super(e)}}const P={NotInitializedError:ki,EmptyVideoError:Ai,VideoTypeError:Oi,InvalidUsernameError:xi,InvalidPasswordError:Pi,NoScansAvailableError:Di,InvalidAccessTokenError:Li,NoScanDataError:Fi,InvalidServerTypeError:Mi,NotImplementedError:Bi,LowFPSError:Ui,FPSCalculationError:Hi,FaceNotCenteredError:Wi,FaceTooFarError:qi,FaceTooCloseError:Vi,FaceLookingLeftError:$i,FaceLookingRightError:zi,ErrorCallbackNotSetError:ji,UnhandledScanError:Ki,SkinExtractionError:Gi,InvalidContentTypeError:Yi,JobNotRegisteredError:Qi,LowFrameCountError:Xi,ConnectionLostError:Zi,ScanFailedError:eo,VideoError:to,UnhandledError:Ji},v={NotInitializedError:new P.NotInitializedError("Nervoscan Client not initialized!"),EmptyVideoError:new P.EmptyVideoError("Video is empty!"),VideoTypeError:new P.VideoTypeError("Video is not a Blob!"),InvalidUsernameError:new P.InvalidUsernameError("Invalid username!"),InvalidPasswordError:new P.InvalidPasswordError("Invalid password!"),NoScansAvailableError:new P.NoScansAvailableError("No scans available, Please purchase a plan!"),InvalidAccessTokenError:new P.InvalidAccessTokenError("Invalid access token!"),NoScanDataError:new P.NoScanDataError("No scan data found!"),InvalidServerTypeError:new P.InvalidServerTypeError("Invalid server type!"),NotImplementedError:new P.NotImplementedError("Not implemented!"),LowFPSError:new P.LowFPSError("Low FPS!"),FPSCalculationError:new P.FPSCalculationError("Error calculating FPS!"),FaceNotCenteredError:new P.FaceNotCenteredError("Face not centered!"),FaceTooFarError:new P.FaceTooFarError("Face too far!"),FaceTooCloseError:new P.FaceTooCloseError("Face too close!"),FaceLookingLeftError:new P.FaceLookingLeftError("Face looking left!"),FaceLookingRightError:new P.FaceLookingRightError("Face looking right!"),ErrorCallbackNotSetError:new P.ErrorCallbackNotSetError("Error callback not set!"),SkinExtractionError:new P.SkinExtractionError("Skin extraction error! Please use a better lighting!"),InvalidContentTypeError:new P.InvalidContentTypeError("Invalid content type!"),JobNotRegisteredError:new P.JobNotRegisteredError("Job not registered! Please await initializeStreaming method!"),LowFrameCountError:new P.LowFrameCountError("Low frame count! Don't stop streaming prematurely!"),ConnectionLostError:new P.ConnectionLostError("Connection lost! Run Client.initializeStreaming() again!"),ScanFailedError:new P.ScanFailedError("Scan failed! Please try again!"),VideoError:new P.VideoError("Video error! Please check your video source! FPS could be very low!"),UnhandledError:new P.UnhandledError("Unhandled error! Please contact support! If you are on production, retry scan!")},G=class G{constructor(){}static getInstance(){return G.instance||(G.instance=new G),G.instance}static throwKnownError(e){throw e}static throwUnknownError(e){throw v.UnhandledError}static handleErrorResponse(e){var t,s,r,i,o,a,c,l,h,u,d,_,p,y,g,I,O;((r=(s=(t=e.response)==null?void 0:t.data)==null?void 0:s.error)==null?void 0:r.code)==="INVALID_USERNAME"?G.throwKnownError(v.InvalidUsernameError):((a=(o=(i=e.response)==null?void 0:i.data)==null?void 0:o.error)==null?void 0:a.code)==="INVALID_PASSWORD"?G.throwKnownError(v.InvalidPasswordError):((h=(l=(c=e.response)==null?void 0:c.data)==null?void 0:l.error)==null?void 0:h.code)==="NO_SCANS_AVAILABLE"||((d=(u=e.response)==null?void 0:u.data)==null?void 0:d.message)==="No packages available!"||((p=(_=e.response)==null?void 0:_.data)==null?void 0:p.message)==="No scans available!"?G.throwKnownError(v.NoScansAvailableError):((y=e.error)==null?void 0:y.code)==="INVALID_CONTENT_TYPE"?G.throwKnownError(v.InvalidContentTypeError):((O=(I=(g=e.response)==null?void 0:g.data)==null?void 0:I.error)==null?void 0:O.code)==="JOB_NOT_REGISTERED"?G.throwKnownError(v.JobNotRegisteredError):G.throwUnknownError(e)}static handleScanError(e){return e.code==="LOW_FPS_ERROR"?v.LowFPSError:e.code==="FPS_CALCULATION_ERROR"?v.FPSCalculationError:e.code==="FACE_NOT_CENTERED_ERROR"?v.FaceNotCenteredError:e.code==="FACE_TOO_FAR_ERROR"?v.FaceTooFarError:e.code==="FACE_TOO_CLOSE_ERROR"?v.FaceTooCloseError:e.code==="FACE_LOOKING_LEFT_ERROR"?v.FaceLookingLeftError:e.code==="FACE_LOOKING_RIGHT_ERROR"?v.FaceLookingRightError:e.code==="SKIN_EXTRACTION_ERROR"?v.SkinExtractionError:e.code==="LOW_FRAME_COUNT_ERROR"?v.LowFrameCountError:e.code==="VIDEO_ERROR"?v.VideoError:e.code==="UNHANDLED_ERROR"?v.UnhandledError:v.ScanFailedError}};x(G,"instance");let R=G;function no(n,e){return function(){return n.apply(e,arguments)}}const{toString:bc}=Object.prototype,{getPrototypeOf:Ps}=Object,vn=(n=>e=>{const t=bc.call(e);return n[t]||(n[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),le=n=>(n=n.toLowerCase(),e=>vn(e)===n),bn=n=>e=>typeof e===n,{isArray:Xe}=Array,gt=bn("undefined");function Cc(n){return n!==null&&!gt(n)&&n.constructor!==null&&!gt(n.constructor)&&ee(n.constructor.isBuffer)&&n.constructor.isBuffer(n)}const so=le("ArrayBuffer");function Sc(n){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(n):e=n&&n.buffer&&so(n.buffer),e}const Tc=bn("string"),ee=bn("function"),ro=bn("number"),Cn=n=>n!==null&&typeof n=="object",Rc=n=>n===!0||n===!1,qt=n=>{if(vn(n)!=="object")return!1;const e=Ps(n);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in n)&&!(Symbol.iterator in n)},Ic=le("Date"),Nc=le("File"),kc=le("Blob"),Ac=le("FileList"),Oc=n=>Cn(n)&&ee(n.pipe),xc=n=>{let e;return n&&(typeof FormData=="function"&&n instanceof FormData||ee(n.append)&&((e=vn(n))==="formdata"||e==="object"&&ee(n.toString)&&n.toString()==="[object FormData]"))},Pc=le("URLSearchParams"),[Dc,Lc,Fc,Mc]=["ReadableStream","Request","Response","Headers"].map(le),Bc=n=>n.trim?n.trim():n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Nt(n,e,{allOwnKeys:t=!1}={}){if(n===null||typeof n>"u")return;let s,r;if(typeof n!="object"&&(n=[n]),Xe(n))for(s=0,r=n.length;s<r;s++)e.call(null,n[s],s,n);else{const i=t?Object.getOwnPropertyNames(n):Object.keys(n),o=i.length;let a;for(s=0;s<o;s++)a=i[s],e.call(null,n[a],a,n)}}function io(n,e){e=e.toLowerCase();const t=Object.keys(n);let s=t.length,r;for(;s-- >0;)if(r=t[s],e===r.toLowerCase())return r;return null}const Ae=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,oo=n=>!gt(n)&&n!==Ae;function ns(){const{caseless:n}=oo(this)&&this||{},e={},t=(s,r)=>{const i=n&&io(e,r)||r;qt(e[i])&&qt(s)?e[i]=ns(e[i],s):qt(s)?e[i]=ns({},s):Xe(s)?e[i]=s.slice():e[i]=s};for(let s=0,r=arguments.length;s<r;s++)arguments[s]&&Nt(arguments[s],t);return e}const Uc=(n,e,t,{allOwnKeys:s}={})=>(Nt(e,(r,i)=>{t&&ee(r)?n[i]=no(r,t):n[i]=r},{allOwnKeys:s}),n),Hc=n=>(n.charCodeAt(0)===65279&&(n=n.slice(1)),n),Wc=(n,e,t,s)=>{n.prototype=Object.create(e.prototype,s),n.prototype.constructor=n,Object.defineProperty(n,"super",{value:e.prototype}),t&&Object.assign(n.prototype,t)},qc=(n,e,t,s)=>{let r,i,o;const a={};if(e=e||{},n==null)return e;do{for(r=Object.getOwnPropertyNames(n),i=r.length;i-- >0;)o=r[i],(!s||s(o,n,e))&&!a[o]&&(e[o]=n[o],a[o]=!0);n=t!==!1&&Ps(n)}while(n&&(!t||t(n,e))&&n!==Object.prototype);return e},Vc=(n,e,t)=>{n=String(n),(t===void 0||t>n.length)&&(t=n.length),t-=e.length;const s=n.indexOf(e,t);return s!==-1&&s===t},$c=n=>{if(!n)return null;if(Xe(n))return n;let e=n.length;if(!ro(e))return null;const t=new Array(e);for(;e-- >0;)t[e]=n[e];return t},zc=(n=>e=>n&&e instanceof n)(typeof Uint8Array<"u"&&Ps(Uint8Array)),jc=(n,e)=>{const s=(n&&n[Symbol.iterator]).call(n);let r;for(;(r=s.next())&&!r.done;){const i=r.value;e.call(n,i[0],i[1])}},Kc=(n,e)=>{let t;const s=[];for(;(t=n.exec(e))!==null;)s.push(t);return s},Gc=le("HTMLFormElement"),Yc=n=>n.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,s,r){return s.toUpperCase()+r}),vr=(({hasOwnProperty:n})=>(e,t)=>n.call(e,t))(Object.prototype),Qc=le("RegExp"),ao=(n,e)=>{const t=Object.getOwnPropertyDescriptors(n),s={};Nt(t,(r,i)=>{let o;(o=e(r,i,n))!==!1&&(s[i]=o||r)}),Object.defineProperties(n,s)},Jc=n=>{ao(n,(e,t)=>{if(ee(n)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const s=n[t];if(ee(s)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},Xc=(n,e)=>{const t={},s=r=>{r.forEach(i=>{t[i]=!0})};return Xe(n)?s(n):s(String(n).split(e)),t},Zc=()=>{},el=(n,e)=>n!=null&&Number.isFinite(n=+n)?n:e;function tl(n){return!!(n&&ee(n.append)&&n[Symbol.toStringTag]==="FormData"&&n[Symbol.iterator])}const nl=n=>{const e=new Array(10),t=(s,r)=>{if(Cn(s)){if(e.indexOf(s)>=0)return;if(!("toJSON"in s)){e[r]=s;const i=Xe(s)?[]:{};return Nt(s,(o,a)=>{const c=t(o,r+1);!gt(c)&&(i[a]=c)}),e[r]=void 0,i}}return s};return t(n,0)},sl=le("AsyncFunction"),rl=n=>n&&(Cn(n)||ee(n))&&ee(n.then)&&ee(n.catch),co=((n,e)=>n?setImmediate:e?((t,s)=>(Ae.addEventListener("message",({source:r,data:i})=>{r===Ae&&i===t&&s.length&&s.shift()()},!1),r=>{s.push(r),Ae.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",ee(Ae.postMessage)),il=typeof queueMicrotask<"u"?queueMicrotask.bind(Ae):typeof process<"u"&&process.nextTick||co,f={isArray:Xe,isArrayBuffer:so,isBuffer:Cc,isFormData:xc,isArrayBufferView:Sc,isString:Tc,isNumber:ro,isBoolean:Rc,isObject:Cn,isPlainObject:qt,isReadableStream:Dc,isRequest:Lc,isResponse:Fc,isHeaders:Mc,isUndefined:gt,isDate:Ic,isFile:Nc,isBlob:kc,isRegExp:Qc,isFunction:ee,isStream:Oc,isURLSearchParams:Pc,isTypedArray:zc,isFileList:Ac,forEach:Nt,merge:ns,extend:Uc,trim:Bc,stripBOM:Hc,inherits:Wc,toFlatObject:qc,kindOf:vn,kindOfTest:le,endsWith:Vc,toArray:$c,forEachEntry:jc,matchAll:Kc,isHTMLForm:Gc,hasOwnProperty:vr,hasOwnProp:vr,reduceDescriptors:ao,freezeMethods:Jc,toObjectSet:Xc,toCamelCase:Yc,noop:Zc,toFiniteNumber:el,findKey:io,global:Ae,isContextDefined:oo,isSpecCompliantForm:tl,toJSONObject:nl,isAsyncFn:sl,isThenable:rl,setImmediate:co,asap:il};function w(n,e,t,s,r){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=n,this.name="AxiosError",e&&(this.code=e),t&&(this.config=t),s&&(this.request=s),r&&(this.response=r,this.status=r.status?r.status:null)}f.inherits(w,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:f.toJSONObject(this.config),code:this.code,status:this.status}}});const lo=w.prototype,ho={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(n=>{ho[n]={value:n}});Object.defineProperties(w,ho);Object.defineProperty(lo,"isAxiosError",{value:!0});w.from=(n,e,t,s,r,i)=>{const o=Object.create(lo);return f.toFlatObject(n,o,function(c){return c!==Error.prototype},a=>a!=="isAxiosError"),w.call(o,n.message,e,t,s,r),o.cause=n,o.name=n.name,i&&Object.assign(o,i),o};const ol=null;function ss(n){return f.isPlainObject(n)||f.isArray(n)}function uo(n){return f.endsWith(n,"[]")?n.slice(0,-2):n}function br(n,e,t){return n?n.concat(e).map(function(r,i){return r=uo(r),!t&&i?"["+r+"]":r}).join(t?".":""):e}function al(n){return f.isArray(n)&&!n.some(ss)}const cl=f.toFlatObject(f,{},null,function(e){return/^is[A-Z]/.test(e)});function Sn(n,e,t){if(!f.isObject(n))throw new TypeError("target must be an object");e=e||new FormData,t=f.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(y,g){return!f.isUndefined(g[y])});const s=t.metaTokens,r=t.visitor||h,i=t.dots,o=t.indexes,c=(t.Blob||typeof Blob<"u"&&Blob)&&f.isSpecCompliantForm(e);if(!f.isFunction(r))throw new TypeError("visitor must be a function");function l(p){if(p===null)return"";if(f.isDate(p))return p.toISOString();if(!c&&f.isBlob(p))throw new w("Blob is not supported. Use a Buffer instead.");return f.isArrayBuffer(p)||f.isTypedArray(p)?c&&typeof Blob=="function"?new Blob([p]):Buffer.from(p):p}function h(p,y,g){let I=p;if(p&&!g&&typeof p=="object"){if(f.endsWith(y,"{}"))y=s?y:y.slice(0,-2),p=JSON.stringify(p);else if(f.isArray(p)&&al(p)||(f.isFileList(p)||f.endsWith(y,"[]"))&&(I=f.toArray(p)))return y=uo(y),I.forEach(function(B,se){!(f.isUndefined(B)||B===null)&&e.append(o===!0?br([y],se,i):o===null?y:y+"[]",l(B))}),!1}return ss(p)?!0:(e.append(br(g,y,i),l(p)),!1)}const u=[],d=Object.assign(cl,{defaultVisitor:h,convertValue:l,isVisitable:ss});function _(p,y){if(!f.isUndefined(p)){if(u.indexOf(p)!==-1)throw Error("Circular reference detected in "+y.join("."));u.push(p),f.forEach(p,function(I,O){(!(f.isUndefined(I)||I===null)&&r.call(e,I,f.isString(O)?O.trim():O,y,d))===!0&&_(I,y?y.concat(O):[O])}),u.pop()}}if(!f.isObject(n))throw new TypeError("data must be an object");return _(n),e}function Cr(n){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(n).replace(/[!'()~]|%20|%00/g,function(s){return e[s]})}function Ds(n,e){this._pairs=[],n&&Sn(n,this,e)}const fo=Ds.prototype;fo.append=function(e,t){this._pairs.push([e,t])};fo.toString=function(e){const t=e?function(s){return e.call(this,s,Cr)}:Cr;return this._pairs.map(function(r){return t(r[0])+"="+t(r[1])},"").join("&")};function ll(n){return encodeURIComponent(n).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function po(n,e,t){if(!e)return n;const s=t&&t.encode||ll;f.isFunction(t)&&(t={serialize:t});const r=t&&t.serialize;let i;if(r?i=r(e,t):i=f.isURLSearchParams(e)?e.toString():new Ds(e,t).toString(s),i){const o=n.indexOf("#");o!==-1&&(n=n.slice(0,o)),n+=(n.indexOf("?")===-1?"?":"&")+i}return n}class Sr{constructor(){this.handlers=[]}use(e,t,s){return this.handlers.push({fulfilled:e,rejected:t,synchronous:s?s.synchronous:!1,runWhen:s?s.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){f.forEach(this.handlers,function(s){s!==null&&e(s)})}}const _o={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},hl=typeof URLSearchParams<"u"?URLSearchParams:Ds,ul=typeof FormData<"u"?FormData:null,dl=typeof Blob<"u"?Blob:null,fl={isBrowser:!0,classes:{URLSearchParams:hl,FormData:ul,Blob:dl},protocols:["http","https","file","blob","url","data"]},Ls=typeof window<"u"&&typeof document<"u",rs=typeof navigator=="object"&&navigator||void 0,pl=Ls&&(!rs||["ReactNative","NativeScript","NS"].indexOf(rs.product)<0),_l=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",ml=Ls&&window.location.href||"http://localhost",gl=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ls,hasStandardBrowserEnv:pl,hasStandardBrowserWebWorkerEnv:_l,navigator:rs,origin:ml},Symbol.toStringTag,{value:"Module"})),K={...gl,...fl};function yl(n,e){return Sn(n,new K.classes.URLSearchParams,Object.assign({visitor:function(t,s,r,i){return K.isNode&&f.isBuffer(t)?(this.append(s,t.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)}},e))}function El(n){return f.matchAll(/\w+|\[(\w*)]/g,n).map(e=>e[0]==="[]"?"":e[1]||e[0])}function wl(n){const e={},t=Object.keys(n);let s;const r=t.length;let i;for(s=0;s<r;s++)i=t[s],e[i]=n[i];return e}function mo(n){function e(t,s,r,i){let o=t[i++];if(o==="__proto__")return!0;const a=Number.isFinite(+o),c=i>=t.length;return o=!o&&f.isArray(r)?r.length:o,c?(f.hasOwnProp(r,o)?r[o]=[r[o],s]:r[o]=s,!a):((!r[o]||!f.isObject(r[o]))&&(r[o]=[]),e(t,s,r[o],i)&&f.isArray(r[o])&&(r[o]=wl(r[o])),!a)}if(f.isFormData(n)&&f.isFunction(n.entries)){const t={};return f.forEachEntry(n,(s,r)=>{e(El(s),r,t,0)}),t}return null}function vl(n,e,t){if(f.isString(n))try{return(e||JSON.parse)(n),f.trim(n)}catch(s){if(s.name!=="SyntaxError")throw s}return(t||JSON.stringify)(n)}const kt={transitional:_o,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const s=t.getContentType()||"",r=s.indexOf("application/json")>-1,i=f.isObject(e);if(i&&f.isHTMLForm(e)&&(e=new FormData(e)),f.isFormData(e))return r?JSON.stringify(mo(e)):e;if(f.isArrayBuffer(e)||f.isBuffer(e)||f.isStream(e)||f.isFile(e)||f.isBlob(e)||f.isReadableStream(e))return e;if(f.isArrayBufferView(e))return e.buffer;if(f.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(i){if(s.indexOf("application/x-www-form-urlencoded")>-1)return yl(e,this.formSerializer).toString();if((a=f.isFileList(e))||s.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return Sn(a?{"files[]":e}:e,c&&new c,this.formSerializer)}}return i||r?(t.setContentType("application/json",!1),vl(e)):e}],transformResponse:[function(e){const t=this.transitional||kt.transitional,s=t&&t.forcedJSONParsing,r=this.responseType==="json";if(f.isResponse(e)||f.isReadableStream(e))return e;if(e&&f.isString(e)&&(s&&!this.responseType||r)){const o=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e)}catch(a){if(o)throw a.name==="SyntaxError"?w.from(a,w.ERR_BAD_RESPONSE,this,null,this.response):a}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:K.classes.FormData,Blob:K.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};f.forEach(["delete","get","head","post","put","patch"],n=>{kt.headers[n]={}});const bl=f.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Cl=n=>{const e={};let t,s,r;return n&&n.split(`
1
+ "use strict";var wc=Object.defineProperty;var vc=(n,e,t)=>e in n?wc(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var x=(n,e,t)=>vc(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class k extends Error{constructor(e){super(e)}}class Ai extends k{constructor(e){super(e)}}class ki extends k{constructor(e){super(e)}}class Oi extends k{constructor(e){super(e)}}class xi extends k{constructor(e){super(e)}}class Pi extends k{constructor(e){super(e)}}class Di extends k{constructor(e){super(e)}}class Li extends k{constructor(e){super(e)}}class Fi extends k{constructor(e){super(e)}}class Mi extends k{constructor(e){super(e)}}class Bi extends k{constructor(e){super(e)}}class Ui extends k{constructor(e){super(e)}}class Hi extends k{constructor(e){super(e)}}class Wi extends k{constructor(e){super(e)}}class qi extends k{constructor(e){super(e)}}class Vi extends k{constructor(e){super(e)}}class $i extends k{constructor(e){super(e)}}class zi extends k{constructor(e){super(e)}}class ji extends k{constructor(e){super(e)}}class Ki extends k{constructor(t){super(t.message);x(this,"errorCode");this.errorCode=t.code}}class Gi extends k{constructor(e){super(e)}}class Yi extends k{constructor(e){super(e)}}class Qi extends k{constructor(e){super(e)}}class Ji extends k{constructor(e){super(e)}}class Xi extends k{constructor(e){super(e)}}class Zi extends k{constructor(e){super(e)}}class eo extends k{constructor(e){super(e)}}class to extends k{constructor(e){super(e)}}const P={NotInitializedError:Ai,EmptyVideoError:ki,VideoTypeError:Oi,InvalidUsernameError:xi,InvalidPasswordError:Pi,NoScansAvailableError:Di,InvalidAccessTokenError:Li,NoScanDataError:Fi,InvalidServerTypeError:Mi,NotImplementedError:Bi,LowFPSError:Ui,FPSCalculationError:Hi,FaceNotCenteredError:Wi,FaceTooFarError:qi,FaceTooCloseError:Vi,FaceLookingLeftError:$i,FaceLookingRightError:zi,ErrorCallbackNotSetError:ji,UnhandledScanError:Ki,SkinExtractionError:Gi,InvalidContentTypeError:Yi,JobNotRegisteredError:Qi,LowFrameCountError:Xi,ConnectionLostError:Zi,ScanFailedError:eo,VideoError:to,UnhandledError:Ji},v={NotInitializedError:new P.NotInitializedError("Nervoscan Client not initialized!"),EmptyVideoError:new P.EmptyVideoError("Video is empty!"),VideoTypeError:new P.VideoTypeError("Video is not a Blob!"),InvalidUsernameError:new P.InvalidUsernameError("Invalid username!"),InvalidPasswordError:new P.InvalidPasswordError("Invalid password!"),NoScansAvailableError:new P.NoScansAvailableError("No scans available, Please purchase a plan!"),InvalidAccessTokenError:new P.InvalidAccessTokenError("Invalid access token!"),NoScanDataError:new P.NoScanDataError("No scan data found!"),InvalidServerTypeError:new P.InvalidServerTypeError("Invalid server type!"),NotImplementedError:new P.NotImplementedError("Not implemented!"),LowFPSError:new P.LowFPSError("Low FPS!"),FPSCalculationError:new P.FPSCalculationError("Error calculating FPS!"),FaceNotCenteredError:new P.FaceNotCenteredError("Face not centered!"),FaceTooFarError:new P.FaceTooFarError("Face too far!"),FaceTooCloseError:new P.FaceTooCloseError("Face too close!"),FaceLookingLeftError:new P.FaceLookingLeftError("Face looking left!"),FaceLookingRightError:new P.FaceLookingRightError("Face looking right!"),ErrorCallbackNotSetError:new P.ErrorCallbackNotSetError("Error callback not set!"),SkinExtractionError:new P.SkinExtractionError("Skin extraction error! Please use a better lighting!"),InvalidContentTypeError:new P.InvalidContentTypeError("Invalid content type!"),JobNotRegisteredError:new P.JobNotRegisteredError("Job not registered! Please await initializeStreaming method!"),LowFrameCountError:new P.LowFrameCountError("Low frame count! Don't stop streaming prematurely!"),ConnectionLostError:new P.ConnectionLostError("Connection lost! Run Client.initializeStreaming() again!"),ScanFailedError:new P.ScanFailedError("Scan failed! Please try again!"),VideoError:new P.VideoError("Video error! Please check your video source! FPS could be very low!"),UnhandledError:new P.UnhandledError("Unhandled error! Please contact support! If you are on production, retry scan!")},G=class G{constructor(){}static getInstance(){return G.instance||(G.instance=new G),G.instance}static throwKnownError(e){throw e}static throwUnknownError(e){throw v.UnhandledError}static handleErrorResponse(e){var t,s,r,i,o,a,c,l,h,u,d,_,p,y,g,I,O;((r=(s=(t=e.response)==null?void 0:t.data)==null?void 0:s.error)==null?void 0:r.code)==="INVALID_USERNAME"?G.throwKnownError(v.InvalidUsernameError):((a=(o=(i=e.response)==null?void 0:i.data)==null?void 0:o.error)==null?void 0:a.code)==="INVALID_PASSWORD"?G.throwKnownError(v.InvalidPasswordError):((h=(l=(c=e.response)==null?void 0:c.data)==null?void 0:l.error)==null?void 0:h.code)==="NO_SCANS_AVAILABLE"||((d=(u=e.response)==null?void 0:u.data)==null?void 0:d.message)==="No packages available!"||((p=(_=e.response)==null?void 0:_.data)==null?void 0:p.message)==="No scans available!"?G.throwKnownError(v.NoScansAvailableError):((y=e.error)==null?void 0:y.code)==="INVALID_CONTENT_TYPE"?G.throwKnownError(v.InvalidContentTypeError):((O=(I=(g=e.response)==null?void 0:g.data)==null?void 0:I.error)==null?void 0:O.code)==="JOB_NOT_REGISTERED"?G.throwKnownError(v.JobNotRegisteredError):G.throwUnknownError(e)}static handleScanError(e){return e.code==="LOW_FPS_ERROR"?v.LowFPSError:e.code==="FPS_CALCULATION_ERROR"?v.FPSCalculationError:e.code==="FACE_NOT_CENTERED_ERROR"?v.FaceNotCenteredError:e.code==="FACE_TOO_FAR_ERROR"?v.FaceTooFarError:e.code==="FACE_TOO_CLOSE_ERROR"?v.FaceTooCloseError:e.code==="FACE_LOOKING_LEFT_ERROR"?v.FaceLookingLeftError:e.code==="FACE_LOOKING_RIGHT_ERROR"?v.FaceLookingRightError:e.code==="SKIN_EXTRACTION_ERROR"?v.SkinExtractionError:e.code==="LOW_FRAME_COUNT_ERROR"?v.LowFrameCountError:e.code==="VIDEO_ERROR"?v.VideoError:e.code==="UNHANDLED_ERROR"?v.UnhandledError:v.ScanFailedError}};x(G,"instance");let R=G;function no(n,e){return function(){return n.apply(e,arguments)}}const{toString:bc}=Object.prototype,{getPrototypeOf:Ps}=Object,vn=(n=>e=>{const t=bc.call(e);return n[t]||(n[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),le=n=>(n=n.toLowerCase(),e=>vn(e)===n),bn=n=>e=>typeof e===n,{isArray:Xe}=Array,gt=bn("undefined");function Cc(n){return n!==null&&!gt(n)&&n.constructor!==null&&!gt(n.constructor)&&ee(n.constructor.isBuffer)&&n.constructor.isBuffer(n)}const so=le("ArrayBuffer");function Sc(n){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(n):e=n&&n.buffer&&so(n.buffer),e}const Tc=bn("string"),ee=bn("function"),ro=bn("number"),Cn=n=>n!==null&&typeof n=="object",Rc=n=>n===!0||n===!1,qt=n=>{if(vn(n)!=="object")return!1;const e=Ps(n);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in n)&&!(Symbol.iterator in n)},Ic=le("Date"),Nc=le("File"),Ac=le("Blob"),kc=le("FileList"),Oc=n=>Cn(n)&&ee(n.pipe),xc=n=>{let e;return n&&(typeof FormData=="function"&&n instanceof FormData||ee(n.append)&&((e=vn(n))==="formdata"||e==="object"&&ee(n.toString)&&n.toString()==="[object FormData]"))},Pc=le("URLSearchParams"),[Dc,Lc,Fc,Mc]=["ReadableStream","Request","Response","Headers"].map(le),Bc=n=>n.trim?n.trim():n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Nt(n,e,{allOwnKeys:t=!1}={}){if(n===null||typeof n>"u")return;let s,r;if(typeof n!="object"&&(n=[n]),Xe(n))for(s=0,r=n.length;s<r;s++)e.call(null,n[s],s,n);else{const i=t?Object.getOwnPropertyNames(n):Object.keys(n),o=i.length;let a;for(s=0;s<o;s++)a=i[s],e.call(null,n[a],a,n)}}function io(n,e){e=e.toLowerCase();const t=Object.keys(n);let s=t.length,r;for(;s-- >0;)if(r=t[s],e===r.toLowerCase())return r;return null}const ke=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,oo=n=>!gt(n)&&n!==ke;function ns(){const{caseless:n}=oo(this)&&this||{},e={},t=(s,r)=>{const i=n&&io(e,r)||r;qt(e[i])&&qt(s)?e[i]=ns(e[i],s):qt(s)?e[i]=ns({},s):Xe(s)?e[i]=s.slice():e[i]=s};for(let s=0,r=arguments.length;s<r;s++)arguments[s]&&Nt(arguments[s],t);return e}const Uc=(n,e,t,{allOwnKeys:s}={})=>(Nt(e,(r,i)=>{t&&ee(r)?n[i]=no(r,t):n[i]=r},{allOwnKeys:s}),n),Hc=n=>(n.charCodeAt(0)===65279&&(n=n.slice(1)),n),Wc=(n,e,t,s)=>{n.prototype=Object.create(e.prototype,s),n.prototype.constructor=n,Object.defineProperty(n,"super",{value:e.prototype}),t&&Object.assign(n.prototype,t)},qc=(n,e,t,s)=>{let r,i,o;const a={};if(e=e||{},n==null)return e;do{for(r=Object.getOwnPropertyNames(n),i=r.length;i-- >0;)o=r[i],(!s||s(o,n,e))&&!a[o]&&(e[o]=n[o],a[o]=!0);n=t!==!1&&Ps(n)}while(n&&(!t||t(n,e))&&n!==Object.prototype);return e},Vc=(n,e,t)=>{n=String(n),(t===void 0||t>n.length)&&(t=n.length),t-=e.length;const s=n.indexOf(e,t);return s!==-1&&s===t},$c=n=>{if(!n)return null;if(Xe(n))return n;let e=n.length;if(!ro(e))return null;const t=new Array(e);for(;e-- >0;)t[e]=n[e];return t},zc=(n=>e=>n&&e instanceof n)(typeof Uint8Array<"u"&&Ps(Uint8Array)),jc=(n,e)=>{const s=(n&&n[Symbol.iterator]).call(n);let r;for(;(r=s.next())&&!r.done;){const i=r.value;e.call(n,i[0],i[1])}},Kc=(n,e)=>{let t;const s=[];for(;(t=n.exec(e))!==null;)s.push(t);return s},Gc=le("HTMLFormElement"),Yc=n=>n.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,s,r){return s.toUpperCase()+r}),vr=(({hasOwnProperty:n})=>(e,t)=>n.call(e,t))(Object.prototype),Qc=le("RegExp"),ao=(n,e)=>{const t=Object.getOwnPropertyDescriptors(n),s={};Nt(t,(r,i)=>{let o;(o=e(r,i,n))!==!1&&(s[i]=o||r)}),Object.defineProperties(n,s)},Jc=n=>{ao(n,(e,t)=>{if(ee(n)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const s=n[t];if(ee(s)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},Xc=(n,e)=>{const t={},s=r=>{r.forEach(i=>{t[i]=!0})};return Xe(n)?s(n):s(String(n).split(e)),t},Zc=()=>{},el=(n,e)=>n!=null&&Number.isFinite(n=+n)?n:e;function tl(n){return!!(n&&ee(n.append)&&n[Symbol.toStringTag]==="FormData"&&n[Symbol.iterator])}const nl=n=>{const e=new Array(10),t=(s,r)=>{if(Cn(s)){if(e.indexOf(s)>=0)return;if(!("toJSON"in s)){e[r]=s;const i=Xe(s)?[]:{};return Nt(s,(o,a)=>{const c=t(o,r+1);!gt(c)&&(i[a]=c)}),e[r]=void 0,i}}return s};return t(n,0)},sl=le("AsyncFunction"),rl=n=>n&&(Cn(n)||ee(n))&&ee(n.then)&&ee(n.catch),co=((n,e)=>n?setImmediate:e?((t,s)=>(ke.addEventListener("message",({source:r,data:i})=>{r===ke&&i===t&&s.length&&s.shift()()},!1),r=>{s.push(r),ke.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",ee(ke.postMessage)),il=typeof queueMicrotask<"u"?queueMicrotask.bind(ke):typeof process<"u"&&process.nextTick||co,f={isArray:Xe,isArrayBuffer:so,isBuffer:Cc,isFormData:xc,isArrayBufferView:Sc,isString:Tc,isNumber:ro,isBoolean:Rc,isObject:Cn,isPlainObject:qt,isReadableStream:Dc,isRequest:Lc,isResponse:Fc,isHeaders:Mc,isUndefined:gt,isDate:Ic,isFile:Nc,isBlob:Ac,isRegExp:Qc,isFunction:ee,isStream:Oc,isURLSearchParams:Pc,isTypedArray:zc,isFileList:kc,forEach:Nt,merge:ns,extend:Uc,trim:Bc,stripBOM:Hc,inherits:Wc,toFlatObject:qc,kindOf:vn,kindOfTest:le,endsWith:Vc,toArray:$c,forEachEntry:jc,matchAll:Kc,isHTMLForm:Gc,hasOwnProperty:vr,hasOwnProp:vr,reduceDescriptors:ao,freezeMethods:Jc,toObjectSet:Xc,toCamelCase:Yc,noop:Zc,toFiniteNumber:el,findKey:io,global:ke,isContextDefined:oo,isSpecCompliantForm:tl,toJSONObject:nl,isAsyncFn:sl,isThenable:rl,setImmediate:co,asap:il};function w(n,e,t,s,r){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=n,this.name="AxiosError",e&&(this.code=e),t&&(this.config=t),s&&(this.request=s),r&&(this.response=r,this.status=r.status?r.status:null)}f.inherits(w,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:f.toJSONObject(this.config),code:this.code,status:this.status}}});const lo=w.prototype,ho={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(n=>{ho[n]={value:n}});Object.defineProperties(w,ho);Object.defineProperty(lo,"isAxiosError",{value:!0});w.from=(n,e,t,s,r,i)=>{const o=Object.create(lo);return f.toFlatObject(n,o,function(c){return c!==Error.prototype},a=>a!=="isAxiosError"),w.call(o,n.message,e,t,s,r),o.cause=n,o.name=n.name,i&&Object.assign(o,i),o};const ol=null;function ss(n){return f.isPlainObject(n)||f.isArray(n)}function uo(n){return f.endsWith(n,"[]")?n.slice(0,-2):n}function br(n,e,t){return n?n.concat(e).map(function(r,i){return r=uo(r),!t&&i?"["+r+"]":r}).join(t?".":""):e}function al(n){return f.isArray(n)&&!n.some(ss)}const cl=f.toFlatObject(f,{},null,function(e){return/^is[A-Z]/.test(e)});function Sn(n,e,t){if(!f.isObject(n))throw new TypeError("target must be an object");e=e||new FormData,t=f.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(y,g){return!f.isUndefined(g[y])});const s=t.metaTokens,r=t.visitor||h,i=t.dots,o=t.indexes,c=(t.Blob||typeof Blob<"u"&&Blob)&&f.isSpecCompliantForm(e);if(!f.isFunction(r))throw new TypeError("visitor must be a function");function l(p){if(p===null)return"";if(f.isDate(p))return p.toISOString();if(!c&&f.isBlob(p))throw new w("Blob is not supported. Use a Buffer instead.");return f.isArrayBuffer(p)||f.isTypedArray(p)?c&&typeof Blob=="function"?new Blob([p]):Buffer.from(p):p}function h(p,y,g){let I=p;if(p&&!g&&typeof p=="object"){if(f.endsWith(y,"{}"))y=s?y:y.slice(0,-2),p=JSON.stringify(p);else if(f.isArray(p)&&al(p)||(f.isFileList(p)||f.endsWith(y,"[]"))&&(I=f.toArray(p)))return y=uo(y),I.forEach(function(B,se){!(f.isUndefined(B)||B===null)&&e.append(o===!0?br([y],se,i):o===null?y:y+"[]",l(B))}),!1}return ss(p)?!0:(e.append(br(g,y,i),l(p)),!1)}const u=[],d=Object.assign(cl,{defaultVisitor:h,convertValue:l,isVisitable:ss});function _(p,y){if(!f.isUndefined(p)){if(u.indexOf(p)!==-1)throw Error("Circular reference detected in "+y.join("."));u.push(p),f.forEach(p,function(I,O){(!(f.isUndefined(I)||I===null)&&r.call(e,I,f.isString(O)?O.trim():O,y,d))===!0&&_(I,y?y.concat(O):[O])}),u.pop()}}if(!f.isObject(n))throw new TypeError("data must be an object");return _(n),e}function Cr(n){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(n).replace(/[!'()~]|%20|%00/g,function(s){return e[s]})}function Ds(n,e){this._pairs=[],n&&Sn(n,this,e)}const fo=Ds.prototype;fo.append=function(e,t){this._pairs.push([e,t])};fo.toString=function(e){const t=e?function(s){return e.call(this,s,Cr)}:Cr;return this._pairs.map(function(r){return t(r[0])+"="+t(r[1])},"").join("&")};function ll(n){return encodeURIComponent(n).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function po(n,e,t){if(!e)return n;const s=t&&t.encode||ll;f.isFunction(t)&&(t={serialize:t});const r=t&&t.serialize;let i;if(r?i=r(e,t):i=f.isURLSearchParams(e)?e.toString():new Ds(e,t).toString(s),i){const o=n.indexOf("#");o!==-1&&(n=n.slice(0,o)),n+=(n.indexOf("?")===-1?"?":"&")+i}return n}class Sr{constructor(){this.handlers=[]}use(e,t,s){return this.handlers.push({fulfilled:e,rejected:t,synchronous:s?s.synchronous:!1,runWhen:s?s.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){f.forEach(this.handlers,function(s){s!==null&&e(s)})}}const _o={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},hl=typeof URLSearchParams<"u"?URLSearchParams:Ds,ul=typeof FormData<"u"?FormData:null,dl=typeof Blob<"u"?Blob:null,fl={isBrowser:!0,classes:{URLSearchParams:hl,FormData:ul,Blob:dl},protocols:["http","https","file","blob","url","data"]},Ls=typeof window<"u"&&typeof document<"u",rs=typeof navigator=="object"&&navigator||void 0,pl=Ls&&(!rs||["ReactNative","NativeScript","NS"].indexOf(rs.product)<0),_l=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",ml=Ls&&window.location.href||"http://localhost",gl=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ls,hasStandardBrowserEnv:pl,hasStandardBrowserWebWorkerEnv:_l,navigator:rs,origin:ml},Symbol.toStringTag,{value:"Module"})),K={...gl,...fl};function yl(n,e){return Sn(n,new K.classes.URLSearchParams,Object.assign({visitor:function(t,s,r,i){return K.isNode&&f.isBuffer(t)?(this.append(s,t.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)}},e))}function El(n){return f.matchAll(/\w+|\[(\w*)]/g,n).map(e=>e[0]==="[]"?"":e[1]||e[0])}function wl(n){const e={},t=Object.keys(n);let s;const r=t.length;let i;for(s=0;s<r;s++)i=t[s],e[i]=n[i];return e}function mo(n){function e(t,s,r,i){let o=t[i++];if(o==="__proto__")return!0;const a=Number.isFinite(+o),c=i>=t.length;return o=!o&&f.isArray(r)?r.length:o,c?(f.hasOwnProp(r,o)?r[o]=[r[o],s]:r[o]=s,!a):((!r[o]||!f.isObject(r[o]))&&(r[o]=[]),e(t,s,r[o],i)&&f.isArray(r[o])&&(r[o]=wl(r[o])),!a)}if(f.isFormData(n)&&f.isFunction(n.entries)){const t={};return f.forEachEntry(n,(s,r)=>{e(El(s),r,t,0)}),t}return null}function vl(n,e,t){if(f.isString(n))try{return(e||JSON.parse)(n),f.trim(n)}catch(s){if(s.name!=="SyntaxError")throw s}return(t||JSON.stringify)(n)}const At={transitional:_o,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const s=t.getContentType()||"",r=s.indexOf("application/json")>-1,i=f.isObject(e);if(i&&f.isHTMLForm(e)&&(e=new FormData(e)),f.isFormData(e))return r?JSON.stringify(mo(e)):e;if(f.isArrayBuffer(e)||f.isBuffer(e)||f.isStream(e)||f.isFile(e)||f.isBlob(e)||f.isReadableStream(e))return e;if(f.isArrayBufferView(e))return e.buffer;if(f.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(i){if(s.indexOf("application/x-www-form-urlencoded")>-1)return yl(e,this.formSerializer).toString();if((a=f.isFileList(e))||s.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return Sn(a?{"files[]":e}:e,c&&new c,this.formSerializer)}}return i||r?(t.setContentType("application/json",!1),vl(e)):e}],transformResponse:[function(e){const t=this.transitional||At.transitional,s=t&&t.forcedJSONParsing,r=this.responseType==="json";if(f.isResponse(e)||f.isReadableStream(e))return e;if(e&&f.isString(e)&&(s&&!this.responseType||r)){const o=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e)}catch(a){if(o)throw a.name==="SyntaxError"?w.from(a,w.ERR_BAD_RESPONSE,this,null,this.response):a}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:K.classes.FormData,Blob:K.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};f.forEach(["delete","get","head","post","put","patch"],n=>{At.headers[n]={}});const bl=f.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Cl=n=>{const e={};let t,s,r;return n&&n.split(`
2
2
  `).forEach(function(o){r=o.indexOf(":"),t=o.substring(0,r).trim().toLowerCase(),s=o.substring(r+1).trim(),!(!t||e[t]&&bl[t])&&(t==="set-cookie"?e[t]?e[t].push(s):e[t]=[s]:e[t]=e[t]?e[t]+", "+s:s)}),e},Tr=Symbol("internals");function rt(n){return n&&String(n).trim().toLowerCase()}function Vt(n){return n===!1||n==null?n:f.isArray(n)?n.map(Vt):String(n)}function Sl(n){const e=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let s;for(;s=t.exec(n);)e[s[1]]=s[2];return e}const Tl=n=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(n.trim());function Un(n,e,t,s,r){if(f.isFunction(s))return s.call(this,e,t);if(r&&(e=t),!!f.isString(e)){if(f.isString(s))return e.indexOf(s)!==-1;if(f.isRegExp(s))return s.test(e)}}function Rl(n){return n.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,s)=>t.toUpperCase()+s)}function Il(n,e){const t=f.toCamelCase(" "+e);["get","set","has"].forEach(s=>{Object.defineProperty(n,s+t,{value:function(r,i,o){return this[s].call(this,e,r,i,o)},configurable:!0})})}let X=class{constructor(e){e&&this.set(e)}set(e,t,s){const r=this;function i(a,c,l){const h=rt(c);if(!h)throw new Error("header name must be a non-empty string");const u=f.findKey(r,h);(!u||r[u]===void 0||l===!0||l===void 0&&r[u]!==!1)&&(r[u||c]=Vt(a))}const o=(a,c)=>f.forEach(a,(l,h)=>i(l,h,c));if(f.isPlainObject(e)||e instanceof this.constructor)o(e,t);else if(f.isString(e)&&(e=e.trim())&&!Tl(e))o(Cl(e),t);else if(f.isHeaders(e))for(const[a,c]of e.entries())i(c,a,s);else e!=null&&i(t,e,s);return this}get(e,t){if(e=rt(e),e){const s=f.findKey(this,e);if(s){const r=this[s];if(!t)return r;if(t===!0)return Sl(r);if(f.isFunction(t))return t.call(this,r,s);if(f.isRegExp(t))return t.exec(r);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=rt(e),e){const s=f.findKey(this,e);return!!(s&&this[s]!==void 0&&(!t||Un(this,this[s],s,t)))}return!1}delete(e,t){const s=this;let r=!1;function i(o){if(o=rt(o),o){const a=f.findKey(s,o);a&&(!t||Un(s,s[a],a,t))&&(delete s[a],r=!0)}}return f.isArray(e)?e.forEach(i):i(e),r}clear(e){const t=Object.keys(this);let s=t.length,r=!1;for(;s--;){const i=t[s];(!e||Un(this,this[i],i,e,!0))&&(delete this[i],r=!0)}return r}normalize(e){const t=this,s={};return f.forEach(this,(r,i)=>{const o=f.findKey(s,i);if(o){t[o]=Vt(r),delete t[i];return}const a=e?Rl(i):String(i).trim();a!==i&&delete t[i],t[a]=Vt(r),s[a]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return f.forEach(this,(s,r)=>{s!=null&&s!==!1&&(t[r]=e&&f.isArray(s)?s.join(", "):s)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join(`
3
- `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const s=new this(e);return t.forEach(r=>s.set(r)),s}static accessor(e){const s=(this[Tr]=this[Tr]={accessors:{}}).accessors,r=this.prototype;function i(o){const a=rt(o);s[a]||(Il(r,o),s[a]=!0)}return f.isArray(e)?e.forEach(i):i(e),this}};X.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);f.reduceDescriptors(X.prototype,({value:n},e)=>{let t=e[0].toUpperCase()+e.slice(1);return{get:()=>n,set(s){this[t]=s}}});f.freezeMethods(X);function Hn(n,e){const t=this||kt,s=e||t,r=X.from(s.headers);let i=s.data;return f.forEach(n,function(a){i=a.call(t,i,r.normalize(),e?e.status:void 0)}),r.normalize(),i}function go(n){return!!(n&&n.__CANCEL__)}function Ze(n,e,t){w.call(this,n??"canceled",w.ERR_CANCELED,e,t),this.name="CanceledError"}f.inherits(Ze,w,{__CANCEL__:!0});function yo(n,e,t){const s=t.config.validateStatus;!t.status||!s||s(t.status)?n(t):e(new w("Request failed with status code "+t.status,[w.ERR_BAD_REQUEST,w.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function Nl(n){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(n);return e&&e[1]||""}function kl(n,e){n=n||10;const t=new Array(n),s=new Array(n);let r=0,i=0,o;return e=e!==void 0?e:1e3,function(c){const l=Date.now(),h=s[i];o||(o=l),t[r]=c,s[r]=l;let u=i,d=0;for(;u!==r;)d+=t[u++],u=u%n;if(r=(r+1)%n,r===i&&(i=(i+1)%n),l-o<e)return;const _=h&&l-h;return _?Math.round(d*1e3/_):void 0}}function Al(n,e){let t=0,s=1e3/e,r,i;const o=(l,h=Date.now())=>{t=h,r=null,i&&(clearTimeout(i),i=null),n.apply(null,l)};return[(...l)=>{const h=Date.now(),u=h-t;u>=s?o(l,h):(r=l,i||(i=setTimeout(()=>{i=null,o(r)},s-u)))},()=>r&&o(r)]}const Zt=(n,e,t=3)=>{let s=0;const r=kl(50,250);return Al(i=>{const o=i.loaded,a=i.lengthComputable?i.total:void 0,c=o-s,l=r(c),h=o<=a;s=o;const u={loaded:o,total:a,progress:a?o/a:void 0,bytes:c,rate:l||void 0,estimated:l&&a&&h?(a-o)/l:void 0,event:i,lengthComputable:a!=null,[e?"download":"upload"]:!0};n(u)},t)},Rr=(n,e)=>{const t=n!=null;return[s=>e[0]({lengthComputable:t,total:n,loaded:s}),e[1]]},Ir=n=>(...e)=>f.asap(()=>n(...e)),Ol=K.hasStandardBrowserEnv?((n,e)=>t=>(t=new URL(t,K.origin),n.protocol===t.protocol&&n.host===t.host&&(e||n.port===t.port)))(new URL(K.origin),K.navigator&&/(msie|trident)/i.test(K.navigator.userAgent)):()=>!0,xl=K.hasStandardBrowserEnv?{write(n,e,t,s,r,i){const o=[n+"="+encodeURIComponent(e)];f.isNumber(t)&&o.push("expires="+new Date(t).toGMTString()),f.isString(s)&&o.push("path="+s),f.isString(r)&&o.push("domain="+r),i===!0&&o.push("secure"),document.cookie=o.join("; ")},read(n){const e=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(n){this.write(n,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Pl(n){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(n)}function Dl(n,e){return e?n.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):n}function Eo(n,e,t){let s=!Pl(e);return n&&(s||t==!1)?Dl(n,e):e}const Nr=n=>n instanceof X?{...n}:n;function Pe(n,e){e=e||{};const t={};function s(l,h,u,d){return f.isPlainObject(l)&&f.isPlainObject(h)?f.merge.call({caseless:d},l,h):f.isPlainObject(h)?f.merge({},h):f.isArray(h)?h.slice():h}function r(l,h,u,d){if(f.isUndefined(h)){if(!f.isUndefined(l))return s(void 0,l,u,d)}else return s(l,h,u,d)}function i(l,h){if(!f.isUndefined(h))return s(void 0,h)}function o(l,h){if(f.isUndefined(h)){if(!f.isUndefined(l))return s(void 0,l)}else return s(void 0,h)}function a(l,h,u){if(u in e)return s(l,h);if(u in n)return s(void 0,l)}const c={url:i,method:i,data:i,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:a,headers:(l,h,u)=>r(Nr(l),Nr(h),u,!0)};return f.forEach(Object.keys(Object.assign({},n,e)),function(h){const u=c[h]||r,d=u(n[h],e[h],h);f.isUndefined(d)&&u!==a||(t[h]=d)}),t}const wo=n=>{const e=Pe({},n);let{data:t,withXSRFToken:s,xsrfHeaderName:r,xsrfCookieName:i,headers:o,auth:a}=e;e.headers=o=X.from(o),e.url=po(Eo(e.baseURL,e.url,e.allowAbsoluteUrls),n.params,n.paramsSerializer),a&&o.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):"")));let c;if(f.isFormData(t)){if(K.hasStandardBrowserEnv||K.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if((c=o.getContentType())!==!1){const[l,...h]=c?c.split(";").map(u=>u.trim()).filter(Boolean):[];o.setContentType([l||"multipart/form-data",...h].join("; "))}}if(K.hasStandardBrowserEnv&&(s&&f.isFunction(s)&&(s=s(e)),s||s!==!1&&Ol(e.url))){const l=r&&i&&xl.read(i);l&&o.set(r,l)}return e},Ll=typeof XMLHttpRequest<"u",Fl=Ll&&function(n){return new Promise(function(t,s){const r=wo(n);let i=r.data;const o=X.from(r.headers).normalize();let{responseType:a,onUploadProgress:c,onDownloadProgress:l}=r,h,u,d,_,p;function y(){_&&_(),p&&p(),r.cancelToken&&r.cancelToken.unsubscribe(h),r.signal&&r.signal.removeEventListener("abort",h)}let g=new XMLHttpRequest;g.open(r.method.toUpperCase(),r.url,!0),g.timeout=r.timeout;function I(){if(!g)return;const B=X.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),Y={data:!a||a==="text"||a==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:B,config:n,request:g};yo(function(Te){t(Te),y()},function(Te){s(Te),y()},Y),g=null}"onloadend"in g?g.onloadend=I:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(I)},g.onabort=function(){g&&(s(new w("Request aborted",w.ECONNABORTED,n,g)),g=null)},g.onerror=function(){s(new w("Network Error",w.ERR_NETWORK,n,g)),g=null},g.ontimeout=function(){let se=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const Y=r.transitional||_o;r.timeoutErrorMessage&&(se=r.timeoutErrorMessage),s(new w(se,Y.clarifyTimeoutError?w.ETIMEDOUT:w.ECONNABORTED,n,g)),g=null},i===void 0&&o.setContentType(null),"setRequestHeader"in g&&f.forEach(o.toJSON(),function(se,Y){g.setRequestHeader(Y,se)}),f.isUndefined(r.withCredentials)||(g.withCredentials=!!r.withCredentials),a&&a!=="json"&&(g.responseType=r.responseType),l&&([d,p]=Zt(l,!0),g.addEventListener("progress",d)),c&&g.upload&&([u,_]=Zt(c),g.upload.addEventListener("progress",u),g.upload.addEventListener("loadend",_)),(r.cancelToken||r.signal)&&(h=B=>{g&&(s(!B||B.type?new Ze(null,n,g):B),g.abort(),g=null)},r.cancelToken&&r.cancelToken.subscribe(h),r.signal&&(r.signal.aborted?h():r.signal.addEventListener("abort",h)));const O=Nl(r.url);if(O&&K.protocols.indexOf(O)===-1){s(new w("Unsupported protocol "+O+":",w.ERR_BAD_REQUEST,n));return}g.send(i||null)})},Ml=(n,e)=>{const{length:t}=n=n?n.filter(Boolean):[];if(e||t){let s=new AbortController,r;const i=function(l){if(!r){r=!0,a();const h=l instanceof Error?l:this.reason;s.abort(h instanceof w?h:new Ze(h instanceof Error?h.message:h))}};let o=e&&setTimeout(()=>{o=null,i(new w(`timeout ${e} of ms exceeded`,w.ETIMEDOUT))},e);const a=()=>{n&&(o&&clearTimeout(o),o=null,n.forEach(l=>{l.unsubscribe?l.unsubscribe(i):l.removeEventListener("abort",i)}),n=null)};n.forEach(l=>l.addEventListener("abort",i));const{signal:c}=s;return c.unsubscribe=()=>f.asap(a),c}},Bl=function*(n,e){let t=n.byteLength;if(t<e){yield n;return}let s=0,r;for(;s<t;)r=s+e,yield n.slice(s,r),s=r},Ul=async function*(n,e){for await(const t of Hl(n))yield*Bl(t,e)},Hl=async function*(n){if(n[Symbol.asyncIterator]){yield*n;return}const e=n.getReader();try{for(;;){const{done:t,value:s}=await e.read();if(t)break;yield s}}finally{await e.cancel()}},kr=(n,e,t,s)=>{const r=Ul(n,e);let i=0,o,a=c=>{o||(o=!0,s&&s(c))};return new ReadableStream({async pull(c){try{const{done:l,value:h}=await r.next();if(l){a(),c.close();return}let u=h.byteLength;if(t){let d=i+=u;t(d)}c.enqueue(new Uint8Array(h))}catch(l){throw a(l),l}},cancel(c){return a(c),r.return()}},{highWaterMark:2})},Tn=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",vo=Tn&&typeof ReadableStream=="function",Wl=Tn&&(typeof TextEncoder=="function"?(n=>e=>n.encode(e))(new TextEncoder):async n=>new Uint8Array(await new Response(n).arrayBuffer())),bo=(n,...e)=>{try{return!!n(...e)}catch{return!1}},ql=vo&&bo(()=>{let n=!1;const e=new Request(K.origin,{body:new ReadableStream,method:"POST",get duplex(){return n=!0,"half"}}).headers.has("Content-Type");return n&&!e}),Ar=64*1024,is=vo&&bo(()=>f.isReadableStream(new Response("").body)),en={stream:is&&(n=>n.body)};Tn&&(n=>{["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!en[e]&&(en[e]=f.isFunction(n[e])?t=>t[e]():(t,s)=>{throw new w(`Response type '${e}' is not supported`,w.ERR_NOT_SUPPORT,s)})})})(new Response);const Vl=async n=>{if(n==null)return 0;if(f.isBlob(n))return n.size;if(f.isSpecCompliantForm(n))return(await new Request(K.origin,{method:"POST",body:n}).arrayBuffer()).byteLength;if(f.isArrayBufferView(n)||f.isArrayBuffer(n))return n.byteLength;if(f.isURLSearchParams(n)&&(n=n+""),f.isString(n))return(await Wl(n)).byteLength},$l=async(n,e)=>{const t=f.toFiniteNumber(n.getContentLength());return t??Vl(e)},zl=Tn&&(async n=>{let{url:e,method:t,data:s,signal:r,cancelToken:i,timeout:o,onDownloadProgress:a,onUploadProgress:c,responseType:l,headers:h,withCredentials:u="same-origin",fetchOptions:d}=wo(n);l=l?(l+"").toLowerCase():"text";let _=Ml([r,i&&i.toAbortSignal()],o),p;const y=_&&_.unsubscribe&&(()=>{_.unsubscribe()});let g;try{if(c&&ql&&t!=="get"&&t!=="head"&&(g=await $l(h,s))!==0){let Y=new Request(e,{method:"POST",body:s,duplex:"half"}),ye;if(f.isFormData(s)&&(ye=Y.headers.get("content-type"))&&h.setContentType(ye),Y.body){const[Te,Mt]=Rr(g,Zt(Ir(c)));s=kr(Y.body,Ar,Te,Mt)}}f.isString(u)||(u=u?"include":"omit");const I="credentials"in Request.prototype;p=new Request(e,{...d,signal:_,method:t.toUpperCase(),headers:h.normalize().toJSON(),body:s,duplex:"half",credentials:I?u:void 0});let O=await fetch(p);const B=is&&(l==="stream"||l==="response");if(is&&(a||B&&y)){const Y={};["status","statusText","headers"].forEach(wr=>{Y[wr]=O[wr]});const ye=f.toFiniteNumber(O.headers.get("content-length")),[Te,Mt]=a&&Rr(ye,Zt(Ir(a),!0))||[];O=new Response(kr(O.body,Ar,Te,()=>{Mt&&Mt(),y&&y()}),Y)}l=l||"text";let se=await en[f.findKey(en,l)||"text"](O,n);return!B&&y&&y(),await new Promise((Y,ye)=>{yo(Y,ye,{data:se,headers:X.from(O.headers),status:O.status,statusText:O.statusText,config:n,request:p})})}catch(I){throw y&&y(),I&&I.name==="TypeError"&&/fetch/i.test(I.message)?Object.assign(new w("Network Error",w.ERR_NETWORK,n,p),{cause:I.cause||I}):w.from(I,I&&I.code,n,p)}}),os={http:ol,xhr:Fl,fetch:zl};f.forEach(os,(n,e)=>{if(n){try{Object.defineProperty(n,"name",{value:e})}catch{}Object.defineProperty(n,"adapterName",{value:e})}});const Or=n=>`- ${n}`,jl=n=>f.isFunction(n)||n===null||n===!1,Co={getAdapter:n=>{n=f.isArray(n)?n:[n];const{length:e}=n;let t,s;const r={};for(let i=0;i<e;i++){t=n[i];let o;if(s=t,!jl(t)&&(s=os[(o=String(t)).toLowerCase()],s===void 0))throw new w(`Unknown adapter '${o}'`);if(s)break;r[o||"#"+i]=s}if(!s){const i=Object.entries(r).map(([a,c])=>`adapter ${a} `+(c===!1?"is not supported by the environment":"is not available in the build"));let o=e?i.length>1?`since :
3
+ `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const s=new this(e);return t.forEach(r=>s.set(r)),s}static accessor(e){const s=(this[Tr]=this[Tr]={accessors:{}}).accessors,r=this.prototype;function i(o){const a=rt(o);s[a]||(Il(r,o),s[a]=!0)}return f.isArray(e)?e.forEach(i):i(e),this}};X.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);f.reduceDescriptors(X.prototype,({value:n},e)=>{let t=e[0].toUpperCase()+e.slice(1);return{get:()=>n,set(s){this[t]=s}}});f.freezeMethods(X);function Hn(n,e){const t=this||At,s=e||t,r=X.from(s.headers);let i=s.data;return f.forEach(n,function(a){i=a.call(t,i,r.normalize(),e?e.status:void 0)}),r.normalize(),i}function go(n){return!!(n&&n.__CANCEL__)}function Ze(n,e,t){w.call(this,n??"canceled",w.ERR_CANCELED,e,t),this.name="CanceledError"}f.inherits(Ze,w,{__CANCEL__:!0});function yo(n,e,t){const s=t.config.validateStatus;!t.status||!s||s(t.status)?n(t):e(new w("Request failed with status code "+t.status,[w.ERR_BAD_REQUEST,w.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function Nl(n){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(n);return e&&e[1]||""}function Al(n,e){n=n||10;const t=new Array(n),s=new Array(n);let r=0,i=0,o;return e=e!==void 0?e:1e3,function(c){const l=Date.now(),h=s[i];o||(o=l),t[r]=c,s[r]=l;let u=i,d=0;for(;u!==r;)d+=t[u++],u=u%n;if(r=(r+1)%n,r===i&&(i=(i+1)%n),l-o<e)return;const _=h&&l-h;return _?Math.round(d*1e3/_):void 0}}function kl(n,e){let t=0,s=1e3/e,r,i;const o=(l,h=Date.now())=>{t=h,r=null,i&&(clearTimeout(i),i=null),n.apply(null,l)};return[(...l)=>{const h=Date.now(),u=h-t;u>=s?o(l,h):(r=l,i||(i=setTimeout(()=>{i=null,o(r)},s-u)))},()=>r&&o(r)]}const Zt=(n,e,t=3)=>{let s=0;const r=Al(50,250);return kl(i=>{const o=i.loaded,a=i.lengthComputable?i.total:void 0,c=o-s,l=r(c),h=o<=a;s=o;const u={loaded:o,total:a,progress:a?o/a:void 0,bytes:c,rate:l||void 0,estimated:l&&a&&h?(a-o)/l:void 0,event:i,lengthComputable:a!=null,[e?"download":"upload"]:!0};n(u)},t)},Rr=(n,e)=>{const t=n!=null;return[s=>e[0]({lengthComputable:t,total:n,loaded:s}),e[1]]},Ir=n=>(...e)=>f.asap(()=>n(...e)),Ol=K.hasStandardBrowserEnv?((n,e)=>t=>(t=new URL(t,K.origin),n.protocol===t.protocol&&n.host===t.host&&(e||n.port===t.port)))(new URL(K.origin),K.navigator&&/(msie|trident)/i.test(K.navigator.userAgent)):()=>!0,xl=K.hasStandardBrowserEnv?{write(n,e,t,s,r,i){const o=[n+"="+encodeURIComponent(e)];f.isNumber(t)&&o.push("expires="+new Date(t).toGMTString()),f.isString(s)&&o.push("path="+s),f.isString(r)&&o.push("domain="+r),i===!0&&o.push("secure"),document.cookie=o.join("; ")},read(n){const e=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(n){this.write(n,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Pl(n){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(n)}function Dl(n,e){return e?n.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):n}function Eo(n,e,t){let s=!Pl(e);return n&&(s||t==!1)?Dl(n,e):e}const Nr=n=>n instanceof X?{...n}:n;function Pe(n,e){e=e||{};const t={};function s(l,h,u,d){return f.isPlainObject(l)&&f.isPlainObject(h)?f.merge.call({caseless:d},l,h):f.isPlainObject(h)?f.merge({},h):f.isArray(h)?h.slice():h}function r(l,h,u,d){if(f.isUndefined(h)){if(!f.isUndefined(l))return s(void 0,l,u,d)}else return s(l,h,u,d)}function i(l,h){if(!f.isUndefined(h))return s(void 0,h)}function o(l,h){if(f.isUndefined(h)){if(!f.isUndefined(l))return s(void 0,l)}else return s(void 0,h)}function a(l,h,u){if(u in e)return s(l,h);if(u in n)return s(void 0,l)}const c={url:i,method:i,data:i,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:a,headers:(l,h,u)=>r(Nr(l),Nr(h),u,!0)};return f.forEach(Object.keys(Object.assign({},n,e)),function(h){const u=c[h]||r,d=u(n[h],e[h],h);f.isUndefined(d)&&u!==a||(t[h]=d)}),t}const wo=n=>{const e=Pe({},n);let{data:t,withXSRFToken:s,xsrfHeaderName:r,xsrfCookieName:i,headers:o,auth:a}=e;e.headers=o=X.from(o),e.url=po(Eo(e.baseURL,e.url,e.allowAbsoluteUrls),n.params,n.paramsSerializer),a&&o.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):"")));let c;if(f.isFormData(t)){if(K.hasStandardBrowserEnv||K.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if((c=o.getContentType())!==!1){const[l,...h]=c?c.split(";").map(u=>u.trim()).filter(Boolean):[];o.setContentType([l||"multipart/form-data",...h].join("; "))}}if(K.hasStandardBrowserEnv&&(s&&f.isFunction(s)&&(s=s(e)),s||s!==!1&&Ol(e.url))){const l=r&&i&&xl.read(i);l&&o.set(r,l)}return e},Ll=typeof XMLHttpRequest<"u",Fl=Ll&&function(n){return new Promise(function(t,s){const r=wo(n);let i=r.data;const o=X.from(r.headers).normalize();let{responseType:a,onUploadProgress:c,onDownloadProgress:l}=r,h,u,d,_,p;function y(){_&&_(),p&&p(),r.cancelToken&&r.cancelToken.unsubscribe(h),r.signal&&r.signal.removeEventListener("abort",h)}let g=new XMLHttpRequest;g.open(r.method.toUpperCase(),r.url,!0),g.timeout=r.timeout;function I(){if(!g)return;const B=X.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),Y={data:!a||a==="text"||a==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:B,config:n,request:g};yo(function(Te){t(Te),y()},function(Te){s(Te),y()},Y),g=null}"onloadend"in g?g.onloadend=I:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(I)},g.onabort=function(){g&&(s(new w("Request aborted",w.ECONNABORTED,n,g)),g=null)},g.onerror=function(){s(new w("Network Error",w.ERR_NETWORK,n,g)),g=null},g.ontimeout=function(){let se=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const Y=r.transitional||_o;r.timeoutErrorMessage&&(se=r.timeoutErrorMessage),s(new w(se,Y.clarifyTimeoutError?w.ETIMEDOUT:w.ECONNABORTED,n,g)),g=null},i===void 0&&o.setContentType(null),"setRequestHeader"in g&&f.forEach(o.toJSON(),function(se,Y){g.setRequestHeader(Y,se)}),f.isUndefined(r.withCredentials)||(g.withCredentials=!!r.withCredentials),a&&a!=="json"&&(g.responseType=r.responseType),l&&([d,p]=Zt(l,!0),g.addEventListener("progress",d)),c&&g.upload&&([u,_]=Zt(c),g.upload.addEventListener("progress",u),g.upload.addEventListener("loadend",_)),(r.cancelToken||r.signal)&&(h=B=>{g&&(s(!B||B.type?new Ze(null,n,g):B),g.abort(),g=null)},r.cancelToken&&r.cancelToken.subscribe(h),r.signal&&(r.signal.aborted?h():r.signal.addEventListener("abort",h)));const O=Nl(r.url);if(O&&K.protocols.indexOf(O)===-1){s(new w("Unsupported protocol "+O+":",w.ERR_BAD_REQUEST,n));return}g.send(i||null)})},Ml=(n,e)=>{const{length:t}=n=n?n.filter(Boolean):[];if(e||t){let s=new AbortController,r;const i=function(l){if(!r){r=!0,a();const h=l instanceof Error?l:this.reason;s.abort(h instanceof w?h:new Ze(h instanceof Error?h.message:h))}};let o=e&&setTimeout(()=>{o=null,i(new w(`timeout ${e} of ms exceeded`,w.ETIMEDOUT))},e);const a=()=>{n&&(o&&clearTimeout(o),o=null,n.forEach(l=>{l.unsubscribe?l.unsubscribe(i):l.removeEventListener("abort",i)}),n=null)};n.forEach(l=>l.addEventListener("abort",i));const{signal:c}=s;return c.unsubscribe=()=>f.asap(a),c}},Bl=function*(n,e){let t=n.byteLength;if(t<e){yield n;return}let s=0,r;for(;s<t;)r=s+e,yield n.slice(s,r),s=r},Ul=async function*(n,e){for await(const t of Hl(n))yield*Bl(t,e)},Hl=async function*(n){if(n[Symbol.asyncIterator]){yield*n;return}const e=n.getReader();try{for(;;){const{done:t,value:s}=await e.read();if(t)break;yield s}}finally{await e.cancel()}},Ar=(n,e,t,s)=>{const r=Ul(n,e);let i=0,o,a=c=>{o||(o=!0,s&&s(c))};return new ReadableStream({async pull(c){try{const{done:l,value:h}=await r.next();if(l){a(),c.close();return}let u=h.byteLength;if(t){let d=i+=u;t(d)}c.enqueue(new Uint8Array(h))}catch(l){throw a(l),l}},cancel(c){return a(c),r.return()}},{highWaterMark:2})},Tn=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",vo=Tn&&typeof ReadableStream=="function",Wl=Tn&&(typeof TextEncoder=="function"?(n=>e=>n.encode(e))(new TextEncoder):async n=>new Uint8Array(await new Response(n).arrayBuffer())),bo=(n,...e)=>{try{return!!n(...e)}catch{return!1}},ql=vo&&bo(()=>{let n=!1;const e=new Request(K.origin,{body:new ReadableStream,method:"POST",get duplex(){return n=!0,"half"}}).headers.has("Content-Type");return n&&!e}),kr=64*1024,is=vo&&bo(()=>f.isReadableStream(new Response("").body)),en={stream:is&&(n=>n.body)};Tn&&(n=>{["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!en[e]&&(en[e]=f.isFunction(n[e])?t=>t[e]():(t,s)=>{throw new w(`Response type '${e}' is not supported`,w.ERR_NOT_SUPPORT,s)})})})(new Response);const Vl=async n=>{if(n==null)return 0;if(f.isBlob(n))return n.size;if(f.isSpecCompliantForm(n))return(await new Request(K.origin,{method:"POST",body:n}).arrayBuffer()).byteLength;if(f.isArrayBufferView(n)||f.isArrayBuffer(n))return n.byteLength;if(f.isURLSearchParams(n)&&(n=n+""),f.isString(n))return(await Wl(n)).byteLength},$l=async(n,e)=>{const t=f.toFiniteNumber(n.getContentLength());return t??Vl(e)},zl=Tn&&(async n=>{let{url:e,method:t,data:s,signal:r,cancelToken:i,timeout:o,onDownloadProgress:a,onUploadProgress:c,responseType:l,headers:h,withCredentials:u="same-origin",fetchOptions:d}=wo(n);l=l?(l+"").toLowerCase():"text";let _=Ml([r,i&&i.toAbortSignal()],o),p;const y=_&&_.unsubscribe&&(()=>{_.unsubscribe()});let g;try{if(c&&ql&&t!=="get"&&t!=="head"&&(g=await $l(h,s))!==0){let Y=new Request(e,{method:"POST",body:s,duplex:"half"}),ye;if(f.isFormData(s)&&(ye=Y.headers.get("content-type"))&&h.setContentType(ye),Y.body){const[Te,Mt]=Rr(g,Zt(Ir(c)));s=Ar(Y.body,kr,Te,Mt)}}f.isString(u)||(u=u?"include":"omit");const I="credentials"in Request.prototype;p=new Request(e,{...d,signal:_,method:t.toUpperCase(),headers:h.normalize().toJSON(),body:s,duplex:"half",credentials:I?u:void 0});let O=await fetch(p);const B=is&&(l==="stream"||l==="response");if(is&&(a||B&&y)){const Y={};["status","statusText","headers"].forEach(wr=>{Y[wr]=O[wr]});const ye=f.toFiniteNumber(O.headers.get("content-length")),[Te,Mt]=a&&Rr(ye,Zt(Ir(a),!0))||[];O=new Response(Ar(O.body,kr,Te,()=>{Mt&&Mt(),y&&y()}),Y)}l=l||"text";let se=await en[f.findKey(en,l)||"text"](O,n);return!B&&y&&y(),await new Promise((Y,ye)=>{yo(Y,ye,{data:se,headers:X.from(O.headers),status:O.status,statusText:O.statusText,config:n,request:p})})}catch(I){throw y&&y(),I&&I.name==="TypeError"&&/fetch/i.test(I.message)?Object.assign(new w("Network Error",w.ERR_NETWORK,n,p),{cause:I.cause||I}):w.from(I,I&&I.code,n,p)}}),os={http:ol,xhr:Fl,fetch:zl};f.forEach(os,(n,e)=>{if(n){try{Object.defineProperty(n,"name",{value:e})}catch{}Object.defineProperty(n,"adapterName",{value:e})}});const Or=n=>`- ${n}`,jl=n=>f.isFunction(n)||n===null||n===!1,Co={getAdapter:n=>{n=f.isArray(n)?n:[n];const{length:e}=n;let t,s;const r={};for(let i=0;i<e;i++){t=n[i];let o;if(s=t,!jl(t)&&(s=os[(o=String(t)).toLowerCase()],s===void 0))throw new w(`Unknown adapter '${o}'`);if(s)break;r[o||"#"+i]=s}if(!s){const i=Object.entries(r).map(([a,c])=>`adapter ${a} `+(c===!1?"is not supported by the environment":"is not available in the build"));let o=e?i.length>1?`since :
4
4
  `+i.map(Or).join(`
5
- `):" "+Or(i[0]):"as no adapter specified";throw new w("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return s},adapters:os};function Wn(n){if(n.cancelToken&&n.cancelToken.throwIfRequested(),n.signal&&n.signal.aborted)throw new Ze(null,n)}function xr(n){return Wn(n),n.headers=X.from(n.headers),n.data=Hn.call(n,n.transformRequest),["post","put","patch"].indexOf(n.method)!==-1&&n.headers.setContentType("application/x-www-form-urlencoded",!1),Co.getAdapter(n.adapter||kt.adapter)(n).then(function(s){return Wn(n),s.data=Hn.call(n,n.transformResponse,s),s.headers=X.from(s.headers),s},function(s){return go(s)||(Wn(n),s&&s.response&&(s.response.data=Hn.call(n,n.transformResponse,s.response),s.response.headers=X.from(s.response.headers))),Promise.reject(s)})}const So="1.8.4",Rn={};["object","boolean","number","function","string","symbol"].forEach((n,e)=>{Rn[n]=function(s){return typeof s===n||"a"+(e<1?"n ":" ")+n}});const Pr={};Rn.transitional=function(e,t,s){function r(i,o){return"[Axios v"+So+"] Transitional option '"+i+"'"+o+(s?". "+s:"")}return(i,o,a)=>{if(e===!1)throw new w(r(o," has been removed"+(t?" in "+t:"")),w.ERR_DEPRECATED);return t&&!Pr[o]&&(Pr[o]=!0,console.warn(r(o," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(i,o,a):!0}};Rn.spelling=function(e){return(t,s)=>(console.warn(`${s} is likely a misspelling of ${e}`),!0)};function Kl(n,e,t){if(typeof n!="object")throw new w("options must be an object",w.ERR_BAD_OPTION_VALUE);const s=Object.keys(n);let r=s.length;for(;r-- >0;){const i=s[r],o=e[i];if(o){const a=n[i],c=a===void 0||o(a,i,n);if(c!==!0)throw new w("option "+i+" must be "+c,w.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new w("Unknown option "+i,w.ERR_BAD_OPTION)}}const $t={assertOptions:Kl,validators:Rn},he=$t.validators;let xe=class{constructor(e){this.defaults=e,this.interceptors={request:new Sr,response:new Sr}}async request(e,t){try{return await this._request(e,t)}catch(s){if(s instanceof Error){let r={};Error.captureStackTrace?Error.captureStackTrace(r):r=new Error;const i=r.stack?r.stack.replace(/^.+\n/,""):"";try{s.stack?i&&!String(s.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(s.stack+=`
6
- `+i):s.stack=i}catch{}}throw s}}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=Pe(this.defaults,t);const{transitional:s,paramsSerializer:r,headers:i}=t;s!==void 0&&$t.assertOptions(s,{silentJSONParsing:he.transitional(he.boolean),forcedJSONParsing:he.transitional(he.boolean),clarifyTimeoutError:he.transitional(he.boolean)},!1),r!=null&&(f.isFunction(r)?t.paramsSerializer={serialize:r}:$t.assertOptions(r,{encode:he.function,serialize:he.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),$t.assertOptions(t,{baseUrl:he.spelling("baseURL"),withXsrfToken:he.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=i&&f.merge(i.common,i[t.method]);i&&f.forEach(["delete","get","head","post","put","patch","common"],p=>{delete i[p]}),t.headers=X.concat(o,i);const a=[];let c=!0;this.interceptors.request.forEach(function(y){typeof y.runWhen=="function"&&y.runWhen(t)===!1||(c=c&&y.synchronous,a.unshift(y.fulfilled,y.rejected))});const l=[];this.interceptors.response.forEach(function(y){l.push(y.fulfilled,y.rejected)});let h,u=0,d;if(!c){const p=[xr.bind(this),void 0];for(p.unshift.apply(p,a),p.push.apply(p,l),d=p.length,h=Promise.resolve(t);u<d;)h=h.then(p[u++],p[u++]);return h}d=a.length;let _=t;for(u=0;u<d;){const p=a[u++],y=a[u++];try{_=p(_)}catch(g){y.call(this,g);break}}try{h=xr.call(this,_)}catch(p){return Promise.reject(p)}for(u=0,d=l.length;u<d;)h=h.then(l[u++],l[u++]);return h}getUri(e){e=Pe(this.defaults,e);const t=Eo(e.baseURL,e.url,e.allowAbsoluteUrls);return po(t,e.params,e.paramsSerializer)}};f.forEach(["delete","get","head","options"],function(e){xe.prototype[e]=function(t,s){return this.request(Pe(s||{},{method:e,url:t,data:(s||{}).data}))}});f.forEach(["post","put","patch"],function(e){function t(s){return function(i,o,a){return this.request(Pe(a||{},{method:e,headers:s?{"Content-Type":"multipart/form-data"}:{},url:i,data:o}))}}xe.prototype[e]=t(),xe.prototype[e+"Form"]=t(!0)});let Gl=class To{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(i){t=i});const s=this;this.promise.then(r=>{if(!s._listeners)return;let i=s._listeners.length;for(;i-- >0;)s._listeners[i](r);s._listeners=null}),this.promise.then=r=>{let i;const o=new Promise(a=>{s.subscribe(a),i=a}).then(r);return o.cancel=function(){s.unsubscribe(i)},o},e(function(i,o,a){s.reason||(s.reason=new Ze(i,o,a),t(s.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=s=>{e.abort(s)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new To(function(r){e=r}),cancel:e}}};function Yl(n){return function(t){return n.apply(null,t)}}function Ql(n){return f.isObject(n)&&n.isAxiosError===!0}const as={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(as).forEach(([n,e])=>{as[e]=n});function Ro(n){const e=new xe(n),t=no(xe.prototype.request,e);return f.extend(t,xe.prototype,e,{allOwnKeys:!0}),f.extend(t,e,null,{allOwnKeys:!0}),t.create=function(r){return Ro(Pe(n,r))},t}const k=Ro(kt);k.Axios=xe;k.CanceledError=Ze;k.CancelToken=Gl;k.isCancel=go;k.VERSION=So;k.toFormData=Sn;k.AxiosError=w;k.Cancel=k.CanceledError;k.all=function(e){return Promise.all(e)};k.spread=Yl;k.isAxiosError=Ql;k.mergeConfig=Pe;k.AxiosHeaders=X;k.formToJSON=n=>mo(f.isHTMLForm(n)?new FormData(n):n);k.getAdapter=Co.getAdapter;k.HttpStatusCode=as;k.default=k;const{Axios:q_,AxiosError:V_,CanceledError:$_,isCancel:z_,CancelToken:j_,VERSION:K_,all:G_,Cancel:Y_,isAxiosError:Q_,spread:J_,toFormData:X_,AxiosHeaders:Z_,HttpStatusCode:em,formToJSON:tm,getAdapter:nm,mergeConfig:sm}=k,ue=Object.create(null);ue.open="0";ue.close="1";ue.ping="2";ue.pong="3";ue.message="4";ue.upgrade="5";ue.noop="6";const zt=Object.create(null);Object.keys(ue).forEach(n=>{zt[ue[n]]=n});const cs={type:"error",data:"parser error"},Io=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",No=typeof ArrayBuffer=="function",ko=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,Fs=({type:n,data:e},t,s)=>Io&&e instanceof Blob?t?s(e):Dr(e,s):No&&(e instanceof ArrayBuffer||ko(e))?t?s(e):Dr(new Blob([e]),s):s(ue[n]+(e||"")),Dr=(n,e)=>{const t=new FileReader;return t.onload=function(){const s=t.result.split(",")[1];e("b"+(s||""))},t.readAsDataURL(n)};function Lr(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}let qn;function Jl(n,e){if(Io&&n.data instanceof Blob)return n.data.arrayBuffer().then(Lr).then(e);if(No&&(n.data instanceof ArrayBuffer||ko(n.data)))return e(Lr(n.data));Fs(n,!1,t=>{qn||(qn=new TextEncoder),e(qn.encode(t))})}const Fr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ht=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n=0;n<Fr.length;n++)ht[Fr.charCodeAt(n)]=n;const Xl=n=>{let e=n.length*.75,t=n.length,s,r=0,i,o,a,c;n[n.length-1]==="="&&(e--,n[n.length-2]==="="&&e--);const l=new ArrayBuffer(e),h=new Uint8Array(l);for(s=0;s<t;s+=4)i=ht[n.charCodeAt(s)],o=ht[n.charCodeAt(s+1)],a=ht[n.charCodeAt(s+2)],c=ht[n.charCodeAt(s+3)],h[r++]=i<<2|o>>4,h[r++]=(o&15)<<4|a>>2,h[r++]=(a&3)<<6|c&63;return l},Zl=typeof ArrayBuffer=="function",Ms=(n,e)=>{if(typeof n!="string")return{type:"message",data:Ao(n,e)};const t=n.charAt(0);return t==="b"?{type:"message",data:eh(n.substring(1),e)}:zt[t]?n.length>1?{type:zt[t],data:n.substring(1)}:{type:zt[t]}:cs},eh=(n,e)=>{if(Zl){const t=Xl(n);return Ao(t,e)}else return{base64:!0,data:n}},Ao=(n,e)=>{switch(e){case"blob":return n instanceof Blob?n:new Blob([n]);case"arraybuffer":default:return n instanceof ArrayBuffer?n:n.buffer}},Oo="",th=(n,e)=>{const t=n.length,s=new Array(t);let r=0;n.forEach((i,o)=>{Fs(i,!1,a=>{s[o]=a,++r===t&&e(s.join(Oo))})})},nh=(n,e)=>{const t=n.split(Oo),s=[];for(let r=0;r<t.length;r++){const i=Ms(t[r],e);if(s.push(i),i.type==="error")break}return s};function sh(){return new TransformStream({transform(n,e){Jl(n,t=>{const s=t.length;let r;if(s<126)r=new Uint8Array(1),new DataView(r.buffer).setUint8(0,s);else if(s<65536){r=new Uint8Array(3);const i=new DataView(r.buffer);i.setUint8(0,126),i.setUint16(1,s)}else{r=new Uint8Array(9);const i=new DataView(r.buffer);i.setUint8(0,127),i.setBigUint64(1,BigInt(s))}n.data&&typeof n.data!="string"&&(r[0]|=128),e.enqueue(r),e.enqueue(t)})}})}let Vn;function Bt(n){return n.reduce((e,t)=>e+t.length,0)}function Ut(n,e){if(n[0].length===e)return n.shift();const t=new Uint8Array(e);let s=0;for(let r=0;r<e;r++)t[r]=n[0][s++],s===n[0].length&&(n.shift(),s=0);return n.length&&s<n[0].length&&(n[0]=n[0].slice(s)),t}function rh(n,e){Vn||(Vn=new TextDecoder);const t=[];let s=0,r=-1,i=!1;return new TransformStream({transform(o,a){for(t.push(o);;){if(s===0){if(Bt(t)<1)break;const c=Ut(t,1);i=(c[0]&128)===128,r=c[0]&127,r<126?s=3:r===126?s=1:s=2}else if(s===1){if(Bt(t)<2)break;const c=Ut(t,2);r=new DataView(c.buffer,c.byteOffset,c.length).getUint16(0),s=3}else if(s===2){if(Bt(t)<8)break;const c=Ut(t,8),l=new DataView(c.buffer,c.byteOffset,c.length),h=l.getUint32(0);if(h>Math.pow(2,21)-1){a.enqueue(cs);break}r=h*Math.pow(2,32)+l.getUint32(4),s=3}else{if(Bt(t)<r)break;const c=Ut(t,r);a.enqueue(Ms(i?c:Vn.decode(c),e)),s=0}if(r===0||r>n){a.enqueue(cs);break}}}})}const xo=4;function H(n){if(n)return ih(n)}function ih(n){for(var e in H.prototype)n[e]=H.prototype[e];return n}H.prototype.on=H.prototype.addEventListener=function(n,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(e),this};H.prototype.once=function(n,e){function t(){this.off(n,t),e.apply(this,arguments)}return t.fn=e,this.on(n,t),this};H.prototype.off=H.prototype.removeListener=H.prototype.removeAllListeners=H.prototype.removeEventListener=function(n,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+n];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var s,r=0;r<t.length;r++)if(s=t[r],s===e||s.fn===e){t.splice(r,1);break}return t.length===0&&delete this._callbacks["$"+n],this};H.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),t=this._callbacks["$"+n],s=1;s<arguments.length;s++)e[s-1]=arguments[s];if(t){t=t.slice(0);for(var s=0,r=t.length;s<r;++s)t[s].apply(this,e)}return this};H.prototype.emitReserved=H.prototype.emit;H.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]};H.prototype.hasListeners=function(n){return!!this.listeners(n).length};const In=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,t)=>t(e,0),ne=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),oh="arraybuffer";function Po(n,...e){return e.reduce((t,s)=>(n.hasOwnProperty(s)&&(t[s]=n[s]),t),{})}const ah=ne.setTimeout,ch=ne.clearTimeout;function Nn(n,e){e.useNativeTimers?(n.setTimeoutFn=ah.bind(ne),n.clearTimeoutFn=ch.bind(ne)):(n.setTimeoutFn=ne.setTimeout.bind(ne),n.clearTimeoutFn=ne.clearTimeout.bind(ne))}const lh=1.33;function hh(n){return typeof n=="string"?uh(n):Math.ceil((n.byteLength||n.size)*lh)}function uh(n){let e=0,t=0;for(let s=0,r=n.length;s<r;s++)e=n.charCodeAt(s),e<128?t+=1:e<2048?t+=2:e<55296||e>=57344?t+=3:(s++,t+=4);return t}function Do(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function dh(n){let e="";for(let t in n)n.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(n[t]));return e}function fh(n){let e={},t=n.split("&");for(let s=0,r=t.length;s<r;s++){let i=t[s].split("=");e[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return e}class ph extends Error{constructor(e,t,s){super(e),this.description=t,this.context=s,this.type="TransportError"}}class Bs extends H{constructor(e){super(),this.writable=!1,Nn(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,s){return super.emitReserved("error",new ph(e,t,s)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=Ms(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){const e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){const t=dh(e);return t.length?"?"+t:""}}class _h extends Bs{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";const t=()=>{this.readyState="paused",e()};if(this._polling||!this.writable){let s=0;this._polling&&(s++,this.once("pollComplete",function(){--s||t()})),this.writable||(s++,this.once("drain",function(){--s||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){const t=s=>{if(this.readyState==="opening"&&s.type==="open"&&this.onOpen(),s.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(s)};nh(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,th(e,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",t=this.query||{};return this.opts.timestampRequests!==!1&&(t[this.opts.timestampParam]=Do()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}}let Lo=!1;try{Lo=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const mh=Lo;function gh(){}class yh extends _h{constructor(e){if(super(e),typeof location<"u"){const t=location.protocol==="https:";let s=location.port;s||(s=t?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||s!==e.port}}doWrite(e,t){const s=this.request({method:"POST",data:e});s.on("success",t),s.on("error",(r,i)=>{this.onError("xhr post error",r,i)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(t,s)=>{this.onError("xhr poll error",t,s)}),this.pollXhr=e}}let Ve=class jt extends H{constructor(e,t,s){super(),this.createRequest=e,Nn(this,s),this._opts=s,this._method=s.method||"GET",this._uri=t,this._data=s.data!==void 0?s.data:null,this._create()}_create(){var e;const t=Po(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this._opts.xd;const s=this._xhr=this.createRequest(t);try{s.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){s.setDisableHeaderCheck&&s.setDisableHeaderCheck(!0);for(let r in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(r)&&s.setRequestHeader(r,this._opts.extraHeaders[r])}}catch{}if(this._method==="POST")try{s.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{s.setRequestHeader("Accept","*/*")}catch{}(e=this._opts.cookieJar)===null||e===void 0||e.addCookies(s),"withCredentials"in s&&(s.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(s.timeout=this._opts.requestTimeout),s.onreadystatechange=()=>{var r;s.readyState===3&&((r=this._opts.cookieJar)===null||r===void 0||r.parseCookies(s.getResponseHeader("set-cookie"))),s.readyState===4&&(s.status===200||s.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof s.status=="number"?s.status:0)},0))},s.send(this._data)}catch(r){this.setTimeoutFn(()=>{this._onError(r)},0);return}typeof document<"u"&&(this._index=jt.requestsCount++,jt.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(e){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=gh,e)try{this._xhr.abort()}catch{}typeof document<"u"&&delete jt.requests[this._index],this._xhr=null}}_onLoad(){const e=this._xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}};Ve.requestsCount=0;Ve.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Mr);else if(typeof addEventListener=="function"){const n="onpagehide"in ne?"pagehide":"unload";addEventListener(n,Mr,!1)}}function Mr(){for(let n in Ve.requests)Ve.requests.hasOwnProperty(n)&&Ve.requests[n].abort()}const Eh=function(){const n=Fo({xdomain:!1});return n&&n.responseType!==null}();class wh extends yh{constructor(e){super(e);const t=e&&e.forceBase64;this.supportsBinary=Eh&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new Ve(Fo,this.uri(),e)}}function Fo(n){const e=n.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||mh))return new XMLHttpRequest}catch{}if(!e)try{return new ne[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const Mo=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class vh extends Bs{get name(){return"websocket"}doOpen(){const e=this.uri(),t=this.opts.protocols,s=Mo?{}:Po(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(s.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,s)}catch(r){return this.emitReserved("error",r)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const s=e[t],r=t===e.length-1;Fs(s,this.supportsBinary,i=>{try{this.doWrite(s,i)}catch{}r&&In(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=Do()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}}const $n=ne.WebSocket||ne.MozWebSocket;class bh extends vh{createSocket(e,t,s){return Mo?new $n(e,t,s):t?new $n(e,t):new $n(e)}doWrite(e,t){this.ws.send(t)}}class Ch extends Bs{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{const t=rh(Number.MAX_SAFE_INTEGER,this.socket.binaryType),s=e.readable.pipeThrough(t).getReader(),r=sh();r.readable.pipeTo(e.writable),this._writer=r.writable.getWriter();const i=()=>{s.read().then(({done:a,value:c})=>{a||(this.onPacket(c),i())}).catch(a=>{})};i();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this._writer.write(o).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const s=e[t],r=t===e.length-1;this._writer.write(s).then(()=>{r&&In(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}}const Sh={websocket:bh,webtransport:Ch,polling:wh},Th=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Rh=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function ls(n){if(n.length>8e3)throw"URI too long";const e=n,t=n.indexOf("["),s=n.indexOf("]");t!=-1&&s!=-1&&(n=n.substring(0,t)+n.substring(t,s).replace(/:/g,";")+n.substring(s,n.length));let r=Th.exec(n||""),i={},o=14;for(;o--;)i[Rh[o]]=r[o]||"";return t!=-1&&s!=-1&&(i.source=e,i.host=i.host.substring(1,i.host.length-1).replace(/;/g,":"),i.authority=i.authority.replace("[","").replace("]","").replace(/;/g,":"),i.ipv6uri=!0),i.pathNames=Ih(i,i.path),i.queryKey=Nh(i,i.query),i}function Ih(n,e){const t=/\/{2,9}/g,s=e.replace(t,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&s.splice(0,1),e.slice(-1)=="/"&&s.splice(s.length-1,1),s}function Nh(n,e){const t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(s,r,i){r&&(t[r]=i)}),t}const hs=typeof addEventListener=="function"&&typeof removeEventListener=="function",Kt=[];hs&&addEventListener("offline",()=>{Kt.forEach(n=>n())},!1);class Ee extends H{constructor(e,t){if(super(),this.binaryType=oh,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e=="object"&&(t=e,e=null),e){const s=ls(e);t.hostname=s.host,t.secure=s.protocol==="https"||s.protocol==="wss",t.port=s.port,s.query&&(t.query=s.query)}else t.host&&(t.hostname=ls(t.host).host);Nn(this,t),this.secure=t.secure!=null?t.secure:typeof location<"u"&&location.protocol==="https:",t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=t.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},t.transports.forEach(s=>{const r=s.prototype.name;this.transports.push(r),this._transportsByName[r]=s}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=fh(this.opts.query)),hs&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},Kt.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){const t=Object.assign({},this.opts.query);t.EIO=xo,t.transport=e,this.id&&(t.sid=this.id);const s=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](s)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const e=this.opts.rememberUpgrade&&Ee.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const t=this.createTransport(e);t.open(),this.setTransport(t)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",t=>this._onClose("transport close",t))}onOpen(){this.readyState="open",Ee.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const t=new Error("server error");t.code=e.data,this._onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let s=0;s<this.writeBuffer.length;s++){const r=this.writeBuffer[s].data;if(r&&(t+=hh(r)),s>0&&t>this._maxPayload)return this.writeBuffer.slice(0,s);t+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,In(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,t,s){return this._sendPacket("message",e,t,s),this}send(e,t,s){return this._sendPacket("message",e,t,s),this}_sendPacket(e,t,s,r){if(typeof t=="function"&&(r=t,t=void 0),typeof s=="function"&&(r=s,s=null),this.readyState==="closing"||this.readyState==="closed")return;s=s||{},s.compress=s.compress!==!1;const i={type:e,data:t,options:s};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),r&&this.once("flush",r),this.flush()}close(){const e=()=>{this._onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},s=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?s():e()}):this.upgrading?s():e()),this}_onError(e){if(Ee.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),hs&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const s=Kt.indexOf(this._offlineEventListener);s!==-1&&Kt.splice(s,1)}this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this._prevBufferLen=0}}}Ee.protocol=xo;class kh extends Ee{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let t=this.createTransport(e),s=!1;Ee.priorWebsocketSuccess=!1;const r=()=>{s||(t.send([{type:"ping",data:"probe"}]),t.once("packet",u=>{if(!s)if(u.type==="pong"&&u.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;Ee.priorWebsocketSuccess=t.name==="websocket",this.transport.pause(()=>{s||this.readyState!=="closed"&&(h(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{const d=new Error("probe error");d.transport=t.name,this.emitReserved("upgradeError",d)}}))};function i(){s||(s=!0,h(),t.close(),t=null)}const o=u=>{const d=new Error("probe error: "+u);d.transport=t.name,i(),this.emitReserved("upgradeError",d)};function a(){o("transport closed")}function c(){o("socket closed")}function l(u){t&&u.name!==t.name&&i()}const h=()=>{t.removeListener("open",r),t.removeListener("error",o),t.removeListener("close",a),this.off("close",c),this.off("upgrading",l)};t.once("open",r),t.once("error",o),t.once("close",a),this.once("close",c),this.once("upgrading",l),this._upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{s||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){const t=[];for(let s=0;s<e.length;s++)~this.transports.indexOf(e[s])&&t.push(e[s]);return t}}let Ah=class extends kh{constructor(e,t={}){const s=typeof e=="object"?e:t;(!s.transports||s.transports&&typeof s.transports[0]=="string")&&(s.transports=(s.transports||["polling","websocket","webtransport"]).map(r=>Sh[r]).filter(r=>!!r)),super(e,s)}};function Oh(n,e="",t){let s=n;t=t||typeof location<"u"&&location,n==null&&(n=t.protocol+"//"+t.host),typeof n=="string"&&(n.charAt(0)==="/"&&(n.charAt(1)==="/"?n=t.protocol+n:n=t.host+n),/^(https?|wss?):\/\//.test(n)||(typeof t<"u"?n=t.protocol+"//"+n:n="https://"+n),s=ls(n)),s.port||(/^(http|ws)$/.test(s.protocol)?s.port="80":/^(http|ws)s$/.test(s.protocol)&&(s.port="443")),s.path=s.path||"/";const i=s.host.indexOf(":")!==-1?"["+s.host+"]":s.host;return s.id=s.protocol+"://"+i+":"+s.port+e,s.href=s.protocol+"://"+i+(t&&t.port===s.port?"":":"+s.port),s}const xh=typeof ArrayBuffer=="function",Ph=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,Bo=Object.prototype.toString,Dh=typeof Blob=="function"||typeof Blob<"u"&&Bo.call(Blob)==="[object BlobConstructor]",Lh=typeof File=="function"||typeof File<"u"&&Bo.call(File)==="[object FileConstructor]";function Us(n){return xh&&(n instanceof ArrayBuffer||Ph(n))||Dh&&n instanceof Blob||Lh&&n instanceof File}function Gt(n,e){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let t=0,s=n.length;t<s;t++)if(Gt(n[t]))return!0;return!1}if(Us(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return Gt(n.toJSON(),!0);for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t)&&Gt(n[t]))return!0;return!1}function Fh(n){const e=[],t=n.data,s=n;return s.data=us(t,e),s.attachments=e.length,{packet:s,buffers:e}}function us(n,e){if(!n)return n;if(Us(n)){const t={_placeholder:!0,num:e.length};return e.push(n),t}else if(Array.isArray(n)){const t=new Array(n.length);for(let s=0;s<n.length;s++)t[s]=us(n[s],e);return t}else if(typeof n=="object"&&!(n instanceof Date)){const t={};for(const s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=us(n[s],e));return t}return n}function Mh(n,e){return n.data=ds(n.data,e),delete n.attachments,n}function ds(n,e){if(!n)return n;if(n&&n._placeholder===!0){if(typeof n.num=="number"&&n.num>=0&&n.num<e.length)return e[n.num];throw new Error("illegal attachments")}else if(Array.isArray(n))for(let t=0;t<n.length;t++)n[t]=ds(n[t],e);else if(typeof n=="object")for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&(n[t]=ds(n[t],e));return n}const Bh=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],Uh=5;var T;(function(n){n[n.CONNECT=0]="CONNECT",n[n.DISCONNECT=1]="DISCONNECT",n[n.EVENT=2]="EVENT",n[n.ACK=3]="ACK",n[n.CONNECT_ERROR=4]="CONNECT_ERROR",n[n.BINARY_EVENT=5]="BINARY_EVENT",n[n.BINARY_ACK=6]="BINARY_ACK"})(T||(T={}));class Hh{constructor(e){this.replacer=e}encode(e){return(e.type===T.EVENT||e.type===T.ACK)&&Gt(e)?this.encodeAsBinary({type:e.type===T.EVENT?T.BINARY_EVENT:T.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=""+e.type;return(e.type===T.BINARY_EVENT||e.type===T.BINARY_ACK)&&(t+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(t+=e.nsp+","),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){const t=Fh(e),s=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(s),r}}function Br(n){return Object.prototype.toString.call(n)==="[object Object]"}class Hs extends H{constructor(e){super(),this.reviver=e}add(e){let t;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);const s=t.type===T.BINARY_EVENT;s||t.type===T.BINARY_ACK?(t.type=s?T.EVENT:T.ACK,this.reconstructor=new Wh(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(Us(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let t=0;const s={type:Number(e.charAt(0))};if(T[s.type]===void 0)throw new Error("unknown packet type "+s.type);if(s.type===T.BINARY_EVENT||s.type===T.BINARY_ACK){const i=t+1;for(;e.charAt(++t)!=="-"&&t!=e.length;);const o=e.substring(i,t);if(o!=Number(o)||e.charAt(t)!=="-")throw new Error("Illegal attachments");s.attachments=Number(o)}if(e.charAt(t+1)==="/"){const i=t+1;for(;++t&&!(e.charAt(t)===","||t===e.length););s.nsp=e.substring(i,t)}else s.nsp="/";const r=e.charAt(t+1);if(r!==""&&Number(r)==r){const i=t+1;for(;++t;){const o=e.charAt(t);if(o==null||Number(o)!=o){--t;break}if(t===e.length)break}s.id=Number(e.substring(i,t+1))}if(e.charAt(++t)){const i=this.tryParse(e.substr(t));if(Hs.isPayloadValid(s.type,i))s.data=i;else throw new Error("invalid payload")}return s}tryParse(e){try{return JSON.parse(e,this.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case T.CONNECT:return Br(t);case T.DISCONNECT:return t===void 0;case T.CONNECT_ERROR:return typeof t=="string"||Br(t);case T.EVENT:case T.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&Bh.indexOf(t[0])===-1);case T.ACK:case T.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class Wh{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const t=Mh(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const qh=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Hs,Encoder:Hh,get PacketType(){return T},protocol:Uh},Symbol.toStringTag,{value:"Module"}));function re(n,e,t){return n.on(e,t),function(){n.off(e,t)}}const Vh=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Uo extends H{constructor(e,t,s){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,s&&s.auth&&(this.auth=s.auth),this._opts=Object.assign({},s),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[re(e,"open",this.onopen.bind(this)),re(e,"packet",this.onpacket.bind(this)),re(e,"error",this.onerror.bind(this)),re(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){var s,r,i;if(Vh.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const o={type:T.EVENT,data:t};if(o.options={},o.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){const h=this.ids++,u=t.pop();this._registerAckCallback(h,u),o.id=h}const a=(r=(s=this.io.engine)===null||s===void 0?void 0:s.transport)===null||r===void 0?void 0:r.writable,c=this.connected&&!(!((i=this.io.engine)===null||i===void 0)&&i._hasPingExpired());return this.flags.volatile&&!a||(c?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(e,t){var s;const r=(s=this.flags.timeout)!==null&&s!==void 0?s:this._opts.ackTimeout;if(r===void 0){this.acks[e]=t;return}const i=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let a=0;a<this.sendBuffer.length;a++)this.sendBuffer[a].id===e&&this.sendBuffer.splice(a,1);t.call(this,new Error("operation has timed out"))},r),o=(...a)=>{this.io.clearTimeoutFn(i),t.apply(this,a)};o.withError=!0,this.acks[e]=o}emitWithAck(e,...t){return new Promise((s,r)=>{const i=(o,a)=>o?r(o):s(a);i.withError=!0,t.push(i),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]=="function"&&(t=e.pop());const s={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((r,...i)=>s!==this._queue[0]?void 0:(r!==null?s.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(r)):(this._queue.shift(),t&&t(null,...i)),s.pending=!1,this._drainQueue())),this._queue.push(s),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;const t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:T.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(s=>String(s.id)===e)){const s=this.acks[e];delete this.acks[e],s.withError&&s.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case T.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case T.EVENT:case T.BINARY_EVENT:this.onevent(e);break;case T.ACK:case T.BINARY_ACK:this.onack(e);break;case T.DISCONNECT:this.ondisconnect();break;case T.CONNECT_ERROR:this.destroy();const s=new Error(e.data.message);s.data=e.data.data,this.emitReserved("connect_error",s);break}}onevent(e){const t=e.data||[];e.id!=null&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const s of t)s.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){const t=this;let s=!1;return function(...r){s||(s=!0,t.packet({type:T.ACK,id:e,data:r}))}}onack(e){const t=this.acks[e.id];typeof t=="function"&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:T.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const t=this._anyListeners;for(let s=0;s<t.length;s++)if(e===t[s])return t.splice(s,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const t=this._anyOutgoingListeners;for(let s=0;s<t.length;s++)if(e===t[s])return t.splice(s,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const s of t)s.apply(this,e.data)}}}function et(n){n=n||{},this.ms=n.min||100,this.max=n.max||1e4,this.factor=n.factor||2,this.jitter=n.jitter>0&&n.jitter<=1?n.jitter:0,this.attempts=0}et.prototype.duration=function(){var n=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),t=Math.floor(e*this.jitter*n);n=(Math.floor(e*10)&1)==0?n-t:n+t}return Math.min(n,this.max)|0};et.prototype.reset=function(){this.attempts=0};et.prototype.setMin=function(n){this.ms=n};et.prototype.setMax=function(n){this.max=n};et.prototype.setJitter=function(n){this.jitter=n};class fs extends H{constructor(e,t){var s;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(t=e,e=void 0),t=t||{},t.path=t.path||"/socket.io",this.opts=t,Nn(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor((s=t.randomizationFactor)!==null&&s!==void 0?s:.5),this.backoff=new et({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;const r=t.parser||qh;this.encoder=new r.Encoder,this.decoder=new r.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)===null||t===void 0||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)===null||t===void 0||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)===null||t===void 0||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new Ah(this.uri,this.opts);const t=this.engine,s=this;this._readyState="opening",this.skipReconnect=!1;const r=re(t,"open",function(){s.onopen(),e&&e()}),i=a=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",a),e?e(a):this.maybeReconnectOnOpen()},o=re(t,"error",i);if(this._timeout!==!1){const a=this._timeout,c=this.setTimeoutFn(()=>{r(),i(new Error("timeout")),t.close()},a);this.opts.autoUnref&&c.unref(),this.subs.push(()=>{this.clearTimeoutFn(c)})}return this.subs.push(r),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(re(e,"ping",this.onping.bind(this)),re(e,"data",this.ondata.bind(this)),re(e,"error",this.onerror.bind(this)),re(e,"close",this.onclose.bind(this)),re(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(t){this.onclose("parse error",t)}}ondecoded(e){In(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let s=this.nsps[e];return s?this._autoConnect&&!s.active&&s.connect():(s=new Uo(this,e,t),this.nsps[e]=s),s}_destroy(e){const t=Object.keys(this.nsps);for(const s of t)if(this.nsps[s].active)return;this._close()}_packet(e){const t=this.encoder.encode(e);for(let s=0;s<t.length;s++)this.engine.write(t[s],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,t){var s;this.cleanup(),(s=this.engine)===null||s===void 0||s.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();this._reconnecting=!0;const s=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(r=>{r?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",r)):e.onreconnect()}))},t);this.opts.autoUnref&&s.unref(),this.subs.push(()=>{this.clearTimeoutFn(s)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const it={};function Yt(n,e){typeof n=="object"&&(e=n,n=void 0),e=e||{};const t=Oh(n,e.path||"/socket.io"),s=t.source,r=t.id,i=t.path,o=it[r]&&i in it[r].nsps,a=e.forceNew||e["force new connection"]||e.multiplex===!1||o;let c;return a?c=new fs(s,e):(it[r]||(it[r]=new fs(s,e)),c=it[r]),t.query&&!e.query&&(e.query=t.queryKey),c.socket(t.path,e)}Object.assign(Yt,{Manager:fs,Socket:Uo,io:Yt,connect:Yt});const $h=()=>{};/**
5
+ `):" "+Or(i[0]):"as no adapter specified";throw new w("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return s},adapters:os};function Wn(n){if(n.cancelToken&&n.cancelToken.throwIfRequested(),n.signal&&n.signal.aborted)throw new Ze(null,n)}function xr(n){return Wn(n),n.headers=X.from(n.headers),n.data=Hn.call(n,n.transformRequest),["post","put","patch"].indexOf(n.method)!==-1&&n.headers.setContentType("application/x-www-form-urlencoded",!1),Co.getAdapter(n.adapter||At.adapter)(n).then(function(s){return Wn(n),s.data=Hn.call(n,n.transformResponse,s),s.headers=X.from(s.headers),s},function(s){return go(s)||(Wn(n),s&&s.response&&(s.response.data=Hn.call(n,n.transformResponse,s.response),s.response.headers=X.from(s.response.headers))),Promise.reject(s)})}const So="1.8.4",Rn={};["object","boolean","number","function","string","symbol"].forEach((n,e)=>{Rn[n]=function(s){return typeof s===n||"a"+(e<1?"n ":" ")+n}});const Pr={};Rn.transitional=function(e,t,s){function r(i,o){return"[Axios v"+So+"] Transitional option '"+i+"'"+o+(s?". "+s:"")}return(i,o,a)=>{if(e===!1)throw new w(r(o," has been removed"+(t?" in "+t:"")),w.ERR_DEPRECATED);return t&&!Pr[o]&&(Pr[o]=!0,console.warn(r(o," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(i,o,a):!0}};Rn.spelling=function(e){return(t,s)=>(console.warn(`${s} is likely a misspelling of ${e}`),!0)};function Kl(n,e,t){if(typeof n!="object")throw new w("options must be an object",w.ERR_BAD_OPTION_VALUE);const s=Object.keys(n);let r=s.length;for(;r-- >0;){const i=s[r],o=e[i];if(o){const a=n[i],c=a===void 0||o(a,i,n);if(c!==!0)throw new w("option "+i+" must be "+c,w.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new w("Unknown option "+i,w.ERR_BAD_OPTION)}}const $t={assertOptions:Kl,validators:Rn},he=$t.validators;let xe=class{constructor(e){this.defaults=e,this.interceptors={request:new Sr,response:new Sr}}async request(e,t){try{return await this._request(e,t)}catch(s){if(s instanceof Error){let r={};Error.captureStackTrace?Error.captureStackTrace(r):r=new Error;const i=r.stack?r.stack.replace(/^.+\n/,""):"";try{s.stack?i&&!String(s.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(s.stack+=`
6
+ `+i):s.stack=i}catch{}}throw s}}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=Pe(this.defaults,t);const{transitional:s,paramsSerializer:r,headers:i}=t;s!==void 0&&$t.assertOptions(s,{silentJSONParsing:he.transitional(he.boolean),forcedJSONParsing:he.transitional(he.boolean),clarifyTimeoutError:he.transitional(he.boolean)},!1),r!=null&&(f.isFunction(r)?t.paramsSerializer={serialize:r}:$t.assertOptions(r,{encode:he.function,serialize:he.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),$t.assertOptions(t,{baseUrl:he.spelling("baseURL"),withXsrfToken:he.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=i&&f.merge(i.common,i[t.method]);i&&f.forEach(["delete","get","head","post","put","patch","common"],p=>{delete i[p]}),t.headers=X.concat(o,i);const a=[];let c=!0;this.interceptors.request.forEach(function(y){typeof y.runWhen=="function"&&y.runWhen(t)===!1||(c=c&&y.synchronous,a.unshift(y.fulfilled,y.rejected))});const l=[];this.interceptors.response.forEach(function(y){l.push(y.fulfilled,y.rejected)});let h,u=0,d;if(!c){const p=[xr.bind(this),void 0];for(p.unshift.apply(p,a),p.push.apply(p,l),d=p.length,h=Promise.resolve(t);u<d;)h=h.then(p[u++],p[u++]);return h}d=a.length;let _=t;for(u=0;u<d;){const p=a[u++],y=a[u++];try{_=p(_)}catch(g){y.call(this,g);break}}try{h=xr.call(this,_)}catch(p){return Promise.reject(p)}for(u=0,d=l.length;u<d;)h=h.then(l[u++],l[u++]);return h}getUri(e){e=Pe(this.defaults,e);const t=Eo(e.baseURL,e.url,e.allowAbsoluteUrls);return po(t,e.params,e.paramsSerializer)}};f.forEach(["delete","get","head","options"],function(e){xe.prototype[e]=function(t,s){return this.request(Pe(s||{},{method:e,url:t,data:(s||{}).data}))}});f.forEach(["post","put","patch"],function(e){function t(s){return function(i,o,a){return this.request(Pe(a||{},{method:e,headers:s?{"Content-Type":"multipart/form-data"}:{},url:i,data:o}))}}xe.prototype[e]=t(),xe.prototype[e+"Form"]=t(!0)});let Gl=class To{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(i){t=i});const s=this;this.promise.then(r=>{if(!s._listeners)return;let i=s._listeners.length;for(;i-- >0;)s._listeners[i](r);s._listeners=null}),this.promise.then=r=>{let i;const o=new Promise(a=>{s.subscribe(a),i=a}).then(r);return o.cancel=function(){s.unsubscribe(i)},o},e(function(i,o,a){s.reason||(s.reason=new Ze(i,o,a),t(s.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=s=>{e.abort(s)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new To(function(r){e=r}),cancel:e}}};function Yl(n){return function(t){return n.apply(null,t)}}function Ql(n){return f.isObject(n)&&n.isAxiosError===!0}const as={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(as).forEach(([n,e])=>{as[e]=n});function Ro(n){const e=new xe(n),t=no(xe.prototype.request,e);return f.extend(t,xe.prototype,e,{allOwnKeys:!0}),f.extend(t,e,null,{allOwnKeys:!0}),t.create=function(r){return Ro(Pe(n,r))},t}const A=Ro(At);A.Axios=xe;A.CanceledError=Ze;A.CancelToken=Gl;A.isCancel=go;A.VERSION=So;A.toFormData=Sn;A.AxiosError=w;A.Cancel=A.CanceledError;A.all=function(e){return Promise.all(e)};A.spread=Yl;A.isAxiosError=Ql;A.mergeConfig=Pe;A.AxiosHeaders=X;A.formToJSON=n=>mo(f.isHTMLForm(n)?new FormData(n):n);A.getAdapter=Co.getAdapter;A.HttpStatusCode=as;A.default=A;const{Axios:q_,AxiosError:V_,CanceledError:$_,isCancel:z_,CancelToken:j_,VERSION:K_,all:G_,Cancel:Y_,isAxiosError:Q_,spread:J_,toFormData:X_,AxiosHeaders:Z_,HttpStatusCode:em,formToJSON:tm,getAdapter:nm,mergeConfig:sm}=A,ue=Object.create(null);ue.open="0";ue.close="1";ue.ping="2";ue.pong="3";ue.message="4";ue.upgrade="5";ue.noop="6";const zt=Object.create(null);Object.keys(ue).forEach(n=>{zt[ue[n]]=n});const cs={type:"error",data:"parser error"},Io=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",No=typeof ArrayBuffer=="function",Ao=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,Fs=({type:n,data:e},t,s)=>Io&&e instanceof Blob?t?s(e):Dr(e,s):No&&(e instanceof ArrayBuffer||Ao(e))?t?s(e):Dr(new Blob([e]),s):s(ue[n]+(e||"")),Dr=(n,e)=>{const t=new FileReader;return t.onload=function(){const s=t.result.split(",")[1];e("b"+(s||""))},t.readAsDataURL(n)};function Lr(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}let qn;function Jl(n,e){if(Io&&n.data instanceof Blob)return n.data.arrayBuffer().then(Lr).then(e);if(No&&(n.data instanceof ArrayBuffer||Ao(n.data)))return e(Lr(n.data));Fs(n,!1,t=>{qn||(qn=new TextEncoder),e(qn.encode(t))})}const Fr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ht=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n=0;n<Fr.length;n++)ht[Fr.charCodeAt(n)]=n;const Xl=n=>{let e=n.length*.75,t=n.length,s,r=0,i,o,a,c;n[n.length-1]==="="&&(e--,n[n.length-2]==="="&&e--);const l=new ArrayBuffer(e),h=new Uint8Array(l);for(s=0;s<t;s+=4)i=ht[n.charCodeAt(s)],o=ht[n.charCodeAt(s+1)],a=ht[n.charCodeAt(s+2)],c=ht[n.charCodeAt(s+3)],h[r++]=i<<2|o>>4,h[r++]=(o&15)<<4|a>>2,h[r++]=(a&3)<<6|c&63;return l},Zl=typeof ArrayBuffer=="function",Ms=(n,e)=>{if(typeof n!="string")return{type:"message",data:ko(n,e)};const t=n.charAt(0);return t==="b"?{type:"message",data:eh(n.substring(1),e)}:zt[t]?n.length>1?{type:zt[t],data:n.substring(1)}:{type:zt[t]}:cs},eh=(n,e)=>{if(Zl){const t=Xl(n);return ko(t,e)}else return{base64:!0,data:n}},ko=(n,e)=>{switch(e){case"blob":return n instanceof Blob?n:new Blob([n]);case"arraybuffer":default:return n instanceof ArrayBuffer?n:n.buffer}},Oo="",th=(n,e)=>{const t=n.length,s=new Array(t);let r=0;n.forEach((i,o)=>{Fs(i,!1,a=>{s[o]=a,++r===t&&e(s.join(Oo))})})},nh=(n,e)=>{const t=n.split(Oo),s=[];for(let r=0;r<t.length;r++){const i=Ms(t[r],e);if(s.push(i),i.type==="error")break}return s};function sh(){return new TransformStream({transform(n,e){Jl(n,t=>{const s=t.length;let r;if(s<126)r=new Uint8Array(1),new DataView(r.buffer).setUint8(0,s);else if(s<65536){r=new Uint8Array(3);const i=new DataView(r.buffer);i.setUint8(0,126),i.setUint16(1,s)}else{r=new Uint8Array(9);const i=new DataView(r.buffer);i.setUint8(0,127),i.setBigUint64(1,BigInt(s))}n.data&&typeof n.data!="string"&&(r[0]|=128),e.enqueue(r),e.enqueue(t)})}})}let Vn;function Bt(n){return n.reduce((e,t)=>e+t.length,0)}function Ut(n,e){if(n[0].length===e)return n.shift();const t=new Uint8Array(e);let s=0;for(let r=0;r<e;r++)t[r]=n[0][s++],s===n[0].length&&(n.shift(),s=0);return n.length&&s<n[0].length&&(n[0]=n[0].slice(s)),t}function rh(n,e){Vn||(Vn=new TextDecoder);const t=[];let s=0,r=-1,i=!1;return new TransformStream({transform(o,a){for(t.push(o);;){if(s===0){if(Bt(t)<1)break;const c=Ut(t,1);i=(c[0]&128)===128,r=c[0]&127,r<126?s=3:r===126?s=1:s=2}else if(s===1){if(Bt(t)<2)break;const c=Ut(t,2);r=new DataView(c.buffer,c.byteOffset,c.length).getUint16(0),s=3}else if(s===2){if(Bt(t)<8)break;const c=Ut(t,8),l=new DataView(c.buffer,c.byteOffset,c.length),h=l.getUint32(0);if(h>Math.pow(2,21)-1){a.enqueue(cs);break}r=h*Math.pow(2,32)+l.getUint32(4),s=3}else{if(Bt(t)<r)break;const c=Ut(t,r);a.enqueue(Ms(i?c:Vn.decode(c),e)),s=0}if(r===0||r>n){a.enqueue(cs);break}}}})}const xo=4;function H(n){if(n)return ih(n)}function ih(n){for(var e in H.prototype)n[e]=H.prototype[e];return n}H.prototype.on=H.prototype.addEventListener=function(n,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(e),this};H.prototype.once=function(n,e){function t(){this.off(n,t),e.apply(this,arguments)}return t.fn=e,this.on(n,t),this};H.prototype.off=H.prototype.removeListener=H.prototype.removeAllListeners=H.prototype.removeEventListener=function(n,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+n];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var s,r=0;r<t.length;r++)if(s=t[r],s===e||s.fn===e){t.splice(r,1);break}return t.length===0&&delete this._callbacks["$"+n],this};H.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),t=this._callbacks["$"+n],s=1;s<arguments.length;s++)e[s-1]=arguments[s];if(t){t=t.slice(0);for(var s=0,r=t.length;s<r;++s)t[s].apply(this,e)}return this};H.prototype.emitReserved=H.prototype.emit;H.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]};H.prototype.hasListeners=function(n){return!!this.listeners(n).length};const In=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,t)=>t(e,0),ne=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),oh="arraybuffer";function Po(n,...e){return e.reduce((t,s)=>(n.hasOwnProperty(s)&&(t[s]=n[s]),t),{})}const ah=ne.setTimeout,ch=ne.clearTimeout;function Nn(n,e){e.useNativeTimers?(n.setTimeoutFn=ah.bind(ne),n.clearTimeoutFn=ch.bind(ne)):(n.setTimeoutFn=ne.setTimeout.bind(ne),n.clearTimeoutFn=ne.clearTimeout.bind(ne))}const lh=1.33;function hh(n){return typeof n=="string"?uh(n):Math.ceil((n.byteLength||n.size)*lh)}function uh(n){let e=0,t=0;for(let s=0,r=n.length;s<r;s++)e=n.charCodeAt(s),e<128?t+=1:e<2048?t+=2:e<55296||e>=57344?t+=3:(s++,t+=4);return t}function Do(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function dh(n){let e="";for(let t in n)n.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(n[t]));return e}function fh(n){let e={},t=n.split("&");for(let s=0,r=t.length;s<r;s++){let i=t[s].split("=");e[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return e}class ph extends Error{constructor(e,t,s){super(e),this.description=t,this.context=s,this.type="TransportError"}}class Bs extends H{constructor(e){super(),this.writable=!1,Nn(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,s){return super.emitReserved("error",new ph(e,t,s)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=Ms(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){const e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){const t=dh(e);return t.length?"?"+t:""}}class _h extends Bs{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";const t=()=>{this.readyState="paused",e()};if(this._polling||!this.writable){let s=0;this._polling&&(s++,this.once("pollComplete",function(){--s||t()})),this.writable||(s++,this.once("drain",function(){--s||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){const t=s=>{if(this.readyState==="opening"&&s.type==="open"&&this.onOpen(),s.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(s)};nh(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,th(e,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",t=this.query||{};return this.opts.timestampRequests!==!1&&(t[this.opts.timestampParam]=Do()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}}let Lo=!1;try{Lo=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const mh=Lo;function gh(){}class yh extends _h{constructor(e){if(super(e),typeof location<"u"){const t=location.protocol==="https:";let s=location.port;s||(s=t?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||s!==e.port}}doWrite(e,t){const s=this.request({method:"POST",data:e});s.on("success",t),s.on("error",(r,i)=>{this.onError("xhr post error",r,i)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(t,s)=>{this.onError("xhr poll error",t,s)}),this.pollXhr=e}}let Ve=class jt extends H{constructor(e,t,s){super(),this.createRequest=e,Nn(this,s),this._opts=s,this._method=s.method||"GET",this._uri=t,this._data=s.data!==void 0?s.data:null,this._create()}_create(){var e;const t=Po(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this._opts.xd;const s=this._xhr=this.createRequest(t);try{s.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){s.setDisableHeaderCheck&&s.setDisableHeaderCheck(!0);for(let r in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(r)&&s.setRequestHeader(r,this._opts.extraHeaders[r])}}catch{}if(this._method==="POST")try{s.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{s.setRequestHeader("Accept","*/*")}catch{}(e=this._opts.cookieJar)===null||e===void 0||e.addCookies(s),"withCredentials"in s&&(s.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(s.timeout=this._opts.requestTimeout),s.onreadystatechange=()=>{var r;s.readyState===3&&((r=this._opts.cookieJar)===null||r===void 0||r.parseCookies(s.getResponseHeader("set-cookie"))),s.readyState===4&&(s.status===200||s.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof s.status=="number"?s.status:0)},0))},s.send(this._data)}catch(r){this.setTimeoutFn(()=>{this._onError(r)},0);return}typeof document<"u"&&(this._index=jt.requestsCount++,jt.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(e){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=gh,e)try{this._xhr.abort()}catch{}typeof document<"u"&&delete jt.requests[this._index],this._xhr=null}}_onLoad(){const e=this._xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}};Ve.requestsCount=0;Ve.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Mr);else if(typeof addEventListener=="function"){const n="onpagehide"in ne?"pagehide":"unload";addEventListener(n,Mr,!1)}}function Mr(){for(let n in Ve.requests)Ve.requests.hasOwnProperty(n)&&Ve.requests[n].abort()}const Eh=function(){const n=Fo({xdomain:!1});return n&&n.responseType!==null}();class wh extends yh{constructor(e){super(e);const t=e&&e.forceBase64;this.supportsBinary=Eh&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new Ve(Fo,this.uri(),e)}}function Fo(n){const e=n.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||mh))return new XMLHttpRequest}catch{}if(!e)try{return new ne[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const Mo=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class vh extends Bs{get name(){return"websocket"}doOpen(){const e=this.uri(),t=this.opts.protocols,s=Mo?{}:Po(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(s.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,s)}catch(r){return this.emitReserved("error",r)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const s=e[t],r=t===e.length-1;Fs(s,this.supportsBinary,i=>{try{this.doWrite(s,i)}catch{}r&&In(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=Do()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}}const $n=ne.WebSocket||ne.MozWebSocket;class bh extends vh{createSocket(e,t,s){return Mo?new $n(e,t,s):t?new $n(e,t):new $n(e)}doWrite(e,t){this.ws.send(t)}}class Ch extends Bs{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{const t=rh(Number.MAX_SAFE_INTEGER,this.socket.binaryType),s=e.readable.pipeThrough(t).getReader(),r=sh();r.readable.pipeTo(e.writable),this._writer=r.writable.getWriter();const i=()=>{s.read().then(({done:a,value:c})=>{a||(this.onPacket(c),i())}).catch(a=>{})};i();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this._writer.write(o).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const s=e[t],r=t===e.length-1;this._writer.write(s).then(()=>{r&&In(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}}const Sh={websocket:bh,webtransport:Ch,polling:wh},Th=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Rh=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function ls(n){if(n.length>8e3)throw"URI too long";const e=n,t=n.indexOf("["),s=n.indexOf("]");t!=-1&&s!=-1&&(n=n.substring(0,t)+n.substring(t,s).replace(/:/g,";")+n.substring(s,n.length));let r=Th.exec(n||""),i={},o=14;for(;o--;)i[Rh[o]]=r[o]||"";return t!=-1&&s!=-1&&(i.source=e,i.host=i.host.substring(1,i.host.length-1).replace(/;/g,":"),i.authority=i.authority.replace("[","").replace("]","").replace(/;/g,":"),i.ipv6uri=!0),i.pathNames=Ih(i,i.path),i.queryKey=Nh(i,i.query),i}function Ih(n,e){const t=/\/{2,9}/g,s=e.replace(t,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&s.splice(0,1),e.slice(-1)=="/"&&s.splice(s.length-1,1),s}function Nh(n,e){const t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(s,r,i){r&&(t[r]=i)}),t}const hs=typeof addEventListener=="function"&&typeof removeEventListener=="function",Kt=[];hs&&addEventListener("offline",()=>{Kt.forEach(n=>n())},!1);class Ee extends H{constructor(e,t){if(super(),this.binaryType=oh,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e=="object"&&(t=e,e=null),e){const s=ls(e);t.hostname=s.host,t.secure=s.protocol==="https"||s.protocol==="wss",t.port=s.port,s.query&&(t.query=s.query)}else t.host&&(t.hostname=ls(t.host).host);Nn(this,t),this.secure=t.secure!=null?t.secure:typeof location<"u"&&location.protocol==="https:",t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=t.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},t.transports.forEach(s=>{const r=s.prototype.name;this.transports.push(r),this._transportsByName[r]=s}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=fh(this.opts.query)),hs&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},Kt.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){const t=Object.assign({},this.opts.query);t.EIO=xo,t.transport=e,this.id&&(t.sid=this.id);const s=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](s)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const e=this.opts.rememberUpgrade&&Ee.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const t=this.createTransport(e);t.open(),this.setTransport(t)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",t=>this._onClose("transport close",t))}onOpen(){this.readyState="open",Ee.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const t=new Error("server error");t.code=e.data,this._onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let s=0;s<this.writeBuffer.length;s++){const r=this.writeBuffer[s].data;if(r&&(t+=hh(r)),s>0&&t>this._maxPayload)return this.writeBuffer.slice(0,s);t+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,In(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,t,s){return this._sendPacket("message",e,t,s),this}send(e,t,s){return this._sendPacket("message",e,t,s),this}_sendPacket(e,t,s,r){if(typeof t=="function"&&(r=t,t=void 0),typeof s=="function"&&(r=s,s=null),this.readyState==="closing"||this.readyState==="closed")return;s=s||{},s.compress=s.compress!==!1;const i={type:e,data:t,options:s};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),r&&this.once("flush",r),this.flush()}close(){const e=()=>{this._onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},s=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?s():e()}):this.upgrading?s():e()),this}_onError(e){if(Ee.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),hs&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const s=Kt.indexOf(this._offlineEventListener);s!==-1&&Kt.splice(s,1)}this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this._prevBufferLen=0}}}Ee.protocol=xo;class Ah extends Ee{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let t=this.createTransport(e),s=!1;Ee.priorWebsocketSuccess=!1;const r=()=>{s||(t.send([{type:"ping",data:"probe"}]),t.once("packet",u=>{if(!s)if(u.type==="pong"&&u.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;Ee.priorWebsocketSuccess=t.name==="websocket",this.transport.pause(()=>{s||this.readyState!=="closed"&&(h(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{const d=new Error("probe error");d.transport=t.name,this.emitReserved("upgradeError",d)}}))};function i(){s||(s=!0,h(),t.close(),t=null)}const o=u=>{const d=new Error("probe error: "+u);d.transport=t.name,i(),this.emitReserved("upgradeError",d)};function a(){o("transport closed")}function c(){o("socket closed")}function l(u){t&&u.name!==t.name&&i()}const h=()=>{t.removeListener("open",r),t.removeListener("error",o),t.removeListener("close",a),this.off("close",c),this.off("upgrading",l)};t.once("open",r),t.once("error",o),t.once("close",a),this.once("close",c),this.once("upgrading",l),this._upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{s||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){const t=[];for(let s=0;s<e.length;s++)~this.transports.indexOf(e[s])&&t.push(e[s]);return t}}let kh=class extends Ah{constructor(e,t={}){const s=typeof e=="object"?e:t;(!s.transports||s.transports&&typeof s.transports[0]=="string")&&(s.transports=(s.transports||["polling","websocket","webtransport"]).map(r=>Sh[r]).filter(r=>!!r)),super(e,s)}};function Oh(n,e="",t){let s=n;t=t||typeof location<"u"&&location,n==null&&(n=t.protocol+"//"+t.host),typeof n=="string"&&(n.charAt(0)==="/"&&(n.charAt(1)==="/"?n=t.protocol+n:n=t.host+n),/^(https?|wss?):\/\//.test(n)||(typeof t<"u"?n=t.protocol+"//"+n:n="https://"+n),s=ls(n)),s.port||(/^(http|ws)$/.test(s.protocol)?s.port="80":/^(http|ws)s$/.test(s.protocol)&&(s.port="443")),s.path=s.path||"/";const i=s.host.indexOf(":")!==-1?"["+s.host+"]":s.host;return s.id=s.protocol+"://"+i+":"+s.port+e,s.href=s.protocol+"://"+i+(t&&t.port===s.port?"":":"+s.port),s}const xh=typeof ArrayBuffer=="function",Ph=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,Bo=Object.prototype.toString,Dh=typeof Blob=="function"||typeof Blob<"u"&&Bo.call(Blob)==="[object BlobConstructor]",Lh=typeof File=="function"||typeof File<"u"&&Bo.call(File)==="[object FileConstructor]";function Us(n){return xh&&(n instanceof ArrayBuffer||Ph(n))||Dh&&n instanceof Blob||Lh&&n instanceof File}function Gt(n,e){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let t=0,s=n.length;t<s;t++)if(Gt(n[t]))return!0;return!1}if(Us(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return Gt(n.toJSON(),!0);for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t)&&Gt(n[t]))return!0;return!1}function Fh(n){const e=[],t=n.data,s=n;return s.data=us(t,e),s.attachments=e.length,{packet:s,buffers:e}}function us(n,e){if(!n)return n;if(Us(n)){const t={_placeholder:!0,num:e.length};return e.push(n),t}else if(Array.isArray(n)){const t=new Array(n.length);for(let s=0;s<n.length;s++)t[s]=us(n[s],e);return t}else if(typeof n=="object"&&!(n instanceof Date)){const t={};for(const s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=us(n[s],e));return t}return n}function Mh(n,e){return n.data=ds(n.data,e),delete n.attachments,n}function ds(n,e){if(!n)return n;if(n&&n._placeholder===!0){if(typeof n.num=="number"&&n.num>=0&&n.num<e.length)return e[n.num];throw new Error("illegal attachments")}else if(Array.isArray(n))for(let t=0;t<n.length;t++)n[t]=ds(n[t],e);else if(typeof n=="object")for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&(n[t]=ds(n[t],e));return n}const Bh=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],Uh=5;var T;(function(n){n[n.CONNECT=0]="CONNECT",n[n.DISCONNECT=1]="DISCONNECT",n[n.EVENT=2]="EVENT",n[n.ACK=3]="ACK",n[n.CONNECT_ERROR=4]="CONNECT_ERROR",n[n.BINARY_EVENT=5]="BINARY_EVENT",n[n.BINARY_ACK=6]="BINARY_ACK"})(T||(T={}));class Hh{constructor(e){this.replacer=e}encode(e){return(e.type===T.EVENT||e.type===T.ACK)&&Gt(e)?this.encodeAsBinary({type:e.type===T.EVENT?T.BINARY_EVENT:T.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=""+e.type;return(e.type===T.BINARY_EVENT||e.type===T.BINARY_ACK)&&(t+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(t+=e.nsp+","),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){const t=Fh(e),s=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(s),r}}function Br(n){return Object.prototype.toString.call(n)==="[object Object]"}class Hs extends H{constructor(e){super(),this.reviver=e}add(e){let t;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);const s=t.type===T.BINARY_EVENT;s||t.type===T.BINARY_ACK?(t.type=s?T.EVENT:T.ACK,this.reconstructor=new Wh(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(Us(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let t=0;const s={type:Number(e.charAt(0))};if(T[s.type]===void 0)throw new Error("unknown packet type "+s.type);if(s.type===T.BINARY_EVENT||s.type===T.BINARY_ACK){const i=t+1;for(;e.charAt(++t)!=="-"&&t!=e.length;);const o=e.substring(i,t);if(o!=Number(o)||e.charAt(t)!=="-")throw new Error("Illegal attachments");s.attachments=Number(o)}if(e.charAt(t+1)==="/"){const i=t+1;for(;++t&&!(e.charAt(t)===","||t===e.length););s.nsp=e.substring(i,t)}else s.nsp="/";const r=e.charAt(t+1);if(r!==""&&Number(r)==r){const i=t+1;for(;++t;){const o=e.charAt(t);if(o==null||Number(o)!=o){--t;break}if(t===e.length)break}s.id=Number(e.substring(i,t+1))}if(e.charAt(++t)){const i=this.tryParse(e.substr(t));if(Hs.isPayloadValid(s.type,i))s.data=i;else throw new Error("invalid payload")}return s}tryParse(e){try{return JSON.parse(e,this.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case T.CONNECT:return Br(t);case T.DISCONNECT:return t===void 0;case T.CONNECT_ERROR:return typeof t=="string"||Br(t);case T.EVENT:case T.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&Bh.indexOf(t[0])===-1);case T.ACK:case T.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class Wh{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const t=Mh(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const qh=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Hs,Encoder:Hh,get PacketType(){return T},protocol:Uh},Symbol.toStringTag,{value:"Module"}));function re(n,e,t){return n.on(e,t),function(){n.off(e,t)}}const Vh=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Uo extends H{constructor(e,t,s){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,s&&s.auth&&(this.auth=s.auth),this._opts=Object.assign({},s),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[re(e,"open",this.onopen.bind(this)),re(e,"packet",this.onpacket.bind(this)),re(e,"error",this.onerror.bind(this)),re(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){var s,r,i;if(Vh.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const o={type:T.EVENT,data:t};if(o.options={},o.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){const h=this.ids++,u=t.pop();this._registerAckCallback(h,u),o.id=h}const a=(r=(s=this.io.engine)===null||s===void 0?void 0:s.transport)===null||r===void 0?void 0:r.writable,c=this.connected&&!(!((i=this.io.engine)===null||i===void 0)&&i._hasPingExpired());return this.flags.volatile&&!a||(c?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(e,t){var s;const r=(s=this.flags.timeout)!==null&&s!==void 0?s:this._opts.ackTimeout;if(r===void 0){this.acks[e]=t;return}const i=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let a=0;a<this.sendBuffer.length;a++)this.sendBuffer[a].id===e&&this.sendBuffer.splice(a,1);t.call(this,new Error("operation has timed out"))},r),o=(...a)=>{this.io.clearTimeoutFn(i),t.apply(this,a)};o.withError=!0,this.acks[e]=o}emitWithAck(e,...t){return new Promise((s,r)=>{const i=(o,a)=>o?r(o):s(a);i.withError=!0,t.push(i),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]=="function"&&(t=e.pop());const s={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((r,...i)=>s!==this._queue[0]?void 0:(r!==null?s.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(r)):(this._queue.shift(),t&&t(null,...i)),s.pending=!1,this._drainQueue())),this._queue.push(s),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;const t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:T.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(s=>String(s.id)===e)){const s=this.acks[e];delete this.acks[e],s.withError&&s.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case T.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case T.EVENT:case T.BINARY_EVENT:this.onevent(e);break;case T.ACK:case T.BINARY_ACK:this.onack(e);break;case T.DISCONNECT:this.ondisconnect();break;case T.CONNECT_ERROR:this.destroy();const s=new Error(e.data.message);s.data=e.data.data,this.emitReserved("connect_error",s);break}}onevent(e){const t=e.data||[];e.id!=null&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const s of t)s.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){const t=this;let s=!1;return function(...r){s||(s=!0,t.packet({type:T.ACK,id:e,data:r}))}}onack(e){const t=this.acks[e.id];typeof t=="function"&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:T.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const t=this._anyListeners;for(let s=0;s<t.length;s++)if(e===t[s])return t.splice(s,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const t=this._anyOutgoingListeners;for(let s=0;s<t.length;s++)if(e===t[s])return t.splice(s,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const s of t)s.apply(this,e.data)}}}function et(n){n=n||{},this.ms=n.min||100,this.max=n.max||1e4,this.factor=n.factor||2,this.jitter=n.jitter>0&&n.jitter<=1?n.jitter:0,this.attempts=0}et.prototype.duration=function(){var n=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),t=Math.floor(e*this.jitter*n);n=(Math.floor(e*10)&1)==0?n-t:n+t}return Math.min(n,this.max)|0};et.prototype.reset=function(){this.attempts=0};et.prototype.setMin=function(n){this.ms=n};et.prototype.setMax=function(n){this.max=n};et.prototype.setJitter=function(n){this.jitter=n};class fs extends H{constructor(e,t){var s;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(t=e,e=void 0),t=t||{},t.path=t.path||"/socket.io",this.opts=t,Nn(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor((s=t.randomizationFactor)!==null&&s!==void 0?s:.5),this.backoff=new et({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;const r=t.parser||qh;this.encoder=new r.Encoder,this.decoder=new r.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)===null||t===void 0||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)===null||t===void 0||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)===null||t===void 0||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new kh(this.uri,this.opts);const t=this.engine,s=this;this._readyState="opening",this.skipReconnect=!1;const r=re(t,"open",function(){s.onopen(),e&&e()}),i=a=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",a),e?e(a):this.maybeReconnectOnOpen()},o=re(t,"error",i);if(this._timeout!==!1){const a=this._timeout,c=this.setTimeoutFn(()=>{r(),i(new Error("timeout")),t.close()},a);this.opts.autoUnref&&c.unref(),this.subs.push(()=>{this.clearTimeoutFn(c)})}return this.subs.push(r),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(re(e,"ping",this.onping.bind(this)),re(e,"data",this.ondata.bind(this)),re(e,"error",this.onerror.bind(this)),re(e,"close",this.onclose.bind(this)),re(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(t){this.onclose("parse error",t)}}ondecoded(e){In(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let s=this.nsps[e];return s?this._autoConnect&&!s.active&&s.connect():(s=new Uo(this,e,t),this.nsps[e]=s),s}_destroy(e){const t=Object.keys(this.nsps);for(const s of t)if(this.nsps[s].active)return;this._close()}_packet(e){const t=this.encoder.encode(e);for(let s=0;s<t.length;s++)this.engine.write(t[s],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,t){var s;this.cleanup(),(s=this.engine)===null||s===void 0||s.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();this._reconnecting=!0;const s=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(r=>{r?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",r)):e.onreconnect()}))},t);this.opts.autoUnref&&s.unref(),this.subs.push(()=>{this.clearTimeoutFn(s)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const it={};function Yt(n,e){typeof n=="object"&&(e=n,n=void 0),e=e||{};const t=Oh(n,e.path||"/socket.io"),s=t.source,r=t.id,i=t.path,o=it[r]&&i in it[r].nsps,a=e.forceNew||e["force new connection"]||e.multiplex===!1||o;let c;return a?c=new fs(s,e):(it[r]||(it[r]=new fs(s,e)),c=it[r]),t.query&&!e.query&&(e.query=t.queryKey),c.socket(t.path,e)}Object.assign(Yt,{Manager:fs,Socket:Uo,io:Yt,connect:Yt});const $h=()=>{};/**
7
7
  * @license
8
8
  * Copyright 2017 Google LLC
9
9
  *
@@ -153,7 +153,7 @@
153
153
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
154
154
  * See the License for the specific language governing permissions and
155
155
  * limitations under the License.
156
- */const au="FirebaseError";class At extends Error{constructor(e,t,s){super(t),this.code=e,this.customData=s,this.name=au,Object.setPrototypeOf(this,At.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,Ko.prototype.create)}}class Ko{constructor(e,t,s){this.service=e,this.serviceName=t,this.errors=s}create(e,...t){const s=t[0]||{},r=`${this.service}/${e}`,i=this.errors[e],o=i?cu(i,s):"Error",a=`${this.serviceName}: ${o} (${r}).`;return new At(r,a,s)}}function cu(n,e){return n.replace(lu,(t,s)=>{const r=e[s];return r!=null?String(r):`<${s}?>`})}const lu=/\{\$([^}]+)}/g;/**
156
+ */const au="FirebaseError";class kt extends Error{constructor(e,t,s){super(t),this.code=e,this.customData=s,this.name=au,Object.setPrototypeOf(this,kt.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,Ko.prototype.create)}}class Ko{constructor(e,t,s){this.service=e,this.serviceName=t,this.errors=s}create(e,...t){const s=t[0]||{},r=`${this.service}/${e}`,i=this.errors[e],o=i?cu(i,s):"Error",a=`${this.serviceName}: ${o} (${r}).`;return new kt(r,a,s)}}function cu(n,e){return n.replace(lu,(t,s)=>{const r=e[s];return r!=null?String(r):`<${s}?>`})}const lu=/\{\$([^}]+)}/g;/**
157
157
  * @license
158
158
  * Copyright 2017 Google LLC
159
159
  *
@@ -243,7 +243,7 @@
243
243
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
244
244
  * See the License for the specific language governing permissions and
245
245
  * limitations under the License.
246
- */const pu=function(n){const e=[];let t=0;for(let s=0;s<n.length;s++){let r=n.charCodeAt(s);if(r>=55296&&r<=56319){const i=r-55296;s++,m(s<n.length,"Surrogate pair missing trail surrogate.");const o=n.charCodeAt(s)-56320;r=65536+(i<<10)+o}r<128?e[t++]=r:r<2048?(e[t++]=r>>6|192,e[t++]=r&63|128):r<65536?(e[t++]=r>>12|224,e[t++]=r>>6&63|128,e[t++]=r&63|128):(e[t++]=r>>18|240,e[t++]=r>>12&63|128,e[t++]=r>>6&63|128,e[t++]=r&63|128)}return e},kn=function(n){let e=0;for(let t=0;t<n.length;t++){const s=n.charCodeAt(t);s<128?e++:s<2048?e+=2:s>=55296&&s<=56319?(e+=4,t++):e+=3}return e};/**
246
+ */const pu=function(n){const e=[];let t=0;for(let s=0;s<n.length;s++){let r=n.charCodeAt(s);if(r>=55296&&r<=56319){const i=r-55296;s++,m(s<n.length,"Surrogate pair missing trail surrogate.");const o=n.charCodeAt(s)-56320;r=65536+(i<<10)+o}r<128?e[t++]=r:r<2048?(e[t++]=r>>6|192,e[t++]=r&63|128):r<65536?(e[t++]=r>>12|224,e[t++]=r>>6&63|128,e[t++]=r&63|128):(e[t++]=r>>18|240,e[t++]=r>>12&63|128,e[t++]=r>>6&63|128,e[t++]=r&63|128)}return e},An=function(n){let e=0;for(let t=0;t<n.length;t++){const s=n.charCodeAt(t);s<128?e++:s<2048?e+=2:s>=55296&&s<=56319?(e+=4,t++):e+=3}return e};/**
247
247
  * @license
248
248
  * Copyright 2021 Google LLC
249
249
  *
@@ -258,7 +258,7 @@
258
258
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
259
259
  * See the License for the specific language governing permissions and
260
260
  * limitations under the License.
261
- */function An(n){return n&&n._delegate?n._delegate:n}class Et{constructor(e,t,s){this.name=e,this.instanceFactory=t,this.type=s,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}}/**
261
+ */function kn(n){return n&&n._delegate?n._delegate:n}class Et{constructor(e,t,s){this.name=e,this.instanceFactory=t,this.type=s,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}}/**
262
262
  * @license
263
263
  * Copyright 2019 Google LLC
264
264
  *
@@ -318,7 +318,7 @@
318
318
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
319
319
  * See the License for the specific language governing permissions and
320
320
  * limitations under the License.
321
- */var L;(function(n){n[n.DEBUG=0]="DEBUG",n[n.VERBOSE=1]="VERBOSE",n[n.INFO=2]="INFO",n[n.WARN=3]="WARN",n[n.ERROR=4]="ERROR",n[n.SILENT=5]="SILENT"})(L||(L={}));const Eu={debug:L.DEBUG,verbose:L.VERBOSE,info:L.INFO,warn:L.WARN,error:L.ERROR,silent:L.SILENT},wu=L.INFO,vu={[L.DEBUG]:"log",[L.VERBOSE]:"log",[L.INFO]:"info",[L.WARN]:"warn",[L.ERROR]:"error"},bu=(n,e,...t)=>{if(e<n.logLevel)return;const s=new Date().toISOString(),r=vu[e];if(r)console[r](`[${s}] ${n.name}:`,...t);else throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`)};class Qo{constructor(e){this.name=e,this._logLevel=wu,this._logHandler=bu,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in L))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel=typeof e=="string"?Eu[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if(typeof e!="function")throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...e){this._userLogHandler&&this._userLogHandler(this,L.DEBUG,...e),this._logHandler(this,L.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,L.VERBOSE,...e),this._logHandler(this,L.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,L.INFO,...e),this._logHandler(this,L.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,L.WARN,...e),this._logHandler(this,L.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,L.ERROR,...e),this._logHandler(this,L.ERROR,...e)}}const Cu=(n,e)=>e.some(t=>n instanceof t);let Wr,qr;function Su(){return Wr||(Wr=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Tu(){return qr||(qr=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const Jo=new WeakMap,_s=new WeakMap,Xo=new WeakMap,zn=new WeakMap,Vs=new WeakMap;function Ru(n){const e=new Promise((t,s)=>{const r=()=>{n.removeEventListener("success",i),n.removeEventListener("error",o)},i=()=>{t(we(n.result)),r()},o=()=>{s(n.error),r()};n.addEventListener("success",i),n.addEventListener("error",o)});return e.then(t=>{t instanceof IDBCursor&&Jo.set(t,n)}).catch(()=>{}),Vs.set(e,n),e}function Iu(n){if(_s.has(n))return;const e=new Promise((t,s)=>{const r=()=>{n.removeEventListener("complete",i),n.removeEventListener("error",o),n.removeEventListener("abort",o)},i=()=>{t(),r()},o=()=>{s(n.error||new DOMException("AbortError","AbortError")),r()};n.addEventListener("complete",i),n.addEventListener("error",o),n.addEventListener("abort",o)});_s.set(n,e)}let ms={get(n,e,t){if(n instanceof IDBTransaction){if(e==="done")return _s.get(n);if(e==="objectStoreNames")return n.objectStoreNames||Xo.get(n);if(e==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return we(n[e])},set(n,e,t){return n[e]=t,!0},has(n,e){return n instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in n}};function Nu(n){ms=n(ms)}function ku(n){return n===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...t){const s=n.call(jn(this),e,...t);return Xo.set(s,e.sort?e.sort():[e]),we(s)}:Tu().includes(n)?function(...e){return n.apply(jn(this),e),we(Jo.get(this))}:function(...e){return we(n.apply(jn(this),e))}}function Au(n){return typeof n=="function"?ku(n):(n instanceof IDBTransaction&&Iu(n),Cu(n,Su())?new Proxy(n,ms):n)}function we(n){if(n instanceof IDBRequest)return Ru(n);if(zn.has(n))return zn.get(n);const e=Au(n);return e!==n&&(zn.set(n,e),Vs.set(e,n)),e}const jn=n=>Vs.get(n);function Ou(n,e,{blocked:t,upgrade:s,blocking:r,terminated:i}={}){const o=indexedDB.open(n,e),a=we(o);return s&&o.addEventListener("upgradeneeded",c=>{s(we(o.result),c.oldVersion,c.newVersion,we(o.transaction),c)}),t&&o.addEventListener("blocked",c=>t(c.oldVersion,c.newVersion,c)),a.then(c=>{i&&c.addEventListener("close",()=>i()),r&&c.addEventListener("versionchange",l=>r(l.oldVersion,l.newVersion,l))}).catch(()=>{}),a}const xu=["get","getKey","getAll","getAllKeys","count"],Pu=["put","add","delete","clear"],Kn=new Map;function Vr(n,e){if(!(n instanceof IDBDatabase&&!(e in n)&&typeof e=="string"))return;if(Kn.get(e))return Kn.get(e);const t=e.replace(/FromIndex$/,""),s=e!==t,r=Pu.includes(t);if(!(t in(s?IDBIndex:IDBObjectStore).prototype)||!(r||xu.includes(t)))return;const i=async function(o,...a){const c=this.transaction(o,r?"readwrite":"readonly");let l=c.store;return s&&(l=l.index(a.shift())),(await Promise.all([l[t](...a),r&&c.done]))[0]};return Kn.set(e,i),i}Nu(n=>({...n,get:(e,t,s)=>Vr(e,t)||n.get(e,t,s),has:(e,t)=>!!Vr(e,t)||n.has(e,t)}));/**
321
+ */var L;(function(n){n[n.DEBUG=0]="DEBUG",n[n.VERBOSE=1]="VERBOSE",n[n.INFO=2]="INFO",n[n.WARN=3]="WARN",n[n.ERROR=4]="ERROR",n[n.SILENT=5]="SILENT"})(L||(L={}));const Eu={debug:L.DEBUG,verbose:L.VERBOSE,info:L.INFO,warn:L.WARN,error:L.ERROR,silent:L.SILENT},wu=L.INFO,vu={[L.DEBUG]:"log",[L.VERBOSE]:"log",[L.INFO]:"info",[L.WARN]:"warn",[L.ERROR]:"error"},bu=(n,e,...t)=>{if(e<n.logLevel)return;const s=new Date().toISOString(),r=vu[e];if(r)console[r](`[${s}] ${n.name}:`,...t);else throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`)};class Qo{constructor(e){this.name=e,this._logLevel=wu,this._logHandler=bu,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in L))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel=typeof e=="string"?Eu[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if(typeof e!="function")throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...e){this._userLogHandler&&this._userLogHandler(this,L.DEBUG,...e),this._logHandler(this,L.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,L.VERBOSE,...e),this._logHandler(this,L.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,L.INFO,...e),this._logHandler(this,L.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,L.WARN,...e),this._logHandler(this,L.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,L.ERROR,...e),this._logHandler(this,L.ERROR,...e)}}const Cu=(n,e)=>e.some(t=>n instanceof t);let Wr,qr;function Su(){return Wr||(Wr=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Tu(){return qr||(qr=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const Jo=new WeakMap,_s=new WeakMap,Xo=new WeakMap,zn=new WeakMap,Vs=new WeakMap;function Ru(n){const e=new Promise((t,s)=>{const r=()=>{n.removeEventListener("success",i),n.removeEventListener("error",o)},i=()=>{t(we(n.result)),r()},o=()=>{s(n.error),r()};n.addEventListener("success",i),n.addEventListener("error",o)});return e.then(t=>{t instanceof IDBCursor&&Jo.set(t,n)}).catch(()=>{}),Vs.set(e,n),e}function Iu(n){if(_s.has(n))return;const e=new Promise((t,s)=>{const r=()=>{n.removeEventListener("complete",i),n.removeEventListener("error",o),n.removeEventListener("abort",o)},i=()=>{t(),r()},o=()=>{s(n.error||new DOMException("AbortError","AbortError")),r()};n.addEventListener("complete",i),n.addEventListener("error",o),n.addEventListener("abort",o)});_s.set(n,e)}let ms={get(n,e,t){if(n instanceof IDBTransaction){if(e==="done")return _s.get(n);if(e==="objectStoreNames")return n.objectStoreNames||Xo.get(n);if(e==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return we(n[e])},set(n,e,t){return n[e]=t,!0},has(n,e){return n instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in n}};function Nu(n){ms=n(ms)}function Au(n){return n===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...t){const s=n.call(jn(this),e,...t);return Xo.set(s,e.sort?e.sort():[e]),we(s)}:Tu().includes(n)?function(...e){return n.apply(jn(this),e),we(Jo.get(this))}:function(...e){return we(n.apply(jn(this),e))}}function ku(n){return typeof n=="function"?Au(n):(n instanceof IDBTransaction&&Iu(n),Cu(n,Su())?new Proxy(n,ms):n)}function we(n){if(n instanceof IDBRequest)return Ru(n);if(zn.has(n))return zn.get(n);const e=ku(n);return e!==n&&(zn.set(n,e),Vs.set(e,n)),e}const jn=n=>Vs.get(n);function Ou(n,e,{blocked:t,upgrade:s,blocking:r,terminated:i}={}){const o=indexedDB.open(n,e),a=we(o);return s&&o.addEventListener("upgradeneeded",c=>{s(we(o.result),c.oldVersion,c.newVersion,we(o.transaction),c)}),t&&o.addEventListener("blocked",c=>t(c.oldVersion,c.newVersion,c)),a.then(c=>{i&&c.addEventListener("close",()=>i()),r&&c.addEventListener("versionchange",l=>r(l.oldVersion,l.newVersion,l))}).catch(()=>{}),a}const xu=["get","getKey","getAll","getAllKeys","count"],Pu=["put","add","delete","clear"],Kn=new Map;function Vr(n,e){if(!(n instanceof IDBDatabase&&!(e in n)&&typeof e=="string"))return;if(Kn.get(e))return Kn.get(e);const t=e.replace(/FromIndex$/,""),s=e!==t,r=Pu.includes(t);if(!(t in(s?IDBIndex:IDBObjectStore).prototype)||!(r||xu.includes(t)))return;const i=async function(o,...a){const c=this.transaction(o,r?"readwrite":"readonly");let l=c.store;return s&&(l=l.index(a.shift())),(await Promise.all([l[t](...a),r&&c.done]))[0]};return Kn.set(e,i),i}Nu(n=>({...n,get:(e,t,s)=>Vr(e,t)||n.get(e,t,s),has:(e,t)=>!!Vr(e,t)||n.has(e,t)}));/**
322
322
  * @license
323
323
  * Copyright 2019 Google LLC
324
324
  *
@@ -438,7 +438,7 @@
438
438
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
439
439
  * See the License for the specific language governing permissions and
440
440
  * limitations under the License.
441
- */const gd="firebase-heartbeat-database",yd=1,wt="firebase-heartbeat-store";let Gn=null;function ea(){return Gn||(Gn=Ou(gd,yd,{upgrade:(n,e)=>{switch(e){case 0:try{n.createObjectStore(wt)}catch(t){console.warn(t)}}}}).catch(n=>{throw ve.create("idb-open",{originalErrorMessage:n.message})})),Gn}async function Ed(n){try{const t=(await ea()).transaction(wt),s=await t.objectStore(wt).get(ta(n));return await t.done,s}catch(e){if(e instanceof At)pe.warn(e.message);else{const t=ve.create("idb-get",{originalErrorMessage:e==null?void 0:e.message});pe.warn(t.message)}}}async function jr(n,e){try{const s=(await ea()).transaction(wt,"readwrite");await s.objectStore(wt).put(e,ta(n)),await s.done}catch(t){if(t instanceof At)pe.warn(t.message);else{const s=ve.create("idb-set",{originalErrorMessage:t==null?void 0:t.message});pe.warn(s.message)}}}function ta(n){return`${n.name}!${n.options.appId}`}/**
441
+ */const gd="firebase-heartbeat-database",yd=1,wt="firebase-heartbeat-store";let Gn=null;function ea(){return Gn||(Gn=Ou(gd,yd,{upgrade:(n,e)=>{switch(e){case 0:try{n.createObjectStore(wt)}catch(t){console.warn(t)}}}}).catch(n=>{throw ve.create("idb-open",{originalErrorMessage:n.message})})),Gn}async function Ed(n){try{const t=(await ea()).transaction(wt),s=await t.objectStore(wt).get(ta(n));return await t.done,s}catch(e){if(e instanceof kt)pe.warn(e.message);else{const t=ve.create("idb-get",{originalErrorMessage:e==null?void 0:e.message});pe.warn(t.message)}}}async function jr(n,e){try{const s=(await ea()).transaction(wt,"readwrite");await s.objectStore(wt).put(e,ta(n)),await s.done}catch(t){if(t instanceof kt)pe.warn(t.message);else{const s=ve.create("idb-set",{originalErrorMessage:t==null?void 0:t.message});pe.warn(s.message)}}}function ta(n){return`${n.name}!${n.options.appId}`}/**
442
442
  * @license
443
443
  * Copyright 2021 Google LLC
444
444
  *
@@ -513,7 +513,7 @@
513
513
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
514
514
  * See the License for the specific language governing permissions and
515
515
  * limitations under the License.
516
- */class kd{constructor(){this.cache_={},this.isInMemoryStorage=!0}set(e,t){t==null?delete this.cache_[e]:this.cache_[e]=t}get(e){return me(this.cache_,e)?this.cache_[e]:null}remove(e){delete this.cache_[e]}}/**
516
+ */class Ad{constructor(){this.cache_={},this.isInMemoryStorage=!0}set(e,t){t==null?delete this.cache_[e]:this.cache_[e]=t}get(e){return me(this.cache_,e)?this.cache_[e]:null}remove(e){delete this.cache_[e]}}/**
517
517
  * @license
518
518
  * Copyright 2017 Google LLC
519
519
  *
@@ -528,7 +528,7 @@
528
528
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
529
529
  * See the License for the specific language governing permissions and
530
530
  * limitations under the License.
531
- */const sa=function(n){try{if(typeof window<"u"&&typeof window[n]<"u"){const e=window[n];return e.setItem("firebase:sentinel","cache"),e.removeItem("firebase:sentinel"),new Nd(e)}}catch{}return new kd},Oe=sa("localStorage"),Ad=sa("sessionStorage");/**
531
+ */const sa=function(n){try{if(typeof window<"u"&&typeof window[n]<"u"){const e=window[n];return e.setItem("firebase:sentinel","cache"),e.removeItem("firebase:sentinel"),new Nd(e)}}catch{}return new Ad},Oe=sa("localStorage"),kd=sa("sessionStorage");/**
532
532
  * @license
533
533
  * Copyright 2017 Google LLC
534
534
  *
@@ -543,7 +543,7 @@
543
543
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
544
544
  * See the License for the specific language governing permissions and
545
545
  * limitations under the License.
546
- */const ze=new Qo("@firebase/database"),Od=function(){let n=1;return function(){return n++}}(),ra=function(n){const e=pu(n),t=new fu;t.update(e);const s=t.digest();return Ws.encodeByteArray(s)},Ot=function(...n){let e="";for(let t=0;t<n.length;t++){const s=n[t];Array.isArray(s)||s&&typeof s=="object"&&typeof s.length=="number"?e+=Ot.apply(null,s):typeof s=="object"?e+=$(s):e+=s,e+=" "}return e};let dt=null,Jr=!0;const xd=function(n,e){m(!0,"Can't turn on custom loggers persistently."),ze.logLevel=L.VERBOSE,dt=ze.log.bind(ze)},z=function(...n){if(Jr===!0&&(Jr=!1,dt===null&&Ad.get("logging_enabled")===!0&&xd()),dt){const e=Ot.apply(null,n);dt(e)}},xt=function(n){return function(...e){z(n,...e)}},ws=function(...n){const e="FIREBASE INTERNAL ERROR: "+Ot(...n);ze.error(e)},_e=function(...n){const e=`FIREBASE FATAL ERROR: ${Ot(...n)}`;throw ze.error(e),new Error(e)},te=function(...n){const e="FIREBASE WARNING: "+Ot(...n);ze.warn(e)},Pd=function(){typeof window<"u"&&window.location&&window.location.protocol&&window.location.protocol.indexOf("https:")!==-1&&te("Insecure Firebase access from a secure page. Please use https in calls to new Firebase().")},ia=function(n){return typeof n=="number"&&(n!==n||n===Number.POSITIVE_INFINITY||n===Number.NEGATIVE_INFINITY)},Dd=function(n){if(document.readyState==="complete")n();else{let e=!1;const t=function(){if(!document.body){setTimeout(t,Math.floor(10));return}e||(e=!0,n())};document.addEventListener?(document.addEventListener("DOMContentLoaded",t,!1),window.addEventListener("load",t,!1)):document.attachEvent&&(document.attachEvent("onreadystatechange",()=>{document.readyState==="complete"&&t()}),window.attachEvent("onload",t))}},Ye="[MIN_NAME]",De="[MAX_NAME]",nt=function(n,e){if(n===e)return 0;if(n===Ye||e===De)return-1;if(e===Ye||n===De)return 1;{const t=Xr(n),s=Xr(e);return t!==null?s!==null?t-s===0?n.length-e.length:t-s:-1:s!==null?1:n<e?-1:1}},Ld=function(n,e){return n===e?0:n<e?-1:1},ot=function(n,e){if(e&&n in e)return e[n];throw new Error("Missing required key ("+n+") in object: "+$(e))},$s=function(n){if(typeof n!="object"||n===null)return $(n);const e=[];for(const s in n)e.push(s);e.sort();let t="{";for(let s=0;s<e.length;s++)s!==0&&(t+=","),t+=$(e[s]),t+=":",t+=$s(n[e[s]]);return t+="}",t},oa=function(n,e){const t=n.length;if(t<=e)return[n];const s=[];for(let r=0;r<t;r+=e)r+e>t?s.push(n.substring(r,t)):s.push(n.substring(r,r+e));return s};function Z(n,e){for(const t in n)n.hasOwnProperty(t)&&e(t,n[t])}const aa=function(n){m(!ia(n),"Invalid JSON number");const e=11,t=52,s=(1<<e-1)-1;let r,i,o,a,c;n===0?(i=0,o=0,r=1/n===-1/0?1:0):(r=n<0,n=Math.abs(n),n>=Math.pow(2,1-s)?(a=Math.min(Math.floor(Math.log(n)/Math.LN2),s),i=a+s,o=Math.round(n*Math.pow(2,t-a)-Math.pow(2,t))):(i=0,o=Math.round(n/Math.pow(2,1-s-t))));const l=[];for(c=t;c;c-=1)l.push(o%2?1:0),o=Math.floor(o/2);for(c=e;c;c-=1)l.push(i%2?1:0),i=Math.floor(i/2);l.push(r?1:0),l.reverse();const h=l.join("");let u="";for(c=0;c<64;c+=8){let d=parseInt(h.substr(c,8),2).toString(16);d.length===1&&(d="0"+d),u=u+d}return u.toLowerCase()},Fd=function(){return!!(typeof window=="object"&&window.chrome&&window.chrome.extension&&!/^chrome/.test(window.location.href))},Md=function(){return typeof Windows=="object"&&typeof Windows.UI=="object"};function Bd(n,e){let t="Unknown Error";n==="too_big"?t="The data requested exceeds the maximum size that can be accessed with a single request.":n==="permission_denied"?t="Client doesn't have permission to access the desired data.":n==="unavailable"&&(t="The service is unavailable");const s=new Error(n+" at "+e._path.toString()+": "+t);return s.code=n.toUpperCase(),s}const Ud=new RegExp("^-?(0*)\\d{1,10}$"),Hd=-2147483648,Wd=2147483647,Xr=function(n){if(Ud.test(n)){const e=Number(n);if(e>=Hd&&e<=Wd)return e}return null},Pt=function(n){try{n()}catch(e){setTimeout(()=>{const t=e.stack||"";throw te("Exception was thrown by user callback.",t),e},Math.floor(0))}},qd=function(){return(typeof window=="object"&&window.navigator&&window.navigator.userAgent||"").search(/googlebot|google webmaster tools|bingbot|yahoo! slurp|baiduspider|yandexbot|duckduckbot/i)>=0},ft=function(n,e){const t=setTimeout(n,e);return typeof t=="number"&&typeof Deno<"u"&&Deno.unrefTimer?Deno.unrefTimer(t):typeof t=="object"&&t.unref&&t.unref(),t};/**
546
+ */const ze=new Qo("@firebase/database"),Od=function(){let n=1;return function(){return n++}}(),ra=function(n){const e=pu(n),t=new fu;t.update(e);const s=t.digest();return Ws.encodeByteArray(s)},Ot=function(...n){let e="";for(let t=0;t<n.length;t++){const s=n[t];Array.isArray(s)||s&&typeof s=="object"&&typeof s.length=="number"?e+=Ot.apply(null,s):typeof s=="object"?e+=$(s):e+=s,e+=" "}return e};let dt=null,Jr=!0;const xd=function(n,e){m(!0,"Can't turn on custom loggers persistently."),ze.logLevel=L.VERBOSE,dt=ze.log.bind(ze)},z=function(...n){if(Jr===!0&&(Jr=!1,dt===null&&kd.get("logging_enabled")===!0&&xd()),dt){const e=Ot.apply(null,n);dt(e)}},xt=function(n){return function(...e){z(n,...e)}},ws=function(...n){const e="FIREBASE INTERNAL ERROR: "+Ot(...n);ze.error(e)},_e=function(...n){const e=`FIREBASE FATAL ERROR: ${Ot(...n)}`;throw ze.error(e),new Error(e)},te=function(...n){const e="FIREBASE WARNING: "+Ot(...n);ze.warn(e)},Pd=function(){typeof window<"u"&&window.location&&window.location.protocol&&window.location.protocol.indexOf("https:")!==-1&&te("Insecure Firebase access from a secure page. Please use https in calls to new Firebase().")},ia=function(n){return typeof n=="number"&&(n!==n||n===Number.POSITIVE_INFINITY||n===Number.NEGATIVE_INFINITY)},Dd=function(n){if(document.readyState==="complete")n();else{let e=!1;const t=function(){if(!document.body){setTimeout(t,Math.floor(10));return}e||(e=!0,n())};document.addEventListener?(document.addEventListener("DOMContentLoaded",t,!1),window.addEventListener("load",t,!1)):document.attachEvent&&(document.attachEvent("onreadystatechange",()=>{document.readyState==="complete"&&t()}),window.attachEvent("onload",t))}},Ye="[MIN_NAME]",De="[MAX_NAME]",nt=function(n,e){if(n===e)return 0;if(n===Ye||e===De)return-1;if(e===Ye||n===De)return 1;{const t=Xr(n),s=Xr(e);return t!==null?s!==null?t-s===0?n.length-e.length:t-s:-1:s!==null?1:n<e?-1:1}},Ld=function(n,e){return n===e?0:n<e?-1:1},ot=function(n,e){if(e&&n in e)return e[n];throw new Error("Missing required key ("+n+") in object: "+$(e))},$s=function(n){if(typeof n!="object"||n===null)return $(n);const e=[];for(const s in n)e.push(s);e.sort();let t="{";for(let s=0;s<e.length;s++)s!==0&&(t+=","),t+=$(e[s]),t+=":",t+=$s(n[e[s]]);return t+="}",t},oa=function(n,e){const t=n.length;if(t<=e)return[n];const s=[];for(let r=0;r<t;r+=e)r+e>t?s.push(n.substring(r,t)):s.push(n.substring(r,r+e));return s};function Z(n,e){for(const t in n)n.hasOwnProperty(t)&&e(t,n[t])}const aa=function(n){m(!ia(n),"Invalid JSON number");const e=11,t=52,s=(1<<e-1)-1;let r,i,o,a,c;n===0?(i=0,o=0,r=1/n===-1/0?1:0):(r=n<0,n=Math.abs(n),n>=Math.pow(2,1-s)?(a=Math.min(Math.floor(Math.log(n)/Math.LN2),s),i=a+s,o=Math.round(n*Math.pow(2,t-a)-Math.pow(2,t))):(i=0,o=Math.round(n/Math.pow(2,1-s-t))));const l=[];for(c=t;c;c-=1)l.push(o%2?1:0),o=Math.floor(o/2);for(c=e;c;c-=1)l.push(i%2?1:0),i=Math.floor(i/2);l.push(r?1:0),l.reverse();const h=l.join("");let u="";for(c=0;c<64;c+=8){let d=parseInt(h.substr(c,8),2).toString(16);d.length===1&&(d="0"+d),u=u+d}return u.toLowerCase()},Fd=function(){return!!(typeof window=="object"&&window.chrome&&window.chrome.extension&&!/^chrome/.test(window.location.href))},Md=function(){return typeof Windows=="object"&&typeof Windows.UI=="object"};function Bd(n,e){let t="Unknown Error";n==="too_big"?t="The data requested exceeds the maximum size that can be accessed with a single request.":n==="permission_denied"?t="Client doesn't have permission to access the desired data.":n==="unavailable"&&(t="The service is unavailable");const s=new Error(n+" at "+e._path.toString()+": "+t);return s.code=n.toUpperCase(),s}const Ud=new RegExp("^-?(0*)\\d{1,10}$"),Hd=-2147483648,Wd=2147483647,Xr=function(n){if(Ud.test(n)){const e=Number(n);if(e>=Hd&&e<=Wd)return e}return null},Pt=function(n){try{n()}catch(e){setTimeout(()=>{const t=e.stack||"";throw te("Exception was thrown by user callback.",t),e},Math.floor(0))}},qd=function(){return(typeof window=="object"&&window.navigator&&window.navigator.userAgent||"").search(/googlebot|google webmaster tools|bingbot|yahoo! slurp|baiduspider|yandexbot|duckduckbot/i)>=0},ft=function(n,e){const t=setTimeout(n,e);return typeof t=="number"&&typeof Deno<"u"&&Deno.unrefTimer?Deno.unrefTimer(t):typeof t=="object"&&t.unref&&t.unref(),t};/**
547
547
  * @license
548
548
  * Copyright 2021 Google LLC
549
549
  *
@@ -768,7 +768,7 @@
768
768
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
769
769
  * See the License for the specific language governing permissions and
770
770
  * limitations under the License.
771
- */const oi=32,ai=768;class D{constructor(e,t){if(t===void 0){this.pieces_=e.split("/");let s=0;for(let r=0;r<this.pieces_.length;r++)this.pieces_[r].length>0&&(this.pieces_[s]=this.pieces_[r],s++);this.pieces_.length=s,this.pieceNum_=0}else this.pieces_=e,this.pieceNum_=t}toString(){let e="";for(let t=this.pieceNum_;t<this.pieces_.length;t++)this.pieces_[t]!==""&&(e+="/"+this.pieces_[t]);return e||"/"}}function N(){return new D("")}function C(n){return n.pieceNum_>=n.pieces_.length?null:n.pieces_[n.pieceNum_]}function Ce(n){return n.pieces_.length-n.pieceNum_}function F(n){let e=n.pieceNum_;return e<n.pieces_.length&&e++,new D(n.pieces_,e)}function Ra(n){return n.pieceNum_<n.pieces_.length?n.pieces_[n.pieces_.length-1]:null}function gf(n){let e="";for(let t=n.pieceNum_;t<n.pieces_.length;t++)n.pieces_[t]!==""&&(e+="/"+encodeURIComponent(String(n.pieces_[t])));return e||"/"}function Ia(n,e=0){return n.pieces_.slice(n.pieceNum_+e)}function Na(n){if(n.pieceNum_>=n.pieces_.length)return null;const e=[];for(let t=n.pieceNum_;t<n.pieces_.length-1;t++)e.push(n.pieces_[t]);return new D(e,0)}function W(n,e){const t=[];for(let s=n.pieceNum_;s<n.pieces_.length;s++)t.push(n.pieces_[s]);if(e instanceof D)for(let s=e.pieceNum_;s<e.pieces_.length;s++)t.push(e.pieces_[s]);else{const s=e.split("/");for(let r=0;r<s.length;r++)s[r].length>0&&t.push(s[r])}return new D(t,0)}function S(n){return n.pieceNum_>=n.pieces_.length}function Q(n,e){const t=C(n),s=C(e);if(t===null)return e;if(t===s)return Q(F(n),F(e));throw new Error("INTERNAL ERROR: innerPath ("+e+") is not within outerPath ("+n+")")}function Gs(n,e){if(Ce(n)!==Ce(e))return!1;for(let t=n.pieceNum_,s=e.pieceNum_;t<=n.pieces_.length;t++,s++)if(n.pieces_[t]!==e.pieces_[s])return!1;return!0}function oe(n,e){let t=n.pieceNum_,s=e.pieceNum_;if(Ce(n)>Ce(e))return!1;for(;t<n.pieces_.length;){if(n.pieces_[t]!==e.pieces_[s])return!1;++t,++s}return!0}class yf{constructor(e,t){this.errorPrefix_=t,this.parts_=Ia(e,0),this.byteLength_=Math.max(1,this.parts_.length);for(let s=0;s<this.parts_.length;s++)this.byteLength_+=kn(this.parts_[s]);ka(this)}}function Ef(n,e){n.parts_.length>0&&(n.byteLength_+=1),n.parts_.push(e),n.byteLength_+=kn(e),ka(n)}function wf(n){const e=n.parts_.pop();n.byteLength_-=kn(e),n.parts_.length>0&&(n.byteLength_-=1)}function ka(n){if(n.byteLength_>ai)throw new Error(n.errorPrefix_+"has a key path longer than "+ai+" bytes ("+n.byteLength_+").");if(n.parts_.length>oi)throw new Error(n.errorPrefix_+"path specified exceeds the maximum depth that can be written ("+oi+") or object contains a cycle "+Ie(n))}function Ie(n){return n.parts_.length===0?"":"in property '"+n.parts_.join(".")+"'"}/**
771
+ */const oi=32,ai=768;class D{constructor(e,t){if(t===void 0){this.pieces_=e.split("/");let s=0;for(let r=0;r<this.pieces_.length;r++)this.pieces_[r].length>0&&(this.pieces_[s]=this.pieces_[r],s++);this.pieces_.length=s,this.pieceNum_=0}else this.pieces_=e,this.pieceNum_=t}toString(){let e="";for(let t=this.pieceNum_;t<this.pieces_.length;t++)this.pieces_[t]!==""&&(e+="/"+this.pieces_[t]);return e||"/"}}function N(){return new D("")}function C(n){return n.pieceNum_>=n.pieces_.length?null:n.pieces_[n.pieceNum_]}function Ce(n){return n.pieces_.length-n.pieceNum_}function F(n){let e=n.pieceNum_;return e<n.pieces_.length&&e++,new D(n.pieces_,e)}function Ra(n){return n.pieceNum_<n.pieces_.length?n.pieces_[n.pieces_.length-1]:null}function gf(n){let e="";for(let t=n.pieceNum_;t<n.pieces_.length;t++)n.pieces_[t]!==""&&(e+="/"+encodeURIComponent(String(n.pieces_[t])));return e||"/"}function Ia(n,e=0){return n.pieces_.slice(n.pieceNum_+e)}function Na(n){if(n.pieceNum_>=n.pieces_.length)return null;const e=[];for(let t=n.pieceNum_;t<n.pieces_.length-1;t++)e.push(n.pieces_[t]);return new D(e,0)}function W(n,e){const t=[];for(let s=n.pieceNum_;s<n.pieces_.length;s++)t.push(n.pieces_[s]);if(e instanceof D)for(let s=e.pieceNum_;s<e.pieces_.length;s++)t.push(e.pieces_[s]);else{const s=e.split("/");for(let r=0;r<s.length;r++)s[r].length>0&&t.push(s[r])}return new D(t,0)}function S(n){return n.pieceNum_>=n.pieces_.length}function Q(n,e){const t=C(n),s=C(e);if(t===null)return e;if(t===s)return Q(F(n),F(e));throw new Error("INTERNAL ERROR: innerPath ("+e+") is not within outerPath ("+n+")")}function Gs(n,e){if(Ce(n)!==Ce(e))return!1;for(let t=n.pieceNum_,s=e.pieceNum_;t<=n.pieces_.length;t++,s++)if(n.pieces_[t]!==e.pieces_[s])return!1;return!0}function oe(n,e){let t=n.pieceNum_,s=e.pieceNum_;if(Ce(n)>Ce(e))return!1;for(;t<n.pieces_.length;){if(n.pieces_[t]!==e.pieces_[s])return!1;++t,++s}return!0}class yf{constructor(e,t){this.errorPrefix_=t,this.parts_=Ia(e,0),this.byteLength_=Math.max(1,this.parts_.length);for(let s=0;s<this.parts_.length;s++)this.byteLength_+=An(this.parts_[s]);Aa(this)}}function Ef(n,e){n.parts_.length>0&&(n.byteLength_+=1),n.parts_.push(e),n.byteLength_+=An(e),Aa(n)}function wf(n){const e=n.parts_.pop();n.byteLength_-=An(e),n.parts_.length>0&&(n.byteLength_-=1)}function Aa(n){if(n.byteLength_>ai)throw new Error(n.errorPrefix_+"has a key path longer than "+ai+" bytes ("+n.byteLength_+").");if(n.parts_.length>oi)throw new Error(n.errorPrefix_+"path specified exceeds the maximum depth that can be written ("+oi+") or object contains a cycle "+Ie(n))}function Ie(n){return n.parts_.length===0?"":"in property '"+n.parts_.join(".")+"'"}/**
772
772
  * @license
773
773
  * Copyright 2017 Google LLC
774
774
  *
@@ -846,7 +846,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
846
846
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
847
847
  * See the License for the specific language governing permissions and
848
848
  * limitations under the License.
849
- */let Ht;class Aa extends On{static get __EMPTY_NODE(){return Ht}static set __EMPTY_NODE(e){Ht=e}compare(e,t){return nt(e.name,t.name)}isDefinedOn(e){throw tt("KeyIndex.isDefinedOn not expected to be called.")}indexedValueChanged(e,t){return!1}minPost(){return b.MIN}maxPost(){return new b(De,Ht)}makePost(e,t){return m(typeof e=="string","KeyIndex indexValue must always be a string."),new b(e,Ht)}toString(){return".key"}}const je=new Aa;/**
849
+ */let Ht;class ka extends On{static get __EMPTY_NODE(){return Ht}static set __EMPTY_NODE(e){Ht=e}compare(e,t){return nt(e.name,t.name)}isDefinedOn(e){throw tt("KeyIndex.isDefinedOn not expected to be called.")}indexedValueChanged(e,t){return!1}minPost(){return b.MIN}maxPost(){return new b(De,Ht)}makePost(e,t){return m(typeof e=="string","KeyIndex indexValue must always be a string."),new b(e,Ht)}toString(){return".key"}}const je=new ka;/**
850
850
  * @license
851
851
  * Copyright 2017 Google LLC
852
852
  *
@@ -921,7 +921,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
921
921
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
922
922
  * See the License for the specific language governing permissions and
923
923
  * limitations under the License.
924
- */let Pa,Da;function Nf(n){Pa=n}function kf(n){Da=n}class Af extends On{compare(e,t){const s=e.node.getPriority(),r=t.node.getPriority(),i=s.compareTo(r);return i===0?nt(e.name,t.name):i}isDefinedOn(e){return!e.getPriority().isEmpty()}indexedValueChanged(e,t){return!e.getPriority().equals(t.getPriority())}minPost(){return b.MIN}maxPost(){return new b(De,new q("[PRIORITY-POST]",Da))}makePost(e,t){const s=Pa(e);return new b(t,new q("[PRIORITY-POST]",s))}toString(){return".priority"}}const U=new Af;/**
924
+ */let Pa,Da;function Nf(n){Pa=n}function Af(n){Da=n}class kf extends On{compare(e,t){const s=e.node.getPriority(),r=t.node.getPriority(),i=s.compareTo(r);return i===0?nt(e.name,t.name):i}isDefinedOn(e){return!e.getPriority().isEmpty()}indexedValueChanged(e,t){return!e.getPriority().equals(t.getPriority())}minPost(){return b.MIN}maxPost(){return new b(De,new q("[PRIORITY-POST]",Da))}makePost(e,t){const s=Pa(e);return new b(t,new q("[PRIORITY-POST]",s))}toString(){return".priority"}}const U=new kf;/**
925
925
  * @license
926
926
  * Copyright 2017 Google LLC
927
927
  *
@@ -966,7 +966,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
966
966
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
967
967
  * See the License for the specific language governing permissions and
968
968
  * limitations under the License.
969
- */let ct;class E{static get EMPTY_NODE(){return ct||(ct=new E(new J(Qs),null,de.Default))}constructor(e,t,s){this.children_=e,this.priorityNode_=t,this.indexMap_=s,this.lazyHash_=null,this.priorityNode_&&xa(this.priorityNode_),this.children_.isEmpty()&&m(!this.priorityNode_||this.priorityNode_.isEmpty(),"An empty node cannot have a priority")}isLeafNode(){return!1}getPriority(){return this.priorityNode_||ct}updatePriority(e){return this.children_.isEmpty()?this:new E(this.children_,e,this.indexMap_)}getImmediateChild(e){if(e===".priority")return this.getPriority();{const t=this.children_.get(e);return t===null?ct:t}}getChild(e){const t=C(e);return t===null?this:this.getImmediateChild(t).getChild(F(e))}hasChild(e){return this.children_.get(e)!==null}updateImmediateChild(e,t){if(m(t,"We should always be passing snapshot nodes"),e===".priority")return this.updatePriority(t);{const s=new b(e,t);let r,i;t.isEmpty()?(r=this.children_.remove(e),i=this.indexMap_.removeFromIndexes(s,this.children_)):(r=this.children_.insert(e,t),i=this.indexMap_.addToIndexes(s,this.children_));const o=r.isEmpty()?ct:this.priorityNode_;return new E(r,o,i)}}updateChild(e,t){const s=C(e);if(s===null)return t;{m(C(e)!==".priority"||Ce(e)===1,".priority must be the last token in a path");const r=this.getImmediateChild(s).updateChild(F(e),t);return this.updateImmediateChild(s,r)}}isEmpty(){return this.children_.isEmpty()}numChildren(){return this.children_.count()}val(e){if(this.isEmpty())return null;const t={};let s=0,r=0,i=!0;if(this.forEachChild(U,(o,a)=>{t[o]=a.val(e),s++,i&&E.INTEGER_REGEXP_.test(o)?r=Math.max(r,Number(o)):i=!1}),!e&&i&&r<2*s){const o=[];for(const a in t)o[a]=t[a];return o}else return e&&!this.getPriority().isEmpty()&&(t[".priority"]=this.getPriority().val()),t}hash(){if(this.lazyHash_===null){let e="";this.getPriority().isEmpty()||(e+="priority:"+Oa(this.getPriority().val())+":"),this.forEachChild(U,(t,s)=>{const r=s.hash();r!==""&&(e+=":"+t+":"+r)}),this.lazyHash_=e===""?"":ra(e)}return this.lazyHash_}getPredecessorChildName(e,t,s){const r=this.resolveIndex_(s);if(r){const i=r.getPredecessorKey(new b(e,t));return i?i.name:null}else return this.children_.getPredecessorKey(e)}getFirstChildName(e){const t=this.resolveIndex_(e);if(t){const s=t.minKey();return s&&s.name}else return this.children_.minKey()}getFirstChild(e){const t=this.getFirstChildName(e);return t?new b(t,this.children_.get(t)):null}getLastChildName(e){const t=this.resolveIndex_(e);if(t){const s=t.maxKey();return s&&s.name}else return this.children_.maxKey()}getLastChild(e){const t=this.getLastChildName(e);return t?new b(t,this.children_.get(t)):null}forEachChild(e,t){const s=this.resolveIndex_(e);return s?s.inorderTraversal(r=>t(r.name,r.node)):this.children_.inorderTraversal(t)}getIterator(e){return this.getIteratorFrom(e.minPost(),e)}getIteratorFrom(e,t){const s=this.resolveIndex_(t);if(s)return s.getIteratorFrom(e,r=>r);{const r=this.children_.getIteratorFrom(e.name,b.Wrap);let i=r.peek();for(;i!=null&&t.compare(i,e)<0;)r.getNext(),i=r.peek();return r}}getReverseIterator(e){return this.getReverseIteratorFrom(e.maxPost(),e)}getReverseIteratorFrom(e,t){const s=this.resolveIndex_(t);if(s)return s.getReverseIteratorFrom(e,r=>r);{const r=this.children_.getReverseIteratorFrom(e.name,b.Wrap);let i=r.peek();for(;i!=null&&t.compare(i,e)>0;)r.getNext(),i=r.peek();return r}}compareTo(e){return this.isEmpty()?e.isEmpty()?0:-1:e.isLeafNode()||e.isEmpty()?1:e===Dt?-1:0}withIndex(e){if(e===je||this.indexMap_.hasIndex(e))return this;{const t=this.indexMap_.addIndex(e,this.children_);return new E(this.children_,this.priorityNode_,t)}}isIndexed(e){return e===je||this.indexMap_.hasIndex(e)}equals(e){if(e===this)return!0;if(e.isLeafNode())return!1;{const t=e;if(this.getPriority().equals(t.getPriority()))if(this.children_.count()===t.children_.count()){const s=this.getIterator(U),r=t.getIterator(U);let i=s.getNext(),o=r.getNext();for(;i&&o;){if(i.name!==o.name||!i.node.equals(o.node))return!1;i=s.getNext(),o=r.getNext()}return i===null&&o===null}else return!1;else return!1}}resolveIndex_(e){return e===je?null:this.indexMap_.get(e.toString())}}E.INTEGER_REGEXP_=/^(0|[1-9]\d*)$/;class Pf extends E{constructor(){super(new J(Qs),E.EMPTY_NODE,de.Default)}compareTo(e){return e===this?0:1}equals(e){return e===this}getPriority(){return this}getImmediateChild(e){return E.EMPTY_NODE}isEmpty(){return!1}}const Dt=new Pf;Object.defineProperties(b,{MIN:{value:new b(Ye,E.EMPTY_NODE)},MAX:{value:new b(De,Dt)}});Aa.__EMPTY_NODE=E.EMPTY_NODE;q.__childrenNodeConstructor=E;If(Dt);kf(Dt);/**
969
+ */let ct;class E{static get EMPTY_NODE(){return ct||(ct=new E(new J(Qs),null,de.Default))}constructor(e,t,s){this.children_=e,this.priorityNode_=t,this.indexMap_=s,this.lazyHash_=null,this.priorityNode_&&xa(this.priorityNode_),this.children_.isEmpty()&&m(!this.priorityNode_||this.priorityNode_.isEmpty(),"An empty node cannot have a priority")}isLeafNode(){return!1}getPriority(){return this.priorityNode_||ct}updatePriority(e){return this.children_.isEmpty()?this:new E(this.children_,e,this.indexMap_)}getImmediateChild(e){if(e===".priority")return this.getPriority();{const t=this.children_.get(e);return t===null?ct:t}}getChild(e){const t=C(e);return t===null?this:this.getImmediateChild(t).getChild(F(e))}hasChild(e){return this.children_.get(e)!==null}updateImmediateChild(e,t){if(m(t,"We should always be passing snapshot nodes"),e===".priority")return this.updatePriority(t);{const s=new b(e,t);let r,i;t.isEmpty()?(r=this.children_.remove(e),i=this.indexMap_.removeFromIndexes(s,this.children_)):(r=this.children_.insert(e,t),i=this.indexMap_.addToIndexes(s,this.children_));const o=r.isEmpty()?ct:this.priorityNode_;return new E(r,o,i)}}updateChild(e,t){const s=C(e);if(s===null)return t;{m(C(e)!==".priority"||Ce(e)===1,".priority must be the last token in a path");const r=this.getImmediateChild(s).updateChild(F(e),t);return this.updateImmediateChild(s,r)}}isEmpty(){return this.children_.isEmpty()}numChildren(){return this.children_.count()}val(e){if(this.isEmpty())return null;const t={};let s=0,r=0,i=!0;if(this.forEachChild(U,(o,a)=>{t[o]=a.val(e),s++,i&&E.INTEGER_REGEXP_.test(o)?r=Math.max(r,Number(o)):i=!1}),!e&&i&&r<2*s){const o=[];for(const a in t)o[a]=t[a];return o}else return e&&!this.getPriority().isEmpty()&&(t[".priority"]=this.getPriority().val()),t}hash(){if(this.lazyHash_===null){let e="";this.getPriority().isEmpty()||(e+="priority:"+Oa(this.getPriority().val())+":"),this.forEachChild(U,(t,s)=>{const r=s.hash();r!==""&&(e+=":"+t+":"+r)}),this.lazyHash_=e===""?"":ra(e)}return this.lazyHash_}getPredecessorChildName(e,t,s){const r=this.resolveIndex_(s);if(r){const i=r.getPredecessorKey(new b(e,t));return i?i.name:null}else return this.children_.getPredecessorKey(e)}getFirstChildName(e){const t=this.resolveIndex_(e);if(t){const s=t.minKey();return s&&s.name}else return this.children_.minKey()}getFirstChild(e){const t=this.getFirstChildName(e);return t?new b(t,this.children_.get(t)):null}getLastChildName(e){const t=this.resolveIndex_(e);if(t){const s=t.maxKey();return s&&s.name}else return this.children_.maxKey()}getLastChild(e){const t=this.getLastChildName(e);return t?new b(t,this.children_.get(t)):null}forEachChild(e,t){const s=this.resolveIndex_(e);return s?s.inorderTraversal(r=>t(r.name,r.node)):this.children_.inorderTraversal(t)}getIterator(e){return this.getIteratorFrom(e.minPost(),e)}getIteratorFrom(e,t){const s=this.resolveIndex_(t);if(s)return s.getIteratorFrom(e,r=>r);{const r=this.children_.getIteratorFrom(e.name,b.Wrap);let i=r.peek();for(;i!=null&&t.compare(i,e)<0;)r.getNext(),i=r.peek();return r}}getReverseIterator(e){return this.getReverseIteratorFrom(e.maxPost(),e)}getReverseIteratorFrom(e,t){const s=this.resolveIndex_(t);if(s)return s.getReverseIteratorFrom(e,r=>r);{const r=this.children_.getReverseIteratorFrom(e.name,b.Wrap);let i=r.peek();for(;i!=null&&t.compare(i,e)>0;)r.getNext(),i=r.peek();return r}}compareTo(e){return this.isEmpty()?e.isEmpty()?0:-1:e.isLeafNode()||e.isEmpty()?1:e===Dt?-1:0}withIndex(e){if(e===je||this.indexMap_.hasIndex(e))return this;{const t=this.indexMap_.addIndex(e,this.children_);return new E(this.children_,this.priorityNode_,t)}}isIndexed(e){return e===je||this.indexMap_.hasIndex(e)}equals(e){if(e===this)return!0;if(e.isLeafNode())return!1;{const t=e;if(this.getPriority().equals(t.getPriority()))if(this.children_.count()===t.children_.count()){const s=this.getIterator(U),r=t.getIterator(U);let i=s.getNext(),o=r.getNext();for(;i&&o;){if(i.name!==o.name||!i.node.equals(o.node))return!1;i=s.getNext(),o=r.getNext()}return i===null&&o===null}else return!1;else return!1}}resolveIndex_(e){return e===je?null:this.indexMap_.get(e.toString())}}E.INTEGER_REGEXP_=/^(0|[1-9]\d*)$/;class Pf extends E{constructor(){super(new J(Qs),E.EMPTY_NODE,de.Default)}compareTo(e){return e===this?0:1}equals(e){return e===this}getPriority(){return this}getImmediateChild(e){return E.EMPTY_NODE}isEmpty(){return!1}}const Dt=new Pf;Object.defineProperties(b,{MIN:{value:new b(Ye,E.EMPTY_NODE)},MAX:{value:new b(De,Dt)}});ka.__EMPTY_NODE=E.EMPTY_NODE;q.__childrenNodeConstructor=E;If(Dt);Af(Dt);/**
970
970
  * @license
971
971
  * Copyright 2017 Google LLC
972
972
  *
@@ -1401,7 +1401,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1401
1401
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1402
1402
  * See the License for the specific language governing permissions and
1403
1403
  * limitations under the License.
1404
- */let mn;class Rp{constructor(){this.views=new Map}}function Ip(n){m(!mn,"__referenceConstructor has already been defined"),mn=n}function Np(){return m(mn,"Reference.ts has not been loaded"),mn}function kp(n){return n.views.size===0}function ir(n,e,t,s){const r=e.source.queryId;if(r!==null){const i=n.views.get(r);return m(i!=null,"SyncTree gave us an op for an invalid query."),bi(i,e,t,s)}else{let i=[];for(const o of n.views.values())i=i.concat(bi(o,e,t,s));return i}}function Ap(n,e,t,s,r){const i=e._queryIdentifier,o=n.views.get(i);if(!o){let a=fn(t,r?s:null),c=!1;a?c=!0:s instanceof E?(a=nr(t,s),c=!1):(a=E.EMPTY_NODE,c=!1);const l=xn(new Fe(a,c,!1),new Fe(s,r,!1));return new vp(e,l)}return o}function Op(n,e,t,s,r,i){const o=Ap(n,e,s,r,i);return n.views.has(e._queryIdentifier)||n.views.set(e._queryIdentifier,o),Sp(o,t),Tp(o,t)}function xp(n,e,t,s){const r=e._queryIdentifier,i=[];let o=[];const a=Se(n);if(r==="default")for(const[c,l]of n.views.entries())o=o.concat(vi(l,t,s)),wi(l)&&(n.views.delete(c),l.query._queryParams.loadsAllData()||i.push(l.query));else{const c=n.views.get(r);c&&(o=o.concat(vi(c,t,s)),wi(c)&&(n.views.delete(r),c.query._queryParams.loadsAllData()||i.push(c.query)))}return a&&!Se(n)&&i.push(new(Np())(e._repo,e._path)),{removed:i,events:o}}function Ka(n){const e=[];for(const t of n.views.values())t.query._queryParams.loadsAllData()||e.push(t);return e}function Ke(n,e){let t=null;for(const s of n.views.values())t=t||Cp(s,e);return t}function Ga(n,e){if(e._queryParams.loadsAllData())return Pn(n);{const s=e._queryIdentifier;return n.views.get(s)}}function Ya(n,e){return Ga(n,e)!=null}function Se(n){return Pn(n)!=null}function Pn(n){for(const e of n.views.values())if(e.query._queryParams.loadsAllData())return e;return null}/**
1404
+ */let mn;class Rp{constructor(){this.views=new Map}}function Ip(n){m(!mn,"__referenceConstructor has already been defined"),mn=n}function Np(){return m(mn,"Reference.ts has not been loaded"),mn}function Ap(n){return n.views.size===0}function ir(n,e,t,s){const r=e.source.queryId;if(r!==null){const i=n.views.get(r);return m(i!=null,"SyncTree gave us an op for an invalid query."),bi(i,e,t,s)}else{let i=[];for(const o of n.views.values())i=i.concat(bi(o,e,t,s));return i}}function kp(n,e,t,s,r){const i=e._queryIdentifier,o=n.views.get(i);if(!o){let a=fn(t,r?s:null),c=!1;a?c=!0:s instanceof E?(a=nr(t,s),c=!1):(a=E.EMPTY_NODE,c=!1);const l=xn(new Fe(a,c,!1),new Fe(s,r,!1));return new vp(e,l)}return o}function Op(n,e,t,s,r,i){const o=kp(n,e,s,r,i);return n.views.has(e._queryIdentifier)||n.views.set(e._queryIdentifier,o),Sp(o,t),Tp(o,t)}function xp(n,e,t,s){const r=e._queryIdentifier,i=[];let o=[];const a=Se(n);if(r==="default")for(const[c,l]of n.views.entries())o=o.concat(vi(l,t,s)),wi(l)&&(n.views.delete(c),l.query._queryParams.loadsAllData()||i.push(l.query));else{const c=n.views.get(r);c&&(o=o.concat(vi(c,t,s)),wi(c)&&(n.views.delete(r),c.query._queryParams.loadsAllData()||i.push(c.query)))}return a&&!Se(n)&&i.push(new(Np())(e._repo,e._path)),{removed:i,events:o}}function Ka(n){const e=[];for(const t of n.views.values())t.query._queryParams.loadsAllData()||e.push(t);return e}function Ke(n,e){let t=null;for(const s of n.views.values())t=t||Cp(s,e);return t}function Ga(n,e){if(e._queryParams.loadsAllData())return Pn(n);{const s=e._queryIdentifier;return n.views.get(s)}}function Ya(n,e){return Ga(n,e)!=null}function Se(n){return Pn(n)!=null}function Pn(n){for(const e of n.views.values())if(e.query._queryParams.loadsAllData())return e;return null}/**
1405
1405
  * @license
1406
1406
  * Copyright 2017 Google LLC
1407
1407
  *
@@ -1416,7 +1416,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1416
1416
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1417
1417
  * See the License for the specific language governing permissions and
1418
1418
  * limitations under the License.
1419
- */let gn;function Pp(n){m(!gn,"__referenceConstructor has already been defined"),gn=n}function Dp(){return m(gn,"Reference.ts has not been loaded"),gn}let Lp=1;class Ci{constructor(e){this.listenProvider_=e,this.syncPointTree_=new M(null),this.pendingWriteTree_=lp(),this.tagToQueryMap=new Map,this.queryToTagMap=new Map}}function Fp(n,e,t,s,r){return Xf(n.pendingWriteTree_,e,t,s,r),r?Lt(n,new Le(Ma(),e,t)):[]}function qe(n,e,t=!1){const s=Zf(n.pendingWriteTree_,e);if(ep(n.pendingWriteTree_,e)){let i=new M(null);return s.snap!=null?i=i.set(N(),!0):Z(s.children,o=>{i=i.set(new D(o),!0)}),Lt(n,new dn(s.path,i,t))}else return[]}function Dn(n,e,t){return Lt(n,new Le(Zs(),e,t))}function Mp(n,e,t){const s=M.fromObject(t);return Lt(n,new Rt(Zs(),e,s))}function Bp(n,e){return Lt(n,new Tt(Zs(),e))}function Up(n,e,t){const s=or(n,t);if(s){const r=ar(s),i=r.path,o=r.queryId,a=Q(i,e),c=new Tt(er(o),a);return cr(n,i,c)}else return[]}function ks(n,e,t,s,r=!1){const i=e._path,o=n.syncPointTree_.get(i);let a=[];if(o&&(e._queryIdentifier==="default"||Ya(o,e))){const c=xp(o,e,t,s);kp(o)&&(n.syncPointTree_=n.syncPointTree_.remove(i));const l=c.removed;if(a=c.events,!r){const h=l.findIndex(d=>d._queryParams.loadsAllData())!==-1,u=n.syncPointTree_.findOnPath(i,(d,_)=>Se(_));if(h&&!u){const d=n.syncPointTree_.subtree(i);if(!d.isEmpty()){const _=qp(d);for(let p=0;p<_.length;++p){const y=_[p],g=y.query,I=Za(n,y);n.listenProvider_.startListening(mt(g),yn(n,g),I.hashFn,I.onComplete)}}}!u&&l.length>0&&!s&&(h?n.listenProvider_.stopListening(mt(e),null):l.forEach(d=>{const _=n.queryToTagMap.get(Ln(d));n.listenProvider_.stopListening(mt(d),_)}))}Vp(n,l)}return a}function Hp(n,e,t,s){const r=or(n,s);if(r!=null){const i=ar(r),o=i.path,a=i.queryId,c=Q(o,e),l=new Le(er(a),c,t);return cr(n,o,l)}else return[]}function Wp(n,e,t,s){const r=or(n,s);if(r){const i=ar(r),o=i.path,a=i.queryId,c=Q(o,e),l=M.fromObject(t),h=new Rt(er(a),c,l);return cr(n,o,h)}else return[]}function Si(n,e,t,s=!1){const r=e._path;let i=null,o=!1;n.syncPointTree_.foreachOnPath(r,(d,_)=>{const p=Q(d,r);i=i||Ke(_,p),o=o||Se(_)});let a=n.syncPointTree_.get(r);a?(o=o||Se(a),i=i||Ke(a,N())):(a=new Rp,n.syncPointTree_=n.syncPointTree_.set(r,a));let c;i!=null?c=!0:(c=!1,i=E.EMPTY_NODE,n.syncPointTree_.subtree(r).foreachChild((_,p)=>{const y=Ke(p,N());y&&(i=i.updateImmediateChild(_,y))}));const l=Ya(a,e);if(!l&&!e._queryParams.loadsAllData()){const d=Ln(e);m(!n.queryToTagMap.has(d),"View does not exist, but we have a tag");const _=$p();n.queryToTagMap.set(d,_),n.tagToQueryMap.set(_,d)}const h=tr(n.pendingWriteTree_,r);let u=Op(a,e,t,h,i,c);if(!l&&!o&&!s){const d=Ga(a,e);u=u.concat(zp(n,e,d))}return u}function Qa(n,e,t){const r=n.pendingWriteTree_,i=n.syncPointTree_.findOnPath(e,(o,a)=>{const c=Q(o,e),l=Ke(a,c);if(l)return l});return Wa(r,e,i,t,!0)}function Lt(n,e){return Ja(e,n.syncPointTree_,null,tr(n.pendingWriteTree_,N()))}function Ja(n,e,t,s){if(S(n.path))return Xa(n,e,t,s);{const r=e.get(N());t==null&&r!=null&&(t=Ke(r,N()));let i=[];const o=C(n.path),a=n.operationForChild(o),c=e.children.get(o);if(c&&a){const l=t?t.getImmediateChild(o):null,h=qa(s,o);i=i.concat(Ja(a,c,l,h))}return r&&(i=i.concat(ir(r,n,s,t))),i}}function Xa(n,e,t,s){const r=e.get(N());t==null&&r!=null&&(t=Ke(r,N()));let i=[];return e.children.inorderTraversal((o,a)=>{const c=t?t.getImmediateChild(o):null,l=qa(s,o),h=n.operationForChild(o);h&&(i=i.concat(Xa(h,a,c,l)))}),r&&(i=i.concat(ir(r,n,s,t))),i}function Za(n,e){const t=e.query,s=yn(n,t);return{hashFn:()=>(bp(e)||E.EMPTY_NODE).hash(),onComplete:r=>{if(r==="ok")return s?Up(n,t._path,s):Bp(n,t._path);{const i=Bd(r,t);return ks(n,t,null,i)}}}}function yn(n,e){const t=Ln(e);return n.queryToTagMap.get(t)}function Ln(n){return n._path.toString()+"$"+n._queryIdentifier}function or(n,e){return n.tagToQueryMap.get(e)}function ar(n){const e=n.indexOf("$");return m(e!==-1&&e<n.length-1,"Bad queryKey."),{queryId:n.substr(e+1),path:new D(n.substr(0,e))}}function cr(n,e,t){const s=n.syncPointTree_.get(e);m(s,"Missing sync point for query tag that we're tracking");const r=tr(n.pendingWriteTree_,e);return ir(s,t,r,null)}function qp(n){return n.fold((e,t,s)=>{if(t&&Se(t))return[Pn(t)];{let r=[];return t&&(r=Ka(t)),Z(s,(i,o)=>{r=r.concat(o)}),r}})}function mt(n){return n._queryParams.loadsAllData()&&!n._queryParams.isDefault()?new(Dp())(n._repo,n._path):n}function Vp(n,e){for(let t=0;t<e.length;++t){const s=e[t];if(!s._queryParams.loadsAllData()){const r=Ln(s),i=n.queryToTagMap.get(r);n.queryToTagMap.delete(r),n.tagToQueryMap.delete(i)}}}function $p(){return Lp++}function zp(n,e,t){const s=e._path,r=yn(n,e),i=Za(n,t),o=n.listenProvider_.startListening(mt(e),r,i.hashFn,i.onComplete),a=n.syncPointTree_.subtree(s);if(r)m(!Se(a.value),"If we're adding a query, it shouldn't be shadowed");else{const c=a.fold((l,h,u)=>{if(!S(l)&&h&&Se(h))return[Pn(h).query];{let d=[];return h&&(d=d.concat(Ka(h).map(_=>_.query))),Z(u,(_,p)=>{d=d.concat(p)}),d}});for(let l=0;l<c.length;++l){const h=c[l];n.listenProvider_.stopListening(mt(h),yn(n,h))}}return o}/**
1419
+ */let gn;function Pp(n){m(!gn,"__referenceConstructor has already been defined"),gn=n}function Dp(){return m(gn,"Reference.ts has not been loaded"),gn}let Lp=1;class Ci{constructor(e){this.listenProvider_=e,this.syncPointTree_=new M(null),this.pendingWriteTree_=lp(),this.tagToQueryMap=new Map,this.queryToTagMap=new Map}}function Fp(n,e,t,s,r){return Xf(n.pendingWriteTree_,e,t,s,r),r?Lt(n,new Le(Ma(),e,t)):[]}function qe(n,e,t=!1){const s=Zf(n.pendingWriteTree_,e);if(ep(n.pendingWriteTree_,e)){let i=new M(null);return s.snap!=null?i=i.set(N(),!0):Z(s.children,o=>{i=i.set(new D(o),!0)}),Lt(n,new dn(s.path,i,t))}else return[]}function Dn(n,e,t){return Lt(n,new Le(Zs(),e,t))}function Mp(n,e,t){const s=M.fromObject(t);return Lt(n,new Rt(Zs(),e,s))}function Bp(n,e){return Lt(n,new Tt(Zs(),e))}function Up(n,e,t){const s=or(n,t);if(s){const r=ar(s),i=r.path,o=r.queryId,a=Q(i,e),c=new Tt(er(o),a);return cr(n,i,c)}else return[]}function As(n,e,t,s,r=!1){const i=e._path,o=n.syncPointTree_.get(i);let a=[];if(o&&(e._queryIdentifier==="default"||Ya(o,e))){const c=xp(o,e,t,s);Ap(o)&&(n.syncPointTree_=n.syncPointTree_.remove(i));const l=c.removed;if(a=c.events,!r){const h=l.findIndex(d=>d._queryParams.loadsAllData())!==-1,u=n.syncPointTree_.findOnPath(i,(d,_)=>Se(_));if(h&&!u){const d=n.syncPointTree_.subtree(i);if(!d.isEmpty()){const _=qp(d);for(let p=0;p<_.length;++p){const y=_[p],g=y.query,I=Za(n,y);n.listenProvider_.startListening(mt(g),yn(n,g),I.hashFn,I.onComplete)}}}!u&&l.length>0&&!s&&(h?n.listenProvider_.stopListening(mt(e),null):l.forEach(d=>{const _=n.queryToTagMap.get(Ln(d));n.listenProvider_.stopListening(mt(d),_)}))}Vp(n,l)}return a}function Hp(n,e,t,s){const r=or(n,s);if(r!=null){const i=ar(r),o=i.path,a=i.queryId,c=Q(o,e),l=new Le(er(a),c,t);return cr(n,o,l)}else return[]}function Wp(n,e,t,s){const r=or(n,s);if(r){const i=ar(r),o=i.path,a=i.queryId,c=Q(o,e),l=M.fromObject(t),h=new Rt(er(a),c,l);return cr(n,o,h)}else return[]}function Si(n,e,t,s=!1){const r=e._path;let i=null,o=!1;n.syncPointTree_.foreachOnPath(r,(d,_)=>{const p=Q(d,r);i=i||Ke(_,p),o=o||Se(_)});let a=n.syncPointTree_.get(r);a?(o=o||Se(a),i=i||Ke(a,N())):(a=new Rp,n.syncPointTree_=n.syncPointTree_.set(r,a));let c;i!=null?c=!0:(c=!1,i=E.EMPTY_NODE,n.syncPointTree_.subtree(r).foreachChild((_,p)=>{const y=Ke(p,N());y&&(i=i.updateImmediateChild(_,y))}));const l=Ya(a,e);if(!l&&!e._queryParams.loadsAllData()){const d=Ln(e);m(!n.queryToTagMap.has(d),"View does not exist, but we have a tag");const _=$p();n.queryToTagMap.set(d,_),n.tagToQueryMap.set(_,d)}const h=tr(n.pendingWriteTree_,r);let u=Op(a,e,t,h,i,c);if(!l&&!o&&!s){const d=Ga(a,e);u=u.concat(zp(n,e,d))}return u}function Qa(n,e,t){const r=n.pendingWriteTree_,i=n.syncPointTree_.findOnPath(e,(o,a)=>{const c=Q(o,e),l=Ke(a,c);if(l)return l});return Wa(r,e,i,t,!0)}function Lt(n,e){return Ja(e,n.syncPointTree_,null,tr(n.pendingWriteTree_,N()))}function Ja(n,e,t,s){if(S(n.path))return Xa(n,e,t,s);{const r=e.get(N());t==null&&r!=null&&(t=Ke(r,N()));let i=[];const o=C(n.path),a=n.operationForChild(o),c=e.children.get(o);if(c&&a){const l=t?t.getImmediateChild(o):null,h=qa(s,o);i=i.concat(Ja(a,c,l,h))}return r&&(i=i.concat(ir(r,n,s,t))),i}}function Xa(n,e,t,s){const r=e.get(N());t==null&&r!=null&&(t=Ke(r,N()));let i=[];return e.children.inorderTraversal((o,a)=>{const c=t?t.getImmediateChild(o):null,l=qa(s,o),h=n.operationForChild(o);h&&(i=i.concat(Xa(h,a,c,l)))}),r&&(i=i.concat(ir(r,n,s,t))),i}function Za(n,e){const t=e.query,s=yn(n,t);return{hashFn:()=>(bp(e)||E.EMPTY_NODE).hash(),onComplete:r=>{if(r==="ok")return s?Up(n,t._path,s):Bp(n,t._path);{const i=Bd(r,t);return As(n,t,null,i)}}}}function yn(n,e){const t=Ln(e);return n.queryToTagMap.get(t)}function Ln(n){return n._path.toString()+"$"+n._queryIdentifier}function or(n,e){return n.tagToQueryMap.get(e)}function ar(n){const e=n.indexOf("$");return m(e!==-1&&e<n.length-1,"Bad queryKey."),{queryId:n.substr(e+1),path:new D(n.substr(0,e))}}function cr(n,e,t){const s=n.syncPointTree_.get(e);m(s,"Missing sync point for query tag that we're tracking");const r=tr(n.pendingWriteTree_,e);return ir(s,t,r,null)}function qp(n){return n.fold((e,t,s)=>{if(t&&Se(t))return[Pn(t)];{let r=[];return t&&(r=Ka(t)),Z(s,(i,o)=>{r=r.concat(o)}),r}})}function mt(n){return n._queryParams.loadsAllData()&&!n._queryParams.isDefault()?new(Dp())(n._repo,n._path):n}function Vp(n,e){for(let t=0;t<e.length;++t){const s=e[t];if(!s._queryParams.loadsAllData()){const r=Ln(s),i=n.queryToTagMap.get(r);n.queryToTagMap.delete(r),n.tagToQueryMap.delete(i)}}}function $p(){return Lp++}function zp(n,e,t){const s=e._path,r=yn(n,e),i=Za(n,t),o=n.listenProvider_.startListening(mt(e),r,i.hashFn,i.onComplete),a=n.syncPointTree_.subtree(s);if(r)m(!Se(a.value),"If we're adding a query, it shouldn't be shadowed");else{const c=a.fold((l,h,u)=>{if(!S(l)&&h&&Se(h))return[Pn(h).query];{let d=[];return h&&(d=d.concat(Ka(h).map(_=>_.query))),Z(u,(_,p)=>{d=d.concat(p)}),d}});for(let l=0;l<c.length;++l){const h=c[l];n.listenProvider_.stopListening(mt(h),yn(n,h))}}return o}/**
1420
1420
  * @license
1421
1421
  * Copyright 2017 Google LLC
1422
1422
  *
@@ -1446,7 +1446,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1446
1446
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1447
1447
  * See the License for the specific language governing permissions and
1448
1448
  * limitations under the License.
1449
- */class dr{constructor(e="",t=null,s={children:{},childCount:0}){this.name=e,this.parent=t,this.node=s}}function fr(n,e){let t=e instanceof D?e:new D(e),s=n,r=C(t);for(;r!==null;){const i=Ge(s.node.children,r)||{children:{},childCount:0};s=new dr(r,s,i),t=F(t),r=C(t)}return s}function st(n){return n.node.value}function ec(n,e){n.node.value=e,As(n)}function tc(n){return n.node.childCount>0}function Jp(n){return st(n)===void 0&&!tc(n)}function Fn(n,e){Z(n.node.children,(t,s)=>{e(new dr(t,n,s))})}function nc(n,e,t,s){t&&e(n),Fn(n,r=>{nc(r,e,!0)})}function Xp(n,e,t){let s=n.parent;for(;s!==null;){if(e(s))return!0;s=s.parent}return!1}function Ft(n){return new D(n.parent===null?n.name:Ft(n.parent)+"/"+n.name)}function As(n){n.parent!==null&&Zp(n.parent,n.name,n)}function Zp(n,e,t){const s=Jp(t),r=me(n.node.children,e);s&&r?(delete n.node.children[e],n.node.childCount--,As(n)):!s&&!r&&(n.node.children[e]=t.node,n.node.childCount++,As(n))}/**
1449
+ */class dr{constructor(e="",t=null,s={children:{},childCount:0}){this.name=e,this.parent=t,this.node=s}}function fr(n,e){let t=e instanceof D?e:new D(e),s=n,r=C(t);for(;r!==null;){const i=Ge(s.node.children,r)||{children:{},childCount:0};s=new dr(r,s,i),t=F(t),r=C(t)}return s}function st(n){return n.node.value}function ec(n,e){n.node.value=e,ks(n)}function tc(n){return n.node.childCount>0}function Jp(n){return st(n)===void 0&&!tc(n)}function Fn(n,e){Z(n.node.children,(t,s)=>{e(new dr(t,n,s))})}function nc(n,e,t,s){t&&e(n),Fn(n,r=>{nc(r,e,!0)})}function Xp(n,e,t){let s=n.parent;for(;s!==null;){if(e(s))return!0;s=s.parent}return!1}function Ft(n){return new D(n.parent===null?n.name:Ft(n.parent)+"/"+n.name)}function ks(n){n.parent!==null&&Zp(n.parent,n.name,n)}function Zp(n,e,t){const s=Jp(t),r=me(n.node.children,e);s&&r?(delete n.node.children[e],n.node.childCount--,ks(n)):!s&&!r&&(n.node.children[e]=t.node,n.node.childCount++,ks(n))}/**
1450
1450
  * @license
1451
1451
  * Copyright 2017 Google LLC
1452
1452
  *
@@ -1461,7 +1461,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1461
1461
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1462
1462
  * See the License for the specific language governing permissions and
1463
1463
  * limitations under the License.
1464
- */const e_=/[\[\].#$\/\u0000-\u001F\u007F]/,t_=/[\[\].#$\u0000-\u001F\u007F]/,es=10*1024*1024,sc=function(n){return typeof n=="string"&&n.length!==0&&!e_.test(n)},rc=function(n){return typeof n=="string"&&n.length!==0&&!t_.test(n)},n_=function(n){return n&&(n=n.replace(/^\/*\.info(\/|$)/,"/")),rc(n)},ic=function(n,e,t){const s=t instanceof D?new yf(t,n):t;if(e===void 0)throw new Error(n+"contains undefined "+Ie(s));if(typeof e=="function")throw new Error(n+"contains a function "+Ie(s)+" with contents = "+e.toString());if(ia(e))throw new Error(n+"contains "+e.toString()+" "+Ie(s));if(typeof e=="string"&&e.length>es/3&&kn(e)>es)throw new Error(n+"contains a string greater than "+es+" utf8 bytes "+Ie(s)+" ('"+e.substring(0,50)+"...')");if(e&&typeof e=="object"){let r=!1,i=!1;if(Z(e,(o,a)=>{if(o===".value")r=!0;else if(o!==".priority"&&o!==".sv"&&(i=!0,!sc(o)))throw new Error(n+" contains an invalid key ("+o+") "+Ie(s)+`. Keys must be non-empty strings and can't contain ".", "#", "$", "/", "[", or "]"`);Ef(s,o),ic(n,a,s),wf(s)}),r&&i)throw new Error(n+' contains ".value" child '+Ie(s)+" in addition to actual children.")}},oc=function(n,e,t,s){if(!rc(t))throw new Error(Yo(n,e)+'was an invalid path = "'+t+`". Paths must be non-empty strings and can't contain ".", "#", "$", "[", or "]"`)},s_=function(n,e,t,s){t&&(t=t.replace(/^\/*\.info(\/|$)/,"/")),oc(n,e,t)},r_=function(n,e){const t=e.path.toString();if(typeof e.repoInfo.host!="string"||e.repoInfo.host.length===0||!sc(e.repoInfo.namespace)&&e.repoInfo.host.split(":")[0]!=="localhost"||t.length!==0&&!n_(t))throw new Error(Yo(n,"url")+`must be a valid firebase URL and the path can't contain ".", "#", "$", "[", or "]".`)};/**
1464
+ */const e_=/[\[\].#$\/\u0000-\u001F\u007F]/,t_=/[\[\].#$\u0000-\u001F\u007F]/,es=10*1024*1024,sc=function(n){return typeof n=="string"&&n.length!==0&&!e_.test(n)},rc=function(n){return typeof n=="string"&&n.length!==0&&!t_.test(n)},n_=function(n){return n&&(n=n.replace(/^\/*\.info(\/|$)/,"/")),rc(n)},ic=function(n,e,t){const s=t instanceof D?new yf(t,n):t;if(e===void 0)throw new Error(n+"contains undefined "+Ie(s));if(typeof e=="function")throw new Error(n+"contains a function "+Ie(s)+" with contents = "+e.toString());if(ia(e))throw new Error(n+"contains "+e.toString()+" "+Ie(s));if(typeof e=="string"&&e.length>es/3&&An(e)>es)throw new Error(n+"contains a string greater than "+es+" utf8 bytes "+Ie(s)+" ('"+e.substring(0,50)+"...')");if(e&&typeof e=="object"){let r=!1,i=!1;if(Z(e,(o,a)=>{if(o===".value")r=!0;else if(o!==".priority"&&o!==".sv"&&(i=!0,!sc(o)))throw new Error(n+" contains an invalid key ("+o+") "+Ie(s)+`. Keys must be non-empty strings and can't contain ".", "#", "$", "/", "[", or "]"`);Ef(s,o),ic(n,a,s),wf(s)}),r&&i)throw new Error(n+' contains ".value" child '+Ie(s)+" in addition to actual children.")}},oc=function(n,e,t,s){if(!rc(t))throw new Error(Yo(n,e)+'was an invalid path = "'+t+`". Paths must be non-empty strings and can't contain ".", "#", "$", "[", or "]"`)},s_=function(n,e,t,s){t&&(t=t.replace(/^\/*\.info(\/|$)/,"/")),oc(n,e,t)},r_=function(n,e){const t=e.path.toString();if(typeof e.repoInfo.host!="string"||e.repoInfo.host.length===0||!sc(e.repoInfo.namespace)&&e.repoInfo.host.split(":")[0]!=="localhost"||t.length!==0&&!n_(t))throw new Error(Yo(n,"url")+`must be a valid firebase URL and the path can't contain ".", "#", "$", "[", or "]".`)};/**
1465
1465
  * @license
1466
1466
  * Copyright 2017 Google LLC
1467
1467
  *
@@ -1491,7 +1491,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1491
1491
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1492
1492
  * See the License for the specific language governing permissions and
1493
1493
  * limitations under the License.
1494
- */const a_="repo_interrupt",c_=25;class l_{constructor(e,t,s,r){this.repoInfo_=e,this.forceRestClient_=t,this.authTokenProvider_=s,this.appCheckProvider_=r,this.dataUpdateCount=0,this.statsListener_=null,this.eventQueue_=new i_,this.nextWriteId_=1,this.interceptServerDataCallback_=null,this.onDisconnect_=un(),this.transactionQueueTree_=new dr,this.persistentConnection_=null,this.key=this.repoInfo_.toURLString()}toString(){return(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host}}function h_(n,e,t){if(n.stats_=js(n.repoInfo_),n.forceRestClient_||qd())n.server_=new hn(n.repoInfo_,(s,r,i,o)=>{Ri(n,s,r,i,o)},n.authTokenProvider_,n.appCheckProvider_),setTimeout(()=>Ii(n,!0),0);else{if(typeof t<"u"&&t!==null){if(typeof t!="object")throw new Error("Only objects are supported for option databaseAuthVariableOverride");try{$(t)}catch(s){throw new Error("Invalid authOverride provided: "+s)}}n.persistentConnection_=new fe(n.repoInfo_,e,(s,r,i,o)=>{Ri(n,s,r,i,o)},s=>{Ii(n,s)},s=>{d_(n,s)},n.authTokenProvider_,n.appCheckProvider_,t),n.server_=n.persistentConnection_}n.authTokenProvider_.addTokenChangeListener(s=>{n.server_.refreshAuthToken(s)}),n.appCheckProvider_.addTokenChangeListener(s=>{n.server_.refreshAppCheckToken(s.token)}),n.statsReporter_=Kd(n.repoInfo_,()=>new jf(n.stats_,n.server_)),n.infoData_=new Wf,n.infoSyncTree_=new Ci({startListening:(s,r,i,o)=>{let a=[];const c=n.infoData_.getNode(s._path);return c.isEmpty()||(a=Dn(n.infoSyncTree_,s._path,c),setTimeout(()=>{o("ok")},0)),a},stopListening:()=>{}}),pr(n,"connected",!1),n.serverSyncTree_=new Ci({startListening:(s,r,i,o)=>(n.server_.listen(s,i,r,(a,c)=>{const l=o(a,c);Ue(n.eventQueue_,s._path,l)}),[]),stopListening:(s,r)=>{n.server_.unlisten(s,r)}})}function u_(n){const t=n.infoData_.getNode(new D(".info/serverTimeOffset")).val()||0;return new Date().getTime()+t}function hc(n){return jp({timestamp:u_(n)})}function Ri(n,e,t,s,r){n.dataUpdateCount++;const i=new D(e);t=n.interceptServerDataCallback_?n.interceptServerDataCallback_(e,t):t;let o=[];if(r)if(s){const c=nn(t,l=>j(l));o=Wp(n.serverSyncTree_,i,c,r)}else{const c=j(t);o=Hp(n.serverSyncTree_,i,c,r)}else if(s){const c=nn(t,l=>j(l));o=Mp(n.serverSyncTree_,i,c)}else{const c=j(t);o=Dn(n.serverSyncTree_,i,c)}let a=i;o.length>0&&(a=mr(n,i)),Ue(n.eventQueue_,a,o)}function Ii(n,e){pr(n,"connected",e),e===!1&&p_(n)}function d_(n,e){Z(e,(t,s)=>{pr(n,t,s)})}function pr(n,e,t){const s=new D("/.info/"+e),r=j(t);n.infoData_.updateSnapshot(s,r);const i=Dn(n.infoSyncTree_,s,r);Ue(n.eventQueue_,s,i)}function f_(n){return n.nextWriteId_++}function p_(n){uc(n,"onDisconnectEvents");const e=hc(n),t=un();Cs(n.onDisconnect_,N(),(r,i)=>{const o=Yp(r,i,n.serverSyncTree_,e);Fa(t,r,o)});let s=[];Cs(t,N(),(r,i)=>{s=s.concat(Dn(n.serverSyncTree_,r,i));const o=w_(n,r);mr(n,o)}),n.onDisconnect_=un(),Ue(n.eventQueue_,N(),s)}function __(n,e,t){let s;C(e._path)===".info"?s=Si(n.infoSyncTree_,e,t):s=Si(n.serverSyncTree_,e,t),cc(n.eventQueue_,e._path,s)}function m_(n,e,t){let s;C(e._path)===".info"?s=ks(n.infoSyncTree_,e,t):s=ks(n.serverSyncTree_,e,t),cc(n.eventQueue_,e._path,s)}function g_(n){n.persistentConnection_&&n.persistentConnection_.interrupt(a_)}function uc(n,...e){let t="";n.persistentConnection_&&(t=n.persistentConnection_.id+":"),z(t,...e)}function dc(n,e,t){return Qa(n.serverSyncTree_,e,t)||E.EMPTY_NODE}function _r(n,e=n.transactionQueueTree_){if(e||Mn(n,e),st(e)){const t=pc(n,e);m(t.length>0,"Sending zero length transaction queue"),t.every(r=>r.status===0)&&y_(n,Ft(e),t)}else tc(e)&&Fn(e,t=>{_r(n,t)})}function y_(n,e,t){const s=t.map(l=>l.currentWriteId),r=dc(n,e,s);let i=r;const o=r.hash();for(let l=0;l<t.length;l++){const h=t[l];m(h.status===0,"tryToSendTransactionQueue_: items in queue should all be run."),h.status=1,h.retryCount++;const u=Q(e,h.path);i=i.updateChild(u,h.currentOutputSnapshotRaw)}const a=i.val(!0),c=e;n.server_.put(c.toString(),a,l=>{uc(n,"transaction put response",{path:c.toString(),status:l});let h=[];if(l==="ok"){const u=[];for(let d=0;d<t.length;d++)t[d].status=2,h=h.concat(qe(n.serverSyncTree_,t[d].currentWriteId)),t[d].onComplete&&u.push(()=>t[d].onComplete(null,!0,t[d].currentOutputSnapshotResolved)),t[d].unwatcher();Mn(n,fr(n.transactionQueueTree_,e)),_r(n,n.transactionQueueTree_),Ue(n.eventQueue_,e,h);for(let d=0;d<u.length;d++)Pt(u[d])}else{if(l==="datastale")for(let u=0;u<t.length;u++)t[u].status===3?t[u].status=4:t[u].status=0;else{te("transaction at "+c.toString()+" failed: "+l);for(let u=0;u<t.length;u++)t[u].status=4,t[u].abortReason=l}mr(n,e)}},o)}function mr(n,e){const t=fc(n,e),s=Ft(t),r=pc(n,t);return E_(n,r,s),s}function E_(n,e,t){if(e.length===0)return;const s=[];let r=[];const o=e.filter(a=>a.status===0).map(a=>a.currentWriteId);for(let a=0;a<e.length;a++){const c=e[a],l=Q(t,c.path);let h=!1,u;if(m(l!==null,"rerunTransactionsUnderNode_: relativePath should not be null."),c.status===4)h=!0,u=c.abortReason,r=r.concat(qe(n.serverSyncTree_,c.currentWriteId,!0));else if(c.status===0)if(c.retryCount>=c_)h=!0,u="maxretry",r=r.concat(qe(n.serverSyncTree_,c.currentWriteId,!0));else{const d=dc(n,c.path,o);c.currentInputSnapshot=d;const _=e[a].update(d.val());if(_!==void 0){ic("transaction failed: Data returned ",_,c.path);let p=j(_);typeof _=="object"&&_!=null&&me(_,".priority")||(p=p.updatePriority(d.getPriority()));const g=c.currentWriteId,I=hc(n),O=Qp(p,d,I);c.currentOutputSnapshotRaw=p,c.currentOutputSnapshotResolved=O,c.currentWriteId=f_(n),o.splice(o.indexOf(g),1),r=r.concat(Fp(n.serverSyncTree_,c.path,O,c.currentWriteId,c.applyLocally)),r=r.concat(qe(n.serverSyncTree_,g,!0))}else h=!0,u="nodata",r=r.concat(qe(n.serverSyncTree_,c.currentWriteId,!0))}Ue(n.eventQueue_,t,r),r=[],h&&(e[a].status=2,function(d){setTimeout(d,Math.floor(0))}(e[a].unwatcher),e[a].onComplete&&(u==="nodata"?s.push(()=>e[a].onComplete(null,!1,e[a].currentInputSnapshot)):s.push(()=>e[a].onComplete(new Error(u),!1,null))))}Mn(n,n.transactionQueueTree_);for(let a=0;a<s.length;a++)Pt(s[a]);_r(n,n.transactionQueueTree_)}function fc(n,e){let t,s=n.transactionQueueTree_;for(t=C(e);t!==null&&st(s)===void 0;)s=fr(s,t),e=F(e),t=C(e);return s}function pc(n,e){const t=[];return _c(n,e,t),t.sort((s,r)=>s.order-r.order),t}function _c(n,e,t){const s=st(e);if(s)for(let r=0;r<s.length;r++)t.push(s[r]);Fn(e,r=>{_c(n,r,t)})}function Mn(n,e){const t=st(e);if(t){let s=0;for(let r=0;r<t.length;r++)t[r].status!==2&&(t[s]=t[r],s++);t.length=s,ec(e,t.length>0?t:void 0)}Fn(e,s=>{Mn(n,s)})}function w_(n,e){const t=Ft(fc(n,e)),s=fr(n.transactionQueueTree_,e);return Xp(s,r=>{ts(n,r)}),ts(n,s),nc(s,r=>{ts(n,r)}),t}function ts(n,e){const t=st(e);if(t){const s=[];let r=[],i=-1;for(let o=0;o<t.length;o++)t[o].status===3||(t[o].status===1?(m(i===o-1,"All SENT items should be at beginning of queue."),i=o,t[o].status=3,t[o].abortReason="set"):(m(t[o].status===0,"Unexpected transaction status in abort"),t[o].unwatcher(),r=r.concat(qe(n.serverSyncTree_,t[o].currentWriteId,!0)),t[o].onComplete&&s.push(t[o].onComplete.bind(null,new Error("set"),!1,null))));i===-1?ec(e,void 0):t.length=i+1,Ue(n.eventQueue_,Ft(e),r);for(let o=0;o<s.length;o++)Pt(s[o])}}/**
1494
+ */const a_="repo_interrupt",c_=25;class l_{constructor(e,t,s,r){this.repoInfo_=e,this.forceRestClient_=t,this.authTokenProvider_=s,this.appCheckProvider_=r,this.dataUpdateCount=0,this.statsListener_=null,this.eventQueue_=new i_,this.nextWriteId_=1,this.interceptServerDataCallback_=null,this.onDisconnect_=un(),this.transactionQueueTree_=new dr,this.persistentConnection_=null,this.key=this.repoInfo_.toURLString()}toString(){return(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host}}function h_(n,e,t){if(n.stats_=js(n.repoInfo_),n.forceRestClient_||qd())n.server_=new hn(n.repoInfo_,(s,r,i,o)=>{Ri(n,s,r,i,o)},n.authTokenProvider_,n.appCheckProvider_),setTimeout(()=>Ii(n,!0),0);else{if(typeof t<"u"&&t!==null){if(typeof t!="object")throw new Error("Only objects are supported for option databaseAuthVariableOverride");try{$(t)}catch(s){throw new Error("Invalid authOverride provided: "+s)}}n.persistentConnection_=new fe(n.repoInfo_,e,(s,r,i,o)=>{Ri(n,s,r,i,o)},s=>{Ii(n,s)},s=>{d_(n,s)},n.authTokenProvider_,n.appCheckProvider_,t),n.server_=n.persistentConnection_}n.authTokenProvider_.addTokenChangeListener(s=>{n.server_.refreshAuthToken(s)}),n.appCheckProvider_.addTokenChangeListener(s=>{n.server_.refreshAppCheckToken(s.token)}),n.statsReporter_=Kd(n.repoInfo_,()=>new jf(n.stats_,n.server_)),n.infoData_=new Wf,n.infoSyncTree_=new Ci({startListening:(s,r,i,o)=>{let a=[];const c=n.infoData_.getNode(s._path);return c.isEmpty()||(a=Dn(n.infoSyncTree_,s._path,c),setTimeout(()=>{o("ok")},0)),a},stopListening:()=>{}}),pr(n,"connected",!1),n.serverSyncTree_=new Ci({startListening:(s,r,i,o)=>(n.server_.listen(s,i,r,(a,c)=>{const l=o(a,c);Ue(n.eventQueue_,s._path,l)}),[]),stopListening:(s,r)=>{n.server_.unlisten(s,r)}})}function u_(n){const t=n.infoData_.getNode(new D(".info/serverTimeOffset")).val()||0;return new Date().getTime()+t}function hc(n){return jp({timestamp:u_(n)})}function Ri(n,e,t,s,r){n.dataUpdateCount++;const i=new D(e);t=n.interceptServerDataCallback_?n.interceptServerDataCallback_(e,t):t;let o=[];if(r)if(s){const c=nn(t,l=>j(l));o=Wp(n.serverSyncTree_,i,c,r)}else{const c=j(t);o=Hp(n.serverSyncTree_,i,c,r)}else if(s){const c=nn(t,l=>j(l));o=Mp(n.serverSyncTree_,i,c)}else{const c=j(t);o=Dn(n.serverSyncTree_,i,c)}let a=i;o.length>0&&(a=mr(n,i)),Ue(n.eventQueue_,a,o)}function Ii(n,e){pr(n,"connected",e),e===!1&&p_(n)}function d_(n,e){Z(e,(t,s)=>{pr(n,t,s)})}function pr(n,e,t){const s=new D("/.info/"+e),r=j(t);n.infoData_.updateSnapshot(s,r);const i=Dn(n.infoSyncTree_,s,r);Ue(n.eventQueue_,s,i)}function f_(n){return n.nextWriteId_++}function p_(n){uc(n,"onDisconnectEvents");const e=hc(n),t=un();Cs(n.onDisconnect_,N(),(r,i)=>{const o=Yp(r,i,n.serverSyncTree_,e);Fa(t,r,o)});let s=[];Cs(t,N(),(r,i)=>{s=s.concat(Dn(n.serverSyncTree_,r,i));const o=w_(n,r);mr(n,o)}),n.onDisconnect_=un(),Ue(n.eventQueue_,N(),s)}function __(n,e,t){let s;C(e._path)===".info"?s=Si(n.infoSyncTree_,e,t):s=Si(n.serverSyncTree_,e,t),cc(n.eventQueue_,e._path,s)}function m_(n,e,t){let s;C(e._path)===".info"?s=As(n.infoSyncTree_,e,t):s=As(n.serverSyncTree_,e,t),cc(n.eventQueue_,e._path,s)}function g_(n){n.persistentConnection_&&n.persistentConnection_.interrupt(a_)}function uc(n,...e){let t="";n.persistentConnection_&&(t=n.persistentConnection_.id+":"),z(t,...e)}function dc(n,e,t){return Qa(n.serverSyncTree_,e,t)||E.EMPTY_NODE}function _r(n,e=n.transactionQueueTree_){if(e||Mn(n,e),st(e)){const t=pc(n,e);m(t.length>0,"Sending zero length transaction queue"),t.every(r=>r.status===0)&&y_(n,Ft(e),t)}else tc(e)&&Fn(e,t=>{_r(n,t)})}function y_(n,e,t){const s=t.map(l=>l.currentWriteId),r=dc(n,e,s);let i=r;const o=r.hash();for(let l=0;l<t.length;l++){const h=t[l];m(h.status===0,"tryToSendTransactionQueue_: items in queue should all be run."),h.status=1,h.retryCount++;const u=Q(e,h.path);i=i.updateChild(u,h.currentOutputSnapshotRaw)}const a=i.val(!0),c=e;n.server_.put(c.toString(),a,l=>{uc(n,"transaction put response",{path:c.toString(),status:l});let h=[];if(l==="ok"){const u=[];for(let d=0;d<t.length;d++)t[d].status=2,h=h.concat(qe(n.serverSyncTree_,t[d].currentWriteId)),t[d].onComplete&&u.push(()=>t[d].onComplete(null,!0,t[d].currentOutputSnapshotResolved)),t[d].unwatcher();Mn(n,fr(n.transactionQueueTree_,e)),_r(n,n.transactionQueueTree_),Ue(n.eventQueue_,e,h);for(let d=0;d<u.length;d++)Pt(u[d])}else{if(l==="datastale")for(let u=0;u<t.length;u++)t[u].status===3?t[u].status=4:t[u].status=0;else{te("transaction at "+c.toString()+" failed: "+l);for(let u=0;u<t.length;u++)t[u].status=4,t[u].abortReason=l}mr(n,e)}},o)}function mr(n,e){const t=fc(n,e),s=Ft(t),r=pc(n,t);return E_(n,r,s),s}function E_(n,e,t){if(e.length===0)return;const s=[];let r=[];const o=e.filter(a=>a.status===0).map(a=>a.currentWriteId);for(let a=0;a<e.length;a++){const c=e[a],l=Q(t,c.path);let h=!1,u;if(m(l!==null,"rerunTransactionsUnderNode_: relativePath should not be null."),c.status===4)h=!0,u=c.abortReason,r=r.concat(qe(n.serverSyncTree_,c.currentWriteId,!0));else if(c.status===0)if(c.retryCount>=c_)h=!0,u="maxretry",r=r.concat(qe(n.serverSyncTree_,c.currentWriteId,!0));else{const d=dc(n,c.path,o);c.currentInputSnapshot=d;const _=e[a].update(d.val());if(_!==void 0){ic("transaction failed: Data returned ",_,c.path);let p=j(_);typeof _=="object"&&_!=null&&me(_,".priority")||(p=p.updatePriority(d.getPriority()));const g=c.currentWriteId,I=hc(n),O=Qp(p,d,I);c.currentOutputSnapshotRaw=p,c.currentOutputSnapshotResolved=O,c.currentWriteId=f_(n),o.splice(o.indexOf(g),1),r=r.concat(Fp(n.serverSyncTree_,c.path,O,c.currentWriteId,c.applyLocally)),r=r.concat(qe(n.serverSyncTree_,g,!0))}else h=!0,u="nodata",r=r.concat(qe(n.serverSyncTree_,c.currentWriteId,!0))}Ue(n.eventQueue_,t,r),r=[],h&&(e[a].status=2,function(d){setTimeout(d,Math.floor(0))}(e[a].unwatcher),e[a].onComplete&&(u==="nodata"?s.push(()=>e[a].onComplete(null,!1,e[a].currentInputSnapshot)):s.push(()=>e[a].onComplete(new Error(u),!1,null))))}Mn(n,n.transactionQueueTree_);for(let a=0;a<s.length;a++)Pt(s[a]);_r(n,n.transactionQueueTree_)}function fc(n,e){let t,s=n.transactionQueueTree_;for(t=C(e);t!==null&&st(s)===void 0;)s=fr(s,t),e=F(e),t=C(e);return s}function pc(n,e){const t=[];return _c(n,e,t),t.sort((s,r)=>s.order-r.order),t}function _c(n,e,t){const s=st(e);if(s)for(let r=0;r<s.length;r++)t.push(s[r]);Fn(e,r=>{_c(n,r,t)})}function Mn(n,e){const t=st(e);if(t){let s=0;for(let r=0;r<t.length;r++)t[r].status!==2&&(t[s]=t[r],s++);t.length=s,ec(e,t.length>0?t:void 0)}Fn(e,s=>{Mn(n,s)})}function w_(n,e){const t=Ft(fc(n,e)),s=fr(n.transactionQueueTree_,e);return Xp(s,r=>{ts(n,r)}),ts(n,s),nc(s,r=>{ts(n,r)}),t}function ts(n,e){const t=st(e);if(t){const s=[];let r=[],i=-1;for(let o=0;o<t.length;o++)t[o].status===3||(t[o].status===1?(m(i===o-1,"All SENT items should be at beginning of queue."),i=o,t[o].status=3,t[o].abortReason="set"):(m(t[o].status===0,"Unexpected transaction status in abort"),t[o].unwatcher(),r=r.concat(qe(n.serverSyncTree_,t[o].currentWriteId,!0)),t[o].onComplete&&s.push(t[o].onComplete.bind(null,new Error("set"),!1,null))));i===-1?ec(e,void 0):t.length=i+1,Ue(n.eventQueue_,Ft(e),r);for(let o=0;o<s.length;o++)Pt(s[o])}}/**
1495
1495
  * @license
1496
1496
  * Copyright 2017 Google LLC
1497
1497
  *
@@ -1551,7 +1551,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1551
1551
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1552
1552
  * See the License for the specific language governing permissions and
1553
1553
  * limitations under the License.
1554
- */class gr{constructor(e,t,s,r){this._repo=e,this._path=t,this._queryParams=s,this._orderByCalled=r}get key(){return S(this._path)?null:Ra(this._path)}get ref(){return new ge(this._repo,this._path)}get _queryIdentifier(){const e=di(this._queryParams),t=$s(e);return t==="{}"?"default":t}get _queryObject(){return di(this._queryParams)}isEqual(e){if(e=An(e),!(e instanceof gr))return!1;const t=this._repo===e._repo,s=Gs(this._path,e._path),r=this._queryIdentifier===e._queryIdentifier;return t&&s&&r}toJSON(){return this.toString()}toString(){return this._repo.toString()+gf(this._path)}}class ge extends gr{constructor(e,t){super(e,t,new Xs,!1)}get parent(){const e=Na(this._path);return e===null?null:new ge(this._repo,e)}get root(){let e=this;for(;e.parent!==null;)e=e.parent;return e}}class It{constructor(e,t,s){this._node=e,this.ref=t,this._index=s}get priority(){return this._node.getPriority().val()}get key(){return this.ref.key}get size(){return this._node.numChildren()}child(e){const t=new D(e),s=En(this.ref,e);return new It(this._node.getChild(t),s,U)}exists(){return!this._node.isEmpty()}exportVal(){return this._node.val(!0)}forEach(e){return this._node.isLeafNode()?!1:!!this._node.forEachChild(this._index,(s,r)=>e(new It(r,En(this.ref,s),U)))}hasChild(e){const t=new D(e);return!this._node.getChild(t).isEmpty()}hasChildren(){return this._node.isLeafNode()?!1:!this._node.isEmpty()}toJSON(){return this.exportVal()}val(){return this._node.val()}}function ut(n,e){return n=An(n),n._checkNotDeleted("ref"),e!==void 0?En(n._root,e):n._root}function En(n,e){return n=An(n),C(n._path)===null?s_("child","path",e):oc("child","path",e),new ge(n._repo,W(n._path,e))}class yr{constructor(e){this.callbackContext=e}respondsTo(e){return e==="value"}createEvent(e,t){const s=t._queryParams.getIndex();return new mc("value",this,new It(e.snapshotNode,new ge(t._repo,t._path),s))}getEventRunner(e){return e.getEventType()==="cancel"?()=>this.callbackContext.onCancel(e.error):()=>this.callbackContext.onValue(e.snapshot,null)}createCancelEvent(e,t){return this.callbackContext.hasCancelCallback?new gc(this,e,t):null}matches(e){return e instanceof yr?!e.callbackContext||!this.callbackContext?!0:e.callbackContext.matches(this.callbackContext):!1}hasAnyCallback(){return this.callbackContext!==null}}class Er{constructor(e,t){this.eventType=e,this.callbackContext=t}respondsTo(e){let t=e==="children_added"?"child_added":e;return t=t==="children_removed"?"child_removed":t,this.eventType===t}createCancelEvent(e,t){return this.callbackContext.hasCancelCallback?new gc(this,e,t):null}createEvent(e,t){m(e.childName!=null,"Child events should have a childName.");const s=En(new ge(t._repo,t._path),e.childName),r=t._queryParams.getIndex();return new mc(e.type,this,new It(e.snapshotNode,s,r),e.prevName)}getEventRunner(e){return e.getEventType()==="cancel"?()=>this.callbackContext.onCancel(e.error):()=>this.callbackContext.onValue(e.snapshot,e.prevName)}matches(e){return e instanceof Er?this.eventType===e.eventType&&(!this.callbackContext||!e.callbackContext||this.callbackContext.matches(e.callbackContext)):!1}hasAnyCallback(){return!!this.callbackContext}}function yc(n,e,t,s,r){const i=new S_(t,void 0),o=e==="value"?new yr(i):new Er(e,i);return __(n._repo,n,o),()=>m_(n._repo,n,o)}function Jt(n,e,t,s){return yc(n,"value",e)}function T_(n,e,t,s){return yc(n,"child_added",e)}Ip(ge);Pp(ge);/**
1554
+ */class gr{constructor(e,t,s,r){this._repo=e,this._path=t,this._queryParams=s,this._orderByCalled=r}get key(){return S(this._path)?null:Ra(this._path)}get ref(){return new ge(this._repo,this._path)}get _queryIdentifier(){const e=di(this._queryParams),t=$s(e);return t==="{}"?"default":t}get _queryObject(){return di(this._queryParams)}isEqual(e){if(e=kn(e),!(e instanceof gr))return!1;const t=this._repo===e._repo,s=Gs(this._path,e._path),r=this._queryIdentifier===e._queryIdentifier;return t&&s&&r}toJSON(){return this.toString()}toString(){return this._repo.toString()+gf(this._path)}}class ge extends gr{constructor(e,t){super(e,t,new Xs,!1)}get parent(){const e=Na(this._path);return e===null?null:new ge(this._repo,e)}get root(){let e=this;for(;e.parent!==null;)e=e.parent;return e}}class It{constructor(e,t,s){this._node=e,this.ref=t,this._index=s}get priority(){return this._node.getPriority().val()}get key(){return this.ref.key}get size(){return this._node.numChildren()}child(e){const t=new D(e),s=En(this.ref,e);return new It(this._node.getChild(t),s,U)}exists(){return!this._node.isEmpty()}exportVal(){return this._node.val(!0)}forEach(e){return this._node.isLeafNode()?!1:!!this._node.forEachChild(this._index,(s,r)=>e(new It(r,En(this.ref,s),U)))}hasChild(e){const t=new D(e);return!this._node.getChild(t).isEmpty()}hasChildren(){return this._node.isLeafNode()?!1:!this._node.isEmpty()}toJSON(){return this.exportVal()}val(){return this._node.val()}}function ut(n,e){return n=kn(n),n._checkNotDeleted("ref"),e!==void 0?En(n._root,e):n._root}function En(n,e){return n=kn(n),C(n._path)===null?s_("child","path",e):oc("child","path",e),new ge(n._repo,W(n._path,e))}class yr{constructor(e){this.callbackContext=e}respondsTo(e){return e==="value"}createEvent(e,t){const s=t._queryParams.getIndex();return new mc("value",this,new It(e.snapshotNode,new ge(t._repo,t._path),s))}getEventRunner(e){return e.getEventType()==="cancel"?()=>this.callbackContext.onCancel(e.error):()=>this.callbackContext.onValue(e.snapshot,null)}createCancelEvent(e,t){return this.callbackContext.hasCancelCallback?new gc(this,e,t):null}matches(e){return e instanceof yr?!e.callbackContext||!this.callbackContext?!0:e.callbackContext.matches(this.callbackContext):!1}hasAnyCallback(){return this.callbackContext!==null}}class Er{constructor(e,t){this.eventType=e,this.callbackContext=t}respondsTo(e){let t=e==="children_added"?"child_added":e;return t=t==="children_removed"?"child_removed":t,this.eventType===t}createCancelEvent(e,t){return this.callbackContext.hasCancelCallback?new gc(this,e,t):null}createEvent(e,t){m(e.childName!=null,"Child events should have a childName.");const s=En(new ge(t._repo,t._path),e.childName),r=t._queryParams.getIndex();return new mc(e.type,this,new It(e.snapshotNode,s,r),e.prevName)}getEventRunner(e){return e.getEventType()==="cancel"?()=>this.callbackContext.onCancel(e.error):()=>this.callbackContext.onValue(e.snapshot,e.prevName)}matches(e){return e instanceof Er?this.eventType===e.eventType&&(!this.callbackContext||!e.callbackContext||this.callbackContext.matches(e.callbackContext)):!1}hasAnyCallback(){return!!this.callbackContext}}function yc(n,e,t,s,r){const i=new S_(t,void 0),o=e==="value"?new yr(i):new Er(e,i);return __(n._repo,n,o),()=>m_(n._repo,n,o)}function Jt(n,e,t,s){return yc(n,"value",e)}function T_(n,e,t,s){return yc(n,"child_added",e)}Ip(ge);Pp(ge);/**
1555
1555
  * @license
1556
1556
  * Copyright 2020 Google LLC
1557
1557
  *
@@ -1566,7 +1566,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1566
1566
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1567
1567
  * See the License for the specific language governing permissions and
1568
1568
  * limitations under the License.
1569
- */const R_="FIREBASE_DATABASE_EMULATOR_HOST",Os={};let I_=!1;function N_(n,e,t,s){n.repoInfo_=new ga(e,!1,n.repoInfo_.namespace,n.repoInfo_.webSocketOnly,n.repoInfo_.nodeAdmin,n.repoInfo_.persistenceKey,n.repoInfo_.includeNamespaceInQueryParams,!0,t),s&&(n.authTokenProvider_=s)}function k_(n,e,t,s,r){let i=s||n.options.databaseURL;i===void 0&&(n.options.projectId||_e("Can't determine Firebase Database URL. Be sure to include a Project ID when calling firebase.initializeApp()."),z("Using default host for project ",n.options.projectId),i=`${n.options.projectId}-default-rtdb.firebaseio.com`);let o=Ni(i,r),a=o.repoInfo,c;typeof process<"u"&&process.env&&(c=process.env[R_]),c?(i=`http://${c}?ns=${a.namespace}`,o=Ni(i,r),a=o.repoInfo):o.repoInfo.secure;const l=new $d(n.name,n.options,e);r_("Invalid Firebase Database URL",o),S(o.path)||_e("Database URL must point to the root of a Firebase Database (not including a child path).");const h=O_(a,n,l,new Vd(n,t));return new x_(h,n)}function A_(n,e){const t=Os[e];(!t||t[n.key]!==n)&&_e(`Database ${e}(${n.repoInfo_}) has already been deleted.`),g_(n),delete t[n.key]}function O_(n,e,t,s){let r=Os[e.name];r||(r={},Os[e.name]=r);let i=r[n.toURLString()];return i&&_e("Database initialized multiple times. Please make sure the format of the database URL matches with each database() call."),i=new l_(n,I_,t,s),r[n.toURLString()]=i,i}class x_{constructor(e,t){this._repoInternal=e,this.app=t,this.type="database",this._instanceStarted=!1}get _repo(){return this._instanceStarted||(h_(this._repoInternal,this.app.options.appId,this.app.options.databaseAuthVariableOverride),this._instanceStarted=!0),this._repoInternal}get _root(){return this._rootInternal||(this._rootInternal=new ge(this._repo,N())),this._rootInternal}_delete(){return this._rootInternal!==null&&(A_(this._repo,this.app.name),this._repoInternal=null,this._rootInternal=null),Promise.resolve()}_checkNotDeleted(e){this._rootInternal===null&&_e("Cannot call "+e+" on a deleted database.")}}function Xt(n=md(),e){const t=ud(n,"database").getImmediate({identifier:e});if(!t._instanceStarted){const s=eu("database");s&&P_(t,...s)}return t}function P_(n,e,t,s={}){n=An(n),n._checkNotDeleted("useEmulator");const r=`${e}:${t}`,i=n._repoInternal;if(n._instanceStarted){if(r===n._repoInternal.repoInfo_.host&&sn(s,i.repoInfo_.emulatorOptions))return;_e("connectDatabaseEmulator() cannot initialize or alter the emulator configuration after the database instance has started.")}let o;if(i.repoInfo_.nodeAdmin)s.mockUserToken&&_e('mockUserToken is not supported by the Admin SDK. For client access with mock users, please use the "firebase" package instead of "firebase-admin".'),o=new Qt(Qt.OWNER);else if(s.mockUserToken){const a=typeof s.mockUserToken=="string"?s.mockUserToken:tu(s.mockUserToken,n.app.options.projectId);o=new Qt(a)}N_(i,r,s,o)}/**
1569
+ */const R_="FIREBASE_DATABASE_EMULATOR_HOST",Os={};let I_=!1;function N_(n,e,t,s){n.repoInfo_=new ga(e,!1,n.repoInfo_.namespace,n.repoInfo_.webSocketOnly,n.repoInfo_.nodeAdmin,n.repoInfo_.persistenceKey,n.repoInfo_.includeNamespaceInQueryParams,!0,t),s&&(n.authTokenProvider_=s)}function A_(n,e,t,s,r){let i=s||n.options.databaseURL;i===void 0&&(n.options.projectId||_e("Can't determine Firebase Database URL. Be sure to include a Project ID when calling firebase.initializeApp()."),z("Using default host for project ",n.options.projectId),i=`${n.options.projectId}-default-rtdb.firebaseio.com`);let o=Ni(i,r),a=o.repoInfo,c;typeof process<"u"&&process.env&&(c=process.env[R_]),c?(i=`http://${c}?ns=${a.namespace}`,o=Ni(i,r),a=o.repoInfo):o.repoInfo.secure;const l=new $d(n.name,n.options,e);r_("Invalid Firebase Database URL",o),S(o.path)||_e("Database URL must point to the root of a Firebase Database (not including a child path).");const h=O_(a,n,l,new Vd(n,t));return new x_(h,n)}function k_(n,e){const t=Os[e];(!t||t[n.key]!==n)&&_e(`Database ${e}(${n.repoInfo_}) has already been deleted.`),g_(n),delete t[n.key]}function O_(n,e,t,s){let r=Os[e.name];r||(r={},Os[e.name]=r);let i=r[n.toURLString()];return i&&_e("Database initialized multiple times. Please make sure the format of the database URL matches with each database() call."),i=new l_(n,I_,t,s),r[n.toURLString()]=i,i}class x_{constructor(e,t){this._repoInternal=e,this.app=t,this.type="database",this._instanceStarted=!1}get _repo(){return this._instanceStarted||(h_(this._repoInternal,this.app.options.appId,this.app.options.databaseAuthVariableOverride),this._instanceStarted=!0),this._repoInternal}get _root(){return this._rootInternal||(this._rootInternal=new ge(this._repo,N())),this._rootInternal}_delete(){return this._rootInternal!==null&&(k_(this._repo,this.app.name),this._repoInternal=null,this._rootInternal=null),Promise.resolve()}_checkNotDeleted(e){this._rootInternal===null&&_e("Cannot call "+e+" on a deleted database.")}}function Xt(n=md(),e){const t=ud(n,"database").getImmediate({identifier:e});if(!t._instanceStarted){const s=eu("database");s&&P_(t,...s)}return t}function P_(n,e,t,s={}){n=kn(n),n._checkNotDeleted("useEmulator");const r=`${e}:${t}`,i=n._repoInternal;if(n._instanceStarted){if(r===n._repoInternal.repoInfo_.host&&sn(s,i.repoInfo_.emulatorOptions))return;_e("connectDatabaseEmulator() cannot initialize or alter the emulator configuration after the database instance has started.")}let o;if(i.repoInfo_.nodeAdmin)s.mockUserToken&&_e('mockUserToken is not supported by the Admin SDK. For client access with mock users, please use the "firebase" package instead of "firebase-admin".'),o=new Qt(Qt.OWNER);else if(s.mockUserToken){const a=typeof s.mockUserToken=="string"?s.mockUserToken:tu(s.mockUserToken,n.app.options.projectId);o=new Qt(a)}N_(i,r,s,o)}/**
1570
1570
  * @license
1571
1571
  * Copyright 2021 Google LLC
1572
1572
  *
@@ -1581,7 +1581,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1581
1581
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1582
1582
  * See the License for the specific language governing permissions and
1583
1583
  * limitations under the License.
1584
- */function D_(n){Id(_d),on(new Et("database",(e,{instanceIdentifier:t})=>{const s=e.getProvider("app").getImmediate(),r=e.getProvider("auth-internal"),i=e.getProvider("app-check-internal");return k_(s,r,i,t)},"PUBLIC").setMultipleInstances(!0)),$e(Yr,Qr,n),$e(Yr,Qr,"esm2017")}fe.prototype.simpleListen=function(n,e){this.sendRequest("q",{p:n},e)};fe.prototype.echo=function(n,e){this.sendRequest("echo",{d:n},e)};D_();const Bn=n=>n==="server"?"https://backend.nervoscan.com":"https://backendv2-dev.nervoscan.com",Ne=class Ne{constructor(){x(this,"socket");x(this,"backendUrl",Bn("server"));x(this,"videoStream");x(this,"videoElement");x(this,"isConnected",!1);x(this,"isStreaming",!1);x(this,"jobId");x(this,"onDisconnection");x(this,"playHandler",()=>{if(!this.videoElement)return;const e=document.createElement("canvas");e.width=this.videoElement.videoWidth,e.height=this.videoElement.videoHeight,this.captureAndSendFrame(e,this.videoElement)});x(this,"stopStreaming",()=>{this.isStreaming=!1,this.removePlayEventListener()})}static getInstance(){return Ne.instance||(Ne.instance=new Ne),Ne.instance}async setupWebSocketConnection(){return new Promise((e,t)=>{if(this.socket)return console.warn("Socket already connected, skipping connection"),e(!0);this.socket=Yt(this.backendUrl,{transports:["websocket","polling"]}),this.socket.once("connect",()=>{this.isConnected=!0,e(!0)}),this.socket.once("connect_error",s=>{t(v.ConnectionLostError)}),this.socket.once("disconnect",s=>{this.handleSocketDisconnection(s)})})}handleSocketDisconnection(e){this.isConnected=!1,console.warn("Disconnected from WebSocket server:",e)}async initializeStreaming(e,t){await this.setupWebSocketConnection(),this.videoStream=e,this.videoElement=t,this.videoElement.srcObject=e}startStreaming(e){var t;this.jobId=e,(t=this.socket)==null||t.emit("register",e),this.sendInitialRequest(e),this.isStreaming=!0,this.startVideoStream(),this.addDisconnectionListener()}async sendInitialRequest(e){await k.post(`${this.backendUrl}/react`,{username:e,uuid:e,device_id:"1234567",face_detector:"BlazefaceFacemesh",motion_tracking:!0,skin_segmentor:"HSVandYCrCbSkinSegmentation",extreme_pixel_removal:!1,gamma_value:1,eularian_color_magnification:!1},{headers:{"Content-Type":"application/json"}})}startVideoStream(){this.videoElement?(this.videoElement.addEventListener("play",this.playHandler),!this.videoElement.paused&&!this.videoElement.ended&&this.playHandler(),this.videoElement.play().then(()=>{}).catch(e=>console.error("Error starting video stream:",e))):console.error("Video stream not found when trying to start streaming")}captureAndSendFrame(e,t){const s=e.getContext("2d");if(!s)return;const r=()=>{this.isStreaming&&(!t.paused&&!t.ended&&(s.drawImage(t,0,0,640,480),this.sendFrameToBackend(e)),setTimeout(r,33))};r()}sendFrameToBackend(e){e.toBlob(t=>{if(!t)return;const s=new FileReader;s.onloadend=()=>{var r;if(this.isConnected&&this.isStreaming){const i=s.result;(r=this.socket)==null||r.emit("frame",i)}},s.readAsArrayBuffer(t)},"image/jpeg",.7)}removePlayEventListener(){this.videoElement&&this.videoElement.removeEventListener("play",this.playHandler)}setOnDisconnection(e){this.onDisconnection=e}addDisconnectionListener(){const e=Xt(),t=ut(e,`${this.jobId}/disconnect`),s=Jt(t,r=>{r.val()!=null&&(this.stopStreaming(),this.onDisconnection&&this.onDisconnection(),s())})}};x(Ne,"instance");let wn=Ne;class Ec{constructor(e,t){x(this,"backendUrl",Bn("server"));x(this,"username");x(this,"password");x(this,"streamingManager",wn.getInstance());this.username=e,this.password=t}}class L_ extends Ec{constructor(t,s){super(t,s);x(this,"streamingManager",wn.getInstance());this.backendUrl=Bn("server")}async getToken(){try{return(await k.post(this.backendUrl.concat("/clientlogin"),{username:this.username,password:this.password})).data.access_token}catch(t){R.handleErrorResponse(t)}}async getAPIKey(t){t||R.throwKnownError(v.InvalidAccessTokenError);try{return(await k.post(this.backendUrl.concat("/clientgeturl"),{host_name:"www.nervoscan.com"},{headers:{Authorization:`Bearer ${t}`}})).data.url.split("?api_key=")[1]}catch(s){R.handleErrorResponse(s)}}async uploadVideoToServer(t,s,r){(!s||!r)&&R.throwKnownError(v.InvalidAccessTokenError);const i=new FormData;i.append("file",t,"recording.webm"),i.append("data",JSON.stringify({uuid:r,meta_data:{}}));const a=await(await fetch(this.backendUrl.concat("/submitscan"),{method:"POST",headers:{Authorization:`Bearer ${s}`},body:i})).json();return a.success===!1&&R.handleErrorResponse(a),a}async getResults(t,s){var r;s||R.throwKnownError(v.InvalidAccessTokenError);try{const i=await k.post(this.backendUrl.concat("/getcustomerinfo"),{mode:"selection",api_keys:[t]},{headers:{Authorization:`Bearer ${s}`}});return((r=i.data)==null?void 0:r.success)===!1&&R.throwKnownError(v.NoScanDataError),i.data}catch(i){console.error("Error getting results:",i),R.handleErrorResponse(i)}}async checkResults(t,s){try{s||R.throwKnownError(v.InvalidAccessTokenError);const o=(await k.post(this.backendUrl.concat("/check"),{api_key:t},{headers:{Authorization:`Bearer ${s}`}})).data.job_status;return o==="Completed"||o==="Failed"?o:"Pending"}catch(r){R.handleErrorResponse(r)}}}class F_ extends Ec{constructor(e,t){super(e,t),this.backendUrl=Bn("serverless")}async getToken(){try{const e=await k.post(this.backendUrl.concat("/user/login"),{username:this.username,password:this.password});if(e.data.success===!1)R.throwKnownError(v.InvalidUsernameError);else return JSON.parse(e.data.body).idToken}catch(e){console.error("error printed in serverless repository",e),R.handleErrorResponse(e)}}async getAPIKey(e){e||R.throwKnownError(v.InvalidAccessTokenError);try{return(await k.post(this.backendUrl.concat("/get-redirection-url"),{host_name:"www.nervoscan.com",username:this.username},{headers:{Authorization:`Bearer ${e}`}})).data.url.split("?api_key=")[1]}catch(t){R.handleErrorResponse(t)}}async uploadVideoToServer(e,t,s){(!t||!s)&&R.throwKnownError(v.InvalidAccessTokenError);try{const r=await this.generatePreSignedUrl(s);return r||R.throwKnownError(v.InvalidAccessTokenError),await this.uploadVideoToS3(e,r)}catch(r){throw console.error("Error uploading video:",r),r.response?(console.error("Error response:",r.response.data),console.error("Error status:",r.response.status),console.error("Error headers:",r.response.headers)):r.request?console.error("Error request:",r.request):console.error("Error message:",r.message),r}}getResults(e,t){return console.log("not implemented"),Promise.resolve(void 0)}async checkResults(e,t){try{t||R.throwKnownError(v.InvalidAccessTokenError);const i=(await k.post(this.backendUrl.concat("/check"),{api_key:e},{headers:{Authorization:`Bearer ${t}`}})).data.job_status;return i==="Completed"||i==="Failed"?i:"Pending"}catch(s){R.handleErrorResponse(s)}}async generatePreSignedUrl(e){try{return(await k.get(this.backendUrl.concat("/generate-presigned-url?job_id="+e))).data.upload_url}catch(t){R.handleErrorResponse(t)}}async uploadVideoToS3(e,t){try{return(await k.put(t,e,{headers:{"Content-Type":"video/mp4"}})).data}catch(s){R.handleErrorResponse(s)}}}var M_="firebase",B_="11.6.1";/**
1584
+ */function D_(n){Id(_d),on(new Et("database",(e,{instanceIdentifier:t})=>{const s=e.getProvider("app").getImmediate(),r=e.getProvider("auth-internal"),i=e.getProvider("app-check-internal");return A_(s,r,i,t)},"PUBLIC").setMultipleInstances(!0)),$e(Yr,Qr,n),$e(Yr,Qr,"esm2017")}fe.prototype.simpleListen=function(n,e){this.sendRequest("q",{p:n},e)};fe.prototype.echo=function(n,e){this.sendRequest("echo",{d:n},e)};D_();const Bn=n=>n==="server"?"https://backend.nervoscan.com":"https://backendv2-dev.nervoscan.com",Ne=class Ne{constructor(){x(this,"socket");x(this,"backendUrl",Bn("server"));x(this,"videoStream");x(this,"videoElement");x(this,"isConnected",!1);x(this,"isStreaming",!1);x(this,"jobId");x(this,"onDisconnection");x(this,"playHandler",()=>{if(!this.videoElement)return;const e=document.createElement("canvas");e.width=this.videoElement.videoWidth,e.height=this.videoElement.videoHeight,this.captureAndSendFrame(e,this.videoElement)});x(this,"stopStreaming",()=>{this.isStreaming=!1,this.removePlayEventListener()})}static getInstance(){return Ne.instance||(Ne.instance=new Ne),Ne.instance}async setupWebSocketConnection(){return new Promise((e,t)=>{if(this.socket)return console.warn("Socket already connected, skipping connection"),e(!0);this.socket=Yt(this.backendUrl,{transports:["websocket","polling"]}),this.socket.once("connect",()=>{this.isConnected=!0,e(!0)}),this.socket.once("connect_error",s=>{t(v.ConnectionLostError)}),this.socket.once("disconnect",s=>{this.handleSocketDisconnection(s)})})}handleSocketDisconnection(e){this.isConnected=!1,console.warn("Disconnected from WebSocket server:",e)}async initializeStreaming(e,t){await this.setupWebSocketConnection(),this.videoStream=e,this.videoElement=t,this.videoElement.srcObject=e}startStreaming(e){var t;this.jobId=e,(t=this.socket)==null||t.emit("register",e),this.sendInitialRequest(e),this.isStreaming=!0,this.startVideoStream(),this.addDisconnectionListener()}async sendInitialRequest(e){await A.post(`${this.backendUrl}/react`,{username:e,uuid:e,device_id:"1234567",face_detector:"BlazefaceFacemesh",motion_tracking:!0,skin_segmentor:"HSVandYCrCbSkinSegmentation",extreme_pixel_removal:!1,gamma_value:1,eularian_color_magnification:!1},{headers:{"Content-Type":"application/json"}})}startVideoStream(){this.videoElement?(this.videoElement.addEventListener("play",this.playHandler),!this.videoElement.paused&&!this.videoElement.ended&&this.playHandler(),this.videoElement.play().then(()=>{}).catch(e=>console.error("Error starting video stream:",e))):console.error("Video stream not found when trying to start streaming")}captureAndSendFrame(e,t){let s=!1;const r=e.getContext("2d");if(!r)return;const i=()=>{if(this.isStreaming){if(s){setTimeout(i,33);return}!t.paused&&!t.ended&&(r.drawImage(t,0,0,640,480),s=!0,e.toBlob(o=>{if(!o)return;const a=new FileReader;a.onloadend=()=>{var c;if(this.isConnected&&this.isStreaming){const l=a.result;(c=this.socket)==null||c.emit("frame",l),s=!1,setTimeout(i,33)}},a.readAsArrayBuffer(o)},"image/jpeg",.7))}};i()}removePlayEventListener(){this.videoElement&&this.videoElement.removeEventListener("play",this.playHandler)}setOnDisconnection(e){this.onDisconnection=e}addDisconnectionListener(){const e=Xt(),t=ut(e,`${this.jobId}/disconnect`),s=Jt(t,r=>{r.val()!=null&&(this.stopStreaming(),this.onDisconnection&&this.onDisconnection(),s())})}};x(Ne,"instance");let wn=Ne;class Ec{constructor(e,t){x(this,"backendUrl",Bn("server"));x(this,"username");x(this,"password");x(this,"streamingManager",wn.getInstance());this.username=e,this.password=t}}class L_ extends Ec{constructor(t,s){super(t,s);x(this,"streamingManager",wn.getInstance());this.backendUrl=Bn("server")}async getToken(){try{return(await A.post(this.backendUrl.concat("/clientlogin"),{username:this.username,password:this.password})).data.access_token}catch(t){R.handleErrorResponse(t)}}async getAPIKey(t){t||R.throwKnownError(v.InvalidAccessTokenError);try{return(await A.post(this.backendUrl.concat("/clientgeturl"),{host_name:"www.nervoscan.com"},{headers:{Authorization:`Bearer ${t}`}})).data.url.split("?api_key=")[1]}catch(s){R.handleErrorResponse(s)}}async uploadVideoToServer(t,s,r){(!s||!r)&&R.throwKnownError(v.InvalidAccessTokenError);const i=new FormData;i.append("file",t,"recording.webm"),i.append("data",JSON.stringify({uuid:r,meta_data:{}}));const a=await(await fetch(this.backendUrl.concat("/submitscan"),{method:"POST",headers:{Authorization:`Bearer ${s}`},body:i})).json();return a.success===!1&&R.handleErrorResponse(a),a}async getResults(t,s){var r;s||R.throwKnownError(v.InvalidAccessTokenError);try{const i=await A.post(this.backendUrl.concat("/getcustomerinfo"),{mode:"selection",api_keys:[t]},{headers:{Authorization:`Bearer ${s}`}});return((r=i.data)==null?void 0:r.success)===!1&&R.throwKnownError(v.NoScanDataError),i.data}catch(i){console.error("Error getting results:",i),R.handleErrorResponse(i)}}async checkResults(t,s){try{s||R.throwKnownError(v.InvalidAccessTokenError);const o=(await A.post(this.backendUrl.concat("/check"),{api_key:t},{headers:{Authorization:`Bearer ${s}`}})).data.job_status;return o==="Completed"||o==="Failed"?o:"Pending"}catch(r){R.handleErrorResponse(r)}}}class F_ extends Ec{constructor(e,t){super(e,t),this.backendUrl=Bn("serverless")}async getToken(){try{const e=await A.post(this.backendUrl.concat("/user/login"),{username:this.username,password:this.password});if(e.data.success===!1)R.throwKnownError(v.InvalidUsernameError);else return JSON.parse(e.data.body).idToken}catch(e){console.error("error printed in serverless repository",e),R.handleErrorResponse(e)}}async getAPIKey(e){e||R.throwKnownError(v.InvalidAccessTokenError);try{return(await A.post(this.backendUrl.concat("/get-redirection-url"),{host_name:"www.nervoscan.com",username:this.username},{headers:{Authorization:`Bearer ${e}`}})).data.url.split("?api_key=")[1]}catch(t){R.handleErrorResponse(t)}}async uploadVideoToServer(e,t,s){(!t||!s)&&R.throwKnownError(v.InvalidAccessTokenError);try{const r=await this.generatePreSignedUrl(s);return r||R.throwKnownError(v.InvalidAccessTokenError),await this.uploadVideoToS3(e,r)}catch(r){throw console.error("Error uploading video:",r),r.response?(console.error("Error response:",r.response.data),console.error("Error status:",r.response.status),console.error("Error headers:",r.response.headers)):r.request?console.error("Error request:",r.request):console.error("Error message:",r.message),r}}getResults(e,t){return console.log("not implemented"),Promise.resolve(void 0)}async checkResults(e,t){try{t||R.throwKnownError(v.InvalidAccessTokenError);const i=(await A.post(this.backendUrl.concat("/check"),{api_key:e},{headers:{Authorization:`Bearer ${t}`}})).data.job_status;return i==="Completed"||i==="Failed"?i:"Pending"}catch(s){R.handleErrorResponse(s)}}async generatePreSignedUrl(e){try{return(await A.get(this.backendUrl.concat("/generate-presigned-url?job_id="+e))).data.upload_url}catch(t){R.handleErrorResponse(t)}}async uploadVideoToS3(e,t){try{return(await A.put(t,e,{headers:{"Content-Type":"video/mp4"}})).data}catch(s){R.handleErrorResponse(s)}}}var M_="firebase",B_="11.6.1";/**
1585
1585
  * @license
1586
1586
  * Copyright 2020 Google LLC
1587
1587
  *
@@ -1596,4 +1596,4 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1596
1596
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1597
1597
  * See the License for the specific language governing permissions and
1598
1598
  * limitations under the License.
1599
- */$e(M_,B_,"app");const ke=class ke{constructor(){x(this,"initialized",!1);x(this,"accessToken");x(this,"backendRepository");x(this,"onWindowResults");x(this,"onFinalResults");x(this,"onError");x(this,"firebaseHandlers",[]);Zo({apiKey:"AIzaSyAoOpQqLrc6wQLJI5KRE2Vt7QV1cplsZv8",authDomain:"nervowebreact.firebaseapp.com",databaseURL:"https://nervowebreact-default-rtdb.asia-southeast1.firebasedatabase.app",projectId:"nervowebreact",storageBucket:"nervowebreact.firebasestorage.app",messagingSenderId:"1025695568936",appId:"1:1025695568936:web:36f269a1eb74e1fdda511d",measurementId:"G-L3105FG92S"})}static getInstance(){return ke.instance||(ke.instance=new ke),ke.instance}initialize(e,t,s="server"){this.initialized=!0,s==="server"?this.backendRepository=new L_(e,t):s==="serverless"?this.backendRepository=new F_(e,t):R.throwKnownError(v.InvalidServerTypeError)}async uploadVideo(e){var r,i,o;this.initialized||R.throwKnownError(v.NotInitializedError),e instanceof Blob||R.throwKnownError(v.VideoTypeError),(e===null||e.size===0)&&R.throwKnownError(v.EmptyVideoError);const t=await((r=this.backendRepository)==null?void 0:r.getToken()),s=await((i=this.backendRepository)==null?void 0:i.getAPIKey(t));return(o=this.backendRepository)==null||o.uploadVideoToServer(e,t,s),s&&this.addfirebaseListeners(s),s}async checkResults(e){var t,s;console.warn("Warning: checkResults() is deprecated and will be removed in a future version. Use setOnWindowResults() and setOnFinalResults() instead!"),this.initialized||R.throwKnownError(v.NotInitializedError);try{return this.accessToken||(this.accessToken=await((t=this.backendRepository)==null?void 0:t.getToken())),await((s=this.backendRepository)==null?void 0:s.checkResults(e,this.accessToken))}catch(r){R.handleErrorResponse(r)}}async getResults(e){var s,r;return console.warn("Warning: getResults() is deprecated and will be removed in a future version. Use setOnWindowResults() and setOnFinalResults() instead!"),this.initialized||R.throwKnownError(v.NotInitializedError),this.accessToken||(this.accessToken=await((s=this.backendRepository)==null?void 0:s.getToken())),await((r=this.backendRepository)==null?void 0:r.getResults(e,this.accessToken))}setOnWindowResults(e){this.onWindowResults=e}setOnFinalResults(e){this.onFinalResults=e}setOnError(e){this.onError=e}setOnDisconnection(e){var t;(t=this.backendRepository)==null||t.streamingManager.setOnDisconnection(e)}async initializeStreaming(e,t){var s;await((s=this.backendRepository)==null?void 0:s.streamingManager.initializeStreaming(e,t))}async startStreaming(){var s,r,i;this.initialized||R.throwKnownError(v.NotInitializedError);const e=await((s=this.backendRepository)==null?void 0:s.getToken()),t=await((r=this.backendRepository)==null?void 0:r.getAPIKey(e));if(t)return(i=this.backendRepository)==null||i.streamingManager.startStreaming(t),this.addfirebaseListeners(t),t;R.throwKnownError(v.InvalidAccessTokenError)}stopStreaming(){var e;(e=this.backendRepository)==null||e.streamingManager.stopStreaming()}async addfirebaseListeners(e){this.addWindowListener(e),this.addFinalListener(e),this.addErrorListener(e)}addWindowListener(e){const t=Xt(),s=ut(t,`${e}`),r=T_(s,i=>{i.val()!==null&&i.key&&/^\d+$/.test(i.key)&&this.onWindowResults&&this.onWindowResults(i.val())});this.firebaseHandlers.push(r)}removefirebaseListeners(){this.firebaseHandlers.forEach(e=>{e()}),this.firebaseHandlers=[]}addFinalListener(e){const t=Xt(),s=ut(t,`/${e}/averaged_results/`),r=Jt(s,i=>{i.val()!==null&&(this.onFinalResults&&this.onFinalResults(i.val()),this.removefirebaseListeners())});this.firebaseHandlers.push(r)}addErrorListener(e){const t=Xt(),s=ut(t,`/${e}/error/`),r=Jt(s,a=>{if(a.val()===null)return;const c=R.handleScanError(a.val());this.onError?this.onError(c):R.throwKnownError(v.ErrorCallbackNotSetError),this.removefirebaseListeners()}),i=ut(t,`/${e}/job_completed/`),o=Jt(i,a=>{a.val()!==null&&(a.val()==="failed"&&this.onError?(this.onError(v.ScanFailedError),this.removefirebaseListeners()):a.val()==="success"&&this.removefirebaseListeners())});this.firebaseHandlers.push(r),this.firebaseHandlers.push(o)}};x(ke,"instance");let xs=ke;exports.Client=xs;exports.ConnectionLostError=Zi;exports.EmptyVideoError=Ai;exports.ErrorCallbackNotSetError=ji;exports.Errors=P;exports.FPSCalculationError=Hi;exports.FaceLookingLeftError=$i;exports.FaceLookingRightError=zi;exports.FaceNotCenteredError=Wi;exports.FaceTooCloseError=Vi;exports.FaceTooFarError=qi;exports.InvalidAccessTokenError=Li;exports.InvalidContentTypeError=Yi;exports.InvalidPasswordError=Pi;exports.InvalidServerTypeError=Mi;exports.InvalidUsernameError=xi;exports.JobNotRegisteredError=Qi;exports.LowFPSError=Ui;exports.LowFrameCountError=Xi;exports.NervoscanError=A;exports.NoScanDataError=Fi;exports.NoScansAvailableError=Di;exports.NotImplementedError=Bi;exports.NotInitializedError=ki;exports.ScanFailedError=eo;exports.SkinExtractionError=Gi;exports.UnhandledError=Ji;exports.UnhandledScanError=Ki;exports.VideoError=to;exports.VideoTypeError=Oi;
1599
+ */$e(M_,B_,"app");const Ae=class Ae{constructor(){x(this,"initialized",!1);x(this,"accessToken");x(this,"backendRepository");x(this,"onWindowResults");x(this,"onFinalResults");x(this,"onError");x(this,"firebaseHandlers",[]);Zo({apiKey:"AIzaSyAoOpQqLrc6wQLJI5KRE2Vt7QV1cplsZv8",authDomain:"nervowebreact.firebaseapp.com",databaseURL:"https://nervowebreact-default-rtdb.asia-southeast1.firebasedatabase.app",projectId:"nervowebreact",storageBucket:"nervowebreact.firebasestorage.app",messagingSenderId:"1025695568936",appId:"1:1025695568936:web:36f269a1eb74e1fdda511d",measurementId:"G-L3105FG92S"})}static getInstance(){return Ae.instance||(Ae.instance=new Ae),Ae.instance}initialize(e,t,s="server"){this.initialized=!0,s==="server"?this.backendRepository=new L_(e,t):s==="serverless"?this.backendRepository=new F_(e,t):R.throwKnownError(v.InvalidServerTypeError)}async uploadVideo(e){var r,i,o;this.initialized||R.throwKnownError(v.NotInitializedError),e instanceof Blob||R.throwKnownError(v.VideoTypeError),(e===null||e.size===0)&&R.throwKnownError(v.EmptyVideoError);const t=await((r=this.backendRepository)==null?void 0:r.getToken()),s=await((i=this.backendRepository)==null?void 0:i.getAPIKey(t));return(o=this.backendRepository)==null||o.uploadVideoToServer(e,t,s),s&&this.addfirebaseListeners(s),s}async checkResults(e){var t,s;console.warn("Warning: checkResults() is deprecated and will be removed in a future version. Use setOnWindowResults() and setOnFinalResults() instead!"),this.initialized||R.throwKnownError(v.NotInitializedError);try{return this.accessToken||(this.accessToken=await((t=this.backendRepository)==null?void 0:t.getToken())),await((s=this.backendRepository)==null?void 0:s.checkResults(e,this.accessToken))}catch(r){R.handleErrorResponse(r)}}async getResults(e){var s,r;return console.warn("Warning: getResults() is deprecated and will be removed in a future version. Use setOnWindowResults() and setOnFinalResults() instead!"),this.initialized||R.throwKnownError(v.NotInitializedError),this.accessToken||(this.accessToken=await((s=this.backendRepository)==null?void 0:s.getToken())),await((r=this.backendRepository)==null?void 0:r.getResults(e,this.accessToken))}setOnWindowResults(e){this.onWindowResults=e}setOnFinalResults(e){this.onFinalResults=e}setOnError(e){this.onError=e}setOnDisconnection(e){var t;(t=this.backendRepository)==null||t.streamingManager.setOnDisconnection(e)}async initializeStreaming(e,t){var s;await((s=this.backendRepository)==null?void 0:s.streamingManager.initializeStreaming(e,t))}async startStreaming(){var s,r,i;this.initialized||R.throwKnownError(v.NotInitializedError);const e=await((s=this.backendRepository)==null?void 0:s.getToken()),t=await((r=this.backendRepository)==null?void 0:r.getAPIKey(e));if(t)return(i=this.backendRepository)==null||i.streamingManager.startStreaming(t),this.addfirebaseListeners(t),t;R.throwKnownError(v.InvalidAccessTokenError)}stopStreaming(){var e;(e=this.backendRepository)==null||e.streamingManager.stopStreaming()}async addfirebaseListeners(e){this.addWindowListener(e),this.addFinalListener(e),this.addErrorListener(e)}addWindowListener(e){const t=Xt(),s=ut(t,`${e}`),r=T_(s,i=>{i.val()!==null&&i.key&&/^\d+$/.test(i.key)&&this.onWindowResults&&this.onWindowResults(i.val())});this.firebaseHandlers.push(r)}removefirebaseListeners(){this.firebaseHandlers.forEach(e=>{e()}),this.firebaseHandlers=[]}addFinalListener(e){const t=Xt(),s=ut(t,`/${e}/averaged_results/`),r=Jt(s,i=>{i.val()!==null&&(this.onFinalResults&&this.onFinalResults(i.val()),this.removefirebaseListeners())});this.firebaseHandlers.push(r)}addErrorListener(e){const t=Xt(),s=ut(t,`/${e}/error/`),r=Jt(s,a=>{if(a.val()===null)return;const c=R.handleScanError(a.val());this.onError?this.onError(c):R.throwKnownError(v.ErrorCallbackNotSetError),this.removefirebaseListeners()}),i=ut(t,`/${e}/job_completed/`),o=Jt(i,a=>{a.val()!==null&&(a.val()==="failed"&&this.onError?(this.onError(v.ScanFailedError),this.removefirebaseListeners()):a.val()==="success"&&this.removefirebaseListeners())});this.firebaseHandlers.push(r),this.firebaseHandlers.push(o)}};x(Ae,"instance");let xs=Ae;exports.Client=xs;exports.ConnectionLostError=Zi;exports.EmptyVideoError=ki;exports.ErrorCallbackNotSetError=ji;exports.Errors=P;exports.FPSCalculationError=Hi;exports.FaceLookingLeftError=$i;exports.FaceLookingRightError=zi;exports.FaceNotCenteredError=Wi;exports.FaceTooCloseError=Vi;exports.FaceTooFarError=qi;exports.InvalidAccessTokenError=Li;exports.InvalidContentTypeError=Yi;exports.InvalidPasswordError=Pi;exports.InvalidServerTypeError=Mi;exports.InvalidUsernameError=xi;exports.JobNotRegisteredError=Qi;exports.LowFPSError=Ui;exports.LowFrameCountError=Xi;exports.NervoscanError=k;exports.NoScanDataError=Fi;exports.NoScansAvailableError=Di;exports.NotImplementedError=Bi;exports.NotInitializedError=Ai;exports.ScanFailedError=eo;exports.SkinExtractionError=Gi;exports.UnhandledError=Ji;exports.UnhandledScanError=Ki;exports.VideoError=to;exports.VideoTypeError=Oi;
@@ -12810,25 +12810,29 @@ const Bn = (n) => n === "server" ? "https://backend.nervoscan.com" : "https://ba
12810
12810
  }).catch((e) => console.error("Error starting video stream:", e))) : console.error("Video stream not found when trying to start streaming");
12811
12811
  }
12812
12812
  captureAndSendFrame(e, t) {
12813
- const s = e.getContext("2d");
12814
- if (!s) return;
12815
- const r = () => {
12816
- this.isStreaming && (!t.paused && !t.ended && (s.drawImage(t, 0, 0, 640, 480), this.sendFrameToBackend(e)), setTimeout(r, 33));
12817
- };
12818
- r();
12819
- }
12820
- sendFrameToBackend(e) {
12821
- e.toBlob((t) => {
12822
- if (!t) return;
12823
- const s = new FileReader();
12824
- s.onloadend = () => {
12825
- var r;
12826
- if (this.isConnected && this.isStreaming) {
12827
- const i = s.result;
12828
- (r = this.socket) == null || r.emit("frame", i);
12813
+ let s = !1;
12814
+ const r = e.getContext("2d");
12815
+ if (!r) return;
12816
+ const i = () => {
12817
+ if (this.isStreaming) {
12818
+ if (s) {
12819
+ setTimeout(i, 33);
12820
+ return;
12829
12821
  }
12830
- }, s.readAsArrayBuffer(t);
12831
- }, "image/jpeg", 0.7);
12822
+ !t.paused && !t.ended && (r.drawImage(t, 0, 0, 640, 480), s = !0, e.toBlob((o) => {
12823
+ if (!o) return;
12824
+ const a = new FileReader();
12825
+ a.onloadend = () => {
12826
+ var c;
12827
+ if (this.isConnected && this.isStreaming) {
12828
+ const l = a.result;
12829
+ (c = this.socket) == null || c.emit("frame", l), s = !1, setTimeout(i, 33);
12830
+ }
12831
+ }, a.readAsArrayBuffer(o);
12832
+ }, "image/jpeg", 0.7));
12833
+ }
12834
+ };
12835
+ i();
12832
12836
  }
12833
12837
  removePlayEventListener() {
12834
12838
  this.videoElement && this.videoElement.removeEventListener("play", this.playHandler);
@@ -1581,7 +1581,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1581
1581
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1582
1582
  * See the License for the specific language governing permissions and
1583
1583
  * limitations under the License.
1584
- */function I_(n){wd(cd),un(new pt("database",(e,{instanceIdentifier:t})=>{const s=e.getProvider("app").getImmediate(),r=e.getProvider("auth-internal"),i=e.getProvider("app-check-internal");return b_(s,r,i,t)},"PUBLIC").setMultipleInstances(!0)),Ge(vo,bo,n),Ge(vo,bo,"esm2017")}me.prototype.simpleListen=function(n,e){this.sendRequest("q",{p:n},e)},me.prototype.echo=function(n,e){this.sendRequest("echo",{d:n},e)},I_();const Mn=n=>n==="server"?"https://backend.nervoscan.com":"https://backendv2-dev.nervoscan.com",Ue=class Ue{constructor(){L(this,"socket");L(this,"backendUrl",Mn("server"));L(this,"videoStream");L(this,"videoElement");L(this,"isConnected",!1);L(this,"isStreaming",!1);L(this,"jobId");L(this,"onDisconnection");L(this,"playHandler",()=>{if(!this.videoElement)return;const e=document.createElement("canvas");e.width=this.videoElement.videoWidth,e.height=this.videoElement.videoHeight,this.captureAndSendFrame(e,this.videoElement)});L(this,"stopStreaming",()=>{this.isStreaming=!1,this.removePlayEventListener()})}static getInstance(){return Ue.instance||(Ue.instance=new Ue),Ue.instance}async setupWebSocketConnection(){return new Promise((e,t)=>{if(this.socket)return console.warn("Socket already connected, skipping connection"),e(!0);this.socket=sn(this.backendUrl,{transports:["websocket","polling"]}),this.socket.once("connect",()=>{this.isConnected=!0,e(!0)}),this.socket.once("connect_error",s=>{t(b.ConnectionLostError)}),this.socket.once("disconnect",s=>{this.handleSocketDisconnection(s)})})}handleSocketDisconnection(e){this.isConnected=!1,console.warn("Disconnected from WebSocket server:",e)}async initializeStreaming(e,t){await this.setupWebSocketConnection(),this.videoStream=e,this.videoElement=t,this.videoElement.srcObject=e}startStreaming(e){var t;this.jobId=e,(t=this.socket)==null||t.emit("register",e),this.sendInitialRequest(e),this.isStreaming=!0,this.startVideoStream(),this.addDisconnectionListener()}async sendInitialRequest(e){await O.post(`${this.backendUrl}/react`,{username:e,uuid:e,device_id:"1234567",face_detector:"BlazefaceFacemesh",motion_tracking:!0,skin_segmentor:"HSVandYCrCbSkinSegmentation",extreme_pixel_removal:!1,gamma_value:1,eularian_color_magnification:!1},{headers:{"Content-Type":"application/json"}})}startVideoStream(){this.videoElement?(this.videoElement.addEventListener("play",this.playHandler),!this.videoElement.paused&&!this.videoElement.ended&&this.playHandler(),this.videoElement.play().then(()=>{}).catch(e=>console.error("Error starting video stream:",e))):console.error("Video stream not found when trying to start streaming")}captureAndSendFrame(e,t){const s=e.getContext("2d");if(!s)return;const r=()=>{this.isStreaming&&(!t.paused&&!t.ended&&(s.drawImage(t,0,0,640,480),this.sendFrameToBackend(e)),setTimeout(r,33))};r()}sendFrameToBackend(e){e.toBlob(t=>{if(!t)return;const s=new FileReader;s.onloadend=()=>{var r;if(this.isConnected&&this.isStreaming){const i=s.result;(r=this.socket)==null||r.emit("frame",i)}},s.readAsArrayBuffer(t)},"image/jpeg",.7)}removePlayEventListener(){this.videoElement&&this.videoElement.removeEventListener("play",this.playHandler)}setOnDisconnection(e){this.onDisconnection=e}addDisconnectionListener(){const e=Fn(),t=Bt(e,`${this.jobId}/disconnect`),s=Ln(t,r=>{r.val()!=null&&(this.stopStreaming(),this.onDisconnection&&this.onDisconnection(),s())})}};L(Ue,"instance");let Bn=Ue;class yc{constructor(e,t){L(this,"backendUrl",Mn("server"));L(this,"username");L(this,"password");L(this,"streamingManager",Bn.getInstance());this.username=e,this.password=t}}class N_ extends yc{constructor(t,s){super(t,s);L(this,"streamingManager",Bn.getInstance());this.backendUrl=Mn("server")}async getToken(){try{return(await O.post(this.backendUrl.concat("/clientlogin"),{username:this.username,password:this.password})).data.access_token}catch(t){N.handleErrorResponse(t)}}async getAPIKey(t){t||N.throwKnownError(b.InvalidAccessTokenError);try{return(await O.post(this.backendUrl.concat("/clientgeturl"),{host_name:"www.nervoscan.com"},{headers:{Authorization:`Bearer ${t}`}})).data.url.split("?api_key=")[1]}catch(s){N.handleErrorResponse(s)}}async uploadVideoToServer(t,s,r){(!s||!r)&&N.throwKnownError(b.InvalidAccessTokenError);const i=new FormData;i.append("file",t,"recording.webm"),i.append("data",JSON.stringify({uuid:r,meta_data:{}}));const a=await(await fetch(this.backendUrl.concat("/submitscan"),{method:"POST",headers:{Authorization:`Bearer ${s}`},body:i})).json();return a.success===!1&&N.handleErrorResponse(a),a}async getResults(t,s){var r;s||N.throwKnownError(b.InvalidAccessTokenError);try{const i=await O.post(this.backendUrl.concat("/getcustomerinfo"),{mode:"selection",api_keys:[t]},{headers:{Authorization:`Bearer ${s}`}});return((r=i.data)==null?void 0:r.success)===!1&&N.throwKnownError(b.NoScanDataError),i.data}catch(i){console.error("Error getting results:",i),N.handleErrorResponse(i)}}async checkResults(t,s){try{s||N.throwKnownError(b.InvalidAccessTokenError);const o=(await O.post(this.backendUrl.concat("/check"),{api_key:t},{headers:{Authorization:`Bearer ${s}`}})).data.job_status;return o==="Completed"||o==="Failed"?o:"Pending"}catch(r){N.handleErrorResponse(r)}}}class A_ extends yc{constructor(e,t){super(e,t),this.backendUrl=Mn("serverless")}async getToken(){try{const e=await O.post(this.backendUrl.concat("/user/login"),{username:this.username,password:this.password});if(e.data.success===!1)N.throwKnownError(b.InvalidUsernameError);else return JSON.parse(e.data.body).idToken}catch(e){console.error("error printed in serverless repository",e),N.handleErrorResponse(e)}}async getAPIKey(e){e||N.throwKnownError(b.InvalidAccessTokenError);try{return(await O.post(this.backendUrl.concat("/get-redirection-url"),{host_name:"www.nervoscan.com",username:this.username},{headers:{Authorization:`Bearer ${e}`}})).data.url.split("?api_key=")[1]}catch(t){N.handleErrorResponse(t)}}async uploadVideoToServer(e,t,s){(!t||!s)&&N.throwKnownError(b.InvalidAccessTokenError);try{const r=await this.generatePreSignedUrl(s);return r||N.throwKnownError(b.InvalidAccessTokenError),await this.uploadVideoToS3(e,r)}catch(r){throw console.error("Error uploading video:",r),r.response?(console.error("Error response:",r.response.data),console.error("Error status:",r.response.status),console.error("Error headers:",r.response.headers)):r.request?console.error("Error request:",r.request):console.error("Error message:",r.message),r}}getResults(e,t){return console.log("not implemented"),Promise.resolve(void 0)}async checkResults(e,t){try{t||N.throwKnownError(b.InvalidAccessTokenError);const i=(await O.post(this.backendUrl.concat("/check"),{api_key:e},{headers:{Authorization:`Bearer ${t}`}})).data.job_status;return i==="Completed"||i==="Failed"?i:"Pending"}catch(s){N.handleErrorResponse(s)}}async generatePreSignedUrl(e){try{return(await O.get(this.backendUrl.concat("/generate-presigned-url?job_id="+e))).data.upload_url}catch(t){N.handleErrorResponse(t)}}async uploadVideoToS3(e,t){try{return(await O.put(t,e,{headers:{"Content-Type":"video/mp4"}})).data}catch(s){N.handleErrorResponse(s)}}}var k_="firebase",O_="11.6.1";/**
1584
+ */function I_(n){wd(cd),un(new pt("database",(e,{instanceIdentifier:t})=>{const s=e.getProvider("app").getImmediate(),r=e.getProvider("auth-internal"),i=e.getProvider("app-check-internal");return b_(s,r,i,t)},"PUBLIC").setMultipleInstances(!0)),Ge(vo,bo,n),Ge(vo,bo,"esm2017")}me.prototype.simpleListen=function(n,e){this.sendRequest("q",{p:n},e)},me.prototype.echo=function(n,e){this.sendRequest("echo",{d:n},e)},I_();const Mn=n=>n==="server"?"https://backend.nervoscan.com":"https://backendv2-dev.nervoscan.com",Ue=class Ue{constructor(){L(this,"socket");L(this,"backendUrl",Mn("server"));L(this,"videoStream");L(this,"videoElement");L(this,"isConnected",!1);L(this,"isStreaming",!1);L(this,"jobId");L(this,"onDisconnection");L(this,"playHandler",()=>{if(!this.videoElement)return;const e=document.createElement("canvas");e.width=this.videoElement.videoWidth,e.height=this.videoElement.videoHeight,this.captureAndSendFrame(e,this.videoElement)});L(this,"stopStreaming",()=>{this.isStreaming=!1,this.removePlayEventListener()})}static getInstance(){return Ue.instance||(Ue.instance=new Ue),Ue.instance}async setupWebSocketConnection(){return new Promise((e,t)=>{if(this.socket)return console.warn("Socket already connected, skipping connection"),e(!0);this.socket=sn(this.backendUrl,{transports:["websocket","polling"]}),this.socket.once("connect",()=>{this.isConnected=!0,e(!0)}),this.socket.once("connect_error",s=>{t(b.ConnectionLostError)}),this.socket.once("disconnect",s=>{this.handleSocketDisconnection(s)})})}handleSocketDisconnection(e){this.isConnected=!1,console.warn("Disconnected from WebSocket server:",e)}async initializeStreaming(e,t){await this.setupWebSocketConnection(),this.videoStream=e,this.videoElement=t,this.videoElement.srcObject=e}startStreaming(e){var t;this.jobId=e,(t=this.socket)==null||t.emit("register",e),this.sendInitialRequest(e),this.isStreaming=!0,this.startVideoStream(),this.addDisconnectionListener()}async sendInitialRequest(e){await O.post(`${this.backendUrl}/react`,{username:e,uuid:e,device_id:"1234567",face_detector:"BlazefaceFacemesh",motion_tracking:!0,skin_segmentor:"HSVandYCrCbSkinSegmentation",extreme_pixel_removal:!1,gamma_value:1,eularian_color_magnification:!1},{headers:{"Content-Type":"application/json"}})}startVideoStream(){this.videoElement?(this.videoElement.addEventListener("play",this.playHandler),!this.videoElement.paused&&!this.videoElement.ended&&this.playHandler(),this.videoElement.play().then(()=>{}).catch(e=>console.error("Error starting video stream:",e))):console.error("Video stream not found when trying to start streaming")}captureAndSendFrame(e,t){let s=!1;const r=e.getContext("2d");if(!r)return;const i=()=>{if(this.isStreaming){if(s){setTimeout(i,33);return}!t.paused&&!t.ended&&(r.drawImage(t,0,0,640,480),s=!0,e.toBlob(o=>{if(!o)return;const a=new FileReader;a.onloadend=()=>{var c;if(this.isConnected&&this.isStreaming){const l=a.result;(c=this.socket)==null||c.emit("frame",l),s=!1,setTimeout(i,33)}},a.readAsArrayBuffer(o)},"image/jpeg",.7))}};i()}removePlayEventListener(){this.videoElement&&this.videoElement.removeEventListener("play",this.playHandler)}setOnDisconnection(e){this.onDisconnection=e}addDisconnectionListener(){const e=Fn(),t=Bt(e,`${this.jobId}/disconnect`),s=Ln(t,r=>{r.val()!=null&&(this.stopStreaming(),this.onDisconnection&&this.onDisconnection(),s())})}};L(Ue,"instance");let Bn=Ue;class yc{constructor(e,t){L(this,"backendUrl",Mn("server"));L(this,"username");L(this,"password");L(this,"streamingManager",Bn.getInstance());this.username=e,this.password=t}}class N_ extends yc{constructor(t,s){super(t,s);L(this,"streamingManager",Bn.getInstance());this.backendUrl=Mn("server")}async getToken(){try{return(await O.post(this.backendUrl.concat("/clientlogin"),{username:this.username,password:this.password})).data.access_token}catch(t){N.handleErrorResponse(t)}}async getAPIKey(t){t||N.throwKnownError(b.InvalidAccessTokenError);try{return(await O.post(this.backendUrl.concat("/clientgeturl"),{host_name:"www.nervoscan.com"},{headers:{Authorization:`Bearer ${t}`}})).data.url.split("?api_key=")[1]}catch(s){N.handleErrorResponse(s)}}async uploadVideoToServer(t,s,r){(!s||!r)&&N.throwKnownError(b.InvalidAccessTokenError);const i=new FormData;i.append("file",t,"recording.webm"),i.append("data",JSON.stringify({uuid:r,meta_data:{}}));const a=await(await fetch(this.backendUrl.concat("/submitscan"),{method:"POST",headers:{Authorization:`Bearer ${s}`},body:i})).json();return a.success===!1&&N.handleErrorResponse(a),a}async getResults(t,s){var r;s||N.throwKnownError(b.InvalidAccessTokenError);try{const i=await O.post(this.backendUrl.concat("/getcustomerinfo"),{mode:"selection",api_keys:[t]},{headers:{Authorization:`Bearer ${s}`}});return((r=i.data)==null?void 0:r.success)===!1&&N.throwKnownError(b.NoScanDataError),i.data}catch(i){console.error("Error getting results:",i),N.handleErrorResponse(i)}}async checkResults(t,s){try{s||N.throwKnownError(b.InvalidAccessTokenError);const o=(await O.post(this.backendUrl.concat("/check"),{api_key:t},{headers:{Authorization:`Bearer ${s}`}})).data.job_status;return o==="Completed"||o==="Failed"?o:"Pending"}catch(r){N.handleErrorResponse(r)}}}class A_ extends yc{constructor(e,t){super(e,t),this.backendUrl=Mn("serverless")}async getToken(){try{const e=await O.post(this.backendUrl.concat("/user/login"),{username:this.username,password:this.password});if(e.data.success===!1)N.throwKnownError(b.InvalidUsernameError);else return JSON.parse(e.data.body).idToken}catch(e){console.error("error printed in serverless repository",e),N.handleErrorResponse(e)}}async getAPIKey(e){e||N.throwKnownError(b.InvalidAccessTokenError);try{return(await O.post(this.backendUrl.concat("/get-redirection-url"),{host_name:"www.nervoscan.com",username:this.username},{headers:{Authorization:`Bearer ${e}`}})).data.url.split("?api_key=")[1]}catch(t){N.handleErrorResponse(t)}}async uploadVideoToServer(e,t,s){(!t||!s)&&N.throwKnownError(b.InvalidAccessTokenError);try{const r=await this.generatePreSignedUrl(s);return r||N.throwKnownError(b.InvalidAccessTokenError),await this.uploadVideoToS3(e,r)}catch(r){throw console.error("Error uploading video:",r),r.response?(console.error("Error response:",r.response.data),console.error("Error status:",r.response.status),console.error("Error headers:",r.response.headers)):r.request?console.error("Error request:",r.request):console.error("Error message:",r.message),r}}getResults(e,t){return console.log("not implemented"),Promise.resolve(void 0)}async checkResults(e,t){try{t||N.throwKnownError(b.InvalidAccessTokenError);const i=(await O.post(this.backendUrl.concat("/check"),{api_key:e},{headers:{Authorization:`Bearer ${t}`}})).data.job_status;return i==="Completed"||i==="Failed"?i:"Pending"}catch(s){N.handleErrorResponse(s)}}async generatePreSignedUrl(e){try{return(await O.get(this.backendUrl.concat("/generate-presigned-url?job_id="+e))).data.upload_url}catch(t){N.handleErrorResponse(t)}}async uploadVideoToS3(e,t){try{return(await O.put(t,e,{headers:{"Content-Type":"video/mp4"}})).data}catch(s){N.handleErrorResponse(s)}}}var k_="firebase",O_="11.6.1";/**
1585
1585
  * @license
1586
1586
  * Copyright 2020 Google LLC
1587
1587
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nervoscan-js-sdk",
3
- "version": "1.0.7",
3
+ "version": "1.0.8-0",
4
4
  "main": "dist/nervoscan-js-sdk.umd.js",
5
5
  "module": "dist/nervoscan-js-sdk.mjs",
6
6
  "types": "dist/types/index.d.ts",
@@ -105,6 +105,7 @@ export class ServerStreamingManager {
105
105
  }
106
106
 
107
107
  private captureAndSendFrame(canvas: HTMLCanvasElement, videoElement: HTMLVideoElement) {
108
+ let sending = false;
108
109
  const context = canvas.getContext('2d');
109
110
  if (!context) return;
110
111
 
@@ -112,29 +113,33 @@ export class ServerStreamingManager {
112
113
  if (!this.isStreaming) {
113
114
  return;
114
115
  }
116
+ if (sending) {
117
+ setTimeout(captureFrame, 33);
118
+ return;
119
+ }
115
120
  if (!videoElement.paused && !videoElement.ended) {
116
121
  context.drawImage(videoElement, 0, 0, 640, 480);
117
- this.sendFrameToBackend(canvas);
122
+ sending = true;
123
+ canvas.toBlob((blob) => {
124
+ if (!blob) return;
125
+ const reader = new FileReader();
126
+ reader.onloadend = () => {
127
+ if (this.isConnected && this.isStreaming) {
128
+ const arrayBuffer = reader.result;
129
+ this.socket?.emit('frame', arrayBuffer);
130
+ sending = false;
131
+ setTimeout(captureFrame, 33);
132
+ }
133
+ };
134
+ reader.readAsArrayBuffer(blob); // read the blob as an array buffer
135
+ }, 'image/jpeg', 0.7);
118
136
  }
119
- setTimeout(captureFrame, 33); // Capture frame every 33ms
137
+
120
138
  };
121
139
 
122
140
  captureFrame();
123
141
  };
124
142
 
125
- private sendFrameToBackend(canvas: HTMLCanvasElement) {
126
- canvas.toBlob((blob) => {
127
- if (!blob) return;
128
- const reader = new FileReader();
129
- reader.onloadend = () => {
130
- if (this.isConnected && this.isStreaming) {
131
- const arrayBuffer = reader.result;
132
- this.socket?.emit('frame', arrayBuffer);
133
- }
134
- };
135
- reader.readAsArrayBuffer(blob);
136
- }, 'image/jpeg', 0.7);
137
- };
138
143
 
139
144
  public stopStreaming = () => {
140
145
  this.isStreaming = false;